@cedarjs/graphql-server 5.0.6 → 5.0.7-next.219
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/createGraphQLYoga.js +19 -19
- package/dist/directives/makeDirectives.d.ts +2 -2
- package/dist/directives/makeDirectives.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/makeMergedSchema.d.ts +6 -6
- package/dist/makeMergedSchema.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +8 -8
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +20 -16
- package/dist/plugins/{useRedwoodAuthContext.d.ts → useCedarAuthContext.d.ts} +2 -2
- package/dist/plugins/useCedarAuthContext.d.ts.map +1 -0
- package/dist/plugins/useCedarAuthContext.js +30 -0
- package/dist/{cjs/plugins/useRedwoodError.d.ts → plugins/useCedarError.d.ts} +4 -4
- package/dist/plugins/useCedarError.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodError.js → useCedarError.js} +5 -5
- package/dist/plugins/{useRedwoodGlobalContextSetter.d.ts → useCedarGlobalContextSetter.d.ts} +2 -2
- package/dist/plugins/useCedarGlobalContextSetter.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodGlobalContextSetter.js → useCedarGlobalContextSetter.js} +2 -2
- package/dist/plugins/{useRedwoodLogger.d.ts → useCedarLogger.d.ts} +2 -2
- package/dist/plugins/useCedarLogger.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodLogger.js → useCedarLogger.js} +2 -2
- package/dist/{cjs/plugins/useRedwoodOpenTelemetry.d.ts → plugins/useCedarOpenTelemetry.d.ts} +3 -3
- package/dist/plugins/useCedarOpenTelemetry.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodOpenTelemetry.js → useCedarOpenTelemetry.js} +3 -3
- package/dist/{cjs/plugins/useRedwoodPopulateContext.d.ts → plugins/useCedarPopulateContext.d.ts} +2 -2
- package/dist/plugins/useCedarPopulateContext.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodPopulateContext.js → useCedarPopulateContext.js} +2 -2
- package/dist/{cjs/plugins/useRedwoodTrustedDocuments.d.ts → plugins/useCedarTrustedDocuments.d.ts} +5 -3
- package/dist/plugins/useCedarTrustedDocuments.d.ts.map +1 -0
- package/dist/plugins/{useRedwoodTrustedDocuments.js → useCedarTrustedDocuments.js} +2 -2
- package/dist/plugins/useRedwoodDirective.d.ts +9 -3
- package/dist/plugins/useRedwoodDirective.d.ts.map +1 -1
- package/dist/plugins/useRedwoodDirective.js +3 -1
- package/dist/subscriptions/makeSubscriptions.d.ts +3 -3
- package/dist/subscriptions/makeSubscriptions.d.ts.map +1 -1
- package/dist/types.d.ts +13 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -20
- package/dist/cjs/cors.d.ts +0 -10
- package/dist/cjs/cors.d.ts.map +0 -1
- package/dist/cjs/cors.js +0 -70
- package/dist/cjs/createGraphQLYoga.d.ts +0 -6
- package/dist/cjs/createGraphQLYoga.d.ts.map +0 -1
- package/dist/cjs/createGraphQLYoga.js +0 -193
- package/dist/cjs/directives/makeDirectives.d.ts +0 -8
- package/dist/cjs/directives/makeDirectives.d.ts.map +0 -1
- package/dist/cjs/directives/makeDirectives.js +0 -89
- package/dist/cjs/errors.d.ts +0 -32
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -101
- package/dist/cjs/functions/graphql.d.ts +0 -15
- package/dist/cjs/functions/graphql.d.ts.map +0 -1
- package/dist/cjs/functions/graphql.js +0 -201
- package/dist/cjs/functions/useRequireAuth.d.ts +0 -12
- package/dist/cjs/functions/useRequireAuth.d.ts.map +0 -1
- package/dist/cjs/functions/useRequireAuth.js +0 -70
- package/dist/cjs/global.api-auto-imports.d.ts +0 -7
- package/dist/cjs/global.api-auto-imports.d.ts.map +0 -1
- package/dist/cjs/global.api-auto-imports.js +0 -1
- package/dist/cjs/globalContext.d.ts +0 -25
- package/dist/cjs/globalContext.d.ts.map +0 -1
- package/dist/cjs/globalContext.js +0 -55
- package/dist/cjs/globalContextStore.d.ts +0 -9
- package/dist/cjs/globalContextStore.d.ts.map +0 -1
- package/dist/cjs/globalContextStore.js +0 -35
- package/dist/cjs/graphiql.d.ts +0 -8
- package/dist/cjs/graphiql.d.ts.map +0 -1
- package/dist/cjs/graphiql.js +0 -45
- package/dist/cjs/index.d.ts +0 -14
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -75
- package/dist/cjs/introspection.d.ts +0 -7
- package/dist/cjs/introspection.d.ts.map +0 -1
- package/dist/cjs/introspection.js +0 -36
- package/dist/cjs/makeMergedSchema.d.ts +0 -17
- package/dist/cjs/makeMergedSchema.d.ts.map +0 -1
- package/dist/cjs/makeMergedSchema.js +0 -283
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/plugins/index.d.ts +0 -10
- package/dist/cjs/plugins/index.d.ts.map +0 -1
- package/dist/cjs/plugins/index.js +0 -52
- package/dist/cjs/plugins/useArmor.d.ts +0 -4
- package/dist/cjs/plugins/useArmor.d.ts.map +0 -1
- package/dist/cjs/plugins/useArmor.js +0 -69
- package/dist/cjs/plugins/useRedwoodAuthContext.d.ts +0 -9
- package/dist/cjs/plugins/useRedwoodAuthContext.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodAuthContext.js +0 -74
- package/dist/cjs/plugins/useRedwoodDirective.d.ts +0 -83
- package/dist/cjs/plugins/useRedwoodDirective.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodDirective.js +0 -166
- package/dist/cjs/plugins/useRedwoodError.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodError.js +0 -62
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts +0 -9
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodGlobalContextSetter.js +0 -35
- package/dist/cjs/plugins/useRedwoodLogger.d.ts +0 -115
- package/dist/cjs/plugins/useRedwoodLogger.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodLogger.js +0 -156
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodOpenTelemetry.js +0 -156
- package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodPopulateContext.js +0 -35
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts.map +0 -1
- package/dist/cjs/plugins/useRedwoodTrustedDocuments.js +0 -80
- package/dist/cjs/rootSchema.d.ts +0 -25
- package/dist/cjs/rootSchema.d.ts.map +0 -1
- package/dist/cjs/rootSchema.js +0 -108
- package/dist/cjs/subscriptions/makeSubscriptions.d.ts +0 -18
- package/dist/cjs/subscriptions/makeSubscriptions.d.ts.map +0 -1
- package/dist/cjs/subscriptions/makeSubscriptions.js +0 -40
- package/dist/cjs/types.d.ts +0 -231
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -16
- package/dist/plugins/useRedwoodAuthContext.d.ts.map +0 -1
- package/dist/plugins/useRedwoodAuthContext.js +0 -50
- package/dist/plugins/useRedwoodError.d.ts +0 -20
- package/dist/plugins/useRedwoodError.d.ts.map +0 -1
- package/dist/plugins/useRedwoodGlobalContextSetter.d.ts.map +0 -1
- package/dist/plugins/useRedwoodLogger.d.ts.map +0 -1
- package/dist/plugins/useRedwoodOpenTelemetry.d.ts +0 -22
- package/dist/plugins/useRedwoodOpenTelemetry.d.ts.map +0 -1
- package/dist/plugins/useRedwoodPopulateContext.d.ts +0 -9
- package/dist/plugins/useRedwoodPopulateContext.d.ts.map +0 -1
- package/dist/plugins/useRedwoodTrustedDocuments.d.ts +0 -23
- package/dist/plugins/useRedwoodTrustedDocuments.d.ts.map +0 -1
package/dist/cjs/index.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var index_exports = {};
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
DirectiveType: () => import_useRedwoodDirective.DirectiveType,
|
|
33
|
-
context: () => import_context.context,
|
|
34
|
-
createTransformerDirective: () => import_makeDirectives.createTransformerDirective,
|
|
35
|
-
createValidatorDirective: () => import_makeDirectives.createValidatorDirective,
|
|
36
|
-
getDirectiveName: () => import_makeDirectives.getDirectiveName,
|
|
37
|
-
hasDirective: () => import_useRedwoodDirective.hasDirective,
|
|
38
|
-
makeDirectivesForPlugin: () => import_makeDirectives.makeDirectivesForPlugin,
|
|
39
|
-
rootSchema: () => rootSchema,
|
|
40
|
-
setContext: () => import_context.setContext,
|
|
41
|
-
useRedwoodDirective: () => import_useRedwoodDirective.useRedwoodDirective
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(index_exports);
|
|
44
|
-
var import_global_api_auto_imports = require("./global.api-auto-imports.js");
|
|
45
|
-
__reExport(index_exports, require("./global.api-auto-imports.js"), module.exports);
|
|
46
|
-
__reExport(index_exports, require("./errors.js"), module.exports);
|
|
47
|
-
__reExport(index_exports, require("./functions/graphql.js"), module.exports);
|
|
48
|
-
__reExport(index_exports, require("./functions/useRequireAuth.js"), module.exports);
|
|
49
|
-
__reExport(index_exports, require("./makeMergedSchema.js"), module.exports);
|
|
50
|
-
__reExport(index_exports, require("./createGraphQLYoga.js"), module.exports);
|
|
51
|
-
__reExport(index_exports, require("./types.js"), module.exports);
|
|
52
|
-
var import_makeDirectives = require("./directives/makeDirectives.js");
|
|
53
|
-
var import_useRedwoodDirective = require("./plugins/useRedwoodDirective.js");
|
|
54
|
-
var rootSchema = __toESM(require("./rootSchema.js"), 1);
|
|
55
|
-
var import_context = require("@cedarjs/context");
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
DirectiveType,
|
|
59
|
-
context,
|
|
60
|
-
createTransformerDirective,
|
|
61
|
-
createValidatorDirective,
|
|
62
|
-
getDirectiveName,
|
|
63
|
-
hasDirective,
|
|
64
|
-
makeDirectivesForPlugin,
|
|
65
|
-
rootSchema,
|
|
66
|
-
setContext,
|
|
67
|
-
useRedwoodDirective,
|
|
68
|
-
...require("./global.api-auto-imports.js"),
|
|
69
|
-
...require("./errors.js"),
|
|
70
|
-
...require("./functions/graphql.js"),
|
|
71
|
-
...require("./functions/useRequireAuth.js"),
|
|
72
|
-
...require("./makeMergedSchema.js"),
|
|
73
|
-
...require("./createGraphQLYoga.js"),
|
|
74
|
-
...require("./types.js")
|
|
75
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { GraphQLYogaOptions } from './types.js';
|
|
2
|
-
export declare const configureGraphQLIntrospection: ({ allowIntrospection, }: {
|
|
3
|
-
allowIntrospection?: GraphQLYogaOptions["allowIntrospection"];
|
|
4
|
-
}) => {
|
|
5
|
-
disableIntrospection: boolean;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=introspection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"introspection.d.ts","sourceRoot":"","sources":["../../src/introspection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,6BAA6B,GAAI,yBAE3C;IACD,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;CAC9D;;CASA,CAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var introspection_exports = {};
|
|
20
|
-
__export(introspection_exports, {
|
|
21
|
-
configureGraphQLIntrospection: () => configureGraphQLIntrospection
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(introspection_exports);
|
|
24
|
-
const configureGraphQLIntrospection = ({
|
|
25
|
-
allowIntrospection
|
|
26
|
-
}) => {
|
|
27
|
-
const isDevEnv = process.env.NODE_ENV === "development";
|
|
28
|
-
const disableIntrospection = isDevEnv && (allowIntrospection ?? true) ? false : !allowIntrospection;
|
|
29
|
-
return {
|
|
30
|
-
disableIntrospection
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
configureGraphQLIntrospection
|
|
36
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IExecutableSchemaDefinition } from '@graphql-tools/schema';
|
|
2
|
-
import type { GraphQLSchema } from 'graphql';
|
|
3
|
-
import type { RedwoodDirective } from './plugins/useRedwoodDirective.js';
|
|
4
|
-
import type { RedwoodSubscription } from './subscriptions/makeSubscriptions.js';
|
|
5
|
-
import type { ServicesGlobImports, SdlGlobImports, RedwoodScalarConfig } from './types.js';
|
|
6
|
-
export declare const makeMergedSchema: ({ sdls, services, schemaOptions, directives, subscriptions, includeScalars, }: {
|
|
7
|
-
sdls: SdlGlobImports;
|
|
8
|
-
services: ServicesGlobImports;
|
|
9
|
-
directives: RedwoodDirective[];
|
|
10
|
-
subscriptions: RedwoodSubscription[];
|
|
11
|
-
includeScalars?: RedwoodScalarConfig;
|
|
12
|
-
/**
|
|
13
|
-
* A list of options passed to [makeExecutableSchema](https://www.graphql-tools.com/docs/generate-schema/#makeexecutableschemaoptions).
|
|
14
|
-
*/
|
|
15
|
-
schemaOptions?: Partial<IExecutableSchemaDefinition>;
|
|
16
|
-
}) => GraphQLSchema;
|
|
17
|
-
//# sourceMappingURL=makeMergedSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"makeMergedSchema.d.ts","sourceRoot":"","sources":["../../src/makeMergedSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAUxE,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAC/E,OAAO,KAAK,EAEV,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAuUnB,eAAO,MAAM,gBAAgB,GAAI,+EAO9B;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,aAAa,EAAE,mBAAmB,EAAE,CAAA;IACpC,cAAc,CAAC,EAAE,mBAAmB,CAAA;IAEpC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;CACrD,kBA+CA,CAAA"}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var makeMergedSchema_exports = {};
|
|
30
|
-
__export(makeMergedSchema_exports, {
|
|
31
|
-
makeMergedSchema: () => makeMergedSchema
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(makeMergedSchema_exports);
|
|
34
|
-
var import_merge = require("@graphql-tools/merge");
|
|
35
|
-
var import_schema = require("@graphql-tools/schema");
|
|
36
|
-
var opentelemetry = __toESM(require("@opentelemetry/api"), 1);
|
|
37
|
-
var import_merge2 = __toESM(require("lodash/merge.js"), 1);
|
|
38
|
-
var import_omitBy = __toESM(require("lodash/omitBy.js"), 1);
|
|
39
|
-
var rootGqlSchema = __toESM(require("./rootSchema.js"), 1);
|
|
40
|
-
const wrapWithOpenTelemetry = async (func, args, root, context, info, name) => {
|
|
41
|
-
const tracer = opentelemetry.trace.getTracer("redwoodjs");
|
|
42
|
-
const parentSpan = context !== null && context["OPEN_TELEMETRY_GRAPHQL"];
|
|
43
|
-
const parentContext = parentSpan ? opentelemetry.trace.setSpan(opentelemetry.context.active(), parentSpan) : opentelemetry.context.active();
|
|
44
|
-
return await tracer.startActiveSpan(
|
|
45
|
-
`redwoodjs:graphql:resolver:${name}`,
|
|
46
|
-
{},
|
|
47
|
-
parentContext,
|
|
48
|
-
async (span) => {
|
|
49
|
-
span.setAttribute(
|
|
50
|
-
"graphql.execute.operationName",
|
|
51
|
-
`${args.operationName || "Anonymous Operation"}`
|
|
52
|
-
);
|
|
53
|
-
try {
|
|
54
|
-
const result = await func(args, {
|
|
55
|
-
root,
|
|
56
|
-
context,
|
|
57
|
-
info
|
|
58
|
-
});
|
|
59
|
-
span.end();
|
|
60
|
-
return result;
|
|
61
|
-
} catch (ex) {
|
|
62
|
-
span.recordException(ex);
|
|
63
|
-
span.setStatus({ code: opentelemetry.SpanStatusCode.ERROR });
|
|
64
|
-
span.end();
|
|
65
|
-
throw ex;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
const mapFieldsToService = ({
|
|
71
|
-
fields = {},
|
|
72
|
-
resolvers: unmappedResolvers,
|
|
73
|
-
services
|
|
74
|
-
}) => Object.keys(fields).reduce((resolvers, name) => {
|
|
75
|
-
if (resolvers?.[name]) {
|
|
76
|
-
return resolvers;
|
|
77
|
-
}
|
|
78
|
-
if (services?.[name]) {
|
|
79
|
-
return {
|
|
80
|
-
...resolvers,
|
|
81
|
-
// Map the arguments from GraphQL to an ordinary function a service would
|
|
82
|
-
// expect.
|
|
83
|
-
[name]: async (root, args, context, info) => {
|
|
84
|
-
const captureResolvers = (
|
|
85
|
-
// @ts-expect-error context is unknown
|
|
86
|
-
context?.["OPEN_TELEMETRY_GRAPHQL"] !== void 0
|
|
87
|
-
);
|
|
88
|
-
if (captureResolvers) {
|
|
89
|
-
return wrapWithOpenTelemetry(
|
|
90
|
-
services[name],
|
|
91
|
-
args,
|
|
92
|
-
root,
|
|
93
|
-
context,
|
|
94
|
-
info,
|
|
95
|
-
name
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return services[name](args, { root, context, info });
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return resolvers;
|
|
103
|
-
}, unmappedResolvers);
|
|
104
|
-
const resolveUnionType = (types) => ({
|
|
105
|
-
__resolveType(obj) {
|
|
106
|
-
if (Object.hasOwn(obj, "__typename")) {
|
|
107
|
-
for (const type of types) {
|
|
108
|
-
if (type.name === obj["__typename"]) {
|
|
109
|
-
return type.name;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const fieldIntersections = new Array(types.length).fill(0);
|
|
114
|
-
let maxIntersectionFields = 0;
|
|
115
|
-
let maxIntersectionType;
|
|
116
|
-
let maxIntersectionIdx = 0;
|
|
117
|
-
for (let i = 0; i < types.length; i++) {
|
|
118
|
-
const type = types[i];
|
|
119
|
-
const fieldIntersection = Object.keys(type.getFields()).filter(
|
|
120
|
-
(field) => field in obj
|
|
121
|
-
);
|
|
122
|
-
fieldIntersections[i] = fieldIntersection.length;
|
|
123
|
-
if (fieldIntersection.length > maxIntersectionFields) {
|
|
124
|
-
maxIntersectionFields = fieldIntersection.length;
|
|
125
|
-
maxIntersectionType = type;
|
|
126
|
-
maxIntersectionIdx = i;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (fieldIntersections.includes(maxIntersectionFields, maxIntersectionIdx + 1)) {
|
|
130
|
-
throw Error(
|
|
131
|
-
"Unable to resolve correct type for union. Try adding unique fields to each type or __typename to each resolver"
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
return maxIntersectionType?.name ?? null;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
const mergeResolversWithServices = ({
|
|
138
|
-
schema,
|
|
139
|
-
resolvers,
|
|
140
|
-
services
|
|
141
|
-
}) => {
|
|
142
|
-
const mergedServices = (0, import_merge2.default)(
|
|
143
|
-
{},
|
|
144
|
-
...Object.keys(services).map((name) => services[name])
|
|
145
|
-
);
|
|
146
|
-
const typesWithFields = Object.keys(schema.getTypeMap()).filter((name) => !name.startsWith("_")).filter(
|
|
147
|
-
(name) => typeof schema.getType(name).getFields !== "undefined"
|
|
148
|
-
).map((name) => {
|
|
149
|
-
return schema.getType(name);
|
|
150
|
-
}).filter(
|
|
151
|
-
(type) => type !== void 0 && type !== null
|
|
152
|
-
);
|
|
153
|
-
const unionTypes = Object.keys(schema.getTypeMap()).filter(
|
|
154
|
-
(name) => typeof schema.getType(name).getTypes !== "undefined"
|
|
155
|
-
).map((name) => {
|
|
156
|
-
return schema.getType(name);
|
|
157
|
-
}).filter(
|
|
158
|
-
(type) => type !== void 0 && type !== null
|
|
159
|
-
);
|
|
160
|
-
const mappedResolvers = typesWithFields.reduce((acc, type) => {
|
|
161
|
-
let servicesForType = mergedServices;
|
|
162
|
-
if (!["Query", "Mutation", "Subscription"].includes(type.name)) {
|
|
163
|
-
servicesForType = mergedServices?.[type.name];
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
...acc,
|
|
167
|
-
[type.name]: mapFieldsToService({
|
|
168
|
-
fields: type.getFields(),
|
|
169
|
-
resolvers: resolvers?.[type.name],
|
|
170
|
-
services: servicesForType
|
|
171
|
-
})
|
|
172
|
-
};
|
|
173
|
-
}, {});
|
|
174
|
-
const mappedUnionResolvers = unionTypes.reduce((acc, type) => {
|
|
175
|
-
return {
|
|
176
|
-
...acc,
|
|
177
|
-
[type.name]: resolveUnionType(type.getTypes())
|
|
178
|
-
};
|
|
179
|
-
}, {});
|
|
180
|
-
return (0, import_omitBy.default)(
|
|
181
|
-
{
|
|
182
|
-
...resolvers,
|
|
183
|
-
...mappedResolvers,
|
|
184
|
-
...mappedUnionResolvers
|
|
185
|
-
},
|
|
186
|
-
(v) => typeof v === "undefined"
|
|
187
|
-
);
|
|
188
|
-
};
|
|
189
|
-
const mergeResolvers = (schemas) => (0, import_omitBy.default)(
|
|
190
|
-
(0, import_merge2.default)(
|
|
191
|
-
{},
|
|
192
|
-
...[
|
|
193
|
-
rootGqlSchema.resolvers,
|
|
194
|
-
...Object.values(schemas).map(({ resolvers }) => resolvers)
|
|
195
|
-
]
|
|
196
|
-
),
|
|
197
|
-
(v) => typeof v === "undefined"
|
|
198
|
-
);
|
|
199
|
-
const mergeTypes = (types, options) => {
|
|
200
|
-
const schemaDefinition = options && typeof options.schemaDefinition === "boolean" ? options.schemaDefinition : true;
|
|
201
|
-
return (0, import_merge.mergeTypeDefs)(types, {
|
|
202
|
-
useSchemaDefinition: schemaDefinition,
|
|
203
|
-
forceSchemaDefinition: schemaDefinition,
|
|
204
|
-
throwOnConflict: true,
|
|
205
|
-
commentDescriptions: true,
|
|
206
|
-
reverseDirectives: true,
|
|
207
|
-
...options
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
const mergeResolversWithSubscriptions = ({
|
|
211
|
-
schema,
|
|
212
|
-
subscriptions,
|
|
213
|
-
resolverValidationOptions,
|
|
214
|
-
inheritResolversFromInterfaces
|
|
215
|
-
}) => {
|
|
216
|
-
if (subscriptions && subscriptions.length > 0) {
|
|
217
|
-
const subscriptionResolvers = { Subscription: {} };
|
|
218
|
-
subscriptions?.forEach((subscription) => {
|
|
219
|
-
subscriptionResolvers["Subscription"] = {
|
|
220
|
-
...subscriptionResolvers["Subscription"],
|
|
221
|
-
...subscription.resolvers
|
|
222
|
-
};
|
|
223
|
-
});
|
|
224
|
-
return (0, import_schema.addResolversToSchema)({
|
|
225
|
-
schema,
|
|
226
|
-
resolvers: subscriptionResolvers,
|
|
227
|
-
resolverValidationOptions,
|
|
228
|
-
inheritResolversFromInterfaces
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
return schema;
|
|
232
|
-
};
|
|
233
|
-
const makeMergedSchema = ({
|
|
234
|
-
sdls,
|
|
235
|
-
services,
|
|
236
|
-
schemaOptions = {},
|
|
237
|
-
directives,
|
|
238
|
-
subscriptions = [],
|
|
239
|
-
includeScalars
|
|
240
|
-
}) => {
|
|
241
|
-
const sdlSchemas = Object.values(sdls).map(({ schema: schema2 }) => schema2);
|
|
242
|
-
const rootEntries = [rootGqlSchema.schema];
|
|
243
|
-
if (includeScalars?.File !== false) {
|
|
244
|
-
rootEntries.push(rootGqlSchema.scalarSchemas.File);
|
|
245
|
-
}
|
|
246
|
-
const typeDefs = mergeTypes(
|
|
247
|
-
[
|
|
248
|
-
...rootEntries,
|
|
249
|
-
...directives.map((directive) => directive.schema),
|
|
250
|
-
// pick out schemas from directives
|
|
251
|
-
...subscriptions.map((subscription) => subscription.schema),
|
|
252
|
-
// pick out schemas from subscriptions
|
|
253
|
-
...sdlSchemas
|
|
254
|
-
// pick out the schemas from sdls
|
|
255
|
-
],
|
|
256
|
-
{ all: true }
|
|
257
|
-
);
|
|
258
|
-
const { typeDefs: schemaOptionsTypeDefs = [], ...otherSchemaOptions } = schemaOptions;
|
|
259
|
-
const schema = (0, import_schema.makeExecutableSchema)({
|
|
260
|
-
typeDefs: [typeDefs, schemaOptionsTypeDefs],
|
|
261
|
-
...otherSchemaOptions
|
|
262
|
-
});
|
|
263
|
-
const resolvers = mergeResolversWithServices({
|
|
264
|
-
schema,
|
|
265
|
-
resolvers: mergeResolvers(sdls),
|
|
266
|
-
services
|
|
267
|
-
});
|
|
268
|
-
const schemaWithSubscriptions = mergeResolversWithSubscriptions({
|
|
269
|
-
schema,
|
|
270
|
-
subscriptions
|
|
271
|
-
});
|
|
272
|
-
const { resolverValidationOptions, inheritResolversFromInterfaces } = schemaOptions || {};
|
|
273
|
-
return (0, import_schema.addResolversToSchema)({
|
|
274
|
-
schema: schemaWithSubscriptions,
|
|
275
|
-
resolvers,
|
|
276
|
-
resolverValidationOptions,
|
|
277
|
-
inheritResolversFromInterfaces
|
|
278
|
-
});
|
|
279
|
-
};
|
|
280
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
281
|
-
0 && (module.exports = {
|
|
282
|
-
makeMergedSchema
|
|
283
|
-
});
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { useArmor } from './useArmor.js';
|
|
2
|
-
export { useRedwoodAuthContext } from './useRedwoodAuthContext.js';
|
|
3
|
-
export { useRedwoodDirective } from './useRedwoodDirective.js';
|
|
4
|
-
export { useRedwoodError } from './useRedwoodError.js';
|
|
5
|
-
export { useRedwoodGlobalContextSetter } from './useRedwoodGlobalContextSetter.js';
|
|
6
|
-
export { useRedwoodLogger } from './useRedwoodLogger.js';
|
|
7
|
-
export { useRedwoodTrustedDocuments } from './useRedwoodTrustedDocuments.js';
|
|
8
|
-
export { useRedwoodPopulateContext } from './useRedwoodPopulateContext.js';
|
|
9
|
-
export { useRedwoodOpenTelemetry } from './useRedwoodOpenTelemetry.js';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAA;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAE5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var plugins_exports = {};
|
|
20
|
-
__export(plugins_exports, {
|
|
21
|
-
useArmor: () => import_useArmor.useArmor,
|
|
22
|
-
useRedwoodAuthContext: () => import_useRedwoodAuthContext.useRedwoodAuthContext,
|
|
23
|
-
useRedwoodDirective: () => import_useRedwoodDirective.useRedwoodDirective,
|
|
24
|
-
useRedwoodError: () => import_useRedwoodError.useRedwoodError,
|
|
25
|
-
useRedwoodGlobalContextSetter: () => import_useRedwoodGlobalContextSetter.useRedwoodGlobalContextSetter,
|
|
26
|
-
useRedwoodLogger: () => import_useRedwoodLogger.useRedwoodLogger,
|
|
27
|
-
useRedwoodOpenTelemetry: () => import_useRedwoodOpenTelemetry.useRedwoodOpenTelemetry,
|
|
28
|
-
useRedwoodPopulateContext: () => import_useRedwoodPopulateContext.useRedwoodPopulateContext,
|
|
29
|
-
useRedwoodTrustedDocuments: () => import_useRedwoodTrustedDocuments.useRedwoodTrustedDocuments
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(plugins_exports);
|
|
32
|
-
var import_useArmor = require("./useArmor.js");
|
|
33
|
-
var import_useRedwoodAuthContext = require("./useRedwoodAuthContext.js");
|
|
34
|
-
var import_useRedwoodDirective = require("./useRedwoodDirective.js");
|
|
35
|
-
var import_useRedwoodError = require("./useRedwoodError.js");
|
|
36
|
-
var import_useRedwoodGlobalContextSetter = require("./useRedwoodGlobalContextSetter.js");
|
|
37
|
-
var import_useRedwoodLogger = require("./useRedwoodLogger.js");
|
|
38
|
-
var import_useRedwoodTrustedDocuments = require("./useRedwoodTrustedDocuments.js");
|
|
39
|
-
var import_useRedwoodPopulateContext = require("./useRedwoodPopulateContext.js");
|
|
40
|
-
var import_useRedwoodOpenTelemetry = require("./useRedwoodOpenTelemetry.js");
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
useArmor,
|
|
44
|
-
useRedwoodAuthContext,
|
|
45
|
-
useRedwoodDirective,
|
|
46
|
-
useRedwoodError,
|
|
47
|
-
useRedwoodGlobalContextSetter,
|
|
48
|
-
useRedwoodLogger,
|
|
49
|
-
useRedwoodOpenTelemetry,
|
|
50
|
-
useRedwoodPopulateContext,
|
|
51
|
-
useRedwoodTrustedDocuments
|
|
52
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useArmor.d.ts","sourceRoot":"","sources":["../../../src/plugins/useArmor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO9C,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,EAAE,SAAS,WAAW,wCAsC5D,CAAA"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useArmor_exports = {};
|
|
20
|
-
__export(useArmor_exports, {
|
|
21
|
-
useArmor: () => useArmor
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useArmor_exports);
|
|
24
|
-
var import_graphql_armor = require("@escape.tech/graphql-armor");
|
|
25
|
-
const armorConfigDefaultOptions = {
|
|
26
|
-
logContext: false,
|
|
27
|
-
logErrors: true
|
|
28
|
-
};
|
|
29
|
-
const useArmor = (logger, config) => {
|
|
30
|
-
const logRejection = (ctx, error) => {
|
|
31
|
-
if (config?.logContext ?? armorConfigDefaultOptions.logContext) {
|
|
32
|
-
if (ctx) {
|
|
33
|
-
logger.debug({ custom: ctx }, `Armor rejection context`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (config?.logErrors ?? armorConfigDefaultOptions.logErrors) {
|
|
37
|
-
logger.error(error, `Armor rejected request: ${error.message}`);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return (0, import_graphql_armor.EnvelopArmorPlugin)({
|
|
41
|
-
...config,
|
|
42
|
-
costLimit: {
|
|
43
|
-
...config?.costLimit,
|
|
44
|
-
onReject: [logRejection]
|
|
45
|
-
},
|
|
46
|
-
maxAliases: {
|
|
47
|
-
allowList: [],
|
|
48
|
-
...config?.maxAliases,
|
|
49
|
-
onReject: [logRejection]
|
|
50
|
-
},
|
|
51
|
-
maxDepth: {
|
|
52
|
-
...config?.maxDepth,
|
|
53
|
-
flattenFragments: true,
|
|
54
|
-
onReject: [logRejection]
|
|
55
|
-
},
|
|
56
|
-
maxDirectives: {
|
|
57
|
-
...config?.maxDirectives,
|
|
58
|
-
onReject: [logRejection]
|
|
59
|
-
},
|
|
60
|
-
maxTokens: {
|
|
61
|
-
...config?.maxTokens,
|
|
62
|
-
onReject: [logRejection]
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 && (module.exports = {
|
|
68
|
-
useArmor
|
|
69
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'graphql-yoga';
|
|
2
|
-
import type { Decoder } from '@cedarjs/api';
|
|
3
|
-
import type { CedarGraphQLContext, GraphQLHandlerOptions } from '../types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Envelop plugin for injecting the current user into the GraphQL Context,
|
|
6
|
-
* based on custom getCurrentUser function.
|
|
7
|
-
*/
|
|
8
|
-
export declare const useRedwoodAuthContext: (getCurrentUser: GraphQLHandlerOptions["getCurrentUser"], authDecoder?: Decoder | Decoder[]) => Plugin<CedarGraphQLContext>;
|
|
9
|
-
//# sourceMappingURL=useRedwoodAuthContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRedwoodAuthContext.d.ts","sourceRoot":"","sources":["../../../src/plugins/useRedwoodAuthContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CAyC5B,CAAA"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useRedwoodAuthContext_exports = {};
|
|
20
|
-
__export(useRedwoodAuthContext_exports, {
|
|
21
|
-
useRedwoodAuthContext: () => useRedwoodAuthContext
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useRedwoodAuthContext_exports);
|
|
24
|
-
var import_api = require("@cedarjs/api");
|
|
25
|
-
const useRedwoodAuthContext = (getCurrentUser, authDecoder) => {
|
|
26
|
-
return {
|
|
27
|
-
async onContextBuilding({ context, extendContext }) {
|
|
28
|
-
let authContext = context.cedarContext?.serverAuthState;
|
|
29
|
-
try {
|
|
30
|
-
if (!authContext) {
|
|
31
|
-
const authEvent = getAuthEvent(context);
|
|
32
|
-
authContext = await (0, import_api.getAuthenticationContext)({
|
|
33
|
-
authDecoder,
|
|
34
|
-
event: authEvent,
|
|
35
|
-
context: context.requestContext
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Exception in getAuthenticationContext: ${error.message}`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
if (authContext) {
|
|
45
|
-
const currentUser = getCurrentUser ? await getCurrentUser(
|
|
46
|
-
authContext[0],
|
|
47
|
-
authContext[1],
|
|
48
|
-
authContext[2]
|
|
49
|
-
) : null;
|
|
50
|
-
if (currentUser) {
|
|
51
|
-
extendContext({ currentUser });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
} catch (error) {
|
|
55
|
-
throw new Error(`Exception in getCurrentUser: ${error.message}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
function getAuthEvent(context) {
|
|
61
|
-
if (context.request) {
|
|
62
|
-
return context.request;
|
|
63
|
-
}
|
|
64
|
-
if (context.event) {
|
|
65
|
-
return context.event;
|
|
66
|
-
}
|
|
67
|
-
throw new Error(
|
|
68
|
-
"GraphQL context contains neither a fetch-native Request nor a Lambda event. Please report this as a Cedar bug."
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
-
0 && (module.exports = {
|
|
73
|
-
useRedwoodAuthContext
|
|
74
|
-
});
|