@quatrain/core 1.0.0-beta22 → 1.0.0-beta23

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.
@@ -0,0 +1,39 @@
1
+ import Middleware from './backends/middlewares/Middleware';
2
+ export declare enum BackendAction {
3
+ CREATE = "create",
4
+ READ = "read",
5
+ UPDATE = "update",
6
+ DELETE = "delete",
7
+ WRITE = "write"
8
+ }
9
+ /**
10
+ * Default interface for a backend record
11
+ */
12
+ export interface BackendRecordType {
13
+ uid: string | undefined;
14
+ path: string | undefined;
15
+ [key: string]: any;
16
+ }
17
+ /**
18
+ * Backend Parameters acceptable keys
19
+ */
20
+ export type BackendParametersKeys = 'host' | 'alias' | 'mapping' | 'middlewares' | 'config' | 'fixtures' | 'softDelete' | 'debug';
21
+ /**
22
+ * Backend parameters interface
23
+ */
24
+ export interface BackendParameters {
25
+ host?: string;
26
+ alias?: string;
27
+ hierarchy?: {
28
+ [collection: string]: any;
29
+ };
30
+ mapping?: {
31
+ [x: string]: any;
32
+ };
33
+ middlewares?: Middleware[];
34
+ config?: any;
35
+ fixtures?: any;
36
+ softDelete?: boolean;
37
+ useNativeForeignKeys?: boolean;
38
+ debug?: boolean;
39
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackendAction = void 0;
4
+ var BackendAction;
5
+ (function (BackendAction) {
6
+ BackendAction["CREATE"] = "create";
7
+ BackendAction["READ"] = "read";
8
+ BackendAction["UPDATE"] = "update";
9
+ BackendAction["DELETE"] = "delete";
10
+ BackendAction["WRITE"] = "write";
11
+ })(BackendAction || (exports.BackendAction = BackendAction = {}));
package/lib/Core.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import { AbstractAuthAdapter } from './authentication';
2
2
  import { AbstractAdapter } from './backends/AbstractAdapter';
3
+ import { AbstractStorageAdapter } from './storages';
3
4
  import { User } from './components/User';
4
5
  import { DataObjectClass } from './components/types/DataObjectClass';
5
6
  export type BackendRegistry<T extends AbstractAdapter> = {
6
7
  [x: string]: T;
7
8
  };
9
+ export type StorageBackendRegistry<T extends AbstractStorageAdapter> = {
10
+ [x: string]: T;
11
+ };
8
12
  export interface AuthAdapter extends AbstractAuthAdapter {
9
13
  }
10
14
  export declare class Core {
@@ -20,7 +24,7 @@ export declare class Core {
20
24
  static auth: AuthAdapter | AbstractAuthAdapter;
21
25
  static timestamp: () => string;
22
26
  protected static _backends: BackendRegistry<any>;
23
- protected static _storages: BackendRegistry<any>;
27
+ protected static _storages: StorageBackendRegistry<any>;
24
28
  static definition(key: string): {
25
29
  manifest: {
26
30
  type: StringConstructor;
@@ -31,8 +35,8 @@ export declare class Core {
31
35
  static getConfig(key: string): Promise<any>;
32
36
  static addBackend(backend: AbstractAdapter, alias: string, setDefault?: boolean): void;
33
37
  static getBackend<T extends AbstractAdapter>(alias?: string): T;
34
- static addStorage(backend: AbstractAdapter, alias: string, setDefault?: boolean): void;
35
- static getStorage<T extends AbstractAdapter>(alias?: string): T;
38
+ static addStorage(backend: AbstractStorageAdapter, alias: string, setDefault?: boolean): void;
39
+ static getStorage<T extends AbstractStorageAdapter>(alias?: string): T;
36
40
  static addClass(name: string, obj: any): void;
37
41
  static getClass(name: string): any;
38
42
  /**
package/lib/Core.js CHANGED
@@ -23,13 +23,17 @@ class Core {
23
23
  }
24
24
  static addConfig(key, value) {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
- yield this.storage.init( /* options ... */);
26
+ if (!this.storage.set) {
27
+ yield this.storage.init();
28
+ }
27
29
  yield this.storage.set(`${this.storagePrefix}_${key}`, value);
28
30
  });
29
31
  }
30
32
  static getConfig(key) {
31
33
  return __awaiter(this, void 0, void 0, function* () {
32
- yield this.storage.init( /* options ... */);
34
+ if (!this.storage.get) {
35
+ yield this.storage.init();
36
+ }
33
37
  return yield this.storage.get(`${this.storagePrefix}_${key}`);
34
38
  });
35
39
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Backend Parameters acceptable keys
3
+ */
4
+ export type StorageParametersKeys = 'region' | 'alias' | 'config' | 'debug';
5
+ /**
6
+ * Backend parameters interface
7
+ */
8
+ export interface StorageParameters {
9
+ region?: string;
10
+ alias?: string;
11
+ config?: any;
12
+ debug?: boolean;
13
+ }
package/lib/Storage.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -15,6 +15,7 @@ export type QueryMetaType = {
15
15
  executionTime: string | number;
16
16
  sortField?: string;
17
17
  sortOrder?: 'asc' | 'desc';
18
+ debug?: any;
18
19
  };
19
20
  export type QueryResultType<T> = {
20
21
  items: Array<T>;
@@ -54,7 +54,7 @@ class Query {
54
54
  else {
55
55
  if (operator === 'equals' && Array.isArray(value)) {
56
56
  // auto-convert operator if value is an array
57
- operator = 'contains'; // Any'
57
+ operator = 'contains';
58
58
  }
59
59
  this.filters.push(new Filter_1.Filter(param, value, operator));
60
60
  }
@@ -107,8 +107,6 @@ class Query {
107
107
  }
108
108
  execute(as = returnAs.AS_DATAOBJECTS, backend = Core_1.Core.getBackend(this._obj.DEFAULT_BACKEND)) {
109
109
  return __awaiter(this, void 0, void 0, function* () {
110
- //<DataObjectClass<any>[] | ObjectUri[] | Persisted<BaseObject>[]> {
111
- //</any><Array<T2> | Array<DataObject> | Array<ObjectUri>> {
112
110
  try {
113
111
  switch (as) {
114
112
  case exports.AS_DATAOBJECTS:
@@ -76,6 +76,9 @@ class BaseRepository {
76
76
  }
77
77
  read(key) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
+ if (!key) {
80
+ throw new Error(`Missing key value in ${this.constructor.name}`);
81
+ }
79
82
  try {
80
83
  let dataObject;
81
84
  if (key.split('/').length <= 2) {
package/lib/index.d.ts CHANGED
@@ -30,6 +30,7 @@ import { AuthAction, AuthParameters, AuthParametersKeys } from './Auth';
30
30
  import { AuthInterface, AbstractAuthAdapter, AuthenticationError } from './authentication';
31
31
  import { AbstractAdapter, MockAdapter, BackendError, Query, QueryMetaType, QueryResultType, Filter, Filters, Limits, Sorting, SortAndLimit } from './backends';
32
32
  import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError } from './common/ResourcesErrors';
33
+ import { StorageParameters, StorageParametersKeys } from './Storage';
33
34
  import { AbstractStorageAdapter } from './storages/AbstractStorageAdapter';
34
35
  import { FileType } from './storages/types/FileType';
35
36
  import { BlobType } from './storages/types/BlobType';
@@ -37,6 +38,7 @@ import { BlobMediaType } from './storages/types/BlobMediaType';
37
38
  import { StorageAdapterInterface } from './storages/StorageAdapterInterface';
38
39
  import { FileResponseLink } from './storages/types/FileResponseLink';
39
40
  import { FileResponseUrl } from './storages/types/FileResponseUrl';
41
+ import { DownloadFileMeta } from './storages/types/DownloadFileMetaType';
40
42
  import { DatabaseTriggerType } from './wrappers/cloud/types/DatabaseTriggerType';
41
43
  import { AbstractCloudWrapper } from './wrappers/cloud/AbstractCloudWrapper';
42
- export { statuses, utils, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, AbstractAdapter, RepositoryClass, MockAdapter, ObjectUri, DataObjectClass, DataObject, AbstractObject, BaseObject, BaseObjectCore, BaseObjectProperties, AuthAction, AuthParameters, AuthParametersKeys, AuthInterface, AbstractAuthAdapter, AuthenticationError, BackendParameters, BackendParametersKeys, BackendRecordType, BackendAction, BaseRepository, BackendError, Query, QueryMetaType, QueryResultType, Filter, Filters, Limits, Sorting, SortAndLimit, Middleware, InjectMetaMiddleware, InjectKeywordsMiddleware, User, UserType, Proxy, UserRepository, Entity, EntityType, EntityRepository, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, FileType, BlobType, BlobMediaType, StorageAdapterInterface, AbstractStorageAdapter, FileResponseLink, FileResponseUrl, DatabaseTriggerType, AbstractCloudWrapper, };
44
+ export { statuses, utils, Core, Property, BaseProperty, BasePropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, HashProperty, HashPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, AbstractAdapter, RepositoryClass, MockAdapter, ObjectUri, DataObjectClass, DataObject, AbstractObject, BaseObject, BaseObjectCore, BaseObjectProperties, AuthAction, AuthParameters, AuthParametersKeys, AuthInterface, AbstractAuthAdapter, AuthenticationError, BackendParameters, BackendParametersKeys, BackendRecordType, BackendAction, BaseRepository, BackendError, Query, QueryMetaType, QueryResultType, Filter, Filters, Limits, Sorting, SortAndLimit, Middleware, InjectMetaMiddleware, InjectKeywordsMiddleware, User, UserType, Proxy, UserRepository, Entity, EntityType, EntityRepository, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, GoneError, StorageParameters, StorageParametersKeys, FileType, BlobType, BlobMediaType, StorageAdapterInterface, AbstractStorageAdapter, FileResponseLink, FileResponseUrl, DownloadFileMeta, DatabaseTriggerType, AbstractCloudWrapper, };
@@ -0,0 +1,10 @@
1
+ import { ObjectUri } from '../components/ObjectUri';
2
+ import { BaseProperty, BasePropertyType } from './BaseProperty';
3
+ import { BaseObjectClass } from '../components/types/BaseObjectClass';
4
+ export interface FilePropertyType extends BasePropertyType {
5
+ }
6
+ export declare class FileProperty extends BaseProperty {
7
+ static TYPE: string;
8
+ _value: BaseObjectClass | ObjectUri | undefined;
9
+ constructor(config: FilePropertyType);
10
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileProperty = void 0;
4
+ const BaseProperty_1 = require("./BaseProperty");
5
+ class FileProperty extends BaseProperty_1.BaseProperty {
6
+ constructor(config) {
7
+ super(config);
8
+ this._value = undefined;
9
+ }
10
+ }
11
+ exports.FileProperty = FileProperty;
12
+ FileProperty.TYPE = 'file';
@@ -0,0 +1,16 @@
1
+ import { ObjectUri } from '../components/ObjectUri';
2
+ import { BaseProperty, BasePropertyType } from './BaseProperty';
3
+ import { BaseObjectClass } from '../components/types/BaseObjectClass';
4
+ export interface ObjectPropertyType extends BasePropertyType {
5
+ instanceOf: any;
6
+ }
7
+ export declare class ObjectProperty extends BaseProperty {
8
+ static TYPE: string;
9
+ _value: BaseObjectClass | ObjectUri | undefined;
10
+ _instanceOf: any;
11
+ constructor(config: ObjectPropertyType);
12
+ get instanceOf(): any;
13
+ val(transform?: string | undefined): any;
14
+ set(value: object, setChanged?: boolean): this;
15
+ toJSON(): any;
16
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectProperty = void 0;
4
+ const DataObject_1 = require("../components/DataObject");
5
+ const ObjectUri_1 = require("../components/ObjectUri");
6
+ const BaseProperty_1 = require("./BaseProperty");
7
+ const Query_1 = require("../backends/Query");
8
+ const Core_1 = require("../Core");
9
+ class ObjectProperty extends BaseProperty_1.BaseProperty {
10
+ constructor(config) {
11
+ super(config);
12
+ this._value = undefined;
13
+ this._instanceOf = config.instanceOf;
14
+ }
15
+ get instanceOf() {
16
+ return this._instanceOf;
17
+ }
18
+ val(transform = undefined) {
19
+ if (typeof this._instanceOf === 'string') {
20
+ this._instanceOf = Core_1.Core.getClass(this._instanceOf);
21
+ }
22
+ if (!this._value) {
23
+ return this._defaultValue;
24
+ }
25
+ switch (transform) {
26
+ case Query_1.returnAs.AS_DATAOBJECTS:
27
+ if (this._value instanceof DataObject_1.DataObject) {
28
+ console.log(`Returning already existing dataObject`);
29
+ return this._value;
30
+ }
31
+ else if (this._value instanceof ObjectUri_1.ObjectUri) {
32
+ console.log(`Converting objectUri -> dataObject`);
33
+ return DataObject_1.DataObject.factory({
34
+ properties: Reflect.get(this._instanceOf, 'PROPS_DEFINITION'),
35
+ uri: this._value,
36
+ });
37
+ }
38
+ else {
39
+ console.log(`Converting instance -> dataObject`);
40
+ return this._value.dataObject;
41
+ }
42
+ case Query_1.returnAs.AS_INSTANCES:
43
+ if (this._value instanceof DataObject_1.DataObject) {
44
+ console.log(`Converting dataObject -> instance`);
45
+ return Reflect.construct(this._instanceOf, [this._value]);
46
+ }
47
+ else if (this._value instanceof ObjectUri_1.ObjectUri) {
48
+ // console.log('ObjectProperty', this)
49
+ console.log(`Converting objectUri -> dataObject -> instance`);
50
+ // console.log(this._instanceOf)
51
+ const dao = DataObject_1.DataObject.factory({
52
+ properties: Reflect.get(this._instanceOf, 'PROPS_DEFINITION'),
53
+ uri: this._value,
54
+ });
55
+ return Reflect.construct(this._instanceOf, [dao]);
56
+ }
57
+ else {
58
+ console.log(`Returning already existing instance`);
59
+ return this._value;
60
+ }
61
+ case Query_1.returnAs.AS_OBJECTURIS:
62
+ default:
63
+ return this._value;
64
+ }
65
+ }
66
+ set(value, setChanged = true) {
67
+ if (value instanceof ObjectUri_1.ObjectUri &&
68
+ value instanceof DataObject_1.DataObject &&
69
+ value.constructor.name !== this._instanceOf.constructor.name) {
70
+ throw new Error(`value ${JSON.stringify(value)} is not an instance of ${this._instanceOf.constructor.name}`);
71
+ }
72
+ return super.set(value, setChanged);
73
+ }
74
+ toJSON() {
75
+ if (this._value instanceof ObjectUri_1.ObjectUri) {
76
+ return this._value.toJSON();
77
+ }
78
+ return this._value &&
79
+ (this._value.dataObject || this._value instanceof DataObject_1.DataObject)
80
+ ? this._value.dataObject.toReference()
81
+ : null;
82
+ }
83
+ }
84
+ exports.ObjectProperty = ObjectProperty;
85
+ ObjectProperty.TYPE = 'object';
@@ -9,6 +9,7 @@ export declare class ObjectProperty extends BaseProperty {
9
9
  _value: BaseObjectClass | ObjectUri | undefined;
10
10
  _instanceOf: any;
11
11
  constructor(config: ObjectPropertyType);
12
+ get instanceOf(): any;
12
13
  val(transform?: string | undefined): any;
13
14
  set(value: object, setChanged?: boolean): this;
14
15
  toJSON(): any;
@@ -12,11 +12,12 @@ class ObjectProperty extends BaseProperty_1.BaseProperty {
12
12
  this._value = undefined;
13
13
  this._instanceOf = config.instanceOf;
14
14
  }
15
+ get instanceOf() {
16
+ return this._instanceOf;
17
+ }
15
18
  val(transform = undefined) {
16
19
  if (typeof this._instanceOf === 'string') {
17
- //console.log(`Getting instance from string ${this._instanceOf}`)
18
20
  this._instanceOf = Core_1.Core.getClass(this._instanceOf);
19
- //throw new Error(`Parameter 'instanceOf' was not properly setted`)
20
21
  }
21
22
  if (!this._value) {
22
23
  return this._defaultValue;
@@ -7,6 +7,7 @@ import { HashPropertyType } from './HashProperty';
7
7
  import { StringPropertyType } from './StringProperty';
8
8
  import { NumberPropertyType } from './NumberProperty';
9
9
  import { ObjectPropertyType } from './ObjectProperty';
10
+ import { FilePropertyType } from './FileProperty';
10
11
  export declare class Property {
11
12
  static TYPE_ANY: string;
12
13
  static TYPE_NUMBER: string;
@@ -18,5 +19,6 @@ export declare class Property {
18
19
  static TYPE_DATETIME: string;
19
20
  static TYPE_ARRAY: string;
20
21
  static TYPE_MAP: string;
21
- static factory(params: ObjectPropertyType & StringPropertyType & NumberPropertyType & EnumPropertyType & BooleanPropertyType & HashPropertyType & DateTimePropertyType, parent: DataObjectClass<any>): BaseProperty;
22
+ static TYPE_FILE: string;
23
+ static factory(params: ObjectPropertyType & StringPropertyType & NumberPropertyType & EnumPropertyType & BooleanPropertyType & HashPropertyType & DateTimePropertyType & FilePropertyType, parent: DataObjectClass<any>): BaseProperty;
22
24
  }
@@ -12,6 +12,7 @@ const ObjectProperty_1 = require("./ObjectProperty");
12
12
  const CollectionProperty_1 = require("./CollectionProperty");
13
13
  const ArrayProperty_1 = require("./ArrayProperty");
14
14
  const MapProperty_1 = require("./MapProperty");
15
+ const FileProperty_1 = require("./FileProperty");
15
16
  class Property {
16
17
  static factory(params, parent) {
17
18
  params.parent = parent;
@@ -41,6 +42,8 @@ class Property {
41
42
  return new ArrayProperty_1.ArrayProperty(params);
42
43
  case MapProperty_1.MapProperty.TYPE:
43
44
  return new MapProperty_1.MapProperty(params);
45
+ case FileProperty_1.FileProperty.TYPE:
46
+ return new FileProperty_1.FileProperty(params);
44
47
  default:
45
48
  throw new Error(`Unknown property type ${params.type}`);
46
49
  }
@@ -57,3 +60,4 @@ Property.TYPE_HASH = 'hash';
57
60
  Property.TYPE_DATETIME = 'datetime';
58
61
  Property.TYPE_ARRAY = 'array';
59
62
  Property.TYPE_MAP = 'map';
63
+ Property.TYPE_FILE = 'file';
@@ -9,9 +9,10 @@ import { BooleanProperty, BooleanPropertyType } from './BooleanProperty';
9
9
  import { DateTimeProperty, DateTimePropertyType } from './DateTimeProperty';
10
10
  import { ObjectProperty, ObjectPropertyType } from './ObjectProperty';
11
11
  import { MapProperty, MapPropertyType } from './MapProperty';
12
+ import { FileProperty, FilePropertyType } from './FileProperty';
12
13
  import { CollectionProperty, CollectionPropertyType } from './CollectionProperty';
13
14
  import { PropertyTypes } from './types/PropertyTypes';
14
- export { Property, BaseProperty, BasePropertyType, ArrayProperty, ArrayPropertyType, NumberProperty, NumberPropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, HashProperty, HashPropertyType, MapProperty, MapPropertyType, CollectionProperty, CollectionPropertyType, };
15
+ export { Property, BaseProperty, BasePropertyType, ArrayProperty, ArrayPropertyType, NumberProperty, NumberPropertyType, BooleanProperty, BooleanPropertyType, DateTimeProperty, DateTimePropertyType, EnumProperty, EnumPropertyType, ObjectProperty, ObjectPropertyType, StringProperty, StringPropertyType, HashProperty, HashPropertyType, MapProperty, MapPropertyType, FileProperty, FilePropertyType, CollectionProperty, CollectionPropertyType, };
15
16
  type BaseType = {
16
17
  type: PropertyTypes;
17
18
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CollectionProperty = exports.MapProperty = exports.HashProperty = exports.StringProperty = exports.ObjectProperty = exports.EnumProperty = exports.DateTimeProperty = exports.BooleanProperty = exports.NumberProperty = exports.ArrayProperty = exports.BaseProperty = exports.Property = void 0;
3
+ exports.CollectionProperty = exports.FileProperty = exports.MapProperty = exports.HashProperty = exports.StringProperty = exports.ObjectProperty = exports.EnumProperty = exports.DateTimeProperty = exports.BooleanProperty = exports.NumberProperty = exports.ArrayProperty = exports.BaseProperty = exports.Property = void 0;
4
4
  const Property_1 = require("./Property");
5
5
  Object.defineProperty(exports, "Property", { enumerable: true, get: function () { return Property_1.Property; } });
6
6
  const BaseProperty_1 = require("./BaseProperty");
@@ -23,5 +23,7 @@ const ObjectProperty_1 = require("./ObjectProperty");
23
23
  Object.defineProperty(exports, "ObjectProperty", { enumerable: true, get: function () { return ObjectProperty_1.ObjectProperty; } });
24
24
  const MapProperty_1 = require("./MapProperty");
25
25
  Object.defineProperty(exports, "MapProperty", { enumerable: true, get: function () { return MapProperty_1.MapProperty; } });
26
+ const FileProperty_1 = require("./FileProperty");
27
+ Object.defineProperty(exports, "FileProperty", { enumerable: true, get: function () { return FileProperty_1.FileProperty; } });
26
28
  const CollectionProperty_1 = require("./CollectionProperty");
27
29
  Object.defineProperty(exports, "CollectionProperty", { enumerable: true, get: function () { return CollectionProperty_1.CollectionProperty; } });
@@ -2,10 +2,16 @@
2
2
  import { Readable } from 'stream';
3
3
  import { FileType } from './types/FileType';
4
4
  import { StorageAdapterInterface } from './StorageAdapterInterface';
5
+ import { DownloadFileMeta } from './types/DownloadFileMetaType';
6
+ import { StorageParameters } from '../Storage';
5
7
  export declare abstract class AbstractStorageAdapter implements StorageAdapterInterface {
8
+ protected _alias: string;
9
+ protected _params: StorageParameters;
10
+ constructor(params?: StorageParameters);
6
11
  abstract getDriver(): any;
7
12
  abstract create(file: FileType, stream: Readable): Promise<FileType>;
8
- abstract download(file: FileType, path: string): Promise<string>;
13
+ abstract download(file: FileType, path: DownloadFileMeta): Promise<any>;
14
+ abstract copy(file: FileType, destFile: FileType): Promise<any>;
9
15
  abstract getUrl(file: FileType, expiresIn?: number, action?: string, extra?: any): Promise<any>;
10
16
  abstract delete(file: FileType): Promise<Boolean>;
11
17
  abstract stream(file: FileType, res: any): Promise<any>;
@@ -3,5 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractStorageAdapter = void 0;
4
4
  //import { APIResponseLink, ResponsePublicUrl } from './types'
5
5
  class AbstractStorageAdapter {
6
+ constructor(params = {}) {
7
+ this._alias = '';
8
+ this._params = {};
9
+ this._alias = params.alias || '';
10
+ this._params = params;
11
+ }
6
12
  }
7
13
  exports.AbstractStorageAdapter = AbstractStorageAdapter;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
- import { Readable } from "stream";
3
- import { FileType } from "./types/FileType";
2
+ import { Readable } from 'stream';
3
+ import { FileType } from './types/FileType';
4
+ import { DownloadFileMeta } from './types/DownloadFileMetaType';
4
5
  /**
5
6
  * These are the public functions that any storage interface must expose
6
7
  */
@@ -9,7 +10,7 @@ export interface StorageAdapterInterface {
9
10
  create(file: FileType, stream: Readable): Promise<FileType>;
10
11
  delete(file: FileType): Promise<Boolean>;
11
12
  stream(file: FileType, res: any): Promise<any>;
12
- download(file: FileType, path: string): Promise<string>;
13
+ download(file: FileType, path: DownloadFileMeta): Promise<string>;
13
14
  getUrl(file: FileType, expiresIn?: number, action?: string, extra?: any): Promise<any>;
14
15
  getUploadUrl(filePath: FileType, expiresIn?: number): Promise<any>;
15
16
  getReadable(filePath: FileType): Promise<Readable>;
@@ -3,6 +3,7 @@ import { BlobType } from './types/BlobType';
3
3
  import { BlobMediaType } from './types/BlobMediaType';
4
4
  import { FileResponseLink } from './types/FileResponseLink';
5
5
  import { FileResponseUrl } from './types/FileResponseUrl';
6
+ import { DownloadFileMeta } from './types/DownloadFileMetaType';
6
7
  import { StorageAdapterInterface } from './StorageAdapterInterface';
7
8
  import { AbstractStorageAdapter } from './AbstractStorageAdapter';
8
- export { FileType, BlobType, BlobMediaType, FileResponseLink, FileResponseUrl, StorageAdapterInterface, AbstractStorageAdapter, };
9
+ export { FileType, BlobType, BlobMediaType, FileResponseLink, FileResponseUrl, DownloadFileMeta, StorageAdapterInterface, AbstractStorageAdapter, };
@@ -0,0 +1,4 @@
1
+ export interface DownloadFileMeta {
2
+ path: string;
3
+ onlyContent?: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/core",
3
- "version": "1.0.0-beta22",
3
+ "version": "1.0.0-beta23",
4
4
  "description": "Core objects for business apps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",