rads-db 0.1.39 → 0.1.42

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
@@ -803,6 +803,10 @@ function ui(args) {
803
803
  return function(classConstructor, _ctx) {
804
804
  };
805
805
  }
806
+ function validate(args) {
807
+ return function(classConstructor, _ctx) {
808
+ };
809
+ }
806
810
  function field(meta) {
807
811
  return function(a, b) {
808
812
  };
@@ -848,3 +852,4 @@ exports.field = field;
848
852
  exports.getRestRoutes = getRestRoutes;
849
853
  exports.precomputed = precomputed;
850
854
  exports.ui = ui;
855
+ exports.validate = validate;
package/dist/index.d.ts CHANGED
@@ -67,6 +67,22 @@ interface EntityMethods<E, EN extends keyof EntityMeta, W> {
67
67
  }
68
68
 
69
69
  type MaybePromise<T> = Promise<T> | T;
70
+ type ValidateFieldDecoratorArgs<T> = T extends string ? ValidateStringDecoratorArgs : T extends number ? ValidateNumberDecoratorArgs : ValidateAnyDecoratorArgs;
71
+ interface ValidateEntityDecoratorArgs {
72
+ }
73
+ interface ValidateAnyDecoratorArgs {
74
+ }
75
+ interface ValidateNumberDecoratorArgs {
76
+ isWhole?: boolean;
77
+ min?: number;
78
+ max?: number;
79
+ }
80
+ interface ValidateStringDecoratorArgs {
81
+ preset?: 'number' | 'decimalNumber' | 'email' | 'icon' | 'imageUrl' | 'fileUrl' | 'absoluteUrl' | 'relativeUrl' | 'phoneNumber' | 'datetime' | 'date' | 'time' | 'timeInterval' | 'duration';
82
+ regex?: RegExp;
83
+ minLength?: number;
84
+ maxLength?: number;
85
+ }
70
86
  interface UiFieldDecoratorArgs {
71
87
  /** User-friendly name of the entity (singular).
72
88
  * Used as editor field label and column name in exports.
@@ -76,6 +92,8 @@ interface UiFieldDecoratorArgs {
76
92
  icon?: string;
77
93
  /** Free text - hint to display under editor field in UI */
78
94
  hint?: string;
95
+ /** TODO: Preferred component to display or edit this value */
96
+ component?: string;
79
97
  }
80
98
  interface UiDecoratorArgs<T = any> {
81
99
  /** User-friendly name of the entity (singular).
@@ -237,6 +255,7 @@ interface RadsRequestContext {
237
255
 
238
256
  declare function entity<T>(meta?: EntityDecoratorArgs): (classConstructor: new () => T, _ctx?: ClassDecoratorContext<any>) => void;
239
257
  declare function ui<T>(args: T extends new () => any ? UiDecoratorArgs<InstanceType<T>> : UiFieldDecoratorArgs): (classConstructor: T, _ctx?: ClassDecoratorContext | ClassFieldDecoratorContext) => void;
258
+ declare function validate<T, C, F>(args: T extends new () => any ? ValidateEntityDecoratorArgs : ValidateFieldDecoratorArgs<F>): (classConstructor: T, _ctx?: ClassDecoratorContext | ClassFieldDecoratorContext<C, F>) => void;
240
259
  declare function field(meta?: FieldDecoratorArgs): (a: any, b?: ClassFieldDecoratorContext) => void;
241
260
  declare function precomputed(meta?: ComputedDecoratorArgs): (a: any, b?: ClassFieldDecoratorContext | ClassDecoratorContext) => void;
242
261
  declare function computed(meta?: ComputedDecoratorArgs): (a: any, b?: ClassFieldDecoratorContext | ClassDecoratorContext) => void;
@@ -244,4 +263,4 @@ declare function computed(meta?: ComputedDecoratorArgs): (a: any, b?: ClassField
244
263
  declare function createRads(args?: CreateRadsArgs): RadsDb;
245
264
  declare function getRestRoutes(db: RadsDb, prefix?: string): Record<string, Record<string, Function>>;
246
265
 
247
- export { AzureCosmosDriverOptions, AzureStorageBlobUploadDriverOptions, Change, ComputedContext, ComputedDecoratorArgs, CreateRadsArgs, DeepPartial, Driver, DriverConstructor, DriverOptions, EntityDecoratorArgs, EntityMethods, FieldDecoratorArgs, FieldDefinition, FileUploadArgs, FileUploadDriver, GenerateClientNormalizedOptions, GenerateClientOptions, GetAggArgs, GetAggArgsAgg, GetAggArgsAny, GetAggResponse, GetArgs, GetArgsAny, GetArgsInclude, GetManyArgs, GetManyArgsAny, GetManyResponse, GetResponse, GetResponseInclude, GetResponseIncludeSelect, GetResponseNoInclude, MemoryDriverOptions, MemoryFileUploadDriverOptions, MinimalDriver, PutArgs, PutEffect, RadsRequestContext, Relation, RestDriverOptions, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, computed, createRads, entity, field, getRestRoutes, precomputed, ui };
266
+ export { AzureCosmosDriverOptions, AzureStorageBlobUploadDriverOptions, Change, ComputedContext, ComputedDecoratorArgs, CreateRadsArgs, DeepPartial, Driver, DriverConstructor, DriverOptions, EntityDecoratorArgs, EntityMethods, FieldDecoratorArgs, FieldDefinition, FileUploadArgs, FileUploadDriver, GenerateClientNormalizedOptions, GenerateClientOptions, GetAggArgs, GetAggArgsAgg, GetAggArgsAny, GetAggResponse, GetArgs, GetArgsAny, GetArgsInclude, GetManyArgs, GetManyArgsAny, GetManyResponse, GetResponse, GetResponseInclude, GetResponseIncludeSelect, GetResponseNoInclude, MemoryDriverOptions, MemoryFileUploadDriverOptions, MinimalDriver, PutArgs, PutEffect, RadsRequestContext, Relation, RestDriverOptions, RestFileUploadDriverOptions, Schema, SchemaValidators, TypeDefinition, UiDecoratorArgs, UiFieldDecoratorArgs, ValidateEntityDecoratorArgs, ValidateFieldDecoratorArgs, ValidateStringDecoratorArgs, computed, createRads, entity, field, getRestRoutes, precomputed, ui, validate };
package/dist/index.mjs CHANGED
@@ -797,6 +797,10 @@ function ui(args) {
797
797
  return function(classConstructor, _ctx) {
798
798
  };
799
799
  }
800
+ function validate(args) {
801
+ return function(classConstructor, _ctx) {
802
+ };
803
+ }
800
804
  function field(meta) {
801
805
  return function(a, b) {
802
806
  };
@@ -835,4 +839,4 @@ function getRestRoutes(db, prefix = "/") {
835
839
  return routes;
836
840
  }
837
841
 
838
- export { computed, createRads, entity, field, getRestRoutes, precomputed, ui };
842
+ export { computed, createRads, entity, field, getRestRoutes, precomputed, ui, validate };
@@ -19,12 +19,17 @@ var _default = options => {
19
19
  const containerClient = client.getContainerClient(args.containerName || defaultContainer);
20
20
  const fileName = `${options.fileNamePrefix || ""}${args.fileName}`;
21
21
  const blobClient = containerClient.getBlockBlobClient(fileName);
22
- await blobClient.upload(args.blob, args.blob.size || args.blob.length, {
23
- blobHTTPHeaders: {
24
- blobContentType: args.blob.type || void 0
25
- },
26
- ...args.options
27
- });
22
+ try {
23
+ await blobClient.upload(await args.blob.arrayBuffer(), args.blob.size || args.blob.length, {
24
+ blobHTTPHeaders: {
25
+ blobContentType: args.blob.type || void 0
26
+ },
27
+ ...args.options
28
+ });
29
+ } catch (e) {
30
+ console.error("Error uploading file to azure storage:");
31
+ throw e;
32
+ }
28
33
  return blobClient.url.split("?")[0];
29
34
  }
30
35
  };
@@ -9,12 +9,17 @@ export default (options) => {
9
9
  const containerClient = client.getContainerClient(args.containerName || defaultContainer);
10
10
  const fileName = `${options.fileNamePrefix || ""}${args.fileName}`;
11
11
  const blobClient = containerClient.getBlockBlobClient(fileName);
12
- await blobClient.upload(args.blob, args.blob.size || args.blob.length, {
13
- blobHTTPHeaders: {
14
- blobContentType: args.blob.type || void 0
15
- },
16
- ...args.options
17
- });
12
+ try {
13
+ await blobClient.upload(await args.blob.arrayBuffer(), args.blob.size || args.blob.length, {
14
+ blobHTTPHeaders: {
15
+ blobContentType: args.blob.type || void 0
16
+ },
17
+ ...args.options
18
+ });
19
+ } catch (e) {
20
+ console.error("Error uploading file to azure storage:");
21
+ throw e;
22
+ }
18
23
  return blobClient.url.split("?")[0];
19
24
  }
20
25
  };
@@ -19,8 +19,7 @@ var _default = options => {
19
19
  async uploadFile(args) {
20
20
  const form = new _formData.default();
21
21
  form.append("containerName", args.containerName || "");
22
- form.append("fileName", args.fileName || "");
23
- form.append("blob", args.blob);
22
+ form.append("blob", args.blob, args.fileName);
24
23
  const response = await fetch(`${options.baseUrl}/uploadFile`, {
25
24
  method: "POST",
26
25
  body: form
@@ -9,8 +9,7 @@ export default (options) => {
9
9
  async uploadFile(args) {
10
10
  const form = new FormData();
11
11
  form.append("containerName", args.containerName || "");
12
- form.append("fileName", args.fileName || "");
13
- form.append("blob", args.blob);
12
+ form.append("blob", args.blob, args.fileName);
14
13
  const response = await fetch(`${options.baseUrl}/uploadFile`, {
15
14
  method: "POST",
16
15
  body: form
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  "require": "./integrations/*.cjs"
35
35
  }
36
36
  },
37
- "version": "0.1.39",
37
+ "version": "0.1.42",
38
38
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
39
39
  "keywords": [],
40
40
  "author": "",