@acodeninja/persist 3.0.0-next.3 → 3.0.0-next.30

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.
Files changed (41) hide show
  1. package/README.md +60 -4
  2. package/docs/code-quirks.md +14 -14
  3. package/docs/defining-models.md +61 -0
  4. package/docs/http.openapi.yml +138 -0
  5. package/docs/{model-property-types.md → model-properties.md} +76 -43
  6. package/docs/models-as-properties.md +46 -46
  7. package/docs/search-queries.md +11 -13
  8. package/docs/storage-engines.md +19 -35
  9. package/docs/structured-queries.md +59 -48
  10. package/docs/transactions.md +6 -7
  11. package/exports/storage/http.js +3 -0
  12. package/exports/storage/s3.js +3 -0
  13. package/jest.config.cjs +8 -12
  14. package/package.json +2 -2
  15. package/src/Connection.js +750 -0
  16. package/src/Persist.js +29 -30
  17. package/src/Schema.js +175 -0
  18. package/src/{Query.js → data/FindIndex.js} +40 -24
  19. package/src/{type → data}/Model.js +107 -34
  20. package/src/data/Property.js +21 -0
  21. package/src/data/SearchIndex.js +106 -0
  22. package/src/{type/complex → data/properties}/ArrayType.js +5 -3
  23. package/src/{type/simple → data/properties}/BooleanType.js +3 -3
  24. package/src/{type/complex → data/properties}/CustomType.js +5 -5
  25. package/src/{type/simple → data/properties}/DateType.js +4 -4
  26. package/src/{type/simple → data/properties}/NumberType.js +3 -3
  27. package/src/{type/resolved → data/properties}/ResolvedType.js +3 -2
  28. package/src/{type/resolved → data/properties}/SlugType.js +1 -1
  29. package/src/{type/simple → data/properties}/StringType.js +3 -3
  30. package/src/{type → data/properties}/Type.js +13 -3
  31. package/src/engine/storage/HTTPStorageEngine.js +149 -253
  32. package/src/engine/storage/S3StorageEngine.js +108 -195
  33. package/src/engine/storage/StorageEngine.js +131 -549
  34. package/exports/engine/storage/file.js +0 -3
  35. package/exports/engine/storage/http.js +0 -3
  36. package/exports/engine/storage/s3.js +0 -3
  37. package/src/SchemaCompiler.js +0 -192
  38. package/src/Transactions.js +0 -145
  39. package/src/engine/StorageEngine.js +0 -319
  40. package/src/engine/storage/FileStorageEngine.js +0 -213
  41. package/src/type/index.js +0 -32
