@gorgo/medusa-integration 0.0.1
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/.medusa/server/src/admin/index.js +2259 -0
- package/.medusa/server/src/admin/index.mjs +2257 -0
- package/.medusa/server/src/api/admin/integrations/[provider_id]/enable/route.d.ts +5 -0
- package/.medusa/server/src/api/admin/integrations/[provider_id]/enable/route.js +17 -0
- package/.medusa/server/src/api/admin/integrations/[provider_id]/route.d.ts +7 -0
- package/.medusa/server/src/api/admin/integrations/[provider_id]/route.js +46 -0
- package/.medusa/server/src/api/admin/integrations/[provider_id]/test-connection/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/integrations/[provider_id]/test-connection/route.js +16 -0
- package/.medusa/server/src/api/admin/integrations/_helpers.d.ts +16 -0
- package/.medusa/server/src/api/admin/integrations/_helpers.js +52 -0
- package/.medusa/server/src/api/admin/integrations/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/admin/integrations/middlewares.js +21 -0
- package/.medusa/server/src/api/admin/integrations/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/integrations/route.js +11 -0
- package/.medusa/server/src/api/admin/integrations/validators.d.ts +11 -0
- package/.medusa/server/src/api/admin/integrations/validators.js +15 -0
- package/.medusa/server/src/api/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/middlewares.js +10 -0
- package/.medusa/server/src/index.d.ts +10 -0
- package/.medusa/server/src/index.js +22 -0
- package/.medusa/server/src/jobs/test-integration-connections.d.ts +16 -0
- package/.medusa/server/src/jobs/test-integration-connections.js +53 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/build-zod.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/build-zod.unit.spec.js +64 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/define.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/define.unit.spec.js +41 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/introspect.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/introspect.unit.spec.js +93 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/validate.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/descriptor/__tests__/validate.unit.spec.js +64 -0
- package/.medusa/server/src/modules/integration/descriptor/build-zod.d.ts +8 -0
- package/.medusa/server/src/modules/integration/descriptor/build-zod.js +82 -0
- package/.medusa/server/src/modules/integration/descriptor/define.d.ts +74 -0
- package/.medusa/server/src/modules/integration/descriptor/define.js +31 -0
- package/.medusa/server/src/modules/integration/descriptor/index.d.ts +5 -0
- package/.medusa/server/src/modules/integration/descriptor/index.js +22 -0
- package/.medusa/server/src/modules/integration/descriptor/introspect.d.ts +5 -0
- package/.medusa/server/src/modules/integration/descriptor/introspect.js +67 -0
- package/.medusa/server/src/modules/integration/descriptor/meta.d.ts +7 -0
- package/.medusa/server/src/modules/integration/descriptor/meta.js +3 -0
- package/.medusa/server/src/modules/integration/descriptor/option.d.ts +104 -0
- package/.medusa/server/src/modules/integration/descriptor/option.js +3 -0
- package/.medusa/server/src/modules/integration/descriptor/validate.d.ts +29 -0
- package/.medusa/server/src/modules/integration/descriptor/validate.js +69 -0
- package/.medusa/server/src/modules/integration/index.d.ts +22 -0
- package/.medusa/server/src/modules/integration/index.js +15 -0
- package/.medusa/server/src/modules/integration/loaders/index.d.ts +1 -0
- package/.medusa/server/src/modules/integration/loaders/index.js +9 -0
- package/.medusa/server/src/modules/integration/loaders/load-providers.d.ts +5 -0
- package/.medusa/server/src/modules/integration/loaders/load-providers.js +35 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260610215533.d.ts +5 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260610215533.js +18 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260618154037.d.ts +5 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260618154037.js +27 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260622120502.d.ts +5 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260622120502.js +14 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260701095518.d.ts +5 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260701095518.js +14 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260708072033.d.ts +5 -0
- package/.medusa/server/src/modules/integration/migrations/Migration20260708072033.js +14 -0
- package/.medusa/server/src/modules/integration/models/integration.d.ts +13 -0
- package/.medusa/server/src/modules/integration/models/integration.js +27 -0
- package/.medusa/server/src/modules/integration/services/__tests__/crypto.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/services/__tests__/crypto.unit.spec.js +33 -0
- package/.medusa/server/src/modules/integration/services/__tests__/integration-provider.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/services/__tests__/integration-provider.unit.spec.js +77 -0
- package/.medusa/server/src/modules/integration/services/__tests__/secrets.unit.spec.d.ts +1 -0
- package/.medusa/server/src/modules/integration/services/__tests__/secrets.unit.spec.js +33 -0
- package/.medusa/server/src/modules/integration/services/crypto.d.ts +10 -0
- package/.medusa/server/src/modules/integration/services/crypto.js +41 -0
- package/.medusa/server/src/modules/integration/services/index.d.ts +3 -0
- package/.medusa/server/src/modules/integration/services/index.js +11 -0
- package/.medusa/server/src/modules/integration/services/integration-module.d.ts +113 -0
- package/.medusa/server/src/modules/integration/services/integration-module.js +219 -0
- package/.medusa/server/src/modules/integration/services/integration-provider.d.ts +49 -0
- package/.medusa/server/src/modules/integration/services/integration-provider.js +76 -0
- package/.medusa/server/src/modules/integration/services/secrets.d.ts +11 -0
- package/.medusa/server/src/modules/integration/services/secrets.js +31 -0
- package/.medusa/server/src/modules/integration/types/index.d.ts +13 -0
- package/.medusa/server/src/modules/integration/types/index.js +10 -0
- package/.medusa/server/src/modules/integration/utils/abstract-integration-provider.d.ts +39 -0
- package/.medusa/server/src/modules/integration/utils/abstract-integration-provider.js +42 -0
- package/.medusa/server/src/modules/integration/utils/index.d.ts +1 -0
- package/.medusa/server/src/modules/integration/utils/index.js +6 -0
- package/.medusa/server/src/subscribers/invalidate-options-cache.d.ts +5 -0
- package/.medusa/server/src/subscribers/invalidate-options-cache.js +13 -0
- package/.medusa/server/src/types/bundles.d.ts +1 -0
- package/.medusa/server/src/types/bundles.js +38 -0
- package/.medusa/server/src/types/http/index.d.ts +1 -0
- package/.medusa/server/src/types/http/index.js +18 -0
- package/.medusa/server/src/types/http/integration/admin/entities.d.ts +32 -0
- package/.medusa/server/src/types/http/integration/admin/entities.js +3 -0
- package/.medusa/server/src/types/http/integration/admin/index.d.ts +2 -0
- package/.medusa/server/src/types/http/integration/admin/index.js +19 -0
- package/.medusa/server/src/types/http/integration/admin/responses.d.ts +19 -0
- package/.medusa/server/src/types/http/integration/admin/responses.js +3 -0
- package/.medusa/server/src/types/http/integration/index.d.ts +1 -0
- package/.medusa/server/src/types/http/integration/index.js +18 -0
- package/.medusa/server/src/types/index.d.ts +3 -0
- package/.medusa/server/src/types/index.js +20 -0
- package/.medusa/server/src/types/integration/common.d.ts +70 -0
- package/.medusa/server/src/types/integration/common.js +3 -0
- package/.medusa/server/src/types/integration/index.d.ts +1 -0
- package/.medusa/server/src/types/integration/index.js +18 -0
- package/.medusa/server/src/workflows/integration/index.d.ts +2 -0
- package/.medusa/server/src/workflows/integration/index.js +19 -0
- package/.medusa/server/src/workflows/integration/steps/apply-integration-section.d.ts +22 -0
- package/.medusa/server/src/workflows/integration/steps/apply-integration-section.js +70 -0
- package/.medusa/server/src/workflows/integration/steps/delete-integration-record.d.ts +6 -0
- package/.medusa/server/src/workflows/integration/steps/delete-integration-record.js +16 -0
- package/.medusa/server/src/workflows/integration/steps/emit-integration-event.d.ts +5 -0
- package/.medusa/server/src/workflows/integration/steps/emit-integration-event.js +11 -0
- package/.medusa/server/src/workflows/integration/steps/index.d.ts +6 -0
- package/.medusa/server/src/workflows/integration/steps/index.js +16 -0
- package/.medusa/server/src/workflows/integration/steps/run-test-connection.d.ts +4 -0
- package/.medusa/server/src/workflows/integration/steps/run-test-connection.js +20 -0
- package/.medusa/server/src/workflows/integration/steps/set-integration-enabled.d.ts +19 -0
- package/.medusa/server/src/workflows/integration/steps/set-integration-enabled.js +27 -0
- package/.medusa/server/src/workflows/integration/steps/upsert-integration-record.d.ts +9 -0
- package/.medusa/server/src/workflows/integration/steps/upsert-integration-record.js +18 -0
- package/.medusa/server/src/workflows/integration/workflows/delete-integration.d.ts +7 -0
- package/.medusa/server/src/workflows/integration/workflows/delete-integration.js +18 -0
- package/.medusa/server/src/workflows/integration/workflows/index.d.ts +4 -0
- package/.medusa/server/src/workflows/integration/workflows/index.js +12 -0
- package/.medusa/server/src/workflows/integration/workflows/set-integration-enabled.d.ts +20 -0
- package/.medusa/server/src/workflows/integration/workflows/set-integration-enabled.js +20 -0
- package/.medusa/server/src/workflows/integration/workflows/test-integration-connection.d.ts +5 -0
- package/.medusa/server/src/workflows/integration/workflows/test-integration-connection.js +21 -0
- package/.medusa/server/src/workflows/integration/workflows/upsert-integration.d.ts +8 -0
- package/.medusa/server/src/workflows/integration/workflows/upsert-integration.js +30 -0
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/package.json +79 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { IntegrationDescriptorInput, TestConnectionContext, TestConnectionResult } from "../descriptor/define";
|
|
2
|
+
/**
|
|
3
|
+
* Base class AND contract for integration-providers. A plugin ships a subclass and
|
|
4
|
+
* registers it via `ModuleProvider(INTEGRATION_MODULE, { services: [MyProvider] })`.
|
|
5
|
+
*
|
|
6
|
+
* export class TkassaIntegrationProvider extends AbstractIntegrationProvider {
|
|
7
|
+
* static identifier = "tkassa"
|
|
8
|
+
* getDescriptor() { return tkassaDescriptor }
|
|
9
|
+
* async testConnection({ credentials }) { ... }
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* This class is the single source of truth for the provider contract — code that
|
|
13
|
+
* consumes providers (the registry) types against it, so adding a method here is the
|
|
14
|
+
* only place to touch (besides implementing it in concrete providers).
|
|
15
|
+
*
|
|
16
|
+
* `static identifier` becomes the descriptor's `pluginId` (settings are stored/resolved
|
|
17
|
+
* under it); authors don't repeat it in the descriptor.
|
|
18
|
+
*
|
|
19
|
+
* Each registration in `options.providers` is one *instance*: its `id` (if any) is
|
|
20
|
+
* injected by the loader and exposed via `getInstanceId()`. A provider registered
|
|
21
|
+
* without an `id` is the single (default) instance — `getInstanceId()` returns null.
|
|
22
|
+
* The container key `int_<identifier>[_<id>]` is the instance's stable identity.
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class AbstractIntegrationProvider {
|
|
25
|
+
static identifier: string;
|
|
26
|
+
/** The registration `id` (from `options.providers[].id`), injected by the loader. */
|
|
27
|
+
protected readonly instanceId_: string | null;
|
|
28
|
+
constructor(_container?: unknown, _options?: unknown, instanceId?: string | null);
|
|
29
|
+
/** Optional fail-fast validation of the provider's `options` at load time. */
|
|
30
|
+
static validateOptions(_options: Record<string, unknown>): void | never;
|
|
31
|
+
getIdentifier(): string;
|
|
32
|
+
/** This instance's id (the registration `id`), or null for the single/default instance. */
|
|
33
|
+
getInstanceId(): string | null;
|
|
34
|
+
/** Return this plugin's settings descriptor (zod schema + UI metadata + sections). */
|
|
35
|
+
abstract getDescriptor(): IntegrationDescriptorInput;
|
|
36
|
+
/** Optional connection check; omit if the plugin can't quickly verify credentials. */
|
|
37
|
+
testConnection?(ctx: TestConnectionContext): Promise<TestConnectionResult>;
|
|
38
|
+
}
|
|
39
|
+
export default AbstractIntegrationProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractIntegrationProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base class AND contract for integration-providers. A plugin ships a subclass and
|
|
6
|
+
* registers it via `ModuleProvider(INTEGRATION_MODULE, { services: [MyProvider] })`.
|
|
7
|
+
*
|
|
8
|
+
* export class TkassaIntegrationProvider extends AbstractIntegrationProvider {
|
|
9
|
+
* static identifier = "tkassa"
|
|
10
|
+
* getDescriptor() { return tkassaDescriptor }
|
|
11
|
+
* async testConnection({ credentials }) { ... }
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* This class is the single source of truth for the provider contract — code that
|
|
15
|
+
* consumes providers (the registry) types against it, so adding a method here is the
|
|
16
|
+
* only place to touch (besides implementing it in concrete providers).
|
|
17
|
+
*
|
|
18
|
+
* `static identifier` becomes the descriptor's `pluginId` (settings are stored/resolved
|
|
19
|
+
* under it); authors don't repeat it in the descriptor.
|
|
20
|
+
*
|
|
21
|
+
* Each registration in `options.providers` is one *instance*: its `id` (if any) is
|
|
22
|
+
* injected by the loader and exposed via `getInstanceId()`. A provider registered
|
|
23
|
+
* without an `id` is the single (default) instance — `getInstanceId()` returns null.
|
|
24
|
+
* The container key `int_<identifier>[_<id>]` is the instance's stable identity.
|
|
25
|
+
*/
|
|
26
|
+
class AbstractIntegrationProvider {
|
|
27
|
+
constructor(_container, _options, instanceId) {
|
|
28
|
+
this.instanceId_ = instanceId ?? null;
|
|
29
|
+
}
|
|
30
|
+
/** Optional fail-fast validation of the provider's `options` at load time. */
|
|
31
|
+
static validateOptions(_options) { }
|
|
32
|
+
getIdentifier() {
|
|
33
|
+
return this.constructor.identifier;
|
|
34
|
+
}
|
|
35
|
+
/** This instance's id (the registration `id`), or null for the single/default instance. */
|
|
36
|
+
getInstanceId() {
|
|
37
|
+
return this.instanceId_;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.AbstractIntegrationProvider = AbstractIntegrationProvider;
|
|
41
|
+
exports.default = AbstractIntegrationProvider;
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWJzdHJhY3QtaW50ZWdyYXRpb24tcHJvdmlkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9pbnRlZ3JhdGlvbi91dGlscy9hYnN0cmFjdC1pbnRlZ3JhdGlvbi1wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFNQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBcUJHO0FBQ0gsTUFBc0IsMkJBQTJCO0lBTS9DLFlBQVksVUFBb0IsRUFBRSxRQUFrQixFQUFFLFVBQTBCO1FBQzlFLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxJQUFJLElBQUksQ0FBQTtJQUN2QyxDQUFDO0lBRUQsOEVBQThFO0lBQzlFLE1BQU0sQ0FBQyxlQUFlLENBQUMsUUFBaUMsSUFBaUIsQ0FBQztJQUUxRSxhQUFhO1FBQ1gsT0FBUSxJQUFJLENBQUMsV0FBa0QsQ0FBQyxVQUFVLENBQUE7SUFDNUUsQ0FBQztJQUVELDJGQUEyRjtJQUMzRixhQUFhO1FBQ1gsT0FBTyxJQUFJLENBQUMsV0FBVyxDQUFBO0lBQ3pCLENBQUM7Q0FPRjtBQTNCRCxrRUEyQkM7QUFFRCxrQkFBZSwyQkFBMkIsQ0FBQSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AbstractIntegrationProvider } from "./abstract-integration-provider";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractIntegrationProvider = void 0;
|
|
4
|
+
var abstract_integration_provider_1 = require("./abstract-integration-provider");
|
|
5
|
+
Object.defineProperty(exports, "AbstractIntegrationProvider", { enumerable: true, get: function () { return abstract_integration_provider_1.AbstractIntegrationProvider; } });
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9pbnRlZ3JhdGlvbi91dGlscy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxpRkFBNkU7QUFBcEUsNElBQUEsMkJBQTJCLE9BQUEifQ==
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = void 0;
|
|
4
|
+
exports.default = invalidateOptionsCache;
|
|
5
|
+
const integration_1 = require("../modules/integration");
|
|
6
|
+
async function invalidateOptionsCache({ event, container, }) {
|
|
7
|
+
const service = container.resolve(integration_1.INTEGRATION_MODULE);
|
|
8
|
+
service.clearOptionsCache(event.data.provider_id);
|
|
9
|
+
}
|
|
10
|
+
exports.config = {
|
|
11
|
+
event: "integration.updated",
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW52YWxpZGF0ZS1vcHRpb25zLWNhY2hlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3N1YnNjcmliZXJzL2ludmFsaWRhdGUtb3B0aW9ucy1jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFJQSx5Q0FNQztBQVRELHdEQUEyRDtBQUc1QyxLQUFLLFVBQVUsc0JBQXNCLENBQUMsRUFDbkQsS0FBSyxFQUNMLFNBQVMsR0FDK0I7SUFDeEMsTUFBTSxPQUFPLEdBQTZCLFNBQVMsQ0FBQyxPQUFPLENBQUMsZ0NBQWtCLENBQUMsQ0FBQTtJQUMvRSxPQUFPLENBQUMsaUJBQWlCLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQTtBQUNuRCxDQUFDO0FBRVksUUFBQSxNQUFNLEdBQXFCO0lBQ3RDLEtBQUssRUFBRSxxQkFBcUI7Q0FDN0IsQ0FBQSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as IntegrationHttpTypes from "./http";
|
|
@@ -0,0 +1,38 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.IntegrationHttpTypes = void 0;
|
|
37
|
+
exports.IntegrationHttpTypes = __importStar(require("./http"));
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy90eXBlcy9idW5kbGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLCtEQUE4QyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./integration";
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
__exportStar(require("./integration"), exports);
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvdHlwZXMvaHR0cC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsZ0RBQTZCIn0=
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { I18nKey, DateValue, ModuleKind, TestStatus } from "../../../integration";
|
|
2
|
+
/** One declared integration instance (registration) merged with its current row state. */
|
|
3
|
+
export interface IntegrationOverviewItem {
|
|
4
|
+
provider_id: string;
|
|
5
|
+
plugin_id: string;
|
|
6
|
+
instance_id: string | null;
|
|
7
|
+
module: ModuleKind;
|
|
8
|
+
display_name: I18nKey;
|
|
9
|
+
/** Descriptor icon — any `<img src>` string (data URI / URL / `/static` path). */
|
|
10
|
+
icon?: string;
|
|
11
|
+
supports_multiple_instances: boolean;
|
|
12
|
+
has_test_connection: boolean;
|
|
13
|
+
is_configured: boolean;
|
|
14
|
+
is_enabled: boolean;
|
|
15
|
+
/** Stored config passes full validation (all required fields + cross-section rules). */
|
|
16
|
+
is_complete: boolean;
|
|
17
|
+
last_test_status: TestStatus | null;
|
|
18
|
+
last_test_at: DateValue;
|
|
19
|
+
}
|
|
20
|
+
/** Client-facing view of an integration record — secrets are never included. */
|
|
21
|
+
export interface MaskedIntegration {
|
|
22
|
+
id: string;
|
|
23
|
+
provider_id: string;
|
|
24
|
+
module: ModuleKind;
|
|
25
|
+
title: string | null;
|
|
26
|
+
is_enabled: boolean;
|
|
27
|
+
has_secrets: boolean;
|
|
28
|
+
last_test_at: DateValue;
|
|
29
|
+
last_test_status: TestStatus | null;
|
|
30
|
+
last_test_message: string | null;
|
|
31
|
+
values: Record<string, unknown>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW50aXRpZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvdHlwZXMvaHR0cC9pbnRlZ3JhdGlvbi9hZG1pbi9lbnRpdGllcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
__exportStar(require("./entities"), exports);
|
|
18
|
+
__exportStar(require("./responses"), exports);
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvdHlwZXMvaHR0cC9pbnRlZ3JhdGlvbi9hZG1pbi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsNkNBQTBCO0FBQzFCLDhDQUEyQiJ9
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DeleteResponse } from "@medusajs/framework/types";
|
|
2
|
+
import type { IntegrationOverviewItem, MaskedIntegration } from "./entities";
|
|
3
|
+
import type { TestConnectionResult, UiDescriptor } from "../../../integration";
|
|
4
|
+
export interface AdminIntegrationListResponse {
|
|
5
|
+
integrations: IntegrationOverviewItem[];
|
|
6
|
+
}
|
|
7
|
+
export interface AdminIntegrationResponse {
|
|
8
|
+
descriptor?: UiDescriptor;
|
|
9
|
+
integration: MaskedIntegration | null;
|
|
10
|
+
/** Whether the stored config passes full validation (all required + cross-section rules). */
|
|
11
|
+
is_complete: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AdminIntegrationUpsertResponse {
|
|
14
|
+
integration: MaskedIntegration;
|
|
15
|
+
}
|
|
16
|
+
export interface AdminIntegrationDeleteResponse extends DeleteResponse<"integration"> {
|
|
17
|
+
}
|
|
18
|
+
export interface AdminIntegrationTestResponse extends TestConnectionResult {
|
|
19
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzcG9uc2VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL3R5cGVzL2h0dHAvaW50ZWdyYXRpb24vYWRtaW4vcmVzcG9uc2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./admin";
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
__exportStar(require("./admin"), exports);
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvdHlwZXMvaHR0cC9pbnRlZ3JhdGlvbi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMENBQXVCIn0=
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
__exportStar(require("./bundles"), exports);
|
|
18
|
+
__exportStar(require("./http"), exports);
|
|
19
|
+
__exportStar(require("./integration"), exports);
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDRDQUF5QjtBQUN6Qix5Q0FBc0I7QUFDdEIsZ0RBQTZCIn0=
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { I18nKey, FieldControl } from "../../modules/integration/descriptor/meta";
|
|
2
|
+
export type { I18nKey };
|
|
3
|
+
export type ModuleKind = "payment" | "fulfillment" | "marketplace" | "crm" | "erp" | "pim" | "notification" | "feed" | "tax" | "other";
|
|
4
|
+
export type TestStatus = "ok" | "fail" | "skipped";
|
|
5
|
+
export type IntegrationLayouts = "core:single-column" | "core:two-column";
|
|
6
|
+
/** Date fields are `Date` server-side and ISO strings once JSON-serialized to the admin. */
|
|
7
|
+
export type DateValue = Date | string | null;
|
|
8
|
+
export interface TestConnectionContext {
|
|
9
|
+
options: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export interface TestConnectionResult {
|
|
12
|
+
status: TestStatus;
|
|
13
|
+
message?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface UiField {
|
|
16
|
+
name: string;
|
|
17
|
+
control: FieldControl;
|
|
18
|
+
secret: boolean;
|
|
19
|
+
required: boolean;
|
|
20
|
+
label: I18nKey;
|
|
21
|
+
hint?: I18nKey;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
options?: string[];
|
|
24
|
+
/** For `select`: i18n-key label per enum value (value → key). UI shows the label, stores the value. */
|
|
25
|
+
optionLabels?: Partial<Record<string, I18nKey>>;
|
|
26
|
+
/** Declarative UI visibility (evaluated admin-side against sibling values). */
|
|
27
|
+
visibleWhen?: {
|
|
28
|
+
field: string;
|
|
29
|
+
equals: string | number | boolean;
|
|
30
|
+
};
|
|
31
|
+
/** Rendered disabled (not editable) — an author-fixed constant. */
|
|
32
|
+
readonly?: boolean;
|
|
33
|
+
/** The constant to display for a readonly (non-secret) field — its descriptor `default`. */
|
|
34
|
+
readonlyValue?: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface UiSection {
|
|
37
|
+
id: string;
|
|
38
|
+
title: I18nKey;
|
|
39
|
+
column: "main" | "side";
|
|
40
|
+
fields: UiField[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Data the integration settings page passes to a provider's custom-section widget
|
|
44
|
+
* (via `LayoutComposer`'s `data` prop → the widget's `data` prop). Secrets are never
|
|
45
|
+
* included — anything needing a secret must go through a server endpoint.
|
|
46
|
+
*/
|
|
47
|
+
export interface IntegrationSectionData {
|
|
48
|
+
/** Registration key `int_<pluginId>[_<instanceId>]` — pass to API calls. */
|
|
49
|
+
providerId: string;
|
|
50
|
+
/** The provider's `static identifier` (e.g. "tkassa"). */
|
|
51
|
+
pluginId: string;
|
|
52
|
+
/** Current non-secret options for this integration. */
|
|
53
|
+
values: Record<string, unknown>;
|
|
54
|
+
/** Whether the stored config passes full validation (use to gate actions). */
|
|
55
|
+
isComplete: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface UiDescriptor {
|
|
58
|
+
module: string;
|
|
59
|
+
pluginId: string;
|
|
60
|
+
instanceId: string | null;
|
|
61
|
+
optionsVersion: number;
|
|
62
|
+
displayName: I18nKey;
|
|
63
|
+
description?: I18nKey;
|
|
64
|
+
icon?: string;
|
|
65
|
+
docsUrl?: string;
|
|
66
|
+
supportsMultipleInstances: boolean;
|
|
67
|
+
preferredLayoutId: IntegrationLayouts;
|
|
68
|
+
hasTestConnection: boolean;
|
|
69
|
+
sections: UiSection[];
|
|
70
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL3R5cGVzL2ludGVncmF0aW9uL2NvbW1vbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./common";
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
__exportStar(require("./common"), exports);
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvdHlwZXMvaW50ZWdyYXRpb24vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDJDQUF3QiJ9
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
__exportStar(require("./steps"), exports);
|
|
18
|
+
__exportStar(require("./workflows"), exports);
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2ludGVncmF0aW9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwwQ0FBdUI7QUFDdkIsOENBQTJCIn0=
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ApplyIntegrationSectionStepInput = {
|
|
2
|
+
provider_id: string;
|
|
3
|
+
/** Optional: a built-in section scopes writable ids to that section. A widget omits it. */
|
|
4
|
+
section_id?: string | null;
|
|
5
|
+
values: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Resolve which option ids this request may write, merge them over the stored config, run
|
|
9
|
+
* per-option validation, and encrypt secret options inline.
|
|
10
|
+
*
|
|
11
|
+
* - With `section_id`: writable ids = exactly that section's options (unknown section → 400).
|
|
12
|
+
* - Without `section_id` (widget): writable ids = the submitted keys that are DECLARED
|
|
13
|
+
* options — undeclared keys are dropped (never written to the `options` JSON column).
|
|
14
|
+
*
|
|
15
|
+
* Only the submitted ids are validated here; the config as a whole may still be a partial
|
|
16
|
+
* draft. Full validation happens lazily at resolve (IntegrationModuleService.getResolvedOptions).
|
|
17
|
+
*/
|
|
18
|
+
export declare const applyIntegrationSectionStep: import("@medusajs/framework/workflows-sdk").StepFunction<ApplyIntegrationSectionStepInput, {
|
|
19
|
+
module: import("../../..").ModuleKind;
|
|
20
|
+
options_version: number;
|
|
21
|
+
options: Record<string, unknown>;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyIntegrationSectionStep = void 0;
|
|
4
|
+
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
5
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
6
|
+
const integration_1 = require("../../../modules/integration");
|
|
7
|
+
const introspect_1 = require("../../../modules/integration/descriptor/introspect");
|
|
8
|
+
const validate_1 = require("../../../modules/integration/descriptor/validate");
|
|
9
|
+
/**
|
|
10
|
+
* Resolve which option ids this request may write, merge them over the stored config, run
|
|
11
|
+
* per-option validation, and encrypt secret options inline.
|
|
12
|
+
*
|
|
13
|
+
* - With `section_id`: writable ids = exactly that section's options (unknown section → 400).
|
|
14
|
+
* - Without `section_id` (widget): writable ids = the submitted keys that are DECLARED
|
|
15
|
+
* options — undeclared keys are dropped (never written to the `options` JSON column).
|
|
16
|
+
*
|
|
17
|
+
* Only the submitted ids are validated here; the config as a whole may still be a partial
|
|
18
|
+
* draft. Full validation happens lazily at resolve (IntegrationModuleService.getResolvedOptions).
|
|
19
|
+
*/
|
|
20
|
+
exports.applyIntegrationSectionStep = (0, workflows_sdk_1.createStep)("apply-integration-section", async (input, { container }) => {
|
|
21
|
+
const service = container.resolve(integration_1.INTEGRATION_MODULE);
|
|
22
|
+
const descriptor = service.getProviderDescriptor(input.provider_id);
|
|
23
|
+
if (!descriptor) {
|
|
24
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `No integration provider registered for "${input.provider_id}"`);
|
|
25
|
+
}
|
|
26
|
+
// Resolve the set of option ids this request is allowed to write.
|
|
27
|
+
let allowed;
|
|
28
|
+
if (input.section_id != null) {
|
|
29
|
+
const section = descriptor.sections.find((s) => s.id === input.section_id);
|
|
30
|
+
if (!section) {
|
|
31
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Unknown section "${input.section_id}"`);
|
|
32
|
+
}
|
|
33
|
+
allowed = [...section.options];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
allowed = Object.keys(input.values).filter((k) => Object.prototype.hasOwnProperty.call(descriptor.options, k));
|
|
37
|
+
}
|
|
38
|
+
// readonly options are author-fixed constants — never written from a client request
|
|
39
|
+
// (their value always comes from the descriptor `default` at resolve).
|
|
40
|
+
allowed = allowed.filter((id) => descriptor.options[id]?.readonly !== true);
|
|
41
|
+
// Secrets are never sent to the client, so a blank/absent secret means "keep existing".
|
|
42
|
+
const current = await service.getStoredValues(input.provider_id);
|
|
43
|
+
const secretKeys = new Set((0, introspect_1.secretFieldNames)(descriptor));
|
|
44
|
+
const submitted = {};
|
|
45
|
+
for (const id of allowed) {
|
|
46
|
+
let v = input.values[id];
|
|
47
|
+
if (secretKeys.has(id) && (v == null || v === "")) {
|
|
48
|
+
if (id in current)
|
|
49
|
+
v = current[id];
|
|
50
|
+
else
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
submitted[id] = v;
|
|
54
|
+
}
|
|
55
|
+
// Validate submitted ids against the merged config (per-option cross-field rules see siblings).
|
|
56
|
+
const merged = { ...current, ...submitted };
|
|
57
|
+
const validated = (0, validate_1.validateOptions)(descriptor, allowed, merged);
|
|
58
|
+
if (!validated.success) {
|
|
59
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, validated.issues.map((i) => `${i.path}: ${i.message}`).join("; "));
|
|
60
|
+
}
|
|
61
|
+
// Merge the (defaulted) validated values over the rest of the config, then encrypt secrets inline.
|
|
62
|
+
const full = { ...current, ...validated.data };
|
|
63
|
+
const options = service.encryptForStorage(descriptor, full);
|
|
64
|
+
return new workflows_sdk_1.StepResponse({
|
|
65
|
+
module: descriptor.module,
|
|
66
|
+
options_version: descriptor.optionsVersion ?? 1,
|
|
67
|
+
options,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbHktaW50ZWdyYXRpb24tc2VjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3MvaW50ZWdyYXRpb24vc3RlcHMvYXBwbHktaW50ZWdyYXRpb24tc2VjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxRUFBNEU7QUFDNUUscURBQXVEO0FBQ3ZELDhEQUFpRTtBQUVqRSxtRkFBcUY7QUFDckYsK0VBQWtGO0FBU2xGOzs7Ozs7Ozs7O0dBVUc7QUFDVSxRQUFBLDJCQUEyQixHQUFHLElBQUEsMEJBQVUsRUFDbkQsMkJBQTJCLEVBQzNCLEtBQUssRUFBRSxLQUF1QyxFQUFFLEVB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= void 0;
|
|
4
|
+
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
5
|
+
const integration_1 = require("../../../modules/integration");
|
|
6
|
+
exports.deleteIntegrationRecordStep = (0, workflows_sdk_1.createStep)("delete-integration-record", async (input, { container }) => {
|
|
7
|
+
const service = container.resolve(integration_1.INTEGRATION_MODULE);
|
|
8
|
+
const existing = await service.findByProviderId(input.provider_id);
|
|
9
|
+
if (!existing)
|
|
10
|
+
return new workflows_sdk_1.StepResponse({ deleted: false });
|
|
11
|
+
// Permanently remove the configuration and its stored credentials. Temporarily turning
|
|
12
|
+
// an integration off is a separate action — POST /admin/integrations/:id/enable.
|
|
13
|
+
await service.deleteIntegrations(existing.id);
|
|
14
|
+
return new workflows_sdk_1.StepResponse({ deleted: true });
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVsZXRlLWludGVncmF0aW9uLXJlY29yZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3MvaW50ZWdyYXRpb24vc3RlcHMvZGVsZXRlLWludGVncmF0aW9uLXJlY29yZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxRUFBNEU7QUFDNUUsOERBQWlFO0FBT3BELFFBQUEsMkJBQTJCLEdBQUcsSUFBQSwwQkFBVSxFQUNuRCwyQkFBMkIsRUFDM0IsS0FBSyxFQUFFLEtBQXVDLEVBQUUsRUFBRSxTQUFTLEVBQUUsRUFBRSxFQUFFO0lBQy9ELE1BQU0sT0FBTyxHQUE2QixTQUFTLENBQUMsT0FBTyxDQUFDLGdDQUFrQixDQUFDLENBQUE7SUFDL0UsTUFBTSxRQUFRLEdBQUcsTUFBTSxPQUFPLENBQUMsZ0JBQWdCLENBQUMsS0FBSyxDQUFDLFdBQVcsQ0FBQyxDQUFBO0lBQ2xFLElBQUksQ0FBQyxRQUFRO1FBQUUsT0FBTyxJQUFJLDRCQUFZLENBQUMsRUFBRSxPQUFPLEVBQUUsS0FBSyxFQUFFLENBQUMsQ0FBQTtJQUMxRCx1RkFBdUY7SUFDdkYsaUZBQWlGO0lBQ2pGLE1BQU0sT0FBTyxDQUFDLGtCQUFrQixDQUFDLFFBQVEsQ0FBQyxFQUFFLENBQUMsQ0FBQTtJQUM3QyxPQUFPLElBQUksNEJBQVksQ0FBQyxFQUFFLE9BQU8sRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFBO0FBQzVDLENBQUMsQ0FDRixDQUFBIn0=
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitIntegrationEventStep = void 0;
|
|
4
|
+
const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
|
|
5
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
6
|
+
exports.emitIntegrationEventStep = (0, workflows_sdk_1.createStep)("emit-integration-event", async (input, { container }) => {
|
|
7
|
+
const eventBus = container.resolve(utils_1.Modules.EVENT_BUS);
|
|
8
|
+
await eventBus.emit({ name: input.name, data: input.data });
|
|
9
|
+
return new workflows_sdk_1.StepResponse(void 0);
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1pdC1pbnRlZ3JhdGlvbi1ldmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3MvaW50ZWdyYXRpb24vc3RlcHMvZW1pdC1pbnRlZ3JhdGlvbi1ldmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxRUFBNEU7QUFDNUUscURBQW1EO0FBUXRDLFFBQUEsd0JBQXdCLEdBQUcsSUFBQSwwQkFBVSxFQUNoRCx3QkFBd0IsRUFDeEIsS0FBSyxFQUFFLEtBQW9DLEVBQUUsRUFBRSxTQUFTLEVBQUUsRUFBRSxFQUFFO0lBQzVELE1BQU0sUUFBUSxHQUFHLFNBQVMsQ0FBQyxPQUFPLENBQXlCLGVBQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUM3RSxNQUFNLFFBQVEsQ0FBQyxJQUFJLENBQUMsRUFBRSxJQUFJLEVBQUUsS0FBSyxDQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsS0FBSyxDQUFDLElBQUksRUFBRSxDQUFDLENBQUE7SUFDM0QsT0FBTyxJQUFJLDRCQUFZLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQTtBQUNqQyxDQUFDLENBQ0YsQ0FBQSJ9
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { applyIntegrationSectionStep } from "./apply-integration-section";
|
|
2
|
+
export { deleteIntegrationRecordStep } from "./delete-integration-record";
|
|
3
|
+
export { emitIntegrationEventStep } from "./emit-integration-event";
|
|
4
|
+
export { runTestConnectionStep } from "./run-test-connection";
|
|
5
|
+
export { setIntegrationEnabledStep } from "./set-integration-enabled";
|
|
6
|
+
export { upsertIntegrationRecordStep } from "./upsert-integration-record";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upsertIntegrationRecordStep = exports.setIntegrationEnabledStep = exports.runTestConnectionStep = exports.emitIntegrationEventStep = exports.deleteIntegrationRecordStep = exports.applyIntegrationSectionStep = void 0;
|
|
4
|
+
var apply_integration_section_1 = require("./apply-integration-section");
|
|
5
|
+
Object.defineProperty(exports, "applyIntegrationSectionStep", { enumerable: true, get: function () { return apply_integration_section_1.applyIntegrationSectionStep; } });
|
|
6
|
+
var delete_integration_record_1 = require("./delete-integration-record");
|
|
7
|
+
Object.defineProperty(exports, "deleteIntegrationRecordStep", { enumerable: true, get: function () { return delete_integration_record_1.deleteIntegrationRecordStep; } });
|
|
8
|
+
var emit_integration_event_1 = require("./emit-integration-event");
|
|
9
|
+
Object.defineProperty(exports, "emitIntegrationEventStep", { enumerable: true, get: function () { return emit_integration_event_1.emitIntegrationEventStep; } });
|
|
10
|
+
var run_test_connection_1 = require("./run-test-connection");
|
|
11
|
+
Object.defineProperty(exports, "runTestConnectionStep", { enumerable: true, get: function () { return run_test_connection_1.runTestConnectionStep; } });
|
|
12
|
+
var set_integration_enabled_1 = require("./set-integration-enabled");
|
|
13
|
+
Object.defineProperty(exports, "setIntegrationEnabledStep", { enumerable: true, get: function () { return set_integration_enabled_1.setIntegrationEnabledStep; } });
|
|
14
|
+
var upsert_integration_record_1 = require("./upsert-integration-record");
|
|
15
|
+
Object.defineProperty(exports, "upsertIntegrationRecordStep", { enumerable: true, get: function () { return upsert_integration_record_1.upsertIntegrationRecordStep; } });
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2ludGVncmF0aW9uL3N0ZXBzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHlFQUF5RTtBQUFoRSx3SUFBQSwyQkFBMkIsT0FBQTtBQUNwQyx5RUFBeUU7QUFBaEUsd0lBQUEsMkJBQTJCLE9BQUE7QUFDcEMsbUVBQW1FO0FBQTFELGtJQUFBLHdCQUF3QixPQUFBO0FBQ2pDLDZEQUE2RDtBQUFwRCw0SEFBQSxxQkFBcUIsT0FBQTtBQUM5QixxRUFBcUU7QUFBNUQsb0lBQUEseUJBQXlCLE9BQUE7QUFDbEMseUVBQXlFO0FBQWhFLHdJQUFBLDJCQUEyQixPQUFBIn0=
|