@useparagon/cli 1.0.9-canary.2 → 1.0.9

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.
Files changed (107) hide show
  1. package/dist/apis/{types/integration.types.d.ts → api.types.d.ts} +74 -32
  2. package/dist/apis/api.types.js +14 -0
  3. package/dist/apis/api.types.js.map +1 -0
  4. package/dist/apis/auth.api.d.ts +1 -1
  5. package/dist/apis/auth.api.js.map +1 -1
  6. package/dist/apis/index.d.ts +1 -1
  7. package/dist/apis/index.js +1 -1
  8. package/dist/apis/index.js.map +1 -1
  9. package/dist/apis/integration.api.d.ts +1 -1
  10. package/dist/apis/integration.api.js +2 -5
  11. package/dist/apis/integration.api.js.map +1 -1
  12. package/dist/apis/project.api.d.ts +2 -1
  13. package/dist/apis/project.api.js +11 -1
  14. package/dist/apis/project.api.js.map +1 -1
  15. package/dist/codegen/codegen.types.d.ts +4 -6
  16. package/dist/codegen/codegen.utils.d.ts +1 -1
  17. package/dist/codegen/codegen.utils.js +5 -31
  18. package/dist/codegen/codegen.utils.js.map +1 -1
  19. package/dist/codegen/codegens/integration.codegen.d.ts +2 -3
  20. package/dist/codegen/codegens/integration.codegen.js +11 -43
  21. package/dist/codegen/codegens/integration.codegen.js.map +1 -1
  22. package/dist/codegen/codegens/intent.codegen.d.ts +1 -1
  23. package/dist/codegen/codegens/intent.codegen.js +0 -3
  24. package/dist/codegen/codegens/intent.codegen.js.map +1 -1
  25. package/dist/codegen/codegens/source.codegen.d.ts +1 -1
  26. package/dist/codegen/codegens/source.codegen.js +10 -33
  27. package/dist/codegen/codegens/source.codegen.js.map +1 -1
  28. package/dist/codegen/codegens/workflow.codegen.d.ts +1 -1
  29. package/dist/codegen/codegens/workflow.codegen.js +22 -40
  30. package/dist/codegen/codegens/workflow.codegen.js.map +1 -1
  31. package/dist/commands/auth/login/login.types.d.ts +1 -1
  32. package/dist/commands/build/build.action.js +1 -1
  33. package/dist/commands/build/build.action.js.map +1 -1
  34. package/dist/commands/build/build.types.d.ts +9 -0
  35. package/dist/commands/init/init.action.js.map +1 -1
  36. package/dist/commands/new/new.command.js +1 -3
  37. package/dist/commands/new/new.command.js.map +1 -1
  38. package/dist/commands/new/workflow/workflow.action.js +1 -2
  39. package/dist/commands/new/workflow/workflow.action.js.map +1 -1
  40. package/dist/commands/push/push.action.d.ts +13 -1
  41. package/dist/commands/push/push.action.js +163 -5
  42. package/dist/commands/push/push.action.js.map +1 -1
  43. package/dist/commands/push/push.command.js +1 -0
  44. package/dist/commands/push/push.command.js.map +1 -1
  45. package/dist/commands/push/push.types.d.ts +3 -1
  46. package/dist/commands/push/push.utils.d.ts +5 -0
  47. package/dist/commands/push/push.utils.js +24 -0
  48. package/dist/commands/push/push.utils.js.map +1 -0
  49. package/dist/compiler/compiler.types.d.ts +37 -2
  50. package/dist/compiler/compiler.types.js +1 -0
  51. package/dist/compiler/compiler.types.js.map +1 -1
  52. package/dist/compiler/compiler.utils.d.ts +7 -0
  53. package/dist/compiler/compiler.utils.js +72 -1
  54. package/dist/compiler/compiler.utils.js.map +1 -1
  55. package/dist/compiler/compilers/changeLog.compiler.d.ts +22 -0
  56. package/dist/compiler/compilers/changeLog.compiler.js +199 -0
  57. package/dist/compiler/compilers/changeLog.compiler.js.map +1 -0
  58. package/dist/compiler/compilers/integrations.compiler.d.ts +1 -2
  59. package/dist/compiler/compilers/integrations.compiler.js +1 -57
  60. package/dist/compiler/compilers/integrations.compiler.js.map +1 -1
  61. package/dist/compiler/compilers/project.compiler.d.ts +3 -3
  62. package/dist/compiler/compilers/project.compiler.js +11 -1
  63. package/dist/compiler/compilers/project.compiler.js.map +1 -1
  64. package/dist/compiler/compilers/workflows.compiler.d.ts +1 -2
  65. package/dist/compiler/compilers/workflows.compiler.js +8 -1
  66. package/dist/compiler/compilers/workflows.compiler.js.map +1 -1
  67. package/dist/config/config.utils.d.ts +2 -2
  68. package/dist/config/config.utils.js.map +1 -1
  69. package/dist/helpers/file.d.ts +2 -1
  70. package/dist/helpers/file.js +14 -9
  71. package/dist/helpers/file.js.map +1 -1
  72. package/package.json +4 -2
  73. package/dist/apis/types/customTrigger.types.d.ts +0 -55
  74. package/dist/apis/types/customTrigger.types.js +0 -3
  75. package/dist/apis/types/customTrigger.types.js.map +0 -1
  76. package/dist/apis/types/index.d.ts +0 -5
  77. package/dist/apis/types/index.js +0 -9
  78. package/dist/apis/types/index.js.map +0 -1
  79. package/dist/apis/types/integration.types.js +0 -3
  80. package/dist/apis/types/integration.types.js.map +0 -1
  81. package/dist/apis/types/project.types.d.ts +0 -12
  82. package/dist/apis/types/project.types.js +0 -3
  83. package/dist/apis/types/project.types.js.map +0 -1
  84. package/dist/apis/types/user.types.d.ts +0 -6
  85. package/dist/apis/types/user.types.js +0 -3
  86. package/dist/apis/types/user.types.js.map +0 -1
  87. package/dist/apis/types/workflow.types.d.ts +0 -8
  88. package/dist/apis/types/workflow.types.js +0 -3
  89. package/dist/apis/types/workflow.types.js.map +0 -1
  90. package/dist/codegen/codegens/trigger.codegen.d.ts +0 -3
  91. package/dist/codegen/codegens/trigger.codegen.js +0 -250
  92. package/dist/codegen/codegens/trigger.codegen.js.map +0 -1
  93. package/dist/commands/new/trigger/index.d.ts +0 -1
  94. package/dist/commands/new/trigger/index.js +0 -5
  95. package/dist/commands/new/trigger/index.js.map +0 -1
  96. package/dist/commands/new/trigger/trigger.action.d.ts +0 -5
  97. package/dist/commands/new/trigger/trigger.action.js +0 -116
  98. package/dist/commands/new/trigger/trigger.action.js.map +0 -1
  99. package/dist/commands/new/trigger/trigger.command.d.ts +0 -8
  100. package/dist/commands/new/trigger/trigger.command.js +0 -25
  101. package/dist/commands/new/trigger/trigger.command.js.map +0 -1
  102. package/dist/commands/new/trigger/trigger.types.d.ts +0 -3
  103. package/dist/commands/new/trigger/trigger.types.js +0 -3
  104. package/dist/commands/new/trigger/trigger.types.js.map +0 -1
  105. package/dist/compiler/compilers/triggers.compiler.d.ts +0 -12
  106. package/dist/compiler/compilers/triggers.compiler.js +0 -148
  107. package/dist/compiler/compilers/triggers.compiler.js.map +0 -1
