@ubiquity-os/plugin-sdk 3.12.2 → 3.12.5
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/configuration.js +5 -0
- package/dist/configuration.mjs +5 -0
- package/dist/index.js +107 -1
- package/dist/index.mjs +107 -1
- package/dist/manifest.d.mts +4 -1
- package/dist/manifest.d.ts +4 -1
- package/dist/manifest.js +77 -0
- package/dist/manifest.mjs +76 -0
- package/package.json +1 -1
package/dist/configuration.js
CHANGED
|
@@ -104,6 +104,11 @@ function normalizeBaseUrl(baseUrl) {
|
|
|
104
104
|
// src/types/manifest.ts
|
|
105
105
|
var import_typebox2 = require("@sinclair/typebox");
|
|
106
106
|
var import_webhooks2 = require("@octokit/webhooks");
|
|
107
|
+
|
|
108
|
+
// src/helpers/runtime-manifest.ts
|
|
109
|
+
var EMPTY_VALUE = String();
|
|
110
|
+
|
|
111
|
+
// src/types/manifest.ts
|
|
107
112
|
var runEvent = import_typebox2.Type.Union(import_webhooks2.emitterEventNames.map((o) => import_typebox2.Type.Literal(o)));
|
|
108
113
|
var exampleCommandExecutionSchema = import_typebox2.Type.Object({
|
|
109
114
|
commandInvocation: import_typebox2.Type.String({ minLength: 1 }),
|
package/dist/configuration.mjs
CHANGED
|
@@ -65,6 +65,11 @@ function normalizeBaseUrl(baseUrl) {
|
|
|
65
65
|
// src/types/manifest.ts
|
|
66
66
|
import { Type as T2 } from "@sinclair/typebox";
|
|
67
67
|
import { emitterEventNames as emitterEventNames2 } from "@octokit/webhooks";
|
|
68
|
+
|
|
69
|
+
// src/helpers/runtime-manifest.ts
|
|
70
|
+
var EMPTY_VALUE = String();
|
|
71
|
+
|
|
72
|
+
// src/types/manifest.ts
|
|
68
73
|
var runEvent = T2.Union(emitterEventNames2.map((o) => T2.Literal(o)));
|
|
69
74
|
var exampleCommandExecutionSchema = T2.Object({
|
|
70
75
|
commandInvocation: T2.String({ minLength: 1 }),
|
package/dist/index.js
CHANGED
|
@@ -853,6 +853,112 @@ var import_ubiquity_os_logger4 = require("@ubiquity-os/ubiquity-os-logger");
|
|
|
853
853
|
var import_hono = require("hono");
|
|
854
854
|
var import_adapter2 = require("hono/adapter");
|
|
855
855
|
var import_http_exception = require("hono/http-exception");
|
|
856
|
+
|
|
857
|
+
// src/types/manifest.ts
|
|
858
|
+
var import_typebox4 = require("@sinclair/typebox");
|
|
859
|
+
var import_webhooks = require("@octokit/webhooks");
|
|
860
|
+
|
|
861
|
+
// src/helpers/runtime-manifest.ts
|
|
862
|
+
var EMPTY_VALUE = String();
|
|
863
|
+
var GITHUB_HEADS_PREFIX = "refs/heads/";
|
|
864
|
+
var GITHUB_TAGS_PREFIX = "refs/tags/";
|
|
865
|
+
function readRuntimeEnvValue(env, key) {
|
|
866
|
+
const explicitValue = env?.[key];
|
|
867
|
+
if (typeof explicitValue === "string" && explicitValue.trim()) {
|
|
868
|
+
return explicitValue.trim();
|
|
869
|
+
}
|
|
870
|
+
const runtime = globalThis;
|
|
871
|
+
if (typeof runtime.Deno?.env?.get === "function") {
|
|
872
|
+
const denoValue = runtime.Deno.env.get(key);
|
|
873
|
+
if (typeof denoValue === "string" && denoValue.trim()) {
|
|
874
|
+
return denoValue.trim();
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (typeof process !== "undefined") {
|
|
878
|
+
const processValue = process.env[key];
|
|
879
|
+
if (typeof processValue === "string" && processValue.trim()) {
|
|
880
|
+
return processValue.trim();
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return EMPTY_VALUE;
|
|
884
|
+
}
|
|
885
|
+
function parseRefNameFromGitHubRef(ref) {
|
|
886
|
+
if (!ref) {
|
|
887
|
+
return EMPTY_VALUE;
|
|
888
|
+
}
|
|
889
|
+
if (ref.startsWith(GITHUB_HEADS_PREFIX)) {
|
|
890
|
+
return ref.slice(GITHUB_HEADS_PREFIX.length);
|
|
891
|
+
}
|
|
892
|
+
if (ref.startsWith(GITHUB_TAGS_PREFIX)) {
|
|
893
|
+
return ref.slice(GITHUB_TAGS_PREFIX.length);
|
|
894
|
+
}
|
|
895
|
+
return EMPTY_VALUE;
|
|
896
|
+
}
|
|
897
|
+
function overrideShortName(shortName, refName) {
|
|
898
|
+
if (!shortName || !refName) {
|
|
899
|
+
return shortName;
|
|
900
|
+
}
|
|
901
|
+
const separatorIndex = shortName.lastIndexOf("@");
|
|
902
|
+
const repository = separatorIndex === -1 ? shortName : shortName.slice(0, separatorIndex);
|
|
903
|
+
if (!repository) {
|
|
904
|
+
return shortName;
|
|
905
|
+
}
|
|
906
|
+
return `${repository}@${refName}`;
|
|
907
|
+
}
|
|
908
|
+
function resolveRuntimeRefName(env) {
|
|
909
|
+
const explicitRefName = readRuntimeEnvValue(env, "REF_NAME");
|
|
910
|
+
if (explicitRefName) {
|
|
911
|
+
return explicitRefName;
|
|
912
|
+
}
|
|
913
|
+
const legacyManifestRefName = readRuntimeEnvValue(env, "PLUGIN_MANIFEST_REF_NAME");
|
|
914
|
+
if (legacyManifestRefName) {
|
|
915
|
+
return legacyManifestRefName;
|
|
916
|
+
}
|
|
917
|
+
const githubRefName = readRuntimeEnvValue(env, "GITHUB_REF_NAME");
|
|
918
|
+
if (githubRefName) {
|
|
919
|
+
return githubRefName;
|
|
920
|
+
}
|
|
921
|
+
return parseRefNameFromGitHubRef(readRuntimeEnvValue(env, "GITHUB_REF"));
|
|
922
|
+
}
|
|
923
|
+
function resolveRuntimeManifest(manifest, env) {
|
|
924
|
+
const refName = resolveRuntimeRefName(env);
|
|
925
|
+
if (!refName) {
|
|
926
|
+
return manifest;
|
|
927
|
+
}
|
|
928
|
+
return {
|
|
929
|
+
...manifest,
|
|
930
|
+
short_name: overrideShortName(manifest.short_name, refName)
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/types/manifest.ts
|
|
935
|
+
var runEvent = import_typebox4.Type.Union(import_webhooks.emitterEventNames.map((o) => import_typebox4.Type.Literal(o)));
|
|
936
|
+
var exampleCommandExecutionSchema = import_typebox4.Type.Object({
|
|
937
|
+
commandInvocation: import_typebox4.Type.String({ minLength: 1 }),
|
|
938
|
+
githubContext: import_typebox4.Type.Optional(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Any())),
|
|
939
|
+
expectedToolCallResult: import_typebox4.Type.Object({
|
|
940
|
+
function: import_typebox4.Type.String({ minLength: 1 }),
|
|
941
|
+
parameters: import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Any())
|
|
942
|
+
})
|
|
943
|
+
});
|
|
944
|
+
var commandSchema = import_typebox4.Type.Object({
|
|
945
|
+
description: import_typebox4.Type.String({ minLength: 1 }),
|
|
946
|
+
"ubiquity:example": import_typebox4.Type.String({ minLength: 1 }),
|
|
947
|
+
parameters: import_typebox4.Type.Optional(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Any())),
|
|
948
|
+
examples: import_typebox4.Type.Optional(import_typebox4.Type.Array(exampleCommandExecutionSchema, { default: [] }))
|
|
949
|
+
});
|
|
950
|
+
var manifestSchema = import_typebox4.Type.Object({
|
|
951
|
+
name: import_typebox4.Type.String({ minLength: 1 }),
|
|
952
|
+
short_name: import_typebox4.Type.String({ minLength: 1 }),
|
|
953
|
+
description: import_typebox4.Type.Optional(import_typebox4.Type.String({ default: "" })),
|
|
954
|
+
commands: import_typebox4.Type.Optional(import_typebox4.Type.Record(import_typebox4.Type.String({ pattern: "^[A-Za-z-_]+$" }), commandSchema, { default: {} })),
|
|
955
|
+
"ubiquity:listeners": import_typebox4.Type.Optional(import_typebox4.Type.Array(runEvent, { default: [] })),
|
|
956
|
+
configuration: import_typebox4.Type.Optional(import_typebox4.Type.Record(import_typebox4.Type.String(), import_typebox4.Type.Any(), { default: {} })),
|
|
957
|
+
skipBotEvents: import_typebox4.Type.Optional(import_typebox4.Type.Boolean({ default: true })),
|
|
958
|
+
homepage_url: import_typebox4.Type.Optional(import_typebox4.Type.String())
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
// src/server.ts
|
|
856
962
|
async function handleError2(context, pluginOptions, error) {
|
|
857
963
|
console.error(error);
|
|
858
964
|
const loggerError = transformError(context, error);
|
|
@@ -865,7 +971,7 @@ function createPlugin(handler, manifest, options) {
|
|
|
865
971
|
const pluginOptions = getPluginOptions(options);
|
|
866
972
|
const app = new import_hono.Hono();
|
|
867
973
|
app.get("/manifest.json", (ctx) => {
|
|
868
|
-
return ctx.json(manifest);
|
|
974
|
+
return ctx.json(resolveRuntimeManifest(manifest, (0, import_adapter2.env)(ctx)));
|
|
869
975
|
});
|
|
870
976
|
app.post("/", async function appPost(ctx) {
|
|
871
977
|
if (ctx.req.header("content-type") !== "application/json") {
|
package/dist/index.mjs
CHANGED
|
@@ -812,6 +812,112 @@ import { Logs as Logs2 } from "@ubiquity-os/ubiquity-os-logger";
|
|
|
812
812
|
import { Hono } from "hono";
|
|
813
813
|
import { env as honoEnv } from "hono/adapter";
|
|
814
814
|
import { HTTPException } from "hono/http-exception";
|
|
815
|
+
|
|
816
|
+
// src/types/manifest.ts
|
|
817
|
+
import { Type as T3 } from "@sinclair/typebox";
|
|
818
|
+
import { emitterEventNames } from "@octokit/webhooks";
|
|
819
|
+
|
|
820
|
+
// src/helpers/runtime-manifest.ts
|
|
821
|
+
var EMPTY_VALUE = String();
|
|
822
|
+
var GITHUB_HEADS_PREFIX = "refs/heads/";
|
|
823
|
+
var GITHUB_TAGS_PREFIX = "refs/tags/";
|
|
824
|
+
function readRuntimeEnvValue(env, key) {
|
|
825
|
+
const explicitValue = env?.[key];
|
|
826
|
+
if (typeof explicitValue === "string" && explicitValue.trim()) {
|
|
827
|
+
return explicitValue.trim();
|
|
828
|
+
}
|
|
829
|
+
const runtime = globalThis;
|
|
830
|
+
if (typeof runtime.Deno?.env?.get === "function") {
|
|
831
|
+
const denoValue = runtime.Deno.env.get(key);
|
|
832
|
+
if (typeof denoValue === "string" && denoValue.trim()) {
|
|
833
|
+
return denoValue.trim();
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
if (typeof process !== "undefined") {
|
|
837
|
+
const processValue = process.env[key];
|
|
838
|
+
if (typeof processValue === "string" && processValue.trim()) {
|
|
839
|
+
return processValue.trim();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return EMPTY_VALUE;
|
|
843
|
+
}
|
|
844
|
+
function parseRefNameFromGitHubRef(ref) {
|
|
845
|
+
if (!ref) {
|
|
846
|
+
return EMPTY_VALUE;
|
|
847
|
+
}
|
|
848
|
+
if (ref.startsWith(GITHUB_HEADS_PREFIX)) {
|
|
849
|
+
return ref.slice(GITHUB_HEADS_PREFIX.length);
|
|
850
|
+
}
|
|
851
|
+
if (ref.startsWith(GITHUB_TAGS_PREFIX)) {
|
|
852
|
+
return ref.slice(GITHUB_TAGS_PREFIX.length);
|
|
853
|
+
}
|
|
854
|
+
return EMPTY_VALUE;
|
|
855
|
+
}
|
|
856
|
+
function overrideShortName(shortName, refName) {
|
|
857
|
+
if (!shortName || !refName) {
|
|
858
|
+
return shortName;
|
|
859
|
+
}
|
|
860
|
+
const separatorIndex = shortName.lastIndexOf("@");
|
|
861
|
+
const repository = separatorIndex === -1 ? shortName : shortName.slice(0, separatorIndex);
|
|
862
|
+
if (!repository) {
|
|
863
|
+
return shortName;
|
|
864
|
+
}
|
|
865
|
+
return `${repository}@${refName}`;
|
|
866
|
+
}
|
|
867
|
+
function resolveRuntimeRefName(env) {
|
|
868
|
+
const explicitRefName = readRuntimeEnvValue(env, "REF_NAME");
|
|
869
|
+
if (explicitRefName) {
|
|
870
|
+
return explicitRefName;
|
|
871
|
+
}
|
|
872
|
+
const legacyManifestRefName = readRuntimeEnvValue(env, "PLUGIN_MANIFEST_REF_NAME");
|
|
873
|
+
if (legacyManifestRefName) {
|
|
874
|
+
return legacyManifestRefName;
|
|
875
|
+
}
|
|
876
|
+
const githubRefName = readRuntimeEnvValue(env, "GITHUB_REF_NAME");
|
|
877
|
+
if (githubRefName) {
|
|
878
|
+
return githubRefName;
|
|
879
|
+
}
|
|
880
|
+
return parseRefNameFromGitHubRef(readRuntimeEnvValue(env, "GITHUB_REF"));
|
|
881
|
+
}
|
|
882
|
+
function resolveRuntimeManifest(manifest, env) {
|
|
883
|
+
const refName = resolveRuntimeRefName(env);
|
|
884
|
+
if (!refName) {
|
|
885
|
+
return manifest;
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
...manifest,
|
|
889
|
+
short_name: overrideShortName(manifest.short_name, refName)
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// src/types/manifest.ts
|
|
894
|
+
var runEvent = T3.Union(emitterEventNames.map((o) => T3.Literal(o)));
|
|
895
|
+
var exampleCommandExecutionSchema = T3.Object({
|
|
896
|
+
commandInvocation: T3.String({ minLength: 1 }),
|
|
897
|
+
githubContext: T3.Optional(T3.Record(T3.String(), T3.Any())),
|
|
898
|
+
expectedToolCallResult: T3.Object({
|
|
899
|
+
function: T3.String({ minLength: 1 }),
|
|
900
|
+
parameters: T3.Record(T3.String(), T3.Any())
|
|
901
|
+
})
|
|
902
|
+
});
|
|
903
|
+
var commandSchema = T3.Object({
|
|
904
|
+
description: T3.String({ minLength: 1 }),
|
|
905
|
+
"ubiquity:example": T3.String({ minLength: 1 }),
|
|
906
|
+
parameters: T3.Optional(T3.Record(T3.String(), T3.Any())),
|
|
907
|
+
examples: T3.Optional(T3.Array(exampleCommandExecutionSchema, { default: [] }))
|
|
908
|
+
});
|
|
909
|
+
var manifestSchema = T3.Object({
|
|
910
|
+
name: T3.String({ minLength: 1 }),
|
|
911
|
+
short_name: T3.String({ minLength: 1 }),
|
|
912
|
+
description: T3.Optional(T3.String({ default: "" })),
|
|
913
|
+
commands: T3.Optional(T3.Record(T3.String({ pattern: "^[A-Za-z-_]+$" }), commandSchema, { default: {} })),
|
|
914
|
+
"ubiquity:listeners": T3.Optional(T3.Array(runEvent, { default: [] })),
|
|
915
|
+
configuration: T3.Optional(T3.Record(T3.String(), T3.Any(), { default: {} })),
|
|
916
|
+
skipBotEvents: T3.Optional(T3.Boolean({ default: true })),
|
|
917
|
+
homepage_url: T3.Optional(T3.String())
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
// src/server.ts
|
|
815
921
|
async function handleError2(context, pluginOptions, error) {
|
|
816
922
|
console.error(error);
|
|
817
923
|
const loggerError = transformError(context, error);
|
|
@@ -824,7 +930,7 @@ function createPlugin(handler, manifest, options) {
|
|
|
824
930
|
const pluginOptions = getPluginOptions(options);
|
|
825
931
|
const app = new Hono();
|
|
826
932
|
app.get("/manifest.json", (ctx) => {
|
|
827
|
-
return ctx.json(manifest);
|
|
933
|
+
return ctx.json(resolveRuntimeManifest(manifest, honoEnv(ctx)));
|
|
828
934
|
});
|
|
829
935
|
app.post("/", async function appPost(ctx) {
|
|
830
936
|
if (ctx.req.header("content-type") !== "application/json") {
|
package/dist/manifest.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
2
|
import { Static } from '@sinclair/typebox';
|
|
3
3
|
|
|
4
|
+
type RuntimeManifestEnv = Record<string, unknown>;
|
|
5
|
+
declare function resolveRuntimeManifest(manifest: Manifest, env?: RuntimeManifestEnv): Manifest;
|
|
6
|
+
|
|
4
7
|
declare const runEvent: _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.promote_to_enterprise" | "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" | "issue_dependencies" | "issue_dependencies.blocked_by_added" | "issue_dependencies.blocked_by_removed" | "issue_dependencies.blocking_added" | "issue_dependencies.blocking_removed" | "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.typed" | "issues.unassigned" | "issues.unlabeled" | "issues.unlocked" | "issues.unpinned" | "issues.untyped" | "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" | "projects_v2_status_update" | "projects_v2_status_update.created" | "projects_v2_status_update.deleted" | "projects_v2_status_update.edited" | "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.assigned" | "secret_scanning_alert.created" | "secret_scanning_alert.publicly_leaked" | "secret_scanning_alert.reopened" | "secret_scanning_alert.resolved" | "secret_scanning_alert.unassigned" | "secret_scanning_alert.validated" | "secret_scanning_alert_location" | "secret_scanning_alert_location.created" | "secret_scanning_scan" | "secret_scanning_scan.completed" | "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" | "sub_issues" | "sub_issues.parent_issue_added" | "sub_issues.parent_issue_removed" | "sub_issues.sub_issue_added" | "sub_issues.sub_issue_removed" | "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">[]>;
|
|
5
8
|
declare const exampleCommandExecutionSchema: _sinclair_typebox.TObject<{
|
|
6
9
|
commandInvocation: _sinclair_typebox.TString;
|
|
@@ -47,4 +50,4 @@ declare const manifestSchema: _sinclair_typebox.TObject<{
|
|
|
47
50
|
}>;
|
|
48
51
|
type Manifest = Static<typeof manifestSchema>;
|
|
49
52
|
|
|
50
|
-
export { type Manifest, commandSchema, exampleCommandExecutionSchema, manifestSchema, runEvent };
|
|
53
|
+
export { type Manifest, commandSchema, exampleCommandExecutionSchema, manifestSchema, resolveRuntimeManifest, runEvent };
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
2
|
import { Static } from '@sinclair/typebox';
|
|
3
3
|
|
|
4
|
+
type RuntimeManifestEnv = Record<string, unknown>;
|
|
5
|
+
declare function resolveRuntimeManifest(manifest: Manifest, env?: RuntimeManifestEnv): Manifest;
|
|
6
|
+
|
|
4
7
|
declare const runEvent: _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.promote_to_enterprise" | "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" | "issue_dependencies" | "issue_dependencies.blocked_by_added" | "issue_dependencies.blocked_by_removed" | "issue_dependencies.blocking_added" | "issue_dependencies.blocking_removed" | "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.typed" | "issues.unassigned" | "issues.unlabeled" | "issues.unlocked" | "issues.unpinned" | "issues.untyped" | "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" | "projects_v2_status_update" | "projects_v2_status_update.created" | "projects_v2_status_update.deleted" | "projects_v2_status_update.edited" | "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.assigned" | "secret_scanning_alert.created" | "secret_scanning_alert.publicly_leaked" | "secret_scanning_alert.reopened" | "secret_scanning_alert.resolved" | "secret_scanning_alert.unassigned" | "secret_scanning_alert.validated" | "secret_scanning_alert_location" | "secret_scanning_alert_location.created" | "secret_scanning_scan" | "secret_scanning_scan.completed" | "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" | "sub_issues" | "sub_issues.parent_issue_added" | "sub_issues.parent_issue_removed" | "sub_issues.sub_issue_added" | "sub_issues.sub_issue_removed" | "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">[]>;
|
|
5
8
|
declare const exampleCommandExecutionSchema: _sinclair_typebox.TObject<{
|
|
6
9
|
commandInvocation: _sinclair_typebox.TString;
|
|
@@ -47,4 +50,4 @@ declare const manifestSchema: _sinclair_typebox.TObject<{
|
|
|
47
50
|
}>;
|
|
48
51
|
type Manifest = Static<typeof manifestSchema>;
|
|
49
52
|
|
|
50
|
-
export { type Manifest, commandSchema, exampleCommandExecutionSchema, manifestSchema, runEvent };
|
|
53
|
+
export { type Manifest, commandSchema, exampleCommandExecutionSchema, manifestSchema, resolveRuntimeManifest, runEvent };
|
package/dist/manifest.js
CHANGED
|
@@ -23,11 +23,87 @@ __export(manifest_exports, {
|
|
|
23
23
|
commandSchema: () => commandSchema,
|
|
24
24
|
exampleCommandExecutionSchema: () => exampleCommandExecutionSchema,
|
|
25
25
|
manifestSchema: () => manifestSchema,
|
|
26
|
+
resolveRuntimeManifest: () => resolveRuntimeManifest,
|
|
26
27
|
runEvent: () => runEvent
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(manifest_exports);
|
|
29
30
|
var import_typebox = require("@sinclair/typebox");
|
|
30
31
|
var import_webhooks = require("@octokit/webhooks");
|
|
32
|
+
|
|
33
|
+
// src/helpers/runtime-manifest.ts
|
|
34
|
+
var EMPTY_VALUE = String();
|
|
35
|
+
var GITHUB_HEADS_PREFIX = "refs/heads/";
|
|
36
|
+
var GITHUB_TAGS_PREFIX = "refs/tags/";
|
|
37
|
+
function readRuntimeEnvValue(env, key) {
|
|
38
|
+
const explicitValue = env?.[key];
|
|
39
|
+
if (typeof explicitValue === "string" && explicitValue.trim()) {
|
|
40
|
+
return explicitValue.trim();
|
|
41
|
+
}
|
|
42
|
+
const runtime = globalThis;
|
|
43
|
+
if (typeof runtime.Deno?.env?.get === "function") {
|
|
44
|
+
const denoValue = runtime.Deno.env.get(key);
|
|
45
|
+
if (typeof denoValue === "string" && denoValue.trim()) {
|
|
46
|
+
return denoValue.trim();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (typeof process !== "undefined") {
|
|
50
|
+
const processValue = process.env[key];
|
|
51
|
+
if (typeof processValue === "string" && processValue.trim()) {
|
|
52
|
+
return processValue.trim();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return EMPTY_VALUE;
|
|
56
|
+
}
|
|
57
|
+
function parseRefNameFromGitHubRef(ref) {
|
|
58
|
+
if (!ref) {
|
|
59
|
+
return EMPTY_VALUE;
|
|
60
|
+
}
|
|
61
|
+
if (ref.startsWith(GITHUB_HEADS_PREFIX)) {
|
|
62
|
+
return ref.slice(GITHUB_HEADS_PREFIX.length);
|
|
63
|
+
}
|
|
64
|
+
if (ref.startsWith(GITHUB_TAGS_PREFIX)) {
|
|
65
|
+
return ref.slice(GITHUB_TAGS_PREFIX.length);
|
|
66
|
+
}
|
|
67
|
+
return EMPTY_VALUE;
|
|
68
|
+
}
|
|
69
|
+
function overrideShortName(shortName, refName) {
|
|
70
|
+
if (!shortName || !refName) {
|
|
71
|
+
return shortName;
|
|
72
|
+
}
|
|
73
|
+
const separatorIndex = shortName.lastIndexOf("@");
|
|
74
|
+
const repository = separatorIndex === -1 ? shortName : shortName.slice(0, separatorIndex);
|
|
75
|
+
if (!repository) {
|
|
76
|
+
return shortName;
|
|
77
|
+
}
|
|
78
|
+
return `${repository}@${refName}`;
|
|
79
|
+
}
|
|
80
|
+
function resolveRuntimeRefName(env) {
|
|
81
|
+
const explicitRefName = readRuntimeEnvValue(env, "REF_NAME");
|
|
82
|
+
if (explicitRefName) {
|
|
83
|
+
return explicitRefName;
|
|
84
|
+
}
|
|
85
|
+
const legacyManifestRefName = readRuntimeEnvValue(env, "PLUGIN_MANIFEST_REF_NAME");
|
|
86
|
+
if (legacyManifestRefName) {
|
|
87
|
+
return legacyManifestRefName;
|
|
88
|
+
}
|
|
89
|
+
const githubRefName = readRuntimeEnvValue(env, "GITHUB_REF_NAME");
|
|
90
|
+
if (githubRefName) {
|
|
91
|
+
return githubRefName;
|
|
92
|
+
}
|
|
93
|
+
return parseRefNameFromGitHubRef(readRuntimeEnvValue(env, "GITHUB_REF"));
|
|
94
|
+
}
|
|
95
|
+
function resolveRuntimeManifest(manifest, env) {
|
|
96
|
+
const refName = resolveRuntimeRefName(env);
|
|
97
|
+
if (!refName) {
|
|
98
|
+
return manifest;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...manifest,
|
|
102
|
+
short_name: overrideShortName(manifest.short_name, refName)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/types/manifest.ts
|
|
31
107
|
var runEvent = import_typebox.Type.Union(import_webhooks.emitterEventNames.map((o) => import_typebox.Type.Literal(o)));
|
|
32
108
|
var exampleCommandExecutionSchema = import_typebox.Type.Object({
|
|
33
109
|
commandInvocation: import_typebox.Type.String({ minLength: 1 }),
|
|
@@ -58,5 +134,6 @@ var manifestSchema = import_typebox.Type.Object({
|
|
|
58
134
|
commandSchema,
|
|
59
135
|
exampleCommandExecutionSchema,
|
|
60
136
|
manifestSchema,
|
|
137
|
+
resolveRuntimeManifest,
|
|
61
138
|
runEvent
|
|
62
139
|
});
|
package/dist/manifest.mjs
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
// src/types/manifest.ts
|
|
2
2
|
import { Type as T } from "@sinclair/typebox";
|
|
3
3
|
import { emitterEventNames } from "@octokit/webhooks";
|
|
4
|
+
|
|
5
|
+
// src/helpers/runtime-manifest.ts
|
|
6
|
+
var EMPTY_VALUE = String();
|
|
7
|
+
var GITHUB_HEADS_PREFIX = "refs/heads/";
|
|
8
|
+
var GITHUB_TAGS_PREFIX = "refs/tags/";
|
|
9
|
+
function readRuntimeEnvValue(env, key) {
|
|
10
|
+
const explicitValue = env?.[key];
|
|
11
|
+
if (typeof explicitValue === "string" && explicitValue.trim()) {
|
|
12
|
+
return explicitValue.trim();
|
|
13
|
+
}
|
|
14
|
+
const runtime = globalThis;
|
|
15
|
+
if (typeof runtime.Deno?.env?.get === "function") {
|
|
16
|
+
const denoValue = runtime.Deno.env.get(key);
|
|
17
|
+
if (typeof denoValue === "string" && denoValue.trim()) {
|
|
18
|
+
return denoValue.trim();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (typeof process !== "undefined") {
|
|
22
|
+
const processValue = process.env[key];
|
|
23
|
+
if (typeof processValue === "string" && processValue.trim()) {
|
|
24
|
+
return processValue.trim();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return EMPTY_VALUE;
|
|
28
|
+
}
|
|
29
|
+
function parseRefNameFromGitHubRef(ref) {
|
|
30
|
+
if (!ref) {
|
|
31
|
+
return EMPTY_VALUE;
|
|
32
|
+
}
|
|
33
|
+
if (ref.startsWith(GITHUB_HEADS_PREFIX)) {
|
|
34
|
+
return ref.slice(GITHUB_HEADS_PREFIX.length);
|
|
35
|
+
}
|
|
36
|
+
if (ref.startsWith(GITHUB_TAGS_PREFIX)) {
|
|
37
|
+
return ref.slice(GITHUB_TAGS_PREFIX.length);
|
|
38
|
+
}
|
|
39
|
+
return EMPTY_VALUE;
|
|
40
|
+
}
|
|
41
|
+
function overrideShortName(shortName, refName) {
|
|
42
|
+
if (!shortName || !refName) {
|
|
43
|
+
return shortName;
|
|
44
|
+
}
|
|
45
|
+
const separatorIndex = shortName.lastIndexOf("@");
|
|
46
|
+
const repository = separatorIndex === -1 ? shortName : shortName.slice(0, separatorIndex);
|
|
47
|
+
if (!repository) {
|
|
48
|
+
return shortName;
|
|
49
|
+
}
|
|
50
|
+
return `${repository}@${refName}`;
|
|
51
|
+
}
|
|
52
|
+
function resolveRuntimeRefName(env) {
|
|
53
|
+
const explicitRefName = readRuntimeEnvValue(env, "REF_NAME");
|
|
54
|
+
if (explicitRefName) {
|
|
55
|
+
return explicitRefName;
|
|
56
|
+
}
|
|
57
|
+
const legacyManifestRefName = readRuntimeEnvValue(env, "PLUGIN_MANIFEST_REF_NAME");
|
|
58
|
+
if (legacyManifestRefName) {
|
|
59
|
+
return legacyManifestRefName;
|
|
60
|
+
}
|
|
61
|
+
const githubRefName = readRuntimeEnvValue(env, "GITHUB_REF_NAME");
|
|
62
|
+
if (githubRefName) {
|
|
63
|
+
return githubRefName;
|
|
64
|
+
}
|
|
65
|
+
return parseRefNameFromGitHubRef(readRuntimeEnvValue(env, "GITHUB_REF"));
|
|
66
|
+
}
|
|
67
|
+
function resolveRuntimeManifest(manifest, env) {
|
|
68
|
+
const refName = resolveRuntimeRefName(env);
|
|
69
|
+
if (!refName) {
|
|
70
|
+
return manifest;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...manifest,
|
|
74
|
+
short_name: overrideShortName(manifest.short_name, refName)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/types/manifest.ts
|
|
4
79
|
var runEvent = T.Union(emitterEventNames.map((o) => T.Literal(o)));
|
|
5
80
|
var exampleCommandExecutionSchema = T.Object({
|
|
6
81
|
commandInvocation: T.String({ minLength: 1 }),
|
|
@@ -30,5 +105,6 @@ export {
|
|
|
30
105
|
commandSchema,
|
|
31
106
|
exampleCommandExecutionSchema,
|
|
32
107
|
manifestSchema,
|
|
108
|
+
resolveRuntimeManifest,
|
|
33
109
|
runEvent
|
|
34
110
|
};
|