@factorialco/fcode-cli 1.1.0

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 (234) hide show
  1. package/README.md +1021 -0
  2. package/bin/dev +17 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +7 -0
  5. package/bin/run.cmd +3 -0
  6. package/dist/commands/add.d.ts +6 -0
  7. package/dist/commands/add.js +22 -0
  8. package/dist/commands/clone.d.ts +26 -0
  9. package/dist/commands/clone.js +177 -0
  10. package/dist/commands/dependencies/add.d.ts +9 -0
  11. package/dist/commands/dependencies/add.js +13 -0
  12. package/dist/commands/dependencies/install.d.ts +14 -0
  13. package/dist/commands/dependencies/install.js +44 -0
  14. package/dist/commands/dependencies/pull.d.ts +12 -0
  15. package/dist/commands/dependencies/pull.js +14 -0
  16. package/dist/commands/dependencies/push.d.ts +12 -0
  17. package/dist/commands/dependencies/push.js +14 -0
  18. package/dist/commands/dependencies/reset.d.ts +9 -0
  19. package/dist/commands/dependencies/reset.js +13 -0
  20. package/dist/commands/dependencies/status.d.ts +9 -0
  21. package/dist/commands/dependencies/status.js +13 -0
  22. package/dist/commands/http.d.ts +22 -0
  23. package/dist/commands/http.js +272 -0
  24. package/dist/commands/login.d.ts +18 -0
  25. package/dist/commands/login.js +62 -0
  26. package/dist/commands/logout.d.ts +10 -0
  27. package/dist/commands/logout.js +34 -0
  28. package/dist/commands/modules/add.d.ts +9 -0
  29. package/dist/commands/modules/add.js +13 -0
  30. package/dist/commands/modules/pull.d.ts +13 -0
  31. package/dist/commands/modules/pull.js +43 -0
  32. package/dist/commands/modules/push.d.ts +13 -0
  33. package/dist/commands/modules/push.js +35 -0
  34. package/dist/commands/modules/remove.d.ts +9 -0
  35. package/dist/commands/modules/remove.js +19 -0
  36. package/dist/commands/modules/reset.d.ts +9 -0
  37. package/dist/commands/modules/reset.js +13 -0
  38. package/dist/commands/modules/status.d.ts +11 -0
  39. package/dist/commands/modules/status.js +40 -0
  40. package/dist/commands/pre-debug.d.ts +20 -0
  41. package/dist/commands/pre-debug.js +120 -0
  42. package/dist/commands/process-metadata.d.ts +18 -0
  43. package/dist/commands/process-metadata.js +63 -0
  44. package/dist/commands/processes/add.d.ts +9 -0
  45. package/dist/commands/processes/add.js +13 -0
  46. package/dist/commands/processes/install-dependencies.d.ts +14 -0
  47. package/dist/commands/processes/install-dependencies.js +30 -0
  48. package/dist/commands/processes/pull.d.ts +13 -0
  49. package/dist/commands/processes/pull.js +47 -0
  50. package/dist/commands/processes/push.d.ts +13 -0
  51. package/dist/commands/processes/push.js +39 -0
  52. package/dist/commands/processes/remove.d.ts +9 -0
  53. package/dist/commands/processes/remove.js +19 -0
  54. package/dist/commands/processes/reset.d.ts +9 -0
  55. package/dist/commands/processes/reset.js +13 -0
  56. package/dist/commands/processes/status.d.ts +11 -0
  57. package/dist/commands/processes/status.js +58 -0
  58. package/dist/commands/pull.d.ts +9 -0
  59. package/dist/commands/pull.js +32 -0
  60. package/dist/commands/push.d.ts +9 -0
  61. package/dist/commands/push.js +29 -0
  62. package/dist/commands/remote/add.d.ts +10 -0
  63. package/dist/commands/remote/add.js +32 -0
  64. package/dist/commands/remote/list.d.ts +7 -0
  65. package/dist/commands/remote/list.js +33 -0
  66. package/dist/commands/remote/set.d.ts +10 -0
  67. package/dist/commands/remote/set.js +28 -0
  68. package/dist/commands/reset.d.ts +6 -0
  69. package/dist/commands/reset.js +19 -0
  70. package/dist/commands/run.d.ts +16 -0
  71. package/dist/commands/run.js +56 -0
  72. package/dist/commands/runtime-env.d.ts +12 -0
  73. package/dist/commands/runtime-env.js +42 -0
  74. package/dist/commands/settings/get.d.ts +12 -0
  75. package/dist/commands/settings/get.js +67 -0
  76. package/dist/commands/settings/remove.d.ts +9 -0
  77. package/dist/commands/settings/remove.js +35 -0
  78. package/dist/commands/settings/set.d.ts +10 -0
  79. package/dist/commands/settings/set.js +39 -0
  80. package/dist/commands/setup-debug.d.ts +12 -0
  81. package/dist/commands/setup-debug.js +118 -0
  82. package/dist/commands/status.d.ts +6 -0
  83. package/dist/commands/status.js +22 -0
  84. package/dist/commands/team/pull.d.ts +8 -0
  85. package/dist/commands/team/pull.js +23 -0
  86. package/dist/commands/team/push.d.ts +11 -0
  87. package/dist/commands/team/push.js +41 -0
  88. package/dist/commands/team/status.d.ts +8 -0
  89. package/dist/commands/team/status.js +40 -0
  90. package/dist/commands/test/scaffold.d.ts +9 -0
  91. package/dist/commands/test/scaffold.js +61 -0
  92. package/dist/commands/test.d.ts +13 -0
  93. package/dist/commands/test.js +72 -0
  94. package/dist/commands/variables/add.d.ts +12 -0
  95. package/dist/commands/variables/add.js +21 -0
  96. package/dist/commands/variables/pull.d.ts +12 -0
  97. package/dist/commands/variables/pull.js +14 -0
  98. package/dist/commands/variables/push.d.ts +12 -0
  99. package/dist/commands/variables/push.js +14 -0
  100. package/dist/commands/variables/remove.d.ts +9 -0
  101. package/dist/commands/variables/remove.js +19 -0
  102. package/dist/commands/variables/reset.d.ts +9 -0
  103. package/dist/commands/variables/reset.js +13 -0
  104. package/dist/commands/variables/status.d.ts +12 -0
  105. package/dist/commands/variables/status.js +58 -0
  106. package/dist/config/global.d.ts +15 -0
  107. package/dist/config/global.js +77 -0
  108. package/dist/config/index.d.ts +14 -0
  109. package/dist/config/index.js +44 -0
  110. package/dist/config/remote.d.ts +15 -0
  111. package/dist/config/remote.js +60 -0
  112. package/dist/config/settings.d.ts +16 -0
  113. package/dist/config/settings.js +54 -0
  114. package/dist/config/workspace.d.ts +28 -0
  115. package/dist/config/workspace.js +158 -0
  116. package/dist/core/commands/api-client-command.d.ts +6 -0
  117. package/dist/core/commands/api-client-command.js +30 -0
  118. package/dist/core/commands/base-command.d.ts +11 -0
  119. package/dist/core/commands/base-command.js +61 -0
  120. package/dist/core/commands/dependency-command.d.ts +5 -0
  121. package/dist/core/commands/dependency-command.js +16 -0
  122. package/dist/core/commands/modules-command.d.ts +7 -0
  123. package/dist/core/commands/modules-command.js +18 -0
  124. package/dist/core/commands/processes-command.d.ts +8 -0
  125. package/dist/core/commands/processes-command.js +27 -0
  126. package/dist/core/commands/resource-command.d.ts +24 -0
  127. package/dist/core/commands/resource-command.js +92 -0
  128. package/dist/core/commands/variables-command.d.ts +5 -0
  129. package/dist/core/commands/variables-command.js +16 -0
  130. package/dist/core/dependencies/env-dependencies-command.d.ts +19 -0
  131. package/dist/core/dependencies/env-dependencies-command.js +70 -0
  132. package/dist/core/dependencies/env-process-dependencies-command.d.ts +15 -0
  133. package/dist/core/dependencies/env-process-dependencies-command.js +78 -0
  134. package/dist/core/dependencies/javascript-env-dependencies.d.ts +8 -0
  135. package/dist/core/dependencies/javascript-env-dependencies.js +77 -0
  136. package/dist/core/dependencies/python-env-dependencies.d.ts +9 -0
  137. package/dist/core/dependencies/python-env-dependencies.js +91 -0
  138. package/dist/core/errors.d.ts +55 -0
  139. package/dist/core/errors.js +144 -0
  140. package/dist/core/executors/execution-task.d.ts +29 -0
  141. package/dist/core/executors/execution-task.js +139 -0
  142. package/dist/core/executors/javascript-execution-task.d.ts +13 -0
  143. package/dist/core/executors/javascript-execution-task.js +618 -0
  144. package/dist/core/executors/python/context.d.ts +2 -0
  145. package/dist/core/executors/python/context.js +3 -0
  146. package/dist/core/executors/python/datastore.d.ts +2 -0
  147. package/dist/core/executors/python/datastore.js +4 -0
  148. package/dist/core/executors/python-execution-task.d.ts +11 -0
  149. package/dist/core/executors/python-execution-task.js +173 -0
  150. package/dist/core/executors/source-code-sanitizer.d.ts +4 -0
  151. package/dist/core/executors/source-code-sanitizer.js +45 -0
  152. package/dist/core/resource-merger.d.ts +14 -0
  153. package/dist/core/resource-merger.js +155 -0
  154. package/dist/core/resource-pusher.d.ts +12 -0
  155. package/dist/core/resource-pusher.js +133 -0
  156. package/dist/core/resource-repository.d.ts +8 -0
  157. package/dist/core/resource-repository.js +2 -0
  158. package/dist/core/types.d.ts +290 -0
  159. package/dist/core/types.js +238 -0
  160. package/dist/core/utils/dependencies.d.ts +5 -0
  161. package/dist/core/utils/dependencies.js +82 -0
  162. package/dist/core/utils/variables.d.ts +4 -0
  163. package/dist/core/utils/variables.js +10 -0
  164. package/dist/hooks/init/auth.d.ts +3 -0
  165. package/dist/hooks/init/auth.js +28 -0
  166. package/dist/hooks/init/update.d.ts +3 -0
  167. package/dist/hooks/init/update.js +42 -0
  168. package/dist/index.d.ts +1 -0
  169. package/dist/index.js +4 -0
  170. package/dist/repositories/process.d.ts +36 -0
  171. package/dist/repositories/process.js +339 -0
  172. package/dist/repositories/programming-language-manifest.d.ts +17 -0
  173. package/dist/repositories/programming-language-manifest.js +95 -0
  174. package/dist/repositories/resource.d.ts +29 -0
  175. package/dist/repositories/resource.js +79 -0
  176. package/dist/repositories/script-library.d.ts +28 -0
  177. package/dist/repositories/script-library.js +164 -0
  178. package/dist/repositories/team.d.ts +23 -0
  179. package/dist/repositories/team.js +74 -0
  180. package/dist/repositories/variable.d.ts +26 -0
  181. package/dist/repositories/variable.js +174 -0
  182. package/dist/runtime/executor.js +87 -0
  183. package/dist/runtime/executor.py +81 -0
  184. package/dist/runtime/libs/node/fcode/index.js +1 -0
  185. package/dist/runtime/libs/python/fcode/__init__.py +75 -0
  186. package/dist/runtime/libs/python/fcode/context.py +98 -0
  187. package/dist/runtime/libs/python/fcode/datastore.py +35 -0
  188. package/dist/runtime/libs/python/fcode/schedule.py +45 -0
  189. package/dist/runtime/libs/python/fcode/storage.py +271 -0
  190. package/dist/runtime/libs/python/fcode/variables.py +102 -0
  191. package/dist/services/auth-service.d.ts +12 -0
  192. package/dist/services/auth-service.js +114 -0
  193. package/dist/services/credential-prompter.d.ts +6 -0
  194. package/dist/services/credential-prompter.js +60 -0
  195. package/dist/services/fcode-graphql-client.d.ts +45 -0
  196. package/dist/services/fcode-graphql-client.js +721 -0
  197. package/dist/services/http-server.d.ts +3 -0
  198. package/dist/services/http-server.js +17 -0
  199. package/dist/services/oauth-browser-service.d.ts +9 -0
  200. package/dist/services/oauth-browser-service.js +164 -0
  201. package/dist/services/process-parameters-sampler.d.ts +2 -0
  202. package/dist/services/process-parameters-sampler.js +41 -0
  203. package/dist/services/process-runner.d.ts +22 -0
  204. package/dist/services/process-runner.js +97 -0
  205. package/dist/services/resource-checker.d.ts +8 -0
  206. package/dist/services/resource-checker.js +82 -0
  207. package/dist/services/test-runner.d.ts +17 -0
  208. package/dist/services/test-runner.js +228 -0
  209. package/dist/utils/canonical-hash.d.ts +9 -0
  210. package/dist/utils/canonical-hash.js +30 -0
  211. package/dist/utils/cli/index.d.ts +14 -0
  212. package/dist/utils/cli/index.js +50 -0
  213. package/dist/utils/cli/screen.d.ts +2 -0
  214. package/dist/utils/cli/screen.js +25 -0
  215. package/dist/utils/cli/styled/table.d.ts +23 -0
  216. package/dist/utils/cli/styled/table.js +272 -0
  217. package/dist/utils/colorize-resource.d.ts +1 -0
  218. package/dist/utils/colorize-resource.js +7 -0
  219. package/dist/utils/env-utils.d.ts +2 -0
  220. package/dist/utils/env-utils.js +16 -0
  221. package/dist/utils/file-utils.d.ts +11 -0
  222. package/dist/utils/file-utils.js +33 -0
  223. package/dist/utils/filenamify.d.ts +4 -0
  224. package/dist/utils/filenamify.js +73 -0
  225. package/dist/utils/gitignore.d.ts +17 -0
  226. package/dist/utils/gitignore.js +60 -0
  227. package/dist/utils/promise.d.ts +4 -0
  228. package/dist/utils/promise.js +38 -0
  229. package/dist/utils/url-utils.d.ts +2 -0
  230. package/dist/utils/url-utils.js +10 -0
  231. package/dist/utils/variable-warnings.d.ts +8 -0
  232. package/dist/utils/variable-warnings.js +38 -0
  233. package/oclif.manifest.json +1783 -0
  234. package/package.json +129 -0
