graphile-build 4.12.2 → 5.0.0-0.3

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 (207) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE.md +15 -19
  3. package/README.md +37 -31
  4. package/dist/SchemaBuilder.d.ts +57 -0
  5. package/dist/SchemaBuilder.d.ts.map +1 -0
  6. package/dist/SchemaBuilder.js +178 -0
  7. package/dist/SchemaBuilder.js.map +1 -0
  8. package/dist/SchemaBuilderHooks.d.ts +7 -0
  9. package/dist/SchemaBuilderHooks.d.ts.map +1 -0
  10. package/dist/SchemaBuilderHooks.js +38 -0
  11. package/dist/SchemaBuilderHooks.js.map +1 -0
  12. package/dist/behavior.d.ts +11 -0
  13. package/dist/behavior.d.ts.map +1 -0
  14. package/dist/behavior.js +101 -0
  15. package/dist/behavior.js.map +1 -0
  16. package/dist/callbackToAsyncIterator.d.ts +10 -0
  17. package/dist/callbackToAsyncIterator.d.ts.map +1 -0
  18. package/dist/callbackToAsyncIterator.js +95 -0
  19. package/dist/callbackToAsyncIterator.js.map +1 -0
  20. package/dist/extend.d.ts +12 -0
  21. package/dist/extend.d.ts.map +1 -0
  22. package/dist/extend.js +48 -0
  23. package/dist/extend.js.map +1 -0
  24. package/dist/global.d.ts +575 -0
  25. package/dist/global.d.ts.map +1 -0
  26. package/dist/global.js +3 -0
  27. package/dist/global.js.map +1 -0
  28. package/dist/index.d.ts +46 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +287 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/inflection.d.ts +73 -0
  33. package/dist/inflection.d.ts.map +1 -0
  34. package/dist/inflection.js +101 -0
  35. package/dist/inflection.js.map +1 -0
  36. package/dist/interfaces.d.ts +226 -0
  37. package/dist/interfaces.d.ts.map +1 -0
  38. package/dist/interfaces.js +3 -0
  39. package/dist/interfaces.js.map +1 -0
  40. package/dist/makeNewBuild.d.ts +7 -0
  41. package/dist/makeNewBuild.d.ts.map +1 -0
  42. package/dist/makeNewBuild.js +261 -0
  43. package/dist/makeNewBuild.js.map +1 -0
  44. package/dist/newWithHooks/index.d.ts +22 -0
  45. package/dist/newWithHooks/index.d.ts.map +1 -0
  46. package/dist/newWithHooks/index.js +347 -0
  47. package/dist/newWithHooks/index.js.map +1 -0
  48. package/dist/plugins/AddNodeInterfaceToSuitableTypesPlugin.d.ts +3 -0
  49. package/dist/plugins/AddNodeInterfaceToSuitableTypesPlugin.d.ts.map +1 -0
  50. package/dist/plugins/AddNodeInterfaceToSuitableTypesPlugin.js +60 -0
  51. package/dist/plugins/AddNodeInterfaceToSuitableTypesPlugin.js.map +1 -0
  52. package/dist/plugins/BuiltinScalarConnectionsPlugin.d.ts +4 -0
  53. package/dist/plugins/BuiltinScalarConnectionsPlugin.d.ts.map +1 -0
  54. package/dist/plugins/BuiltinScalarConnectionsPlugin.js +42 -0
  55. package/dist/plugins/BuiltinScalarConnectionsPlugin.js.map +1 -0
  56. package/dist/plugins/ClientMutationIdDescriptionPlugin.d.ts +12 -0
  57. package/dist/plugins/ClientMutationIdDescriptionPlugin.d.ts.map +1 -0
  58. package/dist/plugins/ClientMutationIdDescriptionPlugin.js +72 -0
  59. package/dist/plugins/ClientMutationIdDescriptionPlugin.js.map +1 -0
  60. package/dist/plugins/CommonTypesPlugin.d.ts +15 -0
  61. package/dist/plugins/CommonTypesPlugin.d.ts.map +1 -0
  62. package/dist/plugins/CommonTypesPlugin.js +114 -0
  63. package/dist/plugins/CommonTypesPlugin.js.map +1 -0
  64. package/dist/plugins/ConnectionPlugin.d.ts +26 -0
  65. package/dist/plugins/ConnectionPlugin.d.ts.map +1 -0
  66. package/dist/plugins/ConnectionPlugin.js +145 -0
  67. package/dist/plugins/ConnectionPlugin.js.map +1 -0
  68. package/dist/plugins/CursorTypePlugin.d.ts +10 -0
  69. package/dist/plugins/CursorTypePlugin.d.ts.map +1 -0
  70. package/dist/plugins/CursorTypePlugin.js +27 -0
  71. package/dist/plugins/CursorTypePlugin.js.map +1 -0
  72. package/dist/plugins/MutationPayloadQueryPlugin.d.ts +8 -0
  73. package/dist/plugins/MutationPayloadQueryPlugin.d.ts.map +1 -0
  74. package/dist/plugins/MutationPayloadQueryPlugin.js +42 -0
  75. package/dist/plugins/MutationPayloadQueryPlugin.js.map +1 -0
  76. package/dist/plugins/MutationPlugin.d.ts +14 -0
  77. package/dist/plugins/MutationPlugin.d.ts.map +1 -0
  78. package/dist/plugins/MutationPlugin.js +69 -0
  79. package/dist/plugins/MutationPlugin.js.map +1 -0
  80. package/dist/plugins/NodeAccessorPlugin.d.ts +13 -0
  81. package/dist/plugins/NodeAccessorPlugin.d.ts.map +1 -0
  82. package/dist/plugins/NodeAccessorPlugin.js +80 -0
  83. package/dist/plugins/NodeAccessorPlugin.js.map +1 -0
  84. package/dist/plugins/NodeIdCodecBase64JSONPlugin.d.ts +3 -0
  85. package/dist/plugins/NodeIdCodecBase64JSONPlugin.d.ts.map +1 -0
  86. package/dist/plugins/NodeIdCodecBase64JSONPlugin.js +32 -0
  87. package/dist/plugins/NodeIdCodecBase64JSONPlugin.js.map +1 -0
  88. package/dist/plugins/NodeIdCodecPipeStringPlugin.d.ts +3 -0
  89. package/dist/plugins/NodeIdCodecPipeStringPlugin.d.ts.map +1 -0
  90. package/dist/plugins/NodeIdCodecPipeStringPlugin.js +32 -0
  91. package/dist/plugins/NodeIdCodecPipeStringPlugin.js.map +1 -0
  92. package/dist/plugins/NodePlugin.d.ts +35 -0
  93. package/dist/plugins/NodePlugin.d.ts.map +1 -0
  94. package/dist/plugins/NodePlugin.js +130 -0
  95. package/dist/plugins/NodePlugin.js.map +1 -0
  96. package/dist/plugins/PageInfoStartEndCursorPlugin.d.ts +11 -0
  97. package/dist/plugins/PageInfoStartEndCursorPlugin.d.ts.map +1 -0
  98. package/dist/plugins/PageInfoStartEndCursorPlugin.js +42 -0
  99. package/dist/plugins/PageInfoStartEndCursorPlugin.js.map +1 -0
  100. package/dist/plugins/QueryPlugin.d.ts +16 -0
  101. package/dist/plugins/QueryPlugin.d.ts.map +1 -0
  102. package/dist/plugins/QueryPlugin.js +69 -0
  103. package/dist/plugins/QueryPlugin.js.map +1 -0
  104. package/dist/plugins/QueryQueryPlugin.d.ts +7 -0
  105. package/dist/plugins/QueryQueryPlugin.d.ts.map +1 -0
  106. package/dist/plugins/QueryQueryPlugin.js +39 -0
  107. package/dist/plugins/QueryQueryPlugin.js.map +1 -0
  108. package/dist/plugins/RegisterQueryNodePlugin.d.ts +3 -0
  109. package/dist/plugins/RegisterQueryNodePlugin.d.ts.map +1 -0
  110. package/dist/plugins/RegisterQueryNodePlugin.js +36 -0
  111. package/dist/plugins/RegisterQueryNodePlugin.js.map +1 -0
  112. package/dist/plugins/StreamDeferPlugin.d.ts +9 -0
  113. package/dist/plugins/StreamDeferPlugin.d.ts.map +1 -0
  114. package/dist/plugins/StreamDeferPlugin.js +26 -0
  115. package/dist/plugins/StreamDeferPlugin.js.map +1 -0
  116. package/dist/plugins/SubscriptionPlugin.d.ts +14 -0
  117. package/dist/plugins/SubscriptionPlugin.d.ts.map +1 -0
  118. package/dist/plugins/SubscriptionPlugin.js +69 -0
  119. package/dist/plugins/SubscriptionPlugin.js.map +1 -0
  120. package/dist/plugins/SwallowErrorsPlugin.d.ts +14 -0
  121. package/dist/plugins/SwallowErrorsPlugin.d.ts.map +1 -0
  122. package/dist/plugins/SwallowErrorsPlugin.js +38 -0
  123. package/dist/plugins/SwallowErrorsPlugin.js.map +1 -0
  124. package/dist/plugins/TrimEmptyDescriptionsPlugin.d.ts +3 -0
  125. package/dist/plugins/TrimEmptyDescriptionsPlugin.d.ts.map +1 -0
  126. package/dist/plugins/TrimEmptyDescriptionsPlugin.js +62 -0
  127. package/dist/plugins/TrimEmptyDescriptionsPlugin.js.map +1 -0
  128. package/dist/plugins/index.d.ts +22 -0
  129. package/dist/plugins/index.d.ts.map +1 -0
  130. package/dist/plugins/index.js +44 -0
  131. package/dist/plugins/index.js.map +1 -0
  132. package/dist/preset.d.ts +4 -0
  133. package/dist/preset.d.ts.map +1 -0
  134. package/dist/preset.js +30 -0
  135. package/dist/preset.js.map +1 -0
  136. package/dist/swallowError.d.ts +9 -0
  137. package/dist/swallowError.d.ts.map +1 -0
  138. package/dist/swallowError.js +34 -0
  139. package/dist/swallowError.js.map +1 -0
  140. package/dist/utils.d.ts +47 -0
  141. package/dist/utils.d.ts.map +1 -0
  142. package/dist/utils.js +169 -0
  143. package/dist/utils.js.map +1 -0
  144. package/package.json +38 -29
  145. package/node8plus/Live.d.ts +0 -88
  146. package/node8plus/Live.js +0 -324
  147. package/node8plus/Live.js.flow +0 -365
  148. package/node8plus/Live.js.map +0 -1
  149. package/node8plus/SchemaBuilder.d.ts +0 -339
  150. package/node8plus/SchemaBuilder.js +0 -461
  151. package/node8plus/SchemaBuilder.js.flow +0 -621
  152. package/node8plus/SchemaBuilder.js.map +0 -1
  153. package/node8plus/callbackToAsyncIterator.js +0 -120
  154. package/node8plus/callbackToAsyncIterator.js.flow +0 -102
  155. package/node8plus/callbackToAsyncIterator.js.map +0 -1
  156. package/node8plus/extend.js +0 -46
  157. package/node8plus/extend.js.flow +0 -47
  158. package/node8plus/extend.js.map +0 -1
  159. package/node8plus/index.d.ts +0 -74
  160. package/node8plus/index.js +0 -187
  161. package/node8plus/index.js.flow +0 -104
  162. package/node8plus/index.js.map +0 -1
  163. package/node8plus/makeNewBuild.js +0 -820
  164. package/node8plus/makeNewBuild.js.flow +0 -1120
  165. package/node8plus/makeNewBuild.js.map +0 -1
  166. package/node8plus/plugins/AddQueriesToSubscriptionsPlugin.js +0 -84
  167. package/node8plus/plugins/AddQueriesToSubscriptionsPlugin.js.flow +0 -83
  168. package/node8plus/plugins/AddQueriesToSubscriptionsPlugin.js.map +0 -1
  169. package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js +0 -74
  170. package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js.flow +0 -92
  171. package/node8plus/plugins/ClientMutationIdDescriptionPlugin.js.map +0 -1
  172. package/node8plus/plugins/MutationPayloadQueryPlugin.js +0 -43
  173. package/node8plus/plugins/MutationPayloadQueryPlugin.js.flow +0 -41
  174. package/node8plus/plugins/MutationPayloadQueryPlugin.js.map +0 -1
  175. package/node8plus/plugins/MutationPlugin.js +0 -53
  176. package/node8plus/plugins/MutationPlugin.js.flow +0 -59
  177. package/node8plus/plugins/MutationPlugin.js.map +0 -1
  178. package/node8plus/plugins/NodePlugin.js +0 -188
  179. package/node8plus/plugins/NodePlugin.js.flow +0 -266
  180. package/node8plus/plugins/NodePlugin.js.map +0 -1
  181. package/node8plus/plugins/QueryPlugin.js +0 -56
  182. package/node8plus/plugins/QueryPlugin.js.flow +0 -74
  183. package/node8plus/plugins/QueryPlugin.js.map +0 -1
  184. package/node8plus/plugins/StandardTypesPlugin.js +0 -90
  185. package/node8plus/plugins/StandardTypesPlugin.js.flow +0 -99
  186. package/node8plus/plugins/StandardTypesPlugin.js.map +0 -1
  187. package/node8plus/plugins/SubscriptionPlugin.js +0 -75
  188. package/node8plus/plugins/SubscriptionPlugin.js.flow +0 -79
  189. package/node8plus/plugins/SubscriptionPlugin.js.map +0 -1
  190. package/node8plus/plugins/SwallowErrorsPlugin.js +0 -31
  191. package/node8plus/plugins/SwallowErrorsPlugin.js.flow +0 -28
  192. package/node8plus/plugins/SwallowErrorsPlugin.js.map +0 -1
  193. package/node8plus/plugins/TrimEmptyDescriptionsPlugin.js +0 -54
  194. package/node8plus/plugins/TrimEmptyDescriptionsPlugin.js.flow +0 -40
  195. package/node8plus/plugins/TrimEmptyDescriptionsPlugin.js.map +0 -1
  196. package/node8plus/plugins/index.js +0 -88
  197. package/node8plus/plugins/index.js.flow +0 -25
  198. package/node8plus/plugins/index.js.map +0 -1
  199. package/node8plus/resolveNode.js +0 -50
  200. package/node8plus/resolveNode.js.flow +0 -49
  201. package/node8plus/resolveNode.js.map +0 -1
  202. package/node8plus/swallowError.js +0 -35
  203. package/node8plus/swallowError.js.flow +0 -31
  204. package/node8plus/swallowError.js.map +0 -1
  205. package/node8plus/utils.js +0 -102
  206. package/node8plus/utils.js.flow +0 -91
  207. package/node8plus/utils.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # graphile-build
