rads-db 3.0.53 → 3.0.54

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 (2) hide show
  1. package/dist/index.d.ts +26 -23
  2. 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<E, EN extends keyof EntityMeta, W> extends GetArgs<E, EN, W> {
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<E, EN extends keyof EntityMeta, W> extends GetManyArgs<E, EN, W> {
13
+ interface VerifyManyArgs<EN extends keyof EntityMeta, W> extends GetManyArgs<EN, W> {
14
14
  recompute?: string[];
15
15
  dryRun?: boolean;
16
16
  }
@@ -29,37 +29,39 @@ type GetArgsWhere<W> = W & {
29
29
  _and?: GetArgsWhere<W>[];
30
30
  _or?: GetArgsWhere<W>[];
31
31
  };
32
- interface GetArgs<E, EN extends keyof EntityMeta, W> {
32
+ interface GetArgs<EN extends keyof EntityMeta, W> {
33
33
  where?: GetArgsWhere<W>;
34
- include?: GetArgsInclude<E, EN>;
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, any>;
42
- type GetArgsAny = GetArgs<any, 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, any>;
45
- type GetArgsInclude<E, EN extends keyof EntityMeta, R extends keyof E = keyof EntityMeta[EN]['relations'] & keyof E> = [R] extends [never] ? Record<string, never> : {
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<NonNullable<E[K]>, EntityMeta[EN]['relations'][K]['entityName']>;
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<E, EN extends keyof EntityMeta, A extends GetArgs<E, EN, any>> {
55
+ interface GetManyResponse<E, EN extends keyof EntityMeta, A extends GetArgs<EN, any>> {
54
56
  nodes: GetResponse<E, EN, A>[];
55
57
  cursor: string | null;
56
58
  }
57
- type GetResponse<E, EN extends keyof EntityMeta, A extends GetArgs<E, EN, any>> = A extends {
59
+ type GetResponse<E, EN extends keyof EntityMeta, A extends GetArgs<EN, any>> = A extends {
58
60
  include: any;
59
61
  } ? GetResponseInclude<E, EN, A['include']> : GetResponseNoInclude<E, EN>;
60
62
  type RelationData<EN extends keyof EntityMeta, K extends keyof EntityMeta[EN]['relations']> = Pick<EntityMeta[EN]['relations'][K]['entity'], EntityMeta[EN]['relations'][K]['denormFields']>;
61
63
  type KeepArray<TMaybeArray, TType> = NonNullable<TMaybeArray> extends any[] ? TType[] : TType;
62
- type GetResponseInclude<E, EN extends keyof EntityMeta, I extends GetArgsInclude<E, EN>> = I extends {
64
+ type GetResponseInclude<E, EN extends keyof EntityMeta, I extends GetArgsInclude<EN>> = I extends {
63
65
  _pick: string[];
64
66
  } ? GetResponseIncludeSelect<E, I> : {
65
67
  [K in keyof E]: K extends keyof EntityMeta[EN]['relations'] ? K extends keyof I ? KeepArray<E[K], GetResponseInclude<EntityMeta[EN]['relations'][K]['entity'], EntityMeta[EN]['relations'][K]['entityName'], I[K]>> : KeepArray<E[K], RelationData<EN, K>> : E[K];
@@ -70,12 +72,13 @@ type GetResponseNoInclude<E, EN extends keyof EntityMeta> = {
70
72
  [K in keyof E]: K extends keyof EntityMeta[EN]['relations'] ? KeepArray<E[K], RelationData<EN, K>> : E[K];
71
73
  };
72
74
  type DeepPartialWithNulls<T> = {
73
- [K in keyof T]?: NonNullable<T[K]> extends any[] ? DeepPartialWithNulls<NonNullable<T[K]>[number]>[] : NonNullable<T[K]> extends {
74
- id: string;
75
- } ? {
76
- id: string;
77
- } | null : NonNullable<T[K]> extends Record<string, any> ? DeepPartialWithNulls<T[K]> | null : T[K] | null;
75
+ [K in keyof T]?: NonNullable<T[K]> extends any[] ? DeepPartialWithNullsItem<NonNullable<T[K]>[number]>[] : DeepPartialWithNullsItem<NonNullable<T[K]>>;
78
76
  };
77
+ type DeepPartialWithNullsItem<T> = T extends {
78
+ id: string;
79
+ } ? {
80
+ id: string;
81
+ } | null : T extends Record<string, any> ? DeepPartialWithNulls<T> | null : T | null;
79
82
  type DeepPartial<T> = {
80
83
  [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
84
  };
@@ -94,14 +97,14 @@ interface EntityMethods<E, EN extends keyof EntityMeta, W> {
94
97
  /** Used to access underlying mechanism of storage directly.
95
98
  * Warning: bypasses all rads features - schema won't be validated, default values won't be filled, etc. */
96
99
  driver: Driver;
97
- get<A extends GetArgs<E, EN, W>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetResponse<E, EN, A>>;
98
- getMany<A extends GetManyArgs<E, EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<E, EN, A>>;
100
+ get<A extends GetArgs<EN, W>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetResponse<E, EN, A>>;
101
+ getMany<A extends GetManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<E, EN, A>>;
99
102
  getAgg<A extends GetAggArgs<EN, W>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetAggResponse<EN, A>>;
100
- getAll<A extends GetManyArgs<E, EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<E, EN, A>['nodes']>;
103
+ getAll<A extends GetManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<E, EN, A>['nodes']>;
101
104
  put(data: PutArgs<E>, ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<E, EN>>;
102
105
  putMany(data: PutArgs<E>[], ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<E, EN>[]>;
103
- verifyMany<A extends VerifyManyArgs<E, EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<VerifyManyResponse>;
104
- verifyAll<A extends VerifyManyArgs<E, EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<Pick<VerifyManyResponse, 'correctCount' | 'incorrectCount'>>;
106
+ verifyMany<A extends VerifyManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<VerifyManyResponse>;
107
+ verifyAll<A extends VerifyManyArgs<EN, W>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<Pick<VerifyManyResponse, 'correctCount' | 'incorrectCount'>>;
105
108
  }
106
109
 
107
110
  type MaybePromise<T> = Promise<T> | T;
@@ -437,4 +440,4 @@ declare function createRadsDb(args?: CreateRadsDbArgs): RadsDb;
437
440
  */
438
441
  declare function createRadsDbClient(args?: CreateRadsDbClientArgs): RadsDb;
439
442
 
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 };
443
+ 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, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.0.53",
3
+ "version": "3.0.54",
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
  }