@weatherboard/cms 0.9.0 → 0.11.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 +63 -1
- package/dist/content-manifest/index.d.cts +7 -0
- package/dist/content-manifest/index.d.mts +7 -0
- package/dist/content-manifest/index.d.ts +7 -0
- package/dist/content-manifest/registry.d.cts +32 -0
- package/dist/content-manifest/registry.d.mts +32 -0
- package/dist/content-manifest/registry.d.ts +32 -0
- package/dist/content-manifest/types.d.cts +123 -0
- package/dist/content-manifest/types.d.mts +123 -0
- package/dist/content-manifest/types.d.ts +123 -0
- package/dist/content-manifest.cjs +2 -0
- package/dist/content-manifest.cjs.map +7 -0
- package/dist/content-manifest.d.cts +1 -0
- package/dist/content-manifest.d.mts +1 -0
- package/dist/content-manifest.d.ts +1 -0
- package/dist/content-manifest.mjs +2 -0
- package/dist/content-manifest.mjs.map +7 -0
- package/dist/contracts/facts.d.cts +163 -0
- package/dist/contracts/facts.d.mts +163 -0
- package/dist/contracts/facts.d.ts +163 -0
- package/dist/fact-guard.cjs +2 -0
- package/dist/fact-guard.cjs.map +7 -0
- package/dist/fact-guard.d.cts +19 -0
- package/dist/fact-guard.d.mts +19 -0
- package/dist/fact-guard.d.ts +19 -0
- package/dist/fact-guard.mjs +2 -0
- package/dist/fact-guard.mjs.map +7 -0
- package/dist/facts.cjs +2 -0
- package/dist/facts.cjs.map +7 -0
- package/dist/facts.d.cts +1 -0
- package/dist/facts.d.mts +1 -0
- package/dist/facts.d.ts +1 -0
- package/dist/facts.mjs +2 -0
- package/dist/facts.mjs.map +7 -0
- package/package.json +35 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './content-manifest/index.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './content-manifest/index.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './content-manifest/index.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var x=1,C=Object.freeze({"plain-text":!0,paragraph:!0,"keyed-text-list":!0,enum:!0,"portable-text":!1,"ordered-list":!1,image:!1,reference:!1}),V=Object.freeze({trimmed:!1,"single-line":!1,"no-em-dash":!1,"no-trailing-full-stop":!1,"sentence-case":!1,"no-money":!1,"no-season-prefix":!1}),u=Object.freeze({depth:16,list:128,string:4096,nodes:1e4,bytes:262144}),M=Object.freeze({season:"keyed-list-keys"});var p=class extends Error{constructor(n,s){super(n);this.code=n;this.path=s}code;path};function r(e,t){throw new p(e,t)}var R=e=>["__proto__","prototype","constructor"].includes(e.toLowerCase());function U(e){let t=0,n=(o,i,c)=>{if(++t>u.nodes&&r("NODE_LIMIT",i),c>u.depth&&r("DEPTH_LIMIT",i),typeof o=="string")return o.length>u.string&&r("STRING_LIMIT",i),(R(o)||[...o].some(f=>f.charCodeAt(0)<32||f.charCodeAt(0)===127))&&r("UNSAFE_CONTENT",i),o;if(o===null||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o))return o;typeof o!="object"&&r("UNSAFE_CONTENT",i);let d=Array.isArray(o);!d&&Object.getPrototypeOf(o)!==Object.prototype&&Object.getPrototypeOf(o)!==null&&r("UNSAFE_CONTENT",i);let _=Object.getOwnPropertyDescriptors(o);Reflect.ownKeys(o).some(f=>typeof f!="string")&&r("UNSAFE_CONTENT",i),d&&o.length>u.list&&r("LIST_LIMIT",i);let T=Object.create(null);for(let[f,b]of Object.entries(_))d&&f==="length"||((!b.enumerable||!("value"in b)||R(f))&&r("UNSAFE_CONTENT",i),f.length>u.string&&r("STRING_LIMIT",i),d&&(String(Number(f))!==f||!Number.isInteger(Number(f))||Number(f)<0)&&r("UNSAFE_CONTENT",i),T[f]=n(b.value,`${i}/${f}`,c+1));return d?(Object.keys(T).length!==o.length&&r("UNSAFE_CONTENT",i),Object.values(T)):T},s=n(e,"",0);return new TextEncoder().encode(JSON.stringify(s)).length>u.bytes&&r("BYTE_LIMIT",""),s}var m=(e,t)=>{typeof e!="string"&&r("INVALID_VALUE_TYPE",t)},I=(e,t)=>{m(e,t),e.trim()||r("INVALID_SHAPE",t)},A=(e,t)=>{typeof e!="boolean"&&r("INVALID_SHAPE",t)},h=(e,t)=>{(!Number.isSafeInteger(e)||e<0)&&r("INVALID_SHAPE",t)},N=(e,t="INVALID_SHAPE")=>(n,s)=>{e.includes(n)||r(t,s)},$=e=>(t,n)=>{I(t,n),e.test(t)||r("INVALID_BINDING",n)},y=e=>(t,n)=>{(typeof t!="string"||!e.test(t))&&r("INVALID_IDENTIFIER",n)},k=y(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/),g=y(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),D=y(/^[a-zA-Z][a-zA-Z0-9_]{0,63}$/),F=(e,t)=>{if((typeof e!="string"||!e.startsWith("/"))&&r("INVALID_IDENTIFIER",t),e==="/")return;let n=e.slice(1).split("/");n.at(-1)===""&&n.pop();for(let s of n)y(/^[a-zA-Z0-9_[\]-]{1,4096}$/)(s,t)},z=(e,t)=>{(typeof e!="string"||e.length!==10||e[4]!=="-"||e[7]!=="-")&&r("INVALID_IDENTIFIER",t),y(/^[0-9]{8}$/)(e.slice(0,4)+e.slice(5,7)+e.slice(8),t);let n=Number(e.slice(5,7)),s=Number(e.slice(8));(n<1||n>12||s<1||s>31)&&r("INVALID_IDENTIFIER",t)},O=(e,t)=>(n,s)=>{g(n,s),N(e,t)(n,s)},l=(e,t=0)=>(n,s)=>{(!Array.isArray(n)||n.length<t)&&r("INVALID_SHAPE",s),n.forEach((o,i)=>e(o,`${s}/${i}`))},E=(e,t)=>{new Set(e).size!==e.length&&r("DUPLICATE_KEY",t)},L=(e,t)=>{l(k,1)(e,t),E(e,t)},a=e=>(t,n)=>{(!t||typeof t!="object"||Array.isArray(t))&&r("INVALID_SHAPE",n);let s=t;for(let o of Object.keys(s))Object.hasOwn(e,o)||r("UNEXPECTED_PROPERTY",`${n}/${o}`);for(let[o,i]of Object.entries(e))i(s[o],`${n}/${o}`)},P=a({route:F,slot:g,component:g}),j=(e,t)=>{let n=e&&typeof e=="object"&&Object.hasOwn(e,"context");a({...n?{context:O(Object.keys(M),"UNKNOWN_CONTEXT")}:{fieldKey:g},equals:m,destinations:l(P,1)})(e,t)},K=e=>(t,n)=>{t!==void 0&&e(t,n)},G=(e,t)=>{a({min:h,max:h})(e,t);let{min:n,max:s}=e;(n>s||s>u.string)&&r("INVALID_LIMITS",t)},H=(e,t)=>{if(e?.kind==="singleton")a({kind:N(["singleton"]),id:k})(e,t);else{a({kind:N(["collection"]),eligibleIds:L,maxDocuments:h})(e,t);let s=e;(s.maxDocuments<1||s.maxDocuments>s.eligibleIds.length)&&r("INVALID_LIMITS",t)}},W=(e,t)=>{let n=e?.kind;O(Object.keys(C),"UNKNOWN_CONTROL")(n,`${t}/kind`);let s=n==="enum"?{options:L}:n==="keyed-text-list"?{keys:l(a({key:g,label:I,conditions:K(l(j))}),1)}:n==="reference"?{eligibleIds:L,documentType:D}:{};a({key:g,path:l(D,1),label:I,kind:I,required:A,classification:N(["visible","metadata","accessibility","control","unsupported"]),rules:l(O(Object.keys(V),"UNKNOWN_RULE")),limits:G,blank:N(["reset","empty","refuse"]),reset:N(["fallback","remove","refuse"]),...s,fallback:(i,c)=>{if(n==="keyed-text-list"){let d=e.keys;a(Object.fromEntries(d.map(_=>[_.key,m])))(i,c)}else["plain-text","paragraph","enum"].includes(n)?m(i,c):i!=null&&r("INVALID_VALUE_TYPE",c)},destinations:l(P,1),conditions:l(j)})(e,t);let o=e;E(o.rules,`${t}/rules`),o.kind==="keyed-text-list"&&E(o.keys.map(i=>i.key),`${t}/keys`),o.kind==="enum"&&!o.options.includes(o.fallback)&&r("INVALID_BINDING",`${t}/fallback`)},Z=(e,t)=>{a({key:g,label:I,documentType:D,selector:H,create:A,delete:A,fields:l(W,1)})(e,t);let n=e;E(n.fields.map(s=>s.key),`${t}/fields`),E(n.fields.map(s=>JSON.stringify(s.path)),`${t}/paths`);for(let s of n.fields){let o=[...s.conditions,...s.kind==="keyed-text-list"?s.keys.flatMap(i=>i.conditions??[]):[]];for(let i of o)"context"in i?(s.kind!=="keyed-text-list"||!s.keys.some(c=>c.key===i.equals))&&r("INVALID_CONTEXT_VALUE",`${t}/conditions`):n.fields.some(c=>c.key===i.fieldKey)||r("INVALID_BINDING",`${t}/conditions`)}},B=(e,t)=>{a({state:N(["complete","partial","unobserved"],"INVALID_COVERAGE"),excluded:l(I)})(e,t);let n=e;n.state==="complete"!=(n.excluded.length===0)&&r("INVALID_COVERAGE",t)},w=a({revision:k,sanity:a({projectId:y(/^[a-z0-9]{8}$/),dataset:y(/^[a-z0-9][a-z0-9_-]{0,63}$/),apiVersion:z,perspective:O(["published"],"INVALID_BINDING")}),controlVersion:N([1],"UNKNOWN_VERSION"),validatorVersion:N([1],"UNKNOWN_VERSION"),coverage:B,warnings:l(I),groups:l(Z)});function S(e){return Array.isArray(e)?`[${e.map(S).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${S(e[t])}`).join(",")}}`:JSON.stringify(e)}async function X(e){let t=U(e);w(t,"/content");let n=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(S(t)));return Array.from(new Uint8Array(n),s=>s.toString(16).padStart(2,"0")).join("")}async function J(e){try{let t=U(e);a({protocolVersion:N([1],"UNKNOWN_PROTOCOL"),digest:$(/^[a-f0-9]{64}$/),repository:a({owner:k,name:k}),build:a({commit:$(/^[a-f0-9]{40}$/),deploymentId:k,environment:N(["production","preview"])}),content:w})(t,"");let n=t;E(n.content.groups.map(i=>i.key),"/content/groups"),n.digest!==await X(n.content)&&r("DIGEST_MISMATCH","/digest");let s=[],o=n.content.groups.flatMap(i=>i.fields.map(c=>{let d=`/content/groups/${i.key}/fields/${c.key}`;return C[c.kind]||s.push({code:"UNSUPPORTED_CONTROL",path:d}),c.classification==="unsupported"&&s.push({code:"UNSUPPORTED_FIELD",path:d}),c.rules.length&&s.push({code:"UNIMPLEMENTED_RULE",path:d}),{groupKey:i.key,fieldKey:c.key,status:!C[c.kind]||c.classification==="unsupported"||c.rules.length?"unsupported":"supported"}}));return n.content.coverage.state!=="complete"&&s.push({code:"INCOMPLETE_COVERAGE",path:"/content/coverage"}),n.content.warnings.forEach((i,c)=>s.push({code:"PRODUCER_WARNING",path:`/content/warnings/${c}`})),{ok:!0,manifest:n,fields:o,diagnostics:s}}catch(t){return{ok:!1,diagnostics:[{code:t instanceof p?t.code:"UNSAFE_CONTENT",path:t instanceof p?t.path:""}]}}}export{M as CONTENT_CONTEXTS,C as CONTENT_CONTROLS,u as CONTENT_MANIFEST_LIMITS,x as CONTENT_MANIFEST_VERSION,V as CONTENT_RULES,X as contentManifestDigest,J as parseContentManifest};
|
|
2
|
+
//# sourceMappingURL=content-manifest.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/content-manifest/registry.ts", "../src/content-manifest/index.ts"],
|
|
4
|
+
"sourcesContent": ["/** Protocol vocabulary only; rule execution is introduced separately. */\nexport const CONTENT_MANIFEST_VERSION = 1;\nexport const CONTENT_CONTROLS = Object.freeze({\n 'plain-text': true, paragraph: true, 'keyed-text-list': true, enum: true,\n 'portable-text': false, 'ordered-list': false, image: false, reference: false,\n});\nexport const CONTENT_RULES = Object.freeze({\n 'trimmed': false, 'single-line': false, 'no-em-dash': false,\n 'no-trailing-full-stop': false, 'sentence-case': false, 'no-money': false,\n 'no-season-prefix': false,\n});\nexport const CONTENT_MANIFEST_LIMITS = Object.freeze({\n depth: 16, list: 128, string: 4096, nodes: 10000, bytes: 262144,\n});\n\n/** Site-supplied render state; allowed values come from the enclosing keyed list. */\nexport const CONTENT_CONTEXTS = Object.freeze({ season: 'keyed-list-keys' as const });\n", "import { CONTENT_CONTEXTS, CONTENT_CONTROLS, CONTENT_MANIFEST_LIMITS as caps, CONTENT_MANIFEST_VERSION, CONTENT_RULES } from './registry';\nimport type { ContentManifest, ContentManifestData, ContentManifestDiagnostic, ContentManifestDiagnosticCode, ParsedContentManifest } from './types';\nexport * from './registry';\nexport type * from './types';\n\ntype RecordValue = Record<string, unknown>;\nclass Refusal extends Error {\n constructor(readonly code: ContentManifestDiagnosticCode, readonly path: string) { super(code); }\n}\nfunction refuse(code: ContentManifestDiagnosticCode, path: string): never { throw new Refusal(code, path); }\nconst reserved = (value: string) => ['__proto__', 'prototype', 'constructor'].includes(value.toLowerCase());\n// Only JSON data properties are inspected; accessors are never invoked.\nfunction bounded(input: unknown): unknown {\n let nodes = 0;\n const visit = (value: unknown, path: string, depth: number): unknown => {\n if (++nodes > caps.nodes) refuse('NODE_LIMIT', path);\n if (depth > caps.depth) refuse('DEPTH_LIMIT', path);\n if (typeof value === 'string') {\n if (value.length > caps.string) refuse('STRING_LIMIT', path);\n if (reserved(value) || [...value].some(c => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)) refuse('UNSAFE_CONTENT', path);\n return value;\n }\n if (value === null || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value))) return value;\n if (typeof value !== 'object') refuse('UNSAFE_CONTENT', path);\n const array = Array.isArray(value);\n if (!array && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) refuse('UNSAFE_CONTENT', path);\n const descriptors = Object.getOwnPropertyDescriptors(value);\n if (Reflect.ownKeys(value).some(key => typeof key !== 'string')) refuse('UNSAFE_CONTENT', path);\n if (array && value.length > caps.list) refuse('LIST_LIMIT', path);\n const output: RecordValue = Object.create(null);\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (array && key === 'length') continue;\n if (!descriptor.enumerable || !('value' in descriptor) || reserved(key)) refuse('UNSAFE_CONTENT', path);\n if (key.length > caps.string) refuse('STRING_LIMIT', path);\n if (array && (String(Number(key)) !== key || !Number.isInteger(Number(key)) || Number(key) < 0)) refuse('UNSAFE_CONTENT', path);\n output[key] = visit(descriptor.value, `${path}/${key}`, depth + 1);\n }\n if (array) {\n if (Object.keys(output).length !== value.length) refuse('UNSAFE_CONTENT', path);\n return Object.values(output);\n }\n return output;\n };\n const result = visit(input, '', 0);\n if (new TextEncoder().encode(JSON.stringify(result)).length > caps.bytes) refuse('BYTE_LIMIT', '');\n return result;\n}\ntype Check = (value: unknown, path: string) => void;\nconst string: Check = (v, p) => { if (typeof v !== 'string') refuse('INVALID_VALUE_TYPE', p); };\nconst text: Check = (v, p) => { string(v, p); if (!(v as string).trim()) refuse('INVALID_SHAPE', p); };\nconst bool: Check = (v, p) => { if (typeof v !== 'boolean') refuse('INVALID_SHAPE', p); };\nconst number: Check = (v, p) => { if (!Number.isSafeInteger(v) || (v as number) < 0) refuse('INVALID_SHAPE', p); };\nconst literal = (values: readonly unknown[], code: ContentManifestDiagnosticCode = 'INVALID_SHAPE'): Check =>\n (v, p) => { if (!values.includes(v)) refuse(code, p); };\nconst pattern = (re: RegExp): Check => (v, p) => { text(v, p); if (!re.test(v as string)) refuse('INVALID_BINDING', p); };\nconst identifier = (re: RegExp): Check => (v, p) => {\n if (typeof v !== 'string' || !re.test(v)) refuse('INVALID_IDENTIFIER', p);\n};\nconst id = identifier(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/);\nconst key = identifier(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/);\nconst segment = identifier(/^[a-zA-Z][a-zA-Z0-9_]{0,63}$/);\n// Root or nonempty slash-separated segments; one trailing slash is allowed.\n// Split first so segment repetition cannot overlap with route repetition.\nconst route: Check = (v, p) => {\n if (typeof v !== 'string' || !v.startsWith('/')) refuse('INVALID_IDENTIFIER', p);\n if (v === '/') return;\n const segments = v.slice(1).split('/');\n if (segments.at(-1) === '') segments.pop();\n for (const part of segments) identifier(/^[a-zA-Z0-9_[\\]-]{1,4096}$/)(part, p);\n};\nconst apiVersion: Check = (v, p) => {\n if (typeof v !== 'string' || v.length !== 10 || v[4] !== '-' || v[7] !== '-') refuse('INVALID_IDENTIFIER', p);\n identifier(/^[0-9]{8}$/)(v.slice(0, 4) + v.slice(5, 7) + v.slice(8), p);\n const month = Number(v.slice(5, 7)); const day = Number(v.slice(8));\n if (month < 1 || month > 12 || day < 1 || day > 31) refuse('INVALID_IDENTIFIER', p);\n};\nconst vocabulary = (values: readonly string[], code: ContentManifestDiagnosticCode): Check => (v, p) => {\n key(v, p); literal(values, code)(v, p);\n};\nconst list = (check: Check, minimum = 0): Check => (v, p) => {\n if (!Array.isArray(v) || v.length < minimum) refuse('INVALID_SHAPE', p);\n v.forEach((item, i) => check(item, `${p}/${i}`));\n};\nconst unique = (values: unknown[], p: string) => {\n if (new Set(values).size !== values.length) refuse('DUPLICATE_KEY', p);\n};\nconst ids: Check = (v, p) => { list(id, 1)(v, p); unique(v as string[], p); };\nconst object = (shape: Record<string, Check>): Check => (v, p) => {\n if (!v || typeof v !== 'object' || Array.isArray(v)) refuse('INVALID_SHAPE', p);\n const record = v as RecordValue;\n for (const key of Object.keys(record)) if (!Object.hasOwn(shape, key)) refuse('UNEXPECTED_PROPERTY', `${p}/${key}`);\n for (const [key, check] of Object.entries(shape)) check(record[key], `${p}/${key}`);\n};\nconst destination = object({ route, slot: key, component: key });\nconst condition: Check = (v, p) => {\n const context = v && typeof v === 'object' && Object.hasOwn(v, 'context');\n object({ ...(context ? { context: vocabulary(Object.keys(CONTENT_CONTEXTS), 'UNKNOWN_CONTEXT') } : { fieldKey: key }),\n equals: string, destinations: list(destination, 1) })(v, p);\n};\nconst optional = (check: Check): Check => (v, p) => { if (v !== undefined) check(v, p); };\nconst limits: Check = (v, p) => {\n object({ min: number, max: number })(v, p);\n const { min, max } = v as { min: number; max: number };\n if (min > max || max > caps.string) refuse('INVALID_LIMITS', p);\n};\nconst selector: Check = (v, p) => {\n const kind = (v as RecordValue | null)?.kind;\n if (kind === 'singleton') object({ kind: literal(['singleton']), id })(v, p);\n else {\n object({ kind: literal(['collection']), eligibleIds: ids, maxDocuments: number })(v, p);\n const record = v as { eligibleIds: string[]; maxDocuments: number };\n if (record.maxDocuments < 1 || record.maxDocuments > record.eligibleIds.length) refuse('INVALID_LIMITS', p);\n }\n};\nconst field: Check = (v, p) => {\n const kind = (v as RecordValue | null)?.kind;\n vocabulary(Object.keys(CONTENT_CONTROLS), 'UNKNOWN_CONTROL')(kind, `${p}/kind`);\n const extra: Record<string, Check> = kind === 'enum' ? { options: ids } : kind === 'keyed-text-list' ?\n { keys: list(object({ key, label: text, conditions: optional(list(condition)) }), 1) } : kind === 'reference' ? { eligibleIds: ids, documentType: segment } : {};\n object({ key, path: list(segment, 1), label: text, kind: text, required: bool,\n classification: literal(['visible', 'metadata', 'accessibility', 'control', 'unsupported']),\n rules: list(vocabulary(Object.keys(CONTENT_RULES), 'UNKNOWN_RULE')), limits,\n blank: literal(['reset', 'empty', 'refuse']), reset: literal(['fallback', 'remove', 'refuse']),\n ...extra,\n fallback: (value, path) => {\n if (kind === 'keyed-text-list') {\n const keys = (v as { keys: { key: string }[] }).keys;\n object(Object.fromEntries(keys.map(k => [k.key, string])))(value, path);\n } else if (['plain-text', 'paragraph', 'enum'].includes(kind as string)) string(value, path);\n else if (value !== undefined && value !== null) refuse('INVALID_VALUE_TYPE', path);\n },\n destinations: list(destination, 1), conditions: list(condition),\n })(v, p);\n const f = v as ContentManifestData['groups'][number]['fields'][number];\n unique(f.rules, `${p}/rules`);\n if (f.kind === 'keyed-text-list') unique(f.keys.map(k => k.key), `${p}/keys`);\n if (f.kind === 'enum' && !f.options.includes(f.fallback)) refuse('INVALID_BINDING', `${p}/fallback`);\n};\nconst group: Check = (v, p) => {\n object({ key, label: text, documentType: segment, selector, create: bool, delete: bool, fields: list(field, 1) })(v, p);\n const g = v as ContentManifestData['groups'][number];\n unique(g.fields.map(f => f.key), `${p}/fields`);\n unique(g.fields.map(f => JSON.stringify(f.path)), `${p}/paths`);\n for (const f of g.fields) {\n const conditions = [...f.conditions, ...(f.kind === 'keyed-text-list' ? f.keys.flatMap(k => k.conditions ?? []) : [])];\n for (const c of conditions) {\n if ('context' in c) {\n if (f.kind !== 'keyed-text-list' || !f.keys.some(k => k.key === c.equals)) refuse('INVALID_CONTEXT_VALUE', `${p}/conditions`);\n } else if (!g.fields.some(other => other.key === c.fieldKey)) refuse('INVALID_BINDING', `${p}/conditions`);\n }\n }\n};\nconst coverage: Check = (v, p) => {\n object({ state: literal(['complete', 'partial', 'unobserved'], 'INVALID_COVERAGE'), excluded: list(text) })(v, p);\n const c = v as ContentManifestData['coverage'];\n if ((c.state === 'complete') !== (c.excluded.length === 0)) refuse('INVALID_COVERAGE', p);\n};\nconst data: Check = object({ revision: id,\n sanity: object({ projectId: identifier(/^[a-z0-9]{8}$/), dataset: identifier(/^[a-z0-9][a-z0-9_-]{0,63}$/),\n apiVersion, perspective: vocabulary(['published'], 'INVALID_BINDING') }),\n controlVersion: literal([1], 'UNKNOWN_VERSION'), validatorVersion: literal([1], 'UNKNOWN_VERSION'),\n coverage, warnings: list(text), groups: list(group),\n});\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value && typeof value === 'object') return `{${Object.keys(value).sort().map(k => `${JSON.stringify(k)}:${canonical((value as RecordValue)[k])}`).join(',')}}`;\n return JSON.stringify(value);\n}\n/** SHA-256 over content data only; object keys sorted, array order preserved. */\nexport async function contentManifestDigest(content: ContentManifestData): Promise<string> {\n const safe = bounded(content);\n data(safe, '/content');\n const bytes = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(canonical(safe)));\n return Array.from(new Uint8Array(bytes), b => b.toString(16).padStart(2, '0')).join('');\n}\n/** Structural acceptance is not permission to publish or proof of rendering. */\nexport async function parseContentManifest(input: unknown): Promise<ParsedContentManifest> {\n try {\n const safe = bounded(input);\n object({ protocolVersion: literal([CONTENT_MANIFEST_VERSION], 'UNKNOWN_PROTOCOL'),\n digest: pattern(/^[a-f0-9]{64}$/), repository: object({ owner: id, name: id }),\n build: object({ commit: pattern(/^[a-f0-9]{40}$/), deploymentId: id, environment: literal(['production', 'preview']) }),\n content: data,\n })(safe, '');\n const manifest = safe as ContentManifest;\n unique(manifest.content.groups.map(g => g.key), '/content/groups');\n if (manifest.digest !== await contentManifestDigest(manifest.content)) refuse('DIGEST_MISMATCH', '/digest');\n const diagnostics: ContentManifestDiagnostic[] = [];\n const fields: Extract<ParsedContentManifest, { ok: true }>['fields'] = manifest.content.groups.flatMap(g => g.fields.map(f => {\n const path = `/content/groups/${g.key}/fields/${f.key}`;\n if (!CONTENT_CONTROLS[f.kind]) diagnostics.push({ code: 'UNSUPPORTED_CONTROL', path });\n if (f.classification === 'unsupported') diagnostics.push({ code: 'UNSUPPORTED_FIELD', path });\n if (f.rules.length) diagnostics.push({ code: 'UNIMPLEMENTED_RULE', path });\n return { groupKey: g.key, fieldKey: f.key, status: (!CONTENT_CONTROLS[f.kind] || f.classification === 'unsupported' || f.rules.length ? 'unsupported' : 'supported') };\n }));\n if (manifest.content.coverage.state !== 'complete') diagnostics.push({ code: 'INCOMPLETE_COVERAGE', path: '/content/coverage' });\n manifest.content.warnings.forEach((_, i) => diagnostics.push({ code: 'PRODUCER_WARNING', path: `/content/warnings/${i}` }));\n return { ok: true, manifest, fields, diagnostics };\n } catch (error) {\n return { ok: false, diagnostics: [{ code: error instanceof Refusal ? error.code : 'UNSAFE_CONTENT', path: error instanceof Refusal ? error.path : '' }] };\n }\n}\n"],
|
|
5
|
+
"mappings": "AACO,IAAMA,EAA2B,EAC3BC,EAAmB,OAAO,OAAO,CAC5C,aAAc,GAAM,UAAW,GAAM,kBAAmB,GAAM,KAAM,GACpE,gBAAiB,GAAO,eAAgB,GAAO,MAAO,GAAO,UAAW,EAC1E,CAAC,EACYC,EAAgB,OAAO,OAAO,CACzC,QAAW,GAAO,cAAe,GAAO,aAAc,GACtD,wBAAyB,GAAO,gBAAiB,GAAO,WAAY,GACpE,mBAAoB,EACtB,CAAC,EACYC,EAA0B,OAAO,OAAO,CACnD,MAAO,GAAI,KAAM,IAAK,OAAQ,KAAM,MAAO,IAAO,MAAO,MAC3D,CA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CAAE,GAAI,GAAO,YAAa,CAAC,CAAE,KAAMA,aAAiBnF,EAAUmF,EAAM,KAAO,iBAAkB,KAAMA,aAAiBnF,EAAUmF,EAAM,KAAO,EAAG,CAAC,CAAE,CAC1J,CACF",
|
|
6
|
+
"names": ["CONTENT_MANIFEST_VERSION", "CONTENT_CONTROLS", "CONTENT_RULES", "CONTENT_MANIFEST_LIMITS", "CONTENT_CONTEXTS", "Refusal", "code", "path", "refuse", "reserved", "value", "bounded", "input", "nodes", "visit", "depth", "CONTENT_MANIFEST_LIMITS", "c", "array", "descriptors", "key", "output", "descriptor", "result", "string", "v", "p", "text", "bool", "number", "literal", "values", "pattern", "re", "identifier", "id", "segment", "route", "segments", "part", "apiVersion", "month", "day", "vocabulary", "list", "check", "minimum", "item", "unique", "ids", "object", "shape", "record", "destination", "condition", "context", "CONTENT_CONTEXTS", "optional", "limits", "min", "max", "selector", "field", "kind", "CONTENT_CONTROLS", "extra", "CONTENT_RULES", "keys", "k", "f", "group", "g", "conditions", "other", "coverage", "data", "canonical", "contentManifestDigest", "content", "safe", "bytes", "b", "parseContentManifest", "manifest", "diagnostics", "fields", "_", "i", "error"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** Public contracts only. Evidence and approval identities never enter the CMS document. */
|
|
2
|
+
export declare const FACT_TYPES: readonly ["integer", "decimal", "boolean", "date", "string", "enum", "reference"];
|
|
3
|
+
export declare const FACT_DISPLAY_RULES: readonly ["identity/v1", "floorHundredsPlus/v1"];
|
|
4
|
+
export type FactDisplayRule = typeof FACT_DISPLAY_RULES[number];
|
|
5
|
+
export declare const FACT_KEY: RegExp;
|
|
6
|
+
export declare const FACT_ALIASES: Readonly<Record<string, string>>;
|
|
7
|
+
export type FactValue = {
|
|
8
|
+
type: "integer";
|
|
9
|
+
value: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "decimal";
|
|
12
|
+
value: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
value: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
type: "date" | "string";
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "enum";
|
|
21
|
+
value: string;
|
|
22
|
+
allowedValues: readonly string[];
|
|
23
|
+
} | {
|
|
24
|
+
type: "reference";
|
|
25
|
+
value: {
|
|
26
|
+
documentId: string;
|
|
27
|
+
documentRevision: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type FactSource = {
|
|
31
|
+
kind: "computed" | "observed" | "attested";
|
|
32
|
+
definition: string;
|
|
33
|
+
version: string;
|
|
34
|
+
};
|
|
35
|
+
export type BusinessFact = {
|
|
36
|
+
key: string;
|
|
37
|
+
publicValue: FactValue;
|
|
38
|
+
unit: string | null;
|
|
39
|
+
timezone: string | null;
|
|
40
|
+
displayRule: FactDisplayRule;
|
|
41
|
+
source: FactSource;
|
|
42
|
+
accountableOwner: string;
|
|
43
|
+
freshness: "computed" | "operational" | "technical";
|
|
44
|
+
optional: boolean;
|
|
45
|
+
surfaces: readonly {
|
|
46
|
+
id: string;
|
|
47
|
+
semantics: "current" | "historical";
|
|
48
|
+
asOf: string | null;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
export declare const FACT_EXPIRY_MS: {
|
|
52
|
+
readonly computed: number;
|
|
53
|
+
readonly operational: number;
|
|
54
|
+
readonly technical: number;
|
|
55
|
+
};
|
|
56
|
+
export type FactEvidence = {
|
|
57
|
+
reference: string;
|
|
58
|
+
digest: string;
|
|
59
|
+
observedAt: string;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
complete: boolean;
|
|
62
|
+
runId: string;
|
|
63
|
+
};
|
|
64
|
+
export type FactRevision = {
|
|
65
|
+
projectId: string;
|
|
66
|
+
revision: number;
|
|
67
|
+
baseRevision: number | null;
|
|
68
|
+
fact: BusinessFact;
|
|
69
|
+
evidence: FactEvidence;
|
|
70
|
+
effectiveAt: string;
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
};
|
|
73
|
+
export type ApprovedFactRevision = FactRevision & {
|
|
74
|
+
hash: string;
|
|
75
|
+
approvedAt: string;
|
|
76
|
+
approval: {
|
|
77
|
+
kind: "signer";
|
|
78
|
+
signerId: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: "policy";
|
|
81
|
+
policyVersion: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type FactPublicationReceipt = {
|
|
85
|
+
intentId: string;
|
|
86
|
+
projectId: string;
|
|
87
|
+
revision: number;
|
|
88
|
+
hash: string;
|
|
89
|
+
destination: {
|
|
90
|
+
projectId: string;
|
|
91
|
+
dataset: string;
|
|
92
|
+
};
|
|
93
|
+
expectedDocumentRevision: string | null;
|
|
94
|
+
cms: {
|
|
95
|
+
transactionId: string;
|
|
96
|
+
documentRevision: string;
|
|
97
|
+
readBackHash: string;
|
|
98
|
+
at: string;
|
|
99
|
+
} | null;
|
|
100
|
+
invalidation: {
|
|
101
|
+
deliveryKey: string;
|
|
102
|
+
target: string;
|
|
103
|
+
type: "businessFact";
|
|
104
|
+
id: string;
|
|
105
|
+
at: string;
|
|
106
|
+
} | null;
|
|
107
|
+
render: {
|
|
108
|
+
url: string;
|
|
109
|
+
deploymentId: string;
|
|
110
|
+
revision: number;
|
|
111
|
+
hash: string;
|
|
112
|
+
at: string;
|
|
113
|
+
} | null;
|
|
114
|
+
};
|
|
115
|
+
export type PublicBusinessFact = Pick<BusinessFact, "key" | "publicValue" | "unit" | "timezone" | "displayRule"> & {
|
|
116
|
+
_type: "businessFact";
|
|
117
|
+
_id: string;
|
|
118
|
+
approvedRevision: number;
|
|
119
|
+
approvedHash: string;
|
|
120
|
+
effectiveAt: string;
|
|
121
|
+
expiresAt: string;
|
|
122
|
+
provenanceSummary: string;
|
|
123
|
+
};
|
|
124
|
+
/** A request supplies one snapshot to every surface. Missing and unavailable are distinct from an empty snapshot. */
|
|
125
|
+
export type FactSnapshot = Readonly<Record<string, PublicBusinessFact>>;
|
|
126
|
+
export type FactReadResult = {
|
|
127
|
+
status: "available";
|
|
128
|
+
snapshot: FactSnapshot;
|
|
129
|
+
} | {
|
|
130
|
+
status: "unavailable";
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
export type FactReader = () => Promise<FactReadResult>;
|
|
134
|
+
export type FactPlaceholderContext = "htmlText" | "htmlAttribute" | "json";
|
|
135
|
+
/** Stored Sanity projection: scalar unions use named slots, never private revision fields. */
|
|
136
|
+
export type StoredFactValue = {
|
|
137
|
+
type: FactValue["type"];
|
|
138
|
+
numberValue?: number;
|
|
139
|
+
textValue?: string;
|
|
140
|
+
booleanValue?: boolean;
|
|
141
|
+
allowedValues?: readonly string[];
|
|
142
|
+
documentId?: string;
|
|
143
|
+
documentRevision?: string;
|
|
144
|
+
};
|
|
145
|
+
export declare function parseStoredFactValue(input: unknown): FactValue;
|
|
146
|
+
export declare function storeFactValue(input: FactValue): StoredFactValue;
|
|
147
|
+
export type StoredBusinessFact = Omit<PublicBusinessFact, "publicValue"> & {
|
|
148
|
+
publicValue: StoredFactValue;
|
|
149
|
+
};
|
|
150
|
+
export declare function assertFactKey(key: string): void;
|
|
151
|
+
export declare function businessFactId(key: string): string;
|
|
152
|
+
export declare function parseFactValue(input: unknown): FactValue;
|
|
153
|
+
export declare function parseFactDisplayRule(input: unknown): FactDisplayRule;
|
|
154
|
+
export declare function formatFact(input: FactValue, rule: FactDisplayRule): string;
|
|
155
|
+
/** Escape each replacement, not the surrounding trusted template. JSON returns string content without quotes;
|
|
156
|
+
* callers serialize complete structured objects and keep numeric properties as exact values. Attributes must be quoted.
|
|
157
|
+
* Raw text/React children use the formatter directly; never HTML-unescape an expanded string.
|
|
158
|
+
*/
|
|
159
|
+
export declare function expandFactPlaceholders(template: string, values: Readonly<Record<string, string>>, context: FactPlaceholderContext): string;
|
|
160
|
+
/** Fixed JSON domain, sorted object keys, array order preserved, finite numbers only. */
|
|
161
|
+
export declare function canonicalFactJson(value: unknown): string;
|
|
162
|
+
/** SHA-256 of contract fields only; unknown fields and approval are ignored. Instants use UTC milliseconds. */
|
|
163
|
+
export declare function hashFactRevision(revision: FactRevision): Promise<string>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** Public contracts only. Evidence and approval identities never enter the CMS document. */
|
|
2
|
+
export declare const FACT_TYPES: readonly ["integer", "decimal", "boolean", "date", "string", "enum", "reference"];
|
|
3
|
+
export declare const FACT_DISPLAY_RULES: readonly ["identity/v1", "floorHundredsPlus/v1"];
|
|
4
|
+
export type FactDisplayRule = typeof FACT_DISPLAY_RULES[number];
|
|
5
|
+
export declare const FACT_KEY: RegExp;
|
|
6
|
+
export declare const FACT_ALIASES: Readonly<Record<string, string>>;
|
|
7
|
+
export type FactValue = {
|
|
8
|
+
type: "integer";
|
|
9
|
+
value: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "decimal";
|
|
12
|
+
value: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
value: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
type: "date" | "string";
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "enum";
|
|
21
|
+
value: string;
|
|
22
|
+
allowedValues: readonly string[];
|
|
23
|
+
} | {
|
|
24
|
+
type: "reference";
|
|
25
|
+
value: {
|
|
26
|
+
documentId: string;
|
|
27
|
+
documentRevision: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type FactSource = {
|
|
31
|
+
kind: "computed" | "observed" | "attested";
|
|
32
|
+
definition: string;
|
|
33
|
+
version: string;
|
|
34
|
+
};
|
|
35
|
+
export type BusinessFact = {
|
|
36
|
+
key: string;
|
|
37
|
+
publicValue: FactValue;
|
|
38
|
+
unit: string | null;
|
|
39
|
+
timezone: string | null;
|
|
40
|
+
displayRule: FactDisplayRule;
|
|
41
|
+
source: FactSource;
|
|
42
|
+
accountableOwner: string;
|
|
43
|
+
freshness: "computed" | "operational" | "technical";
|
|
44
|
+
optional: boolean;
|
|
45
|
+
surfaces: readonly {
|
|
46
|
+
id: string;
|
|
47
|
+
semantics: "current" | "historical";
|
|
48
|
+
asOf: string | null;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
export declare const FACT_EXPIRY_MS: {
|
|
52
|
+
readonly computed: number;
|
|
53
|
+
readonly operational: number;
|
|
54
|
+
readonly technical: number;
|
|
55
|
+
};
|
|
56
|
+
export type FactEvidence = {
|
|
57
|
+
reference: string;
|
|
58
|
+
digest: string;
|
|
59
|
+
observedAt: string;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
complete: boolean;
|
|
62
|
+
runId: string;
|
|
63
|
+
};
|
|
64
|
+
export type FactRevision = {
|
|
65
|
+
projectId: string;
|
|
66
|
+
revision: number;
|
|
67
|
+
baseRevision: number | null;
|
|
68
|
+
fact: BusinessFact;
|
|
69
|
+
evidence: FactEvidence;
|
|
70
|
+
effectiveAt: string;
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
};
|
|
73
|
+
export type ApprovedFactRevision = FactRevision & {
|
|
74
|
+
hash: string;
|
|
75
|
+
approvedAt: string;
|
|
76
|
+
approval: {
|
|
77
|
+
kind: "signer";
|
|
78
|
+
signerId: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: "policy";
|
|
81
|
+
policyVersion: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type FactPublicationReceipt = {
|
|
85
|
+
intentId: string;
|
|
86
|
+
projectId: string;
|
|
87
|
+
revision: number;
|
|
88
|
+
hash: string;
|
|
89
|
+
destination: {
|
|
90
|
+
projectId: string;
|
|
91
|
+
dataset: string;
|
|
92
|
+
};
|
|
93
|
+
expectedDocumentRevision: string | null;
|
|
94
|
+
cms: {
|
|
95
|
+
transactionId: string;
|
|
96
|
+
documentRevision: string;
|
|
97
|
+
readBackHash: string;
|
|
98
|
+
at: string;
|
|
99
|
+
} | null;
|
|
100
|
+
invalidation: {
|
|
101
|
+
deliveryKey: string;
|
|
102
|
+
target: string;
|
|
103
|
+
type: "businessFact";
|
|
104
|
+
id: string;
|
|
105
|
+
at: string;
|
|
106
|
+
} | null;
|
|
107
|
+
render: {
|
|
108
|
+
url: string;
|
|
109
|
+
deploymentId: string;
|
|
110
|
+
revision: number;
|
|
111
|
+
hash: string;
|
|
112
|
+
at: string;
|
|
113
|
+
} | null;
|
|
114
|
+
};
|
|
115
|
+
export type PublicBusinessFact = Pick<BusinessFact, "key" | "publicValue" | "unit" | "timezone" | "displayRule"> & {
|
|
116
|
+
_type: "businessFact";
|
|
117
|
+
_id: string;
|
|
118
|
+
approvedRevision: number;
|
|
119
|
+
approvedHash: string;
|
|
120
|
+
effectiveAt: string;
|
|
121
|
+
expiresAt: string;
|
|
122
|
+
provenanceSummary: string;
|
|
123
|
+
};
|
|
124
|
+
/** A request supplies one snapshot to every surface. Missing and unavailable are distinct from an empty snapshot. */
|
|
125
|
+
export type FactSnapshot = Readonly<Record<string, PublicBusinessFact>>;
|
|
126
|
+
export type FactReadResult = {
|
|
127
|
+
status: "available";
|
|
128
|
+
snapshot: FactSnapshot;
|
|
129
|
+
} | {
|
|
130
|
+
status: "unavailable";
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
export type FactReader = () => Promise<FactReadResult>;
|
|
134
|
+
export type FactPlaceholderContext = "htmlText" | "htmlAttribute" | "json";
|
|
135
|
+
/** Stored Sanity projection: scalar unions use named slots, never private revision fields. */
|
|
136
|
+
export type StoredFactValue = {
|
|
137
|
+
type: FactValue["type"];
|
|
138
|
+
numberValue?: number;
|
|
139
|
+
textValue?: string;
|
|
140
|
+
booleanValue?: boolean;
|
|
141
|
+
allowedValues?: readonly string[];
|
|
142
|
+
documentId?: string;
|
|
143
|
+
documentRevision?: string;
|
|
144
|
+
};
|
|
145
|
+
export declare function parseStoredFactValue(input: unknown): FactValue;
|
|
146
|
+
export declare function storeFactValue(input: FactValue): StoredFactValue;
|
|
147
|
+
export type StoredBusinessFact = Omit<PublicBusinessFact, "publicValue"> & {
|
|
148
|
+
publicValue: StoredFactValue;
|
|
149
|
+
};
|
|
150
|
+
export declare function assertFactKey(key: string): void;
|
|
151
|
+
export declare function businessFactId(key: string): string;
|
|
152
|
+
export declare function parseFactValue(input: unknown): FactValue;
|
|
153
|
+
export declare function parseFactDisplayRule(input: unknown): FactDisplayRule;
|
|
154
|
+
export declare function formatFact(input: FactValue, rule: FactDisplayRule): string;
|
|
155
|
+
/** Escape each replacement, not the surrounding trusted template. JSON returns string content without quotes;
|
|
156
|
+
* callers serialize complete structured objects and keep numeric properties as exact values. Attributes must be quoted.
|
|
157
|
+
* Raw text/React children use the formatter directly; never HTML-unescape an expanded string.
|
|
158
|
+
*/
|
|
159
|
+
export declare function expandFactPlaceholders(template: string, values: Readonly<Record<string, string>>, context: FactPlaceholderContext): string;
|
|
160
|
+
/** Fixed JSON domain, sorted object keys, array order preserved, finite numbers only. */
|
|
161
|
+
export declare function canonicalFactJson(value: unknown): string;
|
|
162
|
+
/** SHA-256 of contract fields only; unknown fields and approval are ignored. Instants use UTC milliseconds. */
|
|
163
|
+
export declare function hashFactRevision(revision: FactRevision): Promise<string>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** Public contracts only. Evidence and approval identities never enter the CMS document. */
|
|
2
|
+
export declare const FACT_TYPES: readonly ["integer", "decimal", "boolean", "date", "string", "enum", "reference"];
|
|
3
|
+
export declare const FACT_DISPLAY_RULES: readonly ["identity/v1", "floorHundredsPlus/v1"];
|
|
4
|
+
export type FactDisplayRule = typeof FACT_DISPLAY_RULES[number];
|
|
5
|
+
export declare const FACT_KEY: RegExp;
|
|
6
|
+
export declare const FACT_ALIASES: Readonly<Record<string, string>>;
|
|
7
|
+
export type FactValue = {
|
|
8
|
+
type: "integer";
|
|
9
|
+
value: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "decimal";
|
|
12
|
+
value: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
value: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
type: "date" | "string";
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "enum";
|
|
21
|
+
value: string;
|
|
22
|
+
allowedValues: readonly string[];
|
|
23
|
+
} | {
|
|
24
|
+
type: "reference";
|
|
25
|
+
value: {
|
|
26
|
+
documentId: string;
|
|
27
|
+
documentRevision: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type FactSource = {
|
|
31
|
+
kind: "computed" | "observed" | "attested";
|
|
32
|
+
definition: string;
|
|
33
|
+
version: string;
|
|
34
|
+
};
|
|
35
|
+
export type BusinessFact = {
|
|
36
|
+
key: string;
|
|
37
|
+
publicValue: FactValue;
|
|
38
|
+
unit: string | null;
|
|
39
|
+
timezone: string | null;
|
|
40
|
+
displayRule: FactDisplayRule;
|
|
41
|
+
source: FactSource;
|
|
42
|
+
accountableOwner: string;
|
|
43
|
+
freshness: "computed" | "operational" | "technical";
|
|
44
|
+
optional: boolean;
|
|
45
|
+
surfaces: readonly {
|
|
46
|
+
id: string;
|
|
47
|
+
semantics: "current" | "historical";
|
|
48
|
+
asOf: string | null;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
export declare const FACT_EXPIRY_MS: {
|
|
52
|
+
readonly computed: number;
|
|
53
|
+
readonly operational: number;
|
|
54
|
+
readonly technical: number;
|
|
55
|
+
};
|
|
56
|
+
export type FactEvidence = {
|
|
57
|
+
reference: string;
|
|
58
|
+
digest: string;
|
|
59
|
+
observedAt: string;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
complete: boolean;
|
|
62
|
+
runId: string;
|
|
63
|
+
};
|
|
64
|
+
export type FactRevision = {
|
|
65
|
+
projectId: string;
|
|
66
|
+
revision: number;
|
|
67
|
+
baseRevision: number | null;
|
|
68
|
+
fact: BusinessFact;
|
|
69
|
+
evidence: FactEvidence;
|
|
70
|
+
effectiveAt: string;
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
};
|
|
73
|
+
export type ApprovedFactRevision = FactRevision & {
|
|
74
|
+
hash: string;
|
|
75
|
+
approvedAt: string;
|
|
76
|
+
approval: {
|
|
77
|
+
kind: "signer";
|
|
78
|
+
signerId: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: "policy";
|
|
81
|
+
policyVersion: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type FactPublicationReceipt = {
|
|
85
|
+
intentId: string;
|
|
86
|
+
projectId: string;
|
|
87
|
+
revision: number;
|
|
88
|
+
hash: string;
|
|
89
|
+
destination: {
|
|
90
|
+
projectId: string;
|
|
91
|
+
dataset: string;
|
|
92
|
+
};
|
|
93
|
+
expectedDocumentRevision: string | null;
|
|
94
|
+
cms: {
|
|
95
|
+
transactionId: string;
|
|
96
|
+
documentRevision: string;
|
|
97
|
+
readBackHash: string;
|
|
98
|
+
at: string;
|
|
99
|
+
} | null;
|
|
100
|
+
invalidation: {
|
|
101
|
+
deliveryKey: string;
|
|
102
|
+
target: string;
|
|
103
|
+
type: "businessFact";
|
|
104
|
+
id: string;
|
|
105
|
+
at: string;
|
|
106
|
+
} | null;
|
|
107
|
+
render: {
|
|
108
|
+
url: string;
|
|
109
|
+
deploymentId: string;
|
|
110
|
+
revision: number;
|
|
111
|
+
hash: string;
|
|
112
|
+
at: string;
|
|
113
|
+
} | null;
|
|
114
|
+
};
|
|
115
|
+
export type PublicBusinessFact = Pick<BusinessFact, "key" | "publicValue" | "unit" | "timezone" | "displayRule"> & {
|
|
116
|
+
_type: "businessFact";
|
|
117
|
+
_id: string;
|
|
118
|
+
approvedRevision: number;
|
|
119
|
+
approvedHash: string;
|
|
120
|
+
effectiveAt: string;
|
|
121
|
+
expiresAt: string;
|
|
122
|
+
provenanceSummary: string;
|
|
123
|
+
};
|
|
124
|
+
/** A request supplies one snapshot to every surface. Missing and unavailable are distinct from an empty snapshot. */
|
|
125
|
+
export type FactSnapshot = Readonly<Record<string, PublicBusinessFact>>;
|
|
126
|
+
export type FactReadResult = {
|
|
127
|
+
status: "available";
|
|
128
|
+
snapshot: FactSnapshot;
|
|
129
|
+
} | {
|
|
130
|
+
status: "unavailable";
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
export type FactReader = () => Promise<FactReadResult>;
|
|
134
|
+
export type FactPlaceholderContext = "htmlText" | "htmlAttribute" | "json";
|
|
135
|
+
/** Stored Sanity projection: scalar unions use named slots, never private revision fields. */
|
|
136
|
+
export type StoredFactValue = {
|
|
137
|
+
type: FactValue["type"];
|
|
138
|
+
numberValue?: number;
|
|
139
|
+
textValue?: string;
|
|
140
|
+
booleanValue?: boolean;
|
|
141
|
+
allowedValues?: readonly string[];
|
|
142
|
+
documentId?: string;
|
|
143
|
+
documentRevision?: string;
|
|
144
|
+
};
|
|
145
|
+
export declare function parseStoredFactValue(input: unknown): FactValue;
|
|
146
|
+
export declare function storeFactValue(input: FactValue): StoredFactValue;
|
|
147
|
+
export type StoredBusinessFact = Omit<PublicBusinessFact, "publicValue"> & {
|
|
148
|
+
publicValue: StoredFactValue;
|
|
149
|
+
};
|
|
150
|
+
export declare function assertFactKey(key: string): void;
|
|
151
|
+
export declare function businessFactId(key: string): string;
|
|
152
|
+
export declare function parseFactValue(input: unknown): FactValue;
|
|
153
|
+
export declare function parseFactDisplayRule(input: unknown): FactDisplayRule;
|
|
154
|
+
export declare function formatFact(input: FactValue, rule: FactDisplayRule): string;
|
|
155
|
+
/** Escape each replacement, not the surrounding trusted template. JSON returns string content without quotes;
|
|
156
|
+
* callers serialize complete structured objects and keep numeric properties as exact values. Attributes must be quoted.
|
|
157
|
+
* Raw text/React children use the formatter directly; never HTML-unescape an expanded string.
|
|
158
|
+
*/
|
|
159
|
+
export declare function expandFactPlaceholders(template: string, values: Readonly<Record<string, string>>, context: FactPlaceholderContext): string;
|
|
160
|
+
/** Fixed JSON domain, sorted object keys, array order preserved, finite numbers only. */
|
|
161
|
+
export declare function canonicalFactJson(value: unknown): string;
|
|
162
|
+
/** SHA-256 of contract fields only; unknown fields and approval are ignored. Instants use UTC milliseconds. */
|
|
163
|
+
export declare function hashFactRevision(revision: FactRevision): Promise<string>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var o=(s,t)=>{for(var e in t)n(s,e,{get:t[e],enumerable:!0})},g=(s,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!l.call(s,r)&&r!==e&&n(s,r,{get:()=>t[r],enumerable:!(a=i(t,r))||a.enumerable});return s};var d=s=>g(n({},"__esModule",{value:!0}),s);var f={};o(f,{FACT_SURFACE_MANIFEST_VERSION:()=>y});module.exports=d(f);var y=1;0&&(module.exports={FACT_SURFACE_MANIFEST_VERSION});
|
|
2
|
+
//# sourceMappingURL=fact-guard.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/fact-guard.ts"],
|
|
4
|
+
"sourcesContent": ["/** Registration seam for the later manifest guard; historical exclusions require evidence. */\nexport const FACT_SURFACE_MANIFEST_VERSION = 1 as const;\nexport type FactSurfaceManifest = {\n facts: readonly { key: string; literals: readonly string[] }[];\n surfaces: readonly { id: string; path: string; semantics: \"current\" | \"historical\" }[];\n exclusions: readonly { path: string; literal: string; asOf: string; evidence: string }[];\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACO,IAAME,EAAgC",
|
|
6
|
+
"names": ["fact_guard_exports", "__export", "FACT_SURFACE_MANIFEST_VERSION", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Registration seam for the later manifest guard; historical exclusions require evidence. */
|
|
2
|
+
export declare const FACT_SURFACE_MANIFEST_VERSION: 1;
|
|
3
|
+
export type FactSurfaceManifest = {
|
|
4
|
+
facts: readonly {
|
|
5
|
+
key: string;
|
|
6
|
+
literals: readonly string[];
|
|
7
|
+
}[];
|
|
8
|
+
surfaces: readonly {
|
|
9
|
+
id: string;
|
|
10
|
+
path: string;
|
|
11
|
+
semantics: "current" | "historical";
|
|
12
|
+
}[];
|
|
13
|
+
exclusions: readonly {
|
|
14
|
+
path: string;
|
|
15
|
+
literal: string;
|
|
16
|
+
asOf: string;
|
|
17
|
+
evidence: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Registration seam for the later manifest guard; historical exclusions require evidence. */
|
|
2
|
+
export declare const FACT_SURFACE_MANIFEST_VERSION: 1;
|
|
3
|
+
export type FactSurfaceManifest = {
|
|
4
|
+
facts: readonly {
|
|
5
|
+
key: string;
|
|
6
|
+
literals: readonly string[];
|
|
7
|
+
}[];
|
|
8
|
+
surfaces: readonly {
|
|
9
|
+
id: string;
|
|
10
|
+
path: string;
|
|
11
|
+
semantics: "current" | "historical";
|
|
12
|
+
}[];
|
|
13
|
+
exclusions: readonly {
|
|
14
|
+
path: string;
|
|
15
|
+
literal: string;
|
|
16
|
+
asOf: string;
|
|
17
|
+
evidence: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Registration seam for the later manifest guard; historical exclusions require evidence. */
|
|
2
|
+
export declare const FACT_SURFACE_MANIFEST_VERSION: 1;
|
|
3
|
+
export type FactSurfaceManifest = {
|
|
4
|
+
facts: readonly {
|
|
5
|
+
key: string;
|
|
6
|
+
literals: readonly string[];
|
|
7
|
+
}[];
|
|
8
|
+
surfaces: readonly {
|
|
9
|
+
id: string;
|
|
10
|
+
path: string;
|
|
11
|
+
semantics: "current" | "historical";
|
|
12
|
+
}[];
|
|
13
|
+
exclusions: readonly {
|
|
14
|
+
path: string;
|
|
15
|
+
literal: string;
|
|
16
|
+
asOf: string;
|
|
17
|
+
evidence: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|