@loradb/lora-graphql 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +500 -77
- package/dist/analyze/access.d.ts +45 -2
- package/dist/analyze/statistics.d.ts +1 -0
- package/dist/cli.js +386 -323
- package/dist/cli.js.map +1 -1
- package/dist/compile/auth.d.ts +49 -0
- package/dist/compile/cache.d.ts +11 -1
- package/dist/compile/context.d.ts +20 -0
- package/dist/compile/cost.d.ts +36 -0
- package/dist/compile/read.d.ts +7 -0
- package/dist/{diff-CcRU-3_p.js → diff-B9iDdELF.js} +13 -12
- package/dist/{diff-CcRU-3_p.js.map → diff-B9iDdELF.js.map} +1 -1
- package/dist/driver-C5dSoSD8.js +13905 -0
- package/dist/driver-C5dSoSD8.js.map +1 -0
- package/dist/driver.d.ts +2 -0
- package/dist/errors.d.ts +29 -1
- package/dist/execute/budget.d.ts +22 -0
- package/dist/execute/changes.d.ts +2 -0
- package/dist/execute/cypher-mutation.d.ts +4 -1
- package/dist/execute/mutate.d.ts +29 -1
- package/dist/guards.d.ts +19 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -17
- package/dist/lora-graphql.d.ts +120 -13
- package/dist/model/desugar.d.ts +10 -0
- package/dist/model/directives.d.ts +1 -1
- package/dist/model/inputs.d.ts +9 -0
- package/dist/model/types.d.ts +46 -3
- package/dist/model/unique-together.d.ts +3 -0
- package/dist/schema/build.d.ts +6 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/dist/driver-DAtBEMWj.js +0 -11845
- package/dist/driver-DAtBEMWj.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
2
|
+
import { execFileSync as re } from "node:child_process";
|
|
3
|
+
import { stat as M, readFile as ce, readdir as ue, mkdir as le, writeFile as _ } from "node:fs/promises";
|
|
4
|
+
import { dirname as fe, basename as de, join as O, relative as pe } from "node:path";
|
|
5
|
+
import { parse as j, Kind as p, visit as Y, print as Z, typeFromAST as me, isNonNullType as G, isListType as he, getNamedType as ge, isEnumType as ve, isInputObjectType as we } from "graphql";
|
|
6
|
+
import { d as Ee } from "./diff-B9iDdELF.js";
|
|
7
|
+
import { q as K, e as be, M as Te, a as R, l as X, g as x, u as ee, c as Ne, i as ye, r as Se, w as Ie } from "./driver-C5dSoSD8.js";
|
|
8
|
+
const $e = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]), W = {
|
|
8
9
|
coalesce: "@coalesce is not supported: it hides predicates from indexes; store a value instead",
|
|
9
10
|
subscriptionsAuthorization: "@subscriptionsAuthorization is not supported: SUBSCRIBE rules go in @authorization",
|
|
10
11
|
shareable: "federation (@shareable) is not supported",
|
|
@@ -13,7 +14,7 @@ const be = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]), B = {
|
|
|
13
14
|
provides: "federation (@provides) is not supported",
|
|
14
15
|
exclude: "@exclude: use @query / @mutation to choose operations",
|
|
15
16
|
vector: "@vector on types (with a provider) is not supported: put @vector(dimensions:, similarity:) on a [Float!] field"
|
|
16
|
-
},
|
|
17
|
+
}, ke = [
|
|
17
18
|
["_NOT_IN", "IN"],
|
|
18
19
|
["_STARTS_WITH", "STARTS_WITH"],
|
|
19
20
|
["_ENDS_WITH", "ENDS_WITH"],
|
|
@@ -25,7 +26,7 @@ const be = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]), B = {
|
|
|
25
26
|
["_LT", "LT"],
|
|
26
27
|
["_IN", "IN"],
|
|
27
28
|
["_EQ", "EQ"]
|
|
28
|
-
],
|
|
29
|
+
], Oe = {
|
|
29
30
|
eq: "EQ",
|
|
30
31
|
in: "IN",
|
|
31
32
|
lt: "LT",
|
|
@@ -38,249 +39,249 @@ const be = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]), B = {
|
|
|
38
39
|
includes: "INCLUDES",
|
|
39
40
|
caseInsensitive: "CASE_INSENSITIVE"
|
|
40
41
|
};
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
(
|
|
44
|
-
),
|
|
45
|
-
ObjectTypeDefinition(
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
48
|
-
let l =
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
function De(n, s = []) {
|
|
43
|
+
const i = j(n, { noLocation: !0 }), a = [], e = i.definitions.filter(
|
|
44
|
+
(o) => o.kind === p.OBJECT_TYPE_DEFINITION && !$e.has(o.name.value) && !k(o.directives, "relationshipProperties") && !k(o.directives, "jwt")
|
|
45
|
+
), c = new Set(e.map((o) => o.name.value)), t = s.length > 0 ? je(s, e) : void 0, u = Y(i, {
|
|
46
|
+
ObjectTypeDefinition(o) {
|
|
47
|
+
if (!c.has(o.name.value)) return;
|
|
48
|
+
const r = o.name.value;
|
|
49
|
+
let l = te(
|
|
50
|
+
o.directives ?? [],
|
|
51
|
+
r,
|
|
51
52
|
void 0,
|
|
52
53
|
a
|
|
53
54
|
);
|
|
54
|
-
k(l, "node") || (l = [...l,
|
|
55
|
-
const
|
|
56
|
-
k(l, "mutation") || (t ?
|
|
55
|
+
k(l, "node") || (l = [...l, I("node")]);
|
|
56
|
+
const f = t?.mutations.get(r);
|
|
57
|
+
k(l, "mutation") || (t ? f && f.size > 0 && (l = [
|
|
57
58
|
...l,
|
|
58
|
-
|
|
59
|
-
operations:
|
|
59
|
+
I("mutation", {
|
|
60
|
+
operations: F([...f].sort())
|
|
60
61
|
})
|
|
61
|
-
]) : (l = [...l,
|
|
62
|
-
`${
|
|
62
|
+
]) : (l = [...l, I("mutation")], a.push(
|
|
63
|
+
`${r}: @mutation added (@neo4j/graphql generates mutations for every type); remove it or narrow its operations`
|
|
63
64
|
)));
|
|
64
|
-
const m = (
|
|
65
|
+
const m = (o.fields ?? []).filter((v) => k(v.directives, "id"));
|
|
65
66
|
m.length === 0 ? a.push(
|
|
66
|
-
`${
|
|
67
|
-
) : m.length > 1 && a.push(`${
|
|
68
|
-
const h = (
|
|
69
|
-
(v) =>
|
|
67
|
+
`${r}: no @id field; add a required @key field (the sort tie-breaker and mutation address)`
|
|
68
|
+
) : m.length > 1 && a.push(`${r}: several @id fields; keep one as the @key`);
|
|
69
|
+
const h = (o.fields ?? []).map(
|
|
70
|
+
(v) => Le(v, r, t, a)
|
|
70
71
|
);
|
|
71
|
-
return { ...
|
|
72
|
+
return { ...o, directives: l, fields: h };
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
|
-
return { typeDefs:
|
|
75
|
+
return { typeDefs: Z(u), todos: a };
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
let e =
|
|
77
|
+
function Le(n, s, i, a) {
|
|
78
|
+
let e = te(
|
|
78
79
|
n.directives ?? [],
|
|
79
80
|
s,
|
|
80
81
|
n.name.value,
|
|
81
82
|
a
|
|
82
83
|
);
|
|
83
|
-
e.find((
|
|
84
|
-
(
|
|
85
|
-
), e.push(
|
|
86
|
-
const t =
|
|
84
|
+
e.find((u) => u.name.value === "id") && (e = e.filter(
|
|
85
|
+
(u) => u.name.value !== "id" && u.name.value !== "unique"
|
|
86
|
+
), e.push(I("key", { generate: se(!0) })));
|
|
87
|
+
const t = i?.filters.get(s)?.get(n.name.value);
|
|
87
88
|
return t && t.size > 0 && !k(e, "filterable") && e.push(
|
|
88
|
-
k(e, "relationship") ?
|
|
89
|
-
),
|
|
89
|
+
k(e, "relationship") ? I("filterable") : I("filterable", { byValue: F([...t].sort()) })
|
|
90
|
+
), i?.sorts.get(s)?.has(n.name.value) && !k(e, "sortable") && e.push(I("sortable")), { ...n, directives: e };
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
-
const e =
|
|
92
|
+
function te(n, s, i, a) {
|
|
93
|
+
const e = i ? `${s}.${i}` : s, c = [];
|
|
93
94
|
for (const t of n) {
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
a.push(`${e}: ${
|
|
95
|
+
const u = t.name.value;
|
|
96
|
+
if (u in W) {
|
|
97
|
+
a.push(`${e}: ${W[u]}`);
|
|
97
98
|
continue;
|
|
98
99
|
}
|
|
99
|
-
if (
|
|
100
|
+
if (u === "key" && !i) {
|
|
100
101
|
a.push(`${e}: federation @key(fields:) is not supported`);
|
|
101
102
|
continue;
|
|
102
103
|
}
|
|
103
|
-
if (
|
|
104
|
-
|
|
104
|
+
if (u === "unique") {
|
|
105
|
+
c.push(I("unique"));
|
|
105
106
|
continue;
|
|
106
107
|
}
|
|
107
|
-
if (
|
|
108
|
-
|
|
108
|
+
if (u === "relationship") {
|
|
109
|
+
c.push(Ae(t, e, a));
|
|
109
110
|
continue;
|
|
110
111
|
}
|
|
111
|
-
if (
|
|
112
|
-
|
|
112
|
+
if (u === "fulltext") {
|
|
113
|
+
c.push(xe(t, "indexes", "indexName", "name"));
|
|
113
114
|
continue;
|
|
114
115
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
116
|
+
if (u === "subscription") {
|
|
117
|
+
c.push(qe(t, e, a));
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
|
-
(
|
|
120
|
-
`${e}: check the @${
|
|
121
|
-
),
|
|
120
|
+
(u === "authorization" || u === "authentication") && a.push(
|
|
121
|
+
`${e}: check the @${u} rule's filters: operators are written { field: { eq: ... } } here`
|
|
122
|
+
), c.push(t);
|
|
122
123
|
}
|
|
123
|
-
return
|
|
124
|
+
return c;
|
|
124
125
|
}
|
|
125
|
-
function
|
|
126
|
+
function Ae(n, s, i) {
|
|
126
127
|
const a = [];
|
|
127
128
|
for (const e of n.arguments ?? []) {
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
e.value.value.includes("UNDIRECTED") && a.push(
|
|
129
|
+
const c = e.name.value;
|
|
130
|
+
if (c === "queryDirection" && e.value.kind === p.ENUM) {
|
|
131
|
+
e.value.value.includes("UNDIRECTED") && a.push(q("queryDirection", ne("UNDIRECTED")));
|
|
131
132
|
continue;
|
|
132
133
|
}
|
|
133
|
-
if (
|
|
134
|
+
if (c === "nestedOperations" && e.value.kind === p.LIST) {
|
|
134
135
|
const t = e.value.values.filter(
|
|
135
|
-
(
|
|
136
|
+
(u) => u.kind === p.ENUM && u.value !== "CONNECT_OR_CREATE"
|
|
136
137
|
);
|
|
137
|
-
t.length < e.value.values.length &&
|
|
138
|
+
t.length < e.value.values.length && i.push(`${s}: connectOrCreate is not supported; use upsert`), a.push(q("nestedOperations", { kind: p.LIST, values: t }));
|
|
138
139
|
continue;
|
|
139
140
|
}
|
|
140
141
|
a.push(e);
|
|
141
142
|
}
|
|
142
143
|
return { ...n, arguments: a };
|
|
143
144
|
}
|
|
144
|
-
function
|
|
145
|
+
function qe(n, s, i) {
|
|
145
146
|
const a = n.arguments?.find((t) => t.name.value === "events")?.value;
|
|
146
147
|
if (!a || a.kind !== p.LIST) return n;
|
|
147
148
|
const e = /* @__PURE__ */ new Set();
|
|
148
|
-
let
|
|
149
|
+
let c = !1;
|
|
149
150
|
for (const t of a.values)
|
|
150
|
-
t.kind === p.ENUM && (t.value.startsWith("CREATED") && !t.value.includes("RELATIONSHIP") ? e.add("CREATE") : t.value.startsWith("UPDATED") ? e.add("UPDATE") : t.value.startsWith("DELETED") && !t.value.includes("RELATIONSHIP") ? e.add("DELETE") : t.value.includes("RELATIONSHIP") && (
|
|
151
|
-
return
|
|
151
|
+
t.kind === p.ENUM && (t.value.startsWith("CREATED") && !t.value.includes("RELATIONSHIP") ? e.add("CREATE") : t.value.startsWith("UPDATED") ? e.add("UPDATE") : t.value.startsWith("DELETED") && !t.value.includes("RELATIONSHIP") ? e.add("DELETE") : t.value.includes("RELATIONSHIP") && (c = !0));
|
|
152
|
+
return i.push(
|
|
152
153
|
`${s}: subscriptions see writes made through this library (or the engine change feed), not CDC`
|
|
153
|
-
),
|
|
154
|
-
operations:
|
|
155
|
-
...
|
|
154
|
+
), I("subscription", {
|
|
155
|
+
operations: F([...e].sort()),
|
|
156
|
+
...c ? { relationships: se(!0) } : {}
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
159
|
+
function je(n, s) {
|
|
160
|
+
const i = {
|
|
160
161
|
filters: /* @__PURE__ */ new Map(),
|
|
161
162
|
sorts: /* @__PURE__ */ new Map(),
|
|
162
163
|
mutations: /* @__PURE__ */ new Map()
|
|
163
164
|
}, a = /* @__PURE__ */ new Map();
|
|
164
|
-
for (const
|
|
165
|
-
a.set(
|
|
166
|
-
const e = new Map(s.map((
|
|
167
|
-
const m =
|
|
168
|
-
h.add(
|
|
169
|
-
}, t = (
|
|
165
|
+
for (const r of s)
|
|
166
|
+
a.set(K(r.name.value), r), a.set(Ce(r.name.value), r);
|
|
167
|
+
const e = new Map(s.map((r) => [r.name.value, r])), c = (r, l, f) => {
|
|
168
|
+
const m = i.filters.get(r) ?? /* @__PURE__ */ new Map(), h = m.get(l) ?? /* @__PURE__ */ new Set();
|
|
169
|
+
h.add(f), m.set(l, h), i.filters.set(r, m);
|
|
170
|
+
}, t = (r, l) => {
|
|
170
171
|
if (l.kind === p.OBJECT)
|
|
171
|
-
for (const
|
|
172
|
-
const m =
|
|
172
|
+
for (const f of l.fields) {
|
|
173
|
+
const m = f.name.value;
|
|
173
174
|
if (m === "AND" || m === "OR") {
|
|
174
|
-
if (
|
|
175
|
-
for (const w of
|
|
175
|
+
if (f.value.kind === p.LIST)
|
|
176
|
+
for (const w of f.value.values) t(r, w);
|
|
176
177
|
continue;
|
|
177
178
|
}
|
|
178
179
|
if (m === "NOT") {
|
|
179
|
-
t(
|
|
180
|
+
t(r, f.value);
|
|
180
181
|
continue;
|
|
181
182
|
}
|
|
182
183
|
const h = /^(.+)_(SOME|ALL|NONE|SINGLE)$/.exec(m);
|
|
183
184
|
if (h) {
|
|
184
|
-
const w =
|
|
185
|
-
w &&
|
|
185
|
+
const w = r.fields?.find((D) => D.name.value === h[1]), y = w && e.get(z(w));
|
|
186
|
+
w && y && (c(r.name.value, h[1], "EQ"), t(y, f.value));
|
|
186
187
|
continue;
|
|
187
188
|
}
|
|
188
|
-
const v =
|
|
189
|
+
const v = ke.find(([w]) => m.endsWith(w)), b = v ? m.slice(0, -v[0].length) : m, g = r.fields?.find((w) => w.name.value === b);
|
|
189
190
|
if (!g) continue;
|
|
190
|
-
const N = e.get(
|
|
191
|
+
const N = e.get(z(g));
|
|
191
192
|
if (N) {
|
|
192
|
-
if (
|
|
193
|
-
for (const w of
|
|
194
|
-
t(N,
|
|
193
|
+
if (c(r.name.value, b, "EQ"), f.value.kind === p.OBJECT) {
|
|
194
|
+
for (const w of f.value.fields) t(N, w.value);
|
|
195
|
+
t(N, f.value);
|
|
195
196
|
}
|
|
196
197
|
continue;
|
|
197
198
|
}
|
|
198
|
-
if (v)
|
|
199
|
-
else if (
|
|
200
|
-
for (const w of
|
|
201
|
-
const
|
|
202
|
-
|
|
199
|
+
if (v) c(r.name.value, b, v[1]);
|
|
200
|
+
else if (f.value.kind === p.OBJECT)
|
|
201
|
+
for (const w of f.value.fields) {
|
|
202
|
+
const y = Oe[w.name.value];
|
|
203
|
+
y && c(r.name.value, b, y);
|
|
203
204
|
}
|
|
204
|
-
else
|
|
205
|
+
else c(r.name.value, b, "EQ");
|
|
205
206
|
}
|
|
206
|
-
},
|
|
207
|
-
for (const
|
|
208
|
-
if (
|
|
209
|
-
const m =
|
|
207
|
+
}, u = (r, l) => {
|
|
208
|
+
for (const f of r?.selections ?? []) {
|
|
209
|
+
if (f.kind !== p.FIELD) continue;
|
|
210
|
+
const m = f.name.value;
|
|
210
211
|
if (l) {
|
|
211
|
-
const h = /^(create|update|delete|upsert)(.+)$/.exec(m), v = m.replace(/(Connection|Aggregate)$/, ""),
|
|
212
|
-
if (
|
|
213
|
-
const g =
|
|
214
|
-
N === "UPSERT" ? (g.add("CREATE"), g.add("UPDATE")) : g.add(N),
|
|
212
|
+
const h = /^(create|update|delete|upsert)(.+)$/.exec(m), v = m.replace(/(Connection|Aggregate)$/, ""), b = a.get(v) ?? (h ? a.get(ae(h[2])) : void 0);
|
|
213
|
+
if (b && h) {
|
|
214
|
+
const g = i.mutations.get(b.name.value) ?? /* @__PURE__ */ new Set(), N = h[1].toUpperCase();
|
|
215
|
+
N === "UPSERT" ? (g.add("CREATE"), g.add("UPDATE")) : g.add(N), i.mutations.set(b.name.value, g);
|
|
215
216
|
}
|
|
216
|
-
if (
|
|
217
|
-
for (const g of
|
|
217
|
+
if (b)
|
|
218
|
+
for (const g of f.arguments ?? []) o(b, g);
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
+
u(f.selectionSet, !1);
|
|
220
221
|
}
|
|
221
|
-
},
|
|
222
|
-
if (l.name.value === "where" && t(
|
|
223
|
-
const
|
|
222
|
+
}, o = (r, l) => {
|
|
223
|
+
if (l.name.value === "where" && t(r, l.value), l.name.value === "sort" || l.name.value === "options") {
|
|
224
|
+
const f = i.sorts.get(r.name.value) ?? /* @__PURE__ */ new Set(), m = (h) => {
|
|
224
225
|
if (h.kind === p.LIST) h.values.forEach(m);
|
|
225
226
|
else if (h.kind === p.OBJECT)
|
|
226
227
|
for (const v of h.fields)
|
|
227
|
-
v.name.value === "sort" ? m(v.value) : v.value.kind === p.ENUM &&
|
|
228
|
+
v.name.value === "sort" ? m(v.value) : v.value.kind === p.ENUM && f.add(v.name.value);
|
|
228
229
|
};
|
|
229
|
-
m(l.value),
|
|
230
|
+
m(l.value), i.sorts.set(r.name.value, f);
|
|
230
231
|
}
|
|
231
232
|
};
|
|
232
|
-
for (const
|
|
233
|
-
for (const l of
|
|
234
|
-
l.kind === p.OPERATION_DEFINITION &&
|
|
235
|
-
return
|
|
233
|
+
for (const r of n)
|
|
234
|
+
for (const l of r.definitions)
|
|
235
|
+
l.kind === p.OPERATION_DEFINITION && u(l.selectionSet, !0);
|
|
236
|
+
return i;
|
|
236
237
|
}
|
|
237
|
-
function
|
|
238
|
+
function z(n) {
|
|
238
239
|
let s = n.type;
|
|
239
240
|
for (; s.kind !== p.NAMED_TYPE; ) s = s.type;
|
|
240
241
|
return s.name.value;
|
|
241
242
|
}
|
|
242
243
|
function k(n, s) {
|
|
243
|
-
return (n ?? []).some((
|
|
244
|
+
return (n ?? []).some((i) => i.name.value === s);
|
|
244
245
|
}
|
|
245
|
-
function
|
|
246
|
+
function I(n, s = {}) {
|
|
246
247
|
return {
|
|
247
248
|
kind: p.DIRECTIVE,
|
|
248
249
|
name: { kind: p.NAME, value: n },
|
|
249
|
-
arguments: Object.entries(s).map(([
|
|
250
|
+
arguments: Object.entries(s).map(([i, a]) => q(i, a))
|
|
250
251
|
};
|
|
251
252
|
}
|
|
252
|
-
function
|
|
253
|
+
function q(n, s) {
|
|
253
254
|
return { kind: p.ARGUMENT, name: { kind: p.NAME, value: n }, value: s };
|
|
254
255
|
}
|
|
255
|
-
const
|
|
256
|
+
const ne = (n) => ({
|
|
256
257
|
kind: p.ENUM,
|
|
257
258
|
value: n
|
|
258
|
-
}),
|
|
259
|
+
}), se = (n) => ({
|
|
259
260
|
kind: p.BOOLEAN,
|
|
260
261
|
value: n
|
|
261
|
-
}),
|
|
262
|
+
}), F = (n) => ({
|
|
262
263
|
kind: p.LIST,
|
|
263
|
-
values: n.map(
|
|
264
|
+
values: n.map(ne)
|
|
264
265
|
});
|
|
265
|
-
function
|
|
266
|
+
function xe(n, s, i, a) {
|
|
266
267
|
return {
|
|
267
268
|
...n,
|
|
268
269
|
arguments: (n.arguments ?? []).map(
|
|
269
|
-
(e) => e.name.value === s && e.value.kind === p.LIST ?
|
|
270
|
+
(e) => e.name.value === s && e.value.kind === p.LIST ? q(s, {
|
|
270
271
|
kind: p.LIST,
|
|
271
272
|
values: e.value.values.map(
|
|
272
|
-
(
|
|
273
|
-
...
|
|
274
|
-
fields:
|
|
275
|
-
(t) => t.name.value ===
|
|
273
|
+
(c) => c.kind === p.OBJECT ? {
|
|
274
|
+
...c,
|
|
275
|
+
fields: c.fields.map(
|
|
276
|
+
(t) => t.name.value === i ? { ...t, name: { kind: p.NAME, value: a } } : t
|
|
276
277
|
)
|
|
277
|
-
} :
|
|
278
|
+
} : c
|
|
278
279
|
)
|
|
279
280
|
}) : e
|
|
280
281
|
)
|
|
281
282
|
};
|
|
282
283
|
}
|
|
283
|
-
const
|
|
284
|
+
const _e = {
|
|
284
285
|
person: "people",
|
|
285
286
|
man: "men",
|
|
286
287
|
woman: "women",
|
|
@@ -290,17 +291,17 @@ const Le = {
|
|
|
290
291
|
foot: "feet",
|
|
291
292
|
tooth: "teeth"
|
|
292
293
|
};
|
|
293
|
-
function
|
|
294
|
-
const s =
|
|
295
|
-
for (const [a, e] of Object.entries(
|
|
296
|
-
if (
|
|
294
|
+
function Ce(n) {
|
|
295
|
+
const s = ae(n), i = s.toLowerCase();
|
|
296
|
+
for (const [a, e] of Object.entries(_e))
|
|
297
|
+
if (i.endsWith(a))
|
|
297
298
|
return s.slice(0, s.length - a.length) + e;
|
|
298
|
-
return
|
|
299
|
+
return K(n);
|
|
299
300
|
}
|
|
300
|
-
function
|
|
301
|
+
function ae(n) {
|
|
301
302
|
return n.charAt(0).toLowerCase() + n.slice(1);
|
|
302
303
|
}
|
|
303
|
-
const
|
|
304
|
+
const H = `lora-graphql <command>
|
|
304
305
|
|
|
305
306
|
print <schema.graphql> the public SDL clients see
|
|
306
307
|
directives the directive definitions, for editors
|
|
@@ -323,55 +324,68 @@ const z = `lora-graphql <command>
|
|
|
323
324
|
rewrite an @neo4j/graphql SDL; TODOs for
|
|
324
325
|
what has no equivalent
|
|
325
326
|
diff <old.graphql> <new.graphql> [--allow-breaking] [--json]
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
diff --base <git-ref> <file|dir>... [--allow-breaking] [--json]
|
|
328
|
+
database statements and API changes; exit 1
|
|
329
|
+
on a breaking change or a destructive statement
|
|
330
|
+
(--base: the SDL files at a git ref against the
|
|
331
|
+
working tree, each side concatenated)`;
|
|
332
|
+
async function Me(n, s = Ye) {
|
|
333
|
+
const [i, ...a] = n, e = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), t = [], u = [];
|
|
334
|
+
for (let o = 0; o < a.length; o++) {
|
|
335
|
+
const r = a[o];
|
|
336
|
+
r === "--operations" ? u.push(a[++o] ?? "") : Re.has(r) ? c.set(r, a[++o] ?? "") : r.startsWith("--") ? e.add(r) : t.push(r);
|
|
332
337
|
}
|
|
333
338
|
try {
|
|
334
|
-
switch (
|
|
339
|
+
switch (i) {
|
|
335
340
|
case "print":
|
|
336
|
-
return await
|
|
341
|
+
return await Pe(S(t, 1), s);
|
|
337
342
|
case "directives":
|
|
338
|
-
return s.out(
|
|
343
|
+
return s.out(be.trim()), 0;
|
|
339
344
|
case "access":
|
|
340
|
-
return await
|
|
345
|
+
return await Fe(S(t, 1), e.has("--json"), s);
|
|
341
346
|
case "requirements":
|
|
342
|
-
return await
|
|
347
|
+
return await Ue(S(t, 1), e.has("--ddl"), s);
|
|
343
348
|
case "check":
|
|
344
|
-
return await
|
|
349
|
+
return await Je(S(t, 1), u, e, c, s);
|
|
345
350
|
case "compile":
|
|
346
|
-
return await
|
|
351
|
+
return await Ge(S(t, 1), u, c, s);
|
|
347
352
|
case "analyze":
|
|
348
|
-
return await
|
|
353
|
+
return await We(S(t, 1), c, s);
|
|
349
354
|
case "migrate": {
|
|
350
|
-
const [
|
|
351
|
-
if (
|
|
355
|
+
const [o, r] = S(t, 2);
|
|
356
|
+
if (o !== "neo4j") throw new L("migrate supports neo4j");
|
|
352
357
|
const l = [];
|
|
353
|
-
for (const m of
|
|
354
|
-
for (const h of await
|
|
355
|
-
const
|
|
356
|
-
for (const m of
|
|
357
|
-
return
|
|
358
|
+
for (const m of u)
|
|
359
|
+
for (const h of await A(m)) l.push(j(h.source));
|
|
360
|
+
const f = De(await E(r), l);
|
|
361
|
+
for (const m of f.todos) s.out(`# TODO(migrate): ${m}`);
|
|
362
|
+
return f.todos.length > 0 && s.out(""), s.out(f.typeDefs), 0;
|
|
358
363
|
}
|
|
359
364
|
case "diff": {
|
|
360
|
-
const
|
|
361
|
-
|
|
365
|
+
const o = c.get("--base");
|
|
366
|
+
if (o !== void 0) {
|
|
367
|
+
if (!o) throw new L("--base takes a git ref");
|
|
368
|
+
const f = S(t, 1), m = await Ve(o, f);
|
|
369
|
+
return m === void 0 ? (s.out(
|
|
370
|
+
`${o} has none of ${f.join(", ")}; nothing to compare`
|
|
371
|
+
), 0) : V(m, await Qe(f), e, s);
|
|
372
|
+
}
|
|
373
|
+
const [r, l] = S(t, 2);
|
|
374
|
+
return V(await E(r), await E(l), e, s);
|
|
362
375
|
}
|
|
363
376
|
default:
|
|
364
|
-
return s.err(
|
|
377
|
+
return s.err(H), 2;
|
|
365
378
|
}
|
|
366
|
-
} catch (
|
|
367
|
-
return
|
|
379
|
+
} catch (o) {
|
|
380
|
+
return o instanceof L ? (s.err(`${o.message}
|
|
368
381
|
|
|
369
|
-
${
|
|
382
|
+
${H}`), 2) : o instanceof Te ? (s.err(o.message), 1) : (s.err(o instanceof Error ? o.message : String(o)), 1);
|
|
370
383
|
}
|
|
371
384
|
}
|
|
372
385
|
class L extends Error {
|
|
373
386
|
}
|
|
374
|
-
const
|
|
387
|
+
const Re = /* @__PURE__ */ new Set([
|
|
388
|
+
"--base",
|
|
375
389
|
"--out",
|
|
376
390
|
"--variables",
|
|
377
391
|
"--context",
|
|
@@ -381,52 +395,52 @@ const je = /* @__PURE__ */ new Set([
|
|
|
381
395
|
"--name",
|
|
382
396
|
"--sample"
|
|
383
397
|
]);
|
|
384
|
-
function
|
|
398
|
+
function S(n, s) {
|
|
385
399
|
if (n.length < s)
|
|
386
400
|
throw new L(`expected ${s} file argument(s)`);
|
|
387
401
|
return n;
|
|
388
402
|
}
|
|
389
|
-
const E = (n) =>
|
|
403
|
+
const E = (n) => ce(n, "utf8");
|
|
390
404
|
function P(n) {
|
|
391
405
|
const s = {
|
|
392
406
|
run: () => Promise.reject(new Error("no database"))
|
|
393
407
|
};
|
|
394
|
-
return new
|
|
408
|
+
return new R({ typeDefs: n, driver: s });
|
|
395
409
|
}
|
|
396
|
-
async function
|
|
410
|
+
async function Fe([n], s, i) {
|
|
397
411
|
const a = P(await E(n)).accessMatrix();
|
|
398
412
|
if (s)
|
|
399
|
-
return
|
|
413
|
+
return i.out(JSON.stringify(a, null, 2)), 0;
|
|
400
414
|
const e = a.map((t) => [
|
|
401
415
|
t.field ? `${t.type}.${t.field}` : t.type,
|
|
402
416
|
t.operation,
|
|
403
417
|
t.principal,
|
|
404
418
|
t.verdict,
|
|
405
419
|
t.by.join(", ")
|
|
406
|
-
]),
|
|
407
|
-
(t) => Math.max(...e.map((
|
|
420
|
+
]), c = [0, 1, 2, 3].map(
|
|
421
|
+
(t) => Math.max(...e.map((u) => u[t].length), 0)
|
|
408
422
|
);
|
|
409
423
|
for (const t of e)
|
|
410
|
-
|
|
411
|
-
t.map((
|
|
424
|
+
i.out(
|
|
425
|
+
t.map((u, o) => o < 4 ? u.padEnd(c[o]) : u).join(" ").trimEnd()
|
|
412
426
|
);
|
|
413
427
|
return 0;
|
|
414
428
|
}
|
|
415
|
-
async function
|
|
429
|
+
async function Pe([n], s) {
|
|
416
430
|
return s.out(P(await E(n)).printPublicSchema()), 0;
|
|
417
431
|
}
|
|
418
|
-
async function
|
|
419
|
-
const a =
|
|
420
|
-
for (const e of
|
|
421
|
-
|
|
422
|
-
s ? `${
|
|
432
|
+
async function Ue([n], s, i) {
|
|
433
|
+
const a = Ne(await E(n));
|
|
434
|
+
for (const e of ye(a))
|
|
435
|
+
i.out(
|
|
436
|
+
s ? `${Se(e)};` : `${ee(e)}, because ${e.reason}`
|
|
423
437
|
);
|
|
424
438
|
return 0;
|
|
425
439
|
}
|
|
426
|
-
async function
|
|
440
|
+
async function oe(n, s) {
|
|
427
441
|
try {
|
|
428
|
-
const { createDatabase:
|
|
429
|
-
return
|
|
442
|
+
const { createDatabase: i } = await import("@loradb/lora-node");
|
|
443
|
+
return i;
|
|
430
444
|
} catch {
|
|
431
445
|
n.err(
|
|
432
446
|
`${s} needs @loradb/lora-node: npm install --save-dev @loradb/lora-node`
|
|
@@ -434,183 +448,183 @@ async function se(n, s) {
|
|
|
434
448
|
return;
|
|
435
449
|
}
|
|
436
450
|
}
|
|
437
|
-
async function
|
|
438
|
-
const
|
|
439
|
-
if (!
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
), l = new
|
|
451
|
+
async function Je([n], s, i, a, e) {
|
|
452
|
+
const c = i.has("--json"), t = await E(n), u = await oe(e, "check");
|
|
453
|
+
if (!u) return 1;
|
|
454
|
+
const o = a.get("--database"), r = await u(
|
|
455
|
+
o ? a.get("--name") ?? "app" : void 0,
|
|
456
|
+
o ? { databaseDir: o } : {}
|
|
457
|
+
), l = new R({
|
|
444
458
|
typeDefs: t,
|
|
445
|
-
driver:
|
|
459
|
+
driver: X(r)
|
|
446
460
|
});
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
for (const
|
|
450
|
-
for (const
|
|
451
|
-
for (const
|
|
452
|
-
const U =
|
|
461
|
+
o || await l.assertSchema({ create: !0 });
|
|
462
|
+
const f = l.getSchema(), m = a.has("--variables") ? JSON.parse(await E(a.get("--variables"))) : {}, h = a.has("--context") ? JSON.parse(await E(a.get("--context"))) : {}, v = [];
|
|
463
|
+
for (const d of s)
|
|
464
|
+
for (const T of await A(d))
|
|
465
|
+
for (const $ of ze(f, T.path, T.source)) {
|
|
466
|
+
const U = $.name.split("#")[1] ?? "", J = m[$.name] ?? m[U], B = h[$.name] ?? h[U] ?? h["*"];
|
|
453
467
|
v.push({
|
|
454
|
-
|
|
455
|
-
...
|
|
456
|
-
...
|
|
468
|
+
...$,
|
|
469
|
+
...J ? { variables: J } : {},
|
|
470
|
+
...B !== void 0 ? { context: B } : {}
|
|
457
471
|
});
|
|
458
472
|
}
|
|
459
|
-
const
|
|
473
|
+
const b = a.has("--row-budget") ? Number(a.get("--row-budget")) : void 0, g = await l.check({
|
|
460
474
|
operations: v,
|
|
461
|
-
...
|
|
475
|
+
...b !== void 0 ? { rowBudget: b } : {}
|
|
462
476
|
}), N = a.get("--baseline"), w = {};
|
|
463
|
-
for (const
|
|
464
|
-
w[`${
|
|
465
|
-
const
|
|
477
|
+
for (const d of g.plans)
|
|
478
|
+
w[`${d.operation} › ${d.field}`] = d.reports.map((T) => T.operators);
|
|
479
|
+
const y = [];
|
|
466
480
|
if (N) {
|
|
467
|
-
let
|
|
481
|
+
let d;
|
|
468
482
|
try {
|
|
469
|
-
|
|
483
|
+
d = JSON.parse(await E(N));
|
|
470
484
|
} catch {
|
|
471
|
-
|
|
485
|
+
d = void 0;
|
|
472
486
|
}
|
|
473
|
-
if (
|
|
487
|
+
if (i.has("--update-baseline") || !d)
|
|
474
488
|
await _(N, JSON.stringify(w, null, 2) + `
|
|
475
489
|
`);
|
|
476
490
|
else
|
|
477
|
-
for (const
|
|
478
|
-
...Object.keys(
|
|
491
|
+
for (const T of /* @__PURE__ */ new Set([
|
|
492
|
+
...Object.keys(d),
|
|
479
493
|
...Object.keys(w)
|
|
480
494
|
]))
|
|
481
|
-
JSON.stringify(
|
|
495
|
+
JSON.stringify(d[T]) !== JSON.stringify(w[T]) && y.push(T);
|
|
482
496
|
}
|
|
483
|
-
const
|
|
484
|
-
if (
|
|
485
|
-
return e.out(JSON.stringify({ ...g, ok:
|
|
486
|
-
for (const
|
|
487
|
-
for (const
|
|
488
|
-
for (const
|
|
497
|
+
const D = g.ok && y.length === 0;
|
|
498
|
+
if (c)
|
|
499
|
+
return e.out(JSON.stringify({ ...g, ok: D, planChanges: y }, null, 2)), D ? 0 : 1;
|
|
500
|
+
for (const d of g.warnings) e.out(`warning ${x(d)}`);
|
|
501
|
+
for (const d of g.lint) e.out(`lint ${x(d)}`);
|
|
502
|
+
for (const d of g.unused)
|
|
489
503
|
e.out(
|
|
490
|
-
`unused ${
|
|
504
|
+
`unused ${d.type} index ${d.name} on :${d.labels.join(":")}(${d.properties.join(", ")})`
|
|
491
505
|
);
|
|
492
|
-
for (const
|
|
493
|
-
for (const
|
|
494
|
-
e.out(`error missing ${
|
|
495
|
-
for (const
|
|
496
|
-
e.out(`error ${
|
|
497
|
-
for (const
|
|
498
|
-
e.out(`error ${
|
|
499
|
-
for (const
|
|
500
|
-
for (const
|
|
501
|
-
for (const
|
|
502
|
-
e.out(`error ${
|
|
503
|
-
for (const
|
|
504
|
-
e.out(`lint ${
|
|
506
|
+
for (const d of g.security) e.out(`error ${x(d)}`);
|
|
507
|
+
for (const d of g.missing)
|
|
508
|
+
e.out(`error missing ${ee(d)}`);
|
|
509
|
+
for (const d of g.cypher)
|
|
510
|
+
e.out(`error ${d.type}.${d.field}: ${d.message}`);
|
|
511
|
+
for (const d of g.errors)
|
|
512
|
+
e.out(`error ${d.operation}: ${d.message}`);
|
|
513
|
+
for (const d of g.plans)
|
|
514
|
+
for (const T of d.reports) {
|
|
515
|
+
for (const $ of T.findings)
|
|
516
|
+
e.out(`error ${d.operation} › ${d.field}: ${$.message}`);
|
|
517
|
+
for (const $ of T.notes)
|
|
518
|
+
e.out(`lint ${d.operation} › ${d.field}: ${$.message}`);
|
|
505
519
|
}
|
|
506
|
-
for (const
|
|
520
|
+
for (const d of y)
|
|
507
521
|
e.out(
|
|
508
|
-
`error ${
|
|
522
|
+
`error ${d}: the plan differs from the baseline (--update-baseline to accept)`
|
|
509
523
|
);
|
|
510
|
-
const
|
|
524
|
+
const ie = g.plans.length;
|
|
511
525
|
return e.out(
|
|
512
|
-
|
|
513
|
-
),
|
|
526
|
+
D ? `ok ${ie} root field(s) in ${v.length} operation(s) seek as expected` : "failed"
|
|
527
|
+
), D ? 0 : 1;
|
|
514
528
|
}
|
|
515
|
-
async function
|
|
529
|
+
async function Be(n) {
|
|
516
530
|
const s = {};
|
|
517
|
-
for (const
|
|
518
|
-
if ((await
|
|
531
|
+
for (const i of n) {
|
|
532
|
+
if ((await M(i)).isFile() && i.endsWith(".json")) {
|
|
519
533
|
Object.assign(
|
|
520
534
|
s,
|
|
521
|
-
JSON.parse(await E(
|
|
535
|
+
JSON.parse(await E(i))
|
|
522
536
|
);
|
|
523
537
|
continue;
|
|
524
538
|
}
|
|
525
|
-
for (const e of await
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
(
|
|
529
|
-
).map((
|
|
530
|
-
),
|
|
531
|
-
|
|
532
|
-
(
|
|
533
|
-
).forEach((
|
|
534
|
-
const l = `${
|
|
535
|
-
s[l] =
|
|
539
|
+
for (const e of await A(i)) {
|
|
540
|
+
const c = j(e.source), t = new Map(
|
|
541
|
+
c.definitions.filter(
|
|
542
|
+
(o) => o.kind === p.FRAGMENT_DEFINITION
|
|
543
|
+
).map((o) => [o.name.value, o])
|
|
544
|
+
), u = pe(process.cwd(), e.path);
|
|
545
|
+
c.definitions.filter(
|
|
546
|
+
(o) => o.kind === p.OPERATION_DEFINITION
|
|
547
|
+
).forEach((o, r) => {
|
|
548
|
+
const l = `${u}#${o.name?.value ?? r + 1}`;
|
|
549
|
+
s[l] = Z({
|
|
536
550
|
kind: p.DOCUMENT,
|
|
537
|
-
definitions: [
|
|
551
|
+
definitions: [o, ...Ie(o, t)]
|
|
538
552
|
});
|
|
539
553
|
});
|
|
540
554
|
}
|
|
541
555
|
}
|
|
542
556
|
return s;
|
|
543
557
|
}
|
|
544
|
-
async function
|
|
558
|
+
async function Ge([n], s, i, a) {
|
|
545
559
|
if (s.length === 0)
|
|
546
560
|
throw new L("compile needs --operations <file|dir>");
|
|
547
|
-
const e = P(await E(n)),
|
|
548
|
-
await
|
|
549
|
-
), t =
|
|
550
|
-
return await
|
|
551
|
-
|
|
552
|
-
JSON.stringify(
|
|
561
|
+
const e = P(await E(n)), c = e.buildManifest(
|
|
562
|
+
await Be(s)
|
|
563
|
+
), t = i.get("--out") ?? "lora-graphql";
|
|
564
|
+
return await le(t, { recursive: !0 }), await _(
|
|
565
|
+
O(t, "manifest.json"),
|
|
566
|
+
JSON.stringify(c) + `
|
|
553
567
|
`
|
|
554
568
|
), await _(
|
|
555
|
-
|
|
556
|
-
e.generateTypes(
|
|
569
|
+
O(t, "operations.d.ts"),
|
|
570
|
+
e.generateTypes(c)
|
|
557
571
|
), a.out(
|
|
558
|
-
`wrote ${Object.keys(
|
|
572
|
+
`wrote ${Object.keys(c.operations).length} operation(s) to ${O(t, "manifest.json")} and ${O(t, "operations.d.ts")}`
|
|
559
573
|
), 0;
|
|
560
574
|
}
|
|
561
|
-
async function
|
|
575
|
+
async function We([n], s, i) {
|
|
562
576
|
const a = s.get("--database");
|
|
563
577
|
if (!a) throw new L("analyze needs --database <dir>");
|
|
564
|
-
const e = await
|
|
578
|
+
const e = await oe(i, "analyze");
|
|
565
579
|
if (!e) return 1;
|
|
566
|
-
const
|
|
580
|
+
const c = await e(s.get("--name") ?? "app", {
|
|
567
581
|
databaseDir: a
|
|
568
|
-
}), t = new
|
|
582
|
+
}), t = new R({
|
|
569
583
|
typeDefs: await E(n),
|
|
570
|
-
driver:
|
|
571
|
-
}),
|
|
572
|
-
return
|
|
584
|
+
driver: X(c)
|
|
585
|
+
}), u = s.has("--sample") ? Number(s.get("--sample")) : void 0, o = await t.analyze(u !== void 0 ? { sample: u } : {});
|
|
586
|
+
return i.out(JSON.stringify(o, null, 2)), c.dispose?.(), 0;
|
|
573
587
|
}
|
|
574
|
-
async function
|
|
575
|
-
if ((await
|
|
576
|
-
const
|
|
577
|
-
for (const a of await
|
|
578
|
-
const e =
|
|
579
|
-
a.isDirectory() ?
|
|
588
|
+
async function A(n) {
|
|
589
|
+
if ((await M(n)).isFile()) return [{ path: n, source: await E(n) }];
|
|
590
|
+
const i = [];
|
|
591
|
+
for (const a of await ue(n, { withFileTypes: !0 })) {
|
|
592
|
+
const e = O(n, a.name);
|
|
593
|
+
a.isDirectory() ? i.push(...await A(e)) : /\.(graphql|gql)$/.test(a.name) && i.push({ path: e, source: await E(e) });
|
|
580
594
|
}
|
|
581
|
-
return
|
|
595
|
+
return i;
|
|
582
596
|
}
|
|
583
|
-
function
|
|
584
|
-
const a =
|
|
597
|
+
function ze(n, s, i) {
|
|
598
|
+
const a = j(i), e = new Map(
|
|
585
599
|
a.definitions.filter(
|
|
586
600
|
(t) => t.kind === p.FRAGMENT_DEFINITION
|
|
587
601
|
).map((t) => [t.name.value, t])
|
|
588
|
-
),
|
|
589
|
-
const
|
|
602
|
+
), c = (t) => {
|
|
603
|
+
const u = /* @__PURE__ */ new Map(), o = (r) => Y(r, {
|
|
590
604
|
FragmentSpread(l) {
|
|
591
|
-
const
|
|
592
|
-
|
|
605
|
+
const f = e.get(l.name.value);
|
|
606
|
+
f && !u.has(f.name.value) && (u.set(f.name.value, f), o(f));
|
|
593
607
|
}
|
|
594
608
|
});
|
|
595
|
-
return
|
|
609
|
+
return o(t), [...u.values()];
|
|
596
610
|
};
|
|
597
611
|
return a.definitions.filter(
|
|
598
612
|
(t) => t.kind === p.OPERATION_DEFINITION && t.operation === "query"
|
|
599
|
-
).map((t,
|
|
600
|
-
const
|
|
601
|
-
for (const
|
|
602
|
-
if (
|
|
603
|
-
const l =
|
|
604
|
-
l && (
|
|
613
|
+
).map((t, u) => {
|
|
614
|
+
const o = {};
|
|
615
|
+
for (const r of t.variableDefinitions ?? []) {
|
|
616
|
+
if (r.defaultValue || r.type.kind !== p.NON_NULL_TYPE) continue;
|
|
617
|
+
const l = me(n, r.type);
|
|
618
|
+
l && (o[r.variable.name.value] = C(l));
|
|
605
619
|
}
|
|
606
620
|
return {
|
|
607
|
-
name: `${s}${t.name ? `#${t.name.value}` : `#${
|
|
608
|
-
document: { kind: p.DOCUMENT, definitions: [t, ...
|
|
609
|
-
variables:
|
|
621
|
+
name: `${s}${t.name ? `#${t.name.value}` : `#${u + 1}`}`,
|
|
622
|
+
document: { kind: p.DOCUMENT, definitions: [t, ...c(t)] },
|
|
623
|
+
variables: o
|
|
610
624
|
};
|
|
611
625
|
});
|
|
612
626
|
}
|
|
613
|
-
const
|
|
627
|
+
const He = {
|
|
614
628
|
String: "x",
|
|
615
629
|
ID: "x",
|
|
616
630
|
Int: 1,
|
|
@@ -624,41 +638,90 @@ const Je = {
|
|
|
624
638
|
LocalDateTime: "2026-01-01T12:00:00",
|
|
625
639
|
Duration: "P1D"
|
|
626
640
|
};
|
|
627
|
-
function
|
|
628
|
-
const s =
|
|
629
|
-
if (
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
if (
|
|
641
|
+
function C(n) {
|
|
642
|
+
const s = G(n) ? n.ofType : n;
|
|
643
|
+
if (he(s)) return [C(s.ofType)];
|
|
644
|
+
const i = ge(s);
|
|
645
|
+
if (ve(i)) return i.getValues()[0]?.value;
|
|
646
|
+
if (we(i)) {
|
|
633
647
|
const a = {};
|
|
634
|
-
for (const e of Object.values(
|
|
635
|
-
|
|
648
|
+
for (const e of Object.values(i.getFields()))
|
|
649
|
+
G(e.type) && e.defaultValue === void 0 && (a[e.name] = C(e.type));
|
|
636
650
|
return a;
|
|
637
651
|
}
|
|
638
|
-
return
|
|
652
|
+
return He[i.name] ?? "x";
|
|
653
|
+
}
|
|
654
|
+
const Q = /\.(graphql|gql)$/;
|
|
655
|
+
async function Qe(n) {
|
|
656
|
+
const s = [];
|
|
657
|
+
for (const i of n) {
|
|
658
|
+
const a = await A(i);
|
|
659
|
+
a.sort((e, c) => e.path < c.path ? -1 : e.path > c.path ? 1 : 0), s.push(...a.map((e) => e.source));
|
|
660
|
+
}
|
|
661
|
+
return s.join(`
|
|
662
|
+
`);
|
|
663
|
+
}
|
|
664
|
+
async function Ve(n, s) {
|
|
665
|
+
const i = (c, ...t) => re("git", t, {
|
|
666
|
+
cwd: c,
|
|
667
|
+
encoding: "utf8",
|
|
668
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
669
|
+
maxBuffer: 67108864
|
|
670
|
+
}), a = [];
|
|
671
|
+
let e = !1;
|
|
672
|
+
for (const c of s) {
|
|
673
|
+
const t = await M(c).then(
|
|
674
|
+
(r) => r.isDirectory(),
|
|
675
|
+
() => !Q.test(c)
|
|
676
|
+
), u = t ? c : fe(c);
|
|
677
|
+
try {
|
|
678
|
+
i(u, "rev-parse", "--verify", "--quiet", `${n}^{commit}`);
|
|
679
|
+
} catch {
|
|
680
|
+
throw new Error(
|
|
681
|
+
`diff: ${n} is not a commit (fetch it, or pass another ref)`
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
if (!t) {
|
|
685
|
+
try {
|
|
686
|
+
a.push(i(u, "show", `${n}:./${de(c)}`)), e = !0;
|
|
687
|
+
} catch {
|
|
688
|
+
}
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
const o = i(u, "ls-tree", "-r", "--name-only", n, "--", ".").split(`
|
|
692
|
+
`).filter((r) => Q.test(r));
|
|
693
|
+
o.sort((r, l) => {
|
|
694
|
+
const f = O(c, r), m = O(c, l);
|
|
695
|
+
return f < m ? -1 : f > m ? 1 : 0;
|
|
696
|
+
});
|
|
697
|
+
for (const r of o)
|
|
698
|
+
a.push(i(u, "show", `${n}:./${r}`)), e = !0;
|
|
699
|
+
}
|
|
700
|
+
return e ? a.join(`
|
|
701
|
+
`) : void 0;
|
|
639
702
|
}
|
|
640
|
-
|
|
641
|
-
const e =
|
|
642
|
-
if (
|
|
643
|
-
return a.out(JSON.stringify(e, null, 2)),
|
|
703
|
+
function V(n, s, i, a) {
|
|
704
|
+
const e = Ee(n, s), c = e.api.breaking.length > 0, t = e.database.statements.some((o) => o.destructive), u = (c || t) && !i.has("--allow-breaking") ? 1 : 0;
|
|
705
|
+
if (i.has("--json"))
|
|
706
|
+
return a.out(JSON.stringify(e, null, 2)), u;
|
|
644
707
|
a.out("# Database"), e.database.statements.length === 0 && a.out("no changes");
|
|
645
|
-
for (const
|
|
646
|
-
a.out(`${
|
|
708
|
+
for (const o of e.database.statements)
|
|
709
|
+
a.out(`${o.destructive ? "// destructive: " : "// "}${o.reason}`), a.out(`${o.text};`);
|
|
647
710
|
a.out(`
|
|
648
|
-
# API`), !
|
|
649
|
-
for (const
|
|
650
|
-
for (const
|
|
651
|
-
for (const
|
|
652
|
-
return
|
|
711
|
+
# API`), !c && e.api.dangerous.length === 0 && a.out("no changes");
|
|
712
|
+
for (const o of e.api.breaking) a.out(`breaking ${o.description}`);
|
|
713
|
+
for (const o of e.api.dangerous) a.out(`dangerous ${o.description}`);
|
|
714
|
+
for (const o of e.notes) a.out(`note ${o}`);
|
|
715
|
+
return u;
|
|
653
716
|
}
|
|
654
|
-
const
|
|
717
|
+
const Ye = {
|
|
655
718
|
out: (n) => process.stdout.write(n + `
|
|
656
719
|
`),
|
|
657
720
|
err: (n) => process.stderr.write(n + `
|
|
658
721
|
`)
|
|
659
|
-
},
|
|
660
|
-
|
|
722
|
+
}, Ze = typeof process < "u" && process.argv[1] !== void 0 && /lora-graphql(\.js)?$|cli\.js$/.test(process.argv[1]);
|
|
723
|
+
Ze && Me(process.argv.slice(2)).then((n) => process.exit(n));
|
|
661
724
|
export {
|
|
662
|
-
|
|
725
|
+
Me as main
|
|
663
726
|
};
|
|
664
727
|
//# sourceMappingURL=cli.js.map
|