UNPKG

everything-dev

Version:

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

1 lines • 2.14 kB
{"version":3,"file":"constructors.mjs","names":[],"sources":["../../src/descriptor/constructors.ts"],"sourcesContent":["import type {\n ApiInput,\n ApiRef,\n AppDescriptor,\n AppInput,\n AttachmentInput,\n AttachmentRef,\n UiInput,\n UiRef,\n} from \"./schema\";\nimport { ApiRefSchema, AppDescriptorSchema, AttachmentRefSchema, UiRefSchema } from \"./schema\";\n\n/**\n * The authored App — returns a pure, Zod-validated, serializable descriptor.\n * Constructors never execute app code (the descriptor IS the deployment plan);\n * resolution and deployment consume it as data.\n */\nexport function App(input: AppInput): AppDescriptor {\n return AppDescriptorSchema.parse(input);\n}\n\n/** The app.api slot. */\nexport function API(input: ApiInput): ApiRef {\n return ApiRefSchema.parse(input);\n}\n\n/** The app.ui slot. */\nexport function UI(input: UiInput): UiRef {\n return UiRefSchema.parse(input);\n}\n\n/**\n * Attach another App — by local workspace path (`Plugin(\"auth\").path(\"plugins/auth\")`)\n * or by published module reference (`Plugin(\"auth\").extends(\"bos://…\")`).\n * The attachment's `name` (the plugin's package name, e.g.\n * `@everything-dev/auth-plugin`) may differ from the registry key; pass it\n * through `extra` to override.\n */\nexport function Plugin<K extends string>(\n name: K,\n): {\n path: (dir: string, extra?: Omit<AttachmentInput, \"path\">) => AttachmentRef;\n extends: (ref: string, extra?: Omit<AttachmentInput, \"extends\">) => AttachmentRef;\n} {\n return {\n path: (dir, extra) => AttachmentRefSchema.parse({ name, ...extra, path: dir }),\n extends: (ref, extra) => AttachmentRefSchema.parse({ name, ...extra, extends: ref }),\n };\n}\nexport { applyDevOverlay } from \"./resolve\";\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,IAAI,OAAgC;CAClD,OAAO,oBAAoB,MAAM,KAAK;AACxC;;AAGA,SAAgB,IAAI,OAAyB;CAC3C,OAAO,aAAa,MAAM,KAAK;AACjC;;AAGA,SAAgB,GAAG,OAAuB;CACxC,OAAO,YAAY,MAAM,KAAK;AAChC;;;;;;;;AASA,SAAgB,OACd,MAIA;CACA,OAAO;EACL,OAAO,KAAK,UAAU,oBAAoB,MAAM;GAAE;GAAM,GAAG;GAAO,MAAM;EAAI,CAAC;EAC7E,UAAU,KAAK,UAAU,oBAAoB,MAAM;GAAE;GAAM,GAAG;GAAO,SAAS;EAAI,CAAC;CACrF;AACF"}