everything-dev 1.42.1 → 1.43.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.
Files changed (57) hide show
  1. package/dist/cli/prompts.cjs +2 -1
  2. package/dist/cli/prompts.cjs.map +1 -1
  3. package/dist/cli/prompts.mjs +2 -1
  4. package/dist/cli/prompts.mjs.map +1 -1
  5. package/dist/cli/upgrade.cjs +2 -15
  6. package/dist/cli/upgrade.cjs.map +1 -1
  7. package/dist/cli/upgrade.mjs +2 -15
  8. package/dist/cli/upgrade.mjs.map +1 -1
  9. package/dist/config.cjs +1 -12
  10. package/dist/config.cjs.map +1 -1
  11. package/dist/config.d.cts.map +1 -1
  12. package/dist/config.d.mts.map +1 -1
  13. package/dist/config.mjs +1 -12
  14. package/dist/config.mjs.map +1 -1
  15. package/dist/contract.d.cts +0 -60
  16. package/dist/contract.d.cts.map +1 -1
  17. package/dist/contract.d.mts +0 -60
  18. package/dist/contract.d.mts.map +1 -1
  19. package/dist/index.cjs +0 -5
  20. package/dist/index.d.cts +2 -3
  21. package/dist/index.d.mts +2 -3
  22. package/dist/index.mjs +2 -3
  23. package/dist/orchestrator.cjs +17 -4
  24. package/dist/orchestrator.cjs.map +1 -1
  25. package/dist/orchestrator.mjs +17 -4
  26. package/dist/orchestrator.mjs.map +1 -1
  27. package/dist/plugin.cjs +2 -4
  28. package/dist/plugin.cjs.map +1 -1
  29. package/dist/plugin.d.cts +0 -60
  30. package/dist/plugin.d.cts.map +1 -1
  31. package/dist/plugin.d.mts +0 -60
  32. package/dist/plugin.d.mts.map +1 -1
  33. package/dist/plugin.mjs +2 -4
  34. package/dist/plugin.mjs.map +1 -1
  35. package/dist/types.cjs +2 -21
  36. package/dist/types.cjs.map +1 -1
  37. package/dist/types.d.cts +1 -129
  38. package/dist/types.d.cts.map +1 -1
  39. package/dist/types.d.mts +1 -129
  40. package/dist/types.d.mts.map +1 -1
  41. package/dist/types.mjs +3 -20
  42. package/dist/types.mjs.map +1 -1
  43. package/package.json +1 -1
  44. package/skills/api-and-auth/SKILL.md +355 -0
  45. package/skills/api-and-auth/references/generated-types.md +14 -0
  46. package/skills/api-and-auth/references/middleware.md +38 -0
  47. package/skills/cli-reference/SKILL.md +249 -0
  48. package/skills/plugin-development/SKILL.md +470 -0
  49. package/skills/ui-integration/SKILL.md +382 -0
  50. package/dist/sidebar.cjs +0 -116
  51. package/dist/sidebar.cjs.map +0 -1
  52. package/dist/sidebar.d.cts +0 -8
  53. package/dist/sidebar.d.cts.map +0 -1
  54. package/dist/sidebar.d.mts +0 -8
  55. package/dist/sidebar.d.mts.map +0 -1
  56. package/dist/sidebar.mjs +0 -114
  57. package/dist/sidebar.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import * as z from \"zod\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport interface JsonObject {\n [key: string]: JsonValue;\n}\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\n\nexport const JsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(JsonValueSchema),\n z.record(z.string(), JsonValueSchema),\n ]),\n);\nexport const JsonObjectSchema = z.record(z.string(), JsonValueSchema);\n\nexport const ExtendsSchema = z.union([\n z.string(),\n z.object({\n development: z.string().optional(),\n production: z.string().optional(),\n staging: z.string().optional(),\n }),\n]);\nexport type Extends = z.infer<typeof ExtendsSchema>;\nexport type ExtendsConfig = Extract<Extends, Record<string, string | undefined>>;\n\nexport const SourceModeSchema = z.enum([\"local\", \"remote\"]);\nexport type SourceMode = z.infer<typeof SourceModeSchema>;\n\nexport const SharedConfigSchema = z.object({\n version: z.string(),\n requiredVersion: z.string().optional(),\n singleton: z.boolean().optional(),\n eager: z.boolean().optional(),\n strictVersion: z.boolean().optional(),\n shareScope: z.string().optional(),\n});\nexport type SharedConfig = z.infer<typeof SharedConfigSchema>;\nexport type SharedDepConfig = SharedConfig;\nexport const SharedDepConfigSchema = SharedConfigSchema;\nexport const SharedDepMapSchema = z.record(z.string(), SharedConfigSchema);\n\nexport const FederationEntrySchema = z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n integrity: z.string().optional(),\n});\nexport type FederationEntry = z.infer<typeof FederationEntrySchema>;\n\nexport const SidebarRoleSchema = z.enum([\"anon\", \"member\", \"admin\"]);\nexport type SidebarRole = z.infer<typeof SidebarRoleSchema>;\n\nexport const SidebarItemSchema = z.object({\n icon: z.string(),\n label: z.string(),\n to: z.string().optional(),\n roleRequired: SidebarRoleSchema.optional(),\n});\nexport type SidebarItem = z.infer<typeof SidebarItemSchema>;\n\nexport const ComposableAppEntrySchema = z.object({\n extends: ExtendsSchema.optional(),\n name: z.string().optional(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n sidebar: z.array(SidebarItemSchema).optional(),\n routes: z.array(z.string()).optional(),\n shared: SharedDepMapSchema.optional(),\n});\nexport type ComposableAppEntry = z.infer<typeof ComposableAppEntrySchema>;\n\nexport const ApiPluginConfigSchema = ComposableAppEntrySchema;\nexport type ApiPluginConfig = z.infer<typeof ApiPluginConfigSchema>;\n\nexport const PluginUiConfigSchema = z.object({\n name: z.string(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n});\nexport type PluginUiConfig = z.infer<typeof PluginUiConfigSchema>;\n\nexport const BosPluginRefSchema = ComposableAppEntrySchema.extend({\n version: z.string().optional(),\n app: z.record(z.string(), z.unknown()).optional(),\n plugins: z.record(z.string(), z.unknown()).optional(),\n});\nexport type BosPluginRef = z.infer<typeof BosPluginRefSchema>;\nexport type PluginEntryValue = string | BosPluginRef;\nexport type PluginEntries = Record<string, PluginEntryValue>;\n\nconst PluginRuntimeUiSchema = z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n localPath: z.string().optional(),\n port: z.number().optional(),\n integrity: z.string().optional(),\n});\nexport type PluginRuntimeUi = z.infer<typeof PluginRuntimeUiSchema>;\n\nexport const RuntimePluginConfigSchema = z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n extendsRef: z.string().optional(),\n localPath: z.string().optional(),\n port: z.number().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n integrity: z.string().optional(),\n shared: SharedDepMapSchema.optional(),\n ui: PluginRuntimeUiSchema.optional(),\n sidebar: z.array(SidebarItemSchema).optional(),\n routes: z.array(z.string()).optional(),\n});\nexport type RuntimePluginConfig = z.infer<typeof RuntimePluginConfigSchema>;\n\nexport const UiConfigSchema = z\n .object({\n name: z.string().optional(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n ssr: z.string().optional(),\n ssrIntegrity: z.string().optional(),\n })\n .strict();\nexport type UiConfig = z.infer<typeof UiConfigSchema>;\n\nexport const HostConfigSchema = z.object({\n development: z.string(),\n production: z.string(),\n integrity: z.string().optional(),\n secrets: z.array(z.string()).optional(),\n});\nexport type HostConfig = z.infer<typeof HostConfigSchema>;\n\nexport const ClientRuntimeInfoSchema = z.object({\n accountId: z.string(),\n gatewayId: z.string(),\n runtimeBasePath: z.string(),\n title: z.string().nullable(),\n description: z.string().nullable(),\n hostUrl: z.string().nullable(),\n});\nexport type ClientRuntimeInfo = z.infer<typeof ClientRuntimeInfoSchema>;\n\nexport const RuntimeLineageSchema = z.object({\n parent: z.string().nullable(),\n root: z.string().nullable(),\n depth: z.number().int().nonnegative(),\n extendsChain: z.array(z.string()),\n});\nexport type RuntimeLineage = z.infer<typeof RuntimeLineageSchema>;\n\nexport const BosStagingSchema = z.object({\n domain: z.string(),\n});\nexport type BosStaging = z.infer<typeof BosStagingSchema>;\n\nconst BosConfigInputAppEntrySchema = z.record(z.string(), z.unknown());\nexport type BosConfigInputAppEntry = z.infer<typeof BosConfigInputAppEntrySchema>;\n\nexport const BosConfigInputSchema: z.ZodType<BosConfigInput> = z.lazy(() =>\n z.object({\n extends: ExtendsSchema.optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n testnet: z.string().optional(),\n template: z.string().optional(),\n gateway: z\n .object({\n development: z.string().optional(),\n production: z.string().optional(),\n account: z.string().optional(),\n })\n .optional(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n name: z.string().optional(),\n version: z.string().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n routes: z.array(z.string()).optional(),\n sidebar: z.array(SidebarItemSchema).optional(),\n app: z.record(z.string(), BosConfigInputAppEntrySchema).optional(),\n plugins: z.record(z.string(), z.union([z.string(), BosConfigInputSchema])).optional(),\n ci: CiConfigSchema.optional(),\n }),\n);\n\nexport interface BosConfigInput {\n extends?: string | ExtendsConfig;\n account?: string;\n domain?: string;\n title?: string;\n description?: string;\n testnet?: string;\n template?: string;\n gateway?: {\n development?: string;\n production?: string;\n account?: string;\n };\n development?: string;\n production?: string;\n integrity?: string;\n name?: string;\n version?: string;\n proxy?: string;\n variables?: JsonObject;\n secrets?: string[];\n routes?: string[];\n sidebar?: SidebarItem[];\n app?: Record<string, BosConfigInputAppEntry>;\n plugins?: Record<string, string | BosConfigInput>;\n ci?: CiConfig;\n}\n\nexport const RailwayCiSchema = z.object({\n service: z.string(),\n});\nexport type RailwayCi = z.infer<typeof RailwayCiSchema>;\n\nexport const CiConfigSchema = z.object({\n railway: RailwayCiSchema.optional(),\n});\nexport type CiConfig = z.infer<typeof CiConfigSchema>;\n\nexport const BosConfigSchema = z.object({\n account: z.string(),\n extends: ExtendsSchema.optional(),\n domain: z.string().optional(),\n title: z.string().optional(),\n description: z.string().optional(),\n testnet: z.string().optional(),\n staging: BosStagingSchema.optional(),\n repository: z.string().optional(),\n ci: CiConfigSchema.optional(),\n plugins: z.record(z.string(), z.union([z.string(), BosPluginRefSchema])).optional(),\n app: z.object({\n host: HostConfigSchema,\n ui: UiConfigSchema,\n api: ComposableAppEntrySchema,\n auth: ComposableAppEntrySchema.optional(),\n }),\n});\nexport type BosConfig = z.infer<typeof BosConfigSchema>;\n\nexport const RuntimeConfigSchema = z.object({\n env: z.enum([\"development\", \"production\", \"staging\"]),\n account: z.string(),\n domain: z.string().optional(),\n networkId: z.enum([\"mainnet\", \"testnet\"]),\n title: z.string().optional(),\n description: z.string().optional(),\n repository: z.string().optional(),\n host: FederationEntrySchema.extend({\n localPath: z.string().optional(),\n port: z.number().optional(),\n secrets: z.array(z.string()).optional(),\n remoteUrl: z.string().optional(),\n }),\n ui: FederationEntrySchema.extend({\n localPath: z.string().optional(),\n port: z.number().optional(),\n ssrUrl: z.string().optional(),\n ssrIntegrity: z.string().optional(),\n }),\n api: FederationEntrySchema.extend({\n localPath: z.string().optional(),\n port: z.number().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n shared: SharedDepMapSchema.optional(),\n }),\n auth: FederationEntrySchema.extend({\n extendsRef: z.string().optional(),\n localPath: z.string().optional(),\n port: z.number().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n sidebar: z.array(SidebarItemSchema).optional(),\n shared: SharedDepMapSchema.optional(),\n }).optional(),\n plugins: z.record(z.string(), RuntimePluginConfigSchema).optional(),\n});\nexport type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;\n\nexport const ClientRuntimeConfigSchema = z.object({\n env: z.enum([\"development\", \"production\", \"staging\"]),\n account: z.string(),\n networkId: z.enum([\"mainnet\", \"testnet\"]),\n hostUrl: z.string().optional(),\n assetsUrl: z.string(),\n apiBase: z.string(),\n rpcBase: z.string(),\n repository: z.string().optional(),\n authAvailable: z.boolean().optional(),\n runtime: ClientRuntimeInfoSchema.optional(),\n ui: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n })\n .optional(),\n api: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n })\n .optional(),\n auth: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n sidebar: z.array(SidebarItemSchema).optional(),\n })\n .optional(),\n plugins: z\n .record(\n z.string(),\n z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n ui: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n integrity: z.string().optional(),\n })\n .optional(),\n sidebar: z.array(SidebarItemSchema).optional(),\n }),\n )\n .optional(),\n});\nexport type ClientRuntimeConfig = z.infer<typeof ClientRuntimeConfigSchema>;\n"],"mappings":";;;AAQA,MAAa,kBAAwC,EAAE,WACrD,EAAE,MAAM;CACN,EAAE,QAAQ;CACV,EAAE,QAAQ;CACV,EAAE,SAAS;CACX,EAAE,MAAM;CACR,EAAE,MAAM,gBAAgB;CACxB,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB;CACtC,CAAC,CACH;AACD,MAAa,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB;AAErE,MAAa,gBAAgB,EAAE,MAAM,CACnC,EAAE,QAAQ,EACV,EAAE,OAAO;CACP,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC/B,CAAC,CACH,CAAC;AAIF,MAAa,mBAAmB,EAAE,KAAK,CAAC,SAAS,SAAS,CAAC;AAG3D,MAAa,qBAAqB,EAAE,OAAO;CACzC,SAAS,EAAE,QAAQ;CACnB,iBAAiB,EAAE,QAAQ,CAAC,UAAU;CACtC,W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S,EAAE,MAAM,kBAAkB,CAAC,UAAU;EAC/C,CAAC,CACD,UAAU;CACb,SAAS,EACN,OACC,EAAE,QAAQ,EACV,EAAE,OAAO;EACP,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,QAAQ;EACf,OAAO,EAAE,QAAQ;EACjB,WAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,WAAW,iBAAiB,UAAU;EACtC,IAAI,EACD,OAAO;GACN,MAAM,EAAE,QAAQ;GAChB,KAAK,EAAE,QAAQ;GACf,OAAO,EAAE,QAAQ;GACjB,QAAQ;GACR,WAAW,EAAE,QAAQ,CAAC,UAAU;GACjC,CAAC,CACD,UAAU;EACb,SAAS,EAAE,MAAM,kBAAkB,CAAC,UAAU;EAC/C,CAAC,CACH,CACA,UAAU;CACd,CAAC"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import * as z from \"zod\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport interface JsonObject {\n [key: string]: JsonValue;\n}\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\n\nexport const JsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(JsonValueSchema),\n z.record(z.string(), JsonValueSchema),\n ]),\n);\nexport const JsonObjectSchema = z.record(z.string(), JsonValueSchema);\n\nexport const ExtendsSchema = z.union([\n z.string(),\n z.object({\n development: z.string().optional(),\n production: z.string().optional(),\n staging: z.string().optional(),\n }),\n]);\nexport type Extends = z.infer<typeof ExtendsSchema>;\nexport type ExtendsConfig = Extract<Extends, Record<string, string | undefined>>;\n\nexport const SourceModeSchema = z.enum([\"local\", \"remote\"]);\nexport type SourceMode = z.infer<typeof SourceModeSchema>;\n\nexport const SharedConfigSchema = z.object({\n version: z.string(),\n requiredVersion: z.string().optional(),\n singleton: z.boolean().optional(),\n eager: z.boolean().optional(),\n strictVersion: z.boolean().optional(),\n shareScope: z.string().optional(),\n});\nexport type SharedConfig = z.infer<typeof SharedConfigSchema>;\nexport type SharedDepConfig = SharedConfig;\nexport const SharedDepConfigSchema = SharedConfigSchema;\nexport const SharedDepMapSchema = z.record(z.string(), SharedConfigSchema);\n\nexport const FederationEntrySchema = z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n integrity: z.string().optional(),\n});\nexport type FederationEntry = z.infer<typeof FederationEntrySchema>;\n\nexport const ComposableAppEntrySchema = z.object({\n extends: ExtendsSchema.optional(),\n name: z.string().optional(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n routes: z.array(z.string()).optional(),\n shared: SharedDepMapSchema.optional(),\n});\nexport type ComposableAppEntry = z.infer<typeof ComposableAppEntrySchema>;\n\nexport const ApiPluginConfigSchema = ComposableAppEntrySchema;\nexport type ApiPluginConfig = z.infer<typeof ApiPluginConfigSchema>;\n\nexport const PluginUiConfigSchema = z.object({\n name: z.string(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n});\nexport type PluginUiConfig = z.infer<typeof PluginUiConfigSchema>;\n\nexport const BosPluginRefSchema = ComposableAppEntrySchema.extend({\n version: z.string().optional(),\n app: z.record(z.string(), z.unknown()).optional(),\n plugins: z.record(z.string(), z.unknown()).optional(),\n});\nexport type BosPluginRef = z.infer<typeof BosPluginRefSchema>;\nexport type PluginEntryValue = string | BosPluginRef;\nexport type PluginEntries = Record<string, PluginEntryValue>;\n\nconst PluginRuntimeUiSchema = z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n localPath: z.string().optional(),\n port: z.number().optional(),\n integrity: z.string().optional(),\n});\nexport type PluginRuntimeUi = z.infer<typeof PluginRuntimeUiSchema>;\n\nexport const RuntimePluginConfigSchema = z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n extendsRef: z.string().optional(),\n localPath: z.string().optional(),\n port: z.number().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n integrity: z.string().optional(),\n shared: SharedDepMapSchema.optional(),\n ui: PluginRuntimeUiSchema.optional(),\n routes: z.array(z.string()).optional(),\n});\nexport type RuntimePluginConfig = z.infer<typeof RuntimePluginConfigSchema>;\n\nexport const UiConfigSchema = z\n .object({\n name: z.string().optional(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n ssr: z.string().optional(),\n ssrIntegrity: z.string().optional(),\n })\n .strict();\nexport type UiConfig = z.infer<typeof UiConfigSchema>;\n\nexport const HostConfigSchema = z.object({\n development: z.string(),\n production: z.string(),\n integrity: z.string().optional(),\n secrets: z.array(z.string()).optional(),\n});\nexport type HostConfig = z.infer<typeof HostConfigSchema>;\n\nexport const ClientRuntimeInfoSchema = z.object({\n accountId: z.string(),\n gatewayId: z.string(),\n runtimeBasePath: z.string(),\n title: z.string().nullable(),\n description: z.string().nullable(),\n hostUrl: z.string().nullable(),\n});\nexport type ClientRuntimeInfo = z.infer<typeof ClientRuntimeInfoSchema>;\n\nexport const RuntimeLineageSchema = z.object({\n parent: z.string().nullable(),\n root: z.string().nullable(),\n depth: z.number().int().nonnegative(),\n extendsChain: z.array(z.string()),\n});\nexport type RuntimeLineage = z.infer<typeof RuntimeLineageSchema>;\n\nexport const BosStagingSchema = z.object({\n domain: z.string(),\n});\nexport type BosStaging = z.infer<typeof BosStagingSchema>;\n\nconst BosConfigInputAppEntrySchema = z.record(z.string(), z.unknown());\nexport type BosConfigInputAppEntry = z.infer<typeof BosConfigInputAppEntrySchema>;\n\nexport const BosConfigInputSchema: z.ZodType<BosConfigInput> = z.lazy(() =>\n z.object({\n extends: ExtendsSchema.optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n testnet: z.string().optional(),\n template: z.string().optional(),\n gateway: z\n .object({\n development: z.string().optional(),\n production: z.string().optional(),\n account: z.string().optional(),\n })\n .optional(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n name: z.string().optional(),\n version: z.string().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n routes: z.array(z.string()).optional(),\n app: z.record(z.string(), BosConfigInputAppEntrySchema).optional(),\n plugins: z.record(z.string(), z.union([z.string(), BosConfigInputSchema])).optional(),\n ci: CiConfigSchema.optional(),\n }),\n);\n\nexport interface BosConfigInput {\n extends?: string | ExtendsConfig;\n account?: string;\n domain?: string;\n title?: string;\n description?: string;\n testnet?: string;\n template?: string;\n gateway?: {\n development?: string;\n production?: string;\n account?: string;\n };\n development?: string;\n production?: string;\n integrity?: string;\n name?: string;\n version?: string;\n proxy?: string;\n variables?: JsonObject;\n secrets?: string[];\n routes?: string[];\n app?: Record<string, BosConfigInputAppEntry>;\n plugins?: Record<string, string | BosConfigInput>;\n ci?: CiConfig;\n}\n\nexport const RailwayCiSchema = z.object({\n service: z.string(),\n});\nexport type RailwayCi = z.infer<typeof RailwayCiSchema>;\n\nexport const CiConfigSchema = z.object({\n railway: RailwayCiSchema.optional(),\n});\nexport type CiConfig = z.infer<typeof CiConfigSchema>;\n\nexport const BosConfigSchema = z.object({\n account: z.string(),\n extends: ExtendsSchema.optional(),\n domain: z.string().optional(),\n title: z.string().optional(),\n description: z.string().optional(),\n testnet: z.string().optional(),\n staging: BosStagingSchema.optional(),\n repository: z.string().optional(),\n ci: CiConfigSchema.optional(),\n plugins: z.record(z.string(), z.union([z.string(), BosPluginRefSchema])).optional(),\n app: z.object({\n host: HostConfigSchema,\n ui: UiConfigSchema,\n api: ComposableAppEntrySchema,\n auth: ComposableAppEntrySchema.optional(),\n }),\n});\nexport type BosConfig = z.infer<typeof BosConfigSchema>;\n\nexport const RuntimeConfigSchema = z.object({\n env: z.enum([\"development\", \"production\", \"staging\"]),\n account: z.string(),\n domain: z.string().optional(),\n networkId: z.enum([\"mainnet\", \"testnet\"]),\n title: z.string().optional(),\n description: z.string().optional(),\n repository: z.string().optional(),\n host: FederationEntrySchema.extend({\n localPath: z.string().optional(),\n port: z.number().optional(),\n secrets: z.array(z.string()).optional(),\n remoteUrl: z.string().optional(),\n }),\n ui: FederationEntrySchema.extend({\n localPath: z.string().optional(),\n port: z.number().optional(),\n ssrUrl: z.string().optional(),\n ssrIntegrity: z.string().optional(),\n }),\n api: FederationEntrySchema.extend({\n localPath: z.string().optional(),\n port: z.number().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n shared: SharedDepMapSchema.optional(),\n }),\n auth: FederationEntrySchema.extend({\n extendsRef: z.string().optional(),\n localPath: z.string().optional(),\n port: z.number().optional(),\n proxy: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n secrets: z.array(z.string()).optional(),\n shared: SharedDepMapSchema.optional(),\n }).optional(),\n plugins: z.record(z.string(), RuntimePluginConfigSchema).optional(),\n});\nexport type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;\n\nexport const ClientRuntimeConfigSchema = z.object({\n env: z.enum([\"development\", \"production\", \"staging\"]),\n account: z.string(),\n networkId: z.enum([\"mainnet\", \"testnet\"]),\n hostUrl: z.string().optional(),\n assetsUrl: z.string(),\n apiBase: z.string(),\n rpcBase: z.string(),\n repository: z.string().optional(),\n authAvailable: z.boolean().optional(),\n runtime: ClientRuntimeInfoSchema.optional(),\n ui: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n })\n .optional(),\n api: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n })\n .optional(),\n auth: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n })\n .optional(),\n plugins: z\n .record(\n z.string(),\n z.object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n integrity: z.string().optional(),\n variables: JsonObjectSchema.optional(),\n ui: z\n .object({\n name: z.string(),\n url: z.string(),\n entry: z.string(),\n source: SourceModeSchema,\n integrity: z.string().optional(),\n })\n .optional(),\n }),\n )\n .optional(),\n});\nexport type ClientRuntimeConfig = z.infer<typeof ClientRuntimeConfigSchema>;\n"],"mappings":";;;AAQA,MAAa,kBAAwC,EAAE,WACrD,EAAE,MAAM;CACN,EAAE,QAAQ;CACV,EAAE,QAAQ;CACV,EAAE,SAAS;CACX,EAAE,MAAM;CACR,EAAE,MAAM,gBAAgB;CACxB,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB;CACtC,CAAC,CACH;AACD,MAAa,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB;AAErE,MAAa,gBAAgB,EAAE,MAAM,CACnC,EAAE,QAAQ,EACV,EAAE,OAAO;CACP,aAAa,EAAE,QAAQ,CAAC,UAAU;CAClC,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC/B,CAAC,CACH,CAAC;AAIF,MAAa,mBAAmB,EAAE,KAAK,CAAC,SAAS,SAAS,CAAC;AAG3D,MAAa,qBAAqB,EAAE,OAAO;CACzC,SAAS,EAAE,QAAQ;CACnB,iBAAiB,EAAE,QAAQ,CAAC,UAAU;CACtC,WAAW,EAAE,SAAS,CAAC,UAAU;CACjC,OAAO,EAAE,SAAS,CAAC,UAAU;CAC7B,eAAe,EAAE,SAAS,CAAC,UAAU;CACrC,YAAY,EAAE,QAAQ,CAAC,UAAU;CAClC,CAAC;AAGF,MAAa,wBAAwB;AACrC,MAAa,qBAAqB,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB;AAE1E,MAAa,wBAAwB,EAAE,OAAO;CAC5C,MAAM,EAAE,QAAQ;CAChB,KAAK,EAAE,QAAQ;CACf,OAAO,EAAE,QAAQ;CACjB,QAAQ;CACR,WAAW,EAAE,QAAQ,CAA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AAQ;EACf,OAAO,EAAE,QAAQ;EACjB,WAAW,EAAE,QAAQ,CAAC,UAAU;EACjC,CAAC,CACD,UAAU;CACb,KAAK,EACF,OAAO;EACN,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,QAAQ;EACf,OAAO,EAAE,QAAQ;EACjB,WAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,WAAW,iBAAiB,UAAU;EACvC,CAAC,CACD,UAAU;CACb,MAAM,EACH,OAAO;EACN,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,QAAQ;EACf,OAAO,EAAE,QAAQ;EACjB,WAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,WAAW,iBAAiB,UAAU;EACvC,CAAC,CACD,UAAU;CACb,SAAS,EACN,OACC,EAAE,QAAQ,EACV,EAAE,OAAO;EACP,MAAM,EAAE,QAAQ;EAChB,KAAK,EAAE,QAAQ;EACf,OAAO,EAAE,QAAQ;EACjB,WAAW,EAAE,QAAQ,CAAC,UAAU;EAChC,WAAW,iBAAiB,UAAU;EACtC,IAAI,EACD,OAAO;GACN,MAAM,EAAE,QAAQ;GAChB,KAAK,EAAE,QAAQ;GACf,OAAO,EAAE,QAAQ;GACjB,QAAQ;GACR,WAAW,EAAE,QAAQ,CAAC,UAAU;GACjC,CAAC,CACD,UAAU;EACd,CAAC,CACH,CACA,UAAU;CACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everything-dev",
