@zuplo/cli 6.69.6 → 6.69.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/__tests__/integration/confirm-production-deploy.integration.test.d.ts +2 -0
  2. package/dist/__tests__/integration/confirm-production-deploy.integration.test.d.ts.map +1 -0
  3. package/dist/__tests__/integration/confirm-production-deploy.integration.test.js +184 -0
  4. package/dist/__tests__/integration/confirm-production-deploy.integration.test.js.map +1 -0
  5. package/dist/__tests__/integration/deploy.integration.test.js +1 -0
  6. package/dist/__tests__/integration/deploy.integration.test.js.map +1 -1
  7. package/dist/__tests__/integration/jest-mocks-setup.js +3 -0
  8. package/dist/__tests__/integration/jest-mocks-setup.js.map +1 -1
  9. package/dist/__tests__/integration/whoami.integration.test.js +27 -0
  10. package/dist/__tests__/integration/whoami.integration.test.js.map +1 -1
  11. package/dist/bucket/list/handler.d.ts +8 -0
  12. package/dist/bucket/list/handler.d.ts.map +1 -0
  13. package/dist/bucket/list/handler.js +54 -0
  14. package/dist/bucket/list/handler.js.map +1 -0
  15. package/dist/bucket/models.d.ts +23 -0
  16. package/dist/bucket/models.d.ts.map +1 -0
  17. package/dist/bucket/models.js +2 -0
  18. package/dist/bucket/models.js.map +1 -0
  19. package/dist/cli.js +4 -0
  20. package/dist/cli.js.map +1 -1
  21. package/dist/cmds/bucket/index.d.ts +4 -0
  22. package/dist/cmds/bucket/index.d.ts.map +1 -0
  23. package/dist/cmds/bucket/index.js +9 -0
  24. package/dist/cmds/bucket/index.js.map +1 -0
  25. package/dist/cmds/bucket/list.d.ts +9 -0
  26. package/dist/cmds/bucket/list.d.ts.map +1 -0
  27. package/dist/cmds/bucket/list.js +60 -0
  28. package/dist/cmds/bucket/list.js.map +1 -0
  29. package/dist/cmds/deploy.d.ts.map +1 -1
  30. package/dist/cmds/deploy.js +4 -1
  31. package/dist/cmds/deploy.js.map +1 -1
  32. package/dist/cmds/logout.d.ts +9 -0
  33. package/dist/cmds/logout.d.ts.map +1 -0
  34. package/dist/cmds/logout.js +23 -0
  35. package/dist/cmds/logout.js.map +1 -0
  36. package/dist/cmds/whoami.d.ts.map +1 -1
  37. package/dist/cmds/whoami.js +1 -2
  38. package/dist/cmds/whoami.js.map +1 -1
  39. package/dist/common/middleware/confirm-production-deploy.d.ts +4 -0
  40. package/dist/common/middleware/confirm-production-deploy.d.ts.map +1 -0
  41. package/dist/common/middleware/confirm-production-deploy.js +49 -0
  42. package/dist/common/middleware/confirm-production-deploy.js.map +1 -0
  43. package/dist/common/middleware/get-environment-param.d.ts +6 -0
  44. package/dist/common/middleware/get-environment-param.d.ts.map +1 -1
  45. package/dist/common/middleware/get-environment-param.js +15 -0
  46. package/dist/common/middleware/get-environment-param.js.map +1 -1
  47. package/dist/common/middleware/get-environment-param.test.d.ts +2 -0
  48. package/dist/common/middleware/get-environment-param.test.d.ts.map +1 -0
  49. package/dist/common/middleware/get-environment-param.test.js +33 -0
  50. package/dist/common/middleware/get-environment-param.test.js.map +1 -0
  51. package/dist/common/output.d.ts +3 -0
  52. package/dist/common/output.d.ts.map +1 -1
  53. package/dist/common/output.js +11 -0
  54. package/dist/common/output.js.map +1 -1
  55. package/dist/common/read-linked-config.d.ts +6 -1
  56. package/dist/common/read-linked-config.d.ts.map +1 -1
  57. package/dist/common/read-linked-config.js +14 -4
  58. package/dist/common/read-linked-config.js.map +1 -1
  59. package/dist/common/read-linked-config.test.js +97 -0
  60. package/dist/common/read-linked-config.test.js.map +1 -1
  61. package/dist/deploy/environments.d.ts +1 -0
  62. package/dist/deploy/environments.d.ts.map +1 -1
  63. package/dist/deploy/environments.js +11 -7
  64. package/dist/deploy/environments.js.map +1 -1
  65. package/dist/login/logout.d.ts +5 -0
  66. package/dist/login/logout.d.ts.map +1 -0
  67. package/dist/login/logout.js +6 -0
  68. package/dist/login/logout.js.map +1 -0
  69. package/dist/login/tokens.d.ts +1 -0
  70. package/dist/login/tokens.d.ts.map +1 -1
  71. package/dist/login/tokens.js +16 -1
  72. package/dist/login/tokens.js.map +1 -1
  73. package/dist/tsconfig.tsbuildinfo +1 -1
  74. package/dist/whoami/handler.d.ts +1 -1
  75. package/dist/whoami/handler.d.ts.map +1 -1
  76. package/dist/whoami/handler.js +8 -1
  77. package/dist/whoami/handler.js.map +1 -1
  78. package/node_modules/@zuplo/core/customer.cli.minified.js +225 -211
  79. package/node_modules/@zuplo/core/index.minified.js +237 -223
  80. package/node_modules/@zuplo/core/package.json +1 -1
  81. package/node_modules/@zuplo/editor/node_modules/find-my-way/.github/workflows/node.js.yml +1 -1
  82. package/node_modules/@zuplo/editor/node_modules/find-my-way/README.md +10 -0
  83. package/node_modules/@zuplo/editor/node_modules/find-my-way/index.d.ts +6 -0
  84. package/node_modules/@zuplo/editor/node_modules/find-my-way/index.js +37 -4
  85. package/node_modules/@zuplo/editor/node_modules/find-my-way/lib/handler-storage.js +2 -2
  86. package/node_modules/@zuplo/editor/node_modules/find-my-way/package.json +3 -3
  87. package/node_modules/@zuplo/editor/node_modules/find-my-way/test/repro-issue-414.test.js +57 -0
  88. package/node_modules/@zuplo/editor/node_modules/find-my-way/test/types/router.test-d.ts +1 -0
  89. package/node_modules/@zuplo/graphql/package.json +1 -1
  90. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  91. package/node_modules/@zuplo/otel/package.json +1 -1
  92. package/node_modules/@zuplo/runtime/package.json +1 -1
  93. package/node_modules/graphql/index.d.ts +1 -0
  94. package/node_modules/graphql/language/ast.d.ts +10 -1
  95. package/node_modules/graphql/language/ast.js +8 -1
  96. package/node_modules/graphql/language/ast.mjs +8 -1
  97. package/node_modules/graphql/language/directiveLocation.d.ts +1 -0
  98. package/node_modules/graphql/language/directiveLocation.js +1 -0
  99. package/node_modules/graphql/language/directiveLocation.mjs +1 -0
  100. package/node_modules/graphql/language/index.d.ts +1 -0
  101. package/node_modules/graphql/language/kinds.d.ts +1 -0
  102. package/node_modules/graphql/language/kinds.js +1 -0
  103. package/node_modules/graphql/language/kinds.mjs +1 -0
  104. package/node_modules/graphql/language/parser.d.ts +14 -0
  105. package/node_modules/graphql/language/parser.js +33 -0
  106. package/node_modules/graphql/language/parser.mjs +33 -0
  107. package/node_modules/graphql/language/predicates.js +3 -1
  108. package/node_modules/graphql/language/predicates.mjs +5 -1
  109. package/node_modules/graphql/language/printer.js +13 -1
  110. package/node_modules/graphql/language/printer.mjs +13 -1
  111. package/node_modules/graphql/package.json +1 -1
  112. package/node_modules/graphql/type/directives.d.ts +9 -1
  113. package/node_modules/graphql/type/directives.js +10 -1
  114. package/node_modules/graphql/type/directives.mjs +10 -1
  115. package/node_modules/graphql/type/introspection.js +24 -1
  116. package/node_modules/graphql/type/introspection.mjs +24 -1
  117. package/node_modules/graphql/utilities/buildASTSchema.js +4 -0
  118. package/node_modules/graphql/utilities/buildASTSchema.mjs +4 -0
  119. package/node_modules/graphql/utilities/buildClientSchema.js +1 -0
  120. package/node_modules/graphql/utilities/buildClientSchema.mjs +1 -0
  121. package/node_modules/graphql/utilities/extendSchema.js +58 -3
  122. package/node_modules/graphql/utilities/extendSchema.mjs +58 -3
  123. package/node_modules/graphql/utilities/getIntrospectionQuery.d.ts +16 -0
  124. package/node_modules/graphql/utilities/getIntrospectionQuery.js +31 -38
  125. package/node_modules/graphql/utilities/getIntrospectionQuery.mjs +31 -38
  126. package/node_modules/graphql/utilities/introspectionFromSchema.js +1 -0
  127. package/node_modules/graphql/utilities/introspectionFromSchema.mjs +1 -0
  128. package/node_modules/graphql/utilities/printSchema.js +1 -0
  129. package/node_modules/graphql/utilities/printSchema.mjs +1 -0
  130. package/node_modules/graphql/utilities/valueFromAST.js +12 -2
  131. package/node_modules/graphql/utilities/valueFromAST.mjs +12 -2
  132. package/node_modules/graphql/validation/rules/KnownDirectivesRule.js +4 -0
  133. package/node_modules/graphql/validation/rules/KnownDirectivesRule.mjs +4 -0
  134. package/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.js +12 -0
  135. package/node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.mjs +12 -0
  136. package/node_modules/graphql/version.js +3 -3
  137. package/node_modules/graphql/version.mjs +3 -3
  138. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/core",
