atmn 2.0.251 → 2.0.253

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.
@@ -136,6 +136,8 @@ export type CatalogPreview = {
136
136
  settings?: SettingsPreview;
137
137
  /** One block per env the push syncs; absent when the config states no `webhooks`. */
138
138
  webhooks?: WebhooksPreview[];
139
+ /** The server's echo of skip_updates: this preview is a safe-mode one. */
140
+ skipUpdates?: boolean;
139
141
  /** Live webhook ids a plain push found out of date but leaves to `-p`. */
140
142
  productionWebhooks?: string[];
141
143
  /** The read-only live check failed: "No changes" would be a claim nobody checked. */
@@ -535,6 +537,21 @@ const planRowId = (row: { planId?: string; version?: number }): string =>
535
537
  ? (row.planId ?? "?")
536
538
  : `${row.planId}@v${row.version}`;
537
539
 
540
+ /** A row safe mode held back: greyed, never a marker, never its diff. */
541
+ const skippedLine = ({
542
+ id,
543
+ label,
544
+ indent = " ",
545
+ }: {
546
+ id: string;
547
+ label?: string;
548
+ indent?: string;
549
+ }): string =>
550
+ `${indent}${chalk.dim(`· ${id}${label && label !== id ? ` ${label}` : ""} skipped`)}`;
551
+
552
+ const SAFE_MODE_HEADER =
553
+ "Safe mode: only ids that don't exist yet are created. Updates and deletions are skipped.";
554
+
538
555
  /** A row printed only to place the work nested under it: no marker, no colour. */
539
556
  const contextLine = ({
540
557
  id,
@@ -666,6 +683,7 @@ const isFreshRow = (plan: PlanChange): boolean =>
666
683
  * are the only work — then its identity moves, its diff, then those variants. */
667
684
  const renderPlanRow = ({ plan }: { plan: PlanChange }): string[] => {
668
685
  const id = planRowId(plan);
686
+ if (plan.action === "skip") return [skippedLine({ id, label: plan.name })];
669
687
  const fresh = isFreshRow(plan);
670
688
  return [
671
689
  isChange(plan)
@@ -843,10 +861,13 @@ export const renderPreview = ({
843
861
  /** Omitted in tests; the dashboard origin in real runs. */
844
862
  migrationLinkBase?: string;
845
863
  }): string => {
846
- const features = (preview.features ?? []).filter(rowHasWork);
847
- const plans = (preview.plans ?? []).filter(rowHasWork);
848
- const rewards = (preview.rewards ?? []).filter(rowHasWork);
849
- const referralPrograms = (preview.referralPrograms ?? []).filter(rowHasWork);
864
+ const safe = preview.skipUpdates === true;
865
+ const shown = (row: PreviewChange): boolean =>
866
+ rowHasWork(row) || (safe && row.action === "skip");
867
+ const features = (preview.features ?? []).filter(shown);
868
+ const plans = (preview.plans ?? []).filter(shown);
869
+ const rewards = (preview.rewards ?? []).filter(shown);
870
+ const referralPrograms = (preview.referralPrograms ?? []).filter(shown);
850
871
  const migrations = preview.migrations ?? [];
851
872
  const settings = settingChanges(preview.settings);
852
873
  const webhooks = (preview.webhooks ?? [])
@@ -876,7 +897,7 @@ export const renderPreview = ({
876
897
  return chalk.dim("No changes. Your catalog matches your config.");
877
898
  }
878
899
 
879
- const sections: string[] = [];
900
+ const sections: string[] = safe ? [chalk.bold(SAFE_MODE_HEADER)] : [];
880
901
 
881
902
  if (settings.length > 0) {
882
903
  sections.push(
@@ -891,17 +912,26 @@ export const renderPreview = ({
891
912
  sections.push(
892
913
  [
893
914
  chalk.bold(`Features (${features.length})`),
894
- ...features.flatMap((feature) => [
895
- line({
896
- action: feature.action,
897
- id: feature.featureId ?? "?",
898
- label: feature.name,
899
- }),
900
- ...renderPreviousAttributes({
901
- attributes: feature.previousAttributes,
902
- indent: DETAIL_INDENT,
903
- }),
904
- ]),
915
+ ...features.flatMap((feature) =>
916
+ feature.action === "skip"
917
+ ? [
918
+ skippedLine({
919
+ id: feature.featureId ?? "?",
920
+ label: feature.name,
921
+ }),
922
+ ]
923
+ : [
924
+ line({
925
+ action: feature.action,
926
+ id: feature.featureId ?? "?",
927
+ label: feature.name,
928
+ }),
929
+ ...renderPreviousAttributes({
930
+ attributes: feature.previousAttributes,
931
+ indent: DETAIL_INDENT,
932
+ }),
933
+ ],
934
+ ),
905
935
  ].join("\n"),
906
936
  );
907
937
  }
@@ -919,17 +949,26 @@ export const renderPreview = ({
919
949
  sections.push(
920
950
  [
921
951
  chalk.bold(`Rewards (${rewards.length})`),
922
- ...rewards.flatMap((reward) => [
923
- line({
924
- action: reward.action,
925
- id: reward.id ?? "?",
926
- label: reward.name ?? reward.kind,
927
- }),
928
- ...renderPreviousAttributes({
929
- attributes: reward.previousAttributes,
930
- indent: DETAIL_INDENT,
931
- }),
932
- ]),
952
+ ...rewards.flatMap((reward) =>
953
+ reward.action === "skip"
954
+ ? [
955
+ skippedLine({
956
+ id: reward.id ?? "?",
957
+ label: reward.name ?? reward.kind,
958
+ }),
959
+ ]
960
+ : [
961
+ line({
962
+ action: reward.action,
963
+ id: reward.id ?? "?",
964
+ label: reward.name ?? reward.kind,
965
+ }),
966
+ ...renderPreviousAttributes({
967
+ attributes: reward.previousAttributes,
968
+ indent: DETAIL_INDENT,
969
+ }),
970
+ ],
971
+ ),
933
972
  ].join("\n"),
934
973
  );
935
974
  }
@@ -938,17 +977,26 @@ export const renderPreview = ({
938
977
  sections.push(
939
978
  [
940
979
  chalk.bold(`Referral programs (${referralPrograms.length})`),
941
- ...referralPrograms.flatMap((program) => [
942
- line({
943
- action: program.action,
944
- id: program.id ?? "?",
945
- label: program.rewardId ?? undefined,
946
- }),
947
- ...renderPreviousAttributes({
948
- attributes: program.previousAttributes,
949
- indent: DETAIL_INDENT,
950
- }),
951
- ]),
980
+ ...referralPrograms.flatMap((program) =>
981
+ program.action === "skip"
982
+ ? [
983
+ skippedLine({
984
+ id: program.id ?? "?",
985
+ label: program.rewardId ?? undefined,
986
+ }),
987
+ ]
988
+ : [
989
+ line({
990
+ action: program.action,
991
+ id: program.id ?? "?",
992
+ label: program.rewardId ?? undefined,
993
+ }),
994
+ ...renderPreviousAttributes({
995
+ attributes: program.previousAttributes,
996
+ indent: DETAIL_INDENT,
997
+ }),
998
+ ],
999
+ ),
952
1000
  ].join("\n"),
953
1001
  );
954
1002
  }
@@ -1,8 +1,26 @@
1
1
  import chalk from "chalk";
2
2
  import type { PreviewSyncWebhooksResponse } from "../generated/client";
3
3
 
4
- type WebhookChange = PreviewSyncWebhooksResponse["changes"][number];
5
- type WebhookState = Extract<WebhookChange, { action: "create" }>["webhook"];
4
+ type WebhookState = Extract<
5
+ PreviewSyncWebhooksResponse["changes"][number],
6
+ { action: "create" }
7
+ >["webhook"];
8
+
9
+ /** What skip_updates held back; spelled out until the generated client carries it. */
10
+ type SkippedWebhookChange = {
11
+ action: "skip";
12
+ id: string;
13
+ skipped: string;
14
+ webhook: WebhookState;
15
+ };
16
+
17
+ type WebhookChange =
18
+ | PreviewSyncWebhooksResponse["changes"][number]
19
+ | SkippedWebhookChange;
20
+
21
+ /** Neither an unmanaged nor a skipped webhook is written. */
22
+ const isWrite = (change: WebhookChange): boolean =>
23
+ change.action !== "unmanaged" && change.action !== "skip";
6
24
 
7
25
  /** One env's webhook lane: the server's diff for that env. */
8
26
  export type WebhooksPreview = {
@@ -15,8 +33,7 @@ export const webhooksHaveWork = ({
15
33
  webhooks,
16
34
  }: {
17
35
  webhooks: WebhooksPreview | undefined;
18
- }): boolean =>
19
- (webhooks?.changes ?? []).some((change) => change.action !== "unmanaged");
36
+ }): boolean => (webhooks?.changes ?? []).some(isWrite);
20
37
 
21
38
  const DETAIL_INDENT = " ";
22
39
 
@@ -76,6 +93,8 @@ const renderChange = ({ change }: { change: WebhookChange }): string[] => {
76
93
  return [
77
94
  ` ${chalk.red(`- ${change.id}`)} ${chalk.bold("delete")}${chalk.dim(` ${change.webhook.url}`)}`,
78
95
  ];
96
+ if (change.action === "skip")
97
+ return [chalk.dim(` · ${change.id} skipped (would ${change.skipped})`)];
79
98
  return [
80
99
  chalk.dim(
81
100
  ` · ${change.id} unmanaged (not in your config; atmn leaves it alone)`,
@@ -91,9 +110,7 @@ export const renderWebhooks = ({
91
110
  }): string | null => {
92
111
  const rows = webhooks.changes.flatMap((change) => renderChange({ change }));
93
112
  if (rows.length === 0) return null;
94
- const count = webhooks.changes.filter(
95
- (change) => change.action !== "unmanaged",
96
- ).length;
113
+ const count = webhooks.changes.filter(isWrite).length;
97
114
  const heading =
98
115
  webhooks.env === undefined
99
116
  ? `Webhooks (${count})`