@entifix/core 0.22.2 → 0.22.3

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.
@@ -34,6 +34,12 @@ export type RecordLabel = {
34
34
  * and a collection is many values.
35
35
  */
36
36
  export declare function canNameRecord(descriptor: EntityFieldDescriptor): boolean;
37
+ /**
38
+ * A member whose value reads as words — a `string` or a `localized`: only such
39
+ * a member names a record it was not declared to name. A table's open link and
40
+ * its sticky title follow the same rule, so a row never opens on "0" or "Paid".
41
+ */
42
+ export declare function isTextMember(descriptor: EntityFieldDescriptor): boolean;
37
43
  /**
38
44
  * What a record is called — the **one derivation** every surface that names a
39
45
  * record goes through: a row's title and checkbox, a card's heading, a confirm
@@ -1 +1 @@
1
- {"version":3,"file":"record-label.d.ts","sourceRoot":"","sources":["../../../src/entity-definition/describe/record-label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAEtC,yFAAyF;AACzF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAA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;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAyB7D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAOxE;AAgBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,iBAAiB,EAAE,gBAAgB,EACnC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,WAAW,CAyBb;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,MAAM,EACvD,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAC5C,MAAM,CAQR"}
@@ -36,7 +36,11 @@ function labelFrom(descriptor, value) {
36
36
  id: String(value)
37
37
  };
38
38
  }
39
- /** A member whose value reads as words: only such a member names a record undeclared. */ function isText(descriptor) {
39
+ /**
40
+ * A member whose value reads as words — a `string` or a `localized`: only such
41
+ * a member names a record it was not declared to name. A table's open link and
42
+ * its sticky title follow the same rule, so a row never opens on "0" or "Paid".
43
+ */ export function isTextMember(descriptor) {
40
44
  return descriptor.type === 'string' || descriptor.type === 'localized';
41
45
  }
42
46
  /**
@@ -64,7 +68,7 @@ function labelFrom(descriptor, value) {
64
68
  if (declared !== undefined && isFilled(declared, values[declared.name])) {
65
69
  return labelFrom(declared, values[declared.name]);
66
70
  }
67
- const undeclared = descriptors.find((descriptor)=>canNameRecord(descriptor) && isText(descriptor) && isFilled(descriptor, values[descriptor.name]));
71
+ const undeclared = descriptors.find((descriptor)=>canNameRecord(descriptor) && isTextMember(descriptor) && isFilled(descriptor, values[descriptor.name]));
68
72
  if (undeclared !== undefined) {
69
73
  return labelFrom(undeclared, values[undeclared.name]);
70
74
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/entity-definition/describe/record-label.ts"],"sourcesContent":["import type { Entity, EntityConstructor } from '../../types/Entity.js';\nimport { extractMetaEntity, findMetaEntity } from '../helpers/index.js';\nimport type { ChildConstructor } from '../meta-entities/meta-accessor/index.js';\nimport {\n COLLECTION_TYPES,\n describeEntityColumns,\n type EntityFieldDescriptor,\n} from './describe-entity-columns.js';\n\n/** How many characters of a long id a fallback label shows. A whole UUID never reads. */\nexport const SHORT_ID_LENGTH = 8;\n\n/**\n * What a record is called, before it is put into words. Core knows neither the\n * reader's locale nor the entity's translated noun, so it answers with what to\n * show and leaves the words to the presentation layer:\n *\n * - `value` — a member's own value, read through its descriptor (a localized\n * text in the reader's locale, a number formatted);\n * - `reference` — the name of the record another entity holds under `id`,\n * which the host's reference registry resolves;\n * - `fallback` — nothing names the record: the entity's noun with\n * {@link shortId} of its id, when it has one.\n */\nexport type RecordLabel =\n | {\n readonly kind: 'value';\n readonly member: EntityFieldDescriptor;\n readonly value: unknown;\n }\n | {\n readonly kind: 'reference';\n readonly member: EntityFieldDescriptor;\n readonly entity: string;\n readonly id: string;\n }\n | { readonly kind: 'fallback'; readonly shortId?: string };\n\nconst described = new WeakMap<ChildConstructor, EntityFieldDescriptor[]>();\n\nfunction descriptorsOf(target: ChildConstructor): EntityFieldDescriptor[] {\n let descriptors = described.get(target);\n if (descriptors === undefined) {\n descriptors = describeEntityColumns(target);\n described.set(target, descriptors);\n }\n return descriptors;\n}\n\n/** Holds something a person could read: not empty, and a localized text in at least one locale. */\nfunction isFilled(descriptor: EntityFieldDescriptor, value: unknown): boolean {\n if (value === undefined || value === null || value === '') return false;\n if (descriptor.type === 'localized') {\n return (\n typeof value === 'object' &&\n Object.values(value).some(text => typeof text === 'string' && text !== '')\n );\n }\n return true;\n}\n\n/**\n * Whether a member can name a record it was not declared to name. One that\n * holds a key or a list never can: an id, a reference and a link are keys,\n * and a collection is many values.\n */\nexport function canNameRecord(descriptor: EntityFieldDescriptor): boolean {\n return (\n descriptor.type !== 'id' &&\n descriptor.type !== 'link' &&\n descriptor.references === undefined &&\n !COLLECTION_TYPES.includes(descriptor.type)\n );\n}\n\nfunction labelFrom(\n descriptor: EntityFieldDescriptor,\n value: unknown,\n): RecordLabel {\n return descriptor.references === undefined\n ? { kind: 'value', member: descriptor, value }\n : {\n kind: 'reference',\n member: descriptor,\n entity: descriptor.references.entity,\n id: String(value),\n };\n}\n\n/** A member whose value reads as words: only such a member names a record undeclared. */\nfunction isText(descriptor: EntityFieldDescriptor): boolean {\n return descriptor.type === 'string' || descriptor.type === 'localized';\n}\n\n/**\n * What a record is called — the **one derivation** every surface that names a\n * record goes through: a row's title and checkbox, a card's heading, a confirm\n * dialog's object, a breadcrumb, a toast, the typed delete policy. In order:\n *\n * 1. the entity's declared `labelMember`, or the member it declares the card's\n * `title`, when filled in — a reference is answered as one, to resolve;\n * 2. the first filled-in **text** member — a `string` or a `localized` — that\n * is not a reference: a status, a payment method, a weight or a date is a\n * value the record holds, never what it is called, and an order named\n * \"card\" or a shipment named \"dispatched\" is the guess this replaced;\n * 3. the fallback: the noun and the id's {@link shortId}.\n *\n * `record` is read by member name, so an entity instance, a plain record and a\n * form's draft all work; a record not loaded yet is called by the noun alone.\n */\nexport function recordLabel(\n entityConstructor: ChildConstructor,\n record: object | undefined,\n): RecordLabel {\n const values = (record ?? {}) as Record<string, unknown>;\n const descriptors = descriptorsOf(entityConstructor);\n const declaredName =\n findMetaEntity(entityConstructor)?.labelMember ??\n descriptors.find(descriptor => descriptor.card === 'title')?.name;\n const declared = descriptors.find(\n descriptor => descriptor.name === declaredName,\n );\n if (declared !== undefined && isFilled(declared, values[declared.name])) {\n return labelFrom(declared, values[declared.name]);\n }\n const undeclared = descriptors.find(\n descriptor =>\n canNameRecord(descriptor) &&\n isText(descriptor) &&\n isFilled(descriptor, values[descriptor.name]),\n );\n if (undeclared !== undefined) {\n return labelFrom(undeclared, values[undeclared.name]);\n }\n const id = values['id'];\n return id === undefined || id === null || id === ''\n ? { kind: 'fallback' }\n : { kind: 'fallback', shortId: shortId(String(id)) };\n}\n\n/**\n * Ids no longer than this are quoted whole: `offering-12` cut to eight\n * characters would name every offering alike, while a UUID is never short.\n */\nexport const SHORT_ID_WHOLE = 12;\n\n/**\n * What a label quotes of an id when nothing names the record: a short id\n * whole, a long one cut to its first {@link SHORT_ID_LENGTH} characters.\n */\nexport function shortId(id: string): string {\n return id.length <= SHORT_ID_WHOLE ? id : id.slice(0, SHORT_ID_LENGTH);\n}\n\n/**\n * The `domain:key` an entity is referenced by — the pair its\n * `@entity({ domain, key })` declares, which is also its permission namespace.\n * Throws for an entity that declares only one of them: nothing could reference\n * it.\n */\nexport function entityReferenceKey<TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n): string {\n const { domain, key, name } = extractMetaEntity(entityConstructor);\n if (domain === undefined || key === undefined) {\n throw new Error(\n `${name} needs both a domain and a key to be referenced — a reference names its target as \"domain:key\".`,\n );\n }\n return `${domain}:${key}`;\n}\n"],"names":["extractMetaEntity","findMetaEntity","COLLECTION_TYPES","describeEntityColumns","SHORT_ID_LENGTH","described","WeakMap","descriptorsOf","target","descriptors","get","undefined","set","isFilled","descriptor","value","type","Object","values","some","text","canNameRecord","references","includes","labelFrom","kind","member","entity","id","String","isText","recordLabel","entityConstructor","record","declaredName","labelMember","find","card","name","declared","undeclared","shortId","SHORT_ID_WHOLE","length","slice","entityReferenceKey","domain","key","Error"],"mappings":"AACA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,sBAAsB;AAExE,SACEC,gBAAgB,EAChBC,qBAAqB,QAEhB,+BAA+B;AAEtC,uFAAuF,GACvF,OAAO,MAAMC,kBAAkB,EAAE;AA4BjC,MAAMC,YAAY,IAAIC;AAEtB,SAASC,cAAcC,MAAwB;IAC7C,IAAIC,cAAcJ,UAAUK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IAAI,KAAK,6BAAnD5B,kBAA6D6B,IAAI;IACnE,MAAMC,WAAW9B,YAAY2B,IAAI,CAC/BtB,CAAAA,aAAcA,WAAWwB,IAAI,KAAKJ;IAEpC,IAAIK,aAAa5B,aAAaE,SAAS0B,UAAUrB,MAAM,CAACqB,SAASD,IAAI,CAAC,GAAG;QACvE,OAAOd,UAAUe,UAAUrB,MAAM,CAACqB,SAASD,IAAI,CAAC;IAClD;IACA,MAAME,aAAa/B,YAAY2B,IAAI,CACjCtB,CAAAA,aACEO,cAAcP,eACdgB,OAAOhB,eACPD,SAASC,YAAYI,MAAM,CAACJ,WAAWwB,IAAI,CAAC;IAEhD,IAAIE,eAAe7B,WAAW;QAC5B,OAAOa,UAAUgB,YAAYtB,MAAM,CAACsB,WAAWF,IAAI,CAAC;IACtD;IACA,MAAMV,KAAKV,MAAM,CAAC,KAAK;IACvB,OAAOU,OAAOjB,aAAaiB,OAAO,QAAQA,OAAO,KAC7C;QAAEH,MAAM;IAAW,IACnB;QAAEA,MAAM;QAAYgB,SAASA,QAAQZ,OAAOD;IAAK;AACvD;AAEA;;;CAGC,GACD,OAAO,MAAMc,iBAAiB,GAAG;AAEjC;;;CAGC,GACD,OAAO,SAASD,QAAQb,EAAU;IAChC,OAAOA,GAAGe,MAAM,IAAID,iBAAiBd,KAAKA,GAAGgB,KAAK,CAAC,GAAGxC;AACxD;AAEA;;;;;CAKC,GACD,OAAO,SAASyC,mBACdb,iBAA6C;IAE7C,MAAM,EAAEc,MAAM,EAAEC,GAAG,EAAET,IAAI,EAAE,GAAGtC,kBAAkBgC;IAChD,IAAIc,WAAWnC,aAAaoC,QAAQpC,WAAW;QAC7C,MAAM,IAAIqC,MACR,GAAGV,KAAK,+FAA+F,CAAC;IAE5G;IACA,OAAO,GAAGQ,OAAO,CAAC,EAAEC,KAAK;AAC3B"}
1
+ {"version":3,"sources":["../../../src/entity-definition/describe/record-label.ts"],"sourcesContent":["import type { Entity, EntityConstructor } from '../../types/Entity.js';\nimport { extractMetaEntity, findMetaEntity } from '../helpers/index.js';\nimport type { ChildConstructor } from '../meta-entities/meta-accessor/index.js';\nimport {\n COLLECTION_TYPES,\n describeEntityColumns,\n type EntityFieldDescriptor,\n} from './describe-entity-columns.js';\n\n/** How many characters of a long id a fallback label shows. A whole UUID never reads. */\nexport const SHORT_ID_LENGTH = 8;\n\n/**\n * What a record is called, before it is put into words. Core knows neither the\n * reader's locale nor the entity's translated noun, so it answers with what to\n * show and leaves the words to the presentation layer:\n *\n * - `value` — a member's own value, read through its descriptor (a localized\n * text in the reader's locale, a number formatted);\n * - `reference` — the name of the record another entity holds under `id`,\n * which the host's reference registry resolves;\n * - `fallback` — nothing names the record: the entity's noun with\n * {@link shortId} of its id, when it has one.\n */\nexport type RecordLabel =\n | {\n readonly kind: 'value';\n readonly member: EntityFieldDescriptor;\n readonly value: unknown;\n }\n | {\n readonly kind: 'reference';\n readonly member: EntityFieldDescriptor;\n readonly entity: string;\n readonly id: string;\n }\n | { readonly kind: 'fallback'; readonly shortId?: string };\n\nconst described = new WeakMap<ChildConstructor, EntityFieldDescriptor[]>();\n\nfunction descriptorsOf(target: ChildConstructor): EntityFieldDescriptor[] {\n let descriptors = described.get(target);\n if (descriptors === undefined) {\n descriptors = describeEntityColumns(target);\n described.set(target, descriptors);\n }\n return descriptors;\n}\n\n/** Holds something a person could read: not empty, and a localized text in at least one locale. */\nfunction isFilled(descriptor: EntityFieldDescriptor, value: unknown): boolean {\n if (value === undefined || value === null || value === '') return false;\n if (descriptor.type === 'localized') {\n return (\n typeof value === 'object' &&\n Object.values(value).some(text => typeof text === 'string' && text !== '')\n );\n }\n return true;\n}\n\n/**\n * Whether a member can name a record it was not declared to name. One that\n * holds a key or a list never can: an id, a reference and a link are keys,\n * and a collection is many values.\n */\nexport function canNameRecord(descriptor: EntityFieldDescriptor): boolean {\n return (\n descriptor.type !== 'id' &&\n descriptor.type !== 'link' &&\n descriptor.references === undefined &&\n !COLLECTION_TYPES.includes(descriptor.type)\n );\n}\n\nfunction labelFrom(\n descriptor: EntityFieldDescriptor,\n value: unknown,\n): RecordLabel {\n return descriptor.references === undefined\n ? { kind: 'value', member: descriptor, value }\n : {\n kind: 'reference',\n member: descriptor,\n entity: descriptor.references.entity,\n id: String(value),\n };\n}\n\n/**\n * A member whose value reads as words — a `string` or a `localized`: only such\n * a member names a record it was not declared to name. A table's open link and\n * its sticky title follow the same rule, so a row never opens on \"0\" or \"Paid\".\n */\nexport function isTextMember(descriptor: EntityFieldDescriptor): boolean {\n return descriptor.type === 'string' || descriptor.type === 'localized';\n}\n\n/**\n * What a record is called — the **one derivation** every surface that names a\n * record goes through: a row's title and checkbox, a card's heading, a confirm\n * dialog's object, a breadcrumb, a toast, the typed delete policy. In order:\n *\n * 1. the entity's declared `labelMember`, or the member it declares the card's\n * `title`, when filled in — a reference is answered as one, to resolve;\n * 2. the first filled-in **text** member — a `string` or a `localized` — that\n * is not a reference: a status, a payment method, a weight or a date is a\n * value the record holds, never what it is called, and an order named\n * \"card\" or a shipment named \"dispatched\" is the guess this replaced;\n * 3. the fallback: the noun and the id's {@link shortId}.\n *\n * `record` is read by member name, so an entity instance, a plain record and a\n * form's draft all work; a record not loaded yet is called by the noun alone.\n */\nexport function recordLabel(\n entityConstructor: ChildConstructor,\n record: object | undefined,\n): RecordLabel {\n const values = (record ?? {}) as Record<string, unknown>;\n const descriptors = descriptorsOf(entityConstructor);\n const declaredName =\n findMetaEntity(entityConstructor)?.labelMember ??\n descriptors.find(descriptor => descriptor.card === 'title')?.name;\n const declared = descriptors.find(\n descriptor => descriptor.name === declaredName,\n );\n if (declared !== undefined && isFilled(declared, values[declared.name])) {\n return labelFrom(declared, values[declared.name]);\n }\n const undeclared = descriptors.find(\n descriptor =>\n canNameRecord(descriptor) &&\n isTextMember(descriptor) &&\n isFilled(descriptor, values[descriptor.name]),\n );\n if (undeclared !== undefined) {\n return labelFrom(undeclared, values[undeclared.name]);\n }\n const id = values['id'];\n return id === undefined || id === null || id === ''\n ? { kind: 'fallback' }\n : { kind: 'fallback', shortId: shortId(String(id)) };\n}\n\n/**\n * Ids no longer than this are quoted whole: `offering-12` cut to eight\n * characters would name every offering alike, while a UUID is never short.\n */\nexport const SHORT_ID_WHOLE = 12;\n\n/**\n * What a label quotes of an id when nothing names the record: a short id\n * whole, a long one cut to its first {@link SHORT_ID_LENGTH} characters.\n */\nexport function shortId(id: string): string {\n return id.length <= SHORT_ID_WHOLE ? id : id.slice(0, SHORT_ID_LENGTH);\n}\n\n/**\n * The `domain:key` an entity is referenced by — the pair its\n * `@entity({ domain, key })` declares, which is also its permission namespace.\n * Throws for an entity that declares only one of them: nothing could reference\n * it.\n */\nexport function entityReferenceKey<TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n): string {\n const { domain, key, name } = extractMetaEntity(entityConstructor);\n if (domain === undefined || key === undefined) {\n throw new Error(\n `${name} needs both a domain and a key to be referenced — a reference names its target as \"domain:key\".`,\n );\n }\n return `${domain}:${key}`;\n}\n"],"names":["extractMetaEntity","findMetaEntity","COLLECTION_TYPES","describeEntityColumns","SHORT_ID_LENGTH","described","WeakMap","descriptorsOf","target","descriptors","get","undefined","set","isFilled","descriptor","value","type","Object","values","some","text","canNameRecord","references","includes","labelFrom","kind","member","entity","id","String","isTextMember","recordLabel","entityConstructor","record","declaredName","labelMember","find","card","name","declared","undeclared","shortId","SHORT_ID_WHOLE","length","slice","entityReferenceKey","domain","key","Error"],"mappings":"AACA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,sBAAsB;AAExE,SACEC,gBAAgB,EAChBC,qBAAqB,QAEhB,+BAA+B;AAEtC,uFAAuF,GACvF,OAAO,MAAMC,kBAAkB,EAAE;AA4BjC,MAAMC,YAAY,IAAIC;AAEtB,SAASC,cAAcC,MAAwB;IAC7C,IAAIC,cAAcJ,UAAUK,GAAG,CAACF;IAChC,IAAIC,gBAAgBE,WAAW;QAC7BF,cAAcN,sBAAsBK;QACpCH,UAAUO,GAAG,CAACJ,QAAQ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AcA,WAAWwB,IAAI,KAAKJ;IAEpC,IAAIK,aAAa5B,aAAaE,SAAS0B,UAAUrB,MAAM,CAACqB,SAASD,IAAI,CAAC,GAAG;QACvE,OAAOd,UAAUe,UAAUrB,MAAM,CAACqB,SAASD,IAAI,CAAC;IAClD;IACA,MAAME,aAAa/B,YAAY2B,IAAI,CACjCtB,CAAAA,aACEO,cAAcP,eACdgB,aAAahB,eACbD,SAASC,YAAYI,MAAM,CAACJ,WAAWwB,IAAI,CAAC;IAEhD,IAAIE,eAAe7B,WAAW;QAC5B,OAAOa,UAAUgB,YAAYtB,MAAM,CAACsB,WAAWF,IAAI,CAAC;IACtD;IACA,MAAMV,KAAKV,MAAM,CAAC,KAAK;IACvB,OAAOU,OAAOjB,aAAaiB,OAAO,QAAQA,OAAO,KAC7C;QAAEH,MAAM;IAAW,IACnB;QAAEA,MAAM;QAAYgB,SAASA,QAAQZ,OAAOD;IAAK;AACvD;AAEA;;;CAGC,GACD,OAAO,MAAMc,iBAAiB,GAAG;AAEjC;;;CAGC,GACD,OAAO,SAASD,QAAQb,EAAU;IAChC,OAAOA,GAAGe,MAAM,IAAID,iBAAiBd,KAAKA,GAAGgB,KAAK,CAAC,GAAGxC;AACxD;AAEA;;;;;CAKC,GACD,OAAO,SAASyC,mBACdb,iBAA6C;IAE7C,MAAM,EAAEc,MAAM,EAAEC,GAAG,EAAET,IAAI,EAAE,GAAGtC,kBAAkBgC;IAChD,IAAIc,WAAWnC,aAAaoC,QAAQpC,WAAW;QAC7C,MAAM,IAAIqC,MACR,GAAGV,KAAK,+FAA+F,CAAC;IAE5G;IACA,OAAO,GAAGQ,OAAO,CAAC,EAAEC,KAAK;AAC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/core",
3
- "version": "0.22.2",
3
+ "version": "0.22.3",
4
4
  "description": "The entity system: decorators that make a class describe itself, entity serialization, the RSQL query protocol and the wire envelopes.",
5
5
  "license": "MIT",
6
6
  "repository": {