@medusajs/api-key 0.1.3 → 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.
Files changed (44) hide show
  1. package/dist/index.d.ts +6 -8
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +5 -26
  4. package/dist/index.js.map +1 -0
  5. package/dist/joiner-config.d.ts +2 -5
  6. package/dist/joiner-config.d.ts.map +1 -0
  7. package/dist/joiner-config.js +8 -28
  8. package/dist/joiner-config.js.map +1 -0
  9. package/dist/migrations/InitialSetup20240221144943.d.ts +1 -0
  10. package/dist/migrations/InitialSetup20240221144943.d.ts.map +1 -0
  11. package/dist/migrations/InitialSetup20240221144943.js +1 -0
  12. package/dist/migrations/InitialSetup20240221144943.js.map +1 -0
  13. package/dist/migrations/Migration20240604080145.d.ts +6 -0
  14. package/dist/migrations/Migration20240604080145.d.ts.map +1 -0
  15. package/dist/migrations/Migration20240604080145.js +14 -0
  16. package/dist/migrations/Migration20240604080145.js.map +1 -0
  17. package/dist/models/api-key.d.ts +2 -0
  18. package/dist/models/api-key.d.ts.map +1 -0
  19. package/dist/models/api-key.js +11 -1
  20. package/dist/models/api-key.js.map +1 -0
  21. package/dist/models/index.d.ts +1 -0
  22. package/dist/models/index.d.ts.map +1 -0
  23. package/dist/models/index.js +1 -0
  24. package/dist/models/index.js.map +1 -0
  25. package/dist/services/api-key-module-service.d.ts +19 -18
  26. package/dist/services/api-key-module-service.d.ts.map +1 -0
  27. package/dist/services/api-key-module-service.js +74 -40
  28. package/dist/services/api-key-module-service.js.map +1 -0
  29. package/dist/services/index.d.ts +2 -1
  30. package/dist/services/index.d.ts.map +1 -0
  31. package/dist/services/index.js +2 -4
  32. package/dist/services/index.js.map +1 -0
  33. package/dist/tsconfig.tsbuildinfo +1 -0
  34. package/dist/types/index.d.ts +3 -3
  35. package/dist/types/index.d.ts.map +1 -0
  36. package/dist/types/index.js +1 -0
  37. package/dist/types/index.js.map +1 -0
  38. package/package.json +22 -26
  39. package/dist/module-definition.d.ts +0 -2
  40. package/dist/module-definition.js +0 -58
  41. package/dist/repositories/index.d.ts +0 -1
  42. package/dist/repositories/index.js +0 -5
  43. package/dist/scripts/bin/run-seed.d.ts +0 -3
  44. package/dist/scripts/bin/run-seed.js +0 -48
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { moduleDefinition } from "./module-definition";
2
- export * from "./types";
3
- export * from "./models";
4
- export * from "./services";
5
- export declare const initialize: (options?: import("@medusajs/modules-sdk").InternalModuleDeclaration | import("@medusajs/modules-sdk").ModuleServiceInitializeOptions | import("@medusajs/modules-sdk").ModuleServiceInitializeCustomDataLayerOptions | import("@medusajs/modules-sdk").ExternalModuleDeclaration | undefined, injectedDependencies?: any) => Promise<unknown>;
6
- export declare const runMigrations: ((options: import("@medusajs/modules-sdk").LoaderOptions<any>, moduleDeclaration?: import("@medusajs/modules-sdk").InternalModuleDeclaration | undefined) => Promise<void>) | undefined;
7
- export declare const revertMigration: ((options: import("@medusajs/modules-sdk").LoaderOptions<any>, moduleDeclaration?: import("@medusajs/modules-sdk").InternalModuleDeclaration | undefined) => Promise<void>) | undefined;
8
- export default moduleDefinition;
1
+ import { ApiKeyModuleService } from "./services";
2
+ declare const _default: import("@medusajs/types").ModuleExports<typeof ApiKeyModuleService> & {
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":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;;;;AAE/C,wBAEE"}
package/dist/index.js CHANGED
@@ -1,29 +1,8 @@
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);
15
- };
16
2
  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("./models"), exports);
