@cedarjs/internal 0.0.4

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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/ast.d.ts +26 -0
  4. package/dist/ast.d.ts.map +1 -0
  5. package/dist/ast.js +198 -0
  6. package/dist/build/api.d.ts +6 -0
  7. package/dist/build/api.d.ts.map +1 -0
  8. package/dist/build/api.js +109 -0
  9. package/dist/cliLogger.d.ts +11 -0
  10. package/dist/cliLogger.d.ts.map +1 -0
  11. package/dist/cliLogger.js +36 -0
  12. package/dist/dev.d.ts +2 -0
  13. package/dist/dev.d.ts.map +1 -0
  14. package/dist/dev.js +41 -0
  15. package/dist/files.d.ts +51 -0
  16. package/dist/files.d.ts.map +1 -0
  17. package/dist/files.js +223 -0
  18. package/dist/generate/clientPreset.d.ts +17 -0
  19. package/dist/generate/clientPreset.d.ts.map +1 -0
  20. package/dist/generate/clientPreset.js +85 -0
  21. package/dist/generate/generate.d.ts +10 -0
  22. package/dist/generate/generate.d.ts.map +1 -0
  23. package/dist/generate/generate.js +91 -0
  24. package/dist/generate/graphqlCodeGen.d.ts +16 -0
  25. package/dist/generate/graphqlCodeGen.d.ts.map +1 -0
  26. package/dist/generate/graphqlCodeGen.js +339 -0
  27. package/dist/generate/graphqlSchema.d.ts +8 -0
  28. package/dist/generate/graphqlSchema.d.ts.map +1 -0
  29. package/dist/generate/graphqlSchema.js +153 -0
  30. package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts +6 -0
  31. package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -0
  32. package/dist/generate/plugins/rw-typescript-resolvers/index.js +67 -0
  33. package/dist/generate/plugins/rw-typescript-resolvers/visitor.d.ts +9 -0
  34. package/dist/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -0
  35. package/dist/generate/plugins/rw-typescript-resolvers/visitor.js +84 -0
  36. package/dist/generate/possibleTypes.d.ts +36 -0
  37. package/dist/generate/possibleTypes.d.ts.map +1 -0
  38. package/dist/generate/possibleTypes.js +106 -0
  39. package/dist/generate/templates/all-currentUser.d.ts.template +28 -0
  40. package/dist/generate/templates/api-globImports.d.ts.template +9 -0
  41. package/dist/generate/templates/api-globalContext.d.ts.template +7 -0
  42. package/dist/generate/templates/api-scenarios.d.ts.template +10 -0
  43. package/dist/generate/templates/api-test-globals.d.ts.template +5 -0
  44. package/dist/generate/templates/mirror-cell.d.ts.template +13 -0
  45. package/dist/generate/templates/mirror-directoryNamedModule.d.ts.template +5 -0
  46. package/dist/generate/templates/web-routerRoutes.d.ts.template +20 -0
  47. package/dist/generate/templates/web-routesPages.d.ts.template +13 -0
  48. package/dist/generate/templates/web-test-globals.d.ts.template +7 -0
  49. package/dist/generate/templates.d.ts +6 -0
  50. package/dist/generate/templates.d.ts.map +1 -0
  51. package/dist/generate/templates.js +61 -0
  52. package/dist/generate/trustedDocuments.d.ts +3 -0
  53. package/dist/generate/trustedDocuments.d.ts.map +1 -0
  54. package/dist/generate/trustedDocuments.js +95 -0
  55. package/dist/generate/typeDefinitions.d.ts +30 -0
  56. package/dist/generate/typeDefinitions.d.ts.map +1 -0
  57. package/dist/generate/typeDefinitions.js +369 -0
  58. package/dist/generate/types.d.ts +6 -0
  59. package/dist/generate/types.d.ts.map +1 -0
  60. package/dist/generate/types.js +16 -0
  61. package/dist/generate/watch.d.ts +3 -0
  62. package/dist/generate/watch.d.ts.map +1 -0
  63. package/dist/generate/watch.js +124 -0
  64. package/dist/gql.d.ts +14 -0
  65. package/dist/gql.d.ts.map +1 -0
  66. package/dist/gql.js +108 -0
  67. package/dist/index.d.ts +11 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +49 -0
  70. package/dist/jsx.d.ts +16 -0
  71. package/dist/jsx.d.ts.map +1 -0
  72. package/dist/jsx.js +100 -0
  73. package/dist/jsxAttributeValue.d.ts +2 -0
  74. package/dist/jsxAttributeValue.d.ts.map +1 -0
  75. package/dist/jsxAttributeValue.js +129 -0
  76. package/dist/project.d.ts +8 -0
  77. package/dist/project.d.ts.map +1 -0
  78. package/dist/project.js +82 -0
  79. package/dist/routes.d.ts +42 -0
  80. package/dist/routes.d.ts.map +1 -0
  81. package/dist/routes.js +111 -0
  82. package/dist/ts2js.d.ts +40 -0
  83. package/dist/ts2js.d.ts.map +1 -0
  84. package/dist/ts2js.js +159 -0
  85. package/dist/validateSchema.d.ts +14 -0
  86. package/dist/validateSchema.d.ts.map +1 -0
  87. package/dist/validateSchema.js +193 -0
  88. package/package.json +131 -0
