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