pinia-orm-edge 1.10.0-28876005.15f5c42 → 1.10.0-28876035.953826a

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,5 +1,6 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.fd1280fe.cjs';
1
+ import { a2 as CastAttribute, q as ModelFields } from './shared/pinia-orm.2ebac49c.cjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
package/dist/casts.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.fd1280fe.mjs';
1
+ import { a2 as CastAttribute, q as ModelFields } from './shared/pinia-orm.2ebac49c.mjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
package/dist/casts.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.fd1280fe.js';
1
+ import { a2 as CastAttribute, q as ModelFields } from './shared/pinia-orm.2ebac49c.js';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,6 +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.fd1280fe.cjs';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.fd1280fe.cjs';
1
+ import { a3 as TypeDefault, aq as PropertyDecorator, ar as TypeOptions, as as UidOptions, M as Model, w as PrimaryKey, L as deleteModes, a2 as CastAttribute, am as Mutator } from './shared/pinia-orm.2ebac49c.cjs';
2
+ export { at as NanoidOptions } from './shared/pinia-orm.2ebac49c.cjs';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
@@ -1,6 +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.fd1280fe.mjs';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.fd1280fe.mjs';
1
+ import { a3 as TypeDefault, aq as PropertyDecorator, ar as TypeOptions, as as UidOptions, M as Model, w as PrimaryKey, L as deleteModes, a2 as CastAttribute, am as Mutator } from './shared/pinia-orm.2ebac49c.mjs';
2
+ export { at as NanoidOptions } from './shared/pinia-orm.2ebac49c.mjs';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
@@ -1,6 +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.fd1280fe.js';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.fd1280fe.js';
1
+ import { a3 as TypeDefault, aq as PropertyDecorator, ar as TypeOptions, as as UidOptions, M as Model, w as PrimaryKey, L as deleteModes, a2 as CastAttribute, am as Mutator } from './shared/pinia-orm.2ebac49c.js';
2
+ export { at as NanoidOptions } from './shared/pinia-orm.2ebac49c.js';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
@@ -1,5 +1,6 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.fd1280fe.cjs';
1
+ import { M as Model, b as Collection } from './shared/pinia-orm.2ebac49c.cjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.fd1280fe.mjs';
1
+ import { M as Model, b as Collection } from './shared/pinia-orm.2ebac49c.mjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
package/dist/helpers.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.fd1280fe.js';
1
+ import { M as Model, b as Collection } from './shared/pinia-orm.2ebac49c.js';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
package/dist/index.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
  const Utils = require('./shared/pinia-orm.a88d8365.cjs');
4
4
  const pinia = require('pinia');
5
5
  const normalizr = require('@pinia-orm/normalizr');
6
+ const vueDemi = require('vue-demi');
6
7
  const CastAttribute = require('./shared/pinia-orm.a7e3e0f3.cjs');
7
8
 
8
9
  var __defProp$l = Object.defineProperty;
@@ -586,12 +587,19 @@ function useStoreActions(query) {
586
587
  };
587
588
  }
588
589
 
