@medusajs/api-key 0.1.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 +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +29 -0
- package/dist/joiner-config.d.ts +5 -0
- package/dist/joiner-config.js +21 -0
- package/dist/models/api-key.d.ts +7 -0
- package/dist/models/api-key.js +59 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +8 -0
- package/dist/module-definition.d.ts +2 -0
- package/dist/module-definition.js +58 -0
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.js +5 -0
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +48 -0
- package/dist/services/api-key-module-service.d.ts +28 -0
- package/dist/services/api-key-module-service.js +99 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +8 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +2 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# API Key Module
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
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,
|
|
26
|
+
});
|
|
27
|
+
exports.runMigrations = module_definition_1.moduleDefinition.runMigrations;
|
|
28
|
+
exports.revertMigration = module_definition_1.moduleDefinition.revertMigration;
|
|
29
|
+
exports.default = module_definition_1.moduleDefinition;
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
// TODO manage the config
|
|
6
|
+
exports.LinkableKeys = {};
|
|
7
|
+
const entityLinkableKeysMap = {};
|
|
8
|
+
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
|
9
|
+
entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
|
|
10
|
+
entityLinkableKeysMap[value].push({
|
|
11
|
+
mapTo: key,
|
|
12
|
+
valueFrom: key.split("_").pop(),
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
|
16
|
+
exports.joinerConfig = {
|
|
17
|
+
serviceName: modules_sdk_1.Modules.API_KEY,
|
|
18
|
+
primaryKeys: ["id"],
|
|
19
|
+
linkableKeys: exports.LinkableKeys,
|
|
20
|
+
alias: [],
|
|
21
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const utils_1 = require("@medusajs/utils");
|
|
13
|
+
const core_1 = require("@mikro-orm/core");
|
|
14
|
+
// TODO:
|
|
15
|
+
let ApiKey = class ApiKey {
|
|
16
|
+
onCreate() {
|
|
17
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "apk");
|
|
18
|
+
}
|
|
19
|
+
onInit() {
|
|
20
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "apk");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], ApiKey.prototype, "id", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, core_1.Property)({
|
|
29
|
+
onCreate: () => new Date(),
|
|
30
|
+
columnType: "timestamptz",
|
|
31
|
+
defaultRaw: "now()",
|
|
32
|
+
}),
|
|
33
|
+
__metadata("design:type", Date)
|
|
34
|
+
], ApiKey.prototype, "created_at", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.Property)({
|
|
37
|
+
onCreate: () => new Date(),
|
|
38
|
+
onUpdate: () => new Date(),
|
|
39
|
+
columnType: "timestamptz",
|
|
40
|
+
defaultRaw: "now()",
|
|
41
|
+
}),
|
|
42
|
+
__metadata("design:type", Date)
|
|
43
|
+
], ApiKey.prototype, "updated_at", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, core_1.BeforeCreate)(),
|
|
46
|
+
__metadata("design:type", Function),
|
|
47
|
+
__metadata("design:paramtypes", []),
|
|
48
|
+
__metadata("design:returntype", void 0)
|
|
49
|
+
], ApiKey.prototype, "onCreate", null);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, core_1.OnInit)(),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", []),
|
|
54
|
+
__metadata("design:returntype", void 0)
|
|
55
|
+
], ApiKey.prototype, "onInit", null);
|
|
56
|
+
ApiKey = __decorate([
|
|
57
|
+
(0, core_1.Entity)()
|
|
58
|
+
], ApiKey);
|
|
59
|
+
exports.default = ApiKey;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ApiKey } from "./api-key";
|
|
@@ -0,0 +1,8 @@
|
|
|
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.ApiKey = void 0;
|
|
7
|
+
var api_key_1 = require("./api-key");
|
|
8
|
+
Object.defineProperty(exports, "ApiKey", { enumerable: true, get: function () { return __importDefault(api_key_1).default; } });
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
|
|
@@ -0,0 +1,5 @@
|
|
|
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; } });
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Context, DAL, ApiKeyTypes, IApiKeyModuleService, ModulesSdkTypes, InternalModuleDeclaration, ModuleJoinerConfig } from "@medusajs/types";
|
|
2
|
+
import { ModulesSdkUtils } from "@medusajs/utils";
|
|
3
|
+
import { ApiKey } from "../models";
|
|
4
|
+
type InjectedDependencies = {
|
|
5
|
+
baseRepository: DAL.RepositoryService;
|
|
6
|
+
apiKeyService: ModulesSdkTypes.InternalModuleService<any>;
|
|
7
|
+
};
|
|
8
|
+
declare const ApiKeyModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, ApiKeyTypes.ApiKeyDTO, {
|
|
9
|
+
ApiKey: {
|
|
10
|
+
dto: ApiKeyTypes.ApiKeyDTO;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export default class ApiKeyModuleService<TEntity extends ApiKey = ApiKey> extends ApiKeyModuleService_base implements IApiKeyModuleService {
|
|
14
|
+
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
15
|
+
protected baseRepository_: DAL.RepositoryService;
|
|
16
|
+
protected readonly apiKeyService_: ModulesSdkTypes.InternalModuleService<TEntity>;
|
|
17
|
+
constructor({ baseRepository, apiKeyService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
|
18
|
+
__joinerConfig(): ModuleJoinerConfig;
|
|
19
|
+
create(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
20
|
+
create(data: ApiKeyTypes.CreateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
21
|
+
protected create_(data: ApiKeyTypes.CreateApiKeyDTO | ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<TEntity | TEntity[]>;
|
|
22
|
+
update(data: ApiKeyTypes.UpdateApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
23
|
+
update(data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
24
|
+
protected update_(data: ApiKeyTypes.UpdateApiKeyDTO[] | ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<TEntity[] | TEntity>;
|
|
25
|
+
revoke(id: string, sharedContext?: Context): Promise<void>;
|
|
26
|
+
authenticate(id: string, sharedContext?: Context): Promise<boolean>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const utils_1 = require("@medusajs/utils");
|
|
16
|
+
const joiner_config_1 = require("../joiner-config");
|
|
17
|
+
const _models_1 = require("../models");
|
|
18
|
+
const generateMethodForModels = [];
|
|
19
|
+
class ApiKeyModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.ApiKey, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
|
|
20
|
+
constructor({ baseRepository, apiKeyService }, moduleDeclaration) {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.moduleDeclaration = moduleDeclaration;
|
|
24
|
+
this.baseRepository_ = baseRepository;
|
|
25
|
+
this.apiKeyService_ = apiKeyService;
|
|
26
|
+
}
|
|
27
|
+
__joinerConfig() {
|
|
28
|
+
return joiner_config_1.joinerConfig;
|
|
29
|
+
}
|
|
30
|
+
async create(data, sharedContext = {}) {
|
|
31
|
+
const createdApiKeys = await this.create_(data, sharedContext);
|
|
32
|
+
return await this.baseRepository_.serialize(createdApiKeys, {
|
|
33
|
+
populate: true,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async create_(data, sharedContext = {}) {
|
|
37
|
+
const data_ = Array.isArray(data) ? data : [data];
|
|
38
|
+
const createdApiKeys = await this.apiKeyService_.create(data_, sharedContext);
|
|
39
|
+
return Array.isArray(data) ? createdApiKeys : createdApiKeys[0];
|
|
40
|
+
}
|
|
41
|
+
async update(data, sharedContext = {}) {
|
|
42
|
+
const updatedApiKeys = await this.update_(data, sharedContext);
|
|
43
|
+
return await this.baseRepository_.serialize(updatedApiKeys, {
|
|
44
|
+
populate: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async update_(data, sharedContext = {}) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
async revoke(id, sharedContext = {}) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
authenticate(id, sharedContext = {}) {
|
|
54
|
+
return Promise.resolve(false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = ApiKeyModuleService;
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
60
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
61
|
+
__metadata("design:type", Function),
|
|
62
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
63
|
+
__metadata("design:returntype", Promise)
|
|
64
|
+
], ApiKeyModuleService.prototype, "create", null);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
67
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
68
|
+
__metadata("design:type", Function),
|
|
69
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
70
|
+
__metadata("design:returntype", Promise)
|
|
71
|
+
], ApiKeyModuleService.prototype, "create_", null);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
74
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
75
|
+
__metadata("design:type", Function),
|
|
76
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
77
|
+
__metadata("design:returntype", Promise)
|
|
78
|
+
], ApiKeyModuleService.prototype, "update", null);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
81
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
82
|
+
__metadata("design:type", Function),
|
|
83
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
84
|
+
__metadata("design:returntype", Promise)
|
|
85
|
+
], ApiKeyModuleService.prototype, "update_", null);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
88
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
91
|
+
__metadata("design:returntype", Promise)
|
|
92
|
+
], ApiKeyModuleService.prototype, "revoke", null);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
95
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
96
|
+
__metadata("design:type", Function),
|
|
97
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
98
|
+
__metadata("design:returntype", Promise)
|
|
99
|
+
], ApiKeyModuleService.prototype, "authenticate", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ApiKeyModuleService } from "./api-key-module-service";
|
|
@@ -0,0 +1,8 @@
|
|
|
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.ApiKeyModuleService = void 0;
|
|
7
|
+
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; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@medusajs/api-key",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Medusa API Key module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=16"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"medusa-api-key-seed": "dist/scripts/bin/run-seed.js"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/medusajs/medusa",
|
|
19
|
+
"directory": "packages/api-key"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"author": "Medusa",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"watch": "tsc --build --watch",
|
|
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",
|
|
31
|
+
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
|
32
|
+
"test:integration": "jest --runInBand --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"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@mikro-orm/cli": "5.9.7",
|
|
41
|
+
"cross-env": "^5.2.1",
|
|
42
|
+
"jest": "^29.6.3",
|
|
43
|
+
"medusa-test-utils": "^1.1.40",
|
|
44
|
+
"rimraf": "^3.0.2",
|
|
45
|
+
"ts-jest": "^29.1.1",
|
|
46
|
+
"ts-node": "^10.9.1",
|
|
47
|
+
"tsc-alias": "^1.8.6",
|
|
48
|
+
"typescript": "^5.1.6"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@medusajs/modules-sdk": "^1.12.4",
|
|
52
|
+
"@medusajs/types": "^1.11.8",
|
|
53
|
+
"@medusajs/utils": "^1.11.1",
|
|
54
|
+
"@mikro-orm/core": "5.9.7",
|
|
55
|
+
"@mikro-orm/migrations": "5.9.7",
|
|
56
|
+
"@mikro-orm/postgresql": "5.9.7",
|
|
57
|
+
"awilix": "^8.0.0",
|
|
58
|
+
"dotenv": "^16.1.4",
|
|
59
|
+
"knex": "2.4.2"
|
|
60
|
+
}
|
|
61
|
+
}
|