2
+
3
+ ## 5.0.0-0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`25037fc15`](undefined)]:
8
+ - grafast@0.0.1-0.2
9
+ - graphile-export@0.0.2-0.2
10
+
11
+ ## 5.0.0-0.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`55f15cf35`](undefined)]:
16
+ - grafast@0.0.1-0.1
17
+ - graphile-export@0.0.2-0.1
18
+
19
+ ## 5.0.0-0.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [#125](https://github.com/benjie/postgraphile-private/pull/125)
24
+ [`91f2256b3`](https://github.com/benjie/postgraphile-private/commit/91f2256b3fd699bec19fc86f1ca79df057e58639)
25
+ Thanks [@benjie](https://github.com/benjie)! - Initial changesets release
26
+
27
+ - Updated dependencies
28
+ [[`91f2256b3`](https://github.com/benjie/postgraphile-private/commit/91f2256b3fd699bec19fc86f1ca79df057e58639)]:
29
+ - @graphile/lru@5.0.0-0.1
30
+ - grafast@0.0.1-0.0
31
+ - graphile-config@0.0.1-0.0
32
+ - graphile-export@0.0.2-0.0
package/LICENSE.md CHANGED
@@ -1,24 +1,20 @@
1
1
  # The MIT License (MIT)
2
2
 
3
- Copyright © `2018` Benjie Gillam
3
+ Copyright © `2023` Benjie Gillam
4
4
 
5
- Permission is hereby granted, free of charge, to any person
6
- obtaining a copy of this software and associated documentation
7
- files (the Software”), to deal in the Software without
8
- restriction, including without limitation the rights to use,
9
- copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the
11
- Software is furnished to do so, subject to the following
12
- conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the “Software”), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
13
11
 
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
16
14
 
17
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
- OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,44 +1,54 @@
1
1
  # graphile-build
2
2
 
3
- <span class="badge-patreon"><a href="https://patreon.com/benjie" title="Support Graphile development on Patreon"><img src="https://img.shields.io/badge/sponsor-via%20Patreon-orange.svg" alt="Patreon sponsor button" /></a></span>
3
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/benjie?color=ff69b4&label=github%20sponsors)](https://github.com/sponsors/benjie)
4
+ [![Patreon sponsor button](https://img.shields.io/badge/sponsor-via%20Patreon-orange.svg)](https://patreon.com/benjie)
4
5
  [![Discord chat room](https://img.shields.io/discord/489127045289476126.svg)](http://discord.gg/graphile)
5
- [![Package on npm](https://img.shields.io/npm/v/graphile-build.svg?style=flat)](https://www.npmjs.com/package/graphile-build)
6
- ![MIT license](https://img.shields.io/npm/l/graphile-build.svg)
7
6
  [![Follow](https://img.shields.io/badge/twitter-@GraphileHQ-blue.svg)](https://twitter.com/GraphileHQ)
8
7
 
9
- `graphile-build` is the core of Graphile Engine. It provides a framework to
10
- build high-performance extensible GraphQL APIs by combining plugins and using
11
- advanced query look-ahead features. Each plugin typically has its own small
12
- purpose (such as implementing the Node interface, adding `query: Query` to
13
- mutation payloads, or watching an external source for schema changes) and by
14
- combining these plugins together you get a large, powerful, and manageable
15
- GraphQL schema. Plugins enable you to make broad changes to your GraphQL
16
- schema with minimal code and without sacrificing performance.
17
-
18
- An example of an application built on `graphile-build` is
19
- [PostGraphile](https://github.com/graphile/postgraphile) which with one
20
- command connects to your PostgreSQL database and provides a full highly
21
- performant standards-compliant GraphQL API. The separate `graphile-build-pg`
22
- module contains the plugins that are specific to PostgreSQL support
23
- (`graphile-build` itself does not know about databases).
8
+ `graphile-build` provides a framework to build extensible GraphQL APIs by
9
+ combining plugins. Each plugin typically has its own small purpose (such as
10
+ implementing the [`Node` interface][global-object-identification], adding
11
+ `query: Query` to mutation payloads, or watching an external source for schema
12
+ changes) and by combining these plugins together you get a large, powerful, and
13
+ manageable GraphQL schema. Plugins enable you to make broad changes to your
14
+ GraphQL schema with minimal code, and because you're changing your schema in
15
+ broad ways it helps to guarantee consistency.
16
+
17
+ Graphile Build has strong built-in support for [Gra*fast*](https://grafast.org)
18
+ so you can make an exceptionally performant auto-generated (or
19
+ generator-assisted) GraphQL API.
20
+
21
+ [PostGraphile](https://github.com/graphile/postgraphile) uses Graphile Build and
22
+ Gra*fast* to produce an extremely high performance standards-compliant GraphQL
23
+ API with minimal fuss. The separate
24
+ [`graphile-build-pg` module](../graphile-build-pg/README.md) contains the
25
+ plugins that are specific to PostgreSQL support (`graphile-build` itself does
26
+ not know nor care about databases).
24
27
 
25
28
  <!-- SPONSORS_BEGIN -->
26
29
 
27
30
  ## Crowd-funded open-source software
28
31
 
29
- To help us develop this software sustainably under the MIT license, we ask
30
- all individuals and businesses that use it to help support its ongoing
31
- maintenance and development via sponsorship.
32
+ To help us develop this software sustainably under the MIT license, we ask all
33
+ individuals and businesses that use it to help support its ongoing maintenance
34
+ and development via sponsorship.
32
35
 
33
36
  ### [Click here to find out more about sponsors and sponsorship.](https://www.graphile.org/sponsor/)
34
37
 
35
38
  And please give some love to our featured sponsors 🤩:
36
39
 
37
40
  <table><tr>
41
+ <td align="center"><a href="https://surge.io/"><img src="https://graphile.org/images/sponsors/surge.png" width="90" height="90" alt="Surge" /><br />Surge</a> *</td>
42
+ <td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td>
43
+ <td align="center"><a href="https://qwick.com/"><img src="https://graphile.org/images/sponsors/qwick.png" width="90" height="90" alt="Qwick" /><br />Qwick</a> *</td>
44
+ <td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
45
+ </tr><tr>
38
46
  <td align="center"><a href="http://chads.website"><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td>
39
- <td align="center"><a href="https://storyscript.com/?utm_source=postgraphile"><img src="https://graphile.org/images/sponsors/storyscript.png" width="90" height="90" alt="Storyscript" /><br />Storyscript</a> *</td>
40
- <td align="center"><a href="https://postlight.com/?utm_source=graphile"><img src="https://graphile.org/images/sponsors/postlight.jpg" width="90" height="90" alt="Postlight" /><br />Postlight</a> *</td>
41
- <td align="center"><a href="https://surge.io/"><img src="https://graphile.org/images/sponsors/surge.png" width="90" height="90" alt="Surge.io" /><br />Surge.io</a> *</td>
47
+ <td align="center"><a href="https://www.fanatics.com/"><img src="https://graphile.org/images/sponsors/fanatics.png" width="90" height="90" alt="Fanatics" /><br />Fanatics</a> *</td>
48
+ <td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
49
+ <td align="center"><a href="https://www.enzuzo.com/"><img src="https://graphile.org/images/sponsors/enzuzo.png" width="90" height="90" alt="Enzuzo" /><br />Enzuzo</a> *</td>
50
+ </tr><tr>
51
+ <td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
42
52
  </tr></table>
43
53
 
44
54
  <em>\* Sponsors the entire Graphile suite</em>
@@ -47,11 +57,7 @@ And please give some love to our featured sponsors 🤩:
47
57
 
48
58
  ## Documentation
49
59
 
50
- **For in-depth documentation about `graphile-build`, please see [the graphile
51
- documentation website at graphile.org](https://www.graphile.org/).** The
52
- below just serves as a limited quick-reference for people already familiar
53
- with the library.
60
+ TODO!
54
61
 
55
- **Please note: rather than using the raw plugin interface that
56
- `graphile-build` exposes, you may want to use the helpers in
57
- the `graphile-utils` module.**
62
+ [global-object-identification]:
63
+ https://relay.dev/graphql/objectidentification.htm
@@ -0,0 +1,57 @@
1
+ /// <reference types="node" />
2
+ import "./global.js";
3
+ import { EventEmitter } from "events";
4
+ import { GraphQLSchema } from "graphql";
5
+ import type { NewWithHooksFunction } from "./newWithHooks/index.js";
6
+ /**
7
+ * The class responsible for building a GraphQL schema from graphile-build
8
+ * plugins by orchestrating the various callback functions.
9
+ */
10
+ declare class SchemaBuilder<TBuild extends GraphileBuild.Build = GraphileBuild.Build> extends EventEmitter {
11
+ private inflection;
12
+ options: GraphileBuild.GraphileBuildSchemaOptions;
13
+ depth: number;
14
+ hooks: GraphileBuild.SchemaBuilderHooks<TBuild>;
15
+ _currentPluginName: string | null | undefined;
16
+ /**
17
+ * Given a Build object, a GraphQL type constructor and a spec, applies the
18
+ * hooks to the spec and then constructs the type, returning the result.
19
+ */
20
+ newWithHooks: NewWithHooksFunction;
21
+ constructor(options: GraphileBuild.GraphileBuildSchemaOptions, inflection: GraphileBuild.Inflection);
22
+ /**
23
+ * @internal
24
+ */
25
+ _setPluginName(name: string | null | undefined): void;
26
+ /**
27
+ * Registers 'fn' as a hook for the given 'hookName'. Every hook `fn` takes
28
+ * three arguments:
29
+ *
30
+ * - obj - the object currently being inspected
31
+ * - build - the current build object (which contains a number of utilities
32
+ * and the context of the build)
33
+ * - context - information specific to the current invocation of the hook
34
+ *
35
+ * The function must return a replacement object for `obj` or `obj` itself.
36
+ * Generally we advice that you return the object itself, modifying it as
37
+ * necessary. In JavaScript, modifying an object object tends to be
38
+ * significantly faster than returning a modified clone.
39
+ */
40
+ hook<THookName extends keyof GraphileBuild.SchemaBuilderHooks<TBuild>>(hookName: THookName, fn: GraphileBuild.SchemaBuilderHooks[THookName][number]): void;
41
+ /**
42
+ * Applies the given 'hookName' hooks to the given 'input' and returns the
43
+ * result, which is typically a derivative of 'input'.
44
+ */
45
+ applyHooks<THookName extends keyof GraphileBuild.SchemaBuilderHooks<TBuild>>(hookName: THookName, input: Parameters<GraphileBuild.SchemaBuilderHooks<TBuild>[THookName][number]>[0], build: Parameters<GraphileBuild.SchemaBuilderHooks<TBuild>[THookName][number]>[1], context: Parameters<GraphileBuild.SchemaBuilderHooks<TBuild>[THookName][number]>[2], debugStr?: string): Parameters<GraphileBuild.SchemaBuilderHooks<TBuild>[THookName][number]>[0];
46
+ /**
47
+ * Create the 'Build' object.
48
+ */
49
+ createBuild(input: GraphileBuild.BuildInput): TBuild;
50
+ /**
51
+ * Given the `input` (result of the "gather" phase), builds the GraphQL
52
+ * schema synchronously.
53
+ */
54
+ buildSchema(input: GraphileBuild.BuildInput): GraphQLSchema;
55
+ }
56
+ export default SchemaBuilder;
57
+ //# sourceMappingURL=SchemaBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaBuilder.d.ts","sourceRoot":"","sources":["../src/SchemaBuilder.ts"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAkB,MAAM,SAAS,CAAC;AAGxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAapE;;;GAGG;AACH,cAAM,aAAa,CACjB,MAAM,SAAS,aAAa,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CACxD,SAAQ,YAAY;IAelB,OAAO,CAAC,UAAU;IAdpB,OAAO,EAAE,aAAa,CAAC,0BAA0B,CAAC;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAEhD,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE9C;;;OAGG;IACH,YAAY,EAAE,oBAAoB,CAAC;gBAGjC,OAAO,EAAE,aAAa,CAAC,0BAA0B,EACzC,UAAU,EAAE,aAAa,CAAC,UAAU;IAiB9C;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAI9C;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,SAAS,SAAS,MAAM,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,EACnE,QAAQ,EAAE,SAAS,EACnB,EAAE,EAAE,aAAa,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GACtD,IAAI;IAWP;;;OAGG;IACH,UAAU,CAAC,SAAS,SAAS,MAAM,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,EACzE,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,UAAU,CACf,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAC5D,CAAC,CAAC,CAAC,EACJ,KAAK,EAAE,UAAU,CACf,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAC5D,CAAC,CAAC,CAAC,EACJ,OAAO,EAAE,UAAU,CACjB,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAC5D,CAAC,CAAC,CAAC,EACJ,QAAQ,SAAK,GACZ,UAAU,CACX,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAC5D,CAAC,CAAC,CAAC;IA4EJ;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,GAAG,MAAM;IA0BpD;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,GAAG,aAAa;CAgD5D;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ require("./global.js");
5
+ const debug_1 = tslib_1.__importDefault(require("debug"));
6
+ const events_1 = require("events");
7
+ const graphql_1 = require("graphql");
8
+ const makeNewBuild_js_1 = tslib_1.__importDefault(require("./makeNewBuild.js"));
9
+ const index_js_1 = require("./newWithHooks/index.js");
10
+ const SchemaBuilderHooks_js_1 = require("./SchemaBuilderHooks.js");
11
+ const utils_js_1 = require("./utils.js");
12
+ const debug = (0, debug_1.default)("graphile-build:SchemaBuilder");
13
+ const INIT_OBJECT = Object.freeze(Object.create(null));
14
+ const INDENT = " ";
15
+ /**
16
+ * The class responsible for building a GraphQL schema from graphile-build
17
+ * plugins by orchestrating the various callback functions.
18
+ */
19
+ class SchemaBuilder extends events_1.EventEmitter {
20
+ inflection;
21
+ options;
22
+ depth;
23
+ hooks;
24
+ _currentPluginName;
25
+ /**
26
+ * Given a Build object, a GraphQL type constructor and a spec, applies the
27
+ * hooks to the spec and then constructs the type, returning the result.
28
+ */
29
+ newWithHooks;
30
+ constructor(options, inflection) {
31
+ super();
32
+ this.inflection = inflection;
33
+ if (!options) {
34
+ throw new Error("Please pass options to SchemaBuilder");
35
+ }
36
+ this.options = options;
37
+ // Because hooks can nest, this keeps track of how deep we are.
38
+ this.depth = -1;
39
+ this.hooks = (0, SchemaBuilderHooks_js_1.makeSchemaBuilderHooks)();
40
+ this.newWithHooks = (0, index_js_1.makeNewWithHooks)({ builder: this }).newWithHooks;
41
+ }
42
+ /**
43
+ * @internal
44
+ */
45
+ _setPluginName(name) {
46
+ this._currentPluginName = name;
47
+ }
48
+ /**
49
+ * Registers 'fn' as a hook for the given 'hookName'. Every hook `fn` takes
50
+ * three arguments:
51
+ *
52
+ * - obj - the object currently being inspected
53
+ * - build - the current build object (which contains a number of utilities
54
+ * and the context of the build)
55
+ * - context - information specific to the current invocation of the hook
56
+ *
57
+ * The function must return a replacement object for `obj` or `obj` itself.
58
+ * Generally we advice that you return the object itself, modifying it as
59
+ * necessary. In JavaScript, modifying an object object tends to be
60
+ * significantly faster than returning a modified clone.
61
+ */
62
+ hook(hookName, fn) {
63
+ if (!this.hooks[hookName]) {
64
+ // TODO: fuzzy-find a similar hook
65
+ throw new Error(`Sorry, '${hookName}' is not a supported hook`);
66
+ }
67
+ if (this._currentPluginName) {
68
+ fn.displayName = `${this._currentPluginName}/schema.hooks.${hookName}`;
69
+ }
70
+ this.hooks[hookName].push(fn);
71
+ }
72
+ /**
73
+ * Applies the given 'hookName' hooks to the given 'input' and returns the
74
+ * result, which is typically a derivative of 'input'.
75
+ */
76
+ applyHooks(hookName, input, build, context, debugStr = "") {
77
+ if (!input) {
78
+ throw new Error("applyHooks was called with falsy input");
79
+ }
80
+ this.depth++;
81
+ const indent = INDENT.repeat(this.depth);
82
+ try {
83
+ debug(`%s[%s%s]: Running...`, indent, hookName, debugStr);
84
+ const hooks = this.hooks[hookName];
85
+ if (!hooks) {
86
+ throw new Error(`Sorry, '${hookName}' is not a registered hook`);
87
+ }
88
+ let newObj = input;
89
+ for (const hook of hooks) {
90
+ this.depth++;
91
+ try {
92
+ const hookDisplayName = hook.displayName || hook.name || "anonymous";
93
+ debug(`%s[%s%s]: Executing '%s'`, indent, hookName, debugStr, hookDisplayName);
94
+ const previousHookName = build.status.currentHookName;
95
+ const previousHookEvent = build.status.currentHookEvent;
96
+ build.status.currentHookName = hookDisplayName;
97
+ build.status.currentHookEvent = hookName;
98
+ const oldObj = newObj;
99
+ newObj = hook(newObj, build, context);
100
+ if (hookName === "build") {
101
+ /*
102
+ * Unlike all the other hooks, the `build` hook must always use the
103
+ * same `build` object - never returning a new object for fear of
104
+ * causing issues to other build hooks that reference the old
105
+ * object and don't get the new additions.
106
+ */
107
+ if (newObj !== oldObj) {
108
+ throw new Error(`Build hook '${hookDisplayName}' returned a new object; 'build' hooks must always return the same Build object - please use 'return build.extend(build, {...})' instead.`);
109
+ }
110
+ }
111
+ build.status.currentHookName = previousHookName;
112
+ build.status.currentHookEvent = previousHookEvent;
113
+ if (!newObj) {
114
+ throw new Error(`GraphileBuild.Hook '${hook.displayName || hook.name || "anonymous"}' for '${hookName}' returned falsy value '${newObj}'`);
115
+ }
116
+ debug(`%s[%s%s]: '%s' complete`, indent, hookName, debugStr, hookDisplayName);
117
+ }
118
+ finally {
119
+ this.depth--;
120
+ }
121
+ }
122
+ debug(`%s[%s%s]: Complete`, indent, hookName, debugStr);
123
+ return newObj;
124
+ }
125
+ finally {
126
+ this.depth--;
127
+ }
128
+ }
129
+ /**
130
+ * Create the 'Build' object.
131
+ */
132
+ createBuild(input) {
133
+ const initialBuild = (0, makeNewBuild_js_1.default)(this, input, this.inflection);
134
+ const build = this.applyHooks("build", initialBuild, initialBuild, {
135
+ scope: {},
136
+ type: "build",
137
+ });
138
+ // Bind all functions so they can be dereferenced
139
+ (0, utils_js_1.bindAll)(build, Object.keys(build).filter((key) => typeof build[key] === "function"));
140
+ const finalBuild = Object.freeze(build);
141
+ finalBuild.status.isBuildPhaseComplete = true;
142
+ const initContext = { scope: {}, type: "init" };
143
+ this.applyHooks("init", INIT_OBJECT, finalBuild, initContext);
144
+ finalBuild.status.isInitPhaseComplete = true;
145
+ return finalBuild;
146
+ }
147
+ /**
148
+ * Given the `input` (result of the "gather" phase), builds the GraphQL
149
+ * schema synchronously.
150
+ */
151
+ buildSchema(input) {
152
+ const build = this.createBuild(input);
153
+ const schemaSpec = {
154
+ directives: [...build.graphql.specifiedDirectives],
155
+ };
156
+ const schemaScope = {
157
+ __origin: `Graphile built-in`,
158
+ };
159
+ const tempSchema = this.newWithHooks(build, graphql_1.GraphQLSchema, schemaSpec, schemaScope);
160
+ const finalizeContext = {
161
+ scope: {},
162
+ type: "finalize",
163
+ };
164
+ const schema = tempSchema
165
+ ? this.applyHooks("finalize", tempSchema, build, finalizeContext, "Finalizing GraphQL schema")
166
+ : tempSchema;
167
+ if (!schema) {
168
+ throw new Error("Schema generation failed");
169
+ }
170
+ const validationErrors = (0, graphql_1.validateSchema)(schema);
171
+ if (validationErrors.length) {
172
+ throw new AggregateError(validationErrors, `Schema construction failed due to ${validationErrors.length} validation failure(s). First failure was: ${String(validationErrors[0])}`);
173
+ }
174
+ return schema;
175
+ }
176
+ }
177
+ exports.default = SchemaBuilder;
178
+ //# sourceMappingURL=SchemaBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaBuilder.js","sourceRoot":"","sources":["../src/SchemaBuilder.ts"],"names":[],"mappings":";;;AAAA,uBAAqB;AAErB,0DAAiC;AACjC,mCAAsC;AAEtC,qCAAwD;AAExD,gFAA6C;AAE7C,sDAA2D;AAC3D,mEAAiE;AACjE,yCAAqC;AAErC,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,8BAA8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,MAAM,EAAE;YAC3B,MAAM,IAAI,cAAc,CACtB,gBAAgB,EAChB,qCACE,gBAAgB,CAAC,MACnB,8CAA8C,MAAM,CAClD,gBAAgB,CAAC,CAAC,CAAC,CACpB,EAAE,CACJ,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,kBAAe,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ import "./global.js";
2
+ /**
3
+ * Returns a new object with arrays for each supported schema hook, ready for
4
+ * hook functions to be registered into it.
5
+ */
6
+ export declare function makeSchemaBuilderHooks<TBuild extends GraphileBuild.Build = GraphileBuild.Build>(): GraphileBuild.SchemaBuilderHooks<TBuild>;
7
+ //# sourceMappingURL=SchemaBuilderHooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaBuilderHooks.d.ts","sourceRoot":"","sources":["../src/SchemaBuilderHooks.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,SAAS,aAAa,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,KACrD,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,CA2B5C"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeSchemaBuilderHooks = void 0;
4
+ require("./global.js");
5
+ /**
6
+ * Returns a new object with arrays for each supported schema hook, ready for
7
+ * hook functions to be registered into it.
8
+ */
9
+ function makeSchemaBuilderHooks() {
10
+ return {
11
+ build: [],
12
+ init: [],
13
+ finalize: [],
14
+ GraphQLSchema: [],
15
+ GraphQLSchema_types: [],
16
+ GraphQLObjectType: [],
17
+ GraphQLObjectType_interfaces: [],
18
+ GraphQLObjectType_fields: [],
19
+ GraphQLObjectType_fields_field: [],
20
+ GraphQLObjectType_fields_field_args: [],
21
+ GraphQLInputObjectType: [],
22
+ GraphQLInputObjectType_fields: [],
23
+ GraphQLInputObjectType_fields_field: [],
24
+ GraphQLEnumType: [],
25
+ GraphQLEnumType_values: [],
26
+ GraphQLEnumType_values_value: [],
27
+ GraphQLUnionType: [],
28
+ GraphQLUnionType_types: [],
29
+ GraphQLInterfaceType: [],
30
+ GraphQLInterfaceType_fields: [],
31
+ GraphQLInterfaceType_fields_field: [],
32
+ GraphQLInterfaceType_fields_field_args: [],
33
+ GraphQLInterfaceType_interfaces: [],
34
+ GraphQLScalarType: [],
35
+ };
36
+ }
37
+ exports.makeSchemaBuilderHooks = makeSchemaBuilderHooks;
38
+ //# sourceMappingURL=SchemaBuilderHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaBuilderHooks.js","sourceRoot":"","sources":["../src/SchemaBuilderHooks.ts"],"names":[],"mappings":";;;AAAA,uBAAqB;AAErB;;;GAGG;AACH,SAAgB,sBAAsB;IAGpC,OAAO;QACL,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,mBAAmB,EAAE,EAAE;QACvB,iBAAiB,EAAE,EAAE;QACrB,4BAA4B,EAAE,EAAE;QAChC,wBAAwB,EAAE,EAAE;QAC5B,8BAA8B,EAAE,EAAE;QAClC,mCAAmC,EAAE,EAAE;QACvC,sBAAsB,EAAE,EAAE;QAC1B,6BAA6B,EAAE,EAAE;QACjC,mCAAmC,EAAE,EAAE;QACvC,eAAe,EAAE,EAAE;QACnB,sBAAsB,EAAE,EAAE;QAC1B,4BAA4B,EAAE,EAAE;QAChC,gBAAgB,EAAE,EAAE;QACpB,sBAAsB,EAAE,EAAE;QAC1B,oBAAoB,EAAE,EAAE;QACxB,2BAA2B,EAAE,EAAE;QAC/B,iCAAiC,EAAE,EAAE;QACrC,sCAAsC,EAAE,EAAE;QAC1C,+BAA+B,EAAE,EAAE;QACnC,iBAAiB,EAAE,EAAE;KACtB,CAAC;AACJ,CAAC;AA7BD,wDA6BC"}
@@ -0,0 +1,11 @@
1
+ export declare class Behavior {
2
+ private globalBehaviorDefaults;
3
+ addDefaultBehavior(behavior: string): void;
4
+ /**
5
+ * @param localBehaviorSpecsString - the behavior of the entity as determined by details on the entity itself and any applicable ancestors
6
+ * @param filter - the behavior the plugin specifies
7
+ * @param defaultBehavior - allows the plugin to specify a default behavior for this in the event that it's not defined elsewhere (lowest priority)
8
+ */
9
+ matches(localBehaviorSpecsString: string | null | undefined, filter: string, defaultBehavior?: string): boolean | undefined;
10
+ }
11
+ //# sourceMappingURL=behavior.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavior.d.ts","sourceRoot":"","sources":["../src/behavior.ts"],"names":[],"mappings":"AAMA,qBAAa,QAAQ;IACnB,OAAO,CAAC,sBAAsB,CAAM;IAG7B,kBAAkB,CAAC,QAAQ,EAAE,MAAM;IAS1C;;;;OAIG;IACI,OAAO,CACZ,wBAAwB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnD,MAAM,EAAE,MAAM,EACd,eAAe,SAAK,GACnB,OAAO,GAAG,SAAS;CAevB"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Behavior = void 0;
4
+ class Behavior {
5
+ globalBehaviorDefaults = "";
6
+ // Should only be called during 'build' phase.
7
+ addDefaultBehavior(behavior) {
8
+ if (this.globalBehaviorDefaults) {
9
+ this.globalBehaviorDefaults += " " + behavior;
10
+ }
11
+ else {
12
+ this.globalBehaviorDefaults = behavior;
13
+ }
14
+ }
15
+ // TODO: would be great if this could return `{deprecationReason: string}` too...
16
+ /**
17
+ * @param localBehaviorSpecsString - the behavior of the entity as determined by details on the entity itself and any applicable ancestors
18
+ * @param filter - the behavior the plugin specifies
19
+ * @param defaultBehavior - allows the plugin to specify a default behavior for this in the event that it's not defined elsewhere (lowest priority)
20
+ */
21
+ matches(localBehaviorSpecsString, filter, defaultBehavior = "") {
22
+ const finalBehaviorSpecsString = `${defaultBehavior} ${this.globalBehaviorDefaults} ${localBehaviorSpecsString ?? ""}`;
23
+ const specs = parseSpecs(finalBehaviorSpecsString);
24
+ const filterScope = parseScope(filter);
25
+ // Loop backwards through the specs
26
+ for (let i = specs.length - 1; i >= 0; i--) {
27
+ const { positive, scope } = specs[i];
28
+ if (scopeMatches(scope, filterScope, positive)) {
29
+ return positive;
30
+ }
31
+ }
32
+ return undefined;
33
+ }
34
+ }
35
+ exports.Behavior = Behavior;
36
+ /**
37
+ * Parses a scope like `root:connection:filter` into it's constituent parts.
38
+ *
39
+ * @internal
40
+ */
41
+ function parseScope(scopeString) {
42
+ return scopeString.split(":");
43
+ }
44
+ /**
45
+ * Parses a behaviorSpecs string like `+list -connection -list:filter` into a
46
+ * list of BehaviorSpecs.
47
+ *
48
+ * @internal
49
+ */
50
+ function parseSpecs(behaviorSpecsString) {
51
+ const fragments = behaviorSpecsString.split(/\s+/);
52
+ const specs = [];
53
+ for (const fragment of fragments) {
54
+ // `+` is implicit
55
+ const [pm, rest] = /^[+-]/.test(fragment)
56
+ ? [fragment.slice(0, 1), fragment.slice(1)]
57
+ : ["+", fragment];
58
+ const positive = pm === "+";
59
+ const scope = parseScope(rest);
60
+ specs.push({ positive, scope });
61
+ }
62
+ return specs;
63
+ }
64
+ /**
65
+ * Returns true if `filterScope` can be matched by `specifiedScope`.
66
+ *
67
+ * If `filterScope` contains an `*` then we return true if any possible
68
+ * `filterScope` can be matched by `specifiedScope` in a positive fashion.
69
+ *
70
+ * @param specifiedScope - the scope the user entered, e.g. from `+root:*:filter`
71
+ * @param filterScope - the scope the plugin says we're in, e.g. from `root:connection:filter`
72
+ *
73
+ * @internal
74
+ */
75
+ function scopeMatches(specifiedScope, filterScope, positive) {
76
+ if (specifiedScope.length > filterScope.length) {
77
+ return false;
78
+ }
79
+ // `specifiedScope` is effectively prepended with `*:*:*:` as many times as
80
+ // necessary to make it the same length as `filterScope`. In actuality we do
81
+ // it more efficiently.
82
+ const filterScopeTrimmed = specifiedScope.length === filterScope.length
83
+ ? filterScope
84
+ : filterScope.slice(filterScope.length - specifiedScope.length);
85
+ // Loop through each entry, if it doesn't match then return false.
86
+ for (let i = 0, l = filterScopeTrimmed.length; i < l; i++) {
87
+ const rule = specifiedScope[i];
88
+ const filter = filterScopeTrimmed[i];
89
+ if (filter === "*" && rule !== "*" && !positive) {
90
+ return false;
91
+ }
92
+ if (rule === "*" || filter === "*") {
93
+ continue;
94
+ }
95
+ if (rule !== filter) {
96
+ return false;
97
+ }
98
+ }
99
+ return true;
100
+ }
101
+ //# sourceMappingURL=behavior.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavior.js","sourceRoot":"","sources":["../src/behavior.ts"],"names":[],"mappings":";;;AAMA,MAAa,QAAQ;IACX,sBAAsB,GAAG,EAAE,CAAC;IAEpC,8CAA8C;IACvC,kBAAkB,CAAC,QAAgB;QACxC,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,IAAI,GAAG,GAAG,QAAQ,CAAC;SAC/C;aAAM;YACL,IAAI,CAAC,sBAAsB,GAAG,QAAQ,CAAC;SACxC;IACH,CAAC;IAED,iFAAiF;IACjF;;;;OAIG;IACI,OAAO,CACZ,wBAAmD,EACnD,MAAc,EACd,eAAe,GAAG,EAAE;QAEpB,MAAM,wBAAwB,GAAG,GAAG,eAAe,IACjD,IAAI,CAAC,sBACP,IAAI,wBAAwB,IAAI,EAAE,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;QACnD,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QACvC,mCAAmC;QACnC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,YAAY,CAAC,KA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CAAC,CAAC,WAAW;QACb,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAEpE,kEAAkE;IAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzD,MAAM,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE;YAC/C,OAAO,KAAK,CAAC;SACd;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE;YAClC,SAAS;SACV;QACD,IAAI,IAAI,KAAK,MAAM,EAAE;YACnB,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Builds an AsyncIterator from a callback; much safer than an async generator
3
+ * because it will not get frozen waiting for a promise to resolve.
4
+ */
5
+ export default function callbackToAsyncIterator<CallbackInput, ReturnVal>(listener: (callback: (value: CallbackInput) => void) => (ReturnVal | null | undefined) | Promise<ReturnVal | null | undefined>, options?: {
6
+ onError?: (err: Error) => void;
7
+ onClose?: (arg: ReturnVal | null | undefined) => void;
8
+ buffering?: boolean;
9
+ }): AsyncIterableIterator<CallbackInput>;
10
+ //# sourceMappingURL=callbackToAsyncIterator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callbackToAsyncIterator.d.ts","sourceRoot":"","sources":["../src/callbackToAsyncIterator.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,aAAa,EAAE,SAAS,EACtE,QAAQ,EAAE,CACR,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,KACrC,CAAC,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC,EAC3E,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;CAChB,GACL,qBAAqB,CAAC,aAAa,CAAC,CA+EtC"}