@entifix/core 0.23.5 → 0.23.7
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 +1 -1
- package/dist/entity-definition/describe/describe-entity-columns.d.ts +3 -1
- package/dist/entity-definition/describe/describe-entity-columns.d.ts.map +1 -1
- package/dist/entity-definition/describe/describe-entity-columns.js +40 -0
- package/dist/entity-definition/describe/describe-entity-columns.js.map +1 -1
- package/dist/entity-definition/meta-entities/meta-accessor/meta-accessor.d.ts +27 -0
- package/dist/entity-definition/meta-entities/meta-accessor/meta-accessor.d.ts.map +1 -1
- package/dist/entity-definition/meta-entities/meta-accessor/meta-accessor.js +1 -0
- package/dist/entity-definition/meta-entities/meta-accessor/meta-accessor.js.map +1 -1
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/scaled-number.d.ts +34 -0
- package/dist/i18n/scaled-number.d.ts.map +1 -0
- package/dist/i18n/scaled-number.js +121 -0
- package/dist/i18n/scaled-number.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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":"
|
|
1
|
+
{"version":3,"file":"describe-entity-columns.d.ts","sourceRoot":"","sources":["../../../src/entity-definition/describe/describe-entity-columns.ts"],"names":[],"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M,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,KA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jB,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,IAA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AI,KAAKtF,YAAY,CAAC,IAAI;QAAEsF,MAAMjG,aAAaiG,IAAI;IAAC,GACjEjG,aAAakG,YAAY,KAAKvF,YAC9B,CAAC,IACD;QAAEuF,cAAclG,aAAakG,YAAY;IAAC;QAC9C5E,MAAM,GAAEtB,uBAAAA,aAAasB,MAAM,YAAnBtB,uBAAuB;OAC3BC,SAAS,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,wBAAwB,6BAA8B,CAAC;AACpE,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhF,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IA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,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;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;IACA;CACD,CAAU;AAqBX,OAAO,MAAMC;IAiCX,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,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,IA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B,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"}
|
package/dist/i18n/index.d.ts
CHANGED
package/dist/i18n/index.d.ts.map
CHANGED
|
@@ -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"}
|
package/dist/i18n/index.js
CHANGED
package/dist/i18n/index.js.map
CHANGED
|
@@ -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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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`, and `1,000` below scale 3);
|
|
19
|
+
* - at scale 3 and over, `1.500` could be fifteen hundred or one and a half:
|
|
20
|
+
* it is a fraction when `.` is the locale's decimal separator and refused
|
|
21
|
+
* when it is not.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseScaled(text: string, scale: number, locale: Locale): number | undefined;
|
|
24
|
+
/** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */
|
|
25
|
+
export declare function scaledToDecimal(value: number, scale: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* A scaled integer as the reader's locale writes it, with no more decimals
|
|
28
|
+
* than it has. With `grouping: false` it is the text to edit: Latin digits in
|
|
29
|
+
* the locale's decimal separator, which `parseScaled` reads back exactly.
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatScaled(value: number, scale: number, locale: Locale, { grouping }?: {
|
|
32
|
+
readonly grouping?: boolean;
|
|
33
|
+
}): string;
|
|
34
|
+
//# 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,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,SAAS,KAAK,CAAC;AA+D5B;;;;;;;;;;;;;;;GAeG;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,CAWR"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most decimals a scale can carry and still leave a safe integer room to
|
|
3
|
+
* count with.
|
|
4
|
+
*/ export const MAX_SCALE = 15;
|
|
5
|
+
const decimalSeparators = new Map();
|
|
6
|
+
/** The character `locale` writes before a fraction. */ function decimalSeparatorOf(locale) {
|
|
7
|
+
var _formatToParts_find;
|
|
8
|
+
const known = decimalSeparators.get(locale);
|
|
9
|
+
if (known !== undefined) return known;
|
|
10
|
+
const separator = ((_formatToParts_find = new Intl.NumberFormat(locale).formatToParts(1.5).find((part)=>part.type === 'decimal')) == null ? void 0 : _formatToParts_find.value) === ',' ? ',' : '.';
|
|
11
|
+
decimalSeparators.set(locale, separator);
|
|
12
|
+
return separator;
|
|
13
|
+
}
|
|
14
|
+
/** 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})+$`);
|
|
15
|
+
const GROUPED = {
|
|
16
|
+
',': groupedBy(','),
|
|
17
|
+
'.': groupedBy('.')
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The whole and fraction digits `text` writes, or `undefined` when it writes
|
|
21
|
+
* no number or could write two.
|
|
22
|
+
*/ function digitsOf(text, scale, locale) {
|
|
23
|
+
if (!/^[\d.,]+$/.test(text) || !/\d/.test(text)) return undefined;
|
|
24
|
+
const last = Math.max(text.lastIndexOf(','), text.lastIndexOf('.'));
|
|
25
|
+
if (last === -1) return [
|
|
26
|
+
text,
|
|
27
|
+
''
|
|
28
|
+
];
|
|
29
|
+
const separator = text.charAt(last);
|
|
30
|
+
const head = text.slice(0, last);
|
|
31
|
+
const tail = text.slice(last + 1);
|
|
32
|
+
const other = separator === ',' ? '.' : ',';
|
|
33
|
+
// Both separators: the last opens the fraction, the other groups.
|
|
34
|
+
if (head.includes(other)) {
|
|
35
|
+
return GROUPED[other].test(head) ? [
|
|
36
|
+
head.replaceAll(other, ''),
|
|
37
|
+
tail
|
|
38
|
+
] : undefined;
|
|
39
|
+
}
|
|
40
|
+
// One separator, repeated: it can only be grouping.
|
|
41
|
+
if (head.includes(separator)) {
|
|
42
|
+
return GROUPED[separator].test(text) ? [
|
|
43
|
+
text.replaceAll(separator, ''),
|
|
44
|
+
''
|
|
45
|
+
] : undefined;
|
|
46
|
+
}
|
|
47
|
+
if (GROUPED[separator].test(text)) {
|
|
48
|
+
// `1,000`: three decimals do not fit, so it can only be a thousand.
|
|
49
|
+
if (scale < 3) return [
|
|
50
|
+
head + tail,
|
|
51
|
+
''
|
|
52
|
+
];
|
|
53
|
+
// They fit, so it could be either. The reader's own decimal separator is
|
|
54
|
+
// the one this member is shown with; the other one is refused.
|
|
55
|
+
return separator === decimalSeparatorOf(locale) ? [
|
|
56
|
+
head,
|
|
57
|
+
tail
|
|
58
|
+
] : undefined;
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
head,
|
|
62
|
+
tail
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The integer `text` stands for in `scale` decimals — `'3,5'` at scale 3 is
|
|
67
|
+
* `3500` — or `undefined` when it stands for none. Read digit by digit and
|
|
68
|
+
* never through a float.
|
|
69
|
+
*
|
|
70
|
+
* **It never rounds and never guesses.** More decimals than the scale holds is
|
|
71
|
+
* not a number here, and neither is text with two readings:
|
|
72
|
+
*
|
|
73
|
+
* - either separator opens a fraction (`64,99`, `64.99`), because people type
|
|
74
|
+
* both whatever their locale;
|
|
75
|
+
* - grouping is accepted where it can only be grouping (`1.234,56`,
|
|
76
|
+
* `12.500.000`, and `1,000` below scale 3);
|
|
77
|
+
* - at scale 3 and over, `1.500` could be fifteen hundred or one and a half:
|
|
78
|
+
* it is a fraction when `.` is the locale's decimal separator and refused
|
|
79
|
+
* when it is not.
|
|
80
|
+
*/ export function parseScaled(text, scale, locale) {
|
|
81
|
+
var _ref;
|
|
82
|
+
var _exec;
|
|
83
|
+
const compact = text.replace(/[\s'’]/g, '');
|
|
84
|
+
const sign = (_ref = (_exec = /^[+-]/.exec(compact)) == null ? void 0 : _exec[0]) != null ? _ref : '';
|
|
85
|
+
const digits = digitsOf(compact.slice(sign.length), scale, locale);
|
|
86
|
+
if (digits === undefined) return undefined;
|
|
87
|
+
const [whole, fraction] = digits;
|
|
88
|
+
if (fraction.length > scale) return undefined;
|
|
89
|
+
const magnitude = BigInt(`${whole}${fraction.padEnd(scale, '0')}`);
|
|
90
|
+
if (magnitude > BigInt(Number.MAX_SAFE_INTEGER)) return undefined;
|
|
91
|
+
return magnitude === 0n ? 0 : Number(magnitude) * (sign === '-' ? -1 : 1);
|
|
92
|
+
}
|
|
93
|
+
/** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */ export function scaledToDecimal(value, scale) {
|
|
94
|
+
if (!Number.isSafeInteger(value)) {
|
|
95
|
+
throw new RangeError(`${String(value)} is not a scaled integer`);
|
|
96
|
+
}
|
|
97
|
+
const digits = String(Math.abs(value)).padStart(scale + 1, '0');
|
|
98
|
+
const at = digits.length - scale;
|
|
99
|
+
const fraction = digits.slice(at).replace(/0+$/, '');
|
|
100
|
+
return `${value < 0 ? '-' : ''}${digits.slice(0, at)}${fraction === '' ? '' : `.${fraction}`}`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A scaled integer as the reader's locale writes it, with no more decimals
|
|
104
|
+
* than it has. With `grouping: false` it is the text to edit: Latin digits in
|
|
105
|
+
* the locale's decimal separator, which `parseScaled` reads back exactly.
|
|
106
|
+
*/ export function formatScaled(value, scale, locale, { grouping = true } = {}) {
|
|
107
|
+
var _ref;
|
|
108
|
+
var _decimal_split_;
|
|
109
|
+
const decimal = scaledToDecimal(value, scale);
|
|
110
|
+
if (!grouping) return decimal.replace('.', decimalSeparatorOf(locale));
|
|
111
|
+
const fraction = (_ref = (_decimal_split_ = decimal.split('.')[1]) == null ? void 0 : _decimal_split_.length) != null ? _ref : 0;
|
|
112
|
+
// `format` takes a decimal string exactly (ES2023), so a long count is never
|
|
113
|
+
// rounded through a float on its way to the screen. The cast is for this
|
|
114
|
+
// package's `lib`, whose typings predate that overload.
|
|
115
|
+
return new Intl.NumberFormat(locale, {
|
|
116
|
+
minimumFractionDigits: fraction,
|
|
117
|
+
maximumFractionDigits: fraction
|
|
118
|
+
}).format(decimal);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=scaled-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/scaled-number.ts"],"sourcesContent":["import 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<Locale, string>();\n\n/** The character `locale` writes before a fraction. */\nfunction decimalSeparatorOf(locale: Locale): string {\n const known = decimalSeparators.get(locale);\n if (known !== undefined) return known;\n const separator =\n new Intl.NumberFormat(locale)\n .formatToParts(1.5)\n .find(part => part.type === 'decimal')?.value === ','\n ? ','\n : '.';\n decimalSeparators.set(locale, 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 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 // `1,000`: three decimals do not fit, so it can only be a thousand.\n if (scale < 3) return [head + tail, ''];\n // They fit, so it could be either. The reader's own decimal separator is\n // the one this member is shown with; the other one is refused.\n return separator === decimalSeparatorOf(locale) ? [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`, and `1,000` below scale 3);\n * - at scale 3 and over, `1.500` could be fifteen hundred or one and a half:\n * it is a fraction when `.` is the locale's decimal separator and refused\n * when it is not.\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 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(locale, {\n minimumFractionDigits: fraction,\n maximumFractionDigits: fraction,\n }).format(decimal as unknown as number);\n}\n"],"names":["MAX_SCALE","decimalSeparators","Map","decimalSeparatorOf","locale","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":"AAEA;;;CAGC,GACD,OAAO,MAAMA,YAAY,GAAG;AAE5B,MAAMC,oBAAoB,IAAIC;AAE9B,qDAAqD,GACrD,SAASC,mBAAmBC,MAAc;QAItC;IAHF,MAAMC,QAAQJ,kBAAkBK,GAAG,CAACF;IACpC,IAAIC,UAAUE,WAAW,OAAOF;IAChC,MAAMG,YACJ,EAAA,sBAAA,IAAIC,KAAKC,YAAY,CAACN,QACnBO,aAAa,CAAC,KACdC,IAAI,CAACC,CAAAA,OAAQA,KAAKC,IAAI,KAAK,+BAF9B,oBAE0CC,KAAK,MAAK,MAChD,MACA;IACNd,kBAAkBe,GAAG,CAACZ,QAAQI;IAC9B,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,EACblB,MAAc;IAEd,IAAI,CAAC,YAAYmB,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,OAAO;QAACH;QAAM;KAAG;IAClC,MAAMb,YAAYa,KAAKO,MAAM,CAACJ;IAC9B,MAAMK,OAAOR,KAAKS,KAAK,CAAC,GAAGN;IAC3B,MAAMO,OAAOV,KAAKS,KAAK,CAACN,OAAO;IAC/B,MAAMQ,QAAQxB,cAAc,MAAM,MAAM;IAExC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AAI,CAAA;AACzE;AAEA,2EAA2E,GAC3E,OAAO,SAASW,gBAAgBlC,KAAa,EAAEO,KAAa;IAC1D,IAAI,CAACyB,OAAOG,aAAa,CAACnC,QAAQ;QAChC,MAAM,IAAIoC,WAAW,GAAGC,OAAOrC,OAAO,wBAAwB,CAAC;IACjE;IACA,MAAMyB,SAASY,OAAO3B,KAAK4B,GAAG,CAACtC,QAAQuC,QAAQ,CAAChC,QAAQ,GAAG;IAC3D,MAAMiC,KAAKf,OAAOC,MAAM,GAAGnB;IAC3B,MAAMqB,WAAWH,OAAOV,KAAK,CAACyB,IAAIlB,OAAO,CAAC,OAAO;IACjD,OAAO,GAAGtB,QAAQ,IAAI,MAAM,KAAKyB,OAAOV,KAAK,CAAC,GAAGyB,MAC/CZ,aAAa,KAAK,KAAK,CAAC,CAAC,EAAEA,UAAU,EACrC;AACJ;AAEA;;;;CAIC,GACD,OAAO,SAASa,aACdzC,KAAa,EACbO,KAAa,EACblB,MAAc,EACd,EAAEqD,WAAW,IAAI,EAAmC,GAAG,CAAC,CAAC;;QAIxCC;IAFjB,MAAMA,UAAUT,gBAAgBlC,OAAOO;IACvC,IAAI,CAACmC,UAAU,OAAOC,QAAQrB,OAAO,CAAC,KAAKlC,mBAAmBC;IAC9D,MAAMuC,oBAAWe,kBAAAA,QAAQC,KAAK,CAAC,IAAI,CAAC,EAAE,qBAArBD,gBAAuBjB,MAAM,mBAAI;IAClD,6EAA6E;IAC7E,yEAAyE;IACzE,wDAAwD;IACxD,OAAO,IAAIhC,KAAKC,YAAY,CAACN,QAAQ;QACnCwD,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';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAA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AAsB,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