@cedarjs/internal 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.
Files changed (148) 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 +129 -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/graphqlSchema.d.ts.map +1 -1
  43. package/dist/generate/templates/mirror-cell-fragment.d.ts.template +18 -0
  44. package/dist/generate/templates.d.ts.map +1 -1
  45. package/dist/generate/templates.js +1 -6
  46. package/dist/generate/typeDefinitions.d.ts.map +1 -1
  47. package/dist/generate/typeDefinitions.js +15 -1
  48. package/dist/gql.d.ts +20 -0
  49. package/dist/gql.d.ts.map +1 -1
  50. package/dist/gql.js +24 -0
  51. package/dist/jsx.d.ts.map +1 -1
  52. package/dist/routes.d.ts.map +1 -1
  53. package/package.json +52 -88
  54. package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
  55. package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
  56. package/dist/cjs/ast.d.ts +0 -26
  57. package/dist/cjs/ast.d.ts.map +0 -1
  58. package/dist/cjs/ast.js +0 -201
  59. package/dist/cjs/build/api.d.ts +0 -7
  60. package/dist/cjs/build/api.d.ts.map +0 -1
  61. package/dist/cjs/build/api.js +0 -251
  62. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +0 -4
  63. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +0 -1
  64. package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.js +0 -59
  65. package/dist/cjs/cliLogger.d.ts +0 -11
  66. package/dist/cjs/cliLogger.d.ts.map +0 -1
  67. package/dist/cjs/cliLogger.js +0 -36
  68. package/dist/cjs/dev.d.ts +0 -2
  69. package/dist/cjs/dev.d.ts.map +0 -1
  70. package/dist/cjs/dev.js +0 -41
  71. package/dist/cjs/files.d.ts +0 -56
  72. package/dist/cjs/files.d.ts.map +0 -1
  73. package/dist/cjs/files.js +0 -230
  74. package/dist/cjs/generate/clientPreset.d.ts +0 -17
  75. package/dist/cjs/generate/clientPreset.d.ts.map +0 -1
  76. package/dist/cjs/generate/clientPreset.js +0 -84
  77. package/dist/cjs/generate/generate.d.ts +0 -10
  78. package/dist/cjs/generate/generate.d.ts.map +0 -1
  79. package/dist/cjs/generate/generate.js +0 -97
  80. package/dist/cjs/generate/gqlormSchema.d.ts +0 -113
  81. package/dist/cjs/generate/gqlormSchema.d.ts.map +0 -1
  82. package/dist/cjs/generate/gqlormSchema.js +0 -1061
  83. package/dist/cjs/generate/graphqlCodeGen.d.ts +0 -16
  84. package/dist/cjs/generate/graphqlCodeGen.d.ts.map +0 -1
  85. package/dist/cjs/generate/graphqlCodeGen.js +0 -380
  86. package/dist/cjs/generate/graphqlSchema.d.ts +0 -8
  87. package/dist/cjs/generate/graphqlSchema.d.ts.map +0 -1
  88. package/dist/cjs/generate/graphqlSchema.js +0 -157
  89. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +0 -7
  90. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +0 -1
  91. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +0 -65
  92. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +0 -10
  93. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +0 -1
  94. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +0 -92
  95. package/dist/cjs/generate/possibleTypes.d.ts +0 -36
  96. package/dist/cjs/generate/possibleTypes.d.ts.map +0 -1
  97. package/dist/cjs/generate/possibleTypes.js +0 -106
  98. package/dist/cjs/generate/templates/all-currentUser.d.ts.template +0 -30
  99. package/dist/cjs/generate/templates/all-gqlorm.d.ts.template +0 -7
  100. package/dist/cjs/generate/templates/api-globImports.d.ts.template +0 -9
  101. package/dist/cjs/generate/templates/api-globalContext.d.ts.template +0 -7
  102. package/dist/cjs/generate/templates/api-scenarios.d.ts.template +0 -10
  103. package/dist/cjs/generate/templates/api-test-globals.d.ts.template +0 -5
  104. package/dist/cjs/generate/templates/mirror-cell.d.ts.template +0 -13
  105. package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +0 -5
  106. package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +0 -20
  107. package/dist/cjs/generate/templates/web-routesPages.d.ts.template +0 -13
  108. package/dist/cjs/generate/templates/web-test-globals.d.ts.template +0 -7
  109. package/dist/cjs/generate/templates.d.ts +0 -6
  110. package/dist/cjs/generate/templates.d.ts.map +0 -1
  111. package/dist/cjs/generate/templates.js +0 -68
  112. package/dist/cjs/generate/trustedDocuments.d.ts +0 -3
  113. package/dist/cjs/generate/trustedDocuments.d.ts.map +0 -1
  114. package/dist/cjs/generate/trustedDocuments.js +0 -95
  115. package/dist/cjs/generate/typeDefinitions.d.ts +0 -31
  116. package/dist/cjs/generate/typeDefinitions.d.ts.map +0 -1
  117. package/dist/cjs/generate/typeDefinitions.js +0 -372
  118. package/dist/cjs/generate/types.d.ts +0 -6
  119. package/dist/cjs/generate/types.d.ts.map +0 -1
  120. package/dist/cjs/generate/types.js +0 -16
  121. package/dist/cjs/generate/watch.d.ts +0 -3
  122. package/dist/cjs/generate/watch.d.ts.map +0 -1
  123. package/dist/cjs/generate/watch.js +0 -132
  124. package/dist/cjs/gql.d.ts +0 -14
  125. package/dist/cjs/gql.d.ts.map +0 -1
  126. package/dist/cjs/gql.js +0 -108
  127. package/dist/cjs/index.d.ts +0 -11
  128. package/dist/cjs/index.d.ts.map +0 -1
  129. package/dist/cjs/index.js +0 -49
  130. package/dist/cjs/jsx.d.ts +0 -16
  131. package/dist/cjs/jsx.d.ts.map +0 -1
  132. package/dist/cjs/jsx.js +0 -101
  133. package/dist/cjs/jsxAttributeValue.d.ts +0 -2
  134. package/dist/cjs/jsxAttributeValue.d.ts.map +0 -1
  135. package/dist/cjs/jsxAttributeValue.js +0 -129
  136. package/dist/cjs/package.json +0 -1
  137. package/dist/cjs/project.d.ts +0 -8
  138. package/dist/cjs/project.d.ts.map +0 -1
  139. package/dist/cjs/project.js +0 -82
  140. package/dist/cjs/routes.d.ts +0 -42
  141. package/dist/cjs/routes.d.ts.map +0 -1
  142. package/dist/cjs/routes.js +0 -111
  143. package/dist/cjs/ts2js.d.ts +0 -40
  144. package/dist/cjs/ts2js.d.ts.map +0 -1
  145. package/dist/cjs/ts2js.js +0 -159
  146. package/dist/cjs/validateSchema.d.ts +0 -14
  147. package/dist/cjs/validateSchema.d.ts.map +0 -1
  148. package/dist/cjs/validateSchema.js +0 -195
