@disconetwork/core 0.0.18 → 0.0.20

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.
@@ -402,6 +402,6 @@ const zRecommendationsBody = z.object({
402
402
  */
403
403
  const zRecommendationsResponse2 = zRecommendationsResponse;
404
404
  //#endregion
405
- export { zRecommendationsBody, zRecommendationsResponse2 };
405
+ export { zAddress, zRecommendationsBody, zRecommendationsResponse2 };
406
406
 
407
407
  //# sourceMappingURL=zod.gen.js.map
@@ -182,5 +182,5 @@ type Footer = {
182
182
  };
183
183
  };
184
184
  //#endregion
185
- export { Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata, Recommendation, RecommendationGroupEntry, RecommendationGroupProperty, RecommendationsRequest, RecommendationsResponse, RunningExperiment };
185
+ export { Address, Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata, Recommendation, RecommendationGroupEntry, RecommendationGroupProperty, RecommendationsRequest, RecommendationsResponse, RunningExperiment };
186
186
  //# sourceMappingURL=recommendations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"recommendations.d.ts","names":[],"sources":["../../src/external/recommendations.ts"],"mappings":";;;;;;;;KA8BY,iBAAA;EACV,IAAA,UA4BA;EA1BA,OAAO;AAAA;;;;;KAiBJ,UAAA;EACH,SAAA;EACA,eAAA;EACA,sBAAA;EACA,SAAA;EACA,aAAA;EACA,YAAA,GAAe,YAAY,EAe3B;EAbA,QAAA;EACA,UAAA;AAAA;AAAA,KAGG,WAAA;EACH,KAAA,GAAQ,KAAA;EACR,SAAA;EACA,QAAA;EACA,KAAA;EACA,MAAA,GAAS,MAAM,EAgBD;EAdd,GAAA,WAWG;EATH,GAAA;AAAA;;;;;;KAQG,WAAA,IACA,WAAA;EAAgB,KAAA;AAAA,MAChB,WAAA;EAAgB,SAAA;AAAA,MAChB,WAAA;EAAgB,YAAA;AAAA,MAChB,WAAA;E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,WAAW;AAAA;AAAA,KAGD,UAAA;EACV,EAAA;EACA,IAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,KAGU,KAAA;EACV,EAAA;EACA,OAAA;EACA,UAAA;EACA,WAAA,EAAa,MAAA;EACb,SAAA;EACA,UAAA,EAAY,eAAA;EACZ,MAAA,EAAQ,UAAA;EACR,QAAA,EAAU,aAAA;EACV,iBAAA,EAAmB,sBAAA;AAAA;AAAA,KAGT,eAAA;EACV,UAAA;EACA,WAAA;EACA,cAAA;EACA,iBAAA;EACA,kBAAA;AAAA;AAAA,KAGU,UAAA;EArDO,8DAuDjB,SAAA;EACA,QAAA;EACA,cAAA;EACA,EAAA;EACA,SAAA;EACA,sBAAA;AAAA;;KAIU,aAAA;EACN,IAAA;EAAoB,IAAA;EAAc,UAAA;AAAA;EAClC,IAAA;EAAuB,UAAA;AAAA;AAAA,KAEjB,sBAAA;EACV,IAAA;EACA,SAAA;EACA,OAAA;AAAA;AAAA,KAGU,MAAA;EACV,kBAAA;IACE,IAAA;IACA,YAAA;IACA,SAAA;EAAA;EAEF,aAAA;IACE,IAAA;IACA,SAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"recommendations.d.ts","names":[],"sources":["../../src/external/recommendations.ts"],"mappings":";;;;;;;;KA8BY,iBAAA;EACV,IAAA,UA4BA;EA1BA,OAAO;AAAA;;;;;KAiBJ,UAAA;EACH,SAAA;EACA,eAAA;EACA,sBAAA;EACA,SAAA;EACA,aAAA;EACA,YAAA,GAAe,YAAY,EAe3B;EAbA,QAAA;EACA,UAAA;AAAA;AAAA,KAGG,WAAA;EACH,KAAA,GAAQ,KAAA;EACR,SAAA;EACA,QAAA;EACA,KAAA;EACA,MAAA,GAAS,MAAM,EAgBD;EAdd,GAAA,WAWG;EATH,GAAA;AAAA;;;;;;KAQG,WAAA,IACA,WAAA;EAAgB,KAAA;AAAA,MAChB,WAAA;EAAgB,SAAA;AAAA,MAChB,WAAA;EAAgB,YAAA;AAAA,MAChB,WAAA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ACA,WAAW;AAAA;AAAA,KAGD,UAAA;EACV,EAAA;EACA,IAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,KAGU,KAAA;EACV,EAAA;EACA,OAAA;EACA,UAAA;EACA,WAAA,EAAa,MAAA;EACb,SAAA;EACA,UAAA,EAAY,eAAA;EACZ,MAAA,EAAQ,UAAA;EACR,QAAA,EAAU,aAAA;EACV,iBAAA,EAAmB,sBAAA;AAAA;AAAA,KAGT,eAAA;EACV,UAAA;EACA,WAAA;EACA,cAAA;EACA,iBAAA;EACA,kBAAA;AAAA;AAAA,KAGU,UAAA;EArDO,8DAuDjB,SAAA;EACA,QAAA;EACA,cAAA;EACA,EAAA;EACA,SAAA;EACA,sBAAA;AAAA;;KAIU,aAAA;EACN,IAAA;EAAoB,IAAA;EAAc,UAAA;AAAA;EAClC,IAAA;EAAuB,UAAA;AAAA;AAAA,KAEjB,sBAAA;EACV,IAAA;EACA,SAAA;EACA,OAAA;AAAA;AAAA,KAGU,MAAA;EACV,kBAAA;IACE,IAAA;IACA,YAAA;IACA,SAAA;EAAA;EAEF,aAAA;IACE,IAAA;IACA,SAAA;EAAA;AAAA"}
@@ -40,8 +40,8 @@ function transformRequest(request) {
40
40
  purchases: v.purchases?.map(wirePurchase),
41
41
  attributes: v.attributes && remap(v.attributes, attributesKeyMap),
42
42
  custom_metadata: v.customMetadata && toSnakeKeys(v.customMetadata),
43
- shipping: v.shipping && remap(v.shipping, addressKeyMap),
44
- billing: v.billing && remap(v.billing, addressKeyMap),
43
+ shipping: v.shipping && wireAddress(v.shipping),
44
+ billing: v.billing && wireAddress(v.billing),
45
45
  running_experiments: v.runningExperiments
46
46
  });
47
47
  }
@@ -54,11 +54,18 @@ const attributesKeyMap = {
54
54
  platformType: "platform_type",
55
55
  deviceType: "device_type"
56
56
  };
57
- const addressKeyMap = {
58
- addressLine1: "address_line_1",
59
- addressLine2: "address_line_2",
60
- countryCode: "country_code"
61
- };
57
+ /**
58
+ * Map an `Address` to its wire shape. Also used by the internal (proxy) request
59
+ * mapper: the proxy forwards addresses to this API untouched, so both clients
60
+ * send the same shape.
61
+ */
62
+ function wireAddress(a) {
63
+ return remap(a, {
64
+ addressLine1: "address_line_1",
65
+ addressLine2: "address_line_2",
66
+ countryCode: "country_code"
67
+ });
68
+ }
62
69
  function wireCostDetails(c) {
63
70
  return remap(c, { currencyCode: "currency_code" });
64
71
  }
@@ -204,6 +211,6 @@ function mapFooter(raw) {
204
211
  };
205
212
  }
206
213
  //#endregion
207
- export { transformRequest, transformResponse };
214
+ export { transformRequest, transformResponse, wireAddress };
208
215
 
