@webda/models 4.0.0-beta.8 → 4.0.0-beta.9

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.
@@ -0,0 +1,365 @@
1
+ /**
2
+ * Own Metadata of a class: a subclass without its own Metadata does not inherit its parent's identifier
3
+ * @param clazz - the class
4
+ * @returns its own Metadata
5
+ */
6
+ function ownMetadata(clazz) {
7
+ return clazz && Object.prototype.hasOwnProperty.call(clazz, "Metadata") ? clazz.Metadata : undefined;
8
+ }
9
+ /**
10
+ * Add a class to a multi-valued index
11
+ * @param index - the index
12
+ * @param key - the key
13
+ * @param clazz - the class
14
+ */
15
+ function addTo(index, key, clazz) {
16
+ let set = index.get(key);
17
+ if (!set) {
18
+ set = new Set();
19
+ index.set(key, set);
20
+ }
21
+ set.add(clazz);
22
+ }
23
+ /**
24
+ * Resolve the `__type` stored in a row (Webda 3 short, lower-case or renamed forms included) to a model
25
+ *
26
+ * Resolution order, first match wins:
27
+ * 1. the exact identifier (or a map key that is not the identifier);
28
+ * 2. a `@WebdaAlias`, exact, then case-insensitive;
29
+ * 3. an identifier, case-insensitive;
30
+ * 4. for a value without `/`: `<namespace>/<value>` then `Webda/<value>`, case-insensitive, identifiers then aliases;
31
+ * 5. otherwise unknown.
32
+ *
33
+ * Two different models matching at the same step make the value ambiguous: it resolves to nothing.
34
+ */
35
+ export class ModelTypeResolver {
36
+ /**
37
+ * @param models - models by identifier (an application model map), or a list of classes carrying Metadata
38
+ * @param options - namespace and exact mode
39
+ */
40
+ constructor(models, options = {}) {
41
+ /** Exact names (identifiers and extra map keys) to class */
42
+ this.byName = new Map();
43
+ /** Current identifier of each class */
44
+ this.identifiers = new Map();
45
+ /** Map keys of a class that are not its identifier */
46
+ this.extraNames = new Map();
47
+ /** Lower-case identifiers and extra names */
48
+ this.lowerNames = new Map();
49
+ /** Aliases */
50
+ this.aliases = new Map();
51
+ /** Lower-case aliases */
52
+ this.lowerAliases = new Map();
53
+ /** Cache of resolutions */
54
+ this.resolutions = new Map();
55
+ /** Cache of families */
56
+ this.families = new Map();
57
+ /** Cache of accepted types */
58
+ this.accepted = new Map();
59
+ this.namespace = options.namespace ?? "Webda";
60
+ this.exactOnly = options.exactOnly ?? false;
61
+ const entries = Array.isArray(models)
62
+ ? models.filter(Boolean).map(model => [undefined, model])
63
+ : Object.entries(models).filter(([, model]) => !!model);
64
+ for (const [key, clazz] of entries) {
65
+ const identifier = ownMetadata(clazz)?.Identifier ?? key;
66
+ if (!identifier)
67
+ continue;
68
+ this.addName(identifier, clazz, false);
69
+ if (key && key !== identifier) {
70
+ this.addName(key, clazz, true);
71
+ }
72
+ }
73
+ }
74
+ /**
75
+ * Index a name of a class
76
+ * @param name - identifier or extra name
77
+ * @param clazz - the class
78
+ * @param extra - true for a map key that is not the identifier
79
+ */
80
+ addName(name, clazz, extra) {
81
+ if (!this.byName.has(name)) {
82
+ this.byName.set(name, clazz);
83
+ }
84
+ addTo(this.lowerNames, name.toLowerCase(), clazz);
85
+ if (extra) {
86
+ this.extraNames.set(clazz, [...(this.extraNames.get(clazz) ?? []), name]);
87
+ return;
88
+ }
89
+ if (!this.identifiers.has(clazz)) {
90
+ this.identifiers.set(clazz, name);
91
+ }
92
+ for (const alias of ownMetadata(clazz)?.Aliases ?? []) {
93
+ addTo(this.aliases, alias, clazz);
94
+ addTo(this.lowerAliases, alias.toLowerCase(), clazz);
95
+ }
96
+ }
97
+ /**
98
+ * Resolver of the hierarchy of a model only, exact identifiers only
99
+ *
100
+ * Used for repositories whose model is not part of the installed application: today's exact matching.
101
+ * @param model - the model
102
+ * @returns the resolver
103
+ */
104
+ static forHierarchy(model) {
105
+ if (!model) {
106
+ return new ModelTypeResolver({}, { exactOnly: true });
107
+ }
108
+ const classes = [];
109
+ const queue = [model];
110
+ while (queue.length) {
111
+ const clazz = queue.shift();
112
+ if (!clazz || classes.includes(clazz))
113
+ continue;
114
+ classes.push(clazz);
115
+ queue.push(...(clazz.Metadata?.Subclasses ?? []).filter((sub) => typeof sub === "function"));
116
+ }
117
+ for (let parent = Object.getPrototypeOf(model); parent && parent !== Function.prototype; parent = Object.getPrototypeOf(parent)) {
118
+ if (ownMetadata(parent)?.Identifier)
119
+ classes.push(parent);
120
+ }
121
+ const record = {};
122
+ for (const clazz of classes) {
123
+ // The repository model may inherit its Metadata (a bare subclass used directly)
124
+ const identifier = (clazz === model ? clazz.Metadata : ownMetadata(clazz))?.Identifier;
125
+ if (identifier && !record[identifier])
126
+ record[identifier] = clazz;
127
+ }
128
+ return new ModelTypeResolver(record, { exactOnly: true });
129
+ }
130
+ /**
131
+ * @param model - a class
132
+ * @returns true when the class is one of the models of this resolver
133
+ */
134
+ knows(model) {
135
+ return this.identifiers.has(model);
136
+ }
137
+ /**
138
+ * @param model - a class
139
+ * @returns its current identifier, undefined when the class is not known
140
+ */
141
+ getIdentifier(model) {
142
+ return this.identifiers.get(model);
143
+ }
144
+ /**
145
+ * Resolve a stored `__type`
146
+ * @param stored - the stored value
147
+ * @returns the resolution
148
+ */
149
+ resolve(stored) {
150
+ let resolution = this.resolutions.get(stored);
151
+ if (!resolution) {
152
+ resolution = this.computeResolution(stored);
153
+ this.resolutions.set(stored, resolution);
154
+ }
155
+ return resolution;
156
+ }
157
+ /**
158
+ * @param stored - the stored value
159
+ * @returns the model, undefined when unknown or ambiguous
160
+ */
161
+ resolveStoredType(stored) {
162
+ return this.resolve(stored).model;
163
+ }
164
+ /**
165
+ * Run the resolution steps
166
+ * @param stored - the stored value
167
+ * @returns the resolution
168
+ */
169
+ computeResolution(stored) {
170
+ if (typeof stored !== "string" || stored === "") {
171
+ return { status: "unknown" };
172
+ }
173
+ const exact = this.byName.get(stored);
174
+ if (exact) {
175
+ return this.found(stored, exact);
176
+ }
177
+ if (this.exactOnly) {
178
+ return { status: "unknown" };
179
+ }
180
+ const lower = stored.toLowerCase();
181
+ const steps = [
182
+ this.aliases.get(stored),
183
+ this.lowerAliases.get(lower),
184
+ this.lowerNames.get(lower)
185
+ ];
186
+ if (!stored.includes("/")) {
187
+ // Webda 3 completeNamespace order: the application namespace first, then Webda
188
+ for (const namespace of new Set([this.namespace, "Webda"])) {
189
+ const name = `${namespace}/${stored}`.toLowerCase();
190
+ steps.push(this.lowerNames.get(name), this.lowerAliases.get(name));
191
+ }
192
+ }
193
+ for (const step of steps) {
194
+ if (!step || step.size === 0)
195
+ continue;
196
+ if (step.size > 1) {
197
+ return {
198
+ status: "ambiguous",
199
+ candidates: [...step].map(clazz => this.identifiers.get(clazz)).sort()
200
+ };
201
+ }
202
+ return this.found(stored, [...step][0]);
203
+ }
204
+ return { status: "unknown" };
205
+ }
206
+ /**
207
+ * @param stored - the stored value
208
+ * @param model - the matched model
209
+ * @returns the resolution of a match
210
+ */
211
+ found(stored, model) {
212
+ const identifier = this.identifiers.get(model);
213
+ return { status: stored === identifier ? "current" : "legacy", model, identifier };
214
+ }
215
+ /**
216
+ * The model and all its transitive subclasses: from `Metadata.Subclasses` (direct only), then any known class
217
+ * extending the model that the metadata does not list
218
+ * @param model - the model
219
+ * @returns the model first, then its subclasses
220
+ */
221
+ family(model) {
222
+ let family = this.families.get(model);
223
+ if (family)
224
+ return family;
225
+ family = [];
226
+ const queue = [model];
227
+ while (queue.length) {
228
+ const clazz = queue.shift();
229
+ if (!clazz || family.includes(clazz))
230
+ continue;
231
+ family.push(clazz);
232
+ for (const sub of clazz.Metadata?.Subclasses ?? []) {
233
+ queue.push(typeof sub === "string" ? this.byName.get(sub) : sub);
234
+ }
235
+ }
236
+ for (const clazz of this.identifiers.keys()) {
237
+ if (!family.includes(clazz) && clazz.prototype instanceof model) {
238
+ family.push(clazz);
239
+ }
240
+ }
241
+ this.families.set(model, family);
242
+ return family;
243
+ }
244
+ /**
245
+ * @param model - the model
246
+ * @returns the current identifiers of the model and its transitive subclasses
247
+ */
248
+ identifiersOf(model) {
249
+ const identifiers = [];
250
+ for (const clazz of this.family(model)) {
251
+ const identifier = this.identifiers.get(clazz) ?? clazz.Metadata?.Identifier;
252
+ if (identifier && !identifiers.includes(identifier))
253
+ identifiers.push(identifier);
254
+ }
255
+ return identifiers;
256
+ }
257
+ /**
258
+ * Every stored string that resolves to the model or one of its transitive subclasses: identifiers, short names,
259
+ * lower-case forms, aliases and their short and lower-case forms
260
+ * @param model - the model
261
+ * @returns the strings, deduplicated
262
+ */
263
+ acceptedTypes(model) {
264
+ let accepted = this.accepted.get(model);
265
+ if (accepted)
266
+ return accepted;
267
+ accepted = [];
268
+ for (const clazz of this.family(model)) {
269
+ const identifier = this.identifiers.get(clazz);
270
+ if (!identifier)
271
+ continue;
272
+ const names = [identifier, ...(this.extraNames.get(clazz) ?? []), ...(ownMetadata(clazz)?.Aliases ?? [])];
273
+ for (const name of names) {
274
+ const short = name.split("/").pop();
275
+ for (const candidate of [name, short, name.toLowerCase(), short.toLowerCase()]) {
276
+ if (!accepted.includes(candidate) && this.resolve(candidate).model === clazz) {
277
+ accepted.push(candidate);
278
+ }
279
+ }
280
+ }
281
+ }
282
+ this.accepted.set(model, accepted);
283
+ return accepted;
284
+ }
285
+ /**
286
+ * Whether a stored row belongs to a model
287
+ * @param model - the model queried
288
+ * @param stored - the stored `__type`, undefined for an untyped row
289
+ * @param tableRoot - the model owning the untyped rows of the table, when known
290
+ * @returns true when the row resolves to the model or one of its transitive subclasses; an untyped row belongs to
291
+ * the table root and its ancestors (to every model when the root is not known), and so does a row typed as a
292
+ * strict ancestor of the table root
293
+ */
294
+ belongsToModel(model, stored, tableRoot) {
295
+ const ownedByRoot = () => !tableRoot || tableRoot === model || tableRoot.prototype instanceof model;
296
+ if (stored === undefined || stored === null || stored === "") {
297
+ return ownedByRoot();
298
+ }
299
+ const resolved = this.resolveStoredType(stored);
300
+ if (resolved === undefined)
301
+ return false;
302
+ if (tableRoot && tableRoot.prototype instanceof resolved) {
303
+ // Typed as an ancestor of the table root (e.g. written before the application subclassed the model)
304
+ return ownedByRoot();
305
+ }
306
+ return this.family(model).includes(resolved);
307
+ }
308
+ }
309
+ /** Global slot: shared by every copy of this module loaded in the process */
310
+ const SLOT = Symbol.for("webda.models.typeResolver");
311
+ /** Resolver used when nothing is installed and no model is given */
312
+ let empty;
313
+ /**
314
+ * Install the resolver of the application (done by `@webda/core` when models load)
315
+ * @param resolver - the resolver, undefined to uninstall
316
+ */
317
+ export function setTypeResolver(resolver) {
318
+ globalThis[SLOT] = resolver;
319
+ }
320
+ /**
321
+ * @returns the installed resolver, if any
322
+ */
323
+ export function useTypeResolver() {
324
+ return globalThis[SLOT];
325
+ }
326
+ /**
327
+ * Resolver to use for a model: the installed one when it knows the model, else the model's own hierarchy (exact
328
+ * identifiers only)
329
+ * @param model - the model, if any
330
+ * @returns the resolver
331
+ */
332
+ export function getTypeResolver(model) {
333
+ const installed = useTypeResolver();
334
+ if (installed && (model === undefined || installed.knows(model))) {
335
+ return installed;
336
+ }
337
+ if (model !== undefined) {
338
+ return ModelTypeResolver.forHierarchy(model);
339
+ }
340
+ return (empty ??= new ModelTypeResolver({}, { exactOnly: true }));
341
+ }
342
+ /**
343
+ * @param stored - a stored `__type`
344
+ * @returns the model it resolves to with the installed resolver
345
+ */
346
+ export function resolveStoredType(stored) {
347
+ return getTypeResolver().resolveStoredType(stored);
348
+ }
349
+ /**
350
+ * @param model - the model
351
+ * @returns every stored string resolving to the model or a transitive subclass
352
+ */
353
+ export function acceptedTypes(model) {
354
+ return getTypeResolver(model).acceptedTypes(model);
355
+ }
356
+ /**
357
+ * @param model - the model
358
+ * @param stored - the stored `__type`
359
+ * @param tableRoot - the model owning the untyped rows
360
+ * @returns true when the row belongs to the model
361
+ */
362
+ export function belongsToModel(model, stored, tableRoot) {
363
+ return getTypeResolver(model).belongsToModel(model, stored, tableRoot);
364
+ }
365
+ //# sourceMappingURL=types-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-resolver.js","sourceRoot":"","sources":["../src/types-resolver.ts"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAU;IAC7B,O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AAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,iBAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,CAAC,KAAK,KAAK,IAAI,iBAAiB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,eAAe,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB,EAAE,MAAiC,EAAE,SAAsB;IACzG,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webda/models",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0-beta.9",
4
4
  "description": "Webda Models implementation",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -28,8 +28,8 @@
28
28
  "@webda/serialize": "^4.0.0-beta.7"
29
29
  },
30
30
  "peerDependencies": {
31
- "@webda/ql": "4.0.0-beta.7",
32
- "@webda/utils": "4.0.0-beta.8"
31
+ "@webda/ql": "4.0.0-beta.8",
32
+ "@webda/utils": "4.0.0-beta.9"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
@@ -41,9 +41,9 @@
41
41
  "type-fest": "^5.5.0",
42
42
  "vitest": "^4.1.2",
43
43
  "vite": "^6.0.0",
44
- "@webda/compiler": "^4.0.0-beta.8",
45
- "@webda/tsc-esm": "4.0.0-beta.8",
46
- "@webda/test": "^4.0.0-beta.7"
44
+ "@webda/test": "^4.0.0-beta.7",
45
+ "@webda/compiler": "^4.0.0-beta.9",
46
+ "@webda/tsc-esm": "4.0.0-beta.8"
47
47
  },
48
48
  "type": "module",
49
49
  "engines": {