@aglyn/plugins-ai 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/activity/ai-activity.js +4 -2
- package/src/lib/activity/ai-activity.js.map +1 -1
- package/src/lib/components/ai-credits-card.component.d.ts +4 -3
- package/src/lib/components/ai-credits-card.component.js +13 -12
- package/src/lib/components/ai-credits-card.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +14 -5
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
- package/src/lib/components/ai-upsell-dialog.component.js +3 -3
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +2 -2
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/declarations.d.ts +2 -2
- package/src/lib/declarations.js +10 -9
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
- package/src/lib/jobs/ai-job-import-step.js +170 -14
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.js +2 -0
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.js +6 -2
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
- package/src/lib/jobs/ai-site-import-compile.js +339 -27
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
- package/src/lib/jobs/ai-site-import-document.js +42 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
- package/src/lib/jobs/ai-site-import-look.js +89 -6
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
- package/src/lib/layout-language/ai-layout-compiler.js +378 -56
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
- package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.js +30 -18
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +74 -3
- package/src/lib/layout-language/ai-layout-language.js +5 -3
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
- package/src/lib/layout-language/ai-layout-store.js +32 -6
- package/src/lib/layout-language/ai-layout-store.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
- package/src/lib/model/ai-site-import-fidelity.js +347 -25
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-view.js +4 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +205 -6
- package/src/lib/model/ai-site-import.js +161 -5
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +8 -1
- package/src/lib/model/ai-site-look.js +8 -5
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +4 -3
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +1 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/providers/model-choice.d.ts +6 -3
- package/src/lib/providers/model-choice.js +8 -4
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
- package/src/lib/runtime/ai-doctrine-validators.js +25 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +19 -2
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-page-links.d.ts +15 -0
- package/src/lib/runtime/ai-page-links.js +48 -0
- package/src/lib/runtime/ai-page-links.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +35 -6
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +3 -1
- package/src/lib/site-import/site-import-crawl.js +8 -3
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +20 -0
- package/src/lib/site-import/site-import-css.js +106 -0
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +39 -0
- package/src/lib/site-import/site-import-html.js +515 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +16 -6
- package/src/lib/site-import/site-import-layout.js +528 -52
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +286 -24
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +3 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/usage/assist-credits.d.ts +5 -4
- package/src/lib/usage/assist-credits.js +5 -4
- package/src/lib/usage/assist-credits.js.map +1 -1
- package/src/lib/usage/staff-org-ai-view.js +6 -6
- package/src/lib/usage/staff-org-ai-view.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +4 -4
- package/src/lib/usage/staff-org-ai.js +8 -7
- package/src/lib/usage/staff-org-ai.js.map +1 -1
- package/src/lib/usage/staff-org-usage-ai.js +2 -2
- package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
|
@@ -62,7 +62,7 @@ import { listDomainOwnershipClaims, normalizeOwnershipDomain } from "@aglyn/tena
|
|
|
62
62
|
import { getOrgForUser, memberHasOrgPermission } from "@aglyn/tenant-data-admin/server/organizations";
|
|
63
63
|
import { consumeRateLimit } from "@aglyn/tenant-data-admin/server/rate-limit-store";
|
|
64
64
|
import { isServerReleaseFlagOnForOrg } from "@aglyn/tenant-data-admin/server/release-flags";
|
|
65
|
-
import { AI_SITE_IMPORT_DOMAIN_INPUT, AI_SITE_IMPORT_FRAME_SLOT, AI_SITE_IMPORT_LABEL_MAX_CHARS, AI_SITE_IMPORT_LEFT_OUT_COPY, AI_SITE_IMPORT_MAX_PAGES, AI_SITE_IMPORT_MIN_WORDS, AI_SITE_IMPORT_WAVE_PAGES, aiSiteImportFormsIn, aiSiteImportFrameIsRead, aiSiteImportInventory, aiSiteImportItemOpen, aiSiteImportLedger, aiSiteImportNextWork, aiSiteImportPageBuild, aiSiteImportPageSettled, aiSiteImportPagesRead, aiSiteImportPhotosIn, aiSiteImportReadStops, aiSiteImportReadVerdict, aiSiteImportReadVerdictMessage, aiSiteImportReadVerdictReason, aiSiteImportWaveClosed, aiSiteImportWaveMessage, aiSiteImportWaveStarted } from "../model/ai-site-import.js";
|
|
65
|
+
import { AI_SITE_IMPORT_DOMAIN_INPUT, AI_SITE_IMPORT_FRAME_SLOT, AI_SITE_IMPORT_LABEL_MAX_CHARS, AI_SITE_IMPORT_LEFT_OUT_COPY, AI_SITE_IMPORT_MAX_PAGES, AI_SITE_IMPORT_MIN_WORDS, AI_SITE_IMPORT_WAVE_PAGES, aiSiteImportFormsIn, aiSiteImportFrameIsRead, aiSiteImportInventory, aiSiteImportItemOpen, aiSiteImportLedger, aiSiteImportNextWork, aiSiteImportPageBuild, aiSiteImportPageSettled, aiSiteImportPagesRead, aiSiteImportPhotosIn, aiSiteImportReadStops, aiSiteImportReadVerdict, aiSiteImportReadVerdictMessage, aiSiteImportReadVerdictReason, aiSiteImportOwnFilms, aiSiteImportVideoNote, aiSiteImportWaveClosed, siteImportApprovedHostsWith, aiSiteImportWaveMessage, aiSiteImportWaveStarted } from "../model/ai-site-import.js";
|
|
66
66
|
import { aiModelForStep } from "../providers/routing.js";
|
|
67
67
|
import { SITE_IMPORT_RELEASE_FLAG } from "../site-import/site-import-flag.js";
|
|
68
68
|
import { crawlSiteForImport, siteImportOrigins } from "../site-import/site-import-crawl.js";
|
|
@@ -133,6 +133,25 @@ const DAY_MS = 24 * 60 * 60 * 1000;
|
|
|
133
133
|
plan: 'Bringing an existing site in is included on every paid plan.',
|
|
134
134
|
/** Names "Bring a site in" (`ai.import`, AGL-4047), never a role. */ role: 'Your role does not include "Bring a site in" — ask an organization admin'
|
|
135
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* The hosts of the films a page plays from the old site, added to the site's
|
|
138
|
+
* Approved media hosts (AGL-4140): the tenant's `media-src` admits only those,
|
|
139
|
+
* so without it the poster shows and the browser refuses the film on a press.
|
|
140
|
+
* In a transaction over the host document, so an owner's edit in between is
|
|
141
|
+
* kept: the owner's entries stay as they are and where they are, each new
|
|
142
|
+
* host is added once, after them, within the list's ceiling, and a list that
|
|
143
|
+
* gains nothing is not written.
|
|
144
|
+
*/ async function approveFilmHosts(firestore, hostId, films) {
|
|
145
|
+
const ref = firestore.collection('hosts').doc(hostId);
|
|
146
|
+
await firestore.runTransaction(async (transaction)=>{
|
|
147
|
+
const host = await transaction.get(ref);
|
|
148
|
+
if (!host.exists) return;
|
|
149
|
+
const next = siteImportApprovedHostsWith(host.get('approvedMediaHosts'), films);
|
|
150
|
+
if (next) transaction.update(ref, {
|
|
151
|
+
approvedMediaHosts: next
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
136
155
|
async function readOwnership(orgId, domain) {
|
|
137
156
|
const claims = await listDomainOwnershipClaims(orgId);
|
|
138
157
|
const claim = claims.find((entry)=>entry.domain === domain);
|
|
@@ -287,7 +306,8 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
287
306
|
* (`aiSiteImportFrameLinkTo`). Every label is the source's, as written.
|
|
288
307
|
* `null` where the reader found no menu on the home page.
|
|
289
308
|
*/ export function aiSiteImportFrameSource(state, wave) {
|
|
290
|
-
var _home_footer, _home_look, _footer_copyright;
|
|
309
|
+
var _home_footer, _home_look, _ref, _home_look1, _footer_copyright;
|
|
310
|
+
var _state_look, _footer_panels;
|
|
291
311
|
const home = state.home;
|
|
292
312
|
const nav = home == null ? void 0 : home.nav;
|
|
293
313
|
if (!home || !nav || !aiSiteImportFrameIsRead(state)) return null;
|
|
@@ -301,8 +321,35 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
301
321
|
};
|
|
302
322
|
const present = (value)=>value !== null;
|
|
303
323
|
const footer = (_home_footer = home.footer) != null ? _home_footer : null;
|
|
324
|
+
const look = (_home_look = home.look) != null ? _home_look : null;
|
|
325
|
+
// A column's picture as the library holds it, never the source's address (AGL-4139).
|
|
326
|
+
const pictures = (_ref = (_state_look = state.look) == null ? void 0 : _state_look.pictures) != null ? _ref : [];
|
|
327
|
+
const column = (read)=>{
|
|
328
|
+
var _ref;
|
|
329
|
+
var _read_image;
|
|
330
|
+
const held = read.image ? pictures.find((photo)=>{
|
|
331
|
+
var _read_image;
|
|
332
|
+
return photo.from === ((_read_image = read.image) == null ? void 0 : _read_image.url);
|
|
333
|
+
}) : undefined;
|
|
334
|
+
return _extends({
|
|
335
|
+
heading: read.heading,
|
|
336
|
+
lines: read.lines,
|
|
337
|
+
band: read.band
|
|
338
|
+
}, held ? {
|
|
339
|
+
image: _extends({
|
|
340
|
+
src: held.src,
|
|
341
|
+
alt: (_ref = (_read_image = read.image) == null ? void 0 : _read_image.alt) != null ? _ref : ''
|
|
342
|
+
}, held.width && held.height ? {
|
|
343
|
+
ratio: held.width / held.height
|
|
344
|
+
} : {})
|
|
345
|
+
} : {}, read.width ? {
|
|
346
|
+
width: read.width
|
|
347
|
+
} : {});
|
|
348
|
+
};
|
|
304
349
|
return {
|
|
305
|
-
nav: nav.items.map((group)=>
|
|
350
|
+
nav: nav.items.map((group)=>{
|
|
351
|
+
var _group_columns, _group_panel, _group_panel1;
|
|
352
|
+
return _extends({
|
|
306
353
|
label: group.label,
|
|
307
354
|
to: to(group.href),
|
|
308
355
|
items: group.items.map((entry)=>{
|
|
@@ -315,17 +362,28 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
315
362
|
iconPath: entry.iconPath
|
|
316
363
|
} : {}, entry.column ? {
|
|
317
364
|
column: entry.column
|
|
365
|
+
} : {}, entry.at !== undefined ? {
|
|
366
|
+
at: entry.at
|
|
367
|
+
} : {}, entry.tile ? {
|
|
368
|
+
tile: aiSiteImportTileRoles(entry.tile, look)
|
|
318
369
|
} : {});
|
|
319
370
|
}).filter(present)
|
|
320
|
-
}
|
|
371
|
+
}, ((_group_columns = group.columns) == null ? void 0 : _group_columns.length) ? {
|
|
372
|
+
columns: group.columns.map(column)
|
|
373
|
+
} : {}, ((_group_panel = group.panel) == null ? void 0 : _group_panel.hover) ? {
|
|
374
|
+
hover: true
|
|
375
|
+
} : {}, ((_group_panel1 = group.panel) == null ? void 0 : _group_panel1.width) ? {
|
|
376
|
+
measure: group.panel.width >= 1400 ? 'xl' : 'lg'
|
|
377
|
+
} : {});
|
|
378
|
+
}).filter((group)=>group.items.length || group.to),
|
|
321
379
|
ctas: nav.ctas.map((cta)=>{
|
|
322
380
|
const target = link(cta.label, cta.href);
|
|
323
381
|
return target ? _extends({}, target, {
|
|
324
382
|
style: cta.style
|
|
325
383
|
}) : null;
|
|
326
384
|
}).filter(present),
|
|
327
|
-
header: aiSiteImportHeaderGround(nav.background, (
|
|
328
|
-
footer: footer ? {
|
|
385
|
+
header: aiSiteImportHeaderGround(nav.background, (_home_look1 = home.look) != null ? _home_look1 : null),
|
|
386
|
+
footer: footer ? _extends({
|
|
329
387
|
columns: footer.columns.map((column)=>({
|
|
330
388
|
heading: column.heading,
|
|
331
389
|
links: column.links.map((entry)=>link(entry.label, entry.href)).filter(present)
|
|
@@ -342,12 +400,54 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
342
400
|
email: footer.email,
|
|
343
401
|
// The © line as the source writes it; where it writes none, the source's own name.
|
|
344
402
|
copyright: (_footer_copyright = footer.copyright) != null ? _footer_copyright : home.siteName ? `© ${home.siteName}` : null
|
|
345
|
-
} :
|
|
403
|
+
}, ((_footer_panels = footer.panels) == null ? void 0 : _footer_panels.length) ? {
|
|
404
|
+
panels: footer.panels.map((box)=>{
|
|
405
|
+
var _box_links;
|
|
406
|
+
return _extends({}, column(box), {
|
|
407
|
+
links: ((_box_links = box.links) != null ? _box_links : []).map((entry)=>link(entry.label, entry.href)).filter(present)
|
|
408
|
+
}, box.iconPath ? {
|
|
409
|
+
iconPath: box.iconPath
|
|
410
|
+
} : {});
|
|
411
|
+
})
|
|
412
|
+
} : {}) : null
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
/** A tile's fill and its icon as theme roles (AGL-4139): on a filled tile of the brand's or the second color, the icon in that color's own ink. */ export function aiSiteImportTileRoles(tile, look) {
|
|
416
|
+
const fill = aiSiteImportFrameColorRole(tile.fill, 'fill', look);
|
|
417
|
+
if (fill === 'primary.main') return {
|
|
418
|
+
fill,
|
|
419
|
+
color: 'primary.contrastText'
|
|
420
|
+
};
|
|
421
|
+
if (fill === 'secondary.main') return {
|
|
422
|
+
fill,
|
|
423
|
+
color: 'secondary.contrastText'
|
|
424
|
+
};
|
|
425
|
+
return {
|
|
426
|
+
fill,
|
|
427
|
+
color: aiSiteImportFrameColorRole(tile.color, 'ink', look)
|
|
346
428
|
};
|
|
347
429
|
}
|
|
430
|
+
/** How far apart two hues are, in degrees. */ const hueApart = (a, b)=>{
|
|
431
|
+
const apart = Math.abs(a - b) % 360;
|
|
432
|
+
return apart > 180 ? 360 - apart : apart;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* A source's tile fill or icon color as a theme role (AGL-4139), the way
|
|
436
|
+
* the header's ground is ranked: a light fill is the theme's light wash and
|
|
437
|
+
* a grey one its stronger step; a quiet icon is the quiet text's; a color
|
|
438
|
+
* near the source's buttons' is the brand's, any other the theme's second
|
|
439
|
+
* color. Never the value itself.
|
|
440
|
+
*/ export function aiSiteImportFrameColorRole(hex, kind, look) {
|
|
441
|
+
const own = hex && /^#[0-9a-f]{6}$/i.test(hex) ? aiHexOklch(hex) : null;
|
|
442
|
+
if (!own) return kind === 'fill' ? 'action.hover' : 'primary.main';
|
|
443
|
+
if (kind === 'fill' && own.L >= 0.9) return 'action.hover';
|
|
444
|
+
if (own.C < 0.04) return kind === 'fill' ? 'action.selected' : 'text.secondary';
|
|
445
|
+
const brand = (look == null ? void 0 : look.buttonFill) && /^#[0-9a-f]{6}$/i.test(look.buttonFill) ? aiHexOklch(look.buttonFill) : null;
|
|
446
|
+
return !brand || hueApart(own.h, brand.h) <= 40 ? 'primary.main' : 'secondary.main';
|
|
447
|
+
}
|
|
348
448
|
/** The header and footer's job: a layout of the site's brand, linking the wave's pages, in the layout language. */ export function aiSiteImportFrameJob(job, state, wave, items) {
|
|
349
449
|
var _ref, _state_home, _ref1, _ref2;
|
|
350
|
-
var _state_frame, _state_look, _home_brand_logo;
|
|
450
|
+
var _state_frame, _state_look, _home_brand_logo, _home_footer;
|
|
351
451
|
const draftId = (_ref = (_state_frame = state.frame) == null ? void 0 : _state_frame.draftId) != null ? _ref : `${job.$id}-${AI_SITE_IMPORT_FRAME_SLOT}`;
|
|
352
452
|
const creation = {
|
|
353
453
|
kind: 'layout',
|
|
@@ -377,7 +477,9 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
377
477
|
alt
|
|
378
478
|
} : {}, aspect ? {
|
|
379
479
|
aspect
|
|
380
|
-
} : {}) : {}, {
|
|
480
|
+
} : {}) : {}, withLogo && ((_home_footer = home.footer) == null ? void 0 : _home_footer.logo) === true ? {
|
|
481
|
+
footer: true
|
|
482
|
+
} : {}, {
|
|
381
483
|
name: !logo || home.brand.kind !== 'logo-only'
|
|
382
484
|
}) : null;
|
|
383
485
|
// The source's own menu, buttons and footer, drawn with no model (AGL-4108).
|
|
@@ -416,7 +518,7 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
416
518
|
}
|
|
417
519
|
/** The page brought in, as its page job carries it: its lines, its photos, and the pages its links may go to (AGL-4084). */ export function aiSiteImportDocumentFor(state, page) {
|
|
418
520
|
var _page_build, _ref;
|
|
419
|
-
var _page_read, _page_photos, _page_read1;
|
|
521
|
+
var _page_read, _page_photos, _page_read1, _page_read_videos, _page_read2;
|
|
420
522
|
const blocks = (_page_read = page.read) == null ? void 0 : _page_read.blocks;
|
|
421
523
|
if (!(blocks == null ? void 0 : blocks.length)) return null;
|
|
422
524
|
return _extends({
|
|
@@ -440,6 +542,8 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
440
542
|
forms: page.forms
|
|
441
543
|
} : {}, ((_page_read1 = page.read) == null ? void 0 : _page_read1.layout) ? {
|
|
442
544
|
layout: page.read.layout
|
|
545
|
+
} : {}, ((_page_read2 = page.read) == null ? void 0 : (_page_read_videos = _page_read2.videos) == null ? void 0 : _page_read_videos.length) ? {
|
|
546
|
+
videos: page.read.videos
|
|
443
547
|
} : {});
|
|
444
548
|
}
|
|
445
549
|
/** One page's job: a page job's plan of one screen, its sections the old page's own, its words carried as they are. */ export function aiSiteImportPageJob(job, state, page, items) {
|
|
@@ -506,7 +610,7 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
506
610
|
});
|
|
507
611
|
}
|
|
508
612
|
/** What the home page says of the site as a whole (AGL-4084), kept for the look, the header and footer and the listing. */ export function aiSiteImportHomeOf(crawled) {
|
|
509
|
-
var _crawled_pages_find, _page_title, _page_description, _page_ogImage, _ref;
|
|
613
|
+
var _crawled_pages_find, _page_title, _page_description, _page_ogImage, _ref, _page_icons, _page_icons1;
|
|
510
614
|
var _facts_organization;
|
|
511
615
|
const page = (_crawled_pages_find = crawled.pages.find((entry)=>entry.foundBy === 'home')) != null ? _crawled_pages_find : crawled.pages.find((entry)=>(entry.path.replace(/\/+$/, '') || '/') === '/');
|
|
512
616
|
if (!page) return null;
|
|
@@ -563,8 +667,33 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
563
667
|
footer: page.footer
|
|
564
668
|
} : {}, page.look ? {
|
|
565
669
|
look: page.look
|
|
670
|
+
} : {}, aiSiteImportFaviconOf((_page_icons = page.icons) != null ? _page_icons : []) ? {
|
|
671
|
+
favicon: aiSiteImportFaviconOf((_page_icons1 = page.icons) != null ? _page_icons1 : [])
|
|
566
672
|
} : {});
|
|
567
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* The icon a site's head names that a site's own icon can be made from
|
|
676
|
+
* (AGL-4139): its largest touch icon, else its largest icon in a picture
|
|
677
|
+
* format the library takes, never an `.ico` or a drawing. `null` for none.
|
|
678
|
+
*/ export function aiSiteImportFaviconOf(icons) {
|
|
679
|
+
var _ref, _largest;
|
|
680
|
+
var _this;
|
|
681
|
+
const raster = (icon)=>{
|
|
682
|
+
var _icon_type;
|
|
683
|
+
const type = ((_icon_type = icon.type) != null ? _icon_type : '').toLowerCase();
|
|
684
|
+
if (type) return /^image\/(?:png|jpe?g|webp|gif)$/.test(type);
|
|
685
|
+
try {
|
|
686
|
+
return /\.(?:png|jpe?g|webp|gif)$/i.test(new URL(icon.url).pathname);
|
|
687
|
+
} catch (unused) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
const largest = (rel)=>icons.filter((icon)=>icon.rel === rel && /^https:\/\//i.test(icon.url) && (rel === 'apple-touch-icon' || raster(icon))).sort((a, b)=>{
|
|
692
|
+
var _b_size, _a_size;
|
|
693
|
+
return ((_b_size = b.size) != null ? _b_size : 0) - ((_a_size = a.size) != null ? _a_size : 0);
|
|
694
|
+
})[0];
|
|
695
|
+
return (_ref = (_this = (_largest = largest('apple-touch-icon')) != null ? _largest : largest('icon')) == null ? void 0 : _this.url) != null ? _ref : null;
|
|
696
|
+
}
|
|
568
697
|
/** Whether a page asks no model at all: copied as it is, its listing the source's own. */ function aiSiteImportPageAsksNoModel(page) {
|
|
569
698
|
var _ref;
|
|
570
699
|
var _page_read_meta, _page_read, _page_read_meta1, _page_read1;
|
|
@@ -729,7 +858,7 @@ async function readDraftWords(firestore, hostId, draftId) {
|
|
|
729
858
|
return wave.slots.every((slot)=>!aiSiteImportItemOpen(items, slot));
|
|
730
859
|
}
|
|
731
860
|
export function createAiJobImportStep(deps = {}) {
|
|
732
|
-
var _deps_crawl, _deps_runnerFor, _deps_ownership, _deps_rateLimit, _deps_releaseFlagOn, _deps_ingest, _deps_readRoom, _deps_readSiteName, _deps_pageWritten, _deps_mintId, _deps_clock, _deps_look, _deps_publishWave, _deps_draftWords;
|
|
861
|
+
var _deps_crawl, _deps_runnerFor, _deps_ownership, _deps_rateLimit, _deps_releaseFlagOn, _deps_ingest, _deps_readRoom, _deps_readSiteName, _deps_pageWritten, _deps_mintId, _deps_clock, _deps_look, _deps_publishWave, _deps_draftWords, _deps_approveFilmHosts;
|
|
733
862
|
const crawl = (_deps_crawl = deps.crawl) != null ? _deps_crawl : crawlSiteForImport;
|
|
734
863
|
const runnerFor = (_deps_runnerFor = deps.runnerFor) != null ? _deps_runnerFor : aiJobStepRunnerFor;
|
|
735
864
|
const ownershipOf = (_deps_ownership = deps.ownership) != null ? _deps_ownership : readOwnership;
|
|
@@ -744,6 +873,7 @@ export function createAiJobImportStep(deps = {}) {
|
|
|
744
873
|
const runLook = (_deps_look = deps.look) != null ? _deps_look : aiRunSiteImportLook;
|
|
745
874
|
const publishWave = (_deps_publishWave = deps.publishWave) != null ? _deps_publishWave : aiPublishImportedWave;
|
|
746
875
|
const draftWordsOf = (_deps_draftWords = deps.draftWords) != null ? _deps_draftWords : readDraftWords;
|
|
876
|
+
const approveFilms = (_deps_approveFilmHosts = deps.approveFilmHosts) != null ? _deps_approveFilmHosts : approveFilmHosts;
|
|
747
877
|
return async (context)=>{
|
|
748
878
|
var _job_siteImport, _job_items;
|
|
749
879
|
var _state_waves_;
|
|
@@ -1176,6 +1306,8 @@ export function createAiJobImportStep(deps = {}) {
|
|
|
1176
1306
|
if (stopped) {
|
|
1177
1307
|
item = stopped;
|
|
1178
1308
|
} else if (page && derived.plan) {
|
|
1309
|
+
var _ref1;
|
|
1310
|
+
var _page_photos, _page_read;
|
|
1179
1311
|
// A page counts as in only when its sections are in it (AGL-3596).
|
|
1180
1312
|
const screen = derived.plan.screens[0];
|
|
1181
1313
|
const written = await pageWritten(firestore, {
|
|
@@ -1185,12 +1317,36 @@ export function createAiJobImportStep(deps = {}) {
|
|
|
1185
1317
|
draftId: page.draftId,
|
|
1186
1318
|
layoutLanguage: true
|
|
1187
1319
|
});
|
|
1320
|
+
// A film the page plays from the old site's address may play there: its host is approved for the site (AGL-4140).
|
|
1321
|
+
const films = written ? aiSiteImportOwnFilms(page.read, (_ref1 = (_page_photos = page.photos) == null ? void 0 : _page_photos.assets) != null ? _ref1 : []) : [];
|
|
1322
|
+
let approved = false;
|
|
1323
|
+
if (films.length) {
|
|
1324
|
+
try {
|
|
1325
|
+
await approveFilms(firestore, hostId, films);
|
|
1326
|
+
approved = true;
|
|
1327
|
+
} catch (error) {
|
|
1328
|
+
console.error('ai site import: the films’ hosts were not approved', {
|
|
1329
|
+
orgId: job.orgId,
|
|
1330
|
+
jobId: job.$id,
|
|
1331
|
+
slot,
|
|
1332
|
+
error
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
// What its row says of its forms, and of where its videos play from (AGL-4140).
|
|
1337
|
+
const note = [
|
|
1338
|
+
page.formNote,
|
|
1339
|
+
aiSiteImportVideoNote((_page_read = page.read) == null ? void 0 : _page_read.videos, {
|
|
1340
|
+
films: films.length,
|
|
1341
|
+
approved
|
|
1342
|
+
})
|
|
1343
|
+
].filter(Boolean).join(' ');
|
|
1188
1344
|
item = written ? _extends({
|
|
1189
1345
|
slot,
|
|
1190
1346
|
status: 'succeeded',
|
|
1191
1347
|
outputs: spent.outputs.map((output)=>output.id)
|
|
1192
|
-
},
|
|
1193
|
-
note
|
|
1348
|
+
}, note ? {
|
|
1349
|
+
note
|
|
1194
1350
|
} : {}) : {
|
|
1195
1351
|
slot,
|
|
1196
1352
|
status: 'failed',
|