rads-db 0.1.108 → 0.1.111
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 +18 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +18 -0
- package/fileUploadDrivers/supabaseStorage.cjs +5 -2
- package/fileUploadDrivers/supabaseStorage.d.ts +1 -0
- package/fileUploadDrivers/supabaseStorage.mjs +5 -2
- package/integrations/restEndpoints.cjs +3 -0
- package/integrations/restEndpoints.mjs +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -980,6 +980,7 @@ function generateMethods(schema, validators, options) {
|
|
|
980
980
|
const opts = { computed: {}, driver: memory(), features: [], ...options };
|
|
981
981
|
const db = {
|
|
982
982
|
_schema: schema,
|
|
983
|
+
_radsUiSlots: getRadsUiSlots(opts.features),
|
|
983
984
|
uploadFile(args) {
|
|
984
985
|
if (!opts.fileUploadDriver)
|
|
985
986
|
throw new Error(`Missing configuration. Please specify "fileUploadDriver" argument in "createRads()".`);
|
|
@@ -1109,6 +1110,23 @@ function addDryRunSupport(driverInstance, entity) {
|
|
|
1109
1110
|
return putMany(data, ctx);
|
|
1110
1111
|
};
|
|
1111
1112
|
}
|
|
1113
|
+
function getRadsUiSlots(features) {
|
|
1114
|
+
const result = {};
|
|
1115
|
+
if (!features)
|
|
1116
|
+
return result;
|
|
1117
|
+
for (const f of features) {
|
|
1118
|
+
if (!f.radsUiSlots)
|
|
1119
|
+
continue;
|
|
1120
|
+
for (const key in f.radsUiSlots) {
|
|
1121
|
+
const slotKey = key;
|
|
1122
|
+
if (!result[slotKey])
|
|
1123
|
+
result[slotKey] = f.radsUiSlots[slotKey];
|
|
1124
|
+
else
|
|
1125
|
+
result[slotKey] = [...f.radsUiSlots[slotKey], ...result[slotKey]];
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return result;
|
|
1129
|
+
}
|
|
1112
1130
|
|
|
1113
1131
|
function entity(meta) {
|
|
1114
1132
|
return function(classConstructor, _ctx) {
|
package/dist/index.d.ts
CHANGED
|
@@ -304,8 +304,21 @@ interface FileSystemNode {
|
|
|
304
304
|
size?: number;
|
|
305
305
|
type: 'blob' | 'tree';
|
|
306
306
|
}
|
|
307
|
+
type RadsUiSlotName = 'entityListActions' | 'entityActions' | 'fieldActions';
|
|
308
|
+
interface RadsUiSlotDefinition {
|
|
309
|
+
entityName?: string | {
|
|
310
|
+
regExp: string;
|
|
311
|
+
};
|
|
312
|
+
fieldName?: string | {
|
|
313
|
+
regExp: string;
|
|
314
|
+
};
|
|
315
|
+
label: string;
|
|
316
|
+
icon?: string;
|
|
317
|
+
endpoint: string;
|
|
318
|
+
}
|
|
307
319
|
interface RadsFeature {
|
|
308
320
|
name: string;
|
|
321
|
+
radsUiSlots: Record<RadsUiSlotName, RadsUiSlotDefinition[]>;
|
|
309
322
|
init?: (db: Record<string, any>, context: ComputedContextGlobal) => void;
|
|
310
323
|
enhanceEntityMethods?: (context: ComputedContext, entityMethodsObj: EntityMethods<any, any, any>) => void;
|
|
311
324
|
beforeGet?: (args: GetArgsAny, ctx: RadsRequestContext, context: ComputedContext) => MaybePromise<any>;
|
|
@@ -331,4 +344,4 @@ declare function getDriverInstance(schema: Schema, key: string, driver: DriverCo
|
|
|
331
344
|
|
|
332
345
|
declare function createRads(args?: CreateRadsArgs): RadsDb;
|
|
333
346
|
|
|
334
|
-
export { Change, ComputedContext, ComputedContextGlobal, ComputedDecoratorArgs, CreateRadsArgs, DeepPartial, Driver, DriverConstructor, EntityDecoratorArgs, EntityMethods, 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, RadsVitePluginOptions, Relation, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, VerifyManyArgs, VerifyManyArgsAny, VerifyManyResponse, computed, createRads, entity, field, getDriverInstance, precomputed, ui, validate };
|
|
347
|
+
export { Change, ComputedContext, ComputedContextGlobal, ComputedDecoratorArgs, CreateRadsArgs, DeepPartial, Driver, DriverConstructor, EntityDecoratorArgs, EntityMethods, 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, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, VerifyManyArgs, VerifyManyArgsAny, VerifyManyResponse, computed, createRads, entity, field, getDriverInstance, precomputed, ui, validate };
|
package/dist/index.mjs
CHANGED
|
@@ -973,6 +973,7 @@ function generateMethods(schema, validators, options) {
|
|
|
973
973
|
const opts = { computed: {}, driver: memory(), features: [], ...options };
|
|
974
974
|
const db = {
|
|
975
975
|
_schema: schema,
|
|
976
|
+
_radsUiSlots: getRadsUiSlots(opts.features),
|
|
976
977
|
uploadFile(args) {
|
|
977
978
|
if (!opts.fileUploadDriver)
|
|
978
979
|
throw new Error(`Missing configuration. Please specify "fileUploadDriver" argument in "createRads()".`);
|
|
@@ -1102,6 +1103,23 @@ function addDryRunSupport(driverInstance, entity) {
|
|
|
1102
1103
|
return putMany(data, ctx);
|
|
1103
1104
|
};
|
|
1104
1105
|
}
|
|
1106
|
+
function getRadsUiSlots(features) {
|
|
1107
|
+
const result = {};
|
|
1108
|
+
if (!features)
|
|
1109
|
+
return result;
|
|
1110
|
+
for (const f of features) {
|
|
1111
|
+
if (!f.radsUiSlots)
|
|
1112
|
+
continue;
|
|
1113
|
+
for (const key in f.radsUiSlots) {
|
|
1114
|
+
const slotKey = key;
|
|
1115
|
+
if (!result[slotKey])
|
|
1116
|
+
result[slotKey] = f.radsUiSlots[slotKey];
|
|
1117
|
+
else
|
|
1118
|
+
result[slotKey] = [...f.radsUiSlots[slotKey], ...result[slotKey]];
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return result;
|
|
1122
|
+
}
|
|
1105
1123
|
|
|
1106
1124
|
function entity(meta) {
|
|
1107
1125
|
return function(classConstructor, _ctx) {
|
|
@@ -17,14 +17,17 @@ var _default = options => {
|
|
|
17
17
|
const {
|
|
18
18
|
data,
|
|
19
19
|
error
|
|
20
|
-
} = await bucketClient.upload(args.fileName, args.blob, {
|
|
20
|
+
} = await bucketClient.upload(args.fileName, args.blob, {
|
|
21
|
+
...options.uploadOptions,
|
|
22
|
+
...args.options
|
|
23
|
+
});
|
|
21
24
|
if (error) throw error;
|
|
22
25
|
const resultPath = data?.path;
|
|
23
26
|
if (!resultPath) return {
|
|
24
27
|
url: resultPath
|
|
25
28
|
};
|
|
26
29
|
return {
|
|
27
|
-
url: bucketClient.getPublicUrl(resultPath)
|
|
30
|
+
url: bucketClient.getPublicUrl(resultPath).data.publicUrl
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
};
|
|
@@ -7,13 +7,16 @@ export default (options) => {
|
|
|
7
7
|
driverName: "supabase",
|
|
8
8
|
async uploadFile(args) {
|
|
9
9
|
const bucketClient = supabase.storage.from(args.containerName || defaultBucket);
|
|
10
|
-
const { data, error } = await bucketClient.upload(args.fileName, args.blob, {
|
|
10
|
+
const { data, error } = await bucketClient.upload(args.fileName, args.blob, {
|
|
11
|
+
...options.uploadOptions,
|
|
12
|
+
...args.options
|
|
13
|
+
});
|
|
11
14
|
if (error)
|
|
12
15
|
throw error;
|
|
13
16
|
const resultPath = data?.path;
|
|
14
17
|
if (!resultPath)
|
|
15
18
|
return { url: resultPath };
|
|
16
|
-
return { url: bucketClient.getPublicUrl(resultPath) };
|
|
19
|
+
return { url: bucketClient.getPublicUrl(resultPath).data.publicUrl };
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
return driver;
|