@noy-db/hub 0.1.0-pre.3 → 0.1.0-pre.5
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/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +3 -3
- package/dist/blobs/index.d.ts +3 -3
- package/dist/blobs/index.js +2 -2
- package/dist/bundle/index.cjs +26 -3
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +3 -3
- package/dist/bundle/index.d.ts +3 -3
- package/dist/bundle/index.js +3 -1
- package/dist/{chunk-M2F2JAWB.js → chunk-6NPQTBZN.js} +103 -8
- package/dist/chunk-6NPQTBZN.js.map +1 -0
- package/dist/{chunk-UQFSPSWG.js → chunk-E4OOAPBZ.js} +2 -2
- package/dist/chunk-EMIGCR7X.js +39 -0
- package/dist/chunk-EMIGCR7X.js.map +1 -0
- package/dist/{chunk-EXQRC2L4.js → chunk-H3DV46AQ.js} +2 -2
- package/dist/{chunk-XHFOENR2.js → chunk-LMKOSLJY.js} +2 -2
- package/dist/{chunk-GJILMRPO.js → chunk-LRN3PNI6.js} +42 -4
- package/dist/chunk-LRN3PNI6.js.map +1 -0
- package/dist/{chunk-4OWFYIDQ.js → chunk-MIRZMUSQ.js} +3 -3
- package/dist/{chunk-ZRG4V3F5.js → chunk-NXUVITPB.js} +1 -1
- package/dist/chunk-NXUVITPB.js.map +1 -0
- package/dist/{chunk-5AATM2M2.js → chunk-QUDXYI4W.js} +2 -2
- package/dist/{chunk-ZLMV3TUA.js → chunk-QV4WLLKB.js} +3 -3
- package/dist/{chunk-E445ICYI.js → chunk-UFL4DUEV.js} +5 -3
- package/dist/chunk-UFL4DUEV.js.map +1 -0
- package/dist/chunk-UQQ2XFXI.js +155 -0
- package/dist/chunk-UQQ2XFXI.js.map +1 -0
- package/dist/consent/index.d.cts +3 -3
- package/dist/consent/index.d.ts +3 -3
- package/dist/{dev-unlock-KrKkcqD3.d.ts → dev-unlock-BgFqShBi.d.ts} +1 -1
- package/dist/{dev-unlock-CeXic1xC.d.cts → dev-unlock-qVMxG2Je.d.cts} +1 -1
- package/dist/{hash-ChfJjRjQ.d.ts → hash-BhoL7iUE.d.ts} +1 -1
- package/dist/{hash-9KO1BGxh.d.cts → hash-Bpvl2eSe.d.cts} +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +4 -4
- package/dist/history/index.d.ts +4 -4
- package/dist/history/index.js +2 -2
- package/dist/i18n/index.cjs +3 -1
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/index.js +3 -3
- package/dist/{index-DN-J-5wT.d.cts → index-6xNpPsxR.d.cts} +1 -1
- package/dist/{index-BRHBCmLt.d.ts → index-DJTf9yxn.d.ts} +1 -1
- package/dist/{index-DhjMjz7L.d.cts → index-DhK_zqOO.d.ts} +39 -5
- package/dist/{index-C8kQtmOk.d.ts → index-DyRt_5vM.d.cts} +39 -5
- package/dist/index.cjs +1501 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +261 -19
- package/dist/index.d.ts +261 -19
- package/dist/index.js +1118 -44
- package/dist/index.js.map +1 -1
- package/dist/{ledger-2NX4L7PN.js → ledger-GA4DMJS6.js} +3 -3
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +3 -3
- package/dist/periods/index.d.ts +3 -3
- package/dist/periods/index.js +3 -3
- package/dist/public-envelope-R4EIEQE6.js +31 -0
- package/dist/public-envelope-R4EIEQE6.js.map +1 -0
- package/dist/query/index.d.cts +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/session/index.cjs +4 -2
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +4 -4
- package/dist/session/index.d.ts +4 -4
- package/dist/session/index.js +1 -1
- package/dist/shadow/index.d.cts +3 -3
- package/dist/shadow/index.d.ts +3 -3
- package/dist/store/index.d.cts +3 -3
- package/dist/store/index.d.ts +3 -3
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +2 -2
- package/dist/sync/index.d.ts +2 -2
- package/dist/sync/index.js +2 -2
- package/dist/team/index.cjs +3 -1
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +3 -3
- package/dist/team/index.d.ts +3 -3
- package/dist/team/index.js +4 -4
- package/dist/tx/index.d.cts +3 -3
- package/dist/tx/index.d.ts +3 -3
- package/dist/{types-Bfs0qr5F.d.cts → types-BpyE4o_n.d.cts} +935 -4
- package/dist/{types-BZpCZB8N.d.ts → types-Df72wWCC.d.ts} +935 -4
- package/package.json +1 -1
- package/dist/chunk-E445ICYI.js.map +0 -1
- package/dist/chunk-GJILMRPO.js.map +0 -1
- package/dist/chunk-M2F2JAWB.js.map +0 -1
- package/dist/chunk-ZRG4V3F5.js.map +0 -1
- /package/dist/{chunk-UQFSPSWG.js.map → chunk-E4OOAPBZ.js.map} +0 -0
- /package/dist/{chunk-EXQRC2L4.js.map → chunk-H3DV46AQ.js.map} +0 -0
- /package/dist/{chunk-XHFOENR2.js.map → chunk-LMKOSLJY.js.map} +0 -0
- /package/dist/{chunk-4OWFYIDQ.js.map → chunk-MIRZMUSQ.js.map} +0 -0
- /package/dist/{chunk-5AATM2M2.js.map → chunk-QUDXYI4W.js.map} +0 -0
- /package/dist/{chunk-ZLMV3TUA.js.map → chunk-QV4WLLKB.js.map} +0 -0
- /package/dist/{ledger-2NX4L7PN.js.map → ledger-GA4DMJS6.js.map} +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NOYDB_FORMAT_VERSION
|
|
3
|
+
} from "./chunk-NXUVITPB.js";
|
|
4
|
+
import {
|
|
5
|
+
ValidationError
|
|
6
|
+
} from "./chunk-ACLDOTNQ.js";
|
|
7
|
+
|
|
8
|
+
// src/meta/public-envelope/schema.ts
|
|
9
|
+
var DATA_URL_PREFIX = /^data:([a-zA-Z0-9.+-]+\/[a-zA-Z0-9.+-]+);base64,/;
|
|
10
|
+
function validatePublicEnvelopeInput(input, schema) {
|
|
11
|
+
const allowed = new Set(schema.fields);
|
|
12
|
+
for (const key of Object.keys(input)) {
|
|
13
|
+
const known = key === "name" || key === "description" || key === "icon" || key === "defaultLocale" ? key : void 0;
|
|
14
|
+
if (!known) {
|
|
15
|
+
throw new ValidationError(
|
|
16
|
+
`setPublicEnvelope: unknown field "${key}". Allowed fields: ${[...allowed].join(", ")}.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (!allowed.has(known)) {
|
|
20
|
+
throw new ValidationError(
|
|
21
|
+
`setPublicEnvelope: field "${known}" is not enabled in this vault's schema. Allowed fields: ${[...allowed].join(", ")}.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (input.name !== void 0) {
|
|
26
|
+
validateText(input.name, "name", schema.maxStringChars);
|
|
27
|
+
}
|
|
28
|
+
if (input.description !== void 0) {
|
|
29
|
+
validateText(input.description, "description", schema.maxStringChars);
|
|
30
|
+
}
|
|
31
|
+
if (input.icon !== void 0) {
|
|
32
|
+
validateIcon(input.icon, schema);
|
|
33
|
+
}
|
|
34
|
+
if (input.defaultLocale !== void 0 && typeof input.defaultLocale !== "string") {
|
|
35
|
+
throw new ValidationError(
|
|
36
|
+
`setPublicEnvelope: defaultLocale must be a string (BCP-47), got ${typeof input.defaultLocale}.`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function validateText(value, field, maxChars) {
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
if (value.length > maxChars) {
|
|
43
|
+
throw new ValidationError(
|
|
44
|
+
`setPublicEnvelope: ${field} exceeds the ${maxChars}-character cap (got ${value.length}).`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
50
|
+
throw new ValidationError(
|
|
51
|
+
`setPublicEnvelope: ${field} must be a string or { [locale]: string } map, got ${typeof value}.`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
for (const [locale, str] of Object.entries(value)) {
|
|
55
|
+
if (typeof str !== "string") {
|
|
56
|
+
throw new ValidationError(
|
|
57
|
+
`setPublicEnvelope: ${field}[${locale}] must be a string, got ${typeof str}.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (str.length > maxChars) {
|
|
61
|
+
throw new ValidationError(
|
|
62
|
+
`setPublicEnvelope: ${field}[${locale}] exceeds the ${maxChars}-character cap (got ${str.length}).`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function validateIcon(icon, schema) {
|
|
68
|
+
if (typeof icon !== "string") {
|
|
69
|
+
throw new ValidationError(
|
|
70
|
+
`setPublicEnvelope: icon must be a data: URL string, got ${typeof icon}.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (icon.length > schema.maxIconBytes) {
|
|
74
|
+
throw new ValidationError(
|
|
75
|
+
`setPublicEnvelope: icon exceeds the ${schema.maxIconBytes}-byte cap (got ${icon.length}).`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
const m = DATA_URL_PREFIX.exec(icon);
|
|
79
|
+
if (!m) {
|
|
80
|
+
throw new ValidationError(
|
|
81
|
+
"setPublicEnvelope: icon must be a base64 data URL (`data:image/png;base64,\u2026` or `data:image/svg+xml;base64,\u2026`). External URLs are not supported in v1."
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const mime = m[1];
|
|
85
|
+
if (!schema.iconMimeTypes.includes(mime)) {
|
|
86
|
+
throw new ValidationError(
|
|
87
|
+
`setPublicEnvelope: icon MIME type "${mime}" is not allowed. Permitted types: ${schema.iconMimeTypes.join(", ")}.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function isPublicEnvelope(x) {
|
|
92
|
+
if (x === null || typeof x !== "object" || Array.isArray(x)) return false;
|
|
93
|
+
const obj = x;
|
|
94
|
+
return obj["_noydb_public"] === 1 && typeof obj["version"] === "number";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/meta/public-envelope/storage.ts
|
|
98
|
+
var PUBLIC_ENVELOPE_RECORD_ID = "public-envelope";
|
|
99
|
+
async function loadPublicEnvelope(store, vault) {
|
|
100
|
+
const envelope = await store.get(vault, "_meta", PUBLIC_ENVELOPE_RECORD_ID);
|
|
101
|
+
if (!envelope) return void 0;
|
|
102
|
+
try {
|
|
103
|
+
const parsed = JSON.parse(envelope._data);
|
|
104
|
+
if (!isPublicEnvelope(parsed)) return void 0;
|
|
105
|
+
return parsed;
|
|
106
|
+
} catch {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function savePublicEnvelope(store, vault, envelope) {
|
|
111
|
+
const wireEnvelope = {
|
|
112
|
+
_noydb: NOYDB_FORMAT_VERSION,
|
|
113
|
+
_v: 1,
|
|
114
|
+
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
115
|
+
_iv: "",
|
|
116
|
+
_data: JSON.stringify(envelope)
|
|
117
|
+
};
|
|
118
|
+
await store.put(vault, "_meta", PUBLIC_ENVELOPE_RECORD_ID, wireEnvelope);
|
|
119
|
+
}
|
|
120
|
+
async function readPublicEnvelope(store, vault, opts = {}) {
|
|
121
|
+
const raw = await loadPublicEnvelope(store, vault);
|
|
122
|
+
if (!raw) return void 0;
|
|
123
|
+
if (opts.locale === void 0) return raw;
|
|
124
|
+
return resolveLocale(raw, opts.locale);
|
|
125
|
+
}
|
|
126
|
+
function resolveLocale(envelope, locale) {
|
|
127
|
+
return {
|
|
128
|
+
...envelope,
|
|
129
|
+
...envelope.name !== void 0 ? { name: pickLocale(envelope.name, locale, envelope.defaultLocale) } : {},
|
|
130
|
+
...envelope.description !== void 0 ? { description: pickLocale(envelope.description, locale, envelope.defaultLocale) } : {}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function pickLocale(value, locale, defaultLocale) {
|
|
134
|
+
if (typeof value === "string") return value;
|
|
135
|
+
if (value[locale] !== void 0 && value[locale] !== "") return value[locale];
|
|
136
|
+
if (defaultLocale && value[defaultLocale] !== void 0 && value[defaultLocale] !== "") {
|
|
137
|
+
return value[defaultLocale];
|
|
138
|
+
}
|
|
139
|
+
for (const v of Object.values(value)) {
|
|
140
|
+
if (v !== "") return v;
|
|
141
|
+
}
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
validatePublicEnvelopeInput,
|
|
147
|
+
isPublicEnvelope,
|
|
148
|
+
PUBLIC_ENVELOPE_RECORD_ID,
|
|
149
|
+
loadPublicEnvelope,
|
|
150
|
+
savePublicEnvelope,
|
|
151
|
+
readPublicEnvelope,
|
|
152
|
+
resolveLocale,
|
|
153
|
+
pickLocale
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=chunk-UQQ2XFXI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/meta/public-envelope/schema.ts","../src/meta/public-envelope/storage.ts"],"sourcesContent":["/**\n * Validate-on-write for the public envelope. Runs at every\n * `setPublicEnvelope` call; the developer's schema decides which\n * fields are allowed and the size caps that apply.\n *\n * @module\n */\nimport { ValidationError } from '../../errors.js'\nimport type {\n PublicEnvelope,\n PublicEnvelopeText,\n ResolvedPublicEnvelopeSchema,\n PublicEnvelopeField,\n} from './types.js'\n\n/** Owner-supplied input — the subset of {@link PublicEnvelope} the owner can set. */\nexport interface SetPublicEnvelopeInput {\n readonly name?: PublicEnvelopeText\n readonly description?: PublicEnvelopeText\n readonly icon?: string\n readonly defaultLocale?: string\n}\n\nconst DATA_URL_PREFIX = /^data:([a-zA-Z0-9.+-]+\\/[a-zA-Z0-9.+-]+);base64,/\n\n/**\n * Validate an owner-supplied envelope input against the developer's\n * resolved schema. Throws `ValidationError` on the first violation;\n * returns void on success.\n *\n * The validator is deliberately strict: every fail mode is a hard\n * error rather than a silent drop, so the owner finds out immediately\n * which field they oversized rather than discovering a truncated\n * label months later.\n */\nexport function validatePublicEnvelopeInput(\n input: SetPublicEnvelopeInput,\n schema: ResolvedPublicEnvelopeSchema,\n): void {\n const allowed = new Set<PublicEnvelopeField>(schema.fields)\n\n // Reject any key not in the schema's allowed-field list.\n for (const key of Object.keys(input)) {\n const known: PublicEnvelopeField | undefined =\n key === 'name' || key === 'description' || key === 'icon' || key === 'defaultLocale'\n ? key\n : undefined\n if (!known) {\n throw new ValidationError(\n `setPublicEnvelope: unknown field \"${key}\". ` +\n `Allowed fields: ${[...allowed].join(', ')}.`,\n )\n }\n if (!allowed.has(known)) {\n throw new ValidationError(\n `setPublicEnvelope: field \"${known}\" is not enabled in this vault's schema. ` +\n `Allowed fields: ${[...allowed].join(', ')}.`,\n )\n }\n }\n\n if (input.name !== undefined) {\n validateText(input.name, 'name', schema.maxStringChars)\n }\n if (input.description !== undefined) {\n validateText(input.description, 'description', schema.maxStringChars)\n }\n if (input.icon !== undefined) {\n validateIcon(input.icon, schema)\n }\n if (input.defaultLocale !== undefined && typeof input.defaultLocale !== 'string') {\n throw new ValidationError(\n `setPublicEnvelope: defaultLocale must be a string (BCP-47), got ${typeof input.defaultLocale}.`,\n )\n }\n}\n\nfunction validateText(\n value: PublicEnvelopeText,\n field: string,\n maxChars: number,\n): void {\n if (typeof value === 'string') {\n if (value.length > maxChars) {\n throw new ValidationError(\n `setPublicEnvelope: ${field} exceeds the ${maxChars}-character cap (got ${value.length}).`,\n )\n }\n return\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new ValidationError(\n `setPublicEnvelope: ${field} must be a string or { [locale]: string } map, got ${typeof value}.`,\n )\n }\n // Locale map. Each value must be a non-empty string within the cap.\n for (const [locale, str] of Object.entries(value)) {\n if (typeof str !== 'string') {\n throw new ValidationError(\n `setPublicEnvelope: ${field}[${locale}] must be a string, got ${typeof str}.`,\n )\n }\n if (str.length > maxChars) {\n throw new ValidationError(\n `setPublicEnvelope: ${field}[${locale}] exceeds the ${maxChars}-character cap (got ${str.length}).`,\n )\n }\n }\n}\n\nfunction validateIcon(icon: string, schema: ResolvedPublicEnvelopeSchema): void {\n if (typeof icon !== 'string') {\n throw new ValidationError(\n `setPublicEnvelope: icon must be a data: URL string, got ${typeof icon}.`,\n )\n }\n if (icon.length > schema.maxIconBytes) {\n throw new ValidationError(\n `setPublicEnvelope: icon exceeds the ${schema.maxIconBytes}-byte cap (got ${icon.length}).`,\n )\n }\n const m = DATA_URL_PREFIX.exec(icon)\n if (!m) {\n throw new ValidationError(\n 'setPublicEnvelope: icon must be a base64 data URL ' +\n '(`data:image/png;base64,…` or `data:image/svg+xml;base64,…`). ' +\n 'External URLs are not supported in v1.',\n )\n }\n const mime = m[1]!\n if (!schema.iconMimeTypes.includes(mime)) {\n throw new ValidationError(\n `setPublicEnvelope: icon MIME type \"${mime}\" is not allowed. ` +\n `Permitted types: ${schema.iconMimeTypes.join(', ')}.`,\n )\n }\n}\n\n/**\n * Lightweight runtime predicate — used by the bundle header\n * validator to recognise a public envelope without requiring it.\n */\nexport function isPublicEnvelope(x: unknown): x is PublicEnvelope {\n if (x === null || typeof x !== 'object' || Array.isArray(x)) return false\n const obj = x as Record<string, unknown>\n return obj['_noydb_public'] === 1 && typeof obj['version'] === 'number'\n}\n","/**\n * Persistence helpers for `_meta/public-envelope`. Mirrors the\n * bypass-AES pattern used by `_meta/handle` and `_meta/policy` —\n * the document is plaintext JSON, the envelope's `_iv` field is\n * left empty.\n *\n * @module\n */\nimport type { NoydbStore, EncryptedEnvelope } from '../../types.js'\nimport { NOYDB_FORMAT_VERSION } from '../../types.js'\nimport type { PublicEnvelope } from './types.js'\nimport { isPublicEnvelope } from './schema.js'\n\n/** Reserved id for the vault-level public envelope record. */\nexport const PUBLIC_ENVELOPE_RECORD_ID = 'public-envelope'\n\n/**\n * Read the public envelope from `_meta/public-envelope`. Returns\n * `undefined` when no envelope has been persisted (fresh vault, or\n * a vault written before the feature was enabled). Tolerates\n * corrupted documents — a JSON parse failure surfaces as `undefined`,\n * not a thrown error, mirroring `_meta/handle`'s contract.\n */\nexport async function loadPublicEnvelope(\n store: NoydbStore,\n vault: string,\n): Promise<PublicEnvelope | undefined> {\n const envelope = await store.get(vault, '_meta', PUBLIC_ENVELOPE_RECORD_ID)\n if (!envelope) return undefined\n try {\n const parsed = JSON.parse(envelope._data) as unknown\n if (!isPublicEnvelope(parsed)) return undefined\n return parsed\n } catch {\n return undefined\n }\n}\n\n/** Persist the public envelope. Idempotent — overwrites any prior write. */\nexport async function savePublicEnvelope(\n store: NoydbStore,\n vault: string,\n envelope: PublicEnvelope,\n): Promise<void> {\n const wireEnvelope: EncryptedEnvelope = {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: 1,\n _ts: new Date().toISOString(),\n _iv: '',\n _data: JSON.stringify(envelope),\n }\n await store.put(vault, '_meta', PUBLIC_ENVELOPE_RECORD_ID, wireEnvelope)\n}\n\n/**\n * Public, no-key reader. Plain function, not a method on `Noydb` —\n * the whole point is it works without an authenticated session, so\n * a UI can show \"Acme 2026 Tax Records\" before unlocking.\n *\n * Resolves any `name` / `description` locale map through the supplied\n * `locale` (when provided). Omitting `locale` returns the raw\n * envelope, which a multilingual picker can render as it pleases.\n */\nexport async function readPublicEnvelope(\n store: NoydbStore,\n vault: string,\n opts: { readonly locale?: string } = {},\n): Promise<PublicEnvelope | undefined> {\n const raw = await loadPublicEnvelope(store, vault)\n if (!raw) return undefined\n if (opts.locale === undefined) return raw\n return resolveLocale(raw, opts.locale)\n}\n\n/**\n * Resolve the locale-map fields (`name`, `description`) of a public\n * envelope to plain strings for the requested locale, falling back\n * through `defaultLocale` and then any available translation.\n *\n * @internal\n */\nexport function resolveLocale(\n envelope: PublicEnvelope,\n locale: string,\n): PublicEnvelope {\n return {\n ...envelope,\n ...(envelope.name !== undefined ? { name: pickLocale(envelope.name, locale, envelope.defaultLocale) } : {}),\n ...(envelope.description !== undefined ? { description: pickLocale(envelope.description, locale, envelope.defaultLocale) } : {}),\n }\n}\n\n/**\n * Resolve a `string | { [locale]: string }` value to a string for a\n * given locale. Exported so the bundle reader can reuse it without\n * duplicating the fallback chain.\n *\n * **Looser than `resolveI18nText`** — the hub's record-field resolver\n * throws `LocaleNotSpecifiedError` when no translation matches, but\n * label semantics deliberately prefer \"show *something*\" over\n * throwing. The fallback chain is:\n * 1. Exact `locale` match.\n * 2. `defaultLocale` (when supplied on the envelope).\n * 3. First non-empty value in the map.\n * 4. Empty string (only if every translation is empty — pathological).\n *\n * This deviation is documented in `docs/subsystems/public-envelope.md`.\n */\nexport function pickLocale(\n value: string | Record<string, string>,\n locale: string,\n defaultLocale: string | undefined,\n): string {\n if (typeof value === 'string') return value\n if (value[locale] !== undefined && value[locale] !== '') return value[locale]\n if (defaultLocale && value[defaultLocale] !== undefined && value[defaultLocale] !== '') {\n return value[defaultLocale]\n }\n for (const v of Object.values(value)) {\n if (v !== '') return v\n }\n return ''\n}\n"],"mappings":";;;;;;;;AAuBA,IAAM,kBAAkB;AAYjB,SAAS,4BACd,OACA,QACM;AACN,QAAM,UAAU,IAAI,IAAyB,OAAO,MAAM;AAG1D,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,UAAM,QACJ,QAAQ,UAAU,QAAQ,iBAAiB,QAAQ,UAAU,QAAQ,kBACjE,MACA;AACN,QAAI,CAAC,OAAO;AACV,YAAM,IAAI;AAAA,QACR,qCAAqC,GAAG,sBACnB,CAAC,GAAG,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,MAC9C;AAAA,IACF;AACA,QAAI,CAAC,QAAQ,IAAI,KAAK,GAAG;AACvB,YAAM,IAAI;AAAA,QACR,6BAA6B,KAAK,4DACb,CAAC,GAAG,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAEA,MAAI,MAAM,SAAS,QAAW;AAC5B,i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ACjD,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,KAAK,WAAW,OAAW,QAAO;AACtC,SAAO,cAAc,KAAK,KAAK,MAAM;AACvC;AASO,SAAS,cACd,UACA,QACgB;AAChB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAI,SAAS,SAAS,SAAY,EAAE,MAAM,WAAW,SAAS,MAAM,QAAQ,SAAS,aAAa,EAAE,IAAI,CAAC;AAAA,IACzG,GAAI,SAAS,gBAAgB,SAAY,EAAE,aAAa,WAAW,SAAS,aAAa,QAAQ,SAAS,aAAa,EAAE,IAAI,CAAC;AAAA,EAChI;AACF;AAkBO,SAAS,WACd,OACA,QACA,eACQ;AACR,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,MAAM,MAAM,MAAM,UAAa,MAAM,MAAM,MAAM,GAAI,QAAO,MAAM,MAAM;AAC5E,MAAI,iBAAiB,MAAM,aAAa,MAAM,UAAa,MAAM,aAAa,MAAM,IAAI;AACtF,WAAO,MAAM,aAAa;AAAA,EAC5B;AACA,aAAW,KAAK,OAAO,OAAO,KAAK,GAAG;AACpC,QAAI,MAAM,GAAI,QAAO;AAAA,EACvB;AACA,SAAO;AACT;","names":[]}
|
package/dist/consent/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Z as ConsentStrategy } from '../types-
|
|
2
|
-
export { _ as CONSENT_AUDIT_COLLECTION, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, a3 as loadConsentEntries, a4 as writeConsentEntry } from '../types-
|
|
1
|
+
import { Z as ConsentStrategy } from '../types-BpyE4o_n.cjs';
|
|
2
|
+
export { _ as CONSENT_AUDIT_COLLECTION, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, a3 as loadConsentEntries, a4 as writeConsentEntry } from '../types-BpyE4o_n.cjs';
|
|
3
3
|
import '../lazy-builder-CZVLKh0Z.cjs';
|
|
4
4
|
import '../predicate-SBHmi6D0.cjs';
|
|
5
5
|
import '../strategy-D-SrOLCl.cjs';
|
|
6
6
|
import '../strategy-BSxFXGzb.cjs';
|
|
7
|
-
import '../index-
|
|
7
|
+
import '../index-6xNpPsxR.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Active consent strategy. Calling `withConsent()` returns a
|
package/dist/consent/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Z as ConsentStrategy } from '../types-
|
|
2
|
-
export { _ as CONSENT_AUDIT_COLLECTION, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, a3 as loadConsentEntries, a4 as writeConsentEntry } from '../types-
|
|
1
|
+
import { Z as ConsentStrategy } from '../types-Df72wWCC.js';
|
|
2
|
+
export { _ as CONSENT_AUDIT_COLLECTION, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, a3 as loadConsentEntries, a4 as writeConsentEntry } from '../types-Df72wWCC.js';
|
|
3
3
|
import '../lazy-builder-BwEoBQZ9.js';
|
|
4
4
|
import '../predicate-SBHmi6D0.js';
|
|
5
5
|
import '../strategy-D-SrOLCl.js';
|
|
6
6
|
import '../strategy-BSxFXGzb.js';
|
|
7
|
-
import '../index-
|
|
7
|
+
import '../index-DJTf9yxn.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Active consent strategy. Calling `withConsent()` returns a
|