@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
@@ -2,18 +2,176 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PushAction = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const prompts_1 = tslib_1.__importDefault(require("prompts"));
5
7
  const apis_1 = require("../../apis");
6
8
  const config_1 = require("../../config");
7
9
  const spinners_1 = tslib_1.__importDefault(require("../../helpers/spinners"));
10
+ const logger_1 = tslib_1.__importDefault(require("../../logger"));
11
+ const build_action_1 = require("../build/build.action");
12
+ const push_utils_1 = require("./push.utils");
13
+ const changeLog_compiler_1 = require("../../compiler/compilers/changeLog.compiler");
8
14
  class PushAction {
9
- async handle(_options) {
10
- const { projectId, projectName, rootPath } = await (0, config_1.getParagraphProjectDetails)();
15
+ buildAction;
16
+ changeLogCompiler;
17
+ projectBuild;
18
+ constructor() {
19
+ this.buildAction = new build_action_1.BuildAction();
20
+ this.changeLogCompiler = new changeLog_compiler_1.ChangeLogCompiler();
21
+ }
22
+ get isCI() {
23
+ try {
24
+ return JSON.parse(process.env['CI'] || 'false');
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
30
+ async getAndValidateStateBuild(rootPath, showRebuildPrompt = true) {
11
31
  const projectBuild = await (0, config_1.getLocalProjectBuild)(rootPath);
12
- spinners_1.default.add('writing-output', {
32
+ const { buildLastModified, sourceHash } = await (0, push_utils_1.getBuildSourceInfo)(rootPath);
33
+ if (projectBuild.buildHash === sourceHash) {
34
+ return projectBuild;
35
+ }
36
+ const buildLastModifiedDate = (0, push_utils_1.getFormattedDate)(buildLastModified);
37
+ logger_1.default.warn(`WARNING: Your last build was created on ${buildLastModifiedDate}, and some files have changed since then.\n`);
38
+ if (showRebuildPrompt) {
39
+ const { shouldRebuild } = await (0, prompts_1.default)({
40
+ type: 'select',
41
+ name: 'shouldRebuild',
42
+ message: 'Do you want to run a build again with your latest updates?',
43
+ choices: [
44
+ { title: '(y)es, build project', value: true },
45
+ {
46
+ title: `(n)o, use my build as of ${buildLastModifiedDate}`,
47
+ value: false,
48
+ },
49
+ ],
50
+ });
51
+ if (shouldRebuild) {
52
+ await this.buildAction.handle({
53
+ integration: [],
54
+ language: 'typescript',
55
+ skipTypeErrors: false,
56
+ includeDrafts: false,
57
+ });
58
+ return (0, config_1.getLocalProjectBuild)(rootPath);
59
+ }
60
+ }
61
+ return projectBuild;
62
+ }
63
+ printChangeLogMessages(messages) {
64
+ const allMessages = Object.values(messages).flat();
65
+ if (!allMessages.length) {
66
+ return;
67
+ }
68
+ logger_1.default.log('');
69
+ logger_1.default.log(chalk_1.default.bold('Changes:'));
70
+ allMessages.forEach((message) => logger_1.default.info(message));
71
+ }
72
+ printWarningMessages(warnings) {
73
+ if (!warnings.length) {
74
+ return;
75
+ }
76
+ logger_1.default.log('');
77
+ logger_1.default.log(chalk_1.default.bold('Warnings (* indicates action required):'));
78
+ warnings.forEach((warning, index) => {
79
+ logger_1.default.info(`${warning.resolvable ? '*' : ' '}[${index + 1}] ${warning.title}`);
80
+ });
81
+ }
82
+ async resolveWaring(input) {
83
+ const { id, title, isConfidential, entityType } = input;
84
+ const resolved = await (0, prompts_1.default)({
85
+ name: id,
86
+ type: isConfidential ? 'password' : 'text',
87
+ message: `Options:\n - ${title}\n - Cancel (^C)\n`,
88
+ });
89
+ if (!(id in resolved) || !this.projectBuild) {
90
+ return;
91
+ }
92
+ switch (entityType) {
93
+ case apis_1.ProjectEntity.Secret:
94
+ this.projectBuild.secrets = this.projectBuild.secrets.map((secret) => {
95
+ if (secret.key === id) {
96
+ return { ...secret, value: resolved[id] };
97
+ }
98
+ return secret;
99
+ });
100
+ logger_1.default.log('');
101
+ logger_1.default.success(`${id} will be set in this push.\n`);
102
+ break;
103
+ default:
104
+ logger_1.default.warn('Entity resolver not supported!');
105
+ break;
106
+ }
107
+ }
108
+ async confirmWarning(warnings) {
109
+ let selectedWarningNum;
110
+ const warningViewOptions = warnings.map((_, index) => index + 1);
111
+ while (true) {
112
+ logger_1.default.log('');
113
+ if (selectedWarningNum !== undefined &&
114
+ warnings[selectedWarningNum - 1]) {
115
+ const warning = warnings[selectedWarningNum - 1];
116
+ logger_1.default.log(chalk_1.default.bold(`WARNING [${selectedWarningNum}]\n`), '----');
117
+ logger_1.default.info(warning.description.trim(), '\n');
118
+ warning.resolvable
119
+ ? await this.resolveWaring(warning.input)
120
+ : logger_1.default.log(`\nNo action required.\n`);
121
+ }
122
+ const { warningAction } = await (0, prompts_1.default)({
123
+ type: 'text',
124
+ name: 'warningAction',
125
+ message: `Options:\n - Confirm push (y)\n - Cancel push (n)\n - ${warnings.length
126
+ ? `View Warning (${warningViewOptions.join(', ')})`
127
+ : ''}`,
128
+ });
129
+ if (warningAction === 'y') {
130
+ return true;
131
+ }
132
+ if (warningAction === 'n') {
133
+ return false;
134
+ }
135
+ if (!isNaN(warningAction) &&
136
+ warningAction > 0 &&
137
+ warningAction <= warnings.length) {
138
+ selectedWarningNum = warningAction;
139
+ }
140
+ else {
141
+ logger_1.default.info('Invalid input. Please try again.');
142
+ return false;
143
+ }
144
+ }
145
+ }
146
+ async handle(options) {
147
+ const shouldConfirmChanges = !options.y && !this.isCI;
148
+ const user = await (0, apis_1.getMe)();
149
+ const { projectId, projectName, rootPath } = await (0, config_1.getParagraphProjectDetails)();
150
+ logger_1.default.info(`You are about to push to the "${projectName}" project as ${user.email}. \n`);
151
+ const projectBuild = await this.getAndValidateStateBuild(rootPath, shouldConfirmChanges);
152
+ this.projectBuild = projectBuild;
153
+ const changeLog = await this.changeLogCompiler.compile({
154
+ updatedBuild: projectBuild,
155
+ });
156
+ this.printChangeLogMessages(changeLog.changeLogMessages);
157
+ this.printWarningMessages(changeLog.changeLogWarnings);
158
+ if (shouldConfirmChanges &&
159
+ !(await this.confirmWarning(changeLog.changeLogWarnings))) {
160
+ return;
161
+ }
162
+ spinners_1.default.add('pushing-output', {
13
163
  text: `Pushing changes to paragon cloud`,
14
164
  });
15
- await (0, apis_1.syncProject)({ ...projectBuild, projectId, projectName });
16
- spinners_1.default.succeed('writing-output', {
165
+ const projectBuildWithResolvedWarning = {
166
+ ...this.projectBuild,
167
+ secrets: this.projectBuild.secrets.filter((secret) => 'value' in secret && secret.value !== undefined),
168
+ };
169
+ await (0, apis_1.syncProject)({
170
+ ...projectBuildWithResolvedWarning,
171
+ projectId,
172
+ projectName,
173
+ });
174
+ spinners_1.default.succeed('pushing-output', {
17
175
  text: `Pushed changes to paragon cloud`,
18
176
  });
19
177
  }
@@ -1 +1 @@
1
- {"version":3,"file":"push.action.js","sourceRoot":"","sources":["../../../src/commands/push/push.action.ts"],"names":[],"mappings":";;;;AAAA,qCAAuD;AACvD,yCAAgF;AAChF,8EAA8C;AAO9C,MAAa,UAAU;IAIrB,KAAK,CAAC,MAAM,CAAC,QAA4B;QACvC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,GACxC,MAAM,IAAA,mCAA0B,GAAE,CAAC;QACrC,MAAM,YAAY,GAAiB,MAAM,IAAA,6BAAoB,EAAC,QAAQ,CAAC,CAAC;QAExE,kBAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE;YAC7B,IAAI,EAAE,kCAAkC;SACzC,CAAC,CAAC;QAEH,MAAM,IAAA,kBAAW,EAAC,EAAE,GAAG,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;QAE/D,kBAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACjC,IAAI,EAAE,iCAAiC;SACxC,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,gCAmBC"}
1
+ {"version":3,"file":"push.action.js","sourceRoot":"","sources":["../../../src/commands/push/push.action.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,8DAA8B;AAC9B,qCAOoB;AACpB,yCAAgF;AAChF,8EAA8C;AAC9C,kEAAkC;AAClC,wDAAoD;AAGpD,6CAAoE;AAMpE,oFAA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AAO,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAC5D;SACF,CAAC;QACF,MAAM,IAAA,kBAAW,EAAC;YAChB,GAAG,+BAA+B;YAClC,SAAS;YACT,WAAW;SACZ,CAAC,CAAC;QAEH,kBAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACjC,IAAI,EAAE,iCAAiC;SACxC,CAAC,CAAC;IACL,CAAC;CACF;AAvPD,gCAuPC"}
@@ -12,6 +12,7 @@ class PushCommand {
12
12
  program
13
13
  .command('push')
14
14
  .description('Push changes to cloud')
15
+ .option('-y', 'Skip showing change logs before para pull.', false)
15
16
  .action(async (rawOptions) => {
16
17
  const options = this.sanitizeOptions(rawOptions);
17
18
  await (0, base_api_1.getToken)();
@@ -1 +1 @@
1
- {"version":3,"file":"push.command.js","sourceRoot":"","sources":["../../../src/commands/push/push.command.ts"],"names":[],"mappings":";;;AAEA,kDAA+C;AAG/C,+CAA2C;AAM3C,MAAa,WAAW;IACd,aAAa,CAAa;IAElC;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAU,EAAE,CAAC;IACxC,CAAC;IAKD,IAAI,CAAC,OAAgB;QACnB,OAAO;aACJ,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,uBAAuB,CAAC;aACpC,MAAM,CAAC,KAAK,EAAE,UAA8B,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAGjD,MAAM,IAAA,mBAAQ,GAAE,CAAC;YAEjB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAOO,eAAe,CAAC,UAA8B;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAhCD,kCAgCC"}
1
+ {"version":3,"file":"push.command.js","sourceRoot":"","sources":["../../../src/commands/push/push.command.ts"],"names":[],"mappings":";;;AAEA,kDAA+C;AAG/C,+CAA2C;AAM3C,MAAa,WAAW;IACd,aAAa,CAAa;IAElC;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAU,EAAE,CAAC;IACxC,CAAC;IAKD,IAAI,CAAC,OAAgB;QACnB,OAAO;aACJ,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,uBAAuB,CAAC;aACpC,MAAM,CAAC,IAAI,EAAE,4CAA4C,EAAE,KAAK,CAAC;aACjE,MAAM,CAAC,KAAK,EAAE,UAA8B,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAGjD,MAAM,IAAA,mBAAQ,GAAE,CAAC;YAEjB,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAOO,eAAe,CAAC,UAA8B;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAjCD,kCAiCC"}
@@ -1 +1,3 @@
1
- export type PushCommandOptions = {};
1
+ export type PushCommandOptions = {
2
+ y?: boolean;
3
+ };
@@ -0,0 +1,5 @@
1
+ export declare const getBuildSourceInfo: (rootPath: string) => Promise<{
2
+ buildLastModified: Date;
3
+ sourceHash: string;
4
+ }>;
5
+ export declare const getFormattedDate: (date: Date) => string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFormattedDate = exports.getBuildSourceInfo = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const folder_hash_1 = require("folder-hash");
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const file_1 = require("../../helpers/file");
8
+ const getBuildSourceInfo = async (rootPath) => {
9
+ const buildLastModified = await (0, file_1.getFileLastModifiedDate)(path_1.default.join(rootPath, 'out', 'build.json'));
10
+ const currentSrcHash = await (0, folder_hash_1.hashElement)(path_1.default.join(rootPath, 'src'));
11
+ return {
12
+ buildLastModified,
13
+ sourceHash: currentSrcHash.hash,
14
+ };
15
+ };
16
+ exports.getBuildSourceInfo = getBuildSourceInfo;
17
+ const getFormattedDate = (date) => {
18
+ return new Intl.DateTimeFormat('en-US', {
19
+ dateStyle: 'long',
20
+ timeStyle: 'short',
21
+ }).format(date);
22
+ };
23
+ exports.getFormattedDate = getFormattedDate;
24
+ //# sourceMappingURL=push.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.utils.js","sourceRoot":"","sources":["../../../src/commands/push/push.utils.ts"],"names":[],"mappings":";;;;AAAA,6CAAyE;AACzE,wDAAwB;AAExB,6CAA6D;AAOtD,MAAM,kBAAkB,GAAG,KAAK,EACrC,QAAgB,EAIf,EAAE;IACH,MAAM,iBAAiB,GAAG,MAAM,IAAA,8BAAuB,EACrD,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC,CACzC,CAAC;IACF,MAAM,cAAc,GAAoB,MAAM,IAAA,yBAAU,EACtD,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,iBAAiB;QACjB,UAAU,EAAE,cAAc,CAAC,IAAI;KAChC,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,kBAAkB,sBAiB7B;AAOK,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAU,EAAE;IACrD,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QACtC,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,OAAO;KACnB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC,CAAC;AALW,QAAA,gBAAgB,oBAK3B"}
@@ -1,11 +1,46 @@
1
- import { ISecret } from '@useparagon/core/secret';
1
+ import { IEvent } from '@useparagon/core/event';
2
+ import { ISecret, SecretDTO } from '@useparagon/core/secret';
3
+ import { IntegrationBuild, ProjectEntity, WorkflowBuild } from '../apis/api.types';
2
4
  export type ProjectDependencies = {
3
5
  projectId: string;
4
6
  eventIdToNameMap: Record<string, string>;
5
- secrets: ISecret[];
7
+ secrets: (ISecret | SecretDTO)[];
6
8
  };
7
9
  export type WorkflowDependencies = ProjectDependencies & {
8
10
  integration: {
9
11
  name: string;
10
12
  };
11
13
  };
14
+ export type EntityIdBuildMap = {
15
+ [ProjectEntity.AppEvent]: Record<string, IEvent>;
16
+ [ProjectEntity.Integration]: Record<string, IntegrationBuild & {
17
+ integrationType: string;
18
+ }>;
19
+ [ProjectEntity.Workflow]: Record<string, WorkflowBuild & {
20
+ integrationType: string;
21
+ }>;
22
+ [ProjectEntity.IntegrationConfig]: Record<string, IntegrationBuild['config'] & {
23
+ integrationId: string;
24
+ }>;
25
+ [ProjectEntity.CustomIntegration]: Record<string, IntegrationBuild['customIntegration'] & {
26
+ integrationId: string;
27
+ }>;
28
+ [ProjectEntity.Step]: {
29
+ [stepId: string]: string;
30
+ };
31
+ };
32
+ export type WarningResolverInput = {
33
+ id: string;
34
+ title: string;
35
+ entityType: ProjectEntity;
36
+ isConfidential?: boolean;
37
+ };
38
+ export type ProjectBuildWarningMessage = {
39
+ title: string;
40
+ description: string;
41
+ } & ({
42
+ resolvable: false;
43
+ } | {
44
+ resolvable: true;
45
+ input: WarningResolverInput;
46
+ });
@@ -1,3 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const api_types_1 = require("../apis/api.types");
3
4
  //# sourceMappingURL=compiler.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.types.js","sourceRoot":"","sources":["../../src/compiler/compiler.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"compiler.types.js","sourceRoot":"","sources":["../../src/compiler/compiler.types.ts"],"names":[],"mappings":";;AAEA,iDAI2B"}
@@ -1,4 +1,11 @@
1
+ import { ProjectBuild } from 'src/apis';
2
+ import { EntityIdBuildMap } from './compiler.types';
1
3
  export declare const WORKFLOW_DRAFT_STATE_IDENTIFIER: string;
2
4
  export declare const extractKeyFromPath: (filePath: string) => string;
3
5
  export declare const requireSafe: <T>(filePath: string, onlyUseDefault?: boolean) => T;
4
6
  export declare const isWorkflowInDraftState: (filePath: string) => boolean;
7
+ export declare const projectBuildToEntityIdBuildMap: (updatedBuild: ProjectBuild, prevBuild?: ProjectBuild) => EntityIdBuildMap;
8
+ export declare const convertToCSV: (rows: Record<string, unknown>[], headerMap: {
9
+ title: string;
10
+ rowKey: string;
11
+ }[]) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isWorkflowInDraftState = exports.requireSafe = exports.extractKeyFromPath = exports.WORKFLOW_DRAFT_STATE_IDENTIFIER = void 0;
3
+ exports.convertToCSV = exports.projectBuildToEntityIdBuildMap = exports.isWorkflowInDraftState = exports.requireSafe = exports.extractKeyFromPath = exports.WORKFLOW_DRAFT_STATE_IDENTIFIER = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const path_1 = tslib_1.__importDefault(require("path"));
6
6
  const logger_1 = tslib_1.__importDefault(require("../logger"));
@@ -43,4 +43,75 @@ const isWorkflowInDraftState = (filePath) => {
43
43
  return false;
44
44
  };
45
45
  exports.isWorkflowInDraftState = isWorkflowInDraftState;
46
+ const projectBuildToEntityIdBuildMap = (updatedBuild, prevBuild) => {
47
+ const eventsMap = {
48
+ ...prevBuild?.events,
49
+ ...updatedBuild.events,
50
+ };
51
+ const integrationMap = {};
52
+ const integrationConfigMap = {};
53
+ const customIntegrationsMap = {};
54
+ const workflowMap = {};
55
+ let stepWorkflowIdMap = {};
56
+ const allIntegrationsTuple = [
57
+ ...Object.entries(prevBuild?.integrations || {}),
58
+ ...Object.entries(updatedBuild.integrations),
59
+ ];
60
+ allIntegrationsTuple.forEach((integrationTuple) => {
61
+ const [integrationType, integration] = integrationTuple;
62
+ if (!integration) {
63
+ return;
64
+ }
65
+ const { customIntegration, config } = integration;
66
+ integrationConfigMap[config.id] = {
67
+ ...config,
68
+ integrationId: integration.id,
69
+ };
70
+ integrationMap[integration.id] = {
71
+ ...integration,
72
+ integrationType,
73
+ };
74
+ if (customIntegration) {
75
+ customIntegrationsMap[customIntegration.id] = {
76
+ ...customIntegration,
77
+ integrationId: integration.id,
78
+ };
79
+ }
80
+ Object.values({
81
+ ...prevBuild?.integrations[integrationType]?.workflows,
82
+ ...updatedBuild.integrations[integrationType]?.workflows,
83
+ }).forEach((workflow) => {
84
+ if (workflow) {
85
+ stepWorkflowIdMap = {
86
+ ...stepWorkflowIdMap,
87
+ ...Object.fromEntries(workflow.steps.map(({ id }) => [id, workflow.id])),
88
+ };
89
+ workflowMap[workflow.id] = {
90
+ ...workflow,
91
+ integrationType: integrationType,
92
+ };
93
+ }
94
+ }, {});
95
+ });
96
+ return {
97
+ events: eventsMap,
98
+ workflows: workflowMap,
99
+ integrations: integrationMap,
100
+ configs: integrationConfigMap,
101
+ customIntegrations: customIntegrationsMap,
102
+ steps: stepWorkflowIdMap,
103
+ };
104
+ };
105
+ exports.projectBuildToEntityIdBuildMap = projectBuildToEntityIdBuildMap;
106
+ const convertToCSV = (rows, headerMap) => {
107
+ const replacer = (_, value) => value ?? '';
108
+ const headerKeys = headerMap.map(({ rowKey }) => rowKey);
109
+ const headerTitles = headerMap.map(({ title }) => title);
110
+ const csvString = [
111
+ headerTitles.join(','),
112
+ ...rows.map((row) => headerKeys.map((key) => JSON.stringify(row[key], replacer)).join(',')),
113
+ ].join('\r\n');
114
+ return csvString;
115
+ };
116
+ exports.convertToCSV = convertToCSV;
46
117
  //# sourceMappingURL=compiler.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.utils.js","sourceRoot":"","sources":["../../src/compiler/compiler.utils.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,+DAA+B;AAElB,QAAA,+BAA+B,GAAW,GAAG,CAAC;AAOpD,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC7D,MAAM,KA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AC,CAAC;AAzEW,QAAA,8BAA8B,kCAyEzC;AASK,MAAM,YAAY,GAAG,CAC1B,IAA+B,EAC/B,SAA8C,EACtC,EAAE;IACV,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAa,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,YAAY,GAAa,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAEnE,MAAM,SAAS,GAAG;QAChB,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QACtB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAClB,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACtE;KACF,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEf,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAhBW,QAAA,YAAY,gBAgBvB"}
@@ -0,0 +1,22 @@
1
+ import { ISecret, SecretDTO } from '@useparagon/core/secret';
2
+ import { AffectedPersona, EntityDiffBase, IntegrationInputChangeLog, ProjectBuild, ProjectComparison, ProjectEntity, WorkflowDefaultEnableChangeLog } from '../../apis';
3
+ import { ProjectChangeLog } from '../../commands/build/build.types';
4
+ import { ICompiler } from '../compiler.interface';
5
+ import { ProjectBuildWarningMessage } from '../compiler.types';
6
+ type ChangeLogCompilerInput = {
7
+ updatedBuild: ProjectBuild;
8
+ };
9
+ export declare class ChangeLogCompiler implements ICompiler<ChangeLogCompilerInput, ProjectChangeLog> {
10
+ private entityIdBuildMap;
11
+ private integrationNameMap;
12
+ saveAffectedUsersToCsv(persona: AffectedPersona[], suffix?: string): Promise<string>;
13
+ getChangelogMessages(ids: string[], entityType: ProjectEntity, operationType: keyof EntityDiffBase): string[];
14
+ generateEntityChangelog(diff: ProjectComparison['comparisonDiff']): Record<keyof EntityDiffBase, string[]>;
15
+ generateDefaultEnabledWorkflowWarning(defaultEnabledWorkflowChangelogs: WorkflowDefaultEnableChangeLog[]): Promise<ProjectBuildWarningMessage[]>;
16
+ generateRequiredSettingWarning(requiredSettings: IntegrationInputChangeLog[]): Promise<ProjectBuildWarningMessage[]>;
17
+ generateDisabledIntegrationWarning(disabledIntegrations: string[]): ProjectBuildWarningMessage[];
18
+ generateIntegrationOauthConfigRequiredWarning(integrationTypes: string[]): ProjectBuildWarningMessage[];
19
+ generateNewSecretsWarnings(secretDependencies: (ISecret | SecretDTO)[]): ProjectBuildWarningMessage[];
20
+ compile(options: ChangeLogCompilerInput): Promise<ProjectChangeLog>;
21
+ }
22
+ export {};
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangeLogCompiler = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const apis_1 = require("../../apis");
7
+ const compiler_utils_1 = require("../compiler.utils");
8
+ class ChangeLogCompiler {
9
+ entityIdBuildMap = {
10
+ events: {},
11
+ workflows: {},
12
+ configs: {},
13
+ customIntegrations: {},
14
+ integrations: {},
15
+ steps: {},
16
+ };
17
+ integrationNameMap = {};
18
+ async saveAffectedUsersToCsv(persona, suffix = '') {
19
+ const headerMap = [
20
+ { title: 'User Id', rowKey: 'endUserId' },
21
+ { title: 'Name', rowKey: 'name' },
22
+ { title: 'Email', rowKey: 'email' },
23
+ ];
24
+ const csvString = (0, compiler_utils_1.convertToCSV)(persona, headerMap);
25
+ const today = new Date().toLocaleDateString('en-GB', {
26
+ month: '2-digit',
27
+ day: '2-digit',
28
+ year: 'numeric',
29
+ });
30
+ const timeStamp = today.split('/').reverse().join('');
31
+ const sanitizedSuffix = suffix.replace(/\s/g, '-').toLowerCase().trim();
32
+ const fileName = `affected-users-${timeStamp}-${sanitizedSuffix}.csv`;
33
+ const filePath = `/tmp/${fileName}`;
34
+ await fs_1.default.promises.writeFile(filePath, csvString);
35
+ return filePath;
36
+ }
37
+ getChangelogMessages(ids, entityType, operationType) {
38
+ const operationTypeSignMap = {
39
+ added: '+',
40
+ updated: '~',
41
+ deleted: '-',
42
+ };
43
+ const diffToChangeLogMessages = ids
44
+ .map((entityId) => {
45
+ const operationTypeSign = operationTypeSignMap[operationType];
46
+ switch (entityType) {
47
+ case apis_1.ProjectEntity.AppEvent:
48
+ const eventName = this.entityIdBuildMap.events[entityId]?.name;
49
+ return `${operationTypeSign} App Event: "${eventName}" ${operationType}`;
50
+ case apis_1.ProjectEntity.Workflow:
51
+ const { name: workflowName, integrationType: workflowIntegrationType, } = this.entityIdBuildMap.workflows?.[entityId] || {};
52
+ return `${operationTypeSign} ${this.integrationNameMap[workflowIntegrationType]}: "${workflowName}" workflow ${operationType}`;
53
+ case apis_1.ProjectEntity.Integration:
54
+ const integrationType = this.entityIdBuildMap.integrations[entityId]?.integrationType;
55
+ return `${operationTypeSign} ${this.integrationNameMap[integrationType]}: Integration ${operationType}`;
56
+ default:
57
+ return;
58
+ }
59
+ })
60
+ .filter((msg) => Boolean(msg));
61
+ return diffToChangeLogMessages;
62
+ }
63
+ generateEntityChangelog(diff) {
64
+ const allChangeLogMessages = {
65
+ added: [],
66
+ updated: [],
67
+ deleted: [],
68
+ };
69
+ const updatedSteps = diff.steps
70
+ ? [...diff.steps.added, ...diff.steps.deleted, ...diff.steps.updated]
71
+ : [];
72
+ if (updatedSteps.length) {
73
+ updatedSteps.forEach((stepId) => {
74
+ const stepWorkflowId = this.entityIdBuildMap.steps[stepId];
75
+ if (stepWorkflowId &&
76
+ !diff.workflows?.added.includes(stepWorkflowId) &&
77
+ !diff.workflows?.updated.includes(stepWorkflowId) &&
78
+ !diff.workflows?.deleted.includes(stepWorkflowId)) {
79
+ diff.workflows?.updated.push(stepWorkflowId);
80
+ }
81
+ });
82
+ }
83
+ if (diff.configs?.updated.length) {
84
+ diff.configs.updated.forEach((configId) => {
85
+ const configIntegrationId = this.entityIdBuildMap.configs[configId].integrationId;
86
+ if (!diff.integrations?.updated.includes(configIntegrationId)) {
87
+ diff.integrations?.updated.push(configIntegrationId);
88
+ }
89
+ });
90
+ }
91
+ if (diff.customIntegrations?.updated.length) {
92
+ diff.customIntegrations.updated.forEach((id) => {
93
+ const integrationId = this.entityIdBuildMap.customIntegrations[id].integrationId;
94
+ if (!diff.integrations?.updated.includes(integrationId)) {
95
+ diff.integrations?.updated.push(integrationId);
96
+ }
97
+ });
98
+ }
99
+ for (const entityType in diff) {
100
+ const entityDiff = diff[entityType];
101
+ Object.keys(allChangeLogMessages).forEach((operationType) => {
102
+ allChangeLogMessages[operationType].push(...this.getChangelogMessages(entityDiff[operationType], entityType, operationType));
103
+ });
104
+ }
105
+ return allChangeLogMessages;
106
+ }
107
+ generateDefaultEnabledWorkflowWarning(defaultEnabledWorkflowChangelogs) {
108
+ return Promise.all(defaultEnabledWorkflowChangelogs.map(async (changeLog) => {
109
+ const { integrationType, name } = this.entityIdBuildMap.workflows[changeLog.workflowId] || {};
110
+ const title = `${integrationType}: ${name} workflow will be enabled by default for all users.`;
111
+ const affectedUsersFilePath = await this.saveAffectedUsersToCsv(changeLog.affectedUsers, name);
112
+ return {
113
+ title,
114
+ resolvable: false,
115
+ description: `${title}\n This workflow has been set to be enabled by default for users already connected to the ${integrationType} integration.\n\n Saved affected users to ${affectedUsersFilePath}.`,
116
+ };
117
+ }));
118
+ }
119
+ generateRequiredSettingWarning(requiredSettings) {
120
+ return Promise.all(requiredSettings.map(async (setting) => {
121
+ const { integrationType, inputTitle } = setting;
122
+ const title = `${integrationType}: ${inputTitle} was added as a required User Setting.`;
123
+ const affectedUsersFilePath = await this.saveAffectedUsersToCsv(setting.affectedUsers, inputTitle);
124
+ return {
125
+ title,
126
+ resolvable: false,
127
+ description: `${title}\n Existing ${integrationType} integration users may need to revisit the Connect Portal.\n\n Saved affected users to ${affectedUsersFilePath}.`,
128
+ };
129
+ }));
130
+ }
131
+ generateDisabledIntegrationWarning(disabledIntegrations) {
132
+ const disabledIntegrationWarnings = disabledIntegrations.map((integrationId) => {
133
+ const integrationName = this.entityIdBuildMap.integrations[integrationId]?.integrationType;
134
+ const title = `${integrationName}: Connected ${integrationName} accounts will be paused.`;
135
+ return {
136
+ title,
137
+ resolvable: false,
138
+ description: `${integrationName}: Connected ${integrationName} accounts will be paused while this integration is disabled.\n ${integrationName} workflows will not execute while accounts are paused.`,
139
+ };
140
+ });
141
+ return disabledIntegrationWarnings;
142
+ }
143
+ generateIntegrationOauthConfigRequiredWarning(integrationTypes) {
144
+ return integrationTypes.map((integrationType) => {
145
+ const title = `${integrationType}: OAuth App will use dev credentials.`;
146
+ return {
147
+ title,
148
+ resolvable: false,
149
+ description: `${integrationType} requires an OAuth App to connect production users on behalf of your app.\n Paragon's dev credentials will be used by default, but you can replace them by visiting ${integrationType} in the Paragon dashboard.`,
150
+ };
151
+ });
152
+ }
153
+ generateNewSecretsWarnings(secretDependencies) {
154
+ const newSecretsDTOs = secretDependencies.filter((secret) => !('id' in secret));
155
+ return newSecretsDTOs.map(({ key }) => {
156
+ const title = `Environment Secret "${key}" is not defined for this project.`;
157
+ return {
158
+ title,
159
+ description: `${title}\n`,
160
+ resolvable: true,
161
+ input: {
162
+ id: key,
163
+ title: 'Set a value for this Environment Secret',
164
+ entityType: apis_1.ProjectEntity.Secret,
165
+ isConfidential: true,
166
+ },
167
+ };
168
+ });
169
+ }
170
+ async compile(options) {
171
+ const { updatedBuild } = options;
172
+ const { secrets, ...buildToCompare } = updatedBuild;
173
+ const previousBuild = await (0, apis_1.getProjectBuild)(updatedBuild.projectId);
174
+ this.entityIdBuildMap = (0, compiler_utils_1.projectBuildToEntityIdBuildMap)(updatedBuild, previousBuild);
175
+ const { integrationNameMap, comparisonDiff, integrationsRequiredOauthConfig, defaultEnabledWorkflows, disabledIntegrations, requiredSettings, } = await (0, apis_1.getProjectBuildComparison)({
176
+ ...buildToCompare,
177
+ secrets: [],
178
+ });
179
+ this.integrationNameMap = { ...integrationNameMap };
180
+ const changeLogMessages = this.generateEntityChangelog(comparisonDiff);
181
+ const newIntegrationRequiredConfigWarnings = this.generateIntegrationOauthConfigRequiredWarning(integrationsRequiredOauthConfig);
182
+ const defaultEnableWarnings = await this.generateDefaultEnabledWorkflowWarning(defaultEnabledWorkflows);
183
+ const requiredSettingWarnings = await this.generateRequiredSettingWarning(requiredSettings);
184
+ const disabledIntegrationWarnings = this.generateDisabledIntegrationWarning(disabledIntegrations);
185
+ const newSecretWarnings = this.generateNewSecretsWarnings(updatedBuild.secrets);
186
+ return {
187
+ changeLogMessages,
188
+ changeLogWarnings: [
189
+ ...newSecretWarnings,
190
+ ...newIntegrationRequiredConfigWarnings,
191
+ ...defaultEnableWarnings,
192
+ ...requiredSettingWarnings,
193
+ ...disabledIntegrationWarnings,
194
+ ],
195
+ };
196
+ }
197
+ }
198
+ exports.ChangeLogCompiler = ChangeLogCompiler;
199
+ //# sourceMappingURL=changeLog.compiler.js.map