@useparagon/cli 0.0.1-canary.1

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 (207) hide show
  1. package/dist/codegen/codegen.types.d.ts +9 -0
  2. package/dist/codegen/codegen.types.js +3 -0
  3. package/dist/codegen/codegen.types.js.map +1 -0
  4. package/dist/codegen/codegen.utils.d.ts +4 -0
  5. package/dist/codegen/codegen.utils.js +70 -0
  6. package/dist/codegen/codegen.utils.js.map +1 -0
  7. package/dist/codegen/codegens/condition.codegen.d.ts +2 -0
  8. package/dist/codegen/codegens/condition.codegen.js +28 -0
  9. package/dist/codegen/codegens/condition.codegen.js.map +1 -0
  10. package/dist/codegen/codegens/event.codegen.d.ts +2 -0
  11. package/dist/codegen/codegens/event.codegen.js +35 -0
  12. package/dist/codegen/codegens/event.codegen.js.map +1 -0
  13. package/dist/codegen/codegens/integration.codegen.d.ts +2 -0
  14. package/dist/codegen/codegens/integration.codegen.js +18 -0
  15. package/dist/codegen/codegens/integration.codegen.js.map +1 -0
  16. package/dist/codegen/codegens/source.codegen.d.ts +5 -0
  17. package/dist/codegen/codegens/source.codegen.js +104 -0
  18. package/dist/codegen/codegens/source.codegen.js.map +1 -0
  19. package/dist/codegen/codegens/workflow.codegen.d.ts +3 -0
  20. package/dist/codegen/codegens/workflow.codegen.js +278 -0
  21. package/dist/codegen/codegens/workflow.codegen.js.map +1 -0
  22. package/dist/commands/build/build.action.d.ts +8 -0
  23. package/dist/commands/build/build.action.js +49 -0
  24. package/dist/commands/build/build.action.js.map +1 -0
  25. package/dist/commands/build/build.command.d.ts +8 -0
  26. package/dist/commands/build/build.command.js +27 -0
  27. package/dist/commands/build/build.command.js.map +1 -0
  28. package/dist/commands/build/build.types.d.ts +6 -0
  29. package/dist/commands/build/build.types.js +3 -0
  30. package/dist/commands/build/build.types.js.map +1 -0
  31. package/dist/commands/build/build.utils.d.ts +1 -0
  32. package/dist/commands/build/build.utils.js +17 -0
  33. package/dist/commands/build/build.utils.js.map +1 -0
  34. package/dist/commands/build/index.d.ts +1 -0
  35. package/dist/commands/build/index.js +5 -0
  36. package/dist/commands/build/index.js.map +1 -0
  37. package/dist/commands/command.interface.d.ts +7 -0
  38. package/dist/commands/command.interface.js +3 -0
  39. package/dist/commands/command.interface.js.map +1 -0
  40. package/dist/commands/command.loader.d.ts +5 -0
  41. package/dist/commands/command.loader.js +27 -0
  42. package/dist/commands/command.loader.js.map +1 -0
  43. package/dist/commands/index.d.ts +2 -0
  44. package/dist/commands/index.js +6 -0
  45. package/dist/commands/index.js.map +1 -0
  46. package/dist/commands/init/index.d.ts +1 -0
  47. package/dist/commands/init/index.js +5 -0
  48. package/dist/commands/init/index.js.map +1 -0
  49. package/dist/commands/init/init.action.d.ts +11 -0
  50. package/dist/commands/init/init.action.js +92 -0
  51. package/dist/commands/init/init.action.js.map +1 -0
  52. package/dist/commands/init/init.command.d.ts +8 -0
  53. package/dist/commands/init/init.command.js +27 -0
  54. package/dist/commands/init/init.command.js.map +1 -0
  55. package/dist/commands/init/init.constants.d.ts +1 -0
  56. package/dist/commands/init/init.constants.js +21 -0
  57. package/dist/commands/init/init.constants.js.map +1 -0
  58. package/dist/commands/init/init.types.d.ts +7 -0
  59. package/dist/commands/init/init.types.js +3 -0
  60. package/dist/commands/init/init.types.js.map +1 -0
  61. package/dist/commands/init/init.utils.d.ts +11 -0
  62. package/dist/commands/init/init.utils.js +50 -0
  63. package/dist/commands/init/init.utils.js.map +1 -0
  64. package/dist/commands/login/index.d.ts +1 -0
  65. package/dist/commands/login/index.js +5 -0
  66. package/dist/commands/login/index.js.map +1 -0
  67. package/dist/commands/login/login.command.d.ts +5 -0
  68. package/dist/commands/login/login.command.js +26 -0
  69. package/dist/commands/login/login.command.js.map +1 -0
  70. package/dist/commands/login/login.types.d.ts +3 -0
  71. package/dist/commands/login/login.types.js +3 -0
  72. package/dist/commands/login/login.types.js.map +1 -0
  73. package/dist/commands/login/login.utils.d.ts +2 -0
  74. package/dist/commands/login/login.utils.js +47 -0
  75. package/dist/commands/login/login.utils.js.map +1 -0
  76. package/dist/compilers/compiler.interface.d.ts +3 -0
  77. package/dist/compilers/compiler.interface.js +3 -0
  78. package/dist/compilers/compiler.interface.js.map +1 -0
  79. package/dist/compilers/compiler.types.d.ts +23 -0
  80. package/dist/compilers/compiler.types.js +3 -0
  81. package/dist/compilers/compiler.types.js.map +1 -0
  82. package/dist/compilers/compiler.utils.d.ts +2 -0
  83. package/dist/compilers/compiler.utils.js +25 -0
  84. package/dist/compilers/compiler.utils.js.map +1 -0
  85. package/dist/compilers/event.compiler.d.ts +7 -0
  86. package/dist/compilers/event.compiler.js +25 -0
  87. package/dist/compilers/event.compiler.js.map +1 -0
  88. package/dist/compilers/integration.compiler.d.ts +9 -0
  89. package/dist/compilers/integration.compiler.js +55 -0
  90. package/dist/compilers/integration.compiler.js.map +1 -0
  91. package/dist/compilers/project.compiler.d.ts +10 -0
  92. package/dist/compilers/project.compiler.js +50 -0
  93. package/dist/compilers/project.compiler.js.map +1 -0
  94. package/dist/compilers/ts.compiler.d.ts +11 -0
  95. package/dist/compilers/ts.compiler.js +70 -0
  96. package/dist/compilers/ts.compiler.js.map +1 -0
  97. package/dist/compilers/workflow.compiler.d.ts +10 -0
  98. package/dist/compilers/workflow.compiler.js +36 -0
  99. package/dist/compilers/workflow.compiler.js.map +1 -0
  100. package/dist/config/config.constants.d.ts +4 -0
  101. package/dist/config/config.constants.js +12 -0
  102. package/dist/config/config.constants.js.map +1 -0
  103. package/dist/config/config.types.d.ts +31 -0
  104. package/dist/config/config.types.js +18 -0
  105. package/dist/config/config.types.js.map +1 -0
  106. package/dist/config/config.utils.d.ts +9 -0
  107. package/dist/config/config.utils.js +136 -0
  108. package/dist/config/config.utils.js.map +1 -0
  109. package/dist/config/index.d.ts +2 -0
  110. package/dist/config/index.js +6 -0
  111. package/dist/config/index.js.map +1 -0
  112. package/dist/helpers/constants.d.ts +2 -0
  113. package/dist/helpers/constants.js +6 -0
  114. package/dist/helpers/constants.js.map +1 -0
  115. package/dist/helpers/json.d.ts +1 -0
  116. package/dist/helpers/json.js +8 -0
  117. package/dist/helpers/json.js.map +1 -0
  118. package/dist/helpers/spinners.d.ts +3 -0
  119. package/dist/helpers/spinners.js +6 -0
  120. package/dist/helpers/spinners.js.map +1 -0
  121. package/dist/helpers/strings.d.ts +1 -0
  122. package/dist/helpers/strings.js +8 -0
  123. package/dist/helpers/strings.js.map +1 -0
  124. package/dist/index.d.ts +4 -0
  125. package/dist/index.js +16 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/logger/index.d.ts +1 -0
  128. package/dist/logger/index.js +9 -0
  129. package/dist/logger/index.js.map +1 -0
  130. package/dist/logger/logger.d.ts +3 -0
  131. package/dist/logger/logger.js +50 -0
  132. package/dist/logger/logger.js.map +1 -0
  133. package/dist/logger/logger.type.d.ts +8 -0
  134. package/dist/logger/logger.type.js +3 -0
  135. package/dist/logger/logger.type.js.map +1 -0
  136. package/dist/templates/configurations/javascript/.prettierignore +2 -0
  137. package/dist/templates/configurations/javascript/.prettierrc +11 -0
  138. package/dist/templates/configurations/typescript/.prettierignore +2 -0
  139. package/dist/templates/configurations/typescript/.prettierrc +19 -0
  140. package/dist/templates/javascript/src/events/hello-world.js +13 -0
  141. package/dist/templates/javascript/src/integrations/slack/config.js +11 -0
  142. package/dist/templates/javascript/src/integrations/slack/workflows/example-workflow.js +30 -0
  143. package/dist/templates/typescript/src/events/hello-world.ts +21 -0
  144. package/dist/templates/typescript/src/integrations/slack/config.ts +18 -0
  145. package/dist/templates/typescript/src/integrations/slack/workflows/example-workflow.ts +30 -0
  146. package/dist/templates/typescript/tsconfig.json +31 -0
  147. package/package.json +56 -0
  148. package/paragon.json +3 -0
  149. package/sample/sample.js +404 -0
  150. package/src/codegen/codegen.types.ts +14 -0
  151. package/src/codegen/codegen.utils.ts +145 -0
  152. package/src/codegen/codegens/condition.codegen.ts +49 -0
  153. package/src/codegen/codegens/event.codegen.ts +39 -0
  154. package/src/codegen/codegens/integration.codegen.ts +23 -0
  155. package/src/codegen/codegens/source.codegen.ts +193 -0
  156. package/src/codegen/codegens/workflow.codegen.ts +495 -0
  157. package/src/commands/build/build.action.ts +73 -0
  158. package/src/commands/build/build.command.ts +61 -0
  159. package/src/commands/build/build.types.ts +7 -0
  160. package/src/commands/build/build.utils.ts +21 -0
  161. package/src/commands/build/index.ts +1 -0
  162. package/src/commands/command.interface.ts +22 -0
  163. package/src/commands/command.loader.ts +33 -0
  164. package/src/commands/index.ts +2 -0
  165. package/src/commands/init/index.ts +1 -0
  166. package/src/commands/init/init.action.ts +166 -0
  167. package/src/commands/init/init.command.ts +71 -0
  168. package/src/commands/init/init.constants.ts +29 -0
  169. package/src/commands/init/init.types.ts +8 -0
  170. package/src/commands/init/init.utils.ts +91 -0
  171. package/src/commands/login/index.ts +1 -0
  172. package/src/commands/login/login.command.ts +48 -0
  173. package/src/commands/login/login.types.ts +9 -0
  174. package/src/commands/login/login.utils.ts +68 -0
  175. package/src/compilers/compiler.interface.ts +9 -0
  176. package/src/compilers/compiler.types.ts +52 -0
  177. package/src/compilers/compiler.utils.ts +32 -0
  178. package/src/compilers/event.compiler.ts +33 -0
  179. package/src/compilers/integration.compiler.ts +84 -0
  180. package/src/compilers/project.compiler.ts +86 -0
  181. package/src/compilers/ts.compiler.ts +116 -0
  182. package/src/compilers/workflow.compiler.ts +69 -0
  183. package/src/config/config.constants.ts +27 -0
  184. package/src/config/config.types.ts +112 -0
  185. package/src/config/config.utils.ts +251 -0
  186. package/src/config/index.ts +2 -0
  187. package/src/helpers/constants.ts +9 -0
  188. package/src/helpers/json.ts +8 -0
  189. package/src/helpers/spinners.ts +3 -0
  190. package/src/helpers/strings.ts +9 -0
  191. package/src/index.ts +26 -0
  192. package/src/logger/index.ts +1 -0
  193. package/src/logger/logger.ts +97 -0
  194. package/src/logger/logger.type.ts +8 -0
  195. package/templates/configurations/javascript/.prettierignore +2 -0
  196. package/templates/configurations/javascript/.prettierrc +11 -0
  197. package/templates/configurations/typescript/.prettierignore +2 -0
  198. package/templates/configurations/typescript/.prettierrc +19 -0
  199. package/templates/javascript/src/events/hello-world.js +13 -0
  200. package/templates/javascript/src/integrations/slack/config.js +11 -0
  201. package/templates/javascript/src/integrations/slack/workflows/example-workflow.js +30 -0
  202. package/templates/typescript/src/events/hello-world.ts +21 -0
  203. package/templates/typescript/src/integrations/slack/config.ts +18 -0
  204. package/templates/typescript/src/integrations/slack/workflows/example-workflow.ts +30 -0
  205. package/templates/typescript/tsconfig.json +31 -0
  206. package/tsconfig.json +13 -0
  207. package/tsconfig.release.json +13 -0
