UNPKG

everything-dev

Version:

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

1 lines • 3.55 kB
{"version":3,"file":"serialize.mjs","names":[],"sources":["../../src/descriptor/serialize.ts"],"sourcesContent":["/**\n * The authored `bos.app.ts` source emitter — the scaffold surface of the\n * descriptor module. The descriptor is pure data (`toConfigInput` and its\n * inverse live in `./resolve`), so the scaffold emits the personalized\n * descriptor as a literal inside the `App()` call; publish/sync still\n * canonicalize the resolved config to JSON for FastKV.\n *\n * Each top-level descriptor field gets a one-line doc comment from\n * `FIELD_COMMENTS`; when a field is added to the descriptor schema, add its\n * comment line in the same commit. Fields without a comment entry are\n * emitted bare.\n */\n\nimport type { BosConfigInput } from \"../types\";\nimport { configInputToDescriptor } from \"./resolve\";\n\nconst FIELD_COMMENTS: Record<string, string> = {\n extends:\n \"The base runtime this app extends — inherit the platform, override only what you change.\",\n account: \"The NEAR account this app publishes under.\",\n domain: \"The gateway: FastKV lookup key and public ingress for this runtime.\",\n title: \"Human-readable runtime title (surfaced by the UI).\",\n description: \"Human-readable runtime description.\",\n repository: \"GitHub repository tarball source used by `bos init`/`bos sync` templates.\",\n testnet: \"Testnet identity for this runtime.\",\n staging: \"Staging environment identity.\",\n starter: \"Authoring-only: the starter level this child was scaffolded with (simple | advanced).\",\n ci: \"CI settings: runtime image name, Railway service.\",\n cdn: \"CDN origin serving this runtime's built bundles.\",\n publish: \"Publish settings: signing mode (session | key | custody).\",\n host: \"Local host workspace override.\",\n api: \"Local API workspace override.\",\n ui: \"Local UI workspace override.\",\n auth: \"Auth attachment — lands in the app.auth slot (e.g. the Better-Auth + NEAR SIWN plugin).\",\n plugins:\n \"Attached plugins, keyed by registry key. `path` = local workspace, `extends` = published module.\",\n};\n\n/** The authored `bos.app.ts` source for a personalized child config. */\nexport function serializeAppDescriptorSource(input: BosConfigInput): string {\n const descriptor = configInputToDescriptor(input);\n const blocks: string[] = [];\n for (const [key, value] of Object.entries(descriptor)) {\n const comment = FIELD_COMMENTS[key];\n const body = JSON.stringify({ [key]: value }, null, 2);\n const block = [...(comment ? [` // ${comment}`] : []), ...body.split(\"\\n\").slice(1, -1)];\n blocks.push(block.join(\"\\n\"));\n }\n return `import { App } from \"everything-dev/descriptor\";\n\n// Authored app descriptor. The published config is canonicalized to JSON\n// from this file; dev-only overrides live in bos.dev.ts (never published).\nexport default App({\n${blocks.join(\",\\n\")},\n});\n`;\n}\n"],"mappings":";;;AAgBA,MAAM,iBAAyC;CAC7C,SACE;CACF,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS;CACT,IAAI;CACJ,KAAK;CACL,SAAS;CACT,MAAM;CACN,KAAK;CACL,IAAI;CACJ,MAAM;CACN,SACE;AACJ;;AAGA,SAAgB,6BAA6B,OAA+B;CAC1E,MAAM,aAAa,wBAAwB,KAAK;CAChD,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GAAG;EACrD,MAAM,UAAU,eAAe;EAC/B,MAAM,OAAO,KAAK,UAAU,GAAG,MAAM,MAAM,GAAG,MAAM,CAAC;EACrD,MAAM,QAAQ,CAAC,GAAI,UAAU,CAAC,QAAQ,SAAS,IAAI,CAAC,GAAI,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC;EACxF,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC;CAC9B;CACA,OAAO;;;;;EAKP,OAAO,KAAK,KAAK,EAAE;;;AAGrB"}