@tstdl/base 0.92.59 → 0.92.62
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/authentication/models/authentication-credentials.model.js +7 -2
- package/authentication/models/authentication-session.model.js +7 -2
- package/authentication/server/drizzle/{0000_known_proemial_gods.sql → 0000_calm_warlock.sql} +3 -3
- package/authentication/server/drizzle/meta/0000_snapshot.json +7 -7
- package/authentication/server/drizzle/meta/_journal.json +2 -2
- package/document-management/models/document-collection.model.js +2 -2
- package/mail/drizzle/{0000_empty_jubilee.sql → 0000_previous_malcolm_colcord.sql} +1 -1
- package/mail/drizzle/meta/0000_snapshot.json +3 -3
- package/mail/drizzle/meta/_journal.json +2 -2
- package/mail/models/mail-log.model.js +7 -2
- package/orm/decorators.d.ts +3 -0
- package/orm/decorators.js +5 -1
- package/orm/server/drizzle/schema-converter.d.ts +1 -1
- package/orm/server/drizzle/schema-converter.js +5 -3
- package/package.json +2 -2
|
@@ -7,14 +7,15 @@ 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 { Table } from '../../orm/decorators.js';
|
|
10
11
|
import { Entity, Unique } from '../../orm/index.js';
|
|
11
12
|
import { Integer, StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
12
|
-
|
|
13
|
+
let AuthenticationCredentials = class AuthenticationCredentials extends Entity {
|
|
13
14
|
subject;
|
|
14
15
|
hashVersion;
|
|
15
16
|
salt;
|
|
16
17
|
hash;
|
|
17
|
-
}
|
|
18
|
+
};
|
|
18
19
|
__decorate([
|
|
19
20
|
StringProperty(),
|
|
20
21
|
Unique(),
|
|
@@ -32,3 +33,7 @@ __decorate([
|
|
|
32
33
|
Uint8ArrayProperty(),
|
|
33
34
|
__metadata("design:type", Uint8Array)
|
|
34
35
|
], AuthenticationCredentials.prototype, "hash", void 0);
|
|
36
|
+
AuthenticationCredentials = __decorate([
|
|
37
|
+
Table('credentials')
|
|
38
|
+
], AuthenticationCredentials);
|
|
39
|
+
export { AuthenticationCredentials };
|
|
@@ -7,17 +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 { Table } from '../../orm/decorators.js';
|
|
10
11
|
import { Entity } from '../../orm/entity.js';
|
|
11
12
|
import { Timestamp } from '../../orm/types.js';
|
|
12
13
|
import { Integer, StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
13
|
-
|
|
14
|
+
let AuthenticationSession = class AuthenticationSession extends Entity {
|
|
14
15
|
subject;
|
|
15
16
|
begin;
|
|
16
17
|
end;
|
|
17
18
|
refreshTokenHashVersion;
|
|
18
19
|
refreshTokenSalt;
|
|
19
20
|
refreshTokenHash;
|
|
20
|
-
}
|
|
21
|
+
};
|
|
21
22
|
__decorate([
|
|
22
23
|
StringProperty(),
|
|
23
24
|
__metadata("design:type", String)
|
|
@@ -42,3 +43,7 @@ __decorate([
|
|
|
42
43
|
Uint8ArrayProperty(),
|
|
43
44
|
__metadata("design:type", Uint8Array)
|
|
44
45
|
], AuthenticationSession.prototype, "refreshTokenHash", void 0);
|
|
46
|
+
AuthenticationSession = __decorate([
|
|
47
|
+
Table('session')
|
|
48
|
+
], AuthenticationSession);
|
|
49
|
+
export { AuthenticationSession };
|
package/authentication/server/drizzle/{0000_known_proemial_gods.sql → 0000_calm_warlock.sql}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
CREATE TABLE "authentication"."
|
|
1
|
+
CREATE TABLE "authentication"."credentials" (
|
|
2
2
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
3
|
"subject" text NOT NULL,
|
|
4
4
|
"hash_version" integer NOT NULL,
|
|
@@ -9,10 +9,10 @@ CREATE TABLE "authentication"."authentication_credentials" (
|
|
|
9
9
|
"create_timestamp" timestamp with time zone NOT NULL,
|
|
10
10
|
"delete_timestamp" timestamp with time zone,
|
|
11
11
|
"attributes" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
12
|
-
CONSTRAINT "
|
|
12
|
+
CONSTRAINT "credentials_subject_unique" UNIQUE("subject")
|
|
13
13
|
);
|
|
14
14
|
--> statement-breakpoint
|
|
15
|
-
CREATE TABLE "authentication"."
|
|
15
|
+
CREATE TABLE "authentication"."session" (
|
|
16
16
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
17
17
|
"subject" text NOT NULL,
|
|
18
18
|
"begin" timestamp with time zone NOT NULL,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "b41cc4f0-eadb-406c-a969-a21f01b60268",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
6
6
|
"tables": {
|
|
7
|
-
"authentication.
|
|
8
|
-
"name": "
|
|
7
|
+
"authentication.credentials": {
|
|
8
|
+
"name": "credentials",
|
|
9
9
|
"schema": "authentication",
|
|
10
10
|
"columns": {
|
|
11
11
|
"id": {
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"foreignKeys": {},
|
|
76
76
|
"compositePrimaryKeys": {},
|
|
77
77
|
"uniqueConstraints": {
|
|
78
|
-
"
|
|
79
|
-
"name": "
|
|
78
|
+
"credentials_subject_unique": {
|
|
79
|
+
"name": "credentials_subject_unique",
|
|
80
80
|
"nullsNotDistinct": false,
|
|
81
81
|
"columns": [
|
|
82
82
|
"subject"
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"checkConstraints": {},
|
|
88
88
|
"isRLSEnabled": false
|
|
89
89
|
},
|
|
90
|
-
"authentication.
|
|
91
|
-
"name": "
|
|
90
|
+
"authentication.session": {
|
|
91
|
+
"name": "session",
|
|
92
92
|
"schema": "authentication",
|
|
93
93
|
"columns": {
|
|
94
94
|
"id": {
|
|
@@ -4,11 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
import { Table } from '../../orm/decorators.js';
|
|
7
8
|
import { Entity } from '../../orm/entity.js';
|
|
8
|
-
import { Class } from '../../schema/index.js';
|
|
9
9
|
let DocumentCollection = class DocumentCollection extends Entity {
|
|
10
10
|
};
|
|
11
11
|
DocumentCollection = __decorate([
|
|
12
|
-
|
|
12
|
+
Table()
|
|
13
13
|
], DocumentCollection);
|
|
14
14
|
export { DocumentCollection };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "f8cdba37-11b9-477a-9f5a-5ef4b5026011",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
6
6
|
"tables": {
|
|
7
|
-
"mail.
|
|
8
|
-
"name": "
|
|
7
|
+
"mail.log": {
|
|
8
|
+
"name": "log",
|
|
9
9
|
"schema": "mail",
|
|
10
10
|
"columns": {
|
|
11
11
|
"id": {
|
|
@@ -7,15 +7,16 @@ 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 { Table } from '../../orm/decorators.js';
|
|
10
11
|
import { Entity, Json, Timestamp } from '../../orm/index.js';
|
|
11
12
|
import { StringProperty } from '../../schema/index.js';
|
|
12
|
-
|
|
13
|
+
let MailLog = class MailLog extends Entity {
|
|
13
14
|
timestamp;
|
|
14
15
|
template;
|
|
15
16
|
data;
|
|
16
17
|
sendResult;
|
|
17
18
|
errors;
|
|
18
|
-
}
|
|
19
|
+
};
|
|
19
20
|
__decorate([
|
|
20
21
|
Timestamp(),
|
|
21
22
|
__metadata("design:type", Number)
|
|
@@ -36,3 +37,7 @@ __decorate([
|
|
|
36
37
|
StringProperty({ array: true, nullable: true }),
|
|
37
38
|
__metadata("design:type", Object)
|
|
38
39
|
], MailLog.prototype, "errors", void 0);
|
|
40
|
+
MailLog = __decorate([
|
|
41
|
+
Table('log')
|
|
42
|
+
], MailLog);
|
|
43
|
+
export { MailLog };
|
package/orm/decorators.d.ts
CHANGED
|
@@ -47,6 +47,9 @@ export declare function PrimaryKey(): PropertyDecorator;
|
|
|
47
47
|
export declare function References(type: () => EntityType): PropertyDecorator;
|
|
48
48
|
export declare function Encrypted(): PropertyDecorator;
|
|
49
49
|
export declare function Embedded(type: AbstractConstructor, options?: TypedOmit<NonNullable<OrmColumnReflectionData['embedded']>, 'type'>): PropertyDecorator;
|
|
50
|
+
export declare function Table(options?: string | {
|
|
51
|
+
name: string;
|
|
52
|
+
}): ClassDecorator;
|
|
50
53
|
export declare function Unique(name?: string, options?: UniqueReflectionData['options']): PropertyDecorator;
|
|
51
54
|
export declare function Unique(name: string | undefined, columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
|
|
52
55
|
export declare function Unique(columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
|
package/orm/decorators.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createClassDecorator, createDecorator, createPropertyDecorator } from '../reflection/utils.js';
|
|
2
2
|
import { Property } from '../schema/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { filterUndefinedObjectProperties } from '../utils/object/object.js';
|
|
4
|
+
import { assertNotArrayPass, isArray, isString } from '../utils/type-guards.js';
|
|
4
5
|
export function createTableDecorator(data) {
|
|
5
6
|
return createClassDecorator({ data: { orm: data }, mergeData: true });
|
|
6
7
|
}
|
|
@@ -27,6 +28,9 @@ export function Embedded(type, options) {
|
|
|
27
28
|
include: [Property(type), createColumnDecorator({ embedded: { type, ...options } })]
|
|
28
29
|
});
|
|
29
30
|
}
|
|
31
|
+
export function Table(options) {
|
|
32
|
+
return createTableDecorator(filterUndefinedObjectProperties({ name: isString(options) ? options : options?.name }));
|
|
33
|
+
}
|
|
30
34
|
export function Unique(nameOrColumns, columnsOrOptions, options) {
|
|
31
35
|
if (isArray(nameOrColumns)) {
|
|
32
36
|
return createTableDecorator({ unique: [{ columns: nameOrColumns, options: assertNotArrayPass(columnsOrOptions) }] });
|
|
@@ -8,7 +8,7 @@ type ConverterContext = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare const getDrizzleTableFromType: typeof _getDrizzleTableFromType;
|
|
10
10
|
export declare function getColumnDefinitions(table: PgTableWithColumns<any>): ColumnDefinition[];
|
|
11
|
-
export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, schemaName: S
|
|
11
|
+
export declare function _getDrizzleTableFromType<T extends EntityType, S extends string>(type: T, schemaName: S): PgTableFromType<S, T>;
|
|
12
12
|
export declare function registerEnum(enumeration: Enumeration, name: string): void;
|
|
13
13
|
export declare function getPgEnum(schema: string | PgSchema, enumeration: Enumeration, context?: ConverterContext): PgEnum<[string, ...string[]]>;
|
|
14
14
|
export {};
|
|
@@ -25,11 +25,12 @@ const columnDefinitionsSymbol = Symbol('columnDefinitions');
|
|
|
25
25
|
export function getColumnDefinitions(table) {
|
|
26
26
|
return table[columnDefinitionsSymbol];
|
|
27
27
|
}
|
|
28
|
-
export function _getDrizzleTableFromType(type, schemaName
|
|
28
|
+
export function _getDrizzleTableFromType(type, schemaName) {
|
|
29
29
|
const metadata = reflectionRegistry.getMetadata(type);
|
|
30
30
|
assertDefined(metadata, `Type ${type.name} does not have reflection metadata.`);
|
|
31
31
|
const dbSchema = getDbSchema(schemaName);
|
|
32
32
|
const tableReflectionData = metadata.data.tryGet('orm');
|
|
33
|
+
const tableName = tableReflectionData?.name ?? getDefaultTableName(type);
|
|
33
34
|
const columnDefinitions = getPostgresColumnEntries(type, tableName, dbSchema);
|
|
34
35
|
function getColumn(table, propertyName) {
|
|
35
36
|
return assertDefinedPass(table[propertyName], `Property "${propertyName}" does not exist on ${type.name}`);
|
|
@@ -102,11 +103,12 @@ function getPostgresColumnEntries(type, tableName, dbSchema, path = new JsonPath
|
|
|
102
103
|
return decodeText(decrypted);
|
|
103
104
|
}
|
|
104
105
|
: (value) => value;
|
|
106
|
+
const prefixedColumnName = [prefix, columnName].join('');
|
|
105
107
|
return [
|
|
106
108
|
{
|
|
107
|
-
name: toCamelCase(
|
|
109
|
+
name: toCamelCase(prefixedColumnName),
|
|
108
110
|
objectPath,
|
|
109
|
-
type: getPostgresColumn(
|
|
111
|
+
type: getPostgresColumn(toSnakeCase(prefixedColumnName), dbSchema, schema, columnReflectionData ?? {}, { type, property }),
|
|
110
112
|
reflectionData: columnReflectionData,
|
|
111
113
|
dereferenceObjectPath: compileDereferencer(objectPath, { optional: true }),
|
|
112
114
|
toDatabase,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.62",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"concurrently": "9.1",
|
|
148
148
|
"drizzle-kit": "0.30",
|
|
149
149
|
"eslint": "9.20",
|
|
150
|
-
"globals": "
|
|
150
|
+
"globals": "16.0",
|
|
151
151
|
"tsc-alias": "1.8",
|
|
152
152
|
"typescript": "5.7"
|
|
153
153
|
},
|