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