@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
package/pdf/tests/utils.test.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
|
-
import { describe, expect, it } from 'vitest';
|
|
54
|
-
import { TemporaryFile } from '../../file/server/temporary-file.js';
|
|
55
|
-
import { spawnCommand } from '../../process/spawn.js';
|
|
56
|
-
import { extractPdfPages, getPdfPageCount, mergePdfs, overlayPdfs, pdfToImage } from '../utils.js';
|
|
57
|
-
describe('pdf utils', () => {
|
|
58
|
-
async function createPdf(pages) {
|
|
59
|
-
const file = TemporaryFile.create('.pdf');
|
|
60
|
-
const source = Array.from({ length: pages }, (_, i) => `Page ${i + 1}`).join('\n#pagebreak()\n');
|
|
61
|
-
const process = await spawnCommand('typst', ['compile', '-', file.path]);
|
|
62
|
-
await process.write(source);
|
|
63
|
-
await process.wait();
|
|
64
|
-
return file;
|
|
65
|
-
}
|
|
66
|
-
it('getPdfPageCount should return correct page count', async () => {
|
|
67
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
68
|
-
try {
|
|
69
|
-
const pdf = __addDisposableResource(env_1, await createPdf(5), true);
|
|
70
|
-
const count = await getPdfPageCount(pdf.path);
|
|
71
|
-
expect(count).toBe(5);
|
|
72
|
-
}
|
|
73
|
-
catch (e_1) {
|
|
74
|
-
env_1.error = e_1;
|
|
75
|
-
env_1.hasError = true;
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
const result_1 = __disposeResources(env_1);
|
|
79
|
-
if (result_1)
|
|
80
|
-
await result_1;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
it('extractPdfPages should extract specific pages', async () => {
|
|
84
|
-
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
85
|
-
try {
|
|
86
|
-
const pdf = __addDisposableResource(env_2, await createPdf(10), true);
|
|
87
|
-
const extracted = __addDisposableResource(env_2, await extractPdfPages(pdf.path, [1, { from: 3, to: 5 }]), true);
|
|
88
|
-
const count = await getPdfPageCount(extracted.path);
|
|
89
|
-
expect(count).toBe(4); // 1 + (5-3+1) = 4
|
|
90
|
-
}
|
|
91
|
-
catch (e_2) {
|
|
92
|
-
env_2.error = e_2;
|
|
93
|
-
env_2.hasError = true;
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
const result_2 = __disposeResources(env_2);
|
|
97
|
-
if (result_2)
|
|
98
|
-
await result_2;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
it('mergePdfs should handle different input types and page ranges', async () => {
|
|
102
|
-
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
103
|
-
try {
|
|
104
|
-
const pdf1 = __addDisposableResource(env_3, await createPdf(2), true);
|
|
105
|
-
const pdf2 = __addDisposableResource(env_3, await createPdf(3), true);
|
|
106
|
-
const pdf2Bytes = await pdf1.read();
|
|
107
|
-
// Test with path, Uint8Array, and page range object
|
|
108
|
-
const merged = __addDisposableResource(env_3, await mergePdfs([
|
|
109
|
-
pdf1.path,
|
|
110
|
-
pdf2Bytes,
|
|
111
|
-
{ input: pdf2.path, pages: [1, { from: 2, to: 3 }] },
|
|
112
|
-
]), true);
|
|
113
|
-
const count = await getPdfPageCount(merged.path);
|
|
114
|
-
expect(count).toBe(2 + 2 + 3); // 2 (path) + 2 (bytes) + 3 (page range)
|
|
115
|
-
}
|
|
116
|
-
catch (e_3) {
|
|
117
|
-
env_3.error = e_3;
|
|
118
|
-
env_3.hasError = true;
|
|
119
|
-
}
|
|
120
|
-
finally {
|
|
121
|
-
const result_3 = __disposeResources(env_3);
|
|
122
|
-
if (result_3)
|
|
123
|
-
await result_3;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
it('pdfToImage should work with binary inputs', async () => {
|
|
127
|
-
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
128
|
-
try {
|
|
129
|
-
const pdf = __addDisposableResource(env_4, await createPdf(1), true);
|
|
130
|
-
const pdfBytes = await pdf.read();
|
|
131
|
-
// pdftocairo fails in some environments if no fonts are available,
|
|
132
|
-
// but here we just want to test the branching logic of writing bytes
|
|
133
|
-
const result = await pdfToImage(pdfBytes, 1, 100, 'png');
|
|
134
|
-
expect(result).toBeInstanceOf(Uint8Array);
|
|
135
|
-
}
|
|
136
|
-
catch (e_4) {
|
|
137
|
-
env_4.error = e_4;
|
|
138
|
-
env_4.hasError = true;
|
|
139
|
-
}
|
|
140
|
-
finally {
|
|
141
|
-
const result_4 = __disposeResources(env_4);
|
|
142
|
-
if (result_4)
|
|
143
|
-
await result_4;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
it('overlayPdfs should overlay two pdfs', async () => {
|
|
147
|
-
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
148
|
-
try {
|
|
149
|
-
const pdf1 = __addDisposableResource(env_5, await createPdf(1), true);
|
|
150
|
-
const pdf2 = __addDisposableResource(env_5, await createPdf(1), true);
|
|
151
|
-
const overlaid = __addDisposableResource(env_5, await overlayPdfs(pdf1.path, pdf2.path), true);
|
|
152
|
-
const count = await getPdfPageCount(overlaid.path);
|
|
153
|
-
expect(count).toBe(1);
|
|
154
|
-
}
|
|
155
|
-
catch (e_5) {
|
|
156
|
-
env_5.error = e_5;
|
|
157
|
-
env_5.hasError = true;
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
const result_5 = __disposeResources(env_5);
|
|
161
|
-
if (result_5)
|
|
162
|
-
await result_5;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
it('overlayPdfs with repeat should overlay and respect repeat option', async () => {
|
|
166
|
-
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
167
|
-
try {
|
|
168
|
-
const pdf1 = __addDisposableResource(env_6, await createPdf(1), true);
|
|
169
|
-
const pdf2 = __addDisposableResource(env_6, await createPdf(1), true);
|
|
170
|
-
const overlaid = __addDisposableResource(env_6, await overlayPdfs(pdf1.path, pdf2.path, { repeat: true }), true);
|
|
171
|
-
const count = await getPdfPageCount(overlaid.path);
|
|
172
|
-
expect(count).toBe(1);
|
|
173
|
-
}
|
|
174
|
-
catch (e_6) {
|
|
175
|
-
env_6.error = e_6;
|
|
176
|
-
env_6.hasError = true;
|
|
177
|
-
}
|
|
178
|
-
finally {
|
|
179
|
-
const result_6 = __disposeResources(env_6);
|
|
180
|
-
if (result_6)
|
|
181
|
-
await result_6;
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
it('should throw descriptive error on qpdf failure', async () => {
|
|
185
|
-
await expect(getPdfPageCount('non-existent.pdf')).rejects.toThrow(/qpdf: open non-existent.pdf: No such file or directory/);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { encodeUtf8 } from '../../utils/encoding.js';
|
|
3
|
-
import { toReadableStream } from '../../utils/stream/to-readable-stream.js';
|
|
4
|
-
import { spawnCommand, spawnWaitCommand, spawnWaitReadCommand } from '../spawn.js';
|
|
5
|
-
describe('spawn', () => {
|
|
6
|
-
describe('spawnCommand', () => {
|
|
7
|
-
it('should spawn a command and wait for completion', async () => {
|
|
8
|
-
const process = await spawnCommand('sh', ['-c', 'exit 0']);
|
|
9
|
-
const result = await process.wait();
|
|
10
|
-
expect(result.code).toBe(0);
|
|
11
|
-
});
|
|
12
|
-
it('should throw on non-zero exit code', async () => {
|
|
13
|
-
const process = await spawnCommand('sh', ['-c', 'echo "error message" >&2; exit 1']);
|
|
14
|
-
await expect(process.wait()).rejects.toThrow('error message');
|
|
15
|
-
});
|
|
16
|
-
it('should handle process terminated by signal', async () => {
|
|
17
|
-
const process = await spawnCommand('sh', ['-c', 'kill -9 $$']);
|
|
18
|
-
await expect(process.wait()).rejects.toThrow('Process exited with code null and signal SIGKILL');
|
|
19
|
-
});
|
|
20
|
-
it('should buffer stdout and allow multiple reads', async () => {
|
|
21
|
-
const process = await spawnCommand('sh', ['-c', 'echo "hello world"']);
|
|
22
|
-
await process.wait();
|
|
23
|
-
const output1 = await process.readOutput();
|
|
24
|
-
const output2 = await process.readOutput();
|
|
25
|
-
const outputBytes = await process.readOutputBytes();
|
|
26
|
-
expect(output1.trim()).toBe('hello world');
|
|
27
|
-
expect(output1).toBe(output2);
|
|
28
|
-
expect(new TextDecoder().decode(outputBytes).trim()).toBe('hello world');
|
|
29
|
-
});
|
|
30
|
-
it('should buffer stderr and allow multiple reads', async () => {
|
|
31
|
-
const process = await spawnCommand('sh', ['-c', 'echo "error message" >&2']);
|
|
32
|
-
await process.wait();
|
|
33
|
-
const error1 = await process.readError();
|
|
34
|
-
const error2 = await process.readError();
|
|
35
|
-
const errorBytes = await process.readErrorBytes();
|
|
36
|
-
expect(error1.trim()).toBe('error message');
|
|
37
|
-
expect(error1).toBe(error2);
|
|
38
|
-
expect(new TextDecoder().decode(errorBytes).trim()).toBe('error message');
|
|
39
|
-
});
|
|
40
|
-
it('should handle different write data types', async () => {
|
|
41
|
-
const process1 = await spawnCommand('cat');
|
|
42
|
-
await process1.write(toReadableStream(encodeUtf8('stream\n')));
|
|
43
|
-
expect(await process1.readOutput()).toBe('stream\n');
|
|
44
|
-
const process2 = await spawnCommand('cat');
|
|
45
|
-
await process2.write(encodeUtf8('bytes\n'));
|
|
46
|
-
expect(await process2.readOutput()).toBe('bytes\n');
|
|
47
|
-
const process3 = await spawnCommand('cat');
|
|
48
|
-
await process3.write('string\n');
|
|
49
|
-
expect(await process3.readOutput()).toBe('string\n');
|
|
50
|
-
});
|
|
51
|
-
it('should handle background writes and error propagation', async () => {
|
|
52
|
-
const process = await spawnCommand('cat');
|
|
53
|
-
process.writeInBackground('test data');
|
|
54
|
-
const result = await process.waitRead('string');
|
|
55
|
-
expect(result.output).toBe('test data');
|
|
56
|
-
});
|
|
57
|
-
it('should handle errors in writeInBackground', async () => {
|
|
58
|
-
const process = await spawnCommand('sh', ['-c', 'exit 0']);
|
|
59
|
-
await process.writable.close();
|
|
60
|
-
process.writeInBackground('this should fail');
|
|
61
|
-
});
|
|
62
|
-
it('should handle non-zero exit code with empty stderr', async () => {
|
|
63
|
-
const process = await spawnCommand('sh', ['-c', 'exit 1']);
|
|
64
|
-
await expect(process.wait()).rejects.toThrow('Process exited with code 1 and signal null.');
|
|
65
|
-
});
|
|
66
|
-
it('should support manual handleNonZeroExitCode', async () => {
|
|
67
|
-
const process = await spawnCommand('sh', ['-c', 'exit 1']);
|
|
68
|
-
process.handleNonZeroExitCode();
|
|
69
|
-
await expect(process.wait()).rejects.toThrow();
|
|
70
|
-
});
|
|
71
|
-
it('should handle errors when reading error text in nonZeroExitCodeError', async () => {
|
|
72
|
-
// Mock TextDecoder to throw
|
|
73
|
-
const originalTextDecoder = global.TextDecoder;
|
|
74
|
-
global.TextDecoder = vi.fn().mockImplementation(() => ({
|
|
75
|
-
decode: () => { throw new Error('mock error'); },
|
|
76
|
-
}));
|
|
77
|
-
try {
|
|
78
|
-
const process = await spawnCommand('sh', ['-c', 'exit 1']);
|
|
79
|
-
await expect(process.wait()).rejects.toThrow('Process exited with code 1 and signal null.');
|
|
80
|
-
}
|
|
81
|
-
finally {
|
|
82
|
-
global.TextDecoder = originalTextDecoder;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
it('should support passing options as second argument', async () => {
|
|
86
|
-
const process = await spawnCommand('sh', { arguments: ['-c', 'exit 0'] });
|
|
87
|
-
const result = await process.wait();
|
|
88
|
-
expect(result.code).toBe(0);
|
|
89
|
-
});
|
|
90
|
-
it('should support separate args and options', async () => {
|
|
91
|
-
const process = await spawnCommand('sh', ['-c', 'exit 0'], { workingDirectory: '.' });
|
|
92
|
-
const result = await process.wait();
|
|
93
|
-
expect(result.code).toBe(0);
|
|
94
|
-
});
|
|
95
|
-
it('should handle explicit undefined options', async () => {
|
|
96
|
-
const process = await spawnCommand('sh', ['-c', 'exit 0'], undefined);
|
|
97
|
-
const result = await process.wait();
|
|
98
|
-
expect(result.code).toBe(0);
|
|
99
|
-
});
|
|
100
|
-
it('should wait without options', async () => {
|
|
101
|
-
const process = await spawnCommand('sh', ['-c', 'exit 0']);
|
|
102
|
-
const result = await process.wait(undefined);
|
|
103
|
-
expect(result.code).toBe(0);
|
|
104
|
-
});
|
|
105
|
-
it('should handle command only', async () => {
|
|
106
|
-
const process = await spawnCommand('ls');
|
|
107
|
-
const result = await process.wait();
|
|
108
|
-
expect(result.code).toBe(0);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
describe('spawnWaitCommand', () => {
|
|
112
|
-
it('should wait for command and return result', async () => {
|
|
113
|
-
const result = await spawnWaitCommand('sh', ['-c', 'exit 0']);
|
|
114
|
-
expect(result.code).toBe(0);
|
|
115
|
-
});
|
|
116
|
-
it('should throw on error by default', async () => {
|
|
117
|
-
await expect(spawnWaitCommand('sh', ['-c', 'exit 1'])).rejects.toThrow();
|
|
118
|
-
});
|
|
119
|
-
it('should support separate args and options', async () => {
|
|
120
|
-
const result = await spawnWaitCommand('sh', ['-c', 'exit 0'], { workingDirectory: '.' });
|
|
121
|
-
expect(result.code).toBe(0);
|
|
122
|
-
});
|
|
123
|
-
it('should support passing options directly', async () => {
|
|
124
|
-
const result = await spawnWaitCommand('sh', { arguments: ['-c', 'exit 0'] });
|
|
125
|
-
expect(result.code).toBe(0);
|
|
126
|
-
});
|
|
127
|
-
it('should support command only', async () => {
|
|
128
|
-
const result = await spawnWaitCommand('ls');
|
|
129
|
-
expect(result.code).toBe(0);
|
|
130
|
-
});
|
|
131
|
-
it('should handle explicit undefined options', async () => {
|
|
132
|
-
const result = await spawnWaitCommand('sh', ['-c', 'exit 0'], undefined);
|
|
133
|
-
expect(result.code).toBe(0);
|
|
134
|
-
});
|
|
135
|
-
it('should NOT throw on error if throwOnNonZeroExitCode is false', async () => {
|
|
136
|
-
const result = await spawnWaitCommand('sh', ['-c', 'exit 1'], { throwOnNonZeroExitCode: false });
|
|
137
|
-
expect(result.code).toBe(1);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe('spawnWaitReadCommand', () => {
|
|
141
|
-
it('should wait and read output', async () => {
|
|
142
|
-
const result = await spawnWaitReadCommand('string', 'sh', ['-c', 'echo "test"']);
|
|
143
|
-
expect(result.output.trim()).toBe('test');
|
|
144
|
-
});
|
|
145
|
-
it('should read binary output', async () => {
|
|
146
|
-
const result = await spawnWaitReadCommand('binary', 'sh', ['-c', 'echo "test"']);
|
|
147
|
-
expect(result.output).toBeInstanceOf(Uint8Array);
|
|
148
|
-
});
|
|
149
|
-
it('should include error in exception', async () => {
|
|
150
|
-
await expect(spawnWaitReadCommand('string', 'sh', ['-c', 'echo "fail" >&2; exit 1'])).rejects.toThrow('fail');
|
|
151
|
-
});
|
|
152
|
-
it('should support options object', async () => {
|
|
153
|
-
const result = await spawnWaitReadCommand('string', 'sh', { arguments: ['-c', 'echo "test"'] });
|
|
154
|
-
expect(result.output.trim()).toBe('test');
|
|
155
|
-
});
|
|
156
|
-
it('should support separate args and options', async () => {
|
|
157
|
-
const result = await spawnWaitReadCommand('string', 'sh', ['-c', 'echo "test"'], { workingDirectory: '.' });
|
|
158
|
-
expect(result.output.trim()).toBe('test');
|
|
159
|
-
});
|
|
160
|
-
it('should support command only', async () => {
|
|
161
|
-
const result = await spawnWaitReadCommand('string', 'ls');
|
|
162
|
-
expect(result.code).toBe(0);
|
|
163
|
-
});
|
|
164
|
-
it('should NOT throw on error if throwOnNonZeroExitCode is false', async () => {
|
|
165
|
-
const result = await spawnWaitReadCommand('string', 'sh', ['-c', 'echo "fail" >&2; exit 1'], { throwOnNonZeroExitCode: false });
|
|
166
|
-
expect(result.code).toBe(1);
|
|
167
|
-
expect(result.error.trim()).toBe('fail');
|
|
168
|
-
});
|
|
169
|
-
it('should handle explicit undefined options', async () => {
|
|
170
|
-
const result = await spawnWaitReadCommand('string', 'sh', ['-c', 'echo "test"'], undefined);
|
|
171
|
-
expect(result.output.trim()).toBe('test');
|
|
172
|
-
});
|
|
173
|
-
it('should wait and read binary output without options', async () => {
|
|
174
|
-
const result = await spawnWaitReadCommand('binary', 'sh', ['-c', 'echo "test"']);
|
|
175
|
-
expect(result.output).toBeInstanceOf(Uint8Array);
|
|
176
|
-
});
|
|
177
|
-
it('should wait and read with explicit undefined options', async () => {
|
|
178
|
-
const result = await spawnWaitReadCommand('string', 'sh', ['-c', 'echo "test"'], undefined);
|
|
179
|
-
expect(result.output.trim()).toBe('test');
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
2
|
-
import { RateLimiterProvider } from '../../rate-limit/index.js';
|
|
3
|
-
import { setupIntegrationTest } from '../../testing/index.js';
|
|
4
|
-
import { timeout } from '../../utils/timing.js';
|
|
5
|
-
describe('PostgresRateLimiter Integration Tests', () => {
|
|
6
|
-
let injector;
|
|
7
|
-
let rateLimiter;
|
|
8
|
-
const limiterName = `test-limiter-${Date.now()}`;
|
|
9
|
-
beforeAll(async () => {
|
|
10
|
-
({ injector } = await setupIntegrationTest({ modules: { rateLimiter: true } }));
|
|
11
|
-
const rateLimiterProvider = injector.resolve(RateLimiterProvider);
|
|
12
|
-
rateLimiter = rateLimiterProvider.get(limiterName, {
|
|
13
|
-
burstCapacity: 10,
|
|
14
|
-
refillInterval: 500, // 10 tokens per 500ms -> 1 token per 50ms
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
afterAll(async () => {
|
|
18
|
-
await injector?.dispose();
|
|
19
|
-
}, 15000);
|
|
20
|
-
it('should acquire tokens successfully', async () => {
|
|
21
|
-
const resource = 'res-1';
|
|
22
|
-
const result = await rateLimiter.tryAcquire(resource, 5);
|
|
23
|
-
expect(result).toBe(true);
|
|
24
|
-
const result2 = await rateLimiter.tryAcquire(resource, 5);
|
|
25
|
-
expect(result2).toBe(true);
|
|
26
|
-
const result3 = await rateLimiter.tryAcquire(resource, 1);
|
|
27
|
-
expect(result3).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
it('should refill tokens over time', async () => {
|
|
30
|
-
const resource = 'res-2';
|
|
31
|
-
await rateLimiter.tryAcquire(resource, 10);
|
|
32
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
33
|
-
// Wait for 1 token (50ms) + buffer
|
|
34
|
-
await timeout(75);
|
|
35
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(true);
|
|
36
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
it('should refund tokens', async () => {
|
|
39
|
-
const resource = 'res-3';
|
|
40
|
-
await rateLimiter.tryAcquire(resource, 10);
|
|
41
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
42
|
-
await rateLimiter.refund(resource, 5);
|
|
43
|
-
expect(await rateLimiter.tryAcquire(resource, 5)).toBe(true);
|
|
44
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
45
|
-
});
|
|
46
|
-
it('should handle fractional tokens', async () => {
|
|
47
|
-
const resource = 'res-4';
|
|
48
|
-
await rateLimiter.tryAcquire(resource, 9.5);
|
|
49
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
50
|
-
expect(await rateLimiter.tryAcquire(resource, 0.5)).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
it('should handle concurrent acquisitions', async () => {
|
|
53
|
-
const resource = 'res-concurrent';
|
|
54
|
-
// Initialize
|
|
55
|
-
await rateLimiter.tryAcquire(resource, 0);
|
|
56
|
-
const results = await Promise.all(Array.from({ length: 20 }).map(() => rateLimiter.tryAcquire(resource, 1)));
|
|
57
|
-
const successCount = results.filter(Boolean).length;
|
|
58
|
-
// We expect 10, but allow up to 12 if tokens refilled during the Promise.all
|
|
59
|
-
expect(successCount).toBeGreaterThanOrEqual(10);
|
|
60
|
-
expect(successCount).toBeLessThanOrEqual(12);
|
|
61
|
-
}, 15000);
|
|
62
|
-
it('should always allow zero or negative cost', async () => {
|
|
63
|
-
const resource = 'res-zero';
|
|
64
|
-
expect(await rateLimiter.tryAcquire(resource, 0)).toBe(true);
|
|
65
|
-
expect(await rateLimiter.tryAcquire(resource, -1)).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it('should reject cost greater than burst capacity', async () => {
|
|
68
|
-
const resource = 'res-large';
|
|
69
|
-
// Burst capacity is 10
|
|
70
|
-
expect(await rateLimiter.tryAcquire(resource, 11)).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
it('should cap tokens at burst capacity on refill', async () => {
|
|
73
|
-
const resource = 'res-refill-cap';
|
|
74
|
-
// Drain
|
|
75
|
-
await rateLimiter.tryAcquire(resource, 10);
|
|
76
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
77
|
-
// Wait for full refill (500ms) + extra
|
|
78
|
-
await timeout(600);
|
|
79
|
-
// Should only have 10 tokens
|
|
80
|
-
expect(await rateLimiter.tryAcquire(resource, 10)).toBe(true);
|
|
81
|
-
// Should be empty again immediately
|
|
82
|
-
expect(await rateLimiter.tryAcquire(resource, 1)).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { renderD2 } from '../d2.js';
|
|
3
|
-
import { renderGraphviz } from '../graphviz.js';
|
|
4
|
-
import { renderTypst } from '../typst.js';
|
|
5
|
-
describe('renderer', () => {
|
|
6
|
-
describe('renderGraphviz', () => {
|
|
7
|
-
it('should render a simple graph with options', async () => {
|
|
8
|
-
const source = 'graph { a -- b }';
|
|
9
|
-
const result = await renderGraphviz(source, {
|
|
10
|
-
format: 'svg',
|
|
11
|
-
engine: 'dot',
|
|
12
|
-
graphAttributes: { rankdir: 'LR' },
|
|
13
|
-
nodeAttributes: { color: 'red' },
|
|
14
|
-
edgeAttributes: { style: 'dashed' },
|
|
15
|
-
scale: 2,
|
|
16
|
-
quiet: true,
|
|
17
|
-
});
|
|
18
|
-
const svg = new TextDecoder().decode(result);
|
|
19
|
-
expect(svg).toContain('<svg');
|
|
20
|
-
expect(svg).toContain('stroke="red"');
|
|
21
|
-
expect(svg).toContain('stroke-dasharray');
|
|
22
|
-
});
|
|
23
|
-
it('should throw on invalid graphviz source', async () => {
|
|
24
|
-
const source = 'invalid graph {';
|
|
25
|
-
await expect(renderGraphviz(source)).rejects.toThrow();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('renderD2', () => {
|
|
29
|
-
it('should render a simple d2 diagram with options', async () => {
|
|
30
|
-
const source = 'x -> y';
|
|
31
|
-
const result = await renderD2(source, {
|
|
32
|
-
format: 'svg',
|
|
33
|
-
layout: 'dagre',
|
|
34
|
-
theme: 1,
|
|
35
|
-
darkTheme: 200,
|
|
36
|
-
pad: 20,
|
|
37
|
-
sketch: true,
|
|
38
|
-
center: true,
|
|
39
|
-
animateInterval: 1000,
|
|
40
|
-
noXmlTag: true,
|
|
41
|
-
salt: 'test',
|
|
42
|
-
omitVersion: true,
|
|
43
|
-
target: '*',
|
|
44
|
-
scale: 0.5,
|
|
45
|
-
});
|
|
46
|
-
const svg = new TextDecoder().decode(result);
|
|
47
|
-
expect(svg).toContain('<svg');
|
|
48
|
-
});
|
|
49
|
-
it('should throw on invalid d2 source', async () => {
|
|
50
|
-
const source = 'invalid {';
|
|
51
|
-
await expect(renderD2(source)).rejects.toThrow();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe('renderTypst', () => {
|
|
55
|
-
it('should render a simple typst document with options', async () => {
|
|
56
|
-
const source = 'Hello World';
|
|
57
|
-
const result = await renderTypst(source, {
|
|
58
|
-
format: 'svg',
|
|
59
|
-
ppi: 300,
|
|
60
|
-
pages: ['1', { from: 1, to: 1 }],
|
|
61
|
-
ignoreSystemFonts: true,
|
|
62
|
-
creationTimestamp: Date.now(),
|
|
63
|
-
root: '/',
|
|
64
|
-
fontPaths: ['/tmp'],
|
|
65
|
-
pdfStandard: '1.7',
|
|
66
|
-
});
|
|
67
|
-
const svg = new TextDecoder().decode(result);
|
|
68
|
-
expect(svg).toContain('<svg');
|
|
69
|
-
expect(svg).toContain('typst-text');
|
|
70
|
-
});
|
|
71
|
-
it('should render to docx (via pandoc) with options', async () => {
|
|
72
|
-
const source = 'Hello World';
|
|
73
|
-
// pandoc --from typst --to docx --output - -
|
|
74
|
-
const result = await renderTypst(source, {
|
|
75
|
-
format: 'docx',
|
|
76
|
-
docxReferenceFile: undefined, // Testing the branch
|
|
77
|
-
});
|
|
78
|
-
expect(result).toBeInstanceOf(Uint8Array);
|
|
79
|
-
// Docx is a zip file, it should start with PK
|
|
80
|
-
expect(result[0]).toBe(0x50); // P
|
|
81
|
-
expect(result[1]).toBe(0x4B); // K
|
|
82
|
-
});
|
|
83
|
-
it('should throw on invalid typst source', async () => {
|
|
84
|
-
const source = '#invalid_func()';
|
|
85
|
-
await expect(renderTypst(source)).rejects.toThrow();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|