moonflower 1.3.5 → 1.3.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/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 +184 -145
- package/dist/openapi/analyzerModule/nodeParsers.mjs.map +1 -1
- package/dist/openapi/analyzerModule/test/TestCase.d.ts +10 -0
- package/dist/openapi/analyzerModule/test/TestCase.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/openapi/analyzerModule/nodeParsers.ts +50 -2
- package/src/openapi/analyzerModule/test/TestCase.ts +10 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +69 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +88 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SyntaxKind as e } from "ts-morph";
|
|
2
|
-
import { Logger as
|
|
3
|
-
import { OpenApiManager as
|
|
4
|
-
const
|
|
5
|
-
const i =
|
|
2
|
+
import { Logger as K } from "../../utils/logger.mjs";
|
|
3
|
+
import { OpenApiManager as v } from "../manager/OpenApiManager.mjs";
|
|
4
|
+
const b = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
5
|
+
const i = b.get(t);
|
|
6
6
|
if (i)
|
|
7
7
|
return i;
|
|
8
8
|
if (t.getKind() === e.Identifier) {
|
|
@@ -11,31 +11,31 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
11
11
|
const o = r.getParent().getLastChild();
|
|
12
12
|
if (o === t)
|
|
13
13
|
throw new Error("Recursive implementation found");
|
|
14
|
-
const
|
|
15
|
-
return
|
|
14
|
+
const d = h(o);
|
|
15
|
+
return b.set(t, d), d;
|
|
16
16
|
}
|
|
17
17
|
const l = t.asKind(e.Identifier).getDefinitions()[0]?.getNode();
|
|
18
18
|
if (l) {
|
|
19
19
|
const o = l.getParent().getLastChild();
|
|
20
20
|
if (o === t)
|
|
21
21
|
throw new Error("Recursive implementation found");
|
|
22
|
-
const
|
|
23
|
-
return
|
|
22
|
+
const d = h(o);
|
|
23
|
+
return b.set(t, d), d;
|
|
24
24
|
}
|
|
25
25
|
throw new Error("No implementation nor definition available");
|
|
26
26
|
}
|
|
27
|
-
return
|
|
28
|
-
},
|
|
27
|
+
return b.set(t, t), t;
|
|
28
|
+
}, S = (t) => {
|
|
29
29
|
const i = t.getChildrenOfKind(e.Identifier);
|
|
30
|
-
return i.length === 2 ?
|
|
30
|
+
return i.length === 2 ? h(i[1]) : t.getChildren().reverse().find(
|
|
31
31
|
(l) => l.getKind() !== e.GreaterThanToken && l.getKind() !== e.CommaToken && l.getKind() !== e.SemicolonToken
|
|
32
32
|
);
|
|
33
33
|
}, P = (t) => {
|
|
34
34
|
const i = t.getFirstChildByKind(e.SyntaxList);
|
|
35
|
-
return i.isKind(e.SyntaxList) ?
|
|
36
|
-
},
|
|
35
|
+
return i.isKind(e.SyntaxList) ? m(i.getFirstChild()) : m(i);
|
|
36
|
+
}, m = (t) => {
|
|
37
37
|
const i = t.getSymbol()?.getName();
|
|
38
|
-
if (i &&
|
|
38
|
+
if (i && v.getInstance().hasExposedModel(i))
|
|
39
39
|
return [
|
|
40
40
|
{
|
|
41
41
|
role: "ref",
|
|
@@ -43,7 +43,7 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
43
43
|
optional: !1
|
|
44
44
|
}
|
|
45
45
|
];
|
|
46
|
-
const r =
|
|
46
|
+
const r = h(t);
|
|
47
47
|
if (r.asKind(e.UndefinedKeyword))
|
|
48
48
|
return "undefined";
|
|
49
49
|
const n = r.asKind(e.LiteralType);
|
|
@@ -64,62 +64,62 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
64
64
|
const s = r.asKind(e.TypeLiteral);
|
|
65
65
|
if (s)
|
|
66
66
|
return s.getFirstChildByKind(e.SyntaxList).getChildrenOfKind(e.PropertySignature).map((I) => {
|
|
67
|
-
const k = I.getFirstChildByKind(e.Identifier),
|
|
67
|
+
const k = I.getFirstChildByKind(e.Identifier), O = S(I), _ = k.getNextSiblingIfKind(e.QuestionToken);
|
|
68
68
|
return {
|
|
69
69
|
role: "property",
|
|
70
70
|
identifier: k.getText(),
|
|
71
|
-
shape:
|
|
72
|
-
optional:
|
|
71
|
+
shape: m(O),
|
|
72
|
+
optional: O.getType().isNullable() || !!_
|
|
73
73
|
};
|
|
74
74
|
});
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
75
|
+
const a = r.asKind(e.TypeReference);
|
|
76
|
+
if (a)
|
|
77
|
+
return m(a.getFirstChild());
|
|
78
78
|
if (r.asKind(e.PropertyAccessExpression)) {
|
|
79
|
-
const
|
|
80
|
-
return f(
|
|
79
|
+
const B = h(r.getLastChild());
|
|
80
|
+
return f(B.asKind(e.CallExpression).getReturnType(), B);
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
return f(
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
return y
|
|
88
|
-
const
|
|
82
|
+
const c = r.asKind(e.UnionType);
|
|
83
|
+
if (c)
|
|
84
|
+
return f(c.getType(), r);
|
|
85
|
+
const y = r.asKind(e.TypeQuery);
|
|
86
|
+
if (y)
|
|
87
|
+
return m(y.getLastChild());
|
|
88
|
+
const A = r.asKind(e.QualifiedName);
|
|
89
|
+
if (A)
|
|
90
|
+
return m(A.getLastChild());
|
|
91
|
+
const T = r.asKind(e.CallExpression);
|
|
92
|
+
if (T)
|
|
93
|
+
return f(T.getReturnType(), T);
|
|
94
|
+
const F = r.asKind(e.AwaitExpression);
|
|
89
95
|
if (F)
|
|
90
|
-
return
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
return y(B.getChildAtIndex(1));
|
|
97
|
-
const E = r.asKind(e.AsExpression);
|
|
98
|
-
if (E)
|
|
99
|
-
return y(E.getChildAtIndex(2));
|
|
100
|
-
const D = r.getSourceFile().getFilePath().split("/").pop();
|
|
101
|
-
return m.warn(`[${D}] Unknown node type: ${r.getKindName()}`), "unknown_1";
|
|
96
|
+
return m(F.getChildAtIndex(1));
|
|
97
|
+
const L = r.asKind(e.AsExpression);
|
|
98
|
+
if (L)
|
|
99
|
+
return m(L.getChildAtIndex(2));
|
|
100
|
+
const U = r.getSourceFile().getFilePath().split("/").pop();
|
|
101
|
+
return K.warn(`[${U}] Unknown node type: ${r.getKindName()}`), "unknown_1";
|
|
102
102
|
}, z = (t) => t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).map((n) => {
|
|
103
|
-
const o = n.getFirstChild(),
|
|
103
|
+
const o = n.getFirstChild(), d = (() => {
|
|
104
104
|
if (o.isKind(e.Identifier))
|
|
105
105
|
return o.getText();
|
|
106
106
|
if (o.isKind(e.StringLiteral))
|
|
107
107
|
return o.getLiteralText();
|
|
108
108
|
const s = n.getSourceFile().getFilePath().split("/").pop();
|
|
109
|
-
return
|
|
110
|
-
})(),
|
|
109
|
+
return K.warn(`[${s}] Unknown identifier name: ${o.getText()}`), "unknown_30";
|
|
110
|
+
})(), p = n.getLastChild(), u = h(p);
|
|
111
111
|
return {
|
|
112
112
|
role: "property",
|
|
113
|
-
identifier:
|
|
114
|
-
shape:
|
|
113
|
+
identifier: d,
|
|
114
|
+
shape: x(u),
|
|
115
115
|
optional: V(u),
|
|
116
|
-
description:
|
|
117
|
-
errorMessage:
|
|
116
|
+
description: N(u, "description"),
|
|
117
|
+
errorMessage: N(u, "errorMessage")
|
|
118
118
|
};
|
|
119
|
-
}) || [],
|
|
119
|
+
}) || [], C = (t) => {
|
|
120
120
|
const i = t.asKind(e.CallExpression);
|
|
121
121
|
return i ? (i.getReturnType().getSymbol()?.getName() ?? "").startsWith("Zod") : !1;
|
|
122
|
-
},
|
|
122
|
+
}, E = (t) => {
|
|
123
123
|
const i = t.asKind(e.CallExpression), l = i.getReturnType().getSymbol()?.getName() ?? "";
|
|
124
124
|
if (l === "ZodNumber")
|
|
125
125
|
return "number";
|
|
@@ -130,16 +130,16 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
130
130
|
if (l === "ZodBigInt")
|
|
131
131
|
return "bigint";
|
|
132
132
|
if (l === "ZodObject") {
|
|
133
|
-
const
|
|
134
|
-
if (!
|
|
133
|
+
const d = i.getFirstChildByKind(e.SyntaxList)?.getFirstChild()?.asKind(e.ObjectLiteralExpression);
|
|
134
|
+
if (!d)
|
|
135
135
|
return "unknown_zod_object";
|
|
136
|
-
const
|
|
137
|
-
return
|
|
138
|
-
const
|
|
136
|
+
const p = d.getFirstChildByKind(e.SyntaxList);
|
|
137
|
+
return p ? p.getChildrenOfKind(e.PropertyAssignment).map((s) => {
|
|
138
|
+
const a = s.getFirstChildByKind(e.Identifier).getText(), g = s.getLastChild();
|
|
139
139
|
return {
|
|
140
140
|
role: "property",
|
|
141
|
-
identifier:
|
|
142
|
-
shape:
|
|
141
|
+
identifier: a,
|
|
142
|
+
shape: C(g) ? E(g) : x(g),
|
|
143
143
|
optional: !1
|
|
144
144
|
};
|
|
145
145
|
}) : [];
|
|
@@ -149,16 +149,16 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
149
149
|
return o ? [
|
|
150
150
|
{
|
|
151
151
|
role: "array",
|
|
152
|
-
shape:
|
|
152
|
+
shape: C(o) ? E(o) : x(o),
|
|
153
153
|
optional: !1
|
|
154
154
|
}
|
|
155
155
|
] : "unknown_zod_array";
|
|
156
156
|
}
|
|
157
157
|
const n = t.getSourceFile().getFilePath().split("/").pop();
|
|
158
|
-
return
|
|
159
|
-
},
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
158
|
+
return K.warn(`[${n}] Unknown zod type: ${l}`), "unknown_zod";
|
|
159
|
+
}, x = (t) => {
|
|
160
|
+
if (C(t))
|
|
161
|
+
return E(t);
|
|
162
162
|
const i = t.getParent().getFirstChildByKind(e.AsExpression);
|
|
163
163
|
if (i) {
|
|
164
164
|
const s = i.getLastChildByKind(e.TypeReference);
|
|
@@ -169,43 +169,43 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
169
169
|
return P(r);
|
|
170
170
|
if (t.getParent().getChildrenOfKind(e.SyntaxList).length >= 2) {
|
|
171
171
|
const s = t.getParent().getFirstChildByKind(e.SyntaxList).getFirstChild();
|
|
172
|
-
return
|
|
172
|
+
return m(s);
|
|
173
173
|
}
|
|
174
174
|
const l = t.getParent().getFirstChildByKind(e.CallExpression);
|
|
175
175
|
if (l) {
|
|
176
|
-
const s =
|
|
176
|
+
const s = h(
|
|
177
177
|
l.getFirstChildByKind(e.SyntaxList).getFirstChild()
|
|
178
|
-
),
|
|
179
|
-
if (
|
|
180
|
-
return f(
|
|
178
|
+
), a = s.getParent().getFirstChildByKind(e.TypeReference);
|
|
179
|
+
if (a)
|
|
180
|
+
return f(a.getType(), a, []);
|
|
181
181
|
const g = s.getParent().getFirstChildByKind(e.ObjectLiteralExpression);
|
|
182
182
|
if (g)
|
|
183
|
-
return
|
|
183
|
+
return x(g);
|
|
184
184
|
if (s.getKind() === e.CallExpression || s.getKind() === e.IntersectionType)
|
|
185
|
-
return
|
|
186
|
-
const
|
|
187
|
-
return
|
|
185
|
+
return x(s);
|
|
186
|
+
const c = t.getSourceFile().getFilePath().split("/").pop();
|
|
187
|
+
return K.warn(`[${c}] Unknown call expression argument: ${s.getKindName()}`), "unknown_3";
|
|
188
188
|
}
|
|
189
189
|
const o = t.getFirstChildByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).find((s) => s.getFirstChildByKind(e.Identifier)?.getText() === "parse");
|
|
190
190
|
if (o) {
|
|
191
|
-
const s =
|
|
191
|
+
const s = S(o).asKind(e.ArrowFunction).getReturnType();
|
|
192
192
|
return f(s, o);
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const s =
|
|
197
|
-
return
|
|
194
|
+
const d = t.getFirstChildByKind(e.SyntaxList)?.getFirstChildByKind(e.ImportType);
|
|
195
|
+
if (d) {
|
|
196
|
+
const s = d.getLastChildByKind(e.GreaterThanToken).getChildIndex(), a = d.getChildAtIndex(s - 1);
|
|
197
|
+
return m(a.getFirstChild());
|
|
198
198
|
}
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
const s =
|
|
199
|
+
const p = t.isKind(e.IntersectionType) ? t : t.getParent()?.isKind(e.VariableDeclaration) ? t.getParent()?.getFirstChildByKind(e.IntersectionType) : null;
|
|
200
|
+
if (p) {
|
|
201
|
+
const s = p.getFirstChildByKind(e.TypeReference);
|
|
202
202
|
if (s)
|
|
203
203
|
return P(s);
|
|
204
204
|
}
|
|
205
205
|
const u = t.getSourceFile().getFilePath().split("/").pop();
|
|
206
|
-
return
|
|
206
|
+
return K.warn(`[${u}] Unknown import type node`), "unknown_2";
|
|
207
207
|
}, V = (t) => {
|
|
208
|
-
if (
|
|
208
|
+
if (C(t))
|
|
209
209
|
return !1;
|
|
210
210
|
const i = t.asKind(e.CallExpression);
|
|
211
211
|
if (i) {
|
|
@@ -214,40 +214,40 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
214
214
|
return !0;
|
|
215
215
|
if (n?.getText() === "RequiredParam")
|
|
216
216
|
return !1;
|
|
217
|
-
const o = i.getFirstChildByKind(e.SyntaxList),
|
|
218
|
-
return V(
|
|
217
|
+
const o = i.getFirstChildByKind(e.SyntaxList), d = h(o.getFirstChild());
|
|
218
|
+
return V(d);
|
|
219
219
|
}
|
|
220
|
-
return t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).some((n) => n.getFirstDescendantByKind(e.Identifier).getText() === "optional" ?
|
|
221
|
-
},
|
|
222
|
-
if (
|
|
220
|
+
return t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).some((n) => n.getFirstDescendantByKind(e.Identifier).getText() === "optional" ? S(n).getKind() === e.TrueKeyword : !1);
|
|
221
|
+
}, N = (t, i) => {
|
|
222
|
+
if (C(t))
|
|
223
223
|
return "";
|
|
224
|
-
const r =
|
|
224
|
+
const r = h(t), l = r.asKind(e.CallExpression);
|
|
225
225
|
if (l) {
|
|
226
|
-
const
|
|
227
|
-
return
|
|
226
|
+
const a = l.getLastChildByKind(e.SyntaxList);
|
|
227
|
+
return N(a, i);
|
|
228
228
|
}
|
|
229
229
|
const n = r.asKind(e.SyntaxList);
|
|
230
230
|
if (n)
|
|
231
|
-
return n.getChildren().map((g) =>
|
|
231
|
+
return n.getChildren().map((g) => N(g, i)).find((g) => !!g && g !== "unknown_25") || "";
|
|
232
232
|
const o = r.asKind(e.ObjectLiteralExpression);
|
|
233
233
|
if (o) {
|
|
234
|
-
const g =
|
|
234
|
+
const g = R(o).find((c) => c.identifier === i);
|
|
235
235
|
return g ? Array.isArray(g.value) ? "array" : g.value || "" : "";
|
|
236
236
|
}
|
|
237
|
-
const
|
|
237
|
+
const d = r.asKind(e.IntersectionType);
|
|
238
|
+
if (d)
|
|
239
|
+
return d.getTypeNodes().flatMap((a) => N(a, i)).filter((a) => !!a && a !== "unknown_25")[0] || "unknown_27";
|
|
240
|
+
const p = r.asKind(e.TypeLiteral);
|
|
238
241
|
if (p)
|
|
239
|
-
return p.
|
|
240
|
-
const a = r.asKind(e.TypeLiteral);
|
|
241
|
-
if (a)
|
|
242
|
-
return K(a.getFirstChildByKind(e.SyntaxList), i);
|
|
242
|
+
return N(p.getFirstChildByKind(e.SyntaxList), i);
|
|
243
243
|
const u = r.asKind(e.PropertySignature);
|
|
244
244
|
if (u && r.getFirstDescendantByKind(e.Identifier).getText() === i)
|
|
245
|
-
return
|
|
245
|
+
return S(u).getFirstDescendantByKind(
|
|
246
246
|
e.StringLiteral
|
|
247
247
|
).getLiteralText();
|
|
248
248
|
const s = r.getSourceFile().getFilePath().split("/").pop();
|
|
249
|
-
return
|
|
250
|
-
},
|
|
249
|
+
return K.dev(`[${s}] Unknown property string value node ${r.getKindName()}`), "unknown_25";
|
|
250
|
+
}, D = (t) => {
|
|
251
251
|
const i = t.getSymbol();
|
|
252
252
|
if (!t.isObject() || !i)
|
|
253
253
|
return !1;
|
|
@@ -255,7 +255,7 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
255
255
|
return i.getName() === "Promise" && r.length === 1;
|
|
256
256
|
}, f = (t, i, r = []) => {
|
|
257
257
|
const l = t.getAliasSymbol()?.getName();
|
|
258
|
-
if (l &&
|
|
258
|
+
if (l && v.getInstance().hasExposedModel(l))
|
|
259
259
|
return [
|
|
260
260
|
{
|
|
261
261
|
role: "ref",
|
|
@@ -263,8 +263,8 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
263
263
|
optional: !1
|
|
264
264
|
}
|
|
265
265
|
];
|
|
266
|
-
const n =
|
|
267
|
-
if (r.some((
|
|
266
|
+
const n = D(t) ? t.getTypeArguments()[0] : t;
|
|
267
|
+
if (r.some((s) => s === n))
|
|
268
268
|
return "circular";
|
|
269
269
|
const o = r.concat(n);
|
|
270
270
|
if (n.getText() === "void")
|
|
@@ -305,9 +305,9 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
305
305
|
return [
|
|
306
306
|
{
|
|
307
307
|
role: "tuple",
|
|
308
|
-
shape: n.getTupleElements().map((
|
|
308
|
+
shape: n.getTupleElements().map((s) => ({
|
|
309
309
|
role: "tuple_entry",
|
|
310
|
-
shape: f(
|
|
310
|
+
shape: f(s, i, o),
|
|
311
311
|
optional: !1
|
|
312
312
|
})),
|
|
313
313
|
optional: !1
|
|
@@ -321,7 +321,24 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
321
321
|
optional: !1
|
|
322
322
|
}
|
|
323
323
|
];
|
|
324
|
-
|
|
324
|
+
const d = n.getSymbol()?.getName(), p = /* @__PURE__ */ new Set([
|
|
325
|
+
"Buffer",
|
|
326
|
+
"Uint8Array",
|
|
327
|
+
"Int8Array",
|
|
328
|
+
"Uint8ClampedArray",
|
|
329
|
+
"Int16Array",
|
|
330
|
+
"Uint16Array",
|
|
331
|
+
"Int32Array",
|
|
332
|
+
"Uint32Array",
|
|
333
|
+
"Float32Array",
|
|
334
|
+
"Float64Array",
|
|
335
|
+
"BigInt64Array",
|
|
336
|
+
"BigUint64Array",
|
|
337
|
+
"ArrayBuffer",
|
|
338
|
+
"SharedArrayBuffer",
|
|
339
|
+
"ReadableStream"
|
|
340
|
+
]);
|
|
341
|
+
if (n.isObject() && d && p.has(d))
|
|
325
342
|
return [
|
|
326
343
|
{
|
|
327
344
|
role: "buffer",
|
|
@@ -329,75 +346,97 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
329
346
|
optional: !1
|
|
330
347
|
}
|
|
331
348
|
];
|
|
349
|
+
if (n.isObject() && d === "RegExp")
|
|
350
|
+
return "string";
|
|
351
|
+
if (n.isObject() && d === "Map") {
|
|
352
|
+
const a = n.getTypeArguments()[1];
|
|
353
|
+
return [
|
|
354
|
+
{
|
|
355
|
+
role: "record",
|
|
356
|
+
shape: a ? f(a, i, o) : "unknown",
|
|
357
|
+
optional: !1
|
|
358
|
+
}
|
|
359
|
+
];
|
|
360
|
+
}
|
|
361
|
+
if (n.isObject() && d === "Set") {
|
|
362
|
+
const a = n.getTypeArguments()[0];
|
|
363
|
+
return [
|
|
364
|
+
{
|
|
365
|
+
role: "array",
|
|
366
|
+
shape: a ? f(a, i, o) : "unknown",
|
|
367
|
+
optional: !1
|
|
368
|
+
}
|
|
369
|
+
];
|
|
370
|
+
}
|
|
332
371
|
if (n.isObject() && n.getProperties().length === 0) {
|
|
333
|
-
const
|
|
334
|
-
if (
|
|
372
|
+
const s = n.getAliasTypeArguments()[1] ?? n.getStringIndexType();
|
|
373
|
+
if (s)
|
|
335
374
|
return [
|
|
336
375
|
{
|
|
337
376
|
role: "record",
|
|
338
|
-
shape: f(
|
|
377
|
+
shape: f(s, i, o),
|
|
339
378
|
optional: !1
|
|
340
379
|
}
|
|
341
380
|
];
|
|
342
381
|
}
|
|
343
382
|
if (n.isObject())
|
|
344
|
-
return n.getText() === "Date" ? "Date" : n.getProperties().map((
|
|
345
|
-
const
|
|
346
|
-
if (!
|
|
383
|
+
return d === "Date" || n.getText() === "Date" ? "Date" : n.getProperties().map((s) => {
|
|
384
|
+
const a = s.getValueDeclaration() || s.getDeclarations()[0];
|
|
385
|
+
if (!a)
|
|
347
386
|
return {
|
|
348
387
|
role: "property",
|
|
349
|
-
identifier:
|
|
350
|
-
shape: f(
|
|
388
|
+
identifier: s.getName(),
|
|
389
|
+
shape: f(s.getTypeAtLocation(i), i, o),
|
|
351
390
|
optional: !1
|
|
352
391
|
};
|
|
353
|
-
if (!(
|
|
392
|
+
if (!(a.asKind(e.PropertySignature) || a.asKind(e.PropertyAssignment) || a.asKind(e.ShorthandPropertyAssignment)))
|
|
354
393
|
return {
|
|
355
394
|
role: "property",
|
|
356
|
-
identifier:
|
|
357
|
-
shape: f(
|
|
395
|
+
identifier: s.getName(),
|
|
396
|
+
shape: f(s.getTypeAtLocation(i), i, o),
|
|
358
397
|
optional: !1
|
|
359
398
|
};
|
|
360
|
-
const
|
|
399
|
+
const c = s.getTypeAtLocation(i).isNullable(), y = f(s.getTypeAtLocation(i), i, o);
|
|
361
400
|
return {
|
|
362
401
|
role: "property",
|
|
363
|
-
identifier:
|
|
364
|
-
shape:
|
|
365
|
-
optional:
|
|
402
|
+
identifier: s.getName(),
|
|
403
|
+
shape: y,
|
|
404
|
+
optional: c
|
|
366
405
|
};
|
|
367
|
-
}).filter((
|
|
406
|
+
}).filter((s) => s.shape !== "undefined");
|
|
368
407
|
if (n.isUnion()) {
|
|
369
|
-
const
|
|
408
|
+
const a = n.getUnionTypes().map((y) => ({
|
|
370
409
|
role: "union_entry",
|
|
371
|
-
shape: f(
|
|
410
|
+
shape: f(y, i, o),
|
|
372
411
|
optional: !1
|
|
373
412
|
})).filter(
|
|
374
|
-
(
|
|
375
|
-
),
|
|
376
|
-
return
|
|
413
|
+
(y, A, T) => !T.find((F, L) => F.shape === y.shape && L > A)
|
|
414
|
+
), g = a.some((y) => y.shape === "undefined"), c = a.filter((y) => y.shape !== "undefined");
|
|
415
|
+
return c.length === 1 ? c[0].shape : [
|
|
377
416
|
{
|
|
378
417
|
role: "union",
|
|
379
|
-
shape:
|
|
380
|
-
optional:
|
|
418
|
+
shape: c,
|
|
419
|
+
optional: g
|
|
381
420
|
}
|
|
382
421
|
];
|
|
383
422
|
}
|
|
384
423
|
if (n.isIntersection())
|
|
385
|
-
return n.getIntersectionTypes().map((
|
|
386
|
-
const
|
|
387
|
-
return
|
|
424
|
+
return n.getIntersectionTypes().map((g) => f(g, i, o)).filter((g) => typeof g != "string").reduce((g, c) => [...g, ...c], []);
|
|
425
|
+
const u = i.getSourceFile().getFilePath().split("/").pop();
|
|
426
|
+
return K.warn(`[${u}] Unknown type shape node ${t.getText()}`), "unknown_5";
|
|
388
427
|
}, w = (t) => {
|
|
389
428
|
if (t.isKind(e.Identifier))
|
|
390
|
-
return w(
|
|
429
|
+
return w(h(t));
|
|
391
430
|
if (t.isKind(e.StringLiteral))
|
|
392
431
|
return t.getLiteralValue();
|
|
393
432
|
if (t.isKind(e.ArrayLiteralExpression))
|
|
394
433
|
return t.forEachChildAsArray().map((r) => w(r));
|
|
395
434
|
if (t.isKind(e.PropertyAccessExpression))
|
|
396
|
-
return w(
|
|
435
|
+
return w(S(t));
|
|
397
436
|
if (t.isKind(e.ObjectLiteralExpression))
|
|
398
|
-
return
|
|
437
|
+
return R(t);
|
|
399
438
|
const i = t.getSourceFile().getFilePath().split("/").pop();
|
|
400
|
-
return
|
|
439
|
+
return K.dev(`[${i}] Unknown literal value node ${t.getKindName()}`), "unknown_6";
|
|
401
440
|
}, Q = (t) => {
|
|
402
441
|
const i = t.getFirstDescendantByKind(e.CallExpression);
|
|
403
442
|
if (!i) return null;
|
|
@@ -405,24 +444,24 @@ const L = /* @__PURE__ */ new WeakMap(), c = (t) => {
|
|
|
405
444
|
if (!r) return null;
|
|
406
445
|
const l = r.getType();
|
|
407
446
|
return l.isStringLiteral() ? l.getLiteralValue() : null;
|
|
408
|
-
},
|
|
409
|
-
const
|
|
447
|
+
}, R = (t) => t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).map((n) => {
|
|
448
|
+
const d = n.getFirstDescendantByKind(e.Identifier).getText(), p = n.getLastChild(), u = h(p), s = w(u);
|
|
410
449
|
return {
|
|
411
|
-
identifier:
|
|
450
|
+
identifier: d,
|
|
412
451
|
value: s
|
|
413
452
|
};
|
|
414
453
|
}) || [];
|
|
415
454
|
export {
|
|
416
|
-
|
|
417
|
-
|
|
455
|
+
h as findNodeImplementation,
|
|
456
|
+
S as findPropertyAssignmentValueNode,
|
|
418
457
|
f as getProperTypeShape,
|
|
419
|
-
|
|
458
|
+
m as getRecursiveNodeShape,
|
|
420
459
|
z as getShapeOfValidatorLiteral,
|
|
421
460
|
P as getTypeReferenceShape,
|
|
422
461
|
V as getValidatorPropertyOptionality,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
462
|
+
x as getValidatorPropertyShape,
|
|
463
|
+
N as getValidatorPropertyStringValue,
|
|
464
|
+
R as getValuesOfObjectLiteral,
|
|
426
465
|
Q as resolveEndpointPath
|
|
427
466
|
};
|
|
428
467
|
//# sourceMappingURL=nodeParsers.mjs.map
|