@tstdl/base 0.93.181 → 0.93.183
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/api/server/api-request-token.provider.js +1 -1
- package/api/server/gateway.js +8 -3
- package/authentication/authentication.api.d.ts +13 -40
- package/authentication/authentication.api.js +5 -14
- package/authentication/client/authentication.service.d.ts +6 -14
- package/authentication/client/authentication.service.js +22 -4
- package/authentication/client/module.d.ts +1 -1
- package/authentication/client/module.js +4 -4
- package/authentication/models/index.d.ts +1 -0
- package/authentication/models/index.js +1 -0
- package/authentication/models/totp-results.model.d.ts +11 -0
- package/authentication/models/totp-results.model.js +37 -0
- package/authentication/server/authentication.api-controller.d.ts +3 -3
- package/authentication/server/authentication.api-controller.js +31 -4
- package/authentication/server/authentication.service.d.ts +5 -14
- package/authentication/server/authentication.service.js +6 -4
- package/core.d.ts +0 -5
- package/core.js +0 -8
- package/document-management/api/document-management.api.d.ts +2 -2
- package/document-management/service-models/document.service-model.d.ts +1 -1
- package/examples/config.d.ts +25 -0
- package/examples/config.js +26 -0
- package/notification/server/module.d.ts +1 -1
- package/notification/server/module.js +1 -1
- package/package.json +5 -5
- package/signals/api.d.ts +5 -1
- package/signals/api.js +3 -1
- package/signals/implementation/api.d.ts +13 -5
- package/signals/implementation/api.js +7 -1
- package/signals/implementation/asserts.d.ts +2 -2
- package/signals/implementation/asserts.js +3 -3
- package/signals/implementation/computed.d.ts +7 -34
- package/signals/implementation/computed.js +14 -83
- package/signals/implementation/configure.js +6 -2
- package/signals/implementation/effect.d.ts +65 -46
- package/signals/implementation/effect.js +97 -62
- package/signals/implementation/index.d.ts +2 -4
- package/signals/implementation/index.js +2 -4
- package/signals/implementation/linked_signal.d.ts +36 -0
- package/signals/implementation/linked_signal.js +34 -0
- package/signals/implementation/primitive/computed.d.ts +55 -0
- package/signals/implementation/primitive/computed.js +107 -0
- package/signals/implementation/primitive/effect.d.ts +26 -0
- package/signals/implementation/primitive/effect.js +31 -0
- package/signals/implementation/{equality.d.ts → primitive/equality.d.ts} +1 -1
- package/signals/implementation/{equality.js → primitive/equality.js} +1 -1
- package/signals/implementation/primitive/errors.d.ts +10 -0
- package/signals/implementation/{errors.js → primitive/errors.js} +3 -4
- package/signals/implementation/primitive/formatter.d.ts +19 -0
- package/signals/implementation/primitive/formatter.js +136 -0
- package/signals/implementation/{graph.d.ts → primitive/graph.d.ts} +68 -36
- package/signals/implementation/primitive/graph.js +386 -0
- package/signals/implementation/primitive/linked_signal.d.ts +46 -0
- package/signals/implementation/primitive/linked_signal.js +110 -0
- package/signals/implementation/primitive/signal.d.ts +31 -0
- package/signals/implementation/primitive/signal.js +80 -0
- package/signals/implementation/primitive/untracked.d.ts +12 -0
- package/signals/implementation/primitive/untracked.js +23 -0
- package/signals/implementation/{watch.d.ts → primitive/watch.d.ts} +1 -2
- package/signals/implementation/{watch.js → primitive/watch.js} +22 -16
- package/signals/implementation/resource/api.d.ts +275 -0
- package/signals/implementation/resource/api.js +26 -0
- package/signals/implementation/resource/debounce.d.ts +13 -0
- package/signals/implementation/resource/debounce.js +113 -0
- package/signals/implementation/resource/from_snapshots.d.ts +16 -0
- package/signals/implementation/resource/from_snapshots.js +44 -0
- package/signals/implementation/resource/index.d.ts +11 -0
- package/signals/implementation/resource/index.js +11 -0
- package/signals/implementation/resource/resource.d.ts +110 -0
- package/signals/implementation/resource/resource.js +402 -0
- package/signals/implementation/root_effect_scheduler.d.ts +50 -0
- package/signals/implementation/root_effect_scheduler.js +66 -0
- package/signals/implementation/signal.d.ts +42 -18
- package/signals/implementation/signal.js +29 -49
- package/signals/implementation/to-observable.d.ts +12 -5
- package/signals/implementation/to-observable.js +12 -2
- package/signals/implementation/to-signal.d.ts +9 -18
- package/signals/implementation/to-signal.js +46 -13
- package/signals/implementation/untracked.d.ts +1 -1
- package/signals/implementation/untracked.js +3 -11
- package/signals/operators/debounce.d.ts +8 -0
- package/signals/operators/debounce.js +19 -0
- package/signals/operators/derive-async.js +43 -15
- package/signals/operators/index.d.ts +2 -0
- package/signals/operators/index.js +2 -0
- package/signals/operators/throttle.d.ts +8 -0
- package/signals/operators/throttle.js +31 -0
- package/ai/genkit/tests/multi-region.test.d.ts +0 -2
- package/ai/genkit/tests/multi-region.test.js +0 -179
- package/ai/genkit/tests/token-limit-fallback.test.d.ts +0 -2
- package/ai/genkit/tests/token-limit-fallback.test.js +0 -209
- package/ai/prompts/tests/prompt-builder.test.d.ts +0 -1
- package/ai/prompts/tests/prompt-builder.test.js +0 -22
- package/ai/tests/instructions-formatter.test.d.ts +0 -1
- package/ai/tests/instructions-formatter.test.js +0 -116
- package/ai/tests/steering.test.d.ts +0 -1
- package/ai/tests/steering.test.js +0 -37
- package/api/client/tests/api-client.test.d.ts +0 -1
- package/api/client/tests/api-client.test.js +0 -194
- package/api/server/tests/csrf.middleware.test.d.ts +0 -1
- package/api/server/tests/csrf.middleware.test.js +0 -91
- package/authentication/tests/authentication-password-requirements.validator.test.d.ts +0 -1
- package/authentication/tests/authentication-password-requirements.validator.test.js +0 -29
- package/authentication/tests/authentication.api-controller.test.d.ts +0 -1
- package/authentication/tests/authentication.api-controller.test.js +0 -156
- package/authentication/tests/authentication.api-request-token.provider.test.d.ts +0 -1
- package/authentication/tests/authentication.api-request-token.provider.test.js +0 -48
- package/authentication/tests/authentication.client-error-handling.test.d.ts +0 -1
- package/authentication/tests/authentication.client-error-handling.test.js +0 -123
- package/authentication/tests/authentication.client-middleware.test.d.ts +0 -1
- package/authentication/tests/authentication.client-middleware.test.js +0 -118
- package/authentication/tests/authentication.client-service-methods.test.d.ts +0 -1
- package/authentication/tests/authentication.client-service-methods.test.js +0 -177
- package/authentication/tests/authentication.client-service-refresh.test.d.ts +0 -1
- package/authentication/tests/authentication.client-service-refresh.test.js +0 -153
- package/authentication/tests/authentication.client-service.test.d.ts +0 -1
- package/authentication/tests/authentication.client-service.test.js +0 -76
- package/authentication/tests/authentication.refresh-busy-loop.test.d.ts +0 -1
- package/authentication/tests/authentication.refresh-busy-loop.test.js +0 -84
- package/authentication/tests/authentication.service.test.d.ts +0 -1
- package/authentication/tests/authentication.service.test.js +0 -167
- package/authentication/tests/authentication.test-ancillary-service.d.ts +0 -9
- package/authentication/tests/authentication.test-ancillary-service.js +0 -27
- package/authentication/tests/brute-force-protection.test.d.ts +0 -1
- package/authentication/tests/brute-force-protection.test.js +0 -211
- package/authentication/tests/helper.test.d.ts +0 -1
- package/authentication/tests/helper.test.js +0 -122
- package/authentication/tests/password-requirements.error.test.d.ts +0 -1
- package/authentication/tests/password-requirements.error.test.js +0 -14
- package/authentication/tests/remember.api.test.d.ts +0 -1
- package/authentication/tests/remember.api.test.js +0 -117
- package/authentication/tests/remember.service.test.d.ts +0 -1
- package/authentication/tests/remember.service.test.js +0 -83
- package/authentication/tests/subject.service.test.d.ts +0 -1
- package/authentication/tests/subject.service.test.js +0 -140
- package/authentication/tests/suspended-subject.test.d.ts +0 -1
- package/authentication/tests/suspended-subject.test.js +0 -120
- package/authentication/tests/totp.enrollment.test.d.ts +0 -1
- package/authentication/tests/totp.enrollment.test.js +0 -123
- package/authentication/tests/totp.login.test.d.ts +0 -1
- package/authentication/tests/totp.login.test.js +0 -213
- package/authentication/tests/totp.recovery-codes.test.d.ts +0 -1
- package/authentication/tests/totp.recovery-codes.test.js +0 -97
- package/authentication/tests/totp.status.test.d.ts +0 -1
- package/authentication/tests/totp.status.test.js +0 -72
- package/cancellation/tests/coverage.test.d.ts +0 -1
- package/cancellation/tests/coverage.test.js +0 -49
- package/cancellation/tests/leak.test.d.ts +0 -1
- package/cancellation/tests/leak.test.js +0 -35
- package/cancellation/tests/token.test.d.ts +0 -1
- package/cancellation/tests/token.test.js +0 -136
- package/circuit-breaker/tests/circuit-breaker.test.d.ts +0 -1
- package/circuit-breaker/tests/circuit-breaker.test.js +0 -116
- package/cryptography/tests/cryptography.test.d.ts +0 -1
- package/cryptography/tests/cryptography.test.js +0 -175
- package/cryptography/tests/jwt.test.d.ts +0 -1
- package/cryptography/tests/jwt.test.js +0 -54
- package/cryptography/tests/modern.test.d.ts +0 -1
- package/cryptography/tests/modern.test.js +0 -105
- package/cryptography/tests/module.test.d.ts +0 -1
- package/cryptography/tests/module.test.js +0 -100
- package/cryptography/tests/totp.test.d.ts +0 -1
- package/cryptography/tests/totp.test.js +0 -108
- package/document-management/tests/ai-config-hierarchy.test.d.ts +0 -1
- package/document-management/tests/ai-config-hierarchy.test.js +0 -59
- package/document-management/tests/ai-config-integration.test.d.ts +0 -1
- package/document-management/tests/ai-config-integration.test.js +0 -125
- package/document-management/tests/ai-config-merge.test.d.ts +0 -1
- package/document-management/tests/ai-config-merge.test.js +0 -46
- package/document-management/tests/document-management-ai-overrides.test.d.ts +0 -1
- package/document-management/tests/document-management-ai-overrides.test.js +0 -63
- package/document-management/tests/document-management-core.test.d.ts +0 -1
- package/document-management/tests/document-management-core.test.js +0 -157
- package/document-management/tests/document-management.api.test.d.ts +0 -1
- package/document-management/tests/document-management.api.test.js +0 -101
- package/document-management/tests/document-statistics.service.test.d.ts +0 -1
- package/document-management/tests/document-statistics.service.test.js +0 -498
- package/document-management/tests/document-validation-ai-overrides.test.d.ts +0 -1
- package/document-management/tests/document-validation-ai-overrides.test.js +0 -87
- package/document-management/tests/document.service.test.d.ts +0 -1
- package/document-management/tests/document.service.test.js +0 -143
- package/document-management/tests/enum-helpers.test.d.ts +0 -1
- package/document-management/tests/enum-helpers.test.js +0 -452
- package/document-management/tests/helper.d.ts +0 -24
- package/document-management/tests/helper.js +0 -39
- package/errors/tests/format.test.d.ts +0 -1
- package/errors/tests/format.test.js +0 -84
- package/http/tests/server-timing.test.d.ts +0 -1
- package/http/tests/server-timing.test.js +0 -42
- package/injector/tests/advanced.test.d.ts +0 -1
- package/injector/tests/advanced.test.js +0 -116
- package/injector/tests/async-init.test.d.ts +0 -1
- package/injector/tests/async-init.test.js +0 -77
- package/injector/tests/basic.test.d.ts +0 -1
- package/injector/tests/basic.test.js +0 -114
- package/injector/tests/hierarchical.test.d.ts +0 -1
- package/injector/tests/hierarchical.test.js +0 -59
- package/injector/tests/leak.test.d.ts +0 -1
- package/injector/tests/leak.test.js +0 -45
- package/injector/tests/lifecycles.test.d.ts +0 -1
- package/injector/tests/lifecycles.test.js +0 -109
- package/logger/tests/pretty-print.test.d.ts +0 -1
- package/logger/tests/pretty-print.test.js +0 -60
- package/notification/tests/notification-api.test.d.ts +0 -1
- package/notification/tests/notification-api.test.js +0 -124
- package/notification/tests/notification-client.test.d.ts +0 -1
- package/notification/tests/notification-client.test.js +0 -101
- package/notification/tests/notification-flow.test.d.ts +0 -1
- package/notification/tests/notification-flow.test.js +0 -296
- package/notification/tests/notification-sse.service.test.d.ts +0 -1
- package/notification/tests/notification-sse.service.test.js +0 -43
- package/notification/tests/notification-type.service.test.d.ts +0 -1
- package/notification/tests/notification-type.service.test.js +0 -41
- package/object-storage/s3/tests/s3.object-storage.integration.test.d.ts +0 -1
- package/object-storage/s3/tests/s3.object-storage.integration.test.js +0 -303
- package/orm/tests/build-jsonb.test.d.ts +0 -1
- package/orm/tests/build-jsonb.test.js +0 -39
- package/orm/tests/data-types.test.d.ts +0 -1
- package/orm/tests/data-types.test.js +0 -39
- package/orm/tests/database-extension.test.d.ts +0 -1
- package/orm/tests/database-extension.test.js +0 -63
- package/orm/tests/database-migration.test.d.ts +0 -1
- package/orm/tests/database-migration.test.js +0 -83
- package/orm/tests/decorators.test.d.ts +0 -1
- package/orm/tests/decorators.test.js +0 -77
- package/orm/tests/encryption.test.d.ts +0 -1
- package/orm/tests/encryption.test.js +0 -31
- package/orm/tests/query-complex.test.d.ts +0 -1
- package/orm/tests/query-complex.test.js +0 -172
- package/orm/tests/query-converter-complex.test.d.ts +0 -1
- package/orm/tests/query-converter-complex.test.js +0 -131
- package/orm/tests/query-converter.test.d.ts +0 -1
- package/orm/tests/query-converter.test.js +0 -123
- package/orm/tests/repository-advanced.test.d.ts +0 -1
- package/orm/tests/repository-advanced.test.js +0 -189
- package/orm/tests/repository-attributes.test.d.ts +0 -1
- package/orm/tests/repository-attributes.test.js +0 -83
- package/orm/tests/repository-compound-primary-key.test.d.ts +0 -2
- package/orm/tests/repository-compound-primary-key.test.js +0 -226
- package/orm/tests/repository-comprehensive.test.d.ts +0 -1
- package/orm/tests/repository-comprehensive.test.js +0 -162
- package/orm/tests/repository-coverage.test.d.ts +0 -2
- package/orm/tests/repository-coverage.test.js +0 -242
- package/orm/tests/repository-cti-complex.test.d.ts +0 -1
- package/orm/tests/repository-cti-complex.test.js +0 -151
- package/orm/tests/repository-cti-embedded.test.d.ts +0 -1
- package/orm/tests/repository-cti-embedded.test.js +0 -178
- package/orm/tests/repository-cti-extensive.test.d.ts +0 -2
- package/orm/tests/repository-cti-extensive.test.js +0 -279
- package/orm/tests/repository-cti-mapping.test.d.ts +0 -2
- package/orm/tests/repository-cti-mapping.test.js +0 -108
- package/orm/tests/repository-cti-search.test.d.ts +0 -1
- package/orm/tests/repository-cti-search.test.js +0 -141
- package/orm/tests/repository-cti-soft-delete.test.d.ts +0 -2
- package/orm/tests/repository-cti-soft-delete.test.js +0 -103
- package/orm/tests/repository-cti-transactions.test.d.ts +0 -1
- package/orm/tests/repository-cti-transactions.test.js +0 -112
- package/orm/tests/repository-cti-upsert-many.test.d.ts +0 -2
- package/orm/tests/repository-cti-upsert-many.test.js +0 -115
- package/orm/tests/repository-cti.test.d.ts +0 -2
- package/orm/tests/repository-cti.test.js +0 -390
- package/orm/tests/repository-edge-cases.test.d.ts +0 -1
- package/orm/tests/repository-edge-cases.test.js +0 -178
- package/orm/tests/repository-expiration.test.d.ts +0 -2
- package/orm/tests/repository-expiration.test.js +0 -140
- package/orm/tests/repository-extra-coverage.test.d.ts +0 -2
- package/orm/tests/repository-extra-coverage.test.js +0 -402
- package/orm/tests/repository-mapping.test.d.ts +0 -2
- package/orm/tests/repository-mapping.test.js +0 -65
- package/orm/tests/repository-regression.test.d.ts +0 -1
- package/orm/tests/repository-regression.test.js +0 -288
- package/orm/tests/repository-search-coverage.test.d.ts +0 -1
- package/orm/tests/repository-search-coverage.test.js +0 -107
- package/orm/tests/repository-search.test.d.ts +0 -1
- package/orm/tests/repository-search.test.js +0 -105
- package/orm/tests/repository-soft-delete.test.d.ts +0 -1
- package/orm/tests/repository-soft-delete.test.js +0 -118
- package/orm/tests/repository-transactions-nested.test.d.ts +0 -1
- package/orm/tests/repository-transactions-nested.test.js +0 -178
- package/orm/tests/repository-types.test.d.ts +0 -1
- package/orm/tests/repository-types.test.js +0 -184
- package/orm/tests/repository-undelete.test.d.ts +0 -2
- package/orm/tests/repository-undelete.test.js +0 -201
- package/orm/tests/schema-converter.test.d.ts +0 -1
- package/orm/tests/schema-converter.test.js +0 -82
- package/orm/tests/schema-generation.test.d.ts +0 -2
- package/orm/tests/schema-generation.test.js +0 -174
- package/orm/tests/sql-helpers.test.d.ts +0 -1
- package/orm/tests/sql-helpers.test.js +0 -67
- package/orm/tests/transaction-safety.test.d.ts +0 -1
- package/orm/tests/transaction-safety.test.js +0 -81
- package/orm/tests/transactional.test.d.ts +0 -1
- package/orm/tests/transactional.test.js +0 -215
- package/orm/tests/utils.test.d.ts +0 -1
- package/orm/tests/utils.test.js +0 -70
- package/pdf/tests/utils.test.d.ts +0 -1
- package/pdf/tests/utils.test.js +0 -187
- package/process/tests/spawn.test.d.ts +0 -1
- package/process/tests/spawn.test.js +0 -182
- package/rate-limit/tests/postgres-rate-limiter.test.d.ts +0 -1
- package/rate-limit/tests/postgres-rate-limiter.test.js +0 -84
- package/renderer/tests/renderer.test.d.ts +0 -1
- package/renderer/tests/renderer.test.js +0 -88
- package/rpc/tests/rpc.integration.test.d.ts +0 -1
- package/rpc/tests/rpc.integration.test.js +0 -615
- package/signals/implementation/errors.d.ts +0 -2
- package/signals/implementation/graph.js +0 -312
- package/signals/implementation/writable-signal.d.ts +0 -48
- package/signals/implementation/writable-signal.js +0 -32
- package/task-queue/tests/coverage-branch.test.d.ts +0 -1
- package/task-queue/tests/coverage-branch.test.js +0 -395
- package/task-queue/tests/coverage-enhancement.test.d.ts +0 -1
- package/task-queue/tests/coverage-enhancement.test.js +0 -150
- package/task-queue/tests/dag.test.d.ts +0 -1
- package/task-queue/tests/dag.test.js +0 -188
- package/task-queue/tests/dependencies.test.d.ts +0 -1
- package/task-queue/tests/dependencies.test.js +0 -296
- package/task-queue/tests/enqueue-batch.test.d.ts +0 -1
- package/task-queue/tests/enqueue-batch.test.js +0 -125
- package/task-queue/tests/enqueue-item.test.d.ts +0 -1
- package/task-queue/tests/enqueue-item.test.js +0 -12
- package/task-queue/tests/fan-out-spawning.test.d.ts +0 -1
- package/task-queue/tests/fan-out-spawning.test.js +0 -94
- package/task-queue/tests/idempotent-replacement.test.d.ts +0 -1
- package/task-queue/tests/idempotent-replacement.test.js +0 -114
- package/task-queue/tests/missing-idempotent-tasks.test.d.ts +0 -1
- package/task-queue/tests/missing-idempotent-tasks.test.js +0 -39
- package/task-queue/tests/optimization-edge-cases.test.d.ts +0 -1
- package/task-queue/tests/optimization-edge-cases.test.js +0 -124
- package/task-queue/tests/queue-generic.test.d.ts +0 -1
- package/task-queue/tests/queue-generic.test.js +0 -8
- package/task-queue/tests/queue.test.d.ts +0 -1
- package/task-queue/tests/queue.test.js +0 -756
- package/task-queue/tests/shutdown.test.d.ts +0 -1
- package/task-queue/tests/shutdown.test.js +0 -41
- package/task-queue/tests/task-context.test.d.ts +0 -1
- package/task-queue/tests/task-context.test.js +0 -7
- package/task-queue/tests/task-union.test.d.ts +0 -1
- package/task-queue/tests/task-union.test.js +0 -18
- package/task-queue/tests/transactions.test.d.ts +0 -1
- package/task-queue/tests/transactions.test.js +0 -47
- package/task-queue/tests/typing.test.d.ts +0 -1
- package/task-queue/tests/typing.test.js +0 -9
- package/task-queue/tests/worker.test.d.ts +0 -1
- package/task-queue/tests/worker.test.js +0 -258
- package/task-queue/tests/zombie-parent.test.d.ts +0 -1
- package/task-queue/tests/zombie-parent.test.js +0 -45
- package/task-queue/tests/zombie-recovery.test.d.ts +0 -1
- package/task-queue/tests/zombie-recovery.test.js +0 -51
- package/utils/tests/backoff.test.d.ts +0 -1
- package/utils/tests/backoff.test.js +0 -41
- package/utils/tests/retry-with-backoff.test.d.ts +0 -1
- package/utils/tests/retry-with-backoff.test.js +0 -49
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { sql } from 'drizzle-orm';
|
|
11
|
-
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
12
|
-
import { StringProperty } from '../../schema/index.js';
|
|
13
|
-
import { dropTables, setupIntegrationTest, truncateTables } from '../../testing/index.js';
|
|
14
|
-
import { Table } from '../decorators.js';
|
|
15
|
-
import { Entity } from '../entity.js';
|
|
16
|
-
import { getRepository } from '../server/index.js';
|
|
17
|
-
describe('ORM Repository Attributes (Integration)', () => {
|
|
18
|
-
let injector;
|
|
19
|
-
let database;
|
|
20
|
-
let repository;
|
|
21
|
-
const schema = 'test_orm_attributes';
|
|
22
|
-
let AttributeEntity = class AttributeEntity extends Entity {
|
|
23
|
-
name;
|
|
24
|
-
};
|
|
25
|
-
__decorate([
|
|
26
|
-
StringProperty(),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], AttributeEntity.prototype, "name", void 0);
|
|
29
|
-
AttributeEntity = __decorate([
|
|
30
|
-
Table('attribute_entities', { schema })
|
|
31
|
-
], AttributeEntity);
|
|
32
|
-
beforeAll(async () => {
|
|
33
|
-
({ injector, database } = await setupIntegrationTest({ orm: { schema } }));
|
|
34
|
-
repository = injector.resolve(getRepository(AttributeEntity));
|
|
35
|
-
await dropTables(database, schema, ['attribute_entities']);
|
|
36
|
-
await database.execute(sql `
|
|
37
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('attribute_entities')} (
|
|
38
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
39
|
-
name TEXT NOT NULL,
|
|
40
|
-
revision INTEGER NOT NULL,
|
|
41
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
42
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
43
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
44
|
-
attributes JSONB NOT NULL DEFAULT '{}'
|
|
45
|
-
)
|
|
46
|
-
`);
|
|
47
|
-
});
|
|
48
|
-
beforeEach(async () => {
|
|
49
|
-
await truncateTables(database, schema, ['attribute_entities']);
|
|
50
|
-
});
|
|
51
|
-
test('should support partial attribute updates', async () => {
|
|
52
|
-
const e1 = await repository.insert(Object.assign(new AttributeEntity(), {
|
|
53
|
-
name: 'E1',
|
|
54
|
-
metadata: { attributes: { a: 1, b: 2 } },
|
|
55
|
-
}));
|
|
56
|
-
expect(e1.metadata.attributes).toEqual({ a: 1, b: 2 });
|
|
57
|
-
const updated = await repository.update(e1.id, {
|
|
58
|
-
metadata: { attributes: { b: 3, c: 4 } },
|
|
59
|
-
});
|
|
60
|
-
expect(updated.metadata.attributes).toEqual({ a: 1, b: 3, c: 4 });
|
|
61
|
-
});
|
|
62
|
-
test('should update attributes during soft delete', async () => {
|
|
63
|
-
const e1 = await repository.insert(Object.assign(new AttributeEntity(), {
|
|
64
|
-
name: 'E1',
|
|
65
|
-
metadata: { attributes: { initial: true } },
|
|
66
|
-
}));
|
|
67
|
-
const deleted = await repository.delete(e1.id, undefined, { attributes: { deleted: true } });
|
|
68
|
-
expect(deleted.metadata.attributes).toEqual({ initial: true, deleted: true });
|
|
69
|
-
});
|
|
70
|
-
test('should support querying by raw SQL on attributes', async () => {
|
|
71
|
-
await repository.insert(Object.assign(new AttributeEntity(), {
|
|
72
|
-
name: 'E1',
|
|
73
|
-
metadata: { attributes: { key: 'value1' } },
|
|
74
|
-
}));
|
|
75
|
-
await repository.insert(Object.assign(new AttributeEntity(), {
|
|
76
|
-
name: 'E2',
|
|
77
|
-
metadata: { attributes: { key: 'value2' } },
|
|
78
|
-
}));
|
|
79
|
-
const results = await repository.loadManyByQuery(sql `attributes->>'key' = 'value1'`);
|
|
80
|
-
expect(results).toHaveLength(1);
|
|
81
|
-
expect(results[0].name).toBe('E1');
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/** biome-ignore-all lint/nursery/noExcessiveClassesPerFile: <explanation> */
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
import { sql } from 'drizzle-orm';
|
|
12
|
-
import { getTableConfig } from 'drizzle-orm/pg-core';
|
|
13
|
-
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
14
|
-
import { StringProperty } from '../../schema/index.js';
|
|
15
|
-
import { dropTables, setupIntegrationTest } from '../../testing/index.js';
|
|
16
|
-
import { ChildEntity, Inheritance, PrimaryKey, Table } from '../decorators.js';
|
|
17
|
-
import { Entity } from '../entity.js';
|
|
18
|
-
import { getDrizzleTableFromType } from '../server/drizzle/index.js';
|
|
19
|
-
import { getRepository } from '../server/index.js';
|
|
20
|
-
describe('ORM Repository Compound Primary Key (Integration)', () => {
|
|
21
|
-
let injector;
|
|
22
|
-
let database;
|
|
23
|
-
let compoundRepo;
|
|
24
|
-
let parentRepo;
|
|
25
|
-
let childRepo;
|
|
26
|
-
let grandchildRepo;
|
|
27
|
-
const schema = 'test_orm_compound_pk';
|
|
28
|
-
let CompoundEntity = class CompoundEntity extends Entity {
|
|
29
|
-
namespace;
|
|
30
|
-
data;
|
|
31
|
-
};
|
|
32
|
-
__decorate([
|
|
33
|
-
StringProperty(),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], CompoundEntity.prototype, "namespace", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
StringProperty(),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], CompoundEntity.prototype, "data", void 0);
|
|
40
|
-
CompoundEntity = __decorate([
|
|
41
|
-
Table('compound_entities', { schema }),
|
|
42
|
-
PrimaryKey(['namespace', 'id'])
|
|
43
|
-
], CompoundEntity);
|
|
44
|
-
let ParentEntity = class ParentEntity extends Entity {
|
|
45
|
-
namespace;
|
|
46
|
-
type;
|
|
47
|
-
};
|
|
48
|
-
__decorate([
|
|
49
|
-
StringProperty(),
|
|
50
|
-
__metadata("design:type", String)
|
|
51
|
-
], ParentEntity.prototype, "namespace", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
StringProperty(),
|
|
54
|
-
__metadata("design:type", String)
|
|
55
|
-
], ParentEntity.prototype, "type", void 0);
|
|
56
|
-
ParentEntity = __decorate([
|
|
57
|
-
Table('parent_entities', { schema }),
|
|
58
|
-
PrimaryKey(['namespace', 'id']),
|
|
59
|
-
Inheritance({ strategy: 'joined', discriminatorColumn: 'type' })
|
|
60
|
-
], ParentEntity);
|
|
61
|
-
let ChildEntityModel = class ChildEntityModel extends ParentEntity {
|
|
62
|
-
childData;
|
|
63
|
-
};
|
|
64
|
-
__decorate([
|
|
65
|
-
StringProperty(),
|
|
66
|
-
__metadata("design:type", String)
|
|
67
|
-
], ChildEntityModel.prototype, "childData", void 0);
|
|
68
|
-
ChildEntityModel = __decorate([
|
|
69
|
-
Table('child_entities', { schema }),
|
|
70
|
-
ChildEntity('child')
|
|
71
|
-
], ChildEntityModel);
|
|
72
|
-
let GrandchildEntity = class GrandchildEntity extends ChildEntityModel {
|
|
73
|
-
grandchildData;
|
|
74
|
-
};
|
|
75
|
-
__decorate([
|
|
76
|
-
StringProperty(),
|
|
77
|
-
__metadata("design:type", String)
|
|
78
|
-
], GrandchildEntity.prototype, "grandchildData", void 0);
|
|
79
|
-
GrandchildEntity = __decorate([
|
|
80
|
-
Table('grandchild_entities', { schema }),
|
|
81
|
-
ChildEntity('grandchild')
|
|
82
|
-
], GrandchildEntity);
|
|
83
|
-
beforeAll(async () => {
|
|
84
|
-
({ injector, database } = await setupIntegrationTest({ orm: { schema } }));
|
|
85
|
-
compoundRepo = injector.resolve(getRepository(CompoundEntity));
|
|
86
|
-
parentRepo = injector.resolve(getRepository(ParentEntity));
|
|
87
|
-
childRepo = injector.resolve(getRepository(ChildEntityModel));
|
|
88
|
-
grandchildRepo = injector.resolve(getRepository(GrandchildEntity));
|
|
89
|
-
await database.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
|
|
90
|
-
await dropTables(database, schema, ['grandchild_entities', 'child_entities', 'parent_entities', 'compound_entities']);
|
|
91
|
-
await database.execute(sql `
|
|
92
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('compound_entities')} (
|
|
93
|
-
namespace TEXT NOT NULL,
|
|
94
|
-
id UUID NOT NULL,
|
|
95
|
-
data TEXT NOT NULL,
|
|
96
|
-
revision INTEGER NOT NULL,
|
|
97
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
98
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
99
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
100
|
-
attributes JSONB NOT NULL DEFAULT '{}',
|
|
101
|
-
PRIMARY KEY (namespace, id)
|
|
102
|
-
)
|
|
103
|
-
`);
|
|
104
|
-
await database.execute(sql `
|
|
105
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('parent_entities')} (
|
|
106
|
-
namespace TEXT NOT NULL,
|
|
107
|
-
id UUID NOT NULL,
|
|
108
|
-
type TEXT NOT NULL,
|
|
109
|
-
revision INTEGER NOT NULL,
|
|
110
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
111
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
112
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
113
|
-
attributes JSONB NOT NULL DEFAULT '{}',
|
|
114
|
-
PRIMARY KEY (namespace, id),
|
|
115
|
-
UNIQUE (namespace, id, type)
|
|
116
|
-
)
|
|
117
|
-
`);
|
|
118
|
-
await database.execute(sql `
|
|
119
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('child_entities')} (
|
|
120
|
-
namespace TEXT NOT NULL,
|
|
121
|
-
id UUID NOT NULL,
|
|
122
|
-
type TEXT NOT NULL CHECK (type IN ('child', 'grandchild')),
|
|
123
|
-
child_data TEXT NOT NULL,
|
|
124
|
-
PRIMARY KEY (namespace, id),
|
|
125
|
-
FOREIGN KEY (namespace, id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('parent_entities')} (namespace, id, type) ON DELETE CASCADE,
|
|
126
|
-
UNIQUE (namespace, id, type)
|
|
127
|
-
)
|
|
128
|
-
`);
|
|
129
|
-
await database.execute(sql `
|
|
130
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('grandchild_entities')} (
|
|
131
|
-
namespace TEXT NOT NULL,
|
|
132
|
-
id UUID NOT NULL,
|
|
133
|
-
type TEXT NOT NULL CHECK (type = 'grandchild'),
|
|
134
|
-
grandchild_data TEXT NOT NULL,
|
|
135
|
-
PRIMARY KEY (namespace, id),
|
|
136
|
-
FOREIGN KEY (namespace, id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('child_entities')} (namespace, id, type) ON DELETE CASCADE
|
|
137
|
-
)
|
|
138
|
-
`);
|
|
139
|
-
});
|
|
140
|
-
beforeEach(async () => {
|
|
141
|
-
await database.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('grandchild_entities')}, ${sql.identifier(schema)}.${sql.identifier('child_entities')}, ${sql.identifier(schema)}.${sql.identifier('parent_entities')}, ${sql.identifier(schema)}.${sql.identifier('compound_entities')} CASCADE`);
|
|
142
|
-
});
|
|
143
|
-
test('should insert and load compound entity', async () => {
|
|
144
|
-
const entity = new CompoundEntity();
|
|
145
|
-
entity.id = '00000000-0000-0000-0000-000000000001';
|
|
146
|
-
entity.namespace = 'ns1';
|
|
147
|
-
entity.data = 'test data';
|
|
148
|
-
await compoundRepo.insert(entity);
|
|
149
|
-
const loaded = await compoundRepo.loadByQuery({ namespace: 'ns1', id: '00000000-0000-0000-0000-000000000001' });
|
|
150
|
-
expect(loaded.data).toBe('test data');
|
|
151
|
-
expect(loaded.namespace).toBe('ns1');
|
|
152
|
-
expect(loaded.id).toBe('00000000-0000-0000-0000-000000000001');
|
|
153
|
-
});
|
|
154
|
-
test('should upsert compound entity', async () => {
|
|
155
|
-
const entity = new CompoundEntity();
|
|
156
|
-
entity.id = '00000000-0000-0000-0000-000000000010';
|
|
157
|
-
entity.namespace = 'ns1';
|
|
158
|
-
entity.data = 'initial data';
|
|
159
|
-
await compoundRepo.insert(entity);
|
|
160
|
-
const updateEntity = new CompoundEntity();
|
|
161
|
-
updateEntity.id = '00000000-0000-0000-0000-000000000010';
|
|
162
|
-
updateEntity.namespace = 'ns1';
|
|
163
|
-
updateEntity.data = 'updated data';
|
|
164
|
-
await compoundRepo.upsert(['namespace', 'id'], updateEntity);
|
|
165
|
-
const loaded = await compoundRepo.loadByQuery({ namespace: 'ns1', id: '00000000-0000-0000-0000-000000000010' });
|
|
166
|
-
expect(loaded.data).toBe('updated data');
|
|
167
|
-
});
|
|
168
|
-
test('should insert and load child entity with compound PK', async () => {
|
|
169
|
-
const entity = new ChildEntityModel();
|
|
170
|
-
entity.id = '00000000-0000-0000-0000-000000000020';
|
|
171
|
-
entity.namespace = 'ns2';
|
|
172
|
-
entity.type = 'child';
|
|
173
|
-
entity.childData = 'child specific data';
|
|
174
|
-
await childRepo.insert(entity);
|
|
175
|
-
const loaded = await childRepo.loadByQuery({ namespace: 'ns2', id: '00000000-0000-0000-0000-000000000020' });
|
|
176
|
-
expect(loaded.childData).toBe('child specific data');
|
|
177
|
-
expect(loaded.namespace).toBe('ns2');
|
|
178
|
-
expect(loaded.id).toBe('00000000-0000-0000-0000-000000000020');
|
|
179
|
-
});
|
|
180
|
-
test('should insert and load grandchild entity with compound PK', async () => {
|
|
181
|
-
const entity = new GrandchildEntity();
|
|
182
|
-
entity.id = '00000000-0000-0000-0000-000000000050';
|
|
183
|
-
entity.namespace = 'ns5';
|
|
184
|
-
entity.type = 'grandchild';
|
|
185
|
-
entity.childData = 'child part';
|
|
186
|
-
entity.grandchildData = 'grandchild part';
|
|
187
|
-
await grandchildRepo.insert(entity);
|
|
188
|
-
const loaded = await grandchildRepo.loadByQuery({ namespace: 'ns5', id: '00000000-0000-0000-0000-000000000050' });
|
|
189
|
-
expect(loaded.grandchildData).toBe('grandchild part');
|
|
190
|
-
expect(loaded.childData).toBe('child part');
|
|
191
|
-
expect(loaded.namespace).toBe('ns5');
|
|
192
|
-
expect(loaded.id).toBe('00000000-0000-0000-0000-000000000050');
|
|
193
|
-
});
|
|
194
|
-
test('should updateManyByQuery with compound PK', async () => {
|
|
195
|
-
const entity1 = new CompoundEntity();
|
|
196
|
-
entity1.id = '00000000-0000-0000-0000-000000000030';
|
|
197
|
-
entity1.namespace = 'ns3';
|
|
198
|
-
entity1.data = 'data 1';
|
|
199
|
-
const entity2 = new CompoundEntity();
|
|
200
|
-
entity2.id = '00000000-0000-0000-0000-000000000040';
|
|
201
|
-
entity2.namespace = 'ns3';
|
|
202
|
-
entity2.data = 'data 2';
|
|
203
|
-
await compoundRepo.insertMany([entity1, entity2]);
|
|
204
|
-
await compoundRepo.updateManyByQuery({ namespace: 'ns3' }, { data: 'batch updated' });
|
|
205
|
-
const entities = await compoundRepo.loadManyByQuery({ namespace: 'ns3' });
|
|
206
|
-
expect(entities).toHaveLength(2);
|
|
207
|
-
expect(entities.every(e => e.data === 'batch updated')).toBe(true);
|
|
208
|
-
});
|
|
209
|
-
test('should respect custom primary key name', () => {
|
|
210
|
-
let CustomPkEntity = class CustomPkEntity extends Entity {
|
|
211
|
-
namespace;
|
|
212
|
-
};
|
|
213
|
-
__decorate([
|
|
214
|
-
StringProperty(),
|
|
215
|
-
__metadata("design:type", String)
|
|
216
|
-
], CustomPkEntity.prototype, "namespace", void 0);
|
|
217
|
-
CustomPkEntity = __decorate([
|
|
218
|
-
Table('custom_pk_table', { schema: 'test' }),
|
|
219
|
-
PrimaryKey(['namespace', 'id'], { name: 'my_custom_pk' })
|
|
220
|
-
], CustomPkEntity);
|
|
221
|
-
const table = getDrizzleTableFromType(CustomPkEntity);
|
|
222
|
-
const config = getTableConfig(table);
|
|
223
|
-
expect(config.primaryKeys).toHaveLength(1);
|
|
224
|
-
expect(config.primaryKeys[0].name).toBe('my_custom_pk');
|
|
225
|
-
});
|
|
226
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { sql } from 'drizzle-orm';
|
|
11
|
-
import { beforeAll, describe, expect, test } from 'vitest';
|
|
12
|
-
import { Integer, StringProperty } from '../../schema/index.js';
|
|
13
|
-
import { setupIntegrationTest } from '../../testing/index.js';
|
|
14
|
-
import { GeneratedTsVector, Table } from '../decorators.js';
|
|
15
|
-
import { Entity } from '../entity.js';
|
|
16
|
-
import { getRepository, injectRepository } from '../server/index.js';
|
|
17
|
-
describe('ORM Repository Comprehensive Options & Edge Cases', () => {
|
|
18
|
-
let injector;
|
|
19
|
-
let db;
|
|
20
|
-
let repository;
|
|
21
|
-
const schema = 'test_orm_comprehensive';
|
|
22
|
-
let ComprehensiveEntity = class ComprehensiveEntity extends Entity {
|
|
23
|
-
name;
|
|
24
|
-
category;
|
|
25
|
-
value;
|
|
26
|
-
searchVector;
|
|
27
|
-
};
|
|
28
|
-
__decorate([
|
|
29
|
-
StringProperty(),
|
|
30
|
-
__metadata("design:type", String)
|
|
31
|
-
], ComprehensiveEntity.prototype, "name", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
StringProperty(),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], ComprehensiveEntity.prototype, "category", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
Integer(),
|
|
38
|
-
__metadata("design:type", Number)
|
|
39
|
-
], ComprehensiveEntity.prototype, "value", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
StringProperty(),
|
|
42
|
-
GeneratedTsVector({ sources: ['name', 'category'] }),
|
|
43
|
-
__metadata("design:type", Object)
|
|
44
|
-
], ComprehensiveEntity.prototype, "searchVector", void 0);
|
|
45
|
-
ComprehensiveEntity = __decorate([
|
|
46
|
-
Table('comprehensive_entities', { schema })
|
|
47
|
-
], ComprehensiveEntity);
|
|
48
|
-
beforeAll(async () => {
|
|
49
|
-
({ injector, database: db } = await setupIntegrationTest({
|
|
50
|
-
orm: { schema },
|
|
51
|
-
}));
|
|
52
|
-
repository = injector.resolve(getRepository(ComprehensiveEntity));
|
|
53
|
-
await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
|
|
54
|
-
await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} CASCADE`);
|
|
55
|
-
await db.execute(sql `
|
|
56
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} (
|
|
57
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
58
|
-
name TEXT NOT NULL,
|
|
59
|
-
category TEXT NOT NULL,
|
|
60
|
-
value INTEGER NOT NULL,
|
|
61
|
-
search_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple', name || ' ' || category)) STORED,
|
|
62
|
-
revision INTEGER NOT NULL,
|
|
63
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
64
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
65
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
66
|
-
attributes JSONB NOT NULL DEFAULT '{}'
|
|
67
|
-
)
|
|
68
|
-
`);
|
|
69
|
-
await db.execute(sql `CREATE INDEX idx_comprehensive_search ON ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} USING GIN (search_vector)`);
|
|
70
|
-
});
|
|
71
|
-
test('should support DISTINCT ON loading', async () => {
|
|
72
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} CASCADE`);
|
|
73
|
-
await repository.insertMany([
|
|
74
|
-
Object.assign(new ComprehensiveEntity(), { name: 'A1', category: 'Cat1', value: 10 }),
|
|
75
|
-
Object.assign(new ComprehensiveEntity(), { name: 'A2', category: 'Cat1', value: 20 }),
|
|
76
|
-
Object.assign(new ComprehensiveEntity(), { name: 'B1', category: 'Cat2', value: 30 }),
|
|
77
|
-
]);
|
|
78
|
-
// Load distinct by category, order by category and value desc to get the one with highest value per category
|
|
79
|
-
const results = await repository.loadManyByQuery({}, {
|
|
80
|
-
distinct: ['category'],
|
|
81
|
-
order: [['category', 'asc'], ['value', 'desc']],
|
|
82
|
-
});
|
|
83
|
-
expect(results).toHaveLength(2);
|
|
84
|
-
expect(results.find((r) => r.category === 'Cat1').name).toBe('A2'); // Value 20 > 10
|
|
85
|
-
expect(results.find((r) => r.category === 'Cat2').name).toBe('B1');
|
|
86
|
-
});
|
|
87
|
-
test('should support search with filter and distinct', async () => {
|
|
88
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} CASCADE`);
|
|
89
|
-
await repository.insertMany([
|
|
90
|
-
Object.assign(new ComprehensiveEntity(), { name: 'Apple One', category: 'Fruit', value: 5 }),
|
|
91
|
-
Object.assign(new ComprehensiveEntity(), { name: 'Apple Two', category: 'Fruit', value: 15 }),
|
|
92
|
-
Object.assign(new ComprehensiveEntity(), { name: 'Apple Three', category: 'Tech', value: 25 }),
|
|
93
|
-
]);
|
|
94
|
-
// Search "Apple", filter value > 10, distinct category
|
|
95
|
-
const results = await repository.search({
|
|
96
|
-
query: { $tsvector: { fields: ['searchVector'], query: 'Apple' } },
|
|
97
|
-
filter: { value: { $gt: 10 } },
|
|
98
|
-
distinct: ['category'],
|
|
99
|
-
order: [['category', 'asc'], ['value', 'desc']], // Distinct on requires matching order prefix
|
|
100
|
-
});
|
|
101
|
-
expect(results).toHaveLength(2);
|
|
102
|
-
const categories = results.map((r) => r.entity.category).sort();
|
|
103
|
-
expect(categories).toEqual(['Fruit', 'Tech']);
|
|
104
|
-
const fruit = results.find((r) => r.entity.category === 'Fruit');
|
|
105
|
-
expect(fruit.entity.name).toBe('Apple Two'); // Value 15 > 10, Apple One filtered out or lower
|
|
106
|
-
});
|
|
107
|
-
test('should handle soft deletes correctly in updates', async () => {
|
|
108
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} CASCADE`);
|
|
109
|
-
const entity = await repository.insert(Object.assign(new ComprehensiveEntity(), { name: 'To Delete', category: 'Test', value: 1 }));
|
|
110
|
-
await repository.delete(entity.id);
|
|
111
|
-
// Try update without withDeleted (should fail/return undefined)
|
|
112
|
-
const tryUpdateResult = await repository.tryUpdate(entity.id, { name: 'Resurrected?' });
|
|
113
|
-
expect(tryUpdateResult).toBeUndefined();
|
|
114
|
-
// Ensure DB is unchanged
|
|
115
|
-
const row = await repository.tryLoad(entity.id, { withDeleted: true });
|
|
116
|
-
expect(row.name).toBe('To Delete');
|
|
117
|
-
// Update WITH withDeleted (should work)
|
|
118
|
-
const updateResult = await repository.update(entity.id, { name: 'Zombie' }, { withDeleted: true });
|
|
119
|
-
expect(updateResult.name).toBe('Zombie');
|
|
120
|
-
expect(updateResult.metadata.deleteTimestamp).not.toBeNull(); // Still deleted
|
|
121
|
-
});
|
|
122
|
-
test('should handle count with and without deleted', async () => {
|
|
123
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} CASCADE`);
|
|
124
|
-
await repository.insert(Object.assign(new ComprehensiveEntity(), { name: 'Alive', category: 'A', value: 1 }));
|
|
125
|
-
const dead = await repository.insert(Object.assign(new ComprehensiveEntity(), { name: 'Dead', category: 'A', value: 2 }));
|
|
126
|
-
await repository.delete(dead.id);
|
|
127
|
-
expect(await repository.count()).toBe(1);
|
|
128
|
-
expect(await repository.count({ withDeleted: true })).toBe(2);
|
|
129
|
-
expect(await repository.countByQuery({ category: 'A' })).toBe(1);
|
|
130
|
-
expect(await repository.countByQuery({ category: 'A' }, { withDeleted: true })).toBe(2);
|
|
131
|
-
});
|
|
132
|
-
test('should fail gracefully (return undefined) for missing entities in tryLoad operations', async () => {
|
|
133
|
-
expect(await repository.tryLoad('00000000-0000-0000-0000-000000000000')).toBeUndefined();
|
|
134
|
-
expect(await repository.tryLoadByQuery({ name: 'NonExistent' })).toBeUndefined();
|
|
135
|
-
});
|
|
136
|
-
test('should return empty array for empty search results', async () => {
|
|
137
|
-
const results = await repository.search({ query: { $tsvector: { fields: ['name'], query: 'NonExistentTerm' } } });
|
|
138
|
-
expect(results).toEqual([]);
|
|
139
|
-
});
|
|
140
|
-
test('should support complex ordering with multiple fields', async () => {
|
|
141
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('comprehensive_entities')} CASCADE`);
|
|
142
|
-
await repository.insertMany([
|
|
143
|
-
Object.assign(new ComprehensiveEntity(), { name: 'A', category: 'X', value: 1 }),
|
|
144
|
-
Object.assign(new ComprehensiveEntity(), { name: 'B', category: 'X', value: 2 }),
|
|
145
|
-
Object.assign(new ComprehensiveEntity(), { name: 'A', category: 'Y', value: 3 }),
|
|
146
|
-
]);
|
|
147
|
-
// Order by Name ASC, then Value DESC
|
|
148
|
-
const results = await repository.loadAll({
|
|
149
|
-
order: [['name', 'asc'], ['value', 'desc']],
|
|
150
|
-
});
|
|
151
|
-
expect(results).toHaveLength(3);
|
|
152
|
-
expect(results[0].name).toBe('A');
|
|
153
|
-
expect(results[0].value).toBe(3); // Y (3) comes before X (1) because both are A? No, wait.
|
|
154
|
-
// Name A (Y, 3) and Name A (X, 1).
|
|
155
|
-
// Order: Name ASC. A, A, B.
|
|
156
|
-
// Tie-break Name: Value DESC. 3, 1.
|
|
157
|
-
// So A(3) then A(1).
|
|
158
|
-
expect(results[1].name).toBe('A');
|
|
159
|
-
expect(results[1].value).toBe(1);
|
|
160
|
-
expect(results[2].name).toBe('B');
|
|
161
|
-
});
|
|
162
|
-
});
|