@aglyn/plugins-ai 1.29.0 → 1.29.2
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 +17 -17
- package/src/lib/components/ai-job-requests.d.ts +6 -0
- package/src/lib/components/ai-job-requests.js +32 -0
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +144 -12
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +3 -0
- package/src/lib/jobs/ai-job-import-step.js +26 -2
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-redirects.d.ts +50 -0
- package/src/lib/jobs/ai-site-import-redirects.js +206 -0
- package/src/lib/jobs/ai-site-import-redirects.js.map +1 -0
- package/src/lib/model/ai-site-import-redirects.d.ts +73 -0
- package/src/lib/model/ai-site-import-redirects.js +203 -0
- package/src/lib/model/ai-site-import-redirects.js.map +1 -0
- package/src/lib/model/ai-site-import-view.d.ts +2 -0
- package/src/lib/model/ai-site-import-view.js +3 -0
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +47 -0
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/server/ai-jobs-redirects.d.ts +32 -0
- package/src/lib/server/ai-jobs-redirects.js +128 -0
- package/src/lib/server/ai-jobs-redirects.js.map +1 -0
- package/src/lib/server.js +10 -0
- package/src/lib/server.js.map +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
import type { AiJob, AiJobItemLedger } from '../model/ai-jobs.types';
|
|
18
|
+
import type { AiSiteImportRedirect, AiSiteImportState } from '../model/ai-site-import';
|
|
19
|
+
import { type AiPluginDraftOwnerLookup, type AiPluginDraftWriterLookup } from './ai-job-plugin-drafts';
|
|
20
|
+
/** The resource the redirects plugin registers its writer under: the same name its rules' addresses are published by. */
|
|
21
|
+
export declare const AI_SITE_IMPORT_REDIRECT_RESOURCE = "redirect";
|
|
22
|
+
/** The status code an import's redirects carry: the move is permanent. */
|
|
23
|
+
export declare const AI_SITE_IMPORT_REDIRECT_STATUS = 301;
|
|
24
|
+
/** The rule id an old address's redirect is written under. */
|
|
25
|
+
export declare function aiSiteImportRedirectId(jobId: string, from: string): string;
|
|
26
|
+
export interface AiSiteImportRedirectsDeps {
|
|
27
|
+
writerFor?: AiPluginDraftWriterLookup;
|
|
28
|
+
ownerFor?: AiPluginDraftOwnerLookup;
|
|
29
|
+
/** Whether the owning plugin runs on the site; the release flags and the site's plugin list otherwise. */
|
|
30
|
+
pluginOn?: (input: {
|
|
31
|
+
orgId: string;
|
|
32
|
+
pluginId: string;
|
|
33
|
+
org: Readonly<Record<string, unknown>> | null;
|
|
34
|
+
host: Readonly<Record<string, unknown>>;
|
|
35
|
+
}) => Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The import's redirects after a wave closed: every old address considered,
|
|
39
|
+
* each `created`, `kept`, `same` or `left-out` with why. `null` when the job
|
|
40
|
+
* names no site. Never throws for a refusal; a write that throws is left out.
|
|
41
|
+
*/
|
|
42
|
+
export declare function aiSiteImportWriteRedirects(firestore: FirebaseFirestore.Firestore, input: {
|
|
43
|
+
job: Pick<AiJob, '$id' | 'orgId' | 'hostId' | 'createdBy'>;
|
|
44
|
+
state: AiSiteImportState;
|
|
45
|
+
items: readonly AiJobItemLedger[];
|
|
46
|
+
org: Readonly<Record<string, unknown>> | null;
|
|
47
|
+
now: Date;
|
|
48
|
+
/** The member the rules are written as; the member who started the import otherwise. */
|
|
49
|
+
actorUid?: string;
|
|
50
|
+
}, deps?: AiSiteImportRedirectsDeps): Promise<AiSiteImportRedirect[] | null>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { createHash } from "node:crypto";
|
|
18
|
+
import { isHostPluginEnabled } from "@aglyn/aglyn/plugin-manager/enabled-plugins";
|
|
19
|
+
import { filterEnabledPluginsByReleaseFlags } from "@aglyn/tenant-data-admin/server/release-flags";
|
|
20
|
+
import { AI_SITE_IMPORT_REDIRECT_RECORD, aiSiteImportRedirectPlan } from "../model/ai-site-import-redirects.js";
|
|
21
|
+
import { aiPluginDraftOwner, aiPluginDraftWriter } from "./ai-job-plugin-drafts.js";
|
|
22
|
+
/*==========================================
|
|
23
|
+
* A CLOSED WAVE'S OLD ADDRESSES, REDIRECTED (AGL-4245).
|
|
24
|
+
*
|
|
25
|
+
* After a wave's pages go live, each old address the plan
|
|
26
|
+
* (`aiSiteImportRedirectPlan`) asks for is written as a permanent redirect by
|
|
27
|
+
* the redirects plugin's writer, on the core's resource-drafts seam under the
|
|
28
|
+
* resource `redirect`. This plugin never imports the redirects plugin and
|
|
29
|
+
* never writes a rule itself: the writer applies the Redirects page's rules
|
|
30
|
+
* to the member who started the import.
|
|
31
|
+
*
|
|
32
|
+
* The caller's half of the seam's contract, as an AI build's drafts make it:
|
|
33
|
+
* the owning plugin must run on the site (switched on for the workspace, not
|
|
34
|
+
* off for the site, past its release flag), and the writer's `refusal` is
|
|
35
|
+
* asked once before any write. Either refusing leaves every address out with
|
|
36
|
+
* why; nothing here throws for it.
|
|
37
|
+
*
|
|
38
|
+
* Each rule is written under `<job id>-<hash of its old address>`, so a wave
|
|
39
|
+
* closing twice, a re-read of the site or a later wave finds the rule it
|
|
40
|
+
* already made instead of a second one, and the job's own id names every rule
|
|
41
|
+
* it made. A rule the site already has at that address (the owner's) is kept
|
|
42
|
+
* and reported, never overwritten. The writer follows an existing chain from
|
|
43
|
+
* the new page's address to where it ends, and refuses a loop.
|
|
44
|
+
*=========================================*/ /** The resource the redirects plugin registers its writer under: the same name its rules' addresses are published by. */ export const AI_SITE_IMPORT_REDIRECT_RESOURCE = AI_SITE_IMPORT_REDIRECT_RECORD;
|
|
45
|
+
/** The status code an import's redirects carry: the move is permanent. */ export const AI_SITE_IMPORT_REDIRECT_STATUS = 301;
|
|
46
|
+
/** The writer's refusal codes this import reads (the redirects plugin's `REDIRECT_AI_REFUSAL_CODES`). */ const CODE_DUPLICATE = 'duplicate';
|
|
47
|
+
const CODE_LIVE_PAGE = 'live-page';
|
|
48
|
+
const CODE_PLAN_LIMIT = 'plan-limit';
|
|
49
|
+
/** The rule id an old address's redirect is written under. */ export function aiSiteImportRedirectId(jobId, from) {
|
|
50
|
+
return `${jobId}-${createHash('sha256').update(from).digest('hex').slice(0, 16)}`;
|
|
51
|
+
}
|
|
52
|
+
async function readPluginOn(input) {
|
|
53
|
+
const released = await filterEnabledPluginsByReleaseFlags([
|
|
54
|
+
input.pluginId
|
|
55
|
+
], {
|
|
56
|
+
orgId: input.orgId,
|
|
57
|
+
authorization: null
|
|
58
|
+
});
|
|
59
|
+
return released.includes(input.pluginId) && isHostPluginEnabled(input.org, input.host, input.pluginId);
|
|
60
|
+
}
|
|
61
|
+
/** What the redirects plugin's `check` says an old address is stored as, or `null`. */ function storedSourceWith(writer, hostId) {
|
|
62
|
+
return (path)=>{
|
|
63
|
+
const checked = writer.check({
|
|
64
|
+
action: 'create',
|
|
65
|
+
source: path,
|
|
66
|
+
destination: '/'
|
|
67
|
+
}, {
|
|
68
|
+
hostId
|
|
69
|
+
});
|
|
70
|
+
if (!checked.ok) return null;
|
|
71
|
+
const stored = checked.facts['storedSource'];
|
|
72
|
+
return typeof stored === 'string' && stored ? stored : null;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Lowercase, no trailing slash, no query: a fallback reading of an old address when no writer can say. */ function plainPath(path) {
|
|
76
|
+
var _ref;
|
|
77
|
+
var _String_split_;
|
|
78
|
+
const value = (_ref = (_String_split_ = String(path != null ? path : '').split(/[?#]/)[0]) == null ? void 0 : _String_split_.trim().toLowerCase()) != null ? _ref : '';
|
|
79
|
+
if (!value.startsWith('/')) return null;
|
|
80
|
+
return value.length > 1 ? value.replace(/\/+$/, '') || '/' : '/';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The import's redirects after a wave closed: every old address considered,
|
|
84
|
+
* each `created`, `kept`, `same` or `left-out` with why. `null` when the job
|
|
85
|
+
* names no site. Never throws for a refusal; a write that throws is left out.
|
|
86
|
+
*/ export async function aiSiteImportWriteRedirects(firestore, input, deps = {}) {
|
|
87
|
+
var _ref, _deps_writerFor, _deps_ownerFor, _host_screens, _deps_pluginOn, _input_actorUid;
|
|
88
|
+
const { job, state } = input;
|
|
89
|
+
const hostId = job.hostId;
|
|
90
|
+
if (!hostId) return null;
|
|
91
|
+
const hostSnapshot = await firestore.collection('hosts').doc(hostId).get();
|
|
92
|
+
const host = (_ref = hostSnapshot.exists ? hostSnapshot.data() : null) != null ? _ref : {};
|
|
93
|
+
const writer = ((_deps_writerFor = deps.writerFor) != null ? _deps_writerFor : aiPluginDraftWriter)(AI_SITE_IMPORT_REDIRECT_RESOURCE);
|
|
94
|
+
const owner = ((_deps_ownerFor = deps.ownerFor) != null ? _deps_ownerFor : aiPluginDraftOwner)(AI_SITE_IMPORT_REDIRECT_RESOURCE);
|
|
95
|
+
const plan = aiSiteImportRedirectPlan({
|
|
96
|
+
state,
|
|
97
|
+
items: input.items,
|
|
98
|
+
screens: (_host_screens = host.screens) != null ? _host_screens : null,
|
|
99
|
+
storedSource: writer ? storedSourceWith(writer, hostId) : plainPath
|
|
100
|
+
});
|
|
101
|
+
const entries = [
|
|
102
|
+
...plan.entries
|
|
103
|
+
];
|
|
104
|
+
if (!plan.asks.length) return entries;
|
|
105
|
+
const leaveAll = (reason, note)=>{
|
|
106
|
+
for (const ask of plan.asks)entries[ask.at] = {
|
|
107
|
+
from: ask.from,
|
|
108
|
+
to: ask.to,
|
|
109
|
+
outcome: 'left-out',
|
|
110
|
+
reason,
|
|
111
|
+
note,
|
|
112
|
+
slot: ask.slot
|
|
113
|
+
};
|
|
114
|
+
return entries;
|
|
115
|
+
};
|
|
116
|
+
const pluginOn = (_deps_pluginOn = deps.pluginOn) != null ? _deps_pluginOn : readPluginOn;
|
|
117
|
+
if (!writer || !owner || !await pluginOn({
|
|
118
|
+
orgId: job.orgId,
|
|
119
|
+
pluginId: owner,
|
|
120
|
+
org: input.org,
|
|
121
|
+
host
|
|
122
|
+
})) {
|
|
123
|
+
return leaveAll('off', 'Redirects is turned off for this site, so no redirects were added. Turn it on to add them.');
|
|
124
|
+
}
|
|
125
|
+
const context = {
|
|
126
|
+
orgId: job.orgId,
|
|
127
|
+
hostId,
|
|
128
|
+
uid: (_input_actorUid = input.actorUid) != null ? _input_actorUid : job.createdBy,
|
|
129
|
+
org: input.org,
|
|
130
|
+
now: input.now
|
|
131
|
+
};
|
|
132
|
+
const refusal = await writer.refusal(context);
|
|
133
|
+
if (refusal) return leaveAll('off', refusal.error);
|
|
134
|
+
let full = null;
|
|
135
|
+
for (const ask of plan.asks){
|
|
136
|
+
const leave = (reason, note = null)=>{
|
|
137
|
+
entries[ask.at] = {
|
|
138
|
+
from: ask.from,
|
|
139
|
+
to: ask.to,
|
|
140
|
+
outcome: 'left-out',
|
|
141
|
+
reason,
|
|
142
|
+
note,
|
|
143
|
+
slot: ask.slot
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
// Once the plan has no room, the rest wait for room too.
|
|
147
|
+
if (full) {
|
|
148
|
+
leave('plan-limit', full);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const ruleId = aiSiteImportRedirectId(job.$id, ask.from);
|
|
152
|
+
try {
|
|
153
|
+
const written = await writer.write(_extends({}, context, {
|
|
154
|
+
id: ruleId,
|
|
155
|
+
name: `${ask.from} → ${ask.to}`,
|
|
156
|
+
content: {
|
|
157
|
+
action: 'create',
|
|
158
|
+
source: ask.from,
|
|
159
|
+
destination: ask.to,
|
|
160
|
+
statusCode: AI_SITE_IMPORT_REDIRECT_STATUS,
|
|
161
|
+
followChain: true
|
|
162
|
+
}
|
|
163
|
+
}));
|
|
164
|
+
if (written.ok === false) {
|
|
165
|
+
// `strictNullChecks` is off, so the refusal is read by its own shape.
|
|
166
|
+
const refusal = written;
|
|
167
|
+
if (refusal.code === CODE_DUPLICATE) {
|
|
168
|
+
entries[ask.at] = {
|
|
169
|
+
from: ask.from,
|
|
170
|
+
to: null,
|
|
171
|
+
outcome: 'kept',
|
|
172
|
+
slot: ask.slot
|
|
173
|
+
};
|
|
174
|
+
} else if (refusal.code === CODE_LIVE_PAGE) {
|
|
175
|
+
leave('page-there');
|
|
176
|
+
} else if (refusal.code === CODE_PLAN_LIMIT) {
|
|
177
|
+
full = refusal.error;
|
|
178
|
+
leave('plan-limit', refusal.error);
|
|
179
|
+
} else {
|
|
180
|
+
leave('refused', refusal.error);
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
var _record_facts;
|
|
184
|
+
const record = written;
|
|
185
|
+
const to = typeof ((_record_facts = record.facts) == null ? void 0 : _record_facts['destination']) === 'string' ? record.facts['destination'] : ask.to;
|
|
186
|
+
entries[ask.at] = {
|
|
187
|
+
from: ask.from,
|
|
188
|
+
to,
|
|
189
|
+
outcome: 'created',
|
|
190
|
+
slot: ask.slot,
|
|
191
|
+
ruleId: record.id || ruleId
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error('ai site import: a redirect could not be written', {
|
|
196
|
+
orgId: job.orgId,
|
|
197
|
+
jobId: job.$id,
|
|
198
|
+
error
|
|
199
|
+
});
|
|
200
|
+
leave('refused', null);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return entries;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=ai-site-import-redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-redirects.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 { createHash } from 'node:crypto'\nimport { isHostPluginEnabled } from '@aglyn/aglyn/plugin-manager/enabled-plugins'\nimport type {\n PluginDraftRecord,\n PluginDraftRefusal,\n PluginResourceDraftWriter,\n} from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts'\nimport { filterEnabledPluginsByReleaseFlags } from '@aglyn/tenant-data-admin/server/release-flags'\nimport type { AiJob, AiJobItemLedger } from '../model/ai-jobs.types'\nimport type { AiSiteImportRedirect, AiSiteImportRedirectReason, AiSiteImportState } from '../model/ai-site-import'\nimport { AI_SITE_IMPORT_REDIRECT_RECORD, aiSiteImportRedirectPlan } from '../model/ai-site-import-redirects'\nimport { aiPluginDraftOwner, aiPluginDraftWriter, type AiPluginDraftOwnerLookup, type AiPluginDraftWriterLookup } from './ai-job-plugin-drafts'\n\n/*==========================================\n * A CLOSED WAVE'S OLD ADDRESSES, REDIRECTED (AGL-4245).\n *\n * After a wave's pages go live, each old address the plan\n * (`aiSiteImportRedirectPlan`) asks for is written as a permanent redirect by\n * the redirects plugin's writer, on the core's resource-drafts seam under the\n * resource `redirect`. This plugin never imports the redirects plugin and\n * never writes a rule itself: the writer applies the Redirects page's rules\n * to the member who started the import.\n *\n * The caller's half of the seam's contract, as an AI build's drafts make it:\n * the owning plugin must run on the site (switched on for the workspace, not\n * off for the site, past its release flag), and the writer's `refusal` is\n * asked once before any write. Either refusing leaves every address out with\n * why; nothing here throws for it.\n *\n * Each rule is written under `<job id>-<hash of its old address>`, so a wave\n * closing twice, a re-read of the site or a later wave finds the rule it\n * already made instead of a second one, and the job's own id names every rule\n * it made. A rule the site already has at that address (the owner's) is kept\n * and reported, never overwritten. The writer follows an existing chain from\n * the new page's address to where it ends, and refuses a loop.\n *=========================================*/\n\n/** The resource the redirects plugin registers its writer under: the same name its rules' addresses are published by. */\nexport const AI_SITE_IMPORT_REDIRECT_RESOURCE = AI_SITE_IMPORT_REDIRECT_RECORD\n\n/** The status code an import's redirects carry: the move is permanent. */\nexport const AI_SITE_IMPORT_REDIRECT_STATUS = 301\n\n/** The writer's refusal codes this import reads (the redirects plugin's `REDIRECT_AI_REFUSAL_CODES`). */\nconst CODE_DUPLICATE = 'duplicate'\nconst CODE_LIVE_PAGE = 'live-page'\nconst CODE_PLAN_LIMIT = 'plan-limit'\n\n/** The rule id an old address's redirect is written under. */\nexport function aiSiteImportRedirectId(jobId: string, from: string): string {\n return `${jobId}-${createHash('sha256').update(from).digest('hex').slice(0, 16)}`\n}\n\nexport interface AiSiteImportRedirectsDeps {\n writerFor?: AiPluginDraftWriterLookup\n ownerFor?: AiPluginDraftOwnerLookup\n /** Whether the owning plugin runs on the site; the release flags and the site's plugin list otherwise. */\n pluginOn?: (input: { orgId: string; pluginId: string; org: Readonly<Record<string, unknown>> | null; host: Readonly<Record<string, unknown>> }) => Promise<boolean>\n}\n\nasync function readPluginOn(input: {\n orgId: string\n pluginId: string\n org: Readonly<Record<string, unknown>> | null\n host: Readonly<Record<string, unknown>>\n}): Promise<boolean> {\n const released = await filterEnabledPluginsByReleaseFlags([input.pluginId], { orgId: input.orgId, authorization: null })\n return released.includes(input.pluginId) && isHostPluginEnabled(input.org as never, input.host as never, input.pluginId)\n}\n\n/** What the redirects plugin's `check` says an old address is stored as, or `null`. */\nfunction storedSourceWith(writer: PluginResourceDraftWriter, hostId: string): (path: string) => string | null {\n return (path) => {\n const checked = writer.check({ action: 'create', source: path, destination: '/' }, { hostId })\n if (!checked.ok) return null\n const stored = checked.facts['storedSource']\n return typeof stored === 'string' && stored ? stored : null\n }\n}\n\n/** Lowercase, no trailing slash, no query: a fallback reading of an old address when no writer can say. */\nfunction plainPath(path: string): string | null {\n const value = String(path ?? '').split(/[?#]/)[0]?.trim().toLowerCase() ?? ''\n if (!value.startsWith('/')) return null\n return value.length > 1 ? value.replace(/\\/+$/, '') || '/' : '/'\n}\n\n/**\n * The import's redirects after a wave closed: every old address considered,\n * each `created`, `kept`, `same` or `left-out` with why. `null` when the job\n * names no site. Never throws for a refusal; a write that throws is left out.\n */\nexport async function aiSiteImportWriteRedirects(\n firestore: FirebaseFirestore.Firestore,\n input: {\n job: Pick<AiJob, '$id' | 'orgId' | 'hostId' | 'createdBy'>\n state: AiSiteImportState\n items: readonly AiJobItemLedger[]\n org: Readonly<Record<string, unknown>> | null\n now: Date\n /** The member the rules are written as; the member who started the import otherwise. */\n actorUid?: string\n },\n deps: AiSiteImportRedirectsDeps = {},\n): Promise<AiSiteImportRedirect[] | null> {\n const { job, state } = input\n const hostId = job.hostId\n if (!hostId) return null\n const hostSnapshot = await firestore.collection('hosts').doc(hostId).get()\n const host = (hostSnapshot.exists ? hostSnapshot.data() : null) ?? {}\n const writer = (deps.writerFor ?? aiPluginDraftWriter)(AI_SITE_IMPORT_REDIRECT_RESOURCE)\n const owner = (deps.ownerFor ?? aiPluginDraftOwner)(AI_SITE_IMPORT_REDIRECT_RESOURCE)\n const plan = aiSiteImportRedirectPlan({\n state,\n items: input.items,\n screens: (host as { screens?: Record<string, unknown> }).screens ?? null,\n storedSource: writer ? storedSourceWith(writer, hostId) : plainPath,\n })\n const entries = [...plan.entries]\n if (!plan.asks.length) return entries\n\n const leaveAll = (reason: AiSiteImportRedirectReason, note: string | null) => {\n for (const ask of plan.asks) entries[ask.at] = { from: ask.from, to: ask.to, outcome: 'left-out', reason, note, slot: ask.slot }\n return entries\n }\n const pluginOn = deps.pluginOn ?? readPluginOn\n if (!writer || !owner || !(await pluginOn({ orgId: job.orgId, pluginId: owner, org: input.org, host }))) {\n return leaveAll('off', 'Redirects is turned off for this site, so no redirects were added. Turn it on to add them.')\n }\n const context = { orgId: job.orgId, hostId, uid: input.actorUid ?? job.createdBy, org: input.org, now: input.now }\n const refusal = await writer.refusal(context)\n if (refusal) return leaveAll('off', refusal.error)\n\n let full: string | null = null\n for (const ask of plan.asks) {\n const leave = (reason: AiSiteImportRedirectReason, note: string | null = null) => {\n entries[ask.at] = { from: ask.from, to: ask.to, outcome: 'left-out', reason, note, slot: ask.slot }\n }\n // Once the plan has no room, the rest wait for room too.\n if (full) {\n leave('plan-limit', full)\n continue\n }\n const ruleId = aiSiteImportRedirectId(job.$id, ask.from)\n try {\n const written = await writer.write({\n ...context,\n id: ruleId,\n name: `${ask.from} → ${ask.to}`,\n content: {\n action: 'create',\n source: ask.from,\n destination: ask.to,\n statusCode: AI_SITE_IMPORT_REDIRECT_STATUS,\n followChain: true,\n },\n })\n if (written.ok === false) {\n // `strictNullChecks` is off, so the refusal is read by its own shape.\n const refusal = written as PluginDraftRefusal\n if (refusal.code === CODE_DUPLICATE) {\n entries[ask.at] = { from: ask.from, to: null, outcome: 'kept', slot: ask.slot }\n } else if (refusal.code === CODE_LIVE_PAGE) {\n leave('page-there')\n } else if (refusal.code === CODE_PLAN_LIMIT) {\n full = refusal.error\n leave('plan-limit', refusal.error)\n } else {\n leave('refused', refusal.error)\n }\n } else {\n const record = written as PluginDraftRecord\n const to = typeof record.facts?.['destination'] === 'string' ? (record.facts['destination'] as string) : ask.to\n entries[ask.at] = { from: ask.from, to, outcome: 'created', slot: ask.slot, ruleId: record.id || ruleId }\n }\n } catch (error) {\n console.error('ai site import: a redirect could not be written', { orgId: job.orgId, jobId: job.$id, error })\n leave('refused', null)\n }\n }\n return entries\n}\n"],"names":["createHash","isHostPluginEnabled","filterEnabledPluginsByReleaseFlags","AI_SITE_IMPORT_REDIRECT_RECORD","aiSiteImportRedirectPlan","aiPluginDraftOwner","aiPluginDraftWriter","AI_SITE_IMPORT_REDIRECT_RESOURCE","AI_SITE_IMPORT_REDIRECT_STATUS","CODE_DUPLICATE","CODE_LIVE_PAGE","CODE_PLAN_LIMIT","aiSiteImportRedirectId","jobId","from","update","digest","slice","readPluginOn","input","released","pluginId","orgId","authorization","includes","org","host","storedSourceWith","writer","hostId","path","checked","check","action","source","destination","ok","stored","facts","plainPath","String","value","split","trim","toLowerCase","startsWith","length","replace","aiSiteImportWriteRedirects","firestore","deps","hostSnapshot","job","state","collection","doc","get","exists","data","writerFor","owner","ownerFor","plan","items","screens","storedSource","entries","asks","leaveAll","reason","note","ask","at","to","outcome","slot","pluginOn","context","uid","actorUid","createdBy","now","refusal","error","full","leave","ruleId","$id","written","write","id","name","content","statusCode","followChain","code","record","console"],"mappings":";AAAA;;;;;;;;;;;;;;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IAAImC,GAAG;gBAAEJ;YAAM;YAC3GE,MAAM,WAAW;QACnB;IACF;IACA,OAAOnB;AACT"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
import type { AiJobItemLedger } from './ai-jobs.types';
|
|
18
|
+
import { type AiSiteImportRedirect, type AiSiteImportRedirectReason, type AiSiteImportState } from './ai-site-import';
|
|
19
|
+
/** One redirect to ask the writer for. */
|
|
20
|
+
export interface AiSiteImportRedirectAsk {
|
|
21
|
+
/** The old address, as the redirects plugin stores it. */
|
|
22
|
+
from: string;
|
|
23
|
+
/** The new page's live address. */
|
|
24
|
+
to: string;
|
|
25
|
+
slot: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface AiSiteImportRedirectPlanInput {
|
|
28
|
+
state: AiSiteImportState;
|
|
29
|
+
items: readonly AiJobItemLedger[];
|
|
30
|
+
/** The site's routing map (`host.screens`): page id → path without its leading slash, `/` for home. */
|
|
31
|
+
screens: Readonly<Record<string, unknown>> | null | undefined;
|
|
32
|
+
/** An old address as the redirects plugin stores a rule's from-path; `null` where it cannot be one. */
|
|
33
|
+
storedSource: (path: string) => string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface AiSiteImportRedirectPlan {
|
|
36
|
+
/** Every old address considered, in the site's order: settled ones as they stand, asked ones as `left-out` placeholders until written. */
|
|
37
|
+
entries: AiSiteImportRedirect[];
|
|
38
|
+
/** The redirects to ask the writer for, each with its place in `entries`. */
|
|
39
|
+
asks: Array<AiSiteImportRedirectAsk & {
|
|
40
|
+
at: number;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Which old addresses to ask a redirect for, and which are settled (see the
|
|
45
|
+
* block above). Pure.
|
|
46
|
+
*/
|
|
47
|
+
export declare function aiSiteImportRedirectPlan(input: AiSiteImportRedirectPlanInput): AiSiteImportRedirectPlan;
|
|
48
|
+
/** What a page's row says of its old address's redirect, or `null` when there is nothing to say yet. */
|
|
49
|
+
export declare function aiSiteImportRedirectText(entry: AiSiteImportRedirect | null | undefined): string | null;
|
|
50
|
+
/** The redirect entry of a page's row, by its slot. */
|
|
51
|
+
export declare function aiSiteImportRedirectOf(state: Pick<AiSiteImportState, 'redirects'> | null | undefined, slot: string): AiSiteImportRedirect | null;
|
|
52
|
+
/** The reasons an address is left out that can clear later: a page published, room in the plan, redirects turned on. */
|
|
53
|
+
export declare const AI_SITE_IMPORT_REDIRECT_RETRYABLE: ReadonlySet<AiSiteImportRedirectReason>;
|
|
54
|
+
/** Whether "Add redirects for published pages" has anything to try: an address left out for a reason that can clear. */
|
|
55
|
+
export declare function aiSiteImportRedirectsRetryable(state: Pick<AiSiteImportState, 'redirects'> | null | undefined): boolean;
|
|
56
|
+
/** The button that runs the pass again, and what it says beside it. */
|
|
57
|
+
export declare const AI_SITE_IMPORT_REDIRECTS_RETRY_COPY: {
|
|
58
|
+
readonly action: "Add redirects for published pages";
|
|
59
|
+
readonly busy: "Adding redirects…";
|
|
60
|
+
readonly help: "Published more of your pages, or made room in your plan? Add the redirects their old addresses are missing.";
|
|
61
|
+
};
|
|
62
|
+
/** The import's redirects, counted, for the card that lists them. */
|
|
63
|
+
export declare function aiSiteImportRedirectCounts(state: Pick<AiSiteImportState, 'redirects'> | null | undefined): {
|
|
64
|
+
created: number;
|
|
65
|
+
kept: number;
|
|
66
|
+
leftOut: number;
|
|
67
|
+
};
|
|
68
|
+
/** The card's lead: "12 redirects added, 1 kept, 2 left out." `null` when there are none to speak of. */
|
|
69
|
+
export declare function aiSiteImportRedirectsSummary(state: Pick<AiSiteImportState, 'redirects'> | null | undefined): string | null;
|
|
70
|
+
/** The record kind the redirects plugin publishes its rules' addresses under (`plugin-record-routes`). */
|
|
71
|
+
export declare const AI_SITE_IMPORT_REDIRECT_RECORD = "redirect";
|
|
72
|
+
/** When the redirects take effect, said beside them. */
|
|
73
|
+
export declare const AI_SITE_IMPORT_REDIRECTS_WHEN = "They send visitors and search engines from your old page addresses to the new pages once your own domain points at your new site. You can change or remove any of them in Redirects.";
|
|
@@ -0,0 +1,203 @@
|
|
|
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
|
+
*/ import { aiSiteImportOtherAddresses } from "./ai-site-import.js";
|
|
17
|
+
const delivered = (row)=>(row == null ? void 0 : row.status) === 'succeeded' || (row == null ? void 0 : row.status) === 'degraded';
|
|
18
|
+
/** A routing map's path as an address: `/` for home, `/about` for `about`. */ function addressOf(path) {
|
|
19
|
+
if (typeof path !== 'string' || !path) return null;
|
|
20
|
+
return path === '/' ? '/' : `/${path.replace(/^\/+/, '')}`;
|
|
21
|
+
}
|
|
22
|
+
/** The key an entry is carried across waves by: its page, or its old address. */ const keyOf = (entry)=>entry.slot ? `s:${entry.slot}` : `a:${entry.from}`;
|
|
23
|
+
/** The outcomes a later wave never asks again. */ const SETTLED = new Set([
|
|
24
|
+
'created',
|
|
25
|
+
'kept',
|
|
26
|
+
'same'
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* Which old addresses to ask a redirect for, and which are settled (see the
|
|
30
|
+
* block above). Pure.
|
|
31
|
+
*/ export function aiSiteImportRedirectPlan(input) {
|
|
32
|
+
var _input_screens, _state_redirects;
|
|
33
|
+
const { state } = input;
|
|
34
|
+
const rows = new Map(input.items.map((row)=>[
|
|
35
|
+
row.slot,
|
|
36
|
+
row
|
|
37
|
+
]));
|
|
38
|
+
const screens = (_input_screens = input.screens) != null ? _input_screens : {};
|
|
39
|
+
const liveAt = new Map();
|
|
40
|
+
const livePaths = new Set();
|
|
41
|
+
for (const [id, path] of Object.entries(screens)){
|
|
42
|
+
const address = addressOf(path);
|
|
43
|
+
if (!address) continue;
|
|
44
|
+
liveAt.set(id, address);
|
|
45
|
+
livePaths.add(address.toLowerCase());
|
|
46
|
+
}
|
|
47
|
+
// Where this import puts its pages, those still to come included.
|
|
48
|
+
const planned = new Map(state.pages.filter((page)=>!page.refused).map((page)=>[
|
|
49
|
+
(page.slug === '/' ? '/' : `/${page.slug}`).toLowerCase(),
|
|
50
|
+
page.slot
|
|
51
|
+
]));
|
|
52
|
+
const prior = new Map(((_state_redirects = state.redirects) != null ? _state_redirects : []).map((entry)=>[
|
|
53
|
+
keyOf(entry),
|
|
54
|
+
entry
|
|
55
|
+
]));
|
|
56
|
+
const entries = [];
|
|
57
|
+
const asks = [];
|
|
58
|
+
const taken = new Map();
|
|
59
|
+
const consider = (page, oldPath, slot)=>{
|
|
60
|
+
var _liveAt_get;
|
|
61
|
+
const from = input.storedSource(oldPath);
|
|
62
|
+
const leave = (reason, to = null)=>entries.push({
|
|
63
|
+
from: from != null ? from : oldPath,
|
|
64
|
+
to,
|
|
65
|
+
outcome: 'left-out',
|
|
66
|
+
reason,
|
|
67
|
+
slot
|
|
68
|
+
});
|
|
69
|
+
if (!from) return leave('unusable');
|
|
70
|
+
const before = prior.get(keyOf({
|
|
71
|
+
slot,
|
|
72
|
+
from
|
|
73
|
+
}));
|
|
74
|
+
if (before && SETTLED.has(before.outcome) && before.from === from) {
|
|
75
|
+
entries.push(before);
|
|
76
|
+
taken.set(from, before.to);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const live = (_liveAt_get = liveAt.get(page.draftId)) != null ? _liveAt_get : null;
|
|
80
|
+
if (!live) return leave('unpublished');
|
|
81
|
+
if (from === live.toLowerCase()) {
|
|
82
|
+
entries.push({
|
|
83
|
+
from,
|
|
84
|
+
to: live,
|
|
85
|
+
outcome: 'same',
|
|
86
|
+
slot
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (taken.has(from)) return taken.get(from) === live ? undefined : leave('shared-address', live);
|
|
91
|
+
const plannedFor = planned.get(from);
|
|
92
|
+
if (livePaths.has(from) || plannedFor && plannedFor !== page.slot) return leave('page-there', live);
|
|
93
|
+
taken.set(from, live);
|
|
94
|
+
asks.push({
|
|
95
|
+
from,
|
|
96
|
+
to: live,
|
|
97
|
+
slot,
|
|
98
|
+
at: entries.length
|
|
99
|
+
});
|
|
100
|
+
entries.push({
|
|
101
|
+
from,
|
|
102
|
+
to: live,
|
|
103
|
+
outcome: 'left-out',
|
|
104
|
+
reason: 'refused',
|
|
105
|
+
slot
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const cameIn = state.pages.filter((page)=>!page.refused && page.origin !== 'proposed' && delivered(rows.get(page.slot)));
|
|
109
|
+
for (const page of cameIn)consider(page, page.path, page.slot);
|
|
110
|
+
// Other addresses of a page that came in, as the read recorded them.
|
|
111
|
+
const byOldPath = new Map();
|
|
112
|
+
for (const page of cameIn){
|
|
113
|
+
const key = input.storedSource(page.path);
|
|
114
|
+
if (key && !byOldPath.has(key)) byOldPath.set(key, page);
|
|
115
|
+
}
|
|
116
|
+
for (const other of aiSiteImportOtherAddresses(state)){
|
|
117
|
+
const key = input.storedSource(other.sameAs);
|
|
118
|
+
const page = key ? byOldPath.get(key) : undefined;
|
|
119
|
+
if (page) consider(page, other.path, null);
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
entries,
|
|
123
|
+
asks
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/*------------------------------------------
|
|
127
|
+
* What the import's page says
|
|
128
|
+
*-----------------------------------------*/ /** Why an old address got no redirect, after "No redirect: ". */ const REASON_COPY = {
|
|
129
|
+
unpublished: 'the new page is not published yet. Add one in Redirects once it is.',
|
|
130
|
+
'page-there': 'a page on your new site uses this address, and a redirect would hide it.',
|
|
131
|
+
'shared-address': 'redirects ignore anything after a ? in an address, and another old page already uses this one.',
|
|
132
|
+
unusable: 'this old address cannot be used for a redirect.',
|
|
133
|
+
'plan-limit': 'your plan has no room for more redirects.',
|
|
134
|
+
off: 'redirects are not available on this site.',
|
|
135
|
+
refused: 'it could not be added.'
|
|
136
|
+
};
|
|
137
|
+
/** What a page's row says of its old address's redirect, or `null` when there is nothing to say yet. */ export function aiSiteImportRedirectText(entry) {
|
|
138
|
+
if (!entry) return null;
|
|
139
|
+
switch(entry.outcome){
|
|
140
|
+
case 'created':
|
|
141
|
+
return entry.to ? `Redirect added: visitors to the old address go to ${entry.to}` : 'Redirect added from the old address';
|
|
142
|
+
case 'kept':
|
|
143
|
+
return 'You already had a redirect from the old address, so it was kept';
|
|
144
|
+
case 'same':
|
|
145
|
+
return null;
|
|
146
|
+
default:
|
|
147
|
+
var _entry_reason;
|
|
148
|
+
return `No redirect: ${entry.note && (entry.reason === 'plan-limit' || entry.reason === 'off' || entry.reason === 'refused') ? entry.note : REASON_COPY[(_entry_reason = entry.reason) != null ? _entry_reason : 'refused']}`;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** The redirect entry of a page's row, by its slot. */ export function aiSiteImportRedirectOf(state, slot) {
|
|
152
|
+
var _find, _ref;
|
|
153
|
+
return (_find = ((_ref = state == null ? void 0 : state.redirects) != null ? _ref : []).find((entry)=>entry.slot === slot)) != null ? _find : null;
|
|
154
|
+
}
|
|
155
|
+
/** The reasons an address is left out that can clear later: a page published, room in the plan, redirects turned on. */ export const AI_SITE_IMPORT_REDIRECT_RETRYABLE = new Set([
|
|
156
|
+
'unpublished',
|
|
157
|
+
'plan-limit',
|
|
158
|
+
'off'
|
|
159
|
+
]);
|
|
160
|
+
/** Whether "Add redirects for published pages" has anything to try: an address left out for a reason that can clear. */ export function aiSiteImportRedirectsRetryable(state) {
|
|
161
|
+
var _ref;
|
|
162
|
+
return ((_ref = state == null ? void 0 : state.redirects) != null ? _ref : []).some((entry)=>{
|
|
163
|
+
var _entry_reason;
|
|
164
|
+
return entry.outcome === 'left-out' && AI_SITE_IMPORT_REDIRECT_RETRYABLE.has((_entry_reason = entry.reason) != null ? _entry_reason : 'refused');
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/** The button that runs the pass again, and what it says beside it. */ export const AI_SITE_IMPORT_REDIRECTS_RETRY_COPY = {
|
|
168
|
+
action: 'Add redirects for published pages',
|
|
169
|
+
busy: 'Adding redirects…',
|
|
170
|
+
help: 'Published more of your pages, or made room in your plan? Add the redirects their old addresses are missing.'
|
|
171
|
+
};
|
|
172
|
+
/** The import's redirects, counted, for the card that lists them. */ export function aiSiteImportRedirectCounts(state) {
|
|
173
|
+
var _ref;
|
|
174
|
+
const counts = {
|
|
175
|
+
created: 0,
|
|
176
|
+
kept: 0,
|
|
177
|
+
leftOut: 0
|
|
178
|
+
};
|
|
179
|
+
for (const entry of (_ref = state == null ? void 0 : state.redirects) != null ? _ref : []){
|
|
180
|
+
if (entry.outcome === 'created') counts.created += 1;
|
|
181
|
+
else if (entry.outcome === 'kept') counts.kept += 1;
|
|
182
|
+
else if (entry.outcome === 'left-out') counts.leftOut += 1;
|
|
183
|
+
}
|
|
184
|
+
return counts;
|
|
185
|
+
}
|
|
186
|
+
/** The card's lead: "12 redirects added, 1 kept, 2 left out." `null` when there are none to speak of. */ export function aiSiteImportRedirectsSummary(state) {
|
|
187
|
+
const counts = aiSiteImportRedirectCounts(state);
|
|
188
|
+
if (!counts.created && !counts.kept && !counts.leftOut) return null;
|
|
189
|
+
const parts = [
|
|
190
|
+
`${counts.created} ${counts.created === 1 ? 'redirect' : 'redirects'} added from your old addresses`,
|
|
191
|
+
...counts.kept ? [
|
|
192
|
+
`${counts.kept} of yours kept`
|
|
193
|
+
] : [],
|
|
194
|
+
...counts.leftOut ? [
|
|
195
|
+
`${counts.leftOut} left out`
|
|
196
|
+
] : []
|
|
197
|
+
];
|
|
198
|
+
return `${parts.join(', ')}.`;
|
|
199
|
+
}
|
|
200
|
+
/** The record kind the redirects plugin publishes its rules' addresses under (`plugin-record-routes`). */ export const AI_SITE_IMPORT_REDIRECT_RECORD = 'redirect';
|
|
201
|
+
/** When the redirects take effect, said beside them. */ export const AI_SITE_IMPORT_REDIRECTS_WHEN = 'They send visitors and search engines from your old page addresses to the new pages once your own domain points at your new site. You can change or remove any of them in Redirects.';
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=ai-site-import-redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-import-redirects.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 type { AiJobItemLedger } from './ai-jobs.types'\nimport {\n aiSiteImportOtherAddresses,\n type AiSiteImportPage,\n type AiSiteImportRedirect,\n type AiSiteImportRedirectReason,\n type AiSiteImportState,\n} from './ai-site-import'\n\n/*==========================================\n * THE OLD ADDRESSES, REDIRECTED (AGL-4245).\n *\n * A business moving its site here keeps its search ranking and its\n * bookmarked links only if each old page address sends visitors to the new\n * page. The import knows both addresses of every page it brings in, so when\n * a wave closes each one gets a permanent (301) redirect, written by the\n * redirects plugin's own writer (the core's resource-drafts seam, resource\n * `redirect`), which holds it to every rule the Redirects page holds a save\n * to: the publishing role, the plan's redirects and its allowance, the\n * page's normalization, duplicates, loops, and a published page's address.\n *\n * This file decides, without reading or writing, which old addresses to ask\n * for and which are settled already:\n *\n * - a page that came in and is live on the new site at an address other\n * than its old one is asked for, to that live address;\n * - a page at the same address needs nothing (`same`);\n * - a page that came in but is not published (its site is not in preview,\n * or another page took its address) is left out as `unpublished`, and is\n * asked for again when a later wave closes;\n * - an old address a page of the new site is at, or one this import will\n * put a page at, is never redirected (`page-there`): the redirect would\n * hide the page;\n * - two old addresses that are one once their query is dropped (a redirect\n * matches the path only) get one redirect, the first's (`shared-address`);\n * - an old address the import already recorded as another address of a\n * page it brought in (a `duplicate` left out with its `sameAs`) is asked\n * for, to that page's live address. No other skipped page is: the import\n * records no new home for it, and none is invented;\n * - an address already `created`, `kept` or `same` is carried as it is, so\n * a later wave never asks twice.\n *\n * Addresses are compared as the redirects plugin stores them, through its\n * writer's `check` (`storedSource`), never by a rule restated here.\n *=========================================*/\n\n/** One redirect to ask the writer for. */\nexport interface AiSiteImportRedirectAsk {\n /** The old address, as the redirects plugin stores it. */\n from: string\n /** The new page's live address. */\n to: string\n slot: string | null\n}\n\nexport interface AiSiteImportRedirectPlanInput {\n state: AiSiteImportState\n items: readonly AiJobItemLedger[]\n /** The site's routing map (`host.screens`): page id → path without its leading slash, `/` for home. */\n screens: Readonly<Record<string, unknown>> | null | undefined\n /** An old address as the redirects plugin stores a rule's from-path; `null` where it cannot be one. */\n storedSource: (path: string) => string | null\n}\n\nexport interface AiSiteImportRedirectPlan {\n /** Every old address considered, in the site's order: settled ones as they stand, asked ones as `left-out` placeholders until written. */\n entries: AiSiteImportRedirect[]\n /** The redirects to ask the writer for, each with its place in `entries`. */\n asks: Array<AiSiteImportRedirectAsk & { at: number }>\n}\n\nconst delivered = (row: AiJobItemLedger | undefined) => row?.status === 'succeeded' || row?.status === 'degraded'\n\n/** A routing map's path as an address: `/` for home, `/about` for `about`. */\nfunction addressOf(path: unknown): string | null {\n if (typeof path !== 'string' || !path) return null\n return path === '/' ? '/' : `/${path.replace(/^\\/+/, '')}`\n}\n\n/** The key an entry is carried across waves by: its page, or its old address. */\nconst keyOf = (entry: Pick<AiSiteImportRedirect, 'slot' | 'from'>) => (entry.slot ? `s:${entry.slot}` : `a:${entry.from}`)\n\n/** The outcomes a later wave never asks again. */\nconst SETTLED: ReadonlySet<AiSiteImportRedirect['outcome']> = new Set(['created', 'kept', 'same'])\n\n/**\n * Which old addresses to ask a redirect for, and which are settled (see the\n * block above). Pure.\n */\nexport function aiSiteImportRedirectPlan(input: AiSiteImportRedirectPlanInput): AiSiteImportRedirectPlan {\n const { state } = input\n const rows = new Map(input.items.map((row) => [row.slot, row]))\n const screens = (input.screens ?? {}) as Record<string, unknown>\n const liveAt = new Map<string, string>()\n const livePaths = new Set<string>()\n for (const [id, path] of Object.entries(screens)) {\n const address = addressOf(path)\n if (!address) continue\n liveAt.set(id, address)\n livePaths.add(address.toLowerCase())\n }\n // Where this import puts its pages, those still to come included.\n const planned = new Map(\n state.pages.filter((page) => !page.refused).map((page) => [(page.slug === '/' ? '/' : `/${page.slug}`).toLowerCase(), page.slot]),\n )\n const prior = new Map((state.redirects ?? []).map((entry) => [keyOf(entry), entry]))\n const entries: AiSiteImportRedirect[] = []\n const asks: AiSiteImportRedirectPlan['asks'] = []\n const taken = new Map<string, string | null>()\n\n const consider = (page: AiSiteImportPage, oldPath: string, slot: string | null) => {\n const from = input.storedSource(oldPath)\n const leave = (reason: AiSiteImportRedirectReason, to: string | null = null) =>\n entries.push({ from: from ?? oldPath, to, outcome: 'left-out', reason, slot })\n if (!from) return leave('unusable')\n const before = prior.get(keyOf({ slot, from }))\n if (before && SETTLED.has(before.outcome) && before.from === from) {\n entries.push(before)\n taken.set(from, before.to)\n return\n }\n const live = liveAt.get(page.draftId) ?? null\n if (!live) return leave('unpublished')\n if (from === live.toLowerCase()) {\n entries.push({ from, to: live, outcome: 'same', slot })\n return\n }\n if (taken.has(from)) return taken.get(from) === live ? undefined : leave('shared-address', live)\n const plannedFor = planned.get(from)\n if (livePaths.has(from) || (plannedFor && plannedFor !== page.slot)) return leave('page-there', live)\n taken.set(from, live)\n asks.push({ from, to: live, slot, at: entries.length })\n entries.push({ from, to: live, outcome: 'left-out', reason: 'refused', slot })\n }\n\n const cameIn = state.pages.filter((page) => !page.refused && page.origin !== 'proposed' && delivered(rows.get(page.slot)))\n for (const page of cameIn) consider(page, page.path, page.slot)\n // Other addresses of a page that came in, as the read recorded them.\n const byOldPath = new Map<string, AiSiteImportPage>()\n for (const page of cameIn) {\n const key = input.storedSource(page.path)\n if (key && !byOldPath.has(key)) byOldPath.set(key, page)\n }\n for (const other of aiSiteImportOtherAddresses(state)) {\n const key = input.storedSource(other.sameAs)\n const page = key ? byOldPath.get(key) : undefined\n if (page) consider(page, other.path, null)\n }\n return { entries, asks }\n}\n\n/*------------------------------------------\n * What the import's page says\n *-----------------------------------------*/\n\n/** Why an old address got no redirect, after \"No redirect: \". */\nconst REASON_COPY: Readonly<Record<AiSiteImportRedirectReason, string>> = {\n unpublished: 'the new page is not published yet. Add one in Redirects once it is.',\n 'page-there': 'a page on your new site uses this address, and a redirect would hide it.',\n 'shared-address': 'redirects ignore anything after a ? in an address, and another old page already uses this one.',\n unusable: 'this old address cannot be used for a redirect.',\n 'plan-limit': 'your plan has no room for more redirects.',\n off: 'redirects are not available on this site.',\n refused: 'it could not be added.',\n}\n\n/** What a page's row says of its old address's redirect, or `null` when there is nothing to say yet. */\nexport function aiSiteImportRedirectText(entry: AiSiteImportRedirect | null | undefined): string | null {\n if (!entry) return null\n switch (entry.outcome) {\n case 'created':\n return entry.to ? `Redirect added: visitors to the old address go to ${entry.to}` : 'Redirect added from the old address'\n case 'kept':\n return 'You already had a redirect from the old address, so it was kept'\n case 'same':\n return null\n default:\n return `No redirect: ${entry.note && (entry.reason === 'plan-limit' || entry.reason === 'off' || entry.reason === 'refused') ? entry.note : REASON_COPY[entry.reason ?? 'refused']}`\n }\n}\n\n/** The redirect entry of a page's row, by its slot. */\nexport function aiSiteImportRedirectOf(state: Pick<AiSiteImportState, 'redirects'> | null | undefined, slot: string): AiSiteImportRedirect | null {\n return (state?.redirects ?? []).find((entry) => entry.slot === slot) ?? null\n}\n\n/** The reasons an address is left out that can clear later: a page published, room in the plan, redirects turned on. */\nexport const AI_SITE_IMPORT_REDIRECT_RETRYABLE: ReadonlySet<AiSiteImportRedirectReason> = new Set(['unpublished', 'plan-limit', 'off'])\n\n/** Whether \"Add redirects for published pages\" has anything to try: an address left out for a reason that can clear. */\nexport function aiSiteImportRedirectsRetryable(state: Pick<AiSiteImportState, 'redirects'> | null | undefined): boolean {\n return (state?.redirects ?? []).some((entry) => entry.outcome === 'left-out' && AI_SITE_IMPORT_REDIRECT_RETRYABLE.has(entry.reason ?? 'refused'))\n}\n\n/** The button that runs the pass again, and what it says beside it. */\nexport const AI_SITE_IMPORT_REDIRECTS_RETRY_COPY = {\n action: 'Add redirects for published pages',\n busy: 'Adding redirects…',\n help: 'Published more of your pages, or made room in your plan? Add the redirects their old addresses are missing.',\n} as const\n\n/** The import's redirects, counted, for the card that lists them. */\nexport function aiSiteImportRedirectCounts(state: Pick<AiSiteImportState, 'redirects'> | null | undefined): {\n created: number\n kept: number\n leftOut: number\n} {\n const counts = { created: 0, kept: 0, leftOut: 0 }\n for (const entry of state?.redirects ?? []) {\n if (entry.outcome === 'created') counts.created += 1\n else if (entry.outcome === 'kept') counts.kept += 1\n else if (entry.outcome === 'left-out') counts.leftOut += 1\n }\n return counts\n}\n\n/** The card's lead: \"12 redirects added, 1 kept, 2 left out.\" `null` when there are none to speak of. */\nexport function aiSiteImportRedirectsSummary(state: Pick<AiSiteImportState, 'redirects'> | null | undefined): string | null {\n const counts = aiSiteImportRedirectCounts(state)\n if (!counts.created && !counts.kept && !counts.leftOut) return null\n const parts = [\n `${counts.created} ${counts.created === 1 ? 'redirect' : 'redirects'} added from your old addresses`,\n ...(counts.kept ? [`${counts.kept} of yours kept`] : []),\n ...(counts.leftOut ? [`${counts.leftOut} left out`] : []),\n ]\n return `${parts.join(', ')}.`\n}\n\n/** The record kind the redirects plugin publishes its rules' addresses under (`plugin-record-routes`). */\nexport const AI_SITE_IMPORT_REDIRECT_RECORD = 'redirect'\n\n/** When the redirects take effect, said beside them. */\nexport const AI_SITE_IMPORT_REDIRECTS_WHEN =\n 'They send visitors and search engines from your old page addresses to the new pages once your own domain points at your new site. You can change or remove any of them in Redirects.'\n"],"names":["aiSiteImportOtherAddresses","delivered","row","status","addressOf","path","replace","keyOf","entry","slot","from","SETTLED","Set","aiSiteImportRedirectPlan","input","state","rows","Map","items","map","screens","liveAt","livePaths","id","Object","entries","address","set","add","toLowerCase","planned","pages","filter","page","refused","slug","prior","redirects","asks","taken","consider","oldPath","storedSource","leave","reason","to","push","outcome","before","get","has","live","draftId","undefined","plannedFor","at","length","cameIn","origin","byOldPath","key","other","sameAs","REASON_COPY","unpublished","unusable","off","aiSiteImportRedirectText","note","aiSiteImportRedirectOf","find","AI_SITE_IMPORT_REDIRECT_RETRYABLE","aiSiteImportRedirectsRetryable","some","AI_SITE_IMPORT_REDIRECTS_RETRY_COPY","action","busy","help","aiSiteImportRedirectCounts","counts","created","kept","leftOut","aiSiteImportRedirectsSummary","parts","join","AI_SITE_IMPORT_REDIRECT_RECORD","AI_SITE_IMPORT_REDIRECTS_WHEN"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAG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NC,MAAM;AACR,EAAU;AAEV,mEAAmE,GACnE,OAAO,SAASC,2BAA2B/D,KAA8D;;IAKvG,MAAMgE,SAAS;QAAEC,SAAS;QAAGC,MAAM;QAAGC,SAAS;IAAE;IACjD,KAAK,MAAM1E,iBAASO,yBAAAA,MAAOsB,SAAS,mBAAI,EAAE,CAAE;QAC1C,IAAI7B,MAAMuC,OAAO,KAAK,WAAWgC,OAAOC,OAAO,IAAI;aAC9C,IAAIxE,MAAMuC,OAAO,KAAK,QAAQgC,OAAOE,IAAI,IAAI;aAC7C,IAAIzE,MAAMuC,OAAO,KAAK,YAAYgC,OAAOG,OAAO,IAAI;IAC3D;IACA,OAAOH;AACT;AAEA,uGAAuG,GACvG,OAAO,SAASI,6BAA6BpE,KAA8D;IACzG,MAAMgE,SAASD,2BAA2B/D;IAC1C,IAAI,CAACgE,OAAOC,OAAO,IAAI,CAACD,OAAOE,IAAI,IAAI,CAACF,OAAOG,OAAO,EAAE,OAAO;IAC/D,MAAME,QAAQ;QACZ,GAAGL,OAAOC,OAAO,CAAC,CAAC,EAAED,OAAOC,OAAO,KAAK,IAAI,aAAa,YAAY,8BAA8B,CAAC;WAChGD,OAAOE,IAAI,GAAG;YAAC,GAAGF,OAAOE,IAAI,CAAC,cAAc,CAAC;SAAC,GAAG,EAAE;WACnDF,OAAOG,OAAO,GAAG;YAAC,GAAGH,OAAOG,OAAO,CAAC,SAAS,CAAC;SAAC,GAAG,EAAE;KACzD;IACD,OAAO,GAAGE,MAAMC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B;AAEA,wGAAwG,GACxG,OAAO,MAAMC,iCAAiC,WAAU;AAExD,sDAAsD,GACtD,OAAO,MAAMC,gCACX,uLAAsL"}
|
|
@@ -134,6 +134,8 @@ export interface AiSiteImportRowView {
|
|
|
134
134
|
pictures?: string | null;
|
|
135
135
|
/** A page the site's plan proposed (AGL-4152): it has no old page to open. */
|
|
136
136
|
isNew?: boolean;
|
|
137
|
+
/** What became of the old address's redirect (AGL-4245): added, kept, or left out and why. */
|
|
138
|
+
redirect?: string | null;
|
|
137
139
|
}
|
|
138
140
|
/**
|
|
139
141
|
* "3 photos added", "2 photos added, 1 already in your media library"; with
|
|
@@ -26,6 +26,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
26
26
|
import { aiCreditRangeText } from "./ai-credit-estimate.js";
|
|
27
27
|
import { aiMediaCreditsPerPicture } from "./ai-media-credits.js";
|
|
28
28
|
import { AI_SITE_IMPORT_FRAME_SLOT, AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE, AI_SITE_IMPORT_LAYOUT_KEPT, AI_SITE_IMPORT_PLAN_FELL_BACK, AI_SITE_IMPORT_LEFT_OUT_COPY, AI_SITE_IMPORT_LEFT_OUT_REASONS, AI_SITE_IMPORT_DEFAULT_CHOICE, AI_SITE_IMPORT_UNREAD_REASONS, aiSiteImportChoiceOf, aiSiteImportGeneratedPicturesOn, aiSiteImportNextWave, aiSiteImportPagesText, aiSiteImportPlanAccepted, aiSiteImportPlanAwaits, aiSiteImportQuoteText, aiSiteImportReadStops, aiSiteImportReadVerdictMessage, aiSiteImportReadVerdictReason, aiSiteImportRemainingCreditRange, aiSiteImportReviewWave, aiSiteImportRunningWave, aiSiteImportWaveChoice, aiSiteImportWaveCreditRange, aiSiteImportWaveIsGenerative, aiSiteImportWaveOwed, aiSiteImportWordingCredits, aiSiteImportWordingPages } from "./ai-site-import.js";
|
|
29
|
+
import { aiSiteImportRedirectOf, aiSiteImportRedirectText } from "./ai-site-import-redirects.js";
|
|
29
30
|
/** What the card says to a plan that does not include it. */ export const AI_SITE_IMPORT_PLAN_COPY = 'Bring your current website in, every page and photo, on any paid plan. Upgrade to bring yours in.';
|
|
30
31
|
/** What the card says to a member who cannot. */ export const AI_SITE_IMPORT_ROLE_COPY = 'Only the workspace owner or an admin can bring a site in.';
|
|
31
32
|
/**
|
|
@@ -222,6 +223,8 @@ const BUILD_COPY = {
|
|
|
222
223
|
pictures: aiSiteImportPicturesText(page)
|
|
223
224
|
} : {}, page.origin === 'proposed' ? {
|
|
224
225
|
isNew: true
|
|
226
|
+
} : {}, aiSiteImportRedirectText(aiSiteImportRedirectOf(state, slot)) ? {
|
|
227
|
+
redirect: aiSiteImportRedirectText(aiSiteImportRedirectOf(state, slot))
|
|
225
228
|
} : {}, {
|
|
226
229
|
photos: aiSiteImportPhotosText(page.photos),
|
|
227
230
|
outputId: (_ref5 = row == null ? void 0 : row.outputs[0]) != null ? _ref5 : null,
|