@stonecrop/casl-middleware 0.12.6 → 0.12.8

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.
@@ -13,20 +13,20 @@ const pe = (e) => {
13
13
  }, he = (e) => (t) => !e || !t ? !1 : Array.isArray(e) ? e.includes(t) : e === t, de = (e) => (t) => !e || !t ? !0 : Object.keys(e).every((n) => {
14
14
  const s = e[n];
15
15
  return t[n] === s;
16
- }), fe = ae, X = (e) => {
16
+ }), fe = ae, q = (e) => {
17
17
  const { can: t, build: n } = new oe(fe);
18
18
  return t("read", "Query"), n({
19
19
  detectSubjectType: pe,
20
20
  fieldMatcher: he,
21
21
  conditionsMatcher: de
22
22
  });
23
- }, z = async (e, t = X) => await t(e);
23
+ }, z = async (e, t = q) => await t(e);
24
24
  function b(e, t) {
25
25
  if (!!!e)
26
26
  throw new Error(t);
27
27
  }
28
28
  const Ee = 10, H = 2;
29
- function B(e) {
29
+ function V(e) {
30
30
  return R(e, []);
31
31
  }
32
32
  function R(e, t) {
@@ -83,11 +83,11 @@ function ye(e) {
83
83
  }
84
84
  return t;
85
85
  }
86
- const Ae = globalThis.process && // eslint-disable-next-line no-undef
87
- process.env.NODE_ENV === "production", Oe = (
86
+ const xe = globalThis.process && // eslint-disable-next-line no-undef
87
+ process.env.NODE_ENV === "production", Ae = (
88
88
  /* c8 ignore next 6 */
89
89
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
90
- Ae ? function(t, n) {
90
+ xe ? function(t, n) {
91
91
  return t instanceof n;
92
92
  } : function(t, n) {
93
93
  if (t instanceof n)
@@ -99,7 +99,7 @@ process.env.NODE_ENV === "production", Oe = (
99
99
  Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
100
100
  );
101
101
  if (i === r) {
102
- const a = B(t);
102
+ const a = V(t);
103
103
  throw new Error(`Cannot use ${i} "${a}" from another module or realm.
104
104
 
105
105
  Ensure that there is only one instance of "graphql" in the node_modules
@@ -122,7 +122,7 @@ class W {
122
122
  line: 1,
123
123
  column: 1
124
124
  }) {
125
- typeof t == "string" || b(!1, `Body must be a string. Received: ${B(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || b(
125
+ typeof t == "string" || b(!1, `Body must be a string. Received: ${V(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || b(
126
126
  !1,
127
127
  "line in locationOffset is 1-indexed and must be positive."
128
128
  ), this.locationOffset.column > 0 || b(
@@ -134,8 +134,8 @@ class W {
134
134
  return "Source";
135
135
  }
136
136
  }
137
- function xe(e) {
138
- return Oe(e, W);
137
+ function Oe(e) {
138
+ return Ae(e, W);
139
139
  }
140
140
  function _e(e, t) {
141
141
  if (!!!e)
@@ -163,16 +163,16 @@ function Ce(e) {
163
163
  );
164
164
  }
165
165
  function Z(e, t) {
166
- const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, i = t.line - 1, r = e.locationOffset.line - 1, a = t.line + r, p = t.line === 1 ? n : 0, l = t.column + p, u = `${e.name}:${a}:${l}
166
+ const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, i = t.line - 1, r = e.locationOffset.line - 1, a = t.line + r, l = t.line === 1 ? n : 0, p = t.column + l, u = `${e.name}:${a}:${p}
167
167
  `, h = s.split(/\r\n|[\n\r]/g), d = h[i];
168
168
  if (d.length > 120) {
169
- const f = Math.floor(l / 80), A = l % 80, E = [];
169
+ const f = Math.floor(p / 80), x = p % 80, E = [];
170
170
  for (let N = 0; N < d.length; N += 80)
171
171
  E.push(d.slice(N, N + 80));
172
172
  return u + Y([
173
173
  [`${a} |`, E[0]],
174
174
  ...E.slice(1, f + 1).map((N) => ["|", N]),
175
- ["|", "^".padStart(A)],
175
+ ["|", "^".padStart(x)],
176
176
  ["|", E[f + 1]]
177
177
  ]);
178
178
  }
@@ -180,7 +180,7 @@ function Z(e, t) {
180
180
  // Lines specified like this: ["prefix", "string"],
181
181
  [`${a - 1} |`, h[i - 1]],
182
182
  [`${a} |`, d],
183
- ["|", "^".padStart(l)],
183
+ ["|", "^".padStart(p)],
184
184
  [`${a + 1} |`, h[i + 1]]
185
185
  ]);
186
186
  }
@@ -191,16 +191,16 @@ function Y(e) {
191
191
  }
192
192
  var c;
193
193
  (function(e) {
194
- e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension", e.TYPE_COORDINATE = "TypeCoordinate", e.MEMBER_COORDINATE = "MemberCoordinate", e.ARGUMENT_COORDINATE = "ArgumentCoordinate", e.DIRECTIVE_COORDINATE = "DirectiveCoordinate", e.DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate";
194
+ e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.DIRECTIVE_EXTENSION = "DirectiveExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension", e.TYPE_COORDINATE = "TypeCoordinate", e.MEMBER_COORDINATE = "MemberCoordinate", e.ARGUMENT_COORDINATE = "ArgumentCoordinate", e.DIRECTIVE_COORDINATE = "DirectiveCoordinate", e.DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate";
195
195
  })(c || (c = {}));
196
196
  var o;
197
197
  (function(e) {
198
198
  e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.DOT = ".", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
199
199
  })(o || (o = {}));
200
- function ke(e) {
200
+ function ve(e) {
201
201
  return typeof e == "object" && e !== null;
202
202
  }
203
- function ve(e) {
203
+ function ke(e) {
204
204
  const t = e[0];
205
205
  return t == null || "kind" in t || "length" in t ? {
206
206
  nodes: t,
@@ -211,7 +211,7 @@ function ve(e) {
211
211
  extensions: e[5]
212
212
  } : t;
213
213
  }
214
- class V extends Error {
214
+ class B extends Error {
215
215
  /**
216
216
  * An array of `{ line, column }` locations within the source GraphQL document
217
217
  * which correspond to this error.
@@ -252,18 +252,18 @@ class V extends Error {
252
252
  */
253
253
  constructor(t, ...n) {
254
254
  var s, i, r;
255
- const { nodes: a, source: p, positions: l, path: u, originalError: h, extensions: d } = ve(n);
255
+ const { nodes: a, source: l, positions: p, path: u, originalError: h, extensions: d } = ke(n);
256
256
  super(t), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = h ?? void 0, this.nodes = J(
257
257
  Array.isArray(a) ? a : a ? [a] : void 0
258
258
  );
259
259
  const f = J(
260
260
  (s = this.nodes) === null || s === void 0 ? void 0 : s.map((E) => E.loc).filter((E) => E != null)
261
261
  );
262
- this.source = p ?? (f == null || (i = f[0]) === null || i === void 0 ? void 0 : i.source), this.positions = l ?? f?.map((E) => E.start), this.locations = l && p ? l.map((E) => M(p, E)) : f?.map((E) => M(E.source, E.start));
263
- const A = ke(
262
+ this.source = l ?? (f == null || (i = f[0]) === null || i === void 0 ? void 0 : i.source), this.positions = p ?? f?.map((E) => E.start), this.locations = p && l ? p.map((E) => M(l, E)) : f?.map((E) => M(E.source, E.start));
263
+ const x = ve(
264
264
  h?.extensions
265
265
  ) ? h?.extensions : void 0;
266
- this.extensions = (r = d ?? A) !== null && r !== void 0 ? r : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
266
+ this.extensions = (r = d ?? x) !== null && r !== void 0 ? r : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
267
267
  message: {
268
268
  writable: !0,
269
269
  enumerable: !0
@@ -287,7 +287,7 @@ class V extends Error {
287
287
  value: h.stack,
288
288
  writable: !0,
289
289
  configurable: !0
290
- }) : Error.captureStackTrace ? Error.captureStackTrace(this, V) : Object.defineProperty(this, "stack", {
290
+ }) : Error.captureStackTrace ? Error.captureStackTrace(this, B) : Object.defineProperty(this, "stack", {
291
291
  value: Error().stack,
292
292
  writable: !0,
293
293
  configurable: !0
@@ -321,7 +321,7 @@ function J(e) {
321
321
  return e === void 0 || e.length === 0 ? void 0 : e;
322
322
  }
323
323
  function T(e, t, n) {
324
- return new V(`Syntax Error: ${n}`, {
324
+ return new B(`Syntax Error: ${n}`, {
325
325
  source: e,
326
326
  positions: [t]
327
327
  });
@@ -471,8 +471,15 @@ const ee = {
471
471
  EnumTypeDefinition: ["description", "name", "directives", "values"],
472
472
  EnumValueDefinition: ["description", "name", "directives"],
473
473
  InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
474
- DirectiveDefinition: ["description", "name", "arguments", "locations"],
474
+ DirectiveDefinition: [
475
+ "description",
476
+ "name",
477
+ "arguments",
478
+ "directives",
479
+ "locations"
480
+ ],
475
481
  SchemaExtension: ["directives", "operationTypes"],
482
+ DirectiveExtension: ["name", "directives"],
476
483
  ScalarTypeExtension: ["name", "directives"],
477
484
  ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
478
485
  InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
@@ -496,7 +503,7 @@ var _;
496
503
  function be(e) {
497
504
  return e === 9 || e === 32;
498
505
  }
499
- function v(e) {
506
+ function k(e) {
500
507
  return e >= 48 && e <= 57;
501
508
  }
502
509
  function te(e) {
@@ -507,17 +514,17 @@ function ne(e) {
507
514
  return te(e) || e === 95;
508
515
  }
509
516
  function Re(e) {
510
- return te(e) || v(e) || e === 95;
517
+ return te(e) || k(e) || e === 95;
511
518
  }
512
519
  function Le(e) {
513
520
  var t;
514
521
  let n = Number.MAX_SAFE_INTEGER, s = null, i = -1;
515
522
  for (let a = 0; a < e.length; ++a) {
516
523
  var r;
517
- const p = e[a], l = Fe(p);
518
- l !== p.length && (s = (r = s) !== null && r !== void 0 ? r : a, i = a, a !== 0 && l < n && (n = l));
524
+ const l = e[a], p = Fe(l);
525
+ p !== l.length && (s = (r = s) !== null && r !== void 0 ? r : a, i = a, a !== 0 && p < n && (n = p));
519
526
  }
520
- return e.map((a, p) => p === 0 ? a : a.slice(n)).slice(
527
+ return e.map((a, l) => l === 0 ? a : a.slice(n)).slice(
521
528
  (t = s) !== null && t !== void 0 ? t : 0,
522
529
  i + 1
523
530
  );
@@ -587,7 +594,7 @@ function ie(e) {
587
594
  function se(e) {
588
595
  return e >= 56320 && e <= 57343;
589
596
  }
590
- function x(e, t) {
597
+ function O(e, t) {
591
598
  const n = e.source.body.codePointAt(t);
592
599
  if (n === void 0)
593
600
  return o.EOF;
@@ -683,16 +690,16 @@ function Me(e, t) {
683
690
  return m(e, o.BRACE_R, i, i + 1);
684
691
  // StringValue
685
692
  case 34:
686
- return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? Ye(e, i) : Ve(e, i);
693
+ return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? Ye(e, i) : Be(e, i);
687
694
  }
688
- if (v(r) || r === 45)
689
- return Be(e, i, r);
695
+ if (k(r) || r === 45)
696
+ return Ve(e, i, r);
690
697
  if (ne(r))
691
698
  return Je(e, i);
692
699
  throw T(
693
700
  e.source,
694
701
  i,
695
- r === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : D(r) || L(n, i) ? `Unexpected character: ${x(e, i)}.` : `Invalid character: ${x(e, i)}.`
702
+ r === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : D(r) || L(n, i) ? `Unexpected character: ${O(e, i)}.` : `Invalid character: ${O(e, i)}.`
696
703
  );
697
704
  }
698
705
  return m(e, o.EOF, s, s);
@@ -719,15 +726,15 @@ function Ue(e, t) {
719
726
  n.slice(t + 1, i)
720
727
  );
721
728
  }
722
- function Be(e, t, n) {
729
+ function Ve(e, t, n) {
723
730
  const s = e.source.body;
724
731
  let i = t, r = n, a = !1;
725
732
  if (r === 45 && (r = s.charCodeAt(++i)), r === 48) {
726
- if (r = s.charCodeAt(++i), v(r))
733
+ if (r = s.charCodeAt(++i), k(r))
727
734
  throw T(
728
735
  e.source,
729
736
  i,
730
- `Invalid number, unexpected digit after 0: ${x(
737
+ `Invalid number, unexpected digit after 0: ${O(
731
738
  e,
732
739
  i
733
740
  )}.`
@@ -738,7 +745,7 @@ function Be(e, t, n) {
738
745
  throw T(
739
746
  e.source,
740
747
  i,
741
- `Invalid number, expected digit but got: ${x(
748
+ `Invalid number, expected digit but got: ${O(
742
749
  e,
743
750
  i
744
751
  )}.`
@@ -752,37 +759,37 @@ function Be(e, t, n) {
752
759
  );
753
760
  }
754
761
  function w(e, t, n) {
755
- if (!v(n))
762
+ if (!k(n))
756
763
  throw T(
757
764
  e.source,
758
765
  t,
759
- `Invalid number, expected digit but got: ${x(
766
+ `Invalid number, expected digit but got: ${O(
760
767
  e,
761
768
  t
762
769
  )}.`
763
770
  );
764
771
  const s = e.source.body;
765
772
  let i = t + 1;
766
- for (; v(s.charCodeAt(i)); )
773
+ for (; k(s.charCodeAt(i)); )
767
774
  ++i;
768
775
  return i;
769
776
  }
770
- function Ve(e, t) {
777
+ function Be(e, t) {
771
778
  const n = e.source.body, s = n.length;
772
779
  let i = t + 1, r = i, a = "";
773
780
  for (; i < s; ) {
774
- const p = n.charCodeAt(i);
775
- if (p === 34)
781
+ const l = n.charCodeAt(i);
782
+ if (l === 34)
776
783
  return a += n.slice(r, i), m(e, o.STRING, t, i + 1, a);
777
- if (p === 92) {
784
+ if (l === 92) {
778
785
  a += n.slice(r, i);
779
- const l = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? je(e, i) : Ge(e, i) : $e(e, i);
780
- a += l.value, i += l.size, r = i;
786
+ const p = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? je(e, i) : Ge(e, i) : $e(e, i);
787
+ a += p.value, i += p.size, r = i;
781
788
  continue;
782
789
  }
783
- if (p === 10 || p === 13)
790
+ if (l === 10 || l === 13)
784
791
  break;
785
- if (D(p))
792
+ if (D(l))
786
793
  ++i;
787
794
  else if (L(n, i))
788
795
  i += 2;
@@ -790,7 +797,7 @@ function Ve(e, t) {
790
797
  throw T(
791
798
  e.source,
792
799
  i,
793
- `Invalid character within String: ${x(
800
+ `Invalid character within String: ${O(
794
801
  e,
795
802
  i
796
803
  )}.`
@@ -811,7 +818,7 @@ function je(e, t) {
811
818
  size: i
812
819
  };
813
820
  }
814
- if (s = s << 4 | k(r), s < 0)
821
+ if (s = s << 4 | v(r), s < 0)
815
822
  break;
816
823
  }
817
824
  throw T(
@@ -824,14 +831,14 @@ function je(e, t) {
824
831
  );
825
832
  }
826
833
  function Ge(e, t) {
827
- const n = e.source.body, s = q(n, t + 2);
834
+ const n = e.source.body, s = X(n, t + 2);
828
835
  if (D(s))
829
836
  return {
830
837
  value: String.fromCodePoint(s),
831
838
  size: 6
832
839
  };
833
840
  if (ie(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
834
- const i = q(n, t + 8);
841
+ const i = X(n, t + 8);
835
842
  if (se(i))
836
843
  return {
837
844
  value: String.fromCodePoint(s, i),
@@ -844,10 +851,10 @@ function Ge(e, t) {
844
851
  `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
845
852
  );
846
853
  }
847
- function q(e, t) {
848
- return k(e.charCodeAt(t)) << 12 | k(e.charCodeAt(t + 1)) << 8 | k(e.charCodeAt(t + 2)) << 4 | k(e.charCodeAt(t + 3));
854
+ function X(e, t) {
855
+ return v(e.charCodeAt(t)) << 12 | v(e.charCodeAt(t + 1)) << 8 | v(e.charCodeAt(t + 2)) << 4 | v(e.charCodeAt(t + 3));
849
856
  }
850
- function k(e) {
857
+ function v(e) {
851
858
  return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
852
859
  }
853
860
  function $e(e, t) {
@@ -906,29 +913,29 @@ function $e(e, t) {
906
913
  }
907
914
  function Ye(e, t) {
908
915
  const n = e.source.body, s = n.length;
909
- let i = e.lineStart, r = t + 3, a = r, p = "";
910
- const l = [];
916
+ let i = e.lineStart, r = t + 3, a = r, l = "";
917
+ const p = [];
911
918
  for (; r < s; ) {
912
919
  const u = n.charCodeAt(r);
913
920
  if (u === 34 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34) {
914
- p += n.slice(a, r), l.push(p);
921
+ l += n.slice(a, r), p.push(l);
915
922
  const h = m(
916
923
  e,
917
924
  o.BLOCK_STRING,
918
925
  t,
919
926
  r + 3,
920
927
  // Return a string of the lines joined with U+000A.
921
- Le(l).join(`
928
+ Le(p).join(`
922
929
  `)
923
930
  );
924
- return e.line += l.length - 1, e.lineStart = i, h;
931
+ return e.line += p.length - 1, e.lineStart = i, h;
925
932
  }
926
933
  if (u === 92 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 && n.charCodeAt(r + 3) === 34) {
927
- p += n.slice(a, r), a = r + 1, r += 4;
934
+ l += n.slice(a, r), a = r + 1, r += 4;
928
935
  continue;
929
936
  }
930
937
  if (u === 10 || u === 13) {
931
- p += n.slice(a, r), l.push(p), u === 13 && n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, p = "", a = r, i = r;
938
+ l += n.slice(a, r), p.push(l), u === 13 && n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, l = "", a = r, i = r;
932
939
  continue;
933
940
  }
934
941
  if (D(u))
@@ -939,7 +946,7 @@ function Ye(e, t) {
939
946
  throw T(
940
947
  e.source,
941
948
  r,
942
- `Invalid character within String: ${x(
949
+ `Invalid character within String: ${O(
943
950
  e,
944
951
  r
945
952
  )}.`
@@ -967,22 +974,22 @@ function Je(e, t) {
967
974
  }
968
975
  var U;
969
976
  (function(e) {
970
- e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
977
+ e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION", e.DIRECTIVE_DEFINITION = "DIRECTIVE_DEFINITION";
971
978
  })(U || (U = {}));
972
979
  function Qe(e, t) {
973
- const n = new qe(e, t), s = n.parseDocument();
980
+ const n = new Xe(e, t), s = n.parseDocument();
974
981
  return Object.defineProperty(s, "tokenCount", {
975
982
  enumerable: !1,
976
983
  value: n.tokenCount
977
984
  }), s;
978
985
  }
979
- class qe {
986
+ class Xe {
980
987
  constructor(t, n = {}) {
981
988
  const { lexer: s, ...i } = n;
982
989
  if (s)
983
990
  this._lexer = s;
984
991
  else {
985
- const r = xe(t) ? t : new W(t);
992
+ const r = Oe(t) ? t : new W(t);
986
993
  this._lexer = new we(r);
987
994
  }
988
995
  this._options = i, this._tokenCounter = 0;
@@ -1742,6 +1749,7 @@ class qe {
1742
1749
  * - UnionTypeExtension
1743
1750
  * - EnumTypeExtension
1744
1751
  * - InputObjectTypeDefinition
1752
+ * - DirectiveDefinitionExtension
1745
1753
  */
1746
1754
  parseTypeSystemExtension() {
1747
1755
  const t = this._lexer.lookahead();
@@ -1761,6 +1769,10 @@ class qe {
1761
1769
  return this.parseEnumTypeExtension();
1762
1770
  case "input":
1763
1771
  return this.parseInputObjectTypeExtension();
1772
+ case "directive":
1773
+ if (this._options.experimentalDirectivesOnDirectiveDefinitions)
1774
+ return this.parseDirectiveDefinitionExtension();
1775
+ break;
1764
1776
  }
1765
1777
  throw this.unexpected(t);
1766
1778
  }
@@ -1897,6 +1909,18 @@ class qe {
1897
1909
  fields: i
1898
1910
  });
1899
1911
  }
1912
+ parseDirectiveDefinitionExtension() {
1913
+ const t = this._lexer.token;
1914
+ this.expectKeyword("extend"), this.expectKeyword("directive"), this.expectToken(o.AT);
1915
+ const n = this.parseName(), s = this.parseConstDirectives();
1916
+ if (s.length === 0)
1917
+ throw this.unexpected();
1918
+ return this.node(t, {
1919
+ kind: c.DIRECTIVE_EXTENSION,
1920
+ name: n,
1921
+ directives: s
1922
+ });
1923
+ }
1900
1924
  /**
1901
1925
  * ```
1902
1926
  * DirectiveDefinition :
@@ -1906,16 +1930,17 @@ class qe {
1906
1930
  parseDirectiveDefinition() {
1907
1931
  const t = this._lexer.token, n = this.parseDescription();
1908
1932
  this.expectKeyword("directive"), this.expectToken(o.AT);
1909
- const s = this.parseName(), i = this.parseArgumentDefs(), r = this.expectOptionalKeyword("repeatable");
1933
+ const s = this.parseName(), i = this.parseArgumentDefs(), r = this._options.experimentalDirectivesOnDirectiveDefinitions ? this.parseConstDirectives() : [], a = this.expectOptionalKeyword("repeatable");
1910
1934
  this.expectKeyword("on");
1911
- const a = this.parseDirectiveLocations();
1935
+ const l = this.parseDirectiveLocations();
1912
1936
  return this.node(t, {
1913
1937
  kind: c.DIRECTIVE_DEFINITION,
1914
1938
  description: n,
1915
1939
  name: s,
1916
1940
  arguments: i,
1917
- repeatable: r,
1918
- locations: a
1941
+ directives: r,
1942
+ repeatable: a,
1943
+ locations: l
1919
1944
  });
1920
1945
  }
1921
1946
  /**
@@ -1952,6 +1977,7 @@ class qe {
1952
1977
  * `ENUM_VALUE`
1953
1978
  * `INPUT_OBJECT`
1954
1979
  * `INPUT_FIELD_DEFINITION`
1980
+ * `DIRECTIVE_DEFINITION`
1955
1981
  */
1956
1982
  parseDirectiveLocation() {
1957
1983
  const t = this._lexer.token, n = this.parseName();
@@ -2139,49 +2165,49 @@ function g(e) {
2139
2165
  function re(e) {
2140
2166
  return Pe(e) ? `"${e}"` : e;
2141
2167
  }
2142
- const Xe = Object.freeze({});
2168
+ const qe = Object.freeze({});
2143
2169
  function ze(e, t, n = ee) {
2144
2170
  const s = /* @__PURE__ */ new Map();
2145
2171
  for (const y of Object.values(c))
2146
2172
  s.set(y, He(t, y));
2147
- let i, r = Array.isArray(e), a = [e], p = -1, l = [], u = e, h, d;
2148
- const f = [], A = [];
2173
+ let i, r = Array.isArray(e), a = [e], l = -1, p = [], u = e, h, d;
2174
+ const f = [], x = [];
2149
2175
  do {
2150
- p++;
2151
- const y = p === a.length, C = y && l.length !== 0;
2176
+ l++;
2177
+ const y = l === a.length, C = y && p.length !== 0;
2152
2178
  if (y) {
2153
- if (h = A.length === 0 ? void 0 : f[f.length - 1], u = d, d = A.pop(), C)
2179
+ if (h = x.length === 0 ? void 0 : f[f.length - 1], u = d, d = x.pop(), C)
2154
2180
  if (r) {
2155
2181
  u = u.slice();
2156
- let O = 0;
2157
- for (const [F, j] of l) {
2158
- const G = F - O;
2159
- j === null ? (u.splice(G, 1), O++) : u[G] = j;
2182
+ let A = 0;
2183
+ for (const [F, j] of p) {
2184
+ const G = F - A;
2185
+ j === null ? (u.splice(G, 1), A++) : u[G] = j;
2160
2186
  }
2161
2187
  } else {
2162
2188
  u = { ...u };
2163
- for (const [O, F] of l)
2164
- u[O] = F;
2189
+ for (const [A, F] of p)
2190
+ u[A] = F;
2165
2191
  }
2166
- p = i.index, a = i.keys, l = i.edits, r = i.inArray, i = i.prev;
2192
+ l = i.index, a = i.keys, p = i.edits, r = i.inArray, i = i.prev;
2167
2193
  } else if (d) {
2168
- if (h = r ? p : a[p], u = d[h], u == null)
2194
+ if (h = r ? l : a[l], u = d[h], u == null)
2169
2195
  continue;
2170
2196
  f.push(h);
2171
2197
  }
2172
2198
  let I;
2173
2199
  if (!Array.isArray(u)) {
2174
2200
  var E, N;
2175
- Q(u) || b(!1, `Invalid AST Node: ${B(u)}.`);
2176
- const O = y ? (E = s.get(u.kind)) === null || E === void 0 ? void 0 : E.leave : (N = s.get(u.kind)) === null || N === void 0 ? void 0 : N.enter;
2177
- if (I = O?.call(t, u, h, d, f, A), I === Xe)
2201
+ Q(u) || b(!1, `Invalid AST Node: ${V(u)}.`);
2202
+ const A = y ? (E = s.get(u.kind)) === null || E === void 0 ? void 0 : E.leave : (N = s.get(u.kind)) === null || N === void 0 ? void 0 : N.enter;
2203
+ if (I = A?.call(t, u, h, d, f, x), I === qe)
2178
2204
  break;
2179
2205
  if (I === !1) {
2180
2206
  if (!y) {
2181
2207
  f.pop();
2182
2208
  continue;
2183
2209
  }
2184
- } else if (I !== void 0 && (l.push([h, I]), !y))
2210
+ } else if (I !== void 0 && (p.push([h, I]), !y))
2185
2211
  if (Q(I))
2186
2212
  u = I;
2187
2213
  else {
@@ -2189,20 +2215,20 @@ function ze(e, t, n = ee) {
2189
2215
  continue;
2190
2216
  }
2191
2217
  }
2192
- if (I === void 0 && C && l.push([h, u]), y)
2218
+ if (I === void 0 && C && p.push([h, u]), y)
2193
2219
  f.pop();
2194
2220
  else {
2195
2221
  var S;
2196
2222
  i = {
2197
2223
  inArray: r,
2198
- index: p,
2224
+ index: l,
2199
2225
  keys: a,
2200
- edits: l,
2226
+ edits: p,
2201
2227
  prev: i
2202
- }, r = Array.isArray(u), a = r ? u : (S = n[u.kind]) !== null && S !== void 0 ? S : [], p = -1, l = [], d && A.push(d), d = u;
2228
+ }, r = Array.isArray(u), a = r ? u : (S = n[u.kind]) !== null && S !== void 0 ? S : [], l = -1, p = [], d && x.push(d), d = u;
2203
2229
  }
2204
2230
  } while (i !== void 0);
2205
- return l.length !== 0 ? l[l.length - 1][1] : e;
2231
+ return p.length !== 0 ? p[p.length - 1][1] : e;
2206
2232
  }
2207
2233
  function He(e, t) {
2208
2234
  const n = e[t];
@@ -2246,22 +2272,22 @@ const We = (e) => e.operation.operation.toLowerCase(), Ze = (e) => e.path.typena
2246
2272
  subscription: "read"
2247
2273
  },
2248
2274
  fieldPermissions: s = {},
2249
- abilityBuilder: i = X,
2275
+ abilityBuilder: i = q,
2250
2276
  debug: r = !1
2251
2277
  } = e;
2252
- return async (a, p, l, u, h) => {
2278
+ return async (a, l, p, u, h) => {
2253
2279
  u.ability || (u.ability = await z(u.user, i));
2254
- const d = We(h), f = Ze(h), A = n[d] || d, E = h.parentType.name, N = t[E] || E;
2255
- if (r && console.log(`Checking permission: ${A} on ${N} at ${f}`), s[f] && !s[f].some(
2280
+ const d = We(h), f = Ze(h), x = n[d] || d, E = h.parentType.name, N = t[E] || E;
2281
+ if (r && console.log(`Checking permission: ${x} on ${N} at ${f}`), s[f] && !s[f].some(
2256
2282
  (I) => (
2257
2283
  // Don't pass resolver args here - only use them if the permission defines conditions
2258
2284
  P(u, I.action, I.subject, I.conditions)
2259
2285
  )
2260
2286
  ))
2261
2287
  throw new $(`Access denied for field ${f}`);
2262
- if (!P(u, A, N))
2263
- throw new $(`Access denied for ${A} on ${N}`);
2264
- if (d === "mutation" && l.input) {
2288
+ if (!P(u, x, N))
2289
+ throw new $(`Access denied for ${x} on ${N}`);
2290
+ if (d === "mutation" && p.input) {
2265
2291
  const y = h.operation.loc?.source.body;
2266
2292
  if (y) {
2267
2293
  const C = Ke(y);
@@ -2269,7 +2295,7 @@ const We = (e) => e.operation.operation.toLowerCase(), Ze = (e) => e.path.typena
2269
2295
  !P(u, "update", N, { field: I }) && r && console.warn(`Warning: Field ${I} update not explicitly allowed`);
2270
2296
  }
2271
2297
  }
2272
- return a(p, l, u, h);
2298
+ return a(l, p, u, h);
2273
2299
  };
2274
2300
  }, st = ue((e) => {
2275
2301
  const {
@@ -2315,9 +2341,9 @@ const We = (e) => e.operation.operation.toLowerCase(), Ze = (e) => e.path.typena
2315
2341
  Mutation: {
2316
2342
  plans: {
2317
2343
  async createAbility(i, r) {
2318
- const a = r.getRaw().input, p = a.userId, l = a.roles;
2344
+ const a = r.getRaw().input, l = a.userId, p = a.roles;
2319
2345
  return s(
2320
- [p, l],
2346
+ [l, p],
2321
2347
  async ([u, h]) => {
2322
2348
  try {
2323
2349
  return {