@useparagon/cli 1.0.8-canary.9 → 1.0.9-canary.2
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/auth.api.d.ts +1 -1
- package/dist/apis/auth.api.js.map +1 -1
- package/dist/apis/index.d.ts +1 -1
- package/dist/apis/index.js +1 -1
- package/dist/apis/index.js.map +1 -1
- package/dist/apis/integration.api.d.ts +1 -1
- package/dist/apis/integration.api.js +5 -2
- package/dist/apis/integration.api.js.map +1 -1
- package/dist/apis/project.api.d.ts +1 -1
- package/dist/apis/project.api.js.map +1 -1
- package/dist/apis/types/customTrigger.types.d.ts +55 -0
- package/dist/apis/types/customTrigger.types.js +3 -0
- package/dist/apis/types/customTrigger.types.js.map +1 -0
- package/dist/apis/types/index.d.ts +5 -0
- package/dist/apis/types/index.js +9 -0
- package/dist/apis/types/index.js.map +1 -0
- package/dist/apis/{api.types.d.ts → types/integration.types.d.ts} +32 -31
- package/dist/apis/types/integration.types.js +3 -0
- package/dist/apis/types/integration.types.js.map +1 -0
- package/dist/apis/types/project.types.d.ts +12 -0
- package/dist/apis/types/project.types.js +3 -0
- package/dist/apis/types/project.types.js.map +1 -0
- package/dist/apis/types/user.types.d.ts +6 -0
- package/dist/apis/{api.types.js → types/user.types.js} +1 -1
- package/dist/apis/types/user.types.js.map +1 -0
- package/dist/apis/types/workflow.types.d.ts +8 -0
- package/dist/apis/types/workflow.types.js +3 -0
- package/dist/apis/types/workflow.types.js.map +1 -0
- package/dist/codegen/codegen.types.d.ts +3 -1
- package/dist/codegen/codegen.utils.d.ts +1 -1
- package/dist/codegen/codegen.utils.js +31 -5
- package/dist/codegen/codegen.utils.js.map +1 -1
- package/dist/codegen/codegens/integration.codegen.d.ts +3 -2
- package/dist/codegen/codegens/integration.codegen.js +43 -11
- package/dist/codegen/codegens/integration.codegen.js.map +1 -1
- package/dist/codegen/codegens/intent.codegen.d.ts +1 -1
- package/dist/codegen/codegens/intent.codegen.js +3 -0
- package/dist/codegen/codegens/intent.codegen.js.map +1 -1
- package/dist/codegen/codegens/source.codegen.d.ts +1 -1
- package/dist/codegen/codegens/source.codegen.js +30 -7
- package/dist/codegen/codegens/source.codegen.js.map +1 -1
- package/dist/codegen/codegens/trigger.codegen.d.ts +3 -0
- package/dist/codegen/codegens/trigger.codegen.js +250 -0
- package/dist/codegen/codegens/trigger.codegen.js.map +1 -0
- package/dist/codegen/codegens/workflow.codegen.d.ts +1 -1
- package/dist/codegen/codegens/workflow.codegen.js +40 -22
- package/dist/codegen/codegens/workflow.codegen.js.map +1 -1
- package/dist/commands/auth/login/login.types.d.ts +1 -1
- package/dist/commands/build/build.action.js +1 -1
- package/dist/commands/build/build.action.js.map +1 -1
- package/dist/commands/init/init.action.js.map +1 -1
- package/dist/commands/new/new.command.js +3 -1
- package/dist/commands/new/new.command.js.map +1 -1
- package/dist/commands/new/trigger/index.d.ts +1 -0
- package/dist/commands/new/trigger/index.js +5 -0
- package/dist/commands/new/trigger/index.js.map +1 -0
- package/dist/commands/new/trigger/trigger.action.d.ts +5 -0
- package/dist/commands/new/trigger/trigger.action.js +116 -0
- package/dist/commands/new/trigger/trigger.action.js.map +1 -0
- package/dist/commands/new/trigger/trigger.command.d.ts +8 -0
- package/dist/commands/new/trigger/trigger.command.js +25 -0
- package/dist/commands/new/trigger/trigger.command.js.map +1 -0
- package/dist/commands/new/trigger/trigger.types.d.ts +3 -0
- package/dist/commands/new/trigger/trigger.types.js +3 -0
- package/dist/commands/new/trigger/trigger.types.js.map +1 -0
- package/dist/commands/new/workflow/workflow.action.js +2 -1
- package/dist/commands/new/workflow/workflow.action.js.map +1 -1
- package/dist/compiler/compilers/integrations.compiler.d.ts +2 -1
- package/dist/compiler/compilers/integrations.compiler.js +57 -1
- package/dist/compiler/compilers/integrations.compiler.js.map +1 -1
- package/dist/compiler/compilers/triggers.compiler.d.ts +12 -0
- package/dist/compiler/compilers/triggers.compiler.js +148 -0
- package/dist/compiler/compilers/triggers.compiler.js.map +1 -0
- package/dist/compiler/compilers/workflows.compiler.d.ts +2 -1
- package/dist/compiler/compilers/workflows.compiler.js.map +1 -1
- package/dist/config/config.utils.d.ts +1 -1
- package/dist/helpers/file.d.ts +1 -1
- package/dist/helpers/file.js +8 -8
- package/dist/helpers/file.js.map +1 -1
- package/package.json +2 -2
- package/dist/apis/api.types.js.map +0 -1
package/dist/apis/auth.api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.api.js","sourceRoot":"","sources":["../../src/apis/auth.api.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"auth.api.js","sourceRoot":"","sources":["../../src/apis/auth.api.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAQvC,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"}
|
package/dist/apis/index.d.ts
CHANGED
package/dist/apis/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./api.types"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./auth.api"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./integration.api"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./project.api"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/apis/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apis/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apis/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,4DAAkC;AAClC,wDAA8B;AAC9B,kDAAwB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IntegrationDependencies, IntegrationMetadata } from './
|
|
1
|
+
import { IntegrationDependencies, IntegrationMetadata } from './types';
|
|
2
2
|
export declare const getIntegrationDependencies: (integrations: string[]) => Promise<Record<string, IntegrationDependencies>>;
|
|
3
3
|
export declare const getDefaultIntegrations: () => Promise<IntegrationMetadata[]>;
|
|
@@ -7,9 +7,12 @@ const getIntegrationDependencies = async (integrations) => {
|
|
|
7
7
|
const nativeIntegrations = integrations.filter((integration) => !(0, core_1.isCustomIntegration)(integration));
|
|
8
8
|
try {
|
|
9
9
|
const integrationTypes = await (0, base_api_1.post)('graphite/integrations', {
|
|
10
|
-
integrations: nativeIntegrations
|
|
10
|
+
integrations: nativeIntegrations,
|
|
11
11
|
});
|
|
12
|
-
return Object.fromEntries(nativeIntegrations.map((integration, index) =>
|
|
12
|
+
return Object.fromEntries(nativeIntegrations.map((integration, index) => [
|
|
13
|
+
integration,
|
|
14
|
+
integrationTypes[index],
|
|
15
|
+
]));
|
|
13
16
|
}
|
|
14
17
|
catch (error) {
|
|
15
18
|
return (0, base_api_1.logApiError)('Failed to get integration data.', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.api.js","sourceRoot":"","sources":["../../src/apis/integration.api.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;
|
|
1
|
+
{"version":3,"file":"integration.api.js","sourceRoot":"","sources":["../../src/apis/integration.api.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAEvD,yCAAoD;AAO7C,MAAM,0BAA0B,GAAG,KAAK,EAC7C,YAAsB,EAC4B,EAAE;IACpD,MAAM,kBAAkB,GAAa,YAAY,CAAC,MAAM,CACtD,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,IAAA,0BAAmB,EAAC,WAAW,CAAC,CAC3D,CAAC;IACF,IAAI,CAAC;QACH,MAAM,gBAAgB,GAA8B,MAAM,IAAA,eAAI,EAC5D,uBAAuB,EACvB;YACE,YAAY,EAAE,kBAAkB;SACjC,CACF,CAAC;QACF,OAAO,MAAM,CAAC,WAAW,CACvB,kBAAkB,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;YAC7C,WAAW;YACX,gBAAgB,CAAC,KAAK,CAAC;SACxB,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,sBAAW,EAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.api.js","sourceRoot":"","sources":["../../src/apis/project.api.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;
|
|
1
|
+
{"version":3,"file":"project.api.js","sourceRoot":"","sources":["../../src/apis/project.api.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,yCAAmD;AACnD,uDAA+D;AAWxD,MAAM,cAAc,GAAG,KAAK,IAEjC,EAAE;IACF,IAAI,CAAC;QACH,OAAO,MAAM,IAAA,cAAG,EAAC,mBAAmB,CAAC,CAAC;IACxC,CAA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AE,KAAK,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC;AAzCW,QAAA,eAAe,mBAyC1B;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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DataType, KeyedSource, TokenizedSource } from '@useparagon/core/resolvers';
|
|
2
|
+
import { HttpMethod, RequestBodyType } from '@useparagon/core/steps/library/request';
|
|
3
|
+
import { CustomTriggerPayloadValidationScheme, SetupResponseType, TriggerSubscription, WebhookTriggerLevel } from '@useparagon/core/triggers/customTrigger';
|
|
4
|
+
export type CustomTriggerSetupResponse = {
|
|
5
|
+
type: SetupResponseType.DEFAULT | SetupResponseType.ECHO_REQUEST_BODY;
|
|
6
|
+
} | {
|
|
7
|
+
type: SetupResponseType.CUSTOM_CODE;
|
|
8
|
+
code: string;
|
|
9
|
+
parameters: KeyedSource<DataType.STRING>[];
|
|
10
|
+
};
|
|
11
|
+
export type CustomTriggerPayloadValidationOption = {
|
|
12
|
+
scheme: CustomTriggerPayloadValidationScheme.NONE;
|
|
13
|
+
} | {
|
|
14
|
+
scheme: CustomTriggerPayloadValidationScheme.CUSTOM;
|
|
15
|
+
parameters: KeyedSource<DataType.STRING>[];
|
|
16
|
+
code: string;
|
|
17
|
+
} | {
|
|
18
|
+
scheme: CustomTriggerPayloadValidationScheme.SHA_1_BASE64_PAYLOAD_BODY | CustomTriggerPayloadValidationScheme.SHA_1_HEX_PAYLOAD_BODY | CustomTriggerPayloadValidationScheme.SHA_256_BASE64_PAYLOAD_BODY | CustomTriggerPayloadValidationScheme.SHA_256_HEX_PAYLOAD_BODY;
|
|
19
|
+
webhookSecret: TokenizedSource<DataType.STRING>;
|
|
20
|
+
webhookSignatureHeader: TokenizedSource<DataType.STRING>;
|
|
21
|
+
};
|
|
22
|
+
export type CustomTriggerSetupOption = {
|
|
23
|
+
url: TokenizedSource<DataType.STRING>;
|
|
24
|
+
httpMethod: HttpMethod;
|
|
25
|
+
params: KeyedSource<DataType.STRING>[];
|
|
26
|
+
headers: KeyedSource<DataType.STRING>[];
|
|
27
|
+
body: KeyedSource[];
|
|
28
|
+
bodyType?: RequestBodyType;
|
|
29
|
+
rawBody?: TokenizedSource<DataType.STRING>;
|
|
30
|
+
response?: CustomTriggerSetupResponse;
|
|
31
|
+
};
|
|
32
|
+
export type CustomTriggerTearDownOption = {
|
|
33
|
+
url: TokenizedSource<DataType.STRING>;
|
|
34
|
+
httpMethod: HttpMethod;
|
|
35
|
+
params: KeyedSource<DataType.STRING>[];
|
|
36
|
+
headers: KeyedSource<DataType.STRING>[];
|
|
37
|
+
body: KeyedSource[];
|
|
38
|
+
bodyType?: RequestBodyType;
|
|
39
|
+
rawBody?: TokenizedSource<DataType.STRING>;
|
|
40
|
+
};
|
|
41
|
+
export type CustomTriggerOptions = {
|
|
42
|
+
triggerSubscription: TriggerSubscription;
|
|
43
|
+
triggerLevel: WebhookTriggerLevel;
|
|
44
|
+
setup: CustomTriggerSetupOption;
|
|
45
|
+
tearDown: CustomTriggerTearDownOption;
|
|
46
|
+
providerId?: TokenizedSource<DataType.STRING>;
|
|
47
|
+
payloadValidationOptions?: CustomTriggerPayloadValidationOption;
|
|
48
|
+
};
|
|
49
|
+
export interface ICustomTrigger {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
options: CustomTriggerOptions;
|
|
54
|
+
isConfigured: boolean;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customTrigger.types.js","sourceRoot":"","sources":["../../../src/apis/types/customTrigger.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./customTrigger.types"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./integration.types"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./project.types"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./user.types"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./workflow.types"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/apis/types/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,8DAAoC;AACpC,0DAAgC;AAChC,uDAA6B;AAC7B,2DAAiC"}
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import { AuthenticationScheme
|
|
2
|
-
import { IEvent } from '@useparagon/core/event';
|
|
1
|
+
import { AuthenticationScheme } from '@useparagon/core';
|
|
3
2
|
import { InputSource, SerializedInput, SidebarInputType } from '@useparagon/core/inputs';
|
|
4
|
-
import { ConnectPortalThemeValues } from '@useparagon/core/integration';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { ConnectPortalThemeValues, ConnectUserProfileConfigStrategy } from '@useparagon/core/integration';
|
|
4
|
+
import { DataType, KeyedSource, Operator, OrConditions, TokenizedSource } from '@useparagon/core/resolvers';
|
|
5
|
+
import { HttpMethod, RequestAuthorization, RequestBodyType } from '@useparagon/core/steps/library/request';
|
|
6
|
+
import { ICustomTrigger } from './customTrigger.types';
|
|
7
|
+
import { WorkflowBuild } from './workflow.types';
|
|
8
|
+
type EmptyStrategy = {
|
|
9
|
+
strategy?: undefined;
|
|
10
|
+
};
|
|
11
|
+
export type HTTPStrategyConfig = {
|
|
12
|
+
strategy: ConnectUserProfileConfigStrategy.HTTP;
|
|
13
|
+
userProfileRequestUrl: TokenizedSource<DataType.STRING>;
|
|
14
|
+
urlParameters: Array<KeyedSource<DataType.STRING>>;
|
|
15
|
+
headers: Array<KeyedSource<DataType.STRING>>;
|
|
16
|
+
rawBody: TokenizedSource<DataType.STRING>;
|
|
17
|
+
body: Array<KeyedSource<DataType.ANY>>;
|
|
18
|
+
requireSuccess: boolean;
|
|
19
|
+
requestMethod: HttpMethod;
|
|
20
|
+
requestBodyType: RequestBodyType;
|
|
21
|
+
};
|
|
22
|
+
export type JWTStrategyConfig = {
|
|
23
|
+
strategy: ConnectUserProfileConfigStrategy.JWT;
|
|
24
|
+
tokenPayload: TokenizedSource<DataType.STRING>;
|
|
25
|
+
requireSuccess: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type UserProfileConfig = EmptyStrategy | HTTPStrategyConfig | JWTStrategyConfig;
|
|
9
28
|
export type InputKeyVisibilityConfig = {
|
|
10
29
|
inputId: string;
|
|
11
30
|
path?: string[];
|
|
@@ -84,14 +103,12 @@ export interface ICustomIntegration {
|
|
|
84
103
|
testEndpointPath?: TokenizedSource<DataType.STRING>;
|
|
85
104
|
apiAuthorization?: RequestAuthorization;
|
|
86
105
|
isPublished?: boolean;
|
|
106
|
+
userProfileConfig?: UserProfileConfig;
|
|
87
107
|
}
|
|
88
|
-
export
|
|
89
|
-
id: string;
|
|
108
|
+
export type IntegrationMetadata = {
|
|
90
109
|
name: string;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
dateCreated?: string;
|
|
94
|
-
}
|
|
110
|
+
title: string;
|
|
111
|
+
};
|
|
95
112
|
export interface IntegrationBuild {
|
|
96
113
|
id: string;
|
|
97
114
|
config: {
|
|
@@ -102,22 +119,6 @@ export interface IntegrationBuild {
|
|
|
102
119
|
active?: boolean;
|
|
103
120
|
dependencies?: IntegrationDependencies;
|
|
104
121
|
customIntegration?: ICustomIntegration;
|
|
122
|
+
customTriggers?: Record<string, ICustomTrigger>;
|
|
105
123
|
}
|
|
106
|
-
export
|
|
107
|
-
projectId: string;
|
|
108
|
-
projectName?: string;
|
|
109
|
-
events: Record<string, IEvent>;
|
|
110
|
-
persona: IPersona;
|
|
111
|
-
integrations: Record<string, IntegrationBuild | undefined>;
|
|
112
|
-
secrets: ISecret[];
|
|
113
|
-
}
|
|
114
|
-
export type IUser = {
|
|
115
|
-
firstName: string;
|
|
116
|
-
middleName: string;
|
|
117
|
-
lastName: string;
|
|
118
|
-
email: string;
|
|
119
|
-
};
|
|
120
|
-
export type IntegrationMetadata = {
|
|
121
|
-
name: string;
|
|
122
|
-
title: string;
|
|
123
|
-
};
|
|
124
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.types.js","sourceRoot":"","sources":["../../../src/apis/types/integration.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IEvent } from '@useparagon/core/event';
|
|
2
|
+
import { IPersona } from '@useparagon/core/persona';
|
|
3
|
+
import { ISecret } from '@useparagon/core/secret';
|
|
4
|
+
import { IntegrationBuild } from './integration.types';
|
|
5
|
+
export interface ProjectBuild {
|
|
6
|
+
projectId: string;
|
|
7
|
+
projectName?: string;
|
|
8
|
+
events: Record<string, IEvent>;
|
|
9
|
+
persona: IPersona;
|
|
10
|
+
integrations: Record<string, IntegrationBuild | undefined>;
|
|
11
|
+
secrets: ISecret[];
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.types.js","sourceRoot":"","sources":["../../../src/apis/types/project.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.types.js","sourceRoot":"","sources":["../../../src/apis/types/user.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.types.js","sourceRoot":"","sources":["../../../src/apis/types/workflow.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IStep } from '@useparagon/core';
|
|
2
2
|
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
|
|
3
3
|
import { ISecret } from '@useparagon/core/secret';
|
|
4
|
-
import { IntegrationDependencies, IntegrationWorkflowMeta } from '../apis/
|
|
4
|
+
import { IntegrationDependencies, IntegrationWorkflowMeta } from '../apis/types';
|
|
5
5
|
export type ProjectDependencies = {
|
|
6
6
|
eventIdToNameMap: Record<string, string>;
|
|
7
7
|
secrets: ISecret[];
|
|
@@ -14,6 +14,7 @@ export type WorkflowDependencies = ProjectDependencies & {
|
|
|
14
14
|
workflowMeta: IntegrationWorkflowMeta;
|
|
15
15
|
sharedInputs: SerializedInput[];
|
|
16
16
|
inputSources: InputSource[];
|
|
17
|
+
customTriggerIdToNameMap: Record<string, string>;
|
|
17
18
|
};
|
|
18
19
|
export type StepDependencies = {
|
|
19
20
|
integration: WorkflowDependencies['integration'];
|
|
@@ -26,4 +27,5 @@ export type StepDependencies = {
|
|
|
26
27
|
secrets: ISecret[];
|
|
27
28
|
currentStepId?: string;
|
|
28
29
|
upstreamStepIds: Set<string>;
|
|
30
|
+
customTriggerIdToNameMap: Record<string, string>;
|
|
29
31
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyedSource } from '@useparagon/core/resolvers';
|
|
2
|
-
import { IntegrationBuild, IntegrationIntent, IntentInputKeyConfig, ProjectBuild } from '../apis/
|
|
2
|
+
import { IntegrationBuild, IntegrationIntent, IntentInputKeyConfig, ProjectBuild } from '../apis/types';
|
|
3
3
|
import { ProjectDependencies } from '../compiler/compiler.types';
|
|
4
4
|
export declare const generateIntegrationFiles: (integrationName: string, integrationOutput: IntegrationBuild, projectDependencies: ProjectDependencies, projectRoot: string) => Promise<void>;
|
|
5
5
|
export declare const generateProjectFiles: (projectBuild: ProjectBuild, projectRoot: string) => Promise<void>;
|
|
@@ -10,6 +10,7 @@ const file_1 = require("../helpers/file");
|
|
|
10
10
|
const event_codegen_1 = require("./codegens/event.codegen");
|
|
11
11
|
const integration_codegen_1 = require("./codegens/integration.codegen");
|
|
12
12
|
const persona_codegen_1 = require("./codegens/persona.codegen");
|
|
13
|
+
const trigger_codegen_1 = require("./codegens/trigger.codegen");
|
|
13
14
|
const workflow_codegen_1 = require("./codegens/workflow.codegen");
|
|
14
15
|
const generateIntegrationFiles = async (integrationName, integrationOutput, projectDependencies, projectRoot) => {
|
|
15
16
|
if (integrationName === 'undefined') {
|
|
@@ -21,13 +22,37 @@ const generateIntegrationFiles = async (integrationName, integrationOutput, proj
|
|
|
21
22
|
recursive: true,
|
|
22
23
|
});
|
|
23
24
|
const sharedInputs = integrationOutput.config.values.sharedMeta?.inputs ?? [];
|
|
24
|
-
const configCode = (0, integration_codegen_1.integrationToConfigCode)(integrationOutput, integrationName);
|
|
25
|
+
const configCode = (0, integration_codegen_1.integrationToConfigCode)(integrationOutput, integrationName, secrets);
|
|
25
26
|
const inputSources = integrationOutput.dependencies?.inputs ?? [];
|
|
26
|
-
const
|
|
27
|
+
const inputsSourceCode = (0, integration_codegen_1.integrationInputsToCode)(integrationName, sharedInputs, inputSources);
|
|
27
28
|
await Promise.all([
|
|
28
29
|
(0, file_1.writeSourceToFile)(integrationPath, 'config', configCode),
|
|
29
|
-
(0, file_1.writeSourceToFile)(integrationPath, 'inputs',
|
|
30
|
+
(0, file_1.writeSourceToFile)(integrationPath, 'inputs', inputsSourceCode),
|
|
30
31
|
]);
|
|
32
|
+
const customTriggers = Object.values(integrationOutput.customTriggers || {});
|
|
33
|
+
const triggerPath = path_1.default.join(integrationPath, 'triggers');
|
|
34
|
+
if (customTriggers.length) {
|
|
35
|
+
await fs_extra_1.default.promises.mkdir(triggerPath, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
const customTriggerIdToNameMap = {};
|
|
38
|
+
const generateUniqueTriggerNames = (0, file_1.withUniqueFileNames)();
|
|
39
|
+
for (const trigger of customTriggers) {
|
|
40
|
+
const triggerCode = (0, trigger_codegen_1.triggerToCode)(trigger, {
|
|
41
|
+
stepIdToVariableMap: {},
|
|
42
|
+
eventIdToNameMap,
|
|
43
|
+
inputs: [],
|
|
44
|
+
sharedInputs,
|
|
45
|
+
inputSources,
|
|
46
|
+
stepIdToStepMap: {},
|
|
47
|
+
secrets,
|
|
48
|
+
upstreamStepIds: new Set(),
|
|
49
|
+
customTriggerIdToNameMap,
|
|
50
|
+
integration: { name: integrationName },
|
|
51
|
+
});
|
|
52
|
+
const triggerFileName = generateUniqueTriggerNames(trigger.name);
|
|
53
|
+
customTriggerIdToNameMap[trigger.id] = triggerFileName;
|
|
54
|
+
await (0, file_1.writeSourceToFile)(triggerPath, triggerFileName, triggerCode);
|
|
55
|
+
}
|
|
31
56
|
const workflowMetas = integrationOutput.config.values.workflowMeta ?? {};
|
|
32
57
|
const workflows = Object.values(integrationOutput.workflows);
|
|
33
58
|
const workflowPath = path_1.default.join(integrationPath, 'workflows');
|
|
@@ -36,7 +61,7 @@ const generateIntegrationFiles = async (integrationName, integrationOutput, proj
|
|
|
36
61
|
recursive: true,
|
|
37
62
|
});
|
|
38
63
|
}
|
|
39
|
-
const
|
|
64
|
+
const generateUniqueWorkflowNames = (0, file_1.withUniqueFileNames)();
|
|
40
65
|
for (const workflow of workflows) {
|
|
41
66
|
const workflowCode = (0, workflow_codegen_1.workflowToCode)(workflow, {
|
|
42
67
|
secrets,
|
|
@@ -51,8 +76,9 @@ const generateIntegrationFiles = async (integrationName, integrationOutput, proj
|
|
|
51
76
|
id: workflow.id,
|
|
52
77
|
inputs: [],
|
|
53
78
|
},
|
|
79
|
+
customTriggerIdToNameMap,
|
|
54
80
|
});
|
|
55
|
-
const workflowFileName =
|
|
81
|
+
const workflowFileName = generateUniqueWorkflowNames(workflow.name);
|
|
56
82
|
await (0, file_1.writeSourceToFile)(workflowPath, `${workflow.isDraft ? '~' : ''}` + workflowFileName, workflowCode);
|
|
57
83
|
}
|
|
58
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.utils.js","sourceRoot":"","sources":["../../src/codegen/codegen.utils.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,wDAAwB;AAGxB,oDAIiC;AAEjC,kDAAiD;
|
|
1
|
+
{"version":3,"file":"codegen.utils.js","sourceRoot":"","sources":["../../src/codegen/codegen.utils.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,wDAAwB;AAGxB,oDAIiC;AAEjC,kDAAiD;AAYjD,0CAAyE;AACzE,4DAAuD;AACvD,wEAGwC;AACxC,gEAA2D;AAC3D,gEAA2D;AAC3D,kEAA6D;AAQtD,MAAM,wBAAwB,GAAG,KAAK,EAC3C,eAAuB,EACvB,iBAAmC,EACnC,mBAAwC,EACxC,WAAmB,EACnB,EAAE;IAEF,IAAI,eAAe,KAAK,WAAW,EAAE,CAAC;QACpC,eAAe,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC;IAC1D,MAAM,eAAe,GAAW,cAAI,CAAC,IAAI,CACvC,WAAW,EACX,cAAc,EACd,eAAe,CAChB,CAAC;IACF,MAAM,kBAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE;QACvC,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,MAAM,YAAY,GAChB,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,CAAC;IAE3D,MAAM,UAAU,GAAW,IAAA,6CAAuB,EAChD,iBAAiB,EACjB,eAAe,EACf,OAAO,CACR,CAAC;IAEF,MAAM,YAAY,GAChB,iBAAiB,CAAC,YAAY,EAAE,MAAM,IAAI,EAAE,CAAC;IAE/C,MAAM,gBAAgB,GAAW,IAAA,6CAAuB,EACtD,eAAe,EACf,YAAY,EACZ,YAAY,CACb,CAAC;IA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X,CAAC;oBAED,IAAI,sBAAsB,EAAE,CAAC;wBAC3B,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;wBACvD,SAAS;oBACX,CAAC;oBAED,MAAM,UAAU,GACd,WAAW,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO;wBACjC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK;wBAC1B,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW;4BACvC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK;iCACrB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;iCACxD,IAAI,CAAC,EAAE,CAAC;4BACb,CAAC,CAAC,SAAS,CAAC;oBAElB,IAAI,SAAS,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;wBACnC,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;oBACzD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAA,eAAO,EAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AA7EW,QAAA,kBAAkB,sBA6E7B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputSource, SerializedInput } from '@useparagon/core/inputs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ISecret } from '@useparagon/core/secret';
|
|
3
|
+
import { IntegrationBuild, IntegrationDependencies } from '../../apis/types';
|
|
4
|
+
export declare const integrationToConfigCode: (integration: IntegrationBuild, integrationName: string, secrets: ISecret[]) => string;
|
|
4
5
|
export declare const integrationInputsToCode: (integrationName: string, inputs: SerializedInput[], inputSources: InputSource[]) => string;
|
|
5
6
|
export declare const typesForIntegration: (integration: string, dependencies: IntegrationDependencies) => string;
|
|
@@ -11,6 +11,34 @@ const json_1 = require("../../helpers/json");
|
|
|
11
11
|
const strings_1 = require("../../helpers/strings");
|
|
12
12
|
const intent_codegen_1 = require("./intent.codegen");
|
|
13
13
|
const source_codegen_1 = require("./source.codegen");
|
|
14
|
+
const profileConfigToCode = (profileConfig, dependencies) => {
|
|
15
|
+
switch (profileConfig.strategy) {
|
|
16
|
+
case integration_1.ConnectUserProfileConfigStrategy.HTTP:
|
|
17
|
+
return `{
|
|
18
|
+
strategy : "${integration_1.ConnectUserProfileConfigStrategy.HTTP}",
|
|
19
|
+
url: ${(0, source_codegen_1.convertSourceToCode)(profileConfig.userProfileRequestUrl, dependencies)},
|
|
20
|
+
method: '${profileConfig.requestMethod}',
|
|
21
|
+
params: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(profileConfig.urlParameters, dependencies)},
|
|
22
|
+
headers: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(profileConfig.headers, dependencies)},
|
|
23
|
+
${['GET', 'DELETE'].includes(profileConfig.requestMethod)
|
|
24
|
+
? ''
|
|
25
|
+
: `body: ${['xml', 'raw'].includes(profileConfig.requestBodyType)
|
|
26
|
+
? (0, source_codegen_1.convertSourceToCode)(profileConfig.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)
|
|
27
|
+
: (0, source_codegen_1.convertKeyedSourceParamsToCode)(profileConfig.body, dependencies)},
|
|
28
|
+
bodyType: "${profileConfig.requestBodyType}",`}requireSuccess: ${Boolean(profileConfig.requireSuccess)},
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
case integration_1.ConnectUserProfileConfigStrategy.JWT:
|
|
32
|
+
return `{
|
|
33
|
+
strategy : "${integration_1.ConnectUserProfileConfigStrategy.JWT}",
|
|
34
|
+
token:"${profileConfig.tokenPayload}",
|
|
35
|
+
requireSuccess: ${Boolean(profileConfig.requireSuccess)}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
default:
|
|
39
|
+
return `undefined`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
14
42
|
const orderIntegrationWorkflows = (workflows, workflowMeta) => {
|
|
15
43
|
return workflows.sort((a, b) => {
|
|
16
44
|
const [aMeta, bMeta] = [
|
|
@@ -26,7 +54,7 @@ const orderIntegrationWorkflows = (workflows, workflowMeta) => {
|
|
|
26
54
|
return (aMeta?.order ?? Infinity) - (bMeta?.order ?? Infinity);
|
|
27
55
|
});
|
|
28
56
|
};
|
|
29
|
-
const integrationToConfigCode = (integration, integrationName) => {
|
|
57
|
+
const integrationToConfigCode = (integration, integrationName, secrets) => {
|
|
30
58
|
const customIntegration = integration.customIntegration;
|
|
31
59
|
const config = integration.config;
|
|
32
60
|
const workflows = Object.values(integration.workflows);
|
|
@@ -78,6 +106,7 @@ const integrationToConfigCode = (integration, integrationName) => {
|
|
|
78
106
|
}
|
|
79
107
|
const dependencies = {
|
|
80
108
|
inputs: customIntegration.inputFields,
|
|
109
|
+
secrets,
|
|
81
110
|
};
|
|
82
111
|
const authorizationConfigToCode = () => {
|
|
83
112
|
let apiAuthorization = customIntegration.apiAuthorization;
|
|
@@ -112,14 +141,14 @@ const integrationToConfigCode = (integration, integrationName) => {
|
|
|
112
141
|
const params = customIntegration.apiAuthorization.params || [];
|
|
113
142
|
return `authorization: {
|
|
114
143
|
type: '${request_1.RequestAuthorizationType.QUERY_PARAMS}',
|
|
115
|
-
params: ${(0, source_codegen_1.
|
|
144
|
+
params: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(params, dependencies)}
|
|
116
145
|
}
|
|
117
146
|
`;
|
|
118
147
|
case request_1.RequestAuthorizationType.AUTH_HEADER:
|
|
119
148
|
const headers = customIntegration.apiAuthorization.headers || [];
|
|
120
149
|
return `authorization: {
|
|
121
150
|
type: '${request_1.RequestAuthorizationType.AUTH_HEADER}',
|
|
122
|
-
headers: ${(0, source_codegen_1.
|
|
151
|
+
headers: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(headers, dependencies)}
|
|
123
152
|
}
|
|
124
153
|
`;
|
|
125
154
|
case request_1.RequestAuthorizationType.CLIENT_CREDENTIAL:
|
|
@@ -160,8 +189,11 @@ const integrationToConfigCode = (integration, integrationName) => {
|
|
|
160
189
|
.map((workflow) => workflowIdToFileInfo[workflow.id].varName)
|
|
161
190
|
.join(',\n')}
|
|
162
191
|
],
|
|
192
|
+
${customIntegration.userProfileConfig
|
|
193
|
+
? `userProfileConfig: ${profileConfigToCode(customIntegration.userProfileConfig, dependencies)},`
|
|
194
|
+
: ''}
|
|
163
195
|
${config.values.connectPortalTheme
|
|
164
|
-
? `theme: ${(0, strings_1.sanitizeString)(config.values.connectPortalTheme)}
|
|
196
|
+
? `theme: ${(0, strings_1.sanitizeString)(config.values.connectPortalTheme)},`
|
|
165
197
|
: ''}
|
|
166
198
|
${(() => {
|
|
167
199
|
const apiBaseUrl = customIntegration.apiBaseUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
@@ -185,10 +217,10 @@ const integrationToConfigCode = (integration, integrationName) => {
|
|
|
185
217
|
`;
|
|
186
218
|
case core_1.AuthenticationScheme.OAUTH:
|
|
187
219
|
const authorizationUrl = customIntegration.oauthAuthorizationUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
188
|
-
const
|
|
220
|
+
const accessTokenUrl = customIntegration.oauthAccessTokenUrl || source_codegen_1.EMPTY_TOKENIZED_SOURCE;
|
|
189
221
|
return `authenticationType: '${core_1.AuthenticationScheme.OAUTH}',
|
|
190
222
|
authorizationUrl: ${(0, source_codegen_1.convertSourceToCode)(authorizationUrl, dependencies)},
|
|
191
|
-
accessTokenUrl: ${(0, source_codegen_1.convertSourceToCode)(
|
|
223
|
+
accessTokenUrl: ${(0, source_codegen_1.convertSourceToCode)(accessTokenUrl, dependencies)},
|
|
192
224
|
scopes: ${(0, strings_1.sanitizeString)(customIntegration.oauthScopes || '')},
|
|
193
225
|
includeClientIdAndSecrets: ${customIntegration.oauthIncludeClientAuthorizationHeader ?? true},
|
|
194
226
|
usePKCEInCodeExchange: ${customIntegration.usePKCEInCodeExchange ?? false},
|
|
@@ -241,16 +273,16 @@ const typesForIntegration = (integration, dependencies) => {
|
|
|
241
273
|
const dynamicComboInputTypes = inputs
|
|
242
274
|
.filter((input) => input.type === inputs_1.DataSourceType.DYNAMIC_COMBO_INPUT)
|
|
243
275
|
.map(inputs_1.getInputTypeForUI);
|
|
244
|
-
const
|
|
276
|
+
const integrationInterfaceName = (0, utils_1.toPascalCase)(`I ${integration}Integration`);
|
|
245
277
|
const sourceCode = `
|
|
246
278
|
import { UserDefinedComboInputOptions, UserDefinedFieldMappingOptions } from '@useparagon/core/inputs';
|
|
247
279
|
import { ActionStep, ActionTriggerStep } from '@useparagon/core';
|
|
248
|
-
import { IntegrationOptions } from '@useparagon/core/integration
|
|
280
|
+
import { IntegrationOptions } from '@useparagon/core/integration';
|
|
249
281
|
|
|
250
282
|
import { IntentToInputOutput } from './intents';
|
|
251
283
|
import { IntentToInputOutput as TriggerIntentToInputOutput } from './triggers';
|
|
252
284
|
|
|
253
|
-
type ${
|
|
285
|
+
type ${integrationInterfaceName}UserDefinedInput = {
|
|
254
286
|
id: string;
|
|
255
287
|
title: string;
|
|
256
288
|
required?: boolean;
|
|
@@ -329,12 +361,12 @@ const typesForIntegration = (integration, dependencies) => {
|
|
|
329
361
|
* this should be used whenever we are creating inputs for integrations/workflows
|
|
330
362
|
* as it will infer proper types
|
|
331
363
|
*/
|
|
332
|
-
export declare const createInputs: <T extends Record<string, ${
|
|
364
|
+
export declare const createInputs: <T extends Record<string, ${integrationInterfaceName}UserDefinedInput>>(inputs: T) => T;
|
|
333
365
|
|
|
334
366
|
/**
|
|
335
367
|
* integration type for ${integration}
|
|
336
368
|
*/
|
|
337
|
-
export type ${
|
|
369
|
+
export type ${integrationInterfaceName} = {
|
|
338
370
|
/**
|
|
339
371
|
* name of integration
|
|
340
372
|
*/
|