@aglyn/aglyn 1.25.0 → 1.26.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/package.json +11 -11
- package/src/lib/app-utils/bandwidth-cap.d.ts +99 -1
- package/src/lib/app-utils/bandwidth-cap.js +148 -4
- package/src/lib/app-utils/bandwidth-cap.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +67 -4
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/notifications.js +5 -0
- package/src/lib/app-utils/notifications.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.js +4 -2
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/sign-in-hint-cookie.d.ts +58 -0
- package/src/lib/app-utils/sign-in-hint-cookie.js +71 -0
- package/src/lib/app-utils/sign-in-hint-cookie.js.map +1 -0
- package/src/lib/app-utils/sign-in-visibility.d.ts +1 -4
- package/src/lib/app-utils/sign-in-visibility.js +4 -4
- package/src/lib/app-utils/sign-in-visibility.js.map +1 -1
- package/src/lib/foundation/definitions/org-billing.types.d.ts +21 -0
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +9 -0
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/aglyn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@aglyn/shared-data-enums": "1.
|
|
41
|
-
"@aglyn/shared-data-mdi": "1.
|
|
42
|
-
"@aglyn/shared-data-types": "1.
|
|
43
|
-
"@aglyn/shared-util-email": "1.
|
|
44
|
-
"@aglyn/shared-util-first-touch": "1.
|
|
45
|
-
"@aglyn/shared-util-http": "1.
|
|
46
|
-
"@aglyn/shared-util-logger": "1.
|
|
47
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
48
|
-
"@aglyn/shared-util-tools": "1.
|
|
49
|
-
"@aglyn/shared-util-vendor": "1.
|
|
40
|
+
"@aglyn/shared-data-enums": "1.26.0",
|
|
41
|
+
"@aglyn/shared-data-mdi": "1.26.0",
|
|
42
|
+
"@aglyn/shared-data-types": "1.26.0",
|
|
43
|
+
"@aglyn/shared-util-email": "1.26.0",
|
|
44
|
+
"@aglyn/shared-util-first-touch": "1.26.0",
|
|
45
|
+
"@aglyn/shared-util-http": "1.26.0",
|
|
46
|
+
"@aglyn/shared-util-logger": "1.26.0",
|
|
47
|
+
"@aglyn/shared-util-timestamp": "1.26.0",
|
|
48
|
+
"@aglyn/shared-util-tools": "1.26.0",
|
|
49
|
+
"@aglyn/shared-util-vendor": "1.26.0",
|
|
50
50
|
"@data-driven-forms/react-form-renderer": "^4.2.3",
|
|
51
51
|
"@msgpack/msgpack": "^3.1.3",
|
|
52
52
|
"@types/unist": "^3.0.3",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
* for, so a new month simply stops matching. A cap whose lift depends on a
|
|
87
87
|
* write is a cap that stays engaged when the writer fails.
|
|
88
88
|
*/
|
|
89
|
-
import type { AglynOrgBilling } from '../foundation';
|
|
89
|
+
import type { AglynOrgBilling, OrgBandwidthCap } from '../foundation';
|
|
90
90
|
/**
|
|
91
91
|
* The month key the marker is stamped with: UTC `YYYY-MM`, the same shape as
|
|
92
92
|
* `utcMonthKey` and the `orgs/{id}/usage/{month}` document id, and the
|
|
@@ -135,6 +135,70 @@ export declare const BANDWIDTH_CAP_RETRY_AFTER_SECONDS = 3600;
|
|
|
135
135
|
* the incident.
|
|
136
136
|
*/
|
|
137
137
|
export declare function bandwidthCapEngaged(org: Partial<AglynOrgBilling> | null | undefined, now?: Date): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* How long the ONE-TIME grace keeps a site online past its band (AGL-4232):
|
|
140
|
+
* the first time a site goes over, ever, it stays up this long so its owner
|
|
141
|
+
* can upgrade before visitors are turned away.
|
|
142
|
+
*/
|
|
143
|
+
export declare const BANDWIDTH_CAP_GRACE_MS: number;
|
|
144
|
+
/**
|
|
145
|
+
* When the grace ends, while one is running for this org this month; `null`
|
|
146
|
+
* when the org is not over its band, is already paused, or never had one.
|
|
147
|
+
* The owner's surfaces read this to say "upgrade or your site pauses on …".
|
|
148
|
+
*/
|
|
149
|
+
export declare function bandwidthCapGraceUntil(org: Partial<AglynOrgBilling> | null | undefined, now?: Date): number | null;
|
|
150
|
+
/**
|
|
151
|
+
* The marker a writer stamps when the cap engages (AGL-1967/2155, AGL-4232):
|
|
152
|
+
* the month and its diagnostics, plus the grace window when the org's sites
|
|
153
|
+
* have never had one. ONE shape for every writer, so a reader cannot tell
|
|
154
|
+
* which of them stamped it.
|
|
155
|
+
*/
|
|
156
|
+
export declare function bandwidthCapMarker(options: {
|
|
157
|
+
month: string;
|
|
158
|
+
nowMs: number;
|
|
159
|
+
pageViews: number;
|
|
160
|
+
includedPageViews: number;
|
|
161
|
+
/** When the grace this engagement carries ends; null for none. */
|
|
162
|
+
graceUntil: number | null;
|
|
163
|
+
}): OrgBandwidthCap;
|
|
164
|
+
/** A grace stamp as stored: epoch ms, or anything else meaning "never". */
|
|
165
|
+
type GraceStamped = {
|
|
166
|
+
bandwidthGraceUsedAt?: unknown;
|
|
167
|
+
} | null | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* The grace an engagement carries (AGL-4232), from the workspace's own stamp
|
|
170
|
+
* (`orgs/{id}.bandwidthGraceUsedAt`) and its sites' stamps as read: a NEW one
|
|
171
|
+
* when neither the workspace nor any of its sites has ever had it, the one
|
|
172
|
+
* ALREADY RUNNING when a stamp is still inside its window (a grace granted on
|
|
173
|
+
* the 29th that runs into the next month), else none.
|
|
174
|
+
*
|
|
175
|
+
* Both stamps are required absent so deleting the site and making a new one
|
|
176
|
+
* does not re-arm it: the grace is given once per workspace's sites.
|
|
177
|
+
*/
|
|
178
|
+
export declare function bandwidthGraceForEngagement(hosts: ReadonlyArray<GraceStamped>, nowMs: number, org?: GraceStamped): {
|
|
179
|
+
graceUntil: number | null;
|
|
180
|
+
grants: boolean;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Whether an org's sites are owed the one-time grace by their own stamps: it
|
|
184
|
+
* has at least one site, and none of them has ever had it
|
|
185
|
+
* (`AglynHost.bandwidthGraceUsedAt`). The workspace's stamp is asked beside
|
|
186
|
+
* it by {@link bandwidthGraceForEngagement}.
|
|
187
|
+
*/
|
|
188
|
+
export declare function bandwidthGraceAvailable(hosts: ReadonlyArray<GraceStamped>): boolean;
|
|
189
|
+
/** When a `YYYY-MM` month ends: midnight UTC on the 1st of the next. */
|
|
190
|
+
export declare function bandwidthCapMonthEndMs(month: string): number;
|
|
191
|
+
/**
|
|
192
|
+
* Whether a grace ends only after the month it was granted in (AGL-4232).
|
|
193
|
+
* Then no pause comes: the new month's count starts at zero, and the site
|
|
194
|
+
* pauses only when it next passes the band, with no grace left.
|
|
195
|
+
*/
|
|
196
|
+
export declare function bandwidthGraceOutlastsMonth(graceUntil: number, month: string): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* The grace deadline as the owner reads it: an unambiguous UTC date and
|
|
199
|
+
* time, e.g. "Thursday, November 19 at 3:04 PM UTC".
|
|
200
|
+
*/
|
|
201
|
+
export declare function formatBandwidthGraceDeadline(ms: number): string;
|
|
138
202
|
/**
|
|
139
203
|
* Should the cap be ENGAGED for this org-month? The writer's half of the
|
|
140
204
|
* question, kept beside the reader's so the two cannot drift apart.
|
|
@@ -159,6 +223,39 @@ export declare function bandwidthCapShouldEngage(options: {
|
|
|
159
223
|
* the two cannot disagree about which plans the cap is for.
|
|
160
224
|
*/
|
|
161
225
|
export declare function bandwidthCapApplies(org: Partial<AglynOrgBilling> | null | undefined): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* The one sentence every grace message carries (AGL-4232): the abuse ceiling
|
|
228
|
+
* stays the cost bound during a grace, so a surge far past the band can still
|
|
229
|
+
* pause the site before the deadline. Said, so the deadline is never a
|
|
230
|
+
* promise the ceiling breaks.
|
|
231
|
+
*/
|
|
232
|
+
export declare const BANDWIDTH_GRACE_SURGE_SENTENCE = "An unusually large surge of traffic can still pause it before then.";
|
|
233
|
+
/**
|
|
234
|
+
* What the OWNER is told when a grace starts (AGL-4232), in the console and by
|
|
235
|
+
* email: the deadline in plain words, with the way past it. `{site}` is
|
|
236
|
+
* filled by the notifier from the site it reads. `used` is the writer's own
|
|
237
|
+
* account of what was used (page views, or traffic including media).
|
|
238
|
+
* `carried` is a grace granted earlier that still runs as the site goes over
|
|
239
|
+
* again in a new month: the same deadline, said again, since it is this
|
|
240
|
+
* month's news.
|
|
241
|
+
*/
|
|
242
|
+
export declare function bandwidthGraceOwnerNotice(options: {
|
|
243
|
+
graceUntil: number;
|
|
244
|
+
/** The `YYYY-MM` the cap engaged for, which decides whether a pause comes. */
|
|
245
|
+
month: string;
|
|
246
|
+
used: string;
|
|
247
|
+
resumesOn: string;
|
|
248
|
+
carried?: boolean;
|
|
249
|
+
}): BandwidthCapNotice;
|
|
250
|
+
/**
|
|
251
|
+
* What the OWNER is told when a site is paused with no grace, or when its
|
|
252
|
+
* grace has ended (AGL-4232): in the console and by email, from whichever
|
|
253
|
+
* writer saw it. `{site}` is filled by the notifier.
|
|
254
|
+
*/
|
|
255
|
+
export declare function bandwidthPausedOwnerNotice(options: {
|
|
256
|
+
used: string;
|
|
257
|
+
resumesOn: string;
|
|
258
|
+
}): BandwidthCapNotice;
|
|
162
259
|
/** What a visitor sees on a capped site. */
|
|
163
260
|
export interface BandwidthCapNotice {
|
|
164
261
|
title: string;
|
|
@@ -192,3 +289,4 @@ export declare function bandwidthCapNotice(): BandwidthCapNotice;
|
|
|
192
289
|
* status discriminates nothing and this code is the whole discriminator.
|
|
193
290
|
*/
|
|
194
291
|
export declare const BANDWIDTH_CAP_CODE = "bandwidth-cap";
|
|
292
|
+
export {};
|
|
@@ -84,7 +84,9 @@
|
|
|
84
84
|
* Nothing ever CLEARS the marker either: it names the month it was written
|
|
85
85
|
* for, so a new month simply stops matching. A cap whose lift depends on a
|
|
86
86
|
* write is a cap that stays engaged when the writer fails.
|
|
87
|
-
*/ import {
|
|
87
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
88
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
89
|
+
import { isCustomPricedPlan, planMetersInfraOverage, resolveEffectivePlan, resolveOrgEntitlements } from "./plan-entitlements.js";
|
|
88
90
|
/**
|
|
89
91
|
* The month key the marker is stamped with: UTC `YYYY-MM`, the same shape as
|
|
90
92
|
* `utcMonthKey` and the `orgs/{id}/usage/{month}` document id, and the
|
|
@@ -138,7 +140,108 @@
|
|
|
138
140
|
if (!Number.isFinite(resolveOrgEntitlements(org).bandwidthGb)) return false;
|
|
139
141
|
const cap = org.bandwidthCap;
|
|
140
142
|
if (!cap || typeof cap !== 'object') return false;
|
|
141
|
-
|
|
143
|
+
if (cap.month !== bandwidthCapMonthKey(now)) return false;
|
|
144
|
+
// The one-time grace (AGL-4232): engaged, but not refusing until it ends.
|
|
145
|
+
// Nothing writes at that moment; every reader re-derives it from the clock.
|
|
146
|
+
return !(typeof cap.graceUntil === 'number' && now.getTime() < cap.graceUntil);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* How long the ONE-TIME grace keeps a site online past its band (AGL-4232):
|
|
150
|
+
* the first time a site goes over, ever, it stays up this long so its owner
|
|
151
|
+
* can upgrade before visitors are turned away.
|
|
152
|
+
*/ export const BANDWIDTH_CAP_GRACE_MS = 72 * 60 * 60 * 1000;
|
|
153
|
+
/**
|
|
154
|
+
* When the grace ends, while one is running for this org this month; `null`
|
|
155
|
+
* when the org is not over its band, is already paused, or never had one.
|
|
156
|
+
* The owner's surfaces read this to say "upgrade or your site pauses on …".
|
|
157
|
+
*/ export function bandwidthCapGraceUntil(org, now = new Date()) {
|
|
158
|
+
const cap = org == null ? void 0 : org.bandwidthCap;
|
|
159
|
+
if (!cap || typeof cap !== 'object' || cap.month !== bandwidthCapMonthKey(now)) return null;
|
|
160
|
+
if (typeof cap.graceUntil !== 'number' || now.getTime() >= cap.graceUntil) return null;
|
|
161
|
+
// Only where the cap would refuse were there no grace: an upgraded org has
|
|
162
|
+
// nothing to be warned about.
|
|
163
|
+
const { graceUntil: _running } = cap, withoutGrace = _object_without_properties_loose(cap, [
|
|
164
|
+
"graceUntil"
|
|
165
|
+
]);
|
|
166
|
+
return bandwidthCapEngaged(_extends({}, org, {
|
|
167
|
+
bandwidthCap: withoutGrace
|
|
168
|
+
}), now) ? cap.graceUntil : null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The marker a writer stamps when the cap engages (AGL-1967/2155, AGL-4232):
|
|
172
|
+
* the month and its diagnostics, plus the grace window when the org's sites
|
|
173
|
+
* have never had one. ONE shape for every writer, so a reader cannot tell
|
|
174
|
+
* which of them stamped it.
|
|
175
|
+
*/ export function bandwidthCapMarker(options) {
|
|
176
|
+
return _extends({
|
|
177
|
+
month: options.month,
|
|
178
|
+
engagedAt: options.nowMs,
|
|
179
|
+
pageViews: Math.round(options.pageViews),
|
|
180
|
+
includedPageViews: Math.round(options.includedPageViews)
|
|
181
|
+
}, options.graceUntil !== null ? {
|
|
182
|
+
graceUntil: options.graceUntil
|
|
183
|
+
} : {});
|
|
184
|
+
}
|
|
185
|
+
const graceStamp = (doc)=>typeof (doc == null ? void 0 : doc.bandwidthGraceUsedAt) === 'number' ? doc.bandwidthGraceUsedAt : 0;
|
|
186
|
+
/**
|
|
187
|
+
* The grace an engagement carries (AGL-4232), from the workspace's own stamp
|
|
188
|
+
* (`orgs/{id}.bandwidthGraceUsedAt`) and its sites' stamps as read: a NEW one
|
|
189
|
+
* when neither the workspace nor any of its sites has ever had it, the one
|
|
190
|
+
* ALREADY RUNNING when a stamp is still inside its window (a grace granted on
|
|
191
|
+
* the 29th that runs into the next month), else none.
|
|
192
|
+
*
|
|
193
|
+
* Both stamps are required absent so deleting the site and making a new one
|
|
194
|
+
* does not re-arm it: the grace is given once per workspace's sites.
|
|
195
|
+
*/ export function bandwidthGraceForEngagement(hosts, nowMs, org) {
|
|
196
|
+
if (bandwidthGraceAvailable(hosts) && graceStamp(org) === 0) {
|
|
197
|
+
return {
|
|
198
|
+
graceUntil: nowMs + BANDWIDTH_CAP_GRACE_MS,
|
|
199
|
+
grants: true
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const latest = Math.max(graceStamp(org), ...hosts.map(graceStamp));
|
|
203
|
+
const running = latest + BANDWIDTH_CAP_GRACE_MS;
|
|
204
|
+
return {
|
|
205
|
+
graceUntil: latest > 0 && nowMs < running ? running : null,
|
|
206
|
+
grants: false
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Whether an org's sites are owed the one-time grace by their own stamps: it
|
|
211
|
+
* has at least one site, and none of them has ever had it
|
|
212
|
+
* (`AglynHost.bandwidthGraceUsedAt`). The workspace's stamp is asked beside
|
|
213
|
+
* it by {@link bandwidthGraceForEngagement}.
|
|
214
|
+
*/ export function bandwidthGraceAvailable(hosts) {
|
|
215
|
+
return hosts.length > 0 && hosts.every((host)=>graceStamp(host) === 0);
|
|
216
|
+
}
|
|
217
|
+
/** When a `YYYY-MM` month ends: midnight UTC on the 1st of the next. */ export function bandwidthCapMonthEndMs(month) {
|
|
218
|
+
const [year, monthIndex] = month.split('-').map(Number);
|
|
219
|
+
return Date.UTC(year, monthIndex, 1);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Whether a grace ends only after the month it was granted in (AGL-4232).
|
|
223
|
+
* Then no pause comes: the new month's count starts at zero, and the site
|
|
224
|
+
* pauses only when it next passes the band, with no grace left.
|
|
225
|
+
*/ export function bandwidthGraceOutlastsMonth(graceUntil, month) {
|
|
226
|
+
return graceUntil >= bandwidthCapMonthEndMs(month);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The grace deadline as the owner reads it: an unambiguous UTC date and
|
|
230
|
+
* time, e.g. "Thursday, November 19 at 3:04 PM UTC".
|
|
231
|
+
*/ export function formatBandwidthGraceDeadline(ms) {
|
|
232
|
+
const date = new Date(ms);
|
|
233
|
+
const day = date.toLocaleDateString('en-US', {
|
|
234
|
+
weekday: 'long',
|
|
235
|
+
month: 'long',
|
|
236
|
+
day: 'numeric',
|
|
237
|
+
timeZone: 'UTC'
|
|
238
|
+
});
|
|
239
|
+
const time = date.toLocaleTimeString('en-US', {
|
|
240
|
+
hour: 'numeric',
|
|
241
|
+
minute: '2-digit',
|
|
242
|
+
timeZone: 'UTC'
|
|
243
|
+
});
|
|
244
|
+
return `${day} at ${time} UTC`;
|
|
142
245
|
}
|
|
143
246
|
/**
|
|
144
247
|
* Should the cap be ENGAGED for this org-month? The writer's half of the
|
|
@@ -174,6 +277,45 @@
|
|
|
174
277
|
includedBandwidthGb: resolveOrgEntitlements(org).bandwidthGb
|
|
175
278
|
});
|
|
176
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* The one sentence every grace message carries (AGL-4232): the abuse ceiling
|
|
282
|
+
* stays the cost bound during a grace, so a surge far past the band can still
|
|
283
|
+
* pause the site before the deadline. Said, so the deadline is never a
|
|
284
|
+
* promise the ceiling breaks.
|
|
285
|
+
*/ export const BANDWIDTH_GRACE_SURGE_SENTENCE = 'An unusually large surge of traffic can still pause it before then.';
|
|
286
|
+
/**
|
|
287
|
+
* What the OWNER is told when a grace starts (AGL-4232), in the console and by
|
|
288
|
+
* email: the deadline in plain words, with the way past it. `{site}` is
|
|
289
|
+
* filled by the notifier from the site it reads. `used` is the writer's own
|
|
290
|
+
* account of what was used (page views, or traffic including media).
|
|
291
|
+
* `carried` is a grace granted earlier that still runs as the site goes over
|
|
292
|
+
* again in a new month: the same deadline, said again, since it is this
|
|
293
|
+
* month's news.
|
|
294
|
+
*/ export function bandwidthGraceOwnerNotice(options) {
|
|
295
|
+
// A grace begun in a month's last 72 hours outlasts it: the count starts
|
|
296
|
+
// again on the 1st, so no pause comes, and saying a date would be false.
|
|
297
|
+
if (bandwidthGraceOutlastsMonth(options.graceUntil, options.month)) {
|
|
298
|
+
return {
|
|
299
|
+
title: '{site} is past its monthly traffic limit and stays online',
|
|
300
|
+
body: `{site} has used ${options.used} this month. It stays online: the ` + `month ends before its extra time would, and its count starts again ` + `on ${options.resumesOn}. Nothing is charged for the extra traffic. ` + 'This extra time is given once and has now been used, so the next time ' + 'your sites pass their limit they pause straight away. An unusually large ' + 'surge of traffic can still pause it before the month ends. Upgrade in ' + 'Billing to keep it online whatever its traffic.'
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const deadline = formatBandwidthGraceDeadline(options.graceUntil);
|
|
304
|
+
return {
|
|
305
|
+
title: `Upgrade or {site} pauses on ${deadline}`,
|
|
306
|
+
body: `{site} has used ${options.used} this month. ` + (options.carried ? `It stays online until ${deadline}, when the extra time it was already given ends. ` : `It stays online until ${deadline}. `) + 'Upgrade in Billing before then to keep it online; if you ' + `don't, visitors see a "temporarily unavailable" notice from then until ` + `${options.resumesOn}. ${BANDWIDTH_GRACE_SURGE_SENTENCE} Nothing is charged ` + 'for the extra traffic. This extra time is given once, so the next time your ' + 'sites pass their limit they pause straight away.'
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* What the OWNER is told when a site is paused with no grace, or when its
|
|
311
|
+
* grace has ended (AGL-4232): in the console and by email, from whichever
|
|
312
|
+
* writer saw it. `{site}` is filled by the notifier.
|
|
313
|
+
*/ export function bandwidthPausedOwnerNotice(options) {
|
|
314
|
+
return {
|
|
315
|
+
title: '{site} paused — monthly traffic limit reached',
|
|
316
|
+
body: `{site} has used ${options.used} this month, so visitors see a ` + `"temporarily unavailable" notice instead of its pages until ` + `${options.resumesOn}. Nothing is charged for the extra traffic. The site ` + 'comes back on its own then, or as soon as you upgrade in Billing.'
|
|
317
|
+
};
|
|
318
|
+
}
|
|
177
319
|
/**
|
|
178
320
|
* The visitor's sentence.
|
|
179
321
|
*
|
|
@@ -192,9 +334,11 @@
|
|
|
192
334
|
* support cannot lift it. Reusing the RENDERING channel (the 503 notice page)
|
|
193
335
|
* while keeping the WORDS separate is the split that keeps both honest.
|
|
194
336
|
*/ export function bandwidthCapNotice() {
|
|
337
|
+
// NEUTRAL (AGL-4232): nothing about limits, plans, traffic or pricing —
|
|
338
|
+
// those are the owner's to read in the console, not a visitor's.
|
|
195
339
|
return {
|
|
196
|
-
title: '
|
|
197
|
-
body: 'This site
|
|
340
|
+
title: 'Temporarily unavailable',
|
|
341
|
+
body: 'This site is temporarily unavailable.'
|
|
198
342
|
};
|
|
199
343
|
}
|
|
200
344
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/bandwidth-cap.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The free plan's BANDWIDTH HARD CAP (AGL-1967 / AGL-2070 / AGL-2155).\n *\n * Enforced from before public signups, so the cap is proven under real\n * traffic while the cohort is small and a mistake is cheap. The requirement\n * this module exists to make true: the free/hobby tier hard-caps, so that it\n * always actually stays free.\n *\n * Until this shipped, bandwidth was the ONE billable dimension with no\n * runtime refusal anywhere. Media ingress, forms, contacts, datasets, API and\n * seats all hard-stop on free; `bandwidthGb: 5` appeared only in the plan\n * table, in reporting arithmetic and in UI. A free site that went viral\n * served every page and Aglyn paid the egress with no ceiling.\n *\n * ## Why a MARKER on the org doc, and not a check\n *\n * The obvious implementation — read the page-view counter before rendering —\n * is the one thing this cap must not do. Page views are counted AFTER the\n * fact, by a client beacon into `hosts/{id}/analytics/{day}`; consulting them\n * per render would put a Firestore read on the hot path of every public page\n * on the platform, paid by every PAYING customer too, to answer a question\n * only free orgs can ever fail. That is the exact cost the whole ISR/cache\n * design exists to avoid.\n *\n * So the decision is made where the arithmetic already happens, and its\n * verdict is denormalized onto the org document as {@link OrgBandwidthCap}.\n * The serving path then reads it from `getOrgBilling`, the org doc it ALREADY\n * loads and caches for 60 seconds as \"the suspension gate and every\n * entitlement input for the render\". **The cap costs zero additional reads.**\n *\n * ### TWO writers, and neither is on the render path (AGL-2413)\n *\n * 1. `apps/tenant/app/api/analytics/collect` — the beacon that WRITES the\n * page-view counter, on its existing 1-in-200 sample. It already sums this\n * month with this query and already loads this org doc for the abuse\n * ceiling, so the cap rides both for free.\n * 2. `api/billing/usage-alerts` — the daily sweep, which sums page views\n * ORG-WIDE across up to 100 hosts and is therefore the backstop for any\n * org running more than one site.\n *\n * The beacon is the one that matters, and it exists because the sweep alone\n * was not a cap at all: it skips every org with no `plan` field, and\n * `createOrganization` writes none — so for the whole never-subscribed free\n * tier the marker had never once been written. The general lesson: **a cap\n * that lives only in a scheduled sweep stops existing the moment the sweep\n * does not run.** Every other free dimension refuses at the\n * point of use; this one now does too.\n *\n * ### The latency, stated plainly\n *\n * The beacon closes the window to the sampling slop — at most\n * (200 x instances) page views past the band, against a free band of ~8,700 —\n * so on the common single-site free org the cap engages within a couple of\n * hundred views. It is still not a per-request throttle, and the honest way to\n * describe it is \"a free site cannot run away\", not \"a free site cannot serve\n * byte 5,368,709,121\". Do not close the remaining slop by adding a read to the\n * RENDER path; the place to close it is the CDN, which is Vercel configuration\n * and not a repo change.\n *\n * ### It RELEASES immediately, though\n *\n * Asymmetric on purpose, and this is why {@link bandwidthCapEngaged} re-reads\n * the plan rather than trusting the marker alone. An org that upgrades starts\n * serving again on the next org-doc TTL — about 60 seconds — without waiting\n * for any cron to run or any flag to be cleared. Making somebody who has just\n * paid wait until tomorrow morning for their site to come back is the failure\n * mode that would make this feature worse than the hole it closes.\n *\n * Nothing ever CLEARS the marker either: it names the month it was written\n * for, so a new month simply stops matching. A cap whose lift depends on a\n * write is a cap that stays engaged when the writer fails.\n */\n\nimport type { AglynOrgBilling, OrgBandwidthCap } from '../foundation'\nimport {\n isCustomPricedPlan,\n planMetersInfraOverage,\n resolveEffectivePlan,\n resolveOrgEntitlements,\n} from './plan-entitlements'\n\n/**\n * The month key the marker is stamped with: UTC `YYYY-MM`, the same shape as\n * `utcMonthKey` and the `orgs/{id}/usage/{month}` document id, and the\n * same key `usage-alerts` dedupes its own guards by. One month boundary\n * across the platform — a cap that reset on a different day from the counter\n * it is derived from would engage against last month's traffic.\n */\nexport function bandwidthCapMonthKey(now: Date = new Date()): string {\n return now.toISOString().slice(0, 7)\n}\n\n/**\n * How long a crawler or uptime check is told to wait.\n *\n * NOT \"until the month rolls over\", which is the arithmetically correct\n * answer and can be three weeks. The site can come back at any moment — the\n * owner upgrades and the release path above restores it in about a minute —\n * so a multi-week `Retry-After` would tell Google to stop looking long after\n * the site was serving again. An hour is short enough to be wrong in the\n * recoverable direction.\n */\nexport const BANDWIDTH_CAP_RETRY_AFTER_SECONDS = 3600\n\n/**\n * Is this org's serving currently refused by the free-plan bandwidth cap?\n *\n * THREE conditions, and the second and third are the ones that matter:\n *\n * 1. the marker names the CURRENT month (a stale marker is not a cap);\n * 2. the org's plan does not meter infrastructure overage — i.e. it is the\n * free plan, or a paid plan held as a staff comp (AGL-3034), which has no\n * subscription to bill past the band either. Paid plans BILL bandwidth\n * past the band and are never cut off; that promise is older than this\n * cap and this function is where it is kept. Re-derived from the CURRENT\n * plan on every read, which is what releases an upgraded org without a\n * write;\n * 3. the plan is not custom-priced, and its band is finite. Enterprise also\n * answers false to `planMetersInfraOverage` — its price is negotiated —\n * and since 2026-09-07 its band is a FINITE fallback (twice Agency's), so\n * \"unmetered and finite\" would describe a contracted customer exactly as\n * it describes a free one. Its traffic is paid for by agreement, not by\n * invoice, and this cap is the free plan's rule alone: an enterprise org\n * carrying a marker some future writer left behind is never refused.\n * Belt and braces: today's writer cannot produce that marker, and this\n * makes it impossible rather than merely unreachable.\n *\n * Fail OPEN on anything unrecognised. A missing org, a malformed marker or a\n * plan this build cannot read all serve the site: an unreadable org doc is an\n * outage, and taking a customer's website down over one is not a cap, it is\n * the incident.\n */\nexport function bandwidthCapEngaged(\n org: Partial<AglynOrgBilling> | null | undefined,\n now: Date = new Date(),\n): boolean {\n if (!org) return false\n if (planMetersInfraOverage(org)) return false\n if (isCustomPricedPlan(resolveEffectivePlan(org))) return false\n if (!Number.isFinite(resolveOrgEntitlements(org).bandwidthGb)) return false\n const cap = org.bandwidthCap\n if (!cap || typeof cap !== 'object') return false\n return cap.month === bandwidthCapMonthKey(now)\n}\n\n/**\n * Should the cap be ENGAGED for this org-month? The writer's half of the\n * question, kept beside the reader's so the two cannot drift apart.\n *\n * Takes the measured figure and the band rather than reading anything, so the\n * cron passes in the very numbers it alerts on. `>` and not `>=`: an org\n * exactly at its band has used what it was given and is not over it.\n */\nexport function bandwidthCapShouldEngage(options: {\n org: Partial<AglynOrgBilling> | null | undefined\n usedBandwidthGb: number\n includedBandwidthGb: number\n}): boolean {\n const { org, usedBandwidthGb, includedBandwidthGb } = options\n if (planMetersInfraOverage(org)) return false\n // The reader's third condition, kept in step: a custom-priced plan is paid\n // for by agreement and is never paused, whatever its band resolves to.\n if (isCustomPricedPlan(resolveEffectivePlan(org))) return false\n if (!Number.isFinite(includedBandwidthGb) || !(includedBandwidthGb > 0)) {\n return false\n }\n return usedBandwidthGb > includedBandwidthGb\n}\n\n/**\n * Could this org's traffic EVER engage the cap — is it on a plan that stops\n * at its band rather than billing past it (AGL-3474)?\n *\n * {@link bandwidthCapShouldEngage} with the usage left out, for a writer that\n * has to decide whether measuring is worth its reads at all: the media CDN\n * totals an org's month only when this is true, so a paying org's video costs\n * no read to meter. Answered by the same predicate rather than restated, so\n * the two cannot disagree about which plans the cap is for.\n */\nexport function bandwidthCapApplies(\n org: Partial<AglynOrgBilling> | null | undefined,\n): boolean {\n return bandwidthCapShouldEngage({\n org,\n usedBandwidthGb: Number.POSITIVE_INFINITY,\n includedBandwidthGb: resolveOrgEntitlements(org).bandwidthGb,\n })\n}\n\n/** What a visitor sees on a capped site. */\nexport interface BandwidthCapNotice {\n title: string\n body: string\n}\n\n/**\n * The visitor's sentence.\n *\n * Constrained the same way the form abuse-ceiling copy is (AGL-1666), and for\n * the same reason: the person reading it is a stranger to the site, so it\n * must not disclose the owner's plan, their bill, or anything about their\n * account beyond the one fact that makes the page they asked for absent. It\n * says what happened, that it is not their fault and not permanent, and when\n * it ends — and then stops. \"Upgrade your plan\" belongs in the owner's\n * console and their inbox, which is where the usage alert already puts it,\n * not on a page shown to their readers.\n *\n * Deliberately NOT routed through `lockdownNotice`. A lockdown is the panic\n * button — staff-set, security or billing, \"contact support\" — and its copy\n * would be a lie here in both directions: nobody took this site down and\n * support cannot lift it. Reusing the RENDERING channel (the 503 notice page)\n * while keeping the WORDS separate is the split that keeps both honest.\n */\nexport function bandwidthCapNotice(): BandwidthCapNotice {\n return {\n title: 'Over the monthly traffic limit',\n body:\n 'This site has used all of the traffic included with it this month, ' +\n 'so its pages are paused until the start of next month. Nothing is ' +\n 'wrong with your connection, and nothing here has been removed.',\n }\n}\n\n/**\n * The refusal code on the machine-readable half of the verdict, so a caller\n * can tell a capped site from a locked one. The two answer the same HTTP\n * status from the same notice page on purpose — a 503 with `Retry-After` is\n * the only status that tells a crawler \"come back\", where a 402 or a 403\n * risks a customer's site being de-indexed over one busy month — so the\n * status discriminates nothing and this code is the whole discriminator.\n */\nexport const BANDWIDTH_CAP_CODE = 'bandwidth-cap'\n"],"names":["isCustomPricedPlan","planMetersInfraOverage","resolveEffectivePlan","resolveOrgEntitlements","bandwidthCapMonthKey","now","Date","toISOString","slice","BANDWIDTH_CAP_RETRY_AFTER_SECONDS","bandwidthCapEngaged","org","Number","isFinite","bandwidthGb","cap","bandwidthCap","month","bandwidthCapShouldEngage","options","usedBandwidthGb","includedBandwidthGb","bandwidthCapApplies","POSITIVE_INFINITY","bandwidthCapNotice","title","body","BANDWIDTH_CAP_CODE"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEC,GAGD,SACEA,kBAAkB,EAClBC,sBAAsB,EACtBC,oBAAoB,EACpBC,sBAAsB,QACjB,yBAAqB;AAE5B;;;;;;CAMC,GACD,OAAO,SAASC,qBAAqBC,MAAY,IAAIC,MAAM;IACzD,OAAOD,IAAIE,WAAW,GAAGC,KAAK,CAAC,GAAG;AACpC;AAEA;;;;;;;;;CASC,GACD,OAAO,MAAMC,oCAAoC,KAAI;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,SAASC,oBACdC,GAAgD,EAChDN,MAAY,IAAIC,MAAM;IAEtB,IAAI,CAACK,KAAK,OAAO;IACjB,IAAIV,uBAAuBU,MAAM,OAAO;IACxC,IAAIX,mBAAmBE,qBAAqBS,OAAO,OAAO;IAC1D,IAAI,CAACC,OAAOC,QAAQ,CAACV,uBAAuBQ,KAAKG,WAAW,GAAG,OAAO;IACtE,MAAMC,MAAMJ,IAAIK,YAAY;IAC5B,IAAI,CAACD,OAAO,OAAOA,QAAQ,UAAU,OAAO;IAC5C,OAAOA,IAAIE,KAAK,KAAKb,qBAAqBC;AAC5C;AAEA;;;;;;;CAOC,GACD,OAAO,SAASa,yBAAyBC,OAIxC;IACC,MAAM,EAAER,GAAG,EAAES,eAAe,EAAEC,mBAAmB,EAAE,GAAGF;IACtD,IAAIlB,uBAAuBU,MAAM,OAAO;IACxC,2EAA2E;IAC3E,uEAAuE;IACvE,IAAIX,mBAAmBE,qBAAqBS,OAAO,OAAO;IAC1D,IAAI,CAACC,OAAOC,QAAQ,CAACQ,wBAAwB,CAAEA,CAAAA,sBAAsB,CAAA,GAAI;QACvE,OAAO;IACT;IACA,OAAOD,kBAAkBC;AAC3B;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASC,oBACdX,GAAgD;IAEhD,OAAOO,yBAAyB;QAC9BP;QACAS,iBAAiBR,OAAOW,iBAAiB;QACzCF,qBAAqBlB,uBAAuBQ,KAAKG,WAAW;IAC9D;AACF;AAQA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASU;IACd,OAAO;QACLC,OAAO;QACPC,MACE,wEACA,uEACA;IACJ;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqB,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/bandwidth-cap.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The free plan's BANDWIDTH HARD CAP (AGL-1967 / AGL-2070 / AGL-2155).\n *\n * Enforced from before public signups, so the cap is proven under real\n * traffic while the cohort is small and a mistake is cheap. The requirement\n * this module exists to make true: the free/hobby tier hard-caps, so that it\n * always actually stays free.\n *\n * Until this shipped, bandwidth was the ONE billable dimension with no\n * runtime refusal anywhere. Media ingress, forms, contacts, datasets, API and\n * seats all hard-stop on free; `bandwidthGb: 5` appeared only in the plan\n * table, in reporting arithmetic and in UI. A free site that went viral\n * served every page and Aglyn paid the egress with no ceiling.\n *\n * ## Why a MARKER on the org doc, and not a check\n *\n * The obvious implementation — read the page-view counter before rendering —\n * is the one thing this cap must not do. Page views are counted AFTER the\n * fact, by a client beacon into `hosts/{id}/analytics/{day}`; consulting them\n * per render would put a Firestore read on the hot path of every public page\n * on the platform, paid by every PAYING customer too, to answer a question\n * only free orgs can ever fail. That is the exact cost the whole ISR/cache\n * design exists to avoid.\n *\n * So the decision is made where the arithmetic already happens, and its\n * verdict is denormalized onto the org document as {@link OrgBandwidthCap}.\n * The serving path then reads it from `getOrgBilling`, the org doc it ALREADY\n * loads and caches for 60 seconds as \"the suspension gate and every\n * entitlement input for the render\". **The cap costs zero additional reads.**\n *\n * ### TWO writers, and neither is on the render path (AGL-2413)\n *\n * 1. `apps/tenant/app/api/analytics/collect` — the beacon that WRITES the\n * page-view counter, on its existing 1-in-200 sample. It already sums this\n * month with this query and already loads this org doc for the abuse\n * ceiling, so the cap rides both for free.\n * 2. `api/billing/usage-alerts` — the daily sweep, which sums page views\n * ORG-WIDE across up to 100 hosts and is therefore the backstop for any\n * org running more than one site.\n *\n * The beacon is the one that matters, and it exists because the sweep alone\n * was not a cap at all: it skips every org with no `plan` field, and\n * `createOrganization` writes none — so for the whole never-subscribed free\n * tier the marker had never once been written. The general lesson: **a cap\n * that lives only in a scheduled sweep stops existing the moment the sweep\n * does not run.** Every other free dimension refuses at the\n * point of use; this one now does too.\n *\n * ### The latency, stated plainly\n *\n * The beacon closes the window to the sampling slop — at most\n * (200 x instances) page views past the band, against a free band of ~8,700 —\n * so on the common single-site free org the cap engages within a couple of\n * hundred views. It is still not a per-request throttle, and the honest way to\n * describe it is \"a free site cannot run away\", not \"a free site cannot serve\n * byte 5,368,709,121\". Do not close the remaining slop by adding a read to the\n * RENDER path; the place to close it is the CDN, which is Vercel configuration\n * and not a repo change.\n *\n * ### It RELEASES immediately, though\n *\n * Asymmetric on purpose, and this is why {@link bandwidthCapEngaged} re-reads\n * the plan rather than trusting the marker alone. An org that upgrades starts\n * serving again on the next org-doc TTL — about 60 seconds — without waiting\n * for any cron to run or any flag to be cleared. Making somebody who has just\n * paid wait until tomorrow morning for their site to come back is the failure\n * mode that would make this feature worse than the hole it closes.\n *\n * Nothing ever CLEARS the marker either: it names the month it was written\n * for, so a new month simply stops matching. A cap whose lift depends on a\n * write is a cap that stays engaged when the writer fails.\n */\n\nimport type { AglynOrgBilling, OrgBandwidthCap } from '../foundation'\nimport {\n isCustomPricedPlan,\n planMetersInfraOverage,\n resolveEffectivePlan,\n resolveOrgEntitlements,\n} from './plan-entitlements'\n\n/**\n * The month key the marker is stamped with: UTC `YYYY-MM`, the same shape as\n * `utcMonthKey` and the `orgs/{id}/usage/{month}` document id, and the\n * same key `usage-alerts` dedupes its own guards by. One month boundary\n * across the platform — a cap that reset on a different day from the counter\n * it is derived from would engage against last month's traffic.\n */\nexport function bandwidthCapMonthKey(now: Date = new Date()): string {\n return now.toISOString().slice(0, 7)\n}\n\n/**\n * How long a crawler or uptime check is told to wait.\n *\n * NOT \"until the month rolls over\", which is the arithmetically correct\n * answer and can be three weeks. The site can come back at any moment — the\n * owner upgrades and the release path above restores it in about a minute —\n * so a multi-week `Retry-After` would tell Google to stop looking long after\n * the site was serving again. An hour is short enough to be wrong in the\n * recoverable direction.\n */\nexport const BANDWIDTH_CAP_RETRY_AFTER_SECONDS = 3600\n\n/**\n * Is this org's serving currently refused by the free-plan bandwidth cap?\n *\n * THREE conditions, and the second and third are the ones that matter:\n *\n * 1. the marker names the CURRENT month (a stale marker is not a cap);\n * 2. the org's plan does not meter infrastructure overage — i.e. it is the\n * free plan, or a paid plan held as a staff comp (AGL-3034), which has no\n * subscription to bill past the band either. Paid plans BILL bandwidth\n * past the band and are never cut off; that promise is older than this\n * cap and this function is where it is kept. Re-derived from the CURRENT\n * plan on every read, which is what releases an upgraded org without a\n * write;\n * 3. the plan is not custom-priced, and its band is finite. Enterprise also\n * answers false to `planMetersInfraOverage` — its price is negotiated —\n * and since 2026-09-07 its band is a FINITE fallback (twice Agency's), so\n * \"unmetered and finite\" would describe a contracted customer exactly as\n * it describes a free one. Its traffic is paid for by agreement, not by\n * invoice, and this cap is the free plan's rule alone: an enterprise org\n * carrying a marker some future writer left behind is never refused.\n * Belt and braces: today's writer cannot produce that marker, and this\n * makes it impossible rather than merely unreachable.\n *\n * Fail OPEN on anything unrecognised. A missing org, a malformed marker or a\n * plan this build cannot read all serve the site: an unreadable org doc is an\n * outage, and taking a customer's website down over one is not a cap, it is\n * the incident.\n */\nexport function bandwidthCapEngaged(\n org: Partial<AglynOrgBilling> | null | undefined,\n now: Date = new Date(),\n): boolean {\n if (!org) return false\n if (planMetersInfraOverage(org)) return false\n if (isCustomPricedPlan(resolveEffectivePlan(org))) return false\n if (!Number.isFinite(resolveOrgEntitlements(org).bandwidthGb)) return false\n const cap = org.bandwidthCap\n if (!cap || typeof cap !== 'object') return false\n if (cap.month !== bandwidthCapMonthKey(now)) return false\n // The one-time grace (AGL-4232): engaged, but not refusing until it ends.\n // Nothing writes at that moment; every reader re-derives it from the clock.\n return !(typeof cap.graceUntil === 'number' && now.getTime() < cap.graceUntil)\n}\n\n/**\n * How long the ONE-TIME grace keeps a site online past its band (AGL-4232):\n * the first time a site goes over, ever, it stays up this long so its owner\n * can upgrade before visitors are turned away.\n */\nexport const BANDWIDTH_CAP_GRACE_MS = 72 * 60 * 60 * 1000\n\n/**\n * When the grace ends, while one is running for this org this month; `null`\n * when the org is not over its band, is already paused, or never had one.\n * The owner's surfaces read this to say \"upgrade or your site pauses on …\".\n */\nexport function bandwidthCapGraceUntil(\n org: Partial<AglynOrgBilling> | null | undefined,\n now: Date = new Date(),\n): number | null {\n const cap = org?.bandwidthCap\n if (!cap || typeof cap !== 'object' || cap.month !== bandwidthCapMonthKey(now)) return null\n if (typeof cap.graceUntil !== 'number' || now.getTime() >= cap.graceUntil) return null\n // Only where the cap would refuse were there no grace: an upgraded org has\n // nothing to be warned about.\n const { graceUntil: _running, ...withoutGrace } = cap\n return bandwidthCapEngaged({ ...org, bandwidthCap: withoutGrace }, now) ? cap.graceUntil : null\n}\n\n/**\n * The marker a writer stamps when the cap engages (AGL-1967/2155, AGL-4232):\n * the month and its diagnostics, plus the grace window when the org's sites\n * have never had one. ONE shape for every writer, so a reader cannot tell\n * which of them stamped it.\n */\nexport function bandwidthCapMarker(options: {\n month: string\n nowMs: number\n pageViews: number\n includedPageViews: number\n /** When the grace this engagement carries ends; null for none. */\n graceUntil: number | null\n}): OrgBandwidthCap {\n return {\n month: options.month,\n engagedAt: options.nowMs,\n pageViews: Math.round(options.pageViews),\n includedPageViews: Math.round(options.includedPageViews),\n ...(options.graceUntil !== null ? { graceUntil: options.graceUntil } : {}),\n }\n}\n\n/** A grace stamp as stored: epoch ms, or anything else meaning \"never\". */\ntype GraceStamped = { bandwidthGraceUsedAt?: unknown } | null | undefined\n\nconst graceStamp = (doc: GraceStamped): number =>\n typeof doc?.bandwidthGraceUsedAt === 'number' ? doc.bandwidthGraceUsedAt : 0\n\n/**\n * The grace an engagement carries (AGL-4232), from the workspace's own stamp\n * (`orgs/{id}.bandwidthGraceUsedAt`) and its sites' stamps as read: a NEW one\n * when neither the workspace nor any of its sites has ever had it, the one\n * ALREADY RUNNING when a stamp is still inside its window (a grace granted on\n * the 29th that runs into the next month), else none.\n *\n * Both stamps are required absent so deleting the site and making a new one\n * does not re-arm it: the grace is given once per workspace's sites.\n */\nexport function bandwidthGraceForEngagement(\n hosts: ReadonlyArray<GraceStamped>,\n nowMs: number,\n org?: GraceStamped,\n): { graceUntil: number | null; grants: boolean } {\n if (bandwidthGraceAvailable(hosts) && graceStamp(org) === 0) {\n return { graceUntil: nowMs + BANDWIDTH_CAP_GRACE_MS, grants: true }\n }\n const latest = Math.max(graceStamp(org), ...hosts.map(graceStamp))\n const running = latest + BANDWIDTH_CAP_GRACE_MS\n return { graceUntil: latest > 0 && nowMs < running ? running : null, grants: false }\n}\n\n/**\n * Whether an org's sites are owed the one-time grace by their own stamps: it\n * has at least one site, and none of them has ever had it\n * (`AglynHost.bandwidthGraceUsedAt`). The workspace's stamp is asked beside\n * it by {@link bandwidthGraceForEngagement}.\n */\nexport function bandwidthGraceAvailable(hosts: ReadonlyArray<GraceStamped>): boolean {\n return hosts.length > 0 && hosts.every((host) => graceStamp(host) === 0)\n}\n\n/** When a `YYYY-MM` month ends: midnight UTC on the 1st of the next. */\nexport function bandwidthCapMonthEndMs(month: string): number {\n const [year, monthIndex] = month.split('-').map(Number)\n return Date.UTC(year, monthIndex, 1)\n}\n\n/**\n * Whether a grace ends only after the month it was granted in (AGL-4232).\n * Then no pause comes: the new month's count starts at zero, and the site\n * pauses only when it next passes the band, with no grace left.\n */\nexport function bandwidthGraceOutlastsMonth(graceUntil: number, month: string): boolean {\n return graceUntil >= bandwidthCapMonthEndMs(month)\n}\n\n/**\n * The grace deadline as the owner reads it: an unambiguous UTC date and\n * time, e.g. \"Thursday, November 19 at 3:04 PM UTC\".\n */\nexport function formatBandwidthGraceDeadline(ms: number): string {\n const date = new Date(ms)\n const day = date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n timeZone: 'UTC',\n })\n const time = date.toLocaleTimeString('en-US', {\n hour: 'numeric',\n minute: '2-digit',\n timeZone: 'UTC',\n })\n return `${day} at ${time} UTC`\n}\n\n/**\n * Should the cap be ENGAGED for this org-month? The writer's half of the\n * question, kept beside the reader's so the two cannot drift apart.\n *\n * Takes the measured figure and the band rather than reading anything, so the\n * cron passes in the very numbers it alerts on. `>` and not `>=`: an org\n * exactly at its band has used what it was given and is not over it.\n */\nexport function bandwidthCapShouldEngage(options: {\n org: Partial<AglynOrgBilling> | null | undefined\n usedBandwidthGb: number\n includedBandwidthGb: number\n}): boolean {\n const { org, usedBandwidthGb, includedBandwidthGb } = options\n if (planMetersInfraOverage(org)) return false\n // The reader's third condition, kept in step: a custom-priced plan is paid\n // for by agreement and is never paused, whatever its band resolves to.\n if (isCustomPricedPlan(resolveEffectivePlan(org))) return false\n if (!Number.isFinite(includedBandwidthGb) || !(includedBandwidthGb > 0)) {\n return false\n }\n return usedBandwidthGb > includedBandwidthGb\n}\n\n/**\n * Could this org's traffic EVER engage the cap — is it on a plan that stops\n * at its band rather than billing past it (AGL-3474)?\n *\n * {@link bandwidthCapShouldEngage} with the usage left out, for a writer that\n * has to decide whether measuring is worth its reads at all: the media CDN\n * totals an org's month only when this is true, so a paying org's video costs\n * no read to meter. Answered by the same predicate rather than restated, so\n * the two cannot disagree about which plans the cap is for.\n */\nexport function bandwidthCapApplies(\n org: Partial<AglynOrgBilling> | null | undefined,\n): boolean {\n return bandwidthCapShouldEngage({\n org,\n usedBandwidthGb: Number.POSITIVE_INFINITY,\n includedBandwidthGb: resolveOrgEntitlements(org).bandwidthGb,\n })\n}\n\n/**\n * The one sentence every grace message carries (AGL-4232): the abuse ceiling\n * stays the cost bound during a grace, so a surge far past the band can still\n * pause the site before the deadline. Said, so the deadline is never a\n * promise the ceiling breaks.\n */\nexport const BANDWIDTH_GRACE_SURGE_SENTENCE =\n 'An unusually large surge of traffic can still pause it before then.'\n\n/**\n * What the OWNER is told when a grace starts (AGL-4232), in the console and by\n * email: the deadline in plain words, with the way past it. `{site}` is\n * filled by the notifier from the site it reads. `used` is the writer's own\n * account of what was used (page views, or traffic including media).\n * `carried` is a grace granted earlier that still runs as the site goes over\n * again in a new month: the same deadline, said again, since it is this\n * month's news.\n */\nexport function bandwidthGraceOwnerNotice(options: {\n graceUntil: number\n /** The `YYYY-MM` the cap engaged for, which decides whether a pause comes. */\n month: string\n used: string\n resumesOn: string\n carried?: boolean\n}): BandwidthCapNotice {\n // A grace begun in a month's last 72 hours outlasts it: the count starts\n // again on the 1st, so no pause comes, and saying a date would be false.\n if (bandwidthGraceOutlastsMonth(options.graceUntil, options.month)) {\n return {\n title: '{site} is past its monthly traffic limit and stays online',\n body:\n `{site} has used ${options.used} this month. It stays online: the ` +\n `month ends before its extra time would, and its count starts again ` +\n `on ${options.resumesOn}. Nothing is charged for the extra traffic. ` +\n 'This extra time is given once and has now been used, so the next time ' +\n 'your sites pass their limit they pause straight away. An unusually large ' +\n 'surge of traffic can still pause it before the month ends. Upgrade in ' +\n 'Billing to keep it online whatever its traffic.',\n }\n }\n const deadline = formatBandwidthGraceDeadline(options.graceUntil)\n return {\n title: `Upgrade or {site} pauses on ${deadline}`,\n body:\n `{site} has used ${options.used} this month. ` +\n (options.carried\n ? `It stays online until ${deadline}, when the extra time it was already given ends. `\n : `It stays online until ${deadline}. `) +\n 'Upgrade in Billing before then to keep it online; if you ' +\n `don't, visitors see a \"temporarily unavailable\" notice from then until ` +\n `${options.resumesOn}. ${BANDWIDTH_GRACE_SURGE_SENTENCE} Nothing is charged ` +\n 'for the extra traffic. This extra time is given once, so the next time your ' +\n 'sites pass their limit they pause straight away.',\n }\n}\n\n/**\n * What the OWNER is told when a site is paused with no grace, or when its\n * grace has ended (AGL-4232): in the console and by email, from whichever\n * writer saw it. `{site}` is filled by the notifier.\n */\nexport function bandwidthPausedOwnerNotice(options: {\n used: string\n resumesOn: string\n}): BandwidthCapNotice {\n return {\n title: '{site} paused — monthly traffic limit reached',\n body:\n `{site} has used ${options.used} this month, so visitors see a ` +\n `\"temporarily unavailable\" notice instead of its pages until ` +\n `${options.resumesOn}. Nothing is charged for the extra traffic. The site ` +\n 'comes back on its own then, or as soon as you upgrade in Billing.',\n }\n}\n\n/** What a visitor sees on a capped site. */\nexport interface BandwidthCapNotice {\n title: string\n body: string\n}\n\n/**\n * The visitor's sentence.\n *\n * Constrained the same way the form abuse-ceiling copy is (AGL-1666), and for\n * the same reason: the person reading it is a stranger to the site, so it\n * must not disclose the owner's plan, their bill, or anything about their\n * account beyond the one fact that makes the page they asked for absent. It\n * says what happened, that it is not their fault and not permanent, and when\n * it ends — and then stops. \"Upgrade your plan\" belongs in the owner's\n * console and their inbox, which is where the usage alert already puts it,\n * not on a page shown to their readers.\n *\n * Deliberately NOT routed through `lockdownNotice`. A lockdown is the panic\n * button — staff-set, security or billing, \"contact support\" — and its copy\n * would be a lie here in both directions: nobody took this site down and\n * support cannot lift it. Reusing the RENDERING channel (the 503 notice page)\n * while keeping the WORDS separate is the split that keeps both honest.\n */\nexport function bandwidthCapNotice(): BandwidthCapNotice {\n // NEUTRAL (AGL-4232): nothing about limits, plans, traffic or pricing —\n // those are the owner's to read in the console, not a visitor's.\n return {\n title: 'Temporarily unavailable',\n body: 'This site is temporarily unavailable.',\n }\n}\n\n/**\n * The refusal code on the machine-readable half of the verdict, so a caller\n * can tell a capped site from a locked one. The two answer the same HTTP\n * status from the same notice page on purpose — a 503 with `Retry-After` is\n * the only status that tells a crawler \"come back\", where a 402 or a 403\n * risks a customer's site being de-indexed over one busy month — so the\n * status discriminates nothing and this code is the whole discriminator.\n */\nexport const BANDWIDTH_CAP_CODE = 'bandwidth-cap'\n"],"names":["isCustomPricedPlan","planMetersInfraOverage","resolveEffectivePlan","resolveOrgEntitlements","bandwidthCapMonthKey","now","Date","toISOString","slice","BANDWIDTH_CAP_RETRY_AFTER_SECONDS","bandwidthCapEngaged","org","Number","isFinite","bandwidthGb","cap","bandwidthCap","month","graceUntil","getTime","BANDWIDTH_CAP_GRACE_MS","bandwidthCapGraceUntil","_running","withoutGrace","bandwidthCapMarker","options","engagedAt","nowMs","pageViews","Math","round","includedPageViews","graceStamp","doc","bandwidthGraceUsedAt","bandwidthGraceForEngagement","hosts","bandwidthGraceAvailable","grants","latest","max","map","running","length","every","host","bandwidthCapMonthEndMs","year","monthIndex","split","UTC","bandwidthGraceOutlastsMonth","formatBandwidthGraceDeadline","ms","date","day","toLocaleDateString","weekday","timeZone","time","toLocaleTimeString","hour","minute","bandwidthCapShouldEngage","usedBandwidthGb","includedBandwidthGb","bandwidthCapApplies","POSITIVE_INFINITY","BANDWIDTH_GRACE_SURGE_SENTENCE","bandwidthGraceOwnerNotice","title","body","used","resumesOn","deadline","carried","bandwidthPausedOwnerNotice","bandwidthCapNotice","BANDW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TION_INDEX = [
|
|
|
12562
12562
|
anchor: '#related',
|
|
12563
12563
|
text: '- Actions builder\n- Webhooks\n- Bindings, variables & functions'
|
|
12564
12564
|
},
|
|
12565
|
+
{
|
|
12566
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12567
|
+
title: 'Claude and other AI assistants',
|
|
12568
|
+
heading: '',
|
|
12569
|
+
anchor: '',
|
|
12570
|
+
text: 'Claude and other AI assistants\nConnect Claude to your workspace and ask it for things in plain words: "Who filled in the contact form this week?", "Add these five services to my site", "Mark order 1042 shipped with this tracking number", "Log my call with Dana and remind me on Friday."\nYou sign in to Aglyn and choose what the assistant may do. There is nothing to copy or paste, and you can disconnect it at any time.\nThe steps below use Claude. Other assistants connect the same way.'
|
|
12571
|
+
},
|
|
12572
|
+
{
|
|
12573
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12574
|
+
title: 'Claude and other AI assistants',
|
|
12575
|
+
heading: 'Connect Claude',
|
|
12576
|
+
anchor: '#connect-claude',
|
|
12577
|
+
text: '1. In Claude, open Settings → Connectors and choose Add custom connector.\n2. Name it Aglyn and enter this address: https://app.aglyn.com/api/mcp\n3. Choose Connect. Aglyn opens and asks you to sign in if you are not already.\n4. Pick the workspace Claude should work in.\n5. Choose what it may do:\n- View only lets Claude look things up and nothing else.\n- View and make changes also lets it add and update things for you.\n6. Choose Allow. You are returned to Claude, and Aglyn appears in its list of connectors.\nConnecting takes the Manage API keys permission in the workspace, which owners and admins have. It is included from the Starter plan.\nOn a Team or Enterprise plan for Claude, an owner of your Claude organization adds the connector once, and each person then connects with their own Aglyn sign-in.'
|
|
12578
|
+
},
|
|
12579
|
+
{
|
|
12580
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12581
|
+
title: 'Claude and other AI assistants',
|
|
12582
|
+
heading: 'Other assistants',
|
|
12583
|
+
anchor: '#other-assistants',
|
|
12584
|
+
text: 'Aglyn works with any assistant or tool that supports the Model Context Protocol (MCP) with sign-in, not only Claude.\n1. In the assistant, find where it adds a connector, app or MCP server.\n2. Enter the address https://app.aglyn.com/api/mcp.\n3. Sign in to Aglyn when it asks, pick the workspace and what the assistant may do, and choose Allow.\nBefore you choose Allow, Aglyn shows the name the app gives itself and where it returns to. Check that this is the assistant you started from. Only continue if you started connecting it yourself.\nEverything on this page applies to any connected assistant: what it can and cannot do, your plan, and how to disconnect it.'
|
|
12585
|
+
},
|
|
12586
|
+
{
|
|
12587
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12588
|
+
title: 'Claude and other AI assistants',
|
|
12589
|
+
heading: 'What Claude can do',
|
|
12590
|
+
anchor: '#what-claude-can-do',
|
|
12591
|
+
text: '| Area | Claude can |\n| Sites | List your sites, create a site, and publish a site. |\n| Site content | Read and edit datasets and their records - the content behind listings, service pages, menus and directories. |\n| Contacts and CRM | Find, add, update and merge contacts. Work with companies, deals, tasks, activities, leads and email templates. |\n| Form submissions | Read submissions, mark them read, and delete them. |\n| Orders and products | Read orders and products, and mark an order shipped or delivered with its tracking number. |\n| Bookings | Read bookings. |\n| Media | List your media and upload new files. |\nEach area follows your plan, the same way it does in the console: the CRM needs a plan with the CRM, orders need commerce, and so on.\nWhat it cannot do\nClaude cannot cancel or refund an order, move or cancel a booking, rename or delete a site, replace or delete media, or change your team, plan or billing. Do those in the console.\nDesigning a page is also done in the console, in the editor. If you use Claude\'s browser extension, Claude can work in the console alongside you there, in your own signed-in window.'
|
|
12592
|
+
},
|
|
12593
|
+
{
|
|
12594
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12595
|
+
title: 'Claude and other AI assistants',
|
|
12596
|
+
heading: 'Good habits',
|
|
12597
|
+
anchor: '#good-habits',
|
|
12598
|
+
text: '- Start with View only if you mainly want answers. You can connect again with more access later.\n- Ask Claude to tell you before it changes anything. In Claude\'s connector settings you can also choose which actions need your approval each time.\n- Check before you publish. Publishing a site makes its changes live for visitors.\n- What Claude reads from your workspace is handled by Claude under your agreement with Anthropic. Connect only a Claude account you trust with your customers\' details.'
|
|
12599
|
+
},
|
|
12600
|
+
{
|
|
12601
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12602
|
+
title: 'Claude and other AI assistants',
|
|
12603
|
+
heading: 'Disconnect Claude',
|
|
12604
|
+
anchor: '#disconnect-claude',
|
|
12605
|
+
text: '1. In Aglyn, open your workspace\'s Settings → API keys.\n2. Under Connected apps, find the assistant and choose Disconnect.\nIt loses access right away. You can also remove the connector in Claude\'s own settings.\nEverything Claude does counts toward your plan\'s API requests, the same as any other connected app. See usage.'
|
|
12606
|
+
},
|
|
12607
|
+
{
|
|
12608
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12609
|
+
title: 'Claude and other AI assistants',
|
|
12610
|
+
heading: 'Claude Code',
|
|
12611
|
+
anchor: '#claude-code',
|
|
12612
|
+
text: 'If you use Claude Code, install the Aglyn plugin. It adds the same connection plus guidance that teaches Claude how to work in Aglyn.\nThen run /mcp, choose aglyn, and sign in.'
|
|
12613
|
+
},
|
|
12614
|
+
{
|
|
12615
|
+
path: '/marketing-and-automation/workflows-and-actions/claude',
|
|
12616
|
+
title: 'Claude and other AI assistants',
|
|
12617
|
+
heading: 'For developers',
|
|
12618
|
+
anchor: '#for-developers',
|
|
12619
|
+
text: 'Scripts and servers with nobody to sign in can use an API key with the same address. The tools Claude sees are the operations in the REST API.'
|
|
12620
|
+
},
|
|
12565
12621
|
{
|
|
12566
12622
|
path: '/marketing-and-automation/workflows-and-actions/org-automations',
|
|
12567
12623
|
title: 'Org automations',
|
|
@@ -12763,28 +12819,35 @@ export const DOCS_SECTION_INDEX = [
|
|
|
12763
12819
|
title: 'Bandwidth',
|
|
12764
12820
|
heading: '',
|
|
12765
12821
|
anchor: '',
|
|
12766
|
-
text: 'Bandwidth\nBandwidth is how much traffic your published sites serve in a calendar month: their pages, and the video, audio and files they serve from your media library. Video, audio, file downloads and other media served from our servers count 1.6× toward bandwidth, because serving them costs more than serving pages. Every plan includes an amount. What happens when you pass it is the part worth reading, because it is not the same on Free as it is on a paid plan.\nPlan availability Every plan has a bandwidth allowance. On a paid plan going past it is metered and billed, and your sites keep serving. On Free it is a hard stop: the site is paused until the start of the next month.'
|
|
12822
|
+
text: 'Bandwidth\nBandwidth is how much traffic your published sites serve in a calendar month: their pages, and the video, audio and files they serve from your media library. Video, audio, file downloads and other media served from our servers count 1.6× toward bandwidth, because serving them costs more than serving pages. Every plan includes an amount. What happens when you pass it is the part worth reading, because it is not the same on Free as it is on a paid plan.\nPlan availability Every plan has a bandwidth allowance. On a paid plan going past it is metered and billed, and your sites keep serving. On Free it is a hard stop: the site is paused until the start of the next month. The first time a site goes over, it stays online for 72 hours first, so there is time to upgrade — see The one-time grace.'
|
|
12767
12823
|
},
|
|
12768
12824
|
{
|
|
12769
12825
|
path: '/workspace-and-billing/billing-and-plans/bandwidth',
|
|
12770
12826
|
title: 'Bandwidth',
|
|
12771
12827
|
heading: 'What each plan includes',
|
|
12772
12828
|
anchor: '#what-each-plan-includes',
|
|
12773
|
-
text: '| Plan | Included bandwidth per month | Past the allowance |\n| Free | 2 GB | Sites are paused until the start of next month |\n| Starter | 15 GB | Keeps serving; the extra is billed |\n| Pro | 25 GB | Keeps serving; the extra is billed |\n| Custom | Set by your agreement | Keeps serving; not billed — your agreement sets the terms |\nThe allowance is per organization, across every site in it — not per site. If you run four sites on one Pro plan (three included and one extra), they share the 25 GB.'
|
|
12829
|
+
text: '| Plan | Included bandwidth per month | Past the allowance |\n| Free | 2 GB | Sites are paused until the start of next month (the first time, after 72 hours) |\n| Starter | 15 GB | Keeps serving; the extra is billed |\n| Pro | 25 GB | Keeps serving; the extra is billed |\n| Custom | Set by your agreement | Keeps serving; not billed — your agreement sets the terms |\nThe allowance is per organization, across every site in it — not per site. If you run four sites on one Pro plan (three included and one extra), they share the 25 GB.'
|
|
12774
12830
|
},
|
|
12775
12831
|
{
|
|
12776
12832
|
path: '/workspace-and-billing/billing-and-plans/bandwidth',
|
|
12777
12833
|
title: 'Bandwidth',
|
|
12778
12834
|
heading: 'Where to see your usage',
|
|
12779
12835
|
anchor: '#where-to-see-it',
|
|
12780
|
-
text: '1. In the console, open Billing from the organization menu.\n2. Find the Usage card.\n3. Read the row labeled Bandwidth (this month, organization).\nThe meter resets on the first of each month, in UTC.\nYou do not have to be watching it. Organization admins get an in-app notification and an email at 75%, 80% and 90% of the allowance and again at 100% — each step once a month, and only the highest step reached, so a busy day that jumps from 70% to 95% sends one 90% notice. What those messages say depends on your plan, and the difference is the point:\n- On a paid plan the 100% message reads "You\'re past your included monthly bandwidth — extra usage is now billed", and tells you the overage appears on your monthly invoice.\n- On Free it
|
|
12836
|
+
text: '1. In the console, open Billing from the organization menu.\n2. Find the Usage card.\n3. Read the row labeled Bandwidth (this month, organization).\nThe meter resets on the first of each month, in UTC.\nYou do not have to be watching it. Organization admins get an in-app notification and an email at 75%, 80% and 90% of the allowance and again at 100% — each step once a month, and only the highest step reached, so a busy day that jumps from 70% to 95% sends one 90% notice. What those messages say depends on your plan, and the difference is the point:\n- On a paid plan the 100% message reads "You\'re past your included monthly bandwidth — extra usage is now billed", and tells you the overage appears on your monthly invoice.\n- On Free there is no overage to bill, only a stop, so passing 100% is told once, at the moment it happens: each site\'s managers get a notification and an email naming the site and either its deadline — "Upgrade or your site pauses on …", the date and time in UTC, the first time — or that it is paused. The 100% usage message is not sent again on top of it. A banner across the top of the console says the same until you upgrade or the month turns.'
|
|
12781
12837
|
},
|
|
12782
12838
|
{
|
|
12783
12839
|
path: '/workspace-and-billing/billing-and-plans/bandwidth',
|
|
12784
12840
|
title: 'Bandwidth',
|
|
12785
12841
|
heading: 'What a paused Free site looks like',
|
|
12786
12842
|
anchor: '#paused',
|
|
12787
|
-
text: 'When a Free organization
|
|
12843
|
+
text: 'When a Free organization\'s pause takes hold, its published sites stop serving pages and answer with a plain notice instead, and the video, audio and files in its media library stop loading until the pause lifts:\n> Temporarily unavailable\n>\n> This site is temporarily unavailable.\nThe notice says nothing about limits, plans or traffic: your visitors are not told why. The reason, and the way to lift it, are in your console and your inbox. Your own team sees the same notice on the public site; the console is where to upgrade.\nThree things are true about that page and are worth knowing before you see it:\n- Nothing is deleted. Your pages, media, datasets and settings are untouched. The console keeps working normally — only the public site is paused, along with the video, audio and files your media library serves. Those stop wherever they load from, the media library\'s own previews included, because every play is delivered the same way; images keep loading.\n- It clears itself. The pause is stamped with the month it belongs to. When the month turns over it stops applying, with no action from you and nothing to un-set.\n- Upgrading lifts it within about a minute. The check re-reads your plan every time, so a plan change releases the pause without waiting for the next month or for any sweep to run.\nSearch engines are told not to index the notice, so a pause does not cost you your rankings.'
|
|
12844
|
+
},
|
|
12845
|
+
{
|
|
12846
|
+
path: '/workspace-and-billing/billing-and-plans/bandwidth',
|
|
12847
|
+
title: 'Bandwidth',
|
|
12848
|
+
heading: 'The one-time grace',
|
|
12849
|
+
anchor: '#grace',
|
|
12850
|
+
text: 'The first time a site goes over its band, it is not paused straight away. It stays online for 72 hours, and you are told the exact date and time it will pause — in the console and by email — so you can upgrade before your visitors are turned away. If you upgrade before then, nothing pauses. If you don\'t, the site pauses at that time, as above, until the month turns over.\nIf a site first goes over in the last three days of a month, its 72 hours would end after the month does. Then nothing pauses: the count starts again on the 1st, and you are told the site stays online and that its extra time has been used.\nThis extra time is given once. It is recorded on your workspace and on every site it has when it is given, so the next time your sites go over — in any later month — they pause as soon as they pass the band. A new month, changing plans and changing back, deleting a site and making a new one, or a site added later, does not bring it back.\nA surge can still pause a site during those 72 hours. Every plan has an abuse ceiling far above its band (for Free, 100,000 page views in a month — see The two mechanisms). If traffic during the 72 hours is unusually large and reaches it, the site pauses then, visitors see the same "temporarily unavailable" notice, and you are told by notification and email, as for any pause.\nIf the extra time ends and the site pauses, you are told that too, within a day.'
|
|
12788
12851
|
},
|
|
12789
12852
|
{
|
|
12790
12853
|
path: '/workspace-and-billing/billing-and-plans/bandwidth',
|