22
- __exportStar(require("./services"), exports);
23
- exports.initialize = (0, modules_sdk_1.initializeFactory)({
24
- moduleName: modules_sdk_1.Modules.API_KEY,
25
- moduleDefinition: module_definition_1.moduleDefinition,
3
+ const utils_1 = require("@medusajs/framework/utils");
4
+ const _services_1 = require("./services");
5
+ exports.default = (0, utils_1.Module)(utils_1.Modules.API_KEY, {
6
+ service: _services_1.ApiKeyModuleService,
26
7
  });
27
- exports.runMigrations = module_definition_1.moduleDefinition.runMigrations;
28
- exports.revertMigration = module_definition_1.moduleDefinition.revertMigration;
29
- exports.default = module_definition_1.moduleDefinition;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qDAA2D;AAC3D,yCAA+C;AAE/C,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,OAAO,EAAE;IACrC,OAAO,EAAE,+BAAmB;CAC7B,CAAC,CAAA"}
@@ -1,5 +1,2 @@
1
- import { ModuleJoinerConfig } from "@medusajs/types";
2
- import { MapToConfig } from "@medusajs/utils";
3
- export declare const LinkableKeys: Record<string, string>;
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,uOAKvB,CAAA"}
@@ -1,31 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
7
- const modules_sdk_1 = require("@medusajs/modules-sdk");
8
- const api_key_1 = __importDefault(require("./models/api-key"));
9
- exports.LinkableKeys = {
10
- api_key_id: api_key_1.default.name,
11
- };
12
- const entityLinkableKeysMap = {};
13
- Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
14
- entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
15
- entityLinkableKeysMap[value].push({
16
- mapTo: key,
17
- valueFrom: key.split("_").pop(),
18
- });
3
+ exports.joinerConfig = void 0;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.API_KEY, {
6
+ linkableKeys: {
7
+ // Merged with the autogenerated ones to maintain backward compatibility
8
+ publishable_key_id: "ApiKey",
9
+ },
19
10
  });
20
- exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
21
- exports.joinerConfig = {
22
- serviceName: modules_sdk_1.Modules.API_KEY,
23
- primaryKeys: ["id"],
24
- linkableKeys: exports.LinkableKeys,
25
- alias: [
26
- {
27
- name: ["api_key", "api_keys"],
28
- args: { entity: api_key_1.default.name },
29
- },
30
- ],
31
- };
11
+ //# 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,OAAO,EAAE;IAC9D,YAAY,EAAE;QACZ,wEAAwE;QACxE,kBAAkB,EAAE,QAAQ;KAC7B;CACF,CAAC,CAAA"}
@@ -2,3 +2,4 @@ import { Migration } from "@mikro-orm/migrations";
2
2
  export declare class InitialSetup20240221144943 extends Migration {
3
3
  up(): Promise<void>;
4
4
  }
5
+ //# sourceMappingURL=InitialSetup20240221144943.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitialSetup20240221144943.d.ts","sourceRoot":"","sources":["../../src/migrations/InitialSetup20240221144943.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,0BAA2B,SAAQ,SAAS;IACjD,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAW1B"}
@@ -10,3 +10,4 @@ class InitialSetup20240221144943 extends migrations_1.Migration {
10
10
  }
11
11
  }
12
12
  exports.InitialSetup20240221144943 = InitialSetup20240221144943;
13
+ //# sourceMappingURL=InitialSetup20240221144943.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitialSetup20240221144943.js","sourceRoot":"","sources":["../../src/migrations/InitialSetup20240221144943.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,0BAA2B,SAAQ,sBAAS;IACvD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,mYAAmY,CACpY,CAAA;QACD,IAAI,CAAC,MAAM,CACT,oFAAoF,CACrF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,oEAAoE,CACrE,CAAA;IACH,CAAC;CACF;AAZD,gEAYC"}
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20240604080145 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20240604080145.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20240604080145.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240604080145.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20240604080145 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20240604080145 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql('alter table if exists "api_key" add column if not exists "updated_at" timestamptz not null default now();');
8
+ }
9
+ async down() {
10
+ this.addSql('alter table if exists "api_key" drop column if exists "updated_at";');
11
+ }
12
+ }
13
+ exports.Migration20240604080145 = Migration20240604080145;
14
+ //# sourceMappingURL=Migration20240604080145.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20240604080145.js","sourceRoot":"","sources":["../../src/migrations/Migration20240604080145.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,2GAA2G,CAC5G,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT,qEAAqE,CACtE,CAAA;IACH,CAAC;CACF;AAZD,0DAYC"}
@@ -8,8 +8,10 @@ export default class ApiKey {
8
8
  last_used_at: Date | null;
9
9
  created_by: string;
10
10
  created_at: Date;
11
+ updated_at?: Date;
11
12
  revoked_by: string | null;
12
13
  revoked_at: Date | null;
13
14
  onCreate(): void;
14
15
  onInit(): void;
15
16
  }
17
+ //# sourceMappingURL=api-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/models/api-key.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,OAAO,OAAO,MAAM;IAEzB,EAAE,EAAE,MAAM,CAAA;IAIV,KAAK,EAAE,MAAM,CAAA;IAGb,IAAI,EAAE,MAAM,CAAA;IAIZ,QAAQ,EAAE,MAAM,CAAA;IAIhB,KAAK,EAAE,MAAM,CAAA;IAKb,IAAI,EAAE,aAAa,GAAG,QAAQ,CAAA;IAM9B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAO;IAGhC,UAAU,EAAE,MAAM,CAAA;IAOlB,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,CAAC,EAAE,IAAI,CAAA;IAGjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAO;IAMhC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const utils_1 = require("@medusajs/utils");
12
+ const utils_1 = require("@medusajs/framework/utils");
13
13
  const core_1 = require("@mikro-orm/core");
14
14
  const TypeIndex = (0, utils_1.createPsqlIndexStatementHelper)({
15
15
  tableName: "api_key",
@@ -81,6 +81,15 @@ __decorate([
81
81
  }),
82
82
  __metadata("design:type", Date)
83
83
  ], ApiKey.prototype, "created_at", void 0);
