@ingridab/sdk 0.1.0-alpha.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/dist/LICENSES.md +37 -0
- package/dist/index.d.ts +610 -514
- package/dist/index.js +2514 -2470
- package/package.json +8 -4
package/dist/index.d.ts
CHANGED
|
@@ -138,87 +138,6 @@ declare type Address_2 = {
|
|
|
138
138
|
type?: AddressType;
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
* @description Represents an address suitable for delivery.
|
|
143
|
-
*/
|
|
144
|
-
declare type AddressAddress = {
|
|
145
|
-
/**
|
|
146
|
-
* @description \nRefers to a ISO-3166 alpha 2 country code.
|
|
147
|
-
* @type string
|
|
148
|
-
*/
|
|
149
|
-
country_code: string;
|
|
150
|
-
/**
|
|
151
|
-
* @description Refers to a first-level administrative subdivision code (ISO-3166-2) without the country_code prefix.\nExample: region for Washington, D.C. = `DC` (from `US-DC`).\nException: for some countries (e.g. Mexico, Hong Kong) we store the subdivision name instead.\nExample: region for Hong Kong = `Kowloon`.
|
|
152
|
-
* @type string | undefined
|
|
153
|
-
*/
|
|
154
|
-
region_code?: string;
|
|
155
|
-
/**
|
|
156
|
-
* @description Refers to a second-level administrative subdivision below the region (ISO-3166-2), without the country_code prefix.\nExample: region for Washington State = `WA` (from `US-WA`), subregion for King County = `033` (from `US-WA-033`).\nException: for some countries (e.g. Mexico, Hong Kong) we store the subdivision name instead.\nExample: subregion within Hong Kong/Kowloon = `Tsim Sha Tsui`.
|
|
157
|
-
* @type string | undefined
|
|
158
|
-
*/
|
|
159
|
-
subregion_code?: string;
|
|
160
|
-
/**
|
|
161
|
-
* @description Refers to a postal code or zipcode.
|
|
162
|
-
* @type string | undefined
|
|
163
|
-
*/
|
|
164
|
-
postal_code?: string;
|
|
165
|
-
/**
|
|
166
|
-
* @description Refers to a city, postal_town or locality.
|
|
167
|
-
* @type string | undefined
|
|
168
|
-
*/
|
|
169
|
-
city?: string;
|
|
170
|
-
/**
|
|
171
|
-
* @description List of strings, each a part of the address, e.g., street name, street number, building name, floor.
|
|
172
|
-
* @type array | undefined
|
|
173
|
-
*/
|
|
174
|
-
address_lines?: string[];
|
|
175
|
-
/**
|
|
176
|
-
* @description Street name of the address.
|
|
177
|
-
* @type string | undefined
|
|
178
|
-
*/
|
|
179
|
-
street?: string;
|
|
180
|
-
/**
|
|
181
|
-
* @description Street number of the address.
|
|
182
|
-
* @type string | undefined
|
|
183
|
-
*/
|
|
184
|
-
street_number?: string;
|
|
185
|
-
/**
|
|
186
|
-
* @description Apartment number of the address.
|
|
187
|
-
* @type string | undefined
|
|
188
|
-
*/
|
|
189
|
-
apartment_number?: string;
|
|
190
|
-
/**
|
|
191
|
-
* @description Building name of the address.
|
|
192
|
-
* @type string | undefined
|
|
193
|
-
*/
|
|
194
|
-
building_name?: string;
|
|
195
|
-
/**
|
|
196
|
-
* @description Floor number of the address.
|
|
197
|
-
* @type string | undefined
|
|
198
|
-
*/
|
|
199
|
-
floor_number?: string;
|
|
200
|
-
/**
|
|
201
|
-
* @description PO Box identifier of the address.
|
|
202
|
-
* @type string | undefined
|
|
203
|
-
*/
|
|
204
|
-
po_box_id?: string;
|
|
205
|
-
/**
|
|
206
|
-
* @description Full name associated with the address, for example company name.
|
|
207
|
-
* @type string | undefined
|
|
208
|
-
*/
|
|
209
|
-
name?: string;
|
|
210
|
-
/**
|
|
211
|
-
* @description Care of information associated with the address.
|
|
212
|
-
* @type string | undefined
|
|
213
|
-
*/
|
|
214
|
-
care_of?: string;
|
|
215
|
-
/**
|
|
216
|
-
* @description Represents a latitude/longitude pair.\nUnless specified otherwise, this must conform to the WGS84 standard.\nValues must be within normalized ranges.
|
|
217
|
-
* @type object | undefined
|
|
218
|
-
*/
|
|
219
|
-
coordinates?: AddressCoordinates;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
141
|
/**
|
|
223
142
|
* @description Types of modifications the validation API made to the original address.
|
|
224
143
|
*/
|
|
@@ -231,23 +150,42 @@ declare type AddressChangeEnum =
|
|
|
231
150
|
| 'componentsAdded'
|
|
232
151
|
| 'componentsRemoved';
|
|
233
152
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
153
|
+
declare type AddressContactEntry = {
|
|
154
|
+
/** The unique identifier of the contact entry. */
|
|
155
|
+
id?: string;
|
|
156
|
+
|
|
157
|
+
/** The name of the contact person. */
|
|
158
|
+
recipientName?: string;
|
|
159
|
+
|
|
160
|
+
/** The company name associated with the contact. */
|
|
161
|
+
companyName?: string;
|
|
162
|
+
|
|
163
|
+
/** The address of the contact. */
|
|
164
|
+
address?: Address_2;
|
|
165
|
+
|
|
166
|
+
/** The email address of the contact. */
|
|
167
|
+
email?: string;
|
|
168
|
+
|
|
169
|
+
/** The VAT number associated with the contact. */
|
|
170
|
+
vatNumber?: string;
|
|
171
|
+
|
|
172
|
+
/** The VAT type associated with the vat number, e.g. "SE_EU" or "GB_VAT" */
|
|
173
|
+
vatType?: string;
|
|
174
|
+
|
|
175
|
+
/** A phone number in E164 format, e.g. "+1234567890" */
|
|
176
|
+
phoneNumber?: string;
|
|
177
|
+
|
|
178
|
+
/** Additional form values associated with the contact */
|
|
179
|
+
additionalFormValues?: AddressContactEntryAdditionalFormValue[];
|
|
248
180
|
};
|
|
249
181
|
|
|
250
|
-
declare type
|
|
182
|
+
declare type AddressContactEntryAdditionalFormValue = {
|
|
183
|
+
/** The key under which the value is stored. Can be referenced in the form configuration */
|
|
184
|
+
formFieldKey: string;
|
|
185
|
+
|
|
186
|
+
/** The value of the form field. */
|
|
187
|
+
value: string;
|
|
188
|
+
};
|
|
251
189
|
|
|
252
190
|
/**
|
|
253
191
|
* @description Response containing the full address resolved from a prediction ID.
|
|
@@ -259,161 +197,106 @@ declare type AddressDetailsResponse = {
|
|
|
259
197
|
address: Address_2;
|
|
260
198
|
};
|
|
261
199
|
|
|
262
|
-
declare type AddressParticleInputState = DeepPartial<V1AlphaAddressContact>;
|
|
263
|
-
|
|
264
|
-
declare type AddressParticleParams = {
|
|
265
|
-
mode: 'postalCode' | 'addressForm';
|
|
266
|
-
prefillAddress?: RecipientContact;
|
|
267
|
-
customization?: {
|
|
268
|
-
address?: { vatTypes?: string[] };
|
|
269
|
-
addressBook?: { displayMode?: 'off' | 'inline' | 'popup' };
|
|
270
|
-
suggestions?: { displayMode?: 'inline' | 'popup' };
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
declare const addressParticleParamsValidator = z.object({
|
|
275
|
-
mode: z.enum(['postalCode', 'addressForm']),
|
|
276
|
-
prefillAddress: recipientContactValidator.optional(),
|
|
277
|
-
customization: z
|
|
278
|
-
.object({
|
|
279
|
-
address: z
|
|
280
|
-
.object({
|
|
281
|
-
vatTypes: z.array(z.string()).optional(), // TODO: TBD - we'll probably need multiselect input to handle this in the Playground
|
|
282
|
-
})
|
|
283
|
-
.optional(),
|
|
284
|
-
addressBook: z
|
|
285
|
-
.object({
|
|
286
|
-
displayMode: z.enum(['off', 'inline', 'popup']).optional(),
|
|
287
|
-
})
|
|
288
|
-
.optional(),
|
|
289
|
-
suggestions: z
|
|
290
|
-
.object({
|
|
291
|
-
displayMode: z.enum(['inline', 'popup']).optional(),
|
|
292
|
-
})
|
|
293
|
-
.optional(),
|
|
294
|
-
})
|
|
295
|
-
.optional(),
|
|
296
|
-
}) satisfies z.ZodType<AddressParticleParams>;
|
|
297
|
-
|
|
298
|
-
declare type AddressPresetParams = Pick<ParticleParamsMap['address'], 'mode' | 'prefillAddress'>;
|
|
299
|
-
|
|
300
200
|
/**
|
|
301
|
-
* @description
|
|
201
|
+
* @description Response containing the complete form configuration for a localized address form.\nIncludes field definitions, validation rules, and visual layout instructions.
|
|
302
202
|
*/
|
|
303
|
-
declare type
|
|
304
|
-
|
|
305
|
-
declare type AddressServiceCreateContactPathParams = {
|
|
203
|
+
declare type AddressFormResponse = {
|
|
306
204
|
/**
|
|
307
|
-
* @description
|
|
308
|
-
* @pattern [^/]+
|
|
309
|
-
* @type string
|
|
205
|
+
* @description Metadata about the form configuration including locale and text direction.
|
|
310
206
|
*/
|
|
311
|
-
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @description A successful response.
|
|
316
|
-
*/
|
|
317
|
-
declare type AddressServiceDeleteContact200 = object;
|
|
318
|
-
|
|
319
|
-
declare type AddressServiceDeleteContactPathParams = {
|
|
207
|
+
meta: FormMeta;
|
|
320
208
|
/**
|
|
321
|
-
* @description
|
|
322
|
-
* @
|
|
323
|
-
* @type string
|
|
209
|
+
* @description Pre-filled values for the form fields.\nKeys correspond to the keys in the `fields` object.\nThis is often populated if a `postalCode` was sent in the request.
|
|
210
|
+
* @type object | undefined
|
|
324
211
|
*/
|
|
325
|
-
|
|
212
|
+
values?: object;
|
|
326
213
|
/**
|
|
327
|
-
* @description
|
|
328
|
-
* @
|
|
329
|
-
* @type string
|
|
214
|
+
* @description Dictionary defining the behavior of each input field.\nKeys are unique field identifiers (e.g., `postalCode`, `locality`).
|
|
215
|
+
* @type object
|
|
330
216
|
*/
|
|
331
|
-
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
declare type AddressServiceListContactsPathParams = {
|
|
217
|
+
fields: object;
|
|
335
218
|
/**
|
|
336
|
-
* @description
|
|
337
|
-
* @
|
|
338
|
-
* @type string
|
|
219
|
+
* @description Defines the visual grid of the form.\nClients should loop through this array to render the UI.\n- Outer array: Rows (stack vertically)\n- Inner array: Columns (stack horizontally / flex)
|
|
220
|
+
* @type array
|
|
339
221
|
*/
|
|
340
|
-
|
|
222
|
+
layout: string[][];
|
|
341
223
|
};
|
|
342
224
|
|
|
343
|
-
declare type
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
country_code?: string;
|
|
225
|
+
declare type AddressFormService = {
|
|
226
|
+
getAddressFormConfig: DataResolver<
|
|
227
|
+
{ params: GetAddressFormQuery['QueryParams']; token: string },
|
|
228
|
+
GetAddressFormQuery['Response']
|
|
229
|
+
>;
|
|
349
230
|
};
|
|
350
231
|
|
|
232
|
+
/* Excluded from this release type: AddressMoleculeCustomization */
|
|
233
|
+
|
|
234
|
+
declare type AddressMoleculeInputState = Partial<AddressContactEntry>;
|
|
235
|
+
|
|
351
236
|
/**
|
|
352
|
-
*
|
|
237
|
+
* Configuration params passed to the address molecule.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const params: AddressMoleculeParams = {
|
|
242
|
+
* mode: 'addressForm',
|
|
243
|
+
* customization: {
|
|
244
|
+
* addressBook: { displayMode: 'popup' },
|
|
245
|
+
* suggestions: { displayMode: 'inline' },
|
|
246
|
+
* },
|
|
247
|
+
* };
|
|
248
|
+
* ```
|
|
353
249
|
*/
|
|
354
|
-
declare type
|
|
355
|
-
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
*/
|
|
394
|
-
company_name?: string;
|
|
395
|
-
/**
|
|
396
|
-
* @description VAT number associated with the contact.
|
|
397
|
-
* @type string | undefined
|
|
398
|
-
*/
|
|
399
|
-
vat?: string;
|
|
400
|
-
/**
|
|
401
|
-
* @description Customs number associated with the contact.
|
|
402
|
-
* @type string | undefined
|
|
403
|
-
*/
|
|
404
|
-
customs_number?: string;
|
|
250
|
+
declare type AddressMoleculeParams = {
|
|
251
|
+
/** The rendering mode for the address molecule. Currently `'addressForm'` is supported. */
|
|
252
|
+
mode: 'addressForm';
|
|
253
|
+
customization?: AddressMoleculePublicCustomization;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/* Excluded from this release type: addressMoleculeParamsValidator */
|
|
257
|
+
|
|
258
|
+
/* Excluded from this release type: AddressMoleculePrivateCustomization */
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Customization flags - exposed to SDK consumers via {@link AddressMoleculeParams}.
|
|
262
|
+
*/
|
|
263
|
+
declare type AddressMoleculePublicCustomization = {
|
|
264
|
+
/** Customization options for the address book picker. */
|
|
265
|
+
addressBook?: {
|
|
266
|
+
/**
|
|
267
|
+
* Controls how the address book is presented.
|
|
268
|
+
*
|
|
269
|
+
* @defaultValue `'inline'`
|
|
270
|
+
*/
|
|
271
|
+
displayMode?: 'off' | 'inline' | 'popup';
|
|
272
|
+
/**
|
|
273
|
+
* Controls how users select an address entry:
|
|
274
|
+
* `'radio'` renders a radio button on each entry, `'disabled'` hides it.
|
|
275
|
+
*
|
|
276
|
+
* @defaultValue `'radio'`
|
|
277
|
+
*/
|
|
278
|
+
selectionControl?: 'radio' | 'disabled';
|
|
279
|
+
};
|
|
280
|
+
/** Customization options for address autocomplete suggestions. */
|
|
281
|
+
suggestions?: {
|
|
282
|
+
/**
|
|
283
|
+
* Controls how address suggestions are presented.
|
|
284
|
+
*
|
|
285
|
+
* @defaultValue `'popup'`
|
|
286
|
+
*/
|
|
287
|
+
displayMode?: 'inline' | 'popup';
|
|
288
|
+
};
|
|
405
289
|
};
|
|
406
290
|
|
|
407
291
|
declare type AddressSuggestionsService = {
|
|
408
292
|
list: DataResolver<
|
|
409
|
-
{ params: AutocompleteAddressQuery['QueryParams']; token: string
|
|
293
|
+
{ params: AutocompleteAddressQuery['QueryParams']; token: string },
|
|
410
294
|
AutocompleteAddressQuery['Response']
|
|
411
295
|
>;
|
|
412
296
|
resolve: DataResolver<
|
|
413
297
|
{
|
|
414
|
-
params: GetAddressDetailsQuery['PathParams'];
|
|
298
|
+
params: GetAddressDetailsQuery['PathParams'] & GetAddressDetailsQuery['QueryParams'];
|
|
415
299
|
token: string;
|
|
416
|
-
siteId: string;
|
|
417
300
|
},
|
|
418
301
|
GetAddressDetailsQuery['Response']
|
|
419
302
|
>;
|
|
@@ -425,7 +308,7 @@ declare type AddressTypeEnum = 'unknown' | 'residential' | 'commercial';
|
|
|
425
308
|
|
|
426
309
|
declare type AddressValidationService = {
|
|
427
310
|
validateAddress: DataResolver<
|
|
428
|
-
{ payload: ValidateAddressMutation['Request']; token: string
|
|
311
|
+
{ payload: ValidateAddressMutation['Request']; token: string },
|
|
429
312
|
ValidateAddressMutation['Response']
|
|
430
313
|
>;
|
|
431
314
|
};
|
|
@@ -676,6 +559,11 @@ declare type AutocompleteAddressQueryParams = {
|
|
|
676
559
|
* @type string
|
|
677
560
|
*/
|
|
678
561
|
countryCode: CountryCode;
|
|
562
|
+
/**
|
|
563
|
+
* @description Site identifier, referring to which site the autocompletion is performed for.
|
|
564
|
+
* @type string
|
|
565
|
+
*/
|
|
566
|
+
siteId: string;
|
|
679
567
|
/**
|
|
680
568
|
* @description The text typed by the user. Ignored if `containerId` is provided.
|
|
681
569
|
* @type string | undefined
|
|
@@ -716,10 +604,10 @@ declare type BaseKey<K> = K extends `${infer B}_${Intl.LDMLPluralRule}` ? B : K;
|
|
|
716
604
|
* as possible for MVP purposes
|
|
717
605
|
*/
|
|
718
606
|
|
|
719
|
-
declare type
|
|
607
|
+
declare type BaseMoleculeDef<K extends MoleculeType> = {
|
|
720
608
|
type: K;
|
|
721
|
-
customization?:
|
|
722
|
-
params:
|
|
609
|
+
customization?: DeepPartial<MoleculeCustomizationConfig<K>>;
|
|
610
|
+
params: MoleculeParamsMap[K];
|
|
723
611
|
};
|
|
724
612
|
|
|
725
613
|
/**
|
|
@@ -743,31 +631,13 @@ declare type ContactPhoneNumber = {
|
|
|
743
631
|
extension?: string;
|
|
744
632
|
};
|
|
745
633
|
|
|
746
|
-
/**
|
|
747
|
-
* @description A phone number, including region and optional extension.
|
|
748
|
-
*/
|
|
749
|
-
declare type ContactPhoneNumber_2 = {
|
|
750
|
-
/**
|
|
751
|
-
* @description \nThe country code where the delivery will occur (ISO 3166-1 alpha-2).
|
|
752
|
-
* @type string
|
|
753
|
-
*/
|
|
754
|
-
country_code: string;
|
|
755
|
-
/**
|
|
756
|
-
* @description The main phone number, formatted as per the region\'s conventions.
|
|
757
|
-
* @type string
|
|
758
|
-
*/
|
|
759
|
-
number: string;
|
|
760
|
-
/**
|
|
761
|
-
* @description An optional phone number extension.
|
|
762
|
-
* @type string | undefined
|
|
763
|
-
*/
|
|
764
|
-
extension?: string;
|
|
765
|
-
};
|
|
766
|
-
|
|
767
634
|
declare type ContactsService = {
|
|
768
635
|
listContactBookEntries: DataResolver<
|
|
769
636
|
{
|
|
770
|
-
params:
|
|
637
|
+
params: {
|
|
638
|
+
addressBookId: string;
|
|
639
|
+
countryCode?: string;
|
|
640
|
+
};
|
|
771
641
|
token: string;
|
|
772
642
|
},
|
|
773
643
|
{
|
|
@@ -776,24 +646,24 @@ declare type ContactsService = {
|
|
|
776
646
|
>;
|
|
777
647
|
getContactBookEntry: DataResolver<
|
|
778
648
|
{
|
|
779
|
-
params: {
|
|
649
|
+
params: { id: string; addressBookId: string };
|
|
780
650
|
token: string;
|
|
781
651
|
},
|
|
782
|
-
|
|
652
|
+
AddressContactEntry
|
|
783
653
|
>;
|
|
784
654
|
upsertContactBookEntry: DataResolver<
|
|
785
655
|
{
|
|
786
|
-
payload:
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
656
|
+
payload: AddressContactEntry;
|
|
657
|
+
params: {
|
|
658
|
+
addressBookId: string;
|
|
659
|
+
};
|
|
790
660
|
token: string;
|
|
791
661
|
},
|
|
792
|
-
|
|
662
|
+
AddressContactEntry
|
|
793
663
|
>;
|
|
794
664
|
deleteContactBookEntry: DataResolver<
|
|
795
|
-
{ params:
|
|
796
|
-
|
|
665
|
+
{ params: { addressBookId: string; id: string }; token: string },
|
|
666
|
+
object
|
|
797
667
|
>;
|
|
798
668
|
};
|
|
799
669
|
|
|
@@ -813,9 +683,11 @@ declare type Coordinates = {
|
|
|
813
683
|
*/
|
|
814
684
|
declare type CountryCode = string;
|
|
815
685
|
|
|
816
|
-
declare
|
|
817
|
-
|
|
818
|
-
|
|
686
|
+
declare const countrySelectorMoleculeParamsValidator = z.object({
|
|
687
|
+
mode: z.enum(['select']),
|
|
688
|
+
name: z.string(),
|
|
689
|
+
customization: z.object({}).optional(),
|
|
690
|
+
}) satisfies z.ZodType<CountrySelectorParams>;
|
|
819
691
|
|
|
820
692
|
declare type CountrySelectorParams = {
|
|
821
693
|
mode: 'select';
|
|
@@ -823,36 +695,62 @@ declare type CountrySelectorParams = {
|
|
|
823
695
|
customization?: Record<never, never>;
|
|
824
696
|
};
|
|
825
697
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
698
|
+
/**
|
|
699
|
+
* Creates a molecule configuration for the address particle.
|
|
700
|
+
*
|
|
701
|
+
* Renders an address form that collects and validates the shopper's shipping address.
|
|
702
|
+
*
|
|
703
|
+
* @param params - Configuration for the address particle. See `AddressParticleParams`.
|
|
704
|
+
* @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```ts
|
|
708
|
+
* const ingrid = await initIngrid({
|
|
709
|
+
* token: 'your-auth-token',
|
|
710
|
+
* siteId: 'your-site-id',
|
|
711
|
+
* locale: 'en-US',
|
|
712
|
+
* molecules: [
|
|
713
|
+
* createAddressMolecule({
|
|
714
|
+
* mode: 'addressForm'
|
|
715
|
+
* }),
|
|
716
|
+
* ],
|
|
717
|
+
* });
|
|
718
|
+
* ```
|
|
719
|
+
*
|
|
720
|
+
* @public
|
|
721
|
+
*/
|
|
722
|
+
export declare const createAddressMolecule: ({ mode, customization }: MoleculeParamsMap["address"]) => {
|
|
837
723
|
type: "address";
|
|
838
|
-
customization:
|
|
839
|
-
address?: {
|
|
840
|
-
vatTypes?: string[];
|
|
841
|
-
};
|
|
842
|
-
addressBook?: {
|
|
843
|
-
displayMode?: "off" | "inline" | "popup";
|
|
844
|
-
};
|
|
845
|
-
suggestions?: {
|
|
846
|
-
displayMode?: "inline" | "popup";
|
|
847
|
-
};
|
|
848
|
-
} | undefined;
|
|
724
|
+
customization: AddressMoleculePublicCustomization | undefined;
|
|
849
725
|
params: {
|
|
850
|
-
mode: "
|
|
851
|
-
prefillAddress: RecipientContact | undefined;
|
|
726
|
+
mode: "addressForm";
|
|
852
727
|
};
|
|
853
728
|
};
|
|
854
729
|
|
|
855
|
-
|
|
730
|
+
/**
|
|
731
|
+
* Creates a molecule configuration for the country selector particle.
|
|
732
|
+
*
|
|
733
|
+
* Renders a country picker that allows the shopper to select their delivery country.
|
|
734
|
+
* Changing the country refreshes available delivery options.
|
|
735
|
+
*
|
|
736
|
+
* @param params - Configuration for the country selector particle. See `CountrySelectorParams`.
|
|
737
|
+
* @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* ```ts
|
|
741
|
+
* const ingrid = await initIngrid({
|
|
742
|
+
* token: 'your-auth-token',
|
|
743
|
+
* siteId: 'your-site-id',
|
|
744
|
+
* locale: 'en-US',
|
|
745
|
+
* molecules: [
|
|
746
|
+
* createCountrySelectorMolecule({ mode: 'select', name: 'country-picker' }),
|
|
747
|
+
* ],
|
|
748
|
+
* });
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* @public
|
|
752
|
+
*/
|
|
753
|
+
export declare const createCountrySelectorMolecule: ({ mode, name, }: MoleculeParamsMap["countrySelector"]) => {
|
|
856
754
|
type: "countrySelector";
|
|
857
755
|
params: {
|
|
858
756
|
mode: "select";
|
|
@@ -860,7 +758,31 @@ export declare const createCountrySelectorMolecule: ({ mode }: CountrySelectorPr
|
|
|
860
758
|
};
|
|
861
759
|
};
|
|
862
760
|
|
|
863
|
-
|
|
761
|
+
/**
|
|
762
|
+
* Creates a molecule configuration for the delivery particle.
|
|
763
|
+
*
|
|
764
|
+
* Renders a delivery options selector where the shopper can browse and choose a shipping method.
|
|
765
|
+
* Use `mode: 'active'` for a checkout flow where the shopper makes a selection, and
|
|
766
|
+
* `mode: 'passive'` for a read-only summary display.
|
|
767
|
+
*
|
|
768
|
+
* @param params - Configuration for the delivery particle. See `DeliveryParticleParams`.
|
|
769
|
+
* @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* ```ts
|
|
773
|
+
* const ingrid = await initIngrid({
|
|
774
|
+
* token: 'your-auth-token',
|
|
775
|
+
* siteId: 'your-site-id',
|
|
776
|
+
* locale: 'en-US',
|
|
777
|
+
* molecules: [
|
|
778
|
+
* createDeliveryMolecule({ mode: 'active', name: 'main-delivery' }),
|
|
779
|
+
* ],
|
|
780
|
+
* });
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* @public
|
|
784
|
+
*/
|
|
785
|
+
export declare const createDeliveryMolecule: ({ mode, name, customization, }: MoleculeParamsMap["delivery"]) => {
|
|
864
786
|
type: "delivery";
|
|
865
787
|
customization: {
|
|
866
788
|
choice?: {
|
|
@@ -906,7 +828,31 @@ export declare const createDeliveryMolecule: ({ mode }: DeliveryPresetParams) =>
|
|
|
906
828
|
};
|
|
907
829
|
};
|
|
908
830
|
|
|
909
|
-
|
|
831
|
+
/**
|
|
832
|
+
* Creates a molecule configuration for the free shipping indicator particle.
|
|
833
|
+
*
|
|
834
|
+
* Renders a progress bar or message showing how close the shopper is to qualifying
|
|
835
|
+
* for free shipping. Pair it with a delivery molecule that has `showFreeShippingIndicator`
|
|
836
|
+
* enabled, or use it standalone via the `deliveryId` param.
|
|
837
|
+
*
|
|
838
|
+
* @param params - Configuration for the free shipping indicator particle. See `FreeShippingIndicatorParams`.
|
|
839
|
+
* @returns A molecule descriptor to pass to the `molecules` array in {@link IngridInitParams}.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```ts
|
|
843
|
+
* const ingrid = await initIngrid({
|
|
844
|
+
* token: 'your-auth-token',
|
|
845
|
+
* siteId: 'your-site-id',
|
|
846
|
+
* locale: 'en-US',
|
|
847
|
+
* molecules: [
|
|
848
|
+
* createFreeShippingIndicatorMolecule({ name: 'free-shipping' }),
|
|
849
|
+
* ],
|
|
850
|
+
* });
|
|
851
|
+
* ```
|
|
852
|
+
*
|
|
853
|
+
* @public
|
|
854
|
+
*/
|
|
855
|
+
export declare const createFreeShippingIndicatorMolecule: ({ name, customization, }: MoleculeParamsMap["freeShippingIndicator"]) => {
|
|
910
856
|
type: "freeShippingIndicator";
|
|
911
857
|
customization: {
|
|
912
858
|
showExhaustedLevelsMessage?: boolean;
|
|
@@ -1060,11 +1006,6 @@ declare type DeliveryCoordinates = {
|
|
|
1060
1006
|
lng: number;
|
|
1061
1007
|
};
|
|
1062
1008
|
|
|
1063
|
-
declare interface DeliveryDebugParams {
|
|
1064
|
-
name: string;
|
|
1065
|
-
customization?: ParticleCustomizationConfig<'delivery'>;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
1009
|
/**
|
|
1069
1010
|
* @description The DeliveryCategory represents a grouping of delivery options that share the same type and other characteristics.
|
|
1070
1011
|
*/
|
|
@@ -1385,6 +1326,67 @@ declare type DeliveryLineItem = {
|
|
|
1385
1326
|
attributes?: string[];
|
|
1386
1327
|
};
|
|
1387
1328
|
|
|
1329
|
+
declare type DeliveryMoleculeParams = {
|
|
1330
|
+
mode: 'active' | 'passive';
|
|
1331
|
+
name: string;
|
|
1332
|
+
customization?: {
|
|
1333
|
+
choice?: {
|
|
1334
|
+
carrierInstructions?: 'off' | 'inline' | 'popup';
|
|
1335
|
+
gaplessAddonsList?: boolean;
|
|
1336
|
+
gaplessCarrierList?: boolean;
|
|
1337
|
+
gaplessDeliveryList?: boolean;
|
|
1338
|
+
labels?: 'off' | 'chips' | 'text';
|
|
1339
|
+
showAddons?: boolean;
|
|
1340
|
+
showCustomInfoText?: boolean;
|
|
1341
|
+
showCustomText?: boolean;
|
|
1342
|
+
showDiscountedPrice?: boolean;
|
|
1343
|
+
showFreeShippingIndicator?: boolean;
|
|
1344
|
+
showPrice?: boolean;
|
|
1345
|
+
showRadioIndicator?: boolean;
|
|
1346
|
+
showReturnPromise?: boolean;
|
|
1347
|
+
showShippingLogo?: boolean;
|
|
1348
|
+
};
|
|
1349
|
+
location?: {
|
|
1350
|
+
gaplessList?: boolean;
|
|
1351
|
+
mapDefaultVisible?: boolean;
|
|
1352
|
+
mapDefaultZoom?: number;
|
|
1353
|
+
mapFitboundsMaxZoom?: number;
|
|
1354
|
+
mapPosition?: 'start' | 'end';
|
|
1355
|
+
mapToggleEnabled?: boolean;
|
|
1356
|
+
};
|
|
1357
|
+
productList?: {
|
|
1358
|
+
defaultView?: 'off' | 'list' | 'summary';
|
|
1359
|
+
showImage?: boolean;
|
|
1360
|
+
showMetadata?: boolean;
|
|
1361
|
+
showPrice?: boolean;
|
|
1362
|
+
showQuantity?: boolean;
|
|
1363
|
+
summaryText?: 'none' | 'products' | 'firstProductAndMore';
|
|
1364
|
+
};
|
|
1365
|
+
summary?: {
|
|
1366
|
+
previewAddons?: boolean;
|
|
1367
|
+
showFreeShippingIndicator?: boolean;
|
|
1368
|
+
};
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
declare const deliveryMoleculeParamsValidator = z.object({
|
|
1373
|
+
customization: deliveryCustomizationValidator,
|
|
1374
|
+
|
|
1375
|
+
// TODO: the passive `mode` has hardcoded logic, but IMHO the behaviour should come from granular config (components + policies), not from `mode` branches.
|
|
1376
|
+
// Just an simple example:
|
|
1377
|
+
// components: {
|
|
1378
|
+
// continue_button: { display: 'hidden' },
|
|
1379
|
+
// pickup_location: { display: 'popup', interaction: 'preview' // or edit }
|
|
1380
|
+
// }
|
|
1381
|
+
//
|
|
1382
|
+
// actionPolicy: {
|
|
1383
|
+
// select_item: 'deny'
|
|
1384
|
+
// }
|
|
1385
|
+
//
|
|
1386
|
+
mode: z.enum(['active', 'passive']),
|
|
1387
|
+
name: z.string(),
|
|
1388
|
+
}) satisfies z.ZodType<DeliveryMoleculeParams>;
|
|
1389
|
+
|
|
1388
1390
|
/**
|
|
1389
1391
|
* @description Constraints on the node\'s handoff.
|
|
1390
1392
|
*/
|
|
@@ -1466,67 +1468,6 @@ declare type DeliveryOptionOrigin = {
|
|
|
1466
1468
|
external_id?: string;
|
|
1467
1469
|
};
|
|
1468
1470
|
|
|
1469
|
-
declare type DeliveryParticleParams = {
|
|
1470
|
-
mode: 'active' | 'passive';
|
|
1471
|
-
name: string;
|
|
1472
|
-
customization?: {
|
|
1473
|
-
choice?: {
|
|
1474
|
-
carrierInstructions?: 'off' | 'inline' | 'popup';
|
|
1475
|
-
gaplessAddonsList?: boolean;
|
|
1476
|
-
gaplessCarrierList?: boolean;
|
|
1477
|
-
gaplessDeliveryList?: boolean;
|
|
1478
|
-
labels?: 'off' | 'chips' | 'text';
|
|
1479
|
-
showAddons?: boolean;
|
|
1480
|
-
showCustomInfoText?: boolean;
|
|
1481
|
-
showCustomText?: boolean;
|
|
1482
|
-
showDiscountedPrice?: boolean;
|
|
1483
|
-
showFreeShippingIndicator?: boolean;
|
|
1484
|
-
showPrice?: boolean;
|
|
1485
|
-
showRadioIndicator?: boolean;
|
|
1486
|
-
showReturnPromise?: boolean;
|
|
1487
|
-
showShippingLogo?: boolean;
|
|
1488
|
-
};
|
|
1489
|
-
location?: {
|
|
1490
|
-
gaplessList?: boolean;
|
|
1491
|
-
mapDefaultVisible?: boolean;
|
|
1492
|
-
mapDefaultZoom?: number;
|
|
1493
|
-
mapFitboundsMaxZoom?: number;
|
|
1494
|
-
mapPosition?: 'start' | 'end';
|
|
1495
|
-
mapToggleEnabled?: boolean;
|
|
1496
|
-
};
|
|
1497
|
-
productList?: {
|
|
1498
|
-
defaultView?: 'off' | 'list' | 'summary';
|
|
1499
|
-
showImage?: boolean;
|
|
1500
|
-
showMetadata?: boolean;
|
|
1501
|
-
showPrice?: boolean;
|
|
1502
|
-
showQuantity?: boolean;
|
|
1503
|
-
summaryText?: 'none' | 'products' | 'firstProductAndMore';
|
|
1504
|
-
};
|
|
1505
|
-
summary?: {
|
|
1506
|
-
previewAddons?: boolean;
|
|
1507
|
-
showFreeShippingIndicator?: boolean;
|
|
1508
|
-
};
|
|
1509
|
-
};
|
|
1510
|
-
};
|
|
1511
|
-
|
|
1512
|
-
declare const deliveryParticleParamsValidator = z.object({
|
|
1513
|
-
customization: deliveryCustomizationValidator,
|
|
1514
|
-
|
|
1515
|
-
// TODO: the passive `mode` has hardcoded logic, but IMHO the behaviour should come from granular config (components + policies), not from `mode` branches.
|
|
1516
|
-
// Just an simple example:
|
|
1517
|
-
// components: {
|
|
1518
|
-
// continue_button: { display: 'hidden' },
|
|
1519
|
-
// pickup_location: { display: 'popup', interaction: 'preview' // or edit }
|
|
1520
|
-
// }
|
|
1521
|
-
//
|
|
1522
|
-
// actionPolicy: {
|
|
1523
|
-
// select_item: 'deny'
|
|
1524
|
-
// }
|
|
1525
|
-
//
|
|
1526
|
-
mode: z.enum(['active', 'passive']),
|
|
1527
|
-
name: z.string(),
|
|
1528
|
-
}) satisfies z.ZodType<DeliveryParticleParams>;
|
|
1529
|
-
|
|
1530
1471
|
/**
|
|
1531
1472
|
* @description The PickupLocation represents a physical location from which a delivery can be retrieved.
|
|
1532
1473
|
*/
|
|
@@ -1578,10 +1519,6 @@ declare type DeliveryPickupLocation = {
|
|
|
1578
1519
|
distances?: PickupLocationDistances;
|
|
1579
1520
|
};
|
|
1580
1521
|
|
|
1581
|
-
declare interface DeliveryPresetParams {
|
|
1582
|
-
mode: ParticleParamsMap['delivery']['mode'];
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
1522
|
/**
|
|
1586
1523
|
* @description ReturnPromise contains promise for returns and exchanges for a user and a cart.
|
|
1587
1524
|
*/
|
|
@@ -1821,7 +1758,7 @@ declare type Event_2<T> = { payload: T };
|
|
|
1821
1758
|
|
|
1822
1759
|
declare type EventsMap = {
|
|
1823
1760
|
countryChange: (event: Event_2<{ country_code: string }>) => void;
|
|
1824
|
-
addressSubmit: (event: Event_2<
|
|
1761
|
+
addressSubmit: (event: Event_2<AddressMoleculeInputState>) => void;
|
|
1825
1762
|
selectionChange: (event: Event_2<{ deliveryId: string; categoryId: string }>) => void;
|
|
1826
1763
|
ready: () => void;
|
|
1827
1764
|
error: (error: unknown) => void;
|
|
@@ -1839,20 +1776,26 @@ declare type ExceptionStatus = {
|
|
|
1839
1776
|
status?: string;
|
|
1840
1777
|
};
|
|
1841
1778
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1779
|
+
/**
|
|
1780
|
+
* @description Metadata about the form configuration.
|
|
1781
|
+
*/
|
|
1782
|
+
declare type FormMeta = {
|
|
1783
|
+
/**
|
|
1784
|
+
* @description ISO 3166-1 alpha-2 country code for this form configuration.
|
|
1785
|
+
*/
|
|
1786
|
+
countryCode: CountryCode;
|
|
1787
|
+
/**
|
|
1788
|
+
* @description Text direction. `rtl` (Right-to-Left) is critical for\nlanguages like Arabic or Hebrew.
|
|
1789
|
+
*/
|
|
1790
|
+
direction: TextDirection;
|
|
1791
|
+
/**
|
|
1792
|
+
* @description IETF language tag for the localized labels.
|
|
1793
|
+
* @type string
|
|
1794
|
+
*/
|
|
1795
|
+
language: string;
|
|
1853
1796
|
};
|
|
1854
1797
|
|
|
1855
|
-
declare const
|
|
1798
|
+
declare const freeShippingIndicatorMoleculeParamsValidator = z.object({
|
|
1856
1799
|
name: z.string(),
|
|
1857
1800
|
deliveryId: z.string().optional(),
|
|
1858
1801
|
customization: z
|
|
@@ -1862,6 +1805,14 @@ declare const freeShippingIndicatorParticleParamsValidator = z.object({
|
|
|
1862
1805
|
.optional(),
|
|
1863
1806
|
}) satisfies z.ZodType<FreeShippingIndicatorParams>;
|
|
1864
1807
|
|
|
1808
|
+
declare type FreeShippingIndicatorParams = {
|
|
1809
|
+
name: string;
|
|
1810
|
+
deliveryId?: string;
|
|
1811
|
+
customization?: {
|
|
1812
|
+
showExhaustedLevelsMessage?: boolean;
|
|
1813
|
+
};
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1865
1816
|
/**
|
|
1866
1817
|
* @description Readiness specifies a time range when the goods will be ready for shipment.
|
|
1867
1818
|
*/
|
|
@@ -1909,9 +1860,58 @@ declare type GetAddressDetailsPathParams = {
|
|
|
1909
1860
|
declare type GetAddressDetailsQuery = {
|
|
1910
1861
|
Response: GetAddressDetails200;
|
|
1911
1862
|
PathParams: GetAddressDetailsPathParams;
|
|
1863
|
+
QueryParams: GetAddressDetailsQueryParams;
|
|
1912
1864
|
Errors: GetAddressDetails400 | GetAddressDetails404 | GetAddressDetails500;
|
|
1913
1865
|
};
|
|
1914
1866
|
|
|
1867
|
+
declare type GetAddressDetailsQueryParams = {
|
|
1868
|
+
/**
|
|
1869
|
+
* @description Site identifier, referring to which site the address is resolved for.
|
|
1870
|
+
* @type string
|
|
1871
|
+
*/
|
|
1872
|
+
siteId: string;
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* @description The request has succeeded.
|
|
1877
|
+
*/
|
|
1878
|
+
declare type GetAddressForm200 = AddressFormResponse;
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* @description The server could not understand the request due to invalid syntax.
|
|
1882
|
+
*/
|
|
1883
|
+
declare type GetAddressForm400 = AtlasErrorsBadRequestError;
|
|
1884
|
+
|
|
1885
|
+
/**
|
|
1886
|
+
* @description Server error
|
|
1887
|
+
*/
|
|
1888
|
+
declare type GetAddressForm500 = AtlasErrorsServerError;
|
|
1889
|
+
|
|
1890
|
+
declare type GetAddressFormQuery = {
|
|
1891
|
+
Response: GetAddressForm200;
|
|
1892
|
+
QueryParams: GetAddressFormQueryParams;
|
|
1893
|
+
Errors: GetAddressForm400 | GetAddressForm500;
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
declare type GetAddressFormQueryParams = {
|
|
1897
|
+
/**
|
|
1898
|
+
* @description ISO 3166-1 alpha-2 country code (e.g., SE, US, GB).
|
|
1899
|
+
* @pattern ^[A-Z]{2}$
|
|
1900
|
+
* @type string
|
|
1901
|
+
*/
|
|
1902
|
+
countryCode: CountryCode;
|
|
1903
|
+
/**
|
|
1904
|
+
* @description Site identifier, referring to which site the form configurations are related to.
|
|
1905
|
+
* @type string
|
|
1906
|
+
*/
|
|
1907
|
+
siteId: string;
|
|
1908
|
+
/**
|
|
1909
|
+
* @description Optional postal code. If provided, the response `values` object\nmay contain pre-filled city/state data.
|
|
1910
|
+
* @type string | undefined
|
|
1911
|
+
*/
|
|
1912
|
+
postalCode?: string;
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
1915
|
declare type GetDeliverySessionArgs = z.infer<typeof deliveryArgsSchema>;
|
|
1916
1916
|
|
|
1917
1917
|
declare type GetTrackingDataArgs = z.infer<typeof trackingArgsSchema>;
|
|
@@ -1947,19 +1947,131 @@ declare type GetTrackingDataResponseOptions = {
|
|
|
1947
1947
|
ica_bankid_flow?: boolean;
|
|
1948
1948
|
};
|
|
1949
1949
|
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1950
|
+
/**
|
|
1951
|
+
* The Ingrid SDK namespace.
|
|
1952
|
+
*
|
|
1953
|
+
* @example
|
|
1954
|
+
* ```ts
|
|
1955
|
+
* const instance = await ingrid.init({
|
|
1956
|
+
* token: 'your-auth-token',
|
|
1957
|
+
* siteId: 'your-site-id',
|
|
1958
|
+
* locale: 'en-US',
|
|
1959
|
+
* countryCode: 'US',
|
|
1960
|
+
* currency: 'USD',
|
|
1961
|
+
* molecules: [createAddressMolecule({ mode: 'addressForm' })],
|
|
1962
|
+
* });
|
|
1963
|
+
*
|
|
1964
|
+
* await instance.compound.mount('#ingrid-container');
|
|
1965
|
+
* ```
|
|
1966
|
+
*
|
|
1967
|
+
* @public
|
|
1968
|
+
*/
|
|
1969
|
+
declare const ingrid: {
|
|
1970
|
+
/**
|
|
1971
|
+
* Initializes the Ingrid Experience Kit.
|
|
1972
|
+
*
|
|
1973
|
+
* Fetches the remote release index and site configuration, bootstraps SDK state,
|
|
1974
|
+
* and returns an {@link IngridInstance} ready to mount into the DOM.
|
|
1975
|
+
*
|
|
1976
|
+
* @param params - See {@link IngridInitParams}.
|
|
1977
|
+
* @returns A promise resolving to an {@link IngridInstance}.
|
|
1978
|
+
*
|
|
1979
|
+
* @public
|
|
1980
|
+
*/
|
|
1981
|
+
init: typeof init;
|
|
1982
|
+
};
|
|
1983
|
+
export default ingrid;
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* The compound instance returned by {@link ingrid.init}, used to control the lifecycle
|
|
1987
|
+
* of the rendered Ingrid experience.
|
|
1988
|
+
*
|
|
1989
|
+
* @public
|
|
1990
|
+
*/
|
|
1991
|
+
export declare interface IngridCompound {
|
|
1992
|
+
/** Mounts the Ingrid experience into the DOM element matching `containerSelector`. */
|
|
1993
|
+
mount(containerSelector: string, options?: {
|
|
1994
|
+
signal?: AbortSignal;
|
|
1995
|
+
}): Promise<void>;
|
|
1996
|
+
/** Unmounts the rendered experience and cleans up all resources. */
|
|
1997
|
+
unmount(callback?: () => void): void;
|
|
1998
|
+
/** Updates runtime configuration of the mounted experience. */
|
|
1999
|
+
update(newConfig: Partial<UpdatableConfig>): void;
|
|
2000
|
+
/**
|
|
2001
|
+
* Subscribes to an SDK event.
|
|
2002
|
+
*
|
|
2003
|
+
* @returns An unsubscribe function.
|
|
2004
|
+
*/
|
|
2005
|
+
on<K extends keyof EventsMap>(event: K, callback: EventsMap[K]): () => boolean;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* Configuration passed to {@link ingrid.init}.
|
|
2010
|
+
*
|
|
2011
|
+
* @example
|
|
2012
|
+
* ```ts
|
|
2013
|
+
* const instance = await ingrid.init({
|
|
2014
|
+
* token: 'your-auth-token',
|
|
2015
|
+
* siteId: 'your-site-id',
|
|
2016
|
+
* countryCode: 'US',
|
|
2017
|
+
* currency: 'USD',
|
|
2018
|
+
* locale: 'en-US',
|
|
2019
|
+
* molecules: [createAddressMolecule({ mode: 'addressForm' })],
|
|
2020
|
+
* });
|
|
2021
|
+
* ```
|
|
2022
|
+
*
|
|
2023
|
+
* @public
|
|
2024
|
+
*/
|
|
2025
|
+
export declare interface IngridInitParams {
|
|
2026
|
+
/** Authentication token for the Ingrid API. */
|
|
2027
|
+
token: string;
|
|
2028
|
+
/** Optional function to refresh the authentication token when it expires. */
|
|
2029
|
+
refreshToken?: () => Promise<{
|
|
2030
|
+
accessToken: string;
|
|
2031
|
+
expiresAt: number;
|
|
2032
|
+
}>;
|
|
2033
|
+
/** Ingrid site identifier. */
|
|
2034
|
+
siteId: string;
|
|
2035
|
+
/** The locale to use for the experience. */
|
|
2036
|
+
locale: Locale;
|
|
2037
|
+
/** ISO 3166-1 alpha-2 country code for the market (e.g. `'SE'`, `'DE'`). */
|
|
2038
|
+
countryCode: string;
|
|
2039
|
+
/** ISO 4217 currency code for the market (e.g. `'SEK'`, `'EUR'`). */
|
|
2040
|
+
currency: string;
|
|
2041
|
+
/** Configuration for the molecules to render. */
|
|
2042
|
+
molecules: MoleculesConfig;
|
|
2043
|
+
/** Optional design token overrides for the experience's visual appearance. */
|
|
2044
|
+
styles?: StyleTokens;
|
|
2045
|
+
/** Optional overrides for the internal data-fetching services. */
|
|
2046
|
+
dataProviders?: {
|
|
2047
|
+
services?: ServicesOverrides;
|
|
1958
2048
|
};
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2049
|
+
/**
|
|
2050
|
+
* Deployment environment.
|
|
2051
|
+
*
|
|
2052
|
+
* @defaultValue `'production'`
|
|
2053
|
+
*/
|
|
2054
|
+
env?: 'production' | 'stage';
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
/**
|
|
2058
|
+
* The object returned by {@link ingrid.init}, providing control over the Ingrid experience lifecycle.
|
|
2059
|
+
*
|
|
2060
|
+
* @public
|
|
2061
|
+
*/
|
|
2062
|
+
export declare interface IngridInstance {
|
|
2063
|
+
/** The compound instance used to mount, unmount, and update the Ingrid experience. */
|
|
2064
|
+
compound: IngridCompound;
|
|
2065
|
+
/** Updates the active locale for the experience. */
|
|
2066
|
+
setLocale(locale: Locale): void;
|
|
2067
|
+
/** Updates the active purchase country code. */
|
|
2068
|
+
setPurchaseCountry(countryCode: string): void;
|
|
2069
|
+
/** Updates the active currency. */
|
|
2070
|
+
setCurrency(currency: string): void;
|
|
2071
|
+
/* Excluded from this release type: __internal */
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
declare function init(params: IngridInitParams): Promise<IngridInstance>;
|
|
1963
2075
|
|
|
1964
2076
|
declare const _internalBrand: unique symbol;
|
|
1965
2077
|
|
|
@@ -2182,12 +2294,42 @@ declare type LocationByValue = {
|
|
|
2182
2294
|
};
|
|
2183
2295
|
|
|
2184
2296
|
declare type MethodOverrides<T> = {
|
|
2185
|
-
[K in keyof T]?: T[K] extends (...args: any[]) => any ? T[K] |
|
|
2297
|
+
[K in keyof T]?: T[K] extends (...args: any[]) => any ? T[K] | WithDefaultProvider<T[K]> : never;
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2300
|
+
declare type MoleculeCustomizationConfig<T extends MoleculeType> = MoleculeCustomizationConfigMap[T];
|
|
2301
|
+
|
|
2302
|
+
declare type MoleculeCustomizationConfigMap = {
|
|
2303
|
+
address: AddressMoleculeCustomization;
|
|
2304
|
+
countrySelector: CountrySelectorParams['customization'];
|
|
2305
|
+
delivery: DeliveryMoleculeParams['customization'];
|
|
2306
|
+
freeShippingIndicator: FreeShippingIndicatorParams['customization'];
|
|
2307
|
+
tracking: TrackingNumberParams['customization'];
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
declare type MoleculeMapType = {
|
|
2311
|
+
address: { readonly validator: typeof addressMoleculeParamsValidator };
|
|
2312
|
+
countrySelector: { readonly validator: typeof countrySelectorMoleculeParamsValidator };
|
|
2313
|
+
delivery: { readonly validator: typeof deliveryMoleculeParamsValidator };
|
|
2314
|
+
freeShippingIndicator: {
|
|
2315
|
+
readonly validator: typeof freeShippingIndicatorMoleculeParamsValidator;
|
|
2316
|
+
};
|
|
2317
|
+
tracking: { readonly validator: typeof trackingNumberParamsValidator };
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2320
|
+
declare type MoleculeParamsMap = {
|
|
2321
|
+
address: AddressMoleculeParams;
|
|
2322
|
+
countrySelector: CountrySelectorParams;
|
|
2323
|
+
delivery: DeliveryMoleculeParams;
|
|
2324
|
+
freeShippingIndicator: FreeShippingIndicatorParams;
|
|
2325
|
+
tracking: TrackingNumberParams;
|
|
2186
2326
|
};
|
|
2187
2327
|
|
|
2188
2328
|
declare type MoleculesConfig = {
|
|
2189
|
-
[K in
|
|
2190
|
-
}[
|
|
2329
|
+
[K in MoleculeType]: BaseMoleculeDef<K>;
|
|
2330
|
+
}[MoleculeType][];
|
|
2331
|
+
|
|
2332
|
+
declare type MoleculeType = keyof MoleculeMapType;
|
|
2191
2333
|
|
|
2192
2334
|
declare type OperationalHours = {
|
|
2193
2335
|
/**
|
|
@@ -2351,18 +2493,6 @@ declare type OrderCartPricesTotals = {
|
|
|
2351
2493
|
tax?: number;
|
|
2352
2494
|
};
|
|
2353
2495
|
|
|
2354
|
-
export declare interface Params {
|
|
2355
|
-
styles?: StyleTokens;
|
|
2356
|
-
dataProviders?: {
|
|
2357
|
-
services?: ServicesOverrides;
|
|
2358
|
-
};
|
|
2359
|
-
token: string;
|
|
2360
|
-
siteId: string;
|
|
2361
|
-
locale: Locale;
|
|
2362
|
-
molecules: MoleculesConfig;
|
|
2363
|
-
env?: 'production' | 'stage' | 'development';
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
2496
|
declare type Parcel = {
|
|
2367
2497
|
/**
|
|
2368
2498
|
* @type array | undefined
|
|
@@ -2449,36 +2579,6 @@ declare type Parcel = {
|
|
|
2449
2579
|
tracking_number?: string;
|
|
2450
2580
|
};
|
|
2451
2581
|
|
|
2452
|
-
declare type ParticleCustomizationConfig<T extends ParticleType> = ParticleCustomizationConfigMap[T];
|
|
2453
|
-
|
|
2454
|
-
declare type ParticleCustomizationConfigMap = {
|
|
2455
|
-
address: AddressParticleParams['customization'];
|
|
2456
|
-
countrySelector: CountrySelectorParams['customization'];
|
|
2457
|
-
delivery: DeliveryParticleParams['customization'];
|
|
2458
|
-
freeShippingIndicator: FreeShippingIndicatorParams['customization'];
|
|
2459
|
-
tracking: TrackingNumberParams['customization'];
|
|
2460
|
-
};
|
|
2461
|
-
|
|
2462
|
-
declare type ParticleMapType = {
|
|
2463
|
-
address: { readonly validator: typeof addressParticleParamsValidator };
|
|
2464
|
-
countrySelector: { readonly validator: typeof countrySelectorParticleParamsValidator };
|
|
2465
|
-
delivery: { readonly validator: typeof deliveryParticleParamsValidator };
|
|
2466
|
-
freeShippingIndicator: {
|
|
2467
|
-
readonly validator: typeof freeShippingIndicatorParticleParamsValidator;
|
|
2468
|
-
};
|
|
2469
|
-
tracking: { readonly validator: typeof trackingNumberParamsValidator };
|
|
2470
|
-
};
|
|
2471
|
-
|
|
2472
|
-
declare type ParticleParamsMap = {
|
|
2473
|
-
address: AddressParticleParams;
|
|
2474
|
-
countrySelector: CountrySelectorParams;
|
|
2475
|
-
delivery: DeliveryParticleParams;
|
|
2476
|
-
freeShippingIndicator: FreeShippingIndicatorParams;
|
|
2477
|
-
tracking: TrackingNumberParams;
|
|
2478
|
-
};
|
|
2479
|
-
|
|
2480
|
-
declare type ParticleType = keyof ParticleMapType;
|
|
2481
|
-
|
|
2482
2582
|
/**
|
|
2483
2583
|
* @description Distances define the walking and driving distances to the pickup location.
|
|
2484
2584
|
*/
|
|
@@ -2680,6 +2780,7 @@ declare type RawTranslationKey =
|
|
|
2680
2780
|
| 'address.delete'
|
|
2681
2781
|
| 'address.delete_confirmation.banner.content'
|
|
2682
2782
|
| 'address.delete_confirmation.banner.title'
|
|
2783
|
+
| 'address.delete_confirmation.warning_text'
|
|
2683
2784
|
| 'address.edit'
|
|
2684
2785
|
| 'address.edit.billing.aria.label'
|
|
2685
2786
|
| 'address.edit.delivery.aria.label'
|
|
@@ -2726,6 +2827,7 @@ declare type RawTranslationKey =
|
|
|
2726
2827
|
| 'address.form.field.vat.label'
|
|
2727
2828
|
| 'address.form.field.vat_type.label'
|
|
2728
2829
|
| 'address.form.field_optional'
|
|
2830
|
+
| 'address.form.search.enter_manually'
|
|
2729
2831
|
| 'address.form.validation.address_line.invalid'
|
|
2730
2832
|
| 'address.form.validation.phone_number.invalid'
|
|
2731
2833
|
| 'address.form.validation.postal_code.invalid'
|
|
@@ -2734,8 +2836,12 @@ declare type RawTranslationKey =
|
|
|
2734
2836
|
| 'address.form.validation.street_number.required'
|
|
2735
2837
|
| 'address.form.vat_other_country'
|
|
2736
2838
|
| 'address.list.add_new_address'
|
|
2839
|
+
| 'address.list.save'
|
|
2737
2840
|
| 'address.list.save_and_continue'
|
|
2738
2841
|
| 'address.list.title'
|
|
2842
|
+
| 'address.popup.address_form.title'
|
|
2843
|
+
| 'address.popup.deleting.title'
|
|
2844
|
+
| 'address.popup.list.title'
|
|
2739
2845
|
| 'address.save'
|
|
2740
2846
|
| 'address.save_anyway'
|
|
2741
2847
|
| 'address.suggestion.address_incorrect.description'
|
|
@@ -2856,25 +2962,6 @@ declare type RawTranslationKey =
|
|
|
2856
2962
|
| 'time.wednesday'
|
|
2857
2963
|
| 'tracking.track_delivery_with';
|
|
2858
2964
|
|
|
2859
|
-
declare type RecipientContact = {
|
|
2860
|
-
first_name?: string;
|
|
2861
|
-
last_name?: string;
|
|
2862
|
-
contact_id?: string;
|
|
2863
|
-
address: {
|
|
2864
|
-
country_code: string;
|
|
2865
|
-
region_code?: string;
|
|
2866
|
-
postal_code?: string;
|
|
2867
|
-
city?: string;
|
|
2868
|
-
address_lines?: string[];
|
|
2869
|
-
};
|
|
2870
|
-
email?: string;
|
|
2871
|
-
phone_number?: {
|
|
2872
|
-
country_code: string;
|
|
2873
|
-
number: string;
|
|
2874
|
-
extension?: string;
|
|
2875
|
-
};
|
|
2876
|
-
};
|
|
2877
|
-
|
|
2878
2965
|
declare type RecursiveObjectValues<T> = T extends object ? RecursiveObjectValues<T[keyof T]> : T;
|
|
2879
2966
|
|
|
2880
2967
|
declare interface SDKInternal {
|
|
@@ -2935,14 +3022,34 @@ declare type Services = {
|
|
|
2935
3022
|
formatMessage: TranslationsService['formatMessage'];
|
|
2936
3023
|
registerTranslations: TranslationsService['registerTranslations'];
|
|
2937
3024
|
};
|
|
3025
|
+
/**
|
|
3026
|
+
* Services for contact book management, address autocomplete, and address validation.
|
|
3027
|
+
*
|
|
3028
|
+
* @example
|
|
3029
|
+
* ```ts
|
|
3030
|
+
* const entries = await services.address.listContactBookEntries({
|
|
3031
|
+
* params: { addressBookId: 'book_123' },
|
|
3032
|
+
* token: authToken,
|
|
3033
|
+
* });
|
|
3034
|
+
* ```
|
|
3035
|
+
*/
|
|
2938
3036
|
address: {
|
|
3037
|
+
/** Fetches a paginated list of address book entries for the given address book. */
|
|
2939
3038
|
listContactBookEntries: ContactsService['listContactBookEntries'];
|
|
3039
|
+
/** Fetches a single address book entry by ID. Returns `null` if not found. */
|
|
2940
3040
|
getContactBookEntry: ContactsService['getContactBookEntry'];
|
|
3041
|
+
/** Creates or updates an address book entry. */
|
|
2941
3042
|
upsertContactBookEntry: ContactsService['upsertContactBookEntry'];
|
|
3043
|
+
/** Deletes an address book entry. */
|
|
2942
3044
|
deleteContactBookEntry: ContactsService['deleteContactBookEntry'];
|
|
3045
|
+
/** Fetches a list of address autocomplete suggestions matching a partial query. */
|
|
2943
3046
|
listSuggestions: AddressSuggestionsService['list'];
|
|
3047
|
+
/** Resolves the full address details for a selected autocomplete suggestion. */
|
|
2944
3048
|
resolveSuggestion: AddressSuggestionsService['resolve'];
|
|
3049
|
+
/** Validates an address against the backend validation service. */
|
|
2945
3050
|
validateAddress: AddressValidationService['validateAddress'];
|
|
3051
|
+
/** Fetches configuration for rendering the address form for a specific country. */
|
|
3052
|
+
getAddressFormConfig: AddressFormService['getAddressFormConfig'];
|
|
2946
3053
|
};
|
|
2947
3054
|
};
|
|
2948
3055
|
|
|
@@ -3021,6 +3128,13 @@ declare type StepEnum =
|
|
|
3021
3128
|
|
|
3022
3129
|
declare type StyleTokens = Partial<Record<ThemeCssVariables, string>>;
|
|
3023
3130
|
|
|
3131
|
+
/**
|
|
3132
|
+
* @description Text direction for form rendering.
|
|
3133
|
+
*/
|
|
3134
|
+
declare type TextDirection = TextDirectionEnum;
|
|
3135
|
+
|
|
3136
|
+
declare type TextDirectionEnum = 'ltr' | 'rtl';
|
|
3137
|
+
|
|
3024
3138
|
declare type ThemeCssVariables = `--${RecursiveObjectValues<typeof variableNames>}`;
|
|
3025
3139
|
|
|
3026
3140
|
declare const trackingArgsSchema = z.union([
|
|
@@ -3060,67 +3174,6 @@ declare interface UpdatableConfig {
|
|
|
3060
3174
|
styles?: StyleTokens;
|
|
3061
3175
|
}
|
|
3062
3176
|
|
|
3063
|
-
/**
|
|
3064
|
-
* @description Contact represents generic contact information.
|
|
3065
|
-
*/
|
|
3066
|
-
declare type V1AlphaAddressContact = {
|
|
3067
|
-
/**
|
|
3068
|
-
* @description The identifier of the contact.
|
|
3069
|
-
* @type string | undefined
|
|
3070
|
-
*/
|
|
3071
|
-
contact_id?: string;
|
|
3072
|
-
/**
|
|
3073
|
-
* @description Represents an address suitable for delivery.
|
|
3074
|
-
* @type object
|
|
3075
|
-
*/
|
|
3076
|
-
address: AddressAddress;
|
|
3077
|
-
/**
|
|
3078
|
-
* @description The email address of the contact.
|
|
3079
|
-
* @type string | undefined
|
|
3080
|
-
*/
|
|
3081
|
-
email?: string;
|
|
3082
|
-
/**
|
|
3083
|
-
* @description A phone number, including region and optional extension.
|
|
3084
|
-
* @type object | undefined
|
|
3085
|
-
*/
|
|
3086
|
-
phone_number?: ContactPhoneNumber_2;
|
|
3087
|
-
/**
|
|
3088
|
-
* @description Full name associated with the contact.
|
|
3089
|
-
* @type string | undefined
|
|
3090
|
-
*/
|
|
3091
|
-
name?: string;
|
|
3092
|
-
/**
|
|
3093
|
-
* @description First name associated with the contact.
|
|
3094
|
-
* @type string | undefined
|
|
3095
|
-
*/
|
|
3096
|
-
first_name?: string;
|
|
3097
|
-
/**
|
|
3098
|
-
* @description Last name associated with the contact.
|
|
3099
|
-
* @type string | undefined
|
|
3100
|
-
*/
|
|
3101
|
-
last_name?: string;
|
|
3102
|
-
/**
|
|
3103
|
-
* @description National ID number associated with the contact.
|
|
3104
|
-
* @type string | undefined
|
|
3105
|
-
*/
|
|
3106
|
-
national_id_number?: string;
|
|
3107
|
-
/**
|
|
3108
|
-
* @description Company name associated with the contact.
|
|
3109
|
-
* @type string | undefined
|
|
3110
|
-
*/
|
|
3111
|
-
company_name?: string;
|
|
3112
|
-
/**
|
|
3113
|
-
* @description VAT number associated with the contact.
|
|
3114
|
-
* @type string | undefined
|
|
3115
|
-
*/
|
|
3116
|
-
vat?: string;
|
|
3117
|
-
/**
|
|
3118
|
-
* @description Customs number associated with the contact.
|
|
3119
|
-
* @type string | undefined
|
|
3120
|
-
*/
|
|
3121
|
-
customs_number?: string;
|
|
3122
|
-
};
|
|
3123
|
-
|
|
3124
3177
|
/**
|
|
3125
3178
|
* @description Represents an address suitable for delivery.
|
|
3126
3179
|
*/
|
|
@@ -3271,6 +3324,11 @@ declare type ValidateAddressMutationRequest = ValidateAddressRequest;
|
|
|
3271
3324
|
* @description Request to validate and standardize an address.
|
|
3272
3325
|
*/
|
|
3273
3326
|
declare type ValidateAddressRequest = {
|
|
3327
|
+
/**
|
|
3328
|
+
* @description Site identifier, referring to which site we validate the address for.
|
|
3329
|
+
* @type string
|
|
3330
|
+
*/
|
|
3331
|
+
siteId: string;
|
|
3274
3332
|
/**
|
|
3275
3333
|
* @description The address to validate against postal reference data.
|
|
3276
3334
|
*/
|
|
@@ -3491,6 +3549,7 @@ declare const variableNames: {
|
|
|
3491
3549
|
readonly '350': "size-350";
|
|
3492
3550
|
readonly '400': "size-400";
|
|
3493
3551
|
readonly '600': "size-600";
|
|
3552
|
+
readonly '700': "size-700";
|
|
3494
3553
|
readonly '800': "size-800";
|
|
3495
3554
|
readonly '1000': "size-1000";
|
|
3496
3555
|
readonly '1200': "size-1200";
|
|
@@ -3559,11 +3618,48 @@ declare type VerificationLevel = VerificationLevelEnum;
|
|
|
3559
3618
|
|
|
3560
3619
|
declare type VerificationLevelEnum = 'premise' | 'street' | 'locality' | 'none';
|
|
3561
3620
|
|
|
3562
|
-
|
|
3563
|
-
|
|
3621
|
+
/**
|
|
3622
|
+
* Opaque wrapper produced by {@link withDefaultProvider}.
|
|
3623
|
+
* Carries a factory that receives the SDK's built-in implementation and returns the override.
|
|
3624
|
+
*
|
|
3625
|
+
* @public
|
|
3626
|
+
*/
|
|
3627
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3628
|
+
declare type WithDefaultProvider<T extends (...args: any[]) => any> = {
|
|
3629
|
+
readonly __tag: 'withDefaultProvider';
|
|
3564
3630
|
readonly factory: (defaultFn: T) => T;
|
|
3565
3631
|
};
|
|
3566
3632
|
|
|
3567
|
-
|
|
3633
|
+
/**
|
|
3634
|
+
* Wraps a service method override so it has access to the SDK's built-in implementation.
|
|
3635
|
+
* Use this instead of a plain function replacement when you want to extend the default
|
|
3636
|
+
* behaviour (e.g. add logging, modify the response) rather than replace it entirely.
|
|
3637
|
+
*
|
|
3638
|
+
* @param factory - Receives the SDK's default implementation as `defaultFn`.
|
|
3639
|
+
* Return a new function that calls `defaultFn` wherever you want the original behaviour.
|
|
3640
|
+
* @returns A {@link WithDefaultProvider} wrapper understood by the SDK's service resolver.
|
|
3641
|
+
*
|
|
3642
|
+
* @example
|
|
3643
|
+
* ```ts
|
|
3644
|
+
* const instance = await ingrid.init({
|
|
3645
|
+
* // ...
|
|
3646
|
+
* dataProviders: {
|
|
3647
|
+
* services: {
|
|
3648
|
+
* address: {
|
|
3649
|
+
* listSuggestions: withDefaultProvider((defaultFn) => async (args) => {
|
|
3650
|
+
* console.log('Fetching suggestions for', args.params);
|
|
3651
|
+
* const result = await defaultFn(args);
|
|
3652
|
+
* console.log('Got', result.length, 'suggestions');
|
|
3653
|
+
* return result;
|
|
3654
|
+
* }),
|
|
3655
|
+
* },
|
|
3656
|
+
* },
|
|
3657
|
+
* },
|
|
3658
|
+
* });
|
|
3659
|
+
* ```
|
|
3660
|
+
*
|
|
3661
|
+
* @public
|
|
3662
|
+
*/
|
|
3663
|
+
export declare const withDefaultProvider: <T extends (...args: any[]) => any>(factory: (defaultFn: T) => T) => WithDefaultProvider<T>;
|
|
3568
3664
|
|
|
3569
3665
|
export { }
|