@tstdl/base 0.91.38 → 0.91.39
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.91.
|
|
3
|
+
"version": "0.91.39",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
},
|
|
119
119
|
"devDependencies": {
|
|
120
120
|
"@mxssfd/typedoc-theme": "1.1",
|
|
121
|
-
"@stylistic/eslint-plugin": "2.
|
|
121
|
+
"@stylistic/eslint-plugin": "2.10",
|
|
122
122
|
"@types/chroma-js": "2.4",
|
|
123
123
|
"@types/koa__router": "12.0",
|
|
124
124
|
"@types/luxon": "3.4",
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
"@types/nodemailer": "6.4",
|
|
129
129
|
"@types/pg": "8.11",
|
|
130
130
|
"@typescript-eslint/eslint-plugin": "7.17",
|
|
131
|
-
"concurrently": "9.
|
|
132
|
-
"drizzle-kit": "0.
|
|
131
|
+
"concurrently": "9.1",
|
|
132
|
+
"drizzle-kit": "0.27",
|
|
133
133
|
"eslint": "8.57",
|
|
134
134
|
"eslint-import-resolver-typescript": "3.6",
|
|
135
135
|
"eslint-plugin-import": "2.31",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"@zxcvbn-ts/language-de": "^3.0",
|
|
148
148
|
"@zxcvbn-ts/language-en": "^3.0",
|
|
149
149
|
"chroma-js": "^2.6",
|
|
150
|
-
"drizzle-orm": "^0.
|
|
150
|
+
"drizzle-orm": "^0.36",
|
|
151
151
|
"handlebars": "^4.7",
|
|
152
152
|
"koa": "^2.15",
|
|
153
153
|
"minio": "^8.0",
|
package/reflection/types.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export type DecoratorMetadataMap = DecoratorTypeMap<{
|
|
|
35
35
|
export type DecoratorHandlerReturnTypeMap = DecoratorTypeMap<{
|
|
36
36
|
class: void | undefined | Constructor;
|
|
37
37
|
property: void;
|
|
38
|
-
accessor: void
|
|
39
|
-
method: void | PropertyDescriptor;
|
|
38
|
+
accessor: void | undefined | TypedPropertyDescriptor<any>;
|
|
39
|
+
method: void | undefined | PropertyDescriptor;
|
|
40
40
|
parameter: void;
|
|
41
41
|
methodParameter: void;
|
|
42
42
|
constructorParameter: void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Decorator } from '../../reflection/types.js';
|
|
2
2
|
import type { SchemaTestable } from '../schema.js';
|
|
3
3
|
import type { ObjectSchemaFactoryFunction, ObjectSchemaOptions } from '../schemas/object.js';
|
|
4
|
+
export type SchemaClassDecorator = Decorator<'class'>;
|
|
4
5
|
export type SchemaPropertyDecorator = Decorator<'property' | 'accessor'>;
|
|
5
6
|
export type SchemaTypeReflectionData = Partial<Pick<ObjectSchemaOptions, 'mask' | 'unknownProperties' | 'unknownPropertiesKey'>> & {
|
|
6
7
|
schema?: SchemaTestable;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EmptyObject, Merge } from 'type-fest';
|
|
2
2
|
import type { JsonPath } from '../../json-path/json-path.js';
|
|
3
|
+
import { type Decorator } from '../../reflection/index.js';
|
|
3
4
|
import type { AbstractConstructor, OneOrMany, PartialProperty, Record as RecordType, SimplifyObject, Type, TypedOmit } from '../../types.js';
|
|
4
5
|
import { type SchemaPropertyDecoratorOptions } from '../decorators/index.js';
|
|
5
|
-
import type { SchemaPropertyDecorator } from '../decorators/types.js';
|
|
6
6
|
import { type OPTIONAL, Schema, type SchemaOutput, type SchemaTestable, type SchemaTestOptions, type SchemaTestResult } from '../schema.js';
|
|
7
7
|
export type Record<K extends PropertyKey = PropertyKey, V = any> = RecordType<K, V>;
|
|
8
8
|
export type ObjectSchemaFactoryFunction<T> = (data: T) => T;
|
|
@@ -85,6 +85,6 @@ export declare function omit<const T extends Record, const K extends keyof T>(sc
|
|
|
85
85
|
export declare function getSchemaFromReflection<T extends Record>(type: AbstractConstructor<T>): Schema<T>;
|
|
86
86
|
declare function _tryGetSchemaFromReflection<T extends Record>(type: AbstractConstructor<T>): Schema<T> | ObjectSchema<T> | null;
|
|
87
87
|
export declare function getObjectSchema<T extends Record>(schemaOrType: SchemaTestable<T>): ObjectSchema<T>;
|
|
88
|
-
export declare function Record<K extends PropertyKey, V>(key:
|
|
88
|
+
export declare function Record<K extends PropertyKey, V>(key: SchemaTestable<K>, value: SchemaTestable<V>, options?: TypedOmit<ObjectSchemaOptions<Record<K, V>>, 'unknownProperties' | 'unknownPropertiesKey'> & SchemaPropertyDecoratorOptions): Decorator<'class' | 'property' | 'accessor'>;
|
|
89
89
|
export declare const emptyObjectSchema: ObjectSchema<EmptyObject>;
|
|
90
90
|
export {};
|
package/schema/schemas/object.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable max-depth */
|
|
2
|
-
import { reflectionRegistry } from '../../reflection/index.js';
|
|
2
|
+
import { createDecorator, reflectionRegistry } from '../../reflection/index.js';
|
|
3
3
|
import { SchemaError } from '../../schema/schema.error.js';
|
|
4
4
|
import { toArray } from '../../utils/array/array.js';
|
|
5
5
|
import { memoizeSingle } from '../../utils/function/memoize.js';
|
|
6
6
|
import { filterObject, mapObjectValues, objectKeys } from '../../utils/object/object.js';
|
|
7
7
|
import { assert, isDefined, isFunction, isLiteralObject, isNotNull, isNotNullOrUndefined, isNull, isObject, isUndefined } from '../../utils/type-guards.js';
|
|
8
8
|
import { typeOf } from '../../utils/type-of.js';
|
|
9
|
-
import { Property } from '../decorators/index.js';
|
|
9
|
+
import { Class, Property } from '../decorators/index.js';
|
|
10
10
|
import { Schema } from '../schema.js';
|
|
11
11
|
import { schemaTestableToSchema } from '../testable.js';
|
|
12
12
|
import { array } from './array.js';
|
|
@@ -188,6 +188,13 @@ export function getObjectSchema(schemaOrType) {
|
|
|
188
188
|
throw new Error('Could not infer ObjectSchema.');
|
|
189
189
|
}
|
|
190
190
|
export function Record(key, value, options) {
|
|
191
|
-
|
|
191
|
+
const keySchema = schemaTestableToSchema(key);
|
|
192
|
+
const valueSchema = schemaTestableToSchema(value);
|
|
193
|
+
return createDecorator({ class: true, property: true, accessor: true }, (data, _metadata, args) => {
|
|
194
|
+
if (data.type == 'class') {
|
|
195
|
+
return Class({ unknownPropertiesKey: keySchema, unknownProperties: valueSchema })(args[0]);
|
|
196
|
+
}
|
|
197
|
+
return Property(record(keySchema, valueSchema, options), options)(args[0], args[1], args[2]);
|
|
198
|
+
});
|
|
192
199
|
}
|
|
193
200
|
export const emptyObjectSchema = explicitObject({});
|