@ebitex/content-sdk 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.
Files changed (86) hide show
  1. package/README.md +62 -0
  2. package/dist/content/cache.d.ts +26 -0
  3. package/dist/content/cache.d.ts.map +1 -0
  4. package/dist/content/cache.js +107 -0
  5. package/dist/content/cache.js.map +1 -0
  6. package/dist/content/client.d.ts +78 -0
  7. package/dist/content/client.d.ts.map +1 -0
  8. package/dist/content/client.js +150 -0
  9. package/dist/content/client.js.map +1 -0
  10. package/dist/content/locale.d.ts +18 -0
  11. package/dist/content/locale.d.ts.map +1 -0
  12. package/dist/content/locale.js +54 -0
  13. package/dist/content/locale.js.map +1 -0
  14. package/dist/content/overlay.d.ts +16 -0
  15. package/dist/content/overlay.d.ts.map +1 -0
  16. package/dist/content/overlay.js +20 -0
  17. package/dist/content/overlay.js.map +1 -0
  18. package/dist/content/site.d.ts +15 -0
  19. package/dist/content/site.d.ts.map +1 -0
  20. package/dist/content/site.js +26 -0
  21. package/dist/content/site.js.map +1 -0
  22. package/dist/content/strategy.d.ts +24 -0
  23. package/dist/content/strategy.d.ts.map +1 -0
  24. package/dist/content/strategy.js +15 -0
  25. package/dist/content/strategy.js.map +1 -0
  26. package/dist/delivery/client.d.ts +61 -0
  27. package/dist/delivery/client.d.ts.map +1 -0
  28. package/dist/delivery/client.js +88 -0
  29. package/dist/delivery/client.js.map +1 -0
  30. package/dist/delivery/query.d.ts +21 -0
  31. package/dist/delivery/query.d.ts.map +1 -0
  32. package/dist/delivery/query.js +49 -0
  33. package/dist/delivery/query.js.map +1 -0
  34. package/dist/errors.d.ts +32 -0
  35. package/dist/errors.d.ts.map +1 -0
  36. package/dist/errors.js +46 -0
  37. package/dist/errors.js.map +1 -0
  38. package/dist/guards.d.ts +42 -0
  39. package/dist/guards.d.ts.map +1 -0
  40. package/dist/guards.js +75 -0
  41. package/dist/guards.js.map +1 -0
  42. package/dist/index.d.ts +24 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +23 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/react/ContentProvider.d.ts +43 -0
  47. package/dist/react/ContentProvider.d.ts.map +1 -0
  48. package/dist/react/ContentProvider.js +36 -0
  49. package/dist/react/ContentProvider.js.map +1 -0
  50. package/dist/react/Experience.d.ts +54 -0
  51. package/dist/react/Experience.d.ts.map +1 -0
  52. package/dist/react/Experience.js +99 -0
  53. package/dist/react/Experience.js.map +1 -0
  54. package/dist/react/PresentationList.d.ts +14 -0
  55. package/dist/react/PresentationList.d.ts.map +1 -0
  56. package/dist/react/PresentationList.js +20 -0
  57. package/dist/react/PresentationList.js.map +1 -0
  58. package/dist/react/RenderPresentation.d.ts +20 -0
  59. package/dist/react/RenderPresentation.d.ts.map +1 -0
  60. package/dist/react/RenderPresentation.js +59 -0
  61. package/dist/react/RenderPresentation.js.map +1 -0
  62. package/dist/react/Resolve.d.ts +34 -0
  63. package/dist/react/Resolve.d.ts.map +1 -0
  64. package/dist/react/Resolve.js +79 -0
  65. package/dist/react/Resolve.js.map +1 -0
  66. package/dist/react/RichText.d.ts +19 -0
  67. package/dist/react/RichText.d.ts.map +1 -0
  68. package/dist/react/RichText.js +37 -0
  69. package/dist/react/RichText.js.map +1 -0
  70. package/dist/react/index.d.ts +15 -0
  71. package/dist/react/index.d.ts.map +1 -0
  72. package/dist/react/index.js +15 -0
  73. package/dist/react/index.js.map +1 -0
  74. package/dist/react/panels.d.ts +47 -0
  75. package/dist/react/panels.d.ts.map +1 -0
  76. package/dist/react/panels.js +92 -0
  77. package/dist/react/panels.js.map +1 -0
  78. package/dist/react/registry.d.ts +58 -0
  79. package/dist/react/registry.d.ts.map +1 -0
  80. package/dist/react/registry.js +92 -0
  81. package/dist/react/registry.js.map +1 -0
  82. package/dist/types.d.ts +187 -0
  83. package/dist/types.d.ts.map +1 -0
  84. package/dist/types.js +9 -0
  85. package/dist/types.js.map +1 -0
  86. package/package.json +55 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * How deep a response is expanded (spec 359 Business Logic §4).
