@ubiquity-os/plugin-sdk 1.0.8 → 1.0.10

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.
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/constants.ts
21
+ var constants_exports = {};
22
+ __export(constants_exports, {
23
+ BOT_USER_ID: () => BOT_USER_ID,
24
+ CONFIG_FULL_PATH: () => CONFIG_FULL_PATH,
25
+ CONFIG_ORG_REPO: () => CONFIG_ORG_REPO,
26
+ DEV_CONFIG_FULL_PATH: () => DEV_CONFIG_FULL_PATH,
27
+ KERNEL_APP_ID: () => KERNEL_APP_ID,
28
+ KERNEL_PUBLIC_KEY: () => KERNEL_PUBLIC_KEY
29
+ });
30
+ module.exports = __toCommonJS(constants_exports);
31
+
32
+ // src/types/config.ts
33
+ var CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
34
+ var DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
35
+ var CONFIG_ORG_REPO = ".ubiquity-os";
36
+
37
+ // src/constants.ts
38
+ var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
39
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
40
+ uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
41
+ U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
42
+ I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
43
+ wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
44
+ Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
45
+ JQIDAQAB
46
+ -----END PUBLIC KEY-----
47
+ `;
48
+ var KERNEL_APP_ID = 975031;
49
+ var BOT_USER_ID = 178941584;
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ BOT_USER_ID,
53
+ CONFIG_FULL_PATH,
54
+ CONFIG_ORG_REPO,
55
+ DEV_CONFIG_FULL_PATH,
56
+ KERNEL_APP_ID,
57
+ KERNEL_PUBLIC_KEY
58
+ });
@@ -0,0 +1,9 @@
1
+ declare const CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
2
+ declare const DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
3
+ declare const CONFIG_ORG_REPO = ".ubiquity-os";
4
+
5
+ declare const KERNEL_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3\nuBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7\nU3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+\nI0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf\nwShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/\nPlnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq\nJQIDAQAB\n-----END PUBLIC KEY-----\n";
6
+ declare const KERNEL_APP_ID = 975031;
7
+ declare const BOT_USER_ID = 178941584;
8
+
9
+ export { BOT_USER_ID, CONFIG_FULL_PATH, CONFIG_ORG_REPO, DEV_CONFIG_FULL_PATH, KERNEL_APP_ID, KERNEL_PUBLIC_KEY };
@@ -0,0 +1,9 @@
1
+ declare const CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
2
+ declare const DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
3
+ declare const CONFIG_ORG_REPO = ".ubiquity-os";
4
+
5
+ declare const KERNEL_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3\nuBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7\nU3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+\nI0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf\nwShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/\nPlnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq\nJQIDAQAB\n-----END PUBLIC KEY-----\n";
6
+ declare const KERNEL_APP_ID = 975031;
7
+ declare const BOT_USER_ID = 178941584;
8
+
9
+ export { BOT_USER_ID, CONFIG_FULL_PATH, CONFIG_ORG_REPO, DEV_CONFIG_FULL_PATH, KERNEL_APP_ID, KERNEL_PUBLIC_KEY };
@@ -0,0 +1,26 @@
1
+ // src/types/config.ts
2
+ var CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
3
+ var DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
4
+ var CONFIG_ORG_REPO = ".ubiquity-os";
5
+
6
+ // src/constants.ts
7
+ var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
8
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
9
+ uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
10
+ U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
11
+ I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
12
+ wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
13
+ Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
14
+ JQIDAQAB
15
+ -----END PUBLIC KEY-----
16
+ `;
17
+ var KERNEL_APP_ID = 975031;
18
+ var BOT_USER_ID = 178941584;
19
+ export {
20
+ BOT_USER_ID,
21
+ CONFIG_FULL_PATH,
22
+ CONFIG_ORG_REPO,
23
+ DEV_CONFIG_FULL_PATH,
24
+ KERNEL_APP_ID,
25
+ KERNEL_PUBLIC_KEY
26
+ };
@@ -1,10 +1,48 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ createActionsPlugin: () => createActionsPlugin,
34
+ createPlugin: () => createPlugin,
35
+ postComment: () => postComment
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+
1
39
  // src/server.ts
