@tstdl/base 0.92.86 → 0.92.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/ai.service.d.ts +3 -3
- package/ai/ai.service.js +24 -11
- package/ai/types.d.ts +4 -3
- package/api/server/gateway.js +1 -1
- package/authentication/server/authentication-ancillary.service.d.ts +6 -4
- package/authentication/server/authentication-ancillary.service.js +5 -5
- package/context/context.d.ts +1 -9
- package/context/context.js +8 -5
- package/document-management/api/document-management.api.d.ts +48 -16
- package/document-management/models/document-category.model.d.ts +1 -1
- package/document-management/models/document-category.model.js +2 -0
- package/document-management/models/document-collection-document.model.js +7 -3
- package/document-management/models/document-property-value.model.d.ts +13 -14
- package/document-management/models/document-property-value.model.js +60 -27
- package/document-management/models/document-property.model.d.ts +2 -0
- package/document-management/models/document-property.model.js +4 -1
- package/document-management/models/document-request-assignment-task-collection.model.d.ts +7 -0
- package/document-management/models/{document-index.model.js → document-request-assignment-task-collection.model.js} +16 -16
- package/document-management/models/document-request-assignment-task.model.d.ts +14 -0
- package/document-management/models/document-request-assignment-task.model.js +72 -0
- package/document-management/models/document-request-collection.model.d.ts +1 -0
- package/document-management/models/document-request-collection.model.js +7 -3
- package/document-management/models/document-request-file.model.d.ts +6 -1
- package/document-management/models/document-request-file.model.js +27 -2
- package/document-management/models/document-request.model.d.ts +1 -0
- package/document-management/models/document-requests-template.js +2 -0
- package/document-management/models/document-type-property.model.js +7 -3
- package/document-management/models/document-type.model.d.ts +1 -1
- package/document-management/models/document-type.model.js +7 -3
- package/document-management/models/document.model.d.ts +4 -1
- package/document-management/models/document.model.js +19 -4
- package/document-management/models/index.d.ts +2 -0
- package/document-management/models/index.js +2 -0
- package/document-management/models/service-models/document.service-model.d.ts +35 -16
- package/document-management/models/service-models/document.service-model.js +11 -6
- package/document-management/models/service-models/document.view-model.d.ts +1 -1
- package/document-management/models/service-models/document.view-model.js +2 -2
- package/document-management/server/drizzle/{0000_useful_overlord.sql → 0000_cool_victor_mancha.sql} +97 -41
- package/document-management/server/drizzle/meta/0000_snapshot.json +514 -126
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/document-management/server/module.d.ts +2 -1
- package/document-management/server/module.js +3 -1
- package/document-management/server/schemas.d.ts +14 -11
- package/document-management/server/schemas.js +13 -10
- package/document-management/server/services/document-management-ancillary.service.d.ts +4 -0
- package/document-management/server/services/document-management-ancillary.service.js +13 -0
- package/document-management/server/services/document-management.service.d.ts +63 -28
- package/document-management/server/services/document-management.service.js +507 -108
- package/document-management/server/services/index.d.ts +1 -0
- package/document-management/server/services/index.js +1 -0
- package/eslint.config.js +1 -0
- package/examples/document-management/main.d.ts +5 -0
- package/examples/document-management/main.js +20 -2
- package/file/index.d.ts +1 -0
- package/file/index.js +1 -0
- package/file/temporary-file.d.ts +17 -0
- package/file/temporary-file.js +49 -0
- package/http/server/http-server-response.d.ts +2 -0
- package/http/server/http-server-response.js +13 -0
- package/injector/index.d.ts +1 -0
- package/injector/index.js +1 -0
- package/injector/injector.js +19 -7
- package/injector/interfaces.d.ts +1 -1
- package/injector/interfaces.js +1 -1
- package/injector/resolution.d.ts +15 -0
- package/injector/resolution.js +6 -0
- package/logger/console/logger.d.ts +1 -1
- package/logger/logger.d.ts +1 -1
- package/object-storage/object-storage.d.ts +5 -7
- package/object-storage/s3/s3.object-storage.d.ts +0 -1
- package/object-storage/s3/s3.object-storage.js +0 -3
- package/orm/{server/data-types → data-types}/numeric-date.js +2 -3
- package/orm/decorators.d.ts +13 -4
- package/orm/decorators.js +13 -7
- package/orm/entity.js +3 -7
- package/orm/index.d.ts +1 -0
- package/orm/index.js +1 -0
- package/orm/server/drizzle/schema-converter.js +48 -19
- package/orm/server/repository.d.ts +5 -4
- package/orm/server/repository.js +33 -22
- package/orm/server/sqls.d.ts +9 -1
- package/orm/server/sqls.js +13 -0
- package/orm/types.d.ts +3 -3
- package/orm/utils.d.ts +3 -0
- package/orm/utils.js +6 -0
- package/package.json +13 -11
- package/pdf/pdf.service.d.ts +0 -1
- package/pdf/pdf.service.js +1 -95
- package/pdf/utils.d.ts +3 -1
- package/pdf/utils.js +129 -4
- package/promise/lazy-promise.d.ts +3 -3
- package/queue/postgres/module.d.ts +1 -1
- package/queue/postgres/queue.js +10 -12
- package/queue/queue.d.ts +14 -0
- package/queue/queue.js +43 -0
- package/utils/date-time.d.ts +4 -2
- package/utils/date-time.js +10 -3
- package/utils/format-error.js +0 -1
- package/utils/object/lazy-property.js +0 -1
- package/utils/try-ignore.d.ts +9 -2
- package/utils/try-ignore.js +30 -6
- package/document-management/models/document-index.model.d.ts +0 -7
- /package/orm/{server/data-types → data-types}/bytea.d.ts +0 -0
- /package/orm/{server/data-types → data-types}/bytea.js +0 -0
- /package/orm/{server/data-types → data-types}/index.d.ts +0 -0
- /package/orm/{server/data-types → data-types}/index.js +0 -0
- /package/orm/{server/data-types → data-types}/numeric-date.d.ts +0 -0
- /package/orm/{server/data-types → data-types}/timestamp.d.ts +0 -0
- /package/orm/{server/data-types → data-types}/timestamp.js +0 -0
package/eslint.config.js
CHANGED
|
@@ -42,6 +42,7 @@ export default [
|
|
|
42
42
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
43
43
|
'@typescript-eslint/no-import-type-side-effects': 'error',
|
|
44
44
|
'@typescript-eslint/no-inferrable-types': ['warn', { ignoreParameters: true, ignoreProperties: true }],
|
|
45
|
+
'@typescript-eslint/no-misused-spread': 'off',
|
|
45
46
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
46
47
|
'@typescript-eslint/no-unnecessary-condition': ['warn', { allowConstantLoopConditions: 'only-allowed-literals', checkTypePredicates: true }],
|
|
47
48
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
import '../../polyfills.js';
|
|
2
|
+
import type { DocumentCollection } from '../../document-management/index.js';
|
|
3
|
+
import { DocumentManagementAncillaryService } from '../../document-management/server/index.js';
|
|
4
|
+
export declare class TestDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
5
|
+
resolveNames(collections: DocumentCollection[]): Promise<string[]>;
|
|
6
|
+
}
|
|
@@ -1,19 +1,37 @@
|
|
|
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
|
+
};
|
|
1
7
|
import '../../polyfills.js';
|
|
2
8
|
import { Application } from '../../application/application.js';
|
|
9
|
+
import { DocumentManagementAncillaryService } from '../../document-management/server/index.js';
|
|
3
10
|
import { configureDocumentManagement, migrateDocumentManagementSchema } from '../../document-management/server/module.js';
|
|
4
11
|
import { DocumentManagementService } from '../../document-management/server/services/document-management.service.js';
|
|
12
|
+
import { Singleton } from '../../injector/index.js';
|
|
5
13
|
import { injectAsync } from '../../injector/inject.js';
|
|
6
14
|
import { configureS3ObjectStorage } from '../../object-storage/index.js';
|
|
15
|
+
let TestDocumentManagementAncillaryService = class TestDocumentManagementAncillaryService extends DocumentManagementAncillaryService {
|
|
16
|
+
async resolveNames(collections) {
|
|
17
|
+
return collections.map((collection) => collection.metadata.attributes['name']);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
TestDocumentManagementAncillaryService = __decorate([
|
|
21
|
+
Singleton()
|
|
22
|
+
], TestDocumentManagementAncillaryService);
|
|
23
|
+
export { TestDocumentManagementAncillaryService };
|
|
7
24
|
async function bootstrap() {
|
|
8
25
|
configureDocumentManagement({
|
|
26
|
+
ancillaryService: TestDocumentManagementAncillaryService,
|
|
27
|
+
fileObjectStorageModule: 'documents',
|
|
9
28
|
database: {
|
|
10
29
|
connection: {
|
|
11
30
|
database: 'xxx',
|
|
12
31
|
user: 'xxx',
|
|
13
32
|
password: 'xxx'
|
|
14
33
|
}
|
|
15
|
-
}
|
|
16
|
-
fileObjectStorageModule: 'documents'
|
|
34
|
+
}
|
|
17
35
|
});
|
|
18
36
|
configureS3ObjectStorage({ endpoint: 'http://localhost:10000', accessKey: 'tstdl-dev', secretKey: 'tstdl-dev', bucketPerModule: true });
|
|
19
37
|
await migrateDocumentManagementSchema();
|
package/file/index.d.ts
CHANGED
package/file/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class TemporaryFile implements AsyncDisposable {
|
|
2
|
+
#private;
|
|
3
|
+
get path(): string;
|
|
4
|
+
static create(): TemporaryFile;
|
|
5
|
+
/**
|
|
6
|
+
* Use an existing file as a temporary file which gets deleted on disposal.
|
|
7
|
+
* @param path path to adopt
|
|
8
|
+
*/
|
|
9
|
+
static adopt(path: string): TemporaryFile;
|
|
10
|
+
static from(content: string | Uint8Array | ReadableStream<Uint8Array>): Promise<TemporaryFile>;
|
|
11
|
+
read(): Promise<Uint8Array>;
|
|
12
|
+
readText(): Promise<string>;
|
|
13
|
+
readStream(): ReadableStream<Uint8Array>;
|
|
14
|
+
write(content: string | Uint8Array | ReadableStream<Uint8Array>): Promise<void>;
|
|
15
|
+
delete(): Promise<void>;
|
|
16
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
|
+
import { readFile, unlink, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { Readable } from 'node:stream';
|
|
5
|
+
export class TemporaryFile {
|
|
6
|
+
#path = `${tmpdir()}/${crypto.randomUUID()}`;
|
|
7
|
+
get path() {
|
|
8
|
+
return this.#path;
|
|
9
|
+
}
|
|
10
|
+
static create() {
|
|
11
|
+
return new TemporaryFile();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Use an existing file as a temporary file which gets deleted on disposal.
|
|
15
|
+
* @param path path to adopt
|
|
16
|
+
*/
|
|
17
|
+
static adopt(path) {
|
|
18
|
+
const file = new TemporaryFile();
|
|
19
|
+
file.#path = path;
|
|
20
|
+
return file;
|
|
21
|
+
}
|
|
22
|
+
static async from(content) {
|
|
23
|
+
const file = new TemporaryFile();
|
|
24
|
+
await file.write(content);
|
|
25
|
+
return file;
|
|
26
|
+
}
|
|
27
|
+
async read() {
|
|
28
|
+
return readFile(this.#path);
|
|
29
|
+
}
|
|
30
|
+
async readText() {
|
|
31
|
+
return readFile(this.#path, { encoding: 'utf8' });
|
|
32
|
+
}
|
|
33
|
+
readStream() {
|
|
34
|
+
const stream = createReadStream(this.#path);
|
|
35
|
+
return Readable.toWeb(stream);
|
|
36
|
+
}
|
|
37
|
+
async write(content) {
|
|
38
|
+
await writeFile(this.#path, content);
|
|
39
|
+
}
|
|
40
|
+
async delete() {
|
|
41
|
+
await unlink(this.#path);
|
|
42
|
+
}
|
|
43
|
+
async [Symbol.asyncDispose]() {
|
|
44
|
+
try {
|
|
45
|
+
await this.delete();
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -32,5 +32,7 @@ export declare class HttpServerResponse {
|
|
|
32
32
|
};
|
|
33
33
|
constructor(response?: HttpServerResponseOptions);
|
|
34
34
|
static fromObject(options?: HttpServerResponseOptions): HttpServerResponse;
|
|
35
|
+
static redirect(url: string, options?: HttpServerResponseOptions): HttpServerResponse;
|
|
35
36
|
update(options: HttpServerResponseOptions): void;
|
|
36
37
|
}
|
|
38
|
+
export declare function redirect(url: string, options?: HttpServerResponseOptions): HttpServerResponse;
|
|
@@ -13,6 +13,16 @@ export class HttpServerResponse {
|
|
|
13
13
|
static fromObject(options) {
|
|
14
14
|
return new HttpServerResponse(options);
|
|
15
15
|
}
|
|
16
|
+
static redirect(url, options) {
|
|
17
|
+
return new HttpServerResponse({
|
|
18
|
+
statusCode: 303,
|
|
19
|
+
...options,
|
|
20
|
+
headers: {
|
|
21
|
+
Location: url,
|
|
22
|
+
...options?.headers
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
16
26
|
update(options) {
|
|
17
27
|
this.statusCode = options.statusCode;
|
|
18
28
|
this.statusMessage = options.statusMessage;
|
|
@@ -25,3 +35,6 @@ export class HttpServerResponse {
|
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
}
|
|
38
|
+
export function redirect(url, options) {
|
|
39
|
+
return HttpServerResponse.redirect(url, options);
|
|
40
|
+
}
|
package/injector/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './inject.js';
|
|
|
8
8
|
export * from './injector.js';
|
|
9
9
|
export * from './interfaces.js';
|
|
10
10
|
export * from './provider.js';
|
|
11
|
+
export * from './resolution.js';
|
|
11
12
|
export * from './resolve-chain.js';
|
|
12
13
|
export * from './resolve.error.js';
|
|
13
14
|
export * from './symbols.js';
|
package/injector/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from './inject.js';
|
|
|
8
8
|
export * from './injector.js';
|
|
9
9
|
export * from './interfaces.js';
|
|
10
10
|
export * from './provider.js';
|
|
11
|
+
export * from './resolution.js';
|
|
11
12
|
export * from './resolve-chain.js';
|
|
12
13
|
export * from './resolve.error.js';
|
|
13
14
|
export * from './symbols.js';
|
package/injector/injector.js
CHANGED
|
@@ -12,6 +12,7 @@ import { assert, isArray, isBoolean, isDefined, isFunction, isNotNull, isNull, i
|
|
|
12
12
|
import { setCurrentInjectionContext } from './inject.js';
|
|
13
13
|
import { afterResolve } from './interfaces.js';
|
|
14
14
|
import { isClassProvider, isFactoryProvider, isProviderWithInitializer, isTokenProvider, isValueProvider } from './provider.js';
|
|
15
|
+
import { runInResolutionContext } from './resolution.js';
|
|
15
16
|
import { ResolveChain } from './resolve-chain.js';
|
|
16
17
|
import { ResolveError } from './resolve.error.js';
|
|
17
18
|
import { injectMetadataSymbol, injectableMetadataSymbol } from './symbols.js';
|
|
@@ -264,7 +265,7 @@ export class Injector {
|
|
|
264
265
|
}
|
|
265
266
|
const injectionContext = injector.getInjectionContext(context, argument, chain);
|
|
266
267
|
const previousInjectionContext = setCurrentInjectionContext(injectionContext);
|
|
267
|
-
const resolutionTag = Symbol();
|
|
268
|
+
const resolutionTag = Symbol('ResolutionTag');
|
|
268
269
|
try {
|
|
269
270
|
const resolutionScoped = registration.options.lifecycle == 'resolution';
|
|
270
271
|
const injectorScoped = registration.options.lifecycle == 'injector';
|
|
@@ -280,12 +281,16 @@ export class Injector {
|
|
|
280
281
|
else if (singletonScoped && registration.resolutions.has(argumentIdentity)) {
|
|
281
282
|
return registration.resolutions.get(argumentIdentity);
|
|
282
283
|
}
|
|
283
|
-
const
|
|
284
|
+
const resolutionContext = {
|
|
285
|
+
afterResolveRegistrations: []
|
|
286
|
+
};
|
|
287
|
+
const value = injector._resolveProvider(resolutionTag, registration, resolveArgument, options, context, resolutionContext, injectionContext, chain);
|
|
284
288
|
const resolution = {
|
|
285
289
|
tag: resolutionTag,
|
|
286
290
|
registration,
|
|
287
291
|
value,
|
|
288
292
|
argument: injectionContext.argument,
|
|
293
|
+
afterResolveRegistrations: resolutionContext.afterResolveRegistrations,
|
|
289
294
|
afterResolveContext: injector.getAfterResolveContext(resolutionTag, context),
|
|
290
295
|
chain
|
|
291
296
|
};
|
|
@@ -305,7 +310,7 @@ export class Injector {
|
|
|
305
310
|
setCurrentInjectionContext(previousInjectionContext);
|
|
306
311
|
}
|
|
307
312
|
}
|
|
308
|
-
_resolveProvider(resolutionTag, registration, resolveArgument, options, context, injectionContext, chain) {
|
|
313
|
+
_resolveProvider(resolutionTag, registration, resolveArgument, options, context, resolutionContext, injectionContext, chain) {
|
|
309
314
|
try {
|
|
310
315
|
setResolving(registration.token, context, chain);
|
|
311
316
|
const { provider } = registration;
|
|
@@ -319,7 +324,7 @@ export class Injector {
|
|
|
319
324
|
}
|
|
320
325
|
const parameters = (typeMetadata?.parameters ?? []).map((metadata) => this.resolveClassInjection(resolutionTag, context, provider.useClass, metadata, arg, chain));
|
|
321
326
|
try {
|
|
322
|
-
result = { value:
|
|
327
|
+
result = { value: runInResolutionContext(resolutionContext, () => Reflect.construct(provider.useClass, parameters)) };
|
|
323
328
|
}
|
|
324
329
|
catch (error) {
|
|
325
330
|
if (error instanceof ResolveError) {
|
|
@@ -344,7 +349,7 @@ export class Injector {
|
|
|
344
349
|
const arg = resolveArgument ?? provider.defaultArgument ?? provider.defaultArgumentProvider?.();
|
|
345
350
|
injectionContext.argument = arg;
|
|
346
351
|
try {
|
|
347
|
-
result = { value: provider.useFactory(arg, this.getResolveContext(resolutionTag, context, chain)) };
|
|
352
|
+
result = { value: runInResolutionContext(resolutionContext, () => provider.useFactory(arg, this.getResolveContext(resolutionTag, context, chain))) };
|
|
348
353
|
}
|
|
349
354
|
catch (error) {
|
|
350
355
|
throw new ResolveError('Error in provider factory.', chain, error);
|
|
@@ -484,7 +489,11 @@ function postProcess(context) {
|
|
|
484
489
|
}
|
|
485
490
|
derefForwardRefs(context);
|
|
486
491
|
for (const resolution of context.resolutions) {
|
|
487
|
-
|
|
492
|
+
for (const afterResolveHandler of resolution.afterResolveRegistrations) {
|
|
493
|
+
const returnValue = afterResolveHandler(resolution.argument, resolution.afterResolveContext);
|
|
494
|
+
throwOnPromise(returnValue, 'registerAfterResolve()', resolution.chain);
|
|
495
|
+
}
|
|
496
|
+
if (!isTokenProvider(resolution.registration.provider) && isFunction(resolution.value?.[afterResolve])) {
|
|
488
497
|
const returnValue = resolution.value[afterResolve](resolution.argument, resolution.afterResolveContext);
|
|
489
498
|
throwOnPromise(returnValue, '[afterResolve]', resolution.chain);
|
|
490
499
|
}
|
|
@@ -504,7 +513,10 @@ async function postProcessAsync(context) {
|
|
|
504
513
|
}
|
|
505
514
|
derefForwardRefs(context);
|
|
506
515
|
for (const resolution of context.resolutions) {
|
|
507
|
-
|
|
516
|
+
for (const afterResolveHandler of resolution.afterResolveRegistrations) {
|
|
517
|
+
await afterResolveHandler(resolution.argument, resolution.afterResolveContext);
|
|
518
|
+
}
|
|
519
|
+
if (!isTokenProvider(resolution.registration.provider) && isFunction(resolution.value?.[afterResolve])) {
|
|
508
520
|
await resolution.value[afterResolve](resolution.argument, resolution.afterResolveContext);
|
|
509
521
|
}
|
|
510
522
|
if (isProviderWithInitializer(resolution.registration.provider)) {
|
package/injector/interfaces.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ export interface Resolvable<A = unknown, D extends Record = Record> extends Part
|
|
|
13
13
|
readonly [resolveArgumentType]?: A;
|
|
14
14
|
}
|
|
15
15
|
export interface AfterResolve<A = unknown, D extends Record = Record> {
|
|
16
|
-
[afterResolve](argument: A
|
|
16
|
+
[afterResolve](argument: NoInfer<A>, context: AfterResolveContext<NoInfer<D>>): void | Promise<void>;
|
|
17
17
|
}
|
package/injector/interfaces.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const resolveArgumentType = Symbol('resolveArgumentType');
|
|
2
|
-
export const afterResolve = Symbol('
|
|
2
|
+
export const afterResolve = Symbol('afterResolve');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Record } from '../types.js';
|
|
2
|
+
import type { Resolvable } from './interfaces.js';
|
|
3
|
+
import type { AfterResolveContext } from './types.js';
|
|
4
|
+
export type AfterResolveHandler<A, D extends Record> = (argument: A, context: AfterResolveContext<D>) => void | Promise<void>;
|
|
5
|
+
export type ResolutionContext<A> = {
|
|
6
|
+
afterResolveRegistrations: AfterResolveHandler<A, any>[];
|
|
7
|
+
};
|
|
8
|
+
declare const assertInResolutionContext: (debugFnOrMessage: import("../types.js").Function | string) => void, getCurrentResolutionContext: {
|
|
9
|
+
(required: true, debugFn: import("../types.js").Function): ResolutionContext<any>;
|
|
10
|
+
(required?: false, debugFn?: import("../types.js").Function): ResolutionContext<any> | null;
|
|
11
|
+
(required: boolean, debugFn: import("../types.js").Function): ResolutionContext<any> | null;
|
|
12
|
+
}, runInResolutionContext: <ReturnT>(context: ResolutionContext<any>, fn: () => ReturnT) => ReturnT;
|
|
13
|
+
export declare function registerAfterResolve(handler: AfterResolveHandler<unknown, Record>): void;
|
|
14
|
+
export declare function registerAfterResolve<A, D extends Record>(_this: Resolvable<A, D>, handler: AfterResolveHandler<A, D>): void;
|
|
15
|
+
export { assertInResolutionContext, getCurrentResolutionContext, runInResolutionContext };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContextProvider } from '../context/index.js';
|
|
2
|
+
const { assertInResolutionContext, getCurrentResolutionContext, runInResolutionContext } = createContextProvider('Resolution');
|
|
3
|
+
export function registerAfterResolve(thisOrHandler, handlerOrNothing) {
|
|
4
|
+
getCurrentResolutionContext(true, registerAfterResolve).afterResolveRegistrations.push(handlerOrNothing ?? thisOrHandler);
|
|
5
|
+
}
|
|
6
|
+
export { assertInResolutionContext, getCurrentResolutionContext, runInResolutionContext };
|
|
@@ -7,5 +7,5 @@ export declare class ConsoleLogger extends Logger {
|
|
|
7
7
|
fork(options: LoggerForkOptions): ConsoleLogger;
|
|
8
8
|
subModule(subModule: string): ConsoleLogger;
|
|
9
9
|
prefix(prefix: string): ConsoleLogger;
|
|
10
|
-
protected log(level: LogLevel, entryOrError: string |
|
|
10
|
+
protected log(level: LogLevel, entryOrError: string | unknown, errorOptions?: LogErrorOptions): void;
|
|
11
11
|
}
|
package/logger/logger.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare abstract class Logger implements Resolvable<LoggerArgument> {
|
|
|
26
26
|
readonly logPrefix: string;
|
|
27
27
|
readonly [resolveArgumentType]: LoggerArgument;
|
|
28
28
|
constructor(level: LogLevel, module?: string | string[], prefix?: string);
|
|
29
|
-
error(error: Error, options?: LogErrorOptions): void;
|
|
30
29
|
error(entry: LogEntryOrProvider): void;
|
|
30
|
+
error(error: unknown, options?: LogErrorOptions): void;
|
|
31
31
|
warn(entry: LogEntryOrProvider): void;
|
|
32
32
|
info(entry: LogEntryOrProvider): void;
|
|
33
33
|
verbose(entry: LogEntryOrProvider): void;
|
|
@@ -21,13 +21,6 @@ export declare abstract class ObjectStorage implements Resolvable<ObjectStorageA
|
|
|
21
21
|
* @param content content of object
|
|
22
22
|
*/
|
|
23
23
|
abstract uploadObject(key: string, content: Uint8Array | ReadableStream<Uint8Array>, options?: UploadObjectOptions): Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Uploads an object stream
|
|
26
|
-
* @param key object key
|
|
27
|
-
* @param stream stream of object
|
|
28
|
-
* @deprecated use {@link uploadObject} instead
|
|
29
|
-
*/
|
|
30
|
-
abstract uploadObjectStream(key: string, stream: ReadableStream<Uint8Array>, options?: UploadObjectOptions): Promise<void>;
|
|
31
24
|
/**
|
|
32
25
|
* Get an url which can be used to upload the object without further authorization
|
|
33
26
|
* @param key object key
|
|
@@ -52,6 +45,11 @@ export declare abstract class ObjectStorage implements Resolvable<ObjectStorageA
|
|
|
52
45
|
* @param key object key
|
|
53
46
|
*/
|
|
54
47
|
abstract getResourceUri(key: string): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Get object content
|
|
50
|
+
* @param key object key
|
|
51
|
+
*/
|
|
52
|
+
abstract getContent(key: string): Promise<Uint8Array>;
|
|
55
53
|
/**
|
|
56
54
|
* Get stream of object content
|
|
57
55
|
* @param key object key
|
|
@@ -12,7 +12,6 @@ export declare class S3ObjectStorage extends ObjectStorage {
|
|
|
12
12
|
exists(key: string): Promise<boolean>;
|
|
13
13
|
statObject(key: string): Promise<BucketItemStat>;
|
|
14
14
|
uploadObject(key: string, content: Uint8Array | ReadableStream<Uint8Array>, options?: UploadObjectOptions): Promise<void>;
|
|
15
|
-
uploadObjectStream(key: string, stream: ReadableStream<Uint8Array>, options?: UploadObjectOptions): Promise<void>;
|
|
16
15
|
getContent(key: string): Promise<Uint8Array>;
|
|
17
16
|
getContentStream(key: string): ReadableStream<Uint8Array>;
|
|
18
17
|
getObjects(): Promise<S3Object[]>;
|
|
@@ -66,9 +66,6 @@ let S3ObjectStorage = class S3ObjectStorage extends ObjectStorage {
|
|
|
66
66
|
]);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
async uploadObjectStream(key, stream, options) {
|
|
70
|
-
return this.uploadObject(key, stream, options);
|
|
71
|
-
}
|
|
72
69
|
async getContent(key) {
|
|
73
70
|
const bucketKey = this.getBucketKey(key);
|
|
74
71
|
const result = await this.client.getObject(this.bucket, bucketKey);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { customType } from 'drizzle-orm/pg-core';
|
|
2
|
-
import { dateToNumericDate, numericDateToDate } from '
|
|
2
|
+
import { dateToNumericDate, numericDateToDate } from '../../utils/date-time.js';
|
|
3
3
|
export const numericDate = customType({
|
|
4
4
|
dataType() {
|
|
5
5
|
return 'date';
|
|
6
6
|
},
|
|
7
7
|
toDriver(value) {
|
|
8
|
-
|
|
9
|
-
return new Date(year, month - 1, day).toISOString();
|
|
8
|
+
return numericDateToDate(value).toISOString();
|
|
10
9
|
},
|
|
11
10
|
fromDriver(value) {
|
|
12
11
|
const date = new Date(value);
|
package/orm/decorators.d.ts
CHANGED
|
@@ -4,16 +4,16 @@ import type { AbstractConstructor, TypedOmit } from '../types.js';
|
|
|
4
4
|
import type { Entity, EntityType } from './entity.js';
|
|
5
5
|
import type { PgTableFromType } from './server/types.js';
|
|
6
6
|
type IndexMethod = LiteralUnion<'hash' | 'btree' | 'gist' | 'spgist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat', string>;
|
|
7
|
+
type NamingStrategy = 'abbreviated-table';
|
|
7
8
|
export type CheckBuilder<T extends Entity = any> = (table: PgTableFromType<EntityType<T>>) => SQL;
|
|
8
9
|
export type OrmTableReflectionData = {
|
|
9
10
|
name?: string;
|
|
10
11
|
schema?: string;
|
|
12
|
+
compundPrimaryKeyName?: string;
|
|
13
|
+
compundPrimaryKeyNaming?: NamingStrategy;
|
|
11
14
|
unique?: UniqueReflectionData[];
|
|
12
15
|
index?: IndexReflectionData[];
|
|
13
|
-
checks?:
|
|
14
|
-
name: string;
|
|
15
|
-
builder: CheckBuilder;
|
|
16
|
-
}[];
|
|
16
|
+
checks?: CheckReflectionData[];
|
|
17
17
|
};
|
|
18
18
|
export type OrmColumnReflectionData = {
|
|
19
19
|
name?: string;
|
|
@@ -35,6 +35,7 @@ export type UniqueReflectionData = {
|
|
|
35
35
|
columns?: string[];
|
|
36
36
|
options?: {
|
|
37
37
|
nulls?: 'distinct' | 'not distinct';
|
|
38
|
+
naming?: NamingStrategy;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
41
|
export type IndexReflectionData = {
|
|
@@ -45,6 +46,14 @@ export type IndexReflectionData = {
|
|
|
45
46
|
using?: IndexMethod;
|
|
46
47
|
unique?: boolean;
|
|
47
48
|
nulls?: 'first' | 'last';
|
|
49
|
+
naming?: NamingStrategy;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type CheckReflectionData = {
|
|
53
|
+
name: string;
|
|
54
|
+
builder: CheckBuilder;
|
|
55
|
+
options?: {
|
|
56
|
+
naming?: NamingStrategy;
|
|
48
57
|
};
|
|
49
58
|
};
|
|
50
59
|
export declare function createTableDecorator(data?: OrmTableReflectionData): ClassDecorator;
|
package/orm/decorators.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { createClassDecorator, createDecorator, createPropertyDecorator } from '../reflection/index.js';
|
|
2
2
|
import { Property } from '../schema/index.js';
|
|
3
|
-
import { objectEntries } from '../utils/object/object.js';
|
|
3
|
+
import { filterUndefinedObjectProperties, objectEntries } from '../utils/object/object.js';
|
|
4
4
|
import { assertNotArrayPass, isArray, isString, isUndefined } from '../utils/type-guards.js';
|
|
5
5
|
export function createTableDecorator(data = {}) {
|
|
6
6
|
return createClassDecorator({
|
|
7
7
|
handler: (_, metadata) => {
|
|
8
8
|
const reflectionData = metadata.data.tryGet('orm') ?? {};
|
|
9
9
|
const dataEntries = objectEntries(data);
|
|
10
|
+
if (dataEntries.length == 0) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
10
13
|
for (const [key, value] of dataEntries) {
|
|
11
14
|
const existingValue = reflectionData[key];
|
|
12
|
-
if (
|
|
13
|
-
reflectionData[key] = value;
|
|
14
|
-
}
|
|
15
|
-
else if (isArray(existingValue)) {
|
|
15
|
+
if (isArray(existingValue)) {
|
|
16
16
|
reflectionData[key] = [...existingValue, ...value];
|
|
17
17
|
}
|
|
18
|
+
else {
|
|
19
|
+
reflectionData[key] = value;
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
metadata.data.set('orm', reflectionData, true);
|
|
20
23
|
}
|
|
@@ -49,7 +52,10 @@ export function Embedded(type, options) {
|
|
|
49
52
|
export function Table(nameOrOptions, optionsOrNothing) {
|
|
50
53
|
const name = isString(nameOrOptions) ? nameOrOptions : nameOrOptions?.name;
|
|
51
54
|
const schema = isString(nameOrOptions) ? optionsOrNothing?.schema : nameOrOptions?.schema;
|
|
52
|
-
|
|
55
|
+
const data = (isUndefined(name) && isUndefined(schema))
|
|
56
|
+
? undefined
|
|
57
|
+
: filterUndefinedObjectProperties({ name, schema });
|
|
58
|
+
return createTableDecorator(data);
|
|
53
59
|
}
|
|
54
60
|
export function Unique(nameOrColumns, columnsOrOptions, options) {
|
|
55
61
|
if (isArray(nameOrColumns)) {
|
|
@@ -58,7 +64,7 @@ export function Unique(nameOrColumns, columnsOrOptions, options) {
|
|
|
58
64
|
if (isArray(columnsOrOptions)) {
|
|
59
65
|
return createTableDecorator({ unique: [{ name: nameOrColumns, columns: columnsOrOptions, options }] });
|
|
60
66
|
}
|
|
61
|
-
return createColumnDecorator({ unique: { name: nameOrColumns, options: columnsOrOptions
|
|
67
|
+
return createColumnDecorator({ unique: { name: nameOrColumns, options: columnsOrOptions } });
|
|
62
68
|
}
|
|
63
69
|
export function Index(nameOrColumns, columnsOrOptions, options) {
|
|
64
70
|
if (isArray(nameOrColumns)) {
|
package/orm/entity.js
CHANGED
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { Defaulted, Integer } from '../schema/index.js';
|
|
11
|
-
import {
|
|
11
|
+
import { PrimaryKey } from './decorators.js';
|
|
12
12
|
import { Embedded, Json, Timestamp, Uuid } from './types.js';
|
|
13
13
|
let EntityMetadataAttributes = class EntityMetadataAttributes {
|
|
14
14
|
};
|
|
@@ -16,13 +16,13 @@ EntityMetadataAttributes = __decorate([
|
|
|
16
16
|
Json()
|
|
17
17
|
], EntityMetadataAttributes);
|
|
18
18
|
export { EntityMetadataAttributes };
|
|
19
|
-
|
|
19
|
+
export class EntityMetadata {
|
|
20
20
|
revision;
|
|
21
21
|
revisionTimestamp;
|
|
22
22
|
createTimestamp;
|
|
23
23
|
deleteTimestamp;
|
|
24
24
|
attributes;
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
__decorate([
|
|
27
27
|
Integer(),
|
|
28
28
|
__metadata("design:type", Number)
|
|
@@ -43,10 +43,6 @@ __decorate([
|
|
|
43
43
|
Defaulted(EntityMetadataAttributes, {}),
|
|
44
44
|
__metadata("design:type", Object)
|
|
45
45
|
], EntityMetadata.prototype, "attributes", void 0);
|
|
46
|
-
EntityMetadata = __decorate([
|
|
47
|
-
Index(['revision', 'revisionTimestamp'])
|
|
48
|
-
], EntityMetadata);
|
|
49
|
-
export { EntityMetadata };
|
|
50
46
|
export class Entity {
|
|
51
47
|
id;
|
|
52
48
|
metadata;
|
package/orm/index.d.ts
CHANGED
package/orm/index.js
CHANGED