rads-db 3.0.53 → 3.0.55
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/dist/index.d.ts +39 -32
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ type MaybePromise$1<T> = Promise<T> | T;
|
|
|
5
5
|
type Change<T> = {
|
|
6
6
|
[K in keyof T]?: T[K] extends any[] ? T[K] : T[K] extends {} ? Change<T[K]> : T[K];
|
|
7
7
|
};
|
|
8
|
-
interface GetManyArgs<
|
|
8
|
+
interface GetManyArgs<EN extends keyof EntityMeta, W> extends GetArgs<EN, W> {
|
|
9
9
|
cursor?: string | null;
|
|
10
10
|
maxItemCount?: number;
|
|
11
11
|
orderBy?: string;
|
|
12
12
|
}
|
|
13
|
-
interface VerifyManyArgs<
|
|
13
|
+
interface VerifyManyArgs<EN extends keyof EntityMeta, W> extends GetManyArgs<EN, W> {
|
|
14
14
|
recompute?: string[];
|
|
15
15
|
dryRun?: boolean;
|
|
16
16
|
}
|
|
@@ -29,53 +29,59 @@ type GetArgsWhere<W> = W & {
|
|
|
29
29
|
_and?: GetArgsWhere<W>[];
|
|
30
30
|
_or?: GetArgsWhere<W>[];
|
|
31
31
|
};
|
|
32
|
-
interface GetArgs<
|
|
32
|
+
interface GetArgs<EN extends keyof EntityMeta, W> {
|
|
33
33
|
where?: GetArgsWhere<W>;
|
|
34
|
-
include?: GetArgsInclude<
|
|
34
|
+
include?: GetArgsInclude<EN>;
|
|
35
35
|
}
|
|
36
36
|
interface GetAggArgs<EN extends keyof EntityMeta, W> {
|
|
37
37
|
where?: GetArgsWhere<W>;
|
|
38
38
|
agg: GetAggArgsAgg<EN>;
|
|
39
39
|
}
|
|
40
40
|
type GetAggArgsAgg<EN extends keyof EntityMeta, F extends string = EntityMeta[EN]['aggregates']> = ('_count' | `${F}_min` | `${F}_max`)[];
|
|
41
|
-
type GetManyArgsAny = GetManyArgs<any, any
|
|
42
|
-
type GetArgsAny = GetArgs<any, any
|
|
41
|
+
type GetManyArgsAny = GetManyArgs<any, any>;
|
|
42
|
+
type GetArgsAny = GetArgs<any, any>;
|
|
43
43
|
type GetAggArgsAny = GetAggArgs<any, any>;
|
|
44
|
-
type VerifyManyArgsAny = VerifyManyArgs<any, any
|
|
45
|
-
type GetArgsInclude<
|
|
44
|
+
type VerifyManyArgsAny = VerifyManyArgs<any, any>;
|
|
45
|
+
type GetArgsInclude<EN extends keyof EntityMeta, R extends keyof EntityMeta[EN]['relations'] = keyof EntityMeta[EN]['relations']> = [R] extends [never] ? {
|
|
46
|
+
_pick?: EntityMeta[EN]['primitives'][];
|
|
47
|
+
} : {
|
|
46
48
|
_pick?: EntityMeta[EN]['primitives'][];
|
|
47
49
|
} & {
|
|
48
|
-
[K in R]?: GetArgsInclude<
|
|
50
|
+
[K in R]?: GetArgsInclude<EntityMeta[EN]['relations'][K]['entityName']>;
|
|
49
51
|
};
|
|
50
52
|
type GetAggResponse<EN extends keyof EntityMeta, A extends GetAggArgs<EN, any>> = {
|
|
51
53
|
[K in A['agg'][0]]: K extends '_count' ? number : number | undefined;
|
|
52
54
|
};
|
|
53
|
-
interface GetManyResponse<
|
|
54
|
-
nodes: GetResponse<
|
|
55
|
+
interface GetManyResponse<EN extends keyof EntityMeta, A extends GetArgs<EN, any>> {
|
|
56
|
+
nodes: GetResponse<EN, A>[];
|
|
55
57
|
cursor: string | null;
|
|
56
58
|
}
|
|
57
|
-
type GetResponse<
|
|
59
|
+
type GetResponse<EN extends keyof EntityMeta, A extends GetArgs<EN, any>> = A extends {
|
|
58
60
|
include: any;
|
|
59
|
-
} ? GetResponseInclude<
|
|
61
|
+
} ? GetResponseInclude<EN, A['include']> : GetResponseNoInclude<EN>;
|
|
62
|
+
type Get<EntityName extends keyof EntityMeta, Include extends GetArgs<EntityName, any>['include'] = {}> = GetResponse<EntityName, {
|
|
63
|
+
include: Include;
|
|
64
|
+
}>;
|
|
60
65
|
type RelationData<EN extends keyof EntityMeta, K extends keyof EntityMeta[EN]['relations']> = Pick<EntityMeta[EN]['relations'][K]['entity'], EntityMeta[EN]['relations'][K]['denormFields']>;
|
|
61
66
|
type KeepArray<TMaybeArray, TType> = NonNullable<TMaybeArray> extends any[] ? TType[] : TType;
|
|
62
|
-
type GetResponseInclude<
|
|
67
|
+
type GetResponseInclude<EN extends keyof EntityMeta, I extends GetArgsInclude<EN>> = I extends {
|
|
63
68
|
_pick: string[];
|
|
64
|
-
} ? GetResponseIncludeSelect<
|
|
65
|
-
[K in keyof
|
|
69
|
+
} ? GetResponseIncludeSelect<EN, I> : {
|
|
70
|
+
[K in keyof EntityMeta[EN]['type']]: K extends keyof EntityMeta[EN]['relations'] ? K extends keyof I ? KeepArray<EntityMeta[EN]['type'][K], GetResponseInclude<EntityMeta[EN]['relations'][K]['entityName'], I[K]>> : KeepArray<EntityMeta[EN]['type'][K], RelationData<EN, K>> : EntityMeta[EN]['type'][K];
|
|
66
71
|
};
|
|
67
|
-
interface GetResponseIncludeSelect<
|
|
72
|
+
interface GetResponseIncludeSelect<EN extends keyof EntityMeta, I> {
|
|
68
73
|
}
|
|
69
|
-
type GetResponseNoInclude<
|
|
70
|
-
[K in keyof
|
|
74
|
+
type GetResponseNoInclude<EN extends keyof EntityMeta> = {
|
|
75
|
+
[K in keyof EntityMeta[EN]['type']]: K extends keyof EntityMeta[EN]['relations'] ? KeepArray<EntityMeta[EN]['type'][K], RelationData<EN, K>> : EntityMeta[EN]['type'][K];
|
|
71
76
|
};
|
|
72
77
|
type DeepPartialWithNulls<T> = {
|
|
73
|
-
[K in keyof T]?: NonNullable<T[K]> extends any[] ?
|
|
74
|
-
id: string;
|
|
75
|
-
} ? {
|
|
76
|
-
id: string;
|
|
77
|
-
} | null : NonNullable<T[K]> extends Record<string, any> ? DeepPartialWithNulls<T[K]> | null : T[K] | null;
|
|
78
|
+
[K in keyof T]?: NonNullable<T[K]> extends any[] ? DeepPartialWithNullsItem<NonNullable<T[K]>[number]>[] : DeepPartialWithNullsItem<NonNullable<T[K]>>;
|
|
78
79
|
};
|
|
80
|
+
type DeepPartialWithNullsItem<T> = T extends {
|
|
81
|
+
id: string;
|
|
82
|
+
} ? {
|
|
83
|
+
id: string;
|
|
84
|
+
} | null : T extends Record<string, any> ? DeepPartialWithNulls<T> | null : T | null;
|
|
79
85
|
type DeepPartial<T> = {
|
|
80
86
|
[K in keyof T]?: NonNullable<T[K]> extends any[] ? DeepPartial<NonNullable<T[K]>[number]>[] : NonNullable<T[K]> extends Record<string, any> ? DeepPartial<T[K]> : T[K];
|
|
81
87
|
};
|
|
@@ -85,6 +91,7 @@ type Relation<T extends {
|
|
|
85
91
|
type PutArgs<T> = {
|
|
86
92
|
id: string;
|
|
87
93
|
} & DeepPartialWithNulls<T>;
|
|
94
|
+
type Put<EntityName extends keyof EntityMeta> = PutArgs<EntityMeta[EntityName]['type']>;
|
|
88
95
|
type DeepKeys<T> = T extends object ? {
|
|
89
96
|
[K in (string | number) & keyof T]: `${`.${K}` | (`${K}` extends `${number}` ? `[${K}]` : never)}${'' | DeepKeys<T[K]>}`;
|
|
90
97
|
}[(string | number) & keyof T] : never;
|
|
@@ -94,14 +101,14 @@ interface EntityMethods<E, EN extends keyof EntityMeta, W> {
|
|
|
94
101
|
/** Used to access underlying mechanism of storage directly.
|
|
95
102
|
* Warning: bypasses all rads features - schema won't be validated, default values won't be filled, etc. */
|
|
96
103
|
driver: Driver;
|
|
97
|
-
get<A extends GetArgs<
|
|
98
|
-
getMany<A extends GetManyArgs<
|
|
104
|
+
get<A extends GetArgs<EN, W>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetResponse<EN, A>>;
|
|
105
|
+
getMany<A extends GetManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<EN, A>>;
|
|
99
106
|
getAgg<A extends GetAggArgs<EN, W>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetAggResponse<EN, A>>;
|
|
100
|
-
getAll<A extends GetManyArgs<
|
|
101
|
-
put(data: PutArgs<E>, ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<
|
|
102
|
-
putMany(data: PutArgs<E>[], ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<
|
|
103
|
-
verifyMany<A extends VerifyManyArgs<
|
|
104
|
-
verifyAll<A extends VerifyManyArgs<
|
|
107
|
+
getAll<A extends GetManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<EN, A>['nodes']>;
|
|
108
|
+
put(data: PutArgs<E>, ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<EN>>;
|
|
109
|
+
putMany(data: PutArgs<E>[], ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<EN>[]>;
|
|
110
|
+
verifyMany<A extends VerifyManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<VerifyManyResponse>;
|
|
111
|
+
verifyAll<A extends VerifyManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<Pick<VerifyManyResponse, 'correctCount' | 'incorrectCount'>>;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
type MaybePromise<T> = Promise<T> | T;
|
|
@@ -437,4 +444,4 @@ declare function createRadsDb(args?: CreateRadsDbArgs): RadsDb;
|
|
|
437
444
|
*/
|
|
438
445
|
declare function createRadsDbClient(args?: CreateRadsDbClientArgs): RadsDb;
|
|
439
446
|
|
|
440
|
-
export { Change, ComputedContext, ComputedContextGlobal, ComputedDecoratorArgs, CreateRadsArgsDrivers, CreateRadsDbArgs, CreateRadsDbArgsNormalized, CreateRadsDbClientArgs, DeepKeys, DeepPartial, DeepPartialWithNulls, Driver, DriverConstructor, EntityDecoratorArgs, EntityMethods, EnumDefinition, FieldDecoratorArgs, FieldDefinition, FileSystemNode, FileUploadArgs, FileUploadDriver, FileUploadResult, GenerateClientNormalizedOptions, GenerateClientOptions, GetAggArgs, GetAggArgsAgg, GetAggArgsAny, GetAggResponse, GetArgs, GetArgsAny, GetArgsInclude, GetArgsWhere, GetManyArgs, GetManyArgsAny, GetManyResponse, GetResponse, GetResponseInclude, GetResponseIncludeSelect, GetResponseNoInclude, GetRestRoutesArgs, GetRestRoutesOptions, GetRestRoutesResponse, MinimalDriver, PutArgs, PutEffect, RadsFeature, RadsHookDoc, RadsRequestContext, RadsUiSlotDefinition, RadsUiSlotName, RadsVitePluginOptions, Relation, RequiredFields, RestDriverOptions, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, VerifyManyArgs, VerifyManyArgsAny, VerifyManyResponse, WhereJsonContains, cleanUndefinedAndNull, computed, createRadsDb, createRadsDbClient, diff, entity, field, getDriverInstance, handlePrecomputed, keepHistory, merge, precomputed, ui, validate };
|
|
447
|
+
export { Change, ComputedContext, ComputedContextGlobal, ComputedDecoratorArgs, CreateRadsArgsDrivers, CreateRadsDbArgs, CreateRadsDbArgsNormalized, CreateRadsDbClientArgs, DeepKeys, DeepPartial, DeepPartialWithNulls, DeepPartialWithNullsItem, Driver, DriverConstructor, EntityDecoratorArgs, EntityMethods, EnumDefinition, FieldDecoratorArgs, FieldDefinition, FileSystemNode, FileUploadArgs, FileUploadDriver, FileUploadResult, GenerateClientNormalizedOptions, GenerateClientOptions, Get, GetAggArgs, GetAggArgsAgg, GetAggArgsAny, GetAggResponse, GetArgs, GetArgsAny, GetArgsInclude, GetArgsWhere, GetManyArgs, GetManyArgsAny, GetManyResponse, GetResponse, GetResponseInclude, GetResponseIncludeSelect, GetResponseNoInclude, GetRestRoutesArgs, GetRestRoutesOptions, GetRestRoutesResponse, MinimalDriver, Put, PutArgs, PutEffect, RadsFeature, RadsHookDoc, RadsRequestContext, RadsUiSlotDefinition, RadsUiSlotName, RadsVitePluginOptions, Relation, RequiredFields, RestDriverOptions, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, VerifyManyArgs, VerifyManyArgsAny, VerifyManyResponse, WhereJsonContains, cleanUndefinedAndNull, computed, createRadsDb, createRadsDbClient, diff, entity, field, getDriverInstance, handlePrecomputed, keepHistory, merge, precomputed, ui, validate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rads-db",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.55",
|
|
4
4
|
"packageManager": "pnpm@8.6.1",
|
|
5
5
|
"description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
|
|
6
6
|
"author": "",
|
|
@@ -107,9 +107,8 @@
|
|
|
107
107
|
"test": "vitest --run && vitest typecheck --run",
|
|
108
108
|
"link-rads-db": "symlink-dir ./test/_rads-db ./node_modules/_rads-db",
|
|
109
109
|
"generate-test-schema": "ts-node ./src/integrations/cli -d './test/entities'",
|
|
110
|
-
"dev": "pnpm install && pnpm link-rads-db && pnpm build && pnpm generate-test-schema && vitest --ui --test-timeout 300000",
|
|
110
|
+
"dev": "pnpm install && pnpm link-rads-db && pnpm build && pnpm generate-test-schema && vitest --ui --test-timeout 300000 --typecheck",
|
|
111
111
|
"lint": "cross-env NODE_ENV=production eslint src/**/*.* test/**/*.*",
|
|
112
|
-
"dev-typecheck": "pnpm install && pnpm build && pnpm generate-test-schema && pnpm link-rads-db && vitest typecheck",
|
|
113
112
|
"build": "unbuild"
|
|
114
113
|
}
|
|
115
114
|
}
|