@ubiquity-os/plugin-sdk 3.1.7 → 3.1.9

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/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import * as hono_types from 'hono/types';
2
1
  import { EmitterWebhookEventName, EmitterWebhookEvent } from '@octokit/webhooks';
3
- import { Hono } from 'hono';
4
2
  import * as _ubiquity_os_ubiquity_os_logger from '@ubiquity-os/ubiquity-os-logger';
5
3
  import { LogReturn, Metadata, Logs, LogLevel } from '@ubiquity-os/ubiquity-os-logger';
6
4
  import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
7
5
  import { customOctokit } from './octokit.mjs';
8
- import { Manifest } from './manifest.mjs';
9
6
  import { TAnySchema } from '@sinclair/typebox';
7
+ import * as hono_types from 'hono/types';
8
+ import { Hono } from 'hono';
9
+ import { Manifest } from './manifest.mjs';
10
10
  import '@octokit/core/dist-types/types';
11
11
  import '@octokit/plugin-paginate-graphql';
12
12
  import '@octokit/plugin-paginate-rest';
@@ -128,8 +128,8 @@ interface Options {
128
128
  bypassSignatureVerification?: boolean;
129
129
  }
130
130
 
131
- declare function createPlugin<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TCommand, TSupportedEvents>) => HandlerReturn, manifest: Manifest, options?: Options): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
132
-
133
131
  declare function createActionsPlugin<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TCommand, TSupportedEvents>) => HandlerReturn, options?: Options): Promise<void>;
134
132
 
133
+ declare function createPlugin<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TCommand, TSupportedEvents>) => HandlerReturn, manifest: Manifest, options?: Options): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
134
+
135
135
  export { CommentHandler, type Context, type Options, createActionsPlugin, createPlugin };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import * as hono_types from 'hono/types';
2
1
  import { EmitterWebhookEventName, EmitterWebhookEvent } from '@octokit/webhooks';
3
- import { Hono } from 'hono';
4
2
  import * as _ubiquity_os_ubiquity_os_logger from '@ubiquity-os/ubiquity-os-logger';
5
3
  import { LogReturn, Metadata, Logs, LogLevel } from '@ubiquity-os/ubiquity-os-logger';
6
4
  import { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
7
5
  import { customOctokit } from './octokit.js';
8
- import { Manifest } from './manifest.js';
9
6
  import { TAnySchema } from '@sinclair/typebox';
7
+ import * as hono_types from 'hono/types';
8
+ import { Hono } from 'hono';
9
+ import { Manifest } from './manifest.js';
10
10
  import '@octokit/core/dist-types/types';
11
11
  import '@octokit/plugin-paginate-graphql';
12
12
  import '@octokit/plugin-paginate-rest';
@@ -128,8 +128,8 @@ interface Options {
128
128
  bypassSignatureVerification?: boolean;
129
129
  }
130
130
 
131
- declare function createPlugin<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TCommand, TSupportedEvents>) => HandlerReturn, manifest: Manifest, options?: Options): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
132
-
133
131
  declare function createActionsPlugin<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TCommand, TSupportedEvents>) => HandlerReturn, options?: Options): Promise<void>;
134
132
 
133
+ declare function createPlugin<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TCommand, TSupportedEvents>) => HandlerReturn, manifest: Manifest, options?: Options): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
134
+
135
135
  export { CommentHandler, type Context, type Options, createActionsPlugin, createPlugin };
