@sixtyninecommerce/client 0.1.0

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.
Files changed (130) hide show
  1. package/README.md +96 -0
  2. package/dist/client.d.ts +3 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +37 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/commerce/cart.d.ts +11 -0
  7. package/dist/commerce/cart.d.ts.map +1 -0
  8. package/dist/commerce/cart.js +51 -0
  9. package/dist/commerce/cart.js.map +1 -0
  10. package/dist/commerce/checkout.d.ts +13 -0
  11. package/dist/commerce/checkout.d.ts.map +1 -0
  12. package/dist/commerce/checkout.js +55 -0
  13. package/dist/commerce/checkout.js.map +1 -0
  14. package/dist/commerce/customer.d.ts +15 -0
  15. package/dist/commerce/customer.d.ts.map +1 -0
  16. package/dist/commerce/customer.js +45 -0
  17. package/dist/commerce/customer.js.map +1 -0
  18. package/dist/commerce/index.d.ts +4 -0
  19. package/dist/commerce/index.d.ts.map +1 -0
  20. package/dist/commerce/index.js +20 -0
  21. package/dist/commerce/index.js.map +1 -0
  22. package/dist/commerce/products.d.ts +11 -0
  23. package/dist/commerce/products.d.ts.map +1 -0
  24. package/dist/commerce/products.js +47 -0
  25. package/dist/commerce/products.js.map +1 -0
  26. package/dist/commerce/queries.d.ts +29 -0
  27. package/dist/commerce/queries.d.ts.map +1 -0
  28. package/dist/commerce/queries.js +444 -0
  29. package/dist/commerce/queries.js.map +1 -0
  30. package/dist/commerce/search.d.ts +6 -0
  31. package/dist/commerce/search.d.ts.map +1 -0
  32. package/dist/commerce/search.js +23 -0
  33. package/dist/commerce/search.js.map +1 -0
  34. package/dist/constants.d.ts +7 -0
  35. package/dist/constants.d.ts.map +1 -0
  36. package/dist/constants.js +7 -0
  37. package/dist/constants.js.map +1 -0
  38. package/dist/content/assets.d.ts +6 -0
  39. package/dist/content/assets.d.ts.map +1 -0
  40. package/dist/content/assets.js +17 -0
  41. package/dist/content/assets.js.map +1 -0
  42. package/dist/content/forms.d.ts +7 -0
  43. package/dist/content/forms.d.ts.map +1 -0
  44. package/dist/content/forms.js +20 -0
  45. package/dist/content/forms.js.map +1 -0
  46. package/dist/content/index.d.ts +4 -0
  47. package/dist/content/index.d.ts.map +1 -0
  48. package/dist/content/index.js +17 -0
  49. package/dist/content/index.js.map +1 -0
  50. package/dist/content/items.d.ts +6 -0
  51. package/dist/content/items.d.ts.map +1 -0
  52. package/dist/content/items.js +23 -0
  53. package/dist/content/items.js.map +1 -0
  54. package/dist/content/menus.d.ts +7 -0
  55. package/dist/content/menus.d.ts.map +1 -0
  56. package/dist/content/menus.js +60 -0
  57. package/dist/content/menus.js.map +1 -0
  58. package/dist/content/resolve.d.ts +6 -0
  59. package/dist/content/resolve.d.ts.map +1 -0
  60. package/dist/content/resolve.js +11 -0
  61. package/dist/content/resolve.js.map +1 -0
  62. package/dist/content/strings.d.ts +6 -0
  63. package/dist/content/strings.d.ts.map +1 -0
  64. package/dist/content/strings.js +11 -0
  65. package/dist/content/strings.js.map +1 -0
  66. package/dist/core/context.d.ts +3 -0
  67. package/dist/core/context.d.ts.map +1 -0
  68. package/dist/core/context.js +93 -0
  69. package/dist/core/context.js.map +1 -0
  70. package/dist/core/headers.d.ts +5 -0
  71. package/dist/core/headers.d.ts.map +1 -0
  72. package/dist/core/headers.js +23 -0
  73. package/dist/core/headers.js.map +1 -0
  74. package/dist/core/http.d.ts +9 -0
  75. package/dist/core/http.d.ts.map +1 -0
  76. package/dist/core/http.js +140 -0
  77. package/dist/core/http.js.map +1 -0
  78. package/dist/currency/exchange.d.ts +7 -0
  79. package/dist/currency/exchange.d.ts.map +1 -0
  80. package/dist/currency/exchange.js +18 -0
  81. package/dist/currency/exchange.js.map +1 -0
  82. package/dist/currency/index.d.ts +4 -0
  83. package/dist/currency/index.d.ts.map +1 -0
  84. package/dist/currency/index.js +5 -0
  85. package/dist/currency/index.js.map +1 -0
  86. package/dist/errors.d.ts +12 -0
  87. package/dist/errors.d.ts.map +1 -0
  88. package/dist/errors.js +21 -0
  89. package/dist/errors.js.map +1 -0
  90. package/dist/index.d.ts +5 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +4 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/media/index.d.ts +4 -0
  95. package/dist/media/index.d.ts.map +1 -0
  96. package/dist/media/index.js +12 -0
  97. package/dist/media/index.js.map +1 -0
  98. package/dist/media/urls.d.ts +31 -0
  99. package/dist/media/urls.d.ts.map +1 -0
  100. package/dist/media/urls.js +63 -0
  101. package/dist/media/urls.js.map +1 -0
  102. package/dist/navigation/index.d.ts +4 -0
  103. package/dist/navigation/index.d.ts.map +1 -0
  104. package/dist/navigation/index.js +5 -0
  105. package/dist/navigation/index.js.map +1 -0
  106. package/dist/navigation/routes.d.ts +8 -0
  107. package/dist/navigation/routes.d.ts.map +1 -0
  108. package/dist/navigation/routes.js +33 -0
  109. package/dist/navigation/routes.js.map +1 -0
  110. package/dist/pricing/format.d.ts +3 -0
  111. package/dist/pricing/format.d.ts.map +1 -0
  112. package/dist/pricing/format.js +13 -0
  113. package/dist/pricing/format.js.map +1 -0
  114. package/dist/pricing/index.d.ts +6 -0
  115. package/dist/pricing/index.d.ts.map +1 -0
  116. package/dist/pricing/index.js +41 -0
  117. package/dist/pricing/index.js.map +1 -0
  118. package/dist/pricing/tiers.d.ts +4 -0
  119. package/dist/pricing/tiers.d.ts.map +1 -0
  120. package/dist/pricing/tiers.js +31 -0
  121. package/dist/pricing/tiers.js.map +1 -0
  122. package/dist/pricing/validation.d.ts +10 -0
  123. package/dist/pricing/validation.d.ts.map +1 -0
  124. package/dist/pricing/validation.js +26 -0
  125. package/dist/pricing/validation.js.map +1 -0
  126. package/dist/types.d.ts +638 -0
  127. package/dist/types.d.ts.map +1 -0
  128. package/dist/types.js +2 -0
  129. package/dist/types.js.map +1 -0
  130. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @sixtyninecommerce/client
