@aiao/rxdb-client-generator 0.0.5 → 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/README.md +32 -0
- package/dist/RxDBClientGenerator-DmFzgpuy.js +1056 -0
- package/dist/build-client-lib-BGlzuRcG.js +166 -0
- package/dist/{analyze_file.d.ts → cli/analyze-file.d.ts} +2 -2
- package/dist/cli/analyze-file.d.ts.map +1 -0
- package/dist/{build_rxdb_client_lib.d.ts → cli/build-client-lib.d.ts} +1 -1
- package/dist/cli/build-client-lib.d.ts.map +1 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/{cli.interface.d.ts → cli/cli.interface.d.ts} +1 -1
- package/dist/cli/cli.interface.d.ts.map +1 -0
- package/dist/cli/find-files.d.ts +8 -0
- package/dist/cli/find-files.d.ts.map +1 -0
- package/dist/cli.js +34 -55
- package/dist/core/RxDBClientGenerator.d.ts +71 -0
- package/dist/core/RxDBClientGenerator.d.ts.map +1 -0
- package/dist/core/RxDBClientGenerator.utils.d.ts +36 -0
- package/dist/core/RxDBClientGenerator.utils.d.ts.map +1 -0
- package/dist/core/metadata.utils.d.ts +4 -0
- package/dist/core/metadata.utils.d.ts.map +1 -0
- package/dist/{ts_morph_browser.d.ts → core/ts-morph-browser.d.ts} +63 -85
- package/dist/core/ts-morph-browser.d.ts.map +1 -0
- package/dist/generators/RepositoryGenerator.interface.d.ts +83 -0
- package/dist/generators/RepositoryGenerator.interface.d.ts.map +1 -0
- package/dist/generators/RepositoryGeneratorBase.d.ts +64 -0
- package/dist/generators/RepositoryGeneratorBase.d.ts.map +1 -0
- package/dist/generators/TreeRepositoryGenerator.d.ts +11 -0
- package/dist/generators/TreeRepositoryGenerator.d.ts.map +1 -0
- package/dist/generators/entity-definition.d.ts +10 -0
- package/dist/generators/entity-definition.d.ts.map +1 -0
- package/dist/{generator_entity_properties.d.ts → generators/entity-properties.d.ts} +4 -5
- package/dist/generators/entity-properties.d.ts.map +1 -0
- package/dist/{generator_entity_relations.d.ts → generators/entity-relations.d.ts} +5 -6
- package/dist/generators/entity-relations.d.ts.map +1 -0
- package/dist/generators/entity-rules.d.ts +16 -0
- package/dist/generators/entity-rules.d.ts.map +1 -0
- package/dist/generators/utils.d.ts +3 -0
- package/dist/generators/utils.d.ts.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/plugins/vite.d.ts +4 -0
- package/dist/plugins/vite.d.ts.map +1 -0
- package/dist/vite.js +6 -6
- package/package.json +5 -5
- package/dist/RxDBClientGenerator-B3NS1KdI.js +0 -863
- package/dist/RxDBClientGenerator.d.ts +0 -34
- package/dist/RxDBClientGenerator.d.ts.map +0 -1
- package/dist/RxDBClientGenerator.utils.d.ts +0 -20
- package/dist/RxDBClientGenerator.utils.d.ts.map +0 -1
- package/dist/analyze_file.d.ts.map +0 -1
- package/dist/build_rxdb_client_lib-D1VubBOB.js +0 -93
- package/dist/build_rxdb_client_lib.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.interface.d.ts.map +0 -1
- package/dist/find_files.d.ts +0 -3
- package/dist/find_files.d.ts.map +0 -1
- package/dist/generator_all_entity_definition.d.ts +0 -7
- package/dist/generator_all_entity_definition.d.ts.map +0 -1
- package/dist/generator_entity_definition.d.ts +0 -11
- package/dist/generator_entity_definition.d.ts.map +0 -1
- package/dist/generator_entity_js_file.d.ts +0 -7
- package/dist/generator_entity_js_file.d.ts.map +0 -1
- package/dist/generator_entity_properties.d.ts.map +0 -1
- package/dist/generator_entity_relations.d.ts.map +0 -1
- package/dist/generator_entity_rules.d.ts +0 -14
- package/dist/generator_entity_rules.d.ts.map +0 -1
- package/dist/generator_repository_methods.d.ts +0 -19
- package/dist/generator_repository_methods.d.ts.map +0 -1
- package/dist/generator_tree_repository_methods.d.ts +0 -16
- package/dist/generator_tree_repository_methods.d.ts.map +0 -1
- package/dist/generator_utils.d.ts +0 -3
- package/dist/generator_utils.d.ts.map +0 -1
- package/dist/ts_morph_browser.d.ts.map +0 -1
- package/dist/vite.d.ts +0 -4
- package/dist/vite.d.ts.map +0 -1
- /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { writeFileSync as _, mkdirSync as b } from "node:fs";
|
|
2
|
+
import { normalize as f, resolve as P, join as C, dirname as M } from "node:path";
|
|
3
|
+
import { Project as T, Node as y } from "ts-morph";
|
|
4
|
+
import { a as N } from "./RxDBClientGenerator-DmFzgpuy.js";
|
|
5
|
+
import { ENTITY_BASE_METADATA_OPTIONS as w, TREE_ADJACENCY_LIST_ENTITY_BASE_OPTIONS as A, PropertyType as D, RelationKind as I, OnDeleteAction as S } from "@aiao/rxdb";
|
|
6
|
+
import { glob as R } from "glob";
|
|
7
|
+
function E(r) {
|
|
8
|
+
switch (r) {
|
|
9
|
+
case "EntityBase":
|
|
10
|
+
return [w];
|
|
11
|
+
default:
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function x(r) {
|
|
16
|
+
switch (r) {
|
|
17
|
+
case "TreeAdjacencyListEntityBase":
|
|
18
|
+
case "TreeEntityBase":
|
|
19
|
+
return [A, w];
|
|
20
|
+
default:
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let g;
|
|
25
|
+
const B = (r, o) => {
|
|
26
|
+
o || (g || (g = new T({
|
|
27
|
+
compilerOptions: {
|
|
28
|
+
target: 99,
|
|
29
|
+
// Latest
|
|
30
|
+
module: 99,
|
|
31
|
+
// ESNext
|
|
32
|
+
moduleResolution: 2,
|
|
33
|
+
// Node
|
|
34
|
+
allowSyntheticDefaultImports: !0,
|
|
35
|
+
esModuleInterop: !0,
|
|
36
|
+
experimentalDecorators: !0,
|
|
37
|
+
emitDecoratorMetadata: !0,
|
|
38
|
+
skipLibCheck: !0
|
|
39
|
+
}
|
|
40
|
+
})), o = g);
|
|
41
|
+
const i = o.addSourceFileAtPath(r).getClasses(), c = /* @__PURE__ */ new Map();
|
|
42
|
+
i.forEach((t) => {
|
|
43
|
+
const n = t.getName();
|
|
44
|
+
if (!n) return;
|
|
45
|
+
const e = { decoratorName: "", extends: "", implements: [] };
|
|
46
|
+
c.set(n, e);
|
|
47
|
+
const a = F(t);
|
|
48
|
+
if (a.length === 1) {
|
|
49
|
+
const { args: u, metadataOptions: h, name: O } = a[0];
|
|
50
|
+
u.length === 1 && (e.metadataOptions = h, e.decoratorName = O);
|
|
51
|
+
}
|
|
52
|
+
const m = t.getBaseClass()?.getName();
|
|
53
|
+
if (m)
|
|
54
|
+
e.extends = m;
|
|
55
|
+
else {
|
|
56
|
+
const u = t.getExtends();
|
|
57
|
+
u && (e.extends = u.getExpression().getText());
|
|
58
|
+
}
|
|
59
|
+
t.getImplements().forEach((u) => {
|
|
60
|
+
const h = u.getText();
|
|
61
|
+
e.implements.push(h);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
const d = (t, n = /* @__PURE__ */ new Set()) => {
|
|
65
|
+
if (n.has(t)) return [];
|
|
66
|
+
n.add(t);
|
|
67
|
+
const e = c.get(t);
|
|
68
|
+
if (!e?.extends)
|
|
69
|
+
return E(t) || x(t) || [];
|
|
70
|
+
const a = c.get(e.extends);
|
|
71
|
+
if (a?.metadataOptions)
|
|
72
|
+
return [...d(e.extends, n), a.metadataOptions];
|
|
73
|
+
const l = E(e.extends) || x(e.extends);
|
|
74
|
+
return l || d(e.extends, n);
|
|
75
|
+
}, p = [];
|
|
76
|
+
for (const [t, n] of c.entries()) {
|
|
77
|
+
const { metadataOptions: e, decoratorName: a } = n;
|
|
78
|
+
if (e) {
|
|
79
|
+
switch (a) {
|
|
80
|
+
case "Entity":
|
|
81
|
+
e.repository || (e.repository = "Repository");
|
|
82
|
+
break;
|
|
83
|
+
case "TreeEntity":
|
|
84
|
+
e.repository = "TreeRepository";
|
|
85
|
+
break;
|
|
86
|
+
case "GraphEntity":
|
|
87
|
+
e.repository = "GraphRepository";
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
p.push({
|
|
91
|
+
decoratorName: a,
|
|
92
|
+
metadataOptions: e,
|
|
93
|
+
implements: n.implements,
|
|
94
|
+
extendMetadataOptions: d(t)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return p;
|
|
99
|
+
}, F = (r) => y.isDecoratable(r) ? r.getDecorators().map((o) => {
|
|
100
|
+
const s = o.getName(), i = o.getExpression(), c = y.isCallExpression(i);
|
|
101
|
+
let d = [], p;
|
|
102
|
+
return c && (d = i.getArguments().map((t) => t.getText()), d.length && (p = k(d[0]))), {
|
|
103
|
+
name: s,
|
|
104
|
+
args: d,
|
|
105
|
+
metadataOptions: p
|
|
106
|
+
};
|
|
107
|
+
}) : [], k = (r) => {
|
|
108
|
+
try {
|
|
109
|
+
return new Function("PropertyType", "RelationKind", "OnDeleteAction", `return ${r}`)(
|
|
110
|
+
D,
|
|
111
|
+
I,
|
|
112
|
+
S
|
|
113
|
+
);
|
|
114
|
+
} catch (o) {
|
|
115
|
+
console.error(o);
|
|
116
|
+
}
|
|
117
|
+
}, $ = async (r) => {
|
|
118
|
+
const o = [];
|
|
119
|
+
for (const s of r)
|
|
120
|
+
try {
|
|
121
|
+
if (s.includes("*") || s.includes("?")) {
|
|
122
|
+
const i = await R(s, {
|
|
123
|
+
absolute: !0,
|
|
124
|
+
// Windows 兼容:在 Windows 上也使用正斜杠
|
|
125
|
+
windowsPathsNoEscape: !0,
|
|
126
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/.git/**"]
|
|
127
|
+
});
|
|
128
|
+
o.push(...i.map((c) => f(c)));
|
|
129
|
+
} else {
|
|
130
|
+
const i = f(P(s));
|
|
131
|
+
o.push(i);
|
|
132
|
+
}
|
|
133
|
+
} catch (i) {
|
|
134
|
+
console.error(`处理路径 ${s} 时出错:`, i);
|
|
135
|
+
}
|
|
136
|
+
return [...new Set(o)];
|
|
137
|
+
};
|
|
138
|
+
function j(r) {
|
|
139
|
+
const o = f(r);
|
|
140
|
+
try {
|
|
141
|
+
b(o, { recursive: !0 });
|
|
142
|
+
} catch (s) {
|
|
143
|
+
throw console.error(`创建目录失败: ${o}`, s), s;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const W = async (r) => {
|
|
147
|
+
const { entities: o, outDir: s, ...i } = r, c = await $(o), d = new T(), p = new N(i);
|
|
148
|
+
for (let t = 0; t < c.length; t++) {
|
|
149
|
+
const n = c[t];
|
|
150
|
+
B(n, d).forEach(({ metadataOptions: a, extendMetadataOptions: l }) => {
|
|
151
|
+
p.addEntity(a, l);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
p.exec(), p.getSourceFiles().forEach((t) => {
|
|
155
|
+
const n = t.getFilePath(), e = f(C(s, n)), a = M(e);
|
|
156
|
+
j(a);
|
|
157
|
+
try {
|
|
158
|
+
_(e, t.getText(), "utf8");
|
|
159
|
+
} catch (l) {
|
|
160
|
+
throw console.error(`写入文件失败: ${e}`, l), l.code === "ENOENT" ? (console.error("可能的原因: 目录不存在或路径包含无效字符"), console.error(` 完整路径: ${e}`), console.error(` 目录路径: ${a}`)) : (l.code === "EACCES" || l.code === "EPERM") && (console.error("可能的原因: 权限不足或文件被占用"), console.error(" 在 Windows 上,请检查:"), console.error(" - 文件是否被其他程序打开"), console.error(" - 是否有足够的文件系统权限"), console.error(" - 防病毒软件是否阻止了文件写入")), l;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
export {
|
|
165
|
+
W as b
|
|
166
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityMetadataOptions } from '
|
|
1
|
+
import { EntityMetadataOptions } from '../../packages/rxdb/src/index.ts';
|
|
2
2
|
import { Project } from 'ts-morph';
|
|
3
3
|
interface AnalyzeFileResult {
|
|
4
4
|
decoratorName: string;
|
|
@@ -11,4 +11,4 @@ interface AnalyzeFileResult {
|
|
|
11
11
|
*/
|
|
12
12
|
declare const _default: (filePath: string, project?: Project) => AnalyzeFileResult[];
|
|
13
13
|
export default _default;
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=analyze-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-file.d.ts","sourceRoot":"","sources":["../../src/cli/analyze-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA8C,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAQ,OAAO,EAAE,MAAM,UAAU,CAAC;AAGzC,UAAU,iBAAiB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,qBAAqB,CAAC;IACvC,qBAAqB,EAAE,qBAAqB,EAAE,CAAC;IAC/C,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAYD;;GAEG;yBACa,UAAU,MAAM,EAAE,UAAU,OAAO,KAAG,iBAAiB,EAAE;AAAzE,wBAqHE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RxDBClientCLIentGeneratorOptions } from './cli.interface.js';
|
|
2
2
|
declare const _default: (options: RxDBClientCLIentGeneratorOptions) => Promise<void>;
|
|
3
3
|
export default _default;
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=build-client-lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-client-lib.d.ts","sourceRoot":"","sources":["../../src/cli/build-client-lib.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;yBAgBhD,SAAS,gCAAgC;AAA/D,wBA0CE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";AA2CA,wBAAsB,IAAI,kBAYzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RxDBClientGeneratorOptions } from '
|
|
1
|
+
import { RxDBClientGeneratorOptions } from '../core/RxDBClientGenerator.js';
|
|
2
2
|
export interface RxDBClientCLIentGeneratorOptions extends RxDBClientGeneratorOptions {
|
|
3
3
|
entities: string[];
|
|
4
4
|
outDir: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.interface.d.ts","sourceRoot":"","sources":["../../src/cli/cli.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E,MAAM,WAAW,gCAAiC,SAAQ,0BAA0B;IAClF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-files.d.ts","sourceRoot":"","sources":["../../src/cli/find-files.ts"],"names":[],"mappings":"AAGA;;;;GAIG;yBACmB,WAAW,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAA7D,wBA2BE"}
|
package/dist/cli.js
CHANGED
|
@@ -1,62 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { resolve as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (o.length === 0)
|
|
20
|
-
throw new Error("配置文件中没有找到有效的配置导出");
|
|
21
|
-
e = r[o[0]];
|
|
22
|
-
}
|
|
23
|
-
return Array.isArray(e) || (e = [e]), e.forEach((o, l) => {
|
|
24
|
-
if (!o.entities || !Array.isArray(o.entities))
|
|
25
|
-
throw new Error(`配置项 ${l}: entities 必须是字符串数组`);
|
|
26
|
-
if (!o.outDir || typeof o.outDir != "string")
|
|
27
|
-
throw new Error(`配置项 ${l}: outDir 必须是字符串`);
|
|
28
|
-
o.entities = o.entities.map((n) => n.startsWith(".") ? c(i, n) : n), o.outDir.startsWith(".") && (o.outDir = c(i, o.outDir));
|
|
29
|
-
}), e;
|
|
30
|
-
} catch (t) {
|
|
31
|
-
throw new Error(`加载配置文件失败: ${t instanceof Error ? t.message : String(t)}`);
|
|
2
|
+
import { existsSync as p } from "node:fs";
|
|
3
|
+
import { resolve as a, dirname as d, normalize as l } from "node:path";
|
|
4
|
+
import { pathToFileURL as m } from "node:url";
|
|
5
|
+
import { b as h } from "./build-client-lib-BGlzuRcG.js";
|
|
6
|
+
async function b(r) {
|
|
7
|
+
if (!p(r))
|
|
8
|
+
throw new Error(`Config file not found: ${r}`);
|
|
9
|
+
const t = a(r), i = d(t), e = await import(m(t).href), n = e.default ?? e.config ?? e.rxdbConfig ?? Object.values(e)[0];
|
|
10
|
+
if (!n)
|
|
11
|
+
throw new Error("No valid config export found");
|
|
12
|
+
const f = Array.isArray(n) ? n : [n];
|
|
13
|
+
for (const o of f) {
|
|
14
|
+
if (!Array.isArray(o.entities))
|
|
15
|
+
throw new Error("entities must be a string array");
|
|
16
|
+
if (typeof o.outDir != "string")
|
|
17
|
+
throw new Error("outDir must be a string");
|
|
18
|
+
o.entities = o.entities.map((u) => l(a(i, u))), o.outDir = l(a(i, o.outDir));
|
|
32
19
|
}
|
|
20
|
+
return f;
|
|
33
21
|
}
|
|
34
|
-
async function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} catch (o) {
|
|
48
|
-
throw console.error(`❌ 配置项 ${r + 1} 执行失败:`, o), o;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
console.log("🎉 所有配置项执行完成!");
|
|
52
|
-
} catch (s) {
|
|
53
|
-
console.error("❌ 程序执行出错:", s), process.exit(1);
|
|
54
|
-
}
|
|
22
|
+
async function w() {
|
|
23
|
+
const r = process.argv.slice(2);
|
|
24
|
+
r.length === 0 && (console.error("Usage: rxdb-client-generator <config-file>"), process.exit(1));
|
|
25
|
+
const t = await b(r[0]);
|
|
26
|
+
await Promise.all(t.map((i) => h(i))), console.log(`✅ Generated ${t.length} client(s) from ${r[0]}`);
|
|
27
|
+
}
|
|
28
|
+
const g = import.meta.url, s = process.argv[1];
|
|
29
|
+
let c = !1;
|
|
30
|
+
try {
|
|
31
|
+
const r = s.startsWith("file://") ? s : m(s).href;
|
|
32
|
+
c = g === r;
|
|
33
|
+
} catch {
|
|
34
|
+
c = g === `file://${s}`;
|
|
55
35
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.error("❌ 程序执行出错:", s), process.exit(1);
|
|
36
|
+
c && w().catch((r) => {
|
|
37
|
+
console.error(r instanceof Error ? r.message : r), process.exit(1);
|
|
59
38
|
});
|
|
60
39
|
export {
|
|
61
|
-
|
|
40
|
+
w as main
|
|
62
41
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { EntityMetadataOptions, EntityType } from '../../packages/rxdb/src/index.ts';
|
|
2
|
+
import { IRepositoryGenerator } from '../generators/RepositoryGenerator.interface.js';
|
|
3
|
+
import { Project } from './ts-morph-browser.js';
|
|
4
|
+
export interface RxDBClientGeneratorOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 关系查询深度
|
|
7
|
+
* 最小为 1
|
|
8
|
+
* @default 3
|
|
9
|
+
* @example 1 允许查询自己的基本属性 + 自己的关系的基本属性
|
|
10
|
+
* @example 2 允许查询自己的基本属性 + 自己的关系的基本属性 + 自己关系的关系的基本属性
|
|
11
|
+
*/
|
|
12
|
+
relationQueryDeep?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* RxDB Client 生成器
|
|
16
|
+
*/
|
|
17
|
+
export declare class RxDBClientGenerator {
|
|
18
|
+
/**
|
|
19
|
+
* Repository 生成器注册表
|
|
20
|
+
* 用于支持可扩展的 Repository 类型
|
|
21
|
+
*/
|
|
22
|
+
private repositoryGenerators;
|
|
23
|
+
entityMetadataOptionsMap: Map<string, EntityMetadataOptions[]>;
|
|
24
|
+
metadataOptionsSet: Set<EntityMetadataOptions>;
|
|
25
|
+
metadataSet: Set<Readonly<import('node_modules/@aiao/rxdb/src/entity/metadata.interface.js').EntityMetadataType>>;
|
|
26
|
+
metadataMap: Map<string, Readonly<import('node_modules/@aiao/rxdb/src/entity/metadata.interface.js').EntityMetadataType>>;
|
|
27
|
+
project: Project;
|
|
28
|
+
config: Required<RxDBClientGeneratorOptions>;
|
|
29
|
+
constructor(options?: RxDBClientGeneratorOptions);
|
|
30
|
+
/**
|
|
31
|
+
* 添加实体配置
|
|
32
|
+
* @param value 实体
|
|
33
|
+
*/
|
|
34
|
+
addEntity(value: EntityMetadataOptions | EntityType, options?: EntityMetadataOptions[]): void;
|
|
35
|
+
getMetadata(mappedEntity: string, mappedNamespace: string): Readonly<import('node_modules/@aiao/rxdb/src/entity/metadata.interface.js').EntityMetadataType> | undefined;
|
|
36
|
+
registerAbstractMetadata(abstractEntityName: string, metadataOptions: EntityMetadataOptions[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* 注册 Repository 生成器
|
|
39
|
+
* 用于扩展支持自定义 Repository 类型
|
|
40
|
+
*
|
|
41
|
+
* @param generator Repository 生成器实例
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const generator = new RxDBClientGenerator();
|
|
45
|
+
* generator.registerRepositoryGenerator(new GeoRepositoryGenerator());
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
registerRepositoryGenerator(generator: IRepositoryGenerator): void;
|
|
49
|
+
/**
|
|
50
|
+
* 获取 Repository 生成器
|
|
51
|
+
* @param name Repository 名称
|
|
52
|
+
* @returns 对应的生成器,如果不存在则返回 undefined
|
|
53
|
+
*/
|
|
54
|
+
getRepositoryGenerator(name: string): IRepositoryGenerator | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* 执行生成器
|
|
57
|
+
*/
|
|
58
|
+
exec(): void;
|
|
59
|
+
getSourceFiles(): import('./ts-morph-browser.js').SourceFile[];
|
|
60
|
+
/**
|
|
61
|
+
* 生成实体的 js 文件
|
|
62
|
+
* 公开此方法以便测试使用
|
|
63
|
+
*/
|
|
64
|
+
generateEntityJsFile(): void;
|
|
65
|
+
/**
|
|
66
|
+
* 生成所有 entity 的定义到 index.d.ts 文件里
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
private generateAllEntityDefinition;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=RxDBClientGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RxDBClientGenerator.d.ts","sourceRoot":"","sources":["../../src/core/RxDBClientGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EAErB,UAAU,EAKX,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAI3F,OAAO,EAAE,OAAO,EAA2B,MAAM,uBAAuB,CAAC;AAEzE,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAKD;;GAEG;AACH,qBAAa,mBAAmB;IAC9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAA2C;IAEvE,wBAAwB,uCAGrB;IACH,kBAAkB,6BAAoC;IACtD,WAAW,uGAA6B;IACxC,WAAW,+GAAqC;IAChD,OAAO,EAAG,OAAO,CAAC;IAElB,MAAM,EAAE,QAAQ,CAAC,0BAA0B,CAAC,CAE1C;gBAEU,OAAO,CAAC,EAAE,0BAA0B;IAShD;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,qBAAqB,GAAG,UAAU,EAAE,OAAO,CAAC,EAAE,qBAAqB,EAAE;IAetF,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAIzD,wBAAwB,CAAC,kBAAkB,EAAE,MAAM,EAAE,eAAe,EAAE,qBAAqB,EAAE;IAQ7F;;;;;;;;;;OAUG;IACH,2BAA2B,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAIlE;;;;OAIG;IACH,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAItE;;OAEG;IACH,IAAI;IAMJ,cAAc;IAId;;;OAGG;IACH,oBAAoB;IAgEpB;;;OAGG;IACH,OAAO,CAAC,2BAA2B;CAoEpC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EntityMetadata, EntityPropertyMetadata } from '../../packages/rxdb/src/index.ts';
|
|
2
|
+
import { PropertyDeclarationStructure } from './ts-morph-browser.js';
|
|
3
|
+
/**
|
|
4
|
+
* 获取属性配置
|
|
5
|
+
*/
|
|
6
|
+
export declare const getPropertyTypeConfig: (property: EntityPropertyMetadata, metadata: EntityMetadata) => Partial<PropertyDeclarationStructure> & {
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getFlatMapInterfaceName: (property: EntityPropertyMetadata, metadata: EntityMetadata) => string;
|
|
11
|
+
/**
|
|
12
|
+
* 生成 keyValue 的精确类型(返回接口名称)
|
|
13
|
+
* 根据 properties 定义生成准确的接口名称
|
|
14
|
+
*/
|
|
15
|
+
export declare const getKeyValuePreciseType: (property: EntityPropertyMetadata, metadata: EntityMetadata) => string;
|
|
16
|
+
/**
|
|
17
|
+
* 获取 keyValue 的属性结构(用于生成接口)
|
|
18
|
+
* 返回属性数组,包含属性名、类型和可选性
|
|
19
|
+
*/
|
|
20
|
+
export declare const getKeyValueInterfaceProperties: (property: EntityPropertyMetadata, metadata: EntityMetadata) => {
|
|
21
|
+
name: Uncapitalize<string>;
|
|
22
|
+
type: string;
|
|
23
|
+
hasQuestionToken: boolean;
|
|
24
|
+
docs: string[] | undefined;
|
|
25
|
+
}[];
|
|
26
|
+
export declare const getEntityPropertyTsType: (property: EntityPropertyMetadata, metadata: EntityMetadata) => string;
|
|
27
|
+
export declare const getGeneratorEntityConfig: (metadata: EntityMetadata) => {
|
|
28
|
+
entityPath: string;
|
|
29
|
+
fileName: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const getGeneratorEntityDefinitionConfig: (metadata: EntityMetadata) => {
|
|
32
|
+
entityPath: string;
|
|
33
|
+
fileName: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function transitionMetadata(metadata: EntityMetadata): string;
|
|
36
|
+
//# sourceMappingURL=RxDBClientGenerator.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RxDBClientGenerator.utils.d.ts","sourceRoot":"","sources":["../../src/core/RxDBClientGenerator.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAA8B,MAAM,YAAY,CAAC;AAEhG,OAAO,KAAK,EAAgB,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAExF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,sBAAsB,EAAE,UAAU,cAAc;UAUtF,MAAM;UACN,MAAM;CAaf,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,UAAU,sBAAsB,EAAE,UAAU,cAAc,WACL,CAAC;AAC9F;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,sBAAsB,EAAE,UAAU,cAAc,KAAG,MAUnG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GAAI,UAAU,sBAAsB,EAAE,UAAU,cAAc;;;;;GAgBxG,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,UAAU,sBAAsB,EAAE,UAAU,cAAc,WAsCjG,CAAC;AAiBF,eAAO,MAAM,wBAAwB,GAAI,UAAU,cAAc;;;CAShE,CAAC;AAkBF,eAAO,MAAM,kCAAkC,GAAI,UAAU,cAAc;;;CAS1E,CAAC;AAcF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAyBnE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EntityMetadataOptions } from '../../packages/rxdb/src/index.ts';
|
|
2
|
+
export declare function getEntityMetadataOptions(className: string): EntityMetadataOptions[] | undefined;
|
|
3
|
+
export declare function getTreeEntityMetadataOptions(className: string): EntityMetadataOptions[] | undefined;
|
|
4
|
+
//# sourceMappingURL=metadata.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.utils.d.ts","sourceRoot":"","sources":["../../src/core/metadata.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,EAAE,GAAG,SAAS,CAO/F;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,EAAE,GAAG,SAAS,CAQnG"}
|