3
+ *
4
+ * - `full` — one request, the server expands references `depth` levels (default **10**, the
5
+ * server's own cap, so the default means "as deep as the document goes"). SSR- and CDN-friendly;
6
+ * the only strategy that can render an Adapter-bearing binding.
7
+ * - `normalized` — descriptors only (default depth 0); the React crawl resolves each reference on
8
+ * demand via `resolveReference`. `depth: 1` is the hybrid: the page's own bindings arrive
9
+ * expanded, deeper references resolve on demand.
10
+ */
11
+ export type ResolveStrategy = {
12
+ strategy: 'full';
13
+ depth?: number;
14
+ } | {
15
+ strategy: 'normalized';
16
+ depth?: number;
17
+ };
18
+ /** The server's `MaxResolveDepth`. */
19
+ export declare const MAX_RESOLVE_DEPTH = 10;
20
+ export declare const DEFAULT_STRATEGY: ResolveStrategy;
21
+ export declare function depthFor(strategy: ResolveStrategy): number;
22
+ export declare function isNormalized(strategy: ResolveStrategy): boolean;
23
+ export declare function strategyKey(strategy: ResolveStrategy): string;
24
+ //# sourceMappingURL=strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../src/content/strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9C,sCAAsC;AACtC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,eAAO,MAAM,gBAAgB,EAAE,eAAgE,CAAA;AAE/F,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAI1D;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAE/D;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,15 @@
1
+ /** The server's `MaxResolveDepth`. */
2
+ export const MAX_RESOLVE_DEPTH = 10;
3
+ export const DEFAULT_STRATEGY = { strategy: 'full', depth: MAX_RESOLVE_DEPTH };
4
+ export function depthFor(strategy) {
5
+ const fallback = strategy.strategy === 'full' ? MAX_RESOLVE_DEPTH : 0;
6
+ const depth = strategy.depth ?? fallback;
7
+ return Math.max(0, Math.min(MAX_RESOLVE_DEPTH, Math.trunc(depth)));
8
+ }
9
+ export function isNormalized(strategy) {
10
+ return strategy.strategy === 'normalized';
11
+ }
12
+ export function strategyKey(strategy) {
13
+ return `${strategy.strategy}:${depthFor(strategy)}`;
14
+ }
15
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../src/content/strategy.ts"],"names":[],"mappings":"AAcA,sCAAsC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAA;AAE/F,MAAM,UAAU,QAAQ,CAAC,QAAyB;IAChD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;IACrE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAA;IACxC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAyB;IACpD,OAAO,QAAQ,CAAC,QAAQ,KAAK,YAAY,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAyB;IACnD,OAAO,GAAG,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AACrD,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { ComponentPage, ContextBag, ExpandedReference, LocaleTreeNode, PathResult, SiteSummary } from '../types.js';
2
+ export interface DeliveryClientOptions {
3
+ /**
4
+ * A Content **delivery** key (content-web → Delivery). A key with an allowed-origins or
5
+ * allowed-IP-ranges restriction is *browser-safe* and may ship in a bundle; a key with neither
6
+ * is a **server-side key** and must never reach a browser — it works from any origin and any
7
+ * address. The SDK cannot tell the two apart; only the Delivery page can. See
8
+ * docs/content-sdk.md before choosing where this client runs.
9
+ */
10
+ apiKey: string;
11
+ /** Defaults to ebitex's production API. Override for a self-hosted or local deployment. */
12
+ baseUrl?: string;
13
+ /** Injectable for testing or for a runtime with a non-global fetch. */
14
+ fetch?: typeof globalThis.fetch;
15
+ }
16
+ export interface RequestOptions {
17
+ signal?: AbortSignal;
18
+ }
19
+ /** Options shared by the two content-reading endpoints (docs/content-delivery-api.md §4, §6, §8). */
20
+ export interface ReadOptions extends RequestOptions {
21
+ /** One locale code. The server resolves its fallback chain; the high-level client picks the code. */
22
+ locale?: string;
23
+ /** Expansion depth (an integer, capped at 10 server-side). Omitted = `0`, descriptors only. */
24
+ resolve?: number;
25
+ /** Keep `Localizable` envelopes unresolved. Never sent by the high-level client. */
26
+ raw?: boolean;
27
+ /**
28
+ * The personalization context. **Present** = server-resolve (personalization collapsed, tokens
29
+ * injected); **absent** = client-resolve (unresolved variant-set envelopes come back).
30
+ */
31
+ ctx?: ContextBag;
32
+ }
33
+ export interface PathOptions extends ReadOptions {
34
+ /** A site's `rootNodeId` (from `listSites`). Required from a browser — the server's `Host` inference can only fire for a request arriving on the site's own hostname. */
35
+ site?: string;
36
+ }
37
+ export interface ListComponentsOptions extends RequestOptions {
38
+ /** A Contract id; matches Components of that Contract or any Contract inheriting from it. */
39
+ contract: string;
40
+ /** Category paths or ids — every one must match (AND), subtree-inclusive. */
41
+ category?: readonly string[];
42
+ /** 1–100; the server defaults to 20. */
43
+ limit?: number;
44
+ cursor?: string;
45
+ }
46
+ /** One method per endpoint of `/content/delivery/v1`, nothing opinionated — see `createContentClient` for the layer above. */
47
+ export interface DeliveryClient {
48
+ readonly baseUrl: string;
49
+ listSites(options?: RequestOptions): Promise<SiteSummary[]>;
50
+ listLocales(options?: RequestOptions): Promise<LocaleTreeNode[]>;
51
+ resolvePath(path: string, options?: PathOptions): Promise<PathResult>;
52
+ getComponent(provider: string, key: string, options?: ReadOptions): Promise<ExpandedReference>;
53
+ listComponents(options: ListComponentsOptions): Promise<ComponentPage>;
54
+ /**
55
+ * Raw bytes of a published-referenced blob — the **server-side** fallback for an SSR/build step
56
+ * that already holds the key. A browser should use a Blob value's own public `url` instead.
57
+ */
58
+ getBlob(blobId: string, options?: RequestOptions): Promise<Response>;
59
+ }
60
+ export declare function createDeliveryClient(options: DeliveryClientOptions): DeliveryClient;
61
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/delivery/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAGxH,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,qGAAqG;AACrG,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,qGAAqG;IACrG,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+FAA+F;IAC/F,OAAO,CAAC,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@
1
+ import { ContentDeliveryError } from '../errors.js';
2
+ import { buildUrl, normalizePath, segment, serializeContext } from './query.js';
3
+ const DEFAULT_BASE_URL = 'https://api.ebitex.io';
4
+ const GROUP = '/content/delivery/v1';
5
+ export function createDeliveryClient(options) {
6
+ const { apiKey } = options;
7
+ if (!apiKey) {
8
+ throw new Error('createDeliveryClient requires an apiKey.');
9
+ }
10
+ const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
11
+ const doFetch = options.fetch ?? globalThis.fetch;
12
+ async function request(url, signal) {
13
+ const response = await doFetch(url, {
14
+ headers: {
15
+ Authorization: `Bearer ${apiKey}`,
16
+ Accept: 'application/json',
17
+ },
18
+ signal,
19
+ });
20
+ if (!response.ok) {
21
+ const body = await readBody(response);
22
+ throw new ContentDeliveryError(response.status, body, readRetryAfter(response, body));
23
+ }
24
+ return response;
25
+ }
26
+ async function json(url, signal) {
27
+ const response = await request(url, signal);
28
+ return (await response.json());
29
+ }
30
+ function readParams(o) {
31
+ return {
32
+ locale: o.locale,
33
+ resolve: o.resolve,
34
+ raw: o.raw,
35
+ ctx: o.ctx === undefined ? undefined : serializeContext(o.ctx),
36
+ };
37
+ }
38
+ return {
39
+ baseUrl,
40
+ listSites(o = {}) {
41
+ return json(buildUrl(baseUrl, `${GROUP}/sites`), o.signal);
42
+ },
43
+ listLocales(o = {}) {
44
+ return json(buildUrl(baseUrl, `${GROUP}/locales`), o.signal);
45
+ },
46
+ resolvePath(path, o = {}) {
47
+ const normalized = normalizePath(path);
48
+ const url = buildUrl(baseUrl, `${GROUP}/path${normalized === '/' ? '/' : normalized}`, { site: o.site, ...readParams(o) });
49
+ return json(url, o.signal);
50
+ },
51
+ getComponent(provider, key, o = {}) {
52
+ return json(buildUrl(baseUrl, `${GROUP}/components/${segment(provider)}/${segment(key)}`, readParams(o)), o.signal);
53
+ },
54
+ listComponents(o) {
55
+ return json(buildUrl(baseUrl, `${GROUP}/components`, { contract: o.contract, category: o.category, limit: o.limit, cursor: o.cursor }), o.signal);
56
+ },
57
+ getBlob(blobId, o = {}) {
58
+ return request(buildUrl(baseUrl, `${GROUP}/blobs/${segment(blobId)}`), o.signal);
59
+ },
60
+ };
61
+ }
62
+ /** Error bodies are JSON in every documented case, but a proxy or gateway can return HTML — don't throw while building an error. */
63
+ async function readBody(response) {
64
+ try {
65
+ return await response.json();
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ }
71
+ /** `Retry-After` (seconds) first; the failed-authentication penalty also puts `retryAfterSeconds` in its body. */
72
+ function readRetryAfter(response, body) {
73
+ const header = response.headers.get('Retry-After');
74
+ if (header !== null) {
75
+ const seconds = Number(header);
76
+ if (Number.isFinite(seconds)) {
77
+ return seconds;
78
+ }
79
+ }
80
+ if (typeof body === 'object' && body !== null && 'retryAfterSeconds' in body) {
81
+ const seconds = body.retryAfterSeconds;
82
+ if (typeof seconds === 'number') {
83
+ return seconds;
84
+ }
85
+ }
86
+ return null;
87
+ }
88
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/delivery/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAoE/E,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AAChD,MAAM,KAAK,GAAG,sBAAsB,CAAA;AAEpC,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CA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,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,KAAK,UAAU,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;QAClF,CAAC;KACF,CAAA;AACH,CAAC;AAED,oIAAoI;AACpI,KAAK,UAAU,QAAQ,CAAC,QAAkB;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,kHAAkH;AAClH,SAAS,cAAc,CAAC,QAAkB,EAAE,IAAa;IACvD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAClD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,OAAO,OAAO,CAAA;QAChB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,mBAAmB,IAAI,IAAI,EAAE,CAAC;QAC7E,MAAM,OAAO,GAAI,IAAuC,CAAC,iBAAiB,CAAA;QAC1E,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,CAAA;QAChB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ContextBag } from '../types.js';
2
+ export type QueryValue = string | number | boolean | undefined | null | readonly string[];
3
+ /**
4
+ * Builds a request URL. An `undefined`/`null` parameter is not emitted at all, so the URL for "no
5
+ * options" is byte-identical to a hand-written one — a consumer's CDN keys its cache on the URL,
6
+ * and `?resolve=0&raw=false` would be a different key from nothing. An array parameter is
7
+ * repeated per value (`category=a&category=b`, the API's own form).
8
+ */
9
+ export declare function buildUrl(baseUrl: string, path: string, params?: Record<string, QueryValue>): string;
10
+ /**
11
+ * Serializes the context bag with **stable key order**, so two equal bags produce one string —
12
+ * one cache key here, one CDN-cacheable URL downstream. The bag is flat by the server's own rule
13
+ * (`ContextBagParser`: scalars and string lists only), so sorting the top level is sufficient.
14
+ * `undefined` properties are dropped, since JSON has no way to carry them anyway.
15
+ */
16
+ export declare function serializeContext(bag: ContextBag): string;
17
+ /** The server's own normalization (`"/" + path.Trim('/')`), applied client-side so cache keys agree with what is requested. */
18
+ export declare function normalizePath(path: string): string;
19
+ /** Encodes one path segment for a route parameter (a provider name, a Component key, a blob id). */
20
+ export declare function segment(value: string): string;
21
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/delivery/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,MAAM,EAAE,CAAA;AAEzF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAM,GAAG,MAAM,CAkBvG;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAUxD;AAED,+HAA+H;AAC/H,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Builds a request URL. An `undefined`/`null` parameter is not emitted at all, so the URL for "no
3
+ * options" is byte-identical to a hand-written one — a consumer's CDN keys its cache on the URL,
4
+ * and `?resolve=0&raw=false` would be a different key from nothing. An array parameter is
5
+ * repeated per value (`category=a&category=b`, the API's own form).
6
+ */
7
+ export function buildUrl(baseUrl, path, params = {}) {
8
+ const search = new URLSearchParams();
9
+ for (const [name, value] of Object.entries(params)) {
10
+ if (value === undefined || value === null) {
11
+ continue;
12
+ }
13
+ if (Array.isArray(value)) {
14
+ for (const item of value) {
15
+ search.append(name, item);
16
+ }
17
+ }
18
+ else {
19
+ search.append(name, String(value));
20
+ }
21
+ }
22
+ const query = search.toString();
23
+ return `${baseUrl}${path}${query ? `?${query}` : ''}`;
24
+ }
25
+ /**
26
+ * Serializes the context bag with **stable key order**, so two equal bags produce one string —
27
+ * one cache key here, one CDN-cacheable URL downstream. The bag is flat by the server's own rule
28
+ * (`ContextBagParser`: scalars and string lists only), so sorting the top level is sufficient.
29
+ * `undefined` properties are dropped, since JSON has no way to carry them anyway.
30
+ */
31
+ export function serializeContext(bag) {
32
+ const ordered = {};
33
+ for (const key of Object.keys(bag).sort()) {
34
+ const value = bag[key];
35
+ if (value !== undefined) {
36
+ ordered[key] = value;
37
+ }
38
+ }
39
+ return JSON.stringify(ordered);
40
+ }
41
+ /** The server's own normalization (`"/" + path.Trim('/')`), applied client-side so cache keys agree with what is requested. */
42
+ export function normalizePath(path) {
43
+ return '/' + path.replace(/^\/+|\/+$/g, '');
44
+ }
45
+ /** Encodes one path segment for a route parameter (a provider name, a Component key, a blob id). */
46
+ export function segment(value) {
47
+ return encodeURIComponent(value);
48
+ }
49
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/delivery/query.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAY,EAAE,SAAqC,EAAE;IAC7F,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,KAAK,MAAM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;AAED,oGAAoG;AACpG,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;AAClC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A non-2xx response from the Content Delivery API. `status` and `code` (the body's `error`
3
+ * string — `null` when the body wasn't the documented JSON shape, e.g. an HTML page from a proxy)
4
+ * let a caller branch on the documented failures rather than parse prose:
5
+ * `missing_api_key`/`invalid_api_key` (401), `scope_denied`/`origin_denied`/`ip_denied`/
6
+ * `app_not_available` (403), `payment_required` (402), `path_not_found`/`not_published` (404),
7
+ * `invalid_context`/`unknown_category`/`validation_failed` (400), `quota_exceeded`/
8
+ * `too_many_failed_authentications` (429 — `retryAfterSeconds` is set).
9
+ */
10
+ export declare class ContentDeliveryError extends Error {
11
+ readonly status: number;
12
+ readonly code: string | null;
13
+ readonly body: unknown;
14
+ readonly retryAfterSeconds: number | null;
15
+ constructor(status: number, body: unknown, retryAfterSeconds?: number | null);
16
+ }
17
+ export type ContentSdkErrorCode =
18
+ /** More than one published site and nothing to pick one by — configure `site` (see docs/content-sdk.md). */
19
+ 'site_unresolved'
20
+ /** An Adapter-bearing binding cannot be resolved client-side (docs/content-delivery-api.md §5b) — use the `full` strategy or `depth ≥ 1`. */
21
+ | 'adapter_requires_server_resolve'
22
+ /** A renderer's lazy loader rejected or exported no default. */
23
+ | 'renderer_load_failed' | 'invalid_options';
24
+ /** A client-side condition the SDK detected itself — no HTTP response is involved. */
25
+ export declare class ContentSdkError extends Error {
26
+ readonly code: ContentSdkErrorCode;
27
+ readonly details: Record<string, unknown> | undefined;
28
+ constructor(code: ContentSdkErrorCode, message: string, details?: Record<string, unknown>);
29
+ }
30
+ /** True for a `DOMException`/`Error` named `AbortError` — the rejection an aborted `fetch` (or the SDK's own cancellation) produces. */
31
+ export declare function isAbortError(error: unknown): boolean;
32
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;gBAE7B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAE,MAAM,GAAG,IAAW;CASnF;AAUD,MAAM,MAAM,mBAAmB;AAC7B,4GAA4G;AAC1G,iBAAiB;AACnB,6IAA6I;GAC3I,iCAAiC;AACnC,gEAAgE;GAC9D,sBAAsB,GACtB,iBAAiB,CAAA;AAErB,sFAAsF;AACtF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAA;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;gBAEzC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAM1F;AAED,wIAAwI;AACxI,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD"}
package/dist/errors.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A non-2xx response from the Content Delivery API. `status` and `code` (the body's `error`
3
+ * string — `null` when the body wasn't the documented JSON shape, e.g. an HTML page from a proxy)
4
+ * let a caller branch on the documented failures rather than parse prose:
5
+ * `missing_api_key`/`invalid_api_key` (401), `scope_denied`/`origin_denied`/`ip_denied`/
6
+ * `app_not_available` (403), `payment_required` (402), `path_not_found`/`not_published` (404),
7
+ * `invalid_context`/`unknown_category`/`validation_failed` (400), `quota_exceeded`/
8
+ * `too_many_failed_authentications` (429 — `retryAfterSeconds` is set).
9
+ */
10
+ export class ContentDeliveryError extends Error {
11
+ status;
12
+ code;
13
+ body;
14
+ retryAfterSeconds;
15
+ constructor(status, body, retryAfterSeconds = null) {
16
+ const code = readCode(body);
17
+ super(`ebitex Content Delivery API request failed with status ${status}${code ? ` (${code})` : ''}`);
18
+ this.name = 'ContentDeliveryError';
19
+ this.status = status;
20
+ this.code = code;
21
+ this.body = body;
22
+ this.retryAfterSeconds = retryAfterSeconds;
23
+ }
24
+ }
25
+ function readCode(body) {
26
+ if (typeof body === 'object' && body !== null && 'error' in body && typeof body.error === 'string') {
27
+ return body.error;
28
+ }
29
+ return null;
30
+ }
31
+ /** A client-side condition the SDK detected itself — no HTTP response is involved. */
32
+ export class ContentSdkError extends Error {
33
+ code;
34
+ details;
35
+ constructor(code, message, details) {
36
+ super(message);
37
+ this.name = 'ContentSdkError';
38
+ this.code = code;
39
+ this.details = details;
40
+ }
41
+ }
42
+ /** True for a `DOMException`/`Error` named `AbortError` — the rejection an aborted `fetch` (or the SDK's own cancellation) produces. */
43
+ export function isAbortError(error) {
44
+ return typeof error === 'object' && error !== null && error.name === 'AbortError';
45
+ }
46
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,MAAM,CAAQ;IACd,IAAI,CAAe;IACnB,IAAI,CAAS;IACb,iBAAiB,CAAe;IAEzC,YAAY,MAAc,EAAE,IAAa,EAAE,oBAAmC,IAAI;QAChF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC3B,KAAK,CAAC,0DAA0D,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACpG,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,IAAa;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,OAAQ,IAA2B,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3H,OAAQ,IAA0B,CAAC,KAAK,CAAA;IAC1C,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAWD,sFAAsF;AACtF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAqB;IACzB,OAAO,CAAqC;IAErD,YAAY,IAAyB,EAAE,OAAe,EAAE,OAAiC;QACvF,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED,wIAAwI;AACxI,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAA4B,CAAC,IAAI,KAAK,YAAY,CAAA;AAC3G,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { BlobValue, CategoryDescriptor, ComponentValue, ContentDocument, InlineValue, LinkValue, PresentationEnvelope, RenderableComponentValue, RichTextFragment, RichTextValue, UnresolvableReference } from './types.js';
2
+ /**
3
+ * Runtime guards for every branch a renderer has to decide on from a value alone
4
+ * (docs/content-delivery-api.md §3b's "three rules"). Each is a structural check on the delivered
5
+ * shape, not a check against a Contract — the SDK never knows which field type a value came from.
6
+ */
7
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
8
+ /** `template` + `component` — a Presentation envelope. */
9
+ export declare function isPresentationEnvelope(value: unknown): value is PresentationEnvelope;
10
+ /** `provider` + `key` — a reference (expanded or not). */
11
+ export declare function isReference(value: unknown): value is ComponentValue & {
12
+ provider: string;
13
+ key: string;
14
+ };
15
+ /** `contract` + `content` with no `provider`/`key` — authored in place. */
16
+ export declare function isInline(value: unknown): value is InlineValue;
17
+ /** `content` is present — the one "resolved here" signal (§3b). True for an inline value and an expanded reference alike. */
18
+ export declare function isResolved<T extends ContentDocument = ContentDocument>(value: unknown): value is RenderableComponentValue<T>;
19
+ export declare function isUnresolvable(value: unknown): value is UnresolvableReference;
20
+ /** The binding carries an Adapter — renderable only once the server has expanded it (§5b). */
21
+ export declare function hasAdapter(value: unknown): value is ComponentValue & {
22
+ adapter: Record<string, unknown>;
23
+ };
24
+ /** A component value — any row of §3b's table. */
25
+ export declare function isComponentValue(value: unknown): value is ComponentValue;
26
+ export declare function isRichTextFragment(value: unknown): value is RichTextFragment;
27
+ /** An ordered fragment array (§9). An empty array is a valid, empty RichText value. */
28
+ export declare function isRichText(value: unknown): value is RichTextValue;
29
+ /** `kind` + `url` — `query`/`anchor` appear only when authored, and `resolved` was absent on an external arm before spec 359's server fix, so neither is required here. */
30
+ export declare function isLinkValue(value: unknown): value is LinkValue;
31
+ export declare function isBlobValue(value: unknown): value is BlobValue;
32
+ export declare function isCategoryDescriptor(value: unknown): value is CategoryDescriptor;
33
+ /**
34
+ * An **unresolved** variant-set envelope (`{ variants, default }`) — only ever present in a
35
+ * client-resolve response (`ctx` omitted). The high-level client always sends `ctx`, so seeing one
36
+ * means a low-level call bypassed it; the renderer treats it as unsupported rather than guessing.
37
+ */
38
+ export declare function isVariantSetEnvelope(value: unknown): value is {
39
+ variants: unknown[];
40
+ default: unknown;
41
+ };
42
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
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AE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAiB5E;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEjE;AAED,2KAA2K;AAC3K,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAEvG"}
package/dist/guards.js ADDED
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Runtime guards for every branch a renderer has to decide on from a value alone
3
+ * (docs/content-delivery-api.md §3b's "three rules"). Each is a structural check on the delivered
4
+ * shape, not a check against a Contract — the SDK never knows which field type a value came from.
5
+ */
6
+ export function isRecord(value) {
7
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
8
+ }
9
+ /** `template` + `component` — a Presentation envelope. */
10
+ export function isPresentationEnvelope(value) {
11
+ return isRecord(value) && isRecord(value.template) && typeof value.template.id === 'string' && isRecord(value.component);
12
+ }
13
+ /** `provider` + `key` — a reference (expanded or not). */
14
+ export function isReference(value) {
15
+ return isRecord(value) && typeof value.provider === 'string' && typeof value.key === 'string';
16
+ }
17
+ /** `contract` + `content` with no `provider`/`key` — authored in place. */
18
+ export function isInline(value) {
19
+ return isRecord(value) && !isReference(value) && isRecord(value.contract) && 'content' in value && value.content !== undefined;
20
+ }
21
+ /** `content` is present — the one "resolved here" signal (§3b). True for an inline value and an expanded reference alike. */
22
+ export function isResolved(value) {
23
+ return isRecord(value) && 'content' in value && value.content !== undefined && value.unresolvable !== true;
24
+ }
25
+ export function isUnresolvable(value) {
26
+ return isRecord(value) && value.unresolvable === true;
27
+ }
28
+ /** The binding carries an Adapter — renderable only once the server has expanded it (§5b). */
29
+ export function hasAdapter(value) {
30
+ return isRecord(value) && isRecord(value.adapter);
31
+ }
32
+ /** A component value — any row of §3b's table. */
33
+ export function isComponentValue(value) {
34
+ return isReference(value) || isInline(value);
35
+ }
36
+ export function isRichTextFragment(value) {
37
+ if (!isRecord(value)) {
38
+ return false;
39
+ }
40
+ switch (value.kind) {
41
+ case 'markdown':
42
+ return typeof value.markdown === 'string';
43
+ case 'presentation':
44
+ return isPresentationEnvelope(value.presentation);
45
+ case 'reference':
46
+ return isReference(value.reference);
47
+ case 'personalized':
48
+ return Array.isArray(value.default) && Array.isArray(value.variants);
49
+ default:
50
+ return false;
51
+ }
52
+ }
53
+ /** An ordered fragment array (§9). An empty array is a valid, empty RichText value. */
54
+ export function isRichText(value) {
55
+ return Array.isArray(value) && value.every(isRichTextFragment);
56
+ }
57
+ /** `kind` + `url` — `query`/`anchor` appear only when authored, and `resolved` was absent on an external arm before spec 359's server fix, so neither is required here. */
58
+ export function isLinkValue(value) {
59
+ return isRecord(value) && (value.kind === 'experience' || value.kind === 'external') && 'url' in value;
60
+ }
61
+ export function isBlobValue(value) {
62
+ return isRecord(value) && typeof value.blobId === 'string' && typeof value.url === 'string' && typeof value.contentType === 'string';
63
+ }
64
+ export function isCategoryDescriptor(value) {
65
+ return isRecord(value) && typeof value.path === 'string' && typeof value.groupExternalId === 'string' && typeof value.provider === 'string' && 'value' in value;
66
+ }
67
+ /**
68
+ * An **unresolved** variant-set envelope (`{ variants, default }`) — only ever present in a
69
+ * client-resolve response (`ctx` omitted). The high-level client always sends `ctx`, so seeing one
70
+ * means a low-level call bypassed it; the renderer treats it as unsupported rather than guessing.
71
+ */
72
+ export function isVariantSetEnvelope(value) {
73
+ return isRecord(value) && Array.isArray(value.variants) && 'default' in value;
74
+ }
75
+ //# sourceMappingURL=gu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,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,KAAK,IAAI,KAAK,CAAA;AACxG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,CAAA;AACtI,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,eAAe,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,CAAA;AACjK,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,SAAS,IAAI,KAAK,CAAA;AAC/E,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@ebitex/content-sdk` — the framework-agnostic half.
3
+ *
4
+ * - **Low-level**: `createDeliveryClient` — one method per Content Delivery API endpoint, the
5
+ * delivered vocabulary as types (`types.ts`) and runtime guards (`guards.ts`), typed errors.
6
+ * - **High-level**: `createContentClient` — `resolveLocation(location)` for router changes: site
7
+ * from the page's own host, locale from the browser's languages against the organization's
8
+ * tree, the context bag, a `full`/`normalized` resolve strategy, caching and cancellation.
9
+ *
10
+ * Nothing here imports React; the rendering layer is `@ebitex/content-sdk/react`. Both clients
11
+ * run in a browser (with a **browser-safe** delivery key) and in Node (any key).
12
+ */
13
+ export { createDeliveryClient, type DeliveryClient, type DeliveryClientOptions, type ListComponentsOptions, type PathOptions, type ReadOptions, type RequestOptions, } from './delivery/client.js';
14
+ export { buildUrl, normalizePath, serializeContext } from './delivery/query.js';
15
+ export { createContentClient, type ContentClient, type ContentClientOptions, type ExperienceResult, type LocationLike, type NotFoundExperience, type PresentationExperience, type RedirectExperience, type ResolveOverrides, type ResolvedSite, } from './content/client.js';
16
+ export { DEFAULT_STRATEGY, MAX_RESOLVE_DEPTH, depthFor, type ResolveStrategy } from './content/strategy.js';
17
+ export { applyContextualOverlay } from './content/overlay.js';
18
+ export { expandLanguageCandidates, selectLocale } from './content/locale.js';
19
+ export { matchSite } from './content/site.js';
20
+ export { RequestCache, type CacheOptions } from './content/cache.js';
21
+ export { ContentDeliveryError, ContentSdkError, isAbortError, type ContentSdkErrorCode } from './errors.js';
22
+ export { hasAdapter, isBlobValue, isCategoryDescriptor, isComponentValue, isInline, isLinkValue, isPresentationEnvelope, isRecord, isReference, isResolved, isRichText, isRichTextFragment, isUnresolvable, isVariantSetEnvelope, } from './guards.js';
23
+ export type { AdapterDescriptor, AdapterWarning, BagPropertyValue, BagValue, BlobValue, CategoryDescriptor, ComponentListItem, ComponentPage, ComponentValue, ContentDocument, ContextBag, EntityDescriptor, ExpandedReference, ExperienceLink, ExternalLink, InlineValue, LinkValue, LocaleTreeNode, MarkdownFragment, PathResult, PersonalizedFragment, PresentationEnvelope, PresentationFragment, PresentationPathResult, RedirectPathResult, ReferenceFragment, RenderableComponentValue, RichTextFragment, RichTextValue, SiteSummary, UnexpandedReference, UnresolvableReference, } from './types.js';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,Q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oB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `@ebitex/content-sdk` — the framework-agnostic half.
3
+ *
4
+ * - **Low-level**: `createDeliveryClient` — one method per Content Delivery API endpoint, the
5
+ * delivered vocabulary as types (`types.ts`) and runtime guards (`guards.ts`), typed errors.
6
+ * - **High-level**: `createContentClient` — `resolveLocation(location)` for router changes: site
7
+ * from the page's own host, locale from the browser's languages against the organization's
8
+ * tree, the context bag, a `full`/`normalized` resolve strategy, caching and cancellation.
9
+ *
10
+ * Nothing here imports React; the rendering layer is `@ebitex/content-sdk/react`. Both clients
11
+ * run in a browser (with a **browser-safe** delivery key) and in Node (any key).
12
+ */
13
+ export { createDeliveryClient, } from './delivery/client.js';
14
+ export { buildUrl, normalizePath, serializeContext } from './delivery/query.js';
15
+ export { createContentClient, } from './content/client.js';
16
+ export { DEFAULT_STRATEGY, MAX_RESOLVE_DEPTH, depthFor } from './content/strategy.js';
17
+ export { applyContextualOverlay } from './content/overlay.js';
18
+ export { expandLanguageCandidates, selectLocale } from './content/locale.js';
19
+ export { matchSite } from './content/site.js';
20
+ export { RequestCache } from './content/cache.js';
21
+ export { ContentDeliveryError, ContentSdkError, isAbortError } from './errors.js';
22
+ export { hasAdapter, isBlobValue, isCategoryDescriptor, isComponentValue, isInline, isLinkValue, isPresentationEnvelope, isRecord, isReference, isResolved, isRichText, isRichTextFragment, isUnresolvable, isVariantSetEnvelope, } from './guards.js';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,oBAAoB,GAOrB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE/E,OAAO,EACL,mBAAmB,GAUpB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,QAAQ,EAAwB,MAAM,uBAAuB,CAAA;AAC3G,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAA;AAEpE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,EAA4B,MAAM,aAAa,CAAA;AAE3G,OAAO,EACL,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,sBAAsB,EACtB,QAAQ,EACR,WAAW,EACX,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,GACrB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import type { ContentClient } from '../content/client.js';
3
+ import type { ResolveStrategy } from '../content/strategy.js';
4
+ import { type ContentErrorProps, type UnresolvedPresentationProps } from './panels.js';
5
+ import { RendererRegistry, type Renderers } from './registry.js';
6
+ export interface MarkdownRendererProps {
7
+ markdown: string;
8
+ }
9
+ export interface ContentProviderProps {
10
+ /**
11
+ * Optional: a tree with renderers but no client still renders a pre-resolved document
12
+ * (`<Experience result>`), which is the SSR path and the seam a live-preview bridge injects
13
+ * through. Required for the hook-driven `<Experience path>` and the normalized strategy.
14
+ */
15
+ client?: ContentClient;
16
+ renderers: Renderers;
17
+ /** Renders a RichText `markdown` fragment. Without one, the default shows the source with a note — see docs/content-sdk.md for the recommended recipe. */
18
+ markdown?: ComponentType<MarkdownRendererProps>;
19
+ /** Replaces the default developer-facing panel for a Presentation that cannot be rendered. */
20
+ fallback?: ComponentType<UnresolvedPresentationProps>;
21
+ /** Rendered while a renderer loads or a reference resolves. Defaults to nothing. */
22
+ loading?: ReactNode;
23
+ /** Replaces the default developer-facing error panel. */
24
+ errorFallback?: ComponentType<ContentErrorProps>;
25
+ children?: ReactNode;
26
+ }
27
+ export interface ContentContextValue {
28
+ client: ContentClient | undefined;
29
+ registry: RendererRegistry;
30
+ Markdown: ComponentType<MarkdownRendererProps> | undefined;
31
+ Fallback: ComponentType<UnresolvedPresentationProps>;
32
+ loading: ReactNode;
33
+ ErrorFallback: ComponentType<ContentErrorProps>;
34
+ }
35
+ export declare function ContentProvider({ client, renderers, markdown, fallback, loading, errorFallback, children }: ContentProviderProps): ReactNode;
36
+ export declare function useContentContext(): ContentContextValue;
37
+ export declare function StrategyScope({ strategy, children }: {
38
+ strategy: ResolveStrategy;
39
+ children?: ReactNode;
40
+ }): ReactNode;
41
+ /** The effective strategy: the enclosing `<Experience>`'s, else the client's, else `full`. */
42
+ export declare function useResolveStrategy(): ResolveStrategy;
43
+ //# sourceMappingURL=ContentProvider.d.ts.map