platform-types 1.10.721 → 1.10.722

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.
@@ -30,7 +30,7 @@
30
30
  * enabled:false until they do.
31
31
  */
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.FEATURE_KEYS = exports.isPaidPlanTier = exports.PAID_PLAN_TIERS = exports.PLAN_TIERS = void 0;
33
+ exports.FEATURE_KEYS = exports.isPaidPlanTier = exports.PLAN_CATALOGUE_ERROR_CODES = exports.PLAN_CATALOGUE_TEMPLATE_FIELDS = exports.PAID_PLAN_TIERS = exports.PLAN_TIERS = void 0;
34
34
  /*
35
35
  * Runtime tuples for the unions above.
36
36
  *
@@ -56,6 +56,29 @@ exports.PLAN_TIERS = exhaustiveTuple()(['basico', 'emprendedor', 'profesional',
56
56
  * grace sweep's tier fan-out and the provider plan seeders all read it.
57
57
  */
58
58
  exports.PAID_PLAN_TIERS = exhaustiveTuple()(['emprendedor', 'profesional', 'avanzado']);
59
+ /** Every template field a plan catalogue draft carries, in the order a diff lists them. */
60
+ exports.PLAN_CATALOGUE_TEMPLATE_FIELDS = exhaustiveTuple()([
61
+ 'name',
62
+ 'description',
63
+ 'displayOrder',
64
+ 'isActive',
65
+ 'isPopular',
66
+ 'color',
67
+ 'priceMonthlyCents',
68
+ 'priceAnnualCents',
69
+ 'currency',
70
+ ]);
71
+ /** Every `error` code the plan catalogue draft / publish routes add — the coverage test holds the handlers to it. */
72
+ exports.PLAN_CATALOGUE_ERROR_CODES = exhaustiveTuple()([
73
+ 'PLAN_CATALOGUE_REVISION_CONFLICT',
74
+ 'PLAN_CATALOGUE_BUSY',
75
+ 'PLAN_CATALOGUE_NO_CHANGES',
76
+ 'PLAN_CATALOGUE_PUBLICATION_NOT_FOUND',
77
+ 'PLAN_CATALOGUE_REQUEST_EXPIRED',
78
+ 'PLAN_CATALOGUE_INVALID_CURSOR',
79
+ 'PLAN_CATALOGUE_DRAFT_STALE',
80
+ 'IDEMPOTENCY_CONFLICT',
81
+ ]);
59
82
  /** Whether `value` names a paid tier — narrows an untyped read (a stored row, a global) to `PaidPlanTier`. */
60
83
  const isPaidPlanTier = (value) => typeof value === 'string' && exports.PAID_PLAN_TIERS.includes(value);
61
84
  exports.isPaidPlanTier = isPaidPlanTier;
@@ -357,6 +357,12 @@ declare global {
357
357
  tier: PaidPlanTier;
358
358
  days: number;
359
359
  };
360
+ /**
361
+ * The publication these plans are, from `POST /platform/billing/plans/publish`
362
+ * — so a consumer (the landing snapshot) can tell which version it rendered.
363
+ * `null` until the catalogue's first publication, or when the rows read are not one publication.
364
+ */
365
+ publicationId: string | null;
360
366
  }
361
367
  /**
362
368
  * One audit row per MANAGER-driven plan mutation (`POST` / `PATCH
@@ -879,10 +885,8 @@ declare global {
879
885
  /** Screened operator reason (10-500 characters, no personal data); lands in each tier's audit entry. */
880
886
  reason: string;
881
887
  /**
882
- * Required on a live write: the comma-joined sorted keys the request
883
- * changes — the string a dry run of the same body returns. It names the
884
- * keys, not the tiers or values, so it proves the caller meant those keys;
885
- * the dry run is where the tiers and the impact are reviewed.
888
+ * Accepted and NOT checked: a grant edit writes the draft, and the echo that
889
+ * gates what readers see is the publish's (`PlanCataloguePublishInput.confirm`).
886
890
  */
887
891
  confirm?: string;
888
892
  /** `true` writes nothing and returns the impact plus the `confirm` string. */
