@superblocksteam/util 1.99.99-next.3 → 2.0.0-SNAPSHOT.03dcbbce5278af46

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 (106) hide show
  1. package/dist/api-files/{api.d.mts → api.d.ts} +4 -3
  2. package/dist/api-files/api.d.ts.map +1 -0
  3. package/dist/api-files/{api.mjs → api.js} +5 -5
  4. package/dist/api-files/api.js.map +1 -0
  5. package/dist/api-files/constants.d.ts.map +1 -1
  6. package/dist/api-files/constants.js +2 -5
  7. package/dist/api-files/constants.js.map +1 -1
  8. package/dist/api-files/index.d.ts +1 -6
  9. package/dist/api-files/index.d.ts.map +1 -1
  10. package/dist/api-files/index.js +1 -12
  11. package/dist/api-files/index.js.map +1 -1
  12. package/dist/api-files/types.d.ts +13 -15
  13. package/dist/api-files/types.d.ts.map +1 -1
  14. package/dist/api-files/types.js +3 -9
  15. package/dist/api-files/types.js.map +1 -1
  16. package/dist/constants.d.ts +1 -2
  17. package/dist/constants.d.ts.map +1 -1
  18. package/dist/constants.js +8 -29
  19. package/dist/constants.js.map +1 -1
  20. package/dist/events.d.ts +0 -4
  21. package/dist/events.d.ts.map +1 -1
  22. package/dist/events.js +2 -9
  23. package/dist/events.js.map +1 -1
  24. package/dist/file-uploader.d.ts.map +1 -1
  25. package/dist/file-uploader.js +27 -18
  26. package/dist/file-uploader.js.map +1 -1
  27. package/dist/file-uploader.test.d.ts +2 -0
  28. package/dist/file-uploader.test.d.ts.map +1 -0
  29. package/dist/file-uploader.test.js +42 -0
  30. package/dist/file-uploader.test.js.map +1 -0
  31. package/dist/identifiers.js +3 -8
  32. package/dist/identifiers.js.map +1 -1
  33. package/dist/index.d.ts +1 -3
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +13 -31
  36. package/dist/index.js.map +1 -1
  37. package/dist/localGitRepoState.js +1 -2
  38. package/dist/login.d.ts +6 -0
  39. package/dist/login.d.ts.map +1 -1
  40. package/dist/login.js +38 -54
  41. package/dist/login.js.map +1 -1
  42. package/dist/login.test.d.ts +2 -0
  43. package/dist/login.test.d.ts.map +1 -0
  44. package/dist/login.test.js +64 -0
  45. package/dist/login.test.js.map +1 -0
  46. package/dist/mask-unix-signals.d.ts +2 -1
  47. package/dist/mask-unix-signals.d.ts.map +1 -1
  48. package/dist/mask-unix-signals.js +1 -4
  49. package/dist/mask-unix-signals.js.map +1 -1
  50. package/dist/resource-configs.d.ts +17 -20
  51. package/dist/resource-configs.d.ts.map +1 -1
  52. package/dist/resource-configs.js +54 -99
  53. package/dist/resource-configs.js.map +1 -1
  54. package/dist/token-manager.d.ts +22 -0
  55. package/dist/token-manager.d.ts.map +1 -0
  56. package/dist/token-manager.js +2 -0
  57. package/dist/token-manager.js.map +1 -0
  58. package/dist/unreachable.js +1 -4
  59. package/dist/unreachable.js.map +1 -1
  60. package/package.json +52 -29
  61. package/.prettierrc +0 -18
  62. package/dist/api-files/api.d.mts.map +0 -1
  63. package/dist/api-files/api.mjs.map +0 -1
  64. package/dist/component-configs.d.ts +0 -6
  65. package/dist/component-configs.d.ts.map +0 -1
  66. package/dist/component-configs.js +0 -178
  67. package/dist/component-configs.js.map +0 -1
  68. package/dist/data-types.d.ts +0 -10
  69. package/dist/data-types.d.ts.map +0 -1
  70. package/dist/data-types.js +0 -32
  71. package/dist/data-types.js.map +0 -1
  72. package/dist/generate-component-types.d.ts +0 -3
  73. package/dist/generate-component-types.d.ts.map +0 -1
  74. package/dist/generate-component-types.js +0 -45
  75. package/dist/generate-component-types.js.map +0 -1
  76. package/dist/types.d.ts +0 -105
  77. package/dist/types.d.ts.map +0 -1
  78. package/dist/types.js +0 -3
  79. package/dist/types.js.map +0 -1
  80. package/dist/validation.d.ts +0 -5
  81. package/dist/validation.d.ts.map +0 -1
  82. package/dist/validation.js +0 -152
  83. package/dist/validation.js.map +0 -1
  84. package/eslint.config.js +0 -83
  85. package/src/api-files/api.mts +0 -504
  86. package/src/api-files/constants.ts +0 -6
  87. package/src/api-files/index.ts +0 -15
  88. package/src/api-files/types.ts +0 -134
  89. package/src/component-configs.ts +0 -161
  90. package/src/constants.ts +0 -48
  91. package/src/data-types.ts +0 -39
  92. package/src/events.ts +0 -12
  93. package/src/file-uploader.ts +0 -28
  94. package/src/generate-component-types.ts +0 -53
  95. package/src/identifiers.ts +0 -70
  96. package/src/index.ts +0 -15
  97. package/src/localGitRepoState.ts +0 -20
  98. package/src/login.ts +0 -66
  99. package/src/mask-unix-signals.ts +0 -86
  100. package/src/resource-configs.ts +0 -293
  101. package/src/types.ts +0 -137
  102. package/src/unreachable.ts +0 -5
  103. package/src/validation.ts +0 -155
  104. package/tsconfig.json +0 -20
  105. package/tsconfig.tsbuildinfo +0 -1
  106. package/tsup.config.ts +0 -8
