@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.
Files changed (77) hide show
  1. package/.eslintrc.json +5 -1
  2. package/authentication/models/authentication-credentials.model.js +10 -10
  3. package/authentication/models/authentication-session.model.d.ts +2 -2
  4. package/authentication/models/authentication-session.model.js +16 -16
  5. package/authentication/models/init-secret-reset-data.model.js +3 -3
  6. package/authentication/models/token-payload-base.model.d.ts +4 -4
  7. package/authentication/models/token-payload-base.model.js +12 -12
  8. package/{reflection/reflection-data-map.d.ts → data-structures/context-data-map.d.ts} +3 -2
  9. package/{reflection/reflection-data-map.js → data-structures/context-data-map.js} +13 -6
  10. package/data-structures/index.d.ts +1 -0
  11. package/data-structures/index.js +1 -0
  12. package/examples/api/basic-overview.js +2 -2
  13. package/examples/api/custom-authentication.js +3 -3
  14. package/examples/orm/drizzle.config.d.ts +2 -0
  15. package/examples/orm/drizzle.config.js +5 -0
  16. package/examples/orm/schemas.d.ts +3 -0
  17. package/examples/orm/schemas.js +4 -0
  18. package/examples/orm/test.js +10 -0
  19. package/examples/orm/user.model.d.ts +9 -0
  20. package/examples/orm/user.model.js +39 -0
  21. package/key-value-store/index.d.ts +0 -1
  22. package/key-value-store/index.js +0 -1
  23. package/key-value-store/key-value.store.d.ts +9 -10
  24. package/key-value-store/mongo/mongo-key-value.store.js +2 -1
  25. package/mail/mail.client.js +5 -6
  26. package/orm/database-schema.d.ts +8 -0
  27. package/orm/database-schema.js +13 -0
  28. package/orm/decorators.d.ts +26 -0
  29. package/orm/decorators.js +21 -2
  30. package/orm/drizzle/schema-converter.d.ts +19 -0
  31. package/orm/drizzle/schema-converter.js +116 -0
  32. package/orm/entity.d.ts +6 -2
  33. package/orm/entity.js +9 -9
  34. package/orm/index.d.ts +1 -2
  35. package/orm/index.js +1 -2
  36. package/orm/repository.d.ts +27 -24
  37. package/orm/repository.js +124 -7
  38. package/orm/schemas/index.d.ts +1 -0
  39. package/orm/schemas/index.js +1 -0
  40. package/orm/schemas/uuid.d.ts +11 -0
  41. package/orm/schemas/uuid.js +16 -0
  42. package/orm/types.d.ts +20 -7
  43. package/orm/types.js +3 -5
  44. package/package.json +7 -4
  45. package/reflection/registry.d.ts +9 -6
  46. package/reflection/registry.js +25 -14
  47. package/schema/decorators/property.d.ts +2 -2
  48. package/schema/decorators/types.d.ts +1 -0
  49. package/schema/schema.d.ts +1 -1
  50. package/schema/schemas/array.d.ts +6 -3
  51. package/schema/schemas/array.js +9 -4
  52. package/schema/schemas/deferred.d.ts +12 -0
  53. package/schema/schemas/deferred.js +23 -0
  54. package/schema/schemas/index.d.ts +1 -0
  55. package/schema/schemas/index.js +1 -0
  56. package/schema/schemas/number.d.ts +5 -0
  57. package/schema/schemas/number.js +8 -1
  58. package/schema/schemas/string.d.ts +4 -1
  59. package/schema/schemas/string.js +8 -2
  60. package/schema/schemas/uint8-array.d.ts +3 -2
  61. package/schema/schemas/uint8-array.js +8 -5
  62. package/templates/resolvers/file.template-resolver.d.ts +1 -2
  63. package/templates/resolvers/file.template-resolver.js +2 -2
  64. package/templates/resolvers/jsx.template-resolver.d.ts +1 -3
  65. package/templates/resolvers/jsx.template-resolver.js +3 -7
  66. package/templates/template.model.d.ts +1 -1
  67. package/templates/template.model.js +5 -5
  68. package/utils/math.d.ts +11 -1
  69. package/utils/math.js +28 -0
  70. package/utils/string/index.d.ts +1 -0
  71. package/utils/string/index.js +1 -0
  72. package/utils/string/snake-case.d.ts +1 -0
  73. package/utils/string/snake-case.js +4 -0
  74. package/orm/schema-converter.d.ts +0 -99
  75. package/orm/schema-converter.js +0 -74
  76. package/orm/schema.d.ts +0 -3
  77. /package/{orm/schema.js → examples/orm/test.d.ts} +0 -0
