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