rads-db 3.0.56 → 3.0.58
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 +26 -26
- package/integrations/node.cjs +3 -1
- package/integrations/node.mjs +3 -1
- package/package.json +1 -1
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<EN extends keyof EntityMeta
|
|
8
|
+
interface GetManyArgs<EN extends keyof EntityMeta> extends GetArgs<EN> {
|
|
9
9
|
cursor?: string | null;
|
|
10
10
|
maxItemCount?: number;
|
|
11
11
|
orderBy?: string;
|
|
12
12
|
}
|
|
13
|
-
interface VerifyManyArgs<EN extends keyof EntityMeta
|
|
13
|
+
interface VerifyManyArgs<EN extends keyof EntityMeta> extends GetManyArgs<EN> {
|
|
14
14
|
recompute?: string[];
|
|
15
15
|
dryRun?: boolean;
|
|
16
16
|
}
|
|
@@ -24,24 +24,24 @@ interface VerifyManyResponse {
|
|
|
24
24
|
toRemove?: any;
|
|
25
25
|
}[];
|
|
26
26
|
}
|
|
27
|
-
type
|
|
28
|
-
_not?:
|
|
29
|
-
_and?:
|
|
30
|
-
_or?:
|
|
27
|
+
type Where<EN extends keyof EntityMeta> = EntityMeta[EN]['whereType'] & {
|
|
28
|
+
_not?: Where<EN>;
|
|
29
|
+
_and?: Where<EN>[];
|
|
30
|
+
_or?: Where<EN>[];
|
|
31
31
|
};
|
|
32
|
-
interface GetArgs<EN extends keyof EntityMeta
|
|
33
|
-
where?:
|
|
32
|
+
interface GetArgs<EN extends keyof EntityMeta> {
|
|
33
|
+
where?: Where<EN>;
|
|
34
34
|
include?: GetArgsInclude<EN>;
|
|
35
35
|
}
|
|
36
|
-
interface GetAggArgs<EN extends keyof EntityMeta
|
|
37
|
-
where?:
|
|
36
|
+
interface GetAggArgs<EN extends keyof EntityMeta> {
|
|
37
|
+
where?: Where<EN>;
|
|
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
|
|
42
|
-
type GetArgsAny = GetArgs<any
|
|
43
|
-
type GetAggArgsAny = GetAggArgs<any
|
|
44
|
-
type VerifyManyArgsAny = VerifyManyArgs<any
|
|
41
|
+
type GetManyArgsAny = GetManyArgs<any>;
|
|
42
|
+
type GetArgsAny = GetArgs<any>;
|
|
43
|
+
type GetAggArgsAny = GetAggArgs<any>;
|
|
44
|
+
type VerifyManyArgsAny = VerifyManyArgs<any>;
|
|
45
45
|
type GetArgsInclude<EN extends keyof EntityMeta, R extends keyof EntityMeta[EN]['relations'] = keyof EntityMeta[EN]['relations']> = [R] extends [never] ? {
|
|
46
46
|
_pick?: EntityMeta[EN]['primitives'][];
|
|
47
47
|
} : {
|
|
@@ -49,14 +49,14 @@ type GetArgsInclude<EN extends keyof EntityMeta, R extends keyof EntityMeta[EN][
|
|
|
49
49
|
} & {
|
|
50
50
|
[K in R]?: GetArgsInclude<EntityMeta[EN]['relations'][K]['entityName']>;
|
|
51
51
|
};
|
|
52
|
-
type GetAggResponse<EN extends keyof EntityMeta, A extends GetAggArgs<EN
|
|
52
|
+
type GetAggResponse<EN extends keyof EntityMeta, A extends GetAggArgs<EN>> = {
|
|
53
53
|
[K in A['agg'][0]]: K extends '_count' ? number : number | undefined;
|
|
54
54
|
};
|
|
55
|
-
interface GetManyResponse<EN extends keyof EntityMeta, A extends GetArgs<EN
|
|
55
|
+
interface GetManyResponse<EN extends keyof EntityMeta, A extends GetArgs<EN>> {
|
|
56
56
|
nodes: GetResponse<EN, A>[];
|
|
57
57
|
cursor: string | null;
|
|
58
58
|
}
|
|
59
|
-
type GetResponse<EN extends keyof EntityMeta, A extends GetArgs<EN
|
|
59
|
+
type GetResponse<EN extends keyof EntityMeta, A extends GetArgs<EN>> = A extends {
|
|
60
60
|
include: any;
|
|
61
61
|
} ? GetResponseInclude<EN, A['include']> : GetResponseNoInclude<EN>;
|
|
62
62
|
type Get<EntityName extends keyof EntityMeta, Include extends keyof EntityMeta[EntityName]['relations'] | GetArgsInclude<EntityName> = {}> = Include extends GetArgsInclude<EntityName> ? GetResponse<EntityName, {
|
|
@@ -99,20 +99,20 @@ type Put<EntityName extends keyof EntityMeta> = PutArgs<EntityMeta[EntityName]['
|
|
|
99
99
|
type DeepKeys<T> = T extends object ? {
|
|
100
100
|
[K in (string | number) & keyof T]: `${`.${K}` | (`${K}` extends `${number}` ? `[${K}]` : never)}${'' | DeepKeys<T[K]>}`;
|
|
101
101
|
}[(string | number) & keyof T] : never;
|
|
102
|
-
interface EntityMethods<E, EN extends keyof EntityMeta
|
|
102
|
+
interface EntityMethods<E, EN extends keyof EntityMeta> {
|
|
103
103
|
/** Returns object with with random UUID as `id` and prefilled default values */
|
|
104
104
|
construct(): E;
|
|
105
105
|
/** Used to access underlying mechanism of storage directly.
|
|
106
106
|
* Warning: bypasses all rads features - schema won't be validated, default values won't be filled, etc. */
|
|
107
107
|
driver: Driver;
|
|
108
|
-
get<A extends GetArgs<EN
|
|
109
|
-
getMany<A extends GetManyArgs<EN
|
|
110
|
-
getAgg<A extends GetAggArgs<EN
|
|
111
|
-
getAll<A extends GetManyArgs<EN
|
|
108
|
+
get<A extends GetArgs<EN>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetResponse<EN, A>>;
|
|
109
|
+
getMany<A extends GetManyArgs<EN>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<EN, A>>;
|
|
110
|
+
getAgg<A extends GetAggArgs<EN>>(args: A, ctx?: RadsRequestContext): MaybePromise$1<GetAggResponse<EN, A>>;
|
|
111
|
+
getAll<A extends GetManyArgs<EN>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<GetManyResponse<EN, A>['nodes']>;
|
|
112
112
|
put(data: PutArgs<E>, ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<EN>>;
|
|
113
113
|
putMany(data: PutArgs<E>[], ctx?: RadsRequestContext): MaybePromise$1<GetResponseNoInclude<EN>[]>;
|
|
114
|
-
verifyMany<A extends VerifyManyArgs<EN
|
|
115
|
-
verifyAll<A extends VerifyManyArgs<EN
|
|
114
|
+
verifyMany<A extends VerifyManyArgs<EN>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<VerifyManyResponse>;
|
|
115
|
+
verifyAll<A extends VerifyManyArgs<EN>>(args?: A, ctx?: RadsRequestContext): MaybePromise$1<Pick<VerifyManyResponse, 'correctCount' | 'incorrectCount'>>;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
type MaybePromise<T> = Promise<T> | T;
|
|
@@ -408,7 +408,7 @@ interface RadsFeature {
|
|
|
408
408
|
name: string;
|
|
409
409
|
radsUiSlots?: Record<RadsUiSlotName, RadsUiSlotDefinition[]>;
|
|
410
410
|
init?: (db: Record<string, any>, context: ComputedContextGlobal) => void;
|
|
411
|
-
enhanceEntityMethods?: (context: ComputedContext, entityMethodsObj: EntityMethods<any, any
|
|
411
|
+
enhanceEntityMethods?: (context: ComputedContext, entityMethodsObj: EntityMethods<any, any>) => void;
|
|
412
412
|
beforeGet?: (args: GetArgsAny, ctx: RadsRequestContext, context: ComputedContext) => MaybePromise<any>;
|
|
413
413
|
afterGet?: (items: any[], args: GetArgsAny, ctx: RadsRequestContext, context: ComputedContext) => MaybePromise<void>;
|
|
414
414
|
beforePut?: (items: RadsHookDoc[], ctx: RadsRequestContext, computedContext: ComputedContext) => void;
|
|
@@ -448,4 +448,4 @@ declare function createRadsDb(args?: CreateRadsDbArgs): RadsDb;
|
|
|
448
448
|
*/
|
|
449
449
|
declare function createRadsDbClient(args?: CreateRadsDbClientArgs): RadsDb;
|
|
450
450
|
|
|
451
|
-
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,
|
|
451
|
+
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, 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, Where, WhereJsonContains, cleanUndefinedAndNull, computed, createRadsDb, createRadsDbClient, diff, entity, field, getDriverInstance, handlePrecomputed, keepHistory, merge, precomputed, ui, validate };
|
package/integrations/node.cjs
CHANGED
|
@@ -106,7 +106,7 @@ function getIndexDts(schema, options) {
|
|
|
106
106
|
if (options.entitiesDir) {
|
|
107
107
|
imports.push(`import type { ${type.name} } from '../../${options.entitiesDir}/${key}'`);
|
|
108
108
|
}
|
|
109
|
-
rootFields.push(`${type.handle}: EntityMethods<${type.name}, '${type.name}'
|
|
109
|
+
rootFields.push(`${type.handle}: EntityMethods<${type.name}, '${type.name}'>`);
|
|
110
110
|
const fieldsArray = Object.values(type.fields);
|
|
111
111
|
const relations = _lodash.default.fromPairs(fieldsArray.filter(f => f.isRelation).map(f => [f.name, {
|
|
112
112
|
entity: f.type,
|
|
@@ -114,6 +114,7 @@ function getIndexDts(schema, options) {
|
|
|
114
114
|
}]));
|
|
115
115
|
entityMeta.push({
|
|
116
116
|
type: type.name,
|
|
117
|
+
whereType: `${type.name}_Where`,
|
|
117
118
|
relationsStr: _lodash.default.keys(relations).map(k => `${k}: { entityName: '${relations[k].entity}', entity: ${relations[k].entity}, denormFields: ${relations[k].denormFields} }`),
|
|
118
119
|
aggregates: fieldsArray.filter(f => f.type === "number" && !f.isArray).map(x => `'${x.name}'`).join(" | "),
|
|
119
120
|
primitives: fieldsArray.filter(f => !schema[f.type]?.decorators?.entity).map(x => `'${x.name}'`).join(" | ")
|
|
@@ -131,6 +132,7 @@ ${whereFields.join("\n")}
|
|
|
131
132
|
const entityMetaStr = entityMeta.map(x => `
|
|
132
133
|
'${x.type}': {
|
|
133
134
|
type: ${x.type}
|
|
135
|
+
whereType: ${x.whereType}
|
|
134
136
|
primitives: ${x.primitives || "never"}
|
|
135
137
|
aggregates: ${x.aggregates || "never"}
|
|
136
138
|
relations: {${x.relationsStr}}
|
package/integrations/node.mjs
CHANGED
|
@@ -97,7 +97,7 @@ export function getIndexDts(schema, options) {
|
|
|
97
97
|
if (options.entitiesDir) {
|
|
98
98
|
imports.push(`import type { ${type.name} } from '../../${options.entitiesDir}/${key}'`);
|
|
99
99
|
}
|
|
100
|
-
rootFields.push(`${type.handle}: EntityMethods<${type.name}, '${type.name}'
|
|
100
|
+
rootFields.push(`${type.handle}: EntityMethods<${type.name}, '${type.name}'>`);
|
|
101
101
|
const fieldsArray = Object.values(type.fields);
|
|
102
102
|
const relations = _.fromPairs(
|
|
103
103
|
fieldsArray.filter((f) => f.isRelation).map((f) => [
|
|
@@ -107,6 +107,7 @@ export function getIndexDts(schema, options) {
|
|
|
107
107
|
);
|
|
108
108
|
entityMeta.push({
|
|
109
109
|
type: type.name,
|
|
110
|
+
whereType: `${type.name}_Where`,
|
|
110
111
|
relationsStr: _.keys(relations).map(
|
|
111
112
|
(k) => `${k}: { entityName: '${relations[k].entity}', entity: ${relations[k].entity}, denormFields: ${relations[k].denormFields} }`
|
|
112
113
|
),
|
|
@@ -130,6 +131,7 @@ ${whereFields.join("\n")}
|
|
|
130
131
|
(x) => `
|
|
131
132
|
'${x.type}': {
|
|
132
133
|
type: ${x.type}
|
|
134
|
+
whereType: ${x.whereType}
|
|
133
135
|
primitives: ${x.primitives || "never"}
|
|
134
136
|
aggregates: ${x.aggregates || "never"}
|
|
135
137
|
relations: {${x.relationsStr}}
|