pinia-orm-edge 1.10.0-28876029.ceaaf3e → 1.10.0-28876069.dc9d711
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 +3 -2
- package/dist/casts.d.mts +3 -2
- package/dist/casts.d.ts +3 -2
- package/dist/decorators.d.cts +4 -3
- package/dist/decorators.d.mts +4 -3
- package/dist/decorators.d.ts +4 -3
- package/dist/helpers.d.cts +3 -2
- package/dist/helpers.d.mts +3 -2
- package/dist/helpers.d.ts +3 -2
- package/dist/index.cjs +27 -8
- package/dist/index.d.cts +8 -17
- package/dist/index.d.mts +8 -17
- package/dist/index.d.ts +8 -17
- package/dist/index.mjs +27 -8
- package/dist/nanoid/async.d.cts +3 -2
- package/dist/nanoid/async.d.mts +3 -2
- package/dist/nanoid/async.d.ts +3 -2
- package/dist/nanoid/index.d.cts +3 -2
- package/dist/nanoid/index.d.mts +3 -2
- package/dist/nanoid/index.d.ts +3 -2
- package/dist/nanoid/non-secure.d.cts +3 -2
- package/dist/nanoid/non-secure.d.mts +3 -2
- package/dist/nanoid/non-secure.d.ts +3 -2
- package/dist/shared/{pinia-orm.fd1280fe.d.cts → pinia-orm.cf7a7464.d.cts} +88 -25
- package/dist/shared/{pinia-orm.fd1280fe.d.mts → pinia-orm.cf7a7464.d.mts} +88 -25
- package/dist/shared/{pinia-orm.fd1280fe.d.ts → pinia-orm.cf7a7464.d.ts} +88 -25
- package/dist/uuid/v1.d.cts +3 -2
- package/dist/uuid/v1.d.mts +3 -2
- package/dist/uuid/v1.d.ts +3 -2
- package/dist/uuid/v4.d.cts +3 -2
- package/dist/uuid/v4.d.mts +3 -2
- package/dist/uuid/v4.d.ts +3 -2
- package/package.json +5 -5
package/dist/casts.d.cts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, q as ModelFields } from './shared/pinia-orm.cf7a7464.cjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class ArrayCast extends CastAttribute {
|
7
8
|
/**
|
package/dist/casts.d.mts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, q as ModelFields } from './shared/pinia-orm.cf7a7464.mjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class ArrayCast extends CastAttribute {
|
7
8
|
/**
|
package/dist/casts.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, q as ModelFields } from './shared/pinia-orm.cf7a7464.js';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class ArrayCast extends CastAttribute {
|
7
8
|
/**
|
package/dist/decorators.d.cts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
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.cf7a7464.cjs';
|
2
|
+
export { at as NanoidOptions } from './shared/pinia-orm.cf7a7464.cjs';
|
3
3
|
import 'pinia';
|
4
|
-
import '
|
4
|
+
import 'vue-demi';
|
5
5
|
import '@pinia-orm/normalizr';
|
6
|
+
import '@/composables';
|
6
7
|
|
7
8
|
/**
|
8
9
|
* Create an Attr attribute property decorator.
|
package/dist/decorators.d.mts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
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.cf7a7464.mjs';
|
2
|
+
export { at as NanoidOptions } from './shared/pinia-orm.cf7a7464.mjs';
|
3
3
|
import 'pinia';
|
4
|
-
import '
|
4
|
+
import 'vue-demi';
|
5
5
|
import '@pinia-orm/normalizr';
|
6
|
+
import '@/composables';
|
6
7
|
|
7
8
|
/**
|
8
9
|
* Create an Attr attribute property decorator.
|
package/dist/decorators.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
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.cf7a7464.js';
|
2
|
+
export { at as NanoidOptions } from './shared/pinia-orm.cf7a7464.js';
|
3
3
|
import 'pinia';
|
4
|
-
import '
|
4
|
+
import 'vue-demi';
|
5
5
|
import '@pinia-orm/normalizr';
|
6
|
+
import '@/composables';
|
6
7
|
|
7
8
|
/**
|
8
9
|
* Create an Attr attribute property decorator.
|
package/dist/helpers.d.cts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.cf7a7464.cjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
7
8
|
|
package/dist/helpers.d.mts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.cf7a7464.mjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
7
8
|
|
package/dist/helpers.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { M as Model, b as Collection } from './shared/pinia-orm.
|
1
|
+
import { M as Model, b as Collection } from './shared/pinia-orm.cf7a7464.js';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
type SortFlags = 'SORT_REGULAR' | 'SORT_FLAG_CASE';
|
7
8
|
|
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
|
-
|
591
|
-
|
592
|
-
|
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,
|
2
|
-
export { A as AfterHook,
|
1
|
+
import { R as Repository, C as Constructor, M as Model, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.cf7a7464.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.cf7a7464.cjs';
|
3
3
|
import { Pinia } from 'pinia';
|
4
|
-
import '
|
4
|
+
import 'vue-demi';
|
5
5
|
import '@pinia-orm/normalizr';
|
6
|
+
import '@/composables';
|
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,
|
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,
|
2
|
-
export { A as AfterHook,
|
1
|
+
import { R as Repository, C as Constructor, M as Model, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.cf7a7464.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.cf7a7464.mjs';
|
3
3
|
import { Pinia } from 'pinia';
|
4
|
-
import '
|
4
|
+
import 'vue-demi';
|
5
5
|
import '@pinia-orm/normalizr';
|
6
|
+
import '@/composables';
|
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,
|
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,
|
2
|
-
export { A as AfterHook,
|
1
|
+
import { R as Repository, C as Constructor, M as Model, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.cf7a7464.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.cf7a7464.js';
|
3
3
|
import { Pinia } from 'pinia';
|
4
|
-
import '
|
4
|
+
import 'vue-demi';
|
5
5
|
import '@pinia-orm/normalizr';
|
6
|
+
import '@/composables';
|
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,
|
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
|
-
|
589
|
-
|
590
|
-
|
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
|
*/
|
package/dist/nanoid/async.d.cts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.cjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
/**
|
7
8
|
* Create a cast nanoid/async.
|
package/dist/nanoid/async.d.mts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.mjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
/**
|
7
8
|
* Create a cast nanoid/async.
|
package/dist/nanoid/async.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.js';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
/**
|
7
8
|
* Create a cast nanoid/async.
|
package/dist/nanoid/index.d.cts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.cjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
7
8
|
static parameters?: NanoidOptions;
|
package/dist/nanoid/index.d.mts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.mjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
7
8
|
static parameters?: NanoidOptions;
|
package/dist/nanoid/index.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.js';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
7
8
|
static parameters?: NanoidOptions;
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.cjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
7
8
|
static parameters?: NanoidOptions;
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.mjs';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
7
8
|
static parameters?: NanoidOptions;
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { a2 as CastAttribute, at as NanoidOptions, q as ModelFields, aq as PropertyDecorator } from '../shared/pinia-orm.cf7a7464.js';
|
2
2
|
import 'pinia';
|
3
|
-
import '
|
3
|
+
import 'vue-demi';
|
4
4
|
import '@pinia-orm/normalizr';
|
5
|
+
import '@/composables';
|
5
6
|
|
6
7
|
declare class UidCast extends CastAttribute {
|
7
8
|
static parameters?: NanoidOptions;
|