@etohq/file 1.0.0

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # File Module
@@ -0,0 +1,6 @@
1
+ import { FileModuleService } from "./services";
2
+ declare const _default: import("@etohq/types").ModuleExports<typeof FileModuleService> & {
3
+ linkable: Record<string, any>;
4
+ };
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;;;;AAI7C,wBAGE"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _services_1 = require("./services");
7
+ const providers_1 = __importDefault(require("./loaders/providers"));
8
+ const utils_1 = require("@etohq/framework/utils");
9
+ exports.default = (0, utils_1.Module)(utils_1.Modules.FILE, {
10
+ service: _services_1.FileModuleService,
11
+ loaders: [providers_1.default],
12
+ });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,yCAA6C;AAC7C,oEAA+C;AAC/C,kDAAwD;AAExD,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,IAAI,EAAE;IAClC,OAAO,EAAE,6BAAiB;IAC1B,OAAO,EAAE,CAAC,mBAAa,CAAC;CACzB,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const joinerConfig: Omit<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
2
+ //# sourceMappingURL=joiner-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iOAEvB,CAAA"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.joinerConfig = void 0;
4
+ const utils_1 = require("@etohq/framework/utils");
5
+ exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.FILE, {
6
+ models: [{ name: "File" }],
7
+ });
8
+ //# sourceMappingURL=joiner-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joiner-config.js","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":";;;AAAA,kDAAoE;AAEvD,QAAA,YAAY,GAAG,IAAA,0BAAkB,EAAC,eAAO,CAAC,IAAI,EAAE;IAC3D,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { LoaderOptions, ModuleProvider, ModulesSdkTypes } from "@etohq/framework/types";
2
+ declare const _default: ({ container, options, }: LoaderOptions<(ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions) & {
3
+ providers: ModuleProvider[];
4
+ }>) => Promise<void>;
5
+ export default _default;
6
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EAChB,MAAM,wBAAwB,CAAA;kDA6B5B,aAAa,CACd,CACI,eAAe,CAAC,8BAA8B,GAC9C,eAAe,CAAC,6CAA6C,CAChE,GAAG;IAAE,SAAS,EAAE,cAAc,EAAE,CAAA;CAAE,CACpC,KAAG,OAAO,CAAC,IAAI,CAAC;AARjB,wBAcC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const modules_sdk_1 = require("@etohq/framework/modules-sdk");
4
+ const _services_1 = require("../services");
5
+ const _types_1 = require("../types");
6
+ const awilix_1 = require("awilix");
7
+ const registrationFn = async (klass, container, pluginOptions) => {
8
+ const key = _services_1.FileProviderService.getRegistrationIdentifier(klass, pluginOptions.id);
9
+ container.register({
10
+ [_types_1.FileProviderRegistrationPrefix + key]: (0, awilix_1.asFunction)((cradle) => new klass(cradle, pluginOptions.options ?? {}), {
11
+ lifetime: klass.LIFE_TIME || awilix_1.Lifetime.SINGLETON,
12
+ }),
13
+ });
14
+ container.registerAdd(_types_1.FileProviderIdentifierRegistrationName, (0, awilix_1.asValue)(key));
15
+ };
16
+ exports.default = async ({ container, options, }) => {
17
+ await (0, modules_sdk_1.moduleProviderLoader)({
18
+ container,
19
+ providers: options?.providers || [],
20
+ registerServiceFn: registrationFn,
21
+ });
22
+ };
23
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":";;AAAA,8DAAmE;AAMnE,yCAA+C;AAC/C,mCAGe;AACf,mCAAsD;AAEtD,MAAM,cAAc,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE;IAC/D,MAAM,GAAG,GAAG,+BAAmB,CAAC,yBAAyB,CACvD,KAAK,EACL,aAAa,CAAC,EAAE,CACjB,CAAA;IAED,SAAS,CAAC,QAAQ,CAAC;QACjB,CAAC,uCAA8B,GAAG,GAAG,CAAC,EAAE,IAAA,mBAAU,EAChD,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC,EAC1D;YACE,QAAQ,EAAE,KAAK,CAAC,SAAS,IAAI,iBAAQ,CAAC,SAAS;SAChD,CACF;KACF,CAAC,CAAA;IAEF,SAAS,CAAC,WAAW,CAAC,+CAAsC,EAAE,IAAA,gBAAO,EAAC,GAAG,CAAC,CAAC,CAAA;AAC7E,CAAC,CAAA;AAED,kBAAe,KAAK,EAAE,EACpB,SAAS,EACT,OAAO,GAMR,EAAiB,EAAE;IAClB,MAAM,IAAA,kCAAoB,EAAC;QACzB,SAAS;QACT,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE;QACnC,iBAAiB,EAAE,cAAc;KAClC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { Context, CreateFileDTO, FileDTO, FileTypes, FilterableFileProps, FindConfig, ModuleJoinerConfig } from "@etohq/framework/types";
2
+ import FileProviderService from "./file-provider-service";
3
+ type InjectedDependencies = {
4
+ fileProviderService: FileProviderService;
5
+ };
6
+ export default class FileModuleService implements FileTypes.IFileModuleService {
7
+ protected readonly fileProviderService_: FileProviderService;
8
+ constructor({ fileProviderService }: InjectedDependencies);
9
+ __joinerConfig(): ModuleJoinerConfig;
10
+ createFiles(data: CreateFileDTO[], sharedContext?: Context): Promise<FileDTO[]>;
11
+ createFiles(data: CreateFileDTO, sharedContext?: Context): Promise<FileDTO>;
12
+ deleteFiles(ids: string[], sharedContext?: Context): Promise<void>;
13
+ deleteFiles(id: string, sharedContext?: Context): Promise<void>;
14
+ retrieveFile(id: string): Promise<FileDTO>;
15
+ listFiles(filters?: FilterableFileProps, config?: FindConfig<FileDTO>, sharedContext?: Context): Promise<FileDTO[]>;
16
+ listAndCountFiles(filters?: FilterableFileProps, config?: FindConfig<FileDTO>, sharedContext?: Context): Promise<[FileDTO[], number]>;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=file-module-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-module-service.d.ts","sourceRoot":"","sources":["../../src/services/file-module-service.ts"],"names":[],"mappings":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,EAAE,MAAM,CAAC,CAAC;CA2BhC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const joiner_config_1 = require("../joiner-config");
4
+ const utils_1 = require("@etohq/framework/utils");
5
+ class FileModuleService {
6
+ constructor({ fileProviderService }) {
7
+ this.fileProviderService_ = fileProviderService;
8
+ }
9
+ __joinerConfig() {
10
+ return joiner_config_1.joinerConfig;
11
+ }
12
+ async createFiles(data) {
13
+ const input = Array.isArray(data) ? data : [data];
14
+ // TODO: Validate file mime type, have config for allowed types
15
+ const files = await Promise.all(input.map((file) => this.fileProviderService_.upload(file)));
16
+ const result = files.map((file) => ({
17
+ id: file.key,
18
+ url: file.url,
19
+ }));
20
+ return Array.isArray(data) ? result : result[0];
21
+ }
22
+ async deleteFiles(ids) {
23
+ const input = Array.isArray(ids) ? ids : [ids];
24
+ await Promise.all(input.map((id) => this.fileProviderService_.delete({ fileKey: id })));
25
+ return;
26
+ }
27
+ async retrieveFile(id) {
28
+ const res = await this.fileProviderService_.getPresignedDownloadUrl({
29
+ fileKey: id,
30
+ });
31
+ return {
32
+ id,
33
+ url: res,
34
+ };
35
+ }
36
+ async listFiles(filters, config, sharedContext) {
37
+ const id = Array.isArray(filters?.id) ? filters?.id?.[0] : filters?.id;
38
+ if (!id) {
39
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Listing of files is only supported when filtering by ID.");
40
+ }
41
+ const res = await this.fileProviderService_.getPresignedDownloadUrl({
42
+ fileKey: id,
43
+ });
44
+ if (!res) {
45
+ return [];
46
+ }
47
+ return [
48
+ {
49
+ id,
50
+ url: res,
51
+ },
52
+ ];
53
+ }
54
+ async listAndCountFiles(filters, config, sharedContext) {
55
+ const id = Array.isArray(filters?.id) ? filters?.id?.[0] : filters?.id;
56
+ if (!id) {
57
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Listing and counting of files is only supported when filtering by ID.");
58
+ }
59
+ const res = await this.fileProviderService_.getPresignedDownloadUrl({
60
+ fileKey: id,
61
+ });
62
+ if (!res) {
63
+ return [[], 0];
64
+ }
65
+ return [
66
+ [
67
+ {
68
+ id,
69
+ url: res,
70
+ },
71
+ ],
72
+ 1,
73
+ ];
74
+ }
75
+ }
76
+ exports.default = FileModuleService;
77
+ //# sourceMappingURL=file-module-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-module-service.js","sourceRoot":"","sources":["../../src/services/file-module-service.ts"],"names":[],"mappings":";;AAUA,oDAA+C;AAE/C,kDAAiD;AAMjD,MAAqB,iBAAiB;IAEpC,YAAY,EAAE,mBAAmB,EAAwB;QACvD,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAA;IACjD,CAAC;IAED,cAAc;QACZ,OAAO,4BAAY,CAAA;IACrB,CAAC;IAQD,KAAK,CAAC,WAAW,CACf,IAAqC;QAErC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACjD,+DAA+D;QAE/D,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAC5D,CAAA;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClC,EAAE,EAAE,IAAI,CAAC,GAAG;YACZ,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAC,CAAA;QAEH,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACjD,CAAC;IAID,KAAK,CAAC,WAAW,CAAC,GAAsB;QACtC,MAAM,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B,aAAuB;QAEvB,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAA;QACtE,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,gBAAQ,CAChB,gBAAQ,CAAC,KAAK,CAAC,YAAY,EAC3B,uEAAuE,CACxE,CAAA;QACH,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,CAAC;YAClE,OAAO,EAAE,EAAE;SACZ,CAAC,CAAA;QAEF,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAChB,CAAC;QAED,OAAO;YACL;gBACE;oBACE,EAAE;oBACF,GAAG,EAAE,GAAG;iBACT;aACF;YACD,CAAC;SACF,CAAA;IACH,CAAC;CACF;AAnHD,oCAmHC"}
@@ -0,0 +1,15 @@
1
+ import { Constructor, FileTypes } from "@etohq/framework/types";
2
+ import { FileProviderRegistrationPrefix } from "../types";
3
+ type InjectedDependencies = {
4
+ [key: `${typeof FileProviderRegistrationPrefix}${string}`]: FileTypes.IFileProvider;
5
+ };
6
+ export default class FileProviderService {
7
+ protected readonly fileProvider_: FileTypes.IFileProvider;
8
+ constructor(container: InjectedDependencies);
9
+ static getRegistrationIdentifier(providerClass: Constructor<FileTypes.IFileProvider>, optionName?: string): string;
10
+ upload(file: FileTypes.ProviderUploadFileDTO): Promise<FileTypes.ProviderFileResultDTO>;
11
+ delete(fileData: FileTypes.ProviderDeleteFileDTO): Promise<void>;
12
+ getPresignedDownloadUrl(fileData: FileTypes.ProviderGetFileDTO): Promise<string>;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=file-provider-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-provider-service.d.ts","sourceRoot":"","sources":["../../src/services/file-provider-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,QAAQ,CAAA;AAEvD,KAAK,oBAAoB,GAAG;IAC1B,CACE,GAAG,EAAE,GAAG,OAAO,8BAA8B,GAAG,MAAM,EAAE,GACvD,SAAS,CAAC,aAAa,CAAA;CAC3B,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,aAAa,CAAA;gBAE7C,SAAS,EAAE,oBAAoB;IAe3C,MAAM,CAAC,yBAAyB,CAC9B,aAAa,EAAE,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,EACnD,UAAU,CAAC,EAAE,MAAM;IAKrB,MAAM,CACJ,IAAI,EAAE,SAAS,CAAC,qBAAqB,GACpC,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAI3C,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE,uBAAuB,CACrB,QAAQ,EAAE,SAAS,CAAC,kBAAkB,GACrC,OAAO,CAAC,MAAM,CAAC;CAGnB"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@etohq/framework/utils");
4
+ const _types_1 = require("../types");
5
+ class FileProviderService {
6
+ constructor(container) {
7
+ const fileProviderKeys = Object.keys(container).filter((k) => k.startsWith(_types_1.FileProviderRegistrationPrefix));
8
+ if (fileProviderKeys.length !== 1) {
9
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `File module should be initialized with exactly one provider`);
10
+ }
11
+ this.fileProvider_ = container[fileProviderKeys[0]];
12
+ }
13
+ static getRegistrationIdentifier(providerClass, optionName) {
14
+ return `${providerClass.identifier}_${optionName}`;
15
+ }
16
+ upload(file) {
17
+ return this.fileProvider_.upload(file);
18
+ }
19
+ delete(fileData) {
20
+ return this.fileProvider_.delete(fileData);
21
+ }
22
+ getPresignedDownloadUrl(fileData) {
23
+ return this.fileProvider_.getPresignedDownloadUrl(fileData);
24
+ }
25
+ }
26
+ exports.default = FileProviderService;
27
+ //# sourceMappingURL=file-provider-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-provider-service.js","sourceRoot":"","sources":["../../src/services/file-provider-service.ts"],"names":[],"mappings":";;AACA,kDAAiD;AACjD,mCAAuD;AAQvD,MAAqB,mBAAmB;IAGtC,YAAY,SAA+B;QACzC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAC3D,CAAC,CAAC,UAAU,CAAC,uCAA8B,CAAC,CAC7C,CAAA;QAED,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,gBAAQ,CAChB,gBAAQ,CAAC,KAAK,CAAC,YAAY,EAC3B,6DAA6D,CAC9D,CAAA;QACH,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,MAAM,CAAC,yBAAyB,CAC9B,aAAmD,EACnD,UAAmB;QAEnB,OAAO,GAAI,aAAqB,CAAC,UAAU,IAAI,UAAU,EAAE,CAAA;IAC7D,CAAC;IAED,MAAM,CACJ,IAAqC;QAErC,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,QAAyC;QAC9C,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC5C,CAAC;IAED,uBAAuB,CACrB,QAAsC;QAEtC,OAAO,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAA;IAC7D,CAAC;CACF;AAxCD,sCAwCC"}
@@ -0,0 +1,3 @@
1
+ export { default as FileModuleService } from "./file-module-service";
2
+ export { default as FileProviderService } from "./file-provider-service";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FileProviderService = exports.FileModuleService = void 0;
7
+ var file_module_service_1 = require("./file-module-service");
8
+ Object.defineProperty(exports, "FileModuleService", { enumerable: true, get: function () { return __importDefault(file_module_service_1).default; } });
9
+ var file_provider_service_1 = require("./file-provider-service");
10
+ Object.defineProperty(exports, "FileProviderService", { enumerable: true, get: function () { return __importDefault(file_provider_service_1).default; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAoE;AAA3D,yIAAA,OAAO,OAAqB;AACrC,iEAAwE;AAA/D,6IAAA,OAAO,OAAuB"}
@@ -0,0 +1 @@
1
+ {"root":["../src/index.ts","../src/joiner-config.ts","../src/loaders/providers.ts","../src/services/file-module-service.ts","../src/services/file-provider-service.ts","../src/services/index.ts","../src/services/__tests__/file.spec.ts","../src/types/index.ts"],"version":"5.6.2"}
@@ -0,0 +1,23 @@
1
+ import { ModuleProviderExports, ModuleServiceInitializeOptions } from "@etohq/framework/types";
2
+ export declare const FileProviderIdentifierRegistrationName = "file_providers_identifier";
3
+ export declare const FileProviderRegistrationPrefix = "fs_";
4
+ export type FileModuleOptions = Partial<ModuleServiceInitializeOptions> & {
5
+ /**
6
+ * Providers to be registered
7
+ */
8
+ provider?: {
9
+ /**
10
+ * The module provider to be registered
11
+ */
12
+ resolve: string | ModuleProviderExports;
13
+ /**
14
+ * The id of the provider
15
+ */
16
+ id: string;
17
+ /**
18
+ * key value pair of the configuration to be passed to the provider constructor
19
+ */
20
+ options?: Record<string, unknown>;
21
+ };
22
+ };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAC/B,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,sCAAsC,8BACtB,CAAA;AAE7B,eAAO,MAAM,8BAA8B,QAAQ,CAAA;AAEnD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,8BAA8B,CAAC,GAAG;IACxE;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAAA;QACvC;;WAEG;QACH,EAAE,EAAE,MAAM,CAAA;QACV;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAClC,CAAA;CACF,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileProviderRegistrationPrefix = exports.FileProviderIdentifierRegistrationName = void 0;
4
+ exports.FileProviderIdentifierRegistrationName = "file_providers_identifier";
5
+ exports.FileProviderRegistrationPrefix = "fs_";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAKa,QAAA,sCAAsC,GACjD,2BAA2B,CAAA;AAEhB,QAAA,8BAA8B,GAAG,KAAK,CAAA"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@etohq/file",
3
+ "version": "1.0.0",
4
+ "description": "Eto File module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "!dist/**/__tests__",
10
+ "!dist/**/__mocks__",
11
+ "!dist/**/__fixtures__"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/etohq/eto",
19
+ "directory": "packages/file"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "author": "Eto",
25
+ "license": "MIT",
26
+ "scripts": {
27
+ "watch": "tsc --build --watch",
28
+ "watch:test": "tsc --build tsconfig.spec.json --watch",
29
+ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases",
30
+ "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
31
+ "test:integration": "jest --passWithNoTests --forceExit -- integration-tests/**/__tests__/**/*.ts",
32
+ "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create --initial",
33
+ "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create",
34
+ "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:up",
35
+ "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm cache:clear"
36
+ },
37
+ "devDependencies": {
38
+ "@etohq/test-utils": "^1.0.0",
39
+ "@mikro-orm/cli": "5.9.7",
40
+ "@mikro-orm/core": "5.9.7",
41
+ "@mikro-orm/migrations": "5.9.7",
42
+ "@mikro-orm/postgresql": "5.9.7",
43
+ "@swc/core": "^1.7.28",
44
+ "@swc/jest": "^0.2.36",
45
+ "@types/jest": "^29.5.14",
46
+ "jest": "^29.7.0",
47
+ "rimraf": "^5.0.2",
48
+ "tsc-alias": "^1.8.6",
49
+ "typescript": "^5.6.2"
50
+ },
51
+ "dependencies": {
52
+ "@etohq/framework": "^1.0.0",
53
+ "awilix": "^8.0.1"
54
+ }
55
+ }