@wildo-ai/external-connectors-public 1.1.2 → 1.1.3
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/dist/esm/.native.tsbuildinfo +1 -0
- package/dist/esm/app/compose-frontend-app-providers.d.ts.map +1 -1
- package/dist/esm/app/compose-frontend-app-providers.js +5 -2
- package/dist/esm/app/compose-frontend-app-providers.js.map +1 -1
- package/dist/esm/app/compose-hydrated-frontend-app-providers.d.ts +33 -0
- package/dist/esm/app/compose-hydrated-frontend-app-providers.d.ts.map +1 -0
- package/dist/esm/app/compose-hydrated-frontend-app-providers.js +41 -0
- package/dist/esm/app/compose-hydrated-frontend-app-providers.js.map +1 -0
- package/dist/esm/app/engine-frontend-app-provider-registry.d.ts.map +1 -1
- package/dist/esm/app/engine-frontend-app-provider-registry.js +4 -0
- package/dist/esm/app/engine-frontend-app-provider-registry.js.map +1 -1
- package/dist/esm/app/frontend-app-provider-module.types.d.ts +128 -15
- package/dist/esm/app/frontend-app-provider-module.types.d.ts.map +1 -1
- package/dist/esm/app/frontend-app-provider-module.types.js +7 -6
- package/dist/esm/app/frontend-app-provider-module.types.js.map +1 -1
- package/dist/esm/app/index.d.ts +4 -0
- package/dist/esm/app/index.d.ts.map +1 -1
- package/dist/esm/app/index.js +4 -0
- package/dist/esm/app/index.js.map +1 -1
- package/dist/esm/companion-exports.d.ts +47 -0
- package/dist/esm/companion-exports.d.ts.map +1 -1
- package/dist/esm/companion-exports.js +99 -5
- package/dist/esm/companion-exports.js.map +1 -1
- package/dist/esm/engine-frontend-providers-package.d.ts +7 -0
- package/dist/esm/engine-frontend-providers-package.d.ts.map +1 -0
- package/dist/esm/engine-frontend-providers-package.js +7 -0
- package/dist/esm/engine-frontend-providers-package.js.map +1 -0
- package/dist/esm/providers/algolia/algolia.frontend-techdoc.module.d.ts.map +1 -1
- package/dist/esm/providers/algolia/algolia.frontend-techdoc.module.js +26 -4
- package/dist/esm/providers/algolia/algolia.frontend-techdoc.module.js.map +1 -1
- package/dist/esm/providers/apple/apple.frontend-app.module.d.ts.map +1 -1
- package/dist/esm/providers/apple/apple.frontend-app.module.js +16 -4
- package/dist/esm/providers/apple/apple.frontend-app.module.js.map +1 -1
- package/dist/esm/providers/github/github.frontend-app.module.d.ts.map +1 -1
- package/dist/esm/providers/github/github.frontend-app.module.js +15 -4
- package/dist/esm/providers/github/github.frontend-app.module.js.map +1 -1
- package/dist/esm/providers/google/google.frontend-app.module.d.ts.map +1 -1
- package/dist/esm/providers/google/google.frontend-app.module.js +16 -4
- package/dist/esm/providers/google/google.frontend-app.module.js.map +1 -1
- package/dist/esm/providers/microsoft/microsoft.frontend-app.module.d.ts.map +1 -1
- package/dist/esm/providers/microsoft/microsoft.frontend-app.module.js +15 -4
- package/dist/esm/providers/microsoft/microsoft.frontend-app.module.js.map +1 -1
- package/dist/esm/providers/posthog/posthog.frontend-website.module.d.ts +19 -0
- package/dist/esm/providers/posthog/posthog.frontend-website.module.d.ts.map +1 -1
- package/dist/esm/providers/posthog/posthog.frontend-website.module.js +65 -4
- package/dist/esm/providers/posthog/posthog.frontend-website.module.js.map +1 -1
- package/dist/esm/providers/recaptcha/recaptcha.frontend-website.module.d.ts.map +1 -1
- package/dist/esm/providers/recaptcha/recaptcha.frontend-website.module.js +24 -4
- package/dist/esm/providers/recaptcha/recaptcha.frontend-website.module.js.map +1 -1
- package/dist/esm/providers/sentry/index.d.ts +0 -2
- package/dist/esm/providers/sentry/index.d.ts.map +0 -1
- package/dist/esm/providers/sentry/index.js +0 -2
- package/dist/esm/providers/sentry/index.js.map +0 -1
- package/dist/esm/providers/sentry/sentry.frontend-app.module.d.ts +57 -0
- package/dist/esm/providers/sentry/sentry.frontend-app.module.d.ts.map +1 -0
- package/dist/esm/providers/sentry/sentry.frontend-app.module.js +141 -0
- package/dist/esm/providers/sentry/sentry.frontend-app.module.js.map +1 -0
- package/dist/esm/providers/sentry/sentry.frontend-website.module.d.ts +27 -0
- package/dist/esm/providers/sentry/sentry.frontend-website.module.d.ts.map +1 -1
- package/dist/esm/providers/sentry/sentry.frontend-website.module.js +79 -4
- package/dist/esm/providers/sentry/sentry.frontend-website.module.js.map +1 -1
- package/dist/esm/providers/stripe/stripe.frontend-app.module.d.ts.map +1 -1
- package/dist/esm/providers/stripe/stripe.frontend-app.module.js +15 -4
- package/dist/esm/providers/stripe/stripe.frontend-app.module.js.map +1 -1
- package/dist/esm/shared/activate-frontend-provider-sdks.d.ts +88 -0
- package/dist/esm/shared/activate-frontend-provider-sdks.d.ts.map +1 -0
- package/dist/esm/shared/activate-frontend-provider-sdks.js +110 -0
- package/dist/esm/shared/activate-frontend-provider-sdks.js.map +1 -0
- package/dist/esm/shared/frontend-provider-surface.types.d.ts +365 -0
- package/dist/esm/shared/frontend-provider-surface.types.d.ts.map +1 -0
- package/dist/esm/shared/frontend-provider-surface.types.js +82 -0
- package/dist/esm/shared/frontend-provider-surface.types.js.map +1 -0
- package/dist/esm/shared/hydrate-frontend-providers.d.ts +150 -0
- package/dist/esm/shared/hydrate-frontend-providers.d.ts.map +1 -0
- package/dist/esm/shared/hydrate-frontend-providers.js +298 -0
- package/dist/esm/shared/hydrate-frontend-providers.js.map +1 -0
- package/dist/esm/techdoc/compose-frontend-techdoc-providers.d.ts.map +1 -1
- package/dist/esm/techdoc/compose-frontend-techdoc-providers.js +5 -2
- package/dist/esm/techdoc/compose-frontend-techdoc-providers.js.map +1 -1
- package/dist/esm/techdoc/compose-hydrated-frontend-techdoc-providers.d.ts +33 -0
- package/dist/esm/techdoc/compose-hydrated-frontend-techdoc-providers.d.ts.map +1 -0
- package/dist/esm/techdoc/compose-hydrated-frontend-techdoc-providers.js +41 -0
- package/dist/esm/techdoc/compose-hydrated-frontend-techdoc-providers.js.map +1 -0
- package/dist/esm/techdoc/frontend-techdoc-provider-module.types.d.ts +61 -4
- package/dist/esm/techdoc/frontend-techdoc-provider-module.types.d.ts.map +1 -1
- package/dist/esm/techdoc/frontend-techdoc-provider-module.types.js +5 -3
- package/dist/esm/techdoc/frontend-techdoc-provider-module.types.js.map +1 -1
- package/dist/esm/techdoc/index.d.ts +4 -0
- package/dist/esm/techdoc/index.d.ts.map +1 -1
- package/dist/esm/techdoc/index.js +4 -0
- package/dist/esm/techdoc/index.js.map +1 -1
- package/dist/esm/website/compose-frontend-website-providers.d.ts.map +1 -1
- package/dist/esm/website/compose-frontend-website-providers.js +5 -2
- package/dist/esm/website/compose-frontend-website-providers.js.map +1 -1
- package/dist/esm/website/compose-hydrated-frontend-website-providers.d.ts +33 -0
- package/dist/esm/website/compose-hydrated-frontend-website-providers.d.ts.map +1 -0
- package/dist/esm/website/compose-hydrated-frontend-website-providers.js +41 -0
- package/dist/esm/website/compose-hydrated-frontend-website-providers.js.map +1 -0
- package/dist/esm/website/engine-frontend-website-provider-registry.d.ts.map +1 -1
- package/dist/esm/website/engine-frontend-website-provider-registry.js +5 -1
- package/dist/esm/website/engine-frontend-website-provider-registry.js.map +1 -1
- package/dist/esm/website/frontend-website-provider-module.types.d.ts +63 -3
- package/dist/esm/website/frontend-website-provider-module.types.d.ts.map +1 -1
- package/dist/esm/website/frontend-website-provider-module.types.js +7 -2
- package/dist/esm/website/frontend-website-provider-module.types.js.map +1 -1
- package/dist/esm/website/index.d.ts +4 -0
- package/dist/esm/website/index.d.ts.map +1 -1
- package/dist/esm/website/index.js +4 -0
- package/dist/esm/website/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +15 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-provider-surface.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/frontend-provider-surface.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,mCAAmC,EACnC,6BAA6B,EAC9B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CA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AAC,CAAC,GAAG,SAAS,GAClH,MAAM,CAAC,MAAM,EAAE,mCAAmC,CAAC,GAAG,SAAS,CAgBjE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The EXECUTABLE half of a frontend provider's surface — the part that cannot
|
|
3
|
+
* cross a JSON channel, and therefore the part that defines the second channel.
|
|
4
|
+
*
|
|
5
|
+
* ## The two channels, and why there have to be two
|
|
6
|
+
*
|
|
7
|
+
* A frontend provider reaches a page through:
|
|
8
|
+
*
|
|
9
|
+
* - the **DATA** channel — `FrontendProviderEntry`, projected by the backend
|
|
10
|
+
* into `/application-config` and materialized into the generated
|
|
11
|
+
* frontend-services artifact. JSON end to end. It answers *which providers
|
|
12
|
+
* are live for this service, in this environment*;
|
|
13
|
+
* - the **CODE** channel — the provider package's own facet barrel, reaching
|
|
14
|
+
* the bundle through a generated `frontend-providers.generated.ts` that the
|
|
15
|
+
* app / website / techdoc build imports. It answers *what code exists in
|
|
16
|
+
* this bundle*.
|
|
17
|
+
*
|
|
18
|
+
* Before this split there was one channel and a cast: the registry took a JSON
|
|
19
|
+
* entry and asserted it was a module. That cast was true only for as long as the
|
|
20
|
+
* module type had nothing but strings on it — the moment a provider needed to
|
|
21
|
+
* load an SDK or register a component, the field would have been dropped by
|
|
22
|
+
* `JSON.stringify` with no error anywhere, and the provider would have looked
|
|
23
|
+
* declared and done nothing.
|
|
24
|
+
*
|
|
25
|
+
* So: everything in this file is CODE and never leaves the bundle, everything in
|
|
26
|
+
* `provider-frontend-surface.shared.schemas.ts` (in `@wildo-ai/saas-models`) is
|
|
27
|
+
* DATA and never carries a function, and `sdk` deliberately has a foot in both —
|
|
28
|
+
* a `descriptor` the CLI and the CSP composer can read, and an `activate()` only
|
|
29
|
+
* a browser can run.
|
|
30
|
+
*
|
|
31
|
+
* Added by slice S4a of epic #337 (issue #332).
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Strips a provider's component declarations down to the half a JSON channel
|
|
35
|
+
* can carry.
|
|
36
|
+
*
|
|
37
|
+
* ONE named source, reachable from every facet barrel, because there are THREE
|
|
38
|
+
* sites that turn a frontend module into a wire entry and they must not hold
|
|
39
|
+
* three opinions: `projectFrontendProviderContribution` (the companion
|
|
40
|
+
* discovery walk, which feeds the generated artifact), the backend's fallback
|
|
41
|
+
* projection in `frontend-bootstrap.backend.service.ts` (what an application
|
|
42
|
+
* serves when no sync has run), and the hydration join, which takes the CODE
|
|
43
|
+
* side whole and needs no stripping at all.
|
|
44
|
+
*
|
|
45
|
+
* The failure a second opinion produces is the one that surface's own comments
|
|
46
|
+
* already name for the CSP footprint: a provider's declaration would appear on
|
|
47
|
+
* the entry when a sync had run and vanish when it had not — a difference no
|
|
48
|
+
* consumer can see and only production can punish.
|
|
49
|
+
*
|
|
50
|
+
* Returns `undefined` for a provider with no components rather than `{}`, so
|
|
51
|
+
* "contributes none" keeps one spelling, the way an absent `sdk` does.
|
|
52
|
+
*
|
|
53
|
+
* ## Why it lives in a browser-bound file
|
|
54
|
+
*
|
|
55
|
+
* Both callers are Node — the companion discovery walk and the backend's
|
|
56
|
+
* fallback projection — and this file's header says everything in it is CODE
|
|
57
|
+
* that never leaves the bundle. The placement is still right: the facet barrels
|
|
58
|
+
* are the only surface BOTH callers can reach (the backend imports
|
|
59
|
+
* `/app`, `/techdoc` and `/website`, never `/companion`), and putting it
|
|
60
|
+
* anywhere else would mean either a fourth subpath for one function or a second
|
|
61
|
+
* copy — which is the exact defect it exists to prevent. It is a pure function
|
|
62
|
+
* with no imports and no state, so a bundler that keeps it keeps a dozen lines.
|
|
63
|
+
*/
|
|
64
|
+
export function projectFrontendComponentDescriptors(components) {
|
|
65
|
+
if (components === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
const descriptors = {};
|
|
68
|
+
// An AUTHORED `components: {}` must not reach the wire either. The invariant
|
|
69
|
+
// is "contributes none has one spelling", and guarding only on `undefined`
|
|
70
|
+
// would have let the second spelling through from a provider that wrote the
|
|
71
|
+
// empty map by hand.
|
|
72
|
+
if (Object.keys(components).length === 0)
|
|
73
|
+
return undefined;
|
|
74
|
+
for (const [capability, declaration] of Object.entries(components)) {
|
|
75
|
+
// Rebuilt field by field rather than spread-minus-`load`, so a future field
|
|
76
|
+
// on the declaration is a COMPILE decision about whether it crosses the wire
|
|
77
|
+
// instead of one that crosses by default.
|
|
78
|
+
descriptors[capability] = { selectionDelivery: declaration.selectionDelivery };
|
|
79
|
+
}
|
|
80
|
+
return descriptors;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=frontend-provider-surface.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-provider-surface.types.js","sourceRoot":"","sources":["../../../../src/shared/frontend-provider-surface.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAoUH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,mCAAmC,CACjD,UAAmH;IAEnH,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,MAAM,WAAW,GAAwD,EAAE,CAAC;IAC5E,6EAA6E;IAC7E,2EAA2E;IAC3E,4EAA4E;IAC5E,qBAAqB;IACrB,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3D,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACnE,4EAA4E;QAC5E,6EAA6E;QAC7E,0CAA0C;QAC1C,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACjF,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/**\n * The EXECUTABLE half of a frontend provider's surface — the part that cannot\n * cross a JSON channel, and therefore the part that defines the second channel.\n *\n * ## The two channels, and why there have to be two\n *\n * A frontend provider reaches a page through:\n *\n * - the **DATA** channel — `FrontendProviderEntry`, projected by the backend\n * into `/application-config` and materialized into the generated\n * frontend-services artifact. JSON end to end. It answers *which providers\n * are live for this service, in this environment*;\n * - the **CODE** channel — the provider package's own facet barrel, reaching\n * the bundle through a generated `frontend-providers.generated.ts` that the\n * app / website / techdoc build imports. It answers *what code exists in\n * this bundle*.\n *\n * Before this split there was one channel and a cast: the registry took a JSON\n * entry and asserted it was a module. That cast was true only for as long as the\n * module type had nothing but strings on it — the moment a provider needed to\n * load an SDK or register a component, the field would have been dropped by\n * `JSON.stringify` with no error anywhere, and the provider would have looked\n * declared and done nothing.\n *\n * So: everything in this file is CODE and never leaves the bundle, everything in\n * `provider-frontend-surface.shared.schemas.ts` (in `@wildo-ai/saas-models`) is\n * DATA and never carries a function, and `sdk` deliberately has a foot in both —\n * a `descriptor` the CLI and the CSP composer can read, and an `activate()` only\n * a browser can run.\n *\n * Added by slice S4a of epic #337 (issue #332).\n */\n\nimport type {\n AppFrontendType,\n ProviderFrontendComponentDescriptor,\n ProviderFrontendSdkDescriptor,\n} from '@wildo-ai/saas-models/public-runtime';\nimport { ProviderFrontendSelectionDelivery } from '@wildo-ai/saas-models/public-runtime';\n\n/**\n * What a surface tells a provider when it activates its SDK.\n *\n * Deliberately small, because it must mean the same thing under Vite, Astro and\n * Docusaurus. Anything a single bundler can offer and the others cannot (a Vite\n * `import.meta.env`, an Astro locals object, a Docusaurus plugin context) would\n * make a provider that works on one surface and silently misbehaves on another,\n * which is the failure this whole slice exists to remove.\n */\nexport interface ProviderFrontendSdkActivationContext {\n /** The provider's own `ref`, so a provider can label its vendor-side telemetry. */\n readonly providerRef: string;\n /** Which of the three frontend surfaces is activating it. */\n readonly surface: AppFrontendType;\n /**\n * The provider's public configuration, as served on the DATA channel and\n * already validated against the module's own `publicConfigSchema` when it\n * declares one. A provider therefore never has to re-coerce it at the use\n * site — which is what the app was doing, per-site, by hand.\n */\n readonly publicConfig: Readonly<Record<string, unknown>>;\n}\n\n/**\n * The result of activating a provider's SDK.\n *\n * `deactivate` is the paired path, and it is optional only because some vendor\n * SDKs genuinely offer no teardown. Where one exists it must be declared: an\n * analytics or error-monitoring SDK that can be started and never stopped\n * cannot honour a consent withdrawal, and a surface that hot-reloads would\n * accumulate one live client per reload.\n */\nexport interface ProviderFrontendSdkActivation {\n /**\n * The vendor handle the surface may hold — a `Sentry` namespace, a `posthog`\n * instance, a picker factory. `unknown` on purpose: this package must not\n * know any vendor's type, and a consumer that needs one narrows it at the\n * point where it also knows which provider it asked for.\n */\n readonly handle: unknown;\n readonly deactivate?: () => void | Promise<void>;\n}\n\n/**\n * A provider's vendor SDK: which package it is (DATA), and how to load and start\n * it (CODE).\n *\n * `activate` owns BOTH the dynamic import and the vendor's initialization call,\n * as one function rather than two. The alternative — a `load()` returning the\n * namespace and an `initialize(handle, config)` beside it — puts the vendor's\n * own start-up contract in the surface's hands, and every surface would then\n * carry a growing switch over vendors. One function keeps that knowledge where\n * it belongs: inside the provider package.\n *\n * The import inside `activate` must be a DYNAMIC `import()`. That is what makes\n * the SDK a separate chunk in all three bundlers, and it is what lets the\n * bundle-isolation policy tell a declared optional dependency from a static one\n * that would land in every page's initial payload.\n */\nexport interface ProviderFrontendSdk {\n /** The DATA half — mirrored onto the provider entry so the CLI can see it without executing anything. */\n readonly descriptor: ProviderFrontendSdkDescriptor;\n activate(context: ProviderFrontendSdkActivationContext): Promise<ProviderFrontendSdkActivation>;\n}\n\n/**\n * A component a provider contributes, keyed by the CAPABILITY it fills.\n *\n * Loaded on demand, like an SDK and for the same reason: a picker nobody opens\n * should cost nothing, and a bundle should not carry every provider's UI.\n *\n * ## Why the loaded value is `unknown` here\n *\n * This package ships into three browser bundles and its bare-specifier\n * allow-list holds ONE entry. Typing the result as `React.ComponentType` would\n * put `react` in the closure of a package whose whole discipline is that it has\n * no renderer — and a provider module is DATA plus loaders; what a loader\n * RETURNS is the consuming surface's business, not this package's.\n *\n * A provider author loses nothing: any `() => Promise<React.ComponentType<P>>`\n * satisfies this type, so authors keep their own props type and the surface\n * narrows once, where React actually lives.\n *\n * ## Why capability-keyed and not component-type-keyed\n *\n * The engine's own component slots are a CLOSED `FrontendComponentType` enum\n * times a preset. Provider capabilities are an OPEN vocabulary an application\n * extends by module augmentation. Forcing provider components through the\n * closed enum would mean an engine edit for every new provider capability,\n * which is precisely what the open vocabulary exists to avoid.\n */\nexport type ProviderFrontendComponentLoader = () => Promise<unknown>;\n\n/**\n * One component a provider contributes: how to load it (CODE) and what it\n * commits to (DATA).\n *\n * Both halves in one declaration, deliberately, and it mirrors `sdk`. A loader\n * alone was the first shape — `components: { FRONTEND_FILE_PICKER: () => … }` —\n * and it could not answer the question a surface asks FIRST: what will a\n * selection from this component contain? That has to be readable without\n * downloading the component, because the framework decides how to route the\n * result before it decides to mount anything, and because a reviewer reading a\n * provider's manifest should see the answer without running a browser.\n *\n * Everything except `load` is projected onto the provider's DATA entry by\n * `projectFrontendProviderContribution`, exactly as `sdk.descriptor` is.\n */\nexport interface ProviderFrontendComponentDeclaration extends ProviderFrontendComponentDescriptor {\n /**\n * Loads the component on demand. Must resolve the COMPONENT, not the module:\n * `async () => (await import('./Picker')).Picker`, never\n * `() => import('./Picker')`. The registry detects and reports the second\n * shape, because a module namespace passed to React renders nothing and the\n * stack trace points at React rather than at the provider.\n */\n readonly load: ProviderFrontendComponentLoader;\n}\n\n/**\n * The components a provider offers, by capability token.\n *\n * A provider may claim a capability without shipping a component — declaring\n * `FRONTEND_FILE_PICKER` and offering only constraints is a real and supported\n * shape — so this map is not required to cover `providerCapabilities`.\n */\nexport type ProviderFrontendComponents = Readonly<Record<string, ProviderFrontendComponentDeclaration>>;\n\n/**\n * What a provider's file picker hands back for ONE chosen file.\n *\n * The three arms are the three answers to issue #383 (Q5), and the union exists\n * because the decision was **per vendor**: a picker for a credentialed vendor\n * and a picker for a vendor with a browser-safe public token genuinely cannot\n * return the same thing, and both must ship.\n *\n * `kind` is not a runtime choice. Each arm corresponds to exactly one\n * `ProviderFrontendSelectionDelivery`, the provider DECLARES which one it emits,\n * and the framework refuses a selection whose `kind` contradicts that\n * declaration. Without the refusal the union would be the hedge the decision\n * rejected — a contract that says \"one of these three, we will find out at\n * runtime\" is not a contract an application's file field can be written\n * against.\n */\nexport type ProviderFileSelection =\n | {\n /** @see ProviderFrontendSelectionDelivery.REMOTE_REFERENCE */\n readonly kind: ProviderFrontendSelectionDelivery.REMOTE_REFERENCE;\n /** Opaque to everything in the browser. Only the application backend can resolve it. */\n readonly externalId: string;\n /** What to show the user before the backend has resolved anything. */\n readonly displayName?: string;\n readonly mimeType?: string;\n readonly sizeBytes?: number;\n }\n | {\n /** @see ProviderFrontendSelectionDelivery.BROWSER_READABLE_FILE */\n readonly kind: ProviderFrontendSelectionDelivery.BROWSER_READABLE_FILE;\n readonly file: File;\n }\n | {\n /** @see ProviderFrontendSelectionDelivery.BROWSER_READABLE_URL */\n readonly kind: ProviderFrontendSelectionDelivery.BROWSER_READABLE_URL;\n /** Fetchable by the browser. Its origin must be admitted by the surface's composed CSP. */\n readonly url: string;\n readonly displayName?: string;\n readonly mimeType?: string;\n readonly sizeBytes?: number;\n };\n\n/**\n * The constraints a framework file field imposes on a picker.\n *\n * Resolved by the framework — schema metadata first, then the provider's own\n * `publicConfig` through the capability's named schema — so a picker never\n * re-reads either. `maxSize` is BYTES; a provider stating megabytes in its\n * public config (`maxFileSizeMb`) is converted before it reaches here.\n *\n * ## Why the field names are these and not clearer ones\n *\n * They are the framework file field's OWN names: `resolveFormFieldFileProviderConstraints`\n * in `@wildo-ai/saas-frontend-lib` produces exactly this shape and its\n * `ResolvedFormFieldFileProviderConstraints` is an alias of this type, so there\n * is one source rather than two spellings of one contract.\n *\n * That is not tidiness. The first draft of this interface called the size cap\n * `maxSizeBytes` while the resolver called it `maxSize` — both BYTES, both\n * optional — and TypeScript accepts the assignment: the weak-type check is\n * satisfied by the two names that DO match, so wiring the resolver into a picker\n * would have compiled and silently dropped the size cap. A picker would then\n * accept files the field rejects, and the user finds out after choosing one.\n */\nexport interface ProviderFilePickerConstraints {\n /**\n * A MUTABLE array, deliberately: `@wildo-ai/zod-decorators`' MIME helpers\n * (`isMimeTypeAllowed`, `buildAcceptAttribute`) take `string[]`, and this\n * type's whole reason for existing is to BE the framework file field's own\n * shape rather than a second one. A `readonly string[]` here would be a\n * better type in isolation and would force a cast at every one of those call\n * sites, which is how the drift this interface prevents starts again.\n */\n allowedMimeTypes?: string[];\n /** BYTES, not megabytes. */\n maxSize?: number;\n maxFiles?: number;\n}\n\n/**\n * The props every `FRONTEND_FILE_PICKER` component receives.\n *\n * Declared in this package, not in the frontend library, because BOTH sides need\n * it and only one of them may depend on React: a provider package authors a\n * component against this type, and the framework surface mounts it against the\n * same type. Nothing here is a React type, so the package's one-entry\n * bare-specifier allow-list is untouched.\n *\n * `onSelect` takes an ARRAY even for a single-file field. A picker that supports\n * multi-select otherwise needs a second callback or a hidden convention, and a\n * field that allows one file can reject a second selection with a message\n * instead of silently keeping whichever arrived first — which is what a\n * single-value callback forces it to do.\n */\nexport interface ProviderFilePickerProps {\n /** The provider's own `ref`, so a picker can label what it renders without being told twice. */\n readonly providerRef: string;\n /**\n * The provider's public configuration, already validated against the module's\n * `publicConfigSchema` when it declares one. A picker never re-coerces it.\n */\n readonly publicConfig: Readonly<Record<string, unknown>>;\n readonly constraints: ProviderFilePickerConstraints;\n /**\n * An access token for THIS provider, on behalf of the current user, when the\n * application has one.\n *\n * Optional, and its absence is a real state rather than a defect: a picker\n * that authenticates through its own vendor popup (OneDrive's does) needs\n * nothing here, and an application that has not connected a user's account to\n * this provider has nothing to give. A picker that does need one must call\n * this and report through `onError` when it is absent — never fall back to a\n * token from `publicConfig`, which is served to every browser.\n *\n * Supplying it is the account-connection surface's job (issue #333), which\n * does not exist yet; until it does, the framework passes nothing and a picker\n * that requires a token says so. The prop is declared now so that the\n * dependency is VISIBLE in the contract rather than discovered by whoever\n * writes the second picker.\n */\n getAccessToken?(): Promise<string | undefined>;\n /**\n * Called with everything the user chose. May be called once with several\n * files; must not be called after `onCancel`.\n */\n onSelect(selections: readonly ProviderFileSelection[]): void;\n /** The user dismissed the picker without choosing. */\n onCancel(): void;\n /**\n * The picker could not run — the vendor SDK failed to load, a grant was\n * refused, the vendor returned an error. Reported rather than thrown: a throw\n * inside a picker's own event handler does not reach a React error boundary,\n * so it would be a surface that silently stops responding.\n */\n onError(error: Error): void;\n}\n\n/**\n * Minimal structural view of a Standard Schema v1 validator.\n *\n * Declared here rather than imported, for two reasons that both matter:\n *\n * 1. `@wildo-ai/external-connectors-public` ships into three browser bundles\n * and its bare-specifier allow-list holds exactly one entry. Importing\n * `zod` to type one optional field would widen that allow-list for a\n * TYPE — a runtime cost paid for a compile-time need.\n * 2. Standard Schema is a cross-library contract (Zod 4, Valibot, ArkType all\n * implement it), so typing the field this way lets a provider package\n * validate with whatever it already depends on instead of forcing Zod on\n * every provider author. Zod 4 schemas satisfy this interface as-is.\n *\n * Only the success/issue discrimination is modelled, because only that is used:\n * the surface asks \"is this public config valid, and if not, what is wrong\".\n */\nexport interface ProviderFrontendPublicConfigIssue {\n readonly message: string;\n /**\n * Standard Schema permits a path segment to be either a key or a\n * `{ key }` wrapper; both shapes are accepted so a validator from any\n * implementing library reads correctly.\n */\n readonly path?: ReadonlyArray<PropertyKey | { readonly key: PropertyKey }>;\n}\n\nexport interface ProviderFrontendPublicConfigSuccess<TOutput> {\n readonly value: TOutput;\n readonly issues?: undefined;\n}\n\nexport interface ProviderFrontendPublicConfigFailure {\n readonly issues: ReadonlyArray<ProviderFrontendPublicConfigIssue>;\n}\n\nexport type ProviderFrontendPublicConfigResult<TOutput> =\n | ProviderFrontendPublicConfigSuccess<TOutput>\n | ProviderFrontendPublicConfigFailure;\n\nexport interface ProviderFrontendPublicConfigSchema<TOutput = unknown> {\n readonly '~standard': {\n readonly version: 1;\n readonly vendor: string;\n validate(\n value: unknown,\n ): ProviderFrontendPublicConfigResult<TOutput> | Promise<ProviderFrontendPublicConfigResult<TOutput>>;\n };\n}\n\n/**\n * Strips a provider's component declarations down to the half a JSON channel\n * can carry.\n *\n * ONE named source, reachable from every facet barrel, because there are THREE\n * sites that turn a frontend module into a wire entry and they must not hold\n * three opinions: `projectFrontendProviderContribution` (the companion\n * discovery walk, which feeds the generated artifact), the backend's fallback\n * projection in `frontend-bootstrap.backend.service.ts` (what an application\n * serves when no sync has run), and the hydration join, which takes the CODE\n * side whole and needs no stripping at all.\n *\n * The failure a second opinion produces is the one that surface's own comments\n * already name for the CSP footprint: a provider's declaration would appear on\n * the entry when a sync had run and vanish when it had not — a difference no\n * consumer can see and only production can punish.\n *\n * Returns `undefined` for a provider with no components rather than `{}`, so\n * \"contributes none\" keeps one spelling, the way an absent `sdk` does.\n *\n * ## Why it lives in a browser-bound file\n *\n * Both callers are Node — the companion discovery walk and the backend's\n * fallback projection — and this file's header says everything in it is CODE\n * that never leaves the bundle. The placement is still right: the facet barrels\n * are the only surface BOTH callers can reach (the backend imports\n * `/app`, `/techdoc` and `/website`, never `/companion`), and putting it\n * anywhere else would mean either a fourth subpath for one function or a second\n * copy — which is the exact defect it exists to prevent. It is a pure function\n * with no imports and no state, so a bundler that keeps it keeps a dozen lines.\n */\nexport function projectFrontendComponentDescriptors(\n components: Readonly<Record<string, ProviderFrontendComponentDescriptor & { readonly load?: unknown }>> | undefined,\n): Record<string, ProviderFrontendComponentDescriptor> | undefined {\n if (components === undefined) return undefined;\n\n const descriptors: Record<string, ProviderFrontendComponentDescriptor> = {};\n // An AUTHORED `components: {}` must not reach the wire either. The invariant\n // is \"contributes none has one spelling\", and guarding only on `undefined`\n // would have let the second spelling through from a provider that wrote the\n // empty map by hand.\n if (Object.keys(components).length === 0) return undefined;\n for (const [capability, declaration] of Object.entries(components)) {\n // Rebuilt field by field rather than spread-minus-`load`, so a future field\n // on the declaration is a COMPILE decision about whether it crosses the wire\n // instead of one that crosses by default.\n descriptors[capability] = { selectionDelivery: declaration.selectionDelivery };\n }\n return descriptors;\n}\n"]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The join between the two channels a frontend provider arrives on.
|
|
3
|
+
*
|
|
4
|
+
* ## What this replaces
|
|
5
|
+
*
|
|
6
|
+
* Hydration used to be one channel and a cast: the registry took each JSON
|
|
7
|
+
* entry off `/application-config` and asserted it was a provider module. The
|
|
8
|
+
* assertion held only while the module type carried nothing but strings. The
|
|
9
|
+
* moment a provider needed to load an SDK, the field would have been dropped by
|
|
10
|
+
* `JSON.stringify` — with no error at any layer — and the provider would have
|
|
11
|
+
* looked declared and done nothing.
|
|
12
|
+
*
|
|
13
|
+
* ## The rule
|
|
14
|
+
*
|
|
15
|
+
* A provider is LIVE for a surface when it appears on BOTH channels:
|
|
16
|
+
*
|
|
17
|
+
* - **DATA** (`entries`) — the authority on *which providers this service has
|
|
18
|
+
* turned on, in this environment*. Backend-resolved, per service, and the
|
|
19
|
+
* only channel that can differ between environments.
|
|
20
|
+
* - **CODE** (`modules`) — the authority on *what code this bundle actually
|
|
21
|
+
* contains*. Written by `wildo config sync` into a
|
|
22
|
+
* `frontend-providers.generated.ts` the bundle imports.
|
|
23
|
+
*
|
|
24
|
+
* DATA without CODE is still live — the provider's identity, capabilities and
|
|
25
|
+
* public config are all real and a UI may list it — but it has nothing to
|
|
26
|
+
* execute, so `sdk` and `publicConfigSchema` are absent and a diagnostic names
|
|
27
|
+
* `wildo config sync`. CODE without DATA is not live and is skipped quietly:
|
|
28
|
+
* a bundle legitimately ships code for providers a given environment leaves
|
|
29
|
+
* off, and warning about that would train readers to ignore the channel.
|
|
30
|
+
*
|
|
31
|
+
* The result is a registry of module-shaped values, so every existing consumer
|
|
32
|
+
* reads exactly what it read before. What changed is that the shape is now
|
|
33
|
+
* BUILT rather than asserted, and each field has a stated owner.
|
|
34
|
+
*/
|
|
35
|
+
import type { FrontendProvidersBlock, ProviderFrontendCspFootprint, ProviderFrontendCspFootprintDeclaration, ProviderFrontendScriptDeclaration, ProviderMetadata } from '@wildo-ai/saas-models/public-runtime';
|
|
36
|
+
import type { ProviderFrontendComponents, ProviderFrontendPublicConfigSchema, ProviderFrontendSdk } from './frontend-provider-surface.types';
|
|
37
|
+
/**
|
|
38
|
+
* Why a hydration diagnostic was raised.
|
|
39
|
+
*
|
|
40
|
+
* A named vocabulary rather than message strings: a surface decides what to do
|
|
41
|
+
* with a diagnostic (console, telemetry, a dev overlay) by its kind, and each
|
|
42
|
+
* member is a distinct operator action.
|
|
43
|
+
*/
|
|
44
|
+
export declare enum FrontendProviderHydrationDiagnosticKind {
|
|
45
|
+
/**
|
|
46
|
+
* The service declares this provider, but the bundle carries no code for it.
|
|
47
|
+
* Its data is served and its SDK cannot run. Remedy: `wildo config sync`, so
|
|
48
|
+
* the generated `frontend-providers.generated.ts` imports the provider's
|
|
49
|
+
* facet barrel.
|
|
50
|
+
*/
|
|
51
|
+
CODE_MISSING_FOR_DECLARED_PROVIDER = "CODE_MISSING_FOR_DECLARED_PROVIDER",
|
|
52
|
+
/**
|
|
53
|
+
* The generated module map keys a module under a ref that is not the ref on
|
|
54
|
+
* the module's own metadata. The key is what the join uses, so trusting it
|
|
55
|
+
* would silently bind one provider's code to another's configuration.
|
|
56
|
+
*/
|
|
57
|
+
GENERATED_MODULE_REF_MISMATCH = "GENERATED_MODULE_REF_MISMATCH",
|
|
58
|
+
/**
|
|
59
|
+
* The entry's CSP footprint or SDK descriptor disagrees with the module's.
|
|
60
|
+
* The entry is what the service's Content-Security-Policy was composed from,
|
|
61
|
+
* so a disagreement means the generated artifact predates the module — and
|
|
62
|
+
* the consequence lands in production only, because CSP is report-only in
|
|
63
|
+
* development. Remedy: `wildo config sync`.
|
|
64
|
+
*/
|
|
65
|
+
GENERATED_ARTIFACT_STALE = "GENERATED_ARTIFACT_STALE",
|
|
66
|
+
/**
|
|
67
|
+
* The bundle carries code for providers and the service declared NONE.
|
|
68
|
+
*
|
|
69
|
+
* Per-provider, code-without-data is silent on purpose — a bundle legitimately
|
|
70
|
+
* ships code an environment leaves off. ALL code and ZERO data is a different
|
|
71
|
+
* signal: almost always a backend older than this bundle, or a service whose
|
|
72
|
+
* provider scope was never authored. Every consumer then degrades with no
|
|
73
|
+
* symptom at all, which is the shape this diagnostic exists to break.
|
|
74
|
+
*/
|
|
75
|
+
DATA_MISSING_FOR_BUNDLED_PROVIDERS = "DATA_MISSING_FOR_BUNDLED_PROVIDERS",
|
|
76
|
+
/** The provider's `publicConfig` did not satisfy the schema the module declares. */
|
|
77
|
+
PUBLIC_CONFIG_INVALID = "PUBLIC_CONFIG_INVALID",
|
|
78
|
+
/**
|
|
79
|
+
* The declared `publicConfigSchema` validated asynchronously. Hydration is
|
|
80
|
+
* synchronous — it runs before first paint on three different bundlers — so
|
|
81
|
+
* an async validator cannot be awaited here and its provider is treated as
|
|
82
|
+
* having no code. Standard Schema permits async validation; Zod is
|
|
83
|
+
* synchronous, which is why this is a refusal rather than a redesign.
|
|
84
|
+
*/
|
|
85
|
+
PUBLIC_CONFIG_SCHEMA_ASYNC = "PUBLIC_CONFIG_SCHEMA_ASYNC"
|
|
86
|
+
}
|
|
87
|
+
export interface FrontendProviderHydrationDiagnostic {
|
|
88
|
+
readonly kind: FrontendProviderHydrationDiagnosticKind;
|
|
89
|
+
readonly providerRef: string;
|
|
90
|
+
/** One sentence naming the remedy, safe to log verbatim. */
|
|
91
|
+
readonly message: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The facet-agnostic view of a provider module the CODE channel supplies.
|
|
95
|
+
*
|
|
96
|
+
* All three facet module types satisfy it structurally; naming it separately
|
|
97
|
+
* keeps this join free of any facet's branded capability types, which are the
|
|
98
|
+
* one thing that genuinely cannot cross the wire (see the note on the narrowing
|
|
99
|
+
* in each facet's `composeHydratedFrontend<Facet>Providers`).
|
|
100
|
+
*/
|
|
101
|
+
export interface FrontendProviderCodeModule {
|
|
102
|
+
metadata: ProviderMetadata;
|
|
103
|
+
csp?: ProviderFrontendCspFootprintDeclaration;
|
|
104
|
+
sdk?: ProviderFrontendSdk;
|
|
105
|
+
components?: ProviderFrontendComponents;
|
|
106
|
+
publicConfigSchema?: ProviderFrontendPublicConfigSchema;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* One provider after the join: DATA for everything JSON can carry, CODE for
|
|
110
|
+
* everything it cannot.
|
|
111
|
+
*
|
|
112
|
+
* `providerCapabilities` and `protocols` are `string` here because that is what
|
|
113
|
+
* the wire carries. Narrowing them to a facet's open union is the one step no
|
|
114
|
+
* runtime check can perform — an application extends that union by TypeScript
|
|
115
|
+
* module augmentation, so its members do not exist at runtime to be checked
|
|
116
|
+
* against — and it therefore happens once, visibly, at each facet boundary.
|
|
117
|
+
*/
|
|
118
|
+
export interface HydratedFrontendProviderModule {
|
|
119
|
+
metadata: ProviderMetadata;
|
|
120
|
+
providerCapabilities: ReadonlyArray<string>;
|
|
121
|
+
protocols: ReadonlyArray<string>;
|
|
122
|
+
publicConfig: Readonly<Record<string, unknown>>;
|
|
123
|
+
csp?: ProviderFrontendCspFootprint;
|
|
124
|
+
scripts?: ReadonlyArray<ProviderFrontendScriptDeclaration>;
|
|
125
|
+
sdk?: ProviderFrontendSdk;
|
|
126
|
+
components?: ProviderFrontendComponents;
|
|
127
|
+
publicConfigSchema?: ProviderFrontendPublicConfigSchema;
|
|
128
|
+
}
|
|
129
|
+
export interface HydrateFrontendProvidersInput<TCodeModule extends FrontendProviderCodeModule> {
|
|
130
|
+
/** The DATA channel: the block hydrated from the backend, or read from the generated artifact. */
|
|
131
|
+
readonly entries: FrontendProvidersBlock | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* The CODE channel: `generatedFrontendProviderModules` from this service's
|
|
134
|
+
* `frontend-providers.generated.ts`. Absent is legal and common — a service
|
|
135
|
+
* with no package-shipped providers ships no such file.
|
|
136
|
+
*/
|
|
137
|
+
readonly modules?: Readonly<Record<string, TCodeModule>>;
|
|
138
|
+
readonly onDiagnostic?: (diagnostic: FrontendProviderHydrationDiagnostic) => void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Joins the DATA and CODE channels into one module map, ready for
|
|
142
|
+
* `composeProviderRegistry`.
|
|
143
|
+
*
|
|
144
|
+
* Synchronous on purpose: it runs before first paint on three bundlers, and an
|
|
145
|
+
* asynchronous join would either block the first render or leave a window in
|
|
146
|
+
* which a consumer reads an empty registry and degrades silently — which is the
|
|
147
|
+
* shape of the bug this whole surface exists to remove.
|
|
148
|
+
*/
|
|
149
|
+
export declare function hydrateFrontendProviderModules<TCodeModule extends FrontendProviderCodeModule>(input: HydrateFrontendProvidersInput<TCodeModule>): Map<string, HydratedFrontendProviderModule>;
|
|
150
|
+
//# sourceMappingURL=hydrate-frontend-providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate-frontend-providers.d.ts","sourceRoot":"","sources":["../../../../src/shared/hydrate-frontend-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,uCAAuC,EACvC,iCAAiC,EACjC,gBAAgB,EACjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EACV,0BAA0B,EAG1B,kCAAkC,EAClC,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;GAMG;AACH,oBAAY,uCAAuC;IACjD;;;;;OAKG;IACH,kCAAkC,uCAAuC;IACzE;;;;OAIG;IACH,6BAA6B,kCAAkC;IAC/D;;;;;;OAMG;IACH,wBAAwB,6BAA6B;IACrD;;;;;;;;OAQG;IACH,kCAAkC,uCAAuC;IACzE,oFAAoF;IACpF,qBAAqB,0BAA0B;IAC/C;;;;;;OAMG;IACH,0BAA0B,+BAA+B;CAC1D;AAED,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,IAAI,EAAE,uC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S,0BAA0B,EAC3F,KAAK,EAAE,6BAA6B,CAAC,WAAW,CAAC,GAChD,GAAG,CAAC,MAAM,EAAE,8BAA8B,CAAC,CA2I7C"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The join between the two channels a frontend provider arrives on.
|
|
3
|
+
*
|
|
4
|
+
* ## What this replaces
|
|
5
|
+
*
|
|
6
|
+
* Hydration used to be one channel and a cast: the registry took each JSON
|
|
7
|
+
* entry off `/application-config` and asserted it was a provider module. The
|
|
8
|
+
* assertion held only while the module type carried nothing but strings. The
|
|
9
|
+
* moment a provider needed to load an SDK, the field would have been dropped by
|
|
10
|
+
* `JSON.stringify` — with no error at any layer — and the provider would have
|
|
11
|
+
* looked declared and done nothing.
|
|
12
|
+
*
|
|
13
|
+
* ## The rule
|
|
14
|
+
*
|
|
15
|
+
* A provider is LIVE for a surface when it appears on BOTH channels:
|
|
16
|
+
*
|
|
17
|
+
* - **DATA** (`entries`) — the authority on *which providers this service has
|
|
18
|
+
* turned on, in this environment*. Backend-resolved, per service, and the
|
|
19
|
+
* only channel that can differ between environments.
|
|
20
|
+
* - **CODE** (`modules`) — the authority on *what code this bundle actually
|
|
21
|
+
* contains*. Written by `wildo config sync` into a
|
|
22
|
+
* `frontend-providers.generated.ts` the bundle imports.
|
|
23
|
+
*
|
|
24
|
+
* DATA without CODE is still live — the provider's identity, capabilities and
|
|
25
|
+
* public config are all real and a UI may list it — but it has nothing to
|
|
26
|
+
* execute, so `sdk` and `publicConfigSchema` are absent and a diagnostic names
|
|
27
|
+
* `wildo config sync`. CODE without DATA is not live and is skipped quietly:
|
|
28
|
+
* a bundle legitimately ships code for providers a given environment leaves
|
|
29
|
+
* off, and warning about that would train readers to ignore the channel.
|
|
30
|
+
*
|
|
31
|
+
* The result is a registry of module-shaped values, so every existing consumer
|
|
32
|
+
* reads exactly what it read before. What changed is that the shape is now
|
|
33
|
+
* BUILT rather than asserted, and each field has a stated owner.
|
|
34
|
+
*/
|
|
35
|
+
import { normalizeProviderFrontendCspFootprint } from '@wildo-ai/saas-models/public-runtime';
|
|
36
|
+
/**
|
|
37
|
+
* Why a hydration diagnostic was raised.
|
|
38
|
+
*
|
|
39
|
+
* A named vocabulary rather than message strings: a surface decides what to do
|
|
40
|
+
* with a diagnostic (console, telemetry, a dev overlay) by its kind, and each
|
|
41
|
+
* member is a distinct operator action.
|
|
42
|
+
*/
|
|
43
|
+
export var FrontendProviderHydrationDiagnosticKind;
|
|
44
|
+
(function (FrontendProviderHydrationDiagnosticKind) {
|
|
45
|
+
/**
|
|
46
|
+
* The service declares this provider, but the bundle carries no code for it.
|
|
47
|
+
* Its data is served and its SDK cannot run. Remedy: `wildo config sync`, so
|
|
48
|
+
* the generated `frontend-providers.generated.ts` imports the provider's
|
|
49
|
+
* facet barrel.
|
|
50
|
+
*/
|
|
51
|
+
FrontendProviderHydrationDiagnosticKind["CODE_MISSING_FOR_DECLARED_PROVIDER"] = "CODE_MISSING_FOR_DECLARED_PROVIDER";
|
|
52
|
+
/**
|
|
53
|
+
* The generated module map keys a module under a ref that is not the ref on
|
|
54
|
+
* the module's own metadata. The key is what the join uses, so trusting it
|
|
55
|
+
* would silently bind one provider's code to another's configuration.
|
|
56
|
+
*/
|
|
57
|
+
FrontendProviderHydrationDiagnosticKind["GENERATED_MODULE_REF_MISMATCH"] = "GENERATED_MODULE_REF_MISMATCH";
|
|
58
|
+
/**
|
|
59
|
+
* The entry's CSP footprint or SDK descriptor disagrees with the module's.
|
|
60
|
+
* The entry is what the service's Content-Security-Policy was composed from,
|
|
61
|
+
* so a disagreement means the generated artifact predates the module — and
|
|
62
|
+
* the consequence lands in production only, because CSP is report-only in
|
|
63
|
+
* development. Remedy: `wildo config sync`.
|
|
64
|
+
*/
|
|
65
|
+
FrontendProviderHydrationDiagnosticKind["GENERATED_ARTIFACT_STALE"] = "GENERATED_ARTIFACT_STALE";
|
|
66
|
+
/**
|
|
67
|
+
* The bundle carries code for providers and the service declared NONE.
|
|
68
|
+
*
|
|
69
|
+
* Per-provider, code-without-data is silent on purpose — a bundle legitimately
|
|
70
|
+
* ships code an environment leaves off. ALL code and ZERO data is a different
|
|
71
|
+
* signal: almost always a backend older than this bundle, or a service whose
|
|
72
|
+
* provider scope was never authored. Every consumer then degrades with no
|
|
73
|
+
* symptom at all, which is the shape this diagnostic exists to break.
|
|
74
|
+
*/
|
|
75
|
+
FrontendProviderHydrationDiagnosticKind["DATA_MISSING_FOR_BUNDLED_PROVIDERS"] = "DATA_MISSING_FOR_BUNDLED_PROVIDERS";
|
|
76
|
+
/** The provider's `publicConfig` did not satisfy the schema the module declares. */
|
|
77
|
+
FrontendProviderHydrationDiagnosticKind["PUBLIC_CONFIG_INVALID"] = "PUBLIC_CONFIG_INVALID";
|
|
78
|
+
/**
|
|
79
|
+
* The declared `publicConfigSchema` validated asynchronously. Hydration is
|
|
80
|
+
* synchronous — it runs before first paint on three different bundlers — so
|
|
81
|
+
* an async validator cannot be awaited here and its provider is treated as
|
|
82
|
+
* having no code. Standard Schema permits async validation; Zod is
|
|
83
|
+
* synchronous, which is why this is a refusal rather than a redesign.
|
|
84
|
+
*/
|
|
85
|
+
FrontendProviderHydrationDiagnosticKind["PUBLIC_CONFIG_SCHEMA_ASYNC"] = "PUBLIC_CONFIG_SCHEMA_ASYNC";
|
|
86
|
+
})(FrontendProviderHydrationDiagnosticKind || (FrontendProviderHydrationDiagnosticKind = {}));
|
|
87
|
+
function sameOriginList(left, right) {
|
|
88
|
+
if (left.length !== right.length)
|
|
89
|
+
return false;
|
|
90
|
+
const sortedLeft = [...left].sort();
|
|
91
|
+
const sortedRight = [...right].sort();
|
|
92
|
+
return sortedLeft.every((origin, index) => origin === sortedRight[index]);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Compares the footprint the CSP was composed from against the one the module
|
|
96
|
+
* declares today. Order-insensitive, because neither channel promises an order
|
|
97
|
+
* and a spurious staleness warning is how a real one stops being read.
|
|
98
|
+
*/
|
|
99
|
+
function sameCspFootprint(entryFootprint, moduleDeclaration) {
|
|
100
|
+
if (entryFootprint === undefined || moduleDeclaration === undefined) {
|
|
101
|
+
return entryFootprint === moduleDeclaration;
|
|
102
|
+
}
|
|
103
|
+
// The module side is a DECLARATION — partial by design — so it is normalized
|
|
104
|
+
// before comparison. Without this, a provider that named one bucket would
|
|
105
|
+
// differ from its own served footprint in the five it did not name, and the
|
|
106
|
+
// staleness diagnostic would fire on every correctly-generated artifact.
|
|
107
|
+
const moduleFootprint = normalizeProviderFrontendCspFootprint(moduleDeclaration);
|
|
108
|
+
const buckets = [
|
|
109
|
+
'scriptOrigins',
|
|
110
|
+
'connectOrigins',
|
|
111
|
+
'frameOrigins',
|
|
112
|
+
'imgOrigins',
|
|
113
|
+
'styleOrigins',
|
|
114
|
+
'fontOrigins',
|
|
115
|
+
];
|
|
116
|
+
return buckets.every((bucket) => sameOriginList(entryFootprint[bucket], moduleFootprint[bucket]));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Validates `publicConfig` against the module's declared schema.
|
|
120
|
+
*
|
|
121
|
+
* Returns the validated config, or `undefined` when the provider must be
|
|
122
|
+
* treated as code-less. Failing that way rather than dropping the provider
|
|
123
|
+
* entirely is deliberate: a misconfigured analytics provider must not take a
|
|
124
|
+
* page down, but it must also not half-run — so its data stays visible and
|
|
125
|
+
* nothing of it executes.
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* Standard Schema discriminates success from failure by the PRESENCE of
|
|
129
|
+
* `issues`, which is a shape TypeScript narrows only through an explicit
|
|
130
|
+
* predicate — the success member declares `issues?: undefined`, so a bare
|
|
131
|
+
* `result.issues !== undefined` leaves the union intact at the use site.
|
|
132
|
+
*/
|
|
133
|
+
function isPublicConfigFailure(result) {
|
|
134
|
+
return result.issues !== undefined;
|
|
135
|
+
}
|
|
136
|
+
function validatePublicConfig(providerRef, publicConfig, schema, raise) {
|
|
137
|
+
const result = schema['~standard'].validate(publicConfig);
|
|
138
|
+
if (result instanceof Promise) {
|
|
139
|
+
raise({
|
|
140
|
+
kind: FrontendProviderHydrationDiagnosticKind.PUBLIC_CONFIG_SCHEMA_ASYNC,
|
|
141
|
+
providerRef,
|
|
142
|
+
message: `Provider "${providerRef}" declares an asynchronous publicConfigSchema. Frontend provider hydration is `
|
|
143
|
+
+ 'synchronous, so the schema cannot be awaited; declare a synchronous validator (a Zod schema is one).',
|
|
144
|
+
});
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
if (isPublicConfigFailure(result)) {
|
|
148
|
+
const detail = result.issues
|
|
149
|
+
.map((issue) => {
|
|
150
|
+
const path = (issue.path ?? [])
|
|
151
|
+
.map((segment) => String(typeof segment === 'object' ? segment.key : segment))
|
|
152
|
+
.join('.');
|
|
153
|
+
return path.length > 0 ? `${path}: ${issue.message}` : issue.message;
|
|
154
|
+
})
|
|
155
|
+
.join('; ');
|
|
156
|
+
raise({
|
|
157
|
+
kind: FrontendProviderHydrationDiagnosticKind.PUBLIC_CONFIG_INVALID,
|
|
158
|
+
providerRef,
|
|
159
|
+
message: `Provider "${providerRef}" was served a publicConfig its own schema rejects, so none of its code will run. ${detail}`,
|
|
160
|
+
});
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
return result.value;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Joins the DATA and CODE channels into one module map, ready for
|
|
167
|
+
* `composeProviderRegistry`.
|
|
168
|
+
*
|
|
169
|
+
* Synchronous on purpose: it runs before first paint on three bundlers, and an
|
|
170
|
+
* asynchronous join would either block the first render or leave a window in
|
|
171
|
+
* which a consumer reads an empty registry and degrades silently — which is the
|
|
172
|
+
* shape of the bug this whole surface exists to remove.
|
|
173
|
+
*/
|
|
174
|
+
export function hydrateFrontendProviderModules(input) {
|
|
175
|
+
const raise = (diagnostic) => {
|
|
176
|
+
input.onDiagnostic?.(diagnostic);
|
|
177
|
+
};
|
|
178
|
+
const generatedModules = input.modules ?? {};
|
|
179
|
+
const hydrated = new Map();
|
|
180
|
+
const declaredRefs = Object.keys(input.entries?.providers ?? {});
|
|
181
|
+
const bundledRefs = Object.keys(generatedModules);
|
|
182
|
+
if (declaredRefs.length === 0 && bundledRefs.length > 0) {
|
|
183
|
+
raise({
|
|
184
|
+
kind: FrontendProviderHydrationDiagnosticKind.DATA_MISSING_FOR_BUNDLED_PROVIDERS,
|
|
185
|
+
// No single provider owns this: it is a statement about the payload.
|
|
186
|
+
providerRef: '',
|
|
187
|
+
message: `This bundle carries code for ${bundledRefs.length} provider(s) — ${bundledRefs.join(', ')} — and the `
|
|
188
|
+
+ 'backend declared none for this service, so every provider-backed surface will render as though none '
|
|
189
|
+
+ 'exists. Usually a backend older than this bundle, or a frontend service whose provider scope was '
|
|
190
|
+
+ 'never authored; `wildo config sync` settles the second.',
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
for (const [ref, entry] of Object.entries(input.entries?.providers ?? {})) {
|
|
194
|
+
const generated = Object.prototype.hasOwnProperty.call(generatedModules, ref)
|
|
195
|
+
? generatedModules[ref]
|
|
196
|
+
: undefined;
|
|
197
|
+
let code = generated;
|
|
198
|
+
if (code !== undefined && code.metadata.ref !== ref) {
|
|
199
|
+
raise({
|
|
200
|
+
kind: FrontendProviderHydrationDiagnosticKind.GENERATED_MODULE_REF_MISMATCH,
|
|
201
|
+
providerRef: ref,
|
|
202
|
+
message: `The generated frontend provider module map lists "${ref}" but the module it points at declares ref `
|
|
203
|
+
+ `"${code.metadata.ref}". Its code is ignored rather than bound to another provider's configuration; `
|
|
204
|
+
+ 'regenerate with `wildo config sync`.',
|
|
205
|
+
});
|
|
206
|
+
code = undefined;
|
|
207
|
+
}
|
|
208
|
+
if (code !== undefined && !sameCspFootprint(entry.csp, code.csp)) {
|
|
209
|
+
raise({
|
|
210
|
+
kind: FrontendProviderHydrationDiagnosticKind.GENERATED_ARTIFACT_STALE,
|
|
211
|
+
providerRef: ref,
|
|
212
|
+
message: `Provider "${ref}" declares a CSP footprint that differs from the one its served entry carries, so the `
|
|
213
|
+
+ "service's Content-Security-Policy was composed from a stale footprint. That surfaces in production "
|
|
214
|
+
+ 'only, because CSP is report-only in development. Regenerate with `wildo config sync`.',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (code !== undefined && entry.sdk?.packageName !== code.sdk?.descriptor.packageName) {
|
|
218
|
+
raise({
|
|
219
|
+
kind: FrontendProviderHydrationDiagnosticKind.GENERATED_ARTIFACT_STALE,
|
|
220
|
+
providerRef: ref,
|
|
221
|
+
message: `Provider "${ref}" declares SDK package "${code.sdk?.descriptor.packageName ?? '(none)'}" but its served `
|
|
222
|
+
+ `entry says "${entry.sdk?.packageName ?? '(none)'}". Regenerate with \`wildo config sync\`.`,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// The same staleness question for the component declarations (#380).
|
|
226
|
+
//
|
|
227
|
+
// It matters more here than for `csp` or `sdk`, because these two copies are
|
|
228
|
+
// read by DIFFERENT parties for the SAME decision. The registry takes its
|
|
229
|
+
// descriptor from the CODE side and the framework refuses a selection
|
|
230
|
+
// against it; a reviewer, the CLI and any build step read the DATA side. So
|
|
231
|
+
// a stale artifact makes the manifest and the ENFORCED contract disagree —
|
|
232
|
+
// a provider whose entry says it returns a remote reference while its code
|
|
233
|
+
// says otherwise — which is precisely the property issue #383 was answered
|
|
234
|
+
// to establish.
|
|
235
|
+
if (code !== undefined) {
|
|
236
|
+
for (const [capability, declared] of Object.entries(code.components ?? {})) {
|
|
237
|
+
const served = entry.components?.[capability]?.selectionDelivery;
|
|
238
|
+
if (served === declared.selectionDelivery)
|
|
239
|
+
continue;
|
|
240
|
+
raise({
|
|
241
|
+
kind: FrontendProviderHydrationDiagnosticKind.GENERATED_ARTIFACT_STALE,
|
|
242
|
+
providerRef: ref,
|
|
243
|
+
message: `Provider "${ref}" declares its "${capability}" component delivers `
|
|
244
|
+
+ `"${declared.selectionDelivery ?? '(none)'}" but its served entry says `
|
|
245
|
+
+ `"${served ?? '(none)'}". The framework enforces the CODE side, so the manifest a reviewer `
|
|
246
|
+
+ 'reads and the contract actually held would disagree. Regenerate with `wildo config sync`.',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
let publicConfig = (entry.publicConfig ?? {});
|
|
251
|
+
if (code?.publicConfigSchema !== undefined) {
|
|
252
|
+
const validated = validatePublicConfig(ref, publicConfig, code.publicConfigSchema, raise);
|
|
253
|
+
if (validated === undefined) {
|
|
254
|
+
code = undefined;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
publicConfig = validated;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (code === undefined && generated === undefined) {
|
|
261
|
+
raise({
|
|
262
|
+
kind: FrontendProviderHydrationDiagnosticKind.CODE_MISSING_FOR_DECLARED_PROVIDER,
|
|
263
|
+
providerRef: ref,
|
|
264
|
+
message: `Frontend provider "${ref}" is declared for this service but the bundle carries no code for it, so its `
|
|
265
|
+
+ 'SDK and components are unavailable. Run `wildo config sync` to regenerate '
|
|
266
|
+
+ 'frontend-providers.generated.ts.',
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// The DATA channel is authoritative for everything it can carry: it is the
|
|
270
|
+
// one that knows what this service turned on, in this environment. The CODE
|
|
271
|
+
// channel contributes only what JSON cannot express — which is why the two
|
|
272
|
+
// executable fields are read off `code` explicitly rather than spread: a
|
|
273
|
+
// spread would also copy the code module's own stale `csp`, and the served
|
|
274
|
+
// footprint is the one the policy was composed from.
|
|
275
|
+
hydrated.set(ref, {
|
|
276
|
+
// The entry's metadata is structurally looser than `ProviderMetadata`:
|
|
277
|
+
// `ProviderOriginSchema` is a plain object whose "GENERATED implies a
|
|
278
|
+
// catalogue provenance" rule is a `superRefine`, and a refinement cannot
|
|
279
|
+
// be expressed in an inferred type. Every entry reaching this join has
|
|
280
|
+
// been through that parse — the app parses the bootstrap response, the
|
|
281
|
+
// website and the technical doc parse the materialized artifact — so the
|
|
282
|
+
// rule holds and the narrowing is stating what the parse just proved.
|
|
283
|
+
// Exactly the assertion `defineProviderMetadata` makes for the same
|
|
284
|
+
// schema, at the other end of the same wire.
|
|
285
|
+
metadata: entry.metadata,
|
|
286
|
+
providerCapabilities: [...entry.providerCapabilities],
|
|
287
|
+
protocols: [...entry.protocols],
|
|
288
|
+
publicConfig,
|
|
289
|
+
csp: entry.csp,
|
|
290
|
+
scripts: entry.scripts,
|
|
291
|
+
sdk: code?.sdk,
|
|
292
|
+
components: code?.components,
|
|
293
|
+
publicConfigSchema: code?.publicConfigSchema,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return hydrated;
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=hydrate-frontend-providers.js.map
|