pinia-orm-edge 1.9.0-28583149.676ad48 → 1.9.0-28583486.807fa36

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 CHANGED
@@ -1,7 +1,6 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.b86abeaa.cjs';
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.b86abeaa.mjs';
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.b86abeaa.js';
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 {
@@ -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.b86abeaa.cjs';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.b86abeaa.cjs';
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
  /**
@@ -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.b86abeaa.mjs';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.b86abeaa.mjs';
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
  /**
@@ -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.b86abeaa.js';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.b86abeaa.js';
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
  /**
@@ -1,7 +1,6 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.b86abeaa.cjs';
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';
@@ -1,7 +1,6 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.b86abeaa.mjs';
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.b86abeaa.js';
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.$entity()}${parent.$entity()}`;
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.$entity()] = this.one(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.$entity();
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.$entity()}.${key}`, `" which is a one to one Relation(${parent.$fields()[key]?.constructor.name}):`, JSON.stringify(parentRecord[key])]);
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;
@@ -1182,9 +1182,6 @@ class Query {
1182
1182
  * Filter the given collection by the registered order conditions.
1183
1183
  */
1184
1184
  filterOrder(models) {
1185
- if (this.orders.length === 0) {
1186
- return models;
1187
- }
1188
1185
  const fields = this.orders.map((order) => order.field);
1189
1186
  const directions = this.orders.map((order) => order.direction);
1190
1187
  return Utils.orderBy(models, fields, directions);
@@ -1310,7 +1307,7 @@ class Query {
1310
1307
  save(records) {
1311
1308
  let processedData = this.newInterpreter().process(records);
1312
1309
  const modelTypes = this.model.$types();
1313
- const isChildEntity = this.model.$baseEntity() !== this.model.$entity();
1310
+ const isChildEntity = this.model.$baseEntity() !== this.model.$entity() || this.model.$baseNamespace() !== this.model.$namespace();
1314
1311
  if (Object.values(modelTypes).length > 0 || isChildEntity) {
1315
1312
  const modelTypesKeys = Object.keys(modelTypes);
1316
1313
  const recordsByTypes = {};
@@ -1324,10 +1321,10 @@ class Query {
1324
1321
  });
1325
1322
  for (const entry in recordsByTypes) {
1326
1323
  const typeModel = modelTypes[entry];
1327
- if (typeModel.entity === this.model.$entity()) {
1324
+ if (typeModel.modelEntity() === this.model.$modelEntity()) {
1328
1325
  processedData = this.newInterpreter().process(recordsByTypes[entry]);
1329
1326
  } else {
1330
- this.newQueryWithConstraints(typeModel.entity).save(recordsByTypes[entry]);
1327
+ this.newQueryWithConstraints(typeModel.modelEntity()).save(recordsByTypes[entry]);
1331
1328
  }
1332
1329
  }
1333
1330
  }
@@ -1983,7 +1980,7 @@ class Database {
1983
1980
  * Register the given model.
1984
1981
  */
1985
1982
  register(model) {
1986
- const entity = model.$entity();
1983
+ const entity = model.$self().modelEntity();
1987
1984
  if (!this.models[entity]) {
1988
1985
  this.models[entity] = model;
1989
1986
  this.registerRelatedModels(model);
@@ -2876,21 +2873,28 @@ class Model {
2876
2873
  static fields() {
2877
2874
  return {};
2878
2875
  }
2876
+ static usedNamespace() {
2877
+ return this.namespace ?? config.model.namespace;
2878
+ }
2879
+ static modelEntity() {
2880
+ return (this.usedNamespace() ? this.usedNamespace() + "/" : "") + this.entity;
2881
+ }
2879
2882
  /**
2880
2883
  * Build the schema by evaluating fields and registry.
2881
2884
  */
2882
2885
  static initializeSchema() {
2883
- this.schemas[this.entity] = {};
2884
- this.fieldsOnDelete[this.entity] = this.fieldsOnDelete[this.entity] ?? {};
2886
+ const entity = this.modelEntity();
2887
+ this.schemas[entity] = {};
2888
+ this.fieldsOnDelete[entity] = this.fieldsOnDelete[entity] ?? {};
2885
2889
  const registry = {
2886
2890
  ...this.fields(),
2887
- ...this.registries[this.entity]
2891
+ ...this.registries[entity]
2888
2892
  };
2889
2893
  for (const key in registry) {
2890
2894
  const attribute = registry[key];
2891
- this.schemas[this.entity][key] = typeof attribute === "function" ? attribute() : attribute;
2892
- if (this.fieldsOnDelete[this.entity][key]) {
2893
- this.schemas[this.entity][key] = this.schemas[this.entity][key].onDelete(this.fieldsOnDelete[this.entity][key]);
2895
+ this.schemas[entity][key] = typeof attribute === "function" ? attribute() : attribute;
2896
+ if (this.fieldsOnDelete[entity][key]) {
2897
+ this.schemas[entity][key] = this.schemas[entity][key].onDelete(this.fieldsOnDelete[entity][key]);
2894
2898
  }
2895
2899
  }
2896
2900
  }
@@ -2898,18 +2902,18 @@ class Model {
2898
2902
  * Set the attribute to the registry.
2899
2903
  */
2900
2904
  static setRegistry(key, attribute) {
2901
- if (!this.registries[this.entity]) {
2902
- this.registries[this.entity] = {};
2905
+ if (!this.registries[this.modelEntity()]) {
2906
+ this.registries[this.modelEntity()] = {};
2903
2907
  }
2904
- this.registries[this.entity][key] = attribute;
2908
+ this.registries[this.modelEntity()][key] = attribute;
2905
2909
  return this;
2906
2910
  }
2907
2911
  /**
2908
2912
  * Set delete behaviour for relation field
2909
2913
  */
2910
2914
  static setFieldDeleteMode(key, mode) {
2911
- this.fieldsOnDelete[this.entity] = this.fieldsOnDelete[this.entity] ?? {};
2912
- this.fieldsOnDelete[this.entity][key] = mode;
2915
+ this.fieldsOnDelete[this.modelEntity()] = this.fieldsOnDelete[this.modelEntity()] ?? {};
2916
+ this.fieldsOnDelete[this.modelEntity()][key] = mode;
2913
2917
  return this;
2914
2918
  }
2915
2919
  /**
@@ -3142,7 +3146,7 @@ class Model {
3142
3146
  * Get the namespace.
3143
3147
  */
3144
3148
  $namespace() {
3145
- return this.$self().namespace ?? config.model.namespace;
3149
+ return this.$self().usedNamespace();
3146
3150
  }
3147
3151
  /**
3148
3152
  * Get the store name.
@@ -3156,6 +3160,18 @@ class Model {
3156
3160
  $baseEntity() {
3157
3161
  return this.$self().baseEntity ?? this.$entity();
3158
3162
  }
3163
+ /**
3164
+ * Get the base namespace for this model.
3165
+ */
3166
+ $baseNamespace() {
3167
+ return this.$self().baseNamespace ?? this.$namespace();
3168
+ }
3169
+ /**
3170
+ * Get the model entity for this model.
3171
+ */
3172
+ $modelEntity() {
3173
+ return this.$self().modelEntity();
3174
+ }
3159
3175
  /**
3160
3176
  * Get the type key for this model.
3161
3177
  */
@@ -3184,7 +3200,7 @@ class Model {
3184
3200
  * Get the model fields for this model.
3185
3201
  */
3186
3202
  $fields() {
3187
- return this.$self().schemas[this.$entity()];
3203
+ return this.$self().schemas[this.$modelEntity()];
3188
3204
  }
3189
3205
  /**
3190
3206
  * Get the model hidden fields
@@ -3211,8 +3227,8 @@ class Model {
3211
3227
  * Bootstrap this model.
3212
3228
  */
3213
3229
  $boot() {
3214
- if (!this.$self().booted[this.$entity()]) {
3215
- this.$self().booted[this.$entity()] = true;
3230
+ if (!this.$self().booted[this.$modelEntity()]) {
3231
+ this.$self().booted[this.$modelEntity()] = true;
3216
3232
  this.$initializeSchema();
3217
3233
  }
3218
3234
  }
@@ -3529,6 +3545,10 @@ __publicField(Model, "entity");
3529
3545
  * The reference to the base entity name if the class extends a base entity.
3530
3546
  */
3531
3547
  __publicField(Model, "baseEntity");
3548
+ /**
3549
+ * The reference to the base namespace if the class extends a base with a different namespace.
3550
+ */
3551
+ __publicField(Model, "baseNamespace");
3532
3552
  /**
3533
3553
  * Define a namespace if you have multiple equal entity names.
3534
3554
  * 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.b86abeaa.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.b86abeaa.cjs';
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.b86abeaa.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.b86abeaa.mjs';
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.b86abeaa.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.b86abeaa.js';
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.$entity()}${parent.$entity()}`;
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.$entity()] = this.one(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.$entity();
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.$entity()}.${key}`, `" which is a one to one Relation(${parent.$fields()[key]?.constructor.name}):`, JSON.stringify(parentRecord[key])]);
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;
@@ -1180,9 +1180,6 @@ class Query {
1180
1180
  * Filter the given collection by the registered order conditions.
1181
1181
  */
1182
1182
  filterOrder(models) {
1183
- if (this.orders.length === 0) {
1184
- return models;
1185
- }
1186
1183
  const fields = this.orders.map((order) => order.field);
1187
1184
  const directions = this.orders.map((order) => order.direction);
1188
1185
  return orderBy(models, fields, directions);
@@ -1308,7 +1305,7 @@ class Query {
1308
1305
  save(records) {
1309
1306
  let processedData = this.newInterpreter().process(records);
1310
1307
  const modelTypes = this.model.$types();
1311
- const isChildEntity = this.model.$baseEntity() !== this.model.$entity();
1308
+ const isChildEntity = this.model.$baseEntity() !== this.model.$entity() || this.model.$baseNamespace() !== this.model.$namespace();
1312
1309
  if (Object.values(modelTypes).length > 0 || isChildEntity) {
1313
1310
  const modelTypesKeys = Object.keys(modelTypes);
1314
1311
  const recordsByTypes = {};
@@ -1322,10 +1319,10 @@ class Query {
1322
1319
  });
1323
1320
  for (const entry in recordsByTypes) {
1324
1321
  const typeModel = modelTypes[entry];
1325
- if (typeModel.entity === this.model.$entity()) {
1322
+ if (typeModel.modelEntity() === this.model.$modelEntity()) {
1326
1323
  processedData = this.newInterpreter().process(recordsByTypes[entry]);
1327
1324
  } else {
1328
- this.newQueryWithConstraints(typeModel.entity).save(recordsByTypes[entry]);
1325
+ this.newQueryWithConstraints(typeModel.modelEntity()).save(recordsByTypes[entry]);
1329
1326
  }
1330
1327
  }
1331
1328
  }
@@ -1981,7 +1978,7 @@ class Database {
1981
1978
  * Register the given model.
1982
1979
  */
1983
1980
  register(model) {
1984
- const entity = model.$entity();
1981
+ const entity = model.$self().modelEntity();
1985
1982
  if (!this.models[entity]) {
1986
1983
  this.models[entity] = model;
1987
1984
  this.registerRelatedModels(model);
@@ -2874,21 +2871,28 @@ class Model {
2874
2871
  static fields() {
2875
2872
  return {};
2876
2873
  }
2874
+ static usedNamespace() {
2875
+ return this.namespace ?? config.model.namespace;
2876
+ }
2877
+ static modelEntity() {
2878
+ return (this.usedNamespace() ? this.usedNamespace() + "/" : "") + this.entity;
2879
+ }
2877
2880
  /**
2878
2881
  * Build the schema by evaluating fields and registry.
2879
2882
  */
2880
2883
  static initializeSchema() {
2881
- this.schemas[this.entity] = {};
2882
- this.fieldsOnDelete[this.entity] = this.fieldsOnDelete[this.entity] ?? {};
2884
+ const entity = this.modelEntity();
2885
+ this.schemas[entity] = {};
2886
+ this.fieldsOnDelete[entity] = this.fieldsOnDelete[entity] ?? {};
2883
2887
  const registry = {
2884
2888
  ...this.fields(),
2885
- ...this.registries[this.entity]
2889
+ ...this.registries[entity]
2886
2890
  };
2887
2891
  for (const key in registry) {
2888
2892
  const attribute = registry[key];
2889
- this.schemas[this.entity][key] = typeof attribute === "function" ? attribute() : attribute;
2890
- if (this.fieldsOnDelete[this.entity][key]) {
2891
- this.schemas[this.entity][key] = this.schemas[this.entity][key].onDelete(this.fieldsOnDelete[this.entity][key]);
2893
+ this.schemas[entity][key] = typeof attribute === "function" ? attribute() : attribute;
2894
+ if (this.fieldsOnDelete[entity][key]) {
2895
+ this.schemas[entity][key] = this.schemas[entity][key].onDelete(this.fieldsOnDelete[entity][key]);
2892
2896
  }
2893
2897
  }
2894
2898
  }
@@ -2896,18 +2900,18 @@ class Model {
2896
2900
  * Set the attribute to the registry.
2897
2901
  */
2898
2902
  static setRegistry(key, attribute) {
2899
- if (!this.registries[this.entity]) {
2900
- this.registries[this.entity] = {};
2903
+ if (!this.registries[this.modelEntity()]) {
2904
+ this.registries[this.modelEntity()] = {};
2901
2905
  }
2902
- this.registries[this.entity][key] = attribute;
2906
+ this.registries[this.modelEntity()][key] = attribute;
2903
2907
  return this;
2904
2908
  }
2905
2909
  /**
2906
2910
  * Set delete behaviour for relation field
2907
2911
  */
2908
2912
  static setFieldDeleteMode(key, mode) {
2909
- this.fieldsOnDelete[this.entity] = this.fieldsOnDelete[this.entity] ?? {};
2910
- this.fieldsOnDelete[this.entity][key] = mode;
2913
+ this.fieldsOnDelete[this.modelEntity()] = this.fieldsOnDelete[this.modelEntity()] ?? {};
2914
+ this.fieldsOnDelete[this.modelEntity()][key] = mode;
2911
2915
  return this;
2912
2916
  }
2913
2917
  /**
@@ -3140,7 +3144,7 @@ class Model {
3140
3144
  * Get the namespace.
3141
3145
  */
3142
3146
  $namespace() {
3143
- return this.$self().namespace ?? config.model.namespace;
3147
+ return this.$self().usedNamespace();
3144
3148
  }
3145
3149
  /**
3146
3150
  * Get the store name.
@@ -3154,6 +3158,18 @@ class Model {
3154
3158
  $baseEntity() {
3155
3159
  return this.$self().baseEntity ?? this.$entity();
3156
3160
  }
3161
+ /**
3162
+ * Get the base namespace for this model.
3163
+ */
3164
+ $baseNamespace() {
3165
+ return this.$self().baseNamespace ?? this.$namespace();
3166
+ }
3167
+ /**
3168
+ * Get the model entity for this model.
3169
+ */
3170
+ $modelEntity() {
3171
+ return this.$self().modelEntity();
3172
+ }
3157
3173
  /**
3158
3174
  * Get the type key for this model.
3159
3175
  */
@@ -3182,7 +3198,7 @@ class Model {
3182
3198
  * Get the model fields for this model.
3183
3199
  */
3184
3200
  $fields() {
3185
- return this.$self().schemas[this.$entity()];
3201
+ return this.$self().schemas[this.$modelEntity()];
3186
3202
  }
3187
3203
  /**
3188
3204
  * Get the model hidden fields
@@ -3209,8 +3225,8 @@ class Model {
3209
3225
  * Bootstrap this model.
3210
3226
  */
3211
3227
  $boot() {
3212
- if (!this.$self().booted[this.$entity()]) {
3213
- this.$self().booted[this.$entity()] = true;
3228
+ if (!this.$self().booted[this.$modelEntity()]) {
3229
+ this.$self().booted[this.$modelEntity()] = true;
3214
3230
  this.$initializeSchema();
3215
3231
  }
3216
3232
  }
@@ -3527,6 +3543,10 @@ __publicField(Model, "entity");
3527
3543
  * The reference to the base entity name if the class extends a base entity.
3528
3544
  */
3529
3545
  __publicField(Model, "baseEntity");
3546
+ /**
3547
+ * The reference to the base namespace if the class extends a base with a different namespace.
3548
+ */
3549
+ __publicField(Model, "baseNamespace");
3530
3550
  /**
3531
3551
  * Define a namespace if you have multiple equal entity names.
3532
3552
  * Resulting in "{namespace}/{entity}"
@@ -1,7 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.cjs';
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
  /**
@@ -1,7 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.mjs';
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
  /**
@@ -1,7 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.js';
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
  /**
@@ -1,7 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.cjs';
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.b86abeaa.mjs';
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.b86abeaa.js';
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.b86abeaa.cjs';
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.b86abeaa.mjs';
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.b86abeaa.js';
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$1> {
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$1 | Model$1[] | null ? GetElementType<NonNullable<M[T]>> : never;
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$1> = {
324
- [K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys$1<M>] extends Model$1 ? M[WithKeys$1<M>] : never>>;
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$1> = (query: Query<M>) => void;
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$1> {
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$1 | Model$1[] | null ? GetElementType<NonNullable<M[T]>> : never;
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$1> = {
324
- [K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys$1<M>] extends Model$1 ? M[WithKeys$1<M>] : never>>;
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$1> = (query: Query<M>) => void;
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$1> {
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$1 | Model$1[] | null ? GetElementType<NonNullable<M[T]>> : never;
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$1> = {
324
- [K in keyof M]: EagerLoadConstraint<GetElementType<M[WithKeys$1<M>] extends Model$1 ? M[WithKeys$1<M>] : never>>;
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$1> = (query: Query<M>) => void;
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,8 +1,7 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.b86abeaa.cjs';
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 {
@@ -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.b86abeaa.mjs';
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.b86abeaa.js';
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 {
@@ -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.b86abeaa.cjs';
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 {
@@ -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.b86abeaa.mjs';
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.b86abeaa.js';
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-28583149.676ad48",
3
+ "version": "1.9.0-28583486.807fa36",
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-28583149.676ad48"
49
+ "@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.9.0-28583486.807fa36"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@nuxt/eslint-config": "^0.3.10",