@cedarjs/graphql-server 0.6.1-next.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/cjs/cors.d.ts +10 -0
  2. package/dist/cjs/cors.d.ts.map +1 -0
  3. package/dist/cjs/cors.js +70 -0
  4. package/dist/cjs/createGraphQLYoga.d.ts +6 -0
  5. package/dist/cjs/createGraphQLYoga.d.ts.map +1 -0
  6. package/dist/cjs/createGraphQLYoga.js +178 -0
  7. package/dist/cjs/directives/makeDirectives.d.ts +8 -0
  8. package/dist/cjs/directives/makeDirectives.d.ts.map +1 -0
  9. package/dist/cjs/directives/makeDirectives.js +89 -0
  10. package/dist/cjs/errors.d.ts +28 -0
  11. package/dist/cjs/errors.d.ts.map +1 -0
  12. package/dist/cjs/errors.js +98 -0
  13. package/dist/cjs/functions/graphql.d.ts +15 -0
  14. package/dist/cjs/functions/graphql.d.ts.map +1 -0
  15. package/dist/cjs/functions/graphql.js +141 -0
  16. package/dist/cjs/functions/useRequireAuth.d.ts +12 -0
  17. package/dist/cjs/functions/useRequireAuth.d.ts.map +1 -0
  18. package/dist/cjs/functions/useRequireAuth.js +70 -0
  19. package/dist/cjs/global.api-auto-imports.d.ts +5 -0
  20. package/dist/cjs/global.api-auto-imports.d.ts.map +1 -0
  21. package/dist/cjs/global.api-auto-imports.js +1 -0
  22. package/dist/cjs/globalContext.d.ts +25 -0
  23. package/dist/cjs/globalContext.d.ts.map +1 -0
  24. package/dist/cjs/globalContext.js +55 -0
  25. package/dist/cjs/globalContextStore.d.ts +9 -0
  26. package/dist/cjs/globalContextStore.d.ts.map +1 -0
  27. package/dist/cjs/globalContextStore.js +35 -0
  28. package/dist/cjs/graphiql.d.ts +8 -0
  29. package/dist/cjs/graphiql.d.ts.map +1 -0
  30. package/dist/cjs/graphiql.js +45 -0
  31. package/dist/cjs/index.d.ts +14 -0
  32. package/dist/cjs/index.d.ts.map +1 -0
  33. package/dist/cjs/index.js +75 -0
  34. package/dist/cjs/introspection.d.ts +7 -0
  35. package/dist/cjs/introspection.d.ts.map +1 -0
  36. package/dist/cjs/introspection.js +36 -0
  37. package/dist/cjs/makeMergedSchema.d.ts +17 -0
  38. package/dist/cjs/makeMergedSchema.d.ts.map +1 -0
  39. package/dist/cjs/makeMergedSchema.js +283 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/cjs/plugins/index.d.ts +10 -0
  42. package/dist/cjs/plugins/index.d.ts.map +1 -0
  43. package/dist/cjs/plugins/index.js +52 -0
  44. package/dist/cjs/plugins/useArmor.d.ts +4 -0
  45. package/dist/cjs/plugins/useArmor.d.ts.map +1 -0
  46. package/dist/cjs/plugins/useArmor.js +69 -0
  47. package/dist/cjs/plugins/useRedwoodAuthContext.d.ts +9 -0
  48. package/dist/cjs/plugins/useRedwoodAuthContext.d.ts.map +1 -0
  49. package/dist/cjs/plugins/useRedwoodAuthContext.js +61 -0
  50. package/dist/cjs/plugins/useRedwoodDirective.d.ts +83 -0
  51. package/dist/cjs/plugins/useRedwoodDirective.d.ts.map +1 -0
  52. package/dist/cjs/plugins/useRedwoodDirective.js +166 -0
  53. package/dist/cjs/plugins/useRedwoodError.d.ts +20 -0
  54. package/dist/cjs/plugins/useRedwoodError.d.ts.map +1 -0
  55. package/dist/cjs/plugins/useRedwoodError.js +63 -0
  56. package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts +9 -0
  57. package/dist/cjs/plugins/useRedwoodGlobalContextSetter.d.ts.map +1 -0
  58. package/dist/cjs/plugins/useRedwoodGlobalContextSetter.js +35 -0
  59. package/dist/cjs/plugins/useRedwoodLogger.d.ts +115 -0
  60. package/dist/cjs/plugins/useRedwoodLogger.d.ts.map +1 -0
  61. package/dist/cjs/plugins/useRedwoodLogger.js +149 -0
  62. package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts +22 -0
  63. package/dist/cjs/plugins/useRedwoodOpenTelemetry.d.ts.map +1 -0
  64. package/dist/cjs/plugins/useRedwoodOpenTelemetry.js +156 -0
  65. package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts +9 -0
  66. package/dist/cjs/plugins/useRedwoodPopulateContext.d.ts.map +1 -0
  67. package/dist/cjs/plugins/useRedwoodPopulateContext.js +35 -0
  68. package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts +23 -0
  69. package/dist/cjs/plugins/useRedwoodTrustedDocuments.d.ts.map +1 -0
  70. package/dist/cjs/plugins/useRedwoodTrustedDocuments.js +80 -0
  71. package/dist/cjs/rootSchema.d.ts +25 -0
  72. package/dist/cjs/rootSchema.d.ts.map +1 -0
  73. package/dist/cjs/rootSchema.js +97 -0
  74. package/dist/cjs/subscriptions/makeSubscriptions.d.ts +18 -0
  75. package/dist/cjs/subscriptions/makeSubscriptions.d.ts.map +1 -0
  76. package/dist/cjs/subscriptions/makeSubscriptions.js +40 -0
  77. package/dist/cjs/types.d.ts +215 -0
  78. package/dist/cjs/types.d.ts.map +1 -0
  79. package/dist/cjs/types.js +16 -0
  80. package/dist/cors.js +2 -26
  81. package/dist/createGraphQLYoga.d.ts +1 -1
  82. package/dist/createGraphQLYoga.d.ts.map +1 -1
  83. package/dist/createGraphQLYoga.js +45 -59
  84. package/dist/directives/makeDirectives.d.ts +1 -1
  85. package/dist/directives/makeDirectives.d.ts.map +1 -1
  86. package/dist/directives/makeDirectives.js +9 -36
  87. package/dist/errors.js +5 -36
  88. package/dist/functions/graphql.d.ts +1 -1
  89. package/dist/functions/graphql.d.ts.map +1 -1
  90. package/dist/functions/graphql.js +6 -30
  91. package/dist/functions/useRequireAuth.d.ts +1 -1
  92. package/dist/functions/useRequireAuth.d.ts.map +1 -1
  93. package/dist/functions/useRequireAuth.js +9 -33
  94. package/dist/global.api-auto-imports.js +0 -1
  95. package/dist/globalContext.js +6 -32
  96. package/dist/globalContextStore.d.ts +1 -1
  97. package/dist/globalContextStore.d.ts.map +1 -1
  98. package/dist/globalContextStore.js +4 -28
  99. package/dist/graphiql.d.ts +1 -1
  100. package/dist/graphiql.d.ts.map +1 -1
  101. package/dist/graphiql.js +2 -26
  102. package/dist/index.d.ts +12 -11
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +24 -82
  105. package/dist/introspection.d.ts +1 -1
  106. package/dist/introspection.d.ts.map +1 -1
  107. package/dist/introspection.js +2 -26
  108. package/dist/makeMergedSchema.d.ts +3 -3
  109. package/dist/makeMergedSchema.d.ts.map +1 -1
  110. package/dist/makeMergedSchema.js +19 -49
  111. package/dist/plugins/index.d.ts +9 -9
  112. package/dist/plugins/index.d.ts.map +1 -1
  113. package/dist/plugins/index.js +11 -43
  114. package/dist/plugins/useArmor.d.ts +2 -2
  115. package/dist/plugins/useArmor.d.ts.map +1 -1
  116. package/dist/plugins/useArmor.js +4 -28
  117. package/dist/plugins/useRedwoodAuthContext.d.ts +1 -1
  118. package/dist/plugins/useRedwoodAuthContext.d.ts.map +1 -1
  119. package/dist/plugins/useRedwoodAuthContext.js +4 -28
  120. package/dist/plugins/useRedwoodDirective.js +9 -37
  121. package/dist/plugins/useRedwoodError.d.ts +1 -1
  122. package/dist/plugins/useRedwoodError.d.ts.map +1 -1
  123. package/dist/plugins/useRedwoodError.js +10 -31
  124. package/dist/plugins/useRedwoodGlobalContextSetter.d.ts +1 -1
  125. package/dist/plugins/useRedwoodGlobalContextSetter.d.ts.map +1 -1
  126. package/dist/plugins/useRedwoodGlobalContextSetter.js +4 -28
  127. package/dist/plugins/useRedwoodLogger.d.ts +1 -1
  128. package/dist/plugins/useRedwoodLogger.d.ts.map +1 -1
  129. package/dist/plugins/useRedwoodLogger.js +10 -34
  130. package/dist/plugins/useRedwoodOpenTelemetry.d.ts +1 -1
  131. package/dist/plugins/useRedwoodOpenTelemetry.d.ts.map +1 -1
  132. package/dist/plugins/useRedwoodOpenTelemetry.js +11 -46
  133. package/dist/plugins/useRedwoodPopulateContext.d.ts +1 -1
  134. package/dist/plugins/useRedwoodPopulateContext.d.ts.map +1 -1
  135. package/dist/plugins/useRedwoodPopulateContext.js +2 -26
  136. package/dist/plugins/useRedwoodTrustedDocuments.d.ts +1 -1
  137. package/dist/plugins/useRedwoodTrustedDocuments.d.ts.map +1 -1
  138. package/dist/plugins/useRedwoodTrustedDocuments.js +4 -28
  139. package/dist/rootSchema.js +26 -54
  140. package/dist/subscriptions/makeSubscriptions.js +5 -29
  141. package/dist/types.d.ts +4 -4
  142. package/dist/types.d.ts.map +1 -1
  143. package/dist/types.js +0 -16
  144. package/package.json +27 -10
  145. package/dist/plugins/__fixtures__/common.d.ts +0 -9
  146. package/dist/plugins/__fixtures__/common.d.ts.map +0 -1
  147. package/dist/plugins/__fixtures__/envelop-testing.d.ts +0 -55
  148. package/dist/plugins/__fixtures__/envelop-testing.d.ts.map +0 -1
