@entifix/core 0.23.6 → 0.23.8

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The entity system. A class decorated with `@entity()` and `@accessor()` describes itself — its members, their types and labels, which of them are sortable or filterable — and everything else in entifix reads that description instead of being told it again.
4
4
 
5
- Presentation lives on the class too: `@entity({ creatable })`, and `@accessor({ minWidth, card, autocomplete })` for how a member reads in a table, on a card and to a browser's autofill. A `@useCase()` declares its place in the action hierarchy (`emphasis`, `priority`, `rowInline`, `shortcut`), the record states it is offered in (`availableWhen`) and, when destructive, how it is undone (`reversible`, `inverse`); a bad shortcut (`parseChord`) or an unsafe destructive verb fails at load.
5
+ Presentation lives on the class too: `@entity({ creatable })`, and `@accessor({ minWidth, card, autocomplete, money, scaled })` for how a member reads in a table, on a card and to a browser's autofill. A `@useCase()` declares its place in the action hierarchy (`emphasis`, `priority`, `rowInline`, `shortcut`), the record states it is offered in (`availableWhen`) and, when destructive, how it is undone (`reversible`, `inverse`); a bad shortcut (`parseChord`) or an unsafe destructive verb fails at load.
6
6
 
7
7
  It also owns what crosses the wire: entity serialization and reconstruction, the envelopes a service answers with, and the RSQL filter and sort protocol a query is written in. Nothing here performs I/O.
8
8
 
@@ -1,4 +1,4 @@
1
- import { type CardRole, type ChildConstructor, type EntityLinkSerialization, type EnumTone, type MemberReference, MetaAccessorType, type MoneyFormat } from '../meta-entities/meta-accessor/index.js';
1
+ import { type CardRole, type ChildConstructor, type EntityLinkSerialization, type EnumTone, type MemberReference, MetaAccessorType, type MoneyFormat, type ScaledFormat } from '../meta-entities/meta-accessor/index.js';
2
2
  /**
3
3
  * A displayable member of an entity, resolved from its accessor metadata. This
4
4
  * is the contract generic UI builds itself from — a table's columns today, a
@@ -55,6 +55,8 @@ export interface EntityFieldDescriptor {
55
55
  notBefore?: string;
56
56
  /** The member is an amount of money, read as this declares. `number` members only. */
57
57
  money?: MoneyFormat;
58
+ /** The member is a scaled integer, read as this declares. `number` members only. */
59
+ scaled?: ScaledFormat;
58
60
  /** The narrowest the member's column reads at, in `rem`, when declared. */
59
61
  minWidth?: number;
60
62
  /** The part the member plays on a record's card, when declared. */
