vsrepo 1.4.2 → 2.1.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/README.md +827 -1322
- package/README.pt-BR.md +833 -1325
- package/dist/VSRepoAdapter.d.ts +109 -0
- package/dist/VSRepoAdapter.js +18 -0
- package/dist/VSRepository.d.ts +166 -1201
- package/dist/VSRepository.js +327 -237
- package/dist/decorators/dynamic-method.decorator.d.ts +25 -0
- package/dist/decorators/dynamic-method.decorator.js +38 -0
- package/dist/decorators/query-method.decorator.d.ts +27 -0
- package/dist/decorators/query-method.decorator.js +45 -0
- package/dist/errors/VSRepoAdapterError.d.ts +22 -0
- package/dist/errors/VSRepoAdapterError.js +31 -0
- package/dist/errors/VSRepoError.d.ts +15 -0
- package/dist/errors/VSRepoError.js +21 -0
- package/dist/index.d.ts +38 -1
- package/dist/index.js +28 -15
- package/dist/internal/constants/debug-arg-symbol.constant.d.ts +1 -0
- package/dist/internal/constants/debug-arg-symbol.constant.js +4 -0
- package/dist/internal/constants/dynamic-methods-key.constant.d.ts +1 -0
- package/dist/internal/constants/query-methods-key.constant.d.ts +1 -0
- package/dist/internal/constants/query-methods-key.constant.js +4 -0
- package/dist/internal/enums/adapter-error-code.enum.d.ts +125 -0
- package/dist/internal/enums/adapter-error-code.enum.js +129 -0
- package/dist/internal/enums/transaction-isolation-level.enum.d.ts +16 -0
- package/dist/internal/enums/transaction-isolation-level.enum.js +20 -0
- package/dist/internal/enums/vs-log-level.enum.d.ts +18 -0
- package/dist/internal/enums/vs-log-level.enum.js +22 -0
- package/dist/internal/enums/vsrepo-error-type.enum.d.ts +19 -0
- package/dist/internal/enums/vsrepo-error-type.enum.js +23 -0
- package/dist/internal/resolvers/dynamic-methods.resolver.d.ts +23 -0
- package/dist/internal/resolvers/dynamic-methods.resolver.js +910 -0
- package/dist/internal/resolvers/merge-wheres.resolver.d.ts +7 -0
- package/dist/internal/resolvers/merge-wheres.resolver.js +26 -0
- package/dist/internal/utils/uncapitalize.util.d.ts +1 -0
- package/dist/internal/utils/vs-logger.util.d.ts +25 -0
- package/dist/internal/utils/vs-logger.util.js +139 -0
- package/dist/internal/validators/decorators.validator.d.ts +8 -0
- package/dist/internal/validators/decorators.validator.js +75 -0
- package/dist/internal/validators/schemas/ordering.schema.d.ts +3 -0
- package/dist/internal/validators/schemas/ordering.schema.js +38 -0
- package/dist/internal/validators/schemas/pagination.schema.d.ts +6 -0
- package/dist/internal/validators/schemas/pagination.schema.js +40 -0
- package/dist/internal/validators/schemas/where.schema.d.ts +7 -0
- package/dist/internal/validators/schemas/where.schema.js +42 -0
- package/dist/internal/validators/vsrepo.validator.d.ts +40 -0
- package/dist/internal/validators/vsrepo.validator.js +182 -0
- package/dist/types/adapter/adapter-method-options.type.d.ts +24 -0
- package/dist/types/adapter/adapter-query-options.type.d.ts +5 -0
- package/dist/types/decorators/dynamic-method-options.type.d.ts +14 -0
- package/dist/types/decorators/query-method-options.type.d.ts +15 -0
- package/dist/types/dynamic-methods/dynamic-method-customization.type.d.ts +7 -0
- package/dist/types/dynamic-methods/dynamic-method-info.type.d.ts +18 -0
- package/dist/types/dynamic-methods/dynamic-method-where-ops.type.d.ts +6 -0
- package/dist/types/utils/count-result.type.d.ts +9 -0
- package/dist/types/utils/decimal-like.type.d.ts +23 -0
- package/dist/types/utils/deep-partial.type.d.ts +14 -0
- package/dist/types/utils/keys-of-type.type.d.ts +20 -0
- package/dist/types/utils/methods-options.type.d.ts +23 -0
- package/dist/types/utils/numeric-keys.type.d.ts +24 -0
- package/dist/types/utils/numeric-like.type.d.ts +10 -0
- package/dist/types/utils/ordering.type.d.ts +39 -0
- package/dist/types/utils/pagination.type.d.ts +11 -0
- package/dist/types/utils/perform-data.type.d.ts +4 -0
- package/dist/types/utils/primitive.type.d.ts +7 -0
- package/dist/types/utils/query-method-arg.type.d.ts +27 -0
- package/dist/types/utils/restrict-method-options.type.d.ts +14 -0
- package/dist/types/utils/see-mode.type.d.ts +12 -0
- package/dist/types/vsrepo/vsrepo-args.type.d.ts +9 -0
- package/dist/types/vsrepo/vsrepo-method.type.d.ts +4 -0
- package/dist/types/vsrepo/vsrepo-method.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-options.type.d.ts +34 -0
- package/dist/types/vsrepo/vsrepo-options.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-orm-types.type.d.ts +17 -0
- package/dist/types/vsrepo/vsrepo-orm-types.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-pretty-where.type.d.ts +7 -0
- package/dist/types/vsrepo/vsrepo-pretty-where.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-query-options.type.d.ts +17 -0
- package/dist/types/vsrepo/vsrepo-query-options.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-query.type.d.ts +5 -0
- package/dist/types/vsrepo/vsrepo-query.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-relations.type.d.ts +26 -0
- package/dist/types/vsrepo/vsrepo-relations.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-resolve-args-data.type.d.ts +19 -0
- package/dist/types/vsrepo/vsrepo-resolve-args-data.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-select.type.d.ts +15 -0
- package/dist/types/vsrepo/vsrepo-select.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-transaction-options.type.d.ts +12 -0
- package/dist/types/vsrepo/vsrepo-transaction-options.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-ugly-where.type.d.ts +9 -0
- package/dist/types/vsrepo/vsrepo-ugly-where.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-where.type.d.ts +99 -0
- package/dist/types/vsrepo/vsrepo-where.type.js +2 -0
- package/package.json +16 -37
- package/README-DynamicRepo.md +0 -625
- package/README-DynamicRepo.pt-BR.md +0 -625
- package/dist/DynamicRepository.d.ts +0 -497
- package/dist/DynamicRepository.js +0 -26
- package/dist/VSRepoError.d.ts +0 -83
- package/dist/VSRepoError.js +0 -17
- package/dist/internal/decorators/dynamic-method.decorator.js +0 -14
- package/dist/internal/decorators/query-method.decorator.js +0 -20
- package/dist/internal/entities/dynamic-method-metadata.entity.js +0 -26
- package/dist/internal/errors/vs-repo.error.js +0 -31
- package/dist/internal/resolvers/base-methods.resolve.js +0 -541
- package/dist/internal/resolvers/create-update-payloads-with-relations.resolve.js +0 -143
- package/dist/internal/resolvers/data-payload-with-relations.resolve.js +0 -60
- package/dist/internal/resolvers/dbAndPrismaArgs.resolve.js +0 -63
- package/dist/internal/resolvers/dynamic-method-customization.resolve.js +0 -57
- package/dist/internal/resolvers/dynamic-method-info.resolve.js +0 -279
- package/dist/internal/resolvers/dynamic-methods-metadata.resolve.js +0 -15
- package/dist/internal/resolvers/merge-wheres.resolve.js +0 -22
- package/dist/internal/resolvers/pretty-wheres.resolve.js +0 -87
- package/dist/internal/resolvers/select.resolve.js +0 -7
- package/dist/internal/resolvers/specific-where.resolve.js +0 -84
- package/dist/internal/resolvers/ugly-where.resolve.js +0 -178
- package/dist/internal/utils/logger.util.js +0 -21
- package/dist/internal/utils/schemas.util.js +0 -31
- package/dist/internal/validation/build-config.validate.js +0 -84
- package/dist/internal/validation/constructor-config.validate.js +0 -64
- package/dist/internal/validation/dynamic-method-config.validate.js +0 -19
- package/dist/internal/validation/extension.validate.js +0 -15
- package/dist/internal/validation/is-object.validate.js +0 -6
- package/dist/internal/validation/method-options.validate.js +0 -42
- package/dist/internal/validation/obj-with-relations.validate.js +0 -37
- package/dist/internal/validation/prisma-client.validate.js +0 -10
- package/dist/internal/validation/query-method-arg.validate.js +0 -22
- package/dist/internal/validation/query-method-options.validate.js +0 -24
- package/scripts/configure-prisma-import.mjs +0 -283
- package/scripts/copy-types.mjs +0 -24
- /package/dist/{internal/decorators/types/dynamic-method-config.type.js → types/adapter/adapter-method-options.type.js} +0 -0
- /package/dist/{internal/errors/types/vs-repo-error-type.type.js → types/adapter/adapter-query-options.type.js} +0 -0
- /package/dist/{internal/errors/types/vs-repo-runtime-error-code.type.js → types/decorators/dynamic-method-options.type.js} +0 -0
- /package/dist/{internal/validation/types → types/decorators}/query-method-options.type.js +0 -0
- /package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-customization.type.js +0 -0
- /package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-info.type.js +0 -0
- /package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-where-ops.type.js +0 -0
- /package/dist/{internal/resolvers/types/base-method-function.type.js → types/utils/count-result.type.js} +0 -0
- /package/dist/{internal/resolvers/types/pretty-where.type.js → types/utils/decimal-like.type.js} +0 -0
- /package/dist/{internal/resolvers/types/prisma-args.type.js → types/utils/deep-partial.type.js} +0 -0
- /package/dist/{internal/resolvers/types/repository-build-instance.type.js → types/utils/keys-of-type.type.js} +0 -0
- /package/dist/{internal/resolvers/types/resolve-db-and-prisma-args-data.type.js → types/utils/methods-options.type.js} +0 -0
- /package/dist/{internal/resolvers/types/ugly-where.type.js → types/utils/numeric-keys.type.js} +0 -0
- /package/dist/{internal/validation/types/base-methods.type.js → types/utils/numeric-like.type.js} +0 -0
- /package/dist/{internal/validation/types/build-config.type.js → types/utils/ordering.type.js} +0 -0
- /package/dist/{internal/validation/types → types/utils}/pagination.type.js +0 -0
- /package/dist/{internal/validation/types/constructor-config.type.js → types/utils/perform-data.type.js} +0 -0
- /package/dist/{internal/validation/types/method-options.type.js → types/utils/primitive.type.js} +0 -0
- /package/dist/{internal/validation/types → types/utils}/query-method-arg.type.js +0 -0
- /package/dist/{internal/validation/types/method.type.js → types/utils/restrict-method-options.type.js} +0 -0
- /package/dist/{internal/validation/types → types/utils}/see-mode.type.js +0 -0
- /package/dist/{internal/validation/types/relation.type.js → types/vsrepo/vsrepo-args.type.js} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateObjWithRelations = validateObjWithRelations;
|
|
4
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
5
|
-
const is_object_validate_1 = require("./is-object.validate");
|
|
6
|
-
function validateObjWithRelations(instance, obj, relationsKeys) {
|
|
7
|
-
const relations = instance.relations;
|
|
8
|
-
if (!relations)
|
|
9
|
-
return;
|
|
10
|
-
for (let i = 0; i < relationsKeys.length; i++) {
|
|
11
|
-
const key = relationsKeys[i];
|
|
12
|
-
if (obj[key] === undefined)
|
|
13
|
-
continue;
|
|
14
|
-
const relation = relations[key];
|
|
15
|
-
if (relation.mode === "mtm" || relation.mode === "otm") {
|
|
16
|
-
if (obj[key] === null) {
|
|
17
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) '${key}' cannot be 'null' when relation mode is "mtm" or "otm", use an empty array instead.`, "91868");
|
|
18
|
-
}
|
|
19
|
-
else if (!Array.isArray(obj[key]) || obj[key].some(val => !(0, is_object_validate_1.isObject)(val))) {
|
|
20
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) '${key}' must be a valid array of objects when relation mode is "mtm" or "otm".`, "91868");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
if (obj[key] === null) {
|
|
25
|
-
if (relation.mode === "oto" && relation.restriction !== "set") {
|
|
26
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) '${key}' can be 'null' only if the relation restriction is "set" and mode is "oto".`, "91868");
|
|
27
|
-
}
|
|
28
|
-
else if (relation.mode === "mto" && !relation.nullable && !relation.nullAble) {
|
|
29
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) '${key}' can be 'null' only if the relation 'nullable' is 'true' and mode is "mto".`, "91868");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else if (!(0, is_object_validate_1.isObject)(obj[key])) {
|
|
33
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) '${key}' must be a valid object when relation mode is "oto" or "mto".`, "91868");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validatePrismaClient = validatePrismaClient;
|
|
4
|
-
const VSRepository_1 = require("../../VSRepository");
|
|
5
|
-
const is_object_validate_1 = require("./is-object.validate");
|
|
6
|
-
function validatePrismaClient(prisma, repo) {
|
|
7
|
-
if (!(0, is_object_validate_1.isObject)(prisma) || prisma["$transaction"] === undefined) {
|
|
8
|
-
throw new VSRepository_1.VSRepoBuildError(`[VSRepository] (${repo.tableName}: build) 'prisma' must be a valid Prisma Client.`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateQueryMethodArg = validateQueryMethodArg;
|
|
7
|
-
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
const schemas_util_1 = require("../utils/schemas.util");
|
|
9
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
10
|
-
function validateQueryMethodArg(arg, instance) {
|
|
11
|
-
const queryArgSchema = zod_1.default.strictObject({
|
|
12
|
-
args: zod_1.default.array(zod_1.default.any()),
|
|
13
|
-
db: schemas_util_1.objectSchema.optional(),
|
|
14
|
-
});
|
|
15
|
-
const argParsed = queryArgSchema.safeParse(arg);
|
|
16
|
-
if (!argParsed.success) {
|
|
17
|
-
const firstIssue = argParsed.error.issues[0];
|
|
18
|
-
const path = firstIssue?.path.length ? firstIssue.path.join(".") : "options";
|
|
19
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) ${path}: ${firstIssue?.message}`, "67542");
|
|
20
|
-
}
|
|
21
|
-
return argParsed.data;
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateQueryMethodOptions = validateQueryMethodOptions;
|
|
7
|
-
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
9
|
-
const is_object_validate_1 = require("./is-object.validate");
|
|
10
|
-
const schemas_util_1 = require("../utils/schemas.util");
|
|
11
|
-
function validateQueryMethodOptions(options) {
|
|
12
|
-
if (!(0, is_object_validate_1.isObject)(options)) {
|
|
13
|
-
throw new vs_repo_error_1.VSRepoDecoratorError(`[VSRepository] (unknown: decorator) 'options' must be a valid object`);
|
|
14
|
-
}
|
|
15
|
-
const optionsParsed = zod_1.default
|
|
16
|
-
.strictObject({ modifying: schemas_util_1.booleanSchema.default(false) })
|
|
17
|
-
.safeParse(options);
|
|
18
|
-
if (!optionsParsed.success) {
|
|
19
|
-
const firstIssue = optionsParsed.error.issues[0];
|
|
20
|
-
const path = firstIssue?.path.length ? firstIssue.path.join(".") : "options";
|
|
21
|
-
throw new vs_repo_error_1.VSRepoDecoratorError(`[VSRepository] (unknown: decorator) ${path}: ${firstIssue?.message}`);
|
|
22
|
-
}
|
|
23
|
-
return optionsParsed.data;
|
|
24
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const workspaceRoot = process.cwd();
|
|
8
|
-
const args = process.argv.slice(2);
|
|
9
|
-
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
const DEFAULT_OUTPUT = 'generated/vsrepo';
|
|
12
|
-
const DEFAULT_PRISMA = 'generated/prisma';
|
|
13
|
-
const GENERATED_HEADER = `/**
|
|
14
|
-
* ! THIS FILE IS AUTO-GENERATED.
|
|
15
|
-
* ! DO NOT EDIT MANUALLY.
|
|
16
|
-
*/
|
|
17
|
-
/* eslint-disable */
|
|
18
|
-
/* biome-ignore-all lint: generated file */
|
|
19
|
-
// @ts-nocheck
|
|
20
|
-
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const command = args[0] || 'generate';
|
|
24
|
-
|
|
25
|
-
if (command !== 'generate') {
|
|
26
|
-
console.error(`Comando desconhecido: ${command}`);
|
|
27
|
-
console.error('Use: vsrepo generate --output <dir-output> --prisma <path-prisma>');
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const commandArgs = command === args[0] ? args.slice(1) : args;
|
|
32
|
-
|
|
33
|
-
const outputFlagIndex = commandArgs.findIndex((arg) => arg === '--output' || arg === '-o');
|
|
34
|
-
const prismaFlagIndex = commandArgs.findIndex((arg) => arg === '--prisma' || arg === '-p');
|
|
35
|
-
|
|
36
|
-
const outputArg =
|
|
37
|
-
outputFlagIndex >= 0
|
|
38
|
-
? commandArgs[outputFlagIndex + 1]
|
|
39
|
-
: DEFAULT_OUTPUT;
|
|
40
|
-
|
|
41
|
-
const prismaArg =
|
|
42
|
-
prismaFlagIndex >= 0
|
|
43
|
-
? commandArgs[prismaFlagIndex + 1]
|
|
44
|
-
: DEFAULT_PRISMA;
|
|
45
|
-
|
|
46
|
-
if (outputArg.startsWith('-')) {
|
|
47
|
-
console.error('Valor inválido para --output');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (prismaArg.startsWith('-')) {
|
|
52
|
-
console.error('Valor inválido para --prisma');
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const outputDir = path.resolve(workspaceRoot, outputArg);
|
|
57
|
-
|
|
58
|
-
const CLASSIC_PRISMA_GENERATED_PATH = "@prisma/client";
|
|
59
|
-
|
|
60
|
-
const prismaTargetPath = prismaArg === CLASSIC_PRISMA_GENERATED_PATH ? prismaArg : stripKnownExtension(
|
|
61
|
-
path.resolve(workspaceRoot, prismaArg, prismaArg.endsWith('client') ? '' : 'client')
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const installedNodeModulesPath = path.join(workspaceRoot, 'node_modules/vsrepo');
|
|
65
|
-
|
|
66
|
-
const installedPackageExists = fs.existsSync(installedNodeModulesPath);
|
|
67
|
-
|
|
68
|
-
const packageRoot = installedPackageExists
|
|
69
|
-
? installedNodeModulesPath
|
|
70
|
-
: path.resolve(scriptDirectory, '..');
|
|
71
|
-
|
|
72
|
-
const sourceDir = path.join(packageRoot, 'dist');
|
|
73
|
-
|
|
74
|
-
if (!fs.existsSync(sourceDir)) {
|
|
75
|
-
console.error(`Nao foi possivel localizar a pasta dist em: ${sourceDir}`);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
80
|
-
|
|
81
|
-
const typeFiles = [
|
|
82
|
-
'VSRepoError.d.ts',
|
|
83
|
-
'VSRepository.d.ts',
|
|
84
|
-
'DynamicRepository.d.ts'
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
// Mapa de basename original (com e sem extensao) -> basename final `.types`,
|
|
88
|
-
// usado para corrigir os imports relativos entre os proprios arquivos gerados
|
|
89
|
-
// (ex: DynamicRepository.d.ts importando de "./VSRepository.d" ou
|
|
90
|
-
// VSRepository.d.ts importando de "./VSRepoError").
|
|
91
|
-
const crossFileReplacements = typeFiles.flatMap((fileName) => {
|
|
92
|
-
const originalBase = fileName.replace(/\.d\.ts$/, '');
|
|
93
|
-
const finalBase = `${originalBase}.types`;
|
|
94
|
-
|
|
95
|
-
return [
|
|
96
|
-
// from "./VSRepository.d" -> from "./VSRepository.types"
|
|
97
|
-
{ pattern: new RegExp(`from(\\s+)(['"])\\./${originalBase}\\.d\\2`, 'g'), replacement: `from$1$2./${finalBase}$2` },
|
|
98
|
-
// from "./VSRepoError" -> from "./VSRepoError.types"
|
|
99
|
-
{ pattern: new RegExp(`from(\\s+)(['"])\\./${originalBase}\\2`, 'g'), replacement: `from$1$2./${finalBase}$2` },
|
|
100
|
-
];
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
for (const fileName of typeFiles) {
|
|
104
|
-
const sourceFile = path.join(sourceDir, fileName);
|
|
105
|
-
|
|
106
|
-
if (!fs.existsSync(sourceFile)) {
|
|
107
|
-
console.warn(`Arquivo ignorado (nao encontrado): ${fileName}`);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const targetFile = path.join(
|
|
112
|
-
outputDir,
|
|
113
|
-
fileName.replace('.d.ts', '.types.d.ts')
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
let contents = fs.readFileSync(sourceFile, 'utf8');
|
|
117
|
-
|
|
118
|
-
contents = contents.replace(
|
|
119
|
-
/from\s+(['"])\.\.\/generated\/prisma\/client\1/g,
|
|
120
|
-
`from '${prismaTargetPath === CLASSIC_PRISMA_GENERATED_PATH ? prismaTargetPath : relativeImportPath(path.dirname(targetFile), prismaTargetPath)}'`
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
for (const { pattern, replacement } of crossFileReplacements) {
|
|
124
|
-
contents = contents.replace(pattern, replacement);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
fs.writeFileSync(targetFile, GENERATED_HEADER + contents, 'utf8');
|
|
128
|
-
|
|
129
|
-
console.log(`Gerado: ${path.relative(workspaceRoot, targetFile)}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const tsFiles = [
|
|
133
|
-
{
|
|
134
|
-
fileName: 'VSRepoError.ts',
|
|
135
|
-
content: `import {
|
|
136
|
-
VSRepoError as VSRepoErrorRuntime,
|
|
137
|
-
VSRepoConfigError as VSRepoConfigErrorRuntime,
|
|
138
|
-
VSRepoBuildError as VSRepoBuildErrorRuntime,
|
|
139
|
-
VSRepoExtendError as VSRepoExtendErrorRuntime,
|
|
140
|
-
VSRepoRuntimeError as VSRepoRuntimeErrorRuntime,
|
|
141
|
-
VSRepoDecoratorError as VSRepoDecoratorErrorRuntime,
|
|
142
|
-
} from 'vsrepo/VSRepoError';
|
|
143
|
-
|
|
144
|
-
import type {
|
|
145
|
-
VSRepoError as VSRepoErrorType,
|
|
146
|
-
VSRepoConfigError as VSRepoConfigErrorType,
|
|
147
|
-
VSRepoBuildError as VSRepoBuildErrorType,
|
|
148
|
-
VSRepoExtendError as VSRepoExtendErrorType,
|
|
149
|
-
VSRepoRuntimeError as VSRepoRuntimeErrorType,
|
|
150
|
-
VSRepoDecoratorError as VSRepoDecoratorErrorType,
|
|
151
|
-
} from './VSRepoError.types';
|
|
152
|
-
|
|
153
|
-
export const VSRepoError = VSRepoErrorRuntime as typeof VSRepoErrorType;
|
|
154
|
-
export const VSRepoConfigError = VSRepoConfigErrorRuntime as typeof VSRepoConfigErrorType;
|
|
155
|
-
export const VSRepoBuildError = VSRepoBuildErrorRuntime as typeof VSRepoBuildErrorType;
|
|
156
|
-
export const VSRepoExtendError = VSRepoExtendErrorRuntime as typeof VSRepoExtendErrorType;
|
|
157
|
-
export const VSRepoRuntimeError = VSRepoRuntimeErrorRuntime as typeof VSRepoRuntimeErrorType;
|
|
158
|
-
export const VSRepoDecoratorError = VSRepoDecoratorErrorRuntime as typeof VSRepoDecoratorErrorType;
|
|
159
|
-
|
|
160
|
-
export type * from './VSRepoError.types';
|
|
161
|
-
`,
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
fileName: 'VSRepository.ts',
|
|
165
|
-
content: `import {
|
|
166
|
-
VSRepository as VSRepositoryRuntime,
|
|
167
|
-
setupVSRepo as setupVSRepoRuntime
|
|
168
|
-
} from 'vsrepo/VSRepository';
|
|
169
|
-
|
|
170
|
-
import type {
|
|
171
|
-
VSRepository as VSRepositoryType,
|
|
172
|
-
setupVSRepo as setupVSRepoType
|
|
173
|
-
} from './VSRepository.types';
|
|
174
|
-
|
|
175
|
-
export const VSRepository = VSRepositoryRuntime as typeof VSRepositoryType;
|
|
176
|
-
export const setupVSRepo = setupVSRepoRuntime as typeof setupVSRepoType;
|
|
177
|
-
|
|
178
|
-
export type * from './VSRepository.types';
|
|
179
|
-
`,
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
fileName: 'DynamicRepository.ts',
|
|
183
|
-
content: `import {
|
|
184
|
-
DynamicRepository as DynamicRepositoryRuntime,
|
|
185
|
-
DynamicMethod as DynamicMethodRuntime,
|
|
186
|
-
QueryMethod as QueryMethodRuntime,
|
|
187
|
-
} from 'vsrepo/DynamicRepository';
|
|
188
|
-
|
|
189
|
-
import type {
|
|
190
|
-
DynamicRepository as DynamicRepositoryType,
|
|
191
|
-
DynamicMethod as DynamicMethodType,
|
|
192
|
-
QueryMethod as QueryMethodType,
|
|
193
|
-
} from './DynamicRepository.types';
|
|
194
|
-
|
|
195
|
-
export const DynamicRepository = DynamicRepositoryRuntime as typeof DynamicRepositoryType;
|
|
196
|
-
export const DynamicMethod = DynamicMethodRuntime as typeof DynamicMethodType;
|
|
197
|
-
export const QueryMethod = QueryMethodRuntime as typeof QueryMethodType;
|
|
198
|
-
|
|
199
|
-
export type * from './DynamicRepository.types';
|
|
200
|
-
`,
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
fileName: 'index.ts',
|
|
204
|
-
content: `export {
|
|
205
|
-
VSRepoError,
|
|
206
|
-
VSRepoConfigError,
|
|
207
|
-
VSRepoBuildError,
|
|
208
|
-
VSRepoExtendError,
|
|
209
|
-
VSRepoRuntimeError,
|
|
210
|
-
VSRepoDecoratorError
|
|
211
|
-
} from './VSRepoError.js';
|
|
212
|
-
|
|
213
|
-
export {
|
|
214
|
-
VSRepository,
|
|
215
|
-
setupVSRepo
|
|
216
|
-
} from './VSRepository.js';
|
|
217
|
-
|
|
218
|
-
export {
|
|
219
|
-
DynamicRepository,
|
|
220
|
-
DynamicMethod,
|
|
221
|
-
QueryMethod,
|
|
222
|
-
} from './DynamicRepository.js';
|
|
223
|
-
|
|
224
|
-
export type * from './VSRepoError.types';
|
|
225
|
-
export type * from './VSRepository.types';
|
|
226
|
-
export type * from './DynamicRepository.types';
|
|
227
|
-
`,
|
|
228
|
-
},
|
|
229
|
-
];
|
|
230
|
-
|
|
231
|
-
for (const file of tsFiles) {
|
|
232
|
-
const targetFile = path.join(outputDir, file.fileName);
|
|
233
|
-
|
|
234
|
-
fs.writeFileSync(targetFile, GENERATED_HEADER + file.content, 'utf8');
|
|
235
|
-
|
|
236
|
-
console.log(`Gerado: ${path.relative(workspaceRoot, targetFile)}`);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Copia os READMEs da raiz do PACOTE vsrepo (nao do projeto do consumidor)
|
|
240
|
-
// para a pasta 'docs' do diretório de output.
|
|
241
|
-
const readmeFiles = [
|
|
242
|
-
'README.md',
|
|
243
|
-
'README.pt-BR.md',
|
|
244
|
-
'README-DynamicRepo.md',
|
|
245
|
-
'README-DynamicRepo.pt-BR.md',
|
|
246
|
-
];
|
|
247
|
-
|
|
248
|
-
const readmeOutputDir = path.join(outputDir, 'docs');
|
|
249
|
-
fs.mkdirSync(readmeOutputDir, { recursive: true });
|
|
250
|
-
|
|
251
|
-
for (const fileName of readmeFiles) {
|
|
252
|
-
const readmeSource = path.join(packageRoot, fileName);
|
|
253
|
-
const readmeTarget = path.join(readmeOutputDir, fileName);
|
|
254
|
-
|
|
255
|
-
if (fs.existsSync(readmeSource)) {
|
|
256
|
-
fs.copyFileSync(readmeSource, readmeTarget);
|
|
257
|
-
console.log(`Gerado: ${path.relative(workspaceRoot, readmeTarget)}`);
|
|
258
|
-
} else {
|
|
259
|
-
console.warn(`README nao encontrado no pacote em: ${readmeSource}. Ignorando a copia.`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
console.log('\nVSRepository gerado com tipagem do Prisma.');
|
|
264
|
-
console.log(`Output: ${path.relative(workspaceRoot, outputDir)}`);
|
|
265
|
-
console.log(`Prisma usado em: ${path.relative(workspaceRoot, prismaTargetPath)}`);
|
|
266
|
-
|
|
267
|
-
function stripKnownExtension(inputPath) {
|
|
268
|
-
return inputPath.replace(/\.(?:d\.ts|ts|js|mjs|cjs)$/i, '');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function relativeImportPath(fromDirectory, toPath) {
|
|
272
|
-
const relativePath = path.relative(fromDirectory, toPath);
|
|
273
|
-
|
|
274
|
-
const normalized = relativePath.startsWith('.')
|
|
275
|
-
? relativePath
|
|
276
|
-
: `./${relativePath}`;
|
|
277
|
-
|
|
278
|
-
return toPosix(normalized);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function toPosix(inputPath) {
|
|
282
|
-
return inputPath.split(path.sep).join('/');
|
|
283
|
-
}
|
package/scripts/copy-types.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
const srcDir = "./src";
|
|
6
|
-
const distDir = "./dist";
|
|
7
|
-
|
|
8
|
-
function copyDefs(dir) {
|
|
9
|
-
const files = fs.readdirSync(dir);
|
|
10
|
-
for (const file of files) {
|
|
11
|
-
const fullPath = path.join(dir, file);
|
|
12
|
-
if (fs.statSync(fullPath).isDirectory()) {
|
|
13
|
-
copyDefs(fullPath);
|
|
14
|
-
} else if (file.endsWith(".d.ts")) {
|
|
15
|
-
const relativePath = path.relative(srcDir, fullPath);
|
|
16
|
-
const destPath = path.join(distDir, relativePath);
|
|
17
|
-
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
18
|
-
fs.copyFileSync(fullPath, destPath);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
copyDefs(srcDir);
|
|
24
|
-
console.log("Arquivos .d.ts copiados para a pasta dist.");
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-info.type.js
RENAMED
|
File without changes
|
/package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-where-ops.type.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/{internal/resolvers/types/pretty-where.type.js → types/utils/decimal-like.type.js}
RENAMED
|
File without changes
|
/package/dist/{internal/resolvers/types/prisma-args.type.js → types/utils/deep-partial.type.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{internal/resolvers/types/ugly-where.type.js → types/utils/numeric-keys.type.js}
RENAMED
|
File without changes
|
/package/dist/{internal/validation/types/base-methods.type.js → types/utils/numeric-like.type.js}
RENAMED
|
File without changes
|
/package/dist/{internal/validation/types/build-config.type.js → types/utils/ordering.type.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{internal/validation/types/method-options.type.js → types/utils/primitive.type.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{internal/validation/types/relation.type.js → types/vsrepo/vsrepo-args.type.js}
RENAMED
|
File without changes
|