@@ -1,56 +0,0 @@
1
- import { type Options as FastGlobOptions } from 'fast-glob';
2
- export declare const findCells: (cwd?: string) => string[];
3
- export declare const findPages: (cwd?: string) => string[];
4
- /**
5
- * This function finds all modules in the 'web' and 'api' directories excluding 'node_modules' and Cell files.
6
- * Cell files are also directory named modules but they have their special type mirror file, so they are ignored.
7
- *
8
- * @param {string} cwd - The directory path to start searching from. By default, it is the base path of the project.
9
- * @returns {Array} modules - An array of absolute paths for the found modules.
10
- *
11
- * @example
12
- * // Assuming the base directory of your project is '/Users/user/myproject'
13
- * findDirectoryNamedModules('/Users/user/myproject');
14
- * // This will return an array with the absolute paths of all matching files, e.g.:
15
- * // ['/Users/user/myproject/web/src/components/Author/Author.tsx', '/Users/user/myproject/web/src/pages/AboutPage/AboutPage.tsx']
16
- */
17
- export declare const findDirectoryNamedModules: (cwd?: string) => string[];
18
- export declare const findGraphQLSchemas: (cwd?: string) => string[];
19
- export declare const findApiFiles: (cwd?: string) => string[];
20
- export declare const findWebFiles: (cwd?: string) => string[];
21
- export declare const findApiServerFunctions: (cwd?: string) => string[];
22
- export declare const findApiDistFunctions: (params: {
23
- cwd: string;
24
- options?: FastGlobOptions;
25
- discoverFunctionsGlob?: string | string[];
26
- }) => string[];
27
- export declare const findRouteHooksSrc: (cwd?: string) => string[];
28
- export declare const isCellFile: (p: string) => boolean;
29
- export declare const findScripts: (cwd?: string) => string[];
30
- export declare const isPageFile: (p: string) => boolean;
31
- /**
32
- * This function checks if the given path belongs to a directory named module.
33
- * A directory named module is where the filename (without extension) is the same as the directory it is in.
34
- *
35
- * @param {string} p - The absolute path of the file.
36
- * @returns {boolean} - Returns true if the path belongs to a directory named module, false otherwise.
37
- *
38
- * @example
39
- * isDirectoryNamedModuleFile('/Users/user/myproject/web/src/components/Author/Author.tsx');
40
- * // Returns: true
41
- *
42
- * isDirectoryNamedModuleFile('/Users/user/myproject/web/src/components/Author/AuthorInfo.tsx');
43
- * // Returns: false
44
- */
45
- export declare const isDirectoryNamedModuleFile: (p: string) => boolean;
46
- export declare const isGraphQLSchemaFile: (p: string) => boolean;
47
- /**
48
- * The following patterns are supported for api functions:
49
- *
50
- * 1. a module at the top level: `/graphql.js`
51
- * 2. a module in a folder with a module of the same name: `/health/health.js`
52
- * 3. a module in a folder named index: `/x/index.js`
53
- */
54
- export declare const isApiFunction: (p: string, functionsPath: string) => boolean;
55
- export declare const isFileInsideFolder: (filePath: string, folderPath: string) => boolean;
56
- //# sourceMappingURL=files.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/files.ts"],"names":[],"mappings":"AAEA,OAAW,EAAE,KAAK,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAM/D,eAAO,MAAM,SAAS,GAAI,MAAK,MAA2B,aAOzD,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,MAAK,MAA6B,aAQ3D,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAK,MAAwB,aAUtE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,MAAK,MAA+B,aAItE,CAAA;AASD,eAAO,MAAM,YAAY,GAAI,MAAK,MAA2B,aAO5D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,MAAK,MAA2B,aAY5D,CAAA;AAED,eAAO,MAAM,sBAAsB,GACjC,MAAK,MAAiC,aAUvC,CAAA;AAKD,eAAO,MAAM,oBAAoB,GAAI,QAAQ;IAC3C,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1C,aAcA,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,MAAK,MAA2B,aAKjE,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,YA6BnC,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,MAAK,MAA2B,aAM3D,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,YAoBnC,CAAA;AACD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,GAAI,GAAG,MAAM,YAGnD,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,GAAG,MAAM,YAQ5C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,eAAe,MAAM,YAc7D,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,YAYtE,CAAA"}
package/dist/cjs/files.js DELETED
@@ -1,230 +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 files_exports = {};
30
- __export(files_exports, {
31
- findApiDistFunctions: () => findApiDistFunctions,
32
- findApiFiles: () => findApiFiles,
33
- findApiServerFunctions: () => findApiServerFunctions,
34
- findCells: () => findCells,
35
- findDirectoryNamedModules: () => findDirectoryNamedModules,
36
- findGraphQLSchemas: () => findGraphQLSchemas,
37
- findPages: () => findPages,
38
- findRouteHooksSrc: () => findRouteHooksSrc,
39
- findScripts: () => findScripts,
40
- findWebFiles: () => findWebFiles,
41
- isApiFunction: () => isApiFunction,
42
- isCellFile: () => isCellFile,
43
- isDirectoryNamedModuleFile: () => isDirectoryNamedModuleFile,
44
- isFileInsideFolder: () => isFileInsideFolder,
45
- isGraphQLSchemaFile: () => isGraphQLSchemaFile,
46
- isPageFile: () => isPageFile
47
- });
48
- module.exports = __toCommonJS(files_exports);
49
- var import_path = __toESM(require("path"), 1);
50
- var import_fast_glob = __toESM(require("fast-glob"), 1);
51
- var import_project_config = require("@cedarjs/project-config");
52
- var import_ast = require("./ast.js");
53
- const findCells = (cwd = (0, import_project_config.getPaths)().web.src) => {
54
- const modules = import_fast_glob.default.sync("**/*Cell.{js,jsx,ts,tsx}", {
55
- cwd,
56
- absolute: true,
57
- ignore: ["node_modules"]
58
- });
59
- return modules.filter(isCellFile);
60
- };
61
- const findPages = (cwd = (0, import_project_config.getPaths)().web.pages) => {
62
- const modules = import_fast_glob.default.sync("**/*Page.{tsx,js,jsx}", {
63
- cwd,
64
- absolute: true,
65
- ignore: ["node_modules"]
66
- });
67
- return modules.filter(isPageFile);
68
- };
69
- const findDirectoryNamedModules = (cwd = (0, import_project_config.getPaths)().base) => {
70
- const modules = import_fast_glob.default.sync("(api|web)/src/**/*.{ts,js,jsx,tsx}", {
71
- cwd,
72
- absolute: true,
73
- ignore: ["node_modules"]
74
- });
75
- return modules.filter(isDirectoryNamedModuleFile).filter((p) => !isCellFile(p));
76
- };
77
- const findGraphQLSchemas = (cwd = (0, import_project_config.getPaths)().api.graphql) => {
78
- return import_fast_glob.default.sync("**/*.sdl.{ts,js}", { cwd, absolute: true }).filter(isGraphQLSchemaFile);
79
- };
80
- const ignoreApiFiles = [
81
- "**/*.test.{js,ts}",
82
- "**/*.scenarios.{js,ts}",
83
- "**/*.fixtures.{js,ts}",
84
- "**/*.d.ts"
85
- ];
86
- const findApiFiles = (cwd = (0, import_project_config.getPaths)().api.src) => {
87
- const files = import_fast_glob.default.sync("**/*.{js,ts,jsx,tsx}", {
88
- cwd,
89
- absolute: true,
90
- ignore: ignoreApiFiles
91
- });
92
- return files;
93
- };
94
- const findWebFiles = (cwd = (0, import_project_config.getPaths)().web.src) => {
95
- const files = import_fast_glob.default.sync("**/*.{js,ts,jsx,tsx}", {
96
- cwd,
97
- absolute: true,
98
- ignore: [
99
- "**/*.test.{js,ts,tsx,jsx}",
100
- "**/*.fixtures.{js,ts,tsx,jsx}",
101
- "**/*.mock.{js,ts,tsx,jsx}",
102
- "**/*.d.ts"
103
- ]
104
- });
105
- return files;
106
- };
107
- const findApiServerFunctions = (cwd = (0, import_project_config.getPaths)().api.functions) => {
108
- const files = import_fast_glob.default.sync("**/*.{js,ts}", {
109
- cwd,
110
- absolute: true,
111
- deep: 2,
112
- // We don't support deeply nested api functions.
113
- ignore: ignoreApiFiles
114
- });
115
- return files.filter((f) => isApiFunction(f, cwd));
116
- };
117
- const findApiDistFunctions = (params) => {
118
- const {
119
- cwd = (0, import_project_config.getPaths)().api.base,
120
- options = {},
121
- discoverFunctionsGlob = "dist/functions/**/*.{ts,js}"
122
- } = params;
123
- return import_fast_glob.default.sync(discoverFunctionsGlob, {
124
- cwd,
125
- // We don't support deeply nested api functions, to maximise compatibility
126
- // with deployment providers
127
- deep: 2,
128
- absolute: true,
129
- ...options
130
- });
131
- };
132
- const findRouteHooksSrc = (cwd = (0, import_project_config.getPaths)().web.src) => {
133
- return import_fast_glob.default.sync("**/*.routeHooks.{js,ts,tsx,jsx}", {
134
- absolute: true,
135
- cwd
136
- });
137
- };
138
- const isCellFile = (p) => {
139
- const { dir, name } = import_path.default.parse(p);
140
- if (!isFileInsideFolder(p, (0, import_project_config.getPaths)().web.src)) {
141
- return false;
142
- }
143
- if (!dir.endsWith(name)) {
144
- return false;
145
- }
146
- const ast = (0, import_ast.fileToAst)(p);
147
- if ((0, import_ast.hasDefaultExport)(ast)) {
148
- return false;
149
- }
150
- const exports2 = (0, import_ast.getNamedExports)(ast);
151
- const exportedQUERY = exports2.findIndex((v) => v.name === "QUERY") !== -1;
152
- const exportedSuccess = exports2.findIndex((v) => v.name === "Success") !== -1;
153
- if (!exportedQUERY && !exportedSuccess) {
154
- return false;
155
- }
156
- return true;
157
- };
158
- const findScripts = (cwd = (0, import_project_config.getPaths)().scripts) => {
159
- return import_fast_glob.default.sync("./**/*.{js,jsx,ts,tsx}", {
160
- cwd,
161
- absolute: true,
162
- ignore: ["node_modules"]
163
- });
164
- };
165
- const isPageFile = (p) => {
166
- const { name } = import_path.default.parse(p);
167
- if (!name.endsWith("Page")) {
168
- return false;
169
- }
170
- if (!isFileInsideFolder(p, (0, import_project_config.getPaths)().web.pages)) {
171
- return false;
172
- }
173
- const ast = (0, import_ast.fileToAst)(p);
174
- if (!(0, import_ast.hasDefaultExport)(ast)) {
175
- return false;
176
- }
177
- return true;
178
- };
179
- const isDirectoryNamedModuleFile = (p) => {
180
- const { dir, name } = import_path.default.parse(p);
181
- return dir.endsWith(name);
182
- };
183
- const isGraphQLSchemaFile = (p) => {
184
- if (!p.match(/\.sdl\.(ts|js)$/)?.[0]) {
185
- return false;
186
- }
187
- const ast = (0, import_ast.fileToAst)(p);
188
- const exports2 = (0, import_ast.getNamedExports)(ast);
189
- return exports2.findIndex((v) => v.name === "schema") !== -1;
190
- };
191
- const isApiFunction = (p, functionsPath) => {
192
- p = import_path.default.relative(functionsPath, p);
193
- const { dir, name } = import_path.default.parse(p);
194
- if (dir === name) {
195
- return true;
196
- } else if (dir === "") {
197
- return true;
198
- } else if (dir.length && name === "index") {
199
- return true;
200
- }
201
- return false;
202
- };
203
- const isFileInsideFolder = (filePath, folderPath) => {
204
- const { dir } = import_path.default.parse(filePath);
205
- const relativePathFromFolder = import_path.default.relative(folderPath, dir);
206
- if (!relativePathFromFolder || relativePathFromFolder.startsWith("..") || import_path.default.isAbsolute(relativePathFromFolder)) {
207
- return false;
208
- } else {
209
- return true;
210
- }
211
- };
212
- // Annotate the CommonJS export names for ESM import in node:
213
- 0 && (module.exports = {
214
- findApiDistFunctions,
215
- findApiFiles,
216
- findApiServerFunctions,
217
- findCells,
218
- findDirectoryNamedModules,
219
- findGraphQLSchemas,
220
- findPages,
221
- findRouteHooksSrc,
222
- findScripts,
223
- findWebFiles,
224
- isApiFunction,
225
- isCellFile,
226
- isDirectoryNamedModuleFile,
227
- isFileInsideFolder,
228
- isGraphQLSchemaFile,
229
- isPageFile
230
- });
@@ -1,17 +0,0 @@
1
- export declare const shouldGenerateTrustedDocuments: () => boolean;
2
- export declare const generateClientPreset: () => Promise<{
3
- clientPresetFiles: string[];
4
- trustedDocumentsStoreFile: never[];
5
- errors: {
6
- message: string;
7
- error: unknown;
8
- }[];
9
- } | {
10
- clientPresetFiles: string[];
11
- trustedDocumentsStoreFile: string;
12
- errors: {
13
- message: string;
14
- error: unknown;
15
- }[];
16
- }>;
17
- //# sourceMappingURL=clientPreset.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientPreset.d.ts","sourceRoot":"","sources":["../../../src/generate/clientPreset.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,8BAA8B,QAAO,OAIjD,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;iBAGN,MAAM;eAAS,OAAO;;;;;;iBAAtB,MAAM;eAAS,OAAO;;EAoDhD,CAAA"}
@@ -1,84 +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 clientPreset_exports = {};
20
- __export(clientPreset_exports, {
21
- generateClientPreset: () => generateClientPreset,
22
- shouldGenerateTrustedDocuments: () => shouldGenerateTrustedDocuments
23
- });
24
- module.exports = __toCommonJS(clientPreset_exports);
25
- var import_cli = require("@graphql-codegen/cli");
26
- var import_client_preset = require("@graphql-codegen/client-preset");
27
- var import_project_config = require("@cedarjs/project-config");
28
- var import_trustedDocuments = require("./trustedDocuments.js");
29
- const shouldGenerateTrustedDocuments = () => {
30
- const config = (0, import_project_config.getConfig)();
31
- return config.graphql.trustedDocuments;
32
- };
33
- const generateClientPreset = async () => {
34
- let clientPresetFiles = [];
35
- const errors = [];
36
- if (!shouldGenerateTrustedDocuments()) {
37
- return { clientPresetFiles, trustedDocumentsStoreFile: [], errors };
38
- }
39
- const documentsGlob = `${(0, import_project_config.getPaths)().web.src}/**/!(*.d).{ts,tsx,js,jsx}`;
40
- const config = {
41
- schema: (0, import_project_config.getPaths)().generated.schema,
42
- documents: documentsGlob,
43
- silent: true,
44
- // Plays nicely with cli task output
45
- generates: {
46
- [`${(0, import_project_config.getPaths)().web.src}/graphql/`]: {
47
- preset: "client",
48
- presetConfig: {
49
- persistedDocuments: true
50
- },
51
- documentTransforms: [import_client_preset.addTypenameSelectionDocumentTransform],
52
- config: {
53
- // DO NOT USE documentMode: 'string',
54
- }
55
- }
56
- }
57
- };
58
- try {
59
- const generatedFiles = await (0, import_cli.generate)(config, true);
60
- clientPresetFiles = generatedFiles.map((f) => f.filename);
61
- const trustedDocumentsStoreFile = await (0, import_trustedDocuments.trustedDocumentsStore)(generatedFiles);
62
- (0, import_trustedDocuments.replaceGqlTagWithTrustedDocumentGraphql)(generatedFiles);
63
- return {
64
- clientPresetFiles,
65
- trustedDocumentsStoreFile,
66
- errors
67
- };
68
- } catch (e) {
69
- errors.push({
70
- message: "Error: Could not generate GraphQL client preset",
71
- error: e
72
- });
73
- return {
74
- clientPresetFiles,
75
- trustedDocumentsStoreFile: [],
76
- errors
77
- };
78
- }
79
- };
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- generateClientPreset,
83
- shouldGenerateTrustedDocuments
84
- });
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare const generate: () => Promise<{
3
- files: string[];
4
- errors: {
5
- message: string;
6
- error: unknown;
7
- }[];
8
- }>;
9
- export declare const run: () => Promise<void>;
10
- //# sourceMappingURL=generate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/generate/generate.ts"],"names":[],"mappings":";AAWA,eAAO,MAAM,QAAQ;;;;;;EA2CpB,CAAA;AAED,eAAO,MAAM,GAAG,qBAoCf,CAAA"}
@@ -1,97 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var generate_exports = {};
21
- __export(generate_exports, {
22
- generate: () => generate,
23
- run: () => run
24
- });
25
- module.exports = __toCommonJS(generate_exports);
26
- var import_loadEnvFiles = require("@cedarjs/cli-helpers/loadEnvFiles");
27
- var import_project_config = require("@cedarjs/project-config");
28
- var import_clientPreset = require("./clientPreset.js");
29
- var import_gqlormSchema = require("./gqlormSchema.js");
30
- var import_graphqlSchema = require("./graphqlSchema.js");
31
- var import_possibleTypes = require("./possibleTypes.js");
32
- var import_typeDefinitions = require("./typeDefinitions.js");
33
- const generate = async () => {
34
- const config = (0, import_project_config.getConfig)();
35
- const { schemaPath, errors: generateGraphQLSchemaErrors } = await (0, import_graphqlSchema.generateGraphQLSchema)();
36
- const { typeDefFiles, errors: generateTypeDefsErrors } = await (0, import_typeDefinitions.generateTypeDefs)();
37
- const clientPresetFiles = [];
38
- const { possibleTypesFiles, errors: generatePossibleTypesErrors } = await (0, import_possibleTypes.generatePossibleTypes)();
39
- const { files: gqlormFiles, errors: gqlormErrors } = await (0, import_gqlormSchema.generateGqlormArtifacts)();
40
- if (config.graphql.trustedDocuments) {
41
- const preset = await (0, import_clientPreset.generateClientPreset)();
42
- clientPresetFiles.push(...preset.clientPresetFiles);
43
- }
44
- let files = [];
45
- if (schemaPath !== "") {
46
- files.push(schemaPath);
47
- }
48
- files = [
49
- ...files,
50
- ...typeDefFiles,
51
- ...clientPresetFiles,
52
- ...possibleTypesFiles,
53
- ...gqlormFiles
54
- ].filter((x) => typeof x === "string");
55
- return {
56
- files,
57
- errors: [
58
- ...generateGraphQLSchemaErrors,
59
- ...generateTypeDefsErrors,
60
- ...generatePossibleTypesErrors,
61
- ...gqlormErrors
62
- ]
63
- };
64
- };
65
- const run = async () => {
66
- (0, import_loadEnvFiles.loadEnvFiles)();
67
- console.log("Generating...");
68
- console.log();
69
- const { files, errors } = await generate();
70
- const rwjsPaths = (0, import_project_config.getPaths)();
71
- for (const f of files) {
72
- console.log("-", f.replace(rwjsPaths.base + "/", ""));
73
- }
74
- console.log();
75
- if (errors.length === 0) {
76
- console.log("... done.");
77
- console.log();
78
- return;
79
- }
80
- process.exitCode ||= 1;
81
- console.log("... done with errors.");
82
- console.log();
83
- for (const { message, error } of errors) {
84
- console.error(message);
85
- console.log();
86
- console.error(error);
87
- console.log();
88
- }
89
- };
90
- if (process.env.NODE_ENV !== "test" && process.argv[1]?.endsWith("generate.js")) {
91
- run();
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- generate,
96
- run
97
- });
@@ -1,113 +0,0 @@
1
- import type * as DMMF from '@prisma/dmmf';
2
- type ModelSchema = Record<string, string[]>;
3
- interface FrontendFieldInfo {
4
- name: string;
5
- tsType: string;
6
- }
7
- interface FrontendModelInfo {
8
- modelName: string;
9
- camelName: string;
10
- fields: FrontendFieldInfo[];
11
- }
12
- export interface BackendFieldInfo {
13
- name: string;
14
- graphqlType: string;
15
- isRequired: boolean;
16
- isId: boolean;
17
- hasDefaultValue: boolean;
18
- isUpdatedAt: boolean;
19
- }
20
- export interface BackendModelInfo {
21
- modelName: string;
22
- camelName: string;
23
- pluralName: string;
24
- fields: BackendFieldInfo[];
25
- idField: BackendFieldInfo | undefined;
26
- }
27
- export interface GqlormBackendConfig {
28
- membershipModel: string;
29
- membershipModelCamel: string;
30
- membershipUserField: string;
31
- membershipOrganizationField: string;
32
- membershipModelExists: boolean;
33
- }
34
- /**
35
- * Map a DMMF field type to its GraphQL SDL equivalent.
36
- *
37
- * Enum fields (kind === 'enum') are mapped to String. Unknown scalar types
38
- * fall back to String.
39
- */
40
- export declare function mapDmmfTypeToGraphql(type: string, kind: string): string;
41
- export declare function buildFrontendModelInfo(dmmf: DMMF.Document): FrontendModelInfo[];
42
- export declare function generateWebGqlormModelsContent(models: FrontendModelInfo[]): string;
43
- /**
44
- * Build a ModelSchema from a Prisma DMMF document.
45
- *
46
- * This is a pure function with no I/O — it can be called directly in tests
47
- * with a mock DMMF object.
48
- */
49
- export declare function buildModelSchema(dmmf: DMMF.Document): ModelSchema;
50
- /**
51
- * Build enriched model information from the DMMF, applying the same visibility
52
- * rules as `buildModelSchema()` but also collecting type, nullability, and
53
- * @id flag per field.
54
- *
55
- * **Note:** This function silently excludes sensitive fields without emitting
56
- * warnings. It is designed to run after `buildModelSchema()` (which emits the
57
- * warnings). In `generateGqlormArtifacts()` the call order is guaranteed, but
58
- * callers using this function standalone should be aware that no warnings will
59
- * be printed for auto-hidden sensitive fields.
60
- *
61
- * This is a pure function — safe for testing.
62
- */
63
- export declare function buildBackendModelInfo(dmmf: DMMF.Document): BackendModelInfo[];
64
- /**
65
- * Scan all SDL files in the given directory and return the set of GraphQL type
66
- * names that are already defined by user-authored SDLs.
67
- *
68
- * This prevents gqlorm from generating duplicate type definitions that would
69
- * cause merge conflicts in `makeMergedSchema`.
70
- */
71
- export declare function getExistingSdlTypeNames(graphqlDir: string): Set<string>;
72
- /**
73
- * Generate the full TypeScript source for `.cedar/gqlorm/backend.ts`.
74
- *
75
- * The generated file exports:
76
- * - `schema`: a gql DocumentNode with type defs and Query fields
77
- * - `createGqlormResolvers(db: GqlormDb)`: a factory function that takes a
78
- * Prisma client-like object and returns a resolvers object
79
- *
80
- * The file does NOT import `db` directly. Instead, the Babel inject plugin
81
- * imports `db` from `src/lib/db` in `graphql.ts` (where that alias resolves
82
- * correctly) and passes it to `createGqlormResolvers`.
83
- *
84
- * The generated `GqlormDb` interface is scoped to exactly the visible models
85
- * and fields — no hidden/sensitive fields, no @gqlorm hide models, no
86
- * dependency on the generated Prisma client path or @prisma/client.
87
- */
88
- export declare function generateGqlormBackendContent(models: BackendModelInfo[], config?: GqlormBackendConfig): string;
89
- /**
90
- * Generate gqlorm artifacts from the Prisma schema.
91
- *
92
- * Reads the project's Prisma schema via DMMF, applies visibility rules
93
- * (@gqlorm directives + sensitivity heuristics), and writes:
94
- *
95
- * 1. `.cedar/gqlorm-schema.json` — the frontend ModelSchema (field names only)
96
- * 2. `.cedar/gqlorm/backend.ts` — auto-generated GraphQL types and resolvers
97
- * for models that don't already have manually-written SDL files
98
- *
99
- * Cedar targets Node.js 24, which strips TypeScript types natively without any
100
- * flags, so backend.ts can be imported directly at runtime
101
- *
102
- * Returns the same `{ files, errors }` shape used by other generators so it
103
- * can be integrated into `generate.ts` without special handling.
104
- */
105
- export declare function generateGqlormArtifacts(): Promise<{
106
- files: string[];
107
- errors: {
108
- message: string;
109
- error: unknown;
110
- }[];
111
- }>;
112
- export {};
113
- //# sourceMappingURL=gqlormSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gqlormSchema.d.ts","sourceRoot":"","sources":["../../../src/generate/gqlormSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,IAAI,MAAM,cAAc,CAAA;AA8BzC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAE3C,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,iBAAiB,EAAE,CAAA;CAC5B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,eAAe,EAAE,OAAO,CAAA;IACxB,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,gBAAgB,EAAE,CAAA;IAC1B,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,2BAA2B,EAAE,MAAM,CAAA;IACnC,qBAAqB,EAAE,OAAO,CAAA;CAC/B;AA6DD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvE;AAoGD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,CAAC,QAAQ,GAClB,iBAAiB,EAAE,CAiDrB;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,iBAAiB,EAAE,GAC1B,MAAM,CA2CR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,GAAG,WAAW,CAkDjE;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,EAAE,CA6D7E;AAkBD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CA6BvE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,gBAAgB,EAAE,EAC1B,MAAM,GAAE,mBAAmD,GAC1D,MAAM,CA+rBR;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC;IACvD,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAC,CAkID"}