@postxl/generator 0.74.2 → 1.0.1
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/LICENSE +50 -0
- package/README.md +79 -1
- package/dist/generator-manager.class.d.ts +59 -0
- package/dist/generator-manager.class.js +221 -0
- package/dist/generator.class.d.ts +90 -0
- package/dist/generator.class.js +32 -0
- package/dist/generator.context.d.ts +174 -0
- package/dist/generator.context.js +125 -0
- package/dist/helpers/branded.types.d.ts +149 -0
- package/dist/helpers/branded.types.js +111 -0
- package/dist/helpers/config-builder.class.d.ts +27 -0
- package/dist/helpers/config-builder.class.js +54 -0
- package/dist/helpers/import-generator.class.d.ts +70 -0
- package/dist/helpers/import-generator.class.js +166 -0
- package/dist/helpers/importable.types.d.ts +52 -0
- package/dist/helpers/importable.types.js +15 -0
- package/dist/helpers/index-generator.class.d.ts +10 -0
- package/dist/helpers/index-generator.class.js +46 -0
- package/dist/helpers/index.d.ts +8 -0
- package/dist/helpers/index.js +24 -0
- package/dist/helpers/package-json.generator.d.ts +56 -0
- package/dist/helpers/package-json.generator.js +36 -0
- package/dist/helpers/tsconfig.generator.d.ts +1 -0
- package/dist/helpers/tsconfig.generator.js +14 -0
- package/dist/helpers/verify-context.d.ts +4 -0
- package/dist/helpers/verify-context.js +23 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/utils/checksum.d.ts +10 -0
- package/dist/utils/checksum.js +132 -0
- package/dist/utils/fs-utils.d.ts +34 -0
- package/dist/utils/fs-utils.js +126 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +26 -0
- package/dist/utils/jsdoc.d.ts +12 -0
- package/dist/utils/jsdoc.js +37 -0
- package/dist/utils/lint.d.ts +46 -0
- package/dist/utils/lint.js +154 -0
- package/dist/utils/lockfile.d.ts +7 -0
- package/dist/utils/lockfile.js +80 -0
- package/dist/utils/logger.class.d.ts +25 -0
- package/dist/utils/logger.class.js +55 -0
- package/dist/utils/merge-conflict.d.ts +55 -0
- package/dist/utils/merge-conflict.js +264 -0
- package/dist/utils/path.d.ts +52 -0
- package/dist/utils/path.js +183 -0
- package/dist/utils/prettier-config.d.ts +2 -0
- package/dist/utils/prettier-config.js +13 -0
- package/dist/utils/prettier.d.ts +5 -0
- package/dist/utils/prettier.js +67 -0
- package/dist/utils/prettier.skiptest.d.ts +1 -0
- package/dist/utils/prettier.skiptest.js +22 -0
- package/dist/utils/promise.d.ts +2 -0
- package/dist/utils/promise.js +10 -0
- package/dist/utils/string-functions.d.ts +9 -0
- package/dist/utils/string-functions.js +23 -0
- package/dist/utils/sync-log-result.d.ts +9 -0
- package/dist/utils/sync-log-result.js +90 -0
- package/dist/utils/sync.d.ts +143 -0
- package/dist/utils/sync.js +325 -0
- package/dist/utils/template.d.ts +66 -0
- package/dist/utils/template.js +159 -0
- package/dist/utils/vfs.class.d.ts +115 -0
- package/dist/utils/vfs.class.js +239 -0
- package/dist/utils/zip.d.ts +13 -0
- package/dist/utils/zip.js +40 -0
- package/package.json +57 -34
- package/dist/generator.d.ts +0 -13
- package/dist/generator.js +0 -455
- package/dist/generators/enums/react.generator.d.ts +0 -10
- package/dist/generators/enums/react.generator.js +0 -110
- package/dist/generators/enums/types.generator.d.ts +0 -10
- package/dist/generators/enums/types.generator.js +0 -39
- package/dist/generators/indices/data/module.generator.d.ts +0 -9
- package/dist/generators/indices/data/module.generator.js +0 -60
- package/dist/generators/indices/data/service.generator.d.ts +0 -9
- package/dist/generators/indices/data/service.generator.js +0 -249
- package/dist/generators/indices/data/types.generator.d.ts +0 -9
- package/dist/generators/indices/data/types.generator.js +0 -49
- package/dist/generators/indices/dispatcher-service.generator.d.ts +0 -9
- package/dist/generators/indices/dispatcher-service.generator.js +0 -107
- package/dist/generators/indices/export/class.generator.d.ts +0 -9
- package/dist/generators/indices/export/class.generator.js +0 -140
- package/dist/generators/indices/export/encoder.generator.d.ts +0 -9
- package/dist/generators/indices/export/encoder.generator.js +0 -50
- package/dist/generators/indices/import/convert-functions.generator.d.ts +0 -9
- package/dist/generators/indices/import/convert-functions.generator.js +0 -509
- package/dist/generators/indices/import/decoder.generator.d.ts +0 -9
- package/dist/generators/indices/import/decoder.generator.js +0 -40
- package/dist/generators/indices/import/service.generator.d.ts +0 -9
- package/dist/generators/indices/import/service.generator.js +0 -573
- package/dist/generators/indices/import/types.generator.d.ts +0 -9
- package/dist/generators/indices/import/types.generator.js +0 -242
- package/dist/generators/indices/repositories.generator.d.ts +0 -9
- package/dist/generators/indices/repositories.generator.js +0 -25
- package/dist/generators/indices/routes.generator.d.ts +0 -9
- package/dist/generators/indices/routes.generator.js +0 -29
- package/dist/generators/indices/seed-migration.generator.d.ts +0 -9
- package/dist/generators/indices/seed-migration.generator.js +0 -36
- package/dist/generators/indices/seed-template.generator.d.ts +0 -9
- package/dist/generators/indices/seed-template.generator.js +0 -80
- package/dist/generators/indices/testids.generator.d.ts +0 -7
- package/dist/generators/indices/testids.generator.js +0 -71
- package/dist/generators/indices/types.generator.d.ts +0 -10
- package/dist/generators/indices/types.generator.js +0 -35
- package/dist/generators/indices/update/actiontypes.generator.d.ts +0 -9
- package/dist/generators/indices/update/actiontypes.generator.js +0 -49
- package/dist/generators/indices/update/module.generator.d.ts +0 -9
- package/dist/generators/indices/update/module.generator.js +0 -41
- package/dist/generators/indices/update/service.generator.d.ts +0 -9
- package/dist/generators/indices/update/service.generator.js +0 -34
- package/dist/generators/indices/view/module.generator.d.ts +0 -9
- package/dist/generators/indices/view/module.generator.js +0 -39
- package/dist/generators/indices/view/service.generator.d.ts +0 -9
- package/dist/generators/indices/view/service.generator.js +0 -34
- package/dist/generators/models/admin.page.generator.d.ts +0 -7
- package/dist/generators/models/admin.page.generator.js +0 -74
- package/dist/generators/models/export/encoder.generator.d.ts +0 -9
- package/dist/generators/models/export/encoder.generator.js +0 -51
- package/dist/generators/models/import/decoder.generator.d.ts +0 -9
- package/dist/generators/models/import/decoder.generator.js +0 -148
- package/dist/generators/models/react/context.generator.d.ts +0 -9
- package/dist/generators/models/react/context.generator.js +0 -71
- package/dist/generators/models/react/index.d.ts +0 -10
- package/dist/generators/models/react/index.js +0 -31
- package/dist/generators/models/react/library.generator.d.ts +0 -10
- package/dist/generators/models/react/library.generator.js +0 -94
- package/dist/generators/models/react/lookup.generator.d.ts +0 -9
- package/dist/generators/models/react/lookup.generator.js +0 -175
- package/dist/generators/models/react/modals.generator.d.ts +0 -23
- package/dist/generators/models/react/modals.generator.js +0 -710
- package/dist/generators/models/repository.generator.d.ts +0 -9
- package/dist/generators/models/repository.generator.js +0 -955
- package/dist/generators/models/route.generator.d.ts +0 -9
- package/dist/generators/models/route.generator.js +0 -92
- package/dist/generators/models/seed.generator.d.ts +0 -21
- package/dist/generators/models/seed.generator.js +0 -285
- package/dist/generators/models/stub.generator.d.ts +0 -9
- package/dist/generators/models/stub.generator.js +0 -92
- package/dist/generators/models/types.generator.d.ts +0 -9
- package/dist/generators/models/types.generator.js +0 -125
- package/dist/generators/models/update/service.generator.d.ts +0 -10
- package/dist/generators/models/update/service.generator.js +0 -302
- package/dist/generators/models/view/service.generator.d.ts +0 -10
- package/dist/generators/models/view/service.generator.js +0 -239
- package/dist/lib/attributes.d.ts +0 -114
- package/dist/lib/attributes.js +0 -2
- package/dist/lib/exports.d.ts +0 -45
- package/dist/lib/exports.js +0 -90
- package/dist/lib/imports.d.ts +0 -65
- package/dist/lib/imports.js +0 -114
- package/dist/lib/meta.d.ts +0 -1191
- package/dist/lib/meta.js +0 -434
- package/dist/lib/schema/fields.d.ts +0 -46
- package/dist/lib/schema/fields.js +0 -62
- package/dist/lib/schema/schema.d.ts +0 -466
- package/dist/lib/schema/schema.js +0 -18
- package/dist/lib/schema/types.d.ts +0 -201
- package/dist/lib/schema/types.js +0 -112
- package/dist/lib/serializer.d.ts +0 -15
- package/dist/lib/serializer.js +0 -24
- package/dist/lib/test-id-collector.d.ts +0 -42
- package/dist/lib/test-id-collector.js +0 -53
- package/dist/lib/types.d.ts +0 -7
- package/dist/lib/types.js +0 -13
- package/dist/lib/typescript.d.ts +0 -5
- package/dist/lib/typescript.js +0 -22
- package/dist/lib/utils/ast.d.ts +0 -29
- package/dist/lib/utils/ast.js +0 -23
- package/dist/lib/utils/error.d.ts +0 -17
- package/dist/lib/utils/error.js +0 -52
- package/dist/lib/utils/file.d.ts +0 -10
- package/dist/lib/utils/file.js +0 -56
- package/dist/lib/utils/jsdoc.d.ts +0 -9
- package/dist/lib/utils/jsdoc.js +0 -37
- package/dist/lib/utils/logger.d.ts +0 -17
- package/dist/lib/utils/logger.js +0 -12
- package/dist/lib/utils/string.d.ts +0 -40
- package/dist/lib/utils/string.js +0 -187
- package/dist/lib/utils/types.d.ts +0 -12
- package/dist/lib/utils/types.js +0 -2
- package/dist/lib/zod.d.ts +0 -8
- package/dist/lib/zod.js +0 -60
- package/dist/prisma/attributes.d.ts +0 -21
- package/dist/prisma/attributes.js +0 -175
- package/dist/prisma/client-path.d.ts +0 -7
- package/dist/prisma/client-path.js +0 -29
- package/dist/prisma/parse.d.ts +0 -12
- package/dist/prisma/parse.js +0 -452
package/dist/lib/schema/types.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// MARK: - Generated content related types
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.toPackageName = exports.toPath = exports.toBackendModulePath = exports.toModuleLocation = exports.toFolderName = exports.toFileName = exports.toVariableName = exports.toFunctionName = exports.toEnumName = exports.toFieldName = exports.ID_FIELD_NAME = exports.isAnnotatedTypeName = exports.toAnnotatedTypeName = exports.toTypeName = exports.toModelName = exports.toDiscriminantName = exports.toClassName = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Converts a raw string to a branded ClassName.
|
|
7
|
-
*/
|
|
8
|
-
const toClassName = (t) => t;
|
|
9
|
-
exports.toClassName = toClassName;
|
|
10
|
-
/**
|
|
11
|
-
* Brands a raw string as a discriminant.
|
|
12
|
-
*/
|
|
13
|
-
const toDiscriminantName = (t) => t;
|
|
14
|
-
exports.toDiscriminantName = toDiscriminantName;
|
|
15
|
-
/**
|
|
16
|
-
* Brands a raw string to a ModelName identifier.
|
|
17
|
-
*/
|
|
18
|
-
const toModelName = (t) => t;
|
|
19
|
-
exports.toModelName = toModelName;
|
|
20
|
-
/**
|
|
21
|
-
* Brands a raw string to a TypeScript Type identifier.
|
|
22
|
-
*/
|
|
23
|
-
const toTypeName = (t) => t;
|
|
24
|
-
exports.toTypeName = toTypeName;
|
|
25
|
-
/**
|
|
26
|
-
* Converts a branded string to a branded TypeName.
|
|
27
|
-
*/
|
|
28
|
-
const toAnnotatedTypeName = (name) => ({
|
|
29
|
-
typeName: name,
|
|
30
|
-
kind: 'TypeName',
|
|
31
|
-
});
|
|
32
|
-
exports.toAnnotatedTypeName = toAnnotatedTypeName;
|
|
33
|
-
/**
|
|
34
|
-
* Type guard to check if a given type is an AnnotatedTypeName.
|
|
35
|
-
*/
|
|
36
|
-
const isAnnotatedTypeName = (t) => typeof t === 'object' && t.kind === 'TypeName';
|
|
37
|
-
exports.isAnnotatedTypeName = isAnnotatedTypeName;
|
|
38
|
-
/**
|
|
39
|
-
* Brands a raw string to an IdFieldName identifier.
|
|
40
|
-
*/
|
|
41
|
-
exports.ID_FIELD_NAME = 'id';
|
|
42
|
-
/**
|
|
43
|
-
* Brands a raw string to a FieldName identifier.
|
|
44
|
-
*/
|
|
45
|
-
const toFieldName = (t) => t;
|
|
46
|
-
exports.toFieldName = toFieldName;
|
|
47
|
-
/**
|
|
48
|
-
* Brands a raw string to an EnumName identifier.
|
|
49
|
-
*/
|
|
50
|
-
const toEnumName = (t) => t;
|
|
51
|
-
exports.toEnumName = toEnumName;
|
|
52
|
-
/**
|
|
53
|
-
* Converts a string to a branded function name.
|
|
54
|
-
*/
|
|
55
|
-
const toFunctionName = (t) => t;
|
|
56
|
-
exports.toFunctionName = toFunctionName;
|
|
57
|
-
/**
|
|
58
|
-
* Converts a string to a branded VariableName.
|
|
59
|
-
*/
|
|
60
|
-
const toVariableName = (t) => t;
|
|
61
|
-
exports.toVariableName = toVariableName;
|
|
62
|
-
/**
|
|
63
|
-
* Lets you brand a string value as a name of the file.
|
|
64
|
-
*
|
|
65
|
-
* NOTE: THIS SHOULD NOT BE A PATH!
|
|
66
|
-
*/
|
|
67
|
-
const toFileName = (t) => t;
|
|
68
|
-
exports.toFileName = toFileName;
|
|
69
|
-
/**
|
|
70
|
-
* Converts a string to a branded FolderName.
|
|
71
|
-
*/
|
|
72
|
-
const toFolderName = (t) => t;
|
|
73
|
-
exports.toFolderName = toFolderName;
|
|
74
|
-
/**
|
|
75
|
-
* Converts a absolute module file path and a module name to a concrete location.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
*
|
|
79
|
-
* ```ts
|
|
80
|
-
* toModuleLocation(`actions`, `./backend/libs/actions/src/dispatcher.service`)
|
|
81
|
-
* // {
|
|
82
|
-
* // path: '/backend/libs/actions/src/dispatcher.service',
|
|
83
|
-
* // import: '@backend/actions/dispatcher.service'
|
|
84
|
-
* // }
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
const toModuleLocation = (moduleName, absoluteFilePath) => {
|
|
88
|
-
// NOTE: We assume that the file path contains the backend path and a module name
|
|
89
|
-
// and a file is located in the `src` or `e2e` folder.
|
|
90
|
-
const TEST = new RegExp(`(^.+/${moduleName}/src/)|(^.+/e2e/)`);
|
|
91
|
-
if (!absoluteFilePath.match(TEST)) {
|
|
92
|
-
throw new Error(`The file path "${absoluteFilePath}" does not contain the module name "${moduleName}" or is not located in the "src" or "e2e" folder!`);
|
|
93
|
-
}
|
|
94
|
-
const importPath = absoluteFilePath.replace(TEST, `${moduleName}/`);
|
|
95
|
-
return {
|
|
96
|
-
path: (0, exports.toPath)(absoluteFilePath),
|
|
97
|
-
import: (0, exports.toBackendModulePath)(`@backend/${importPath}`),
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
exports.toModuleLocation = toModuleLocation;
|
|
101
|
-
/**
|
|
102
|
-
* Converts a string to a branded BackendModulePath.
|
|
103
|
-
*/
|
|
104
|
-
const toBackendModulePath = (t) => t;
|
|
105
|
-
exports.toBackendModulePath = toBackendModulePath;
|
|
106
|
-
/**
|
|
107
|
-
* Converts a string to a branded PAth.
|
|
108
|
-
*/
|
|
109
|
-
const toPath = (t) => t;
|
|
110
|
-
exports.toPath = toPath;
|
|
111
|
-
const toPackageName = (t) => t;
|
|
112
|
-
exports.toPackageName = toPackageName;
|
package/dist/lib/serializer.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lets you serialize a string content easily.
|
|
3
|
-
*/
|
|
4
|
-
export declare class Serializer {
|
|
5
|
-
private _content;
|
|
6
|
-
constructor();
|
|
7
|
-
/**
|
|
8
|
-
* Appends given content to the file and inserts a newline.
|
|
9
|
-
*/
|
|
10
|
-
append(content: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* Returns the contents of the serializer.
|
|
13
|
-
*/
|
|
14
|
-
print(): string;
|
|
15
|
-
}
|
package/dist/lib/serializer.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Serializer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Lets you serialize a string content easily.
|
|
6
|
-
*/
|
|
7
|
-
class Serializer {
|
|
8
|
-
constructor() {
|
|
9
|
-
this._content = '';
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Appends given content to the file and inserts a newline.
|
|
13
|
-
*/
|
|
14
|
-
append(content) {
|
|
15
|
-
this._content += `${content}\n`;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Returns the contents of the serializer.
|
|
19
|
-
*/
|
|
20
|
-
print() {
|
|
21
|
-
return this._content;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.Serializer = Serializer;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export type TestId = string & {
|
|
2
|
-
__brand: 'ElementId';
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* The TestIdCollector is used to generate and track HTML element IDs.
|
|
6
|
-
* The idea is that it is instantiated once and then used to generate IDs throughout the generators.
|
|
7
|
-
* After the files are generated, all generated IDs can be serialized to a file.
|
|
8
|
-
*
|
|
9
|
-
* An ID can for instance be something like `post-create-name, `${model.name}-${componentType}-${fieldName}`.
|
|
10
|
-
*
|
|
11
|
-
* Each code generator can instantiate a TestIdCollector - the constructor will require the current model & component type.
|
|
12
|
-
* All generated Ids will be stored in a global static Set so we can serialize them later.
|
|
13
|
-
*/
|
|
14
|
-
export declare class TestIdCollector {
|
|
15
|
-
private _prefix;
|
|
16
|
-
/**
|
|
17
|
-
* We store all generated IDs in a global static Set so we can serialize them later.
|
|
18
|
-
*/
|
|
19
|
-
private static _ids;
|
|
20
|
-
constructor(_prefix: string);
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new instance of the TestIdCollector.
|
|
23
|
-
*/
|
|
24
|
-
static from(prefix: string): TestIdCollector;
|
|
25
|
-
/**
|
|
26
|
-
* Generates a new ID for an element and stores it in the collector
|
|
27
|
-
*/
|
|
28
|
-
idFor(
|
|
29
|
-
/**
|
|
30
|
-
* The name of the element, e.g. `age`, `submit`.
|
|
31
|
-
*/
|
|
32
|
-
elementName: string, options?: {
|
|
33
|
-
/**
|
|
34
|
-
* Optional prefix for the type of the element, e.g. `field` or `button`.
|
|
35
|
-
*/
|
|
36
|
-
typePrefix?: string;
|
|
37
|
-
}): TestId;
|
|
38
|
-
/**
|
|
39
|
-
* Returns all generated IDs and resets the stored IDs.
|
|
40
|
-
*/
|
|
41
|
-
static flush(): TestId[];
|
|
42
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestIdCollector = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The TestIdCollector is used to generate and track HTML element IDs.
|
|
6
|
-
* The idea is that it is instantiated once and then used to generate IDs throughout the generators.
|
|
7
|
-
* After the files are generated, all generated IDs can be serialized to a file.
|
|
8
|
-
*
|
|
9
|
-
* An ID can for instance be something like `post-create-name, `${model.name}-${componentType}-${fieldName}`.
|
|
10
|
-
*
|
|
11
|
-
* Each code generator can instantiate a TestIdCollector - the constructor will require the current model & component type.
|
|
12
|
-
* All generated Ids will be stored in a global static Set so we can serialize them later.
|
|
13
|
-
*/
|
|
14
|
-
class TestIdCollector {
|
|
15
|
-
constructor(_prefix) {
|
|
16
|
-
this._prefix = _prefix;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new instance of the TestIdCollector.
|
|
20
|
-
*/
|
|
21
|
-
static from(prefix) {
|
|
22
|
-
return new TestIdCollector(prefix);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Generates a new ID for an element and stores it in the collector
|
|
26
|
-
*/
|
|
27
|
-
idFor(
|
|
28
|
-
/**
|
|
29
|
-
* The name of the element, e.g. `age`, `submit`.
|
|
30
|
-
*/
|
|
31
|
-
elementName, options) {
|
|
32
|
-
const { typePrefix } = options !== null && options !== void 0 ? options : {};
|
|
33
|
-
const id = [this._prefix, typePrefix, elementName].filter((x) => x !== undefined && x !== '').join('-');
|
|
34
|
-
if (TestIdCollector._ids.has(id)) {
|
|
35
|
-
throw new Error(`ID ${id} already exists.`);
|
|
36
|
-
}
|
|
37
|
-
TestIdCollector._ids.add(id);
|
|
38
|
-
return id;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Returns all generated IDs and resets the stored IDs.
|
|
42
|
-
*/
|
|
43
|
-
static flush() {
|
|
44
|
-
const result = [...TestIdCollector._ids.values()];
|
|
45
|
-
TestIdCollector._ids.clear();
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.TestIdCollector = TestIdCollector;
|
|
50
|
-
/**
|
|
51
|
-
* We store all generated IDs in a global static Set so we can serialize them later.
|
|
52
|
-
*/
|
|
53
|
-
TestIdCollector._ids = new Set();
|
package/dist/lib/types.d.ts
DELETED
package/dist/lib/types.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExhaustiveSwitchCheck = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Makes a type check that is only valid when all cases of a switch
|
|
6
|
-
* statement have been covered.
|
|
7
|
-
*/
|
|
8
|
-
class ExhaustiveSwitchCheck extends Error {
|
|
9
|
-
constructor(val) {
|
|
10
|
-
super(`Unreachable case: ${JSON.stringify(val)}`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.ExhaustiveSwitchCheck = ExhaustiveSwitchCheck;
|
package/dist/lib/typescript.d.ts
DELETED
package/dist/lib/typescript.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFieldType = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
/**
|
|
6
|
-
* Converts a field to a TypeScript type definition.
|
|
7
|
-
*/
|
|
8
|
-
function getFieldType(f) {
|
|
9
|
-
switch (f.kind) {
|
|
10
|
-
case 'enum':
|
|
11
|
-
return f.typeName;
|
|
12
|
-
case 'relation':
|
|
13
|
-
return f.relationToModel.brandedIdType;
|
|
14
|
-
case 'id':
|
|
15
|
-
return f.model.brandedIdType;
|
|
16
|
-
case 'scalar':
|
|
17
|
-
return f.tsTypeName;
|
|
18
|
-
default:
|
|
19
|
-
throw new types_1.ExhaustiveSwitchCheck(f);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.getFieldType = getFieldType;
|
package/dist/lib/utils/ast.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A collection of utility functions that let you more easily write TypeScript code.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Utility function that lets you easily create a TypeScript switch statement.
|
|
6
|
-
*/
|
|
7
|
-
export declare function createSwitchStatement({ field, cases, defaultBlock, }: {
|
|
8
|
-
/**
|
|
9
|
-
* The variable name to switch on.
|
|
10
|
-
*/
|
|
11
|
-
field: string;
|
|
12
|
-
/**
|
|
13
|
-
* The cases to switch on.
|
|
14
|
-
*/
|
|
15
|
-
cases: {
|
|
16
|
-
/**
|
|
17
|
-
* The value to match.
|
|
18
|
-
*/
|
|
19
|
-
match: string;
|
|
20
|
-
/**
|
|
21
|
-
* The body of the switch case.
|
|
22
|
-
*/
|
|
23
|
-
block: string;
|
|
24
|
-
}[];
|
|
25
|
-
/**
|
|
26
|
-
* The execution block of the default case.
|
|
27
|
-
*/
|
|
28
|
-
defaultBlock?: string;
|
|
29
|
-
}): string;
|
package/dist/lib/utils/ast.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* A collection of utility functions that let you more easily write TypeScript code.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createSwitchStatement = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Utility function that lets you easily create a TypeScript switch statement.
|
|
9
|
-
*/
|
|
10
|
-
function createSwitchStatement({ field, cases, defaultBlock, }) {
|
|
11
|
-
const _cases = cases.map(_createSwitchCase).join('\n');
|
|
12
|
-
const _default = defaultBlock ? `default: {\n${defaultBlock}\n}` : '';
|
|
13
|
-
return `
|
|
14
|
-
switch (${field}) {
|
|
15
|
-
${_cases}
|
|
16
|
-
${_default}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
exports.createSwitchStatement = createSwitchStatement;
|
|
21
|
-
function _createSwitchCase({ match, block, }) {
|
|
22
|
-
return `case ${match}: {\n${block}\n}`;
|
|
23
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* Prisma generator often overwrites any error message because of some concurrency issues.
|
|
4
|
-
* By showing the error via console.log and throwing it again, we ensure that the error message is shown.
|
|
5
|
-
*/
|
|
6
|
-
export declare function throwError(message: string): never;
|
|
7
|
-
/**
|
|
8
|
-
* Extracts the error message from an error object or any other object.
|
|
9
|
-
*/
|
|
10
|
-
export declare function extractError(error: unknown): string;
|
|
11
|
-
/**
|
|
12
|
-
* Tries to extract and format a Zod error to a nice log string, color highlighting
|
|
13
|
-
* the object properties that failed validation and their respective error messages.
|
|
14
|
-
*
|
|
15
|
-
* As a fallback, it returns a JSON string representation of the error.
|
|
16
|
-
*/
|
|
17
|
-
export declare function formatZodError(e: z.ZodError): string;
|
package/dist/lib/utils/error.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatZodError = exports.extractError = exports.throwError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Prisma generator often overwrites any error message because of some concurrency issues.
|
|
6
|
-
* By showing the error via console.log and throwing it again, we ensure that the error message is shown.
|
|
7
|
-
*/
|
|
8
|
-
function throwError(message) {
|
|
9
|
-
const m = ` ❌❌❌ ${message}`;
|
|
10
|
-
console.error(m);
|
|
11
|
-
throw new Error(m);
|
|
12
|
-
}
|
|
13
|
-
exports.throwError = throwError;
|
|
14
|
-
/**
|
|
15
|
-
* Extracts the error message from an error object or any other object.
|
|
16
|
-
*/
|
|
17
|
-
function extractError(error) {
|
|
18
|
-
if (error instanceof Error) {
|
|
19
|
-
return error.message;
|
|
20
|
-
}
|
|
21
|
-
return JSON.stringify(error);
|
|
22
|
-
}
|
|
23
|
-
exports.extractError = extractError;
|
|
24
|
-
function extractNestedErrors(value) {
|
|
25
|
-
if (!value._errors) {
|
|
26
|
-
return '';
|
|
27
|
-
}
|
|
28
|
-
return value._errors.join(' or ');
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Tries to extract and format a Zod error to a nice log string, color highlighting
|
|
32
|
-
* the object properties that failed validation and their respective error messages.
|
|
33
|
-
*
|
|
34
|
-
* As a fallback, it returns a JSON string representation of the error.
|
|
35
|
-
*/
|
|
36
|
-
function formatZodError(e) {
|
|
37
|
-
const formatted = e.format();
|
|
38
|
-
if (typeof formatted === 'string') {
|
|
39
|
-
return formatted;
|
|
40
|
-
}
|
|
41
|
-
if (typeof formatted !== 'object') {
|
|
42
|
-
return JSON.stringify(e.format(), null, 2);
|
|
43
|
-
}
|
|
44
|
-
if (formatted._errors && formatted._errors.length > 0) {
|
|
45
|
-
return `\t${formatted._errors.join(' or ')}`;
|
|
46
|
-
}
|
|
47
|
-
return Object.entries(formatted)
|
|
48
|
-
.filter(([key]) => key !== '_errors')
|
|
49
|
-
.map(([key, value]) => `\t${key}:\t ${extractNestedErrors(value)}`)
|
|
50
|
-
.join('\n');
|
|
51
|
-
}
|
|
52
|
-
exports.formatZodError = formatZodError;
|
package/dist/lib/utils/file.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the relative path from one file (e.g. current file) to another file
|
|
3
|
-
* assuming that both files have the same starting point (e.g. from `/a` to `/b/c` is `./b/c`).
|
|
4
|
-
*
|
|
5
|
-
* If the referenced file is a package, then we return the package reference (e.g. `@lib/package`).
|
|
6
|
-
*/
|
|
7
|
-
export declare function getRelativePath({ from, to }: {
|
|
8
|
-
from: string;
|
|
9
|
-
to: string;
|
|
10
|
-
}): string;
|
package/dist/lib/utils/file.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRelativePath = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Returns the relative path from one file (e.g. current file) to another file
|
|
6
|
-
* assuming that both files have the same starting point (e.g. from `/a` to `/b/c` is `./b/c`).
|
|
7
|
-
*
|
|
8
|
-
* If the referenced file is a package, then we return the package reference (e.g. `@lib/package`).
|
|
9
|
-
*/
|
|
10
|
-
function getRelativePath({ from, to }) {
|
|
11
|
-
if (to.startsWith('@')) {
|
|
12
|
-
return to;
|
|
13
|
-
}
|
|
14
|
-
const fromParts = _resolvePath(from);
|
|
15
|
-
const toParts = _resolvePath(to);
|
|
16
|
-
// NOTE: We expect that from value references a file of a file in a given folder.
|
|
17
|
-
// Relative to that file, we need to remove it.
|
|
18
|
-
fromParts.pop();
|
|
19
|
-
// Remove common parts.
|
|
20
|
-
while (fromParts.length > 0 && toParts.length > 0 && fromParts[0] === toParts[0]) {
|
|
21
|
-
fromParts.shift();
|
|
22
|
-
toParts.shift();
|
|
23
|
-
}
|
|
24
|
-
// Add ../ for each remaining part in fromParts.
|
|
25
|
-
const relativePath = fromParts
|
|
26
|
-
.map(() => '..')
|
|
27
|
-
.concat(toParts)
|
|
28
|
-
.join('/');
|
|
29
|
-
if (relativePath.startsWith('.')) {
|
|
30
|
-
return relativePath;
|
|
31
|
-
}
|
|
32
|
-
return `./${relativePath}`;
|
|
33
|
-
}
|
|
34
|
-
exports.getRelativePath = getRelativePath;
|
|
35
|
-
/**
|
|
36
|
-
* Returns a list of folders leading from the root to the referenecd file or folder and removes
|
|
37
|
-
* any positional paths.
|
|
38
|
-
*/
|
|
39
|
-
function _resolvePath(path) {
|
|
40
|
-
const chunks = path.split('/');
|
|
41
|
-
const resolved = [];
|
|
42
|
-
while (chunks.length > 0) {
|
|
43
|
-
// NOTE: We can safely force unwrap here because we check the length of the array.
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
-
const chunk = chunks.shift();
|
|
46
|
-
if (chunk === '..') {
|
|
47
|
-
resolved.pop();
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (chunk === '.') {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
resolved.push(chunk);
|
|
54
|
-
}
|
|
55
|
-
return resolved;
|
|
56
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Field } from '../schema/schema';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a string of JSDoc comments from an array of lines.
|
|
4
|
-
*/
|
|
5
|
-
export declare function toJsDocComment(comments: string[] | undefined): string;
|
|
6
|
-
/**
|
|
7
|
-
* Returns a JSDoc comment for a field.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getFieldComment(f: Field): string;
|
package/dist/lib/utils/jsdoc.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFieldComment = exports.toJsDocComment = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Returns a string of JSDoc comments from an array of lines.
|
|
6
|
-
*/
|
|
7
|
-
function toJsDocComment(comments) {
|
|
8
|
-
if (!comments || comments.length === 0) {
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
return `/**${comments
|
|
12
|
-
.filter((c) => c !== '')
|
|
13
|
-
.map((c) => `\n * ${c}`)
|
|
14
|
-
.join('')} \n */`;
|
|
15
|
-
}
|
|
16
|
-
exports.toJsDocComment = toJsDocComment;
|
|
17
|
-
/**
|
|
18
|
-
* Returns a JSDoc comment for a field.
|
|
19
|
-
*/
|
|
20
|
-
function getFieldComment(f) {
|
|
21
|
-
const lines = [];
|
|
22
|
-
if (f.description) {
|
|
23
|
-
lines.push(...f.description.split('\n'));
|
|
24
|
-
}
|
|
25
|
-
else if (f.kind === 'enum' && f.enumerator.description) {
|
|
26
|
-
lines.push(...f.enumerator.description.split('\n'));
|
|
27
|
-
}
|
|
28
|
-
const _examples = f.attributes.examples;
|
|
29
|
-
if (_examples) {
|
|
30
|
-
lines.push(`Examples: ${_examples.map((e) => `"${e}"`).join(', ')}`);
|
|
31
|
-
}
|
|
32
|
-
if (lines.length === 0) {
|
|
33
|
-
return '';
|
|
34
|
-
}
|
|
35
|
-
return toJsDocComment(lines);
|
|
36
|
-
}
|
|
37
|
-
exports.getFieldComment = getFieldComment;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A generic logger interface.
|
|
3
|
-
* Compatible with the `@prisma/internals` logger and console.
|
|
4
|
-
*/
|
|
5
|
-
export interface Logger {
|
|
6
|
-
log(...data: unknown[]): void;
|
|
7
|
-
warn(message: unknown, ...optionalParams: unknown[]): void;
|
|
8
|
-
info(message: unknown, ...optionalParams: unknown[]): void;
|
|
9
|
-
error(message: unknown, ...optionalParams: unknown[]): void;
|
|
10
|
-
query(message: unknown, ...optionalParams: unknown[]): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Highlights a string cyan
|
|
14
|
-
*
|
|
15
|
-
* NOTE: We would normally use `chalk.cyan` here, but this causes an error in the Prisma generator, so we use this workaround.
|
|
16
|
-
*/
|
|
17
|
-
export declare function highlight(str: string): string;
|
package/dist/lib/utils/logger.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.highlight = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Highlights a string cyan
|
|
6
|
-
*
|
|
7
|
-
* NOTE: We would normally use `chalk.cyan` here, but this causes an error in the Prisma generator, so we use this workaround.
|
|
8
|
-
*/
|
|
9
|
-
function highlight(str) {
|
|
10
|
-
return `\u001B[36m${str}\u001B[39m`;
|
|
11
|
-
}
|
|
12
|
-
exports.highlight = highlight;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the same string with a lowercase first letter.
|
|
3
|
-
*/
|
|
4
|
-
export declare const uncapitalize: (str: string) => string;
|
|
5
|
-
/**
|
|
6
|
-
* Returns the same string with an uppercase first letter.
|
|
7
|
-
*/
|
|
8
|
-
export declare const capitalize: (str: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the camelCase version of the given string.
|
|
11
|
-
*/
|
|
12
|
-
export declare const toCamelCase: (str: string) => string;
|
|
13
|
-
/**
|
|
14
|
-
* Returns the PascalCase version of the given string.
|
|
15
|
-
*/
|
|
16
|
-
export declare const toPascalCase: (str: string) => string;
|
|
17
|
-
/**
|
|
18
|
-
* Returns a pluralized version of the given string based on the count.
|
|
19
|
-
*/
|
|
20
|
-
export declare const pluralize: (s: string, count?: number) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Returns true if the given string is already pluralized.
|
|
23
|
-
*/
|
|
24
|
-
export declare const isPlural: (s: string) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Converts each line of a string to a commented line
|
|
27
|
-
*/
|
|
28
|
-
export declare const commentLines: (lines: string) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Provide all relevant conjugation of a name
|
|
31
|
-
*/
|
|
32
|
-
export declare const conjugateNames: (name: string) => {
|
|
33
|
-
PascalCase: string;
|
|
34
|
-
camelCase: string;
|
|
35
|
-
pluralized: string;
|
|
36
|
-
uncapitalizedPlural: string;
|
|
37
|
-
uncapitalized: string;
|
|
38
|
-
capitalized: string;
|
|
39
|
-
capitalizedPlural: string;
|
|
40
|
-
};
|