@@ -1,3 +0,0 @@
1
- import { ICustomTrigger } from '../../apis/types';
2
- import { StepDependencies } from '../codegen.types';
3
- export declare const triggerToCode: (trigger: ICustomTrigger, dependencies: StepDependencies) => string;
@@ -1,250 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.triggerToCode = void 0;
4
- const customTrigger_1 = require("@useparagon/core/triggers/customTrigger");
5
- const strings_1 = require("../../helpers/strings");
6
- const source_codegen_1 = require("./source.codegen");
7
- const triggerToCode = (trigger, dependencies) => {
8
- const { integration } = dependencies;
9
- const isCustomIntegration = integration.name.startsWith('custom');
10
- const triggerSubscription = trigger.options.triggerSubscription;
11
- const triggerLevel = 'APP';
12
- if (triggerSubscription === customTrigger_1.TriggerSubscription.MANUAL) {
13
- return `
14
- import {
15
- ManualWebhookTrigger,
16
- CustomTriggerSetupResponse,
17
- TriggerPayloadValidationOption,
18
- ISetupTriggerResponseContext,
19
- IPayloadValidationContext
20
- } from '@useparagon/core/triggers/customTrigger';
21
- ${isCustomIntegration
22
- ? `import {
23
- DefaultInputToResultMap,
24
- } from '@useparagon/core/inputs';`
25
- : `import { InputResultMap } from '@useparagon/integrations/${integration.name}';`}
26
-
27
- /**
28
- * "${trigger.name}" custom trigger
29
- */
30
- export default class extends ManualWebhookTrigger<"${triggerLevel}"> {
31
- /**
32
- * This property is maintained by Paragon. Do not edit this property.
33
- */
34
- readonly id = '${trigger.id}';
35
-
36
- /**
37
- * define whether trigger is app level or user level
38
- */
39
- readonly triggerLevel = "${triggerLevel}";
40
-
41
- /**
42
- * The name of the custom trigger
43
- */
44
- name = ${(0, strings_1.sanitizeString)(trigger.name)};
45
-
46
- /**
47
- * The description of custom trigger
48
- */
49
- description = ${(0, strings_1.sanitizeString)(trigger.description)};
50
-
51
- /**
52
- * if true user can use this in workflow
53
- */
54
- isConfigured = ${trigger.isConfigured};
55
-
56
- /**
57
- * setup response
58
- * @param context
59
- * @returns
60
- */
61
- setupResponse(context: ISetupTriggerResponseContext<${isCustomIntegration ? 'DefaultInputToResultMap' : 'InputResultMap'}>): CustomTriggerSetupResponse{
62
- return {
63
- ${(() => {
64
- const setupResponse = trigger.options.setup.response;
65
- switch (setupResponse?.type) {
66
- case customTrigger_1.SetupResponseType.CUSTOM_CODE:
67
- return `
68
- type: "${setupResponse.type}",
69
- parameters: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(setupResponse.parameters || [], dependencies)},
70
- code: ${setupResponse.code}
71
- `;
72
- case customTrigger_1.SetupResponseType.ECHO_REQUEST_BODY:
73
- return `type: "${customTrigger_1.SetupResponseInitType.ECHO_REQUEST_BODY}"`;
74
- case customTrigger_1.SetupResponseType.DEFAULT:
75
- default:
76
- return `type: "${customTrigger_1.SetupResponseInitType.RESPOND_WITH_200}"`;
77
- }
78
- })()}
79
- }
80
- }
81
-
82
- /**
83
- * validate payload
84
- * @param context
85
- * @returns
86
- */
87
- validatePayload(context: IPayloadValidationContext<${isCustomIntegration ? 'DefaultInputToResultMap' : 'InputResultMap'}>): TriggerPayloadValidationOption{
88
- return {
89
- ${(() => {
90
- const payloadValidationOptions = trigger.options.payloadValidationOptions;
91
- if (!payloadValidationOptions?.scheme) {
92
- return 'scheme: "NONE"';
93
- }
94
- switch (payloadValidationOptions.scheme) {
95
- case customTrigger_1.CustomTriggerPayloadValidationScheme.CUSTOM:
96
- return `
97
- scheme: "${payloadValidationOptions.scheme}",
98
- parameters: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(payloadValidationOptions.parameters || [], dependencies)},
99
- code: ${payloadValidationOptions.code}
100
- `;
101
- default:
102
- return `scheme: "${payloadValidationOptions.scheme}"`;
103
- }
104
- })()}
105
- }
106
- }
107
- }
108
- `;
109
- }
110
- const setupOptions = trigger.options.setup;
111
- const teardownOptions = trigger.options.tearDown;
112
- const setupBodyType = setupOptions?.bodyType ?? 'json';
113
- const teardownBodyType = teardownOptions?.bodyType ?? 'json';
114
- return `
115
- import {
116
- ApiEndpointWebhookTrigger,
117
- ICreateTriggerContext,
118
- ITeardownTriggerContext,
119
- ICreateTriggerSetup,
120
- ITeardownTriggerSetup,
121
- CustomTriggerSetupResponse,
122
- TriggerPayloadValidationOption,
123
- ISetupTriggerResponseContext,
124
- IPayloadValidationContext
125
- } from '@useparagon/core/triggers/customTrigger';
126
- ${isCustomIntegration
127
- ? `import {
128
- DefaultInputToResultMap,
129
- } from '@useparagon/core/inputs';`
130
- : `import { InputResultMap } from '@useparagon/integrations/${integration.name}';`}
131
-
132
- /**
133
- * "${trigger.name}" custom trigger
134
- */
135
- export default class extends ApiEndpointWebhookTrigger<"${triggerLevel}"> {
136
- /**
137
- * This property is maintained by Paragon. Do not edit this property.
138
- */
139
- readonly id = '${trigger.id}';
140
-
141
- /**
142
- * define whether trigger is app level or user level
143
- */
144
- readonly triggerLevel = "${triggerLevel}";
145
-
146
- /**
147
- * The name of the custom trigger
148
- */
149
- name = ${(0, strings_1.sanitizeString)(trigger.name)};
150
-
151
- /**
152
- * The description of custom trigger
153
- */
154
- description = ${(0, strings_1.sanitizeString)(trigger.description)};
155
-
156
- /**
157
- * if true user can use this in workflow
158
- */
159
- isConfigured = ${trigger.isConfigured};
160
-
161
- /**
162
- * describe setup configuration of custom trigger
163
- * @param context
164
- * @returns
165
- */
166
- create(context: ICreateTriggerContext<${isCustomIntegration ? 'DefaultInputToResultMap' : 'InputResultMap'}>): ICreateTriggerSetup {
167
- return {
168
- url: ${(0, source_codegen_1.convertSourceToCode)(setupOptions?.url || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)},
169
- bodyType: '${setupBodyType}',
170
- body: ${['xml', 'raw'].includes(setupBodyType)
171
- ? (0, source_codegen_1.convertSourceToCode)(setupOptions?.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)
172
- : (0, source_codegen_1.convertKeyedSourceParamsToCode)(setupOptions?.body || [], dependencies)},
173
- params: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(setupOptions?.params || [], dependencies)},
174
- headers: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(setupOptions?.headers || [], dependencies)},
175
- };
176
- }
177
-
178
- /**
179
- * describe teardown configuration of custom trigger
180
- * @param context
181
- * @returns
182
- */
183
- teardown(context: ITeardownTriggerContext<${isCustomIntegration ? 'DefaultInputToResultMap' : 'InputResultMap'}>): ITeardownTriggerSetup {
184
- return {
185
- url: ${(0, source_codegen_1.convertSourceToCode)(teardownOptions?.url || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)},
186
- bodyType: '${teardownBodyType}',
187
- body: ${['xml', 'raw'].includes(teardownBodyType)
188
- ? (0, source_codegen_1.convertSourceToCode)(teardownOptions?.rawBody || source_codegen_1.EMPTY_TOKENIZED_SOURCE, dependencies)
189
- : (0, source_codegen_1.convertKeyedSourceParamsToCode)(teardownOptions?.body || [], dependencies)},
190
- params: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(teardownOptions?.params || [], dependencies)},
191
- headers: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(teardownOptions?.headers || [], dependencies)},
192
- }
193
- }
194
-
195
- /**
196
- * setup response
197
- * @param context
198
- * @returns
199
- */
200
- setupResponse(context: ISetupTriggerResponseContext<${isCustomIntegration ? 'DefaultInputToResultMap' : 'InputResultMap'}>): CustomTriggerSetupResponse{
201
- return {
202
- ${(() => {
203
- const setupResponse = trigger.options.setup.response;
204
- switch (setupResponse?.type) {
205
- case customTrigger_1.SetupResponseType.CUSTOM_CODE:
206
- return `
207
- type: "${setupResponse.type}",
208
- parameters: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(setupResponse.parameters || [], dependencies)},
209
- code: ${setupResponse.code}
210
- `;
211
- case customTrigger_1.SetupResponseType.ECHO_REQUEST_BODY:
212
- return `type: "${customTrigger_1.SetupResponseInitType.ECHO_REQUEST_BODY}"`;
213
- case customTrigger_1.SetupResponseType.DEFAULT:
214
- default:
215
- return `type: "${customTrigger_1.SetupResponseInitType.RESPOND_WITH_200}"`;
216
- }
217
- })()}
218
- }
219
- }
220
-
221
- /**
222
- * validate payload
223
- * @param context
224
- * @returns
225
- */
226
- validatePayload(context: IPayloadValidationContext<${isCustomIntegration ? 'DefaultInputToResultMap' : 'InputResultMap'}>): TriggerPayloadValidationOption{
227
- return {
228
- ${(() => {
229
- const payloadValidationOptions = trigger.options.payloadValidationOptions;
230
- if (!payloadValidationOptions?.scheme) {
231
- return 'scheme: "NONE"';
232
- }
233
- switch (payloadValidationOptions.scheme) {
234
- case customTrigger_1.CustomTriggerPayloadValidationScheme.CUSTOM:
235
- return `
236
- scheme: "${payloadValidationOptions.scheme}",
237
- parameters: ${(0, source_codegen_1.convertKeyedSourceParamsToCode)(payloadValidationOptions.parameters || [], dependencies)},
238
- code: ${payloadValidationOptions.code}
239
- `;
240
- default:
241
- return `scheme: "${payloadValidationOptions.scheme}"`;
242
- }
243
- })()}
244
- }
245
- }
246
- }
247
- `;
248
- };
249
- exports.triggerToCode = triggerToCode;
250
- //# sourceMappingURL=trigger.codegen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trigger.codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegens/trigger.codegen.ts"],"names":[],"mappings":";;;AAAA,2EAMiD;AAGjD,mDAAuD;AAGvD,qDAI0B;AAOnB,MAAM,aAAa,GAAG,CAC3B,OAAuB,EACvB,YAA8B,EACtB,EAAE;IACV,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC;IACrC,MAAM,mBAAmB,GAAY,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE3E,MAAM,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;IACtC,MAAM,YAAY,GAAwB,KAAK,CAAC;IAEhD,IAAI,mBAAmB,KAAK,mCAAmB,CAAC,MAAM,EAAE,CAAC;QACvD,OAAO;;;;;;;;QASH,mBAAmB;YAC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;YACJ,KAAK,iCAAiB,CAAC,iBAAiB;gBACtC,OAAO,UAAU,qCAAqB,CAAC,iBAAiB,GAAG,CAAC;YAC9D,KAAK,iCAAiB,CAAC,OAAO,CAAC;YAC/B;gBACE,OAAO,UAAU,qCAAqB,CAAC,gBAAgB,GAAG,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC,EAAE;;;;;;;;;2DAUN,mBAAmB,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBACpD;;YAEM,CAAC,GAAG,EAAE;QACN,MAAM,wBAAwB,GAC5B,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC;QAC3C,IAAI,CAAC,wBAAwB,EAAE,MAAM,EAAE,CAAC;YACtC,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,QAAQ,wBAAwB,CAAC,MAAM,EAAE,CAAC;YACxC,KAAK,oDAAoC,CAAC,MAAM;gBAC9C,OAAO;6BACM,wBAAwB,CAAC,MAAM;gCAC5B,IAAA,+CAA8B,EAC1C,wBAAwB,CAAC,UAAU,IAAI,EAAE,EACzC,YAAY,CACb;0BACO,wBAAwB,CAAC,IAAI;iBACtC,CAAC;YACJ;gBACE,OAAO,YAAY,wBAAwB,CAAC,MAAM,GAAG,CAAC;QAC1D,CAAC;IACH,CAAC,CAAC,EAAE;;;;GAIX,CAAC;AACJ,CAAC,CAAC;AA9TW,QAAA,aAAa,iBA8TxB"}
@@ -1 +0,0 @@
1
- export * from './trigger.command';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./trigger.command"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/new/trigger/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC"}
@@ -1,5 +0,0 @@
1
- import { IAction } from '../../command.interface';
2
- import { TriggerCommandOptions } from './trigger.types';
3
- export declare class TriggerAction implements IAction<TriggerCommandOptions, void> {
4
- handle({ integration }: TriggerCommandOptions): Promise<void>;
5
- }
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TriggerAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
6
- const glob_1 = require("glob");
7
- const path_1 = tslib_1.__importDefault(require("path"));
8
- const prompts_1 = tslib_1.__importDefault(require("prompts"));
9
- const uuid_1 = require("uuid");
10
- const request_1 = require("@useparagon/core/steps/library/request");
11
- const base_api_1 = require("../../../apis/base.api");
12
- const source_codegen_1 = require("../../../codegen/codegens/source.codegen");
13
- const trigger_codegen_1 = require("../../../codegen/codegens/trigger.codegen");
14
- const compiler_utils_1 = require("../../../compiler/compiler.utils");
15
- const config_1 = require("../../../config");
16
- const file_1 = require("../../../helpers/file");
17
- const logger_1 = tslib_1.__importDefault(require("../../../logger"));
18
- const new_utils_1 = require("../new.utils");
19
- class TriggerAction {
20
- async handle({ integration }) {
21
- const { rootPath } = await (0, config_1.getParagraphProjectDetails)();
22
- await (0, base_api_1.getToken)();
23
- const currentActiveIntegrations = await (0, new_utils_1.getCurrentActiveIntegrations)(rootPath);
24
- if (!currentActiveIntegrations.length) {
25
- logger_1.default.fatal('No integration present.');
26
- }
27
- if (!currentActiveIntegrations.some((currentIntegration) => currentIntegration === integration)) {
28
- logger_1.default.fatal(`${integration} does not match with current integrations - ${currentActiveIntegrations.join(', ')}`);
29
- }
30
- const { triggerName } = await (0, prompts_1.default)({
31
- type: 'text',
32
- name: 'triggerName',
33
- message: 'Please enter name of your trigger.',
34
- });
35
- if (!triggerName) {
36
- logger_1.default.fatal('trigger name not passed.');
37
- }
38
- const { triggerSubscription } = await (0, prompts_1.default)({
39
- type: 'autocomplete',
40
- name: 'triggerSubscription',
41
- message: 'Select trigger subscription type',
42
- choices: [
43
- { title: 'Api endpoint trigger', value: 'PROGRAMMATIC' },
44
- { title: 'Manual trigger', value: 'MANUAL' },
45
- ],
46
- });
47
- if (!triggerSubscription) {
48
- logger_1.default.fatal('Trigger type not selected.');
49
- }
50
- const { triggerLevel } = await (0, prompts_1.default)({
51
- type: 'autocomplete',
52
- name: 'triggerLevel',
53
- message: 'Select how trigger will be used',
54
- choices: [
55
- { title: 'App level', value: 'APP' },
56
- { title: 'User level', value: 'USER' },
57
- ],
58
- });
59
- if (!triggerLevel) {
60
- logger_1.default.fatal('trigger level not selected.');
61
- }
62
- const defaultOptions = {
63
- url: source_codegen_1.EMPTY_TOKENIZED_SOURCE,
64
- params: [],
65
- headers: [],
66
- body: [],
67
- bodyType: request_1.RequestBodyType.JSON,
68
- rawBody: source_codegen_1.EMPTY_TOKENIZED_SOURCE,
69
- };
70
- const newTrigger = {
71
- id: (0, uuid_1.v4)(),
72
- name: triggerName,
73
- description: '',
74
- isConfigured: false,
75
- options: {
76
- triggerSubscription,
77
- triggerLevel,
78
- setup: {
79
- httpMethod: request_1.HttpMethod.POST,
80
- ...defaultOptions,
81
- },
82
- tearDown: {
83
- httpMethod: request_1.HttpMethod.DELETE,
84
- ...defaultOptions,
85
- },
86
- },
87
- };
88
- const triggerCode = (0, trigger_codegen_1.triggerToCode)(newTrigger, {
89
- stepIdToVariableMap: {},
90
- eventIdToNameMap: {},
91
- inputs: [],
92
- sharedInputs: [],
93
- inputSources: [],
94
- stepIdToStepMap: {},
95
- secrets: [],
96
- upstreamStepIds: new Set(),
97
- customTriggerIdToNameMap: {},
98
- integration: { name: integration },
99
- });
100
- const triggersPath = path_1.default.join(rootPath, 'src', 'integrations', integration, 'triggers');
101
- const currentTriggers = (await (0, glob_1.glob)(path_1.default.join(triggersPath, '*.ts'), {
102
- nodir: true,
103
- })).map(compiler_utils_1.extractKeyFromPath);
104
- if (!currentTriggers.length) {
105
- await fs_extra_1.default.promises.mkdir(triggersPath, {
106
- recursive: true,
107
- });
108
- }
109
- const generateTriggerName = (0, file_1.withUniqueFileNames)(currentTriggers);
110
- const sanitizeNewTriggerName = generateTriggerName(triggerName);
111
- await (0, file_1.writeSourceToFile)(triggersPath, sanitizeNewTriggerName, triggerCode);
112
- logger_1.default.success(`Trigger with name ${sanitizeNewTriggerName} created.`);
113
- }
114
- }
115
- exports.TriggerAction = TriggerAction;
116
- //# sourceMappingURL=trigger.action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trigger.action.js","sourceRoot":"","sources":["../../../../src/commands/new/trigger/trigger.action.ts"],"names":[],"mappings":";;;;AAAA,gEAA0B;AAC1B,+BAA4B;AAC5B,wDAAwB;AACxB,8DAA8B;AAC9B,+BAA0B;AAG1B,oEAGgD;AAEhD,qDAAkD;AAKlD,6EAAkF;AAClF,+EAA0E;AAC1E,qEAAsE;AACtE,4CAA6D;AAC7D,gDAA+E;AAC/E,qEAAqC;AAErC,4CAA4D;AAM5D,MAAa,aAAa;IAIxB,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAyB;QAEjD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,mCAA0B,GAAE,CAAC;QAGxD,MAAM,IAAA,mBAAQ,GAAE,CAAC;QAEjB,MAAM,yBAAyB,GAC7B,MAAM,IAAA,wCAA4B,EAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,CAAC,yBAAyB,CAAC,MAAM,EAAE,CAAC;YACtC,gBAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC1C,CAAC;QAED,IACE,CAAC,yBAAyB,CAAC,IAAI,CAC7B,CAAC,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,KAAK,WAAW,CAC3D,EACD,CAAC;YACD,gBAAM,CAAC,KAAK,CACV,GAAG,WAAW,+CAA+C,yBAAyB,CAAC,IAAI,CACzF,IAAI,CACL,EAAE,CACJ,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,iBAAO,EAAC;YACpC,IAAI,EAAE,MAAM;YACZ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mBAAmB,CAAC,WAAW,CAAC,CAAC;QAExE,MAAM,IAAA,wBAAiB,EAAC,YAAY,EAAE,sBAAsB,EAAE,WAAW,CAAC,CAAC;QAE3E,gBAAM,CAAC,OAAO,CAAC,qBAAqB,sBAAsB,WAAW,CAAC,CAAC;IACzE,CAAC;CACF;AAzID,sCAyIC"}
@@ -1,8 +0,0 @@
1
- import { Command } from 'commander';
2
- import { ICommand } from '../../command.interface';
3
- export declare class TriggerCommand implements ICommand {
4
- private actionHandler;
5
- constructor();
6
- load(program: Command): void;
7
- private sanitizeOptions;
8
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TriggerCommand = void 0;
4
- const trigger_action_1 = require("./trigger.action");
5
- class TriggerCommand {
6
- actionHandler;
7
- constructor() {
8
- this.actionHandler = new trigger_action_1.TriggerAction();
9
- }
10
- load(program) {
11
- program
12
- .command('trigger')
13
- .description('Create new trigger')
14
- .requiredOption('--integration [integration]', 'Integration under which new trigger will be created')
15
- .action((options) => {
16
- const sanitizedOptions = this.sanitizeOptions(options);
17
- return this.actionHandler.handle(sanitizedOptions);
18
- });
19
- }
20
- sanitizeOptions(rawOptions) {
21
- return rawOptions;
22
- }
23
- }
24
- exports.TriggerCommand = TriggerCommand;
25
- //# sourceMappingURL=trigger.command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trigger.command.js","sourceRoot":"","sources":["../../../../src/commands/new/trigger/trigger.command.ts"],"names":[],"mappings":";;;AAGA,qDAAiD;AAMjD,MAAa,cAAc;IACjB,aAAa,CAAgB;IAErC;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,8BAAa,EAAE,CAAC;IAC3C,CAAC;IAKD,IAAI,CAAC,OAAgB;QACnB,OAAO;aACJ,OAAO,CAAC,SAAS,CAAC;aAClB,WAAW,CAAC,oBAAoB,CAAC;aACjC,cAAc,CACb,6BAA6B,EAC7B,qDAAqD,CACtD;aACA,MAAM,CAAC,CAAC,OAA8B,EAAE,EAAE;YACzC,MAAM,gBAAgB,GACpB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC;IAOO,eAAe,CACrB,UAAiC;QAEjC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAnCD,wCAmCC"}
@@ -1,3 +0,0 @@
1
- export type TriggerCommandOptions = {
2
- integration: string;
3
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=trigger.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trigger.types.js","sourceRoot":"","sources":["../../../../src/commands/new/trigger/trigger.types.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- import { StepDependencies } from '@useparagon/core';
2
- import { ICustomTrigger } from '../../apis';
3
- import { ICompiler } from '../compiler.interface';
4
- type TriggersCompilerInput = {
5
- projectRoot: string;
6
- integration: string;
7
- dependencies: StepDependencies;
8
- };
9
- export declare class TriggersCompiler implements ICompiler<TriggersCompilerInput, ICustomTrigger[]> {
10
- compile(options: TriggersCompilerInput): Promise<ICustomTrigger[]>;
11
- }
12
- export {};
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TriggersCompiler = void 0;
4
- const tslib_1 = require("tslib");
5
- const glob_1 = require("glob");
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- const uuid_1 = require("uuid");
8
- const resolvers_1 = require("@useparagon/core/resolvers");
9
- const request_1 = require("@useparagon/core/steps/library/request");
10
- const customTrigger_1 = require("@useparagon/core/triggers/customTrigger");
11
- const source_codegen_1 = require("../../codegen/codegens/source.codegen");
12
- const logger_1 = tslib_1.__importDefault(require("../../logger"));
13
- const compiler_utils_1 = require("../compiler.utils");
14
- class TriggersCompiler {
15
- async compile(options) {
16
- const { integration, projectRoot, dependencies } = options;
17
- const currentIntegrationPath = path_1.default.join(projectRoot, 'integrations', integration);
18
- const userTriggerPaths = await (0, glob_1.glob)('triggers/*.js', {
19
- nodir: true,
20
- cwd: currentIntegrationPath,
21
- });
22
- if (!userTriggerPaths.length) {
23
- return [];
24
- }
25
- const idToTriggerMap = {};
26
- for (const triggerPath of userTriggerPaths) {
27
- const userDefinedTrigger = (0, compiler_utils_1.requireSafe)(path_1.default.join(currentIntegrationPath, triggerPath));
28
- const trigger = new userDefinedTrigger();
29
- if (!(0, uuid_1.validate)(trigger.id)) {
30
- logger_1.default.fatal(`"${triggerPath}" id must be uuid.`);
31
- }
32
- const triggerContext = new customTrigger_1.CustomTriggerContext();
33
- const payloadValidationOptions = trigger.validatePayload(triggerContext);
34
- const serializedPayloadValidationOptions = (() => {
35
- if (!payloadValidationOptions ||
36
- payloadValidationOptions.scheme ===
37
- customTrigger_1.CustomTriggerPayloadValidationScheme.NONE) {
38
- return { scheme: customTrigger_1.CustomTriggerPayloadValidationScheme.NONE };
39
- }
40
- else if (payloadValidationOptions.scheme ===
41
- customTrigger_1.CustomTriggerPayloadValidationScheme.CUSTOM) {
42
- return {
43
- scheme: customTrigger_1.CustomTriggerPayloadValidationScheme.CUSTOM,
44
- code: payloadValidationOptions.code.toString(),
45
- parameters: (0, resolvers_1.resolveParamsToSources)(payloadValidationOptions.parameters || [], resolvers_1.DataType.STRING, undefined, dependencies),
46
- };
47
- }
48
- return {
49
- scheme: payloadValidationOptions.scheme,
50
- webhookSecret: (0, resolvers_1.resolveToTokenizedSource)(payloadValidationOptions.webhookSecret, resolvers_1.DataType.STRING, dependencies),
51
- webhookSignatureHeader: (0, resolvers_1.resolveToTokenizedSource)(payloadValidationOptions.webhookSignatureHeader, resolvers_1.DataType.STRING, dependencies),
52
- };
53
- })();
54
- const setupResponseOptions = trigger.setupResponse(triggerContext);
55
- const serializeSetupResponseOptions = (() => {
56
- let setupResponseSerializedOptions = {
57
- type: customTrigger_1.SetupResponseType.DEFAULT,
58
- };
59
- switch (setupResponseOptions?.type) {
60
- case customTrigger_1.SetupResponseInitType.CUSTOM_CODE:
61
- setupResponseSerializedOptions = {
62
- type: customTrigger_1.SetupResponseType.CUSTOM_CODE,
63
- code: setupResponseOptions.code.toString(),
64
- parameters: (0, resolvers_1.resolveParamsToSources)(setupResponseOptions.parameters || [], resolvers_1.DataType.STRING, undefined, dependencies),
65
- };
66
- break;
67
- case customTrigger_1.SetupResponseInitType.ECHO_REQUEST_BODY:
68
- setupResponseSerializedOptions = {
69
- type: customTrigger_1.SetupResponseType.ECHO_REQUEST_BODY,
70
- };
71
- break;
72
- case customTrigger_1.SetupResponseInitType.RESPOND_WITH_200:
73
- default:
74
- setupResponseSerializedOptions = {
75
- type: customTrigger_1.SetupResponseType.DEFAULT,
76
- };
77
- break;
78
- }
79
- return setupResponseSerializedOptions;
80
- })();
81
- const defaultOptions = {
82
- url: source_codegen_1.EMPTY_TOKENIZED_SOURCE,
83
- params: [],
84
- headers: [],
85
- body: [],
86
- bodyType: request_1.RequestBodyType.JSON,
87
- rawBody: source_codegen_1.EMPTY_TOKENIZED_SOURCE,
88
- };
89
- let setupApiOptions = defaultOptions;
90
- let teardownApiOptions = {
91
- ...defaultOptions,
92
- httpMethod: request_1.HttpMethod.DELETE,
93
- };
94
- if (trigger.triggerSubscription === 'PROGRAMMATIC') {
95
- const createFnResult = trigger.create(triggerContext);
96
- const isCreateJsonBody = !['xml', 'raw'].includes(createFnResult.bodyType);
97
- setupApiOptions = {
98
- url: (0, resolvers_1.resolveToTokenizedSource)(createFnResult.url, resolvers_1.DataType.STRING, dependencies),
99
- params: (0, resolvers_1.resolveParamsToSources)(createFnResult.params, resolvers_1.DataType.STRING, undefined, dependencies),
100
- headers: (0, resolvers_1.resolveParamsToSources)(createFnResult.headers, resolvers_1.DataType.STRING, undefined, dependencies),
101
- bodyType: createFnResult.bodyType,
102
- body: isCreateJsonBody
103
- ? (0, resolvers_1.resolveParamsToSources)(createFnResult.body, resolvers_1.DataType.ANY, undefined, dependencies)
104
- : [],
105
- rawBody: !isCreateJsonBody
106
- ? (0, resolvers_1.resolveToTokenizedSource)(createFnResult.body || '', resolvers_1.DataType.STRING, dependencies)
107
- : undefined,
108
- };
109
- const teardownFnResult = trigger.teardown(triggerContext);
110
- const isTeardownJsonBody = !['xml', 'raw'].includes(teardownFnResult.bodyType);
111
- teardownApiOptions = {
112
- httpMethod: request_1.HttpMethod.DELETE,
113
- url: (0, resolvers_1.resolveToTokenizedSource)(teardownFnResult.url, resolvers_1.DataType.STRING, dependencies),
114
- params: (0, resolvers_1.resolveParamsToSources)(teardownFnResult.params, resolvers_1.DataType.STRING, undefined, dependencies),
115
- headers: (0, resolvers_1.resolveParamsToSources)(teardownFnResult.headers, resolvers_1.DataType.STRING, undefined, dependencies),
116
- bodyType: teardownFnResult.bodyType,
117
- body: isTeardownJsonBody
118
- ? (0, resolvers_1.resolveParamsToSources)(teardownFnResult.body, resolvers_1.DataType.ANY, undefined, dependencies)
119
- : [],
120
- rawBody: !isTeardownJsonBody
121
- ? (0, resolvers_1.resolveToTokenizedSource)(teardownFnResult.body || '', resolvers_1.DataType.STRING, dependencies)
122
- : undefined,
123
- };
124
- }
125
- const userTrigger = {
126
- id: trigger.id,
127
- name: trigger.name || '',
128
- description: trigger.description || '',
129
- options: {
130
- setup: {
131
- ...setupApiOptions,
132
- httpMethod: request_1.HttpMethod.POST,
133
- response: serializeSetupResponseOptions,
134
- },
135
- tearDown: teardownApiOptions,
136
- triggerLevel: trigger.triggerLevel,
137
- triggerSubscription: trigger.triggerSubscription,
138
- payloadValidationOptions: serializedPayloadValidationOptions,
139
- },
140
- isConfigured: Boolean(trigger.isConfigured),
141
- };
142
- idToTriggerMap[userTrigger.id] = userTrigger;
143
- }
144
- return Object.values(idToTriggerMap);
145
- }
146
- }
147
- exports.TriggersCompiler = TriggersCompiler;
148
- //# sourceMappingURL=triggers.compiler.js.map
@@ -1 +0,0 @@
1
-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