@tstdl/base 0.93.178 → 0.93.180
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/response.js +4 -3
- package/api/server/gateway.js +9 -3
- package/audit/auditor.d.ts +1 -2
- package/audit/drizzle/{0000_lumpy_thunderball.sql → 0000_shallow_elektra.sql} +1 -1
- package/audit/drizzle/meta/0000_snapshot.json +2 -2
- package/audit/drizzle/meta/_journal.json +2 -2
- package/authentication/README.md +87 -42
- package/authentication/authentication.api.d.ts +392 -53
- package/authentication/authentication.api.js +133 -28
- package/authentication/client/api.client.d.ts +3 -3
- package/authentication/client/api.client.js +4 -4
- package/authentication/client/authentication.service.d.ts +93 -23
- package/authentication/client/authentication.service.js +113 -28
- package/authentication/client/http-client.middleware.d.ts +1 -1
- package/authentication/client/http-client.middleware.js +5 -4
- package/authentication/client/module.d.ts +1 -1
- package/authentication/client/module.js +2 -2
- package/authentication/errors/index.d.ts +1 -1
- package/authentication/errors/index.js +1 -1
- package/authentication/errors/password-requirements.error.d.ts +5 -0
- package/authentication/errors/{secret-requirements.error.js → password-requirements.error.js} +2 -2
- package/authentication/models/authentication-password.model.d.ts +8 -0
- package/authentication/models/{authentication-credentials.model.js → authentication-password.model.js} +11 -17
- package/authentication/models/authentication-session.model.d.ts +0 -2
- package/authentication/models/authentication-session.model.js +1 -7
- package/authentication/models/authentication-totp-recovery-code.model.d.ts +6 -0
- package/authentication/models/authentication-totp-recovery-code.model.js +34 -0
- package/authentication/models/authentication-totp.model.d.ts +19 -0
- package/authentication/models/authentication-totp.model.js +51 -0
- package/authentication/models/authentication-used-totp-token.model.d.ts +5 -0
- package/authentication/models/authentication-used-totp-token.model.js +32 -0
- package/authentication/models/index.d.ts +6 -3
- package/authentication/models/index.js +6 -3
- package/authentication/models/{init-secret-reset-data.model.d.ts → init-password-reset-data.model.d.ts} +3 -3
- package/authentication/models/{init-secret-reset-data.model.js → init-password-reset-data.model.js} +5 -5
- package/authentication/models/password-check-result.model.d.ts +3 -0
- package/authentication/models/{secret-check-result.model.js → password-check-result.model.js} +6 -6
- package/authentication/models/subject.model.d.ts +0 -6
- package/authentication/models/subject.model.js +0 -6
- package/authentication/models/token.model.d.ts +16 -2
- package/authentication/server/authentication-ancillary.service.d.ts +6 -6
- package/authentication/server/authentication-ancillary.service.js +1 -1
- package/authentication/server/authentication-password-requirements.validator.d.ts +55 -0
- package/authentication/server/{authentication-secret-requirements.validator.js → authentication-password-requirements.validator.js} +22 -22
- package/authentication/server/authentication.api-controller.d.ts +55 -27
- package/authentication/server/authentication.api-controller.js +214 -39
- package/authentication/server/authentication.audit.d.ts +42 -5
- package/authentication/server/authentication.service.d.ts +182 -93
- package/authentication/server/authentication.service.js +628 -206
- package/authentication/server/drizzle/{0000_soft_tag.sql → 0000_odd_echo.sql} +59 -13
- package/authentication/server/drizzle/meta/0000_snapshot.json +345 -32
- package/authentication/server/drizzle/meta/_journal.json +2 -2
- package/authentication/server/helper.d.ts +16 -16
- package/authentication/server/helper.js +33 -34
- package/authentication/server/index.d.ts +1 -1
- package/authentication/server/index.js +1 -1
- package/authentication/server/module.d.ts +2 -2
- package/authentication/server/module.js +4 -2
- package/authentication/server/schemas.d.ts +11 -7
- package/authentication/server/schemas.js +7 -3
- package/authentication/tests/authentication-password-requirements.validator.test.js +29 -0
- package/authentication/tests/authentication.api-controller.test.js +49 -15
- package/authentication/tests/authentication.client-error-handling.test.js +3 -2
- package/authentication/tests/authentication.client-middleware.test.js +5 -5
- package/authentication/tests/authentication.client-service-methods.test.js +28 -14
- package/authentication/tests/authentication.client-service-refresh.test.js +7 -6
- package/authentication/tests/authentication.client-service.test.js +10 -8
- package/authentication/tests/authentication.service.test.js +37 -29
- package/authentication/tests/authentication.test-ancillary-service.d.ts +1 -1
- package/authentication/tests/authentication.test-ancillary-service.js +1 -1
- package/authentication/tests/brute-force-protection.test.js +211 -0
- package/authentication/tests/helper.test.js +25 -21
- package/authentication/tests/password-requirements.error.test.js +14 -0
- package/authentication/tests/remember.api.test.js +22 -14
- package/authentication/tests/remember.service.test.js +23 -16
- package/authentication/tests/subject.service.test.js +2 -2
- package/authentication/tests/suspended-subject.test.d.ts +1 -0
- package/authentication/tests/suspended-subject.test.js +120 -0
- package/authentication/tests/totp.enrollment.test.d.ts +1 -0
- package/authentication/tests/totp.enrollment.test.js +123 -0
- package/authentication/tests/totp.login.test.d.ts +1 -0
- package/authentication/tests/totp.login.test.js +213 -0
- package/authentication/tests/totp.recovery-codes.test.d.ts +1 -0
- package/authentication/tests/totp.recovery-codes.test.js +97 -0
- package/authentication/tests/totp.status.test.d.ts +1 -0
- package/authentication/tests/totp.status.test.js +72 -0
- package/circuit-breaker/postgres/drizzle/{0000_cooing_korath.sql → 0000_same_captain_cross.sql} +1 -1
- package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +2 -2
- package/circuit-breaker/postgres/drizzle/meta/_journal.json +2 -2
- package/cryptography/cryptography.d.ts +336 -0
- package/cryptography/cryptography.js +328 -0
- package/cryptography/index.d.ts +4 -0
- package/cryptography/index.js +4 -0
- package/{utils → cryptography}/jwt.d.ts +22 -4
- package/{utils → cryptography}/jwt.js +36 -18
- package/cryptography/module.d.ts +35 -0
- package/cryptography/module.js +148 -0
- package/cryptography/tests/cryptography.test.d.ts +1 -0
- package/cryptography/tests/cryptography.test.js +175 -0
- package/cryptography/tests/jwt.test.d.ts +1 -0
- package/cryptography/tests/jwt.test.js +54 -0
- package/cryptography/tests/modern.test.d.ts +1 -0
- package/cryptography/tests/modern.test.js +105 -0
- package/cryptography/tests/module.test.d.ts +1 -0
- package/cryptography/tests/module.test.js +100 -0
- package/cryptography/tests/totp.test.d.ts +1 -0
- package/cryptography/tests/totp.test.js +108 -0
- package/cryptography/totp.d.ts +96 -0
- package/cryptography/totp.js +123 -0
- package/document-management/server/drizzle/{0000_curious_nighthawk.sql → 0000_sharp_scream.sql} +21 -21
- package/document-management/server/drizzle/meta/0000_snapshot.json +22 -22
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/document-management/server/services/document-file.service.js +1 -1
- package/errors/errors.localization.d.ts +2 -2
- package/errors/errors.localization.js +2 -2
- package/errors/index.d.ts +1 -0
- package/errors/index.js +1 -0
- package/errors/too-many-requests.error.d.ts +5 -0
- package/errors/too-many-requests.error.js +7 -0
- package/examples/api/authentication.js +5 -5
- package/examples/api/custom-authentication.js +4 -3
- package/file/server/mime-type.js +1 -1
- package/http/http-body.d.ts +1 -0
- package/http/http-body.js +3 -0
- package/image-service/imgproxy/imgproxy-image-service.d.ts +0 -1
- package/image-service/imgproxy/imgproxy-image-service.js +9 -27
- package/key-value-store/postgres/drizzle/{0000_shocking_slipstream.sql → 0000_moaning_calypso.sql} +1 -1
- package/key-value-store/postgres/drizzle/meta/0000_snapshot.json +2 -2
- package/key-value-store/postgres/drizzle/meta/_journal.json +2 -2
- package/lock/postgres/drizzle/{0000_busy_tattoo.sql → 0000_nappy_wraith.sql} +1 -1
- package/lock/postgres/drizzle/meta/0000_snapshot.json +2 -2
- package/lock/postgres/drizzle/meta/_journal.json +2 -2
- package/logger/formatters/json.js +1 -1
- package/logger/formatters/pretty-print.js +1 -1
- package/mail/drizzle/{0000_numerous_the_watchers.sql → 0000_cultured_quicksilver.sql} +2 -2
- package/mail/drizzle/meta/0000_snapshot.json +4 -4
- package/mail/drizzle/meta/_journal.json +2 -9
- package/notification/server/drizzle/{0000_wise_pyro.sql → 0000_new_tenebrous.sql} +6 -6
- package/notification/server/drizzle/meta/0000_snapshot.json +7 -7
- package/notification/server/drizzle/meta/_journal.json +2 -2
- package/notification/tests/notification-flow.test.js +1 -8
- package/notification/tests/notification-type.service.test.js +3 -3
- package/openid-connect/oidc.service.js +2 -3
- package/orm/data-types/common.js +1 -1
- package/orm/server/drizzle/schema-converter.js +9 -4
- package/orm/server/encryption.js +1 -1
- package/orm/server/module.d.ts +0 -1
- package/orm/server/module.js +0 -4
- package/orm/server/repository.d.ts +2 -1
- package/orm/server/repository.js +7 -10
- package/orm/tests/encryption.test.js +4 -6
- package/orm/tests/repository-extra-coverage.test.js +0 -2
- package/orm/tests/repository-regression.test.js +0 -3
- package/package.json +9 -8
- package/password/README.md +1 -1
- package/password/have-i-been-pwned.js +1 -1
- package/rate-limit/postgres/drizzle/{0000_watery_rage.sql → 0000_serious_sauron.sql} +1 -1
- package/rate-limit/postgres/drizzle/meta/0000_snapshot.json +2 -2
- package/rate-limit/postgres/drizzle/meta/_journal.json +2 -2
- package/rate-limit/postgres/postgres-rate-limiter.d.ts +1 -1
- package/rate-limit/postgres/postgres-rate-limiter.js +1 -1
- package/rate-limit/rate-limiter.d.ts +1 -1
- package/rpc/tests/rpc.integration.test.js +25 -31
- package/supports.d.ts +1 -0
- package/supports.js +1 -0
- package/task-queue/postgres/drizzle/{0000_faithful_daimon_hellstrom.sql → 0000_dark_ronan.sql} +5 -5
- package/task-queue/postgres/drizzle/meta/0000_snapshot.json +10 -10
- package/task-queue/postgres/drizzle/meta/_journal.json +2 -9
- package/task-queue/postgres/task-queue.js +2 -2
- package/task-queue/tests/coverage-enhancement.test.js +2 -2
- package/test/drizzle/{0000_natural_cannonball.sql → 0000_organic_gamora.sql} +2 -2
- package/test/drizzle/meta/0000_snapshot.json +3 -4
- package/test/drizzle/meta/_journal.json +2 -9
- package/testing/integration-setup.d.ts +7 -3
- package/testing/integration-setup.js +119 -96
- package/utils/alphabet.d.ts +1 -0
- package/utils/alphabet.js +1 -0
- package/utils/base32.d.ts +4 -0
- package/utils/base32.js +49 -0
- package/utils/base64.d.ts +0 -2
- package/utils/base64.js +6 -70
- package/utils/equals.d.ts +13 -3
- package/utils/equals.js +29 -9
- package/utils/index.d.ts +1 -2
- package/utils/index.js +1 -2
- package/utils/random.d.ts +1 -0
- package/utils/random.js +14 -8
- package/authentication/errors/secret-requirements.error.d.ts +0 -5
- package/authentication/models/authentication-credentials.model.d.ts +0 -10
- package/authentication/models/secret-check-result.model.d.ts +0 -3
- package/authentication/server/authentication-secret-requirements.validator.d.ts +0 -55
- package/authentication/tests/authentication-ancillary.service.test.js +0 -13
- package/authentication/tests/authentication-secret-requirements.validator.test.js +0 -29
- package/authentication/tests/secret-requirements.error.test.js +0 -14
- package/mail/drizzle/0001_married_tarantula.sql +0 -12
- package/mail/drizzle/meta/0001_snapshot.json +0 -69
- package/orm/server/tokens.d.ts +0 -1
- package/orm/server/tokens.js +0 -2
- package/task-queue/postgres/drizzle/0001_rapid_infant_terrible.sql +0 -16
- package/task-queue/postgres/drizzle/meta/0001_snapshot.json +0 -753
- package/test/drizzle/0001_closed_the_captain.sql +0 -2
- package/test/drizzle/meta/0001_snapshot.json +0 -117
- package/utils/cryptography.d.ts +0 -137
- package/utils/cryptography.js +0 -201
- /package/authentication/tests/{authentication-ancillary.service.test.d.ts → authentication-password-requirements.validator.test.d.ts} +0 -0
- /package/authentication/tests/{authentication-secret-requirements.validator.test.d.ts → brute-force-protection.test.d.ts} +0 -0
- /package/authentication/tests/{secret-requirements.error.test.d.ts → password-requirements.error.test.d.ts} +0 -0
|
@@ -3,8 +3,9 @@ import { NotFoundError } from '../../errors/not-found.error.js';
|
|
|
3
3
|
import { NotImplementedError } from '../../errors/not-implemented.error.js';
|
|
4
4
|
import { NotSupportedError } from '../../errors/not-supported.error.js';
|
|
5
5
|
import { internal } from '../../internal.js';
|
|
6
|
-
import { registerSerializer } from '../../serializer/index.js';
|
|
6
|
+
import { registerSerializer, serialize } from '../../serializer/index.js';
|
|
7
7
|
import { afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
8
|
+
import { defaultReadableStreamRpcAdapter } from '../adapters/readable-stream.adapter.js';
|
|
8
9
|
import { MessagePortRpcEndpoint } from '../endpoints/message-port.rpc-endpoint.js';
|
|
9
10
|
import { RpcConnectionClosedError, RpcRemoteError } from '../rpc.error.js';
|
|
10
11
|
import { Rpc } from '../rpc.js';
|
|
@@ -27,7 +28,6 @@ describe('Rpc Integration', () => {
|
|
|
27
28
|
Rpc.reset();
|
|
28
29
|
});
|
|
29
30
|
beforeAll(async () => {
|
|
30
|
-
const { defaultReadableStreamRpcAdapter } = await import('../adapters/readable-stream.adapter.js');
|
|
31
31
|
try {
|
|
32
32
|
Rpc.registerAdapter(defaultReadableStreamRpcAdapter);
|
|
33
33
|
}
|
|
@@ -71,7 +71,7 @@ describe('Rpc Integration', () => {
|
|
|
71
71
|
},
|
|
72
72
|
greet(name) {
|
|
73
73
|
return `Hello, ${name}!`;
|
|
74
|
-
}
|
|
74
|
+
},
|
|
75
75
|
};
|
|
76
76
|
Rpc.expose(target, 'test-service-1');
|
|
77
77
|
Rpc.listen(serverEndpoint);
|
|
@@ -90,8 +90,8 @@ describe('Rpc Integration', () => {
|
|
|
90
90
|
const target = {
|
|
91
91
|
version: '1.0.0',
|
|
92
92
|
config: {
|
|
93
|
-
enabled: true
|
|
94
|
-
}
|
|
93
|
+
enabled: true,
|
|
94
|
+
},
|
|
95
95
|
};
|
|
96
96
|
Rpc.expose(target, 'test-service-2');
|
|
97
97
|
Rpc.listen(serverEndpoint);
|
|
@@ -106,7 +106,7 @@ describe('Rpc Integration', () => {
|
|
|
106
106
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
107
107
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
108
108
|
const target = {
|
|
109
|
-
value: 0
|
|
109
|
+
value: 0,
|
|
110
110
|
};
|
|
111
111
|
Rpc.expose(target, 'test-service-3');
|
|
112
112
|
Rpc.listen(serverEndpoint);
|
|
@@ -124,7 +124,7 @@ describe('Rpc Integration', () => {
|
|
|
124
124
|
const target = {
|
|
125
125
|
fail() {
|
|
126
126
|
throw new MyAppError('Operation failed', 500);
|
|
127
|
-
}
|
|
127
|
+
},
|
|
128
128
|
};
|
|
129
129
|
Rpc.expose(target, 'test-service-4');
|
|
130
130
|
Rpc.listen(serverEndpoint);
|
|
@@ -160,7 +160,7 @@ describe('Rpc Integration', () => {
|
|
|
160
160
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
161
161
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
162
162
|
const target = {
|
|
163
|
-
foo: 'bar'
|
|
163
|
+
foo: 'bar',
|
|
164
164
|
};
|
|
165
165
|
Rpc.expose(target, 'test-service-6');
|
|
166
166
|
Rpc.listen(serverEndpoint);
|
|
@@ -180,7 +180,7 @@ describe('Rpc Integration', () => {
|
|
|
180
180
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
181
181
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
182
182
|
const target = {
|
|
183
|
-
foo: 'bar'
|
|
183
|
+
foo: 'bar',
|
|
184
184
|
};
|
|
185
185
|
Rpc.expose(target, 'test-service-helpers');
|
|
186
186
|
Rpc.listen(serverEndpoint);
|
|
@@ -202,12 +202,12 @@ describe('Rpc Integration', () => {
|
|
|
202
202
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
203
203
|
const nested = {
|
|
204
204
|
id: 'nested-1',
|
|
205
|
-
async getValue() { return 'val'; }
|
|
205
|
+
async getValue() { return 'val'; },
|
|
206
206
|
};
|
|
207
207
|
const target = {
|
|
208
208
|
getNested() {
|
|
209
209
|
return Rpc.proxy(nested, target);
|
|
210
|
-
}
|
|
210
|
+
},
|
|
211
211
|
};
|
|
212
212
|
Rpc.expose(target, 'test-nested-root');
|
|
213
213
|
Rpc.listen(serverEndpoint);
|
|
@@ -226,7 +226,7 @@ describe('Rpc Integration', () => {
|
|
|
226
226
|
async sum(buffer) {
|
|
227
227
|
const view = new Uint8Array(buffer);
|
|
228
228
|
return view.reduce((a, b) => a + b, 0);
|
|
229
|
-
}
|
|
229
|
+
},
|
|
230
230
|
};
|
|
231
231
|
Rpc.expose(target, 'test-transfer');
|
|
232
232
|
Rpc.listen(serverEndpoint);
|
|
@@ -242,7 +242,6 @@ describe('Rpc Integration', () => {
|
|
|
242
242
|
const { port1, port2 } = new MessageChannel();
|
|
243
243
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
244
244
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
245
|
-
const { defaultReadableStreamRpcAdapter } = await import('../adapters/readable-stream.adapter.js');
|
|
246
245
|
const target = {
|
|
247
246
|
async getStream() {
|
|
248
247
|
const stream = new ReadableStream({
|
|
@@ -251,10 +250,10 @@ describe('Rpc Integration', () => {
|
|
|
251
250
|
controller.enqueue(2);
|
|
252
251
|
controller.enqueue(3);
|
|
253
252
|
controller.close();
|
|
254
|
-
}
|
|
253
|
+
},
|
|
255
254
|
});
|
|
256
255
|
return Rpc.adapt(stream, defaultReadableStreamRpcAdapter);
|
|
257
|
-
}
|
|
256
|
+
},
|
|
258
257
|
};
|
|
259
258
|
Rpc.expose(target, 'test-stream');
|
|
260
259
|
Rpc.listen(serverEndpoint);
|
|
@@ -353,15 +352,15 @@ describe('Rpc Integration', () => {
|
|
|
353
352
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
354
353
|
const nested = {
|
|
355
354
|
id: 'nested',
|
|
356
|
-
async getValue() { return 'val'; }
|
|
355
|
+
async getValue() { return 'val'; },
|
|
357
356
|
};
|
|
358
357
|
const target = {
|
|
359
358
|
getData() {
|
|
360
359
|
return Rpc.serialize({
|
|
361
360
|
info: 'some info',
|
|
362
|
-
item: Rpc.proxy(nested)
|
|
361
|
+
item: Rpc.proxy(nested),
|
|
363
362
|
});
|
|
364
|
-
}
|
|
363
|
+
},
|
|
365
364
|
};
|
|
366
365
|
Rpc.expose(target, 'test-complex-serialization');
|
|
367
366
|
Rpc.listen(serverEndpoint);
|
|
@@ -380,7 +379,7 @@ describe('Rpc Integration', () => {
|
|
|
380
379
|
const target = {
|
|
381
380
|
fail() {
|
|
382
381
|
throw 'String error';
|
|
383
|
-
}
|
|
382
|
+
},
|
|
384
383
|
};
|
|
385
384
|
Rpc.expose(target, 'test-string-error');
|
|
386
385
|
Rpc.listen(serverEndpoint);
|
|
@@ -400,7 +399,6 @@ describe('Rpc Integration', () => {
|
|
|
400
399
|
const { port1, port2 } = new MessageChannel();
|
|
401
400
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
402
401
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
403
|
-
const { defaultReadableStreamRpcAdapter } = await import('../adapters/readable-stream.adapter.js');
|
|
404
402
|
let cancelled = false;
|
|
405
403
|
let cancelReason;
|
|
406
404
|
const target = {
|
|
@@ -409,10 +407,10 @@ describe('Rpc Integration', () => {
|
|
|
409
407
|
cancel(reason) {
|
|
410
408
|
cancelled = true;
|
|
411
409
|
cancelReason = reason;
|
|
412
|
-
}
|
|
410
|
+
},
|
|
413
411
|
});
|
|
414
412
|
return Rpc.adapt(stream, defaultReadableStreamRpcAdapter);
|
|
415
|
-
}
|
|
413
|
+
},
|
|
416
414
|
};
|
|
417
415
|
Rpc.expose(target, 'test-stream-cancel');
|
|
418
416
|
Rpc.listen(serverEndpoint);
|
|
@@ -431,12 +429,12 @@ describe('Rpc Integration', () => {
|
|
|
431
429
|
const fakeAdapter = {
|
|
432
430
|
name: 'Fake',
|
|
433
431
|
adaptSource: () => ({ data: undefined }),
|
|
434
|
-
adaptTarget: () => ({})
|
|
432
|
+
adaptTarget: () => ({}),
|
|
435
433
|
};
|
|
436
434
|
const target2 = {
|
|
437
435
|
getFake() {
|
|
438
436
|
return Rpc.adapt({}, fakeAdapter);
|
|
439
|
-
}
|
|
437
|
+
},
|
|
440
438
|
};
|
|
441
439
|
Rpc.expose(target2, 'test-fake-adapter');
|
|
442
440
|
Rpc.listen(serverEndpoint);
|
|
@@ -460,7 +458,7 @@ describe('Rpc Integration', () => {
|
|
|
460
458
|
removeEventListener: () => { },
|
|
461
459
|
start: () => { },
|
|
462
460
|
close: () => { },
|
|
463
|
-
postMessage: () => { }
|
|
461
|
+
postMessage: () => { },
|
|
464
462
|
};
|
|
465
463
|
const MockSharedWorker = class {
|
|
466
464
|
port = mockPort;
|
|
@@ -512,7 +510,6 @@ describe('Rpc Integration', () => {
|
|
|
512
510
|
const { port1, port2 } = new MessageChannel();
|
|
513
511
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
514
512
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
515
|
-
const { defaultReadableStreamRpcAdapter } = await import('../adapters/readable-stream.adapter.js');
|
|
516
513
|
const stream = new ReadableStream();
|
|
517
514
|
const root = { stream: Rpc.adapt(stream, defaultReadableStreamRpcAdapter, stream) };
|
|
518
515
|
Rpc.expose(root, 'test-adapt-root');
|
|
@@ -523,7 +520,6 @@ describe('Rpc Integration', () => {
|
|
|
523
520
|
clientEndpoint.close();
|
|
524
521
|
});
|
|
525
522
|
it('should throw when serializing a marked rpc proxy directly', async () => {
|
|
526
|
-
const { serialize } = await import('../../serializer/index.js');
|
|
527
523
|
const proxyInstance = new Rpc[internal].RpcProxy();
|
|
528
524
|
expect(() => serialize(proxyInstance)).toThrow(NotSupportedError);
|
|
529
525
|
});
|
|
@@ -534,7 +530,7 @@ describe('Rpc Integration', () => {
|
|
|
534
530
|
const adapter = {
|
|
535
531
|
name: 'test-serialize-adapt',
|
|
536
532
|
adaptSource: () => ({ data: 'some-data', transfer: [] }),
|
|
537
|
-
adaptTarget: (data) => ({ deserializedData: data })
|
|
533
|
+
adaptTarget: (data) => ({ deserializedData: data }),
|
|
538
534
|
};
|
|
539
535
|
Rpc.registerAdapter(adapter);
|
|
540
536
|
const target = {
|
|
@@ -542,7 +538,7 @@ describe('Rpc Integration', () => {
|
|
|
542
538
|
const obj = {};
|
|
543
539
|
Rpc.adapt(obj, adapter);
|
|
544
540
|
return Rpc.serialize(obj);
|
|
545
|
-
}
|
|
541
|
+
},
|
|
546
542
|
};
|
|
547
543
|
Rpc.expose(target, 'test-serialize-adapt-service');
|
|
548
544
|
Rpc.listen(serverEndpoint);
|
|
@@ -556,7 +552,6 @@ describe('Rpc Integration', () => {
|
|
|
556
552
|
const { port1, port2 } = new MessageChannel();
|
|
557
553
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
558
554
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
559
|
-
const { defaultReadableStreamRpcAdapter } = await import('../adapters/readable-stream.adapter.js');
|
|
560
555
|
const stream = new ReadableStream();
|
|
561
556
|
const channel = serverEndpoint.openChannel();
|
|
562
557
|
defaultReadableStreamRpcAdapter.adaptSource(stream, channel);
|
|
@@ -577,7 +572,6 @@ describe('Rpc Integration', () => {
|
|
|
577
572
|
const { port1, port2 } = new MessageChannel();
|
|
578
573
|
const serverEndpoint = new MessagePortRpcEndpoint(port1);
|
|
579
574
|
const clientEndpoint = new MessagePortRpcEndpoint(port2);
|
|
580
|
-
const { defaultReadableStreamRpcAdapter } = await import('../adapters/readable-stream.adapter.js');
|
|
581
575
|
const channel = serverEndpoint.openChannel();
|
|
582
576
|
const stream = defaultReadableStreamRpcAdapter.adaptTarget(undefined, channel);
|
|
583
577
|
const clientChannel = clientEndpoint.getChannel(channel.id);
|
package/supports.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export declare const supportsBlob: boolean;
|
|
|
3
3
|
export declare const supportsBuffer: boolean;
|
|
4
4
|
export declare const supportsStructuredClone: boolean;
|
|
5
5
|
export declare const supportsNotification: boolean;
|
|
6
|
+
export declare const supportsCookies: boolean;
|
|
6
7
|
export declare const supportsColoredStdout: boolean;
|
|
7
8
|
export declare const supportsColoredStderr: boolean;
|
package/supports.js
CHANGED
|
@@ -3,5 +3,6 @@ export const supportsBlob = (typeof Blob == 'function');
|
|
|
3
3
|
export const supportsBuffer = (typeof Buffer == 'function');
|
|
4
4
|
export const supportsStructuredClone = (typeof structuredClone == 'function');
|
|
5
5
|
export const supportsNotification = (typeof Notification == 'function');
|
|
6
|
+
export const supportsCookies = (typeof navigator == 'object' && navigator.cookieEnabled == true);
|
|
6
7
|
export const supportsColoredStdout = (typeof process == 'object' && (process.stdout.hasColors?.() ?? false));
|
|
7
8
|
export const supportsColoredStderr = (typeof process == 'object' && (process.stderr.hasColors?.() ?? false));
|
package/task-queue/postgres/drizzle/{0000_faithful_daimon_hellstrom.sql → 0000_dark_ronan.sql}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
CREATE TYPE "task_queue"."task_dependency_type" AS ENUM('schedule', 'complete', 'child');--> statement-breakpoint
|
|
2
2
|
CREATE TYPE "task_queue"."task_status" AS ENUM('pending', 'running', 'completed', 'cancelled', 'dead', 'waiting', 'waiting-children', 'paused', 'retrying', 'timed-out', 'expired', 'skipped', 'orphaned');--> statement-breakpoint
|
|
3
3
|
CREATE TABLE "task_queue"."task" (
|
|
4
|
-
"id" uuid PRIMARY KEY DEFAULT
|
|
4
|
+
"id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
|
|
5
5
|
"namespace" text NOT NULL,
|
|
6
6
|
"type" text NOT NULL,
|
|
7
7
|
"status" "task_queue"."task_status" NOT NULL,
|
|
@@ -26,12 +26,12 @@ CREATE TABLE "task_queue"."task" (
|
|
|
26
26
|
"data" jsonb,
|
|
27
27
|
"state" jsonb,
|
|
28
28
|
"result" jsonb,
|
|
29
|
-
"
|
|
29
|
+
"errors" jsonb NOT NULL,
|
|
30
30
|
CONSTRAINT "task_namespace_idempotency_key_unique" UNIQUE("namespace","idempotency_key")
|
|
31
31
|
);
|
|
32
32
|
--> statement-breakpoint
|
|
33
33
|
CREATE TABLE "task_queue"."task_archive" (
|
|
34
|
-
"id" uuid PRIMARY KEY DEFAULT
|
|
34
|
+
"id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
|
|
35
35
|
"namespace" text NOT NULL,
|
|
36
36
|
"type" text NOT NULL,
|
|
37
37
|
"status" "task_queue"."task_status" NOT NULL,
|
|
@@ -56,11 +56,11 @@ CREATE TABLE "task_queue"."task_archive" (
|
|
|
56
56
|
"data" jsonb,
|
|
57
57
|
"state" jsonb,
|
|
58
58
|
"result" jsonb,
|
|
59
|
-
"
|
|
59
|
+
"errors" jsonb NOT NULL
|
|
60
60
|
);
|
|
61
61
|
--> statement-breakpoint
|
|
62
62
|
CREATE TABLE "task_queue"."task_dependency" (
|
|
63
|
-
"id" uuid PRIMARY KEY DEFAULT
|
|
63
|
+
"id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
|
|
64
64
|
"task_id" uuid NOT NULL,
|
|
65
65
|
"dependency_task_id" uuid NOT NULL,
|
|
66
66
|
"type" "task_queue"."task_dependency_type" NOT NULL,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "037764bd-71ff-483e-ac54-83bf3d31166a",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"type": "uuid",
|
|
14
14
|
"primaryKey": true,
|
|
15
15
|
"notNull": true,
|
|
16
|
-
"default": "
|
|
16
|
+
"default": "uuidv7()"
|
|
17
17
|
},
|
|
18
18
|
"namespace": {
|
|
19
19
|
"name": "namespace",
|
|
@@ -160,11 +160,11 @@
|
|
|
160
160
|
"primaryKey": false,
|
|
161
161
|
"notNull": false
|
|
162
162
|
},
|
|
163
|
-
"
|
|
164
|
-
"name": "
|
|
163
|
+
"errors": {
|
|
164
|
+
"name": "errors",
|
|
165
165
|
"type": "jsonb",
|
|
166
166
|
"primaryKey": false,
|
|
167
|
-
"notNull":
|
|
167
|
+
"notNull": true
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
170
|
"indexes": {
|
|
@@ -418,7 +418,7 @@
|
|
|
418
418
|
"type": "uuid",
|
|
419
419
|
"primaryKey": true,
|
|
420
420
|
"notNull": true,
|
|
421
|
-
"default": "
|
|
421
|
+
"default": "uuidv7()"
|
|
422
422
|
},
|
|
423
423
|
"namespace": {
|
|
424
424
|
"name": "namespace",
|
|
@@ -565,11 +565,11 @@
|
|
|
565
565
|
"primaryKey": false,
|
|
566
566
|
"notNull": false
|
|
567
567
|
},
|
|
568
|
-
"
|
|
569
|
-
"name": "
|
|
568
|
+
"errors": {
|
|
569
|
+
"name": "errors",
|
|
570
570
|
"type": "jsonb",
|
|
571
571
|
"primaryKey": false,
|
|
572
|
-
"notNull":
|
|
572
|
+
"notNull": true
|
|
573
573
|
}
|
|
574
574
|
},
|
|
575
575
|
"indexes": {
|
|
@@ -611,7 +611,7 @@
|
|
|
611
611
|
"type": "uuid",
|
|
612
612
|
"primaryKey": true,
|
|
613
613
|
"notNull": true,
|
|
614
|
-
"default": "
|
|
614
|
+
"default": "uuidv7()"
|
|
615
615
|
},
|
|
616
616
|
"task_id": {
|
|
617
617
|
"name": "task_id",
|
|
@@ -5,15 +5,8 @@
|
|
|
5
5
|
{
|
|
6
6
|
"idx": 0,
|
|
7
7
|
"version": "7",
|
|
8
|
-
"when":
|
|
9
|
-
"tag": "
|
|
10
|
-
"breakpoints": true
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"idx": 1,
|
|
14
|
-
"version": "7",
|
|
15
|
-
"when": 1774305322701,
|
|
16
|
-
"tag": "0001_rapid_infant_terrible",
|
|
8
|
+
"when": 1774646421355,
|
|
9
|
+
"tag": "0000_dark_ronan",
|
|
17
10
|
"breakpoints": true
|
|
18
11
|
}
|
|
19
12
|
]
|
|
@@ -64,7 +64,7 @@ import { NotFoundError, serializeError, TimeoutError } from '../../errors/index.
|
|
|
64
64
|
import { afterResolve, inject, provide, Singleton } from '../../injector/index.js';
|
|
65
65
|
import { Logger } from '../../logger/index.js';
|
|
66
66
|
import { MessageBus } from '../../message-bus/index.js';
|
|
67
|
-
import { arrayOverlaps, buildJsonb, caseWhen, coalesce, enumValue, greatest, interval, least, power,
|
|
67
|
+
import { arrayOverlaps, buildJsonb, caseWhen, coalesce, enumValue, greatest, interval, least, power, RANDOM_UUID_V7, TRANSACTION_TIMESTAMP } from '../../orm/index.js';
|
|
68
68
|
import { DatabaseConfig, injectRepository } from '../../orm/server/index.js';
|
|
69
69
|
import { RateLimiter } from '../../rate-limit/index.js';
|
|
70
70
|
import { distinct, toArray } from '../../utils/array/array.js';
|
|
@@ -662,7 +662,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
662
662
|
.update(taskTable)
|
|
663
663
|
.set({
|
|
664
664
|
status: TaskStatus.Running,
|
|
665
|
-
token:
|
|
665
|
+
token: RANDOM_UUID_V7,
|
|
666
666
|
visibilityDeadline: sql `${TRANSACTION_TIMESTAMP} + ${interval(this.visibilityTimeout, 'milliseconds')}`,
|
|
667
667
|
startTimestamp: TRANSACTION_TIMESTAMP,
|
|
668
668
|
// If it was PENDING, it's the first try (tries=0) -> tries=1.
|
|
@@ -3,7 +3,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
|
3
3
|
import { CancellationToken } from '../../cancellation/index.js';
|
|
4
4
|
import { runInInjectionContext } from '../../injector/index.js';
|
|
5
5
|
import { Logger } from '../../logger/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { RANDOM_UUID_V7 } from '../../orm/index.js';
|
|
7
7
|
import { injectRepository } from '../../orm/server/index.js';
|
|
8
8
|
import { TaskQueueProvider, TaskStatus } from '../../task-queue/index.js';
|
|
9
9
|
import { task as taskTable } from '../../task-queue/postgres/schemas.js';
|
|
@@ -71,7 +71,7 @@ describe('Task Queue Coverage Enhancement', () => {
|
|
|
71
71
|
// Manually break the token in DB
|
|
72
72
|
const repository = runInInjectionContext(injector, () => injectRepository(PostgresTask));
|
|
73
73
|
await repository.useTransaction(undefined, async (tx) => {
|
|
74
|
-
await tx.pgTransaction.update(taskTable).set({ token:
|
|
74
|
+
await tx.pgTransaction.update(taskTable).set({ token: RANDOM_UUID_V7 }).where(eq(taskTable.id, task.id));
|
|
75
75
|
});
|
|
76
76
|
const signal = new CancellationToken();
|
|
77
77
|
const context = new TaskContext(queue, dTask, signal, injector.resolve(Logger));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
CREATE TABLE "test"."test" (
|
|
2
|
-
"id" uuid PRIMARY KEY DEFAULT
|
|
2
|
+
"id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
|
|
3
3
|
"title" text NOT NULL,
|
|
4
4
|
"content" text NOT NULL,
|
|
5
5
|
"tags" text NOT NULL,
|
|
6
6
|
"language" text NOT NULL
|
|
7
7
|
);
|
|
8
8
|
--> statement-breakpoint
|
|
9
|
-
CREATE INDEX "test_parade_idx" ON "test"."test" USING bm25 ("id","language","title","content","tags",(("title" || ' ' || "content" || ' ' || "tags")::pdb.simple('alias=search_text')),(('foo')::pdb.simple('alias=foo'))) WITH (key_field='id'
|
|
9
|
+
CREATE INDEX "test_parade_idx" ON "test"."test" USING bm25 ("id","language","title","content","tags",(("title" || ' ' || "content" || ' ' || "tags")::pdb.simple('alias=search_text')),(('foo')::pdb.simple('alias=foo'))) WITH (key_field='id');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "14846cdd-ba3a-49f5-8bb1-0fc71147d041",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"type": "uuid",
|
|
14
14
|
"primaryKey": true,
|
|
15
15
|
"notNull": true,
|
|
16
|
-
"default": "
|
|
16
|
+
"default": "uuidv7()"
|
|
17
17
|
},
|
|
18
18
|
"title": {
|
|
19
19
|
"name": "title",
|
|
@@ -91,8 +91,7 @@
|
|
|
91
91
|
"concurrently": false,
|
|
92
92
|
"method": "bm25",
|
|
93
93
|
"with": {
|
|
94
|
-
"key_field": "'id'"
|
|
95
|
-
"mutable_segment_rows": 12
|
|
94
|
+
"key_field": "'id'"
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
},
|
|
@@ -5,15 +5,8 @@
|
|
|
5
5
|
{
|
|
6
6
|
"idx": 0,
|
|
7
7
|
"version": "7",
|
|
8
|
-
"when":
|
|
9
|
-
"tag": "
|
|
10
|
-
"breakpoints": true
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"idx": 1,
|
|
14
|
-
"version": "7",
|
|
15
|
-
"when": 1762968768532,
|
|
16
|
-
"tag": "0001_closed_the_captain",
|
|
8
|
+
"when": 1774646423853,
|
|
9
|
+
"tag": "0000_organic_gamora",
|
|
17
10
|
"breakpoints": true
|
|
18
11
|
}
|
|
19
12
|
]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** biome-ignore-all lint/nursery/useExpect: helper file */
|
|
2
2
|
import type { PoolConfig } from 'pg';
|
|
3
3
|
import { type TestOptions } from 'vitest';
|
|
4
|
-
import { type AuthenticationAncillaryService } from '../authentication/server/index.js';
|
|
5
|
-
import { Injector } from '../injector/index.js';
|
|
4
|
+
import { type AuthenticationAncillaryService, type AuthenticationServiceOptions } from '../authentication/server/index.js';
|
|
5
|
+
import { Injector, type ProvidersItem } from '../injector/index.js';
|
|
6
6
|
import { LogLevel } from '../logger/index.js';
|
|
7
7
|
import { type S3ObjectStorageProviderConfig } from '../object-storage/s3/index.js';
|
|
8
8
|
import type { EntityType } from '../orm/entity.js';
|
|
@@ -14,6 +14,10 @@ export type IntegrationTestOptions = {
|
|
|
14
14
|
schema?: string;
|
|
15
15
|
encryptionSecret?: Uint8Array;
|
|
16
16
|
};
|
|
17
|
+
authentication?: {
|
|
18
|
+
ancillaryService?: Type<AuthenticationAncillaryService>;
|
|
19
|
+
options?: AuthenticationServiceOptions;
|
|
20
|
+
};
|
|
17
21
|
api?: {
|
|
18
22
|
baseUrl?: string;
|
|
19
23
|
port?: number;
|
|
@@ -36,7 +40,7 @@ export type IntegrationTestOptions = {
|
|
|
36
40
|
taskQueue?: boolean;
|
|
37
41
|
webServer?: boolean;
|
|
38
42
|
};
|
|
39
|
-
|
|
43
|
+
providers?: ProvidersItem[];
|
|
40
44
|
/**
|
|
41
45
|
* If true, a fresh context will be created and it will be disposed after the test.
|
|
42
46
|
* If false (default), the context is shared across tests with the same options and is NOT disposed automatically.
|