2
- import { Type as T } from "@sinclair/typebox";
3
- import { Value } from "@sinclair/typebox/value";
4
- import { LOG_LEVEL, LogReturn, Logs } from "@ubiquity-os/ubiquity-os-logger";
5
- import { Hono } from "hono";
6
- import { env as honoEnv } from "hono/adapter";
7
- import { HTTPException } from "hono/http-exception";
40
+ var import_typebox = require("@sinclair/typebox");
41
+ var import_value = require("@sinclair/typebox/value");
42
+ var import_ubiquity_os_logger = require("@ubiquity-os/ubiquity-os-logger");
43
+ var import_hono = require("hono");
44
+ var import_adapter = require("hono/adapter");
45
+ var import_http_exception = require("hono/http-exception");
8
46
 
9
47
  // src/util.ts
10
48
  function sanitizeMetadata(obj) {
@@ -47,11 +85,6 @@ ${metadataSerialized}
47
85
  `;
48
86
  }
49
87
 
50
- // src/types/config.ts
51
- var CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
52
- var DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
53
- var CONFIG_ORG_REPO = ".ubiquity-os";
54
-
55
88
  // src/constants.ts
56
89
  var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
57
90
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
@@ -63,16 +96,14 @@ Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
63
96
  JQIDAQAB
64
97
  -----END PUBLIC KEY-----
65
98
  `;
66
- var KERNEL_APP_ID = 975031;
67
- var BOT_USER_ID = 178941584;
68
99
 
69
100
  // src/octokit.ts
70
- import { Octokit } from "@octokit/core";
71
- import { paginateRest } from "@octokit/plugin-paginate-rest";
72
- import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
73
- import { retry } from "@octokit/plugin-retry";
74
- import { throttling } from "@octokit/plugin-throttling";
75
- import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
101
+ var import_core = require("@octokit/core");
102
+ var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
103
+ var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
104
+ var import_plugin_retry = require("@octokit/plugin-retry");
105
+ var import_plugin_throttling = require("@octokit/plugin-throttling");
106
+ var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
76
107
  var defaultOptions = {
77
108
  throttle: {
78
109
  onAbuseLimit: (retryAfter, options, octokit) => {
@@ -89,7 +120,7 @@ var defaultOptions = {
89
120
  }
90
121
  }
91
122
  };
92
- var customOctokit = Octokit.plugin(throttling, retry, paginateRest, restEndpointMethods, paginateGraphQL).defaults((instanceOptions) => {
123
+ var customOctokit = import_core.Octokit.plugin(import_plugin_throttling.throttling, import_plugin_retry.retry, import_plugin_paginate_rest.paginateRest, import_plugin_rest_endpoint_methods.restEndpointMethods, import_plugin_paginate_graphql.paginateGraphQL).defaults((instanceOptions) => {
93
124
  return { ...defaultOptions, ...instanceOptions };
94
125
  });
95
126
 
@@ -126,60 +157,66 @@ async function verifySignature(publicKeyPem, inputs, signature) {
126
157
  }
127
158
 
128
159
  // src/server.ts
129
- var inputSchema = T.Object({
130
- stateId: T.String(),
131
- eventName: T.String(),
132
- eventPayload: T.Record(T.String(), T.Any()),
133
- authToken: T.String(),
134
- settings: T.Record(T.String(), T.Any()),
135
- ref: T.String(),
136
- signature: T.String()
160
+ var inputSchema = import_typebox.Type.Object({
161
+ stateId: import_typebox.Type.String(),
162
+ eventName: import_typebox.Type.String(),
163
+ eventPayload: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any()),
164
+ authToken: import_typebox.Type.String(),
165
+ settings: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any()),
166
+ ref: import_typebox.Type.String(),
167
+ signature: import_typebox.Type.String(),
168
+ bypassSignatureVerification: import_typebox.Type.Optional(
169
+ import_typebox.Type.Boolean({
170
+ default: false,
171
+ description: "Bypass signature verification (caution: only use this if you know what you're doing)"
172
+ })
173
+ )
137
174
  });
138
175
  function createPlugin(handler, manifest, options) {
139
176
  const pluginOptions = {
140
- kernelPublicKey: options?.kernelPublicKey || KERNEL_PUBLIC_KEY,
141
- logLevel: options?.logLevel || LOG_LEVEL.INFO,
142
- postCommentOnError: options?.postCommentOnError || true,
177
+ kernelPublicKey: options?.kernelPublicKey ?? KERNEL_PUBLIC_KEY,
178
+ logLevel: options?.logLevel ?? import_ubiquity_os_logger.LOG_LEVEL.INFO,
179
+ postCommentOnError: options?.postCommentOnError ?? true,
143
180
  settingsSchema: options?.settingsSchema,
144
181
  envSchema: options?.envSchema
145
182
  };
146
- const app = new Hono();
183
+ const app = new import_hono.Hono();
147
184
  app.get("/manifest.json", (ctx) => {
148
185
  return ctx.json(manifest);
149
186
  });
150
187
  app.post("/", async (ctx) => {
151
188
  if (ctx.req.header("content-type") !== "application/json") {
152
- throw new HTTPException(400, { message: "Content-Type must be application/json" });
189
+ throw new import_http_exception.HTTPException(400, { message: "Content-Type must be application/json" });
153
190
  }
154
191
  const body = await ctx.req.json();
155
- const inputSchemaErrors = [...Value.Errors(inputSchema, body)];
192
+ const inputSchemaErrors = [...import_value.Value.Errors(inputSchema, body)];
156
193
  if (inputSchemaErrors.length) {
157
194
  console.dir(inputSchemaErrors, { depth: null });
158
- throw new HTTPException(400, { message: "Invalid body" });
195
+ throw new import_http_exception.HTTPException(400, { message: "Invalid body" });
159
196
  }
160
- const inputs = Value.Decode(inputSchema, body);
197
+ const inputs = import_value.Value.Decode(inputSchema, body);
161
198
  const signature = inputs.signature;
162
- if (!await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
163
- throw new HTTPException(400, { message: "Invalid signature" });
199
+ if (!options?.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
200
+ throw new import_http_exception.HTTPException(400, { message: "Invalid signature" });
164
201
  }
165
202
  let config2;
166
203
  if (pluginOptions.settingsSchema) {
167
204
  try {
168
- config2 = Value.Decode(pluginOptions.settingsSchema, Value.Default(pluginOptions.settingsSchema, inputs.settings));
205
+ config2 = import_value.Value.Decode(pluginOptions.settingsSchema, import_value.Value.Default(pluginOptions.settingsSchema, inputs.settings));
169
206
  } catch (e) {
170
- console.dir(...Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
207
+ console.dir(...import_value.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
171
208
  throw e;
172
209
  }
173
210
  } else {
174
211
  config2 = inputs.settings;
175
212
  }
176
213
  let env;
177
- const honoEnvironment = honoEnv(ctx);
214
+ const honoEnvironment = (0, import_adapter.env)(ctx);
178
215
  if (pluginOptions.envSchema) {
179
216
  try {
180
- env = Value.Decode(pluginOptions.envSchema, Value.Default(pluginOptions.envSchema, honoEnvironment));
217
+ env = import_value.Value.Decode(pluginOptions.envSchema, import_value.Value.Default(pluginOptions.envSchema, honoEnvironment));
181
218
  } catch (e) {
182
- console.dir(...Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
219
+ console.dir(...import_value.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
183
220
  throw e;
184
221
  }
185
222
  } else {
@@ -191,7 +228,7 @@ function createPlugin(handler, manifest, options) {
191
228
  octokit: new customOctokit({ auth: inputs.authToken }),
192
229
  config: config2,
193
230
  env,
194
- logger: new Logs(pluginOptions.logLevel)
231
+ logger: new import_ubiquity_os_logger.Logs(pluginOptions.logLevel)
195
232
  };
196
233
  try {
197
234
  const result = await handler(context2);
@@ -201,7 +238,7 @@ function createPlugin(handler, manifest, options) {
201
238
  let loggerError;
202
239
  if (error instanceof Error) {
203
240
  loggerError = context2.logger.error(`Error: ${error}`, { error });
204
- } else if (error instanceof LogReturn) {
241
+ } else if (error instanceof import_ubiquity_os_logger.LogReturn) {
205
242
  loggerError = error;
206
243
  } else {
207
244
  loggerError = context2.logger.error(`Error: ${error}`);
@@ -209,36 +246,36 @@ function createPlugin(handler, manifest, options) {
209
246
  if (pluginOptions.postCommentOnError && loggerError) {
210
247
  await postComment(context2, loggerError);
211
248
  }
212
- throw new HTTPException(500, { message: "Unexpected error" });
249
+ throw new import_http_exception.HTTPException(500, { message: "Unexpected error" });
213
250
  }
214
251
  });
215
252
  return app;
216
253
  }
217
254
 
218
255
  // src/actions.ts
219
- import * as core from "@actions/core";
220
- import * as github from "@actions/github";
221
- import { Type as T2 } from "@sinclair/typebox";
222
- import { Value as Value2 } from "@sinclair/typebox/value";
223
- import { LOG_LEVEL as LOG_LEVEL2, LogReturn as LogReturn2, Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
224
- import { config } from "dotenv";
225
- config();
226
- var inputSchema2 = T2.Object({
227
- stateId: T2.String(),
228
- eventName: T2.String(),
229
- eventPayload: T2.String(),
230
- authToken: T2.String(),
231
- settings: T2.String(),
232
- ref: T2.String(),
233
- signature: T2.String()
256
+ var core = __toESM(require("@actions/core"), 1);
257
+ var github = __toESM(require("@actions/github"), 1);
258
+ var import_typebox2 = require("@sinclair/typebox");
259
+ var import_value2 = require("@sinclair/typebox/value");
260
+ var import_ubiquity_os_logger2 = require("@ubiquity-os/ubiquity-os-logger");
261
+ var import_dotenv = require("dotenv");
262
+ (0, import_dotenv.config)();
263
+ var inputSchema2 = import_typebox2.Type.Object({
264
+ stateId: import_typebox2.Type.String(),
265
+ eventName: import_typebox2.Type.String(),
266
+ eventPayload: import_typebox2.Type.String(),
267
+ authToken: import_typebox2.Type.String(),
268
+ settings: import_typebox2.Type.String(),
269
+ ref: import_typebox2.Type.String(),
270
+ signature: import_typebox2.Type.String()
234
271
  });
235
272
  async function createActionsPlugin(handler, options) {
236
273
  const pluginOptions = {
237
- logLevel: options?.logLevel || LOG_LEVEL2.INFO,
238
- postCommentOnError: options?.postCommentOnError || true,
274
+ logLevel: options?.logLevel ?? import_ubiquity_os_logger2.LOG_LEVEL.INFO,
275
+ postCommentOnError: options?.postCommentOnError ?? true,
239
276
  settingsSchema: options?.settingsSchema,
240
277
  envSchema: options?.envSchema,
241
- kernelPublicKey: options?.kernelPublicKey || KERNEL_PUBLIC_KEY
278
+ kernelPublicKey: options?.kernelPublicKey ?? KERNEL_PUBLIC_KEY
242
279
  };
243
280
  const pluginGithubToken = process.env.PLUGIN_GITHUB_TOKEN;
244
281
  if (!pluginGithubToken) {
@@ -246,13 +283,13 @@ async function createActionsPlugin(handler, options) {
246
283
  return;
247
284
  }
248
285
  const inputPayload = github.context.payload.inputs;
249
- const inputSchemaErrors = [...Value2.Errors(inputSchema2, inputPayload)];
286
+ const inputSchemaErrors = [...import_value2.Value.Errors(inputSchema2, inputPayload)];
250
287
  if (inputSchemaErrors.length) {
251
288
  console.dir(inputSchemaErrors, { depth: null });
252
289
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.join(",")}`);
253
290
  return;
254
291
  }
255
- const inputs = Value2.Decode(inputSchema2, inputPayload);
292
+ const inputs = import_value2.Value.Decode(inputSchema2, inputPayload);
256
293
  const signature = inputs.signature;
257
294
  if (!await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
258
295
  core.setFailed(`Error: Invalid signature`);
@@ -261,9 +298,9 @@ async function createActionsPlugin(handler, options) {
261
298
  let config2;
262
299
  if (pluginOptions.settingsSchema) {
263
300
  try {
264
- config2 = Value2.Decode(pluginOptions.settingsSchema, Value2.Default(pluginOptions.settingsSchema, JSON.parse(inputs.settings)));
301
+ config2 = import_value2.Value.Decode(pluginOptions.settingsSchema, import_value2.Value.Default(pluginOptions.settingsSchema, JSON.parse(inputs.settings)));
265
302
  } catch (e) {
266
- console.dir(...Value2.Errors(pluginOptions.settingsSchema, JSON.parse(inputs.settings)), { depth: null });
303
+ console.dir(...import_value2.Value.Errors(pluginOptions.settingsSchema, JSON.parse(inputs.settings)), { depth: null });
267
304
  throw e;
268
305
  }
269
306
  } else {
@@ -272,9 +309,9 @@ async function createActionsPlugin(handler, options) {
272
309
  let env;
273
310
  if (pluginOptions.envSchema) {
274
311
  try {
275
- env = Value2.Decode(pluginOptions.envSchema, Value2.Default(pluginOptions.envSchema, process.env));
312
+ env = import_value2.Value.Decode(pluginOptions.envSchema, import_value2.Value.Default(pluginOptions.envSchema, process.env));
276
313
  } catch (e) {
277
- console.dir(...Value2.Errors(pluginOptions.envSchema, process.env), { depth: null });
314
+ console.dir(...import_value2.Value.Errors(pluginOptions.envSchema, process.env), { depth: null });
278
315
  throw e;
279
316
  }
280
317
  } else {
@@ -286,7 +323,7 @@ async function createActionsPlugin(handler, options) {
286
323
  octokit: new customOctokit({ auth: inputs.authToken }),
287
324
  config: config2,
288
325
  env,
289
- logger: new Logs2(pluginOptions.logLevel)
326
+ logger: new import_ubiquity_os_logger2.Logs(pluginOptions.logLevel)
290
327
  };
291
328
  try {
292
329
  const result = await handler(context2);
@@ -298,7 +335,7 @@ async function createActionsPlugin(handler, options) {
298
335
  if (error instanceof Error) {
299
336
  core.setFailed(error);
300
337
  loggerError = context2.logger.error(`Error: ${error}`, { error });
301
- } else if (error instanceof LogReturn2) {
338
+ } else if (error instanceof import_ubiquity_os_logger2.LogReturn) {
302
339
  core.setFailed(error.logMessage.raw);
303
340
  loggerError = error;
304
341
  } else {
@@ -341,14 +378,9 @@ async function returnDataToKernel(repoToken, stateId, output) {
341
378
  }
342
379
  });
343
380
  }
344
- export {
345
- BOT_USER_ID,
346
- CONFIG_FULL_PATH,
347
- CONFIG_ORG_REPO,
348
- DEV_CONFIG_FULL_PATH,
349
- KERNEL_APP_ID,
350
- KERNEL_PUBLIC_KEY,
381
+ // Annotate the CommonJS export names for ESM import in node:
382
+ 0 && (module.exports = {
351
383
  createActionsPlugin,
352
384
  createPlugin,
353
385
  postComment
354
- };
386
+ });
@@ -0,0 +1,57 @@
1
+ import * as hono_types from 'hono/types';
2
+ import { EmitterWebhookEventName, EmitterWebhookEvent } from '@octokit/webhooks';
3
+ import { TAnySchema } from '@sinclair/typebox';
4
+ import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
5
+ import { Hono } from 'hono';
6
+ import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
7
+ import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-graphql';
8
+ import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
9
+ import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
10
+ import * as _octokit_request_error from '@octokit/request-error';
11
+ import { Octokit } from '@octokit/core';
12
+ import { Manifest } from './manifest.cjs';
13
+
14
+ declare const customOctokit: typeof Octokit & _octokit_core_dist_types_types.Constructor<{
15
+ retry: {
16
+ retryRequest: (error: _octokit_request_error.RequestError, retries: number, retryAfter: number) => _octokit_request_error.RequestError;
17
+ };
18
+ } & {
19
+ paginate: _octokit_plugin_paginate_rest.PaginateInterface;
20
+ } & _octokit_plugin_rest_endpoint_methods.Api & _octokit_plugin_paginate_graphql.paginateGraphQLInterface>;
21
+
22
+ interface Context<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName> {
23
+ eventName: TSupportedEvents;
24
+ payload: {
25
+ [K in TSupportedEvents]: K extends EmitterWebhookEventName ? EmitterWebhookEvent<K> : never;
26
+ }[TSupportedEvents]["payload"];
27
+ octokit: InstanceType<typeof customOctokit>;
28
+ config: TConfig;
29
+ env: TEnv;
30
+ logger: Logs;
31
+ }
32
+
33
+ interface Options$1 {
34
+ kernelPublicKey?: string;
35
+ logLevel?: LogLevel;
36
+ postCommentOnError?: boolean;
37
+ settingsSchema?: TAnySchema;
38
+ envSchema?: TAnySchema;
39
+ bypassSignatureVerification?: boolean;
40
+ }
41
+ declare function createPlugin<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TSupportedEvents>) => Promise<Record<string, unknown> | undefined>, manifest: Manifest, options?: Options$1): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
42
+
43
+ interface Options {
44
+ logLevel?: LogLevel;
45
+ postCommentOnError?: boolean;
46
+ settingsSchema?: TAnySchema;
47
+ envSchema?: TAnySchema;
48
+ kernelPublicKey?: string;
49
+ }
50
+ declare function createActionsPlugin<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TSupportedEvents>) => Promise<Record<string, unknown> | undefined>, options?: Options): Promise<void>;
51
+
52
+ /**
53
+ * Posts a comment on a GitHub issue if the issue exists in the context payload, embedding structured metadata to it.
54
+ */
55
+ declare function postComment(context: Context, message: LogReturn): Promise<void>;
56
+
57
+ export { type Context, createActionsPlugin, createPlugin, postComment };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import { EmitterWebhookEventName, EmitterWebhookEvent } from '@octokit/webhooks';
3
- import * as _sinclair_typebox from '@sinclair/typebox';
4
- import { Static, TAnySchema } from '@sinclair/typebox';
3
+ import { TAnySchema } from '@sinclair/typebox';
5
4
  import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
6
5
  import { Hono } from 'hono';
7
6
  import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
@@ -10,6 +9,7 @@ import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-end
10
9
  import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
11
10
  import * as _octokit_request_error from '@octokit/request-error';
12
11
  import { Octokit } from '@octokit/core';
12
+ import { Manifest } from './manifest.js';
13
13
 
14
14
  declare const customOctokit: typeof Octokit & _octokit_core_dist_types_types.Constructor<{
15
15
  retry: {
@@ -30,24 +30,13 @@ interface Context<TConfig = unknown, TEnv = unknown, TSupportedEvents extends Em
30
30
  logger: Logs;
31
31
  }
32
32
 
33
- declare const manifestSchema: _sinclair_typebox.TObject<{
34
- name: _sinclair_typebox.TString;
35
- description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
36
- commands: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
37
- description: _sinclair_typebox.TString;
38
- "ubiquity:example": _sinclair_typebox.TString;
39
- }>>>;
40
- "ubiquity:listeners": _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"branch_protection_configuration" | "branch_protection_configuration.disabled" | "branch_protection_configuration.enabled" | "branch_protection_rule" | "branch_protection_rule.created" | "branch_protection_rule.deleted" | "branch_protection_rule.edited" | "check_run" | "check_run.completed" | "check_run.created" | "check_run.requested_action" | "check_run.rerequested" | "check_suite" | "check_suite.completed" | "check_suite.requested" | "check_suite.rerequested" | "code_scanning_alert" | "code_scanning_alert.appeared_in_branch" | "code_scanning_alert.closed_by_user" | "code_scanning_alert.created" | "code_scanning_alert.fixed" | "code_scanning_alert.reopened" | "code_scanning_alert.reopened_by_user" | "commit_comment" | "commit_comment.created" | "create" | "custom_property" | "custom_property.created" | "custom_property.deleted" | "custom_property.updated" | "custom_property_values" | "custom_property_values.updated" | "delete" | "dependabot_alert" | "dependabot_alert.auto_dismissed" | "dependabot_alert.auto_reopened" | "dependabot_alert.created" | "dependabot_alert.dismissed" | "dependabot_alert.fixed" | "dependabot_alert.reintroduced" | "dependabot_alert.reopened" | "deploy_key" | "deploy_key.created" | "deploy_key.deleted" | "deployment" | "deployment.created" | "deployment_protection_rule" | "deployment_protection_rule.requested" | "deployment_review" | "deployment_review.approved" | "deployment_review.rejected" | "deployment_review.requested" | "deployment_status" | "deployment_status.created" | "discussion" | "discussion.answered" | "discussion.category_changed" | "discussion.closed" | "discussion.created" | "discussion.deleted" | "discussion.edited" | "discussion.labeled" | "discussion.locked" | "discussion.pinned" | "discussion.reopened" | "discussion.transferred" | "discussion.unanswered" | "discussion.unlabeled" | "discussion.unlocked" | "discussion.unpinned" | "discussion_comment" | "discussion_comment.created" | "discussion_comment.deleted" | "discussion_comment.edited" | "fork" | "github_app_authorization" | "github_app_authorization.revoked" | "gollum" | "installation" | "installation.created" | "installation.deleted" | "installation.new_permissions_accepted" | "installation.suspend" | "installation.unsuspend" | "installation_repositories" | "installation_repositories.added" | "installation_repositories.removed" | "installation_target" | "installation_target.renamed" | "issue_comment" | "issue_comment.created" | "issue_comment.deleted" | "issue_comment.edited" | "issues" | "issues.assigned" | "issues.closed" | "issues.deleted" | "issues.demilestoned" | "issues.edited" | "issues.labeled" | "issues.locked" | "issues.milestoned" | "issues.opened" | "issues.pinned" | "issues.reopened" | "issues.transferred" | "issues.unassigned" | "issues.unlabeled" | "issues.unlocked" | "issues.unpinned" | "label" | "label.created" | "label.deleted" | "label.edited" | "marketplace_purchase" | "marketplace_purchase.cancelled" | "marketplace_purchase.changed" | "marketplace_purchase.pending_change" | "marketplace_purchase.pending_change_cancelled" | "marketplace_purchase.purchased" | "member" | "member.added" | "member.edited" | "member.removed" | "membership" | "membership.added" | "membership.removed" | "merge_group" | "merge_group.checks_requested" | "merge_group.destroyed" | "meta" | "meta.deleted" | "milestone" | "milestone.closed" | "milestone.created" | "milestone.deleted" | "milestone.edited" | "milestone.opened" | "org_block" | "org_block.blocked" | "org_block.unblocked" | "organization" | "organization.deleted" | "organization.member_added" | "organization.member_invited" | "organization.member_removed" | "organization.renamed" | "package" | "package.published" | "package.updated" | "page_build" | "personal_access_token_request" | "personal_access_token_request.approved" | "personal_access_token_request.cancelled" | "personal_access_token_request.created" | "personal_access_token_request.denied" | "ping" | "project" | "project.closed" | "project.created" | "project.deleted" | "project.edited" | "project.reopened" | "project_card" | "project_card.converted" | "project_card.created" | "project_card.deleted" | "project_card.edited" | "project_card.moved" | "project_column" | "project_column.created" | "project_column.deleted" | "project_column.edited" | "project_column.moved" | "projects_v2" | "projects_v2.closed" | "projects_v2.created" | "projects_v2.deleted" | "projects_v2.edited" | "projects_v2.reopened" | "projects_v2_item" | "projects_v2_item.archived" | "projects_v2_item.converted" | "projects_v2_item.created" | "projects_v2_item.deleted" | "projects_v2_item.edited" | "projects_v2_item.reordered" | "projects_v2_item.restored" | "public" | "pull_request" | "pull_request.assigned" | "pull_request.auto_merge_disabled" | "pull_request.auto_merge_enabled" | "pull_request.closed" | "pull_request.converted_to_draft" | "pull_request.demilestoned" | "pull_request.dequeued" | "pull_request.edited" | "pull_request.enqueued" | "pull_request.labeled" | "pull_request.locked" | "pull_request.milestoned" | "pull_request.opened" | "pull_request.ready_for_review" | "pull_request.reopened" | "pull_request.review_request_removed" | "pull_request.review_requested" | "pull_request.synchronize" | "pull_request.unassigned" | "pull_request.unlabeled" | "pull_request.unlocked" | "pull_request_review" | "pull_request_review.dismissed" | "pull_request_review.edited" | "pull_request_review.submitted" | "pull_request_review_comment" | "pull_request_review_comment.created" | "pull_request_review_comment.deleted" | "pull_request_review_comment.edited" | "pull_request_review_thread" | "pull_request_review_thread.resolved" | "pull_request_review_thread.unresolved" | "push" | "registry_package" | "registry_package.published" | "registry_package.updated" | "release" | "release.created" | "release.deleted" | "release.edited" | "release.prereleased" | "release.published" | "release.released" | "release.unpublished" | "repository" | "repository.archived" | "repository.created" | "repository.deleted" | "repository.edited" | "repository.privatized" | "repository.publicized" | "repository.renamed" | "repository.transferred" | "repository.unarchived" | "repository_advisory" | "repository_advisory.published" | "repository_advisory.reported" | "repository_dispatch" | "repository_dispatch.sample.collected" | "repository_import" | "repository_ruleset" | "repository_ruleset.created" | "repository_ruleset.deleted" | "repository_ruleset.edited" | "repository_vulnerability_alert" | "repository_vulnerability_alert.create" | "repository_vulnerability_alert.dismiss" | "repository_vulnerability_alert.reopen" | "repository_vulnerability_alert.resolve" | "secret_scanning_alert" | "secret_scanning_alert.created" | "secret_scanning_alert.reopened" | "secret_scanning_alert.resolved" | "secret_scanning_alert.revoked" | "secret_scanning_alert.validated" | "secret_scanning_alert_location" | "secret_scanning_alert_location.created" | "security_advisory" | "security_advisory.published" | "security_advisory.updated" | "security_advisory.withdrawn" | "security_and_analysis" | "sponsorship" | "sponsorship.cancelled" | "sponsorship.created" | "sponsorship.edited" | "sponsorship.pending_cancellation" | "sponsorship.pending_tier_change" | "sponsorship.tier_changed" | "star" | "star.created" | "star.deleted" | "status" | "team" | "team.added_to_repository" | "team.created" | "team.deleted" | "team.edited" | "team.removed_from_repository" | "team_add" | "watch" | "watch.started" | "workflow_dispatch" | "workflow_job" | "workflow_job.completed" | "workflow_job.in_progress" | "workflow_job.queued" | "workflow_job.waiting" | "workflow_run" | "workflow_run.completed" | "workflow_run.in_progress" | "workflow_run.requested">[]>>>;
41
- configuration: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
42
- }>;
43
- type Manifest = Static<typeof manifestSchema>;
44
-
45
33
  interface Options$1 {
46
34
  kernelPublicKey?: string;
47
35
  logLevel?: LogLevel;
48
36
  postCommentOnError?: boolean;
49
37
  settingsSchema?: TAnySchema;
50
38
  envSchema?: TAnySchema;
39
+ bypassSignatureVerification?: boolean;
51
40
  }
52
41
  declare function createPlugin<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TSupportedEvents>) => Promise<Record<string, unknown> | undefined>, manifest: Manifest, options?: Options$1): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
53
42
 
@@ -65,12 +54,4 @@ declare function createActionsPlugin<TConfig = unknown, TEnv = unknown, TSupport
65
54
  */
66
55
  declare function postComment(context: Context, message: LogReturn): Promise<void>;
67
56
 
68
- declare const CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
69
- declare const DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
70
- declare const CONFIG_ORG_REPO = ".ubiquity-os";
71
-
72
- declare const KERNEL_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3\nuBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7\nU3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+\nI0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf\nwShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/\nPlnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq\nJQIDAQAB\n-----END PUBLIC KEY-----\n";
73
- declare const KERNEL_APP_ID = 975031;
74
- declare const BOT_USER_ID = 178941584;
75
-
76
- export { BOT_USER_ID, CONFIG_FULL_PATH, CONFIG_ORG_REPO, type Context, DEV_CONFIG_FULL_PATH, KERNEL_APP_ID, KERNEL_PUBLIC_KEY, type Manifest, createActionsPlugin, createPlugin, postComment };
57
+ export { type Context, createActionsPlugin, createPlugin, postComment };