@homeflare/alchemy 0.27.4 → 0.28.0

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.
@@ -23,5 +23,5 @@ export { type RepoBaselineInput, PUBLIC_ONLY_UNDECLARABLE, repoBaselineRuleset,
23
23
  export { type DeclareRepoBaselineOptions, declareRepoBaseline } from './declare-repo-baseline.ts';
24
24
  export { RepositoryRuleset, RepositoryRulesetProvider, type RepositoryRulesetAttributes, type RepositoryRulesetProps, type RepositoryRulesetPullRequestRule, type RepositoryRulesetReviewerRule, type RepositoryRulesetRules, type RepositoryRulesetStatusChecksRule, } from './repository-ruleset.ts';
25
25
  export { RULE_TYPE_COVERAGE, type RepositoryRuleType } from './repository-ruleset-constraints.ts';
26
- export { BypassActorWidened, DuplicateRuleset, NeverReportedContext, ReadbackMismatch, RequiredChecksOmitted, RulesetConstraintRefused, UndeclaredLiveRule, type RepositoryRulesetError, } from './repository-ruleset-errors.ts';
26
+ export { BypassActorNarrowed, BypassActorWidened, DuplicateRuleset, NeverReportedContext, ReadbackMismatch, RequiredChecksOmitted, RuleNarrowed, RulesetConstraintRefused, UndeclaredLiveRule, type RepositoryRulesetError, } from './repository-ruleset-errors.ts';
27
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/github/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,iBAAiB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,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AAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,sBAAsB,GAC5B,MAAM,gCAAgC,CAAC"}
@@ -208,6 +208,18 @@ class BypassActorWidened extends Data.TaggedError("BypassActorWidened") {
208
208
  }
209
209
  }
210
210
 
211
+ class BypassActorNarrowed extends Data.TaggedError("BypassActorNarrowed") {
212
+ get message() {
213
+ return `GitHub.RepositoryRuleset "${this.name}" on ${this.owner}/${this.repository}: the ` + `declaration drops a bypass actor the live ruleset has (${this.narrowed.join(", ")}), and ` + "the declaration carries no `acknowledgeBypassNarrowing`. Add one with a reason once the " + "removal is deliberate, or restore the actor to match live.";
214
+ }
215
+ }
216
+
217
+ class RuleNarrowed extends Data.TaggedError("RuleNarrowed") {
218
+ get message() {
219
+ return `GitHub.RepositoryRuleset "${this.name}" on ${this.owner}/${this.repository}: the ` + `declaration drops a live "${this.ruleType}" rule, and carries no ` + "`acknowledgeRuleNarrowing`. Add one with a reason once the removal is deliberate, or " + "declare the rule to match live.";
220
+ }
221
+ }
222
+
211
223
  class UndeclaredLiveRule extends Data.TaggedError("UndeclaredLiveRule") {
212
224
  get message() {
213
225
  return `GitHub.RepositoryRuleset "${this.name}" on ${this.owner}/${this.repository}: the live ` + `ruleset has a "${this.ruleType}" rule this resource does not model. Declare it (if it is ` + "now modeled) or an explicit `false` to remove it — the PUT replaces `rules` wholesale, so " + "nothing may be dropped silently.";
@@ -587,6 +599,65 @@ var refuseUnreportedContexts = (octokit, owner, repo, contexts) => Effect3.gen(f
587
599
  }
588
600
  });
589
601
 
602
+ // src/github/repository-ruleset-narrowing-guards.ts
603
+ var isBypassNarrowingAcknowledged = (props) => props.acknowledgeBypassNarrowing !== undefined && props.acknowledgeBypassNarrowing.reason.trim().length > 0;
604
+ var isRuleNarrowingAcknowledged = (props) => props.acknowledgeRuleNarrowing !== undefined && props.acknowledgeRuleNarrowing.reason.trim().length > 0;
605
+ function bypassNarrowingRefusal(input) {
606
+ if (input.acknowledged)
607
+ return;
608
+ if (input.live === undefined)
609
+ return;
610
+ const liveActors = input.live.bypass_actors ?? [];
611
+ const declaredKeys = new Set((input.declared ?? []).map((a) => bypassKey({
612
+ actor_type: a.actorType,
613
+ actor_id: a.actorId,
614
+ bypass_mode: a.bypassMode ?? "always"
615
+ })));
616
+ const narrowed = liveActors.map(bypassKey).filter((k) => !declaredKeys.has(k));
617
+ if (narrowed.length === 0)
618
+ return;
619
+ return new BypassActorNarrowed({
620
+ owner: input.owner,
621
+ repository: input.repository,
622
+ name: input.name,
623
+ narrowed
624
+ });
625
+ }
626
+ function droppedBooleanOrPullRequestType(rules, live) {
627
+ const declaredFalse = [
628
+ [rules.creation, "creation"],
629
+ [rules.update, "update"],
630
+ [rules.deletion, "deletion"],
631
+ [rules.requiredLinearHistory, "required_linear_history"],
632
+ [rules.requiredSignatures, "required_signatures"],
633
+ [rules.nonFastForward, "non_fast_forward"]
634
+ ];
635
+ for (const [declared, type] of declaredFalse) {
636
+ if (declared === false && live.has(type))
637
+ return type;
638
+ }
639
+ if (rules.pullRequest === false && live.has("pull_request"))
640
+ return "pull_request";
641
+ return;
642
+ }
643
+ function ruleNarrowingRefusal(input) {
644
+ if (input.acknowledged)
645
+ return;
646
+ const rules = input.declared;
647
+ if (rules === undefined)
648
+ return;
649
+ const live = liveRuleTypes(input.live);
650
+ const ruleType = droppedBooleanOrPullRequestType(rules, live) ?? (rules.requiredStatusChecks === false && live.has("required_status_checks") ? "required_status_checks" : undefined);
651
+ if (ruleType === undefined)
652
+ return;
653
+ return new RuleNarrowed({
654
+ owner: input.owner,
655
+ repository: input.repository,
656
+ name: input.name,
657
+ ruleType
658
+ });
659
+ }
660
+
590
661
  // src/github/repository-ruleset-reconcile.ts