3
- "version": "6.69.6",
3
+ "version": "6.69.8",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -63,6 +63,6 @@ jobs:
63
63
  pull-requests: write
64
64
  contents: write
65
65
  steps:
66
- - uses: fastify/github-action-merge-dependabot@1b2ed42db8f9d81a46bac83adedfc03eb5149dff # v3.11.2
66
+ - uses: fastify/github-action-merge-dependabot@30c3f8f14a4f7b315ba38dbc1b793d27128fef82 # v3.12.0
67
67
  with:
68
68
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -126,6 +126,16 @@ const router = require('find-my-way')({
126
126
  })
127
127
  ```
128
128
 
129
+ If you want to handle the case where the `maxParamLength` is exceeded, you can provide a custom `onMaxParamLength` handler. This handler will be invoked if no other route (e.g. a wildcard) matches the path.
130
+ ```js
131
+ const router = require('find-my-way')({
132
+ onMaxParamLength: function (path, req, res) {
133
+ res.statusCode = 414
134
+ res.end('URI Too Long')
135
+ }
136
+ })
137
+ ```
138
+
129
139
  If you are using a regex based route, `find-my-way` will throw an error if detects potentially catastrophic exponential-time regular expressions *(internally uses [`safe-regex2`](https://github.com/fastify/safe-regex2))*.<br/>
130
140
  If you want to disable this behavior, pass the option `allowUnsafeRegex`.
131
141
  ```js
