Skip to content

Commit

Permalink
Tighten itineraries-create request schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
konker committed Nov 23, 2023
1 parent 0f516b6 commit d66d2b2
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"$ref": "#/definitions/body"
}
},
"required": ["headers", "requestContext", "body"],
"definitions": {
"body": {
"type": "object",
Expand Down Expand Up @@ -55,7 +56,8 @@
}
}
}
}
},
"required": ["itinerary"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"$ref": "#/definitions/body"
}
},
"required": ["headers", "requestContext", "body"],
"definitions": {
"body": {
"type": "object",
Expand Down Expand Up @@ -55,7 +56,8 @@
}
}
}
}
},
"required": ["itinerary"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"$ref": "#/definitions/body"
}
},
"required": ["headers", "requestContext", "body"],
"definitions": {
"body": {
"type": "object",
Expand Down Expand Up @@ -58,7 +59,8 @@
}
}
}
}
},
"required": ["itinerary"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,67 +38,83 @@ export const schemaId =
// OutwardReturnWrapper
// The purpose of this remains a mystery
export type OutwardReturnWrapper = t.Branded<
{
({
itinerary?: Itinerary_8303_.Itinerary;
customerSelections?: Array<
{
ref?: ProductOptionV2_8170_.Ref;
customerSelection?: CustomerSelection_57c3_.CustomerSelection;
} & Record<string, unknown>
>;
} & Record<string, unknown>,
} & Record<string, unknown>) & {
itinerary: Defined;
},
OutwardReturnWrapperBrand
>;
export type OutwardReturnWrapperC = t.BrandC<
t.IntersectionC<
[
t.PartialC<{
itinerary: typeof Itinerary_8303_.Itinerary;
customerSelections: t.ArrayC<
t.IntersectionC<
[
t.PartialC<{
ref: typeof ProductOptionV2_8170_.Ref;
customerSelection: typeof CustomerSelection_57c3_.CustomerSelection;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>
>;
t.IntersectionC<
[
t.PartialC<{
itinerary: typeof Itinerary_8303_.Itinerary;
customerSelections: t.ArrayC<
t.IntersectionC<
[
t.PartialC<{
ref: typeof ProductOptionV2_8170_.Ref;
customerSelection: typeof CustomerSelection_57c3_.CustomerSelection;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>
>;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>,
t.TypeC<{
itinerary: typeof Defined;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>,
OutwardReturnWrapperBrand
>;
export const OutwardReturnWrapper: OutwardReturnWrapperC = t.brand(
t.intersection([
t.partial({
itinerary: Itinerary_8303_.Itinerary,
customerSelections: t.array(
t.intersection([
t.partial({
ref: ProductOptionV2_8170_.Ref,
customerSelection: CustomerSelection_57c3_.CustomerSelection,
}),
t.record(t.string, t.unknown),
]),
),
t.intersection([
t.partial({
itinerary: Itinerary_8303_.Itinerary,
customerSelections: t.array(
t.intersection([
t.partial({
ref: ProductOptionV2_8170_.Ref,
customerSelection: CustomerSelection_57c3_.CustomerSelection,
}),
t.record(t.string, t.unknown),
]),
),
}),
t.record(t.string, t.unknown),
]),
t.type({
itinerary: Defined,
}),
t.record(t.string, t.unknown),
]),
(
x,
): x is t.Branded<
{
({
itinerary?: Itinerary_8303_.Itinerary;
customerSelections?: Array<
{
ref?: ProductOptionV2_8170_.Ref;
customerSelection?: CustomerSelection_57c3_.CustomerSelection;
} & Record<string, unknown>
>;
} & Record<string, unknown>,
} & Record<string, unknown>) & {
itinerary: Defined;
},
OutwardReturnWrapperBrand
> => true,
'OutwardReturnWrapper',
Expand Down Expand Up @@ -178,30 +194,54 @@ export type RequestV1 = t.Branded<
headers?: ApiCommon_16a4_.StandardApiEndpointHeaders;
requestContext?: ApiCommon_16a4_.ApiGatewayAuthorizedRequestContext;
body?: Body;
} & {
headers: Defined;
requestContext: Defined;
body: Defined;
},
RequestV1Brand
>;
export type RequestV1C = t.BrandC<
t.PartialC<{
headers: typeof ApiCommon_16a4_.StandardApiEndpointHeaders;
requestContext: typeof ApiCommon_16a4_.ApiGatewayAuthorizedRequestContext;
body: typeof Body;
}>,
t.IntersectionC<
[
t.PartialC<{
headers: typeof ApiCommon_16a4_.StandardApiEndpointHeaders;
requestContext: typeof ApiCommon_16a4_.ApiGatewayAuthorizedRequestContext;
body: typeof Body;
}>,
t.TypeC<{
headers: typeof Defined;
requestContext: typeof Defined;
body: typeof Defined;
}>,
]
>,
RequestV1Brand
>;
export const RequestV1: RequestV1C = t.brand(
t.partial({
headers: ApiCommon_16a4_.StandardApiEndpointHeaders,
requestContext: ApiCommon_16a4_.ApiGatewayAuthorizedRequestContext,
body: Body,
}),
t.intersection([
t.partial({
headers: ApiCommon_16a4_.StandardApiEndpointHeaders,
requestContext: ApiCommon_16a4_.ApiGatewayAuthorizedRequestContext,
body: Body,
}),
t.type({
headers: Defined,
requestContext: Defined,
body: Defined,
}),
]),
(
x,
): x is t.Branded<
{
headers?: ApiCommon_16a4_.StandardApiEndpointHeaders;
requestContext?: ApiCommon_16a4_.ApiGatewayAuthorizedRequestContext;
body?: Body;
} & {
headers: Defined;
requestContext: Defined;
body: Defined;
},
RequestV1Brand
> => true,
Expand Down
Loading

0 comments on commit d66d2b2

Please sign in to comment.