@cedarjs/internal 5.0.3 → 5.0.4-next.167

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 (143) hide show
  1. package/dist/ast.d.ts +1 -0
  2. package/dist/ast.d.ts.map +1 -1
  3. package/dist/ast.js +21 -0
  4. package/dist/build/api-graphql-transforms.d.ts +34 -0
  5. package/dist/build/api-graphql-transforms.d.ts.map +1 -0
  6. package/dist/build/api-graphql-transforms.js +119 -0
  7. package/dist/build/api.d.ts +2 -0
  8. package/dist/build/api.d.ts.map +1 -1
  9. package/dist/build/api.js +202 -39
  10. package/dist/build/auto-import.d.ts +10 -0
  11. package/dist/build/auto-import.d.ts.map +1 -0
  12. package/dist/build/auto-import.js +120 -0
  13. package/dist/build/directory-named-import.d.ts +2 -0
  14. package/dist/build/directory-named-import.d.ts.map +1 -0
  15. package/dist/build/directory-named-import.js +26 -0
  16. package/dist/build/esbuild-plugin-api-graphql.d.ts +6 -0
  17. package/dist/build/esbuild-plugin-api-graphql.d.ts.map +1 -0
  18. package/dist/build/esbuild-plugin-api-graphql.js +80 -0
  19. package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts +13 -0
  20. package/dist/build/esbuild-plugin-cedar-otel-wrapping.d.ts.map +1 -0
  21. package/dist/build/esbuild-plugin-cedar-otel-wrapping.js +180 -0
  22. package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts +4 -0
  23. package/dist/build/esbuild-plugin-handler-als-wrapping.d.ts.map +1 -0
  24. package/dist/build/{esbuild-plugin-cedar-context-wrapping.js → esbuild-plugin-handler-als-wrapping.js} +12 -12
  25. package/dist/build/esm-extensions.d.ts +33 -0
  26. package/dist/build/esm-extensions.d.ts.map +1 -0
  27. package/dist/build/esm-extensions.js +37 -0
  28. package/dist/build/import-dir.d.ts +22 -0
  29. package/dist/build/import-dir.d.ts.map +1 -0
  30. package/dist/build/import-dir.js +54 -0
  31. package/dist/build/job-path-injector.d.ts +15 -0
  32. package/dist/build/job-path-injector.d.ts.map +1 -0
  33. package/dist/build/job-path-injector.js +69 -0
  34. package/dist/build/src-alias.d.ts +14 -0
  35. package/dist/build/src-alias.d.ts.map +1 -0
  36. package/dist/build/src-alias.js +17 -0
  37. package/dist/build/tsconfig-paths.d.ts +2 -0
  38. package/dist/build/tsconfig-paths.d.ts.map +1 -0
  39. package/dist/build/tsconfig-paths.js +72 -0
  40. package/dist/generate/clientPreset.d.ts.map +1 -1
  41. package/dist/generate/clientPreset.js +10 -3
  42. package/dist/generate/templates/mirror-cell-fragment.d.ts.template +18 -0
  43. package/dist/generate/typeDefinitions.d.ts.map +1 -1
  44. package/dist/generate/typeDefinitions.js +15 -1
  45. package/dist/gql.d.ts +20 -0
  46. package/dist/gql.d.ts.map +1 -1
  47. package/dist/gql.js +24 -0
  48. package/package.json +48 -80
  49. package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
  50. package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
  51. package/dist/cjs/ast.d.ts +0 -26
  52. package/dist/cjs/ast.d.ts.map +0 -1
  53. package/dist/cjs/ast.js +0 -201
  54. package/dist/cjs/build/api.d.ts +0 -7
  55. package/dist/cjs/build/api.d.ts.map +0 -1
  56. package/dist/cjs/build/api.js +0 -251
  57. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
  58. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
  59. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.js +0 -59
  60. package/dist/cjs/cliLogger.d.ts +0 -11
  61. package/dist/cjs/cliLogger.d.ts.map +0 -1
  62. package/dist/cjs/cliLogger.js +0 -36
  63. package/dist/cjs/dev.d.ts +0 -2
  64. package/dist/cjs/dev.d.ts.map +0 -1
  65. package/dist/cjs/dev.js +0 -41
  66. package/dist/cjs/files.d.ts +0 -56
  67. package/dist/cjs/files.d.ts.map +0 -1
  68. package/dist/cjs/files.js +0 -230
  69. package/dist/cjs/generate/clientPreset.d.ts +0 -17
  70. package/dist/cjs/generate/clientPreset.d.ts.map +0 -1
  71. package/dist/cjs/generate/clientPreset.js +0 -84
  72. package/dist/cjs/generate/generate.d.ts +0 -10
  73. package/dist/cjs/generate/generate.d.ts.map +0 -1
  74. package/dist/cjs/generate/generate.js +0 -97
  75. package/dist/cjs/generate/gqlormSchema.d.ts +0 -113
  76. package/dist/cjs/generate/gqlormSchema.d.ts.map +0 -1
  77. package/dist/cjs/generate/gqlormSchema.js +0 -1061
  78. package/dist/cjs/generate/graphqlCodeGen.d.ts +0 -16
  79. package/dist/cjs/generate/graphqlCodeGen.d.ts.map +0 -1
  80. package/dist/cjs/generate/graphqlCodeGen.js +0 -380
  81. package/dist/cjs/generate/graphqlSchema.d.ts +0 -8
  82. package/dist/cjs/generate/graphqlSchema.d.ts.map +0 -1
  83. package/dist/cjs/generate/graphqlSchema.js +0 -157
  84. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +0 -7
  85. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +0 -1
  86. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +0 -65
  87. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +0 -10
  88. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +0 -1
  89. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +0 -92
  90. package/dist/cjs/generate/possibleTypes.d.ts +0 -36
  91. package/dist/cjs/generate/possibleTypes.d.ts.map +0 -1
  92. package/dist/cjs/generate/possibleTypes.js +0 -106
  93. package/dist/cjs/generate/templates/all-currentUser.d.ts.template +0 -30
  94. package/dist/cjs/generate/templates/all-gqlorm.d.ts.template +0 -7
  95. package/dist/cjs/generate/templates/api-globImports.d.ts.template +0 -9
  96. package/dist/cjs/generate/templates/api-globalContext.d.ts.template +0 -7
  97. package/dist/cjs/generate/templates/api-scenarios.d.ts.template +0 -10
  98. package/dist/cjs/generate/templates/api-test-globals.d.ts.template +0 -5
  99. package/dist/cjs/generate/templates/mirror-cell.d.ts.template +0 -13
  100. package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +0 -5
  101. package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +0 -20
  102. package/dist/cjs/generate/templates/web-routesPages.d.ts.template +0 -13
  103. package/dist/cjs/generate/templates/web-test-globals.d.ts.template +0 -7
  104. package/dist/cjs/generate/templates.d.ts +0 -6
  105. package/dist/cjs/generate/templates.d.ts.map +0 -1
  106. package/dist/cjs/generate/templates.js +0 -68
  107. package/dist/cjs/generate/trustedDocuments.d.ts +0 -3
  108. package/dist/cjs/generate/trustedDocuments.d.ts.map +0 -1
  109. package/dist/cjs/generate/trustedDocuments.js +0 -95
  110. package/dist/cjs/generate/typeDefinitions.d.ts +0 -31
  111. package/dist/cjs/generate/typeDefinitions.d.ts.map +0 -1
  112. package/dist/cjs/generate/typeDefinitions.js +0 -372
  113. package/dist/cjs/generate/types.d.ts +0 -6
  114. package/dist/cjs/generate/types.d.ts.map +0 -1
  115. package/dist/cjs/generate/types.js +0 -16
  116. package/dist/cjs/generate/watch.d.ts +0 -3
  117. package/dist/cjs/generate/watch.d.ts.map +0 -1
  118. package/dist/cjs/generate/watch.js +0 -132
  119. package/dist/cjs/gql.d.ts +0 -14
  120. package/dist/cjs/gql.d.ts.map +0 -1
  121. package/dist/cjs/gql.js +0 -108
  122. package/dist/cjs/index.d.ts +0 -11
  123. package/dist/cjs/index.d.ts.map +0 -1
  124. package/dist/cjs/index.js +0 -49
  125. package/dist/cjs/jsx.d.ts +0 -16
  126. package/dist/cjs/jsx.d.ts.map +0 -1
  127. package/dist/cjs/jsx.js +0 -101
  128. package/dist/cjs/jsxAttributeValue.d.ts +0 -2
  129. package/dist/cjs/jsxAttributeValue.d.ts.map +0 -1
  130. package/dist/cjs/jsxAttributeValue.js +0 -129
  131. package/dist/cjs/package.json +0 -1
  132. package/dist/cjs/project.d.ts +0 -8
  133. package/dist/cjs/project.d.ts.map +0 -1
  134. package/dist/cjs/project.js +0 -82
  135. package/dist/cjs/routes.d.ts +0 -42
  136. package/dist/cjs/routes.d.ts.map +0 -1
  137. package/dist/cjs/routes.js +0 -111
  138. package/dist/cjs/ts2js.d.ts +0 -40
  139. package/dist/cjs/ts2js.d.ts.map +0 -1
  140. package/dist/cjs/ts2js.js +0 -159
  141. package/dist/cjs/validateSchema.d.ts +0 -14
  142. package/dist/cjs/validateSchema.d.ts.map +0 -1
  143. package/dist/cjs/validateSchema.js +0 -195
