@aglyn/aglyn 1.0.0-beta.254 → 1.0.0-beta.256
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/activity-labels.js +2 -0
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/business-profile-values.d.ts +83 -0
- package/src/lib/app-utils/business-profile-values.js +160 -0
- package/src/lib/app-utils/business-profile-values.js.map +1 -0
- package/src/lib/app-utils/business-profile.d.ts +7 -60
- package/src/lib/app-utils/business-profile.js +2 -172
- package/src/lib/app-utils/business-profile.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +8 -5
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +16 -10
- package/src/lib/app-utils/docs-help.generated.js +56 -18
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +278 -5
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/lockdown.d.ts +6 -0
- package/src/lib/app-utils/lockdown.js +20 -0
- package/src/lib/app-utils/lockdown.js.map +1 -1
- package/src/lib/app-utils/native-app-association.d.ts +139 -0
- package/src/lib/app-utils/native-app-association.js +264 -0
- package/src/lib/app-utils/native-app-association.js.map +1 -0
- package/src/lib/app-utils/sso-enforcement.d.ts +69 -0
- package/src/lib/app-utils/sso-enforcement.js +66 -0
- package/src/lib/app-utils/sso-enforcement.js.map +1 -0
- package/src/lib/app-utils/time-zone-choices.d.ts +46 -0
- package/src/lib/app-utils/time-zone-choices.js +469 -0
- package/src/lib/app-utils/time-zone-choices.js.map +1 -0
- package/src/lib/data-transfer/site-package-diff.d.ts +108 -0
- package/src/lib/data-transfer/site-package-diff.js +268 -0
- package/src/lib/data-transfer/site-package-diff.js.map +1 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +2 -2
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright 2026 Aglyn LLC
|
|
@@ -17,179 +16,10 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
17
16
|
*/ import { siteProfileUrls } from "./content-authors.js";
|
|
18
17
|
import { normalizeAreaServed } from "./local-business.js";
|
|
19
18
|
import { PLATFORM_BRAND_NAME } from "./platform-brand.js";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* that writes about it needs to know — the site's own pages, the structured
|
|
23
|
-
* data, and any generator a plugin brings.
|
|
24
|
-
*
|
|
25
|
-
* ── Most of it is already stored, so this stores only the rest ─────────────
|
|
26
|
-
*
|
|
27
|
-
* The site's name, its one-line description, its contact details, its hours,
|
|
28
|
-
* the areas it serves and its social profiles all have a home on the host
|
|
29
|
-
* document already: `seo.entity` (the publisher entity the JSON-LD is built
|
|
30
|
-
* from, edited in Setup → SEO) and `business` (the contact card the `host.*`
|
|
31
|
-
* tokens and the footer read, edited in Setup → Basic details). Copying them
|
|
32
|
-
* here would make two places to keep in step, and the copy would drift.
|
|
33
|
-
*
|
|
34
|
-
* So the profile document holds only what has no home yet — the services, the
|
|
35
|
-
* audience, the tone of voice — plus a line about the business and the area it
|
|
36
|
-
* serves for a site whose SEO entity does not say. {@link resolveBusinessProfile}
|
|
37
|
-
* reads the two together into one picture, field by field, and says where
|
|
38
|
-
* each value came from.
|
|
39
|
-
*
|
|
40
|
-
* ── Where it is stored ────────────────────────────────────────────────────
|
|
41
|
-
*
|
|
42
|
-
* `hosts/{hostId}/businessProfile/profile` for a site and
|
|
43
|
-
* `orgs/{orgId}/businessProfile/defaults` for the workspace, whose values a
|
|
44
|
-
* site inherits where it has none of its own. A subcollection document rather
|
|
45
|
-
* than a key on the host: the host document's `business` map is replaced
|
|
46
|
-
* whole by the contact card's save, and a key beside it would be one more
|
|
47
|
-
* thing a partial write could blank.
|
|
48
|
-
*
|
|
49
|
-
* ── Whose words win ───────────────────────────────────────────────────────
|
|
50
|
-
*
|
|
51
|
-
* Every stored value carries its source. What the owner typed is never
|
|
52
|
-
* replaced by anything else; what the guided start was told replaces only
|
|
53
|
-
* what a generator guessed; and a generator's guess fills only what is empty.
|
|
54
|
-
* {@link mergeBusinessProfilePrefill} is the one place that rule is applied.
|
|
55
|
-
*/ /** The collection a profile document lives in, under a host or an org. */ export const BUSINESS_PROFILE_SUBCOLLECTION = 'businessProfile';
|
|
56
|
-
/** The site's profile document id. */ export const BUSINESS_PROFILE_SITE_DOC = 'profile';
|
|
57
|
-
/** The workspace defaults document id. */ export const BUSINESS_PROFILE_WORKSPACE_DOC = 'defaults';
|
|
58
|
-
/** How much a source's words weigh: a higher rank is never replaced by a lower one. */ const SOURCE_RANK = {
|
|
59
|
-
ai: 1,
|
|
60
|
-
start: 2,
|
|
61
|
-
owner: 3
|
|
62
|
-
};
|
|
63
|
-
export const BUSINESS_TONES = [
|
|
64
|
-
'friendly',
|
|
65
|
-
'professional',
|
|
66
|
-
'playful',
|
|
67
|
-
'premium',
|
|
68
|
-
'plain'
|
|
69
|
-
];
|
|
19
|
+
import { BUSINESS_PROFILE_FIELDS, BUSINESS_PROFILE_MAX_CHARS, BUSINESS_TONES, businessProfileSourceOf, fieldValue, isEmpty, text } from "./business-profile-values.js";
|
|
20
|
+
export { BUSINESS_PROFILE_FIELDS, BUSINESS_PROFILE_MAX_CHARS, BUSINESS_PROFILE_MAX_SERVICES, BUSINESS_PROFILE_SITE_DOC, BUSINESS_PROFILE_SUBCOLLECTION, BUSINESS_PROFILE_WORKSPACE_DOC, BUSINESS_TONE_LABELS, BUSINESS_TONES, businessProfileOwnerWrite, businessProfileSourceOf, mergeBusinessProfilePrefill, sanitizeBusinessProfileValues } from "./business-profile-values.js";
|
|
70
21
|
/** The tones as a plain list, in the order the owner picks them, for the native apps' pickers. */ export const BUSINESS_TONE_ORDER = BUSINESS_TONES;
|
|
71
|
-
/** Each tone as the owner picks it and as a writer is told it. */ export const BUSINESS_TONE_LABELS = {
|
|
72
|
-
friendly: 'Friendly and warm',
|
|
73
|
-
professional: 'Professional and clear',
|
|
74
|
-
playful: 'Playful and upbeat',
|
|
75
|
-
premium: 'Premium and refined',
|
|
76
|
-
plain: 'Plain and direct'
|
|
77
|
-
};
|
|
78
|
-
/** The fields the profile document stores itself. */ export const BUSINESS_PROFILE_FIELDS = [
|
|
79
|
-
'whatYouDo',
|
|
80
|
-
'services',
|
|
81
|
-
'serviceArea',
|
|
82
|
-
'audience',
|
|
83
|
-
'tone',
|
|
84
|
-
'toneNotes'
|
|
85
|
-
];
|
|
86
22
|
/** The stored fields as a plain list, for the native apps' writers. */ export const BUSINESS_PROFILE_FIELD_ORDER = BUSINESS_PROFILE_FIELDS;
|
|
87
|
-
/** Each field's ceiling, in characters; `services` is per item. */ export const BUSINESS_PROFILE_MAX_CHARS = {
|
|
88
|
-
whatYouDo: 200,
|
|
89
|
-
services: 60,
|
|
90
|
-
serviceArea: 120,
|
|
91
|
-
audience: 160,
|
|
92
|
-
toneNotes: 200
|
|
93
|
-
};
|
|
94
|
-
/** At most this many services are kept. */ export const BUSINESS_PROFILE_MAX_SERVICES = 12;
|
|
95
|
-
const text = (value, max)=>typeof value === 'string' ? value.replace(/\s+/g, ' ').trim().slice(0, max) : '';
|
|
96
|
-
const tone = (value)=>BUSINESS_TONES.includes(value) ? value : null;
|
|
97
|
-
const services = (value)=>{
|
|
98
|
-
const items = Array.isArray(value) ? value : typeof value === 'string' ? value.split(/[,\n]/) : [];
|
|
99
|
-
const seen = new Set();
|
|
100
|
-
const kept = [];
|
|
101
|
-
for (const item of items){
|
|
102
|
-
const name = text(item, BUSINESS_PROFILE_MAX_CHARS.services);
|
|
103
|
-
const key = name.toLowerCase();
|
|
104
|
-
if (!name || seen.has(key)) continue;
|
|
105
|
-
seen.add(key);
|
|
106
|
-
kept.push(name);
|
|
107
|
-
if (kept.length >= BUSINESS_PROFILE_MAX_SERVICES) break;
|
|
108
|
-
}
|
|
109
|
-
return kept;
|
|
110
|
-
};
|
|
111
|
-
/** One field's stored value, sanitized; empty is `''`, `[]` or `null`. */ function fieldValue(doc, field) {
|
|
112
|
-
switch(field){
|
|
113
|
-
case 'services':
|
|
114
|
-
return services(doc == null ? void 0 : doc.services);
|
|
115
|
-
case 'tone':
|
|
116
|
-
return tone(doc == null ? void 0 : doc.tone);
|
|
117
|
-
default:
|
|
118
|
-
return text(doc == null ? void 0 : doc[field], BUSINESS_PROFILE_MAX_CHARS[field]);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const isEmpty = (value)=>value === null || value === '' || Array.isArray(value) && value.length === 0;
|
|
122
|
-
/** The source a stored, non-empty value carries; the owner's when none is recorded. */ export function businessProfileSourceOf(doc, field) {
|
|
123
|
-
var _doc_sources;
|
|
124
|
-
if (isEmpty(fieldValue(doc, field))) return null;
|
|
125
|
-
const source = doc == null ? void 0 : (_doc_sources = doc.sources) == null ? void 0 : _doc_sources[field];
|
|
126
|
-
return source && source in SOURCE_RANK ? source : 'owner';
|
|
127
|
-
}
|
|
128
|
-
/** Every value a write may carry, sanitized; an absent field stays absent. */ export function sanitizeBusinessProfileValues(values) {
|
|
129
|
-
const clean = {};
|
|
130
|
-
for (const field of BUSINESS_PROFILE_FIELDS){
|
|
131
|
-
if (!(field in values)) continue;
|
|
132
|
-
clean[field] = fieldValue(values, field);
|
|
133
|
-
}
|
|
134
|
-
return clean;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* The document a generator's or the guided start's values make of the stored
|
|
138
|
-
* one: each value fills a field that is empty or was written by a source that
|
|
139
|
-
* weighs less, and nothing else. `null` when nothing would change, so a caller
|
|
140
|
-
* writes only when there is something to write.
|
|
141
|
-
*/ export function mergeBusinessProfilePrefill(current, values, source) {
|
|
142
|
-
var _ref;
|
|
143
|
-
const clean = sanitizeBusinessProfileValues(values);
|
|
144
|
-
const next = _extends({}, current != null ? current : {}, {
|
|
145
|
-
sources: _extends({}, (_ref = current == null ? void 0 : current.sources) != null ? _ref : {})
|
|
146
|
-
});
|
|
147
|
-
let changed = false;
|
|
148
|
-
for (const field of BUSINESS_PROFILE_FIELDS){
|
|
149
|
-
var _current_sources;
|
|
150
|
-
if (!(field in clean)) continue;
|
|
151
|
-
const value = clean[field];
|
|
152
|
-
if (isEmpty(value)) continue;
|
|
153
|
-
// An explicit source counts even on an empty value: a field the owner
|
|
154
|
-
// cleared stays cleared rather than being refilled behind them.
|
|
155
|
-
const recorded = current == null ? void 0 : (_current_sources = current.sources) == null ? void 0 : _current_sources[field];
|
|
156
|
-
const held = recorded && recorded in SOURCE_RANK ? recorded : businessProfileSourceOf(current, field);
|
|
157
|
-
if (held && SOURCE_RANK[held] >= SOURCE_RANK[source]) continue;
|
|
158
|
-
if (JSON.stringify(fieldValue(current, field)) === JSON.stringify(value)) continue;
|
|
159
|
-
next[field] = value;
|
|
160
|
-
next.sources[field] = source;
|
|
161
|
-
changed = true;
|
|
162
|
-
}
|
|
163
|
-
return changed ? next : null;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* The document the owner's save makes: every field they changed becomes
|
|
167
|
-
* theirs, and a field they left as it was keeps the source it had — so saving
|
|
168
|
-
* the form after correcting one line does not claim every suggestion on it.
|
|
169
|
-
*/ export function businessProfileOwnerWrite(current, edited) {
|
|
170
|
-
const clean = sanitizeBusinessProfileValues(edited);
|
|
171
|
-
const next = {};
|
|
172
|
-
const sources = {};
|
|
173
|
-
for (const field of BUSINESS_PROFILE_FIELDS){
|
|
174
|
-
var _businessProfileSourceOf;
|
|
175
|
-
const before = fieldValue(current, field);
|
|
176
|
-
const after = field in clean ? clean[field] : before;
|
|
177
|
-
next[field] = after;
|
|
178
|
-
const same = JSON.stringify(before) === JSON.stringify(after);
|
|
179
|
-
if (isEmpty(after)) {
|
|
180
|
-
var _current_sources;
|
|
181
|
-
// A suggestion the owner deleted is their decision, and recorded as
|
|
182
|
-
// one, so the next prefill does not put it back.
|
|
183
|
-
if (!same) sources[field] = 'owner';
|
|
184
|
-
else if ((current == null ? void 0 : (_current_sources = current.sources) == null ? void 0 : _current_sources[field]) === 'owner') sources[field] = 'owner';
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
sources[field] = same ? (_businessProfileSourceOf = businessProfileSourceOf(current, field)) != null ? _businessProfileSourceOf : 'owner' : 'owner';
|
|
188
|
-
}
|
|
189
|
-
return _extends({}, next, {
|
|
190
|
-
sources
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
23
|
/** The postal address as one line: the SEO entity's parts, else the contact card's block. */ function addressLine(host) {
|
|
194
24
|
var _host_seo_entity, _host_seo, _host_business;
|
|
195
25
|
const parts = host == null ? void 0 : (_host_seo = host.seo) == null ? void 0 : (_host_seo_entity = _host_seo.entity) == null ? void 0 : _host_seo_entity.address;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/business-profile.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\nimport { siteProfileUrls, type HostSeoEntity } from './content-authors'\nimport { normalizeAreaServed } from './local-business'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\n\n/**\n * A site's BUSINESS PROFILE (AGL-3661): what the business is, as everything\n * that writes about it needs to know — the site's own pages, the structured\n * data, and any generator a plugin brings.\n *\n * ── Most of it is already stored, so this stores only the rest ─────────────\n *\n * The site's name, its one-line description, its contact details, its hours,\n * the areas it serves and its social profiles all have a home on the host\n * document already: `seo.entity` (the publisher entity the JSON-LD is built\n * from, edited in Setup → SEO) and `business` (the contact card the `host.*`\n * tokens and the footer read, edited in Setup → Basic details). Copying them\n * here would make two places to keep in step, and the copy would drift.\n *\n * So the profile document holds only what has no home yet — the services, the\n * audience, the tone of voice — plus a line about the business and the area it\n * serves for a site whose SEO entity does not say. {@link resolveBusinessProfile}\n * reads the two together into one picture, field by field, and says where\n * each value came from.\n *\n * ── Where it is stored ────────────────────────────────────────────────────\n *\n * `hosts/{hostId}/businessProfile/profile` for a site and\n * `orgs/{orgId}/businessProfile/defaults` for the workspace, whose values a\n * site inherits where it has none of its own. A subcollection document rather\n * than a key on the host: the host document's `business` map is replaced\n * whole by the contact card's save, and a key beside it would be one more\n * thing a partial write could blank.\n *\n * ── Whose words win ───────────────────────────────────────────────────────\n *\n * Every stored value carries its source. What the owner typed is never\n * replaced by anything else; what the guided start was told replaces only\n * what a generator guessed; and a generator's guess fills only what is empty.\n * {@link mergeBusinessProfilePrefill} is the one place that rule is applied.\n */\n\n/** The collection a profile document lives in, under a host or an org. */\nexport const BUSINESS_PROFILE_SUBCOLLECTION = 'businessProfile'\n/** The site's profile document id. */\nexport const BUSINESS_PROFILE_SITE_DOC = 'profile'\n/** The workspace defaults document id. */\nexport const BUSINESS_PROFILE_WORKSPACE_DOC = 'defaults'\n\n/** Who wrote a stored value: the owner, the guided start's answers, or a generator. */\nexport type BusinessProfileSource = 'owner' | 'start' | 'ai'\n\n/**\n * Where a RESOLVED value came from: a stored source, the site's own settings\n * (`seo.entity`, `business`, the display name), or the workspace defaults.\n */\nexport type BusinessProfileOrigin = BusinessProfileSource | 'site' | 'workspace'\n\n/** How much a source's words weigh: a higher rank is never replaced by a lower one. */\nconst SOURCE_RANK: Readonly<Record<BusinessProfileSource, number>> = {\n ai: 1,\n start: 2,\n owner: 3,\n}\n\nexport const BUSINESS_TONES = ['friendly', 'professional', 'playful', 'premium', 'plain'] as const\nexport type BusinessTone = (typeof BUSINESS_TONES)[number]\n\n/** The tones as a plain list, in the order the owner picks them, for the native apps' pickers. */\nexport const BUSINESS_TONE_ORDER: readonly string[] = BUSINESS_TONES\n\n/** Each tone as the owner picks it and as a writer is told it. */\nexport const BUSINESS_TONE_LABELS: Readonly<Record<BusinessTone, string>> = {\n friendly: 'Friendly and warm',\n professional: 'Professional and clear',\n playful: 'Playful and upbeat',\n premium: 'Premium and refined',\n plain: 'Plain and direct',\n}\n\n/** The fields the profile document stores itself. */\nexport const BUSINESS_PROFILE_FIELDS = [\n 'whatYouDo',\n 'services',\n 'serviceArea',\n 'audience',\n 'tone',\n 'toneNotes',\n] as const\nexport type BusinessProfileField = (typeof BUSINESS_PROFILE_FIELDS)[number]\n\n/** The stored fields as a plain list, for the native apps' writers. */\nexport const BUSINESS_PROFILE_FIELD_ORDER: readonly string[] = BUSINESS_PROFILE_FIELDS\n\n/** Each field's ceiling, in characters; `services` is per item. */\nexport const BUSINESS_PROFILE_MAX_CHARS: Readonly<Record<Exclude<BusinessProfileField, 'tone'>, number>> = {\n whatYouDo: 200,\n services: 60,\n serviceArea: 120,\n audience: 160,\n toneNotes: 200,\n}\n\n/** At most this many services are kept. */\nexport const BUSINESS_PROFILE_MAX_SERVICES = 12\n\n/** The stored document, at either level. */\nexport interface BusinessProfileDoc {\n whatYouDo?: string\n services?: string[]\n serviceArea?: string\n audience?: string\n tone?: BusinessTone | null\n toneNotes?: string\n /** Who wrote each stored value; a value without one is the owner's. */\n sources?: Partial<Record<BusinessProfileField, BusinessProfileSource>>\n updatedAt?: unknown\n updatedBy?: string | null\n}\n\n/** The values a write carries, before they are sanitized. */\nexport type BusinessProfileValues = Partial<\n Pick<BusinessProfileDoc, 'whatYouDo' | 'services' | 'serviceArea' | 'audience' | 'tone' | 'toneNotes'>\n>\n\n/** The host fields the profile reads. A closed surface, as the host tokens' is. */\nexport interface BusinessProfileHost {\n displayName?: string\n logoUrl?: string\n seo?: { description?: string; entity?: HostSeoEntity | null } | null\n business?: {\n supportEmail?: string\n address?: string\n socialLinks?: Array<{ label?: string; url?: string } | null> | null\n } | null\n}\n\nexport interface ResolvedBusinessField<T> {\n value: T\n origin: BusinessProfileOrigin\n}\n\n/** The picture every reader works from: each field's value and where it came from. */\nexport interface ResolvedBusinessProfile {\n name: ResolvedBusinessField<string> | null\n whatYouDo: ResolvedBusinessField<string> | null\n services: ResolvedBusinessField<string[]> | null\n serviceArea: ResolvedBusinessField<string> | null\n audience: ResolvedBusinessField<string> | null\n tone: ResolvedBusinessField<BusinessTone> | null\n toneNotes: ResolvedBusinessField<string> | null\n /** The schema.org business type the SEO entity names, e.g. `Plumber`. */\n businessType: string | null\n /** Real contact details, each only where the owner entered it in the site's settings. */\n contact: {\n email: string | null\n phone: string | null\n address: string | null\n hours: string | null\n }\n /** The site's social and other profiles, https only. */\n profiles: string[]\n logo: string | null\n}\n\nconst text = (value: unknown, max: number): string =>\n typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim().slice(0, max) : ''\n\nconst tone = (value: unknown): BusinessTone | null =>\n (BUSINESS_TONES as readonly unknown[]).includes(value) ? (value as BusinessTone) : null\n\nconst services = (value: unknown): string[] => {\n const items = Array.isArray(value) ? value : typeof value === 'string' ? value.split(/[,\\n]/) : []\n const seen = new Set<string>()\n const kept: string[] = []\n for (const item of items) {\n const name = text(item, BUSINESS_PROFILE_MAX_CHARS.services)\n const key = name.toLowerCase()\n if (!name || seen.has(key)) continue\n seen.add(key)\n kept.push(name)\n if (kept.length >= BUSINESS_PROFILE_MAX_SERVICES) break\n }\n return kept\n}\n\n/** One field's stored value, sanitized; empty is `''`, `[]` or `null`. */\nfunction fieldValue(doc: BusinessProfileValues | null | undefined, field: BusinessProfileField): unknown {\n switch (field) {\n case 'services':\n return services(doc?.services)\n case 'tone':\n return tone(doc?.tone)\n default:\n return text(doc?.[field], BUSINESS_PROFILE_MAX_CHARS[field])\n }\n}\n\nconst isEmpty = (value: unknown): boolean =>\n value === null || value === '' || (Array.isArray(value) && value.length === 0)\n\n/** The source a stored, non-empty value carries; the owner's when none is recorded. */\nexport function businessProfileSourceOf(\n doc: BusinessProfileDoc | null | undefined,\n field: BusinessProfileField,\n): BusinessProfileSource | null {\n if (isEmpty(fieldValue(doc, field))) return null\n const source = doc?.sources?.[field]\n return source && source in SOURCE_RANK ? source : 'owner'\n}\n\n/** Every value a write may carry, sanitized; an absent field stays absent. */\nexport function sanitizeBusinessProfileValues(values: BusinessProfileValues): BusinessProfileValues {\n const clean: BusinessProfileValues = {}\n for (const field of BUSINESS_PROFILE_FIELDS) {\n if (!(field in values)) continue\n ;(clean as Record<string, unknown>)[field] = fieldValue(values, field)\n }\n return clean\n}\n\n/**\n * The document a generator's or the guided start's values make of the stored\n * one: each value fills a field that is empty or was written by a source that\n * weighs less, and nothing else. `null` when nothing would change, so a caller\n * writes only when there is something to write.\n */\nexport function mergeBusinessProfilePrefill(\n current: BusinessProfileDoc | null | undefined,\n values: BusinessProfileValues,\n source: Exclude<BusinessProfileSource, 'owner'>,\n): BusinessProfileDoc | null {\n const clean = sanitizeBusinessProfileValues(values)\n const next: BusinessProfileDoc = { ...(current ?? {}), sources: { ...(current?.sources ?? {}) } }\n let changed = false\n for (const field of BUSINESS_PROFILE_FIELDS) {\n if (!(field in clean)) continue\n const value = (clean as Record<string, unknown>)[field]\n if (isEmpty(value)) continue\n // An explicit source counts even on an empty value: a field the owner\n // cleared stays cleared rather than being refilled behind them.\n const recorded = current?.sources?.[field]\n const held = recorded && recorded in SOURCE_RANK ? recorded : businessProfileSourceOf(current, field)\n if (held && SOURCE_RANK[held] >= SOURCE_RANK[source]) continue\n if (JSON.stringify(fieldValue(current, field)) === JSON.stringify(value)) continue\n ;(next as Record<string, unknown>)[field] = value\n next.sources![field] = source\n changed = true\n }\n return changed ? next : null\n}\n\n/**\n * The document the owner's save makes: every field they changed becomes\n * theirs, and a field they left as it was keeps the source it had — so saving\n * the form after correcting one line does not claim every suggestion on it.\n */\nexport function businessProfileOwnerWrite(\n current: BusinessProfileDoc | null | undefined,\n edited: BusinessProfileValues,\n): Pick<BusinessProfileDoc, BusinessProfileField | 'sources'> {\n const clean = sanitizeBusinessProfileValues(edited)\n const next: Record<string, unknown> = {}\n const sources: Partial<Record<BusinessProfileField, BusinessProfileSource>> = {}\n for (const field of BUSINESS_PROFILE_FIELDS) {\n const before = fieldValue(current, field)\n const after = field in clean ? (clean as Record<string, unknown>)[field] : before\n next[field] = after\n const same = JSON.stringify(before) === JSON.stringify(after)\n if (isEmpty(after)) {\n // A suggestion the owner deleted is their decision, and recorded as\n // one, so the next prefill does not put it back.\n if (!same) sources[field] = 'owner'\n else if (current?.sources?.[field] === 'owner') sources[field] = 'owner'\n continue\n }\n sources[field] = same ? (businessProfileSourceOf(current, field) ?? 'owner') : 'owner'\n }\n return { ...(next as Pick<BusinessProfileDoc, BusinessProfileField>), sources }\n}\n\n/** The postal address as one line: the SEO entity's parts, else the contact card's block. */\nfunction addressLine(host: BusinessProfileHost | null | undefined): string {\n const parts = host?.seo?.entity?.address\n const line = [\n parts?.streetAddress,\n parts?.addressLocality,\n parts?.addressRegion,\n parts?.postalCode,\n parts?.addressCountry,\n ]\n .map((part) => text(part, 200))\n .filter(Boolean)\n .join(', ')\n return line || text(host?.business?.address, 400)\n}\n\n/**\n * The profile as every reader sees it, field by field (AGL-3661):\n *\n * 1. what the OWNER typed into the site's profile;\n * 2. what the site's own settings say (the SEO entity, the contact card, the\n * display name), which the owner typed too, elsewhere;\n * 3. what the guided start or a generator stored on the site's profile;\n * 4. the workspace defaults.\n *\n * Contact details, the logo and the profiles come from the site's settings\n * only: nothing but the owner's own entry may say how to reach the business.\n */\nexport function resolveBusinessProfile(input: {\n host: BusinessProfileHost | null | undefined\n site?: BusinessProfileDoc | null\n workspace?: BusinessProfileDoc | null\n}): ResolvedBusinessProfile {\n const { host, site, workspace } = input\n const entity = host?.seo?.entity ?? null\n const fromSite: Partial<Record<BusinessProfileField, unknown>> = {\n whatYouDo: text(entity?.description, BUSINESS_PROFILE_MAX_CHARS.whatYouDo),\n serviceArea: normalizeAreaServed(entity?.areaServed).join(', ').slice(0, BUSINESS_PROFILE_MAX_CHARS.serviceArea),\n }\n\n const resolve = <T>(field: BusinessProfileField): ResolvedBusinessField<T> | null => {\n const stored = businessProfileSourceOf(site, field)\n if (stored === 'owner') return { value: fieldValue(site, field) as T, origin: 'owner' }\n const own = fromSite[field]\n if (own !== undefined && !isEmpty(own)) return { value: own as T, origin: 'site' }\n if (stored) return { value: fieldValue(site, field) as T, origin: stored }\n if (businessProfileSourceOf(workspace, field)) {\n return { value: fieldValue(workspace, field) as T, origin: 'workspace' }\n }\n return null\n }\n\n const name = text(entity?.name, 200) || text(host?.displayName, 200)\n return {\n name: name ? { value: name, origin: 'site' } : null,\n whatYouDo: resolve<string>('whatYouDo'),\n services: resolve<string[]>('services'),\n serviceArea: resolve<string>('serviceArea'),\n audience: resolve<string>('audience'),\n tone: resolve<BusinessTone>('tone'),\n toneNotes: resolve<string>('toneNotes'),\n businessType: text(entity?.businessType, 80) || null,\n contact: {\n email: text(entity?.email, 320) || text(host?.business?.supportEmail, 320) || null,\n phone: text(entity?.telephone, 64) || null,\n address: addressLine(host) || null,\n hours: text(entity?.openingHours, 400) || null,\n },\n profiles: siteProfileUrls(host as Parameters<typeof siteProfileUrls>[0]),\n logo: text(host?.logoUrl, 800) || text(entity?.logo, 800) || null,\n }\n}\n\n/** Each origin as the profile screen labels it. */\nexport const BUSINESS_PROFILE_ORIGIN_LABELS: Readonly<Record<BusinessProfileOrigin, string>> = {\n owner: 'You',\n site: 'Site settings',\n start: 'Your answers when the site was started',\n ai: `Suggested by ${PLATFORM_BRAND_NAME} AI`,\n workspace: 'Workspace default',\n}\n"],"names":["siteProfileUrls","normalizeAreaServed","PLATFORM_BRAND_NAME","BUSINESS_PROFILE_SUBCOLLECTION","BUSINESS_PROFILE_SITE_DOC","BUSINESS_PROFILE_WORKSPACE_DOC","SOURCE_RANK","ai","start","owner","BUSINESS_TONES","BUSINESS_TONE_ORDER","BUSINESS_TONE_LABELS","friendly","professional","playful","premium","plain","BUSINESS_PROFILE_FIELDS","BUSINESS_PROFILE_FIELD_ORDER","BUSINESS_PROFILE_MAX_CHARS","whatYouDo","services","serviceArea","audience","toneNotes","BUSINESS_PROFILE_MAX_SERVICES","text","value","max","replace","trim","slice","tone","includes","items","Array","isArray","split","seen","Set","kept","item","name","key","toLowerCase","has","add","push","length","fieldValue","doc","field","isEmpty","businessProfileSourceOf","source","sources","sanitizeBusinessProfileValues","values","clean","mergeBusinessProfilePrefill","current","next","changed","recorded","held","JSON","stringify","businessProfileOwnerWrite","edited","before","after","same","addressLine","host","parts","seo","entity","address","line","streetAddress","addressLocality","addressRegion","postalCode","addressCountry","map","part","filter","Boolean","join","business","resolveBusinessProfile","input","site","workspace","fromSite","description","areaServed","resolve","stored","origin","own","undefined","displayName","businessType","contact","email","supportEmail","phone","telephone","hours","openingHours","profiles","logo","logoUrl","BUSINESS_PROFILE_ORIGIN_LABELS"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAA4B,uBAAmB;AACvE,SAASC,mBAAmB,QAAQ,sBAAkB;AACtD,SAASC,mBAAmB,QAAQ,sBAAkB;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCC,GAED,wEAAwE,GACxE,OAAO,MAAMC,iCAAiC,kBAAiB;AAC/D,oCAAoC,GACpC,OAAO,MAAMC,4BAA4B,UAAS;AAClD,wCAAwC,GACxC,OAAO,MAAMC,iCAAiC,WAAU;AAWxD,qFAAqF,GACrF,MAAMC,cAA+D;IACnEC,IAAI;IACJC,OAAO;IACPC,OAAO;AACT;AAEA,OAAO,MAAMC,iBAAiB;IAAC;IAAY;IAAgB;IAAW;IAAW;CAAQ,CAAS;AAGlG,gGAAgG,GAChG,OAAO,MAAMC,sBAAyCD,eAAc;AAEpE,gEAAgE,GAChE,OAAO,MAAME,uBAA+D;IAC1EC,UAAU;IACVC,cAAc;IACdC,SAAS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ExB,OAAOsB,WAAW4C,WAAW1C;gBAAagD,QAAQ;YAAY;QACzE;QACA,OAAO;IACT;IAEA,MAAMzD,OAAOhB,KAAKkD,0BAAAA,OAAQlC,IAAI,EAAE,QAAQhB,KAAK+C,wBAAAA,KAAM6B,WAAW,EAAE;IAChE,OAAO;QACL5D,MAAMA,OAAO;YAAEf,OAAOe;YAAMyD,QAAQ;QAAO,IAAI;QAC/C/E,WAAW6E,QAAgB;QAC3B5E,UAAU4E,QAAkB;QAC5B3E,aAAa2E,QAAgB;QAC7B1E,UAAU0E,QAAgB;QAC1BjE,MAAMiE,QAAsB;QAC5BzE,WAAWyE,QAAgB;QAC3BM,cAAc7E,KAAKkD,0BAAAA,OAAQ2B,YAAY,EAAE,OAAO;QAChDC,SAAS;YACPC,OAAO/E,KAAKkD,0BAAAA,OAAQ6B,KAAK,EAAE,QAAQ/E,KAAK+C,yBAAAA,iBAAAA,KAAMgB,QAAQ,qBAAdhB,eAAgBiC,YAAY,EAAE,QAAQ;YAC9EC,OAAOjF,KAAKkD,0BAAAA,OAAQgC,SAAS,EAAE,OAAO;YACtC/B,SAASL,YAAYC,SAAS;YAC9BoC,OAAOnF,KAAKkD,0BAAAA,OAAQkC,YAAY,EAAE,QAAQ;QAC5C;QACAC,UAAUhH,gBAAgB0E;QAC1BuC,MAAMtF,KAAK+C,wBAAAA,KAAMwC,OAAO,EAAE,QAAQvF,KAAKkD,0BAAAA,OAAQoC,IAAI,EAAE,QAAQ;IAC/D;AACF;AAEA,iDAAiD,GACjD,OAAO,MAAME,iCAAkF;IAC7F1G,OAAO;IACPoF,MAAM;IACNrF,OAAO;IACPD,IAAI,CAAC,aAAa,EAAEL,oBAAoB,GAAG,CAAC;IAC5C4F,WAAW;AACb,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/business-profile.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\nimport { siteProfileUrls, type HostSeoEntity } from './content-authors'\nimport { normalizeAreaServed } from './local-business'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\nimport {\n BUSINESS_PROFILE_FIELDS,\n BUSINESS_PROFILE_MAX_CHARS,\n BUSINESS_TONES,\n businessProfileSourceOf,\n fieldValue,\n isEmpty,\n text,\n type BusinessProfileDoc,\n type BusinessProfileField,\n type BusinessProfileOrigin,\n type BusinessProfileSource,\n type BusinessProfileValues,\n type BusinessTone,\n} from './business-profile-values'\n\nexport {\n BUSINESS_PROFILE_FIELDS,\n BUSINESS_PROFILE_MAX_CHARS,\n BUSINESS_PROFILE_MAX_SERVICES,\n BUSINESS_PROFILE_SITE_DOC,\n BUSINESS_PROFILE_SUBCOLLECTION,\n BUSINESS_PROFILE_WORKSPACE_DOC,\n BUSINESS_TONE_LABELS,\n BUSINESS_TONES,\n businessProfileOwnerWrite,\n businessProfileSourceOf,\n mergeBusinessProfilePrefill,\n sanitizeBusinessProfileValues,\n} from './business-profile-values'\nexport type {\n BusinessProfileDoc,\n BusinessProfileField,\n BusinessProfileOrigin,\n BusinessProfileSource,\n BusinessProfileValues,\n BusinessTone,\n} from './business-profile-values'\n\n/** The tones as a plain list, in the order the owner picks them, for the native apps' pickers. */\nexport const BUSINESS_TONE_ORDER: readonly string[] = BUSINESS_TONES\n\n/** The stored fields as a plain list, for the native apps' writers. */\nexport const BUSINESS_PROFILE_FIELD_ORDER: readonly string[] = BUSINESS_PROFILE_FIELDS\n\n/**\n * A site's BUSINESS PROFILE (AGL-3661): what the business is, as everything\n * that writes about it needs to know — the site's own pages, the structured\n * data, and any generator a plugin brings.\n *\n * ── Most of it is already stored, so this stores only the rest ─────────────\n *\n * The site's name, its one-line description, its contact details, its hours,\n * the areas it serves and its social profiles all have a home on the host\n * document already: `seo.entity` (the publisher entity the JSON-LD is built\n * from, edited in Setup → SEO) and `business` (the contact card the `host.*`\n * tokens and the footer read, edited in Setup → Basic details). Copying them\n * here would make two places to keep in step, and the copy would drift.\n *\n * So the profile document holds only what has no home yet — the services, the\n * audience, the tone of voice — plus a line about the business and the area it\n * serves for a site whose SEO entity does not say. {@link resolveBusinessProfile}\n * reads the two together into one picture, field by field, and says where\n * each value came from.\n *\n * ── Where it is stored ────────────────────────────────────────────────────\n *\n * `hosts/{hostId}/businessProfile/profile` for a site and\n * `orgs/{orgId}/businessProfile/defaults` for the workspace, whose values a\n * site inherits where it has none of its own. A subcollection document rather\n * than a key on the host: the host document's `business` map is replaced\n * whole by the contact card's save, and a key beside it would be one more\n * thing a partial write could blank.\n *\n * ── Whose words win ───────────────────────────────────────────────────────\n *\n * Every stored value carries its source. What the owner typed is never\n * replaced by anything else; what the guided start was told replaces only\n * what a generator guessed; and a generator's guess fills only what is empty.\n * {@link mergeBusinessProfilePrefill} is the one place that rule is applied.\n */\n\n\n/** The host fields the profile reads. A closed surface, as the host tokens' is. */\nexport interface BusinessProfileHost {\n displayName?: string\n logoUrl?: string\n seo?: { description?: string; entity?: HostSeoEntity | null } | null\n business?: {\n supportEmail?: string\n address?: string\n socialLinks?: Array<{ label?: string; url?: string } | null> | null\n } | null\n}\n\nexport interface ResolvedBusinessField<T> {\n value: T\n origin: BusinessProfileOrigin\n}\n\n/** The picture every reader works from: each field's value and where it came from. */\nexport interface ResolvedBusinessProfile {\n name: ResolvedBusinessField<string> | null\n whatYouDo: ResolvedBusinessField<string> | null\n services: ResolvedBusinessField<string[]> | null\n serviceArea: ResolvedBusinessField<string> | null\n audience: ResolvedBusinessField<string> | null\n tone: ResolvedBusinessField<BusinessTone> | null\n toneNotes: ResolvedBusinessField<string> | null\n /** The schema.org business type the SEO entity names, e.g. `Plumber`. */\n businessType: string | null\n /** Real contact details, each only where the owner entered it in the site's settings. */\n contact: {\n email: string | null\n phone: string | null\n address: string | null\n hours: string | null\n }\n /** The site's social and other profiles, https only. */\n profiles: string[]\n logo: string | null\n}\n\n\n/** The postal address as one line: the SEO entity's parts, else the contact card's block. */\nfunction addressLine(host: BusinessProfileHost | null | undefined): string {\n const parts = host?.seo?.entity?.address\n const line = [\n parts?.streetAddress,\n parts?.addressLocality,\n parts?.addressRegion,\n parts?.postalCode,\n parts?.addressCountry,\n ]\n .map((part) => text(part, 200))\n .filter(Boolean)\n .join(', ')\n return line || text(host?.business?.address, 400)\n}\n\n/**\n * The profile as every reader sees it, field by field (AGL-3661):\n *\n * 1. what the OWNER typed into the site's profile;\n * 2. what the site's own settings say (the SEO entity, the contact card, the\n * display name), which the owner typed too, elsewhere;\n * 3. what the guided start or a generator stored on the site's profile;\n * 4. the workspace defaults.\n *\n * Contact details, the logo and the profiles come from the site's settings\n * only: nothing but the owner's own entry may say how to reach the business.\n */\nexport function resolveBusinessProfile(input: {\n host: BusinessProfileHost | null | undefined\n site?: BusinessProfileDoc | null\n workspace?: BusinessProfileDoc | null\n}): ResolvedBusinessProfile {\n const { host, site, workspace } = input\n const entity = host?.seo?.entity ?? null\n const fromSite: Partial<Record<BusinessProfileField, unknown>> = {\n whatYouDo: text(entity?.description, BUSINESS_PROFILE_MAX_CHARS.whatYouDo),\n serviceArea: normalizeAreaServed(entity?.areaServed).join(', ').slice(0, BUSINESS_PROFILE_MAX_CHARS.serviceArea),\n }\n\n const resolve = <T>(field: BusinessProfileField): ResolvedBusinessField<T> | null => {\n const stored = businessProfileSourceOf(site, field)\n if (stored === 'owner') return { value: fieldValue(site, field) as T, origin: 'owner' }\n const own = fromSite[field]\n if (own !== undefined && !isEmpty(own)) return { value: own as T, origin: 'site' }\n if (stored) return { value: fieldValue(site, field) as T, origin: stored }\n if (businessProfileSourceOf(workspace, field)) {\n return { value: fieldValue(workspace, field) as T, origin: 'workspace' }\n }\n return null\n }\n\n const name = text(entity?.name, 200) || text(host?.displayName, 200)\n return {\n name: name ? { value: name, origin: 'site' } : null,\n whatYouDo: resolve<string>('whatYouDo'),\n services: resolve<string[]>('services'),\n serviceArea: resolve<string>('serviceArea'),\n audience: resolve<string>('audience'),\n tone: resolve<BusinessTone>('tone'),\n toneNotes: resolve<string>('toneNotes'),\n businessType: text(entity?.businessType, 80) || null,\n contact: {\n email: text(entity?.email, 320) || text(host?.business?.supportEmail, 320) || null,\n phone: text(entity?.telephone, 64) || null,\n address: addressLine(host) || null,\n hours: text(entity?.openingHours, 400) || null,\n },\n profiles: siteProfileUrls(host as Parameters<typeof siteProfileUrls>[0]),\n logo: text(host?.logoUrl, 800) || text(entity?.logo, 800) || null,\n }\n}\n\n/** Each origin as the profile screen labels it. */\nexport const BUSINESS_PROFILE_ORIGIN_LABELS: Readonly<Record<BusinessProfileOrigin, string>> = {\n owner: 'You',\n site: 'Site settings',\n start: 'Your answers when the site was started',\n ai: `Suggested by ${PLATFORM_BRAND_NAME} AI`,\n workspace: 'Workspace default',\n}\n"],"names":["siteProfileUrls","normalizeAreaServed","PLATFORM_BRAND_NAME","BUSINESS_PROFILE_FIELDS","BUSINESS_PROFILE_MAX_CHARS","BUSINESS_TONES","businessProfileSourceOf","fieldValue","isEmpty","text","BUSINESS_PROFILE_MAX_SERVICES","BUSINESS_PROFILE_SITE_DOC","BUSINESS_PROFILE_SUBCOLLECTION","BUSINESS_PROFILE_WORKSPACE_DOC","BUSINESS_TONE_LABELS","businessProfileOwnerWrite","mergeBusinessProfilePrefill","sanitizeBusinessProfileValues","BUSINESS_TONE_ORDER","BUSINESS_PROFILE_FIELD_ORDER","addressLine","host","parts","seo","entity","address","line","streetAddress","addressLocality","addressRegion","postalCode","addressCountry","map","part","filter","Boolean","join","business","resolveBusinessProfile","input","site","workspace","fromSite","whatYouDo","description","serviceArea","areaServed","slice","resolve","field","stored","value","origin","own","undefined","name","displayName","services","audience","tone","toneNotes","businessType","contact","email","supportEmail","phone","telephone","hours","openingHours","profiles","logo","logoUrl","BUSINESS_PROFILE_ORIGIN_LABELS","owner","start","ai"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAA4B,uBAAmB;AACvE,SAASC,mBAAmB,QAAQ,sBAAkB;AACtD,SAASC,mBAAmB,QAAQ,sBAAkB;AACtD,SACEC,uBAAuB,EACvBC,0BAA0B,EAC1BC,cAAc,EACdC,uBAAuB,EACvBC,UAAU,EACVC,OAAO,EACPC,IAAI,QAOC,+BAA2B;AAElC,SACEN,uBAAuB,EACvBC,0BAA0B,EAC1BM,6BAA6B,EAC7BC,yBAAyB,EACzBC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,oBAAoB,EACpBT,cAAc,EACdU,yBAAyB,EACzBT,uBAAuB,EACvBU,2BAA2B,EAC3BC,6BAA6B,QACxB,+BAA2B;AAUlC,gGAAgG,GAChG,OAAO,MAAMC,sBAAyCb,eAAc;AAEpE,qEAAqE,GACrE,OAAO,MAAMc,+BAAkDhB,wBAAuB;AAiFtF,2FAA2F,GAC3F,SAASiB,YAAYC,IAA4C;QACjDA,kBAAAA,WAWMA;IAXpB,MAAMC,QAAQD,yBAAAA,YAAAA,KAAME,GAAG,sBAATF,mBAAAA,UAAWG,MAAM,qBAAjBH,iBAAmBI,OAAO;IACxC,MAAMC,OAAO;QACXJ,yBAAAA,MAAOK,aAAa;QACpBL,yBAAAA,MAAOM,eAAe;QACtBN,yBAAAA,MAAOO,aAAa;QACpBP,yBAAAA,MAAOQ,UAAU;QACjBR,yBAAAA,MAAOS,cAAc;KACtB,CACEC,GAAG,CAAC,CAACC,OAASxB,KAAKwB,MAAM,MACzBC,MAAM,CAACC,SACPC,IAAI,CAAC;IACR,OAAOV,QAAQjB,KAAKY,yBAAAA,iBAAAA,KAAMgB,QAAQ,qBAAdhB,eAAgBI,OAAO,EAAE;AAC/C;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,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0BAAAA,OAAQqC,YAAY,EAAE,OAAO;QAChDC,SAAS;YACPC,OAAOtD,KAAKe,0BAAAA,OAAQuC,KAAK,EAAE,QAAQtD,KAAKY,yBAAAA,iBAAAA,KAAMgB,QAAQ,qBAAdhB,eAAgB2C,YAAY,EAAE,QAAQ;YAC9EC,OAAOxD,KAAKe,0BAAAA,OAAQ0C,SAAS,EAAE,OAAO;YACtCzC,SAASL,YAAYC,SAAS;YAC9B8C,OAAO1D,KAAKe,0BAAAA,OAAQ4C,YAAY,EAAE,QAAQ;QAC5C;QACAC,UAAUrE,gBAAgBqB;QAC1BiD,MAAM7D,KAAKY,wBAAAA,KAAMkD,OAAO,EAAE,QAAQ9D,KAAKe,0BAAAA,OAAQ8C,IAAI,EAAE,QAAQ;IAC/D;AACF;AAEA,iDAAiD,GACjD,OAAO,MAAME,iCAAkF;IAC7FC,OAAO;IACPjC,MAAM;IACNkC,OAAO;IACPC,IAAI,CAAC,aAAa,EAAEzE,oBAAoB,GAAG,CAAC;IAC5CuC,WAAW;AACb,EAAC"}
|
|
@@ -199,10 +199,6 @@
|
|
|
199
199
|
'#1-open-the-workflows-page': 'In the console, go to Automation → Workflows and choose New workflow.',
|
|
200
200
|
'#4-save-and-test': 'Save the workflow. When the trigger fires, the workflow runs and each run counts once toward your tier\'s metered allowance — however many steps it has, and whatever they are.'
|
|
201
201
|
},
|
|
202
|
-
carrierAccounts: {
|
|
203
|
-
'#carrier-accounts': 'The Carrier accounts card lists the carriers your labels and checkout rates come from, for every site in the workspace.',
|
|
204
|
-
'#shipping-labels': 'A label bought on Aglyn\'s carrier accounts is charged to the workspace at the carrier\'s price, with nothing added.'
|
|
205
|
-
},
|
|
206
202
|
catalog: {
|
|
207
203
|
'#categories-and-tags': 'The Categories & collections card, in the products hub\'s catalog, organizes your products into categories and collections that storefront pages and filters use.',
|
|
208
204
|
'#review-moderation': 'The Review moderation card, in the products hub\'s Promotions section, lists your reviews so you can publish, hide and reply to them.',
|
|
@@ -475,6 +471,9 @@
|
|
|
475
471
|
'#pause-it-on-one-site': 'Each site\'s Automation → Actions section shows Org automations on this site: the ones placed on it, whether each runs here, and Pause here / Resume here.',
|
|
476
472
|
'#what-an-org-automation-is': 'An org automation has a trigger, optional conditions and an ordered list of steps, exactly like an action — and a placement: the sites it runs on.'
|
|
477
473
|
},
|
|
474
|
+
ownShippingAccounts: {
|
|
475
|
+
'#connect-an-account': 'Open your site\'s Products hub and choose Shipping & delivery.'
|
|
476
|
+
},
|
|
478
477
|
pickupAndDelivery: {
|
|
479
478
|
'#set-up-local-delivery': 'The Local delivery card, on Products → Shipping & delivery, lets your own driver deliver orders: buyers enter their postal code at the cart, pay your fee and book a delivery time.'
|
|
480
479
|
},
|
|
@@ -569,12 +568,16 @@
|
|
|
569
568
|
'#sequences': 'A sequence is the emails, and the tasks between them, one person gets from one rep.'
|
|
570
569
|
},
|
|
571
570
|
shipping: {
|
|
572
|
-
'#where-parcels-ship-from': 'Each inventory location (the Inventory locations card in the store\'s settings) can carry a postal address: choose Add address on its row, or Edit address once it has one.',
|
|
573
571
|
'#zones-and-rates': 'The Shipping card, on Products → Shipping & delivery, prices every parcel: group the countries you ship to into zones, then give each zone one or more rates.'
|
|
574
572
|
},
|
|
575
573
|
shippingEasy: {
|
|
576
574
|
'#connect': 'The ShippingEasy card, on Products → Shipping & delivery, sends each paid order to your ShippingEasy account and takes each label back, using the API keys from Before you start.'
|
|
577
575
|
},
|
|
576
|
+
shippingLabels: {
|
|
577
|
+
'#carrier-accounts': 'The Carrier accounts card, on Products → Shipping & delivery, lists the carriers your labels and checkout rates come from, for every site in the workspace.',
|
|
578
|
+
'#label-spend': 'Once your workspace has bought a label, Billing → Usage shows a Shipping labels card for this month and the five before it: Labels, From Stripe balance, On invoice, and Voided, returned.',
|
|
579
|
+
'#shipping-labels-settings': 'Open your site\'s Products hub and choose Shipping & delivery.'
|
|
580
|
+
},
|
|
578
581
|
shipStation: {
|
|
579
582
|
'#connect': 'The ShipStation card, on Products → Shipping & delivery, connects your store to ShipStation as a Custom Store, so ShipStation imports your paid orders and sends each shipment back.'
|
|
580
583
|
},
|