3
- "version": "1.42.1",
3
+ "version": "1.43.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -0,0 +1,355 @@
1
+ ---
2
+ name: api-and-auth
3
+ description: API architecture, oRPC contracts, auth middleware, plugin-client composition, session handling, and client-side auth. Use when adding API routes, creating middleware, calling other plugins in-process, or integrating auth in routes and UI.
4
+ metadata:
5
+ sources: "api/src/index.ts,api/src/contract.ts,api/src/lib/auth.ts,host/src/services/auth.ts,host/src/services/plugins.ts,host/src/program.ts,ui/src/lib/auth.ts,ui/src/lib/api.ts"
6
+ ---
7
+
8
+ # API Architecture & Auth
9
+
10
+ ## Plugin Anatomy
11
+
12
+ The API is an every-plugin registered via `createPlugin.withPlugins<PluginsClient>()`:
13
+
14
+ ```ts
15
+ export default createPlugin.withPlugins<PluginsClient>()({
16
+ variables: z.object({ /* typed config */ }),
17
+ secrets: z.object({ /* typed env vars, defaults for dev */ }),
18
+ context: z.object({ /* per-request context injected by host */ }),
19
+ contract,
20
+ initialize: (config, plugins) => Effect.promise(async () => {
21
+ return { db, upvoteService, publisher, auth, plugins };
22
+ }),
23
+ shutdown: (services) => Effect.promise(async () => { /* cleanup */ }),
24
+ createRouter: (services, builder) => ({
25
+ ping: builder.ping.handler(async () => ({ status: "ok", timestamp })),
26
+ }),
27
+ });
28
+ ```
29
+
30
+ Fields: `variables` (public config), `secrets` (private env), `context` (per-request host context), `contract` (oRPC router), `initialize` (startup, returns services), `createRouter` (maps procedures to handlers), `shutdown` (cleanup). `plugins` in `initialize` gives typed factories for all other plugins.
31
+
32
+ ## oRPC Contract Design
33
+
34
+ Defined in `api/src/contract.ts`:
35
+
36
+ ```ts
37
+ import { BAD_REQUEST, NOT_FOUND, UNAUTHORIZED } from "every-plugin/errors";
38
+ import { eventIterator, oc } from "every-plugin/orpc";
39
+ import { z } from "every-plugin/zod";
40
+
41
+ export const contract = oc.router({
42
+ ping: oc.route({ method: "GET", path: "/ping" }).output(
43
+ z.object({ status: z.literal("ok"), timestamp: z.iso.datetime() }),
44
+ ),
45
+ upvoteThing: oc
46
+ .route({ method: "POST", path: "/upvotes" })
47
+ .input(z.object({ thingId: z.string() }))
48
+ .output(z.object({ thingId: z.string(), userId: z.string(), totalCount: z.number().int().nonnegative() }))
49
+ .errors({ UNAUTHORIZED, BAD_REQUEST }),
50
+ getUserVote: oc
51
+ .route({ method: "GET", path: "/upvotes/{thingId}/me" })
52
+ .input(z.object({ thingId: z.string() }))
53
+ .output(z.object({ thingId: z.string(), hasUpvote: z.boolean() }))
54
+ .errors({ UNAUTHORIZED }),
55
+ getUpvoteFeed: oc
56
+ .route({ method: "GET", path: "/upvotes/feed" })
57
+ .input(z.object({ limit: z.number().int().min(1).max(100).optional(), cursor: z.string().optional() }))
58
+ .output(z.object({ data: z.array(/*...*/), meta: z.object({ total, hasMore, nextCursor }) })),
59
+ subscribeUpvotes: oc
60
+ .route({ method: "GET", path: "/upvotes/stream" })
61
+ .output(eventIterator(VoteEventSchema)),
62
+ });
63
+ ```
64
+
65
+ Conventions: `.errors()` declares typed errors, `{paramName}` path params match Zod input keys, `.output(eventIterator(Schema))` enables SSE streaming, export `type ContractType = typeof contract` for type generation.
66
+
67
+ ## Route Implementation
68
+
69
+ ```ts
70
+ createRouter: (services, builder) => {
71
+ const { requireAuth } = createAuthMiddleware(builder);
72
+
73
+ return {
74
+ ping: builder.ping.handler(async () => ({
75
+ status: "ok",
76
+ timestamp: new Date().toISOString(),
77
+ })),
78
+ upvoteThing: builder.upvoteThing.use(requireAuth).handler(async ({ input, context }) => {
79
+ return await services.upvoteService.upvoteThing(input.thingId, context.userId);
80
+ }),
81
+ subscribeUpvotes: builder.subscribeUpvotes.handler(async function* ({ signal, lastEventId }) {
82
+ const iterator = services.publisher.subscribe("vote", { signal, lastEventId });
83
+ for await (const event of iterator) yield event;
84
+ }),
85
+ };
86
+ };
87
+ ```
88
+
89
+ Handler receives `{ input, context, signal?, lastEventId? }`.
90
+
91
+ ## Middleware
92
+
93
+ Create auth middleware with `createAuthMiddleware(builder)` in `api/src/lib/auth.ts`. Each middleware narrows the context type through `.use()` — no non-null assertions needed.
94
+
95
+ ```ts
96
+ const { requireAuth } = createAuthMiddleware(builder);
97
+
98
+ builder.myRoute.use(requireAuth).handler(async ({ input, context }) => {
99
+ context.userId; // string — narrowed by middleware
100
+ });
101
+ ```
102
+
103
+ Available: `requireAuth`, `requireAuthOrApiKey`, `requireRole("admin")`, `requireOrganization`, `requireOrgRole("owner")`, `requireApiKey`. Apply via `.use()`:
104
+
105
+ ```ts
106
+ builder.authHealth.use(requireAuth).handler(...)
107
+ builder.adminAction.use(requireRole("admin")).handler(...)
108
+ ```
109
+
110
+ See `references/middleware.md` for the full middleware table, org metadata validation, and typed context helpers.
111
+
112
+ ## Error Handling
113
+
114
+ Use `ORPCError` from `every-plugin/errors`:
115
+
116
+ ```ts
117
+ import { ORPCError } from "every-plugin/orpc";
118
+ import { BAD_REQUEST, UNAUTHORIZED } from "every-plugin/errors";
119
+
120
+ throw new ORPCError("UNAUTHORIZED", {
121
+ message: "Authentication required",
122
+ data: { hint: "Sign in or provide an API key" },
123
+ });
124
+ ```
125
+
126
+ Declare throwable errors in the contract via `.errors({ UNAUTHORIZED, BAD_REQUEST })`. Client-side errors are intercepted by `onError` in `createRpcLink` (`ui/src/lib/api.ts`).
127
+
128
+ ## Auth Plugin Architecture
129
+
130
+ The auth plugin is an **external plugin** loaded in **Phase 0** of the host's initialization:
131
+
132
+ 1. **Phase 0** (`host/src/services/plugins.ts`): Load auth plugin, create `authClient` factory.
133
+ 2. **Phase 1**: Load all non-API plugins.
134
+ 3. **Phase 2**: Load API plugin with `pluginsClient` (includes auth + all other plugin factories).
135
+
136
+ The host mounts the auth handler at `/api/auth/*`:
137
+
138
+ ```ts
139
+ // host/src/services/auth.ts
140
+ export function registerAuthHandler(app, plugins) {
141
+ const services = getAuthServices(plugins);
142
+ if (!services) return;
143
+ app.on(["POST", "GET"], "/api/auth/*", (c) => services.handler(c.req.raw));
144
+ }
145
+ ```
146
+
147
+ ## Session Middleware
148
+
149
+ Runs on every non-auth request. Resolves the session from cookies and sets Hono request context:
150
+
151
+ ```ts
152
+ // host/src/services/auth.ts
153
+ export function createSessionMiddleware(plugins) {
154
+ return async (c, next) => {
155
+ if (c.req.path.startsWith("/api/auth/")) return next();
156
+ c.set("reqHeaders", c.req.raw.headers);
157
+
158
+ const authClient = authClientFactory({ reqHeaders });
159
+ const [session, context] = await Promise.all([
160
+ authClient.getSession(),
161
+ authClient.getContext(),
162
+ ]);
163
+
164
+ c.set("user", session?.user ?? context.user ?? null);
165
+ c.set("session", session?.session ?? null);
166
+ c.set("walletAddress", context.near.primaryAccountId ?? null);
167
+ c.set("apiKey", context.apiKey ?? null);
168
+ c.set("organizationId", context.organization?.activeOrganizationId ?? null);
169
+
170
+ await next();
171
+ };
172
+ }
173
+ ```
174
+
175
+ If resolution fails, all values are `null` — `requireAuth` routes reject with `UNAUTHORIZED`.
176
+
177
+ The context is transformed for the API plugin via `buildPluginContext()`, with the full `organization` envelope from Better Auth:
178
+
179
+ ```ts
180
+ export function buildPluginContext(c) {
181
+ return {
182
+ userId: user?.id, user: user ?? undefined,
183
+ organization: context.organization ?? undefined,
184
+ apiKey: apiKey ?? undefined,
185
+ reqHeaders: c.get("reqHeaders"),
186
+ getRawBody: c.get("getRawBody"),
187
+ };
188
+ }
189
+ ```
190
+
191
+ ## Auth in API Routes
192
+
193
+ The API plugin receives `auth` in `initialize`:
194
+
195
+ ```ts
196
+ initialize: (config, plugins) => Effect.promise(async () => {
197
+ const { auth, ...restPlugins } = plugins;
198
+ return { auth, plugins: restPlugins, ... };
199
+ })
200
+ ```
201
+
202
+ Use `getAuthClient()` for in-process calls:
203
+
204
+ ```ts
205
+ import { getAuthClient, createAuthMiddleware } from "./lib/auth";
206
+
207
+ const authClient = getAuthClient(services, { reqHeaders: context.reqHeaders });
208
+ const session = await authClient.getSession();
209
+ ```
210
+
211
+ `AuthCapableServices` requires an `auth` factory. If unavailable, `getAuthClient()` throws.
212
+
213
+ ## Auth on the Client
214
+
215
+ Create the client in `ui/src/lib/auth.ts`:
216
+
217
+ ```ts
218
+ export function createAuthClient(runtimeConfig) {
219
+ return betterAuth.createClient({
220
+ baseURL: runtimeConfig.authBaseUrl,
221
+ plugins: [siwn({ recipients, networkId }), passkey(), organization(), admin(), apiKey(), anonymous(), phone()],
222
+ });
223
+ }
224
+ ```
225
+
226
+ In route code:
227
+
228
+ ```ts
229
+ import { useAuthClient, sessionQueryOptions } from "@/app";
230
+
231
+ const authClient = useAuthClient();
232
+ ```
233
+
234
+ The `sessionQueryOptions()` helper provides standard TanStack Query config:
235
+
236
+ ```ts
237
+ const session = await queryClient.ensureQueryData(
238
+ sessionQueryOptions(authClient, context.session),
239
+ );
240
+ ```
241
+
242
+ ### Auth Route Guard
243
+
244
+ The `_authenticated.tsx` layout redirects unauthenticated users:
245
+
246
+ ```ts
247
+ export const Route = createFileRoute("/_layout/_authenticated")({
248
+ beforeLoad: async ({ context, location }) => {
249
+ const { queryClient, authClient } = context;
250
+ const session = await queryClient.ensureQueryData(
251
+ sessionQueryOptions(authClient, context.session),
252
+ );
253
+ if (!session?.user) {
254
+ throw redirect({ to: "/login", search: { redirect: location.href } });
255
+ }
256
+ return { auth: { isAuthenticated: true, user: session.user, session: session.session } };
257
+ },
258
+ component: AuthenticatedLayout,
259
+ });
260
+ ```
261
+
262
+ ## Plugin Client Composition
263
+
264
+ The host uses **two-phase loading** so API plugins can call other plugins in-process:
265
+
266
+ 1. **Phase 0**: Auth plugin → `authClient` factory
267
+ 2. **Phase 1**: All non-API plugins → `pluginsClient` map of `createClient` factories
268
+ 3. **Phase 2**: API plugin with all plugin factories merged
269
+
270
+ ```ts
271
+ // host/src/services/plugins.ts
272
+ const pluginsClient = { ...pluginClients };
273
+ if (authClient) pluginsClient.auth = authClient;
274
+ const baseApi = await loadPluginEntry(runtime, apiEntry, integrityRegistry, pluginsClient);
275
+ ```
276
+
277
+ ### Calling Plugins from API Routes
278
+
279
+ The API plugin receives `plugins` in `initialize`:
280
+
281
+ ```ts
282
+ initialize: (config, plugins) => Effect.promise(async () => {
283
+ const authClient = plugins.auth({ reqHeaders: someHeaders });
284
+ const session = await authClient.getSession();
285
+ return { auth: plugins.auth, plugins, ... };
286
+ })
287
+ ```
288
+
289
+ ### API-Owned Registry Pattern
290
+
291
+ When the API owns the durable registry and a plugin owns the semantic payload:
292
+
293
+ ```ts
294
+ const provider = thingProviders[input.pluginId];
295
+ if (!provider) {
296
+ throw new ORPCError("BAD_REQUEST", { message: `Unsupported pluginId: ${input.pluginId}` });
297
+ }
298
+ ```
299
+
300
+ Rules: API owns `thingId`, `pluginId`, timestamps. Plugin owns `type` and `payload`. Keep one SSE stream per concept and filter server-side.
301
+
302
+ ### Effect and DB Lifecycle
303
+
304
+ Prefer `Layer` for long-lived resources (DB, service singletons) and `Effect` for the work itself. Use `runEffect()` to bridge Effect and async handlers with clean ORPC error boundaries — unwraps `ORPCError` from Effect and converts unknown errors to `INTERNAL_SERVER_ERROR`:
305
+
306
+ ```ts
307
+ import { runEffect } from "@/lib/context";
308
+
309
+ const result = await runEffect(services.myService.doSomething(input));
310
+ ```
311
+
312
+ Best practices: Keep service interfaces Effect-native, bridge to async only at the handler boundary via `runEffect()`. Use `Context.Tag` for DI between services. Initialize long-lived resources in `initialize` and return them as services.
313
+
314
+ ### SSR Proxy Client
315
+
316
+ `createPluginsClient()` creates a Proxy that merges the API client with all plugin clients:
317
+
318
+ ```ts
319
+ export function createPluginsClient(result, context) {
320
+ const apiClient = result.api?.createClient(context);
321
+ const pluginClients = {};
322
+ for (const [key, plugin] of Object.entries(result.plugins)) {
323
+ if (key === "api") continue;
324
+ pluginClients[key] = plugin.createClient(context);
325
+ }
326
+ if (result.authClient) pluginClients.auth = result.authClient(context);
327
+
328
+ return new Proxy(apiClient, {
329
+ get(target, key) {
330
+ if (typeof key === "string" && key in pluginClients) return pluginClients[key];
331
+ return Reflect.get(target, key);
332
+ },
333
+ });
334
+ }
335
+ ```
336
+
337
+ ## Generated Types
338
+
339
+ See `references/generated-types.md` for the full table — files, contents, and regeneration triggers.
340
+
341
+ ## SSE Notes
342
+
343
+ Prefer a single publisher channel per concept and filter on the consumer side:
344
+
345
+ ```ts
346
+ const iterator = services.publisher.subscribe("thing", { signal, lastEventId });
347
+ for await (const event of iterator) {
348
+ if (input.pluginId && event.pluginId !== input.pluginId) continue;
349
+ yield event;
350
+ }
351
+ ```
352
+
353
+ ## How Routes Are Mounted
354
+
355
+ The host (`host/src/program.ts`) creates RPC and OpenAPI handlers from each plugin's router, mounted at `/api/rpc/<plugin-namespace>`. The session middleware runs on `/api/*` before the RPC handlers, ensuring context is set.
@@ -0,0 +1,14 @@
1
+ # Generated Types
2
+
3
+ | File | Contents | Regenerated by |
4
+ |------|----------|---------------|
5
+ | `api/src/lib/plugins-types.gen.ts` | `PluginsClient` — factory types for all plugins | `bos types gen` |
6
+ | `api/src/lib/auth-types.gen.ts` | Auth plugin request context types | `bos types gen` |
7
+ | `ui/src/lib/api-types.gen.ts` | `ApiContract` — all procedure types | `bos types gen` |
8
+ | `ui/src/lib/auth-types.gen.ts` | Auth client session/user types | `bos types gen` |
9
+
10
+ Type resolution:
11
+ - `local:plugins/<name>` → reads `src/contract.ts` directly from disk
12
+ - Remote URL → fetches contract types from the deployed plugin's manifest
13
+ - Missing local path with no URL → skipped with a warning
14
+ - Run `bos types gen` or restart `bos dev` after hand-editing `bos.config.json`
@@ -0,0 +1,38 @@
1
+ # Middleware Reference
2
+
3
+ ## Available Middlewares
4
+
5
+ | Middleware | Narrows |
6
+ |---|---|
7
+ | `requireAuth` | `userId: string`, `user: RequestAuthUser` |
8
+ | `requireAuthOrApiKey` | gate only — allows session or API key auth, no narrowing |
9
+ | `requireRole("admin")` | `userId`, `user` |
10
+ | `requireOrganization` | `userId`, `user`, `organization.activeOrganizationId: string` |
11
+ | `requireOrgRole("owner")` | all of above + `organization.member` non-null with `id`, `role` |
12
+ | `requireApiKey` | `apiKey: ApiKeyContext` |
13
+
14
+ ## Org Metadata Validation
15
+
16
+ Pass an optional Zod schema to `createAuthMiddleware` for runtime validation:
17
+
18
+ ```ts
19
+ import { z } from "every-plugin/zod";
20
+
21
+ const orgMetaSchema = z.object({ plan: z.enum(["free", "pro"]), seats: z.number() });
22
+ const { requireOrganization } = createAuthMiddleware(builder, { orgMetaSchema });
23
+ ```
24
+
25
+ When a schema is provided, `requireOrganization` and `requireOrgRole` call `schema.safeParse()` on the org metadata. On parse failure, throws `INTERNAL_SERVER_ERROR` (data integrity issue). When no schema is passed, metadata stays `Record<string, unknown>` with no validation.
26
+
27
+ ## Typed Org Context Helpers
28
+
29
+ ```ts
30
+ import type { OrgAuthenticatedContext } from "./lib/auth";
31
+
32
+ type MyOrgMeta = { plan: "free" | "pro"; seats: number };
33
+
34
+ const ctx = context as OrgAuthenticatedContext<MyOrgMeta>;
35
+ ctx.organization.organization?.metadata?.plan;
36
+ ```
37
+
38
+ Also available: `OrgMemberAuthenticatedContext<TMeta>` (guarantees `organization.member` is non-null).