@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,84 @@
|
|
|
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 visitor_exports = {};
|
|
20
|
+
__export(visitor_exports, {
|
|
21
|
+
RwTypeScriptResolversVisitor: () => RwTypeScriptResolversVisitor
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(visitor_exports);
|
|
24
|
+
var import_typescript_resolvers = require("@graphql-codegen/typescript-resolvers");
|
|
25
|
+
var import_visitor_plugin_common = require("@graphql-codegen/visitor-plugin-common");
|
|
26
|
+
class RwTypeScriptResolversVisitor extends import_typescript_resolvers.TypeScriptResolversVisitor {
|
|
27
|
+
constructor(pluginConfig, schema) {
|
|
28
|
+
super(pluginConfig, schema);
|
|
29
|
+
}
|
|
30
|
+
FieldDefinition(node, key, parent) {
|
|
31
|
+
const hasArguments = node.arguments && node.arguments.length > 0;
|
|
32
|
+
const superFieldDefinition = super.FieldDefinition(node, key, parent);
|
|
33
|
+
return (parentName) => {
|
|
34
|
+
const fieldDef = superFieldDefinition(parentName);
|
|
35
|
+
if (!hasArguments && fieldDef?.includes(": Resolver<")) {
|
|
36
|
+
return fieldDef.replace(": Resolver<", ": OptArgsResolverFn<");
|
|
37
|
+
}
|
|
38
|
+
return fieldDef;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Original implementation is here:
|
|
42
|
+
// https://github.com/dotansimha/graphql-code-generator/blob/c6c60a3078f3797af435c3852220d8898964031d/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts#L1091
|
|
43
|
+
ObjectTypeDefinition(node) {
|
|
44
|
+
const originalBlock = super.ObjectTypeDefinition(node);
|
|
45
|
+
const name = this.convertName(node, {
|
|
46
|
+
suffix: this.config.resolverTypeSuffix
|
|
47
|
+
});
|
|
48
|
+
const typeName = node.name;
|
|
49
|
+
const parentType = this.getParentTypeToUse(typeName);
|
|
50
|
+
const fieldsContent = (node.fields || []).map((f) => f(node.name));
|
|
51
|
+
const isRootType = [
|
|
52
|
+
this.schema.getQueryType()?.name,
|
|
53
|
+
this.schema.getMutationType()?.name,
|
|
54
|
+
this.schema.getSubscriptionType()?.name
|
|
55
|
+
].includes(typeName);
|
|
56
|
+
if (!isRootType) {
|
|
57
|
+
fieldsContent.push(
|
|
58
|
+
(0, import_visitor_plugin_common.indent)(
|
|
59
|
+
`${this.config.internalResolversPrefix}isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>${this.getPunctuation(
|
|
60
|
+
"type"
|
|
61
|
+
)}`
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const blockRelationsResolver = new import_visitor_plugin_common.DeclarationBlock(
|
|
66
|
+
this._declarationBlockConfig
|
|
67
|
+
).export().asKind("type").withName(
|
|
68
|
+
name.replace("Resolvers", "RelationResolvers"),
|
|
69
|
+
`<ContextType = ${this.config.contextType.type}, ${this.transformParentGenericType(parentType)}>`
|
|
70
|
+
).withBlock(
|
|
71
|
+
fieldsContent.map(
|
|
72
|
+
(content) => content.replace(
|
|
73
|
+
/: (?:OptArgs)?Resolver(?:Fn)?/,
|
|
74
|
+
"?: RequiredResolverFn"
|
|
75
|
+
)
|
|
76
|
+
).join("\n")
|
|
77
|
+
);
|
|
78
|
+
return originalBlock + "\n" + blockRelationsResolver.string;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
RwTypeScriptResolversVisitor
|
|
84
|
+
});
|
|
@@ -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"), 1);
|
|
35
|
+
var import_path = __toESM(require("path"), 1);
|
|
36
|
+
var fragmentMatcher = __toESM(require("@graphql-codegen/fragment-matcher"), 1);
|
|
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.js");
|
|
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,30 @@
|
|
|
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 a roles key is returned from
|
|
11
|
+
* {@link getCurrentUser()}
|
|
12
|
+
*
|
|
13
|
+
* You may take a look at https://cedarjs.com/docs/tutorial/chapter7/rbac for
|
|
14
|
+
* a tutorial on how to add fully-fledged RBAC (Role-based Access Control) to
|
|
15
|
+
* your database model.
|
|
16
|
+
*/
|
|
17
|
+
roles?: unknown | unknown[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Overwrite<T, U> = Omit<T, keyof U> & U
|
|
21
|
+
|
|
22
|
+
declare module '@cedarjs/context' {
|
|
23
|
+
interface GlobalContext {
|
|
24
|
+
currentUser?: Overwrite<UndefinedRoles, InferredCurrentUser>
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module '@cedarjs/auth' {
|
|
29
|
+
interface CurrentUser extends InferredCurrentUser {}
|
|
30
|
+
}
|
|
@@ -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,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,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,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,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":"AASA;;;GAGG;AACH,eAAO,MAAM,aAAa,iBACV,MAAM,eACP,MAAM,mBACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAYxC,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
+
const import_meta = {};
|
|
37
|
+
const ___dirname = (
|
|
38
|
+
// __dirname will work for CJS, and import.meta.dirname will work for ESM
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
typeof __dirname !== "undefined" ? __dirname : import_meta?.dirname
|
|
42
|
+
);
|
|
43
|
+
const writeTemplate = (templatePath, destination, templateValues = {}) => {
|
|
44
|
+
const templateString = import_node_fs.default.readFileSync(
|
|
45
|
+
import_node_path.default.join(___dirname, templatePath),
|
|
46
|
+
"utf-8"
|
|
47
|
+
);
|
|
48
|
+
const template = templatized(templateString, templateValues);
|
|
49
|
+
import_node_fs.default.writeFileSync(
|
|
50
|
+
destination,
|
|
51
|
+
"// This file was generated by CedarJS\n" + template
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
const templatized = (template, vars = {}) => {
|
|
55
|
+
const handler = new Function(
|
|
56
|
+
"vars",
|
|
57
|
+
[
|
|
58
|
+
"const tagged = ( " + Object.keys(vars).join(", ") + " ) =>",
|
|
59
|
+
"`" + template + "`",
|
|
60
|
+
"return tagged(...Object.values(vars))"
|
|
61
|
+
].join("\n")
|
|
62
|
+
);
|
|
63
|
+
return handler(vars);
|
|
64
|
+
};
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
writeTemplate
|
|
68
|
+
});
|
|
@@ -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"), 1);
|
|
36
|
+
var import_path = __toESM(require("path"), 1);
|
|
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 CedarJS project and return the generated path to
|
|
3
|
+
* 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;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,gBAW5C,CAAA"}
|