@medusajs/file 0.0.2 → 1.0.0-rc-20241003153304

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.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { moduleDefinition } from "./module-definition";
2
- export * from "./types";
3
- export * from "./services";
4
- export declare const initialize: (options?: import("@medusajs/modules-sdk").ModuleServiceInitializeOptions | import("@medusajs/modules-sdk").ModuleServiceInitializeCustomDataLayerOptions | import("@medusajs/modules-sdk").InternalModuleDeclaration | import("@medusajs/modules-sdk").ExternalModuleDeclaration | undefined, injectedDependencies?: any) => Promise<unknown>;
5
- export declare const runMigrations: ((options: import("@medusajs/modules-sdk").LoaderOptions<any>, moduleDeclaration?: import("@medusajs/modules-sdk").InternalModuleDeclaration | undefined) => Promise<void>) | undefined;
6
- export declare const revertMigration: ((options: import("@medusajs/modules-sdk").LoaderOptions<any>, moduleDeclaration?: import("@medusajs/modules-sdk").InternalModuleDeclaration | undefined) => Promise<void>) | undefined;
7
- export default moduleDefinition;
1
+ import { FileModuleService } from "./services";
2
+ declare const _default: import("@medusajs/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 CHANGED
@@ -1,28 +1,13 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.revertMigration = exports.runMigrations = exports.initialize = void 0;
18
- const module_definition_1 = require("./module-definition");
19
- const modules_sdk_1 = require("@medusajs/modules-sdk");
20
- __exportStar(require("./types"), exports);
21
- __exportStar(require("./services"), exports);
22
- exports.initialize = (0, modules_sdk_1.initializeFactory)({
23
- moduleName: modules_sdk_1.Modules.FILE,
24
- moduleDefinition: module_definition_1.moduleDefinition,
6
+ const _services_1 = require("./services");
7
+ const providers_1 = __importDefault(require("./loaders/providers"));
8
+ const utils_1 = require("@medusajs/framework/utils");
9
+ exports.default = (0, utils_1.Module)(utils_1.Modules.FILE, {
10
+ service: _services_1.FileModuleService,
11
+ loaders: [providers_1.default],
25
12
  });
26
- exports.runMigrations = module_definition_1.moduleDefinition.runMigrations;
27
- exports.revertMigration = module_definition_1.moduleDefinition.revertMigration;
28
- exports.default = module_definition_1.moduleDefinition;
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,qDAA2D;AAE3D,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,IAAI,EAAE;IAClC,OAAO,EAAE,6BAAiB;IAC1B,OAAO,EAAE,CAAC,mBAAa,CAAC;CACzB,CAAC,CAAA"}
@@ -1,5 +1,2 @@
1
- import { ModuleJoinerConfig } from "@medusajs/types";
2
- import { MapToConfig } from "@medusajs/utils";
3
- export declare const LinkableKeys: {};
4
- export declare const entityNameToLinkableKeysMap: MapToConfig;
5
- export declare const joinerConfig: ModuleJoinerConfig;
1
+ export declare const joinerConfig: Omit<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@medusajs/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,uOAEvB,CAAA"}
@@ -1,20 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- exports.LinkableKeys = {};
6
- const entityLinkableKeysMap = {};
7
- exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
8
- exports.joinerConfig = {
9
- serviceName: modules_sdk_1.Modules.FILE,
10
- primaryKeys: ["id"],
11
- linkableKeys: exports.LinkableKeys,
12
- alias: [
13
- {
14
- name: ["file", "files"],
15
- args: {
16
- entity: "File",
17
- },
18
- },
19
- ],
20
- };
3
+ exports.joinerConfig = void 0;
4
+ const utils_1 = require("@medusajs/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,qDAAuE;AAE1D,QAAA,YAAY,GAAG,IAAA,0BAAkB,EAAC,eAAO,CAAC,IAAI,EAAE;IAC3D,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC,CAAA"}
@@ -1,5 +1,6 @@
1
- import { LoaderOptions, ModuleProvider, ModulesSdkTypes } from "@medusajs/types";
1
+ import { LoaderOptions, ModuleProvider, ModulesSdkTypes } from "@medusajs/framework/types";
2
2
  declare const _default: ({ container, options, }: LoaderOptions<(ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions) & {
3
3
  providers: ModuleProvider[];
4
4
  }>) => Promise<void>;
5
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,2BAA2B,CAAA;kDA6B/B,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"}
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const modules_sdk_1 = require("@medusajs/modules-sdk");
3
+ const modules_sdk_1 = require("@medusajs/framework/modules-sdk");
4
4
  const _services_1 = require("../services");
5
5
  const _types_1 = require("../types");
6
6
  const awilix_1 = require("awilix");
7
7
  const registrationFn = async (klass, container, pluginOptions) => {
8
- Object.entries(pluginOptions.config || []).map(([name, config]) => {
9
- const key = _services_1.FileProviderService.getRegistrationIdentifier(klass, name);
10
- container.register({
11
- [_types_1.FileProviderRegistrationPrefix + key]: (0, awilix_1.asFunction)((cradle) => new klass(cradle, config), {
12
- lifetime: klass.LIFE_TIME || awilix_1.Lifetime.SINGLETON,
13
- }),
14
- });
15
- container.registerAdd(_types_1.FileProviderIdentifierRegistrationName, (0, awilix_1.asValue)(key));
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
+ }),
16
13
  });
14
+ container.registerAdd(_types_1.FileProviderIdentifierRegistrationName, (0, awilix_1.asValue)(key));
17
15
  };
18
16
  exports.default = async ({ container, options, }) => {
19
17
  await (0, modules_sdk_1.moduleProviderLoader)({
@@ -22,3 +20,4 @@ exports.default = async ({ container, options, }) => {
22
20
  registerServiceFn: registrationFn,
23
21
  });
24
22
  };
23
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":";;AAAA,iEAAsE;AAMtE,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"}
@@ -1,4 +1,4 @@
1
- import { Context, CreateFileDTO, FileDTO, ModuleJoinerConfig, FileTypes, FilterableFileProps, FindConfig } from "@medusajs/types";
1
+ import { Context, CreateFileDTO, FileDTO, FileTypes, FilterableFileProps, FindConfig, ModuleJoinerConfig } from "@medusajs/framework/types";
2
2
  import FileProviderService from "./file-provider-service";
3
3
  type InjectedDependencies = {
4
4
  fileProviderService: FileProviderService;
@@ -7,12 +7,13 @@ export default class FileModuleService implements FileTypes.IFileModuleService {
7
7
  protected readonly fileProviderService_: FileProviderService;
8
8
  constructor({ fileProviderService }: InjectedDependencies);
9
9
  __joinerConfig(): ModuleJoinerConfig;
10
- create(data: CreateFileDTO[], sharedContext?: Context): Promise<FileDTO[]>;
11
- create(data: CreateFileDTO, sharedContext?: Context): Promise<FileDTO>;
12
- delete(ids: string[], sharedContext?: Context): Promise<void>;
13
- delete(id: string, sharedContext?: Context): Promise<void>;
14
- retrieve(id: string): Promise<FileDTO>;
15
- list(filters?: FilterableFileProps, config?: FindConfig<FileDTO>, sharedContext?: Context): Promise<FileDTO[]>;
16
- listAndCount(filters?: FilterableFileProps, config?: FindConfig<FileDTO>, sharedContext?: Context): Promise<[FileDTO[], number]>;
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
17
  }
18
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":"AAAA,OAAO,EACL,OAAO,EACP,aAAa,EACb,OAAO,EACP,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EACnB,MAAM,2BAA2B,CAAA;AAGlC,OAAO,mBAAmB,MAAM,yBAAyB,CAAA;AAGzD,KAAK,oBAAoB,GAAG;IAC1B,mBAAmB,EAAE,mBAAmB,CAAA;CACzC,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,SAAS,CAAC,kBAAkB;IAC5E,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,CAAA;gBAChD,EAAE,mBAAmB,EAAE,EAAE,oBAAoB;IAIzD,cAAc,IAAI,kBAAkB;IAIpC,WAAW,CACT,IAAI,EAAE,aAAa,EAAE,EACrB,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,OAAO,EAAE,CAAC;IACrB,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBrE,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAClE,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/D,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW1C,SAAS,CACb,OAAO,CAAC,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAC5B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,OAAO,EAAE,CAAC;IAyBf,iBAAiB,CACrB,OAAO,CAAC,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAC5B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;CA2BhC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const joiner_config_1 = require("../joiner-config");
4
- const medusa_core_utils_1 = require("medusa-core-utils");
4
+ const utils_1 = require("@medusajs/framework/utils");
5
5
  class FileModuleService {
6
6
  constructor({ fileProviderService }) {
7
7
  this.fileProviderService_ = fileProviderService;
@@ -9,7 +9,7 @@ class FileModuleService {
9
9
  __joinerConfig() {
10
10
  return joiner_config_1.joinerConfig;
11
11
  }
12
- async create(data) {
12
+ async createFiles(data) {
13
13
  const input = Array.isArray(data) ? data : [data];
14
14
  // TODO: Validate file mime type, have config for allowed types
15
15
  const files = await Promise.all(input.map((file) => this.fileProviderService_.upload(file)));
@@ -19,12 +19,12 @@ class FileModuleService {
19
19
  }));
20
20
  return Array.isArray(data) ? result : result[0];
21
21
  }
22
- async delete(ids) {
22
+ async deleteFiles(ids) {
23
23
  const input = Array.isArray(ids) ? ids : [ids];
24
24
  await Promise.all(input.map((id) => this.fileProviderService_.delete({ fileKey: id })));
25
25
  return;
26
26
  }
27
- async retrieve(id) {
27
+ async retrieveFile(id) {
28
28
  const res = await this.fileProviderService_.getPresignedDownloadUrl({
29
29
  fileKey: id,
30
30
  });
@@ -33,10 +33,10 @@ class FileModuleService {
33
33
  url: res,
34
34
  };
35
35
  }
36
- async list(filters, config, sharedContext) {
36
+ async listFiles(filters, config, sharedContext) {
37
37
  const id = Array.isArray(filters?.id) ? filters?.id?.[0] : filters?.id;
38
38
  if (!id) {
39
- throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "Listing of files is only supported when filtering by ID.");
39
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Listing of files is only supported when filtering by ID.");
40
40
  }
41
41
  const res = await this.fileProviderService_.getPresignedDownloadUrl({
42
42
  fileKey: id,
@@ -51,10 +51,10 @@ class FileModuleService {
51
51
  },
52
52
  ];
53
53
  }
54
- async listAndCount(filters, config, sharedContext) {
54
+ async listAndCountFiles(filters, config, sharedContext) {
55
55
  const id = Array.isArray(filters?.id) ? filters?.id?.[0] : filters?.id;
56
56
  if (!id) {
57
- throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, "Listing and counting of files is only supported when filtering by ID.");
57
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Listing and counting of files is only supported when filtering by ID.");
58
58
  }
59
59
  const res = await this.fileProviderService_.getPresignedDownloadUrl({
60
60
  fileKey: id,
@@ -74,3 +74,4 @@ class FileModuleService {
74
74
  }
75
75
  }
76
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":"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"}
@@ -1,4 +1,4 @@
1
- import { Constructor, FileTypes } from "@medusajs/types";
1
+ import { Constructor, FileTypes } from "@medusajs/framework/types";
2
2
  import { FileProviderRegistrationPrefix } from "../types";
3
3
  type InjectedDependencies = {
4
4
  [key: `${typeof FileProviderRegistrationPrefix}${string}`]: FileTypes.IFileProvider;
@@ -12,3 +12,4 @@ export default class FileProviderService {
12
12
  getPresignedDownloadUrl(fileData: FileTypes.ProviderGetFileDTO): Promise<string>;
13
13
  }
14
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,2BAA2B,CAAA;AAElE,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"}
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const medusa_core_utils_1 = require("medusa-core-utils");
3
+ const utils_1 = require("@medusajs/framework/utils");
4
4
  const _types_1 = require("../types");
5
5
  class FileProviderService {
6
6
  constructor(container) {
7
7
  const fileProviderKeys = Object.keys(container).filter((k) => k.startsWith(_types_1.FileProviderRegistrationPrefix));
8
8
  if (fileProviderKeys.length !== 1) {
9
- throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.INVALID_DATA, `File module should be initialized with exactly one provider`);
9
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `File module should be initialized with exactly one provider`);
10
10
  }
11
11
  this.fileProvider_ = container[fileProviderKeys[0]];
12
12
  }
@@ -24,3 +24,4 @@ class FileProviderService {
24
24
  }
25
25
  }
26
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,qDAAuD;AACvD,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,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,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"}
@@ -1,2 +1,3 @@
1
1
  export { default as FileModuleService } from "./file-module-service";
2
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"}
@@ -8,3 +8,4 @@ var file_module_service_1 = require("./file-module-service");
8
8
  Object.defineProperty(exports, "FileModuleService", { enumerable: true, get: function () { return __importDefault(file_module_service_1).default; } });
9
9
  var file_provider_service_1 = require("./file-provider-service");
10
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"}
@@ -1,4 +1,4 @@
1
- import { ModuleProviderExports, ModuleServiceInitializeOptions } from "@medusajs/types";
1
+ import { ModuleProviderExports, ModuleServiceInitializeOptions } from "@medusajs/framework/types";
2
2
  export declare const FileProviderIdentifierRegistrationName = "file_providers_identifier";
3
3
  export declare const FileProviderRegistrationPrefix = "fs_";
4
4
  export type FileModuleOptions = Partial<ModuleServiceInitializeOptions> & {
@@ -10,11 +10,14 @@ export type FileModuleOptions = Partial<ModuleServiceInitializeOptions> & {
10
10
  * The module provider to be registered
11
11
  */
12
12
  resolve: string | ModuleProviderExports;
13
- options: {
14
- /**
15
- * key value pair of the provider name and the configuration to be passed to the provider constructor
16
- */
17
- config: Record<string, unknown>;
18
- };
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>;
19
21
  };
20
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,2BAA2B,CAAA;AAElC,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"}
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileProviderRegistrationPrefix = exports.FileProviderIdentifierRegistrationName = void 0;
4
4
  exports.FileProviderIdentifierRegistrationName = "file_providers_identifier";
5
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 CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@medusajs/file",
3
- "version": "0.0.2",
3
+ "version": "1.0.0-rc-20241003153304",
4
4
  "description": "Medusa File module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
- "dist"
8
+ "dist",
9
+ "!dist/**/__tests__",
10
+ "!dist/**/__mocks__",
11
+ "!dist/**/__fixtures__"
9
12
  ],
10
13
  "engines": {
11
- "node": ">=16"
14
+ "node": ">=20"
12
15
  },
13
16
  "repository": {
14
17
  "type": "git",
@@ -23,39 +26,32 @@
23
26
  "scripts": {
24
27
  "watch": "tsc --build --watch",
25
28
  "watch:test": "tsc --build tsconfig.spec.json --watch",
26
- "prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
27
- "build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
29
+ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
30
+ "build": "rimraf dist && tsc --build && npm run resolve:aliases",
28
31
  "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
29
32
  "test:integration": "jest --passWithNoTests --forceExit -- integration-tests/**/__tests__/**/*.ts",
30
- "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
31
- "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
32
- "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
33
- "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up",
34
- "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
33
+ "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:generate",
34
+ "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create --initial",
35
+ "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:create",
36
+ "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm migration:up",
37
+ "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts medusa-mikro-orm cache:clear"
35
38
  },
36
39
  "devDependencies": {
40
+ "@medusajs/framework": "1.0.0-rc-20241003153304",
37
41
  "@mikro-orm/cli": "5.9.7",
38
- "cross-env": "^5.2.1",
39
- "faker": "^6.6.6",
40
- "jest": "^29.6.3",
41
- "medusa-test-utils": "^1.1.45",
42
- "pg-god": "^1.0.12",
43
- "rimraf": "^3.0.2",
44
- "ts-jest": "^29.1.1",
45
- "ts-node": "^10.9.1",
46
- "tsc-alias": "^1.8.6",
47
- "typescript": "^5.1.6"
48
- },
49
- "dependencies": {
50
- "@medusajs/modules-sdk": "^1.12.12",
51
- "@medusajs/types": "^1.11.17",
52
- "@medusajs/utils": "^1.11.10",
53
42
  "@mikro-orm/core": "5.9.7",
54
43
  "@mikro-orm/migrations": "5.9.7",
55
44
  "@mikro-orm/postgresql": "5.9.7",
56
- "awilix": "^8.0.0",
57
- "dotenv": "^16.4.5",
58
- "knex": "2.4.2",
59
- "lodash": "^4.17.21"
45
+ "@swc/core": "^1.7.28",
46
+ "@swc/jest": "^0.2.36",
47
+ "jest": "^29.7.0",
48
+ "medusa-test-utils": "2.0.0-rc-20241003153304",
49
+ "rimraf": "^3.0.2",
50
+ "tsc-alias": "^1.8.6",
51
+ "typescript": "^5.6.2"
52
+ },
53
+ "peerDependencies": {
54
+ "@medusajs/framework": "1.0.0-rc-20241003153304",
55
+ "awilix": "^8.0.1"
60
56
  }
61
57
  }
@@ -1,4 +0,0 @@
1
- import { ModuleExports } from "@medusajs/types";
2
- export declare const runMigrations: () => Promise<void>;
3
- export declare const revertMigration: () => Promise<void>;
4
- export declare const moduleDefinition: ModuleExports;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.moduleDefinition = exports.revertMigration = exports.runMigrations = void 0;
30
- const _services_1 = require("./services");
31
- const providers_1 = __importDefault(require("./loaders/providers"));
32
- const ModuleServices = __importStar(require("./services"));
33
- const utils_1 = require("@medusajs/utils");
34
- const runMigrations = () => {
35
- return Promise.resolve();
36
- };
37
- exports.runMigrations = runMigrations;
38
- const revertMigration = () => {
39
- return Promise.resolve();
40
- };
41
- exports.revertMigration = revertMigration;
42
- const containerLoader = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
43
- moduleModels: {},
44
- moduleRepositories: {},
45
- moduleServices: ModuleServices,
46
- });
47
- const loaders = [containerLoader, providers_1.default];
48
- const service = _services_1.FileModuleService;
49
- exports.moduleDefinition = {
50
- service,
51
- loaders,
52
- runMigrations: exports.runMigrations,
53
- revertMigration: exports.revertMigration,
54
- };