@inneranimalmedia/agentsam-sdk 2.6.10 → 2.6.11
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/README.md +3 -0
- package/TRADEMARKS.md +22 -0
- package/apps/README.md +3 -0
- package/apps/cad-creator/LICENSE +21 -0
- package/apps/cad-creator/README.md +4 -1
- package/apps/cad-creator/shared/cad/package.json +1 -1
- package/apps/client-cms-editor/LICENSE +21 -0
- package/apps/client-cms-editor/README.md +3 -0
- package/apps/client-cms-editor/backend/package.json +2 -2
- package/apps/client-cms-editor/frontend/package.json +3 -3
- package/apps/client-cms-editor/package-lock.json +43 -43
- package/apps/client-cms-editor/package.json +3 -3
- package/apps/client-cms-editor/reference/harvest/HARVEST_RECEIPT.json +1 -1
- package/apps/client-cms-editor/reference/harvest/README.md +1 -1
- package/apps/client-cms-editor/reference/harvest/plans/ARCHIVE-INTAKE.md +1 -1
- package/apps/client-cms-editor/reference/harvest/plans/HARVEST-INDEX.md +1 -1
- package/apps/client-cms-editor/reference/harvest/plans/TOOLING-LAB.md +1 -1
- package/apps/client-cms-editor/shared/cms/package.json +1 -1
- package/docs/MINI.md +4 -2
- package/docs/REPO_FILE_MAP.txt +0 -1
- package/docs/SOURCE_ARCHITECTURE.md +1 -1
- package/docs/architecture/DUAL_ANALYTICS_PRODUCT.md +140 -0
- package/docs/content-studio/REVISION_GATE_2026-09-27.md +1 -1
- package/docs/engineering/go-portability/01-product-project-deployment-authority.md +69 -0
- package/docs/engineering/provider-internal-renames/01-lane-initialization.md +20 -0
- package/docs/engineering/provider-internal-renames/01a-runtime-environment-contract.md +115 -0
- package/docs/engineering/provider-internal-renames/02-cfoa.md +57 -0
- package/docs/engineering/provider-internal-renames/03-gclioa.md +32 -0
- package/docs/engineering/provider-internal-renames/04-goaude.md +50 -0
- package/docs/engineering/provider-internal-renames/05-gdrv.md +33 -0
- package/docs/engineering/provider-internal-renames/06-verification.md +103 -0
- package/docs/engineering/provider-internal-renames/README.md +77 -0
- package/docs/engineering/provider-internal-renames/runtime-environment-contract.json +220 -0
- package/docs/engineering/test-diagnostics/go-cli-test-hang-20261003.md +49 -0
- package/docs/engineering/test-diagnostics/go-skip-deploy-docker-fix.md +90 -0
- package/docs/knowledge-service-verification.md +3 -3
- package/docs/plans/AGENTSAM-SUSPEND-QUEUE-KNOWLEDGE-RDP-2026-10-03.md +870 -0
- package/docs/plans/LOCAL-STUDIO-GRADUATION-2026-09-26.md +9 -9
- package/docs/plans/MACHINE-FIRST-APPS-TUI-2026-09-24.md +11 -11
- package/docs/plans/RECONCILIATION-2026-09-19.md +6 -6
- package/docs/plans/SAM_WORK_PROTOCOL.md +667 -0
- package/docs/plans/TOMORROW-EXTENSIVE-TODO-2026-09-26.md +2 -2
- package/docs/plans/UNIVERSAL-INGEST-MACHINE-FIRST-2026-09-24.md +3 -3
- package/examples/hyperspace-demo/src/main.tsx +227 -110
- package/migrations/d1/0020_agentsam_receipt_catalog.sql +35 -0
- package/migrations/runtime/0006_agent_run_suspend_activity.sql +53 -0
- package/migrations/runtime/0007_queue_control.sql +40 -0
- package/migrations/runtime/0008_agent_run_dependencies.sql +24 -0
- package/migrations/runtime/0008_analytics_legacy_bootstrap.sql +43 -0
- package/migrations/runtime/0009_analytics_authority.sql +108 -0
- package/package.json +26 -11
- package/packages/agentsam-brand/README.md +3 -0
- package/packages/agentsam-brand/package.json +2 -2
- package/packages/agentsam-contracts/dist/adapter.d.ts +22 -0
- package/packages/agentsam-contracts/dist/adapter.js +0 -0
- package/packages/agentsam-contracts/dist/agent.d.ts +66 -0
- package/packages/agentsam-contracts/dist/agent.js +15 -0
- package/packages/agentsam-contracts/dist/artifacts.d.ts +70 -0
- package/packages/agentsam-contracts/dist/artifacts.js +0 -0
- package/packages/agentsam-contracts/dist/authority.d.ts +21 -0
- package/packages/agentsam-contracts/dist/authority.js +0 -0
- package/packages/agentsam-contracts/dist/context.d.ts +14 -0
- package/packages/agentsam-contracts/dist/context.js +0 -0
- package/packages/agentsam-contracts/dist/errors.d.ts +121 -0
- package/packages/agentsam-contracts/dist/errors.js +5 -0
- package/packages/agentsam-contracts/dist/events.d.ts +53 -0
- package/packages/agentsam-contracts/dist/events.js +0 -0
- package/packages/agentsam-contracts/dist/execution.d.ts +38 -0
- package/packages/agentsam-contracts/dist/execution.js +0 -0
- package/packages/agentsam-contracts/dist/hooks.d.ts +31 -0
- package/packages/agentsam-contracts/dist/hooks.js +0 -0
- package/packages/agentsam-contracts/dist/identity.d.ts +15 -0
- package/packages/agentsam-contracts/dist/identity.js +0 -0
- package/packages/agentsam-contracts/dist/index.d.ts +16 -0
- package/packages/agentsam-contracts/dist/index.js +164 -0
- package/packages/agentsam-contracts/dist/models.d.ts +9 -0
- package/packages/agentsam-contracts/dist/models.js +0 -0
- package/packages/agentsam-contracts/dist/providers.d.ts +27 -0
- package/packages/agentsam-contracts/dist/providers.js +0 -0
- package/packages/agentsam-contracts/dist/repository.d.ts +56 -0
- package/packages/agentsam-contracts/dist/repository.js +15 -0
- package/packages/agentsam-contracts/dist/run.d.ts +113 -0
- package/packages/agentsam-contracts/dist/run.js +132 -0
- package/packages/agentsam-contracts/dist/tools.d.ts +82 -0
- package/packages/agentsam-contracts/dist/tools.js +0 -0
- package/packages/agentsam-contracts/dist/widgets.d.ts +38 -0
- package/packages/agentsam-contracts/dist/widgets.js +0 -0
- package/packages/agentsam-contracts/package.json +9 -1
- package/packages/agentsam-contracts/scripts/build.mjs +1 -1
- package/packages/agentsam-contracts/src/agent.ts +78 -3
- package/packages/agentsam-contracts/src/index.ts +2 -0
- package/packages/agentsam-contracts/src/run.ts +320 -0
- package/packages/agentsam-contracts/src/widgets.ts +58 -0
- package/packages/agentsam-contracts/test/contracts.test.mjs +1 -1
- package/packages/agentsam-contracts/test/run-contract.test.mjs +94 -0
- package/packages/agentsam-errors/package.json +1 -1
- package/packages/agentsam-goap/README.md +3 -0
- package/packages/agentsam-goap/package.json +2 -2
- package/packages/agentsam-hooks/package.json +2 -2
- package/packages/agentsam-hooks/src/adapters/agents.js +48 -22
- package/packages/agentsam-hooks/src/index.d.ts +16 -0
- package/packages/agentsam-knowledge/package.json +1 -1
- package/packages/agentsam-knowledge/src/backends/index.js +1 -1
- package/packages/agentsam-merch/README.md +62 -0
- package/packages/agentsam-merch/bin/agentsam-merch.mjs +16 -0
- package/packages/agentsam-merch/package.json +65 -0
- package/packages/agentsam-merch/profiles/completeful/dtg-back-large.json +42 -0
- package/packages/agentsam-merch/profiles/completeful/laser-engraving.json +39 -0
- package/packages/agentsam-merch/profiles/generic/embroidery-digitization.json +22 -0
- package/packages/agentsam-merch/schemas/collection-candidate.schema.json +66 -0
- package/packages/agentsam-merch/schemas/manufacturing-profile.schema.json +221 -0
- package/packages/agentsam-merch/src/adapters-completeful.js +50 -0
- package/packages/agentsam-merch/src/cli.js +93 -0
- package/packages/agentsam-merch/src/collection-lab.js +60 -0
- package/packages/agentsam-merch/src/compatibility.js +501 -0
- package/packages/agentsam-merch/src/derivatives.js +112 -0
- package/packages/agentsam-merch/src/index.d.ts +316 -0
- package/packages/agentsam-merch/src/index.js +46 -0
- package/packages/agentsam-merch/src/node/index.d.ts +58 -0
- package/packages/agentsam-merch/src/node/index.js +6 -0
- package/packages/agentsam-merch/src/node/raster.js +142 -0
- package/packages/agentsam-merch/src/node/vector.js +239 -0
- package/packages/agentsam-merch/src/product-concepts.js +118 -0
- package/packages/agentsam-merch/src/profile-registry.js +104 -0
- package/packages/agentsam-merch/src/profile.js +158 -0
- package/packages/agentsam-merch/src/transforms.js +215 -0
- package/packages/agentsam-merch/test/merch.test.mjs +332 -0
- package/packages/agentsam-merch/test/node-transforms.test.mjs +149 -0
- package/packages/agentsam-nav/dist/browser.global.js +71 -34
- package/packages/agentsam-nav/dist/browser.js +3179 -781
- package/packages/agentsam-nav/dist/index.js +3171 -773
- package/packages/agentsam-nav/package.json +1 -1
- package/packages/agentsam-queue-control/README.md +4 -1
- package/packages/agentsam-queue-control/package.json +4 -3
- package/packages/agentsam-queue-control/schemas/job-envelope.schema.json +111 -11
- package/packages/agentsam-queue-control/src/adapters/cloudflare.js +34 -6
- package/packages/agentsam-queue-control/src/adapters/memory.js +11 -2
- package/packages/agentsam-queue-control/src/adapters/sqlite.js +259 -0
- package/packages/agentsam-queue-control/src/contracts.js +207 -3
- package/packages/agentsam-queue-control/src/control-plane.js +62 -2
- package/packages/agentsam-queue-control/src/index.js +1 -0
- package/packages/agentsam-queue-control/test/queue-control.test.mjs +310 -0
- package/packages/agentsam-queue-control/test/sqlite-adapter.test.mjs +91 -0
- package/packages/agentsam-rapid-rust/README.md +3 -0
- package/packages/agentsam-repository/README.md +3 -0
- package/packages/agentsam-repository/package.json +1 -1
- package/packages/agentsam-vault/package.json +1 -1
- package/packages/agentsam-workbench/README.md +43 -0
- package/packages/agentsam-workbench/package.json +13 -3
- package/packages/agentsam-workbench/src/agent/AgentConversationSurface.tsx +108 -0
- package/packages/agentsam-workbench/src/agent/AgentPanel.tsx +25 -8
- package/packages/agentsam-workbench/src/agent/AgentRuntimeField.tsx +152 -0
- package/packages/agentsam-workbench/src/agent/Composer.tsx +10 -1
- package/packages/agentsam-workbench/src/agent/RunMode.ts +26 -0
- package/packages/agentsam-workbench/src/agent/Thread.tsx +18 -3
- package/packages/agentsam-workbench/src/agent/index.ts +3 -0
- package/packages/agentsam-workbench/src/index.ts +4 -0
- package/packages/agentsam-workbench/src/manufacturing/PreflightIndicator.tsx +203 -0
- package/packages/agentsam-workbench/src/manufacturing/index.ts +2 -0
- package/packages/agentsam-workbench/src/manufacturing/loading.ts +147 -0
- package/packages/agentsam-workbench/src/widgets/BuiltinWidget.tsx +22 -0
- package/packages/agentsam-workbench/src/widgets/CountdownWidget.tsx +68 -0
- package/packages/agentsam-workbench/src/widgets/WidgetFrame.tsx +56 -0
- package/packages/agentsam-workbench/src/widgets/countdown.ts +25 -0
- package/packages/agentsam-workbench/src/widgets/index.ts +6 -0
- package/packages/agentsam-workbench/src/widgets/registry.ts +13 -0
- package/packages/agentsam-workbench/src/widgets/useCountdown.ts +128 -0
- package/packages/agentsam-workbench/src/widgets/widgets.css +102 -0
- package/packages/connectors/{cloudflare → cfoa}/package.json +3 -3
- package/packages/heuristic-theme/package.json +1 -1
- package/packages/identity/README.md +3 -0
- package/packages/identity/backend/README.md +3 -0
- package/packages/identity/package.json +1 -1
- package/packages/identity/src/frontend/auth-portal/README.md +3 -0
- package/packages/identity/src/index.js +1 -1
- package/packages/identity/src/oauth/README.md +4 -1
- package/packages/identity/src/oauth/credentials.js +1 -1
- package/packages/identity/src/server/worker-router.js +1 -1
- package/packages/identity/tests/google-desktop-identity-login.test.mjs +1 -1
- package/packages/identity/tests/lane1-packed-consumer.test.mjs +1 -1
- package/packages/identity/tests/oauth-presets-accounts-ssot.test.mjs +1 -1
- package/packages/providers/completeful/package.json +1 -1
- package/packages/theme-church-site/package.json +1 -1
- package/packages/theme-companions-site/package.json +1 -1
- package/packages/theme-floors-site/package.json +1 -1
- package/packages/theme-fuelnfree-site/package.json +1 -1
- package/packages/theme-handyman-site/package.json +1 -1
- package/packages/theme-insurance-site/package.json +1 -1
- package/packages/theme-scenes/package.json +1 -1
- package/packages/theme-shinshu-site/package.json +1 -1
- package/packages/work-graph/package.json +1 -1
- package/protocol/models/README.md +3 -0
- package/protocol/receipts/agentsam.receipt.v1.json +95 -0
- package/protocol/theme-refinery/receipts/products-registry-batch-20260924.json +6 -6
- package/protocol/theme-refinery/receipts/theme-harvest-20260924.json +6 -6
- package/skills/README.md +3 -0
- package/src/acp/agent-executor.js +106 -0
- package/src/acp/client.js +316 -0
- package/src/acp/dependencies.js +426 -0
- package/src/acp/http.js +207 -0
- package/src/acp/index.js +22 -0
- package/src/acp/runs.js +125 -0
- package/src/acp/runtime-selection.js +180 -0
- package/src/cli/command-catalog.js +3 -0
- package/src/cli.js +24 -0
- package/src/commands/cloudflare-login.js +1 -1
- package/src/commands/cloudflare.js +2 -2
- package/src/commands/connections.js +1 -1
- package/src/commands/go.js +76 -6
- package/src/commands/merch.js +5 -0
- package/src/commands/mini.js +1 -1
- package/src/commands/receipts.js +140 -0
- package/src/commands/run.js +253 -0
- package/src/go/container.js +1 -1
- package/src/go/contract.js +61 -18
- package/src/go/discover.js +0 -4
- package/src/go/index.js +13 -1
- package/src/go/probe.js +109 -0
- package/src/go/{cloudflare.js → providers/cloudflare.js} +36 -136
- package/src/go/verify.js +1 -1
- package/src/indexing/ingest/inventory.js +1 -1
- package/src/lib/deploy/local-studio.js +2 -2
- package/src/lib/mini/scaffold.js +1 -1
- package/src/lib/whoami-capabilities.js +1 -1
- package/src/local/runtime-store.js +8 -0
- package/src/mcp/cloudflare-bundles.js +1 -1
- package/src/plugins/index.js +1 -0
- package/src/plugins/registry.js +59 -6
- package/src/receipts/contract.js +68 -0
- package/src/receipts/index.js +20 -0
- package/src/receipts/prune.js +64 -0
- package/src/receipts/sinks.js +285 -0
- package/templates/mini/gadget/app.js +15 -40
- package/templates/mini/gadget/index.html +7 -7
- package/templates/mini/shared/style.css +1 -1
- package/packages/agentsam-repository/src/goap.js.bak-20260922011251 +0 -670
- /package/packages/connectors/{cloudflare → cfoa}/OAUTH_STORAGE_AUDIT.md +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/api-client.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/capabilities.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/credential.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/brand-protection.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/keyless.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/pages.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/scanner.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/snippets.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/tag-gateway.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/tags.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/token-validation.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/vectorize.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/workflows.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/index.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/oauth-persist.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/owner.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/permission-options.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/routes.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/scope-catalog.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/vault.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/tests/capabilities.test.mjs +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/tests/connector.test.mjs +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/tests/oauth-persist.test.mjs +0 -0
- /package/packages/identity/src/oauth/{google-desktop-exchange.js → goaude.js} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const COLLECTION_CANDIDATE_STATE = Object.freeze({
|
|
2
|
+
CONCEPT: "concept",
|
|
3
|
+
APPROVED_ART: "approved-art",
|
|
4
|
+
PRODUCTION_READY: "production-ready",
|
|
5
|
+
SAMPLE_ORDERED: "sample-ordered",
|
|
6
|
+
SAMPLE_APPROVED: "sample-approved",
|
|
7
|
+
PUBLISHED: "published",
|
|
8
|
+
RETIRED: "retired",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const transitions = Object.freeze({
|
|
12
|
+
"concept": ["approved-art", "retired"],
|
|
13
|
+
"approved-art": ["production-ready", "concept", "retired"],
|
|
14
|
+
"production-ready": ["sample-ordered", "approved-art", "retired"],
|
|
15
|
+
"sample-ordered": ["sample-approved", "production-ready", "retired"],
|
|
16
|
+
"sample-approved": ["published", "production-ready", "retired"],
|
|
17
|
+
"published": ["retired"],
|
|
18
|
+
"retired": [],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function canTransitionCollectionCandidate(from, to) {
|
|
22
|
+
return (transitions[from] || []).includes(to);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function createCollectionCandidate(input = {}) {
|
|
26
|
+
if (!input.id) throw new TypeError("candidate id is required");
|
|
27
|
+
if (!input.designId) throw new TypeError("candidate designId is required");
|
|
28
|
+
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
id: String(input.id),
|
|
31
|
+
designId: String(input.designId),
|
|
32
|
+
collectionPath: Object.freeze([...(input.collectionPath || [])]),
|
|
33
|
+
state: input.state || COLLECTION_CANDIDATE_STATE.CONCEPT,
|
|
34
|
+
products: Object.freeze([...(input.products || [])]),
|
|
35
|
+
approvals: Object.freeze({
|
|
36
|
+
artwork: Boolean(input.approvals?.artwork),
|
|
37
|
+
wording: Boolean(input.approvals?.wording),
|
|
38
|
+
palette: Boolean(input.approvals?.palette),
|
|
39
|
+
visualIdentity: Boolean(input.approvals?.visualIdentity),
|
|
40
|
+
}),
|
|
41
|
+
metadata: Object.freeze({ ...(input.metadata || {}) }),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function transitionCollectionCandidate(candidate, nextState) {
|
|
46
|
+
if (!canTransitionCollectionCandidate(candidate.state, nextState)) {
|
|
47
|
+
throw new Error(`Invalid collection candidate transition: ${candidate.state} -> ${nextState}`);
|
|
48
|
+
}
|
|
49
|
+
return Object.freeze({ ...candidate, state: nextState });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function approvalsComplete(candidate) {
|
|
53
|
+
const approvals = candidate.approvals || {};
|
|
54
|
+
return Boolean(
|
|
55
|
+
approvals.artwork &&
|
|
56
|
+
approvals.wording &&
|
|
57
|
+
approvals.palette &&
|
|
58
|
+
approvals.visualIdentity
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mediaKindForFormat,
|
|
3
|
+
normalizeFormat,
|
|
4
|
+
normalizeManufacturingProfile,
|
|
5
|
+
} from "./profile.js";
|
|
6
|
+
|
|
7
|
+
export const COMPATIBILITY_STATUS = Object.freeze({
|
|
8
|
+
READY: "ready",
|
|
9
|
+
READY_WITH_WARNING: "ready_with_warning",
|
|
10
|
+
READY_WITH_TRANSFORM: "ready_with_transform",
|
|
11
|
+
PREPARED_FOR_DIGITIZATION: "prepared_for_digitization",
|
|
12
|
+
NEEDS_VARIANT: "needs_variant",
|
|
13
|
+
UNSUPPORTED: "unsupported",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const severity = Object.freeze({
|
|
17
|
+
[COMPATIBILITY_STATUS.READY]: 0,
|
|
18
|
+
[COMPATIBILITY_STATUS.READY_WITH_WARNING]: 1,
|
|
19
|
+
[COMPATIBILITY_STATUS.READY_WITH_TRANSFORM]: 2,
|
|
20
|
+
[COMPATIBILITY_STATUS.PREPARED_FOR_DIGITIZATION]: 3,
|
|
21
|
+
[COMPATIBILITY_STATUS.NEEDS_VARIANT]: 4,
|
|
22
|
+
[COMPATIBILITY_STATUS.UNSUPPORTED]: 5,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function addIssue(issues, status, code, message, action = null, meta = null) {
|
|
26
|
+
issues.push(Object.freeze({ status, code, message, action, meta }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function numberOrNull(value) {
|
|
30
|
+
const number = Number(value);
|
|
31
|
+
return Number.isFinite(number) && number > 0 ? number : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function normalizeAsset(input = {}) {
|
|
35
|
+
const mimeFormat = input.mimeType?.split("/").pop();
|
|
36
|
+
const format = normalizeFormat(input.format || input.extension || mimeFormat);
|
|
37
|
+
const widthPx = numberOrNull(input.widthPx || input.width);
|
|
38
|
+
const heightPx = numberOrNull(input.heightPx || input.height);
|
|
39
|
+
const contentWidthPx =
|
|
40
|
+
numberOrNull(input.contentWidthPx || input.trimmedWidthPx) || widthPx;
|
|
41
|
+
const contentHeightPx =
|
|
42
|
+
numberOrNull(input.contentHeightPx || input.trimmedHeightPx) || heightPx;
|
|
43
|
+
|
|
44
|
+
return Object.freeze({
|
|
45
|
+
...input,
|
|
46
|
+
format,
|
|
47
|
+
mediaKind: input.mediaKind || mediaKindForFormat(format),
|
|
48
|
+
widthPx,
|
|
49
|
+
heightPx,
|
|
50
|
+
contentWidthPx,
|
|
51
|
+
contentHeightPx,
|
|
52
|
+
bytes: numberOrNull(input.bytes || input.sizeBytes),
|
|
53
|
+
colorSpace: input.colorSpace ? String(input.colorSpace).toLowerCase() : null,
|
|
54
|
+
colorMode: input.colorMode ? String(input.colorMode).toLowerCase() : null,
|
|
55
|
+
hasAlpha: typeof input.hasAlpha === "boolean" ? input.hasAlpha : null,
|
|
56
|
+
transparentBorderDetected: input.transparentBorderDetected === true,
|
|
57
|
+
isAlphaTrimmed: input.isAlphaTrimmed === true,
|
|
58
|
+
hasGradients: input.hasGradients === true,
|
|
59
|
+
hasOpenPaths: input.hasOpenPaths === true,
|
|
60
|
+
hasLiveText: input.hasLiveText === true,
|
|
61
|
+
hasExplicitViewBox:
|
|
62
|
+
typeof input.hasExplicitViewBox === "boolean" ? input.hasExplicitViewBox : null,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function targetGeometry(profile, target = {}) {
|
|
67
|
+
const widthIn = numberOrNull(
|
|
68
|
+
target.placementWidthIn ||
|
|
69
|
+
target.printWidthIn ||
|
|
70
|
+
profile.preferredPrintWidthIn,
|
|
71
|
+
);
|
|
72
|
+
const heightIn = numberOrNull(
|
|
73
|
+
target.placementHeightIn ||
|
|
74
|
+
target.printHeightIn ||
|
|
75
|
+
profile.preferredPrintHeightIn,
|
|
76
|
+
);
|
|
77
|
+
return Object.freeze({ widthIn, heightIn });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function calculateEffectivePpi(assetInput, profileInput, target = {}) {
|
|
81
|
+
const asset = normalizeAsset(assetInput);
|
|
82
|
+
const profile = normalizeManufacturingProfile(profileInput);
|
|
83
|
+
if (
|
|
84
|
+
asset.mediaKind !== "raster" ||
|
|
85
|
+
!asset.contentWidthPx ||
|
|
86
|
+
!asset.contentHeightPx
|
|
87
|
+
) {
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
effectivePpi: null,
|
|
90
|
+
widthPpi: null,
|
|
91
|
+
heightPpi: null,
|
|
92
|
+
widthIn: null,
|
|
93
|
+
heightIn: null,
|
|
94
|
+
basis: null,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const { widthIn, heightIn } = targetGeometry(profile, target);
|
|
99
|
+
const widthPpi = widthIn ? asset.contentWidthPx / widthIn : null;
|
|
100
|
+
const heightPpi = heightIn ? asset.contentHeightPx / heightIn : null;
|
|
101
|
+
const samples = [widthPpi, heightPpi].filter((value) => value != null);
|
|
102
|
+
const effectivePpi = samples.length ? Math.min(...samples) : null;
|
|
103
|
+
const basis =
|
|
104
|
+
asset.contentWidthPx !== asset.widthPx ||
|
|
105
|
+
asset.contentHeightPx !== asset.heightPx
|
|
106
|
+
? "content_bounds"
|
|
107
|
+
: "pixel_bounds";
|
|
108
|
+
|
|
109
|
+
return Object.freeze({
|
|
110
|
+
effectivePpi,
|
|
111
|
+
widthPpi,
|
|
112
|
+
heightPpi,
|
|
113
|
+
widthIn,
|
|
114
|
+
heightIn,
|
|
115
|
+
basis,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function resolutionQuality(profile, ppi) {
|
|
120
|
+
if (ppi == null || profile.resolution.readyPpi == null) {
|
|
121
|
+
return Object.freeze({
|
|
122
|
+
band: "unknown",
|
|
123
|
+
readyPpi: profile.resolution.readyPpi,
|
|
124
|
+
minimumPpi: profile.resolution.minimumPpi,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (ppi >= profile.resolution.readyPpi) {
|
|
129
|
+
return Object.freeze({
|
|
130
|
+
band: "ready",
|
|
131
|
+
readyPpi: profile.resolution.readyPpi,
|
|
132
|
+
minimumPpi: profile.resolution.minimumPpi,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (
|
|
137
|
+
profile.resolution.minimumPpi != null &&
|
|
138
|
+
ppi >= profile.resolution.minimumPpi
|
|
139
|
+
) {
|
|
140
|
+
return Object.freeze({
|
|
141
|
+
band: "warning",
|
|
142
|
+
readyPpi: profile.resolution.readyPpi,
|
|
143
|
+
minimumPpi: profile.resolution.minimumPpi,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return Object.freeze({
|
|
148
|
+
band: "fail",
|
|
149
|
+
readyPpi: profile.resolution.readyPpi,
|
|
150
|
+
minimumPpi: profile.resolution.minimumPpi,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function evaluateManufacturingCompatibility(
|
|
155
|
+
assetInput,
|
|
156
|
+
profileInput,
|
|
157
|
+
target = {},
|
|
158
|
+
) {
|
|
159
|
+
const asset = normalizeAsset(assetInput);
|
|
160
|
+
const profile = normalizeManufacturingProfile(profileInput);
|
|
161
|
+
const issues = [];
|
|
162
|
+
|
|
163
|
+
if (!asset.format || asset.mediaKind === "unknown") {
|
|
164
|
+
addIssue(
|
|
165
|
+
issues,
|
|
166
|
+
COMPATIBILITY_STATUS.UNSUPPORTED,
|
|
167
|
+
"unknown_source_format",
|
|
168
|
+
"The source format cannot be classified safely.",
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const canAutoVectorize =
|
|
173
|
+
asset.mediaKind === "raster" &&
|
|
174
|
+
profile.allowVector &&
|
|
175
|
+
profile.vectorization.enabled;
|
|
176
|
+
|
|
177
|
+
if (asset.mediaKind === "raster" && !profile.allowRaster) {
|
|
178
|
+
if (canAutoVectorize) {
|
|
179
|
+
addIssue(
|
|
180
|
+
issues,
|
|
181
|
+
COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
|
|
182
|
+
"raster_requires_vectorization",
|
|
183
|
+
"Build and verify a process-specific vector derivative before production.",
|
|
184
|
+
"vectorize_monochrome",
|
|
185
|
+
{
|
|
186
|
+
preferredTracer: profile.vectorization.preferredTracer,
|
|
187
|
+
outputFormat: profile.vectorization.outputFormat,
|
|
188
|
+
},
|
|
189
|
+
);
|
|
190
|
+
} else {
|
|
191
|
+
addIssue(
|
|
192
|
+
issues,
|
|
193
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
194
|
+
"raster_not_allowed",
|
|
195
|
+
"This manufacturing profile requires a non-raster production variant.",
|
|
196
|
+
"build_vector_or_process_specific_variant",
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (asset.mediaKind === "vector" && !profile.allowVector) {
|
|
202
|
+
if (profile.allowRaster) {
|
|
203
|
+
addIssue(
|
|
204
|
+
issues,
|
|
205
|
+
COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
|
|
206
|
+
"vector_requires_rasterization",
|
|
207
|
+
`Rasterize the vector master to ${profile.format}.`,
|
|
208
|
+
`rasterize:${profile.format}`,
|
|
209
|
+
);
|
|
210
|
+
} else {
|
|
211
|
+
addIssue(
|
|
212
|
+
issues,
|
|
213
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
214
|
+
"vector_not_allowed",
|
|
215
|
+
"This manufacturing profile does not accept the source media kind.",
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (asset.format && profile.format && asset.format !== profile.format) {
|
|
221
|
+
const targetKind = mediaKindForFormat(profile.format);
|
|
222
|
+
const conversionAllowed =
|
|
223
|
+
(targetKind === "raster" &&
|
|
224
|
+
["raster", "vector"].includes(asset.mediaKind)) ||
|
|
225
|
+
(targetKind === "vector" &&
|
|
226
|
+
(asset.mediaKind === "vector" || canAutoVectorize));
|
|
227
|
+
|
|
228
|
+
addIssue(
|
|
229
|
+
issues,
|
|
230
|
+
conversionAllowed
|
|
231
|
+
? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
|
|
232
|
+
: COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
233
|
+
"format_mismatch",
|
|
234
|
+
`Production format is ${profile.format}; source is ${asset.format}.`,
|
|
235
|
+
conversionAllowed
|
|
236
|
+
? canAutoVectorize && targetKind === "vector"
|
|
237
|
+
? "vectorize_monochrome"
|
|
238
|
+
: `convert:${profile.format}`
|
|
239
|
+
: "build_process_specific_variant",
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (
|
|
244
|
+
asset.mediaKind === "raster" &&
|
|
245
|
+
asset.transparentBorderDetected &&
|
|
246
|
+
!asset.isAlphaTrimmed
|
|
247
|
+
) {
|
|
248
|
+
addIssue(
|
|
249
|
+
issues,
|
|
250
|
+
profile.autoNormalize.trimAlpha
|
|
251
|
+
? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
|
|
252
|
+
: COMPATIBILITY_STATUS.READY_WITH_WARNING,
|
|
253
|
+
"transparent_border_detected",
|
|
254
|
+
"Transparent outer pixels change the visible-artwork geometry.",
|
|
255
|
+
profile.autoNormalize.trimAlpha ? "trim_alpha" : null,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (
|
|
260
|
+
profile.colorSpace &&
|
|
261
|
+
asset.colorSpace &&
|
|
262
|
+
asset.colorSpace !== profile.colorSpace
|
|
263
|
+
) {
|
|
264
|
+
addIssue(
|
|
265
|
+
issues,
|
|
266
|
+
profile.autoNormalize.colorSpace
|
|
267
|
+
? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
|
|
268
|
+
: COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
269
|
+
"color_space_mismatch",
|
|
270
|
+
`Convert ${asset.colorSpace} to ${profile.colorSpace}.`,
|
|
271
|
+
profile.autoNormalize.colorSpace
|
|
272
|
+
? `normalize_color_space:${profile.colorSpace}`
|
|
273
|
+
: "replace_or_convert_color_space",
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (profile.colorMode === "monochrome" && asset.colorMode !== "monochrome") {
|
|
278
|
+
addIssue(
|
|
279
|
+
issues,
|
|
280
|
+
canAutoVectorize || asset.mediaKind === "vector"
|
|
281
|
+
? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
|
|
282
|
+
: COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
283
|
+
"monochrome_required",
|
|
284
|
+
"Create a monochrome production derivative.",
|
|
285
|
+
canAutoVectorize ? "vectorize_monochrome" : "convert_monochrome",
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (!profile.allowGradients && asset.mediaKind === "vector" && asset.hasGradients) {
|
|
290
|
+
addIssue(
|
|
291
|
+
issues,
|
|
292
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
293
|
+
"gradients_not_allowed",
|
|
294
|
+
"Gradients must be simplified for this manufacturing process.",
|
|
295
|
+
"simplify_gradients",
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (
|
|
300
|
+
profile.requireClosedPaths &&
|
|
301
|
+
asset.mediaKind === "vector" &&
|
|
302
|
+
asset.hasOpenPaths
|
|
303
|
+
) {
|
|
304
|
+
addIssue(
|
|
305
|
+
issues,
|
|
306
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
307
|
+
"closed_paths_required",
|
|
308
|
+
"Open vector paths must be closed before production.",
|
|
309
|
+
"close_paths",
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (
|
|
314
|
+
profile.requireViewBox &&
|
|
315
|
+
asset.mediaKind === "vector" &&
|
|
316
|
+
asset.hasExplicitViewBox === false
|
|
317
|
+
) {
|
|
318
|
+
addIssue(
|
|
319
|
+
issues,
|
|
320
|
+
profile.autoNormalize.svgOptimize
|
|
321
|
+
? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
|
|
322
|
+
: COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
323
|
+
"viewbox_required",
|
|
324
|
+
"SVG production artwork requires an explicit viewBox.",
|
|
325
|
+
profile.autoNormalize.svgOptimize ? "normalize_svg" : "repair_svg_viewbox",
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (
|
|
330
|
+
profile.outlineText &&
|
|
331
|
+
asset.mediaKind === "vector" &&
|
|
332
|
+
asset.hasLiveText
|
|
333
|
+
) {
|
|
334
|
+
addIssue(
|
|
335
|
+
issues,
|
|
336
|
+
profile.autoNormalize.outlineText
|
|
337
|
+
? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
|
|
338
|
+
: COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
339
|
+
"outline_text_required",
|
|
340
|
+
"Convert live text to vector outlines.",
|
|
341
|
+
profile.autoNormalize.outlineText ? "outline_text" : "outline_text_manually",
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (
|
|
346
|
+
profile.requireAlpha &&
|
|
347
|
+
asset.mediaKind === "raster" &&
|
|
348
|
+
asset.hasAlpha === false
|
|
349
|
+
) {
|
|
350
|
+
addIssue(
|
|
351
|
+
issues,
|
|
352
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
353
|
+
"alpha_required",
|
|
354
|
+
"This production profile requires transparent artwork.",
|
|
355
|
+
"build_transparent_variant",
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const resolution = calculateEffectivePpi(asset, profile, target);
|
|
360
|
+
const quality = resolutionQuality(profile, resolution.effectivePpi);
|
|
361
|
+
|
|
362
|
+
if (quality.band === "warning") {
|
|
363
|
+
addIssue(
|
|
364
|
+
issues,
|
|
365
|
+
COMPATIBILITY_STATUS.READY_WITH_WARNING,
|
|
366
|
+
"soft_resolution",
|
|
367
|
+
`Effective resolution is ${Math.round(
|
|
368
|
+
resolution.effectivePpi,
|
|
369
|
+
)} PPI at the current physical placement; target is ${Math.round(
|
|
370
|
+
quality.readyPpi,
|
|
371
|
+
)} PPI.`,
|
|
372
|
+
null,
|
|
373
|
+
{
|
|
374
|
+
effectivePpi: resolution.effectivePpi,
|
|
375
|
+
readyPpi: quality.readyPpi,
|
|
376
|
+
minimumPpi: quality.minimumPpi,
|
|
377
|
+
},
|
|
378
|
+
);
|
|
379
|
+
} else if (quality.band === "fail") {
|
|
380
|
+
addIssue(
|
|
381
|
+
issues,
|
|
382
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
383
|
+
"insufficient_resolution",
|
|
384
|
+
`Effective resolution is ${Math.round(
|
|
385
|
+
resolution.effectivePpi,
|
|
386
|
+
)} PPI at the current physical placement; minimum is ${Math.round(
|
|
387
|
+
quality.minimumPpi || quality.readyPpi,
|
|
388
|
+
)} PPI.`,
|
|
389
|
+
"replace_with_higher_resolution_master",
|
|
390
|
+
{
|
|
391
|
+
effectivePpi: resolution.effectivePpi,
|
|
392
|
+
readyPpi: quality.readyPpi,
|
|
393
|
+
minimumPpi: quality.minimumPpi,
|
|
394
|
+
},
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (profile.maxBytes && asset.bytes && asset.bytes > profile.maxBytes) {
|
|
399
|
+
addIssue(
|
|
400
|
+
issues,
|
|
401
|
+
COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
|
|
402
|
+
"file_too_large",
|
|
403
|
+
`Source exceeds the ${profile.maxBytes}-byte profile limit.`,
|
|
404
|
+
"lossless_optimize",
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
let status = issues.reduce(
|
|
409
|
+
(current, issue) =>
|
|
410
|
+
severity[issue.status] > severity[current] ? issue.status : current,
|
|
411
|
+
COMPATIBILITY_STATUS.READY,
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
if (
|
|
415
|
+
![
|
|
416
|
+
COMPATIBILITY_STATUS.UNSUPPORTED,
|
|
417
|
+
COMPATIBILITY_STATUS.NEEDS_VARIANT,
|
|
418
|
+
].includes(status) &&
|
|
419
|
+
profile.handoff?.status ===
|
|
420
|
+
COMPATIBILITY_STATUS.PREPARED_FOR_DIGITIZATION
|
|
421
|
+
) {
|
|
422
|
+
status = COMPATIBILITY_STATUS.PREPARED_FOR_DIGITIZATION;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const requirementsVerified = profile.source?.verified !== false;
|
|
426
|
+
const nonBlocking =
|
|
427
|
+
status === COMPATIBILITY_STATUS.READY ||
|
|
428
|
+
status === COMPATIBILITY_STATUS.READY_WITH_WARNING;
|
|
429
|
+
|
|
430
|
+
return Object.freeze({
|
|
431
|
+
profileId: profile.id,
|
|
432
|
+
manufacturer: profile.manufacturer,
|
|
433
|
+
process: profile.process,
|
|
434
|
+
status,
|
|
435
|
+
requirementsVerified,
|
|
436
|
+
productionReady: nonBlocking && requirementsVerified,
|
|
437
|
+
transformReady: status === COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
|
|
438
|
+
effectivePpi:
|
|
439
|
+
resolution.effectivePpi == null
|
|
440
|
+
? null
|
|
441
|
+
: Math.round(resolution.effectivePpi * 10) / 10,
|
|
442
|
+
resolution: Object.freeze({
|
|
443
|
+
band: quality.band,
|
|
444
|
+
basis: resolution.basis,
|
|
445
|
+
widthPpi:
|
|
446
|
+
resolution.widthPpi == null
|
|
447
|
+
? null
|
|
448
|
+
: Math.round(resolution.widthPpi * 10) / 10,
|
|
449
|
+
heightPpi:
|
|
450
|
+
resolution.heightPpi == null
|
|
451
|
+
? null
|
|
452
|
+
: Math.round(resolution.heightPpi * 10) / 10,
|
|
453
|
+
readyPpi: quality.readyPpi,
|
|
454
|
+
minimumPpi: quality.minimumPpi,
|
|
455
|
+
}),
|
|
456
|
+
target: Object.freeze({
|
|
457
|
+
format: profile.format,
|
|
458
|
+
ppi: profile.ppi,
|
|
459
|
+
printWidthIn: resolution.widthIn,
|
|
460
|
+
printHeightIn: resolution.heightIn,
|
|
461
|
+
}),
|
|
462
|
+
issues: Object.freeze(issues),
|
|
463
|
+
actions: Object.freeze([
|
|
464
|
+
...new Set(issues.map((issue) => issue.action).filter(Boolean)),
|
|
465
|
+
]),
|
|
466
|
+
handoff: profile.handoff,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export function evaluateCompatibleProducts(asset, products, registry) {
|
|
471
|
+
return products.map((product) => {
|
|
472
|
+
const profile =
|
|
473
|
+
(product.profileId && registry.get(product.profileId)) ||
|
|
474
|
+
registry.select(product.profileContext || product);
|
|
475
|
+
if (!profile) {
|
|
476
|
+
return Object.freeze({
|
|
477
|
+
...product,
|
|
478
|
+
compatibility: {
|
|
479
|
+
status: COMPATIBILITY_STATUS.UNSUPPORTED,
|
|
480
|
+
productionReady: false,
|
|
481
|
+
issues: [
|
|
482
|
+
{
|
|
483
|
+
code: "profile_not_found",
|
|
484
|
+
message: "No manufacturing profile matched this product.",
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
actions: [],
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return Object.freeze({
|
|
492
|
+
...product,
|
|
493
|
+
profileId: profile.id,
|
|
494
|
+
compatibility: evaluateManufacturingCompatibility(
|
|
495
|
+
asset,
|
|
496
|
+
profile,
|
|
497
|
+
product.target || product,
|
|
498
|
+
),
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { evaluateManufacturingCompatibility } from "./compatibility.js";
|
|
2
|
+
import { normalizeManufacturingProfile } from "./profile.js";
|
|
3
|
+
|
|
4
|
+
export const DERIVATIVE_ROLE = Object.freeze({
|
|
5
|
+
ORIGINAL: "original/master",
|
|
6
|
+
MANUFACTURING: "manufacturing",
|
|
7
|
+
STOREFRONT: "storefront/gallery",
|
|
8
|
+
THUMBNAIL: "thumbnail",
|
|
9
|
+
SOCIAL: "social",
|
|
10
|
+
MOCKUP: "mockup",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export function planMediaDerivatives({
|
|
14
|
+
asset,
|
|
15
|
+
profile,
|
|
16
|
+
target = {},
|
|
17
|
+
storefrontFormat = "webp",
|
|
18
|
+
thumbnailFormat = "webp",
|
|
19
|
+
socialFormat = "jpg",
|
|
20
|
+
mockupFormat = "webp",
|
|
21
|
+
} = {}) {
|
|
22
|
+
const normalizedProfile = normalizeManufacturingProfile(profile);
|
|
23
|
+
const compatibility = evaluateManufacturingCompatibility(asset, normalizedProfile, target);
|
|
24
|
+
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
source: Object.freeze({
|
|
27
|
+
role: DERIVATIVE_ROLE.ORIGINAL,
|
|
28
|
+
preserve: true,
|
|
29
|
+
immutableAuthority: true,
|
|
30
|
+
format: asset?.format || null,
|
|
31
|
+
}),
|
|
32
|
+
manufacturing: Object.freeze({
|
|
33
|
+
role: DERIVATIVE_ROLE.MANUFACTURING,
|
|
34
|
+
preserve: true,
|
|
35
|
+
derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
|
|
36
|
+
format: normalizedProfile.format,
|
|
37
|
+
profileId: normalizedProfile.id,
|
|
38
|
+
compatibility,
|
|
39
|
+
mustNotUseStorefrontDerivative: true,
|
|
40
|
+
}),
|
|
41
|
+
storefront: Object.freeze({
|
|
42
|
+
role: DERIVATIVE_ROLE.STOREFRONT,
|
|
43
|
+
preserve: false,
|
|
44
|
+
derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
|
|
45
|
+
format: storefrontFormat,
|
|
46
|
+
optimizeFor: "delivery",
|
|
47
|
+
}),
|
|
48
|
+
thumbnail: Object.freeze({
|
|
49
|
+
role: DERIVATIVE_ROLE.THUMBNAIL,
|
|
50
|
+
preserve: false,
|
|
51
|
+
derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
|
|
52
|
+
format: thumbnailFormat,
|
|
53
|
+
optimizeFor: "small-ui",
|
|
54
|
+
}),
|
|
55
|
+
social: Object.freeze({
|
|
56
|
+
role: DERIVATIVE_ROLE.SOCIAL,
|
|
57
|
+
preserve: false,
|
|
58
|
+
derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
|
|
59
|
+
format: socialFormat,
|
|
60
|
+
optimizeFor: "social",
|
|
61
|
+
}),
|
|
62
|
+
mockup: Object.freeze({
|
|
63
|
+
role: DERIVATIVE_ROLE.MOCKUP,
|
|
64
|
+
preserve: false,
|
|
65
|
+
derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
|
|
66
|
+
format: mockupFormat,
|
|
67
|
+
optimizeFor: "preview",
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function buildMerchPlan({ design, products = [], registry }) {
|
|
73
|
+
if (!design?.asset) throw new TypeError("design.asset is required");
|
|
74
|
+
if (!registry?.get || !registry?.select) {
|
|
75
|
+
throw new TypeError("a manufacturing profile registry is required");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const targets = products.map((product) => {
|
|
79
|
+
const profile =
|
|
80
|
+
(product.profileId && registry.get(product.profileId)) ||
|
|
81
|
+
registry.select(product.profileContext || product);
|
|
82
|
+
|
|
83
|
+
if (!profile) {
|
|
84
|
+
return Object.freeze({
|
|
85
|
+
id: product.id,
|
|
86
|
+
name: product.name || product.id,
|
|
87
|
+
profileId: null,
|
|
88
|
+
status: "unsupported",
|
|
89
|
+
reason: "No manufacturing profile matched.",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const derivatives = planMediaDerivatives({
|
|
94
|
+
asset: design.asset,
|
|
95
|
+
profile,
|
|
96
|
+
target: product.target || product,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return Object.freeze({
|
|
100
|
+
...product,
|
|
101
|
+
profileId: profile.id,
|
|
102
|
+
status: derivatives.manufacturing.compatibility.status,
|
|
103
|
+
derivatives,
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return Object.freeze({
|
|
108
|
+
schemaVersion: "agentsam.merch-plan.v1",
|
|
109
|
+
design: Object.freeze({ ...design }),
|
|
110
|
+
targets: Object.freeze(targets),
|
|
111
|
+
});
|
|
112
|
+
}
|