pinia-orm-edge 1.9.0-28583149.676ad48 → 1.9.0-28583537.6bbcf83
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/dist/casts.d.cts +1 -2
- package/dist/casts.d.mts +1 -2
- package/dist/casts.d.ts +1 -2
- package/dist/decorators.d.cts +2 -3
- package/dist/decorators.d.mts +2 -3
- package/dist/decorators.d.ts +2 -3
- package/dist/helpers.d.cts +1 -2
- package/dist/helpers.d.mts +1 -2
- package/dist/helpers.d.ts +1 -2
- package/dist/index.cjs +49 -28
- package/dist/index.d.cts +2 -3
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +49 -28
- package/dist/nanoid/async.d.cts +1 -2
- package/dist/nanoid/async.d.mts +1 -2
- package/dist/nanoid/async.d.ts +1 -2
- package/dist/nanoid/index.d.cts +1 -2
- package/dist/nanoid/index.d.mts +1 -2
- package/dist/nanoid/index.d.ts +1 -2
- package/dist/nanoid/non-secure.d.cts +1 -2
- package/dist/nanoid/non-secure.d.mts +1 -2
- package/dist/nanoid/non-secure.d.ts +1 -2
- package/dist/shared/{pinia-orm.b86abeaa.d.cts → pinia-orm.b5d0a9df.d.cts} +19 -6
- package/dist/shared/{pinia-orm.b86abeaa.d.mts → pinia-orm.b5d0a9df.d.mts} +19 -6
- package/dist/shared/{pinia-orm.b86abeaa.d.ts → pinia-orm.b5d0a9df.d.ts} +19 -6
- package/dist/uuid/v1.d.cts +1 -2
- package/dist/uuid/v1.d.mts +1 -2
- package/dist/uuid/v1.d.ts +1 -2
- package/dist/uuid/v4.d.cts +1 -2
- package/dist/uuid/v4.d.mts +1 -2
- package/dist/uuid/v4.d.ts +1 -2
- package/package.json +2 -2
package/dist/casts.d.cts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b5d0a9df.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class ArrayCast extends CastAttribute {
|
package/dist/casts.d.mts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b5d0a9df.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class ArrayCast extends CastAttribute {
|
package/dist/casts.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b5d0a9df.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class ArrayCast extends CastAttribute {
|
package/dist/decorators.d.cts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.
|
2
|
-
export { aq as NanoidOptions } from './shared/pinia-orm.
|
1
|
+
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.b5d0a9df.cjs';
|
2
|
+
export { aq as NanoidOptions } from './shared/pinia-orm.b5d0a9df.cjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
/**
|
package/dist/decorators.d.mts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.
|
2
|
-
export { aq as NanoidOptions } from './shared/pinia-orm.
|
1
|
+
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.b5d0a9df.mjs';
|
2
|
+
export { aq as NanoidOptions } from './shared/pinia-orm.b5d0a9df.mjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
/**
|
package/dist/decorators.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.
|
2
|
-
export { aq as NanoidOptions } from './shared/pinia-orm.
|
1
|
+
import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.b5d0a9df.js';
|
2
|
+
export { aq as NanoidOptions } from './shared/pinia-orm.b5d0a9df.js';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
/**
|
package/dist/helpers.d.cts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.b5d0a9df.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
package/dist/helpers.d.mts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.b5d0a9df.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
package/dist/helpers.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.b5d0a9df.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
package/dist/index.cjs
CHANGED
@@ -380,7 +380,7 @@ class Schema {
|
|
380
380
|
one(model, parent) {
|
381
381
|
model = model || this.model;
|
382
382
|
parent = parent || this.model;
|
383
|
-
const entity = `${model.$
|
383
|
+
const entity = `${model.$self().modelEntity()}${parent.$self().modelEntity()}`;
|
384
384
|
if (this.schemas[entity]) {
|
385
385
|
return this.schemas[entity];
|
386
386
|
}
|
@@ -401,7 +401,7 @@ class Schema {
|
|
401
401
|
*/
|
402
402
|
union(models, callback) {
|
403
403
|
const schemas = models.reduce((schemas2, model) => {
|
404
|
-
schemas2[model.$
|
404
|
+
schemas2[model.$self().modelEntity()] = this.one(model);
|
405
405
|
return schemas2;
|
406
406
|
}, {});
|
407
407
|
return new normalizr.schema.Union(schemas, callback);
|
@@ -410,7 +410,7 @@ class Schema {
|
|
410
410
|
* Create a new normalizr entity.
|
411
411
|
*/
|
412
412
|
newEntity(model, parent) {
|
413
|
-
const entity = model.$
|
413
|
+
const entity = model.$self().modelEntity();
|
414
414
|
const idAttribute = this.idAttribute(model, parent);
|
415
415
|
return new normalizr.schema.Entity(entity, {}, { idAttribute });
|
416
416
|
}
|
@@ -448,7 +448,7 @@ class Schema {
|
|
448
448
|
}
|
449
449
|
}
|
450
450
|
if (["BelongsTo", "HasOne", "MorphOne", "MorphTo"].includes(parent.$fields()[key]?.constructor.name ?? "") && Utils.isArray(parentRecord[key])) {
|
451
|
-
Utils.throwError(['You are passing a list to "', `${parent.$
|
451
|
+
Utils.throwError(['You are passing a list to "', `${parent.$modelEntity()}.${key}`, `" which is a one to one Relation(${parent.$fields()[key]?.constructor.name}):`, JSON.stringify(parentRecord[key])]);
|
452
452
|
}
|
453
453
|
const id = model.$getIndexId(record);
|
454
454
|
return id;
|
@@ -1091,8 +1091,9 @@ class Query {
|
|
1091
1091
|
return queryResult;
|
1092
1092
|
}
|
1093
1093
|
internalGet(triggerHook) {
|
1094
|
-
if (this.model.$entity() !== this.model.$baseEntity()) {
|
1095
|
-
|
1094
|
+
if (this.model.$entity() !== this.model.$baseEntity() || this.model.$namespace() !== this.model.$baseNamespace()) {
|
1095
|
+
const typeKeyValue = this.model.$fields()[this.model.$typeKey()].make() ?? this.model.$entity();
|
1096
|
+
this.where(this.model.$typeKey(), typeKeyValue);
|
1096
1097
|
}
|
1097
1098
|
let models = this.select();
|
1098
1099
|
if (this.orders.length === 0) {
|
@@ -1182,9 +1183,6 @@ class Query {
|
|
1182
1183
|
* Filter the given collection by the registered order conditions.
|
1183
1184
|
*/
|
1184
1185
|
filterOrder(models) {
|
1185
|
-
if (this.orders.length === 0) {
|
1186
|
-
return models;
|
1187
|
-
}
|
1188
1186
|
const fields = this.orders.map((order) => order.field);
|
1189
1187
|
const directions = this.orders.map((order) => order.direction);
|
1190
1188
|
return Utils.orderBy(models, fields, directions);
|
@@ -1310,7 +1308,7 @@ class Query {
|
|
1310
1308
|
save(records) {
|
1311
1309
|
let processedData = this.newInterpreter().process(records);
|
1312
1310
|
const modelTypes = this.model.$types();
|
1313
|
-
const isChildEntity = this.model.$baseEntity() !== this.model.$entity();
|
1311
|
+
const isChildEntity = this.model.$baseEntity() !== this.model.$entity() || this.model.$baseNamespace() !== this.model.$namespace();
|
1314
1312
|
if (Object.values(modelTypes).length > 0 || isChildEntity) {
|
1315
1313
|
const modelTypesKeys = Object.keys(modelTypes);
|
1316
1314
|
const recordsByTypes = {};
|
@@ -1324,10 +1322,10 @@ class Query {
|
|
1324
1322
|
});
|
1325
1323
|
for (const entry in recordsByTypes) {
|
1326
1324
|
const typeModel = modelTypes[entry];
|
1327
|
-
if (typeModel.
|
1325
|
+
if (typeModel.modelEntity() === this.model.$modelEntity()) {
|
1328
1326
|
processedData = this.newInterpreter().process(recordsByTypes[entry]);
|
1329
1327
|
} else {
|
1330
|
-
this.newQueryWithConstraints(typeModel.
|
1328
|
+
this.newQueryWithConstraints(typeModel.modelEntity()).save(recordsByTypes[entry]);
|
1331
1329
|
}
|
1332
1330
|
}
|
1333
1331
|
}
|
@@ -1983,7 +1981,7 @@ class Database {
|
|
1983
1981
|
* Register the given model.
|
1984
1982
|
*/
|
1985
1983
|
register(model) {
|
1986
|
-
const entity = model.$
|
1984
|
+
const entity = model.$self().modelEntity();
|
1987
1985
|
if (!this.models[entity]) {
|
1988
1986
|
this.models[entity] = model;
|
1989
1987
|
this.registerRelatedModels(model);
|
@@ -2876,21 +2874,28 @@ class Model {
|
|
2876
2874
|
static fields() {
|
2877
2875
|
return {};
|
2878
2876
|
}
|
2877
|
+
static usedNamespace() {
|
2878
|
+
return this.namespace ?? config.model.namespace;
|
2879
|
+
}
|
2880
|
+
static modelEntity() {
|
2881
|
+
return (this.usedNamespace() ? this.usedNamespace() + "/" : "") + this.entity;
|
2882
|
+
}
|
2879
2883
|
/**
|
2880
2884
|
* Build the schema by evaluating fields and registry.
|
2881
2885
|
*/
|
2882
2886
|
static initializeSchema() {
|
2883
|
-
|
2884
|
-
this.
|
2887
|
+
const entity = this.modelEntity();
|
2888
|
+
this.schemas[entity] = {};
|
2889
|
+
this.fieldsOnDelete[entity] = this.fieldsOnDelete[entity] ?? {};
|
2885
2890
|
const registry = {
|
2886
2891
|
...this.fields(),
|
2887
|
-
...this.registries[
|
2892
|
+
...this.registries[entity]
|
2888
2893
|
};
|
2889
2894
|
for (const key in registry) {
|
2890
2895
|
const attribute = registry[key];
|
2891
|
-
this.schemas[
|
2892
|
-
if (this.fieldsOnDelete[
|
2893
|
-
this.schemas[
|
2896
|
+
this.schemas[entity][key] = typeof attribute === "function" ? attribute() : attribute;
|
2897
|
+
if (this.fieldsOnDelete[entity][key]) {
|
2898
|
+
this.schemas[entity][key] = this.schemas[entity][key].onDelete(this.fieldsOnDelete[entity][key]);
|
2894
2899
|
}
|
2895
2900
|
}
|
2896
2901
|
}
|
@@ -2898,18 +2903,18 @@ class Model {
|
|
2898
2903
|
* Set the attribute to the registry.
|
2899
2904
|
*/
|
2900
2905
|
static setRegistry(key, attribute) {
|
2901
|
-
if (!this.registries[this.
|
2902
|
-
this.registries[this.
|
2906
|
+
if (!this.registries[this.modelEntity()]) {
|
2907
|
+
this.registries[this.modelEntity()] = {};
|
2903
2908
|
}
|
2904
|
-
this.registries[this.
|
2909
|
+
this.registries[this.modelEntity()][key] = attribute;
|
2905
2910
|
return this;
|
2906
2911
|
}
|
2907
2912
|
/**
|
2908
2913
|
* Set delete behaviour for relation field
|
2909
2914
|
*/
|
2910
2915
|
static setFieldDeleteMode(key, mode) {
|
2911
|
-
this.fieldsOnDelete[this.
|
2912
|
-
this.fieldsOnDelete[this.
|
2916
|
+
this.fieldsOnDelete[this.modelEntity()] = this.fieldsOnDelete[this.modelEntity()] ?? {};
|
2917
|
+
this.fieldsOnDelete[this.modelEntity()][key] = mode;
|
2913
2918
|
return this;
|
2914
2919
|
}
|
2915
2920
|
/**
|
@@ -3142,7 +3147,7 @@ class Model {
|
|
3142
3147
|
* Get the namespace.
|
3143
3148
|
*/
|
3144
3149
|
$namespace() {
|
3145
|
-
return this.$self().
|
3150
|
+
return this.$self().usedNamespace();
|
3146
3151
|
}
|
3147
3152
|
/**
|
3148
3153
|
* Get the store name.
|
@@ -3156,6 +3161,18 @@ class Model {
|
|
3156
3161
|
$baseEntity() {
|
3157
3162
|
return this.$self().baseEntity ?? this.$entity();
|
3158
3163
|
}
|
3164
|
+
/**
|
3165
|
+
* Get the base namespace for this model.
|
3166
|
+
*/
|
3167
|
+
$baseNamespace() {
|
3168
|
+
return this.$self().baseNamespace ?? this.$namespace();
|
3169
|
+
}
|
3170
|
+
/**
|
3171
|
+
* Get the model entity for this model.
|
3172
|
+
*/
|
3173
|
+
$modelEntity() {
|
3174
|
+
return this.$self().modelEntity();
|
3175
|
+
}
|
3159
3176
|
/**
|
3160
3177
|
* Get the type key for this model.
|
3161
3178
|
*/
|
@@ -3184,7 +3201,7 @@ class Model {
|
|
3184
3201
|
* Get the model fields for this model.
|
3185
3202
|
*/
|
3186
3203
|
$fields() {
|
3187
|
-
return this.$self().schemas[this.$
|
3204
|
+
return this.$self().schemas[this.$modelEntity()];
|
3188
3205
|
}
|
3189
3206
|
/**
|
3190
3207
|
* Get the model hidden fields
|
@@ -3211,8 +3228,8 @@ class Model {
|
|
3211
3228
|
* Bootstrap this model.
|
3212
3229
|
*/
|
3213
3230
|
$boot() {
|
3214
|
-
if (!this.$self().booted[this.$
|
3215
|
-
this.$self().booted[this.$
|
3231
|
+
if (!this.$self().booted[this.$modelEntity()]) {
|
3232
|
+
this.$self().booted[this.$modelEntity()] = true;
|
3216
3233
|
this.$initializeSchema();
|
3217
3234
|
}
|
3218
3235
|
}
|
@@ -3529,6 +3546,10 @@ __publicField(Model, "entity");
|
|
3529
3546
|
* The reference to the base entity name if the class extends a base entity.
|
3530
3547
|
*/
|
3531
3548
|
__publicField(Model, "baseEntity");
|
3549
|
+
/**
|
3550
|
+
* The reference to the base namespace if the class extends a base with a different namespace.
|
3551
|
+
*/
|
3552
|
+
__publicField(Model, "baseNamespace");
|
3532
3553
|
/**
|
3533
3554
|
* Define a namespace if you have multiple equal entity names.
|
3534
3555
|
* Resulting in "{namespace}/{entity}"
|
package/dist/index.d.cts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.
|
2
|
-
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.
|
1
|
+
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.b5d0a9df.cjs';
|
2
|
+
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.b5d0a9df.cjs';
|
3
3
|
import { Pinia } from 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare function useRepo<R extends Repository>(repository: R | Constructor<R>, pinia?: Pinia): R;
|
package/dist/index.d.mts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.
|
2
|
-
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.
|
1
|
+
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.b5d0a9df.mjs';
|
2
|
+
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.b5d0a9df.mjs';
|
3
3
|
import { Pinia } from 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare function useRepo<R extends Repository>(repository: R | Constructor<R>, pinia?: Pinia): R;
|
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.
|
2
|
-
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.
|
1
|
+
import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.b5d0a9df.js';
|
2
|
+
export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.b5d0a9df.js';
|
3
3
|
import { Pinia } from 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare function useRepo<R extends Repository>(repository: R | Constructor<R>, pinia?: Pinia): R;
|
package/dist/index.mjs
CHANGED
@@ -378,7 +378,7 @@ class Schema {
|
|
378
378
|
one(model, parent) {
|
379
379
|
model = model || this.model;
|
380
380
|
parent = parent || this.model;
|
381
|
-
const entity = `${model.$
|
381
|
+
const entity = `${model.$self().modelEntity()}${parent.$self().modelEntity()}`;
|
382
382
|
if (this.schemas[entity]) {
|
383
383
|
return this.schemas[entity];
|
384
384
|
}
|
@@ -399,7 +399,7 @@ class Schema {
|
|
399
399
|
*/
|
400
400
|
union(models, callback) {
|
401
401
|
const schemas = models.reduce((schemas2, model) => {
|
402
|
-
schemas2[model.$
|
402
|
+
schemas2[model.$self().modelEntity()] = this.one(model);
|
403
403
|
return schemas2;
|
404
404
|
}, {});
|
405
405
|
return new schema.Union(schemas, callback);
|
@@ -408,7 +408,7 @@ class Schema {
|
|
408
408
|
* Create a new normalizr entity.
|
409
409
|
*/
|
410
410
|
newEntity(model, parent) {
|
411
|
-
const entity = model.$
|
411
|
+
const entity = model.$self().modelEntity();
|
412
412
|
const idAttribute = this.idAttribute(model, parent);
|
413
413
|
return new schema.Entity(entity, {}, { idAttribute });
|
414
414
|
}
|
@@ -446,7 +446,7 @@ class Schema {
|
|
446
446
|
}
|
447
447
|
}
|
448
448
|
if (["BelongsTo", "HasOne", "MorphOne", "MorphTo"].includes(parent.$fields()[key]?.constructor.name ?? "") && isArray(parentRecord[key])) {
|
449
|
-
throwError(['You are passing a list to "', `${parent.$
|
449
|
+
throwError(['You are passing a list to "', `${parent.$modelEntity()}.${key}`, `" which is a one to one Relation(${parent.$fields()[key]?.constructor.name}):`, JSON.stringify(parentRecord[key])]);
|
450
450
|
}
|
451
451
|
const id = model.$getIndexId(record);
|
452
452
|
return id;
|
@@ -1089,8 +1089,9 @@ class Query {
|
|
1089
1089
|
return queryResult;
|
1090
1090
|
}
|
1091
1091
|
internalGet(triggerHook) {
|
1092
|
-
if (this.model.$entity() !== this.model.$baseEntity()) {
|
1093
|
-
|
1092
|
+
if (this.model.$entity() !== this.model.$baseEntity() || this.model.$namespace() !== this.model.$baseNamespace()) {
|
1093
|
+
const typeKeyValue = this.model.$fields()[this.model.$typeKey()].make() ?? this.model.$entity();
|
1094
|
+
this.where(this.model.$typeKey(), typeKeyValue);
|
1094
1095
|
}
|
1095
1096
|
let models = this.select();
|
1096
1097
|
if (this.orders.length === 0) {
|
@@ -1180,9 +1181,6 @@ class Query {
|
|
1180
1181
|
* Filter the given collection by the registered order conditions.
|
1181
1182
|
*/
|
1182
1183
|
filterOrder(models) {
|
1183
|
-
if (this.orders.length === 0) {
|
1184
|
-
return models;
|
1185
|
-
}
|
1186
1184
|
const fields = this.orders.map((order) => order.field);
|
1187
1185
|
const directions = this.orders.map((order) => order.direction);
|
1188
1186
|
return orderBy(models, fields, directions);
|
@@ -1308,7 +1306,7 @@ class Query {
|
|
1308
1306
|
save(records) {
|
1309
1307
|
let processedData = this.newInterpreter().process(records);
|
1310
1308
|
const modelTypes = this.model.$types();
|
1311
|
-
const isChildEntity = this.model.$baseEntity() !== this.model.$entity();
|
1309
|
+
const isChildEntity = this.model.$baseEntity() !== this.model.$entity() || this.model.$baseNamespace() !== this.model.$namespace();
|
1312
1310
|
if (Object.values(modelTypes).length > 0 || isChildEntity) {
|
1313
1311
|
const modelTypesKeys = Object.keys(modelTypes);
|
1314
1312
|
const recordsByTypes = {};
|
@@ -1322,10 +1320,10 @@ class Query {
|
|
1322
1320
|
});
|
1323
1321
|
for (const entry in recordsByTypes) {
|
1324
1322
|
const typeModel = modelTypes[entry];
|
1325
|
-
if (typeModel.
|
1323
|
+
if (typeModel.modelEntity() === this.model.$modelEntity()) {
|
1326
1324
|
processedData = this.newInterpreter().process(recordsByTypes[entry]);
|
1327
1325
|
} else {
|
1328
|
-
this.newQueryWithConstraints(typeModel.
|
1326
|
+
this.newQueryWithConstraints(typeModel.modelEntity()).save(recordsByTypes[entry]);
|
1329
1327
|
}
|
1330
1328
|
}
|
1331
1329
|
}
|
@@ -1981,7 +1979,7 @@ class Database {
|
|
1981
1979
|
* Register the given model.
|
1982
1980
|
*/
|
1983
1981
|
register(model) {
|
1984
|
-
const entity = model.$
|
1982
|
+
const entity = model.$self().modelEntity();
|
1985
1983
|
if (!this.models[entity]) {
|
1986
1984
|
this.models[entity] = model;
|
1987
1985
|
this.registerRelatedModels(model);
|
@@ -2874,21 +2872,28 @@ class Model {
|
|
2874
2872
|
static fields() {
|
2875
2873
|
return {};
|
2876
2874
|
}
|
2875
|
+
static usedNamespace() {
|
2876
|
+
return this.namespace ?? config.model.namespace;
|
2877
|
+
}
|
2878
|
+
static modelEntity() {
|
2879
|
+
return (this.usedNamespace() ? this.usedNamespace() + "/" : "") + this.entity;
|
2880
|
+
}
|
2877
2881
|
/**
|
2878
2882
|
* Build the schema by evaluating fields and registry.
|
2879
2883
|
*/
|
2880
2884
|
static initializeSchema() {
|
2881
|
-
|
2882
|
-
this.
|
2885
|
+
const entity = this.modelEntity();
|
2886
|
+
this.schemas[entity] = {};
|
2887
|
+
this.fieldsOnDelete[entity] = this.fieldsOnDelete[entity] ?? {};
|
2883
2888
|
const registry = {
|
2884
2889
|
...this.fields(),
|
2885
|
-
...this.registries[
|
2890
|
+
...this.registries[entity]
|
2886
2891
|
};
|
2887
2892
|
for (const key in registry) {
|
2888
2893
|
const attribute = registry[key];
|
2889
|
-
this.schemas[
|
2890
|
-
if (this.fieldsOnDelete[
|
2891
|
-
this.schemas[
|
2894
|
+
this.schemas[entity][key] = typeof attribute === "function" ? attribute() : attribute;
|
2895
|
+
if (this.fieldsOnDelete[entity][key]) {
|
2896
|
+
this.schemas[entity][key] = this.schemas[entity][key].onDelete(this.fieldsOnDelete[entity][key]);
|
2892
2897
|
}
|
2893
2898
|
}
|
2894
2899
|
}
|
@@ -2896,18 +2901,18 @@ class Model {
|
|
2896
2901
|
* Set the attribute to the registry.
|
2897
2902
|
*/
|
2898
2903
|
static setRegistry(key, attribute) {
|
2899
|
-
if (!this.registries[this.
|
2900
|
-
this.registries[this.
|
2904
|
+
if (!this.registries[this.modelEntity()]) {
|
2905
|
+
this.registries[this.modelEntity()] = {};
|
2901
2906
|
}
|
2902
|
-
this.registries[this.
|
2907
|
+
this.registries[this.modelEntity()][key] = attribute;
|
2903
2908
|
return this;
|
2904
2909
|
}
|
2905
2910
|
/**
|
2906
2911
|
* Set delete behaviour for relation field
|
2907
2912
|
*/
|
2908
2913
|
static setFieldDeleteMode(key, mode) {
|
2909
|
-
this.fieldsOnDelete[this.
|
2910
|
-
this.fieldsOnDelete[this.
|
2914
|
+
this.fieldsOnDelete[this.modelEntity()] = this.fieldsOnDelete[this.modelEntity()] ?? {};
|
2915
|
+
this.fieldsOnDelete[this.modelEntity()][key] = mode;
|
2911
2916
|
return this;
|
2912
2917
|
}
|
2913
2918
|
/**
|
@@ -3140,7 +3145,7 @@ class Model {
|
|
3140
3145
|
* Get the namespace.
|
3141
3146
|
*/
|
3142
3147
|
$namespace() {
|
3143
|
-
return this.$self().
|
3148
|
+
return this.$self().usedNamespace();
|
3144
3149
|
}
|
3145
3150
|
/**
|
3146
3151
|
* Get the store name.
|
@@ -3154,6 +3159,18 @@ class Model {
|
|
3154
3159
|
$baseEntity() {
|
3155
3160
|
return this.$self().baseEntity ?? this.$entity();
|
3156
3161
|
}
|
3162
|
+
/**
|
3163
|
+
* Get the base namespace for this model.
|
3164
|
+
*/
|
3165
|
+
$baseNamespace() {
|
3166
|
+
return this.$self().baseNamespace ?? this.$namespace();
|
3167
|
+
}
|
3168
|
+
/**
|
3169
|
+
* Get the model entity for this model.
|
3170
|
+
*/
|
3171
|
+
$modelEntity() {
|
3172
|
+
return this.$self().modelEntity();
|
3173
|
+
}
|
3157
3174
|
/**
|
3158
3175
|
* Get the type key for this model.
|
3159
3176
|
*/
|
@@ -3182,7 +3199,7 @@ class Model {
|
|
3182
3199
|
* Get the model fields for this model.
|
3183
3200
|
*/
|
3184
3201
|
$fields() {
|
3185
|
-
return this.$self().schemas[this.$
|
3202
|
+
return this.$self().schemas[this.$modelEntity()];
|
3186
3203
|
}
|
3187
3204
|
/**
|
3188
3205
|
* Get the model hidden fields
|
@@ -3209,8 +3226,8 @@ class Model {
|
|
3209
3226
|
* Bootstrap this model.
|
3210
3227
|
*/
|
3211
3228
|
$boot() {
|
3212
|
-
if (!this.$self().booted[this.$
|
3213
|
-
this.$self().booted[this.$
|
3229
|
+
if (!this.$self().booted[this.$modelEntity()]) {
|
3230
|
+
this.$self().booted[this.$modelEntity()] = true;
|
3214
3231
|
this.$initializeSchema();
|
3215
3232
|
}
|
3216
3233
|
}
|
@@ -3527,6 +3544,10 @@ __publicField(Model, "entity");
|
|
3527
3544
|
* The reference to the base entity name if the class extends a base entity.
|
3528
3545
|
*/
|
3529
3546
|
__publicField(Model, "baseEntity");
|
3547
|
+
/**
|
3548
|
+
* The reference to the base namespace if the class extends a base with a different namespace.
|
3549
|
+
*/
|
3550
|
+
__publicField(Model, "baseNamespace");
|
3530
3551
|
/**
|
3531
3552
|
* Define a namespace if you have multiple equal entity names.
|
3532
3553
|
* Resulting in "{namespace}/{entity}"
|
package/dist/nanoid/async.d.cts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
/**
|
package/dist/nanoid/async.d.mts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
/**
|
package/dist/nanoid/async.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
/**
|
package/dist/nanoid/index.d.cts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class UidCast extends CastAttribute {
|
package/dist/nanoid/index.d.mts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class UidCast extends CastAttribute {
|
package/dist/nanoid/index.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class UidCast extends CastAttribute {
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.cjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class UidCast extends CastAttribute {
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.mjs';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class UidCast extends CastAttribute {
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
1
|
+
import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.js';
|
2
2
|
import 'pinia';
|
3
3
|
import '@pinia-orm/normalizr';
|
4
|
-
import '@/model/Model';
|
5
4
|
import '@/composables';
|
6
5
|
|
7
6
|
declare class UidCast extends CastAttribute {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import * as pinia from 'pinia';
|
2
2
|
import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
|
3
3
|
import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
|
4
|
-
import { Model as Model$1, WithKeys as WithKeys$1 } from '@/model/Model';
|
5
4
|
import * as __composables from '@/composables';
|
6
5
|
|
7
6
|
interface Constructor<T> {
|
@@ -291,7 +290,7 @@ declare class Interpreter {
|
|
291
290
|
private getSchema;
|
292
291
|
}
|
293
292
|
|
294
|
-
interface Where<T = Model
|
293
|
+
interface Where<T = Model> {
|
295
294
|
field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
|
296
295
|
value: WhereSecondaryClosure<T> | any;
|
297
296
|
boolean: 'and' | 'or';
|
@@ -301,7 +300,7 @@ type NonMethodKeys<T> = {
|
|
301
300
|
}[keyof T];
|
302
301
|
type GetElementType<T extends unknown[] | unknown> = T extends (infer U)[] ? U : T;
|
303
302
|
type UltimateKeys<M> = {
|
304
|
-
[T in keyof M]: M[T] extends Model
|
303
|
+
[T in keyof M]: M[T] extends Model | Model[] | null ? GetElementType<NonNullable<M[T]>> : never;
|
305
304
|
};
|
306
305
|
type WherePrimaryClosure<T> = (model: T) => boolean;
|
307
306
|
type WhereSecondaryClosure<T> = (value: T) => boolean;
|
@@ -320,10 +319,10 @@ type OrderBy = string | ((model: any) => any);
|
|
320
319
|
type GroupBy = string;
|
321
320
|
type GroupByFields = string[];
|
322
321
|
type OrderDirection = 'asc' | 'desc';
|
323
|
-
type EagerLoad<M extends Model
|
324
|
-
[K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys
|
322
|
+
type EagerLoad<M extends Model> = {
|
323
|
+
[K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys<M>] extends Model ? M[WithKeys<M>] : never>>;
|
325
324
|
};
|
326
|
-
type EagerLoadConstraint<M extends Model
|
325
|
+
type EagerLoadConstraint<M extends Model> = (query: Query<M>) => void;
|
327
326
|
|
328
327
|
declare class Query<M extends Model = Model> {
|
329
328
|
/**
|
@@ -1356,6 +1355,10 @@ declare class Model {
|
|
1356
1355
|
* The reference to the base entity name if the class extends a base entity.
|
1357
1356
|
*/
|
1358
1357
|
static baseEntity: string;
|
1358
|
+
/**
|
1359
|
+
* The reference to the base namespace if the class extends a base with a different namespace.
|
1360
|
+
*/
|
1361
|
+
static baseNamespace: string;
|
1359
1362
|
/**
|
1360
1363
|
* Define a namespace if you have multiple equal entity names.
|
1361
1364
|
* Resulting in "{namespace}/{entity}"
|
@@ -1431,6 +1434,8 @@ declare class Model {
|
|
1431
1434
|
* Create a new model fields definition.
|
1432
1435
|
*/
|
1433
1436
|
static fields(): ModelFields;
|
1437
|
+
static usedNamespace(): string;
|
1438
|
+
static modelEntity(): string;
|
1434
1439
|
/**
|
1435
1440
|
* Build the schema by evaluating fields and registry.
|
1436
1441
|
*/
|
@@ -1609,6 +1614,14 @@ declare class Model {
|
|
1609
1614
|
* Get the base entity for this model.
|
1610
1615
|
*/
|
1611
1616
|
$baseEntity(): string;
|
1617
|
+
/**
|
1618
|
+
* Get the base namespace for this model.
|
1619
|
+
*/
|
1620
|
+
$baseNamespace(): string;
|
1621
|
+
/**
|
1622
|
+
* Get the model entity for this model.
|
1623
|
+
*/
|
1624
|
+
$modelEntity(): string;
|
1612
1625
|
/**
|
1613
1626
|
* Get the type key for this model.
|
1614
1627
|
*/
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import * as pinia from 'pinia';
|
2
2
|
import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
|
3
3
|
import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
|
4
|
-
import { Model as Model$1, WithKeys as WithKeys$1 } from '@/model/Model';
|
5
4
|
import * as __composables from '@/composables';
|
6
5
|
|
7
6
|
interface Constructor<T> {
|
@@ -291,7 +290,7 @@ declare class Interpreter {
|
|
291
290
|
private getSchema;
|
292
291
|
}
|
293
292
|
|
294
|
-
interface Where<T = Model
|
293
|
+
interface Where<T = Model> {
|
295
294
|
field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
|
296
295
|
value: WhereSecondaryClosure<T> | any;
|
297
296
|
boolean: 'and' | 'or';
|
@@ -301,7 +300,7 @@ type NonMethodKeys<T> = {
|
|
301
300
|
}[keyof T];
|
302
301
|
type GetElementType<T extends unknown[] | unknown> = T extends (infer U)[] ? U : T;
|
303
302
|
type UltimateKeys<M> = {
|
304
|
-
[T in keyof M]: M[T] extends Model
|
303
|
+
[T in keyof M]: M[T] extends Model | Model[] | null ? GetElementType<NonNullable<M[T]>> : never;
|
305
304
|
};
|
306
305
|
type WherePrimaryClosure<T> = (model: T) => boolean;
|
307
306
|
type WhereSecondaryClosure<T> = (value: T) => boolean;
|
@@ -320,10 +319,10 @@ type OrderBy = string | ((model: any) => any);
|
|
320
319
|
type GroupBy = string;
|
321
320
|
type GroupByFields = string[];
|
322
321
|
type OrderDirection = 'asc' | 'desc';
|
323
|
-
type EagerLoad<M extends Model
|
324
|
-
[K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys
|
322
|
+
type EagerLoad<M extends Model> = {
|
323
|
+
[K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys<M>] extends Model ? M[WithKeys<M>] : never>>;
|
325
324
|
};
|
326
|
-
type EagerLoadConstraint<M extends Model
|
325
|
+
type EagerLoadConstraint<M extends Model> = (query: Query<M>) => void;
|
327
326
|
|
328
327
|
declare class Query<M extends Model = Model> {
|
329
328
|
/**
|
@@ -1356,6 +1355,10 @@ declare class Model {
|
|
1356
1355
|
* The reference to the base entity name if the class extends a base entity.
|
1357
1356
|
*/
|
1358
1357
|
static baseEntity: string;
|
1358
|
+
/**
|
1359
|
+
* The reference to the base namespace if the class extends a base with a different namespace.
|
1360
|
+
*/
|
1361
|
+
static baseNamespace: string;
|
1359
1362
|
/**
|
1360
1363
|
* Define a namespace if you have multiple equal entity names.
|
1361
1364
|
* Resulting in "{namespace}/{entity}"
|
@@ -1431,6 +1434,8 @@ declare class Model {
|
|
1431
1434
|
* Create a new model fields definition.
|
1432
1435
|
*/
|
1433
1436
|
static fields(): ModelFields;
|
1437
|
+
static usedNamespace(): string;
|
1438
|
+
static modelEntity(): string;
|
1434
1439
|
/**
|
1435
1440
|
* Build the schema by evaluating fields and registry.
|
1436
1441
|
*/
|
@@ -1609,6 +1614,14 @@ declare class Model {
|
|
1609
1614
|
* Get the base entity for this model.
|
1610
1615
|
*/
|
1611
1616
|
$baseEntity(): string;
|
1617
|
+
/**
|
1618
|
+
* Get the base namespace for this model.
|
1619
|
+
*/
|
1620
|
+
$baseNamespace(): string;
|
1621
|
+
/**
|
1622
|
+
* Get the model entity for this model.
|
1623
|
+
*/
|
1624
|
+
$modelEntity(): string;
|
1612
1625
|
/**
|
1613
1626
|
* Get the type key for this model.
|
1614
1627
|
*/
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import * as pinia from 'pinia';
|
2
2
|
import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
|
3
3
|
import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
|
4
|
-
import { Model as Model$1, WithKeys as WithKeys$1 } from '@/model/Model';
|
5
4
|
import * as __composables from '@/composables';
|
6
5
|
|
7
6
|
interface Constructor<T> {
|
@@ -291,7 +290,7 @@ declare class Interpreter {
|
|
291
290
|
private getSchema;
|
292
291
|
}
|
293
292
|
|
294
|
-
interface Where<T = Model
|
293
|
+
interface Where<T = Model> {
|
295
294
|
field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
|
296
295
|
value: WhereSecondaryClosure<T> | any;
|
297
296
|
boolean: 'and' | 'or';
|
@@ -301,7 +300,7 @@ type NonMethodKeys<T> = {
|
|
301
300
|
}[keyof T];
|
302
301
|
type GetElementType<T extends unknown[] | unknown> = T extends (infer U)[] ? U : T;
|
303
302
|
type UltimateKeys<M> = {
|
304
|
-
[T in keyof M]: M[T] extends Model
|
303
|
+
[T in keyof M]: M[T] extends Model | Model[] | null ? GetElementType<NonNullable<M[T]>> : never;
|
305
304
|
};
|
306
305
|
type WherePrimaryClosure<T> = (model: T) => boolean;
|
307
306
|
type WhereSecondaryClosure<T> = (value: T) => boolean;
|
@@ -320,10 +319,10 @@ type OrderBy = string | ((model: any) => any);
|
|
320
319
|
type GroupBy = string;
|
321
320
|
type GroupByFields = string[];
|
322
321
|
type OrderDirection = 'asc' | 'desc';
|
323
|
-
type EagerLoad<M extends Model
|
324
|
-
[K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys
|
322
|
+
type EagerLoad<M extends Model> = {
|
323
|
+
[K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys<M>] extends Model ? M[WithKeys<M>] : never>>;
|
325
324
|
};
|
326
|
-
type EagerLoadConstraint<M extends Model
|
325
|
+
type EagerLoadConstraint<M extends Model> = (query: Query<M>) => void;
|
327
326
|
|
328
327
|
declare class Query<M extends Model = Model> {
|
329
328
|
/**
|
@@ -1356,6 +1355,10 @@ declare class Model {
|
|
1356
1355
|
* The reference to the base entity name if the class extends a base entity.
|
1357
1356
|
*/
|
1358
1357
|
static baseEntity: string;
|
1358
|
+
/**
|
1359
|
+
* The reference to the base namespace if the class extends a base with a different namespace.
|
1360
|
+
*/
|
1361
|
+
static baseNamespace: string;
|
1359
1362
|
/**
|
1360
1363
|
* Define a namespace if you have multiple equal entity names.
|
1361
1364
|
* Resulting in "{namespace}/{entity}"
|
@@ -1431,6 +1434,8 @@ declare class Model {
|
|
1431
1434
|
* Create a new model fields definition.
|
1432
1435
|
*/
|
1433
1436
|
static fields(): ModelFields;
|
1437
|
+
static usedNamespace(): string;
|
1438
|
+
static modelEntity(): string;
|
1434
1439
|
/**
|
1435
1440
|
* Build the schema by evaluating fields and registry.
|
1436
1441
|
*/
|
@@ -1609,6 +1614,14 @@ declare class Model {
|
|
1609
1614
|
* Get the base entity for this model.
|
1610
1615
|
*/
|
1611
1616
|
$baseEntity(): string;
|
1617
|
+
/**
|
1618
|
+
* Get the base namespace for this model.
|
1619
|
+
*/
|
1620
|
+
$baseNamespace(): string;
|
1621
|
+
/**
|
1622
|
+
* Get the model entity for this model.
|
1623
|
+
*/
|
1624
|
+
$modelEntity(): string;
|
1612
1625
|
/**
|
1613
1626
|
* Get the type key for this model.
|
1614
1627
|
*/
|
package/dist/uuid/v1.d.cts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { V1Options } from 'uuid';
|
2
|
-
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
2
|
+
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.cjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare class UidCast extends CastAttribute {
|
package/dist/uuid/v1.d.mts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { V1Options } from 'uuid';
|
2
|
-
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
2
|
+
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.mjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare class UidCast extends CastAttribute {
|
package/dist/uuid/v1.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { V1Options } from 'uuid';
|
2
|
-
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
2
|
+
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.js';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare class UidCast extends CastAttribute {
|
package/dist/uuid/v4.d.cts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { V4Options } from 'uuid';
|
2
|
-
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
2
|
+
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.cjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare class UidCast extends CastAttribute {
|
package/dist/uuid/v4.d.mts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { V4Options } from 'uuid';
|
2
|
-
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
2
|
+
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.mjs';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare class UidCast extends CastAttribute {
|
package/dist/uuid/v4.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { V4Options } from 'uuid';
|
2
|
-
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.
|
2
|
+
import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b5d0a9df.js';
|
3
3
|
import 'pinia';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
-
import '@/model/Model';
|
6
5
|
import '@/composables';
|
7
6
|
|
8
7
|
declare class UidCast extends CastAttribute {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "pinia-orm-edge",
|
3
|
-
"version": "1.9.0-
|
3
|
+
"version": "1.9.0-28583537.6bbcf83",
|
4
4
|
"description": "The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.",
|
5
5
|
"keywords": [
|
6
6
|
"vue",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"pinia": "^2.1.7"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
-
"@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.9.0-
|
49
|
+
"@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.9.0-28583537.6bbcf83"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"@nuxt/eslint-config": "^0.3.10",
|