@tstdl/base 0.93.125 → 0.93.127
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/ai/genkit/tests/multi-region.test.js +6 -6
- package/ai/index.d.ts +2 -6
- package/ai/index.js +2 -6
- package/ai/parser/index.d.ts +1 -0
- package/ai/parser/index.js +1 -0
- package/ai/parser/parser.d.ts +12 -0
- package/ai/parser/parser.js +28 -0
- package/ai/prompts/build.d.ts +21 -0
- package/ai/prompts/build.js +25 -0
- package/ai/prompts/index.d.ts +2 -0
- package/ai/prompts/index.js +2 -0
- package/ai/prompts/instructions-formatter.d.ts +9 -22
- package/ai/prompts/instructions-formatter.js +20 -7
- package/ai/prompts/instructions.js +1 -1
- package/ai/prompts/steering.d.ts +27 -0
- package/ai/prompts/steering.js +54 -0
- package/ai/tests/instructions-formatter.test.js +115 -0
- package/ai/tests/steering.test.js +37 -0
- package/application/application.d.ts +2 -1
- package/application/application.js +3 -0
- package/authentication/client/module.d.ts +1 -1
- package/authentication/client/module.js +4 -5
- package/authentication/tests/authentication-ancillary.service.test.js +1 -1
- package/authentication/tests/authentication.api-controller.test.js +3 -1
- package/authentication/tests/authentication.api-request-token.provider.test.js +1 -1
- package/authentication/tests/authentication.client-service.test.js +1 -1
- package/authentication/tests/authentication.service.test.js +1 -1
- package/authentication/tests/subject.service.test.js +1 -1
- package/circuit-breaker/tests/circuit-breaker.test.js +1 -1
- package/document-management/api/document-management.api.d.ts +16 -16
- package/document-management/api/document-management.api.js +12 -12
- package/document-management/models/ai-configuration.d.ts +59 -0
- package/document-management/models/ai-configuration.js +1 -0
- package/document-management/models/document-assignment-scope.model.js +2 -4
- package/document-management/models/document-assignment-task.model.js +2 -4
- package/document-management/models/document-collection-assignment.model.js +2 -4
- package/document-management/models/document-collection.model.js +2 -3
- package/document-management/models/document-content.model.d.ts +6 -0
- package/document-management/models/document-content.model.js +32 -0
- package/document-management/models/document-property-value.model.js +1 -2
- package/document-management/models/document-request-collection-assignment.model.js +2 -4
- package/document-management/models/document-request.model.js +2 -4
- package/document-management/models/document-tag-assignment.model.js +2 -3
- package/document-management/models/document-validation-execution-related-document.model.js +2 -4
- package/document-management/models/document-validation-execution.model.js +2 -5
- package/document-management/models/document-workflow.model.d.ts +2 -1
- package/document-management/models/document-workflow.model.js +4 -5
- package/document-management/models/document.model.js +2 -3
- package/document-management/models/index.d.ts +2 -0
- package/document-management/models/index.js +2 -0
- package/document-management/server/api/document-management.api.d.ts +7 -7
- package/document-management/server/api/document-management.api.js +9 -9
- package/document-management/server/configure.d.ts +4 -1
- package/document-management/server/configure.js +9 -4
- package/document-management/server/drizzle/{0000_complex_black_bird.sql → 0000_curious_nighthawk.sql} +7 -27
- package/document-management/server/drizzle/meta/0000_snapshot.json +12 -284
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/document-management/server/module.d.ts +2 -0
- package/document-management/server/module.js +1 -0
- package/document-management/server/schemas.d.ts +2 -1
- package/document-management/server/services/document-file.service.d.ts +6 -6
- package/document-management/server/services/document-file.service.js +7 -81
- package/document-management/server/services/document-management-ai-provider.service.d.ts +66 -0
- package/document-management/server/services/document-management-ai-provider.service.js +2 -0
- package/document-management/server/services/document-management-ai.service.d.ts +44 -7
- package/document-management/server/services/document-management-ai.service.js +332 -329
- package/document-management/server/services/document-validation.service.d.ts +1 -1
- package/document-management/server/services/document-workflow.service.d.ts +4 -3
- package/document-management/server/services/document-workflow.service.js +26 -9
- package/document-management/server/services/document.service.d.ts +7 -3
- package/document-management/server/services/document.service.js +13 -4
- package/document-management/server/services/index.d.ts +1 -0
- package/document-management/server/services/index.js +1 -0
- package/document-management/server/validators/ai-validation-executor.d.ts +419 -12
- package/document-management/server/validators/ai-validation-executor.js +51 -46
- package/document-management/server/validators/single-document-validation-executor.d.ts +1 -3
- package/document-management/server/validators/single-document-validation-executor.js +2 -4
- package/document-management/service-models/document.service-model.d.ts +3 -3
- package/document-management/service-models/document.service-model.js +1 -1
- package/document-management/tests/ai-config-hierarchy.test.d.ts +1 -0
- package/document-management/tests/ai-config-hierarchy.test.js +64 -0
- package/document-management/tests/ai-config-integration.test.d.ts +1 -0
- package/document-management/tests/ai-config-integration.test.js +125 -0
- package/document-management/tests/ai-config-merge.test.d.ts +1 -0
- package/document-management/tests/ai-config-merge.test.js +38 -0
- package/document-management/tests/document-management-ai-overrides.test.d.ts +1 -0
- package/document-management/tests/document-management-ai-overrides.test.js +64 -0
- package/document-management/tests/document-management-core.test.js +6 -6
- package/document-management/tests/document-management.api.test.js +5 -5
- package/document-management/tests/document-statistics.service.test.js +10 -6
- package/document-management/tests/document-validation-ai-overrides.test.d.ts +1 -0
- package/document-management/tests/document-validation-ai-overrides.test.js +85 -0
- package/document-management/tests/document.service.test.js +15 -11
- package/document-management/tests/enum-helpers.test.js +5 -5
- package/examples/document-management/ai-provider.d.ts +20 -0
- package/examples/document-management/ai-provider.js +74 -0
- package/examples/document-management/main.js +9 -6
- package/examples/injector/graph-example.d.ts +1 -0
- package/examples/injector/graph-example.js +340 -0
- package/injector/decorators.d.ts +4 -4
- package/injector/decorators.js +5 -6
- package/injector/forward-ref.d.ts +15 -0
- package/injector/forward-ref.js +20 -0
- package/injector/graph.d.ts +113 -0
- package/injector/graph.js +652 -0
- package/injector/index.d.ts +2 -0
- package/injector/index.js +2 -0
- package/injector/inject.d.ts +15 -15
- package/injector/injector.d.ts +101 -13
- package/injector/injector.js +103 -59
- package/injector/resolve-chain.d.ts +20 -6
- package/injector/resolve-chain.js +39 -14
- package/injector/tests/advanced.test.d.ts +1 -0
- package/injector/tests/advanced.test.js +116 -0
- package/injector/tests/async-init.test.d.ts +1 -0
- package/injector/tests/async-init.test.js +77 -0
- package/injector/tests/basic.test.d.ts +1 -0
- package/injector/tests/basic.test.js +114 -0
- package/injector/tests/hierarchical.test.d.ts +1 -0
- package/injector/tests/hierarchical.test.js +59 -0
- package/injector/tests/lifecycles.test.d.ts +1 -0
- package/injector/tests/lifecycles.test.js +109 -0
- package/injector/token.d.ts +2 -1
- package/injector/token.js +4 -1
- package/injector/type-info.d.ts +1 -5
- package/injector/types.d.ts +4 -10
- package/logger/tests/pretty-print.test.d.ts +1 -0
- package/logger/{formatters → tests}/pretty-print.test.js +1 -1
- package/logger/transports/console.d.ts +3 -2
- package/logger/transports/console.js +4 -3
- package/notification/tests/notification-api.test.js +8 -5
- package/notification/tests/notification-client.test.d.ts +1 -0
- package/notification/tests/{unit/notification-client.test.js → notification-client.test.js} +5 -5
- package/notification/tests/notification-flow.test.js +6 -5
- package/notification/tests/notification-sse.service.test.js +1 -1
- package/notification/tests/notification-type.service.test.js +1 -1
- package/object-storage/s3/s3.object-storage.js +3 -0
- package/object-storage/s3/tests/s3.object-storage.integration.test.js +1 -1
- package/orm/tests/repository-attributes.test.js +10 -17
- package/orm/tests/repository-cti-mapping.test.js +2 -2
- package/orm/tests/repository-cti-soft-delete.test.js +1 -1
- package/orm/tests/repository-cti.test.js +19 -33
- package/orm/tests/repository-extra-coverage.test.js +1 -1
- package/orm/tests/repository-search.test.js +5 -2
- package/orm/tests/transaction-safety.test.js +1 -1
- package/package.json +7 -9
- package/rate-limit/tests/postgres-rate-limiter.test.js +6 -16
- package/renderer/d2.d.ts +77 -0
- package/renderer/d2.js +68 -0
- package/renderer/graphviz.d.ts +47 -0
- package/renderer/graphviz.js +58 -0
- package/renderer/index.d.ts +4 -0
- package/renderer/index.js +4 -0
- package/renderer/typst.d.ts +57 -0
- package/renderer/typst.js +62 -0
- package/rpc/adapters/readable-stream.adapter.d.ts +3 -0
- package/rpc/adapters/readable-stream.adapter.js +5 -1
- package/rpc/rpc.js +28 -3
- package/rpc/tests/rpc.integration.test.js +3 -1
- package/schema/schemas/nullable.js +1 -1
- package/task-queue/task-queue.d.ts +2 -0
- package/task-queue/task-queue.js +6 -2
- package/task-queue/tests/complex.test.js +1 -1
- package/task-queue/tests/dependencies.test.js +3 -3
- package/task-queue/tests/extensive-dependencies.test.js +1 -1
- package/task-queue/tests/queue.test.js +1 -1
- package/task-queue/tests/worker.test.js +4 -7
- package/test5.js +52 -8
- package/{unit-test → testing}/integration-setup.d.ts +1 -0
- package/{unit-test → testing}/integration-setup.js +13 -0
- package/utils/base64.d.ts +7 -0
- package/utils/base64.js +10 -1
- package/utils/noop.d.ts +7 -1
- package/utils/noop.js +7 -1
- package/ai/ai-file.service.d.ts +0 -57
- package/ai/ai-file.service.js +0 -233
- package/ai/ai-session.d.ts +0 -38
- package/ai/ai-session.js +0 -50
- package/ai/ai.service.d.ts +0 -126
- package/ai/ai.service.js +0 -481
- package/ai/functions.d.ts +0 -9
- package/ai/functions.js +0 -38
- package/ai/module.d.ts +0 -26
- package/ai/module.js +0 -25
- package/ai/types.d.ts +0 -229
- package/ai/types.js +0 -33
- package/latex/index.d.ts +0 -1
- package/latex/index.js +0 -1
- package/typst/index.d.ts +0 -1
- package/typst/index.js +0 -1
- package/typst/render.d.ts +0 -23
- package/typst/render.js +0 -32
- /package/{logger/formatters/pretty-print.test.d.ts → ai/tests/instructions-formatter.test.d.ts} +0 -0
- /package/{notification/tests/unit/notification-client.test.d.ts → ai/tests/steering.test.d.ts} +0 -0
- /package/{latex/render.d.ts → renderer/latex.d.ts} +0 -0
- /package/{latex/render.js → renderer/latex.js} +0 -0
- /package/{unit-test → testing}/index.d.ts +0 -0
- /package/{unit-test → testing}/index.js +0 -0
package/injector/type-info.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import type { ForwardRefTypeHint } from '../utils/object/forward-ref.js';
|
|
2
1
|
import type { InjectionToken } from './token.js';
|
|
3
|
-
import type { ArgumentProvider,
|
|
2
|
+
import type { ArgumentProvider, Mapper } from './types.js';
|
|
4
3
|
export type InjectMetadata = {
|
|
5
4
|
/** Token overwrite by inject decorator */
|
|
6
5
|
injectToken?: InjectionToken;
|
|
7
|
-
/** If defined, resolve the token or ForwardRefToken using ForwardRef strategy instead of resolving the token directly */
|
|
8
|
-
forwardRef?: boolean | ForwardRefInjectionToken;
|
|
9
|
-
forwardRefTypeHint?: ForwardRefTypeHint;
|
|
10
6
|
/** Whether injection is optional if token is not registered. Set by optional decorator */
|
|
11
7
|
optional?: boolean;
|
|
12
8
|
/** Whether injection should resolve all providers */
|
package/injector/types.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { CancellationSignal } from '../cancellation/index.js';
|
|
2
2
|
import type { Record } from '../types/index.js';
|
|
3
|
-
import type { ForwardRefTypeHint } from '../utils/object/forward-ref.js';
|
|
4
3
|
import type { DisposeHandler, Injector, ProvidersItem } from './injector.js';
|
|
5
4
|
import type { ResolveArgument } from './interfaces.js';
|
|
6
|
-
import type { InjectionToken } from './token.js';
|
|
7
5
|
/**
|
|
8
6
|
* Transient: new resolution for every resolve
|
|
9
7
|
* resolution: one resolution per resolve tree
|
|
@@ -11,26 +9,22 @@ import type { InjectionToken } from './token.js';
|
|
|
11
9
|
* singleton: one resolution at injector where token is registered
|
|
12
10
|
*/
|
|
13
11
|
export type Lifecycle = 'transient' | 'resolution' | 'injector' | 'singleton';
|
|
14
|
-
export type ResolveContext<D extends Record
|
|
12
|
+
export type ResolveContext<D extends Record = Record<PropertyKey, unknown>> = Pick<Injector, 'resolve' | 'resolveAll'> & {
|
|
15
13
|
readonly data: ResolveContextData<D>;
|
|
16
14
|
readonly cancellationSignal: CancellationSignal;
|
|
17
15
|
addDisposeHandler(handler: DisposeHandler): void;
|
|
18
16
|
};
|
|
19
|
-
export type AfterResolveContext<D extends Record
|
|
17
|
+
export type AfterResolveContext<D extends Record = Record<PropertyKey, unknown>> = {
|
|
20
18
|
readonly data: ResolveContextData<D>;
|
|
21
19
|
readonly cancellationSignal: CancellationSignal;
|
|
22
20
|
addDisposeHandler(handler: DisposeHandler): void;
|
|
23
21
|
};
|
|
24
22
|
export type Mapper<T = any, U = unknown> = (value: T) => U;
|
|
25
|
-
export type ArgumentProvider<T = unknown, D extends Record = Record
|
|
26
|
-
export type
|
|
27
|
-
export type ResolveOptions<T, A> = {
|
|
23
|
+
export type ArgumentProvider<T = unknown, D extends Record = Record<PropertyKey, unknown>> = (context: ResolveContext<D>) => T;
|
|
24
|
+
export type ResolveOptions = {
|
|
28
25
|
optional?: boolean;
|
|
29
26
|
skipSelf?: boolean | number;
|
|
30
27
|
onlySelf?: boolean;
|
|
31
|
-
/** If defined, resolve the token using ForwardRef strategy instead of resolving the token directly can be used to circumvent circular dependency problems */
|
|
32
|
-
forwardRef?: boolean | ForwardRefInjectionToken<T, A>;
|
|
33
|
-
forwardRefTypeHint?: ForwardRefTypeHint;
|
|
34
28
|
};
|
|
35
29
|
/**
|
|
36
30
|
* Data to store between different stages like resolve and afterResolve
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,7 @@ vi.mock('#/supports.js', () => ({
|
|
|
5
5
|
supportsColoredStderr: true,
|
|
6
6
|
}));
|
|
7
7
|
import { LogLevel } from '../level.js';
|
|
8
|
-
import { PrettyPrintLogFormatter } from '
|
|
8
|
+
import { PrettyPrintLogFormatter } from '../formatters/pretty-print.js';
|
|
9
9
|
describe('PrettyPrintLogFormatter', () => {
|
|
10
10
|
const formatter = new PrettyPrintLogFormatter();
|
|
11
11
|
it('should format a log entry with an error and no context', () => {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type InjectionToken, type Resolvable, type resolveArgumentType } from '../../injector/index.js';
|
|
2
2
|
import type { ProvidersItem } from '../../injector/injector.js';
|
|
3
|
+
import type { TypedOmit } from '../../types/index.js';
|
|
3
4
|
import { LogFormatter, type LogPayload } from '../formatter.js';
|
|
4
|
-
import { LogLevel } from '../level.js';
|
|
5
5
|
import { LogTransport, LogTransportOptions } from '../transport.js';
|
|
6
6
|
export declare class ConsoleLogTransportOptions extends LogTransportOptions {
|
|
7
7
|
formatter: InjectionToken<LogFormatter>;
|
|
8
|
+
stderrOnly?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare class ConsoleLogTransport extends LogTransport implements Resolvable<ConsoleLogTransportOptions> {
|
|
10
11
|
#private;
|
|
11
12
|
readonly [resolveArgumentType]: ConsoleLogTransportOptions;
|
|
12
13
|
log(payload: LogPayload): void;
|
|
13
14
|
}
|
|
14
|
-
export declare function provideConsoleLogTransport(formatter: InjectionToken<LogFormatter>,
|
|
15
|
+
export declare function provideConsoleLogTransport(formatter: InjectionToken<LogFormatter>, options?: TypedOmit<ConsoleLogTransportOptions, 'formatter'>): ProvidersItem;
|
|
@@ -12,6 +12,7 @@ import { LogLevel } from '../level.js';
|
|
|
12
12
|
import { LogTransport, LogTransportOptions, provideLogTransport } from '../transport.js';
|
|
13
13
|
export class ConsoleLogTransportOptions extends LogTransportOptions {
|
|
14
14
|
formatter;
|
|
15
|
+
stderrOnly;
|
|
15
16
|
}
|
|
16
17
|
const consoleLevelFuncMap = {
|
|
17
18
|
[LogLevel.Error]: 'error',
|
|
@@ -26,7 +27,7 @@ let ConsoleLogTransport = class ConsoleLogTransport extends LogTransport {
|
|
|
26
27
|
#formatter = isDefined(this.#argument?.formatter) ? inject(this.#argument.formatter) : inject(LogFormatter);
|
|
27
28
|
log(payload) {
|
|
28
29
|
const message = this.#formatter.format(payload);
|
|
29
|
-
const consoleFunc = consoleLevelFuncMap[payload.level];
|
|
30
|
+
const consoleFunc = (this.#argument?.stderrOnly == true) ? 'error' : consoleLevelFuncMap[payload.level];
|
|
30
31
|
console[consoleFunc](message);
|
|
31
32
|
}
|
|
32
33
|
};
|
|
@@ -34,6 +35,6 @@ ConsoleLogTransport = __decorate([
|
|
|
34
35
|
Singleton()
|
|
35
36
|
], ConsoleLogTransport);
|
|
36
37
|
export { ConsoleLogTransport };
|
|
37
|
-
export function provideConsoleLogTransport(formatter,
|
|
38
|
-
return provideLogTransport({ useToken: ConsoleLogTransport, defaultArgument: {
|
|
38
|
+
export function provideConsoleLogTransport(formatter, options) {
|
|
39
|
+
return provideLogTransport({ useToken: ConsoleLogTransport, defaultArgument: { ...options, formatter } });
|
|
39
40
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
|
-
import { beforeAll, describe, expect, test, vi } from 'vitest';
|
|
2
|
+
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
3
3
|
import { SubjectService } from '../../authentication/server/subject.service.js';
|
|
4
|
-
import {
|
|
4
|
+
import { clearTenantData, setupIntegrationTest } from '../../testing/index.js';
|
|
5
5
|
import { NotificationChannel } from '../models/index.js';
|
|
6
6
|
import { NotificationApiController } from '../server/api/notification.api-controller.js';
|
|
7
7
|
import { NotificationSseService } from '../server/services/notification-sse.service.js';
|
|
@@ -15,7 +15,7 @@ describe('Notification API (Integration)', () => {
|
|
|
15
15
|
let sseService;
|
|
16
16
|
let subjectService;
|
|
17
17
|
const schema = 'notification';
|
|
18
|
-
const tenantId =
|
|
18
|
+
const tenantId = crypto.randomUUID();
|
|
19
19
|
let userId;
|
|
20
20
|
beforeAll(async () => {
|
|
21
21
|
({ injector, database } = await setupIntegrationTest({
|
|
@@ -27,7 +27,7 @@ describe('Notification API (Integration)', () => {
|
|
|
27
27
|
rateLimiter: true,
|
|
28
28
|
},
|
|
29
29
|
}));
|
|
30
|
-
await
|
|
30
|
+
await clearTenantData(database, 'authentication', ['user', 'subject'], tenantId);
|
|
31
31
|
controller = injector.resolve(NotificationApiController);
|
|
32
32
|
notificationService = injector.resolve(NotificationService);
|
|
33
33
|
sseService = injector.resolve(NotificationSseService);
|
|
@@ -41,6 +41,9 @@ describe('Notification API (Integration)', () => {
|
|
|
41
41
|
});
|
|
42
42
|
userId = user.id;
|
|
43
43
|
});
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
vi.clearAllMocks();
|
|
46
|
+
});
|
|
44
47
|
const createMockContext = (params = {}) => ({
|
|
45
48
|
parameters: params,
|
|
46
49
|
abortSignal: new AbortController().signal,
|
|
@@ -51,7 +54,7 @@ describe('Notification API (Integration)', () => {
|
|
|
51
54
|
subject: userId,
|
|
52
55
|
},
|
|
53
56
|
}),
|
|
54
|
-
});
|
|
57
|
+
}); // Cast to any for controller compatibility if definition is strict
|
|
55
58
|
test('stream should register sse client', async () => {
|
|
56
59
|
const registerSpy = vi.spyOn(sseService, 'register');
|
|
57
60
|
const subject = new Subject();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
-
import { AuthenticationClientService } from '
|
|
3
|
-
import { Injector, runInInjectionContext } from '
|
|
4
|
-
import { NotificationApiClient } from '
|
|
5
|
-
import { NotificationClient } from '
|
|
6
|
-
import { configureDefaultSignalsImplementation } from '
|
|
2
|
+
import { AuthenticationClientService } from '../../authentication/client/authentication.service.js';
|
|
3
|
+
import { Injector, runInInjectionContext } from '../../injector/index.js';
|
|
4
|
+
import { NotificationApiClient } from '../../notification/api/index.js';
|
|
5
|
+
import { NotificationClient } from '../../notification/client/notification-client.js';
|
|
6
|
+
import { configureDefaultSignalsImplementation } from '../../signals/implementation/configure.js';
|
|
7
7
|
import { BehaviorSubject, of, Subject } from 'rxjs';
|
|
8
8
|
describe('NotificationClient', () => {
|
|
9
9
|
let injector;
|
|
@@ -9,7 +9,7 @@ import { SubjectService } from '../../authentication/server/subject.service.js';
|
|
|
9
9
|
import { runInInjectionContext, Singleton } from '../../injector/index.js';
|
|
10
10
|
import { MailService } from '../../mail/mail.service.js';
|
|
11
11
|
import { injectRepository } from '../../orm/server/index.js';
|
|
12
|
-
import { setupIntegrationTest, truncateTables } from '../../
|
|
12
|
+
import { clearTenantData, setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
13
13
|
import { InAppNotification, NotificationChannel, NotificationLogEntity, NotificationStatus, WebPushSubscription } from '../models/index.js';
|
|
14
14
|
import { configureNotification } from '../server/module.js';
|
|
15
15
|
import { EmailChannelProvider } from '../server/providers/email-channel-provider.js';
|
|
@@ -34,7 +34,7 @@ describe('Notification Flow (Integration)', () => {
|
|
|
34
34
|
let subjectService;
|
|
35
35
|
let mailServiceMock;
|
|
36
36
|
const schema = 'notification';
|
|
37
|
-
const tenantId =
|
|
37
|
+
const tenantId = crypto.randomUUID();
|
|
38
38
|
beforeAll(async () => {
|
|
39
39
|
({ injector, database } = await setupIntegrationTest({
|
|
40
40
|
orm: { schema },
|
|
@@ -63,8 +63,8 @@ describe('Notification Flow (Integration)', () => {
|
|
|
63
63
|
worker.registerProvider(NotificationChannel.InApp, injector.resolve(InAppChannelProvider));
|
|
64
64
|
});
|
|
65
65
|
beforeEach(async () => {
|
|
66
|
-
await truncateTables(database, '
|
|
67
|
-
await
|
|
66
|
+
await truncateTables(database, schema, ['log', 'in_app', 'in_app_archive', 'type', 'preference', 'web_push_subscription']);
|
|
67
|
+
await clearTenantData(database, 'authentication', ['user', 'subject'], tenantId);
|
|
68
68
|
vi.clearAllMocks();
|
|
69
69
|
});
|
|
70
70
|
test('should execute full notification flow with escalation', async () => {
|
|
@@ -296,6 +296,7 @@ describe('Notification Flow (Integration)', () => {
|
|
|
296
296
|
test('should auto-archive old notifications', async () => {
|
|
297
297
|
await runInInjectionContext(injector, async () => {
|
|
298
298
|
const logRepo = injectRepository(NotificationLogEntity);
|
|
299
|
+
const inAppRepo = injectRepository(InAppNotification);
|
|
299
300
|
const user = await subjectService.createUser({ tenantId, email: 'auto@example.com', firstName: 'Auto', lastName: 'User' });
|
|
300
301
|
await typeService.initializeTypes({ test: { label: 'Auto Test' } });
|
|
301
302
|
await notificationService.send(tenantId, user.id, { type: 'test', triggerSubjectId: user.id, payload: {} });
|
|
@@ -306,11 +307,11 @@ describe('Notification Flow (Integration)', () => {
|
|
|
306
307
|
// Manually update timestamp to be old (31 days ago)
|
|
307
308
|
const oldTimestamp = Date.now() - 31 * 24 * 60 * 60 * 1000;
|
|
308
309
|
await logRepo.updateByQuery({ id: logs[0].id }, { timestamp: oldTimestamp });
|
|
310
|
+
await inAppRepo.updateByQuery({ tenantId, logId: logs[0].id }, { timestamp: oldTimestamp });
|
|
309
311
|
await notificationService.runAutoArchive();
|
|
310
312
|
// Verify archived
|
|
311
313
|
expect(await notificationService.listInApp(tenantId, user.id)).toHaveLength(0);
|
|
312
314
|
expect(await notificationService.listArchivedInApp(tenantId, user.id)).toHaveLength(1);
|
|
313
|
-
vi.useRealTimers();
|
|
314
315
|
});
|
|
315
316
|
});
|
|
316
317
|
test('should archive all notifications for a user', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
2
|
import { runInInjectionContext } from '../../injector/index.js';
|
|
3
|
-
import { setupIntegrationTest } from '../../
|
|
3
|
+
import { setupIntegrationTest } from '../../testing/index.js';
|
|
4
4
|
import { NotificationSseService } from '../server/services/notification-sse.service.js';
|
|
5
5
|
describe('NotificationSseService', () => {
|
|
6
6
|
test('should register and publish to bus', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
2
|
import { runInInjectionContext } from '../../injector/index.js';
|
|
3
|
-
import { setupIntegrationTest, truncateTables } from '../../
|
|
3
|
+
import { setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
4
4
|
import { NotificationTypeService } from '../server/services/notification-type.service.js';
|
|
5
5
|
describe('NotificationTypeService', () => {
|
|
6
6
|
test('should initialize types correctly', async () => {
|
|
@@ -56,6 +56,9 @@ let S3ObjectStorage = S3ObjectStorage_1 = class S3ObjectStorage extends ObjectSt
|
|
|
56
56
|
}));
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
+
if (this.isError(error, 'BucketAlreadyOwnedByYou', 'BucketAlreadyExists')) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
59
62
|
if (this.isBadRequestError(error)) {
|
|
60
63
|
throw new BadRequestError(`S3 request failed with 400 Bad Request. This often indicates an invalid bucket name ("${this.bucket}") or missing "forcePathStyle: true" for local S3 providers.`);
|
|
61
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
2
|
-
import { setupIntegrationTest } from '../../../
|
|
2
|
+
import { setupIntegrationTest } from '../../../testing/index.js';
|
|
3
3
|
import { readBinaryStream } from '../../../utils/stream/stream-reader.js';
|
|
4
4
|
import { configureS3ObjectStorage } from '../s3.object-storage-provider.js';
|
|
5
5
|
import { S3ObjectStorage } from '../s3.object-storage.js';
|
|
@@ -9,15 +9,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Injector, runInInjectionContext } from '../../injector/index.js';
|
|
11
11
|
import { StringProperty } from '../../schema/index.js';
|
|
12
|
+
import { dropTables, setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
12
13
|
import { sql } from 'drizzle-orm';
|
|
13
|
-
import { beforeAll, describe, expect, test } from 'vitest';
|
|
14
|
+
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
14
15
|
import { Table } from '../decorators.js';
|
|
15
16
|
import { Entity } from '../entity.js';
|
|
16
|
-
import {
|
|
17
|
+
import { Database } from '../server/index.js';
|
|
17
18
|
import { injectRepository } from '../server/repository.js';
|
|
18
19
|
describe('ORM Repository Attributes (Integration)', () => {
|
|
19
20
|
let injector;
|
|
20
|
-
let
|
|
21
|
+
let database;
|
|
21
22
|
const schema = 'test_orm_attributes';
|
|
22
23
|
let AttributeEntity = class AttributeEntity extends Entity {
|
|
23
24
|
name;
|
|
@@ -30,17 +31,9 @@ describe('ORM Repository Attributes (Integration)', () => {
|
|
|
30
31
|
Table('attribute_entities', { schema })
|
|
31
32
|
], AttributeEntity);
|
|
32
33
|
beforeAll(async () => {
|
|
33
|
-
injector =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
connection: {
|
|
37
|
-
host: '127.0.0.1', port: 5432, user: 'tstdl', password: 'wf7rq6glrk5jykne', database: 'tstdl',
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
db = injector.resolve(Database);
|
|
41
|
-
await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
|
|
42
|
-
await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('attribute_entities')} CASCADE`);
|
|
43
|
-
await db.execute(sql `
|
|
34
|
+
({ injector, database } = await setupIntegrationTest({ orm: { schema } }));
|
|
35
|
+
await dropTables(database, schema, ['attribute_entities']);
|
|
36
|
+
await database.execute(sql `
|
|
44
37
|
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('attribute_entities')} (
|
|
45
38
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
46
39
|
name TEXT NOT NULL,
|
|
@@ -52,8 +45,10 @@ describe('ORM Repository Attributes (Integration)', () => {
|
|
|
52
45
|
)
|
|
53
46
|
`);
|
|
54
47
|
});
|
|
48
|
+
beforeEach(async () => {
|
|
49
|
+
await truncateTables(database, schema, ['attribute_entities']);
|
|
50
|
+
});
|
|
55
51
|
test('should support partial attribute updates', async () => {
|
|
56
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('attribute_entities')} CASCADE`);
|
|
57
52
|
await runInInjectionContext(injector, async () => {
|
|
58
53
|
const repository = injectRepository(AttributeEntity);
|
|
59
54
|
const e1 = await repository.insert(Object.assign(new AttributeEntity(), {
|
|
@@ -68,7 +63,6 @@ describe('ORM Repository Attributes (Integration)', () => {
|
|
|
68
63
|
});
|
|
69
64
|
});
|
|
70
65
|
test('should update attributes during soft delete', async () => {
|
|
71
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('attribute_entities')} CASCADE`);
|
|
72
66
|
await runInInjectionContext(injector, async () => {
|
|
73
67
|
const repository = injectRepository(AttributeEntity);
|
|
74
68
|
const e1 = await repository.insert(Object.assign(new AttributeEntity(), {
|
|
@@ -80,7 +74,6 @@ describe('ORM Repository Attributes (Integration)', () => {
|
|
|
80
74
|
});
|
|
81
75
|
});
|
|
82
76
|
test('should support querying by raw SQL on attributes', async () => {
|
|
83
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('attribute_entities')} CASCADE`);
|
|
84
77
|
await runInInjectionContext(injector, async () => {
|
|
85
78
|
const repository = injectRepository(AttributeEntity);
|
|
86
79
|
await repository.insert(Object.assign(new AttributeEntity(), {
|
|
@@ -96,9 +96,9 @@ describe('ORM Repository CTI Mapping (Integration)', () => {
|
|
|
96
96
|
expect(child.secret).toBe('Hidden');
|
|
97
97
|
// Verify DB column names
|
|
98
98
|
const { rows: parentRows } = await db.execute(sql `SELECT display_name FROM ${sql.identifier(schema)}.${sql.identifier('mapped_parents')} WHERE id = ${child.id}`);
|
|
99
|
-
expect(parentRows[0]
|
|
99
|
+
expect(parentRows[0]['display_name']).toBe('Visible');
|
|
100
100
|
const { rows: childRows } = await db.execute(sql `SELECT internal_secret FROM ${sql.identifier(schema)}.${sql.identifier('mapped_children')} WHERE id = ${child.id}`);
|
|
101
|
-
expect(childRows[0]
|
|
101
|
+
expect(childRows[0]['internal_secret']).toBe('Hidden');
|
|
102
102
|
// Load back
|
|
103
103
|
const loaded = await repo.load(child.id);
|
|
104
104
|
expect(loaded.displayName).toBe('Visible');
|
|
@@ -92,7 +92,7 @@ describe('ORM Repository CTI Soft Delete (Integration)', () => {
|
|
|
92
92
|
const entity = await repo.insert(Object.assign(new Subtype(), { baseName: 'B1', subData: 'S1' }));
|
|
93
93
|
await repo.delete(entity.id);
|
|
94
94
|
const { rows } = await db.execute(sql `SELECT delete_timestamp FROM ${sql.identifier(schema)}.${sql.identifier('bases')} WHERE id = ${entity.id}`);
|
|
95
|
-
expect(rows[0]
|
|
95
|
+
expect(rows[0]['delete_timestamp']).not.toBeNull();
|
|
96
96
|
expect(await repo.has(entity.id)).toBe(false);
|
|
97
97
|
expect(await repo.loadManyByQuery({ id: entity.id }).then((r) => r[0])).toBeUndefined();
|
|
98
98
|
});
|
|
@@ -9,9 +9,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Injector, runInInjectionContext } from '../../injector/index.js';
|
|
11
11
|
import { StringProperty } from '../../schema/index.js';
|
|
12
|
-
import { dropTables, setupIntegrationTest, truncateTables } from '../../
|
|
12
|
+
import { dropTables, setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
13
13
|
import { sql } from 'drizzle-orm';
|
|
14
|
-
import { beforeAll, describe, expect, test } from 'vitest';
|
|
14
|
+
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
15
15
|
import { ChildEntity, Column, Inheritance, Table } from '../decorators.js';
|
|
16
16
|
import { Entity } from '../entity.js';
|
|
17
17
|
import { Database, injectRepository } from '../server/index.js';
|
|
@@ -137,8 +137,10 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
137
137
|
)
|
|
138
138
|
`);
|
|
139
139
|
});
|
|
140
|
-
|
|
140
|
+
beforeEach(async () => {
|
|
141
141
|
await truncateTables(database, schema, ['users']);
|
|
142
|
+
});
|
|
143
|
+
test('should insert into both parent and child tables', async () => {
|
|
142
144
|
await runInInjectionContext(injector, async () => {
|
|
143
145
|
const repository = injectRepository(Admin);
|
|
144
146
|
const newAdmin = new Admin();
|
|
@@ -154,17 +156,16 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
154
156
|
// Verify DB state
|
|
155
157
|
const { rows: [userRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('users')} WHERE id = ${inserted.id}`);
|
|
156
158
|
expect(userRow).toBeDefined();
|
|
157
|
-
expect(userRow
|
|
158
|
-
expect(userRow
|
|
159
|
-
expect(userRow
|
|
159
|
+
expect(userRow['type']).toBe('admin');
|
|
160
|
+
expect(userRow['name']).toBe('Alice');
|
|
161
|
+
expect(userRow['revision']).toBe(1);
|
|
160
162
|
const { rows: [adminRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('admins')} WHERE id = ${inserted.id}`);
|
|
161
163
|
expect(adminRow).toBeDefined();
|
|
162
|
-
expect(adminRow
|
|
163
|
-
expect(adminRow
|
|
164
|
+
expect(adminRow['type']).toBe('admin');
|
|
165
|
+
expect(adminRow['role']).toBe('SuperAdmin');
|
|
164
166
|
});
|
|
165
167
|
});
|
|
166
168
|
test('should insert many into both parent and child tables', async () => {
|
|
167
|
-
await truncateTables(database, schema, ['users']);
|
|
168
169
|
await runInInjectionContext(injector, async () => {
|
|
169
170
|
const repository = injectRepository(Admin);
|
|
170
171
|
const admins = [
|
|
@@ -179,14 +180,13 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
179
180
|
expect(insertedAdmins[1].type).toBe('admin');
|
|
180
181
|
for (const inserted of insertedAdmins) {
|
|
181
182
|
const { rows: [userRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('users')} WHERE id = ${inserted.id}`);
|
|
182
|
-
expect(userRow
|
|
183
|
+
expect(userRow['name']).toBe(inserted.name);
|
|
183
184
|
const { rows: [adminRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('admins')} WHERE id = ${inserted.id}`);
|
|
184
|
-
expect(adminRow
|
|
185
|
+
expect(adminRow['role']).toBe(inserted.role);
|
|
185
186
|
}
|
|
186
187
|
});
|
|
187
188
|
});
|
|
188
189
|
test('should update both parent and child tables', async () => {
|
|
189
|
-
await truncateTables(database, schema, ['users']);
|
|
190
190
|
await runInInjectionContext(injector, async () => {
|
|
191
191
|
const repository = injectRepository(Admin);
|
|
192
192
|
const newAdmin = Object.assign(new Admin(), { name: 'Alice', role: 'SuperAdmin' });
|
|
@@ -198,14 +198,13 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
198
198
|
expect(updated.metadata.revision).toBe(2);
|
|
199
199
|
// Verify DB state
|
|
200
200
|
const { rows: [userRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('users')} WHERE id = ${inserted.id}`);
|
|
201
|
-
expect(userRow
|
|
202
|
-
expect(userRow
|
|
201
|
+
expect(userRow['name']).toBe('Alice Updated');
|
|
202
|
+
expect(userRow['revision']).toBe(2);
|
|
203
203
|
const { rows: [adminRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('admins')} WHERE id = ${inserted.id}`);
|
|
204
|
-
expect(adminRow
|
|
204
|
+
expect(adminRow['role']).toBe('MegaAdmin');
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
test('should soft delete from parent table', async () => {
|
|
208
|
-
await truncateTables(database, schema, ['users']);
|
|
209
208
|
await runInInjectionContext(injector, async () => {
|
|
210
209
|
const repository = injectRepository(Admin);
|
|
211
210
|
const newAdmin = Object.assign(new Admin(), { name: 'Alice', role: 'SuperAdmin' });
|
|
@@ -213,14 +212,13 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
213
212
|
await repository.delete(inserted.id);
|
|
214
213
|
// Verify DB state
|
|
215
214
|
const { rows: [userRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('users')} WHERE id = ${inserted.id}`);
|
|
216
|
-
expect(userRow
|
|
215
|
+
expect(userRow['delete_timestamp']).not.toBeNull();
|
|
217
216
|
// Child table should still have the row (soft delete only affects parent)
|
|
218
217
|
const { rows: [adminRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('admins')} WHERE id = ${inserted.id}`);
|
|
219
218
|
expect(adminRow).toBeDefined();
|
|
220
219
|
});
|
|
221
220
|
});
|
|
222
221
|
test('should hard delete from both tables via cascade', async () => {
|
|
223
|
-
await truncateTables(database, schema, ['users']);
|
|
224
222
|
await runInInjectionContext(injector, async () => {
|
|
225
223
|
const repository = injectRepository(Admin);
|
|
226
224
|
const newAdmin = Object.assign(new Admin(), { name: 'Alice', role: 'SuperAdmin' });
|
|
@@ -234,7 +232,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
234
232
|
});
|
|
235
233
|
});
|
|
236
234
|
test('should load entities polymorphically from parent repository', async () => {
|
|
237
|
-
await truncateTables(database, schema, ['users']);
|
|
238
235
|
await runInInjectionContext(injector, async () => {
|
|
239
236
|
const adminRepository = injectRepository(Admin);
|
|
240
237
|
const guestRepository = injectRepository(Guest);
|
|
@@ -265,7 +262,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
265
262
|
});
|
|
266
263
|
});
|
|
267
264
|
test('should load polymorphic subset from parent repository', async () => {
|
|
268
|
-
await truncateTables(database, schema, ['users']);
|
|
269
265
|
await runInInjectionContext(injector, async () => {
|
|
270
266
|
const adminRepository = injectRepository(Admin);
|
|
271
267
|
const guestRepository = injectRepository(Guest);
|
|
@@ -284,7 +280,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
284
280
|
});
|
|
285
281
|
});
|
|
286
282
|
test('should count and check existence for child entities', async () => {
|
|
287
|
-
await truncateTables(database, schema, ['users']);
|
|
288
283
|
await runInInjectionContext(injector, async () => {
|
|
289
284
|
const adminRepository = injectRepository(Admin);
|
|
290
285
|
const guestRepository = injectRepository(Guest);
|
|
@@ -300,7 +295,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
300
295
|
});
|
|
301
296
|
});
|
|
302
297
|
test('should query child entities by parent fields', async () => {
|
|
303
|
-
await truncateTables(database, schema, ['users']);
|
|
304
298
|
await runInInjectionContext(injector, async () => {
|
|
305
299
|
const adminRepository = injectRepository(Admin);
|
|
306
300
|
await adminRepository.insert(Object.assign(new Admin(), { name: 'TargetAdmin', role: 'Super' }));
|
|
@@ -312,7 +306,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
312
306
|
});
|
|
313
307
|
});
|
|
314
308
|
test('should perform partial updates on parent or child fields', async () => {
|
|
315
|
-
await truncateTables(database, schema, ['users']);
|
|
316
309
|
await runInInjectionContext(injector, async () => {
|
|
317
310
|
const adminRepository = injectRepository(Admin);
|
|
318
311
|
const inserted = await adminRepository.insert(Object.assign(new Admin(), { name: 'Alice', role: 'Super' }));
|
|
@@ -351,7 +344,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
351
344
|
await expect(query).rejects.toThrow();
|
|
352
345
|
});
|
|
353
346
|
test('should support nested inheritance', async () => {
|
|
354
|
-
await truncateTables(database, schema, ['users']);
|
|
355
347
|
await runInInjectionContext(injector, async () => {
|
|
356
348
|
const managerRepository = injectRepository(Manager);
|
|
357
349
|
const manager = new Manager();
|
|
@@ -365,15 +357,14 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
365
357
|
expect(inserted.type).toBe('manager');
|
|
366
358
|
// Verify DB state - all 3 tables should have rows
|
|
367
359
|
const { rows: [userRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('users')} WHERE id = ${inserted.id}`);
|
|
368
|
-
expect(userRow
|
|
360
|
+
expect(userRow['name']).toBe('Big Boss');
|
|
369
361
|
const { rows: [staffRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('staff')} WHERE id = ${inserted.id}`);
|
|
370
|
-
expect(staffRow
|
|
362
|
+
expect(staffRow['employee_id']).toBe('EMP001');
|
|
371
363
|
const { rows: [managerRow] } = await database.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('managers')} WHERE id = ${inserted.id}`);
|
|
372
|
-
expect(managerRow
|
|
364
|
+
expect(managerRow['department']).toBe('Executive');
|
|
373
365
|
});
|
|
374
366
|
});
|
|
375
367
|
test('should rollback parent insert if child insert fails', async () => {
|
|
376
|
-
await truncateTables(database, schema, ['users']);
|
|
377
368
|
await runInInjectionContext(injector, async () => {
|
|
378
369
|
const adminRepository = injectRepository(Admin);
|
|
379
370
|
// Attempt to insert an admin with a missing role (should fail because of NOT NULL)
|
|
@@ -387,7 +378,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
387
378
|
});
|
|
388
379
|
});
|
|
389
380
|
test('should count and check existence polymorphically', async () => {
|
|
390
|
-
await truncateTables(database, schema, ['users']);
|
|
391
381
|
await runInInjectionContext(injector, async () => {
|
|
392
382
|
const adminRepository = injectRepository(Admin);
|
|
393
383
|
const guestRepository = injectRepository(Guest);
|
|
@@ -400,7 +390,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
400
390
|
});
|
|
401
391
|
});
|
|
402
392
|
test('should load many by IDs polymorphically', async () => {
|
|
403
|
-
await truncateTables(database, schema, ['users']);
|
|
404
393
|
await runInInjectionContext(injector, async () => {
|
|
405
394
|
const adminRepository = injectRepository(Admin);
|
|
406
395
|
const guestRepository = injectRepository(Guest);
|
|
@@ -414,7 +403,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
414
403
|
});
|
|
415
404
|
});
|
|
416
405
|
test('should update many child entities', async () => {
|
|
417
|
-
await truncateTables(database, schema, ['users']);
|
|
418
406
|
await runInInjectionContext(injector, async () => {
|
|
419
407
|
const adminRepository = injectRepository(Admin);
|
|
420
408
|
const a1 = await adminRepository.insert(Object.assign(new Admin(), { name: 'A1', role: 'Old' }));
|
|
@@ -426,7 +414,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
426
414
|
});
|
|
427
415
|
});
|
|
428
416
|
test('should update nested inheritance fields', async () => {
|
|
429
|
-
await truncateTables(database, schema, ['users']);
|
|
430
417
|
await runInInjectionContext(injector, async () => {
|
|
431
418
|
const managerRepository = injectRepository(Manager);
|
|
432
419
|
const manager = Object.assign(new Manager(), { name: 'Boss', employeeId: 'E1', department: 'D1' });
|
|
@@ -439,7 +426,6 @@ describe('ORM Repository CTI (Integration)', () => {
|
|
|
439
426
|
});
|
|
440
427
|
});
|
|
441
428
|
test('should delete from nested inheritance tables', async () => {
|
|
442
|
-
await truncateTables(database, schema, ['users']);
|
|
443
429
|
await runInInjectionContext(injector, async () => {
|
|
444
430
|
const managerRepository = injectRepository(Manager);
|
|
445
431
|
const manager = Object.assign(new Manager(), { name: 'Boss', employeeId: 'E1', department: 'D1' });
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { NotFoundError } from '../../errors/not-found.error.js';
|
|
11
11
|
import { Injector, runInInjectionContext } from '../../injector/index.js';
|
|
12
12
|
import { StringProperty } from '../../schema/index.js';
|
|
13
|
-
import { dropTables, setupIntegrationTest, truncateTables } from '../../
|
|
13
|
+
import { dropTables, setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
14
14
|
import { toArrayAsync } from '../../utils/async-iterable-helpers/to-array.js';
|
|
15
15
|
import { sql } from 'drizzle-orm';
|
|
16
16
|
import { beforeAll, describe, expect, test } from 'vitest';
|
|
@@ -8,10 +8,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { sql } from 'drizzle-orm';
|
|
11
|
-
import { beforeAll, describe, expect, test } from 'vitest';
|
|
11
|
+
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
12
12
|
import { Injector, runInInjectionContext } from '../../injector/index.js';
|
|
13
13
|
import { StringProperty } from '../../schema/index.js';
|
|
14
|
-
import { dropTables, setupIntegrationTest } from '../../
|
|
14
|
+
import { dropTables, setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
15
15
|
import { Table } from '../decorators.js';
|
|
16
16
|
import { Entity } from '../entity.js';
|
|
17
17
|
import { Database } from '../server/index.js';
|
|
@@ -51,6 +51,9 @@ describe('ORM Repository Search', () => {
|
|
|
51
51
|
)
|
|
52
52
|
`);
|
|
53
53
|
});
|
|
54
|
+
beforeEach(async () => {
|
|
55
|
+
await truncateTables(database, schema, ['search_entities']);
|
|
56
|
+
});
|
|
54
57
|
test('should support search with score transformer', async () => {
|
|
55
58
|
await runInInjectionContext(injector, async () => {
|
|
56
59
|
const repository = injectRepository(SearchEntity);
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Injector, Singleton, runInInjectionContext } from '../../injector/index.js';
|
|
11
11
|
import { StringProperty } from '../../schema/index.js';
|
|
12
|
-
import { dropTables, setupIntegrationTest } from '../../
|
|
12
|
+
import { dropTables, setupIntegrationTest } from '../../testing/index.js';
|
|
13
13
|
import { sql } from 'drizzle-orm';
|
|
14
14
|
import { beforeAll, describe, expect, test } from 'vitest';
|
|
15
15
|
import { Entity, Table } from '../index.js';
|