@ingridab/sdk 0.1.0 → 0.3.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.
@@ -0,0 +1,305 @@
1
+ /**
2
+ * Configuration params passed to the address molecule.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const params: AddressMoleculeParams = {
7
+ * mode: 'addressForm',
8
+ * customization: {
9
+ * addressBook: { displayMode: 'popup' },
10
+ * suggestions: { displayMode: 'inline' },
11
+ * },
12
+ * };
13
+ * ```
14
+ */
15
+ declare type AddressMoleculeParams = {
16
+ /** The rendering mode for the address molecule. Currently `'addressForm'` and `'searchDriven'` are supported. */
17
+ mode: 'addressForm' | 'searchDriven';
18
+ customization?: AddressMoleculePublicCustomization;
19
+ };
20
+
21
+ /**
22
+ * Customization flags - exposed to SDK consumers via {@link AddressMoleculeParams}.
23
+ */
24
+ declare type AddressMoleculePublicCustomization = {
25
+ /** Customization options for the address book picker. */
26
+ addressBook?: {
27
+ /**
28
+ * Controls how the address book is presented.
29
+ *
30
+ * @defaultValue `'off'`
31
+ */
32
+ displayMode?: 'off' | 'inline' | 'popup';
33
+ /**
34
+ * Controls how users select an address entry:
35
+ * `'radio'` renders a radio button on each entry, `'disabled'` hides it.
36
+ *
37
+ * @defaultValue `'radio'`
38
+ */
39
+ selectionControl?: 'radio' | 'disabled';
40
+ };
41
+ /** Customization options for address autocomplete suggestions. */
42
+ suggestions?: {
43
+ /**
44
+ * Controls how address suggestions are presented.
45
+ *
46
+ * @defaultValue `'popup'`
47
+ */
48
+ displayMode?: 'inline' | 'popup';
49
+ };
50
+ };
51
+
52
+ declare type CountrySelectorParams = {
53
+ mode: 'select';
54
+ name: string;
55
+ customization?: Record<never, never>;
56
+ };
57
+
58
+ /**
59
+ * UNSTABLE - DO NOT USE
60
+ *
61
+ * Creates a molecule configuration for the country selector particle.
62
+ *
63
+ * Renders a country picker that allows the shopper to select their delivery country.
64
+ * Changing the country refreshes available delivery options.
65
+ *
66
+ * @param params - Configuration for the country selector particle. See `CountrySelectorParams`.
67
+ * @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const instance = await ingrid.init({
72
+ * token: 'your-auth-token',
73
+ * siteId: 'your-site-id',
74
+ * locale: 'en-US',
75
+ * countryCode: 'US',
76
+ * currency: 'USD',
77
+ * molecules: [
78
+ * createCountrySelectorMolecule({ mode: 'select', name: 'country-picker' }),
79
+ * ],
80
+ * });
81
+ * ```
82
+ */
83
+ export declare const createCountrySelectorMolecule: ({ mode, name, }: MoleculeParamsMap["countrySelector"]) => {
84
+ type: "countrySelector";
85
+ params: {
86
+ mode: "select";
87
+ name: string;
88
+ };
89
+ };
90
+
91
+ /**
92
+ * UNSTABLE - DO NOT USE
93
+ *
94
+ * Creates a molecule configuration for the delivery particle.
95
+ *
96
+ * Renders a delivery options selector where the shopper can browse and choose a shipping method.
97
+ * Use `mode: 'active'` for a checkout flow where the shopper makes a selection, and
98
+ * `mode: 'passive'` for a read-only summary display.
99
+ *
100
+ * @param params - Configuration for the delivery particle. See `DeliveryMoleculeParams`.
101
+ * @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * const instance = await ingrid.init({
106
+ * token: 'your-auth-token',
107
+ * siteId: 'your-site-id',
108
+ * locale: 'en-US',
109
+ * countryCode: 'US',
110
+ * currency: 'USD',
111
+ * molecules: [
112
+ * createDeliveryMolecule({ mode: 'active', name: 'main-delivery' }),
113
+ * ],
114
+ * });
115
+ * ```
116
+ */
117
+ export declare const createDeliveryMolecule: ({ mode, name, customization, }: MoleculeParamsMap["delivery"]) => {
118
+ type: "delivery";
119
+ customization: {
120
+ choice?: {
121
+ carrierInstructions?: "off" | "inline" | "popup";
122
+ gaplessAddonsList?: boolean;
123
+ gaplessCarrierList?: boolean;
124
+ gaplessDeliveryList?: boolean;
125
+ labels?: "off" | "chips" | "text";
126
+ showAddons?: boolean;
127
+ showCustomInfoText?: boolean;
128
+ showCustomText?: boolean;
129
+ showDiscountedPrice?: boolean;
130
+ zeroPriceDisplay?: "free" | "0";
131
+ showFreeShippingIndicator?: boolean;
132
+ showPrice?: boolean;
133
+ showRadioIndicator?: boolean;
134
+ showReturnPromise?: boolean;
135
+ showShippingLogo?: boolean;
136
+ showDeliveryTime?: boolean;
137
+ showLocationSection?: boolean;
138
+ showLocationAddress?: boolean;
139
+ showLocationCarrierName?: boolean;
140
+ showLocationType?: boolean;
141
+ categoryLabel?: "name" | "type";
142
+ };
143
+ location?: {
144
+ gaplessList?: boolean;
145
+ mapDefaultVisible?: boolean;
146
+ mapDefaultZoom?: number;
147
+ mapFitboundsMaxZoom?: number;
148
+ mapPosition?: "start" | "end";
149
+ mapToggleEnabled?: boolean;
150
+ zeroPriceDisplay?: "free" | "0";
151
+ displayMode?: "popup" | "inline";
152
+ selectionControl?: "radio" | "disabled";
153
+ selectionAlignment?: "left" | "right";
154
+ showLocationAddress?: boolean;
155
+ showCarrierName?: boolean;
156
+ showLocationType?: boolean;
157
+ showOpeningHours?: boolean;
158
+ showPrice?: boolean;
159
+ };
160
+ productList?: {
161
+ defaultView?: "off" | "list" | "summary";
162
+ showImage?: boolean;
163
+ showMetadata?: boolean;
164
+ showPrice?: boolean;
165
+ showQuantity?: boolean;
166
+ summaryText?: "none" | "products" | "firstProductAndMore";
167
+ zeroPriceDisplay?: "free" | "0";
168
+ };
169
+ summary?: {
170
+ previewAddons?: boolean;
171
+ showFreeShippingIndicator?: boolean;
172
+ showDiscountedPrice?: boolean;
173
+ zeroPriceDisplay?: "free" | "0";
174
+ categoryLabel?: "name" | "type";
175
+ };
176
+ } | undefined;
177
+ params: {
178
+ mode: "active" | "passive";
179
+ name: string;
180
+ };
181
+ };
182
+
183
+ /**
184
+ * UNSTABLE - DO NOT USE
185
+ *
186
+ * Creates a molecule configuration for the free shipping indicator particle.
187
+ *
188
+ * Renders a progress bar or message showing how close the shopper is to qualifying
189
+ * for free shipping. Pair it with a delivery molecule that has `showFreeShippingIndicator`
190
+ * enabled, or use it standalone via the `deliveryId` param.
191
+ *
192
+ * @param params - Configuration for the free shipping indicator particle. See `FreeShippingIndicatorParams`.
193
+ * @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const instance = await ingrid.init({
198
+ * token: 'your-auth-token',
199
+ * siteId: 'your-site-id',
200
+ * locale: 'en-US',
201
+ * countryCode: 'US',
202
+ * currency: 'USD',
203
+ * molecules: [
204
+ * createFreeShippingIndicatorMolecule({ name: 'free-shipping' }),
205
+ * ],
206
+ * });
207
+ * ```
208
+ */
209
+ export declare const createFreeShippingIndicatorMolecule: ({ name, customization, }: MoleculeParamsMap["freeShippingIndicator"]) => {
210
+ type: "freeShippingIndicator";
211
+ customization: {
212
+ showExhaustedLevelsMessage?: boolean;
213
+ zeroPriceDisplay?: "free" | "0";
214
+ } | undefined;
215
+ params: {
216
+ name: string;
217
+ };
218
+ };
219
+
220
+ declare type DeliveryMoleculeParams = {
221
+ mode: 'active' | 'passive';
222
+ name: string;
223
+ customization?: {
224
+ choice?: {
225
+ carrierInstructions?: 'off' | 'inline' | 'popup';
226
+ gaplessAddonsList?: boolean;
227
+ gaplessCarrierList?: boolean;
228
+ gaplessDeliveryList?: boolean;
229
+ labels?: 'off' | 'chips' | 'text';
230
+ showAddons?: boolean;
231
+ showCustomInfoText?: boolean;
232
+ showCustomText?: boolean;
233
+ showDiscountedPrice?: boolean;
234
+ zeroPriceDisplay?: 'free' | '0';
235
+ showFreeShippingIndicator?: boolean;
236
+ showPrice?: boolean;
237
+ showRadioIndicator?: boolean;
238
+ showReturnPromise?: boolean;
239
+ showShippingLogo?: boolean;
240
+ showDeliveryTime?: boolean;
241
+ showLocationSection?: boolean;
242
+ showLocationAddress?: boolean;
243
+ showLocationCarrierName?: boolean;
244
+ showLocationType?: boolean;
245
+ categoryLabel?: 'name' | 'type';
246
+ };
247
+ location?: {
248
+ gaplessList?: boolean;
249
+ mapDefaultVisible?: boolean;
250
+ mapDefaultZoom?: number;
251
+ mapFitboundsMaxZoom?: number;
252
+ mapPosition?: 'start' | 'end';
253
+ mapToggleEnabled?: boolean;
254
+ zeroPriceDisplay?: 'free' | '0';
255
+ displayMode?: 'popup' | 'inline';
256
+ selectionControl?: 'radio' | 'disabled';
257
+ selectionAlignment?: 'left' | 'right';
258
+ showLocationAddress?: boolean;
259
+ showCarrierName?: boolean;
260
+ showLocationType?: boolean;
261
+ showOpeningHours?: boolean;
262
+ showPrice?: boolean;
263
+ };
264
+ productList?: {
265
+ defaultView?: 'off' | 'list' | 'summary';
266
+ showImage?: boolean;
267
+ showMetadata?: boolean;
268
+ showPrice?: boolean;
269
+ showQuantity?: boolean;
270
+ summaryText?: 'none' | 'products' | 'firstProductAndMore';
271
+ zeroPriceDisplay?: 'free' | '0';
272
+ };
273
+ summary?: {
274
+ previewAddons?: boolean;
275
+ showFreeShippingIndicator?: boolean;
276
+ showDiscountedPrice?: boolean;
277
+ zeroPriceDisplay?: 'free' | '0';
278
+ categoryLabel?: 'name' | 'type';
279
+ };
280
+ };
281
+ };
282
+
283
+ declare type FreeShippingIndicatorParams = {
284
+ name: string;
285
+ deliveryId?: string;
286
+ customization?: {
287
+ showExhaustedLevelsMessage?: boolean;
288
+ zeroPriceDisplay?: 'free' | '0';
289
+ };
290
+ };
291
+
292
+ declare type MoleculeParamsMap = {
293
+ address: AddressMoleculeParams;
294
+ countrySelector: CountrySelectorParams;
295
+ delivery: DeliveryMoleculeParams;
296
+ freeShippingIndicator: FreeShippingIndicatorParams;
297
+ tracking: TrackingNumberParams;
298
+ };
299
+
300
+ declare type TrackingNumberParams = {
301
+ parcelIndex: string;
302
+ customization?: Record<never, never>;
303
+ };
304
+
305
+ export { }
@@ -0,0 +1,35 @@
1
+ const c = ({
2
+ mode: e,
3
+ name: r
4
+ }) => ({
5
+ type: "countrySelector",
6
+ params: {
7
+ mode: e,
8
+ name: r
9
+ }
10
+ }), o = ({
11
+ mode: e,
12
+ name: r,
13
+ customization: t
14
+ }) => ({
15
+ type: "delivery",
16
+ customization: t,
17
+ params: {
18
+ mode: e,
19
+ name: r
20
+ }
21
+ }), a = ({
22
+ name: e,
23
+ customization: r
24
+ }) => ({
25
+ type: "freeShippingIndicator",
26
+ customization: r,
27
+ params: {
28
+ name: e
29
+ }
30
+ });
31
+ export {
32
+ c as createCountrySelectorMolecule,
33
+ o as createDeliveryMolecule,
34
+ a as createFreeShippingIndicatorMolecule
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ingridab/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,13 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "default": "./dist/index.js"
15
15
  }
