@ingridab/sdk 0.3.0 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -869,6 +869,12 @@ declare type DateTimeRange = {
869
869
  start?: string;
870
870
  };
871
871
 
872
+ declare type DeepNonNullable<T> = T extends (...args: unknown[]) => unknown
873
+ ? T
874
+ : T extends object
875
+ ? { [K in keyof T]-?: DeepNonNullable<T[K]> }
876
+ : NonNullable<T>;
877
+
872
878
  declare type DeepPartial<T> = T extends (infer U)[]
873
879
  ? // this prevents the array elements from being undefined
874
880
  // DeepPartial<string[]> would be string[] | undefined instead of (string | undefined)[]
@@ -1009,6 +1015,8 @@ declare type DeliveryGroup = {
1009
1015
  fulfillmentGroupRef?: string;
1010
1016
  };
1011
1017
 
1018
+ /* Excluded from this release type: DeliveryMoleculeCustomization */
1019
+
1012
1020
  declare type DeliveryMoleculeParams = {
1013
1021
  mode: 'active' | 'passive';
1014
1022
  name: string;
@@ -1018,6 +1026,7 @@ declare type DeliveryMoleculeParams = {
1018
1026
  gaplessAddonsList?: boolean;
1019
1027
  gaplessCarrierList?: boolean;
1020
1028
  gaplessDeliveryList?: boolean;
1029
+ gaplessDeliveryTimeList?: boolean;
1021
1030
  labels?: 'off' | 'chips' | 'text';
1022
1031
  showAddons?: boolean;
1023
1032
  showCustomInfoText?: boolean;
@@ -1028,13 +1037,15 @@ declare type DeliveryMoleculeParams = {
1028
1037
  showPrice?: boolean;
1029
1038
  showRadioIndicator?: boolean;
1030
1039
  showReturnPromise?: boolean;
1031
- showShippingLogo?: boolean;
1040
+ showCarrierLogo?: boolean;
1041
+ showCarrierName?: boolean;
1032
1042
  showDeliveryTime?: boolean;
1033
1043
  showLocationSection?: boolean;
1034
1044
  showLocationAddress?: boolean;
1035
1045
  showLocationCarrierName?: boolean;
1036
1046
  showLocationType?: boolean;
1037
1047
  categoryLabel?: 'name' | 'type';
1048
+ deliveryTime?: 'off' | 'inline' | 'popup';
1038
1049
  };
1039
1050
  location?: {
1040
1051
  gaplessList?: boolean;
@@ -1304,7 +1315,7 @@ declare type Event_2<T> = { payload: T };
1304
1315
  * | Event | When it fires |
1305
1316
  * | ----------------- | --------------------------------------------------------------------- |
1306
1317
  * | `ready` | Compound is mounted and interactive |
1307
- * | `addressSubmit` | Shopper confirms the address form |
1318
+ * | `addressSubmit` | Shopper confirms the address form or submits a postal code |
1308
1319
  * | `countryChange` | Shopper selects a different country |
1309
1320
  * | `selectionChange` | Shopper selects a delivery option |
1310
1321
  * | `error` | An unhandled error occurs during mount or is caught by the compound's error boundary at runtime |
@@ -1327,9 +1338,16 @@ export declare type EventsMap = {
1327
1338
  * Fires when the shopper selects a delivery option. `groupId`/`categoryId`
1328
1339
  * identify the choice within the options response; `serviceToken` is the
1329
1340
  * signed offer token to hand to the orchestrator for backend order creation.
1341
+ * `timeSlotId` is the selected scheduled-delivery window (one of the
1342
+ * service's `timeSlots[].id`), present only when the user picked a slot.
1330
1343
  */
1331
1344
  selectionChange: (
1332
- event: Event_2<{ groupId: string; categoryId: string; serviceToken: string }>
1345
+ event: Event_2<{
1346
+ groupId: string;
1347
+ categoryId: string;
1348
+ serviceToken: string;
1349
+ timeSlotId?: string;
1350
+ }>
1333
1351
  ) => void;
1334
1352
  ready: () => void;
1335
1353
  error: (error: unknown) => void;
@@ -1972,8 +1990,9 @@ declare type MoleculeCustomizationConfig<T extends MoleculeType> = MoleculeCusto
1972
1990
  declare type MoleculeCustomizationConfigMap = {
1973
1991
  address: AddressMoleculeCustomization;
1974
1992
  countrySelector: CountrySelectorParams['customization'];
1975
- delivery: DeliveryMoleculeParams['customization'];
1993
+ delivery: DeliveryMoleculeCustomization;
1976
1994
  freeShippingIndicator: FreeShippingIndicatorParams['customization'];
1995
+ postalCode: PostalCodeMoleculeCustomization;
1977
1996
  tracking: TrackingNumberParams['customization'];
1978
1997
  };
1979
1998
 
@@ -1984,6 +2003,7 @@ declare type MoleculeMapType = {
1984
2003
  freeShippingIndicator: {
1985
2004
  readonly validator: typeof freeShippingIndicatorMoleculeParamsValidator;
1986
2005
  };
2006
+ postalCode: { readonly validator: typeof postalCodeMoleculeParamsValidator };
1987
2007
  tracking: { readonly validator: typeof trackingNumberParamsValidator };
1988
2008
  };
1989
2009
 
@@ -1992,6 +2012,7 @@ declare type MoleculeParamsMap = {
1992
2012
  countrySelector: CountrySelectorParams;
1993
2013
  delivery: DeliveryMoleculeParams;
1994
2014
  freeShippingIndicator: FreeShippingIndicatorParams;
2015
+ postalCode: PostalCodeParams;
1995
2016
  tracking: TrackingNumberParams;
1996
2017
  };
1997
2018
 
@@ -2302,6 +2323,17 @@ declare type PickupLocationTypeEnum =
2302
2323
  | 'MANNED'
2303
2324
  | 'AGE_VERIFICATION';
2304
2325
 
2326
+ /* Excluded from this release type: PostalCodeMoleculeCustomization */
2327
+
2328
+ declare const postalCodeMoleculeParamsValidator = z.object({
2329
+ customization: z.object({}).optional(),
2330
+ }) satisfies z.ZodType<PostalCodeParams>;
2331
+
2332
+ declare type PostalCodeParams = {
2333
+ // No customization flags yet
2334
+ customization?: Record<never, never>;
2335
+ };
2336
+
2305
2337
  /**
2306
2338
  * @description A single address prediction returned by the autocomplete endpoint.
2307
2339
  */
@@ -2573,6 +2605,7 @@ declare type RawTranslationKey =
2573
2605
  | 'global.pickup_locations'
2574
2606
  | 'global.postal_code'
2575
2607
  | 'global.save'
2608
+ | 'global.select_delivery_time'
2576
2609
  | 'global.select_location'
2577
2610
  | 'global.show'
2578
2611
  | 'global.show_available_services'
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { z as t } from "zod";
2
- import { QueryClient as V } from "@tanstack/query-core";
3
- import { atom as f, createStore as R } from "jotai";
4
- import W from "axios";
5
- import $ from "i18next";
6
- const xe = ({ mode: e, customization: r }) => ({
2
+ import { QueryClient as q } from "@tanstack/query-core";
3
+ import { atom as f, createStore as $ } from "jotai";
4
+ import O from "axios";
5
+ import K from "i18next";
6
+ const De = ({ mode: e, customization: r }) => ({
7
7
  type: "address",
8
8
  customization: r,
9
9
  params: {
10
10
  mode: e
11
11
  }
12
- }), P = ["en-US", "pl-PL", "sv-SE"];
12
+ }), C = ["en-US", "pl-PL", "sv-SE"];
13
13
  t.union([
14
- t.object({ token: t.string().optional(), locale: t.enum(P) }),
15
- t.object({ email: t.string(), tos_id: t.string(), locale: t.enum(P) })
14
+ t.object({ token: t.string().optional(), locale: t.enum(C) }),
15
+ t.object({ email: t.string(), tos_id: t.string(), locale: t.enum(C) })
16
16
  ]);
17
17
  t.object({
18
18
  id: t.string().optional(),
@@ -67,12 +67,13 @@ t.object({
67
67
  name: t.string(),
68
68
  customization: t.object({}).optional()
69
69
  });
70
- const x = t.number().int().min(0).max(24).optional(), K = t.object({
70
+ const x = t.number().int().min(0).max(24).optional(), Z = t.object({
71
71
  choice: t.object({
72
72
  carrierInstructions: t.enum(["off", "inline", "popup"]).optional(),
73
73
  gaplessAddonsList: t.boolean().optional(),
74
74
  gaplessCarrierList: t.boolean().optional(),
75
75
  gaplessDeliveryList: t.boolean().optional(),
76
+ gaplessDeliveryTimeList: t.boolean().optional(),
76
77
  labels: t.enum(["off", "chips", "text"]).optional(),
77
78
  showAddons: t.boolean().optional(),
78
79
  showCustomInfoText: t.boolean().optional(),
@@ -83,13 +84,15 @@ const x = t.number().int().min(0).max(24).optional(), K = t.object({
83
84
  showPrice: t.boolean().optional(),
84
85
  showRadioIndicator: t.boolean().optional(),
85
86
  showReturnPromise: t.boolean().optional(),
86
- showShippingLogo: t.boolean().optional(),
87
+ showCarrierLogo: t.boolean().optional(),
88
+ showCarrierName: t.boolean().optional(),
87
89
  showDeliveryTime: t.boolean().optional(),
88
90
  showLocationSection: t.boolean().optional(),
89
91
  showLocationAddress: t.boolean().optional(),
90
92
  showLocationCarrierName: t.boolean().optional(),
91
93
  showLocationType: t.boolean().optional(),
92
- categoryLabel: t.enum(["name", "type"]).optional()
94
+ categoryLabel: t.enum(["name", "type"]).optional(),
95
+ deliveryTime: t.enum(["off", "inline", "popup"]).optional()
93
96
  }).optional(),
94
97
  location: t.object({
95
98
  gaplessList: t.boolean().optional(),
@@ -126,7 +129,7 @@ const x = t.number().int().min(0).max(24).optional(), K = t.object({
126
129
  }).optional()
127
130
  }).optional();
128
131
  t.object({
129
- customization: K,
132
+ customization: Z,
130
133
  mode: t.enum(["active", "passive"]),
131
134
  name: t.string()
132
135
  });
@@ -138,6 +141,9 @@ t.object({
138
141
  zeroPriceDisplay: t.enum(["free", "0"]).optional()
139
142
  }).optional()
140
143
  });
144
+ t.object({
145
+ customization: t.object({}).optional()
146
+ });
141
147
  t.object({
142
148
  parcelIndex: t.string(),
143
149
  customization: t.object({}).optional()
@@ -147,7 +153,7 @@ const D = {
147
153
  warn: 1,
148
154
  info: 2,
149
155
  debug: 3
150
- }, Z = async (e) => await import(e), G = {
156
+ }, G = async (e) => await import(e), H = {
151
157
  "address.address_book.billing.modal.aria.label": "Choose a billing address from your address book",
152
158
  "address.address_book.delivery.modal.aria.label": "Choose a delivery address from your address book",
153
159
  "address.confirm": "Confirm address",
@@ -295,6 +301,7 @@ const D = {
295
301
  "global.pickup_locations": "Pickup locations",
296
302
  "global.postal_code": "Postal Code",
297
303
  "global.save": "Save",
304
+ "global.select_delivery_time": "Select delivery time",
298
305
  "global.select_location": "Select location",
299
306
  "global.show": "Show",
300
307
  "global.show_available_services": "Show available services",
@@ -344,7 +351,7 @@ const D = {
344
351
  "time.tuesday": "Tuesday",
345
352
  "time.wednesday": "Wednesday",
346
353
  "tracking.track_delivery_with": "Track delivery with {{carrierName}}"
347
- }, H = {
354
+ }, J = {
348
355
  "address.address_book.billing.modal.aria.label": "Wybierz adres rozliczeniowy z książki adresowej",
349
356
  "address.address_book.delivery.modal.aria.label": "Wybierz adres dostawy z książki adresowej",
350
357
  "address.confirm": "Potwierdź adres",
@@ -492,6 +499,7 @@ const D = {
492
499
  "global.pickup_locations": "Punkty odbioru",
493
500
  "global.postal_code": "Kod pocztowy",
494
501
  "global.save": "Zapisz",
502
+ "global.select_delivery_time": "Wybierz czas dostawy",
495
503
  "global.select_location": "Wybierz lokalizację",
496
504
  "global.show": "Pokaż",
497
505
  "global.show_available_services": "Pokaż dostępne usługi",
@@ -544,7 +552,7 @@ const D = {
544
552
  "time.tuesday": "Wtorek",
545
553
  "time.wednesday": "Środa",
546
554
  "tracking.track_delivery_with": "Śledź przesyłkę z {{carrierName}}"
547
- }, J = {
555
+ }, Q = {
548
556
  "address.address_book.billing.modal.aria.label": "Välj en faktureringsadress från din adressbok",
549
557
  "address.address_book.delivery.modal.aria.label": "Välj en leveransadress från din adressbok",
550
558
  "address.confirm": "Bekräfta adress",
@@ -692,6 +700,7 @@ const D = {
692
700
  "global.pickup_locations": "Utlämningsställen",
693
701
  "global.postal_code": "Postnummer",
694
702
  "global.save": "Spara",
703
+ "global.select_delivery_time": "Välj leveranstid",
695
704
  "global.select_location": "Välj plats",
696
705
  "global.show": "Visa",
697
706
  "global.show_available_services": "Visa tillgängliga tjänster",
@@ -741,24 +750,24 @@ const D = {
741
750
  "time.tuesday": "Tisdag",
742
751
  "time.wednesday": "Onsdag",
743
752
  "tracking.track_delivery_with": "Spåra leverans med {{carrierName}}"
744
- }, Q = {
745
- "en-US": G,
746
- "pl-PL": H,
747
- "sv-SE": J
748
- }, Y = async ({ token: e, initUrl: r, siteId: a }) => (await Promise.resolve(), {
753
+ }, Y = {
754
+ "en-US": H,
755
+ "pl-PL": J,
756
+ "sv-SE": Q
757
+ }, X = async ({ token: e, initUrl: r, siteId: a }) => (await Promise.resolve(), {
749
758
  token: e,
750
759
  initUrl: r,
751
760
  siteId: a
752
- }), X = async (e) => (await Promise.resolve(), Q[e] || "en-US"), ee = (e) => {
753
- const r = "0.3.0".split(".").slice(0, 2).join("."), a = e.versions.sdkCompatibility?.[r];
754
- return typeof a == "string" && a.trim().length > 0 ? a : "0.3.0";
755
- }, re = new V({
761
+ }), ee = async (e) => (await Promise.resolve(), Y[e] || "en-US"), re = (e) => {
762
+ const r = "0.4.0".split(".").slice(0, 2).join("."), a = e.versions.sdkCompatibility?.[r];
763
+ return typeof a == "string" && a.trim().length > 0 ? a : "0.4.0";
764
+ }, te = new q({
756
765
  defaultOptions: {
757
766
  queries: {
758
767
  refetchOnWindowFocus: !1
759
768
  }
760
769
  }
761
- }), te = (e) => e === "stage" ? "https://cdn-stage.ingrid.com/experience-kit/molecules" : "https://cdn.ingrid.com/experience-kit/molecules", ae = async (e, r) => {
770
+ }), ae = (e) => e === "stage" ? "https://cdn-stage.ingrid.com/experience-kit/molecules" : "https://cdn.ingrid.com/experience-kit/molecules", oe = async (e, r) => {
762
771
  try {
763
772
  const a = await fetch(`${e}/release-index.json`);
764
773
  if (!a.ok)
@@ -768,15 +777,15 @@ const D = {
768
777
  } catch (a) {
769
778
  return r.error("Error fetching release index", { error: a }), null;
770
779
  }
771
- }, oe = async ({
780
+ }, se = async ({
772
781
  moleculesUrl: e,
773
782
  logger: r
774
- }) => re.fetchQuery({
783
+ }) => te.fetchQuery({
775
784
  queryKey: [e, "release-index"],
776
- queryFn: () => ae(e, r),
785
+ queryFn: () => oe(e, r),
777
786
  staleTime: 1 / 0
778
- }), T = "en-US", se = async () => {
779
- const e = $.createInstance();
787
+ }), T = "en-US", ie = async () => {
788
+ const e = K.createInstance();
780
789
  return await e.init({
781
790
  defaultNS: "default",
782
791
  lng: T,
@@ -791,7 +800,7 @@ const D = {
791
800
  }
792
801
  };
793
802
  };
794
- class ie {
803
+ class ne {
795
804
  instance;
796
805
  securityData = null;
797
806
  securityWorker;
@@ -803,7 +812,7 @@ class ie {
803
812
  format: o,
804
813
  ...s
805
814
  } = {}) {
806
- this.instance = W.create({
815
+ this.instance = O.create({
807
816
  ...s,
808
817
  baseURL: s.baseURL || "https://api.ingrid.com"
809
818
  }), this.secure = a, this.format = o, this.securityWorker = r;
@@ -863,7 +872,7 @@ class ie {
863
872
  });
864
873
  };
865
874
  }
866
- class C extends ie {
875
+ class P extends ne {
867
876
  v1 = {
868
877
  /**
869
878
  * @description Get the full address details for a prediction. Exchanges a prediction ID (where `action` was `resolve`) for a full, formatted address object that can be used to populate the address form fields. This is the second step of the autocomplete flow — called after the user selects a final address prediction from the autocomplete results.
@@ -936,11 +945,11 @@ class C extends ie {
936
945
  })
937
946
  };
938
947
  }
939
- const ne = ({
948
+ const de = ({
940
949
  baseUrl: e,
941
950
  logger: r
942
951
  }) => {
943
- const a = new C({
952
+ const a = new P({
944
953
  baseURL: e ? `${e}` : void 0
945
954
  });
946
955
  return {
@@ -952,11 +961,11 @@ const ne = ({
952
961
  return r.debug("Validated address successfully", { data: n }), n;
953
962
  }
954
963
  };
955
- }, de = ({
964
+ }, le = ({
956
965
  baseUrl: e,
957
966
  logger: r
958
967
  }) => {
959
- const a = new C({
968
+ const a = new P({
960
969
  baseURL: e ? `${e}` : void 0
961
970
  });
962
971
  return {
@@ -979,11 +988,11 @@ const ne = ({
979
988
  return r.debug("Converted address suggestion successfully", { data: i }), i;
980
989
  }
981
990
  };
982
- }, le = ({
991
+ }, ce = ({
983
992
  baseUrl: e,
984
993
  logger: r
985
994
  }) => {
986
- const a = new C({
995
+ const a = new P({
987
996
  baseURL: e ? `${e}` : void 0
988
997
  });
989
998
  return {
@@ -995,11 +1004,11 @@ const ne = ({
995
1004
  return r.debug("Got address form config successfully", { data: n }), n;
996
1005
  }
997
1006
  };
998
- }, De = (e) => ({ __tag: "withDefaultProvider", factory: e });
1007
+ }, Te = (e) => ({ __tag: "withDefaultProvider", factory: e });
999
1008
  function c(e, r) {
1000
1009
  return r === void 0 ? e : typeof r == "function" ? r : r.factory(e);
1001
1010
  }
1002
- const ce = (e) => {
1011
+ const ue = (e) => {
1003
1012
  const r = (a) => e.warn(
1004
1013
  `delivery.${a} has no default implementation. Provide a custom delivery service via dataProviders.services.delivery to enable the delivery molecule.`
1005
1014
  );
@@ -1011,7 +1020,7 @@ const ce = (e) => {
1011
1020
  locations: []
1012
1021
  }))
1013
1022
  };
1014
- }, ue = (e) => {
1023
+ }, me = (e) => {
1015
1024
  const r = (a) => e.warn(
1016
1025
  `ContactsService.${a} has no implementation. Provide a custom contacts service to support address book features.`
1017
1026
  );
@@ -1021,20 +1030,20 @@ const ce = (e) => {
1021
1030
  upsertContactBookEntry: () => (r("upsertContactBookEntry"), Promise.resolve({})),
1022
1031
  deleteContactBookEntry: () => (r("deleteContactBookEntry"), Promise.resolve({}))
1023
1032
  };
1024
- }, me = ({ baseUrl: e }) => async (r) => (await W.get(
1033
+ }, pe = ({ baseUrl: e }) => async (r) => (await O.get(
1025
1034
  `${e}/v1/delivery_tracking/tracking_data.get`,
1026
1035
  {
1027
1036
  params: r
1028
1037
  }
1029
- )).data, pe = async (e, r) => {
1030
- const a = ue(r), o = de({
1038
+ )).data, ge = async (e, r) => {
1039
+ const a = me(r), o = le({
1031
1040
  baseUrl: e,
1032
1041
  logger: r
1033
- }), s = ne({ baseUrl: e, logger: r }), n = le({ baseUrl: e, logger: r }), i = await se();
1042
+ }), s = de({ baseUrl: e, logger: r }), n = ce({ baseUrl: e, logger: r }), i = await ie();
1034
1043
  return {
1035
- delivery: ce(r),
1044
+ delivery: ue(r),
1036
1045
  tracking: {
1037
- getTrackingData: me({ baseUrl: e })
1046
+ getTrackingData: pe({ baseUrl: e })
1038
1047
  },
1039
1048
  translations: {
1040
1049
  formatMessage: i.formatMessage,
@@ -1051,7 +1060,7 @@ const ce = (e) => {
1051
1060
  getAddressFormConfig: n.getAddressFormConfig
1052
1061
  }
1053
1062
  };
1054
- }, u = (e) => (Object.assign(e, { __type: "internal" }), e), ge = (e, r) => ({
1063
+ }, u = (e) => (Object.assign(e, { __type: "internal" }), e), ye = (e, r) => ({
1055
1064
  delivery: {
1056
1065
  getDeliveryOptions: c(
1057
1066
  u(e.delivery.getDeliveryOptions),
@@ -1118,11 +1127,11 @@ const ce = (e) => {
1118
1127
  return;
1119
1128
  }
1120
1129
  e(...s);
1121
- }, ye = (e = "production") => e === "stage" ? "https://api-stage.ingrid.com" : "https://api.ingrid.com", B = (e, r) => {
1130
+ }, _e = (e = "production") => e === "stage" ? "https://api-stage.ingrid.com" : "https://api.ingrid.com", B = (e, r) => {
1122
1131
  Object.entries(e).forEach(([a, o]) => {
1123
1132
  r.style.setProperty(a, o);
1124
1133
  });
1125
- }, _e = () => {
1134
+ }, fe = () => {
1126
1135
  const e = document.createElement("link");
1127
1136
  e.rel = "preload", e.href = void 0, e.as = "font", e.type = "font/woff2", e.crossOrigin = "anonymous";
1128
1137
  const r = document.createElement("style");
@@ -1134,7 +1143,7 @@ const ce = (e) => {
1134
1143
  }
1135
1144
  `)
1136
1145
  ), document.head.appendChild(e), document.head.appendChild(r);
1137
- }, fe = (e) => e instanceof HTMLElement, be = ({ logger: e, eventChannel: r, ...a }, o, s, n) => {
1146
+ }, be = (e) => e instanceof HTMLElement, ve = ({ logger: e, eventChannel: r, ...a }, o, s, n) => {
1138
1147
  if (!s)
1139
1148
  throw e.error("Instance creation failed: compoundInitUrl is empty"), new Error("compoundInitUrl cannot be empty");
1140
1149
  let i = null;
@@ -1176,14 +1185,14 @@ const ce = (e) => {
1176
1185
  const d = document.querySelector(l);
1177
1186
  if (!d)
1178
1187
  throw e.error("Mount failed: container not found", { containerSelector: l }), new Error("Container couldn't be found!");
1179
- if (!fe(d))
1188
+ if (!be(d))
1180
1189
  throw e.error("Mount failed: container is not valid HTMLElement", {
1181
1190
  containerSelector: l
1182
1191
  }), new Error("Container is not valid HTMLElement");
1183
1192
  y = d;
1184
1193
  let v = d.shadowRoot;
1185
1194
  v || (b(), v = d.attachShadow({ mode: "open" }), n && (e.debug("Styles overrided", { styleOverrides: n }), B(n, d))), e.debug("Shadow root attached"), g() && (e.debug("Remount requested; unmounting first", { containerSelector: l }), h()), b();
1186
- const A = await Z(s);
1195
+ const A = await G(s);
1187
1196
  b(), i = await A.default(
1188
1197
  v,
1189
1198
  { ...a, logger: e.namespace(`module-${l}`), eventChannel: r },
@@ -1219,7 +1228,7 @@ const ce = (e) => {
1219
1228
  update: L(S, g, e),
1220
1229
  on: r.on
1221
1230
  };
1222
- }, ve = () => {
1231
+ }, he = () => {
1223
1232
  const e = {};
1224
1233
  return {
1225
1234
  emit: (r, ...a) => {
@@ -1253,6 +1262,11 @@ const ce = (e) => {
1253
1262
  freeShippingIndicator: {
1254
1263
  status: "inactive"
1255
1264
  },
1265
+ postalCode: {
1266
+ status: "inactive",
1267
+ open: !0,
1268
+ postalCode: ""
1269
+ },
1256
1270
  tracking: {
1257
1271
  status: "inactive"
1258
1272
  }
@@ -1260,7 +1274,7 @@ const ce = (e) => {
1260
1274
  k.countrySelector
1261
1275
  ), M = f(
1262
1276
  k.freeShippingIndicator
1263
- ), U = f(k.delivery), N = f(k.tracking), z = (e) => {
1277
+ ), U = f(k.delivery), N = f(k.postalCode), V = f(k.tracking), z = (e) => {
1264
1278
  const r = e.type, a = k[r], o = { status: "active" };
1265
1279
  switch (e.type) {
1266
1280
  case "address":
@@ -1279,12 +1293,14 @@ const ce = (e) => {
1279
1293
  return { ...a, ...o };
1280
1294
  case "freeShippingIndicator":
1281
1295
  return { ...a, ...o };
1296
+ case "postalCode":
1297
+ return { ...a, ...o };
1282
1298
  case "tracking":
1283
1299
  return { ...a, ...o };
1284
1300
  default:
1285
1301
  throw new Error("Unrecognized molecule");
1286
1302
  }
1287
- }, he = (e, r) => {
1303
+ }, we = (e, r) => {
1288
1304
  for (const a of e)
1289
1305
  switch (a.type) {
1290
1306
  case "address":
@@ -1299,9 +1315,12 @@ const ce = (e) => {
1299
1315
  case "freeShippingIndicator":
1300
1316
  r.set(M, z(a));
1301
1317
  break;
1302
- case "tracking":
1318
+ case "postalCode":
1303
1319
  r.set(N, z(a));
1304
1320
  break;
1321
+ case "tracking":
1322
+ r.set(V, z(a));
1323
+ break;
1305
1324
  default:
1306
1325
  throw new Error("Unrecognized molecule");
1307
1326
  }
@@ -1310,9 +1329,10 @@ const ce = (e) => {
1310
1329
  countrySelector: I,
1311
1330
  delivery: U,
1312
1331
  freeShippingIndicator: M,
1313
- tracking: N
1332
+ postalCode: N,
1333
+ tracking: V
1314
1334
  };
1315
- }, we = {
1335
+ }, ke = {
1316
1336
  lastTime: null,
1317
1337
  log(e) {
1318
1338
  const r = this.lastTime ? e.timestamp - this.lastTime : 0, o = `${e.namespace ? `[${e.namespace}]` : ""} [${e.level}]`, s = e.messageArgs ?? [];
@@ -1322,10 +1342,10 @@ const ce = (e) => {
1322
1342
  "color: #888"
1323
1343
  ), this.lastTime = e.timestamp;
1324
1344
  }
1325
- }, ke = (e) => e instanceof Error ? {
1345
+ }, ze = (e) => e instanceof Error ? {
1326
1346
  message: e.stack ?? e.message ?? String(e),
1327
1347
  error: e
1328
- } : { message: String(e) }, O = (e) => {
1348
+ } : { message: String(e) }, R = (e) => {
1329
1349
  const r = D.warn, a = (o) => (s, ...n) => {
1330
1350
  if (D[o] > r)
1331
1351
  return;
@@ -1333,7 +1353,7 @@ const ce = (e) => {
1333
1353
  level: o,
1334
1354
  namespace: e.namespace,
1335
1355
  timestamp: Date.now(),
1336
- ...ke(s),
1356
+ ...ze(s),
1337
1357
  messageArgs: n
1338
1358
  };
1339
1359
  for (const [g, m] of e.transports.entries())
@@ -1348,22 +1368,22 @@ const ce = (e) => {
1348
1368
  info: a("info"),
1349
1369
  warn: a("warn"),
1350
1370
  error: a("error"),
1351
- namespace: (o) => O({
1371
+ namespace: (o) => R({
1352
1372
  ...e,
1353
1373
  namespace: e.namespace ? `${e.namespace}:${o}` : o
1354
1374
  })
1355
1375
  };
1356
- }, ze = new V({
1376
+ }, je = new q({
1357
1377
  defaultOptions: {
1358
1378
  queries: {
1359
1379
  refetchOnWindowFocus: !1
1360
1380
  }
1361
1381
  }
1362
- }), q = "en-US", j = O({
1382
+ }), W = "en-US", j = R({
1363
1383
  level: "debug",
1364
1384
  namespace: "experience-kit",
1365
- transports: [we]
1366
- }), Te = {
1385
+ transports: [ke]
1386
+ }), Le = {
1367
1387
  /**
1368
1388
  * Initializes the Ingrid Experience Kit.
1369
1389
  *
@@ -1375,26 +1395,26 @@ const ce = (e) => {
1375
1395
  *
1376
1396
  * @public
1377
1397
  */
1378
- init: je
1398
+ init: Se
1379
1399
  };
1380
- async function je(e) {
1400
+ async function Se(e) {
1381
1401
  if (!e.siteId)
1382
1402
  throw new Error("[Experience Kit] siteId is required");
1383
- const r = te(e.env ?? "production"), a = await oe({
1403
+ const r = ae(e.env ?? "production"), a = await se({
1384
1404
  moleculesUrl: r,
1385
1405
  logger: j
1386
1406
  });
1387
1407
  if (!a)
1388
1408
  throw j.error("Failed to fetch release index, aborting initialization"), new Error("[Experience Kit][FATAL] Failed to fetch release index");
1389
- const o = await Y({
1409
+ const o = await X({
1390
1410
  token: e.token,
1391
- initUrl: `${r}/${ee(a)}/init.js`,
1411
+ initUrl: `${r}/${re(a)}/init.js`,
1392
1412
  siteId: e.siteId
1393
1413
  });
1394
- _e();
1395
- const s = ye(e.env), n = R(), i = ve(), g = he(e.molecules, n), m = f(e.locale), y = f(e.countryCode), h = f(e.currency), S = f(void 0), E = await pe(s, j), l = n.get(m), w = await X(l), _ = {
1396
- queryClient: { ref: ze }
1397
- }, p = ge(E, e.dataProviders?.services ?? {});
1414
+ fe();
1415
+ const s = _e(e.env), n = $(), i = he(), g = we(e.molecules, n), m = f(e.locale), y = f(e.countryCode), h = f(e.currency), S = f(void 0), E = await ge(s, j), l = n.get(m), w = await ee(l), _ = {
1416
+ queryClient: { ref: je }
1417
+ }, p = ye(E, e.dataProviders?.services ?? {});
1398
1418
  p.translations.registerTranslations(l, "default", w);
1399
1419
  const b = {
1400
1420
  token: e.token,
@@ -1417,9 +1437,9 @@ async function je(e) {
1417
1437
  eventChannel: i
1418
1438
  };
1419
1439
  return {
1420
- compound: be(b, e.molecules, o.initUrl, e.styles),
1440
+ compound: ve(b, e.molecules, o.initUrl, e.styles),
1421
1441
  setLocale: (d) => {
1422
- P.includes(d) || (j.warn(`Locale ${d} is not supported. Fallbacks to ${q}`), d = q), n.set(m, d);
1442
+ C.includes(d) || (j.warn(`Locale ${d} is not supported. Fallbacks to ${W}`), d = W), n.set(m, d);
1423
1443
  },
1424
1444
  setPurchaseCountry: (d) => {
1425
1445
  n.set(y, d);
@@ -1434,7 +1454,7 @@ async function je(e) {
1434
1454
  };
1435
1455
  }
1436
1456
  export {
1437
- xe as createAddressMolecule,
1438
- Te as default,
1439
- De as withDefaultProvider
1457
+ De as createAddressMolecule,
1458
+ Le as default,
1459
+ Te as withDefaultProvider
1440
1460
  };
@@ -122,6 +122,7 @@ export declare const createDeliveryMolecule: ({ mode, name, customization, }: Mo
122
122
  gaplessAddonsList?: boolean;
123
123
  gaplessCarrierList?: boolean;
124
124
  gaplessDeliveryList?: boolean;
125
+ gaplessDeliveryTimeList?: boolean;
125
126
  labels?: "off" | "chips" | "text";
126
127
  showAddons?: boolean;
127
128
  showCustomInfoText?: boolean;
@@ -132,13 +133,15 @@ export declare const createDeliveryMolecule: ({ mode, name, customization, }: Mo
132
133
  showPrice?: boolean;
133
134
  showRadioIndicator?: boolean;
134
135
  showReturnPromise?: boolean;
135
- showShippingLogo?: boolean;
136
+ showCarrierLogo?: boolean;
137
+ showCarrierName?: boolean;
136
138
  showDeliveryTime?: boolean;
137
139
  showLocationSection?: boolean;
138
140
  showLocationAddress?: boolean;
139
141
  showLocationCarrierName?: boolean;
140
142
  showLocationType?: boolean;
141
143
  categoryLabel?: "name" | "type";
144
+ deliveryTime?: "off" | "inline" | "popup";
142
145
  };
143
146
  location?: {
144
147
  gaplessList?: boolean;
@@ -217,6 +220,35 @@ export declare const createFreeShippingIndicatorMolecule: ({ name, customization
217
220
  };
218
221
  };
219
222
 
223
+ /**
224
+ * UNSTABLE - DO NOT USE
225
+ *
226
+ * Creates a molecule configuration for the postal code particle.
227
+ *
228
+ * Renders a postal code input that lets the shopper provide the postal code used
229
+ * to resolve available delivery options.
230
+ *
231
+ * @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * const instance = await ingrid.init({
236
+ * token: 'your-auth-token',
237
+ * siteId: 'your-site-id',
238
+ * locale: 'en-US',
239
+ * countryCode: 'US',
240
+ * currency: 'USD',
241
+ * molecules: [
242
+ * createPostalCodeMolecule(),
243
+ * ],
244
+ * });
245
+ * ```
246
+ */
247
+ export declare const createPostalCodeMolecule: () => {
248
+ type: "postalCode";
249
+ params: {};
250
+ };
251
+
220
252
  declare type DeliveryMoleculeParams = {
221
253
  mode: 'active' | 'passive';
222
254
  name: string;
@@ -226,6 +258,7 @@ declare type DeliveryMoleculeParams = {
226
258
  gaplessAddonsList?: boolean;
227
259
  gaplessCarrierList?: boolean;
228
260
  gaplessDeliveryList?: boolean;
261
+ gaplessDeliveryTimeList?: boolean;
229
262
  labels?: 'off' | 'chips' | 'text';
230
263
  showAddons?: boolean;
231
264
  showCustomInfoText?: boolean;
@@ -236,13 +269,15 @@ declare type DeliveryMoleculeParams = {
236
269
  showPrice?: boolean;
237
270
  showRadioIndicator?: boolean;
238
271
  showReturnPromise?: boolean;
239
- showShippingLogo?: boolean;
272
+ showCarrierLogo?: boolean;
273
+ showCarrierName?: boolean;
240
274
  showDeliveryTime?: boolean;
241
275
  showLocationSection?: boolean;
242
276
  showLocationAddress?: boolean;
243
277
  showLocationCarrierName?: boolean;
244
278
  showLocationType?: boolean;
245
279
  categoryLabel?: 'name' | 'type';
280
+ deliveryTime?: 'off' | 'inline' | 'popup';
246
281
  };
247
282
  location?: {
248
283
  gaplessList?: boolean;
@@ -294,9 +329,15 @@ declare type MoleculeParamsMap = {
294
329
  countrySelector: CountrySelectorParams;
295
330
  delivery: DeliveryMoleculeParams;
296
331
  freeShippingIndicator: FreeShippingIndicatorParams;
332
+ postalCode: PostalCodeParams;
297
333
  tracking: TrackingNumberParams;
298
334
  };
299
335
 
336
+ declare type PostalCodeParams = {
337
+ // No customization flags yet
338
+ customization?: Record<never, never>;
339
+ };
340
+
300
341
  declare type TrackingNumberParams = {
301
342
  parcelIndex: string;
302
343
  customization?: Record<never, never>;
package/dist/internal.js CHANGED
@@ -1,35 +1,39 @@
1
- const c = ({
1
+ const r = ({
2
2
  mode: e,
3
- name: r
3
+ name: t
4
4
  }) => ({
5
5
  type: "countrySelector",
6
6
  params: {
7
7
  mode: e,
8
- name: r
8
+ name: t
9
9
  }
10
- }), o = ({
10
+ }), c = ({
11
11
  mode: e,
12
- name: r,
13
- customization: t
12
+ name: t,
13
+ customization: o
14
14
  }) => ({
15
15
  type: "delivery",
16
- customization: t,
16
+ customization: o,
17
17
  params: {
18
18
  mode: e,
19
- name: r
19
+ name: t
20
20
  }
21
21
  }), a = ({
22
22
  name: e,
23
- customization: r
23
+ customization: t
24
24
  }) => ({
25
25
  type: "freeShippingIndicator",
26
- customization: r,
26
+ customization: t,
27
27
  params: {
28
28
  name: e
29
29
  }
30
+ }), l = () => ({
31
+ type: "postalCode",
32
+ params: {}
30
33
  });
31
34
  export {
32
- c as createCountrySelectorMolecule,
33
- o as createDeliveryMolecule,
34
- a as createFreeShippingIndicatorMolecule
35
+ r as createCountrySelectorMolecule,
36
+ c as createDeliveryMolecule,
37
+ a as createFreeShippingIndicatorMolecule,
38
+ l as createPostalCodeMolecule
35
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ingridab/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -33,12 +33,13 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@tanstack/query-core": "^5.100.14",
36
- "jotai": "^2.13.1",
37
36
  "axios": "^1.16.1",
38
37
  "i18next": "^25.5.2",
38
+ "jotai": "^2.13.1",
39
39
  "zod": "^3.24.1"
40
40
  },
41
41
  "devDependencies": {
42
+ "@ingrid/third-party-notices": "0.0.0-b9145ca",
42
43
  "@microsoft/api-extractor": "7.58.0",
43
44
  "dotenv": "17.2.3",
44
45
  "jsdom": "24.1.3",
@@ -49,8 +50,8 @@
49
50
  "vite": "7.3.1",
50
51
  "vite-plugin-dts": "4.5.4",
51
52
  "vitest": "4.1.0",
52
- "@ingridab/api-types": "0.3.0",
53
- "@ingridab/bergman-system": "0.1.1",
53
+ "@ingridab/api-types": "0.4.0",
54
+ "@ingridab/bergman-system": "0.2.0",
54
55
  "@ingridab/config": "^0.0.0"
55
56
  },
56
57
  "scripts": {
package/dist/LICENSES.md DELETED
@@ -1,3 +0,0 @@
1
- # Licenses
2
-
3
- The app does not bundle any dependencies with licenses.