package/dist/cjs/ts2js.js DELETED
@@ -1,159 +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 ts2js_exports = {};
30
- __export(ts2js_exports, {
31
- convertTsFilesToJs: () => convertTsFilesToJs,
32
- convertTsProjectToJs: () => convertTsProjectToJs,
33
- convertTsScriptsToJs: () => convertTsScriptsToJs,
34
- getPrettierConfig: () => getPrettierConfig,
35
- prettify: () => prettify,
36
- transformTSToJS: () => transformTSToJS,
37
- typeScriptSourceFiles: () => typeScriptSourceFiles
38
- });
39
- module.exports = __toCommonJS(ts2js_exports);
40
- var import_node_fs = __toESM(require("node:fs"), 1);
41
- var import_path = __toESM(require("path"), 1);
42
- var import_core = require("@babel/core");
43
- var import_fast_glob = __toESM(require("fast-glob"), 1);
44
- var import_prettier = require("prettier");
45
- var import_project_config = require("@cedarjs/project-config");
46
- const convertTsProjectToJs = (cwd = (0, import_project_config.getPaths)().base) => {
47
- const files = typeScriptSourceFiles(cwd);
48
- convertTsFilesToJs(cwd, files);
49
- };
50
- const convertTsScriptsToJs = (cwd = (0, import_project_config.getPaths)().base) => {
51
- const files = typeScriptSourceFiles(cwd, "scripts/*.{ts,tsx}");
52
- convertTsFilesToJs(cwd, files);
53
- };
54
- const convertTsFilesToJs = async (cwd, files) => {
55
- if (files.length === 0) {
56
- console.log("No TypeScript files found to convert to JS in this project.");
57
- }
58
- for (const f of files) {
59
- const code = await transformTSToJS(f);
60
- if (code) {
61
- import_node_fs.default.writeFileSync(
62
- import_path.default.join(cwd, f.replace(".tsx", ".jsx").replace(".ts", ".js")),
63
- code,
64
- "utf8"
65
- );
66
- import_node_fs.default.unlinkSync(import_path.default.join(cwd, f));
67
- }
68
- }
69
- if (import_node_fs.default.existsSync(import_path.default.join(cwd, "api/tsconfig.json"))) {
70
- import_node_fs.default.renameSync(
71
- import_path.default.join(cwd, "api/tsconfig.json"),
72
- import_path.default.join(cwd, "api/jsconfig.json")
73
- );
74
- }
75
- if (import_node_fs.default.existsSync(import_path.default.join(cwd, "web/tsconfig.json"))) {
76
- import_node_fs.default.renameSync(
77
- import_path.default.join(cwd, "web/tsconfig.json"),
78
- import_path.default.join(cwd, "web/jsconfig.json")
79
- );
80
- }
81
- if (import_node_fs.default.existsSync(import_path.default.join(cwd, "scripts/tsconfig.json"))) {
82
- import_node_fs.default.renameSync(
83
- import_path.default.join(cwd, "scripts/tsconfig.json"),
84
- import_path.default.join(cwd, "scripts/jsconfig.json")
85
- );
86
- }
87
- };
88
- const typeScriptSourceFiles = (cwd, globPattern = "{api,web}/src/**/*.{ts,tsx}") => {
89
- console.log(globPattern);
90
- return import_fast_glob.default.sync(globPattern, {
91
- cwd,
92
- ignore: ["node_modules"]
93
- });
94
- };
95
- const transformTSToJS = (file) => {
96
- const tsCode = import_node_fs.default.readFileSync(file, "utf8");
97
- const filename = import_path.default.basename(file);
98
- const result = (0, import_core.transform)(tsCode, {
99
- filename,
100
- cwd: (0, import_project_config.getPaths)().base,
101
- configFile: false,
102
- plugins: [
103
- [
104
- "@babel/plugin-transform-typescript",
105
- {
106
- isTSX: true,
107
- allExtensions: true
108
- }
109
- ]
110
- ],
111
- retainLines: true
112
- });
113
- if (!result?.code) {
114
- return void 0;
115
- }
116
- return prettify(result.code, filename.replace(/\.ts$/, ".js"));
117
- };
118
- const getPrettierConfig = async () => {
119
- try {
120
- const { default: prettierConfig } = await import(`file://${import_path.default.join((0, import_project_config.getPaths)().base, "prettier.config.cjs")}`);
121
- return prettierConfig;
122
- } catch {
123
- return void 0;
124
- }
125
- };
126
- const prettierParser = (filename) => {
127
- switch (import_path.default.extname(filename.replace(".template", ""))) {
128
- case ".css":
129
- return "css";
130
- case ".js":
131
- return "babel";
132
- case ".ts":
133
- case ".tsx":
134
- return "babel-ts";
135
- default:
136
- return void 0;
137
- }
138
- };
139
- const prettify = async (code, filename) => {
140
- const parser = prettierParser(filename);
141
- if (typeof parser === "undefined") {
142
- return code;
143
- }
144
- const prettierConfig = await getPrettierConfig();
145
- return (0, import_prettier.format)(code, {
146
- ...prettierConfig,
147
- parser
148
- });
149
- };
150
- // Annotate the CommonJS export names for ESM import in node:
151
- 0 && (module.exports = {
152
- convertTsFilesToJs,
153
- convertTsProjectToJs,
154
- convertTsScriptsToJs,
155
- getPrettierConfig,
156
- prettify,
157
- transformTSToJS,
158
- typeScriptSourceFiles
159
- });
@@ -1,14 +0,0 @@
1
- import type { DocumentNode } from 'graphql';
2
- export declare const DIRECTIVE_REQUIRED_ERROR_MESSAGE = "You must specify one of @requireAuth, @skipAuth or a custom directive";
3
- export declare const DIRECTIVE_INVALID_ROLE_TYPES_ERROR_MESSAGE = "Please check that the requireAuth roles is a string or an array of strings.";
4
- /**
5
- * These are names that are commonly used in GraphQL schemas as scalars
6
- * and would cause a conflict if used as a type name.
7
- *
8
- * Note: Query, Mutation, and Subscription are not included here because
9
- * they are checked for separately.
10
- */
11
- export declare const RESERVED_TYPES: string[];
12
- export declare function validateSchema(schemaDocumentNode: DocumentNode, typesToCheck?: string[]): void;
13
- export declare const loadAndValidateSdls: () => Promise<void>;
14
- //# sourceMappingURL=validateSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateSchema.d.ts","sourceRoot":"","sources":["../../src/validateSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAA4B,MAAM,SAAS,CAAA;AAQrE,eAAO,MAAM,gCAAgC,0EAC4B,CAAA;AAEzE,eAAO,MAAM,0CAA0C,gFACwB,CAAA;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,UAS1B,CAAA;AAED,wBAAgB,cAAc,CAC5B,kBAAkB,EAAE,YAAY,EAChC,YAAY,GAAE,MAAM,EAA0B,QAwI/C;AAED,eAAO,MAAM,mBAAmB,qBAkC/B,CAAA"}
@@ -1,195 +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 validateSchema_exports = {};
20
- __export(validateSchema_exports, {
21
- DIRECTIVE_INVALID_ROLE_TYPES_ERROR_MESSAGE: () => DIRECTIVE_INVALID_ROLE_TYPES_ERROR_MESSAGE,
22
- DIRECTIVE_REQUIRED_ERROR_MESSAGE: () => DIRECTIVE_REQUIRED_ERROR_MESSAGE,
23
- RESERVED_TYPES: () => RESERVED_TYPES,
24
- loadAndValidateSdls: () => loadAndValidateSdls,
25
- validateSchema: () => validateSchema
26
- });
27
- module.exports = __toCommonJS(validateSchema_exports);
28
- var import_code_file_loader = require("@graphql-tools/code-file-loader");
29
- var import_load = require("@graphql-tools/load");
30
- var import_merge = require("@graphql-tools/merge");
31
- var import_graphql = require("graphql");
32
- var import_graphql_server = require("@cedarjs/graphql-server");
33
- var import_project_config = require("@cedarjs/project-config");
34
- var import_project = require("./project.js");
35
- const DIRECTIVE_REQUIRED_ERROR_MESSAGE = "You must specify one of @requireAuth, @skipAuth or a custom directive";
36
- const DIRECTIVE_INVALID_ROLE_TYPES_ERROR_MESSAGE = "Please check that the requireAuth roles is a string or an array of strings.";
37
- const RESERVED_TYPES = [
38
- "Int",
39
- "Float",
40
- "Boolean",
41
- "String",
42
- "DateTime",
43
- "ID",
44
- "uid",
45
- "as"
46
- ];
47
- function validateSchema(schemaDocumentNode, typesToCheck = ["Query", "Mutation"]) {
48
- const validationOutput = [];
49
- const reservedNameValidationOutput = [];
50
- const directiveRoleValidationOutput = [];
51
- if ((0, import_project.isServerFileSetup)() && (0, import_project.isRealtimeSetup)()) {
52
- typesToCheck.push("Subscription");
53
- }
54
- (0, import_graphql.visit)(schemaDocumentNode, {
55
- InterfaceTypeDefinition(typeNode) {
56
- if (RESERVED_TYPES.includes(typeNode.name.value)) {
57
- reservedNameValidationOutput.push({
58
- objectType: "interface",
59
- name: typeNode.name.value
60
- });
61
- }
62
- },
63
- InputObjectTypeDefinition(typeNode) {
64
- if (RESERVED_TYPES.includes(typeNode.name.value)) {
65
- reservedNameValidationOutput.push({
66
- objectType: "input type",
67
- name: typeNode.name.value
68
- });
69
- }
70
- },
71
- ObjectTypeDefinition(typeNode) {
72
- if (RESERVED_TYPES.includes(typeNode.name.value)) {
73
- reservedNameValidationOutput.push({
74
- objectType: "type",
75
- name: typeNode.name.value
76
- });
77
- }
78
- if (typesToCheck.includes(typeNode.name.value)) {
79
- for (const field of typeNode.fields || []) {
80
- const fieldName = field.name.value;
81
- const fieldTypeName = typeNode.name.value;
82
- const isLegacyRedwoodQuery = fieldName === "redwood" && fieldTypeName === "Query";
83
- const isCedarQuery = fieldName === "cedar" && fieldTypeName === "Query" || // TODO: Remove this when I remove the root schema
84
- fieldName === "cedarjs" && fieldTypeName === "Query";
85
- const isCurrentUserQuery = fieldName === "currentUser" && fieldTypeName === "Query";
86
- if (!(isCedarQuery || isCurrentUserQuery || isLegacyRedwoodQuery)) {
87
- const hasDirective = field.directives?.length;
88
- if (!hasDirective) {
89
- validationOutput.push(`${fieldName} ${fieldTypeName}`);
90
- }
91
- field.directives?.forEach((directive) => {
92
- if (directive.name.value === "requireAuth") {
93
- directive.arguments?.forEach((arg) => {
94
- if (arg.name.value === "roles") {
95
- if (arg.value.kind !== import_graphql.Kind.STRING && arg.value.kind !== import_graphql.Kind.LIST) {
96
- directiveRoleValidationOutput.push({
97
- fieldName,
98
- invalid: arg.value.kind
99
- });
100
- }
101
- if (arg.value.kind === import_graphql.Kind.LIST) {
102
- const invalidValues = arg.value.values?.filter(
103
- (val) => val.kind !== import_graphql.Kind.STRING
104
- );
105
- if (invalidValues.length > 0) {
106
- invalidValues.forEach((invalid) => {
107
- directiveRoleValidationOutput.push({
108
- fieldName,
109
- invalid: invalid.kind
110
- });
111
- });
112
- }
113
- }
114
- }
115
- });
116
- }
117
- });
118
- }
119
- }
120
- }
121
- }
122
- });
123
- if (validationOutput.length > 0) {
124
- const fieldsWithoutDirectives = validationOutput.map(
125
- (field) => `- ${field}`
126
- );
127
- throw new Error(
128
- `${DIRECTIVE_REQUIRED_ERROR_MESSAGE} for
129
- ${fieldsWithoutDirectives.join(
130
- "\n"
131
- )}
132
- `
133
- );
134
- }
135
- if (directiveRoleValidationOutput.length > 0) {
136
- const fieldWithInvalidRoleValues = directiveRoleValidationOutput.map(
137
- (field) => `- ${field.fieldName} has an invalid ${field.invalid}`
138
- );
139
- throw new RangeError(
140
- `${DIRECTIVE_INVALID_ROLE_TYPES_ERROR_MESSAGE}
141
-
142
- ${fieldWithInvalidRoleValues.join(
143
- "\n"
144
- )}
145
-
146
- For example: @requireAuth(roles: "admin") or @requireAuth(roles: ["admin", "editor"])`
147
- );
148
- }
149
- if (reservedNameValidationOutput.length > 0) {
150
- const reservedNameMsg = reservedNameValidationOutput.map(
151
- (output) => {
152
- return `The ${output.objectType} named '${output.name}' is a reserved GraphQL name.
153
- Please rename it to something more specific, like: Application${output.name}.
154
- `;
155
- }
156
- );
157
- throw new TypeError(reservedNameMsg.join("\n"));
158
- }
159
- }
160
- const loadAndValidateSdls = async () => {
161
- const projectTypeSrc = await (0, import_load.loadTypedefs)(
162
- [
163
- "graphql/**/*.sdl.{js,ts}",
164
- "directives/**/*.{js,ts}",
165
- "subscriptions/**/*.{js,ts}"
166
- ],
167
- {
168
- loaders: [
169
- new import_code_file_loader.CodeFileLoader({
170
- noRequire: true,
171
- pluckConfig: {
172
- globalGqlIdentifierName: "gql"
173
- }
174
- })
175
- ],
176
- cwd: (0, import_project_config.getPaths)().api.src
177
- }
178
- );
179
- const projectDocumentNodes = Object.values(projectTypeSrc).map(({ document }) => document).filter((documentNode) => {
180
- return !!documentNode;
181
- });
182
- const mergedDocumentNode = (0, import_merge.mergeTypeDefs)([
183
- import_graphql_server.rootSchema.schema,
184
- projectDocumentNodes
185
- ]);
186
- validateSchema(mergedDocumentNode);
187
- };
188
- // Annotate the CommonJS export names for ESM import in node:
189
- 0 && (module.exports = {
190
- DIRECTIVE_INVALID_ROLE_TYPES_ERROR_MESSAGE,
191
- DIRECTIVE_REQUIRED_ERROR_MESSAGE,
192
- RESERVED_TYPES,
193
- loadAndValidateSdls,
194
- validateSchema
195
- });