@@ -1,99 +0,0 @@
1
- import { boolean, doublePrecision, text, type PgTableWithColumns } from 'drizzle-orm/pg-core';
2
- import type { GetTagMetadata, SnakeCase, Tagged } from 'type-fest';
3
- import type { Type } from '../types.js';
4
- import { BuildColumns, NotNull } from 'drizzle-orm';
5
- import type { DbSchemaStatic } from './schema.js';
6
- import { Integer } from './types.js';
7
- export declare const mySchema: import("drizzle-orm/pg-core").PgSchema<"my_schema">;
8
- export declare const colors: import("drizzle-orm/pg-core").PgEnum<["red", "green", "blue"]>;
9
- export declare const mySchemaUsers: PgTableWithColumns<{
10
- name: "users";
11
- schema: "my_schema";
12
- columns: {
13
- id: import("drizzle-orm/pg-core").PgColumn<{
14
- name: "id";
15
- tableName: "users";
16
- dataType: "string";
17
- columnType: "PgUUID";
18
- data: string;
19
- driverParam: string;
20
- notNull: false;
21
- hasDefault: false;
22
- isPrimaryKey: false;
23
- isAutoincrement: false;
24
- hasRuntimeDefault: false;
25
- enumValues: undefined;
26
- baseColumn: never;
27
- generated: undefined;
28
- }, {}, {}>;
29
- name: import("drizzle-orm/pg-core").PgColumn<{
30
- name: "name";
31
- tableName: "users";
32
- dataType: "string";
33
- columnType: "PgText";
34
- data: string;
35
- driverParam: string;
36
- notNull: false;
37
- hasDefault: false;
38
- isPrimaryKey: false;
39
- isAutoincrement: false;
40
- hasRuntimeDefault: false;
41
- enumValues: [string, ...string[]];
42
- baseColumn: never;
43
- generated: undefined;
44
- }, {}, {}>;
45
- age: import("drizzle-orm/pg-core").PgColumn<{
46
- name: "age";
47
- tableName: "users";
48
- dataType: "number";
49
- columnType: "PgInteger";
50
- data: number;
51
- driverParam: string | number;
52
- notNull: false;
53
- hasDefault: false;
54
- isPrimaryKey: false;
55
- isAutoincrement: false;
56
- hasRuntimeDefault: false;
57
- enumValues: undefined;
58
- baseColumn: never;
59
- generated: undefined;
60
- }, {}, {}>;
61
- color: import("drizzle-orm/pg-core").PgColumn<{
62
- name: "color";
63
- tableName: "users";
64
- dataType: "string";
65
- columnType: "PgEnumColumn";
66
- data: "red" | "green" | "blue";
67
- driverParam: string;
68
- notNull: false;
69
- hasDefault: true;
70
- isPrimaryKey: false;
71
- isAutoincrement: false;
72
- hasRuntimeDefault: false;
73
- enumValues: ["red", "green", "blue"];
74
- baseColumn: never;
75
- generated: undefined;
76
- }, {}, {}>;
77
- };
78
- dialect: "pg";
79
- }>;
80
- type ColumnBase<Name extends string, T> = T extends Tagged<T, 'column', any> ? GetTagMetadata<T, 'column'> : T extends string ? ReturnType<typeof text<Name, string, [string, ...string[]]>> : T extends number ? ReturnType<typeof doublePrecision<Name>> : T extends boolean ? ReturnType<typeof boolean<Name>> : never;
81
- type Column<Name extends string, T> = null extends T ? ColumnBase<Name, T> : NotNull<ColumnBase<Name, T>>;
82
- export declare function getDrizzleSchemaFromType<T extends Type & DbSchemaStatic>(type: T): PgTableWithColumns<{
83
- name: SnakeCase<T['entityName']>;
84
- schema: '';
85
- columns: BuildColumns<T['entityName'], {
86
- [P in keyof InstanceType<T>]: Column<Extract<P, string>, InstanceType<T>[P]>;
87
- }, 'pg'>;
88
- dialect: '';
89
- }>;
90
- export declare class Entity2 {
91
- id: string;
92
- }
93
- export declare class User extends Entity2 {
94
- static entityName: 'UserData';
95
- name: string;
96
- age: Integer<'age'> | null;
97
- hasAge: boolean;
98
- }
99
- export {};
@@ -1,74 +0,0 @@
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 { boolean, doublePrecision, integer, pgSchema, text, unique, uuid } from 'drizzle-orm/pg-core';
11
- import { NotSupportedError } from '../errors/not-supported.error.js';
12
- import { reflectionRegistry } from '../reflection/registry.js';
13
- import { Property } from '../schema/index.js';
14
- import { fromEntries } from '../utils/object/object.js';
15
- import { assertStringPass, isUndefined } from '../utils/type-guards.js';
16
- import { Integer } from './types.js';
17
- export const mySchema = pgSchema('my_schema');
18
- export const colors = mySchema.enum('colors', ['red', 'green', 'blue']);
19
- export const mySchemaUsers = mySchema.table('users', {
20
- id: uuid('id'),
21
- name: text('name'),
22
- age: integer(''),
23
- color: colors('color').default('red'),
24
- }, (self) => ({
25
- unq: unique().on(self.age).nullsNotDistinct().nullsNotDistinct()
26
- }));
27
- export function getDrizzleSchemaFromType(type) {
28
- const metadata = reflectionRegistry.getMetadata(type);
29
- if (isUndefined(metadata)) {
30
- throw new Error('Type does not have reflection metadata.');
31
- }
32
- const entries = [...metadata.properties].map(([property, propertyMetadata]) => [property, getPostgresColumn(assertStringPass(property), propertyMetadata.type)]);
33
- const schema = mySchema.table(type.entityName, fromEntries(entries));
34
- return schema;
35
- }
36
- function getPostgresColumn(name, type) {
37
- if (type == String) {
38
- return text(name);
39
- }
40
- if (type == Number) {
41
- return doublePrecision(name);
42
- }
43
- if (type == Boolean) {
44
- return boolean(name);
45
- }
46
- throw new NotSupportedError(`Type ${type.name} not supported`);
47
- }
48
- export class Entity2 {
49
- id;
50
- }
51
- __decorate([
52
- Property(),
53
- __metadata("design:type", String)
54
- ], Entity2.prototype, "id", void 0);
55
- export class User extends Entity2 {
56
- name;
57
- age;
58
- hasAge;
59
- }
60
- __decorate([
61
- Property(),
62
- __metadata("design:type", String)
63
- ], User.prototype, "name", void 0);
64
- __decorate([
65
- Integer(),
66
- __metadata("design:type", Object)
67
- ], User.prototype, "age", void 0);
68
- __decorate([
69
- Property(),
70
- __metadata("design:type", Boolean)
71
- ], User.prototype, "hasAge", void 0);
72
- const user = getDrizzleSchemaFromType(User);
73
- const db = null;
74
- const results = await db.select().from(user);
package/orm/schema.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export interface DbSchemaStatic {
2
- readonly entityName: string;
3
- }
File without changes