589
- function useDataStore(id, options, query) {
590
- return pinia.defineStore(id, {
591
- state: () => ({ data: {} }),
592
- actions: useStoreActions(query),
590
+ function useDataStore(id, options, customOptions, query) {
591
+ if (config.pinia.storeType === "optionStore") {
592
+ return pinia.defineStore(id, {
593
+ state: () => ({ data: {} }),
594
+ actions: useStoreActions(query),
595
+ ...options
596
+ });
597
+ }
598
+ return pinia.defineStore(id, () => ({
599
+ data: vueDemi.ref({}),
600
+ ...useStoreActions(query),
593
601
  ...options
594
- });
602
+ }), customOptions);
595
603
  }
596
604
 
597
605
  var __defProp$e = Object.defineProperty;
@@ -809,11 +817,11 @@ class Query {
809
817
  * Commit a store action and get the data
810
818
  */
811
819
  commit(name, payload) {
812
- const store = useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this)(this.pinia);
820
+ const store = useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this.model.$piniaExtend(), this)(this.pinia);
813
821
  if (undefined) {
814
822
  undefined.accept(pinia.acceptHMRUpdate(store, undefined));
815
823
  }
816
- if (name && typeof store[name] === "function") {
824
+ if (name && name !== "all" && name !== "get" && typeof store[name] === "function") {
817
825
  store[name](payload, false);
818
826
  }
819
827
  if (this.cache && ["get", "all", "insert", "flush", "delete", "update", "destroy"].includes(name)) {
@@ -1661,6 +1669,9 @@ const CONFIG_DEFAULTS = {
1661
1669
  cache: {
1662
1670
  shared: true,
1663
1671
  provider: WeakCache
1672
+ },
1673
+ pinia: {
1674
+ storeType: "optionStore"
1664
1675
  }
1665
1676
  };
1666
1677
  const config = { ...CONFIG_DEFAULTS };
@@ -1778,7 +1789,7 @@ class Repository {
1778
1789
  * Returns the pinia store used with this model
1779
1790
  */
1780
1791
  piniaStore() {
1781
- return useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this.query())(this.pinia);
1792
+ return useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this.model.$piniaExtend(), this.query())(this.pinia);
1782
1793
  }
1783
1794
  repo(modelOrRepository) {
1784
1795
  return useRepo(modelOrRepository);
@@ -2066,6 +2077,7 @@ function mapRepos(modelsOrRepositories) {
2066
2077
  function createORM(options) {
2067
2078
  config.model = { ...CONFIG_DEFAULTS.model, ...options?.model };
2068
2079
  config.cache = options?.cache === false ? false : { ...CONFIG_DEFAULTS.cache, ...options?.cache !== true && options?.cache };
2080
+ config.pinia = { ...CONFIG_DEFAULTS.pinia, ...options?.pinia };
2069
2081
  if (options?.plugins) {
2070
2082
  options.plugins.forEach((plugin) => plugins.push(plugin));
2071
2083
  }
@@ -3332,6 +3344,12 @@ class Model {
3332
3344
  $piniaOptions() {
3333
3345
  return this.$self().piniaOptions;
3334
3346
  }
3347
+ /**
3348
+ * Get the extended functionality.
3349
+ */
3350
+ $piniaExtend() {
3351
+ return this.$self().piniaExtend;
3352
+ }
3335
3353
  /**
3336
3354
  * Get the primary key for this model.
3337
3355
  */
@@ -3745,6 +3763,7 @@ __publicField(Model, "registries", {});
3745
3763
  * to the 'defineStore' function of pinia.
3746
3764
  */
3747
3765
  __publicField(Model, "piniaOptions", {});
3766
+ __publicField(Model, "piniaExtend", {});
3748
3767
  /**
3749
3768
  * The mutators for the model.
3750
3769
  */
package/dist/index.d.cts CHANGED
@@ -1,25 +1,13 @@
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.fd1280fe.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.fd1280fe.cjs';
1
+ import { R as Repository, C as Constructor, M as Model, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.2ebac49c.cjs';
2
+ export { A as AfterHook, J as Attribute, B as BeforeHook, Q as BelongsTo, T as BelongsToMany, ap as CacheConfig, h as CacheConfigOptions, a2 as CastAttribute, a1 as Casts, b as Collection, k as CreatePiniaOrm, d as DataStore, D as DataStoreState, m as Database, K as Dictionary, ak as EagerLoad, al as EagerLoadConstraint, E as Element, a as Elements, a9 as GetElementType, af as Group, ah as GroupBy, ai as GroupByFields, G as GroupedCollection, U as HasMany, X as HasManyBy, Y as HasManyThrough, V as HasOne, z as InheritanceTypes, j as InstallOptions, a5 as Interpreter, I as Item, y as MetaValues, g as ModelConfigOptions, q as ModelFields, x as ModelOptions, t as ModelRegistries, v as ModelRegistry, s as ModelSchemas, Z as MorphMany, a0 as MorphOne, _ as MorphTo, $ as MorphToMany, am as Mutator, an as MutatorFunctions, ao as Mutators, a8 as NonMethodKeys, N as NormalizedData, ae as Order, ag as OrderBy, aj as OrderDirection, i as PiniaConfigOptions, e as PiniaOrmPlugin, P as PiniaOrmPluginContext, w as PrimaryKey, a6 as Query, O as Relation, o as Schema, n as Schemas, S as StoreActions, a4 as Type, a3 as TypeDefault, aa as UltimateKeys, a7 as Where, ad as WhereGroup, ab as WherePrimaryClosure, ac as WhereSecondaryClosure, H as WithKeys, l as createORM, f as definePiniaOrmPlugin, L as deleteModes, p as plugins, r as registerPlugins, c as useDataStore, u as useStoreActions } from './shared/pinia-orm.2ebac49c.cjs';
3
3
  import { Pinia } from 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
7
8
  declare function useRepo<R extends Repository<any>>(repository: R | Constructor<R>, pinia?: Pinia): R;
8
9
  declare function useRepo<M extends Model>(model: Constructor<M>, pinia?: Pinia): Repository<M>;
9
10
 
10
- declare function useStoreActions(query?: Query): {
11
- save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
12
- insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
13
- update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
14
- fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
15
- destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
16
- /**
17
- * Commit `delete` change to the store.
18
- */
19
- delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
20
- flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
21
- };
22
-
23
11
  type ModelOrRepository<M extends typeof Model, R extends typeof Repository> = M | R;
24
12
  type ModelsOrRepositories<M extends typeof Model = any, R extends typeof Repository = any> = Record<string, ModelOrRepository<M, R>>;
25
13
  type MappedRepositories<MR extends ModelsOrRepositories> = {
@@ -41,9 +29,12 @@ declare const CONFIG_DEFAULTS: {
41
29
  shared: boolean;
42
30
  provider: typeof WeakCache;
43
31
  };
32
+ pinia: {
33
+ storeType: string;
34
+ };
44
35
  };
45
36
  declare const config: FilledInstallOptions & {
46
37
  [key: string]: any;
47
38
  };
48
39
 
49
- export { CONFIG_DEFAULTS, Constructor, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
40
+ export { CONFIG_DEFAULTS, Constructor, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Repository, config, mapRepos, useRepo };
package/dist/index.d.mts CHANGED
@@ -1,25 +1,13 @@
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.fd1280fe.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.fd1280fe.mjs';
1
+ import { R as Repository, C as Constructor, M as Model, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.2ebac49c.mjs';
2
+ export { A as AfterHook, J as Attribute, B as BeforeHook, Q as BelongsTo, T as BelongsToMany, ap as CacheConfig, h as CacheConfigOptions, a2 as CastAttribute, a1 as Casts, b as Collection, k as CreatePiniaOrm, d as DataStore, D as DataStoreState, m as Database, K as Dictionary, ak as EagerLoad, al as EagerLoadConstraint, E as Element, a as Elements, a9 as GetElementType, af as Group, ah as GroupBy, ai as GroupByFields, G as GroupedCollection, U as HasMany, X as HasManyBy, Y as HasManyThrough, V as HasOne, z as InheritanceTypes, j as InstallOptions, a5 as Interpreter, I as Item, y as MetaValues, g as ModelConfigOptions, q as ModelFields, x as ModelOptions, t as ModelRegistries, v as ModelRegistry, s as ModelSchemas, Z as MorphMany, a0 as MorphOne, _ as MorphTo, $ as MorphToMany, am as Mutator, an as MutatorFunctions, ao as Mutators, a8 as NonMethodKeys, N as NormalizedData, ae as Order, ag as OrderBy, aj as OrderDirection, i as PiniaConfigOptions, e as PiniaOrmPlugin, P as PiniaOrmPluginContext, w as PrimaryKey, a6 as Query, O as Relation, o as Schema, n as Schemas, S as StoreActions, a4 as Type, a3 as TypeDefault, aa as UltimateKeys, a7 as Where, ad as WhereGroup, ab as WherePrimaryClosure, ac as WhereSecondaryClosure, H as WithKeys, l as createORM, f as definePiniaOrmPlugin, L as deleteModes, p as plugins, r as registerPlugins, c as useDataStore, u as useStoreActions } from './shared/pinia-orm.2ebac49c.mjs';
3
3
  import { Pinia } from 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
7
8
  declare function useRepo<R extends Repository<any>>(repository: R | Constructor<R>, pinia?: Pinia): R;
8
9
  declare function useRepo<M extends Model>(model: Constructor<M>, pinia?: Pinia): Repository<M>;
9
10
 
10
- declare function useStoreActions(query?: Query): {
11
- save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
12
- insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
13
- update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
14
- fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
15
- destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
16
- /**
17
- * Commit `delete` change to the store.
18
- */
19
- delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
20
- flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
21
- };
22
-
23
11
  type ModelOrRepository<M extends typeof Model, R extends typeof Repository> = M | R;
24
12
  type ModelsOrRepositories<M extends typeof Model = any, R extends typeof Repository = any> = Record<string, ModelOrRepository<M, R>>;
25
13
  type MappedRepositories<MR extends ModelsOrRepositories> = {
@@ -41,9 +29,12 @@ declare const CONFIG_DEFAULTS: {
41
29
  shared: boolean;
42
30
  provider: typeof WeakCache;
43
31
  };
32
+ pinia: {
33
+ storeType: string;
34
+ };
44
35
  };
45
36
  declare const config: FilledInstallOptions & {
46
37
  [key: string]: any;
47
38
  };
48
39
 
49
- export { CONFIG_DEFAULTS, Constructor, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
40
+ export { CONFIG_DEFAULTS, Constructor, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Repository, config, mapRepos, useRepo };
package/dist/index.d.ts CHANGED
@@ -1,25 +1,13 @@
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.fd1280fe.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.fd1280fe.js';
1
+ import { R as Repository, C as Constructor, M as Model, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.2ebac49c.js';
2
+ export { A as AfterHook, J as Attribute, B as BeforeHook, Q as BelongsTo, T as BelongsToMany, ap as CacheConfig, h as CacheConfigOptions, a2 as CastAttribute, a1 as Casts, b as Collection, k as CreatePiniaOrm, d as DataStore, D as DataStoreState, m as Database, K as Dictionary, ak as EagerLoad, al as EagerLoadConstraint, E as Element, a as Elements, a9 as GetElementType, af as Group, ah as GroupBy, ai as GroupByFields, G as GroupedCollection, U as HasMany, X as HasManyBy, Y as HasManyThrough, V as HasOne, z as InheritanceTypes, j as InstallOptions, a5 as Interpreter, I as Item, y as MetaValues, g as ModelConfigOptions, q as ModelFields, x as ModelOptions, t as ModelRegistries, v as ModelRegistry, s as ModelSchemas, Z as MorphMany, a0 as MorphOne, _ as MorphTo, $ as MorphToMany, am as Mutator, an as MutatorFunctions, ao as Mutators, a8 as NonMethodKeys, N as NormalizedData, ae as Order, ag as OrderBy, aj as OrderDirection, i as PiniaConfigOptions, e as PiniaOrmPlugin, P as PiniaOrmPluginContext, w as PrimaryKey, a6 as Query, O as Relation, o as Schema, n as Schemas, S as StoreActions, a4 as Type, a3 as TypeDefault, aa as UltimateKeys, a7 as Where, ad as WhereGroup, ab as WherePrimaryClosure, ac as WhereSecondaryClosure, H as WithKeys, l as createORM, f as definePiniaOrmPlugin, L as deleteModes, p as plugins, r as registerPlugins, c as useDataStore, u as useStoreActions } from './shared/pinia-orm.2ebac49c.js';
3
3
  import { Pinia } from 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
7
8
  declare function useRepo<R extends Repository<any>>(repository: R | Constructor<R>, pinia?: Pinia): R;
8
9
  declare function useRepo<M extends Model>(model: Constructor<M>, pinia?: Pinia): Repository<M>;
9
10
 
10
- declare function useStoreActions(query?: Query): {
11
- save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
12
- insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
13
- update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
14
- fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
15
- destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
16
- /**
17
- * Commit `delete` change to the store.
18
- */
19
- delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
20
- flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
21
- };
22
-
23
11
  type ModelOrRepository<M extends typeof Model, R extends typeof Repository> = M | R;
24
12
  type ModelsOrRepositories<M extends typeof Model = any, R extends typeof Repository = any> = Record<string, ModelOrRepository<M, R>>;
25
13
  type MappedRepositories<MR extends ModelsOrRepositories> = {
@@ -41,9 +29,12 @@ declare const CONFIG_DEFAULTS: {
41
29
  shared: boolean;
42
30
  provider: typeof WeakCache;
43
31
  };
32
+ pinia: {
33
+ storeType: string;
34
+ };
44
35
  };
45
36
  declare const config: FilledInstallOptions & {
46
37
  [key: string]: any;
47
38
  };
48
39
 
49
- export { CONFIG_DEFAULTS, Constructor, DataStore, Elements, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Query, Repository, config, mapRepos, useRepo, useStoreActions };
40
+ export { CONFIG_DEFAULTS, Constructor, FilledInstallOptions, type MappedRepositories, Model, type ModelOrRepository, type ModelsOrRepositories, Repository, config, mapRepos, useRepo };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { i as isArray, t as throwError, a as assert, g as generateId, b as isNullish, c as compareWithOperator, d as generateKey, e as isEmpty, f as isFunction, h as groupBy, o as orderBy, j as equals, k as isDate } from './shared/pinia-orm.f3905af9.mjs';
2
2
  import { defineStore, acceptHMRUpdate } from 'pinia';
3
3
  import { schema, normalize } from '@pinia-orm/normalizr';
4
+ import { ref } from 'vue-demi';
4
5
  export { C as CastAttribute } from './shared/pinia-orm.4ff2e12f.mjs';
5
6
 
6
7
  var __defProp$l = Object.defineProperty;
@@ -584,12 +585,19 @@ function useStoreActions(query) {
584
585
  };
585
586
  }
586
587
 
587
- function useDataStore(id, options, query) {
588
- return defineStore(id, {
589
- state: () => ({ data: {} }),
590
- actions: useStoreActions(query),
588
+ function useDataStore(id, options, customOptions, query) {
589
+ if (config.pinia.storeType === "optionStore") {
590
+ return defineStore(id, {
591
+ state: () => ({ data: {} }),
592
+ actions: useStoreActions(query),
593
+ ...options
594
+ });
595
+ }
596
+ return defineStore(id, () => ({
597
+ data: ref({}),
598
+ ...useStoreActions(query),
591
599
  ...options
592
- });
600
+ }), customOptions);
593
601
  }
594
602
 
595
603
  var __defProp$e = Object.defineProperty;
@@ -807,11 +815,11 @@ class Query {
807
815
  * Commit a store action and get the data
808
816
  */
809
817
  commit(name, payload) {
810
- const store = useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this)(this.pinia);
818
+ const store = useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this.model.$piniaExtend(), this)(this.pinia);
811
819
  if (import.meta.hot) {
812
820
  import.meta.hot.accept(acceptHMRUpdate(store, import.meta.hot));
813
821
  }
814
- if (name && typeof store[name] === "function") {
822
+ if (name && name !== "all" && name !== "get" && typeof store[name] === "function") {
815
823
  store[name](payload, false);
816
824
  }
817
825
  if (this.cache && ["get", "all", "insert", "flush", "delete", "update", "destroy"].includes(name)) {
@@ -1659,6 +1667,9 @@ const CONFIG_DEFAULTS = {
1659
1667
  cache: {
1660
1668
  shared: true,
1661
1669
  provider: WeakCache
1670
+ },
1671
+ pinia: {
1672
+ storeType: "optionStore"
1662
1673
  }
1663
1674
  };
1664
1675
  const config = { ...CONFIG_DEFAULTS };
@@ -1776,7 +1787,7 @@ class Repository {
1776
1787
  * Returns the pinia store used with this model
1777
1788
  */
1778
1789
  piniaStore() {
1779
- return useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this.query())(this.pinia);
1790
+ return useDataStore(this.model.$storeName(), this.model.$piniaOptions(), this.model.$piniaExtend(), this.query())(this.pinia);
1780
1791
  }
1781
1792
  repo(modelOrRepository) {
1782
1793
  return useRepo(modelOrRepository);
@@ -2064,6 +2075,7 @@ function mapRepos(modelsOrRepositories) {
2064
2075
  function createORM(options) {
2065
2076
  config.model = { ...CONFIG_DEFAULTS.model, ...options?.model };
2066
2077
  config.cache = options?.cache === false ? false : { ...CONFIG_DEFAULTS.cache, ...options?.cache !== true && options?.cache };
2078
+ config.pinia = { ...CONFIG_DEFAULTS.pinia, ...options?.pinia };
2067
2079
  if (options?.plugins) {
2068
2080
  options.plugins.forEach((plugin) => plugins.push(plugin));
2069
2081
  }
@@ -3330,6 +3342,12 @@ class Model {
3330
3342
  $piniaOptions() {
3331
3343
  return this.$self().piniaOptions;
3332
3344
  }
3345
+ /**
3346
+ * Get the extended functionality.
3347
+ */
3348
+ $piniaExtend() {
3349
+ return this.$self().piniaExtend;
3350
+ }
3333
3351
  /**
3334
3352
  * Get the primary key for this model.
3335
3353
  */
@@ -3743,6 +3761,7 @@ __publicField(Model, "registries", {});
3743
3761
  * to the 'defineStore' function of pinia.
3744
3762
  */
3745
3763
  __publicField(Model, "piniaOptions", {});
3764
+ __publicField(Model, "piniaExtend", {});
3746
3765
  /**
3747
3766
  * The mutators for the model.
3748
3767
  */
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.cjs';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.cjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.mjs';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.mjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.js';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.js';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.cjs';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.cjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.mjs';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.mjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.js';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.js';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.cjs';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.cjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.mjs';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.mjs';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.js';
1
+ import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.js';
2
2
  import 'pinia';
3
+ import 'vue-demi';
3
4
  import '@/composables';
4
5
  import '@pinia-orm/normalizr';
5
6
 
@@ -1,5 +1,6 @@
1
1
  import * as pinia from 'pinia';
2
- import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
2
+ import { PiniaPlugin, DefineStoreOptionsBase, DefineSetupStoreOptions, Pinia } from 'pinia';
3
+ import * as vue_demi from 'vue-demi';
3
4
  import * as __composables from '@/composables';
4
5
  import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
5
6
 
@@ -59,14 +60,19 @@ interface CacheConfigOptions {
59
60
  shared?: boolean;
60
61
  provider?: typeof WeakCache<string, Model[]>;
61
62
  }
63
+ interface PiniaConfigOptions {
64
+ storeType?: 'optionStore' | 'setupStore' | string;
65
+ }
62
66
  interface InstallOptions {
63
67
  model?: ModelConfigOptions;
64
68
  cache?: CacheConfigOptions | boolean;
69
+ pinia?: PiniaConfigOptions;
65
70
  plugins?: PiniaOrmPlugin[];
66
71
  }
67
72
  interface FilledInstallOptions {
68
73
  model: Required<ModelConfigOptions>;
69
74
  cache: Required<CacheConfigOptions | boolean>;
75
+ pinia: Required<PiniaConfigOptions>;
70
76
  }
71
77
  interface CreatePiniaOrm {
72
78
  use(plugin: PiniaOrmPlugin): this;
@@ -295,6 +301,54 @@ declare class Interpreter {
295
301
  private getSchema;
296
302
  }
297
303
 
304
+ declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, customOptions?: DefineSetupStoreOptions<string, S, T, any>, query?: Query<any>): pinia.StoreDefinition<string, pinia._UnwrapAll<Pick<{
305
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
306
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
307
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
308
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
309
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
310
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
311
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
312
+ data: vue_demi.Ref<Record<string, any>>;
313
+ }, "data">>, Pick<{
314
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
315
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
316
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
317
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
318
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
319
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
320
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
321
+ data: vue_demi.Ref<Record<string, any>>;
322
+ }, never>, Pick<{
323
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
324
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
325
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
326
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
327
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
328
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
329
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
330
+ data: vue_demi.Ref<Record<string, any>>;
331
+ }, "insert" | "flush" | "delete" | "update" | "destroy" | "save" | "fresh">>;
332
+ interface DataStoreState {
333
+ data: Record<string, any>;
334
+ [s: string]: any;
335
+ }
336
+ type DataStore = ReturnType<typeof __composables['useDataStore']>;
337
+
338
+ declare function useStoreActions(query?: Query): {
339
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
340
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
341
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
342
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
343
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
344
+ /**
345
+ * Commit `delete` change to the store.
346
+ */
347
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
348
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
349
+ };
350
+ type StoreActions = 'insert' | 'flush' | 'delete' | 'update' | 'destroy' | 'save' | 'fresh';
351
+
298
352
  interface Where<T = Model> {
299
353
  field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
300
354
  value: WhereSecondaryClosure<T> | any;
@@ -408,7 +462,7 @@ declare class Query<M extends Model = Model> {
408
462
  /**
409
463
  * Commit a store action and get the data
410
464
  */
411
- protected commit(name: string, payload?: any): Record<string, any>;
465
+ protected commit(name: StoreActions | 'all' | 'get', payload?: any): Record<string, any>;
412
466
  /**
413
467
  * Make meta field visible
414
468
  */
@@ -1426,6 +1480,7 @@ declare class Model {
1426
1480
  * to the 'defineStore' function of pinia.
1427
1481
  */
1428
1482
  protected static piniaOptions: {};
1483
+ protected static piniaExtend: {};
1429
1484
  /**
1430
1485
  * The mutators for the model.
1431
1486
  */
@@ -1650,6 +1705,10 @@ declare class Model {
1650
1705
  * Get the pinia options for this model.
1651
1706
  */
1652
1707
  $piniaOptions(): {};
1708
+ /**
1709
+ * Get the extended functionality.
1710
+ */
1711
+ $piniaExtend(): {};
1653
1712
  /**
1654
1713
  * Get the primary key for this model.
1655
1714
  */
@@ -1787,21 +1846,6 @@ type Item<M extends Model = Model> = M | null;
1787
1846
  type Collection<M extends Model = Model> = M[];
1788
1847
  type GroupedCollection<M extends Model = Model> = Record<string, M[]>;
1789
1848
 
1790
- declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query<any>): pinia.StoreDefinition<string, S, {}, {
1791
- save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1792
- insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1793
- update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1794
- fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1795
- destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1796
- delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1797
- flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1798
- }>;
1799
- interface DataStoreState {
1800
- data: Record<string, any>;
1801
- [s: string]: any;
1802
- }
1803
- type DataStore = ReturnType<typeof __composables['useDataStore']>;
1804
-
1805
1849
  interface ModelConstructor<M extends Model> extends Constructor<M> {
1806
1850
  newRawInstance(): M;
1807
1851
  }
@@ -1908,7 +1952,25 @@ declare class Repository<M extends Model = Model> {
1908
1952
  /**
1909
1953
  * Returns the pinia store used with this model
1910
1954
  */
1911
- piniaStore<S extends DataStoreState = DataStoreState>(): pinia.Store<string, S, {}, {
1955
+ piniaStore<S extends DataStoreState = DataStoreState>(): pinia.Store<string, pinia._UnwrapAll<Pick<{
1956
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1957
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1958
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1959
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1960
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1961
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1962
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1963
+ data: vue_demi.Ref<Record<string, any>>;
1964
+ }, "data">>, Pick<{
1965
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1966
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1967
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1968
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1969
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1970
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1971
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1972
+ data: vue_demi.Ref<Record<string, any>>;
1973
+ }, never>, Pick<{
1912
1974
  save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1913
1975
  insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1914
1976
  update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
@@ -1916,7 +1978,8 @@ declare class Repository<M extends Model = Model> {
1916
1978
  destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1917
1979
  delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1918
1980
  flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1919
- }>;
1981
+ data: vue_demi.Ref<Record<string, any>>;
1982
+ }, "insert" | "flush" | "delete" | "update" | "destroy" | "save" | "fresh">>;
1920
1983
  /**
1921
1984
  * Create a new repository with the given model.
1922
1985
  */
@@ -2058,4 +2121,4 @@ declare class Repository<M extends Model = Model> {
2058
2121
  flush(): M[];
2059
2122
  }
2060
2123
 
2061
- export { type Casts as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStore as D, type Elements as E, type FilledInstallOptions as F, type GroupedCollection as G, type deleteModes as H, type Item as I, Relation as J, BelongsTo as K, BelongsToMany as L, Model as M, type NormalizedData as N, HasMany as O, type PiniaOrmPluginContext as P, Query as Q, Repository as R, type Schemas as S, HasOne as T, HasManyBy as U, HasManyThrough as V, WeakCache as W, MorphMany as X, MorphTo as Y, MorphToMany as Z, MorphOne as _, type Element as a, CastAttribute as a0, type TypeDefault as a1, Type as a2, Interpreter as a3, type Where as a4, type NonMethodKeys as a5, type GetElementType as a6, type UltimateKeys as a7, type WherePrimaryClosure as a8, type WhereSecondaryClosure as a9, type WhereGroup as aa, type Order as ab, type Group as ac, type OrderBy as ad, type GroupBy as ae, type GroupByFields as af, type OrderDirection as ag, type EagerLoad as ah, type EagerLoadConstraint as ai, type Mutator as aj, type MutatorFunctions as ak, type Mutators as al, type CacheConfig as am, type PropertyDecorator as an, type TypeOptions as ao, type UidOptions as ap, type NanoidOptions as aq, type Collection as b, type DataStoreState as c, type PiniaOrmPlugin as d, definePiniaOrmPlugin as e, type ModelConfigOptions as f, type CacheConfigOptions as g, type InstallOptions as h, type CreatePiniaOrm as i, createORM as j, Database as k, Schema as l, type ModelFields as m, type ModelSchemas as n, type ModelRegistries as o, plugins as p, type ModelRegistry as q, registerPlugins as r, type PrimaryKey as s, type ModelOptions as t, useDataStore as u, type MetaValues as v, type InheritanceTypes as w, type WithKeys as x, Attribute as y, type Dictionary as z };
2124
+ export { MorphToMany as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStoreState as D, type Element as E, type FilledInstallOptions as F, type GroupedCollection as G, type WithKeys as H, type Item as I, Attribute as J, type Dictionary as K, type deleteModes as L, Model as M, type NormalizedData as N, Relation as O, type PiniaOrmPluginContext as P, BelongsTo as Q, Repository as R, type StoreActions as S, BelongsToMany as T, HasMany as U, HasOne as V, WeakCache as W, HasManyBy as X, HasManyThrough as Y, MorphMany as Z, MorphTo as _, type Elements as a, MorphOne as a0, type Casts as a1, CastAttribute as a2, type TypeDefault as a3, Type as a4, Interpreter as a5, Query as a6, type Where as a7, type NonMethodKeys as a8, type GetElementType as a9, type UltimateKeys as aa, type WherePrimaryClosure as ab, type WhereSecondaryClosure as ac, type WhereGroup as ad, type Order as ae, type Group as af, type OrderBy as ag, type GroupBy as ah, type GroupByFields as ai, type OrderDirection as aj, type EagerLoad as ak, type EagerLoadConstraint as al, type Mutator as am, type MutatorFunctions as an, type Mutators as ao, type CacheConfig as ap, type PropertyDecorator as aq, type TypeOptions as ar, type UidOptions as as, type NanoidOptions as at, type Collection as b, useDataStore as c, type DataStore as d, type PiniaOrmPlugin as e, definePiniaOrmPlugin as f, type ModelConfigOptions as g, type CacheConfigOptions as h, type PiniaConfigOptions as i, type InstallOptions as j, type CreatePiniaOrm as k, createORM as l, Database as m, type Schemas as n, Schema as o, plugins as p, type ModelFields as q, registerPlugins as r, type ModelSchemas as s, type ModelRegistries as t, useStoreActions as u, type ModelRegistry as v, type PrimaryKey as w, type ModelOptions as x, type MetaValues as y, type InheritanceTypes as z };
@@ -1,5 +1,6 @@
1
1
  import * as pinia from 'pinia';
2
- import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
2
+ import { PiniaPlugin, DefineStoreOptionsBase, DefineSetupStoreOptions, Pinia } from 'pinia';
3
+ import * as vue_demi from 'vue-demi';
3
4
  import * as __composables from '@/composables';
4
5
  import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
5
6
 
@@ -59,14 +60,19 @@ interface CacheConfigOptions {
59
60
  shared?: boolean;
60
61
  provider?: typeof WeakCache<string, Model[]>;
61
62
  }
63
+ interface PiniaConfigOptions {
64
+ storeType?: 'optionStore' | 'setupStore' | string;
65
+ }
62
66
  interface InstallOptions {
63
67
  model?: ModelConfigOptions;
64
68
  cache?: CacheConfigOptions | boolean;
69
+ pinia?: PiniaConfigOptions;
65
70
  plugins?: PiniaOrmPlugin[];
66
71
  }
67
72
  interface FilledInstallOptions {
68
73
  model: Required<ModelConfigOptions>;
69
74
  cache: Required<CacheConfigOptions | boolean>;
75
+ pinia: Required<PiniaConfigOptions>;
70
76
  }
71
77
  interface CreatePiniaOrm {
72
78
  use(plugin: PiniaOrmPlugin): this;
@@ -295,6 +301,54 @@ declare class Interpreter {
295
301
  private getSchema;
296
302
  }
297
303
 
304
+ declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, customOptions?: DefineSetupStoreOptions<string, S, T, any>, query?: Query<any>): pinia.StoreDefinition<string, pinia._UnwrapAll<Pick<{
305
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
306
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
307
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
308
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
309
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
310
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
311
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
312
+ data: vue_demi.Ref<Record<string, any>>;
313
+ }, "data">>, Pick<{
314
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
315
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
316
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
317
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
318
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
319
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
320
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
321
+ data: vue_demi.Ref<Record<string, any>>;
322
+ }, never>, Pick<{
323
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
324
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
325
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
326
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
327
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
328
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
329
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
330
+ data: vue_demi.Ref<Record<string, any>>;
331
+ }, "insert" | "flush" | "delete" | "update" | "destroy" | "save" | "fresh">>;
332
+ interface DataStoreState {
333
+ data: Record<string, any>;
334
+ [s: string]: any;
335
+ }
336
+ type DataStore = ReturnType<typeof __composables['useDataStore']>;
337
+
338
+ declare function useStoreActions(query?: Query): {
339
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
340
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
341
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
342
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
343
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
344
+ /**
345
+ * Commit `delete` change to the store.
346
+ */
347
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
348
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
349
+ };
350
+ type StoreActions = 'insert' | 'flush' | 'delete' | 'update' | 'destroy' | 'save' | 'fresh';
351
+
298
352
  interface Where<T = Model> {
299
353
  field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
300
354
  value: WhereSecondaryClosure<T> | any;
@@ -408,7 +462,7 @@ declare class Query<M extends Model = Model> {
408
462
  /**
409
463
  * Commit a store action and get the data
410
464
  */
411
- protected commit(name: string, payload?: any): Record<string, any>;
465
+ protected commit(name: StoreActions | 'all' | 'get', payload?: any): Record<string, any>;
412
466
  /**
413
467
  * Make meta field visible
414
468
  */
@@ -1426,6 +1480,7 @@ declare class Model {
1426
1480
  * to the 'defineStore' function of pinia.
1427
1481
  */
1428
1482
  protected static piniaOptions: {};
1483
+ protected static piniaExtend: {};
1429
1484
  /**
1430
1485
  * The mutators for the model.
1431
1486
  */
@@ -1650,6 +1705,10 @@ declare class Model {
1650
1705
  * Get the pinia options for this model.
1651
1706
  */
1652
1707
  $piniaOptions(): {};
1708
+ /**
1709
+ * Get the extended functionality.
1710
+ */
1711
+ $piniaExtend(): {};
1653
1712
  /**
1654
1713
  * Get the primary key for this model.
1655
1714
  */
@@ -1787,21 +1846,6 @@ type Item<M extends Model = Model> = M | null;
1787
1846
  type Collection<M extends Model = Model> = M[];
1788
1847
  type GroupedCollection<M extends Model = Model> = Record<string, M[]>;
1789
1848
 
1790
- declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query<any>): pinia.StoreDefinition<string, S, {}, {
1791
- save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1792
- insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1793
- update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1794
- fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1795
- destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1796
- delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1797
- flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1798
- }>;
1799
- interface DataStoreState {
1800
- data: Record<string, any>;
1801
- [s: string]: any;
1802
- }
1803
- type DataStore = ReturnType<typeof __composables['useDataStore']>;
1804
-
1805
1849
  interface ModelConstructor<M extends Model> extends Constructor<M> {
1806
1850
  newRawInstance(): M;
1807
1851
  }
@@ -1908,7 +1952,25 @@ declare class Repository<M extends Model = Model> {
1908
1952
  /**
1909
1953
  * Returns the pinia store used with this model
1910
1954
  */
1911
- piniaStore<S extends DataStoreState = DataStoreState>(): pinia.Store<string, S, {}, {
1955
+ piniaStore<S extends DataStoreState = DataStoreState>(): pinia.Store<string, pinia._UnwrapAll<Pick<{
1956
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1957
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1958
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1959
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1960
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1961
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1962
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1963
+ data: vue_demi.Ref<Record<string, any>>;
1964
+ }, "data">>, Pick<{
1965
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1966
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1967
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1968
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1969
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1970
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1971
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1972
+ data: vue_demi.Ref<Record<string, any>>;
1973
+ }, never>, Pick<{
1912
1974
  save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1913
1975
  insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1914
1976
  update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
@@ -1916,7 +1978,8 @@ declare class Repository<M extends Model = Model> {
1916
1978
  destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1917
1979
  delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1918
1980
  flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1919
- }>;
1981
+ data: vue_demi.Ref<Record<string, any>>;
1982
+ }, "insert" | "flush" | "delete" | "update" | "destroy" | "save" | "fresh">>;
1920
1983
  /**
1921
1984
  * Create a new repository with the given model.
1922
1985
  */
@@ -2058,4 +2121,4 @@ declare class Repository<M extends Model = Model> {
2058
2121
  flush(): M[];
2059
2122
  }
2060
2123
 
2061
- export { type Casts as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStore as D, type Elements as E, type FilledInstallOptions as F, type GroupedCollection as G, type deleteModes as H, type Item as I, Relation as J, BelongsTo as K, BelongsToMany as L, Model as M, type NormalizedData as N, HasMany as O, type PiniaOrmPluginContext as P, Query as Q, Repository as R, type Schemas as S, HasOne as T, HasManyBy as U, HasManyThrough as V, WeakCache as W, MorphMany as X, MorphTo as Y, MorphToMany as Z, MorphOne as _, type Element as a, CastAttribute as a0, type TypeDefault as a1, Type as a2, Interpreter as a3, type Where as a4, type NonMethodKeys as a5, type GetElementType as a6, type UltimateKeys as a7, type WherePrimaryClosure as a8, type WhereSecondaryClosure as a9, type WhereGroup as aa, type Order as ab, type Group as ac, type OrderBy as ad, type GroupBy as ae, type GroupByFields as af, type OrderDirection as ag, type EagerLoad as ah, type EagerLoadConstraint as ai, type Mutator as aj, type MutatorFunctions as ak, type Mutators as al, type CacheConfig as am, type PropertyDecorator as an, type TypeOptions as ao, type UidOptions as ap, type NanoidOptions as aq, type Collection as b, type DataStoreState as c, type PiniaOrmPlugin as d, definePiniaOrmPlugin as e, type ModelConfigOptions as f, type CacheConfigOptions as g, type InstallOptions as h, type CreatePiniaOrm as i, createORM as j, Database as k, Schema as l, type ModelFields as m, type ModelSchemas as n, type ModelRegistries as o, plugins as p, type ModelRegistry as q, registerPlugins as r, type PrimaryKey as s, type ModelOptions as t, useDataStore as u, type MetaValues as v, type InheritanceTypes as w, type WithKeys as x, Attribute as y, type Dictionary as z };
2124
+ export { MorphToMany as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStoreState as D, type Element as E, type FilledInstallOptions as F, type GroupedCollection as G, type WithKeys as H, type Item as I, Attribute as J, type Dictionary as K, type deleteModes as L, Model as M, type NormalizedData as N, Relation as O, type PiniaOrmPluginContext as P, BelongsTo as Q, Repository as R, type StoreActions as S, BelongsToMany as T, HasMany as U, HasOne as V, WeakCache as W, HasManyBy as X, HasManyThrough as Y, MorphMany as Z, MorphTo as _, type Elements as a, MorphOne as a0, type Casts as a1, CastAttribute as a2, type TypeDefault as a3, Type as a4, Interpreter as a5, Query as a6, type Where as a7, type NonMethodKeys as a8, type GetElementType as a9, type UltimateKeys as aa, type WherePrimaryClosure as ab, type WhereSecondaryClosure as ac, type WhereGroup as ad, type Order as ae, type Group as af, type OrderBy as ag, type GroupBy as ah, type GroupByFields as ai, type OrderDirection as aj, type EagerLoad as ak, type EagerLoadConstraint as al, type Mutator as am, type MutatorFunctions as an, type Mutators as ao, type CacheConfig as ap, type PropertyDecorator as aq, type TypeOptions as ar, type UidOptions as as, type NanoidOptions as at, type Collection as b, useDataStore as c, type DataStore as d, type PiniaOrmPlugin as e, definePiniaOrmPlugin as f, type ModelConfigOptions as g, type CacheConfigOptions as h, type PiniaConfigOptions as i, type InstallOptions as j, type CreatePiniaOrm as k, createORM as l, Database as m, type Schemas as n, Schema as o, plugins as p, type ModelFields as q, registerPlugins as r, type ModelSchemas as s, type ModelRegistries as t, useStoreActions as u, type ModelRegistry as v, type PrimaryKey as w, type ModelOptions as x, type MetaValues as y, type InheritanceTypes as z };
@@ -1,5 +1,6 @@
1
1
  import * as pinia from 'pinia';
2
- import { PiniaPlugin, Pinia, DefineStoreOptionsBase } from 'pinia';
2
+ import { PiniaPlugin, DefineStoreOptionsBase, DefineSetupStoreOptions, Pinia } from 'pinia';
3
+ import * as vue_demi from 'vue-demi';
3
4
  import * as __composables from '@/composables';
4
5
  import { schema, Schema as Schema$1 } from '@pinia-orm/normalizr';
5
6
 
@@ -59,14 +60,19 @@ interface CacheConfigOptions {
59
60
  shared?: boolean;
60
61
  provider?: typeof WeakCache<string, Model[]>;
61
62
  }
63
+ interface PiniaConfigOptions {
64
+ storeType?: 'optionStore' | 'setupStore' | string;
65
+ }
62
66
  interface InstallOptions {
63
67
  model?: ModelConfigOptions;
64
68
  cache?: CacheConfigOptions | boolean;
69
+ pinia?: PiniaConfigOptions;
65
70
  plugins?: PiniaOrmPlugin[];
66
71
  }
67
72
  interface FilledInstallOptions {
68
73
  model: Required<ModelConfigOptions>;
69
74
  cache: Required<CacheConfigOptions | boolean>;
75
+ pinia: Required<PiniaConfigOptions>;
70
76
  }
71
77
  interface CreatePiniaOrm {
72
78
  use(plugin: PiniaOrmPlugin): this;
@@ -295,6 +301,54 @@ declare class Interpreter {
295
301
  private getSchema;
296
302
  }
297
303
 
304
+ declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, customOptions?: DefineSetupStoreOptions<string, S, T, any>, query?: Query<any>): pinia.StoreDefinition<string, pinia._UnwrapAll<Pick<{
305
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
306
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
307
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
308
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
309
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
310
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
311
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
312
+ data: vue_demi.Ref<Record<string, any>>;
313
+ }, "data">>, Pick<{
314
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
315
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
316
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
317
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
318
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
319
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
320
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
321
+ data: vue_demi.Ref<Record<string, any>>;
322
+ }, never>, Pick<{
323
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
324
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
325
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
326
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
327
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
328
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
329
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
330
+ data: vue_demi.Ref<Record<string, any>>;
331
+ }, "insert" | "flush" | "delete" | "update" | "destroy" | "save" | "fresh">>;
332
+ interface DataStoreState {
333
+ data: Record<string, any>;
334
+ [s: string]: any;
335
+ }
336
+ type DataStore = ReturnType<typeof __composables['useDataStore']>;
337
+
338
+ declare function useStoreActions(query?: Query): {
339
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
340
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
341
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
342
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
343
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
344
+ /**
345
+ * Commit `delete` change to the store.
346
+ */
347
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
348
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
349
+ };
350
+ type StoreActions = 'insert' | 'flush' | 'delete' | 'update' | 'destroy' | 'save' | 'fresh';
351
+
298
352
  interface Where<T = Model> {
299
353
  field: WherePrimaryClosure<T> | NonMethodKeys<T> | string | string[];
300
354
  value: WhereSecondaryClosure<T> | any;
@@ -408,7 +462,7 @@ declare class Query<M extends Model = Model> {
408
462
  /**
409
463
  * Commit a store action and get the data
410
464
  */
411
- protected commit(name: string, payload?: any): Record<string, any>;
465
+ protected commit(name: StoreActions | 'all' | 'get', payload?: any): Record<string, any>;
412
466
  /**
413
467
  * Make meta field visible
414
468
  */
@@ -1426,6 +1480,7 @@ declare class Model {
1426
1480
  * to the 'defineStore' function of pinia.
1427
1481
  */
1428
1482
  protected static piniaOptions: {};
1483
+ protected static piniaExtend: {};
1429
1484
  /**
1430
1485
  * The mutators for the model.
1431
1486
  */
@@ -1650,6 +1705,10 @@ declare class Model {
1650
1705
  * Get the pinia options for this model.
1651
1706
  */
1652
1707
  $piniaOptions(): {};
1708
+ /**
1709
+ * Get the extended functionality.
1710
+ */
1711
+ $piniaExtend(): {};
1653
1712
  /**
1654
1713
  * Get the primary key for this model.
1655
1714
  */
@@ -1787,21 +1846,6 @@ type Item<M extends Model = Model> = M | null;
1787
1846
  type Collection<M extends Model = Model> = M[];
1788
1847
  type GroupedCollection<M extends Model = Model> = Record<string, M[]>;
1789
1848
 
1790
- declare function useDataStore<S extends DataStoreState, T extends DataStore = DataStore>(id: string, options: DefineStoreOptionsBase<S, T>, query?: Query<any>): pinia.StoreDefinition<string, S, {}, {
1791
- save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1792
- insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1793
- update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1794
- fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1795
- destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1796
- delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1797
- flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1798
- }>;
1799
- interface DataStoreState {
1800
- data: Record<string, any>;
1801
- [s: string]: any;
1802
- }
1803
- type DataStore = ReturnType<typeof __composables['useDataStore']>;
1804
-
1805
1849
  interface ModelConstructor<M extends Model> extends Constructor<M> {
1806
1850
  newRawInstance(): M;
1807
1851
  }
@@ -1908,7 +1952,25 @@ declare class Repository<M extends Model = Model> {
1908
1952
  /**
1909
1953
  * Returns the pinia store used with this model
1910
1954
  */
1911
- piniaStore<S extends DataStoreState = DataStoreState>(): pinia.Store<string, S, {}, {
1955
+ piniaStore<S extends DataStoreState = DataStoreState>(): pinia.Store<string, pinia._UnwrapAll<Pick<{
1956
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1957
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1958
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1959
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1960
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1961
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1962
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1963
+ data: vue_demi.Ref<Record<string, any>>;
1964
+ }, "data">>, Pick<{
1965
+ save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1966
+ insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1967
+ update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1968
+ fresh(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1969
+ destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1970
+ delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1971
+ flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1972
+ data: vue_demi.Ref<Record<string, any>>;
1973
+ }, never>, Pick<{
1912
1974
  save(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1913
1975
  insert(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
1914
1976
  update(this: DataStore, records: Elements, triggerQueryAction?: boolean): void;
@@ -1916,7 +1978,8 @@ declare class Repository<M extends Model = Model> {
1916
1978
  destroy(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1917
1979
  delete(this: DataStore, ids: (string | number)[], triggerQueryAction?: boolean): void;
1918
1980
  flush(this: DataStore, _records?: Elements, triggerQueryAction?: boolean): void;
1919
- }>;
1981
+ data: vue_demi.Ref<Record<string, any>>;
1982
+ }, "insert" | "flush" | "delete" | "update" | "destroy" | "save" | "fresh">>;
1920
1983
  /**
1921
1984
  * Create a new repository with the given model.
1922
1985
  */
@@ -2058,4 +2121,4 @@ declare class Repository<M extends Model = Model> {
2058
2121
  flush(): M[];
2059
2122
  }
2060
2123
 
2061
- export { type Casts as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStore as D, type Elements as E, type FilledInstallOptions as F, type GroupedCollection as G, type deleteModes as H, type Item as I, Relation as J, BelongsTo as K, BelongsToMany as L, Model as M, type NormalizedData as N, HasMany as O, type PiniaOrmPluginContext as P, Query as Q, Repository as R, type Schemas as S, HasOne as T, HasManyBy as U, HasManyThrough as V, WeakCache as W, MorphMany as X, MorphTo as Y, MorphToMany as Z, MorphOne as _, type Element as a, CastAttribute as a0, type TypeDefault as a1, Type as a2, Interpreter as a3, type Where as a4, type NonMethodKeys as a5, type GetElementType as a6, type UltimateKeys as a7, type WherePrimaryClosure as a8, type WhereSecondaryClosure as a9, type WhereGroup as aa, type Order as ab, type Group as ac, type OrderBy as ad, type GroupBy as ae, type GroupByFields as af, type OrderDirection as ag, type EagerLoad as ah, type EagerLoadConstraint as ai, type Mutator as aj, type MutatorFunctions as ak, type Mutators as al, type CacheConfig as am, type PropertyDecorator as an, type TypeOptions as ao, type UidOptions as ap, type NanoidOptions as aq, type Collection as b, type DataStoreState as c, type PiniaOrmPlugin as d, definePiniaOrmPlugin as e, type ModelConfigOptions as f, type CacheConfigOptions as g, type InstallOptions as h, type CreatePiniaOrm as i, createORM as j, Database as k, Schema as l, type ModelFields as m, type ModelSchemas as n, type ModelRegistries as o, plugins as p, type ModelRegistry as q, registerPlugins as r, type PrimaryKey as s, type ModelOptions as t, useDataStore as u, type MetaValues as v, type InheritanceTypes as w, type WithKeys as x, Attribute as y, type Dictionary as z };
2124
+ export { MorphToMany as $, type AfterHook as A, type BeforeHook as B, type Constructor as C, type DataStoreState as D, type Element as E, type FilledInstallOptions as F, type GroupedCollection as G, type WithKeys as H, type Item as I, Attribute as J, type Dictionary as K, type deleteModes as L, Model as M, type NormalizedData as N, Relation as O, type PiniaOrmPluginContext as P, BelongsTo as Q, Repository as R, type StoreActions as S, BelongsToMany as T, HasMany as U, HasOne as V, WeakCache as W, HasManyBy as X, HasManyThrough as Y, MorphMany as Z, MorphTo as _, type Elements as a, MorphOne as a0, type Casts as a1, CastAttribute as a2, type TypeDefault as a3, Type as a4, Interpreter as a5, Query as a6, type Where as a7, type NonMethodKeys as a8, type GetElementType as a9, type UltimateKeys as aa, type WherePrimaryClosure as ab, type WhereSecondaryClosure as ac, type WhereGroup as ad, type Order as ae, type Group as af, type OrderBy as ag, type GroupBy as ah, type GroupByFields as ai, type OrderDirection as aj, type EagerLoad as ak, type EagerLoadConstraint as al, type Mutator as am, type MutatorFunctions as an, type Mutators as ao, type CacheConfig as ap, type PropertyDecorator as aq, type TypeOptions as ar, type UidOptions as as, type NanoidOptions as at, type Collection as b, useDataStore as c, type DataStore as d, type PiniaOrmPlugin as e, definePiniaOrmPlugin as f, type ModelConfigOptions as g, type CacheConfigOptions as h, type PiniaConfigOptions as i, type InstallOptions as j, type CreatePiniaOrm as k, createORM as l, Database as m, type Schemas as n, Schema as o, plugins as p, type ModelFields as q, registerPlugins as r, type ModelSchemas as s, type ModelRegistries as t, useStoreActions as u, type ModelRegistry as v, type PrimaryKey as w, type ModelOptions as x, type MetaValues as y, type InheritanceTypes as z };
@@ -1,6 +1,7 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.cjs';
2
+ import { a2 as CastAttribute, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.cjs';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
@@ -1,6 +1,7 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.mjs';
2
+ import { a2 as CastAttribute, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.mjs';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
package/dist/uuid/v1.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.js';
2
+ import { a2 as CastAttribute, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.js';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
@@ -1,6 +1,7 @@
1
1
  import { V4Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.cjs';
2
+ import { a2 as CastAttribute, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.cjs';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
@@ -1,6 +1,7 @@
1
1
  import { V4Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.mjs';
2
+ import { a2 as CastAttribute, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.mjs';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
package/dist/uuid/v4.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { V4Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.fd1280fe.js';
2
+ import { a2 as CastAttribute, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.2ebac49c.js';
3
3
  import 'pinia';
4
+ import 'vue-demi';
4
5
  import '@/composables';
5
6
  import '@pinia-orm/normalizr';
6
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinia-orm-edge",
3
- "version": "1.10.0-28876005.15f5c42",
3
+ "version": "1.10.0-28876035.953826a",
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.10.0-28876005.15f5c42"
49
+ "@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.10.0-28876035.953826a"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@nuxt/eslint-config": "^0.3.13",
@@ -84,7 +84,7 @@
84
84
  "size-limit": [
85
85
  {
86
86
  "path": "dist/index.mjs",
87
- "limit": "13 kB"
87
+ "limit": "16 kB"
88
88
  },
89
89
  {
90
90
  "path": "dist/decorators.mjs",