@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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a variable is a string index based object
|
|
3
|
+
* @param value variable to check
|
|
4
|
+
*/
|
|
5
|
+
// must be a real function: https://github.com/microsoft/TypeScript/issues/36931
|
|
6
|
+
export function assertDictionary(value) {
|
|
7
|
+
if (typeof value !== 'object' || value === null) {
|
|
8
|
+
throw Error('The value is no string indexed object.');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const isNullOrWhitespace = (value) => {
|
|
12
|
+
return (value === null ||
|
|
13
|
+
value === undefined ||
|
|
14
|
+
(typeof value === 'string' && value.trim().length === 0));
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../src/common/checks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAC9B,KAAc;IAGd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAA2B,EACA,EAAE;IAC7B,OAAO,CACL,KAAK,KAAK,IAAI;QACd,KAAK,KAAK,SAAS;QACnB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** TYpe definition of an object with field accessor. */
|
|
2
|
+
export interface Dict<T> {
|
|
3
|
+
[key: string]: T;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Error to be thrown in a default block of an exhaustive switch-case block, if checked value has a finite amount of possible values (e.g enum).
|
|
7
|
+
* This error has a very low chance to actually be thrown.
|
|
8
|
+
* Instead, it is used by IDE to give an indication of which possible value is not covered by switch-case and will result in a failed build.
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnreachableCaseError extends Error {
|
|
11
|
+
constructor(val: never);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,GAAG,EAAE,KAAK;CAGvB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error to be thrown in a default block of an exhaustive switch-case block, if checked value has a finite amount of possible values (e.g enum).
|
|
3
|
+
* This error has a very low chance to actually be thrown.
|
|
4
|
+
* Instead, it is used by IDE to give an indication of which possible value is not covered by switch-case and will result in a failed build.
|
|
5
|
+
*/
|
|
6
|
+
export class UnreachableCaseError extends Error {
|
|
7
|
+
constructor(val) {
|
|
8
|
+
super(`Unreachable case: ${val}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,GAAU;QACpB,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NextFunction, Request, Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Middleware that forwards requests that accept html to graphiql.
|
|
4
|
+
* @param graphQLUrl The url to forward from. (default: '/graphql')
|
|
5
|
+
* @param graphiQLUrl The url to forward to. (default: '/graphiql')
|
|
6
|
+
*/
|
|
7
|
+
export declare const forwardToGraphiQl: (graphQLUrl?: string, graphiQLUrl?: string) => (req: Request, res: Response, next: NextFunction) => void;
|
|
8
|
+
//# sourceMappingURL=forward-to-graphiql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward-to-graphiql.d.ts","sourceRoot":"","sources":["../../../src/middleware/forward-to-graphiql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC3B,mBAAuB,EAAE,oBAAyB,MAClD,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IAYlD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware that forwards requests that accept html to graphiql.
|
|
3
|
+
* @param graphQLUrl The url to forward from. (default: '/graphql')
|
|
4
|
+
* @param graphiQLUrl The url to forward to. (default: '/graphiql')
|
|
5
|
+
*/
|
|
6
|
+
export const forwardToGraphiQl = (graphQLUrl = '/graphql', graphiQLUrl = '/graphiql') => (req, res, next) => {
|
|
7
|
+
if (req.accepts('html') &&
|
|
8
|
+
// Get requests to / that accept html
|
|
9
|
+
((req.path === '/' && req.method === 'GET' && req.accepts('html')) ||
|
|
10
|
+
// Get requests to /graphql that accept html and do not have a query
|
|
11
|
+
(req.path === graphQLUrl && req.method === 'GET' && !req.query.query))) {
|
|
12
|
+
// forward to graphiql
|
|
13
|
+
return res.redirect(graphiQLUrl);
|
|
14
|
+
}
|
|
15
|
+
return next();
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=forward-to-graphiql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward-to-graphiql.js","sourceRoot":"","sources":["../../../src/middleware/forward-to-graphiql.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,CAAC,UAAU,GAAG,UAAU,EAAE,WAAW,GAAG,WAAW,EAAE,EAAE,CACvD,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;IACxD,IACE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;QACnB,qCAAqC;QACrC,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAChE,oEAAoE;YACpE,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACxE,CAAC;QACD,sBAAsB;QACtB,OAAO,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Plugin } from 'postgraphile';
|
|
2
|
+
import type { Dict } from '../common/index.js';
|
|
3
|
+
export interface MosaicErrorDefinition {
|
|
4
|
+
message: string;
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Adds a detached enum type to the GraphQL schema, listing all possible
|
|
9
|
+
* ErrorCode values and adding messages as a descriptions.
|
|
10
|
+
*
|
|
11
|
+
* Make sure to add it after `EnforceStrictPermissionsPlugin` or any other
|
|
12
|
+
* plugin that might filter queries out of the resulting schema.
|
|
13
|
+
*
|
|
14
|
+
* If there is a need to adjust this enum - use `GraphQLEnumType` postgraphile
|
|
15
|
+
* hook and `isErrorCodesEnum` scope to find the generated enum. E.g.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
builder.hook('GraphQLEnumType', (enumField, _build, context) => {
|
|
19
|
+
if (context.scope.isErrorCodesEnum === true) {
|
|
20
|
+
// Modification logic
|
|
21
|
+
}
|
|
22
|
+
return enumField;
|
|
23
|
+
});
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const AddErrorCodesEnumPluginFactory: (errorCodeEnums: Dict<MosaicErrorDefinition>[]) => Plugin;
|
|
27
|
+
//# sourceMappingURL=add-error-codes-enum-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-error-codes-enum-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/add-error-codes-enum-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AA+BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,8BAA8B,EAAE,CAC3C,cAAc,EAAE,IAAI,CAAC,qBAAqB,CAAC,EAAE,KAC1C,MAwCJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GraphQLEnumType } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Maps an array of error code enum objects to a single object, forming a
|
|
4
|
+
* unified ErrorCodes GraphQL Enum.
|
|
5
|
+
*/
|
|
6
|
+
const mapEnumValues = (errorCodeEnums) => {
|
|
7
|
+
const values = {};
|
|
8
|
+
for (const errorCodeEnum of errorCodeEnums) {
|
|
9
|
+
for (const key in errorCodeEnum) {
|
|
10
|
+
if (Object.prototype.hasOwnProperty.call(errorCodeEnum, key)) {
|
|
11
|
+
const element = errorCodeEnum[key];
|
|
12
|
+
if (values[element.code]) {
|
|
13
|
+
throw new Error(`Error code '${element.code}' is used in multiple enum objects. Error codes must be unique.`);
|
|
14
|
+
}
|
|
15
|
+
values[element.code] = {
|
|
16
|
+
value: element.code,
|
|
17
|
+
description: element.message,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return values;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Adds a detached enum type to the GraphQL schema, listing all possible
|
|
26
|
+
* ErrorCode values and adding messages as a descriptions.
|
|
27
|
+
*
|
|
28
|
+
* Make sure to add it after `EnforceStrictPermissionsPlugin` or any other
|
|
29
|
+
* plugin that might filter queries out of the resulting schema.
|
|
30
|
+
*
|
|
31
|
+
* If there is a need to adjust this enum - use `GraphQLEnumType` postgraphile
|
|
32
|
+
* hook and `isErrorCodesEnum` scope to find the generated enum. E.g.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
builder.hook('GraphQLEnumType', (enumField, _build, context) => {
|
|
36
|
+
if (context.scope.isErrorCodesEnum === true) {
|
|
37
|
+
// Modification logic
|
|
38
|
+
}
|
|
39
|
+
return enumField;
|
|
40
|
+
});
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export const AddErrorCodesEnumPluginFactory = (errorCodeEnums) => (builder) => {
|
|
44
|
+
const dummyQueryName = '_dummyErrorCodesEnum';
|
|
45
|
+
// Attaches the enum type and a dummy query endpoint to the schema.
|
|
46
|
+
// Postgraphile removes all unused types, so we are first adding a dummy
|
|
47
|
+
// query endpoint (to emulate enum usage), and during the `finalize` phase -
|
|
48
|
+
// we delete it, so that the cleanup would not remove the enum type itself.
|
|
49
|
+
builder.hook('GraphQLObjectType:fields', (fields, { extend, newWithHooks }, { scope: { isRootQuery } }) => {
|
|
50
|
+
if (!isRootQuery) {
|
|
51
|
+
return fields;
|
|
52
|
+
}
|
|
53
|
+
const values = mapEnumValues(errorCodeEnums);
|
|
54
|
+
const enumType = newWithHooks(GraphQLEnumType, {
|
|
55
|
+
name: 'ErrorCodesEnum',
|
|
56
|
+
description: `Exposes all error codes and messages for errors that a service requests can throw. In some cases, messages that are actually thrown can be different, since they can include more details or a single code can used for different errors of the same type.`,
|
|
57
|
+
values,
|
|
58
|
+
}, { isErrorCodesEnum: true });
|
|
59
|
+
return extend(fields, {
|
|
60
|
+
[dummyQueryName]: {
|
|
61
|
+
type: enumType,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
// Removing the dummy type from schema, leaving only the enum type.
|
|
66
|
+
builder.hook('finalize', (schema) => {
|
|
67
|
+
const query = schema.getQueryType();
|
|
68
|
+
if (query) {
|
|
69
|
+
delete query.getFields()[dummyQueryName];
|
|
70
|
+
}
|
|
71
|
+
return schema;
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=add-error-codes-enum-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-error-codes-enum-plugin.js","sourceRoot":"","sources":["../../../src/plugins/add-error-codes-enum-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAW1C;;;GAGG;AACH,MAAM,aAAa,GAAG,CACpB,cAA6C,EAC1B,EAAE;IACrB,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;YAChC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC;gBAC7D,MAAM,OAAO,GAAG,aA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AAC,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Plugin } from 'postgraphile';
|
|
2
|
+
interface PolicyRow {
|
|
3
|
+
schemaname: string;
|
|
4
|
+
tablename: string;
|
|
5
|
+
permissive: 'PERMISSIVE' | 'RESTRICTIVE';
|
|
6
|
+
command: string;
|
|
7
|
+
using: string | null;
|
|
8
|
+
withcheck: string | null;
|
|
9
|
+
}
|
|
10
|
+
type SqlOperation = 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE';
|
|
11
|
+
declare function setPermissionsCommentText(currentDescription: string | null | undefined, policies: PolicyRow[], type: SqlOperation): string;
|
|
12
|
+
/**
|
|
13
|
+
* Plugin that adds permissions annotation to graphql schema descriptions.
|
|
14
|
+
*
|
|
15
|
+
* @param graphileBuildOptions should be of type `Partial<Options> & { ownerPool: Pool }`
|
|
16
|
+
*/
|
|
17
|
+
export declare const AnnotateTypesWithPermissionsPlugin: Plugin;
|
|
18
|
+
export declare const exportedForTestingAnnotatePlugin: {
|
|
19
|
+
setPermissionsCommentText: typeof setPermissionsCommentText;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=annotate-types-with-permissions-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate-types-with-permissions-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/annotate-types-with-permissions-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,UAAU,SAAS;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,YAAY,GAAG,aAAa,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,KAAK,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAsD9D,iBAAS,yBAAyB,CAChC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7C,QAAQ,EAAE,SAAS,EAAE,EACrB,IAAI,EAAE,YAAY,GACjB,MAAM,CAeR;AAID;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,MA2GhD,CAAC;AAEF,eAAO,MAAM,gCAAgC;;CAAgC,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { isNullOrWhitespace } from '../common/index.js';
|
|
2
|
+
async function loadPolicies(ownerPool) {
|
|
3
|
+
const client = await ownerPool.connect();
|
|
4
|
+
try {
|
|
5
|
+
// get all policies, sort so "ALL" is last and custom ones come earlier
|
|
6
|
+
const queryResult = await client.query(`
|
|
7
|
+
select
|
|
8
|
+
schemaname,
|
|
9
|
+
tablename,
|
|
10
|
+
permissive,
|
|
11
|
+
cmd as command,
|
|
12
|
+
qual as using,
|
|
13
|
+
with_check as withcheck
|
|
14
|
+
from pg_policies
|
|
15
|
+
order by command desc`);
|
|
16
|
+
return queryResult.rows;
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
client.release();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function parsePermissions(sqlPolicy) {
|
|
23
|
+
const matches = /(ax_utils\.)?user_has_permission\('([^']+)/.exec(sqlPolicy);
|
|
24
|
+
return matches && matches.length > 2 ? matches[2] : '';
|
|
25
|
+
}
|
|
26
|
+
function getPermissions(policies, commands, field) {
|
|
27
|
+
let matchingPolicies = policies.filter((p) => commands.find((cmd) => p.command === cmd) && p[field]);
|
|
28
|
+
// If RESTRICTIVE policies found, list only them and remove PERMISSIVE ones
|
|
29
|
+
if (matchingPolicies.some((policy) => policy.permissive === 'RESTRICTIVE')) {
|
|
30
|
+
matchingPolicies = matchingPolicies.filter((policy) => policy.permissive === 'RESTRICTIVE');
|
|
31
|
+
}
|
|
32
|
+
return [
|
|
33
|
+
...new Set(// removes duplicates
|
|
34
|
+
matchingPolicies
|
|
35
|
+
.map((p) => parsePermissions(p[field]))
|
|
36
|
+
.filter((p) => !isNullOrWhitespace(p))
|
|
37
|
+
.sort()),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
function setPermissionsCommentText(currentDescription, policies, type) {
|
|
41
|
+
const field = type === 'SELECT' || type === 'DELETE' ? 'using' : 'withcheck';
|
|
42
|
+
const permissions = getPermissions(policies, ['ALL', type], field);
|
|
43
|
+
const description = isNullOrWhitespace(currentDescription)
|
|
44
|
+
? ''
|
|
45
|
+
: currentDescription;
|
|
46
|
+
return permissions.length > 0
|
|
47
|
+
? [
|
|
48
|
+
isNullOrWhitespace(description) ? description : `${description}\n`,
|
|
49
|
+
...permissions
|
|
50
|
+
.map((permission) => `@permissions: ${permission}`)
|
|
51
|
+
.join('\n'),
|
|
52
|
+
].join('')
|
|
53
|
+
: description;
|
|
54
|
+
}
|
|
55
|
+
// all available hooks are defined here:
|
|
56
|
+
// https://www.graphile.org/graphile-build/all-hooks/
|
|
57
|
+
/**
|
|
58
|
+
* Plugin that adds permissions annotation to graphql schema descriptions.
|
|
59
|
+
*
|
|
60
|
+
* @param graphileBuildOptions should be of type `Partial<Options> & { ownerPool: Pool }`
|
|
61
|
+
*/
|
|
62
|
+
export const AnnotateTypesWithPermissionsPlugin = async (builder, { ownerPool }) => {
|
|
63
|
+
const allPolicies = await loadPolicies(ownerPool);
|
|
64
|
+
builder.hook('GraphQLInputObjectType', (obj, _build, context) => {
|
|
65
|
+
const scope = context.scope;
|
|
66
|
+
// PostGraphile input Types that do not correspond to a database table
|
|
67
|
+
if (scope.isPointInputType ||
|
|
68
|
+
scope.isIntervalInputType ||
|
|
69
|
+
scope.isPgConnectionFilterOperators ||
|
|
70
|
+
scope.isPgConnectionFilterMany ||
|
|
71
|
+
scope.isPgCondition ||
|
|
72
|
+
scope.isPgConnectionFilter) {
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
// PostGraphile generated input types for DB mutations
|
|
76
|
+
if (scope.pgIntrospection) {
|
|
77
|
+
const policies = allPolicies.filter((value) => value.schemaname === scope.pgIntrospection.namespaceName &&
|
|
78
|
+
value.tablename === scope.pgIntrospection.name);
|
|
79
|
+
let operation;
|
|
80
|
+
switch (true) {
|
|
81
|
+
case scope.isPgCreateInputType:
|
|
82
|
+
operation = 'INSERT';
|
|
83
|
+
break;
|
|
84
|
+
case scope.isPgUpdateInputType:
|
|
85
|
+
operation = 'UPDATE';
|
|
86
|
+
break;
|
|
87
|
+
case scope.isPgDeleteInputType:
|
|
88
|
+
operation = 'DELETE';
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
return obj;
|
|
92
|
+
}
|
|
93
|
+
obj.description = setPermissionsCommentText(obj.description, policies, operation);
|
|
94
|
+
return obj;
|
|
95
|
+
}
|
|
96
|
+
// The input objects that come to this code-path are custom input types
|
|
97
|
+
// and require custom logic to protect them!
|
|
98
|
+
// Only works if they have input >types< - if they have no input or scalar
|
|
99
|
+
// input values they cannot be found by this method.
|
|
100
|
+
// Example: PopulateInput from the populate endpoint
|
|
101
|
+
return obj;
|
|
102
|
+
});
|
|
103
|
+
builder.hook('GraphQLObjectType', (obj, _build, context) => {
|
|
104
|
+
const scope = context.scope;
|
|
105
|
+
if (
|
|
106
|
+
// PostGraphile Types that do not correspond to a database table
|
|
107
|
+
scope.isPointType ||
|
|
108
|
+
scope.isIntervalType ||
|
|
109
|
+
scope.isPgConnectionFilterOperators ||
|
|
110
|
+
scope.isPgConnectionFilterMany ||
|
|
111
|
+
scope.isPgCondition ||
|
|
112
|
+
scope.isPgConnectionFilter ||
|
|
113
|
+
scope.isPageInfo ||
|
|
114
|
+
scope.isEdgeType ||
|
|
115
|
+
scope.isRootQuery ||
|
|
116
|
+
scope.isRootMutation ||
|
|
117
|
+
scope.isRootSubscription ||
|
|
118
|
+
scope.isMutationPayload ||
|
|
119
|
+
scope.isPgDeletePayloadType ||
|
|
120
|
+
scope.isPgUpdatePayloadType ||
|
|
121
|
+
// TODO: Procedures have no row level security: secure them in another way
|
|
122
|
+
context?.scope?.pgIntrospection?.kind === 'procedure') {
|
|
123
|
+
return obj;
|
|
124
|
+
}
|
|
125
|
+
// PostGraphile generated types for DB queries
|
|
126
|
+
if (scope.pgIntrospection) {
|
|
127
|
+
const policies = allPolicies.filter((value) => value.schemaname === scope.pgIntrospection.namespaceName &&
|
|
128
|
+
value.tablename === scope.pgIntrospection.name);
|
|
129
|
+
obj.description = setPermissionsCommentText(obj.description, policies, 'SELECT');
|
|
130
|
+
return obj;
|
|
131
|
+
}
|
|
132
|
+
// The objects that come to this code-path are custom types
|
|
133
|
+
// and require custom logic to protect them!
|
|
134
|
+
// Only works if they have >types< - if they have no input or scalar
|
|
135
|
+
// input values they cannot be found by this method.
|
|
136
|
+
return obj;
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
export const exportedForTestingAnnotatePlugin = { setPermissionsCommentText };
|
|
140
|
+
//# sourceMappingURL=annotate-types-with-permissions-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate-types-with-permissions-plugin.js","sourceRoot":"","sources":["../../../src/plugins/annotate-types-with-permissions-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAcxD,KAAK,UAAU,YAAY,CAAC,SAAe;IACzC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;IACzC,IAAI,CAAC;QACH,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wBAAwB;YAC9B,KAAK,CAAC,aAAa;YACnB,KAAK,CAAC,oBAAoB;YAC1B,KAAK,CAAC,UAAU;YAChB,KAAK,CAAC,UAAU;YAChB,KAAK,CAAC,WAAW;YACjB,KAAK,CAAC,cAAc;YACpB,KAAK,CAAC,kBAAkB;YACxB,KAAK,CAAC,iBAAiB;YACvB,KAAK,CAAC,qBAAqB;YAC3B,KAAK,CAAC,qBAAqB;YAC3B,0EAA0E;YAC1E,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,KAAK,WAAW,EACrD,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QAED,8CAA8C;QAC9C,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CACjC,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,eAAe,CAAC,aAAa;gBACxD,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,eAAe,CAAC,IAAI,CACjD,CAAC;YAEF,GAAG,CAAC,WAAW,GAAG,yBAAyB,CACzC,GAAG,CAAC,WAAW,EACf,QAAQ,EACR,QAAQ,CACT,CAAC;YACF,OAAO,GAAG,CAAC;QACb,CAAC;QAED,2DAA2D;QAC3D,4CAA4C;QAC5C,oEAAoE;QACpE,oDAAoD;QACpD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type DbClient, type PgAuthenticatedManagementSubject } from '@axinom/mosaic-db-common';
|
|
2
|
+
import type { BasicConfig, BasicDBConfig, BasicManagedServiceConfig } from '@axinom/mosaic-service-common';
|
|
3
|
+
import type { StoreInboxMessage } from '@axinom/mosaic-transactional-inbox-outbox';
|
|
4
|
+
import type { Plugin } from 'postgraphile';
|
|
5
|
+
type MinimalConfig = Pick<BasicConfig, 'serviceId'> & (Pick<BasicDBConfig, 'dbOwner'> & Pick<BasicManagedServiceConfig, 'dbEnvOwner'>);
|
|
6
|
+
/**
|
|
7
|
+
* This factory will generate a Postgraphile plugin that adds a mutation to the selected entities allowing the user to perform a bulk edit operation on the specified entity and its relations.
|
|
8
|
+
*
|
|
9
|
+
* @param tableName Name of the table to enable the BulkEdit mutation
|
|
10
|
+
* @param bulkEditMutationName Name of the BulkEdit mutation to be generated
|
|
11
|
+
* @param messageSettings The settings for the MultiTenantMessaging for the service that implements the ItemChangeCommand (e.g. ImageServiceMultiTenantMessagingSettings.ImageServicePerformItemChange)
|
|
12
|
+
* @param excludedForeignKeyRelations Optional array of FK table names to exclude from bulk edit operations
|
|
13
|
+
* @returns The Postgraphile plugin that enables the BulkEdit mutation.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BulkEditAsyncPluginFactory: (tableName: string, bulkEditMutationName: string, getLongLivedToken: (originalToken: string, config: BasicDBConfig) => Promise<string>, excludedForeignKeyRelations?: string[]) => Plugin;
|
|
16
|
+
interface MainResolverPayload {
|
|
17
|
+
mainTableName: string;
|
|
18
|
+
gqlFieldNameToColumnNameMap: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
inputData?: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface FkResolverPayload {
|
|
26
|
+
[fKTableName: string]: {
|
|
27
|
+
parentKeyColumnName: string;
|
|
28
|
+
fkGqlFieldNameToColumnNameMap: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
};
|
|
31
|
+
inputData?: {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Metadata for clearing all entities in a foreign key relation
|
|
38
|
+
*/
|
|
39
|
+
interface FkClearPayload {
|
|
40
|
+
[fKTableName: string]: {
|
|
41
|
+
parentKeyColumnName: string;
|
|
42
|
+
shouldClear: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Complete payload for bulk item change operations
|
|
47
|
+
* Contains metadata for all possible actions: set, clear, remove, and add
|
|
48
|
+
*/
|
|
49
|
+
interface BulkItemChangePayload {
|
|
50
|
+
set: MainResolverPayload;
|
|
51
|
+
clears: FkClearPayload;
|
|
52
|
+
removals: FkResolverPayload;
|
|
53
|
+
additions: FkResolverPayload;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Exported for testing purposes
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export declare function asyncResolverImplementation(bulkItemChangePayload: BulkItemChangePayload, entityIds: string[], config: MinimalConfig, ownerPool: DbClient, envOwnerPool: DbClient, longLivedToken: string, subject: PgAuthenticatedManagementSubject, storeInboxMessage: StoreInboxMessage): Promise<void>;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=bulk-edit-async-plugin-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulk-edit-async-plugin-factory.d.ts","sourceRoot":"","sources":["../../../../src/plugins/bulk-edit/bulk-edit-async-plugin-factory.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gCAAgC,EAGtC,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAgBnF,OAAO,KAAK,EAAqB,MAAM,EAAiB,MAAM,cAAc,CAAC;AAE7E,KAAK,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GACjD,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAC7B,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC,CAA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