@aiao/rxdb-vue 0.0.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Aiao Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # rxdb-vue
@@ -0,0 +1,149 @@
1
+ import { EntityStaticType, EntityType } from '../../rxdb/src/index.ts';
2
+ import { ComputedRef, Ref } from 'vue';
3
+ type UseOptions<T> = T | (() => T) | Ref<T> | ComputedRef<T>;
4
+ export interface RxDBResource<T> {
5
+ /**
6
+ * 资源的数值
7
+ */
8
+ readonly value: T;
9
+ /**
10
+ * 资源的错误
11
+ */
12
+ readonly error: Error | undefined;
13
+ /**
14
+ * 资源的加载状态
15
+ */
16
+ readonly isLoading: boolean;
17
+ /**
18
+ * 资源的空状态
19
+ */
20
+ readonly isEmpty: boolean | undefined;
21
+ /**
22
+ * 资源是否具有数值
23
+ */
24
+ readonly hasValue: boolean;
25
+ }
26
+ /**
27
+ * 通过 ID 获取单个实体
28
+ *
29
+ * @param EntityType 实体类
30
+ * @param options 实体的 ID 或选项对象
31
+ * @returns 包含实体的响应式资源对象
32
+ */
33
+ export declare const useGet: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "getOptions">>) => RxDBResource<InstanceType<T> | undefined>;
34
+ /**
35
+ * 查找匹配条件的单个实体
36
+ *
37
+ * @param EntityType 实体类
38
+ * @param options 查询选项(where 子句、排序等)
39
+ * @returns 包含实体的响应式资源对象
40
+ */
41
+ export declare const useFindOne: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findOneOptions">>) => RxDBResource<InstanceType<T> | undefined>;
42
+ /**
43
+ * Find one entity or throw an error if not found
44
+ *
45
+ * @param EntityType The entity class
46
+ * @param options Query options
47
+ * @returns A reactive resource object containing the entity
48
+ */
49
+ export declare const useFindOneOrFail: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findOneOrFailOptions">>) => RxDBResource<InstanceType<T> | undefined>;
50
+ /**
51
+ * Find multiple entities matching the criteria
52
+ *
53
+ * @param EntityType The entity class
54
+ * @param options Query options
55
+ * @returns A reactive resource object containing an array of entities
56
+ */
57
+ export declare const useFind: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findOptions">>) => RxDBResource<InstanceType<T>[]>;
58
+ /**
59
+ * Find all entities
60
+ *
61
+ * @param EntityType The entity class
62
+ * @param options Query options
63
+ * @returns A reactive resource object containing all entities
64
+ */
65
+ export declare const useFindAll: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findAllOptions">>) => RxDBResource<InstanceType<T>[]>;
66
+ /**
67
+ * Count entities matching the criteria
68
+ *
69
+ * @param EntityType The entity class
70
+ * @param options Query options
71
+ * @returns A reactive resource object containing the count
72
+ */
73
+ export declare const useCount: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "countOptions">>) => RxDBResource<number>;
74
+ /**
75
+ * Find all descendant entities in a tree structure
76
+ *
77
+ * @param EntityType The entity class
78
+ * @param options Tree query options (entityId, depth, etc.)
79
+ * @returns A reactive resource object containing descendant entities
80
+ */
81
+ export declare const useFindDescendants: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findTreeOptions">>) => RxDBResource<InstanceType<T>[]>;
82
+ /**
83
+ * Count descendant entities in a tree structure
84
+ *
85
+ * @param EntityType The entity class
86
+ * @param options Tree query options
87
+ * @returns A reactive resource object containing the count
88
+ */
89
+ export declare const useCountDescendants: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findTreeOptions">>) => RxDBResource<number>;
90
+ /**
91
+ * Find all ancestor entities in a tree structure
92
+ *
93
+ * @param EntityType The entity class
94
+ * @param options Tree query options
95
+ * @returns A reactive resource object containing ancestor entities
96
+ */
97
+ export declare const useFindAncestors: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findTreeOptions">>) => RxDBResource<InstanceType<T>[]>;
98
+ /**
99
+ * Count ancestor entities in a tree structure
100
+ *
101
+ * @param EntityType The entity class
102
+ * @param options Tree query options
103
+ * @returns A reactive resource object containing the count
104
+ */
105
+ export declare const useCountAncestors: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findTreeOptions">>) => RxDBResource<number>;
106
+ /**
107
+ * Find neighbor entities in a graph structure
108
+ *
109
+ * @param EntityType The entity class
110
+ * @param options Graph query options (entityId, direction, level, etc.)
111
+ * @returns A reactive resource object containing neighbor entities
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const { value: friends } = useGraphNeighbors(User, {
116
+ * entityId: 'user-1',
117
+ * direction: 'out',
118
+ * level: 1
119
+ * });
120
+ * ```
121
+ */
122
+ export declare const useGraphNeighbors: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findNeighborsOptions">>) => RxDBResource<InstanceType<T>[]>;
123
+ /**
124
+ * Count neighbor entities in a graph structure
125
+ *
126
+ * @param EntityType The entity class
127
+ * @param options Graph query options
128
+ * @returns A reactive resource object containing the count
129
+ */
130
+ export declare const useCountNeighbors: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findNeighborsOptions">>) => RxDBResource<number>;
131
+ /**
132
+ * Find paths between two entities in a graph
133
+ *
134
+ * @param EntityType The entity class
135
+ * @param options Path query options (fromId, toId, maxDepth, etc.)
136
+ * @returns A reactive resource object containing paths
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const { value: paths } = useGraphPaths(User, {
141
+ * fromId: 'user-1',
142
+ * toId: 'user-2',
143
+ * maxDepth: 5
144
+ * });
145
+ * ```
146
+ */
147
+ export declare const useGraphPaths: <T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, "findPathsOptions">>) => RxDBResource<any[]>;
148
+ export {};
149
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAiD,GAAG,EAAS,MAAM,KAAK,CAAC;AAE7F,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE7D,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE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AiB,GAAI,CAAC,SAAS,UAAU,EACpD,YAAY,CAAC,EACb,SAAS,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,KAC/D,YAAY,CAAC,MAAM,CAA4E,CAAC;AAEnG;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,KAC3D,YAAY,CAAC,GAAG,EAAE,CAAuE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './hooks';
2
+ export * from './rxdb-vue';
3
+ export * from './useInfiniteScroll';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,149 @@
1
+ import { isFunction as O } from "@aiao/utils";
2
+ import { reactive as N, ref as p, watch as E, markRaw as D, onScopeDispose as P, isRef as M, provide as j, inject as k, unref as C, computed as m, onMounted as V, onBeforeUnmount as q } from "vue";
3
+ const i = (n, e, c, s) => {
4
+ const r = N({
5
+ value: c,
6
+ error: void 0,
7
+ isLoading: !0,
8
+ isEmpty: void 0,
9
+ hasValue: !1
10
+ }), o = p(void 0);
11
+ let a = !1;
12
+ return E(
13
+ [() => n, () => e, () => O(s) ? s() : M(s) ? s.value : s],
14
+ ([, , g], [, , h]) => {
15
+ a = !1, o.value && (o.value.unsubscribe(), o.value = void 0), (h === void 0 || !r.hasValue) && (r.isLoading = !0);
16
+ const v = n[e];
17
+ if (!v || typeof v != "function") {
18
+ const t = new Error(`Method "${String(e)}" not found on EntityType`);
19
+ Promise.resolve().then(() => {
20
+ a || (r.error = t, r.isLoading = !1);
21
+ });
22
+ return;
23
+ }
24
+ try {
25
+ o.value = v(g).subscribe({
26
+ next: (t) => {
27
+ if (a) return;
28
+ r.isLoading = !1, r.hasValue = !0, r.error = void 0;
29
+ let l;
30
+ Array.isArray(t) ? (l = [...t.map((y) => D(y))], r.isEmpty = t.length === 0) : (l = t != null ? D(t) : t, r.isEmpty = t == null), r.value = l;
31
+ },
32
+ error: (t) => {
33
+ a || (r.isLoading = !1, r.hasValue = !1, r.error = t, console.error(`RxDB query error in ${String(e)}:`, t));
34
+ }
35
+ });
36
+ } catch (t) {
37
+ const l = t instanceof Error ? t : new Error(String(t));
38
+ Promise.resolve().then(() => {
39
+ a || (r.isLoading = !1, r.error = l);
40
+ });
41
+ }
42
+ },
43
+ { immediate: !0 }
44
+ ), P(() => {
45
+ a = !0, o.value && (o.value.unsubscribe(), o.value = void 0);
46
+ }), r;
47
+ }, T = (n, e) => i(n, "get", void 0, e), $ = (n, e) => i(n, "findOne", void 0, e), z = (n, e) => i(n, "findOneOrFail", void 0, e), Q = (n, e) => i(n, "find", [], e), U = (n, e) => i(n, "findAll", [], e), H = (n, e) => i(n, "count", 0, e), W = (n, e) => i(n, "findDescendants", [], e), X = (n, e) => i(n, "countDescendants", 0, e), Y = (n, e) => i(n, "findAncestors", [], e), Z = (n, e) => i(n, "countAncestors", 0, e), _ = (n, e) => i(n, "findNeighbors", [], e), ee = (n, e) => i(n, "countNeighbors", 0, e), ne = (n, e) => i(n, "findPaths", [], e), B = /* @__PURE__ */ Symbol("RxDBProvider");
48
+ function I() {
49
+ return {
50
+ provideRxDB: (c) => j(B, c),
51
+ injectRxDB: () => {
52
+ const c = k(B);
53
+ return C(c);
54
+ }
55
+ };
56
+ }
57
+ const { injectRxDB: S, provideRxDB: re } = I(), te = () => {
58
+ const n = S();
59
+ if (!n)
60
+ throw new Error("RxDB instance not found. Make sure to call provideRxDB() in your app setup.");
61
+ return n;
62
+ };
63
+ function se(n, e) {
64
+ const c = S();
65
+ if (!c)
66
+ throw new Error("RxDB not provided. Make sure to call provideRxDB() in parent component.");
67
+ const s = p([]), r = p(!1), o = p(!0), a = p(!1);
68
+ let f = !0;
69
+ const g = [], h = m(() => O(e) ? e() : M(e) ? e.value : e), v = m(() => s.value.flat().map((u) => D(u))), t = () => {
70
+ if (s.value.length === 0) return;
71
+ const u = s.value[s.value.length - 1];
72
+ if (u.length !== 0)
73
+ return u[u.length - 1];
74
+ }, l = () => {
75
+ if (r.value || !o.value || !f)
76
+ return;
77
+ r.value = !0;
78
+ const u = t(), d = JSON.parse(JSON.stringify(h.value));
79
+ u && (d.after = u);
80
+ const F = s.value.length, A = c.entityManager.getRepository(n).findByCursor(d).subscribe({
81
+ next: (x) => {
82
+ if (!f) return;
83
+ const R = [...s.value];
84
+ R[F] = x, s.value = R;
85
+ const L = d.limit || 100;
86
+ x.length < L && (o.value = !1), r.value = !1;
87
+ },
88
+ error: () => {
89
+ f && (r.value = !1);
90
+ },
91
+ complete: () => {
92
+ f && (r.value = !1);
93
+ }
94
+ });
95
+ g.push(A);
96
+ }, y = () => {
97
+ g.forEach((u) => u.unsubscribe()), g.length = 0;
98
+ }, w = () => {
99
+ queueMicrotask(() => {
100
+ y(), s.value = [], r.value = !1, o.value = !0, setTimeout(() => l(), 0);
101
+ });
102
+ };
103
+ V(() => {
104
+ a.value || (a.value = !0, Promise.resolve().then(() => {
105
+ f && l();
106
+ }));
107
+ });
108
+ const b = p(JSON.stringify(h.value));
109
+ return E(
110
+ () => h.value,
111
+ (u) => {
112
+ const d = JSON.stringify(u);
113
+ a.value && b.value !== d && (b.value = d, queueMicrotask(() => {
114
+ y(), s.value = [], r.value = !1, o.value = !0, setTimeout(() => l(), 0);
115
+ }));
116
+ },
117
+ { deep: !0 }
118
+ ), q(() => {
119
+ f = !1, y();
120
+ }), {
121
+ value: v,
122
+ // 优化:移除不必要的 as any 断言,因为 allItems 类型已兼容
123
+ isEmpty: m(() => v.value.length === 0 && !r.value && a.value),
124
+ isLoading: r,
125
+ hasMore: o,
126
+ loadMore: l,
127
+ refresh: w
128
+ };
129
+ }
130
+ export {
131
+ S as injectRxDB,
132
+ I as makeRxDBDependencyInjector,
133
+ re as provideRxDB,
134
+ H as useCount,
135
+ Z as useCountAncestors,
136
+ X as useCountDescendants,
137
+ ee as useCountNeighbors,
138
+ Q as useFind,
139
+ U as useFindAll,
140
+ Y as useFindAncestors,
141
+ W as useFindDescendants,
142
+ $ as useFindOne,
143
+ z as useFindOneOrFail,
144
+ T as useGet,
145
+ _ as useGraphNeighbors,
146
+ ne as useGraphPaths,
147
+ se as useInfiniteScroll,
148
+ te as useRxDB
149
+ };
@@ -0,0 +1,14 @@
1
+ import { RxDB } from '../../rxdb/src/index.ts';
2
+ import { Ref } from 'vue';
3
+ interface PGliteDependencyInjection<T extends RxDB> {
4
+ provideRxDB: (db: Ref<T | undefined> | (T | undefined)) => void;
5
+ injectRxDB: () => T | undefined;
6
+ }
7
+ /**
8
+ * RxDB 依赖注入
9
+ */
10
+ declare function makeRxDBDependencyInjector<T extends RxDB>(): PGliteDependencyInjection<T>;
11
+ declare const injectRxDB: () => RxDB | undefined, provideRxDB: (db: RxDB | Ref<RxDB | undefined, RxDB | undefined> | undefined) => void;
12
+ declare const useRxDB: () => RxDB;
13
+ export { injectRxDB, makeRxDBDependencyInjector, provideRxDB, useRxDB };
14
+ //# sourceMappingURL=rxdb-vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rxdb-vue.d.ts","sourceRoot":"","sources":["../src/rxdb-vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAmB,GAAG,EAAS,MAAM,KAAK,CAAC;AAElD,UAAU,yBAAyB,CAAC,CAAC,SAAS,IAAI;IAChD,WAAW,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC;IAChE,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjC;AAID;;GAEG;AACH,iBAAS,0BAA0B,CAAC,CAAC,SAAS,IAAI,KAAK,yBAAyB,CAAC,CAAC,CAAC,CAYlF;AAED,QAAA,MAAQ,UAAU,0BAAE,WAAW,sEAvB8B,IAuBS,CAAC;AAEvE,QAAA,MAAM,OAAO,QAAO,IAMnB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { EntityStaticType, EntityType } from '../../rxdb/src/index.ts';
2
+ import { ComputedRef, Ref } from 'vue';
3
+ type UseOptions<T> = T | (() => T);
4
+ export interface InfiniteScrollResource<T> {
5
+ value: ComputedRef<T[]>;
6
+ isEmpty: ComputedRef<boolean>;
7
+ isLoading: Ref<boolean>;
8
+ hasMore: Ref<boolean>;
9
+ loadMore: () => void;
10
+ refresh: () => void;
11
+ }
12
+ /**
13
+ * 用于游标分页的无限滚动钩子
14
+ *
15
+ * @param EntityType 实体类
16
+ * @param options 带有游标分页的查询选项
17
+ * @returns 包含无限滚动控制的资源对象
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const resource = useInfiniteScroll(Todo, {
22
+ * where: { completed: false },
23
+ * orderBy: [{ field: 'createdAt', sort: 'desc' }],
24
+ * limit: 50
25
+ * });
26
+ * ```
27
+ */
28
+ export declare function useInfiniteScroll<T extends EntityType>(EntityType: T, options: UseOptions<EntityStaticType<T, 'findByCursorOptions'>>): InfiniteScrollResource<InstanceType<T>>;
29
+ export {};
30
+ //# sourceMappingURL=useInfiniteScroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInfiniteScroll.d.ts","sourceRoot":"","sources":["../src/useInfiniteScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,GAAG,EAAoE,MAAM,KAAK,CAAC;AAGnH,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnC,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,UAAU,EACpD,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,GAC9D,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAoJzC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@aiao/rxdb-vue",
3
+ "version": "0.0.7",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "@aiao/source": "./src/index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "dependencies": {
18
+ "@aiao/rxdb": "0.0.7",
19
+ "@aiao/utils": "0.0.7"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "!**/*.tsbuildinfo"
24
+ ],
25
+ "nx": {
26
+ "name": "rxdb-vue",
27
+ "tags": [
28
+ "vue-lib"
29
+ ]
30
+ }
31
+ }