209
216
  //# sourceMappingURL=recommendationsTransforms.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recommendationsTransforms.js","names":[],"sources":["../../src/external/recommendationsTransforms.ts"],"sourcesContent":["/**\n * Zod schemas + casing transforms for the **external** recommendations contract.\n *\n * The public types mirror the endpoint 1:1 in structure, so the only\n * transformation is snake_case ↔ camelCase:\n * - Request: validate the camelCase input, then build the wire body with\n * explicit per-field `remap`s (the same mechanism Speakeasy-generated SDKs\n * use). Named fields are renamed deterministically; genuinely data-keyed\n * values — `variant`'s map, `customMetadata` — are handled explicitly so a\n * blind recaser can't corrupt them.\n * - Response: validate the snake_case wire, then recase to camelCase\n * **preserving map keys** (offer ids / group keys are data, not field names).\n *\n * @internal Built into the external `DiscoClient`; not part of the public API.\n */\n\nimport { remap } from \"../lib/primitives.js\";\nimport { toSnakeKeys } from \"../lib/case.js\";\n// The wire types the generated SDK returns (and has already validated). Aliased\n// with a `Wire` suffix to avoid clashing with the public camelCase domain types\n// imported above.\nimport type {\n Advertiser as AdvertiserWire,\n Asset as AssetWire,\n CtaDetails as CtaDetailsWire,\n Footer as FooterWire,\n Offer as OfferWire,\n Recommendation as RecommendationWire,\n RecommendationGroupEntry as RecommendationGroupEntryWire,\n RecommendationGroupProperty as RecommendationGroupPropertyWire,\n RecommendationsRequest as RecommendationsWireRequest,\n RecommendationsResponse as RecommendationsWireResponse,\n} from \"../api/generated/recommendations/types.gen.js\";\nimport type {\n Advertiser,\n CostDetails,\n Offer,\n OfferAsset,\n OfferCtaDetails,\n OfferMetadata,\n OrderDetails,\n Purchase,\n Recommendation,\n RecommendationGroupEntry,\n RecommendationGroupProperty,\n RecommendationsRequest,\n RecommendationsResponse,\n RunningExperiment,\n} from \"./recommendations.js\";\n\n/**\n * Build the snake_case wire body from the public request via explicit per-field\n * `remap`s. Transform-only: validation is performed by the generated SDK's\n * request validator (which surfaces as `DiscoValidationError` from\n * `DiscoClient`), so this does not parse or throw on bad input.\n */\nexport function transformRequest(\n request: RecommendationsRequest,\n): RecommendationsWireRequest {\n const v = request;\n // `compact` erases field types, so this cast is the request-side seam between\n // the domain shape and the wire shape. The generated SDK validates the result\n // at runtime; a full compile-time check would require a typed builder.\n return compact({\n user_details: remap(v.userDetails, {\n firstName: \"first_name\",\n lastName: \"last_name\",\n emailHash: \"email_hash\",\n externalGuid: \"external_guid\",\n }),\n placement_details: remap(v.placementDetails, {\n displayMode: \"display_mode\",\n subView: \"sub_view\",\n layoutId: \"layout_id\",\n }),\n order_details: v.orderDetails && wireOrderDetails(v.orderDetails),\n purchases: v.purchases?.map(wirePurchase),\n attributes: v.attributes && remap(v.attributes, attributesKeyMap),\n // Untyped map: recase keys algorithmically rather than field-by-field.\n custom_metadata: v.customMetadata && toSnakeKeys(v.customMetadata),\n shipping: v.shipping && remap(v.shipping, addressKeyMap),\n billing: v.billing && remap(v.billing, addressKeyMap),\n // `name` / `version` are already snake-safe; left as-is.\n running_experiments: v.runningExperiments,\n }) as unknown as RecommendationsWireRequest;\n}\n\nconst attributesKeyMap = {\n userAgent: \"user_agent\",\n operatingSystem: \"operating_system\",\n operatingSystemVersion: \"operating_system_version\",\n ipAddress: \"ip_address\",\n ipAddressHash: \"ip_address_hash\",\n platformType: \"platform_type\",\n deviceType: \"device_type\",\n} as const;\n\nconst addressKeyMap = {\n addressLine1: \"address_line_1\",\n addressLine2: \"address_line_2\",\n countryCode: \"country_code\",\n} as const;\n\nfunction wireCostDetails(c: CostDetails): Record<string, unknown> {\n return remap(c, { currencyCode: \"currency_code\" });\n}\n\nfunction wireOrderDetails(o: OrderDetails): Record<string, unknown> {\n return {\n ...remap(o, {\n orderId: \"order_id\",\n paymentType: \"payment_type\",\n costDetails: null,\n }),\n ...(o.costDetails && { cost_details: wireCostDetails(o.costDetails) }),\n };\n}\n\nfunction wirePurchase(p: Purchase): Record<string, unknown> {\n return {\n // `variant` is unmapped, so its value — string or data-keyed map — passes\n // through verbatim; recasing its keys would corrupt advertiser data.\n ...remap(p, {\n productId: \"product_id\",\n costDetails: null,\n attributes: null,\n }),\n ...(p.costDetails && { cost_details: wireCostDetails(p.costDetails) }),\n ...(p.attributes && {\n attributes: remap(p.attributes, {\n isClearance: \"is_clearance\",\n isGift: \"is_gift\",\n }),\n }),\n };\n}\n\n/** Drop keys whose value is `undefined` so absent optionals leave no trace. */\nfunction compact(obj: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, val] of Object.entries(obj)) {\n if (val !== undefined) out[k] = val;\n }\n return out;\n}\n\n// ─── Response: recase the generated wire response, preserving map keys ──────\n// Validation lives in the generated SDK; this is pure transformation over its\n// already-validated wire types (the `*Wire` aliases).\n\n/**\n * Recase the rec-api wire response into the friendly camelCase shape, keeping\n * the normalized maps intact. Transform-only: the generated SDK validates the\n * response before this runs, so it neither parses nor throws.\n */\nexport function transformResponse(\n raw: RecommendationsWireResponse,\n): RecommendationsResponse {\n return {\n sessionId: raw.session_id,\n recommendations: mapValues(raw.recommendations ?? {}, mapRecommendation),\n recommendationGroups: mapValues(\n raw.recommendation_groups ?? {},\n (entries) => entries.map(mapGroupEntry),\n ),\n recommendationGroupProperties: raw.recommendation_group_properties\n ? mapValues(raw.recommendation_group_properties, mapGroupProperty)\n : undefined,\n runningExperiments: raw.running_experiments?.map(\n (e): RunningExperiment => ({ name: e.name, version: e.version }),\n ),\n footer: mapFooter(raw.footer),\n };\n}\n\n/** Map a dictionary's values while preserving its (data) keys. */\nfunction mapValues<T, U>(\n obj: Record<string, T>,\n fn: (value: T) => U,\n): Record<string, U> {\n const out: Record<string, U> = {};\n for (const [key, value] of Object.entries(obj)) {\n out[key] = fn(value);\n }\n return out;\n}\n\nfunction mapRecommendation(raw: RecommendationWire): Recommendation {\n return {\n advertiser: mapAdvertiser(raw.advertiser),\n offer: mapOffer(raw.offer),\n };\n}\n\nfunction mapGroupEntry(\n raw: RecommendationGroupEntryWire,\n): RecommendationGroupEntry {\n return {\n insertionOrder: raw.insertion_order,\n insertionId: raw.insertion_id,\n offerId: raw.offer_id,\n advertiserId: raw.advertiser_id,\n };\n}\n\nfunction mapGroupProperty(\n raw: RecommendationGroupPropertyWire,\n): RecommendationGroupProperty {\n return { heading: raw.heading ?? null, slotContext: raw.slot_context };\n}\n\nfunction mapAdvertiser(raw: AdvertiserWire): Advertiser {\n return {\n id: raw.id,\n name: raw.name,\n logoUrl: raw.logo_url,\n description: raw.description ?? null,\n };\n}\n\nfunction mapOffer(raw: OfferWire): Offer {\n return {\n id: raw.id,\n heading: raw.heading,\n subheading: raw.subheading ?? null,\n jsonContent: raw.json_content ?? null,\n targetUrl: raw.target_url,\n ctaDetails: mapCtaDetails(raw.cta_details),\n assets: (raw.assets ?? []).map(mapAsset),\n metadata: mapMetadata(raw.metadata),\n disclosureDetails: raw.disclosure_details\n ? {\n copy: raw.disclosure_details.copy,\n targetUrl: raw.disclosure_details.target_url ?? null,\n content: raw.disclosure_details.content ?? null,\n }\n : null,\n };\n}\n\nfunction mapCtaDetails(raw: CtaDetailsWire): OfferCtaDetails {\n return {\n acceptCopy: raw.accept_copy,\n declineCopy: raw.decline_copy,\n transitionCopy: raw.transition_copy ?? null,\n claimedAcceptCopy: raw.claimed_accept_copy ?? null,\n claimedDeclineCopy: raw.claimed_decline_copy ?? null,\n };\n}\n\nfunction mapAsset(raw: AssetWire): OfferAsset {\n return {\n assetType: raw.asset_type,\n imageUrl: raw.image_url,\n insertionOrder: raw.insertion_order,\n id: raw.id ?? null,\n targetUrl: raw.target_url ?? null,\n // Spec marks this optional; default to `false` to keep the public type's\n // required boolean.\n shouldTriggerClaimFlow: raw.should_trigger_claim_flow ?? false,\n };\n}\n\nfunction mapMetadata(raw: OfferWire[\"metadata\"]): OfferMetadata {\n return raw.type === \"PROMO_CODE\"\n ? { type: \"PROMO_CODE\", code: raw.code, layoutType: raw.layout_type }\n : { type: \"NO_PROMO_CODE\", layoutType: raw.layout_type };\n}\n\nfunction mapFooter(raw: FooterWire): RecommendationsResponse[\"footer\"] {\n return {\n attributionDetails: {\n copy: raw.attribution_details.copy,\n discoLogoUrl: raw.attribution_details.disco_logo_url,\n targetUrl: raw.attribution_details.target_url,\n },\n privacyPolicy: {\n copy: raw.privacy_policy.copy,\n targetUrl: raw.privacy_policy.target_url,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,iBACd,SAC4B;CAC5B,MAAM,IAAI;CAIV,OAAO,QAAQ;EACb,cAAc,MAAM,EAAE,aAAa;GACjC,WAAW;GACX,UAAU;GACV,WAAW;GACX,cAAc;EAChB,CAAC;EACD,mBAAmB,MAAM,EAAE,kBAAkB;GAC3C,aAAa;GACb,SAAS;GACT,UAAU;EACZ,CAAC;EACD,eAAe,EAAE,gBAAgB,iBAAiB,EAAE,YAAY;EAChE,WAAW,EAAE,WAAW,IAAI,YAAY;EACxC,YAAY,EAAE,cAAc,MAAM,EAAE,YAAY,gBAAgB;EAEhE,iBAAiB,EAAE,kBAAkB,YAAY,EAAE,cAAc;EACjE,UAAU,EAAE,YAAY,MAAM,EAAE,UAAU,aAAa;EACvD,SAAS,EAAE,WAAW,MAAM,EAAE,SAAS,aAAa;EAEpD,qBAAqB,EAAE;CACzB,CAAC;AACH;AAEA,MAAM,mBAAmB;CACvB,WAAW;CACX,iBAAiB;CACjB,wBAAwB;CACxB,WAAW;CACX,eAAe;CACf,cAAc;CACd,YAAY;AACd;AAEA,MAAM,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wB,IAAI,6BAA6B;CAC3D;AACF;AAEA,SAAS,YAAY,KAA2C;CAC9D,OAAO,IAAI,SAAS,eAChB;EAAE,MAAM;EAAc,MAAM,IAAI;EAAM,YAAY,IAAI;CAAY,IAClE;EAAE,MAAM;EAAiB,YAAY,IAAI;CAAY;AAC3D;AAEA,SAAS,UAAU,KAAoD;CACrE,OAAO;EACL,oBAAoB;GAClB,MAAM,IAAI,oBAAoB;GAC9B,cAAc,IAAI,oBAAoB;GACtC,WAAW,IAAI,oBAAoB;EACrC;EACA,eAAe;GACb,MAAM,IAAI,eAAe;GACzB,WAAW,IAAI,eAAe;EAChC;CACF;AACF"}