16
+ },
17
+ "./internal": {
18
+ "import": {
19
+ "source": "./lib/internal.ts",
20
+ "types": "./dist/internal.d.ts",
21
+ "default": "./dist/internal.js"
22
+ }
16
23
  }
17
24
  },
18
25
  "files": [
@@ -21,15 +28,15 @@
21
28
  "README.md"
22
29
  ],
23
30
  "publishConfig": {
24
- "access": "restricted",
31
+ "access": "public",
25
32
  "registry": "https://registry.npmjs.org"
26
33
  },
27
34
  "dependencies": {
28
- "@tanstack/react-query": "5.55.0",
29
- "jotai": "2.13.1",
30
- "axios": "1.16.1",
31
- "i18next": "25.5.2",
32
- "zod": "3.24.1"
35
+ "@tanstack/query-core": "^5.100.14",
36
+ "jotai": "^2.13.1",
37
+ "axios": "^1.16.1",
38
+ "i18next": "^25.5.2",
39
+ "zod": "^3.24.1"
33
40
  },
34
41
  "devDependencies": {
35
42
  "@microsoft/api-extractor": "7.58.0",
@@ -37,14 +44,14 @@
37
44
  "jsdom": "24.1.3",
38
45
  "swagger-typescript-api": "13.6.0",
39
46
  "tsx": "4.21.0",
40
- "typedoc": "0.27.0",
41
- "typedoc-plugin-markdown": "4.3.0",
47
+ "typedoc": "0.28.19",
48
+ "typedoc-plugin-markdown": "4.11.0",
42
49
  "vite": "7.3.1",
43
50
  "vite-plugin-dts": "4.5.4",
44
- "vitest": "4.0.18",
45
- "@ingridab/api-types": "0.1.0",
46
- "@ingridab/config": "^0.0.0",
47
- "@ingridab/bergman-system": "0.1.0"
51
+ "vitest": "4.1.0",
52
+ "@ingridab/api-types": "0.3.0",
53
+ "@ingridab/bergman-system": "0.1.1",
54
+ "@ingridab/config": "^0.0.0"
48
55
  },
49
56
  "scripts": {
50
57
  "dev": "vite",