@@ -103,6 +103,12 @@ declare namespace Router {
103
103
  res: Res<V>
104
104
  ): void;
105
105
 
106
+ onMaxParamLength?(
107
+ path: string,
108
+ req: Req<V>,
109
+ res: Res<V>
110
+ ): void;
111
+
106
112
  constraints? : {
107
113
  [key: string]: ConstraintStrategy<V>
108
114
  }
@@ -96,6 +96,7 @@ function Router (opts) {
96
96
  this.ignoreTrailingSlash = opts.ignoreTrailingSlash || false
97
97
  this.ignoreDuplicateSlashes = opts.ignoreDuplicateSlashes || false
98
98
  this.maxParamLength = opts.maxParamLength || 100
99
+ this.onMaxParamLength = opts.onMaxParamLength || null
99
100
  this.allowUnsafeRegex = opts.allowUnsafeRegex || false
100
101
  this.constrainer = new Constrainer(opts.constraints)
101
102
  this.useSemicolonDelimiter = opts.useSemicolonDelimiter || false
@@ -608,6 +609,7 @@ Router.prototype.find = function find (method, path, derivedConstraints) {
608
609
  const pathLen = path.length
609
610
 
610
611
  const brothersNodesStack = []
612
+ let maxParamLengthExceeded = false
611
613
 
612
614
  while (true) {
613
615
  if (pathIndex === pathLen && currentNode.isLeafNode) {
@@ -626,6 +628,9 @@ Router.prototype.find = function find (method, path, derivedConstraints) {
626
628
 
627
629
  if (node === null) {
628
630
  if (brothersNodesStack.length === 0) {
631
+ if (maxParamLengthExceeded && this.onMaxParamLength) {
632
+ return this._onMaxParamLength(originPath)
633
+ }
629
634
  return null
630
635
  }
631
636
 
@@ -667,18 +672,34 @@ Router.prototype.find = function find (method, path, derivedConstraints) {
667
672
 
668
673
  if (currentNode.isRegex) {
669
674
  const matchedParameters = currentNode.regex.exec(param)
670
- if (matchedParameters === null) continue
675
+ if (matchedParameters === null) {
676
+ node = null
677
+ continue
678
+ }
671
679
 
680
+ let regexMaxParamLengthExceeded = false
672
681
  for (let i = 1; i < matchedParameters.length; i++) {
673
682
  const matchedParam = matchedParameters[i]
674
683
  if (matchedParam.length > maxParamLength) {
675
- return null
684
+ regexMaxParamLengthExceeded = true
685
+ break
676
686
  }
677
- params.push(matchedParam)
687
+ }
688
+
689
+ if (regexMaxParamLengthExceeded) {
690
+ maxParamLengthExceeded = true
691
+ node = null
692
+ continue
693
+ }
694
+
695
+ for (let i = 1; i < matchedParameters.length; i++) {
696
+ params.push(matchedParameters[i])
678
697
  }
679
698
  } else {
680
699
  if (param.length > maxParamLength) {
681
- return null
700
+ maxParamLengthExceeded = true
701
+ node = null
702
+ continue
682
703
  }
683
704
  params.push(param)
684
705
  }
@@ -719,6 +740,18 @@ Router.prototype._onBadUrl = function (path) {
719
740
  }
720
741
  }
721
742
 
743
+ Router.prototype._onMaxParamLength = function (path) {
744
+ if (this.onMaxParamLength === null) {
745
+ return null
746
+ }
747
+ const onMaxParamLength = this.onMaxParamLength
748
+ return {
749
+ handler: (req, res, ctx) => onMaxParamLength(path, req, res),
750
+ params: {},
751
+ store: null
752
+ }
753
+ }
754
+
722
755
  Router.prototype.prettyPrint = function (options = {}) {
723
756
  const method = options.method
724
757
 
@@ -165,8 +165,8 @@ class HandlerStorage {
165
165
  }
166
166
  }
167
167
 
168
- // Return the first handler who's bit is set in the candidates https://stackoverflow.com/questions/18134985/how-to-find-index-of-first-set-bit
169
- lines.push('return this.handlers[Math.floor(Math.log2(candidates))]')
168
+ // Return the highest set bit index in the candidates bitmask.
169
+ lines.push('return this.handlers[31 - Math.clz32(candidates)]')
170
170
 
171
171
  this._getHandlerMatchingConstraints = new Function('derivedConstraints', lines.join('\n')) // eslint-disable-line
172
172
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-my-way",
3
- "version": "9.5.0",
3
+ "version": "9.6.0",
4
4
  "description": "Crazy fast http radix based router",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -36,10 +36,10 @@
36
36
  "devDependencies": {
37
37
  "@types/node": "^25.0.3",
38
38
  "benchmark": "^2.1.4",
39
- "borp": "^0.21.0",
39
+ "borp": "^1.0.0",
40
40
  "chalk": "^5.4.1",
41
41
  "inquirer": "^13.1.0",
42
- "pre-commit": "^1.2.2",
42
+ "pre-commit": "^2.0.0",
43
43
  "proxyquire": "^2.1.3",
44
44
  "rfdc": "^1.3.0",
45
45
  "simple-git": "^3.7.1",
@@ -0,0 +1,57 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const FindMyWay = require('../')
5
+
6
+ test('should return null when maxParamLength is exceeded (current behavior)', t => {
7
+ t.plan(1)
8
+ const findMyWay = FindMyWay({ maxParamLength: 5 })
9
+ findMyWay.on('GET', '/test/:param', () => 'param')
10
+
11
+ const handle = findMyWay.find('GET', '/test/123456')
12
+ t.assert.equal(handle, null)
13
+ })
14
+
15
+ test('should still match other routes if one parametric route exceeds maxParamLength (static)', t => {
16
+ t.plan(2)
17
+ const findMyWay = FindMyWay({ maxParamLength: 5 })
18
+ findMyWay.on('GET', '/test/:param', () => 'param')
19
+ findMyWay.on('GET', '/test/special', () => 'special')
20
+
21
+ const handle = findMyWay.find('GET', '/test/special')
22
+ t.assert.ok(handle)
23
+ t.assert.equal(handle.handler(), 'special')
24
+ })
25
+
26
+ test('should fail to match any route if the only candidate exceeds maxParamLength', t => {
27
+ t.plan(1)
28
+ const findMyWay = FindMyWay({ maxParamLength: 5 })
29
+ findMyWay.on('GET', '/test/:param', () => 'param')
30
+
31
+ const handle = findMyWay.find('GET', '/test/123456789')
32
+ t.assert.equal(handle, null)
33
+ })
34
+
35
+ test('should match wildcard if parametric exceeds maxParamLength', t => {
36
+ t.plan(2)
37
+ const findMyWay = FindMyWay({ maxParamLength: 5 })
38
+ findMyWay.on('GET', '/test/:param', () => 'param')
39
+ findMyWay.on('GET', '/test/*', () => 'wildcard')
40
+
41
+ const handle = findMyWay.find('GET', '/test/123456789')
42
+ t.assert.ok(handle)
43
+ t.assert.equal(handle.handler(), 'wildcard')
44
+ })
45
+
46
+ test('should return custom onMaxParamLength handler if provided and no other route matches', t => {
47
+ t.plan(2)
48
+ const findMyWay = FindMyWay({
49
+ maxParamLength: 5,
50
+ onMaxParamLength: (path, req, res) => 'custom error'
51
+ })
52
+ findMyWay.on('GET', '/test/:param', () => 'param')
53
+
54
+ const handle = findMyWay.find('GET', '/test/123456')
55
+ t.assert.ok(handle)
56
+ t.assert.equal(handle.handler(), 'custom error')
57
+ })
@@ -27,6 +27,7 @@ expectType<string>(Router.trimLastSlash('/hello/'))
27
27
  querystringParser: (queryString) => {},
28
28
  defaultRoute (http1Req, http1Res) {},
29
29
  onBadUrl (path, http1Req, http1Res) {},
30
+ onMaxParamLength (path, http1Req, http1Res) {},
30
31
  constraints: {
31
32
  foo: {
32
33
  name: 'foo',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/graphql",
3
3
  "type": "module",
4
- "version": "6.69.6",
4
+ "version": "6.69.8",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -2,7 +2,7 @@
2
2
  "name": "@zuplo/openapi-tools",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "6.69.6",
5
+ "version": "6.69.8",
6
6
  "description": "Tooling for OpenAPI files",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/otel",
3
3
  "type": "module",
4
- "version": "6.69.6",
4
+ "version": "6.69.8",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.69.6",
4
+ "version": "6.69.8",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -280,6 +280,7 @@ export type {
280
280
  UnionTypeExtensionNode,
281
281
  EnumTypeExtensionNode,
282
282
  InputObjectTypeExtensionNode,
283
+ DirectiveExtensionNode,
283
284
  SchemaCoordinateNode,
284
285
  TypeCoordinateNode,
285
286
  MemberCoordinateNode,
@@ -135,6 +135,7 @@ export declare type ASTNode =
135
135
  | UnionTypeExtensionNode
136
136
  | EnumTypeExtensionNode
137
137
  | InputObjectTypeExtensionNode
138
+ | DirectiveExtensionNode
138
139
  | TypeCoordinateNode
139
140
  | MemberCoordinateNode
140
141
  | ArgumentCoordinateNode
@@ -480,13 +481,15 @@ export interface DirectiveDefinitionNode {
480
481
  readonly description?: StringValueNode;
481
482
  readonly name: NameNode;
482
483
  readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
484
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
483
485
  readonly repeatable: boolean;
484
486
  readonly locations: ReadonlyArray<NameNode>;
485
487
  }
486
488
  /** Type System Extensions */
487
489
  export declare type TypeSystemExtensionNode =
488
490
  | SchemaExtensionNode
489
- | TypeExtensionNode;
491
+ | TypeExtensionNode
492
+ | DirectiveExtensionNode;
490
493
  export interface SchemaExtensionNode {
491
494
  readonly kind: Kind.SCHEMA_EXTENSION;
492
495
  readonly loc?: Location;
@@ -544,6 +547,12 @@ export interface InputObjectTypeExtensionNode {
544
547
  readonly directives?: ReadonlyArray<ConstDirectiveNode>;
545
548
  readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
546
549
  }
550
+ export interface DirectiveExtensionNode {
551
+ readonly kind: Kind.DIRECTIVE_EXTENSION;
552
+ readonly loc?: Location;
553
+ readonly name: NameNode;
554
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
555
+ }
547
556
  /** Schema Coordinates */
548
557
  export declare type SchemaCoordinateNode =
549
558
  | TypeCoordinateNode
@@ -200,8 +200,15 @@ const QueryDocumentKeys = {
200
200
  EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
201
201
  EnumValueDefinition: ['description', 'name', 'directives'],
202
202
  InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
203
- DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
203
+ DirectiveDefinition: [
204
+ 'description',
205
+ 'name',
206
+ 'arguments',
207
+ 'directives',
208
+ 'locations',
209
+ ],
204
210
  SchemaExtension: ['directives', 'operationTypes'],
211
+ DirectiveExtension: ['name', 'directives'],
205
212
  ScalarTypeExtension: ['name', 'directives'],
206
213
  ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
207
214
  InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
@@ -184,8 +184,15 @@ export const QueryDocumentKeys = {
184
184
  EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
185
185
  EnumValueDefinition: ['description', 'name', 'directives'],
186
186
  InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
187
- DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
187
+ DirectiveDefinition: [
188
+ 'description',
189
+ 'name',
190
+ 'arguments',
191
+ 'directives',
192
+ 'locations',
193
+ ],
188
194
  SchemaExtension: ['directives', 'operationTypes'],
195
+ DirectiveExtension: ['name', 'directives'],
189
196
  ScalarTypeExtension: ['name', 'directives'],
190
197
  ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
191
198
  InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
@@ -23,6 +23,7 @@ declare enum DirectiveLocation {
23
23
  ENUM_VALUE = 'ENUM_VALUE',
24
24
  INPUT_OBJECT = 'INPUT_OBJECT',
25
25
  INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION',
26
+ DIRECTIVE_DEFINITION = 'DIRECTIVE_DEFINITION',
26
27
  }
27
28
  export { DirectiveLocation };
28
29
  /**
@@ -31,6 +31,7 @@ exports.DirectiveLocation = DirectiveLocation;
31
31
  DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE';
32
32
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
33
33
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
34
+ DirectiveLocation['DIRECTIVE_DEFINITION'] = 'DIRECTIVE_DEFINITION';
34
35
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
35
36
  /**
36
37
  * The enum type representing the directive location values.
@@ -23,6 +23,7 @@ var DirectiveLocation;
23
23
  DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE';
24
24
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
25
25
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
26
+ DirectiveLocation['DIRECTIVE_DEFINITION'] = 'DIRECTIVE_DEFINITION';
26
27
  })(DirectiveLocation || (DirectiveLocation = {}));
27
28
 
28
29
  export { DirectiveLocation };
@@ -86,6 +86,7 @@ export type {
86
86
  UnionTypeExtensionNode,
87
87
  EnumTypeExtensionNode,
88
88
  InputObjectTypeExtensionNode,
89
+ DirectiveExtensionNode,
89
90
  SchemaCoordinateNode,
90
91
  TypeCoordinateNode,
91
92
  MemberCoordinateNode,
@@ -49,6 +49,7 @@ declare enum Kind {
49
49
  DIRECTIVE_DEFINITION = 'DirectiveDefinition',
50
50
  /** Type System Extensions */
51
51
  SCHEMA_EXTENSION = 'SchemaExtension',
52
+ DIRECTIVE_EXTENSION = 'DirectiveExtension',
52
53
  /** Type Extensions */
53
54
  SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension',
54
55
  OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension',
@@ -49,6 +49,7 @@ exports.Kind = Kind;
49
49
  Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition';
50
50
  Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition';
51
51
  Kind['SCHEMA_EXTENSION'] = 'SchemaExtension';
52
+ Kind['DIRECTIVE_EXTENSION'] = 'DirectiveExtension';
52
53
  Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension';
53
54
  Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension';
54
55
  Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension';
@@ -41,6 +41,7 @@ var Kind;
41
41
  Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition';
42
42
  Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition';
43
43
  Kind['SCHEMA_EXTENSION'] = 'SchemaExtension';
44
+ Kind['DIRECTIVE_EXTENSION'] = 'DirectiveExtension';
44
45
  Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension';
45
46
  Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension';
46
47
  Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension';
@@ -10,6 +10,7 @@ import type {
10
10
  ConstValueNode,
11
11
  DefinitionNode,
12
12
  DirectiveDefinitionNode,
13
+ DirectiveExtensionNode,
13
14
  DirectiveNode,
14
15
  DocumentNode,
15
16
  EnumTypeDefinitionNode,
@@ -89,6 +90,17 @@ export interface ParseOptions {
89
90
  * ```
90
91
  */
91
92
  allowLegacyFragmentVariables?: boolean;
93
+ /**
94
+ * EXPERIMENTAL:
95
+ *
96
+ * If enabled, the parser will parse directives on directive definitions.
97
+ * This syntax is not part of the GraphQL specification and may change.
98
+ *
99
+ * ```graphql
100
+ * directive @foo @bar on FIELD
101
+ * ```
102
+ */
103
+ experimentalDirectivesOnDirectiveDefinitions?: boolean;
92
104
  /**
93
105
  * You may override the Lexer class used to lex the source; this is used by
94
106
  * schema coordinates to introduce a lexer with a restricted syntax.
@@ -447,6 +459,7 @@ export declare class Parser {
447
459
  * - UnionTypeExtension
448
460
  * - EnumTypeExtension
449
461
  * - InputObjectTypeDefinition
462
+ * - DirectiveDefinitionExtension
450
463
  */
451
464
  parseTypeSystemExtension(): TypeSystemExtensionNode;
452
465
  /**
@@ -494,6 +507,7 @@ export declare class Parser {
494
507
  * - extend input Name Directives[Const]
495
508
  */
496
509
  parseInputObjectTypeExtension(): InputObjectTypeExtensionNode;
510
+ parseDirectiveDefinitionExtension(): DirectiveExtensionNode;
497
511
  /**
498
512
  * ```
499
513
  * DirectiveDefinition :
@@ -1112,6 +1112,7 @@ class Parser {
1112
1112
  * - UnionTypeExtension
1113
1113
  * - EnumTypeExtension
1114
1114
  * - InputObjectTypeDefinition
1115
+ * - DirectiveDefinitionExtension
1115
1116
  */
1116
1117
 
1117
1118
  parseTypeSystemExtension() {
@@ -1139,6 +1140,13 @@ class Parser {
1139
1140
 
1140
1141
  case 'input':
1141
1142
  return this.parseInputObjectTypeExtension();
1143
+
1144
+ case 'directive':
1145
+ if (this._options.experimentalDirectivesOnDirectiveDefinitions) {
1146
+ return this.parseDirectiveDefinitionExtension();
1147
+ }
1148
+
1149
+ break;
1142
1150
  }
1143
1151
  }
1144
1152
 
@@ -1334,6 +1342,25 @@ class Parser {
1334
1342
  fields,
1335
1343
  });
1336
1344
  }
1345
+
1346
+ parseDirectiveDefinitionExtension() {
1347
+ const start = this._lexer.token;
1348
+ this.expectKeyword('extend');
1349
+ this.expectKeyword('directive');
1350
+ this.expectToken(_tokenKind.TokenKind.AT);
1351
+ const name = this.parseName();
1352
+ const directives = this.parseConstDirectives();
1353
+
1354
+ if (directives.length === 0) {
1355
+ throw this.unexpected();
1356
+ }
1357
+
1358
+ return this.node(start, {
1359
+ kind: _kinds.Kind.DIRECTIVE_EXTENSION,
1360
+ name,
1361
+ directives,
1362
+ });
1363
+ }
1337
1364
  /**
1338
1365
  * ```
1339
1366
  * DirectiveDefinition :
@@ -1348,6 +1375,10 @@ class Parser {
1348
1375
  this.expectToken(_tokenKind.TokenKind.AT);
1349
1376
  const name = this.parseName();
1350
1377
  const args = this.parseArgumentDefs();
1378
+ const directives = this._options
1379
+ .experimentalDirectivesOnDirectiveDefinitions
1380
+ ? this.parseConstDirectives()
1381
+ : [];
1351
1382
  const repeatable = this.expectOptionalKeyword('repeatable');
1352
1383
  this.expectKeyword('on');
1353
1384
  const locations = this.parseDirectiveLocations();
@@ -1356,6 +1387,7 @@ class Parser {
1356
1387
  description,
1357
1388
  name,
1358
1389
  arguments: args,
1390
+ directives,
1359
1391
  repeatable,
1360
1392
  locations,
1361
1393
  });
@@ -1398,6 +1430,7 @@ class Parser {
1398
1430
  * `ENUM_VALUE`
1399
1431
  * `INPUT_OBJECT`
1400
1432
  * `INPUT_FIELD_DEFINITION`
1433
+ * `DIRECTIVE_DEFINITION`
1401
1434
  */
1402
1435
 
1403
1436
  parseDirectiveLocation() {
@@ -1075,6 +1075,7 @@ export class Parser {
1075
1075
  * - UnionTypeExtension
1076
1076
  * - EnumTypeExtension
1077
1077
  * - InputObjectTypeDefinition
1078
+ * - DirectiveDefinitionExtension
1078
1079
  */
1079
1080
 
1080
1081
  parseTypeSystemExtension() {
@@ -1102,6 +1103,13 @@ export class Parser {
1102
1103
 
1103
1104
  case 'input':
1104
1105
  return this.parseInputObjectTypeExtension();
1106
+
1107
+ case 'directive':
1108
+ if (this._options.experimentalDirectivesOnDirectiveDefinitions) {
1109
+ return this.parseDirectiveDefinitionExtension();
1110
+ }
1111
+
1112
+ break;
1105
1113
  }
1106
1114
  }
1107
1115
 
@@ -1297,6 +1305,25 @@ export class Parser {
1297
1305
  fields,
1298
1306
  });
1299
1307
  }
1308
+
1309
+ parseDirectiveDefinitionExtension() {
1310
+ const start = this._lexer.token;
1311
+ this.expectKeyword('extend');
1312
+ this.expectKeyword('directive');
1313
+ this.expectToken(TokenKind.AT);
1314
+ const name = this.parseName();
1315
+ const directives = this.parseConstDirectives();
1316
+
1317
+ if (directives.length === 0) {
1318
+ throw this.unexpected();
1319
+ }
1320
+
1321
+ return this.node(start, {
1322
+ kind: Kind.DIRECTIVE_EXTENSION,
1323
+ name,
1324
+ directives,
1325
+ });
1326
+ }
1300
1327
  /**
1301
1328
  * ```
1302
1329
  * DirectiveDefinition :
@@ -1311,6 +1338,10 @@ export class Parser {
1311
1338
  this.expectToken(TokenKind.AT);
1312
1339
  const name = this.parseName();
1313
1340
  const args = this.parseArgumentDefs();
1341
+ const directives = this._options
1342
+ .experimentalDirectivesOnDirectiveDefinitions
1343
+ ? this.parseConstDirectives()
1344
+ : [];
1314
1345
  const repeatable = this.expectOptionalKeyword('repeatable');
1315
1346
  this.expectKeyword('on');
1316
1347
  const locations = this.parseDirectiveLocations();
@@ -1319,6 +1350,7 @@ export class Parser {
1319
1350
  description,
1320
1351
  name,
1321
1352
  arguments: args,
1353
+ directives,
1322
1354
  repeatable,
1323
1355
  locations,
1324
1356
  });
@@ -1358,6 +1390,7 @@ export class Parser {
1358
1390
  * `ENUM_VALUE`
1359
1391
  * `INPUT_OBJECT`
1360
1392
  * `INPUT_FIELD_DEFINITION`
1393
+ * `DIRECTIVE_DEFINITION`
1361
1394
  */
1362
1395
 
1363
1396
  parseDirectiveLocation() {
@@ -94,7 +94,9 @@ function isTypeDefinitionNode(node) {
94
94
 
95
95
  function isTypeSystemExtensionNode(node) {
96
96
  return (
97
- node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node)
97
+ node.kind === _kinds.Kind.SCHEMA_EXTENSION ||
98
+ node.kind === _kinds.Kind.DIRECTIVE_EXTENSION ||
99
+ isTypeExtensionNode(node)
98
100
  );
99
101
  }
100
102
 
@@ -67,7 +67,11 @@ export function isTypeDefinitionNode(node) {
67
67
  );
68
68
  }
69
69
  export function isTypeSystemExtensionNode(node) {
70
- return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
70
+ return (
71
+ node.kind === Kind.SCHEMA_EXTENSION ||
72
+ node.kind === Kind.DIRECTIVE_EXTENSION ||
73
+ isTypeExtensionNode(node)
74
+ );
71
75
  }
72
76
  export function isTypeExtensionNode(node) {
73
77
  return (