moonflower 1.4.8 → 1.5.0
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/openapi/analyzerModule/analyzerModule.cjs +1 -1
- package/dist/openapi/analyzerModule/analyzerModule.cjs.map +1 -1
- package/dist/openapi/analyzerModule/analyzerModule.d.ts +18 -3
- package/dist/openapi/analyzerModule/analyzerModule.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/analyzerModule.mjs +168 -112
- package/dist/openapi/analyzerModule/analyzerModule.mjs.map +1 -1
- package/dist/openapi/analyzerModule/analyzerWorker.cjs +2 -0
- package/dist/openapi/analyzerModule/analyzerWorker.cjs.map +1 -0
- package/dist/openapi/analyzerModule/analyzerWorker.d.ts +2 -0
- package/dist/openapi/analyzerModule/analyzerWorker.d.ts.map +1 -0
- package/dist/openapi/analyzerModule/analyzerWorker.mjs +44 -0
- package/dist/openapi/analyzerModule/analyzerWorker.mjs.map +1 -0
- package/dist/openapi/analyzerModule/nodeParsers.cjs +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.cjs.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.mjs +199 -264
- package/dist/openapi/analyzerModule/nodeParsers.mjs.map +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.cjs +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.cjs.map +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.d.ts +8 -1
- package/dist/openapi/analyzerModule/parseEndpoint.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.mjs +121 -106
- package/dist/openapi/analyzerModule/parseEndpoint.mjs.map +1 -1
- package/dist/openapi/analyzerModule/test/TestCase.d.ts +1 -0
- package/dist/openapi/analyzerModule/test/TestCase.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/test/workerGlobalSetup.d.ts +3 -0
- package/dist/openapi/analyzerModule/test/workerGlobalSetup.d.ts.map +1 -0
- package/dist/openapi/analyzerModule/workerPaths.d.ts +2 -0
- package/dist/openapi/analyzerModule/workerPaths.d.ts.map +1 -0
- package/dist/openapi/analyzerModule/workerPool.cjs +2 -0
- package/dist/openapi/analyzerModule/workerPool.cjs.map +1 -0
- package/dist/openapi/analyzerModule/workerPool.d.ts +33 -0
- package/dist/openapi/analyzerModule/workerPool.d.ts.map +1 -0
- package/dist/openapi/analyzerModule/workerPool.mjs +46 -0
- package/dist/openapi/analyzerModule/workerPool.mjs.map +1 -0
- package/package.json +1 -1
- package/src/openapi/analyzerModule/analyzerModule.ts +198 -25
- package/src/openapi/analyzerModule/analyzerWorker.ts +73 -0
- package/src/openapi/analyzerModule/nodeParsers.ts +4 -104
- package/src/openapi/analyzerModule/parseEndpoint.ts +31 -9
- package/src/openapi/analyzerModule/test/TestCase.ts +1 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +2 -2
- package/src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.data.ts +6 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.ts +9 -1
- package/src/openapi/analyzerModule/test/workerGlobalSetup.ts +25 -0
- package/src/openapi/analyzerModule/workerPaths.ts +4 -0
- package/src/openapi/analyzerModule/workerPool.ts +92 -0
- package/src/test/app.spec.ts +10 -1
- package/vite.config.ts +5 -0
|
@@ -1,212 +1,147 @@
|
|
|
1
1
|
import { SyntaxKind as t } from "ts-morph";
|
|
2
2
|
import { Logger as m } from "../../utils/logger.mjs";
|
|
3
3
|
import { OpenApiManager as V } from "../manager/OpenApiManager.mjs";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
4
|
+
const S = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), f = (e) => {
|
|
5
|
+
const i = S.get(e);
|
|
6
|
+
if (i)
|
|
7
|
+
return i;
|
|
8
8
|
if (e.getKind() === t.Identifier) {
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
9
|
+
const n = e.asKind(t.Identifier).getImplementations()[0]?.getNode();
|
|
10
|
+
if (n) {
|
|
11
|
+
const l = n.getParent().getLastChild();
|
|
12
|
+
if (l === e)
|
|
13
13
|
throw new Error("Recursive implementation found");
|
|
14
|
-
const p = f(
|
|
15
|
-
return
|
|
14
|
+
const p = f(l);
|
|
15
|
+
return S.set(e, p), p;
|
|
16
16
|
}
|
|
17
17
|
const s = e.asKind(t.Identifier).getDefinitions()[0]?.getNode();
|
|
18
18
|
if (s) {
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
19
|
+
const l = s.getParent().getLastChild();
|
|
20
|
+
if (l === e)
|
|
21
21
|
throw new Error("Recursive implementation found");
|
|
22
|
-
const p = f(
|
|
23
|
-
return
|
|
22
|
+
const p = f(l);
|
|
23
|
+
return S.set(e, p), p;
|
|
24
24
|
}
|
|
25
25
|
throw new Error("No implementation nor definition available");
|
|
26
26
|
}
|
|
27
|
-
return
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
return
|
|
27
|
+
return S.set(e, e), e;
|
|
28
|
+
}, T = (e) => {
|
|
29
|
+
const i = e.getChildrenOfKind(t.Identifier);
|
|
30
|
+
return i.length === 2 ? f(i[1]) : e.getChildren().reverse().find(
|
|
31
31
|
(s) => s.getKind() !== t.GreaterThanToken && s.getKind() !== t.CommaToken && s.getKind() !== t.SemicolonToken
|
|
32
32
|
);
|
|
33
|
-
},
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
}, w = (e) => {
|
|
34
|
+
const i = e.getFirstChildByKind(t.SyntaxList);
|
|
35
|
+
return i.isKind(t.SyntaxList) ? y(i.getFirstChild()) : y(i);
|
|
36
36
|
}, y = (e) => {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
40
|
-
const
|
|
41
|
-
return
|
|
37
|
+
const i = v.get(e);
|
|
38
|
+
if (i !== void 0)
|
|
39
|
+
return i;
|
|
40
|
+
const n = $(e);
|
|
41
|
+
return v.set(e, n), n;
|
|
42
42
|
}, $ = (e) => {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
43
|
+
const i = e.getSymbol()?.getName();
|
|
44
|
+
if (i && V.getInstance().hasExposedModel(i))
|
|
45
45
|
return [
|
|
46
46
|
{
|
|
47
47
|
role: "ref",
|
|
48
|
-
shape:
|
|
48
|
+
shape: i,
|
|
49
49
|
optional: !1
|
|
50
50
|
}
|
|
51
51
|
];
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
52
|
+
const n = f(e);
|
|
53
|
+
if (n.asKind(t.UndefinedKeyword))
|
|
54
54
|
return "undefined";
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
if (
|
|
55
|
+
const o = n.asKind(t.LiteralType);
|
|
56
|
+
if (o) {
|
|
57
|
+
if (o.getFirstChildByKind(t.TrueKeyword))
|
|
58
58
|
return "true";
|
|
59
|
-
if (
|
|
59
|
+
if (o.getFirstChildByKind(t.FalseKeyword))
|
|
60
60
|
return "false";
|
|
61
61
|
}
|
|
62
|
-
if (
|
|
62
|
+
if (n.asKind(t.BooleanKeyword) || n.asKind(t.TrueKeyword) || n.asKind(t.FalseKeyword))
|
|
63
63
|
return "boolean";
|
|
64
|
-
if (
|
|
64
|
+
if (n.asKind(t.StringKeyword) || n.asKind(t.StringLiteral))
|
|
65
65
|
return "string";
|
|
66
|
-
if (
|
|
66
|
+
if (n.asKind(t.NumberKeyword) || n.asKind(t.NumericLiteral))
|
|
67
67
|
return "number";
|
|
68
|
-
if (
|
|
68
|
+
if (n.asKind(t.BigIntKeyword) || n.asKind(t.BigIntLiteral))
|
|
69
69
|
return "bigint";
|
|
70
|
-
const r =
|
|
70
|
+
const r = n.asKind(t.TypeLiteral);
|
|
71
71
|
if (r)
|
|
72
|
-
return r.getFirstChildByKind(t.SyntaxList).getChildrenOfKind(t.PropertySignature).map((
|
|
73
|
-
const
|
|
72
|
+
return r.getFirstChildByKind(t.SyntaxList).getChildrenOfKind(t.PropertySignature).map((B) => {
|
|
73
|
+
const I = B.getFirstChildByKind(t.Identifier), k = T(B), _ = I.getNextSiblingIfKind(t.QuestionToken);
|
|
74
74
|
return {
|
|
75
75
|
role: "property",
|
|
76
|
-
identifier:
|
|
77
|
-
shape: y(
|
|
78
|
-
optional:
|
|
76
|
+
identifier: I.getText(),
|
|
77
|
+
shape: y(k),
|
|
78
|
+
optional: k.getType().isNullable() || !!_
|
|
79
79
|
};
|
|
80
80
|
});
|
|
81
|
-
const g =
|
|
81
|
+
const g = n.asKind(t.TypeReference);
|
|
82
82
|
if (g)
|
|
83
83
|
return y(g.getFirstChild());
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
return c(
|
|
84
|
+
if (n.asKind(t.PropertyAccessExpression)) {
|
|
85
|
+
const b = f(n.getLastChild());
|
|
86
|
+
return c(b.asKind(t.CallExpression).getReturnType(), b);
|
|
87
87
|
}
|
|
88
|
-
const h =
|
|
88
|
+
const h = n.asKind(t.UnionType);
|
|
89
89
|
if (h)
|
|
90
|
-
return c(h.getType(),
|
|
91
|
-
const
|
|
92
|
-
if (A)
|
|
93
|
-
return y(A.getLastChild());
|
|
94
|
-
const F = i.asKind(t.QualifiedName);
|
|
95
|
-
if (F)
|
|
96
|
-
return y(F.getLastChild());
|
|
97
|
-
const x = i.asKind(t.CallExpression);
|
|
90
|
+
return c(h.getType(), n);
|
|
91
|
+
const x = n.asKind(t.TypeQuery);
|
|
98
92
|
if (x)
|
|
99
|
-
return
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
return y(
|
|
103
|
-
const
|
|
93
|
+
return y(x.getLastChild());
|
|
94
|
+
const C = n.asKind(t.QualifiedName);
|
|
95
|
+
if (C)
|
|
96
|
+
return y(C.getLastChild());
|
|
97
|
+
const K = n.asKind(t.CallExpression);
|
|
98
|
+
if (K)
|
|
99
|
+
return c(K.getReturnType(), K);
|
|
100
|
+
const P = n.asKind(t.AwaitExpression);
|
|
104
101
|
if (P)
|
|
105
|
-
return y(P.getChildAtIndex(
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
102
|
+
return y(P.getChildAtIndex(1));
|
|
103
|
+
const E = n.asKind(t.AsExpression);
|
|
104
|
+
if (E)
|
|
105
|
+
return y(E.getChildAtIndex(2));
|
|
106
|
+
const D = n.getSourceFile().getFilePath().split("/").pop();
|
|
107
|
+
return m.warn(`[${D}] Unknown node type: ${n.getKindName()}`), "unknown_1";
|
|
108
|
+
}, z = (e) => e.getFirstDescendantByKind(t.SyntaxList).getChildrenOfKind(t.PropertyAssignment).map((o) => {
|
|
109
|
+
const l = o.getFirstChild(), p = (() => {
|
|
110
|
+
if (l.isKind(t.Identifier))
|
|
111
|
+
return l.getText();
|
|
112
|
+
if (l.isKind(t.StringLiteral))
|
|
113
|
+
return l.getLiteralText();
|
|
114
|
+
const r = o.getSourceFile().getFilePath().split("/").pop();
|
|
115
|
+
return m.warn(`[${r}] Unknown identifier name: ${l.getText()}`), "unknown_30";
|
|
116
|
+
})(), a = o.getLastChild(), d = f(a);
|
|
117
117
|
return {
|
|
118
118
|
role: "property",
|
|
119
119
|
identifier: p,
|
|
120
|
-
shape:
|
|
121
|
-
optional: R(
|
|
122
|
-
description: N(
|
|
123
|
-
errorMessage: N(
|
|
120
|
+
shape: A(d),
|
|
121
|
+
optional: R(d),
|
|
122
|
+
description: N(d, "description"),
|
|
123
|
+
errorMessage: N(d, "errorMessage")
|
|
124
124
|
};
|
|
125
|
-
}) || [],
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
-
},
|
|
129
|
-
const
|
|
130
|
-
if (s
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
return "unknown_zod_object";
|
|
142
|
-
const o = p.getFirstChildByKind(t.SyntaxList);
|
|
143
|
-
return o ? o.getChildrenOfKind(t.PropertyAssignment).map((r) => {
|
|
144
|
-
const g = r.getFirstChildByKind(t.Identifier).getText(), u = r.getLastChild();
|
|
145
|
-
return {
|
|
146
|
-
role: "property",
|
|
147
|
-
identifier: g,
|
|
148
|
-
shape: K(u) ? C(u) : T(u),
|
|
149
|
-
optional: !1
|
|
150
|
-
};
|
|
151
|
-
}) : [];
|
|
125
|
+
}) || [], L = (e) => {
|
|
126
|
+
const i = e.asKind(t.CallExpression);
|
|
127
|
+
return i ? (i.getReturnType().getSymbol()?.getName() ?? "").startsWith("Zod") : !1;
|
|
128
|
+
}, j = (e) => {
|
|
129
|
+
const i = e.asKind(t.CallExpression), n = i.getReturnType(), s = n.getProperty("_output");
|
|
130
|
+
if (s)
|
|
131
|
+
return c(s.getTypeAtLocation(i), i);
|
|
132
|
+
const o = e.getSourceFile().getFilePath().split("/").pop(), l = n.getSymbol()?.getName() ?? "";
|
|
133
|
+
return m.warn(`[${o}] Unknown zod type: ${l}`), "unknown_zod";
|
|
134
|
+
}, A = (e) => {
|
|
135
|
+
if (L(e))
|
|
136
|
+
return j(e);
|
|
137
|
+
const i = e.getParent().getFirstChildByKind(t.AsExpression);
|
|
138
|
+
if (i) {
|
|
139
|
+
const r = i.getLastChildByKind(t.TypeReference);
|
|
140
|
+
return w(r);
|
|
152
141
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return [
|
|
157
|
-
{
|
|
158
|
-
role: "array",
|
|
159
|
-
shape: K(a) ? C(a) : T(a),
|
|
160
|
-
optional: !1
|
|
161
|
-
}
|
|
162
|
-
];
|
|
163
|
-
const o = n.getFirstChildByKind(t.PropertyAccessExpression)?.getFirstChildByKind(t.CallExpression);
|
|
164
|
-
return o && K(o) ? [
|
|
165
|
-
{
|
|
166
|
-
role: "array",
|
|
167
|
-
shape: C(o),
|
|
168
|
-
optional: !1
|
|
169
|
-
}
|
|
170
|
-
] : "unknown_zod_array";
|
|
171
|
-
}
|
|
172
|
-
if (s === "ZodEnum") {
|
|
173
|
-
const a = i.getTypeArguments();
|
|
174
|
-
if (a.length > 0) {
|
|
175
|
-
const l = a[0].getProperties().map((r) => ({
|
|
176
|
-
role: "union_entry",
|
|
177
|
-
shape: c(r.getTypeAtLocation(n), n, []),
|
|
178
|
-
optional: !1
|
|
179
|
-
}));
|
|
180
|
-
if (l.length === 1)
|
|
181
|
-
return l[0].shape;
|
|
182
|
-
if (l.length > 1)
|
|
183
|
-
return [
|
|
184
|
-
{
|
|
185
|
-
role: "union",
|
|
186
|
-
shape: l,
|
|
187
|
-
optional: !1
|
|
188
|
-
}
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
return "unknown_zod_enum";
|
|
192
|
-
}
|
|
193
|
-
if (s === "ZodOptional") {
|
|
194
|
-
const a = n.getFirstChildByKind(t.PropertyAccessExpression)?.getFirstChildByKind(t.CallExpression);
|
|
195
|
-
return a && K(a) ? C(a) : "unknown_zod_optional";
|
|
196
|
-
}
|
|
197
|
-
const d = e.getSourceFile().getFilePath().split("/").pop();
|
|
198
|
-
return m.warn(`[${d}] Unknown zod type: ${s}`), "unknown_zod";
|
|
199
|
-
}, T = (e) => {
|
|
200
|
-
if (K(e))
|
|
201
|
-
return C(e);
|
|
202
|
-
const n = e.getParent().getFirstChildByKind(t.AsExpression);
|
|
203
|
-
if (n) {
|
|
204
|
-
const r = n.getLastChildByKind(t.TypeReference);
|
|
205
|
-
return B(r);
|
|
206
|
-
}
|
|
207
|
-
const i = e.getParent().getFirstChildByKind(t.TypeReference);
|
|
208
|
-
if (i)
|
|
209
|
-
return B(i);
|
|
142
|
+
const n = e.getParent().getFirstChildByKind(t.TypeReference);
|
|
143
|
+
if (n)
|
|
144
|
+
return w(n);
|
|
210
145
|
if (e.getParent().getChildrenOfKind(t.SyntaxList).length >= 2) {
|
|
211
146
|
const r = e.getParent().getFirstChildByKind(t.SyntaxList).getFirstChild();
|
|
212
147
|
return y(r);
|
|
@@ -220,80 +155,80 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
220
155
|
return c(g.getType(), g, []);
|
|
221
156
|
const u = r.getParent().getFirstChildByKind(t.ObjectLiteralExpression);
|
|
222
157
|
if (u)
|
|
223
|
-
return
|
|
158
|
+
return A(u);
|
|
224
159
|
if (r.getKind() === t.CallExpression || r.getKind() === t.IntersectionType)
|
|
225
|
-
return
|
|
160
|
+
return A(r);
|
|
226
161
|
const h = e.getSourceFile().getFilePath().split("/").pop();
|
|
227
162
|
return m.warn(`[${h}] Unknown call expression argument: ${r.getKindName()}`), "unknown_3";
|
|
228
163
|
}
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
231
|
-
const r =
|
|
232
|
-
return c(r,
|
|
164
|
+
const l = e.getFirstChildByKind(t.SyntaxList).getChildrenOfKind(t.PropertyAssignment).find((r) => r.getFirstChildByKind(t.Identifier)?.getText() === "parse");
|
|
165
|
+
if (l) {
|
|
166
|
+
const r = T(l).asKind(t.ArrowFunction).getReturnType();
|
|
167
|
+
return c(r, l);
|
|
233
168
|
}
|
|
234
169
|
const p = e.getFirstChildByKind(t.SyntaxList)?.getFirstChildByKind(t.ImportType);
|
|
235
170
|
if (p) {
|
|
236
171
|
const r = p.getLastChildByKind(t.GreaterThanToken).getChildIndex(), g = p.getChildAtIndex(r - 1);
|
|
237
172
|
return y(g.getFirstChild());
|
|
238
173
|
}
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const r =
|
|
174
|
+
const a = e.isKind(t.IntersectionType) ? e : e.getParent()?.isKind(t.VariableDeclaration) ? e.getParent()?.getFirstChildByKind(t.IntersectionType) : null;
|
|
175
|
+
if (a) {
|
|
176
|
+
const r = a.getFirstChildByKind(t.TypeReference);
|
|
242
177
|
if (r)
|
|
243
|
-
return
|
|
178
|
+
return w(r);
|
|
244
179
|
}
|
|
245
|
-
const
|
|
246
|
-
return m.warn(`[${
|
|
180
|
+
const d = e.getSourceFile().getFilePath().split("/").pop();
|
|
181
|
+
return m.warn(`[${d}] Unknown import type node`), "unknown_2";
|
|
247
182
|
}, R = (e) => {
|
|
248
|
-
if (
|
|
183
|
+
if (L(e))
|
|
249
184
|
return (e.asKind(t.CallExpression).getReturnType().getSymbol()?.getName() ?? "") === "ZodOptional";
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
252
|
-
const
|
|
253
|
-
if (
|
|
185
|
+
const i = e.asKind(t.CallExpression);
|
|
186
|
+
if (i) {
|
|
187
|
+
const o = i.getFirstChildByKind(t.Identifier);
|
|
188
|
+
if (o?.getText() === "OptionalParam")
|
|
254
189
|
return !0;
|
|
255
|
-
if (
|
|
190
|
+
if (o?.getText() === "RequiredParam")
|
|
256
191
|
return !1;
|
|
257
|
-
const
|
|
192
|
+
const l = i.getFirstChildByKind(t.SyntaxList), p = f(l.getFirstChild());
|
|
258
193
|
return R(p);
|
|
259
194
|
}
|
|
260
|
-
return e.getFirstDescendantByKind(t.SyntaxList).getChildrenOfKind(t.PropertyAssignment).some((
|
|
261
|
-
}, N = (e,
|
|
262
|
-
if (
|
|
195
|
+
return e.getFirstDescendantByKind(t.SyntaxList).getChildrenOfKind(t.PropertyAssignment).some((o) => o.getFirstDescendantByKind(t.Identifier).getText() === "optional" ? T(o).getKind() === t.TrueKeyword : !1);
|
|
196
|
+
}, N = (e, i) => {
|
|
197
|
+
if (L(e))
|
|
263
198
|
return "";
|
|
264
|
-
const
|
|
199
|
+
const n = f(e), s = n.asKind(t.CallExpression);
|
|
265
200
|
if (s) {
|
|
266
201
|
const g = s.getLastChildByKind(t.SyntaxList);
|
|
267
|
-
return N(g,
|
|
202
|
+
return N(g, i);
|
|
268
203
|
}
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
return
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
-
const u = U(
|
|
204
|
+
const o = n.asKind(t.SyntaxList);
|
|
205
|
+
if (o)
|
|
206
|
+
return o.getChildren().map((u) => N(u, i)).find((u) => !!u && u !== "unknown_25") || "";
|
|
207
|
+
const l = n.asKind(t.ObjectLiteralExpression);
|
|
208
|
+
if (l) {
|
|
209
|
+
const u = U(l).find((h) => h.identifier === i);
|
|
275
210
|
return u ? Array.isArray(u.value) ? "array" : u.value || "" : "";
|
|
276
211
|
}
|
|
277
|
-
const p =
|
|
212
|
+
const p = n.asKind(t.IntersectionType);
|
|
278
213
|
if (p)
|
|
279
|
-
return p.getTypeNodes().flatMap((g) => N(g,
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
return N(
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
return
|
|
214
|
+
return p.getTypeNodes().flatMap((g) => N(g, i)).filter((g) => !!g && g !== "unknown_25")[0] || "unknown_27";
|
|
215
|
+
const a = n.asKind(t.TypeLiteral);
|
|
216
|
+
if (a)
|
|
217
|
+
return N(a.getFirstChildByKind(t.SyntaxList), i);
|
|
218
|
+
const d = n.asKind(t.PropertySignature);
|
|
219
|
+
if (d && n.getFirstDescendantByKind(t.Identifier).getText() === i)
|
|
220
|
+
return T(d).getFirstDescendantByKind(
|
|
286
221
|
t.StringLiteral
|
|
287
222
|
).getLiteralText();
|
|
288
|
-
const r =
|
|
289
|
-
return m.dev(`[${r}] Unknown property string value node ${
|
|
223
|
+
const r = n.getSourceFile().getFilePath().split("/").pop();
|
|
224
|
+
return m.dev(`[${r}] Unknown property string value node ${n.getKindName()}`), "unknown_25";
|
|
290
225
|
}, M = (e) => {
|
|
291
|
-
const
|
|
292
|
-
if (!e.isObject() || !
|
|
226
|
+
const i = e.getSymbol();
|
|
227
|
+
if (!e.isObject() || !i)
|
|
293
228
|
return !1;
|
|
294
|
-
const
|
|
295
|
-
return
|
|
296
|
-
}, c = (e,
|
|
229
|
+
const n = e.getTypeArguments();
|
|
230
|
+
return i.getName() === "Promise" && n.length === 1;
|
|
231
|
+
}, c = (e, i, n = []) => {
|
|
297
232
|
const s = e.getAliasSymbol()?.getName();
|
|
298
233
|
if (s && V.getInstance().hasExposedModel(s))
|
|
299
234
|
return [
|
|
@@ -303,16 +238,16 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
303
238
|
optional: !1
|
|
304
239
|
}
|
|
305
240
|
];
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
241
|
+
const o = M(e) ? e.getTypeArguments()[0] : e;
|
|
242
|
+
if (n.some((d) => d === o))
|
|
308
243
|
return "circular";
|
|
309
|
-
const
|
|
244
|
+
const l = o.compilerType, p = O.get(l);
|
|
310
245
|
if (p !== void 0)
|
|
311
246
|
return p;
|
|
312
|
-
const
|
|
313
|
-
return
|
|
314
|
-
},
|
|
315
|
-
const s =
|
|
247
|
+
const a = Q(o, i, n);
|
|
248
|
+
return O.set(l, a), a;
|
|
249
|
+
}, Q = (e, i, n) => {
|
|
250
|
+
const s = n.concat(e);
|
|
316
251
|
if (e.getText() === "void")
|
|
317
252
|
return "void";
|
|
318
253
|
if (e.isAny())
|
|
@@ -351,9 +286,9 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
351
286
|
return [
|
|
352
287
|
{
|
|
353
288
|
role: "tuple",
|
|
354
|
-
shape: e.getTupleElements().map((
|
|
289
|
+
shape: e.getTupleElements().map((a) => ({
|
|
355
290
|
role: "tuple_entry",
|
|
356
|
-
shape: c(
|
|
291
|
+
shape: c(a, i, s),
|
|
357
292
|
optional: !1
|
|
358
293
|
})),
|
|
359
294
|
optional: !1
|
|
@@ -363,26 +298,26 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
363
298
|
return [
|
|
364
299
|
{
|
|
365
300
|
role: "array",
|
|
366
|
-
shape: c(e.getArrayElementType(),
|
|
301
|
+
shape: c(e.getArrayElementType(), i, s),
|
|
367
302
|
optional: !1
|
|
368
303
|
}
|
|
369
304
|
];
|
|
370
305
|
if (e.isObject()) {
|
|
371
|
-
const
|
|
306
|
+
const a = e.getNumberIndexType(), r = e.getBaseTypes()?.find((g) => g.isArray());
|
|
372
307
|
if (r)
|
|
373
308
|
return [
|
|
374
309
|
{
|
|
375
310
|
role: "array",
|
|
376
311
|
shape: c(
|
|
377
|
-
r.getArrayElementType() ??
|
|
378
|
-
|
|
312
|
+
r.getArrayElementType() ?? a,
|
|
313
|
+
i,
|
|
379
314
|
s
|
|
380
315
|
),
|
|
381
316
|
optional: !1
|
|
382
317
|
}
|
|
383
318
|
];
|
|
384
319
|
}
|
|
385
|
-
const
|
|
320
|
+
const o = e.getSymbol()?.getName(), l = /* @__PURE__ */ new Set([
|
|
386
321
|
"Buffer",
|
|
387
322
|
"Uint8Array",
|
|
388
323
|
"Int8Array",
|
|
@@ -399,7 +334,7 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
399
334
|
"SharedArrayBuffer",
|
|
400
335
|
"ReadableStream"
|
|
401
336
|
]);
|
|
402
|
-
if (e.isObject() &&
|
|
337
|
+
if (e.isObject() && o && l.has(o))
|
|
403
338
|
return [
|
|
404
339
|
{
|
|
405
340
|
role: "buffer",
|
|
@@ -407,72 +342,72 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
407
342
|
optional: !1
|
|
408
343
|
}
|
|
409
344
|
];
|
|
410
|
-
if (e.isObject() &&
|
|
345
|
+
if (e.isObject() && o === "RegExp")
|
|
411
346
|
return "string";
|
|
412
|
-
if (e.isObject() &&
|
|
413
|
-
const
|
|
347
|
+
if (e.isObject() && o === "Map") {
|
|
348
|
+
const d = e.getTypeArguments()[1];
|
|
414
349
|
return [
|
|
415
350
|
{
|
|
416
351
|
role: "record",
|
|
417
|
-
shape:
|
|
352
|
+
shape: d ? c(d, i, s) : "unknown",
|
|
418
353
|
optional: !1
|
|
419
354
|
}
|
|
420
355
|
];
|
|
421
356
|
}
|
|
422
|
-
if (e.isObject() &&
|
|
423
|
-
const
|
|
357
|
+
if (e.isObject() && o === "Set") {
|
|
358
|
+
const d = e.getTypeArguments()[0];
|
|
424
359
|
return [
|
|
425
360
|
{
|
|
426
361
|
role: "array",
|
|
427
|
-
shape:
|
|
362
|
+
shape: d ? c(d, i, s) : "unknown",
|
|
428
363
|
optional: !1
|
|
429
364
|
}
|
|
430
365
|
];
|
|
431
366
|
}
|
|
432
367
|
if (e.isObject() && e.getProperties().length === 0) {
|
|
433
|
-
const
|
|
434
|
-
if (
|
|
368
|
+
const a = e.getAliasTypeArguments()[1] ?? e.getStringIndexType();
|
|
369
|
+
if (a)
|
|
435
370
|
return [
|
|
436
371
|
{
|
|
437
372
|
role: "record",
|
|
438
|
-
shape: c(
|
|
373
|
+
shape: c(a, i, s),
|
|
439
374
|
optional: !1
|
|
440
375
|
}
|
|
441
376
|
];
|
|
442
377
|
}
|
|
443
378
|
if (e.isObject())
|
|
444
|
-
return
|
|
445
|
-
const
|
|
446
|
-
if (!
|
|
379
|
+
return o === "Date" || e.getText() === "Date" ? "Date" : e.getProperties().map((a) => {
|
|
380
|
+
const d = a.getValueDeclaration() || a.getDeclarations()[0], r = c(a.getTypeAtLocation(i), i, s);
|
|
381
|
+
if (!d)
|
|
447
382
|
return {
|
|
448
383
|
role: "property",
|
|
449
|
-
identifier:
|
|
384
|
+
identifier: a.getName(),
|
|
450
385
|
shape: r,
|
|
451
386
|
optional: !1
|
|
452
387
|
};
|
|
453
|
-
if (!(
|
|
388
|
+
if (!(d.asKind(t.PropertySignature) || d.asKind(t.PropertyAssignment) || d.asKind(t.ShorthandPropertyAssignment)))
|
|
454
389
|
return {
|
|
455
390
|
role: "property",
|
|
456
|
-
identifier:
|
|
391
|
+
identifier: a.getName(),
|
|
457
392
|
shape: r,
|
|
458
393
|
optional: !1
|
|
459
394
|
};
|
|
460
|
-
const u =
|
|
395
|
+
const u = a.getTypeAtLocation(i).isNullable();
|
|
461
396
|
return {
|
|
462
397
|
role: "property",
|
|
463
|
-
identifier:
|
|
398
|
+
identifier: a.getName(),
|
|
464
399
|
shape: r,
|
|
465
400
|
optional: u
|
|
466
401
|
};
|
|
467
|
-
}).filter((
|
|
402
|
+
}).filter((a) => a.shape !== "undefined");
|
|
468
403
|
if (e.isUnion()) {
|
|
469
|
-
const
|
|
404
|
+
const d = e.getUnionTypes().map((u) => ({
|
|
470
405
|
role: "union_entry",
|
|
471
|
-
shape: c(u,
|
|
406
|
+
shape: c(u, i, s),
|
|
472
407
|
optional: !1
|
|
473
408
|
})).filter(
|
|
474
|
-
(u, h,
|
|
475
|
-
), r =
|
|
409
|
+
(u, h, x) => !x.find((C, K) => C.shape === u.shape && K > h)
|
|
410
|
+
), r = d.some((u) => u.shape === "undefined"), g = d.filter((u) => u.shape !== "undefined");
|
|
476
411
|
return g.length === 1 ? g[0].shape : [
|
|
477
412
|
{
|
|
478
413
|
role: "union",
|
|
@@ -482,31 +417,31 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
482
417
|
];
|
|
483
418
|
}
|
|
484
419
|
if (e.isIntersection())
|
|
485
|
-
return e.getIntersectionTypes().map((r) => c(r,
|
|
486
|
-
const p =
|
|
420
|
+
return e.getIntersectionTypes().map((r) => c(r, i, s)).filter((r) => typeof r != "string").reduce((r, g) => [...r, ...g], []);
|
|
421
|
+
const p = i.getSourceFile().getFilePath().split("/").pop();
|
|
487
422
|
return m.warn(`[${p}] Unknown type shape node ${e.getText()}`), "unknown_5";
|
|
488
|
-
},
|
|
423
|
+
}, F = (e) => {
|
|
489
424
|
if (e.isKind(t.Identifier))
|
|
490
|
-
return
|
|
425
|
+
return F(f(e));
|
|
491
426
|
if (e.isKind(t.StringLiteral))
|
|
492
427
|
return e.getLiteralValue();
|
|
493
428
|
if (e.isKind(t.ArrayLiteralExpression))
|
|
494
|
-
return e.forEachChildAsArray().map((
|
|
429
|
+
return e.forEachChildAsArray().map((n) => F(n));
|
|
495
430
|
if (e.isKind(t.PropertyAccessExpression))
|
|
496
|
-
return
|
|
431
|
+
return F(T(e));
|
|
497
432
|
if (e.isKind(t.ObjectLiteralExpression))
|
|
498
433
|
return U(e);
|
|
499
|
-
const
|
|
500
|
-
return m.dev(`[${
|
|
434
|
+
const i = e.getSourceFile().getFilePath().split("/").pop();
|
|
435
|
+
return m.dev(`[${i}] Unknown literal value node ${e.getKindName()}`), "unknown_6";
|
|
501
436
|
}, H = (e) => {
|
|
502
|
-
const
|
|
503
|
-
if (!n) return null;
|
|
504
|
-
const i = n.getArguments()[0];
|
|
437
|
+
const i = e.getFirstDescendantByKind(t.CallExpression);
|
|
505
438
|
if (!i) return null;
|
|
506
|
-
const
|
|
439
|
+
const n = i.getArguments()[0];
|
|
440
|
+
if (!n) return null;
|
|
441
|
+
const s = n.getType();
|
|
507
442
|
return s.isStringLiteral() ? s.getLiteralValue() : null;
|
|
508
|
-
}, U = (e) => e.getFirstDescendantByKind(t.SyntaxList).getChildrenOfKind(t.PropertyAssignment).map((
|
|
509
|
-
const p =
|
|
443
|
+
}, U = (e) => e.getFirstDescendantByKind(t.SyntaxList).getChildrenOfKind(t.PropertyAssignment).map((o) => {
|
|
444
|
+
const p = o.getFirstDescendantByKind(t.Identifier).getText(), a = o.getLastChild(), d = f(a), r = F(d);
|
|
510
445
|
return {
|
|
511
446
|
identifier: p,
|
|
512
447
|
value: r
|
|
@@ -514,13 +449,13 @@ const b = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), _ =
|
|
|
514
449
|
}) || [];
|
|
515
450
|
export {
|
|
516
451
|
f as findNodeImplementation,
|
|
517
|
-
|
|
452
|
+
T as findPropertyAssignmentValueNode,
|
|
518
453
|
c as getProperTypeShape,
|
|
519
454
|
y as getRecursiveNodeShape,
|
|
520
|
-
|
|
521
|
-
|
|
455
|
+
z as getShapeOfValidatorLiteral,
|
|
456
|
+
w as getTypeReferenceShape,
|
|
522
457
|
R as getValidatorPropertyOptionality,
|
|
523
|
-
|
|
458
|
+
A as getValidatorPropertyShape,
|
|
524
459
|
N as getValidatorPropertyStringValue,
|
|
525
460
|
U as getValuesOfObjectLiteral,
|
|
526
461
|
H as resolveEndpointPath
|