@aglyn/aglyn 1.0.0-beta.270 → 1.0.0-beta.272
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/account-preferences.d.ts +50 -0
- package/src/lib/app-utils/account-preferences.js +96 -0
- package/src/lib/app-utils/account-preferences.js.map +1 -1
- package/src/lib/app-utils/activity-labels.js +2 -0
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +16 -2
- package/src/lib/app-utils/analytics-events.js +2 -0
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/append-only-history.d.ts +94 -0
- package/src/lib/app-utils/append-only-history.js +73 -0
- package/src/lib/app-utils/append-only-history.js.map +1 -0
- package/src/lib/app-utils/bundle-intent.d.ts +186 -0
- package/src/lib/app-utils/bundle-intent.js +386 -0
- package/src/lib/app-utils/bundle-intent.js.map +1 -0
- package/src/lib/app-utils/client-build.d.ts +207 -0
- package/src/lib/app-utils/client-build.js +237 -0
- package/src/lib/app-utils/client-build.js.map +1 -0
- package/src/lib/app-utils/console-routes.d.ts +4 -0
- package/src/lib/app-utils/console-routes.js +2 -0
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +13 -6
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +11 -5
- package/src/lib/app-utils/docs-help.generated.js +31 -2
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +105 -35
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/margin-utilization.js +6 -4
- package/src/lib/app-utils/margin-utilization.js.map +1 -1
- package/src/lib/app-utils/media-filter.d.ts +26 -0
- package/src/lib/app-utils/media-filter.js +32 -0
- package/src/lib/app-utils/media-filter.js.map +1 -1
- package/src/lib/app-utils/onboarding-deep-link.d.ts +36 -2
- package/src/lib/app-utils/onboarding-deep-link.js +48 -5
- package/src/lib/app-utils/onboarding-deep-link.js.map +1 -1
- package/src/lib/app-utils/operator-alerts.js +21 -0
- package/src/lib/app-utils/operator-alerts.js.map +1 -1
- package/src/lib/app-utils/owner-approval-record.d.ts +102 -0
- package/src/lib/app-utils/owner-approval-record.js +148 -0
- package/src/lib/app-utils/owner-approval-record.js.map +1 -0
- package/src/lib/app-utils/plan-card-meters.d.ts +96 -0
- package/src/lib/app-utils/plan-card-meters.js +197 -0
- package/src/lib/app-utils/plan-card-meters.js.map +1 -0
- package/src/lib/app-utils/plan-entitlements.d.ts +183 -67
- package/src/lib/app-utils/plan-entitlements.js +213 -58
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +22 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +4 -0
- package/src/lib/app-utils/server.js +7 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-care-project.d.ts +227 -0
- package/src/lib/app-utils/site-care-project.js +423 -0
- package/src/lib/app-utils/site-care-project.js.map +1 -0
- package/src/lib/app-utils/site-care.d.ts +291 -0
- package/src/lib/app-utils/site-care.js +310 -0
- package/src/lib/app-utils/site-care.js.map +1 -0
- package/src/lib/app-utils/upgrade-proposal.d.ts +29 -4
- package/src/lib/app-utils/upgrade-proposal.js +60 -9
- package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
- package/src/lib/foundation/definitions/org-billing.types.d.ts +40 -10
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +3 -1
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +20 -0
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +48 -0
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.js +16 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-ai-capabilities.d.ts +19 -0
- package/src/lib/plugin-manager/plugin-ai-capabilities.js.map +1 -1
- package/src/lib/plugin-manager/plugin-domain-search.d.ts +81 -0
- package/src/lib/plugin-manager/plugin-domain-search.js +63 -0
- package/src/lib/plugin-manager/plugin-domain-search.js.map +1 -0
- package/src/lib/plugin-manager/plugin-entitlements.d.ts +23 -5
- package/src/lib/plugin-manager/plugin-entitlements.js +10 -0
- package/src/lib/plugin-manager/plugin-entitlements.js.map +1 -1
- package/src/lib/plugin-manager/plugin-media-ingest.d.ts +18 -1
- package/src/lib/plugin-manager/plugin-media-ingest.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-resources.d.ts +74 -0
- package/src/lib/plugin-manager/plugin-site-resources.js +135 -0
- package/src/lib/plugin-manager/plugin-site-resources.js.map +1 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.d.ts +61 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.js +102 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.js.map +1 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A SITE STAFF BUILD FOR A CLIENT, ON ONE SCREEN (AGL-3958).
|
|
19
|
+
*
|
|
20
|
+
* At a booth or on a doorstep there is no laptop: staff create the client's
|
|
21
|
+
* workspace with "Build for a client" on (AGL-3952), and land on one screen
|
|
22
|
+
* that asks the business details once, records the domain the owner wants,
|
|
23
|
+
* shows the photo link's QR (AGL-3957), starts the guided AI start with those
|
|
24
|
+
* answers, and sends the owner the preview. This module is that screen's
|
|
25
|
+
* vocabulary: what is asked, what an answer may be, and the intent the
|
|
26
|
+
* hand-off carries into the owner's checkout.
|
|
27
|
+
*
|
|
28
|
+
* Pure: shapes, bounds and parsers, read by the screen, the staff route that
|
|
29
|
+
* stores the record and the hand-off that reads its intent. No React, no
|
|
30
|
+
* network.
|
|
31
|
+
*/
|
|
32
|
+
import type { OrgPlan, OrgSeatAddons } from '../foundation/definitions/org-billing.types';
|
|
33
|
+
/** What staff ask the owner, once, and the guided start reads instead of asking again. */
|
|
34
|
+
export interface ClientBuildIntake {
|
|
35
|
+
/** The business's name, as its header and footer will say it. */
|
|
36
|
+
businessName: string;
|
|
37
|
+
/** What the business does, in a few words: the guided start's first answer. */
|
|
38
|
+
whatTheyDo: string;
|
|
39
|
+
/** The towns or area it serves; empty when it serves no one place. */
|
|
40
|
+
towns: string;
|
|
41
|
+
/** The owner's phone: the preview is texted here, and the site may show it. */
|
|
42
|
+
phone: string;
|
|
43
|
+
/** The owner's email: the preview is emailed here, and the site may show it. */
|
|
44
|
+
email: string;
|
|
45
|
+
/**
|
|
46
|
+
* Opening hours as the owner says them, e.g. "Mon–Fri 8am–5pm". Said with
|
|
47
|
+
* am or pm, they also fill the guided start's opening hours (AGL-3995).
|
|
48
|
+
*/
|
|
49
|
+
hours: string;
|
|
50
|
+
/** The owner's own words about the business, in one box. */
|
|
51
|
+
ownerWords: string;
|
|
52
|
+
}
|
|
53
|
+
export type ClientBuildIntakeField = keyof ClientBuildIntake;
|
|
54
|
+
/** The longest each answer may be, in characters. */
|
|
55
|
+
export declare const CLIENT_BUILD_LIMITS: Readonly<Record<ClientBuildIntakeField, number>>;
|
|
56
|
+
/** An intake with nothing typed: what the screen starts on. */
|
|
57
|
+
export declare const EMPTY_CLIENT_BUILD_INTAKE: ClientBuildIntake;
|
|
58
|
+
/**
|
|
59
|
+
* Why each answer cannot be used, in a sentence shown beside it; an answer
|
|
60
|
+
* that is fine has no entry. The name and what they do are required, since
|
|
61
|
+
* the site cannot be named or planned without them; the phone and the email
|
|
62
|
+
* are each optional, but the preview needs one of them to reach the owner.
|
|
63
|
+
*/
|
|
64
|
+
export declare function clientBuildIntakeErrors(intake: ClientBuildIntake): Partial<Record<ClientBuildIntakeField, string>>;
|
|
65
|
+
/**
|
|
66
|
+
* An intake as the route admits it: every answer a trimmed string within its
|
|
67
|
+
* bound, or the first reason it is not. Fields the body does not carry are
|
|
68
|
+
* empty, never `undefined`, so the record always has the same shape.
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseClientBuildIntake(raw: unknown): ClientBuildIntake | string;
|
|
71
|
+
/** The owner's phone as a text goes to it, E.164, or `null` when there is none to text. */
|
|
72
|
+
export declare function clientBuildPhone(intake: Pick<ClientBuildIntake, 'phone'>): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* What the owner chose on the Domain step (Zach, 2026-10-19).
|
|
75
|
+
*
|
|
76
|
+
* - `free`: the site stays on its free address for now.
|
|
77
|
+
* - `register`: a name the owner wants to buy. NOT bought here: it rides the
|
|
78
|
+
* bundle link, so the owner buys it on their own phone after they
|
|
79
|
+
* subscribe, with their own registrant details and their own tick on the
|
|
80
|
+
* registrar's terms.
|
|
81
|
+
* - `own`: a domain the owner already has, which the hand-off and the Site
|
|
82
|
+
* Care intake connect (one-click DNS opens the owner's provider and needs
|
|
83
|
+
* their login, so staff do it with them, or hand them the records).
|
|
84
|
+
*/
|
|
85
|
+
export type ClientBuildDomain = {
|
|
86
|
+
choice: 'free';
|
|
87
|
+
} | {
|
|
88
|
+
choice: 'register';
|
|
89
|
+
name: string;
|
|
90
|
+
firstYearUsd: number;
|
|
91
|
+
renewalUsd: number;
|
|
92
|
+
} | {
|
|
93
|
+
choice: 'own';
|
|
94
|
+
name: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A domain name as typed, normalized — lower case, no scheme, no `www.`, no
|
|
98
|
+
* path — or `null` when it is not one. "I have example.com" is typed on a
|
|
99
|
+
* phone, often as the address bar showed it.
|
|
100
|
+
*/
|
|
101
|
+
export declare function normalizeClientBuildDomainName(raw: unknown): string | null;
|
|
102
|
+
/** A Domain step answer as the route admits it, or the reason it is not one. */
|
|
103
|
+
export declare function parseClientBuildDomain(raw: unknown): ClientBuildDomain | string;
|
|
104
|
+
/** "$12.99" for a whole-dollar-and-cents price. */
|
|
105
|
+
export declare function formatDomainUsd(amount: number): string;
|
|
106
|
+
/** "$12.99 the first year, then $18.99 a year": both prices together, always. */
|
|
107
|
+
export declare function domainPriceText(prices: {
|
|
108
|
+
firstYearUsd: number;
|
|
109
|
+
renewalUsd: number;
|
|
110
|
+
}): string;
|
|
111
|
+
/** Add-ons, by their `OrgSeatAddons` key, as Billing sells them. */
|
|
112
|
+
export type ClientBuildAddon = keyof OrgSeatAddons;
|
|
113
|
+
/**
|
|
114
|
+
* What the owner is asked to buy, as the build leaves it for the hand-off
|
|
115
|
+
* (AGL-3955, AGL-3956): the plan, the add-ons, the interval, a coupon, and
|
|
116
|
+
* the domain they picked. The hand-off dialog opens on it and the bundle
|
|
117
|
+
* link preselects it, so the owner's checkout is one tap from paid.
|
|
118
|
+
*
|
|
119
|
+
* `domain` is a name to REGISTER, bought by the owner after they subscribe;
|
|
120
|
+
* `existingDomain` is one they already hold, which is connected rather than
|
|
121
|
+
* bought. At most one of the two is set.
|
|
122
|
+
*/
|
|
123
|
+
export interface ClientBuildIntent {
|
|
124
|
+
plan: OrgPlan;
|
|
125
|
+
addons: ClientBuildAddon[];
|
|
126
|
+
interval: 'month' | 'year';
|
|
127
|
+
coupon?: string;
|
|
128
|
+
domain?: {
|
|
129
|
+
name: string;
|
|
130
|
+
firstYearUsd: number;
|
|
131
|
+
renewalUsd: number;
|
|
132
|
+
};
|
|
133
|
+
existingDomain?: string;
|
|
134
|
+
}
|
|
135
|
+
/** Site Care rides every build for a client unless staff take it off (AGL-3954). */
|
|
136
|
+
export declare const CLIENT_BUILD_DEFAULT_ADDONS: readonly ClientBuildAddon[];
|
|
137
|
+
/** The intent a build starts with: the plan the workspace was comped on, Site Care, monthly. */
|
|
138
|
+
export declare function clientBuildIntent(options: {
|
|
139
|
+
plan: OrgPlan | null | undefined;
|
|
140
|
+
domain?: ClientBuildDomain | null;
|
|
141
|
+
}): ClientBuildIntent;
|
|
142
|
+
/**
|
|
143
|
+
* A stored intent, narrowed, or `null` when it is not one worth acting on.
|
|
144
|
+
* What the hand-off reads: a plan this build cannot sell, an add-on it does
|
|
145
|
+
* not know or a malformed domain reads as absent rather than as a checkout
|
|
146
|
+
* for something that does not exist.
|
|
147
|
+
*/
|
|
148
|
+
export declare function readClientBuildIntent(raw: unknown): ClientBuildIntent | null;
|
|
149
|
+
/**
|
|
150
|
+
* The build as it is stored, one per workspace, at
|
|
151
|
+
* `orgs/{orgId}/clientBuild/{CLIENT_BUILD_DOC_ID}`: a subcollection the rules
|
|
152
|
+
* open to no client, written and read only by `/api/admin/client-build`
|
|
153
|
+
* (staff) through the Admin SDK. Not on the org document, which every
|
|
154
|
+
* member reads: the owner's phone and email are staff's to hold until the
|
|
155
|
+
* owner joins.
|
|
156
|
+
*/
|
|
157
|
+
export interface ClientBuildRecord {
|
|
158
|
+
intake: ClientBuildIntake;
|
|
159
|
+
/** `null` until the Domain step is answered. */
|
|
160
|
+
domain: ClientBuildDomain | null;
|
|
161
|
+
intent: ClientBuildIntent;
|
|
162
|
+
/** The site the build made, once it has. */
|
|
163
|
+
hostId: string | null;
|
|
164
|
+
/** Its subdomain, which is what a console URL names a site by. */
|
|
165
|
+
host: string | null;
|
|
166
|
+
/** The guided start's job, once it is started. */
|
|
167
|
+
jobId: string | null;
|
|
168
|
+
/**
|
|
169
|
+
* The starter site was given instead of a guided start (no AI on the
|
|
170
|
+
* workspace, or staff chose it), so the build step is finished without a job.
|
|
171
|
+
*/
|
|
172
|
+
starter: boolean;
|
|
173
|
+
/** When the preview was last sent to the owner, ms; `null` before. */
|
|
174
|
+
previewSentAt: number | null;
|
|
175
|
+
updatedAt: number;
|
|
176
|
+
/** The staff uid that last wrote it. */
|
|
177
|
+
updatedBy: string;
|
|
178
|
+
}
|
|
179
|
+
/** The subcollection and document the record lives at under its org. */
|
|
180
|
+
export declare const CLIENT_BUILD_COLLECTION = "clientBuild";
|
|
181
|
+
export declare const CLIENT_BUILD_DOC_ID = "current";
|
|
182
|
+
/** The screen's steps, in order. */
|
|
183
|
+
export declare const CLIENT_BUILD_STEPS: readonly ["details", "domain", "photos", "build", "send"];
|
|
184
|
+
export type ClientBuildStep = (typeof CLIENT_BUILD_STEPS)[number];
|
|
185
|
+
/**
|
|
186
|
+
* Where a stored build resumes: the first step it has not finished. A phone
|
|
187
|
+
* that reloads mid-build, or a second phone, opens where the first left off.
|
|
188
|
+
*/
|
|
189
|
+
export declare function clientBuildResumeStep(record: Pick<ClientBuildRecord, 'domain' | 'hostId' | 'jobId'> & {
|
|
190
|
+
starter?: boolean;
|
|
191
|
+
} | null): ClientBuildStep;
|
|
192
|
+
/**
|
|
193
|
+
* The address the site is going to live at, as the owner is told it: the
|
|
194
|
+
* domain they picked or already have, else the free address it is on.
|
|
195
|
+
*/
|
|
196
|
+
export declare function clientBuildSiteAddress(domain: ClientBuildDomain | null | undefined, liveUrl: string | null): string | null;
|
|
197
|
+
/**
|
|
198
|
+
* The text the owner gets with their preview: short enough for one or two
|
|
199
|
+
* segments, and naming who it is from, since it arrives from a number they
|
|
200
|
+
* do not know. The email says the same at length, from the catalog.
|
|
201
|
+
*/
|
|
202
|
+
export declare function clientBuildPreviewText(options: {
|
|
203
|
+
businessName: string;
|
|
204
|
+
previewUrl: string;
|
|
205
|
+
siteAddress: string | null;
|
|
206
|
+
productName: string;
|
|
207
|
+
}): string;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* A SITE STAFF BUILD FOR A CLIENT, ON ONE SCREEN (AGL-3958).
|
|
18
|
+
*
|
|
19
|
+
* At a booth or on a doorstep there is no laptop: staff create the client's
|
|
20
|
+
* workspace with "Build for a client" on (AGL-3952), and land on one screen
|
|
21
|
+
* that asks the business details once, records the domain the owner wants,
|
|
22
|
+
* shows the photo link's QR (AGL-3957), starts the guided AI start with those
|
|
23
|
+
* answers, and sends the owner the preview. This module is that screen's
|
|
24
|
+
* vocabulary: what is asked, what an answer may be, and the intent the
|
|
25
|
+
* hand-off carries into the owner's checkout.
|
|
26
|
+
*
|
|
27
|
+
* Pure: shapes, bounds and parsers, read by the screen, the staff route that
|
|
28
|
+
* stores the record and the hand-off that reads its intent. No React, no
|
|
29
|
+
* network.
|
|
30
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
31
|
+
import { normalizePhone } from "../foundation/definitions/contact.types.js";
|
|
32
|
+
import { SELF_SERVE_PLANS } from "./plan-entitlements.js";
|
|
33
|
+
/** The longest each answer may be, in characters. */ export const CLIENT_BUILD_LIMITS = {
|
|
34
|
+
// The three the guided start passes on as its own inputs, which it bounds
|
|
35
|
+
// at 120 (`AI_SITE_INPUT_MAX_CHARS`).
|
|
36
|
+
businessName: 120,
|
|
37
|
+
whatTheyDo: 120,
|
|
38
|
+
towns: 120,
|
|
39
|
+
phone: 32,
|
|
40
|
+
email: 254,
|
|
41
|
+
hours: 200,
|
|
42
|
+
ownerWords: 1500
|
|
43
|
+
};
|
|
44
|
+
/** An intake with nothing typed: what the screen starts on. */ export const EMPTY_CLIENT_BUILD_INTAKE = {
|
|
45
|
+
businessName: '',
|
|
46
|
+
whatTheyDo: '',
|
|
47
|
+
towns: '',
|
|
48
|
+
phone: '',
|
|
49
|
+
email: '',
|
|
50
|
+
hours: '',
|
|
51
|
+
ownerWords: ''
|
|
52
|
+
};
|
|
53
|
+
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
54
|
+
/**
|
|
55
|
+
* Why each answer cannot be used, in a sentence shown beside it; an answer
|
|
56
|
+
* that is fine has no entry. The name and what they do are required, since
|
|
57
|
+
* the site cannot be named or planned without them; the phone and the email
|
|
58
|
+
* are each optional, but the preview needs one of them to reach the owner.
|
|
59
|
+
*/ export function clientBuildIntakeErrors(intake) {
|
|
60
|
+
var _errors, _businessName, _errors1, _whatTheyDo, _errors2, _phone, _errors3, _email, _errors4, _phone1;
|
|
61
|
+
const errors = {};
|
|
62
|
+
for (const field of Object.keys(CLIENT_BUILD_LIMITS)){
|
|
63
|
+
if (intake[field].trim().length > CLIENT_BUILD_LIMITS[field]) {
|
|
64
|
+
errors[field] = `Keep this under ${CLIENT_BUILD_LIMITS[field].toLocaleString('en-US')} characters.`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!intake.businessName.trim()) (_businessName = (_errors = errors).businessName) != null ? _businessName : _errors.businessName = 'Name the business.';
|
|
68
|
+
if (!intake.whatTheyDo.trim()) (_whatTheyDo = (_errors1 = errors).whatTheyDo) != null ? _whatTheyDo : _errors1.whatTheyDo = 'Say what the business does.';
|
|
69
|
+
const phone = intake.phone.trim();
|
|
70
|
+
const email = intake.email.trim();
|
|
71
|
+
if (phone && !normalizePhone(phone)) (_phone = (_errors2 = errors).phone) != null ? _phone : _errors2.phone = 'Type a phone number with its area code.';
|
|
72
|
+
if (email && !EMAIL_PATTERN.test(email)) (_email = (_errors3 = errors).email) != null ? _email : _errors3.email = 'Type an email address like name@example.com.';
|
|
73
|
+
if (!phone && !email) (_phone1 = (_errors4 = errors).phone) != null ? _phone1 : _errors4.phone = 'Add a phone or an email, so the owner gets the preview.';
|
|
74
|
+
return errors;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* An intake as the route admits it: every answer a trimmed string within its
|
|
78
|
+
* bound, or the first reason it is not. Fields the body does not carry are
|
|
79
|
+
* empty, never `undefined`, so the record always has the same shape.
|
|
80
|
+
*/ export function parseClientBuildIntake(raw) {
|
|
81
|
+
if (!raw || typeof raw !== 'object') return 'Missing the business details';
|
|
82
|
+
const source = raw;
|
|
83
|
+
const intake = _extends({}, EMPTY_CLIENT_BUILD_INTAKE);
|
|
84
|
+
for (const field of Object.keys(CLIENT_BUILD_LIMITS)){
|
|
85
|
+
const value = source[field];
|
|
86
|
+
if (value === undefined || value === null) continue;
|
|
87
|
+
if (typeof value !== 'string') return `${field} must be text`;
|
|
88
|
+
intake[field] = value.trim();
|
|
89
|
+
}
|
|
90
|
+
const errors = clientBuildIntakeErrors(intake);
|
|
91
|
+
const first = Object.values(errors)[0];
|
|
92
|
+
return first != null ? first : intake;
|
|
93
|
+
}
|
|
94
|
+
/** The owner's phone as a text goes to it, E.164, or `null` when there is none to text. */ export function clientBuildPhone(intake) {
|
|
95
|
+
return normalizePhone(intake.phone);
|
|
96
|
+
}
|
|
97
|
+
/** A registrable name: labels of letters, digits and hyphens, and a TLD of letters. */ const DOMAIN_PATTERN = /^(?=.{3,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
|
98
|
+
/**
|
|
99
|
+
* A domain name as typed, normalized — lower case, no scheme, no `www.`, no
|
|
100
|
+
* path — or `null` when it is not one. "I have example.com" is typed on a
|
|
101
|
+
* phone, often as the address bar showed it.
|
|
102
|
+
*/ export function normalizeClientBuildDomainName(raw) {
|
|
103
|
+
if (typeof raw !== 'string') return null;
|
|
104
|
+
const name = raw.trim().toLowerCase().replace(/^[a-z]+:\/\//, '').replace(/^www\./, '').replace(/[/?#].*$/, '').replace(/\.$/, '');
|
|
105
|
+
return DOMAIN_PATTERN.test(name) ? name : null;
|
|
106
|
+
}
|
|
107
|
+
const isPrice = (value)=>typeof value === 'number' && Number.isFinite(value) && value >= 0 && value < 1000000;
|
|
108
|
+
/** A Domain step answer as the route admits it, or the reason it is not one. */ export function parseClientBuildDomain(raw) {
|
|
109
|
+
if (!raw || typeof raw !== 'object') return 'Missing the domain choice';
|
|
110
|
+
const source = raw;
|
|
111
|
+
if (source['choice'] === 'free') return {
|
|
112
|
+
choice: 'free'
|
|
113
|
+
};
|
|
114
|
+
const name = normalizeClientBuildDomainName(source['name']);
|
|
115
|
+
if (source['choice'] === 'own') {
|
|
116
|
+
return name ? {
|
|
117
|
+
choice: 'own',
|
|
118
|
+
name
|
|
119
|
+
} : 'Type the domain the owner has, like example.com';
|
|
120
|
+
}
|
|
121
|
+
if (source['choice'] === 'register') {
|
|
122
|
+
if (!name) return 'Pick a domain from the search';
|
|
123
|
+
if (!isPrice(source['firstYearUsd']) || !isPrice(source['renewalUsd'])) {
|
|
124
|
+
return 'The domain needs its first-year and renewal prices';
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
choice: 'register',
|
|
128
|
+
name,
|
|
129
|
+
firstYearUsd: source['firstYearUsd'],
|
|
130
|
+
renewalUsd: source['renewalUsd']
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return 'Unknown domain choice';
|
|
134
|
+
}
|
|
135
|
+
/** "$12.99" for a whole-dollar-and-cents price. */ export function formatDomainUsd(amount) {
|
|
136
|
+
return `$${amount.toFixed(2)}`;
|
|
137
|
+
}
|
|
138
|
+
/** "$12.99 the first year, then $18.99 a year": both prices together, always. */ export function domainPriceText(prices) {
|
|
139
|
+
return prices.firstYearUsd === prices.renewalUsd ? `${formatDomainUsd(prices.firstYearUsd)} a year` : `${formatDomainUsd(prices.firstYearUsd)} the first year, then ${formatDomainUsd(prices.renewalUsd)} a year`;
|
|
140
|
+
}
|
|
141
|
+
/** Site Care rides every build for a client unless staff take it off (AGL-3954). */ export const CLIENT_BUILD_DEFAULT_ADDONS = [
|
|
142
|
+
'siteCare'
|
|
143
|
+
];
|
|
144
|
+
/** The plans a build may propose: every self-serve tier but Free. */ const INTENT_PLANS = SELF_SERVE_PLANS.filter((plan)=>plan !== 'free');
|
|
145
|
+
/** The intent a build starts with: the plan the workspace was comped on, Site Care, monthly. */ export function clientBuildIntent(options) {
|
|
146
|
+
const plan = options.plan && INTENT_PLANS.includes(options.plan) ? options.plan : 'starter';
|
|
147
|
+
const domain = options.domain;
|
|
148
|
+
return _extends({
|
|
149
|
+
plan,
|
|
150
|
+
addons: [
|
|
151
|
+
...CLIENT_BUILD_DEFAULT_ADDONS
|
|
152
|
+
],
|
|
153
|
+
interval: 'month'
|
|
154
|
+
}, (domain == null ? void 0 : domain.choice) === 'register' ? {
|
|
155
|
+
domain: {
|
|
156
|
+
name: domain.name,
|
|
157
|
+
firstYearUsd: domain.firstYearUsd,
|
|
158
|
+
renewalUsd: domain.renewalUsd
|
|
159
|
+
}
|
|
160
|
+
} : {}, (domain == null ? void 0 : domain.choice) === 'own' ? {
|
|
161
|
+
existingDomain: domain.name
|
|
162
|
+
} : {});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* A stored intent, narrowed, or `null` when it is not one worth acting on.
|
|
166
|
+
* What the hand-off reads: a plan this build cannot sell, an add-on it does
|
|
167
|
+
* not know or a malformed domain reads as absent rather than as a checkout
|
|
168
|
+
* for something that does not exist.
|
|
169
|
+
*/ export function readClientBuildIntent(raw) {
|
|
170
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
171
|
+
const source = raw;
|
|
172
|
+
const plan = source['plan'];
|
|
173
|
+
if (typeof plan !== 'string' || !INTENT_PLANS.includes(plan)) return null;
|
|
174
|
+
const addons = Array.isArray(source['addons']) ? source['addons'].filter((addon)=>typeof addon === 'string' && addon.length > 0) : [];
|
|
175
|
+
const interval = source['interval'] === 'year' ? 'year' : 'month';
|
|
176
|
+
const coupon = typeof source['coupon'] === 'string' && source['coupon'].trim() ? source['coupon'].trim() : undefined;
|
|
177
|
+
const rawDomain = source['domain'];
|
|
178
|
+
const parsed = rawDomain && typeof rawDomain === 'object' ? parseClientBuildDomain(_extends({}, rawDomain, {
|
|
179
|
+
choice: 'register'
|
|
180
|
+
})) : null;
|
|
181
|
+
const domain = parsed && typeof parsed === 'object' && parsed.choice === 'register' ? parsed : null;
|
|
182
|
+
const existing = normalizeClientBuildDomainName(source['existingDomain']);
|
|
183
|
+
return _extends({
|
|
184
|
+
plan: plan,
|
|
185
|
+
addons,
|
|
186
|
+
interval
|
|
187
|
+
}, coupon ? {
|
|
188
|
+
coupon
|
|
189
|
+
} : {}, domain ? {
|
|
190
|
+
domain: {
|
|
191
|
+
name: domain.name,
|
|
192
|
+
firstYearUsd: domain.firstYearUsd,
|
|
193
|
+
renewalUsd: domain.renewalUsd
|
|
194
|
+
}
|
|
195
|
+
} : existing ? {
|
|
196
|
+
existingDomain: existing
|
|
197
|
+
} : {});
|
|
198
|
+
}
|
|
199
|
+
/** The subcollection and document the record lives at under its org. */ export const CLIENT_BUILD_COLLECTION = 'clientBuild';
|
|
200
|
+
export const CLIENT_BUILD_DOC_ID = 'current';
|
|
201
|
+
/** The screen's steps, in order. */ export const CLIENT_BUILD_STEPS = [
|
|
202
|
+
'details',
|
|
203
|
+
'domain',
|
|
204
|
+
'photos',
|
|
205
|
+
'build',
|
|
206
|
+
'send'
|
|
207
|
+
];
|
|
208
|
+
/**
|
|
209
|
+
* Where a stored build resumes: the first step it has not finished. A phone
|
|
210
|
+
* that reloads mid-build, or a second phone, opens where the first left off.
|
|
211
|
+
*/ export function clientBuildResumeStep(record) {
|
|
212
|
+
if (!record) return 'details';
|
|
213
|
+
if (!record.domain) return 'domain';
|
|
214
|
+
// The site exists before its photos are asked for, and the guided start
|
|
215
|
+
// waits on them: until a job is started, or the starter site was given
|
|
216
|
+
// instead, the build is at the photos.
|
|
217
|
+
if (!record.hostId || !record.jobId && !record.starter) return 'photos';
|
|
218
|
+
return 'send';
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The address the site is going to live at, as the owner is told it: the
|
|
222
|
+
* domain they picked or already have, else the free address it is on.
|
|
223
|
+
*/ export function clientBuildSiteAddress(domain, liveUrl) {
|
|
224
|
+
if (domain && domain.choice !== 'free') return domain.name;
|
|
225
|
+
return liveUrl ? liveUrl.replace(/^https?:\/\//, '') : null;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The text the owner gets with their preview: short enough for one or two
|
|
229
|
+
* segments, and naming who it is from, since it arrives from a number they
|
|
230
|
+
* do not know. The email says the same at length, from the catalog.
|
|
231
|
+
*/ export function clientBuildPreviewText(options) {
|
|
232
|
+
const name = options.businessName.trim() || 'your business';
|
|
233
|
+
const address = options.siteAddress && options.siteAddress !== options.previewUrl.replace(/^https?:\/\//, '') ? ` It will live at ${options.siteAddress}.` : '';
|
|
234
|
+
return `${options.productName}: the new website for ${name} is ready to look at: ${options.previewUrl}${address}`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
//# sourceMappingURL=client-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/client-build.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 * A SITE STAFF BUILD FOR A CLIENT, ON ONE SCREEN (AGL-3958).\n *\n * At a booth or on a doorstep there is no laptop: staff create the client's\n * workspace with \"Build for a client\" on (AGL-3952), and land on one screen\n * that asks the business details once, records the domain the owner wants,\n * shows the photo link's QR (AGL-3957), starts the guided AI start with those\n * answers, and sends the owner the preview. This module is that screen's\n * vocabulary: what is asked, what an answer may be, and the intent the\n * hand-off carries into the owner's checkout.\n *\n * Pure: shapes, bounds and parsers, read by the screen, the staff route that\n * stores the record and the hand-off that reads its intent. No React, no\n * network.\n */\n\nimport type { OrgPlan, OrgSeatAddons } from '../foundation/definitions/org-billing.types'\nimport { normalizePhone } from '../foundation/definitions/contact.types'\nimport { SELF_SERVE_PLANS } from './plan-entitlements'\n\n/** What staff ask the owner, once, and the guided start reads instead of asking again. */\nexport interface ClientBuildIntake {\n /** The business's name, as its header and footer will say it. */\n businessName: string\n /** What the business does, in a few words: the guided start's first answer. */\n whatTheyDo: string\n /** The towns or area it serves; empty when it serves no one place. */\n towns: string\n /** The owner's phone: the preview is texted here, and the site may show it. */\n phone: string\n /** The owner's email: the preview is emailed here, and the site may show it. */\n email: string\n /**\n * Opening hours as the owner says them, e.g. \"Mon–Fri 8am–5pm\". Said with\n * am or pm, they also fill the guided start's opening hours (AGL-3995).\n */\n hours: string\n /** The owner's own words about the business, in one box. */\n ownerWords: string\n}\n\nexport type ClientBuildIntakeField = keyof ClientBuildIntake\n\n/** The longest each answer may be, in characters. */\nexport const CLIENT_BUILD_LIMITS: Readonly<Record<ClientBuildIntakeField, number>> = {\n // The three the guided start passes on as its own inputs, which it bounds\n // at 120 (`AI_SITE_INPUT_MAX_CHARS`).\n businessName: 120,\n whatTheyDo: 120,\n towns: 120,\n phone: 32,\n email: 254,\n hours: 200,\n ownerWords: 1_500,\n}\n\n/** An intake with nothing typed: what the screen starts on. */\nexport const EMPTY_CLIENT_BUILD_INTAKE: ClientBuildIntake = {\n businessName: '',\n whatTheyDo: '',\n towns: '',\n phone: '',\n email: '',\n hours: '',\n ownerWords: '',\n}\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\n/**\n * Why each answer cannot be used, in a sentence shown beside it; an answer\n * that is fine has no entry. The name and what they do are required, since\n * the site cannot be named or planned without them; the phone and the email\n * are each optional, but the preview needs one of them to reach the owner.\n */\nexport function clientBuildIntakeErrors(\n intake: ClientBuildIntake,\n): Partial<Record<ClientBuildIntakeField, string>> {\n const errors: Partial<Record<ClientBuildIntakeField, string>> = {}\n for (const field of Object.keys(CLIENT_BUILD_LIMITS) as ClientBuildIntakeField[]) {\n if (intake[field].trim().length > CLIENT_BUILD_LIMITS[field]) {\n errors[field] = `Keep this under ${CLIENT_BUILD_LIMITS[field].toLocaleString('en-US')} characters.`\n }\n }\n if (!intake.businessName.trim()) errors.businessName ??= 'Name the business.'\n if (!intake.whatTheyDo.trim()) errors.whatTheyDo ??= 'Say what the business does.'\n const phone = intake.phone.trim()\n const email = intake.email.trim()\n if (phone && !normalizePhone(phone)) errors.phone ??= 'Type a phone number with its area code.'\n if (email && !EMAIL_PATTERN.test(email)) errors.email ??= 'Type an email address like name@example.com.'\n if (!phone && !email) errors.phone ??= 'Add a phone or an email, so the owner gets the preview.'\n return errors\n}\n\n/**\n * An intake as the route admits it: every answer a trimmed string within its\n * bound, or the first reason it is not. Fields the body does not carry are\n * empty, never `undefined`, so the record always has the same shape.\n */\nexport function parseClientBuildIntake(raw: unknown): ClientBuildIntake | string {\n if (!raw || typeof raw !== 'object') return 'Missing the business details'\n const source = raw as Record<string, unknown>\n const intake = { ...EMPTY_CLIENT_BUILD_INTAKE }\n for (const field of Object.keys(CLIENT_BUILD_LIMITS) as ClientBuildIntakeField[]) {\n const value = source[field]\n if (value === undefined || value === null) continue\n if (typeof value !== 'string') return `${field} must be text`\n intake[field] = value.trim()\n }\n const errors = clientBuildIntakeErrors(intake)\n const first = Object.values(errors)[0]\n return first ?? intake\n}\n\n/** The owner's phone as a text goes to it, E.164, or `null` when there is none to text. */\nexport function clientBuildPhone(intake: Pick<ClientBuildIntake, 'phone'>): string | null {\n return normalizePhone(intake.phone)\n}\n\n// ── The domain ─────────────────────────────────────────────────────────────\n\n/**\n * What the owner chose on the Domain step (Zach, 2026-10-19).\n *\n * - `free`: the site stays on its free address for now.\n * - `register`: a name the owner wants to buy. NOT bought here: it rides the\n * bundle link, so the owner buys it on their own phone after they\n * subscribe, with their own registrant details and their own tick on the\n * registrar's terms.\n * - `own`: a domain the owner already has, which the hand-off and the Site\n * Care intake connect (one-click DNS opens the owner's provider and needs\n * their login, so staff do it with them, or hand them the records).\n */\nexport type ClientBuildDomain =\n | { choice: 'free' }\n | { choice: 'register'; name: string; firstYearUsd: number; renewalUsd: number }\n | { choice: 'own'; name: string }\n\n/** A registrable name: labels of letters, digits and hyphens, and a TLD of letters. */\nconst DOMAIN_PATTERN = /^(?=.{3,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/\n\n/**\n * A domain name as typed, normalized — lower case, no scheme, no `www.`, no\n * path — or `null` when it is not one. \"I have example.com\" is typed on a\n * phone, often as the address bar showed it.\n */\nexport function normalizeClientBuildDomainName(raw: unknown): string | null {\n if (typeof raw !== 'string') return null\n const name = raw\n .trim()\n .toLowerCase()\n .replace(/^[a-z]+:\\/\\//, '')\n .replace(/^www\\./, '')\n .replace(/[/?#].*$/, '')\n .replace(/\\.$/, '')\n return DOMAIN_PATTERN.test(name) ? name : null\n}\n\nconst isPrice = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value) && value >= 0 && value < 1_000_000\n\n/** A Domain step answer as the route admits it, or the reason it is not one. */\nexport function parseClientBuildDomain(raw: unknown): ClientBuildDomain | string {\n if (!raw || typeof raw !== 'object') return 'Missing the domain choice'\n const source = raw as Record<string, unknown>\n if (source['choice'] === 'free') return { choice: 'free' }\n const name = normalizeClientBuildDomainName(source['name'])\n if (source['choice'] === 'own') {\n return name ? { choice: 'own', name } : 'Type the domain the owner has, like example.com'\n }\n if (source['choice'] === 'register') {\n if (!name) return 'Pick a domain from the search'\n if (!isPrice(source['firstYearUsd']) || !isPrice(source['renewalUsd'])) {\n return 'The domain needs its first-year and renewal prices'\n }\n return {\n choice: 'register',\n name,\n firstYearUsd: source['firstYearUsd'],\n renewalUsd: source['renewalUsd'],\n }\n }\n return 'Unknown domain choice'\n}\n\n/** \"$12.99\" for a whole-dollar-and-cents price. */\nexport function formatDomainUsd(amount: number): string {\n return `$${amount.toFixed(2)}`\n}\n\n/** \"$12.99 the first year, then $18.99 a year\": both prices together, always. */\nexport function domainPriceText(prices: { firstYearUsd: number; renewalUsd: number }): string {\n return prices.firstYearUsd === prices.renewalUsd\n ? `${formatDomainUsd(prices.firstYearUsd)} a year`\n : `${formatDomainUsd(prices.firstYearUsd)} the first year, then ${formatDomainUsd(prices.renewalUsd)} a year`\n}\n\n// ── The intent the hand-off carries ────────────────────────────────────────\n\n/** Add-ons, by their `OrgSeatAddons` key, as Billing sells them. */\nexport type ClientBuildAddon = keyof OrgSeatAddons\n\n/**\n * What the owner is asked to buy, as the build leaves it for the hand-off\n * (AGL-3955, AGL-3956): the plan, the add-ons, the interval, a coupon, and\n * the domain they picked. The hand-off dialog opens on it and the bundle\n * link preselects it, so the owner's checkout is one tap from paid.\n *\n * `domain` is a name to REGISTER, bought by the owner after they subscribe;\n * `existingDomain` is one they already hold, which is connected rather than\n * bought. At most one of the two is set.\n */\nexport interface ClientBuildIntent {\n plan: OrgPlan\n addons: ClientBuildAddon[]\n interval: 'month' | 'year'\n coupon?: string\n domain?: { name: string; firstYearUsd: number; renewalUsd: number }\n existingDomain?: string\n}\n\n/** Site Care rides every build for a client unless staff take it off (AGL-3954). */\nexport const CLIENT_BUILD_DEFAULT_ADDONS: readonly ClientBuildAddon[] = ['siteCare']\n\n/** The plans a build may propose: every self-serve tier but Free. */\nconst INTENT_PLANS: readonly OrgPlan[] = SELF_SERVE_PLANS.filter((plan) => plan !== 'free')\n\n/** The intent a build starts with: the plan the workspace was comped on, Site Care, monthly. */\nexport function clientBuildIntent(options: {\n plan: OrgPlan | null | undefined\n domain?: ClientBuildDomain | null\n}): ClientBuildIntent {\n const plan = options.plan && INTENT_PLANS.includes(options.plan) ? options.plan : 'starter'\n const domain = options.domain\n return {\n plan,\n addons: [...CLIENT_BUILD_DEFAULT_ADDONS],\n interval: 'month',\n ...(domain?.choice === 'register'\n ? { domain: { name: domain.name, firstYearUsd: domain.firstYearUsd, renewalUsd: domain.renewalUsd } }\n : {}),\n ...(domain?.choice === 'own' ? { existingDomain: domain.name } : {}),\n }\n}\n\n/**\n * A stored intent, narrowed, or `null` when it is not one worth acting on.\n * What the hand-off reads: a plan this build cannot sell, an add-on it does\n * not know or a malformed domain reads as absent rather than as a checkout\n * for something that does not exist.\n */\nexport function readClientBuildIntent(raw: unknown): ClientBuildIntent | null {\n if (!raw || typeof raw !== 'object') return null\n const source = raw as Record<string, unknown>\n const plan = source['plan']\n if (typeof plan !== 'string' || !(INTENT_PLANS as readonly string[]).includes(plan)) return null\n const addons = Array.isArray(source['addons'])\n ? source['addons'].filter((addon): addon is ClientBuildAddon => typeof addon === 'string' && addon.length > 0)\n : []\n const interval = source['interval'] === 'year' ? 'year' : 'month'\n const coupon = typeof source['coupon'] === 'string' && source['coupon'].trim() ? source['coupon'].trim() : undefined\n const rawDomain = source['domain']\n const parsed =\n rawDomain && typeof rawDomain === 'object' ? parseClientBuildDomain({ ...rawDomain, choice: 'register' }) : null\n const domain = parsed && typeof parsed === 'object' && parsed.choice === 'register' ? parsed : null\n const existing = normalizeClientBuildDomainName(source['existingDomain'])\n return {\n plan: plan as OrgPlan,\n addons,\n interval,\n ...(coupon ? { coupon } : {}),\n ...(domain\n ? { domain: { name: domain.name, firstYearUsd: domain.firstYearUsd, renewalUsd: domain.renewalUsd } }\n : existing\n ? { existingDomain: existing }\n : {}),\n }\n}\n\n// ── The record ─────────────────────────────────────────────────────────────\n\n/**\n * The build as it is stored, one per workspace, at\n * `orgs/{orgId}/clientBuild/{CLIENT_BUILD_DOC_ID}`: a subcollection the rules\n * open to no client, written and read only by `/api/admin/client-build`\n * (staff) through the Admin SDK. Not on the org document, which every\n * member reads: the owner's phone and email are staff's to hold until the\n * owner joins.\n */\nexport interface ClientBuildRecord {\n intake: ClientBuildIntake\n /** `null` until the Domain step is answered. */\n domain: ClientBuildDomain | null\n intent: ClientBuildIntent\n /** The site the build made, once it has. */\n hostId: string | null\n /** Its subdomain, which is what a console URL names a site by. */\n host: string | null\n /** The guided start's job, once it is started. */\n jobId: string | null\n /**\n * The starter site was given instead of a guided start (no AI on the\n * workspace, or staff chose it), so the build step is finished without a job.\n */\n starter: boolean\n /** When the preview was last sent to the owner, ms; `null` before. */\n previewSentAt: number | null\n updatedAt: number\n /** The staff uid that last wrote it. */\n updatedBy: string\n}\n\n/** The subcollection and document the record lives at under its org. */\nexport const CLIENT_BUILD_COLLECTION = 'clientBuild'\nexport const CLIENT_BUILD_DOC_ID = 'current'\n\n/** The screen's steps, in order. */\nexport const CLIENT_BUILD_STEPS = ['details', 'domain', 'photos', 'build', 'send'] as const\nexport type ClientBuildStep = (typeof CLIENT_BUILD_STEPS)[number]\n\n/**\n * Where a stored build resumes: the first step it has not finished. A phone\n * that reloads mid-build, or a second phone, opens where the first left off.\n */\nexport function clientBuildResumeStep(\n record: Pick<ClientBuildRecord, 'domain' | 'hostId' | 'jobId'> & { starter?: boolean } | null,\n): ClientBuildStep {\n if (!record) return 'details'\n if (!record.domain) return 'domain'\n // The site exists before its photos are asked for, and the guided start\n // waits on them: until a job is started, or the starter site was given\n // instead, the build is at the photos.\n if (!record.hostId || (!record.jobId && !record.starter)) return 'photos'\n return 'send'\n}\n\n/**\n * The address the site is going to live at, as the owner is told it: the\n * domain they picked or already have, else the free address it is on.\n */\nexport function clientBuildSiteAddress(\n domain: ClientBuildDomain | null | undefined,\n liveUrl: string | null,\n): string | null {\n if (domain && domain.choice !== 'free') return domain.name\n return liveUrl ? liveUrl.replace(/^https?:\\/\\//, '') : null\n}\n\n/**\n * The text the owner gets with their preview: short enough for one or two\n * segments, and naming who it is from, since it arrives from a number they\n * do not know. The email says the same at length, from the catalog.\n */\nexport function clientBuildPreviewText(options: {\n businessName: string\n previewUrl: string\n siteAddress: string | null\n productName: string\n}): string {\n const name = options.businessName.trim() || 'your business'\n const address =\n options.siteAddress && options.siteAddress !== options.previewUrl.replace(/^https?:\\/\\//, '')\n ? ` It will live at ${options.siteAddress}.`\n : ''\n return `${options.productName}: the new website for ${name} is ready to look at: ${options.previewUrl}${address}`\n}\n"],"names":["normalizePhone","SELF_SERVE_PLANS","CLIENT_BUILD_LIMITS","businessName","whatTheyDo","towns","phone","email","hours","ownerWords","EMPTY_CLIENT_BUILD_INTAKE","EMAIL_PATTERN","clientBuildIntakeErrors","intake","errors","field","Object","keys","trim","length","toLocaleString","test","parseClientBuildIntake","raw","source","value","undefined","first","values","clientBuildPhone","DOMAIN_PATTERN","normalizeClientBuildDomainName","name","toLowerCase","replace","isPrice","Number","isFinite","parseClientBuildDomain","choice","firstYearUsd","renewalUsd","formatDomainUsd","amount","toFixed","domainPriceText","prices","CLIENT_BUILD_DEFAULT_ADDONS","INTENT_PLANS","filter","plan","clientBuildIntent","options","includes","domain","addons","interval","existingDomain","readClientBuildIntent","Array","isArray","addon","coupon","rawDomain","parsed","existing","CLIENT_BUILD_COLLECTION","CLIENT_BUILD_DOC_ID","CLIENT_BUILD_STEPS","clientBuildResumeStep","record","hostId","jobId","starter","clientBuildSiteAddress","liveUrl","clientBuildPreviewText","address","siteAddress","previewUrl","productName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;CAcC;AAGD,SAASA,cAAc,QAAQ,6CAAyC;AACxE,SAASC,gBAAgB,QAAQ,yBAAqB;AAyBtD,mDAAmD,GACnD,OAAO,MAAMC,sBAAwE;IACnF,0EAA0E;IAC1E,sCAAsC;IACtCC,cAAc;IACdC,YAAY;IACZC,OAAO;IACPC,OAAO;IACPC,OAAO;IACPC,OAAO;IACPC,YAAY;AACd,EAAC;AAED,6DAA6D,GAC7D,OAAO,MAAMC,4BAA+C;IAC1DP,cAAc;IACdC,YAAY;IACZC,OAAO;IACPC,OAAO;IACPC,OAAO;IACPC,OAAO;IACPC,YAAY;AACd,EAAC;AAED,MAAME,gBAAgB;AAEtB;;;;;CAKC,GACD,OAAO,SAASC,wBACdC,MAAyB;QAQQC,SAAAA,eACFA,UAAAA,aAGMA,UAAAA,QACIA,UAAAA,QACnBA,UAAAA;IAZtB,MAAMA,SAA0D,CAAC;IACjE,KAAK,MAAMC,SAASC,OAAOC,IAAI,CAACf,qBAAkD;QAChF,IAAIW,MAAM,CAACE,MAAM,CAACG,IAAI,GAAGC,MAAM,GAAGjB,mBAAmB,CAACa,MAAM,EAAE;YAC5DD,MAAM,CAACC,MAAM,GAAG,CAAC,gBAAgB,EAAEb,mBAAmB,CAACa,MAAM,CAACK,cAAc,CAAC,SAAS,YAAY,CAAC;QACrG;IACF;IACA,IAAI,CAACP,OAAOV,YAAY,CAACe,IAAI,KAAIJ,gBAAAA,CAAAA,UAAAA,QAAOX,YAAY,YAAnBW,gBAAAA,QAAOX,YAAY,GAAK;IACzD,IAAI,CAACU,OAAOT,UAAU,CAACc,IAAI,KAAIJ,cAAAA,CAAAA,WAAAA,QAAOV,UAAU,YAAjBU,cAAAA,SAAOV,UAAU,GAAK;IACrD,MAAME,QAAQO,OAAOP,KAAK,CAACY,IAAI;IAC/B,MAAMX,QAAQM,OAAON,K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AAMpB,OAAOoB,QAAQjD,YAAY,CAACe,IAAI,MAAM;IAC5C,MAAM2D,UACJzB,QAAQ0B,WAAW,IAAI1B,QAAQ0B,WAAW,KAAK1B,QAAQ2B,UAAU,CAAC7C,OAAO,CAAC,gBAAgB,MACtF,CAAC,iBAAiB,EAAEkB,QAAQ0B,WAAW,CAAC,CAAC,CAAC,GAC1C;IACN,OAAO,GAAG1B,QAAQ4B,WAAW,CAAC,sBAAsB,EAAEhD,KAAK,sBAAsB,EAAEoB,QAAQ2B,UAAU,GAAGF,SAAS;AACnH"}
|
|
@@ -43,6 +43,7 @@ export declare enum Route {
|
|
|
43
43
|
ADMIN_EMAILS = "/admin/emails",
|
|
44
44
|
ADMIN_EMAIL_BESIGNER = "/admin/emails/[templateKey]/versions/[versionId]/besigner",
|
|
45
45
|
ORG_HOME = "/[orgSlug]",
|
|
46
|
+
ORG_CLIENT_BUILD = "/[orgSlug]/client-build",
|
|
46
47
|
ORG_MEDIA = "/[orgSlug]/media",
|
|
47
48
|
ORG_DATA = "/[orgSlug]/data",
|
|
48
49
|
ORG_CRM = "/[orgSlug]/crm",
|
|
@@ -190,6 +191,9 @@ export interface RoutePayload {
|
|
|
190
191
|
[Route.ORG_HOME]: {
|
|
191
192
|
orgSlug: string;
|
|
192
193
|
};
|
|
194
|
+
[Route.ORG_CLIENT_BUILD]: {
|
|
195
|
+
orgSlug: string;
|
|
196
|
+
};
|
|
193
197
|
[Route.HOST_DASHBOARD]: {
|
|
194
198
|
orgSlug: string;
|
|
195
199
|
host: string;
|
|
@@ -105,6 +105,8 @@ export var Route = /*#__PURE__*/ function(Route) {
|
|
|
105
105
|
// like the rest of `/admin/*` rather than nested under `[orgSlug]`.
|
|
106
106
|
Route["ADMIN_EMAIL_BESIGNER"] = "/admin/emails/[templateKey]/versions/[versionId]/besigner";
|
|
107
107
|
Route["ORG_HOME"] = "/[orgSlug]";
|
|
108
|
+
// Staff build a site for a client on one phone screen (AGL-3958).
|
|
109
|
+
Route["ORG_CLIENT_BUILD"] = "/[orgSlug]/client-build";
|
|
108
110
|
Route["ORG_MEDIA"] = "/[orgSlug]/media";
|
|
109
111
|
Route["ORG_DATA"] = "/[orgSlug]/data";
|
|
110
112
|
/*
|