2
+
3
+ JavaScript/TypeScript client for [sixtynine-commerce](https://sixtyninecommerce.com) storefronts.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @sixtyninecommerce/client
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { createStorefrontClient } from '@sixtyninecommerce/client';
15
+
16
+ const client = await createStorefrontClient({
17
+ storeCode: 'my-store',
18
+ cdnUrl: 'https://cdn.my-store.com',
19
+ });
20
+
21
+ // Products
22
+ const product = await client.commerce.getProduct('blue-shirt');
23
+ const results = await client.commerce.searchProducts({ term: 'shirt' });
24
+
25
+ // Cart
26
+ await client.commerce.addToCart(product.variants[0].id, 1);
27
+ const order = await client.commerce.getActiveOrder();
28
+
29
+ // CMS content
30
+ const page = await client.content.resolvePath('/about-us');
31
+ const menu = await client.content.getMenu('main-menu');
32
+
33
+ // Routes
34
+ const routes = await client.navigation.getRoutes();
35
+
36
+ // Pricing helpers
37
+ client.pricing.formatPrice(2999, 'EUR'); // "€29.99"
38
+ client.pricing.getTierForQuantity(variant.priceTiers, 10);
39
+ client.pricing.validateOrderMinimums(order, { minOrderAmount: 5000 });
40
+
41
+ // Media helpers
42
+ client.media.assetUrl('shop/source/photo.jpg');
43
+ client.media.getPresetUrl(asset, 'm', 'webp');
44
+ client.media.getResponsiveImageData(asset); // { src, srcSet, sizes, alt }
45
+
46
+ // Language & auth
47
+ client.setLanguage('nl');
48
+ client.setAuthToken(token);
49
+
50
+ // Escape hatch for custom queries
51
+ const data = await client.graphql(`query { activeChannel { id } }`);
52
+ ```
53
+
54
+ ## Modules
55
+
56
+ | Module | Description |
57
+ |--------|-------------|
58
+ | `commerce` | Products, collections, search, cart, checkout, customer auth |
59
+ | `content` | CMS resolve, content items, assets, forms, content strings, menus |
60
+ | `navigation` | Unified route manifest, route lookup |
61
+ | `pricing` | Price formatting, tier lookup, order validation (pure functions) |
62
+ | `media` | CDN URLs, preset URLs, responsive image data (pure functions) |
63
+ | `currency` | Exchange rates, currency conversion |
64
+
65
+ ## Tree-Shakeable Imports
66
+
67
+ ```typescript
68
+ // Import only pricing (no network code)
69
+ import { formatPrice, getTierForQuantity } from '@sixtyninecommerce/client/pricing';
70
+
71
+ // Import only media helpers
72
+ import { PRESETS, getResponsiveImageData } from '@sixtyninecommerce/client/media';
73
+ ```
74
+
75
+ ## Error Handling
76
+
77
+ Cart and checkout mutations throw `MutationError` with the Vendure error code:
78
+
79
+ ```typescript
80
+ import { MutationError } from '@sixtyninecommerce/client';
81
+
82
+ try {
83
+ await client.commerce.addToCart(variantId, 100);
84
+ } catch (error) {
85
+ if (error instanceof MutationError) {
86
+ // error.errorCode — "INSUFFICIENT_STOCK_ERROR"
87
+ // error.message — "Only 3 items available"
88
+ // error.fields — { quantityAvailable: 3 }
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## Requirements
94
+
95
+ - Node.js 20+ / modern browser / edge runtime
96
+ - Standard `fetch` API (inject custom fetch via config for SSR)
@@ -0,0 +1,3 @@
1
+ import type { StorefrontClient, StorefrontClientConfig } from './types.js';
2
+ export declare function createStorefrontClient(config: StorefrontClientConfig): Promise<StorefrontClient>;
3
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAmB3E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CA8B3B"}
package/dist/client.js ADDED
@@ -0,0 +1,37 @@
1
+ import { createCommerceModule } from './commerce/index.js';
2
+ import { createContentModule } from './content/index.js';
3
+ import { createStoreContext } from './core/context.js';
4
+ import { createHttpClient } from './core/http.js';
5
+ import { createCurrencyModule } from './currency/index.js';
6
+ import { createMediaModule } from './media/index.js';
7
+ import { createNavigationModule } from './navigation/index.js';
8
+ import { createPricingModule } from './pricing/index.js';
9
+ export async function createStorefrontClient(config) {
10
+ const ctx = await createStoreContext(config);
11
+ const http = createHttpClient(ctx);
12
+ return {
13
+ context: ctx,
14
+ commerce: createCommerceModule(http),
15
+ content: createContentModule(http, ctx),
16
+ navigation: createNavigationModule(http),
17
+ pricing: createPricingModule(ctx),
18
+ media: createMediaModule(ctx),
19
+ currency: createCurrencyModule(http),
20
+ setLanguage(code) {
21
+ ctx.languageCode = code;
22
+ },
23
+ getLanguage() {
24
+ return ctx.languageCode;
25
+ },
26
+ setAuthToken(token) {
27
+ ctx.authToken = token;
28
+ },
29
+ clearAuthToken() {
30
+ ctx.authToken = null;
31
+ },
32
+ graphql(query, variables) {
33
+ return http.graphql(query, variables);
34
+ },
35
+ };
36
+ }
37
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAoBzD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAA8B;IAE9B,MAAM,GAAG,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEnC,OAAO;QACL,OAAO,EAAE,GAAG;QAEZ,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC;QACpC,OAAO,EAAE,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC;QACvC,UAAU,EAAE,sBAAsB,CAAC,IAAI,CAAC;QACxC,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC;QACjC,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC;QAC7B,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC;QAEpC,WAAW,CAAC,IAAY;YACtB,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC;QAC1B,CAAC;QACD,WAAW;YACT,OAAO,GAAG,CAAC,YAAY,CAAC;QAC1B,CAAC;QACD,YAAY,CAAC,KAAa;YACxB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;QACxB,CAAC;QACD,cAAc;YACZ,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,OAAO,CAAc,KAAa,EAAE,SAAmC;YACrE,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { HttpClient } from '../core/http.js';
2
+ import type { Order } from '../types.js';
3
+ export declare function createCartMethods(http: HttpClient): {
4
+ getActiveOrder(): Promise<Order | null>;
5
+ addToCart(variantId: string, quantity: number): Promise<Order>;
6
+ updateCartLine(lineId: string, quantity: number): Promise<Order>;
7
+ removeFromCart(lineId: string): Promise<Order>;
8
+ applyCouponCode(code: string): Promise<Order>;
9
+ removeCouponCode(code: string): Promise<Order>;
10
+ };
11
+ //# sourceMappingURL=cart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../src/commerce/cart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAqBzC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU;sBAEtB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;yBAKlB,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;2BAQvC,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;2BAQzC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;0BAOxB,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;2BAKtB,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;EAOvD"}
@@ -0,0 +1,51 @@
1
+ import { MutationError } from '../errors.js';
2
+ import { ACTIVE_ORDER, ADD_TO_CART, ADJUST_ORDER_LINE, APPLY_COUPON, REMOVE_COUPON, REMOVE_ORDER_LINE, } from './queries.js';
3
+ function unwrapOrderResult(data, operationField) {
4
+ const result = data[operationField];
5
+ if (!result) {
6
+ throw new MutationError('UNKNOWN_ERROR', `No result from ${operationField}`);
7
+ }
8
+ if ('errorCode' in result) {
9
+ throw new MutationError(result.errorCode, result.message, result);
10
+ }
11
+ return result;
12
+ }
13
+ export function createCartMethods(http) {
14
+ return {
15
+ async getActiveOrder() {
16
+ const data = await http.graphql(ACTIVE_ORDER);
17
+ return data.activeOrder;
18
+ },
19
+ async addToCart(variantId, quantity) {
20
+ const data = await http.graphql(ADD_TO_CART, {
21
+ variantId,
22
+ quantity,
23
+ });
24
+ return unwrapOrderResult(data, 'addItemToOrder');
25
+ },
26
+ async updateCartLine(lineId, quantity) {
27
+ const data = await http.graphql(ADJUST_ORDER_LINE, {
28
+ lineId,
29
+ quantity,
30
+ });
31
+ return unwrapOrderResult(data, 'adjustOrderLine');
32
+ },
33
+ async removeFromCart(lineId) {
34
+ const data = await http.graphql(REMOVE_ORDER_LINE, {
35
+ lineId,
36
+ });
37
+ return unwrapOrderResult(data, 'removeOrderLine');
38
+ },
39
+ async applyCouponCode(code) {
40
+ const data = await http.graphql(APPLY_COUPON, { code });
41
+ return unwrapOrderResult(data, 'applyCouponCode');
42
+ },
43
+ async removeCouponCode(code) {
44
+ const data = await http.graphql(REMOVE_COUPON, {
45
+ code,
46
+ });
47
+ return data.removeCouponCode;
48
+ },
49
+ };
50
+ }
51
+ //# sourceMappingURL=cart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart.js","sourceRoot":"","sources":["../../src/commerce/cart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,SAAS,iBAAiB,CAAC,IAA6B,EAAE,cAAsB;IAC9E,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAA4B,CAAC;IAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,kBAAkB,cAAc,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAA0B,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAgB;IAChD,OAAO;QACL,KAAK,CAAC,cAAc;YAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAgC,YAAY,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,SAAiB,EAAE,QAAgB;YACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,WAAW,EAAE;gBACpE,SAAS;gBACT,QAAQ;aACT,CAAC,CAAC;YACH,OAAO,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACnD,CAAC;QAED,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,QAAgB;YACnD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,iBAAiB,EAAE;gBAC1E,MAAM;gBACN,QAAQ;aACT,CAAC,CAAC;YACH,OAAO,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QACpD,CAAC;QAED,KAAK,CAAC,cAAc,CAAC,MAAc;YACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,iBAAiB,EAAE;gBAC1E,MAAM;aACP,CAAC,CAAC;YACH,OAAO,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QACpD,CAAC;QAED,KAAK,CAAC,eAAe,CAAC,IAAY;YAChC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YACjF,OAAO,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QACpD,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,IAAY;YACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA8B,aAAa,EAAE;gBAC1E,IAAI;aACL,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,gBAAgB,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { HttpClient } from '../core/http.js';
2
+ import type { AddressInput, CustomerInput, Order, PaymentInput, PaymentMethod, ShippingMethod } from '../types.js';
3
+ export declare function createCheckoutMethods(http: HttpClient): {
4
+ setCustomerForOrder(input: CustomerInput): Promise<Order>;
5
+ setShippingAddress(input: AddressInput): Promise<Order>;
6
+ setBillingAddress(input: AddressInput): Promise<Order>;
7
+ getEligibleShippingMethods(): Promise<ShippingMethod[]>;
8
+ setShippingMethod(ids: string[]): Promise<Order>;
9
+ getEligiblePaymentMethods(): Promise<PaymentMethod[]>;
10
+ transitionToArrangingPayment(): Promise<Order>;
11
+ addPayment(input: PaymentInput): Promise<Order>;
12
+ };
13
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commerce/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,aAAa,CAAC;AAuBrB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU;+BAEjB,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC;8BAK/B,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;6BAO9B,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;kCAOxB,OAAO,CAAC,cAAc,EAAE,CAAC;2BAOhC,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;iCAOnB,OAAO,CAAC,aAAa,EAAE,CAAC;oCAOrB,OAAO,CAAC,KAAK,CAAC;sBAK5B,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;EAKxD"}
@@ -0,0 +1,55 @@
1
+ import { MutationError } from '../errors.js';
2
+ import { ADD_PAYMENT, ELIGIBLE_PAYMENT_METHODS, ELIGIBLE_SHIPPING_METHODS, SET_BILLING_ADDRESS, SET_CUSTOMER, SET_SHIPPING_ADDRESS, SET_SHIPPING_METHOD, TRANSITION_TO_ARRANGING_PAYMENT, } from './queries.js';
3
+ function unwrapResult(data, field) {
4
+ const result = data[field];
5
+ if (!result) {
6
+ throw new MutationError('UNKNOWN_ERROR', `No result from ${field}`);
7
+ }
8
+ if ('errorCode' in result) {
9
+ throw new MutationError(result.errorCode, result.message, result);
10
+ }
11
+ return result;
12
+ }
13
+ export function createCheckoutMethods(http) {
14
+ return {
15
+ async setCustomerForOrder(input) {
16
+ const data = await http.graphql(SET_CUSTOMER, { input });
17
+ return unwrapResult(data, 'setCustomerForOrder');
18
+ },
19
+ async setShippingAddress(input) {
20
+ const data = await http.graphql(SET_SHIPPING_ADDRESS, {
21
+ input,
22
+ });
23
+ return unwrapResult(data, 'setOrderShippingAddress');
24
+ },
25
+ async setBillingAddress(input) {
26
+ const data = await http.graphql(SET_BILLING_ADDRESS, {
27
+ input,
28
+ });
29
+ return unwrapResult(data, 'setOrderBillingAddress');
30
+ },
31
+ async getEligibleShippingMethods() {
32
+ const data = await http.graphql(ELIGIBLE_SHIPPING_METHODS);
33
+ return data.eligibleShippingMethods;
34
+ },
35
+ async setShippingMethod(ids) {
36
+ const data = await http.graphql(SET_SHIPPING_METHOD, {
37
+ ids,
38
+ });
39
+ return unwrapResult(data, 'setOrderShippingMethod');
40
+ },
41
+ async getEligiblePaymentMethods() {
42
+ const data = await http.graphql(ELIGIBLE_PAYMENT_METHODS);
43
+ return data.eligiblePaymentMethods;
44
+ },
45
+ async transitionToArrangingPayment() {
46
+ const data = await http.graphql(TRANSITION_TO_ARRANGING_PAYMENT);
47
+ return unwrapResult(data, 'transitionOrderToState');
48
+ },
49
+ async addPayment(input) {
50
+ const data = await http.graphql(ADD_PAYMENT, { input });
51
+ return unwrapResult(data, 'addPaymentToOrder');
52
+ },
53
+ };
54
+ }
55
+ //# sourceMappingURL=checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commerce/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAS7C,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,cAAc,CAAC;AAEtB,SAAS,YAAY,CAAC,IAA6B,EAAE,KAAa;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAA4B,CAAC;IACtD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,kBAAkB,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAA0B,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAgB;IACpD,OAAO;QACL,KAAK,CAAC,mBAAmB,CAAC,KAAoB;YAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAClF,OAAO,YAAY,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QACnD,CAAC;QAED,KAAK,CAAC,kBAAkB,CAAC,KAAmB;YAC1C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,oBAAoB,EAAE;gBAC7E,KAAK;aACN,CAAC,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QACvD,CAAC;QAED,KAAK,CAAC,iBAAiB,CAAC,KAAmB;YACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,mBAAmB,EAAE;gBAC5E,KAAK;aACN,CAAC,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,0BAA0B;YAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAC7B,yBAAyB,CAC1B,CAAC;YACF,OAAO,IAAI,CAAC,uBAAuB,CAAC;QACtC,CAAC;QAED,KAAK,CAAC,iBAAiB,CAAC,GAAa;YACnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,mBAAmB,EAAE;gBAC5E,GAAG;aACJ,CAAC,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,yBAAyB;YAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAC7B,wBAAwB,CACzB,CAAC;YACF,OAAO,IAAI,CAAC,sBAAsB,CAAC;QACrC,CAAC;QAED,KAAK,CAAC,4BAA4B;YAChC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,+BAA+B,CAAC,CAAC;YAC1F,OAAO,YAAY,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,UAAU,CAAC,KAAmB;YAClC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACjF,OAAO,YAAY,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { HttpClient } from '../core/http.js';
2
+ import type { Customer, OrderListOptions, OrderSummary, PaginatedList, RegisterInput } from '../types.js';
3
+ export declare function createCustomerMethods(http: HttpClient): {
4
+ login(email: string, password: string): Promise<{
5
+ id: string;
6
+ identifier: string;
7
+ }>;
8
+ register(input: RegisterInput): Promise<{
9
+ success: boolean;
10
+ }>;
11
+ logout(): Promise<void>;
12
+ getCurrentCustomer(): Promise<Customer | null>;
13
+ getCustomerOrders(options?: OrderListOptions): Promise<PaginatedList<OrderSummary>>;
14
+ };
15
+ //# sourceMappingURL=customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACd,MAAM,aAAa,CAAC;AAGrB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU;iBAE/B,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;oBAYnE,aAAa,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;cAWnD,OAAO,CAAC,IAAI,CAAC;0BAID,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;gCAKlB,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;EAe5F"}
@@ -0,0 +1,45 @@
1
+ import { MutationError } from '../errors.js';
2
+ import { GET_CURRENT_CUSTOMER, GET_CUSTOMER_ORDERS, LOGIN, LOGOUT, REGISTER } from './queries.js';
3
+ export function createCustomerMethods(http) {
4
+ return {
5
+ async login(email, password) {
6
+ const data = await http.graphql(LOGIN, {
7
+ email,
8
+ password,
9
+ });
10
+ const result = data.login;
11
+ if ('errorCode' in result) {
12
+ throw new MutationError(result.errorCode, result.message, result);
13
+ }
14
+ return result;
15
+ },
16
+ async register(input) {
17
+ const data = await http.graphql(REGISTER, { input });
18
+ const result = data.registerCustomerAccount;
19
+ if ('errorCode' in result) {
20
+ throw new MutationError(result.errorCode, result.message, result);
21
+ }
22
+ return result;
23
+ },
24
+ async logout() {
25
+ await http.graphql(LOGOUT);
26
+ },
27
+ async getCurrentCustomer() {
28
+ const data = await http.graphql(GET_CURRENT_CUSTOMER);
29
+ return data.activeCustomer;
30
+ },
31
+ async getCustomerOrders(options) {
32
+ const vars = {};
33
+ if (options) {
34
+ vars.options = {
35
+ take: options.take ?? 10,
36
+ skip: options.skip ?? 0,
37
+ sort: { createdAt: 'DESC' },
38
+ };
39
+ }
40
+ const data = await http.graphql(GET_CUSTOMER_ORDERS, vars);
41
+ return data.activeCustomer?.orders ?? { items: [], totalItems: 0 };
42
+ },
43
+ };
44
+ }
45
+ //# sourceMappingURL=customer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAElG,MAAM,UAAU,qBAAqB,CAAC,IAAgB;IACpD,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,QAAgB;YACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAqC,KAAK,EAAE;gBACzE,KAAK;gBACL,QAAQ;aACT,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;gBAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;YACxF,CAAC;YACD,OAAO,MAA4C,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,KAAoB;YACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAE5B,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACxB,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC;YAC5C,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;gBAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;YACxF,CAAC;YACD,OAAO,MAA8B,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,MAAM;YACV,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,kBAAkB;YACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAsC,oBAAoB,CAAC,CAAC;YAC3F,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,iBAAiB,CAAC,OAA0B;YAChD,MAAM,IAAI,GAA4B,EAAE,CAAC;YACzC,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC,OAAO,GAAG;oBACb,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;oBACxB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;oBACvB,IAAI,EAAE,EAAE,SAAS,EAAE,MAAe,EAAE;iBACrC,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAE5B,mBAAmB,EAAE,IAAI,CAAC,CAAC;YAC9B,OAAO,IAAI,CAAC,cAAc,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { HttpClient } from '../core/http.js';
2
+ import type { CommerceModule } from '../types.js';
3
+ export declare function createCommerceModule(http: HttpClient): CommerceModule;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAcrE"}
@@ -0,0 +1,20 @@
1
+ import { createCartMethods } from './cart.js';
2
+ import { createCheckoutMethods } from './checkout.js';
3
+ import { createCustomerMethods } from './customer.js';
4
+ import { createProductMethods } from './products.js';
5
+ import { createSearchMethods } from './search.js';
6
+ export function createCommerceModule(http) {
7
+ const products = createProductMethods(http);
8
+ const search = createSearchMethods(http);
9
+ const cart = createCartMethods(http);
10
+ const checkout = createCheckoutMethods(http);
11
+ const customer = createCustomerMethods(http);
12
+ return {
13
+ ...products,
14
+ ...search,
15
+ ...cart,
16
+ ...checkout,
17
+ ...customer,
18
+ };
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,UAAU,oBAAoB,CAAC,IAAgB;IACnD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAE7C,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,MAAM;QACT,GAAG,IAAI;QACP,GAAG,QAAQ;QACX,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { HttpClient } from '../core/http.js';
2
+ import type { Collection, CollectionDetail, CollectionListOptions, Facet, PaginatedList, Product, ProductListOptions, ProductSummary } from '../types.js';
3
+ export declare function createProductMethods(http: HttpClient): {
4
+ getProduct(slug: string): Promise<Product>;
5
+ getProductById(id: string): Promise<Product>;
6
+ getProducts(options?: ProductListOptions): Promise<PaginatedList<ProductSummary>>;
7
+ getFacets(): Promise<Facet[]>;
8
+ getCollections(options?: CollectionListOptions): Promise<Collection[]>;
9
+ getCollection(slug: string): Promise<CollectionDetail>;
10
+ };
11
+ //# sourceMappingURL=products.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../src/commerce/products.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,EACL,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,cAAc,EACf,MAAM,aAAa,CAAC;AAUrB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU;qBAE1B,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;uBAKvB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;0BAKtB,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;iBAqBpE,OAAO,CAAC,KAAK,EAAE,CAAC;6BAKJ,qBAAqB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;wBAOlD,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;EAO/D"}
@@ -0,0 +1,47 @@
1
+ import { GET_COLLECTION, GET_PRODUCT, GET_PRODUCT_BY_ID, LIST_COLLECTIONS, LIST_FACETS, LIST_PRODUCTS, } from './queries.js';
2
+ export function createProductMethods(http) {
3
+ return {
4
+ async getProduct(slug) {
5
+ const data = await http.graphql(GET_PRODUCT, { slug });
6
+ return data.product;
7
+ },
8
+ async getProductById(id) {
9
+ const data = await http.graphql(GET_PRODUCT_BY_ID, { id });
10
+ return data.product;
11
+ },
12
+ async getProducts(options) {
13
+ const vars = {};
14
+ if (options) {
15
+ const queryOptions = {
16
+ take: options.take ?? 20,
17
+ skip: options.skip ?? 0,
18
+ };
19
+ if (options.collectionSlug) {
20
+ queryOptions.filter = { collectionSlug: { eq: options.collectionSlug } };
21
+ }
22
+ if (options.sort)
23
+ queryOptions.sort = options.sort;
24
+ vars.options = queryOptions;
25
+ }
26
+ const data = await http.graphql(LIST_PRODUCTS, vars);
27
+ return data.products;
28
+ },
29
+ async getFacets() {
30
+ const data = await http.graphql(LIST_FACETS);
31
+ return data.facets.items;
32
+ },
33
+ async getCollections(options) {
34
+ const data = await http.graphql(LIST_COLLECTIONS, {
35
+ options: { take: options?.take ?? 100, skip: options?.skip ?? 0 },
36
+ });
37
+ return data.collections.items;
38
+ },
39
+ async getCollection(slug) {
40
+ const data = await http.graphql(GET_COLLECTION, {
41
+ slug,
42
+ });
43
+ return data.collection;
44
+ },
45
+ };
46
+ }
47
+ //# sourceMappingURL=products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"products.js","sourceRoot":"","sources":["../../src/commerce/products.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,oBAAoB,CAAC,IAAgB;IACnD,OAAO;QACL,KAAK,CAAC,UAAU,CAAC,IAAY;YAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAuB,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;QAED,KAAK,CAAC,cAAc,CAAC,EAAU;YAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAuB,iBAAiB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACjF,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,OAA4B;YAC5C,MAAM,IAAI,GAA4B,EAAE,CAAC;YACzC,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,YAAY,GAA4B;oBAC5C,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;oBACxB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;iBACxB,CAAC;gBACF,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;oBAC3B,YAAY,CAAC,MAAM,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;gBAC3E,CAAC;gBACD,IAAI,OAAO,CAAC,IAAI;oBAAE,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;gBACnD,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;YAC9B,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAC7B,aAAa,EACb,IAAI,CACL,CAAC;YACF,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QAED,KAAK,CAAC,SAAS;YACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAiC,WAAW,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAC3B,CAAC;QAED,KAAK,CAAC,cAAc,CAAC,OAA+B;YAClD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA2C,gBAAgB,EAAE;gBAC1F,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE;aAClE,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAChC,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,IAAY;YAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAmC,cAAc,EAAE;gBAChF,IAAI;aACL,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ export declare const GET_PRODUCT = "\n query GetProduct($slug: String!) {\n product(slug: $slug) {\n id name slug description\n featuredAsset {\n source name\n customFields { altText }\n presets {\n xxs { url webpUrl } xs { url webpUrl }\n s { url webpUrl } m { url webpUrl }\n l { url webpUrl } xl { url webpUrl }\n }\n }\n assets {\n source name\n customFields { altText }\n presets {\n xs { url webpUrl } m { url webpUrl }\n l { url webpUrl } xl { url webpUrl }\n }\n }\n variants {\n id name sku\n price priceWithTax currencyCode stockLevel\n priceListName retailPrice retailPriceWithTax\n priceTiers { minQuantity price priceWithTax discountLabel }\n options { id code name group { id name code } }\n assets {\n source name\n customFields { altText }\n presets { m { url webpUrl } l { url webpUrl } }\n }\n }\n optionGroups { id name code options { id name code } }\n facetValues { id name code facet { id name code } }\n collections { id name slug }\n }\n }\n";
2
+ export declare const GET_PRODUCT_BY_ID = "\n query GetProductById($id: ID!) {\n product(id: $id) {\n id name slug description\n featuredAsset {\n source name\n customFields { altText }\n presets {\n xxs { url webpUrl } xs { url webpUrl }\n s { url webpUrl } m { url webpUrl }\n l { url webpUrl } xl { url webpUrl }\n }\n }\n assets {\n source name\n customFields { altText }\n presets {\n xs { url webpUrl } m { url webpUrl }\n l { url webpUrl } xl { url webpUrl }\n }\n }\n variants {\n id name sku\n price priceWithTax currencyCode stockLevel\n priceListName retailPrice retailPriceWithTax\n priceTiers { minQuantity price priceWithTax discountLabel }\n options { id code name group { id name code } }\n assets {\n source name\n customFields { altText }\n presets { m { url webpUrl } l { url webpUrl } }\n }\n }\n optionGroups { id name code options { id name code } }\n facetValues { id name code facet { id name code } }\n collections { id name slug }\n }\n }\n";
3
+ export declare const LIST_PRODUCTS = "\n query ListProducts($options: ProductListOptions) {\n products(options: $options) {\n items {\n id name slug description\n featuredAsset {\n source name\n customFields { altText }\n presets { xs { url webpUrl } m { url webpUrl } l { url webpUrl } }\n }\n variants {\n id name sku\n price priceWithTax currencyCode stockLevel\n priceListName retailPrice retailPriceWithTax\n priceTiers { minQuantity price priceWithTax discountLabel }\n }\n facetValues { id name code facet { id name code } }\n collections { id name slug }\n }\n totalItems\n }\n }\n";
4
+ export declare const LIST_FACETS = "\n query ListFacets {\n facets {\n items {\n id name code\n values { id name code }\n }\n totalItems\n }\n }\n";
5
+ export declare const LIST_COLLECTIONS = "\n query ListCollections($options: CollectionListOptions) {\n collections(options: $options) {\n items {\n id name slug description\n breadcrumbs { id name slug }\n featuredAsset {\n source\n presets { xs { url webpUrl } m { url webpUrl } }\n }\n parent { id name slug }\n children { id name slug }\n }\n totalItems\n }\n }\n";
6
+ export declare const GET_COLLECTION = "\n query GetCollection($slug: String!) {\n collection(slug: $slug) {\n id name slug description\n featuredAsset {\n source\n presets { l { url webpUrl } xl { url webpUrl } }\n }\n breadcrumbs { id name slug }\n children { id name slug }\n productVariants(options: { take: 20 }) {\n items {\n id\n product {\n id name slug\n featuredAsset { source presets { m { url webpUrl } } }\n }\n price priceWithTax currencyCode stockLevel\n priceListName retailPrice retailPriceWithTax\n }\n totalItems\n }\n }\n }\n";
7
+ export declare const SEARCH_PRODUCTS = "\n query SearchProducts($input: SearchInput!) {\n search(input: $input) {\n items {\n productId productName slug description\n price { ... on SinglePrice { value } ... on PriceRange { min max } }\n priceWithTax { ... on SinglePrice { value } ... on PriceRange { min max } }\n currencyCode\n productAsset { preview focalPoint { x y } }\n collectionIds\n }\n totalItems\n facetValues { facetValue { id name code facet { id name code } } count }\n }\n }\n";
8
+ export declare const ACTIVE_ORDER = "\n query ActiveOrder {\n activeOrder {\n id code state active\n totalQuantity\n subTotal subTotalWithTax\n shipping shippingWithTax\n total totalWithTax\n currencyCode\n lines {\n id quantity\n unitPrice unitPriceWithTax\n linePrice linePriceWithTax\n productVariant {\n id name sku\n product { id name slug }\n options { id name group { name } }\n }\n featuredAsset { source presets { xs { url webpUrl } } }\n }\n shippingAddress { fullName streetLine1 streetLine2 city province postalCode countryCode }\n customer { id firstName lastName emailAddress }\n couponCodes\n }\n }\n";
9
+ export declare const ADD_TO_CART = "\n mutation AddToCart($variantId: ID!, $quantity: Int!) {\n addItemToOrder(productVariantId: $variantId, quantity: $quantity) {\n ... on Order {\n id code state active totalQuantity\n subTotal subTotalWithTax shipping shippingWithTax total totalWithTax currencyCode\n lines {\n id quantity unitPrice unitPriceWithTax linePrice linePriceWithTax\n productVariant { id name sku product { id name slug } options { id name group { name } } }\n featuredAsset { source presets { xs { url webpUrl } } }\n }\n shippingAddress { fullName streetLine1 streetLine2 city province postalCode countryCode }\n customer { id firstName lastName emailAddress }\n couponCodes\n }\n ... on OrderModificationError { errorCode message }\n ... on OrderLimitError { errorCode message maxItems }\n ... on NegativeQuantityError { errorCode message }\n ... on InsufficientStockError { errorCode message quantityAvailable order { id } }\n }\n }\n";
10
+ export declare const ADJUST_ORDER_LINE = "\n mutation AdjustOrderLine($lineId: ID!, $quantity: Int!) {\n adjustOrderLine(orderLineId: $lineId, quantity: $quantity) {\n ... on Order {\n id code state active totalQuantity\n subTotal subTotalWithTax shipping shippingWithTax total totalWithTax currencyCode\n lines {\n id quantity unitPrice unitPriceWithTax linePrice linePriceWithTax\n productVariant { id name sku product { id name slug } options { id name group { name } } }\n featuredAsset { source presets { xs { url webpUrl } } }\n }\n shippingAddress { fullName streetLine1 streetLine2 city province postalCode countryCode }\n customer { id firstName lastName emailAddress }\n couponCodes\n }\n ... on OrderModificationError { errorCode message }\n ... on OrderLimitError { errorCode message maxItems }\n ... on NegativeQuantityError { errorCode message }\n ... on InsufficientStockError { errorCode message quantityAvailable }\n }\n }\n";
11
+ export declare const REMOVE_ORDER_LINE = "\n mutation RemoveOrderLine($lineId: ID!) {\n removeOrderLine(orderLineId: $lineId) {\n ... on Order {\n id code state active totalQuantity\n subTotal subTotalWithTax shipping shippingWithTax total totalWithTax currencyCode\n lines {\n id quantity unitPrice unitPriceWithTax linePrice linePriceWithTax\n productVariant { id name sku product { id name slug } options { id name group { name } } }\n featuredAsset { source presets { xs { url webpUrl } } }\n }\n shippingAddress { fullName streetLine1 streetLine2 city province postalCode countryCode }\n customer { id firstName lastName emailAddress }\n couponCodes\n }\n ... on OrderModificationError { errorCode message }\n }\n }\n";
12
+ export declare const APPLY_COUPON = "\n mutation ApplyCoupon($code: String!) {\n applyCouponCode(couponCode: $code) {\n ... on Order {\n id code state active totalQuantity\n subTotal subTotalWithTax shipping shippingWithTax total totalWithTax currencyCode\n lines {\n id quantity unitPrice unitPriceWithTax linePrice linePriceWithTax\n productVariant { id name sku product { id name slug } options { id name group { name } } }\n featuredAsset { source presets { xs { url webpUrl } } }\n }\n couponCodes\n }\n ... on CouponCodeExpiredError { errorCode message couponCode }\n ... on CouponCodeInvalidError { errorCode message couponCode }\n ... on CouponCodeLimitError { errorCode message couponCode limit }\n }\n }\n";
13
+ export declare const REMOVE_COUPON = "\n mutation RemoveCoupon($code: String!) {\n removeCouponCode(couponCode: $code) {\n id code state active totalQuantity\n subTotal subTotalWithTax shipping shippingWithTax total totalWithTax currencyCode\n lines {\n id quantity unitPrice unitPriceWithTax linePrice linePriceWithTax\n productVariant { id name sku product { id name slug } options { id name group { name } } }\n featuredAsset { source presets { xs { url webpUrl } } }\n }\n couponCodes\n }\n }\n";
14
+ export declare const SET_CUSTOMER = "\n mutation SetCustomer($input: CreateCustomerInput!) {\n setCustomerForOrder(input: $input) {\n ... on Order {\n id customer { id firstName lastName emailAddress }\n }\n ... on AlreadyLoggedInError { errorCode message }\n ... on EmailAddressConflictError { errorCode message }\n ... on GuestCheckoutError { errorCode message }\n ... on NoActiveOrderError { errorCode message }\n }\n }\n";
15
+ export declare const SET_SHIPPING_ADDRESS = "\n mutation SetShippingAddress($input: CreateAddressInput!) {\n setOrderShippingAddress(input: $input) {\n ... on Order {\n id shippingAddress { fullName streetLine1 streetLine2 city province postalCode countryCode }\n }\n ... on NoActiveOrderError { errorCode message }\n }\n }\n";
16
+ export declare const SET_BILLING_ADDRESS = "\n mutation SetBillingAddress($input: CreateAddressInput!) {\n setOrderBillingAddress(input: $input) {\n ... on Order {\n id\n }\n ... on NoActiveOrderError { errorCode message }\n }\n }\n";
17
+ export declare const ELIGIBLE_SHIPPING_METHODS = "\n query ShippingMethods {\n eligibleShippingMethods {\n id name description price priceWithTax metadata\n }\n }\n";
18
+ export declare const SET_SHIPPING_METHOD = "\n mutation SetShippingMethod($ids: [ID!]!) {\n setOrderShippingMethod(shippingMethodId: $ids) {\n ... on Order {\n id shipping shippingWithTax total totalWithTax\n }\n ... on OrderModificationError { errorCode message }\n ... on IneligibleShippingMethodError { errorCode message }\n ... on NoActiveOrderError { errorCode message }\n }\n }\n";
19
+ export declare const ELIGIBLE_PAYMENT_METHODS = "\n query PaymentMethods {\n eligiblePaymentMethods {\n id name code description isEligible eligibilityMessage\n }\n }\n";
20
+ export declare const TRANSITION_TO_ARRANGING_PAYMENT = "\n mutation TransitionToArrangingPayment {\n transitionOrderToState(state: \"ArrangingPayment\") {\n ... on Order { id state }\n ... on OrderStateTransitionError { errorCode message transitionError }\n }\n }\n";
21
+ export declare const ADD_PAYMENT = "\n mutation AddPayment($input: PaymentInput!) {\n addPaymentToOrder(input: $input) {\n ... on Order { id code state totalWithTax }\n ... on OrderPaymentStateError { errorCode message }\n ... on IneligiblePaymentMethodError { errorCode message }\n ... on PaymentFailedError { errorCode message paymentErrorMessage }\n ... on PaymentDeclinedError { errorCode message paymentErrorMessage }\n ... on OrderStateTransitionError { errorCode message transitionError }\n ... on NoActiveOrderError { errorCode message }\n }\n }\n";
22
+ export declare const LOGIN = "\n mutation Login($email: String!, $password: String!) {\n login(username: $email, password: $password) {\n ... on CurrentUser { id identifier }\n ... on InvalidCredentialsError { errorCode message authenticationError }\n ... on NotVerifiedError { errorCode message }\n ... on NativeAuthStrategyError { errorCode message }\n }\n }\n";
23
+ export declare const REGISTER = "\n mutation Register($input: RegisterCustomerInput!) {\n registerCustomerAccount(input: $input) {\n ... on Success { success }\n ... on MissingPasswordError { errorCode message }\n ... on PasswordValidationError { errorCode message validationErrorMessage }\n ... on NativeAuthStrategyError { errorCode message }\n }\n }\n";
24
+ export declare const GET_CURRENT_CUSTOMER = "\n query Me {\n activeCustomer {\n id firstName lastName emailAddress phoneNumber\n addresses {\n id fullName streetLine1 streetLine2 city province postalCode\n country { code name }\n defaultShippingAddress defaultBillingAddress\n }\n orders(options: { take: 10, sort: { createdAt: DESC } }) {\n items {\n id code state totalWithTax createdAt\n lines { id quantity productVariant { name } }\n }\n totalItems\n }\n }\n }\n";
25
+ export declare const GET_CUSTOMER_ORDERS = "\n query CustomerOrders($options: OrderListOptions) {\n activeCustomer {\n orders(options: $options) {\n items {\n id code state totalWithTax createdAt\n lines { id quantity productVariant { name } }\n }\n totalItems\n }\n }\n }\n";
26
+ export declare const LOGOUT = "\n mutation Logout {\n logout { success }\n }\n";
27
+ export declare const GET_EXCHANGE_RATES = "\n query ExchangeRates {\n exchangeRates {\n baseCurrency targetCurrency rate inverseRate rateDate\n }\n }\n";
28
+ export declare const CONVERT_CURRENCY = "\n query ConvertCurrency($amount: String!, $from: String!, $to: String!) {\n convertCurrency(amount: $amount, fromCurrency: $from, toCurrency: $to) {\n amount fromCurrency toCurrency rate result\n }\n }\n";
29
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/commerce/queries.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,ipCAsCvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,2oCAsC7B,CAAC;AAEF,eAAO,MAAM,aAAa,mrBAsBzB,CAAC;AAEF,eAAO,MAAM,WAAW,wJAUvB,CAAC;AAIF,eAAO,MAAM,gBAAgB,6ZAgB5B,CAAC;AAEF,eAAO,MAAM,cAAc,+oBAwB1B,CAAC;AAIF,eAAO,MAAM,eAAe,+gBAe3B,CAAC;AAIF,eAAO,MAAM,YAAY,2sBAyBxB,CAAC;AAEF,eAAO,MAAM,WAAW,2gCAqBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,0/BAqB7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,gxBAkB7B,CAAC;AAEF,eAAO,MAAM,YAAY,0wBAkBxB,CAAC;AAEF,eAAO,MAAM,aAAa,ugBAazB,CAAC;AAIF,eAAO,MAAM,YAAY,qbAYxB,CAAC;AAEF,eAAO,MAAM,oBAAoB,2TAShC,CAAC;AAEF,eAAO,MAAM,mBAAmB,+NAS/B,CAAC;AAEF,eAAO,MAAM,yBAAyB,oIAMrC,CAAC;AAEF,eAAO,MAAM,mBAAmB,kYAW/B,CAAC;AAEF,eAAO,MAAM,wBAAwB,yIAMpC,CAAC;AAEF,eAAO,MAAM,+BAA+B,wOAO3C,CAAC;AAEF,eAAO,MAAM,WAAW,ujBAYvB,CAAC;AAIF,eAAO,MAAM,KAAK,6WASjB,CAAC;AAEF,eAAO,MAAM,QAAQ,kWASpB,CAAC;AAEF,eAAO,MAAM,oBAAoB,wgBAkBhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,oSAY/B,CAAC;AAEF,eAAO,MAAM,MAAM,yDAIlB,CAAC;AAIF,eAAO,MAAM,kBAAkB,8HAM9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,8NAM5B,CAAC"}