@percher/core 1.0.3 → 1.2.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.
- package/dist/appstore-artifacts.d.ts +2 -2
- package/dist/appstore-artifacts.d.ts.map +1 -1
- package/dist/appstore-artifacts.js +22 -8
- package/dist/appstore-artifacts.js.map +1 -1
- package/dist/commands/analytics.d.ts +1 -0
- package/dist/commands/analytics.d.ts.map +1 -1
- package/dist/commands/billing.d.ts +3 -8
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +14 -9
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/data.d.ts +1 -2
- package/dist/commands/data.d.ts.map +1 -1
- package/dist/commands/data.js +10 -1
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +56 -35
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +13 -2
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/migrate-supabase-sdk.js +1 -1
- package/dist/commands/migrate-supabase-sdk.js.map +1 -1
- package/dist/commands/migrate-supabase-status.js +2 -1
- package/dist/commands/migrate-supabase-status.js.map +1 -1
- package/dist/commands/publish-api-error.d.ts +13 -0
- package/dist/commands/publish-api-error.d.ts.map +1 -1
- package/dist/commands/publish-api-error.js +4 -32
- package/dist/commands/publish-api-error.js.map +1 -1
- package/dist/commands/publish-failure.d.ts.map +1 -1
- package/dist/commands/publish-failure.js +5 -1
- package/dist/commands/publish-failure.js.map +1 -1
- package/dist/commands/publish-in-flight.d.ts +23 -0
- package/dist/commands/publish-in-flight.d.ts.map +1 -0
- package/dist/commands/publish-in-flight.js +33 -0
- package/dist/commands/publish-in-flight.js.map +1 -0
- package/dist/commands/publish-node.d.ts +7 -0
- package/dist/commands/publish-node.d.ts.map +1 -1
- package/dist/commands/publish-node.js +30 -0
- package/dist/commands/publish-node.js.map +1 -1
- package/dist/commands/publish-rate-limit.d.ts +11 -0
- package/dist/commands/publish-rate-limit.d.ts.map +1 -0
- package/dist/commands/publish-rate-limit.js +62 -0
- package/dist/commands/publish-rate-limit.js.map +1 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +16 -46
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/rollback.d.ts.map +1 -1
- package/dist/commands/rollback.js +21 -14
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/versions.d.ts +6 -0
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/wait-deploy.d.ts.map +1 -1
- package/dist/commands/wait-deploy.js +5 -3
- package/dist/commands/wait-deploy.js.map +1 -1
- package/dist/env-scan-source.d.ts +2 -1
- package/dist/env-scan-source.d.ts.map +1 -1
- package/dist/env-scan-source.js +9 -4
- package/dist/env-scan-source.js.map +1 -1
- package/dist/error-classifier.d.ts +1 -1
- package/dist/error-classifier.d.ts.map +1 -1
- package/dist/error-classifier.js +13 -0
- package/dist/error-classifier.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plans.d.ts +88 -4
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +55 -4
- package/dist/plans.js.map +1 -1
- package/dist/poll-deployment.d.ts +27 -1
- package/dist/poll-deployment.d.ts.map +1 -1
- package/dist/poll-deployment.js +56 -13
- package/dist/poll-deployment.js.map +1 -1
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +23 -27
- package/dist/recovery.js.map +1 -1
- package/dist/static-docker.d.ts +17 -0
- package/dist/static-docker.d.ts.map +1 -1
- package/dist/static-docker.js +51 -4
- package/dist/static-docker.js.map +1 -1
- package/dist/stream-utils.d.ts +0 -1
- package/dist/stream-utils.d.ts.map +1 -1
- package/dist/stream-utils.js +0 -6
- package/dist/stream-utils.js.map +1 -1
- package/dist/structured-error-codes.d.ts +8 -1
- package/dist/structured-error-codes.d.ts.map +1 -1
- package/dist/structured-error-codes.js +40 -0
- package/dist/structured-error-codes.js.map +1 -1
- package/dist/templates/ai-files/claude-md.d.ts.map +1 -1
- package/dist/templates/ai-files/claude-md.js +7 -1
- package/dist/templates/ai-files/claude-md.js.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.d.ts.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.js +7 -1
- package/dist/templates/ai-files/cursor-percher-mdc.js.map +1 -1
- package/package.json +4 -4
- package/templates/astro/Dockerfile +10 -4
- package/templates/capsule/Dockerfile +10 -4
- package/templates/eleventy/Dockerfile +10 -4
- package/templates/hugo/Dockerfile +10 -4
- package/templates/preact/Dockerfile +10 -4
- package/templates/solid/Dockerfile +10 -4
- package/templates/vite-react/Dockerfile +10 -4
- package/templates/vite-vue/Dockerfile +10 -4
package/dist/plans.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
export type PlanId = "free" | "starter" | "maker" | "max" | "anonymous";
|
|
2
|
+
/**
|
|
3
|
+
* Billing term. Spelled the way Polar spells `recurring_interval`, because
|
|
4
|
+
* this value is threaded to Polar's API and persisted verbatim from its
|
|
5
|
+
* subscription payload — translating it on the way in would mean translating
|
|
6
|
+
* it back on the way out, twice, for no gain.
|
|
7
|
+
*
|
|
8
|
+
* The entitlement tier is orthogonal: a `PlanId` never encodes a term, and
|
|
9
|
+
* `starter_annual` is not a plan. Interval decides what the customer pays and
|
|
10
|
+
* when; the tier decides what they get.
|
|
11
|
+
*/
|
|
12
|
+
export type BillingInterval = "month" | "year";
|
|
13
|
+
/** Every valid interval, for boundary validation. */
|
|
14
|
+
export declare const BILLING_INTERVALS: BillingInterval[];
|
|
15
|
+
/** True only for a real billing interval. Use at every API/CLI boundary. */
|
|
16
|
+
export declare function isBillingInterval(value: string): value is BillingInterval;
|
|
2
17
|
/**
|
|
3
18
|
* Disk-pool symmetry (Phase 1) — the disk footprint (MB) charged for
|
|
4
19
|
* a PocketBase app that has no measured volume sample yet. A new PB
|
|
@@ -142,14 +157,83 @@ export interface PlanLimits {
|
|
|
142
157
|
*/
|
|
143
158
|
egressGbPerMonth: number;
|
|
144
159
|
}
|
|
160
|
+
export interface PlanPrice {
|
|
161
|
+
/** Net EUR charged per month on a monthly subscription. */
|
|
162
|
+
monthly: number;
|
|
163
|
+
/**
|
|
164
|
+
* Net EUR charged per year on an annual subscription — 10× monthly, so
|
|
165
|
+
* two months are free. Held as its own number rather than derived from a
|
|
166
|
+
* discount rate: the discount is a lever the business may withdraw, and a
|
|
167
|
+
* computed list price cannot be changed without changing every tier at once.
|
|
168
|
+
*/
|
|
169
|
+
annual: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A plan as 1.0.x published it, plus an optional `price`, so code that builds
|
|
173
|
+
* its own `PlanInfo` keeps compiling. The catalog returns `PricedPlanInfo`.
|
|
174
|
+
*/
|
|
145
175
|
export interface PlanInfo {
|
|
146
176
|
label: string;
|
|
147
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Net EUR product/accounting amounts before VAT or sales tax, per term.
|
|
179
|
+
* NOT a sufficient consumer display on a Swedish surface — those lead with
|
|
180
|
+
* the tax-inclusive total (net × 1.25 at 25% VAT) and may show the net
|
|
181
|
+
* amount only as secondary explanation.
|
|
182
|
+
*/
|
|
183
|
+
price?: PlanPrice;
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated Use `price.monthly`. In the catalog it always equals
|
|
186
|
+
* `price.monthly`.
|
|
187
|
+
*/
|
|
148
188
|
priceEur: number;
|
|
149
189
|
/** Internal tier — never purchasable, never listed on user-facing plan surfaces. */
|
|
150
190
|
hidden?: boolean;
|
|
151
191
|
limits: PlanLimits;
|
|
152
192
|
}
|
|
193
|
+
/** A catalog plan: `price` is always present. */
|
|
194
|
+
export interface PricedPlanInfo extends PlanInfo {
|
|
195
|
+
price: PlanPrice;
|
|
196
|
+
}
|
|
197
|
+
/** The net amount a tier costs for one billing term. */
|
|
198
|
+
export declare function planPrice(info: PricedPlanInfo, interval: BillingInterval): number;
|
|
199
|
+
/**
|
|
200
|
+
* Whether a plan change takes effect at once or at the end of the period the
|
|
201
|
+
* customer has already paid for. `upgrade` prorates; `downgrade` defers.
|
|
202
|
+
*
|
|
203
|
+
* Lives here, next to the catalog it reads, because BOTH the API and the
|
|
204
|
+
* dashboard need the same answer. The API sends it to Polar; the UI has to
|
|
205
|
+
* tell the person what is about to happen, and a checkout screen promising an
|
|
206
|
+
* immediate start for a change that defers collects consent evidence which
|
|
207
|
+
* contradicts the transaction it exists to evidence.
|
|
208
|
+
*
|
|
209
|
+
* - A SHRINKING tier always defers, whatever the term does. A hosting plan
|
|
210
|
+
* that loses capacity the instant someone clicks would pull RAM out from
|
|
211
|
+
* under apps inside a period the customer has already paid for.
|
|
212
|
+
* - Otherwise month → year prorates: they are committing to more, and get the
|
|
213
|
+
* annual rate at once.
|
|
214
|
+
* - Otherwise year → month defers: the year is already collected, so the
|
|
215
|
+
* smaller commitment starts when that year ends.
|
|
216
|
+
* - Same term, same-or-larger tier: prorate only if the bill actually grows.
|
|
217
|
+
*
|
|
218
|
+
* Tier size is measured by the MONTHLY price — a term-independent measure of
|
|
219
|
+
* how big a tier is. Comparing a €290 annual against a €12 monthly would read
|
|
220
|
+
* every switch to annual as an upgrade, including Max → Starter.
|
|
221
|
+
*/
|
|
222
|
+
export declare function planChangeDirection(from: {
|
|
223
|
+
plan: string;
|
|
224
|
+
interval: BillingInterval;
|
|
225
|
+
}, to: {
|
|
226
|
+
plan: string;
|
|
227
|
+
interval: BillingInterval;
|
|
228
|
+
}): "upgrade" | "downgrade" | "unchanged";
|
|
229
|
+
/** True when a change applies at once rather than at the next period. */
|
|
230
|
+
export declare function planChangeIsImmediate(from: {
|
|
231
|
+
plan: string;
|
|
232
|
+
interval: BillingInterval;
|
|
233
|
+
}, to: {
|
|
234
|
+
plan: string;
|
|
235
|
+
interval: BillingInterval;
|
|
236
|
+
}): boolean;
|
|
153
237
|
/**
|
|
154
238
|
* Pool sizes are derived from `docs/operations/capacity-model.md`'s
|
|
155
239
|
* "Konkreta startpooler" table. They are the *sellable* totals per
|
|
@@ -161,7 +245,7 @@ export interface PlanInfo {
|
|
|
161
245
|
* `apps` is a hard cap (anti-abuse backstop) enforced at app-create;
|
|
162
246
|
* pool dimensions are the load-bearing constraint.
|
|
163
247
|
*/
|
|
164
|
-
export declare const PLAN_CATALOG: Record<PlanId,
|
|
248
|
+
export declare const PLAN_CATALOG: Record<PlanId, PricedPlanInfo>;
|
|
165
249
|
/** Internal enumeration — every tier incl. hidden ones (anonymous). */
|
|
166
250
|
export declare const ALL_PLAN_IDS: PlanId[];
|
|
167
251
|
/**
|
|
@@ -177,12 +261,12 @@ export declare function isPublicPlanId(plan: string): plan is PlanId;
|
|
|
177
261
|
/** Look up plan limits, defaulting to free for unknown plan ids */
|
|
178
262
|
export declare function getPlanLimits(plan: string): PlanLimits;
|
|
179
263
|
/** Look up full plan info, defaulting to free for unknown plan ids */
|
|
180
|
-
export declare function getPlanInfo(plan: string):
|
|
264
|
+
export declare function getPlanInfo(plan: string): PricedPlanInfo;
|
|
181
265
|
/**
|
|
182
266
|
* Plan limits with admin-role bypass applied.
|
|
183
267
|
*
|
|
184
268
|
* Admin users (those whose email is in `PERCHER_ADMIN_EMAILS`) get
|
|
185
|
-
* max-tier resource ceilings — memory, CPU, instances, storage —
|
|
269
|
+
* all max-tier features and resource ceilings — memory, CPU, instances, storage —
|
|
186
270
|
* plus `Number.POSITIVE_INFINITY` for every cap that would otherwise
|
|
187
271
|
* cause platform-driven friction when they're operating the
|
|
188
272
|
* platform: app count, deploy rate, preview slots, custom domains,
|
package/dist/plans.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../src/plans.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,WAAW,CAAC;AAExE;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;wBACnB,CAAC;mBACN,EAAE;sBACC,GAAG;oBACL,IAAI;kBACN,IAAI;CACgC,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,+FAA+F;IAC/F,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,eAAe,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,gBAAgB,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;OAaG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;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E,MAAM,GAAG,cAAc,CAExD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,UAAU,CA2ChF"}
|
package/dist/plans.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** Every valid interval, for boundary validation. */
|
|
2
|
+
export const BILLING_INTERVALS = ["month", "year"];
|
|
3
|
+
/** True only for a real billing interval. Use at every API/CLI boundary. */
|
|
4
|
+
export function isBillingInterval(value) {
|
|
5
|
+
return BILLING_INTERVALS.includes(value);
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* Disk-pool symmetry (Phase 1) — the disk footprint (MB) charged for
|
|
3
9
|
* a PocketBase app that has no measured volume sample yet. A new PB
|
|
@@ -25,6 +31,48 @@ export const EGRESS_GB_PER_MONTH = {
|
|
|
25
31
|
maker: 1000,
|
|
26
32
|
max: 2500,
|
|
27
33
|
};
|
|
34
|
+
/** The net amount a tier costs for one billing term. */
|
|
35
|
+
export function planPrice(info, interval) {
|
|
36
|
+
return interval === "year" ? info.price.annual : info.price.monthly;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether a plan change takes effect at once or at the end of the period the
|
|
40
|
+
* customer has already paid for. `upgrade` prorates; `downgrade` defers.
|
|
41
|
+
*
|
|
42
|
+
* Lives here, next to the catalog it reads, because BOTH the API and the
|
|
43
|
+
* dashboard need the same answer. The API sends it to Polar; the UI has to
|
|
44
|
+
* tell the person what is about to happen, and a checkout screen promising an
|
|
45
|
+
* immediate start for a change that defers collects consent evidence which
|
|
46
|
+
* contradicts the transaction it exists to evidence.
|
|
47
|
+
*
|
|
48
|
+
* - A SHRINKING tier always defers, whatever the term does. A hosting plan
|
|
49
|
+
* that loses capacity the instant someone clicks would pull RAM out from
|
|
50
|
+
* under apps inside a period the customer has already paid for.
|
|
51
|
+
* - Otherwise month → year prorates: they are committing to more, and get the
|
|
52
|
+
* annual rate at once.
|
|
53
|
+
* - Otherwise year → month defers: the year is already collected, so the
|
|
54
|
+
* smaller commitment starts when that year ends.
|
|
55
|
+
* - Same term, same-or-larger tier: prorate only if the bill actually grows.
|
|
56
|
+
*
|
|
57
|
+
* Tier size is measured by the MONTHLY price — a term-independent measure of
|
|
58
|
+
* how big a tier is. Comparing a €290 annual against a €12 monthly would read
|
|
59
|
+
* every switch to annual as an upgrade, including Max → Starter.
|
|
60
|
+
*/
|
|
61
|
+
export function planChangeDirection(from, to) {
|
|
62
|
+
if (from.plan === to.plan && from.interval === to.interval)
|
|
63
|
+
return "unchanged";
|
|
64
|
+
const fromTier = PLAN_CATALOG[from.plan]?.price.monthly ?? 0;
|
|
65
|
+
const toTier = PLAN_CATALOG[to.plan]?.price.monthly ?? 0;
|
|
66
|
+
if (toTier < fromTier)
|
|
67
|
+
return "downgrade";
|
|
68
|
+
if (from.interval !== to.interval)
|
|
69
|
+
return to.interval === "year" ? "upgrade" : "downgrade";
|
|
70
|
+
return toTier > fromTier ? "upgrade" : "downgrade";
|
|
71
|
+
}
|
|
72
|
+
/** True when a change applies at once rather than at the next period. */
|
|
73
|
+
export function planChangeIsImmediate(from, to) {
|
|
74
|
+
return planChangeDirection(from, to) === "upgrade";
|
|
75
|
+
}
|
|
28
76
|
/**
|
|
29
77
|
* Pool sizes are derived from `docs/operations/capacity-model.md`'s
|
|
30
78
|
* "Konkreta startpooler" table. They are the *sellable* totals per
|
|
@@ -39,6 +87,7 @@ export const EGRESS_GB_PER_MONTH = {
|
|
|
39
87
|
export const PLAN_CATALOG = {
|
|
40
88
|
free: {
|
|
41
89
|
label: "Free",
|
|
90
|
+
price: { monthly: 0, annual: 0 },
|
|
42
91
|
priceEur: 0,
|
|
43
92
|
limits: {
|
|
44
93
|
// Owner decision 2026-09-16: Free promises TWO apps, not three. The
|
|
@@ -81,7 +130,8 @@ export const PLAN_CATALOG = {
|
|
|
81
130
|
},
|
|
82
131
|
starter: {
|
|
83
132
|
label: "Starter",
|
|
84
|
-
|
|
133
|
+
price: { monthly: 4, annual: 40 },
|
|
134
|
+
priceEur: 4,
|
|
85
135
|
limits: {
|
|
86
136
|
apps: 10,
|
|
87
137
|
deploysPerHour: 30,
|
|
@@ -123,6 +173,7 @@ export const PLAN_CATALOG = {
|
|
|
123
173
|
},
|
|
124
174
|
maker: {
|
|
125
175
|
label: "Maker",
|
|
176
|
+
price: { monthly: 12, annual: 120 },
|
|
126
177
|
priceEur: 12,
|
|
127
178
|
limits: {
|
|
128
179
|
apps: 20,
|
|
@@ -171,6 +222,7 @@ export const PLAN_CATALOG = {
|
|
|
171
222
|
max: {
|
|
172
223
|
// Public label and entitlement/API identifier intentionally share one name.
|
|
173
224
|
label: "Max",
|
|
225
|
+
price: { monthly: 29, annual: 290 },
|
|
174
226
|
priceEur: 29,
|
|
175
227
|
limits: {
|
|
176
228
|
apps: 40,
|
|
@@ -220,6 +272,7 @@ export const PLAN_CATALOG = {
|
|
|
220
272
|
},
|
|
221
273
|
anonymous: {
|
|
222
274
|
label: "Anonymous",
|
|
275
|
+
price: { monthly: 0, annual: 0 },
|
|
223
276
|
priceEur: 0,
|
|
224
277
|
hidden: true,
|
|
225
278
|
limits: {
|
|
@@ -281,7 +334,7 @@ export function getPlanInfo(plan) {
|
|
|
281
334
|
* Plan limits with admin-role bypass applied.
|
|
282
335
|
*
|
|
283
336
|
* Admin users (those whose email is in `PERCHER_ADMIN_EMAILS`) get
|
|
284
|
-
* max-tier resource ceilings — memory, CPU, instances, storage —
|
|
337
|
+
* all max-tier features and resource ceilings — memory, CPU, instances, storage —
|
|
285
338
|
* plus `Number.POSITIVE_INFINITY` for every cap that would otherwise
|
|
286
339
|
* cause platform-driven friction when they're operating the
|
|
287
340
|
* platform: app count, deploy rate, preview slots, custom domains,
|
|
@@ -307,8 +360,6 @@ export function getEffectivePlanLimits(plan, isAdmin = false) {
|
|
|
307
360
|
const INF = Number.POSITIVE_INFINITY;
|
|
308
361
|
return {
|
|
309
362
|
...max,
|
|
310
|
-
// Resource exemptions do not grant paid visitor analytics access.
|
|
311
|
-
visitorAnalytics: getPlanLimits(plan).visitorAnalytics,
|
|
312
363
|
apps: INF,
|
|
313
364
|
deploysPerHour: INF,
|
|
314
365
|
dailyLiveDeploys: INF,
|
package/dist/plans.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plans.js","sourceRoot":"","sources":["../src/plans.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plans.js","sourceRoot":"","sources":["../src/plans.ts"],"names":[],"mappings":"AAcA,qDAAqD;AACrD,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAEtE,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAQ,iBAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,SAAS,EAAE,CAAC;IACZ,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,GAAG;IACZ,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;CACgC,CAAC;AA+J5C,wDAAwD;AACxD,MAAM,UAAU,SAAS,CAAC,IAAoB,EAAE,QAAyB;IACvE,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiD,EACjD,EAA+C;IAE/C,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,CAAC,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;QAChB,6DAA6D;QAC7D,6DAA6D;QAC7D,wDAAwD;QACxD,0BAA0B;QAC1B,SAAS,EAAE,GAAG;QACd,QAAQ,EAAE,GAAG;QACb,UAAU,EAAE,GAAG;QACf,uEAAuE;QACvE,gBAAgB,EAAE,GAAG;QACrB,mEAAmE;QACnE,gEAAgE;QAChE,2DAA2D;KAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DeployEvent } from "@percher/client";
|
|
2
2
|
import type { Context } from "./context.js";
|
|
3
|
+
import { PercherCoreError } from "./errors.js";
|
|
3
4
|
export interface DeploymentLike {
|
|
4
5
|
id: string;
|
|
5
6
|
status: string;
|
|
@@ -31,8 +32,15 @@ export interface PollDeploymentOptions<D extends DeploymentLike> {
|
|
|
31
32
|
onTimeout: (deployment: D) => never;
|
|
32
33
|
/** App display name, used in the network-error hint message. */
|
|
33
34
|
appName: string;
|
|
34
|
-
/** Maximum consecutive transient failures before giving up (default
|
|
35
|
+
/** Maximum consecutive transient failures before giving up (default: no
|
|
36
|
+
* count limit, only {@link retryBudgetMs}). */
|
|
35
37
|
maxRetries?: number;
|
|
38
|
+
/**
|
|
39
|
+
* How long one streak of transient failures may last before giving up
|
|
40
|
+
* (default 5 minutes). A platform deploy recreates the API for about that
|
|
41
|
+
* long, and the deploy being polled keeps running through it.
|
|
42
|
+
*/
|
|
43
|
+
retryBudgetMs?: number;
|
|
36
44
|
/**
|
|
37
45
|
* Backoff (ms) before retry attempt N (1-indexed). Default doubles
|
|
38
46
|
* from 1s: 1000, 2000, 4000, 8000. Tests inject `() => 0` to skip
|
|
@@ -40,6 +48,24 @@ export interface PollDeploymentOptions<D extends DeploymentLike> {
|
|
|
40
48
|
*/
|
|
41
49
|
backoffMs?: (attempt: number) => number;
|
|
42
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when polling lost contact with the API for longer than the retry
|
|
53
|
+
* budget. The deploy was created and is probably still running; the caller
|
|
54
|
+
* reports it as such, with its id, rather than as a failure.
|
|
55
|
+
*/
|
|
56
|
+
export declare class DeployPollLostContactError extends PercherCoreError {
|
|
57
|
+
readonly deploymentId: string;
|
|
58
|
+
constructor(message: string, deploymentId: string, appName: string, options?: {
|
|
59
|
+
cause?: unknown;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A failure that says nothing about the deploy: the connection dropped, or
|
|
64
|
+
* the edge answered 502/503/504 because the API was restarting, or a 429 asked
|
|
65
|
+
* the poll to slow down. Not a 500,
|
|
66
|
+
* which the API itself returns for a real failure (BUILD_FAILED and others).
|
|
67
|
+
*/
|
|
68
|
+
export declare function isTransientPollError(err: unknown): boolean;
|
|
43
69
|
/**
|
|
44
70
|
* Poll `getDeployment` until the deployment reaches a terminal status.
|
|
45
71
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-deployment.d.ts","sourceRoot":"","sources":["../src/poll-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"poll-deployment.d.ts","sourceRoot":"","sources":["../src/poll-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAA4C,MAAM,iBAAiB,CAAC;AAE7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,cAAc;IAC7D,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;IACX,uEAAuE;IACvE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;2DAEuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,IAAI,CAAC;IACjC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,gEAAgE;IAChE,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,KAAK,CAAC;IACpC,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB;oDACgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACzC;AAED;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,gBAAgB;IAG5D,QAAQ,CAAC,YAAY,EAAE,MAAM;IAF/B,YACE,OAAO,EAAE,MAAM,EACN,YAAY,EAAE,MAAM,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAQ9B;CACF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAQ1D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,cAAc,EAC3D,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC,CA4EZ"}
|
package/dist/poll-deployment.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
import { isTransientNetworkError } from "@percher/client";
|
|
1
|
+
import { isTransientNetworkError, PercherApiError } from "@percher/client";
|
|
2
2
|
import { TIMEOUTS } from "@percher/shared/timeouts";
|
|
3
|
+
import { PercherCoreError } from "./errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when polling lost contact with the API for longer than the retry
|
|
6
|
+
* budget. The deploy was created and is probably still running; the caller
|
|
7
|
+
* reports it as such, with its id, rather than as a failure.
|
|
8
|
+
*/
|
|
9
|
+
export class DeployPollLostContactError extends PercherCoreError {
|
|
10
|
+
deploymentId;
|
|
11
|
+
constructor(message, deploymentId, appName, options) {
|
|
12
|
+
super(message, {
|
|
13
|
+
code: "push.lost-contact",
|
|
14
|
+
hint: `The deploy may already be live. Check with: percher deploys ${appName}`,
|
|
15
|
+
cause: options?.cause,
|
|
16
|
+
});
|
|
17
|
+
this.deploymentId = deploymentId;
|
|
18
|
+
this.name = "DeployPollLostContactError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A failure that says nothing about the deploy: the connection dropped, or
|
|
23
|
+
* the edge answered 502/503/504 because the API was restarting, or a 429 asked
|
|
24
|
+
* the poll to slow down. Not a 500,
|
|
25
|
+
* which the API itself returns for a real failure (BUILD_FAILED and others).
|
|
26
|
+
*/
|
|
27
|
+
export function isTransientPollError(err) {
|
|
28
|
+
if (isTransientNetworkError(err))
|
|
29
|
+
return true;
|
|
30
|
+
// A 429 on a status read means "slow down": the deploy exists and keeps
|
|
31
|
+
// going, so reporting it as failed invites a duplicate publish.
|
|
32
|
+
if (err instanceof PercherApiError)
|
|
33
|
+
return err.status === 429 || err.status === 502 || err.status === 503 || err.status === 504;
|
|
34
|
+
// A body cut off mid-read when the API is recreated (Node's undici).
|
|
35
|
+
return err instanceof TypeError && /terminated/i.test(err.message);
|
|
36
|
+
}
|
|
3
37
|
/**
|
|
4
38
|
* Poll `getDeployment` until the deployment reaches a terminal status.
|
|
5
39
|
*
|
|
@@ -19,7 +53,8 @@ export async function pollDeployment(opts) {
|
|
|
19
53
|
const terminal = opts.terminal ?? ["live", "failed"];
|
|
20
54
|
const intervalMs = opts.intervalMs ?? 2000;
|
|
21
55
|
const timeoutMs = opts.timeoutMs ?? TIMEOUTS.clientPublishPoll;
|
|
22
|
-
const maxRetries = opts.maxRetries ??
|
|
56
|
+
const maxRetries = opts.maxRetries ?? Number.POSITIVE_INFINITY;
|
|
57
|
+
const retryBudgetMs = opts.retryBudgetMs ?? 5 * 60_000;
|
|
23
58
|
let deployment = opts.initial;
|
|
24
59
|
const startedAt = Date.now();
|
|
25
60
|
const seenEventIds = new Set();
|
|
@@ -37,6 +72,7 @@ export async function pollDeployment(opts) {
|
|
|
37
72
|
opts.onTick?.(deployment);
|
|
38
73
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
39
74
|
let attempt = 0;
|
|
75
|
+
let streakStartedAt = 0;
|
|
40
76
|
let polled = false;
|
|
41
77
|
while (!polled) {
|
|
42
78
|
try {
|
|
@@ -45,19 +81,26 @@ export async function pollDeployment(opts) {
|
|
|
45
81
|
}
|
|
46
82
|
catch (err) {
|
|
47
83
|
attempt++;
|
|
48
|
-
|
|
49
|
-
if (!isNetwork || attempt >= maxRetries) {
|
|
50
|
-
if (isNetwork) {
|
|
51
|
-
// Surface a more helpful message than the bare network
|
|
52
|
-
// error: the deploy may have completed server-side
|
|
53
|
-
// already, and a direct check is one CLI invocation away.
|
|
54
|
-
const msg = err.message ?? String(err);
|
|
55
|
-
throw new Error(`${msg}\n\nThe deploy may already be live — your network connection dropped mid-poll. Check with: percher deploys ${opts.appName}`, { cause: err });
|
|
56
|
-
}
|
|
84
|
+
if (!isTransientPollError(err))
|
|
57
85
|
throw err;
|
|
86
|
+
if (attempt === 1) {
|
|
87
|
+
streakStartedAt = Date.now();
|
|
88
|
+
// A streak can last minutes; say so rather than go quiet.
|
|
89
|
+
opts.ctx.status(err instanceof PercherApiError && err.status === 429
|
|
90
|
+
? "Percher asked this client to slow down; retrying while the deploy continues..."
|
|
91
|
+
: "Lost contact with Percher; retrying while the deploy continues...");
|
|
92
|
+
}
|
|
93
|
+
// The streak never outlasts the poll's own budget.
|
|
94
|
+
if (Date.now() - startedAt > timeoutMs)
|
|
95
|
+
opts.onTimeout(deployment);
|
|
96
|
+
if (attempt >= maxRetries || Date.now() - streakStartedAt >= retryBudgetMs) {
|
|
97
|
+
// The deploy may have completed server-side already, and a direct
|
|
98
|
+
// check is one CLI invocation away.
|
|
99
|
+
const msg = err.message ?? String(err);
|
|
100
|
+
throw new DeployPollLostContactError(`${msg}\n\nThe deploy may already be live — contact with Percher was lost mid-poll. Check with: percher deploys ${opts.appName}`, deployment.id, opts.appName, { cause: err });
|
|
58
101
|
}
|
|
59
|
-
// Backoff: 1s, 2s, 4s, 8s
|
|
60
|
-
const backoff = (opts.backoffMs ?? ((n) => 1000 * 2 ** (n - 1)))(attempt);
|
|
102
|
+
// Backoff: 1s, 2s, 4s, 8s, then every 15s, by default.
|
|
103
|
+
const backoff = (opts.backoffMs ?? ((n) => Math.min(1000 * 2 ** (n - 1), 15_000)))(attempt);
|
|
61
104
|
await new Promise((r) => setTimeout(r, backoff));
|
|
62
105
|
}
|
|
63
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-deployment.js","sourceRoot":"","sources":["../src/poll-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"poll-deployment.js","sourceRoot":"","sources":["../src/poll-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAmD5C;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,gBAAgB;IAGnD,YAAY;IAFvB,YACE,OAAe,EACN,YAAoB,EAC7B,OAAe,EACf,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE;YACb,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,+DAA+D,OAAO,EAAE;YA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AC,OAAO;QAAE,OAAO;IAC1B,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAAE,SAAS;YACzC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;IACpE,CAAC;AACH,CAAC"}
|
package/dist/recovery.d.ts
CHANGED
|
@@ -157,7 +157,9 @@ export type ReasonCode =
|
|
|
157
157
|
/** Likely-transient infra issue (network, image registry, etc). */
|
|
158
158
|
| "infra_transient"
|
|
159
159
|
/** Hard infra outage — Percher can't deploy at all right now. */
|
|
160
|
-
| "infra_unavailable"
|
|
160
|
+
| "infra_unavailable" | "pb_provision_failed"
|
|
161
|
+
/** Platform build-secret protection requires an operator or config change. */
|
|
162
|
+
| "build_secrets_unavailable"
|
|
161
163
|
/** Build log isn't in storage yet (deploy too fresh). */
|
|
162
164
|
| "log_unavailable_yet"
|
|
163
165
|
/** Build log fetch errored (transport / encoding / size cap). */
|
package/dist/recovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,OA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E,YAAY,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAKD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,GAAG,OAAO,CAExD;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,YAAY,GAAG,eAAe,CAqB9E;AAED;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,OAAO,GAAG,eAAe,CAkD1E;AA2BD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,cAAc,GACtB,eAAe,CA0KjB"}
|
package/dist/recovery.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TIMEOUTS } from "@percher/shared/timeouts";
|
|
2
|
+
import { PB_PROVISION_FAILED_ASK } from "./structured-error-codes.js";
|
|
2
3
|
import { appRef, boundedLine, envKeyList, idToken, isSafeRelativePath } from "./untrusted.js";
|
|
3
4
|
// ── Builders ─────────────────────────────────────────────────────────
|
|
4
5
|
//
|
|
@@ -282,9 +283,9 @@ const BUILD_PROBLEM_CODE = /^[a-z][a-z0-9-]{0,63}$/;
|
|
|
282
283
|
* rather than re-implementing it.
|
|
283
284
|
*/
|
|
284
285
|
export function buildProblemToRecoveryProblem(p) {
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
const file = p.file
|
|
286
|
+
// Callers filter through `hasEditableFile`; the builder checks again, since
|
|
287
|
+
// an agent is told to open this file.
|
|
288
|
+
const file = isSafeRelativePath(p.file) ? p.file : "";
|
|
288
289
|
const code = BUILD_PROBLEM_CODE.test(p.code) ? p.code : "build";
|
|
289
290
|
// Bounded: an agent is told to open this file at this line, and a forged
|
|
290
291
|
// problem could otherwise point it at line -1 or 1e308.
|
|
@@ -408,6 +409,15 @@ function unprovenPlatformClaim(failure) {
|
|
|
408
409
|
*/
|
|
409
410
|
export function recoveryFromErrorClass(errorClass, failure) {
|
|
410
411
|
switch (errorClass) {
|
|
412
|
+
case "build_secrets_unavailable":
|
|
413
|
+
return recoveryAsk({
|
|
414
|
+
prompt: "Percher cannot protect build secrets for this build. Should I remove the non-public keys from [build] pass_env and publish again, or wait and publish later?",
|
|
415
|
+
options: [
|
|
416
|
+
"remove non-public keys from [build] pass_env and publish again",
|
|
417
|
+
"wait and publish later",
|
|
418
|
+
],
|
|
419
|
+
reasonCode: "build_secrets_unavailable",
|
|
420
|
+
});
|
|
411
421
|
case "missing_env":
|
|
412
422
|
return recoveryEnv({
|
|
413
423
|
// Thread the app through so the agent calls percher_env_set on the
|
|
@@ -416,43 +426,29 @@ export function recoveryFromErrorClass(errorClass, failure) {
|
|
|
416
426
|
keys: failure.missingEnvVars ?? [],
|
|
417
427
|
reasonCode: "missing_env",
|
|
418
428
|
});
|
|
419
|
-
// The
|
|
420
|
-
//
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
429
|
+
// "The platform's, go again" classes count only when the platform SAID so (`classSource`):
|
|
430
|
+
// advising a retry the failure-loop guard counts gets apps suspended on Percher's advice.
|
|
431
|
+
case "pb_provision_failed":
|
|
432
|
+
if (failure.classSource !== "code")
|
|
433
|
+
return unprovenPlatformClaim(failure);
|
|
434
|
+
return recoveryAsk(PB_PROVISION_FAILED_ASK);
|
|
425
435
|
case "infra_unavailable":
|
|
426
436
|
if (failure.classSource !== "code")
|
|
427
437
|
return unprovenPlatformClaim(failure);
|
|
428
438
|
return retryKnownPublish(failure, "infra_unavailable");
|
|
429
439
|
case "platform_at_capacity":
|
|
430
|
-
//
|
|
431
|
-
// limit (the host is full right now), not the app's fault. Hand the
|
|
432
|
-
// agent the same retry recovery as infra_unavailable so it re-issues
|
|
433
|
-
// the publish once capacity frees up, instead of falling through to
|
|
434
|
-
// the generic ask_user/doctor path. reasonCode `infra_transient`
|
|
435
|
-
// (retryable) keeps it distinct from a hard infra outage. The guard
|
|
436
|
-
// excludes this class only when it arrives as a code, which is exactly
|
|
437
|
-
// the condition this branch is gated on — so a retry issued here cannot
|
|
438
|
-
// feed the streak.
|
|
440
|
+
// Transient fullness: retry only from a code, which exempts the suspension streak.
|
|
439
441
|
if (failure.classSource !== "code")
|
|
440
442
|
return unprovenPlatformClaim(failure);
|
|
441
443
|
return retryKnownPublish(failure, "infra_transient");
|
|
442
444
|
case "pb_operation_busy":
|
|
443
|
-
//
|
|
444
|
-
// remains app-attributable. The operation is nevertheless transient and
|
|
445
|
-
// a later publish is the correct action once it finishes. Only accept
|
|
446
|
-
// the structured code: prose can come from tenant output.
|
|
445
|
+
// App-attributable but transient; only a code (never tenant prose) authorizes a retry.
|
|
447
446
|
if (failure.classSource !== "code")
|
|
448
447
|
return unprovenPlatformClaim(failure);
|
|
449
448
|
return retryKnownPublish(failure, "infra_transient");
|
|
450
449
|
case "plan_pool_exceeded":
|
|
451
|
-
//
|
|
452
|
-
//
|
|
453
|
-
// the user's quota. The options are the user's to choose — but the
|
|
454
|
-
// platform now knows WHICH of their apps is holding the allowance, so
|
|
455
|
-
// the question names them and the sleep is one call away.
|
|
450
|
+
// The account needs room before publishing can succeed. The owner
|
|
451
|
+
// chooses how; name the blocking apps and offer sleep as an action.
|
|
456
452
|
return recoveryPoolExceeded(failure.poolBlockers);
|
|
457
453
|
case "app_data_mount_conflict":
|
|
458
454
|
// Not `fix_problems`: which file to change depends on the project — a
|