@stonyx/orm 0.2.1-beta.92 → 0.2.1-beta.93
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/package.json +1 -1
- package/src/db.ts +1 -1
- package/src/setup-rest-server.ts +3 -3
- package/src/store.ts +2 -2
- package/src/view-resolver.ts +2 -2
package/package.json
CHANGED
package/src/db.ts
CHANGED
|
@@ -115,7 +115,7 @@ export default class DB {
|
|
|
115
115
|
const { autosave, saveInterval } = config.orm.db;
|
|
116
116
|
|
|
117
117
|
store.set(dbKey, new Map());
|
|
118
|
-
Orm.instance.models[`${dbKey}Model`] = await this.getSchema();
|
|
118
|
+
(Orm.instance as Orm).models[`${dbKey}Model`] = await this.getSchema();
|
|
119
119
|
|
|
120
120
|
await this.validateMode();
|
|
121
121
|
this.record = await this.getRecord();
|
package/src/setup-rest-server.ts
CHANGED
|
@@ -31,9 +31,9 @@ export default async function(route: string, accessPath: string, metaRoute: bool
|
|
|
31
31
|
for (const model of models === '*' ? availableModels : models) {
|
|
32
32
|
if (model === dbKey) continue;
|
|
33
33
|
if (!store.data.has(model)) throw new Error(`Unable to define access for Invalid Model "${model}". Model does not exist`);
|
|
34
|
-
if (accessFiles[model]) throw new Error(`Access for model "${model}" has already been defined by another access class.`);
|
|
34
|
+
if (accessFiles![model]) throw new Error(`Access for model "${model}" has already been defined by another access class.`);
|
|
35
35
|
|
|
36
|
-
accessFiles[model] = accessInstance.access;
|
|
36
|
+
accessFiles![model] = accessInstance.access;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
} catch (error) {
|
|
@@ -47,7 +47,7 @@ export default async function(route: string, accessPath: string, metaRoute: bool
|
|
|
47
47
|
const name = route === '/' ? 'index' : (route[0] === '/' ? route.slice(1) : route);
|
|
48
48
|
|
|
49
49
|
// Configure endpoints for models and views with access configuration
|
|
50
|
-
for (const [model, access] of Object.entries(accessFiles)) {
|
|
50
|
+
for (const [model, access] of Object.entries(accessFiles!)) {
|
|
51
51
|
const pluralizedModel = getPluralName(model);
|
|
52
52
|
const modelName = name === 'index' ? pluralizedModel : `${name}/${pluralizedModel}`;
|
|
53
53
|
RestServer.instance.mountRoute(OrmRequest, { name: modelName, options: { model, access } });
|
package/src/store.ts
CHANGED
|
@@ -315,9 +315,9 @@ export default class Store {
|
|
|
315
315
|
}
|
|
316
316
|
} else if (value && isStoreRecord(value) && value.__model && !this._isBidirectionalRelationship(
|
|
317
317
|
record.__model.__name,
|
|
318
|
-
value.__model.__name
|
|
318
|
+
(value as StoreRecord).__model.__name
|
|
319
319
|
)) {
|
|
320
|
-
children.push({ childRecord: value, relationshipKey: key, type: 'belongsTo' });
|
|
320
|
+
children.push({ childRecord: value as StoreRecord, relationshipKey: key, type: 'belongsTo' });
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
|
package/src/view-resolver.ts
CHANGED
|
@@ -156,8 +156,8 @@ export default class ViewResolver {
|
|
|
156
156
|
if (!aggProp.relationship) continue;
|
|
157
157
|
const allRelated: unknown[] = [];
|
|
158
158
|
for (const record of groupRecords) {
|
|
159
|
-
const relatedRecords = record.__relationships?.[aggProp.relationship]
|
|
160
|
-
|| record[aggProp.relationship];
|
|
159
|
+
const relatedRecords = record.__relationships?.[aggProp.relationship!]
|
|
160
|
+
|| record[aggProp.relationship!];
|
|
161
161
|
if (Array.isArray(relatedRecords)) {
|
|
162
162
|
allRelated.push(...relatedRecords);
|
|
163
163
|
}
|