@@ -920,7 +924,9 @@ declare global {
920
924
  * Stores on this tier, any status: those whose SUBSCRIPTION row is on it
921
925
  * (`planTier-status`) plus, on `profesional` — the tier a store with no
922
926
  * SUBSCRIPTION row resolves to — every store with no row. A lower bound
923
- * when `truncated`.
927
+ * when `truncated`. ⚠️ Always `0` on a grant edit, which writes the draft
928
+ * only: the store counts and the impact are the publish dry run's
929
+ * (`PlanCataloguePublishTierResult`).
924
930
  */
925
931
  subscribedStores: number;
926
932
  /** Dry run only: per reduced key, the stores it bites. Empty when nothing on this tier is reduced. */
@@ -953,10 +959,174 @@ declare global {
953
959
  dryRun: boolean;
954
960
  /** `false` on a dry run and on an identical replay (no change, no write, no audit). */
955
961
  written: boolean;
956
- /** The comma-joined sorted changed keys — what a live run must send as `confirm`. Empty when nothing changes. */
962
+ /** The comma-joined sorted changed keys. Informational on a draft edit — the publish computes its own. */
957
963
  confirm: string;
958
964
  tiers: PlanGrantsTierResult[];
965
+ /**
966
+ * The draft catalogue after the write. Grant edits land in the DRAFT and
967
+ * reach no reader until `POST /platform/billing/plans/publish`; absent on a
968
+ * dry run and on an identical replay.
969
+ */
970
+ draft?: PlanCatalogueDraftSummary;
971
+ }
972
+ /** The template fields a draft carries per tier; provider ids and bookkeeping are never part of it. */
973
+ type PlanCatalogueTemplateField = 'name' | 'description' | 'displayOrder' | 'isActive' | 'isPopular' | 'color' | 'priceMonthlyCents' | 'priceAnnualCents' | 'currency';
974
+ /** One template field that differs between the published catalogue and the draft. `null` = absent. */
975
+ interface PlanCatalogueFieldChange {
976
+ field: PlanCatalogueTemplateField;
977
+ before: string | number | boolean | null;
978
+ after: string | number | boolean | null;
979
+ }
980
+ /** One tier the draft changes: its template fields and its effective grants, published → draft. */
981
+ interface PlanCatalogueTierDiff {
982
+ tier: PlanTier;
983
+ fields: PlanCatalogueFieldChange[];
984
+ changes: PlanGrantChange[];
985
+ }
986
+ /**
987
+ * The two revisions every draft mutation and publish is guarded on. `draftRevision`
988
+ * is `null` while no draft exists; `publishedRevision` is the current
989
+ * `publicationId`, `null` before the first publication. A request naming a stale
990
+ * pair is `409 PLAN_CATALOGUE_REVISION_CONFLICT` and writes nothing.
991
+ */
992
+ interface PlanCatalogueRevisions {
993
+ draftRevision: string | null;
994
+ publishedRevision: string | null;
995
+ }
996
+ /** What a draft write answers alongside its own result. */
997
+ interface PlanCatalogueDraftSummary extends PlanCatalogueRevisions {
998
+ /** Whether the draft differs from the published catalogue at all. */
999
+ dirty: boolean;
1000
+ }
1001
+ /** `data` of `GET /platform/billing/plans/draft` and of the discard / restore mutations. */
1002
+ interface PlanCatalogueDraftResult extends PlanCatalogueDraftSummary {
1003
+ /** The published version number the draft would replace; `null` before the first publication. */
1004
+ publishedVersion: number | null;
1005
+ /** The publication the draft was restored from, until the next edit or publish. */
1006
+ restoredFrom: string | null;
1007
+ /**
1008
+ * Tiers whose published row changed since the draft was started (a direct
1009
+ * row write, or a publication racing the draft's first write). Non-empty means a publish is refused
1010
+ * `409 PLAN_CATALOGUE_DRAFT_STALE`: discard the draft, or restore a
1011
+ * publication into it.
1012
+ */
1013
+ staleTiers: PlanTier[];
1014
+ /** Every operator who wrote this draft, first edit first. */
1015
+ editors: {
1016
+ userId: string;
1017
+ fullName: string;
1018
+ }[];
1019
+ /**
1020
+ * The draft rendered exactly as `GET /public/plans` would serve it once published. Its
1021
+ * `publicationId` is `null` while a draft exists (unpublished content is no publication; the
1022
+ * base it stands on is `publishedRevision`) and the published one when there is no draft.
1023
+ */
1024
+ catalogue: PlanCatalogue;
1025
+ /** Per changed tier, published → draft. Empty when the draft is clean. */
1026
+ diff: PlanCatalogueTierDiff[];
1027
+ }
1028
+ /** Body of `POST /platform/billing/plans/draft/discard`. */
1029
+ interface PlanCatalogueDiscardInput {
1030
+ expectedDraftRevision: string | null;
1031
+ expectedPublishedRevision: string | null;
1032
+ }
1033
+ /** Body of `POST /platform/billing/plans/draft/restore`: copy a past publication into the draft. */
1034
+ interface PlanCatalogueRestoreInput extends PlanCatalogueDiscardInput {
1035
+ publicationId: string;
959
1036
  }
1037
+ /** Body of `POST /platform/billing/plans/publish`. */
1038
+ interface PlanCataloguePublishInput extends PlanCatalogueDiscardInput {
1039
+ /** Idempotency key, a UUID: a retry with the same body answers the first result; a different body is `409 IDEMPOTENCY_CONFLICT`. */
1040
+ requestId: string;
1041
+ /** Screened operator reason (10-500 characters, no personal data); lands on the publication, the publication-level audit row, every changed tier's audit row and, on the first publish ever, version 1's `recordedReason`. */
1042
+ reason: string;
1043
+ /** Required on a live publish: the `confirm` string the dry run of the same draft returned. */
1044
+ confirm?: string;
1045
+ /** `true` writes nothing and returns the diff, the store counts, the impact and the `confirm` string. */
1046
+ dryRun?: boolean;
1047
+ }
1048
+ /** One changed tier in a publish result. */
1049
+ interface PlanCataloguePublishTierResult extends PlanCatalogueTierDiff {
1050
+ /** Stores on the tier, as `PlanGrantsTierResult.subscribedStores`. */
1051
+ subscribedStores: number;
1052
+ /** Dry run only: per reduced key, the stores it bites. */
1053
+ impact?: PlanGrantImpact[];
1054
+ /** As `PlanGrantsTierResult.truncated`, for the dry run's impact or the live follow-up. */
1055
+ truncated?: boolean;
1056
+ /** Live publish only: stores the `subscription` socket frame reached. */
1057
+ notifiedStores?: number;
1058
+ /** Live publish only, when `storefront` or `customDomain` changed: stores whose shop grace a reconcile settled. */
1059
+ reconciledStores?: number;
1060
+ /**
1061
+ * A paid tier whose price, currency or name changed, with a currency set on the draft being
1062
+ * published (never `basico`, never when that currency is absent): run the provider seeders
1063
+ * to mint its new prices.
1064
+ */
1065
+ stripeSyncRequired: boolean;
1066
+ }
1067
+ /** `data` of `POST /platform/billing/plans/publish`. */
1068
+ interface PlanCataloguePublishResult {
1069
+ dryRun: boolean;
1070
+ written: boolean;
1071
+ /**
1072
+ * The comma-joined sorted changes a live publish must echo: each changed grant
1073
+ * key, and `<tier>.<field>` for each changed template field. Empty when only
1074
+ * the bootstrap would be written.
1075
+ */
1076
+ confirm: string;
1077
+ /** The new current publication; `null` on a dry run. */
1078
+ publicationId: string | null;
1079
+ version: number | null;
1080
+ committedAt: string | null;
1081
+ /** `true` when this publish also recorded the pre-existing live catalogue as version 1. */
1082
+ bootstrapped: boolean;
1083
+ tiers: PlanCataloguePublishTierResult[];
1084
+ }
1085
+ /** One immutable publication in `GET /platform/billing/plans/publications`, newest first. */
1086
+ interface PlanCataloguePublicationEntry {
1087
+ publicationId: string;
1088
+ version: number;
1089
+ committedAt: string;
1090
+ actor: {
1091
+ userId: string;
1092
+ fullName: string;
1093
+ };
1094
+ reason: string;
1095
+ restoredFrom: string | null;
1096
+ /** Who wrote the draft this publication was made from; empty for the bootstrap (version 1). */
1097
+ draftEditors: {
1098
+ userId: string;
1099
+ fullName: string;
1100
+ }[];
1101
+ /**
1102
+ * Version 1 only: the operator whose publish captured the live rows, and
1103
+ * their reason — `actor` there is the system. `null` on every later
1104
+ * publication.
1105
+ */
1106
+ recordedBy: {
1107
+ userId: string;
1108
+ fullName: string;
1109
+ } | null;
1110
+ recordedReason: string | null;
1111
+ /** The publication every reader serves now. */
1112
+ current: boolean;
1113
+ }
1114
+ interface PlanCataloguePublicationPage {
1115
+ items: PlanCataloguePublicationEntry[];
1116
+ cursor?: string;
1117
+ }
1118
+ /** `data` of a `409 PLAN_CATALOGUE_DRAFT_STALE`: the tiers whose published row changed since the draft started. */
1119
+ interface PlanCatalogueDraftStaleData {
1120
+ tiers: PlanTier[];
1121
+ }
1122
+ /** The `error` codes the plan catalogue draft / publish routes add. */
1123
+ type PlanCatalogueErrorCode = 'PLAN_CATALOGUE_REVISION_CONFLICT'
1124
+ /**
1125
+ * 409 · the publish commit was cancelled by a concurrent transaction
1126
+ * alone, on its attempt and its one retry. Nothing was written and no
1127
+ * revision moved: send the same request again.
1128
+ */
1129
+ | 'PLAN_CATALOGUE_BUSY' | 'PLAN_CATALOGUE_NO_CHANGES' | 'PLAN_CATALOGUE_PUBLICATION_NOT_FOUND' | 'PLAN_CATALOGUE_REQUEST_EXPIRED' | 'PLAN_CATALOGUE_INVALID_CURSOR' | 'PLAN_CATALOGUE_DRAFT_STALE' | 'IDEMPOTENCY_CONFLICT';
960
1130
  }
