@tstdl/base 0.91.28 → 0.91.31
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/.eslintrc.json +5 -1
- package/authentication/models/authentication-credentials.model.js +10 -10
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.js +16 -16
- package/authentication/models/init-secret-reset-data.model.js +3 -3
- package/authentication/models/token-payload-base.model.d.ts +4 -4
- package/authentication/models/token-payload-base.model.js +12 -12
- package/{reflection/reflection-data-map.d.ts → data-structures/context-data-map.d.ts} +3 -2
- package/{reflection/reflection-data-map.js → data-structures/context-data-map.js} +13 -6
- package/data-structures/index.d.ts +1 -0
- package/data-structures/index.js +1 -0
- package/examples/api/basic-overview.js +2 -2
- package/examples/api/custom-authentication.js +3 -3
- package/examples/orm/drizzle.config.d.ts +2 -0
- package/examples/orm/drizzle.config.js +5 -0
- package/examples/orm/schemas.d.ts +3 -0
- package/examples/orm/schemas.js +4 -0
- package/examples/orm/test.js +10 -0
- package/examples/orm/user.model.d.ts +9 -0
- package/examples/orm/user.model.js +39 -0
- package/key-value-store/index.d.ts +0 -1
- package/key-value-store/index.js +0 -1
- package/key-value-store/key-value.store.d.ts +9 -10
- package/key-value-store/mongo/mongo-key-value.store.js +2 -1
- package/mail/mail.client.js +5 -6
- package/orm/database-schema.d.ts +8 -0
- package/orm/database-schema.js +13 -0
- package/orm/decorators.d.ts +26 -0
- package/orm/decorators.js +21 -2
- package/orm/drizzle/schema-converter.d.ts +19 -0
- package/orm/drizzle/schema-converter.js +116 -0
- package/orm/entity.d.ts +6 -2
- package/orm/entity.js +9 -9
- package/orm/index.d.ts +1 -2
- package/orm/index.js +1 -2
- package/orm/repository.d.ts +27 -24
- package/orm/repository.js +124 -7
- package/orm/schemas/index.d.ts +1 -0
- package/orm/schemas/index.js +1 -0
- package/orm/schemas/uuid.d.ts +11 -0
- package/orm/schemas/uuid.js +16 -0
- package/orm/types.d.ts +20 -7
- package/orm/types.js +3 -5
- package/package.json +7 -4
- package/reflection/registry.d.ts +9 -6
- package/reflection/registry.js +25 -14
- package/schema/decorators/property.d.ts +2 -2
- package/schema/decorators/types.d.ts +1 -0
- package/schema/schema.d.ts +1 -1
- package/schema/schemas/array.d.ts +6 -3
- package/schema/schemas/array.js +9 -4
- package/schema/schemas/deferred.d.ts +12 -0
- package/schema/schemas/deferred.js +23 -0
- package/schema/schemas/index.d.ts +1 -0
- package/schema/schemas/index.js +1 -0
- package/schema/schemas/number.d.ts +5 -0
- package/schema/schemas/number.js +8 -1
- package/schema/schemas/string.d.ts +4 -1
- package/schema/schemas/string.js +8 -2
- package/schema/schemas/uint8-array.d.ts +3 -2
- package/schema/schemas/uint8-array.js +8 -5
- package/templates/resolvers/file.template-resolver.d.ts +1 -2
- package/templates/resolvers/file.template-resolver.js +2 -2
- package/templates/resolvers/jsx.template-resolver.d.ts +1 -3
- package/templates/resolvers/jsx.template-resolver.js +3 -7
- package/templates/template.model.d.ts +1 -1
- package/templates/template.model.js +5 -5
- package/utils/math.d.ts +11 -1
- package/utils/math.js +28 -0
- package/utils/string/index.d.ts +1 -0
- package/utils/string/index.js +1 -0
- package/utils/string/snake-case.d.ts +1 -0
- package/utils/string/snake-case.js +4 -0
- package/orm/schema-converter.d.ts +0 -99
- package/orm/schema-converter.js +0 -74
- package/orm/schema.d.ts +0 -3
- /package/{orm/schema.js → examples/orm/test.d.ts} +0 -0
package/.eslintrc.json
CHANGED
|
@@ -149,7 +149,11 @@
|
|
|
149
149
|
"@stylistic/quotes": ["warn", "single"],
|
|
150
150
|
"@stylistic/semi": ["warn", "always"],
|
|
151
151
|
"@stylistic/multiline-ternary": ["warn", "always-multiline"],
|
|
152
|
-
"@stylistic/generator-star-spacing":
|
|
152
|
+
"@stylistic/generator-star-spacing": ["error", {
|
|
153
|
+
"named": "before",
|
|
154
|
+
"anonymous": "neither",
|
|
155
|
+
"method": "before"
|
|
156
|
+
}],
|
|
153
157
|
"@stylistic/indent": ["off"],
|
|
154
158
|
"@stylistic/max-len": ["off"],
|
|
155
159
|
"@stylistic/object-curly-spacing": ["warn", "always"],
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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
|
-
import {
|
|
10
|
+
import { NumberProperty, StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
11
11
|
export class AuthenticationCredentials {
|
|
12
12
|
id;
|
|
13
13
|
subject;
|
|
@@ -16,23 +16,23 @@ export class AuthenticationCredentials {
|
|
|
16
16
|
hash;
|
|
17
17
|
}
|
|
18
18
|
__decorate([
|
|
19
|
-
|
|
19
|
+
StringProperty(),
|
|
20
20
|
__metadata("design:type", String)
|
|
21
21
|
], AuthenticationCredentials.prototype, "id", void 0);
|
|
22
22
|
__decorate([
|
|
23
|
-
|
|
23
|
+
StringProperty(),
|
|
24
24
|
__metadata("design:type", String)
|
|
25
25
|
], AuthenticationCredentials.prototype, "subject", void 0);
|
|
26
26
|
__decorate([
|
|
27
|
-
|
|
27
|
+
NumberProperty(),
|
|
28
28
|
__metadata("design:type", Number)
|
|
29
29
|
], AuthenticationCredentials.prototype, "hashVersion", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
|
|
31
|
+
Uint8ArrayProperty(),
|
|
32
32
|
__metadata("design:type", Uint8Array)
|
|
33
33
|
], AuthenticationCredentials.prototype, "salt", void 0);
|
|
34
34
|
__decorate([
|
|
35
|
-
|
|
35
|
+
Uint8ArrayProperty(),
|
|
36
36
|
__metadata("design:type", Uint8Array)
|
|
37
37
|
], AuthenticationCredentials.prototype, "hash", void 0);
|
|
38
38
|
export class NewAuthenticationCredentials {
|
|
@@ -42,18 +42,18 @@ export class NewAuthenticationCredentials {
|
|
|
42
42
|
hash;
|
|
43
43
|
}
|
|
44
44
|
__decorate([
|
|
45
|
-
|
|
45
|
+
StringProperty(),
|
|
46
46
|
__metadata("design:type", String)
|
|
47
47
|
], NewAuthenticationCredentials.prototype, "subject", void 0);
|
|
48
48
|
__decorate([
|
|
49
|
-
|
|
49
|
+
NumberProperty(),
|
|
50
50
|
__metadata("design:type", Number)
|
|
51
51
|
], NewAuthenticationCredentials.prototype, "hashVersion", void 0);
|
|
52
52
|
__decorate([
|
|
53
|
-
|
|
53
|
+
Uint8ArrayProperty(),
|
|
54
54
|
__metadata("design:type", Uint8Array)
|
|
55
55
|
], NewAuthenticationCredentials.prototype, "salt", void 0);
|
|
56
56
|
__decorate([
|
|
57
|
-
|
|
57
|
+
Uint8ArrayProperty(),
|
|
58
58
|
__metadata("design:type", Uint8Array)
|
|
59
59
|
], NewAuthenticationCredentials.prototype, "hash", void 0);
|
|
@@ -7,44 +7,44 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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
|
-
import {
|
|
10
|
+
import { NumberProperty, StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
11
11
|
export class AuthenticationSession {
|
|
12
12
|
id;
|
|
13
13
|
subject;
|
|
14
|
-
/**
|
|
14
|
+
/** Timestamp */
|
|
15
15
|
begin;
|
|
16
|
-
/**
|
|
16
|
+
/** Timestamp */
|
|
17
17
|
end;
|
|
18
18
|
refreshTokenHashVersion;
|
|
19
19
|
refreshTokenSalt;
|
|
20
20
|
refreshTokenHash;
|
|
21
21
|
}
|
|
22
22
|
__decorate([
|
|
23
|
-
|
|
23
|
+
StringProperty(),
|
|
24
24
|
__metadata("design:type", String)
|
|
25
25
|
], AuthenticationSession.prototype, "id", void 0);
|
|
26
26
|
__decorate([
|
|
27
|
-
|
|
27
|
+
StringProperty(),
|
|
28
28
|
__metadata("design:type", String)
|
|
29
29
|
], AuthenticationSession.prototype, "subject", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
|
|
31
|
+
NumberProperty(),
|
|
32
32
|
__metadata("design:type", Number)
|
|
33
33
|
], AuthenticationSession.prototype, "begin", void 0);
|
|
34
34
|
__decorate([
|
|
35
|
-
|
|
35
|
+
NumberProperty(),
|
|
36
36
|
__metadata("design:type", Number)
|
|
37
37
|
], AuthenticationSession.prototype, "end", void 0);
|
|
38
38
|
__decorate([
|
|
39
|
-
|
|
39
|
+
NumberProperty(),
|
|
40
40
|
__metadata("design:type", Number)
|
|
41
41
|
], AuthenticationSession.prototype, "refreshTokenHashVersion", void 0);
|
|
42
42
|
__decorate([
|
|
43
|
-
|
|
43
|
+
Uint8ArrayProperty(),
|
|
44
44
|
__metadata("design:type", Uint8Array)
|
|
45
45
|
], AuthenticationSession.prototype, "refreshTokenSalt", void 0);
|
|
46
46
|
__decorate([
|
|
47
|
-
|
|
47
|
+
Uint8ArrayProperty(),
|
|
48
48
|
__metadata("design:type", Uint8Array)
|
|
49
49
|
], AuthenticationSession.prototype, "refreshTokenHash", void 0);
|
|
50
50
|
export class NewAuthenticationSession {
|
|
@@ -56,26 +56,26 @@ export class NewAuthenticationSession {
|
|
|
56
56
|
refreshTokenHash;
|
|
57
57
|
}
|
|
58
58
|
__decorate([
|
|
59
|
-
|
|
59
|
+
StringProperty(),
|
|
60
60
|
__metadata("design:type", String)
|
|
61
61
|
], NewAuthenticationSession.prototype, "subject", void 0);
|
|
62
62
|
__decorate([
|
|
63
|
-
|
|
63
|
+
NumberProperty(),
|
|
64
64
|
__metadata("design:type", Number)
|
|
65
65
|
], NewAuthenticationSession.prototype, "begin", void 0);
|
|
66
66
|
__decorate([
|
|
67
|
-
|
|
67
|
+
NumberProperty(),
|
|
68
68
|
__metadata("design:type", Number)
|
|
69
69
|
], NewAuthenticationSession.prototype, "end", void 0);
|
|
70
70
|
__decorate([
|
|
71
|
-
|
|
71
|
+
NumberProperty(),
|
|
72
72
|
__metadata("design:type", Number)
|
|
73
73
|
], NewAuthenticationSession.prototype, "refreshTokenHashVersion", void 0);
|
|
74
74
|
__decorate([
|
|
75
|
-
|
|
75
|
+
Uint8ArrayProperty(),
|
|
76
76
|
__metadata("design:type", Uint8Array)
|
|
77
77
|
], NewAuthenticationSession.prototype, "refreshTokenSalt", void 0);
|
|
78
78
|
__decorate([
|
|
79
|
-
|
|
79
|
+
Uint8ArrayProperty(),
|
|
80
80
|
__metadata("design:type", Uint8Array)
|
|
81
81
|
], NewAuthenticationSession.prototype, "refreshTokenHash", void 0);
|
|
@@ -7,17 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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
|
-
import {
|
|
10
|
+
import { StringProperty } from '../../schema/index.js';
|
|
11
11
|
export class InitSecretResetData {
|
|
12
12
|
/** Subject is not checked for existence. */
|
|
13
13
|
subject;
|
|
14
14
|
token;
|
|
15
15
|
}
|
|
16
16
|
__decorate([
|
|
17
|
-
|
|
17
|
+
StringProperty(),
|
|
18
18
|
__metadata("design:type", String)
|
|
19
19
|
], InitSecretResetData.prototype, "subject", void 0);
|
|
20
20
|
__decorate([
|
|
21
|
-
|
|
21
|
+
StringProperty(),
|
|
22
22
|
__metadata("design:type", String)
|
|
23
23
|
], InitSecretResetData.prototype, "token", void 0);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare class TokenPayloadBase {
|
|
2
|
-
/**
|
|
2
|
+
/** Token id */
|
|
3
3
|
jti: string;
|
|
4
|
-
/**
|
|
4
|
+
/** Issue timestamp in seconds */
|
|
5
5
|
iat: number;
|
|
6
|
-
/**
|
|
6
|
+
/** Expiration timestamp in seconds */
|
|
7
7
|
exp: number;
|
|
8
|
-
/**
|
|
8
|
+
/** Refresh token expiration timestamp in seconds */
|
|
9
9
|
refreshTokenExp: number;
|
|
10
10
|
sessionId: string;
|
|
11
11
|
subject: string;
|
|
@@ -7,45 +7,45 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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
|
-
import {
|
|
10
|
+
import { NumberProperty, StringProperty } from '../../schema/index.js';
|
|
11
11
|
export class TokenPayloadBase {
|
|
12
|
-
/**
|
|
12
|
+
/** Token id */
|
|
13
13
|
jti;
|
|
14
|
-
/**
|
|
14
|
+
/** Issue timestamp in seconds */
|
|
15
15
|
iat;
|
|
16
|
-
/**
|
|
16
|
+
/** Expiration timestamp in seconds */
|
|
17
17
|
exp;
|
|
18
|
-
/**
|
|
18
|
+
/** Refresh token expiration timestamp in seconds */
|
|
19
19
|
refreshTokenExp;
|
|
20
20
|
sessionId;
|
|
21
21
|
subject;
|
|
22
22
|
impersonator;
|
|
23
23
|
}
|
|
24
24
|
__decorate([
|
|
25
|
-
|
|
25
|
+
StringProperty(),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
27
|
], TokenPayloadBase.prototype, "jti", void 0);
|
|
28
28
|
__decorate([
|
|
29
|
-
|
|
29
|
+
NumberProperty(),
|
|
30
30
|
__metadata("design:type", Number)
|
|
31
31
|
], TokenPayloadBase.prototype, "iat", void 0);
|
|
32
32
|
__decorate([
|
|
33
|
-
|
|
33
|
+
NumberProperty(),
|
|
34
34
|
__metadata("design:type", Number)
|
|
35
35
|
], TokenPayloadBase.prototype, "exp", void 0);
|
|
36
36
|
__decorate([
|
|
37
|
-
|
|
37
|
+
NumberProperty(),
|
|
38
38
|
__metadata("design:type", Number)
|
|
39
39
|
], TokenPayloadBase.prototype, "refreshTokenExp", void 0);
|
|
40
40
|
__decorate([
|
|
41
|
-
|
|
41
|
+
StringProperty(),
|
|
42
42
|
__metadata("design:type", String)
|
|
43
43
|
], TokenPayloadBase.prototype, "sessionId", void 0);
|
|
44
44
|
__decorate([
|
|
45
|
-
|
|
45
|
+
StringProperty(),
|
|
46
46
|
__metadata("design:type", String)
|
|
47
47
|
], TokenPayloadBase.prototype, "subject", void 0);
|
|
48
48
|
__decorate([
|
|
49
|
-
|
|
49
|
+
StringProperty({ optional: true }),
|
|
50
50
|
__metadata("design:type", String)
|
|
51
51
|
], TokenPayloadBase.prototype, "impersonator", void 0);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Record } from '../types.js';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class ContextDataMap {
|
|
3
3
|
private readonly data;
|
|
4
4
|
constructor();
|
|
5
5
|
has(key: PropertyKey): boolean;
|
|
6
6
|
tryGet<T>(key: PropertyKey): T | undefined;
|
|
7
|
+
tryGet<T, D>(key: PropertyKey, defaultValue: D): T | D;
|
|
7
8
|
get<T>(key: PropertyKey): T;
|
|
8
9
|
set(key: PropertyKey, value: any, mergeValue?: boolean): void;
|
|
9
|
-
setMany(data: Record, mergeValues?: boolean): void;
|
|
10
|
+
setMany(data: Record | readonly [PropertyKey, any][], mergeValues?: boolean): void;
|
|
10
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { merge } from '../utils/merge.js';
|
|
2
2
|
import { objectEntries } from '../utils/object/object.js';
|
|
3
|
-
import { isUndefined } from '../utils/type-guards.js';
|
|
4
|
-
export class
|
|
3
|
+
import { isArray, isUndefined } from '../utils/type-guards.js';
|
|
4
|
+
export class ContextDataMap {
|
|
5
5
|
data;
|
|
6
6
|
constructor() {
|
|
7
7
|
this.data = new Map();
|
|
@@ -9,13 +9,17 @@ export class ReflectionDataMap {
|
|
|
9
9
|
has(key) {
|
|
10
10
|
return this.data.has(key);
|
|
11
11
|
}
|
|
12
|
-
tryGet(key) {
|
|
13
|
-
|
|
12
|
+
tryGet(key, defaultValue) {
|
|
13
|
+
const value = this.data.get(key);
|
|
14
|
+
if (isUndefined(value)) {
|
|
15
|
+
return defaultValue;
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
14
18
|
}
|
|
15
19
|
get(key) {
|
|
16
20
|
const data = this.tryGet(key);
|
|
17
21
|
if (isUndefined(data)) {
|
|
18
|
-
throw new Error(`No data for ${String(key)} available.`);
|
|
22
|
+
throw new Error(`No data for key "${String(key)}" available.`);
|
|
19
23
|
}
|
|
20
24
|
return data;
|
|
21
25
|
}
|
|
@@ -29,7 +33,10 @@ export class ReflectionDataMap {
|
|
|
29
33
|
this.data.set(key, newData);
|
|
30
34
|
}
|
|
31
35
|
setMany(data, mergeValues = false) {
|
|
32
|
-
|
|
36
|
+
const entries = isArray(data)
|
|
37
|
+
? data
|
|
38
|
+
: objectEntries(data);
|
|
39
|
+
for (const [key, value] of entries) {
|
|
33
40
|
this.set(key, value, mergeValues);
|
|
34
41
|
}
|
|
35
42
|
}
|
|
@@ -8,6 +8,7 @@ export * from './array-list.js';
|
|
|
8
8
|
export * from './cache.js';
|
|
9
9
|
export * from './circular-buffer.js';
|
|
10
10
|
export * from './collection.js';
|
|
11
|
+
export * from './context-data-map.js';
|
|
11
12
|
export * from './dictionary.js';
|
|
12
13
|
export * from './distinct-collection.js';
|
|
13
14
|
export * from './index-out-of-bounds.error.js';
|
package/data-structures/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from './array-list.js';
|
|
|
8
8
|
export * from './cache.js';
|
|
9
9
|
export * from './circular-buffer.js';
|
|
10
10
|
export * from './collection.js';
|
|
11
|
+
export * from './context-data-map.js';
|
|
11
12
|
export * from './dictionary.js';
|
|
12
13
|
export * from './distinct-collection.js';
|
|
13
14
|
export * from './index-out-of-bounds.error.js';
|
|
@@ -18,7 +18,7 @@ import { configureHttpClient } from '../../http/client/module.js';
|
|
|
18
18
|
import { configureNodeHttpServer } from '../../http/server/node/module.js';
|
|
19
19
|
import { inject } from '../../injector/inject.js';
|
|
20
20
|
import { WebServerModule } from '../../module/modules/web-server.module.js';
|
|
21
|
-
import { NumberProperty,
|
|
21
|
+
import { NumberProperty, StringProperty, array, boolean, number, object } from '../../schema/index.js';
|
|
22
22
|
import { timeout } from '../../utils/timing.js';
|
|
23
23
|
import { Agent } from 'undici';
|
|
24
24
|
class User {
|
|
@@ -30,7 +30,7 @@ __decorate([
|
|
|
30
30
|
__metadata("design:type", Number)
|
|
31
31
|
], User.prototype, "id", void 0);
|
|
32
32
|
__decorate([
|
|
33
|
-
|
|
33
|
+
StringProperty(),
|
|
34
34
|
__metadata("design:type", String)
|
|
35
35
|
], User.prototype, "name", void 0);
|
|
36
36
|
const users = [
|
|
@@ -26,7 +26,7 @@ import { Singleton } from '../../injector/decorators.js';
|
|
|
26
26
|
import { inject, injectAsync } from '../../injector/inject.js';
|
|
27
27
|
import { configureLocalMessageBus } from '../../message-bus/local/module.js';
|
|
28
28
|
import { WebServerModule } from '../../module/modules/index.js';
|
|
29
|
-
import {
|
|
29
|
+
import { StringProperty, emptyObjectSchema } from '../../schema/index.js';
|
|
30
30
|
import { configureDefaultSignalsImplementation } from '../../signals/implementation/configure.js';
|
|
31
31
|
import { first } from '../../utils/iterable-helpers/first.js';
|
|
32
32
|
import { skip } from '../../utils/iterable-helpers/skip.js';
|
|
@@ -57,14 +57,14 @@ class CustomTokenPaylod {
|
|
|
57
57
|
deviceRegistrationId;
|
|
58
58
|
}
|
|
59
59
|
__decorate([
|
|
60
|
-
|
|
60
|
+
StringProperty(),
|
|
61
61
|
__metadata("design:type", String)
|
|
62
62
|
], CustomTokenPaylod.prototype, "deviceRegistrationId", void 0);
|
|
63
63
|
class AuthenticationData {
|
|
64
64
|
deviceId;
|
|
65
65
|
}
|
|
66
66
|
__decorate([
|
|
67
|
-
|
|
67
|
+
StringProperty(),
|
|
68
68
|
__metadata("design:type", String)
|
|
69
69
|
], AuthenticationData.prototype, "deviceId", void 0);
|
|
70
70
|
const CustomAuthenticationApiClient = getAuthenticationApiClient(CustomTokenPaylod, AuthenticationData, emptyObjectSchema);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
3
|
+
import { pgSchema, uuid } from 'drizzle-orm/pg-core';
|
|
4
|
+
import * as schema from './schemas.js';
|
|
5
|
+
const db = drizzle('', { schema });
|
|
6
|
+
const query = eq(schema.user, 1);
|
|
7
|
+
const x = pgSchema('').table('test', {
|
|
8
|
+
id: uuid().defaultRandom().primaryKey()
|
|
9
|
+
});
|
|
10
|
+
await db.insert(x).values({});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Entity, Integer, Unique } from '../../orm/index.js';
|
|
11
|
+
import { Array, BooleanProperty, StringProperty } from '../../schema/index.js';
|
|
12
|
+
export class User extends Entity {
|
|
13
|
+
static entityName = 'User';
|
|
14
|
+
name;
|
|
15
|
+
nickNames;
|
|
16
|
+
age;
|
|
17
|
+
hasAge;
|
|
18
|
+
mail;
|
|
19
|
+
}
|
|
20
|
+
__decorate([
|
|
21
|
+
StringProperty(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], User.prototype, "name", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
Array(String),
|
|
26
|
+
__metadata("design:type", Array)
|
|
27
|
+
], User.prototype, "nickNames", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
Integer({ nullable: true }),
|
|
30
|
+
__metadata("design:type", Object)
|
|
31
|
+
], User.prototype, "age", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
BooleanProperty(),
|
|
34
|
+
__metadata("design:type", Boolean)
|
|
35
|
+
], User.prototype, "hasAge", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
Unique(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], User.prototype, "mail", void 0);
|
package/key-value-store/index.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { resolveArgumentType } from '../injector/interfaces.js';
|
|
1
|
+
import { type Resolvable, resolveArgumentType } from '../injector/interfaces.js';
|
|
3
2
|
import type { StringMap } from '../types.js';
|
|
4
|
-
/**
|
|
3
|
+
/** Key value store module */
|
|
5
4
|
export type KeyValueStoreArgument = string;
|
|
6
5
|
export declare abstract class KeyValueStore<KV extends StringMap> implements Resolvable<KeyValueStoreArgument> {
|
|
7
6
|
readonly module: string;
|
|
8
7
|
readonly [resolveArgumentType]: KeyValueStoreArgument;
|
|
9
8
|
constructor(module: string);
|
|
10
|
-
/**
|
|
9
|
+
/** Get value of key */
|
|
11
10
|
abstract get<K extends keyof KV>(key: K): Promise<KV[K] | undefined>;
|
|
12
|
-
/**
|
|
11
|
+
/** Get value of key */
|
|
13
12
|
abstract get<K extends keyof KV, D>(key: K, defaultValue: D): Promise<KV[K] | D>;
|
|
14
|
-
/**
|
|
13
|
+
/** Set key */
|
|
15
14
|
abstract set<K extends keyof KV>(key: K, value: KV[K]): Promise<void>;
|
|
16
|
-
/**
|
|
15
|
+
/** Set multiple keys */
|
|
17
16
|
abstract setMany(keyValues: Partial<KV>): Promise<void>;
|
|
18
|
-
/**
|
|
17
|
+
/** Delete key */
|
|
19
18
|
abstract delete(key: keyof KV): Promise<boolean>;
|
|
20
|
-
/**
|
|
19
|
+
/** Delete multiple keys */
|
|
21
20
|
abstract deleteMany(keys: (keyof KV)[]): Promise<void>;
|
|
22
|
-
/**
|
|
21
|
+
/** Delete all keys */
|
|
23
22
|
abstract clear(): Promise<void>;
|
|
24
23
|
}
|
|
@@ -9,10 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { getNewId } from '../../database/index.js';
|
|
11
11
|
import { Singleton } from '../../injector/index.js';
|
|
12
|
-
import { KeyValueStore
|
|
12
|
+
import { KeyValueStore } from '../../key-value-store/index.js';
|
|
13
13
|
import { currentTimestamp } from '../../utils/date-time.js';
|
|
14
14
|
import { objectEntries } from '../../utils/object/object.js';
|
|
15
15
|
import { assertString, isUndefined } from '../../utils/type-guards.js';
|
|
16
|
+
import { MongoKeyValueStoreProvider } from './mongo-key-value-store.provider.js';
|
|
16
17
|
import { MongoKeyValueRepository } from './mongo-key-value.repository.js';
|
|
17
18
|
let MongoKeyValueStore = class MongoKeyValueStore extends KeyValueStore {
|
|
18
19
|
keyValueRepository;
|
package/mail/mail.client.js
CHANGED
|
@@ -7,19 +7,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
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
|
-
import {
|
|
11
|
-
import { BooleanProperty } from '../schema/index.js';
|
|
10
|
+
import { BooleanProperty, NumberProperty, StringProperty } from '../schema/index.js';
|
|
12
11
|
import { Optional } from '../schema/schemas/optional.js';
|
|
13
12
|
export class MailClientAuthConfig {
|
|
14
13
|
user;
|
|
15
14
|
password;
|
|
16
15
|
}
|
|
17
16
|
__decorate([
|
|
18
|
-
|
|
17
|
+
StringProperty(),
|
|
19
18
|
__metadata("design:type", String)
|
|
20
19
|
], MailClientAuthConfig.prototype, "user", void 0);
|
|
21
20
|
__decorate([
|
|
22
|
-
|
|
21
|
+
StringProperty(),
|
|
23
22
|
__metadata("design:type", String)
|
|
24
23
|
], MailClientAuthConfig.prototype, "password", void 0);
|
|
25
24
|
export class MailClientConfig {
|
|
@@ -30,11 +29,11 @@ export class MailClientConfig {
|
|
|
30
29
|
auth;
|
|
31
30
|
}
|
|
32
31
|
__decorate([
|
|
33
|
-
|
|
32
|
+
StringProperty(),
|
|
34
33
|
__metadata("design:type", String)
|
|
35
34
|
], MailClientConfig.prototype, "host", void 0);
|
|
36
35
|
__decorate([
|
|
37
|
-
|
|
36
|
+
NumberProperty(),
|
|
38
37
|
__metadata("design:type", Number)
|
|
39
38
|
], MailClientConfig.prototype, "port", void 0);
|
|
40
39
|
__decorate([
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PgTableFromType } from './drizzle/schema-converter.js';
|
|
2
|
+
import type { EntityType } from './entity.js';
|
|
3
|
+
export declare class DatabaseSchema<Name extends string> {
|
|
4
|
+
readonly name: Name;
|
|
5
|
+
constructor(name: Name);
|
|
6
|
+
getTable<T extends EntityType>(type: T): PgTableFromType<Name, T>;
|
|
7
|
+
}
|
|
8
|
+
export declare function databaseSchema<Name extends string>(name: Name): DatabaseSchema<Name>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getDrizzleTableFromType } from './drizzle/schema-converter.js';
|
|
2
|
+
export class DatabaseSchema {
|
|
3
|
+
name;
|
|
4
|
+
constructor(name) {
|
|
5
|
+
this.name = name;
|
|
6
|
+
}
|
|
7
|
+
getTable(type) {
|
|
8
|
+
return getDrizzleTableFromType(this.name, type);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function databaseSchema(name) {
|
|
12
|
+
return new DatabaseSchema(name);
|
|
13
|
+
}
|
package/orm/decorators.d.ts
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
+
export type OrmTableReflectionData = {
|
|
2
|
+
name?: string;
|
|
3
|
+
unique?: UniqueReflectionData[];
|
|
4
|
+
};
|
|
5
|
+
export type OrmColumnReflectionData = {
|
|
6
|
+
name?: string;
|
|
7
|
+
primaryKey?: boolean;
|
|
8
|
+
unique?: UniqueReflectionData;
|
|
9
|
+
uuid?: {
|
|
10
|
+
defaultRandom?: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type UniqueReflectionData = {
|
|
14
|
+
name?: string;
|
|
15
|
+
columns?: string[];
|
|
16
|
+
options?: {
|
|
17
|
+
nulls?: 'distinct' | 'not distinct';
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function createTableDecorator(data?: OrmTableReflectionData): ClassDecorator;
|
|
21
|
+
export declare function createColumnDecorator(data?: OrmColumnReflectionData): PropertyDecorator;
|
|
22
|
+
export declare function createTableAndColumnDecorator(data?: OrmColumnReflectionData): ClassDecorator & PropertyDecorator;
|
|
23
|
+
export declare function Column(options: OrmColumnReflectionData): PropertyDecorator;
|
|
1
24
|
export declare function PrimaryKey(): PropertyDecorator;
|
|
25
|
+
export declare function Unique(name?: string, options?: UniqueReflectionData['options']): PropertyDecorator;
|
|
26
|
+
export declare function Unique(name: string | undefined, columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
|
|
27
|
+
export {};
|