rads-db 3.0.13 → 3.0.15
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.cjs +11 -2
- package/dist/index.d.ts +7 -4
- package/dist/index.mjs +11 -2
- package/features/softDelete.cjs +1 -3
- package/features/softDelete.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -983,10 +983,19 @@ function generateMethods(schema, validators, options) {
|
|
|
983
983
|
const db = {
|
|
984
984
|
_schema: schema,
|
|
985
985
|
_radsUiSlots: getRadsUiSlots(opts.features),
|
|
986
|
-
uploadFile(args) {
|
|
986
|
+
async uploadFile(args) {
|
|
987
|
+
for (const f of opts.features) {
|
|
988
|
+
const result2 = await f.beforeUploadFile?.(args);
|
|
989
|
+
if (result2)
|
|
990
|
+
return result2;
|
|
991
|
+
}
|
|
987
992
|
if (!opts.fileUploadDriver)
|
|
988
993
|
throw new Error(`Missing configuration. Please specify "fileUploadDriver" argument in "createRads()".`);
|
|
989
|
-
|
|
994
|
+
const result = await opts.fileUploadDriver.uploadFile(args);
|
|
995
|
+
for (const f of opts.features) {
|
|
996
|
+
await f.afterUploadFile?.(result, args);
|
|
997
|
+
}
|
|
998
|
+
return result;
|
|
990
999
|
}
|
|
991
1000
|
};
|
|
992
1001
|
const effects = {};
|
package/dist/index.d.ts
CHANGED
|
@@ -207,12 +207,13 @@ interface TypeDefinition {
|
|
|
207
207
|
handle?: string;
|
|
208
208
|
handlePlural?: string;
|
|
209
209
|
}
|
|
210
|
+
interface FileUploadResult {
|
|
211
|
+
url: string;
|
|
212
|
+
}
|
|
210
213
|
interface FileUploadDriver {
|
|
211
214
|
driverName: string;
|
|
212
215
|
client?: any;
|
|
213
|
-
uploadFile(args: FileUploadArgs, ctx?: RadsRequestContext): Promise<
|
|
214
|
-
url: string;
|
|
215
|
-
}>;
|
|
216
|
+
uploadFile(args: FileUploadArgs, ctx?: RadsRequestContext): Promise<FileUploadResult>;
|
|
216
217
|
}
|
|
217
218
|
interface GetRestRoutesOptions {
|
|
218
219
|
/** Instance of RadsDb */
|
|
@@ -366,6 +367,8 @@ interface RadsFeature {
|
|
|
366
367
|
oldDoc: any;
|
|
367
368
|
doc: any;
|
|
368
369
|
}[], ctx: RadsRequestContext, computedContext: ComputedContext) => void;
|
|
370
|
+
beforeUploadFile?: (args: FileUploadArgs) => MaybePromise<any>;
|
|
371
|
+
afterUploadFile?: (result: FileUploadResult, args: FileUploadArgs) => MaybePromise<void>;
|
|
369
372
|
}
|
|
370
373
|
|
|
371
374
|
declare function entity<T>(meta?: EntityDecoratorArgs): (classConstructor: new () => T, _ctx?: ClassDecoratorContext<any>) => void;
|
|
@@ -389,4 +392,4 @@ declare function createRadsDb(args?: CreateRadsDbArgs): RadsDb;
|
|
|
389
392
|
*/
|
|
390
393
|
declare function createRadsDbClient(args?: CreateRadsDbClientArgs): RadsDb;
|
|
391
394
|
|
|
392
|
-
export { Change, ComputedContext, ComputedContextGlobal, ComputedDecoratorArgs, CreateRadsArgsDrivers, CreateRadsDbArgs, CreateRadsDbArgsNormalized, CreateRadsDbClientArgs, DeepPartial, Driver, DriverConstructor, EntityDecoratorArgs, EntityMethods, EnumDefinition, FieldDecoratorArgs, FieldDefinition, FileSystemNode, FileUploadArgs, FileUploadDriver, GenerateClientNormalizedOptions, GenerateClientOptions, GetAggArgs, GetAggArgsAgg, GetAggArgsAny, GetAggResponse, GetArgs, GetArgsAny, GetArgsInclude, GetManyArgs, GetManyArgsAny, GetManyResponse, GetResponse, GetResponseInclude, GetResponseIncludeSelect, GetResponseNoInclude, GetRestRoutesArgs, GetRestRoutesOptions, GetRestRoutesResponse, MinimalDriver, PutArgs, PutEffect, RadsFeature, RadsRequestContext, RadsUiSlotDefinition, RadsUiSlotName, RadsVitePluginOptions, Relation, RequiredFields, RestDriverOptions, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, VerifyManyArgs, VerifyManyArgsAny, VerifyManyResponse, computed, createRadsDb, createRadsDbClient, entity, field, getDriverInstance, precomputed, ui, validate };
|
|
395
|
+
export { Change, ComputedContext, ComputedContextGlobal, ComputedDecoratorArgs, CreateRadsArgsDrivers, CreateRadsDbArgs, CreateRadsDbArgsNormalized, CreateRadsDbClientArgs, DeepPartial, Driver, DriverConstructor, EntityDecoratorArgs, EntityMethods, EnumDefinition, FieldDecoratorArgs, FieldDefinition, FileSystemNode, FileUploadArgs, FileUploadDriver, FileUploadResult, GenerateClientNormalizedOptions, GenerateClientOptions, GetAggArgs, GetAggArgsAgg, GetAggArgsAny, GetAggResponse, GetArgs, GetArgsAny, GetArgsInclude, GetManyArgs, GetManyArgsAny, GetManyResponse, GetResponse, GetResponseInclude, GetResponseIncludeSelect, GetResponseNoInclude, GetRestRoutesArgs, GetRestRoutesOptions, GetRestRoutesResponse, MinimalDriver, PutArgs, PutEffect, RadsFeature, RadsRequestContext, RadsUiSlotDefinition, RadsUiSlotName, RadsVitePluginOptions, Relation, RequiredFields, RestDriverOptions, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, VerifyManyArgs, VerifyManyArgsAny, VerifyManyResponse, computed, createRadsDb, createRadsDbClient, entity, field, getDriverInstance, precomputed, ui, validate };
|
package/dist/index.mjs
CHANGED
|
@@ -975,10 +975,19 @@ function generateMethods(schema, validators, options) {
|
|
|
975
975
|
const db = {
|
|
976
976
|
_schema: schema,
|
|
977
977
|
_radsUiSlots: getRadsUiSlots(opts.features),
|
|
978
|
-
uploadFile(args) {
|
|
978
|
+
async uploadFile(args) {
|
|
979
|
+
for (const f of opts.features) {
|
|
980
|
+
const result2 = await f.beforeUploadFile?.(args);
|
|
981
|
+
if (result2)
|
|
982
|
+
return result2;
|
|
983
|
+
}
|
|
979
984
|
if (!opts.fileUploadDriver)
|
|
980
985
|
throw new Error(`Missing configuration. Please specify "fileUploadDriver" argument in "createRads()".`);
|
|
981
|
-
|
|
986
|
+
const result = await opts.fileUploadDriver.uploadFile(args);
|
|
987
|
+
for (const f of opts.features) {
|
|
988
|
+
await f.afterUploadFile?.(result, args);
|
|
989
|
+
}
|
|
990
|
+
return result;
|
|
982
991
|
}
|
|
983
992
|
};
|
|
984
993
|
const effects = {};
|
package/features/softDelete.cjs
CHANGED
|
@@ -11,9 +11,7 @@ var _default = () => {
|
|
|
11
11
|
if (!context.schema[context.typeName]?.fields?.isDeleted) return;
|
|
12
12
|
if (args.where.isDeleted || args.where.isDeleted_in) return;
|
|
13
13
|
args.where._and = [...(args.where._and || []), {
|
|
14
|
-
|
|
15
|
-
isDeleted: true
|
|
16
|
-
}
|
|
14
|
+
isDeleted: false
|
|
17
15
|
}];
|
|
18
16
|
}
|
|
19
17
|
};
|
package/features/softDelete.mjs
CHANGED