@eldrajs/sdk 0.2.8 → 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.
- package/CHANGELOG.md +36 -0
- package/README.md +49 -0
- package/THIRD-PARTY-NOTICES.md +18 -0
- package/dist/{client-t66vCzJf.js → client-COQ5N834.js} +55 -0
- package/dist/format/date.d.ts +4 -0
- package/dist/format/date.js +12214 -0
- package/dist/format/display-names.d.ts +4 -0
- package/dist/format/display-names.js +4905 -0
- package/dist/format/list.d.ts +4 -0
- package/dist/format/list.js +902 -0
- package/dist/format/relative-time.d.ts +4 -0
- package/dist/format/relative-time.js +1546 -0
- package/dist/format.d.ts +12 -0
- package/dist/format.js +72 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/locale-DOZdbAbY.js +4011 -0
- package/dist/number-D3Vt6TOL.js +9585 -0
- package/dist/{types-B40H01uK.d.ts → types-Cs5t0rx7.d.ts} +102 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +32 -3
|
@@ -281,6 +281,7 @@ interface EldraClient {
|
|
|
281
281
|
cart: EldraCartClient;
|
|
282
282
|
orders: EldraOrdersClient;
|
|
283
283
|
platform: EldraPlatformClient;
|
|
284
|
+
forms: EldraFormsClient;
|
|
284
285
|
checkout: EldraCheckoutClient;
|
|
285
286
|
inventory: EldraInventoryClient;
|
|
286
287
|
}
|
|
@@ -379,5 +380,105 @@ interface EldraPlatformClient {
|
|
|
379
380
|
interface EldraInventoryClient {
|
|
380
381
|
availability(items: EldraStockAvailabilityInput[], context?: EldraRequestContext): Promise<EldraStockAvailability>;
|
|
381
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* A localized string as the forms API publishes it: one entry per locale tag the merchant wrote
|
|
385
|
+
* (`en-US`, `is-IS`). A caller resolves its own locale and falls back; the API never guesses.
|
|
386
|
+
*/
|
|
387
|
+
type EldraFormLocalized = Record<string, string>;
|
|
388
|
+
/**
|
|
389
|
+
* The field types a form definition can carry. `checkbox` and `consent` both carry a boolean;
|
|
390
|
+
* `required` on a `consent` field means it must be checked. `number` and `url` carry text the
|
|
391
|
+
* platform validates (a finite number, an absolute http(s) URL).
|
|
392
|
+
*/
|
|
393
|
+
type EldraFormFieldType = 'text' | 'email' | 'phone' | 'textarea' | 'select' | 'checkbox' | 'consent' | 'number' | 'url';
|
|
394
|
+
interface EldraFormFieldOption {
|
|
395
|
+
value: string;
|
|
396
|
+
label: EldraFormLocalized;
|
|
397
|
+
}
|
|
398
|
+
interface EldraFormField {
|
|
399
|
+
/** Stable id: the key of the field in a submission's `values` and in a 422's `errors`. */
|
|
400
|
+
id: string;
|
|
401
|
+
type: EldraFormFieldType;
|
|
402
|
+
required: boolean;
|
|
403
|
+
label: EldraFormLocalized;
|
|
404
|
+
placeholder?: EldraFormLocalized;
|
|
405
|
+
options?: EldraFormFieldOption[];
|
|
406
|
+
validation?: {
|
|
407
|
+
minLength?: number;
|
|
408
|
+
maxLength?: number;
|
|
409
|
+
pattern?: string;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/** The actions a submission triggers; the merchant's notify/confirm targets are never published. */
|
|
413
|
+
type EldraFormActionKind = 'store' | 'notify' | 'confirm' | 'subscribe';
|
|
414
|
+
/**
|
|
415
|
+
* A form definition exactly as `GET /site/v1/forms/{key}` answers it. Hand-written rather than
|
|
416
|
+
* contract-derived (the SDK ships no response types): the shape is the platform's documented wire
|
|
417
|
+
* contract, and `@eldrajs/theme-nuxt` validates a build-time read of it before baking it.
|
|
418
|
+
*/
|
|
419
|
+
interface EldraFormDefinition {
|
|
420
|
+
key: string;
|
|
421
|
+
name: string;
|
|
422
|
+
fields: EldraFormField[];
|
|
423
|
+
/** The name of a field that must stay empty: render it hidden from people, send it as `hp`. */
|
|
424
|
+
honeypotField: string;
|
|
425
|
+
/** Cloudflare Turnstile site key, or `null` when the merchant has not enabled it. */
|
|
426
|
+
turnstileSiteKey: string | null;
|
|
427
|
+
success: {
|
|
428
|
+
message: EldraFormLocalized;
|
|
429
|
+
redirect?: EldraFormLocalized;
|
|
430
|
+
};
|
|
431
|
+
kinds: EldraFormActionKind[];
|
|
432
|
+
/**
|
|
433
|
+
* The consent sentence per locale, with the shop name already filled in for `{shop}`. Present
|
|
434
|
+
* only when `kinds` contains `subscribe`. Show it next to the submit button (escaped, plain
|
|
435
|
+
* text): submitting the form is the visitor's consent to exactly this wording, and the platform
|
|
436
|
+
* stores it as the proof. There is no extra checkbox and no extra submit field.
|
|
437
|
+
*/
|
|
438
|
+
consentText?: EldraFormLocalized;
|
|
439
|
+
}
|
|
440
|
+
interface EldraFormSubmitInput {
|
|
441
|
+
/** `fieldId` to the entered value; a checkbox is a boolean, everything else a string. */
|
|
442
|
+
values: Record<string, string | boolean>;
|
|
443
|
+
locale: string;
|
|
444
|
+
pagePath: string;
|
|
445
|
+
turnstileToken?: string;
|
|
446
|
+
/** The honeypot field's value, which a person never fills. */
|
|
447
|
+
hp?: string;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* What a submission resolves to. A `422` is an answer, not a failure — it carries the field-keyed
|
|
451
|
+
* messages a form shows inline — so it resolves as `status: 'invalid'`. Every other non-2xx
|
|
452
|
+
* (`404` unknown form, `413` oversize, `429` rate limited) rejects with `EldraHttpError`.
|
|
453
|
+
*/
|
|
454
|
+
type EldraFormSubmitResult = {
|
|
455
|
+
status: 'ok';
|
|
456
|
+
/** `true` when the form subscribes the visitor and a confirmation email is on its way. */
|
|
457
|
+
pending: boolean;
|
|
458
|
+
} | {
|
|
459
|
+
status: 'invalid';
|
|
460
|
+
/** `fieldId` to messages, the shape `@eldrajs/ui`'s `apiErrors` expects. */
|
|
461
|
+
errors: Record<string, string[]>;
|
|
462
|
+
/** Messages about the form as a whole. */
|
|
463
|
+
form: string[];
|
|
464
|
+
};
|
|
465
|
+
interface EldraFormTokenResult {
|
|
466
|
+
status: 'confirmed' | 'unsubscribed';
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* The site-forms API. Needs the organisation's `FORMS` feature (not `PAGE_BUILDER`) and a registered
|
|
470
|
+
* storefront origin in a browser; works with no theme. The mailed confirm and unsubscribe links point
|
|
471
|
+
* at the web gateway's own page, not the storefront.
|
|
472
|
+
*/
|
|
473
|
+
interface EldraFormsClient {
|
|
474
|
+
/** `GET /site/v1/forms/{key}`. Rejects with `EldraHttpError` (`404`) for an unknown key. */
|
|
475
|
+
get(key: string, context?: EldraRequestContext): Promise<EldraFormDefinition>;
|
|
476
|
+
/** `POST /site/v1/forms/{key}/submissions`. See `EldraFormSubmitResult`. */
|
|
477
|
+
submit(key: string, input: EldraFormSubmitInput, context?: EldraRequestContext): Promise<EldraFormSubmitResult>;
|
|
478
|
+
/** Double opt-in: `POST /site/v1/forms/subscriptions/confirm?token=` (a GET of the link is only a page). */
|
|
479
|
+
confirm(token: string, context?: EldraRequestContext): Promise<EldraFormTokenResult>;
|
|
480
|
+
/** `POST /site/v1/forms/subscriptions/unsubscribe?token=` (a GET of the link is only a page). */
|
|
481
|
+
unsubscribe(token: string, context?: EldraRequestContext): Promise<EldraFormTokenResult>;
|
|
482
|
+
}
|
|
382
483
|
//#endregion
|
|
383
|
-
export {
|
|
484
|
+
export { EldraOrganizationFeature as $, EldraFeature as A, EldraContractMethod as At, EldraFormSubmitResult as B, EldraCmsResolveEntryListResponse as C, EldraStockAvailabilityInput as Ct, EldraCollectionListOptions as D, EldraContract as Dt, EldraCollectionList as E, RuntimeValue as Et, EldraFormField as F, EldraContractResponse as Ft, EldraInventoryClient as G, EldraFormsClient as H, EldraFormFieldOption as I, EldraOrderLine as J, EldraLocaleOptions as K, EldraFormFieldType as L, EldraFeatureClient as M, EldraContractPaths as Mt, EldraFormActionKind as N, EldraContractProp as Nt, EldraCollectionProductsOptions as O, EldraContractBody as Ot, EldraFormDefinition as P, EldraContractQuery as Pt, EldraOrganizationDetails as Q, EldraFormLocalized as R, EldraCmsResolveEntryListOptions as S, EldraStockAvailability as St, EldraCollection as T, RuntimeEnv as Tt, EldraHttpClient as U, EldraFormTokenResult as V, EldraHttpRequest as W, EldraOrdersClient as X, EldraOrderReadOptions as Y, EldraOrganizationCommerce as Z, EldraCmsEntryListEntry as _, EldraRequestContext as _t, EldraCartTotals as a, EldraPlatformConfig as at, EldraCmsGetOptions as b, EldraSearchOptions as bt, EldraCatalogListProductsOptions as c, EldraProductList as ct, EldraCheckoutUrlOptions as d, EldraProductOption as dt, EldraOrganizationLocales as et, EldraClient as f, EldraProductOptionValue as ft, EldraCmsEntryListDisplayMode as g, EldraRecoveredBasketItem as gt, EldraCmsEntryList as h, EldraRecoveredBasket as ht, EldraCartItem as i, EldraPlatformClient as it, EldraFeatureCapabilities as j, EldraContractPath as jt, EldraDiscountResult as k, EldraContractItem as kt, EldraCategory as l, EldraProductListItem as lt, EldraCmsClient as m, EldraProductVariant as mt, EldraCart as n, EldraPageMeta as nt, EldraCatalogClient as o, EldraPlatformReadOptions as ot, EldraClientOptions as p, EldraProductThumbnail as pt, EldraOrder as q, EldraCartClient as r, EldraPaginated as rt, EldraCatalogGetProductOptions as s, EldraProductDetails as st, EldraAddCartItemInput as t, EldraOrganizationOptions as tt, EldraCheckoutClient as u, EldraProductMediaLink as ut, EldraCmsEntryListFilterCriterion as v, EldraRequestOptions as vt, EldraCmsResolvedEntryList as w, EldraStockAvailabilityItem as wt, EldraCmsListOptions as x, EldraSearchResponse as xt, EldraCmsGetEntryByUniqueFieldOptions as y, EldraRetryOptions as yt, EldraFormSubmitInput as z };
|
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Framework-free client for the Eldra Web Studio public storefront API: CMS, catalog, cart, checkout handoff, orders, inventory. Types generated from your gateway's OpenAPI document and CMS schemas at build time.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
23
|
"CHANGELOG.md",
|
|
24
|
-
"LICENSE"
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"THIRD-PARTY-NOTICES.md"
|
|
25
26
|
],
|
|
26
27
|
"type": "module",
|
|
27
28
|
"sideEffects": false,
|
|
@@ -34,6 +35,26 @@
|
|
|
34
35
|
"types": "./dist/vite.d.ts",
|
|
35
36
|
"import": "./dist/vite.js"
|
|
36
37
|
},
|
|
38
|
+
"./format": {
|
|
39
|
+
"types": "./dist/format.d.ts",
|
|
40
|
+
"import": "./dist/format.js"
|
|
41
|
+
},
|
|
42
|
+
"./format/date": {
|
|
43
|
+
"types": "./dist/format/date.d.ts",
|
|
44
|
+
"import": "./dist/format/date.js"
|
|
45
|
+
},
|
|
46
|
+
"./format/list": {
|
|
47
|
+
"types": "./dist/format/list.d.ts",
|
|
48
|
+
"import": "./dist/format/list.js"
|
|
49
|
+
},
|
|
50
|
+
"./format/relative-time": {
|
|
51
|
+
"types": "./dist/format/relative-time.d.ts",
|
|
52
|
+
"import": "./dist/format/relative-time.js"
|
|
53
|
+
},
|
|
54
|
+
"./format/display-names": {
|
|
55
|
+
"types": "./dist/format/display-names.d.ts",
|
|
56
|
+
"import": "./dist/format/display-names.js"
|
|
57
|
+
},
|
|
37
58
|
"./package.json": "./package.json"
|
|
38
59
|
},
|
|
39
60
|
"publishConfig": {
|
|
@@ -44,6 +65,12 @@
|
|
|
44
65
|
"openapi-typescript": "^7.13.0"
|
|
45
66
|
},
|
|
46
67
|
"devDependencies": {
|
|
68
|
+
"@formatjs/intl-datetimeformat": "7.8.1",
|
|
69
|
+
"@formatjs/intl-displaynames": "7.3.15",
|
|
70
|
+
"@formatjs/intl-listformat": "8.3.15",
|
|
71
|
+
"@formatjs/intl-numberformat": "9.4.3",
|
|
72
|
+
"@formatjs/intl-relativetimeformat": "12.3.15",
|
|
73
|
+
"@playwright/test": "1.62.1",
|
|
47
74
|
"vite": "^8.0.8"
|
|
48
75
|
},
|
|
49
76
|
"peerDependencies": {
|
|
@@ -61,6 +88,8 @@
|
|
|
61
88
|
"build": "tsdown",
|
|
62
89
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.generated.json",
|
|
63
90
|
"test": "vitest run",
|
|
64
|
-
"fixture": "node scripts/fixture.mjs"
|
|
91
|
+
"fixture": "node scripts/fixture.mjs",
|
|
92
|
+
"format-data": "node scripts/extract-format-data.mjs",
|
|
93
|
+
"check:format-data": "node scripts/extract-format-data.mjs --check"
|
|
65
94
|
}
|
|
66
95
|
}
|