@@ -1,504 +0,0 @@
1
- import fs from "fs-extra";
2
- import { cloneDeep } from "lodash-es";
3
- import slugify from "slugify";
4
- import { parse, stringify as ymlstringify } from "yaml";
5
- import {
6
- DEFAULT_LINES_FOR_LARGE_STEPS,
7
- LANGUAGE_STEP_EXTENSIONS,
8
- } from "./constants.js";
9
- import type {
10
- AdditionalStepFiles,
11
- Api,
12
- ApiRepresentation,
13
- ApiWrapper,
14
- Block,
15
- LanguageContent,
16
- Step,
17
- } from "./types.js";
18
-
19
- function slugifyName(originalName: any): string {
20
- return (slugify as any)(originalName, {
21
- replacement: "_",
22
- lower: true,
23
- });
24
- }
25
-
26
- function findUnusedFilePath(
27
- filename: string,
28
- extension: string,
29
- existingFilePaths: Set<string>,
30
- ): string {
31
- let proposedFilename = `${filename}.${extension}`;
32
- let i = 1;
33
- while (existingFilePaths.has(proposedFilename)) {
34
- proposedFilename = `${filename}_${i}.${extension}`;
35
- i++;
36
- }
37
- existingFilePaths.add(proposedFilename);
38
- return proposedFilename;
39
- }
40
-
41
- function extractAdditionalStepFiles(
42
- api: Api,
43
- additionalStepFiles: AdditionalStepFiles[],
44
- stepPathMap: Record<string, string>,
45
- currentStepNames: string[],
46
- apiRepresentation?: ApiRepresentation,
47
- ): Api {
48
- if (!api.blocks || !apiRepresentation?.extractLargeSourceFiles) {
49
- return api;
50
- }
51
- // TODO: lodash
52
- const apiClone = cloneDeep(api);
53
- const minLinesForExtraction =
54
- apiRepresentation?.minLinesForExtraction ?? DEFAULT_LINES_FOR_LARGE_STEPS;
55
- const existingFilePaths = new Set<string>();
56
- extractAdditionalStepFilesFromBlocks(
57
- apiClone.blocks ?? [],
58
- additionalStepFiles,
59
- existingFilePaths,
60
- minLinesForExtraction,
61
- stepPathMap,
62
- currentStepNames,
63
- );
64
- return apiClone;
65
- }
66
-
67
- function extractAdditionalStepFilesFromStep(
68
- step: Step,
69
- name: string,
70
- additionalStepFiles: AdditionalStepFiles[],
71
- existingFilePaths: Set<string>,
72
- minLinesForExtraction: number,
73
- stepPathMap: Record<string, string>,
74
- currentStepNames: string[],
75
- ) {
76
- // Handle language step files
77
- if (step && "integration" in step) {
78
- const integration = step.integration as keyof Step;
79
- const extension =
80
- LANGUAGE_STEP_EXTENSIONS[
81
- integration as keyof typeof LANGUAGE_STEP_EXTENSIONS
82
- ];
83
- if (extension) {
84
- const languageContent = step[integration] as LanguageContent;
85
- if (languageContent) {
86
- const blockBody = languageContent.body;
87
- if (blockBody && typeof blockBody === "string") {
88
- const lines = blockBody?.split("\n");
89
- const linesNum = lines?.length;
90
- if (linesNum && linesNum > minLinesForExtraction) {
91
- // Record the separate file is needed, with the language contents
92
- let relativePath;
93
- if (stepPathMap?.[name]) {
94
- relativePath = stepPathMap[name].startsWith("./")
95
- ? stepPathMap[name].split("./")?.[1]
96
- : stepPathMap[name];
97
- } else {
98
- relativePath = findUnusedFilePath(
99
- slugifyName(name),
100
- extension,
101
- existingFilePaths,
102
- );
103
- stepPathMap[name] = `./${relativePath}`;
104
- }
105
- additionalStepFiles.push({
106
- relativePath: relativePath,
107
- contents: blockBody,
108
- language: integration,
109
- });
110
- currentStepNames.push(name);
111
- // Replace the body with a reference to the separate file
112
- languageContent.body = {
113
- path: `./${relativePath}`,
114
- };
115
- }
116
- }
117
- }
118
- }
119
- }
120
- }
121
-
122
- function extractAdditionalStepFilesFromBlocks(
123
- blocks: Block[],
124
- additionalStepFiles: AdditionalStepFiles[],
125
- existingFilePaths: Set<string>,
126
- minLinesForExtraction: number,
127
- stepPathMap: Record<string, string>,
128
- currentStepNames: string[],
129
- ) {
130
- for (const block of blocks) {
131
- // Handle language step files
132
- if (block.step) {
133
- extractAdditionalStepFilesFromStep(
134
- block.step,
135
- block.name,
136
- additionalStepFiles,
137
- existingFilePaths,
138
- minLinesForExtraction,
139
- stepPathMap,
140
- currentStepNames,
141
- );
142
- }
143
-
144
- // Handle loops
145
- extractAdditionalStepFilesFromBlocks(
146
- block.loop?.blocks ?? [],
147
- additionalStepFiles,
148
- existingFilePaths,
149
- minLinesForExtraction,
150
- stepPathMap,
151
- currentStepNames,
152
- );
153
- // Handle try/catch
154
- if (block.tryCatch) {
155
- extractAdditionalStepFilesFromBlocks(
156
- block.tryCatch.try?.blocks ?? [],
157
- additionalStepFiles,
158
- existingFilePaths,
159
- minLinesForExtraction,
160
- stepPathMap,
161
- currentStepNames,
162
- );
163
- extractAdditionalStepFilesFromBlocks(
164
- block.tryCatch.catch?.blocks ?? [],
165
- additionalStepFiles,
166
- existingFilePaths,
167
- minLinesForExtraction,
168
- stepPathMap,
169
- currentStepNames,
170
- );
171
- extractAdditionalStepFilesFromBlocks(
172
- block.tryCatch.finally?.blocks ?? [],
173
- additionalStepFiles,
174
- existingFilePaths,
175
- minLinesForExtraction,
176
- stepPathMap,
177
- currentStepNames,
178
- );
179
- }
180
- // Handle conditional
181
- if (block.conditional) {
182
- extractAdditionalStepFilesFromBlocks(
183
- block.conditional.if?.blocks ?? [],
184
- additionalStepFiles,
185
- existingFilePaths,
186
- minLinesForExtraction,
187
- stepPathMap,
188
- currentStepNames,
189
- );
190
- for (const elseIfBlock of block.conditional.elseIf ?? []) {
191
- extractAdditionalStepFilesFromBlocks(
192
- elseIfBlock.blocks,
193
- additionalStepFiles,
194
- existingFilePaths,
195
- minLinesForExtraction,
196
- stepPathMap,
197
- currentStepNames,
198
- );
199
- }
200
- extractAdditionalStepFilesFromBlocks(
201
- block.conditional.else?.blocks ?? [],
202
- additionalStepFiles,
203
- existingFilePaths,
204
- minLinesForExtraction,
205
- stepPathMap,
206
- currentStepNames,
207
- );
208
- }
209
- // Handle Parallel API
210
- if (block.parallel) {
211
- for (const path of Object.values(block.parallel?.static?.paths ?? {})) {
212
- extractAdditionalStepFilesFromBlocks(
213
- path.blocks,
214
- additionalStepFiles,
215
- existingFilePaths,
216
- minLinesForExtraction,
217
- stepPathMap,
218
- currentStepNames,
219
- );
220
- }
221
- extractAdditionalStepFilesFromBlocks(
222
- block.parallel?.dynamic?.blocks ?? [],
223
- additionalStepFiles,
224
- existingFilePaths,
225
- minLinesForExtraction,
226
- stepPathMap,
227
- currentStepNames,
228
- );
229
- }
230
- // Handle stream
231
- if (block.stream) {
232
- const trigger = block.stream.trigger;
233
- if (trigger && trigger.step) {
234
- extractAdditionalStepFilesFromStep(
235
- trigger.step,
236
- trigger.name,
237
- additionalStepFiles,
238
- existingFilePaths,
239
- minLinesForExtraction,
240
- stepPathMap,
241
- currentStepNames,
242
- );
243
- }
244
- extractAdditionalStepFilesFromBlocks(
245
- block.stream.process?.blocks ?? [],
246
- additionalStepFiles,
247
- existingFilePaths,
248
- minLinesForExtraction,
249
- stepPathMap,
250
- currentStepNames,
251
- );
252
- }
253
- }
254
- }
255
-
256
- async function readYamlFile(path: string): Promise<any> {
257
- return parse(await fs.readFile(path, "utf8"));
258
- }
259
-
260
- async function resolveLanguageSpecificStepContentFromBlocks(
261
- parentPath: string,
262
- blocks: Block[],
263
- stepPathMap: Record<string, string>,
264
- ) {
265
- for (const block of blocks) {
266
- // Handle language-specific step content
267
- if (block.step) {
268
- const step = block.step;
269
- await resolveLanguageSpecificStepContentFromStep(
270
- parentPath,
271
- step,
272
- block.name,
273
- stepPathMap,
274
- );
275
- }
276
- // Handle conditional blocks
277
- if (block.conditional) {
278
- await resolveLanguageSpecificStepContentFromBlocks(
279
- parentPath,
280
- block.conditional.if?.blocks ?? [],
281
- stepPathMap,
282
- );
283
- for (const elseIfBlock of block.conditional.elseIf) {
284
- await resolveLanguageSpecificStepContentFromBlocks(
285
- parentPath,
286
- elseIfBlock.blocks,
287
- stepPathMap,
288
- );
289
- }
290
- await resolveLanguageSpecificStepContentFromBlocks(
291
- parentPath,
292
- block.conditional.else?.blocks ?? [],
293
- stepPathMap,
294
- );
295
- }
296
- // Handle loop blocks
297
- await resolveLanguageSpecificStepContentFromBlocks(
298
- parentPath,
299
- block.loop?.blocks ?? [],
300
- stepPathMap,
301
- );
302
- // Handle try-catch blocks
303
- if (block.tryCatch) {
304
- await resolveLanguageSpecificStepContentFromBlocks(
305
- parentPath,
306
- block.tryCatch.try?.blocks ?? [],
307
- stepPathMap,
308
- );
309
- await resolveLanguageSpecificStepContentFromBlocks(
310
- parentPath,
311
- block.tryCatch.catch?.blocks ?? [],
312
- stepPathMap,
313
- );
314
- await resolveLanguageSpecificStepContentFromBlocks(
315
- parentPath,
316
- block.tryCatch.finally?.blocks ?? [],
317
- stepPathMap,
318
- );
319
- }
320
- // Handle parallel blocks
321
- if (block.parallel) {
322
- for (const path of Object.values(block.parallel?.static?.paths ?? {})) {
323
- await resolveLanguageSpecificStepContentFromBlocks(
324
- parentPath,
325
- path.blocks,
326
- stepPathMap,
327
- );
328
- }
329
- await resolveLanguageSpecificStepContentFromBlocks(
330
- parentPath,
331
- block.parallel?.dynamic?.blocks ?? [],
332
- stepPathMap,
333
- );
334
- }
335
- // Handle stream blocks
336
- if (block.stream) {
337
- await resolveLanguageSpecificStepContentFromBlocks(
338
- parentPath,
339
- block.stream.process?.blocks ?? [],
340
- stepPathMap,
341
- );
342
- await resolveLanguageSpecificStepContentFromStep(
343
- parentPath,
344
- block.stream.trigger?.step ?? ({} as Step),
345
- block.stream.trigger?.name,
346
- stepPathMap,
347
- );
348
- }
349
- }
350
- }
351
-
352
- async function resolveLanguageSpecificStepContentFromStep(
353
- parentPath: string,
354
- step: Step,
355
- stepName?: string,
356
- stepPathMap?: Record<string, string>,
357
- ) {
358
- // Handle language-specific step content
359
- if (
360
- !step?.integration ||
361
- !LANGUAGE_STEP_EXTENSIONS[
362
- step.integration as keyof typeof LANGUAGE_STEP_EXTENSIONS
363
- ]
364
- ) {
365
- return;
366
- }
367
- const languageContent = step[
368
- step.integration as keyof Step
369
- ] as LanguageContent;
370
- if (
371
- languageContent.body &&
372
- typeof languageContent.body === "object" &&
373
- "path" in languageContent.body
374
- ) {
375
- const languageFilePath = `${parentPath}/${languageContent.body.path}`;
376
- if (await fs.pathExists(languageFilePath)) {
377
- // Read the file content
378
- const stepBodyContent = await fs.readFile(languageFilePath, "utf8");
379
- if (stepBodyContent && languageContent) {
380
- if (stepPathMap && stepName) {
381
- stepPathMap[stepName] = languageContent.body.path;
382
- }
383
- languageContent.body = stepBodyContent;
384
- }
385
- }
386
- }
387
- }
388
-
389
- export async function writeApiFiles(
390
- api: ApiWrapper,
391
- apiNameSlug: string,
392
- directoryPath: string,
393
- nestedApiFiles: boolean,
394
- apiPromises: Array<Promise<void>>,
395
- additionalStepFiles: AdditionalStepFiles[],
396
- apiRepresentation?: ApiRepresentation,
397
- existingFilePaths?: Set<string>,
398
- stepPathMap?: Record<string, string>,
399
- ) {
400
- let pathForApiFile = directoryPath;
401
- let yamlFileName = `${apiNameSlug}.yaml`;
402
-
403
- const currentStepNames: string[] = [];
404
- // Determine whether to extract into separate files the source code from the steps
405
- const updatedApi = extractAdditionalStepFiles(
406
- api.apiPb,
407
- additionalStepFiles,
408
- stepPathMap ?? {},
409
- currentStepNames,
410
- apiRepresentation,
411
- );
412
-
413
- // Stop tracking unused step paths from removed steps (e.g. when a step is renamed or removed)
414
- if (stepPathMap) {
415
- Object.keys(stepPathMap).forEach((stepName) => {
416
- if (!currentStepNames.includes(stepName)) {
417
- const stepFileName = stepPathMap[stepName].startsWith("./")
418
- ? stepPathMap[stepName].split("./")[1]
419
- : stepPathMap[stepName];
420
- fs.remove(`${pathForApiFile}/${stepFileName}`);
421
- delete stepPathMap[stepName];
422
- }
423
- });
424
- }
425
-
426
- if (apiRepresentation?.extractLargeSourceFiles) {
427
- if (nestedApiFiles) {
428
- // This API has at least one large step code file, so we need a nested directory
429
- pathForApiFile = `${pathForApiFile}/${apiNameSlug}`;
430
- yamlFileName = "api.yaml";
431
- }
432
- // Make sure the directory exists
433
- await fs.ensureDir(pathForApiFile);
434
- // Write any additional step source code files to the disk
435
- for (const stepFile of additionalStepFiles) {
436
- const sourceFilePath = `${pathForApiFile}/${stepFile.relativePath}`;
437
- const handleApi = async () => {
438
- await fs.outputFile(sourceFilePath, stepFile.contents);
439
- };
440
- apiPromises.push(handleApi());
441
- // Mark the existing source file as being reused
442
- existingFilePaths?.delete(sourceFilePath);
443
- }
444
- } else {
445
- // No additional step files to write, so mark the API directory as existing so that it will be removed later.
446
- // Do this even if the current representation does not extract large source files, in case they were previously
447
- existingFilePaths?.add(`${directoryPath}/${apiNameSlug}`);
448
- }
449
-
450
- // Convert the updated API to YAML and write it to disk
451
- const apiContent = ymlstringify(updatedApi, {
452
- sortMapEntries: true,
453
- blockQuote: "literal",
454
- });
455
- const yamlFilePath = `${pathForApiFile}/${yamlFileName}`;
456
- const handleApi = async () => {
457
- await fs.outputFile(yamlFilePath, apiContent);
458
- };
459
- apiPromises.push(handleApi());
460
- // Mark the existing source file as being reused
461
- existingFilePaths?.delete(yamlFilePath);
462
- }
463
-
464
- export async function readAppApiYamlFile(
465
- parentDirectory: string,
466
- apiName?: string,
467
- ): Promise<{ api: Api; stepPathMap: Record<string, string> }> {
468
- // The API is either stored in its entirety in a single YAML file, or
469
- // or in a subdirectory containing the YAML file and zero or more language-specific files.
470
- const apiNameSlug = slugifyName(apiName ?? "api");
471
- const singularApiYamlPath = `${parentDirectory}/${apiNameSlug}.yaml`;
472
- const apiDirPath = `${parentDirectory}/${apiNameSlug}`;
473
- const nestedApiYamlPath = `${apiDirPath}/api.yaml`;
474
-
475
- // Read the YAML file
476
- let yamlPath: string;
477
- let yamlParentPath: string;
478
- if (await fs.pathExists(singularApiYamlPath)) {
479
- // The API YAML file is in the parent directory
480
- yamlPath = singularApiYamlPath;
481
- yamlParentPath = parentDirectory;
482
- } else if (await fs.pathExists(nestedApiYamlPath)) {
483
- // The API YAML file is nested in an API-specific directory
484
- yamlPath = nestedApiYamlPath;
485
- yamlParentPath = apiDirPath;
486
- } else {
487
- throw new Error(`API ${apiName ?? ""} not found at ${parentDirectory}`);
488
- }
489
-
490
- // That is nested in an API-specific directory
491
- const apiDefn = (await readYamlFile(yamlPath)) as Api;
492
-
493
- // Map step name -> step path
494
- const stepPathMap: Record<string, string> = {};
495
-
496
- // The API YAML file may or may not have language-specific content in separate files.
497
- // Replace any file references with the actual content
498
- await resolveLanguageSpecificStepContentFromBlocks(
499
- yamlParentPath,
500
- apiDefn.blocks ?? [],
501
- stepPathMap,
502
- );
503
- return { api: apiDefn, stepPathMap };
504
- }
@@ -1,6 +0,0 @@
1
- export const LANGUAGE_STEP_EXTENSIONS = {
2
- javascript: "js",
3
- python: "py",
4
- } as const;
5
-
6
- export const DEFAULT_LINES_FOR_LARGE_STEPS = 1;
@@ -1,15 +0,0 @@
1
- import type * as Api from "./api.mjs" with { "resolution-mode": "import" };
2
-
3
- export async function writeApiFiles(
4
- ...args: Parameters<typeof Api.writeApiFiles>
5
- ) {
6
- const esmFunction = await import("./api.mjs");
7
- return esmFunction.writeApiFiles(...args);
8
- }
9
-
10
- export async function readAppApiYamlFile(
11
- ...args: Parameters<typeof Api.readAppApiYamlFile>
12
- ) {
13
- const esmFunction = await import("./api.mjs");
14
- return esmFunction.readAppApiYamlFile(...args);
15
- }
@@ -1,134 +0,0 @@
1
- export type AdditionalStepFiles = {
2
- relativePath: string;
3
- contents: string;
4
- language: keyof Step;
5
- };
6
-
7
- export type ApiRepresentation = {
8
- extractLargeSourceFiles: boolean;
9
- minLinesForExtraction: number;
10
- };
11
-
12
- export interface ApiWrapper {
13
- apiPb: Api;
14
- name?: string; //@deprecated this attribute is used for getting a name for backends(jobs and workflows) that were never migrated to the new API version.
15
- }
16
-
17
- /** A signature, as produced by the agent. */
18
- export interface Signature {
19
- /** The id of the key used to sign the data. */
20
- keyId: string;
21
- /** The actual signature, in base64. */
22
- data: string;
23
- }
24
-
25
- export type Api = {
26
- metadata: {
27
- id: string;
28
- name: string;
29
- organization: string;
30
- timestamps?: {
31
- created: string;
32
- updated: string;
33
- deactivated: boolean;
34
- };
35
- // These properties are merged in from the v3 api entity
36
- creator?: {
37
- id: string;
38
- name: string;
39
- };
40
- folder?: string;
41
- };
42
- blocks?: Block[];
43
- trigger: any;
44
- signature?: Signature;
45
- };
46
-
47
- export type Block = {
48
- name: string;
49
- step?: Step;
50
- loop?: Loop;
51
- tryCatch?: TryCatch;
52
- conditional?: Conditional;
53
- parallel?: Parallel;
54
- stream?: Stream;
55
- };
56
-
57
- export type Step = {
58
- integration: string;
59
- javascript?: LanguageContent;
60
- python?: LanguageContent;
61
- };
62
-
63
- export type Loop = {
64
- blocks: Block[];
65
- range: string;
66
- type: LoopType;
67
- variables?: Variables;
68
- };
69
-
70
- export enum LoopType {
71
- FOR = "TYPE_FOR",
72
- FOR_EACH = "TYPE_FOREACH",
73
- WHILE = "TYPE_WHILE",
74
- UNSPECIFIED = "TYPE_UNSPECIFIED",
75
- }
76
-
77
- export type TryCatch = {
78
- try?: Blocks;
79
- catch?: Blocks;
80
- finally?: Blocks;
81
- variables?: Variables;
82
- };
83
-
84
- export type Conditional = {
85
- if?: ConditionalBlockWithCondition;
86
- elseIf: ConditionalBlockWithCondition[];
87
- else?: Blocks;
88
- };
89
-
90
- export type Blocks = {
91
- blocks: Block[];
92
- };
93
-
94
- export type ConditionalBlockWithCondition = Blocks & {
95
- condition?: string;
96
- };
97
-
98
- export type Parallel = {
99
- static?: {
100
- paths: Record<string, Blocks>;
101
- };
102
- dynamic?: {
103
- blocks: Block[];
104
- variables?: Variables;
105
- paths?: string;
106
- };
107
- poolSize?: number;
108
- wait?: WAIT_TYPE;
109
- };
110
-
111
- export type Stream = {
112
- trigger?: StreamTrigger;
113
- process?: Blocks;
114
- variables?: Variables;
115
- };
116
-
117
- export type StreamTrigger = {
118
- name: string;
119
- step?: Step;
120
- };
121
-
122
- export enum WAIT_TYPE {
123
- ALL = "WAIT_ALL",
124
- ANY = "WAIT_NONE",
125
- UNSPECIFIED = "WAIT_UNSPECIFIED",
126
- }
127
-
128
- export type Variables = Record<string, string>;
129
-
130
- export type LanguageContent = {
131
- body: Body;
132
- };
133
-
134
- export type Body = string | { path: string };