package/dist/index.js CHANGED
@@ -36,12 +36,12 @@ __export(src_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(src_exports);
38
38
 
39
- // src/server.ts
39
+ // src/actions.ts
40
+ var core = __toESM(require("@actions/core"));
41
+ var github2 = __toESM(require("@actions/github"));
40
42
  var import_value2 = require("@sinclair/typebox/value");
41
43
  var import_ubiquity_os_logger3 = require("@ubiquity-os/ubiquity-os-logger");
42
- var import_hono = require("hono");
43
- var import_adapter2 = require("hono/adapter");
44
- var import_http_exception = require("hono/http-exception");
44
+ var import_dotenv = require("dotenv");
45
45
 
46
46
  // src/helpers/runtime-info.ts
47
47
  var import_github = __toESM(require("@actions/github"));
@@ -101,7 +101,7 @@ var DenoRuntimeInfo = class extends PluginRuntimeInfo {
101
101
  }
102
102
  get runUrl() {
103
103
  const projectName = Deno.env.get("DENO_PROJECT_NAME");
104
- const baseUrl = `https://dash.deno.com/project/${projectName}/logs`;
104
+ const baseUrl = `https://dash.deno.com/projects/${projectName}/logs`;
105
105
  const start = new Date(Date.now() - 6e4).toISOString();
106
106
  const end = new Date(Date.now() + 6e4).toISOString();
107
107
  const filters = {
@@ -331,11 +331,11 @@ function transformError(context2, error) {
331
331
 
332
332
  // src/octokit.ts
333
333
  var import_core = require("@octokit/core");
334
+ var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
334
335
  var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
335
336
  var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
336
337
  var import_plugin_retry = require("@octokit/plugin-retry");
337
338
  var import_plugin_throttling = require("@octokit/plugin-throttling");
338
- var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
339
339
  var defaultOptions = {
340
340
  throttle: {
341
341
  onAbuseLimit: (retryAfter, options, octokit) => {
@@ -418,95 +418,7 @@ var inputSchema = import_typebox3.Type.Object({
418
418
  signature: import_typebox3.Type.String()
419
419
  });
420
420
 
421
- // src/server.ts
422
- function createPlugin(handler, manifest, options) {
423
- const pluginOptions = getPluginOptions(options);
424
- const app = new import_hono.Hono();
425
- app.get("/manifest.json", (ctx) => {
426
- return ctx.json(manifest);
427
- });
428
- app.post("/", async function appPost(ctx) {
429
- if (ctx.req.header("content-type") !== "application/json") {
430
- throw new import_http_exception.HTTPException(400, { message: "Content-Type must be application/json" });
431
- }
432
- const body = await ctx.req.json();
433
- const inputSchemaErrors = [...import_value2.Value.Errors(inputSchema, body)];
434
- if (inputSchemaErrors.length) {
435
- console.dir(inputSchemaErrors, { depth: null });
436
- throw new import_http_exception.HTTPException(400, { message: "Invalid body" });
437
- }
438
- const signature = body.signature;
439
- if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
440
- throw new import_http_exception.HTTPException(400, { message: "Invalid signature" });
441
- }
442
- const inputs = import_value2.Value.Decode(inputSchema, body);
443
- let config2;
444
- if (pluginOptions.settingsSchema) {
445
- try {
446
- config2 = import_value2.Value.Decode(pluginOptions.settingsSchema, import_value2.Value.Default(pluginOptions.settingsSchema, inputs.settings));
447
- } catch (e) {
448
- console.dir(...import_value2.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
449
- throw e;
450
- }
451
- } else {
452
- config2 = inputs.settings;
453
- }
454
- let env;
455
- const honoEnvironment = (0, import_adapter2.env)(ctx);
456
- if (pluginOptions.envSchema) {
457
- try {
458
- env = import_value2.Value.Decode(pluginOptions.envSchema, import_value2.Value.Default(pluginOptions.envSchema, honoEnvironment));
459
- } catch (e) {
460
- console.dir(...import_value2.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
461
- throw e;
462
- }
463
- } else {
464
- env = ctx.env;
465
- }
466
- const workerName = new URL(inputs.ref).hostname.split(".")[0];
467
- PluginRuntimeInfo.getInstance({ ...env, CLOUDFLARE_WORKER_NAME: workerName });
468
- let command = null;
469
- if (inputs.command && pluginOptions.commandSchema) {
470
- try {
471
- command = import_value2.Value.Decode(pluginOptions.commandSchema, import_value2.Value.Default(pluginOptions.commandSchema, inputs.command));
472
- } catch (e) {
473
- console.log(...import_value2.Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
474
- throw e;
475
- }
476
- } else if (inputs.command) {
477
- command = inputs.command;
478
- }
479
- const context2 = {
480
- eventName: inputs.eventName,
481
- payload: inputs.eventPayload,
482
- command,
483
- octokit: new customOctokit({ auth: inputs.authToken }),
484
- config: config2,
485
- env,
486
- logger: new import_ubiquity_os_logger3.Logs(pluginOptions.logLevel),
487
- commentHandler: new CommentHandler()
488
- };
489
- try {
490
- const result = await handler(context2);
491
- return ctx.json({ stateId: inputs.stateId, output: result ?? {} });
492
- } catch (error) {
493
- console.error(error);
494
- const loggerError = transformError(context2, error);
495
- if (pluginOptions.postCommentOnError && loggerError) {
496
- await context2.commentHandler.postComment(context2, loggerError);
497
- }
498
- throw new import_http_exception.HTTPException(500, { message: "Unexpected error" });
499
- }
500
- });
501
- return app;
502
- }
503
-
504
421
  // src/actions.ts
505
- var core = __toESM(require("@actions/core"));
506
- var github2 = __toESM(require("@actions/github"));
507
- var import_value3 = require("@sinclair/typebox/value");
508
- var import_ubiquity_os_logger4 = require("@ubiquity-os/ubiquity-os-logger");
509
- var import_dotenv = require("dotenv");
510
422
  (0, import_dotenv.config)();
511
423
  async function createActionsPlugin(handler, options) {
512
424
  const pluginOptions = getPluginOptions(options);
@@ -516,7 +428,7 @@ async function createActionsPlugin(handler, options) {
516
428
  return;
517
429
  }
518
430
  const body = github2.context.payload.inputs;
519
- const inputSchemaErrors = [...import_value3.Value.Errors(inputSchema, body)];
431
+ const inputSchemaErrors = [...import_value2.Value.Errors(inputSchema, body)];
520
432
  if (inputSchemaErrors.length) {
521
433
  console.dir(inputSchemaErrors, { depth: null });
522
434
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.map((o) => o.message).join(", ")}`);
@@ -527,13 +439,13 @@ async function createActionsPlugin(handler, options) {
527
439
  core.setFailed(`Error: Invalid signature`);
528
440
  return;
529
441
  }
530
- const inputs = import_value3.Value.Decode(inputSchema, body);
442
+ const inputs = import_value2.Value.Decode(inputSchema, body);
531
443
  let config2;
532
444
  if (pluginOptions.settingsSchema) {
533
445
  try {
534
- config2 = import_value3.Value.Decode(pluginOptions.settingsSchema, import_value3.Value.Default(pluginOptions.settingsSchema, inputs.settings));
446
+ config2 = import_value2.Value.Decode(pluginOptions.settingsSchema, import_value2.Value.Default(pluginOptions.settingsSchema, inputs.settings));
535
447
  } catch (e) {
536
- console.dir(...import_value3.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
448
+ console.dir(...import_value2.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
537
449
  core.setFailed(`Error: Invalid settings provided.`);
538
450
  throw e;
539
451
  }
@@ -543,9 +455,9 @@ async function createActionsPlugin(handler, options) {
543
455
  let env;
544
456
  if (pluginOptions.envSchema) {
545
457
  try {
546
- env = import_value3.Value.Decode(pluginOptions.envSchema, import_value3.Value.Default(pluginOptions.envSchema, process.env));
458
+ env = import_value2.Value.Decode(pluginOptions.envSchema, import_value2.Value.Default(pluginOptions.envSchema, process.env));
547
459
  } catch (e) {
548
- console.dir(...import_value3.Value.Errors(pluginOptions.envSchema, process.env), { depth: null });
460
+ console.dir(...import_value2.Value.Errors(pluginOptions.envSchema, process.env), { depth: null });
549
461
  core.setFailed(`Error: Invalid environment provided.`);
550
462
  throw e;
551
463
  }
@@ -555,9 +467,9 @@ async function createActionsPlugin(handler, options) {
555
467
  let command = null;
556
468
  if (inputs.command && pluginOptions.commandSchema) {
557
469
  try {
558
- command = import_value3.Value.Decode(pluginOptions.commandSchema, import_value3.Value.Default(pluginOptions.commandSchema, inputs.command));
470
+ command = import_value2.Value.Decode(pluginOptions.commandSchema, import_value2.Value.Default(pluginOptions.commandSchema, inputs.command));
559
471
  } catch (e) {
560
- console.dir(...import_value3.Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
472
+ console.dir(...import_value2.Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
561
473
  throw e;
562
474
  }
563
475
  } else if (inputs.command) {
@@ -570,7 +482,7 @@ async function createActionsPlugin(handler, options) {
570
482
  octokit: new customOctokit({ auth: inputs.authToken }),
571
483
  config: config2,
572
484
  env,
573
- logger: new import_ubiquity_os_logger4.Logs(pluginOptions.logLevel),
485
+ logger: new import_ubiquity_os_logger3.Logs(pluginOptions.logLevel),
574
486
  commentHandler: new CommentHandler()
575
487
  };
576
488
  try {
@@ -580,7 +492,7 @@ async function createActionsPlugin(handler, options) {
580
492
  } catch (error) {
581
493
  console.error(error);
582
494
  const loggerError = transformError(context2, error);
583
- if (loggerError instanceof import_ubiquity_os_logger4.LogReturn) {
495
+ if (loggerError instanceof import_ubiquity_os_logger3.LogReturn) {
584
496
  core.setFailed(loggerError.logMessage.diff);
585
497
  } else if (loggerError instanceof Error) {
586
498
  core.setFailed(loggerError);
@@ -602,6 +514,94 @@ async function returnDataToKernel(repoToken, stateId, output) {
602
514
  }
603
515
  });
604
516
  }
517
+
518
+ // src/server.ts
519
+ var import_value3 = require("@sinclair/typebox/value");
520
+ var import_ubiquity_os_logger4 = require("@ubiquity-os/ubiquity-os-logger");
521
+ var import_hono = require("hono");
522
+ var import_adapter2 = require("hono/adapter");
523
+ var import_http_exception = require("hono/http-exception");
524
+ function createPlugin(handler, manifest, options) {
525
+ const pluginOptions = getPluginOptions(options);
526
+ const app = new import_hono.Hono();
527
+ app.get("/manifest.json", (ctx) => {
528
+ return ctx.json(manifest);
529
+ });
530
+ app.post("/", async function appPost(ctx) {
531
+ if (ctx.req.header("content-type") !== "application/json") {
532
+ throw new import_http_exception.HTTPException(400, { message: "Content-Type must be application/json" });
533
+ }
534
+ const body = await ctx.req.json();
535
+ const inputSchemaErrors = [...import_value3.Value.Errors(inputSchema, body)];
536
+ if (inputSchemaErrors.length) {
537
+ console.dir(inputSchemaErrors, { depth: null });
538
+ throw new import_http_exception.HTTPException(400, { message: "Invalid body" });
539
+ }
540
+ const signature = body.signature;
541
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
542
+ throw new import_http_exception.HTTPException(400, { message: "Invalid signature" });
543
+ }
544
+ const inputs = import_value3.Value.Decode(inputSchema, body);
545
+ let config2;
546
+ if (pluginOptions.settingsSchema) {
547
+ try {
548
+ config2 = import_value3.Value.Decode(pluginOptions.settingsSchema, import_value3.Value.Default(pluginOptions.settingsSchema, inputs.settings));
549
+ } catch (e) {
550
+ console.dir(...import_value3.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
551
+ throw e;
552
+ }
553
+ } else {
554
+ config2 = inputs.settings;
555
+ }
556
+ let env;
557
+ const honoEnvironment = (0, import_adapter2.env)(ctx);
558
+ if (pluginOptions.envSchema) {
559
+ try {
560
+ env = import_value3.Value.Decode(pluginOptions.envSchema, import_value3.Value.Default(pluginOptions.envSchema, honoEnvironment));
561
+ } catch (e) {
562
+ console.dir(...import_value3.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
563
+ throw e;
564
+ }
565
+ } else {
566
+ env = ctx.env;
567
+ }
568
+ const workerName = new URL(inputs.ref).hostname.split(".")[0];
569
+ PluginRuntimeInfo.getInstance({ ...env, CLOUDFLARE_WORKER_NAME: workerName });
570
+ let command = null;
571
+ if (inputs.command && pluginOptions.commandSchema) {
572
+ try {
573
+ command = import_value3.Value.Decode(pluginOptions.commandSchema, import_value3.Value.Default(pluginOptions.commandSchema, inputs.command));
574
+ } catch (e) {
575
+ console.log(...import_value3.Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
576
+ throw e;
577
+ }
578
+ } else if (inputs.command) {
579
+ command = inputs.command;
580
+ }
581
+ const context2 = {
582
+ eventName: inputs.eventName,
583
+ payload: inputs.eventPayload,
584
+ command,
585
+ octokit: new customOctokit({ auth: inputs.authToken }),
586
+ config: config2,
587
+ env,
588
+ logger: new import_ubiquity_os_logger4.Logs(pluginOptions.logLevel),
589
+ commentHandler: new CommentHandler()
590
+ };
591
+ try {
592
+ const result = await handler(context2);
593
+ return ctx.json({ stateId: inputs.stateId, output: result ?? {} });
594
+ } catch (error) {
595
+ console.error(error);
596
+ const loggerError = transformError(context2, error);
597
+ if (pluginOptions.postCommentOnError && loggerError) {
598
+ await context2.commentHandler.postComment(context2, loggerError);
599
+ }
600
+ throw new import_http_exception.HTTPException(500, { message: "Unexpected error" });
601
+ }
602
+ });
603
+ return app;
604
+ }
605
605
  // Annotate the CommonJS export names for ESM import in node:
606
606
  0 && (module.exports = {
607
607
  CommentHandler,
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- // src/server.ts
1
+ // src/actions.ts
2
+ import * as core from "@actions/core";
3
+ import * as github2 from "@actions/github";
2
4
  import { Value as Value2 } from "@sinclair/typebox/value";
3
- import { Logs } from "@ubiquity-os/ubiquity-os-logger";
4
- import { Hono } from "hono";
5
- import { env as honoEnv } from "hono/adapter";
6
- import { HTTPException } from "hono/http-exception";
5
+ import { LogReturn as LogReturn3, Logs } from "@ubiquity-os/ubiquity-os-logger";
6
+ import { config } from "dotenv";
7
7
 
8
8
  // src/helpers/runtime-info.ts
9
9
  import github from "@actions/github";
@@ -63,7 +63,7 @@ var DenoRuntimeInfo = class extends PluginRuntimeInfo {
63
63
  }
64
64
  get runUrl() {
65
65
  const projectName = Deno.env.get("DENO_PROJECT_NAME");
66
- const baseUrl = `https://dash.deno.com/project/${projectName}/logs`;
66
+ const baseUrl = `https://dash.deno.com/projects/${projectName}/logs`;
67
67
  const start = new Date(Date.now() - 6e4).toISOString();
68
68
  const end = new Date(Date.now() + 6e4).toISOString();
69
69
  const filters = {
@@ -293,11 +293,11 @@ function transformError(context2, error) {
293
293
 
294
294
  // src/octokit.ts
295
295
  import { Octokit } from "@octokit/core";
296
+ import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
296
297
  import { paginateRest } from "@octokit/plugin-paginate-rest";
297
298
  import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
298
299
  import { retry } from "@octokit/plugin-retry";
299
300
  import { throttling } from "@octokit/plugin-throttling";
300
- import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
301
301
  var defaultOptions = {
302
302
  throttle: {
303
303
  onAbuseLimit: (retryAfter, options, octokit) => {
@@ -380,95 +380,7 @@ var inputSchema = T2.Object({
380
380
  signature: T2.String()
381
381
  });
382
382
 
383
- // src/server.ts
384
- function createPlugin(handler, manifest, options) {
385
- const pluginOptions = getPluginOptions(options);
386
- const app = new Hono();
387
- app.get("/manifest.json", (ctx) => {
388
- return ctx.json(manifest);
389
- });
390
- app.post("/", async function appPost(ctx) {
391
- if (ctx.req.header("content-type") !== "application/json") {
392
- throw new HTTPException(400, { message: "Content-Type must be application/json" });
393
- }
394
- const body = await ctx.req.json();
395
- const inputSchemaErrors = [...Value2.Errors(inputSchema, body)];
396
- if (inputSchemaErrors.length) {
397
- console.dir(inputSchemaErrors, { depth: null });
398
- throw new HTTPException(400, { message: "Invalid body" });
399
- }
400
- const signature = body.signature;
401
- if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
402
- throw new HTTPException(400, { message: "Invalid signature" });
403
- }
404
- const inputs = Value2.Decode(inputSchema, body);
405
- let config2;
406
- if (pluginOptions.settingsSchema) {
407
- try {
408
- config2 = Value2.Decode(pluginOptions.settingsSchema, Value2.Default(pluginOptions.settingsSchema, inputs.settings));
409
- } catch (e) {
410
- console.dir(...Value2.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
411
- throw e;
412
- }
413
- } else {
414
- config2 = inputs.settings;
415
- }
416
- let env;
417
- const honoEnvironment = honoEnv(ctx);
418
- if (pluginOptions.envSchema) {
419
- try {
420
- env = Value2.Decode(pluginOptions.envSchema, Value2.Default(pluginOptions.envSchema, honoEnvironment));
421
- } catch (e) {
422
- console.dir(...Value2.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
423
- throw e;
424
- }
425
- } else {
426
- env = ctx.env;
427
- }
428
- const workerName = new URL(inputs.ref).hostname.split(".")[0];
429
- PluginRuntimeInfo.getInstance({ ...env, CLOUDFLARE_WORKER_NAME: workerName });
430
- let command = null;
431
- if (inputs.command && pluginOptions.commandSchema) {
432
- try {
433
- command = Value2.Decode(pluginOptions.commandSchema, Value2.Default(pluginOptions.commandSchema, inputs.command));
434
- } catch (e) {
435
- console.log(...Value2.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
436
- throw e;
437
- }
438
- } else if (inputs.command) {
439
- command = inputs.command;
440
- }
441
- const context2 = {
442
- eventName: inputs.eventName,
443
- payload: inputs.eventPayload,
444
- command,
445
- octokit: new customOctokit({ auth: inputs.authToken }),
446
- config: config2,
447
- env,
448
- logger: new Logs(pluginOptions.logLevel),
449
- commentHandler: new CommentHandler()
450
- };
451
- try {
452
- const result = await handler(context2);
453
- return ctx.json({ stateId: inputs.stateId, output: result ?? {} });
454
- } catch (error) {
455
- console.error(error);
456
- const loggerError = transformError(context2, error);
457
- if (pluginOptions.postCommentOnError && loggerError) {
458
- await context2.commentHandler.postComment(context2, loggerError);
459
- }
460
- throw new HTTPException(500, { message: "Unexpected error" });
461
- }
462
- });
463
- return app;
464
- }
465
-
466
383
  // src/actions.ts
467
- import * as core from "@actions/core";
468
- import * as github2 from "@actions/github";
469
- import { Value as Value3 } from "@sinclair/typebox/value";
470
- import { LogReturn as LogReturn3, Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
471
- import { config } from "dotenv";
472
384
  config();
473
385
  async function createActionsPlugin(handler, options) {
474
386
  const pluginOptions = getPluginOptions(options);
@@ -478,7 +390,7 @@ async function createActionsPlugin(handler, options) {
478
390
  return;
479
391
  }
480
392
  const body = github2.context.payload.inputs;
481
- const inputSchemaErrors = [...Value3.Errors(inputSchema, body)];
393
+ const inputSchemaErrors = [...Value2.Errors(inputSchema, body)];
482
394
  if (inputSchemaErrors.length) {
483
395
  console.dir(inputSchemaErrors, { depth: null });
484
396
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.map((o) => o.message).join(", ")}`);
@@ -489,13 +401,13 @@ async function createActionsPlugin(handler, options) {
489
401
  core.setFailed(`Error: Invalid signature`);
490
402
  return;
491
403
  }
492
- const inputs = Value3.Decode(inputSchema, body);
404
+ const inputs = Value2.Decode(inputSchema, body);
493
405
  let config2;
494
406
  if (pluginOptions.settingsSchema) {
495
407
  try {
496
- config2 = Value3.Decode(pluginOptions.settingsSchema, Value3.Default(pluginOptions.settingsSchema, inputs.settings));
408
+ config2 = Value2.Decode(pluginOptions.settingsSchema, Value2.Default(pluginOptions.settingsSchema, inputs.settings));
497
409
  } catch (e) {
498
- console.dir(...Value3.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
410
+ console.dir(...Value2.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
499
411
  core.setFailed(`Error: Invalid settings provided.`);
500
412
  throw e;
501
413
  }
@@ -505,9 +417,9 @@ async function createActionsPlugin(handler, options) {
505
417
  let env;
506
418
  if (pluginOptions.envSchema) {
507
419
  try {
508
- env = Value3.Decode(pluginOptions.envSchema, Value3.Default(pluginOptions.envSchema, process.env));
420
+ env = Value2.Decode(pluginOptions.envSchema, Value2.Default(pluginOptions.envSchema, process.env));
509
421
  } catch (e) {
510
- console.dir(...Value3.Errors(pluginOptions.envSchema, process.env), { depth: null });
422
+ console.dir(...Value2.Errors(pluginOptions.envSchema, process.env), { depth: null });
511
423
  core.setFailed(`Error: Invalid environment provided.`);
512
424
  throw e;
513
425
  }
@@ -517,9 +429,9 @@ async function createActionsPlugin(handler, options) {
517
429
  let command = null;
518
430
  if (inputs.command && pluginOptions.commandSchema) {
519
431
  try {
520
- command = Value3.Decode(pluginOptions.commandSchema, Value3.Default(pluginOptions.commandSchema, inputs.command));
432
+ command = Value2.Decode(pluginOptions.commandSchema, Value2.Default(pluginOptions.commandSchema, inputs.command));
521
433
  } catch (e) {
522
- console.dir(...Value3.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
434
+ console.dir(...Value2.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
523
435
  throw e;
524
436
  }
525
437
  } else if (inputs.command) {
@@ -532,7 +444,7 @@ async function createActionsPlugin(handler, options) {
532
444
  octokit: new customOctokit({ auth: inputs.authToken }),
533
445
  config: config2,
534
446
  env,
535
- logger: new Logs2(pluginOptions.logLevel),
447
+ logger: new Logs(pluginOptions.logLevel),
536
448
  commentHandler: new CommentHandler()
537
449
  };
538
450
  try {
@@ -564,6 +476,94 @@ async function returnDataToKernel(repoToken, stateId, output) {
564
476
  }
565
477
  });
566
478
  }
479
+
480
+ // src/server.ts
481
+ import { Value as Value3 } from "@sinclair/typebox/value";
482
+ import { Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
483
+ import { Hono } from "hono";
484
+ import { env as honoEnv } from "hono/adapter";
485
+ import { HTTPException } from "hono/http-exception";
486
+ function createPlugin(handler, manifest, options) {
487
+ const pluginOptions = getPluginOptions(options);
488
+ const app = new Hono();
489
+ app.get("/manifest.json", (ctx) => {
490
+ return ctx.json(manifest);
491
+ });
492
+ app.post("/", async function appPost(ctx) {
493
+ if (ctx.req.header("content-type") !== "application/json") {
494
+ throw new HTTPException(400, { message: "Content-Type must be application/json" });
495
+ }
496
+ const body = await ctx.req.json();
497
+ const inputSchemaErrors = [...Value3.Errors(inputSchema, body)];
498
+ if (inputSchemaErrors.length) {
499
+ console.dir(inputSchemaErrors, { depth: null });
500
+ throw new HTTPException(400, { message: "Invalid body" });
501
+ }
502
+ const signature = body.signature;
503
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
504
+ throw new HTTPException(400, { message: "Invalid signature" });
505
+ }
506
+ const inputs = Value3.Decode(inputSchema, body);
507
+ let config2;
508
+ if (pluginOptions.settingsSchema) {
509
+ try {
510
+ config2 = Value3.Decode(pluginOptions.settingsSchema, Value3.Default(pluginOptions.settingsSchema, inputs.settings));
511
+ } catch (e) {
512
+ console.dir(...Value3.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
513
+ throw e;
514
+ }
515
+ } else {
516
+ config2 = inputs.settings;
517
+ }
518
+ let env;
519
+ const honoEnvironment = honoEnv(ctx);
520
+ if (pluginOptions.envSchema) {
521
+ try {
522
+ env = Value3.Decode(pluginOptions.envSchema, Value3.Default(pluginOptions.envSchema, honoEnvironment));
523
+ } catch (e) {
524
+ console.dir(...Value3.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
525
+ throw e;
526
+ }
527
+ } else {
528
+ env = ctx.env;
529
+ }
530
+ const workerName = new URL(inputs.ref).hostname.split(".")[0];
531
+ PluginRuntimeInfo.getInstance({ ...env, CLOUDFLARE_WORKER_NAME: workerName });
532
+ let command = null;
533
+ if (inputs.command && pluginOptions.commandSchema) {
534
+ try {
535
+ command = Value3.Decode(pluginOptions.commandSchema, Value3.Default(pluginOptions.commandSchema, inputs.command));
536
+ } catch (e) {
537
+ console.log(...Value3.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
538
+ throw e;
539
+ }
540
+ } else if (inputs.command) {
541
+ command = inputs.command;
542
+ }
543
+ const context2 = {
544
+ eventName: inputs.eventName,
545
+ payload: inputs.eventPayload,
546
+ command,
547
+ octokit: new customOctokit({ auth: inputs.authToken }),
548
+ config: config2,
549
+ env,
550
+ logger: new Logs2(pluginOptions.logLevel),
551
+ commentHandler: new CommentHandler()
552
+ };
553
+ try {
554
+ const result = await handler(context2);
555
+ return ctx.json({ stateId: inputs.stateId, output: result ?? {} });
556
+ } catch (error) {
557
+ console.error(error);
558
+ const loggerError = transformError(context2, error);
559
+ if (pluginOptions.postCommentOnError && loggerError) {
560
+ await context2.commentHandler.postComment(context2, loggerError);
561
+ }
562
+ throw new HTTPException(500, { message: "Unexpected error" });
563
+ }
564
+ });
565
+ return app;
566
+ }
567
567
  export {
568
568
  CommentHandler,
569
569
  createActionsPlugin,
@@ -1,6 +1,7 @@
1
1
  import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
2
2
  import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-graphql';
3
3
  import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
4
+ export { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
4
5
  import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
5
6
  import * as _octokit_request_error from '@octokit/request-error';
6
7
  import { Octokit } from '@octokit/core';
package/dist/octokit.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
2
2
  import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-graphql';
3
3
  import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
4
+ export { RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
4
5
  import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
5
6
  import * as _octokit_request_error from '@octokit/request-error';
6
7
  import { Octokit } from '@octokit/core';
package/dist/octokit.js CHANGED
@@ -24,11 +24,11 @@ __export(octokit_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(octokit_exports);
26
26
  var import_core = require("@octokit/core");
27
+ var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
27
28
  var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
28
29
  var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
29
30
  var import_plugin_retry = require("@octokit/plugin-retry");
30
31
  var import_plugin_throttling = require("@octokit/plugin-throttling");
31
- var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
32
32
  var defaultOptions = {
33
33
  throttle: {
34
34
  onAbuseLimit: (retryAfter, options, octokit) => {
package/dist/octokit.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  // src/octokit.ts
2
2
  import { Octokit } from "@octokit/core";
3
+ import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
3
4
  import { paginateRest } from "@octokit/plugin-paginate-rest";
4
5
  import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
5
6
  import { retry } from "@octokit/plugin-retry";
6
7
  import { throttling } from "@octokit/plugin-throttling";
7
- import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
8
8
  var defaultOptions = {
9
9
  throttle: {
10
10
  onAbuseLimit: (retryAfter, options, octokit) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubiquity-os/plugin-sdk",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "SDK for plugin support.",
5
5
  "author": "Ubiquity DAO",
6
6
  "license": "MIT",
@@ -92,7 +92,6 @@
92
92
  "@octokit/plugin-rest-endpoint-methods": "^13.3.1",
93
93
  "@octokit/plugin-retry": "^7.1.4",
94
94
  "@octokit/plugin-throttling": "^9.4.0",
95
- "@octokit/rest": "^21.1.1",
96
95
  "@octokit/types": "^13.8.0",
97
96
  "@octokit/webhooks": "^13.7.4",
98
97
  "@ubiquity-os/ubiquity-os-logger": "^1.4.0",
@@ -128,7 +127,6 @@
128
127
  "msw": "^2.6.3",
129
128
  "npm-run-all": "^4.1.5",
130
129
  "prettier": "^3.3.3",
131
- "simple-git": "^3.27.0",
132
130
  "ts-jest": "^29.2.5",
133
131
  "ts-node": "^10.9.2",
134
132
  "tsup": "^8.4.0",