@tstdl/base 0.92.8 → 0.92.10

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 (99) hide show
  1. package/ai/ai.service.d.ts +19 -4
  2. package/ai/ai.service.js +241 -3
  3. package/ai/functions.d.ts +5 -0
  4. package/ai/functions.js +40 -0
  5. package/ai/types.d.ts +27 -0
  6. package/ai/types.js +3 -0
  7. package/document-management/index.d.ts +0 -2
  8. package/document-management/index.js +0 -2
  9. package/document-management/models/schemas.d.ts +18 -18
  10. package/document-management/models/schemas.js +1 -1
  11. package/document-management/server/index.d.ts +2 -0
  12. package/document-management/server/index.js +2 -0
  13. package/document-management/{module.d.ts → server/module.d.ts} +3 -3
  14. package/document-management/{module.js → server/module.js} +4 -4
  15. package/document-management/{services → server/services}/document-management.service.d.ts +24 -23
  16. package/document-management/{services → server/services}/document-management.service.js +12 -12
  17. package/examples/document-management/main.js +2 -2
  18. package/examples/orm/schemas.d.ts +2 -2
  19. package/examples/orm/schemas.js +1 -1
  20. package/orm/decorators.d.ts +4 -2
  21. package/orm/entity.d.ts +1 -1
  22. package/orm/index.d.ts +0 -5
  23. package/orm/index.js +0 -5
  24. package/orm/schemas/json.d.ts +2 -2
  25. package/orm/schemas/numeric-date.d.ts +2 -2
  26. package/orm/schemas/timestamp.d.ts +2 -2
  27. package/orm/schemas/uuid.d.ts +2 -2
  28. package/orm/{database-schema.d.ts → server/database-schema.d.ts} +2 -2
  29. package/orm/{database.d.ts → server/database.d.ts} +1 -1
  30. package/orm/{database.js → server/database.js} +1 -1
  31. package/orm/{drizzle → server/drizzle}/schema-converter.d.ts +6 -6
  32. package/orm/{drizzle → server/drizzle}/schema-converter.js +15 -15
  33. package/orm/server/index.d.ts +6 -0
  34. package/orm/server/index.js +6 -0
  35. package/orm/{module.d.ts → server/module.d.ts} +1 -1
  36. package/orm/{module.js → server/module.js} +3 -3
  37. package/orm/{query-converter.d.ts → server/query-converter.d.ts} +2 -2
  38. package/orm/{query-converter.js → server/query-converter.js} +3 -3
  39. package/orm/{repository.d.ts → server/repository.d.ts} +4 -4
  40. package/orm/{repository.js → server/repository.js} +7 -7
  41. package/orm/{transaction.d.ts → server/transaction.d.ts} +1 -1
  42. package/orm/{transaction.js → server/transaction.js} +1 -1
  43. package/package.json +8 -6
  44. package/reflection/registry.js +2 -2
  45. package/reflection/utils.d.ts +1 -3
  46. package/schema/decorators/index.d.ts +2 -3
  47. package/schema/decorators/index.js +1 -3
  48. package/schema/decorators/schema.d.ts +21 -0
  49. package/schema/decorators/schema.js +36 -0
  50. package/schema/decorators/types.d.ts +10 -2
  51. package/schema/decorators/utils.d.ts +7 -2
  52. package/schema/decorators/utils.js +26 -7
  53. package/schema/schema.d.ts +2 -2
  54. package/schema/schemas/any.d.ts +2 -2
  55. package/schema/schemas/array.d.ts +2 -2
  56. package/schema/schemas/bigint.d.ts +2 -2
  57. package/schema/schemas/boolean.d.ts +2 -2
  58. package/schema/schemas/date.d.ts +2 -2
  59. package/schema/schemas/defaulted.d.ts +2 -2
  60. package/schema/schemas/deferred.d.ts +2 -2
  61. package/schema/schemas/enumeration.d.ts +2 -2
  62. package/schema/schemas/function.d.ts +20 -6
  63. package/schema/schemas/function.js +58 -7
  64. package/schema/schemas/instance.d.ts +2 -2
  65. package/schema/schemas/literal.d.ts +2 -2
  66. package/schema/schemas/never.d.ts +1 -1
  67. package/schema/schemas/nullable.d.ts +2 -2
  68. package/schema/schemas/nullable.js +2 -2
  69. package/schema/schemas/number.d.ts +4 -4
  70. package/schema/schemas/object.d.ts +2 -2
  71. package/schema/schemas/object.js +7 -18
  72. package/schema/schemas/one-or-many.d.ts +2 -2
  73. package/schema/schemas/optional.d.ts +2 -2
  74. package/schema/schemas/optional.js +2 -2
  75. package/schema/schemas/readable-stream.d.ts +2 -2
  76. package/schema/schemas/regexp.d.ts +2 -2
  77. package/schema/schemas/string.d.ts +2 -2
  78. package/schema/schemas/symbol.d.ts +2 -2
  79. package/schema/schemas/uint8-array.d.ts +2 -2
  80. package/schema/schemas/union.d.ts +2 -2
  81. package/schema/schemas/unknown.d.ts +2 -2
  82. package/schema/testable.d.ts +2 -2
  83. package/schema/testable.js +9 -9
  84. package/templates/resolvers/jsx.template-resolver.js +2 -2
  85. package/types.d.ts +1 -1
  86. package/utils/object/lazy-property.d.ts +2 -2
  87. package/utils/object/object.d.ts +2 -1
  88. package/schema/decorators/property.d.ts +0 -12
  89. package/schema/decorators/property.js +0 -21
  90. /package/document-management/{drizzle → server/drizzle}/0000_wakeful_firebrand.sql +0 -0
  91. /package/document-management/{drizzle → server/drizzle}/meta/0000_snapshot.json +0 -0
  92. /package/document-management/{drizzle → server/drizzle}/meta/_journal.json +0 -0
  93. /package/document-management/{drizzle.config.d.ts → server/drizzle.config.d.ts} +0 -0
  94. /package/document-management/{drizzle.config.js → server/drizzle.config.js} +0 -0
  95. /package/document-management/{services → server/services}/index.d.ts +0 -0
  96. /package/document-management/{services → server/services}/index.js +0 -0
  97. /package/orm/{database-schema.js → server/database-schema.js} +0 -0
  98. /package/orm/{drizzle → server/drizzle}/index.d.ts +0 -0
  99. /package/orm/{drizzle → server/drizzle}/index.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import '../../polyfills.js';