1
+ {"version":3,"file":"recommendationsTransforms.js","names":[],"sources":["../../src/external/recommendationsTransforms.ts"],"sourcesContent":["/**\n * Zod schemas + casing transforms for the **external** recommendations contract.\n *\n * The public types mirror the endpoint 1:1 in structure, so the only\n * transformation is snake_case ↔ camelCase:\n * - Request: validate the camelCase input, then build the wire body with\n * explicit per-field `remap`s (the same mechanism Speakeasy-generated SDKs\n * use). Named fields are renamed deterministically; genuinely data-keyed\n * values — `variant`'s map, `customMetadata` — are handled explicitly so a\n * blind recaser can't corrupt them.\n * - Response: validate the snake_case wire, then recase to camelCase\n * **preserving map keys** (offer ids / group keys are data, not field names).\n *\n * @internal Built into the external `DiscoClient`; not part of the public API.\n */\n\nimport { remap } from \"../lib/primitives.js\";\nimport { toSnakeKeys } from \"../lib/case.js\";\n// The wire types the generated SDK returns (and has already validated). Aliased\n// with a `Wire` suffix to avoid clashing with the public camelCase domain types\n// imported above.\nimport type {\n Address as AddressWire,\n Advertiser as AdvertiserWire,\n Asset as AssetWire,\n CtaDetails as CtaDetailsWire,\n Footer as FooterWire,\n Offer as OfferWire,\n Recommendation as RecommendationWire,\n RecommendationGroupEntry as RecommendationGroupEntryWire,\n RecommendationGroupProperty as RecommendationGroupPropertyWire,\n RecommendationsRequest as RecommendationsWireRequest,\n RecommendationsResponse as RecommendationsWireResponse,\n} from \"../api/generated/recommendations/types.gen.js\";\nimport type {\n Address,\n Advertiser,\n CostDetails,\n Offer,\n OfferAsset,\n OfferCtaDetails,\n OfferMetadata,\n OrderDetails,\n Purchase,\n Recommendation,\n RecommendationGroupEntry,\n RecommendationGroupProperty,\n RecommendationsRequest,\n RecommendationsResponse,\n RunningExperiment,\n} from \"./recommendations.js\";\n\n/**\n * Build the snake_case wire body from the public request via explicit per-field\n * `remap`s. Transform-only: validation is performed by the generated SDK's\n * request validator (which surfaces as `DiscoValidationError` from\n * `DiscoClient`), so this does not parse or throw on bad input.\n */\nexport function transformRequest(\n request: RecommendationsRequest,\n): RecommendationsWireRequest {\n const v = request;\n // `compact` erases field types, so this cast is the request-side seam between\n // the domain shape and the wire shape. The generated SDK validates the result\n // at runtime; a full compile-time check would require a typed builder.\n return compact({\n user_details: remap(v.userDetails, {\n firstName: \"first_name\",\n lastName: \"last_name\",\n emailHash: \"email_hash\",\n externalGuid: \"external_guid\",\n }),\n placement_details: remap(v.placementDetails, {\n displayMode: \"display_mode\",\n subView: \"sub_view\",\n layoutId: \"layout_id\",\n }),\n order_details: v.orderDetails && wireOrderDetails(v.orderDetails),\n purchases: v.purchases?.map(wirePurchase),\n attributes: v.attributes && remap(v.attributes, attributesKeyMap),\n // Untyped map: recase keys algorithmically rather than field-by-field.\n custom_metadata: v.customMetadata && toSnakeKeys(v.customMetadata),\n shipping: v.shipping && wireAddress(v.shipping),\n billing: v.billing && wireAddress(v.billing),\n // `name` / `version` are already snake-safe; left as-is.\n running_experiments: v.runningExperiments,\n }) as unknown as RecommendationsWireRequest;\n}\n\nconst attributesKeyMap = {\n userAgent: \"user_agent\",\n operatingSystem: \"operating_system\",\n operatingSystemVersion: \"operating_system_version\",\n ipAddress: \"ip_address\",\n ipAddressHash: \"ip_address_hash\",\n platformType: \"platform_type\",\n deviceType: \"device_type\",\n} as const;\n\n/**\n * Map an `Address` to its wire shape. Also used by the internal (proxy) request\n * mapper: the proxy forwards addresses to this API untouched, so both clients\n * send the same shape.\n */\nexport function wireAddress(a: Address): AddressWire {\n return remap(a, {\n addressLine1: \"address_line_1\",\n addressLine2: \"address_line_2\",\n countryCode: \"country_code\",\n });\n}\n\nfunction wireCostDetails(c: CostDetails): Record<string, unknown> {\n return remap(c, { currencyCode: \"currency_code\" });\n}\n\nfunction wireOrderDetails(o: OrderDetails): Record<string, unknown> {\n return {\n ...remap(o, {\n orderId: \"order_id\",\n paymentType: \"payment_type\",\n costDetails: null,\n }),\n ...(o.costDetails && { cost_details: wireCostDetails(o.costDetails) }),\n };\n}\n\nfunction wirePurchase(p: Purchase): Record<string, unknown> {\n return {\n // `variant` is unmapped, so its value — string or data-keyed map — passes\n // through verbatim; recasing its keys would corrupt advertiser data.\n ...remap(p, {\n productId: \"product_id\",\n costDetails: null,\n attributes: null,\n }),\n ...(p.costDetails && { cost_details: wireCostDetails(p.costDetails) }),\n ...(p.attributes && {\n attributes: remap(p.attributes, {\n isClearance: \"is_clearance\",\n isGift: \"is_gift\",\n }),\n }),\n };\n}\n\n/** Drop keys whose value is `undefined` so absent optionals leave no trace. */\nfunction compact(obj: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, val] of Object.entries(obj)) {\n if (val !== undefined) out[k] = val;\n }\n return out;\n}\n\n// ─── Response: recase the generated wire response, preserving map keys ──────\n// Validation lives in the generated SDK; this is pure transformation over its\n// already-validated wire types (the `*Wire` aliases).\n\n/**\n * Recase the rec-api wire response into the friendly camelCase shape, keeping\n * the normalized maps intact. Transform-only: the generated SDK validates the\n * response before this runs, so it neither parses nor throws.\n */\nexport function transformResponse(\n raw: RecommendationsWireResponse,\n): RecommendationsResponse {\n return {\n sessionId: raw.session_id,\n recommendations: mapValues(raw.recommendations ?? {}, mapRecommendation),\n recommendationGroups: mapValues(\n raw.recommendation_groups ?? {},\n (entries) => entries.map(mapGroupEntry),\n ),\n recommendationGroupProperties: raw.recommendation_group_properties\n ? mapValues(raw.recommendation_group_properties, mapGroupProperty)\n : undefined,\n runningExperiments: raw.running_experiments?.map(\n (e): RunningExperiment => ({ name: e.name, version: e.version }),\n ),\n footer: mapFooter(raw.footer),\n };\n}\n\n/** Map a dictionary's values while preserving its (data) keys. */\nfunction mapValues<T, U>(\n obj: Record<string, T>,\n fn: (value: T) => U,\n): Record<string, U> {\n const out: Record<string, U> = {};\n for (const [key, value] of Object.entries(obj)) {\n out[key] = fn(value);\n }\n return out;\n}\n\nfunction mapRecommendation(raw: RecommendationWire): Recommendation {\n return {\n advertiser: mapAdvertiser(raw.advertiser),\n offer: mapOffer(raw.offer),\n };\n}\n\nfunction mapGroupEntry(\n raw: RecommendationGroupEntryWire,\n): RecommendationGroupEntry {\n return {\n insertionOrder: raw.insertion_order,\n insertionId: raw.insertion_id,\n offerId: raw.offer_id,\n advertiserId: raw.advertiser_id,\n };\n}\n\nfunction mapGroupProperty(\n raw: RecommendationGroupPropertyWire,\n): RecommendationGroupProperty {\n return { heading: raw.heading ?? null, slotContext: raw.slot_context };\n}\n\nfunction mapAdvertiser(raw: AdvertiserWire): Advertiser {\n return {\n id: raw.id,\n name: raw.name,\n logoUrl: raw.logo_url,\n description: raw.description ?? null,\n };\n}\n\nfunction mapOffer(raw: OfferWire): Offer {\n return {\n id: raw.id,\n heading: raw.heading,\n subheading: raw.subheading ?? null,\n jsonContent: raw.json_content ?? null,\n targetUrl: raw.target_url,\n ctaDetails: mapCtaDetails(raw.cta_details),\n assets: (raw.assets ?? []).map(mapAsset),\n metadata: mapMetadata(raw.metadata),\n disclosureDetails: raw.disclosure_details\n ? {\n copy: raw.disclosure_details.copy,\n targetUrl: raw.disclosure_details.target_url ?? null,\n content: raw.disclosure_details.content ?? null,\n }\n : null,\n };\n}\n\nfunction mapCtaDetails(raw: CtaDetailsWire): OfferCtaDetails {\n return {\n acceptCopy: raw.accept_copy,\n declineCopy: raw.decline_copy,\n transitionCopy: raw.transition_copy ?? null,\n claimedAcceptCopy: raw.claimed_accept_copy ?? null,\n claimedDeclineCopy: raw.claimed_decline_copy ?? null,\n };\n}\n\nfunction mapAsset(raw: AssetWire): OfferAsset {\n return {\n assetType: raw.asset_type,\n imageUrl: raw.image_url,\n insertionOrder: raw.insertion_order,\n id: raw.id ?? null,\n targetUrl: raw.target_url ?? null,\n // Spec marks this optional; default to `false` to keep the public type's\n // required boolean.\n shouldTriggerClaimFlow: raw.should_trigger_claim_flow ?? false,\n };\n}\n\nfunction mapMetadata(raw: OfferWire[\"metadata\"]): OfferMetadata {\n return raw.type === \"PROMO_CODE\"\n ? { type: \"PROMO_CODE\", code: raw.code, layoutType: raw.layout_type }\n : { type: \"NO_PROMO_CODE\", layoutType: raw.layout_type };\n}\n\nfunction mapFooter(raw: FooterWire): RecommendationsResponse[\"footer\"] {\n return {\n attributionDetails: {\n copy: raw.attribution_details.copy,\n discoLogoUrl: raw.attribution_details.disco_logo_url,\n targetUrl: raw.attribution_details.target_url,\n },\n privacyPolicy: {\n copy: raw.privacy_policy.copy,\n targetUrl: raw.privacy_policy.target_url,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,iBACd,SAC4B;CAC5B,MAAM,IAAI;CAIV,OAAO,QAAQ;EACb,cAAc,MAAM,EAAE,aAAa;GACjC,WAAW;GACX,UAAU;GACV,WAAW;GACX,cAAc;EAChB,CAAC;EACD,mBAAmB,MAAM,EAAE,kBAAkB;GAC3C,aAAa;GACb,SAAS;GACT,UAAU;EACZ,CAAC;EACD,eAAe,EAAE,gBAAgB,iBAAiB,EAAE,YAAY;EAChE,WAAW,EAAE,WAAW,IAAI,YAAY;EACxC,YAAY,EAAE,cAAc,MAAM,EAAE,YAAY,gBAAgB;EAEhE,iBAAiB,EAAE,kBAAkB,YAAY,EAAE,cAAc;EACjE,UAAU,EAAE,YAAY,YAAY,EAAE,QAAQ;EAC9C,SAAS,EAAE,WAAW,YAAY,EAAE,OAAO;EAE3C,qBAAqB,EAAE;CACzB,CAAC;AACH;AAEA,MAAM,mBAAmB;CACvB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AS,SAAS,KAA4B;CAC5C,OAAO;EACL,WAAW,IAAI;EACf,UAAU,IAAI;EACd,gBAAgB,IAAI;EACpB,IAAI,IAAI,MAAM;EACd,WAAW,IAAI,cAAc;EAG7B,wBAAwB,IAAI,6BAA6B;CAC3D;AACF;AAEA,SAAS,YAAY,KAA2C;CAC9D,OAAO,IAAI,SAAS,eAChB;EAAE,MAAM;EAAc,MAAM,IAAI;EAAM,YAAY,IAAI;CAAY,IAClE;EAAE,MAAM;EAAiB,YAAY,IAAI;CAAY;AAC3D;AAEA,SAAS,UAAU,KAAoD;CACrE,OAAO;EACL,oBAAoB;GAClB,MAAM,IAAI,oBAAoB;GAC9B,cAAc,IAAI,oBAAoB;GACtC,WAAW,IAAI,oBAAoB;EACrC;EACA,eAAe;GACb,MAAM,IAAI,eAAe;GACzB,WAAW,IAAI,eAAe;EAChC;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata } from "../external/recommendations.js";
1
+ import { Address, Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata } from "../external/recommendations.js";
2
2
 
3
3
  //#region src/internal/recommendations.d.ts
4
4
  type RecommendationsRequest = {
@@ -6,6 +6,8 @@ type RecommendationsRequest = {
6
6
  placement?: PlacementDetails;
7
7
  order?: OrderDetails;
8
8
  purchases?: Purchase[];
9
+ shipping?: Address;
10
+ billing?: Address;
9
11
  experiments?: RunningExperiment[];
10
12
  attributes?: Record<string, unknown>;
11
13
  /**
@@ -46,7 +48,7 @@ type RunningExperiment = {
46
48
  id: string;
47
49
  variant: string;
48
50
  };
49
- type LayoutId = "SHOPIFY_NATIVE_LEAD_GEN" | "SHOPIFY_NATIVE_ESSENTIAL" | "SHOPIFY_NATIVE_COVER" | (string & {});
51
+ type LayoutId = "SHOPIFY_NATIVE_LEAD_GEN" | "SHOPIFY_NATIVE_ESSENTIAL" | (string & {});
50
52
  type RecommendationsResponse = {
51
53
  sessionId: string;
52
54
  layoutId: LayoutId;
@@ -1 +1 @@
1
- {"version":3,"file":"recommendations.d.ts","names":[],"sources":["../../src/internal/recommendations.ts"],"mappings":";;;KAyCY,sBAAA;EACV,IAAA,GAAO,WAAA;EACP,SAAA,GAAY,gBAAA;EACZ,KAAA,GAAQ,YAAA;EACR,SAAA,GAAY,QAAA;EACZ,WAAA,GAAc,iBAAA;EACd,UAAA,GAAa,MAAA;EADC;;;;;;EAQd,MAAA,GAAS,MAAA;AAAA;AAAA,KAGC,WAAA;EACV,KAAA;EACA,SAAA;EACA,SAAA;EACA,QAAA;EACA,KAAA;AAAA;AAAA,KAGU,gBAAA;EAHL,oEAKL,QAAA,WAFU;EAIV,WAAA;EAEA,IAAA;AAAA;AAAA,KAGU,YAAA;EACV,EAAA;EACA,MAAA;EACA,YAAA;AAAA;AAAA,KAGU,QAAA;EACV,IAAA;EACA,IAAA;EACA,OAAA;EACA,QAAA;EACA,SAAA;EACA,MAAA;EACA,YAAA;AAAA;AAAA,KAGU,iBAAA;EACV,EAAA;EACA,OAAO;AAAA;AAAA,KAKG,QAAA;AAAA,KAOA,uBAAA;EACV,SAAA;EACA,QAAA,EAAU,QAAA;EACV,oBAAA,EAAsB,mBAAA;EACtB,MAAA,EAAQ,MAAA;EACR,sBAAA,EAAwB,sBAAA;AAAA;AAAA,KAGd,mBAAA;EACV,OAAA;EACA,WAAA;EACA,eAAA,EAAiB,cAAc;AAAA;AAlBjC;;;;AAAoB;AAOpB;AAPA,KA2BY,cAAA;EACV,EAAA;EACA,WAAA;EACA,UAAA,EAAY,UAAA;EACZ,KAAA,EAAO,KAAK;AAAA;;;;;;;;;KAWF,sBAAA;EACV,QAAA,GAAW,MAAA;EACX,OAAA,GAAU,MAAA;AAAA,IACR,MAAA,SAAe,MAAA"}
1
+ {"version":3,"file":"recommendations.d.ts","names":[],"sources":["../../src/internal/recommendations.ts"],"mappings":";;;KA4CY,sBAAA;EACV,IAAA,GAAO,WAAA;EACP,SAAA,GAAY,gBAAA;EACZ,KAAA,GAAQ,YAAA;EACR,SAAA,GAAY,QAAA;EACZ,QAAA,GAAW,OAAA;EACX,OAAA,GAAU,OAAA;EACV,WAAA,GAAc,iBAAA;EACd,UAAA,GAAa,MAAA;EAHF;;;;;;EAUX,MAAA,GAAS,MAAA;AAAA;AAAA,KAGC,WAAA;EACV,KAAA;EACA,SAAA;EACA,SAAA;EACA,QAAA;EACA,KAAA;AAAA;AAAA,KAGU,gBAAA;EANV,oEAQA,QAAA,WANA;EAQA,WAAA,WAPK;EASL,IAAA;AAAA;AAAA,KAGU,YAAA;EACV,EAAA;EACA,MAAA;EACA,YAAA;AAAA;AAAA,KAGU,QAAA;EACV,IAAA;EACA,IAAA;EACA,OAAA;EACA,QAAA;EACA,SAAA;EACA,MAAA;EACA,YAAA;AAAA;AAAA,KAGU,iBAAA;EACV,EAAA;EACA,OAAO;AAAA;AAAA,KAKG,QAAA;AAAA,KAMA,uBAAA;EACV,SAAA;EACA,QAAA,EAAU,QAAA;EACV,oBAAA,EAAsB,mBAAA;EACtB,MAAA,EAAQ,MAAA;EACR,sBAAA,EAAwB,sBAAA;AAAA;AAAA,KAGd,mBAAA;EACV,OAAA;EACA,WAAA;EACA,eAAA,EAAiB,cAAc;AAAA;;;;AAtBxB;AAKT;;KA0BY,cAAA;EACV,EAAA;EACA,WAAA;EACA,UAAA,EAAY,UAAA;EACZ,KAAA,EAAO,KAAK;AAAA;;;;;;;;;KAWF,sBAAA;EACV,QAAA,GAAW,MAAA;EACX,OAAA,GAAU,MAAA;AAAA,IACR,MAAA,SAAe,MAAA"}
@@ -1,4 +1,6 @@
1
+ import { zAddress } from "../api/generated/recommendations/zod.gen.js";
1
2
  import { remap } from "../lib/primitives.js";
3
+ import { wireAddress } from "../external/recommendationsTransforms.js";
2
4
  import { parse } from "../lib/schemas.js";
3
5
  import * as z from "zod/v4-mini";
4
6
  //#region src/internal/recommendationsRequestMapper.ts
@@ -64,6 +66,7 @@ const Purchase$outboundSchema = z.pipe(z.object({
64
66
  currency_code: v.currencyCode
65
67
  } : void 0
66
68
  })));
69
+ const Address$outboundSchema = z.pipe(z.pipe(z.custom((v) => typeof v === "object" && v !== null), z.transform(wireAddress)), zAddress);
67
70
  const RunningExperiment$outboundSchema = z.object({
68
71
  id: z.string(),
69
72
  variant: z.string()
@@ -79,6 +82,8 @@ const RecommendationsRequest$outboundSchema = z.pipe(z.object({
79
82
  placement: z.optional(PlacementDetails$outboundSchema),
80
83
  order: z.optional(OrderDetails$outboundSchema),
81
84
  purchases: z.optional(z.array(Purchase$outboundSchema)),
85
+ shipping: z.optional(Address$outboundSchema),
86
+ billing: z.optional(Address$outboundSchema),
82
87
  experiments: z.optional(z.array(RunningExperiment$outboundSchema)),
83
88
  attributes: z.optional(z.record(z.string(), z.unknown())),
84
89
  extras: z.optional(z.record(z.string(), z.unknown()))
@@ -87,7 +92,9 @@ const RecommendationsRequest$outboundSchema = z.pipe(z.object({
87
92
  user_details: v.user,
88
93
  placement_details: v.placement,
89
94
  order_details: v.order,
90
- purchases: v.purchases
95
+ purchases: v.purchases,
96
+ shipping: v.shipping,
97
+ billing: v.billing
91
98
  },
92
99
  running_experiments: v.experiments,
93
100
  attributes: v.attributes,
@@ -1 +1 @@
1
- {"version":3,"file":"recommendationsRequestMapper.js","names":[],"sources":["../../src/internal/recommendationsRequestMapper.ts"],"sourcesContent":["/**\n * Wire types for the recommendations *request* and `transformRequest`, which\n * builds the snake_case wire body from the public `RecommendationsRequest`.\n *\n * `InternalDiscoClient.getRecommendations` calls `transformRequest` to map the\n * camelCase request into the wire body before POSTing it.\n *\n * The mapping is Zod-backed: `RecommendationsRequest$outboundSchema` validates\n * the public request before a `z.transform()` reshapes it into the wire body,\n * so a malformed request surfaces as a `DiscoValidationError` *before* it hits\n * the network. This mirrors how Speakeasy-generated SDKs use an\n * `$outboundSchema` per model.\n */\n\nimport * as z from \"zod/v4-mini\";\nimport { parse } from \"../lib/schemas.js\";\nimport { remap } from \"../lib/primitives.js\";\nimport type {\n OrderDetails,\n PlacementDetails,\n Purchase,\n RecommendationsRequest,\n RunningExperiment,\n UserDetails,\n} from \"./recommendations.js\";\n\n// ─── Raw wire shape ──────────────────────────────────────────────────────────\n//\n// The endpoint nests most request fields under `recommendations_data`, with\n// monetary fields tucked into a `cost_details` sub-object, while experiments\n// and attributes sit at the top level. The public `RecommendationsRequest` is\n// a flatter façade over this; the outbound schema bridges the two.\n\ntype RawCostDetails = {\n amount?: number | string;\n currency_code?: string;\n};\n\ntype RawUserDetails = {\n email?: string;\n email_hash?: string;\n first_name?: string;\n last_name?: string;\n phone?: string;\n};\n\ntype RawPlacementDetails = {\n widget_id?: string;\n display_mode?: string;\n view?: string;\n};\n\ntype RawOrderDetails = {\n order_id?: string;\n cost_details?: RawCostDetails;\n};\n\ntype RawPurchase = {\n name?: string;\n type?: string;\n variant?: string;\n quantity?: number;\n product_id?: string;\n cost_details?: RawCostDetails;\n};\n\ntype RawRunningExperiment = {\n id: string;\n variant: string;\n};\n\ntype RawRecommendationsData = {\n user_details?: RawUserDetails;\n placement_details?: RawPlacementDetails;\n order_details?: RawOrderDetails;\n purchases?: RawPurchase[];\n};\n\ntype RawRecommendationsRequest = {\n recommendations_data?: RawRecommendationsData;\n running_experiments?: RawRunningExperiment[];\n attributes?: Record<string, unknown>;\n /**\n * Platform-specific top-level fields passed through untransformed\n * (e.g. `shopify_checkout_token`). The public type funnels these through\n * `extras`; on the raw body they're just additional keys.\n */\n [key: string]: unknown;\n};\n\n// ─── Outbound schemas ──────────────────────────────────────────────────────────\n//\n// Each schema validates a slice of the public (camelCase) request and pipes it\n// through a `z.transform()` into the snake_case wire shape. Simple field\n// renames go through `remap`; the monetary fields fold into a `cost_details`\n// sub-object that's omitted entirely when no amount/currency is present. The\n// `z.ZodMiniType<RawX, PublicX>` annotation pins input and output types to the\n// hand-written shapes so they can't drift.\n//\n// Written against `zod/v4-mini` (functional API) rather than classic `zod/v4`\n// so bundlers only keep the validators actually used — this matters for\n// size-capped runtimes such as Shopify UI extensions (64 KB).\n\nconst UserDetails$outboundSchema: z.ZodMiniType<RawUserDetails, UserDetails> =\n z.pipe(\n z.object({\n email: z.optional(z.string()),\n emailHash: z.optional(z.string()),\n firstName: z.optional(z.string()),\n lastName: z.optional(z.string()),\n phone: z.optional(z.string()),\n }),\n z.transform((v: UserDetails) =>\n remap(v, {\n emailHash: \"email_hash\",\n firstName: \"first_name\",\n lastName: \"last_name\",\n }),\n ),\n );\n\nconst PlacementDetails$outboundSchema: z.ZodMiniType<\n RawPlacementDetails,\n PlacementDetails\n> = z.pipe(\n z.object({\n widgetId: z.optional(z.string()),\n displayMode: z.optional(z.string()),\n view: z.optional(z.string()),\n }),\n z.transform((v: PlacementDetails) =>\n remap(v, { displayMode: \"display_mode\", widgetId: \"widget_id\" }),\n ),\n);\n\nconst OrderDetails$outboundSchema: z.ZodMiniType<\n RawOrderDetails,\n OrderDetails\n> = z.pipe(\n z.object({\n id: z.optional(z.string()),\n amount: z.optional(z.union([z.number(), z.string()])),\n currencyCode: z.optional(z.string()),\n }),\n z.transform(\n (v: OrderDetails): RawOrderDetails => ({\n order_id: v.id,\n cost_details:\n v.amount !== undefined || v.currencyCode !== undefined\n ? { amount: v.amount, currency_code: v.currencyCode }\n : undefined,\n }),\n ),\n);\n\nconst Purchase$outboundSchema: z.ZodMiniType<RawPurchase, Purchase> = z.pipe(\n z.object({\n name: z.optional(z.string()),\n type: z.optional(z.string()),\n variant: z.optional(z.string()),\n quantity: z.optional(z.number()),\n productId: z.optional(z.string()),\n amount: z.optional(z.number()),\n currencyCode: z.optional(z.string()),\n }),\n z.transform(\n (v: Purchase): RawPurchase => ({\n name: v.name,\n type: v.type,\n variant: v.variant,\n quantity: v.quantity,\n product_id: v.productId,\n cost_details:\n v.amount !== undefined || v.currencyCode !== undefined\n ? { amount: v.amount, currency_code: v.currencyCode }\n : undefined,\n }),\n ),\n);\n\nconst RunningExperiment$outboundSchema: z.ZodMiniType<\n RawRunningExperiment,\n RunningExperiment\n> = z.object({\n id: z.string(),\n variant: z.string(),\n});\n\n/**\n * Validates the public request and reshapes it into the raw wire body: nest\n * fields under `recommendations_data`, fold monetary fields into `cost_details`,\n * convert camelCase to snake_case, and spread `extras` at the top level\n * untransformed.\n */\nconst RecommendationsRequest$outboundSchema: z.ZodMiniType<\n RawRecommendationsRequest,\n RecommendationsRequest\n> = z.pipe(\n z.object({\n user: z.optional(UserDetails$outboundSchema),\n placement: z.optional(PlacementDetails$outboundSchema),\n order: z.optional(OrderDetails$outboundSchema),\n purchases: z.optional(z.array(Purchase$outboundSchema)),\n experiments: z.optional(z.array(RunningExperiment$outboundSchema)),\n attributes: z.optional(z.record(z.string(), z.unknown())),\n extras: z.optional(z.record(z.string(), z.unknown())),\n }),\n z.transform(\n (v): RawRecommendationsRequest => ({\n recommendations_data: {\n user_details: v.user,\n placement_details: v.placement,\n order_details: v.order,\n purchases: v.purchases,\n },\n running_experiments: v.experiments,\n attributes: v.attributes,\n ...v.extras,\n }),\n ),\n);\n\n// ─── Mapper ───────────────────────────────────────────────────────────────────\n\n/**\n * Build the raw request body from the public `RecommendationsRequest`: nest\n * fields under `recommendations_data`, fold monetary fields into `cost_details`\n * (omitted entirely when no amount/currency is present), and convert camelCase\n * to snake_case. `extras` is spread at the top level untransformed.\n *\n * Validates the input first and throws `DiscoValidationError` if the request\n * doesn't match the expected shape.\n *\n * @internal Built into `DiscoClient.getRecommendations`; not part of the public\n * API. The wire shape is encapsulated by the client on purpose.\n */\nexport function transformRequest(\n req: RecommendationsRequest,\n): RawRecommendationsRequest {\n return parse(\n req,\n (value) => RecommendationsRequest$outboundSchema.parse(value),\n \"Failed to validate recommendations request\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuGA,MAAM,6BACJ,EAAE,KACA,EAAE,OAAO;CACP,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,WA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;AACrC,CAAC,GACD,EAAE,WACC,OAA8B;CAC7B,MAAM,EAAE;CACR,MAAM,EAAE;CACR,SAAS,EAAE;CACX,UAAU,EAAE;CACZ,YAAY,EAAE;CACd,cACE,EAAE,WAAW,KAAA,KAAa,EAAE,iBAAiB,KAAA,IACzC;EAAE,QAAQ,EAAE;EAAQ,eAAe,EAAE;CAAa,IAClD,KAAA;AACR,EACF,CACF;AAEA,MAAM,mCAGF,EAAE,OAAO;CACX,IAAI,EAAE,OAAO;CACb,SAAS,EAAE,OAAO;AACpB,CAAC;;;;;;;AAQD,MAAM,wCAGF,EAAE,KACJ,EAAE,OAAO;CACP,MAAM,EAAE,SAAS,0BAA0B;CAC3C,WAAW,EAAE,SAAS,+BAA+B;CACrD,OAAO,EAAE,SAAS,2BAA2B;CAC7C,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;CACtD,aAAa,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;CACjE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;CACxD,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC,GACD,EAAE,WACC,OAAkC;CACjC,sBAAsB;EACpB,cAAc,EAAE;EAChB,mBAAmB,EAAE;EACrB,eAAe,EAAE;EACjB,WAAW,EAAE;CACf;CACA,qBAAqB,EAAE;CACvB,YAAY,EAAE;CACd,GAAG,EAAE;AACP,EACF,CACF;;;;;;;;;;;;;AAgBA,SAAgB,iBACd,KAC2B;CAC3B,OAAO,MACL,MACC,UAAU,sCAAsC,MAAM,KAAK,GAC5D,4CACF;AACF"}
1
+ {"version":3,"file":"recommendationsRequestMapper.js","names":[],"sources":["../../src/internal/recommendationsRequestMapper.ts"],"sourcesContent":["/**\n * Wire types for the recommendations *request* and `transformRequest`, which\n * builds the snake_case wire body from the public `RecommendationsRequest`.\n *\n * `InternalDiscoClient.getRecommendations` calls `transformRequest` to map the\n * camelCase request into the wire body before POSTing it.\n *\n * The mapping is Zod-backed: `RecommendationsRequest$outboundSchema` validates\n * the public request before a `z.transform()` reshapes it into the wire body,\n * so a malformed request surfaces as a `DiscoValidationError` *before* it hits\n * the network. This mirrors how Speakeasy-generated SDKs use an\n * `$outboundSchema` per model.\n */\n\nimport * as z from \"zod/v4-mini\";\nimport { parse } from \"../lib/schemas.js\";\nimport { remap } from \"../lib/primitives.js\";\nimport type { Address as RawAddress } from \"../api/generated/recommendations/types.gen.js\";\nimport { zAddress } from \"../api/generated/recommendations/zod.gen.js\";\nimport { wireAddress } from \"../external/recommendationsTransforms.js\";\nimport type {\n Address,\n OrderDetails,\n PlacementDetails,\n Purchase,\n RecommendationsRequest,\n RunningExperiment,\n UserDetails,\n} from \"./recommendations.js\";\n\n// ─── Raw wire shape ──────────────────────────────────────────────────────────\n//\n// The endpoint nests most request fields under `recommendations_data`, with\n// monetary fields tucked into a `cost_details` sub-object, while experiments\n// and attributes sit at the top level. The public `RecommendationsRequest` is\n// a flatter façade over this; the outbound schema bridges the two.\n\ntype RawCostDetails = {\n amount?: number | string;\n currency_code?: string;\n};\n\ntype RawUserDetails = {\n email?: string;\n email_hash?: string;\n first_name?: string;\n last_name?: string;\n phone?: string;\n};\n\ntype RawPlacementDetails = {\n widget_id?: string;\n display_mode?: string;\n view?: string;\n};\n\ntype RawOrderDetails = {\n order_id?: string;\n cost_details?: RawCostDetails;\n};\n\ntype RawPurchase = {\n name?: string;\n type?: string;\n variant?: string;\n quantity?: number;\n product_id?: string;\n cost_details?: RawCostDetails;\n};\n\ntype RawRunningExperiment = {\n id: string;\n variant: string;\n};\n\ntype RawRecommendationsData = {\n user_details?: RawUserDetails;\n placement_details?: RawPlacementDetails;\n order_details?: RawOrderDetails;\n purchases?: RawPurchase[];\n shipping?: RawAddress;\n billing?: RawAddress;\n};\n\ntype RawRecommendationsRequest = {\n recommendations_data?: RawRecommendationsData;\n running_experiments?: RawRunningExperiment[];\n attributes?: Record<string, unknown>;\n /**\n * Platform-specific top-level fields passed through untransformed\n * (e.g. `shopify_checkout_token`). The public type funnels these through\n * `extras`; on the raw body they're just additional keys.\n */\n [key: string]: unknown;\n};\n\n// ─── Outbound schemas ──────────────────────────────────────────────────────────\n//\n// Each schema validates a slice of the public (camelCase) request and pipes it\n// through a `z.transform()` into the snake_case wire shape. Simple field\n// renames go through `remap`; the monetary fields fold into a `cost_details`\n// sub-object that's omitted entirely when no amount/currency is present. The\n// `z.ZodMiniType<RawX, PublicX>` annotation pins input and output types to the\n// hand-written shapes so they can't drift.\n//\n// Written against `zod/v4-mini` (functional API) rather than classic `zod/v4`\n// so bundlers only keep the validators actually used — this matters for\n// size-capped runtimes such as Shopify UI extensions (64 KB).\n\nconst UserDetails$outboundSchema: z.ZodMiniType<RawUserDetails, UserDetails> =\n z.pipe(\n z.object({\n email: z.optional(z.string()),\n emailHash: z.optional(z.string()),\n firstName: z.optional(z.string()),\n lastName: z.optional(z.string()),\n phone: z.optional(z.string()),\n }),\n z.transform((v: UserDetails) =>\n remap(v, {\n emailHash: \"email_hash\",\n firstName: \"first_name\",\n lastName: \"last_name\",\n }),\n ),\n );\n\nconst PlacementDetails$outboundSchema: z.ZodMiniType<\n RawPlacementDetails,\n PlacementDetails\n> = z.pipe(\n z.object({\n widgetId: z.optional(z.string()),\n displayMode: z.optional(z.string()),\n view: z.optional(z.string()),\n }),\n z.transform((v: PlacementDetails) =>\n remap(v, { displayMode: \"display_mode\", widgetId: \"widget_id\" }),\n ),\n);\n\nconst OrderDetails$outboundSchema: z.ZodMiniType<\n RawOrderDetails,\n OrderDetails\n> = z.pipe(\n z.object({\n id: z.optional(z.string()),\n amount: z.optional(z.union([z.number(), z.string()])),\n currencyCode: z.optional(z.string()),\n }),\n z.transform(\n (v: OrderDetails): RawOrderDetails => ({\n order_id: v.id,\n cost_details:\n v.amount !== undefined || v.currencyCode !== undefined\n ? { amount: v.amount, currency_code: v.currencyCode }\n : undefined,\n }),\n ),\n);\n\nconst Purchase$outboundSchema: z.ZodMiniType<RawPurchase, Purchase> = z.pipe(\n z.object({\n name: z.optional(z.string()),\n type: z.optional(z.string()),\n variant: z.optional(z.string()),\n quantity: z.optional(z.number()),\n productId: z.optional(z.string()),\n amount: z.optional(z.number()),\n currencyCode: z.optional(z.string()),\n }),\n z.transform(\n (v: Purchase): RawPurchase => ({\n name: v.name,\n type: v.type,\n variant: v.variant,\n quantity: v.quantity,\n product_id: v.productId,\n cost_details:\n v.amount !== undefined || v.currencyCode !== undefined\n ? { amount: v.amount, currency_code: v.currencyCode }\n : undefined,\n }),\n ),\n);\n\n// The proxy forwards addresses to rec-api untouched, so this is the external\n// client's address handling, not a restatement of it: map with `wireAddress`,\n// then validate the wire shape against the spec's generated `zAddress`, as\n// `DiscoClient` does.\nconst Address$outboundSchema: z.ZodMiniType<RawAddress, Address> = z.pipe(\n z.pipe(\n z.custom<Address>((v) => typeof v === \"object\" && v !== null),\n z.transform(wireAddress),\n ),\n zAddress,\n);\n\nconst RunningExperiment$outboundSchema: z.ZodMiniType<\n RawRunningExperiment,\n RunningExperiment\n> = z.object({\n id: z.string(),\n variant: z.string(),\n});\n\n/**\n * Validates the public request and reshapes it into the raw wire body: nest\n * fields under `recommendations_data`, fold monetary fields into `cost_details`,\n * convert camelCase to snake_case, and spread `extras` at the top level\n * untransformed.\n */\nconst RecommendationsRequest$outboundSchema: z.ZodMiniType<\n RawRecommendationsRequest,\n RecommendationsRequest\n> = z.pipe(\n z.object({\n user: z.optional(UserDetails$outboundSchema),\n placement: z.optional(PlacementDetails$outboundSchema),\n order: z.optional(OrderDetails$outboundSchema),\n purchases: z.optional(z.array(Purchase$outboundSchema)),\n shipping: z.optional(Address$outboundSchema),\n billing: z.optional(Address$outboundSchema),\n experiments: z.optional(z.array(RunningExperiment$outboundSchema)),\n attributes: z.optional(z.record(z.string(), z.unknown())),\n extras: z.optional(z.record(z.string(), z.unknown())),\n }),\n z.transform(\n (v): RawRecommendationsRequest => ({\n recommendations_data: {\n user_details: v.user,\n placement_details: v.placement,\n order_details: v.order,\n purchases: v.purchases,\n shipping: v.shipping,\n billing: v.billing,\n },\n running_experiments: v.experiments,\n attributes: v.attributes,\n ...v.extras,\n }),\n ),\n);\n\n// ─── Mapper ───────────────────────────────────────────────────────────────────\n\n/**\n * Build the raw request body from the public `RecommendationsRequest`: nest\n * fields under `recommendations_data`, fold monetary fields into `cost_details`\n * (omitted entirely when no amount/currency is present), and convert camelCase\n * to snake_case. `extras` is spread at the top level untransformed.\n *\n * Validates the input first and throws `DiscoValidationError` if the request\n * doesn't match the expected shape.\n *\n * @internal Built into `DiscoClient.getRecommendations`; not part of the public\n * API. The wire shape is encapsulated by the client on purpose.\n */\nexport function transformRequest(\n req: RecommendationsRequest,\n): RawRecommendationsRequest {\n return parse(\n req,\n (value) => RecommendationsRequest$outboundSchema.parse(value),\n \"Failed to validate recommendations request\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6GA,MAAM,6BACJ,EAAE,KACA,EAAE,OAAO;CACP,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAC/B,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;AAC9B,CAAC,GACD,EAAE,WAAW,MACX,MAAM,GAAG;CACP,WAAW;CACX,WAAW;CACX,UAAU;AACZ,CAAC,CACH,CACF;AAEF,MAAM,kCAGF,EAAE,KACJ,EAAE,OAAO;CACP,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAC/B,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC;CAClC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;AAC7B,CAAC,GACD,EAAE,WAAW,MACX,MAAM,GAAG;CAAE,aAAa;CAAgB,UAAU;AAAY,CAAC,CACjE,CACF;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AAQD,MAAM,wCAGF,EAAE,KACJ,EAAE,OAAO;CACP,MAAM,EAAE,SAAS,0BAA0B;CAC3C,WAAW,EAAE,SAAS,+BAA+B;CACrD,OAAO,EAAE,SAAS,2BAA2B;CAC7C,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;CACtD,UAAU,EAAE,SAAS,sBAAsB;CAC3C,SAAS,EAAE,SAAS,sBAAsB;CAC1C,aAAa,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;CACjE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;CACxD,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC,GACD,EAAE,WACC,OAAkC;CACjC,sBAAsB;EACpB,cAAc,EAAE;EAChB,mBAAmB,EAAE;EACrB,eAAe,EAAE;EACjB,WAAW,EAAE;EACb,UAAU,EAAE;EACZ,SAAS,EAAE;CACb;CACA,qBAAqB,EAAE;CACvB,YAAY,EAAE;CACd,GAAG,EAAE;AACP,EACF,CACF;;;;;;;;;;;;;AAgBA,SAAgB,iBACd,KAC2B;CAC3B,OAAO,MACL,MACC,UAAU,sCAAsC,MAAM,KAAK,GAC5D,4CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { SdkIdentity } from "./sdkIdentity.js";
2
- import { Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata } from "./external/recommendations.js";
2
+ import { Address, Advertiser, Footer, Offer, OfferAsset, OfferCtaDetails, OfferDisclosureDetails, OfferMetadata } from "./external/recommendations.js";
3
3
  import { BrandClickInitiatingTarget, BrandDisplayInitiatingTarget, BrandProperties, BrandVisibilityEventType, ElementClickInitiatingTarget, EventPayload, EventPlacementDetails, EventTracker, ProductDisplayInitiatingTarget, ProductEventType, ProductProperties, WidgetEventType } from "./types.js";
4
4
  import { DiscoApiError, DiscoError, DiscoNetworkError, DiscoValidationError } from "./errors.js";
5
5
  import { DiscoEnv } from "./env.js";
@@ -8,4 +8,4 @@ import { ApiKeyConfig, CreateTrackingManagerOptions, DiscoClientConfig, GetRecom
8
8
  import { TrackingManager, TrackingManagerConfig } from "./TrackingManager.js";
9
9
  import { denormalize } from "./internal/denormalize.js";
10
10
  import { ASTNode, LinkNode, ParagraphNode, Screen, ScreenDocument, ScrollViewNode, TextNode, parseScreens } from "./internal/screens.js";
11
- export { type ASTNode, type Advertiser, type ApiKeyConfig, type BrandClickInitiatingTarget, type BrandDisplayInitiatingTarget, type BrandProperties, type BrandVisibilityEventType, type CreateTrackingManagerOptions, DiscoApiError, type DiscoClientConfig, type DiscoEnv, DiscoError, DiscoNetworkError, DiscoValidationError, type ElementClickInitiatingTarget, type EventPayload, type EventPlacementDetails, type EventTracker, type Footer, type GetRecommendationsOptions, INTERNAL_BASE_URL, InternalDiscoClient, type LayoutId, type LinkNode, type Offer, type OfferAsset, type OfferCtaDetails, type OfferDisclosureDetails, type OfferMetadata, type OrderDetails, type ParagraphNode, type PlacementDetails, type ProductDisplayInitiatingTarget, type ProductEventType, type ProductProperties, type PublisherCustomization, type Purchase, type Recommendation, type RecommendationGroup, type RecommendationsRequest, type RecommendationsResponse, type RecommendationsWithTracker, type RunningExperiment, type Screen, type ScreenDocument, type ScrollViewNode, type SdkIdentity, type ShopGidConfig, type TextNode, TrackingManager, type TrackingManagerConfig, type UserDetails, type WidgetEventType, denormalize, parseScreens };
11
+ export { type ASTNode, type Address, type Advertiser, type ApiKeyConfig, type BrandClickInitiatingTarget, type BrandDisplayInitiatingTarget, type BrandProperties, type BrandVisibilityEventType, type CreateTrackingManagerOptions, DiscoApiError, type DiscoClientConfig, type DiscoEnv, DiscoError, DiscoNetworkError, DiscoValidationError, type ElementClickInitiatingTarget, type EventPayload, type EventPlacementDetails, type EventTracker, type Footer, type GetRecommendationsOptions, INTERNAL_BASE_URL, InternalDiscoClient, type LayoutId, type LinkNode, type Offer, type OfferAsset, type OfferCtaDetails, type OfferDisclosureDetails, type OfferMetadata, type OrderDetails, type ParagraphNode, type PlacementDetails, type ProductDisplayInitiatingTarget, type ProductEventType, type ProductProperties, type PublisherCustomization, type Purchase, type Recommendation, type RecommendationGroup, type RecommendationsRequest, type RecommendationsResponse, type RecommendationsWithTracker, type RunningExperiment, type Screen, type ScreenDocument, type ScrollViewNode, type SdkIdentity, type ShopGidConfig, type TextNode, TrackingManager, type TrackingManagerConfig, type UserDetails, type WidgetEventType, denormalize, parseScreens };
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@disconetwork/core";
3
- var version = "0.0.18";
3
+ var version = "0.0.20";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disconetwork/core",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Core package for disco-js.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "dist"
27
27
  ],
28
28
  "publishConfig": {
29
- "access": "restricted"
29
+ "access": "public"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=20"