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
7 changes: 3 additions & 4 deletions generate_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ QUICKTYPE_ARGS=(
--src "$SPEC_DIR"/discovery/*.json
--src "$SPEC_DIR/schemas/shopping/checkout.create_req.json"
--src "$SPEC_DIR/schemas/shopping/checkout.update_req.json"
--src "$SPEC_DIR/schemas/shopping/checkout.complete_req.json"
--src "$SPEC_DIR/schemas/shopping/checkout_resp.json"
--src "$SPEC_DIR/schemas/shopping/order.json"
--src "$SPEC_DIR/schemas/shopping/payment.create_req.json"
--src "$SPEC_DIR/schemas/shopping/payment.update_req.json"
--src "$SPEC_DIR/schemas/shopping/payment.complete_req.json"
--src "$SPEC_DIR/schemas/shopping/payment_data.json"
--src "$SPEC_DIR/schemas/shopping/payment_resp.json"
--src "$SPEC_DIR/schemas/shopping/ap2_mandate.json#/\$defs/complete_request_with_ap2"
Expand All @@ -82,10 +84,7 @@ QUICKTYPE_ARGS=(
--src "$SPEC_DIR/schemas/shopping/catalog_lookup.json#/\$defs/get_product_response"
--src "$SPEC_DIR/schemas/shopping/catalog_search.json#/\$defs/search_request"
--src "$SPEC_DIR/schemas/shopping/catalog_search.json#/\$defs/search_response"
--src "$SPEC_DIR/schemas/shopping/split_payments.json#/\$defs/instrument_group"
--src "$SPEC_DIR/schemas/shopping/split_payments.json#/\$defs/payment_instrument"
--src "$SPEC_DIR/schemas/shopping/split_payments.json#/\$defs/dev.ucp.shopping.checkout"
--src "$SPEC_DIR/schemas/shopping/split_payments.json#/\$defs/dev.ucp.shopping.split_payments"

-o "$TMP_OUTPUT"
)

Expand Down
19 changes: 11 additions & 8 deletions scripts/project-current-ucp-schemas.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ const topLevelVariantMap = {
"shopping/checkout.json": {
create: "shopping/checkout.create_req.json",
update: "shopping/checkout.update_req.json",
complete: "shopping/checkout.complete_req.json",
response: "shopping/checkout_resp.json",
},
"shopping/payment.json": {
create: "shopping/payment.create_req.json",
update: "shopping/payment.update_req.json",
complete: "shopping/payment.complete_req.json",
response: "shopping/payment_resp.json",
},
"shopping/order.json": {
Expand Down Expand Up @@ -87,9 +89,6 @@ const topLevelVariantMap = {
"shopping/catalog_search.json": {
response: "shopping/catalog_search.json",
},
"shopping/split_payments.json": {
response: "shopping/split_payments.json",
},
};

const alwaysUnifiedTypeFiles = new Set([
Expand All @@ -102,7 +101,6 @@ const alwaysUnifiedTypeFiles = new Set([
"binding",
"buyer",
"business_fulfillment_config",
"business_split_payments_config",
"card_credential",
"card_payment_instrument",
"category",
Expand All @@ -119,8 +117,6 @@ const alwaysUnifiedTypeFiles = new Set([
"fulfillment_option",
"fulfillment_option_base",
"input_correlation",
"instrument_group",
"line_item",
"link",
"media",
"merchant_fulfillment_config",
Expand Down Expand Up @@ -380,6 +376,10 @@ function titleSuffixForOutput(outputRel) {
return "Update Request";
}

if (outputRel.endsWith(".complete_req.json")) {
return "Complete Request";
}

if (outputRel.endsWith("_req.json")) {
return "Request";
}
Expand Down Expand Up @@ -596,8 +596,11 @@ function writeCompatibilityDiscoverySchemas() {
required: ["capabilities", "version"],
properties: {
capabilities: {
type: "array",
items: { $ref: "capability_response.json" },
type: "object",
additionalProperties: {
type: "array",
items: { $ref: "capability_response.json" },
},
},
version: { type: "string" },
},
Expand Down
14 changes: 2 additions & 12 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
CheckoutWithFulfillmentUpdateRequestSchema,
OrderSchema,
PaymentCredentialSchema,
PaymentSplitPaymentsSchema,
} from "./spec_generated";

export const ExtendedPaymentCredentialSchema = PaymentCredentialSchema.extend({
Expand All @@ -37,9 +36,6 @@ export const ExtendedCheckoutResponseSchema = CheckoutResponseSchema.extend(
.extend(CheckoutWithDiscountResponseSchema.pick({ discounts: true }).shape)
.extend(CheckoutWithBuyerConsentResponseSchema.pick({ buyer: true }).shape)
.extend({
payment: PaymentSplitPaymentsSchema.optional(),
order_id: z.string().optional(),
order_permalink_url: z.string().optional(),
platform: PlatformConfigSchema.optional(),
});
export type ExtendedCheckoutResponse = z.infer<
Expand All @@ -56,10 +52,7 @@ export const ExtendedCheckoutCreateRequestSchema =
.extend(
CheckoutWithBuyerConsentCreateRequestSchema.pick({ buyer: true }).shape
)
.extend(CheckoutWithCartCreateRequestSchema.pick({ cart_id: true }).shape)
.extend({
payment: PaymentSplitPaymentsSchema.optional(),
});
.extend(CheckoutWithCartCreateRequestSchema.pick({ cart_id: true }).shape);
export type ExtendedCheckoutCreateRequest = z.infer<
typeof ExtendedCheckoutCreateRequestSchema
>;
Expand All @@ -73,10 +66,7 @@ export const ExtendedCheckoutUpdateRequestSchema =
)
.extend(
CheckoutWithBuyerConsentUpdateRequestSchema.pick({ buyer: true }).shape
)
.extend({
payment: PaymentSplitPaymentsSchema.optional(),
});
);
export type ExtendedCheckoutUpdateRequest = z.infer<
typeof ExtendedCheckoutUpdateRequestSchema
>;
Expand Down
Loading
Loading