appwrite-cli 12.0.0 → 13.0.0-rc.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 (283) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +145 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/client.d.ts +89 -0
  8. package/dist/lib/client.d.ts.map +1 -0
  9. package/dist/lib/client.js +227 -0
  10. package/dist/lib/client.js.map +1 -0
  11. package/dist/lib/commands/account.d.ts +379 -0
  12. package/dist/lib/commands/account.d.ts.map +1 -0
  13. package/dist/lib/commands/account.js +1228 -0
  14. package/dist/lib/commands/account.js.map +1 -0
  15. package/dist/lib/commands/console.d.ts +20 -0
  16. package/dist/lib/commands/console.d.ts.map +1 -0
  17. package/dist/lib/commands/console.js +78 -0
  18. package/dist/lib/commands/console.js.map +1 -0
  19. package/dist/lib/commands/databases.d.ts +732 -0
  20. package/dist/lib/commands/databases.d.ts.map +1 -0
  21. package/dist/lib/commands/databases.js +2196 -0
  22. package/dist/lib/commands/databases.js.map +1 -0
  23. package/dist/lib/commands/functions.d.ts +310 -0
  24. package/dist/lib/commands/functions.d.ts.map +1 -0
  25. package/dist/lib/commands/functions.js +1100 -0
  26. package/dist/lib/commands/functions.js.map +1 -0
  27. package/dist/lib/commands/generic.d.ts +17 -0
  28. package/dist/lib/commands/generic.d.ts.map +1 -0
  29. package/dist/lib/commands/generic.js +279 -0
  30. package/dist/lib/commands/generic.js.map +1 -0
  31. package/dist/lib/commands/graphql.d.ts +19 -0
  32. package/dist/lib/commands/graphql.d.ts.map +1 -0
  33. package/dist/lib/commands/graphql.js +77 -0
  34. package/dist/lib/commands/graphql.js.map +1 -0
  35. package/dist/lib/commands/health.d.ts +153 -0
  36. package/dist/lib/commands/health.d.ts.map +1 -0
  37. package/dist/lib/commands/health.js +464 -0
  38. package/dist/lib/commands/health.js.map +1 -0
  39. package/dist/lib/commands/init.d.ts +3 -0
  40. package/dist/lib/commands/init.d.ts.map +1 -0
  41. package/dist/lib/commands/init.js +518 -0
  42. package/dist/lib/commands/init.js.map +1 -0
  43. package/dist/lib/commands/locale.d.ts +53 -0
  44. package/dist/lib/commands/locale.d.ts.map +1 -0
  45. package/dist/lib/commands/locale.js +165 -0
  46. package/dist/lib/commands/locale.js.map +1 -0
  47. package/dist/lib/commands/messaging.d.ts +588 -0
  48. package/dist/lib/commands/messaging.d.ts.map +1 -0
  49. package/dist/lib/commands/messaging.js +2042 -0
  50. package/dist/lib/commands/messaging.js.map +1 -0
  51. package/dist/lib/commands/migrations.d.ts +150 -0
  52. package/dist/lib/commands/migrations.d.ts.map +1 -0
  53. package/dist/lib/commands/migrations.js +524 -0
  54. package/dist/lib/commands/migrations.js.map +1 -0
  55. package/dist/lib/commands/organizations.d.ts +11 -0
  56. package/dist/lib/commands/organizations.d.ts.map +1 -0
  57. package/dist/lib/commands/organizations.js +31 -0
  58. package/dist/lib/commands/organizations.js.map +1 -0
  59. package/dist/lib/commands/project.d.ts +53 -0
  60. package/dist/lib/commands/project.d.ts.map +1 -0
  61. package/dist/lib/commands/project.js +176 -0
  62. package/dist/lib/commands/project.js.map +1 -0
  63. package/dist/lib/commands/projects.d.ts +516 -0
  64. package/dist/lib/commands/projects.d.ts.map +1 -0
  65. package/dist/lib/commands/projects.js +1590 -0
  66. package/dist/lib/commands/projects.js.map +1 -0
  67. package/dist/lib/commands/proxy.d.ts +71 -0
  68. package/dist/lib/commands/proxy.d.ts.map +1 -0
  69. package/dist/lib/commands/proxy.js +240 -0
  70. package/dist/lib/commands/proxy.js.map +1 -0
  71. package/dist/lib/commands/pull.d.ts +8 -0
  72. package/dist/lib/commands/pull.d.ts.map +1 -0
  73. package/dist/lib/commands/pull.js +455 -0
  74. package/dist/lib/commands/pull.js.map +1 -0
  75. package/dist/lib/commands/push.d.ts +4 -0
  76. package/dist/lib/commands/push.d.ts.map +1 -0
  77. package/dist/lib/commands/push.js +2154 -0
  78. package/dist/lib/commands/push.js.map +1 -0
  79. package/dist/lib/commands/run.d.ts +3 -0
  80. package/dist/lib/commands/run.d.ts.map +1 -0
  81. package/dist/lib/commands/run.js +287 -0
  82. package/dist/lib/commands/run.js.map +1 -0
  83. package/dist/lib/commands/sites.d.ts +296 -0
  84. package/dist/lib/commands/sites.d.ts.map +1 -0
  85. package/dist/lib/commands/sites.js +1046 -0
  86. package/dist/lib/commands/sites.js.map +1 -0
  87. package/dist/lib/commands/storage.d.ts +170 -0
  88. package/dist/lib/commands/storage.d.ts.map +1 -0
  89. package/dist/lib/commands/storage.js +651 -0
  90. package/dist/lib/commands/storage.js.map +1 -0
  91. package/dist/lib/commands/tables-db.d.ts +728 -0
  92. package/dist/lib/commands/tables-db.d.ts.map +1 -0
  93. package/dist/lib/commands/tables-db.js +2198 -0
  94. package/dist/lib/commands/tables-db.js.map +1 -0
  95. package/dist/lib/commands/teams.d.ts +129 -0
  96. package/dist/lib/commands/teams.d.ts.map +1 -0
  97. package/dist/lib/commands/teams.js +403 -0
  98. package/dist/lib/commands/teams.js.map +1 -0
  99. package/dist/lib/commands/tokens.d.ts +48 -0
  100. package/dist/lib/commands/tokens.d.ts.map +1 -0
  101. package/dist/lib/commands/tokens.js +156 -0
  102. package/dist/lib/commands/tokens.js.map +1 -0
  103. package/dist/lib/commands/types.d.ts +3 -0
  104. package/dist/lib/commands/types.d.ts.map +1 -0
  105. package/dist/lib/commands/types.js +155 -0
  106. package/dist/lib/commands/types.js.map +1 -0
  107. package/dist/lib/commands/update.d.ts +3 -0
  108. package/dist/lib/commands/update.d.ts.map +1 -0
  109. package/dist/lib/commands/update.js +202 -0
  110. package/dist/lib/commands/update.js.map +1 -0
  111. package/dist/lib/commands/users.d.ts +382 -0
  112. package/dist/lib/commands/users.d.ts.map +1 -0
  113. package/dist/lib/commands/users.js +1195 -0
  114. package/dist/lib/commands/users.js.map +1 -0
  115. package/dist/lib/commands/vcs.d.ts +92 -0
  116. package/dist/lib/commands/vcs.d.ts.map +1 -0
  117. package/dist/lib/commands/vcs.js +276 -0
  118. package/dist/lib/commands/vcs.js.map +1 -0
  119. package/dist/lib/config.d.ts +118 -0
  120. package/dist/lib/config.d.ts.map +1 -0
  121. package/{lib → dist/lib}/config.js +204 -325
  122. package/dist/lib/config.js.map +1 -0
  123. package/dist/lib/emulation/docker.d.ts +15 -0
  124. package/dist/lib/emulation/docker.d.ts.map +1 -0
  125. package/dist/lib/emulation/docker.js +220 -0
  126. package/dist/lib/emulation/docker.js.map +1 -0
  127. package/dist/lib/emulation/utils.d.ts +29 -0
  128. package/dist/lib/emulation/utils.d.ts.map +1 -0
  129. package/dist/lib/emulation/utils.js +168 -0
  130. package/dist/lib/emulation/utils.js.map +1 -0
  131. package/dist/lib/exception.d.ts +8 -0
  132. package/dist/lib/exception.d.ts.map +1 -0
  133. package/dist/lib/exception.js +16 -0
  134. package/dist/lib/exception.js.map +1 -0
  135. package/dist/lib/id.d.ts +7 -0
  136. package/dist/lib/id.d.ts.map +1 -0
  137. package/dist/lib/id.js +32 -0
  138. package/dist/lib/id.js.map +1 -0
  139. package/dist/lib/paginate.d.ts +10 -0
  140. package/dist/lib/paginate.d.ts.map +1 -0
  141. package/{lib → dist/lib}/paginate.js +9 -15
  142. package/dist/lib/paginate.js.map +1 -0
  143. package/dist/lib/parser.d.ts +18 -0
  144. package/dist/lib/parser.d.ts.map +1 -0
  145. package/dist/lib/parser.js +237 -0
  146. package/dist/lib/parser.js.map +1 -0
  147. package/dist/lib/questions.d.ts +59 -0
  148. package/dist/lib/questions.d.ts.map +1 -0
  149. package/dist/lib/questions.js +995 -0
  150. package/dist/lib/questions.js.map +1 -0
  151. package/dist/lib/sdks.d.ts +4 -0
  152. package/dist/lib/sdks.d.ts.map +1 -0
  153. package/dist/lib/sdks.js +51 -0
  154. package/dist/lib/sdks.js.map +1 -0
  155. package/dist/lib/spinner.d.ts +28 -0
  156. package/dist/lib/spinner.d.ts.map +1 -0
  157. package/{lib → dist/lib}/spinner.js +34 -45
  158. package/dist/lib/spinner.js.map +1 -0
  159. package/dist/lib/type-generation/attribute.d.ts +17 -0
  160. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  161. package/dist/lib/type-generation/attribute.js +19 -0
  162. package/dist/lib/type-generation/attribute.js.map +1 -0
  163. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  164. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  165. package/dist/lib/type-generation/languages/csharp.js +180 -0
  166. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  167. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  168. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  169. package/dist/lib/type-generation/languages/dart.js +197 -0
  170. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  171. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  172. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  173. package/dist/lib/type-generation/languages/java.js +140 -0
  174. package/dist/lib/type-generation/languages/java.js.map +1 -0
  175. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  176. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  177. package/dist/lib/type-generation/languages/javascript.js +108 -0
  178. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  179. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  180. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  181. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  182. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  183. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  184. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  185. package/dist/lib/type-generation/languages/language.js +82 -0
  186. package/dist/lib/type-generation/languages/language.js.map +1 -0
  187. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  188. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  189. package/dist/lib/type-generation/languages/php.js +116 -0
  190. package/dist/lib/type-generation/languages/php.js.map +1 -0
  191. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  192. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  193. package/dist/lib/type-generation/languages/swift.js +179 -0
  194. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  195. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  196. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  197. package/dist/lib/type-generation/languages/typescript.js +112 -0
  198. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  199. package/dist/lib/types.d.ts +133 -0
  200. package/dist/lib/types.d.ts.map +1 -0
  201. package/dist/lib/types.js +3 -0
  202. package/dist/lib/types.js.map +1 -0
  203. package/dist/lib/utils.d.ts +15 -0
  204. package/dist/lib/utils.d.ts.map +1 -0
  205. package/{lib → dist/lib}/utils.js +74 -120
  206. package/dist/lib/utils.js.map +1 -0
  207. package/dist/lib/validations.d.ts +2 -0
  208. package/dist/lib/validations.d.ts.map +1 -0
  209. package/dist/lib/validations.js +20 -0
  210. package/dist/lib/validations.js.map +1 -0
  211. package/docs/examples/databases/upsert-document.md +1 -2
  212. package/index.ts +152 -0
  213. package/install.ps1 +2 -5
  214. package/install.sh +1 -2
  215. package/lib/client.ts +259 -0
  216. package/lib/commands/{account.js → account.ts} +410 -664
  217. package/lib/commands/console.ts +112 -0
  218. package/lib/commands/{databases.js → databases.ts} +818 -1136
  219. package/lib/commands/{functions.js → functions.ts} +381 -526
  220. package/lib/commands/{generic.js → generic.ts} +47 -39
  221. package/lib/commands/graphql.ts +110 -0
  222. package/lib/commands/{health.js → health.ts} +168 -284
  223. package/lib/commands/{init.js → init.ts} +68 -66
  224. package/lib/commands/{locale.js → locale.ts} +75 -121
  225. package/lib/commands/{messaging.js → messaging.ts} +699 -937
  226. package/lib/commands/{migrations.js → migrations.ts} +182 -258
  227. package/lib/commands/organizations.ts +46 -0
  228. package/lib/commands/{project.js → project.ts} +75 -111
  229. package/lib/commands/{projects.js → projects.ts} +587 -843
  230. package/lib/commands/{proxy.js → proxy.ts} +94 -140
  231. package/lib/commands/{pull.js → pull.ts} +54 -44
  232. package/lib/commands/{push.js → push.ts} +235 -191
  233. package/lib/commands/{run.js → run.ts} +61 -55
  234. package/lib/commands/{sites.js → sites.ts} +364 -504
  235. package/lib/commands/{storage.js → storage.ts} +216 -292
  236. package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
  237. package/lib/commands/{teams.js → teams.ts} +162 -236
  238. package/lib/commands/{tokens.js → tokens.ts} +70 -99
  239. package/lib/commands/{types.js → types.ts} +37 -35
  240. package/lib/commands/{update.js → update.ts} +25 -27
  241. package/lib/commands/{users.js → users.ts} +426 -644
  242. package/lib/commands/{vcs.js → vcs.ts} +122 -173
  243. package/lib/config.ts +854 -0
  244. package/lib/emulation/{docker.js → docker.ts} +39 -38
  245. package/lib/emulation/utils.ts +193 -0
  246. package/lib/exception.ts +20 -0
  247. package/lib/{id.js → id.ts} +5 -5
  248. package/lib/paginate.ts +63 -0
  249. package/lib/parser.ts +238 -0
  250. package/lib/{questions.js → questions.ts} +148 -156
  251. package/lib/sdks.ts +55 -0
  252. package/lib/spinner.ts +118 -0
  253. package/lib/type-generation/attribute.ts +17 -0
  254. package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -48
  255. package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
  256. package/lib/type-generation/languages/{java.js → java.ts} +58 -47
  257. package/lib/type-generation/languages/javascript.ts +111 -0
  258. package/lib/type-generation/languages/kotlin.ts +96 -0
  259. package/lib/type-generation/languages/language.ts +119 -0
  260. package/lib/type-generation/languages/{php.js → php.ts} +55 -48
  261. package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
  262. package/lib/type-generation/languages/typescript.ts +116 -0
  263. package/lib/types.ts +150 -0
  264. package/lib/utils.ts +322 -0
  265. package/lib/validations.ts +17 -0
  266. package/package.json +21 -12
  267. package/scoop/appwrite.config.json +3 -3
  268. package/tsconfig.json +30 -0
  269. package/index.js +0 -147
  270. package/lib/client.js +0 -254
  271. package/lib/commands/console.js +0 -127
  272. package/lib/commands/graphql.js +0 -126
  273. package/lib/commands/organizations.js +0 -48
  274. package/lib/emulation/utils.js +0 -186
  275. package/lib/exception.js +0 -9
  276. package/lib/parser.js +0 -250
  277. package/lib/sdks.js +0 -60
  278. package/lib/type-generation/attribute.js +0 -16
  279. package/lib/type-generation/languages/javascript.js +0 -102
  280. package/lib/type-generation/languages/kotlin.js +0 -85
  281. package/lib/type-generation/languages/language.js +0 -125
  282. package/lib/type-generation/languages/typescript.js +0 -107
  283. package/lib/validations.js +0 -17