591
662
  var guardedPullRequestFields = (rule) => {
592
663
  const params = rule?.parameters ?? {};
@@ -631,6 +702,8 @@ var reconcileRuleset = (input) => Effect4.gen(function* () {
631
702
  if (observed === undefined) {
632
703
  observed = yield* probeByName(octokit, { owner, repo, name: news.name, target });
633
704
  }
705
+ const bypassAcknowledged = isBypassNarrowingAcknowledged(news);
706
+ const ruleAcknowledged = isRuleNarrowingAcknowledged(news);
634
707
  const bypassRefusal = news.bypassActors === undefined ? undefined : bypassWideningRefusal({
635
708
  owner,
636
709
  repository: repo,
@@ -640,6 +713,16 @@ var reconcileRuleset = (input) => Effect4.gen(function* () {
640
713
  });
641
714
  if (bypassRefusal !== undefined)
642
715
  return yield* Effect4.fail(bypassRefusal);
716
+ const bypassNarrowRefusal = news.bypassActors === undefined ? undefined : bypassNarrowingRefusal({
717
+ owner,
718
+ repository: repo,
719
+ name: news.name,
720
+ declared: news.bypassActors,
721
+ live: observed,
722
+ acknowledged: bypassAcknowledged
723
+ });
724
+ if (bypassNarrowRefusal !== undefined)
725
+ return yield* Effect4.fail(bypassNarrowRefusal);
643
726
  const ruleRefusal = undeclaredLiveRuleRefusal({
644
727
  owner,
645
728
  repository: repo,
@@ -649,6 +732,16 @@ var reconcileRuleset = (input) => Effect4.gen(function* () {
649
732
  });
650
733
  if (ruleRefusal !== undefined)
651
734
  return yield* Effect4.fail(ruleRefusal);
735
+ const ruleNarrowRefusal = ruleNarrowingRefusal({
736
+ owner,
737
+ repository: repo,
738
+ name: news.name,
739
+ declared: news.rules,
740
+ live: observed,
741
+ acknowledged: ruleAcknowledged
742
+ });
743
+ if (ruleNarrowRefusal !== undefined)
744
+ return yield* Effect4.fail(ruleNarrowRefusal);
652
745
  const checksRefusal = requiredChecksOmissionRefusal({
653
746
  owner,
654
747
  repository: repo,
@@ -700,7 +793,8 @@ var attrsOf = (r) => ({
700
793
  updatedAt: r.updated_at
701
794
  });
702
795
  function constraintRefusal(props) {
703
- const approvals = props.rules?.pullRequest?.requiredApprovingReviewCount;
796
+ const pr = props.rules?.pullRequest === false ? undefined : props.rules?.pullRequest;
797
+ const approvals = pr?.requiredApprovingReviewCount;
704
798
  if (approvals !== undefined) {
705
799
  const reason = approvalCountRefusal(approvals);
706
800
  if (reason !== undefined) {
@@ -710,7 +804,7 @@ function constraintRefusal(props) {
710
804
  });
711
805
  }
712
806
  }
713
- const methods = props.rules?.pullRequest?.allowedMergeMethods;
807
+ const methods = pr?.allowedMergeMethods;
714
808
  if (methods !== undefined) {
715
809
  const reason = allowedMergeMethodsRefusal(methods);
716
810
  if (reason !== undefined) {
@@ -850,6 +944,7 @@ var declareRepoBaseline = (id, options) => Effect7.gen(function* () {
850
944
  return { repository, ruleset };
851
945
  });
852
946
  export {
947
+ BypassActorNarrowed,
853
948
  BypassActorWidened,
854
949
  DuplicateRuleset,
855
950
  NeverReportedContext,
@@ -859,6 +954,7 @@ export {
859
954
  RepositoryRuleset,
860
955
  RepositoryRulesetProvider,
861
956
  RequiredChecksOmitted,
957
+ RuleNarrowed,
862
958
  RulesetConstraintRefused,
863
959
  UndeclaredLiveRule,
864
960
  declareRepoBaseline,
@@ -868,5 +964,5 @@ export {
868
964
  repoPolicy
869
965
  };
870
966
 
871
- //# debugId=45989F9C0ABF077664756E2164756E21
967
+ //# debugId=92F34291743D117E64756E2164756E21
872
968
  //# sourceMappingURL=index.js.map