@toon-protocol/rig 5.3.0 → 5.4.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.
@@ -12,7 +12,7 @@ import {
12
12
  parseMaintainers,
13
13
  queryRelay,
14
14
  resolveIdentity
15
- } from "./chunk-OVZJ5P6E.js";
15
+ } from "./chunk-7LB352DM.js";
16
16
  import {
17
17
  defaultDaemonPort,
18
18
  standaloneForced,
@@ -4000,6 +4000,53 @@ function assembleCiStatus(opts) {
4000
4000
  const ok = counted.length > 0 && red === 0 && pending === 0;
4001
4001
  return { runs, summary, ok, ...reason !== void 0 ? { reason } : {} };
4002
4002
  }
4003
+ async function evaluateCiGate(opts) {
4004
+ const { relays, owner, repoId, commit, webSocketFactory } = opts;
4005
+ const repoAddr = repoAddress(owner, repoId);
4006
+ const events = await queryAll(
4007
+ relays,
4008
+ [
4009
+ {
4010
+ kinds: [
4011
+ CI_WORKFLOW_RESULT_KIND,
4012
+ CI_WORKFLOW_PROGRESS_KIND,
4013
+ CI_JOB_RESULT_KIND
4014
+ ],
4015
+ "#a": [repoAddr],
4016
+ "#c": [commit]
4017
+ },
4018
+ {
4019
+ kinds: [CI_SERVICE_REQUEST_KIND, CI_SERVICE_STOP_KIND],
4020
+ "#a": [repoAddr]
4021
+ },
4022
+ {
4023
+ kinds: [REPOSITORY_ANNOUNCEMENT_KIND2],
4024
+ authors: [owner],
4025
+ "#d": [repoId]
4026
+ }
4027
+ ],
4028
+ webSocketFactory
4029
+ );
4030
+ let announce = null;
4031
+ for (const ev of events) {
4032
+ if (ev.kind !== REPOSITORY_ANNOUNCEMENT_KIND2 || ev.pubkey.toLowerCase() !== owner)
4033
+ continue;
4034
+ if (!ev.tags.some((t) => t[0] === "d" && t[1] === repoId)) continue;
4035
+ if (announce === null || ev.created_at > announce.created_at || ev.created_at === announce.created_at && ev.id < announce.id) {
4036
+ announce = ev;
4037
+ }
4038
+ }
4039
+ const authorized = authorizedAuthors(owner, announce?.tags ?? []);
4040
+ return assembleCiStatus({
4041
+ commit,
4042
+ ownerPubkey: owner,
4043
+ repoId,
4044
+ authorized,
4045
+ events,
4046
+ ...opts.requireTrust !== void 0 ? { requireTrust: opts.requireTrust } : {},
4047
+ ...opts.workflow !== void 0 ? { workflow: opts.workflow } : {}
4048
+ });
4049
+ }
4003
4050
  async function runCiStatus(args, deps) {
4004
4051
  const { io } = deps;
4005
4052
  let flags;
@@ -4085,47 +4132,12 @@ async function runCiStatus(args, deps) {
4085
4132
  );
4086
4133
  }
4087
4134
  const webSocketFactory = deps.webSocketFactory ?? defaultWebSocketFactory;
4088
- const repoAddr = repoAddress(owner, repoId);
4089
- const events = await queryAll(
4135
+ const assembled = await evaluateCiGate({
4090
4136
  relays,
4091
- [
4092
- {
4093
- kinds: [
4094
- CI_WORKFLOW_RESULT_KIND,
4095
- CI_WORKFLOW_PROGRESS_KIND,
4096
- CI_JOB_RESULT_KIND
4097
- ],
4098
- "#a": [repoAddr],
4099
- "#c": [commit]
4100
- },
4101
- {
4102
- kinds: [CI_SERVICE_REQUEST_KIND, CI_SERVICE_STOP_KIND],
4103
- "#a": [repoAddr]
4104
- },
4105
- {
4106
- kinds: [REPOSITORY_ANNOUNCEMENT_KIND2],
4107
- authors: [owner],
4108
- "#d": [repoId]
4109
- }
4110
- ],
4111
- webSocketFactory
4112
- );
4113
- let announce = null;
4114
- for (const ev of events) {
4115
- if (ev.kind !== REPOSITORY_ANNOUNCEMENT_KIND2 || ev.pubkey.toLowerCase() !== owner)
4116
- continue;
4117
- if (!ev.tags.some((t) => t[0] === "d" && t[1] === repoId)) continue;
4118
- if (announce === null || ev.created_at > announce.created_at || ev.created_at === announce.created_at && ev.id < announce.id) {
4119
- announce = ev;
4120
- }
4121
- }
4122
- const authorized = authorizedAuthors(owner, announce?.tags ?? []);
4123
- const assembled = assembleCiStatus({
4124
- commit,
4125
- ownerPubkey: owner,
4137
+ owner,
4126
4138
  repoId,
4127
- authorized,
4128
- events,
4139
+ commit,
4140
+ webSocketFactory,
4129
4141
  ...flags.requireTrust !== void 0 ? { requireTrust: flags.requireTrust } : {},
4130
4142
  ...flags.workflow !== void 0 ? { workflow: flags.workflow } : {}
4131
4143
  });
@@ -4339,6 +4351,7 @@ export {
4339
4351
  runRemote,
4340
4352
  CI_STATUS_USAGE,
4341
4353
  assembleCiStatus,
4354
+ evaluateCiGate,
4342
4355
  runCiStatus
4343
4356
  };
4344
- //# sourceMappingURL=chunk-DGF7WCRW.js.map
4357
+ //# sourceMappingURL=chunk-YBJNZS5X.js.map