@oneie/sdk 0.14.11 → 0.14.13
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 +6 -1
- package/dist/.build-fingerprint +1 -0
- package/dist/billing.d.ts +12 -0
- package/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +32 -5
- package/dist/billing.js.map +1 -1
- package/dist/blocks.d.ts +126 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +407 -0
- package/dist/blocks.js.map +1 -0
- package/dist/client.d.ts +0 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -23
- package/dist/client.js.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +26 -6
- package/dist/compile.js.map +1 -1
- package/dist/fetch.d.ts +17 -2
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +22 -26
- package/dist/fetch.js.map +1 -1
- package/dist/fn-allowlist.d.ts +27 -0
- package/dist/fn-allowlist.d.ts.map +1 -0
- package/dist/fn-allowlist.js +60 -0
- package/dist/fn-allowlist.js.map +1 -0
- package/dist/generated/fn-map.d.ts +2 -2
- package/dist/generated/fn-map.d.ts.map +1 -1
- package/dist/generated/fn-map.js +480 -13
- package/dist/generated/fn-map.js.map +1 -1
- package/dist/generated/schemas/index.d.ts +1 -1
- package/dist/generated/schemas.d.ts +77 -3
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/generated/schemas.js +28 -3
- package/dist/generated/schemas.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/market.d.ts +37 -1
- package/dist/market.d.ts.map +1 -1
- package/dist/market.js +26 -1
- package/dist/market.js.map +1 -1
- package/dist/receiver-action.d.ts +4 -0
- package/dist/receiver-action.d.ts.map +1 -0
- package/dist/receiver-action.js +38 -0
- package/dist/receiver-action.js.map +1 -0
- package/dist/receivers.d.ts +902 -24
- package/dist/receivers.d.ts.map +1 -1
- package/dist/receivers.js +1363 -40
- package/dist/receivers.js.map +1 -1
- package/dist/role-actions.d.ts +28 -0
- package/dist/role-actions.d.ts.map +1 -0
- package/dist/role-actions.js +68 -0
- package/dist/role-actions.js.map +1 -0
- package/dist/role-tiers.d.ts +45 -0
- package/dist/role-tiers.d.ts.map +1 -0
- package/dist/role-tiers.js +99 -0
- package/dist/role-tiers.js.map +1 -0
- package/dist/schemas.d.ts +23 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +21 -0
- package/dist/schemas.js.map +1 -1
- package/dist/work-contract-grammar.json +44 -0
- package/package.json +22 -2
package/README.md
CHANGED
|
@@ -48,6 +48,11 @@ highways.forEach(h => console.log(`${h.path}: ${h.net}`));
|
|
|
48
48
|
| `@oneie/sdk/openapi` | `buildReceiverPayload()` — generate the receiver `oneOf` for `openapi.yaml` (`bun run generate:openapi`) |
|
|
49
49
|
| `@oneie/sdk/client` | `SubstrateClient` as a direct subpath (skips the barrel) |
|
|
50
50
|
| `@oneie/sdk/brain` | `BrainClient` — CF-Worker-safe substrate client (use this, never the bare barrel, in a Worker) |
|
|
51
|
+
| `@oneie/sdk/blocks` | `normalizeBlockProps()` — land an agent's generated copy on the fields the block that RENDERS reads. Puck's family collapse unions every member's fields into one registration, so a prop can be declared, accepted and still invisible; this resolves the member and rewrites the keys onto its own vocabulary. Schema-agnostic: pass your own `BlockSchema` |
|
|
52
|
+
| `@oneie/sdk/fn-allowlist` | The TypeQL functions callable through `fn()` — one list, so a caller and the gateway cannot disagree |
|
|
53
|
+
| `@oneie/sdk/role-tiers` | `tierOf()` — the four rungs (`owner` · `admin` · `member` · `viewer`) as an ordered comparison |
|
|
54
|
+
| `@oneie/sdk/role-actions` | `minTier()` — the per-action floor the tier is compared against |
|
|
55
|
+
| `@oneie/sdk/receiver-action` | `receiverAction()` — the receiver a role-gated action resolves to |
|
|
51
56
|
| `@oneie/sdk/gateway` | `GatewayClient` — typed client for the `api.one.ie` gateway |
|
|
52
57
|
| `@oneie/sdk/types` | Type definitions only — `Outcome<T>`, `Signal`, and friends |
|
|
53
58
|
| `@oneie/sdk/telemetry` | `emit()`, opt-out helpers — the anonymous usage-signal layer |
|
|
@@ -55,7 +60,7 @@ highways.forEach(h => console.log(`${h.path}: ${h.net}`));
|
|
|
55
60
|
| `@oneie/sdk/work-contract` | Work-contract primitives — deterministic gate rails every page inherits |
|
|
56
61
|
| `@oneie/sdk/market` | Marketplace helpers — list, hire, bounty |
|
|
57
62
|
| `@oneie/sdk/billing` | Billing/credits helpers |
|
|
58
|
-
| `@oneie/sdk/fetch` | `oneFetch()`, `createAgent()` — x402-aware fetch wrapper
|
|
63
|
+
| `@oneie/sdk/fetch` | `oneFetch()`, `createAgent({ pay })` — x402-aware fetch wrapper. The buyer supplies its own `pay(option) => txHash` signer; the SDK never signs, never asks a server to pay, and holds no chain library. Without a signer a 402 throws `PaymentError`. `~/.oneie/budget.json` is an **advisory** self-ledger, not a control (`PaymentError`, `BudgetExceededError`, `X402NetworkError`) |
|
|
59
64
|
| `@oneie/sdk/templates` | `TEMPLATES`, `tqlToManifest()`, `BASE_MANIFEST` — scaffold manifests for `oneie create` |
|
|
60
65
|
| `@oneie/sdk/generated/fn-map` | Generated TypeQL function map — backs the CLI's `fn run` and MCP's `fn.ts` tools |
|
|
61
66
|
| `@oneie/sdk/generated/skins/engineering` | Generated skin vocabulary map |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
838c0e63656afd0c9f2fde06926410fec459f840a8d04eec6b2cd81c256420db
|
package/dist/billing.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Billing helpers — pure, no I/O.
|
|
3
3
|
*
|
|
4
|
+
* CREDITS_PER_USD: the canonical credit rate.
|
|
4
5
|
* rateFor: convert OpenRouter KV blob pricing → platform credits per 1k tokens.
|
|
5
6
|
* computeBurn: calculate billed amount from upstream cost + margin config.
|
|
6
7
|
*/
|
|
@@ -12,6 +13,17 @@ export type RateModel = {
|
|
|
12
13
|
export type RateBlob = {
|
|
13
14
|
models: RateModel[];
|
|
14
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* The credit rate. One thousand credits to the dollar, so 1 credit = $0.001.
|
|
18
|
+
* This is the only place the rate is declared. Import it, never retype it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CREDITS_PER_USD = 1000;
|
|
21
|
+
/** The same rate read the other way, for pricing a single credit. */
|
|
22
|
+
export declare const USD_PER_CREDIT: number;
|
|
23
|
+
/** Convert dollars to credits. Rounds, because credits are whole units. */
|
|
24
|
+
export declare function creditsForUsd(usd: number): number;
|
|
25
|
+
/** Convert cents to credits. Stripe amounts arrive in cents. */
|
|
26
|
+
export declare function creditsForCents(cents: number): number;
|
|
15
27
|
/**
|
|
16
28
|
* Convert a model's live OpenRouter pricing to platform credits per 1k tokens.
|
|
17
29
|
* Pass the parsed KV blob (`openrouter:models:v1`) from the caller's KV read.
|
package/dist/billing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACtF,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,SAAS,EAAE,CAAA;CAAE,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,eAAe,OAAQ,CAAA;AAEpC,qEAAqE;AACrE,eAAO,MAAM,cAAc,QAAsB,CAAA;AAEjD,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,GACvB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CA6BjD;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC5F,CAAA;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAwB5D"}
|
package/dist/billing.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Billing helpers — pure, no I/O.
|
|
3
3
|
*
|
|
4
|
+
* CREDITS_PER_USD: the canonical credit rate.
|
|
4
5
|
* rateFor: convert OpenRouter KV blob pricing → platform credits per 1k tokens.
|
|
5
6
|
* computeBurn: calculate billed amount from upstream cost + margin config.
|
|
6
7
|
*/
|
|
7
|
-
/**
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The credit rate. One thousand credits to the dollar, so 1 credit = $0.001.
|
|
10
|
+
* This is the only place the rate is declared. Import it, never retype it.
|
|
11
|
+
*/
|
|
12
|
+
export const CREDITS_PER_USD = 1_000;
|
|
13
|
+
/** The same rate read the other way, for pricing a single credit. */
|
|
14
|
+
export const USD_PER_CREDIT = 1 / CREDITS_PER_USD;
|
|
15
|
+
/** Convert dollars to credits. Rounds, because credits are whole units. */
|
|
16
|
+
export function creditsForUsd(usd) {
|
|
17
|
+
return Math.round(usd * CREDITS_PER_USD);
|
|
18
|
+
}
|
|
19
|
+
/** Convert cents to credits. Stripe amounts arrive in cents. */
|
|
20
|
+
export function creditsForCents(cents) {
|
|
21
|
+
return creditsForUsd(cents / 100);
|
|
22
|
+
}
|
|
9
23
|
/**
|
|
10
24
|
* Convert a model's live OpenRouter pricing to platform credits per 1k tokens.
|
|
11
25
|
* Pass the parsed KV blob (`openrouter:models:v1`) from the caller's KV read.
|
|
@@ -18,13 +32,26 @@ export function rateFor(modelId, kvBlob) {
|
|
|
18
32
|
if (m?.promptPrice) {
|
|
19
33
|
const pIn = parseFloat(m.promptPrice);
|
|
20
34
|
const pOut = m.completionPrice ? parseFloat(m.completionPrice) : pIn * 3;
|
|
35
|
+
// NOT rounded. A rate is not money yet, and rounding one to a whole
|
|
36
|
+
// credit here throws away the cheap end of the model list: at 1,000
|
|
37
|
+
// credits to the dollar, gpt-4o-mini input prices at 0.15 credits per
|
|
38
|
+
// 1k tokens, which rounds to zero, and haiku at 0.8 rounds to 1 — a 25%
|
|
39
|
+
// overcharge. Both callers already divide by 1,000 and round at the
|
|
40
|
+
// charge (api/chat.ts upstreamCredits, channels/cost-estimate.ts), which
|
|
41
|
+
// is the only place rounding belongs.
|
|
21
42
|
return {
|
|
22
|
-
input_per_1k:
|
|
23
|
-
output_per_1k:
|
|
43
|
+
input_per_1k: pIn * 1_000 * CREDITS_PER_USD,
|
|
44
|
+
output_per_1k: pOut * 1_000 * CREDITS_PER_USD,
|
|
24
45
|
};
|
|
25
46
|
}
|
|
26
47
|
}
|
|
27
|
-
|
|
48
|
+
// Fallback for a model the blob does not carry. Priced in dollars first so
|
|
49
|
+
// it keeps its meaning if the rate ever moves again: $0.0025 and $0.0125 per
|
|
50
|
+
// 1k tokens, which is the same money the old 25/125 meant at the old rate.
|
|
51
|
+
return {
|
|
52
|
+
input_per_1k: 0.0025 * CREDITS_PER_USD,
|
|
53
|
+
output_per_1k: 0.0125 * CREDITS_PER_USD,
|
|
54
|
+
};
|
|
28
55
|
}
|
|
29
56
|
export function computeBurn(p) {
|
|
30
57
|
const platformPct = Math.max(p.config?.platform_margin_pct ?? 10, p.config?.platform_floor_pct ?? 5);
|
package/dist/billing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAEpC,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,eAAe,CAAA;AAEjD,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,eAAe,CAAC,CAAA;AAC1C,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC,CAAA;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACrB,OAAe,EACf,MAAwB;IAExB,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,a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AAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5D,MAAM,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAEzC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,YAAY,CAAC,GAAG,GAAG,CAAC,CAAA;IACpE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,CAAA;IAC/D,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAA;IACnE,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,GAAG,YAAY,GAAG,cAAc,GAAG,cAAc,CAAA;IAE1E,OAAO;QACL,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,CAAC,CAAC,QAAQ;QACxB,aAAa,EAAE,YAAY;QAC3B,eAAe,EAAE,cAAc;QAC/B,eAAe,EAAE,cAAc;QAC/B,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,IAAI;QAC9B,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI;KACvB,CAAA;AACH,CAAC"}
|
package/dist/blocks.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* blocks.ts — land generated copy on the fields the block that RENDERS reads.
|
|
3
|
+
*
|
|
4
|
+
* One implementation, so a second one can never drift into the exact bug it
|
|
5
|
+
* exists to fix. `channels/src/tools/block-props.ts` binds it to the generated
|
|
6
|
+
* `BLOCK_SCHEMA` and `emit_block` calls it on every block it emits.
|
|
7
|
+
*
|
|
8
|
+
* Both call sites run it. `emit_block.execute` normalises the OUTPUT frame;
|
|
9
|
+
* `BlockFrame` (one.ie/web) normalises again at the frame, which is what covers
|
|
10
|
+
* the STREAMING preview — `MessageList` draws that from the model's partial tool
|
|
11
|
+
* input, before `execute` has seen it, so without this a mis-named prop painted
|
|
12
|
+
* placeholder copy for the length of the stream and snapped to the real text
|
|
13
|
+
* only at the end. The browser binds to a generated slim schema
|
|
14
|
+
* (`one.ie/web/src/lib/puck/block-schema.generated.ts`, third artifact of
|
|
15
|
+
* `.claude/scripts/blocks-manifest.mjs`, drift-gated by its `--check`): measured
|
|
16
|
+
* 7,104 bytes brotli added to a chat island that already statically imports the
|
|
17
|
+
* whole 320 KB Puck registry, which is why it is a static import and not the
|
|
18
|
+
* lazy one first planned against the 202 KB full manifest.
|
|
19
|
+
*
|
|
20
|
+
* The defect, measured 2026-08-19 against a real prod turn on https://one.ie
|
|
21
|
+
* ("Show me a hero section for a moving company called Zebra Movers"). The
|
|
22
|
+
* model wrote good copy and called the tool cleanly:
|
|
23
|
+
*
|
|
24
|
+
* emit_block Hero { variant:'centered', headline:'Move with confidence.',
|
|
25
|
+
* subheadline:'Zebra Movers makes local and long-distance moves simple…',
|
|
26
|
+
* primaryCta:{label:'Get a free quote',href:'/quote'},
|
|
27
|
+
* secondaryCta:{…}, badge:'Licensed & insured' }
|
|
28
|
+
*
|
|
29
|
+
* and the browser rendered HeroCentered's DEFAULTS — 0 of 6 generated fields
|
|
30
|
+
* visible (measured through the real registry: `heading`/`subheading`/
|
|
31
|
+
* `primaryCtaLabel`, all untouched). Two silent losses stacked:
|
|
32
|
+
*
|
|
33
|
+
* 1. Puck family collapse UNIONS every member's fields into one
|
|
34
|
+
* registration, so `headline` is declared on the Hero family
|
|
35
|
+
* (HeroVideoDialog reads it) and survives the declared-key filter — but
|
|
36
|
+
* the member that renders variant 'centered' reads `heading`. Declared,
|
|
37
|
+
* kept, and invisible: nothing drops, nothing warns.
|
|
38
|
+
* 2. `subheadline` and `badge` are not declared anywhere on the family, so
|
|
39
|
+
* they are dropped outright. Same outcome, no signal.
|
|
40
|
+
*
|
|
41
|
+
* A model cannot guess this vocabulary — `Faq/default` takes `faqs[q|a]` while
|
|
42
|
+
* `Faq/simple` takes `items[question|answer]`, same family — so the fix is two
|
|
43
|
+
* halves and this file is the second: the tool PUBLISHES the per-variant field
|
|
44
|
+
* list so the first attempt is usually right, and `normalizeBlockProps` MAPS
|
|
45
|
+
* whatever still arrives under a synonym onto the member's real field. The
|
|
46
|
+
* mapping is not guesswork: a block declares its own `metadata.semantics`
|
|
47
|
+
* (role -> prop, 219 of 279 members do), and that declaration is consulted
|
|
48
|
+
* before any candidate list here.
|
|
49
|
+
*
|
|
50
|
+
* Refusal is still the answer where repair cannot reach — when NOTHING the
|
|
51
|
+
* model sent can land, `emit_block` rejects and names the legal fields.
|
|
52
|
+
*/
|
|
53
|
+
export interface BlockFieldSpec {
|
|
54
|
+
/** Puck field type — 'text' | 'textarea' | 'array' | 'select' | 'radio' | … */
|
|
55
|
+
type: string;
|
|
56
|
+
/** For `type: "array"` — the keys each ITEM object takes. */
|
|
57
|
+
of?: readonly string[];
|
|
58
|
+
/** For `type: "select" | "radio"` — the legal values. */
|
|
59
|
+
options?: readonly (string | number | boolean)[];
|
|
60
|
+
}
|
|
61
|
+
export interface BlockVariantSpec {
|
|
62
|
+
/** The fields the member that renders this variant actually reads. */
|
|
63
|
+
fields: Record<string, BlockFieldSpec>;
|
|
64
|
+
/** The block's own role -> prop declaration (heading/body/cta/image). */
|
|
65
|
+
semantics: Record<string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* Props the RENDER reads that the editor's `fields` cannot express, keyed by
|
|
68
|
+
* the array field they belong to. Puck has no nested string-array, so
|
|
69
|
+
* `PricingSection` renders `tiers[].features` and can never declare it —
|
|
70
|
+
* without this the key exists, renders, and no agent is ever told about it
|
|
71
|
+
* (measured by `.claude/scripts/blocks-render-probe.mjs`). Absent on almost
|
|
72
|
+
* every member; three carry it today.
|
|
73
|
+
*/
|
|
74
|
+
renders?: Record<string, readonly string[]>;
|
|
75
|
+
}
|
|
76
|
+
export interface BlockSchemaEntry {
|
|
77
|
+
/** The variant that renders when none is sent. null for a non-family block. */
|
|
78
|
+
canonicalVariant: string | null;
|
|
79
|
+
/** Keyed by variant value; the single key '' for a non-family block. */
|
|
80
|
+
variants: Record<string, BlockVariantSpec>;
|
|
81
|
+
}
|
|
82
|
+
export type BlockSchema = Record<string, BlockSchemaEntry>;
|
|
83
|
+
/** Chrome fields — background/pattern/effect. Never content, always passed
|
|
84
|
+
* through untouched: the model may set them, but they can't carry copy and
|
|
85
|
+
* they must not count as "the payload landed". Exported because a caller
|
|
86
|
+
* deciding whether the model even TRIED to write copy has to ask the same
|
|
87
|
+
* question — a chrome-only call is a legitimate "render the default with this
|
|
88
|
+
* background", not a payload that failed to land. */
|
|
89
|
+
export declare const CHROME_PROPS: ReadonlySet<string>;
|
|
90
|
+
export interface NormalizedBlock {
|
|
91
|
+
/** The variant whose member the props were resolved against — `''` for a
|
|
92
|
+
* block that is not a collapsed family. */
|
|
93
|
+
variant: string;
|
|
94
|
+
/** Props rewritten onto that member's field names, `variant` preserved. */
|
|
95
|
+
props: Record<string, unknown>;
|
|
96
|
+
/** Member fields that received model-supplied content. Empty means the block
|
|
97
|
+
* would render pure defaults — the invisible-payload case. */
|
|
98
|
+
landed: string[];
|
|
99
|
+
/** Keys that mapped to no declared field, in the model's own spelling. They
|
|
100
|
+
* are PASSED THROUGH, not removed — a block can render a prop it never
|
|
101
|
+
* declared as an editor field. Reported so the caller can tell the model
|
|
102
|
+
* which of its names the registry does not know. */
|
|
103
|
+
unmapped: string[];
|
|
104
|
+
/** Every field the rendering member declares, for the rejection message. */
|
|
105
|
+
fields: string[];
|
|
106
|
+
/** Per-field detail (`type`, array item keys) for the rejection message. */
|
|
107
|
+
spec: Record<string, BlockFieldSpec>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolve `props` against the member that `component` + `props.variant` really
|
|
111
|
+
* renders, and rewrite every key onto that member's vocabulary.
|
|
112
|
+
*
|
|
113
|
+
* A component with no schema entry passes through untouched — the table is
|
|
114
|
+
* generated from the live registry, and a name it doesn't know is one the
|
|
115
|
+
* renderer rejects downstream anyway.
|
|
116
|
+
*/
|
|
117
|
+
export declare function normalizeBlockProps(schema: BlockSchema, component: string, props?: Record<string, unknown>): NormalizedBlock;
|
|
118
|
+
/** The field list as the model should read it back — same shape as
|
|
119
|
+
* BLOCK_FIELD_DOC's lines, so the rejection speaks the description's language. */
|
|
120
|
+
export declare function describeFields(spec: Record<string, BlockFieldSpec>): string;
|
|
121
|
+
/** The variants of `component` that declare at least one field — what to point
|
|
122
|
+
* a model at when it picked one that can carry no copy (`Hero/default` and
|
|
123
|
+
* `Pricing/default` are static blocks; both are the family canonical, so they
|
|
124
|
+
* are exactly what a no-variant call renders). */
|
|
125
|
+
export declare function variantsWithFields(schema: BlockSchema, component: string): string[];
|
|
126
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACtB,yDAAyD;IACzD,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;CACjD;AAED,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACtC,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC;;;;;;;OAOG;IACH,OAAO,CAAC,E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