@@ -0,0 +1,36 @@
1
+ type PossibleTypesResult = {
2
+ possibleTypesFiles: string[];
3
+ errors: {
4
+ message: string;
5
+ error: unknown;
6
+ }[];
7
+ };
8
+ /**
9
+ * Generate possible types from fragments and union types
10
+ *
11
+ * In order to use fragments with unions and interfaces in Apollo Client,
12
+ * you need to tell the client how to discriminate between the different
13
+ * types that implement or belong to a supertype.
14
+ *
15
+ * You pass a possibleTypes option to the InMemoryCache constructor
16
+ * to specify these relationships in your schema.
17
+ *
18
+ * This object maps the name of an interface or union type (the supertype)
19
+ * to the types that implement or belong to it (the subtypes).
20
+ *
21
+ * For example:
22
+ *
23
+ * ```ts
24
+ * possibleTypes: {
25
+ * Character: ["Jedi", "Droid"],
26
+ * Test: ["PassingTest", "FailingTest", "SkippedTest"],
27
+ * Snake: ["Viper", "Python"],
28
+ * Groceries: ['Fruit', 'Vegetable'],
29
+ * },
30
+ * ```
31
+ *
32
+ * @see https://www.apollographql.com/docs/react/data/fragments/#using-fragments-with-unions-and-interfaces
33
+ **/
34
+ export declare const generatePossibleTypes: () => Promise<PossibleTypesResult>;
35
+ export {};
36
+ //# sourceMappingURL=possibleTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"possibleTypes.d.ts","sourceRoot":"","sources":["../../src/generate/possibleTypes.ts"],"names":[],"mappings":"AAYA,KAAK,mBAAmB,GAAG;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;IAyBI;AACJ,eAAO,MAAM,qBAAqB,QAAa,OAAO,CAAC,mBAAmB,CAyEzE,CAAA"}
@@ -0,0 +1,106 @@
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 possibleTypes_exports = {};
30
+ __export(possibleTypes_exports, {
31
+ generatePossibleTypes: () => generatePossibleTypes
32
+ });
33
+ module.exports = __toCommonJS(possibleTypes_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ var import_path = __toESM(require("path"));
36
+ var fragmentMatcher = __toESM(require("@graphql-codegen/fragment-matcher"));
37
+ var import_graphql_file_loader = require("@graphql-tools/graphql-file-loader");
38
+ var import_load = require("@graphql-tools/load");
39
+ var import_prettier = require("prettier");
40
+ var import_project_config = require("@cedarjs/project-config");
41
+ var import_graphqlCodeGen = require("./graphqlCodeGen");
42
+ const generatePossibleTypes = async () => {
43
+ const config = (0, import_project_config.getConfig)();
44
+ if (!config.graphql.fragments) {
45
+ return {
46
+ possibleTypesFiles: [],
47
+ errors: []
48
+ };
49
+ }
50
+ const filename = import_path.default.join((0, import_project_config.getPaths)().web.graphql, "possibleTypes.ts");
51
+ const options = (0, import_graphqlCodeGen.getLoadDocumentsOptions)(filename);
52
+ const documentsGlob = "./web/src/**/!(*.d).{ts,tsx,js,jsx}";
53
+ let documents;
54
+ try {
55
+ documents = await (0, import_load.loadDocuments)([documentsGlob], options);
56
+ } catch {
57
+ return {
58
+ possibleTypesFiles: [],
59
+ errors: []
60
+ };
61
+ }
62
+ const errors = [];
63
+ try {
64
+ const files = [];
65
+ const pluginConfig = {};
66
+ const info = {
67
+ outputFile: filename
68
+ };
69
+ const schema = (0, import_load.loadSchemaSync)((0, import_project_config.getPaths)().generated.schema, {
70
+ loaders: [new import_graphql_file_loader.GraphQLFileLoader()],
71
+ sort: true
72
+ });
73
+ const possibleTypes = await fragmentMatcher.plugin(
74
+ schema,
75
+ documents,
76
+ pluginConfig,
77
+ info
78
+ );
79
+ files.push(filename);
80
+ const output = await (0, import_prettier.format)(possibleTypes.toString(), {
81
+ trailingComma: "es5",
82
+ bracketSpacing: true,
83
+ tabWidth: 2,
84
+ semi: false,
85
+ singleQuote: true,
86
+ arrowParens: "always",
87
+ parser: "typescript"
88
+ });
89
+ import_fs.default.mkdirSync(import_path.default.dirname(filename), { recursive: true });
90
+ import_fs.default.writeFileSync(filename, output);
91
+ return { possibleTypesFiles: [filename], errors };
92
+ } catch (e) {
93
+ errors.push({
94
+ message: "Error: Could not generate GraphQL possible types (web)",
95
+ error: e
96
+ });
97
+ return {
98
+ possibleTypesFiles: [],
99
+ errors
100
+ };
101
+ }
102
+ };
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ generatePossibleTypes
106
+ });
@@ -0,0 +1,28 @@
1
+ import '@cedarjs/api'
2
+ import '@cedarjs/auth'
3
+
4
+ import { getCurrentUser } from '../../../api/src/lib/auth'
5
+
6
+ export type InferredCurrentUser = Awaited<ReturnType<typeof getCurrentUser>>
7
+
8
+ type UndefinedRoles = {
9
+ /**
10
+ * ⚠️ Heads-Up: This is undefined unless roles key is returned from {@link getCurrentUser()}
11
+ *
12
+ * You may take a look at https://redwoodjs.com/docs/tutorial/chapter7/rbac for a tutorial on
13
+ * how to add fully-fledged RBAC (Role-based Access Control) to your database model.
14
+ */
15
+ roles?: unknown | unknown[]
16
+ }
17
+
18
+ type Overwrite<T, U> = Omit<T, keyof U> & U
19
+
20
+ declare module '@cedarjs/context' {
21
+ interface GlobalContext {
22
+ currentUser?: Overwrite<UndefinedRoles, InferredCurrentUser>
23
+ }
24
+ }
25
+
26
+ declare module '@cedarjs/auth' {
27
+ interface CurrentUser extends InferredCurrentUser {}
28
+ }
@@ -0,0 +1,9 @@
1
+ declare module 'src/services/**/*.{js,ts}'
2
+ declare module 'src/directives/**/*.{js,ts}'
3
+ declare module 'src/graphql/**/*.sdl.{js,ts}'
4
+ declare module 'src/subscriptions/**/*.{js,ts}'
5
+
6
+
7
+ declare module 'api/src/services/**/*.{js,ts}'
8
+ declare module 'api/src/directives/**/*.{js,ts}'
9
+ declare module 'api/src/graphql/**/*.sdl.{js,ts}'
@@ -0,0 +1,7 @@
1
+ import type { GlobalContext } from "@cedarjs/context"
2
+
3
+ export {}
4
+
5
+ declare global {
6
+ const context: GlobalContext
7
+ }
@@ -0,0 +1,10 @@
1
+ import type { Scenario, DefineScenario, DescribeScenario } from '@cedarjs/testing/api'
2
+
3
+ declare global {
4
+ /**
5
+ * Note that the scenario name must match the exports in your {model}.scenarios.ts file
6
+ */
7
+ const scenario: Scenario
8
+ const describeScenario: DescribeScenario
9
+ const defineScenario: DefineScenario
10
+ }
@@ -0,0 +1,5 @@
1
+ import type { CurrentUser } from '@cedarjs/auth'
2
+
3
+ declare global {
4
+ const mockCurrentUser: (currentUser: CurrentUser) => void
5
+ }
@@ -0,0 +1,13 @@
1
+ import * as Cell from './${name}'
2
+ import type { CellProps } from '@cedarjs/web'
3
+ import type { ${queryResultType}, ${queryVariablesType} } from 'types/graphql'
4
+
5
+ type SuccessType = typeof Cell.Success
6
+
7
+ export * from './${name}'
8
+
9
+ type CellInputs = CellProps<SuccessType, ${queryResultType}, typeof Cell, ${queryVariablesType}>
10
+
11
+ export default function (props: CellInputs): ReturnType<SuccessType>
12
+
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { default as DEFAULT } from './${name}'
2
+ export default DEFAULT
3
+ export * from './${name}'
4
+
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { RouteParams, QueryParams } from '@cedarjs/router'
2
+
3
+ declare module '@cedarjs/router' {
4
+ interface AvailableRoutes {
5
+ // Only "<Route />" components with a "name" and "path" prop will be populated here.
6
+ ${routes.map(
7
+ ({ props: { name, path }}) => {
8
+ return ` ${name}: (params?: RouteParams<"${path}"> & QueryParams) => "${path}"`
9
+ }
10
+ ).join('\n')}
11
+ }
12
+
13
+ export function useRoutePaths(): Record<keyof AvailableRoutes, string>
14
+ export function useRoutePath(routeName: keyof AvailableRoutes): string
15
+
16
+ /** Gets the name of the current route (as defined in your Routes file) */
17
+ export function useRouteName(): keyof AvailableRoutes | undefined
18
+ }
19
+
20
+ //# sourceMappingURL=web-routerRoutes.d.ts.map
@@ -0,0 +1,13 @@
1
+ ${pages
2
+ .map(({ importName, importPath }) => {
3
+ return `import ${importName}Type from '${importPath}'`
4
+ })
5
+ .join('\n')}
6
+
7
+ declare global {
8
+ ${pages.map(({ importName }) => {
9
+ return ` const ${importName}: typeof ${importName}Type`
10
+ }).join('\n')}
11
+ }
12
+
13
+ //# sourceMappingURL=web-routesPages.d.ts.map
@@ -0,0 +1,7 @@
1
+ // Import other mocking function globals
2
+ import '@cedarjs/testing'
3
+ import { InferredCurrentUser } from './all-currentUser'
4
+
5
+ declare global {
6
+ const mockCurrentUser: (currentUser: InferredCurrentUser) => void
7
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Write the contents of the template to the destination and interpolate the variables.
3
+ * The template is a string that uses standard es6 template literals which allow embded expression.
4
+ */
5
+ export declare const writeTemplate: (templatePath: string, destination: string, templateValues?: Record<string, unknown>) => void;
6
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/generate/templates.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,aAAa,iBACV,MAAM,eACP,MAAM,mBACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAYxC,CAAA"}
@@ -0,0 +1,61 @@
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 templates_exports = {};
30
+ __export(templates_exports, {
31
+ writeTemplate: () => writeTemplate
32
+ });
33
+ module.exports = __toCommonJS(templates_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ var import_path = __toESM(require("path"));
36
+ const writeTemplate = (templatePath, destination, templateValues = {}) => {
37
+ const templateString = import_fs.default.readFileSync(
38
+ import_path.default.join(__dirname, templatePath),
39
+ "utf-8"
40
+ );
41
+ const template = templatized(templateString, templateValues);
42
+ import_fs.default.writeFileSync(
43
+ destination,
44
+ "// This file was generated by RedwoodJS\n" + template
45
+ );
46
+ };
47
+ const templatized = (template, vars = {}) => {
48
+ const handler = new Function(
49
+ "vars",
50
+ [
51
+ "const tagged = ( " + Object.keys(vars).join(", ") + " ) =>",
52
+ "`" + template + "`",
53
+ "return tagged(...Object.values(vars))"
54
+ ].join("\n")
55
+ );
56
+ return handler(vars);
57
+ };
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ writeTemplate
61
+ });
@@ -0,0 +1,3 @@
1
+ export declare const trustedDocumentsStore: (generatedFiles: any) => Promise<string>;
2
+ export declare const replaceGqlTagWithTrustedDocumentGraphql: (generatedFiles: any) => Promise<void>;
3
+ //# sourceMappingURL=trustedDocuments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trustedDocuments.d.ts","sourceRoot":"","sources":["../../src/generate/trustedDocuments.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,qBAAqB,mBAA0B,GAAG,oBA8B9D,CAAA;AAID,eAAO,MAAM,uCAAuC,mBAClC,GAAG,kBA8BpB,CAAA"}
@@ -0,0 +1,95 @@
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 trustedDocuments_exports = {};
30
+ __export(trustedDocuments_exports, {
31
+ replaceGqlTagWithTrustedDocumentGraphql: () => replaceGqlTagWithTrustedDocumentGraphql,
32
+ trustedDocumentsStore: () => trustedDocumentsStore
33
+ });
34
+ module.exports = __toCommonJS(trustedDocuments_exports);
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_path = __toESM(require("path"));
37
+ var import_prettier = require("prettier");
38
+ var import_project_config = require("@cedarjs/project-config");
39
+ const trustedDocumentsStore = async (generatedFiles) => {
40
+ let trustedDocumentsStoreFile = "";
41
+ const output = generatedFiles.filter(
42
+ (f) => f.filename.endsWith("persisted-documents.json")
43
+ );
44
+ const storeFile = output[0];
45
+ if (storeFile?.content) {
46
+ const content = await (0, import_prettier.format)(`export const store = ${storeFile.content}`, {
47
+ trailingComma: "es5",
48
+ bracketSpacing: true,
49
+ tabWidth: 2,
50
+ semi: false,
51
+ singleQuote: true,
52
+ arrowParens: "always",
53
+ parser: "typescript"
54
+ });
55
+ trustedDocumentsStoreFile = import_path.default.join(
56
+ (0, import_project_config.getPaths)().api.lib,
57
+ "trustedDocumentsStore.ts"
58
+ );
59
+ import_fs.default.mkdirSync(import_path.default.dirname(trustedDocumentsStoreFile), { recursive: true });
60
+ import_fs.default.writeFileSync(trustedDocumentsStoreFile, content);
61
+ }
62
+ return trustedDocumentsStoreFile;
63
+ };
64
+ const replaceGqlTagWithTrustedDocumentGraphql = async (generatedFiles) => {
65
+ const gqlFileOutput = generatedFiles.filter(
66
+ (f) => f.filename.endsWith("gql.ts")
67
+ );
68
+ const gqlFile = gqlFileOutput[0];
69
+ if (gqlFile?.content) {
70
+ gqlFile.content += `
71
+
72
+ export function gql(source: string | TemplateStringsArray) {
73
+ if (typeof source === 'string') {
74
+ return graphql(source)
75
+ }
76
+
77
+ return graphql(source.join('\\n'))
78
+ }`;
79
+ const content = await (0, import_prettier.format)(gqlFile.content, {
80
+ trailingComma: "es5",
81
+ bracketSpacing: true,
82
+ tabWidth: 2,
83
+ semi: true,
84
+ singleQuote: false,
85
+ arrowParens: "always",
86
+ parser: "typescript"
87
+ });
88
+ import_fs.default.writeFileSync(gqlFile.filename, content);
89
+ }
90
+ };
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ replaceGqlTagWithTrustedDocumentGraphql,
94
+ trustedDocumentsStore
95
+ });
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Generate all the types for a RedwoodJS project
3
+ * and return the generated path to files, so they're logged
4
+ */
5
+ export declare const generateTypeDefs: () => Promise<{
6
+ typeDefFiles: string[];
7
+ errors: {
8
+ message: string;
9
+ error: unknown;
10
+ }[];
11
+ }>;
12
+ export declare const generateMirrorDirectoryNamedModules: () => string[];
13
+ export declare const mirrorPathForDirectoryNamedModules: (p: string, rwjsPaths?: import("@cedarjs/project-config").Paths) => string[];
14
+ export declare const generateMirrorDirectoryNamedModule: (p: string, rwjsPaths?: import("@cedarjs/project-config").Paths) => string;
15
+ export declare const generateMirrorCells: () => string[];
16
+ export declare const mirrorPathForCell: (p: string, rwjsPaths?: import("@cedarjs/project-config").Paths) => string[];
17
+ export declare const generateMirrorCell: (p: string, rwjsPaths?: import("@cedarjs/project-config").Paths) => string;
18
+ export declare const generateTypeDefRouterRoutes: () => string[];
19
+ export declare const generateTypeDefRouterPages: () => string[];
20
+ export declare const generateTypeDefCurrentUser: () => string[];
21
+ export declare const generateTypeDefScenarios: () => string[];
22
+ export declare const generateTypeDefTestMocks: () => string[];
23
+ export declare const generateTypeDefGlobImports: () => string[];
24
+ export declare const generateTypeDefGlobalContext: () => string[];
25
+ /**
26
+ * Typescript does not preserve triple slash directives when outputting js or d.ts files.
27
+ * This is a work around so that *.svg, *.png, etc. imports have types.
28
+ */
29
+ export declare const generateViteClientTypesDirective: () => string[];
30
+ //# sourceMappingURL=typeDefinitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeDefinitions.d.ts","sourceRoot":"","sources":["../../src/generate/typeDefinitions.ts"],"names":[],"mappings":"AAyCA;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;EAyB5B,CAAA;AAED,eAAO,MAAM,mCAAmC,gBAK/C,CAAA;AAED,eAAO,MAAM,kCAAkC,MAC1C,MAAM,kEAUV,CAAA;AAED,eAAO,MAAM,kCAAkC,MAC1C,MAAM,gEAqDV,CAAA;AAED,eAAO,MAAM,mBAAmB,gBAG/B,CAAA;AAED,eAAO,MAAM,iBAAiB,MAAO,MAAM,kEAQ1C,CAAA;AAED,eAAO,MAAM,kBAAkB,MAAO,MAAM,gEA8D3C,CAAA;AAiBD,eAAO,MAAM,2BAA2B,gBAmEvC,CAAA;AAED,eAAO,MAAM,0BAA0B,gBA8CtC,CAAA;AAED,eAAO,MAAM,0BAA0B,gBAEtC,CAAA;AAED,eAAO,MAAM,wBAAwB,gBAEpC,CAAA;AAED,eAAO,MAAM,wBAAwB,gBAKpC,CAAA;AAED,eAAO,MAAM,0BAA0B,gBAEtC,CAAA;AAED,eAAO,MAAM,4BAA4B,gBAExC,CAAA;AACD;;;GAGG;AACH,eAAO,MAAM,gCAAgC,gBAW5C,CAAA"}