@@ -1 +1 @@
1
- {"version":3,"file":"describe-entity-columns.d.ts","sourceRoot":"","sources":["../../../src/entity-definition/describe/describe-entity-columns.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EAEb,KAAK,eAAe,EAEpB,gBAAgB,EAChB,KAAK,WAAW,EACjB,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,QAAQ,EAAE,OAAO,CAAC;IAClB,kEAAkE;IAClE,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/C,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C;;;OAGG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AAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,EAAE,QAWJ;AAkED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,MAAM,EAC1D,iBAAiB,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAC5C,MAAM,CAAC,EAAE,OAAO,GACf,qBAAqB,EAAE,CAsBzB"}
1
+ {"version":3,"file":"describe-entity-columns.d.ts","sourceRoot":"","sources":["../../../src/entity-definition/describe/describe-entity-columns.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EAEb,KAAK,eAAe,EAEpB,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,QAAQ,EAAE,OAAO,CAAC;IAClB,kEAAkE;IAClE,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/C,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,kBA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AAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,EAAE,QAWJ;AAsED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,MAAM,EAC1D,iBAAiB,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAC5C,MAAM,CAAC,EAAE,OAAO,GACf,qBAAqB,EAAE,CAuBzB"}
@@ -1,4 +1,5 @@
1
1
  import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { MAX_SCALE } from '../../i18n/scaled-number.js';
2
3
  import { extractMetaAccessors, findMetaEntity } from '../helpers/index.js';
3
4
  import { EntityCollectionLink } from '../links/entity-collection-link/index.js';
4
5
  import { EntityLink } from '../links/entity-link/index.js';
@@ -182,6 +183,27 @@ import { EnumTones } from '../meta-entities/meta-accessor/index.js';
182
183
  if (metaAccessor.money === undefined || type === 'number') return;
183
184
  throw new Error(`"${String(metaAccessor.name)}" is a ${type} and declares money — only a number member can be an amount.`);
184
185
  }
186
+ /**
187
+ * A scale is a count of decimals on a number that is not money — money has
188
+ * its currency's.
189
+ */ function assertScaled(metaAccessor, type) {
190
+ const { scaled } = metaAccessor;
191
+ if (scaled === undefined) return;
192
+ const name = String(metaAccessor.name);
193
+ if (type !== 'number') {
194
+ throw new Error(`"${name}" is a ${type} and declares scaled — only a number member can be a scaled integer.`);
195
+ }
196
+ if (metaAccessor.money !== undefined) {
197
+ throw new Error(`"${name}" declares money and scaled — an amount's decimals are its currency's.`);
198
+ }
199
+ const scales = scaled.units === undefined ? [
200
+ scaled.scale
201
+ ] : Object.values(scaled.units);
202
+ const valid = (scale)=>Number.isInteger(scale) && scale >= 0 && scale <= MAX_SCALE;
203
+ if (scales.length === 0 || !scales.every(valid)) {
204
+ throw new Error(`"${name}" declares scales [${scales.join(', ')}] — at least one, each a whole number of decimals from 0 to ${String(MAX_SCALE)}.`);
205
+ }
206
+ }
185
207
  /**
186
208
  * Tones belong to an enum's values: on any other member, or keyed by a value
187
209
  * the enum does not have, they would colour nothing — or the wrong thing.
@@ -223,6 +245,20 @@ import { EnumTones } from '../meta-entities/meta-accessor/index.js';
223
245
  }
224
246
  }
225
247
  }
248
+ /**
249
+ * A `unitMember` must be a visible `string` or `enum` member of the same
250
+ * entity: without it the integer would print a thousand times what it means.
251
+ */ function assertUnitMembers(descriptors) {
252
+ for (const descriptor of descriptors){
253
+ var _descriptor_scaled;
254
+ const member = (_descriptor_scaled = descriptor.scaled) == null ? void 0 : _descriptor_scaled.unitMember;
255
+ if (member === undefined) continue;
256
+ const unit = descriptors.find((other)=>other.name === member);
257
+ if ((unit == null ? void 0 : unit.type) !== 'string' && (unit == null ? void 0 : unit.type) !== 'enum') {
258
+ throw new Error(`"${descriptor.name}" reads its unit from "${member}", which must be a visible string or enum member of the entity.`);
259
+ }
260
+ }
261
+ }
226
262
  /**
227
263
  * One parent member per entity. Two would be two trees over the same records,
228
264
  * and which one a table indents by would depend on declaration order.
@@ -253,6 +289,7 @@ function toDescriptor(target, metaAccessor, index, sample) {
253
289
  assertParentType(metaAccessor, type);
254
290
  assertReference(target, metaAccessor, type);
255
291
  assertMoneyType(metaAccessor, type);
292
+ assertScaled(metaAccessor, type);
256
293
  assertEnumTones(metaAccessor, type);
257
294
  assertMinWidth(metaAccessor);
258
295
  const child = type === 'composition' ? metaAccessor.childType == null ? void 0 : metaAccessor.childType.call(metaAccessor) : undefined;
@@ -287,6 +324,8 @@ function toDescriptor(target, metaAccessor, index, sample) {
287
324
  notBefore: metaAccessor.notBefore
288
325
  }, metaAccessor.money === undefined ? {} : {
289
326
  money: metaAccessor.money
327
+ }, metaAccessor.scaled === undefined ? {} : {
328
+ scaled: metaAccessor.scaled
290
329
  }, metaAccessor.minWidth === undefined ? {} : {
291
330
  minWidth: metaAccessor.minWidth
292
331
  }, metaAccessor.card === undefined ? {} : {
@@ -330,6 +369,7 @@ function toDescriptor(target, metaAccessor, index, sample) {
330
369
  }).map((metaAccessor, index)=>toDescriptor(entityConstructor, metaAccessor, index, sample)).sort((left, right)=>left.order - right.order);
331
370
  assertNotBefore(descriptors);
332
371
  assertCurrencyMembers(descriptors);
372
+ assertUnitMembers(descriptors);
333
373
  assertOneParent(descriptors);
334
374
  assertLabelMember(entityConstructor, descriptors);
335
375
  return descriptors;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/entity-definition/describe/describe-entity-columns.ts"],"sourcesContent":["import { extractMetaAccessors, findMetaEntity } from '../helpers/index.js';\nimport { EntityCollectionLink } from '../links/entity-collection-link/index.js';\nimport { EntityLink } from '../links/entity-link/index.js';\nimport { assertBounds } from '../meta-entities/bounds.js';\nimport {\n type CardRole,\n type ChildConstructor,\n type EntityLinkSerialization,\n type EnumTone,\n EnumTones,\n type MemberReference,\n MetaAccessor,\n MetaAccessorType,\n type MoneyFormat,\n} from '../meta-entities/meta-accessor/index.js';\n\n/**\n * A displayable member of an entity, resolved from its accessor metadata. This\n * is the contract generic UI builds itself from — a table's columns today, a\n * form's fields later — so it stays framework-free and lives next to the\n * metadata it derives from.\n */\nexport interface EntityFieldDescriptor {\n /** Accessor name. The stable identity used by preferences and slots. */\n name: string;\n /** Wire/property key: `alias ?? name`. */\n key: string;\n label: string;\n /**\n * Catalog key for {@link label}, when the entity declared one. Resolution is\n * the presentation layer's job — core has no locale and no catalogs, and the\n * same descriptor feeds the server-side filter allowlist, where a translated\n * label would be meaningless.\n */\n labelKey?: string;\n type: MetaAccessorType;\n sortable: boolean;\n filterable: boolean;\n order: number;\n /** Cannot be written back. A form shows it but disables its input. */\n readonly: boolean;\n /** Must hold a value. A form rejects submit while it is empty. */\n required: boolean;\n enumValues?: readonly string[];\n /** Catalog prefix for {@link enumValues}; a value reads as `${enumLabelKey}.${value}`. */\n enumLabelKey?: string;\n /** The tone each value reads in as a status, when the member declares them. */\n enumTones?: Readonly<Record<string, EnumTone>>;\n /** Property of a `link` target used as its display label. */\n linkLabelProperty: string;\n /** Property of a `link` target a picker searches on. Defaults to the label. */\n linkSearchProperty: string;\n /** Whether a `link` writes back its foreign key or the inlined target. */\n linkSerialization: EntityLinkSerialization;\n /**\n * The class describing one row of a `composition` member, resolved from the\n * accessor's thunk. Absent on every other type.\n */\n childType?: ChildConstructor;\n /**\n * The member is dropped when the record is copied — a unique code, an audit\n * stamp. The identity member is always reset and is not flagged.\n */\n resetOnClone: boolean;\n /** The fewest values a collection member may hold. */\n minItems?: number;\n /** The most values a collection member may hold. */\n maxItems?: number;\n /** The `date` member this one may not precede. */\n notBefore?: string;\n /** The member is an amount of money, read as this declares. `number` members only. */\n money?: MoneyFormat;\n /** The narrowest the member's column reads at, in `rem`, when declared. */\n minWidth?: number;\n /** The part the member plays on a record's card, when declared. */\n card?: CardRole;\n /** The member's HTML autofill token, when declared. */\n autocomplete?: string;\n /** This member holds the parent record's id: the entity forms a tree. */\n parent?: boolean;\n /**\n * This member holds the id of a record of another entity, named `domain:key`.\n * A screen shows that record's name in its place.\n */\n references?: MemberReference;\n /**\n * `'none'`: the member travels with the record and is never shown — a form\n * keeps it in its draft without a field, a table without a column. Today\n * only a `revision` member presents as nothing.\n */\n presentation?: 'none';\n}\n\n/** Types whose values are scalars a user can meaningfully sort/filter on. */\nexport const SCALAR_TYPES: readonly MetaAccessorType[] = [\n 'string',\n 'number',\n 'boolean',\n 'date',\n 'enum',\n];\n\n/**\n * Types whose value is a collection. None of them may ever be sorted or\n * filtered: this descriptor is also the **server-side RSQL allowlist**, and an\n * array compared as a scalar matches nothing — so the query would not fail, it\n * would quietly return an empty page.\n *\n * Exported so `describe-entity-columns.spec.ts` can assert that this list,\n * {@link SCALAR_TYPES}, the two reference types and `localized` partition\n * `MetaAccessorTypes` exactly. Nothing in the repo guards `MetaAccessorType`\n * exhaustively — every switch over it has a `default` that treats the value as\n * a string — so that partition spec is what makes an eleventh type impossible\n * to add silently.\n */\nexport const COLLECTION_TYPES: readonly MetaAccessorType[] = [\n 'linkCollection',\n 'composition',\n 'scalarCollection',\n];\n\n/** `productCode` / `product-code` / `product_code` → `Product Code`. */\nfunction humanize(name: string): string {\n return name\n .replace(/[-_]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/\\s+/g, ' ')\n .trim()\n .replace(/^./, first => first.toUpperCase());\n}\n\n/**\n * Best-effort type for accessors that did not declare one. Entities are not\n * required to annotate every member, so a sample row keeps a bare `@accessor()`\n * usable; a declared `type` always wins over this.\n */\nfunction inferType(name: string, value: unknown): MetaAccessorType {\n if (value instanceof EntityLink) return 'link';\n if (value instanceof EntityCollectionLink) return 'linkCollection';\n if (value instanceof Date) return 'date';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (name === 'id') return 'id';\n return 'string';\n}\n\n/**\n * A collection member declared sortable is always a mistake, and so is a link\n * or composition collection declared filterable — only a `scalarCollection`\n * may be filtered, an equality on it meaning \"any element matches\". The\n * mistake breaks the developer rather than the query — the same posture as `applyEntityLinks`\n * throwing on an `embedded` link it cannot build.\n *\n * Silently clamping to `false` was the alternative and is worse: the author\n * keeps a declaration that reads as honoured, and the symptom is an empty\n * result page rather than an error anyone can act on.\n */\nfunction assertNotQueryable(\n metaAccessor: MetaAccessor,\n type: MetaAccessorType,\n) {\n if (!COLLECTION_TYPES.includes(type)) return;\n // An array of scalars may be filtered (an equality means \"any element\n // matches\"); sortable stays forbidden for every collection, and a link or\n // composition collection is not filterable either.\n const queryableFilter =\n type !== 'scalarCollection' && metaAccessor.filterable === true;\n if (metaAccessor.sortable !== true && !queryableFilter) return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" is a ${type} and cannot be sortable, and only a scalarCollection may be filterable — member metadata is the server-side query allowlist, and a collection compared as a scalar matches nothing.`,\n );\n}\n\n/**\n * Item counts belong to a collection, and must be counts. A `minItems` on a\n * string would read as honoured and constrain nothing.\n */\nfunction assertItemCounts(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n const { minItems, maxItems } = metaAccessor;\n if (minItems === undefined && maxItems === undefined) return;\n const name = String(metaAccessor.name);\n if (!COLLECTION_TYPES.includes(type)) {\n throw new Error(\n `\"${name}\" is a ${type}, and only a collection can declare minItems or maxItems.`,\n );\n }\n assertBounds(`\"${name}\"`, { min: minItems, max: maxItems });\n}\n\n/**\n * `notBefore` compares two instants, so both ends must be `date` members of\n * the same entity. Checked once every member is described, since the one it\n * names may be declared after it.\n */\nfunction assertNotBefore(descriptors: readonly EntityFieldDescriptor[]) {\n for (const descriptor of descriptors) {\n if (descriptor.notBefore === undefined) continue;\n const earlier = descriptors.find(\n other => other.name === descriptor.notBefore,\n );\n if (descriptor.type !== 'date' || earlier?.type !== 'date') {\n throw new Error(\n `\"${descriptor.name}\" declares notBefore \"${descriptor.notBefore}\", and both must be date members of the entity.`,\n );\n }\n }\n}\n\n/**\n * A parent is one record's id, so it is an `id` or a `string` member — a\n * number or a date cannot name a record, and a collection would be two\n * parents. Checked per member, since the type is only known once inferred.\n */\nfunction assertParentType(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n if (metaAccessor.parent !== true) return;\n if (type === 'id' || type === 'string') return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" is a ${type} and cannot be the parent member — a parent is one record's id, so it is an id or a string.`,\n );\n}\n\n/** The one name a revision member may have: the wire key is part of the contract. */\nexport const REVISION_MEMBER = 'revision';\n\n/**\n * A revision is the store's, not the author's: it is one number named\n * `revision` that every save carries and no query uses, so it cannot be\n * renamed, required, queried, hidden (it would not be serialized) or\n * `readonly` (the same). One name makes one member, so an entity has one at\n * most. Checked against every\n * accessor before hidden ones are dropped, since a hidden revision is exactly\n * the one describing would never see.\n */\nfunction assertRevisionMembers(members: readonly MetaAccessor[]) {\n const revisions = members.filter(member => member.type === 'revision');\n for (const member of revisions) {\n const name = String(member.name);\n if (name !== REVISION_MEMBER || member.alias !== undefined) {\n throw new Error(\n `\"${name}\" is a revision member and must be named \"${REVISION_MEMBER}\", with no alias — the wire key is part of the contract.`,\n );\n }\n for (const flag of [\n 'required',\n 'filterable',\n 'sortable',\n 'hidden',\n 'readonly',\n ] as const) {\n if (member[flag] === true) {\n throw new Error(\n `\"${name}\" is a revision member and cannot be ${flag} — it travels with every record and is never queried or entered.`,\n );\n }\n }\n }\n}\n\n/** A composition's child has no save of its own, so it carries no revision. */\nfunction assertChildHasNoRevision(child: ChildConstructor) {\n if (extractMetaAccessors(child).some(member => member.type === 'revision')) {\n throw new Error(\n `${child.name} is the child of a composition and declares a revision member — a child has no save of its own, so its master's revision covers it.`,\n );\n }\n}\n\n/** A reference's entity, as `@entity({ domain, key })` names it: two kebab-case words. */\nconst REFERENCE_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * A reference holds one record's id, so it is an `id` or a `string` member, and\n * names its target as `domain:key`. On the `parent` member it may only name the\n * entity itself — a parent is a record of the same entity, built into a tree —\n * which is what lets a list show a branch's parent by name.\n */\nfunction assertReference(\n target: ChildConstructor,\n metaAccessor: MetaAccessor,\n type: MetaAccessorType,\n) {\n const { references } = metaAccessor;\n if (references === undefined) return;\n const name = String(metaAccessor.name);\n if (type !== 'id' && type !== 'string') {\n throw new Error(\n `\"${name}\" is a ${type} and declares references — a reference holds one record's id, so it is an id or a string.`,\n );\n }\n if (!REFERENCE_KEY.test(references.entity)) {\n throw new Error(\n `\"${name}\" references \"${references.entity}\", which is not an entity's \"domain:key\" — the pair its @entity({ domain, key }) declares.`,\n );\n }\n const own = findMetaEntity(target);\n if (\n metaAccessor.parent === true &&\n references.entity !== `${own?.domain}:${own?.key}`\n ) {\n throw new Error(\n `\"${name}\" is the parent member and references \"${references.entity}\" — a parent is a record of the same entity, so it can only reference ${target.name} itself.`,\n );\n }\n}\n\n/** Members whose value can name a record: a text, a number, or a reference to one. */\nconst LABEL_TYPES: readonly MetaAccessorType[] = [\n 'string',\n 'number',\n 'localized',\n];\n\n/**\n * An entity's `labelMember` must be a visible member that holds one value a\n * person can read: a hidden one never reaches the client, and a collection is\n * many names. Checked against every accessor, since a hidden member is exactly\n * the one describing would never see.\n */\nfunction assertLabelMember(\n target: ChildConstructor,\n descriptors: readonly EntityFieldDescriptor[],\n) {\n const labelMember = findMetaEntity(target)?.labelMember;\n if (labelMember === undefined) return;\n const declared = extractMetaAccessors(target).some(\n metaAccessor => String(metaAccessor.name) === labelMember,\n );\n const descriptor = descriptors.find(other => other.name === labelMember);\n if (descriptor === undefined) {\n throw new Error(\n declared\n ? `${target.name} is called by \"${labelMember}\", which is hidden — a hidden member never reaches the client, so nothing could show the name.`\n : `${target.name} is called by \"${labelMember}\", which is not a member of the entity.`,\n );\n }\n if (\n descriptor.references === undefined &&\n !LABEL_TYPES.includes(descriptor.type)\n ) {\n throw new Error(\n `${target.name} is called by \"${labelMember}\", a ${descriptor.type} — a record is called by a string, a localized text, a number or a reference.`,\n );\n }\n}\n\n/** Money is a reading of a number; any other member declaring it is a mistake. */\nfunction assertMoneyType(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n if (metaAccessor.money === undefined || type === 'number') return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" is a ${type} and declares money — only a number member can be an amount.`,\n );\n}\n\n/**\n * Tones belong to an enum's values: on any other member, or keyed by a value\n * the enum does not have, they would colour nothing — or the wrong thing.\n */\nfunction assertEnumTones(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n const { enumTones } = metaAccessor;\n if (enumTones === undefined) return;\n const name = String(metaAccessor.name);\n if (type !== 'enum') {\n throw new Error(\n `\"${name}\" is a ${type} and declares enumTones — only an enum member's values have a tone.`,\n );\n }\n const values = metaAccessor.enumValues ?? [];\n for (const [value, tone] of Object.entries(enumTones)) {\n if (!values.includes(value)) {\n throw new Error(\n `\"${name}\" declares a tone for \"${value}\", which is not one of its enumValues (${values.join(', ')}).`,\n );\n }\n if (!(EnumTones as readonly string[]).includes(tone)) {\n throw new Error(\n `\"${name}\" declares tone \"${String(tone)}\" for \"${value}\" — a tone is one of ${EnumTones.join(', ')}.`,\n );\n }\n }\n}\n\n/** A width is a positive length; zero or less would never switch layouts. */\nfunction assertMinWidth(metaAccessor: MetaAccessor) {\n const { minWidth } = metaAccessor;\n if (minWidth === undefined || (Number.isFinite(minWidth) && minWidth > 0))\n return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" declares minWidth ${String(minWidth)} — a column's narrowest width is a positive number of rem.`,\n );\n}\n\n/**\n * A `currencyMember` must be a visible `string` member of the same entity: a\n * hidden one never reaches the client, so the amount would print with no\n * currency and nothing would say why.\n */\nfunction assertCurrencyMembers(descriptors: readonly EntityFieldDescriptor[]) {\n for (const descriptor of descriptors) {\n const member = descriptor.money?.currencyMember;\n if (member === undefined) continue;\n const currency = descriptors.find(other => other.name === member);\n if (currency?.type !== 'string') {\n throw new Error(\n `\"${descriptor.name}\" reads its currency from \"${member}\", which must be a visible string member of the entity.`,\n );\n }\n }\n}\n\n/**\n * One parent member per entity. Two would be two trees over the same records,\n * and which one a table indents by would depend on declaration order.\n */\nexport function assertOneParent(\n members: readonly {\n readonly name: string | symbol;\n readonly parent?: boolean;\n }[],\n) {\n const parents = members.filter(member => member.parent === true);\n if (parents.length > 1) {\n throw new Error(\n `An entity declares one parent member at most; found ${parents.map(member => `\"${String(member.name)}\"`).join(', ')}.`,\n );\n }\n}\n\n/**\n * ⚠️ **A parent member must travel.** The serializer skips a `hidden` or\n * `readonly` member in both directions, so the parent key would not survive a\n * single trip over the wire and the tree would arrive flat, with nothing\n * failing. Hide it from a table or a form with a slot instead. Checked before\n * hidden members are dropped, since a hidden parent is exactly the one\n * describing would never see.\n */\nexport function assertParentVisible(\n members: readonly {\n readonly name: string | symbol;\n readonly parent?: boolean;\n readonly hidden?: boolean;\n readonly readonly?: boolean;\n }[],\n) {\n const stuck = members.find(\n member =>\n member.parent === true &&\n (member.hidden === true || member.readonly === true),\n );\n if (stuck === undefined) return;\n throw new Error(\n `\"${String(stuck.name)}\" is the parent member and is ${stuck.hidden === true ? 'hidden' : 'readonly'} — such a member is never serialized, so the tree would arrive flat. Hide it with a slot instead.`,\n );\n}\n\nfunction toDescriptor(\n target: ChildConstructor,\n metaAccessor: MetaAccessor,\n index: number,\n sample: unknown,\n): EntityFieldDescriptor {\n const name = String(metaAccessor.name);\n const type =\n metaAccessor.type ??\n inferType(name, (sample as Record<string, unknown> | undefined)?.[name]);\n assertNotQueryable(metaAccessor, type);\n assertItemCounts(metaAccessor, type);\n assertParentType(metaAccessor, type);\n assertReference(target, metaAccessor, type);\n assertMoneyType(metaAccessor, type);\n assertEnumTones(metaAccessor, type);\n assertMinWidth(metaAccessor);\n const child = type === 'composition' ? metaAccessor.childType?.() : undefined;\n if (child !== undefined) assertChildHasNoRevision(child);\n // A localized member is queried one locale at a time (`name.en`), which\n // makes it as queryable as the text each locale holds.\n const isScalar = SCALAR_TYPES.includes(type) || type === 'localized';\n const linkLabelProperty = metaAccessor.linkLabelProperty ?? 'name';\n\n return {\n name,\n key: String(metaAccessor.alias ?? metaAccessor.name),\n label: metaAccessor.label ?? humanize(name),\n labelKey: metaAccessor.labelKey,\n type,\n sortable: metaAccessor.sortable ?? isScalar,\n filterable: metaAccessor.filterable ?? isScalar,\n order: metaAccessor.order ?? index,\n readonly: metaAccessor.readonly ?? false,\n required: metaAccessor.required ?? false,\n enumValues: metaAccessor.enumValues,\n enumLabelKey: metaAccessor.enumLabelKey,\n ...(metaAccessor.enumTones === undefined\n ? {}\n : { enumTones: metaAccessor.enumTones }),\n linkLabelProperty,\n linkSearchProperty: metaAccessor.linkSearchProperty ?? linkLabelProperty,\n linkSerialization: metaAccessor.linkSerialization ?? 'id',\n childType: metaAccessor.childType?.(),\n resetOnClone: metaAccessor.resetOnClone ?? false,\n minItems: metaAccessor.minItems,\n maxItems: metaAccessor.maxItems,\n notBefore: metaAccessor.notBefore,\n ...(metaAccessor.money === undefined ? {} : { money: metaAccessor.money }),\n ...(metaAccessor.minWidth === undefined\n ? {}\n : { minWidth: metaAccessor.minWidth }),\n ...(metaAccessor.card === undefined ? {} : { card: metaAccessor.card }),\n ...(metaAccessor.autocomplete === undefined\n ? {}\n : { autocomplete: metaAccessor.autocomplete }),\n parent: metaAccessor.parent ?? false,\n ...(type === 'revision' ? { presentation: 'none' as const } : {}),\n ...(metaAccessor.references === undefined\n ? {}\n : { references: metaAccessor.references }),\n };\n}\n\n/**\n * Resolves an entity's displayable members from its accessor metadata, sorted by\n * `order` (declaration order when undeclared).\n *\n * Getter-kind and non-`hidden` mirror the filter {@link serializeEntity} walks,\n * minus its `readonly` exclusion: a read-only member is still worth showing,\n * it just cannot be written back.\n *\n * `sample` is an optional instance used only to infer the `type` of accessors\n * that did not declare one.\n *\n * The target is a {@link ChildConstructor} rather than an `EntityConstructor`,\n * which is wider than it looks: nothing here reads `id`, and a `composition`\n * member's child is a **value** with accessors and no identity. So the same\n * walk describes an entity and describes one row of the collection it owns,\n * from one implementation.\n */\nexport function describeEntityColumns<TTarget extends object>(\n entityConstructor: ChildConstructor<TTarget>,\n sample?: TTarget,\n): EntityFieldDescriptor[] {\n const seen = new Set<string>();\n assertParentVisible(extractMetaAccessors(entityConstructor));\n assertRevisionMembers(extractMetaAccessors(entityConstructor));\n\n const descriptors = extractMetaAccessors(entityConstructor)\n .filter(metaAccessor => {\n if (metaAccessor.hidden || metaAccessor.kind !== 'getter') return false;\n const name = String(metaAccessor.name);\n if (seen.has(name)) return false;\n seen.add(name);\n return true;\n })\n .map((metaAccessor, index) =>\n toDescriptor(entityConstructor, metaAccessor, index, sample),\n )\n .sort((left, right) => left.order - right.order);\n assertNotBefore(descriptors);\n assertCurrencyMembers(descriptors);\n assertOneParent(descriptors);\n assertLabelMember(entityConstructor, descriptors);\n return descriptors;\n}\n"],"names":["extractMetaAccessors","findMetaEntity","EntityCollectionLink","EntityLink","assertBounds","EnumTones","SCALAR_TYPES","COLLECTION_TYPES","humanize","name","replace","trim","first","toUpperCase","inferType","value","Date","assertNotQueryable","metaAccessor","type","includes","queryableFilter","filterable","sortable","Error","String","assertItemCounts","minItems","maxItems","undefined","min","max","assertNotBefore","descriptors","descriptor","notBefore","earlier","find","other","assertParentType","parent","REVISION_MEMBER","assertRevisionMembers","members","revisions","filter","member","alias","flag","assertChildHasNoRevision","child","some","REFERENCE_KEY","assertReference","target","references","test","entity","own","domain","key","LABEL_TYPES","assertLabelMember","labelMember","declared","assertMoneyType","money","assertEnumTones","enumTones","values","enumValues","tone","Object","entries","join","assertMinWidth","minWidth","Number","isFinite","assertCurrencyMembers","currencyMember","currency","assertOneParent","parents","length","map","assertParentVisible","stuck","hidden","readonly","toDescriptor","index","sample","childType","isScalar","linkLabelProperty","label","labelKey","order","required","enumLabelKey","linkSearchProperty","linkSerialization","resetOnClone","card","autocomplete","presentation","describeEntityColumns","entityConstructor","seen","Set","kind","has","add","sort","left","right"],"mappings":";AAAA,SAASA,oBAAoB,EAAEC,cAAc,QAAQ,sBAAsB;AAC3E,SAASC,oBAAoB,QAAQ,2CAA2C;AAChF,SAASC,UAAU,QAAQ,gCAAgC;AAC3D,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAKEC,SAAS,QAKJ,0CAA0C;AA+EjD,2EAA2E,GAC3E,OAAO,MAAMC,eAA4C;IACvD;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,mBAAgD;IAC3D;IACA;IACA;CACD,CAAC;AAEF,sEAAsE,GACtE,SAASC,SAASC,IAAY;IAC5B,OAAOA,KACJC,OAAO,CAAC,UAAU,KAClBA,OAAO,CAAC,sBAAsB,SAC9BA,OAAO,CAAC,QAAQ,KAChBC,IAAI,GACJD,OAAO,CAAC,MAAME,CAAAA,QAASA,MAAMC,WAAW;AAC7C;AAEA;;;;CAIC,GACD,SAASC,UAAUL,IAAY,EAAEM,KAAc;IAC7C,IAAIA,iBAAiBZ,YAAY,OAAO;IACxC,I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AQ,KAAK/C,YAC1B,CAAC,IACD;QAAE+C,UAAU1D,aAAa0D,QAAQ;IAAC,GAClC1D,aAAasF,IAAI,KAAK3E,YAAY,CAAC,IAAI;QAAE2E,MAAMtF,aAAasF,IAAI;IAAC,GACjEtF,aAAauF,YAAY,KAAK5E,YAC9B,CAAC,IACD;QAAE4E,cAAcvF,aAAauF,YAAY;IAAC;QAC9CjE,MAAM,GAAEtB,uBAAAA,aAAasB,MAAM,YAAnBtB,uBAAuB;OAC3BC,SAAS,aAAa;QAAEuF,cAAc;IAAgB,IAAI,CAAC,GAC3DxF,aAAaqC,UAAU,KAAK1B,YAC5B,CAAC,IACD;QAAE0B,YAAYrC,aAAaqC,UAAU;IAAC;AAE9C;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASoD,sBACdC,iBAA4C,EAC5ChB,MAAgB;IAEhB,MAAMiB,OAAO,IAAIC;IACjBxB,oBAAoBtF,qBAAqB4G;IACzClE,sBAAsB1C,qBAAqB4G;IAE3C,MAAM3E,cAAcjC,qBAAqB4G,mBACtC/D,MAAM,CAAC3B,CAAAA;QACN,IAAIA,aAAasE,MAAM,IAAItE,aAAa6F,IAAI,KAAK,UAAU,OAAO;QAClE,MAAMtG,OAAOgB,OAAOP,aAAaT,IAAI;QACrC,IAAIoG,KAAKG,GAAG,CAACvG,OAAO,OAAO;QAC3BoG,KAAKI,GAAG,CAACxG;QACT,OAAO;IACT,GACC4E,GAAG,CAAC,CAACnE,cAAcyE,QAClBD,aAAakB,mBAAmB1F,cAAcyE,OAAOC,SAEtDsB,IAAI,CAAC,CAACC,MAAMC,QAAUD,KAAKjB,KAAK,GAAGkB,MAAMlB,KAAK;IACjDlE,gBAAgBC;IAChB8C,sBAAsB9C;IACtBiD,gBAAgBjD;IAChB6B,kBAAkB8C,mBAAmB3E;IACrC,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../../src/entity-definition/describe/describe-entity-columns.ts"],"sourcesContent":["import { MAX_SCALE } from '../../i18n/scaled-number.js';\nimport { extractMetaAccessors, findMetaEntity } from '../helpers/index.js';\nimport { EntityCollectionLink } from '../links/entity-collection-link/index.js';\nimport { EntityLink } from '../links/entity-link/index.js';\nimport { assertBounds } from '../meta-entities/bounds.js';\nimport {\n type CardRole,\n type ChildConstructor,\n type EntityLinkSerialization,\n type EnumTone,\n EnumTones,\n type MemberReference,\n MetaAccessor,\n MetaAccessorType,\n type MoneyFormat,\n type ScaledFormat,\n} from '../meta-entities/meta-accessor/index.js';\n\n/**\n * A displayable member of an entity, resolved from its accessor metadata. This\n * is the contract generic UI builds itself from — a table's columns today, a\n * form's fields later — so it stays framework-free and lives next to the\n * metadata it derives from.\n */\nexport interface EntityFieldDescriptor {\n /** Accessor name. The stable identity used by preferences and slots. */\n name: string;\n /** Wire/property key: `alias ?? name`. */\n key: string;\n label: string;\n /**\n * Catalog key for {@link label}, when the entity declared one. Resolution is\n * the presentation layer's job — core has no locale and no catalogs, and the\n * same descriptor feeds the server-side filter allowlist, where a translated\n * label would be meaningless.\n */\n labelKey?: string;\n type: MetaAccessorType;\n sortable: boolean;\n filterable: boolean;\n order: number;\n /** Cannot be written back. A form shows it but disables its input. */\n readonly: boolean;\n /** Must hold a value. A form rejects submit while it is empty. */\n required: boolean;\n enumValues?: readonly string[];\n /** Catalog prefix for {@link enumValues}; a value reads as `${enumLabelKey}.${value}`. */\n enumLabelKey?: string;\n /** The tone each value reads in as a status, when the member declares them. */\n enumTones?: Readonly<Record<string, EnumTone>>;\n /** Property of a `link` target used as its display label. */\n linkLabelProperty: string;\n /** Property of a `link` target a picker searches on. Defaults to the label. */\n linkSearchProperty: string;\n /** Whether a `link` writes back its foreign key or the inlined target. */\n linkSerialization: EntityLinkSerialization;\n /**\n * The class describing one row of a `composition` member, resolved from the\n * accessor's thunk. Absent on every other type.\n */\n childType?: ChildConstructor;\n /**\n * The member is dropped when the record is copied — a unique code, an audit\n * stamp. The identity member is always reset and is not flagged.\n */\n resetOnClone: boolean;\n /** The fewest values a collection member may hold. */\n minItems?: number;\n /** The most values a collection member may hold. */\n maxItems?: number;\n /** The `date` member this one may not precede. */\n notBefore?: string;\n /** The member is an amount of money, read as this declares. `number` members only. */\n money?: MoneyFormat;\n /** The member is a scaled integer, read as this declares. `number` members only. */\n scaled?: ScaledFormat;\n /** The narrowest the member's column reads at, in `rem`, when declared. */\n minWidth?: number;\n /** The part the member plays on a record's card, when declared. */\n card?: CardRole;\n /** The member's HTML autofill token, when declared. */\n autocomplete?: string;\n /** This member holds the parent record's id: the entity forms a tree. */\n parent?: boolean;\n /**\n * This member holds the id of a record of another entity, named `domain:key`.\n * A screen shows that record's name in its place.\n */\n references?: MemberReference;\n /**\n * `'none'`: the member travels with the record and is never shown — a form\n * keeps it in its draft without a field, a table without a column. Today\n * only a `revision` member presents as nothing.\n */\n presentation?: 'none';\n}\n\n/** Types whose values are scalars a user can meaningfully sort/filter on. */\nexport const SCALAR_TYPES: readonly MetaAccessorType[] = [\n 'string',\n 'number',\n 'boolean',\n 'date',\n 'enum',\n];\n\n/**\n * Types whose value is a collection. None of them may ever be sorted or\n * filtered: this descriptor is also the **server-side RSQL allowlist**, and an\n * array compared as a scalar matches nothing — so the query would not fail, it\n * would quietly return an empty page.\n *\n * Exported so `describe-entity-columns.spec.ts` can assert that this list,\n * {@link SCALAR_TYPES}, the two reference types and `localized` partition\n * `MetaAccessorTypes` exactly. Nothing in the repo guards `MetaAccessorType`\n * exhaustively — every switch over it has a `default` that treats the value as\n * a string — so that partition spec is what makes an eleventh type impossible\n * to add silently.\n */\nexport const COLLECTION_TYPES: readonly MetaAccessorType[] = [\n 'linkCollection',\n 'composition',\n 'scalarCollection',\n];\n\n/** `productCode` / `product-code` / `product_code` → `Product Code`. */\nfunction humanize(name: string): string {\n return name\n .replace(/[-_]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/\\s+/g, ' ')\n .trim()\n .replace(/^./, first => first.toUpperCase());\n}\n\n/**\n * Best-effort type for accessors that did not declare one. Entities are not\n * required to annotate every member, so a sample row keeps a bare `@accessor()`\n * usable; a declared `type` always wins over this.\n */\nfunction inferType(name: string, value: unknown): MetaAccessorType {\n if (value instanceof EntityLink) return 'link';\n if (value instanceof EntityCollectionLink) return 'linkCollection';\n if (value instanceof Date) return 'date';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (name === 'id') return 'id';\n return 'string';\n}\n\n/**\n * A collection member declared sortable is always a mistake, and so is a link\n * or composition collection declared filterable — only a `scalarCollection`\n * may be filtered, an equality on it meaning \"any element matches\". The\n * mistake breaks the developer rather than the query — the same posture as `applyEntityLinks`\n * throwing on an `embedded` link it cannot build.\n *\n * Silently clamping to `false` was the alternative and is worse: the author\n * keeps a declaration that reads as honoured, and the symptom is an empty\n * result page rather than an error anyone can act on.\n */\nfunction assertNotQueryable(\n metaAccessor: MetaAccessor,\n type: MetaAccessorType,\n) {\n if (!COLLECTION_TYPES.includes(type)) return;\n // An array of scalars may be filtered (an equality means \"any element\n // matches\"); sortable stays forbidden for every collection, and a link or\n // composition collection is not filterable either.\n const queryableFilter =\n type !== 'scalarCollection' && metaAccessor.filterable === true;\n if (metaAccessor.sortable !== true && !queryableFilter) return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" is a ${type} and cannot be sortable, and only a scalarCollection may be filterable — member metadata is the server-side query allowlist, and a collection compared as a scalar matches nothing.`,\n );\n}\n\n/**\n * Item counts belong to a collection, and must be counts. A `minItems` on a\n * string would read as honoured and constrain nothing.\n */\nfunction assertItemCounts(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n const { minItems, maxItems } = metaAccessor;\n if (minItems === undefined && maxItems === undefined) return;\n const name = String(metaAccessor.name);\n if (!COLLECTION_TYPES.includes(type)) {\n throw new Error(\n `\"${name}\" is a ${type}, and only a collection can declare minItems or maxItems.`,\n );\n }\n assertBounds(`\"${name}\"`, { min: minItems, max: maxItems });\n}\n\n/**\n * `notBefore` compares two instants, so both ends must be `date` members of\n * the same entity. Checked once every member is described, since the one it\n * names may be declared after it.\n */\nfunction assertNotBefore(descriptors: readonly EntityFieldDescriptor[]) {\n for (const descriptor of descriptors) {\n if (descriptor.notBefore === undefined) continue;\n const earlier = descriptors.find(\n other => other.name === descriptor.notBefore,\n );\n if (descriptor.type !== 'date' || earlier?.type !== 'date') {\n throw new Error(\n `\"${descriptor.name}\" declares notBefore \"${descriptor.notBefore}\", and both must be date members of the entity.`,\n );\n }\n }\n}\n\n/**\n * A parent is one record's id, so it is an `id` or a `string` member — a\n * number or a date cannot name a record, and a collection would be two\n * parents. Checked per member, since the type is only known once inferred.\n */\nfunction assertParentType(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n if (metaAccessor.parent !== true) return;\n if (type === 'id' || type === 'string') return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" is a ${type} and cannot be the parent member — a parent is one record's id, so it is an id or a string.`,\n );\n}\n\n/** The one name a revision member may have: the wire key is part of the contract. */\nexport const REVISION_MEMBER = 'revision';\n\n/**\n * A revision is the store's, not the author's: it is one number named\n * `revision` that every save carries and no query uses, so it cannot be\n * renamed, required, queried, hidden (it would not be serialized) or\n * `readonly` (the same). One name makes one member, so an entity has one at\n * most. Checked against every\n * accessor before hidden ones are dropped, since a hidden revision is exactly\n * the one describing would never see.\n */\nfunction assertRevisionMembers(members: readonly MetaAccessor[]) {\n const revisions = members.filter(member => member.type === 'revision');\n for (const member of revisions) {\n const name = String(member.name);\n if (name !== REVISION_MEMBER || member.alias !== undefined) {\n throw new Error(\n `\"${name}\" is a revision member and must be named \"${REVISION_MEMBER}\", with no alias — the wire key is part of the contract.`,\n );\n }\n for (const flag of [\n 'required',\n 'filterable',\n 'sortable',\n 'hidden',\n 'readonly',\n ] as const) {\n if (member[flag] === true) {\n throw new Error(\n `\"${name}\" is a revision member and cannot be ${flag} — it travels with every record and is never queried or entered.`,\n );\n }\n }\n }\n}\n\n/** A composition's child has no save of its own, so it carries no revision. */\nfunction assertChildHasNoRevision(child: ChildConstructor) {\n if (extractMetaAccessors(child).some(member => member.type === 'revision')) {\n throw new Error(\n `${child.name} is the child of a composition and declares a revision member — a child has no save of its own, so its master's revision covers it.`,\n );\n }\n}\n\n/** A reference's entity, as `@entity({ domain, key })` names it: two kebab-case words. */\nconst REFERENCE_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * A reference holds one record's id, so it is an `id` or a `string` member, and\n * names its target as `domain:key`. On the `parent` member it may only name the\n * entity itself — a parent is a record of the same entity, built into a tree —\n * which is what lets a list show a branch's parent by name.\n */\nfunction assertReference(\n target: ChildConstructor,\n metaAccessor: MetaAccessor,\n type: MetaAccessorType,\n) {\n const { references } = metaAccessor;\n if (references === undefined) return;\n const name = String(metaAccessor.name);\n if (type !== 'id' && type !== 'string') {\n throw new Error(\n `\"${name}\" is a ${type} and declares references — a reference holds one record's id, so it is an id or a string.`,\n );\n }\n if (!REFERENCE_KEY.test(references.entity)) {\n throw new Error(\n `\"${name}\" references \"${references.entity}\", which is not an entity's \"domain:key\" — the pair its @entity({ domain, key }) declares.`,\n );\n }\n const own = findMetaEntity(target);\n if (\n metaAccessor.parent === true &&\n references.entity !== `${own?.domain}:${own?.key}`\n ) {\n throw new Error(\n `\"${name}\" is the parent member and references \"${references.entity}\" — a parent is a record of the same entity, so it can only reference ${target.name} itself.`,\n );\n }\n}\n\n/** Members whose value can name a record: a text, a number, or a reference to one. */\nconst LABEL_TYPES: readonly MetaAccessorType[] = [\n 'string',\n 'number',\n 'localized',\n];\n\n/**\n * An entity's `labelMember` must be a visible member that holds one value a\n * person can read: a hidden one never reaches the client, and a collection is\n * many names. Checked against every accessor, since a hidden member is exactly\n * the one describing would never see.\n */\nfunction assertLabelMember(\n target: ChildConstructor,\n descriptors: readonly EntityFieldDescriptor[],\n) {\n const labelMember = findMetaEntity(target)?.labelMember;\n if (labelMember === undefined) return;\n const declared = extractMetaAccessors(target).some(\n metaAccessor => String(metaAccessor.name) === labelMember,\n );\n const descriptor = descriptors.find(other => other.name === labelMember);\n if (descriptor === undefined) {\n throw new Error(\n declared\n ? `${target.name} is called by \"${labelMember}\", which is hidden — a hidden member never reaches the client, so nothing could show the name.`\n : `${target.name} is called by \"${labelMember}\", which is not a member of the entity.`,\n );\n }\n if (\n descriptor.references === undefined &&\n !LABEL_TYPES.includes(descriptor.type)\n ) {\n throw new Error(\n `${target.name} is called by \"${labelMember}\", a ${descriptor.type} — a record is called by a string, a localized text, a number or a reference.`,\n );\n }\n}\n\n/** Money is a reading of a number; any other member declaring it is a mistake. */\nfunction assertMoneyType(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n if (metaAccessor.money === undefined || type === 'number') return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" is a ${type} and declares money — only a number member can be an amount.`,\n );\n}\n\n/**\n * A scale is a count of decimals on a number that is not money — money has\n * its currency's.\n */\nfunction assertScaled(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n const { scaled } = metaAccessor;\n if (scaled === undefined) return;\n const name = String(metaAccessor.name);\n if (type !== 'number') {\n throw new Error(\n `\"${name}\" is a ${type} and declares scaled — only a number member can be a scaled integer.`,\n );\n }\n if (metaAccessor.money !== undefined) {\n throw new Error(\n `\"${name}\" declares money and scaled — an amount's decimals are its currency's.`,\n );\n }\n const scales =\n scaled.units === undefined ? [scaled.scale] : Object.values(scaled.units);\n const valid = (scale: number) =>\n Number.isInteger(scale) && scale >= 0 && scale <= MAX_SCALE;\n if (scales.length === 0 || !scales.every(valid)) {\n throw new Error(\n `\"${name}\" declares scales [${scales.join(', ')}] — at least one, each a whole number of decimals from 0 to ${String(MAX_SCALE)}.`,\n );\n }\n}\n\n/**\n * Tones belong to an enum's values: on any other member, or keyed by a value\n * the enum does not have, they would colour nothing — or the wrong thing.\n */\nfunction assertEnumTones(metaAccessor: MetaAccessor, type: MetaAccessorType) {\n const { enumTones } = metaAccessor;\n if (enumTones === undefined) return;\n const name = String(metaAccessor.name);\n if (type !== 'enum') {\n throw new Error(\n `\"${name}\" is a ${type} and declares enumTones — only an enum member's values have a tone.`,\n );\n }\n const values = metaAccessor.enumValues ?? [];\n for (const [value, tone] of Object.entries(enumTones)) {\n if (!values.includes(value)) {\n throw new Error(\n `\"${name}\" declares a tone for \"${value}\", which is not one of its enumValues (${values.join(', ')}).`,\n );\n }\n if (!(EnumTones as readonly string[]).includes(tone)) {\n throw new Error(\n `\"${name}\" declares tone \"${String(tone)}\" for \"${value}\" — a tone is one of ${EnumTones.join(', ')}.`,\n );\n }\n }\n}\n\n/** A width is a positive length; zero or less would never switch layouts. */\nfunction assertMinWidth(metaAccessor: MetaAccessor) {\n const { minWidth } = metaAccessor;\n if (minWidth === undefined || (Number.isFinite(minWidth) && minWidth > 0))\n return;\n throw new Error(\n `\"${String(metaAccessor.name)}\" declares minWidth ${String(minWidth)} — a column's narrowest width is a positive number of rem.`,\n );\n}\n\n/**\n * A `currencyMember` must be a visible `string` member of the same entity: a\n * hidden one never reaches the client, so the amount would print with no\n * currency and nothing would say why.\n */\nfunction assertCurrencyMembers(descriptors: readonly EntityFieldDescriptor[]) {\n for (const descriptor of descriptors) {\n const member = descriptor.money?.currencyMember;\n if (member === undefined) continue;\n const currency = descriptors.find(other => other.name === member);\n if (currency?.type !== 'string') {\n throw new Error(\n `\"${descriptor.name}\" reads its currency from \"${member}\", which must be a visible string member of the entity.`,\n );\n }\n }\n}\n\n/**\n * A `unitMember` must be a visible `string` or `enum` member of the same\n * entity: without it the integer would print a thousand times what it means.\n */\nfunction assertUnitMembers(descriptors: readonly EntityFieldDescriptor[]) {\n for (const descriptor of descriptors) {\n const member = descriptor.scaled?.unitMember;\n if (member === undefined) continue;\n const unit = descriptors.find(other => other.name === member);\n if (unit?.type !== 'string' && unit?.type !== 'enum') {\n throw new Error(\n `\"${descriptor.name}\" reads its unit from \"${member}\", which must be a visible string or enum member of the entity.`,\n );\n }\n }\n}\n\n/**\n * One parent member per entity. Two would be two trees over the same records,\n * and which one a table indents by would depend on declaration order.\n */\nexport function assertOneParent(\n members: readonly {\n readonly name: string | symbol;\n readonly parent?: boolean;\n }[],\n) {\n const parents = members.filter(member => member.parent === true);\n if (parents.length > 1) {\n throw new Error(\n `An entity declares one parent member at most; found ${parents.map(member => `\"${String(member.name)}\"`).join(', ')}.`,\n );\n }\n}\n\n/**\n * ⚠️ **A parent member must travel.** The serializer skips a `hidden` or\n * `readonly` member in both directions, so the parent key would not survive a\n * single trip over the wire and the tree would arrive flat, with nothing\n * failing. Hide it from a table or a form with a slot instead. Checked before\n * hidden members are dropped, since a hidden parent is exactly the one\n * describing would never see.\n */\nexport function assertParentVisible(\n members: readonly {\n readonly name: string | symbol;\n readonly parent?: boolean;\n readonly hidden?: boolean;\n readonly readonly?: boolean;\n }[],\n) {\n const stuck = members.find(\n member =>\n member.parent === true &&\n (member.hidden === true || member.readonly === true),\n );\n if (stuck === undefined) return;\n throw new Error(\n `\"${String(stuck.name)}\" is the parent member and is ${stuck.hidden === true ? 'hidden' : 'readonly'} — such a member is never serialized, so the tree would arrive flat. Hide it with a slot instead.`,\n );\n}\n\nfunction toDescriptor(\n target: ChildConstructor,\n metaAccessor: MetaAccessor,\n index: number,\n sample: unknown,\n): EntityFieldDescriptor {\n const name = String(metaAccessor.name);\n const type =\n metaAccessor.type ??\n inferType(name, (sample as Record<string, unknown> | undefined)?.[name]);\n assertNotQueryable(metaAccessor, type);\n assertItemCounts(metaAccessor, type);\n assertParentType(metaAccessor, type);\n assertReference(target, metaAccessor, type);\n assertMoneyType(metaAccessor, type);\n assertScaled(metaAccessor, type);\n assertEnumTones(metaAccessor, type);\n assertMinWidth(metaAccessor);\n const child = type === 'composition' ? metaAccessor.childType?.() : undefined;\n if (child !== undefined) assertChildHasNoRevision(child);\n // A localized member is queried one locale at a time (`name.en`), which\n // makes it as queryable as the text each locale holds.\n const isScalar = SCALAR_TYPES.includes(type) || type === 'localized';\n const linkLabelProperty = metaAccessor.linkLabelProperty ?? 'name';\n\n return {\n name,\n key: String(metaAccessor.alias ?? metaAccessor.name),\n label: metaAccessor.label ?? humanize(name),\n labelKey: metaAccessor.labelKey,\n type,\n sortable: metaAccessor.sortable ?? isScalar,\n filterable: metaAccessor.filterable ?? isScalar,\n order: metaAccessor.order ?? index,\n readonly: metaAccessor.readonly ?? false,\n required: metaAccessor.required ?? false,\n enumValues: metaAccessor.enumValues,\n enumLabelKey: metaAccessor.enumLabelKey,\n ...(metaAccessor.enumTones === undefined\n ? {}\n : { enumTones: metaAccessor.enumTones }),\n linkLabelProperty,\n linkSearchProperty: metaAccessor.linkSearchProperty ?? linkLabelProperty,\n linkSerialization: metaAccessor.linkSerialization ?? 'id',\n childType: metaAccessor.childType?.(),\n resetOnClone: metaAccessor.resetOnClone ?? false,\n minItems: metaAccessor.minItems,\n maxItems: metaAccessor.maxItems,\n notBefore: metaAccessor.notBefore,\n ...(metaAccessor.money === undefined ? {} : { money: metaAccessor.money }),\n ...(metaAccessor.scaled === undefined\n ? {}\n : { scaled: metaAccessor.scaled }),\n ...(metaAccessor.minWidth === undefined\n ? {}\n : { minWidth: metaAccessor.minWidth }),\n ...(metaAccessor.card === undefined ? {} : { card: metaAccessor.card }),\n ...(metaAccessor.autocomplete === undefined\n ? {}\n : { autocomplete: metaAccessor.autocomplete }),\n parent: metaAccessor.parent ?? false,\n ...(type === 'revision' ? { presentation: 'none' as const } : {}),\n ...(metaAccessor.references === undefined\n ? {}\n : { references: metaAccessor.references }),\n };\n}\n\n/**\n * Resolves an entity's displayable members from its accessor metadata, sorted by\n * `order` (declaration order when undeclared).\n *\n * Getter-kind and non-`hidden` mirror the filter {@link serializeEntity} walks,\n * minus its `readonly` exclusion: a read-only member is still worth showing,\n * it just cannot be written back.\n *\n * `sample` is an optional instance used only to infer the `type` of accessors\n * that did not declare one.\n *\n * The target is a {@link ChildConstructor} rather than an `EntityConstructor`,\n * which is wider than it looks: nothing here reads `id`, and a `composition`\n * member's child is a **value** with accessors and no identity. So the same\n * walk describes an entity and describes one row of the collection it owns,\n * from one implementation.\n */\nexport function describeEntityColumns<TTarget extends object>(\n entityConstructor: ChildConstructor<TTarget>,\n sample?: TTarget,\n): EntityFieldDescriptor[] {\n const seen = new Set<string>();\n assertParentVisible(extractMetaAccessors(entityConstructor));\n assertRevisionMembers(extractMetaAccessors(entityConstructor));\n\n const descriptors = extractMetaAccessors(entityConstructor)\n .filter(metaAccessor => {\n if (metaAccessor.hidden || metaAccessor.kind !== 'getter') return false;\n const name = String(metaAccessor.name);\n if (seen.has(name)) return false;\n seen.add(name);\n return true;\n })\n .map((metaAccessor, index) =>\n toDescriptor(entityConstructor, metaAccessor, index, sample),\n )\n .sort((left, right) => left.order - right.order);\n assertNotBefore(descriptors);\n assertCurrencyMembers(descriptors);\n assertUnitMembers(descriptors);\n assertOneParent(descriptors);\n assertLabelMember(entityConstructor, descriptors);\n return descriptors;\n}\n"],"names":["MAX_SCALE","extractMetaAccessors","findMetaEntity","EntityCollectionLink","EntityLink","assertBounds","EnumTones","SCALAR_TYPES","COLLECTION_TYPES","humanize","name","replace","trim","first","toUpperCase","inferType","value","Date","assertNotQueryable","metaAccessor","type","includes","queryableFilter","filterable","sortable","Error","String","assertItemCounts","minItems","maxItems","undefined","min","max","assertNotBefore","descriptors","descriptor","notBefore","earlier","find","other","assertParentType","parent","REVISION_MEMBER","assertRevisionMembers","members","revisions","filter","member","alias","flag","assertChildHasNoRevision","child","some","REFERENCE_KEY","assertReference","target","references","test","entity","own","domain","key","LABEL_TYPES","assertLabelMember","labelMember","declared","assertMoneyType","money","assertScaled","scaled","scales","units","scale","Object","values","valid","Number","isInteger","length","every","join","assertEnumTones","enumTones","enumValues","tone","entries","assertMinWidth","minWidth","isFinite","assertCurrencyMembers","currencyMember","currency","assertUnitMembers","unitMember","unit","assertOneParent","parents","map","assertParentVisible","stuck","hidden","readonly","toDescriptor","index","sample","childType","isScalar","linkLabelProperty","label","labelKey","order","required","enumLabelKey","linkSearchProperty","linkSerialization","resetOnClone","card","autocomplete","presentation","describeEntityColumns","entityConstructor","seen","Set","kind","has","add","sort","left","right"],"mappings":";AAAA,SAASA,SAAS,QAAQ,8BAA8B;AACxD,SAASC,oBAAoB,EAAEC,cAAc,QAAQ,sBAAsB;AAC3E,SAASC,oBAAoB,QAAQ,2CAA2C;AAChF,SAASC,UAAU,QAAQ,gCAAgC;AAC3D,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAKEC,SAAS,QAMJ,0CAA0C;AAiFjD,2EAA2E,GAC3E,OAAO,MAAMC,eAA4C;IACvD;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,mBAAgD;IAC3D;IACA;IACA;CACD,CAAC;AAEF,sEAAsE,GACtE,SAASC,SAASC,IAAY;IAC5B,OAAOA,KACJC,OAAO,CAAC,UAAU,KAClBA,OAAO,CAAC,sBAAsB,SAC9BA,OAAO,CAAC,QAAQ,KAChBC,IAAI,GACJD,OAAO,CAAC,MAAME,CAAAA,QAASA,MAAMC,WAAW;AAC7C;AAEA;;;;CAIC,GACD,SAASC,UAAUL,IAAY,EAAEM,KAAc;IAC7C,IAAIA,iBAAiBZ,YAAY,OAAO;IACxC,IAAIY,iBAAiBb,sBAAsB,OAAO;IAClD,IAAIa,iBAAiBC,MAAM,OAAO;IAClC,IAAI,OAAOD,UAAU,UAAU,OAAO;IACtC,IAAI,OAAOA,UAAU,WAAW,OAAO;IACvC,IAAIN,SAAS,MAAM,OAAO;IAC1B,OAAO;AACT;AAEA;;;;;;;;;;CAUC,GACD,SAASQ,mBACPC,YAA0B,EAC1BC,IAAsB;IAEtB,IAAI,CAACZ,iBAAiBa,QAAQ,CAACD,OAAO;IACtC,sEAAsE;IACtE,0EAA0E;IAC1E,mDAAmD;IACnD,MAAME,kBACJF,SAAS,sBAAsBD,aAAaI,UAAU,KAAK;IAC7D,IAAIJ,aAAaK,QAAQ,KAAK,QAAQ,CAACF,iBAAiB;IACxD,MAAM,IAAIG,MACR,CAAC,CAA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aAAa;QAAEkG,cAAc;IAAgB,IAAI,CAAC,GAC3DnG,aAAaqC,UAAU,KAAK1B,YAC5B,CAAC,IACD;QAAE0B,YAAYrC,aAAaqC,UAAU;IAAC;AAE9C;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAAS+D,sBACdC,iBAA4C,EAC5ChB,MAAgB;IAEhB,MAAMiB,OAAO,IAAIC;IACjBxB,oBAAoBjG,qBAAqBuH;IACzC7E,sBAAsB1C,qBAAqBuH;IAE3C,MAAMtF,cAAcjC,qBAAqBuH,mBACtC1E,MAAM,CAAC3B,CAAAA;QACN,IAAIA,aAAaiF,MAAM,IAAIjF,aAAawG,IAAI,KAAK,UAAU,OAAO;QAClE,MAAMjH,OAAOgB,OAAOP,aAAaT,IAAI;QACrC,IAAI+G,KAAKG,GAAG,CAAClH,OAAO,OAAO;QAC3B+G,KAAKI,GAAG,CAACnH;QACT,OAAO;IACT,GACCuF,GAAG,CAAC,CAAC9E,cAAcoF,QAClBD,aAAakB,mBAAmBrG,cAAcoF,OAAOC,SAEtDsB,IAAI,CAAC,CAACC,MAAMC,QAAUD,KAAKjB,KAAK,GAAGkB,MAAMlB,KAAK;IACjD7E,gBAAgBC;IAChBuD,sBAAsBvD;IACtB0D,kBAAkB1D;IAClB6D,gBAAgB7D;IAChB6B,kBAAkByD,mBAAmBtF;IACrC,OAAOA;AACT"}
@@ -178,6 +178,15 @@ export interface MetaAccessorOptions {
178
178
  * form edits the major amount and writes back the stored one.
179
179
  */
180
180
  money?: MoneyFormat;
181
+ /**
182
+ * This `number` member is an integer counting a fraction of a whole —
183
+ * `3500` for 3.5 at scale 3 — and how many decimals that is: fixed, or
184
+ * decided by the unit another member of the same record holds. Presentation
185
+ * only — the member is still that integer to validation, queries and every
186
+ * adapter — so a table prints `3,5 m` rather than `3500`, and a form edits
187
+ * the decimal and writes back the integer.
188
+ */
189
+ scaled?: ScaledFormat;
181
190
  /**
182
191
  * The narrowest this member's column reads at, in `rem`. A table whose
183
192
  * visible columns no longer fit side by side becomes a list of cards, so the
@@ -227,6 +236,23 @@ export type MoneyFormat = {
227
236
  readonly currencyMember: string;
228
237
  readonly currency?: never;
229
238
  });
239
+ /**
240
+ * How a `number` member reads as a scaled integer: `scale` fixed, or
241
+ * `unitMember` naming the record's own unit member, with the scale of each
242
+ * unit in `units`. A unit is printed as its code, or as
243
+ * `<unitLabelKey>.<code>` from the host's catalog when that is declared.
244
+ */
245
+ export type ScaledFormat = {
246
+ readonly scale: number;
247
+ readonly unitMember?: never;
248
+ readonly units?: never;
249
+ readonly unitLabelKey?: never;
250
+ } | {
251
+ readonly unitMember: string;
252
+ readonly units: Readonly<Record<string, number>>;
253
+ readonly unitLabelKey?: string;
254
+ readonly scale?: never;
255
+ };
230
256
  export declare class MetaAccessor {
231
257
  readonly name: string | symbol;
232
258
  readonly kind: MetaAccessorKind;
@@ -254,6 +280,7 @@ export declare class MetaAccessor {
254
280
  readonly parent?: boolean;
255
281
  readonly references?: MemberReference;
256
282
  readonly money?: MoneyFormat;
283
+ readonly scaled?: ScaledFormat;
257
284
  readonly minWidth?: number;
258
285
  readonly card?: CardRole;
259
286
  readonly autocomplete?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"meta-accessor.d.ts","sourceRoot":"","sources":["../../../../src/entity-definition/meta-entities/meta-accessor/meta-accessor.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,sJAapB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,KAI7D,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,MAAM,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,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AAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAM7B,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,IAAI,EAAE,gBAAgB,EACtB,OAAO,CAAC,EAAE,mBAAmB;CAwChC"}
@@ -71,6 +71,7 @@ export class MetaAccessor {
71
71
  this.parent = options == null ? void 0 : options.parent;
72
72
  this.references = options == null ? void 0 : options.references;
73
73
  this.money = options == null ? void 0 : options.money;
74
+ this.scaled = options == null ? void 0 : options.scaled;
74
75
  this.minWidth = options == null ? void 0 : options.minWidth;
75
76
  this.card = options == null ? void 0 : options.card;
76
77
  this.autocomplete = options == null ? void 0 : options.autocomplete;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/entity-definition/meta-entities/meta-accessor/meta-accessor.ts"],"sourcesContent":["export type MetaAccessorKind = 'getter' | 'setter';\n\n/**\n * The kinds of value an accessor can hold, as far as generic UI and adapters\n * care. It is deliberately a presentation/behaviour taxonomy rather than a\n * TypeScript mirror: `id` and `enum` are strings at runtime but are rendered,\n * sorted and filtered differently.\n *\n * `revision` is a number the store owns: the version of the record a save read\n * (ADR 0032). It travels in the body, and presents as nothing.\n *\n * `localized` holds a text per locale (`LocalizedText`). It is queried only\n * through one locale at a time — `name.en` — never as the whole object.\n */\nexport const MetaAccessorTypes = [\n 'string',\n 'number',\n 'boolean',\n 'date',\n 'enum',\n 'id',\n 'link',\n 'linkCollection',\n 'composition',\n 'scalarCollection',\n 'localized',\n 'revision',\n] as const;\nexport type MetaAccessorType = (typeof MetaAccessorTypes)[number];\n\n/**\n * The class whose accessors describe one row of a `composition` member.\n *\n * Deliberately not `EntityConstructor`: a child of a composition is a **value**,\n * not an entity. It has no identity of its own, is never addressed apart from\n * the master that holds it, and therefore has no `id` for `Entity` to require.\n * What it does have is `@accessor()` metadata, which is written to its own\n * class's `Symbol.metadata` bag independently of `@entity()` — so a child is\n * described by its accessors and by nothing else.\n *\n * ⚠️ It is a **shape declaration, not a runtime constructor contract.** Children\n * arrive off the wire as plain objects — the serializer walks `instanceof\n * EntityLink`, not the declared type, so an embedded array passes straight\n * through — and an autosaved draft may hold nothing that does not survive a\n * JSON round trip anyway. Nothing may branch on `instanceof` against this constructor.\n */\nexport type ChildConstructor<TChild extends object = object> = new (\n // Mirrors `EntityConstructor`: the arguments are the child's business, only\n // the class identity matters here.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: any[]\n) => TChild;\n\n/**\n * The wire shape a relation takes: the target's foreign key, or the whole\n * target inlined. Declared here rather than next to `EntityLink` because it is\n * metadata about a member, not state of a link instance.\n */\nexport const EntityLinkSerializations = ['id', 'embedded'] as const;\nexport type EntityLinkSerialization = (typeof EntityLinkSerializations)[number];\n\nexport interface MetaAccessorOptions {\n alias?: string;\n type?: MetaAccessorType;\n readonly?: boolean;\n hidden?: boolean;\n /** Member must hold a value. Drives form validation; defaults to optional. */\n required?: boolean;\n /** Human label for UI. Falls back to a humanized `name`. */\n label?: string;\n /**\n * Translation key for the label, resolved by the presentation layer. Takes\n * precedence over `label`, which stays as the untranslated fallback for a\n * member that has no catalog entry yet.\n *\n * Keys mirror the entity's own `@entity({ key })`, so they are derivable\n * rather than invented: `entity:product-specification.fields.code`.\n */\n labelKey?: string;\n /** Opt in/out of sorting controls. Defaults per `type`. */\n sortable?: boolean;\n /** Opt in/out of filtering controls. Defaults per `type`. */\n filterable?: boolean;\n /** Default position among the entity's members; ties keep declaration order. */\n order?: number;\n /** Allowed values when `type` is `enum` — drives the filter value control. */\n enumValues?: readonly string[];\n /**\n * Catalog prefix for those values; a value's label is `${enumLabelKey}.${value}`.\n * Explicit rather than derived from `labelKey`, so a member whose values are\n * shared with another member can point both at one vocabulary.\n */\n enumLabelKey?: string;\n /**\n * The tone each value reads in where it is shown as a status: `success`,\n * `warning`, `danger`, `info` or `neutral`. Legal only on an `enum` member,\n * and every key must be one of its {@link enumValues}; a value left out reads\n * `neutral`. Declared, a screen shows the value as a tag in that tone beside\n * its words; undeclared, the value stays plain text — not every enum is a\n * status. Presentation only.\n */\n enumTones?: Readonly<Record<string, EnumTone>>;\n /** Property of a `link` target used as its display label. Default `name`. */\n linkLabelProperty?: string;\n /**\n * Property of a `link` target a picker searches on. Defaults to\n * {@link linkLabelProperty} — you search for what you read. It must be\n * `filterable` on the target entity, since member metadata is also the\n * server-side filter allowlist.\n */\n linkSearchProperty?: string;\n /**\n * How a `link` travels when its owner is serialized: as the target's scalar\n * foreign key (`id`, the default) or with the whole target inlined\n * (`embedded`). The serializer decides per *link instance* — it inlines\n * whatever `isLoaded` — so without this the shape a write takes would depend\n * on whether the form happened to hold the target. Declaring it on the entity\n * makes the wire shape a property of the relation instead of an accident of\n * the UI.\n */\n linkSerialization?: EntityLinkSerialization;\n /**\n * The class describing one row of a `composition` member — the child's own\n * `@accessor()` metadata is what a detail grid renders its columns from.\n *\n * A **thunk**, because a child module and the entity that owns it are usually\n * declared in the same package and a direct reference makes the decorator's\n * evaluation order load-bearing. Deferring the read to first use removes the\n * ordering question entirely, which is the same reason a to-one relation's\n * target is reached through a resolver rather than an import.\n *\n * Meaningless on any other type. There is no inference fallback: an empty\n * array cannot be told apart from an empty `string[]` at runtime, so a\n * collection must be declared.\n */\n childType?: () => ChildConstructor;\n /**\n * Reset this member when the record is copied.\n *\n * It lives on the **accessor**, not on a use case's descriptor, and that is a\n * decision already made: `UseCaseDescriptor` is closed against per-verb\n * payloads, and this is the exact case, because a descriptor that\n * grows a field per verb ends up a union of every verb's arguments. Which\n * members a copy must not carry is a property of the *member* — a unique\n * code, an audit stamp, a sequence number — and it is the same answer however\n * the copy is triggered.\n *\n * The identity member is always reset and needs no flag.\n */\n resetOnClone?: boolean;\n /**\n * The fewest values a collection member may hold — `1` for \"not empty\". Only\n * meaningful on a collection type (`scalarCollection`, `linkCollection`,\n * `composition`); declaring it elsewhere fails when the entity is described.\n *\n * Distinct from {@link required}: on a collection `required` already means\n * \"at least one\", and a `minItems` of two is a fact `required` cannot state.\n */\n minItems?: number;\n /** The most values a collection member may hold. Collection types only. */\n maxItems?: number;\n /**\n * Another `date` member this one may not precede — a period's `end` declares\n * `notBefore: 'start'`. Checked only when both hold a value. Both members must\n * be `date`s, or describing the entity fails.\n */\n notBefore?: string;\n /**\n * This member holds the id of the record's **parent**, another record of\n * the same entity — so the entity forms a tree. At most one member per\n * entity, and it must be an `id` or a `string`; describing the entity fails\n * otherwise.\n *\n * An id rather than a `link` on purpose. A tree is always built from the\n * whole set of its records ({@link buildTree}), never by resolving one parent\n * at a time, so a link's lazy resolution would be a fetch per node that\n * nothing needs. Absent means a root.\n */\n parent?: boolean;\n /**\n * This `id` or `string` member holds the id of a record of another entity,\n * named by the `domain:key` pair that entity's `@entity({ domain, key })`\n * declares — so the declaring package imports nothing of the target's. A\n * screen reads the target's name in its place through the host's\n * `ReferenceLabelsTag` registry, rather than showing the key.\n *\n * Not a `link` on purpose: the target may live in another store, and a\n * `link` invites the storage-layer join that would couple the two, while its\n * accessor would import the target's class across a domain boundary.\n * Presentation and resolution only — to validation, queries, serialization\n * and every adapter the member is still its id.\n */\n references?: MemberReference;\n /**\n * This `number` member is an amount of money, and how to read it: its\n * currency, fixed or held by another member of the same record, and whether\n * the number counts the currency's minor units (cents) or its major ones.\n * Presentation only — the member is still a number to validation, queries\n * and every adapter — so a table prints `Q64,99` rather than `6499`, and a\n * form edits the major amount and writes back the stored one.\n */\n money?: MoneyFormat;\n /**\n * The narrowest this member's column reads at, in `rem`. A table whose\n * visible columns no longer fit side by side becomes a list of cards, so the\n * sum of these is where it switches. Undeclared, the member's type decides.\n * Presentation only.\n */\n minWidth?: number;\n /**\n * The part this member plays on a record's card: its `title` — the heading\n * that links to the record — a `subtitle` under it, a `badge`, a line of\n * `meta`, or `hidden` from the card. Undeclared, the record's first\n * filled-in member is the title, an id is hidden, the first enum is the\n * badge and up to three more members are meta. Presentation only.\n */\n card?: CardRole;\n /**\n * What the member holds about the person filling it in, as an HTML autofill\n * token — `email`, `given-name`, `tel`, `street-address` — so a browser can\n * fill it and assistive tech can say what it is for (WCAG 1.3.5).\n * Presentation only.\n */\n autocomplete?: string;\n}\n\n/**\n * The tone an enum value reads in as a status. Words always go beside it — a\n * tone never carries a meaning alone.\n */\nexport const EnumTones = [\n 'success',\n 'warning',\n 'danger',\n 'info',\n 'neutral',\n] as const;\nexport type EnumTone = (typeof EnumTones)[number];\n\n/** The entity a reference member points at, as `domain:key`. */\nexport interface MemberReference {\n readonly entity: string;\n}\n\n/** The part a member plays on a record's card. */\nexport type CardRole = 'title' | 'subtitle' | 'badge' | 'meta' | 'hidden';\n\n/**\n * How a `number` member reads as money: `currency` fixed, or\n * `currencyMember` naming the record's own ISO 4217 code member; `unit`\n * whether the stored number counts minor units (`6499` for 64.99) or major.\n */\nexport type MoneyFormat = { readonly unit: 'minor' | 'major' } & (\n | { readonly currency: string; readonly currencyMember?: never }\n | { readonly currencyMember: string; readonly currency?: never }\n);\n\nexport class MetaAccessor {\n //#region Properties\n\n readonly name: string | symbol;\n readonly kind: MetaAccessorKind;\n readonly alias?: string;\n readonly type?: MetaAccessorType;\n readonly readonly?: boolean;\n readonly hidden?: boolean;\n readonly required?: boolean;\n readonly label?: string;\n readonly labelKey?: string;\n readonly sortable?: boolean;\n readonly filterable?: boolean;\n readonly order?: number;\n readonly enumValues?: readonly string[];\n readonly enumLabelKey?: string;\n readonly enumTones?: Readonly<Record<string, EnumTone>>;\n readonly linkLabelProperty?: string;\n readonly linkSearchProperty?: string;\n readonly linkSerialization?: EntityLinkSerialization;\n readonly childType?: () => ChildConstructor;\n readonly resetOnClone?: boolean;\n readonly minItems?: number;\n readonly maxItems?: number;\n readonly notBefore?: string;\n readonly parent?: boolean;\n readonly references?: MemberReference;\n readonly money?: MoneyFormat;\n readonly minWidth?: number;\n readonly card?: CardRole;\n readonly autocomplete?: string;\n\n //#endregion\n\n //#region Constructors\n constructor(\n name: string | symbol,\n kind: MetaAccessorKind,\n options?: MetaAccessorOptions,\n ) {\n this.name = name;\n this.kind = kind;\n this.alias = options?.alias;\n this.type = options?.type;\n this.readonly = options?.readonly;\n this.hidden = options?.hidden;\n this.required = options?.required;\n this.label = options?.label;\n this.labelKey = options?.labelKey;\n this.sortable = options?.sortable;\n this.filterable = options?.filterable;\n this.order = options?.order;\n this.enumValues = options?.enumValues;\n this.enumLabelKey = options?.enumLabelKey;\n this.enumTones = options?.enumTones;\n this.linkLabelProperty = options?.linkLabelProperty;\n this.linkSearchProperty = options?.linkSearchProperty;\n this.linkSerialization = options?.linkSerialization;\n this.childType = options?.childType;\n this.resetOnClone = options?.resetOnClone;\n this.minItems = options?.minItems;\n this.maxItems = options?.maxItems;\n this.notBefore = options?.notBefore;\n this.parent = options?.parent;\n this.references = options?.references;\n this.money = options?.money;\n this.minWidth = options?.minWidth;\n this.card = options?.card;\n this.autocomplete = options?.autocomplete;\n }\n //#endregion\n\n //#region Methods\n //#endregion\n\n //#region Accessors\n //#endregion\n}\n"],"names":["MetaAccessorTypes","EntityLinkSerializations","EnumTones","MetaAccessor","name","kind","options","alias","type","readonly","hidden","required","label","labelKey","sortable","filterable","order","enumValues","enumLabelKey","enumTones","linkLabelProperty","linkSearchProperty","linkSerialization","childType","resetOnClone","minItems","maxItems","notBefore","parent","references","money","minWidth","card","autocomplete"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,OAAO,MAAMA,oBAAoB;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AA0BX;;;;CAIC,GACD,OAAO,MAAMC,2BAA2B;IAAC;IAAM;CAAW,CAAU;AAwKpE;;;CAGC,GACD,OAAO,MAAMC,YAAY;IACvB;IACA;IACA;IACA;IAC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GAAGpB,2BAAAA,QAASoB,QAAQ;QACjC,IAAI,CAACC,SAAS,GAAGrB,2BAAAA,QAASqB,SAAS;QACnC,IAAI,CAACC,MAAM,GAAGtB,2BAAAA,QAASsB,MAAM;QAC7B,IAAI,CAACC,UAAU,GAAGvB,2BAAAA,QAASuB,UAAU;QACrC,IAAI,CAACC,KAAK,GAAGxB,2BAAAA,QAASwB,KAAK;QAC3B,IAAI,CAACC,QAAQ,GAAGzB,2BAAAA,QAASyB,QAAQ;QACjC,IAAI,CAACC,IAAI,GAAG1B,2BAAAA,QAAS0B,IAAI;QACzB,IAAI,CAACC,YAAY,GAAG3B,2BAAAA,QAAS2B,YAAY;IAC3C;AAQF"}
1
+ {"version":3,"sources":["../../../../src/entity-definition/meta-entities/meta-accessor/meta-accessor.ts"],"sourcesContent":["export type MetaAccessorKind = 'getter' | 'setter';\n\n/**\n * The kinds of value an accessor can hold, as far as generic UI and adapters\n * care. It is deliberately a presentation/behaviour taxonomy rather than a\n * TypeScript mirror: `id` and `enum` are strings at runtime but are rendered,\n * sorted and filtered differently.\n *\n * `revision` is a number the store owns: the version of the record a save read\n * (ADR 0032). It travels in the body, and presents as nothing.\n *\n * `localized` holds a text per locale (`LocalizedText`). It is queried only\n * through one locale at a time — `name.en` — never as the whole object.\n */\nexport const MetaAccessorTypes = [\n 'string',\n 'number',\n 'boolean',\n 'date',\n 'enum',\n 'id',\n 'link',\n 'linkCollection',\n 'composition',\n 'scalarCollection',\n 'localized',\n 'revision',\n] as const;\nexport type MetaAccessorType = (typeof MetaAccessorTypes)[number];\n\n/**\n * The class whose accessors describe one row of a `composition` member.\n *\n * Deliberately not `EntityConstructor`: a child of a composition is a **value**,\n * not an entity. It has no identity of its own, is never addressed apart from\n * the master that holds it, and therefore has no `id` for `Entity` to require.\n * What it does have is `@accessor()` metadata, which is written to its own\n * class's `Symbol.metadata` bag independently of `@entity()` — so a child is\n * described by its accessors and by nothing else.\n *\n * ⚠️ It is a **shape declaration, not a runtime constructor contract.** Children\n * arrive off the wire as plain objects — the serializer walks `instanceof\n * EntityLink`, not the declared type, so an embedded array passes straight\n * through — and an autosaved draft may hold nothing that does not survive a\n * JSON round trip anyway. Nothing may branch on `instanceof` against this constructor.\n */\nexport type ChildConstructor<TChild extends object = object> = new (\n // Mirrors `EntityConstructor`: the arguments are the child's business, only\n // the class identity matters here.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: any[]\n) => TChild;\n\n/**\n * The wire shape a relation takes: the target's foreign key, or the whole\n * target inlined. Declared here rather than next to `EntityLink` because it is\n * metadata about a member, not state of a link instance.\n */\nexport const EntityLinkSerializations = ['id', 'embedded'] as const;\nexport type EntityLinkSerialization = (typeof EntityLinkSerializations)[number];\n\nexport interface MetaAccessorOptions {\n alias?: string;\n type?: MetaAccessorType;\n readonly?: boolean;\n hidden?: boolean;\n /** Member must hold a value. Drives form validation; defaults to optional. */\n required?: boolean;\n /** Human label for UI. Falls back to a humanized `name`. */\n label?: string;\n /**\n * Translation key for the label, resolved by the presentation layer. Takes\n * precedence over `label`, which stays as the untranslated fallback for a\n * member that has no catalog entry yet.\n *\n * Keys mirror the entity's own `@entity({ key })`, so they are derivable\n * rather than invented: `entity:product-specification.fields.code`.\n */\n labelKey?: string;\n /** Opt in/out of sorting controls. Defaults per `type`. */\n sortable?: boolean;\n /** Opt in/out of filtering controls. Defaults per `type`. */\n filterable?: boolean;\n /** Default position among the entity's members; ties keep declaration order. */\n order?: number;\n /** Allowed values when `type` is `enum` — drives the filter value control. */\n enumValues?: readonly string[];\n /**\n * Catalog prefix for those values; a value's label is `${enumLabelKey}.${value}`.\n * Explicit rather than derived from `labelKey`, so a member whose values are\n * shared with another member can point both at one vocabulary.\n */\n enumLabelKey?: string;\n /**\n * The tone each value reads in where it is shown as a status: `success`,\n * `warning`, `danger`, `info` or `neutral`. Legal only on an `enum` member,\n * and every key must be one of its {@link enumValues}; a value left out reads\n * `neutral`. Declared, a screen shows the value as a tag in that tone beside\n * its words; undeclared, the value stays plain text — not every enum is a\n * status. Presentation only.\n */\n enumTones?: Readonly<Record<string, EnumTone>>;\n /** Property of a `link` target used as its display label. Default `name`. */\n linkLabelProperty?: string;\n /**\n * Property of a `link` target a picker searches on. Defaults to\n * {@link linkLabelProperty} — you search for what you read. It must be\n * `filterable` on the target entity, since member metadata is also the\n * server-side filter allowlist.\n */\n linkSearchProperty?: string;\n /**\n * How a `link` travels when its owner is serialized: as the target's scalar\n * foreign key (`id`, the default) or with the whole target inlined\n * (`embedded`). The serializer decides per *link instance* — it inlines\n * whatever `isLoaded` — so without this the shape a write takes would depend\n * on whether the form happened to hold the target. Declaring it on the entity\n * makes the wire shape a property of the relation instead of an accident of\n * the UI.\n */\n linkSerialization?: EntityLinkSerialization;\n /**\n * The class describing one row of a `composition` member — the child's own\n * `@accessor()` metadata is what a detail grid renders its columns from.\n *\n * A **thunk**, because a child module and the entity that owns it are usually\n * declared in the same package and a direct reference makes the decorator's\n * evaluation order load-bearing. Deferring the read to first use removes the\n * ordering question entirely, which is the same reason a to-one relation's\n * target is reached through a resolver rather than an import.\n *\n * Meaningless on any other type. There is no inference fallback: an empty\n * array cannot be told apart from an empty `string[]` at runtime, so a\n * collection must be declared.\n */\n childType?: () => ChildConstructor;\n /**\n * Reset this member when the record is copied.\n *\n * It lives on the **accessor**, not on a use case's descriptor, and that is a\n * decision already made: `UseCaseDescriptor` is closed against per-verb\n * payloads, and this is the exact case, because a descriptor that\n * grows a field per verb ends up a union of every verb's arguments. Which\n * members a copy must not carry is a property of the *member* — a unique\n * code, an audit stamp, a sequence number — and it is the same answer however\n * the copy is triggered.\n *\n * The identity member is always reset and needs no flag.\n */\n resetOnClone?: boolean;\n /**\n * The fewest values a collection member may hold — `1` for \"not empty\". Only\n * meaningful on a collection type (`scalarCollection`, `linkCollection`,\n * `composition`); declaring it elsewhere fails when the entity is described.\n *\n * Distinct from {@link required}: on a collection `required` already means\n * \"at least one\", and a `minItems` of two is a fact `required` cannot state.\n */\n minItems?: number;\n /** The most values a collection member may hold. Collection types only. */\n maxItems?: number;\n /**\n * Another `date` member this one may not precede — a period's `end` declares\n * `notBefore: 'start'`. Checked only when both hold a value. Both members must\n * be `date`s, or describing the entity fails.\n */\n notBefore?: string;\n /**\n * This member holds the id of the record's **parent**, another record of\n * the same entity — so the entity forms a tree. At most one member per\n * entity, and it must be an `id` or a `string`; describing the entity fails\n * otherwise.\n *\n * An id rather than a `link` on purpose. A tree is always built from the\n * whole set of its records ({@link buildTree}), never by resolving one parent\n * at a time, so a link's lazy resolution would be a fetch per node that\n * nothing needs. Absent means a root.\n */\n parent?: boolean;\n /**\n * This `id` or `string` member holds the id of a record of another entity,\n * named by the `domain:key` pair that entity's `@entity({ domain, key })`\n * declares — so the declaring package imports nothing of the target's. A\n * screen reads the target's name in its place through the host's\n * `ReferenceLabelsTag` registry, rather than showing the key.\n *\n * Not a `link` on purpose: the target may live in another store, and a\n * `link` invites the storage-layer join that would couple the two, while its\n * accessor would import the target's class across a domain boundary.\n * Presentation and resolution only — to validation, queries, serialization\n * and every adapter the member is still its id.\n */\n references?: MemberReference;\n /**\n * This `number` member is an amount of money, and how to read it: its\n * currency, fixed or held by another member of the same record, and whether\n * the number counts the currency's minor units (cents) or its major ones.\n * Presentation only — the member is still a number to validation, queries\n * and every adapter — so a table prints `Q64,99` rather than `6499`, and a\n * form edits the major amount and writes back the stored one.\n */\n money?: MoneyFormat;\n /**\n * This `number` member is an integer counting a fraction of a whole —\n * `3500` for 3.5 at scale 3 — and how many decimals that is: fixed, or\n * decided by the unit another member of the same record holds. Presentation\n * only — the member is still that integer to validation, queries and every\n * adapter — so a table prints `3,5 m` rather than `3500`, and a form edits\n * the decimal and writes back the integer.\n */\n scaled?: ScaledFormat;\n /**\n * The narrowest this member's column reads at, in `rem`. A table whose\n * visible columns no longer fit side by side becomes a list of cards, so the\n * sum of these is where it switches. Undeclared, the member's type decides.\n * Presentation only.\n */\n minWidth?: number;\n /**\n * The part this member plays on a record's card: its `title` — the heading\n * that links to the record — a `subtitle` under it, a `badge`, a line of\n * `meta`, or `hidden` from the card. Undeclared, the record's first\n * filled-in member is the title, an id is hidden, the first enum is the\n * badge and up to three more members are meta. Presentation only.\n */\n card?: CardRole;\n /**\n * What the member holds about the person filling it in, as an HTML autofill\n * token — `email`, `given-name`, `tel`, `street-address` — so a browser can\n * fill it and assistive tech can say what it is for (WCAG 1.3.5).\n * Presentation only.\n */\n autocomplete?: string;\n}\n\n/**\n * The tone an enum value reads in as a status. Words always go beside it — a\n * tone never carries a meaning alone.\n */\nexport const EnumTones = [\n 'success',\n 'warning',\n 'danger',\n 'info',\n 'neutral',\n] as const;\nexport type EnumTone = (typeof EnumTones)[number];\n\n/** The entity a reference member points at, as `domain:key`. */\nexport interface MemberReference {\n readonly entity: string;\n}\n\n/** The part a member plays on a record's card. */\nexport type CardRole = 'title' | 'subtitle' | 'badge' | 'meta' | 'hidden';\n\n/**\n * How a `number` member reads as money: `currency` fixed, or\n * `currencyMember` naming the record's own ISO 4217 code member; `unit`\n * whether the stored number counts minor units (`6499` for 64.99) or major.\n */\nexport type MoneyFormat = { readonly unit: 'minor' | 'major' } & (\n | { readonly currency: string; readonly currencyMember?: never }\n | { readonly currencyMember: string; readonly currency?: never }\n);\n\n/**\n * How a `number` member reads as a scaled integer: `scale` fixed, or\n * `unitMember` naming the record's own unit member, with the scale of each\n * unit in `units`. A unit is printed as its code, or as\n * `<unitLabelKey>.<code>` from the host's catalog when that is declared.\n */\nexport type ScaledFormat =\n | {\n readonly scale: number;\n readonly unitMember?: never;\n readonly units?: never;\n readonly unitLabelKey?: never;\n }\n | {\n readonly unitMember: string;\n readonly units: Readonly<Record<string, number>>;\n readonly unitLabelKey?: string;\n readonly scale?: never;\n };\n\nexport class MetaAccessor {\n //#region Properties\n\n readonly name: string | symbol;\n readonly kind: MetaAccessorKind;\n readonly alias?: string;\n readonly type?: MetaAccessorType;\n readonly readonly?: boolean;\n readonly hidden?: boolean;\n readonly required?: boolean;\n readonly label?: string;\n readonly labelKey?: string;\n readonly sortable?: boolean;\n readonly filterable?: boolean;\n readonly order?: number;\n readonly enumValues?: readonly string[];\n readonly enumLabelKey?: string;\n readonly enumTones?: Readonly<Record<string, EnumTone>>;\n readonly linkLabelProperty?: string;\n readonly linkSearchProperty?: string;\n readonly linkSerialization?: EntityLinkSerialization;\n readonly childType?: () => ChildConstructor;\n readonly resetOnClone?: boolean;\n readonly minItems?: number;\n readonly maxItems?: number;\n readonly notBefore?: string;\n readonly parent?: boolean;\n readonly references?: MemberReference;\n readonly money?: MoneyFormat;\n readonly scaled?: ScaledFormat;\n readonly minWidth?: number;\n readonly card?: CardRole;\n readonly autocomplete?: string;\n\n //#endregion\n\n //#region Constructors\n constructor(\n name: string | symbol,\n kind: MetaAccessorKind,\n options?: MetaAccessorOptions,\n ) {\n this.name = name;\n this.kind = kind;\n this.alias = options?.alias;\n this.type = options?.type;\n this.readonly = options?.readonly;\n this.hidden = options?.hidden;\n this.required = options?.required;\n this.label = options?.label;\n this.labelKey = options?.labelKey;\n this.sortable = options?.sortable;\n this.filterable = options?.filterable;\n this.order = options?.order;\n this.enumValues = options?.enumValues;\n this.enumLabelKey = options?.enumLabelKey;\n this.enumTones = options?.enumTones;\n this.linkLabelProperty = options?.linkLabelProperty;\n this.linkSearchProperty = options?.linkSearchProperty;\n this.linkSerialization = options?.linkSerialization;\n this.childType = options?.childType;\n this.resetOnClone = options?.resetOnClone;\n this.minItems = options?.minItems;\n this.maxItems = options?.maxItems;\n this.notBefore = options?.notBefore;\n this.parent = options?.parent;\n this.references = options?.references;\n this.money = options?.money;\n this.scaled = options?.scaled;\n this.minWidth = options?.minWidth;\n this.card = options?.card;\n this.autocomplete = options?.autocomplete;\n }\n //#endregion\n\n //#region Methods\n //#endregion\n\n //#region Accessors\n //#endregion\n}\n"],"names":["MetaAccessorTypes","EntityLinkSerializations","EnumTones","MetaAccessor","name","kind","options","alias","type","readonly","hidden","required","label","labelKey","sortable","filterable","order","enumValues","enumLabelKey","enumTones","linkLabelProperty","linkSearchProperty","linkSerialization","childType","resetOnClone","minItems","maxItems","notBefore","parent","references","money","scaled","minWidth","card","autocomplete"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,OAAO,MAAMA,oBAAoB;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AA0BX;;;;CAIC,GACD,OAAO,MAAMC,2BAA2B;IAAC;IAAM;CAAW,CAAU;AAiLpE;;;CAGC,GACD,OAAO,MAAMC,YAAY;IACvB;IACA;IACA;IACA;IACA;CACD,CAAU;AAyCX,OAAO,MAAMC;IAkCX,YAAY;IAEZ,sBAAsB;IACtB,YACEC,IAAqB,EACrBC,IAAsB,EACtBC,OAA6B,CAC7B;QACA,IAAI,CAACF,IAAI,GAAGA;QACZ,IAAI,CAACC,IAAI,GAAGA;QACZ,IAAI,CAACE,KAAK,GAAGD,2BAAAA,QAASC,KAAK;QAC3B,IAAI,CAACC,IAAI,GAAGF,2BAAAA,QAASE,IAAI;QACzB,IAAI,CAACC,QAAQ,GAAGH,2BAAAA,QAASG,QAAQ;QACjC,IAAI,CAACC,MAAM,GAAGJ,2BAAAA,QAASI,MAAM;QAC7B,IAAI,CAACC,QAAQ,GAAGL,2BAAAA,QAASK,QAAQ;QACjC,IAAI,CAACC,KAAK,GAAGN,2BAAAA,QAASM,KAAK;QAC3B,IAAI,CAACC,QAAQ,GAAGP,2BAAAA,QAASO,QAAQ;QACjC,IAAI,CAACC,QAAQ,GAAGR,2BAAAA,QAASQ,QAAQ;QACjC,IAAI,CAACC,UAAU,GAAGT,2BAAAA,QAASS,UAAU;QACrC,IAAI,CAACC,KAAK,GAAGV,2BAAAA,QAASU,KAAK;QAC3B,IAAI,CAACC,UAAU,GAAGX,2BAAAA,QAASW,UAAU;QACrC,IAAI,CAACC,YAAY,GAAGZ,2BAAAA,QAASY,YAAY;QACzC,IAAI,CAACC,SAAS,GAAGb,2BAAAA,QAASa,SAAS;QACnC,IAAI,CAACC,iBAAiB,GAAGd,2BAAAA,QAASc,iBAAiB;QACnD,IAAI,CAACC,kBAAkB,GAAGf,2BAAAA,QAASe,kBAAkB;QACrD,IAAI,CAACC,iBAAiB,GAAGhB,2BAAAA,QAASgB,iBAAiB;QACnD,IAAI,CAACC,SAAS,GAAGjB,2BAAAA,QAASiB,SAAS;QACnC,IAAI,CAACC,YAAY,GAAGlB,2BAAAA,QAASkB,YAAY;QACzC,IAAI,CAACC,QAAQ,GAAGnB,2BAAAA,QAASmB,QAAQ;QACjC,IAAI,CAACC,QAAQ,GAAGpB,2BAAAA,QAASoB,QAAQ;QACjC,IAAI,CAACC,SAAS,GAAGrB,2BAAAA,QAASqB,SAAS;QACnC,IAAI,CAACC,MAAM,GAAGtB,2BAAAA,QAASsB,MAAM;QAC7B,IAAI,CAACC,UAAU,GAAGvB,2BAAAA,QAASuB,UAAU;QACrC,IAAI,CAACC,KAAK,GAAGxB,2BAAAA,QAASwB,KAAK;QAC3B,IAAI,CAACC,MAAM,GAAGzB,2BAAAA,QAASyB,MAAM;QAC7B,IAAI,CAACC,QAAQ,GAAG1B,2BAAAA,QAAS0B,QAAQ;QACjC,IAAI,CAACC,IAAI,GAAG3B,2BAAAA,QAAS2B,IAAI;QACzB,IAAI,CAACC,YAAY,GAAG5B,2BAAAA,QAAS4B,YAAY;IAC3C;AAQF"}
@@ -1,4 +1,4 @@
1
- import type { Locale } from './locales.js';
1
+ import { type Locale } from './locales.js';
2
2
  export interface Formatters {
3
3
  /** Calendar date only. */
4
4
  date(value: Date | string | number): string;
@@ -9,8 +9,9 @@ export interface Formatters {
9
9
  relative(value: number, unit: Intl.RelativeTimeFormatUnit): string;
10
10
  }
11
11
  /**
12
- * Locale-aware formatting, memoized per locale because constructing an `Intl.*`
13
- * formatter is expensive and these run once per table cell.
12
+ * Locale-aware formatting in the locale's `formattingLocale`, memoized per
13
+ * that tag because constructing an `Intl.*` formatter is expensive and these
14
+ * run once per table cell.
14
15
  *
15
16
  * This exists to kill an argument-less `toLocaleString()`, which resolves against
16
17
  * the *runtime's* default locale — Node's on the server, the visitor's in the
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/i18n/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5C,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;CACpE;AAUD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAoCzD"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/i18n/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5C,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;CACpE;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAmCzD"}
@@ -1,11 +1,13 @@
1
+ import { formattingLocale } from './locales.js';
1
2
  /** `undefined` for an unparseable input, so callers can fall back to the raw value. */ function toDate(value) {
2
3
  const date = value instanceof Date ? value : new Date(value);
3
4
  return Number.isNaN(date.getTime()) ? undefined : date;
4
5
  }
5
6
  const cache = new Map();
6
7
  /**
7
- * Locale-aware formatting, memoized per locale because constructing an `Intl.*`
8
- * formatter is expensive and these run once per table cell.
8
+ * Locale-aware formatting in the locale's `formattingLocale`, memoized per
9
+ * that tag because constructing an `Intl.*` formatter is expensive and these
10
+ * run once per table cell.
9
11
  *
10
12
  * This exists to kill an argument-less `toLocaleString()`, which resolves against
11
13
  * the *runtime's* default locale — Node's on the server, the visitor's in the
@@ -13,17 +15,18 @@ const cache = new Map();
13
15
  * and React reported a hydration mismatch. Passing the negotiated locale
14
16
  * explicitly makes both halves agree by construction.
15
17
  */ export function makeFormatters(locale) {
16
- const cached = cache.get(locale);
18
+ const tag = formattingLocale(locale);
19
+ const cached = cache.get(tag);
17
20
  if (cached !== undefined) return cached;
18
- const dateFormat = new Intl.DateTimeFormat(locale, {
21
+ const dateFormat = new Intl.DateTimeFormat(tag, {
19
22
  dateStyle: 'medium'
20
23
  });
21
- const dateTimeFormat = new Intl.DateTimeFormat(locale, {
24
+ const dateTimeFormat = new Intl.DateTimeFormat(tag, {
22
25
  dateStyle: 'medium',
23
26
  timeStyle: 'short'
24
27
  });
25
- const numberFormat = new Intl.NumberFormat(locale);
26
- const relativeFormat = new Intl.RelativeTimeFormat(locale, {
28
+ const numberFormat = new Intl.NumberFormat(tag);
29
+ const relativeFormat = new Intl.RelativeTimeFormat(tag, {
27
30
  numeric: 'auto'
28
31
  });
29
32
  const formatters = {
@@ -35,14 +38,14 @@ const cache = new Map();
35
38
  const date = toDate(value);
36
39
  return date === undefined ? String(value) : dateTimeFormat.format(date);
37
40
  },
38
- number: (value, options)=>options === undefined ? numberFormat.format(value) : new Intl.NumberFormat(locale, options).format(value),
39
- currency: (value, currency)=>new Intl.NumberFormat(locale, {
41
+ number: (value, options)=>options === undefined ? numberFormat.format(value) : new Intl.NumberFormat(tag, options).format(value),
42
+ currency: (value, currency)=>new Intl.NumberFormat(tag, {
40
43
  style: 'currency',
41
44
  currency
42
45
  }).format(value),
43
46
  relative: (value, unit)=>relativeFormat.format(value, unit)
44
47
  };
45
- cache.set(locale, formatters);
48
+ cache.set(tag, formatters);
46
49
  return formatters;
47
50
  }
48
51
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/format.ts"],"sourcesContent":["import type { Locale } from './locales.js';\n\nexport interface Formatters {\n /** Calendar date only. */\n date(value: Date | string | number): string;\n /** Date plus wall-clock time. */\n dateTime(value: Date | string | number): string;\n number(value: number, options?: Intl.NumberFormatOptions): string;\n currency(value: number, currency: string): string;\n relative(value: number, unit: Intl.RelativeTimeFormatUnit): string;\n}\n\n/** `undefined` for an unparseable input, so callers can fall back to the raw value. */\nfunction toDate(value: Date | string | number): Date | undefined {\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\nconst cache = new Map<Locale, Formatters>();\n\n/**\n * Locale-aware formatting, memoized per locale because constructing an `Intl.*`\n * formatter is expensive and these run once per table cell.\n *\n * This exists to kill an argument-less `toLocaleString()`, which resolves against\n * the *runtime's* default locale — Node's on the server, the visitor's in the\n * browser. Those disagree, so the same cell rendered twice produced two strings\n * and React reported a hydration mismatch. Passing the negotiated locale\n * explicitly makes both halves agree by construction.\n */\nexport function makeFormatters(locale: Locale): Formatters {\n const cached = cache.get(locale);\n if (cached !== undefined) return cached;\n\n const dateFormat = new Intl.DateTimeFormat(locale, { dateStyle: 'medium' });\n const dateTimeFormat = new Intl.DateTimeFormat(locale, {\n dateStyle: 'medium',\n timeStyle: 'short',\n });\n const numberFormat = new Intl.NumberFormat(locale);\n const relativeFormat = new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto',\n });\n\n const formatters: Formatters = {\n date: value => {\n const date = toDate(value);\n return date === undefined ? String(value) : dateFormat.format(date);\n },\n dateTime: value => {\n const date = toDate(value);\n return date === undefined ? String(value) : dateTimeFormat.format(date);\n },\n number: (value, options) =>\n options === undefined\n ? numberFormat.format(value)\n : new Intl.NumberFormat(locale, options).format(value),\n currency: (value, currency) =>\n new Intl.NumberFormat(locale, { style: 'currency', currency }).format(\n value,\n ),\n relative: (value, unit) => relativeFormat.format(value, unit),\n };\n\n cache.set(locale, formatters);\n return formatters;\n}\n"],"names":["toDate","value","date","Date","Number","isNaN","getTime","undefined","cache","Map","makeFormatters","locale","cached","get","dateFormat","Intl","DateTimeFormat","dateStyle","dateTimeFormat","timeStyle","numberFormat","NumberFormat","relativeFormat","RelativeTimeFormat","numeric","formatters","String","format","dateTime","number","options","currency","style","relative","unit","set"],"mappings":"AAYA,qFAAqF,GACrF,SAASA,OAAOC,KAA6B;IAC3C,MAAMC,OAAOD,iBAAiBE,OAAOF,QAAQ,IAAIE,KAAKF;IACtD,OAAOG,OAAOC,KAAK,CAACH,KAAKI,OAAO,MAAMC,YAAYL;AACpD;AAEA,MAAMM,QAAQ,IAAIC;AAElB;;;;;;;;;CASC,GACD,OAAO,SAASC,eAAeC,MAAc;IAC3C,MAAMC,SAASJ,MAAMK,GAAG,CAACF;IACzB,IAAIC,WAAWL,WAAW,OAAOK;IAEjC,MAAME,aAAa,IAAIC,KAAKC,cAAc,CAACL,QAAQ;QAAEM,WAAW;IAAS;IACzE,MAAMC,iBAAiB,IAAIH,KAAKC,cAAc,CAACL,QAAQ;QACrDM,WAAW;QACXE,WAAW;IACb;IACA,MAAMC,eAAe,IAAIL,KAAKM,YAAY,CAACV;IAC3C,MAAMW,iBAAiB,IAAIP,KAAKQ,kBAAkB,CAACZ,QAAQ;QACzDa,SAAS;IACX;IAEA,MAAMC,aAAyB;QAC7BvB,MAAMD,CAAAA;YACJ,MAAMC,OAAOF,OAAOC;YACpB,OAAOC,SAASK,YAAYmB,OAAOzB,SAASa,WAAWa,MAAM,CAACzB;QAChE;QACA0B,UAAU3B,CAAAA;YACR,MAAMC,OAAOF,OAAOC;YACpB,OAAOC,SAASK,YAAYmB,OAAOzB,SAASiB,eAAeS,MAAM,CAACzB;QACpE;QACA2B,QAAQ,CAAC5B,OAAO6B,UACdA,YAAYvB,YACRa,aAAaO,MAAM,CAAC1B,SACpB,IAAIc,KAAKM,YAAY,CAACV,QAAQmB,SAASH,MAAM,CAAC1B;QACpD8B,UAAU,CAAC9B,OAAO8B,WAChB,IAAIhB,KAAKM,YAAY,CAACV,QAAQ;gBAAEqB,OAAO;gBAAYD;YAAS,GAAGJ,MAAM,CACnE1B;QAEJgC,UAAU,CAAChC,OAAOiC,OAASZ,eAAeK,MAAM,CAAC1B,OAAOiC;IAC1D;IAEA1B,MAAM2B,GAAG,CAACxB,QAAQc;IAClB,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../src/i18n/format.ts"],"sourcesContent":["import { formattingLocale, type Locale } from './locales.js';\n\nexport interface Formatters {\n /** Calendar date only. */\n date(value: Date | string | number): string;\n /** Date plus wall-clock time. */\n dateTime(value: Date | string | number): string;\n number(value: number, options?: Intl.NumberFormatOptions): string;\n currency(value: number, currency: string): string;\n relative(value: number, unit: Intl.RelativeTimeFormatUnit): string;\n}\n\n/** `undefined` for an unparseable input, so callers can fall back to the raw value. */\nfunction toDate(value: Date | string | number): Date | undefined {\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\nconst cache = new Map<string, Formatters>();\n\n/**\n * Locale-aware formatting in the locale's `formattingLocale`, memoized per\n * that tag because constructing an `Intl.*` formatter is expensive and these\n * run once per table cell.\n *\n * This exists to kill an argument-less `toLocaleString()`, which resolves against\n * the *runtime's* default locale — Node's on the server, the visitor's in the\n * browser. Those disagree, so the same cell rendered twice produced two strings\n * and React reported a hydration mismatch. Passing the negotiated locale\n * explicitly makes both halves agree by construction.\n */\nexport function makeFormatters(locale: Locale): Formatters {\n const tag = formattingLocale(locale);\n const cached = cache.get(tag);\n if (cached !== undefined) return cached;\n\n const dateFormat = new Intl.DateTimeFormat(tag, { dateStyle: 'medium' });\n const dateTimeFormat = new Intl.DateTimeFormat(tag, {\n dateStyle: 'medium',\n timeStyle: 'short',\n });\n const numberFormat = new Intl.NumberFormat(tag);\n const relativeFormat = new Intl.RelativeTimeFormat(tag, {\n numeric: 'auto',\n });\n\n const formatters: Formatters = {\n date: value => {\n const date = toDate(value);\n return date === undefined ? String(value) : dateFormat.format(date);\n },\n dateTime: value => {\n const date = toDate(value);\n return date === undefined ? String(value) : dateTimeFormat.format(date);\n },\n number: (value, options) =>\n options === undefined\n ? numberFormat.format(value)\n : new Intl.NumberFormat(tag, options).format(value),\n currency: (value, currency) =>\n new Intl.NumberFormat(tag, { style: 'currency', currency }).format(value),\n relative: (value, unit) => relativeFormat.format(value, unit),\n };\n\n cache.set(tag, formatters);\n return formatters;\n}\n"],"names":["formattingLocale","toDate","value","date","Date","Number","isNaN","getTime","undefined","cache","Map","makeFormatters","locale","tag","cached","get","dateFormat","Intl","DateTimeFormat","dateStyle","dateTimeFormat","timeStyle","numberFormat","NumberFormat","relativeFormat","RelativeTimeFormat","numeric","formatters","String","format","dateTime","number","options","currency","style","relative","unit","set"],"mappings":"AAAA,SAASA,gBAAgB,QAAqB,eAAe;AAY7D,qFAAqF,GACrF,SAASC,OAAOC,KAA6B;IAC3C,MAAMC,OAAOD,iBAAiBE,OAAOF,QAAQ,IAAIE,KAAKF;IACtD,OAAOG,OAAOC,KAAK,CAACH,KAAKI,OAAO,MAAMC,YAAYL;AACpD;AAEA,MAAMM,QAAQ,IAAIC;AAElB;;;;;;;;;;CAUC,GACD,OAAO,SAASC,eAAeC,MAAc;IAC3C,MAAMC,MAAMb,iBAAiBY;IAC7B,MAAME,SAASL,MAAMM,GAAG,CAACF;IACzB,IAAIC,WAAWN,WAAW,OAAOM;IAEjC,MAAME,aAAa,IAAIC,KAAKC,cAAc,CAACL,KAAK;QAAEM,WAAW;IAAS;IACtE,MAAMC,iBAAiB,IAAIH,KAAKC,cAAc,CAACL,KAAK;QAClDM,WAAW;QACXE,WAAW;IACb;IACA,MAAMC,eAAe,IAAIL,KAAKM,YAAY,CAACV;IAC3C,MAAMW,iBAAiB,IAAIP,KAAKQ,kBAAkB,CAACZ,KAAK;QACtDa,SAAS;IACX;IAEA,MAAMC,aAAyB;QAC7BxB,MAAMD,CAAAA;YACJ,MAAMC,OAAOF,OAAOC;YACpB,OAAOC,SAASK,YAAYoB,OAAO1B,SAASc,WAAWa,MAAM,CAAC1B;QAChE;QACA2B,UAAU5B,CAAAA;YACR,MAAMC,OAAOF,OAAOC;YACpB,OAAOC,SAASK,YAAYoB,OAAO1B,SAASkB,eAAeS,MAAM,CAAC1B;QACpE;QACA4B,QAAQ,CAAC7B,OAAO8B,UACdA,YAAYxB,YACRc,aAAaO,MAAM,CAAC3B,SACpB,IAAIe,KAAKM,YAAY,CAACV,KAAKmB,SAASH,MAAM,CAAC3B;QACjD+B,UAAU,CAAC/B,OAAO+B,WAChB,IAAIhB,KAAKM,YAAY,CAACV,KAAK;gBAAEqB,OAAO;gBAAYD;YAAS,GAAGJ,MAAM,CAAC3B;QACrEiC,UAAU,CAACjC,OAAOkC,OAASZ,eAAeK,MAAM,CAAC3B,OAAOkC;IAC1D;IAEA3B,MAAM4B,GAAG,CAACxB,KAAKc;IACf,OAAOA;AACT"}
@@ -1,4 +1,5 @@
1
1
  export * from './format.js';
2
2
  export * from './locales.js';
3
3
  export * from './negotiate.js';
4
+ export * from './scaled-number.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from './format.js';
2
2
  export * from './locales.js';
3
3
  export * from './negotiate.js';
4
+ export * from './scaled-number.js';
4
5
 
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/index.ts"],"sourcesContent":["export * from './format.js';\nexport * from './locales.js';\nexport * from './negotiate.js';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,iBAAiB"}
1
+ {"version":3,"sources":["../../src/i18n/index.ts"],"sourcesContent":["export * from './format.js';\nexport * from './locales.js';\nexport * from './negotiate.js';\nexport * from './scaled-number.js';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB"}
@@ -28,6 +28,15 @@ export interface LocaleDefinition {
28
28
  * catalog key falls back to.
29
29
  */
30
30
  readonly defaultLocale: Locale;
31
+ /**
32
+ * The conventions each locale formats numbers, money and dates in, where
33
+ * they are not the language's own: `{ es: 'es-GT' }` writes `64.99` where
34
+ * `es` writes `64,99`. Catalogs, routing and the cookie keep the locale.
35
+ *
36
+ * Left out, what was declared before stands for the locales still listed,
37
+ * so a second declaration of the same locales cannot undo it; `{}` clears it.
38
+ */
39
+ readonly formattingLocales?: Readonly<Partial<Record<Locale, string>>>;
31
40
  }
32
41
  /**
33
42
  * Declares the host's locales. Call it once, from a module every entry point
@@ -40,6 +49,12 @@ export interface LocaleDefinition {
40
49
  * third locale needs no change to entifix.
41
50
  */
42
51
  export declare function defineLocales(definition: LocaleDefinition): void;
52
+ /**
53
+ * The tag to hand `Intl` for `locale`: the one the host declared in
54
+ * `formattingLocales`, or the locale itself. Every formatter and parser here
55
+ * asks it, so a caller passes the locale it renders in and nothing else.
56
+ */
57
+ export declare function formattingLocale(locale: string): string;
43
58
  /** The locales the host declared. */
44
59
  export declare function locales(): readonly Locale[];
45
60
  /** The host's default locale. */
@@ -1 +1 @@
1
- {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../src/i18n/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,MAAM,WAAW,cAAc;CAAG;AAElC,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,cAAc,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GAC1E,CAAC,GACD,MAAM,CAAC;AAEX,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAcD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAiBhE;AAED,qCAAqC;AACrC,wBAAgB,OAAO,IAAI,SAAS,MAAM,EAAE,CAE3C;AAED,iCAAiC;AACjC,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,iDAAiD;AACjD,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAEhD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAKxD"}
1
+ {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../src/i18n/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,MAAM,WAAW,cAAc;CAAG;AAElC,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,cAAc,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GAC1E,CAAC,GACD,MAAM,CAAC;AAEX,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CACxE;AAeD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAuChE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,qCAAqC;AACrC,wBAAgB,OAAO,IAAI,SAAS,MAAM,EAAE,CAE3C;AAED,iCAAiC;AACjC,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,iDAAiD;AACjD,wBAAgB,YAAY,IAAI,IAAI,CAGnC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAEhD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAKxD"}
@@ -25,6 +25,7 @@
25
25
  defaultLocale: 'en'
26
26
  };
27
27
  let declared = UNDECLARED;
28
+ let formatting = new Map();
28
29
  /**
29
30
  * Declares the host's locales. Call it once, from a module every entry point
30
31
  * imports — including a Next middleware, which is bundled on its own and shares
@@ -35,7 +36,7 @@ let declared = UNDECLARED;
35
36
  * `['en', 'es']` with `en` first gets English as the fallback everywhere, and a
36
37
  * third locale needs no change to entifix.
37
38
  */ export function defineLocales(definition) {
38
- const { locales: list, defaultLocale: fallback } = definition;
39
+ const { locales: list, defaultLocale: fallback, formattingLocales } = definition;
39
40
  if (list.length === 0) {
40
41
  throw new Error('defineLocales needs at least one locale.');
41
42
  }
@@ -46,6 +47,20 @@ let declared = UNDECLARED;
46
47
  if (!list.includes(fallback)) {
47
48
  throw new Error(`The default locale "${fallback}" is not one of ${JSON.stringify(list)}.`);
48
49
  }
50
+ const next = new Map(formattingLocales === undefined ? [
51
+ ...formatting
52
+ ].filter(([locale])=>list.includes(locale)) : Object.entries(formattingLocales));
53
+ for (const [locale, tag] of next){
54
+ if (!list.includes(locale)) {
55
+ throw new Error(`The formatting locale's key "${locale}" is not one of ${JSON.stringify(list)}.`);
56
+ }
57
+ // A tag without data formats as the runtime's own locale, which is a
58
+ // different one on the server and in the browser.
59
+ if (Intl.NumberFormat.supportedLocalesOf(tag).length === 0) {
60
+ throw new Error(`Intl has no formats for the locale "${tag}".`);
61
+ }
62
+ }
63
+ formatting = next;
49
64
  declared = {
50
65
  locales: [
51
66
  ...list
@@ -53,6 +68,14 @@ let declared = UNDECLARED;
53
68
  defaultLocale: fallback
54
69
  };
55
70
  }
71
+ /**
72
+ * The tag to hand `Intl` for `locale`: the one the host declared in
73
+ * `formattingLocales`, or the locale itself. Every formatter and parser here
74
+ * asks it, so a caller passes the locale it renders in and nothing else.
75
+ */ export function formattingLocale(locale) {
76
+ var _formatting_get;
77
+ return (_formatting_get = formatting.get(locale)) != null ? _formatting_get : locale;
78
+ }
56
79
  /** The locales the host declared. */ export function locales() {
57
80
  return declared.locales;
58
81
  }
@@ -61,6 +84,7 @@ let declared = UNDECLARED;
61
84
  }
62
85
  /** Forgets the host's declaration. For specs. */ export function resetLocales() {
63
86
  declared = UNDECLARED;
87
+ formatting = new Map();
64
88
  }
65
89
  /**
66
90
  * Host-scoped so the choice is shared across the fleet's localhost ports in dev,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/locales.ts"],"sourcesContent":["/**\n * Where a host narrows {@link Locale} to the locales it ships:\n *\n * ```ts\n * declare module '@entifix/core' {\n * interface LocaleRegister {\n * locale: 'es' | 'en';\n * }\n * }\n * ```\n *\n * The same mechanism i18next's `CustomTypeOptions` uses. Without it a locale is\n * any string, which is honest for a framework that does not know which\n * languages its host speaks.\n */\n// An empty interface is the point: a host merges its declaration into it.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type\nexport interface LocaleRegister {}\n\n/** A locale the host declared, or any string when it declared none. */\nexport type Locale = LocaleRegister extends { locale: infer L extends string }\n ? L\n : string;\n\n/** What a host declares through {@link defineLocales}. */\nexport interface LocaleDefinition {\n /** Every locale the host ships, in the order a switcher offers them. */\n readonly locales: readonly Locale[];\n /**\n * The locale a visitor gets when nothing else decides, and the one a missing\n * catalog key falls back to.\n */\n readonly defaultLocale: Locale;\n}\n\n/**\n * What a host gets when it declares nothing: English alone. Neutral rather than\n * any one adopter's choice — the adopter that once supplied the `es` default\n * here now declares it like everyone else (#35).\n */\nconst UNDECLARED: LocaleDefinition = {\n locales: ['en' as Locale],\n defaultLocale: 'en' as Locale,\n};\n\nlet declared: LocaleDefinition = UNDECLARED;\n\n/**\n * Declares the host's locales. Call it once, from a module every entry point\n * imports — including a Next middleware, which is bundled on its own and shares\n * no module state with the server.\n *\n * Read at call time by every helper below and by `@entifix/i18n`,\n * `@entifix/react-controls` and `@entifix/next-i18n`, so a host declaring\n * `['en', 'es']` with `en` first gets English as the fallback everywhere, and a\n * third locale needs no change to entifix.\n */\nexport function defineLocales(definition: LocaleDefinition): void {\n const { locales: list, defaultLocale: fallback } = definition;\n if (list.length === 0) {\n throw new Error('defineLocales needs at least one locale.');\n }\n const duplicate = list.find(\n (locale, index) => list.indexOf(locale) !== index,\n );\n if (duplicate !== undefined) {\n throw new Error(`defineLocales was given \"${duplicate}\" more than once.`);\n }\n if (!list.includes(fallback)) {\n throw new Error(\n `The default locale \"${fallback}\" is not one of ${JSON.stringify(list)}.`,\n );\n }\n declared = { locales: [...list], defaultLocale: fallback };\n}\n\n/** The locales the host declared. */\nexport function locales(): readonly Locale[] {\n return declared.locales;\n}\n\n/** The host's default locale. */\nexport function defaultLocale(): Locale {\n return declared.defaultLocale;\n}\n\n/** Forgets the host's declaration. For specs. */\nexport function resetLocales(): void {\n declared = UNDECLARED;\n}\n\n/**\n * Host-scoped so the choice is shared across the fleet's localhost ports in dev,\n * exactly like `entifix_at`/`entifix_sid`. Written by the locale middleware on every\n * redirect, so a visitor who lands on `/en/...` keeps English on the next visit.\n */\nexport const LOCALE_COOKIE = 'entifix_locale';\n\n/**\n * Request header the locale middleware sets when it rewrites a prefixed path.\n * Server components read it instead of a route param, which is what lets the\n * route tree stay free of an `app/[locale]` segment.\n */\nexport const LOCALE_HEADER = 'x-entifix-locale';\n\nexport function isLocale(value: unknown): value is Locale {\n return (\n typeof value === 'string' &&\n (declared.locales as readonly string[]).includes(value)\n );\n}\n"],"names":["UNDECLARED","locales","defaultLocale","declared","defineLocales","definition","list","fallback","length","Error","duplicate","find","locale","index","indexOf","undefined","includes","JSON","stringify","resetLocales","LOCALE_COOKIE","LOCALE_HEADER","isLocale","value"],"mappings":"AAAA;;;;;;;;;;;;;;CAcC,GACD,0EAA0E;AAC1E,0GAA0G;AAmB1G;;;;CAIC,GACD,MAAMA,aAA+B;IACnCC,SAAS;QAAC;KAAe;IACzBC,eAAe;AACjB;AAEA,IAAIC,WAA6BH;AAEjC;;;;;;;;;CASC,GACD,OAAO,SAASI,cAAcC,UAA4B;IACxD,MAAM,EAAEJ,SAASK,IAAI,EAAEJ,eAAeK,QAAQ,EAAE,GAAGF;IACnD,IAAIC,KAAKE,MAAM,KAAK,GAAG;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,MAAMC,YAAYJ,KAAKK,IAAI,CACzB,CAACC,QAAQC,QAAUP,KAAKQ,OAAO,CAACF,YAAYC;IAE9C,IAAIH,cAAcK,WAAW;QAC3B,MAAM,IAAIN,MAAM,CAAC,yBAAyB,EAAEC,UAAU,iBAAiB,CAAC;IAC1E;IACA,IAAI,CAACJ,KAAKU,QAAQ,CAACT,WAAW;QAC5B,MAAM,IAAIE,MACR,CAAC,oBAAoB,EAAEF,SAAS,gBAAgB,EAAEU,KAAKC,SAAS,CAACZ,MAAM,CAAC,CAAC;IAE7E;IACAH,WAAW;QAAEF,SAAS;eAAIK;SAAK;QAAEJ,eAAeK;IAAS;AAC3D;AAEA,mCAAmC,GACnC,OAAO,SAASN;IACd,OAAOE,SAASF,OAAO;AACzB;AAEA,+BAA+B,GAC/B,OAAO,SAASC;IACd,OAAOC,SAASD,aAAa;AAC/B;AAEA,+CAA+C,GAC/C,OAAO,SAASiB;IACdhB,WAAWH;AACb;AAEA;;;;CAIC,GACD,OAAO,MAAMoB,gBAAgB,iBAAiB;AAE9C;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,mBAAmB;AAEhD,OAAO,SAASC,SAASC,KAAc;IACrC,OACE,OAAOA,UAAU,YACjB,AAACpB,SAASF,OAAO,CAAuBe,QAAQ,CAACO;AAErD"}
1
+ {"version":3,"sources":["../../src/i18n/locales.ts"],"sourcesContent":["/**\n * Where a host narrows {@link Locale} to the locales it ships:\n *\n * ```ts\n * declare module '@entifix/core' {\n * interface LocaleRegister {\n * locale: 'es' | 'en';\n * }\n * }\n * ```\n *\n * The same mechanism i18next's `CustomTypeOptions` uses. Without it a locale is\n * any string, which is honest for a framework that does not know which\n * languages its host speaks.\n */\n// An empty interface is the point: a host merges its declaration into it.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type\nexport interface LocaleRegister {}\n\n/** A locale the host declared, or any string when it declared none. */\nexport type Locale = LocaleRegister extends { locale: infer L extends string }\n ? L\n : string;\n\n/** What a host declares through {@link defineLocales}. */\nexport interface LocaleDefinition {\n /** Every locale the host ships, in the order a switcher offers them. */\n readonly locales: readonly Locale[];\n /**\n * The locale a visitor gets when nothing else decides, and the one a missing\n * catalog key falls back to.\n */\n readonly defaultLocale: Locale;\n /**\n * The conventions each locale formats numbers, money and dates in, where\n * they are not the language's own: `{ es: 'es-GT' }` writes `64.99` where\n * `es` writes `64,99`. Catalogs, routing and the cookie keep the locale.\n *\n * Left out, what was declared before stands for the locales still listed,\n * so a second declaration of the same locales cannot undo it; `{}` clears it.\n */\n readonly formattingLocales?: Readonly<Partial<Record<Locale, string>>>;\n}\n\n/**\n * What a host gets when it declares nothing: English alone. Neutral rather than\n * any one adopter's choice — the adopter that once supplied the `es` default\n * here now declares it like everyone else (#35).\n */\nconst UNDECLARED: LocaleDefinition = {\n locales: ['en' as Locale],\n defaultLocale: 'en' as Locale,\n};\n\nlet declared: LocaleDefinition = UNDECLARED;\nlet formatting: ReadonlyMap<string, string> = new Map();\n\n/**\n * Declares the host's locales. Call it once, from a module every entry point\n * imports — including a Next middleware, which is bundled on its own and shares\n * no module state with the server.\n *\n * Read at call time by every helper below and by `@entifix/i18n`,\n * `@entifix/react-controls` and `@entifix/next-i18n`, so a host declaring\n * `['en', 'es']` with `en` first gets English as the fallback everywhere, and a\n * third locale needs no change to entifix.\n */\nexport function defineLocales(definition: LocaleDefinition): void {\n const {\n locales: list,\n defaultLocale: fallback,\n formattingLocales,\n } = definition;\n if (list.length === 0) {\n throw new Error('defineLocales needs at least one locale.');\n }\n const duplicate = list.find(\n (locale, index) => list.indexOf(locale) !== index,\n );\n if (duplicate !== undefined) {\n throw new Error(`defineLocales was given \"${duplicate}\" more than once.`);\n }\n if (!list.includes(fallback)) {\n throw new Error(\n `The default locale \"${fallback}\" is not one of ${JSON.stringify(list)}.`,\n );\n }\n const next = new Map(\n formattingLocales === undefined\n ? [...formatting].filter(([locale]) => list.includes(locale as Locale))\n : (Object.entries(formattingLocales) as [string, string][]),\n );\n for (const [locale, tag] of next) {\n if (!list.includes(locale as Locale)) {\n throw new Error(\n `The formatting locale's key \"${locale}\" is not one of ${JSON.stringify(list)}.`,\n );\n }\n // A tag without data formats as the runtime's own locale, which is a\n // different one on the server and in the browser.\n if (Intl.NumberFormat.supportedLocalesOf(tag).length === 0) {\n throw new Error(`Intl has no formats for the locale \"${tag}\".`);\n }\n }\n formatting = next;\n declared = { locales: [...list], defaultLocale: fallback };\n}\n\n/**\n * The tag to hand `Intl` for `locale`: the one the host declared in\n * `formattingLocales`, or the locale itself. Every formatter and parser here\n * asks it, so a caller passes the locale it renders in and nothing else.\n */\nexport function formattingLocale(locale: string): string {\n return formatting.get(locale) ?? locale;\n}\n\n/** The locales the host declared. */\nexport function locales(): readonly Locale[] {\n return declared.locales;\n}\n\n/** The host's default locale. */\nexport function defaultLocale(): Locale {\n return declared.defaultLocale;\n}\n\n/** Forgets the host's declaration. For specs. */\nexport function resetLocales(): void {\n declared = UNDECLARED;\n formatting = new Map();\n}\n\n/**\n * Host-scoped so the choice is shared across the fleet's localhost ports in dev,\n * exactly like `entifix_at`/`entifix_sid`. Written by the locale middleware on every\n * redirect, so a visitor who lands on `/en/...` keeps English on the next visit.\n */\nexport const LOCALE_COOKIE = 'entifix_locale';\n\n/**\n * Request header the locale middleware sets when it rewrites a prefixed path.\n * Server components read it instead of a route param, which is what lets the\n * route tree stay free of an `app/[locale]` segment.\n */\nexport const LOCALE_HEADER = 'x-entifix-locale';\n\nexport function isLocale(value: unknown): value is Locale {\n return (\n typeof value === 'string' &&\n (declared.locales as readonly string[]).includes(value)\n );\n}\n"],"names":["UNDECLARED","locales","defaultLocale","declared","formatting","Map","defineLocales","definition","list","fallback","formattingLocales","length","Error","duplicate","find","locale","index","indexOf","undefined","includes","JSON","stringify","next","filter","Object","entries","tag","Intl","NumberFormat","supportedLocalesOf","formattingLocale","get","resetLocales","LOCALE_COOKIE","LOCALE_HEADER","isLocale","value"],"mappings":"AAAA;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,EAAEc,IAAI,EAAE,CAAC;QAChE;IACF;IACAtB,aAAakB;IACbnB,WAAW;QAAEF,SAAS;eAAIO;SAAK;QAAEN,eAAeO;IAAS;AAC3D;AAEA;;;;CAIC,GACD,OAAO,SAASqB,iBAAiBf,MAAc;QACtCX;IAAP,QAAOA,kBAAAA,WAAW2B,GAAG,CAAChB,mBAAfX,kBAA0BW;AACnC;AAEA,mCAAmC,GACnC,OAAO,SAASd;IACd,OAAOE,SAASF,OAAO;AACzB;AAEA,+BAA+B,GAC/B,OAAO,SAASC;IACd,OAAOC,SAASD,aAAa;AAC/B;AAEA,+CAA+C,GAC/C,OAAO,SAAS8B;IACd7B,WAAWH;IACXI,aAAa,IAAIC;AACnB;AAEA;;;;CAIC,GACD,OAAO,MAAM4B,gBAAgB,iBAAiB;AAE9C;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,mBAAmB;AAEhD,OAAO,SAASC,SAASC,KAAc;IACrC,OACE,OAAOA,UAAU,YACjB,AAACjC,SAASF,OAAO,CAAuBkB,QAAQ,CAACiB;AAErD"}
@@ -0,0 +1,35 @@
1
+ import { type Locale } from './locales.js';
2
+ /**
3
+ * The most decimals a scale can carry and still leave a safe integer room to
4
+ * count with.
5
+ */
6
+ export declare const MAX_SCALE = 15;
7
+ /**
8
+ * The integer `text` stands for in `scale` decimals — `'3,5'` at scale 3 is
9
+ * `3500` — or `undefined` when it stands for none. Read digit by digit and
10
+ * never through a float.
11
+ *
12
+ * **It never rounds and never guesses.** More decimals than the scale holds is
13
+ * not a number here, and neither is text with two readings:
14
+ *
15
+ * - either separator opens a fraction (`64,99`, `64.99`), because people type
16
+ * both whatever their locale;
17
+ * - grouping is accepted where it can only be grouping (`1.234,56`,
18
+ * `12.500.000`);
19
+ * - one separator and three digits could be either. In the decimal separator
20
+ * of the locale's `formattingLocale` it is always a fraction, so `64.999` at
21
+ * scale 2 is refused in `en` and never 64,999. In the other one it is a
22
+ * thousand below scale 3 (`1,000`) and refused from there on.
23
+ */
24
+ export declare function parseScaled(text: string, scale: number, locale: Locale): number | undefined;
25
+ /** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */
26
+ export declare function scaledToDecimal(value: number, scale: number): string;
27
+ /**
28
+ * A scaled integer as the reader's locale writes it, with no more decimals
29
+ * than it has. With `grouping: false` it is the text to edit: Latin digits in
30
+ * the locale's decimal separator, which `parseScaled` reads back exactly.
31
+ */
32
+ export declare function formatScaled(value: number, scale: number, locale: Locale, { grouping }?: {
33
+ readonly grouping?: boolean;
34
+ }): string;
35
+ //# sourceMappingURL=scaled-number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaled-number.d.ts","sourceRoot":"","sources":["../../src/i18n/scaled-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,SAAS,KAAK,CAAC;AAsE5B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAUpB;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,EAAE,QAAe,EAAE,GAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,CAYR"}
@@ -0,0 +1,131 @@
1
+ import { formattingLocale } from './locales.js';
2
+ /**
3
+ * The most decimals a scale can carry and still leave a safe integer room to
4
+ * count with.
5
+ */ export const MAX_SCALE = 15;
6
+ const decimalSeparators = new Map();
7
+ /** The character `locale` writes before a fraction. */ function decimalSeparatorOf(locale) {
8
+ var _formatToParts_find;
9
+ const tag = formattingLocale(locale);
10
+ const known = decimalSeparators.get(tag);
11
+ if (known !== undefined) return known;
12
+ const separator = ((_formatToParts_find = new Intl.NumberFormat(tag).formatToParts(1.5).find((part)=>part.type === 'decimal')) == null ? void 0 : _formatToParts_find.value) === ',' ? ',' : '.';
13
+ decimalSeparators.set(tag, separator);
14
+ return separator;
15
+ }
16
+ /** Digits grouped in threes by one separator: `1,000`, `12.500.000`. */ const groupedBy = (separator)=>new RegExp(`^[1-9]\\d{0,2}(?:\\${separator}\\d{3})+$`);
17
+ const GROUPED = {
18
+ ',': groupedBy(','),
19
+ '.': groupedBy('.')
20
+ };
21
+ /**
22
+ * The whole and fraction digits `text` writes, or `undefined` when it writes
23
+ * no number or could write two.
24
+ */ function digitsOf(text, scale, locale) {
25
+ if (!/^[\d.,]+$/.test(text) || !/\d/.test(text)) return undefined;
26
+ const last = Math.max(text.lastIndexOf(','), text.lastIndexOf('.'));
27
+ if (last === -1) return [
28
+ text,
29
+ ''
30
+ ];
31
+ const separator = text.charAt(last);
32
+ const head = text.slice(0, last);
33
+ const tail = text.slice(last + 1);
34
+ const other = separator === ',' ? '.' : ',';
35
+ // Both separators: the last opens the fraction, the other groups.
36
+ if (head.includes(other)) {
37
+ // With nothing after it, only the locale's decimal separator opens one:
38
+ // `64.999,` in `en` is a slip, not sixty-four thousand.
39
+ if (tail === '' && separator !== decimalSeparatorOf(locale)) {
40
+ return undefined;
41
+ }
42
+ return GROUPED[other].test(head) ? [
43
+ head.replaceAll(other, ''),
44
+ tail
45
+ ] : undefined;
46
+ }
47
+ // One separator, repeated: it can only be grouping.
48
+ if (head.includes(separator)) {
49
+ return GROUPED[separator].test(text) ? [
50
+ text.replaceAll(separator, ''),
51
+ ''
52
+ ] : undefined;
53
+ }
54
+ if (GROUPED[separator].test(text)) {
55
+ // `64.999` where `.` opens fractions is never sixty-four thousand, however
56
+ // few decimals fit: it is a fraction, and refused where that is too long.
57
+ if (separator === decimalSeparatorOf(locale)) return [
58
+ head,
59
+ tail
60
+ ];
61
+ // The other separator groups, unless three decimals fit: then it could be
62
+ // either, and is refused.
63
+ return scale < 3 ? [
64
+ head + tail,
65
+ ''
66
+ ] : undefined;
67
+ }
68
+ return [
69
+ head,
70
+ tail
71
+ ];
72
+ }
73
+ /**
74
+ * The integer `text` stands for in `scale` decimals — `'3,5'` at scale 3 is
75
+ * `3500` — or `undefined` when it stands for none. Read digit by digit and
76
+ * never through a float.
77
+ *
78
+ * **It never rounds and never guesses.** More decimals than the scale holds is
79
+ * not a number here, and neither is text with two readings:
80
+ *
81
+ * - either separator opens a fraction (`64,99`, `64.99`), because people type
82
+ * both whatever their locale;
83
+ * - grouping is accepted where it can only be grouping (`1.234,56`,
84
+ * `12.500.000`);
85
+ * - one separator and three digits could be either. In the decimal separator
86
+ * of the locale's `formattingLocale` it is always a fraction, so `64.999` at
87
+ * scale 2 is refused in `en` and never 64,999. In the other one it is a
88
+ * thousand below scale 3 (`1,000`) and refused from there on.
89
+ */ export function parseScaled(text, scale, locale) {
90
+ var _ref;
91
+ var _exec;
92
+ const compact = text.replace(/[\s'’]/g, '');
93
+ const sign = (_ref = (_exec = /^[+-]/.exec(compact)) == null ? void 0 : _exec[0]) != null ? _ref : '';
94
+ const digits = digitsOf(compact.slice(sign.length), scale, locale);
95
+ if (digits === undefined) return undefined;
96
+ const [whole, fraction] = digits;
97
+ if (fraction.length > scale) return undefined;
98
+ const magnitude = BigInt(`${whole}${fraction.padEnd(scale, '0')}`);
99
+ if (magnitude > BigInt(Number.MAX_SAFE_INTEGER)) return undefined;
100
+ return magnitude === 0n ? 0 : Number(magnitude) * (sign === '-' ? -1 : 1);
101
+ }
102
+ /** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */ export function scaledToDecimal(value, scale) {
103
+ if (!Number.isSafeInteger(value)) {
104
+ throw new RangeError(`${String(value)} is not a scaled integer`);
105
+ }
106
+ const digits = String(Math.abs(value)).padStart(scale + 1, '0');
107
+ const at = digits.length - scale;
108
+ const fraction = digits.slice(at).replace(/0+$/, '');
109
+ return `${value < 0 ? '-' : ''}${digits.slice(0, at)}${fraction === '' ? '' : `.${fraction}`}`;
110
+ }
111
+ /**
112
+ * A scaled integer as the reader's locale writes it, with no more decimals
113
+ * than it has. With `grouping: false` it is the text to edit: Latin digits in
114
+ * the locale's decimal separator, which `parseScaled` reads back exactly.
115
+ */ export function formatScaled(value, scale, locale, { grouping = true } = {}) {
116
+ var _ref;
117
+ var _decimal_split_;
118
+ const decimal = scaledToDecimal(value, scale);
119
+ const tag = formattingLocale(locale);
120
+ if (!grouping) return decimal.replace('.', decimalSeparatorOf(locale));
121
+ const fraction = (_ref = (_decimal_split_ = decimal.split('.')[1]) == null ? void 0 : _decimal_split_.length) != null ? _ref : 0;
122
+ // `format` takes a decimal string exactly (ES2023), so a long count is never
123
+ // rounded through a float on its way to the screen. The cast is for this
124
+ // package's `lib`, whose typings predate that overload.
125
+ return new Intl.NumberFormat(tag, {
126
+ minimumFractionDigits: fraction,
127
+ maximumFractionDigits: fraction
128
+ }).format(decimal);
129
+ }
130
+
131
+ //# sourceMappingURL=scaled-number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/i18n/scaled-number.ts"],"sourcesContent":["import { formattingLocale, type Locale } from './locales.js';\n\n/**\n * The most decimals a scale can carry and still leave a safe integer room to\n * count with.\n */\nexport const MAX_SCALE = 15;\n\nconst decimalSeparators = new Map<string, string>();\n\n/** The character `locale` writes before a fraction. */\nfunction decimalSeparatorOf(locale: Locale): string {\n const tag = formattingLocale(locale);\n const known = decimalSeparators.get(tag);\n if (known !== undefined) return known;\n const separator =\n new Intl.NumberFormat(tag)\n .formatToParts(1.5)\n .find(part => part.type === 'decimal')?.value === ','\n ? ','\n : '.';\n decimalSeparators.set(tag, separator);\n return separator;\n}\n\n/** Digits grouped in threes by one separator: `1,000`, `12.500.000`. */\nconst groupedBy = (separator: string) =>\n new RegExp(`^[1-9]\\\\d{0,2}(?:\\\\${separator}\\\\d{3})+$`);\n\nconst GROUPED = { ',': groupedBy(','), '.': groupedBy('.') } as const;\n\n/**\n * The whole and fraction digits `text` writes, or `undefined` when it writes\n * no number or could write two.\n */\nfunction digitsOf(\n text: string,\n scale: number,\n locale: Locale,\n): readonly [whole: string, fraction: string] | undefined {\n if (!/^[\\d.,]+$/.test(text) || !/\\d/.test(text)) return undefined;\n const last = Math.max(text.lastIndexOf(','), text.lastIndexOf('.'));\n if (last === -1) return [text, ''];\n const separator = text.charAt(last) as ',' | '.';\n const head = text.slice(0, last);\n const tail = text.slice(last + 1);\n const other = separator === ',' ? '.' : ',';\n\n // Both separators: the last opens the fraction, the other groups.\n if (head.includes(other)) {\n // With nothing after it, only the locale's decimal separator opens one:\n // `64.999,` in `en` is a slip, not sixty-four thousand.\n if (tail === '' && separator !== decimalSeparatorOf(locale)) {\n return undefined;\n }\n return GROUPED[other].test(head)\n ? [head.replaceAll(other, ''), tail]\n : undefined;\n }\n // One separator, repeated: it can only be grouping.\n if (head.includes(separator)) {\n return GROUPED[separator].test(text)\n ? [text.replaceAll(separator, ''), '']\n : undefined;\n }\n if (GROUPED[separator].test(text)) {\n // `64.999` where `.` opens fractions is never sixty-four thousand, however\n // few decimals fit: it is a fraction, and refused where that is too long.\n if (separator === decimalSeparatorOf(locale)) return [head, tail];\n // The other separator groups, unless three decimals fit: then it could be\n // either, and is refused.\n return scale < 3 ? [head + tail, ''] : undefined;\n }\n return [head, tail];\n}\n\n/**\n * The integer `text` stands for in `scale` decimals — `'3,5'` at scale 3 is\n * `3500` — or `undefined` when it stands for none. Read digit by digit and\n * never through a float.\n *\n * **It never rounds and never guesses.** More decimals than the scale holds is\n * not a number here, and neither is text with two readings:\n *\n * - either separator opens a fraction (`64,99`, `64.99`), because people type\n * both whatever their locale;\n * - grouping is accepted where it can only be grouping (`1.234,56`,\n * `12.500.000`);\n * - one separator and three digits could be either. In the decimal separator\n * of the locale's `formattingLocale` it is always a fraction, so `64.999` at\n * scale 2 is refused in `en` and never 64,999. In the other one it is a\n * thousand below scale 3 (`1,000`) and refused from there on.\n */\nexport function parseScaled(\n text: string,\n scale: number,\n locale: Locale,\n): number | undefined {\n const compact = text.replace(/[\\s'’]/g, '');\n const sign = /^[+-]/.exec(compact)?.[0] ?? '';\n const digits = digitsOf(compact.slice(sign.length), scale, locale);\n if (digits === undefined) return undefined;\n const [whole, fraction] = digits;\n if (fraction.length > scale) return undefined;\n const magnitude = BigInt(`${whole}${fraction.padEnd(scale, '0')}`);\n if (magnitude > BigInt(Number.MAX_SAFE_INTEGER)) return undefined;\n return magnitude === 0n ? 0 : Number(magnitude) * (sign === '-' ? -1 : 1);\n}\n\n/** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */\nexport function scaledToDecimal(value: number, scale: number): string {\n if (!Number.isSafeInteger(value)) {\n throw new RangeError(`${String(value)} is not a scaled integer`);\n }\n const digits = String(Math.abs(value)).padStart(scale + 1, '0');\n const at = digits.length - scale;\n const fraction = digits.slice(at).replace(/0+$/, '');\n return `${value < 0 ? '-' : ''}${digits.slice(0, at)}${\n fraction === '' ? '' : `.${fraction}`\n }`;\n}\n\n/**\n * A scaled integer as the reader's locale writes it, with no more decimals\n * than it has. With `grouping: false` it is the text to edit: Latin digits in\n * the locale's decimal separator, which `parseScaled` reads back exactly.\n */\nexport function formatScaled(\n value: number,\n scale: number,\n locale: Locale,\n { grouping = true }: { readonly grouping?: boolean } = {},\n): string {\n const decimal = scaledToDecimal(value, scale);\n const tag = formattingLocale(locale);\n if (!grouping) return decimal.replace('.', decimalSeparatorOf(locale));\n const fraction = decimal.split('.')[1]?.length ?? 0;\n // `format` takes a decimal string exactly (ES2023), so a long count is never\n // rounded through a float on its way to the screen. The cast is for this\n // package's `lib`, whose typings predate that overload.\n return new Intl.NumberFormat(tag, {\n minimumFractionDigits: fraction,\n maximumFractionDigits: fraction,\n }).format(decimal as unknown as number);\n}\n"],"names":["formattingLocale","MAX_SCALE","decimalSeparators","Map","decimalSeparatorOf","locale","tag","known","get","undefined","separator","Intl","NumberFormat","formatToParts","find","part","type","value","set","groupedBy","RegExp","GROUPED","digitsOf","text","scale","test","last","Math","max","lastIndexOf","charAt","head","slice","tail","other","includes","replaceAll","parseScaled","compact","replace","sign","exec","digits","length","whole","fraction","magnitude","BigInt","padEnd","Number","MAX_SAFE_INTEGER","scaledToDecimal","isSafeInteger","RangeError","String","abs","padStart","at","formatScaled","grouping","decimal","split","minimumFractionDigits","maximumFractionDigits","format"],"mappings":"AAAA,SAASA,gBAAgB,QAAqB,eAAe;AAE7D;;;CAGC,GACD,OAAO,MAAMC,YAAY,GAAG;AAE5B,MAAMC,oBAAoB,IAAIC;AAE9B,qDAAqD,GACrD,SAASC,mBAAmBC,MAAc;QAKtC;IAJF,MAAMC,MAAMN,iBAAiBK;IAC7B,MAAME,QAAQL,kBAAkBM,GAAG,CAACF;IACpC,IAAIC,UAAUE,WAAW,OAAOF;IAChC,MAAMG,YACJ,EAAA,sBAAA,IAAIC,KAAKC,YAAY,CAACN,KACnBO,aAAa,CAAC,KACdC,IAAI,CAACC,CAAAA,OAAQA,KAAKC,IAAI,KAAK,+BAF9B,oBAE0CC,KAAK,MAAK,MAChD,MACA;IACNf,kBAAkBgB,GAAG,CAACZ,KAAKI;IAC3B,OAAOA;AACT;AAEA,sEAAsE,GACtE,MAAMS,YAAY,CAACT,YACjB,IAAIU,OAAO,CAAC,mBAAmB,EAAEV,UAAU,SAAS,CAAC;AAEvD,MAAMW,UAAU;IAAE,KAAKF,UAAU;IAAM,KAAKA,UAAU;AAAK;AAE3D;;;CAGC,GACD,SAASG,SACPC,IAAY,EACZC,KAAa,EACbnB,MAAc;IAEd,IAAI,CAAC,YAAYoB,IAAI,CAACF,SAAS,CAAC,KAAKE,IAAI,CAACF,OAAO,OAAOd;IACxD,MAAMiB,OAAOC,KAAKC,GAAG,CAACL,KAAKM,WAAW,CAAC,MAAMN,KAAKM,WAAW,CAAC;IAC9D,IAAIH,SAAS,CAAC,GAAG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,mBAAI;IAClD,6EAA6E;IAC7E,yEAAyE;IACzE,wDAAwD;IACxD,OAAO,IAAIhC,KAAKC,YAAY,CAACN,KAAK;QAChCwD,uBAAuBjB;QACvBkB,uBAAuBlB;IACzB,GAAGmB,MAAM,CAACJ;AACZ"}
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export * from './i18n/format.js';
31
31
  export * from './i18n/locales.js';
32
32
  export * from './i18n/localized-text.js';
33
33
  export * from './i18n/negotiate.js';
34
+ export * from './i18n/scaled-number.js';
34
35
  export * from './idempotency/index.js';
35
36
  export * from './query/fold.js';
36
37
  export * from './query/in-memory-query.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kDAAkD,CAAC;AACjE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kDAAkD,CAAC;AACjE,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uDAAuD,CAAC;AACtE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,wDAAwD,CAAC;AACvE,cAAc,wDAAwD,CAAC;AACvE,cAAc,0DAA0D,CAAC;AACzE,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAA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,CAAC;AACvE,cAAc,wDAAwD,CAAC;AACvE,cAAc,0DAA0D,CAAC;AACzE,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ export * from './i18n/format.js';
31
31
  export * from './i18n/locales.js';
32
32
  export * from './i18n/localized-text.js';
33
33
  export * from './i18n/negotiate.js';
34
+ export * from './i18n/scaled-number.js';
34
35
  export * from './idempotency/index.js';
35
36
  export * from './query/fold.js';
36
37
  export * from './query/in-memory-query.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './base-entities/configuration-client/index.js';\nexport * from './command-palette/index.js';\nexport * from './deadline/deadline.js';\nexport * from './endpoint/index.js';\nexport * from './entity-definition/decorators/accessor/index.js';\nexport * from './entity-definition/decorators/entity/index.js';\nexport * from './entity-definition/decorators/method/index.js';\nexport * from './entity-definition/decorators/use-case/index.js';\nexport * from './entity-definition/describe/index.js';\nexport * from './entity-definition/field-path.js';\nexport * from './entity-definition/helpers/index.js';\nexport * from './entity-definition/links/apply-entity-links/index.js';\nexport * from './entity-definition/links/entity-collection-link/index.js';\nexport * from './entity-definition/links/entity-link/index.js';\nexport * from './entity-definition/links/entity-link-source/index.js';\nexport * from './entity-definition/links/link-targets/index.js';\nexport * from './entity-definition/meta-entities/meta-accessor/index.js';\nexport * from './entity-definition/meta-entities/meta-entity/index.js';\nexport * from './entity-definition/meta-entities/meta-method/index.js';\nexport * from './entity-definition/meta-entities/meta-use-case/index.js';\nexport * from './entity-definition/metadata/index.js';\nexport * from './entity-definition/reconstruct/index.js';\nexport * from './entity-definition/revision.js';\nexport * from './entity-definition/serializer/index.js';\nexport * from './entity-definition/validate/index.js';\nexport * from './envelope/index.js';\nexport * from './failure/index.js';\nexport * from './hierarchy/index.js';\nexport * from './http/session-cookies.js';\nexport * from './i18n/format.js';\nexport * from './i18n/locales.js';\nexport * from './i18n/localized-text.js';\nexport * from './i18n/negotiate.js';\nexport * from './idempotency/index.js';\nexport * from './query/fold.js';\nexport * from './query/in-memory-query.js';\nexport * from './rsql/index.js';\nexport * from './shortcut/chord.js';\nexport * from './types/BulkOutcome.js';\nexport * from './types/Entity.js';\nexport * from './types/EntityAction.js';\nexport * from './types/EntityDraft.js';\nexport * from './types/EntityFacets.js';\nexport * from './types/EntityFiltering.js';\nexport * from './types/EntityLoadRequest.js';\nexport * from './types/EntityPage.js';\nexport * from './types/EntityRowDraft.js';\nexport * from './types/EntitySelection.js';\nexport * from './types/EntitySorting.js';\nexport * from './types/Json.js';\nexport * from './types/StandardSchema.js';\nexport * from './types/UseCase.js';\nexport * from './use-case-runner/index.js';\nexport * from './wizard/index.js';\n"],"names":[],"mappings":"AAAA,cAAc,gDAAgD;AAC9D,cAAc,6BAA6B;AAC3C,cAAc,yBAAyB;AACvC,cAAc,sBAAsB;AACpC,cAAc,mDAAmD;AACjE,cAAc,iDAAiD;AAC/D,cAAc,iDAAiD;AAC/D,cAAc,mDAAmD;AACjE,cAAc,wCAAwC;AACtD,cAAc,oCAAoC;AAClD,cAAc,uCAAuC;AACrD,cAAc,wDAAwD;AACtE,cAAc,4DAA4D;AAC1E,cAAc,iDAAiD;AAC/D,cAAc,wDAAwD;AACtE,cAAc,kDAAkD;AAChE,cAAc,2DAA2D;AACzE,cAAc,yDAAyD;AACvE,cAAc,yDAAyD;AACvE,cAAc,2DAA2D;AACzE,cAAc,wCAAwC;AACtD,cAAc,2CAA2C;AACzD,cAAc,kCAAkC;AAChD,cAAc,0CAA0C;AACxD,cAAc,wCAAwC;AACtD,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,4BAA4B;AAC1C,cAAc,mBAAmB;AACjC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,0BAA0B;AACxC,cAAc,6BAA6B;AAC3C,cAAc,+BAA+B;AAC7C,cAAc,wBAAwB;AACtC,cAAc,4BAA4B;AAC1C,cAAc,6BAA6B;AAC3C,cAAc,2BAA2B;AACzC,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,qBAAqB;AACnC,cAAc,6BAA6B;AAC3C,cAAc,oBAAoB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './base-entities/configuration-client/index.js';\nexport * from './command-palette/index.js';\nexport * from './deadline/deadline.js';\nexport * from './endpoint/index.js';\nexport * from './entity-definition/decorators/accessor/index.js';\nexport * from './entity-definition/decorators/entity/index.js';\nexport * from './entity-definition/decorators/method/index.js';\nexport * from './entity-definition/decorators/use-case/index.js';\nexport * from './entity-definition/describe/index.js';\nexport * from './entity-definition/field-path.js';\nexport * from './entity-definition/helpers/index.js';\nexport * from './entity-definition/links/apply-entity-links/index.js';\nexport * from './entity-definition/links/entity-collection-link/index.js';\nexport * from './entity-definition/links/entity-link/index.js';\nexport * from './entity-definition/links/entity-link-source/index.js';\nexport * from './entity-definition/links/link-targets/index.js';\nexport * from './entity-definition/meta-entities/meta-accessor/index.js';\nexport * from './entity-definition/meta-entities/meta-entity/index.js';\nexport * from './entity-definition/meta-entities/meta-method/index.js';\nexport * from './entity-definition/meta-entities/meta-use-case/index.js';\nexport * from './entity-definition/metadata/index.js';\nexport * from './entity-definition/reconstruct/index.js';\nexport * from './entity-definition/revision.js';\nexport * from './entity-definition/serializer/index.js';\nexport * from './entity-definition/validate/index.js';\nexport * from './envelope/index.js';\nexport * from './failure/index.js';\nexport * from './hierarchy/index.js';\nexport * from './http/session-cookies.js';\nexport * from './i18n/format.js';\nexport * from './i18n/locales.js';\nexport * from './i18n/localized-text.js';\nexport * from './i18n/negotiate.js';\nexport * from './i18n/scaled-number.js';\nexport * from './idempotency/index.js';\nexport * from './query/fold.js';\nexport * from './query/in-memory-query.js';\nexport * from './rsql/index.js';\nexport * from './shortcut/chord.js';\nexport * from './types/BulkOutcome.js';\nexport * from './types/Entity.js';\nexport * from './types/EntityAction.js';\nexport * from './types/EntityDraft.js';\nexport * from './types/EntityFacets.js';\nexport * from './types/EntityFiltering.js';\nexport * from './types/EntityLoadRequest.js';\nexport * from './types/EntityPage.js';\nexport * from './types/EntityRowDraft.js';\nexport * from './types/EntitySelection.js';\nexport * from './types/EntitySorting.js';\nexport * from './types/Json.js';\nexport * from './types/StandardSchema.js';\nexport * from './types/UseCase.js';\nexport * from './use-case-runner/index.js';\nexport * from './wizard/index.js';\n"],"names":[],"mappings":"AAAA,cAAc,gDAAgD;AAC9D,cAAc,6BAA6B;AAC3C,cAAc,yBAAyB;AACvC,cAAc,sBAAsB;AACpC,cAAc,mDAAmD;AACjE,cAAc,iDAAiD;AAC/D,cAAc,iDAAiD;AAC/D,cAAc,mDAAmD;AACjE,cAAc,wCAAwC;AACtD,cAAc,oCAAoC;AAClD,cAAc,uCAAuC;AACrD,cAAc,wDAAwD;AACtE,cAAc,4DAA4D;AAC1E,cAAc,iDAAiD;AAC/D,cAAc,wDAAwD;AACtE,cAAc,kDAAkD;AAChE,cAAc,2DAA2D;AACzE,cAAc,yDAAyD;AACvE,cAAc,yDAAyD;AACvE,cAAc,2DAA2D;AACzE,cAAc,wCAAwC;AACtD,cAAc,2CAA2C;AACzD,cAAc,kCAAkC;AAChD,cAAc,0CAA0C;AACxD,cAAc,wCAAwC;AACtD,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,4BAA4B;AAC1C,cAAc,mBAAmB;AACjC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,sBAAsB;AACpC,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,0BAA0B;AACxC,cAAc,6BAA6B;AAC3C,cAAc,+BAA+B;AAC7C,cAAc,wBAAwB;AACtC,cAAc,4BAA4B;AAC1C,cAAc,6BAA6B;AAC3C,cAAc,2BAA2B;AACzC,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,qBAAqB;AACnC,cAAc,6BAA6B;AAC3C,cAAc,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/core",
3
- "version": "0.23.6",
3
+ "version": "0.23.8",
4
4
  "description": "The entity system: decorators that make a class describe itself, entity serialization, the RSQL query protocol and the wire envelopes.",
5
5
  "license": "MIT",
6
6
  "repository": {