@@ -0,0 +1,290 @@
1
+ export type Credentials = {
2
+ url: string;
3
+ authUrl: string;
4
+ email?: string;
5
+ password?: string;
6
+ clientId?: string;
7
+ clientSecret?: string;
8
+ accessToken?: string;
9
+ };
10
+ export interface Token {
11
+ access_token: string;
12
+ refresh_token: string;
13
+ }
14
+ export interface UserInfo {
15
+ groups: string[];
16
+ name: string;
17
+ }
18
+ export interface AuthInfo {
19
+ authUrl: string;
20
+ token: Token;
21
+ userInfo: UserInfo;
22
+ }
23
+ export interface AuthConfig {
24
+ clientId: string;
25
+ url: string;
26
+ }
27
+ export interface TeamOrigin {
28
+ url: string;
29
+ slug: string;
30
+ }
31
+ export interface TeamMetadata {
32
+ [key: string]: any;
33
+ modules: {
34
+ [key: string]: ScriptLibrary;
35
+ };
36
+ processes: {
37
+ [key: string]: Process;
38
+ };
39
+ slug: string;
40
+ variables: {
41
+ [key: string]: Variable;
42
+ };
43
+ dependencies: {
44
+ [key: string]: ProgrammingLanguageManifest;
45
+ };
46
+ team?: {
47
+ contentHash?: string;
48
+ };
49
+ }
50
+ export interface RemoteMetadata {
51
+ [key: string]: any;
52
+ }
53
+ export interface Config {
54
+ [key: string]: any;
55
+ }
56
+ export interface Settings {
57
+ [key: string]: string;
58
+ }
59
+ export interface GlobalConfig extends Config {
60
+ auth?: AuthInfo;
61
+ versionCheckTime?: number;
62
+ settings?: Settings;
63
+ }
64
+ export interface WorkspaceConfig {
65
+ activeTeam: string;
66
+ teams: TeamMetadata[];
67
+ }
68
+ export type ResourceRepositoryOptions = {
69
+ name: string;
70
+ };
71
+ export declare abstract class Resource {
72
+ abstract readonly contentHash: string;
73
+ id: string | undefined;
74
+ slug: string;
75
+ errorPushing: boolean | undefined;
76
+ resolvingTeamSlug?: string;
77
+ sameAs(other: Resource): boolean;
78
+ }
79
+ export declare enum OnConflictResolution {
80
+ KEEP_LOCAL = 0,
81
+ KEEP_REMOTE = 1
82
+ }
83
+ export declare enum ResourceStatus {
84
+ CONFLICT = "\uD83D\uDD25 (conflict)",
85
+ REMOTE_REMOVED = "\uD83D\uDDD1\uFE0F\uD83C\uDF29\uFE0F (removed-remote)",
86
+ LOCAL_REMOVED = "\uD83D\uDDD1\uFE0F\uD83D\uDCBB (removed-local)",
87
+ MODIFIED = "\uD83D\uDD3A (modified)",
88
+ REMOTE_NEW = "\uD83C\uDF29\uFE0F (new-remote)",
89
+ LOCAL_NEW = "\u2728 (new-local)",
90
+ OUT_OF_DATE = "\uD83D\uDD3B (out-of-date)",
91
+ UP_TO_DATE = "\u2705 (up-to-date)",
92
+ SENSITIVE = "\uD83D\uDD12 (sensitive)",
93
+ SENSITIVITY_CHANGED = "\uD83D\uDEAB (sensitivity-changed)"
94
+ }
95
+ type MergedResourceRecord = Record<string, unknown> & Resource;
96
+ export type MergedResource = MergedResourceRecord & {
97
+ status: ResourceStatus;
98
+ };
99
+ export type ProgrammingLanguage = 'JAVASCRIPT' | 'PYTHON';
100
+ export declare const programmingLanguageDisplayName: (programmingLanguage: ProgrammingLanguage) => string;
101
+ export interface ProcessWebhook {
102
+ enabled: boolean;
103
+ username?: string;
104
+ password?: string;
105
+ }
106
+ export interface ProcessForm {
107
+ enabled: boolean;
108
+ }
109
+ export interface ProcessVisibility {
110
+ isPublic: boolean;
111
+ }
112
+ export interface ProcessMetadataFields {
113
+ name: string;
114
+ description?: string;
115
+ tags: string[];
116
+ webhook?: ProcessWebhook;
117
+ form?: ProcessForm;
118
+ visibility?: ProcessVisibility;
119
+ }
120
+ export declare class Process extends Resource {
121
+ id: string;
122
+ slug: string;
123
+ name: string;
124
+ description?: string;
125
+ readme: string;
126
+ tags: string[];
127
+ webhook?: ProcessWebhook;
128
+ form?: ProcessForm;
129
+ visibility?: ProcessVisibility;
130
+ script: {
131
+ parametersSchema: any;
132
+ programmingLanguage: ProgrammingLanguage;
133
+ sourceCode: string;
134
+ };
135
+ manifest: {
136
+ dependencies: Array<Dependency>;
137
+ };
138
+ settings: {
139
+ dependencies: {
140
+ scopedToProcess: boolean;
141
+ };
142
+ };
143
+ constructor(id: string, slug: string, script: any, readme: string, manifest: {
144
+ dependencies: Array<Dependency>;
145
+ } | null, settings: {
146
+ dependencies: {
147
+ scopedToProcess: boolean;
148
+ };
149
+ }, metadata: ProcessMetadataFields, resolvingTeamSlug?: string);
150
+ get contentHash(): string;
151
+ }
152
+ export declare class VersionedProcess extends Resource {
153
+ id: string;
154
+ slug: string;
155
+ tag: string;
156
+ readme: string;
157
+ script: {
158
+ parametersSchema: any;
159
+ programmingLanguage: ProgrammingLanguage;
160
+ sourceCode: string;
161
+ };
162
+ constructor(id: string, tag: string, script: any, readme: string);
163
+ get contentHash(): string;
164
+ }
165
+ export declare class ScriptLibrary extends Resource {
166
+ id: string;
167
+ slug: string;
168
+ name: string;
169
+ programmingLanguage: ProgrammingLanguage;
170
+ sourceCode: string;
171
+ constructor(id: string, name: string, sourceCode: string, programmingLanguage: ProgrammingLanguage, resolvingTeamSlug?: string);
172
+ get contentHash(): string;
173
+ }
174
+ export declare class VersionedScriptLibrary extends Resource {
175
+ id: string;
176
+ slug: string;
177
+ tag: string;
178
+ programmingLanguage: ProgrammingLanguage;
179
+ sourceCode: string;
180
+ constructor(id: string, tag: string, sourceCode: string, programmingLanguage: ProgrammingLanguage);
181
+ get contentHash(): string;
182
+ }
183
+ export declare class Variable extends Resource {
184
+ static ENV_KEY_MAX_LENGTH: number;
185
+ static ENV_KEY_REGEX: RegExp;
186
+ id: string | undefined;
187
+ slug: string;
188
+ isSensitive: boolean;
189
+ key: string;
190
+ value: string;
191
+ overriddenLocally?: boolean;
192
+ constructor(id: string | undefined, key: string, value: string, isSensitive: boolean);
193
+ static validate(variable: Variable): Variable;
194
+ get contentHash(): string;
195
+ }
196
+ export declare class ProgrammingLanguageManifest extends Resource {
197
+ id: string | undefined;
198
+ slug: string;
199
+ programmingLanguage: ProgrammingLanguage;
200
+ dependencies: Array<Dependency>;
201
+ constructor(id: string, slug: string, programmingLanguage: ProgrammingLanguage, dependencies: Array<Dependency>);
202
+ get contentHash(): string;
203
+ }
204
+ export interface ErrorHandlerConfig {
205
+ processSlug: string;
206
+ tag?: string | null;
207
+ }
208
+ export declare class Team extends Resource {
209
+ id: string | undefined;
210
+ slug: string;
211
+ zoneId?: string;
212
+ errorHandlerConfig?: ErrorHandlerConfig;
213
+ parentTeamSlugs: string[];
214
+ constructor(slug: string, parentTeamSlugs: string[], zoneId?: string, errorHandlerConfig?: ErrorHandlerConfig);
215
+ get contentHash(): string;
216
+ }
217
+ export interface RawErrorHandlerConfig {
218
+ processId: string;
219
+ tag?: string | null;
220
+ }
221
+ export interface RawTeamSettings {
222
+ slug: string;
223
+ zoneId?: string;
224
+ errorHandlerConfig?: RawErrorHandlerConfig | null;
225
+ parentTeamSlugs: string[];
226
+ }
227
+ export interface TeamUpdateInput {
228
+ zoneId?: string;
229
+ parentTeamSlugs?: string[];
230
+ executionErrorHandlerConfig?: RawErrorHandlerConfig | null;
231
+ }
232
+ export type ResourceMetadata = {
233
+ [key: string]: any;
234
+ };
235
+ export interface AddResourceOptions {
236
+ variableSensitive: boolean;
237
+ }
238
+ export type FcodeGraphQLClientOptions = {
239
+ accessToken: string;
240
+ teamSlug: string;
241
+ };
242
+ export declare class ProcessNotFound extends Error {
243
+ }
244
+ export declare class ScriptLibraryNotFound extends Error {
245
+ }
246
+ export interface WebhookRequest {
247
+ headers: Record<string, string>;
248
+ rawBody: string;
249
+ query: Record<string, string>;
250
+ method: string;
251
+ }
252
+ export type ExecutionOptions = {
253
+ version: string | undefined;
254
+ parameters: any;
255
+ variables: Array<Variable>;
256
+ logLevel: string;
257
+ request?: WebhookRequest;
258
+ jsonLogs?: boolean;
259
+ hookFilePath?: string;
260
+ hookFunction?: string;
261
+ silent?: boolean;
262
+ };
263
+ export declare const ForceFlag: {
264
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
265
+ };
266
+ export declare const ResourceSlugArg: {
267
+ resourceSlug: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
268
+ };
269
+ export declare const TeamNameArg: {
270
+ team: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
271
+ };
272
+ export declare const DependenciesFlags: {
273
+ check: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
274
+ reset: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
275
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
276
+ };
277
+ export declare class Dependency {
278
+ name: string;
279
+ specifier: string;
280
+ }
281
+ export declare class ServiceAccount extends Resource {
282
+ id: string;
283
+ slug: string;
284
+ name: string;
285
+ clientId: string;
286
+ clientSecret: string;
287
+ constructor(id: string, name: string, clientId: string, clientSecret: string);
288
+ get contentHash(): string;
289
+ }
290
+ export {};
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServiceAccount = exports.Dependency = exports.DependenciesFlags = exports.TeamNameArg = exports.ResourceSlugArg = exports.ForceFlag = exports.ScriptLibraryNotFound = exports.ProcessNotFound = exports.Team = exports.ProgrammingLanguageManifest = exports.Variable = exports.VersionedScriptLibrary = exports.ScriptLibrary = exports.VersionedProcess = exports.Process = exports.programmingLanguageDisplayName = exports.ResourceStatus = exports.OnConflictResolution = exports.Resource = void 0;
4
+ const core_1 = require("@oclif/core");
5
+ const crypto = require("node:crypto");
6
+ const canonical_hash_1 = require("../utils/canonical-hash");
7
+ class Resource {
8
+ sameAs(other) {
9
+ return this.slug === other.slug;
10
+ }
11
+ }
12
+ exports.Resource = Resource;
13
+ var OnConflictResolution;
14
+ (function (OnConflictResolution) {
15
+ OnConflictResolution[OnConflictResolution["KEEP_LOCAL"] = 0] = "KEEP_LOCAL";
16
+ OnConflictResolution[OnConflictResolution["KEEP_REMOTE"] = 1] = "KEEP_REMOTE";
17
+ })(OnConflictResolution || (exports.OnConflictResolution = OnConflictResolution = {}));
18
+ var ResourceStatus;
19
+ (function (ResourceStatus) {
20
+ ResourceStatus["CONFLICT"] = "\uD83D\uDD25 (conflict)";
21
+ ResourceStatus["REMOTE_REMOVED"] = "\uD83D\uDDD1\uFE0F\uD83C\uDF29\uFE0F (removed-remote)";
22
+ ResourceStatus["LOCAL_REMOVED"] = "\uD83D\uDDD1\uFE0F\uD83D\uDCBB (removed-local)";
23
+ ResourceStatus["MODIFIED"] = "\uD83D\uDD3A (modified)";
24
+ ResourceStatus["REMOTE_NEW"] = "\uD83C\uDF29\uFE0F (new-remote)";
25
+ ResourceStatus["LOCAL_NEW"] = "\u2728 (new-local)";
26
+ ResourceStatus["OUT_OF_DATE"] = "\uD83D\uDD3B (out-of-date)";
27
+ ResourceStatus["UP_TO_DATE"] = "\u2705 (up-to-date)";
28
+ ResourceStatus["SENSITIVE"] = "\uD83D\uDD12 (sensitive)";
29
+ ResourceStatus["SENSITIVITY_CHANGED"] = "\uD83D\uDEAB (sensitivity-changed)";
30
+ })(ResourceStatus || (exports.ResourceStatus = ResourceStatus = {}));
31
+ const programmingLanguageDisplayName = (programmingLanguage) => {
32
+ switch (programmingLanguage) {
33
+ case 'JAVASCRIPT':
34
+ return 'JavaScript';
35
+ case 'PYTHON':
36
+ return 'Python';
37
+ }
38
+ };
39
+ exports.programmingLanguageDisplayName = programmingLanguageDisplayName;
40
+ class Process extends Resource {
41
+ constructor(id, slug, script, readme, manifest, settings, metadata, resolvingTeamSlug) {
42
+ super();
43
+ this.id = id;
44
+ this.slug = slug;
45
+ this.name = metadata.name;
46
+ this.description = metadata.description;
47
+ this.tags = metadata.tags;
48
+ this.webhook = metadata.webhook;
49
+ this.form = metadata.form;
50
+ this.visibility = metadata.visibility;
51
+ this.script = script;
52
+ this.readme = readme;
53
+ this.manifest = settings.dependencies.scopedToProcess && manifest !== null ? manifest : { dependencies: [] };
54
+ this.settings = settings;
55
+ this.resolvingTeamSlug = resolvingTeamSlug;
56
+ }
57
+ get contentHash() {
58
+ return (0, canonical_hash_1.canonicalJsonHash)({
59
+ name: this.name || '',
60
+ description: this.description || '',
61
+ parametersSchema: this.script?.parametersSchema || {},
62
+ readme: this.readme || '',
63
+ sourceCode: this.script?.sourceCode || '',
64
+ tags: this.tags || [],
65
+ webhook: this.webhook || null,
66
+ form: this.form || null,
67
+ visibility: this.visibility || null,
68
+ manifestDependencies: this.manifest.dependencies,
69
+ dependenciesScopedToProcess: this.settings.dependencies.scopedToProcess,
70
+ });
71
+ }
72
+ }
73
+ exports.Process = Process;
74
+ class VersionedProcess extends Resource {
75
+ constructor(id, tag, script, readme) {
76
+ super();
77
+ this.id = id;
78
+ this.slug = id;
79
+ this.tag = tag;
80
+ this.script = script;
81
+ this.readme = readme;
82
+ }
83
+ get contentHash() {
84
+ return crypto
85
+ .createHash('md5')
86
+ .update(JSON.stringify({ parametersSchema: this.script?.parametersSchema || {}, readme: this.readme || '', sourceCode: this.script?.sourceCode || '' }))
87
+ .digest('hex');
88
+ }
89
+ }
90
+ exports.VersionedProcess = VersionedProcess;
91
+ class ScriptLibrary extends Resource {
92
+ constructor(id, name, sourceCode, programmingLanguage, resolvingTeamSlug) {
93
+ super();
94
+ this.id = id;
95
+ this.slug = name;
96
+ this.name = name;
97
+ this.sourceCode = sourceCode;
98
+ this.programmingLanguage = programmingLanguage;
99
+ this.resolvingTeamSlug = resolvingTeamSlug;
100
+ }
101
+ get contentHash() {
102
+ return crypto.createHash('md5').update(this.sourceCode).digest('hex');
103
+ }
104
+ }
105
+ exports.ScriptLibrary = ScriptLibrary;
106
+ class VersionedScriptLibrary extends Resource {
107
+ constructor(id, tag, sourceCode, programmingLanguage) {
108
+ super();
109
+ this.id = id;
110
+ this.slug = id;
111
+ this.tag = tag;
112
+ this.sourceCode = sourceCode;
113
+ this.programmingLanguage = programmingLanguage;
114
+ }
115
+ get contentHash() {
116
+ return crypto.createHash('md5').update(this.sourceCode).digest('hex');
117
+ }
118
+ }
119
+ exports.VersionedScriptLibrary = VersionedScriptLibrary;
120
+ class Variable extends Resource {
121
+ constructor(id, key, value, isSensitive) {
122
+ super();
123
+ this.id = id;
124
+ this.slug = key;
125
+ this.key = key;
126
+ this.value = value;
127
+ this.isSensitive = isSensitive;
128
+ }
129
+ static validate(variable) {
130
+ if (!Variable.ENV_KEY_REGEX.test(variable.key)) {
131
+ throw new Error(`Variable key "${variable.key}" is not valid. Use letters, '_' or numbers, and don't start with a number`);
132
+ }
133
+ if (variable.key.length > Variable.ENV_KEY_MAX_LENGTH) {
134
+ throw new Error(`Variable key "${variable.key}" exceed ${Variable.ENV_KEY_MAX_LENGTH} characters`);
135
+ }
136
+ return variable;
137
+ }
138
+ get contentHash() {
139
+ if (this.isSensitive) {
140
+ return '';
141
+ }
142
+ return crypto
143
+ .createHash('md5')
144
+ .update(this.value || '')
145
+ .digest('hex');
146
+ }
147
+ }
148
+ exports.Variable = Variable;
149
+ Variable.ENV_KEY_MAX_LENGTH = 64;
150
+ Variable.ENV_KEY_REGEX = /^[A-Z_a-z]\w*$/;
151
+ class ProgrammingLanguageManifest extends Resource {
152
+ constructor(id, slug, programmingLanguage, dependencies) {
153
+ super();
154
+ this.id = id;
155
+ this.slug = slug;
156
+ this.programmingLanguage = programmingLanguage;
157
+ this.dependencies = dependencies;
158
+ }
159
+ get contentHash() {
160
+ return crypto
161
+ .createHash('md5')
162
+ .update(JSON.stringify({ slug: this.slug, programmingLanguage: this.programmingLanguage, dependencies: this.dependencies }))
163
+ .digest('hex');
164
+ }
165
+ }
166
+ exports.ProgrammingLanguageManifest = ProgrammingLanguageManifest;
167
+ class Team extends Resource {
168
+ constructor(slug, parentTeamSlugs, zoneId, errorHandlerConfig) {
169
+ super();
170
+ this.slug = slug;
171
+ this.parentTeamSlugs = parentTeamSlugs;
172
+ this.zoneId = zoneId;
173
+ this.errorHandlerConfig = errorHandlerConfig;
174
+ }
175
+ get contentHash() {
176
+ return (0, canonical_hash_1.canonicalJsonHash)({
177
+ zoneId: this.zoneId || null,
178
+ errorHandlerConfig: this.errorHandlerConfig || null,
179
+ parentTeamSlugs: [...(this.parentTeamSlugs || [])].sort(),
180
+ });
181
+ }
182
+ }
183
+ exports.Team = Team;
184
+ class ProcessNotFound extends Error {
185
+ }
186
+ exports.ProcessNotFound = ProcessNotFound;
187
+ class ScriptLibraryNotFound extends Error {
188
+ }
189
+ exports.ScriptLibraryNotFound = ScriptLibraryNotFound;
190
+ exports.ForceFlag = {
191
+ force: core_1.Flags.boolean({
192
+ char: 'f',
193
+ description: 'Force command',
194
+ }),
195
+ };
196
+ exports.ResourceSlugArg = {
197
+ resourceSlug: core_1.Args.string({
198
+ description: 'Resource slug',
199
+ name: 'slug',
200
+ }),
201
+ };
202
+ exports.TeamNameArg = {
203
+ team: core_1.Args.string({ description: 'Team name', name: 'team' }),
204
+ };
205
+ exports.DependenciesFlags = {
206
+ check: core_1.Flags.boolean({
207
+ char: 'c',
208
+ description: 'Check if is needed to install dependencies',
209
+ }),
210
+ reset: core_1.Flags.boolean({
211
+ char: 'r',
212
+ description: 'Remove all existing dependencies before installing',
213
+ }),
214
+ force: core_1.Flags.boolean({
215
+ char: 'f',
216
+ description: 'Force dependencies installation even if they are already installed',
217
+ }),
218
+ };
219
+ class Dependency {
220
+ }
221
+ exports.Dependency = Dependency;
222
+ class ServiceAccount extends Resource {
223
+ constructor(id, name, clientId, clientSecret) {
224
+ super();
225
+ this.id = id;
226
+ this.slug = name;
227
+ this.name = name;
228
+ this.clientId = clientId;
229
+ this.clientSecret = clientSecret;
230
+ }
231
+ get contentHash() {
232
+ return crypto
233
+ .createHash('md5')
234
+ .update(JSON.stringify({ name: this.name, clientId: this.clientId, clientSecret: this.clientSecret }))
235
+ .digest('hex');
236
+ }
237
+ }
238
+ exports.ServiceAccount = ServiceAccount;
@@ -0,0 +1,5 @@
1
+ import type { Dependency, Process, ProgrammingLanguage } from '../types';
2
+ export declare function getDependenciesPath(programmingLanguage: ProgrammingLanguage): Promise<string>;
3
+ export declare function getProcessDependenciesPath(process: Process): string;
4
+ export declare function dependenciesToFile(programmingLanguage: ProgrammingLanguage, dependencies?: Array<Dependency>): string;
5
+ export declare function dependenciesFromFile(programmingLanguage: ProgrammingLanguage, fileContent: string): Array<Dependency>;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDependenciesPath = getDependenciesPath;
4
+ exports.getProcessDependenciesPath = getProcessDependenciesPath;
5
+ exports.dependenciesToFile = dependenciesToFile;
6
+ exports.dependenciesFromFile = dependenciesFromFile;
7
+ const path = require("node:path");
8
+ const workspace_1 = require("../../config/workspace");
9
+ const programming_language_manifest_1 = require("../../repositories/programming-language-manifest");
10
+ const env_dependencies_command_1 = require("../dependencies/env-dependencies-command");
11
+ async function getDependenciesPath(programmingLanguage) {
12
+ const basePath = (0, workspace_1.baseDependenciesPath)(programmingLanguage);
13
+ const repo = new programming_language_manifest_1.default();
14
+ const programmingLanguageManifest = await repo.find(programmingLanguage);
15
+ const dependenciesDirectory = (0, env_dependencies_command_1.dependenciesHash)(programmingLanguageManifest.dependencies);
16
+ return path.join(basePath, dependenciesDirectory);
17
+ }
18
+ function getProcessDependenciesPath(process) {
19
+ const basePath = (0, workspace_1.baseDependenciesPath)(process.script.programmingLanguage);
20
+ const dependenciesDirectory = (0, env_dependencies_command_1.dependenciesHash)(process.manifest?.dependencies ?? []);
21
+ return path.join(basePath, dependenciesDirectory);
22
+ }
23
+ function dependenciesToFile(programmingLanguage, dependencies = []) {
24
+ switch (programmingLanguage) {
25
+ case 'JAVASCRIPT':
26
+ if (dependencies.length === 0) {
27
+ return '{\n \n}\n';
28
+ }
29
+ return '{\n' + dependencies.map((dependency) => ` "${dependency.name}": "${dependency.specifier}"`).join(',\n') + '\n}\n';
30
+ case 'PYTHON':
31
+ return (dependencies
32
+ .map((dependency) => {
33
+ if (dependency.specifier.startsWith('git+')) {
34
+ return `${dependency.name} @ ${dependency.specifier}`;
35
+ }
36
+ return `${dependency.name}==${dependency.specifier}`;
37
+ })
38
+ .join('\n') + '\n');
39
+ default:
40
+ return '';
41
+ }
42
+ }
43
+ function dependenciesFromFile(programmingLanguage, fileContent) {
44
+ if (!fileContent.trim()) {
45
+ return [];
46
+ }
47
+ const dependencies = new Array();
48
+ switch (programmingLanguage) {
49
+ case 'JAVASCRIPT':
50
+ let dependenciesObject = JSON.parse(fileContent);
51
+ if (typeof dependenciesObject?.dependencies === 'object') {
52
+ dependenciesObject = dependenciesObject.dependencies;
53
+ }
54
+ for (const dependency of Object.keys(dependenciesObject)) {
55
+ dependencies.push({
56
+ name: dependency,
57
+ specifier: dependenciesObject[dependency],
58
+ });
59
+ }
60
+ break;
61
+ case 'PYTHON':
62
+ fileContent.split('\n').map((line) => {
63
+ let tokens;
64
+ if (line.includes(' @ ')) {
65
+ tokens = line.split(' @ ');
66
+ }
67
+ else {
68
+ tokens = line.split('==');
69
+ }
70
+ if (tokens.length !== 2) {
71
+ return;
72
+ }
73
+ dependencies.push({
74
+ name: tokens[0],
75
+ specifier: tokens[1],
76
+ });
77
+ });
78
+ break;
79
+ default:
80
+ }
81
+ return dependencies.sort((a, b) => a.name.localeCompare(b.name));
82
+ }
@@ -0,0 +1,4 @@
1
+ export declare const getVariablesObject: (variables: Array<{
2
+ key: string;
3
+ value: string;
4
+ }>) => {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVariablesObject = void 0;
4
+ const getVariablesObject = (variables) =>
5
+ // eslint-disable-next-line unicorn/no-array-reduce, unicorn/prefer-object-from-entries
6
+ variables.reduce((teamVariables, { key, value }) => ({
7
+ ...teamVariables,
8
+ [key]: value,
9
+ }), {});
10
+ exports.getVariablesObject = getVariablesObject;
@@ -0,0 +1,3 @@
1
+ import { Hook } from '@oclif/core';
2
+ declare const auth: Hook<'init'>;
3
+ export default auth;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dotenv_1 = require("dotenv");
4
+ const auth_service_1 = require("../../services/auth-service");
5
+ const credential_prompter_1 = require("../../services/credential-prompter");
6
+ const oauth_browser_service_1 = require("../../services/oauth-browser-service");
7
+ const global_1 = require("../../config/global");
8
+ const url_utils_1 = require("../../utils/url-utils");
9
+ const auth = async function ({ argv }) {
10
+ const url = argv[0] || global_1.FCODE_CLOUD_URL;
11
+ const authUrl = argv[1] || (0, url_utils_1.buildAuthUrl)(url);
12
+ const isAuthenticated = await auth_service_1.default.isAuthenticated(url);
13
+ if (!isAuthenticated) {
14
+ (0, dotenv_1.config)();
15
+ const accessToken = argv[6];
16
+ const prompt = argv[7];
17
+ if (accessToken) {
18
+ await auth_service_1.default.login({ url, authUrl, accessToken });
19
+ }
20
+ else if (prompt || argv[2] || argv[3] || (argv[4] && argv[5])) {
21
+ await credential_prompter_1.default.prompt({ url, authUrl, email: argv[2], password: argv[3], clientId: argv[4], clientSecret: argv[5] });
22
+ }
23
+ else {
24
+ await (0, oauth_browser_service_1.loginViaBrowser)(url, authUrl, argv[4]);
25
+ }
26
+ }
27
+ };
28
+ exports.default = auth;
@@ -0,0 +1,3 @@
1
+ import { Hook } from '@oclif/core';
2
+ declare const updateNotifier: Hook<'init'>;
3
+ export default updateNotifier;