From c442f82153a350f8b2dcc508325ea0618fcbfc8b Mon Sep 17 00:00:00 2001 From: P Date: Sat, 7 Mar 2026 22:49:06 +0200 Subject: [PATCH 1/3] feat: brand APIs --- smithy/model/brand/brand-apis.smithy | 76 +++++++++++++++++++++++++++ smithy/model/brand/brand-io.smithy | 36 +++++++++++++ smithy/model/brand/brand-types.smithy | 19 +++++++ smithy/model/common.smithy | 8 +++ smithy/model/main.smithy | 6 ++- 5 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 smithy/model/brand/brand-apis.smithy create mode 100644 smithy/model/brand/brand-io.smithy create mode 100644 smithy/model/brand/brand-types.smithy diff --git a/smithy/model/brand/brand-apis.smithy b/smithy/model/brand/brand-apis.smithy new file mode 100644 index 0000000..749ad33 --- /dev/null +++ b/smithy/model/brand/brand-apis.smithy @@ -0,0 +1,76 @@ +$version: "2" + +namespace com.shopping.inandout.brand + +use com.shopping.inandout#DeleteRestrictedError +use com.shopping.inandout#ImageUrl +use com.shopping.inandout#InternalServerError +use com.shopping.inandout#InvalidInputError +use com.shopping.inandout#ResourceAlreadyExistsError +use com.shopping.inandout#ResourceName +use com.shopping.inandout#ResourceNotFoundError +use com.shopping.inandout#UUID + +resource Brand { + identifiers: { + brandId: UUID + } + properties: { + name: ResourceName + logoUrl: ImageUrl + createdAt: Timestamp + updatedAt: Timestamp + } + create: CreateBrand + read: GetBrand + update: UpdateBrand + delete: DeleteBrand +} + +@http(method: "POST", uri: "/brands") +operation CreateBrand { + input: CreateBrandInput + output: BrandSummary + errors: [ + InvalidInputError + ResourceAlreadyExistsError + InternalServerError + ] +} + +@readonly +@http(method: "GET", uri: "/brands/{brandId}") +operation GetBrand { + input: GetBrandInput + output: BrandSummary + errors: [ + InvalidInputError + ResourceNotFoundError + InternalServerError + ] +} + +@http(method: "PATCH", uri: "/brands/{brandId}") +operation UpdateBrand { + input: UpdateBrandInput + output: BrandSummary + errors: [ + InvalidInputError + ResourceNotFoundError + InternalServerError + ] +} + +@idempotent +@http(method: "DELETE", uri: "/brands/{brandId}") +@documentation("Restricted cascading operation, references for stores and articles should NOT exist") +operation DeleteBrand { + input: DeleteBrandInput + output: BrandSummary + errors: [ + InvalidInputError + ResourceNotFoundError + DeleteRestrictedError + InternalServerError + ] +} diff --git a/smithy/model/brand/brand-io.smithy b/smithy/model/brand/brand-io.smithy new file mode 100644 index 0000000..1e77ef9 --- /dev/null +++ b/smithy/model/brand/brand-io.smithy @@ -0,0 +1,36 @@ +$version: "2" + +namespace com.shopping.inandout.brand + +use com.shopping.inandout#ImageUrl +use com.shopping.inandout#ResourceName +use com.shopping.inandout#UUID + +structure CreateBrandInput { + @required + name: ResourceName + + logoUrl: ImageUrl +} + +structure GetBrandInput { + @required + @httpLabel + brandId: UUID +} + +structure UpdateBrandInput { + @required + @httpLabel + brandId: UUID + + name: ResourceName + + logoUrl: ImageUrl +} + +structure DeleteBrandInput { + @required + @httpLabel + brandId: UUID +} diff --git a/smithy/model/brand/brand-types.smithy b/smithy/model/brand/brand-types.smithy new file mode 100644 index 0000000..389ed27 --- /dev/null +++ b/smithy/model/brand/brand-types.smithy @@ -0,0 +1,19 @@ +$version: "2" + +namespace com.shopping.inandout.brand + +use com.shopping.inandout#ImageUrl +use com.shopping.inandout#ResourceName + +structure BrandSummary { + @required + name: ResourceName + + logoUrl: ImageUrl + + @required + createdAt: Timestamp + + @required + updatedAt: Timestamp +} diff --git a/smithy/model/common.smithy b/smithy/model/common.smithy index 90426d1..34d0b92 100644 --- a/smithy/model/common.smithy +++ b/smithy/model/common.smithy @@ -9,3 +9,11 @@ string UUID list UUIDList { member: UUID } + +@pattern("^[a-zA-Z0-9\\- ]+$") +@length(min: 3, max: 63) +string ResourceName + +@pattern("^https?://[a-zA-Z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]+\\.(jpg|jpeg|png|gif)$") +@length(min: 8, max: 255) +string ImageUrl diff --git a/smithy/model/main.smithy b/smithy/model/main.smithy index adae545..4e67665 100644 --- a/smithy/model/main.smithy +++ b/smithy/model/main.smithy @@ -2,12 +2,16 @@ $version: "2" namespace com.shopping.inandout -use com.shopping.inandout.tsp#FindTspSolution use aws.protocols#restJson1 +use com.shopping.inandout.brand#Brand +use com.shopping.inandout.tsp#FindTspSolution @restJson1 service InAndOut { version: "2026-04-01" + resources: [ + Brand + ] operations: [ FindTspSolution ] From fa4626dcd52bbce38b195e1203c71116b1fc63fd Mon Sep 17 00:00:00 2001 From: P Date: Sat, 7 Mar 2026 23:08:41 +0200 Subject: [PATCH 2/3] fix: added brandId to output operations --- smithy/model/brand/brand-types.smithy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smithy/model/brand/brand-types.smithy b/smithy/model/brand/brand-types.smithy index 389ed27..40cdeb1 100644 --- a/smithy/model/brand/brand-types.smithy +++ b/smithy/model/brand/brand-types.smithy @@ -4,8 +4,13 @@ namespace com.shopping.inandout.brand use com.shopping.inandout#ImageUrl use com.shopping.inandout#ResourceName +use com.shopping.inandout#UUID structure BrandSummary { + @required + @resourceIdentifier("brandId") + brandId: UUID + @required name: ResourceName From 59537ba796e247a58d7d7dac839ab7be62f568c1 Mon Sep 17 00:00:00 2001 From: P Date: Sat, 7 Mar 2026 23:12:16 +0200 Subject: [PATCH 3/3] removed useless trait --- smithy/model/brand/brand-types.smithy | 1 - 1 file changed, 1 deletion(-) diff --git a/smithy/model/brand/brand-types.smithy b/smithy/model/brand/brand-types.smithy index 40cdeb1..04f8cbc 100644 --- a/smithy/model/brand/brand-types.smithy +++ b/smithy/model/brand/brand-types.smithy @@ -8,7 +8,6 @@ use com.shopping.inandout#UUID structure BrandSummary { @required - @resourceIdentifier("brandId") brandId: UUID @required