@loradb/lora-graphql 0.20.2 → 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/dist/cli.js CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { stat as H, readdir as oe, readFile as ie, mkdir as re, writeFile as _ } from "node:fs/promises";
3
- import { join as D, relative as ce } from "node:path";
4
- import { parse as q, Kind as p, visit as Q, print as V, typeFromAST as ue, isNonNullType as W, isListType as le, getNamedType as fe, isEnumType as de, isInputObjectType as pe } from "graphql";
5
- import { d as me } from "./diff-BO2igqdY.js";
6
- import { m as Y, d as he, M as ge, L as M, l as Z, f as C, o as K, b as ve, i as we, r as Ee, u as Te } from "./driver-XeJM24iP.js";
7
- const be = /* @__PURE__ */ new Set(["Query", "Mutation", "Subscription"]), B = {
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
- }, Ne = [
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
- ], Se = {
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 ye(n, s = []) {
42
- const o = q(n, { noLocation: !0 }), a = [], e = o.definitions.filter(
43
- (i) => i.kind === p.OBJECT_TYPE_DEFINITION && !be.has(i.name.value) && !k(i.directives, "relationshipProperties") && !k(i.directives, "jwt")
44
- ), u = new Set(e.map((i) => i.name.value)), t = s.length > 0 ? $e(s, e) : void 0, r = Q(o, {
45
- ObjectTypeDefinition(i) {
46
- if (!u.has(i.name.value)) return;
47
- const c = i.name.value;
48
- let l = X(
49
- i.directives ?? [],
50
- c,
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, y("node")]);
55
- const d = t?.mutations.get(c);
56
- k(l, "mutation") || (t ? d && d.size > 0 && (l = [
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
- y("mutation", {
59
- operations: R([...d].sort())
59
+ I("mutation", {
60
+ operations: F([...f].sort())
60
61
  })
61
- ]) : (l = [...l, y("mutation")], a.push(
62
- `${c}: @mutation added (@neo4j/graphql generates mutations for every type); remove it or narrow its operations`
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 = (i.fields ?? []).filter((v) => k(v.directives, "id"));
65
+ const m = (o.fields ?? []).filter((v) => k(v.directives, "id"));
65
66
  m.length === 0 ? a.push(
66
- `${c}: no @id field; add a required @key field (the sort tie-breaker and mutation address)`
67
- ) : m.length > 1 && a.push(`${c}: several @id fields; keep one as the @key`);
68
- const h = (i.fields ?? []).map(
69
- (v) => Ie(v, c, t, a)
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 { ...i, directives: l, fields: h };
72
+ return { ...o, directives: l, fields: h };
72
73
  }
73
74
  });
74
- return { typeDefs: V(r), todos: a };
75
+ return { typeDefs: Z(u), todos: a };
75
76
  }
76
- function Ie(n, s, o, a) {
77
- let e = X(
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((r) => r.name.value === "id") && (e = e.filter(
84
- (r) => r.name.value !== "id" && r.name.value !== "unique"
85
- ), e.push(y("key", { generate: te(!0) })));
86
- const t = o?.filters.get(s)?.get(n.name.value);
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") ? y("filterable") : y("filterable", { byValue: R([...t].sort()) })
89
- ), o?.sorts.get(s)?.has(n.name.value) && !k(e, "sortable") && e.push(y("sortable")), { ...n, directives: e };
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 X(n, s, o, a) {
92
- const e = o ? `${s}.${o}` : s, u = [];
92
+ function te(n, s, i, a) {
93
+ const e = i ? `${s}.${i}` : s, c = [];
93
94
  for (const t of n) {
94
- const r = t.name.value;
95
- if (r in B) {
96
- a.push(`${e}: ${B[r]}`);
95
+ const u = t.name.value;
96
+ if (u in W) {
97
+ a.push(`${e}: ${W[u]}`);
97
98
  continue;
98
99
  }
99
- if (r === "key" && !o) {
100
+ if (u === "key" && !i) {
100
101
  a.push(`${e}: federation @key(fields:) is not supported`);
101
102
  continue;
102
103
  }
103
- if (r === "unique") {
104
- u.push(y("unique"));
104
+ if (u === "unique") {
105
+ c.push(I("unique"));
105
106
  continue;
106
107
  }
107
- if (r === "relationship") {
108
- u.push(Oe(t, e, a));
108
+ if (u === "relationship") {
109
+ c.push(Ae(t, e, a));
109
110
  continue;
110
111
  }
111
- if (r === "fulltext") {
112
- u.push(De(t, "indexes", "indexName", "name"));
112
+ if (u === "fulltext") {
113
+ c.push(xe(t, "indexes", "indexName", "name"));
113
114
  continue;
114
115
  }
115
- if (r === "subscription") {
116
- u.push(ke(t, e, a));
116
+ if (u === "subscription") {
117
+ c.push(qe(t, e, a));
117
118
  continue;
118
119
  }
119
- (r === "authorization" || r === "authentication") && a.push(
120
- `${e}: check the @${r} rule's filters: operators are written { field: { eq: ... } } here`
121
- ), u.push(t);
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 u;
124
+ return c;
124
125
  }
125
- function Oe(n, s, o) {
126
+ function Ae(n, s, i) {
126
127
  const a = [];
127
128
  for (const e of n.arguments ?? []) {
128
- const u = e.name.value;
129
- if (u === "queryDirection" && e.value.kind === p.ENUM) {
130
- e.value.value.includes("UNDIRECTED") && a.push(A("queryDirection", ee("UNDIRECTED")));
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 (u === "nestedOperations" && e.value.kind === p.LIST) {
134
+ if (c === "nestedOperations" && e.value.kind === p.LIST) {
134
135
  const t = e.value.values.filter(
135
- (r) => r.kind === p.ENUM && r.value !== "CONNECT_OR_CREATE"
136
+ (u) => u.kind === p.ENUM && u.value !== "CONNECT_OR_CREATE"
136
137
  );
137
- t.length < e.value.values.length && o.push(`${s}: connectOrCreate is not supported; use upsert`), a.push(A("nestedOperations", { kind: p.LIST, values: t }));
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 ke(n, s, o) {
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 u = !1;
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") && (u = !0));
151
- return o.push(
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
- ), y("subscription", {
154
- operations: R([...e].sort()),
155
- ...u ? { relationships: te(!0) } : {}
154
+ ), I("subscription", {
155
+ operations: F([...e].sort()),
156
+ ...c ? { relationships: se(!0) } : {}
156
157
  });
157
158
  }
158
- function $e(n, s) {
159
- const o = {
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 c of s)
165
- a.set(Y(c.name.value), c), a.set(Ae(c.name.value), c);
166
- const e = new Map(s.map((c) => [c.name.value, c])), u = (c, l, d) => {
167
- const m = o.filters.get(c) ?? /* @__PURE__ */ new Map(), h = m.get(l) ?? /* @__PURE__ */ new Set();
168
- h.add(d), m.set(l, h), o.filters.set(c, m);
169
- }, t = (c, l) => {
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 d of l.fields) {
172
- const m = d.name.value;
172
+ for (const f of l.fields) {
173
+ const m = f.name.value;
173
174
  if (m === "AND" || m === "OR") {
174
- if (d.value.kind === p.LIST)
175
- for (const w of d.value.values) t(c, w);
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(c, d.value);
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 = c.fields?.find(($) => $.name.value === h[1]), S = w && e.get(G(w));
185
- w && S && (u(c.name.value, h[1], "EQ"), t(S, d.value));
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 = Ne.find(([w]) => m.endsWith(w)), T = v ? m.slice(0, -v[0].length) : m, g = c.fields?.find((w) => w.name.value === T);
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(G(g));
191
+ const N = e.get(z(g));
191
192
  if (N) {
192
- if (u(c.name.value, T, "EQ"), d.value.kind === p.OBJECT) {
193
- for (const w of d.value.fields) t(N, w.value);
194
- t(N, d.value);
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) u(c.name.value, T, v[1]);
199
- else if (d.value.kind === p.OBJECT)
200
- for (const w of d.value.fields) {
201
- const S = Se[w.name.value];
202
- S && u(c.name.value, T, S);
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 u(c.name.value, T, "EQ");
205
+ else c(r.name.value, b, "EQ");
205
206
  }
206
- }, r = (c, l) => {
207
- for (const d of c?.selections ?? []) {
208
- if (d.kind !== p.FIELD) continue;
209
- const m = d.name.value;
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)$/, ""), T = a.get(v) ?? (h ? a.get(ne(h[2])) : void 0);
212
- if (T && h) {
213
- const g = o.mutations.get(T.name.value) ?? /* @__PURE__ */ new Set(), N = h[1].toUpperCase();
214
- N === "UPSERT" ? (g.add("CREATE"), g.add("UPDATE")) : g.add(N), o.mutations.set(T.name.value, g);
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 (T)
217
- for (const g of d.arguments ?? []) i(T, g);
217
+ if (b)
218
+ for (const g of f.arguments ?? []) o(b, g);
218
219
  }
219
- r(d.selectionSet, !1);
220
+ u(f.selectionSet, !1);
220
221
  }
221
- }, i = (c, l) => {
222
- if (l.name.value === "where" && t(c, l.value), l.name.value === "sort" || l.name.value === "options") {
223
- const d = o.sorts.get(c.name.value) ?? /* @__PURE__ */ new Set(), m = (h) => {
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 && d.add(v.name.value);
228
+ v.name.value === "sort" ? m(v.value) : v.value.kind === p.ENUM && f.add(v.name.value);
228
229
  };
229
- m(l.value), o.sorts.set(c.name.value, d);
230
+ m(l.value), i.sorts.set(r.name.value, f);
230
231
  }
231
232
  };
232
- for (const c of n)
233
- for (const l of c.definitions)
234
- l.kind === p.OPERATION_DEFINITION && r(l.selectionSet, !0);
235
- return o;
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 G(n) {
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((o) => o.name.value === s);
244
+ return (n ?? []).some((i) => i.name.value === s);
244
245
  }
245
- function y(n, s = {}) {
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(([o, a]) => A(o, a))
250
+ arguments: Object.entries(s).map(([i, a]) => q(i, a))
250
251
  };
251
252
  }
252
- function A(n, s) {
253
+ function q(n, s) {
253
254
  return { kind: p.ARGUMENT, name: { kind: p.NAME, value: n }, value: s };
254
255
  }
255
- const ee = (n) => ({
256
+ const ne = (n) => ({
256
257
  kind: p.ENUM,
257
258
  value: n
258
- }), te = (n) => ({
259
+ }), se = (n) => ({
259
260
  kind: p.BOOLEAN,
260
261
  value: n
261
- }), R = (n) => ({
262
+ }), F = (n) => ({
262
263
  kind: p.LIST,
263
- values: n.map(ee)
264
+ values: n.map(ne)
264
265
  });
265
- function De(n, s, o, a) {
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 ? A(s, {
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
- (u) => u.kind === p.OBJECT ? {
273
- ...u,
274
- fields: u.fields.map(
275
- (t) => t.name.value === o ? { ...t, name: { kind: p.NAME, value: a } } : t
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
- } : u
278
+ } : c
278
279
  )
279
280
  }) : e
280
281
  )
281
282
  };
282
283
  }
283
- const Le = {
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 Ae(n) {
294
- const s = ne(n), o = s.toLowerCase();
295
- for (const [a, e] of Object.entries(Le))
296
- if (o.endsWith(a))
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 Y(n);
299
+ return K(n);
299
300
  }
300
- function ne(n) {
301
+ function ae(n) {
301
302
  return n.charAt(0).toLowerCase() + n.slice(1);
302
303
  }
303
- const z = `lora-graphql <command>
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
- database statements and API changes`;
327
- async function qe(n, s = Be) {
328
- const [o, ...a] = n, e = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), t = [], r = [];
329
- for (let i = 0; i < a.length; i++) {
330
- const c = a[i];
331
- c === "--operations" ? r.push(a[++i] ?? "") : je.has(c) ? u.set(c, a[++i] ?? "") : c.startsWith("--") ? e.add(c) : t.push(c);
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 (o) {
339
+ switch (i) {
335
340
  case "print":
336
- return await _e(O(t, 1), s);
341
+ return await Pe(S(t, 1), s);
337
342
  case "directives":
338
- return s.out(he.trim()), 0;
343
+ return s.out(be.trim()), 0;
339
344
  case "access":
340
- return await Ce(O(t, 1), e.has("--json"), s);
345
+ return await Fe(S(t, 1), e.has("--json"), s);
341
346
  case "requirements":
342
- return await xe(O(t, 1), e.has("--ddl"), s);
347
+ return await Ue(S(t, 1), e.has("--ddl"), s);
343
348
  case "check":
344
- return await Me(O(t, 1), r, e, u, s);
349
+ return await Je(S(t, 1), u, e, c, s);
345
350
  case "compile":
346
- return await Pe(O(t, 1), r, u, s);
351
+ return await Ge(S(t, 1), u, c, s);
347
352
  case "analyze":
348
- return await Ue(O(t, 1), u, s);
353
+ return await We(S(t, 1), c, s);
349
354
  case "migrate": {
350
- const [i, c] = O(t, 2);
351
- if (i !== "neo4j") throw new L("migrate supports neo4j");
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 r)
354
- for (const h of await j(m)) l.push(q(h.source));
355
- const d = ye(await E(c), l);
356
- for (const m of d.todos) s.out(`# TODO(migrate): ${m}`);
357
- return d.todos.length > 0 && s.out(""), s.out(d.typeDefs), 0;
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 [i, c] = O(t, 2);
361
- return await We(i, c, e, s);
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(z), 2;
377
+ return s.err(H), 2;
365
378
  }
366
- } catch (i) {
367
- return i instanceof L ? (s.err(`${i.message}
379
+ } catch (o) {
380
+ return o instanceof L ? (s.err(`${o.message}
368
381
 
369
- ${z}`), 2) : i instanceof ge ? (s.err(i.message), 1) : (s.err(i instanceof Error ? i.message : String(i)), 1);
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 je = /* @__PURE__ */ new Set([
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 O(n, s) {
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) => ie(n, "utf8");
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 M({ typeDefs: n, driver: s });
408
+ return new R({ typeDefs: n, driver: s });
395
409
  }
396
- async function Ce([n], s, o) {
410
+ async function Fe([n], s, i) {
397
411
  const a = P(await E(n)).accessMatrix();
398
412
  if (s)
399
- return o.out(JSON.stringify(a, null, 2)), 0;
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
- ]), u = [0, 1, 2, 3].map(
407
- (t) => Math.max(...e.map((r) => r[t].length), 0)
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
- o.out(
411
- t.map((r, i) => i < 4 ? r.padEnd(u[i]) : r).join(" ").trimEnd()
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 _e([n], s) {
429
+ async function Pe([n], s) {
416
430
  return s.out(P(await E(n)).printPublicSchema()), 0;
417
431
  }
418
- async function xe([n], s, o) {
419
- const a = ve(await E(n));
420
- for (const e of we(a))
421
- o.out(
422
- s ? `${Ee(e)};` : `${K(e)}, because ${e.reason}`
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 se(n, s) {
440
+ async function oe(n, s) {
427
441
  try {
428
- const { createDatabase: o } = await import("@loradb/lora-node");
429
- return o;
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 Me([n], s, o, a, e) {
438
- const u = o.has("--json"), t = await E(n), r = await se(e, "check");
439
- if (!r) return 1;
440
- const i = a.get("--database"), c = await r(
441
- i ? a.get("--name") ?? "app" : void 0,
442
- i ? { databaseDir: i } : {}
443
- ), l = new M({
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: Z(c)
459
+ driver: X(r)
446
460
  });
447
- i || await l.assertSchema({ create: !0 });
448
- const d = 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 = [];
449
- for (const f of s)
450
- for (const b of await j(f))
451
- for (const I of Fe(d, b.path, b.source)) {
452
- const U = I.name.split("#")[1] ?? "", F = m[I.name] ?? m[U], J = h[I.name] ?? h[U] ?? h["*"];
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
- ...I,
455
- ...F ? { variables: F } : {},
456
- ...J !== void 0 ? { context: J } : {}
468
+ ...$,
469
+ ...J ? { variables: J } : {},
470
+ ...B !== void 0 ? { context: B } : {}
457
471
  });
458
472
  }
459
- const T = a.has("--row-budget") ? Number(a.get("--row-budget")) : void 0, g = await l.check({
473
+ const b = a.has("--row-budget") ? Number(a.get("--row-budget")) : void 0, g = await l.check({
460
474
  operations: v,
461
- ...T !== void 0 ? { rowBudget: T } : {}
475
+ ...b !== void 0 ? { rowBudget: b } : {}
462
476
  }), N = a.get("--baseline"), w = {};
463
- for (const f of g.plans)
464
- w[`${f.operation} › ${f.field}`] = f.reports.map((b) => b.operators);
465
- const S = [];
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 f;
481
+ let d;
468
482
  try {
469
- f = JSON.parse(await E(N));
483
+ d = JSON.parse(await E(N));
470
484
  } catch {
471
- f = void 0;
485
+ d = void 0;
472
486
  }
473
- if (o.has("--update-baseline") || !f)
487
+ if (i.has("--update-baseline") || !d)
474
488
  await _(N, JSON.stringify(w, null, 2) + `
475
489
  `);
476
490
  else
477
- for (const b of /* @__PURE__ */ new Set([
478
- ...Object.keys(f),
491
+ for (const T of /* @__PURE__ */ new Set([
492
+ ...Object.keys(d),
479
493
  ...Object.keys(w)
480
494
  ]))
481
- JSON.stringify(f[b]) !== JSON.stringify(w[b]) && S.push(b);
495
+ JSON.stringify(d[T]) !== JSON.stringify(w[T]) && y.push(T);
482
496
  }
483
- const $ = g.ok && S.length === 0;
484
- if (u)
485
- return e.out(JSON.stringify({ ...g, ok: $, planChanges: S }, null, 2)), $ ? 0 : 1;
486
- for (const f of g.warnings) e.out(`warning ${C(f)}`);
487
- for (const f of g.lint) e.out(`lint ${C(f)}`);
488
- for (const f of g.unused)
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 ${f.type} index ${f.name} on :${f.labels.join(":")}(${f.properties.join(", ")})`
504
+ `unused ${d.type} index ${d.name} on :${d.labels.join(":")}(${d.properties.join(", ")})`
491
505
  );
492
- for (const f of g.security) e.out(`error ${C(f)}`);
493
- for (const f of g.missing)
494
- e.out(`error missing ${K(f)}`);
495
- for (const f of g.cypher)
496
- e.out(`error ${f.type}.${f.field}: ${f.message}`);
497
- for (const f of g.errors)
498
- e.out(`error ${f.operation}: ${f.message}`);
499
- for (const f of g.plans)
500
- for (const b of f.reports) {
501
- for (const I of b.findings)
502
- e.out(`error ${f.operation} › ${f.field}: ${I.message}`);
503
- for (const I of b.notes)
504
- e.out(`lint ${f.operation} › ${f.field}: ${I.message}`);
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 f of S)
520
+ for (const d of y)
507
521
  e.out(
508
- `error ${f}: the plan differs from the baseline (--update-baseline to accept)`
522
+ `error ${d}: the plan differs from the baseline (--update-baseline to accept)`
509
523
  );
510
- const ae = g.plans.length;
524
+ const ie = g.plans.length;
511
525
  return e.out(
512
- $ ? `ok ${ae} root field(s) in ${v.length} operation(s) seek as expected` : "failed"
513
- ), $ ? 0 : 1;
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 Re(n) {
529
+ async function Be(n) {
516
530
  const s = {};
517
- for (const o of n) {
518
- if ((await H(o)).isFile() && o.endsWith(".json")) {
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(o))
535
+ JSON.parse(await E(i))
522
536
  );
523
537
  continue;
524
538
  }
525
- for (const e of await j(o)) {
526
- const u = q(e.source), t = new Map(
527
- u.definitions.filter(
528
- (i) => i.kind === p.FRAGMENT_DEFINITION
529
- ).map((i) => [i.name.value, i])
530
- ), r = ce(process.cwd(), e.path);
531
- u.definitions.filter(
532
- (i) => i.kind === p.OPERATION_DEFINITION
533
- ).forEach((i, c) => {
534
- const l = `${r}#${i.name?.value ?? c + 1}`;
535
- s[l] = V({
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: [i, ...Te(i, t)]
551
+ definitions: [o, ...Ie(o, t)]
538
552
  });
539
553
  });
540
554
  }
541
555
  }
542
556
  return s;
543
557
  }
544
- async function Pe([n], s, o, a) {
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)), u = e.buildManifest(
548
- await Re(s)
549
- ), t = o.get("--out") ?? "lora-graphql";
550
- return await re(t, { recursive: !0 }), await _(
551
- D(t, "manifest.json"),
552
- JSON.stringify(u) + `
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
- D(t, "operations.d.ts"),
556
- e.generateTypes(u)
569
+ O(t, "operations.d.ts"),
570
+ e.generateTypes(c)
557
571
  ), a.out(
558
- `wrote ${Object.keys(u.operations).length} operation(s) to ${D(t, "manifest.json")} and ${D(t, "operations.d.ts")}`
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 Ue([n], s, o) {
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 se(o, "analyze");
578
+ const e = await oe(i, "analyze");
565
579
  if (!e) return 1;
566
- const u = await e(s.get("--name") ?? "app", {
580
+ const c = await e(s.get("--name") ?? "app", {
567
581
  databaseDir: a
568
- }), t = new M({
582
+ }), t = new R({
569
583
  typeDefs: await E(n),
570
- driver: Z(u)
571
- }), r = s.has("--sample") ? Number(s.get("--sample")) : void 0, i = await t.analyze(r !== void 0 ? { sample: r } : {});
572
- return o.out(JSON.stringify(i, null, 2)), u.dispose?.(), 0;
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 j(n) {
575
- if ((await H(n)).isFile()) return [{ path: n, source: await E(n) }];
576
- const o = [];
577
- for (const a of await oe(n, { withFileTypes: !0 })) {
578
- const e = D(n, a.name);
579
- a.isDirectory() ? o.push(...await j(e)) : /\.(graphql|gql)$/.test(a.name) && o.push({ path: e, source: await E(e) });
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 o;
595
+ return i;
582
596
  }
583
- function Fe(n, s, o) {
584
- const a = q(o), e = new Map(
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
- ), u = (t) => {
589
- const r = /* @__PURE__ */ new Map(), i = (c) => Q(c, {
602
+ ), c = (t) => {
603
+ const u = /* @__PURE__ */ new Map(), o = (r) => Y(r, {
590
604
  FragmentSpread(l) {
591
- const d = e.get(l.name.value);
592
- d && !r.has(d.name.value) && (r.set(d.name.value, d), i(d));
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 i(t), [...r.values()];
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, r) => {
600
- const i = {};
601
- for (const c of t.variableDefinitions ?? []) {
602
- if (c.defaultValue || c.type.kind !== p.NON_NULL_TYPE) continue;
603
- const l = ue(n, c.type);
604
- l && (i[c.variable.name.value] = x(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}` : `#${r + 1}`}`,
608
- document: { kind: p.DOCUMENT, definitions: [t, ...u(t)] },
609
- variables: i
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 Je = {
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 x(n) {
628
- const s = W(n) ? n.ofType : n;
629
- if (le(s)) return [x(s.ofType)];
630
- const o = fe(s);
631
- if (de(o)) return o.getValues()[0]?.value;
632
- if (pe(o)) {
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(o.getFields()))
635
- W(e.type) && e.defaultValue === void 0 && (a[e.name] = x(e.type));
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 Je[o.name] ?? "x";
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
- async function We(n, s, o, a) {
641
- const e = me(await E(n), await E(s)), u = e.api.breaking.length > 0, t = u && !o.has("--allow-breaking") ? 1 : 0;
642
- if (o.has("--json"))
643
- return a.out(JSON.stringify(e, null, 2)), t;
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 r of e.database.statements)
646
- a.out(`${r.destructive ? "// destructive: " : "// "}${r.reason}`), a.out(`${r.text};`);
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`), !u && e.api.dangerous.length === 0 && a.out("no changes");
649
- for (const r of e.api.breaking) a.out(`breaking ${r.description}`);
650
- for (const r of e.api.dangerous) a.out(`dangerous ${r.description}`);
651
- for (const r of e.notes) a.out(`note ${r}`);
652
- return t;
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 Be = {
717
+ const Ye = {
655
718
  out: (n) => process.stdout.write(n + `
656
719
  `),
657
720
  err: (n) => process.stderr.write(n + `
658
721
  `)
659
- }, Ge = typeof process < "u" && process.argv[1] !== void 0 && /lora-graphql(\.js)?$|cli\.js$/.test(process.argv[1]);
660
- Ge && qe(process.argv.slice(2)).then((n) => process.exit(n));
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
- qe as main
725
+ Me as main
663
726
  };
664
727
  //# sourceMappingURL=cli.js.map