@reactionary/core 0.0.80 → 0.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decorators/reactionary.decorator.js +2 -2
- package/initialization.js +0 -17
- package/package.json +1 -1
- package/providers/base.provider.js +1 -29
- package/providers/cart.provider.js +36 -3
- package/providers/inventory.provider.js +3 -2
- package/providers/order.provider.js +39 -3
- package/providers/price.provider.js +19 -12
- package/providers/product.provider.js +34 -11
- package/schemas/models/identifiers.model.js +35 -37
- package/schemas/models/identity.model.js +5 -5
- package/schemas/models/inventory.model.js +7 -5
- package/schemas/models/order.model.js +16 -16
- package/schemas/models/payment.model.js +10 -10
- package/schemas/models/price.model.js +7 -7
- package/schemas/models/product-search.model.js +15 -15
- package/schemas/models/product.model.js +32 -32
- package/schemas/models/profile.model.js +16 -16
- package/schemas/models/shipping-method.model.js +19 -19
- package/schemas/models/store.model.js +7 -4
- package/schemas/mutations/analytics.mutation.js +3 -3
- package/schemas/mutations/cart.mutation.js +19 -19
- package/schemas/mutations/checkout.mutation.js +10 -10
- package/schemas/mutations/profile.mutation.js +2 -2
- package/schemas/queries/cart.query.js +1 -1
- package/schemas/queries/category.query.js +6 -6
- package/schemas/queries/checkout.query.js +3 -3
- package/schemas/queries/inventory.query.js +3 -3
- package/schemas/queries/order.query.js +1 -1
- package/schemas/queries/price.query.js +2 -2
- package/schemas/queries/product-search.query.js +1 -1
- package/schemas/queries/product.query.js +4 -4
- package/schemas/queries/store.query.js +4 -4
- package/src/providers/analytics.provider.d.ts +1 -2
- package/src/providers/base.provider.d.ts +3 -22
- package/src/providers/cart.provider.d.ts +10 -10
- package/src/providers/category.provider.d.ts +7 -7
- package/src/providers/checkout.provider.d.ts +8 -8
- package/src/providers/identity.provider.d.ts +5 -5
- package/src/providers/inventory.provider.d.ts +3 -3
- package/src/providers/order.provider.d.ts +6 -6
- package/src/providers/price.provider.d.ts +5 -5
- package/src/providers/product-search.provider.d.ts +2 -2
- package/src/providers/product.provider.d.ts +5 -12
- package/src/providers/profile.provider.d.ts +3 -3
- package/src/providers/store.provider.d.ts +2 -2
- package/src/schemas/capabilities.schema.d.ts +2 -1
- package/src/schemas/models/analytics.model.d.ts +2 -1
- package/src/schemas/models/base.model.d.ts +6 -5
- package/src/schemas/models/cart.model.d.ts +53 -52
- package/src/schemas/models/category.model.d.ts +7 -6
- package/src/schemas/models/checkout.model.d.ts +94 -93
- package/src/schemas/models/cost.model.d.ts +33 -32
- package/src/schemas/models/currency.model.d.ts +2 -1
- package/src/schemas/models/identifiers.model.d.ts +80 -79
- package/src/schemas/models/identity.model.d.ts +23 -22
- package/src/schemas/models/inventory.model.d.ts +21 -12
- package/src/schemas/models/order.model.d.ts +140 -137
- package/src/schemas/models/payment.model.d.ts +31 -30
- package/src/schemas/models/price.model.d.ts +31 -30
- package/src/schemas/models/product-search.model.d.ts +118 -117
- package/src/schemas/models/product.model.d.ts +137 -136
- package/src/schemas/models/profile.model.d.ts +50 -49
- package/src/schemas/models/shipping-method.model.d.ts +42 -41
- package/src/schemas/models/store.model.d.ts +9 -8
- package/src/schemas/mutations/analytics.mutation.d.ts +48 -47
- package/src/schemas/mutations/base.mutation.d.ts +2 -1
- package/src/schemas/mutations/cart.mutation.d.ts +73 -72
- package/src/schemas/mutations/checkout.mutation.d.ts +96 -95
- package/src/schemas/mutations/identity.mutation.d.ts +4 -3
- package/src/schemas/mutations/profile.mutation.d.ts +4 -3
- package/src/schemas/queries/base.query.d.ts +2 -1
- package/src/schemas/queries/cart.query.d.ts +7 -7
- package/src/schemas/queries/category.query.d.ts +20 -19
- package/src/schemas/queries/checkout.query.d.ts +7 -6
- package/src/schemas/queries/identity.query.d.ts +2 -1
- package/src/schemas/queries/inventory.query.d.ts +8 -7
- package/src/schemas/queries/order.query.d.ts +3 -2
- package/src/schemas/queries/price.query.d.ts +5 -4
- package/src/schemas/queries/product-search.query.d.ts +12 -11
- package/src/schemas/queries/product.query.d.ts +14 -13
- package/src/schemas/queries/profile.query.d.ts +2 -1
- package/src/schemas/queries/store.query.d.ts +6 -5
- package/src/schemas/session.schema.d.ts +1 -1
- package/src/zod-utils.d.ts +5 -0
- package/zod-utils.js +0 -0
|
@@ -47,7 +47,7 @@ function Reactionary(options) {
|
|
|
47
47
|
return traceSpan(scope, async () => {
|
|
48
48
|
const input = validateInput(args[0], configuration.inputSchema);
|
|
49
49
|
const cacheKey = this.generateCacheKeyForQuery(scope, input);
|
|
50
|
-
const fromCache = await this.cache.get(cacheKey,
|
|
50
|
+
const fromCache = await this.cache.get(cacheKey, options.inputSchema);
|
|
51
51
|
let result = fromCache;
|
|
52
52
|
if (!result) {
|
|
53
53
|
result = await original.apply(this, [input]);
|
|
@@ -81,7 +81,7 @@ async function traceSpan(name, fn) {
|
|
|
81
81
|
const tracer = getTracer();
|
|
82
82
|
return tracer.startActiveSpan(name, async (span) => {
|
|
83
83
|
try {
|
|
84
|
-
return fn();
|
|
84
|
+
return await fn();
|
|
85
85
|
} catch (err) {
|
|
86
86
|
if (err instanceof Error) {
|
|
87
87
|
span.recordException(err);
|
package/initialization.js
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
function createInitialRequestContext() {
|
|
2
2
|
return {
|
|
3
|
-
id: "",
|
|
4
|
-
identity: {
|
|
5
|
-
type: "Anonymous",
|
|
6
|
-
meta: {
|
|
7
|
-
cache: { hit: false, key: "" },
|
|
8
|
-
placeholder: false
|
|
9
|
-
},
|
|
10
|
-
id: { userId: "anonymous-" + crypto.randomUUID().toString() },
|
|
11
|
-
token: void 0,
|
|
12
|
-
issued: /* @__PURE__ */ new Date(),
|
|
13
|
-
expiry: new Date((/* @__PURE__ */ new Date()).getTime() + 3600 * 1e3),
|
|
14
|
-
logonId: "",
|
|
15
|
-
createdAt: "",
|
|
16
|
-
updatedAt: "",
|
|
17
|
-
keyring: [],
|
|
18
|
-
currentService: void 0
|
|
19
|
-
},
|
|
20
3
|
languageContext: {
|
|
21
4
|
locale: "en",
|
|
22
5
|
currencyCode: "USD"
|
package/package.json
CHANGED
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createPaginatedResponseSchema
|
|
3
|
-
} from "../schemas/models/base.model.js";
|
|
4
1
|
import {} from "../schemas/session.schema.js";
|
|
5
2
|
import { hasher } from "node-object-hash";
|
|
6
3
|
class BaseProvider {
|
|
7
|
-
constructor(
|
|
8
|
-
this.schema = schema;
|
|
4
|
+
constructor(cache, context) {
|
|
9
5
|
this.cache = cache;
|
|
10
6
|
this.context = context;
|
|
11
7
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Validates that the final domain model constructed by the provider
|
|
14
|
-
* fulfills the schema as defined. This will throw an exception.
|
|
15
|
-
*/
|
|
16
|
-
assert(value) {
|
|
17
|
-
return this.schema.parse(value);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new model entity based on the schema defaults.
|
|
21
|
-
*/
|
|
22
|
-
newModel() {
|
|
23
|
-
return this.schema.parse({});
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Handler for parsing a response from a remote provider and converting it
|
|
27
|
-
* into the typed domain model.
|
|
28
|
-
*/
|
|
29
|
-
parseSingle(_body) {
|
|
30
|
-
const model = this.newModel();
|
|
31
|
-
return this.assert(model);
|
|
32
|
-
}
|
|
33
|
-
parsePaginatedResult(_body) {
|
|
34
|
-
return createPaginatedResponseSchema(this.schema).parse({});
|
|
35
|
-
}
|
|
36
8
|
generateDependencyIdsForModel(model) {
|
|
37
9
|
const identifier = model?.identifier;
|
|
38
10
|
if (!identifier) {
|
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
import { BaseProvider } from "./base.provider.js";
|
|
2
2
|
class CartProvider extends BaseProvider {
|
|
3
3
|
createEmptyCart() {
|
|
4
|
-
const cart =
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const cart = {
|
|
5
|
+
identifier: { key: "" },
|
|
6
|
+
meta: { placeholder: true, cache: { hit: true, key: "empty-cart" } },
|
|
7
|
+
description: "",
|
|
8
|
+
items: [],
|
|
9
|
+
name: "",
|
|
10
|
+
price: {
|
|
11
|
+
grandTotal: {
|
|
12
|
+
value: 0,
|
|
13
|
+
currency: "XXX"
|
|
14
|
+
},
|
|
15
|
+
totalDiscount: {
|
|
16
|
+
value: 0,
|
|
17
|
+
currency: "XXX"
|
|
18
|
+
},
|
|
19
|
+
totalProductPrice: {
|
|
20
|
+
value: 0,
|
|
21
|
+
currency: "XXX"
|
|
22
|
+
},
|
|
23
|
+
totalShipping: {
|
|
24
|
+
value: 0,
|
|
25
|
+
currency: "XXX"
|
|
26
|
+
},
|
|
27
|
+
totalSurcharge: {
|
|
28
|
+
value: 0,
|
|
29
|
+
currency: "XXX"
|
|
30
|
+
},
|
|
31
|
+
totalTax: {
|
|
32
|
+
value: 0,
|
|
33
|
+
currency: "XXX"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
userId: {
|
|
37
|
+
userId: ""
|
|
38
|
+
}
|
|
39
|
+
};
|
|
7
40
|
return cart;
|
|
8
41
|
}
|
|
9
42
|
getResourceName() {
|
|
@@ -4,7 +4,7 @@ class InventoryProvider extends BaseProvider {
|
|
|
4
4
|
return "inventory";
|
|
5
5
|
}
|
|
6
6
|
createEmptyInventory(key) {
|
|
7
|
-
|
|
7
|
+
const inventory = {
|
|
8
8
|
identifier: key,
|
|
9
9
|
quantity: 0,
|
|
10
10
|
status: "outOfStock",
|
|
@@ -15,7 +15,8 @@ class InventoryProvider extends BaseProvider {
|
|
|
15
15
|
},
|
|
16
16
|
placeholder: true
|
|
17
17
|
}
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
|
+
return inventory;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
export {
|
|
@@ -1,9 +1,45 @@
|
|
|
1
1
|
import { BaseProvider } from "./base.provider.js";
|
|
2
2
|
class OrderProvider extends BaseProvider {
|
|
3
3
|
createEmptyOrder() {
|
|
4
|
-
const order =
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const order = {
|
|
5
|
+
meta: { placeholder: true, cache: { hit: true, key: "empty-order" } },
|
|
6
|
+
identifier: {
|
|
7
|
+
key: ""
|
|
8
|
+
},
|
|
9
|
+
inventoryStatus: "NotAllocated",
|
|
10
|
+
items: [],
|
|
11
|
+
orderStatus: "AwaitingPayment",
|
|
12
|
+
paymentInstructions: [],
|
|
13
|
+
price: {
|
|
14
|
+
grandTotal: {
|
|
15
|
+
value: 0,
|
|
16
|
+
currency: "XXX"
|
|
17
|
+
},
|
|
18
|
+
totalDiscount: {
|
|
19
|
+
value: 0,
|
|
20
|
+
currency: "XXX"
|
|
21
|
+
},
|
|
22
|
+
totalProductPrice: {
|
|
23
|
+
value: 0,
|
|
24
|
+
currency: "XXX"
|
|
25
|
+
},
|
|
26
|
+
totalShipping: {
|
|
27
|
+
value: 0,
|
|
28
|
+
currency: "XXX"
|
|
29
|
+
},
|
|
30
|
+
totalSurcharge: {
|
|
31
|
+
value: 0,
|
|
32
|
+
currency: "XXX"
|
|
33
|
+
},
|
|
34
|
+
totalTax: {
|
|
35
|
+
value: 0,
|
|
36
|
+
currency: "XXX"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
userId: {
|
|
40
|
+
userId: ""
|
|
41
|
+
}
|
|
42
|
+
};
|
|
7
43
|
return order;
|
|
8
44
|
}
|
|
9
45
|
getResourceName() {
|
|
@@ -9,19 +9,26 @@ class PriceProvider extends BaseProvider {
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
createEmptyPriceResult(sku) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const price = {
|
|
13
|
+
identifier: {
|
|
14
|
+
variant: {
|
|
15
|
+
sku
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
tieredPrices: [],
|
|
19
|
+
unitPrice: {
|
|
20
|
+
value: -1,
|
|
21
|
+
currency: this.context.languageContext.currencyCode
|
|
22
|
+
},
|
|
23
|
+
meta: {
|
|
24
|
+
cache: {
|
|
25
|
+
hit: false,
|
|
26
|
+
key: `price-${sku}-${this.context.languageContext.currencyCode}`
|
|
27
|
+
},
|
|
28
|
+
placeholder: true
|
|
29
|
+
}
|
|
15
30
|
};
|
|
16
|
-
|
|
17
|
-
value: -1,
|
|
18
|
-
currency: this.context.languageContext.currencyCode
|
|
19
|
-
};
|
|
20
|
-
base.meta = {
|
|
21
|
-
cache: { hit: false, key: `price-${sku}-${this.context.languageContext.currencyCode}` },
|
|
22
|
-
placeholder: true
|
|
23
|
-
};
|
|
24
|
-
return this.assert(base);
|
|
31
|
+
return price;
|
|
25
32
|
}
|
|
26
33
|
getResourceName() {
|
|
27
34
|
return "price";
|
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
import { BaseProvider } from "./base.provider.js";
|
|
2
2
|
class ProductProvider extends BaseProvider {
|
|
3
|
-
/**
|
|
4
|
-
* Returns a set of Products for each variant. Is a paged response, to ensure we do not build in overfetching from the start.
|
|
5
|
-
*
|
|
6
|
-
* Usecase: You are rendering a variant-list on a b2b PDP page maybe, and it contains 500 variants. You do not want to fetch all 500 variants in one go.
|
|
7
|
-
* @param payload
|
|
8
|
-
* @param reqCtx
|
|
9
|
-
*/
|
|
10
|
-
// public abstract getVariantList(payload: ProductQueryVariants, reqCtx: RequestContext): Promise<typeof this.parsePaginatedResult>;
|
|
11
3
|
createEmptyProduct(id) {
|
|
12
|
-
const product =
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
const product = {
|
|
5
|
+
brand: "",
|
|
6
|
+
description: "",
|
|
7
|
+
identifier: {
|
|
8
|
+
key: id
|
|
9
|
+
},
|
|
10
|
+
longDescription: "",
|
|
11
|
+
mainVariant: {
|
|
12
|
+
barcode: "",
|
|
13
|
+
ean: "",
|
|
14
|
+
gtin: "",
|
|
15
|
+
identifier: {
|
|
16
|
+
sku: ""
|
|
17
|
+
},
|
|
18
|
+
images: [],
|
|
19
|
+
name: "",
|
|
20
|
+
options: [],
|
|
21
|
+
upc: ""
|
|
22
|
+
},
|
|
23
|
+
manufacturer: "",
|
|
24
|
+
meta: {
|
|
25
|
+
cache: {
|
|
26
|
+
hit: false,
|
|
27
|
+
key: ""
|
|
28
|
+
},
|
|
29
|
+
placeholder: false
|
|
30
|
+
},
|
|
31
|
+
name: "",
|
|
32
|
+
options: [],
|
|
33
|
+
parentCategories: [],
|
|
34
|
+
published: false,
|
|
35
|
+
sharedAttributes: [],
|
|
36
|
+
slug: ""
|
|
37
|
+
};
|
|
15
38
|
return product;
|
|
16
39
|
}
|
|
17
40
|
/**
|
|
@@ -1,95 +1,93 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PaginationOptionsSchema } from "./base.model.js";
|
|
3
3
|
const FacetIdentifierSchema = z.looseObject({
|
|
4
|
-
key: z.string()
|
|
4
|
+
key: z.string()
|
|
5
5
|
});
|
|
6
6
|
const FacetValueIdentifierSchema = z.object({
|
|
7
|
-
facet: FacetIdentifierSchema
|
|
8
|
-
key: z.string()
|
|
7
|
+
facet: FacetIdentifierSchema,
|
|
8
|
+
key: z.string()
|
|
9
9
|
});
|
|
10
10
|
const ProductVariantIdentifierSchema = z.looseObject({
|
|
11
|
-
sku: z.string()
|
|
11
|
+
sku: z.string()
|
|
12
12
|
});
|
|
13
13
|
const ProductAttributeIdentifierSchema = z.looseObject({
|
|
14
|
-
key: z.string().
|
|
14
|
+
key: z.string().describe("The unique identifier for the product attribute.")
|
|
15
15
|
});
|
|
16
16
|
const ProductAttributeValueIdentifierSchema = z.looseObject({
|
|
17
|
-
key: z.string().
|
|
17
|
+
key: z.string().describe("The unique identifier for the product attribute value.")
|
|
18
18
|
});
|
|
19
19
|
const ProductOptionIdentifierSchema = z.looseObject({
|
|
20
|
-
key: z.string().
|
|
20
|
+
key: z.string().describe("The unique identifier for the product option.")
|
|
21
21
|
});
|
|
22
22
|
const ProductOptionValueIdentifierSchema = z.looseObject({
|
|
23
|
-
option: ProductOptionIdentifierSchema
|
|
24
|
-
key: z.string().
|
|
23
|
+
option: ProductOptionIdentifierSchema,
|
|
24
|
+
key: z.string().describe('The value of the product option, e.g., "Red" or "Large".')
|
|
25
25
|
});
|
|
26
26
|
const ProductIdentifierSchema = z.looseObject({
|
|
27
|
-
key: z.string()
|
|
27
|
+
key: z.string()
|
|
28
28
|
});
|
|
29
29
|
const ProductSearchIdentifierSchema = z.looseObject({
|
|
30
|
-
term: z.string()
|
|
31
|
-
facets: z.array(FacetValueIdentifierSchema
|
|
32
|
-
filters: z.array(z.string())
|
|
33
|
-
paginationOptions: PaginationOptionsSchema
|
|
30
|
+
term: z.string(),
|
|
31
|
+
facets: z.array(FacetValueIdentifierSchema),
|
|
32
|
+
filters: z.array(z.string()),
|
|
33
|
+
paginationOptions: PaginationOptionsSchema
|
|
34
34
|
});
|
|
35
35
|
const CartIdentifierSchema = z.looseObject({
|
|
36
|
-
key: z.string()
|
|
36
|
+
key: z.string()
|
|
37
37
|
});
|
|
38
38
|
const CartItemIdentifierSchema = z.looseObject({
|
|
39
|
-
key: z.string()
|
|
39
|
+
key: z.string()
|
|
40
40
|
});
|
|
41
41
|
const PriceIdentifierSchema = z.looseObject({
|
|
42
|
-
variant: ProductVariantIdentifierSchema
|
|
42
|
+
variant: ProductVariantIdentifierSchema
|
|
43
43
|
});
|
|
44
44
|
const CategoryIdentifierSchema = z.looseObject({
|
|
45
|
-
key: z.string()
|
|
45
|
+
key: z.string()
|
|
46
46
|
});
|
|
47
47
|
const StoreIdentifierSchema = z.looseObject({
|
|
48
|
-
key: z.string()
|
|
48
|
+
key: z.string()
|
|
49
49
|
});
|
|
50
50
|
const OrderIdentifierSchema = z.looseObject({
|
|
51
|
-
key: z.string()
|
|
51
|
+
key: z.string()
|
|
52
52
|
});
|
|
53
53
|
const OrderItemIdentifierSchema = z.looseObject({
|
|
54
|
-
key: z.string()
|
|
54
|
+
key: z.string()
|
|
55
55
|
});
|
|
56
56
|
const CheckoutIdentifierSchema = z.looseObject({
|
|
57
|
-
key: z.string()
|
|
57
|
+
key: z.string()
|
|
58
58
|
});
|
|
59
59
|
const CheckoutItemIdentifierSchema = z.looseObject({
|
|
60
|
-
key: z.string()
|
|
60
|
+
key: z.string()
|
|
61
61
|
});
|
|
62
62
|
const WebStoreIdentifierSchema = z.looseObject({
|
|
63
|
-
key: z.string()
|
|
63
|
+
key: z.string()
|
|
64
64
|
});
|
|
65
65
|
const FulfillmentCenterIdentifierSchema = z.looseObject({
|
|
66
|
-
key: z.string()
|
|
66
|
+
key: z.string()
|
|
67
67
|
});
|
|
68
68
|
const InventoryIdentifierSchema = z.looseObject({
|
|
69
|
-
variant: ProductVariantIdentifierSchema
|
|
70
|
-
fulfillmentCenter: FulfillmentCenterIdentifierSchema
|
|
71
|
-
() => FulfillmentCenterIdentifierSchema.parse({})
|
|
72
|
-
)
|
|
69
|
+
variant: ProductVariantIdentifierSchema,
|
|
70
|
+
fulfillmentCenter: FulfillmentCenterIdentifierSchema
|
|
73
71
|
});
|
|
74
72
|
const IdentityIdentifierSchema = z.looseObject({
|
|
75
|
-
userId: z.string()
|
|
73
|
+
userId: z.string()
|
|
76
74
|
});
|
|
77
75
|
const ShippingMethodIdentifierSchema = z.looseObject({
|
|
78
|
-
key: z.string()
|
|
76
|
+
key: z.string()
|
|
79
77
|
});
|
|
80
78
|
const PaymentMethodIdentifierSchema = z.looseObject({
|
|
81
|
-
method: z.string()
|
|
82
|
-
name: z.string()
|
|
83
|
-
paymentProcessor: z.string()
|
|
79
|
+
method: z.string(),
|
|
80
|
+
name: z.string(),
|
|
81
|
+
paymentProcessor: z.string()
|
|
84
82
|
});
|
|
85
83
|
const AddressIdentifierSchema = z.looseObject({
|
|
86
|
-
nickName: z.string()
|
|
84
|
+
nickName: z.string()
|
|
87
85
|
});
|
|
88
86
|
const PaymentInstructionIdentifierSchema = z.looseObject({
|
|
89
|
-
key: z.string()
|
|
87
|
+
key: z.string()
|
|
90
88
|
});
|
|
91
89
|
const PickupPointIdentifierSchema = z.looseObject({
|
|
92
|
-
key: z.string()
|
|
90
|
+
key: z.string()
|
|
93
91
|
});
|
|
94
92
|
export {
|
|
95
93
|
AddressIdentifierSchema,
|
|
@@ -2,15 +2,15 @@ import { z } from "zod";
|
|
|
2
2
|
import { BaseModelSchema } from "./base.model.js";
|
|
3
3
|
import { IdentityIdentifierSchema } from "./identifiers.model.js";
|
|
4
4
|
const AnonymousIdentitySchema = BaseModelSchema.extend({
|
|
5
|
-
type: z.literal("Anonymous")
|
|
5
|
+
type: z.literal("Anonymous")
|
|
6
6
|
});
|
|
7
7
|
const GuestIdentitySchema = BaseModelSchema.extend({
|
|
8
|
-
id: IdentityIdentifierSchema
|
|
9
|
-
type: z.literal("Guest")
|
|
8
|
+
id: IdentityIdentifierSchema,
|
|
9
|
+
type: z.literal("Guest")
|
|
10
10
|
});
|
|
11
11
|
const RegisteredIdentitySchema = BaseModelSchema.extend({
|
|
12
|
-
id: IdentityIdentifierSchema
|
|
13
|
-
type: z.literal("Registered")
|
|
12
|
+
id: IdentityIdentifierSchema,
|
|
13
|
+
type: z.literal("Registered")
|
|
14
14
|
});
|
|
15
15
|
const IdentitySchema = z.discriminatedUnion("type", [AnonymousIdentitySchema, GuestIdentitySchema, RegisteredIdentitySchema]);
|
|
16
16
|
export {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { BaseModelSchema } from "./base.model.js";
|
|
3
|
-
import { InventoryIdentifierSchema
|
|
3
|
+
import { InventoryIdentifierSchema } from "./identifiers.model.js";
|
|
4
|
+
const InventoryStatusSchema = z.enum(["inStock", "outOfStock", "onBackOrder", "preOrder", "discontinued"]);
|
|
4
5
|
const InventorySchema = BaseModelSchema.extend({
|
|
5
|
-
identifier: InventoryIdentifierSchema
|
|
6
|
-
quantity: z.number()
|
|
7
|
-
status:
|
|
6
|
+
identifier: InventoryIdentifierSchema,
|
|
7
|
+
quantity: z.number(),
|
|
8
|
+
status: InventoryStatusSchema
|
|
8
9
|
});
|
|
9
10
|
export {
|
|
10
|
-
InventorySchema
|
|
11
|
+
InventorySchema,
|
|
12
|
+
InventoryStatusSchema
|
|
11
13
|
};
|
|
@@ -5,28 +5,28 @@ import { AddressSchema } from "./profile.model.js";
|
|
|
5
5
|
import { ShippingMethodSchema } from "./shipping-method.model.js";
|
|
6
6
|
import { CostBreakDownSchema, ItemCostBreakdownSchema } from "./cost.model.js";
|
|
7
7
|
import { PaymentInstructionSchema } from "./payment.model.js";
|
|
8
|
-
const OrderStatusSchema = z.enum(["AwaitingPayment", "ReleasedToFulfillment", "Shipped", "Cancelled"]).
|
|
9
|
-
const OrderInventoryStatusSchema = z.enum(["NotAllocated", "Allocated", "Backordered", "Preordered"]).
|
|
8
|
+
const OrderStatusSchema = z.enum(["AwaitingPayment", "ReleasedToFulfillment", "Shipped", "Cancelled"]).describe("The current status of the order.");
|
|
9
|
+
const OrderInventoryStatusSchema = z.enum(["NotAllocated", "Allocated", "Backordered", "Preordered"]).describe("The inventory release status of the order.");
|
|
10
10
|
const OrderItemSchema = z.looseObject({
|
|
11
|
-
identifier: CartItemIdentifierSchema
|
|
12
|
-
variant: ProductVariantIdentifierSchema
|
|
13
|
-
quantity: z.number()
|
|
14
|
-
price: ItemCostBreakdownSchema
|
|
15
|
-
inventoryStatus: OrderInventoryStatusSchema.
|
|
11
|
+
identifier: CartItemIdentifierSchema,
|
|
12
|
+
variant: ProductVariantIdentifierSchema,
|
|
13
|
+
quantity: z.number(),
|
|
14
|
+
price: ItemCostBreakdownSchema,
|
|
15
|
+
inventoryStatus: OrderInventoryStatusSchema.describe("The inventory release status of the order item.")
|
|
16
16
|
});
|
|
17
17
|
const OrderSchema = BaseModelSchema.extend({
|
|
18
|
-
identifier: CartIdentifierSchema
|
|
19
|
-
userId: IdentityIdentifierSchema
|
|
20
|
-
items: z.array(OrderItemSchema)
|
|
21
|
-
price: CostBreakDownSchema
|
|
22
|
-
name: z.string().
|
|
23
|
-
description: z.string().
|
|
18
|
+
identifier: CartIdentifierSchema,
|
|
19
|
+
userId: IdentityIdentifierSchema,
|
|
20
|
+
items: z.array(OrderItemSchema),
|
|
21
|
+
price: CostBreakDownSchema,
|
|
22
|
+
name: z.string().optional(),
|
|
23
|
+
description: z.string().optional(),
|
|
24
24
|
shippingAddress: AddressSchema.optional(),
|
|
25
25
|
billingAddress: AddressSchema.optional(),
|
|
26
26
|
shippingMethod: ShippingMethodSchema.optional(),
|
|
27
|
-
orderStatus: OrderStatusSchema
|
|
28
|
-
inventoryStatus: OrderInventoryStatusSchema
|
|
29
|
-
paymentInstructions: z.array(PaymentInstructionSchema)
|
|
27
|
+
orderStatus: OrderStatusSchema,
|
|
28
|
+
inventoryStatus: OrderInventoryStatusSchema,
|
|
29
|
+
paymentInstructions: z.array(PaymentInstructionSchema),
|
|
30
30
|
cartReference: CartIdentifierSchema.optional().describe("Reference to the cart from which this order was created.")
|
|
31
31
|
});
|
|
32
32
|
export {
|
|
@@ -4,21 +4,21 @@ import { PaymentInstructionIdentifierSchema, PaymentMethodIdentifierSchema } fro
|
|
|
4
4
|
import { MonetaryAmountSchema } from "./price.model.js";
|
|
5
5
|
const PaymentStatusSchema = z.enum(["pending", "authorized", "canceled", "capture", "partial_capture", "refunded", "partial_refund"]);
|
|
6
6
|
const PaymentProtocolDataSchema = z.looseObject({
|
|
7
|
-
key: z.string()
|
|
8
|
-
value: z.string()
|
|
7
|
+
key: z.string(),
|
|
8
|
+
value: z.string()
|
|
9
9
|
});
|
|
10
10
|
const PaymentMethodSchema = BaseModelSchema.extend({
|
|
11
|
-
identifier: PaymentMethodIdentifierSchema
|
|
11
|
+
identifier: PaymentMethodIdentifierSchema,
|
|
12
12
|
logo: ImageSchema.optional(),
|
|
13
|
-
description: z.string()
|
|
14
|
-
isPunchOut: z.boolean()
|
|
13
|
+
description: z.string(),
|
|
14
|
+
isPunchOut: z.boolean()
|
|
15
15
|
});
|
|
16
16
|
const PaymentInstructionSchema = BaseModelSchema.extend({
|
|
17
|
-
identifier: PaymentInstructionIdentifierSchema
|
|
18
|
-
amount: MonetaryAmountSchema
|
|
19
|
-
paymentMethod: PaymentMethodIdentifierSchema
|
|
20
|
-
protocolData: z.array(PaymentProtocolDataSchema).
|
|
21
|
-
status: PaymentStatusSchema
|
|
17
|
+
identifier: PaymentInstructionIdentifierSchema,
|
|
18
|
+
amount: MonetaryAmountSchema,
|
|
19
|
+
paymentMethod: PaymentMethodIdentifierSchema,
|
|
20
|
+
protocolData: z.array(PaymentProtocolDataSchema).describe("Additional protocol-specific data for processing the payment."),
|
|
21
|
+
status: PaymentStatusSchema
|
|
22
22
|
});
|
|
23
23
|
export {
|
|
24
24
|
PaymentInstructionSchema,
|
|
@@ -3,17 +3,17 @@ import { BaseModelSchema } from "./base.model.js";
|
|
|
3
3
|
import { PriceIdentifierSchema } from "./identifiers.model.js";
|
|
4
4
|
import { CurrencySchema } from "./currency.model.js";
|
|
5
5
|
const MonetaryAmountSchema = z.looseObject({
|
|
6
|
-
value: z.number().
|
|
7
|
-
currency: CurrencySchema.
|
|
6
|
+
value: z.number().describe("The monetary amount in decimal-precision."),
|
|
7
|
+
currency: CurrencySchema.describe("The currency associated with the amount, as a ISO 4217 standardized code.")
|
|
8
8
|
});
|
|
9
9
|
const TieredPriceSchema = z.looseObject({
|
|
10
|
-
minimumQuantity: z.number().
|
|
11
|
-
price: MonetaryAmountSchema.
|
|
10
|
+
minimumQuantity: z.number().describe("The minimum quantity required to be eligible for the tiered price."),
|
|
11
|
+
price: MonetaryAmountSchema.describe("The monetary amount for the tiered price.")
|
|
12
12
|
});
|
|
13
13
|
const PriceSchema = BaseModelSchema.extend({
|
|
14
|
-
identifier: PriceIdentifierSchema
|
|
15
|
-
unitPrice: MonetaryAmountSchema
|
|
16
|
-
tieredPrices: z.array(TieredPriceSchema)
|
|
14
|
+
identifier: PriceIdentifierSchema,
|
|
15
|
+
unitPrice: MonetaryAmountSchema,
|
|
16
|
+
tieredPrices: z.array(TieredPriceSchema)
|
|
17
17
|
});
|
|
18
18
|
export {
|
|
19
19
|
MonetaryAmountSchema,
|
|
@@ -3,30 +3,30 @@ import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSch
|
|
|
3
3
|
import { BaseModelSchema, createPaginatedResponseSchema, ImageSchema } from "./base.model.js";
|
|
4
4
|
import { ProductVariantOptionSchema } from "./product.model.js";
|
|
5
5
|
const ProductSearchResultItemVariantSchema = z.looseObject({
|
|
6
|
-
variant: ProductVariantIdentifierSchema.
|
|
7
|
-
image: ImageSchema.
|
|
6
|
+
variant: ProductVariantIdentifierSchema.describe("The specific variant of the product"),
|
|
7
|
+
image: ImageSchema.describe("The image representing this variant in the search results"),
|
|
8
8
|
options: ProductVariantOptionSchema.optional().describe("The subset of options that can reasonably be applied on a PLP")
|
|
9
9
|
});
|
|
10
10
|
const ProductSearchResultItemSchema = BaseModelSchema.extend({
|
|
11
|
-
identifier: ProductIdentifierSchema
|
|
12
|
-
name: z.string()
|
|
13
|
-
slug: z.string()
|
|
14
|
-
variants: z.array(ProductSearchResultItemVariantSchema).
|
|
11
|
+
identifier: ProductIdentifierSchema,
|
|
12
|
+
name: z.string(),
|
|
13
|
+
slug: z.string(),
|
|
14
|
+
variants: z.array(ProductSearchResultItemVariantSchema).describe("A list of variants associated with the product in the search results. If exactly one is present, you can use add-to-cart directly from PLP. If none are present, you must direct to PDP. If mulitple are present, and no options are set, you must direct to PDP. If multiple are present, and they have options, you can render swatches on PLP and allow customer to flip between variants.")
|
|
15
15
|
});
|
|
16
16
|
const ProductSearchResultFacetValueSchema = z.looseObject({
|
|
17
|
-
identifier: FacetValueIdentifierSchema
|
|
18
|
-
name: z.string()
|
|
19
|
-
count: z.number()
|
|
20
|
-
active: z.boolean()
|
|
17
|
+
identifier: FacetValueIdentifierSchema,
|
|
18
|
+
name: z.string(),
|
|
19
|
+
count: z.number(),
|
|
20
|
+
active: z.boolean()
|
|
21
21
|
});
|
|
22
22
|
const ProductSearchResultFacetSchema = z.looseObject({
|
|
23
|
-
identifier: FacetIdentifierSchema
|
|
24
|
-
name: z.string()
|
|
25
|
-
values: z.array(ProductSearchResultFacetValueSchema)
|
|
23
|
+
identifier: FacetIdentifierSchema,
|
|
24
|
+
name: z.string(),
|
|
25
|
+
values: z.array(ProductSearchResultFacetValueSchema)
|
|
26
26
|
});
|
|
27
27
|
const ProductSearchResultSchema = createPaginatedResponseSchema(ProductSearchResultItemSchema).extend({
|
|
28
|
-
identifier: ProductSearchIdentifierSchema
|
|
29
|
-
facets: z.array(ProductSearchResultFacetSchema)
|
|
28
|
+
identifier: ProductSearchIdentifierSchema,
|
|
29
|
+
facets: z.array(ProductSearchResultFacetSchema)
|
|
30
30
|
});
|
|
31
31
|
export {
|
|
32
32
|
ProductSearchResultFacetSchema,
|