@useparagon/cli 0.0.1-canary.28 → 0.0.1-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codegen/codegen.types.d.ts +2 -19
- package/dist/codegen/codegen.utils.d.ts +4 -4
- package/dist/codegen/codegen.utils.js +39 -47
- package/dist/codegen/codegen.utils.js.map +1 -1
- package/dist/codegen/codegens/condition.codegen.d.ts +1 -2
- package/dist/codegen/codegens/condition.codegen.js +10 -99
- package/dist/codegen/codegens/condition.codegen.js.map +1 -1
- package/dist/codegen/codegens/event.codegen.js +12 -6
- package/dist/codegen/codegens/event.codegen.js.map +1 -1
- package/dist/codegen/codegens/integration.codegen.d.ts +2 -5
- package/dist/codegen/codegens/integration.codegen.js +6 -233
- package/dist/codegen/codegens/integration.codegen.js.map +1 -1
- package/dist/codegen/codegens/source.codegen.d.ts +4 -7
- package/dist/codegen/codegens/source.codegen.js +27 -202
- package/dist/codegen/codegens/source.codegen.js.map +1 -1
- package/dist/codegen/codegens/workflow.codegen.d.ts +2 -2
- package/dist/codegen/codegens/workflow.codegen.js +117 -239
- package/dist/codegen/codegens/workflow.codegen.js.map +1 -1
- package/dist/commands/build/build.action.d.ts +2 -2
- package/dist/commands/build/build.action.js +33 -30
- package/dist/commands/build/build.action.js.map +1 -1
- package/dist/commands/build/build.command.js +7 -9
- package/dist/commands/build/build.command.js.map +1 -1
- package/dist/commands/build/build.utils.d.ts +1 -1
- package/dist/commands/build/build.utils.js +9 -12
- package/dist/commands/build/build.utils.js.map +1 -1
- package/dist/commands/command.loader.js +9 -13
- package/dist/commands/command.loader.js.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init/init.action.d.ts +2 -2
- package/dist/commands/init/init.action.js +69 -87
- package/dist/commands/init/init.action.js.map +1 -1
- package/dist/commands/init/init.command.js +7 -13
- package/dist/commands/init/init.command.js.map +1 -1
- package/dist/commands/init/init.constants.js +21 -0
- package/dist/commands/init/init.constants.js.map +1 -0
- package/dist/commands/init/init.utils.d.ts +11 -0
- package/dist/commands/init/init.utils.js +50 -0
- package/dist/commands/init/init.utils.js.map +1 -0
- package/dist/commands/login/index.js.map +1 -0
- package/dist/commands/{auth/auth.command.d.ts → login/login.command.d.ts} +1 -1
- package/dist/commands/login/login.command.js +26 -0
- package/dist/commands/login/login.command.js.map +1 -0
- package/dist/commands/login/login.types.d.ts +3 -0
- package/dist/commands/login/login.types.js.map +1 -0
- package/dist/commands/login/login.utils.d.ts +2 -0
- package/dist/commands/login/login.utils.js +47 -0
- package/dist/commands/login/login.utils.js.map +1 -0
- package/dist/compilers/compiler.interface.d.ts +3 -0
- package/dist/compilers/compiler.interface.js.map +1 -0
- package/dist/compilers/compiler.types.d.ts +23 -0
- package/dist/compilers/compiler.types.js.map +1 -0
- package/dist/compilers/compiler.utils.d.ts +2 -0
- package/dist/{compiler → compilers}/compiler.utils.js +6 -9
- package/dist/compilers/compiler.utils.js.map +1 -0
- package/dist/compilers/event.compiler.d.ts +7 -0
- package/dist/compilers/event.compiler.js +25 -0
- package/dist/compilers/event.compiler.js.map +1 -0
- package/dist/compilers/integration.compiler.d.ts +9 -0
- package/dist/compilers/integration.compiler.js +55 -0
- package/dist/compilers/integration.compiler.js.map +1 -0
- package/dist/compilers/project.compiler.d.ts +10 -0
- package/dist/compilers/project.compiler.js +50 -0
- package/dist/compilers/project.compiler.js.map +1 -0
- package/dist/{compiler → compilers}/ts.compiler.d.ts +1 -1
- package/dist/{compiler → compilers}/ts.compiler.js +17 -11
- package/dist/compilers/ts.compiler.js.map +1 -0
- package/dist/compilers/workflow.compiler.d.ts +10 -0
- package/dist/compilers/workflow.compiler.js +36 -0
- package/dist/compilers/workflow.compiler.js.map +1 -0
- package/dist/config/config.constants.d.ts +2 -1
- package/dist/config/config.constants.js +6 -4
- package/dist/config/config.constants.js.map +1 -1
- package/dist/config/config.types.d.ts +13 -12
- package/dist/config/config.types.js +3 -3
- package/dist/config/config.types.js.map +1 -1
- package/dist/config/config.utils.d.ts +9 -10
- package/dist/config/config.utils.js +124 -93
- package/dist/config/config.utils.js.map +1 -1
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.js +0 -1
- package/dist/config/index.js.map +1 -1
- package/dist/helpers/strings.d.ts +0 -2
- package/dist/helpers/strings.js +1 -35
- package/dist/helpers/strings.js.map +1 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +1 -1
- package/dist/logger/logger.js +3 -44
- package/dist/logger/logger.js.map +1 -1
- package/dist/logger/logger.type.d.ts +1 -3
- package/dist/templates/configurations/javascript/.prettierrc +0 -4
- package/dist/templates/configurations/typescript/.prettierrc +0 -4
- package/dist/templates/javascript/src/events/hello-world.js +13 -0
- package/dist/templates/javascript/src/integrations/slack/config.js +11 -0
- package/dist/templates/javascript/src/integrations/slack/workflows/example-workflow.js +30 -0
- package/dist/templates/typescript/src/events/hello-world.ts +21 -0
- package/dist/templates/typescript/src/integrations/slack/config.ts +18 -0
- package/dist/templates/typescript/src/integrations/slack/workflows/example-workflow.ts +30 -0
- package/dist/templates/{configurations/typescript → typescript}/tsconfig.json +4 -7
- package/package.json +19 -25
- package/dist/apis/api.types.d.ts +0 -87
- package/dist/apis/api.types.js +0 -3
- package/dist/apis/api.types.js.map +0 -1
- package/dist/apis/auth.api.d.ts +0 -5
- package/dist/apis/auth.api.js +0 -14
- package/dist/apis/auth.api.js.map +0 -1
- package/dist/apis/base.api.d.ts +0 -10
- package/dist/apis/base.api.js +0 -90
- package/dist/apis/base.api.js.map +0 -1
- package/dist/apis/index.d.ts +0 -4
- package/dist/apis/index.js +0 -8
- package/dist/apis/index.js.map +0 -1
- package/dist/apis/integration.api.d.ts +0 -3
- package/dist/apis/integration.api.js +0 -28
- package/dist/apis/integration.api.js.map +0 -1
- package/dist/apis/project.api.d.ts +0 -7
- package/dist/apis/project.api.js +0 -41
- package/dist/apis/project.api.js.map +0 -1
- package/dist/codegen/codegens/persona.codegen.d.ts +0 -2
- package/dist/codegen/codegens/persona.codegen.js +0 -12
- package/dist/codegen/codegens/persona.codegen.js.map +0 -1
- package/dist/commands/auth/auth.command.js +0 -18
- package/dist/commands/auth/auth.command.js.map +0 -1
- package/dist/commands/auth/index.d.ts +0 -1
- package/dist/commands/auth/index.js +0 -5
- package/dist/commands/auth/index.js.map +0 -1
- package/dist/commands/auth/login/index.js.map +0 -1
- package/dist/commands/auth/login/login.action.d.ts +0 -5
- package/dist/commands/auth/login/login.action.js +0 -42
- package/dist/commands/auth/login/login.action.js.map +0 -1
- package/dist/commands/auth/login/login.command.d.ts +0 -8
- package/dist/commands/auth/login/login.command.js +0 -25
- package/dist/commands/auth/login/login.command.js.map +0 -1
- package/dist/commands/auth/login/login.types.d.ts +0 -9
- package/dist/commands/auth/login/login.types.js.map +0 -1
- package/dist/commands/auth/login/login.utils.d.ts +0 -2
- package/dist/commands/auth/login/login.utils.js +0 -93
- package/dist/commands/auth/login/login.utils.js.map +0 -1
- package/dist/commands/auth/logout/index.d.ts +0 -1
- package/dist/commands/auth/logout/index.js +0 -5
- package/dist/commands/auth/logout/index.js.map +0 -1
- package/dist/commands/auth/logout/logout.action.d.ts +0 -5
- package/dist/commands/auth/logout/logout.action.js +0 -14
- package/dist/commands/auth/logout/logout.action.js.map +0 -1
- package/dist/commands/auth/logout/logout.command.d.ts +0 -8
- package/dist/commands/auth/logout/logout.command.js +0 -24
- package/dist/commands/auth/logout/logout.command.js.map +0 -1
- package/dist/commands/auth/logout/logout.types.d.ts +0 -1
- package/dist/commands/auth/logout/logout.types.js +0 -3
- package/dist/commands/auth/logout/logout.types.js.map +0 -1
- package/dist/commands/auth/me/index.d.ts +0 -1
- package/dist/commands/auth/me/index.js +0 -5
- package/dist/commands/auth/me/index.js.map +0 -1
- package/dist/commands/auth/me/me.action.d.ts +0 -5
- package/dist/commands/auth/me/me.action.js +0 -26
- package/dist/commands/auth/me/me.action.js.map +0 -1
- package/dist/commands/auth/me/me.command.d.ts +0 -8
- package/dist/commands/auth/me/me.command.js +0 -24
- package/dist/commands/auth/me/me.command.js.map +0 -1
- package/dist/commands/auth/me/me.types.d.ts +0 -1
- package/dist/commands/auth/me/me.types.js +0 -3
- package/dist/commands/auth/me/me.types.js.map +0 -1
- package/dist/commands/install/index.d.ts +0 -1
- package/dist/commands/install/index.js +0 -5
- package/dist/commands/install/index.js.map +0 -1
- package/dist/commands/install/install.action.d.ts +0 -5
- package/dist/commands/install/install.action.js +0 -11
- package/dist/commands/install/install.action.js.map +0 -1
- package/dist/commands/install/install.command.d.ts +0 -8
- package/dist/commands/install/install.command.js +0 -28
- package/dist/commands/install/install.command.js.map +0 -1
- package/dist/commands/install/install.constants.js +0 -68
- package/dist/commands/install/install.constants.js.map +0 -1
- package/dist/commands/install/install.types.d.ts +0 -7
- package/dist/commands/install/install.types.js +0 -3
- package/dist/commands/install/install.types.js.map +0 -1
- package/dist/commands/install/install.utils.d.ts +0 -8
- package/dist/commands/install/install.utils.js +0 -125
- package/dist/commands/install/install.utils.js.map +0 -1
- package/dist/commands/new/index.d.ts +0 -1
- package/dist/commands/new/index.js +0 -5
- package/dist/commands/new/index.js.map +0 -1
- package/dist/commands/new/integration/index.d.ts +0 -1
- package/dist/commands/new/integration/index.js +0 -5
- package/dist/commands/new/integration/index.js.map +0 -1
- package/dist/commands/new/integration/integration.action.d.ts +0 -5
- package/dist/commands/new/integration/integration.action.js +0 -52
- package/dist/commands/new/integration/integration.action.js.map +0 -1
- package/dist/commands/new/integration/integration.command.d.ts +0 -8
- package/dist/commands/new/integration/integration.command.js +0 -26
- package/dist/commands/new/integration/integration.command.js.map +0 -1
- package/dist/commands/new/integration/integration.types.d.ts +0 -1
- package/dist/commands/new/integration/integration.types.js +0 -3
- package/dist/commands/new/integration/integration.types.js.map +0 -1
- package/dist/commands/new/new.command.d.ts +0 -5
- package/dist/commands/new/new.command.js +0 -16
- package/dist/commands/new/new.command.js.map +0 -1
- package/dist/commands/new/new.utils.d.ts +0 -1
- package/dist/commands/new/new.utils.js +0 -18
- package/dist/commands/new/new.utils.js.map +0 -1
- package/dist/commands/new/workflow/index.d.ts +0 -1
- package/dist/commands/new/workflow/index.js +0 -5
- package/dist/commands/new/workflow/index.js.map +0 -1
- package/dist/commands/new/workflow/workflow.action.d.ts +0 -5
- package/dist/commands/new/workflow/workflow.action.js +0 -90
- package/dist/commands/new/workflow/workflow.action.js.map +0 -1
- package/dist/commands/new/workflow/workflow.command.d.ts +0 -8
- package/dist/commands/new/workflow/workflow.command.js +0 -29
- package/dist/commands/new/workflow/workflow.command.js.map +0 -1
- package/dist/commands/new/workflow/workflow.types.d.ts +0 -3
- package/dist/commands/new/workflow/workflow.types.js +0 -3
- package/dist/commands/new/workflow/workflow.types.js.map +0 -1
- package/dist/commands/push/index.d.ts +0 -1
- package/dist/commands/push/index.js +0 -5
- package/dist/commands/push/index.js.map +0 -1
- package/dist/commands/push/push.action.d.ts +0 -5
- package/dist/commands/push/push.action.js +0 -22
- package/dist/commands/push/push.action.js.map +0 -1
- package/dist/commands/push/push.command.d.ts +0 -8
- package/dist/commands/push/push.command.js +0 -26
- package/dist/commands/push/push.command.js.map +0 -1
- package/dist/commands/push/push.types.d.ts +0 -1
- package/dist/commands/push/push.types.js +0 -3
- package/dist/commands/push/push.types.js.map +0 -1
- package/dist/compiler/compiler.interface.d.ts +0 -3
- package/dist/compiler/compiler.interface.js.map +0 -1
- package/dist/compiler/compiler.types.d.ts +0 -11
- package/dist/compiler/compiler.types.js.map +0 -1
- package/dist/compiler/compiler.utils.d.ts +0 -2
- package/dist/compiler/compiler.utils.js.map +0 -1
- package/dist/compiler/compilers/events.compiler.d.ts +0 -10
- package/dist/compiler/compilers/events.compiler.js +0 -39
- package/dist/compiler/compilers/events.compiler.js.map +0 -1
- package/dist/compiler/compilers/integrations.compiler.d.ts +0 -17
- package/dist/compiler/compilers/integrations.compiler.js +0 -169
- package/dist/compiler/compilers/integrations.compiler.js.map +0 -1
- package/dist/compiler/compilers/persona.compiler.d.ts +0 -9
- package/dist/compiler/compilers/persona.compiler.js +0 -15
- package/dist/compiler/compilers/persona.compiler.js.map +0 -1
- package/dist/compiler/compilers/project.compiler.d.ts +0 -14
- package/dist/compiler/compilers/project.compiler.js +0 -66
- package/dist/compiler/compilers/project.compiler.js.map +0 -1
- package/dist/compiler/compilers/workflows.compiler.d.ts +0 -24
- package/dist/compiler/compilers/workflows.compiler.js +0 -64
- package/dist/compiler/compilers/workflows.compiler.js.map +0 -1
- package/dist/compiler/ts.compiler.js.map +0 -1
- package/dist/helpers/file.d.ts +0 -3
- package/dist/helpers/file.js +0 -54
- package/dist/helpers/file.js.map +0 -1
- package/dist/helpers/http.d.ts +0 -1
- package/dist/helpers/http.js +0 -11
- package/dist/helpers/http.js.map +0 -1
- /package/dist/commands/{install/install.constants.d.ts → init/init.constants.d.ts} +0 -0
- /package/dist/commands/{auth/login → login}/index.d.ts +0 -0
- /package/dist/commands/{auth/login → login}/index.js +0 -0
- /package/dist/commands/{auth/login → login}/login.types.js +0 -0
- /package/dist/{compiler → compilers}/compiler.interface.js +0 -0
- /package/dist/{compiler → compilers}/compiler.types.js +0 -0
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
|
|
3
|
-
import { ISecret } from '@useparagon/core/secret';
|
|
4
|
-
import { IntegrationWorkflowMeta } from '../apis/api.types';
|
|
1
|
+
import { IEvent } from '@useparagon/core/event';
|
|
5
2
|
export type ProjectDependencies = {
|
|
6
|
-
|
|
7
|
-
secrets: ISecret[];
|
|
3
|
+
events: Record<string, IEvent>;
|
|
8
4
|
};
|
|
9
5
|
export type WorkflowDependencies = ProjectDependencies & {
|
|
10
6
|
integration: {
|
|
11
7
|
name: string;
|
|
12
8
|
};
|
|
13
|
-
workflowMeta: IntegrationWorkflowMeta;
|
|
14
|
-
sharedInputs: SerializedInput[];
|
|
15
|
-
inputSources: InputSource[];
|
|
16
|
-
};
|
|
17
|
-
export type StepDependencies = {
|
|
18
|
-
sharedInputs: SerializedInput[];
|
|
19
|
-
inputs: SerializedInput[];
|
|
20
|
-
inputSources: InputSource[];
|
|
21
|
-
stepIdToVariableMap: Record<string, string>;
|
|
22
|
-
eventIdToNameMap: Record<string, string>;
|
|
23
|
-
stepIdToStepMap: Record<string, IStep>;
|
|
24
|
-
secrets: ISecret[];
|
|
25
|
-
currentStepId?: string;
|
|
26
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput:
|
|
4
|
-
export declare const generateProjectFiles: (projectBuild:
|
|
1
|
+
import { BuildOutput, IntegrationOutput, ProjectDependencies } from '../compilers/compiler.types';
|
|
2
|
+
export declare const wrapMultilineString: (value: string) => string;
|
|
3
|
+
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput: IntegrationOutput, projectDependencies: ProjectDependencies, projectRoot: string) => Promise<void>;
|
|
4
|
+
export declare const generateProjectFiles: (projectBuild: BuildOutput, projectRoot: string) => Promise<void>;
|
|
@@ -1,78 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateProjectFiles = exports.generateIntegrationFiles = void 0;
|
|
3
|
+
exports.generateProjectFiles = exports.generateIntegrationFiles = exports.wrapMultilineString = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const importSortOrderPlugin = tslib_1.__importStar(require("@trivago/prettier-plugin-sort-imports"));
|
|
5
6
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
6
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const
|
|
8
|
+
const prettier_1 = tslib_1.__importDefault(require("prettier"));
|
|
9
|
+
const organiseImportPlugin = tslib_1.__importStar(require("prettier-plugin-organize-imports"));
|
|
8
10
|
const event_codegen_1 = require("./codegens/event.codegen");
|
|
9
11
|
const integration_codegen_1 = require("./codegens/integration.codegen");
|
|
10
|
-
const persona_codegen_1 = require("./codegens/persona.codegen");
|
|
11
12
|
const workflow_codegen_1 = require("./codegens/workflow.codegen");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
13
|
+
const writeSourceToFile = (filePath, fileName, sourceCode) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const sanitizeFileName = fileName;
|
|
15
|
+
const formattedCode = prettier_1.default.format(sourceCode, {
|
|
16
|
+
parser: 'typescript',
|
|
17
|
+
semi: true,
|
|
18
|
+
trailingComma: 'all',
|
|
19
|
+
singleQuote: true,
|
|
20
|
+
plugins: [organiseImportPlugin, importSortOrderPlugin],
|
|
21
|
+
importOrder: ['^@useparagon/(.*)$', '^[./]'],
|
|
22
|
+
importOrderSeparation: true,
|
|
23
|
+
importOrderCaseInsensitive: true,
|
|
24
|
+
});
|
|
25
|
+
yield fs_extra_1.default.promises.writeFile(path_1.default.join(filePath, `${sanitizeFileName}.ts`), formattedCode);
|
|
26
|
+
});
|
|
27
|
+
const wrapMultilineString = (value) => {
|
|
28
|
+
return '`' + value + '`';
|
|
29
|
+
};
|
|
30
|
+
exports.wrapMultilineString = wrapMultilineString;
|
|
31
|
+
const generateIntegrationFiles = (integrationName, integrationOutput, projectDependencies, projectRoot) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
32
|
const integrationPath = path_1.default.join(projectRoot, 'integrations', integrationName);
|
|
15
|
-
|
|
33
|
+
yield fs_extra_1.default.promises.mkdir(integrationPath, {
|
|
16
34
|
recursive: true,
|
|
17
35
|
});
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const inputsSouceCode = (0, integration_codegen_1.integrationInputsToCode)(integrationName, sharedInputs, inputSources);
|
|
22
|
-
await Promise.all([
|
|
23
|
-
(0, file_1.writeSourceToFile)(integrationPath, 'config', configCode),
|
|
24
|
-
(0, file_1.writeSourceToFile)(integrationPath, 'inputs', inputsSouceCode),
|
|
25
|
-
]);
|
|
26
|
-
const workflowMetas = integrationOutput.config.values.workflowMeta ?? {};
|
|
27
|
-
const workflows = Object.values(integrationOutput.workflows);
|
|
36
|
+
const configCode = (0, integration_codegen_1.integrationConfigToCode)(integrationOutput.config, integrationName);
|
|
37
|
+
yield writeSourceToFile(integrationPath, 'config', configCode);
|
|
38
|
+
const workflowOutputs = Object.values(integrationOutput.workflows);
|
|
28
39
|
const workflowPath = path_1.default.join(integrationPath, 'workflows');
|
|
29
|
-
if (
|
|
30
|
-
|
|
40
|
+
if (workflowOutputs.length) {
|
|
41
|
+
fs_extra_1.default.promises.mkdir(workflowPath, {
|
|
31
42
|
recursive: true,
|
|
32
43
|
});
|
|
33
44
|
}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
secrets,
|
|
38
|
-
eventIdToNameMap,
|
|
39
|
-
integration: { name: integrationName },
|
|
40
|
-
sharedInputs,
|
|
41
|
-
inputSources,
|
|
42
|
-
workflowMeta: workflowMetas[workflow.id] || {
|
|
43
|
-
id: workflow.id,
|
|
44
|
-
inputs: [],
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
await (0, file_1.writeSourceToFile)(workflowPath, generateUniqueNames(workflow.name), workflowCode);
|
|
45
|
+
for (const workflowOutput of workflowOutputs) {
|
|
46
|
+
const workflowCode = (0, workflow_codegen_1.workflowToCode)(workflowOutput, Object.assign(Object.assign({}, projectDependencies), { integration: { name: integrationName } }));
|
|
47
|
+
yield writeSourceToFile(workflowPath, workflowOutput.name, workflowCode);
|
|
48
48
|
}
|
|
49
|
-
};
|
|
49
|
+
});
|
|
50
50
|
exports.generateIntegrationFiles = generateIntegrationFiles;
|
|
51
|
-
const generateProjectFiles =
|
|
51
|
+
const generateProjectFiles = (projectBuild, projectRoot) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
yield fs_extra_1.default.promises.mkdir(projectRoot, { recursive: true });
|
|
52
53
|
const events = Object.values(projectBuild.events);
|
|
53
54
|
const eventPath = path_1.default.join(projectRoot, 'events');
|
|
54
55
|
if (events.length) {
|
|
55
|
-
|
|
56
|
+
yield fs_extra_1.default.promises.mkdir(eventPath, {
|
|
56
57
|
recursive: true,
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
|
-
const eventIdToNameMap = {};
|
|
60
|
-
const generateUniqueNames = (0, file_1.withUniqueFileNames)();
|
|
61
60
|
for (const event of events) {
|
|
62
|
-
const eventFileName = generateUniqueNames(event.name);
|
|
63
|
-
eventIdToNameMap[event.id] = eventFileName;
|
|
64
61
|
const eventSourceCode = (0, event_codegen_1.eventToCode)(event);
|
|
65
|
-
|
|
62
|
+
yield writeSourceToFile(eventPath, event.name, eventSourceCode);
|
|
66
63
|
}
|
|
67
|
-
await (0, file_1.writeSourceToFile)(projectRoot, 'persona.meta', (0, persona_codegen_1.personaToCode)(projectBuild.persona));
|
|
68
64
|
const integrationOutputs = Object.entries(projectBuild.integrations);
|
|
69
65
|
for (const [integrationName, integrationOutput] of integrationOutputs) {
|
|
70
|
-
|
|
71
|
-
eventIdToNameMap,
|
|
72
|
-
projectId: projectBuild.projectId,
|
|
73
|
-
secrets: projectBuild.secrets,
|
|
74
|
-
}, projectRoot);
|
|
66
|
+
yield (0, exports.generateIntegrationFiles)(integrationName, integrationOutput, { events: projectBuild.events }, projectRoot);
|
|
75
67
|
}
|
|
76
|
-
};
|
|
68
|
+
});
|
|
77
69
|
exports.generateProjectFiles = generateProjectFiles;
|
|
78
70
|
//# sourceMappingURL=codegen.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.utils.js","sourceRoot":"","sources":["../../src/codegen/codegen.utils.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,wDAAwB;
|
|
1
|
+
{"version":3,"file":"codegen.utils.js","sourceRoot":"","sources":["../../src/codegen/codegen.utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { OperatorCondition } from '@useparagon/core/resolvers';
|
|
2
|
-
|
|
3
|
-
export declare const conditionToCode: (operatorCondition: OperatorCondition, dependencies: StepDependencies) => string;
|
|
2
|
+
export declare const conditionToCode: (operatorCondition: OperatorCondition, stepIdToVariableMap: Record<string, string>) => string;
|
|
@@ -3,110 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.conditionToCode = void 0;
|
|
4
4
|
const resolvers_1 = require("@useparagon/core/resolvers");
|
|
5
5
|
const source_codegen_1 = require("./source.codegen");
|
|
6
|
-
const conditionToCode = (operatorCondition,
|
|
6
|
+
const conditionToCode = (operatorCondition, stepIdToVariableMap) => {
|
|
7
7
|
let code = '';
|
|
8
8
|
const condition = operatorCondition.condition;
|
|
9
|
-
const getOperatorParams = (argumentNeeded = false) => {
|
|
10
|
-
let parameters = (0, source_codegen_1.convertSourceToCode)(condition.variable, dependencies);
|
|
11
|
-
if (argumentNeeded && 'argument' in condition) {
|
|
12
|
-
parameters = `${parameters},${(0, source_codegen_1.convertSourceToCode)(condition.argument, dependencies)}`;
|
|
13
|
-
}
|
|
14
|
-
return parameters;
|
|
15
|
-
};
|
|
16
9
|
switch (condition.operator) {
|
|
17
|
-
case resolvers_1.Operator.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
case resolvers_1.Operator.ArrayIsIn:
|
|
21
|
-
code = `Operators.ArrayIsIn(${getOperatorParams(true)})`;
|
|
22
|
-
break;
|
|
23
|
-
case resolvers_1.Operator.ArrayIsNotEmpty:
|
|
24
|
-
code = `Operators.ArrayIsNotEmpty(${getOperatorParams()})`;
|
|
25
|
-
break;
|
|
26
|
-
case resolvers_1.Operator.ArrayIsNotIn:
|
|
27
|
-
code = `Operators.ArrayIsNotIn(${getOperatorParams(true)})`;
|
|
28
|
-
break;
|
|
29
|
-
case resolvers_1.Operator.BooleanFalse:
|
|
30
|
-
code = `Operators.BooleanFalse(${getOperatorParams()})`;
|
|
31
|
-
break;
|
|
32
|
-
case resolvers_1.Operator.BooleanTrue:
|
|
33
|
-
code = `Operators.BooleanTrue(${getOperatorParams()})`;
|
|
34
|
-
break;
|
|
35
|
-
case resolvers_1.Operator.DateTimeAfter:
|
|
36
|
-
code = `Operators.DateTimeAfter(${getOperatorParams(true)})`;
|
|
37
|
-
break;
|
|
38
|
-
case resolvers_1.Operator.DateTimeBefore:
|
|
39
|
-
code = `Operators.DateTimeBefore(${getOperatorParams(true)})`;
|
|
40
|
-
break;
|
|
41
|
-
case resolvers_1.Operator.DateTimeEquals:
|
|
42
|
-
code = `Operators.DateTimeEquals(${getOperatorParams(true)})`;
|
|
43
|
-
break;
|
|
44
|
-
case resolvers_1.Operator.DoesNotExist:
|
|
45
|
-
code = `Operators.DoesNotExist(${getOperatorParams()})`;
|
|
46
|
-
break;
|
|
47
|
-
case resolvers_1.Operator.Exists:
|
|
48
|
-
code = `Operators.Exists(${getOperatorParams()})`;
|
|
49
|
-
break;
|
|
50
|
-
case resolvers_1.Operator.IsNotNull:
|
|
51
|
-
code = `Operators.IsNotNull(${getOperatorParams()})`;
|
|
52
|
-
break;
|
|
53
|
-
case resolvers_1.Operator.IsNull:
|
|
54
|
-
code = `Operators.IsNull(${getOperatorParams()})`;
|
|
55
|
-
break;
|
|
56
|
-
case resolvers_1.Operator.NumberDoesNotEqual:
|
|
57
|
-
code = `Operators.NumberDoesNotEqual(${getOperatorParams(true)})`;
|
|
58
|
-
break;
|
|
59
|
-
case resolvers_1.Operator.NumberEquals:
|
|
60
|
-
code = `Operators.NumberEquals(${getOperatorParams(true)})`;
|
|
61
|
-
break;
|
|
62
|
-
case resolvers_1.Operator.NumberGreaterThan:
|
|
63
|
-
code = `Operators.NumberGreaterThan(${getOperatorParams(true)})`;
|
|
10
|
+
case resolvers_1.Operator.BooleanTrue: {
|
|
11
|
+
const variable = (0, source_codegen_1.convertSourceToCode)(condition.variable, stepIdToVariableMap);
|
|
12
|
+
code = `Operators.BooleanTrue(${variable})`;
|
|
64
13
|
break;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
code = `Operators.
|
|
70
|
-
break;
|
|
71
|
-
case resolvers_1.Operator.NumberLessThanOrEqualTo:
|
|
72
|
-
code = `Operators.NumberLessThanOrEqualTo(${getOperatorParams(true)})`;
|
|
73
|
-
break;
|
|
74
|
-
case resolvers_1.Operator.StringContains:
|
|
75
|
-
code = `Operators.StringContains(${getOperatorParams(true)})`;
|
|
76
|
-
break;
|
|
77
|
-
case resolvers_1.Operator.StringDoesNotContain:
|
|
78
|
-
code = `Operators.StringDoesNotContain(${getOperatorParams(true)})`;
|
|
79
|
-
break;
|
|
80
|
-
case resolvers_1.Operator.StringDoesNotEndWith:
|
|
81
|
-
code = `Operators.StringDoesNotEndWith(${getOperatorParams(true)})`;
|
|
82
|
-
break;
|
|
83
|
-
case resolvers_1.Operator.StringDoesNotExactlyMatch:
|
|
84
|
-
code = `Operators.StringDoesNotExactlyMatch(${getOperatorParams(true)})`;
|
|
85
|
-
break;
|
|
86
|
-
case resolvers_1.Operator.StringDoesNotStartWith:
|
|
87
|
-
code = `Operators.StringDoesNotStartWith(${getOperatorParams(true)})`;
|
|
88
|
-
break;
|
|
89
|
-
case resolvers_1.Operator.StringEndsWith:
|
|
90
|
-
code = `Operators.StringEndsWith(${getOperatorParams(true)})`;
|
|
91
|
-
break;
|
|
92
|
-
case resolvers_1.Operator.StringExactlyMatches:
|
|
93
|
-
code = `Operators.StringExactlyMatches(${getOperatorParams(true)})`;
|
|
94
|
-
break;
|
|
95
|
-
case resolvers_1.Operator.StringGreaterThan:
|
|
96
|
-
code = `Operators.StringContains(${getOperatorParams(true)})`;
|
|
97
|
-
break;
|
|
98
|
-
case resolvers_1.Operator.StringIsIn:
|
|
99
|
-
code = `Operators.StringIsIn(${getOperatorParams(true)})`;
|
|
100
|
-
break;
|
|
101
|
-
case resolvers_1.Operator.StringIsNotIn:
|
|
102
|
-
code = `Operators.StringIsNotIn(${getOperatorParams(true)})`;
|
|
103
|
-
break;
|
|
104
|
-
case resolvers_1.Operator.StringLessThan:
|
|
105
|
-
code = `Operators.StringLessThan(${getOperatorParams(true)})`;
|
|
106
|
-
break;
|
|
107
|
-
case resolvers_1.Operator.StringStartsWith:
|
|
108
|
-
code = `Operators.StringStartsWith(${getOperatorParams(true)})`;
|
|
14
|
+
}
|
|
15
|
+
case resolvers_1.Operator.StringContains: {
|
|
16
|
+
const variable = (0, source_codegen_1.convertSourceToCode)(condition.variable, stepIdToVariableMap);
|
|
17
|
+
const argument = (0, source_codegen_1.convertSourceToCode)(condition.argument, stepIdToVariableMap);
|
|
18
|
+
code = `Operators.StringContains(${variable},${argument})`;
|
|
109
19
|
break;
|
|
20
|
+
}
|
|
110
21
|
default:
|
|
111
22
|
code = 'undefined';
|
|
112
23
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/condition.codegen.ts"],"names":[],"mappings":";;;AAAA,0DAIoC;
|
|
1
|
+
{"version":3,"file":"condition.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/condition.codegen.ts"],"names":[],"mappings":";;;AAAA,0DAIoC;AAEpC,qDAAuD;AAOhD,MAAM,eAAe,GAAG,CAC7B,iBAAoC,EACpC,mBAA2C,EACnC,EAAE;IACV,IAAI,IAAI,GAAW,EAAE,CAAC;IAEtB,MAAM,SAAS,GAAc,iBAAiB,CAAC,SAAS,CAAC;IAEzD,QAAQ,SAAS,CAAC,QAAQ,EAAE;QAC1B,KAAK,oBAAQ,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM,QAAQ,GAAW,IAAA,oCAAmB,EAC1C,SAAS,CAAC,QAAQ,EAClB,mBAAmB,CACpB,CAAC;YACF,IAAI,GAAG,yBAAyB,QAAQ,GAAG,CAAC;YAC5C,MAAM;SACP;QAED,KAAK,oBAAQ,CAAC,cAAc,CAAC,CAAC;YAC5B,MAAM,QAAQ,GAAW,IAAA,oCAAmB,EAC1C,SAAS,CAAC,QAAQ,EAClB,mBAAmB,CACpB,CAAC;YACF,MAAM,QAAQ,GAAW,IAAA,oCAAmB,EAC1C,SAAS,CAAC,QAAQ,EAClB,mBAAmB,CACpB,CAAC;YACF,IAAI,GAAG,4BAA4B,QAAQ,IAAI,QAAQ,GAAG,CAAC;YAC3D,MAAM;SACP;QACD;YACE,IAAI,GAAG,WAAW,CAAC;YACnB,MAAM;KACT;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAnCW,QAAA,eAAe,mBAmC1B"}
|
|
@@ -2,23 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.eventToCode = void 0;
|
|
4
4
|
const json_1 = require("../../helpers/json");
|
|
5
|
-
const strings_1 = require("../../helpers/strings");
|
|
6
5
|
const eventToCode = (event) => {
|
|
7
6
|
const sourceCode = `
|
|
8
|
-
import {
|
|
7
|
+
import { IEvent } from '@useparagon/core/event';
|
|
9
8
|
|
|
10
|
-
export type EventSchema =
|
|
9
|
+
export type EventSchema = {
|
|
10
|
+
|
|
11
|
+
};
|
|
11
12
|
|
|
12
|
-
const event:
|
|
13
|
+
const event: IEvent<EventSchema> = {
|
|
14
|
+
/**
|
|
15
|
+
* This property is maintained by Paragon. Do not edit this property.
|
|
16
|
+
*/
|
|
17
|
+
id: '${event.id}',
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* name of event
|
|
15
21
|
*/
|
|
16
|
-
name : ${
|
|
22
|
+
name : '${event.name}',
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
25
|
* schema of event payload
|
|
20
26
|
*/
|
|
21
|
-
schema
|
|
27
|
+
schema:${(0, json_1.stringifyObject)(event.schema)}
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export default event;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/event.codegen.ts"],"names":[],"mappings":";;;AAEA,6CAAqD;
|
|
1
|
+
{"version":3,"file":"event.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/event.codegen.ts"],"names":[],"mappings":";;;AAEA,6CAAqD;AAO9C,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE;IACnD,MAAM,UAAU,GAAW;;;;;;;;;;;UAWnB,KAAK,CAAC,EAAE;;;;;aAKL,KAAK,CAAC,IAAI;;;;;YAKX,IAAA,sBAAe,EAAC,KAAK,CAAC,MAAM,CAAC;;;;EAIvC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AA7BW,QAAA,WAAW,eA6BtB"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const integrationToConfigCode: (integration: IntegrationBuild, integrationName: string) => string;
|
|
4
|
-
export declare const integrationInputsToCode: (integrationName: string, inputs: SerializedInput[], inputSources: InputSource[]) => string;
|
|
5
|
-
export declare const typesForIntegration: (integration: string, dependencies: IntegrationDependencies) => string;
|
|
1
|
+
import { IntegrationOutput } from '../../compilers/compiler.types';
|
|
2
|
+
export declare const integrationConfigToCode: (config: IntegrationOutput['config'], integrationName: string) => string;
|
|
@@ -1,245 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const inputs_1 = require("@useparagon/core/inputs");
|
|
5
|
-
const utils_1 = require("@useparagon/core/utils");
|
|
6
|
-
const request_1 = require("@useparagon/core/steps/library/request");
|
|
7
|
-
const core_1 = require("@useparagon/core");
|
|
8
|
-
const integration_1 = require("@useparagon/core/integration");
|
|
3
|
+
exports.integrationConfigToCode = void 0;
|
|
9
4
|
const json_1 = require("../../helpers/json");
|
|
10
|
-
const
|
|
11
|
-
const source_codegen_1 = require("./source.codegen");
|
|
12
|
-
const integrationToConfigCode = (integration, integrationName) => {
|
|
13
|
-
const customIntegration = integration.customIntegration;
|
|
14
|
-
const config = integration.config;
|
|
15
|
-
if (!customIntegration) {
|
|
16
|
-
const sourceCode = `
|
|
17
|
-
import { IIntegrationConfig } from '@useparagon/core/integration';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* configuration for a ${integrationName}
|
|
21
|
-
*/
|
|
22
|
-
const config: IIntegrationConfig = ${(0, json_1.stringifyObject)({
|
|
23
|
-
description: config.values.description ||
|
|
24
|
-
`A description for the integration's purpose.`,
|
|
25
|
-
overviewText: config.values.overview ||
|
|
26
|
-
`A long-form description for the integration's purpose.`,
|
|
27
|
-
showWatermark: config.values.paragonLink || true,
|
|
28
|
-
})}
|
|
29
|
-
|
|
30
|
-
export default config;`;
|
|
31
|
-
return sourceCode;
|
|
32
|
-
}
|
|
33
|
-
const dependencies = {
|
|
34
|
-
inputs: customIntegration.inputFields
|
|
35
|
-
};
|
|
36
|
-
const authorizationConfigToCode = () => {
|
|
37
|
-
switch (customIntegration.apiAuthorization?.type) {
|
|
38
|
-
case request_1.RequestAuthorizationType.BASIC:
|
|
39
|
-
const userName = customIntegration.apiAuthorization.username || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
40
|
-
const password = customIntegration.apiAuthorization.password || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
41
|
-
return `authorization: {
|
|
42
|
-
type: '${request_1.RequestAuthorizationType.BASIC}',
|
|
43
|
-
userName: ${(0, source_codegen_1.convertSourceToCode)(userName, dependencies)},
|
|
44
|
-
password: ${(0, source_codegen_1.convertSourceToCode)(password, dependencies)},
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
case request_1.RequestAuthorizationType.BEARER_TOKEN:
|
|
48
|
-
const token = customIntegration.apiAuthorization.token || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
49
|
-
return `authorization: {
|
|
50
|
-
type: '${request_1.RequestAuthorizationType.BEARER_TOKEN}',
|
|
51
|
-
token: ${(0, source_codegen_1.convertSourceToCode)(token, dependencies)},
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
case request_1.RequestAuthorizationType.QUERY_PARAMS:
|
|
55
|
-
const params = customIntegration.apiAuthorization.params || [];
|
|
56
|
-
return `authorization: {
|
|
57
|
-
type: '${request_1.RequestAuthorizationType.QUERY_PARAMS}',
|
|
58
|
-
params: ${(0, source_codegen_1.covertKeyedSourceParamsToCode)(params, dependencies)}
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
61
|
-
case request_1.RequestAuthorizationType.AUTH_HEADER:
|
|
62
|
-
const headers = customIntegration.apiAuthorization.headers || [];
|
|
63
|
-
return `authorization: {
|
|
64
|
-
type: '${request_1.RequestAuthorizationType.AUTH_HEADER}',
|
|
65
|
-
headers: ${(0, source_codegen_1.covertKeyedSourceParamsToCode)(headers, dependencies)}
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
case request_1.RequestAuthorizationType.CLIENT_CREDENTIAL:
|
|
69
|
-
return `authorization: {
|
|
70
|
-
type: '${request_1.RequestAuthorizationType.CLIENT_CREDENTIAL}',
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
default:
|
|
74
|
-
return '';
|
|
75
|
-
}
|
|
76
|
-
};
|
|
5
|
+
const integrationConfigToCode = (config, integrationName) => {
|
|
77
6
|
const sourceCode = `
|
|
78
|
-
import {
|
|
7
|
+
import { IIntegrationConfig } from '@useparagon/core';
|
|
79
8
|
|
|
80
9
|
/**
|
|
81
|
-
*
|
|
10
|
+
* configuration for a ${integrationName}
|
|
82
11
|
*/
|
|
83
|
-
|
|
12
|
+
const config: IIntegrationConfig = ${(0, json_1.stringifyObject)(config || {})}
|
|
84
13
|
|
|
85
|
-
/**
|
|
86
|
-
* custom integration config
|
|
87
|
-
*/
|
|
88
|
-
const config :ICustomIntegrationConfig ={
|
|
89
|
-
name: ${(0, strings_1.sanitizeString)(customIntegration.name)},
|
|
90
|
-
description: ${(0, strings_1.sanitizeString)(config.values.description || '')},
|
|
91
|
-
accentColor: ${(0, strings_1.sanitizeString)(config.values.accentColor || '')},
|
|
92
|
-
${(() => {
|
|
93
|
-
switch (customIntegration.authenticationType) {
|
|
94
|
-
case core_1.AuthenticationScheme.OAUTH_CLIENT_CREDENTIAL:
|
|
95
|
-
const oauthAccessTokenUrl = customIntegration.oauthAccessTokenUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
96
|
-
return `authenticationType: '${core_1.AuthenticationScheme.OAUTH_CLIENT_CREDENTIAL}',
|
|
97
|
-
accessTokenUrl:${(0, source_codegen_1.convertSourceToCode)(oauthAccessTokenUrl, dependencies)}
|
|
98
|
-
`;
|
|
99
|
-
case core_1.AuthenticationScheme.OAUTH:
|
|
100
|
-
const authorizationUrl = customIntegration.oauthAuthorizationUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
101
|
-
const accesstokenUrl = customIntegration.oauthAccessTokenUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
102
|
-
return `authenticationType: '${core_1.AuthenticationScheme.OAUTH}',
|
|
103
|
-
authorizationUrl: ${(0, source_codegen_1.convertSourceToCode)(authorizationUrl, dependencies)},
|
|
104
|
-
accessTokenUrl: ${(0, source_codegen_1.convertSourceToCode)(accesstokenUrl, dependencies)},
|
|
105
|
-
scopes: ${(0, strings_1.sanitizeString)(customIntegration.oauthScopes || '')},
|
|
106
|
-
includeClientIdAndSecrets: ${customIntegration.oauthIncludeClientAuthorizationHeader ?? true},
|
|
107
|
-
usePKCEInCodeExchange: ${customIntegration.usePKCEInCodeExchange ?? false}
|
|
108
|
-
`;
|
|
109
|
-
case core_1.AuthenticationScheme.BASIC:
|
|
110
|
-
const apiBaseUrl = customIntegration.apiBaseUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
111
|
-
const testEndpointPath = customIntegration.testEndpointPath || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
112
|
-
return `authenticationType: '${core_1.AuthenticationScheme.BASIC}',
|
|
113
|
-
apiBaseUrl: ${(0, source_codegen_1.convertSourceToCode)(apiBaseUrl, dependencies)},
|
|
114
|
-
testEndpointPath: ${(0, source_codegen_1.convertSourceToCode)(testEndpointPath, dependencies)},
|
|
115
|
-
${authorizationConfigToCode()}
|
|
116
|
-
`;
|
|
117
|
-
default:
|
|
118
|
-
return '';
|
|
119
|
-
}
|
|
120
|
-
})()}};
|
|
121
14
|
export default config;`;
|
|
122
15
|
return sourceCode;
|
|
123
16
|
};
|
|
124
|
-
exports.
|
|
125
|
-
const integrationInputsToCode = (integrationName, inputs, inputSources) => {
|
|
126
|
-
const sourceCode = `
|
|
127
|
-
${integrationName.startsWith('custom')
|
|
128
|
-
? "import { createInputs } from '@useparagon/core/inputs';"
|
|
129
|
-
: `import { createInputs } from '@useparagon/types/${integrationName}';`}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* define inputs here which can be used across workflows
|
|
133
|
-
*/
|
|
134
|
-
const integrationInputs = createInputs(${(0, json_1.stringifyObject)((0, inputs_1.mapUserDefinedInputsWithTitle)((0, inputs_1.convertSerializedInputsToUserDefinedInputs)(inputs, inputSources)))});
|
|
135
|
-
|
|
136
|
-
export default integrationInputs;
|
|
137
|
-
`;
|
|
138
|
-
return sourceCode;
|
|
139
|
-
};
|
|
140
|
-
exports.integrationInputsToCode = integrationInputsToCode;
|
|
141
|
-
const typesForIntegration = (integration, dependencies) => {
|
|
142
|
-
const { inputs, intents, triggers } = dependencies;
|
|
143
|
-
const supportedInputTypes = Object.keys(inputs_1.BASIC_INPUT_NAME_TO_INPUT_TYPE_MAP).concat(inputs.map(inputs_1.getInputTypeForUI));
|
|
144
|
-
const integratonInterfaceName = (0, utils_1.toPascalCase)(`I ${integration}Integration`);
|
|
145
|
-
const sourceCode = `
|
|
146
|
-
/**
|
|
147
|
-
* ############### WARNING ######################
|
|
148
|
-
* ##### DO NOT DELETE/RENAME THIS FILE ########
|
|
149
|
-
* ##### DO NOT UPDATE THIS FILE CONTENT ########
|
|
150
|
-
* ############### WARNING ######################
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
import { IIntegration } from '@useparagon/core';
|
|
154
|
-
import { UserDefinedInput } from '@useparagon/core/inputs';
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* supported input names
|
|
158
|
-
*/
|
|
159
|
-
export type InputType = ${supportedInputTypes
|
|
160
|
-
.map((inputType) => [`'${inputType}'`])
|
|
161
|
-
.join(' | ')};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* map b/w input type to result
|
|
165
|
-
*/
|
|
166
|
-
export type InputResultMap = {
|
|
167
|
-
'email' : string;
|
|
168
|
-
'url' : string;
|
|
169
|
-
'password' : string;
|
|
170
|
-
'boolean' : boolean;
|
|
171
|
-
'text' : string;
|
|
172
|
-
'number' : number;
|
|
173
|
-
${inputs
|
|
174
|
-
.map((source) => {
|
|
175
|
-
let result = 'string';
|
|
176
|
-
if (source.type === 'COMBO_INPUT_DATA_SOURCE') {
|
|
177
|
-
result = `
|
|
178
|
-
{
|
|
179
|
-
'${(0, inputs_1.getInputTypeForUI)(source.mainInputSource)}' : string;
|
|
180
|
-
'${(0, inputs_1.getInputTypeForUI)(source.dependentInputSource)}' : string;
|
|
181
|
-
}
|
|
182
|
-
`;
|
|
183
|
-
}
|
|
184
|
-
else if (source.type === 'FIELD_MAPPER_DATA_SOURCE') {
|
|
185
|
-
result = `
|
|
186
|
-
{
|
|
187
|
-
'${(0, inputs_1.getInputTypeForUI)(source.recordSource)}' : string;
|
|
188
|
-
'${(0, inputs_1.getInputTypeForUI)(source.fieldSource)}' : string;
|
|
189
|
-
}
|
|
190
|
-
`;
|
|
191
|
-
}
|
|
192
|
-
return [`'${(0, inputs_1.getInputTypeForUI)(source)}'`, result].join(' : ');
|
|
193
|
-
})
|
|
194
|
-
.join(';')}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* pass { variableName for input => Input }
|
|
199
|
-
* this should be used whenever we are creating inputs for integrations/workflows
|
|
200
|
-
* as it will infer proper types
|
|
201
|
-
*/
|
|
202
|
-
export declare const createInputs: <T extends Record<string, UserDefinedInput<InputType>>>(inputs: T) => T;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* map bw intent to [input , output]
|
|
206
|
-
*/
|
|
207
|
-
export type IntentToInputOutput = {
|
|
208
|
-
|
|
209
|
-
${intents
|
|
210
|
-
.map((intent) => `
|
|
211
|
-
/**
|
|
212
|
-
* ${intent.title}
|
|
213
|
-
*/
|
|
214
|
-
${intent.name}:[any, any]
|
|
215
|
-
`)
|
|
216
|
-
.join(';')}
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* map bw trigger intent to [input , output]
|
|
222
|
-
*/
|
|
223
|
-
export type TriggerIntentToInputOutput = {
|
|
224
|
-
${triggers
|
|
225
|
-
.map((intent) => `
|
|
226
|
-
/**
|
|
227
|
-
* ${intent.title}
|
|
228
|
-
*/
|
|
229
|
-
${intent.name}:[any, any]
|
|
230
|
-
`)
|
|
231
|
-
.join(';')}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* integration type for ${integration}
|
|
236
|
-
*/
|
|
237
|
-
export type ${integratonInterfaceName} = IIntegration<
|
|
238
|
-
IntentToInputOutput,
|
|
239
|
-
TriggerIntentToInputOutput
|
|
240
|
-
>;
|
|
241
|
-
`;
|
|
242
|
-
return sourceCode;
|
|
243
|
-
};
|
|
244
|
-
exports.typesForIntegration = typesForIntegration;
|
|
17
|
+
exports.integrationConfigToCode = integrationConfigToCode;
|
|
245
18
|
//# sourceMappingURL=integration.codegen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/integration.codegen.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"integration.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/integration.codegen.ts"],"names":[],"mappings":";;;AACA,6CAAqD;AAM9C,MAAM,uBAAuB,GAAG,CACrC,MAAmC,EACnC,eAAuB,EACf,EAAE;IACV,MAAM,UAAU,GAAW;;;;6BAIA,eAAe;;yCAEH,IAAA,sBAAe,EAAC,MAAM,IAAI,EAAE,CAAC;;2BAE3C,CAAC;IAE1B,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC"}
|