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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Primitive } from "../utils/primitive.type";
|
|
2
|
+
/**
|
|
3
|
+
* Operators available to filter a single scalar field's value.
|
|
4
|
+
*
|
|
5
|
+
* The set of operators offered narrows based on `V`'s type: numbers and dates
|
|
6
|
+
* additionally get `between`; strings additionally get `contains`, `startsWith`,
|
|
7
|
+
* `endsWith`, and `ignoreCase`; every non-boolean type additionally gets
|
|
8
|
+
* `in`, `notIn`, `gt`, `gte`, `lt`, and `lte`.
|
|
9
|
+
*
|
|
10
|
+
* @template V Type of the field's value.
|
|
11
|
+
*
|
|
12
|
+
* @publicApi
|
|
13
|
+
*/
|
|
14
|
+
export type VSRepoFieldOperators<V> = {
|
|
15
|
+
/** Matches records where the field equals `V`. */
|
|
16
|
+
equals?: V;
|
|
17
|
+
/** Negates the given value or operator object. */
|
|
18
|
+
not?: V | VSRepoFieldOperators<V>;
|
|
19
|
+
} & (V extends number | Date ? {
|
|
20
|
+
/** Matches records where the field is between the given `[min, max]` tuple, inclusive. */
|
|
21
|
+
between?: [V, V];
|
|
22
|
+
} : {}) & (V extends string ? {
|
|
23
|
+
/** Matches records where the field contains the given substring. */
|
|
24
|
+
contains?: string;
|
|
25
|
+
/** Matches records where the field starts with the given substring. */
|
|
26
|
+
startsWith?: string;
|
|
27
|
+
/** Matches records where the field ends with the given substring. */
|
|
28
|
+
endsWith?: string;
|
|
29
|
+
/** Applies the string filters above case-insensitively. */
|
|
30
|
+
ignoreCase?: boolean;
|
|
31
|
+
} : {}) & (V extends boolean ? {} : {
|
|
32
|
+
/** Matches records where the field is one of the given values. */
|
|
33
|
+
in?: V[];
|
|
34
|
+
/** Matches records where the field is none of the given values. */
|
|
35
|
+
notIn?: V[];
|
|
36
|
+
/** Matches records where the field is greater than the given value. */
|
|
37
|
+
gt?: V;
|
|
38
|
+
/** Matches records where the field is greater than or equal to the given value. */
|
|
39
|
+
gte?: V;
|
|
40
|
+
/** Matches records where the field is less than the given value. */
|
|
41
|
+
lt?: V;
|
|
42
|
+
/** Matches records where the field is less than or equal to the given value. */
|
|
43
|
+
lte?: V;
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Value accepted for a single scalar field in a `VSRepoWhere`/`VSRepoWherePlain`
|
|
47
|
+
* filter: either a direct value (shorthand for `equals`) or a `VSRepoFieldOperators` object.
|
|
48
|
+
*
|
|
49
|
+
* @template V Type of the field's value.
|
|
50
|
+
*
|
|
51
|
+
* @publicApi
|
|
52
|
+
*/
|
|
53
|
+
export type VSRepoFieldWhere<V> = V | VSRepoFieldOperators<V>;
|
|
54
|
+
/**
|
|
55
|
+
* Field-level filters for an entity, without the top-level `AND`/`OR`/`NOT`
|
|
56
|
+
* logical operators (see `VSRepoWhere` for those).
|
|
57
|
+
*
|
|
58
|
+
* Scalar fields accept a `VSRepoFieldWhere`. To-many relation fields accept
|
|
59
|
+
* `_some`/`_every`/`_none` filters, applied to the related records. To-one
|
|
60
|
+
* relation fields accept `_with`/`_without` filters.
|
|
61
|
+
*
|
|
62
|
+
* @template T Entity type being filtered.
|
|
63
|
+
*
|
|
64
|
+
* @publicApi
|
|
65
|
+
*/
|
|
66
|
+
export type VSRepoWherePlain<T> = {
|
|
67
|
+
[P in keyof T]?: NonNullable<T[P]> extends Primitive ? VSRepoFieldWhere<T[P]> : NonNullable<T[P]> extends Array<infer U> ? U extends object ? {
|
|
68
|
+
/** Matches records where at least one related record matches the given filter. */
|
|
69
|
+
_some?: VSRepoWherePlain<U>;
|
|
70
|
+
/** Matches records where every related record matches the given filter. */
|
|
71
|
+
_every?: VSRepoWherePlain<U>;
|
|
72
|
+
/** Matches records where no related record matches the given filter. */
|
|
73
|
+
_none?: VSRepoWherePlain<U>;
|
|
74
|
+
} : VSRepoFieldWhere<T[P]> : NonNullable<T[P]> extends object ? {
|
|
75
|
+
/** Matches records whose related record matches the given filter. */
|
|
76
|
+
_with?: VSRepoWherePlain<NonNullable<T[P]>>;
|
|
77
|
+
/** Matches records whose related record does not match the given filter. */
|
|
78
|
+
_without?: VSRepoWherePlain<NonNullable<T[P]>>;
|
|
79
|
+
} : VSRepoFieldWhere<T[P]>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Filter shape accepted by the `where` clause of repository/adapter methods.
|
|
83
|
+
*
|
|
84
|
+
* Combines `VSRepoWherePlain`'s field-level filters with the top-level
|
|
85
|
+
* logical operators `AND`, `OR`, and `NOT`, each accepting either a single
|
|
86
|
+
* filter object or a list of them.
|
|
87
|
+
*
|
|
88
|
+
* @template T Entity type being filtered.
|
|
89
|
+
*
|
|
90
|
+
* @publicApi
|
|
91
|
+
*/
|
|
92
|
+
export type VSRepoWhere<T> = VSRepoWherePlain<T> & {
|
|
93
|
+
/** Combines multiple filters, matching records that satisfy all of them. */
|
|
94
|
+
AND?: VSRepoWherePlain<T> | VSRepoWherePlain<T>[];
|
|
95
|
+
/** Combines multiple filters, matching records that satisfy at least one of them. */
|
|
96
|
+
OR?: VSRepoWherePlain<T> | VSRepoWherePlain<T>[];
|
|
97
|
+
/** Negates one or more filters, matching records that satisfy none of them. */
|
|
98
|
+
NOT?: VSRepoWherePlain<T> | VSRepoWherePlain<T>[];
|
|
99
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vsrepo",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "ORM-agnostic repository pattern library with full TypeScript support and automatic type inference.",
|
|
5
5
|
"homepage": "https://github.com/jaobrabo123/VSRepository#readme",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -14,61 +14,39 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"require": "./dist/index.js"
|
|
17
|
-
},
|
|
18
|
-
"./VSRepository": {
|
|
19
|
-
"types": "./dist/VSRepository.d.ts",
|
|
20
|
-
"import": "./dist/VSRepository.js",
|
|
21
|
-
"require": "./dist/VSRepository.js"
|
|
22
|
-
},
|
|
23
|
-
"./DynamicRepository": {
|
|
24
|
-
"types": "./dist/DynamicRepository.d.ts",
|
|
25
|
-
"import": "./dist/DynamicRepository.js",
|
|
26
|
-
"require": "./dist/DynamicRepository.js"
|
|
27
|
-
},
|
|
28
|
-
"./VSRepoError": {
|
|
29
|
-
"types": "./dist/VSRepoError.d.ts",
|
|
30
|
-
"import": "./dist/VSRepoError.js",
|
|
31
|
-
"require": "./dist/VSRepoError.js"
|
|
32
17
|
}
|
|
33
18
|
},
|
|
34
19
|
"type": "commonjs",
|
|
35
20
|
"files": [
|
|
36
21
|
"dist",
|
|
37
|
-
"scripts",
|
|
38
22
|
"README.md",
|
|
39
|
-
"README.pt-BR.md"
|
|
40
|
-
"README-DynamicRepo.md",
|
|
41
|
-
"README-DynamicRepo.pt-BR.md"
|
|
23
|
+
"README.pt-BR.md"
|
|
42
24
|
],
|
|
43
|
-
"bin": {
|
|
44
|
-
"vsrepo": "scripts/configure-prisma-import.mjs"
|
|
45
|
-
},
|
|
46
25
|
"engines": {
|
|
47
26
|
"node": ">=18"
|
|
48
27
|
},
|
|
49
28
|
"scripts": {
|
|
50
|
-
"
|
|
51
|
-
"build": "tsc -p tsconfig.build.json
|
|
29
|
+
"clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
|
|
30
|
+
"build": "pnpm run clean && tsc -p tsconfig.build.json",
|
|
52
31
|
"prepack": "pnpm build",
|
|
53
|
-
"
|
|
54
|
-
"test:
|
|
55
|
-
"test:implementation
|
|
56
|
-
"test:
|
|
32
|
+
"typecheck": "tsc --noEmit -p tsconfig.build.json",
|
|
33
|
+
"test:typing": "tsc --noEmit -p test/tsconfig.json",
|
|
34
|
+
"test:implementation": "jest",
|
|
35
|
+
"test:implementation:watch": "jest --watch",
|
|
36
|
+
"test": "pnpm run test:typing && pnpm run test:implementation"
|
|
57
37
|
},
|
|
58
38
|
"keywords": [
|
|
59
39
|
"prisma",
|
|
40
|
+
"typeorm",
|
|
60
41
|
"repository",
|
|
61
42
|
"orm",
|
|
62
43
|
"typescript",
|
|
44
|
+
"repository-pattern",
|
|
63
45
|
"vsrepo",
|
|
64
|
-
"vsrepository"
|
|
65
|
-
"jparepository"
|
|
46
|
+
"vsrepository"
|
|
66
47
|
],
|
|
67
48
|
"author": "João Pedro Azevedo Freire Mecenas",
|
|
68
49
|
"license": "MIT",
|
|
69
|
-
"peerDependencies": {
|
|
70
|
-
"@prisma/client": "^7.8.0"
|
|
71
|
-
},
|
|
72
50
|
"devDependencies": {
|
|
73
51
|
"@jest/globals": "^30.4.1",
|
|
74
52
|
"@prisma/adapter-pg": "^7.8.0",
|
|
@@ -81,11 +59,12 @@
|
|
|
81
59
|
"prisma": "^7.8.0",
|
|
82
60
|
"ts-jest": "^29.4.12",
|
|
83
61
|
"tsx": "^4.22.3",
|
|
84
|
-
"typescript": "^6.0.3"
|
|
62
|
+
"typescript": "^6.0.3",
|
|
63
|
+
"zod": "^4.5.1"
|
|
85
64
|
},
|
|
86
65
|
"dependencies": {
|
|
87
66
|
"deepmerge": "^4.3.1",
|
|
88
67
|
"reflect-metadata": "^0.2.2",
|
|
89
|
-
"
|
|
68
|
+
"valibot": "^1.4.2"
|
|
90
69
|
}
|
|
91
70
|
}
|