@useparagon/cli 0.0.1-canary.3 → 0.0.1-canary.30
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/apis/api.types.d.ts +87 -0
- package/dist/apis/api.types.js +3 -0
- package/dist/apis/api.types.js.map +1 -0
- package/dist/apis/auth.api.d.ts +5 -0
- package/dist/apis/auth.api.js +14 -0
- package/dist/apis/auth.api.js.map +1 -0
- package/dist/apis/base.api.d.ts +10 -0
- package/dist/apis/base.api.js +90 -0
- package/dist/apis/base.api.js.map +1 -0
- package/dist/apis/index.d.ts +4 -0
- package/dist/apis/index.js +8 -0
- package/dist/apis/index.js.map +1 -0
- package/dist/apis/integration.api.d.ts +3 -0
- package/dist/apis/integration.api.js +28 -0
- package/dist/apis/integration.api.js.map +1 -0
- package/dist/apis/project.api.d.ts +7 -0
- package/dist/apis/project.api.js +41 -0
- package/dist/apis/project.api.js.map +1 -0
- package/dist/codegen/codegen.types.d.ts +19 -2
- package/dist/codegen/codegen.utils.d.ts +4 -4
- package/dist/codegen/codegen.utils.js +47 -39
- package/dist/codegen/codegen.utils.js.map +1 -1
- package/dist/codegen/codegens/condition.codegen.d.ts +2 -1
- package/dist/codegen/codegens/condition.codegen.js +99 -10
- package/dist/codegen/codegens/condition.codegen.js.map +1 -1
- package/dist/codegen/codegens/event.codegen.js +6 -12
- package/dist/codegen/codegens/event.codegen.js.map +1 -1
- package/dist/codegen/codegens/integration.codegen.d.ts +5 -2
- package/dist/codegen/codegens/integration.codegen.js +233 -6
- package/dist/codegen/codegens/integration.codegen.js.map +1 -1
- package/dist/codegen/codegens/persona.codegen.d.ts +2 -0
- package/dist/codegen/codegens/persona.codegen.js +12 -0
- package/dist/codegen/codegens/persona.codegen.js.map +1 -0
- package/dist/codegen/codegens/source.codegen.d.ts +7 -4
- package/dist/codegen/codegens/source.codegen.js +202 -27
- 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 +239 -117
- package/dist/codegen/codegens/workflow.codegen.js.map +1 -1
- package/dist/commands/{login/login.command.d.ts → auth/auth.command.d.ts} +1 -1
- package/dist/commands/auth/auth.command.js +18 -0
- package/dist/commands/auth/auth.command.js.map +1 -0
- package/dist/commands/auth/index.d.ts +1 -0
- package/dist/commands/auth/index.js +5 -0
- package/dist/commands/auth/index.js.map +1 -0
- package/dist/commands/auth/login/index.js.map +1 -0
- package/dist/commands/auth/login/login.action.d.ts +5 -0
- package/dist/commands/auth/login/login.action.js +42 -0
- package/dist/commands/auth/login/login.action.js.map +1 -0
- package/dist/commands/auth/login/login.command.d.ts +8 -0
- package/dist/commands/auth/login/login.command.js +25 -0
- package/dist/commands/auth/login/login.command.js.map +1 -0
- package/dist/commands/auth/login/login.types.d.ts +9 -0
- package/dist/commands/auth/login/login.types.js.map +1 -0
- package/dist/commands/auth/login/login.utils.d.ts +2 -0
- package/dist/commands/auth/login/login.utils.js +93 -0
- package/dist/commands/auth/login/login.utils.js.map +1 -0
- package/dist/commands/auth/logout/index.d.ts +1 -0
- package/dist/commands/auth/logout/index.js +5 -0
- package/dist/commands/auth/logout/index.js.map +1 -0
- package/dist/commands/auth/logout/logout.action.d.ts +5 -0
- package/dist/commands/auth/logout/logout.action.js +14 -0
- package/dist/commands/auth/logout/logout.action.js.map +1 -0
- package/dist/commands/auth/logout/logout.command.d.ts +8 -0
- package/dist/commands/auth/logout/logout.command.js +24 -0
- package/dist/commands/auth/logout/logout.command.js.map +1 -0
- package/dist/commands/auth/logout/logout.types.d.ts +1 -0
- package/dist/commands/auth/logout/logout.types.js +3 -0
- package/dist/commands/auth/logout/logout.types.js.map +1 -0
- package/dist/commands/auth/me/index.d.ts +1 -0
- package/dist/commands/auth/me/index.js +5 -0
- package/dist/commands/auth/me/index.js.map +1 -0
- package/dist/commands/auth/me/me.action.d.ts +5 -0
- package/dist/commands/auth/me/me.action.js +26 -0
- package/dist/commands/auth/me/me.action.js.map +1 -0
- package/dist/commands/auth/me/me.command.d.ts +8 -0
- package/dist/commands/auth/me/me.command.js +24 -0
- package/dist/commands/auth/me/me.command.js.map +1 -0
- package/dist/commands/auth/me/me.types.d.ts +1 -0
- package/dist/commands/auth/me/me.types.js +3 -0
- package/dist/commands/auth/me/me.types.js.map +1 -0
- package/dist/commands/build/build.action.d.ts +2 -2
- package/dist/commands/build/build.action.js +32 -33
- package/dist/commands/build/build.action.js.map +1 -1
- package/dist/commands/build/build.command.js +9 -7
- 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 +12 -9
- package/dist/commands/build/build.utils.js.map +1 -1
- package/dist/commands/command.loader.js +13 -9
- 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 +87 -69
- package/dist/commands/init/init.action.js.map +1 -1
- package/dist/commands/init/init.command.js +13 -7
- package/dist/commands/init/init.command.js.map +1 -1
- package/dist/commands/install/index.d.ts +1 -0
- package/dist/commands/install/index.js +5 -0
- package/dist/commands/install/index.js.map +1 -0
- package/dist/commands/install/install.action.d.ts +5 -0
- package/dist/commands/install/install.action.js +15 -0
- package/dist/commands/install/install.action.js.map +1 -0
- package/dist/commands/install/install.command.d.ts +8 -0
- package/dist/commands/install/install.command.js +24 -0
- package/dist/commands/install/install.command.js.map +1 -0
- package/dist/commands/install/install.constants.js +68 -0
- package/dist/commands/install/install.constants.js.map +1 -0
- package/dist/commands/install/install.types.d.ts +7 -0
- package/dist/commands/install/install.types.js +3 -0
- package/dist/commands/install/install.types.js.map +1 -0
- package/dist/commands/install/install.utils.d.ts +8 -0
- package/dist/commands/install/install.utils.js +125 -0
- package/dist/commands/install/install.utils.js.map +1 -0
- package/dist/commands/new/index.d.ts +1 -0
- package/dist/commands/new/index.js +5 -0
- package/dist/commands/new/index.js.map +1 -0
- package/dist/commands/new/integration/index.d.ts +1 -0
- package/dist/commands/new/integration/index.js +5 -0
- package/dist/commands/new/integration/index.js.map +1 -0
- package/dist/commands/new/integration/integration.action.d.ts +5 -0
- package/dist/commands/new/integration/integration.action.js +52 -0
- package/dist/commands/new/integration/integration.action.js.map +1 -0
- package/dist/commands/new/integration/integration.command.d.ts +8 -0
- package/dist/commands/new/integration/integration.command.js +26 -0
- package/dist/commands/new/integration/integration.command.js.map +1 -0
- package/dist/commands/new/integration/integration.types.d.ts +1 -0
- package/dist/commands/new/integration/integration.types.js +3 -0
- package/dist/commands/new/integration/integration.types.js.map +1 -0
- package/dist/commands/new/new.command.d.ts +5 -0
- package/dist/commands/new/new.command.js +16 -0
- package/dist/commands/new/new.command.js.map +1 -0
- package/dist/commands/new/new.utils.d.ts +1 -0
- package/dist/commands/new/new.utils.js +18 -0
- package/dist/commands/new/new.utils.js.map +1 -0
- package/dist/commands/new/workflow/index.d.ts +1 -0
- package/dist/commands/new/workflow/index.js +5 -0
- package/dist/commands/new/workflow/index.js.map +1 -0
- package/dist/commands/new/workflow/workflow.action.d.ts +5 -0
- package/dist/commands/new/workflow/workflow.action.js +94 -0
- package/dist/commands/new/workflow/workflow.action.js.map +1 -0
- package/dist/commands/new/workflow/workflow.command.d.ts +8 -0
- package/dist/commands/new/workflow/workflow.command.js +25 -0
- package/dist/commands/new/workflow/workflow.command.js.map +1 -0
- package/dist/commands/new/workflow/workflow.types.d.ts +3 -0
- package/dist/commands/new/workflow/workflow.types.js +3 -0
- package/dist/commands/new/workflow/workflow.types.js.map +1 -0
- package/dist/commands/push/index.d.ts +1 -0
- package/dist/commands/push/index.js +5 -0
- package/dist/commands/push/index.js.map +1 -0
- package/dist/commands/push/push.action.d.ts +5 -0
- package/dist/commands/push/push.action.js +22 -0
- package/dist/commands/push/push.action.js.map +1 -0
- package/dist/commands/push/push.command.d.ts +8 -0
- package/dist/commands/push/push.command.js +26 -0
- package/dist/commands/push/push.command.js.map +1 -0
- package/dist/commands/push/push.types.d.ts +1 -0
- package/dist/commands/push/push.types.js +3 -0
- package/dist/commands/push/push.types.js.map +1 -0
- package/dist/compiler/compiler.interface.d.ts +3 -0
- package/dist/compiler/compiler.interface.js.map +1 -0
- package/dist/compiler/compiler.types.d.ts +11 -0
- package/dist/compiler/compiler.types.js.map +1 -0
- package/dist/compiler/compiler.utils.d.ts +2 -0
- package/dist/{compilers → compiler}/compiler.utils.js +9 -6
- package/dist/compiler/compiler.utils.js.map +1 -0
- package/dist/compiler/compilers/events.compiler.d.ts +10 -0
- package/dist/compiler/compilers/events.compiler.js +39 -0
- package/dist/compiler/compilers/events.compiler.js.map +1 -0
- package/dist/compiler/compilers/integrations.compiler.d.ts +17 -0
- package/dist/compiler/compilers/integrations.compiler.js +169 -0
- package/dist/compiler/compilers/integrations.compiler.js.map +1 -0
- package/dist/compiler/compilers/persona.compiler.d.ts +9 -0
- package/dist/compiler/compilers/persona.compiler.js +15 -0
- package/dist/compiler/compilers/persona.compiler.js.map +1 -0
- package/dist/compiler/compilers/project.compiler.d.ts +15 -0
- package/dist/compiler/compilers/project.compiler.js +68 -0
- package/dist/compiler/compilers/project.compiler.js.map +1 -0
- package/dist/compiler/compilers/workflows.compiler.d.ts +24 -0
- package/dist/compiler/compilers/workflows.compiler.js +64 -0
- package/dist/compiler/compilers/workflows.compiler.js.map +1 -0
- package/dist/{compilers → compiler}/ts.compiler.d.ts +1 -3
- package/dist/{compilers → compiler}/ts.compiler.js +12 -18
- package/dist/compiler/ts.compiler.js.map +1 -0
- package/dist/config/config.constants.d.ts +1 -2
- package/dist/config/config.constants.js +4 -6
- package/dist/config/config.constants.js.map +1 -1
- package/dist/config/config.types.d.ts +14 -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 +10 -9
- package/dist/config/config.utils.js +111 -123
- package/dist/config/config.utils.js.map +1 -1
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/helpers/file.d.ts +3 -0
- package/dist/helpers/file.js +54 -0
- package/dist/helpers/file.js.map +1 -0
- package/dist/helpers/http.d.ts +1 -0
- package/dist/helpers/http.js +11 -0
- package/dist/helpers/http.js.map +1 -0
- package/dist/helpers/strings.d.ts +2 -0
- package/dist/helpers/strings.js +35 -1
- package/dist/helpers/strings.js.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/logger/logger.js +44 -3
- package/dist/logger/logger.js.map +1 -1
- package/dist/logger/logger.type.d.ts +3 -1
- package/dist/templates/configurations/javascript/.prettierrc +4 -0
- package/dist/templates/configurations/typescript/.prettierrc +4 -0
- package/dist/templates/{typescript → configurations/typescript}/tsconfig.json +7 -4
- package/package.json +25 -19
- package/dist/commands/init/init.constants.js +0 -21
- package/dist/commands/init/init.constants.js.map +0 -1
- package/dist/commands/init/init.utils.d.ts +0 -11
- package/dist/commands/init/init.utils.js +0 -50
- package/dist/commands/init/init.utils.js.map +0 -1
- package/dist/commands/login/index.js.map +0 -1
- package/dist/commands/login/login.command.js +0 -26
- package/dist/commands/login/login.command.js.map +0 -1
- package/dist/commands/login/login.types.d.ts +0 -3
- package/dist/commands/login/login.types.js.map +0 -1
- package/dist/commands/login/login.utils.d.ts +0 -2
- package/dist/commands/login/login.utils.js +0 -47
- package/dist/commands/login/login.utils.js.map +0 -1
- package/dist/compilers/compiler.interface.d.ts +0 -3
- package/dist/compilers/compiler.interface.js.map +0 -1
- package/dist/compilers/compiler.types.d.ts +0 -23
- package/dist/compilers/compiler.types.js.map +0 -1
- package/dist/compilers/compiler.utils.d.ts +0 -2
- package/dist/compilers/compiler.utils.js.map +0 -1
- package/dist/compilers/event.compiler.d.ts +0 -7
- package/dist/compilers/event.compiler.js +0 -25
- package/dist/compilers/event.compiler.js.map +0 -1
- package/dist/compilers/integration.compiler.d.ts +0 -9
- package/dist/compilers/integration.compiler.js +0 -55
- package/dist/compilers/integration.compiler.js.map +0 -1
- package/dist/compilers/project.compiler.d.ts +0 -10
- package/dist/compilers/project.compiler.js +0 -50
- package/dist/compilers/project.compiler.js.map +0 -1
- package/dist/compilers/ts.compiler.js.map +0 -1
- package/dist/compilers/workflow.compiler.d.ts +0 -10
- package/dist/compilers/workflow.compiler.js +0 -36
- package/dist/compilers/workflow.compiler.js.map +0 -1
- package/dist/templates/javascript/src/events/hello-world.js +0 -13
- package/dist/templates/javascript/src/integrations/slack/config.js +0 -11
- package/dist/templates/javascript/src/integrations/slack/workflows/example-workflow.js +0 -30
- package/dist/templates/typescript/src/events/hello-world.ts +0 -21
- package/dist/templates/typescript/src/integrations/slack/config.ts +0 -18
- package/dist/templates/typescript/src/integrations/slack/workflows/example-workflow.ts +0 -30
- /package/dist/commands/{login → auth/login}/index.d.ts +0 -0
- /package/dist/commands/{login → auth/login}/index.js +0 -0
- /package/dist/commands/{login → auth/login}/login.types.js +0 -0
- /package/dist/commands/{init/init.constants.d.ts → install/install.constants.d.ts} +0 -0
- /package/dist/{compilers → compiler}/compiler.interface.js +0 -0
- /package/dist/{compilers → compiler}/compiler.types.js +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AuthenticationScheme, IStep } from '@useparagon/core';
|
|
2
|
+
import { IEvent } from '@useparagon/core/event';
|
|
3
|
+
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
|
|
4
|
+
import { IPersona } from '@useparagon/core/persona';
|
|
5
|
+
import { DataType, OrConditions, TokenizedSource } from '@useparagon/core/resolvers';
|
|
6
|
+
import { ISecret } from '@useparagon/core/secret';
|
|
7
|
+
import { RequestAuthorization } from '@useparagon/core/steps/library/request';
|
|
8
|
+
export type IntegrationIntent = {
|
|
9
|
+
name: string;
|
|
10
|
+
title: string;
|
|
11
|
+
inputs: any[];
|
|
12
|
+
output: any[];
|
|
13
|
+
};
|
|
14
|
+
export type IntegrationDependencies = {
|
|
15
|
+
inputs: InputSource[];
|
|
16
|
+
intents: IntegrationIntent[];
|
|
17
|
+
triggers: IntegrationIntent[];
|
|
18
|
+
};
|
|
19
|
+
export type IntegrationWorkflowMeta = {
|
|
20
|
+
id: string;
|
|
21
|
+
infoText?: string;
|
|
22
|
+
defaultEnabled?: boolean;
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
order?: number;
|
|
25
|
+
inputs: SerializedInput[];
|
|
26
|
+
permissions?: OrConditions;
|
|
27
|
+
};
|
|
28
|
+
export type WorkflowMeta = {
|
|
29
|
+
[id: string]: IntegrationWorkflowMeta;
|
|
30
|
+
};
|
|
31
|
+
export type ModalConfig = {
|
|
32
|
+
accentColor?: string;
|
|
33
|
+
paragonLink?: boolean;
|
|
34
|
+
description?: string;
|
|
35
|
+
overview?: string;
|
|
36
|
+
workflowMeta?: WorkflowMeta;
|
|
37
|
+
sharedMeta?: {
|
|
38
|
+
inputs?: SerializedInput[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export interface ICustomIntegration {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
authenticationType?: AuthenticationScheme;
|
|
45
|
+
inputFields: SerializedInput[];
|
|
46
|
+
oauthAuthorizationUrl?: TokenizedSource<DataType.STRING>;
|
|
47
|
+
oauthAccessTokenUrl?: TokenizedSource<DataType.STRING>;
|
|
48
|
+
oauthScopes?: string;
|
|
49
|
+
oauthIncludeClientAuthorizationHeader?: boolean;
|
|
50
|
+
usePKCEInCodeExchange?: boolean;
|
|
51
|
+
apiBaseUrl?: TokenizedSource<DataType.STRING>;
|
|
52
|
+
testEndpointPath?: TokenizedSource<DataType.STRING>;
|
|
53
|
+
apiAuthorization?: RequestAuthorization;
|
|
54
|
+
isPublished?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface WorkflowBuild {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
steps: IStep[];
|
|
60
|
+
}
|
|
61
|
+
export interface IntegrationBuild {
|
|
62
|
+
id: string;
|
|
63
|
+
config: {
|
|
64
|
+
values: ModalConfig;
|
|
65
|
+
};
|
|
66
|
+
workflows: Record<string, WorkflowBuild | undefined>;
|
|
67
|
+
dependencies?: IntegrationDependencies;
|
|
68
|
+
customIntegration?: ICustomIntegration;
|
|
69
|
+
}
|
|
70
|
+
export interface ProjectBuild {
|
|
71
|
+
projectId: string;
|
|
72
|
+
projectName?: string;
|
|
73
|
+
events: Record<string, IEvent>;
|
|
74
|
+
persona: IPersona;
|
|
75
|
+
integrations: Record<string, IntegrationBuild | undefined>;
|
|
76
|
+
secrets: ISecret[];
|
|
77
|
+
}
|
|
78
|
+
export type IUser = {
|
|
79
|
+
firstName: string;
|
|
80
|
+
middleName: string;
|
|
81
|
+
lastName: string;
|
|
82
|
+
email: string;
|
|
83
|
+
};
|
|
84
|
+
export type IntegrationMetadata = {
|
|
85
|
+
name: string;
|
|
86
|
+
title: string;
|
|
87
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.types.js","sourceRoot":"","sources":["../../src/apis/api.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMe = void 0;
|
|
4
|
+
const base_api_1 = require("./base.api");
|
|
5
|
+
const getMe = async (overrideConfig) => {
|
|
6
|
+
try {
|
|
7
|
+
return await (0, base_api_1.get)('graphite/auth/me', overrideConfig);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
return (0, base_api_1.logApiError)('Failed to get user.', error);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.getMe = getMe;
|
|
14
|
+
//# sourceMappingURL=auth.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.api.js","sourceRoot":"","sources":["../../src/apis/auth.api.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAOvC,MAAM,KAAK,GAAG,KAAK,EAAE,cAG3B,EAAkB,EAAE;IACnB,IAAI,CAAC;QACH,OAAO,MAAM,IAAA,cAAG,EAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,sBAAW,EAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC;AATW,QAAA,KAAK,SAShB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IProfile } from '../config';
|
|
2
|
+
export declare const getProfile: () => Promise<IProfile>;
|
|
3
|
+
export declare const getToken: () => Promise<string>;
|
|
4
|
+
export declare const logApiError: (apiDescription: string, error: any) => never;
|
|
5
|
+
export declare const get: (path: string, options?: {
|
|
6
|
+
token: string;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
}) => Promise<any>;
|
|
9
|
+
export declare const post: <D extends object>(path: string, data: D) => Promise<any>;
|
|
10
|
+
export declare const put: <D extends object>(path: string, data: D) => Promise<any>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.put = exports.post = exports.get = exports.logApiError = exports.getToken = exports.getProfile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
7
|
+
const config_1 = require("../config");
|
|
8
|
+
const http_1 = require("../helpers/http");
|
|
9
|
+
let _token;
|
|
10
|
+
let _baseUrl;
|
|
11
|
+
let _currentProfile;
|
|
12
|
+
const getProfile = async () => {
|
|
13
|
+
if (_currentProfile) {
|
|
14
|
+
return _currentProfile;
|
|
15
|
+
}
|
|
16
|
+
const profileConfig = await (0, config_1.getConfigForProfile)(config_1.SystemFile.PROFILES, config_1.DEFAULT_PROFILE);
|
|
17
|
+
_currentProfile = profileConfig;
|
|
18
|
+
return _currentProfile;
|
|
19
|
+
};
|
|
20
|
+
exports.getProfile = getProfile;
|
|
21
|
+
const getBaseUrl = async () => {
|
|
22
|
+
if (_baseUrl) {
|
|
23
|
+
return _baseUrl;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const profileConfig = await (0, config_1.getConfigForProfile)(config_1.SystemFile.PROFILES, config_1.DEFAULT_PROFILE);
|
|
27
|
+
if (!profileConfig.services[config_1.Service.ZEUS]) {
|
|
28
|
+
logger_1.default.fatal('Api url is not present in config.');
|
|
29
|
+
}
|
|
30
|
+
_currentProfile = profileConfig;
|
|
31
|
+
_baseUrl = (0, http_1.sanitizeUrl)(profileConfig.services[config_1.Service.ZEUS]);
|
|
32
|
+
return _baseUrl;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
logger_1.default.fatal('User not logged in.');
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const getToken = async () => {
|
|
39
|
+
if (_token) {
|
|
40
|
+
return _token;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const credential = await (0, config_1.getConfigForProfile)(config_1.SystemFile.CREDENTIALS, config_1.DEFAULT_PROFILE);
|
|
44
|
+
_token = credential.token;
|
|
45
|
+
if (!_token) {
|
|
46
|
+
logger_1.default.fatal('Token value not present in config.');
|
|
47
|
+
}
|
|
48
|
+
return _token;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
logger_1.default.fatal('User not logged in.');
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.getToken = getToken;
|
|
55
|
+
const logApiError = (apiDescription, error) => {
|
|
56
|
+
const errorMessage = error['response']?.['data']?.['message'] || error.message;
|
|
57
|
+
logger_1.default.fatal(`${apiDescription}
|
|
58
|
+
- Details: ${errorMessage}`);
|
|
59
|
+
};
|
|
60
|
+
exports.logApiError = logApiError;
|
|
61
|
+
const get = async (path, options) => {
|
|
62
|
+
const apiBaseUrl = options ? options.baseUrl : await getBaseUrl();
|
|
63
|
+
const token = options ? options.token : await (0, exports.getToken)();
|
|
64
|
+
const response = await axios_1.default.get(`${apiBaseUrl}/${path}`, {
|
|
65
|
+
headers: {
|
|
66
|
+
Authorization: `Bearer ${token}`,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return response.data;
|
|
70
|
+
};
|
|
71
|
+
exports.get = get;
|
|
72
|
+
const post = async (path, data) => {
|
|
73
|
+
const response = await axios_1.default.post(`${await getBaseUrl()}/${path}`, data, {
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${await (0, exports.getToken)()}`,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return response.data;
|
|
79
|
+
};
|
|
80
|
+
exports.post = post;
|
|
81
|
+
const put = async (path, data) => {
|
|
82
|
+
const response = await axios_1.default.put(`${await getBaseUrl()}/${path}`, data, {
|
|
83
|
+
headers: {
|
|
84
|
+
Authorization: `Bearer ${await (0, exports.getToken)()}`,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return response.data;
|
|
88
|
+
};
|
|
89
|
+
exports.put = put;
|
|
90
|
+
//# sourceMappingURL=base.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.api.js","sourceRoot":"","sources":["../../src/apis/base.api.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAE1B,+DAA+B;AAE/B,sCAOmB;AACnB,0CAA8C;AAM9C,IAAI,MAA0B,CAAC;AAC/B,IAAI,QAA4B,CAAC;AACjC,IAAI,eAAqC,CAAC;AAMnC,MAAM,UAAU,GAAG,KAAK,IAAuB,EAAE;IACtD,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,MAAM,aAAa,GAAa,MAAM,IAAA,4BAAmB,EACvD,mBAAU,CAAC,QAAQ,EACnB,wBAAe,CAChB,CAAC;IAEF,eAAe,GAAG,aAAa,CAAC;IAChC,OAAO,eAAe,CAAC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AAE,EAAE;IACnE,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,MAAM,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE;QACtE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,MAAM,IAAA,gBAAQ,GAAE,EAAE;SAC5C;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC,CAAC;AARW,QAAA,GAAG,OAQd"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./api.types"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./auth.api"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./integration.api"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./project.api"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apis/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,qDAA2B;AAC3B,4DAAkC;AAClC,wDAA8B"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IntegrationDependencies, IntegrationMetadata } from './api.types';
|
|
2
|
+
export declare const getIntegrationDependencies: (integrations: string[]) => Promise<Record<string, IntegrationDependencies>>;
|
|
3
|
+
export declare const getDefaultIntegrations: () => Promise<IntegrationMetadata[]>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultIntegrations = exports.getIntegrationDependencies = void 0;
|
|
4
|
+
const core_1 = require("@useparagon/core");
|
|
5
|
+
const base_api_1 = require("./base.api");
|
|
6
|
+
const getIntegrationDependencies = async (integrations) => {
|
|
7
|
+
const nativeIntegrations = integrations.filter((integration) => !(0, core_1.isCustomIntegration)(integration));
|
|
8
|
+
try {
|
|
9
|
+
const integrationTypes = await (0, base_api_1.post)('graphite/integrations', {
|
|
10
|
+
integrations: nativeIntegrations
|
|
11
|
+
});
|
|
12
|
+
return Object.fromEntries(nativeIntegrations.map((integration, index) => ([integration, integrationTypes[index]])));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return (0, base_api_1.logApiError)('Failed to get integration data.', error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.getIntegrationDependencies = getIntegrationDependencies;
|
|
19
|
+
const getDefaultIntegrations = async () => {
|
|
20
|
+
try {
|
|
21
|
+
return await (0, base_api_1.get)('graphite/integrations');
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return (0, base_api_1.logApiError)('Failed to list native integrations.', error);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.getDefaultIntegrations = getDefaultIntegrations;
|
|
28
|
+
//# sourceMappingURL=integration.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.api.js","sourceRoot":"","sources":["../../src/apis/integration.api.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAGvD,yCAAoD;AAM7C,MAAM,0BAA0B,GAAG,KAAK,EAC7C,YAAsB,EAC4B,EAAE;IACpD,MAAM,kBAAkB,GAAa,YAAY,CAAC,MAAM,CAAC,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,IAAA,0BAAmB,EAAC,WAAW,CAAC,CAAC,CAAC;IACrH,IAAI,CAAC;QACH,MAAM,gBAAgB,GAA8B,MAAM,IAAA,eAAI,EAAC,uBAAuB,EAAE;YACtF,YAAY,EAAE,kBAAkB;SACjC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,sBAAW,EAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC;AAMK,MAAM,sBAAsB,GAAG,KAAK,IAEzC,EAAE;IACF,IAAI,CAAC;QACH,OAAO,MAAM,IAAA,cAAG,EAAC,uBAAuB,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,sBAAW,EAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;AACH,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProjectBuild } from './api.types';
|
|
2
|
+
export declare const getProjectList: () => Promise<{
|
|
3
|
+
title: string;
|
|
4
|
+
id: string;
|
|
5
|
+
}[]>;
|
|
6
|
+
export declare const getProjectBuild: (projectId: string) => Promise<ProjectBuild>;
|
|
7
|
+
export declare const syncProject: (build: ProjectBuild) => Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncProject = exports.getProjectBuild = exports.getProjectList = void 0;
|
|
4
|
+
const base_api_1 = require("./base.api");
|
|
5
|
+
const getProjectList = async () => {
|
|
6
|
+
try {
|
|
7
|
+
return await (0, base_api_1.get)('graphite/projects');
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
return (0, base_api_1.logApiError)('Failed to list projects.', error);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.getProjectList = getProjectList;
|
|
14
|
+
const getProjectBuild = async (projectId) => {
|
|
15
|
+
try {
|
|
16
|
+
return await (0, base_api_1.get)(`graphite/projects/${projectId}`);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error && error['response']?.['data']?.['status'] === 404) {
|
|
20
|
+
return {
|
|
21
|
+
projectId,
|
|
22
|
+
integrations: {},
|
|
23
|
+
events: {},
|
|
24
|
+
secrets: [],
|
|
25
|
+
persona: { meta: {} },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return (0, base_api_1.logApiError)('Failed to get project.', error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.getProjectBuild = getProjectBuild;
|
|
32
|
+
const syncProject = async (build) => {
|
|
33
|
+
try {
|
|
34
|
+
await (0, base_api_1.put)('graphite/projects', build);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return (0, base_api_1.logApiError)('Failed to push changes to cloud.', error);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.syncProject = syncProject;
|
|
41
|
+
//# sourceMappingURL=project.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.api.js","sourceRoot":"","sources":["../../src/apis/project.api.ts"],"names":[],"mappings":";;;AACA,yCAAmD;AAM5C,MAAM,cAAc,GAAG,KAAK,IAEjC,EAAE;IACF,IAAI,CAAC;QACH,OAAO,MAAM,IAAA,cAAG,EAAC,mBAAmB,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,sBAAW,EAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;AACH,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB;AAOK,MAAM,eAAe,GAAG,KAAK,EAClC,SAAiB,EACM,EAAE;IACzB,IAAI,CAAC;QACH,OAAO,MAAM,IAAA,cAAG,EAAC,qBAAqB,SAAS,EAAE,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEf,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC;YAC7D,OAAO;gBACL,SAAS;gBACT,YAAY,EAAE,EAAE;gBAChB,MAAM,EAAE,EAAE;gBACV,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;aACtB,CAAC;QACJ,CAAC;QACD,OAAO,IAAA,sBAAW,EAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,eAAe,mBAkB1B;AAMK,MAAM,WAAW,GAAG,KAAK,EAAE,KAAmB,EAAiB,EAAE;IACtE,IAAI,CAAC;QACH,MAAM,IAAA,cAAG,EAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,sBAAW,EAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;AACH,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB"}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IStep } from '@useparagon/core';
|
|
2
|
+
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
|
|
3
|
+
import { ISecret } from '@useparagon/core/secret';
|
|
4
|
+
import { IntegrationWorkflowMeta } from '../apis/api.types';
|
|
2
5
|
export type ProjectDependencies = {
|
|
3
|
-
|
|
6
|
+
eventIdToNameMap: Record<string, string>;
|
|
7
|
+
secrets: ISecret[];
|
|
4
8
|
};
|
|
5
9
|
export type WorkflowDependencies = ProjectDependencies & {
|
|
6
10
|
integration: {
|
|
7
11
|
name: string;
|
|
8
12
|
};
|
|
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;
|
|
9
26
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput:
|
|
4
|
-
export declare const generateProjectFiles: (projectBuild:
|
|
1
|
+
import { IntegrationBuild, ProjectBuild } from '../apis/api.types';
|
|
2
|
+
import { ProjectDependencies } from '../compiler/compiler.types';
|
|
3
|
+
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput: IntegrationBuild, projectDependencies: ProjectDependencies, projectRoot: string) => Promise<void>;
|
|
4
|
+
export declare const generateProjectFiles: (projectBuild: ProjectBuild, projectRoot: string) => Promise<void>;
|
|
@@ -1,70 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateProjectFiles = exports.generateIntegrationFiles =
|
|
3
|
+
exports.generateProjectFiles = exports.generateIntegrationFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const importSortOrderPlugin = tslib_1.__importStar(require("@trivago/prettier-plugin-sort-imports"));
|
|
6
5
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
7
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
-
const
|
|
9
|
-
const organiseImportPlugin = tslib_1.__importStar(require("prettier-plugin-organize-imports"));
|
|
7
|
+
const file_1 = require("../helpers/file");
|
|
10
8
|
const event_codegen_1 = require("./codegens/event.codegen");
|
|
11
9
|
const integration_codegen_1 = require("./codegens/integration.codegen");
|
|
10
|
+
const persona_codegen_1 = require("./codegens/persona.codegen");
|
|
12
11
|
const workflow_codegen_1 = require("./codegens/workflow.codegen");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
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* () {
|
|
12
|
+
const generateIntegrationFiles = async (integrationName, integrationOutput, projectDependencies, projectRoot) => {
|
|
13
|
+
const { eventIdToNameMap, secrets } = projectDependencies;
|
|
32
14
|
const integrationPath = path_1.default.join(projectRoot, 'integrations', integrationName);
|
|
33
|
-
|
|
15
|
+
await fs_extra_1.default.promises.mkdir(integrationPath, {
|
|
34
16
|
recursive: true,
|
|
35
17
|
});
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
18
|
+
const sharedInputs = integrationOutput.config.values.sharedMeta?.inputs ?? [];
|
|
19
|
+
const configCode = (0, integration_codegen_1.integrationToConfigCode)(integrationOutput, integrationName);
|
|
20
|
+
const inputSources = integrationOutput.dependencies?.inputs ?? [];
|
|
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);
|
|
39
28
|
const workflowPath = path_1.default.join(integrationPath, 'workflows');
|
|
40
|
-
if (
|
|
41
|
-
fs_extra_1.default.promises.mkdir(workflowPath, {
|
|
29
|
+
if (workflows.length) {
|
|
30
|
+
await fs_extra_1.default.promises.mkdir(workflowPath, {
|
|
42
31
|
recursive: true,
|
|
43
32
|
});
|
|
44
33
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const generateUniqueNames = (0, file_1.withUniqueFileNames)();
|
|
35
|
+
for (const workflow of workflows) {
|
|
36
|
+
const workflowCode = (0, workflow_codegen_1.workflowToCode)(workflow, {
|
|
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);
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
50
|
exports.generateIntegrationFiles = generateIntegrationFiles;
|
|
51
|
-
const generateProjectFiles = (projectBuild, projectRoot) =>
|
|
52
|
-
yield fs_extra_1.default.promises.mkdir(projectRoot, { recursive: true });
|
|
51
|
+
const generateProjectFiles = async (projectBuild, projectRoot) => {
|
|
53
52
|
const events = Object.values(projectBuild.events);
|
|
54
53
|
const eventPath = path_1.default.join(projectRoot, 'events');
|
|
55
54
|
if (events.length) {
|
|
56
|
-
|
|
55
|
+
await fs_extra_1.default.promises.mkdir(eventPath, {
|
|
57
56
|
recursive: true,
|
|
58
57
|
});
|
|
59
58
|
}
|
|
59
|
+
const eventIdToNameMap = {};
|
|
60
|
+
const generateUniqueNames = (0, file_1.withUniqueFileNames)();
|
|
60
61
|
for (const event of events) {
|
|
62
|
+
const eventFileName = generateUniqueNames(event.name);
|
|
63
|
+
eventIdToNameMap[event.id] = eventFileName;
|
|
61
64
|
const eventSourceCode = (0, event_codegen_1.eventToCode)(event);
|
|
62
|
-
|
|
65
|
+
await (0, file_1.writeSourceToFile)(eventPath, eventFileName, eventSourceCode);
|
|
63
66
|
}
|
|
67
|
+
await (0, file_1.writeSourceToFile)(projectRoot, 'persona.meta', (0, persona_codegen_1.personaToCode)(projectBuild.persona));
|
|
64
68
|
const integrationOutputs = Object.entries(projectBuild.integrations);
|
|
65
69
|
for (const [integrationName, integrationOutput] of integrationOutputs) {
|
|
66
|
-
|
|
70
|
+
await (0, exports.generateIntegrationFiles)(integrationName, integrationOutput, {
|
|
71
|
+
eventIdToNameMap,
|
|
72
|
+
projectId: projectBuild.projectId,
|
|
73
|
+
secrets: projectBuild.secrets,
|
|
74
|
+
}, projectRoot);
|
|
67
75
|
}
|
|
68
|
-
}
|
|
76
|
+
};
|
|
69
77
|
exports.generateProjectFiles = generateProjectFiles;
|
|
70
78
|
//# sourceMappingURL=codegen.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.utils.js","sourceRoot":"","sources":["../../src/codegen/codegen.utils.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"codegen.utils.js","sourceRoot":"","sources":["../../src/codegen/codegen.utils.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,wDAAwB;AAYxB,0CAAyE;AACzE,4DAAuD;AACvD,wEAGwC;AACxC,gEAA2D;AAC3D,kEAA6D;AAQtD,MAAM,wBAAwB,GAAG,KAAK,EAC3C,eAAuB,EACvB,iBAAmC,EACnC,mBAAwC,EACxC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AAA,2BAAW,EAAC,KAAK,CAAC,CAAC;QACnD,MAAM,IAAA,wBAAiB,EACrB,SAAS,EACT,aAAa,EACb,eAAe,CAChB,CAAC;IACJ,CAAC;IAGD,MAAM,IAAA,wBAAiB,EACrB,WAAW,EACX,cAAc,EACd,IAAA,+BAAa,EAAC,YAAY,CAAC,OAAO,CAAC,CACpC,CAAC;IAEF,MAAM,kBAAkB,GAAsC,MAAM,CAAC,OAAO,CAC1E,YAAY,CAAC,YAAY,CACW,CAAC;IAEvC,KAAK,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,IAAI,kBAAkB,EAAE,CAAC;QACtE,MAAM,IAAA,gCAAwB,EAC5B,eAAe,EACf,iBAAiB,EACjB;YACE,gBAAgB;YAChB,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,OAAO,EAAE,YAAY,CAAC,OAAO;SAC9B,EACD,WAAW,CACZ,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAnDW,QAAA,oBAAoB,wBAmD/B"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { OperatorCondition } from '@useparagon/core/resolvers';
|
|
2
|
-
|
|
2
|
+
import { StepDependencies } from '../codegen.types';
|
|
3
|
+
export declare const conditionToCode: (operatorCondition: OperatorCondition, dependencies: StepDependencies) => string;
|