@platform-x-shp/shopify-adapter 0.10.0 → 0.11.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 (46) hide show
  1. package/dist/src/cart.d.ts +12 -0
  2. package/dist/src/cart.d.ts.map +1 -1
  3. package/dist/src/cart.js +36 -0
  4. package/dist/src/cart.js.map +1 -1
  5. package/dist/src/customer-account.d.ts +11 -0
  6. package/dist/src/customer-account.d.ts.map +1 -0
  7. package/dist/src/customer-account.js +95 -0
  8. package/dist/src/customer-account.js.map +1 -0
  9. package/dist/src/delivery-sso.d.ts +30 -7
  10. package/dist/src/delivery-sso.d.ts.map +1 -1
  11. package/dist/src/delivery-sso.js +88 -52
  12. package/dist/src/delivery-sso.js.map +1 -1
  13. package/dist/src/errors.d.ts +8 -0
  14. package/dist/src/errors.d.ts.map +1 -1
  15. package/dist/src/errors.js +13 -1
  16. package/dist/src/errors.js.map +1 -1
  17. package/dist/src/gateway-session.d.ts +38 -0
  18. package/dist/src/gateway-session.d.ts.map +1 -0
  19. package/dist/src/gateway-session.js +82 -0
  20. package/dist/src/gateway-session.js.map +1 -0
  21. package/dist/src/index.d.ts +10 -4
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/index.js +33 -2
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/my-account.d.ts +44 -0
  26. package/dist/src/my-account.d.ts.map +1 -0
  27. package/dist/src/my-account.js +280 -0
  28. package/dist/src/my-account.js.map +1 -0
  29. package/dist/src/redis-connector.d.ts +14 -0
  30. package/dist/src/redis-connector.d.ts.map +1 -1
  31. package/dist/src/redis-connector.js +60 -0
  32. package/dist/src/redis-connector.js.map +1 -1
  33. package/dist/src/shopify-oidc.d.ts +31 -0
  34. package/dist/src/shopify-oidc.d.ts.map +1 -0
  35. package/dist/src/shopify-oidc.js +80 -0
  36. package/dist/src/shopify-oidc.js.map +1 -0
  37. package/dist/src/shopify-session.d.ts +89 -0
  38. package/dist/src/shopify-session.d.ts.map +1 -0
  39. package/dist/src/shopify-session.js +251 -0
  40. package/dist/src/shopify-session.js.map +1 -0
  41. package/dist/src/tenant-config.d.ts.map +1 -1
  42. package/dist/src/tenant-config.js +3 -1
  43. package/dist/src/tenant-config.js.map +1 -1
  44. package/dist/src/tenant-types.d.ts +7 -0
  45. package/dist/src/tenant-types.d.ts.map +1 -1
  46. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;IAG1B;IAFlB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AAVD,kDAUC;AAED,MAAa,oBAAqB,SAAQ,mBAAmB;IAC3D,YAAY,OAAO,GAAG,WAAW,EAAE,OAAiC;QAClE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AALD,oDAKC;AAOD,4FAA4F;AAC5F,MAAa,sBAAuB,SAAQ,mBAAmB;IAG3C;IAFlB,YACE,OAAe,EACC,UAA8B;QAE9C,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QAFf,eAAU,GAAV,UAAU,CAAoB;QAG9C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AARD,wDAQC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;IAG1B;IAFlB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AAVD,kDAUC;AAED,MAAa,oBAAqB,SAAQ,mBAAmB;IAC3D,YAAY,OAAO,GAAG,WAAW,EAAE,OAAiC;QAClE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AALD,oDAKC;AAOD,4FAA4F;AAC5F,MAAa,sBAAuB,SAAQ,mBAAmB;IAG3C;IAFlB,YACE,OAAe,EACC,UAA8B;QAE9C,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QAFf,eAAU,GAAV,UAAU,CAAoB;QAG9C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AARD,wDAQC;AAED;;;;GAIG;AACH,MAAa,yBAA0B,SAAQ,mBAAmB;IAChE,YAAY,OAAO,GAAG,4CAA4C,EAAE,OAAiC;QACnG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AALD,8DAKC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Read-only access to the delivery gateway's `express-session` record, so a
