@powerhousedao/workflow 6.2.3-dev.43 → 6.2.3-dev.45

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.
Files changed (233) hide show
  1. package/dist/browser/{BlockSelector-C-C56Wcf.js → BlockSelector-B41mSc0W.js} +431 -411
  2. package/dist/browser/BlockSelector-B41mSc0W.js.map +1 -0
  3. package/dist/browser/assets/{entry-KqlcH_wb.js → entry-CtB3hwiW.js} +99 -3
  4. package/dist/browser/assets/{projection-entry-DD5A5lZY.js → projection-entry-Cd33KgnS.js} +2 -3
  5. package/dist/browser/{connection-BUum0hJI.js → connection-BP17lpt3.js} +2 -2
  6. package/dist/browser/{connection-BUum0hJI.js.map → connection-BP17lpt3.js.map} +1 -1
  7. package/dist/browser/{connection-form-C9iDnI6H.js → connection-form-CkRzKggD.js} +524 -13
  8. package/dist/browser/connection-form-CkRzKggD.js.map +1 -0
  9. package/dist/browser/{data-tree-B4W7ZUmG.js → data-tree-BugZMgLk.js} +2 -2
  10. package/dist/browser/{data-tree-B4W7ZUmG.js.map → data-tree-BugZMgLk.js.map} +1 -1
  11. package/dist/browser/document-models/connection/index.js +3 -3
  12. package/dist/browser/document-models/index.js +3 -3
  13. package/dist/browser/document-models/workflow/index.js +2 -2
  14. package/dist/browser/{document-models-C1ZgIZyV.js → document-models-B7IwLbfO.js} +3 -3
  15. package/dist/browser/{document-models-C1ZgIZyV.js.map → document-models-B7IwLbfO.js.map} +1 -1
  16. package/dist/browser/{editor-cEmJfc9W.js → editor-9eSmoDTm.js} +331 -39
  17. package/dist/browser/editor-9eSmoDTm.js.map +1 -0
  18. package/dist/browser/{editor-4BJf6hN7.js → editor-DvK4LPwF.js} +7 -10
  19. package/dist/browser/editor-DvK4LPwF.js.map +1 -0
  20. package/dist/browser/{editor-Crt3ZeGd.js → editor-ldDYxtLV.js} +166 -43
  21. package/dist/browser/editor-ldDYxtLV.js.map +1 -0
  22. package/dist/browser/editors/connection-editor/module.js +1 -1
  23. package/dist/browser/editors/workflow-editor/module.js +1 -1
  24. package/dist/browser/editors/workflow-studio/module.js +1 -1
  25. package/dist/browser/graphql-Cr1ia6fo.js +2474 -0
  26. package/dist/browser/graphql-Cr1ia6fo.js.map +1 -0
  27. package/dist/browser/index.js +9 -5
  28. package/dist/browser/index.js.map +1 -1
  29. package/dist/browser/{module-jDZ4pq3W.js → module-B2BMwu5E.js} +129 -17
  30. package/dist/browser/module-B2BMwu5E.js.map +1 -0
  31. package/dist/browser/{module-DU2vb3FH.js → module-D4UiG9ii.js} +13 -5
  32. package/dist/browser/module-D4UiG9ii.js.map +1 -0
  33. package/dist/browser/reactor/index.js +2 -2
  34. package/dist/browser/{runtime-queries-Ds2kk-Ow.js → runtime-queries-IZG_nonR.js} +85 -11
  35. package/dist/browser/runtime-queries-IZG_nonR.js.map +1 -0
  36. package/dist/browser/{trigger-text-5CT870cu.js → trigger-text-C37YRggR.js} +142 -20
  37. package/dist/browser/trigger-text-C37YRggR.js.map +1 -0
  38. package/dist/browser/upgrade-manifests-C_9cyumV.js +8 -0
  39. package/dist/browser/{upgrade-manifests-BpakVE9l.js.map → upgrade-manifests-C_9cyumV.js.map} +1 -1
  40. package/dist/browser/{workflow-BxShRhVy.js → workflow-DFLQ2cFr.js} +2 -2
  41. package/dist/browser/{workflow-BxShRhVy.js.map → workflow-DFLQ2cFr.js.map} +1 -1
  42. package/dist/node/{BlockSelector-C9_1wbx4.mjs → BlockSelector-BMnBzXcA.mjs} +431 -411
  43. package/dist/node/BlockSelector-BMnBzXcA.mjs.map +1 -0
  44. package/dist/node/{connection-D544oqVW.mjs → connection-BxJoL8js.mjs} +2 -2
  45. package/dist/node/{connection-D544oqVW.mjs.map → connection-BxJoL8js.mjs.map} +1 -1
  46. package/dist/node/{connection-form-DUOXUqBz.mjs → connection-form-DZFudcoD.mjs} +524 -13
  47. package/dist/node/connection-form-DZFudcoD.mjs.map +1 -0
  48. package/dist/node/{data-tree-CoV-swZZ.mjs → data-tree-CR8IOshA.mjs} +2 -2
  49. package/dist/node/{data-tree-CoV-swZZ.mjs.map → data-tree-CR8IOshA.mjs.map} +1 -1
  50. package/dist/node/document-models/connection/index.mjs +3 -3
  51. package/dist/node/document-models/index.mjs +3 -3
  52. package/dist/node/document-models/workflow/index.mjs +2 -2
  53. package/dist/node/{editor-BFDE4Q3v.mjs → editor-BV5CYmUI.mjs} +7 -10
  54. package/dist/node/editor-BV5CYmUI.mjs.map +1 -0
  55. package/dist/node/{editor-D2jRtRNl.mjs → editor-D_P9-st9.mjs} +166 -43
  56. package/dist/node/editor-D_P9-st9.mjs.map +1 -0
  57. package/dist/node/{editor-BwOQIwVw.mjs → editor-NUaiiO4B.mjs} +331 -39
  58. package/dist/node/editor-NUaiiO4B.mjs.map +1 -0
  59. package/dist/node/editors/connection-editor/module.mjs +1 -1
  60. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  61. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  62. package/dist/node/graphql-BGVLRhC1.mjs +14554 -0
  63. package/dist/node/graphql-BGVLRhC1.mjs.map +1 -0
  64. package/dist/node/index.mjs +9 -6
  65. package/dist/node/index.mjs.map +1 -1
  66. package/dist/node/{module-BMwJQh65.mjs → module-BlT-atBQ.mjs} +129 -17
  67. package/dist/node/module-BlT-atBQ.mjs.map +1 -0
  68. package/dist/node/{module-Dhe5E-VA.mjs → module-BsqRZox1.mjs} +13 -5
  69. package/dist/node/module-BsqRZox1.mjs.map +1 -0
  70. package/dist/node/pieces/reactor/descriptor.json +34 -17
  71. package/dist/node/pieces/reactor/index.mjs +67 -67
  72. package/dist/node/pieces/reactor/package.json +1 -1
  73. package/dist/node/{runtime-queries-D5EGaCrH.mjs → runtime-queries-BM6I7dDA.mjs} +85 -11
  74. package/dist/node/runtime-queries-BM6I7dDA.mjs.map +1 -0
  75. package/dist/node/{trigger-text-CXnnanWC.mjs → trigger-text-78ZhfT-b.mjs} +142 -20
  76. package/dist/node/trigger-text-78ZhfT-b.mjs.map +1 -0
  77. package/dist/node/upgrade-manifests-CYZfts3a.mjs +8 -0
  78. package/dist/node/{upgrade-manifests-CmNd742Y.mjs.map → upgrade-manifests-CYZfts3a.mjs.map} +1 -1
  79. package/dist/node/{workflow-CGzYGZnr.mjs → workflow-BpfdBHyS.mjs} +2 -2
  80. package/dist/node/{workflow-CGzYGZnr.mjs.map → workflow-BpfdBHyS.mjs.map} +1 -1
  81. package/dist/powerhouse.manifest.json +1 -1
  82. package/dist/style.css +44 -0
  83. package/dist/types/ai/workflow-tools.d.ts.map +1 -1
  84. package/dist/types/document-models/connection/v1/gen/config/error.d.ts +15 -1
  85. package/dist/types/document-models/connection/v1/gen/config/error.d.ts.map +1 -1
  86. package/dist/types/document-models/connection/v1/gen/connection/error.d.ts +13 -1
  87. package/dist/types/document-models/connection/v1/gen/connection/error.d.ts.map +1 -1
  88. package/dist/types/document-models/connection/v1/gen/document-model.d.ts.map +1 -1
  89. package/dist/types/document-models/connection/v1/gen/reducer.d.ts.map +1 -1
  90. package/dist/types/document-models/connection/v1/gen/schema/types.d.ts +11 -2
  91. package/dist/types/document-models/connection/v1/gen/schema/types.d.ts.map +1 -1
  92. package/dist/types/document-models/connection/v1/gen/schema/zod.d.ts +3 -1
  93. package/dist/types/document-models/connection/v1/gen/schema/zod.d.ts.map +1 -1
  94. package/dist/types/document-models/connection/v1/src/reactor-connection.d.ts +17 -0
  95. package/dist/types/document-models/connection/v1/src/reactor-connection.d.ts.map +1 -0
  96. package/dist/types/document-models/connection/v1/src/reducers/config.d.ts.map +1 -1
  97. package/dist/types/document-models/connection/v1/src/reducers/connection.d.ts.map +1 -1
  98. package/dist/types/document-models/connection/v1/src/utils.d.ts +1 -1
  99. package/dist/types/document-models/connection/v1/src/utils.d.ts.map +1 -1
  100. package/dist/types/document-models/connection/v1/tests/reactor-connection.test.d.ts +2 -0
  101. package/dist/types/document-models/connection/v1/tests/reactor-connection.test.d.ts.map +1 -0
  102. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts +7 -0
  103. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts.map +1 -1
  104. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts.map +1 -1
  105. package/dist/types/document-models/workflow/v1/src/reducers/steps.d.ts.map +1 -1
  106. package/dist/types/document-models/workflow/v1/src/reducers/trigger.d.ts.map +1 -1
  107. package/dist/types/document-models/workflow/v1/tests/reactor-connection.test.d.ts +2 -0
  108. package/dist/types/document-models/workflow/v1/tests/reactor-connection.test.d.ts.map +1 -0
  109. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts +1 -1
  110. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts.map +1 -1
  111. package/dist/types/editors/connection-editor/ReactorBindings.d.ts +6 -0
  112. package/dist/types/editors/connection-editor/ReactorBindings.d.ts.map +1 -0
  113. package/dist/types/editors/connection-editor/ReactorConnectionSettings.d.ts +7 -0
  114. package/dist/types/editors/connection-editor/ReactorConnectionSettings.d.ts.map +1 -0
  115. package/dist/types/editors/connection-editor/connection-callbacks.d.ts.map +1 -1
  116. package/dist/types/editors/connection-editor/connection-form.d.ts +4 -1
  117. package/dist/types/editors/connection-editor/connection-form.d.ts.map +1 -1
  118. package/dist/types/editors/connection-editor/connection-usage.d.ts +13 -3
  119. package/dist/types/editors/connection-editor/connection-usage.d.ts.map +1 -1
  120. package/dist/types/editors/connection-editor/editor.d.ts.map +1 -1
  121. package/dist/types/editors/connection-editor/status.d.ts.map +1 -1
  122. package/dist/types/editors/shared/data-viewer.d.ts.map +1 -1
  123. package/dist/types/editors/shared/document-ref.d.ts +5 -0
  124. package/dist/types/editors/shared/document-ref.d.ts.map +1 -0
  125. package/dist/types/editors/workflow-editor/document/useWorkflowModel.d.ts.map +1 -1
  126. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  127. package/dist/types/editors/workflow-editor/reactor-hooks.d.ts +25 -0
  128. package/dist/types/editors/workflow-editor/reactor-hooks.d.ts.map +1 -0
  129. package/dist/types/editors/workflow-editor/runtime-client.d.ts +16 -1
  130. package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
  131. package/dist/types/editors/workflow-editor/runtime-persist.d.ts +1 -1
  132. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts.map +1 -1
  133. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +3 -0
  134. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
  135. package/dist/types/editors/workflow-editor/ui/PublishControls.d.ts +13 -0
  136. package/dist/types/editors/workflow-editor/ui/PublishControls.d.ts.map +1 -1
  137. package/dist/types/editors/workflow-editor/ui/ReactorConnectionField.d.ts +9 -0
  138. package/dist/types/editors/workflow-editor/ui/ReactorConnectionField.d.ts.map +1 -0
  139. package/dist/types/editors/workflow-editor/ui/SignInPrompt.d.ts +6 -0
  140. package/dist/types/editors/workflow-editor/ui/SignInPrompt.d.ts.map +1 -0
  141. package/dist/types/editors/workflow-editor/ui/StepError.d.ts +4 -0
  142. package/dist/types/editors/workflow-editor/ui/StepError.d.ts.map +1 -0
  143. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts +1 -0
  144. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
  145. package/dist/types/editors/workflow-editor/ui/SwitchboardGrants.d.ts +2 -0
  146. package/dist/types/editors/workflow-editor/ui/SwitchboardGrants.d.ts.map +1 -0
  147. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
  148. package/dist/types/editors/workflow-editor/ui/design-time.d.ts +1 -0
  149. package/dist/types/editors/workflow-editor/ui/design-time.d.ts.map +1 -1
  150. package/dist/types/editors/workflow-editor/ui/document-options.d.ts +24 -0
  151. package/dist/types/editors/workflow-editor/ui/document-options.d.ts.map +1 -0
  152. package/dist/types/editors/workflow-editor/ui/document-options.test.d.ts +2 -0
  153. package/dist/types/editors/workflow-editor/ui/document-options.test.d.ts.map +1 -0
  154. package/dist/types/editors/workflow-editor/ui/document-shape.d.ts +8 -0
  155. package/dist/types/editors/workflow-editor/ui/document-shape.d.ts.map +1 -0
  156. package/dist/types/editors/workflow-editor/ui/document-shape.test.d.ts +2 -0
  157. package/dist/types/editors/workflow-editor/ui/document-shape.test.d.ts.map +1 -0
  158. package/dist/types/editors/workflow-editor/ui/expression-scope.d.ts +2 -0
  159. package/dist/types/editors/workflow-editor/ui/expression-scope.d.ts.map +1 -1
  160. package/dist/types/editors/workflow-editor/ui/forms.d.ts +5 -1
  161. package/dist/types/editors/workflow-editor/ui/forms.d.ts.map +1 -1
  162. package/dist/types/editors/workflow-editor/ui/model.d.ts +14 -0
  163. package/dist/types/editors/workflow-editor/ui/model.d.ts.map +1 -1
  164. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts +6 -3
  165. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts.map +1 -1
  166. package/dist/types/editors/workflow-editor/ui/reactor-access.d.ts +43 -0
  167. package/dist/types/editors/workflow-editor/ui/reactor-access.d.ts.map +1 -0
  168. package/dist/types/editors/workflow-editor/ui/reactor-access.test.d.ts +2 -0
  169. package/dist/types/editors/workflow-editor/ui/reactor-access.test.d.ts.map +1 -0
  170. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.d.ts +2 -0
  171. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.d.ts.map +1 -0
  172. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.test.d.ts +2 -0
  173. package/dist/types/editors/workflow-editor/ui/reactor-connection-create.test.d.ts.map +1 -0
  174. package/dist/types/editors/workflow-editor/ui/reactor-view.d.ts +25 -0
  175. package/dist/types/editors/workflow-editor/ui/reactor-view.d.ts.map +1 -0
  176. package/dist/types/editors/workflow-editor/ui/reactor-view.test.d.ts +2 -0
  177. package/dist/types/editors/workflow-editor/ui/reactor-view.test.d.ts.map +1 -0
  178. package/dist/types/editors/workflow-editor/ui/use-validity.d.ts +1 -0
  179. package/dist/types/editors/workflow-editor/ui/use-validity.d.ts.map +1 -1
  180. package/dist/types/editors/workflow-editor/ui/validation.d.ts +3 -1
  181. package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -1
  182. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
  183. package/dist/types/pieces/reactor/index.d.ts.map +1 -1
  184. package/dist/types/pieces/reactor/lib/actions/document-create.d.ts +4 -3
  185. package/dist/types/pieces/reactor/lib/actions/document-create.d.ts.map +1 -1
  186. package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts +2 -2
  187. package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts.map +1 -1
  188. package/dist/types/pieces/reactor/lib/actions/document-find.d.ts +3 -2
  189. package/dist/types/pieces/reactor/lib/actions/document-find.d.ts.map +1 -1
  190. package/dist/types/pieces/reactor/lib/actions/document-get.d.ts +2 -2
  191. package/dist/types/pieces/reactor/lib/actions/document-get.d.ts.map +1 -1
  192. package/dist/types/pieces/reactor/lib/actions/document-schema.d.ts +2 -2
  193. package/dist/types/pieces/reactor/lib/actions/document-schema.d.ts.map +1 -1
  194. package/dist/types/pieces/reactor/lib/actions/document-types.d.ts +1 -1
  195. package/dist/types/pieces/reactor/lib/actions/document-types.d.ts.map +1 -1
  196. package/dist/types/pieces/reactor/lib/documents.d.ts +32 -0
  197. package/dist/types/pieces/reactor/lib/documents.d.ts.map +1 -0
  198. package/dist/types/pieces/reactor/lib/parse.d.ts.map +1 -1
  199. package/dist/types/pieces/reactor/lib/reactor.d.ts +15 -4
  200. package/dist/types/pieces/reactor/lib/reactor.d.ts.map +1 -1
  201. package/dist/types/pieces/reactor/lib/triggers/document-event.d.ts +6 -6
  202. package/dist/types/pieces/reactor/lib/triggers/document-event.d.ts.map +1 -1
  203. package/dist/types/pieces/reactor/reactor.test.d.ts +2 -0
  204. package/dist/types/pieces/reactor/reactor.test.d.ts.map +1 -0
  205. package/dist/types/pieces/reactor/test-signer.d.ts +3 -0
  206. package/dist/types/pieces/reactor/test-signer.d.ts.map +1 -0
  207. package/dist/types/scripts/ui-stack.d.ts +4 -1
  208. package/dist/types/scripts/ui-stack.d.ts.map +1 -1
  209. package/dist/types/test/ui/reactor-connection.spec.d.ts +2 -0
  210. package/dist/types/test/ui/reactor-connection.spec.d.ts.map +1 -0
  211. package/package.json +8 -8
  212. package/dist/browser/BlockSelector-C-C56Wcf.js.map +0 -1
  213. package/dist/browser/connection-form-C9iDnI6H.js.map +0 -1
  214. package/dist/browser/editor-4BJf6hN7.js.map +0 -1
  215. package/dist/browser/editor-Crt3ZeGd.js.map +0 -1
  216. package/dist/browser/editor-cEmJfc9W.js.map +0 -1
  217. package/dist/browser/module-DU2vb3FH.js.map +0 -1
  218. package/dist/browser/module-jDZ4pq3W.js.map +0 -1
  219. package/dist/browser/runtime-queries-Ds2kk-Ow.js.map +0 -1
  220. package/dist/browser/trigger-text-5CT870cu.js.map +0 -1
  221. package/dist/browser/upgrade-manifests-BpakVE9l.js +0 -8
  222. package/dist/node/BlockSelector-C9_1wbx4.mjs.map +0 -1
  223. package/dist/node/connection-form-DUOXUqBz.mjs.map +0 -1
  224. package/dist/node/editor-BFDE4Q3v.mjs.map +0 -1
  225. package/dist/node/editor-BwOQIwVw.mjs.map +0 -1
  226. package/dist/node/editor-D2jRtRNl.mjs.map +0 -1
  227. package/dist/node/module-BMwJQh65.mjs.map +0 -1
  228. package/dist/node/module-Dhe5E-VA.mjs.map +0 -1
  229. package/dist/node/runtime-queries-D5EGaCrH.mjs.map +0 -1
  230. package/dist/node/trigger-text-CXnnanWC.mjs.map +0 -1
  231. package/dist/node/upgrade-manifests-CmNd742Y.mjs +0 -8
  232. package/dist/types/pieces/reactor/lib/actions/dispatch-outcome.test.d.ts +0 -2
  233. package/dist/types/pieces/reactor/lib/actions/dispatch-outcome.test.d.ts.map +0 -1
