UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

1 lines • 6.79 kB
{"version":3,"file":"platform.mjs","names":[],"sources":["../../../src/services/deploy/platform.ts"],"sourcesContent":["import { CORE_UI_DEPLOY_FIELDS } from \"every-plugin/build/ui\";\nimport type { DeployResultEntry } from \"./integrity\";\n\n/**\n * Image-native deploy entries (plan 043): the runtime image serves its own\n * staged artifacts at its own origin — the publish writes the deterministic\n * URLs, nothing is uploaded. Integrity is omitted: the published URL carries\n * the bytes' identity via the image build itself.\n */\nexport function platformUrlDeployEntries(input: {\n origin: string;\n account: string;\n gateway: string;\n key: string;\n kind: \"app\" | \"plugin\";\n integrity?: string;\n ssrIntegrity?: string;\n /** the workspace's uploaded version manifest: filename (relative to the\n * bundle base) + its own SRI — written as the remote's `digest` */\n digest?: { file: string; integrity: string };\n}): DeployResultEntry[] {\n const { origin, account, gateway, key, kind, integrity, ssrIntegrity, digest } = input;\n const section = kind === \"app\" ? \"app\" : \"plugins\";\n const base = `${origin.replace(/\\/$/, \"\")}/bundles/${account}/${gateway}/${key}/`;\n const entries: DeployResultEntry[] = [\n {\n url: base,\n ...(digest\n ? {\n value: digest.file,\n valueField: `${section}.${key}.digest.manifest`,\n integrity: digest.integrity,\n integrityField: `${section}.${key}.digest.integrity`,\n // the remote's identity is the digest — a stale direct entry\n // SRI, retired flat manifest pointer, or the pre-cutover `pin`\n // stamp must not linger\n removeFields: [\n `${section}.${key}.integrity`,\n `${section}.${key}.manifest`,\n `${section}.${key}.pin.manifest`,\n `${section}.${key}.pin.integrity`,\n ],\n }\n : {\n integrity,\n integrityField: `${section}.${key}.integrity`,\n removeFields: [\n `${section}.${key}.manifest`,\n `${section}.${key}.pin.manifest`,\n `${section}.${key}.pin.integrity`,\n ],\n }),\n urlField: `${section}.${key}.production`,\n },\n ];\n\n if (kind === \"app\" && key === \"ui\") {\n entries.push({\n url: `${base}ssr/`,\n integrity: ssrIntegrity,\n urlField: CORE_UI_DEPLOY_FIELDS.ssrUrlField ?? \"\",\n integrityField: CORE_UI_DEPLOY_FIELDS.ssrIntegrityField ?? \"\",\n });\n }\n\n return entries;\n}\n\n/**\n * Folder-form plugin ui deploy entries: the plugin's ui surface builds to\n * `<plugin>/ui/dist` (web remoteEntry + ssr container) and uploads as its own\n * bundle key (`<key>-ui`), pinning `<section>.<key>.ui.*` in bos.config.json.\n * Without these entries a deployed plugin ui resolves with no production URL\n * and the host cannot compose (or even address) its routes.\n */\nexport function pluginUiUrlDeployEntries(input: {\n origin: string;\n account: string;\n gateway: string;\n key: string;\n kind: \"app\" | \"plugin\";\n integrity?: string;\n ssrIntegrity?: string;\n /** the uploaded version manifest: filename + its own SRI — written as the\n * ui remote's `digest` */\n digest?: { file: string; integrity: string };\n /** The built MF container name — remote boots need it pinned in the config. */\n name?: string;\n}): DeployResultEntry[] {\n const { origin, account, gateway, key, kind, integrity, ssrIntegrity, digest, name } = input;\n const section = kind === \"app\" ? \"app\" : \"plugins\";\n const base = `${origin.replace(/\\/$/, \"\")}/bundles/${account}/${gateway}/${key}-ui/`;\n const entries: DeployResultEntry[] = [\n {\n url: base,\n ...(digest\n ? {\n value: digest.file,\n valueField: `${section}.${key}.ui.digest.manifest`,\n integrity: digest.integrity,\n integrityField: `${section}.${key}.ui.digest.integrity`,\n removeFields: [\n `${section}.${key}.ui.integrity`,\n `${section}.${key}.ui.manifest`,\n `${section}.${key}.ui.pin.manifest`,\n `${section}.${key}.ui.pin.integrity`,\n ],\n }\n : {\n integrity,\n integrityField: `${section}.${key}.ui.integrity`,\n removeFields: [\n `${section}.${key}.ui.manifest`,\n `${section}.${key}.ui.pin.manifest`,\n `${section}.${key}.ui.pin.integrity`,\n ],\n }),\n urlField: `${section}.${key}.ui.production`,\n },\n ];\n if (name) {\n entries.push({\n url: base,\n urlField: `${section}.${key}.ui.production`,\n value: name,\n valueField: `${section}.${key}.ui.name`,\n });\n }\n entries.push({\n url: `${base}ssr/`,\n integrity: ssrIntegrity,\n urlField: `${section}.${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