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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicMethod = DynamicMethod;
|
|
4
|
+
const dynamic_methods_key_constant_1 = require("../internal/constants/dynamic-methods-key.constant");
|
|
5
|
+
const decorators_validator_1 = require("../internal/validators/decorators.validator");
|
|
6
|
+
/**
|
|
7
|
+
* Property decorator used to declare a dynamic method on a `VSRepository` subclass.
|
|
8
|
+
*
|
|
9
|
+
* Applied to a `declare` class field whose name follows one of the supported
|
|
10
|
+
* dynamic-method patterns (e.g. `findByEmail`, `findManyByStatusPaginated`,
|
|
11
|
+
* `upsertById`), the method's behavior is inferred from the field name at
|
|
12
|
+
* construction time, optionally adjusted via `options`.
|
|
13
|
+
*
|
|
14
|
+
* @template T Entity type the decorated method operates on.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* class UserRepository extends VSRepository<User, string> {
|
|
19
|
+
* @DynamicMethod()
|
|
20
|
+
* declare findByEmail: (email: string) => Promise<User[]>;
|
|
21
|
+
*
|
|
22
|
+
* @DynamicMethod<User>({ injectOrdering: { createdAt: "desc" } })
|
|
23
|
+
* declare findByAge: (age: number) => Promise<User[]>;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @publicApi
|
|
28
|
+
*/
|
|
29
|
+
function DynamicMethod(options) {
|
|
30
|
+
const validatedOptions = options
|
|
31
|
+
? decorators_validator_1.DecoratorsValidator.validateDynamicMethodOptions(options)
|
|
32
|
+
: undefined;
|
|
33
|
+
return (target, propertyKey) => {
|
|
34
|
+
const methods = Reflect.getMetadata(dynamic_methods_key_constant_1.DYNAMIC_METHODS_KEY, target) ?? [];
|
|
35
|
+
methods.push({ ...validatedOptions, propertyKey });
|
|
36
|
+
Reflect.defineMetadata(dynamic_methods_key_constant_1.DYNAMIC_METHODS_KEY, methods, target);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { QueryMethodOptions } from "../types/decorators/query-method-options.type";
|
|
2
|
+
/**
|
|
3
|
+
* Property decorator used to declare a raw SQL query method on a `VSRepository`
|
|
4
|
+
* subclass, bypassing name-based method parsing entirely.
|
|
5
|
+
*
|
|
6
|
+
* Applied to a `declare` class field, it executes `value` directly through the
|
|
7
|
+
* adapter's `query()` method, with parameters injected positionally via the
|
|
8
|
+
* `args` array passed at the call site (`$1`, `$2`, ... placeholders).
|
|
9
|
+
*
|
|
10
|
+
* @param value Raw SQL statement to execute. Use `$1`, `$2`, ... placeholders for
|
|
11
|
+
* the values that will be passed via `args` — never interpolate values directly into `value`.
|
|
12
|
+
* @param options Optional configuration; set `modifying: true` for `INSERT`/`UPDATE`/`DELETE` statements.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* class UserRepository extends VSRepository<User, string> {
|
|
17
|
+
* @QueryMethod('SELECT * FROM "user" WHERE email = $1')
|
|
18
|
+
* declare findByEmailRaw: (arg: QueryMethodArg<[email: string]>) => Promise<User[]>;
|
|
19
|
+
*
|
|
20
|
+
* @QueryMethod('UPDATE "user" SET active = true WHERE id = $1', { modifying: true })
|
|
21
|
+
* declare activateUser: (arg: QueryMethodArg<[id: string]>) => Promise<number>;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @publicApi
|
|
26
|
+
*/
|
|
27
|
+
export declare function QueryMethod(value: string, options?: QueryMethodOptions): PropertyDecorator;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryMethod = QueryMethod;
|
|
4
|
+
const VSRepoError_1 = require("../errors/VSRepoError");
|
|
5
|
+
const query_methods_key_constant_1 = require("../internal/constants/query-methods-key.constant");
|
|
6
|
+
const vsrepo_error_type_enum_1 = require("../internal/enums/vsrepo-error-type.enum");
|
|
7
|
+
const decorators_validator_1 = require("../internal/validators/decorators.validator");
|
|
8
|
+
/**
|
|
9
|
+
* Property decorator used to declare a raw SQL query method on a `VSRepository`
|
|
10
|
+
* subclass, bypassing name-based method parsing entirely.
|
|
11
|
+
*
|
|
12
|
+
* Applied to a `declare` class field, it executes `value` directly through the
|
|
13
|
+
* adapter's `query()` method, with parameters injected positionally via the
|
|
14
|
+
* `args` array passed at the call site (`$1`, `$2`, ... placeholders).
|
|
15
|
+
*
|
|
16
|
+
* @param value Raw SQL statement to execute. Use `$1`, `$2`, ... placeholders for
|
|
17
|
+
* the values that will be passed via `args` — never interpolate values directly into `value`.
|
|
18
|
+
* @param options Optional configuration; set `modifying: true` for `INSERT`/`UPDATE`/`DELETE` statements.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* class UserRepository extends VSRepository<User, string> {
|
|
23
|
+
* @QueryMethod('SELECT * FROM "user" WHERE email = $1')
|
|
24
|
+
* declare findByEmailRaw: (arg: QueryMethodArg<[email: string]>) => Promise<User[]>;
|
|
25
|
+
*
|
|
26
|
+
* @QueryMethod('UPDATE "user" SET active = true WHERE id = $1', { modifying: true })
|
|
27
|
+
* declare activateUser: (arg: QueryMethodArg<[id: string]>) => Promise<number>;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @publicApi
|
|
32
|
+
*/
|
|
33
|
+
function QueryMethod(value, options) {
|
|
34
|
+
if (typeof value !== "string") {
|
|
35
|
+
throw new VSRepoError_1.VSRepoError(`'value' must be a valid string`, vsrepo_error_type_enum_1.VSRepoErrorType.DECORATOR);
|
|
36
|
+
}
|
|
37
|
+
const validatedConfig = options
|
|
38
|
+
? decorators_validator_1.DecoratorsValidator.validateQueryMethodOptions(options)
|
|
39
|
+
: { modifying: false };
|
|
40
|
+
return (target, propertyKey) => {
|
|
41
|
+
const methods = Reflect.getMetadata(query_methods_key_constant_1.QUERY_METHODS_KEY, target) ?? [];
|
|
42
|
+
methods.push({ ...validatedConfig, value, propertyKey });
|
|
43
|
+
Reflect.defineMetadata(query_methods_key_constant_1.QUERY_METHODS_KEY, methods, target);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterErrorCode } from "../internal/enums/adapter-error-code.enum";
|
|
2
|
+
import { VSRepoError } from "./VSRepoError";
|
|
3
|
+
/**
|
|
4
|
+
* Error raised when a `VSRepoAdapter` fails while talking to the underlying
|
|
5
|
+
* ORM/database. Carries a stable, adapter-agnostic {@link AdapterErrorCode} plus
|
|
6
|
+
* the original error thrown by the adapter, so callers can react to failures
|
|
7
|
+
* without depending on any specific ORM's error shape.
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
export declare class VSRepoAdapterError extends VSRepoError {
|
|
12
|
+
readonly code: AdapterErrorCode;
|
|
13
|
+
readonly originalError: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* @param message - Human-readable description of the adapter failure.
|
|
16
|
+
* @param code - Stable, adapter-agnostic code classifying the failure.
|
|
17
|
+
* @param originalError - The raw error (or `null`/`undefined`) thrown by the
|
|
18
|
+
* underlying ORM/database driver.
|
|
19
|
+
* @param cause - Optional root cause to chain, e.g. the originating exception.
|
|
20
|
+
*/
|
|
21
|
+
constructor(message: string, code: AdapterErrorCode, originalError: unknown, cause?: unknown);
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VSRepoAdapterError = void 0;
|
|
4
|
+
const vsrepo_error_type_enum_1 = require("../internal/enums/vsrepo-error-type.enum");
|
|
5
|
+
const VSRepoError_1 = require("./VSRepoError");
|
|
6
|
+
/**
|
|
7
|
+
* Error raised when a `VSRepoAdapter` fails while talking to the underlying
|
|
8
|
+
* ORM/database. Carries a stable, adapter-agnostic {@link AdapterErrorCode} plus
|
|
9
|
+
* the original error thrown by the adapter, so callers can react to failures
|
|
10
|
+
* without depending on any specific ORM's error shape.
|
|
11
|
+
*
|
|
12
|
+
* @publicApi
|
|
13
|
+
*/
|
|
14
|
+
class VSRepoAdapterError extends VSRepoError_1.VSRepoError {
|
|
15
|
+
code;
|
|
16
|
+
originalError;
|
|
17
|
+
/**
|
|
18
|
+
* @param message - Human-readable description of the adapter failure.
|
|
19
|
+
* @param code - Stable, adapter-agnostic code classifying the failure.
|
|
20
|
+
* @param originalError - The raw error (or `null`/`undefined`) thrown by the
|
|
21
|
+
* underlying ORM/database driver.
|
|
22
|
+
* @param cause - Optional root cause to chain, e.g. the originating exception.
|
|
23
|
+
*/
|
|
24
|
+
constructor(message, code, originalError, cause) {
|
|
25
|
+
super(message, vsrepo_error_type_enum_1.VSRepoErrorType.ADAPTER, cause);
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.originalError = originalError;
|
|
28
|
+
this.name = "VSRepoAdapterError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.VSRepoAdapterError = VSRepoAdapterError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VSRepoErrorType } from "../internal/enums/vsrepo-error-type.enum";
|
|
2
|
+
/**
|
|
3
|
+
* Base error thrown by VSRepository for any invalid usage, configuration, or
|
|
4
|
+
* runtime failure — decorator misuse, invalid method options, resolver
|
|
5
|
+
* failures, and base-method guard clauses.
|
|
6
|
+
*
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
export declare class VSRepoError extends Error {
|
|
10
|
+
/** Category of the error. See `VSRepoErrorType` for the full list. */
|
|
11
|
+
readonly type: VSRepoErrorType;
|
|
12
|
+
constructor(message: string,
|
|
13
|
+
/** Category of the error. See `VSRepoErrorType` for the full list. */
|
|
14
|
+
type: VSRepoErrorType, cause?: unknown);
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VSRepoError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base error thrown by VSRepository for any invalid usage, configuration, or
|
|
6
|
+
* runtime failure — decorator misuse, invalid method options, resolver
|
|
7
|
+
* failures, and base-method guard clauses.
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
class VSRepoError extends Error {
|
|
12
|
+
type;
|
|
13
|
+
constructor(message,
|
|
14
|
+
/** Category of the error. See `VSRepoErrorType` for the full list. */
|
|
15
|
+
type, cause) {
|
|
16
|
+
super(`[VSRepository] Error: ${message}`, { cause });
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.name = "VSRepoError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.VSRepoError = VSRepoError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export { VSRepository } from "./VSRepository.js";
|
|
3
|
+
export { VSRepoAdapter } from "./VSRepoAdapter.js";
|
|
4
|
+
export { VSRepoError } from "./errors/VSRepoError.js";
|
|
5
|
+
export { VSRepoAdapterError } from "./errors/VSRepoAdapterError.js";
|
|
6
|
+
export { DynamicMethod } from "./decorators/dynamic-method.decorator.js";
|
|
7
|
+
export { QueryMethod } from "./decorators/query-method.decorator.js";
|
|
8
|
+
export { VSRepoErrorType } from "./internal/enums/vsrepo-error-type.enum.js";
|
|
9
|
+
export { VSLogLevel } from "./internal/enums/vs-log-level.enum.js";
|
|
10
|
+
export { TransactionIsolationLevel } from "./internal/enums/transaction-isolation-level.enum.js";
|
|
11
|
+
export { AdapterErrorCode } from "./internal/enums/adapter-error-code.enum.js";
|
|
12
|
+
export type { VSRepoOptions } from "./types/vsrepo/vsrepo-options.type.js";
|
|
13
|
+
export type { VSRepoOrmTypes } from "./types/vsrepo/vsrepo-orm-types.type.js";
|
|
14
|
+
export type { VSRepoArgs } from "./types/vsrepo/vsrepo-args.type.js";
|
|
15
|
+
export type { VSRepoMethod } from "./types/vsrepo/vsrepo-method.type.js";
|
|
16
|
+
export type { VSRepoWhere, VSRepoWherePlain, VSRepoFieldWhere, VSRepoFieldOperators, } from "./types/vsrepo/vsrepo-where.type.js";
|
|
17
|
+
export type { VSRepoRelations, RelationKeys } from "./types/vsrepo/vsrepo-relations.type.js";
|
|
18
|
+
export type { VSRepoSelect } from "./types/vsrepo/vsrepo-select.type.js";
|
|
19
|
+
export type { VSRepoTransactionOptions } from "./types/vsrepo/vsrepo-transaction-options.type.js";
|
|
20
|
+
export type { AdapterMethodOptions } from "./types/adapter/adapter-method-options.type.js";
|
|
21
|
+
export type { AdapterQueryOptions } from "./types/adapter/adapter-query-options.type.js";
|
|
22
|
+
export type { DynamicMethodOptions } from "./types/decorators/dynamic-method-options.type.js";
|
|
23
|
+
export type { QueryMethodOptions } from "./types/decorators/query-method-options.type.js";
|
|
24
|
+
export type { QueryMethodArg } from "./types/utils/query-method-arg.type.js";
|
|
25
|
+
export type { CountResult } from "./types/utils/count-result.type.js";
|
|
26
|
+
export type { DeepPartial } from "./types/utils/deep-partial.type.js";
|
|
27
|
+
export type { KeysOfType } from "./types/utils/keys-of-type.type.js";
|
|
28
|
+
export type { MethodOptions } from "./types/utils/methods-options.type.js";
|
|
29
|
+
export type { Ordering, OrderByField, SortDirection } from "./types/utils/ordering.type.js";
|
|
30
|
+
export type { Pagination } from "./types/utils/pagination.type.js";
|
|
31
|
+
export type { Primitive } from "./types/utils/primitive.type.js";
|
|
32
|
+
export type { SeeMode } from "./types/utils/see-mode.type.js";
|
|
33
|
+
export type { VSRepoQueryOptions } from "./types/vsrepo/vsrepo-query-options.type";
|
|
34
|
+
export type { DecimalLike } from "./types/utils/decimal-like.type.js";
|
|
35
|
+
export type { NumericKeys } from "./types/utils/numeric-keys.type.js";
|
|
36
|
+
export type { NumericLike } from "./types/utils/numeric-like.type.js";
|
|
37
|
+
export type { RestrictMethodOptions } from "./types/utils/restrict-method-options.type.js";
|
|
38
|
+
export { VSLogger } from "./internal/utils/vs-logger.util.js";
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
3
|
+
exports.VSLogger = exports.AdapterErrorCode = exports.TransactionIsolationLevel = exports.VSLogLevel = exports.VSRepoErrorType = exports.QueryMethod = exports.DynamicMethod = exports.VSRepoAdapterError = exports.VSRepoError = exports.VSRepoAdapter = exports.VSRepository = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
// Public classes / constructors
|
|
6
|
+
var VSRepository_js_1 = require("./VSRepository.js");
|
|
7
|
+
Object.defineProperty(exports, "VSRepository", { enumerable: true, get: function () { return VSRepository_js_1.VSRepository; } });
|
|
8
|
+
var VSRepoAdapter_js_1 = require("./VSRepoAdapter.js");
|
|
9
|
+
Object.defineProperty(exports, "VSRepoAdapter", { enumerable: true, get: function () { return VSRepoAdapter_js_1.VSRepoAdapter; } });
|
|
10
|
+
var VSRepoError_js_1 = require("./errors/VSRepoError.js");
|
|
11
|
+
Object.defineProperty(exports, "VSRepoError", { enumerable: true, get: function () { return VSRepoError_js_1.VSRepoError; } });
|
|
12
|
+
var VSRepoAdapterError_js_1 = require("./errors/VSRepoAdapterError.js");
|
|
13
|
+
Object.defineProperty(exports, "VSRepoAdapterError", { enumerable: true, get: function () { return VSRepoAdapterError_js_1.VSRepoAdapterError; } });
|
|
14
|
+
// Decorators
|
|
15
|
+
var dynamic_method_decorator_js_1 = require("./decorators/dynamic-method.decorator.js");
|
|
16
|
+
Object.defineProperty(exports, "DynamicMethod", { enumerable: true, get: function () { return dynamic_method_decorator_js_1.DynamicMethod; } });
|
|
17
|
+
var query_method_decorator_js_1 = require("./decorators/query-method.decorator.js");
|
|
18
|
+
Object.defineProperty(exports, "QueryMethod", { enumerable: true, get: function () { return query_method_decorator_js_1.QueryMethod; } });
|
|
19
|
+
// Public enums
|
|
20
|
+
var vsrepo_error_type_enum_js_1 = require("./internal/enums/vsrepo-error-type.enum.js");
|
|
21
|
+
Object.defineProperty(exports, "VSRepoErrorType", { enumerable: true, get: function () { return vsrepo_error_type_enum_js_1.VSRepoErrorType; } });
|
|
22
|
+
var vs_log_level_enum_js_1 = require("./internal/enums/vs-log-level.enum.js");
|
|
23
|
+
Object.defineProperty(exports, "VSLogLevel", { enumerable: true, get: function () { return vs_log_level_enum_js_1.VSLogLevel; } });
|
|
24
|
+
var transaction_isolation_level_enum_js_1 = require("./internal/enums/transaction-isolation-level.enum.js");
|
|
25
|
+
Object.defineProperty(exports, "TransactionIsolationLevel", { enumerable: true, get: function () { return transaction_isolation_level_enum_js_1.TransactionIsolationLevel; } });
|
|
26
|
+
var adapter_error_code_enum_js_1 = require("./internal/enums/adapter-error-code.enum.js");
|
|
27
|
+
Object.defineProperty(exports, "AdapterErrorCode", { enumerable: true, get: function () { return adapter_error_code_enum_js_1.AdapterErrorCode; } });
|
|
28
|
+
// Internal features
|
|
29
|
+
var vs_logger_util_js_1 = require("./internal/utils/vs-logger.util.js");
|
|
30
|
+
Object.defineProperty(exports, "VSLogger", { enumerable: true, get: function () { return vs_logger_util_js_1.VSLogger; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEBUG_ARG_SYMBOL: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DYNAMIC_METHODS_KEY: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QUERY_METHODS_KEY: unique symbol;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Granular error codes that a `VSRepoAdapter` can raise via `VSRepoAdapterError`,
|
|
3
|
+
* mirroring the most common failures thrown by ORMs and database drivers so they
|
|
4
|
+
* can be mapped to a stable, adapter-agnostic code.
|
|
5
|
+
*
|
|
6
|
+
* @publicApi
|
|
7
|
+
*/
|
|
8
|
+
export declare enum AdapterErrorCode {
|
|
9
|
+
/**
|
|
10
|
+
* A unknown/unclassified error raised by the underlying database or ORM.
|
|
11
|
+
* Fallback code when no more specific code matches.
|
|
12
|
+
*/
|
|
13
|
+
UNKNOWN = "UNKNOWN",
|
|
14
|
+
/**
|
|
15
|
+
* The database client (or connection pool) backing the adapter was not
|
|
16
|
+
* provided or could not be resolved.
|
|
17
|
+
*/
|
|
18
|
+
MISSING_DB_CLIENT = "MISSING_DB_CLIENT",
|
|
19
|
+
/**
|
|
20
|
+
* The adapter could not reach/connect to the database, or an established
|
|
21
|
+
* connection was lost/terminated.
|
|
22
|
+
*/
|
|
23
|
+
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
24
|
+
/**
|
|
25
|
+
* The connection pool is exhausted or depleted: no connection was available
|
|
26
|
+
* because they were all busy or the configured limit was reached.
|
|
27
|
+
*/
|
|
28
|
+
CONNECTION_POOL_EXHAUSTED = "CONNECTION_POOL_EXHAUSTED",
|
|
29
|
+
/**
|
|
30
|
+
* The database did not respond in time; a connection/query/statement
|
|
31
|
+
* exceeded its allowed timeout.
|
|
32
|
+
*/
|
|
33
|
+
TIMEOUT = "TIMEOUT",
|
|
34
|
+
/**
|
|
35
|
+
* The operation violated a unique constraint (duplicate key).
|
|
36
|
+
* E.g. Postgres/SQLite `23505`, MySQL `1062`.
|
|
37
|
+
*/
|
|
38
|
+
UNIQUE_CONSTRAINT_VIOLATION = "UNIQUE_CONSTRAINT_VIOLATION",
|
|
39
|
+
/** A foreign key constraint was violated (referenced row missing). */
|
|
40
|
+
FOREIGN_KEY_VIOLATION = "FOREIGN_KEY_VIOLATION",
|
|
41
|
+
/** A NOT NULL constraint was violated. */
|
|
42
|
+
NOT_NULL_VIOLATION = "NOT_NULL_VIOLATION",
|
|
43
|
+
/** A CHECK constraint was violated. */
|
|
44
|
+
CHECK_VIOLATION = "CHECK_VIOLATION",
|
|
45
|
+
/** A general integrity/constraint violation not covered by more specific codes. */
|
|
46
|
+
CONSTRAINT_VIOLATION = "CONSTRAINT_VIOLATION",
|
|
47
|
+
/** The requested record was not found (e.g. a `findOneOrThrow`-style operation). */
|
|
48
|
+
NOT_FOUND = "NOT_FOUND",
|
|
49
|
+
/**
|
|
50
|
+
* The value(s) provided for a field are invalid for its type or length, or a
|
|
51
|
+
* required value is missing.
|
|
52
|
+
*/
|
|
53
|
+
INVALID_DATA = "INVALID_DATA",
|
|
54
|
+
/**
|
|
55
|
+
* The provided value is too long and exceeds the column/field length limit.
|
|
56
|
+
*/
|
|
57
|
+
VALUE_TOO_LONG = "VALUE_TOO_LONG",
|
|
58
|
+
/**
|
|
59
|
+
* A value could not be converted/cast to the target type.
|
|
60
|
+
* E.g. Postgres `22P02` invalid text representation, MySQL `1366` incorrect value.
|
|
61
|
+
*/
|
|
62
|
+
CONVERSION_ERROR = "CONVERSION_ERROR",
|
|
63
|
+
/** The query/stored procedure SQL is malformed or invalid. */
|
|
64
|
+
INVALID_QUERY = "INVALID_QUERY",
|
|
65
|
+
/** The referenced table/column/relation does not exist. */
|
|
66
|
+
TABLE_OR_COLUMN_NOT_FOUND = "TABLE_OR_COLUMN_NOT_FOUND",
|
|
67
|
+
/**
|
|
68
|
+
* The operation was aborted by a lock timeout or a deadlock between
|
|
69
|
+
* concurrent transactions.
|
|
70
|
+
*/
|
|
71
|
+
DEADLOCK = "DEADLOCK",
|
|
72
|
+
/** The operation could not acquire a required database lock in time. */
|
|
73
|
+
LOCK_TIMEOUT = "LOCK_TIMEOUT",
|
|
74
|
+
/** The record is locked and cannot be modified. */
|
|
75
|
+
LOCKED = "LOCKED",
|
|
76
|
+
/** The current user/role does not have permission to perform the operation. */
|
|
77
|
+
ACCESS_DENIED = "ACCESS_DENIED",
|
|
78
|
+
/** Invalid connection credentials (host/user/password) provided. */
|
|
79
|
+
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
80
|
+
/** The authenticated user does not own the record / row-level security rejected it. */
|
|
81
|
+
ROW_NOT_ALLOWED = "ROW_NOT_ALLOWED",
|
|
82
|
+
/**
|
|
83
|
+
* The entity/model or table is not defined/mapped in the ORM, or the adapter
|
|
84
|
+
* lacks the model metadata to build the query.
|
|
85
|
+
*/
|
|
86
|
+
MODEL_NOT_FOUND = "MODEL_NOT_FOUND",
|
|
87
|
+
/**
|
|
88
|
+
* A field/column name in the provided data or `where` does not exist on the
|
|
89
|
+
* entity/model.
|
|
90
|
+
*/
|
|
91
|
+
FIELD_NOT_FOUND = "FIELD_NOT_FOUND",
|
|
92
|
+
/** A transaction was used after it was committed/rolled back. */
|
|
93
|
+
TRANSACTION_CLOSED = "TRANSACTION_CLOSED",
|
|
94
|
+
/** A nested transaction could not be opened (e.g. nested `transaction()` calls). */
|
|
95
|
+
TRANSACTION_ALREADY_STARTED = "TRANSACTION_ALREADY_STARTED",
|
|
96
|
+
/** A transaction failed to commit (e.g. due to a write conflict) and was rolled back. */
|
|
97
|
+
TRANSACTION_CONFLICT = "TRANSACTION_CONFLICT",
|
|
98
|
+
/** No active transaction when one was required for the operation. */
|
|
99
|
+
TRANSACTION_NOT_STARTED = "TRANSACTION_NOT_STARTED",
|
|
100
|
+
/**
|
|
101
|
+
* The connection was closed/terminated while a transaction or query was
|
|
102
|
+
* still in progress.
|
|
103
|
+
*/
|
|
104
|
+
CONNECTION_CLOSED = "CONNECTION_CLOSED",
|
|
105
|
+
/**
|
|
106
|
+
* The value provided to a `merge`/`upsert`/`update` is a partial object but
|
|
107
|
+
* is invalid or missing required keys.
|
|
108
|
+
*/
|
|
109
|
+
INVALID_PARTIAL = "INVALID_PARTIAL",
|
|
110
|
+
/**
|
|
111
|
+
* An unsupported feature/operation was requested from the adapter (e.g. raw
|
|
112
|
+
* `query()` not supported by the underlying ORM).
|
|
113
|
+
*/
|
|
114
|
+
NOT_SUPPORTED = "NOT_SUPPORTED",
|
|
115
|
+
/**
|
|
116
|
+
* The adapter configuration provided is invalid or incomplete (e.g. missing
|
|
117
|
+
* required options, or options with an invalid type/value).
|
|
118
|
+
*/
|
|
119
|
+
INVALID_ADAPTER_CONFIG = "INVALID_ADAPTER_CONFIG",
|
|
120
|
+
/**
|
|
121
|
+
* An internal adapter bug or an unrecoverable state occurred. Should rarely
|
|
122
|
+
* be used; prefer a more specific code.
|
|
123
|
+
*/
|
|
124
|
+
INTERNAL = "INTERNAL"
|
|
125
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdapterErrorCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Granular error codes that a `VSRepoAdapter` can raise via `VSRepoAdapterError`,
|
|
6
|
+
* mirroring the most common failures thrown by ORMs and database drivers so they
|
|
7
|
+
* can be mapped to a stable, adapter-agnostic code.
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
var AdapterErrorCode;
|
|
12
|
+
(function (AdapterErrorCode) {
|
|
13
|
+
/**
|
|
14
|
+
* A unknown/unclassified error raised by the underlying database or ORM.
|
|
15
|
+
* Fallback code when no more specific code matches.
|
|
16
|
+
*/
|
|
17
|
+
AdapterErrorCode["UNKNOWN"] = "UNKNOWN";
|
|
18
|
+
/**
|
|
19
|
+
* The database client (or connection pool) backing the adapter was not
|
|
20
|
+
* provided or could not be resolved.
|
|
21
|
+
*/
|
|
22
|
+
AdapterErrorCode["MISSING_DB_CLIENT"] = "MISSING_DB_CLIENT";
|
|
23
|
+
/**
|
|
24
|
+
* The adapter could not reach/connect to the database, or an established
|
|
25
|
+
* connection was lost/terminated.
|
|
26
|
+
*/
|
|
27
|
+
AdapterErrorCode["CONNECTION_FAILED"] = "CONNECTION_FAILED";
|
|
28
|
+
/**
|
|
29
|
+
* The connection pool is exhausted or depleted: no connection was available
|
|
30
|
+
* because they were all busy or the configured limit was reached.
|
|
31
|
+
*/
|
|
32
|
+
AdapterErrorCode["CONNECTION_POOL_EXHAUSTED"] = "CONNECTION_POOL_EXHAUSTED";
|
|
33
|
+
/**
|
|
34
|
+
* The database did not respond in time; a connection/query/statement
|
|
35
|
+
* exceeded its allowed timeout.
|
|
36
|
+
*/
|
|
37
|
+
AdapterErrorCode["TIMEOUT"] = "TIMEOUT";
|
|
38
|
+
/**
|
|
39
|
+
* The operation violated a unique constraint (duplicate key).
|
|
40
|
+
* E.g. Postgres/SQLite `23505`, MySQL `1062`.
|
|
41
|
+
*/
|
|
42
|
+
AdapterErrorCode["UNIQUE_CONSTRAINT_VIOLATION"] = "UNIQUE_CONSTRAINT_VIOLATION";
|
|
43
|
+
/** A foreign key constraint was violated (referenced row missing). */
|
|
44
|
+
AdapterErrorCode["FOREIGN_KEY_VIOLATION"] = "FOREIGN_KEY_VIOLATION";
|
|
45
|
+
/** A NOT NULL constraint was violated. */
|
|
46
|
+
AdapterErrorCode["NOT_NULL_VIOLATION"] = "NOT_NULL_VIOLATION";
|
|
47
|
+
/** A CHECK constraint was violated. */
|
|
48
|
+
AdapterErrorCode["CHECK_VIOLATION"] = "CHECK_VIOLATION";
|
|
49
|
+
/** A general integrity/constraint violation not covered by more specific codes. */
|
|
50
|
+
AdapterErrorCode["CONSTRAINT_VIOLATION"] = "CONSTRAINT_VIOLATION";
|
|
51
|
+
/** The requested record was not found (e.g. a `findOneOrThrow`-style operation). */
|
|
52
|
+
AdapterErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
53
|
+
/**
|
|
54
|
+
* The value(s) provided for a field are invalid for its type or length, or a
|
|
55
|
+
* required value is missing.
|
|
56
|
+
*/
|
|
57
|
+
AdapterErrorCode["INVALID_DATA"] = "INVALID_DATA";
|
|
58
|
+
/**
|
|
59
|
+
* The provided value is too long and exceeds the column/field length limit.
|
|
60
|
+
*/
|
|
61
|
+
AdapterErrorCode["VALUE_TOO_LONG"] = "VALUE_TOO_LONG";
|
|
62
|
+
/**
|
|
63
|
+
* A value could not be converted/cast to the target type.
|
|
64
|
+
* E.g. Postgres `22P02` invalid text representation, MySQL `1366` incorrect value.
|
|
65
|
+
*/
|
|
66
|
+
AdapterErrorCode["CONVERSION_ERROR"] = "CONVERSION_ERROR";
|
|
67
|
+
/** The query/stored procedure SQL is malformed or invalid. */
|
|
68
|
+
AdapterErrorCode["INVALID_QUERY"] = "INVALID_QUERY";
|
|
69
|
+
/** The referenced table/column/relation does not exist. */
|
|
70
|
+
AdapterErrorCode["TABLE_OR_COLUMN_NOT_FOUND"] = "TABLE_OR_COLUMN_NOT_FOUND";
|
|
71
|
+
/**
|
|
72
|
+
* The operation was aborted by a lock timeout or a deadlock between
|
|
73
|
+
* concurrent transactions.
|
|
74
|
+
*/
|
|
75
|
+
AdapterErrorCode["DEADLOCK"] = "DEADLOCK";
|
|
76
|
+
/** The operation could not acquire a required database lock in time. */
|
|
77
|
+
AdapterErrorCode["LOCK_TIMEOUT"] = "LOCK_TIMEOUT";
|
|
78
|
+
/** The record is locked and cannot be modified. */
|
|
79
|
+
AdapterErrorCode["LOCKED"] = "LOCKED";
|
|
80
|
+
/** The current user/role does not have permission to perform the operation. */
|
|
81
|
+
AdapterErrorCode["ACCESS_DENIED"] = "ACCESS_DENIED";
|
|
82
|
+
/** Invalid connection credentials (host/user/password) provided. */
|
|
83
|
+
AdapterErrorCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
|
|
84
|
+
/** The authenticated user does not own the record / row-level security rejected it. */
|
|
85
|
+
AdapterErrorCode["ROW_NOT_ALLOWED"] = "ROW_NOT_ALLOWED";
|
|
86
|
+
/**
|
|
87
|
+
* The entity/model or table is not defined/mapped in the ORM, or the adapter
|
|
88
|
+
* lacks the model metadata to build the query.
|
|
89
|
+
*/
|
|
90
|
+
AdapterErrorCode["MODEL_NOT_FOUND"] = "MODEL_NOT_FOUND";
|
|
91
|
+
/**
|
|
92
|
+
* A field/column name in the provided data or `where` does not exist on the
|
|
93
|
+
* entity/model.
|
|
94
|
+
*/
|
|
95
|
+
AdapterErrorCode["FIELD_NOT_FOUND"] = "FIELD_NOT_FOUND";
|
|
96
|
+
/** A transaction was used after it was committed/rolled back. */
|
|
97
|
+
AdapterErrorCode["TRANSACTION_CLOSED"] = "TRANSACTION_CLOSED";
|
|
98
|
+
/** A nested transaction could not be opened (e.g. nested `transaction()` calls). */
|
|
99
|
+
AdapterErrorCode["TRANSACTION_ALREADY_STARTED"] = "TRANSACTION_ALREADY_STARTED";
|
|
100
|
+
/** A transaction failed to commit (e.g. due to a write conflict) and was rolled back. */
|
|
101
|
+
AdapterErrorCode["TRANSACTION_CONFLICT"] = "TRANSACTION_CONFLICT";
|
|
102
|
+
/** No active transaction when one was required for the operation. */
|
|
103
|
+
AdapterErrorCode["TRANSACTION_NOT_STARTED"] = "TRANSACTION_NOT_STARTED";
|
|
104
|
+
/**
|
|
105
|
+
* The connection was closed/terminated while a transaction or query was
|
|
106
|
+
* still in progress.
|
|
107
|
+
*/
|
|
108
|
+
AdapterErrorCode["CONNECTION_CLOSED"] = "CONNECTION_CLOSED";
|
|
109
|
+
/**
|
|
110
|
+
* The value provided to a `merge`/`upsert`/`update` is a partial object but
|
|
111
|
+
* is invalid or missing required keys.
|
|
112
|
+
*/
|
|
113
|
+
AdapterErrorCode["INVALID_PARTIAL"] = "INVALID_PARTIAL";
|
|
114
|
+
/**
|
|
115
|
+
* An unsupported feature/operation was requested from the adapter (e.g. raw
|
|
116
|
+
* `query()` not supported by the underlying ORM).
|
|
117
|
+
*/
|
|
118
|
+
AdapterErrorCode["NOT_SUPPORTED"] = "NOT_SUPPORTED";
|
|
119
|
+
/**
|
|
120
|
+
* The adapter configuration provided is invalid or incomplete (e.g. missing
|
|
121
|
+
* required options, or options with an invalid type/value).
|
|
122
|
+
*/
|
|
123
|
+
AdapterErrorCode["INVALID_ADAPTER_CONFIG"] = "INVALID_ADAPTER_CONFIG";
|
|
124
|
+
/**
|
|
125
|
+
* An internal adapter bug or an unrecoverable state occurred. Should rarely
|
|
126
|
+
* be used; prefer a more specific code.
|
|
127
|
+
*/
|
|
128
|
+
AdapterErrorCode["INTERNAL"] = "INTERNAL";
|
|
129
|
+
})(AdapterErrorCode || (exports.AdapterErrorCode = AdapterErrorCode = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Isolation levels accepted by `VSRepository.transaction()`, mirroring the
|
|
3
|
+
* standard SQL isolation levels.
|
|
4
|
+
*
|
|
5
|
+
* @publicApi
|
|
6
|
+
*/
|
|
7
|
+
export declare enum TransactionIsolationLevel {
|
|
8
|
+
/** Allows dirty reads: a transaction may see uncommitted changes from other transactions. */
|
|
9
|
+
READ_UNCOMMITTED = "ReadUncommitted",
|
|
10
|
+
/** Prevents dirty reads; non-repeatable reads and phantom reads may still occur. */
|
|
11
|
+
READ_COMMITTED = "ReadCommitted",
|
|
12
|
+
/** Prevents dirty and non-repeatable reads; phantom reads may still occur. */
|
|
13
|
+
REPEATABLE_READ = "RepeatableRead",
|
|
14
|
+
/** Strongest isolation level: transactions behave as if executed sequentially. */
|
|
15
|
+
SERIALIZABLE = "Serializable"
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionIsolationLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Isolation levels accepted by `VSRepository.transaction()`, mirroring the
|
|
6
|
+
* standard SQL isolation levels.
|
|
7
|
+
*
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
10
|
+
var TransactionIsolationLevel;
|
|
11
|
+
(function (TransactionIsolationLevel) {
|
|
12
|
+
/** Allows dirty reads: a transaction may see uncommitted changes from other transactions. */
|
|
13
|
+
TransactionIsolationLevel["READ_UNCOMMITTED"] = "ReadUncommitted";
|
|
14
|
+
/** Prevents dirty reads; non-repeatable reads and phantom reads may still occur. */
|
|
15
|
+
TransactionIsolationLevel["READ_COMMITTED"] = "ReadCommitted";
|
|
16
|
+
/** Prevents dirty and non-repeatable reads; phantom reads may still occur. */
|
|
17
|
+
TransactionIsolationLevel["REPEATABLE_READ"] = "RepeatableRead";
|
|
18
|
+
/** Strongest isolation level: transactions behave as if executed sequentially. */
|
|
19
|
+
TransactionIsolationLevel["SERIALIZABLE"] = "Serializable";
|
|
20
|
+
})(TransactionIsolationLevel || (exports.TransactionIsolationLevel = TransactionIsolationLevel = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimum severity a message must have to be printed by the repository's
|
|
3
|
+
* internal logger, configured via `VSRepoOptions.logLevel`. Levels are
|
|
4
|
+
* ordered from most to least verbose; setting a level suppresses all
|
|
5
|
+
* messages below it.
|
|
6
|
+
*
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
export declare enum VSLogLevel {
|
|
10
|
+
/** Verbose internal details, including every resolved query. */
|
|
11
|
+
DEBUG = 0,
|
|
12
|
+
/** High-level lifecycle events, such as repository initialization. */
|
|
13
|
+
INFO = 1,
|
|
14
|
+
/** Recoverable issues and slow operations (see `logSlowThresholdMs`). */
|
|
15
|
+
WARN = 2,
|
|
16
|
+
/** Failures raised while executing an operation. */
|
|
17
|
+
ERROR = 3
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VSLogLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Minimum severity a message must have to be printed by the repository's
|
|
6
|
+
* internal logger, configured via `VSRepoOptions.logLevel`. Levels are
|
|
7
|
+
* ordered from most to least verbose; setting a level suppresses all
|
|
8
|
+
* messages below it.
|
|
9
|
+
*
|
|
10
|
+
* @publicApi
|
|
11
|
+
*/
|
|
12
|
+
var VSLogLevel;
|
|
13
|
+
(function (VSLogLevel) {
|
|
14
|
+
/** Verbose internal details, including every resolved query. */
|
|
15
|
+
VSLogLevel[VSLogLevel["DEBUG"] = 0] = "DEBUG";
|
|
16
|
+
/** High-level lifecycle events, such as repository initialization. */
|
|
17
|
+
VSLogLevel[VSLogLevel["INFO"] = 1] = "INFO";
|
|
18
|
+
/** Recoverable issues and slow operations (see `logSlowThresholdMs`). */
|
|
19
|
+
VSLogLevel[VSLogLevel["WARN"] = 2] = "WARN";
|
|
20
|
+
/** Failures raised while executing an operation. */
|
|
21
|
+
VSLogLevel[VSLogLevel["ERROR"] = 3] = "ERROR";
|
|
22
|
+
})(VSLogLevel || (exports.VSLogLevel = VSLogLevel = {}));
|