@tstdl/base 0.93.182 → 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 +6 -1
- 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,178 +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 { describe, expect } from 'vitest';
|
|
12
|
-
import { NotFoundError } from '../../errors/not-found.error.js';
|
|
13
|
-
import { StringProperty } from '../../schema/index.js';
|
|
14
|
-
import { getIntegrationTest } from '../../testing/index.js';
|
|
15
|
-
import { ChildEntity, Column, Inheritance, Table } from '../decorators.js';
|
|
16
|
-
import { Entity } from '../entity.js';
|
|
17
|
-
import { injectRepository } from '../server/repository.js';
|
|
18
|
-
const schema = 'test_orm_edge_cases';
|
|
19
|
-
const test = getIntegrationTest({ orm: { schema } });
|
|
20
|
-
describe('ORM Repository Edge Cases', () => {
|
|
21
|
-
let BaseItem = class BaseItem extends Entity {
|
|
22
|
-
type;
|
|
23
|
-
name;
|
|
24
|
-
};
|
|
25
|
-
__decorate([
|
|
26
|
-
StringProperty(),
|
|
27
|
-
Column({ name: 'type' }),
|
|
28
|
-
__metadata("design:type", String)
|
|
29
|
-
], BaseItem.prototype, "type", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
StringProperty(),
|
|
32
|
-
__metadata("design:type", String)
|
|
33
|
-
], BaseItem.prototype, "name", void 0);
|
|
34
|
-
BaseItem = __decorate([
|
|
35
|
-
Table('base_items', { schema }),
|
|
36
|
-
Inheritance({ strategy: 'joined', discriminatorColumn: 'type' })
|
|
37
|
-
], BaseItem);
|
|
38
|
-
let DerivedItem = class DerivedItem extends BaseItem {
|
|
39
|
-
description;
|
|
40
|
-
};
|
|
41
|
-
__decorate([
|
|
42
|
-
StringProperty(),
|
|
43
|
-
__metadata("design:type", String)
|
|
44
|
-
], DerivedItem.prototype, "description", void 0);
|
|
45
|
-
DerivedItem = __decorate([
|
|
46
|
-
Table('derived_items', { schema }),
|
|
47
|
-
ChildEntity('derived')
|
|
48
|
-
], DerivedItem);
|
|
49
|
-
test.beforeEach(async ({ database: db }) => {
|
|
50
|
-
await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
|
|
51
|
-
await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('derived_items')} CASCADE`);
|
|
52
|
-
await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('base_items')} CASCADE`);
|
|
53
|
-
await db.execute(sql `
|
|
54
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('base_items')} (
|
|
55
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
56
|
-
type TEXT NOT NULL,
|
|
57
|
-
name TEXT NOT NULL,
|
|
58
|
-
revision INTEGER NOT NULL,
|
|
59
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
60
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
61
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
62
|
-
attributes JSONB NOT NULL DEFAULT '{}',
|
|
63
|
-
UNIQUE (id, type)
|
|
64
|
-
)
|
|
65
|
-
`);
|
|
66
|
-
await db.execute(sql `
|
|
67
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('derived_items')} (
|
|
68
|
-
id UUID PRIMARY KEY,
|
|
69
|
-
type TEXT NOT NULL CHECK (type = 'derived'),
|
|
70
|
-
description TEXT NOT NULL,
|
|
71
|
-
FOREIGN KEY (id, type) REFERENCES ${sql.identifier(schema)}.${sql.identifier('base_items')} (id, type) ON DELETE CASCADE
|
|
72
|
-
)
|
|
73
|
-
`);
|
|
74
|
-
});
|
|
75
|
-
test('should rollback transaction on insertMany failure', async () => {
|
|
76
|
-
const repo = injectRepository(BaseItem);
|
|
77
|
-
const id = '00000000-0000-0000-0000-000000000001';
|
|
78
|
-
try {
|
|
79
|
-
await repo.insertMany([
|
|
80
|
-
Object.assign(new BaseItem(), { id, name: 'Success', type: 'base' }),
|
|
81
|
-
Object.assign(new BaseItem(), { id, name: 'Fail', type: 'base' }), // Duplicate ID
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
// Expected
|
|
86
|
-
}
|
|
87
|
-
const count = await repo.count();
|
|
88
|
-
expect(count).toBe(0);
|
|
89
|
-
});
|
|
90
|
-
test('should rollback transaction on updateMany failure', async () => {
|
|
91
|
-
const repo = injectRepository(BaseItem);
|
|
92
|
-
await repo.insert(Object.assign(new BaseItem(), { name: 'Item 1', type: 'base' }));
|
|
93
|
-
try {
|
|
94
|
-
await repo.transaction(async (tx) => {
|
|
95
|
-
const txRepo = repo.withTransaction(tx);
|
|
96
|
-
await txRepo.updateManyByQuery({}, { name: 'Updated' });
|
|
97
|
-
throw new Error('Rollback');
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
// Expected
|
|
102
|
-
}
|
|
103
|
-
const item = await repo.loadByQuery({ name: 'Item 1' });
|
|
104
|
-
expect(item.name).toBe('Item 1');
|
|
105
|
-
});
|
|
106
|
-
test('should throw on negative offset', async () => {
|
|
107
|
-
const repo = injectRepository(BaseItem);
|
|
108
|
-
await expect(repo.loadAll({ offset: -1 })).rejects.toThrow();
|
|
109
|
-
});
|
|
110
|
-
test('should fail when unique constraint is violated even if soft deleted', async () => {
|
|
111
|
-
const repo = injectRepository(BaseItem);
|
|
112
|
-
const id = '00000000-0000-0000-0000-000000000002';
|
|
113
|
-
await repo.insert(Object.assign(new BaseItem(), { id, name: 'A', type: 'base' }));
|
|
114
|
-
await repo.delete(id);
|
|
115
|
-
// Attempt to insert same ID again (Unique violation)
|
|
116
|
-
await expect(repo.insert(Object.assign(new BaseItem(), { id, name: 'B', type: 'base' }))).rejects.toThrow();
|
|
117
|
-
});
|
|
118
|
-
test('should fail loading if child row is missing (data corruption)', async ({ database: db }) => {
|
|
119
|
-
const derivedRepo = injectRepository(DerivedItem);
|
|
120
|
-
const baseRepo = injectRepository(BaseItem);
|
|
121
|
-
const derived = await derivedRepo.insert(Object.assign(new DerivedItem(), { name: 'Derived', description: 'Desc' }));
|
|
122
|
-
// Manually delete child row
|
|
123
|
-
await db.execute(sql `DELETE FROM ${sql.identifier(schema)}.${sql.identifier('derived_items')} WHERE id = ${derived.id}`);
|
|
124
|
-
// Verify deletion
|
|
125
|
-
const { rows } = await db.execute(sql `SELECT * FROM ${sql.identifier(schema)}.${sql.identifier('derived_items')} WHERE id = ${derived.id}`);
|
|
126
|
-
expect(rows).toHaveLength(0);
|
|
127
|
-
// Child repo should fail because primary table row is missing
|
|
128
|
-
await expect(derivedRepo.load(derived.id)).rejects.toThrow(NotFoundError);
|
|
129
|
-
// Base repo should succeed (returning corrupted entity) because base row exists and it uses left join for subclasses
|
|
130
|
-
const loadedBase = await baseRepo.load(derived.id, { includeSubclasses: true });
|
|
131
|
-
expect(loadedBase).toBeInstanceOf(DerivedItem);
|
|
132
|
-
expect(loadedBase.description).toBeNull();
|
|
133
|
-
});
|
|
134
|
-
test('should throw NotFoundError when update target does not exist', async () => {
|
|
135
|
-
const repo = injectRepository(BaseItem);
|
|
136
|
-
await expect(repo.update('00000000-0000-0000-0000-000000000000', { name: 'New' })).rejects.toThrow(NotFoundError);
|
|
137
|
-
});
|
|
138
|
-
test('should throw NotFoundError when updateByQuery matches nothing', async () => {
|
|
139
|
-
const repo = injectRepository(BaseItem);
|
|
140
|
-
await expect(repo.updateByQuery({ name: 'Missing' }, { name: 'New' })).rejects.toThrow(NotFoundError);
|
|
141
|
-
});
|
|
142
|
-
test('should throw NotFoundError when delete target does not exist', async () => {
|
|
143
|
-
const repo = injectRepository(BaseItem);
|
|
144
|
-
await expect(repo.delete('00000000-0000-0000-0000-000000000000')).rejects.toThrow(NotFoundError);
|
|
145
|
-
});
|
|
146
|
-
test('should throw NotFoundError when deleteByQuery matches nothing', async () => {
|
|
147
|
-
const repo = injectRepository(BaseItem);
|
|
148
|
-
await expect(repo.deleteByQuery({ name: 'Missing' })).rejects.toThrow(NotFoundError);
|
|
149
|
-
});
|
|
150
|
-
test('should throw NotFoundError when hardDelete target does not exist', async () => {
|
|
151
|
-
const repo = injectRepository(BaseItem);
|
|
152
|
-
await expect(repo.hardDelete('00000000-0000-0000-0000-000000000000')).rejects.toThrow(NotFoundError);
|
|
153
|
-
});
|
|
154
|
-
test('should throw NotFoundError when hardDeleteByQuery matches nothing', async () => {
|
|
155
|
-
const repo = injectRepository(BaseItem);
|
|
156
|
-
await expect(repo.hardDeleteByQuery({ name: 'Missing' })).rejects.toThrow(NotFoundError);
|
|
157
|
-
});
|
|
158
|
-
test('should handle empty updates gracefully', async () => {
|
|
159
|
-
const repo = injectRepository(BaseItem);
|
|
160
|
-
const item = await repo.insert(Object.assign(new BaseItem(), { name: 'EmptyUpdate', type: 'base' }));
|
|
161
|
-
const updated = await repo.update(item.id, {});
|
|
162
|
-
expect(updated.metadata.revision).toBeGreaterThan(item.metadata.revision);
|
|
163
|
-
expect(updated.name).toBe('EmptyUpdate');
|
|
164
|
-
});
|
|
165
|
-
test('should handle unknown properties in query gracefully (throw error)', async () => {
|
|
166
|
-
const repo = injectRepository(BaseItem);
|
|
167
|
-
await expect(repo.loadByQuery({ unknownProp: 'value' })).rejects.toThrow('Could not map property unknownProp');
|
|
168
|
-
});
|
|
169
|
-
test('should prevent updating discriminator column via update', async () => {
|
|
170
|
-
const repo = injectRepository(BaseItem);
|
|
171
|
-
const item = await repo.insert(Object.assign(new BaseItem(), { name: 'TypeCheck', type: 'base' }));
|
|
172
|
-
// Try to change type to 'derived'
|
|
173
|
-
await repo.update(item.id, { type: 'derived' });
|
|
174
|
-
const reloaded = await repo.load(item.id);
|
|
175
|
-
// It should change if not blocked
|
|
176
|
-
expect(reloaded.type).toBe('derived');
|
|
177
|
-
});
|
|
178
|
-
});
|
|
@@ -1,140 +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 { beforeAll, describe, expect, test } from 'vitest';
|
|
13
|
-
import { StringProperty } from '../../schema/index.js';
|
|
14
|
-
import { setupIntegrationTest } from '../../testing/index.js';
|
|
15
|
-
import { Expires, Table, TimeToLive } from '../decorators.js';
|
|
16
|
-
import { Entity } from '../entity.js';
|
|
17
|
-
import { TimestampProperty } from '../schemas/index.js';
|
|
18
|
-
import { getRepository } from '../server/index.js';
|
|
19
|
-
describe('ORM Repository Expiration', () => {
|
|
20
|
-
let injector;
|
|
21
|
-
let db;
|
|
22
|
-
let expirationRepo;
|
|
23
|
-
let ttlRepo;
|
|
24
|
-
const schema = 'test_orm_expiration';
|
|
25
|
-
let ExpirationEntity = class ExpirationEntity extends Entity {
|
|
26
|
-
name;
|
|
27
|
-
softExpireAt;
|
|
28
|
-
hardExpireAt;
|
|
29
|
-
};
|
|
30
|
-
__decorate([
|
|
31
|
-
StringProperty(),
|
|
32
|
-
__metadata("design:type", String)
|
|
33
|
-
], ExpirationEntity.prototype, "name", void 0);
|
|
34
|
-
__decorate([
|
|
35
|
-
TimestampProperty(),
|
|
36
|
-
Expires({ after: 0, mode: 'soft' }),
|
|
37
|
-
__metadata("design:type", Number)
|
|
38
|
-
], ExpirationEntity.prototype, "softExpireAt", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
TimestampProperty(),
|
|
41
|
-
Expires({ after: 0, mode: 'hard' }),
|
|
42
|
-
__metadata("design:type", Number)
|
|
43
|
-
], ExpirationEntity.prototype, "hardExpireAt", void 0);
|
|
44
|
-
ExpirationEntity = __decorate([
|
|
45
|
-
Table('expiration_entities', { schema })
|
|
46
|
-
], ExpirationEntity);
|
|
47
|
-
let TtlEntity = class TtlEntity extends Entity {
|
|
48
|
-
name;
|
|
49
|
-
};
|
|
50
|
-
__decorate([
|
|
51
|
-
StringProperty(),
|
|
52
|
-
__metadata("design:type", String)
|
|
53
|
-
], TtlEntity.prototype, "name", void 0);
|
|
54
|
-
TtlEntity = __decorate([
|
|
55
|
-
Table('ttl_entities', { schema }),
|
|
56
|
-
TimeToLive(100, 'hard') // 100ms TTL
|
|
57
|
-
], TtlEntity);
|
|
58
|
-
beforeAll(async () => {
|
|
59
|
-
({ injector, database: db } = await setupIntegrationTest({
|
|
60
|
-
orm: { schema },
|
|
61
|
-
}));
|
|
62
|
-
expirationRepo = injector.resolve(getRepository(ExpirationEntity));
|
|
63
|
-
ttlRepo = injector.resolve(getRepository(TtlEntity));
|
|
64
|
-
await db.execute(sql `CREATE SCHEMA IF NOT EXISTS ${sql.identifier(schema)}`);
|
|
65
|
-
await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('expiration_entities')} CASCADE`);
|
|
66
|
-
await db.execute(sql `DROP TABLE IF EXISTS ${sql.identifier(schema)}.${sql.identifier('ttl_entities')} CASCADE`);
|
|
67
|
-
await db.execute(sql `
|
|
68
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('expiration_entities')} (
|
|
69
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
70
|
-
name TEXT NOT NULL,
|
|
71
|
-
soft_expire_at TIMESTAMP WITH TIME ZONE,
|
|
72
|
-
hard_expire_at TIMESTAMP WITH TIME ZONE,
|
|
73
|
-
revision INTEGER NOT NULL,
|
|
74
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
75
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
76
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
77
|
-
attributes JSONB NOT NULL DEFAULT '{}'
|
|
78
|
-
)
|
|
79
|
-
`);
|
|
80
|
-
await db.execute(sql `
|
|
81
|
-
CREATE TABLE ${sql.identifier(schema)}.${sql.identifier('ttl_entities')} (
|
|
82
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
83
|
-
name TEXT NOT NULL,
|
|
84
|
-
revision INTEGER NOT NULL,
|
|
85
|
-
revision_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
86
|
-
create_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
87
|
-
delete_timestamp TIMESTAMP WITH TIME ZONE,
|
|
88
|
-
attributes JSONB NOT NULL DEFAULT '{}'
|
|
89
|
-
)
|
|
90
|
-
`);
|
|
91
|
-
});
|
|
92
|
-
test('should support TimeToLive decorator', async () => {
|
|
93
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('ttl_entities')} CASCADE`);
|
|
94
|
-
const e1 = await ttlRepo.insert(Object.assign(new TtlEntity(), { name: 'Valid' }));
|
|
95
|
-
// Wait 150ms for expiration
|
|
96
|
-
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
97
|
-
await ttlRepo.processExpirations();
|
|
98
|
-
const all = await ttlRepo.loadAll({ withDeleted: true });
|
|
99
|
-
expect(all).toHaveLength(0);
|
|
100
|
-
});
|
|
101
|
-
test('should soft delete expired entities', async () => {
|
|
102
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('expiration_entities')} CASCADE`);
|
|
103
|
-
const now = Date.now();
|
|
104
|
-
const past = now - 10000; // 10s ago
|
|
105
|
-
const future = now + 10000; // 10s in future
|
|
106
|
-
const e1 = await expirationRepo.insert(Object.assign(new ExpirationEntity(), { name: 'Expired', softExpireAt: past }));
|
|
107
|
-
const e2 = await expirationRepo.insert(Object.assign(new ExpirationEntity(), { name: 'Valid', softExpireAt: future }));
|
|
108
|
-
await expirationRepo.processExpirations();
|
|
109
|
-
const all = await expirationRepo.loadAll();
|
|
110
|
-
expect(all).toHaveLength(1);
|
|
111
|
-
expect(all[0].name).toBe('Valid');
|
|
112
|
-
const withDeleted = await expirationRepo.loadAll({ withDeleted: true });
|
|
113
|
-
expect(withDeleted).toHaveLength(2);
|
|
114
|
-
expect(withDeleted.find((e) => e.id === e1.id).metadata.deleteTimestamp).toBeDefined();
|
|
115
|
-
});
|
|
116
|
-
test('should hard delete expired entities', async () => {
|
|
117
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('expiration_entities')} CASCADE`);
|
|
118
|
-
const now = Date.now();
|
|
119
|
-
const past = now - 10000;
|
|
120
|
-
const future = now + 10000;
|
|
121
|
-
const e1 = await expirationRepo.insert(Object.assign(new ExpirationEntity(), { name: 'Expired', hardExpireAt: past }));
|
|
122
|
-
const e2 = await expirationRepo.insert(Object.assign(new ExpirationEntity(), { name: 'Valid', hardExpireAt: future }));
|
|
123
|
-
await expirationRepo.processExpirations();
|
|
124
|
-
const all = await expirationRepo.loadAll({ withDeleted: true });
|
|
125
|
-
expect(all).toHaveLength(1);
|
|
126
|
-
expect(all[0].name).toBe('Valid');
|
|
127
|
-
});
|
|
128
|
-
test('should handle mixed expiration', async () => {
|
|
129
|
-
await db.execute(sql `TRUNCATE TABLE ${sql.identifier(schema)}.${sql.identifier('expiration_entities')} CASCADE`);
|
|
130
|
-
const past = Date.now() - 10000;
|
|
131
|
-
await expirationRepo.insert(Object.assign(new ExpirationEntity(), {
|
|
132
|
-
name: 'BothExpired',
|
|
133
|
-
softExpireAt: past,
|
|
134
|
-
hardExpireAt: past,
|
|
135
|
-
}));
|
|
136
|
-
await expirationRepo.processExpirations();
|
|
137
|
-
const all = await expirationRepo.loadAll({ withDeleted: true });
|
|
138
|
-
expect(all).toHaveLength(0);
|
|
139
|
-
});
|
|
140
|
-
});
|