2
2
  import { Application } from '../../application/application.js';
3
- import { configureDocumentManagement, migrateDocumentManagementSchema } from '../../document-management/module.js';
4
- import { DocumentManagementService } from '../../document-management/services/document-management.service.js';
3
+ import { configureDocumentManagement, migrateDocumentManagementSchema } from '../../document-management/server/module.js';
4
+ import { DocumentManagementService } from '../../document-management/server/services/document-management.service.js';
5
5
  import { injectAsync } from '../../injector/inject.js';
6
6
  import { configureS3ObjectStorage } from '../../object-storage/index.js';
7
7
  async function bootstrap() {
@@ -1,3 +1,3 @@
1
1
  import { User } from './user.model.js';
2
- export declare const mySchema: import("../../orm/database-schema.js").DatabaseSchema<"my_application">;
3
- export declare const user: import("../../orm/drizzle/schema-converter.js").PgTableFromType<"my_application", typeof User>;
2
+ export declare const mySchema: import("../../orm/server/database-schema.js").DatabaseSchema<"my_application">;
3
+ export declare const user: import("../../orm/server/drizzle/schema-converter.js").PgTableFromType<"my_application", typeof User>;
@@ -1,4 +1,4 @@
1
- import { databaseSchema } from '../../orm/database-schema.js';
1
+ import { databaseSchema } from '../../orm/server/database-schema.js';
2
2
  import { User } from './user.model.js';
3
3
  export const mySchema = databaseSchema('my_application');
4
4
  export const user = mySchema.getTable(User);
@@ -1,6 +1,7 @@
1
- import type { PgIndexMethod } from 'drizzle-orm/pg-core';
1
+ import type { LiteralUnion } from 'type-fest';
2
2
  import type { AbstractConstructor, TypedOmit } from '../types.js';
3
3
  import type { EntityType } from './entity.js';
4
+ type IndexMethod = LiteralUnion<'hash' | 'btree' | 'gist' | 'spgist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat', string>;
4
5
  export type OrmTableReflectionData = {
5
6
  name?: string;
6
7
  unique?: UniqueReflectionData[];
@@ -32,7 +33,7 @@ export type IndexReflectionData = {
32
33
  columns?: (string | [string, 'asc' | 'desc'])[];
33
34
  order?: 'asc' | 'desc';
34
35
  options?: {
35
- using?: PgIndexMethod;
36
+ using?: IndexMethod;
36
37
  unique?: boolean;
37
38
  nulls?: 'first' | 'last';
38
39
  };
@@ -48,3 +49,4 @@ export declare function Unique(name?: string, options?: UniqueReflectionData['op
48
49
  export declare function Unique(name: string | undefined, columns: [string, ...string[]], options?: UniqueReflectionData['options']): ClassDecorator;
49
50
  export declare function Index(name?: string, options?: IndexReflectionData['options']): PropertyDecorator;
50
51
  export declare function Index(name: string | undefined, columns: [string, ...string[]], options?: IndexReflectionData['options']): ClassDecorator;
52
+ export {};
package/orm/entity.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Record } from '../schema/index.js';
2
- import { Type, TypedOmit, UntaggedDeep } from '../types.js';
2
+ import type { Type, TypedOmit, UntaggedDeep } from '../types.js';
3
3
  import { Embedded, type HasDefault, type IsPrimaryKey, Json, Timestamp, Uuid } from './types.js';
4
4
  export interface EntityType<T extends Entity = Entity> extends Type<T> {
5
5
  readonly entityName?: string;
package/orm/index.d.ts CHANGED
@@ -1,8 +1,3 @@
1
- export * from './database-schema.js';
2
- export * from './database.js';
3
1
  export * from './entity.js';
4
- export * from './module.js';
5
2
  export * from './query.js';
6
- export * from './repository.js';
7
- export * from './transaction.js';
8
3
  export * from './types.js';
package/orm/index.js CHANGED
@@ -1,8 +1,3 @@
1
- export * from './database-schema.js';
2
- export * from './database.js';
3
1
  export * from './entity.js';
4
- export * from './module.js';
5
2
  export * from './query.js';
6
- export * from './repository.js';
7
- export * from './transaction.js';
8
3
  export * from './types.js';
@@ -1,9 +1,9 @@
1
1
  import { type Decorator } from '../../reflection/index.js';
2
- import { ObjectSchema, type ObjectSchemaOptions, type SchemaPropertyDecoratorOptions } from '../../schema/index.js';
2
+ import { ObjectSchema, type ObjectSchemaOptions, type SchemaDecoratorOptions } from '../../schema/index.js';
3
3
  export type JsonSchemaOptions = Pick<ObjectSchemaOptions, 'factory'>;
4
4
  export declare class JsonSchema extends ObjectSchema {
5
5
  readonly name = "Json";
6
6
  constructor(options?: JsonSchemaOptions);
7
7
  }
8
8
  export declare function json(options?: JsonSchemaOptions): JsonSchema;
9
- export declare function Json(options?: JsonSchemaOptions & SchemaPropertyDecoratorOptions): Decorator<'class' | 'property' | 'accessor'>;
9
+ export declare function Json(options?: JsonSchemaOptions & SchemaDecoratorOptions): Decorator<'class' | 'property' | 'accessor'>;
@@ -1,8 +1,8 @@
1
- import { NumberSchema, type NumberSchemaOptions, type SchemaPropertyDecorator, type SchemaPropertyDecoratorOptions, type SimpleSchemaOptions } from '../../schema/index.js';
1
+ import { NumberSchema, type NumberSchemaOptions, type SchemaPropertyDecorator, type SchemaDecoratorOptions, type SimpleSchemaOptions } from '../../schema/index.js';
2
2
  export type NumericDateSchemaOptions = SimpleSchemaOptions<number> & Pick<NumberSchemaOptions, 'minimum' | 'maximum'>;
3
3
  export declare class NumericDateSchema extends NumberSchema {
4
4
  readonly name = "NumericDate";
5
5
  constructor(options?: NumericDateSchemaOptions);
6
6
  }
7
7
  export declare function numericDate(options?: NumericDateSchemaOptions): NumericDateSchema;
8
- export declare function NumericDate(options?: NumericDateSchemaOptions & SchemaPropertyDecoratorOptions): SchemaPropertyDecorator;
8
+ export declare function NumericDate(options?: NumericDateSchemaOptions & SchemaDecoratorOptions): SchemaPropertyDecorator;
@@ -1,5 +1,5 @@
1
1
  import type { JsonPath } from '../../json-path/json-path.js';
2
- import { NumberSchema, type NumberSchemaOptions, type SchemaPropertyDecorator, type SchemaPropertyDecoratorOptions, type SchemaTestOptions, type SchemaTestResult, type SimpleSchemaOptions } from '../../schema/index.js';
2
+ import { NumberSchema, type NumberSchemaOptions, type SchemaPropertyDecorator, type SchemaDecoratorOptions, type SchemaTestOptions, type SchemaTestResult, type SimpleSchemaOptions } from '../../schema/index.js';
3
3
  export type TimestampSchemaOptions = SimpleSchemaOptions<number> & Pick<NumberSchemaOptions, 'minimum' | 'maximum'>;
4
4
  export declare class TimestampSchema extends NumberSchema {
5
5
  readonly name = "Timestamp";
@@ -7,4 +7,4 @@ export declare class TimestampSchema extends NumberSchema {
7
7
  _test(value: any, path: JsonPath, options: SchemaTestOptions): SchemaTestResult<number>;
8
8
  }
9
9
  export declare function timestamp(options?: TimestampSchemaOptions): TimestampSchema;
10
- export declare function Timestamp(options?: TimestampSchemaOptions & SchemaPropertyDecoratorOptions): SchemaPropertyDecorator;
10
+ export declare function Timestamp(options?: TimestampSchemaOptions & SchemaDecoratorOptions): SchemaPropertyDecorator;
@@ -1,4 +1,4 @@
1
- import { StringSchema, type SchemaPropertyDecorator, type SchemaPropertyDecoratorOptions } from '../../schema/index.js';
1
+ import { StringSchema, type SchemaPropertyDecorator, type SchemaDecoratorOptions } from '../../schema/index.js';
2
2
  export type UuidSchemaOptions = {
3
3
  defaultRandom?: boolean;
4
4
  };
@@ -8,4 +8,4 @@ export declare class UuidSchema extends StringSchema {
8
8
  constructor(options?: UuidSchemaOptions);
9
9
  }
10
10
  export declare function uuid(options?: UuidSchemaOptions): UuidSchema;
11
- export declare function Uuid(options?: UuidSchemaOptions & SchemaPropertyDecoratorOptions): SchemaPropertyDecorator;
11
+ export declare function Uuid(options?: UuidSchemaOptions & SchemaDecoratorOptions): SchemaPropertyDecorator;
@@ -1,7 +1,7 @@
1
1
  import type { PgEnum } from 'drizzle-orm/pg-core';
2
- import type { Enumeration, EnumerationValue, UnionToTuple } from '../types.js';
2
+ import type { Enumeration, EnumerationValue, UnionToTuple } from '../../types.js';
3
3
  import { type PgTableFromType } from './drizzle/schema-converter.js';
4
- import type { EntityType } from './entity.js';
4
+ import type { EntityType } from '../entity.js';
5
5
  export declare class DatabaseSchema<Name extends string> {
6
6
  readonly name: Name;
7
7
  constructor(name: Name);
@@ -1,5 +1,5 @@
1
1
  import { NodePgDatabase } from 'drizzle-orm/node-postgres';
2
- import { Resolvable, type resolveArgumentType } from '../injector/interfaces.js';
2
+ import { Resolvable, type resolveArgumentType } from '../../injector/interfaces.js';
3
3
  import { DatabaseArgument } from './module.js';
4
4
  export declare class Database extends NodePgDatabase<any> implements Resolvable<DatabaseArgument> {
5
5
  readonly [resolveArgumentType]?: DatabaseArgument;
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { NodePgDatabase } from 'drizzle-orm/node-postgres';
8
- import { ReplaceClass } from '../injector/decorators.js';
8
+ import { ReplaceClass } from '../../injector/decorators.js';
9
9
  let Database = class Database extends NodePgDatabase {
10
10
  };
11
11
  Database = __decorate([
@@ -1,12 +1,12 @@
1
1
  import type { BuildColumns, NotNull } from 'drizzle-orm';
2
2
  import { type PgColumnBuilder, type PgEnum, type PgSchema, type PgTableWithColumns } from 'drizzle-orm/pg-core';
3
3
  import type { CamelCase, ConditionalPick, SnakeCase } from 'type-fest';
4
- import { JsonPath } from '../../json-path/json-path.js';
5
- import { type Record } from '../../schema/index.js';
6
- import type { AbstractConstructor, Enumeration } from '../../types.js';
7
- import type { OrmColumnReflectionData } from '../decorators.js';
8
- import type { EntityType } from '../entity.js';
9
- import type { ColumnBuilder, embedded } from '../types.js';
4
+ import { JsonPath } from '../../../json-path/json-path.js';
5
+ import { type Record } from '../../../schema/index.js';
6
+ import type { AbstractConstructor, Enumeration } from '../../../types.js';
7
+ import type { OrmColumnReflectionData } from '../../decorators.js';
8
+ import type { EntityType } from '../../entity.js';
9
+ import type { ColumnBuilder, embedded } from '../../types.js';
10
10
  type Column<Name extends string, T> = null extends T ? ColumnBuilder<T, Name> : NotNull<ColumnBuilder<T, Name>>;
11
11
  type ConverterContext = {
12
12
  type: AbstractConstructor;
@@ -1,20 +1,20 @@
1
1
  import { toCamelCase, toSnakeCase } from 'drizzle-orm/casing';
2
2
  import { boolean, date, doublePrecision, index, integer, jsonb, pgSchema, text, timestamp, unique, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
3
- import { MultiKeyMap } from '../../data-structures/multi-key-map.js';
4
- import { NotSupportedError } from '../../errors/not-supported.error.js';
5
- import { JsonPath } from '../../json-path/json-path.js';
6
- import { reflectionRegistry } from '../../reflection/registry.js';
7
- import { ArraySchema, BooleanSchema, DefaultSchema, EnumerationSchema, getObjectSchema, NullableSchema, NumberSchema, ObjectSchema, OptionalSchema, StringSchema } from '../../schema/index.js';
8
- import { compareByValueSelectionToOrder, orderRest } from '../../utils/comparison.js';
9
- import { enumValues } from '../../utils/enum.js';
10
- import { memoize, memoizeSingle } from '../../utils/function/memoize.js';
11
- import { compileDereferencer } from '../../utils/object/dereference.js';
12
- import { fromEntries, objectEntries } from '../../utils/object/object.js';
13
- import { assertDefined, assertDefinedPass, isArray, isDefined, isNull, isString, isUndefined } from '../../utils/type-guards.js';
14
- import { JsonSchema } from '../schemas/json.js';
15
- import { NumericDateSchema } from '../schemas/numeric-date.js';
16
- import { TimestampSchema } from '../schemas/timestamp.js';
17
- import { UuidSchema } from '../schemas/uuid.js';
3
+ import { MultiKeyMap } from '../../../data-structures/multi-key-map.js';
4
+ import { NotSupportedError } from '../../../errors/not-supported.error.js';
5
+ import { JsonPath } from '../../../json-path/json-path.js';
6
+ import { reflectionRegistry } from '../../../reflection/registry.js';
7
+ import { ArraySchema, BooleanSchema, DefaultSchema, EnumerationSchema, getObjectSchema, NullableSchema, NumberSchema, ObjectSchema, OptionalSchema, StringSchema } from '../../../schema/index.js';
8
+ import { compareByValueSelectionToOrder, orderRest } from '../../../utils/comparison.js';
9
+ import { enumValues } from '../../../utils/enum.js';
10
+ import { memoize, memoizeSingle } from '../../../utils/function/memoize.js';
11
+ import { compileDereferencer } from '../../../utils/object/dereference.js';
12
+ import { fromEntries, objectEntries } from '../../../utils/object/object.js';
13
+ import { assertDefined, assertDefinedPass, isArray, isDefined, isNull, isString, isUndefined } from '../../../utils/type-guards.js';
14
+ import { JsonSchema } from '../../schemas/json.js';
15
+ import { NumericDateSchema } from '../../schemas/numeric-date.js';
16
+ import { TimestampSchema } from '../../schemas/timestamp.js';
17
+ import { UuidSchema } from '../../schemas/uuid.js';
18
18
  const getDbSchema = memoizeSingle(pgSchema);
19
19
  export const getDrizzleTableFromType = memoize(_getDrizzleTableFromType);
20
20
  const columnDefinitionsSymbol = Symbol('columnDefinitions');
@@ -0,0 +1,6 @@
1
+ export * from './database-schema.js';
2
+ export * from './database.js';
3
+ export * from './module.js';
4
+ export * from './query-converter.js';
5
+ export * from './repository.js';
6
+ export * from './transaction.js';
@@ -0,0 +1,6 @@
1
+ export * from './database-schema.js';
2
+ export * from './database.js';
3
+ export * from './module.js';
4
+ export * from './query-converter.js';
5
+ export * from './repository.js';
6
+ export * from './transaction.js';
@@ -3,4 +3,4 @@ export type DatabaseConfig = {
3
3
  connection: DatabaseArgument;
4
4
  };
5
5
  export type DatabaseArgument = string | PoolConfig;
6
- export declare const DATABASE_CONFIG: import("../injector/index.js").InjectionToken<DatabaseConfig, never>;
6
+ export declare const DATABASE_CONFIG: import("../../injector/index.js").InjectionToken<DatabaseConfig, never>;
@@ -1,7 +1,7 @@
1
1
  import { drizzle } from 'drizzle-orm/node-postgres';
2
- import { inject, injectionToken } from '../injector/index.js';
3
- import { Injector } from '../injector/injector.js';
4
- import { isUndefined } from '../utils/type-guards.js';
2
+ import { inject, injectionToken } from '../../injector/index.js';
3
+ import { Injector } from '../../injector/injector.js';
4
+ import { isUndefined } from '../../utils/type-guards.js';
5
5
  import { Database } from './database.js';
6
6
  export const DATABASE_CONFIG = injectionToken('EntityRepositoryConfig');
7
7
  Injector.registerSingleton(Database, {
@@ -1,5 +1,5 @@
1
1
  import { SQL } from 'drizzle-orm';
2
2
  import type { ColumnDefinition, PgTableFromType } from './drizzle/schema-converter.js';
3
- import type { EntityType } from './entity.js';
4
- import type { Query } from './query.js';
3
+ import type { EntityType } from '../entity.js';
4
+ import type { Query } from '../query.js';
5
5
  export declare function convertQuery(query: Query, table: PgTableFromType<string, EntityType>, columnDefinitionsMap: Map<string, ColumnDefinition>): SQL;
@@ -1,7 +1,7 @@
1
1
  import { and, eq, gt, gte, inArray, isNotNull, isNull, isSQLWrapper, lt, lte, ne, not, notInArray, or, SQL, sql } from 'drizzle-orm';
2
- import { NotSupportedError } from '../errors/not-supported.error.js';
3
- import { hasOwnProperty, objectEntries } from '../utils/object/object.js';
4
- import { assertDefinedPass, isPrimitive, isRegExp, isString, isUndefined } from '../utils/type-guards.js';
2
+ import { NotSupportedError } from '../../errors/not-supported.error.js';
3
+ import { hasOwnProperty, objectEntries } from '../../utils/object/object.js';
4
+ import { assertDefinedPass, isPrimitive, isRegExp, isString, isUndefined } from '../../utils/type-guards.js';
5
5
  const sqlTrue = sql `true`;
6
6
  export function convertQuery(query, table, columnDefinitionsMap) {
7
7
  if (query instanceof SQL) {
@@ -1,12 +1,12 @@
1
1
  import { SQL } from 'drizzle-orm';
2
2
  import { PgTransaction as DrizzlePgTransaction, PgColumn, PgInsertValue, PgQueryResultHKT, PgUpdateSetSource } from 'drizzle-orm/pg-core';
3
3
  import { PartialDeep } from 'type-fest';
4
- import { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
5
- import type { DeepPartial, OneOrMany, Paths, Record, Type, TypedOmit, UntaggedDeep } from '../types.js';
4
+ import { Resolvable, resolveArgumentType } from '../../injector/interfaces.js';
5
+ import type { DeepPartial, OneOrMany, Paths, Record, Type, TypedOmit, UntaggedDeep } from '../../types.js';
6
6
  import { Database } from './database.js';
7
7
  import { ColumnDefinition, type PgTableFromType } from './drizzle/schema-converter.js';
8
- import type { Entity, EntityMetadata, EntityMetadataAttributes, EntityType, NewEntity } from './entity.js';
9
- import type { Query } from './query.js';
8
+ import type { Entity, EntityMetadata, EntityMetadataAttributes, EntityType, NewEntity } from '../entity.js';
9
+ import type { Query } from '../query.js';
10
10
  import { Transaction, TransactionConfig } from './transaction.js';
11
11
  type PgTransaction = DrizzlePgTransaction<PgQueryResultHKT, Record, Record>;
12
12
  export declare const repositoryType: unique symbol;
@@ -10,13 +10,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  import { count, eq, inArray, sql } from 'drizzle-orm';
12
12
  import { PgTransaction as DrizzlePgTransaction } from 'drizzle-orm/pg-core';
13
- import { NotFoundError } from '../errors/not-found.error.js';
14
- import { Singleton } from '../injector/decorators.js';
15
- import { inject, injectArgument } from '../injector/inject.js';
16
- import { Schema } from '../schema/schema.js';
17
- import { toArray } from '../utils/array/array.js';
18
- import { fromDeepObjectEntries } from '../utils/object/object.js';
19
- import { assertDefinedPass, assertNotNullPass, isNotNull, isUndefined } from '../utils/type-guards.js';
13
+ import { NotFoundError } from '../../errors/not-found.error.js';
14
+ import { Singleton } from '../../injector/decorators.js';
15
+ import { inject, injectArgument } from '../../injector/inject.js';
16
+ import { Schema } from '../../schema/schema.js';
17
+ import { toArray } from '../../utils/array/array.js';
18
+ import { fromDeepObjectEntries } from '../../utils/object/object.js';
19
+ import { assertDefinedPass, assertNotNullPass, isNotNull, isUndefined } from '../../utils/type-guards.js';
20
20
  import { Database } from './database.js';
21
21
  import { getColumnDefinitions, getDrizzleTableFromType } from './drizzle/schema-converter.js';
22
22
  import { convertQuery } from './query-converter.js';
@@ -1,4 +1,4 @@
1
- import { DeferredPromise } from '../promise/deferred-promise.js';
1
+ import { DeferredPromise } from '../../promise/deferred-promise.js';
2
2
  import type { PgTransaction as DrizzlePgTransaction, PgTransactionConfig } from 'drizzle-orm/pg-core';
3
3
  import type { Database } from './database.js';
4
4
  type PgTransaction = DrizzlePgTransaction<any, any, any>;
@@ -1,4 +1,4 @@
1
- import { DeferredPromise } from '../promise/deferred-promise.js';
1
+ import { DeferredPromise } from '../../promise/deferred-promise.js';
2
2
  import { Subject } from 'rxjs';
3
3
  export class Transaction {
4
4
  #afterCommitSubject = new Subject();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.8",
3
+ "version": "0.92.10",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,8 +13,8 @@
13
13
  "build:production:copy-files": "cp package.json .eslintrc.json tsconfig.server.json dist/ && cp tsconfig.base.json dist/tsconfig.json && npm run copy:document-management",
14
14
  "build:docs": "typedoc",
15
15
  "build:docs:watch": "typedoc --watch",
16
- "generate:drizzle": "drizzle-kit generate --config dist/document-management/drizzle.config.js",
17
- "copy:document-management": "rm -rf ./dist/document-management/drizzle && cp -r ./source/document-management/drizzle ./dist/document-management/",
16
+ "generate:drizzle": "drizzle-kit generate --config dist/document-management/server/drizzle.config.js",
17
+ "copy:document-management": "rm -rf ./dist/document-management/server/drizzle && cp -r ./source/document-management/server/drizzle ./dist/document-management/server/",
18
18
  "lint": "eslint --config .eslintrc.json --cache source/",
19
19
  "pub": "npm run build:production && rm -vf dist/test* && rm -vrf dist/tools/ && npm publish dist/",
20
20
  "tsc:watch": "tsc --watch",
@@ -46,6 +46,7 @@
46
46
  "./disposable": "./disposable/index.js",
47
47
  "./distributed-loop": "./distributed-loop/index.js",
48
48
  "./dom": "./dom/index.js",
49
+ "./document-management": "./document-management/index.js",
49
50
  "./enumerable": "./enumerable/index.js",
50
51
  "./errors": "./errors/index.js",
51
52
  "./file": "./file/index.js",
@@ -72,6 +73,7 @@
72
73
  "./object-storage": "./object-storage/index.js",
73
74
  "./openid-connect": "./openid-connect/index.js",
74
75
  "./orm": "./orm/index.js",
76
+ "./orm/server": "./orm/server/index.js",
75
77
  "./password": "./password/index.js",
76
78
  "./pdf": "./pdf/index.js",
77
79
  "./pool": "./pool/index.js",
@@ -119,11 +121,11 @@
119
121
  "luxon": "^3.5",
120
122
  "reflect-metadata": "^0.2",
121
123
  "rxjs": "^7.8",
122
- "type-fest": "4.31"
124
+ "type-fest": "4.32"
123
125
  },
124
126
  "devDependencies": {
125
127
  "@mxssfd/typedoc-theme": "1.1",
126
- "@stylistic/eslint-plugin": "2.12",
128
+ "@stylistic/eslint-plugin": "2.13",
127
129
  "@types/chroma-js": "2.4",
128
130
  "@types/koa__router": "12.0",
129
131
  "@types/luxon": "3.4",
@@ -148,7 +150,7 @@
148
150
  "@elastic/elasticsearch": "^8.17",
149
151
  "@google/generative-ai": "^0.21",
150
152
  "@koa/router": "^13.1",
151
- "@tstdl/angular": "^0.91",
153
+ "@tstdl/angular": "^0.92",
152
154
  "@zxcvbn-ts/core": "^3.0",
153
155
  "@zxcvbn-ts/language-common": "^3.0",
154
156
  "@zxcvbn-ts/language-de": "^3.0",
@@ -40,13 +40,13 @@ export class ReflectionRegistry {
40
40
  return (data.static ? metadata.staticMethods : metadata.methods).get(data.methodKey);
41
41
  }
42
42
  else if (data.type == 'method-parameter') {
43
- return (data.static ? metadata.staticMethods : metadata.methods).get(data.methodKey);
43
+ return (data.static ? metadata.staticMethods : metadata.methods).get(data.methodKey).parameters.at(data.index);
44
44
  }
45
45
  else if (data.type == 'constructor-parameter') { // eslint-disable-line @typescript-eslint/no-unnecessary-condition
46
46
  if (isUndefined(metadata.parameters)) {
47
47
  throw new Error('Constructor parameters are not available. (missing decoration?)');
48
48
  }
49
- return metadata.parameters[data.index];
49
+ return metadata.parameters.at(data.index);
50
50
  }
51
51
  throw new Error(`Unknown DecoratorData type ${data.type}`);
52
52
  }
@@ -1,8 +1,6 @@
1
1
  import type { AbstractConstructor, Constructor, ConstructorParameterDecorator, OneOrMany, PropertiesOfType, Record, TypedOmit } from '../types.js';
2
2
  import type { CombinedDecoratorParameters, Decorator, DecoratorData, DecoratorHandler, DecoratorMetadata, DecoratorType, DecoratorUnion } from './types.js';
3
- export type CreateDecoratorTypeOptions = {
4
- [P in DecoratorType]?: boolean;
5
- };
3
+ export type CreateDecoratorTypeOptions = Partial<Record<DecoratorType, boolean>>;
6
4
  export type CreateDecoratorOptions = {
7
5
  data?: Record<string | symbol>;
8
6
  /** Merge data values instead of replacing them (requires them to be objects, arrays, maps or sets) */
@@ -1,4 +1,3 @@
1
1
  export * from './class.js';
2
- export * from './property.js';
3
- export * from './types.js';
4
- export * from './utils.js';
2
+ export * from './schema.js';
3
+ export type * from './types.js';
@@ -1,4 +1,2 @@
1
1
  export * from './class.js';
2
- export * from './property.js';
3
- export * from './types.js';
4
- export * from './utils.js';
2
+ export * from './schema.js';
@@ -0,0 +1,21 @@
1
+ import type { SetRequired } from 'type-fest';
2
+ import { type Decorator } from '../../reflection/index.js';
3
+ import type { TypedOmit } from '../../types.js';
4
+ import type { SchemaTestable } from '../schema.js';
5
+ import type { CombinedSchemaDecorator, SchemaReflectionData, SchemaTestableProvider } from './types.js';
6
+ export type SchemaDecoratorOptions = SchemaReflectionData;
7
+ export type SchemaDecoratorOptionsWithRequiredSchema = SetRequired<SchemaReflectionData, 'schema'>;
8
+ export type SchemaDecoratorOptionsWithoutSchema = TypedOmit<SchemaReflectionData, 'schema'>;
9
+ export declare function createSchemaDecorator(data?: SchemaReflectionData): CombinedSchemaDecorator;
10
+ export declare function SchemaDecorator(schema: SchemaTestable, options?: SchemaDecoratorOptionsWithoutSchema): CombinedSchemaDecorator;
11
+ export declare function SchemaDecorator(options: SchemaDecoratorOptionsWithRequiredSchema): CombinedSchemaDecorator;
12
+ export declare function Parameter(name: string, schema: SchemaTestable, options?: SchemaDecoratorOptionsWithoutSchema): Decorator<'parameter'>;
13
+ export declare function Parameter(name: string, options: SchemaDecoratorOptions): Decorator<'parameter'>;
14
+ export declare const Property: typeof SchemaDecorator;
15
+ /**
16
+ * @deprecated use @Property instead
17
+ * @param schemaTestableProvider
18
+ * @param options
19
+ * @returns
20
+ */
21
+ export declare function PropertySchema(schemaTestableProvider: SchemaTestableProvider, options?: SchemaDecoratorOptionsWithoutSchema): CombinedSchemaDecorator;
@@ -0,0 +1,36 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { createDecorator } from '../../reflection/index.js';
3
+ import { filterUndefinedObjectProperties } from '../../utils/object/object.js';
4
+ import { isSchemaTestable } from '../testable.js';
5
+ export function createSchemaDecorator(data = {}) {
6
+ return createDecorator({
7
+ property: true,
8
+ accessor: true,
9
+ method: true,
10
+ parameter: true,
11
+ data: { schema: filterUndefinedObjectProperties(data) },
12
+ mergeData: true
13
+ });
14
+ }
15
+ export function SchemaDecorator(schemaOrOptions, optionsOrNothing) {
16
+ if (isSchemaTestable(schemaOrOptions)) {
17
+ return createSchemaDecorator({ ...optionsOrNothing, schema: () => schemaOrOptions });
18
+ }
19
+ return createSchemaDecorator(schemaOrOptions);
20
+ }
21
+ export function Parameter(name, schemaOrOptions, optionsOrNothing) {
22
+ if (isSchemaTestable(schemaOrOptions)) {
23
+ return createSchemaDecorator({ ...optionsOrNothing, schema: () => schemaOrOptions, parameter: { name } });
24
+ }
25
+ return createSchemaDecorator({ ...schemaOrOptions, parameter: { name } });
26
+ }
27
+ export const Property = SchemaDecorator;
28
+ /**
29
+ * @deprecated use @Property instead
30
+ * @param schemaTestableProvider
31
+ * @param options
32
+ * @returns
33
+ */
34
+ export function PropertySchema(schemaTestableProvider, options) {
35
+ return SchemaDecorator({ ...options, schema: schemaTestableProvider });
36
+ }
@@ -3,14 +3,22 @@ import type { SchemaOptions, SchemaTestable } from '../schema.js';
3
3
  import type { ObjectSchemaFactory, ObjectSchemaOptions } from '../schemas/object.js';
4
4
  export type SchemaClassDecorator = Decorator<'class'>;
5
5
  export type SchemaPropertyDecorator = Decorator<'property' | 'accessor'>;
6
+ export type SchemaMethodDecorator = Decorator<'method'>;
7
+ export type CombinedSchemaDecorator = Decorator<'property' | 'accessor' | 'parameter'>;
6
8
  export type SchemaTypeReflectionData = Partial<Pick<ObjectSchemaOptions, 'mask' | 'unknownProperties' | 'unknownPropertiesKey' | 'description' | 'example'>> & {
7
9
  schema?: SchemaTestable;
8
10
  factory?: ObjectSchemaFactory<any>;
9
11
  };
10
- export type SchemaTestableProvider = (data: SchemaPropertyReflectionData) => SchemaTestable;
11
- export type SchemaPropertyReflectionData = Partial<Pick<SchemaOptions<any>, 'description' | 'example'>> & {
12
+ export type SchemaTestableProvider = (data: SchemaReflectionData) => SchemaTestable;
13
+ export type SchemaReflectionData = Partial<Pick<SchemaOptions<any>, 'description' | 'example'>> & {
12
14
  schema?: SchemaTestableProvider;
13
15
  array?: boolean;
14
16
  optional?: boolean;
15
17
  nullable?: boolean;
18
+ method?: {
19
+ returnType?: SchemaTestableProvider;
20
+ };
21
+ parameter?: {
22
+ name?: string;
23
+ };
16
24
  };
@@ -1,2 +1,7 @@
1
- import type { SchemaPropertyDecorator, SchemaPropertyReflectionData } from './types.js';
2
- export declare function createSchemaPropertyDecorator(data?: SchemaPropertyReflectionData): SchemaPropertyDecorator;
1
+ import type { AbstractConstructor } from '../../types.js';
2
+ import type { SchemaTestable } from '../schema.js';
3
+ import type { SchemaReflectionData } from './types.js';
4
+ export declare function schemaReflectionDataToSchema(reflectionData: SchemaReflectionData | undefined, fallbackType: AbstractConstructor | null, source: {
5
+ type: AbstractConstructor;
6
+ key: string | symbol;
7
+ }): SchemaTestable;
@@ -1,9 +1,28 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import { createPropertyOrAccessorDecorator } from '../../reflection/index.js';
3
- import { filterUndefinedObjectProperties } from '../../utils/object/object.js';
4
- export function createSchemaPropertyDecorator(data = {}) {
5
- return createPropertyOrAccessorDecorator({
6
- data: { schema: filterUndefinedObjectProperties(data) },
7
- mergeData: true
8
- });
2
+ import { isDefined, isFunction, isNullOrUndefined, isUndefined } from '../../utils/type-guards.js';
3
+ import { array } from '../schemas/array.js';
4
+ import { nullable } from '../schemas/nullable.js';
5
+ import { optional } from '../schemas/optional.js';
6
+ import { schemaTestableToSchema } from '../testable.js';
7
+ export function schemaReflectionDataToSchema(reflectionData, fallbackType, source) {
8
+ if (isUndefined(reflectionData?.schema) && (fallbackType == Object)) {
9
+ throw new Error(`Schema of property "${String(source.key)}" on type ${source.type.name} is inferred as Object. This is most likely unwanted and happens if the property is defined as partial or the type is an union. Use an explicit @Property(Object) if this is wanted.`);
10
+ }
11
+ let propertySchema = isDefined(reflectionData?.schema) ? reflectionData.schema(reflectionData) : fallbackType;
12
+ if (isNullOrUndefined(propertySchema)) {
13
+ throw new Error(`Could not infer schema for property "${String(source.key)}" on type ${source.type.name}. This happens if neither explicit @Property(type) is used nor reflection metadata is available.`);
14
+ }
15
+ if (isFunction(propertySchema)) {
16
+ propertySchema = schemaTestableToSchema(propertySchema, { description: reflectionData?.description, example: reflectionData?.example });
17
+ }
18
+ if (reflectionData?.array == true) {
19
+ propertySchema = array(propertySchema);
20
+ }
21
+ if (reflectionData?.nullable == true) {
22
+ propertySchema = nullable(propertySchema);
23
+ }
24
+ if (reflectionData?.optional == true) {
25
+ propertySchema = optional(propertySchema);
26
+ }
27
+ return propertySchema;
9
28
  }
@@ -22,9 +22,9 @@ type NormalizePrimitiveToConstructor<T> = Or<IsEqual<T, string>, IsEqual<T, Stri
22
22
  export type SchemaTestable<T = unknown> = Schema<T> | AbstractConstructor<T> | NormalizePrimitiveToConstructor<T>;
23
23
  export type SchemaOutput<T extends SchemaTestable> = T extends SchemaTestable<infer U> ? U : never;
24
24
  export declare const OPTIONAL: unique symbol;
25
- export type SchemaOptions<T> = {
25
+ export type SchemaOptions<_T> = {
26
26
  description?: string | null;
27
- example?: T | undefined;
27
+ example?: any;
28
28
  };
29
29
  export declare abstract class Schema<T = unknown> {
30
30
  readonly [OPTIONAL]: boolean;
@@ -1,4 +1,4 @@
1
- import { type SchemaPropertyDecorator, type SchemaPropertyDecoratorOptions } from '../decorators/index.js';
1
+ import { type SchemaPropertyDecorator, type SchemaDecoratorOptions } from '../decorators/index.js';
2
2
  import { Schema, type SchemaOptions, type SchemaTestResult } from '../schema.js';
3
3
  export type AnySchemaOptions = SchemaOptions<any>;
4
4
  export declare class AnySchema extends Schema<any> {
@@ -6,4 +6,4 @@ export declare class AnySchema extends Schema<any> {
6
6
  _test(value: any): SchemaTestResult<any>;
7
7
  }
8
8
  export declare function any(options?: AnySchemaOptions): AnySchema;
9
- export declare function Any(options?: AnySchemaOptions & SchemaPropertyDecoratorOptions): SchemaPropertyDecorator;
9
+ export declare function Any(options?: AnySchemaOptions & SchemaDecoratorOptions): SchemaPropertyDecorator;
@@ -1,6 +1,6 @@
1
1
  import type { JsonPath } from '../../json-path/json-path.js';
2
2
  import type { TypedOmit } from '../../types.js';
3
- import { type SchemaPropertyDecorator, type SchemaPropertyDecoratorOptions } from '../decorators/index.js';
3
+ import { type SchemaDecoratorOptions, type SchemaPropertyDecorator } from '../decorators/index.js';
4
4
  import { Schema, type SchemaOptions, type SchemaTestable, type SchemaTestOptions, type SchemaTestResult } from '../schema.js';
5
5
  import type { Coercible } from '../types.js';
6
6
  export type ArraySchemaOptions<T> = SchemaOptions<T[]> & Coercible & {
@@ -17,4 +17,4 @@ export declare class ArraySchema<T> extends Schema<T[]> {
17
17
  _test(value: any, path: JsonPath, options: SchemaTestOptions): SchemaTestResult<T[]>;
18
18
  }
19
19
  export declare function array<T>(schema: SchemaTestable<T>, options?: ArraySchemaOptions<T>): ArraySchema<T>;
20
- export declare function Array(schema: SchemaTestable, options?: ArraySchemaOptions<unknown> & TypedOmit<SchemaPropertyDecoratorOptions, 'array'>): SchemaPropertyDecorator;
20
+ export declare function Array(schema: SchemaTestable, options?: ArraySchemaOptions<unknown> & TypedOmit<SchemaDecoratorOptions, 'array'>): SchemaPropertyDecorator;