@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.
- package/README.md +62 -0
- package/dist/content/cache.d.ts +26 -0
- package/dist/content/cache.d.ts.map +1 -0
- package/dist/content/cache.js +107 -0
- package/dist/content/cache.js.map +1 -0
- package/dist/content/client.d.ts +78 -0
- package/dist/content/client.d.ts.map +1 -0
- package/dist/content/client.js +150 -0
- package/dist/content/client.js.map +1 -0
- package/dist/content/locale.d.ts +18 -0
- package/dist/content/locale.d.ts.map +1 -0
- package/dist/content/locale.js +54 -0
- package/dist/content/locale.js.map +1 -0
- package/dist/content/overlay.d.ts +16 -0
- package/dist/content/overlay.d.ts.map +1 -0
- package/dist/content/overlay.js +20 -0
- package/dist/content/overlay.js.map +1 -0
- package/dist/content/site.d.ts +15 -0
- package/dist/content/site.d.ts.map +1 -0
- package/dist/content/site.js +26 -0
- package/dist/content/site.js.map +1 -0
- package/dist/content/strategy.d.ts +24 -0
- package/dist/content/strategy.d.ts.map +1 -0
- package/dist/content/strategy.js +15 -0
- package/dist/content/strategy.js.map +1 -0
- package/dist/delivery/client.d.ts +61 -0
- package/dist/delivery/client.d.ts.map +1 -0
- package/dist/delivery/client.js +88 -0
- package/dist/delivery/client.js.map +1 -0
- package/dist/delivery/query.d.ts +21 -0
- package/dist/delivery/query.d.ts.map +1 -0
- package/dist/delivery/query.js +49 -0
- package/dist/delivery/query.js.map +1 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +46 -0
- package/dist/errors.js.map +1 -0
- package/dist/guards.d.ts +42 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +75 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/react/ContentProvider.d.ts +43 -0
- package/dist/react/ContentProvider.d.ts.map +1 -0
- package/dist/react/ContentProvider.js +36 -0
- package/dist/react/ContentProvider.js.map +1 -0
- package/dist/react/Experience.d.ts +54 -0
- package/dist/react/Experience.d.ts.map +1 -0
- package/dist/react/Experience.js +99 -0
- package/dist/react/Experience.js.map +1 -0
- package/dist/react/PresentationList.d.ts +14 -0
- package/dist/react/PresentationList.d.ts.map +1 -0
- package/dist/react/PresentationList.js +20 -0
- package/dist/react/PresentationList.js.map +1 -0
- package/dist/react/RenderPresentation.d.ts +20 -0
- package/dist/react/RenderPresentation.d.ts.map +1 -0
- package/dist/react/RenderPresentation.js +59 -0
- package/dist/react/RenderPresentation.js.map +1 -0
- package/dist/react/Resolve.d.ts +34 -0
- package/dist/react/Resolve.d.ts.map +1 -0
- package/dist/react/Resolve.js +79 -0
- package/dist/react/Resolve.js.map +1 -0
- package/dist/react/RichText.d.ts +19 -0
- package/dist/react/RichText.d.ts.map +1 -0
- package/dist/react/RichText.js +37 -0
- package/dist/react/RichText.js.map +1 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +15 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/panels.d.ts +47 -0
- package/dist/react/panels.d.ts.map +1 -0
- package/dist/react/panels.js +92 -0
- package/dist/react/panels.js.map +1 -0
- package/dist/react/registry.d.ts +58 -0
- package/dist/react/registry.d.ts.map +1 -0
- package/dist/react/registry.js +92 -0
- package/dist/react/registry.js.map +1 -0
- package/dist/types.d.ts +187 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { EntityDescriptor } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Why a Presentation could not be handed to a renderer. Closed set — each has a remedy the
|
|
5
|
+
* default panel shows, and a consumer replacing the panel gets the same props.
|
|
6
|
+
*/
|
|
7
|
+
export type FallbackReason =
|
|
8
|
+
/** No renderer registered for `template.externalId`. */
|
|
9
|
+
'not_registered'
|
|
10
|
+
/** The renderer's lazy loader rejected or exported no default component. */
|
|
11
|
+
| 'load_failed'
|
|
12
|
+
/** The server attempted the bound Component and could not resolve it (§5). */
|
|
13
|
+
| 'unresolvable'
|
|
14
|
+
/** An unexpanded reference under the `full` strategy — the response ran out of depth (or the server's expansion budget). */
|
|
15
|
+
| 'depth_exceeded'
|
|
16
|
+
/** An Adapter-bearing binding that only the server can apply (§5b), met under the normalized strategy. */
|
|
17
|
+
| 'adapter_requires_server_resolve'
|
|
18
|
+
/** The normalized strategy's own fetch of the reference failed. */
|
|
19
|
+
| 'resolve_failed'
|
|
20
|
+
/** An unresolved variant-set envelope — a client-resolve response the renderer does not support. */
|
|
21
|
+
| 'client_resolve_unsupported'
|
|
22
|
+
/** A RichText `reference` fragment with no `renderReference` provided — there is no Template to dispatch on. */
|
|
23
|
+
| 'reference_needs_renderer';
|
|
24
|
+
export interface UnresolvedPresentationProps {
|
|
25
|
+
reason: FallbackReason;
|
|
26
|
+
/** One line telling the implementor what to do. */
|
|
27
|
+
remedy: string;
|
|
28
|
+
template?: EntityDescriptor;
|
|
29
|
+
/** The envelope (or fragment) as delivered, for the details view. */
|
|
30
|
+
envelope: unknown;
|
|
31
|
+
error?: unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare const REMEDIES: Record<FallbackReason, (template: EntityDescriptor | undefined) => string>;
|
|
34
|
+
/**
|
|
35
|
+
* The default fallback: a developer-facing panel naming the Template, the reason, the remedy, the
|
|
36
|
+
* bound Contract and its available fields, and the envelope JSON. Renders in production too — an
|
|
37
|
+
* honest hole beats a silent one. Replace it via `<ContentProvider fallback>`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function UnresolvedPresentation({ reason, remedy, template, envelope, error }: UnresolvedPresentationProps): ReactNode;
|
|
40
|
+
export interface ContentErrorProps {
|
|
41
|
+
error: unknown;
|
|
42
|
+
/** The path being resolved, when known. */
|
|
43
|
+
path?: string;
|
|
44
|
+
}
|
|
45
|
+
/** The default error panel — developer-facing, with the documented remedy per error code. Replace it via `<ContentProvider errorFallback>`. */
|
|
46
|
+
export declare function ContentError({ error, path }: ContentErrorProps): ReactNode;
|
|
47
|
+
//# sourceMappingURL=panels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/react/panels.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc;AACxB,wDAAwD;AACtD,gBAAgB;AAClB,4EAA4E;GAC1E,aAAa;AACf,8EAA8E;GAC5E,cAAc;AAChB,4HAA4H;GAC1H,gBAAgB;AAClB,0GAA0G;GACxG,iCAAiC;AACnC,mEAAmE;GACjE,gBAAgB;AAClB,oGAAoG;GAClG,4BAA4B;AAC9B,gHAAgH;GAC9G,0BAA0B,CAAA;AAE9B,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,cAAc,CAAA;IACtB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IAC3B,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,KAAK,MAAM,CAU/F,CAAA;AAaD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,2BAA2B,GAAG,SAAS,CA8B5H;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,OAAO,CAAA;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAeD,+IAA+I;AAC/I,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,iBAAiB,GAAG,SAAS,CA8B1E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ContentDeliveryError, ContentSdkError } from '../errors.js';
|
|
3
|
+
import { isRecord, isResolved } from '../guards.js';
|
|
4
|
+
export const REMEDIES = {
|
|
5
|
+
not_registered: (t) => `Add presentations/${t?.externalId ?? '<externalId>'}.tsx with a default export, or register "${t?.externalId ?? '<externalId>'}" in <ContentProvider renderers>.`,
|
|
6
|
+
load_failed: (t) => `The renderer for "${t?.externalId ?? '<externalId>'}" failed to load — check the error below and that the module has a default export.`,
|
|
7
|
+
unresolvable: () => 'The bound Component is not published (or its provider could not resolve it). Publish it, or bind another one.',
|
|
8
|
+
depth_exceeded: () => "This binding was not expanded in the response — use the 'full' strategy with a higher depth, or the 'normalized' strategy to resolve it on demand.",
|
|
9
|
+
adapter_requires_server_resolve: () => "This binding carries an Adapter, which only the server can apply — use the 'full' strategy, or a normalized depth ≥ 1.",
|
|
10
|
+
resolve_failed: () => 'Fetching the bound Component failed — see the error below.',
|
|
11
|
+
client_resolve_unsupported: () => 'This value is an unresolved personalization envelope. Request it with a ctx (the high-level client always does) so the server resolves it.',
|
|
12
|
+
reference_needs_renderer: () => 'A RichText reference fragment has no Template to dispatch on — pass renderReference to <RichText>.',
|
|
13
|
+
};
|
|
14
|
+
const TITLES = {
|
|
15
|
+
not_registered: 'has no renderer',
|
|
16
|
+
load_failed: 'failed to load its renderer',
|
|
17
|
+
unresolvable: 'is bound to an unresolvable Component',
|
|
18
|
+
depth_exceeded: 'was not expanded',
|
|
19
|
+
adapter_requires_server_resolve: 'needs server-side resolution',
|
|
20
|
+
resolve_failed: 'could not be resolved',
|
|
21
|
+
client_resolve_unsupported: 'is an unresolved personalization envelope',
|
|
22
|
+
reference_needs_renderer: 'has no reference renderer',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The default fallback: a developer-facing panel naming the Template, the reason, the remedy, the
|
|
26
|
+
* bound Contract and its available fields, and the envelope JSON. Renders in production too — an
|
|
27
|
+
* honest hole beats a silent one. Replace it via `<ContentProvider fallback>`.
|
|
28
|
+
*/
|
|
29
|
+
export function UnresolvedPresentation({ reason, remedy, template, envelope, error }) {
|
|
30
|
+
const name = template?.externalId ?? template?.id ?? 'Presentation';
|
|
31
|
+
const component = isRecord(envelope) && isRecord(envelope.component) ? envelope.component : undefined;
|
|
32
|
+
const contract = component && isRecord(component.contract) ? component.contract : undefined;
|
|
33
|
+
const fields = component && isResolved(component) ? Object.keys(component.content) : [];
|
|
34
|
+
return (_jsxs("section", { role: "note", "data-ebitex-content": "fallback", "data-reason": reason, style: panelStyle, children: [_jsxs("h2", { style: headingStyle, children: ["Presentation \"", name, "\" ", TITLES[reason]] }), _jsx("p", { style: paragraphStyle, children: remedy }), contract ? (_jsxs("p", { style: metaStyle, children: ["Contract: ", String(contract.externalId ?? contract.id), typeof contract.version === 'number' ? ` (v${contract.version})` : '', fields.length > 0 ? ` · content fields: ${fields.join(', ')}` : ''] })) : null, error !== undefined ? (_jsxs("p", { style: metaStyle, children: ["Error: ", error instanceof Error ? `${error.name}: ${error.message}` : String(error)] })) : null, _jsxs("details", { children: [_jsx("summary", { children: "Envelope JSON" }), _jsx("pre", { style: preStyle, children: safeStringify(envelope) })] })] }));
|
|
35
|
+
}
|
|
36
|
+
const HTTP_REMEDIES = {
|
|
37
|
+
missing_api_key: 'No key was sent — pass apiKey to createContentClient.',
|
|
38
|
+
invalid_api_key: 'The key is unknown, revoked, or expired. Create a new one in Content → Delivery.',
|
|
39
|
+
scope_denied: 'This key cannot read published content — create a delivery key in Content → Delivery.',
|
|
40
|
+
origin_denied: "Add this page's origin to the key's allowed origins (Content → Delivery → Manage). A non-browser caller needs a server-side key.",
|
|
41
|
+
ip_denied: "This network's address is outside the key's allowed IP ranges. Run GET /diagnostics/client-address from here and add the address it reports (Content → Delivery → Manage).",
|
|
42
|
+
too_many_failed_authentications: 'Too many failed authentications from this address — wait for the retry window, then check the key value.',
|
|
43
|
+
quota_exceeded: "The organization's per-minute delivery quota is exhausted — wait for the retry window, or raise the tier.",
|
|
44
|
+
payment_required: "The organization's subscription needs attention (Hub → Billing).",
|
|
45
|
+
app_not_available: 'Content is not enabled for this organization.',
|
|
46
|
+
invalid_context: 'The context bag was rejected — keep it flat (scalars and string lists) and under 8 KB.',
|
|
47
|
+
};
|
|
48
|
+
/** The default error panel — developer-facing, with the documented remedy per error code. Replace it via `<ContentProvider errorFallback>`. */
|
|
49
|
+
export function ContentError({ error, path }) {
|
|
50
|
+
let title = 'Content could not be loaded';
|
|
51
|
+
let remedy;
|
|
52
|
+
let detail;
|
|
53
|
+
if (error instanceof ContentDeliveryError) {
|
|
54
|
+
title = `Content Delivery API answered ${error.status}${error.code ? ` (${error.code})` : ''}`;
|
|
55
|
+
remedy = error.code ? HTTP_REMEDIES[error.code] : undefined;
|
|
56
|
+
detail = safeStringify(error.body);
|
|
57
|
+
if (error.retryAfterSeconds !== null) {
|
|
58
|
+
remedy = `${remedy ?? ''} Retry after ${error.retryAfterSeconds}s.`.trim();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (error instanceof ContentSdkError) {
|
|
62
|
+
title = `Content SDK: ${error.code}`;
|
|
63
|
+
remedy = error.message; // an SDK error's message is written as its remedy (found live: hiding it under Details left the panel saying only the code)
|
|
64
|
+
detail = safeStringify(error.details ?? null);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
68
|
+
}
|
|
69
|
+
return (_jsxs("section", { role: "alert", "data-ebitex-content": "error", style: panelStyle, children: [_jsx("h2", { style: headingStyle, children: title }), path ? _jsxs("p", { style: metaStyle, children: ["Path: ", path] }) : null, remedy ? _jsx("p", { style: paragraphStyle, children: remedy }) : null, _jsxs("details", { children: [_jsx("summary", { children: "Details" }), _jsx("pre", { style: preStyle, children: detail })] })] }));
|
|
70
|
+
}
|
|
71
|
+
function safeStringify(value) {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.stringify(value, null, 2) ?? String(value);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return String(value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const panelStyle = {
|
|
80
|
+
border: '1px dashed currentColor',
|
|
81
|
+
borderRadius: '0.5rem',
|
|
82
|
+
padding: '0.75rem 1rem',
|
|
83
|
+
margin: '0.5rem 0',
|
|
84
|
+
fontFamily: 'system-ui, sans-serif',
|
|
85
|
+
fontSize: '0.875rem',
|
|
86
|
+
lineHeight: 1.4,
|
|
87
|
+
};
|
|
88
|
+
const headingStyle = { fontSize: '1rem', margin: '0 0 0.25rem' };
|
|
89
|
+
const paragraphStyle = { margin: '0 0 0.25rem' };
|
|
90
|
+
const metaStyle = { margin: '0 0 0.25rem', opacity: 0.8 };
|
|
91
|
+
const preStyle = { overflowX: 'auto', fontSize: '0.75rem', margin: '0.25rem 0 0' };
|
|
92
|
+
//# sourceMappingURL=panels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panels.js","sourceRoot":"","sources":["../../src/react/panels.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAmCnD,MAAM,CAAC,MAAM,QAAQ,GAA+E;IAClG,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CACpB,qBAAqB,CAAC,EAAE,UAAU,IAAI,cAAc,4CAA4C,CAAC,EAAE,UAAU,IAAI,cAAc,mCAAmC;IACpK,WAAW,EAAE,CAAC,CA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E,SAAS,EAAE,MAAM,EAAE,aAAa,EAAW,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { ContentDocument, EntityDescriptor, RenderableComponentValue } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a renderer receives — the Presentation envelope with one guarantee added:
|
|
5
|
+
* `component.content` is present (see `RenderPresentation`'s resolution gate). A renderer never
|
|
6
|
+
* has to defend against a hollow envelope.
|
|
7
|
+
*/
|
|
8
|
+
export interface PresentationRendererProps<TContent = ContentDocument, TSettings = ContentDocument> {
|
|
9
|
+
template: EntityDescriptor;
|
|
10
|
+
settings: TSettings;
|
|
11
|
+
component: RenderableComponentValue<TContent>;
|
|
12
|
+
}
|
|
13
|
+
export type PresentationRenderer<TContent = ContentDocument, TSettings = ContentDocument> = ComponentType<PresentationRendererProps<TContent, TSettings>>;
|
|
14
|
+
export type AnyPresentationRenderer = PresentationRenderer<any, any>;
|
|
15
|
+
export interface RendererModule {
|
|
16
|
+
default: AnyPresentationRenderer;
|
|
17
|
+
}
|
|
18
|
+
/** A renderer loaded on first use — `lazyRenderer(() => import('./presentations/hero'))`. */
|
|
19
|
+
export interface LazyRenderer {
|
|
20
|
+
load: () => Promise<RendererModule> | RendererModule;
|
|
21
|
+
}
|
|
22
|
+
export type RendererEntry = AnyPresentationRenderer | LazyRenderer;
|
|
23
|
+
/** A function form of the registry: `(externalId) => import(\`./presentations/${externalId}\`)`, returning `undefined` for an unknown Template. */
|
|
24
|
+
export type RendererResolver = (externalId: string) => RendererEntry | Promise<RendererModule> | RendererModule | undefined;
|
|
25
|
+
export type Renderers = Record<string, RendererEntry> | RendererResolver;
|
|
26
|
+
/** Identity with typing — `defineRenderers({ hero: Hero })` keeps each renderer's own generic parameters intact. */
|
|
27
|
+
export declare function defineRenderers<T extends Record<string, RendererEntry>>(renderers: T): T;
|
|
28
|
+
export declare function lazyRenderer(load: LazyRenderer['load']): LazyRenderer;
|
|
29
|
+
/**
|
|
30
|
+
* Derives the registry from Vite's `import.meta.glob('./presentations/*.tsx')`: each file's
|
|
31
|
+
* basename (without extension) is the Template `externalId`, and the module's `default` export
|
|
32
|
+
* is the renderer. `presentations/hero.tsx` → `hero`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderersFromGlob(glob: Record<string, () => Promise<unknown>>): Record<string, LazyRenderer>;
|
|
35
|
+
export type RendererState = {
|
|
36
|
+
status: 'ready';
|
|
37
|
+
renderer: AnyPresentationRenderer;
|
|
38
|
+
} | {
|
|
39
|
+
status: 'loading';
|
|
40
|
+
promise: Promise<RendererState>;
|
|
41
|
+
} | {
|
|
42
|
+
status: 'missing';
|
|
43
|
+
} | {
|
|
44
|
+
status: 'failed';
|
|
45
|
+
error: unknown;
|
|
46
|
+
};
|
|
47
|
+
/** Resolves and memoizes renderers per `externalId`; one instance per `<ContentProvider>`. */
|
|
48
|
+
export declare class RendererRegistry {
|
|
49
|
+
private readonly states;
|
|
50
|
+
private readonly renderers;
|
|
51
|
+
constructor(renderers: Renderers);
|
|
52
|
+
get(externalId: string | null): RendererState;
|
|
53
|
+
private resolve;
|
|
54
|
+
private loading;
|
|
55
|
+
private settle;
|
|
56
|
+
private fromModule;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/react/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAE9F;;;;GAIG;AACH,MAAM,WAAW,yBAAyB,CAAC,QAAQ,GAAG,eAAe,EAAE,SAAS,GAAG,eAAe;IAChG,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,QAAQ,EAAE,SAAS,CAAA;IACnB,SAAS,EAAE,wB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AC;IAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CAAE,GACtD;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAExC,8FAA8F;AAC9F,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;gBAEzB,SAAS,EAAE,SAAS;IAIhC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa;IAe7C,OAAO,CAAC,OAAO;IAgCf,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,UAAU;CAWnB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ContentSdkError } from '../errors.js';
|
|
2
|
+
/** Identity with typing — `defineRenderers({ hero: Hero })` keeps each renderer's own generic parameters intact. */
|
|
3
|
+
export function defineRenderers(renderers) {
|
|
4
|
+
return renderers;
|
|
5
|
+
}
|
|
6
|
+
export function lazyRenderer(load) {
|
|
7
|
+
return { load };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Derives the registry from Vite's `import.meta.glob('./presentations/*.tsx')`: each file's
|
|
11
|
+
* basename (without extension) is the Template `externalId`, and the module's `default` export
|
|
12
|
+
* is the renderer. `presentations/hero.tsx` → `hero`.
|
|
13
|
+
*/
|
|
14
|
+
export function renderersFromGlob(glob) {
|
|
15
|
+
const renderers = {};
|
|
16
|
+
for (const [path, load] of Object.entries(glob)) {
|
|
17
|
+
const file = path.split('/').pop() ?? path;
|
|
18
|
+
const externalId = file.replace(/\.[^.]+$/, '');
|
|
19
|
+
renderers[externalId] = { load: () => load() };
|
|
20
|
+
}
|
|
21
|
+
return renderers;
|
|
22
|
+
}
|
|
23
|
+
/** Resolves and memoizes renderers per `externalId`; one instance per `<ContentProvider>`. */
|
|
24
|
+
export class RendererRegistry {
|
|
25
|
+
states = new Map();
|
|
26
|
+
renderers;
|
|
27
|
+
constructor(renderers) {
|
|
28
|
+
this.renderers = renderers;
|
|
29
|
+
}
|
|
30
|
+
get(externalId) {
|
|
31
|
+
if (externalId === null) {
|
|
32
|
+
return { status: 'missing' };
|
|
33
|
+
}
|
|
34
|
+
const cached = this.states.get(externalId);
|
|
35
|
+
if (cached !== undefined) {
|
|
36
|
+
return cached;
|
|
37
|
+
}
|
|
38
|
+
const state = this.resolve(externalId);
|
|
39
|
+
this.states.set(externalId, state);
|
|
40
|
+
return state;
|
|
41
|
+
}
|
|
42
|
+
resolve(externalId) {
|
|
43
|
+
let entry;
|
|
44
|
+
try {
|
|
45
|
+
entry = typeof this.renderers === 'function' ? this.renderers(externalId) : this.renderers[externalId];
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return { status: 'failed', error };
|
|
49
|
+
}
|
|
50
|
+
if (entry === undefined || entry === null) {
|
|
51
|
+
return { status: 'missing' };
|
|
52
|
+
}
|
|
53
|
+
if (typeof entry === 'function') {
|
|
54
|
+
return { status: 'ready', renderer: entry };
|
|
55
|
+
}
|
|
56
|
+
if (isThenable(entry)) {
|
|
57
|
+
return this.loading(externalId, entry);
|
|
58
|
+
}
|
|
59
|
+
if ('load' in entry && typeof entry.load === 'function') {
|
|
60
|
+
try {
|
|
61
|
+
const loaded = entry.load();
|
|
62
|
+
return isThenable(loaded) ? this.loading(externalId, loaded) : this.fromModule(loaded);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return { status: 'failed', error };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return this.fromModule(entry);
|
|
69
|
+
}
|
|
70
|
+
loading(externalId, promise) {
|
|
71
|
+
const settled = promise.then((module) => this.settle(externalId, this.fromModule(module)), (error) => this.settle(externalId, { status: 'failed', error }));
|
|
72
|
+
return { status: 'loading', promise: settled };
|
|
73
|
+
}
|
|
74
|
+
settle(externalId, state) {
|
|
75
|
+
this.states.set(externalId, state);
|
|
76
|
+
return state;
|
|
77
|
+
}
|
|
78
|
+
fromModule(module) {
|
|
79
|
+
const renderer = typeof module === 'object' && module !== null ? module.default : undefined;
|
|
80
|
+
if (typeof renderer === 'function') {
|
|
81
|
+
return { status: 'ready', renderer: renderer };
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
status: 'failed',
|
|
85
|
+
error: new ContentSdkError('renderer_load_failed', 'The renderer module has no default export that is a component.'),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function isThenable(value) {
|
|
90
|
+
return typeof value === 'object' && value !== null && typeof value.then === 'function';
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/react/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAqC9C,oHAAoH;AACpH,MAAM,UAAU,eAAe,CAA0C,SAAY;IACnF,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAA0B;IACrD,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA4C;IAC5E,MAAM,SAAS,GAAiC,EAAE,CAAA;IAClD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,CAAA;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QAC/C,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,G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AAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,UAAU,CAAC,MAAe;QAChC,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAE,MAAgC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;QACtH,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAmC,EAAE,CAAA;QAC3E,CAAC;QAED,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,IAAI,eAAe,CAAC,sBAAsB,EAAE,gEAAgE,CAAC;SACrH,CAAA;IACH,CAAC;CACF;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CAAA;AAChH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Content Delivery API's **delivered vocabulary** (docs/content-delivery-api.md §3–§9, spec
|
|
3
|
+
* 351-delivery-template-content-shape-unification), transcribed. Every shape here is what the API
|
|
4
|
+
* returns — never a client-side invention — so a value can always be mapped back to what was
|
|
5
|
+
* authored. Field-value documents are `Record<string, unknown>` by default; narrow them with the
|
|
6
|
+
* generic parameters (`PresentationEnvelope<HeroContent, HeroSettings>`) in your own renderers.
|
|
7
|
+
*/
|
|
8
|
+
/** `{ id, externalId, version }` — how a Contract or Template is identified everywhere in a response (§3b). `version` is `null` only for a row published before spec 351 that hasn't been republished since. */
|
|
9
|
+
export interface EntityDescriptor {
|
|
10
|
+
id: string;
|
|
11
|
+
externalId: string | null;
|
|
12
|
+
version: number | null;
|
|
13
|
+
}
|
|
14
|
+
/** A field-value document — the fields of one Contract, as delivered. */
|
|
15
|
+
export type ContentDocument = Record<string, unknown>;
|
|
16
|
+
export interface SiteSummary {
|
|
17
|
+
rootNodeId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
/** Mapped hostnames (no port). Empty for a site with no host mapping. */
|
|
20
|
+
hosts: string[];
|
|
21
|
+
}
|
|
22
|
+
/** One node of the organization's locale tree (`GET /locales`); `parentCode` is `null` for the root. */
|
|
23
|
+
export interface LocaleTreeNode {
|
|
24
|
+
code: string;
|
|
25
|
+
parentCode: string | null;
|
|
26
|
+
}
|
|
27
|
+
export type BagValue = string | number | boolean | null;
|
|
28
|
+
export type BagPropertyValue = BagValue | BagValue[];
|
|
29
|
+
/**
|
|
30
|
+
* The personalization context (§8): reserved `audiences` (consumer-computed trait names) plus any
|
|
31
|
+
* flat, org-defined scalar/string-list properties. `locale` is reserved too, but the server always
|
|
32
|
+
* overwrites it with the request's own `?locale=`, so the SDK never sets it.
|
|
33
|
+
*/
|
|
34
|
+
export interface ContextBag {
|
|
35
|
+
audiences?: string[];
|
|
36
|
+
[property: string]: BagPropertyValue | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Which Adapter mapped a binding (§5b): a named one (`id`/`externalId`) or an inline, unnamed one.
|
|
40
|
+
* The frozen descriptor also carries the mapping's own `rules` and `outputContract`; they are
|
|
41
|
+
* opaque here — there is no client-side mapping engine, by design.
|
|
42
|
+
*/
|
|
43
|
+
export interface AdapterDescriptor {
|
|
44
|
+
id?: string;
|
|
45
|
+
externalId?: string | null;
|
|
46
|
+
inline?: boolean;
|
|
47
|
+
[frozen: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
export interface AdapterWarning {
|
|
50
|
+
target: string;
|
|
51
|
+
code: string;
|
|
52
|
+
}
|
|
53
|
+
interface ReferenceBase {
|
|
54
|
+
provider: string;
|
|
55
|
+
key: string;
|
|
56
|
+
/** Absent only on a bare embed reference authored without one — every top-level descriptor carries it. */
|
|
57
|
+
contract?: EntityDescriptor;
|
|
58
|
+
/** The edge's own values, overlaid on the target's stored defaults — by the server at `resolve ≥ 1`, or by `applyContextualOverlay` under the normalized strategy. */
|
|
59
|
+
contextualValues?: ContentDocument;
|
|
60
|
+
adapter?: AdapterDescriptor;
|
|
61
|
+
}
|
|
62
|
+
/** A reference not resolved in this response: fetch it (`resolveReference`) or request a deeper `resolve`. */
|
|
63
|
+
export interface UnexpandedReference extends ReferenceBase {
|
|
64
|
+
content?: undefined;
|
|
65
|
+
unresolvable?: undefined;
|
|
66
|
+
}
|
|
67
|
+
/** A reference resolved in this response; `content` already has the contextual overlay applied. */
|
|
68
|
+
export interface ExpandedReference<TContent = ContentDocument> extends ReferenceBase {
|
|
69
|
+
content: TContent;
|
|
70
|
+
adapterWarnings?: AdapterWarning[];
|
|
71
|
+
unresolvable?: undefined;
|
|
72
|
+
}
|
|
73
|
+
/** A reference the server attempted and could not resolve (§5) — it never says why. */
|
|
74
|
+
export interface UnresolvableReference extends ReferenceBase {
|
|
75
|
+
unresolvable: true;
|
|
76
|
+
content?: undefined;
|
|
77
|
+
}
|
|
78
|
+
/** A value authored in place — nothing to fetch, ever. */
|
|
79
|
+
export interface InlineValue<TContent = ContentDocument> {
|
|
80
|
+
contract: EntityDescriptor;
|
|
81
|
+
content: TContent;
|
|
82
|
+
adapterWarnings?: AdapterWarning[];
|
|
83
|
+
provider?: undefined;
|
|
84
|
+
key?: undefined;
|
|
85
|
+
unresolvable?: undefined;
|
|
86
|
+
}
|
|
87
|
+
/** Every row of docs/content-delivery-api.md §3b's table, decidable from the value alone (see `guards.ts`). */
|
|
88
|
+
export type ComponentValue<TContent = ContentDocument> = UnexpandedReference | ExpandedReference<TContent> | UnresolvableReference | InlineValue<TContent>;
|
|
89
|
+
/** A component value a renderer can render right now — `content` is present. */
|
|
90
|
+
export type RenderableComponentValue<TContent = ContentDocument> = ExpandedReference<TContent> | InlineValue<TContent>;
|
|
91
|
+
/** A Presentation envelope — a page's own payload, a Presentation field's value, a relayed Presentation, a RichText `presentation` fragment. */
|
|
92
|
+
export interface PresentationEnvelope<TContent = ContentDocument, TSettings = ContentDocument> {
|
|
93
|
+
template: EntityDescriptor;
|
|
94
|
+
settings: TSettings;
|
|
95
|
+
component: ComponentValue<TContent>;
|
|
96
|
+
}
|
|
97
|
+
export interface PresentationPathResult {
|
|
98
|
+
kind: 'presentation';
|
|
99
|
+
nodeId: string;
|
|
100
|
+
path: string;
|
|
101
|
+
presentation: PresentationEnvelope;
|
|
102
|
+
}
|
|
103
|
+
/** Follow it yourself — chains and cycles are already collapsed server-side. */
|
|
104
|
+
export interface RedirectPathResult {
|
|
105
|
+
kind: 'redirect';
|
|
106
|
+
targetPath: string;
|
|
107
|
+
targetNodeId: string | null;
|
|
108
|
+
}
|
|
109
|
+
export type PathResult = PresentationPathResult | RedirectPathResult;
|
|
110
|
+
export interface ComponentListItem {
|
|
111
|
+
provider: string;
|
|
112
|
+
key: string;
|
|
113
|
+
contract: EntityDescriptor;
|
|
114
|
+
}
|
|
115
|
+
export interface ComponentPage {
|
|
116
|
+
items: ComponentListItem[];
|
|
117
|
+
/** Pass back as `cursor`; `null` means there is no next page. */
|
|
118
|
+
nextCursor: string | null;
|
|
119
|
+
}
|
|
120
|
+
export interface MarkdownFragment {
|
|
121
|
+
kind: 'markdown';
|
|
122
|
+
/** CommonMark (+ GFM tables and strikethrough only), never raw HTML. Render each fragment as its own document. */
|
|
123
|
+
markdown: string;
|
|
124
|
+
}
|
|
125
|
+
export interface PresentationFragment {
|
|
126
|
+
kind: 'presentation';
|
|
127
|
+
presentation: PresentationEnvelope;
|
|
128
|
+
}
|
|
129
|
+
/** Deprecated as an embed kind since spec 233, still delivered when authored. */
|
|
130
|
+
export interface ReferenceFragment {
|
|
131
|
+
kind: 'reference';
|
|
132
|
+
reference: ComponentValue;
|
|
133
|
+
}
|
|
134
|
+
/** Present only in client-resolve mode (`ctx` omitted) — the high-level client never produces one. */
|
|
135
|
+
export interface PersonalizedFragment {
|
|
136
|
+
kind: 'personalized';
|
|
137
|
+
default: RichTextFragment[];
|
|
138
|
+
variants: Array<{
|
|
139
|
+
conditions: unknown[];
|
|
140
|
+
value: RichTextFragment[];
|
|
141
|
+
}>;
|
|
142
|
+
}
|
|
143
|
+
export type RichTextFragment = MarkdownFragment | PresentationFragment | ReferenceFragment | PersonalizedFragment;
|
|
144
|
+
/** A delivered RichText value: an ordered fragment array. An `isEnumerable` RichText field is an array of these. */
|
|
145
|
+
export type RichTextValue = RichTextFragment[];
|
|
146
|
+
export interface ExperienceLink {
|
|
147
|
+
kind: 'experience';
|
|
148
|
+
target: {
|
|
149
|
+
provider: string;
|
|
150
|
+
key: string;
|
|
151
|
+
kind?: 'experience';
|
|
152
|
+
};
|
|
153
|
+
/** Present only when authored. */
|
|
154
|
+
query?: string | null;
|
|
155
|
+
anchor?: string | null;
|
|
156
|
+
/** The current localized path (absolute across sites), or `null` when the target isn't published. */
|
|
157
|
+
url: string | null;
|
|
158
|
+
resolved: boolean;
|
|
159
|
+
}
|
|
160
|
+
export interface ExternalLink {
|
|
161
|
+
kind: 'external';
|
|
162
|
+
/** Fully composed at publish time. */
|
|
163
|
+
url: string;
|
|
164
|
+
query?: string | null;
|
|
165
|
+
anchor?: string | null;
|
|
166
|
+
/** Always `true` (absent only on a delivery older than spec 359's server fix). */
|
|
167
|
+
resolved?: true;
|
|
168
|
+
}
|
|
169
|
+
export type LinkValue = ExperienceLink | ExternalLink;
|
|
170
|
+
export interface BlobValue {
|
|
171
|
+
/** Absent means `core`. */
|
|
172
|
+
provider?: string;
|
|
173
|
+
blobId: string;
|
|
174
|
+
contentType: string;
|
|
175
|
+
sizeBytes: number;
|
|
176
|
+
/** A public, unauthenticated URL — put it straight in `<img src>`. */
|
|
177
|
+
url: string;
|
|
178
|
+
}
|
|
179
|
+
export interface CategoryDescriptor {
|
|
180
|
+
provider: string;
|
|
181
|
+
key: string;
|
|
182
|
+
path: string;
|
|
183
|
+
value: string;
|
|
184
|
+
groupExternalId: string;
|
|
185
|
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B,SAAS,EAAE,MAAM,CAAA;IACjB,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAA;CACZ;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CAAA;CACxB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Content Delivery API's **delivered vocabulary** (docs/content-delivery-api.md §3–§9, spec
|
|
3
|
+
* 351-delivery-template-content-shape-unification), transcribed. Every shape here is what the API
|
|
4
|
+
* returns — never a client-side invention — so a value can always be mapped back to what was
|
|
5
|
+
* authored. Field-value documents are `Record<string, unknown>` by default; narrow them with the
|
|
6
|
+
* generic parameters (`PresentationEnvelope<HeroContent, HeroSettings>`) in your own renderers.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ebitex/content-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Consume published ebitex Content from your own site: a typed Delivery API client and React rendering utilities.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./react": {
|
|
17
|
+
"types": "./dist/react/index.d.ts",
|
|
18
|
+
"import": "./dist/react/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"lint": "oxlint",
|
|
27
|
+
"test": "vitest run"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=19",
|
|
31
|
+
"react-dom": ">=19"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"react": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"react-dom": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
43
|
+
"@testing-library/react": "^16.3.2",
|
|
44
|
+
"@testing-library/user-event": "^14.6.1",
|
|
45
|
+
"@types/react": "^19.2.17",
|
|
46
|
+
"@types/react-dom": "^19.2.3",
|
|
47
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
48
|
+
"jsdom": "^29.1.1",
|
|
49
|
+
"oxlint": "^1.71.0",
|
|
50
|
+
"react": "^19.2.7",
|
|
51
|
+
"react-dom": "^19.2.7",
|
|
52
|
+
"typescript": "~6.0.2",
|
|
53
|
+
"vitest": "^4.1.10"
|
|
54
|
+
}
|
|
55
|
+
}
|