84
+ __decorate([
85
+ (0, core_1.Property)({
86
+ onCreate: () => new Date(),
87
+ onUpdate: () => new Date(),
88
+ columnType: "timestamptz",
89
+ defaultRaw: "now()",
90
+ }),
91
+ __metadata("design:type", Date)
92
+ ], ApiKey.prototype, "updated_at", void 0);
84
93
  __decorate([
85
94
  (0, core_1.Property)({ columnType: "text", nullable: true }),
86
95
  __metadata("design:type", Object)
@@ -108,3 +117,4 @@ ApiKey = __decorate([
108
117
  (0, core_1.Entity)()
109
118
  ], ApiKey);
110
119
  exports.default = ApiKey;
120
+ //# sourceMappingURL=api-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key.js","sourceRoot":"","sources":["../../src/models/api-key.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qDAIkC;AAElC,0CAOwB;AAExB,MAAM,SAAS,GAAG,IAAA,sCAA8B,EAAC;IAC/C,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,MAAM;CAChB,CAAC,CAAA;AAEF,MAAM,UAAU,GAAG,IAAA,sCAA8B,EAAC;IAChD,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,IAAI;CACb,CAAC,CAAA;AAGa,IAAM,MAAM,GAAZ,MAAM,MAAM;IAAZ;QA4Bb,iBAAY,GAAgB,IAAI,CAAA;QAqBhC,eAAU,GAAkB,IAAI,CAAA;QAMhC,eAAU,GAAgB,IAAI,CAAA;IAWhC,CAAC;IARC,QAAQ;QACN,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAgB,EAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;IAC5C,CAAC;IAGD,MAAM;QACJ,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAgB,EAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;IAC5C,CAAC;CACF,CAAA;AAhEC;IADC,IAAA,iBAAU,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;kCACzB;AAIV;IAFC,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAChC,UAAU,CAAC,aAAa,EAAE;;qCACd;AAGb;IADC,IAAA,eAAQ,EAA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Y,GAAE;;;;sCAGd;AAGD;IADC,IAAA,aAAM,GAAE;;;;oCAGR;AAjEkB,MAAM;IAD1B,IAAA,aAAM,GAAE;GACY,MAAM,CAkE1B;kBAlEoB,MAAM"}
@@ -1 +1,2 @@
1
1
  export { default as ApiKey } from "./api-key";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,WAAW,CAAA"}
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ApiKey = void 0;
7
7
  var api_key_1 = require("./api-key");
8
8
  Object.defineProperty(exports, "ApiKey", { enumerable: true, get: function () { return __importDefault(api_key_1).default; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA6C;AAApC,kHAAA,OAAO,OAAU"}
@@ -1,36 +1,36 @@
1
- import { Context, DAL, ApiKeyTypes, IApiKeyModuleService, ModulesSdkTypes, InternalModuleDeclaration, ModuleJoinerConfig, FindConfig, FilterableApiKeyProps } from "@medusajs/types";
1
+ import { ApiKeyTypes, Context, DAL, FilterableApiKeyProps, FindConfig, IApiKeyModuleService, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/framework/types";
2
2
  import { ApiKey } from "../models";
3
3
  import { RevokeApiKeyInput, TokenDTO, UpdateApiKeyInput } from "../types";
4
- import { ModulesSdkUtils } from "@medusajs/utils";
5
4
  type InjectedDependencies = {
6
5
  baseRepository: DAL.RepositoryService;
7
- apiKeyService: ModulesSdkTypes.InternalModuleService<any>;
6
+ apiKeyService: ModulesSdkTypes.IMedusaInternalService<any>;
8
7
  };
9
- declare const ApiKeyModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, ApiKeyTypes.ApiKeyDTO, {
8
+ declare const ApiKeyModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<{
10
9
  ApiKey: {
11
10
  dto: ApiKeyTypes.ApiKeyDTO;
12
11
  };
13
12
  }>;
14
- export default class ApiKeyModuleService<TEntity extends ApiKey = ApiKey> extends ApiKeyModuleService_base implements IApiKeyModuleService {
13
+ export declare class ApiKeyModuleService extends ApiKeyModuleService_base implements IApiKeyModuleService {
15
14
  protected readonly moduleDeclaration: InternalModuleDeclaration;
16
15
  protected baseRepository_: DAL.RepositoryService;
17
- protected readonly apiKeyService_: ModulesSdkTypes.InternalModuleService<TEntity>;
16
+ protected readonly apiKeyService_: ModulesSdkTypes.IMedusaInternalService<ApiKey>;
18
17
  constructor({ baseRepository, apiKeyService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
19
18
  __joinerConfig(): ModuleJoinerConfig;
20
- create(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
21
- create(data: ApiKeyTypes.CreateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
22
- protected create_(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<[TEntity[], TokenDTO[]]>;
23
- upsert(data: ApiKeyTypes.UpsertApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
24
- upsert(data: ApiKeyTypes.UpsertApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
25
- update(id: string, data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
26
- update(selector: FilterableApiKeyProps, data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
27
- protected update_(normalizedInput: UpdateApiKeyInput[], sharedContext?: Context): Promise<TEntity[]>;
28
- retrieve(id: string, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
29
- list(filters?: ApiKeyTypes.FilterableApiKeyProps, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
30
- listAndCount(filters?: ApiKeyTypes.FilterableApiKeyProps, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<[ApiKeyTypes.ApiKeyDTO[], number]>;
19
+ deleteApiKeys(ids: string | string[], sharedContext?: Context): Promise<void>;
20
+ createApiKeys(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
21
+ createApiKeys(data: ApiKeyTypes.CreateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
22
+ protected createApiKeys_(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<[ApiKey[], TokenDTO[]]>;
23
+ upsertApiKeys(data: ApiKeyTypes.UpsertApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
24
+ upsertApiKeys(data: ApiKeyTypes.UpsertApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
25
+ updateApiKeys(id: string, data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
26
+ updateApiKeys(selector: FilterableApiKeyProps, data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
27
+ protected updateApiKeys_(normalizedInput: UpdateApiKeyInput[], sharedContext?: Context): Promise<ApiKey[]>;
28
+ retrieveApiKey(id: string, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
29
+ listApiKeys(filters?: ApiKeyTypes.FilterableApiKeyProps, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
30
+ listAndCountApiKeys(filters?: ApiKeyTypes.FilterableApiKeyProps, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<[ApiKeyTypes.ApiKeyDTO[], number]>;
31
31
  revoke(id: string, data: ApiKeyTypes.RevokeApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
32
32
  revoke(selector: FilterableApiKeyProps, data: ApiKeyTypes.RevokeApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
33
- revoke_(normalizedInput: RevokeApiKeyInput[], sharedContext?: Context): Promise<TEntity[]>;
33
+ revoke_(normalizedInput: RevokeApiKeyInput[], sharedContext?: Context): Promise<ApiKey[]>;
34
34
  authenticate(token: string, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO | false>;
35
35
  protected authenticate_(token: string, sharedContext?: Context): Promise<ApiKey | false>;
36
36
  protected validateCreateApiKeys_(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<void>;
@@ -41,3 +41,4 @@ export default class ApiKeyModuleService<TEntity extends ApiKey = ApiKey> extend
41
41
  protected static calculateHash(token: string, salt: string): Promise<string>;
42
42
  }
43
43
  export {};
44
+ //# sourceMappingURL=api-key-module-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key-module-service.d.ts","sourceRoot":"","sources":["../../src/services/api-key-module-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,OAAO,EACP,GAAG,EACH,qBAAqB,EACrB,UAAU,EACV,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAalC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAEL,iBAAiB,EACjB,QAAQ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AAW,CAAC,SAAS,CAAC;IAC3B,MAAM,CACV,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,EAAE,WAAW,CAAC,eAAe,EACjC,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;IAwB7B,OAAO,CACX,eAAe,EAAE,iBAAiB,EAAE,EACnB,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBd,YAAY,CAChB,KAAK,EAAE,MAAM,EACI,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,WAAW,CAAC,SAAS,GAAG,KAAK,CAAC;cAezB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACI,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;cAqCV,sBAAsB,CACpC,IAAI,EAAE,WAAW,CAAC,eAAe,EAAE,EACnC,aAAa,GAAE,OAAY,GAC1B,OAAO,CAAC,IAAI,CAAC;cAuCA,qBAAqB,CAAC,CAAC,EACrC,YAAY,EAAE,MAAM,GAAG,qBAAqB,EAC5C,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,EACnB,aAAa,GAAE,OAAY,GAC1B,OAAO,CAAC,CAAC,EAAE,CAAC;cAyBC,sBAAsB,CACpC,IAAI,EAAE,iBAAiB,EAAE,EACzB,aAAa,GAAE,OAAY,GAC1B,OAAO,CAAC,IAAI,CAAC;IAsChB,SAAS,CAAC,MAAM,CAAC,sBAAsB,IAAI,QAAQ;qBAW5B,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAC;qBAatC,aAAa,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC;CAGnB"}
@@ -15,15 +15,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ApiKeyModuleService = void 0;
19
+ const types_1 = require("@medusajs/framework/types");
20
+ const utils_1 = require("@medusajs/framework/utils");
21
+ const _models_1 = require("../models");
18
22
  const crypto_1 = __importDefault(require("crypto"));
19
23
  const util_1 = __importDefault(require("util"));
20
- const types_1 = require("@medusajs/types");
21
24
  const joiner_config_1 = require("../joiner-config");
22
- const _models_1 = require("../models");
23
- const utils_1 = require("@medusajs/utils");
24
25
  const scrypt = util_1.default.promisify(crypto_1.default.scrypt);
25
- const generateMethodForModels = [];
26
- class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.ApiKey, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
26
+ class ApiKeyModuleService extends (0, utils_1.MedusaService)({ ApiKey: _models_1.ApiKey }) {
27
27
  constructor({ baseRepository, apiKeyService }, moduleDeclaration) {
28
28
  // @ts-ignore
29
29
  super(...arguments);
@@ -34,8 +34,23 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
34
34
  __joinerConfig() {
35
35
  return joiner_config_1.joinerConfig;
36
36
  }
37
- async create(data, sharedContext = {}) {
38
- const [createdApiKeys, generatedTokens] = await this.create_(Array.isArray(data) ? data : [data], sharedContext);
37
+ // @ts-expect-error
38
+ async deleteApiKeys(ids, sharedContext = {}) {
39
+ const apiKeyIds = Array.isArray(ids) ? ids : [ids];
40
+ const unrevokedApiKeys = (await this.apiKeyService_.list({
41
+ id: ids,
42
+ $or: [
43
+ { revoked_at: { $eq: null } },
44
+ { revoked_at: { $gt: new Date() } },
45
+ ],
46
+ }, { select: ["id"] }, sharedContext)).map((apiKey) => apiKey.id);
47
+ if ((0, utils_1.isPresent)(unrevokedApiKeys)) {
48
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_ALLOWED, `Cannot delete api keys that are not revoked - ${unrevokedApiKeys.join(", ")}`);
49
+ }
50
+ return await super.deleteApiKeys(apiKeyIds, sharedContext);
51
+ }
52
+ async createApiKeys(data, sharedContext = {}) {
53
+ const [createdApiKeys, generatedTokens] = await this.createApiKeys_(Array.isArray(data) ? data : [data], sharedContext);
39
54
  const serializedResponse = await this.baseRepository_.serialize(createdApiKeys, {
40
55
  populate: true,
41
56
  });
@@ -48,7 +63,7 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
48
63
  }));
49
64
  return Array.isArray(data) ? responseWithRawToken : responseWithRawToken[0];
50
65
  }
51
- async create_(data, sharedContext = {}) {
66
+ async createApiKeys_(data, sharedContext = {}) {
52
67
  await this.validateCreateApiKeys_(data, sharedContext);
53
68
  const normalizedInput = [];
54
69
  const generatedTokens = [];
@@ -71,14 +86,14 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
71
86
  const createdApiKeys = await this.apiKeyService_.create(normalizedInput, sharedContext);
72
87
  return [createdApiKeys, generatedTokens];
73
88
  }
74
- async upsert(data, sharedContext = {}) {
89
+ async upsertApiKeys(data, sharedContext = {}) {
75
90
  const input = Array.isArray(data) ? data : [data];
76
91
  const forUpdate = input.filter((apiKey) => !!apiKey.id);
77
92
  const forCreate = input.filter((apiKey) => !apiKey.id);
78
93
  const operations = [];
79
94
  if (forCreate.length) {
80
95
  const op = async () => {
81
- const [createdApiKeys, generatedTokens] = await this.create_(forCreate, sharedContext);
96
+ const [createdApiKeys, generatedTokens] = await this.createApiKeys_(forCreate, sharedContext);
82
97
  const serializedResponse = await this.baseRepository_.serialize(createdApiKeys, {
83
98
  populate: true,
84
99
  });
@@ -93,7 +108,7 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
93
108
  }
94
109
  if (forUpdate.length) {
95
110
  const op = async () => {
96
- const updateResp = await this.update_(forUpdate, sharedContext);
111
+ const updateResp = await this.updateApiKeys_(forUpdate, sharedContext);
97
112
  return await this.baseRepository_.serialize(updateResp);
98
113
  };
99
114
  operations.push(op());
@@ -101,15 +116,15 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
101
116
  const result = (await (0, utils_1.promiseAll)(operations)).flat();
102
117
  return Array.isArray(data) ? result : result[0];
103
118
  }
104
- async update(idOrSelector, data, sharedContext = {}) {
119
+ async updateApiKeys(idOrSelector, data, sharedContext = {}) {
105
120
  let normalizedInput = await this.normalizeUpdateInput_(idOrSelector, data, sharedContext);
106
- const updatedApiKeys = await this.update_(normalizedInput, sharedContext);
121
+ const updatedApiKeys = await this.updateApiKeys_(normalizedInput, sharedContext);
107
122
  const serializedResponse = await this.baseRepository_.serialize(updatedApiKeys.map(omitToken), {
108
123
  populate: true,
109
124
  });
110
125
  return (0, utils_1.isString)(idOrSelector) ? serializedResponse[0] : serializedResponse;
111
126
  }
112
- async update_(normalizedInput, sharedContext = {}) {
127
+ async updateApiKeys_(normalizedInput, sharedContext = {}) {
113
128
  const updateRequest = normalizedInput.map((k) => ({
114
129
  id: k.id,
115
130
  title: k.title,
@@ -117,19 +132,22 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
117
132
  const updatedApiKeys = await this.apiKeyService_.update(updateRequest, sharedContext);
118
133
  return updatedApiKeys;
119
134
  }
120
- async retrieve(id, config, sharedContext) {
135
+ // @ts-expect-error
136
+ async retrieveApiKey(id, config, sharedContext) {
121
137
  const apiKey = await this.apiKeyService_.retrieve(id, config, sharedContext);
122
138
  return await this.baseRepository_.serialize(omitToken(apiKey), {
123
139
  populate: true,
124
140
  });
125
141
  }
126
- async list(filters, config, sharedContext) {
142
+ //@ts-expect-error
143
+ async listApiKeys(filters, config, sharedContext) {
127
144
  const apiKeys = await this.apiKeyService_.list(filters, config, sharedContext);
128
145
  return await this.baseRepository_.serialize(apiKeys.map(omitToken), {
129
146
  populate: true,
130
147
  });
131
148
  }
132
- async listAndCount(filters, config, sharedContext) {
149
+ //@ts-expect-error
150
+ async listAndCountApiKeys(filters, config, sharedContext) {
133
151
  const [apiKeys, count] = await this.apiKeyService_.listAndCount(filters, config, sharedContext);
134
152
  return [
135
153
  await this.baseRepository_.serialize(apiKeys.map(omitToken), {
@@ -182,7 +200,7 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
182
200
  { revoked_at: { $eq: null } },
183
201
  { revoked_at: { $gt: new Date() } },
184
202
  ],
185
- }, { take: null }, sharedContext);
203
+ }, {}, sharedContext);
186
204
  const matches = await (0, utils_1.promiseAll)(secretKeys.map(async (dbKey) => {
187
205
  const hashedInput = await ApiKeyModuleService.calculateHash(token, dbKey.salt);
188
206
  if (hashedInput === dbKey.token) {
@@ -215,7 +233,7 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
215
233
  { revoked_at: { $eq: null } },
216
234
  { revoked_at: { $gt: new Date() } },
217
235
  ],
218
- }, { take: null }, sharedContext);
236
+ }, {}, sharedContext);
219
237
  if (dbSecretKeys.length) {
220
238
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `You can only have one active secret key a time. Revoke or delete your existing key before creating a new one.`);
221
239
  }
@@ -278,83 +296,98 @@ class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
278
296
  return (await scrypt(token, salt, 64)).toString("hex");
279
297
  }
280
298
  }
281
- exports.default = ApiKeyModuleService;
299
+ exports.ApiKeyModuleService = ApiKeyModuleService;
300
+ __decorate([
301
+ (0, utils_1.InjectTransactionManager)()
302
+ // @ts-expect-error
303
+ ,
304
+ __param(1, (0, utils_1.MedusaContext)()),
305
+ __metadata("design:type", Function),
306
+ __metadata("design:paramtypes", [Object, Object]),
307
+ __metadata("design:returntype", Promise)
308
+ ], ApiKeyModuleService.prototype, "deleteApiKeys", null);
282
309
  __decorate([
283
- (0, utils_1.InjectManager)("baseRepository_"),
310
+ (0, utils_1.InjectManager)(),
284
311
  __param(1, (0, utils_1.MedusaContext)()),
285
312
  __metadata("design:type", Function),
286
313
  __metadata("design:paramtypes", [Object, Object]),
287
314
  __metadata("design:returntype", Promise)
288
- ], ApiKeyModuleService.prototype, "create", null);
315
+ ], ApiKeyModuleService.prototype, "createApiKeys", null);
289
316
  __decorate([
290
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
317
+ (0, utils_1.InjectTransactionManager)(),
291
318
  __param(1, (0, utils_1.MedusaContext)()),
292
319
  __metadata("design:type", Function),
293
320
  __metadata("design:paramtypes", [Array, Object]),
294
321
  __metadata("design:returntype", Promise)
295
- ], ApiKeyModuleService.prototype, "create_", null);
322
+ ], ApiKeyModuleService.prototype, "createApiKeys_", null);
296
323
  __decorate([
297
- (0, utils_1.InjectManager)("baseRepository_"),
324
+ (0, utils_1.InjectManager)(),
298
325
  __param(1, (0, utils_1.MedusaContext)()),
299
326
  __metadata("design:type", Function),
300
327
  __metadata("design:paramtypes", [Object, Object]),
301
328
  __metadata("design:returntype", Promise)
302
- ], ApiKeyModuleService.prototype, "upsert", null);
329
+ ], ApiKeyModuleService.prototype, "upsertApiKeys", null);
303
330
  __decorate([
304
- (0, utils_1.InjectManager)("baseRepository_"),
331
+ (0, utils_1.InjectManager)(),
305
332
  __param(2, (0, utils_1.MedusaContext)()),
306
333
  __metadata("design:type", Function),
307
334
  __metadata("design:paramtypes", [Object, Object, Object]),
308
335
  __metadata("design:returntype", Promise)
309
- ], ApiKeyModuleService.prototype, "update", null);
336
+ ], ApiKeyModuleService.prototype, "updateApiKeys", null);
310
337
  __decorate([
311
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
338
+ (0, utils_1.InjectTransactionManager)(),
312
339
  __param(1, (0, utils_1.MedusaContext)()),
313
340
  __metadata("design:type", Function),
314
341
  __metadata("design:paramtypes", [Array, Object]),
315
342
  __metadata("design:returntype", Promise)
316
- ], ApiKeyModuleService.prototype, "update_", null);
343
+ ], ApiKeyModuleService.prototype, "updateApiKeys_", null);
317
344
  __decorate([
318
- (0, utils_1.InjectManager)("baseRepository_"),
345
+ (0, utils_1.InjectManager)()
346
+ // @ts-expect-error
347
+ ,
319
348
  __metadata("design:type", Function),
320
349
  __metadata("design:paramtypes", [String, Object, Object]),
321
350
  __metadata("design:returntype", Promise)
322
- ], ApiKeyModuleService.prototype, "retrieve", null);
351
+ ], ApiKeyModuleService.prototype, "retrieveApiKey", null);
323
352
  __decorate([
324
- (0, utils_1.InjectManager)("baseRepository_"),
353
+ (0, utils_1.InjectManager)()
354
+ //@ts-expect-error
355
+ ,
325
356
  __metadata("design:type", Function),
326
357
  __metadata("design:paramtypes", [Object, Object, Object]),
327
358
  __metadata("design:returntype", Promise)
328
- ], ApiKeyModuleService.prototype, "list", null);
359
+ ], ApiKeyModuleService.prototype, "listApiKeys", null);
329
360
  __decorate([
330
- (0, utils_1.InjectManager)("baseRepository_"),
361
+ (0, utils_1.InjectManager)()
362
+ //@ts-expect-error
363
+ ,
331
364
  __metadata("design:type", Function),
332
365
  __metadata("design:paramtypes", [Object, Object, Object]),
333
366
  __metadata("design:returntype", Promise)
334
- ], ApiKeyModuleService.prototype, "listAndCount", null);
367
+ ], ApiKeyModuleService.prototype, "listAndCountApiKeys", null);
335
368
  __decorate([
336
- (0, utils_1.InjectManager)("baseRepository_"),
369
+ (0, utils_1.InjectManager)(),
337
370
  __param(2, (0, utils_1.MedusaContext)()),
338
371
  __metadata("design:type", Function),
339
372
  __metadata("design:paramtypes", [Object, Object, Object]),
340
373
  __metadata("design:returntype", Promise)
341
374
  ], ApiKeyModuleService.prototype, "revoke", null);
342
375
  __decorate([
343
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
376
+ (0, utils_1.InjectTransactionManager)(),
344
377
  __param(1, (0, utils_1.MedusaContext)()),
345
378
  __metadata("design:type", Function),
346
379
  __metadata("design:paramtypes", [Array, Object]),
347
380
  __metadata("design:returntype", Promise)
348
381
  ], ApiKeyModuleService.prototype, "revoke_", null);
349
382
  __decorate([
350
- (0, utils_1.InjectManager)("baseRepository_"),
383
+ (0, utils_1.InjectManager)(),
351
384
  __param(1, (0, utils_1.MedusaContext)()),
352
385
  __metadata("design:type", Function),
353
386
  __metadata("design:paramtypes", [String, Object]),
354
387
  __metadata("design:returntype", Promise)
355
388
  ], ApiKeyModuleService.prototype, "authenticate", null);
356
389
  __decorate([
357
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
390
+ (0, utils_1.InjectTransactionManager)(),
358
391
  __param(1, (0, utils_1.MedusaContext)()),
359
392
  __metadata("design:type", Function),
360
393
  __metadata("design:paramtypes", [String, Object]),
@@ -371,3 +404,4 @@ key) => {
371
404
  const redactKey = (key) => {
372
405
  return [key.slice(0, 6), key.slice(-3)].join("***");
373
406
  };
407
+ //# sourceMappingURL=api-key-module-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key-module-service.js","sourceRoot":"","sources":["../../src/services/api-key-module-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,qDAUkC;AAClC,qDAWkC;AAClC,qCAAgC;AAOhC,oDAA2B;AAC3B,gDAAuB;AACvB,oDAA+C;AAE/C,MAAM,MAAM,GAAG,cAAI,CAAC,SAAS,CAAC,gBAAM,CAAC,MAAM,CAAC,CAAA;AAO5C,MAAa,mBACX,SAAQ,IAAA,qBAAa,EAElB,EAAE,MAAM,EAAN,gBAAM,EAAE,CAAC;IAMd,YACE,EAAE,cAAc,EAAE,aAAa,EAAwB,EACpC,iBAA4C;QAE/D,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QAHA,sBAAiB,GAAjB,iBAAiB,CAA2B;QAI/D,IAAI,CAAC,eAAe,GAAG,cAAc,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAA;IACrC,CAAC;IAED,cAAc;QACZ,OAAO,4BAAY,CAAA;IACrB,CAAC;IAIK,AADN,mBAAmB;IACnB,KAAK,CAAC,aAAa,CACjB,GAAsB,EACL,gBAAyB,EAAE;QAE5C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAA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I,KAAK,kBAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAA;IAC3D,OAAO,GAAG,CAAC,IAAI,CAAA;IACf,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE;IACxC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACrD,CAAC,CAAA"}
@@ -1 +1,2 @@
1
- export { default as ApiKeyModuleService } from "./api-key-module-service";
1
+ export { ApiKeyModuleService } from "./api-key-module-service";
2
+ //# 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,mBAAmB,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ApiKeyModuleService = void 0;
7
4
  var api_key_module_service_1 = require("./api-key-module-service");
8
- Object.defineProperty(exports, "ApiKeyModuleService", { enumerable: true, get: function () { return __importDefault(api_key_module_service_1).default; } });
5
+ Object.defineProperty(exports, "ApiKeyModuleService", { enumerable: true, get: function () { return api_key_module_service_1.ApiKeyModuleService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAArD,6HAAA,mBAAmB,OAAA"}
@@ -0,0 +1 @@
1
+ {"root":["../src/index.ts","../src/joiner-config.ts","../src/migrations/initialsetup20240221144943.ts","../src/migrations/migration20240604080145.ts","../src/models/api-key.ts","../src/models/index.ts","../src/services/api-key-module-service.ts","../src/services/index.ts","../src/services/__tests__/noop.ts","../src/types/index.ts"],"version":"5.6.2"}
@@ -1,8 +1,7 @@
1
- import { ApiKeyType, RevokeApiKeyDTO, UpdateApiKeyDTO } from "@medusajs/types";
2
- import { IEventBusModuleService, Logger } from "@medusajs/types";
1
+ import { ApiKeyType, IEventBusModuleService, Logger, RevokeApiKeyDTO, UpdateApiKeyDTO } from "@medusajs/framework/types";
3
2
  export type InitializeModuleInjectableDependencies = {
4
3
  logger?: Logger;
5
- eventBusService?: IEventBusModuleService;
4
+ EventBus?: IEventBusModuleService;
6
5
  };
7
6
  export type CreateApiKeyDTO = {
8
7
  token: string;
@@ -24,3 +23,4 @@ export type UpdateApiKeyInput = UpdateApiKeyDTO & {
24
23
  export type RevokeApiKeyInput = RevokeApiKeyDTO & {
25
24
  id: string;
26
25
  };
26
+ //# 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,UAAU,EACV,sBAAsB,EACtB,MAAM,EACN,eAAe,EACf,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAElC,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,sBAAsB,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAChE,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@medusajs/api-key",
3
- "version": "0.1.3",
3
+ "version": "1.0.0-rc-20241003153304",
4
4
  "description": "Medusa API Key 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"
12
- },
13
- "bin": {
14
- "medusa-api-key-seed": "dist/scripts/bin/run-seed.js"
14
+ "node": ">=20"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -26,36 +26,32 @@
26
26
  "scripts": {
27
27
  "watch": "tsc --build --watch",
28
28
  "watch:test": "tsc --build tsconfig.spec.json --watch",
29
- "prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
30
- "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",
31
31
  "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
32
32
  "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
33
- "migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
34
- "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
35
- "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
36
- "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up",
37
- "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"
38
38
  },
39
39
  "devDependencies": {
40
+ "@medusajs/framework": "1.0.0-rc-20241003153304",
40
41
  "@mikro-orm/cli": "5.9.7",
41
- "cross-env": "^5.2.1",
42
- "jest": "^29.6.3",
43
- "medusa-test-utils": "^1.1.45",
42
+ "@swc/core": "^1.7.28",
43
+ "@swc/jest": "^0.2.36",
44
+ "jest": "^29.7.0",
45
+ "medusa-test-utils": "2.0.0-rc-20241003153304",
44
46
  "rimraf": "^3.0.2",
45
- "ts-jest": "^29.1.1",
46
- "ts-node": "^10.9.1",
47
47
  "tsc-alias": "^1.8.6",
48
- "typescript": "^5.1.6"
48
+ "typescript": "^5.6.2"
49
49
  },
50
- "dependencies": {
51
- "@medusajs/modules-sdk": "^1.12.12",
52
- "@medusajs/types": "^1.11.17",
53
- "@medusajs/utils": "^1.11.10",
50
+ "peerDependencies": {
51
+ "@medusajs/framework": "1.0.0-rc-20241003153304",
54
52
  "@mikro-orm/core": "5.9.7",
55
53
  "@mikro-orm/migrations": "5.9.7",
56
54
  "@mikro-orm/postgresql": "5.9.7",
57
- "awilix": "^8.0.0",
58
- "dotenv": "^16.4.5",
59
- "knex": "2.4.2"
55
+ "awilix": "^8.0.1"
60
56
  }
61
57
  }
@@ -1,2 +0,0 @@
1
- import { ModuleExports } from "@medusajs/types";
2
- export declare const moduleDefinition: ModuleExports;
@@ -1,58 +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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.moduleDefinition = void 0;
27
- const ModuleServices = __importStar(require("./services"));
28
- const _services_1 = require("./services");
29
- const modules_sdk_1 = require("@medusajs/modules-sdk");
30
- const Models = __importStar(require("./models"));
31
- const ModuleModels = __importStar(require("./models"));
32
- const utils_1 = require("@medusajs/utils");
33
- const ModuleRepositories = __importStar(require("./repositories"));
34
- const migrationScriptOptions = {
35
- moduleName: modules_sdk_1.Modules.API_KEY,
36
- models: Models,
37
- pathToMigrations: __dirname + "/migrations",
38
- };
39
- const runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
40
- const revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
41
- const containerLoader = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
42
- moduleModels: ModuleModels,
43
- moduleRepositories: ModuleRepositories,
44
- moduleServices: ModuleServices,
45
- });
46
- const connectionLoader = utils_1.ModulesSdkUtils.mikroOrmConnectionLoaderFactory({
47
- moduleName: modules_sdk_1.Modules.API_KEY,
48
- moduleModels: Object.values(Models),
49
- migrationsPath: __dirname + "/migrations",
50
- });
51
- const service = _services_1.ApiKeyModuleService;
52
- const loaders = [containerLoader, connectionLoader];
53
- exports.moduleDefinition = {
54
- service,
55
- loaders,
56
- revertMigration,
57
- runMigrations,
58
- };
@@ -1 +0,0 @@
1
- export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseRepository = void 0;
4
- var utils_1 = require("@medusajs/utils");
5
- Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- declare const _default: Promise<void>;
3
- export default _default;
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- const utils_1 = require("@medusajs/utils");
28
- const modules_sdk_1 = require("@medusajs/modules-sdk");
29
- const Models = __importStar(require("../../models"));
30
- const os_1 = require("os");
31
- const args = process.argv;
32
- const path = args.pop();
33
- exports.default = (async () => {
34
- const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
35
- config();
36
- if (!path) {
37
- throw new Error(`filePath is required.${os_1.EOL}Example: medusa-api-key-seed <filePath>`);
38
- }
39
- const run = utils_1.ModulesSdkUtils.buildSeedScript({
40
- moduleName: modules_sdk_1.Modules.API_KEY,
41
- models: Models,
42
- pathToMigrations: __dirname + "/../../migrations",
43
- seedHandler: async ({ manager, data }) => {
44
- // TODO: Add seed logic
45
- },
46
- });
47
- await run({ path });
48
- })();