@cedarjs/internal 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.
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +28 -64
- package/dist/build/api.js +22 -56
- package/dist/cjs/ast.d.ts +26 -0
- package/dist/cjs/ast.d.ts.map +1 -0
- package/dist/cjs/ast.js +201 -0
- package/dist/cjs/build/api.d.ts +6 -0
- package/dist/cjs/build/api.d.ts.map +1 -0
- package/dist/cjs/build/api.js +109 -0
- package/dist/cjs/cliLogger.d.ts +11 -0
- package/dist/cjs/cliLogger.d.ts.map +1 -0
- package/dist/cjs/cliLogger.js +36 -0
- package/dist/cjs/dev.d.ts +2 -0
- package/dist/cjs/dev.d.ts.map +1 -0
- package/dist/cjs/dev.js +41 -0
- package/dist/cjs/files.d.ts +56 -0
- package/dist/cjs/files.d.ts.map +1 -0
- package/dist/cjs/files.js +230 -0
- package/dist/cjs/generate/clientPreset.d.ts +17 -0
- package/dist/cjs/generate/clientPreset.d.ts.map +1 -0
- package/dist/cjs/generate/clientPreset.js +85 -0
- package/dist/cjs/generate/generate.d.ts +10 -0
- package/dist/cjs/generate/generate.d.ts.map +1 -0
- package/dist/cjs/generate/generate.js +91 -0
- package/dist/cjs/generate/graphqlCodeGen.d.ts +16 -0
- package/dist/cjs/generate/graphqlCodeGen.d.ts.map +1 -0
- package/dist/cjs/generate/graphqlCodeGen.js +346 -0
- package/dist/cjs/generate/graphqlSchema.d.ts +8 -0
- package/dist/cjs/generate/graphqlSchema.d.ts.map +1 -0
- package/dist/cjs/generate/graphqlSchema.js +154 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +7 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +65 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +9 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -0
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +84 -0
- package/dist/cjs/generate/possibleTypes.d.ts +36 -0
- package/dist/cjs/generate/possibleTypes.d.ts.map +1 -0
- package/dist/cjs/generate/possibleTypes.js +106 -0
- package/dist/cjs/generate/templates/all-currentUser.d.ts.template +30 -0
- package/dist/cjs/generate/templates/api-globImports.d.ts.template +9 -0
- package/dist/cjs/generate/templates/api-globalContext.d.ts.template +7 -0
- package/dist/cjs/generate/templates/api-scenarios.d.ts.template +10 -0
- package/dist/cjs/generate/templates/api-test-globals.d.ts.template +5 -0
- package/dist/cjs/generate/templates/mirror-cell.d.ts.template +13 -0
- package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +5 -0
- package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +20 -0
- package/dist/cjs/generate/templates/web-routesPages.d.ts.template +13 -0
- package/dist/cjs/generate/templates/web-test-globals.d.ts.template +7 -0
- package/dist/cjs/generate/templates.d.ts +6 -0
- package/dist/cjs/generate/templates.d.ts.map +1 -0
- package/dist/cjs/generate/templates.js +68 -0
- package/dist/cjs/generate/trustedDocuments.d.ts +3 -0
- package/dist/cjs/generate/trustedDocuments.d.ts.map +1 -0
- package/dist/cjs/generate/trustedDocuments.js +95 -0
- package/dist/cjs/generate/typeDefinitions.d.ts +30 -0
- package/dist/cjs/generate/typeDefinitions.d.ts.map +1 -0
- package/dist/cjs/generate/typeDefinitions.js +369 -0
- package/dist/cjs/generate/types.d.ts +6 -0
- package/dist/cjs/generate/types.d.ts.map +1 -0
- package/dist/cjs/generate/types.js +16 -0
- package/dist/cjs/generate/watch.d.ts +3 -0
- package/dist/cjs/generate/watch.d.ts.map +1 -0
- package/dist/cjs/generate/watch.js +124 -0
- package/dist/cjs/gql.d.ts +14 -0
- package/dist/cjs/gql.d.ts.map +1 -0
- package/dist/cjs/gql.js +108 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +49 -0
- package/dist/cjs/jsx.d.ts +16 -0
- package/dist/cjs/jsx.d.ts.map +1 -0
- package/dist/cjs/jsx.js +101 -0
- package/dist/cjs/jsxAttributeValue.d.ts +2 -0
- package/dist/cjs/jsxAttributeValue.d.ts.map +1 -0
- package/dist/cjs/jsxAttributeValue.js +129 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/project.d.ts +8 -0
- package/dist/cjs/project.d.ts.map +1 -0
- package/dist/cjs/project.js +82 -0
- package/dist/cjs/routes.d.ts +42 -0
- package/dist/cjs/routes.d.ts.map +1 -0
- package/dist/cjs/routes.js +111 -0
- package/dist/cjs/ts2js.d.ts +40 -0
- package/dist/cjs/ts2js.d.ts.map +1 -0
- package/dist/cjs/ts2js.js +159 -0
- package/dist/cjs/validateSchema.d.ts +14 -0
- package/dist/cjs/validateSchema.d.ts.map +1 -0
- package/dist/cjs/validateSchema.js +194 -0
- package/dist/cliLogger.js +4 -28
- package/dist/dev.js +4 -38
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +46 -95
- package/dist/generate/clientPreset.js +17 -39
- package/dist/generate/generate.js +14 -39
- package/dist/generate/graphqlCodeGen.d.ts.map +1 -1
- package/dist/generate/graphqlCodeGen.js +49 -79
- package/dist/generate/graphqlSchema.d.ts.map +1 -1
- package/dist/generate/graphqlSchema.js +26 -59
- package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts +4 -3
- package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -1
- package/dist/generate/plugins/rw-typescript-resolvers/index.js +11 -35
- package/dist/generate/plugins/rw-typescript-resolvers/visitor.js +10 -31
- package/dist/generate/possibleTypes.js +19 -53
- package/dist/generate/templates.d.ts.map +1 -1
- package/dist/generate/templates.js +14 -42
- package/dist/generate/trustedDocuments.js +13 -48
- package/dist/generate/typeDefinitions.d.ts +2 -2
- package/dist/generate/typeDefinitions.d.ts.map +1 -1
- package/dist/generate/typeDefinitions.js +83 -123
- package/dist/generate/types.js +0 -16
- package/dist/generate/watch.js +55 -63
- package/dist/gql.js +16 -42
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -47
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +7 -40
- package/dist/jsxAttributeValue.js +2 -26
- package/dist/project.js +21 -58
- package/dist/routes.d.ts +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +12 -48
- package/dist/ts2js.d.ts +1 -1
- package/dist/ts2js.js +33 -73
- package/dist/validateSchema.js +19 -47
- package/package.json +91 -31
|
@@ -0,0 +1,36 @@
|
|
|
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 cliLogger_exports = {};
|
|
20
|
+
__export(cliLogger_exports, {
|
|
21
|
+
cliLogger: () => cliLogger
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cliLogger_exports);
|
|
24
|
+
var import_logger = require("@cedarjs/api/logger");
|
|
25
|
+
const logLevel = import_logger.defaultLoggerOptions.level;
|
|
26
|
+
const cliLogger = function(...data) {
|
|
27
|
+
console.log(...data);
|
|
28
|
+
};
|
|
29
|
+
cliLogger.trace = logLevel === "trace" ? console.log : () => {
|
|
30
|
+
};
|
|
31
|
+
cliLogger.debug = logLevel === "trace" || logLevel === "debug" ? console.log : () => {
|
|
32
|
+
};
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
cliLogger
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/dev.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,SAAU,MAAM,WAAU,KAAK,GAAG,KAAK,kBAE/D,CAAA"}
|
package/dist/cjs/dev.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 dev_exports = {};
|
|
30
|
+
__export(dev_exports, {
|
|
31
|
+
shutdownPort: () => shutdownPort
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(dev_exports);
|
|
34
|
+
var import_kill_port = __toESM(require("kill-port"), 1);
|
|
35
|
+
const shutdownPort = (port, method = "tcp") => {
|
|
36
|
+
return (0, import_kill_port.default)(port, method);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
shutdownPort
|
|
41
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,SAAS,MAAM,aAOpC,CAAA;AAED,eAAO,MAAM,SAAS,SAAS,MAAM,aAQpC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,SAAS,MAAM,aAUpD,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAS,MAAM,aAI7C,CAAA;AASD,eAAO,MAAM,YAAY,SAAS,MAAM,aAOvC,CAAA;AAED,eAAO,MAAM,YAAY,SAAS,MAAM,aAYvC,CAAA;AAED,eAAO,MAAM,sBAAsB,SAC5B,MAAM,aAUZ,CAAA;AAKD,eAAO,MAAM,oBAAoB,WAAY;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,SAAS,MAAM,aAK5C,CAAA;AAED,eAAO,MAAM,UAAU,MAAO,MAAM,YA6BnC,CAAA;AAED,eAAO,MAAM,WAAW,SAAS,MAAM,aAMtC,CAAA;AAED,eAAO,MAAM,UAAU,MAAO,MAAM,YAoBnC,CAAA;AACD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,MAAO,MAAM,YAGnD,CAAA;AAED,eAAO,MAAM,mBAAmB,MAAO,MAAM,YAQ5C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,MAAO,MAAM,iBAAiB,MAAM,YAc7D,CAAA;AAED,eAAO,MAAM,kBAAkB,aAAc,MAAM,cAAc,MAAM,YAYtE,CAAA"}
|
|
@@ -0,0 +1,230 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;iBAIN,MAAM;eAAS,OAAO;;;;;;iBAAtB,MAAM;eAAS,OAAO;;EAoDhD,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 generatedFiles = [];
|
|
35
|
+
let clientPresetFiles = [];
|
|
36
|
+
const errors = [];
|
|
37
|
+
if (!shouldGenerateTrustedDocuments()) {
|
|
38
|
+
return { clientPresetFiles, trustedDocumentsStoreFile: [], errors };
|
|
39
|
+
}
|
|
40
|
+
const documentsGlob = `${(0, import_project_config.getPaths)().web.src}/**/!(*.d).{ts,tsx,js,jsx}`;
|
|
41
|
+
const config = {
|
|
42
|
+
schema: (0, import_project_config.getPaths)().generated.schema,
|
|
43
|
+
documents: documentsGlob,
|
|
44
|
+
silent: true,
|
|
45
|
+
// Plays nicely with cli task output
|
|
46
|
+
generates: {
|
|
47
|
+
[`${(0, import_project_config.getPaths)().web.src}/graphql/`]: {
|
|
48
|
+
preset: "client",
|
|
49
|
+
presetConfig: {
|
|
50
|
+
persistedDocuments: true
|
|
51
|
+
},
|
|
52
|
+
documentTransforms: [import_client_preset.addTypenameSelectionDocumentTransform],
|
|
53
|
+
config: {
|
|
54
|
+
// DO NOT USE documentMode: 'string',
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
generatedFiles = await (0, import_cli.generate)(config, true);
|
|
61
|
+
clientPresetFiles = generatedFiles.map((f) => f.filename);
|
|
62
|
+
const trustedDocumentsStoreFile = await (0, import_trustedDocuments.trustedDocumentsStore)(generatedFiles);
|
|
63
|
+
(0, import_trustedDocuments.replaceGqlTagWithTrustedDocumentGraphql)(generatedFiles);
|
|
64
|
+
return {
|
|
65
|
+
clientPresetFiles,
|
|
66
|
+
trustedDocumentsStoreFile,
|
|
67
|
+
errors
|
|
68
|
+
};
|
|
69
|
+
} catch (e) {
|
|
70
|
+
errors.push({
|
|
71
|
+
message: "Error: Could not generate GraphQL client preset",
|
|
72
|
+
error: e
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
clientPresetFiles,
|
|
76
|
+
trustedDocumentsStoreFile: [],
|
|
77
|
+
errors
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
generateClientPreset,
|
|
84
|
+
shouldGenerateTrustedDocuments
|
|
85
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/generate/generate.ts"],"names":[],"mappings":";AASA,eAAO,MAAM,QAAQ;;;;;;EAsCpB,CAAA;AAED,eAAO,MAAM,GAAG,qBA4Bf,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
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_project_config = require("@cedarjs/project-config");
|
|
27
|
+
var import_clientPreset = require("./clientPreset.js");
|
|
28
|
+
var import_graphqlSchema = require("./graphqlSchema.js");
|
|
29
|
+
var import_possibleTypes = require("./possibleTypes.js");
|
|
30
|
+
var import_typeDefinitions = require("./typeDefinitions.js");
|
|
31
|
+
const generate = async () => {
|
|
32
|
+
const config = (0, import_project_config.getConfig)();
|
|
33
|
+
const { schemaPath, errors: generateGraphQLSchemaErrors } = await (0, import_graphqlSchema.generateGraphQLSchema)();
|
|
34
|
+
const { typeDefFiles, errors: generateTypeDefsErrors } = await (0, import_typeDefinitions.generateTypeDefs)();
|
|
35
|
+
const clientPresetFiles = [];
|
|
36
|
+
const { possibleTypesFiles, errors: generatePossibleTypesErrors } = await (0, import_possibleTypes.generatePossibleTypes)();
|
|
37
|
+
if (config.graphql.trustedDocuments) {
|
|
38
|
+
const preset = await (0, import_clientPreset.generateClientPreset)();
|
|
39
|
+
clientPresetFiles.push(...preset.clientPresetFiles);
|
|
40
|
+
}
|
|
41
|
+
let files = [];
|
|
42
|
+
if (schemaPath !== "") {
|
|
43
|
+
files.push(schemaPath);
|
|
44
|
+
}
|
|
45
|
+
files = [
|
|
46
|
+
...files,
|
|
47
|
+
...typeDefFiles,
|
|
48
|
+
...clientPresetFiles,
|
|
49
|
+
...possibleTypesFiles
|
|
50
|
+
].filter((x) => typeof x === "string");
|
|
51
|
+
return {
|
|
52
|
+
files,
|
|
53
|
+
errors: [
|
|
54
|
+
...generateGraphQLSchemaErrors,
|
|
55
|
+
...generateTypeDefsErrors,
|
|
56
|
+
...generatePossibleTypesErrors
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const run = async () => {
|
|
61
|
+
console.log("Generating...");
|
|
62
|
+
console.log();
|
|
63
|
+
const { files, errors } = await generate();
|
|
64
|
+
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
65
|
+
for (const f of files) {
|
|
66
|
+
console.log("-", f.replace(rwjsPaths.base + "/", ""));
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
if (errors.length === 0) {
|
|
70
|
+
console.log("... done.");
|
|
71
|
+
console.log();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
process.exitCode ||= 1;
|
|
75
|
+
console.log("... done with errors.");
|
|
76
|
+
console.log();
|
|
77
|
+
for (const { message, error } of errors) {
|
|
78
|
+
console.error(message);
|
|
79
|
+
console.log();
|
|
80
|
+
console.error(error);
|
|
81
|
+
console.log();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (process.env.NODE_ENV !== "test" && process.argv[1]?.endsWith("generate.js")) {
|
|
85
|
+
run();
|
|
86
|
+
}
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
generate,
|
|
90
|
+
run
|
|
91
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LoadTypedefsOptions } from '@graphql-tools/load';
|
|
2
|
+
type TypeDefResult = {
|
|
3
|
+
typeDefFiles: string[];
|
|
4
|
+
errors: {
|
|
5
|
+
message: string;
|
|
6
|
+
error: unknown;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export declare const generateTypeDefGraphQLApi: () => Promise<TypeDefResult>;
|
|
10
|
+
export declare const generateTypeDefGraphQLWeb: () => Promise<TypeDefResult>;
|
|
11
|
+
export declare function getLoadDocumentsOptions(filename: string): LoadTypedefsOptions<{
|
|
12
|
+
cwd: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const getResolverFnType: () => "(\n args: TArgs,\n obj?: { root: TParent; context: TContext; info: GraphQLResolveInfo }\n ) => TResult | Promise<TResult>" | "(\n args?: TArgs,\n obj?: { root: TParent; context: TContext; info: GraphQLResolveInfo }\n ) => TResult | Promise<TResult>";
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=graphqlCodeGen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAc9D,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CAgFvE,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CAwDvE,CAAA;AAiCD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM;SACD,MAAM;GAQ5D;AAqHD,eAAO,MAAM,iBAAiB,4RAe7B,CAAA"}
|