graphile-config 0.0.1-beta.8 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,200 @@
1
1
  # graphile-config
2
2
 
3
+ ## 1.0.0-rc.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8a5a7c5`](https://github.com/graphile/crystal/commit/8a5a7c536fc4b9b702600c5cc3d413724670c327)
8
+ Thanks [@benjie](https://github.com/benjie)! - Bump to release candidate
9
+
10
+ ## 0.0.1-beta.18
11
+
12
+ ### Patch Changes
13
+
14
+ - [#2697](https://github.com/graphile/crystal/pull/2697)
15
+ [`cfd4c3c`](https://github.com/graphile/crystal/commit/cfd4c3cff0ef40ed87a2c700b7719c1ca0e73588)
16
+ Thanks [@benjie](https://github.com/benjie)! - Be more selective about the
17
+ errors caught whilst loading a config file; a bug/throw in the config file
18
+ should still be raised.
19
+
20
+ - [#2688](https://github.com/graphile/crystal/pull/2688)
21
+ [`e15f886`](https://github.com/graphile/crystal/commit/e15f886cae1041416b44b74b75426f8d43000dcf)
22
+ Thanks [@benjie](https://github.com/benjie)! - Fixes bug where two different
23
+ plugins with the same name would be allowed to exist in the same (resolved)
24
+ preset. Users of dynamically created presets and plugins (e.g.
25
+ `makeV4Preset(...)` in PostGraphile) should be wary not to include two calls
26
+ to the same factory in their preset (directly or indirectly).
27
+
28
+ ## 0.0.1-beta.17
29
+
30
+ ### Patch Changes
31
+
32
+ - [#2577](https://github.com/graphile/crystal/pull/2577)
33
+ [`0c6b1f1`](https://github.com/graphile/crystal/commit/0c6b1f1e188f6e2913832adfed9ca76dfdc25c47)
34
+ Thanks [@benjie](https://github.com/benjie)! - Update dependencies
35
+
36
+ - [#2588](https://github.com/graphile/crystal/pull/2588)
37
+ [`e0cdabe`](https://github.com/graphile/crystal/commit/e0cdabe25c8894da550546c93bc03b895585544c)
38
+ Thanks [@benjie](https://github.com/benjie)! - Add support for
39
+ `--experimental-strip-types` to `graphile-config`'s loading of config files.
40
+ No need for `ts-node`/`tsx` now.
41
+
42
+ ## 0.0.1-beta.16
43
+
44
+ ### Patch Changes
45
+
46
+ - [#2482](https://github.com/graphile/crystal/pull/2482)
47
+ [`459e1869a2ec58925b2bac5458af487c52a8ca37`](https://github.com/graphile/crystal/commit/459e1869a2ec58925b2bac5458af487c52a8ca37)
48
+ Thanks [@benjie](https://github.com/benjie)! - Minimum version of Node.js
49
+ bumped to Node 22 (the latest LTS).
50
+
51
+ ## 0.0.1-beta.15
52
+
53
+ ### Patch Changes
54
+
55
+ - [`00d79e6f5608affc3f36bb0ce4ca2547230174e7`](https://github.com/graphile/crystal/commit/00d79e6f5608affc3f36bb0ce4ca2547230174e7)
56
+ Thanks [@benjie](https://github.com/benjie)! - Rename parameter to
57
+ Middleware.register.
58
+
59
+ ## 0.0.1-beta.14
60
+
61
+ ### Patch Changes
62
+
63
+ - [#2280](https://github.com/graphile/crystal/pull/2280)
64
+ [`83c546509`](https://github.com/graphile/crystal/commit/83c546509d24be2955a56120981363ad3c3a5f3f)
65
+ Thanks [@benjie](https://github.com/benjie)! - Fix TypeScript types of
66
+ MiddlewareNext
67
+
68
+ ## 0.0.1-beta.13
69
+
70
+ ### Patch Changes
71
+
72
+ - [#2270](https://github.com/graphile/crystal/pull/2270)
73
+ [`7580bc16a`](https://github.com/graphile/crystal/commit/7580bc16a050fd8d916c6dabe9d1ded980090349)
74
+ Thanks [@benjie](https://github.com/benjie)! - Check that `process` exists
75
+ before reading from it.
76
+
77
+ ## 0.0.1-beta.12
78
+
79
+ ### Patch Changes
80
+
81
+ - [#2240](https://github.com/graphile/crystal/pull/2240)
82
+ [`d13b76f0f`](https://github.com/graphile/crystal/commit/d13b76f0fef2a58466ecb44880af62d25910e83e)
83
+ Thanks [@benjie](https://github.com/benjie)! - Adds
84
+ `MiddlewareHandlers<TActivities>` type to help with adding middleware to
85
+ configs
86
+
87
+ - [#2253](https://github.com/graphile/crystal/pull/2253)
88
+ [`b167bd849`](https://github.com/graphile/crystal/commit/b167bd8499be5866b71bac6594d55bd768fda1d0)
89
+ Thanks [@benjie](https://github.com/benjie)! - 🚨 `{}` is no longer a valid
90
+ `GraphileConfig.ResolvedPreset`; use `resolvePreset({})`
91
+
92
+ Also: adds `resolvePreset(preset)` and deprecates `resolvePresets(presets)`.
93
+
94
+ - [#2250](https://github.com/graphile/crystal/pull/2250)
95
+ [`6a13ecbd4`](https://github.com/graphile/crystal/commit/6a13ecbd45534c39c846c1d8bc58242108426dd1)
96
+ Thanks [@benjie](https://github.com/benjie)! - Add support for 'preset.lib'
97
+ which can be used to store global module references to help avoid the dual
98
+ package hazard.
99
+
100
+ ## 0.0.1-beta.11
101
+
102
+ ### Patch Changes
103
+
104
+ - [#2224](https://github.com/graphile/crystal/pull/2224)
105
+ [`5626c7d36`](https://github.com/graphile/crystal/commit/5626c7d3649285e11fe9857dfa319d2883d027eb)
106
+ Thanks [@benjie](https://github.com/benjie)! - Remove requirement that plugins
107
+ have a version.
108
+
109
+ ## 0.0.1-beta.10
110
+
111
+ ### Patch Changes
112
+
113
+ - [#2188](https://github.com/graphile/crystal/pull/2188)
114
+ [`cc0941731`](https://github.com/graphile/crystal/commit/cc0941731a1679bc04ce7b7fd4254009bb5f1f62)
115
+ Thanks [@benjie](https://github.com/benjie)! - Overhaul the way in which
116
+ `graphile-config` presets work such that including a preset at two different
117
+ layers shouldn't result in unexpected behavior.
118
+
119
+ - [#2155](https://github.com/graphile/crystal/pull/2155)
120
+ [`8b472cd51`](https://github.com/graphile/crystal/commit/8b472cd51cd66d8227f9f2722d09c0a774792b0f)
121
+ Thanks [@benjie](https://github.com/benjie)! - `disablePlugins` now supports
122
+ TypeScript auto-completion of known plugin names. Other names are still
123
+ accepted without error, so this is just a minor DX improvement rather than
124
+ type safety.
125
+
126
+ - [#2160](https://github.com/graphile/crystal/pull/2160)
127
+ [`9cd9bb522`](https://github.com/graphile/crystal/commit/9cd9bb5222a9f0398ee4b8bfa4f741b6de2a2192)
128
+ Thanks [@benjie](https://github.com/benjie)! - Add support for lists of hook
129
+ objects, so that the same hook can be applied multiple times in the same
130
+ plugin but with different priorities.
131
+
132
+ ## 0.0.1-beta.9
133
+
134
+ ### Patch Changes
135
+
136
+ - [#2071](https://github.com/graphile/crystal/pull/2071)
137
+ [`582bd768f`](https://github.com/graphile/crystal/commit/582bd768fec403ce3284f293b85b9fd86e4d3f40)
138
+ Thanks [@benjie](https://github.com/benjie)! - `GrafastExecutionArgs` now
139
+ accepts `resolvedPreset` and `requestContext` directly; passing these through
140
+ additional arguments is now deprecated and support will be removed in a future
141
+ revision. This affects:
142
+ - `grafast()`
143
+ - `execute()`
144
+ - `subscribe()`
145
+ - `hookArgs()`
146
+
147
+ `graphile-config` has gained a middleware system which is more powerful than
148
+ it's AsyncHooks system. Old hooks can be emulated through the middleware
149
+ system safely since middleware is a superset of hooks' capabilities.
150
+ `applyHooks` has been renamed to `orderedApply` (because it applies to more
151
+ than just hooks), calling `applyHooks` will still work but is deprecated.
152
+
153
+ 🚨 `grafast` no longer automatically reads your `graphile.config.ts` or
154
+ similar; you must do that yourself and pass the `resolvedPreset` to grafast
155
+ via the `args`. This is to aid in bundling of grafast since it should not need
156
+ to read from filesystem or dynamically load modules.
157
+
158
+ `grafast` no longer outputs performance warning when you set
159
+ `GRAPHILE_ENV=development`.
160
+
161
+ 🚨 `plugin.grafast.hooks.args` is now `plugin.grafast.middleware.prepareArgs`,
162
+ and the signature has changed - you must be sure to call the `next()` function
163
+ and ctx/resolvedPreset can be extracted directly from `args`:
164
+
165
+ ```diff
166
+ const plugin = {
167
+ grafast: {
168
+ - hooks: {
169
+ + middleware: {
170
+ - args({ args, ctx, resolvedPreset }) {
171
+ + prepareArgs(next, { args }) {
172
+ + const { requestContext: ctx, resolvedPreset } = args;
173
+ // ...
174
+ + return next();
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ Many more middleware have been added; use TypeScript's autocomplete to see
182
+ what's available until we have proper documentation for them.
183
+
184
+ `plugin.grafserv.hooks.*` are still supported but deprecated; instead use
185
+ middleware `plugin.grafserv.middleware.*` (note that call signatures have
186
+ changed slightly, similar to the diff above):
187
+ - `hooks.init` -> `middleware.setPreset`
188
+ - `hooks.processGraphQLRequestBody` -> `middleware.processGraphQLRequestBody`
189
+ - `hooks.ruruHTMLParts` -> `middleware.ruruHTMLParts`
190
+
191
+ A few TypeScript types related to Hooks have been renamed, but their old names
192
+ are still available, just deprecated. They will be removed in a future update:
193
+ - `HookObject` -> `FunctionalityObject`
194
+ - `PluginHook` -> `CallbackOrDescriptor`
195
+ - `PluginHookObject` -> `CallbackDescriptor`
196
+ - `PluginHookCallback` -> `UnwrapCallback`
197
+
3
198
  ## 0.0.1-beta.8
4
199
 
5
200
  ### Patch Changes
package/README.md CHANGED
@@ -125,12 +125,7 @@ And please give some love to our featured sponsors 🤩:
125
125
 
126
126
  <table><tr>
127
127
  <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>
128
- <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>
129
- <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>
130
- <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>
131
- </tr><tr>
132
128
  <td align="center"><a href="https://gosteelhead.com/"><img src="https://graphile.org/images/sponsors/steelhead.svg" width="90" height="90" alt="Steelhead" /><br />Steelhead</a> *</td>
133
- <td align="center"><a href="https://www.sylvera.com/"><img src="https://graphile.org/images/sponsors/sylvera.svg" width="90" height="90" alt="Sylvera" /><br />Sylvera</a> *</td>
134
129
  </tr></table>
135
130
 
136
131
  <em>\* Sponsors the entire Graphile suite</em>
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTerminalWidth = exports.runCli = void 0;
3
+ exports.runCli = runCli;
4
+ exports.getTerminalWidth = getTerminalWidth;
4
5
  const tslib_1 = require("tslib");
5
6
  const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
7
  const helpers_1 = require("yargs/helpers");
@@ -17,9 +18,7 @@ Thank you for using our software.`)
17
18
  .wrap(yargs_1.default.terminalWidth()).argv;
18
19
  await run(argv);
19
20
  }
20
- exports.runCli = runCli;
21
21
  function getTerminalWidth() {
22
22
  return yargs_1.default.terminalWidth();
23
23
  }
24
- exports.getTerminalWidth = getTerminalWidth;
25
24
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AACA,0DAA0B;AAC1B,2CAAwC;AAejC,KAAK,UAAU,MAAM,CAC1B,OAA+B,EAC/B,GAAyC;IAEzC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;SACrD,MAAM,EAAE;SACR,cAAc,CAAC,KAAK,EAAE,sCAAsC,CAAC;SAC7D,QAAQ,CACP;;;;;kCAK4B,CAC7B;SACA,IAAI,CAAC,eAAK,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC;IACpC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC;AAjBD,wBAiBC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,eAAK,CAAC,aAAa,EAAE,CAAC;AAC/B,CAAC;AAFD,4CAEC"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAiBA,wBAiBC;AAED,4CAEC;;AArCD,0DAA0B;AAC1B,2CAAwC;AAejC,KAAK,UAAU,MAAM,CAC1B,OAA+B,EAC/B,GAAyC;IAEzC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;SACrD,MAAM,EAAE;SACR,cAAc,CAAC,KAAK,EAAE,sCAAsC,CAAC;SAC7D,QAAQ,CACP;;;;;kCAK4B,CAC7B;SACA,IAAI,CAAC,eAAK,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC;IACpC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,eAAK,CAAC,aAAa,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CallbackDescriptor, CallbackOrDescriptor, FunctionalityObject } from "./interfaces.js";
2
+ export declare function orderedApply<TFunctionality extends FunctionalityObject<TFunctionality>>(plugins: readonly GraphileConfig.Plugin[] | undefined, functionalityRetriever: (plugin: GraphileConfig.Plugin) => Partial<TFunctionality> | undefined, applyCallback: <TFunctionalityName extends keyof TFunctionality>(functionalityName: TFunctionalityName, hookFn: TFunctionality[TFunctionalityName] extends CallbackOrDescriptor<infer U> ? U : TFunctionality[TFunctionalityName] extends ReadonlyArray<CallbackDescriptor<infer U>> ? U : never, plugin: GraphileConfig.Plugin) => void): void;
3
+ //# sourceMappingURL=functionality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functionality.d.ts","sourceRoot":"","sources":["../src/functionality.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AAkBzB,wBAAgB,YAAY,CAC1B,cAAc,SAAS,mBAAmB,CAAC,cAAc,CAAC,EAE1D,OAAO,EAAE,SAAS,cAAc,CAAC,MAAM,EAAE,GAAG,SAAS,EACrD,sBAAsB,EAAE,CACtB,MAAM,EAAE,cAAc,CAAC,MAAM,KAC1B,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,EACxC,aAAa,EAAE,CAAC,kBAAkB,SAAS,MAAM,cAAc,EAC7D,iBAAiB,EAAE,kBAAkB,EACrC,MAAM,EAAE,cAAc,CAAC,kBAAkB,CAAC,SAAS,oBAAoB,CACrE,MAAM,CAAC,CACR,GACG,CAAC,GACD,cAAc,CAAC,kBAAkB,CAAC,SAAS,aAAa,CACpD,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAC5B,GACD,CAAC,GACD,KAAK,EACX,MAAM,EAAE,cAAc,CAAC,MAAM,KAC1B,IAAI,GACR,IAAI,CAgFN"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orderedApply = orderedApply;
4
+ const sort_js_1 = require("./sort.js");
5
+ // TypeScript nonsense
6
+ const isCallbackDescriptor = (v) => typeof v !== "function";
7
+ const isCallback = (v) => typeof v === "function";
8
+ function isArray(arg) {
9
+ return Array.isArray(arg);
10
+ }
11
+ function orderedApply(plugins, functionalityRetriever, applyCallback) {
12
+ // Normalize all the plugin "functionalities" and gather them into collections
13
+ const allFunctionalities = Object.create(null);
14
+ let uid = 0;
15
+ if (plugins) {
16
+ for (const plugin of plugins) {
17
+ const hooks = functionalityRetriever(plugin);
18
+ if (!hooks) {
19
+ continue;
20
+ }
21
+ const keys = Object.keys(hooks);
22
+ for (const key of keys) {
23
+ const value = hooks[key];
24
+ if (!value) {
25
+ continue;
26
+ }
27
+ const hookList = isArray(value) ? value : [value];
28
+ for (const hookSpecRaw of hookList) {
29
+ const callback = (isCallback(hookSpecRaw) ? hookSpecRaw : hookSpecRaw.callback);
30
+ const { provides, before, after } = isCallbackDescriptor(hookSpecRaw)
31
+ ? hookSpecRaw
32
+ : {};
33
+ if (!allFunctionalities[key]) {
34
+ allFunctionalities[key] = [];
35
+ }
36
+ // We need to give each functionality a unique ID
37
+ const id = String(uid++);
38
+ allFunctionalities[key].push({
39
+ id,
40
+ plugin,
41
+ callback,
42
+ provides: [...(provides || []), id, plugin.name],
43
+ before: before || [],
44
+ after: after || [],
45
+ });
46
+ }
47
+ }
48
+ }
49
+ }
50
+ // Sort the collections according to provides, before and after.
51
+ for (const functionalityName in allFunctionalities) {
52
+ const functionalities = allFunctionalities[functionalityName];
53
+ if (!functionalities) {
54
+ continue;
55
+ }
56
+ const final = (0, sort_js_1.sortWithBeforeAfterProvides)(functionalities, "id");
57
+ // Finally we can register the functionalities
58
+ for (const functionality of final) {
59
+ applyCallback(functionalityName, functionality.callback, functionality.plugin);
60
+ }
61
+ }
62
+ }
63
+ //# sourceMappingURL=functionality.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functionality.js","sourceRoot":"","sources":["../src/functionality.ts"],"names":[],"mappings":";;AAwBA,oCAoGC;AArHD,uCAAwD;AAExD,sBAAsB;AACtB,MAAM,oBAAoB,GAAG,CAC3B,CAA0B,EACE,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC;AACzD,MAAM,UAAU,GAAG,CACjB,CAA0B,EAClB,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC;AACrC,SAAS,OAAO,CACd,GAE8C;IAE9C,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,YAAY,CAG1B,OAAqD,EACrD,sBAEwC,EACxC,aAYS;IAUT,8EAA8E;IAC9E,MAAM,kBAAkB,GAEpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,SA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E;IAChE,KAAK,MAAM,iBAAiB,IAAI,kBAAkB,EAAE,CAAC;QACnD,MAAM,eAAe,GAAG,kBAAkB,CAAC,iBAAiB,CAE/C,CAAC;QACd,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,SAAS;QACX,CAAC;QAED,MAAM,KAAK,GAAG,IAAA,qCAA2B,EAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAEjE,8CAA8C;QAC9C,KAAK,MAAM,aAAa,IAAI,KAAK,EAAE,CAAC;YAClC,aAAa,CACX,iBAAiB,EACjB,aAAa,CAAC,QAAQ,EACtB,aAAa,CAAC,MAAM,CACrB,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
package/dist/hooks.d.ts CHANGED
@@ -1,15 +1,24 @@
1
- import type { PluginHook } from "./interfaces.js";
2
- export type HookObject<T> = Record<keyof T, PluginHook<(...args: any[]) => any>>;
3
- export declare class AsyncHooks<THooks extends HookObject<THooks>> {
1
+ import { orderedApply } from "./functionality.js";
2
+ import type { CallbackDescriptor, CallbackOrDescriptor, FunctionalityObject, PromiseOrDirect, UnwrapCallback } from "./interfaces.js";
3
+ export declare class AsyncHooks<THooks extends FunctionalityObject<THooks>> {
4
4
  callbacks: {
5
- [key in keyof THooks]?: Array<THooks[keyof THooks] extends PluginHook<infer U> ? U : never>;
5
+ [key in keyof THooks]?: Array<THooks[keyof THooks] extends CallbackOrDescriptor<infer U> ? U : never>;
6
6
  };
7
- hook<THookName extends keyof THooks>(event: THookName, fn: THooks[THookName] extends PluginHook<infer U> ? U : never): void;
7
+ hook<THookName extends keyof THooks>(event: THookName, fn: THooks[THookName] extends CallbackOrDescriptor<infer U> ? U : never): void;
8
8
  /**
9
9
  * Hooks can _mutate_ the argument, they cannot return a replacement. This
10
10
  * allows us to completely side-step the problem of recursive calls.
11
11
  */
12
- process<THookName extends keyof THooks>(event: THookName, ...args: Parameters<THooks[THookName] extends PluginHook<infer U> ? U : never>): void | Promise<void>;
12
+ process<THookName extends keyof THooks>(hookName: THookName, ...args: Parameters<THooks[THookName] extends CallbackOrDescriptor<infer U> ? U : never>): void | Promise<void>;
13
13
  }
14
- export declare function applyHooks<THooks extends HookObject<THooks>>(plugins: readonly GraphileConfig.Plugin[] | undefined, hooksRetriever: (plugin: GraphileConfig.Plugin) => Partial<THooks> | undefined, applyHookCallback: <THookName extends keyof THooks>(hookName: THookName, hookFn: THooks[THookName] extends PluginHook<infer U> ? U : never, plugin: GraphileConfig.Plugin) => void): void;
14
+ /** @deprecated Use FunctionalityObject */
15
+ export type HookObject<T> = FunctionalityObject<T>;
16
+ /** @deprecated Use `orderedApply` */
17
+ export declare const applyHooks: typeof orderedApply;
18
+ /** @deprecated Use CallbackDescriptor */
19
+ export type PluginHookObject<T extends (...args: any[]) => any> = CallbackDescriptor<T>;
20
+ /** @deprecated Use CallbackOrDescriptor */
21
+ export type PluginHook<T extends (...args: any[]) => PromiseOrDirect<UnwrapCallback<any> | void>> = CallbackOrDescriptor<T> | readonly CallbackDescriptor<T>[];
22
+ /** @deprecated Use UnwrapCallback */
23
+ export type PluginHookCallback<T extends CallbackOrDescriptor<(...args: any[]) => any>> = UnwrapCallback<T>;
15
24
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAKpE,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,MAAM,CAChC,MAAM,CAAC,EACP,UAAU,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CACpC,CAAC;AAEF,qBAAa,UAAU,CAAC,MAAM,SAAS,UAAU,CAAC,MAAM,CAAC;IACvD,SAAS,EAAE;SACR,GAAG,IAAI,MAAM,MAAM,CAAC,CAAC,EAAE,KAAK,CAC3B,MAAM,CAAC,MAAM,MAAM,CAAC,SAAS,UAAU,CAAC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,CAAC,SAAS,oBAAoB,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,IACrD,cAAc,CAAC,CAAC,CAAC,CAAC"}
package/dist/hooks.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyHooks = exports.AsyncHooks = void 0;
4
- const sort_js_1 = require("./sort.js");
5
- const isDev = process.env.GRAPHILE_ENV === "development";
4
+ const functionality_js_1 = require("./functionality.js");
5
+ const isDev = typeof process !== "undefined" && process.env.GRAPHILE_ENV === "development";
6
6
  class AsyncHooks {
7
7
  constructor() {
8
8
  this.callbacks = Object.create(null);
@@ -15,8 +15,8 @@ class AsyncHooks {
15
15
  * Hooks can _mutate_ the argument, they cannot return a replacement. This
16
16
  * allows us to completely side-step the problem of recursive calls.
17
17
  */
18
- process(event, ...args) {
19
- const callbacks = this.callbacks[event];
18
+ process(hookName, ...args) {
19
+ const callbacks = this.callbacks[hookName];
20
20
  if (!callbacks) {
21
21
  return;
22
22
  }
@@ -31,7 +31,7 @@ class AsyncHooks {
31
31
  const result = callback.apply(null, args);
32
32
  if (result != null) {
33
33
  if (isDev && typeof result.then !== "function") {
34
- throw new Error(`Hook '${event}' returned invalid value of type ${typeof result} - must be 'undefined' or a Promise/PromiseLike.`);
34
+ throw new Error(`Hook '${hookName}' returned invalid value of type ${typeof result} - must be 'undefined' or a Promise/PromiseLike.`);
35
35
  }
36
36
  chain = result;
37
37
  }
@@ -41,57 +41,6 @@ class AsyncHooks {
41
41
  }
42
42
  }
43
43
  exports.AsyncHooks = AsyncHooks;
44
- function applyHooks(plugins, hooksRetriever, applyHookCallback) {
45
- // Normalize all the hooks and gather them into collections
46
- const allHooks = Object.create(null);
47
- let uid = 0;
48
- if (plugins) {
49
- for (const plugin of plugins) {
50
- const hooks = hooksRetriever(plugin);
51
- if (!hooks) {
52
- continue;
53
- }
54
- const keys = Object.keys(hooks);
55
- for (const key of keys) {
56
- const hookSpecRaw = hooks[key];
57
- if (!hookSpecRaw) {
58
- continue;
59
- }
60
- // TypeScript nonsense
61
- const isPluginHookObject = (v) => typeof v !== "function";
62
- const isPluginHookFunction = (v) => typeof v === "function";
63
- const callback = (isPluginHookFunction(hookSpecRaw) ? hookSpecRaw : hookSpecRaw.callback);
64
- const { provides, before, after } = isPluginHookObject(hookSpecRaw)
65
- ? hookSpecRaw
66
- : {};
67
- if (!allHooks[key]) {
68
- allHooks[key] = [];
69
- }
70
- // We need to give each hook a unique ID
71
- const id = String(uid++);
72
- allHooks[key].push({
73
- id,
74
- plugin,
75
- callback,
76
- provides: [...(provides || []), id, plugin.name],
77
- before: before || [],
78
- after: after || [],
79
- });
80
- }
81
- }
82
- }
83
- // Sort the collections according to provides, before and after.
84
- for (const hookName in allHooks) {
85
- const hooks = allHooks[hookName];
86
- if (!hooks) {
87
- continue;
88
- }
89
- const final = (0, sort_js_1.sortWithBeforeAfterProvides)(hooks, "id");
90
- // Finally we can register the hooks
91
- for (const hook of final) {
92
- applyHookCallback(hookName, hook.callback, hook.plugin);
93
- }
94
- }
95
- }
96
- exports.applyHooks = applyHooks;
44
+ /** @deprecated Use `orderedApply` */
45
+ exports.applyHooks = functionality_js_1.orderedApply;
97
46
  //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;AACA,uCAAwD;AAExD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,aAAa,CAAC;AAOzD,MAAa,UAAU;IAAvB;QACE,cAAS,GAIL,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IA8C1B,CAAC;IA5CC,IAAI,CACF,KAAgB,EAChB,EAA6D;QAE7D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE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CAAC,MAAM,CAAC;QAC3B,IAAI,KAAK,GAAG,SAAS,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC1C,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;oBACnB,IAAI,KAAK,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;wBAC/C,MAAM,IAAI,KAAK,CACb,SACE,QACF,oCAAoC,OAAO,MAAM,kDAAkD,CACpG,CAAC;oBACJ,CAAC;oBACD,KAAK,GAAG,MAAM,CAAC;gBACjB,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnDD,gCAmDC;AAMD,qCAAqC;AACxB,QAAA,UAAU,GAAG,+BAAY,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,19 +1,39 @@
1
1
  import "./interfaces.js";
2
2
  export { GraphileConfig };
3
- export { applyHooks, AsyncHooks, HookObject } from "./hooks.js";
4
- export type { PluginHook, PluginHookObject } from "./interfaces.js";
5
- export { isResolvedPreset, resolvePresets } from "./resolvePresets.js";
3
+ export { orderedApply } from "./functionality.js";
4
+ export { applyHooks, AsyncHooks, HookObject, PluginHook, PluginHookObject, } from "./hooks.js";
5
+ export type { CallbackDescriptor, CallbackOrDescriptor, FunctionalityObject, } from "./interfaces.js";
6
+ export type { MiddlewareHandlers, MiddlewareNext } from "./middleware.js";
7
+ export { Middleware } from "./middleware.js";
8
+ export { isResolvedPreset, resolvePreset, resolvePresets, } from "./resolvePresets.js";
6
9
  export declare function sortedPlugins(plugins: GraphileConfig.Plugin[] | undefined): GraphileConfig.Plugin[];
7
10
  declare global {
8
11
  namespace GraphileConfig {
12
+ interface Lib {
13
+ versions: Record<string, string | undefined>;
14
+ }
15
+ /**
16
+ * Expand this through declaration merging to get TypeScript
17
+ * auto-completion of plugin names in the relevant places.
18
+ */
19
+ interface Plugins {
20
+ [key: string & {}]: true;
21
+ }
22
+ /**
23
+ * Expand this through declaration merging to get TypeScript
24
+ * auto-completion of things that plugins can provide.
25
+ */
26
+ interface Provides {
27
+ [key: string & {}]: true;
28
+ }
9
29
  interface Plugin {
10
- name: string;
11
- version: string;
30
+ name: keyof GraphileConfig.Plugins;
31
+ version?: string;
12
32
  experimental?: boolean;
13
33
  description?: string;
14
- provides?: string[];
15
- after?: string[];
16
- before?: string[];
34
+ provides?: (keyof GraphileConfig.Plugins | keyof GraphileConfig.Provides)[];
35
+ after?: (keyof GraphileConfig.Plugins | keyof GraphileConfig.Provides)[];
36
+ before?: (keyof GraphileConfig.Plugins | keyof GraphileConfig.Provides)[];
17
37
  }
18
38
  /**
19
39
  * A Graphile Config Preset that can be combined with other presets to
@@ -23,15 +43,22 @@ declare global {
23
43
  interface Preset {
24
44
  extends?: ReadonlyArray<Preset>;
25
45
  plugins?: Plugin[];
26
- disablePlugins?: ReadonlyArray<string>;
46
+ disablePlugins?: ReadonlyArray<keyof GraphileConfig.Plugins>;
47
+ lib?: Partial<GraphileConfig.Lib>;
27
48
  appendPlugins?: never;
28
49
  prependPlugins?: never;
29
50
  skipPlugins?: never;
30
51
  }
52
+ /**
53
+ * The result of `resolvePreset(preset)` on a preset - compatible with
54
+ * `Preset` but guaranteed to not extend from other presets (and a few
55
+ * other assertions).
56
+ */
31
57
  interface ResolvedPreset extends Preset {
32
- extends?: ReadonlyArray<never>;
33
- plugins?: Plugin[];
34
- disablePlugins?: ReadonlyArray<string>;
58
+ extends?: never;
59
+ plugins: Plugin[];
60
+ disablePlugins: ReadonlyArray<keyof GraphileConfig.Plugins>;
61
+ lib: GraphileConfig.Lib;
35
62
  }
36
63
  }
37
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEvE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,GAAG,SAAS,GAC3C,cAAc,CAAC,MAAM,EAAE,CAMzB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,MAAM;YACd,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;YACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;YACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;SACnB;QAED;;;;WAIG;QACH,UAAU,MAAM;YACd,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;YAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;YACnB,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;YACvC,aAAa,CAAC,EAAE,KAAK,CAAC;YACtB,cAAc,CAAC,EAAE,KAAK,CAAC;YACvB,WAAW,CAAC,EAAE,KAAK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MAAM;YACd,IAAI,EAAE,MAAM,cAAc,CAAC,OAAO,CAAC;YACnC,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,CACP,MAAM,cAAc,CAAC,OAAO,GAC5B,MAAM,cAAc,CAAC,QAAQ,CAChC,EAAE,CAAC;YACJ,KAAK,CAAC,EAAE,CAAC,MAAM,cAAc,CAAC,OAAO,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzE,MAAM,CAAC,EAAE,CAAC,MAAM,cAAc,CAAC,OAAO,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;SAC3E;QAED;;;;WAIG;QACH,UAAU,MAAM;YACd,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;YAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;YACnB,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;YAC7D,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAIlC,aAAa,CAAC,EAAE,KAAK,CAAC;YACtB,cAAc,CAAC,EAAE,KAAK,CAAC;YACvB,WAAW,CAAC,EAAE,KAAK,CAAC;SAGrB;QAED;;;;WAIG;QACH,UAAU,cAAe,SAAQ,MAAM;YAGrC,OAAO,CAAC,EAAE,KAAK,CAAC;YAChB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,cAAc,EAAE,aAAa,CAAC,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;YAC5D,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC;SACzB;KACF;CACF"}
package/dist/index.js CHANGED
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortedPlugins = exports.resolvePresets = exports.isResolvedPreset = exports.AsyncHooks = exports.applyHooks = void 0;
3
+ exports.resolvePresets = exports.resolvePreset = exports.isResolvedPreset = exports.Middleware = exports.AsyncHooks = exports.applyHooks = exports.orderedApply = void 0;
4
+ exports.sortedPlugins = sortedPlugins;
4
5
  require("./interfaces.js");
5
6
  const sort_js_1 = require("./sort.js");
7
+ var functionality_js_1 = require("./functionality.js");
8
+ Object.defineProperty(exports, "orderedApply", { enumerable: true, get: function () { return functionality_js_1.orderedApply; } });
6
9
  var hooks_js_1 = require("./hooks.js");
7
10
  Object.defineProperty(exports, "applyHooks", { enumerable: true, get: function () { return hooks_js_1.applyHooks; } });
8
11
  Object.defineProperty(exports, "AsyncHooks", { enumerable: true, get: function () { return hooks_js_1.AsyncHooks; } });
12
+ var middleware_js_1 = require("./middleware.js");
13
+ Object.defineProperty(exports, "Middleware", { enumerable: true, get: function () { return middleware_js_1.Middleware; } });
9
14
  var resolvePresets_js_1 = require("./resolvePresets.js");
10
15
  Object.defineProperty(exports, "isResolvedPreset", { enumerable: true, get: function () { return resolvePresets_js_1.isResolvedPreset; } });
16
+ Object.defineProperty(exports, "resolvePreset", { enumerable: true, get: function () { return resolvePresets_js_1.resolvePreset; } });
11
17
  Object.defineProperty(exports, "resolvePresets", { enumerable: true, get: function () { return resolvePresets_js_1.resolvePresets; } });
12
18
  function sortedPlugins(plugins) {
13
19
  if (plugins) {
@@ -17,5 +23,4 @@ function sortedPlugins(plugins) {
17
23
  return [];
18
24
  }
19
25
  }
20
- exports.sortedPlugins = sortedPlugins;
21
26
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AAEzB,uCAAwD;AAIxD,uCAAgE;AAAvD,sGAAA,UAAU,OAAA;AAAE,sGAAA,UAAU,OAAA;AAE/B,yDAAuE;AAA9D,qHAAA,gBAAgB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAEzC,SAAgB,aAAa,CAC3B,OAA4C;IAE5C,IAAI,OAAO,EAAE;QACX,OAAO,IAAA,qCAA2B,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KACrD;SAAM;QACL,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,sCAQC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA2BA,sCAQC;AAnCD,2BAAyB;AAEzB,uCAAwD;AAIxD,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,uCAMoB;AALlB,sGAAA,UAAU,OAAA;AACV,sGAAA,UAAU,OAAA;AAWZ,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,yDAI6B;AAH3B,qHAAA,gBAAgB,OAAA;AAChB,kHAAA,aAAa,OAAA;AACb,mHAAA,cAAc,OAAA;AAGhB,SAAgB,aAAa,CAC3B,OAA4C;IAE5C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,IAAA,qCAA2B,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -1,9 +1,12 @@
1
- export type PluginHookObject<T extends (...args: any[]) => any> = {
2
- provides?: string[];
3
- before?: string[];
4
- after?: string[];
1
+ export type AnyCallback = (...args: any[]) => any;
2
+ export type CallbackDescriptor<T extends AnyCallback> = {
3
+ provides?: (keyof GraphileConfig.Plugins | keyof GraphileConfig.Provides)[];
4
+ before?: (keyof GraphileConfig.Plugins | keyof GraphileConfig.Provides)[];
5
+ after?: (keyof GraphileConfig.Plugins | keyof GraphileConfig.Provides)[];
5
6
  callback: T;
6
7
  };
7
- export type PluginHook<T extends (...args: any[]) => any> = T | PluginHookObject<T>;
8
- export type PluginHookCallback<T extends PluginHook<(...args: any[]) => any>> = T extends PluginHook<infer U> ? U : never;
8
+ export type PromiseOrDirect<T> = T | PromiseLike<T>;
9
+ export type CallbackOrDescriptor<T extends AnyCallback> = T | CallbackDescriptor<T>;
10
+ export type UnwrapCallback<T extends CallbackOrDescriptor<AnyCallback> | ReadonlyArray<CallbackDescriptor<AnyCallback>>> = T extends CallbackOrDescriptor<infer U> ? U : T extends ReadonlyArray<CallbackDescriptor<infer U>> ? U : never;
11
+ export type FunctionalityObject<T> = Record<keyof T, CallbackOrDescriptor<AnyCallback> | ReadonlyArray<CallbackDescriptor<AnyCallback>>>;
9
12
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI;IAChE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACpD,CAAC,GACD,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAExB,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,IAC1E,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAElD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI;IACtD,QAAQ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file":"loadConfig.d.ts","sourceRoot":"","sources":["../src/loadConfig.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,CAAC;AAiHzB,wBAAsB,UAAU,CAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAwDvC"}