3
+ * backend behind the gateway can learn who the logged-in user is from the
4
+ * forwarded `platform-x-session` cookie instead of trusting plain headers.
5
+ *
6
+ * Deliberately not `express-session` itself: that middleware resets the
7
+ * record's TTL on every response, and this service must never write to the
8
+ * gateway's session. This only verifies the cookie signature and does one
9
+ * Redis GET.
10
+ */
11
+ export interface GatewaySessionConfig {
12
+ /** Cookie name, `platform-x-session` at the gateway. */
13
+ cookieName: string;
14
+ /** Gateway cookie secret(s). More than one allows secret rotation; the first is the current one. */
15
+ secrets: string[];
16
+ /** Redis key prefix of the gateway's session store, `platform-x-session:` at the gateway. */
17
+ prefix: string;
18
+ }
19
+ export interface GatewaySession {
20
+ /** The gateway session id, the unsigned cookie value. */
21
+ sessionId: string;
22
+ /** `session.userInfo` as the gateway stores it after Keycloak login. */
23
+ userInfo?: Record<string, unknown>;
24
+ /** `session.token` as the gateway stores it (Keycloak access token and expiry). */
25
+ token?: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Same check as `cookie-signature`'s `unsign`: the value is `s:<id>.<sig>` and
29
+ * `<sig>` is the base64 HMAC-SHA256 of `<id>`, without padding.
30
+ */
31
+ export declare function unsignGatewayCookie(rawValue: string, secrets: string[]): string | null;
32
+ /**
33
+ * Returns the gateway session for a request's `Cookie` header, or `null` when
34
+ * there is no cookie, the signature is wrong, or no record exists. Throws
35
+ * {@link ShopifySessionUnavailableError} only when Redis cannot be read.
36
+ */
37
+ export declare function readGatewaySession(cookieHeader: string | undefined, config: GatewaySessionConfig): Promise<GatewaySession | null>;
38
+ //# sourceMappingURL=gateway-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-session.d.ts","sourceRoot":"","sources":["../../src/gateway-session.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AAEH,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,oGAAoG;IACpG,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAwBD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAatF;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAmBhC"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.unsignGatewayCookie = unsignGatewayCookie;
7
+ exports.readGatewaySession = readGatewaySession;
8
+ const node_crypto_1 = __importDefault(require("node:crypto"));
9
+ const redis_connector_1 = require("./redis-connector");
10
+ const shopify_session_1 = require("./shopify-session");
11
+ function parseCookie(header, name) {
12
+ if (!header)
13
+ return undefined;
14
+ for (const part of header.split(';')) {
15
+ const index = part.indexOf('=');
16
+ if (index < 0)
17
+ continue;
18
+ if (part.slice(0, index).trim() === name)
19
+ return part.slice(index + 1).trim();
20
+ }
21
+ return undefined;
22
+ }
23
+ function safeDecode(value) {
24
+ try {
25
+ return decodeURIComponent(value);
26
+ }
27
+ catch {
28
+ return value;
29
+ }
30
+ }
31
+ function signature(sessionId, secret) {
32
+ return node_crypto_1.default.createHmac('sha256', secret).update(sessionId).digest('base64').replace(/=+$/, '');
33
+ }
34
+ /**
35
+ * Same check as `cookie-signature`'s `unsign`: the value is `s:<id>.<sig>` and
36
+ * `<sig>` is the base64 HMAC-SHA256 of `<id>`, without padding.
37
+ */
38
+ function unsignGatewayCookie(rawValue, secrets) {
39
+ const value = safeDecode(rawValue);
40
+ if (!value.startsWith('s:'))
41
+ return null;
42
+ const signed = value.slice(2);
43
+ const dot = signed.lastIndexOf('.');
44
+ if (dot <= 0)
45
+ return null;
46
+ const sessionId = signed.slice(0, dot);
47
+ const given = Buffer.from(signed.slice(dot + 1));
48
+ for (const secret of secrets) {
49
+ const expected = Buffer.from(signature(sessionId, secret));
50
+ if (given.length === expected.length && node_crypto_1.default.timingSafeEqual(given, expected))
51
+ return sessionId;
52
+ }
53
+ return null;
54
+ }
55
+ /**
56
+ * Returns the gateway session for a request's `Cookie` header, or `null` when
57
+ * there is no cookie, the signature is wrong, or no record exists. Throws
58
+ * {@link ShopifySessionUnavailableError} only when Redis cannot be read.
59
+ */
60
+ async function readGatewaySession(cookieHeader, config) {
61
+ if (config.secrets.length === 0)
62
+ return null;
63
+ const raw = parseCookie(cookieHeader, config.cookieName);
64
+ if (!raw)
65
+ return null;
66
+ const sessionId = unsignGatewayCookie(raw, config.secrets);
67
+ if (!sessionId)
68
+ return null;
69
+ let record;
70
+ try {
71
+ record = (await (0, redis_connector_1.getRedisValueStrict)(`${config.prefix}${sessionId}`, true));
72
+ }
73
+ catch (err) {
74
+ if (err instanceof redis_connector_1.RedisUnavailableError)
75
+ throw new shopify_session_1.ShopifySessionUnavailableError('Session store is unavailable');
76
+ throw err;
77
+ }
78
+ if (!record)
79
+ return null;
80
+ return { sessionId, userInfo: record.userInfo, token: record.token };
81
+ }
82
+ //# sourceMappingURL=gateway-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-session.js","sourceRoot":"","sources":["../../src/gateway-session.ts"],"names":[],"mappings":";;;;;AA4DA,kDAaC;AAOD,gDAsBC;AAtGD,8DAAiC;AAEjC,uDAA+E;AAC/E,uDAAmE;AA+BnE,SAAS,WAAW,CAAC,MAA0B,EAAE,IAAY;IAC3D,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CA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Q,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACvE,CAAC"}
@@ -18,11 +18,13 @@
18
18
  */
19
19
  export { adminGraphql, storefrontGraphql } from './client';
20
20
  export type { ShopifyApiType } from './client';
21
- export { ShopifyAdapterError, ShopifyNotFoundError, ShopifyUserErrorsError } from './errors';
21
+ export { ShopifyAdapterError, ShopifyNotFoundError, ShopifyUserErrorsError, ShopifyCustomerTokenError } from './errors';
22
+ export { customerAccountGraphql, customerAccountEndpoint } from './customer-account';
23
+ export { getMyCustomer, updateMyCustomer, listMyAddresses, getMyAddress, createMyAddress, updateMyAddress, deleteMyAddress, setMyDefaultAddress, listMyOrders, getMyOrder, } from './my-account';
22
24
  export type { ShopifyUserError } from './errors';
23
25
  export { fetchProducts, fetchProductById, fetchProductByIdOrThrow, fetchProductByHandle, searchProducts, getProductFilters, fetchProductVariants, fetchVariantById, fetchVariantInventory, fetchProductMedia, fetchCollections, fetchCollectionById, fetchCollectionProducts, } from './products';
24
26
  export type { ShopifyProduct, ProductsPage, PageInfo, ShopifyProductVariant, ShopifyProductMedia, InventoryByLocation, VariantInventory, ShopifyCollection, CollectionsPage, FilterOptions, } from './products';
25
- export { createCart, getCart, addCartLines, updateCartLines, removeCartLines, linkCartToCustomer, } from './cart';
27
+ export { createCart, getCart, addCartLines, updateCartLines, removeCartLines, linkCartToCustomer, linkCartToCustomerAccount, } from './cart';
26
28
  export type { ShopifyCart, ShopifyCartLine, ShopifyMoney, CartLineInput, CartLineUpdateInput } from './cart';
27
29
  export { listOrders, getOrderById, updateOrder, cancelOrder, closeOrder, reopenOrder, captureOrderPayment, markOrderAsPaid, calculateRefund, createRefund, createDraftOrder, getDraftOrder, completeDraftOrder, sendDraftOrderInvoice, } from './orders';
28
30
  export type { ShopifyOrder, ShopifyOrderSummary, ShopifyOrderLineItem, ShopifyOrderAddress, OrdersPage, OrdersPageInfo, OrderUpdateInput, OrderCancelInput, OrderCancelResult, OrderCaptureInput, ShopifyOrderTransaction, RefundLineItemInput, CalculateRefundInput, SuggestedRefund, SuggestedRefundLineItem, RefundInput, ShopifyRefund, DraftOrderLineItemInput, DraftOrderInput, ShopifyDraftOrder, DraftOrderCompleteInput, EmailInput, } from './orders';
@@ -47,8 +49,12 @@ export { extractBearer, verifyKeycloakToken, keycloakConfigForTenant, requireKey
47
49
  export type { KeycloakTokenPayload, KeycloakVerifyConfig } from './keycloak-auth';
48
50
  export { signPlatformXToken, verifyPlatformXToken, platformXConfigForTenant, platformXSigningConfigForTenant, requirePlatformXAuth, } from './platformx-auth';
49
51
  export type { PlatformXTokenPayload, PlatformXSigningConfig, PlatformXVerifyConfig } from './platformx-auth';
50
- export { beginDeliverySso, handleShopifyOAuthCallback, mintShopifySession, logoutShopifySession, errorReturnUrl, requireCsrfHeader, sessionCors, HttpError, SESSION_COOKIE_NAME, SESSION_TTL_SECONDS, } from './delivery-sso';
51
- export type { DeliverySsoConfig, MintedSession } from './delivery-sso';
52
+ export { beginDeliverySso, handleShopifyOAuthCallback, mintShopifySession, logoutShopifySession, errorReturnUrl, requireCsrfHeader, sessionCors, HttpError, SESSION_COOKIE_NAME, SESSION_TTL_SECONDS, EMAIL_MISMATCH_ERROR, } from './delivery-sso';
53
+ export type { DeliverySsoConfig, MintedSession, GatewaySessionIdentity } from './delivery-sso';
54
+ export { validateShopifySession, ensureShopifySession, endShopifySession, getShopifySession, saveShopifySession, deleteShopifySession, shopifySessionKey, resolveSessionSettings, ShopifySessionUnavailableError, } from './shopify-session';
55
+ export { readGatewaySession, unsignGatewayCookie } from './gateway-session';
56
+ export type { GatewaySession, GatewaySessionConfig } from './gateway-session';
57
+ export type { ShopifySessionRecord, ShopifySessionValidation, EnsureShopifySessionResult, ShopifySessionSettings, } from './shopify-session';
52
58
  export { Logger } from './utils/logger';
53
59
  export type { LoggerInterface } from './utils/logger';
54
60
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src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M,mBAAmB,CAAC;AAC5E,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/src/index.js CHANGED
@@ -18,8 +18,9 @@
18
18
  * shopify-adapter stack.
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.shopifyTopicToRoutingKey = exports.ORDER_WEBHOOK_TOPICS = exports.cartCreatedEvent = exports.setDefaultCustomerAddress = exports.deleteCustomerAddress = exports.updateCustomerAddress = exports.createCustomerAddress = exports.getCustomerAddress = exports.listCustomerAddresses = exports.updateCustomer = exports.getCustomerByEmail = exports.getCustomerById = exports.sendDraftOrderInvoice = exports.completeDraftOrder = exports.getDraftOrder = exports.createDraftOrder = exports.createRefund = exports.calculateRefund = exports.markOrderAsPaid = exports.captureOrderPayment = exports.reopenOrder = exports.closeOrder = exports.cancelOrder = exports.updateOrder = exports.getOrderById = exports.listOrders = exports.linkCartToCustomer = exports.removeCartLines = exports.updateCartLines = exports.addCartLines = exports.getCart = exports.createCart = exports.fetchCollectionProducts = exports.fetchCollectionById = exports.fetchCollections = exports.fetchProductMedia = exports.fetchVariantInventory = exports.fetchVariantById = exports.fetchProductVariants = exports.getProductFilters = exports.searchProducts = exports.fetchProductByHandle = exports.fetchProductByIdOrThrow = exports.fetchProductById = exports.fetchProducts = exports.ShopifyUserErrorsError = exports.ShopifyNotFoundError = exports.ShopifyAdapterError = exports.storefrontGraphql = exports.adminGraphql = void 0;
22
- exports.Logger = exports.SESSION_TTL_SECONDS = exports.SESSION_COOKIE_NAME = exports.HttpError = exports.sessionCors = exports.requireCsrfHeader = exports.errorReturnUrl = exports.logoutShopifySession = exports.mintShopifySession = exports.handleShopifyOAuthCallback = exports.beginDeliverySso = exports.requirePlatformXAuth = exports.platformXSigningConfigForTenant = exports.platformXConfigForTenant = exports.verifyPlatformXToken = exports.signPlatformXToken = exports.requireKeycloakAuth = exports.keycloakConfigForTenant = exports.verifyKeycloakToken = exports.extractBearer = exports.UnauthorizedError = exports.TokenInvalidError = exports.TokenExpiredError = exports.SecretNotFoundError = exports.TenantNotFoundError = exports.CircuitOpenError = exports.TimeoutError = exports.CircuitBreaker = exports.withTimeout = exports.withRetry = exports.ClientError = exports.gql = exports.clearGraphQLClientCache = exports.getGraphQLClient = exports.HepSecretProvider = exports.createConfigProvider = exports.buildSecretId = exports.extractSiteName = exports.getClientTenantDetails = exports.setConfigProvider = exports.clearTenantCache = exports.getActiveCommerceProvider = exports.getTenantConfig = exports.registerShopifyWebhooks = exports.createShopifyWebhookRouter = void 0;
21
+ exports.getDraftOrder = exports.createDraftOrder = exports.createRefund = exports.calculateRefund = exports.markOrderAsPaid = exports.captureOrderPayment = exports.reopenOrder = exports.closeOrder = exports.cancelOrder = exports.updateOrder = exports.getOrderById = exports.listOrders = exports.linkCartToCustomerAccount = exports.linkCartToCustomer = exports.removeCartLines = exports.updateCartLines = exports.addCartLines = exports.getCart = exports.createCart = exports.fetchCollectionProducts = exports.fetchCollectionById = exports.fetchCollections = exports.fetchProductMedia = exports.fetchVariantInventory = exports.fetchVariantById = exports.fetchProductVariants = exports.getProductFilters = exports.searchProducts = exports.fetchProductByHandle = exports.fetchProductByIdOrThrow = exports.fetchProductById = exports.fetchProducts = exports.getMyOrder = exports.listMyOrders = exports.setMyDefaultAddress = exports.deleteMyAddress = exports.updateMyAddress = exports.createMyAddress = exports.getMyAddress = exports.listMyAddresses = exports.updateMyCustomer = exports.getMyCustomer = exports.customerAccountEndpoint = exports.customerAccountGraphql = exports.ShopifyCustomerTokenError = exports.ShopifyUserErrorsError = exports.ShopifyNotFoundError = exports.ShopifyAdapterError = exports.storefrontGraphql = exports.adminGraphql = void 0;
22
+ exports.handleShopifyOAuthCallback = exports.beginDeliverySso = exports.requirePlatformXAuth = exports.platformXSigningConfigForTenant = exports.platformXConfigForTenant = exports.verifyPlatformXToken = exports.signPlatformXToken = exports.requireKeycloakAuth = exports.keycloakConfigForTenant = exports.verifyKeycloakToken = exports.extractBearer = exports.UnauthorizedError = exports.TokenInvalidError = exports.TokenExpiredError = exports.SecretNotFoundError = exports.TenantNotFoundError = exports.CircuitOpenError = exports.TimeoutError = exports.CircuitBreaker = exports.withTimeout = exports.withRetry = exports.ClientError = exports.gql = exports.clearGraphQLClientCache = exports.getGraphQLClient = exports.HepSecretProvider = exports.createConfigProvider = exports.buildSecretId = exports.extractSiteName = exports.getClientTenantDetails = exports.setConfigProvider = exports.clearTenantCache = exports.getActiveCommerceProvider = exports.getTenantConfig = exports.registerShopifyWebhooks = exports.createShopifyWebhookRouter = exports.shopifyTopicToRoutingKey = exports.ORDER_WEBHOOK_TOPICS = exports.cartCreatedEvent = exports.setDefaultCustomerAddress = exports.deleteCustomerAddress = exports.updateCustomerAddress = exports.createCustomerAddress = exports.getCustomerAddress = exports.listCustomerAddresses = exports.updateCustomer = exports.getCustomerByEmail = exports.getCustomerById = exports.sendDraftOrderInvoice = exports.completeDraftOrder = void 0;
23
+ exports.Logger = exports.unsignGatewayCookie = exports.readGatewaySession = exports.ShopifySessionUnavailableError = exports.resolveSessionSettings = exports.shopifySessionKey = exports.deleteShopifySession = exports.saveShopifySession = exports.getShopifySession = exports.endShopifySession = exports.ensureShopifySession = exports.validateShopifySession = exports.EMAIL_MISMATCH_ERROR = exports.SESSION_TTL_SECONDS = exports.SESSION_COOKIE_NAME = exports.HttpError = exports.sessionCors = exports.requireCsrfHeader = exports.errorReturnUrl = exports.logoutShopifySession = exports.mintShopifySession = void 0;
23
24
  var client_1 = require("./client");
24
25
  Object.defineProperty(exports, "adminGraphql", { enumerable: true, get: function () { return client_1.adminGraphql; } });
25
26
  Object.defineProperty(exports, "storefrontGraphql", { enumerable: true, get: function () { return client_1.storefrontGraphql; } });
@@ -27,6 +28,21 @@ var errors_1 = require("./errors");
27
28
  Object.defineProperty(exports, "ShopifyAdapterError", { enumerable: true, get: function () { return errors_1.ShopifyAdapterError; } });
28
29
  Object.defineProperty(exports, "ShopifyNotFoundError", { enumerable: true, get: function () { return errors_1.ShopifyNotFoundError; } });
29
30
  Object.defineProperty(exports, "ShopifyUserErrorsError", { enumerable: true, get: function () { return errors_1.ShopifyUserErrorsError; } });
31
+ Object.defineProperty(exports, "ShopifyCustomerTokenError", { enumerable: true, get: function () { return errors_1.ShopifyCustomerTokenError; } });
32
+ var customer_account_1 = require("./customer-account");
33
+ Object.defineProperty(exports, "customerAccountGraphql", { enumerable: true, get: function () { return customer_account_1.customerAccountGraphql; } });
34
+ Object.defineProperty(exports, "customerAccountEndpoint", { enumerable: true, get: function () { return customer_account_1.customerAccountEndpoint; } });
35
+ var my_account_1 = require("./my-account");
36
+ Object.defineProperty(exports, "getMyCustomer", { enumerable: true, get: function () { return my_account_1.getMyCustomer; } });
37
+ Object.defineProperty(exports, "updateMyCustomer", { enumerable: true, get: function () { return my_account_1.updateMyCustomer; } });
38
+ Object.defineProperty(exports, "listMyAddresses", { enumerable: true, get: function () { return my_account_1.listMyAddresses; } });
39
+ Object.defineProperty(exports, "getMyAddress", { enumerable: true, get: function () { return my_account_1.getMyAddress; } });
40
+ Object.defineProperty(exports, "createMyAddress", { enumerable: true, get: function () { return my_account_1.createMyAddress; } });
41
+ Object.defineProperty(exports, "updateMyAddress", { enumerable: true, get: function () { return my_account_1.updateMyAddress; } });
42
+ Object.defineProperty(exports, "deleteMyAddress", { enumerable: true, get: function () { return my_account_1.deleteMyAddress; } });
43
+ Object.defineProperty(exports, "setMyDefaultAddress", { enumerable: true, get: function () { return my_account_1.setMyDefaultAddress; } });
44
+ Object.defineProperty(exports, "listMyOrders", { enumerable: true, get: function () { return my_account_1.listMyOrders; } });
45
+ Object.defineProperty(exports, "getMyOrder", { enumerable: true, get: function () { return my_account_1.getMyOrder; } });
30
46
  var products_1 = require("./products");
31
47
  Object.defineProperty(exports, "fetchProducts", { enumerable: true, get: function () { return products_1.fetchProducts; } });
32
48
  Object.defineProperty(exports, "fetchProductById", { enumerable: true, get: function () { return products_1.fetchProductById; } });
@@ -48,6 +64,7 @@ Object.defineProperty(exports, "addCartLines", { enumerable: true, get: function
48
64
  Object.defineProperty(exports, "updateCartLines", { enumerable: true, get: function () { return cart_1.updateCartLines; } });
49
65
  Object.defineProperty(exports, "removeCartLines", { enumerable: true, get: function () { return cart_1.removeCartLines; } });
50
66
  Object.defineProperty(exports, "linkCartToCustomer", { enumerable: true, get: function () { return cart_1.linkCartToCustomer; } });
67
+ Object.defineProperty(exports, "linkCartToCustomerAccount", { enumerable: true, get: function () { return cart_1.linkCartToCustomerAccount; } });
51
68
  var orders_1 = require("./orders");
52
69
  Object.defineProperty(exports, "listOrders", { enumerable: true, get: function () { return orders_1.listOrders; } });
53
70
  Object.defineProperty(exports, "getOrderById", { enumerable: true, get: function () { return orders_1.getOrderById; } });
@@ -134,6 +151,20 @@ Object.defineProperty(exports, "sessionCors", { enumerable: true, get: function
134
151
  Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return delivery_sso_1.HttpError; } });
135
152
  Object.defineProperty(exports, "SESSION_COOKIE_NAME", { enumerable: true, get: function () { return delivery_sso_1.SESSION_COOKIE_NAME; } });
136
153
  Object.defineProperty(exports, "SESSION_TTL_SECONDS", { enumerable: true, get: function () { return delivery_sso_1.SESSION_TTL_SECONDS; } });
154
+ Object.defineProperty(exports, "EMAIL_MISMATCH_ERROR", { enumerable: true, get: function () { return delivery_sso_1.EMAIL_MISMATCH_ERROR; } });
155
+ var shopify_session_1 = require("./shopify-session");
156
+ Object.defineProperty(exports, "validateShopifySession", { enumerable: true, get: function () { return shopify_session_1.validateShopifySession; } });
157
+ Object.defineProperty(exports, "ensureShopifySession", { enumerable: true, get: function () { return shopify_session_1.ensureShopifySession; } });
158
+ Object.defineProperty(exports, "endShopifySession", { enumerable: true, get: function () { return shopify_session_1.endShopifySession; } });
159
+ Object.defineProperty(exports, "getShopifySession", { enumerable: true, get: function () { return shopify_session_1.getShopifySession; } });
160
+ Object.defineProperty(exports, "saveShopifySession", { enumerable: true, get: function () { return shopify_session_1.saveShopifySession; } });
161
+ Object.defineProperty(exports, "deleteShopifySession", { enumerable: true, get: function () { return shopify_session_1.deleteShopifySession; } });
162
+ Object.defineProperty(exports, "shopifySessionKey", { enumerable: true, get: function () { return shopify_session_1.shopifySessionKey; } });
163
+ Object.defineProperty(exports, "resolveSessionSettings", { enumerable: true, get: function () { return shopify_session_1.resolveSessionSettings; } });
164
+ Object.defineProperty(exports, "ShopifySessionUnavailableError", { enumerable: true, get: function () { return shopify_session_1.ShopifySessionUnavailableError; } });
165
+ var gateway_session_1 = require("./gateway-session");
166
+ Object.defineProperty(exports, "readGatewaySession", { enumerable: true, get: function () { return gateway_session_1.readGatewaySession; } });
167
+ Object.defineProperty(exports, "unsignGatewayCookie", { enumerable: true, get: function () { return gateway_session_1.unsignGatewayCookie; } });
137
168
  var logger_1 = require("./utils/logger");
138
169
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
139
170
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;AAEH,mCAA2D;AAAlD,sGAAA,YAAY,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAExC,mCAA6F;AAApF,6GAAA,mBAAmB,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAE1E,uCAcoB;AAblB,yGAAA,aAAa,OAAA;AACb,4GAAA,gBAAgB,OAAA;AAChB,mHAAA,uBAAuB,OAAA;AACvB,gHAAA,oBAAoB,OAAA;AACpB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AAC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kB,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAQhD,yCAAwC;AAA/B,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,44 @@
1
+ import type { AddressInput, CustomerUpdateInput, ShopifyAddress, ShopifyCustomer } from './customers';
2
+ import type { OrdersPage, ShopifyOrder } from './orders';
3
+ /** The logged-in customer's own profile. */
4
+ export declare function getMyCustomer(siteName: string, accessToken: string): Promise<ShopifyCustomer>;
5
+ /**
6
+ * Updates the customer's name, phone and marketing consent.
7
+ *
8
+ * Their email is their login identity, so it cannot be changed here: passing a different one is rejected
9
+ * (passing the current one is ignored, so a form that always sends it still works).
10
+ *
11
+ * The Customer Account API has no mutation for the phone number, so a changed phone is written with the
12
+ * Admin API. The customer id for that call is read from the access token's own customer, never taken from
13
+ * the caller, so a customer can only ever change their own phone.
14
+ */
15
+ export declare function updateMyCustomer(siteName: string, accessToken: string, input: CustomerUpdateInput): Promise<ShopifyCustomer>;
16
+ /** The customer's addresses, each flagged with whether it is their default. */
17
+ export declare function listMyAddresses(siteName: string, accessToken: string): Promise<ShopifyAddress[]>;
18
+ /** One of the customer's addresses by id (numeric or GID), or `null`. */
19
+ export declare function getMyAddress(siteName: string, accessToken: string, addressId: string): Promise<ShopifyAddress | null>;
20
+ /** Adds an address, optionally as the default. */
21
+ export declare function createMyAddress(siteName: string, accessToken: string, input: AddressInput): Promise<ShopifyAddress>;
22
+ /** Updates an address's fields, optionally making it the default. `null` if it is not one of the customer's addresses. */
23
+ export declare function updateMyAddress(siteName: string, accessToken: string, addressId: string, input: AddressInput): Promise<ShopifyAddress | null>;
24
+ /** Removes an address and returns its id, or `null` if it is not one of the customer's addresses. */
25
+ export declare function deleteMyAddress(siteName: string, accessToken: string, addressId: string): Promise<string | null>;
26
+ /** Makes an existing address the customer's default and returns the updated profile, or `null` if it does not exist. */
27
+ export declare function setMyDefaultAddress(siteName: string, accessToken: string, addressId: string): Promise<ShopifyCustomer | null>;
28
+ /**
29
+ * The customer's own orders, newest first, with cursor pagination. An optional Shopify search `query` only ever
30
+ * narrows the customer's own orders further: Shopify applies it inside the token's scope.
31
+ */
32
+ export declare function listMyOrders(siteName: string, accessToken: string, opts?: {
33
+ first?: number;
34
+ after?: string;
35
+ query?: string;
36
+ }): Promise<OrdersPage>;
37
+ /**
38
+ * One of the customer's own orders, with line items. Throws `ShopifyNotFoundError` for an order that does
39
+ * not exist or belongs to someone else: Shopify does not distinguish them, and neither do we.
40
+ *
41
+ * The Customer Account API has no tags or archived flag on an order, so `tags` is empty and `closed` false.
42
+ */
43
+ export declare function getMyOrder(siteName: string, accessToken: string, orderId: string): Promise<ShopifyOrder>;
44
+ //# sourceMappingURL=my-account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"my-account.d.ts","sourceRoot":"","sources":["../../src/my-account.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtG,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAuB,MAAM,UAAU,CAAC;AA6F9E,4CAA4C;AAC5C,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAOnG;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,eAAe,CAAC,CAoC1B;AAED,+EAA+E;AAC/E,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAUtG;AAED,yEAAyE;AACzE,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAI3H;AAED,kDAAkD;AAClD,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAmBzH;AAED,0HAA0H;AAC1H,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAgBhC;AAED,qGAAqG;AACrG,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAatH;AAED,wHAAwH;AACxH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAajC;AAcD;;;GAGG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5D,OAAO,CAAC,UAAU,CAAC,CAqBrB;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAiD9G"}
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMyCustomer = getMyCustomer;
4
+ exports.updateMyCustomer = updateMyCustomer;
5
+ exports.listMyAddresses = listMyAddresses;
6
+ exports.getMyAddress = getMyAddress;
7
+ exports.createMyAddress = createMyAddress;
8
+ exports.updateMyAddress = updateMyAddress;
9
+ exports.deleteMyAddress = deleteMyAddress;
10
+ exports.setMyDefaultAddress = setMyDefaultAddress;
11
+ exports.listMyOrders = listMyOrders;
12
+ exports.getMyOrder = getMyOrder;
13
+ const customer_account_1 = require("./customer-account");
14
+ const customers_1 = require("./customers");
15
+ const errors_1 = require("./errors");
16
+ /**
17
+ * The delivery flow's customer and order functions: the logged-in customer's own
18
+ * data, read and written through the Customer Account API with their access
19
+ * token. Each takes the token instead of a customer id, because Shopify scopes
20
+ * every call to the token's owner. They return the same shapes as the Admin API
21
+ * versions in customers.ts and orders.ts, which the authoring flow keeps using.
22
+ *
23
+ * Field names checked against the 2026-04 Customer Account API schema on kiwi.
24
+ */
25
+ const ADDRESS_FIELDS = 'id firstName lastName address1 address2 city province country zip phoneNumber';
26
+ const CUSTOMER_FIELDS = `
27
+ id
28
+ firstName
29
+ lastName
30
+ emailAddress { emailAddress marketingState }
31
+ phoneNumber { phoneNumber }
32
+ creationDate
33
+ defaultAddress { id }
34
+ `;
35
+ const MONEY = 'amount currencyCode';
36
+ const ORDER_SUMMARY_FIELDS = `
37
+ id
38
+ name
39
+ email
40
+ createdAt
41
+ financialStatus
42
+ fulfillmentStatus
43
+ totalPrice { ${MONEY} }
44
+ `;
45
+ function ensureNoUserErrors(errors, message) {
46
+ if (errors && errors.length > 0) {
47
+ throw new errors_1.ShopifyUserErrorsError(message, errors);
48
+ }
49
+ }
50
+ /** The trailing numeric segment of a GID, ignoring any `?key=...` suffix Shopify appends to customer-facing ids. */
51
+ function numericId(gid) {
52
+ const last = gid.split('?')[0]?.split('/').pop() ?? gid;
53
+ return last;
54
+ }
55
+ function sameValue(a, b, ignoreCase) {
56
+ const norm = (v) => (ignoreCase ? (v ?? '').trim().toLowerCase() : (v ?? '').trim());
57
+ return norm(a) === norm(b);
58
+ }
59
+ function mapAddress(node, isDefault) {
60
+ return {
61
+ shopifyId: node.id,
62
+ firstName: node.firstName ?? undefined,
63
+ lastName: node.lastName ?? undefined,
64
+ address1: node.address1 ?? undefined,
65
+ address2: node.address2 ?? undefined,
66
+ city: node.city ?? undefined,
67
+ province: node.province ?? undefined,
68
+ country: node.country ?? undefined,
69
+ zip: node.zip ?? undefined,
70
+ phone: node.phoneNumber ?? undefined,
71
+ isDefault,
72
+ };
73
+ }
74
+ /** The Customer Account API takes codes (`zoneCode`, `territoryCode`) and `phoneNumber`; the shared input uses province, country and phone. */
75
+ function toAddressInput(input) {
76
+ const { province, country, phone, ...rest } = input;
77
+ const out = { ...rest };
78
+ delete out.setAsDefault;
79
+ if (province !== undefined)
80
+ out.zoneCode = province;
81
+ if (country !== undefined)
82
+ out.territoryCode = country;
83
+ if (phone !== undefined)
84
+ out.phoneNumber = phone;
85
+ return out;
86
+ }
87
+ function mapCustomer(node) {
88
+ return {
89
+ shopifyId: node.id,
90
+ firstName: node.firstName ?? undefined,
91
+ lastName: node.lastName ?? undefined,
92
+ email: node.emailAddress?.emailAddress ?? undefined,
93
+ phone: node.phoneNumber?.phoneNumber ?? undefined,
94
+ acceptsMarketing: node.emailAddress?.marketingState === 'SUBSCRIBED',
95
+ createdAt: node.creationDate ?? undefined,
96
+ defaultAddressId: node.defaultAddress?.id ?? undefined,
97
+ };
98
+ }
99
+ /** The logged-in customer's own profile. */
100
+ async function getMyCustomer(siteName, accessToken) {
101
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `query MyCustomer { customer { ${CUSTOMER_FIELDS} } }`);
102
+ return mapCustomer(data.customer);
103
+ }
104
+ /**
105
+ * Updates the customer's name, phone and marketing consent.
106
+ *
107
+ * Their email is their login identity, so it cannot be changed here: passing a different one is rejected
108
+ * (passing the current one is ignored, so a form that always sends it still works).
109
+ *
110
+ * The Customer Account API has no mutation for the phone number, so a changed phone is written with the
111
+ * Admin API. The customer id for that call is read from the access token's own customer, never taken from
112
+ * the caller, so a customer can only ever change their own phone.
113
+ */
114
+ async function updateMyCustomer(siteName, accessToken, input) {
115
+ const current = input.email !== undefined || input.phone !== undefined ? await getMyCustomer(siteName, accessToken) : undefined;
116
+ if (input.email !== undefined && !sameValue(input.email, current?.email, true)) {
117
+ throw new errors_1.ShopifyUserErrorsError('The email address cannot be changed', [
118
+ { field: ['email'], message: 'The email address cannot be changed from the account page' },
119
+ ]);
120
+ }
121
+ if (input.phone !== undefined && current && !sameValue(input.phone, current.phone, false)) {
122
+ await (0, customers_1.updateCustomer)(siteName, current.shopifyId, { phone: input.phone });
123
+ }
124
+ if (input.firstName !== undefined || input.lastName !== undefined) {
125
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `mutation UpdateMyCustomer($input: CustomerUpdateInput!) {
126
+ customerUpdate(input: $input) { customer { id } userErrors { field message } }
127
+ }`, { input: { firstName: input.firstName, lastName: input.lastName } });
128
+ ensureNoUserErrors(data.customerUpdate.userErrors, 'Failed to update customer');
129
+ }
130
+ if (input.acceptsMarketing !== undefined) {
131
+ const mutation = input.acceptsMarketing ? 'customerEmailMarketingSubscribe' : 'customerEmailMarketingUnsubscribe';
132
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `mutation MyMarketing { ${mutation} { userErrors { field message } } }`);
133
+ ensureNoUserErrors(data[mutation]?.userErrors, 'Failed to update marketing consent');
134
+ }
135
+ return getMyCustomer(siteName, accessToken);
136
+ }
137
+ /** The customer's addresses, each flagged with whether it is their default. */
138
+ async function listMyAddresses(siteName, accessToken) {
139
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `query MyAddresses { customer { defaultAddress { id } addresses(first: 100) { nodes { ${ADDRESS_FIELDS} } } } }`);
140
+ const defaultId = data.customer.defaultAddress ? numericId(data.customer.defaultAddress.id) : null;
141
+ return data.customer.addresses.nodes.map((node) => mapAddress(node, defaultId !== null && numericId(node.id) === defaultId));
142
+ }
143
+ /** One of the customer's addresses by id (numeric or GID), or `null`. */
144
+ async function getMyAddress(siteName, accessToken, addressId) {
145
+ const target = numericId(addressId);
146
+ const addresses = await listMyAddresses(siteName, accessToken);
147
+ return addresses.find((address) => numericId(address.shopifyId) === target) ?? null;
148
+ }
149
+ /** Adds an address, optionally as the default. */
150
+ async function createMyAddress(siteName, accessToken, input) {
151
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `mutation CreateMyAddress($address: CustomerAddressInput!, $defaultAddress: Boolean) {
152
+ customerAddressCreate(address: $address, defaultAddress: $defaultAddress) {
153
+ customerAddress { ${ADDRESS_FIELDS} }
154
+ userErrors { field message }
155
+ }
156
+ }`, { address: toAddressInput(input), defaultAddress: input.setAsDefault ?? false });
157
+ ensureNoUserErrors(data.customerAddressCreate.userErrors, 'Failed to create customer address');
158
+ if (!data.customerAddressCreate.customerAddress) {
159
+ throw new errors_1.ShopifyUserErrorsError('Failed to create customer address', data.customerAddressCreate.userErrors);
160
+ }
161
+ return mapAddress(data.customerAddressCreate.customerAddress, input.setAsDefault ?? false);
162
+ }
163
+ /** Updates an address's fields, optionally making it the default. `null` if it is not one of the customer's addresses. */
164
+ async function updateMyAddress(siteName, accessToken, addressId, input) {
165
+ const resolved = await getMyAddress(siteName, accessToken, addressId);
166
+ if (!resolved)
167
+ return null;
168
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `mutation UpdateMyAddress($addressId: ID!, $address: CustomerAddressInput, $defaultAddress: Boolean) {
169
+ customerAddressUpdate(addressId: $addressId, address: $address, defaultAddress: $defaultAddress) {
170
+ customerAddress { id }
171
+ userErrors { field message }
172
+ }
173
+ }`, { addressId: resolved.shopifyId, address: toAddressInput(input), defaultAddress: input.setAsDefault });
174
+ ensureNoUserErrors(data.customerAddressUpdate.userErrors, 'Failed to update customer address');
175
+ return getMyAddress(siteName, accessToken, resolved.shopifyId);
176
+ }
177
+ /** Removes an address and returns its id, or `null` if it is not one of the customer's addresses. */
178
+ async function deleteMyAddress(siteName, accessToken, addressId) {
179
+ const resolved = await getMyAddress(siteName, accessToken, addressId);
180
+ if (!resolved)
181
+ return null;
182
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `mutation DeleteMyAddress($addressId: ID!) {
183
+ customerAddressDelete(addressId: $addressId) { deletedAddressId userErrors { field message } }
184
+ }`, { addressId: resolved.shopifyId });
185
+ ensureNoUserErrors(data.customerAddressDelete.userErrors, 'Failed to delete customer address');
186
+ return resolved.shopifyId;
187
+ }
188
+ /** Makes an existing address the customer's default and returns the updated profile, or `null` if it does not exist. */
189
+ async function setMyDefaultAddress(siteName, accessToken, addressId) {
190
+ const resolved = await getMyAddress(siteName, accessToken, addressId);
191
+ if (!resolved)
192
+ return null;
193
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `mutation SetMyDefaultAddress($addressId: ID!) {
194
+ customerAddressUpdate(addressId: $addressId, defaultAddress: true) { customerAddress { id } userErrors { field message } }
195
+ }`, { addressId: resolved.shopifyId });
196
+ ensureNoUserErrors(data.customerAddressUpdate.userErrors, 'Failed to set the default address');
197
+ return getMyCustomer(siteName, accessToken);
198
+ }
199
+ function mapOrderSummary(node) {
200
+ return {
201
+ shopifyId: node.id,
202
+ name: node.name,
203
+ email: node.email ?? undefined,
204
+ createdAt: node.createdAt ? new Date(node.createdAt) : undefined,
205
+ financialStatus: node.financialStatus ?? undefined,
206
+ fulfillmentStatus: node.fulfillmentStatus ?? undefined,
207
+ totalPrice: node.totalPrice ?? undefined,
208
+ };
209
+ }
210
+ /**
211
+ * The customer's own orders, newest first, with cursor pagination. An optional Shopify search `query` only ever
212
+ * narrows the customer's own orders further: Shopify applies it inside the token's scope.
213
+ */
214
+ async function listMyOrders(siteName, accessToken, opts = {}) {
215
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `query MyOrders($first: Int!, $after: String, $query: String) {
216
+ customer {
217
+ orders(first: $first, after: $after, query: $query, sortKey: CREATED_AT, reverse: true) {
218
+ nodes { ${ORDER_SUMMARY_FIELDS} }
219
+ pageInfo { hasNextPage endCursor }
220
+ }
221
+ }
222
+ }`, { first: opts.first ?? 50, after: opts.after, query: opts.query });
223
+ const { nodes, pageInfo } = data.customer.orders;
224
+ return {
225
+ items: nodes.map(mapOrderSummary),
226
+ pageInfo: { hasNextPage: pageInfo.hasNextPage, endCursor: pageInfo.endCursor ?? undefined },
227
+ };
228
+ }
229
+ /**
230
+ * One of the customer's own orders, with line items. Throws `ShopifyNotFoundError` for an order that does
231
+ * not exist or belongs to someone else: Shopify does not distinguish them, and neither do we.
232
+ *
233
+ * The Customer Account API has no tags or archived flag on an order, so `tags` is empty and `closed` false.
234
+ */
235
+ async function getMyOrder(siteName, accessToken, orderId) {
236
+ const data = await (0, customer_account_1.customerAccountGraphql)(siteName, accessToken, `query MyOrder($id: ID!) {
237
+ order(id: $id) {
238
+ ${ORDER_SUMMARY_FIELDS}
239
+ phone
240
+ note
241
+ processedAt
242
+ cancelledAt
243
+ subtotal { ${MONEY} }
244
+ totalShipping { ${MONEY} }
245
+ totalTax { ${MONEY} }
246
+ customer { id }
247
+ shippingAddress { address1 address2 city province country zip }
248
+ lineItems(first: 50) {
249
+ nodes { id title quantity sku price { ${MONEY} } variantId }
250
+ }
251
+ }
252
+ }`, { id: orderId });
253
+ if (!data.order) {
254
+ throw new errors_1.ShopifyNotFoundError('Order not found', { orderId });
255
+ }
256
+ const node = data.order;
257
+ return {
258
+ ...mapOrderSummary(node),
259
+ phone: node.phone ?? undefined,
260
+ note: node.note ?? undefined,
261
+ tags: [],
262
+ processedAt: node.processedAt ? new Date(node.processedAt) : undefined,
263
+ cancelledAt: node.cancelledAt ? new Date(node.cancelledAt) : undefined,
264
+ closed: false,
265
+ subtotalPrice: node.subtotal ?? undefined,
266
+ totalShippingPrice: node.totalShipping ?? undefined,
267
+ totalTax: node.totalTax ?? undefined,
268
+ customerId: node.customer?.id ?? undefined,
269
+ shippingAddress: node.shippingAddress ?? undefined,
270
+ lineItems: (node.lineItems?.nodes ?? []).map((li) => ({
271
+ id: li.id,
272
+ title: li.title,
273
+ quantity: li.quantity,
274
+ sku: li.sku ?? undefined,
275
+ originalUnitPrice: li.price ?? undefined,
276
+ variantId: li.variantId ?? undefined,
277
+ })),
278
+ };
279
+ }
280
+ //# sourceMappingURL=my-account.js.map