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