@@ -1,3 +0,0 @@
1
- import FileStorageEngine from '../../../src/engine/storage/FileStorageEngine.js';
2
-
3
- export default FileStorageEngine;
@@ -1,3 +0,0 @@
1
- import HTTPStorageEngine from '../../../src/engine/storage/HTTPStorageEngine.js';
2
-
3
- export default HTTPStorageEngine;
@@ -1,3 +0,0 @@
1
- import S3StorageEngine from '../../../src/engine/storage/S3StorageEngine.js';
2
-
3
- export default S3StorageEngine;
@@ -1,192 +0,0 @@
1
- import Type from './type/index.js';
2
- import ajv from 'ajv';
3
- import ajvErrors from 'ajv-errors';
4
- import ajvFormats from 'ajv-formats';
5
-
6
- /**
7
- * A class responsible for compiling raw schema definitions into a format that can be validated using the AJV (Another JSON Validator) library.
8
- */
9
- class SchemaCompiler {
10
- /**
11
- * Compiles a raw schema into a validation-ready schema, and returns a class that extends `CompiledSchema`.
12
- *
13
- * This method converts a given schema into a JSON schema-like format, setting up properties, types, formats, and validation rules.
14
- * It uses AJV for the validation process and integrates with model types and their specific validation rules.
15
- *
16
- * @param {Object|Model} rawSchema - The raw schema or model definition to be compiled.
17
- * @returns {CompiledSchema} - A class that extends `CompiledSchema`, with the compiled schema and validator attached.
18
- *
19
- * @example
20
- * const schemaClass = SchemaCompiler.compile(MyModelSchema);
21
- * const isValid = schemaClass.validate(data); // Throws ValidationError if data is invalid.
22
- */
23
- static compile(rawSchema) {
24
- const validation = new ajv({allErrors: true});
25
-
26
- ajvErrors(validation);
27
- ajvFormats(validation);
28
-
29
- const schema = {
30
- type: 'object',
31
- additionalProperties: false,
32
- properties: {},
33
- required: [],
34
- };
35
-
36
- if (Type.Model.isModel(rawSchema)) {
37
- schema.required.push('id');
38
- schema.properties.id = {type: 'string'};
39
- }
40
-
41
- for (const [name, type] of Object.entries(rawSchema)) {
42
- if (['indexedProperties', 'searchProperties'].includes(name)) continue;
43
-
44
- const property = type instanceof Function && !type.prototype ? type() : type;
45
-
46
- if (property?._required || property?._items?._type?._required)
47
- schema.required.push(name);
48
-
49
- if (Type.Model.isModel(property)) {
50
- schema.properties[name] = {
51
- type: 'object',
52
- additionalProperties: false,
53
- required: ['id'],
54
- properties: {
55
- id: {
56
- type: 'string',
57
- pattern: `^${property.toString()}/[A-Z0-9]+$`,
58
- },
59
- },
60
- };
61
- continue;
62
- }
63
-
64
- if (property?._schema) {
65
- schema.properties[name] = property._schema;
66
- continue;
67
- }
68
-
69
- schema.properties[name] = {type: property?._type};
70
-
71
- if (property?._format) {
72
- schema.properties[name].format = property._format;
73
- }
74
-
75
- if (property?._type === 'array') {
76
- schema.properties[name].items = {type: property?._items._type};
77
-
78
- if (property?._items?._format) {
79
- schema.properties[name].items.format = property?._items._format;
80
- }
81
-
82
- if (Type.Model.isModel(property?._items)) {
83
- schema.properties[name].items = {
84
- type: 'object',
85
- additionalProperties: false,
86
- required: ['id'],
87
- properties: {
88
- id: {
89
- type: 'string',
90
- pattern: `^${property?._items.toString()}/[A-Z0-9]+$`,
91
- },
92
- },
93
- };
94
- }
95
- }
96
- }
97
-
98
- class Schema extends CompiledSchema {
99
- /**
100
- * The compiled schema definition.
101
- * @type {Object}
102
- * @static
103
- * @private
104
- */
105
- static _schema = schema;
106
-
107
- /**
108
- * The AJV validator function compiled from the schema.
109
- * @type {Function}
110
- * @static
111
- * @private
112
- */
113
- static _validator = validation.compile(schema);
114
- }
115
-
116
- return Schema;
117
- }
118
- }
119
-
120
-
121
- /**
122
- * Represents a compiled schema used for validating data models.
123
- * This class provides a mechanism to validate data using a precompiled schema and a validator function.
124
- */
125
- export class CompiledSchema {
126
- /**
127
- * The schema definition for validation, typically a precompiled JSON schema or similar.
128
- * @type {?Object}
129
- * @static
130
- * @private
131
- */
132
- static _schema = null;
133
-
134
- /**
135
- * The validator function used to validate data against the schema.
136
- * @type {?Function}
137
- * @static
138
- * @private
139
- */
140
- static _validator = null;
141
-
142
- /**
143
- * Validates the given data against the compiled schema.
144
- *
145
- * If the data is an instance of a model, it will be converted to a plain object via `toData()` before validation.
146
- *
147
- * @param {Object|Model} data - The data or model instance to be validated.
148
- * @returns {boolean} - Returns `true` if the data is valid according to the schema.
149
- * @throws {ValidationError} - Throws a `ValidationError` if the data is invalid.
150
- */
151
- static validate(data) {
152
- let inputData = Object.assign({}, data);
153
-
154
- if (Type.Model.isModel(data)) {
155
- inputData = data.toData();
156
- }
157
-
158
- const valid = this._validator?.(inputData);
159
-
160
- if (valid) return valid;
161
-
162
- throw new ValidationError(inputData, this._validator.errors);
163
- }
164
- }
165
-
166
- /**
167
- * Represents a validation error that occurs when a model or data fails validation.
168
- * Extends the built-in JavaScript `Error` class.
169
- */
170
- export class ValidationError extends Error {
171
- /**
172
- * Creates an instance of `ValidationError`.
173
- *
174
- * @param {Object} data - The data that failed validation.
175
- * @param {Array<Object>} errors - A list of validation errors, each typically containing details about what failed.
176
- */
177
- constructor(data, errors) {
178
- super('Validation failed');
179
- /**
180
- * An array of validation errors, containing details about each failed validation.
181
- * @type {Array<Object>}
182
- */
183
- this.errors = errors;
184
- /**
185
- * The data that caused the validation error.
186
- * @type {Object}
187
- */
188
- this.data = data;
189
- }
190
- }
191
-
192
- export default SchemaCompiler;
@@ -1,145 +0,0 @@
1
- /**
2
- * Class representing a transaction-related error.
3
- *
4
- * @class TransactionError
5
- * @extends Error
6
- */
7
- class TransactionError extends Error {
8
- }
9
-
10
- /**
11
- * Error thrown when a transaction is already committed.
12
- *
13
- * @class TransactionCommittedError
14
- * @extends TransactionError
15
- */
16
- export class TransactionCommittedError extends TransactionError {
17
- /**
18
- * Creates an instance of TransactionCommittedError.
19
- * This error is thrown when attempting to commit an already committed transaction.
20
- * @property {string} message - The error message.
21
- */
22
- message = 'Transaction was already committed.';
23
- }
24
-
25
- /**
26
- * Enables transaction support for the provided engine.
27
- *
28
- * This function enhances an engine class with transaction capabilities, allowing multiple
29
- * changes to be grouped into a single transaction that can be committed or rolled back.
30
- *
31
- * @param {Engine.constructor} engine - The base engine class to be enhanced with transaction support.
32
- * @returns {TransactionalEngine.constructor} TransactionalEngine - The enhanced engine class with transaction functionality.
33
- */
34
- export default function enableTransactions(engine) {
35
- /**
36
- * A class representing an engine with transaction capabilities.
37
- * @class TransactionalEngine
38
- * @extends {engine}
39
- */
40
- class TransactionalEngine extends engine {
41
- }
42
-
43
- /**
44
- * Starts a transaction on the engine. Returns a Transaction class that can handle
45
- * put, commit, and rollback actions for the transaction.
46
- *
47
- * @returns {Transaction.constructor} Transaction - A class that manages the transaction's operations.
48
- */
49
- TransactionalEngine.start = () => {
50
- /**
51
- * A class representing an active transaction on the engine.
52
- * Contains methods to put changes, commit the transaction, or roll back in case of failure.
53
- *
54
- * @class Transaction
55
- */
56
- class Transaction extends TransactionalEngine {
57
- /**
58
- * @property {Array<Object>} transactions - An array storing all the operations within the transaction.
59
- * @static
60
- */
61
- static transactions = [];
62
-
63
- /**
64
- * @property {boolean} committed - Indicates if the transaction has been committed.
65
- * @static
66
- */
67
- static committed = false;
68
-
69
- /**
70
- * @property {boolean} failed - Indicates if the transaction has failed.
71
- * @static
72
- */
73
- static failed = false;
74
-
75
- /**
76
- * Adds a model to the transaction queue.
77
- *
78
- * @param {Object} model - The model to be added to the transaction.
79
- * @returns {Promise<void>} A promise that resolves once the model is added.
80
- */
81
- static put(model) {
82
- this.transactions.push({
83
- hasRun: false,
84
- hasRolledBack: false,
85
- model,
86
- });
87
-
88
- return Promise.resolve();
89
- }
90
-
91
- /**
92
- * Checks if the transaction has already been committed. If true, throws a TransactionCommittedError.
93
- *
94
- * @throws {TransactionCommittedError} If the transaction has already been committed.
95
- * @private
96
- */
97
- static _checkCommitted() {
98
- if (this.committed) throw new TransactionCommittedError();
99
- }
100
-
101
- /**
102
- * Commits the transaction, applying all the changes to the engine.
103
- * Rolls back if any part of the transaction fails.
104
- *
105
- * @returns {Promise<void>} A promise that resolves once the transaction is committed, or rejects if an error occurs.
106
- * @throws {Error} If any operation in the transaction fails.
107
- */
108
- static async commit() {
109
- this._checkCommitted();
110
-
111
- try {
112
- for (const [index, {model}] of this.transactions.entries()) {
113
- try {
114
- this.transactions[index].original = await engine.get(model.constructor, model.id);
115
- } catch (_error) {
116
- this.transactions[index].original = null;
117
- }
118
-
119
- await engine.put(model);
120
- this.transactions[index].hasRun = true;
121
- }
122
- } catch (e) {
123
- this.committed = true;
124
- this.failed = true;
125
- for (const [index, {original}] of this.transactions.entries()) {
126
- if (original) {
127
- await engine.put(this.transactions[index].original);
128
- }
129
- this.transactions[index].hasRolledBack = true;
130
- }
131
- throw e;
132
- }
133
-
134
- this.committed = true;
135
- this.failed = false;
136
- }
137
- }
138
-
139
- return Transaction;
140
- };
141
-
142
- Object.defineProperty(TransactionalEngine, 'name', {value: `${engine.toString()}`});
143
-
144
- return TransactionalEngine;
145
- }
@@ -1,319 +0,0 @@
1
- import Type from '../type/index.js';
2
- import _ from 'lodash';
3
-
4
- export default class StorageEngine {
5
- /**
6
- * @param {Object} configuration
7
- * @param {Array<Type.Model.constructor>?} models
8
- */
9
- constructor(configuration = {}, models = null) {
10
- this.configuration = configuration;
11
- this.models = Object.fromEntries((models ?? []).map(model => [model.name, model]));
12
- }
13
-
14
- /**
15
- * Persists a model if it has changed, and updates all related models and their indexes
16
- * @param {Type.Model} model
17
- * @return {Promise<void>}
18
- */
19
- async put(model) {
20
- const processedModels = [];
21
- const modelsToPut = [];
22
- const modelsToReindex = {};
23
- const modelsToReindexSearch = {};
24
-
25
- /**
26
- * @param {Type.Model} modelToProcess
27
- * @return {Promise<void>}
28
- */
29
- const processModel = async (modelToProcess) => {
30
- if (processedModels.includes(modelToProcess.id))
31
- return;
32
-
33
- processedModels.push(modelToProcess.id);
34
-
35
- if (!Object.keys(this.models).includes(modelToProcess.constructor.name))
36
- throw new ModelNotRegisteredStorageEngineError(modelToProcess, this);
37
-
38
- modelToProcess.validate();
39
- const currentModel = await this.get(modelToProcess.id).catch(() => null);
40
-
41
- const modelToProcessHasChanged = JSON.stringify(currentModel?.toData() || {}) !== JSON.stringify(modelToProcess.toData());
42
-
43
- if (modelToProcessHasChanged) modelsToPut.push(modelToProcess);
44
-
45
- if (
46
- Boolean(modelToProcess.constructor.indexedProperties().length) &&
47
- indexedFieldsHaveChanged(currentModel, modelToProcess)
48
- ) {
49
- const modelToProcessConstructor = this.getModelConstructorFromId(modelToProcess.id);
50
- modelsToReindex[modelToProcessConstructor] = modelsToReindex[modelToProcessConstructor] || [];
51
- modelsToReindex[modelToProcessConstructor].push(modelToProcess);
52
- }
53
-
54
- if (
55
- Boolean(modelToProcess.constructor.searchProperties().length) &&
56
- searchableFieldsHaveChanged(currentModel, modelToProcess)
57
- ) {
58
- const modelToProcessConstructor = this.getModelConstructorFromId(modelToProcess.id);
59
- modelsToReindexSearch[modelToProcessConstructor] = modelsToReindexSearch[modelToProcessConstructor] || [];
60
- modelsToReindexSearch[modelToProcessConstructor].push(modelToProcess);
61
- }
62
-
63
- for (const [field, value] of Object.entries(modelToProcess)) {
64
- if (Type.Model.isModel(value)) {
65
- await processModel(modelToProcess[field]);
66
- }
67
- }
68
- };
69
-
70
- await processModel(model);
71
-
72
- await Promise.all([
73
- Promise.all(modelsToPut.map(m => this._putModel(m.toData()))),
74
- Promise.all(Object.entries(modelsToReindex).map(async ([constructorName, models]) => {
75
- const modelConstructor = this.models[constructorName];
76
- const index = await this._getIndex(modelConstructor);
77
-
78
- await this._putIndex(modelConstructor, {
79
- ...index || {},
80
- ...Object.fromEntries(models.map(m => [m.id, m.toIndexData()])),
81
- });
82
- })),
83
- Promise.all(Object.entries(modelsToReindexSearch).map(async ([constructorName, models]) => {
84
- const modelConstructor = this.models[constructorName];
85
- const index = await this._getSearchIndex(modelConstructor);
86
-
87
- await this._putSearchIndex(modelConstructor, {
88
- ...index || {},
89
- ...Object.fromEntries(models.map(m => [m.id, m.toIndexData()])),
90
- });
91
- })),
92
- ]);
93
- }
94
-
95
- /**
96
- * Get a model by its id
97
- * @param {string} modelId
98
- * @return {Promise<void>}
99
- */
100
- get(modelId) {
101
- try {
102
- this.getModelConstructorFromId(modelId);
103
- } catch (e) {
104
- return Promise.reject(e);
105
- }
106
- return this._getModel(modelId);
107
- }
108
-
109
- /**
110
- * Get the model constructor from a model id
111
- * @param {string} modelId
112
- * @return {Model.constructor}
113
- */
114
- getModelConstructorFromId(modelId) {
115
- const modelName = modelId.split('/')[0];
116
- const constructor = this.models[modelName];
117
-
118
- if (!constructor) throw new ModelNotRegisteredStorageEngineError(modelName, this);
119
-
120
- return constructor;
121
- }
122
-
123
- /**
124
- * Get model classes that are directly linked to the given model in either direction
125
- * @param {Type.Model.constructor} model
126
- * @return {Record<string, Record<string, Type.Model.constructor>>}
127
- */
128
- getLinksFor(model) {
129
- return Object.fromEntries(
130
- Object.entries(this.getAllModelLinks())
131
- .filter(([modelName, links]) =>
132
- model.name === modelName ||
133
- Object.values(links).some((link) => link.name === model.name),
134
- ),
135
- );
136
- }
137
-
138
- /**
139
- * Get all model links
140
- * @return {Record<string, Record<string, Type.Model.constructor>>}
141
- */
142
- getAllModelLinks() {
143
- return Object.entries(this.models)
144
- .map(([registeredModelName, registeredModelClass]) =>
145
- Object.entries(registeredModelClass)
146
- .map(([propertyName, propertyType]) => [
147
- registeredModelName,
148
- propertyName,
149
- typeof propertyType === 'function' && !Type.Model.isModel(propertyType) ? propertyType() : propertyType,
150
- ])
151
- .filter(([_m, _p, type]) => Type.Model.isModel(type))
152
- .map(([containingModel, propertyName, propertyType]) => ({
153
- containingModel,
154
- propertyName,
155
- propertyType,
156
- })),
157
- )
158
- .flat()
159
- .reduce((accumulator, {containingModel, propertyName, propertyType}) => ({
160
- ...accumulator,
161
- [containingModel]: {
162
- ...accumulator[containingModel] || {},
163
- [propertyName]: propertyType,
164
- },
165
- }), {});
166
- }
167
-
168
- /**
169
- * Update a model
170
- * @param {Model} _model
171
- * @throws MethodNotImplementedStorageEngineError
172
- * @return Promise<void>
173
- */
174
- _putModel(_model) {
175
- return Promise.reject(new MethodNotImplementedStorageEngineError('_putModel', this));
176
- }
177
-
178
- /**
179
- * Get a model
180
- * @param {string} _id
181
- * @throws MethodNotImplementedStorageEngineError
182
- * @throws ModelNotFoundStorageEngineError
183
- * @return Promise<void>
184
- */
185
- _getModel(_id) {
186
- return Promise.reject(new MethodNotImplementedStorageEngineError('_getModel', this));
187
- }
188
-
189
- /**
190
- * Get a model's index data
191
- * @param {Model.constructor} _modelConstructor
192
- * @throws MethodNotImplementedStorageEngineError
193
- * @return Promise<void>
194
- */
195
- _getIndex(_modelConstructor) {
196
- return Promise.reject(new MethodNotImplementedStorageEngineError('_getIndex', this));
197
- }
198
-
199
- /**
200
- * Put a model's index data
201
- * @param {Model.constructor} _modelConstructor
202
- * @param {object} _data
203
- * @throws MethodNotImplementedStorageEngineError
204
- * @return Promise<void>
205
- */
206
- _putIndex(_modelConstructor, _data) {
207
- return Promise.reject(new MethodNotImplementedStorageEngineError('_putIndex', this));
208
- }
209
-
210
- /**
211
- * Get a model's raw search index data
212
- * @param {Model.constructor} _modelConstructor
213
- * @throws MethodNotImplementedStorageEngineError
214
- * @return Promise<void>
215
- */
216
- _getSearchIndex(_modelConstructor) {
217
- return Promise.reject(new MethodNotImplementedStorageEngineError('_getSearchIndex', this));
218
- }
219
-
220
- /**
221
- * Get a model's raw search index data
222
- * @param {Model.constructor} _modelConstructor
223
- * @throws MethodNotImplementedStorageEngineError
224
- * @return Promise<void>
225
- */
226
- _getSearchIndexCompiled(_modelConstructor) {
227
- return Promise.reject(new MethodNotImplementedStorageEngineError('_getSearchIndexCompiled', this));
228
- }
229
-
230
- /**
231
- * Put a model's raw and compiled search index data
232
- * @param {Model.constructor} _modelConstructor
233
- * @param {object} _data
234
- * @throws MethodNotImplementedStorageEngineError
235
- * @return Promise<void>
236
- */
237
- _putSearchIndex(_modelConstructor, _data) {
238
- return Promise.reject(new MethodNotImplementedStorageEngineError('_putSearchIndex', this));
239
- }
240
- }
241
-
242
- /**
243
- * Decide if two models indexable fields have changed
244
- * @param {Type.Model} currentModel
245
- * @param {Type.Model} modelToProcess
246
- * @return {boolean}
247
- * @private
248
- */
249
- function indexedFieldsHaveChanged(currentModel, modelToProcess) {
250
- return !currentModel || Boolean(
251
- modelToProcess.constructor.indexedProperties()
252
- .filter(field => JSON.stringify(_.get(currentModel, field)) !== JSON.stringify(_.get(modelToProcess, field)))
253
- .length,
254
- );
255
- }
256
-
257
- /**
258
- * Decide if two models searchable fields have changed
259
- * @param {Type.Model} currentModel
260
- * @param {Type.Model} modelToProcess
261
- * @return {boolean}
262
- * @private
263
- */
264
- function searchableFieldsHaveChanged(currentModel, modelToProcess) {
265
- return !currentModel || Boolean(
266
- modelToProcess.constructor.searchProperties()
267
- .filter(field => JSON.stringify(_.get(currentModel, field)) !== JSON.stringify(_.get(modelToProcess, field)))
268
- .length,
269
- );
270
- }
271
-
272
- /**
273
- * @class StorageEngineError
274
- * @extends Error
275
- */
276
- export class StorageEngineError extends Error {
277
- }
278
-
279
- /**
280
- * @class ModelNotRegisteredStorageEngineError
281
- * @extends StorageEngineError
282
- */
283
- export class ModelNotRegisteredStorageEngineError extends StorageEngineError {
284
- /**
285
- * @param {Type.Model} model
286
- * @param {StorageEngine} storageEngine
287
- */
288
- constructor(model, storageEngine) {
289
- const modelName = typeof model === 'string' ? model : model.constructor.name;
290
- super(`The model ${modelName} is not registered in the storage engine ${storageEngine.constructor.name}`);
291
- }
292
- }
293
-
294
- /**
295
- * @class MethodNotImplementedStorageEngineError
296
- * @extends StorageEngineError
297
- */
298
- export class MethodNotImplementedStorageEngineError extends StorageEngineError {
299
- /**
300
- * @param {string} method
301
- * @param {StorageEngine} storageEngine
302
- */
303
- constructor(method, storageEngine) {
304
- super(`The method ${method} is not implemented in the storage engine ${storageEngine.constructor.name}`);
305
- }
306
- }
307
-
308
- /**
309
- * @class ModelNotFoundStorageEngineError
310
- * @extends StorageEngineError
311
- */
312
- export class ModelNotFoundStorageEngineError extends StorageEngineError {
313
- /**
314
- * @param {string} modelId
315
- */
316
- constructor(modelId) {
317
- super(`The model ${modelId} was not found`);
318
- }
319
- }