@@ -0,0 +1,156 @@
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 useRedwoodOpenTelemetry_exports = {};
30
+ __export(useRedwoodOpenTelemetry_exports, {
31
+ AttributeName: () => AttributeName,
32
+ useRedwoodOpenTelemetry: () => useRedwoodOpenTelemetry
33
+ });
34
+ module.exports = __toCommonJS(useRedwoodOpenTelemetry_exports);
35
+ var import_core = require("@envelop/core");
36
+ var import_on_resolve = require("@envelop/on-resolve");
37
+ var import_api = require("@opentelemetry/api");
38
+ var opentelemetry = __toESM(require("@opentelemetry/api"), 1);
39
+ var import_graphql = require("graphql");
40
+ var AttributeName = /* @__PURE__ */ ((AttributeName2) => {
41
+ AttributeName2["EXECUTION_ERROR"] = "graphql.execute.error";
42
+ AttributeName2["EXECUTION_RESULT"] = "graphql.execute.result";
43
+ AttributeName2["RESOLVER_EXCEPTION"] = "graphql.resolver.exception";
44
+ AttributeName2["RESOLVER_FIELD_NAME"] = "graphql.resolver.fieldName";
45
+ AttributeName2["RESOLVER_TYPE_NAME"] = "graphql.resolver.typeName";
46
+ AttributeName2["RESOLVER_RESULT_TYPE"] = "graphql.resolver.resultType";
47
+ AttributeName2["RESOLVER_ARGS"] = "graphql.resolver.args";
48
+ AttributeName2["EXECUTION_OPERATION_NAME"] = "graphql.execute.operationName";
49
+ AttributeName2["EXECUTION_OPERATION_DOCUMENT"] = "graphql.execute.document";
50
+ AttributeName2["EXECUTION_VARIABLES"] = "graphql.execute.variables";
51
+ return AttributeName2;
52
+ })(AttributeName || {});
53
+ const tracingSpanSymbol = "OPEN_TELEMETRY_GRAPHQL";
54
+ const useRedwoodOpenTelemetry = (options) => {
55
+ const spanKind = import_api.SpanKind.SERVER;
56
+ const spanAdditionalAttributes = {};
57
+ const tracer = opentelemetry.trace.getTracer("redwoodjs");
58
+ return {
59
+ onPluginInit({ addPlugin }) {
60
+ if (options.resolvers) {
61
+ addPlugin(
62
+ (0, import_on_resolve.useOnResolve)(({ info, context, args }) => {
63
+ if (context && typeof context === "object" && context[tracingSpanSymbol]) {
64
+ const ctx = opentelemetry.trace.setSpan(
65
+ opentelemetry.context.active(),
66
+ context[tracingSpanSymbol]
67
+ );
68
+ const { fieldName, returnType, parentType } = info;
69
+ return tracer.startActiveSpan(
70
+ `${parentType.name}.${fieldName}`,
71
+ {
72
+ attributes: {
73
+ ["graphql.resolver.fieldName" /* RESOLVER_FIELD_NAME */]: fieldName,
74
+ ["graphql.resolver.typeName" /* RESOLVER_TYPE_NAME */]: parentType.toString(),
75
+ ["graphql.resolver.resultType" /* RESOLVER_RESULT_TYPE */]: returnType.toString(),
76
+ ["graphql.resolver.args" /* RESOLVER_ARGS */]: JSON.stringify(args || {})
77
+ }
78
+ },
79
+ ctx,
80
+ (resolverSpan) => {
81
+ resolverSpan.spanContext();
82
+ return ({ result }) => {
83
+ if (result instanceof Error) {
84
+ resolverSpan.recordException({
85
+ name: "graphql.resolver.exception" /* RESOLVER_EXCEPTION */,
86
+ message: JSON.stringify(result)
87
+ });
88
+ }
89
+ resolverSpan.end();
90
+ };
91
+ }
92
+ );
93
+ }
94
+ return () => {
95
+ };
96
+ })
97
+ );
98
+ }
99
+ },
100
+ onExecute({ args, extendContext }) {
101
+ return tracer.startActiveSpan(
102
+ `${args.operationName || "Anonymous Operation"}`,
103
+ {
104
+ kind: spanKind,
105
+ attributes: {
106
+ ...spanAdditionalAttributes,
107
+ ["graphql.execute.operationName" /* EXECUTION_OPERATION_NAME */]: args.operationName ?? void 0,
108
+ ["graphql.execute.document" /* EXECUTION_OPERATION_DOCUMENT */]: (0, import_graphql.print)(args.document),
109
+ ...options.variables ? {
110
+ ["graphql.execute.variables" /* EXECUTION_VARIABLES */]: JSON.stringify(
111
+ args.variableValues ?? {}
112
+ )
113
+ } : {}
114
+ }
115
+ },
116
+ (executionSpan) => {
117
+ const resultCbs = {
118
+ onExecuteDone({ result }) {
119
+ if ((0, import_core.isAsyncIterable)(result)) {
120
+ executionSpan.end();
121
+ console.warn(
122
+ `Plugin "RedwoodOpenTelemetry" encountered an AsyncIterator which is not supported yet, so tracing data is not available for the operation.`
123
+ );
124
+ return;
125
+ }
126
+ if (result.data && options.result) {
127
+ executionSpan.setAttribute(
128
+ "graphql.execute.result" /* EXECUTION_RESULT */,
129
+ JSON.stringify(result)
130
+ );
131
+ }
132
+ if (result.errors && result.errors.length > 0) {
133
+ executionSpan.recordException({
134
+ name: "graphql.execute.error" /* EXECUTION_ERROR */,
135
+ message: JSON.stringify(result.errors)
136
+ });
137
+ }
138
+ executionSpan.end();
139
+ }
140
+ };
141
+ if (options.resolvers) {
142
+ extendContext({
143
+ [tracingSpanSymbol]: executionSpan
144
+ });
145
+ }
146
+ return resultCbs;
147
+ }
148
+ );
149
+ }
150
+ };
151
+ };
152
+ // Annotate the CommonJS export names for ESM import in node:
153
+ 0 && (module.exports = {
154
+ AttributeName,
155
+ useRedwoodOpenTelemetry
156
+ });
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from 'graphql-yoga';
2
+ import type { RedwoodGraphQLContext, GraphQLHandlerOptions } from '../types.js';
3
+ /**
4
+ * This Envelop plugin enriches the context on a per-request basis
5
+ * by populating it with the results of a custom function
6
+ * @returns
7
+ */
8
+ export declare const useRedwoodPopulateContext: (populateContextBuilder: NonNullable<GraphQLHandlerOptions["context"]>) => Plugin<RedwoodGraphQLContext>;
9
+ //# sourceMappingURL=useRedwoodPopulateContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRedwoodPopulateContext.d.ts","sourceRoot":"","sources":["../../../src/plugins/useRedwoodPopulateContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,2BACZ,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,KACpE,MAAM,CAAC,qBAAqB,CAW9B,CAAA"}
@@ -0,0 +1,35 @@
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 useRedwoodPopulateContext_exports = {};
20
+ __export(useRedwoodPopulateContext_exports, {
21
+ useRedwoodPopulateContext: () => useRedwoodPopulateContext
22
+ });
23
+ module.exports = __toCommonJS(useRedwoodPopulateContext_exports);
24
+ const useRedwoodPopulateContext = (populateContextBuilder) => {
25
+ return {
26
+ async onContextBuilding({ context, extendContext }) {
27
+ const populateContext = typeof populateContextBuilder === "function" ? await populateContextBuilder({ context }) : populateContextBuilder;
28
+ extendContext(populateContext);
29
+ }
30
+ };
31
+ };
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ useRedwoodPopulateContext
35
+ });
@@ -0,0 +1,23 @@
1
+ import type { UsePersistedOperationsOptions } from '@graphql-yoga/plugin-persisted-operations';
2
+ import type { Plugin } from 'graphql-yoga';
3
+ import type { RedwoodGraphQLContext } from '../types.js';
4
+ export type RedwoodTrustedDocumentOptions = Omit<UsePersistedOperationsOptions, 'getPersistedOperation'> & {
5
+ /**
6
+ * Whether to disable the plugin
7
+ * @default false
8
+ */
9
+ disabled?: boolean;
10
+ /**
11
+ * The store to get the persisted operation hash from
12
+ * Required when the plugin is not disabled
13
+ */
14
+ store?: Readonly<Record<string, string>>;
15
+ } & ({
16
+ disabled: true;
17
+ store?: Readonly<Record<string, string>>;
18
+ } | {
19
+ disabled?: false;
20
+ store: Readonly<Record<string, string>>;
21
+ });
22
+ export declare const useRedwoodTrustedDocuments: (options: RedwoodTrustedDocumentOptions) => Plugin<RedwoodGraphQLContext>;
23
+ //# sourceMappingURL=useRedwoodTrustedDocuments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRedwoodTrustedDocuments.d.ts","sourceRoot":"","sources":["../../../src/plugins/useRedwoodTrustedDocuments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAA;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,6BAA6B,EAC7B,uBAAuB,CACxB,GAAG;IACF;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACzC,GAAG,CACE;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAChE,CAAA;AAoEH,eAAO,MAAM,0BAA0B,YAC5B,6BAA6B,KACrC,MAAM,CAAC,qBAAqB,CA8B9B,CAAA"}
@@ -0,0 +1,80 @@
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 useRedwoodTrustedDocuments_exports = {};
20
+ __export(useRedwoodTrustedDocuments_exports, {
21
+ useRedwoodTrustedDocuments: () => useRedwoodTrustedDocuments
22
+ });
23
+ module.exports = __toCommonJS(useRedwoodTrustedDocuments_exports);
24
+ var import_plugin_persisted_operations = require("@graphql-yoga/plugin-persisted-operations");
25
+ const REDWOOD__AUTH_GET_CURRENT_USER_QUERY = '{"query":"query __REDWOOD__AUTH_GET_CURRENT_USER { redwood { currentUser } }"}';
26
+ const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION = '{"query":"mutation { resyncMailRenderers }"}';
27
+ const CEDAR__STUDIO_TEMPLATE_MUTATION = '{"query":"mutation { resyncMailTemplate }"}';
28
+ const allowRedwoodAuthCurrentUserQuery = async (request) => {
29
+ const headers = request.headers;
30
+ const hasContentType = headers.get("content-type") === "application/json";
31
+ const hasAuthProvider = !!headers.get("auth-provider");
32
+ const hasAuthorization = !!headers.get("authorization");
33
+ const hasAllowedHeaders = hasContentType && hasAuthProvider && hasAuthorization;
34
+ const query = await request.text();
35
+ const hasAllowedQuery = query === REDWOOD__AUTH_GET_CURRENT_USER_QUERY;
36
+ return hasAllowedHeaders && hasAllowedQuery;
37
+ };
38
+ const allowCedarStudioResyncMailMutations = async (request) => {
39
+ const isLocalDevelopment = process.env.NODE_ENV === "development";
40
+ if (!isLocalDevelopment) {
41
+ return false;
42
+ }
43
+ const headers = request.headers;
44
+ const hasContentType = headers.get("content-type") === "application/json";
45
+ const query = await request.text();
46
+ const isAllowedQuery = query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || query === CEDAR__STUDIO_TEMPLATE_MUTATION;
47
+ return hasContentType && isAllowedQuery;
48
+ };
49
+ const useRedwoodTrustedDocuments = (options) => {
50
+ return (0, import_plugin_persisted_operations.usePersistedOperations)({
51
+ ...options,
52
+ customErrors: {
53
+ persistedQueryOnly: "Use Trusted Only!",
54
+ ...options.customErrors
55
+ },
56
+ getPersistedOperation(sha256Hash) {
57
+ return options.store ? options.store[sha256Hash] : null;
58
+ },
59
+ allowArbitraryOperations: async (request) => {
60
+ if (options.allowArbitraryOperations !== void 0) {
61
+ if (typeof options.allowArbitraryOperations === "boolean") {
62
+ if (options.allowArbitraryOperations) {
63
+ return true;
64
+ }
65
+ }
66
+ if (typeof options.allowArbitraryOperations === "function") {
67
+ const result = await options.allowArbitraryOperations(request);
68
+ if (result === true) {
69
+ return true;
70
+ }
71
+ }
72
+ }
73
+ return allowRedwoodAuthCurrentUserQuery(request) || allowCedarStudioResyncMailMutations(request);
74
+ }
75
+ });
76
+ };
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ useRedwoodTrustedDocuments
80
+ });
@@ -0,0 +1,25 @@
1
+ import { BigIntResolver, DateResolver, TimeResolver, DateTimeResolver, JSONResolver, JSONObjectResolver, ByteResolver } from 'graphql-scalars';
2
+ /**
3
+ * This adds scalar types for dealing with Date, Time, DateTime, and JSON.
4
+ * This also adds a root Query type which is needed to start the GraphQL server on a fresh install.
5
+ *
6
+ * NOTE: When you add a new Scalar type you must add it to
7
+ * "generateTypeDefGraphQL" in @cedarjs/internal.
8
+ */
9
+ export declare const schema: import("graphql").DocumentNode;
10
+ export declare const scalarSchemas: {
11
+ File: import("graphql").DocumentNode;
12
+ };
13
+ export type ScalarSchemaKeys = keyof typeof scalarSchemas;
14
+ export interface Resolvers {
15
+ BigInt: typeof BigIntResolver;
16
+ Date: typeof DateResolver;
17
+ Time: typeof TimeResolver;
18
+ DateTime: typeof DateTimeResolver;
19
+ JSON: typeof JSONResolver;
20
+ JSONObject: typeof JSONObjectResolver;
21
+ Query: Record<string, unknown>;
22
+ Byte: typeof ByteResolver;
23
+ }
24
+ export declare const resolvers: Resolvers;
25
+ //# sourceMappingURL=rootSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootSchema.d.ts","sourceRoot":"","sources":["../../src/rootSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACb,MAAM,iBAAiB,CAAA;AAMxB;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,gCAgClB,CAAA;AAED,eAAO,MAAM,aAAa;;CAIzB,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,aAAa,CAAA;AAEzD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,cAAc,CAAA;IAC7B,IAAI,EAAE,OAAO,YAAY,CAAA;IACzB,IAAI,EAAE,OAAO,YAAY,CAAA;IACzB,QAAQ,EAAE,OAAO,gBAAgB,CAAA;IACjC,IAAI,EAAE,OAAO,YAAY,CAAA;IACzB,UAAU,EAAE,OAAO,kBAAkB,CAAA;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,IAAI,EAAE,OAAO,YAAY,CAAA;CAC1B;AAED,eAAO,MAAM,SAAS,EAAE,SAwBvB,CAAA"}
@@ -0,0 +1,97 @@
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 rootSchema_exports = {};
20
+ __export(rootSchema_exports, {
21
+ resolvers: () => resolvers,
22
+ scalarSchemas: () => scalarSchemas,
23
+ schema: () => schema
24
+ });
25
+ module.exports = __toCommonJS(rootSchema_exports);
26
+ var import_graphql_scalars = require("graphql-scalars");
27
+ var import_graphql_tag = require("graphql-tag");
28
+ var import_api = require("@cedarjs/api");
29
+ const schema = import_graphql_tag.gql`
30
+ scalar BigInt
31
+ scalar Date
32
+ scalar Time
33
+ scalar DateTime
34
+ scalar JSON
35
+ scalar JSONObject
36
+ scalar Byte
37
+
38
+ """
39
+ The Cedar Root Schema
40
+
41
+ Defines details about Cedar such as the current user and version information.
42
+ """
43
+ type Redwood {
44
+ "The version of CedarJS."
45
+ version: String
46
+ "The current user."
47
+ currentUser: JSON
48
+ "The version of Prisma."
49
+ prismaVersion: String
50
+ }
51
+
52
+ """
53
+ About the Redwood queries.
54
+ """
55
+ type Query {
56
+ "Fetches the Redwood root schema."
57
+ redwood: Redwood
58
+ "Fetches the CedarJS root schema."
59
+ cedarjs: Redwood
60
+ }
61
+ `;
62
+ const scalarSchemas = {
63
+ File: import_graphql_tag.gql`
64
+ scalar File
65
+ `
66
+ };
67
+ const resolvers = {
68
+ BigInt: import_graphql_scalars.BigIntResolver,
69
+ Date: import_graphql_scalars.DateResolver,
70
+ Time: import_graphql_scalars.TimeResolver,
71
+ DateTime: import_graphql_scalars.DateTimeResolver,
72
+ JSON: import_graphql_scalars.JSONResolver,
73
+ JSONObject: import_graphql_scalars.JSONObjectResolver,
74
+ Query: {
75
+ redwood: () => ({
76
+ version: import_api.redwoodVersion,
77
+ prismaVersion: import_api.prismaVersion,
78
+ currentUser: (_args, context) => {
79
+ return context?.currentUser;
80
+ }
81
+ }),
82
+ cedarjs: () => ({
83
+ version: import_api.cedarjsVersion,
84
+ prismaVersion: import_api.prismaVersion,
85
+ currentUser: (_args, context) => {
86
+ return context?.currentUser;
87
+ }
88
+ })
89
+ },
90
+ Byte: import_graphql_scalars.ByteResolver
91
+ };
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ resolvers,
95
+ scalarSchemas,
96
+ schema
97
+ });
@@ -0,0 +1,18 @@
1
+ import type { DocumentNode } from 'graphql';
2
+ /**
3
+ * We want SubscriptionsGlobs type to be an object with this shape:
4
+ *
5
+ * But not fully supported in TS
6
+ * {
7
+ * schema: DocumentNode // <-- required
8
+ * [string]: RedwoodSubscription
9
+ * }
10
+ */
11
+ export type SubscriptionGlobImports = Record<string, any>;
12
+ export type RedwoodSubscription = {
13
+ schema: DocumentNode;
14
+ resolvers: any;
15
+ name: string;
16
+ };
17
+ export declare const makeSubscriptions: (SubscriptionGlobs: SubscriptionGlobImports) => RedwoodSubscription[];
18
+ //# sourceMappingURL=makeSubscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeSubscriptions.d.ts","sourceRoot":"","sources":["../../../src/subscriptions/makeSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,GAAG,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,iBAAiB,sBACT,uBAAuB,KACzC,mBAAmB,EAmBrB,CAAA"}
@@ -0,0 +1,40 @@
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 makeSubscriptions_exports = {};
20
+ __export(makeSubscriptions_exports, {
21
+ makeSubscriptions: () => makeSubscriptions
22
+ });
23
+ module.exports = __toCommonJS(makeSubscriptions_exports);
24
+ const makeSubscriptions = (SubscriptionGlobs) => {
25
+ return Object.entries(SubscriptionGlobs).flatMap(
26
+ ([importedGlobName, exports2]) => {
27
+ const [SubscriptionNameFromFile] = importedGlobName.split("_").slice(-2);
28
+ const subscription = {
29
+ schema: exports2.schema,
30
+ resolvers: exports2[SubscriptionNameFromFile] || exports2.default,
31
+ name: SubscriptionNameFromFile
32
+ };
33
+ return [subscription];
34
+ }
35
+ );
36
+ };
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ makeSubscriptions
40
+ });