@aiao/rxdb-client-generator 0.0.9 → 0.0.11
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/{RxDBClientGenerator-6qmS8Mrd.js → RxDBClientGenerator-CnVT5HUD.js} +196 -195
- package/dist/build-client-lib-D18fixnL.js +165 -0
- package/dist/cli/analyze-file.d.ts +5 -0
- package/dist/cli/analyze-file.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/core/RxDBClientGenerator.d.ts +4 -0
- package/dist/core/RxDBClientGenerator.d.ts.map +1 -1
- package/dist/core/RxDBClientGenerator.utils.d.ts.map +1 -1
- package/dist/generators/RepositoryGeneratorBase.d.ts +2 -1
- package/dist/generators/RepositoryGeneratorBase.d.ts.map +1 -1
- package/dist/generators/entity-definition.d.ts.map +1 -1
- package/dist/generators/entity-properties.d.ts.map +1 -1
- package/dist/generators/entity-rules.d.ts.map +1 -1
- package/dist/generators/utils.d.ts +2 -1
- package/dist/generators/utils.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/vite.js +1 -1
- package/package.json +4 -4
- package/dist/build-client-lib-Bkh60Zeb.js +0 -162
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { writeFileSync as _, mkdirSync as R } from "node:fs";
|
|
2
|
+
import { normalize as f, resolve as w, join as S, dirname as I } from "node:path";
|
|
3
|
+
import { Project as T, Node as h } from "ts-morph";
|
|
4
|
+
import { R as b, b as M, a as N, d as A } from "./RxDBClientGenerator-CnVT5HUD.js";
|
|
5
|
+
import { ENTITY_BASE_METADATA_OPTIONS as x, TREE_ADJACENCY_LIST_ENTITY_BASE_OPTIONS as C, PropertyType as D, RelationKind as Y, OnDeleteAction as F } from "@aiao/rxdb";
|
|
6
|
+
import { glob as B } from "glob";
|
|
7
|
+
function y(n) {
|
|
8
|
+
if (n === "EntityBase")
|
|
9
|
+
return [x];
|
|
10
|
+
}
|
|
11
|
+
function O(n) {
|
|
12
|
+
switch (n) {
|
|
13
|
+
case "TreeAdjacencyListEntityBase":
|
|
14
|
+
case "TreeEntityBase":
|
|
15
|
+
return [C, x];
|
|
16
|
+
default:
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let g;
|
|
21
|
+
const $ = (n, r) => {
|
|
22
|
+
r || (g || (g = new T({
|
|
23
|
+
compilerOptions: {
|
|
24
|
+
target: 99,
|
|
25
|
+
// Latest
|
|
26
|
+
module: 99,
|
|
27
|
+
// ESNext
|
|
28
|
+
moduleResolution: 2,
|
|
29
|
+
// Node
|
|
30
|
+
allowSyntheticDefaultImports: !0,
|
|
31
|
+
esModuleInterop: !0,
|
|
32
|
+
experimentalDecorators: !0,
|
|
33
|
+
emitDecoratorMetadata: !0,
|
|
34
|
+
skipLibCheck: !0
|
|
35
|
+
}
|
|
36
|
+
})), r = g);
|
|
37
|
+
const s = r.addSourceFileAtPath(n).getClasses(), c = /* @__PURE__ */ new Map();
|
|
38
|
+
s.forEach((t) => {
|
|
39
|
+
const a = t.getName();
|
|
40
|
+
if (!a) return;
|
|
41
|
+
const e = { decoratorName: "", extends: "", implements: [] };
|
|
42
|
+
c.set(a, e);
|
|
43
|
+
const i = k(t);
|
|
44
|
+
if (i.length === 1) {
|
|
45
|
+
const { args: m, metadataOptions: E, name: P } = i[0];
|
|
46
|
+
m.length === 1 && (e.metadataOptions = E, e.decoratorName = P);
|
|
47
|
+
}
|
|
48
|
+
const u = t.getBaseClass()?.getName();
|
|
49
|
+
if (u)
|
|
50
|
+
e.extends = u;
|
|
51
|
+
else {
|
|
52
|
+
const m = t.getExtends();
|
|
53
|
+
m && (e.extends = m.getExpression().getText());
|
|
54
|
+
}
|
|
55
|
+
t.getImplements().forEach((m) => {
|
|
56
|
+
const E = m.getText();
|
|
57
|
+
e.implements.push(E);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
const d = (t, a = /* @__PURE__ */ new Set()) => {
|
|
61
|
+
if (a.has(t)) return [];
|
|
62
|
+
a.add(t);
|
|
63
|
+
const e = c.get(t);
|
|
64
|
+
if (!e?.extends)
|
|
65
|
+
return y(t) || O(t) || [];
|
|
66
|
+
const i = c.get(e.extends);
|
|
67
|
+
if (i?.metadataOptions)
|
|
68
|
+
return [...d(e.extends, a), i.metadataOptions];
|
|
69
|
+
const l = y(e.extends) || O(e.extends);
|
|
70
|
+
return l || d(e.extends, a);
|
|
71
|
+
}, p = [];
|
|
72
|
+
for (const [t, a] of c.entries()) {
|
|
73
|
+
const { metadataOptions: e, decoratorName: i } = a;
|
|
74
|
+
if (e) {
|
|
75
|
+
switch (i) {
|
|
76
|
+
case "Entity":
|
|
77
|
+
e.repository || (e.repository = N);
|
|
78
|
+
break;
|
|
79
|
+
case "TreeEntity":
|
|
80
|
+
e.repository = M;
|
|
81
|
+
break;
|
|
82
|
+
case "GraphEntity":
|
|
83
|
+
e.repository = b;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
p.push({
|
|
87
|
+
decoratorName: i,
|
|
88
|
+
metadataOptions: e,
|
|
89
|
+
implements: a.implements,
|
|
90
|
+
extendMetadataOptions: d(t)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return p;
|
|
95
|
+
}, k = (n) => h.isDecoratable(n) ? n.getDecorators().map((r) => {
|
|
96
|
+
const o = r.getName(), s = r.getExpression(), c = h.isCallExpression(s);
|
|
97
|
+
let d = [], p;
|
|
98
|
+
return c && (d = s.getArguments().map((t) => t.getText()), d.length && (p = v(d[0]))), {
|
|
99
|
+
name: o,
|
|
100
|
+
args: d,
|
|
101
|
+
metadataOptions: p
|
|
102
|
+
};
|
|
103
|
+
}) : [], v = (n, r) => {
|
|
104
|
+
try {
|
|
105
|
+
const o = new Function("PropertyType", "RelationKind", "OnDeleteAction", `return ${n}`)(
|
|
106
|
+
D,
|
|
107
|
+
Y,
|
|
108
|
+
F
|
|
109
|
+
);
|
|
110
|
+
return o === void 0 && console.warn("Metadata options resolved to undefined", r ? `in ${r}` : ""), o;
|
|
111
|
+
} catch (o) {
|
|
112
|
+
const s = o instanceof Error ? o.message : String(o);
|
|
113
|
+
console.error("Failed to parse metadata options:", s);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}, j = async (n) => {
|
|
117
|
+
const r = [];
|
|
118
|
+
for (const o of n)
|
|
119
|
+
try {
|
|
120
|
+
if (o.includes("*") || o.includes("?")) {
|
|
121
|
+
const s = await B(o, {
|
|
122
|
+
absolute: !0,
|
|
123
|
+
// Windows 兼容:在 Windows 上也使用正斜杠
|
|
124
|
+
windowsPathsNoEscape: !0,
|
|
125
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/.git/**"]
|
|
126
|
+
});
|
|
127
|
+
r.push(...s.map((c) => f(c)));
|
|
128
|
+
} else {
|
|
129
|
+
const s = f(w(o));
|
|
130
|
+
r.push(s);
|
|
131
|
+
}
|
|
132
|
+
} catch (s) {
|
|
133
|
+
console.error(`处理路径 ${o} 时出错:`, s);
|
|
134
|
+
}
|
|
135
|
+
return [...new Set(r)];
|
|
136
|
+
};
|
|
137
|
+
function z(n) {
|
|
138
|
+
const r = f(n);
|
|
139
|
+
try {
|
|
140
|
+
R(r, { recursive: !0 });
|
|
141
|
+
} catch (o) {
|
|
142
|
+
throw console.error(`创建目录失败: ${r}`, o), o;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const Q = async (n) => {
|
|
146
|
+
const { entities: r, outDir: o, ...s } = n, c = await j(r), d = new T(), p = new A(s);
|
|
147
|
+
for (let t = 0; t < c.length; t++) {
|
|
148
|
+
const a = c[t];
|
|
149
|
+
$(a, d).forEach(({ metadataOptions: i, extendMetadataOptions: l }) => {
|
|
150
|
+
p.addEntity(i, l);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
p.exec(), p.getSourceFiles().forEach((t) => {
|
|
154
|
+
const a = t.getFilePath(), e = f(S(o, a)), i = I(e);
|
|
155
|
+
z(i);
|
|
156
|
+
try {
|
|
157
|
+
_(e, t.getText(), "utf8");
|
|
158
|
+
} catch (l) {
|
|
159
|
+
throw console.error(`写入文件失败: ${e}`, l), l.code === "ENOENT" ? (console.error("可能的原因: 目录不存在或路径包含无效字符"), console.error(` 完整路径: ${e}`), console.error(` 目录路径: ${i}`)) : (l.code === "EACCES" || l.code === "EPERM") && (console.error("可能的原因: 权限不足或文件被占用"), console.error(" 在 Windows 上,请检查:"), console.error(" - 文件是否被其他程序打开"), console.error(" - 是否有足够的文件系统权限"), console.error(" - 防病毒软件是否阻止了文件写入")), l;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
export {
|
|
164
|
+
Q as b
|
|
165
|
+
};
|
|
@@ -1 +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;
|
|
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;AAQzC,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;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,IAErC,CAAC;AAEF;;GAEG;yBACa,UAAU,MAAM,EAAE,UAAU,OAAO,KAAG,iBAAiB,EAAE;AAAzE,wBAqHE"}
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { existsSync as p } from "node:fs";
|
|
3
3
|
import { resolve as a, dirname as d, normalize as l } from "node:path";
|
|
4
4
|
import { pathToFileURL as m } from "node:url";
|
|
5
|
-
import { b as h } from "./build-client-lib-
|
|
5
|
+
import { b as h } from "./build-client-lib-D18fixnL.js";
|
|
6
6
|
async function b(r) {
|
|
7
7
|
if (!p(r))
|
|
8
8
|
throw new Error(`Config file not found: ${r}`);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { EntityMetadataOptions, EntityType } from '../../packages/rxdb/src/index.ts';
|
|
2
2
|
import { IRepositoryGenerator } from '../generators/RepositoryGenerator.interface.js';
|
|
3
3
|
import { Project } from './ts-morph-browser.js';
|
|
4
|
+
export declare const NAMESPACE_PUBLIC: "public";
|
|
5
|
+
export declare const REPOSITORY_TYPE_REPOSITORY: "Repository";
|
|
6
|
+
export declare const REPOSITORY_TYPE_TREE_REPOSITORY: "TreeRepository";
|
|
7
|
+
export declare const REPOSITORY_TYPE_GRAPH_REPOSITORY: "GraphRepository";
|
|
4
8
|
export interface RxDBClientGeneratorOptions {
|
|
5
9
|
/**
|
|
6
10
|
* 关系查询深度
|
|
@@ -1 +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;
|
|
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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AsB,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;AAsBF,eAAO,MAAM,kCAAkC,GAAI,UAAU,cAAc;;;CAS1E,CAAC;AAkBF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CA6BnE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RuleTypeData } from './entity-rules.js';
|
|
2
2
|
import { GeneratorContext, IRepositoryGenerator } from './RepositoryGenerator.interface.js';
|
|
3
|
+
import { IdType } from './utils.js';
|
|
3
4
|
export declare const buildRules: (entityRules: RuleTypeData[], rxdbNamedImports: Set<string>) => string[];
|
|
4
5
|
/**
|
|
5
6
|
* 基础 Repository 生成器(抽象基类)
|
|
@@ -51,7 +52,7 @@ export declare abstract class RepositoryGeneratorBase implements IRepositoryGene
|
|
|
51
52
|
/**
|
|
52
53
|
* 共享工具:获取 ID 类型
|
|
53
54
|
*/
|
|
54
|
-
protected getIdType(metadata: GeneratorContext['metadata']):
|
|
55
|
+
protected getIdType(metadata: GeneratorContext['metadata']): IdType;
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Repository 生成器
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepositoryGeneratorBase.d.ts","sourceRoot":"","sources":["../../src/generators/RepositoryGeneratorBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AACjG,eAAO,MAAM,UAAU,GAAI,aAAa,YAAY,EAAE,EAAE,kBAAkB,GAAG,CAAC,MAAM,CAAC,aA0BpF,CAAC;AAEF;;;GAGG;AACH,8BAAsB,uB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":["../../src/generators/entity-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-definition.d.ts","sourceRoot":"","sources":["../../src/generators/entity-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAA8B,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACjG,OAAO,KAAK,EAIV,UAAU,EACX,MAAM,6BAA6B,CAAC;AAIrC;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,mBAAmB,EAC9B,UAAU,cAAc,EACxB,MAAM,UAAU;;CA0IjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-properties.d.ts","sourceRoot":"","sources":["../../src/generators/entity-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"entity-properties.d.ts","sourceRoot":"","sources":["../../src/generators/entity-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwC,MAAM,YAAY,CAAC;AAMlF,OAAO,KAAK,EAAE,YAAY,EAAE,4BAA4B,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE1G;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,uDAKtC;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,eAAe,EAAE,YAAY,CAAC,4BAA4B,CAAC,EAAE,CAAC;IAC9D,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC/B,SA8EA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-rules.d.ts","sourceRoot":"","sources":["../../src/generators/entity-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAKf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,SAAS;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"entity-rules.d.ts","sourceRoot":"","sources":["../../src/generators/entity-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAKf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,SAAS;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAkOD,eAAO,MAAM,mBAAmB,GAC9B,WAAW,mBAAmB,EAC9B,UAAU,cAAc,EACxB,gBAAgB,cAAc,EAC9B,aAAY,MAAM,EAAO,EACzB,SAAQ,YAAY,EAAO,EAC3B,QAAO,SAAS,EAAO,KACtB,YAAY,EAad,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { EntityMetadata } from '../../packages/rxdb/src/index.ts';
|
|
2
|
-
export
|
|
2
|
+
export type IdType = 'UUID' | 'string' | 'number';
|
|
3
|
+
export declare const getIdType: (metadata: EntityMetadata) => IdType;
|
|
3
4
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generators/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,SAAS,GAAI,UAAU,cAAc,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generators/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,eAAO,MAAM,SAAS,GAAI,UAAU,cAAc,KAAG,MAcpD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { R as
|
|
1
|
+
import { N as O, R as P, a, b as T, c as Y, d as _ } from "./RxDBClientGenerator-CnVT5HUD.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
O as NAMESPACE_PUBLIC,
|
|
4
|
+
P as REPOSITORY_TYPE_GRAPH_REPOSITORY,
|
|
5
|
+
a as REPOSITORY_TYPE_REPOSITORY,
|
|
6
|
+
T as REPOSITORY_TYPE_TREE_REPOSITORY,
|
|
7
|
+
Y as RepositoryGeneratorBase,
|
|
8
|
+
_ as RxDBClientGenerator
|
|
5
9
|
};
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiao/rxdb-client-generator",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"glob": "^13.0.1",
|
|
41
42
|
"ts-morph": "^27.0.2",
|
|
42
|
-
"
|
|
43
|
-
"@aiao/
|
|
44
|
-
"@aiao/utils": "0.0.9"
|
|
43
|
+
"@aiao/rxdb": "0.0.11",
|
|
44
|
+
"@aiao/utils": "0.0.11"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,162 +0,0 @@
|
|
|
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-6qmS8Mrd.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
|
-
if (r === "EntityBase")
|
|
9
|
-
return [w];
|
|
10
|
-
}
|
|
11
|
-
function x(r) {
|
|
12
|
-
switch (r) {
|
|
13
|
-
case "TreeAdjacencyListEntityBase":
|
|
14
|
-
case "TreeEntityBase":
|
|
15
|
-
return [A, w];
|
|
16
|
-
default:
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
let g;
|
|
21
|
-
const B = (r, o) => {
|
|
22
|
-
o || (g || (g = new T({
|
|
23
|
-
compilerOptions: {
|
|
24
|
-
target: 99,
|
|
25
|
-
// Latest
|
|
26
|
-
module: 99,
|
|
27
|
-
// ESNext
|
|
28
|
-
moduleResolution: 2,
|
|
29
|
-
// Node
|
|
30
|
-
allowSyntheticDefaultImports: !0,
|
|
31
|
-
esModuleInterop: !0,
|
|
32
|
-
experimentalDecorators: !0,
|
|
33
|
-
emitDecoratorMetadata: !0,
|
|
34
|
-
skipLibCheck: !0
|
|
35
|
-
}
|
|
36
|
-
})), o = g);
|
|
37
|
-
const i = o.addSourceFileAtPath(r).getClasses(), c = /* @__PURE__ */ new Map();
|
|
38
|
-
i.forEach((t) => {
|
|
39
|
-
const n = t.getName();
|
|
40
|
-
if (!n) return;
|
|
41
|
-
const e = { decoratorName: "", extends: "", implements: [] };
|
|
42
|
-
c.set(n, e);
|
|
43
|
-
const a = F(t);
|
|
44
|
-
if (a.length === 1) {
|
|
45
|
-
const { args: u, metadataOptions: h, name: O } = a[0];
|
|
46
|
-
u.length === 1 && (e.metadataOptions = h, e.decoratorName = O);
|
|
47
|
-
}
|
|
48
|
-
const m = t.getBaseClass()?.getName();
|
|
49
|
-
if (m)
|
|
50
|
-
e.extends = m;
|
|
51
|
-
else {
|
|
52
|
-
const u = t.getExtends();
|
|
53
|
-
u && (e.extends = u.getExpression().getText());
|
|
54
|
-
}
|
|
55
|
-
t.getImplements().forEach((u) => {
|
|
56
|
-
const h = u.getText();
|
|
57
|
-
e.implements.push(h);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
const d = (t, n = /* @__PURE__ */ new Set()) => {
|
|
61
|
-
if (n.has(t)) return [];
|
|
62
|
-
n.add(t);
|
|
63
|
-
const e = c.get(t);
|
|
64
|
-
if (!e?.extends)
|
|
65
|
-
return E(t) || x(t) || [];
|
|
66
|
-
const a = c.get(e.extends);
|
|
67
|
-
if (a?.metadataOptions)
|
|
68
|
-
return [...d(e.extends, n), a.metadataOptions];
|
|
69
|
-
const l = E(e.extends) || x(e.extends);
|
|
70
|
-
return l || d(e.extends, n);
|
|
71
|
-
}, p = [];
|
|
72
|
-
for (const [t, n] of c.entries()) {
|
|
73
|
-
const { metadataOptions: e, decoratorName: a } = n;
|
|
74
|
-
if (e) {
|
|
75
|
-
switch (a) {
|
|
76
|
-
case "Entity":
|
|
77
|
-
e.repository || (e.repository = "Repository");
|
|
78
|
-
break;
|
|
79
|
-
case "TreeEntity":
|
|
80
|
-
e.repository = "TreeRepository";
|
|
81
|
-
break;
|
|
82
|
-
case "GraphEntity":
|
|
83
|
-
e.repository = "GraphRepository";
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
p.push({
|
|
87
|
-
decoratorName: a,
|
|
88
|
-
metadataOptions: e,
|
|
89
|
-
implements: n.implements,
|
|
90
|
-
extendMetadataOptions: d(t)
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return p;
|
|
95
|
-
}, F = (r) => y.isDecoratable(r) ? r.getDecorators().map((o) => {
|
|
96
|
-
const s = o.getName(), i = o.getExpression(), c = y.isCallExpression(i);
|
|
97
|
-
let d = [], p;
|
|
98
|
-
return c && (d = i.getArguments().map((t) => t.getText()), d.length && (p = k(d[0]))), {
|
|
99
|
-
name: s,
|
|
100
|
-
args: d,
|
|
101
|
-
metadataOptions: p
|
|
102
|
-
};
|
|
103
|
-
}) : [], k = (r) => {
|
|
104
|
-
try {
|
|
105
|
-
return new Function("PropertyType", "RelationKind", "OnDeleteAction", `return ${r}`)(
|
|
106
|
-
D,
|
|
107
|
-
I,
|
|
108
|
-
S
|
|
109
|
-
);
|
|
110
|
-
} catch (o) {
|
|
111
|
-
console.error(o);
|
|
112
|
-
}
|
|
113
|
-
}, $ = async (r) => {
|
|
114
|
-
const o = [];
|
|
115
|
-
for (const s of r)
|
|
116
|
-
try {
|
|
117
|
-
if (s.includes("*") || s.includes("?")) {
|
|
118
|
-
const i = await R(s, {
|
|
119
|
-
absolute: !0,
|
|
120
|
-
// Windows 兼容:在 Windows 上也使用正斜杠
|
|
121
|
-
windowsPathsNoEscape: !0,
|
|
122
|
-
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/.git/**"]
|
|
123
|
-
});
|
|
124
|
-
o.push(...i.map((c) => f(c)));
|
|
125
|
-
} else {
|
|
126
|
-
const i = f(P(s));
|
|
127
|
-
o.push(i);
|
|
128
|
-
}
|
|
129
|
-
} catch (i) {
|
|
130
|
-
console.error(`处理路径 ${s} 时出错:`, i);
|
|
131
|
-
}
|
|
132
|
-
return [...new Set(o)];
|
|
133
|
-
};
|
|
134
|
-
function j(r) {
|
|
135
|
-
const o = f(r);
|
|
136
|
-
try {
|
|
137
|
-
b(o, { recursive: !0 });
|
|
138
|
-
} catch (s) {
|
|
139
|
-
throw console.error(`创建目录失败: ${o}`, s), s;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const W = async (r) => {
|
|
143
|
-
const { entities: o, outDir: s, ...i } = r, c = await $(o), d = new T(), p = new N(i);
|
|
144
|
-
for (let t = 0; t < c.length; t++) {
|
|
145
|
-
const n = c[t];
|
|
146
|
-
B(n, d).forEach(({ metadataOptions: a, extendMetadataOptions: l }) => {
|
|
147
|
-
p.addEntity(a, l);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
p.exec(), p.getSourceFiles().forEach((t) => {
|
|
151
|
-
const n = t.getFilePath(), e = f(C(s, n)), a = M(e);
|
|
152
|
-
j(a);
|
|
153
|
-
try {
|
|
154
|
-
_(e, t.getText(), "utf8");
|
|
155
|
-
} catch (l) {
|
|
156
|
-
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;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
export {
|
|
161
|
-
W as b
|
|
162
|
-
};
|