@@ -0,0 +1,2474 @@
1
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/devAssert.mjs
2
+ function devAssert(condition, message) {
3
+ if (!Boolean(condition)) throw new Error(message);
4
+ }
5
+ //#endregion
6
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/isObjectLike.mjs
7
+ /**
8
+ * Return true if `value` is object-like. A value is object-like if it's not
9
+ * `null` and has a `typeof` result of "object".
10
+ */
11
+ function isObjectLike(value) {
12
+ return typeof value == "object" && value !== null;
13
+ }
14
+ //#endregion
15
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/invariant.mjs
16
+ function invariant(condition, message) {
17
+ if (!Boolean(condition)) throw new Error(message != null ? message : "Unexpected invariant triggered.");
18
+ }
19
+ //#endregion
20
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/location.mjs
21
+ const LineRegExp = /\r\n|[\n\r]/g;
22
+ /**
23
+ * Represents a location in a Source.
24
+ */
25
+ /**
26
+ * Takes a Source and a UTF-8 character offset, and returns the corresponding
27
+ * line and column as a SourceLocation.
28
+ */
29
+ function getLocation(source, position) {
30
+ let lastLineStart = 0;
31
+ let line = 1;
32
+ for (const match of source.body.matchAll(LineRegExp)) {
33
+ typeof match.index === "number" || invariant(false);
34
+ if (match.index >= position) break;
35
+ lastLineStart = match.index + match[0].length;
36
+ line += 1;
37
+ }
38
+ return {
39
+ line,
40
+ column: position + 1 - lastLineStart
41
+ };
42
+ }
43
+ //#endregion
44
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/printLocation.mjs
45
+ /**
46
+ * Render a helpful description of the location in the GraphQL Source document.
47
+ */
48
+ function printLocation(location) {
49
+ return printSourceLocation(location.source, getLocation(location.source, location.start));
50
+ }
51
+ /**
52
+ * Render a helpful description of the location in the GraphQL Source document.
53
+ */
54
+ function printSourceLocation(source, sourceLocation) {
55
+ const firstLineColumnOffset = source.locationOffset.column - 1;
56
+ const body = "".padStart(firstLineColumnOffset) + source.body;
57
+ const lineIndex = sourceLocation.line - 1;
58
+ const lineOffset = source.locationOffset.line - 1;
59
+ const lineNum = sourceLocation.line + lineOffset;
60
+ const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
61
+ const columnNum = sourceLocation.column + columnOffset;
62
+ const locationStr = `${source.name}:${lineNum}:${columnNum}\n`;
63
+ const lines = body.split(/\r\n|[\n\r]/g);
64
+ const locationLine = lines[lineIndex];
65
+ if (locationLine.length > 120) {
66
+ const subLineIndex = Math.floor(columnNum / 80);
67
+ const subLineColumnNum = columnNum % 80;
68
+ const subLines = [];
69
+ for (let i = 0; i < locationLine.length; i += 80) subLines.push(locationLine.slice(i, i + 80));
70
+ return locationStr + printPrefixedLines([
71
+ [`${lineNum} |`, subLines[0]],
72
+ ...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
73
+ ["|", "^".padStart(subLineColumnNum)],
74
+ ["|", subLines[subLineIndex + 1]]
75
+ ]);
76
+ }
77
+ return locationStr + printPrefixedLines([
78
+ [`${lineNum - 1} |`, lines[lineIndex - 1]],
79
+ [`${lineNum} |`, locationLine],
80
+ ["|", "^".padStart(columnNum)],
81
+ [`${lineNum + 1} |`, lines[lineIndex + 1]]
82
+ ]);
83
+ }
84
+ function printPrefixedLines(lines) {
85
+ const existingLines = lines.filter(([_, line]) => line !== void 0);
86
+ const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
87
+ return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
88
+ }
89
+ //#endregion
90
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/error/GraphQLError.mjs
91
+ function toNormalizedOptions(args) {
92
+ const firstArg = args[0];
93
+ if (firstArg == null || "kind" in firstArg || "length" in firstArg) return {
94
+ nodes: firstArg,
95
+ source: args[1],
96
+ positions: args[2],
97
+ path: args[3],
98
+ originalError: args[4],
99
+ extensions: args[5]
100
+ };
101
+ return firstArg;
102
+ }
103
+ /**
104
+ * A GraphQLError describes an Error found during the parse, validate, or
105
+ * execute phases of performing a GraphQL operation. In addition to a message
106
+ * and stack trace, it also includes information about the locations in a
107
+ * GraphQL document and/or execution result that correspond to the Error.
108
+ */
109
+ var GraphQLError = class GraphQLError extends Error {
110
+ /**
111
+ * An array of `{ line, column }` locations within the source GraphQL document
112
+ * which correspond to this error.
113
+ *
114
+ * Errors during validation often contain multiple locations, for example to
115
+ * point out two things with the same name. Errors during execution include a
116
+ * single location, the field which produced the error.
117
+ *
118
+ * Enumerable, and appears in the result of JSON.stringify().
119
+ */
120
+ /**
121
+ * An array describing the JSON-path into the execution response which
122
+ * corresponds to this error. Only included for errors during execution.
123
+ *
124
+ * Enumerable, and appears in the result of JSON.stringify().
125
+ */
126
+ /**
127
+ * An array of GraphQL AST Nodes corresponding to this error.
128
+ */
129
+ /**
130
+ * The source GraphQL document for the first location of this error.
131
+ *
132
+ * Note that if this Error represents more than one node, the source may not
133
+ * represent nodes after the first node.
134
+ */
135
+ /**
136
+ * An array of character offsets within the source GraphQL document
137
+ * which correspond to this error.
138
+ */
139
+ /**
140
+ * The original error thrown from a field resolver during execution.
141
+ */
142
+ /**
143
+ * Extension fields to add to the formatted error.
144
+ */
145
+ /**
146
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
147
+ */
148
+ constructor(message, ...rawArgs) {
149
+ var _this$nodes, _nodeLocations$, _ref;
150
+ const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
151
+ super(message);
152
+ this.name = "GraphQLError";
153
+ this.path = path !== null && path !== void 0 ? path : void 0;
154
+ this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
155
+ this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0);
156
+ const nodeLocations = undefinedIfEmpty((_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node) => node.loc).filter((loc) => loc != null));
157
+ this.source = source !== null && source !== void 0 ? source : nodeLocations === null || nodeLocations === void 0 ? void 0 : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === void 0 ? void 0 : _nodeLocations$.source;
158
+ this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
159
+ this.locations = positions && source ? positions.map((pos) => getLocation(source, pos)) : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => getLocation(loc.source, loc.start));
160
+ const originalExtensions = isObjectLike(originalError === null || originalError === void 0 ? void 0 : originalError.extensions) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
161
+ this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : Object.create(null);
162
+ Object.defineProperties(this, {
163
+ message: {
164
+ writable: true,
165
+ enumerable: true
166
+ },
167
+ name: { enumerable: false },
168
+ nodes: { enumerable: false },
169
+ source: { enumerable: false },
170
+ positions: { enumerable: false },
171
+ originalError: { enumerable: false }
172
+ });
173
+ /* c8 ignore start */
174
+ if (originalError !== null && originalError !== void 0 && originalError.stack) Object.defineProperty(this, "stack", {
175
+ value: originalError.stack,
176
+ writable: true,
177
+ configurable: true
178
+ });
179
+ else if (Error.captureStackTrace) Error.captureStackTrace(this, GraphQLError);
180
+ else Object.defineProperty(this, "stack", {
181
+ value: Error().stack,
182
+ writable: true,
183
+ configurable: true
184
+ });
185
+ /* c8 ignore stop */
186
+ }
187
+ get [Symbol.toStringTag]() {
188
+ return "GraphQLError";
189
+ }
190
+ toString() {
191
+ let output = this.message;
192
+ if (this.nodes) {
193
+ for (const node of this.nodes) if (node.loc) output += "\n\n" + printLocation(node.loc);
194
+ } else if (this.source && this.locations) for (const location of this.locations) output += "\n\n" + printSourceLocation(this.source, location);
195
+ return output;
196
+ }
197
+ toJSON() {
198
+ const formattedError = { message: this.message };
199
+ if (this.locations != null) formattedError.locations = this.locations;
200
+ if (this.path != null) formattedError.path = this.path;
201
+ if (this.extensions != null && Object.keys(this.extensions).length > 0) formattedError.extensions = this.extensions;
202
+ return formattedError;
203
+ }
204
+ };
205
+ function undefinedIfEmpty(array) {
206
+ return array === void 0 || array.length === 0 ? void 0 : array;
207
+ }
208
+ //#endregion
209
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/error/syntaxError.mjs
210
+ /**
211
+ * Produces a GraphQLError representing a syntax error, containing useful
212
+ * descriptive information about the syntax error's position in the source.
213
+ */
214
+ function syntaxError(source, position, description) {
215
+ return new GraphQLError(`Syntax Error: ${description}`, {
216
+ source,
217
+ positions: [position]
218
+ });
219
+ }
220
+ //#endregion
221
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/ast.mjs
222
+ /**
223
+ * Contains a range of UTF-8 character offsets and token references that
224
+ * identify the region of the source from which the AST derived.
225
+ */
226
+ var Location = class {
227
+ /**
228
+ * The character offset at which this Node begins.
229
+ */
230
+ /**
231
+ * The character offset at which this Node ends.
232
+ */
233
+ /**
234
+ * The Token at which this Node begins.
235
+ */
236
+ /**
237
+ * The Token at which this Node ends.
238
+ */
239
+ /**
240
+ * The Source document the AST represents.
241
+ */
242
+ constructor(startToken, endToken, source) {
243
+ this.start = startToken.start;
244
+ this.end = endToken.end;
245
+ this.startToken = startToken;
246
+ this.endToken = endToken;
247
+ this.source = source;
248
+ }
249
+ get [Symbol.toStringTag]() {
250
+ return "Location";
251
+ }
252
+ toJSON() {
253
+ return {
254
+ start: this.start,
255
+ end: this.end
256
+ };
257
+ }
258
+ };
259
+ /**
260
+ * Represents a range of characters represented by a lexical token
261
+ * within a Source.
262
+ */
263
+ var Token = class {
264
+ /**
265
+ * The kind of Token.
266
+ */
267
+ /**
268
+ * The character offset at which this Node begins.
269
+ */
270
+ /**
271
+ * The character offset at which this Node ends.
272
+ */
273
+ /**
274
+ * The 1-indexed line number on which this Token appears.
275
+ */
276
+ /**
277
+ * The 1-indexed column number at which this Token begins.
278
+ */
279
+ /**
280
+ * For non-punctuation tokens, represents the interpreted value of the token.
281
+ *
282
+ * Note: is undefined for punctuation tokens, but typed as string for
283
+ * convenience in the parser.
284
+ */
285
+ /**
286
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
287
+ * including ignored tokens. <SOF> is always the first node and <EOF>
288
+ * the last.
289
+ */
290
+ constructor(kind, start, end, line, column, value) {
291
+ this.kind = kind;
292
+ this.start = start;
293
+ this.end = end;
294
+ this.line = line;
295
+ this.column = column;
296
+ this.value = value;
297
+ this.prev = null;
298
+ this.next = null;
299
+ }
300
+ get [Symbol.toStringTag]() {
301
+ return "Token";
302
+ }
303
+ toJSON() {
304
+ return {
305
+ kind: this.kind,
306
+ value: this.value,
307
+ line: this.line,
308
+ column: this.column
309
+ };
310
+ }
311
+ };
312
+ new Set(Object.keys({
313
+ Name: [],
314
+ Document: ["definitions"],
315
+ OperationDefinition: [
316
+ "description",
317
+ "name",
318
+ "variableDefinitions",
319
+ "directives",
320
+ "selectionSet"
321
+ ],
322
+ VariableDefinition: [
323
+ "description",
324
+ "variable",
325
+ "type",
326
+ "defaultValue",
327
+ "directives"
328
+ ],
329
+ Variable: ["name"],
330
+ SelectionSet: ["selections"],
331
+ Field: [
332
+ "alias",
333
+ "name",
334
+ "arguments",
335
+ "directives",
336
+ "selectionSet"
337
+ ],
338
+ Argument: ["name", "value"],
339
+ FragmentSpread: ["name", "directives"],
340
+ InlineFragment: [
341
+ "typeCondition",
342
+ "directives",
343
+ "selectionSet"
344
+ ],
345
+ FragmentDefinition: [
346
+ "description",
347
+ "name",
348
+ "variableDefinitions",
349
+ "typeCondition",
350
+ "directives",
351
+ "selectionSet"
352
+ ],
353
+ IntValue: [],
354
+ FloatValue: [],
355
+ StringValue: [],
356
+ BooleanValue: [],
357
+ NullValue: [],
358
+ EnumValue: [],
359
+ ListValue: ["values"],
360
+ ObjectValue: ["fields"],
361
+ ObjectField: ["name", "value"],
362
+ Directive: ["name", "arguments"],
363
+ NamedType: ["name"],
364
+ ListType: ["type"],
365
+ NonNullType: ["type"],
366
+ SchemaDefinition: [
367
+ "description",
368
+ "directives",
369
+ "operationTypes"
370
+ ],
371
+ OperationTypeDefinition: ["type"],
372
+ ScalarTypeDefinition: [
373
+ "description",
374
+ "name",
375
+ "directives"
376
+ ],
377
+ ObjectTypeDefinition: [
378
+ "description",
379
+ "name",
380
+ "interfaces",
381
+ "directives",
382
+ "fields"
383
+ ],
384
+ FieldDefinition: [
385
+ "description",
386
+ "name",
387
+ "arguments",
388
+ "type",
389
+ "directives"
390
+ ],
391
+ InputValueDefinition: [
392
+ "description",
393
+ "name",
394
+ "type",
395
+ "defaultValue",
396
+ "directives"
397
+ ],
398
+ InterfaceTypeDefinition: [
399
+ "description",
400
+ "name",
401
+ "interfaces",
402
+ "directives",
403
+ "fields"
404
+ ],
405
+ UnionTypeDefinition: [
406
+ "description",
407
+ "name",
408
+ "directives",
409
+ "types"
410
+ ],
411
+ EnumTypeDefinition: [
412
+ "description",
413
+ "name",
414
+ "directives",
415
+ "values"
416
+ ],
417
+ EnumValueDefinition: [
418
+ "description",
419
+ "name",
420
+ "directives"
421
+ ],
422
+ InputObjectTypeDefinition: [
423
+ "description",
424
+ "name",
425
+ "directives",
426
+ "fields"
427
+ ],
428
+ DirectiveDefinition: [
429
+ "description",
430
+ "name",
431
+ "arguments",
432
+ "locations"
433
+ ],
434
+ SchemaExtension: ["directives", "operationTypes"],
435
+ ScalarTypeExtension: ["name", "directives"],
436
+ ObjectTypeExtension: [
437
+ "name",
438
+ "interfaces",
439
+ "directives",
440
+ "fields"
441
+ ],
442
+ InterfaceTypeExtension: [
443
+ "name",
444
+ "interfaces",
445
+ "directives",
446
+ "fields"
447
+ ],
448
+ UnionTypeExtension: [
449
+ "name",
450
+ "directives",
451
+ "types"
452
+ ],
453
+ EnumTypeExtension: [
454
+ "name",
455
+ "directives",
456
+ "values"
457
+ ],
458
+ InputObjectTypeExtension: [
459
+ "name",
460
+ "directives",
461
+ "fields"
462
+ ],
463
+ TypeCoordinate: ["name"],
464
+ MemberCoordinate: ["name", "memberName"],
465
+ ArgumentCoordinate: [
466
+ "name",
467
+ "fieldName",
468
+ "argumentName"
469
+ ],
470
+ DirectiveCoordinate: ["name"],
471
+ DirectiveArgumentCoordinate: ["name", "argumentName"]
472
+ }));
473
+ /** Name */
474
+ var OperationTypeNode;
475
+ (function(OperationTypeNode) {
476
+ OperationTypeNode["QUERY"] = "query";
477
+ OperationTypeNode["MUTATION"] = "mutation";
478
+ OperationTypeNode["SUBSCRIPTION"] = "subscription";
479
+ })(OperationTypeNode || (OperationTypeNode = {}));
480
+ //#endregion
481
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/directiveLocation.mjs
482
+ /**
483
+ * The set of allowed directive location values.
484
+ */
485
+ var DirectiveLocation;
486
+ (function(DirectiveLocation) {
487
+ DirectiveLocation["QUERY"] = "QUERY";
488
+ DirectiveLocation["MUTATION"] = "MUTATION";
489
+ DirectiveLocation["SUBSCRIPTION"] = "SUBSCRIPTION";
490
+ DirectiveLocation["FIELD"] = "FIELD";
491
+ DirectiveLocation["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
492
+ DirectiveLocation["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
493
+ DirectiveLocation["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
494
+ DirectiveLocation["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
495
+ DirectiveLocation["SCHEMA"] = "SCHEMA";
496
+ DirectiveLocation["SCALAR"] = "SCALAR";
497
+ DirectiveLocation["OBJECT"] = "OBJECT";
498
+ DirectiveLocation["FIELD_DEFINITION"] = "FIELD_DEFINITION";
499
+ DirectiveLocation["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
500
+ DirectiveLocation["INTERFACE"] = "INTERFACE";
501
+ DirectiveLocation["UNION"] = "UNION";
502
+ DirectiveLocation["ENUM"] = "ENUM";
503
+ DirectiveLocation["ENUM_VALUE"] = "ENUM_VALUE";
504
+ DirectiveLocation["INPUT_OBJECT"] = "INPUT_OBJECT";
505
+ DirectiveLocation["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
506
+ })(DirectiveLocation || (DirectiveLocation = {}));
507
+ /**
508
+ * The enum type representing the directive location values.
509
+ *
510
+ * @deprecated Please use `DirectiveLocation`. Will be remove in v17.
511
+ */
512
+ //#endregion
513
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/kinds.mjs
514
+ /**
515
+ * The set of allowed kind values for AST nodes.
516
+ */
517
+ var Kind;
518
+ (function(Kind) {
519
+ Kind["NAME"] = "Name";
520
+ Kind["DOCUMENT"] = "Document";
521
+ Kind["OPERATION_DEFINITION"] = "OperationDefinition";
522
+ Kind["VARIABLE_DEFINITION"] = "VariableDefinition";
523
+ Kind["SELECTION_SET"] = "SelectionSet";
524
+ Kind["FIELD"] = "Field";
525
+ Kind["ARGUMENT"] = "Argument";
526
+ Kind["FRAGMENT_SPREAD"] = "FragmentSpread";
527
+ Kind["INLINE_FRAGMENT"] = "InlineFragment";
528
+ Kind["FRAGMENT_DEFINITION"] = "FragmentDefinition";
529
+ Kind["VARIABLE"] = "Variable";
530
+ Kind["INT"] = "IntValue";
531
+ Kind["FLOAT"] = "FloatValue";
532
+ Kind["STRING"] = "StringValue";
533
+ Kind["BOOLEAN"] = "BooleanValue";
534
+ Kind["NULL"] = "NullValue";
535
+ Kind["ENUM"] = "EnumValue";
536
+ Kind["LIST"] = "ListValue";
537
+ Kind["OBJECT"] = "ObjectValue";
538
+ Kind["OBJECT_FIELD"] = "ObjectField";
539
+ Kind["DIRECTIVE"] = "Directive";
540
+ Kind["NAMED_TYPE"] = "NamedType";
541
+ Kind["LIST_TYPE"] = "ListType";
542
+ Kind["NON_NULL_TYPE"] = "NonNullType";
543
+ Kind["SCHEMA_DEFINITION"] = "SchemaDefinition";
544
+ Kind["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
545
+ Kind["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
546
+ Kind["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
547
+ Kind["FIELD_DEFINITION"] = "FieldDefinition";
548
+ Kind["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
549
+ Kind["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
550
+ Kind["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
551
+ Kind["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
552
+ Kind["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
553
+ Kind["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
554
+ Kind["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
555
+ Kind["SCHEMA_EXTENSION"] = "SchemaExtension";
556
+ Kind["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
557
+ Kind["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
558
+ Kind["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
559
+ Kind["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
560
+ Kind["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
561
+ Kind["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
562
+ Kind["TYPE_COORDINATE"] = "TypeCoordinate";
563
+ Kind["MEMBER_COORDINATE"] = "MemberCoordinate";
564
+ Kind["ARGUMENT_COORDINATE"] = "ArgumentCoordinate";
565
+ Kind["DIRECTIVE_COORDINATE"] = "DirectiveCoordinate";
566
+ Kind["DIRECTIVE_ARGUMENT_COORDINATE"] = "DirectiveArgumentCoordinate";
567
+ })(Kind || (Kind = {}));
568
+ /**
569
+ * The enum type representing the possible kind values of AST nodes.
570
+ *
571
+ * @deprecated Please use `Kind`. Will be remove in v17.
572
+ */
573
+ //#endregion
574
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/characterClasses.mjs
575
+ /**
576
+ * ```
577
+ * WhiteSpace ::
578
+ * - "Horizontal Tab (U+0009)"
579
+ * - "Space (U+0020)"
580
+ * ```
581
+ * @internal
582
+ */
583
+ function isWhiteSpace(code) {
584
+ return code === 9 || code === 32;
585
+ }
586
+ /**
587
+ * ```
588
+ * Digit :: one of
589
+ * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
590
+ * ```
591
+ * @internal
592
+ */
593
+ function isDigit(code) {
594
+ return code >= 48 && code <= 57;
595
+ }
596
+ /**
597
+ * ```
598
+ * Letter :: one of
599
+ * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
600
+ * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
601
+ * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
602
+ * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
603
+ * ```
604
+ * @internal
605
+ */
606
+ function isLetter(code) {
607
+ return code >= 97 && code <= 122 || code >= 65 && code <= 90;
608
+ }
609
+ /**
610
+ * ```
611
+ * NameStart ::
612
+ * - Letter
613
+ * - `_`
614
+ * ```
615
+ * @internal
616
+ */
617
+ function isNameStart(code) {
618
+ return isLetter(code) || code === 95;
619
+ }
620
+ /**
621
+ * ```
622
+ * NameContinue ::
623
+ * - Letter
624
+ * - Digit
625
+ * - `_`
626
+ * ```
627
+ * @internal
628
+ */
629
+ function isNameContinue(code) {
630
+ return isLetter(code) || isDigit(code) || code === 95;
631
+ }
632
+ //#endregion
633
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/blockString.mjs
634
+ /**
635
+ * Produces the value of a block string from its parsed raw value, similar to
636
+ * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
637
+ *
638
+ * This implements the GraphQL spec's BlockStringValue() static algorithm.
639
+ *
640
+ * @internal
641
+ */
642
+ function dedentBlockStringLines(lines) {
643
+ var _firstNonEmptyLine2;
644
+ let commonIndent = Number.MAX_SAFE_INTEGER;
645
+ let firstNonEmptyLine = null;
646
+ let lastNonEmptyLine = -1;
647
+ for (let i = 0; i < lines.length; ++i) {
648
+ var _firstNonEmptyLine;
649
+ const line = lines[i];
650
+ const indent = leadingWhitespace(line);
651
+ if (indent === line.length) continue;
652
+ firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
653
+ lastNonEmptyLine = i;
654
+ if (i !== 0 && indent < commonIndent) commonIndent = indent;
655
+ }
656
+ return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice((_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0, lastNonEmptyLine + 1);
657
+ }
658
+ function leadingWhitespace(str) {
659
+ let i = 0;
660
+ while (i < str.length && isWhiteSpace(str.charCodeAt(i))) ++i;
661
+ return i;
662
+ }
663
+ //#endregion
664
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/tokenKind.mjs
665
+ /**
666
+ * An exported enum describing the different kinds of tokens that the
667
+ * lexer emits.
668
+ */
669
+ var TokenKind;
670
+ (function(TokenKind) {
671
+ TokenKind["SOF"] = "<SOF>";
672
+ TokenKind["EOF"] = "<EOF>";
673
+ TokenKind["BANG"] = "!";
674
+ TokenKind["DOLLAR"] = "$";
675
+ TokenKind["AMP"] = "&";
676
+ TokenKind["PAREN_L"] = "(";
677
+ TokenKind["PAREN_R"] = ")";
678
+ TokenKind["DOT"] = ".";
679
+ TokenKind["SPREAD"] = "...";
680
+ TokenKind["COLON"] = ":";
681
+ TokenKind["EQUALS"] = "=";
682
+ TokenKind["AT"] = "@";
683
+ TokenKind["BRACKET_L"] = "[";
684
+ TokenKind["BRACKET_R"] = "]";
685
+ TokenKind["BRACE_L"] = "{";
686
+ TokenKind["PIPE"] = "|";
687
+ TokenKind["BRACE_R"] = "}";
688
+ TokenKind["NAME"] = "Name";
689
+ TokenKind["INT"] = "Int";
690
+ TokenKind["FLOAT"] = "Float";
691
+ TokenKind["STRING"] = "String";
692
+ TokenKind["BLOCK_STRING"] = "BlockString";
693
+ TokenKind["COMMENT"] = "Comment";
694
+ })(TokenKind || (TokenKind = {}));
695
+ /**
696
+ * The enum type representing the token kinds values.
697
+ *
698
+ * @deprecated Please use `TokenKind`. Will be remove in v17.
699
+ */
700
+ //#endregion
701
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/lexer.mjs
702
+ /**
703
+ * A Lexer interface which provides common properties and methods required for
704
+ * lexing GraphQL source.
705
+ *
706
+ * @internal
707
+ */
708
+ /**
709
+ * Given a Source object, creates a Lexer for that source.
710
+ * A Lexer is a stateful stream generator in that every time
711
+ * it is advanced, it returns the next token in the Source. Assuming the
712
+ * source lexes, the final Token emitted by the lexer will be of kind
713
+ * EOF, after which the lexer will repeatedly return the same EOF token
714
+ * whenever called.
715
+ */
716
+ var Lexer = class {
717
+ /**
718
+ * The previously focused non-ignored token.
719
+ */
720
+ /**
721
+ * The currently focused non-ignored token.
722
+ */
723
+ /**
724
+ * The (1-indexed) line containing the current token.
725
+ */
726
+ /**
727
+ * The character offset at which the current line begins.
728
+ */
729
+ constructor(source) {
730
+ const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
731
+ this.source = source;
732
+ this.lastToken = startOfFileToken;
733
+ this.token = startOfFileToken;
734
+ this.line = 1;
735
+ this.lineStart = 0;
736
+ }
737
+ get [Symbol.toStringTag]() {
738
+ return "Lexer";
739
+ }
740
+ /**
741
+ * Advances the token stream to the next non-ignored token.
742
+ */
743
+ advance() {
744
+ this.lastToken = this.token;
745
+ return this.token = this.lookahead();
746
+ }
747
+ /**
748
+ * Looks ahead and returns the next non-ignored token, but does not change
749
+ * the state of Lexer.
750
+ */
751
+ lookahead() {
752
+ let token = this.token;
753
+ if (token.kind !== TokenKind.EOF) do
754
+ if (token.next) token = token.next;
755
+ else {
756
+ const nextToken = readNextToken(this, token.end);
757
+ token.next = nextToken;
758
+ nextToken.prev = token;
759
+ token = nextToken;
760
+ }
761
+ while (token.kind === TokenKind.COMMENT);
762
+ return token;
763
+ }
764
+ };
765
+ /**
766
+ * @internal
767
+ */
768
+ function isPunctuatorTokenKind(kind) {
769
+ return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.DOT || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
770
+ }
771
+ /**
772
+ * A Unicode scalar value is any Unicode code point except surrogate code
773
+ * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and
774
+ * 0xE000 to 0x10FFFF.
775
+ *
776
+ * SourceCharacter ::
777
+ * - "Any Unicode scalar value"
778
+ */
779
+ function isUnicodeScalarValue(code) {
780
+ return code >= 0 && code <= 55295 || code >= 57344 && code <= 1114111;
781
+ }
782
+ /**
783
+ * The GraphQL specification defines source text as a sequence of unicode scalar
784
+ * values (which Unicode defines to exclude surrogate code points). However
785
+ * JavaScript defines strings as a sequence of UTF-16 code units which may
786
+ * include surrogates. A surrogate pair is a valid source character as it
787
+ * encodes a supplementary code point (above U+FFFF), but unpaired surrogate
788
+ * code points are not valid source characters.
789
+ */
790
+ function isSupplementaryCodePoint(body, location) {
791
+ return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
792
+ }
793
+ function isLeadingSurrogate(code) {
794
+ return code >= 55296 && code <= 56319;
795
+ }
796
+ function isTrailingSurrogate(code) {
797
+ return code >= 56320 && code <= 57343;
798
+ }
799
+ /**
800
+ * Prints the code point (or end of file reference) at a given location in a
801
+ * source for use in error messages.
802
+ *
803
+ * Printable ASCII is printed quoted, while other points are printed in Unicode
804
+ * code point form (ie. U+1234).
805
+ *
806
+ * @internal
807
+ */
808
+ function printCodePointAt(lexer, location) {
809
+ const code = lexer.source.body.codePointAt(location);
810
+ if (code === void 0) return TokenKind.EOF;
811
+ else if (code >= 32 && code <= 126) {
812
+ const char = String.fromCodePoint(code);
813
+ return char === "\"" ? "'\"'" : `"${char}"`;
814
+ }
815
+ return "U+" + code.toString(16).toUpperCase().padStart(4, "0");
816
+ }
817
+ /**
818
+ * Create a token with line and column location information.
819
+ *
820
+ * @internal
821
+ */
822
+ function createToken(lexer, kind, start, end, value) {
823
+ const line = lexer.line;
824
+ return new Token(kind, start, end, line, 1 + start - lexer.lineStart, value);
825
+ }
826
+ /**
827
+ * Gets the next token from the source starting at the given position.
828
+ *
829
+ * This skips over whitespace until it finds the next lexable token, then lexes
830
+ * punctuators immediately or calls the appropriate helper function for more
831
+ * complicated tokens.
832
+ */
833
+ function readNextToken(lexer, start) {
834
+ const body = lexer.source.body;
835
+ const bodyLength = body.length;
836
+ let position = start;
837
+ while (position < bodyLength) {
838
+ const code = body.charCodeAt(position);
839
+ switch (code) {
840
+ case 65279:
841
+ case 9:
842
+ case 32:
843
+ case 44:
844
+ ++position;
845
+ continue;
846
+ case 10:
847
+ ++position;
848
+ ++lexer.line;
849
+ lexer.lineStart = position;
850
+ continue;
851
+ case 13:
852
+ if (body.charCodeAt(position + 1) === 10) position += 2;
853
+ else ++position;
854
+ ++lexer.line;
855
+ lexer.lineStart = position;
856
+ continue;
857
+ case 35: return readComment(lexer, position);
858
+ case 33: return createToken(lexer, TokenKind.BANG, position, position + 1);
859
+ case 36: return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
860
+ case 38: return createToken(lexer, TokenKind.AMP, position, position + 1);
861
+ case 40: return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
862
+ case 41: return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
863
+ case 46:
864
+ if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) return createToken(lexer, TokenKind.SPREAD, position, position + 3);
865
+ break;
866
+ case 58: return createToken(lexer, TokenKind.COLON, position, position + 1);
867
+ case 61: return createToken(lexer, TokenKind.EQUALS, position, position + 1);
868
+ case 64: return createToken(lexer, TokenKind.AT, position, position + 1);
869
+ case 91: return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
870
+ case 93: return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
871
+ case 123: return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
872
+ case 124: return createToken(lexer, TokenKind.PIPE, position, position + 1);
873
+ case 125: return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
874
+ case 34:
875
+ if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) return readBlockString(lexer, position);
876
+ return readString(lexer, position);
877
+ }
878
+ if (isDigit(code) || code === 45) return readNumber(lexer, position, code);
879
+ if (isNameStart(code)) return readName(lexer, position);
880
+ throw syntaxError(lexer.source, position, code === 39 ? "Unexpected single quote character ('), did you mean to use a double quote (\")?" : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`);
881
+ }
882
+ return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
883
+ }
884
+ /**
885
+ * Reads a comment token from the source file.
886
+ *
887
+ * ```
888
+ * Comment :: # CommentChar* [lookahead != CommentChar]
889
+ *
890
+ * CommentChar :: SourceCharacter but not LineTerminator
891
+ * ```
892
+ */
893
+ function readComment(lexer, start) {
894
+ const body = lexer.source.body;
895
+ const bodyLength = body.length;
896
+ let position = start + 1;
897
+ while (position < bodyLength) {
898
+ const code = body.charCodeAt(position);
899
+ if (code === 10 || code === 13) break;
900
+ if (isUnicodeScalarValue(code)) ++position;
901
+ else if (isSupplementaryCodePoint(body, position)) position += 2;
902
+ else break;
903
+ }
904
+ return createToken(lexer, TokenKind.COMMENT, start, position, body.slice(start + 1, position));
905
+ }
906
+ /**
907
+ * Reads a number token from the source file, either a FloatValue or an IntValue
908
+ * depending on whether a FractionalPart or ExponentPart is encountered.
909
+ *
910
+ * ```
911
+ * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]
912
+ *
913
+ * IntegerPart ::
914
+ * - NegativeSign? 0
915
+ * - NegativeSign? NonZeroDigit Digit*
916
+ *
917
+ * NegativeSign :: -
918
+ *
919
+ * NonZeroDigit :: Digit but not `0`
920
+ *
921
+ * FloatValue ::
922
+ * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
923
+ * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]
924
+ * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
925
+ *
926
+ * FractionalPart :: . Digit+
927
+ *
928
+ * ExponentPart :: ExponentIndicator Sign? Digit+
929
+ *
930
+ * ExponentIndicator :: one of `e` `E`
931
+ *
932
+ * Sign :: one of + -
933
+ * ```
934
+ */
935
+ function readNumber(lexer, start, firstCode) {
936
+ const body = lexer.source.body;
937
+ let position = start;
938
+ let code = firstCode;
939
+ let isFloat = false;
940
+ if (code === 45) code = body.charCodeAt(++position);
941
+ if (code === 48) {
942
+ code = body.charCodeAt(++position);
943
+ if (isDigit(code)) throw syntaxError(lexer.source, position, `Invalid number, unexpected digit after 0: ${printCodePointAt(lexer, position)}.`);
944
+ } else {
945
+ position = readDigits(lexer, position, code);
946
+ code = body.charCodeAt(position);
947
+ }
948
+ if (code === 46) {
949
+ isFloat = true;
950
+ code = body.charCodeAt(++position);
951
+ position = readDigits(lexer, position, code);
952
+ code = body.charCodeAt(position);
953
+ }
954
+ if (code === 69 || code === 101) {
955
+ isFloat = true;
956
+ code = body.charCodeAt(++position);
957
+ if (code === 43 || code === 45) code = body.charCodeAt(++position);
958
+ position = readDigits(lexer, position, code);
959
+ code = body.charCodeAt(position);
960
+ }
961
+ if (code === 46 || isNameStart(code)) throw syntaxError(lexer.source, position, `Invalid number, expected digit but got: ${printCodePointAt(lexer, position)}.`);
962
+ return createToken(lexer, isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, body.slice(start, position));
963
+ }
964
+ /**
965
+ * Returns the new position in the source after reading one or more digits.
966
+ */
967
+ function readDigits(lexer, start, firstCode) {
968
+ if (!isDigit(firstCode)) throw syntaxError(lexer.source, start, `Invalid number, expected digit but got: ${printCodePointAt(lexer, start)}.`);
969
+ const body = lexer.source.body;
970
+ let position = start + 1;
971
+ while (isDigit(body.charCodeAt(position))) ++position;
972
+ return position;
973
+ }
974
+ /**
975
+ * Reads a single-quote string token from the source file.
976
+ *
977
+ * ```
978
+ * StringValue ::
979
+ * - `""` [lookahead != `"`]
980
+ * - `"` StringCharacter+ `"`
981
+ *
982
+ * StringCharacter ::
983
+ * - SourceCharacter but not `"` or `\` or LineTerminator
984
+ * - `\u` EscapedUnicode
985
+ * - `\` EscapedCharacter
986
+ *
987
+ * EscapedUnicode ::
988
+ * - `{` HexDigit+ `}`
989
+ * - HexDigit HexDigit HexDigit HexDigit
990
+ *
991
+ * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
992
+ * ```
993
+ */
994
+ function readString(lexer, start) {
995
+ const body = lexer.source.body;
996
+ const bodyLength = body.length;
997
+ let position = start + 1;
998
+ let chunkStart = position;
999
+ let value = "";
1000
+ while (position < bodyLength) {
1001
+ const code = body.charCodeAt(position);
1002
+ if (code === 34) {
1003
+ value += body.slice(chunkStart, position);
1004
+ return createToken(lexer, TokenKind.STRING, start, position + 1, value);
1005
+ }
1006
+ if (code === 92) {
1007
+ value += body.slice(chunkStart, position);
1008
+ const escape = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
1009
+ value += escape.value;
1010
+ position += escape.size;
1011
+ chunkStart = position;
1012
+ continue;
1013
+ }
1014
+ if (code === 10 || code === 13) break;
1015
+ if (isUnicodeScalarValue(code)) ++position;
1016
+ else if (isSupplementaryCodePoint(body, position)) position += 2;
1017
+ else throw syntaxError(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`);
1018
+ }
1019
+ throw syntaxError(lexer.source, position, "Unterminated string.");
1020
+ }
1021
+ function readEscapedUnicodeVariableWidth(lexer, position) {
1022
+ const body = lexer.source.body;
1023
+ let point = 0;
1024
+ let size = 3;
1025
+ while (size < 12) {
1026
+ const code = body.charCodeAt(position + size++);
1027
+ if (code === 125) {
1028
+ if (size < 5 || !isUnicodeScalarValue(point)) break;
1029
+ return {
1030
+ value: String.fromCodePoint(point),
1031
+ size
1032
+ };
1033
+ }
1034
+ point = point << 4 | readHexDigit(code);
1035
+ if (point < 0) break;
1036
+ }
1037
+ throw syntaxError(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + size)}".`);
1038
+ }
1039
+ function readEscapedUnicodeFixedWidth(lexer, position) {
1040
+ const body = lexer.source.body;
1041
+ const code = read16BitHexCode(body, position + 2);
1042
+ if (isUnicodeScalarValue(code)) return {
1043
+ value: String.fromCodePoint(code),
1044
+ size: 6
1045
+ };
1046
+ if (isLeadingSurrogate(code)) {
1047
+ if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
1048
+ const trailingCode = read16BitHexCode(body, position + 8);
1049
+ if (isTrailingSurrogate(trailingCode)) return {
1050
+ value: String.fromCodePoint(code, trailingCode),
1051
+ size: 12
1052
+ };
1053
+ }
1054
+ }
1055
+ throw syntaxError(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`);
1056
+ }
1057
+ /**
1058
+ * Reads four hexadecimal characters and returns the positive integer that 16bit
1059
+ * hexadecimal string represents. For example, "000f" will return 15, and "dead"
1060
+ * will return 57005.
1061
+ *
1062
+ * Returns a negative number if any char was not a valid hexadecimal digit.
1063
+ */
1064
+ function read16BitHexCode(body, position) {
1065
+ return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
1066
+ }
1067
+ /**
1068
+ * Reads a hexadecimal character and returns its positive integer value (0-15).
1069
+ *
1070
+ * '0' becomes 0, '9' becomes 9
1071
+ * 'A' becomes 10, 'F' becomes 15
1072
+ * 'a' becomes 10, 'f' becomes 15
1073
+ *
1074
+ * Returns -1 if the provided character code was not a valid hexadecimal digit.
1075
+ *
1076
+ * HexDigit :: one of
1077
+ * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
1078
+ * - `A` `B` `C` `D` `E` `F`
1079
+ * - `a` `b` `c` `d` `e` `f`
1080
+ */
1081
+ function readHexDigit(code) {
1082
+ return code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
1083
+ }
1084
+ /**
1085
+ * | Escaped Character | Code Point | Character Name |
1086
+ * | ----------------- | ---------- | ---------------------------- |
1087
+ * | `"` | U+0022 | double quote |
1088
+ * | `\` | U+005C | reverse solidus (back slash) |
1089
+ * | `/` | U+002F | solidus (forward slash) |
1090
+ * | `b` | U+0008 | backspace |
1091
+ * | `f` | U+000C | form feed |
1092
+ * | `n` | U+000A | line feed (new line) |
1093
+ * | `r` | U+000D | carriage return |
1094
+ * | `t` | U+0009 | horizontal tab |
1095
+ */
1096
+ function readEscapedCharacter(lexer, position) {
1097
+ const body = lexer.source.body;
1098
+ switch (body.charCodeAt(position + 1)) {
1099
+ case 34: return {
1100
+ value: "\"",
1101
+ size: 2
1102
+ };
1103
+ case 92: return {
1104
+ value: "\\",
1105
+ size: 2
1106
+ };
1107
+ case 47: return {
1108
+ value: "/",
1109
+ size: 2
1110
+ };
1111
+ case 98: return {
1112
+ value: "\b",
1113
+ size: 2
1114
+ };
1115
+ case 102: return {
1116
+ value: "\f",
1117
+ size: 2
1118
+ };
1119
+ case 110: return {
1120
+ value: "\n",
1121
+ size: 2
1122
+ };
1123
+ case 114: return {
1124
+ value: "\r",
1125
+ size: 2
1126
+ };
1127
+ case 116: return {
1128
+ value: " ",
1129
+ size: 2
1130
+ };
1131
+ }
1132
+ throw syntaxError(lexer.source, position, `Invalid character escape sequence: "${body.slice(position, position + 2)}".`);
1133
+ }
1134
+ /**
1135
+ * Reads a block string token from the source file.
1136
+ *
1137
+ * ```
1138
+ * StringValue ::
1139
+ * - `"""` BlockStringCharacter* `"""`
1140
+ *
1141
+ * BlockStringCharacter ::
1142
+ * - SourceCharacter but not `"""` or `\"""`
1143
+ * - `\"""`
1144
+ * ```
1145
+ */
1146
+ function readBlockString(lexer, start) {
1147
+ const body = lexer.source.body;
1148
+ const bodyLength = body.length;
1149
+ let lineStart = lexer.lineStart;
1150
+ let position = start + 3;
1151
+ let chunkStart = position;
1152
+ let currentLine = "";
1153
+ const blockLines = [];
1154
+ while (position < bodyLength) {
1155
+ const code = body.charCodeAt(position);
1156
+ if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
1157
+ currentLine += body.slice(chunkStart, position);
1158
+ blockLines.push(currentLine);
1159
+ const token = createToken(lexer, TokenKind.BLOCK_STRING, start, position + 3, dedentBlockStringLines(blockLines).join("\n"));
1160
+ lexer.line += blockLines.length - 1;
1161
+ lexer.lineStart = lineStart;
1162
+ return token;
1163
+ }
1164
+ if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
1165
+ currentLine += body.slice(chunkStart, position);
1166
+ chunkStart = position + 1;
1167
+ position += 4;
1168
+ continue;
1169
+ }
1170
+ if (code === 10 || code === 13) {
1171
+ currentLine += body.slice(chunkStart, position);
1172
+ blockLines.push(currentLine);
1173
+ if (code === 13 && body.charCodeAt(position + 1) === 10) position += 2;
1174
+ else ++position;
1175
+ currentLine = "";
1176
+ chunkStart = position;
1177
+ lineStart = position;
1178
+ continue;
1179
+ }
1180
+ if (isUnicodeScalarValue(code)) ++position;
1181
+ else if (isSupplementaryCodePoint(body, position)) position += 2;
1182
+ else throw syntaxError(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`);
1183
+ }
1184
+ throw syntaxError(lexer.source, position, "Unterminated string.");
1185
+ }
1186
+ /**
1187
+ * Reads an alphanumeric + underscore name from the source.
1188
+ *
1189
+ * ```
1190
+ * Name ::
1191
+ * - NameStart NameContinue* [lookahead != NameContinue]
1192
+ * ```
1193
+ *
1194
+ * @internal
1195
+ */
1196
+ function readName(lexer, start) {
1197
+ const body = lexer.source.body;
1198
+ const bodyLength = body.length;
1199
+ let position = start + 1;
1200
+ while (position < bodyLength) if (isNameContinue(body.charCodeAt(position))) ++position;
1201
+ else break;
1202
+ return createToken(lexer, TokenKind.NAME, start, position, body.slice(start, position));
1203
+ }
1204
+ //#endregion
1205
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/inspect.mjs
1206
+ const MAX_ARRAY_LENGTH = 10;
1207
+ const MAX_RECURSIVE_DEPTH = 2;
1208
+ /**
1209
+ * Used to print values in error messages.
1210
+ */
1211
+ function inspect(value) {
1212
+ return formatValue(value, []);
1213
+ }
1214
+ function formatValue(value, seenValues) {
1215
+ switch (typeof value) {
1216
+ case "string": return JSON.stringify(value);
1217
+ case "function": return value.name ? `[function ${value.name}]` : "[function]";
1218
+ case "object": return formatObjectValue(value, seenValues);
1219
+ default: return String(value);
1220
+ }
1221
+ }
1222
+ function formatObjectValue(value, previouslySeenValues) {
1223
+ if (value === null) return "null";
1224
+ if (previouslySeenValues.includes(value)) return "[Circular]";
1225
+ const seenValues = [...previouslySeenValues, value];
1226
+ if (isJSONable(value)) {
1227
+ const jsonValue = value.toJSON();
1228
+ if (jsonValue !== value) return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
1229
+ } else if (Array.isArray(value)) return formatArray(value, seenValues);
1230
+ return formatObject(value, seenValues);
1231
+ }
1232
+ function isJSONable(value) {
1233
+ return typeof value.toJSON === "function";
1234
+ }
1235
+ function formatObject(object, seenValues) {
1236
+ const entries = Object.entries(object);
1237
+ if (entries.length === 0) return "{}";
1238
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) return "[" + getObjectTag(object) + "]";
1239
+ return "{ " + entries.map(([key, value]) => key + ": " + formatValue(value, seenValues)).join(", ") + " }";
1240
+ }
1241
+ function formatArray(array, seenValues) {
1242
+ if (array.length === 0) return "[]";
1243
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) return "[Array]";
1244
+ const len = Math.min(MAX_ARRAY_LENGTH, array.length);
1245
+ const remaining = array.length - len;
1246
+ const items = [];
1247
+ for (let i = 0; i < len; ++i) items.push(formatValue(array[i], seenValues));
1248
+ if (remaining === 1) items.push("... 1 more item");
1249
+ else if (remaining > 1) items.push(`... ${remaining} more items`);
1250
+ return "[" + items.join(", ") + "]";
1251
+ }
1252
+ function getObjectTag(object) {
1253
+ const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
1254
+ if (tag === "Object" && typeof object.constructor === "function") {
1255
+ const name = object.constructor.name;
1256
+ if (typeof name === "string" && name !== "") return name;
1257
+ }
1258
+ return tag;
1259
+ }
1260
+ /**
1261
+ * A replacement for instanceof which includes an error warning when multi-realm
1262
+ * constructors are detected.
1263
+ * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
1264
+ * See: https://webpack.js.org/guides/production/
1265
+ */
1266
+ const instanceOf = (globalThis.process, function instanceOf(value, constructor) {
1267
+ if (value instanceof constructor) return true;
1268
+ if (typeof value === "object" && value !== null) {
1269
+ var _value$constructor;
1270
+ const className = constructor.prototype[Symbol.toStringTag];
1271
+ if (className === (Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name)) {
1272
+ const stringifiedValue = inspect(value);
1273
+ throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
1274
+
1275
+ Ensure that there is only one instance of "graphql" in the node_modules
1276
+ directory. If different versions of "graphql" are the dependencies of other
1277
+ relied on modules, use "resolutions" to ensure only one version is installed.
1278
+
1279
+ https://yarnpkg.com/en/docs/selective-version-resolutions
1280
+
1281
+ Duplicate "graphql" modules cannot be used at the same time since different
1282
+ versions may have different capabilities and behavior. The data from one
1283
+ version used in the function from another could produce confusing and
1284
+ spurious results.`);
1285
+ }
1286
+ }
1287
+ return false;
1288
+ });
1289
+ //#endregion
1290
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/source.mjs
1291
+ /**
1292
+ * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
1293
+ * optional, but they are useful for clients who store GraphQL documents in source files.
1294
+ * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
1295
+ * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
1296
+ * The `line` and `column` properties in `locationOffset` are 1-indexed.
1297
+ */
1298
+ var Source = class {
1299
+ constructor(body, name = "GraphQL request", locationOffset = {
1300
+ line: 1,
1301
+ column: 1
1302
+ }) {
1303
+ typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
1304
+ this.body = body;
1305
+ this.name = name;
1306
+ this.locationOffset = locationOffset;
1307
+ this.locationOffset.line > 0 || devAssert(false, "line in locationOffset is 1-indexed and must be positive.");
1308
+ this.locationOffset.column > 0 || devAssert(false, "column in locationOffset is 1-indexed and must be positive.");
1309
+ }
1310
+ get [Symbol.toStringTag]() {
1311
+ return "Source";
1312
+ }
1313
+ };
1314
+ /**
1315
+ * Test if the given value is a Source object.
1316
+ *
1317
+ * @internal
1318
+ */
1319
+ function isSource(source) {
1320
+ return instanceOf(source, Source);
1321
+ }
1322
+ //#endregion
1323
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/parser.mjs
1324
+ /**
1325
+ * Configuration options to control parser behavior
1326
+ */
1327
+ /**
1328
+ * Given a GraphQL source, parses it into a Document.
1329
+ * Throws GraphQLError if a syntax error is encountered.
1330
+ */
1331
+ function parse(source, options) {
1332
+ const parser = new Parser(source, options);
1333
+ const document = parser.parseDocument();
1334
+ Object.defineProperty(document, "tokenCount", {
1335
+ enumerable: false,
1336
+ value: parser.tokenCount
1337
+ });
1338
+ return document;
1339
+ }
1340
+ /**
1341
+ * This class is exported only to assist people in implementing their own parsers
1342
+ * without duplicating too much code and should be used only as last resort for cases
1343
+ * such as experimental syntax or if certain features could not be contributed upstream.
1344
+ *
1345
+ * It is still part of the internal API and is versioned, so any changes to it are never
1346
+ * considered breaking changes. If you still need to support multiple versions of the
1347
+ * library, please use the `versionInfo` variable for version detection.
1348
+ *
1349
+ * @internal
1350
+ */
1351
+ var Parser = class {
1352
+ constructor(source, options = {}) {
1353
+ const { lexer, ..._options } = options;
1354
+ if (lexer) this._lexer = lexer;
1355
+ else {
1356
+ const sourceObj = isSource(source) ? source : new Source(source);
1357
+ this._lexer = new Lexer(sourceObj);
1358
+ }
1359
+ this._options = _options;
1360
+ this._tokenCounter = 0;
1361
+ }
1362
+ get tokenCount() {
1363
+ return this._tokenCounter;
1364
+ }
1365
+ /**
1366
+ * Converts a name lex token into a name parse node.
1367
+ */
1368
+ parseName() {
1369
+ const token = this.expectToken(TokenKind.NAME);
1370
+ return this.node(token, {
1371
+ kind: Kind.NAME,
1372
+ value: token.value
1373
+ });
1374
+ }
1375
+ /**
1376
+ * Document : Definition+
1377
+ */
1378
+ parseDocument() {
1379
+ return this.node(this._lexer.token, {
1380
+ kind: Kind.DOCUMENT,
1381
+ definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF)
1382
+ });
1383
+ }
1384
+ /**
1385
+ * Definition :
1386
+ * - ExecutableDefinition
1387
+ * - TypeSystemDefinition
1388
+ * - TypeSystemExtension
1389
+ *
1390
+ * ExecutableDefinition :
1391
+ * - OperationDefinition
1392
+ * - FragmentDefinition
1393
+ *
1394
+ * TypeSystemDefinition :
1395
+ * - SchemaDefinition
1396
+ * - TypeDefinition
1397
+ * - DirectiveDefinition
1398
+ *
1399
+ * TypeDefinition :
1400
+ * - ScalarTypeDefinition
1401
+ * - ObjectTypeDefinition
1402
+ * - InterfaceTypeDefinition
1403
+ * - UnionTypeDefinition
1404
+ * - EnumTypeDefinition
1405
+ * - InputObjectTypeDefinition
1406
+ */
1407
+ parseDefinition() {
1408
+ if (this.peek(TokenKind.BRACE_L)) return this.parseOperationDefinition();
1409
+ const hasDescription = this.peekDescription();
1410
+ const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
1411
+ if (hasDescription && keywordToken.kind === TokenKind.BRACE_L) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries.");
1412
+ if (keywordToken.kind === TokenKind.NAME) {
1413
+ switch (keywordToken.value) {
1414
+ case "schema": return this.parseSchemaDefinition();
1415
+ case "scalar": return this.parseScalarTypeDefinition();
1416
+ case "type": return this.parseObjectTypeDefinition();
1417
+ case "interface": return this.parseInterfaceTypeDefinition();
1418
+ case "union": return this.parseUnionTypeDefinition();
1419
+ case "enum": return this.parseEnumTypeDefinition();
1420
+ case "input": return this.parseInputObjectTypeDefinition();
1421
+ case "directive": return this.parseDirectiveDefinition();
1422
+ }
1423
+ switch (keywordToken.value) {
1424
+ case "query":
1425
+ case "mutation":
1426
+ case "subscription": return this.parseOperationDefinition();
1427
+ case "fragment": return this.parseFragmentDefinition();
1428
+ }
1429
+ if (hasDescription) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions.");
1430
+ switch (keywordToken.value) {
1431
+ case "extend": return this.parseTypeSystemExtension();
1432
+ }
1433
+ }
1434
+ throw this.unexpected(keywordToken);
1435
+ }
1436
+ /**
1437
+ * OperationDefinition :
1438
+ * - SelectionSet
1439
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
1440
+ */
1441
+ parseOperationDefinition() {
1442
+ const start = this._lexer.token;
1443
+ if (this.peek(TokenKind.BRACE_L)) return this.node(start, {
1444
+ kind: Kind.OPERATION_DEFINITION,
1445
+ operation: OperationTypeNode.QUERY,
1446
+ description: void 0,
1447
+ name: void 0,
1448
+ variableDefinitions: [],
1449
+ directives: [],
1450
+ selectionSet: this.parseSelectionSet()
1451
+ });
1452
+ const description = this.parseDescription();
1453
+ const operation = this.parseOperationType();
1454
+ let name;
1455
+ if (this.peek(TokenKind.NAME)) name = this.parseName();
1456
+ return this.node(start, {
1457
+ kind: Kind.OPERATION_DEFINITION,
1458
+ operation,
1459
+ description,
1460
+ name,
1461
+ variableDefinitions: this.parseVariableDefinitions(),
1462
+ directives: this.parseDirectives(false),
1463
+ selectionSet: this.parseSelectionSet()
1464
+ });
1465
+ }
1466
+ /**
1467
+ * OperationType : one of query mutation subscription
1468
+ */
1469
+ parseOperationType() {
1470
+ const operationToken = this.expectToken(TokenKind.NAME);
1471
+ switch (operationToken.value) {
1472
+ case "query": return OperationTypeNode.QUERY;
1473
+ case "mutation": return OperationTypeNode.MUTATION;
1474
+ case "subscription": return OperationTypeNode.SUBSCRIPTION;
1475
+ }
1476
+ throw this.unexpected(operationToken);
1477
+ }
1478
+ /**
1479
+ * VariableDefinitions : ( VariableDefinition+ )
1480
+ */
1481
+ parseVariableDefinitions() {
1482
+ return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R);
1483
+ }
1484
+ /**
1485
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
1486
+ */
1487
+ parseVariableDefinition() {
1488
+ return this.node(this._lexer.token, {
1489
+ kind: Kind.VARIABLE_DEFINITION,
1490
+ description: this.parseDescription(),
1491
+ variable: this.parseVariable(),
1492
+ type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
1493
+ defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
1494
+ directives: this.parseConstDirectives()
1495
+ });
1496
+ }
1497
+ /**
1498
+ * Variable : $ Name
1499
+ */
1500
+ parseVariable() {
1501
+ const start = this._lexer.token;
1502
+ this.expectToken(TokenKind.DOLLAR);
1503
+ return this.node(start, {
1504
+ kind: Kind.VARIABLE,
1505
+ name: this.parseName()
1506
+ });
1507
+ }
1508
+ /**
1509
+ * ```
1510
+ * SelectionSet : { Selection+ }
1511
+ * ```
1512
+ */
1513
+ parseSelectionSet() {
1514
+ return this.node(this._lexer.token, {
1515
+ kind: Kind.SELECTION_SET,
1516
+ selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R)
1517
+ });
1518
+ }
1519
+ /**
1520
+ * Selection :
1521
+ * - Field
1522
+ * - FragmentSpread
1523
+ * - InlineFragment
1524
+ */
1525
+ parseSelection() {
1526
+ return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
1527
+ }
1528
+ /**
1529
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
1530
+ *
1531
+ * Alias : Name :
1532
+ */
1533
+ parseField() {
1534
+ const start = this._lexer.token;
1535
+ const nameOrAlias = this.parseName();
1536
+ let alias;
1537
+ let name;
1538
+ if (this.expectOptionalToken(TokenKind.COLON)) {
1539
+ alias = nameOrAlias;
1540
+ name = this.parseName();
1541
+ } else name = nameOrAlias;
1542
+ return this.node(start, {
1543
+ kind: Kind.FIELD,
1544
+ alias,
1545
+ name,
1546
+ arguments: this.parseArguments(false),
1547
+ directives: this.parseDirectives(false),
1548
+ selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
1549
+ });
1550
+ }
1551
+ /**
1552
+ * Arguments[Const] : ( Argument[?Const]+ )
1553
+ */
1554
+ parseArguments(isConst) {
1555
+ const item = isConst ? this.parseConstArgument : this.parseArgument;
1556
+ return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
1557
+ }
1558
+ /**
1559
+ * Argument[Const] : Name : Value[?Const]
1560
+ */
1561
+ parseArgument(isConst = false) {
1562
+ const start = this._lexer.token;
1563
+ const name = this.parseName();
1564
+ this.expectToken(TokenKind.COLON);
1565
+ return this.node(start, {
1566
+ kind: Kind.ARGUMENT,
1567
+ name,
1568
+ value: this.parseValueLiteral(isConst)
1569
+ });
1570
+ }
1571
+ parseConstArgument() {
1572
+ return this.parseArgument(true);
1573
+ }
1574
+ /**
1575
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
1576
+ *
1577
+ * FragmentSpread : ... FragmentName Directives?
1578
+ *
1579
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
1580
+ */
1581
+ parseFragment() {
1582
+ const start = this._lexer.token;
1583
+ this.expectToken(TokenKind.SPREAD);
1584
+ const hasTypeCondition = this.expectOptionalKeyword("on");
1585
+ if (!hasTypeCondition && this.peek(TokenKind.NAME)) return this.node(start, {
1586
+ kind: Kind.FRAGMENT_SPREAD,
1587
+ name: this.parseFragmentName(),
1588
+ directives: this.parseDirectives(false)
1589
+ });
1590
+ return this.node(start, {
1591
+ kind: Kind.INLINE_FRAGMENT,
1592
+ typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
1593
+ directives: this.parseDirectives(false),
1594
+ selectionSet: this.parseSelectionSet()
1595
+ });
1596
+ }
1597
+ /**
1598
+ * FragmentDefinition :
1599
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
1600
+ *
1601
+ * TypeCondition : NamedType
1602
+ */
1603
+ parseFragmentDefinition() {
1604
+ const start = this._lexer.token;
1605
+ const description = this.parseDescription();
1606
+ this.expectKeyword("fragment");
1607
+ if (this._options.allowLegacyFragmentVariables === true) return this.node(start, {
1608
+ kind: Kind.FRAGMENT_DEFINITION,
1609
+ description,
1610
+ name: this.parseFragmentName(),
1611
+ variableDefinitions: this.parseVariableDefinitions(),
1612
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1613
+ directives: this.parseDirectives(false),
1614
+ selectionSet: this.parseSelectionSet()
1615
+ });
1616
+ return this.node(start, {
1617
+ kind: Kind.FRAGMENT_DEFINITION,
1618
+ description,
1619
+ name: this.parseFragmentName(),
1620
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1621
+ directives: this.parseDirectives(false),
1622
+ selectionSet: this.parseSelectionSet()
1623
+ });
1624
+ }
1625
+ /**
1626
+ * FragmentName : Name but not `on`
1627
+ */
1628
+ parseFragmentName() {
1629
+ if (this._lexer.token.value === "on") throw this.unexpected();
1630
+ return this.parseName();
1631
+ }
1632
+ /**
1633
+ * Value[Const] :
1634
+ * - [~Const] Variable
1635
+ * - IntValue
1636
+ * - FloatValue
1637
+ * - StringValue
1638
+ * - BooleanValue
1639
+ * - NullValue
1640
+ * - EnumValue
1641
+ * - ListValue[?Const]
1642
+ * - ObjectValue[?Const]
1643
+ *
1644
+ * BooleanValue : one of `true` `false`
1645
+ *
1646
+ * NullValue : `null`
1647
+ *
1648
+ * EnumValue : Name but not `true`, `false` or `null`
1649
+ */
1650
+ parseValueLiteral(isConst) {
1651
+ const token = this._lexer.token;
1652
+ switch (token.kind) {
1653
+ case TokenKind.BRACKET_L: return this.parseList(isConst);
1654
+ case TokenKind.BRACE_L: return this.parseObject(isConst);
1655
+ case TokenKind.INT:
1656
+ this.advanceLexer();
1657
+ return this.node(token, {
1658
+ kind: Kind.INT,
1659
+ value: token.value
1660
+ });
1661
+ case TokenKind.FLOAT:
1662
+ this.advanceLexer();
1663
+ return this.node(token, {
1664
+ kind: Kind.FLOAT,
1665
+ value: token.value
1666
+ });
1667
+ case TokenKind.STRING:
1668
+ case TokenKind.BLOCK_STRING: return this.parseStringLiteral();
1669
+ case TokenKind.NAME:
1670
+ this.advanceLexer();
1671
+ switch (token.value) {
1672
+ case "true": return this.node(token, {
1673
+ kind: Kind.BOOLEAN,
1674
+ value: true
1675
+ });
1676
+ case "false": return this.node(token, {
1677
+ kind: Kind.BOOLEAN,
1678
+ value: false
1679
+ });
1680
+ case "null": return this.node(token, { kind: Kind.NULL });
1681
+ default: return this.node(token, {
1682
+ kind: Kind.ENUM,
1683
+ value: token.value
1684
+ });
1685
+ }
1686
+ case TokenKind.DOLLAR:
1687
+ if (isConst) {
1688
+ this.expectToken(TokenKind.DOLLAR);
1689
+ if (this._lexer.token.kind === TokenKind.NAME) {
1690
+ const varName = this._lexer.token.value;
1691
+ throw syntaxError(this._lexer.source, token.start, `Unexpected variable "$${varName}" in constant value.`);
1692
+ } else throw this.unexpected(token);
1693
+ }
1694
+ return this.parseVariable();
1695
+ default: throw this.unexpected();
1696
+ }
1697
+ }
1698
+ parseConstValueLiteral() {
1699
+ return this.parseValueLiteral(true);
1700
+ }
1701
+ parseStringLiteral() {
1702
+ const token = this._lexer.token;
1703
+ this.advanceLexer();
1704
+ return this.node(token, {
1705
+ kind: Kind.STRING,
1706
+ value: token.value,
1707
+ block: token.kind === TokenKind.BLOCK_STRING
1708
+ });
1709
+ }
1710
+ /**
1711
+ * ListValue[Const] :
1712
+ * - [ ]
1713
+ * - [ Value[?Const]+ ]
1714
+ */
1715
+ parseList(isConst) {
1716
+ const item = () => this.parseValueLiteral(isConst);
1717
+ return this.node(this._lexer.token, {
1718
+ kind: Kind.LIST,
1719
+ values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
1720
+ });
1721
+ }
1722
+ /**
1723
+ * ```
1724
+ * ObjectValue[Const] :
1725
+ * - { }
1726
+ * - { ObjectField[?Const]+ }
1727
+ * ```
1728
+ */
1729
+ parseObject(isConst) {
1730
+ const item = () => this.parseObjectField(isConst);
1731
+ return this.node(this._lexer.token, {
1732
+ kind: Kind.OBJECT,
1733
+ fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
1734
+ });
1735
+ }
1736
+ /**
1737
+ * ObjectField[Const] : Name : Value[?Const]
1738
+ */
1739
+ parseObjectField(isConst) {
1740
+ const start = this._lexer.token;
1741
+ const name = this.parseName();
1742
+ this.expectToken(TokenKind.COLON);
1743
+ return this.node(start, {
1744
+ kind: Kind.OBJECT_FIELD,
1745
+ name,
1746
+ value: this.parseValueLiteral(isConst)
1747
+ });
1748
+ }
1749
+ /**
1750
+ * Directives[Const] : Directive[?Const]+
1751
+ */
1752
+ parseDirectives(isConst) {
1753
+ const directives = [];
1754
+ while (this.peek(TokenKind.AT)) directives.push(this.parseDirective(isConst));
1755
+ return directives;
1756
+ }
1757
+ parseConstDirectives() {
1758
+ return this.parseDirectives(true);
1759
+ }
1760
+ /**
1761
+ * ```
1762
+ * Directive[Const] : @ Name Arguments[?Const]?
1763
+ * ```
1764
+ */
1765
+ parseDirective(isConst) {
1766
+ const start = this._lexer.token;
1767
+ this.expectToken(TokenKind.AT);
1768
+ return this.node(start, {
1769
+ kind: Kind.DIRECTIVE,
1770
+ name: this.parseName(),
1771
+ arguments: this.parseArguments(isConst)
1772
+ });
1773
+ }
1774
+ /**
1775
+ * Type :
1776
+ * - NamedType
1777
+ * - ListType
1778
+ * - NonNullType
1779
+ */
1780
+ parseTypeReference() {
1781
+ const start = this._lexer.token;
1782
+ let type;
1783
+ if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
1784
+ const innerType = this.parseTypeReference();
1785
+ this.expectToken(TokenKind.BRACKET_R);
1786
+ type = this.node(start, {
1787
+ kind: Kind.LIST_TYPE,
1788
+ type: innerType
1789
+ });
1790
+ } else type = this.parseNamedType();
1791
+ if (this.expectOptionalToken(TokenKind.BANG)) return this.node(start, {
1792
+ kind: Kind.NON_NULL_TYPE,
1793
+ type
1794
+ });
1795
+ return type;
1796
+ }
1797
+ /**
1798
+ * NamedType : Name
1799
+ */
1800
+ parseNamedType() {
1801
+ return this.node(this._lexer.token, {
1802
+ kind: Kind.NAMED_TYPE,
1803
+ name: this.parseName()
1804
+ });
1805
+ }
1806
+ peekDescription() {
1807
+ return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
1808
+ }
1809
+ /**
1810
+ * Description : StringValue
1811
+ */
1812
+ parseDescription() {
1813
+ if (this.peekDescription()) return this.parseStringLiteral();
1814
+ }
1815
+ /**
1816
+ * ```
1817
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
1818
+ * ```
1819
+ */
1820
+ parseSchemaDefinition() {
1821
+ const start = this._lexer.token;
1822
+ const description = this.parseDescription();
1823
+ this.expectKeyword("schema");
1824
+ const directives = this.parseConstDirectives();
1825
+ const operationTypes = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
1826
+ return this.node(start, {
1827
+ kind: Kind.SCHEMA_DEFINITION,
1828
+ description,
1829
+ directives,
1830
+ operationTypes
1831
+ });
1832
+ }
1833
+ /**
1834
+ * OperationTypeDefinition : OperationType : NamedType
1835
+ */
1836
+ parseOperationTypeDefinition() {
1837
+ const start = this._lexer.token;
1838
+ const operation = this.parseOperationType();
1839
+ this.expectToken(TokenKind.COLON);
1840
+ const type = this.parseNamedType();
1841
+ return this.node(start, {
1842
+ kind: Kind.OPERATION_TYPE_DEFINITION,
1843
+ operation,
1844
+ type
1845
+ });
1846
+ }
1847
+ /**
1848
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
1849
+ */
1850
+ parseScalarTypeDefinition() {
1851
+ const start = this._lexer.token;
1852
+ const description = this.parseDescription();
1853
+ this.expectKeyword("scalar");
1854
+ const name = this.parseName();
1855
+ const directives = this.parseConstDirectives();
1856
+ return this.node(start, {
1857
+ kind: Kind.SCALAR_TYPE_DEFINITION,
1858
+ description,
1859
+ name,
1860
+ directives
1861
+ });
1862
+ }
1863
+ /**
1864
+ * ObjectTypeDefinition :
1865
+ * Description?
1866
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
1867
+ */
1868
+ parseObjectTypeDefinition() {
1869
+ const start = this._lexer.token;
1870
+ const description = this.parseDescription();
1871
+ this.expectKeyword("type");
1872
+ const name = this.parseName();
1873
+ const interfaces = this.parseImplementsInterfaces();
1874
+ const directives = this.parseConstDirectives();
1875
+ const fields = this.parseFieldsDefinition();
1876
+ return this.node(start, {
1877
+ kind: Kind.OBJECT_TYPE_DEFINITION,
1878
+ description,
1879
+ name,
1880
+ interfaces,
1881
+ directives,
1882
+ fields
1883
+ });
1884
+ }
1885
+ /**
1886
+ * ImplementsInterfaces :
1887
+ * - implements `&`? NamedType
1888
+ * - ImplementsInterfaces & NamedType
1889
+ */
1890
+ parseImplementsInterfaces() {
1891
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
1892
+ }
1893
+ /**
1894
+ * ```
1895
+ * FieldsDefinition : { FieldDefinition+ }
1896
+ * ```
1897
+ */
1898
+ parseFieldsDefinition() {
1899
+ return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R);
1900
+ }
1901
+ /**
1902
+ * FieldDefinition :
1903
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
1904
+ */
1905
+ parseFieldDefinition() {
1906
+ const start = this._lexer.token;
1907
+ const description = this.parseDescription();
1908
+ const name = this.parseName();
1909
+ const args = this.parseArgumentDefs();
1910
+ this.expectToken(TokenKind.COLON);
1911
+ const type = this.parseTypeReference();
1912
+ const directives = this.parseConstDirectives();
1913
+ return this.node(start, {
1914
+ kind: Kind.FIELD_DEFINITION,
1915
+ description,
1916
+ name,
1917
+ arguments: args,
1918
+ type,
1919
+ directives
1920
+ });
1921
+ }
1922
+ /**
1923
+ * ArgumentsDefinition : ( InputValueDefinition+ )
1924
+ */
1925
+ parseArgumentDefs() {
1926
+ return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R);
1927
+ }
1928
+ /**
1929
+ * InputValueDefinition :
1930
+ * - Description? Name : Type DefaultValue? Directives[Const]?
1931
+ */
1932
+ parseInputValueDef() {
1933
+ const start = this._lexer.token;
1934
+ const description = this.parseDescription();
1935
+ const name = this.parseName();
1936
+ this.expectToken(TokenKind.COLON);
1937
+ const type = this.parseTypeReference();
1938
+ let defaultValue;
1939
+ if (this.expectOptionalToken(TokenKind.EQUALS)) defaultValue = this.parseConstValueLiteral();
1940
+ const directives = this.parseConstDirectives();
1941
+ return this.node(start, {
1942
+ kind: Kind.INPUT_VALUE_DEFINITION,
1943
+ description,
1944
+ name,
1945
+ type,
1946
+ defaultValue,
1947
+ directives
1948
+ });
1949
+ }
1950
+ /**
1951
+ * InterfaceTypeDefinition :
1952
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
1953
+ */
1954
+ parseInterfaceTypeDefinition() {
1955
+ const start = this._lexer.token;
1956
+ const description = this.parseDescription();
1957
+ this.expectKeyword("interface");
1958
+ const name = this.parseName();
1959
+ const interfaces = this.parseImplementsInterfaces();
1960
+ const directives = this.parseConstDirectives();
1961
+ const fields = this.parseFieldsDefinition();
1962
+ return this.node(start, {
1963
+ kind: Kind.INTERFACE_TYPE_DEFINITION,
1964
+ description,
1965
+ name,
1966
+ interfaces,
1967
+ directives,
1968
+ fields
1969
+ });
1970
+ }
1971
+ /**
1972
+ * UnionTypeDefinition :
1973
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
1974
+ */
1975
+ parseUnionTypeDefinition() {
1976
+ const start = this._lexer.token;
1977
+ const description = this.parseDescription();
1978
+ this.expectKeyword("union");
1979
+ const name = this.parseName();
1980
+ const directives = this.parseConstDirectives();
1981
+ const types = this.parseUnionMemberTypes();
1982
+ return this.node(start, {
1983
+ kind: Kind.UNION_TYPE_DEFINITION,
1984
+ description,
1985
+ name,
1986
+ directives,
1987
+ types
1988
+ });
1989
+ }
1990
+ /**
1991
+ * UnionMemberTypes :
1992
+ * - = `|`? NamedType
1993
+ * - UnionMemberTypes | NamedType
1994
+ */
1995
+ parseUnionMemberTypes() {
1996
+ return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
1997
+ }
1998
+ /**
1999
+ * EnumTypeDefinition :
2000
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
2001
+ */
2002
+ parseEnumTypeDefinition() {
2003
+ const start = this._lexer.token;
2004
+ const description = this.parseDescription();
2005
+ this.expectKeyword("enum");
2006
+ const name = this.parseName();
2007
+ const directives = this.parseConstDirectives();
2008
+ const values = this.parseEnumValuesDefinition();
2009
+ return this.node(start, {
2010
+ kind: Kind.ENUM_TYPE_DEFINITION,
2011
+ description,
2012
+ name,
2013
+ directives,
2014
+ values
2015
+ });
2016
+ }
2017
+ /**
2018
+ * ```
2019
+ * EnumValuesDefinition : { EnumValueDefinition+ }
2020
+ * ```
2021
+ */
2022
+ parseEnumValuesDefinition() {
2023
+ return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R);
2024
+ }
2025
+ /**
2026
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
2027
+ */
2028
+ parseEnumValueDefinition() {
2029
+ const start = this._lexer.token;
2030
+ const description = this.parseDescription();
2031
+ const name = this.parseEnumValueName();
2032
+ const directives = this.parseConstDirectives();
2033
+ return this.node(start, {
2034
+ kind: Kind.ENUM_VALUE_DEFINITION,
2035
+ description,
2036
+ name,
2037
+ directives
2038
+ });
2039
+ }
2040
+ /**
2041
+ * EnumValue : Name but not `true`, `false` or `null`
2042
+ */
2043
+ parseEnumValueName() {
2044
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw syntaxError(this._lexer.source, this._lexer.token.start, `${getTokenDesc(this._lexer.token)} is reserved and cannot be used for an enum value.`);
2045
+ return this.parseName();
2046
+ }
2047
+ /**
2048
+ * InputObjectTypeDefinition :
2049
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
2050
+ */
2051
+ parseInputObjectTypeDefinition() {
2052
+ const start = this._lexer.token;
2053
+ const description = this.parseDescription();
2054
+ this.expectKeyword("input");
2055
+ const name = this.parseName();
2056
+ const directives = this.parseConstDirectives();
2057
+ const fields = this.parseInputFieldsDefinition();
2058
+ return this.node(start, {
2059
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
2060
+ description,
2061
+ name,
2062
+ directives,
2063
+ fields
2064
+ });
2065
+ }
2066
+ /**
2067
+ * ```
2068
+ * InputFieldsDefinition : { InputValueDefinition+ }
2069
+ * ```
2070
+ */
2071
+ parseInputFieldsDefinition() {
2072
+ return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R);
2073
+ }
2074
+ /**
2075
+ * TypeSystemExtension :
2076
+ * - SchemaExtension
2077
+ * - TypeExtension
2078
+ *
2079
+ * TypeExtension :
2080
+ * - ScalarTypeExtension
2081
+ * - ObjectTypeExtension
2082
+ * - InterfaceTypeExtension
2083
+ * - UnionTypeExtension
2084
+ * - EnumTypeExtension
2085
+ * - InputObjectTypeDefinition
2086
+ */
2087
+ parseTypeSystemExtension() {
2088
+ const keywordToken = this._lexer.lookahead();
2089
+ if (keywordToken.kind === TokenKind.NAME) switch (keywordToken.value) {
2090
+ case "schema": return this.parseSchemaExtension();
2091
+ case "scalar": return this.parseScalarTypeExtension();
2092
+ case "type": return this.parseObjectTypeExtension();
2093
+ case "interface": return this.parseInterfaceTypeExtension();
2094
+ case "union": return this.parseUnionTypeExtension();
2095
+ case "enum": return this.parseEnumTypeExtension();
2096
+ case "input": return this.parseInputObjectTypeExtension();
2097
+ }
2098
+ throw this.unexpected(keywordToken);
2099
+ }
2100
+ /**
2101
+ * ```
2102
+ * SchemaExtension :
2103
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
2104
+ * - extend schema Directives[Const]
2105
+ * ```
2106
+ */
2107
+ parseSchemaExtension() {
2108
+ const start = this._lexer.token;
2109
+ this.expectKeyword("extend");
2110
+ this.expectKeyword("schema");
2111
+ const directives = this.parseConstDirectives();
2112
+ const operationTypes = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
2113
+ if (directives.length === 0 && operationTypes.length === 0) throw this.unexpected();
2114
+ return this.node(start, {
2115
+ kind: Kind.SCHEMA_EXTENSION,
2116
+ directives,
2117
+ operationTypes
2118
+ });
2119
+ }
2120
+ /**
2121
+ * ScalarTypeExtension :
2122
+ * - extend scalar Name Directives[Const]
2123
+ */
2124
+ parseScalarTypeExtension() {
2125
+ const start = this._lexer.token;
2126
+ this.expectKeyword("extend");
2127
+ this.expectKeyword("scalar");
2128
+ const name = this.parseName();
2129
+ const directives = this.parseConstDirectives();
2130
+ if (directives.length === 0) throw this.unexpected();
2131
+ return this.node(start, {
2132
+ kind: Kind.SCALAR_TYPE_EXTENSION,
2133
+ name,
2134
+ directives
2135
+ });
2136
+ }
2137
+ /**
2138
+ * ObjectTypeExtension :
2139
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
2140
+ * - extend type Name ImplementsInterfaces? Directives[Const]
2141
+ * - extend type Name ImplementsInterfaces
2142
+ */
2143
+ parseObjectTypeExtension() {
2144
+ const start = this._lexer.token;
2145
+ this.expectKeyword("extend");
2146
+ this.expectKeyword("type");
2147
+ const name = this.parseName();
2148
+ const interfaces = this.parseImplementsInterfaces();
2149
+ const directives = this.parseConstDirectives();
2150
+ const fields = this.parseFieldsDefinition();
2151
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
2152
+ return this.node(start, {
2153
+ kind: Kind.OBJECT_TYPE_EXTENSION,
2154
+ name,
2155
+ interfaces,
2156
+ directives,
2157
+ fields
2158
+ });
2159
+ }
2160
+ /**
2161
+ * InterfaceTypeExtension :
2162
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
2163
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
2164
+ * - extend interface Name ImplementsInterfaces
2165
+ */
2166
+ parseInterfaceTypeExtension() {
2167
+ const start = this._lexer.token;
2168
+ this.expectKeyword("extend");
2169
+ this.expectKeyword("interface");
2170
+ const name = this.parseName();
2171
+ const interfaces = this.parseImplementsInterfaces();
2172
+ const directives = this.parseConstDirectives();
2173
+ const fields = this.parseFieldsDefinition();
2174
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
2175
+ return this.node(start, {
2176
+ kind: Kind.INTERFACE_TYPE_EXTENSION,
2177
+ name,
2178
+ interfaces,
2179
+ directives,
2180
+ fields
2181
+ });
2182
+ }
2183
+ /**
2184
+ * UnionTypeExtension :
2185
+ * - extend union Name Directives[Const]? UnionMemberTypes
2186
+ * - extend union Name Directives[Const]
2187
+ */
2188
+ parseUnionTypeExtension() {
2189
+ const start = this._lexer.token;
2190
+ this.expectKeyword("extend");
2191
+ this.expectKeyword("union");
2192
+ const name = this.parseName();
2193
+ const directives = this.parseConstDirectives();
2194
+ const types = this.parseUnionMemberTypes();
2195
+ if (directives.length === 0 && types.length === 0) throw this.unexpected();
2196
+ return this.node(start, {
2197
+ kind: Kind.UNION_TYPE_EXTENSION,
2198
+ name,
2199
+ directives,
2200
+ types
2201
+ });
2202
+ }
2203
+ /**
2204
+ * EnumTypeExtension :
2205
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
2206
+ * - extend enum Name Directives[Const]
2207
+ */
2208
+ parseEnumTypeExtension() {
2209
+ const start = this._lexer.token;
2210
+ this.expectKeyword("extend");
2211
+ this.expectKeyword("enum");
2212
+ const name = this.parseName();
2213
+ const directives = this.parseConstDirectives();
2214
+ const values = this.parseEnumValuesDefinition();
2215
+ if (directives.length === 0 && values.length === 0) throw this.unexpected();
2216
+ return this.node(start, {
2217
+ kind: Kind.ENUM_TYPE_EXTENSION,
2218
+ name,
2219
+ directives,
2220
+ values
2221
+ });
2222
+ }
2223
+ /**
2224
+ * InputObjectTypeExtension :
2225
+ * - extend input Name Directives[Const]? InputFieldsDefinition
2226
+ * - extend input Name Directives[Const]
2227
+ */
2228
+ parseInputObjectTypeExtension() {
2229
+ const start = this._lexer.token;
2230
+ this.expectKeyword("extend");
2231
+ this.expectKeyword("input");
2232
+ const name = this.parseName();
2233
+ const directives = this.parseConstDirectives();
2234
+ const fields = this.parseInputFieldsDefinition();
2235
+ if (directives.length === 0 && fields.length === 0) throw this.unexpected();
2236
+ return this.node(start, {
2237
+ kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
2238
+ name,
2239
+ directives,
2240
+ fields
2241
+ });
2242
+ }
2243
+ /**
2244
+ * ```
2245
+ * DirectiveDefinition :
2246
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
2247
+ * ```
2248
+ */
2249
+ parseDirectiveDefinition() {
2250
+ const start = this._lexer.token;
2251
+ const description = this.parseDescription();
2252
+ this.expectKeyword("directive");
2253
+ this.expectToken(TokenKind.AT);
2254
+ const name = this.parseName();
2255
+ const args = this.parseArgumentDefs();
2256
+ const repeatable = this.expectOptionalKeyword("repeatable");
2257
+ this.expectKeyword("on");
2258
+ const locations = this.parseDirectiveLocations();
2259
+ return this.node(start, {
2260
+ kind: Kind.DIRECTIVE_DEFINITION,
2261
+ description,
2262
+ name,
2263
+ arguments: args,
2264
+ repeatable,
2265
+ locations
2266
+ });
2267
+ }
2268
+ /**
2269
+ * DirectiveLocations :
2270
+ * - `|`? DirectiveLocation
2271
+ * - DirectiveLocations | DirectiveLocation
2272
+ */
2273
+ parseDirectiveLocations() {
2274
+ return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
2275
+ }
2276
+ parseDirectiveLocation() {
2277
+ const start = this._lexer.token;
2278
+ const name = this.parseName();
2279
+ if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) return name;
2280
+ throw this.unexpected(start);
2281
+ }
2282
+ /**
2283
+ * SchemaCoordinate :
2284
+ * - Name
2285
+ * - Name . Name
2286
+ * - Name . Name ( Name : )
2287
+ * - \@ Name
2288
+ * - \@ Name ( Name : )
2289
+ */
2290
+ parseSchemaCoordinate() {
2291
+ const start = this._lexer.token;
2292
+ const ofDirective = this.expectOptionalToken(TokenKind.AT);
2293
+ const name = this.parseName();
2294
+ let memberName;
2295
+ if (!ofDirective && this.expectOptionalToken(TokenKind.DOT)) memberName = this.parseName();
2296
+ let argumentName;
2297
+ if ((ofDirective || memberName) && this.expectOptionalToken(TokenKind.PAREN_L)) {
2298
+ argumentName = this.parseName();
2299
+ this.expectToken(TokenKind.COLON);
2300
+ this.expectToken(TokenKind.PAREN_R);
2301
+ }
2302
+ if (ofDirective) {
2303
+ if (argumentName) return this.node(start, {
2304
+ kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE,
2305
+ name,
2306
+ argumentName
2307
+ });
2308
+ return this.node(start, {
2309
+ kind: Kind.DIRECTIVE_COORDINATE,
2310
+ name
2311
+ });
2312
+ } else if (memberName) {
2313
+ if (argumentName) return this.node(start, {
2314
+ kind: Kind.ARGUMENT_COORDINATE,
2315
+ name,
2316
+ fieldName: memberName,
2317
+ argumentName
2318
+ });
2319
+ return this.node(start, {
2320
+ kind: Kind.MEMBER_COORDINATE,
2321
+ name,
2322
+ memberName
2323
+ });
2324
+ }
2325
+ return this.node(start, {
2326
+ kind: Kind.TYPE_COORDINATE,
2327
+ name
2328
+ });
2329
+ }
2330
+ /**
2331
+ * Returns a node that, if configured to do so, sets a "loc" field as a
2332
+ * location object, used to identify the place in the source that created a
2333
+ * given parsed object.
2334
+ */
2335
+ node(startToken, node) {
2336
+ if (this._options.noLocation !== true) node.loc = new Location(startToken, this._lexer.lastToken, this._lexer.source);
2337
+ return node;
2338
+ }
2339
+ /**
2340
+ * Determines if the next token is of a given kind
2341
+ */
2342
+ peek(kind) {
2343
+ return this._lexer.token.kind === kind;
2344
+ }
2345
+ /**
2346
+ * If the next token is of the given kind, return that token after advancing the lexer.
2347
+ * Otherwise, do not change the parser state and throw an error.
2348
+ */
2349
+ expectToken(kind) {
2350
+ const token = this._lexer.token;
2351
+ if (token.kind === kind) {
2352
+ this.advanceLexer();
2353
+ return token;
2354
+ }
2355
+ throw syntaxError(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`);
2356
+ }
2357
+ /**
2358
+ * If the next token is of the given kind, return "true" after advancing the lexer.
2359
+ * Otherwise, do not change the parser state and return "false".
2360
+ */
2361
+ expectOptionalToken(kind) {
2362
+ if (this._lexer.token.kind === kind) {
2363
+ this.advanceLexer();
2364
+ return true;
2365
+ }
2366
+ return false;
2367
+ }
2368
+ /**
2369
+ * If the next token is a given keyword, advance the lexer.
2370
+ * Otherwise, do not change the parser state and throw an error.
2371
+ */
2372
+ expectKeyword(value) {
2373
+ const token = this._lexer.token;
2374
+ if (token.kind === TokenKind.NAME && token.value === value) this.advanceLexer();
2375
+ else throw syntaxError(this._lexer.source, token.start, `Expected "${value}", found ${getTokenDesc(token)}.`);
2376
+ }
2377
+ /**
2378
+ * If the next token is a given keyword, return "true" after advancing the lexer.
2379
+ * Otherwise, do not change the parser state and return "false".
2380
+ */
2381
+ expectOptionalKeyword(value) {
2382
+ const token = this._lexer.token;
2383
+ if (token.kind === TokenKind.NAME && token.value === value) {
2384
+ this.advanceLexer();
2385
+ return true;
2386
+ }
2387
+ return false;
2388
+ }
2389
+ /**
2390
+ * Helper function for creating an error when an unexpected lexed token is encountered.
2391
+ */
2392
+ unexpected(atToken) {
2393
+ const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
2394
+ return syntaxError(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`);
2395
+ }
2396
+ /**
2397
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
2398
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2399
+ * Advances the parser to the next lex token after the closing token.
2400
+ */
2401
+ any(openKind, parseFn, closeKind) {
2402
+ this.expectToken(openKind);
2403
+ const nodes = [];
2404
+ while (!this.expectOptionalToken(closeKind)) nodes.push(parseFn.call(this));
2405
+ return nodes;
2406
+ }
2407
+ /**
2408
+ * Returns a list of parse nodes, determined by the parseFn.
2409
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
2410
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
2411
+ * Advances the parser to the next lex token after the closing token.
2412
+ */
2413
+ optionalMany(openKind, parseFn, closeKind) {
2414
+ if (this.expectOptionalToken(openKind)) {
2415
+ const nodes = [];
2416
+ do
2417
+ nodes.push(parseFn.call(this));
2418
+ while (!this.expectOptionalToken(closeKind));
2419
+ return nodes;
2420
+ }
2421
+ return [];
2422
+ }
2423
+ /**
2424
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2425
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2426
+ * Advances the parser to the next lex token after the closing token.
2427
+ */
2428
+ many(openKind, parseFn, closeKind) {
2429
+ this.expectToken(openKind);
2430
+ const nodes = [];
2431
+ do
2432
+ nodes.push(parseFn.call(this));
2433
+ while (!this.expectOptionalToken(closeKind));
2434
+ return nodes;
2435
+ }
2436
+ /**
2437
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
2438
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
2439
+ * Advances the parser to the next lex token after last item in the list.
2440
+ */
2441
+ delimitedMany(delimiterKind, parseFn) {
2442
+ this.expectOptionalToken(delimiterKind);
2443
+ const nodes = [];
2444
+ do
2445
+ nodes.push(parseFn.call(this));
2446
+ while (this.expectOptionalToken(delimiterKind));
2447
+ return nodes;
2448
+ }
2449
+ advanceLexer() {
2450
+ const { maxTokens } = this._options;
2451
+ const token = this._lexer.advance();
2452
+ if (token.kind !== TokenKind.EOF) {
2453
+ ++this._tokenCounter;
2454
+ if (maxTokens !== void 0 && this._tokenCounter > maxTokens) throw syntaxError(this._lexer.source, token.start, `Document contains more that ${maxTokens} tokens. Parsing aborted.`);
2455
+ }
2456
+ }
2457
+ };
2458
+ /**
2459
+ * A helper function to describe a token as a string for debugging.
2460
+ */
2461
+ function getTokenDesc(token) {
2462
+ const value = token.value;
2463
+ return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
2464
+ }
2465
+ /**
2466
+ * A helper function to describe a token kind as a string for debugging.
2467
+ */
2468
+ function getTokenKindDesc(kind) {
2469
+ return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
2470
+ }
2471
+ //#endregion
2472
+ export { Kind, parse };
2473
+
2474
+ //# sourceMappingURL=graphql-Cr1ia6fo.js.map