Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions smithy/model/common.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,93 @@ string ResourceName
@pattern("^https?://[a-zA-Z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=%]+\\.(jpg|jpeg|png|gif)$")
@length(min: 8, max: 255)
string ImageUrl

@pattern("^[a-zA-Z0-9\\-, ]+$")
@length(min: 8, max: 255)
string Description

@range(min: 0, max: 100)
double Percentage

@range(min: 0)
integer NaturalNumber

@range(min: 0)
double PositiveDouble

@range(min: -180, max: 180)
double Longitude

@range(min: -90, max: 90)
double Latitude

structure GeoCoordinates {
@required
longitude: Longitude

@required
latitude: Latitude
}

enum DayType {
MON = "MON"
TUE = "TUE"
WED = "WED"
THU = "THU"
FRI = "FRI"
SAT = "SAT"
SUN = "SUN"
}

// All UTC offsets fall between this interval: [-12, 14].
// Doubles are better suited since zones like `UTC+12:45` exist.
// See: https://en.wikipedia.org/wiki/List_of_UTC_offsets.
@range(min: -12, max: 14)
@documentation("UTC offsets for various globe zones")
double Timezone

@range(min: 0, max: 59)
integer Minute

@range(min: 0, max: 23)
integer Hour

structure Time {
@required
hour: Hour

@required
minute: Minute
}

structure TimeRange {
@required
begin: Time

@required
end: Time
}

@mixin
@documentation("Parameters sent by the client to control pagination of the list results")
structure InputPagination {
@httpQuery("nextToken")
@documentation("An id used to retrieve the next page of results; leave empty for the first request")
nextToken: String

@httpQuery("pageSize")
@default(100)
@documentation("The maximum number of items the client is requesting to be returned in this page")
pageSize: NaturalNumber
}

@mixin
@documentation("Metadata returned to the client to assist in navigating paginated results")
structure OutputPagination {
@documentation("An id to be passed in the subsequent request to retrieve the next page; null if no more pages exist")
nextToken: String

@required
@documentation("The actual number of items returned in the current response page.")
tokenCount: NaturalNumber
}
3 changes: 3 additions & 0 deletions smithy/model/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ namespace com.shopping.inandout

use aws.protocols#restJson1
use com.shopping.inandout.brand#Brand
use com.shopping.inandout.store#Store
use com.shopping.inandout.tsp#FindTspSolution

@restJson1
@paginated(inputToken: "nextToken", outputToken: "nextToken", pageSize: "pageSize", items: "tokens")
service InAndOut {
version: "2026-04-01"
resources: [
Brand
Store
]
operations: [
FindTspSolution
Expand Down
95 changes: 95 additions & 0 deletions smithy/model/store/store-apis.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
$version: "2"

namespace com.shopping.inandout.store

use com.shopping.inandout#Description
use com.shopping.inandout#GeoCoordinates
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#Timezone
use com.shopping.inandout#UUID

resource Store {
identifiers: {
storeId: UUID
}
properties: {
name: ResourceName
brandId: UUID
description: Description
imageUrl: ImageUrl
geoCoordinates: GeoCoordinates
operatingHoursMap: OperatingHoursMap
timezone: Timezone
createdAt: Timestamp
updatedAt: Timestamp
}
create: CreateStore
read: GetStore
list: ListStores
update: UpdateStore
delete: DeleteStore
}

@http(method: "POST", uri: "/stores")
operation CreateStore {
input: CreateStoreInput
output: StoreSummary
errors: [
InvalidInputError
ResourceAlreadyExistsError
InternalServerError
]
}

@readonly
@http(method: "GET", uri: "/stores/{storeId}")
operation GetStore {
input: GetStoreInput
output: StoreSummary
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@readonly
@paginated
@http(method: "GET", uri: "/stores")
operation ListStores {
input: ListStoresInput
output: StoreSummaries
errors: [
InvalidInputError
InternalServerError
]
}

@http(method: "PATCH", uri: "/stores/{storeId}")
operation UpdateStore {
input: UpdateStoreInput
output: StoreSummary
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@idempotent
@http(method: "DELETE", uri: "/stores/{storeId}")
@documentation("Not restricted cascading operation, deletes floors, stands, etc.")
operation DeleteStore {
input: DeleteStoreInput
output: StoreSummary
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}
93 changes: 93 additions & 0 deletions smithy/model/store/store-io.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
$version: "2"

namespace com.shopping.inandout.store

use com.shopping.inandout#Description
use com.shopping.inandout#GeoCoordinates
use com.shopping.inandout#ImageUrl
use com.shopping.inandout#InputPagination
use com.shopping.inandout#Latitude
use com.shopping.inandout#Longitude
use com.shopping.inandout#PositiveDouble
use com.shopping.inandout#ResourceName
use com.shopping.inandout#Timezone
use com.shopping.inandout#UUID
use com.shopping.inandout.brand#Brand

@references([
{
resource: Brand
}
])
structure CreateStoreInput {
name: ResourceName

@required
brandId: UUID

description: Description

imageUrl: ImageUrl

timezone: Timezone

operatingHoursMap: OperatingHoursMap

geoCoordinates: GeoCoordinates
}

structure GetStoreInput {
@required
@httpLabel
storeId: UUID
}

structure ListStoresInput with [InputPagination] {
@httpQuery("name")
name: ResourceName

@httpQuery("isOpen")
isOpen: Boolean

@httpQuery("userLongitude")
userLongitude: Longitude

@httpQuery("userLatitude")
userLatitude: Latitude

// ! User location must be provided in order for the below queries to work.
@httpQuery("maxDistance")
@documentation("Distance measured in kilometers")
maxDistance: PositiveDouble
}

@references([
{
resource: Brand
}
])
structure UpdateStoreInput {
@required
@httpLabel
storeId: UUID

name: ResourceName

brandId: UUID

description: Description

imageUrl: ImageUrl

timezone: Timezone

operatingHoursMap: OperatingHoursMap

geoCoordinates: GeoCoordinates
}

structure DeleteStoreInput {
@required
@httpLabel
storeId: UUID
}
59 changes: 59 additions & 0 deletions smithy/model/store/store-types.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$version: "2"

namespace com.shopping.inandout.store

use com.shopping.inandout#DayType
use com.shopping.inandout#Description
use com.shopping.inandout#GeoCoordinates
use com.shopping.inandout#ImageUrl
use com.shopping.inandout#OutputPagination
use com.shopping.inandout#ResourceName
use com.shopping.inandout#TimeRange
use com.shopping.inandout#Timezone
use com.shopping.inandout#UUID
use com.shopping.inandout.brand#Brand

map OperatingHoursMap {
key: DayType
value: TimeRange
}

@references([
{
resource: Brand
}
])
structure StoreSummary {
@required
storeId: UUID

name: ResourceName

@required
brandId: UUID

description: Description

imageUrl: ImageUrl

geoCoordinates: GeoCoordinates

operatingHoursMap: OperatingHoursMap

timezone: Timezone

@required
createdAt: Timestamp

@required
updatedAt: Timestamp
}

list StoreSummaryList {
member: StoreSummary
}

// This is needed since lists or other similar collections can not be used as input/output for operations.
structure StoreSummaries with [OutputPagination] {
tokens: StoreSummaryList
}