@ubiquity-os/plugin-sdk 1.0.11 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,53 +1,48 @@
1
1
  import * as hono_types from 'hono/types';
2
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
3
  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';
4
+ import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
5
+ import { customOctokit } from './octokit.mjs';
12
6
  import { Manifest } from './manifest.mjs';
7
+ import { TAnySchema } from '@sinclair/typebox';
8
+ import '@octokit/core/dist-types/types';
9
+ import '@octokit/plugin-paginate-graphql';
10
+ import '@octokit/plugin-rest-endpoint-methods';
11
+ import '@octokit/plugin-paginate-rest';
12
+ import '@octokit/request-error';
13
+ import '@octokit/core';
13
14
 
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> {
15
+ interface Context<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName> {
23
16
  eventName: TSupportedEvents;
24
17
  payload: {
25
18
  [K in TSupportedEvents]: K extends EmitterWebhookEventName ? EmitterWebhookEvent<K> : never;
26
19
  }[TSupportedEvents]["payload"];
20
+ command: TCommand | null;
27
21
  octokit: InstanceType<typeof customOctokit>;
28
22
  config: TConfig;
29
23
  env: TEnv;
30
24
  logger: Logs;
31
25
  }
32
26
 
33
- interface Options$1 {
27
+ type Return = Record<string, unknown> | undefined | void;
28
+ type HandlerReturn = Promise<Return> | Return;
29
+
30
+ interface Options {
34
31
  kernelPublicKey?: string;
35
32
  logLevel?: LogLevel;
36
33
  postCommentOnError?: boolean;
37
34
  settingsSchema?: TAnySchema;
38
35
  envSchema?: TAnySchema;
36
+ commandSchema?: TAnySchema;
37
+ /**
38
+ * @deprecated This disables signature verification - only for local development
39
+ */
39
40
  bypassSignatureVerification?: boolean;
40
41
  }
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
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>;
43
+ 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, "/">;
44
+
45
+ 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>;
51
46
 
52
47
  /**
53
48
  * Posts a comment on a GitHub issue if the issue exists in the context payload, embedding structured metadata to it.
package/dist/index.d.ts CHANGED
@@ -1,53 +1,48 @@
1
1
  import * as hono_types from 'hono/types';
2
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
3
  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';
4
+ import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
5
+ import { customOctokit } from './octokit.js';
12
6
  import { Manifest } from './manifest.js';
7
+ import { TAnySchema } from '@sinclair/typebox';
8
+ import '@octokit/core/dist-types/types';
9
+ import '@octokit/plugin-paginate-graphql';
10
+ import '@octokit/plugin-rest-endpoint-methods';
11
+ import '@octokit/plugin-paginate-rest';
12
+ import '@octokit/request-error';
13
+ import '@octokit/core';
13
14
 
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> {
15
+ interface Context<TConfig = unknown, TEnv = unknown, TCommand = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName> {
23
16
  eventName: TSupportedEvents;
24
17
  payload: {
25
18
  [K in TSupportedEvents]: K extends EmitterWebhookEventName ? EmitterWebhookEvent<K> : never;
26
19
  }[TSupportedEvents]["payload"];
20
+ command: TCommand | null;
27
21
  octokit: InstanceType<typeof customOctokit>;
28
22
  config: TConfig;
29
23
  env: TEnv;
30
24
  logger: Logs;
31
25
  }
32
26
 
33
- interface Options$1 {
27
+ type Return = Record<string, unknown> | undefined | void;
28
+ type HandlerReturn = Promise<Return> | Return;
29
+
30
+ interface Options {
34
31
  kernelPublicKey?: string;
35
32
  logLevel?: LogLevel;
36
33
  postCommentOnError?: boolean;
37
34
  settingsSchema?: TAnySchema;
38
35
  envSchema?: TAnySchema;
36
+ commandSchema?: TAnySchema;
37
+ /**
38
+ * @deprecated This disables signature verification - only for local development
39
+ */
39
40
  bypassSignatureVerification?: boolean;
40
41
  }
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
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>;
43
+ 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, "/">;
44
+
45
+ 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>;
51
46
 
52
47
  /**
53
48
  * Posts a comment on a GitHub issue if the issue exists in the context payload, embedding structured metadata to it.
package/dist/index.js CHANGED
@@ -39,15 +39,42 @@ module.exports = __toCommonJS(src_exports);
39
39
  // src/server.ts
40
40
  var import_typebox = require("@sinclair/typebox");
41
41
  var import_value = require("@sinclair/typebox/value");
42
- var import_ubiquity_os_logger = require("@ubiquity-os/ubiquity-os-logger");
42
+ var import_ubiquity_os_logger2 = require("@ubiquity-os/ubiquity-os-logger");
43
43
  var import_hono = require("hono");
44
44
  var import_adapter = require("hono/adapter");
45
45
  var import_http_exception = require("hono/http-exception");
46
46
 
47
+ // src/util.ts
48
+ var import_ubiquity_os_logger = require("@ubiquity-os/ubiquity-os-logger");
49
+
50
+ // src/constants.ts
51
+ var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
52
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
53
+ uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
54
+ U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
55
+ I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
56
+ wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
57
+ Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
58
+ JQIDAQAB
59
+ -----END PUBLIC KEY-----
60
+ `;
61
+
47
62
  // src/util.ts
48
63
  function sanitizeMetadata(obj) {
49
64
  return JSON.stringify(obj, null, 2).replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/--/g, "&#45;&#45;");
50
65
  }
66
+ function getPluginOptions(options) {
67
+ return {
68
+ // Important to use || and not ?? to not consider empty strings
69
+ kernelPublicKey: options?.kernelPublicKey || KERNEL_PUBLIC_KEY,
70
+ logLevel: options?.logLevel ?? import_ubiquity_os_logger.LOG_LEVEL.INFO,
71
+ postCommentOnError: options?.postCommentOnError ?? true,
72
+ settingsSchema: options?.settingsSchema,
73
+ envSchema: options?.envSchema,
74
+ commandSchema: options?.commandSchema,
75
+ bypassSignatureVerification: options?.bypassSignatureVerification || false
76
+ };
77
+ }
51
78
 
52
79
  // src/comment.ts
53
80
  var HEADER_NAME = "Ubiquity";
@@ -85,18 +112,6 @@ ${metadataSerialized}
85
112
  `;
86
113
  }
87
114
 
88
- // src/constants.ts
89
- var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
90
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
91
- uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
92
- U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
93
- I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
94
- wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
95
- Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
96
- JQIDAQAB
97
- -----END PUBLIC KEY-----
98
- `;
99
-
100
115
  // src/octokit.ts
101
116
  var import_core = require("@octokit/core");
102
117
  var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
@@ -133,7 +148,8 @@ async function verifySignature(publicKeyPem, inputs, signature) {
133
148
  eventPayload: inputs.eventPayload,
134
149
  settings: inputs.settings,
135
150
  authToken: inputs.authToken,
136
- ref: inputs.ref
151
+ ref: inputs.ref,
152
+ command: inputs.command
137
153
  };
138
154
  const pemContents = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").trim();
139
155
  const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
@@ -161,25 +177,14 @@ var inputSchema = import_typebox.Type.Object({
161
177
  stateId: import_typebox.Type.String(),
162
178
  eventName: import_typebox.Type.String(),
163
179
  eventPayload: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any()),
180
+ command: import_typebox.Type.Union([import_typebox.Type.Null(), import_typebox.Type.Object({ name: import_typebox.Type.String(), parameters: import_typebox.Type.Unknown() })]),
164
181
  authToken: import_typebox.Type.String(),
165
182
  settings: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any()),
166
183
  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
- )
184
+ signature: import_typebox.Type.String()
174
185
  });
175
186
  function createPlugin(handler, manifest, options) {
176
- const pluginOptions = {
177
- kernelPublicKey: options?.kernelPublicKey ?? KERNEL_PUBLIC_KEY,
178
- logLevel: options?.logLevel ?? import_ubiquity_os_logger.LOG_LEVEL.INFO,
179
- postCommentOnError: options?.postCommentOnError ?? true,
180
- settingsSchema: options?.settingsSchema,
181
- envSchema: options?.envSchema
182
- };
187
+ const pluginOptions = getPluginOptions(options);
183
188
  const app = new import_hono.Hono();
184
189
  app.get("/manifest.json", (ctx) => {
185
190
  return ctx.json(manifest);
@@ -191,12 +196,12 @@ function createPlugin(handler, manifest, options) {
191
196
  const body = await ctx.req.json();
192
197
  const inputSchemaErrors = [...import_value.Value.Errors(inputSchema, body)];
193
198
  if (inputSchemaErrors.length) {
194
- console.dir(inputSchemaErrors, { depth: null });
199
+ console.log(inputSchemaErrors, { depth: null });
195
200
  throw new import_http_exception.HTTPException(400, { message: "Invalid body" });
196
201
  }
197
202
  const inputs = import_value.Value.Decode(inputSchema, body);
198
203
  const signature = inputs.signature;
199
- if (!options?.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
204
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
200
205
  throw new import_http_exception.HTTPException(400, { message: "Invalid signature" });
201
206
  }
202
207
  let config2;
@@ -204,7 +209,7 @@ function createPlugin(handler, manifest, options) {
204
209
  try {
205
210
  config2 = import_value.Value.Decode(pluginOptions.settingsSchema, import_value.Value.Default(pluginOptions.settingsSchema, inputs.settings));
206
211
  } catch (e) {
207
- console.dir(...import_value.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
212
+ console.log(...import_value.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
208
213
  throw e;
209
214
  }
210
215
  } else {
@@ -216,29 +221,41 @@ function createPlugin(handler, manifest, options) {
216
221
  try {
217
222
  env = import_value.Value.Decode(pluginOptions.envSchema, import_value.Value.Default(pluginOptions.envSchema, honoEnvironment));
218
223
  } catch (e) {
219
- console.dir(...import_value.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
224
+ console.log(...import_value.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
220
225
  throw e;
221
226
  }
222
227
  } else {
223
228
  env = ctx.env;
224
229
  }
230
+ let command = null;
231
+ if (inputs.command && pluginOptions.commandSchema) {
232
+ try {
233
+ command = import_value.Value.Decode(pluginOptions.commandSchema, import_value.Value.Default(pluginOptions.commandSchema, inputs.command));
234
+ } catch (e) {
235
+ console.log(...import_value.Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
236
+ throw e;
237
+ }
238
+ } else if (inputs.command) {
239
+ command = inputs.command;
240
+ }
225
241
  const context2 = {
226
242
  eventName: inputs.eventName,
227
243
  payload: inputs.eventPayload,
244
+ command,
228
245
  octokit: new customOctokit({ auth: inputs.authToken }),
229
246
  config: config2,
230
247
  env,
231
- logger: new import_ubiquity_os_logger.Logs(pluginOptions.logLevel)
248
+ logger: new import_ubiquity_os_logger2.Logs(pluginOptions.logLevel)
232
249
  };
233
250
  try {
234
251
  const result = await handler(context2);
235
- return ctx.json({ stateId: inputs.stateId, output: result });
252
+ return ctx.json({ stateId: inputs.stateId, output: result ?? {} });
236
253
  } catch (error) {
237
254
  console.error(error);
238
255
  let loggerError;
239
256
  if (error instanceof Error) {
240
257
  loggerError = context2.logger.error(`Error: ${error}`, { error });
241
- } else if (error instanceof import_ubiquity_os_logger.LogReturn) {
258
+ } else if (error instanceof import_ubiquity_os_logger2.LogReturn) {
242
259
  loggerError = error;
243
260
  } else {
244
261
  loggerError = context2.logger.error(`Error: ${error}`);
@@ -255,75 +272,99 @@ function createPlugin(handler, manifest, options) {
255
272
  // src/actions.ts
256
273
  var core = __toESM(require("@actions/core"));
257
274
  var github = __toESM(require("@actions/github"));
275
+ var import_typebox4 = require("@sinclair/typebox");
276
+ var import_value3 = require("@sinclair/typebox/value");
277
+ var import_ubiquity_os_logger3 = require("@ubiquity-os/ubiquity-os-logger");
278
+ var import_dotenv = require("dotenv");
279
+
280
+ // src/types/command.ts
258
281
  var import_typebox2 = require("@sinclair/typebox");
282
+ var commandCallSchema = import_typebox2.Type.Union([import_typebox2.Type.Null(), import_typebox2.Type.Object({ name: import_typebox2.Type.String(), parameters: import_typebox2.Type.Unknown() })]);
283
+
284
+ // src/types/util.ts
285
+ var import_typebox3 = require("@sinclair/typebox");
259
286
  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");
287
+ function jsonType(type) {
288
+ return import_typebox3.Type.Transform(import_typebox3.Type.String()).Decode((value) => {
289
+ const parsed = JSON.parse(value);
290
+ return import_value2.Value.Decode(type, import_value2.Value.Default(type, parsed));
291
+ }).Encode((value) => JSON.stringify(value));
292
+ }
293
+
294
+ // src/actions.ts
262
295
  (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()
296
+ var inputSchema2 = import_typebox4.Type.Object({
297
+ stateId: import_typebox4.Type.String(),
298
+ eventName: import_typebox4.Type.String(),
299
+ eventPayload: jsonType(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Any())),
300
+ command: jsonType(commandCallSchema),
301
+ authToken: import_typebox4.Type.String(),
302
+ settings: jsonType(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Any())),
303
+ ref: import_typebox4.Type.String(),
304
+ signature: import_typebox4.Type.String()
271
305
  });
272
306
  async function createActionsPlugin(handler, options) {
273
- const pluginOptions = {
274
- logLevel: options?.logLevel ?? import_ubiquity_os_logger2.LOG_LEVEL.INFO,
275
- postCommentOnError: options?.postCommentOnError ?? true,
276
- settingsSchema: options?.settingsSchema,
277
- envSchema: options?.envSchema,
278
- kernelPublicKey: options?.kernelPublicKey ?? KERNEL_PUBLIC_KEY
279
- };
307
+ const pluginOptions = getPluginOptions(options);
280
308
  const pluginGithubToken = process.env.PLUGIN_GITHUB_TOKEN;
281
309
  if (!pluginGithubToken) {
282
310
  core.setFailed("Error: PLUGIN_GITHUB_TOKEN env is not set");
283
311
  return;
284
312
  }
313
+ const body = github.context.payload.inputs;
314
+ const signature = body.signature;
315
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
316
+ core.setFailed(`Error: Invalid signature`);
317
+ return;
318
+ }
285
319
  const inputPayload = github.context.payload.inputs;
286
- const inputSchemaErrors = [...import_value2.Value.Errors(inputSchema2, inputPayload)];
320
+ const inputSchemaErrors = [...import_value3.Value.Errors(inputSchema2, inputPayload)];
287
321
  if (inputSchemaErrors.length) {
288
322
  console.dir(inputSchemaErrors, { depth: null });
289
323
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.join(",")}`);
290
324
  return;
291
325
  }
292
- const inputs = import_value2.Value.Decode(inputSchema2, inputPayload);
293
- const signature = inputs.signature;
294
- if (!await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
295
- core.setFailed(`Error: Invalid signature`);
296
- return;
297
- }
326
+ const inputs = import_value3.Value.Decode(inputSchema2, inputPayload);
298
327
  let config2;
299
328
  if (pluginOptions.settingsSchema) {
300
329
  try {
301
- config2 = import_value2.Value.Decode(pluginOptions.settingsSchema, import_value2.Value.Default(pluginOptions.settingsSchema, JSON.parse(inputs.settings)));
330
+ config2 = import_value3.Value.Decode(pluginOptions.settingsSchema, import_value3.Value.Default(pluginOptions.settingsSchema, inputs.settings));
302
331
  } catch (e) {
303
- console.dir(...import_value2.Value.Errors(pluginOptions.settingsSchema, JSON.parse(inputs.settings)), { depth: null });
332
+ console.dir(...import_value3.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
304
333
  throw e;
305
334
  }
306
335
  } else {
307
- config2 = JSON.parse(inputs.settings);
336
+ config2 = inputs.settings;
308
337
  }
309
338
  let env;
310
339
  if (pluginOptions.envSchema) {
311
340
  try {
312
- env = import_value2.Value.Decode(pluginOptions.envSchema, import_value2.Value.Default(pluginOptions.envSchema, process.env));
341
+ env = import_value3.Value.Decode(pluginOptions.envSchema, import_value3.Value.Default(pluginOptions.envSchema, process.env));
313
342
  } catch (e) {
314
- console.dir(...import_value2.Value.Errors(pluginOptions.envSchema, process.env), { depth: null });
343
+ console.dir(...import_value3.Value.Errors(pluginOptions.envSchema, process.env), { depth: null });
315
344
  throw e;
316
345
  }
317
346
  } else {
318
347
  env = process.env;
319
348
  }
349
+ let command = null;
350
+ if (inputs.command && pluginOptions.commandSchema) {
351
+ try {
352
+ command = import_value3.Value.Decode(pluginOptions.commandSchema, import_value3.Value.Default(pluginOptions.commandSchema, inputs.command));
353
+ } catch (e) {
354
+ console.dir(...import_value3.Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
355
+ throw e;
356
+ }
357
+ } else if (inputs.command) {
358
+ command = inputs.command;
359
+ }
320
360
  const context2 = {
321
361
  eventName: inputs.eventName,
322
- payload: JSON.parse(inputs.eventPayload),
362
+ payload: inputs.eventPayload,
363
+ command,
323
364
  octokit: new customOctokit({ auth: inputs.authToken }),
324
365
  config: config2,
325
366
  env,
326
- logger: new import_ubiquity_os_logger2.Logs(pluginOptions.logLevel)
367
+ logger: new import_ubiquity_os_logger3.Logs(pluginOptions.logLevel)
327
368
  };
328
369
  try {
329
370
  const result = await handler(context2);
@@ -335,7 +376,7 @@ async function createActionsPlugin(handler, options) {
335
376
  if (error instanceof Error) {
336
377
  core.setFailed(error);
337
378
  loggerError = context2.logger.error(`Error: ${error}`, { error });
338
- } else if (error instanceof import_ubiquity_os_logger2.LogReturn) {
379
+ } else if (error instanceof import_ubiquity_os_logger3.LogReturn) {
339
380
  core.setFailed(error.logMessage.raw);
340
381
  loggerError = error;
341
382
  } else {
package/dist/index.mjs CHANGED
@@ -1,15 +1,42 @@
1
1
  // src/server.ts
2
2
  import { Type as T } from "@sinclair/typebox";
3
3
  import { Value } from "@sinclair/typebox/value";
4
- import { LOG_LEVEL, LogReturn, Logs } from "@ubiquity-os/ubiquity-os-logger";
4
+ import { LogReturn as LogReturn2, Logs } from "@ubiquity-os/ubiquity-os-logger";
5
5
  import { Hono } from "hono";
6
6
  import { env as honoEnv } from "hono/adapter";
7
7
  import { HTTPException } from "hono/http-exception";
8
8
 
9
+ // src/util.ts
10
+ import { LOG_LEVEL } from "@ubiquity-os/ubiquity-os-logger";
11
+
12
+ // src/constants.ts
13
+ var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
14
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
15
+ uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
16
+ U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
17
+ I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
18
+ wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
19
+ Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
20
+ JQIDAQAB
21
+ -----END PUBLIC KEY-----
22
+ `;
23
+
9
24
  // src/util.ts
10
25
  function sanitizeMetadata(obj) {
11
26
  return JSON.stringify(obj, null, 2).replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/--/g, "&#45;&#45;");
12
27
  }
28
+ function getPluginOptions(options) {
29
+ return {
30
+ // Important to use || and not ?? to not consider empty strings
31
+ kernelPublicKey: options?.kernelPublicKey || KERNEL_PUBLIC_KEY,
32
+ logLevel: options?.logLevel ?? LOG_LEVEL.INFO,
33
+ postCommentOnError: options?.postCommentOnError ?? true,
34
+ settingsSchema: options?.settingsSchema,
35
+ envSchema: options?.envSchema,
36
+ commandSchema: options?.commandSchema,
37
+ bypassSignatureVerification: options?.bypassSignatureVerification || false
38
+ };
39
+ }
13
40
 
14
41
  // src/comment.ts
15
42
  var HEADER_NAME = "Ubiquity";
@@ -47,18 +74,6 @@ ${metadataSerialized}
47
74
  `;
48
75
  }
49
76
 
50
- // src/constants.ts
51
- var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
52
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
53
- uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
54
- U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
55
- I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
56
- wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
57
- Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
58
- JQIDAQAB
59
- -----END PUBLIC KEY-----
60
- `;
61
-
62
77
  // src/octokit.ts
63
78
  import { Octokit } from "@octokit/core";
64
79
  import { paginateRest } from "@octokit/plugin-paginate-rest";
@@ -95,7 +110,8 @@ async function verifySignature(publicKeyPem, inputs, signature) {
95
110
  eventPayload: inputs.eventPayload,
96
111
  settings: inputs.settings,
97
112
  authToken: inputs.authToken,
98
- ref: inputs.ref
113
+ ref: inputs.ref,
114
+ command: inputs.command
99
115
  };
100
116
  const pemContents = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").trim();
101
117
  const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
@@ -123,25 +139,14 @@ var inputSchema = T.Object({
123
139
  stateId: T.String(),
124
140
  eventName: T.String(),
125
141
  eventPayload: T.Record(T.String(), T.Any()),
142
+ command: T.Union([T.Null(), T.Object({ name: T.String(), parameters: T.Unknown() })]),
126
143
  authToken: T.String(),
127
144
  settings: T.Record(T.String(), T.Any()),
128
145
  ref: T.String(),
129
- signature: T.String(),
130
- bypassSignatureVerification: T.Optional(
131
- T.Boolean({
132
- default: false,
133
- description: "Bypass signature verification (caution: only use this if you know what you're doing)"
134
- })
135
- )
146
+ signature: T.String()
136
147
  });
137
148
  function createPlugin(handler, manifest, options) {
138
- const pluginOptions = {
139
- kernelPublicKey: options?.kernelPublicKey ?? KERNEL_PUBLIC_KEY,
140
- logLevel: options?.logLevel ?? LOG_LEVEL.INFO,
141
- postCommentOnError: options?.postCommentOnError ?? true,
142
- settingsSchema: options?.settingsSchema,
143
- envSchema: options?.envSchema
144
- };
149
+ const pluginOptions = getPluginOptions(options);
145
150
  const app = new Hono();
146
151
  app.get("/manifest.json", (ctx) => {
147
152
  return ctx.json(manifest);
@@ -153,12 +158,12 @@ function createPlugin(handler, manifest, options) {
153
158
  const body = await ctx.req.json();
154
159
  const inputSchemaErrors = [...Value.Errors(inputSchema, body)];
155
160
  if (inputSchemaErrors.length) {
156
- console.dir(inputSchemaErrors, { depth: null });
161
+ console.log(inputSchemaErrors, { depth: null });
157
162
  throw new HTTPException(400, { message: "Invalid body" });
158
163
  }
159
164
  const inputs = Value.Decode(inputSchema, body);
160
165
  const signature = inputs.signature;
161
- if (!options?.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
166
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
162
167
  throw new HTTPException(400, { message: "Invalid signature" });
163
168
  }
164
169
  let config2;
@@ -166,7 +171,7 @@ function createPlugin(handler, manifest, options) {
166
171
  try {
167
172
  config2 = Value.Decode(pluginOptions.settingsSchema, Value.Default(pluginOptions.settingsSchema, inputs.settings));
168
173
  } catch (e) {
169
- console.dir(...Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
174
+ console.log(...Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
170
175
  throw e;
171
176
  }
172
177
  } else {
@@ -178,15 +183,27 @@ function createPlugin(handler, manifest, options) {
178
183
  try {
179
184
  env = Value.Decode(pluginOptions.envSchema, Value.Default(pluginOptions.envSchema, honoEnvironment));
180
185
  } catch (e) {
181
- console.dir(...Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
186
+ console.log(...Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
182
187
  throw e;
183
188
  }
184
189
  } else {
185
190
  env = ctx.env;
186
191
  }
192
+ let command = null;
193
+ if (inputs.command && pluginOptions.commandSchema) {
194
+ try {
195
+ command = Value.Decode(pluginOptions.commandSchema, Value.Default(pluginOptions.commandSchema, inputs.command));
196
+ } catch (e) {
197
+ console.log(...Value.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
198
+ throw e;
199
+ }
200
+ } else if (inputs.command) {
201
+ command = inputs.command;
202
+ }
187
203
  const context2 = {
188
204
  eventName: inputs.eventName,
189
205
  payload: inputs.eventPayload,
206
+ command,
190
207
  octokit: new customOctokit({ auth: inputs.authToken }),
191
208
  config: config2,
192
209
  env,
@@ -194,13 +211,13 @@ function createPlugin(handler, manifest, options) {
194
211
  };
195
212
  try {
196
213
  const result = await handler(context2);
197
- return ctx.json({ stateId: inputs.stateId, output: result });
214
+ return ctx.json({ stateId: inputs.stateId, output: result ?? {} });
198
215
  } catch (error) {
199
216
  console.error(error);
200
217
  let loggerError;
201
218
  if (error instanceof Error) {
202
219
  loggerError = context2.logger.error(`Error: ${error}`, { error });
203
- } else if (error instanceof LogReturn) {
220
+ } else if (error instanceof LogReturn2) {
204
221
  loggerError = error;
205
222
  } else {
206
223
  loggerError = context2.logger.error(`Error: ${error}`);
@@ -217,71 +234,95 @@ function createPlugin(handler, manifest, options) {
217
234
  // src/actions.ts
218
235
  import * as core from "@actions/core";
219
236
  import * as github from "@actions/github";
237
+ import { Type as T3 } from "@sinclair/typebox";
238
+ import { Value as Value3 } from "@sinclair/typebox/value";
239
+ import { LogReturn as LogReturn3, Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
240
+ import { config } from "dotenv";
241
+
242
+ // src/types/command.ts
220
243
  import { Type as T2 } from "@sinclair/typebox";
244
+ var commandCallSchema = T2.Union([T2.Null(), T2.Object({ name: T2.String(), parameters: T2.Unknown() })]);
245
+
246
+ // src/types/util.ts
247
+ import { Type } from "@sinclair/typebox";
221
248
  import { Value as Value2 } from "@sinclair/typebox/value";
222
- import { LOG_LEVEL as LOG_LEVEL2, LogReturn as LogReturn2, Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
223
- import { config } from "dotenv";
249
+ function jsonType(type) {
250
+ return Type.Transform(Type.String()).Decode((value) => {
251
+ const parsed = JSON.parse(value);
252
+ return Value2.Decode(type, Value2.Default(type, parsed));
253
+ }).Encode((value) => JSON.stringify(value));
254
+ }
255
+
256
+ // src/actions.ts
224
257
  config();
225
- var inputSchema2 = T2.Object({
226
- stateId: T2.String(),
227
- eventName: T2.String(),
228
- eventPayload: T2.String(),
229
- authToken: T2.String(),
230
- settings: T2.String(),
231
- ref: T2.String(),
232
- signature: T2.String()
258
+ var inputSchema2 = T3.Object({
259
+ stateId: T3.String(),
260
+ eventName: T3.String(),
261
+ eventPayload: jsonType(T3.Record(T3.String(), T3.Any())),
262
+ command: jsonType(commandCallSchema),
263
+ authToken: T3.String(),
264
+ settings: jsonType(T3.Record(T3.String(), T3.Any())),
265
+ ref: T3.String(),
266
+ signature: T3.String()
233
267
  });
234
268
  async function createActionsPlugin(handler, options) {
235
- const pluginOptions = {
236
- logLevel: options?.logLevel ?? LOG_LEVEL2.INFO,
237
- postCommentOnError: options?.postCommentOnError ?? true,
238
- settingsSchema: options?.settingsSchema,
239
- envSchema: options?.envSchema,
240
- kernelPublicKey: options?.kernelPublicKey ?? KERNEL_PUBLIC_KEY
241
- };
269
+ const pluginOptions = getPluginOptions(options);
242
270
  const pluginGithubToken = process.env.PLUGIN_GITHUB_TOKEN;
243
271
  if (!pluginGithubToken) {
244
272
  core.setFailed("Error: PLUGIN_GITHUB_TOKEN env is not set");
245
273
  return;
246
274
  }
275
+ const body = github.context.payload.inputs;
276
+ const signature = body.signature;
277
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
278
+ core.setFailed(`Error: Invalid signature`);
279
+ return;
280
+ }
247
281
  const inputPayload = github.context.payload.inputs;
248
- const inputSchemaErrors = [...Value2.Errors(inputSchema2, inputPayload)];
282
+ const inputSchemaErrors = [...Value3.Errors(inputSchema2, inputPayload)];
249
283
  if (inputSchemaErrors.length) {
250
284
  console.dir(inputSchemaErrors, { depth: null });
251
285
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.join(",")}`);
252
286
  return;
253
287
  }
254
- const inputs = Value2.Decode(inputSchema2, inputPayload);
255
- const signature = inputs.signature;
256
- if (!await verifySignature(pluginOptions.kernelPublicKey, inputs, signature)) {
257
- core.setFailed(`Error: Invalid signature`);
258
- return;
259
- }
288
+ const inputs = Value3.Decode(inputSchema2, inputPayload);
260
289
  let config2;
261
290
  if (pluginOptions.settingsSchema) {
262
291
  try {
263
- config2 = Value2.Decode(pluginOptions.settingsSchema, Value2.Default(pluginOptions.settingsSchema, JSON.parse(inputs.settings)));
292
+ config2 = Value3.Decode(pluginOptions.settingsSchema, Value3.Default(pluginOptions.settingsSchema, inputs.settings));
264
293
  } catch (e) {
265
- console.dir(...Value2.Errors(pluginOptions.settingsSchema, JSON.parse(inputs.settings)), { depth: null });
294
+ console.dir(...Value3.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
266
295
  throw e;
267
296
  }
268
297
  } else {
269
- config2 = JSON.parse(inputs.settings);
298
+ config2 = inputs.settings;
270
299
  }
271
300
  let env;
272
301
  if (pluginOptions.envSchema) {
273
302
  try {
274
- env = Value2.Decode(pluginOptions.envSchema, Value2.Default(pluginOptions.envSchema, process.env));
303
+ env = Value3.Decode(pluginOptions.envSchema, Value3.Default(pluginOptions.envSchema, process.env));
275
304
  } catch (e) {
276
- console.dir(...Value2.Errors(pluginOptions.envSchema, process.env), { depth: null });
305
+ console.dir(...Value3.Errors(pluginOptions.envSchema, process.env), { depth: null });
277
306
  throw e;
278
307
  }
279
308
  } else {
280
309
  env = process.env;
281
310
  }
311
+ let command = null;
312
+ if (inputs.command && pluginOptions.commandSchema) {
313
+ try {
314
+ command = Value3.Decode(pluginOptions.commandSchema, Value3.Default(pluginOptions.commandSchema, inputs.command));
315
+ } catch (e) {
316
+ console.dir(...Value3.Errors(pluginOptions.commandSchema, inputs.command), { depth: null });
317
+ throw e;
318
+ }
319
+ } else if (inputs.command) {
320
+ command = inputs.command;
321
+ }
282
322
  const context2 = {
283
323
  eventName: inputs.eventName,
284
- payload: JSON.parse(inputs.eventPayload),
324
+ payload: inputs.eventPayload,
325
+ command,
285
326
  octokit: new customOctokit({ auth: inputs.authToken }),
286
327
  config: config2,
287
328
  env,
@@ -297,7 +338,7 @@ async function createActionsPlugin(handler, options) {
297
338
  if (error instanceof Error) {
298
339
  core.setFailed(error);
299
340
  loggerError = context2.logger.error(`Error: ${error}`, { error });
300
- } else if (error instanceof LogReturn2) {
341
+ } else if (error instanceof LogReturn3) {
301
342
  core.setFailed(error.logMessage.raw);
302
343
  loggerError = error;
303
344
  } else {
@@ -5,6 +5,7 @@ declare const runEvent: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"bra
5
5
  declare const commandSchema: _sinclair_typebox.TObject<{
6
6
  description: _sinclair_typebox.TString;
7
7
  "ubiquity:example": _sinclair_typebox.TString;
8
+ parameters: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
8
9
  }>;
9
10
  declare const manifestSchema: _sinclair_typebox.TObject<{
10
11
  name: _sinclair_typebox.TString;
@@ -12,9 +13,11 @@ declare const manifestSchema: _sinclair_typebox.TObject<{
12
13
  commands: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
13
14
  description: _sinclair_typebox.TString;
14
15
  "ubiquity:example": _sinclair_typebox.TString;
16
+ parameters: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
15
17
  }>>>;
16
18
  "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">[]>>>;
17
19
  configuration: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
20
+ skipBotEvents: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
18
21
  }>;
19
22
  type Manifest = Static<typeof manifestSchema>;
20
23
 
@@ -5,6 +5,7 @@ declare const runEvent: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"bra
5
5
  declare const commandSchema: _sinclair_typebox.TObject<{
6
6
  description: _sinclair_typebox.TString;
7
7
  "ubiquity:example": _sinclair_typebox.TString;
8
+ parameters: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
8
9
  }>;
9
10
  declare const manifestSchema: _sinclair_typebox.TObject<{
10
11
  name: _sinclair_typebox.TString;
@@ -12,9 +13,11 @@ declare const manifestSchema: _sinclair_typebox.TObject<{
12
13
  commands: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TObject<{
13
14
  description: _sinclair_typebox.TString;
14
15
  "ubiquity:example": _sinclair_typebox.TString;
16
+ parameters: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
15
17
  }>>>;
16
18
  "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">[]>>>;
17
19
  configuration: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
20
+ skipBotEvents: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
18
21
  }>;
19
22
  type Manifest = Static<typeof manifestSchema>;
20
23
 
package/dist/manifest.js CHANGED
@@ -30,14 +30,16 @@ var import_webhooks = require("@octokit/webhooks");
30
30
  var runEvent = import_typebox.Type.Union(import_webhooks.emitterEventNames.map((o) => import_typebox.Type.Literal(o)));
31
31
  var commandSchema = import_typebox.Type.Object({
32
32
  description: import_typebox.Type.String({ minLength: 1 }),
33
- "ubiquity:example": import_typebox.Type.String({ minLength: 1 })
33
+ "ubiquity:example": import_typebox.Type.String({ minLength: 1 }),
34
+ parameters: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any()))
34
35
  });
35
36
  var manifestSchema = import_typebox.Type.Object({
36
37
  name: import_typebox.Type.String({ minLength: 1 }),
37
38
  description: import_typebox.Type.Optional(import_typebox.Type.String({ default: "" })),
38
- commands: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), commandSchema, { default: {} })),
39
+ commands: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String({ pattern: "^[A-Za-z-_]+$" }), commandSchema, { default: {} })),
39
40
  "ubiquity:listeners": import_typebox.Type.Optional(import_typebox.Type.Array(runEvent, { default: [] })),
40
- configuration: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any(), { default: {} }))
41
+ configuration: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any(), { default: {} })),
42
+ skipBotEvents: import_typebox.Type.Optional(import_typebox.Type.Boolean({ default: true }))
41
43
  });
42
44
  // Annotate the CommonJS export names for ESM import in node:
43
45
  0 && (module.exports = {
package/dist/manifest.mjs CHANGED
@@ -4,14 +4,16 @@ import { emitterEventNames } from "@octokit/webhooks";
4
4
  var runEvent = T.Union(emitterEventNames.map((o) => T.Literal(o)));
5
5
  var commandSchema = T.Object({
6
6
  description: T.String({ minLength: 1 }),
7
- "ubiquity:example": T.String({ minLength: 1 })
7
+ "ubiquity:example": T.String({ minLength: 1 }),
8
+ parameters: T.Optional(T.Record(T.String(), T.Any()))
8
9
  });
9
10
  var manifestSchema = T.Object({
10
11
  name: T.String({ minLength: 1 }),
11
12
  description: T.Optional(T.String({ default: "" })),
12
- commands: T.Optional(T.Record(T.String(), commandSchema, { default: {} })),
13
+ commands: T.Optional(T.Record(T.String({ pattern: "^[A-Za-z-_]+$" }), commandSchema, { default: {} })),
13
14
  "ubiquity:listeners": T.Optional(T.Array(runEvent, { default: [] })),
14
- configuration: T.Optional(T.Record(T.String(), T.Any(), { default: {} }))
15
+ configuration: T.Optional(T.Record(T.String(), T.Any(), { default: {} })),
16
+ skipBotEvents: T.Optional(T.Boolean({ default: true }))
15
17
  });
16
18
  export {
17
19
  commandSchema,
@@ -0,0 +1,16 @@
1
+ import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
2
+ import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-graphql';
3
+ import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
4
+ import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
5
+ import * as _octokit_request_error from '@octokit/request-error';
6
+ import { Octokit } from '@octokit/core';
7
+
8
+ declare const customOctokit: typeof Octokit & _octokit_core_dist_types_types.Constructor<{
9
+ retry: {
10
+ retryRequest: (error: _octokit_request_error.RequestError, retries: number, retryAfter: number) => _octokit_request_error.RequestError;
11
+ };
12
+ } & {
13
+ paginate: _octokit_plugin_paginate_rest.PaginateInterface;
14
+ } & _octokit_plugin_rest_endpoint_methods.Api & _octokit_plugin_paginate_graphql.paginateGraphQLInterface>;
15
+
16
+ export { customOctokit };
@@ -0,0 +1,16 @@
1
+ import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
2
+ import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-graphql';
3
+ import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
4
+ import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
5
+ import * as _octokit_request_error from '@octokit/request-error';
6
+ import { Octokit } from '@octokit/core';
7
+
8
+ declare const customOctokit: typeof Octokit & _octokit_core_dist_types_types.Constructor<{
9
+ retry: {
10
+ retryRequest: (error: _octokit_request_error.RequestError, retries: number, retryAfter: number) => _octokit_request_error.RequestError;
11
+ };
12
+ } & {
13
+ paginate: _octokit_plugin_paginate_rest.PaginateInterface;
14
+ } & _octokit_plugin_rest_endpoint_methods.Api & _octokit_plugin_paginate_graphql.paginateGraphQLInterface>;
15
+
16
+ export { customOctokit };
@@ -0,0 +1,54 @@
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/octokit.ts
21
+ var octokit_exports = {};
22
+ __export(octokit_exports, {
23
+ customOctokit: () => customOctokit
24
+ });
25
+ module.exports = __toCommonJS(octokit_exports);
26
+ var import_core = require("@octokit/core");
27
+ var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
28
+ var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
29
+ var import_plugin_retry = require("@octokit/plugin-retry");
30
+ var import_plugin_throttling = require("@octokit/plugin-throttling");
31
+ var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
32
+ var defaultOptions = {
33
+ throttle: {
34
+ onAbuseLimit: (retryAfter, options, octokit) => {
35
+ octokit.log.warn(`Abuse limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
36
+ return true;
37
+ },
38
+ onRateLimit: (retryAfter, options, octokit) => {
39
+ octokit.log.warn(`Rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
40
+ return true;
41
+ },
42
+ onSecondaryRateLimit: (retryAfter, options, octokit) => {
43
+ octokit.log.warn(`Secondary rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
44
+ return true;
45
+ }
46
+ }
47
+ };
48
+ 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) => {
49
+ return { ...defaultOptions, ...instanceOptions };
50
+ });
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ customOctokit
54
+ });
@@ -0,0 +1,29 @@
1
+ // src/octokit.ts
2
+ import { Octokit } from "@octokit/core";
3
+ import { paginateRest } from "@octokit/plugin-paginate-rest";
4
+ import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
5
+ import { retry } from "@octokit/plugin-retry";
6
+ import { throttling } from "@octokit/plugin-throttling";
7
+ import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
8
+ var defaultOptions = {
9
+ throttle: {
10
+ onAbuseLimit: (retryAfter, options, octokit) => {
11
+ octokit.log.warn(`Abuse limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
12
+ return true;
13
+ },
14
+ onRateLimit: (retryAfter, options, octokit) => {
15
+ octokit.log.warn(`Rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
16
+ return true;
17
+ },
18
+ onSecondaryRateLimit: (retryAfter, options, octokit) => {
19
+ octokit.log.warn(`Secondary rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
20
+ return true;
21
+ }
22
+ }
23
+ };
24
+ var customOctokit = Octokit.plugin(throttling, retry, paginateRest, restEndpointMethods, paginateGraphQL).defaults((instanceOptions) => {
25
+ return { ...defaultOptions, ...instanceOptions };
26
+ });
27
+ export {
28
+ customOctokit
29
+ };
@@ -5,6 +5,7 @@ interface Inputs {
5
5
  authToken: unknown;
6
6
  settings: unknown;
7
7
  ref: unknown;
8
+ command: unknown;
8
9
  }
9
10
  declare function verifySignature(publicKeyPem: string, inputs: Inputs, signature: string): Promise<boolean>;
10
11
  declare function signPayload(payload: string, privateKey: string): Promise<string>;
@@ -5,6 +5,7 @@ interface Inputs {
5
5
  authToken: unknown;
6
6
  settings: unknown;
7
7
  ref: unknown;
8
+ command: unknown;
8
9
  }
9
10
  declare function verifySignature(publicKeyPem: string, inputs: Inputs, signature: string): Promise<boolean>;
10
11
  declare function signPayload(payload: string, privateKey: string): Promise<string>;
package/dist/signature.js CHANGED
@@ -32,7 +32,8 @@ async function verifySignature(publicKeyPem, inputs, signature) {
32
32
  eventPayload: inputs.eventPayload,
33
33
  settings: inputs.settings,
34
34
  authToken: inputs.authToken,
35
- ref: inputs.ref
35
+ ref: inputs.ref,
36
+ command: inputs.command
36
37
  };
37
38
  const pemContents = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").trim();
38
39
  const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
@@ -7,7 +7,8 @@ async function verifySignature(publicKeyPem, inputs, signature) {
7
7
  eventPayload: inputs.eventPayload,
8
8
  settings: inputs.settings,
9
9
  authToken: inputs.authToken,
10
- ref: inputs.ref
10
+ ref: inputs.ref,
11
+ command: inputs.command
11
12
  };
12
13
  const pemContents = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").trim();
13
14
  const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubiquity-os/plugin-sdk",
3
- "version": "1.0.11",
3
+ "version": "1.1.1",
4
4
  "description": "SDK for plugin support.",
5
5
  "author": "Ubiquity DAO",
6
6
  "license": "MIT",
@@ -21,6 +21,9 @@
21
21
  ],
22
22
  "signature": [
23
23
  "dist/signature.d.ts"
24
+ ],
25
+ "octokit": [
26
+ "dist/octokit.d.ts"
24
27
  ]
25
28
  }
26
29
  },
@@ -44,6 +47,11 @@
44
47
  "types": "./dist/signature.d.ts",
45
48
  "import": "./dist/signature.mjs",
46
49
  "require": "./dist/signature.js"
50
+ },
51
+ "./octokit": {
52
+ "types": "./dist/octokit.d.ts",
53
+ "import": "./dist/octokit.mjs",
54
+ "require": "./dist/octokit.js"
47
55
  }
48
56
  },
49
57
  "files": [
@@ -79,11 +87,13 @@
79
87
  "@octokit/rest": "^21.0.2",
80
88
  "@octokit/types": "^13.6.1",
81
89
  "@octokit/webhooks": "^13.3.0",
82
- "@sinclair/typebox": "^0.33.21",
83
90
  "@ubiquity-os/ubiquity-os-logger": "^1.3.2",
84
91
  "dotenv": "^16.4.5",
85
92
  "hono": "^4.6.9"
86
93
  },
94
+ "peerDependencies": {
95
+ "@sinclair/typebox": "0.34.3"
96
+ },
87
97
  "devDependencies": {
88
98
  "@commitlint/cli": "^18.6.1",
89
99
  "@commitlint/config-conventional": "^18.6.2",