skystream-cli 1.2.5 → 1.2.7

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 (2) hide show
  1. package/dist/index.js +43 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ const program = new Command();
9
9
  program
10
10
  .name('skystream')
11
11
  .description('SkyStream Plugin Development Kit CLI (Sky Gen 2)')
12
- .version('1.2.5');
12
+ .version('1.2.7');
13
13
  // Schemas
14
14
  const pluginSchema = z.object({
15
15
  packageName: z.string().min(5).regex(/^[a-z0-9._-]+$/),
@@ -103,7 +103,7 @@ const JS_TEMPLATE = `(function() {
103
103
  * @param {string} url
104
104
  * @param {(res: Response) => void} cb
105
105
  */
106
- function load(url, cb) {
106
+ async function load(url, cb) {
107
107
  try {
108
108
  // Standard: Return a single item with full metadata
109
109
  cb({
@@ -381,28 +381,63 @@ program.command('test')
381
381
  console.log(`\n--- Testing ${manifest.packageName} -> ${options.function} ---`);
382
382
  const context = {
383
383
  manifest,
384
- console: { log: (...args) => console.log(' [JS]:', ...args), error: (...args) => console.error(' [JS ERR]:', ...args) },
384
+ console: {
385
+ log: (...args) => console.log(' [JS]:', ...args),
386
+ error: (...args) => console.error(' [JS ERR]:', ...args)
387
+ },
385
388
  http_get: async (url, headers, cb) => {
386
389
  try {
387
- const res = await axios.get(url, { headers });
388
- const result = { status: res.status, body: res.data, headers: res.headers };
390
+ const res = await axios.get(url, { headers: headers || {} });
391
+ const result = { statusCode: res.status, body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data), headers: res.headers };
392
+ if (cb)
393
+ cb(result);
394
+ return result;
395
+ }
396
+ catch (e) {
397
+ const res = { statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
398
+ if (cb)
399
+ cb(res);
400
+ return res;
401
+ }
402
+ },
403
+ http_post: async (url, headers, body, cb) => {
404
+ try {
405
+ const res = await axios.post(url, body, { headers: headers || {} });
406
+ const result = { statusCode: res.status, body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data), headers: res.headers };
389
407
  if (cb)
390
408
  cb(result);
391
409
  return result;
392
410
  }
393
411
  catch (e) {
394
- const res = { status: 500, body: e.message, headers: {} };
412
+ const res = { statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
395
413
  if (cb)
396
414
  cb(res);
397
415
  return res;
398
416
  }
399
417
  },
418
+ _fetch: async (url) => {
419
+ try {
420
+ const res = await axios.get(url);
421
+ return typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
422
+ }
423
+ catch (e) {
424
+ throw new Error(`HTTP Error ${e.response?.status || 500} fetching ${url}`);
425
+ }
426
+ },
427
+ fetch: async (url) => {
428
+ const res = await axios.get(url);
429
+ return {
430
+ statusCode: res.status,
431
+ body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data),
432
+ headers: res.headers
433
+ };
434
+ },
400
435
  btoa: (s) => Buffer.from(s).toString('base64'),
401
436
  atob: (s) => Buffer.from(s, 'base64').toString('utf8'),
402
437
  globalThis: {},
403
438
  };
404
- const runtime = new Function('manifest', 'console', 'http_get', 'btoa', 'atob', 'globalThis', jsContent);
405
- runtime(context.manifest, context.console, context.http_get, context.btoa, context.atob, context.globalThis);
439
+ const runtime = new Function('manifest', 'console', 'http_get', 'http_post', '_fetch', 'fetch', 'btoa', 'atob', 'globalThis', jsContent);
440
+ runtime(context.manifest, context.console, context.http_get, context.http_post, context._fetch, context.fetch, context.btoa, context.atob, context.globalThis);
406
441
  const fn = context.globalThis[options.function];
407
442
  if (typeof fn !== 'function') {
408
443
  console.error('Error: exported function not found');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skystream-cli",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "type": "module",
5
5
  "description": "SkyStream Plugin Development Kit & Repository Manager",
6
6
  "main": "dist/index.js",