@@ -0,0 +1,1100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionsDeleteVariable = exports.functionsUpdateVariable = exports.functionsGetVariable = exports.functionsCreateVariable = exports.functionsListVariables = exports.functionsGetUsage = exports.functionsDeleteExecution = exports.functionsGetExecution = exports.functionsCreateExecution = exports.functionsListExecutions = exports.functionsUpdateDeploymentStatus = exports.functionsGetDeploymentDownload = exports.functionsDeleteDeployment = exports.functionsGetDeployment = exports.functionsCreateVcsDeployment = exports.functionsCreateTemplateDeployment = exports.functionsCreateDuplicateDeployment = exports.functionsCreateDeployment = exports.functionsListDeployments = exports.functionsUpdateFunctionDeployment = exports.functionsDelete = exports.functionsUpdate = exports.functionsGet = exports.functionsListUsage = exports.functionsGetTemplate = exports.functionsListTemplates = exports.functionsListSpecifications = exports.functionsListRuntimes = exports.functionsCreate = exports.functionsList = exports.functions = void 0;
4
+ const fs = require("fs");
5
+ const pathLib = require("path");
6
+ const tar = require("tar");
7
+ const ignore = require("ignore");
8
+ const utils_1 = require("../utils");
9
+ const commander_1 = require("commander");
10
+ const sdks_1 = require("../sdks");
11
+ const parser_1 = require("../parser");
12
+ const config_1 = require("../config");
13
+ const undici_1 = require("undici");
14
+ const web_1 = require("stream/web");
15
+ function convertReadStreamToReadableStream(readStream) {
16
+ return new web_1.ReadableStream({
17
+ start(controller) {
18
+ readStream.on("data", (chunk) => {
19
+ controller.enqueue(chunk);
20
+ });
21
+ readStream.on("end", () => {
22
+ controller.close();
23
+ });
24
+ readStream.on("error", (err) => {
25
+ controller.error(err);
26
+ });
27
+ },
28
+ cancel() {
29
+ readStream.destroy();
30
+ },
31
+ });
32
+ }
33
+ exports.functions = new commander_1.Command("functions").description(parser_1.commandDescriptions['functions'] ?? '').configureHelp({
34
+ helpWidth: process.stdout.columns || 80
35
+ });
36
+ const functionsList = async ({ queries, search, total, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
37
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
38
+ sdk;
39
+ let apiPath = '/functions';
40
+ let payload = {};
41
+ if (typeof queries !== 'undefined') {
42
+ payload['queries'] = queries;
43
+ }
44
+ if (typeof search !== 'undefined') {
45
+ payload['search'] = search;
46
+ }
47
+ if (typeof total !== 'undefined') {
48
+ payload['total'] = total;
49
+ }
50
+ let response = undefined;
51
+ response = await client.call('get', apiPath, {}, payload);
52
+ if (parseOutput) {
53
+ if (showConsole) {
54
+ (0, utils_1.showConsoleLink)('functions', 'list');
55
+ }
56
+ else {
57
+ (0, parser_1.parse)(response);
58
+ }
59
+ }
60
+ return response;
61
+ };
62
+ exports.functionsList = functionsList;
63
+ const functionsCreate = async ({ functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, scopes, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, specification, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
64
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
65
+ sdk;
66
+ let apiPath = '/functions';
67
+ let payload = {};
68
+ if (typeof functionId !== 'undefined') {
69
+ payload['functionId'] = functionId;
70
+ }
71
+ if (typeof name !== 'undefined') {
72
+ payload['name'] = name;
73
+ }
74
+ if (typeof runtime !== 'undefined') {
75
+ payload['runtime'] = runtime;
76
+ }
77
+ execute = execute === true ? [] : execute;
78
+ if (typeof execute !== 'undefined') {
79
+ payload['execute'] = execute;
80
+ }
81
+ events = events === true ? [] : events;
82
+ if (typeof events !== 'undefined') {
83
+ payload['events'] = events;
84
+ }
85
+ if (typeof schedule !== 'undefined') {
86
+ payload['schedule'] = schedule;
87
+ }
88
+ if (typeof timeout !== 'undefined') {
89
+ payload['timeout'] = timeout;
90
+ }
91
+ if (typeof enabled !== 'undefined') {
92
+ payload['enabled'] = enabled;
93
+ }
94
+ if (typeof logging !== 'undefined') {
95
+ payload['logging'] = logging;
96
+ }
97
+ if (typeof entrypoint !== 'undefined') {
98
+ payload['entrypoint'] = entrypoint;
99
+ }
100
+ if (typeof commands !== 'undefined') {
101
+ payload['commands'] = commands;
102
+ }
103
+ scopes = scopes === true ? [] : scopes;
104
+ if (typeof scopes !== 'undefined') {
105
+ payload['scopes'] = scopes;
106
+ }
107
+ if (typeof installationId !== 'undefined') {
108
+ payload['installationId'] = installationId;
109
+ }
110
+ if (typeof providerRepositoryId !== 'undefined') {
111
+ payload['providerRepositoryId'] = providerRepositoryId;
112
+ }
113
+ if (typeof providerBranch !== 'undefined') {
114
+ payload['providerBranch'] = providerBranch;
115
+ }
116
+ if (typeof providerSilentMode !== 'undefined') {
117
+ payload['providerSilentMode'] = providerSilentMode;
118
+ }
119
+ if (typeof providerRootDirectory !== 'undefined') {
120
+ payload['providerRootDirectory'] = providerRootDirectory;
121
+ }
122
+ if (typeof specification !== 'undefined') {
123
+ payload['specification'] = specification;
124
+ }
125
+ let response = undefined;
126
+ response = await client.call('post', apiPath, {
127
+ 'content-type': 'application/json',
128
+ }, payload);
129
+ if (parseOutput) {
130
+ (0, parser_1.parse)(response);
131
+ }
132
+ return response;
133
+ };
134
+ exports.functionsCreate = functionsCreate;
135
+ const functionsListRuntimes = async ({ parseOutput = true, overrideForCli = false, sdk = undefined }) => {
136
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
137
+ sdk;
138
+ let apiPath = '/functions/runtimes';
139
+ let payload = {};
140
+ let response = undefined;
141
+ response = await client.call('get', apiPath, {}, payload);
142
+ if (parseOutput) {
143
+ (0, parser_1.parse)(response);
144
+ }
145
+ return response;
146
+ };
147
+ exports.functionsListRuntimes = functionsListRuntimes;
148
+ const functionsListSpecifications = async ({ parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
149
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
150
+ sdk;
151
+ let apiPath = '/functions/specifications';
152
+ let payload = {};
153
+ let response = undefined;
154
+ response = await client.call('get', apiPath, {}, payload);
155
+ if (parseOutput) {
156
+ if (showConsole) {
157
+ (0, utils_1.showConsoleLink)('functions', 'listSpecifications');
158
+ }
159
+ else {
160
+ (0, parser_1.parse)(response);
161
+ }
162
+ }
163
+ return response;
164
+ };
165
+ exports.functionsListSpecifications = functionsListSpecifications;
166
+ const functionsListTemplates = async ({ runtimes, useCases, limit, offset, total, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
167
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
168
+ sdk;
169
+ let apiPath = '/functions/templates';
170
+ let payload = {};
171
+ if (typeof runtimes !== 'undefined') {
172
+ payload['runtimes'] = runtimes;
173
+ }
174
+ if (typeof useCases !== 'undefined') {
175
+ payload['useCases'] = useCases;
176
+ }
177
+ if (typeof limit !== 'undefined') {
178
+ payload['limit'] = limit;
179
+ }
180
+ if (typeof offset !== 'undefined') {
181
+ payload['offset'] = offset;
182
+ }
183
+ if (typeof total !== 'undefined') {
184
+ payload['total'] = total;
185
+ }
186
+ let response = undefined;
187
+ response = await client.call('get', apiPath, {}, payload);
188
+ if (parseOutput) {
189
+ if (showConsole) {
190
+ (0, utils_1.showConsoleLink)('functions', 'listTemplates');
191
+ }
192
+ else {
193
+ (0, parser_1.parse)(response);
194
+ }
195
+ }
196
+ return response;
197
+ };
198
+ exports.functionsListTemplates = functionsListTemplates;
199
+ const functionsGetTemplate = async ({ templateId, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
200
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
201
+ sdk;
202
+ let apiPath = '/functions/templates/{templateId}'.replace('{templateId}', templateId);
203
+ let payload = {};
204
+ let response = undefined;
205
+ response = await client.call('get', apiPath, {}, payload);
206
+ if (parseOutput) {
207
+ if (showConsole) {
208
+ (0, utils_1.showConsoleLink)('functions', 'getTemplate', templateId);
209
+ }
210
+ else {
211
+ (0, parser_1.parse)(response);
212
+ }
213
+ }
214
+ return response;
215
+ };
216
+ exports.functionsGetTemplate = functionsGetTemplate;
217
+ const functionsListUsage = async ({ range, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
218
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
219
+ sdk;
220
+ let apiPath = '/functions/usage';
221
+ let payload = {};
222
+ if (typeof range !== 'undefined') {
223
+ payload['range'] = range;
224
+ }
225
+ let response = undefined;
226
+ response = await client.call('get', apiPath, {}, payload);
227
+ if (parseOutput) {
228
+ if (showConsole) {
229
+ (0, utils_1.showConsoleLink)('functions', 'listUsage');
230
+ }
231
+ else {
232
+ (0, parser_1.parse)(response);
233
+ }
234
+ }
235
+ return response;
236
+ };
237
+ exports.functionsListUsage = functionsListUsage;
238
+ const functionsGet = async ({ functionId, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
239
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
240
+ sdk;
241
+ let apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
242
+ let payload = {};
243
+ let response = undefined;
244
+ response = await client.call('get', apiPath, {}, payload);
245
+ if (parseOutput) {
246
+ if (showConsole) {
247
+ (0, utils_1.showConsoleLink)('functions', 'get', functionId);
248
+ }
249
+ else {
250
+ (0, parser_1.parse)(response);
251
+ }
252
+ }
253
+ return response;
254
+ };
255
+ exports.functionsGet = functionsGet;
256
+ const functionsUpdate = async ({ functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, scopes, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, specification, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
257
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
258
+ sdk;
259
+ let apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
260
+ let payload = {};
261
+ if (typeof name !== 'undefined') {
262
+ payload['name'] = name;
263
+ }
264
+ if (typeof runtime !== 'undefined') {
265
+ payload['runtime'] = runtime;
266
+ }
267
+ execute = execute === true ? [] : execute;
268
+ if (typeof execute !== 'undefined') {
269
+ payload['execute'] = execute;
270
+ }
271
+ events = events === true ? [] : events;
272
+ if (typeof events !== 'undefined') {
273
+ payload['events'] = events;
274
+ }
275
+ if (typeof schedule !== 'undefined') {
276
+ payload['schedule'] = schedule;
277
+ }
278
+ if (typeof timeout !== 'undefined') {
279
+ payload['timeout'] = timeout;
280
+ }
281
+ if (typeof enabled !== 'undefined') {
282
+ payload['enabled'] = enabled;
283
+ }
284
+ if (typeof logging !== 'undefined') {
285
+ payload['logging'] = logging;
286
+ }
287
+ if (typeof entrypoint !== 'undefined') {
288
+ payload['entrypoint'] = entrypoint;
289
+ }
290
+ if (typeof commands !== 'undefined') {
291
+ payload['commands'] = commands;
292
+ }
293
+ scopes = scopes === true ? [] : scopes;
294
+ if (typeof scopes !== 'undefined') {
295
+ payload['scopes'] = scopes;
296
+ }
297
+ if (typeof installationId !== 'undefined') {
298
+ payload['installationId'] = installationId;
299
+ }
300
+ if (typeof providerRepositoryId !== 'undefined') {
301
+ payload['providerRepositoryId'] = providerRepositoryId;
302
+ }
303
+ if (typeof providerBranch !== 'undefined') {
304
+ payload['providerBranch'] = providerBranch;
305
+ }
306
+ if (typeof providerSilentMode !== 'undefined') {
307
+ payload['providerSilentMode'] = providerSilentMode;
308
+ }
309
+ if (typeof providerRootDirectory !== 'undefined') {
310
+ payload['providerRootDirectory'] = providerRootDirectory;
311
+ }
312
+ if (typeof specification !== 'undefined') {
313
+ payload['specification'] = specification;
314
+ }
315
+ let response = undefined;
316
+ response = await client.call('put', apiPath, {
317
+ 'content-type': 'application/json',
318
+ }, payload);
319
+ if (parseOutput) {
320
+ (0, parser_1.parse)(response);
321
+ }
322
+ return response;
323
+ };
324
+ exports.functionsUpdate = functionsUpdate;
325
+ const functionsDelete = async ({ functionId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
326
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
327
+ sdk;
328
+ let apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
329
+ let payload = {};
330
+ let response = undefined;
331
+ response = await client.call('delete', apiPath, {
332
+ 'content-type': 'application/json',
333
+ }, payload);
334
+ if (parseOutput) {
335
+ (0, parser_1.parse)(response);
336
+ }
337
+ return response;
338
+ };
339
+ exports.functionsDelete = functionsDelete;
340
+ const functionsUpdateFunctionDeployment = async ({ functionId, deploymentId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
341
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
342
+ sdk;
343
+ let apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', functionId);
344
+ let payload = {};
345
+ if (typeof deploymentId !== 'undefined') {
346
+ payload['deploymentId'] = deploymentId;
347
+ }
348
+ let response = undefined;
349
+ response = await client.call('patch', apiPath, {
350
+ 'content-type': 'application/json',
351
+ }, payload);
352
+ if (parseOutput) {
353
+ (0, parser_1.parse)(response);
354
+ }
355
+ return response;
356
+ };
357
+ exports.functionsUpdateFunctionDeployment = functionsUpdateFunctionDeployment;
358
+ const functionsListDeployments = async ({ functionId, queries, search, total, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
359
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
360
+ sdk;
361
+ let apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
362
+ let payload = {};
363
+ if (typeof queries !== 'undefined') {
364
+ payload['queries'] = queries;
365
+ }
366
+ if (typeof search !== 'undefined') {
367
+ payload['search'] = search;
368
+ }
369
+ if (typeof total !== 'undefined') {
370
+ payload['total'] = total;
371
+ }
372
+ let response = undefined;
373
+ response = await client.call('get', apiPath, {}, payload);
374
+ if (parseOutput) {
375
+ if (showConsole) {
376
+ (0, utils_1.showConsoleLink)('functions', 'listDeployments', functionId);
377
+ }
378
+ else {
379
+ (0, parser_1.parse)(response);
380
+ }
381
+ }
382
+ return response;
383
+ };
384
+ exports.functionsListDeployments = functionsListDeployments;
385
+ const functionsCreateDeployment = async ({ functionId, code, activate, entrypoint, commands, parseOutput = true, overrideForCli = false, sdk = undefined, onProgress = () => { } }) => {
386
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
387
+ sdk;
388
+ let apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
389
+ let payload = {};
390
+ if (typeof entrypoint !== 'undefined') {
391
+ payload['entrypoint'] = entrypoint;
392
+ }
393
+ if (typeof commands !== 'undefined') {
394
+ payload['commands'] = commands;
395
+ }
396
+ const folderPath = fs.realpathSync(code);
397
+ if (!fs.lstatSync(folderPath).isDirectory()) {
398
+ throw new Error('The path is not a directory.');
399
+ }
400
+ const ignorer = ignore();
401
+ const resourceId = functionId;
402
+ const resourceConfig = config_1.localConfig.getFunction(resourceId);
403
+ ignorer.add('.appwrite');
404
+ if (resourceConfig.ignore) {
405
+ ignorer.add(resourceConfig.ignore);
406
+ }
407
+ else if (fs.existsSync(pathLib.join(code, '.gitignore'))) {
408
+ ignorer.add(fs.readFileSync(pathLib.join(code, '.gitignore')).toString());
409
+ }
410
+ const files = (0, utils_1.getAllFiles)(code).map((file) => pathLib.relative(code, file)).filter((file) => !ignorer.ignores(file));
411
+ const archiveFileName = `functions-${resourceId}-code.tar.gz`;
412
+ await tar
413
+ .create({
414
+ gzip: true,
415
+ sync: true,
416
+ cwd: folderPath,
417
+ file: archiveFileName
418
+ }, files);
419
+ let archivePath = fs.realpathSync(archiveFileName);
420
+ if (typeof archivePath !== 'undefined') {
421
+ payload['code'] = archivePath;
422
+ code = archivePath;
423
+ }
424
+ const filePath = fs.realpathSync(code);
425
+ const nodeStream = fs.createReadStream(filePath);
426
+ const stream = convertReadStreamToReadableStream(nodeStream);
427
+ if (typeof filePath !== 'undefined') {
428
+ code = { type: 'file', stream, filename: pathLib.basename(filePath), size: fs.statSync(filePath).size };
429
+ payload['code'] = code;
430
+ }
431
+ if (typeof activate !== 'undefined') {
432
+ payload['activate'] = activate;
433
+ }
434
+ const size = code.size;
435
+ const apiHeaders = {
436
+ 'content-type': 'multipart/form-data',
437
+ };
438
+ let id = undefined;
439
+ let response = undefined;
440
+ let chunksUploaded = 0;
441
+ let currentChunk = 1;
442
+ let currentPosition = 0;
443
+ let uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
444
+ const uploadChunk = async (lastUpload = false) => {
445
+ if (currentChunk <= chunksUploaded) {
446
+ return;
447
+ }
448
+ const start = ((currentChunk - 1) * client.CHUNK_SIZE);
449
+ let end = start + currentPosition - 1;
450
+ if (!lastUpload || currentChunk !== 1) {
451
+ apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
452
+ }
453
+ let uploadableChunkTrimmed;
454
+ if (currentPosition + 1 >= client.CHUNK_SIZE) {
455
+ uploadableChunkTrimmed = uploadableChunk;
456
+ }
457
+ else {
458
+ uploadableChunkTrimmed = new Uint8Array(currentPosition);
459
+ for (let i = 0; i <= currentPosition; i++) {
460
+ uploadableChunkTrimmed[i] = uploadableChunk[i];
461
+ }
462
+ }
463
+ if (id) {
464
+ apiHeaders['x-appwrite-id'] = id;
465
+ }
466
+ payload['code'] = { type: 'file', file: new undici_1.File([uploadableChunkTrimmed], code.filename), filename: code.filename };
467
+ response = await client.call('post', apiPath, apiHeaders, payload);
468
+ if (!id) {
469
+ id = response['$id'];
470
+ }
471
+ if (onProgress !== null) {
472
+ onProgress({
473
+ $id: response['$id'],
474
+ progress: Math.min((currentChunk) * client.CHUNK_SIZE, size) / size * 100,
475
+ sizeUploaded: end + 1,
476
+ chunksTotal: response['chunksTotal'],
477
+ chunksUploaded: response['chunksUploaded']
478
+ });
479
+ }
480
+ uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
481
+ currentChunk++;
482
+ currentPosition = 0;
483
+ };
484
+ for await (const chunk of code.stream) {
485
+ for (const b of chunk) {
486
+ uploadableChunk[currentPosition] = b;
487
+ currentPosition++;
488
+ if (currentPosition >= client.CHUNK_SIZE) {
489
+ await uploadChunk();
490
+ currentPosition = 0;
491
+ }
492
+ }
493
+ }
494
+ if (currentPosition > 0) { // Check if there's any remaining data for the last chunk
495
+ await uploadChunk(true);
496
+ }
497
+ await fs.unlink(filePath, () => { });
498
+ if (parseOutput) {
499
+ (0, parser_1.parse)(response);
500
+ }
501
+ return response;
502
+ };
503
+ exports.functionsCreateDeployment = functionsCreateDeployment;
504
+ const functionsCreateDuplicateDeployment = async ({ functionId, deploymentId, buildId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
505
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
506
+ sdk;
507
+ let apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', functionId);
508
+ let payload = {};
509
+ if (typeof deploymentId !== 'undefined') {
510
+ payload['deploymentId'] = deploymentId;
511
+ }
512
+ if (typeof buildId !== 'undefined') {
513
+ payload['buildId'] = buildId;
514
+ }
515
+ let response = undefined;
516
+ response = await client.call('post', apiPath, {
517
+ 'content-type': 'application/json',
518
+ }, payload);
519
+ if (parseOutput) {
520
+ (0, parser_1.parse)(response);
521
+ }
522
+ return response;
523
+ };
524
+ exports.functionsCreateDuplicateDeployment = functionsCreateDuplicateDeployment;
525
+ const functionsCreateTemplateDeployment = async ({ functionId, repository, owner, rootDirectory, type, reference, activate, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
526
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
527
+ sdk;
528
+ let apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', functionId);
529
+ let payload = {};
530
+ if (typeof repository !== 'undefined') {
531
+ payload['repository'] = repository;
532
+ }
533
+ if (typeof owner !== 'undefined') {
534
+ payload['owner'] = owner;
535
+ }
536
+ if (typeof rootDirectory !== 'undefined') {
537
+ payload['rootDirectory'] = rootDirectory;
538
+ }
539
+ if (typeof type !== 'undefined') {
540
+ payload['type'] = type;
541
+ }
542
+ if (typeof reference !== 'undefined') {
543
+ payload['reference'] = reference;
544
+ }
545
+ if (typeof activate !== 'undefined') {
546
+ payload['activate'] = activate;
547
+ }
548
+ let response = undefined;
549
+ response = await client.call('post', apiPath, {
550
+ 'content-type': 'application/json',
551
+ }, payload);
552
+ if (parseOutput) {
553
+ (0, parser_1.parse)(response);
554
+ }
555
+ return response;
556
+ };
557
+ exports.functionsCreateTemplateDeployment = functionsCreateTemplateDeployment;
558
+ const functionsCreateVcsDeployment = async ({ functionId, type, reference, activate, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
559
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
560
+ sdk;
561
+ let apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', functionId);
562
+ let payload = {};
563
+ if (typeof type !== 'undefined') {
564
+ payload['type'] = type;
565
+ }
566
+ if (typeof reference !== 'undefined') {
567
+ payload['reference'] = reference;
568
+ }
569
+ if (typeof activate !== 'undefined') {
570
+ payload['activate'] = activate;
571
+ }
572
+ let response = undefined;
573
+ response = await client.call('post', apiPath, {
574
+ 'content-type': 'application/json',
575
+ }, payload);
576
+ if (parseOutput) {
577
+ (0, parser_1.parse)(response);
578
+ }
579
+ return response;
580
+ };
581
+ exports.functionsCreateVcsDeployment = functionsCreateVcsDeployment;
582
+ const functionsGetDeployment = async ({ functionId, deploymentId, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
583
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
584
+ sdk;
585
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
586
+ let payload = {};
587
+ let response = undefined;
588
+ response = await client.call('get', apiPath, {}, payload);
589
+ if (parseOutput) {
590
+ if (showConsole) {
591
+ (0, utils_1.showConsoleLink)('functions', 'getDeployment', functionId, deploymentId);
592
+ }
593
+ else {
594
+ (0, parser_1.parse)(response);
595
+ }
596
+ }
597
+ return response;
598
+ };
599
+ exports.functionsGetDeployment = functionsGetDeployment;
600
+ const functionsDeleteDeployment = async ({ functionId, deploymentId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
601
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
602
+ sdk;
603
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
604
+ let payload = {};
605
+ let response = undefined;
606
+ response = await client.call('delete', apiPath, {
607
+ 'content-type': 'application/json',
608
+ }, payload);
609
+ if (parseOutput) {
610
+ (0, parser_1.parse)(response);
611
+ }
612
+ return response;
613
+ };
614
+ exports.functionsDeleteDeployment = functionsDeleteDeployment;
615
+ const functionsGetDeploymentDownload = async ({ functionId, deploymentId, type, parseOutput = true, overrideForCli = false, sdk = undefined, destination, console: showConsole }) => {
616
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
617
+ sdk;
618
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
619
+ let payload = {};
620
+ if (typeof type !== 'undefined') {
621
+ payload['type'] = type;
622
+ }
623
+ if (!overrideForCli) {
624
+ payload['project'] = config_1.localConfig.getProject().projectId;
625
+ payload['key'] = config_1.globalConfig.getKey();
626
+ const queryParams = new URLSearchParams(payload);
627
+ apiPath = `${config_1.globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
628
+ }
629
+ let response = undefined;
630
+ response = await client.call('get', apiPath, {}, payload, 'arraybuffer');
631
+ if (overrideForCli) {
632
+ response = Buffer.from(response);
633
+ }
634
+ fs.writeFileSync(destination, response);
635
+ if (parseOutput) {
636
+ if (showConsole) {
637
+ (0, utils_1.showConsoleLink)('functions', 'getDeploymentDownload', functionId, deploymentId);
638
+ }
639
+ else {
640
+ (0, parser_1.parse)(response);
641
+ }
642
+ }
643
+ return response;
644
+ };
645
+ exports.functionsGetDeploymentDownload = functionsGetDeploymentDownload;
646
+ const functionsUpdateDeploymentStatus = async ({ functionId, deploymentId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
647
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
648
+ sdk;
649
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
650
+ let payload = {};
651
+ let response = undefined;
652
+ response = await client.call('patch', apiPath, {
653
+ 'content-type': 'application/json',
654
+ }, payload);
655
+ if (parseOutput) {
656
+ (0, parser_1.parse)(response);
657
+ }
658
+ return response;
659
+ };
660
+ exports.functionsUpdateDeploymentStatus = functionsUpdateDeploymentStatus;
661
+ const functionsListExecutions = async ({ functionId, queries, total, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
662
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
663
+ sdk;
664
+ let apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
665
+ let payload = {};
666
+ if (typeof queries !== 'undefined') {
667
+ payload['queries'] = queries;
668
+ }
669
+ if (typeof total !== 'undefined') {
670
+ payload['total'] = total;
671
+ }
672
+ let response = undefined;
673
+ response = await client.call('get', apiPath, {}, payload);
674
+ if (parseOutput) {
675
+ if (showConsole) {
676
+ (0, utils_1.showConsoleLink)('functions', 'listExecutions', functionId);
677
+ }
678
+ else {
679
+ (0, parser_1.parse)(response);
680
+ }
681
+ }
682
+ return response;
683
+ };
684
+ exports.functionsListExecutions = functionsListExecutions;
685
+ const functionsCreateExecution = async ({ functionId, body, async, xpath, method, headers, scheduledAt, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
686
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
687
+ sdk;
688
+ let apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
689
+ let payload = {};
690
+ if (typeof body !== 'undefined') {
691
+ payload['body'] = body;
692
+ }
693
+ if (typeof async !== 'undefined') {
694
+ payload['async'] = async;
695
+ }
696
+ if (typeof xpath !== 'undefined') {
697
+ payload['path'] = xpath;
698
+ }
699
+ if (typeof method !== 'undefined') {
700
+ payload['method'] = method;
701
+ }
702
+ if (typeof headers !== 'undefined') {
703
+ payload['headers'] = JSON.parse(headers);
704
+ }
705
+ if (typeof scheduledAt !== 'undefined') {
706
+ payload['scheduledAt'] = scheduledAt;
707
+ }
708
+ let response = undefined;
709
+ response = await client.call('post', apiPath, {
710
+ 'content-type': 'application/json',
711
+ }, payload);
712
+ if (parseOutput) {
713
+ (0, parser_1.parse)(response);
714
+ }
715
+ return response;
716
+ };
717
+ exports.functionsCreateExecution = functionsCreateExecution;
718
+ const functionsGetExecution = async ({ functionId, executionId, parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole }) => {
719
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
720
+ sdk;
721
+ let apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
722
+ let payload = {};
723
+ let response = undefined;
724
+ response = await client.call('get', apiPath, {}, payload);
725
+ if (parseOutput) {
726
+ if (showConsole) {
727
+ (0, utils_1.showConsoleLink)('functions', 'getExecution', functionId, executionId);
728
+ }
729
+ else {
730
+ (0, parser_1.parse)(response);
731
+ }
732
+ }
733
+ return response;
734
+ };
735
+ exports.functionsGetExecution = functionsGetExecution;
736
+ const functionsDeleteExecution = async ({ functionId, executionId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
737
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
738
+ sdk;
739
+ let apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
740
+ let payload = {};
741
+ let response = undefined;
742
+ response = await client.call('delete', apiPath, {
743
+ 'content-type': 'application/json',
744
+ }, payload);
745
+ if (parseOutput) {
746
+ (0, parser_1.parse)(response);
747
+ }
748
+ return response;
749
+ };
750
+ exports.functionsDeleteExecution = functionsDeleteExecution;
751
+ const functionsGetUsage = async ({ functionId, range, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
752
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
753
+ sdk;
754
+ let apiPath = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
755
+ let payload = {};
756
+ if (typeof range !== 'undefined') {
757
+ payload['range'] = range;
758
+ }
759
+ let response = undefined;
760
+ response = await client.call('get', apiPath, {}, payload);
761
+ if (parseOutput) {
762
+ (0, parser_1.parse)(response);
763
+ }
764
+ return response;
765
+ };
766
+ exports.functionsGetUsage = functionsGetUsage;
767
+ const functionsListVariables = async ({ functionId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
768
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
769
+ sdk;
770
+ let apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
771
+ let payload = {};
772
+ let response = undefined;
773
+ response = await client.call('get', apiPath, {}, payload);
774
+ if (parseOutput) {
775
+ (0, parser_1.parse)(response);
776
+ }
777
+ return response;
778
+ };
779
+ exports.functionsListVariables = functionsListVariables;
780
+ const functionsCreateVariable = async ({ functionId, key, value, secret, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
781
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
782
+ sdk;
783
+ let apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
784
+ let payload = {};
785
+ if (typeof key !== 'undefined') {
786
+ payload['key'] = key;
787
+ }
788
+ if (typeof value !== 'undefined') {
789
+ payload['value'] = value;
790
+ }
791
+ if (typeof secret !== 'undefined') {
792
+ payload['secret'] = secret;
793
+ }
794
+ let response = undefined;
795
+ response = await client.call('post', apiPath, {
796
+ 'content-type': 'application/json',
797
+ }, payload);
798
+ if (parseOutput) {
799
+ (0, parser_1.parse)(response);
800
+ }
801
+ return response;
802
+ };
803
+ exports.functionsCreateVariable = functionsCreateVariable;
804
+ const functionsGetVariable = async ({ functionId, variableId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
805
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
806
+ sdk;
807
+ let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
808
+ let payload = {};
809
+ let response = undefined;
810
+ response = await client.call('get', apiPath, {}, payload);
811
+ if (parseOutput) {
812
+ (0, parser_1.parse)(response);
813
+ }
814
+ return response;
815
+ };
816
+ exports.functionsGetVariable = functionsGetVariable;
817
+ const functionsUpdateVariable = async ({ functionId, variableId, key, value, secret, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
818
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
819
+ sdk;
820
+ let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
821
+ let payload = {};
822
+ if (typeof key !== 'undefined') {
823
+ payload['key'] = key;
824
+ }
825
+ if (typeof value !== 'undefined') {
826
+ payload['value'] = value;
827
+ }
828
+ if (typeof secret !== 'undefined') {
829
+ payload['secret'] = secret;
830
+ }
831
+ let response = undefined;
832
+ response = await client.call('put', apiPath, {
833
+ 'content-type': 'application/json',
834
+ }, payload);
835
+ if (parseOutput) {
836
+ (0, parser_1.parse)(response);
837
+ }
838
+ return response;
839
+ };
840
+ exports.functionsUpdateVariable = functionsUpdateVariable;
841
+ const functionsDeleteVariable = async ({ functionId, variableId, parseOutput = true, overrideForCli = false, sdk = undefined }) => {
842
+ let client = !sdk ? await (0, sdks_1.sdkForProject)() :
843
+ sdk;
844
+ let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
845
+ let payload = {};
846
+ let response = undefined;
847
+ response = await client.call('delete', apiPath, {
848
+ 'content-type': 'application/json',
849
+ }, payload);
850
+ if (parseOutput) {
851
+ (0, parser_1.parse)(response);
852
+ }
853
+ return response;
854
+ };
855
+ exports.functionsDeleteVariable = functionsDeleteVariable;
856
+ exports.functions
857
+ .command(`list`)
858
+ .description(`Get a list of all the project's functions. You can use the query params to filter your results.`)
859
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId`)
860
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
861
+ .option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
862
+ .option(`--console`, `Get the resource console url`)
863
+ .action((0, parser_1.actionRunner)(exports.functionsList));
864
+ exports.functions
865
+ .command(`create`)
866
+ .description(`Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API.`)
867
+ .requiredOption(`--function-id <function-id>`, `Function ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
868
+ .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
869
+ .requiredOption(`--runtime <runtime>`, `Execution runtime.`)
870
+ .option(`--execute [execute...]`, `An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.`)
871
+ .option(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
872
+ .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
873
+ .option(`--timeout <timeout>`, `Function maximum execution time in seconds.`, parser_1.parseInteger)
874
+ .option(`--enabled [value]`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
875
+ .option(`--logging [value]`, `When disabled, executions will exclude logs and errors, and will be slightly faster.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
876
+ .option(`--entrypoint <entrypoint>`, `Entrypoint File. This path is relative to the "providerRootDirectory".`)
877
+ .option(`--commands <commands>`, `Build Commands.`)
878
+ .option(`--scopes [scopes...]`, `List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.`)
879
+ .option(`--installation-id <installation-id>`, `Appwrite Installation ID for VCS (Version Control System) deployment.`)
880
+ .option(`--provider-repository-id <provider-repository-id>`, `Repository ID of the repo linked to the function.`)
881
+ .option(`--provider-branch <provider-branch>`, `Production branch for the repo linked to the function.`)
882
+ .option(`--provider-silent-mode [value]`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
883
+ .option(`--provider-root-directory <provider-root-directory>`, `Path to function code in the linked repo.`)
884
+ .option(`--specification <specification>`, `Runtime specification for the function and builds.`)
885
+ .action((0, parser_1.actionRunner)(exports.functionsCreate));
886
+ exports.functions
887
+ .command(`list-runtimes`)
888
+ .description(`Get a list of all runtimes that are currently active on your instance.`)
889
+ .action((0, parser_1.actionRunner)(exports.functionsListRuntimes));
890
+ exports.functions
891
+ .command(`list-specifications`)
892
+ .description(`List allowed function specifications for this instance.`)
893
+ .option(`--console`, `Get the resource console url`)
894
+ .action((0, parser_1.actionRunner)(exports.functionsListSpecifications));
895
+ exports.functions
896
+ .command(`list-templates`)
897
+ .description(`List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method.`)
898
+ .option(`--runtimes [runtimes...]`, `List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed.`)
899
+ .option(`--use-cases [use-cases...]`, `List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed.`)
900
+ .option(`--limit <limit>`, `Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.`, parser_1.parseInteger)
901
+ .option(`--offset <offset>`, `Offset the list of returned templates. Maximum offset is 5000.`, parser_1.parseInteger)
902
+ .option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
903
+ .option(`--console`, `Get the resource console url`)
904
+ .action((0, parser_1.actionRunner)(exports.functionsListTemplates));
905
+ exports.functions
906
+ .command(`get-template`)
907
+ .description(`Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method.`)
908
+ .requiredOption(`--template-id <template-id>`, `Template ID.`)
909
+ .option(`--console`, `Get the resource console url`)
910
+ .action((0, parser_1.actionRunner)(exports.functionsGetTemplate));
911
+ exports.functions
912
+ .command(`list-usage`)
913
+ .description(`Get usage metrics and statistics for all functions in the project. View statistics including total deployments, builds, logs, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
914
+ .option(`--range <range>`, `Date range.`)
915
+ .option(`--console`, `Get the resource console url`)
916
+ .action((0, parser_1.actionRunner)(exports.functionsListUsage));
917
+ exports.functions
918
+ .command(`get`)
919
+ .description(`Get a function by its unique ID.`)
920
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
921
+ .option(`--console`, `Get the resource console url`)
922
+ .action((0, parser_1.actionRunner)(exports.functionsGet));
923
+ exports.functions
924
+ .command(`update`)
925
+ .description(`Update function by its unique ID.`)
926
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
927
+ .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
928
+ .option(`--runtime <runtime>`, `Execution runtime.`)
929
+ .option(`--execute [execute...]`, `An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.`)
930
+ .option(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
931
+ .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
932
+ .option(`--timeout <timeout>`, `Maximum execution time in seconds.`, parser_1.parseInteger)
933
+ .option(`--enabled [value]`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
934
+ .option(`--logging [value]`, `When disabled, executions will exclude logs and errors, and will be slightly faster.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
935
+ .option(`--entrypoint <entrypoint>`, `Entrypoint File. This path is relative to the "providerRootDirectory".`)
936
+ .option(`--commands <commands>`, `Build Commands.`)
937
+ .option(`--scopes [scopes...]`, `List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.`)
938
+ .option(`--installation-id <installation-id>`, `Appwrite Installation ID for VCS (Version Controle System) deployment.`)
939
+ .option(`--provider-repository-id <provider-repository-id>`, `Repository ID of the repo linked to the function`)
940
+ .option(`--provider-branch <provider-branch>`, `Production branch for the repo linked to the function`)
941
+ .option(`--provider-silent-mode [value]`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
942
+ .option(`--provider-root-directory <provider-root-directory>`, `Path to function code in the linked repo.`)
943
+ .option(`--specification <specification>`, `Runtime specification for the function and builds.`)
944
+ .action((0, parser_1.actionRunner)(exports.functionsUpdate));
945
+ exports.functions
946
+ .command(`delete`)
947
+ .description(`Delete a function by its unique ID.`)
948
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
949
+ .action((0, parser_1.actionRunner)(exports.functionsDelete));
950
+ exports.functions
951
+ .command(`update-function-deployment`)
952
+ .description(`Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function.`)
953
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
954
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
955
+ .action((0, parser_1.actionRunner)(exports.functionsUpdateFunctionDeployment));
956
+ exports.functions
957
+ .command(`list-deployments`)
958
+ .description(`Get a list of all the function's code deployments. You can use the query params to filter your results.`)
959
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
960
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type`)
961
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
962
+ .option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
963
+ .option(`--console`, `Get the resource console url`)
964
+ .action((0, parser_1.actionRunner)(exports.functionsListDeployments));
965
+ exports.functions
966
+ .command(`create-deployment`)
967
+ .description(`Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). Use the "command" param to set the entrypoint used to execute your code.`)
968
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
969
+ .requiredOption(`--code <code>`, `Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.`)
970
+ .requiredOption(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
971
+ .option(`--entrypoint <entrypoint>`, `Entrypoint File.`)
972
+ .option(`--commands <commands>`, `Build Commands.`)
973
+ .action((0, parser_1.actionRunner)(exports.functionsCreateDeployment));
974
+ exports.functions
975
+ .command(`create-duplicate-deployment`)
976
+ .description(`Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.`)
977
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
978
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
979
+ .option(`--build-id <build-id>`, `Build unique ID.`)
980
+ .action((0, parser_1.actionRunner)(exports.functionsCreateDuplicateDeployment));
981
+ exports.functions
982
+ .command(`create-template-deployment`)
983
+ .description(`Create a deployment based on a template. Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details.`)
984
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
985
+ .requiredOption(`--repository <repository>`, `Repository name of the template.`)
986
+ .requiredOption(`--owner <owner>`, `The name of the owner of the template.`)
987
+ .requiredOption(`--root-directory <root-directory>`, `Path to function code in the template repo.`)
988
+ .requiredOption(`--type <type>`, `Type for the reference provided. Can be commit, branch, or tag`)
989
+ .requiredOption(`--reference <reference>`, `Reference value, can be a commit hash, branch name, or release tag`)
990
+ .option(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
991
+ .action((0, parser_1.actionRunner)(exports.functionsCreateTemplateDeployment));
992
+ exports.functions
993
+ .command(`create-vcs-deployment`)
994
+ .description(`Create a deployment when a function is connected to VCS. This endpoint lets you create deployment from a branch, commit, or a tag.`)
995
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
996
+ .requiredOption(`--type <type>`, `Type of reference passed. Allowed values are: branch, commit`)
997
+ .requiredOption(`--reference <reference>`, `VCS reference to create deployment from. Depending on type this can be: branch name, commit hash`)
998
+ .option(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
999
+ .action((0, parser_1.actionRunner)(exports.functionsCreateVcsDeployment));
1000
+ exports.functions
1001
+ .command(`get-deployment`)
1002
+ .description(`Get a function deployment by its unique ID.`)
1003
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1004
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1005
+ .option(`--console`, `Get the resource console url`)
1006
+ .action((0, parser_1.actionRunner)(exports.functionsGetDeployment));
1007
+ exports.functions
1008
+ .command(`delete-deployment`)
1009
+ .description(`Delete a code deployment by its unique ID.`)
1010
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1011
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1012
+ .action((0, parser_1.actionRunner)(exports.functionsDeleteDeployment));
1013
+ exports.functions
1014
+ .command(`get-deployment-download`)
1015
+ .description(`Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.`)
1016
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1017
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1018
+ .option(`--type <type>`, `Deployment file to download. Can be: "source", "output".`)
1019
+ .requiredOption(`--destination <path>`, `output file path.`)
1020
+ .option(`--console`, `Get the resource console url`)
1021
+ .action((0, parser_1.actionRunner)(exports.functionsGetDeploymentDownload));
1022
+ exports.functions
1023
+ .command(`update-deployment-status`)
1024
+ .description(`Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.`)
1025
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1026
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1027
+ .action((0, parser_1.actionRunner)(exports.functionsUpdateDeploymentStatus));
1028
+ exports.functions
1029
+ .command(`list-executions`)
1030
+ .description(`Get a list of all the current user function execution logs. You can use the query params to filter your results.`)
1031
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1032
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId`)
1033
+ .option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
1034
+ .option(`--console`, `Get the resource console url`)
1035
+ .action((0, parser_1.actionRunner)(exports.functionsListExecutions));
1036
+ exports.functions
1037
+ .command(`create-execution`)
1038
+ .description(`Trigger a function execution. The returned object will return you the current execution status. You can ping the 'Get Execution' endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.`)
1039
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1040
+ .option(`--body <body>`, `HTTP body of execution. Default value is empty string.`)
1041
+ .option(`--async [value]`, `Execute code in the background. Default value is false.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
1042
+ .option(`--xpath <xpath>`, `HTTP path of execution. Path can include query params. Default value is /`)
1043
+ .option(`--method <method>`, `HTTP method of execution. Default value is POST.`)
1044
+ .option(`--headers <headers>`, `HTTP headers of execution. Defaults to empty.`)
1045
+ .option(`--scheduled-at <scheduled-at>`, `Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.`)
1046
+ .action((0, parser_1.actionRunner)(exports.functionsCreateExecution));
1047
+ exports.functions
1048
+ .command(`get-execution`)
1049
+ .description(`Get a function execution log by its unique ID.`)
1050
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1051
+ .requiredOption(`--execution-id <execution-id>`, `Execution ID.`)
1052
+ .option(`--console`, `Get the resource console url`)
1053
+ .action((0, parser_1.actionRunner)(exports.functionsGetExecution));
1054
+ exports.functions
1055
+ .command(`delete-execution`)
1056
+ .description(`Delete a function execution by its unique ID.`)
1057
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1058
+ .requiredOption(`--execution-id <execution-id>`, `Execution ID.`)
1059
+ .action((0, parser_1.actionRunner)(exports.functionsDeleteExecution));
1060
+ exports.functions
1061
+ .command(`get-usage`)
1062
+ .description(`Get usage metrics and statistics for a for a specific function. View statistics including total deployments, builds, executions, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
1063
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1064
+ .option(`--range <range>`, `Date range.`)
1065
+ .action((0, parser_1.actionRunner)(exports.functionsGetUsage));
1066
+ exports.functions
1067
+ .command(`list-variables`)
1068
+ .description(`Get a list of all variables of a specific function.`)
1069
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1070
+ .action((0, parser_1.actionRunner)(exports.functionsListVariables));
1071
+ exports.functions
1072
+ .command(`create-variable`)
1073
+ .description(`Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables.`)
1074
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1075
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
1076
+ .requiredOption(`--value <value>`, `Variable value. Max length: 8192 chars.`)
1077
+ .option(`--secret [value]`, `Secret variables can be updated or deleted, but only functions can read them during build and runtime.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
1078
+ .action((0, parser_1.actionRunner)(exports.functionsCreateVariable));
1079
+ exports.functions
1080
+ .command(`get-variable`)
1081
+ .description(`Get a variable by its unique ID.`)
1082
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1083
+ .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1084
+ .action((0, parser_1.actionRunner)(exports.functionsGetVariable));
1085
+ exports.functions
1086
+ .command(`update-variable`)
1087
+ .description(`Update variable by its unique ID.`)
1088
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1089
+ .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1090
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
1091
+ .option(`--value <value>`, `Variable value. Max length: 8192 chars.`)
1092
+ .option(`--secret [value]`, `Secret variables can be updated or deleted, but only functions can read them during build and runtime.`, (value) => value === undefined ? true : (0, parser_1.parseBool)(value))
1093
+ .action((0, parser_1.actionRunner)(exports.functionsUpdateVariable));
1094
+ exports.functions
1095
+ .command(`delete-variable`)
1096
+ .description(`Delete a variable by its unique ID.`)
1097
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1098
+ .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1099
+ .action((0, parser_1.actionRunner)(exports.functionsDeleteVariable));
1100
+ //# sourceMappingURL=functions.js.map