@naturalcycles/js-lib 15.42.0 → 15.42.1
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.
|
@@ -19,7 +19,7 @@ export declare const j: {
|
|
|
19
19
|
integer<T extends number = number>(): JsonSchemaNumberBuilder<T, false>;
|
|
20
20
|
string<T extends string = string>(): JsonSchemaStringBuilder<T, false>;
|
|
21
21
|
object: typeof object;
|
|
22
|
-
dbEntity<
|
|
22
|
+
dbEntity<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props: P): JsonSchemaObjectBuilder<BaseDBEntity & { [K in keyof P]: P[K] extends JsonSchemaAnyBuilder<infer U, any, any> ? U : never; }>;
|
|
23
23
|
rootObject<T extends AnyObject>(props: { [K in keyof T]: JsonSchemaAnyBuilder<T[K]>; }): JsonSchemaObjectBuilder<T, false>;
|
|
24
24
|
array<T extends JsonSchemaAnyBuilder<any>>(itemSchema: T): JsonSchemaArrayBuilder<T["infer"], false>;
|
|
25
25
|
tuple<T extends any[] = unknown[]>(items: JsonSchemaAnyBuilder[]): JsonSchemaTupleBuilder<T>;
|
|
@@ -139,12 +139,14 @@ export declare class JsonSchemaArrayBuilder<ITEM, Opt extends boolean = false> e
|
|
|
139
139
|
constructor(itemsSchema: JsonSchemaBuilder<ITEM>);
|
|
140
140
|
min(minItems: number): this;
|
|
141
141
|
max(maxItems: number): this;
|
|
142
|
-
unique(uniqueItems
|
|
142
|
+
unique(uniqueItems?: boolean): this;
|
|
143
143
|
}
|
|
144
144
|
export declare class JsonSchemaTupleBuilder<T extends any[]> extends JsonSchemaAnyBuilder<T, JsonSchemaTuple<T>> {
|
|
145
145
|
constructor(items: JsonSchemaBuilder[]);
|
|
146
146
|
}
|
|
147
|
-
declare function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props?:
|
|
147
|
+
declare function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props?: {
|
|
148
|
+
[K in keyof P]: P[K] & JsonSchemaAnyBuilder<any, any, any>;
|
|
149
|
+
}): JsonSchemaObjectBuilder<{
|
|
148
150
|
[K in keyof P as P[K] extends JsonSchemaAnyBuilder<any, any, infer Opt> ? Opt extends true ? never : K : never]: P[K] extends JsonSchemaAnyBuilder<infer U, any, any> ? U : never;
|
|
149
151
|
} & {
|
|
150
152
|
[K in keyof P as P[K] extends JsonSchemaAnyBuilder<any, any, infer Opt> ? Opt extends true ? K : never : never]?: P[K] extends JsonSchemaAnyBuilder<infer U, any, any> ? U : never;
|
|
@@ -392,7 +392,7 @@ export class JsonSchemaArrayBuilder extends JsonSchemaAnyBuilder {
|
|
|
392
392
|
Object.assign(this.schema, { maxItems });
|
|
393
393
|
return this;
|
|
394
394
|
}
|
|
395
|
-
unique(uniqueItems) {
|
|
395
|
+
unique(uniqueItems = true) {
|
|
396
396
|
Object.assign(this.schema, { uniqueItems });
|
|
397
397
|
return this;
|
|
398
398
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.42.
|
|
4
|
+
"version": "15.42.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2",
|
|
7
7
|
"undici": "^7",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@types/semver": "^7",
|
|
14
14
|
"crypto-js": "^4",
|
|
15
15
|
"dayjs": "^1",
|
|
16
|
-
"@naturalcycles/dev-lib": "
|
|
16
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
".": "./dist/index.js",
|
|
@@ -119,14 +119,18 @@ export const j = {
|
|
|
119
119
|
|
|
120
120
|
// complex types
|
|
121
121
|
object,
|
|
122
|
-
dbEntity<
|
|
122
|
+
dbEntity<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props: P) {
|
|
123
123
|
return j
|
|
124
124
|
.object<BaseDBEntity>({
|
|
125
125
|
id: j.string(),
|
|
126
126
|
created: j.integer().unixTimestamp2000(),
|
|
127
127
|
updated: j.integer().unixTimestamp2000(),
|
|
128
128
|
})
|
|
129
|
-
.extend(j.object(props))
|
|
129
|
+
.extend(j.object(props)) as JsonSchemaObjectBuilder<
|
|
130
|
+
BaseDBEntity & {
|
|
131
|
+
[K in keyof P]: P[K] extends JsonSchemaAnyBuilder<infer U, any, any> ? U : never
|
|
132
|
+
}
|
|
133
|
+
>
|
|
130
134
|
},
|
|
131
135
|
|
|
132
136
|
rootObject<T extends AnyObject>(props: {
|
|
@@ -541,7 +545,7 @@ export class JsonSchemaArrayBuilder<ITEM, Opt extends boolean = false> extends J
|
|
|
541
545
|
return this
|
|
542
546
|
}
|
|
543
547
|
|
|
544
|
-
unique(uniqueItems
|
|
548
|
+
unique(uniqueItems = true): this {
|
|
545
549
|
Object.assign(this.schema, { uniqueItems })
|
|
546
550
|
return this
|
|
547
551
|
}
|
|
@@ -561,9 +565,9 @@ export class JsonSchemaTupleBuilder<T extends any[]> extends JsonSchemaAnyBuilde
|
|
|
561
565
|
}
|
|
562
566
|
}
|
|
563
567
|
|
|
564
|
-
function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(
|
|
565
|
-
|
|
566
|
-
): JsonSchemaObjectBuilder<
|
|
568
|
+
function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props?: {
|
|
569
|
+
[K in keyof P]: P[K] & JsonSchemaAnyBuilder<any, any, any>
|
|
570
|
+
}): JsonSchemaObjectBuilder<
|
|
567
571
|
{
|
|
568
572
|
[K in keyof P as P[K] extends JsonSchemaAnyBuilder<any, any, infer Opt>
|
|
569
573
|
? Opt extends true
|