@axinom/mosaic-graphql-common 0.33.0 → 0.34.0-rc.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.
- package/dist/cjs/common/checks.d.ts.map +1 -0
- package/dist/cjs/common/checks.js.map +1 -0
- package/dist/cjs/common/index.d.ts +3 -0
- package/dist/cjs/common/index.d.ts.map +1 -0
- package/dist/{common → cjs/common}/index.js +2 -2
- package/dist/cjs/common/index.js.map +1 -0
- package/dist/cjs/common/types.d.ts.map +1 -0
- package/dist/cjs/common/types.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/{index.js → cjs/index.js} +4 -4
- package/dist/cjs/index.js.map +1 -0
- package/dist/{middleware → cjs/middleware}/forward-to-graphiql.d.ts +1 -1
- package/dist/cjs/middleware/forward-to-graphiql.d.ts.map +1 -0
- package/dist/cjs/middleware/forward-to-graphiql.js.map +1 -0
- package/dist/cjs/middleware/index.d.ts +2 -0
- package/dist/cjs/middleware/index.d.ts.map +1 -0
- package/dist/{middleware → cjs/middleware}/index.js +1 -1
- package/dist/cjs/middleware/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{plugins → cjs/plugins}/add-error-codes-enum-plugin.d.ts +2 -2
- package/dist/cjs/plugins/add-error-codes-enum-plugin.d.ts.map +1 -0
- package/dist/cjs/plugins/add-error-codes-enum-plugin.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/annotate-types-with-permissions-plugin.d.ts +1 -1
- package/dist/cjs/plugins/annotate-types-with-permissions-plugin.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/annotate-types-with-permissions-plugin.js +5 -6
- package/dist/cjs/plugins/annotate-types-with-permissions-plugin.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/bulk-edit/bulk-edit-async-plugin-factory.d.ts +4 -4
- package/dist/cjs/plugins/bulk-edit/bulk-edit-async-plugin-factory.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/bulk-edit/bulk-edit-async-plugin-factory.js +22 -15
- package/dist/cjs/plugins/bulk-edit/bulk-edit-async-plugin-factory.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/bulk-edit/bulk-edit-item-change-handler-helpers.d.ts +5 -5
- package/dist/cjs/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.d.ts.map +1 -0
- package/dist/cjs/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/deprecate-stray-node-id-fields-plugin.d.ts +1 -1
- package/dist/cjs/plugins/deprecate-stray-node-id-fields-plugin.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/deprecate-stray-node-id-fields-plugin.js +2 -2
- package/dist/cjs/plugins/deprecate-stray-node-id-fields-plugin.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/generic-bulk-plugin-factory.d.ts +1 -1
- package/dist/cjs/plugins/generic-bulk-plugin-factory.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/generic-bulk-plugin-factory.js +21 -21
- package/dist/cjs/plugins/generic-bulk-plugin-factory.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/graphiql-management-mode-plugin-hook.d.ts +1 -1
- package/dist/cjs/plugins/graphiql-management-mode-plugin-hook.d.ts.map +1 -0
- package/dist/cjs/plugins/graphiql-management-mode-plugin-hook.js.map +1 -0
- package/dist/cjs/plugins/index.d.ts +12 -0
- package/dist/cjs/plugins/index.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/index.js +11 -11
- package/dist/cjs/plugins/index.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/omit-from-query-root-plugin.d.ts +1 -1
- package/dist/cjs/plugins/omit-from-query-root-plugin.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/omit-from-query-root-plugin.js +1 -1
- package/dist/cjs/plugins/omit-from-query-root-plugin.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/operations-enum-generator-plugin-factory.d.ts +7 -1
- package/dist/cjs/plugins/operations-enum-generator-plugin-factory.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/operations-enum-generator-plugin-factory.js +15 -4
- package/dist/cjs/plugins/operations-enum-generator-plugin-factory.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/subscriptions-plugin-factory.d.ts +1 -1
- package/dist/cjs/plugins/subscriptions-plugin-factory.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/subscriptions-plugin-factory.js +7 -14
- package/dist/cjs/plugins/subscriptions-plugin-factory.js.map +1 -0
- package/dist/{plugins → cjs/plugins}/validation-directives-plugin.d.ts +1 -1
- package/dist/cjs/plugins/validation-directives-plugin.d.ts.map +1 -0
- package/dist/{plugins → cjs/plugins}/validation-directives-plugin.js +3 -4
- package/dist/cjs/plugins/validation-directives-plugin.js.map +1 -0
- package/dist/{postgraphile → cjs/postgraphile}/enhance-graphql-errors.d.ts +3 -3
- package/dist/cjs/postgraphile/enhance-graphql-errors.d.ts.map +1 -0
- package/dist/{postgraphile → cjs/postgraphile}/enhance-graphql-errors.js +23 -19
- package/dist/cjs/postgraphile/enhance-graphql-errors.js.map +1 -0
- package/dist/cjs/postgraphile/index.d.ts +4 -0
- package/dist/cjs/postgraphile/index.d.ts.map +1 -0
- package/dist/{postgraphile → cjs/postgraphile}/index.js +3 -3
- package/dist/cjs/postgraphile/index.js.map +1 -0
- package/dist/{postgraphile → cjs/postgraphile}/postgraphile-options-builder.d.ts +4 -4
- package/dist/cjs/postgraphile/postgraphile-options-builder.d.ts.map +1 -0
- package/dist/{postgraphile → cjs/postgraphile}/postgraphile-options-builder.js +34 -25
- package/dist/cjs/postgraphile/postgraphile-options-builder.js.map +1 -0
- package/dist/{postgraphile → cjs/postgraphile}/websocket-utils.d.ts +2 -2
- package/dist/cjs/postgraphile/websocket-utils.d.ts.map +1 -0
- package/dist/cjs/postgraphile/websocket-utils.js.map +1 -0
- package/dist/esm/common/checks.d.ts +9 -0
- package/dist/esm/common/checks.d.ts.map +1 -0
- package/dist/esm/common/checks.js +16 -0
- package/dist/esm/common/checks.js.map +1 -0
- package/dist/esm/common/index.d.ts +3 -0
- package/dist/esm/common/index.d.ts.map +1 -0
- package/dist/esm/common/index.js +3 -0
- package/dist/esm/common/index.js.map +1 -0
- package/dist/esm/common/types.d.ts +13 -0
- package/dist/esm/common/types.d.ts.map +1 -0
- package/dist/esm/common/types.js +11 -0
- package/dist/esm/common/types.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/middleware/forward-to-graphiql.d.ts +8 -0
- package/dist/esm/middleware/forward-to-graphiql.d.ts.map +1 -0
- package/dist/esm/middleware/forward-to-graphiql.js +17 -0
- package/dist/esm/middleware/forward-to-graphiql.js.map +1 -0
- package/dist/esm/middleware/index.d.ts +2 -0
- package/dist/esm/middleware/index.d.ts.map +1 -0
- package/dist/esm/middleware/index.js +2 -0
- package/dist/esm/middleware/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/plugins/add-error-codes-enum-plugin.d.ts +27 -0
- package/dist/esm/plugins/add-error-codes-enum-plugin.d.ts.map +1 -0
- package/dist/esm/plugins/add-error-codes-enum-plugin.js +74 -0
- package/dist/esm/plugins/add-error-codes-enum-plugin.js.map +1 -0
- package/dist/esm/plugins/annotate-types-with-permissions-plugin.d.ts +22 -0
- package/dist/esm/plugins/annotate-types-with-permissions-plugin.d.ts.map +1 -0
- package/dist/esm/plugins/annotate-types-with-permissions-plugin.js +140 -0
- package/dist/esm/plugins/annotate-types-with-permissions-plugin.js.map +1 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-async-plugin-factory.d.ts +61 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-async-plugin-factory.d.ts.map +1 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-async-plugin-factory.js +397 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-async-plugin-factory.js.map +1 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.d.ts +15 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.d.ts.map +1 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.js +82 -0
- package/dist/esm/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.js.map +1 -0
- package/dist/esm/plugins/deprecate-stray-node-id-fields-plugin.d.ts +14 -0
- package/dist/esm/plugins/deprecate-stray-node-id-fields-plugin.d.ts.map +1 -0
- package/dist/esm/plugins/deprecate-stray-node-id-fields-plugin.js +33 -0
- package/dist/esm/plugins/deprecate-stray-node-id-fields-plugin.js.map +1 -0
- package/dist/esm/plugins/generic-bulk-plugin-factory.d.ts +51 -0
- package/dist/esm/plugins/generic-bulk-plugin-factory.d.ts.map +1 -0
- package/dist/esm/plugins/generic-bulk-plugin-factory.js +178 -0
- package/dist/esm/plugins/generic-bulk-plugin-factory.js.map +1 -0
- package/dist/esm/plugins/graphiql-management-mode-plugin-hook.d.ts +13 -0
- package/dist/esm/plugins/graphiql-management-mode-plugin-hook.d.ts.map +1 -0
- package/dist/esm/plugins/graphiql-management-mode-plugin-hook.js +41 -0
- package/dist/esm/plugins/graphiql-management-mode-plugin-hook.js.map +1 -0
- package/dist/esm/plugins/index.d.ts +12 -0
- package/dist/esm/plugins/index.d.ts.map +1 -0
- package/dist/esm/plugins/index.js +12 -0
- package/dist/esm/plugins/index.js.map +1 -0
- package/dist/esm/plugins/omit-from-query-root-plugin.d.ts +17 -0
- package/dist/esm/plugins/omit-from-query-root-plugin.d.ts.map +1 -0
- package/dist/esm/plugins/omit-from-query-root-plugin.js +39 -0
- package/dist/esm/plugins/omit-from-query-root-plugin.js.map +1 -0
- package/dist/esm/plugins/operations-enum-generator-plugin-factory.d.ts +21 -0
- package/dist/esm/plugins/operations-enum-generator-plugin-factory.d.ts.map +1 -0
- package/dist/esm/plugins/operations-enum-generator-plugin-factory.js +112 -0
- package/dist/esm/plugins/operations-enum-generator-plugin-factory.js.map +1 -0
- package/dist/esm/plugins/subscriptions-plugin-factory.d.ts +9 -0
- package/dist/esm/plugins/subscriptions-plugin-factory.d.ts.map +1 -0
- package/dist/esm/plugins/subscriptions-plugin-factory.js +103 -0
- package/dist/esm/plugins/subscriptions-plugin-factory.js.map +1 -0
- package/dist/esm/plugins/validation-directives-plugin.d.ts +6 -0
- package/dist/esm/plugins/validation-directives-plugin.d.ts.map +1 -0
- package/dist/esm/plugins/validation-directives-plugin.js +109 -0
- package/dist/esm/plugins/validation-directives-plugin.js.map +1 -0
- package/dist/esm/postgraphile/enhance-graphql-errors.d.ts +49 -0
- package/dist/esm/postgraphile/enhance-graphql-errors.d.ts.map +1 -0
- package/dist/esm/postgraphile/enhance-graphql-errors.js +77 -0
- package/dist/esm/postgraphile/enhance-graphql-errors.js.map +1 -0
- package/dist/esm/postgraphile/index.d.ts +4 -0
- package/dist/esm/postgraphile/index.d.ts.map +1 -0
- package/dist/esm/postgraphile/index.js +4 -0
- package/dist/esm/postgraphile/index.js.map +1 -0
- package/dist/esm/postgraphile/postgraphile-options-builder.d.ts +285 -0
- package/dist/esm/postgraphile/postgraphile-options-builder.d.ts.map +1 -0
- package/dist/esm/postgraphile/postgraphile-options-builder.js +436 -0
- package/dist/esm/postgraphile/postgraphile-options-builder.js.map +1 -0
- package/dist/esm/postgraphile/websocket-utils.d.ts +11 -0
- package/dist/esm/postgraphile/websocket-utils.d.ts.map +1 -0
- package/dist/esm/postgraphile/websocket-utils.js +13 -0
- package/dist/esm/postgraphile/websocket-utils.js.map +1 -0
- package/package.json +24 -15
- package/src/common/index.ts +2 -2
- package/src/index.ts +4 -4
- package/src/middleware/forward-to-graphiql.ts +1 -1
- package/src/middleware/index.ts +1 -1
- package/src/plugins/add-error-codes-enum-plugin.ts +2 -2
- package/src/plugins/annotate-types-with-permissions-plugin.spec.ts +1 -1
- package/src/plugins/annotate-types-with-permissions-plugin.ts +3 -3
- package/src/plugins/bulk-edit/bulk-edit-async-plugin-factory.spec.ts +4 -4
- package/src/plugins/bulk-edit/bulk-edit-async-plugin-factory.ts +9 -9
- package/src/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.spec.ts +3 -3
- package/src/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.ts +5 -5
- package/src/plugins/deprecate-stray-node-id-fields-plugin.ts +2 -2
- package/src/plugins/generic-bulk-plugin-factory.ts +3 -3
- package/src/plugins/graphiql-management-mode-plugin-hook.ts +1 -1
- package/src/plugins/index.ts +11 -11
- package/src/plugins/omit-from-query-root-plugin.ts +3 -3
- package/src/plugins/operations-enum-generator-plugin-factory.ts +28 -5
- package/src/plugins/subscriptions-plugin-factory.ts +4 -4
- package/src/plugins/validation-directives-plugin.ts +2 -2
- package/src/postgraphile/enhance-graphql-errors.spec.ts +2 -2
- package/src/postgraphile/enhance-graphql-errors.ts +5 -5
- package/src/postgraphile/index.ts +3 -3
- package/src/postgraphile/postgraphile-options-builder.spec.ts +10 -7
- package/src/postgraphile/postgraphile-options-builder.ts +20 -11
- package/src/postgraphile/websocket-utils.ts +2 -2
- package/dist/common/checks.d.ts.map +0 -1
- package/dist/common/checks.js.map +0 -1
- package/dist/common/index.d.ts +0 -3
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js.map +0 -1
- package/dist/common/types.d.ts.map +0 -1
- package/dist/common/types.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/middleware/forward-to-graphiql.d.ts.map +0 -1
- package/dist/middleware/forward-to-graphiql.js.map +0 -1
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js.map +0 -1
- package/dist/plugins/add-error-codes-enum-plugin.d.ts.map +0 -1
- package/dist/plugins/add-error-codes-enum-plugin.js.map +0 -1
- package/dist/plugins/annotate-types-with-permissions-plugin.d.ts.map +0 -1
- package/dist/plugins/annotate-types-with-permissions-plugin.js.map +0 -1
- package/dist/plugins/bulk-edit/bulk-edit-async-plugin-factory.d.ts.map +0 -1
- package/dist/plugins/bulk-edit/bulk-edit-async-plugin-factory.js.map +0 -1
- package/dist/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.d.ts.map +0 -1
- package/dist/plugins/bulk-edit/bulk-edit-item-change-handler-helpers.js.map +0 -1
- package/dist/plugins/deprecate-stray-node-id-fields-plugin.d.ts.map +0 -1
- package/dist/plugins/deprecate-stray-node-id-fields-plugin.js.map +0 -1
- package/dist/plugins/generic-bulk-plugin-factory.d.ts.map +0 -1
- package/dist/plugins/generic-bulk-plugin-factory.js.map +0 -1
- package/dist/plugins/graphiql-management-mode-plugin-hook.d.ts.map +0 -1
- package/dist/plugins/graphiql-management-mode-plugin-hook.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -12
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/omit-from-query-root-plugin.d.ts.map +0 -1
- package/dist/plugins/omit-from-query-root-plugin.js.map +0 -1
- package/dist/plugins/operations-enum-generator-plugin-factory.d.ts.map +0 -1
- package/dist/plugins/operations-enum-generator-plugin-factory.js.map +0 -1
- package/dist/plugins/subscriptions-plugin-factory.d.ts.map +0 -1
- package/dist/plugins/subscriptions-plugin-factory.js.map +0 -1
- package/dist/plugins/validation-directives-plugin.d.ts.map +0 -1
- package/dist/plugins/validation-directives-plugin.js.map +0 -1
- package/dist/postgraphile/enhance-graphql-errors.d.ts.map +0 -1
- package/dist/postgraphile/enhance-graphql-errors.js.map +0 -1
- package/dist/postgraphile/index.d.ts +0 -4
- package/dist/postgraphile/index.d.ts.map +0 -1
- package/dist/postgraphile/index.js.map +0 -1
- package/dist/postgraphile/postgraphile-options-builder.d.ts.map +0 -1
- package/dist/postgraphile/postgraphile-options-builder.js.map +0 -1
- package/dist/postgraphile/websocket-utils.d.ts.map +0 -1
- package/dist/postgraphile/websocket-utils.js.map +0 -1
- /package/dist/{common → cjs/common}/checks.d.ts +0 -0
- /package/dist/{common → cjs/common}/checks.js +0 -0
- /package/dist/{common → cjs/common}/types.d.ts +0 -0
- /package/dist/{common → cjs/common}/types.js +0 -0
- /package/dist/{middleware → cjs/middleware}/forward-to-graphiql.js +0 -0
- /package/dist/{plugins → cjs/plugins}/add-error-codes-enum-plugin.js +0 -0
- /package/dist/{plugins → cjs/plugins}/bulk-edit/bulk-edit-item-change-handler-helpers.js +0 -0
- /package/dist/{plugins → cjs/plugins}/graphiql-management-mode-plugin-hook.js +0 -0
- /package/dist/{postgraphile → cjs/postgraphile}/websocket-utils.js +0 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import _PgPubsub from '@graphile/pg-pubsub';
|
|
3
|
+
import { NodePlugin } from 'graphile-build';
|
|
4
|
+
import { GraphQLError } from 'graphql';
|
|
5
|
+
import { IncomingMessage } from 'http';
|
|
6
|
+
import { makePluginHook, } from 'postgraphile';
|
|
7
|
+
import { enhanceGraphqlErrors } from './enhance-graphql-errors.js';
|
|
8
|
+
// @graphile/pg-pubsub is a TypeScript-compiled CJS package that emits
|
|
9
|
+
// `module.exports = { __esModule: true, default: pluginObject }`.
|
|
10
|
+
// Node.js native ESM does not honour the __esModule sentinel, so the default
|
|
11
|
+
// import receives the whole module.exports wrapper object, not the plugin.
|
|
12
|
+
// `createRequire` cannot be used here because `import.meta.url` does not
|
|
13
|
+
// compile under `module: CommonJS` in the CJS build pass of this dual-publish
|
|
14
|
+
// library. The long-term fix is upgrading to PostGraphile v5, which replaces
|
|
15
|
+
// this plugin with a first-class ESM-compatible subscription API.
|
|
16
|
+
const PgPubsub = (_PgPubsub.default ?? _PgPubsub);
|
|
17
|
+
/**
|
|
18
|
+
* A builder class that allows construction of postgraphile options using multiple dedicated extension methods.
|
|
19
|
+
*/
|
|
20
|
+
export class PostgraphileOptionsBuilder {
|
|
21
|
+
transformers = [];
|
|
22
|
+
headers = {};
|
|
23
|
+
pluginHooks = new Set();
|
|
24
|
+
hookFuncs = new Set();
|
|
25
|
+
/**
|
|
26
|
+
* Builds a postgraphile options object with previously used extension methods.
|
|
27
|
+
*/
|
|
28
|
+
build() {
|
|
29
|
+
let options = {};
|
|
30
|
+
for (const transform of this.transformers) {
|
|
31
|
+
options = transform(options);
|
|
32
|
+
}
|
|
33
|
+
this.buildHeadersHookPlugin();
|
|
34
|
+
// Build plugin hooks from hook functions
|
|
35
|
+
[...this.hookFuncs].map((hookFunc) => {
|
|
36
|
+
this.pluginHooks.add(hookFunc(options));
|
|
37
|
+
});
|
|
38
|
+
if (this.pluginHooks.size > 0) {
|
|
39
|
+
options.pluginHook = makePluginHook([...this.pluginHooks]);
|
|
40
|
+
}
|
|
41
|
+
return options;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds a hook plugin that adds custom headers to http responses.
|
|
45
|
+
*/
|
|
46
|
+
buildHeadersHookPlugin() {
|
|
47
|
+
if (Object.keys(this.headers).length > 0) {
|
|
48
|
+
this.pluginHooks.add({
|
|
49
|
+
'postgraphile:http:handler': (req, { res }) => {
|
|
50
|
+
for (const key in this.headers) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(this.headers, key)) {
|
|
52
|
+
res.setHeader(key, this.headers[key]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return req;
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* This builder option must be used if the Hook Plugin requires PostGraphileOptions in the logic.
|
|
62
|
+
* A function which returns a PostGraphilePlugin should be passed into this method.
|
|
63
|
+
* That function will use PostGraphileOptions created in the build() method and attach the plugin returned from the function as a Postgraphile Hook.
|
|
64
|
+
* @example
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
new PostgraphileOptionsBuilder()
|
|
68
|
+
.addHookPluginFactory(customHookFactory)
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @param hookFunction This is a function which takes an argument of type PostGraphileOptions<Request, Response> and returns a PostGraphilePlugin object.
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
addHookPluginFactory(hookFunction) {
|
|
75
|
+
this.hookFuncs.add(hookFunction);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* This function takes a PostGraphilePlugin object and attaches it as a Postgraphile Hook when build() is called.
|
|
80
|
+
* @example
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
new PostgraphileOptionsBuilder()
|
|
84
|
+
.addHookPluginFunction(subscriptionAuthorizationHook)
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param hookPlugin This is a PostGraphilePlugin object.
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
addHookPlugin(hookPlugin) {
|
|
91
|
+
this.pluginHooks.add(hookPlugin);
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sets `pgSettings` property of postgraphile options object.
|
|
96
|
+
* Example:
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
new PostgraphileOptionsBuilder()
|
|
100
|
+
.setPgSettings(async req => {
|
|
101
|
+
const { subject } = await getManagementAuthenticationContext(req, idServiceParams);
|
|
102
|
+
return buildPgSettings(subject, config.dbGqlRole, config.serviceId);
|
|
103
|
+
})
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @param pgSettings A plain object specifying custom config values to set in the PostgreSQL transaction (accessed via current_setting('my.custom.setting')) or an (optionally asynchronous) function which will return the same (or a Promise to the same) based on the incoming web request (e.g. to extract session data).
|
|
107
|
+
*/
|
|
108
|
+
setPgSettings(pgSettings) {
|
|
109
|
+
this.transformers.push((options) => {
|
|
110
|
+
options.pgSettings = pgSettings;
|
|
111
|
+
return options;
|
|
112
|
+
});
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sets `handleErrors` property of postgraphile options object.
|
|
117
|
+
* Example:
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
new PostgraphileOptionsBuilder()
|
|
121
|
+
.setErrorsHandler((errors, req) => {
|
|
122
|
+
return enhanceGraphqlErrors(
|
|
123
|
+
result.errors,
|
|
124
|
+
req.body?.operationName,
|
|
125
|
+
customizeGraphQlErrorFields(defaultPgErrorMapper),
|
|
126
|
+
logGraphQlError(defaultWriteLogMapper, req.authContext?.subject, this.logger),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @param handleErrors Enables ability to modify errors before sending them down to the client. Optionally can send down custom responses. If you use this then showErrorStack and extendedError may have no effect.
|
|
133
|
+
*/
|
|
134
|
+
setErrorsHandler(handleErrors) {
|
|
135
|
+
this.transformers.push((options) => {
|
|
136
|
+
options.handleErrors = handleErrors;
|
|
137
|
+
return options;
|
|
138
|
+
});
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Sets properties of postgraphile options object to be used in without any conditions. Additional calls will override and add properties.
|
|
143
|
+
* Example:
|
|
144
|
+
*
|
|
145
|
+
* ```ts
|
|
146
|
+
new PostgraphileOptionsBuilder()
|
|
147
|
+
.setProperties({
|
|
148
|
+
enableCors: true,
|
|
149
|
+
dynamicJson: true,
|
|
150
|
+
ignoreRBAC: false,
|
|
151
|
+
legacyRelations: 'omit',
|
|
152
|
+
setofFunctionsContainNulls: false,
|
|
153
|
+
})
|
|
154
|
+
* ```
|
|
155
|
+
* @param properties An object containing postgraphile options.
|
|
156
|
+
*/
|
|
157
|
+
setProperties(properties) {
|
|
158
|
+
this.transformers.push((options) => {
|
|
159
|
+
return { ...options, ...properties };
|
|
160
|
+
});
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Sets properties of postgraphile options object to be used based on some
|
|
165
|
+
* condition (use if true, omit if false). Additional calls will override and
|
|
166
|
+
* add properties.
|
|
167
|
+
* Example:
|
|
168
|
+
*
|
|
169
|
+
* ```ts
|
|
170
|
+
new PostgraphileOptionsBuilder()
|
|
171
|
+
.setConditionalProperties(config.isDev, {
|
|
172
|
+
exportGqlSchemaPath: './src/generated/schema.graphql',
|
|
173
|
+
watchPg: true,
|
|
174
|
+
graphiql: true,
|
|
175
|
+
enhanceGraphiql: true,
|
|
176
|
+
allowExplain: true,
|
|
177
|
+
})
|
|
178
|
+
* ```
|
|
179
|
+
* @param properties An object containing postgraphile options.
|
|
180
|
+
*/
|
|
181
|
+
setConditionalProperties(condition, properties) {
|
|
182
|
+
if (condition) {
|
|
183
|
+
this.transformers.push((options) => {
|
|
184
|
+
return { ...options, ...properties };
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Sets all necessary postgraphile properties to enable subscriptions.
|
|
191
|
+
* Example:
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
new PostgraphileOptionsBuilder()
|
|
195
|
+
.enableSubscriptions({
|
|
196
|
+
plugin: SubscriptionsPlugin,
|
|
197
|
+
websocketMiddlewares: middlewares,
|
|
198
|
+
hookFactory: subscriptionAuthorizationHookFactory
|
|
199
|
+
})
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* Results in something like this:
|
|
203
|
+
*
|
|
204
|
+
* ```ts
|
|
205
|
+
import PgPubsub from '@graphile/pg-pubsub';
|
|
206
|
+
import { makePluginHook } from 'postgraphile';
|
|
207
|
+
//.........
|
|
208
|
+
{
|
|
209
|
+
appendPlugins: [SubscriptionsPlugin], // Other plugins will be included if they were added using other methods
|
|
210
|
+
pluginHook: makePluginHook([PgPubsub, subscriptionAuthorizationHook]),
|
|
211
|
+
subscriptions: true,
|
|
212
|
+
websocketMiddlewares, // Empty array if websocketMiddlewares are not specified
|
|
213
|
+
subscriptionEventEmitterMaxListeners: 0, // unlimited
|
|
214
|
+
}
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* To make sure that Postgraphile is able to correctly establish WebSockets
|
|
218
|
+
* connection, additional changes should be done by using
|
|
219
|
+
* `enhanceHttpServerWithSubscriptions`.
|
|
220
|
+
*
|
|
221
|
+
* See more here: https://www.graphile.org/postgraphile/subscriptions/#advanced-setup
|
|
222
|
+
*
|
|
223
|
+
* To customize the maximum number of listeners use:
|
|
224
|
+
*
|
|
225
|
+
* ```ts
|
|
226
|
+
* import PgPubsub from '@graphile/pg-pubsub'; // must be imported to extend the PostGraphileOptions type with the pg-pubsub options.
|
|
227
|
+
* ...
|
|
228
|
+
* new PostgraphileOptionsBuilder()
|
|
229
|
+
* .setProperties({
|
|
230
|
+
* subscriptionEventEmitterMaxListeners: 42,
|
|
231
|
+
* })
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @param plugin Graphile engine plugin that adds one or multiple subscription
|
|
235
|
+
* endpoints. Can be added separately.
|
|
236
|
+
* @param websocketMiddlewares If you're using websockets (subscriptions ||
|
|
237
|
+
* live) then you may want to authenticate your users using sessions or
|
|
238
|
+
* similar. You can pass some simple middlewares here that will be executed
|
|
239
|
+
* against the websocket connection in order to perform authentication.
|
|
240
|
+
* @param hookFactory A factory function for a Postgraphile hook plugin.
|
|
241
|
+
*/
|
|
242
|
+
enableSubscriptions({ plugin, websocketMiddlewares, hookFactory, }) {
|
|
243
|
+
this.transformers.push((options) => {
|
|
244
|
+
options.subscriptions = true;
|
|
245
|
+
options.appendPlugins = [
|
|
246
|
+
...new Set([...(options.appendPlugins ?? []), plugin]),
|
|
247
|
+
];
|
|
248
|
+
options.subscriptionEventEmitterMaxListeners = 0;
|
|
249
|
+
// Add the pub/sub realtime provider
|
|
250
|
+
// This is for PostGraphile server plugins: https://www.graphile.org/postgraphile/plugins/
|
|
251
|
+
this.pluginHooks.add(PgPubsub);
|
|
252
|
+
if (websocketMiddlewares) {
|
|
253
|
+
options.websocketMiddlewares = [
|
|
254
|
+
...new Set([
|
|
255
|
+
...(options.websocketMiddlewares ?? []),
|
|
256
|
+
...websocketMiddlewares,
|
|
257
|
+
]),
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
else if (!options.websocketMiddlewares) {
|
|
261
|
+
options.websocketMiddlewares = [];
|
|
262
|
+
}
|
|
263
|
+
if (hookFactory) {
|
|
264
|
+
this.hookFuncs.add(hookFactory);
|
|
265
|
+
}
|
|
266
|
+
return options;
|
|
267
|
+
});
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Adds multiple graphile engine plugins to `appendPlugins` array of postgraphile options object. `setAdditionalGraphQLContextFromRequest` and `addGraphileBuildOptions` methods can be used to pass parameters to said plugins.
|
|
272
|
+
* Example:
|
|
273
|
+
*
|
|
274
|
+
```ts
|
|
275
|
+
new PostgraphileOptionsBuilder()
|
|
276
|
+
.addPlugins(
|
|
277
|
+
PgSimplifyInflectorPlugin,
|
|
278
|
+
ScalarTypesPlugin,
|
|
279
|
+
SmartTagsPlugin,
|
|
280
|
+
ValidationDirectivesPlugin,
|
|
281
|
+
)
|
|
282
|
+
```
|
|
283
|
+
* @param plugins Comma-separated list of Graphile Engine schema plugins to load after the default plugins.
|
|
284
|
+
*/
|
|
285
|
+
addPlugins(...plugins) {
|
|
286
|
+
this.transformers.push((options) => {
|
|
287
|
+
options.appendPlugins = [
|
|
288
|
+
...new Set([...(options.appendPlugins ?? []), ...plugins]),
|
|
289
|
+
];
|
|
290
|
+
return options;
|
|
291
|
+
});
|
|
292
|
+
return this;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Adds multiple graphile engine plugins to `appendPlugins` array of postgraphile options object.
|
|
296
|
+
* `setAdditionalGraphQLContextFromRequest` and `addGraphileBuildOptions` methods can be used to pass parameters to said plugins.
|
|
297
|
+
* Explicit condition parameter is used to make a decision if plugins should be used or not (use if true, omit if false).
|
|
298
|
+
* Example:
|
|
299
|
+
*
|
|
300
|
+
```ts
|
|
301
|
+
new PostgraphileOptionsBuilder()
|
|
302
|
+
.addConditionalPlugins(config.isDev || config.enablePopulatePlugins, PopulateMoviesPlugin, PopulateTvshowsPlugin)
|
|
303
|
+
```
|
|
304
|
+
* @param plugins Comma-separated list of Graphile Engine schema plugins to load after the default plugins.
|
|
305
|
+
*/
|
|
306
|
+
addConditionalPlugins(condition, ...plugins) {
|
|
307
|
+
if (condition) {
|
|
308
|
+
this.addPlugins(...plugins);
|
|
309
|
+
}
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Skips multiple default postgraphile plugins by adding them to `skipPlugins` array of postgraphile options object .
|
|
314
|
+
* Example:
|
|
315
|
+
*
|
|
316
|
+
```ts
|
|
317
|
+
new PostgraphileOptionsBuilder()
|
|
318
|
+
.skipPlugins(NodePlugin, MutationPayloadQueryPlugin)
|
|
319
|
+
```
|
|
320
|
+
* @param plugins Comma-separated list of Graphile Engine schema plugins to skip.
|
|
321
|
+
*/
|
|
322
|
+
skipPlugins(...plugins) {
|
|
323
|
+
this.transformers.push((options) => {
|
|
324
|
+
options.skipPlugins = [
|
|
325
|
+
...new Set([...(options.skipPlugins ?? []), ...plugins]),
|
|
326
|
+
];
|
|
327
|
+
return options;
|
|
328
|
+
});
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Adds properties to resulting `graphileBuildOptions` property of postgraphile options object. Useful for modifying default postgraphile plugin settings.
|
|
333
|
+
* Example:
|
|
334
|
+
*
|
|
335
|
+
```ts
|
|
336
|
+
new PostgraphileOptionsBuilder()
|
|
337
|
+
.addGraphileBuildOptions({ pgSkipInstallingWatchFixtures: true })
|
|
338
|
+
```
|
|
339
|
+
* @param graphileBuildOptions Additional Options to pass through into the graphile schema building system (received via the second argument of a plugin).
|
|
340
|
+
*/
|
|
341
|
+
addGraphileBuildOptions(graphileBuildOptions) {
|
|
342
|
+
this.transformers.push((options) => {
|
|
343
|
+
options.graphileBuildOptions = {
|
|
344
|
+
...(options.graphileBuildOptions ?? {}),
|
|
345
|
+
...graphileBuildOptions,
|
|
346
|
+
};
|
|
347
|
+
return options;
|
|
348
|
+
});
|
|
349
|
+
return this;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Adds `additionalGraphQLContextFromRequest` property to postgraphile options object. Define only once. Multiple calls will not expand previous calls, but will override them.
|
|
353
|
+
*
|
|
354
|
+
* Example:
|
|
355
|
+
```ts
|
|
356
|
+
new PostgraphileOptionsBuilder()
|
|
357
|
+
.setAdditionalGraphQLContextFromRequest(async req => {
|
|
358
|
+
const { subject } = await getManagementAuthenticationContext(req);
|
|
359
|
+
return { subject, serviceId: config.serviceId };
|
|
360
|
+
})
|
|
361
|
+
```
|
|
362
|
+
* @param callback Some Graphile Engine schema plugins may need additional information available on the context argument to the resolver - you can use this function to provide such information based on the incoming request - you can even use this to change the response , e.g. setting cookies.
|
|
363
|
+
*/
|
|
364
|
+
setAdditionalGraphQLContextFromRequest(callback) {
|
|
365
|
+
this.transformers.push((options) => {
|
|
366
|
+
options.additionalGraphQLContextFromRequest = callback;
|
|
367
|
+
return options;
|
|
368
|
+
});
|
|
369
|
+
return this;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Enables or disables graphiql GUI depending on a passed condition parameter. Enable if true, disable if false.
|
|
373
|
+
* Sets 3 postgraphile properties: `graphiql`, `enhanceGraphiql` and `allowExplain`.
|
|
374
|
+
* Example:
|
|
375
|
+
*
|
|
376
|
+
* ```ts
|
|
377
|
+
new PostgraphileOptionsBuilder()
|
|
378
|
+
.setGraphiql(config.graphqlGuiEnabled)
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
setGraphiql(condition) {
|
|
382
|
+
this.transformers.push((options) => {
|
|
383
|
+
return {
|
|
384
|
+
...options,
|
|
385
|
+
...{
|
|
386
|
+
graphiql: condition,
|
|
387
|
+
enhanceGraphiql: condition,
|
|
388
|
+
allowExplain: condition,
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
});
|
|
392
|
+
return this;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Sets a response header for each GraphQL request.
|
|
396
|
+
*
|
|
397
|
+
* @param name header name
|
|
398
|
+
* @param value header value
|
|
399
|
+
*/
|
|
400
|
+
setHeader(name, value) {
|
|
401
|
+
this.headers[name] = value;
|
|
402
|
+
return this;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Sets default values for properties that we see as best practices which most
|
|
406
|
+
* services should start from. This includes the default GraphQL errors handler,
|
|
407
|
+
* suggested default properties, development properties in dev-environments,
|
|
408
|
+
* and excludes the 'NodePlugin'.
|
|
409
|
+
*/
|
|
410
|
+
setDefaultSettings(isDev, graphqlGuiEnabled) {
|
|
411
|
+
this.setErrorsHandler((errors) => {
|
|
412
|
+
return enhanceGraphqlErrors(errors);
|
|
413
|
+
})
|
|
414
|
+
.setProperties({
|
|
415
|
+
enableCors: true,
|
|
416
|
+
dynamicJson: true,
|
|
417
|
+
ignoreRBAC: false,
|
|
418
|
+
legacyRelations: 'omit',
|
|
419
|
+
setofFunctionsContainNulls: false,
|
|
420
|
+
watchPg: false,
|
|
421
|
+
disableQueryLog: true,
|
|
422
|
+
retryOnInitFail: true,
|
|
423
|
+
})
|
|
424
|
+
.setConditionalProperties(isDev, {
|
|
425
|
+
exportGqlSchemaPath: './src/generated/graphql/schema.graphql',
|
|
426
|
+
watchPg: true,
|
|
427
|
+
disableQueryLog: false,
|
|
428
|
+
retryOnInitFail: false,
|
|
429
|
+
})
|
|
430
|
+
.setGraphiql(graphqlGuiEnabled)
|
|
431
|
+
// removes some nodeId and byNodeId endpoints, but still leaves support for cursor pagination
|
|
432
|
+
.skipPlugins(NodePlugin);
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
//# sourceMappingURL=postgraphile-options-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgraphile-options-builder.js","sourceRoot":"","sources":["../../../src/postgraphile/postgraphile-options-builder.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAe,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EACL,cAAc,GAOf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,sEAAsE;AACtE,kEAAkE;AAClE,6EAA6E;AAC7E,2EAA2E;AAC3E,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,kEAAkE;AAClE,MAAM,QAAQ,GAAG,CAAE,SAAiB,CAAC,OAAO,IAAI,SAAS,CAAqB,CAAC;AAoB/E;;GAEG;AACH,MAAM,OAAO,0BAA0B;IAC7B,YAAY,GAE6B,EAAE,CAAC;IAE5C,OAAO,GAAqC,EAAE,CAAC;IAC/C,WAAW,GAA4B,IAAI,GAAG,EAAsB,CAAC;IACrE,SAAS,GAA2B,IAAI,GAAG,EAAqB,CAAC;IAEzE;;OAEG;IACI,KAAK;QACV,IAAI,OAAO,GAA2C,EAAE,CAAC;QACzD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC1C,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAE9B,yCAAyC;QACzC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,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,SAAS;iBACxB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,SAAS,CACd,IAAY,EACZ,KAAiC;QAEjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,kBAAkB,CACvB,KAAc,EACd,iBAA0B;QAE1B,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/B,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC,CAAC;aACC,aAAa,CAAC;YACb,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,eAAe,EAAE,MAAM;YACvB,0BAA0B,EAAE,KAAK;YAEjC,OAAO,EAAE,KAAK;YACd,eAAe,EAAE,IAAI;YACrB,eAAe,EAAE,IAAI;SACtB,CAAC;aACD,wBAAwB,CAAC,KAAK,EAAE;YAC/B,mBAAmB,EAAE,wCAAwC;YAC7D,OAAO,EAAE,IAAI;YACb,eAAe,EAAE,KAAK;YACtB,eAAe,EAAE,KAAK;SACvB,CAAC;aACD,WAAW,CAAC,iBAAiB,CAAC;YAC/B,6FAA6F;aAC5F,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
import type { WebSocket } from 'graphql-ws';
|
|
3
|
+
/**
|
|
4
|
+
* Extract the reference to web socket when given a request object that is coming
|
|
5
|
+
* from Postgraphile. The web socket reference is attached as a symbol.
|
|
6
|
+
*
|
|
7
|
+
* @param req A Postgraphile request.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const getWebsocketFromRequest: (req: Request) => WebSocket | undefined;
|
|
11
|
+
//# sourceMappingURL=websocket-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-utils.d.ts","sourceRoot":"","sources":["../../../src/postgraphile/websocket-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,OAAO,KACX,SAAS,GAAG,SAMd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the reference to web socket when given a request object that is coming
|
|
3
|
+
* from Postgraphile. The web socket reference is attached as a symbol.
|
|
4
|
+
*
|
|
5
|
+
* @param req A Postgraphile request.
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export const getWebsocketFromRequest = (req) => {
|
|
9
|
+
const websocketSymbol = Object.getOwnPropertySymbols(req.socket).filter((sym) => sym.description === 'websocket')[0];
|
|
10
|
+
const websocket = req.socket[websocketSymbol];
|
|
11
|
+
return websocket;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=websocket-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-utils.js","sourceRoot":"","sources":["../../../src/postgraphile/websocket-utils.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,GAAY,EACW,EAAE;IACzB,MAAM,eAAe,GAAG,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CACrE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,KAAK,WAAW,CACzC,CAAC,CAAC,CAAC,CAAC;IACL,MAAM,SAAS,GAAI,GAAW,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACvD,OAAO,SAAsB,CAAC;AAChC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-graphql-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0-rc.3",
|
|
4
4
|
"description": "Common GraphQL and PostGraphile related functionality.",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -13,31 +13,41 @@
|
|
|
13
13
|
"dist",
|
|
14
14
|
"src"
|
|
15
15
|
],
|
|
16
|
-
"main": "dist/index.js",
|
|
17
|
-
"
|
|
16
|
+
"main": "dist/cjs/index.js",
|
|
17
|
+
"module": "dist/esm/index.js",
|
|
18
|
+
"types": "dist/cjs/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/cjs/index.d.ts",
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
18
27
|
"scripts": {
|
|
19
28
|
"clean": "rimraf dist",
|
|
20
|
-
"build": "yarn clean && tsc --project tsconfig.build.json",
|
|
21
|
-
"ts:validate": "tsc",
|
|
29
|
+
"build": "yarn clean && tsc --project tsconfig.build.json && tsc --project tsconfig.build.esm.json && node ../../scripts/write-esm-markers.js",
|
|
30
|
+
"ts:validate": "tsc && yarn build && yarn check:esm-interop",
|
|
22
31
|
"build:ci": "yarn workspaces focus && yarn build",
|
|
23
32
|
"dev": "tsc -w --project tsconfig.build.json",
|
|
24
33
|
"publish:latest": "npm run build && npm publish",
|
|
25
34
|
"test": "vitest run --silent",
|
|
26
35
|
"test:watch": "vitest watch",
|
|
27
36
|
"test:cov": "vitest run --coverage --silent && yarn posttest:cov",
|
|
28
|
-
"posttest:cov": "
|
|
37
|
+
"posttest:cov": "tsx ../../scripts/open-test-coverage.ts -- libs/graphql-common",
|
|
38
|
+
"check:esm-interop": "node ./scripts/check-esm-interop.mjs",
|
|
29
39
|
"test:debug": "vitest run --inspect-brk --no-file-parallelism",
|
|
30
40
|
"test:ci": "vitest run --reporter=default --reporter=junit --coverage --coverage.reporter=cobertura --coverage.reporter=html",
|
|
31
41
|
"test:ui": "vitest --ui",
|
|
32
42
|
"lint": "eslint . --ext .ts,.tsx,.js --color --cache"
|
|
33
43
|
},
|
|
34
44
|
"dependencies": {
|
|
35
|
-
"@axinom/mosaic-db-common": "^0.
|
|
36
|
-
"@axinom/mosaic-message-bus": "^0.
|
|
37
|
-
"@axinom/mosaic-message-bus-abstractions": "^0.24.3",
|
|
38
|
-
"@axinom/mosaic-messages": "^0.
|
|
39
|
-
"@axinom/mosaic-service-common": "^0.
|
|
40
|
-
"@axinom/mosaic-transactional-inbox-outbox": "^0.
|
|
45
|
+
"@axinom/mosaic-db-common": "^0.58.0-rc.3",
|
|
46
|
+
"@axinom/mosaic-message-bus": "^0.51.0-rc.3",
|
|
47
|
+
"@axinom/mosaic-message-bus-abstractions": "^0.24.4-rc.3",
|
|
48
|
+
"@axinom/mosaic-messages": "^0.68.0-rc.3",
|
|
49
|
+
"@axinom/mosaic-service-common": "^0.70.0-rc.3",
|
|
50
|
+
"@axinom/mosaic-transactional-inbox-outbox": "^0.30.0-rc.3",
|
|
41
51
|
"@graphile/pg-pubsub": "^4.12.3",
|
|
42
52
|
"endent": "^2.1.0",
|
|
43
53
|
"express": "^4.17.1",
|
|
@@ -51,7 +61,7 @@
|
|
|
51
61
|
"postgraphile": "^4.13.0"
|
|
52
62
|
},
|
|
53
63
|
"devDependencies": {
|
|
54
|
-
"@axinom/mosaic-dev-be-common": "^0.
|
|
64
|
+
"@axinom/mosaic-dev-be-common": "^0.19.0-rc.3",
|
|
55
65
|
"@types/express": "^4.17.17",
|
|
56
66
|
"@types/inflection": "^1.5.28",
|
|
57
67
|
"@types/node": "^22.0.0",
|
|
@@ -59,12 +69,11 @@
|
|
|
59
69
|
"eslint": "^8.35.0",
|
|
60
70
|
"jest-extended": "^7.0.0",
|
|
61
71
|
"rimraf": "^3.0.2",
|
|
62
|
-
"ts-node": "^10.9.1",
|
|
63
72
|
"typescript": "^5.9.3",
|
|
64
73
|
"vitest": "^4.0.18"
|
|
65
74
|
},
|
|
66
75
|
"publishConfig": {
|
|
67
76
|
"access": "public"
|
|
68
77
|
},
|
|
69
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "9c7831acd6fcced9a09f97ffd4c9d67ee1b3b640"
|
|
70
79
|
}
|
package/src/common/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './checks';
|
|
2
|
-
export * from './types';
|
|
1
|
+
export * from './checks.js';
|
|
2
|
+
export * from './types.js';
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './middleware';
|
|
3
|
-
export * from './plugins';
|
|
4
|
-
export * from './postgraphile';
|
|
1
|
+
export * from './common/index.js';
|
|
2
|
+
export * from './middleware/index.js';
|
|
3
|
+
export * from './plugins/index.js';
|
|
4
|
+
export * from './postgraphile/index.js';
|
package/src/middleware/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './forward-to-graphiql';
|
|
1
|
+
export * from './forward-to-graphiql.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLEnumType } from 'graphql';
|
|
2
|
-
import { Plugin } from 'postgraphile';
|
|
3
|
-
import { Dict } from '../common';
|
|
2
|
+
import type { Plugin } from 'postgraphile';
|
|
3
|
+
import type { Dict } from '../common/index.js';
|
|
4
4
|
|
|
5
5
|
type GraphQLEnumValues = Dict<{ value: string; description: string }>;
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { exportedForTestingAnnotatePlugin } from './annotate-types-with-permissions-plugin';
|
|
2
|
+
import { exportedForTestingAnnotatePlugin } from './annotate-types-with-permissions-plugin.js';
|
|
3
3
|
const getPolicy = (
|
|
4
4
|
overrides: {
|
|
5
5
|
permissive?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Pool } from 'pg';
|
|
2
|
-
import { Plugin } from 'postgraphile';
|
|
3
|
-
import { isNullOrWhitespace } from '../common';
|
|
1
|
+
import type { Pool } from 'pg';
|
|
2
|
+
import type { Plugin } from 'postgraphile';
|
|
3
|
+
import { isNullOrWhitespace } from '../common/index.js';
|
|
4
4
|
|
|
5
5
|
interface PolicyRow {
|
|
6
6
|
schemaname: string;
|
|
@@ -21,10 +21,10 @@ vi.mock('@axinom/mosaic-db-common', async () => {
|
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
import { PerformItemChangeCommand } from '@axinom/mosaic-messages';
|
|
25
|
-
import { StoreInboxMessage } from '@axinom/mosaic-transactional-inbox-outbox';
|
|
26
|
-
import { DatabaseClient } from 'pg-transactional-outbox';
|
|
27
|
-
import { asyncResolverImplementation } from './bulk-edit-async-plugin-factory';
|
|
24
|
+
import type { PerformItemChangeCommand } from '@axinom/mosaic-messages';
|
|
25
|
+
import type { StoreInboxMessage } from '@axinom/mosaic-transactional-inbox-outbox';
|
|
26
|
+
import type { DatabaseClient } from 'pg-transactional-outbox';
|
|
27
|
+
import { asyncResolverImplementation } from './bulk-edit-async-plugin-factory.js';
|
|
28
28
|
|
|
29
29
|
describe('bulk-edit-async-plugin-factory', () => {
|
|
30
30
|
describe('asyncResolverImplementation', () => {
|