airborne-core-cli 0.9.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.
- package/CHANGELOG.md +11 -0
- package/action.js +624 -0
- package/bin.js +3 -0
- package/index.js +1642 -0
- package/package.json +26 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
|
3
|
+
|
|
4
|
+
- - -
|
|
5
|
+
## airborne_core_cli-v0.1.0 - 2025-10-16
|
|
6
|
+
#### Features
|
|
7
|
+
- added airborne cli - (545c8a7) - yash.rajput.001
|
|
8
|
+
|
|
9
|
+
- - -
|
|
10
|
+
|
|
11
|
+
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
|
package/action.js
ADDED
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { promises as fsPromises } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { CreateApplicationCommand, CreateDimensionCommand, CreateFileCommand, CreateOrganisationCommand, CreatePackageCommand, CreateReleaseCommand, DeleteDimensionCommand, GetReleaseCommand, GetUserCommand, ListDimensionsCommand, ListFilesCommand, ListOrganisationsCommand, ListPackagesCommand, ListReleasesCommand, PostLoginCommand, RequestOrganisationCommand, ServeReleaseCommand, ServeReleaseV2Command, UpdateDimensionCommand, UploadFileCommand, AirborneClient } from "airborne-server-sdk"
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { dirname } from 'path';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
|
|
12
|
+
const configFilePath = path.join(__dirname, ".config");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Reads the config file and parses it as JSON.
|
|
16
|
+
* Returns an Error if file not found.
|
|
17
|
+
*/
|
|
18
|
+
async function readConfigFile() {
|
|
19
|
+
try {
|
|
20
|
+
const data = await fsPromises.readFile(configFilePath, "utf-8");
|
|
21
|
+
return JSON.parse(data);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
if (err.code === "ENOENT") {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`❌ No config file found. Please run configure --base-url <url>\` first.`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the endpoint from the config file
|
|
35
|
+
*/
|
|
36
|
+
export async function getBaseUrl() {
|
|
37
|
+
try {
|
|
38
|
+
const config = await readConfigFile();
|
|
39
|
+
return config.baseUrl || null; // return null if not set
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error("Error reading endpoint:", err);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function getClient(token,isAuthReq){
|
|
47
|
+
const baseUrl = await getBaseUrl();
|
|
48
|
+
|
|
49
|
+
if(!token || !isAuthReq){
|
|
50
|
+
return new AirborneClient({
|
|
51
|
+
endpoint: baseUrl
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
else{
|
|
55
|
+
return new AirborneClient({
|
|
56
|
+
endpoint: baseUrl,
|
|
57
|
+
token: { token: token },
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function readJsonFile(filePath) {
|
|
63
|
+
if (path.extname(filePath).toLowerCase() !== ".json") {
|
|
64
|
+
throw new Error("File must be a JSON file (.json)");
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const data = fs.readFileSync(filePath, "utf8");
|
|
68
|
+
return JSON.parse(data);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
throw new Error(`Failed to read or parse JSON file: ${err.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function mergeOptionsWithJsonFile(options, jsonFilePath) {
|
|
75
|
+
const jsonOptions = readJsonFile(jsonFilePath);
|
|
76
|
+
|
|
77
|
+
// CLI arguments take precedence over JSON file values
|
|
78
|
+
const merged = { ...jsonOptions };
|
|
79
|
+
|
|
80
|
+
// Override with any CLI arguments that were provided
|
|
81
|
+
Object.keys(options).forEach(key => {
|
|
82
|
+
if (options[key] !== undefined) {
|
|
83
|
+
merged[key] = options[key];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return merged;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
function validateRequiredOptions(options, requiredParams) {
|
|
92
|
+
const missing = [];
|
|
93
|
+
const getNestedValue = (obj, path) => {
|
|
94
|
+
const parts = path.replace(/\[\]/g, "").split(/\.|\{value\}/); // handle list [] and map {value}
|
|
95
|
+
let current = obj;
|
|
96
|
+
for (const part of parts) {
|
|
97
|
+
if (!current) return undefined;
|
|
98
|
+
current = current[part];
|
|
99
|
+
}
|
|
100
|
+
return current;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
for (const field of requiredParams) {
|
|
104
|
+
// Check if this is a nested field that requires conditional validation
|
|
105
|
+
const fieldParts = field.split('.');
|
|
106
|
+
if (fieldParts.length > 1) {
|
|
107
|
+
// Get the parent path (everything except the last part)
|
|
108
|
+
const parentPath = fieldParts.slice(0, -1).join('.');
|
|
109
|
+
|
|
110
|
+
// Check if the parent is also in the required params
|
|
111
|
+
const parentIsRequired = requiredParams.includes(parentPath);
|
|
112
|
+
|
|
113
|
+
// If parent is not required, only validate this field if parent exists
|
|
114
|
+
if (!parentIsRequired) {
|
|
115
|
+
const parentExists = getNestedValue(options, parentPath);
|
|
116
|
+
if (parentExists === undefined || parentExists === null) {
|
|
117
|
+
continue; // Skip validation if parent doesn't exist
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const value = getNestedValue(options, field);
|
|
123
|
+
if (value === undefined || value === null) {
|
|
124
|
+
missing.push(field);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (missing.length > 0) {
|
|
129
|
+
throw new Error(`Missing required parameters: ${missing.join(', ')}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export async function CreateApplicationAction(paramsFile, options){
|
|
133
|
+
let finalOptions = {};
|
|
134
|
+
const requiredParams = ["application","organisation","token"];
|
|
135
|
+
|
|
136
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
137
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
138
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
139
|
+
} else if (paramsFile) {
|
|
140
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
141
|
+
} else {
|
|
142
|
+
finalOptions = options;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Validate that all required options are present
|
|
146
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
const client = await getClient(options.token, true);
|
|
152
|
+
const command = new CreateApplicationCommand(finalOptions);
|
|
153
|
+
return await client.send(command);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function CreateDimensionAction(paramsFile, options){
|
|
157
|
+
let finalOptions = {};
|
|
158
|
+
const requiredParams = ["dimension","description","dimension_type","organisation","application","token"];
|
|
159
|
+
|
|
160
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
161
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
162
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
163
|
+
} else if (paramsFile) {
|
|
164
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
165
|
+
} else {
|
|
166
|
+
finalOptions = options;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Validate that all required options are present
|
|
170
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
const client = await getClient(options.token, true);
|
|
176
|
+
const command = new CreateDimensionCommand(finalOptions);
|
|
177
|
+
return await client.send(command);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export async function CreateFileAction(paramsFile, options){
|
|
181
|
+
let finalOptions = {};
|
|
182
|
+
const requiredParams = ["file_path","url","organisation","application","token"];
|
|
183
|
+
|
|
184
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
185
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
186
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
187
|
+
} else if (paramsFile) {
|
|
188
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
189
|
+
} else {
|
|
190
|
+
finalOptions = options;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Validate that all required options are present
|
|
194
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
// Handle document fields specially if they're objects from JSON
|
|
199
|
+
if (finalOptions.metadata && typeof finalOptions.metadata === 'object') {
|
|
200
|
+
// Convert object to string if command expects JSON string
|
|
201
|
+
finalOptions.metadata = JSON.stringify(finalOptions.metadata);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const client = await getClient(options.token, true);
|
|
205
|
+
const command = new CreateFileCommand(finalOptions);
|
|
206
|
+
return await client.send(command);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export async function CreateOrganisationAction(paramsFile, options){
|
|
210
|
+
let finalOptions = {};
|
|
211
|
+
const requiredParams = ["name","token"];
|
|
212
|
+
|
|
213
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
214
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
215
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
216
|
+
} else if (paramsFile) {
|
|
217
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
218
|
+
} else {
|
|
219
|
+
finalOptions = options;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Validate that all required options are present
|
|
223
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
const client = await getClient(options.token, true);
|
|
229
|
+
const command = new CreateOrganisationCommand(finalOptions);
|
|
230
|
+
return await client.send(command);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export async function CreatePackageAction(paramsFile, options){
|
|
234
|
+
let finalOptions = {};
|
|
235
|
+
const requiredParams = ["index","files","organisation","application","token"];
|
|
236
|
+
|
|
237
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
238
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
239
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
240
|
+
} else if (paramsFile) {
|
|
241
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
242
|
+
} else {
|
|
243
|
+
finalOptions = options;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Validate that all required options are present
|
|
247
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
const client = await getClient(options.token, true);
|
|
253
|
+
const command = new CreatePackageCommand(finalOptions);
|
|
254
|
+
return await client.send(command);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export async function CreateReleaseAction(paramsFile, options){
|
|
258
|
+
let finalOptions = {};
|
|
259
|
+
const requiredParams = ["config","config.release_config_timeout","config.boot_timeout","config.properties","organisation","application","token"];
|
|
260
|
+
|
|
261
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
262
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
263
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
264
|
+
} else if (paramsFile) {
|
|
265
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
266
|
+
} else {
|
|
267
|
+
finalOptions = options;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Validate that all required options are present
|
|
271
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
const client = await getClient(options.token, true);
|
|
277
|
+
const command = new CreateReleaseCommand(finalOptions);
|
|
278
|
+
return await client.send(command);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export async function DeleteDimensionAction(paramsFile, options){
|
|
282
|
+
let finalOptions = {};
|
|
283
|
+
const requiredParams = ["dimension","organisation","application","token"];
|
|
284
|
+
|
|
285
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
286
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
287
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
288
|
+
} else if (paramsFile) {
|
|
289
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
290
|
+
} else {
|
|
291
|
+
finalOptions = options;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Validate that all required options are present
|
|
295
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
const client = await getClient(options.token, true);
|
|
301
|
+
const command = new DeleteDimensionCommand(finalOptions);
|
|
302
|
+
return await client.send(command);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export async function GetReleaseAction(paramsFile, options){
|
|
306
|
+
let finalOptions = {};
|
|
307
|
+
const requiredParams = ["releaseId","organisation","application","token"];
|
|
308
|
+
|
|
309
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
310
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
311
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
312
|
+
} else if (paramsFile) {
|
|
313
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
314
|
+
} else {
|
|
315
|
+
finalOptions = options;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Validate that all required options are present
|
|
319
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
const client = await getClient(options.token, true);
|
|
325
|
+
const command = new GetReleaseCommand(finalOptions);
|
|
326
|
+
return await client.send(command);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export async function GetUserAction(paramsFile, options){
|
|
330
|
+
let finalOptions = {};
|
|
331
|
+
const requiredParams = ["token"];
|
|
332
|
+
|
|
333
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
334
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
335
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
336
|
+
} else if (paramsFile) {
|
|
337
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
338
|
+
} else {
|
|
339
|
+
finalOptions = options;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Validate that all required options are present
|
|
343
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
const client = await getClient(options.token, true);
|
|
349
|
+
const command = new GetUserCommand(finalOptions);
|
|
350
|
+
return await client.send(command);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export async function ListDimensionsAction(paramsFile, options){
|
|
354
|
+
let finalOptions = {};
|
|
355
|
+
const requiredParams = ["organisation","application","token"];
|
|
356
|
+
|
|
357
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
358
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
359
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
360
|
+
} else if (paramsFile) {
|
|
361
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
362
|
+
} else {
|
|
363
|
+
finalOptions = options;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Validate that all required options are present
|
|
367
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
const client = await getClient(options.token, true);
|
|
373
|
+
const command = new ListDimensionsCommand(finalOptions);
|
|
374
|
+
return await client.send(command);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export async function ListFilesAction(paramsFile, options){
|
|
378
|
+
let finalOptions = {};
|
|
379
|
+
const requiredParams = ["organisation","application","token"];
|
|
380
|
+
|
|
381
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
382
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
383
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
384
|
+
} else if (paramsFile) {
|
|
385
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
386
|
+
} else {
|
|
387
|
+
finalOptions = options;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Validate that all required options are present
|
|
391
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
const client = await getClient(options.token, true);
|
|
397
|
+
const command = new ListFilesCommand(finalOptions);
|
|
398
|
+
return await client.send(command);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export async function ListOrganisationsAction(paramsFile, options){
|
|
402
|
+
let finalOptions = {};
|
|
403
|
+
const requiredParams = ["token"];
|
|
404
|
+
|
|
405
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
406
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
407
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
408
|
+
} else if (paramsFile) {
|
|
409
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
410
|
+
} else {
|
|
411
|
+
finalOptions = options;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Validate that all required options are present
|
|
415
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
const client = await getClient(options.token, true);
|
|
421
|
+
const command = new ListOrganisationsCommand(finalOptions);
|
|
422
|
+
return await client.send(command);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export async function ListPackagesAction(paramsFile, options){
|
|
426
|
+
let finalOptions = {};
|
|
427
|
+
const requiredParams = ["organisation","application","token"];
|
|
428
|
+
|
|
429
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
430
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
431
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
432
|
+
} else if (paramsFile) {
|
|
433
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
434
|
+
} else {
|
|
435
|
+
finalOptions = options;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Validate that all required options are present
|
|
439
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
const client = await getClient(options.token, true);
|
|
445
|
+
const command = new ListPackagesCommand(finalOptions);
|
|
446
|
+
return await client.send(command);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export async function ListReleasesAction(paramsFile, options){
|
|
450
|
+
let finalOptions = {};
|
|
451
|
+
const requiredParams = ["organisation","application","token"];
|
|
452
|
+
|
|
453
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
454
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
455
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
456
|
+
} else if (paramsFile) {
|
|
457
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
458
|
+
} else {
|
|
459
|
+
finalOptions = options;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// Validate that all required options are present
|
|
463
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
const client = await getClient(options.token, true);
|
|
469
|
+
const command = new ListReleasesCommand(finalOptions);
|
|
470
|
+
return await client.send(command);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export async function PostLoginAction(paramsFile, options){
|
|
474
|
+
let finalOptions = {};
|
|
475
|
+
const requiredParams = ["client_id","client_secret"];
|
|
476
|
+
|
|
477
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
478
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
479
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
480
|
+
} else if (paramsFile) {
|
|
481
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
482
|
+
} else {
|
|
483
|
+
finalOptions = options;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// Validate that all required options are present
|
|
487
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
const client = await getClient(null, false);
|
|
493
|
+
const command = new PostLoginCommand(finalOptions);
|
|
494
|
+
return await client.send(command);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export async function RequestOrganisationAction(paramsFile, options){
|
|
498
|
+
let finalOptions = {};
|
|
499
|
+
const requiredParams = ["organisation_name","name","email","phone","app_store_link","play_store_link","token"];
|
|
500
|
+
|
|
501
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
502
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
503
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
504
|
+
} else if (paramsFile) {
|
|
505
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
506
|
+
} else {
|
|
507
|
+
finalOptions = options;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Validate that all required options are present
|
|
511
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
const client = await getClient(options.token, true);
|
|
517
|
+
const command = new RequestOrganisationCommand(finalOptions);
|
|
518
|
+
return await client.send(command);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export async function ServeReleaseAction(paramsFile, options){
|
|
522
|
+
let finalOptions = {};
|
|
523
|
+
const requiredParams = ["organisation","application","token"];
|
|
524
|
+
|
|
525
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
526
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
527
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
528
|
+
} else if (paramsFile) {
|
|
529
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
530
|
+
} else {
|
|
531
|
+
finalOptions = options;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Validate that all required options are present
|
|
535
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
const client = await getClient(options.token, true);
|
|
541
|
+
const command = new ServeReleaseCommand(finalOptions);
|
|
542
|
+
return await client.send(command);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export async function ServeReleaseV2Action(paramsFile, options){
|
|
546
|
+
let finalOptions = {};
|
|
547
|
+
const requiredParams = ["organisation","application","token"];
|
|
548
|
+
|
|
549
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
550
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
551
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
552
|
+
} else if (paramsFile) {
|
|
553
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
554
|
+
} else {
|
|
555
|
+
finalOptions = options;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Validate that all required options are present
|
|
559
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
const client = await getClient(options.token, true);
|
|
565
|
+
const command = new ServeReleaseV2Command(finalOptions);
|
|
566
|
+
return await client.send(command);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
export async function UpdateDimensionAction(paramsFile, options){
|
|
570
|
+
let finalOptions = {};
|
|
571
|
+
const requiredParams = ["dimension","change_reason","position","organisation","application","token"];
|
|
572
|
+
|
|
573
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
574
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
575
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
576
|
+
} else if (paramsFile) {
|
|
577
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
578
|
+
} else {
|
|
579
|
+
finalOptions = options;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// Validate that all required options are present
|
|
583
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
const client = await getClient(options.token, true);
|
|
589
|
+
const command = new UpdateDimensionCommand(finalOptions);
|
|
590
|
+
return await client.send(command);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export async function UploadFileAction(paramsFile, options){
|
|
594
|
+
let finalOptions = {};
|
|
595
|
+
const requiredParams = ["file","file_path","checksum","organisation","application","token"];
|
|
596
|
+
|
|
597
|
+
if (paramsFile && paramsFile.startsWith('@')) {
|
|
598
|
+
const jsonFilePath = paramsFile.slice(1);
|
|
599
|
+
finalOptions = mergeOptionsWithJsonFile(options, jsonFilePath, requiredParams);
|
|
600
|
+
} else if (paramsFile) {
|
|
601
|
+
throw new Error("Params file must start with @ (e.g., @params.json)");
|
|
602
|
+
} else {
|
|
603
|
+
finalOptions = options;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// Validate that all required options are present
|
|
607
|
+
validateRequiredOptions(finalOptions, requiredParams);
|
|
608
|
+
|
|
609
|
+
// Handle blob fields recursively at all levels
|
|
610
|
+
if (finalOptions.file) {
|
|
611
|
+
// For streaming blobs, create a readable stream
|
|
612
|
+
const filePathfile = path.resolve(finalOptions.file);
|
|
613
|
+
if (!fs.existsSync(filePathfile)) {
|
|
614
|
+
throw new Error(`File not found: ${filePathfile}`);
|
|
615
|
+
}
|
|
616
|
+
finalOptions.file = fs.createReadStream(filePathfile);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
const client = await getClient(options.token, true);
|
|
622
|
+
const command = new UploadFileCommand(finalOptions);
|
|
623
|
+
return await client.send(command);
|
|
624
|
+
}
|
package/bin.js
ADDED