961
1131
  export type BillingProviderName = SubscriptionProvider;
962
1132
  export type InvoiceSummary = globalThis.InvoiceSummary;
@@ -968,6 +1138,10 @@ export declare const PLAN_TIERS: readonly ["basico", "emprendedor", "profesional
968
1138
  * grace sweep's tier fan-out and the provider plan seeders all read it.
969
1139
  */
970
1140
  export declare const PAID_PLAN_TIERS: readonly ["emprendedor", "profesional", "avanzado"];
1141
+ /** Every template field a plan catalogue draft carries, in the order a diff lists them. */
1142
+ export declare const PLAN_CATALOGUE_TEMPLATE_FIELDS: readonly ["name", "description", "displayOrder", "isActive", "isPopular", "color", "priceMonthlyCents", "priceAnnualCents", "currency"];
1143
+ /** Every `error` code the plan catalogue draft / publish routes add — the coverage test holds the handlers to it. */
1144
+ export declare const PLAN_CATALOGUE_ERROR_CODES: readonly ["PLAN_CATALOGUE_REVISION_CONFLICT", "PLAN_CATALOGUE_BUSY", "PLAN_CATALOGUE_NO_CHANGES", "PLAN_CATALOGUE_PUBLICATION_NOT_FOUND", "PLAN_CATALOGUE_REQUEST_EXPIRED", "PLAN_CATALOGUE_INVALID_CURSOR", "PLAN_CATALOGUE_DRAFT_STALE", "IDEMPOTENCY_CONFLICT"];
971
1145
  /** Whether `value` names a paid tier — narrows an untyped read (a stored row, a global) to `PaidPlanTier`. */
972
1146
  export declare const isPaidPlanTier: (value: unknown) => value is PaidPlanTier;
973
1147
  /**
@@ -53,6 +53,29 @@ export const PLAN_TIERS = exhaustiveTuple()(['basico', 'emprendedor', 'profesion
53
53
  * grace sweep's tier fan-out and the provider plan seeders all read it.
54
54
  */
55
55
  export const PAID_PLAN_TIERS = exhaustiveTuple()(['emprendedor', 'profesional', 'avanzado']);
56
+ /** Every template field a plan catalogue draft carries, in the order a diff lists them. */
57
+ export const PLAN_CATALOGUE_TEMPLATE_FIELDS = exhaustiveTuple()([
58
+ 'name',
59
+ 'description',
60
+ 'displayOrder',
61
+ 'isActive',
62
+ 'isPopular',
63
+ 'color',
64
+ 'priceMonthlyCents',
65
+ 'priceAnnualCents',
66
+ 'currency',
67
+ ]);
68
+ /** Every `error` code the plan catalogue draft / publish routes add — the coverage test holds the handlers to it. */
69
+ export const PLAN_CATALOGUE_ERROR_CODES = exhaustiveTuple()([
70
+ 'PLAN_CATALOGUE_REVISION_CONFLICT',
71
+ 'PLAN_CATALOGUE_BUSY',
72
+ 'PLAN_CATALOGUE_NO_CHANGES',
73
+ 'PLAN_CATALOGUE_PUBLICATION_NOT_FOUND',
74
+ 'PLAN_CATALOGUE_REQUEST_EXPIRED',
75
+ 'PLAN_CATALOGUE_INVALID_CURSOR',
76
+ 'PLAN_CATALOGUE_DRAFT_STALE',
77
+ 'IDEMPOTENCY_CONFLICT',
78
+ ]);
56
79
  /** Whether `value` names a paid tier — narrows an untyped read (a stored row, a global) to `PaidPlanTier`. */
57
80
  export const isPaidPlanTier = (value) => typeof value === 'string' && PAID_PLAN_TIERS.includes(value);
58
81
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.721",
3
+ "version": "1.10.722",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",