@@ -0,0 +1,404 @@
1
+ module.exports.samplebuild = {
2
+ events: {
3
+ '4d26c381-fb4a-4a20-b95d-bacd4acd4291': {
4
+ id: '4d26c381-fb4a-4a20-b95d-bacd4acd4291',
5
+ name: 'hello',
6
+ schema: {
7
+ message: 'Hellow world',
8
+ },
9
+ },
10
+ '1a41436a-2e4d-4c12-8e32-16a408938fd3': {
11
+ id: '1a41436a-2e4d-4c12-8e32-16a408938fd3',
12
+ name: 'hello',
13
+ schema: {
14
+ message: 'Hello, World!',
15
+ nested: {
16
+ value: {
17
+ count: 20,
18
+ },
19
+ },
20
+ },
21
+ },
22
+ },
23
+ integrations: {
24
+ 'custom.dummyJson': {
25
+ config: {
26
+ default: {
27
+ description: 'A dummy BYO integration.',
28
+ overviewText:
29
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n \n Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n \n Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n \n Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
30
+ scopes: 'user:read',
31
+ },
32
+ },
33
+ workflows: {
34
+ '4d26c381-fb4a-4a20-b95d-bacd4acd4291': {
35
+ id: '4d26c381-fb4a-4a20-b95d-bacd4acd4291',
36
+ name: '01-simple-event',
37
+ stateMachine: {
38
+ stepMap: {
39
+ 'b11b1604-a39a-442b-8963-721e6c9bb747': {
40
+ id: 'b11b1604-a39a-442b-8963-721e6c9bb747',
41
+ dateCreated: '2023-11-01T13:54:18.081Z',
42
+ dateUpdated: '2023-11-01T13:56:44.972Z',
43
+ description: 'description',
44
+ type: 'TRANSITION/IFELSE',
45
+ parameters: {
46
+ choices: [
47
+ {
48
+ next: null,
49
+ label: 'Yes',
50
+ isDefault: false,
51
+ conditionWrapper: {
52
+ join: 'OR',
53
+ type: 'JOIN',
54
+ conditions: [
55
+ {
56
+ join: 'AND',
57
+ type: 'JOIN',
58
+ conditions: [
59
+ {
60
+ type: 'OPERATOR',
61
+ condition: {
62
+ operator: '$booleanTrue',
63
+ variable: {
64
+ path: ['result', 'num'],
65
+ type: 'VARIABLE',
66
+ stepId:
67
+ '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
68
+ dataType: 'BOOLEAN',
69
+ },
70
+ },
71
+ },
72
+ {
73
+ type: 'OPERATOR',
74
+ condition: {
75
+ argument: {
76
+ type: 'VALUE',
77
+ value: 'paragon',
78
+ dataType: 'STRING',
79
+ },
80
+ operator: '$stringContains',
81
+ variable: {
82
+ path: ['result', 'str'],
83
+ type: 'VARIABLE',
84
+ stepId:
85
+ '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
86
+ dataType: 'STRING',
87
+ },
88
+ },
89
+ },
90
+ ],
91
+ },
92
+ ],
93
+ },
94
+ },
95
+ {
96
+ next: '2f7edb3f-1b58-4b80-be08-67f85ed6afea',
97
+ label: 'No',
98
+ isDefault: true,
99
+ },
100
+ ],
101
+ },
102
+ next: 'd4f2bf7d-4610-4625-9314-02c9be9dc43b',
103
+ status: 'INVALID',
104
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
105
+ },
106
+ '2f7edb3f-1b58-4b80-be08-67f85ed6afea': {
107
+ id: '2f7edb3f-1b58-4b80-be08-67f85ed6afea',
108
+ dateCreated: '2023-11-01T13:56:41.950Z',
109
+ dateUpdated: '2023-11-01T13:57:03.174Z',
110
+ description: 'description',
111
+ type: 'ACTION/FUNCTION',
112
+ parameters: {
113
+ code: 'function yourFunction(parameters, libraries) {\nreturn [1,2,3]\n}',
114
+ parameters: [],
115
+ },
116
+ next: '82f21fb0-e712-4cb8-b2ec-70fa0ffc5568',
117
+ status: 'INVALID',
118
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
119
+ },
120
+ '82f21fb0-e712-4cb8-b2ec-70fa0ffc5568': {
121
+ id: '82f21fb0-e712-4cb8-b2ec-70fa0ffc5568',
122
+ dateCreated: '2023-11-01T13:57:00.178Z',
123
+ dateUpdated: '2023-11-01T13:57:14.448Z',
124
+ description: 'description',
125
+ type: 'TRANSITION/MAP',
126
+ parameters: {
127
+ iterator: {
128
+ path: ['result'],
129
+ type: 'VARIABLE',
130
+ stepId: '2f7edb3f-1b58-4b80-be08-67f85ed6afea',
131
+ dataType: 'ARRAY',
132
+ },
133
+ nextToIterate: 'd9c96e6e-9a34-4c6c-8428-578023056934',
134
+ },
135
+ next: null,
136
+ status: 'INVALID',
137
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
138
+ },
139
+ 'd4f2bf7d-4610-4625-9314-02c9be9dc43b': {
140
+ id: 'd4f2bf7d-4610-4625-9314-02c9be9dc43b',
141
+ dateCreated: '2023-11-01T13:56:32.611Z',
142
+ dateUpdated: '2023-11-01T13:56:32.611Z',
143
+ description: 'description',
144
+ type: 'ACTION/RESPONSE',
145
+ parameters: {
146
+ bodyData: [],
147
+ statusCode: 200,
148
+ responseType: 'JSON',
149
+ },
150
+ next: null,
151
+ status: 'INVALID',
152
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
153
+ },
154
+ 'd9c96e6e-9a34-4c6c-8428-578023056934': {
155
+ id: 'd9c96e6e-9a34-4c6c-8428-578023056934',
156
+ dateCreated: '2023-11-01T13:57:14.448Z',
157
+ dateUpdated: '2023-11-01T13:57:14.448Z',
158
+ description: 'description',
159
+ type: 'ACTION/FUNCTION',
160
+ parameters: {
161
+ code: 'function yourFunction(parameters, libraries) {\nreturn "success"\n}',
162
+ parameters: [],
163
+ },
164
+ next: null,
165
+ status: 'INVALID',
166
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
167
+ },
168
+ '22e7f997-de29-410d-be06-7b87fbfbd77b': {
169
+ id: '22e7f997-de29-410d-be06-7b87fbfbd77b',
170
+ dateCreated: '2023-11-01T13:53:20.128Z',
171
+ dateUpdated: '2023-11-01T13:53:35.597Z',
172
+ description: 'Trigger',
173
+ type: 'TRIGGER/CRON',
174
+ parameters: {
175
+ schedule: {
176
+ unit: 'MINUTES',
177
+ minutes: 10,
178
+ },
179
+ },
180
+ next: '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
181
+ status: 'INVALID',
182
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
183
+ },
184
+ '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361': {
185
+ id: '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
186
+ dateCreated: '2023-11-01T13:53:32.531Z',
187
+ dateUpdated: '2023-11-01T13:54:58.249Z',
188
+ description: 'description',
189
+ type: 'ACTION/FUNCTION',
190
+ parameters: {
191
+ code: 'function yourFunction(parameters, libraries) {\nreturn {\n num:4,\n str:"paragon"\n}\n}',
192
+ parameters: [],
193
+ },
194
+ next: '99d371fd-608f-4785-b4c8-a361f595e7c9',
195
+ status: 'INVALID',
196
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
197
+ },
198
+ '99d371fd-608f-4785-b4c8-a361f595e7c9': {
199
+ id: '99d371fd-608f-4785-b4c8-a361f595e7c9',
200
+ dateCreated: '2023-11-01T13:54:01.396Z',
201
+ dateUpdated: '2023-11-01T13:55:08.164Z',
202
+ description: 'description',
203
+ type: 'ACTION/DELAY',
204
+ parameters: {
205
+ unit: 'HOURS',
206
+ value: {
207
+ path: ['result', 'num'],
208
+ type: 'VARIABLE',
209
+ stepId: '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
210
+ dataType: 'NON_DECIMAL',
211
+ },
212
+ },
213
+ next: 'b11b1604-a39a-442b-8963-721e6c9bb747',
214
+ status: 'INVALID',
215
+ workflowId: 'c3000c95-82cf-4814-b4c2-2cb2c4b89bbc',
216
+ },
217
+ },
218
+ sequenceMap: {
219
+ 'sequence-0': {
220
+ id: 'sequence-0',
221
+ start: '22e7f997-de29-410d-be06-7b87fbfbd77b',
222
+ stepIds: ['22e7f997-de29-410d-be06-7b87fbfbd77b'],
223
+ stepEdges: [
224
+ {
225
+ from: '22e7f997-de29-410d-be06-7b87fbfbd77b',
226
+ to: '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
227
+ },
228
+ ],
229
+ sequenceEdges: [
230
+ {
231
+ type: 'NEXT',
232
+ from: 'sequence-0',
233
+ to: 'sequence-1',
234
+ },
235
+ ],
236
+ type: 'TRIGGER',
237
+ conditionalBranchWidth: 0,
238
+ },
239
+ 'sequence-1': {
240
+ id: 'sequence-1',
241
+ start: '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
242
+ stepIds: [
243
+ '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
244
+ '99d371fd-608f-4785-b4c8-a361f595e7c9',
245
+ ],
246
+ stepEdges: [
247
+ {
248
+ from: '6c7c9bbc-f33e-4e7e-8226-47d18fcdf361',
249
+ to: '99d371fd-608f-4785-b4c8-a361f595e7c9',
250
+ },
251
+ {
252
+ from: '99d371fd-608f-4785-b4c8-a361f595e7c9',
253
+ to: 'b11b1604-a39a-442b-8963-721e6c9bb747',
254
+ },
255
+ ],
256
+ sequenceEdges: [
257
+ {
258
+ type: 'NEXT',
259
+ from: 'sequence-1',
260
+ to: 'sequence-2',
261
+ },
262
+ ],
263
+ type: 'MAIN',
264
+ conditionalBranchWidth: 0,
265
+ },
266
+ 'sequence-2': {
267
+ id: 'sequence-2',
268
+ start: 'b11b1604-a39a-442b-8963-721e6c9bb747',
269
+ stepIds: ['b11b1604-a39a-442b-8963-721e6c9bb747'],
270
+ stepEdges: [
271
+ {
272
+ from: 'b11b1604-a39a-442b-8963-721e6c9bb747',
273
+ to: 'd4f2bf7d-4610-4625-9314-02c9be9dc43b',
274
+ },
275
+ {
276
+ label: 'Yes',
277
+ from: 'b11b1604-a39a-442b-8963-721e6c9bb747',
278
+ to: null,
279
+ },
280
+ {
281
+ label: 'No',
282
+ from: 'b11b1604-a39a-442b-8963-721e6c9bb747',
283
+ to: '2f7edb3f-1b58-4b80-be08-67f85ed6afea',
284
+ },
285
+ ],
286
+ sequenceEdges: [
287
+ {
288
+ type: 'BRANCH',
289
+ from: 'sequence-2',
290
+ to: 'sequence-3',
291
+ },
292
+ {
293
+ type: 'BRANCH',
294
+ from: 'sequence-2',
295
+ to: 'sequence-4',
296
+ },
297
+ {
298
+ type: 'NEXT',
299
+ from: 'sequence-2',
300
+ to: 'sequence-8',
301
+ },
302
+ ],
303
+ type: 'MAIN',
304
+ conditionalBranchWidth: 1.5,
305
+ },
306
+ 'sequence-3': {
307
+ id: 'sequence-3',
308
+ stepIds: [],
309
+ stepEdges: [],
310
+ sequenceEdges: [],
311
+ type: 'BRANCH',
312
+ conditionalBranchWidth: 0,
313
+ },
314
+ 'sequence-4': {
315
+ id: 'sequence-4',
316
+ start: '2f7edb3f-1b58-4b80-be08-67f85ed6afea',
317
+ stepIds: ['2f7edb3f-1b58-4b80-be08-67f85ed6afea'],
318
+ stepEdges: [
319
+ {
320
+ from: '2f7edb3f-1b58-4b80-be08-67f85ed6afea',
321
+ to: '82f21fb0-e712-4cb8-b2ec-70fa0ffc5568',
322
+ },
323
+ ],
324
+ sequenceEdges: [
325
+ {
326
+ type: 'NEXT',
327
+ from: 'sequence-4',
328
+ to: 'sequence-5',
329
+ },
330
+ ],
331
+ type: 'BRANCH',
332
+ conditionalBranchWidth: 0,
333
+ },
334
+ 'sequence-5': {
335
+ id: 'sequence-5',
336
+ start: '82f21fb0-e712-4cb8-b2ec-70fa0ffc5568',
337
+ stepIds: ['82f21fb0-e712-4cb8-b2ec-70fa0ffc5568'],
338
+ stepEdges: [
339
+ {
340
+ from: '82f21fb0-e712-4cb8-b2ec-70fa0ffc5568',
341
+ to: null,
342
+ },
343
+ ],
344
+ sequenceEdges: [
345
+ {
346
+ type: 'FANOUT',
347
+ from: 'sequence-5',
348
+ to: 'sequence-6',
349
+ },
350
+ {
351
+ type: 'NEXT',
352
+ from: 'sequence-5',
353
+ to: 'sequence-7',
354
+ },
355
+ ],
356
+ type: 'BRANCH',
357
+ conditionalBranchWidth: 0.5,
358
+ },
359
+ 'sequence-6': {
360
+ id: 'sequence-6',
361
+ start: 'd9c96e6e-9a34-4c6c-8428-578023056934',
362
+ stepIds: ['d9c96e6e-9a34-4c6c-8428-578023056934'],
363
+ stepEdges: [
364
+ {
365
+ from: 'd9c96e6e-9a34-4c6c-8428-578023056934',
366
+ to: null,
367
+ },
368
+ ],
369
+ sequenceEdges: [],
370
+ type: 'FANOUT',
371
+ conditionalBranchWidth: 0,
372
+ },
373
+ 'sequence-7': {
374
+ id: 'sequence-7',
375
+ stepIds: [],
376
+ stepEdges: [],
377
+ sequenceEdges: [],
378
+ type: 'MAIN',
379
+ conditionalBranchWidth: 0,
380
+ },
381
+ 'sequence-8': {
382
+ id: 'sequence-8',
383
+ start: 'd4f2bf7d-4610-4625-9314-02c9be9dc43b',
384
+ stepIds: ['d4f2bf7d-4610-4625-9314-02c9be9dc43b'],
385
+ stepEdges: [
386
+ {
387
+ from: 'd4f2bf7d-4610-4625-9314-02c9be9dc43b',
388
+ to: null,
389
+ },
390
+ ],
391
+ sequenceEdges: [],
392
+ type: 'MAIN',
393
+ conditionalBranchWidth: 0,
394
+ },
395
+ },
396
+ start: 'sequence-0',
397
+ activeStepId: '22e7f997-de29-410d-be06-7b87fbfbd77b',
398
+ unusedSteps: [],
399
+ },
400
+ },
401
+ },
402
+ },
403
+ },
404
+ };
@@ -0,0 +1,14 @@
1
+ import { IEvent } from '@useparagon/core/event';
2
+
3
+ /**
4
+ * integration depdencies
5
+ */
6
+ export type ProjectDependencies = {
7
+ events: Record<string, IEvent>;
8
+ };
9
+
10
+ export type WorkflowDependencies = ProjectDependencies & {
11
+ integration: {
12
+ name: string;
13
+ };
14
+ };
@@ -0,0 +1,145 @@
1
+ import * as importSortOrderPlugin from '@trivago/prettier-plugin-sort-imports';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import prettier from 'prettier';
5
+ import * as organiseImportPlugin from 'prettier-plugin-organize-imports';
6
+
7
+ import { IEvent } from '@useparagon/core/event';
8
+
9
+ import {
10
+ BuildOutput,
11
+ IntegrationOutput,
12
+ WorkflowOutput,
13
+ ProjectDependencies,
14
+ } from '../compilers/compiler.types';
15
+ import { eventToCode } from './codegens/event.codegen';
16
+ import { integrationConfigToCode } from './codegens/integration.codegen';
17
+ import { workflowToCode } from './codegens/workflow.codegen';
18
+
19
+ /**
20
+ * write code in file
21
+ * @param filePath
22
+ * @param fileName
23
+ * @param sourceCode
24
+ */
25
+ const writeSourceToFile = async (
26
+ filePath: string,
27
+ fileName: string,
28
+ sourceCode: string,
29
+ ): Promise<void> => {
30
+ const sanitizeFileName: string = fileName;
31
+
32
+ const formattedCode: string = prettier.format(sourceCode, {
33
+ parser: 'typescript',
34
+ semi: true,
35
+ trailingComma: 'all',
36
+ singleQuote: true,
37
+ plugins: [organiseImportPlugin, importSortOrderPlugin],
38
+ //@ts-ignore plugin specific config
39
+ importOrder: ['^@useparagon/(.*)$', '^[./]'],
40
+ importOrderSeparation: true,
41
+ importOrderCaseInsensitive: true,
42
+ });
43
+
44
+ await fs.promises.writeFile(
45
+ path.join(filePath, `${sanitizeFileName}.ts`),
46
+ formattedCode,
47
+ );
48
+ };
49
+
50
+ /**
51
+ * wrap multiline string value with template string
52
+ * @param value
53
+ * @returns
54
+ */
55
+ export const wrapMultilineString = (value: string): string => {
56
+ return '`' + value + '`';
57
+ };
58
+
59
+ /**
60
+ * generate all source files for integration
61
+ * @param integrationOutput
62
+ * @param ProjectDependencies
63
+ * @param projectRoot
64
+ */
65
+ export const generateIntegrationFiles = async (
66
+ integrationName: string,
67
+ integrationOutput: IntegrationOutput,
68
+ projectDependencies: ProjectDependencies,
69
+ projectRoot: string,
70
+ ) => {
71
+ const integrationPath: string = path.join(
72
+ projectRoot,
73
+ 'integrations',
74
+ integrationName,
75
+ );
76
+ await fs.promises.mkdir(integrationPath, {
77
+ recursive: true,
78
+ });
79
+
80
+ const configCode: string = integrationConfigToCode(
81
+ integrationOutput.config,
82
+ integrationName,
83
+ );
84
+ await writeSourceToFile(integrationPath, 'config', configCode);
85
+
86
+ const workflowOutputs: WorkflowOutput[] = Object.values(
87
+ integrationOutput.workflows,
88
+ );
89
+
90
+ const workflowPath: string = path.join(integrationPath, 'workflows');
91
+
92
+ if (workflowOutputs.length) {
93
+ fs.promises.mkdir(workflowPath, {
94
+ recursive: true,
95
+ });
96
+ }
97
+
98
+ for (const workflowOutput of workflowOutputs) {
99
+ const workflowCode: string = workflowToCode(workflowOutput, {
100
+ ...projectDependencies,
101
+ integration: { name: integrationName },
102
+ });
103
+ await writeSourceToFile(workflowPath, workflowOutput.name, workflowCode);
104
+ }
105
+ };
106
+
107
+ /**
108
+ * generate all source files for project
109
+ * @param projectBuild
110
+ * @param projectRoot
111
+ */
112
+ export const generateProjectFiles = async (
113
+ projectBuild: BuildOutput,
114
+ projectRoot: string,
115
+ ) => {
116
+ await fs.promises.mkdir(projectRoot, { recursive: true });
117
+
118
+ const events: IEvent[] = Object.values(projectBuild.events);
119
+
120
+ const eventPath: string = path.join(projectRoot, 'events');
121
+
122
+ if (events.length) {
123
+ await fs.promises.mkdir(eventPath, {
124
+ recursive: true,
125
+ });
126
+ }
127
+
128
+ for (const event of events) {
129
+ const eventSourceCode: string = eventToCode(event);
130
+ await writeSourceToFile(eventPath, event.name, eventSourceCode);
131
+ }
132
+
133
+ const integrationOutputs: Array<[string, IntegrationOutput]> = Object.entries(
134
+ projectBuild.integrations,
135
+ );
136
+
137
+ for (const [integrationName, integrationOutput] of integrationOutputs) {
138
+ await generateIntegrationFiles(
139
+ integrationName,
140
+ integrationOutput,
141
+ { events: projectBuild.events },
142
+ projectRoot,
143
+ );
144
+ }
145
+ };
@@ -0,0 +1,49 @@
1
+ import {
2
+ Condition,
3
+ Operator,
4
+ OperatorCondition,
5
+ } from '@useparagon/core/resolvers';
6
+
7
+ import { convertSourceToCode } from './source.codegen';
8
+
9
+ /**
10
+ * convert condition to code
11
+ * @param condition
12
+ * @returns
13
+ */
14
+ export const conditionToCode = (
15
+ operatorCondition: OperatorCondition,
16
+ stepIdToVariableMap: Record<string, string>,
17
+ ): string => {
18
+ let code: string = '';
19
+
20
+ const condition: Condition = operatorCondition.condition;
21
+
22
+ switch (condition.operator) {
23
+ case Operator.BooleanTrue: {
24
+ const variable: string = convertSourceToCode(
25
+ condition.variable,
26
+ stepIdToVariableMap,
27
+ );
28
+ code = `Operators.BooleanTrue(${variable})`;
29
+ break;
30
+ }
31
+
32
+ case Operator.StringContains: {
33
+ const variable: string = convertSourceToCode(
34
+ condition.variable,
35
+ stepIdToVariableMap,
36
+ );
37
+ const argument: string = convertSourceToCode(
38
+ condition.argument,
39
+ stepIdToVariableMap,
40
+ );
41
+ code = `Operators.StringContains(${variable},${argument})`;
42
+ break;
43
+ }
44
+ default:
45
+ code = 'undefined';
46
+ break;
47
+ }
48
+ return code;
49
+ };
@@ -0,0 +1,39 @@
1
+ import { IEvent } from '@useparagon/core/event';
2
+
3
+ import { stringifyObject } from '../../helpers/json';
4
+
5
+ /**
6
+ * get source code for event
7
+ * @param event
8
+ * @returns
9
+ */
10
+ export const eventToCode = (event: IEvent): string => {
11
+ const sourceCode: string = `
12
+ import { IEvent } from '@useparagon/core/event';
13
+
14
+ export type EventSchema = {
15
+
16
+ };
17
+
18
+ const event: IEvent<EventSchema> = {
19
+ /**
20
+ * This property is maintained by Paragon. Do not edit this property.
21
+ */
22
+ id: '${event.id}',
23
+
24
+ /**
25
+ * name of event
26
+ */
27
+ name : '${event.name}',
28
+
29
+ /**
30
+ * schema of event payload
31
+ */
32
+ schema:${stringifyObject(event.schema)}
33
+ }
34
+
35
+ export default event;
36
+ `;
37
+
38
+ return sourceCode;
39
+ };
@@ -0,0 +1,23 @@
1
+ import { IntegrationOutput } from '../../compilers/compiler.types';
2
+ import { stringifyObject } from '../../helpers/json';
3
+
4
+ /**
5
+ * convert integration config to source code
6
+ * @returns
7
+ */
8
+ export const integrationConfigToCode = (
9
+ config: IntegrationOutput['config'],
10
+ integrationName: string,
11
+ ): string => {
12
+ const sourceCode: string = `
13
+ import { IIntegrationConfig } from '@useparagon/core';
14
+
15
+ /**
16
+ * configuration for a ${integrationName}
17
+ */
18
+ const config: IIntegrationConfig = ${stringifyObject(config || {})}
19
+
20
+ export default config;`;
21
+
22
+ return sourceCode;
23
+ };