rads-db 0.1.109 → 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 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,7 +17,10 @@ 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 {
@@ -4,4 +4,5 @@ export default _default;
4
4
  interface SupabaseFileUploadDriverOptions {
5
5
  supabase: SupabaseClient;
6
6
  defaultBucket?: string;
7
+ uploadOptions?: Parameters<ReturnType<SupabaseClient['storage']['from']>['upload']>['2'];
7
8
  }
@@ -7,7 +7,10 @@ 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;
@@ -98,6 +98,9 @@ function getRadsTunnelHandler(options) {
98
98
  if (method === "_schema") {
99
99
  return db._schema;
100
100
  }
101
+ if (method === "_radsUiSlots") {
102
+ return db._radsUiSlots;
103
+ }
101
104
  if (method === "getProcessInfo") {
102
105
  return {};
103
106
  }
@@ -65,6 +65,9 @@ export function getRadsTunnelHandler(options) {
65
65
  if (method === "_schema") {
66
66
  return db._schema;
67
67
  }
68
+ if (method === "_radsUiSlots") {
69
+ return db._radsUiSlots;
70
+ }
68
71
  if (method === "getProcessInfo") {
69
72
  return {};
70
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "0.1.109",
3
+ "version": "0.1.111",
4
4
  "files": [
5
5
  "dist",
6
6
  "drivers",