@powerhousedao/vetra-studio 6.2.3-dev.98 → 6.3.0-dev.1

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.
@@ -21,7 +21,18 @@ type JwkPair = {
21
21
  * Codegen hot-reload stays a runner/dev-verb concern (the project-level
22
22
  * watcher), tracked as the R4 follow-up alongside external browser plugin
23
23
  * loading.
24
+ *
25
+ * The codegen PROCESSOR is the server's own dev-mode machinery; its config
26
+ * (`VetraConfig`: which drive it generates from, `--interactive`) reaches it
27
+ * through this plugin's entry config, which the ph-cli switchboard runner
28
+ * fills in from the invocation.
24
29
  */
30
+ /** The entry config. Not for host files: the runner writes it. */
31
+ export interface StudioSwitchboardConfig {
32
+ /** Entries for the server's `processorConfig` map, by processor config key
33
+ * (classic `ph vetra` passes the same map to the same server option). */
34
+ processorConfig?: Record<string, unknown>;
35
+ }
25
36
  export interface StudioHostContext {
26
37
  options?: Record<string, unknown>;
27
38
  renown?: unknown;
@@ -36,8 +47,9 @@ export interface StudioHooks {
36
47
  /** The key pair the switchboard signs with: the same file and env var its
37
48
  * identity loads from (`options.identity.keypairPath`, else .ph/.keypair.json). */
38
49
  export declare function hostKeyPairLoader(options: Record<string, unknown> | undefined): () => Promise<JwkPair | undefined>;
39
- export declare function createStudioSwitchboardPlugin(loadKeyPairFor?: (options: Record<string, unknown> | undefined) => () => Promise<JwkPair | undefined>): HostPlugin<StudioHooks>;
40
- declare const studioSwitchboardPlugin: HostPlugin<StudioHooks>;
50
+ export declare function createStudioSwitchboardPlugin(loadKeyPairFor?: (options: Record<string, unknown> | undefined) => () => Promise<JwkPair | undefined>, config?: StudioSwitchboardConfig): HostPlugin<StudioHooks>;
51
+ /** A factory, so the entry may carry config (host-core plugins-resolve). */
52
+ declare const studioSwitchboardPlugin: (config?: StudioSwitchboardConfig) => HostPlugin<StudioHooks>;
41
53
  //#endregion
42
54
  export { studioSwitchboardPlugin as default };
43
55
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../src/sign-in.ts","../src/switchboard.ts"],"mappings":";;;KAyDY;EAAY,WAAW;EAAY,YAAY;;;;;;;;;;;;;;;;;;;iBChC1C;EACf,UAAU;EACV;EACA;EACA;EACA,gBAAgB;;iBAWD;EACf,yBACE,SAAS,4BACN;EACL,yBAAyB,KAAK,sBAAsB;;;;wBAKtC,kBACd,SAAS,4CACF,QAAQ;wBAQD,8BACd,kBACE,SAAS,8CACA,QAAQ,uBAClB,WAAW;cAmCR,yBAAyB,WAAW"}
1
+ {"version":3,"file":"switchboard.d.mts","names":[],"sources":["../src/sign-in.ts","../src/switchboard.ts"],"mappings":";;;KAyDY;EAAY,WAAW;EAAY,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;iBC1B1C;;;EAGf,kBAAkB;;iBAGH;EACf,UAAU;EACV;EACA;EACA;EACA,gBAAgB;;iBAWD;EACf,yBACE,SAAS,4BACN;EACL,yBAAyB,KAAK,sBAAsB;;;;wBAKtC,kBACd,SAAS,4CACF,QAAQ;wBAQD,8BACd,kBACE,SAAS,8CACA,QAAQ,sBACnB,SAAQ,0BACP,WAAW;;cAgDR,0BAAuB,SAClB,4BACR,WAAW"}
@@ -89,15 +89,24 @@ function hostKeyPairLoader(options) {
89
89
  const identity = options?.identity;
90
90
  return async () => await new NodeKeyStorage(identity?.keypairPath).loadKeyPair();
91
91
  }
92
- function createStudioSwitchboardPlugin(loadKeyPairFor = hostKeyPairLoader) {
92
+ function createStudioSwitchboardPlugin(loadKeyPairFor = hostKeyPairLoader, config = {}) {
93
+ const processorConfig = Object.entries(config.processorConfig ?? {});
93
94
  return {
94
95
  name: "vetra-studio-switchboard",
95
96
  appliesTo: "switchboard",
96
97
  hooks: {
97
- transformServerOptions: (options) => ({
98
- ...options,
99
- dev: true
100
- }),
98
+ transformServerOptions: (options) => {
99
+ const transformed = {
100
+ ...options,
101
+ dev: true
102
+ };
103
+ if (processorConfig.length === 0) return transformed;
104
+ const existing = options.processorConfig instanceof Map ? options.processorConfig : [];
105
+ return {
106
+ ...transformed,
107
+ processorConfig: new Map([...existing, ...processorConfig])
108
+ };
109
+ },
101
110
  onSubgraphsRegistering: async (ctx) => {
102
111
  const api = ctx.api;
103
112
  const registry = ctx.graphqlManager;
@@ -114,7 +123,8 @@ function createStudioSwitchboardPlugin(loadKeyPairFor = hostKeyPairLoader) {
114
123
  }
115
124
  };
116
125
  }
117
- const studioSwitchboardPlugin = createStudioSwitchboardPlugin();
126
+ /** A factory, so the entry may carry config (host-core plugins-resolve). */
127
+ const studioSwitchboardPlugin = (config) => createStudioSwitchboardPlugin(hostKeyPairLoader, config);
118
128
  //#endregion
119
129
  export { createStudioSwitchboardPlugin, studioSwitchboardPlugin as default, hostKeyPairLoader };
120
130
 
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.mjs","names":[],"sources":["../src/sign-in.ts","../src/switchboard.ts"],"sourcesContent":["import type { API, Context, ISubgraph } from \"@powerhousedao/reactor-api\";\nimport { GraphQLError, parse } from \"graphql\";\n\n/**\n * Studio sign-in: hands the studio's own Renown identity (the project's CLI\n * key pair and the user `ph login` delegated it to) to a caller that proves\n * it is a listed admin with a bearer, typically one `ph access-token` minted.\n * The browser installs the key pair as its Renown key and logs in with the\n * user's DID, so an agent reaches a real Renown session in Connect without a\n * wallet. Served only by a studio (dev verb) switchboard.\n */\n\nexport const STUDIO_SUBGRAPH_NAME = \"vetra-studio\";\n\nexport const studioTypeDefs = parse(/* GraphQL */ `\n type StudioKeyPair {\n \"The public JWK, as JSON.\"\n publicKey: String!\n \"The private JWK, as JSON.\"\n privateKey: String!\n }\n\n type StudioIdentity {\n \"did:pkh of the user the key is delegated by; log in with it.\"\n userDid: String!\n \"did:key of the key pair.\"\n did: String!\n address: String!\n chainId: Int!\n keyPair: StudioKeyPair!\n }\n\n type Query {\n \"Whether this switchboard serves studio sign-in (a studio dev host).\"\n studioSignInAvailable: Boolean!\n }\n\n type Mutation {\n \"\"\"\n The studio's Renown identity, for a listed admin's bearer: install the key\n pair in the browser and log in with userDid. Studio (dev) hosts only.\n \"\"\"\n studioSignIn: StudioIdentity!\n }\n`);\n\n/** The switchboard facts the sign-in decides from. */\nexport type StudioApi = Pick<API, \"authorizationService\"> & {\n authService: unknown;\n};\n\n/** The parts of the host's Renown instance the sign-in reads. */\nexport type StudioRenown = {\n readonly did: string;\n readonly user: { did: string; address: string; chainId: number } | undefined;\n};\n\nexport type JwkPair = { publicKey: JsonWebKey; privateKey: JsonWebKey };\n\nexport type StudioSignInDeps = {\n api: StudioApi;\n renown: StudioRenown | null | undefined;\n /** The key pair the host signs with (its NodeKeyStorage). */\n loadKeyPair: () => Promise<JwkPair | undefined>;\n};\n\nfunction forbidden(message: string): GraphQLError {\n return new GraphQLError(message, { extensions: { code: \"FORBIDDEN\" } });\n}\n\nexport function isListedAdmin(\n admins: readonly string[],\n address: string | undefined,\n): boolean {\n if (!address) return false;\n const caller = address.toLowerCase();\n return admins.some((admin) => admin.toLowerCase() === caller);\n}\n\nexport async function studioSignIn(\n deps: StudioSignInDeps,\n ctx: Pick<Context, \"user\">,\n) {\n if (deps.api.authService === undefined) {\n throw forbidden(\n \"Studio sign-in needs the switchboard to read bearers: set AUTH_ENABLED=true and list your address in ADMINS.\",\n );\n }\n const address = ctx.user?.address;\n if (!address) {\n throw forbidden(\n \"Studio sign-in needs a bearer: pass one from `ph access-token`.\",\n );\n }\n if (!isListedAdmin(deps.api.authorizationService.config.admins, address)) {\n throw forbidden(\"Studio sign-in is for the host's admins.\");\n }\n const user = deps.renown?.user;\n if (!deps.renown || !user) {\n throw forbidden(\n \"This studio has no signed-in Renown identity: run `ph login` in the project, then restart it.\",\n );\n }\n const keyPair = await deps.loadKeyPair();\n if (!keyPair) {\n throw forbidden(\"This studio has no key pair to hand over.\");\n }\n return {\n userDid: user.did,\n did: deps.renown.did,\n address: user.address,\n chainId: user.chainId,\n keyPair: {\n publicKey: JSON.stringify(keyPair.publicKey),\n privateKey: JSON.stringify(keyPair.privateKey),\n },\n };\n}\n\nexport function createStudioSubgraph(\n deps: StudioSignInDeps & { relationalDb: API[\"relationalDb\"] },\n): ISubgraph {\n return {\n name: STUDIO_SUBGRAPH_NAME,\n typeDefs: studioTypeDefs,\n relationalDb: deps.relationalDb,\n hasSubscriptions: false,\n resolvers: {\n Query: { studioSignInAvailable: () => true },\n Mutation: {\n studioSignIn: (_parent: unknown, _args: unknown, ctx: Context) =>\n studioSignIn(deps, ctx),\n },\n },\n };\n}\n","import type { HostPlugin } from \"@powerhousedao/host-core\";\nimport type { API, ISubgraph } from \"@powerhousedao/reactor-api\";\nimport { NodeKeyStorage } from \"@renown/sdk/node\";\nimport {\n createStudioSubgraph,\n type JwkPair,\n type StudioRenown,\n} from \"./sign-in.js\";\n\n/**\n * Vetra Studio, server side (rewire R4): what makes a switchboard the STUDIO\n * switchboard and cannot be expressed through other plugins — the dev-mode\n * machinery (Vite-loaded local document models with HMR), and studio sign-in\n * (an admin's bearer gets the studio's Renown identity, so an agent can log\n * the studio Connect in; see sign-in.ts). Listed verb-scoped (verbs: [\"dev\"])\n * in the vetra host; `ph run vetra` at the run verb is the same stack\n * headless, without dev tooling. The studio DRIVES are not this plugin's\n * business: they are core drive declarations in the host file\n * (reactor.drives with projectHash ids), seeded by the runner.\n *\n * Codegen hot-reload stays a runner/dev-verb concern (the project-level\n * watcher), tracked as the R4 follow-up alongside external browser plugin\n * loading.\n */\n\nexport interface StudioHostContext {\n options?: Record<string, unknown>;\n renown?: unknown;\n api?: unknown;\n graphqlManager?: unknown;\n lateSubgraphs?: Promise<unknown>[];\n}\n\ninterface SubgraphRegistry {\n registerSubgraphInstance(\n subgraph: ISubgraph,\n supergraph?: string,\n core?: boolean,\n ): Promise<unknown>;\n}\n\nexport interface StudioHooks {\n transformServerOptions: (\n options: Record<string, unknown>,\n ) => Record<string, unknown>;\n onSubgraphsRegistering: (ctx: StudioHostContext) => Promise<void>;\n}\n\n/** The key pair the switchboard signs with: the same file and env var its\n * identity loads from (`options.identity.keypairPath`, else .ph/.keypair.json). */\nexport function hostKeyPairLoader(\n options: Record<string, unknown> | undefined,\n): () => Promise<JwkPair | undefined> {\n const identity = options?.identity as { keypairPath?: string } | undefined;\n return async () =>\n (await new NodeKeyStorage(identity?.keypairPath).loadKeyPair()) as\n | JwkPair\n | undefined;\n}\n\nexport function createStudioSwitchboardPlugin(\n loadKeyPairFor: (\n options: Record<string, unknown> | undefined,\n ) => () => Promise<JwkPair | undefined> = hostKeyPairLoader,\n): HostPlugin<StudioHooks> {\n return {\n name: \"vetra-studio-switchboard\",\n appliesTo: \"switchboard\",\n hooks: {\n transformServerOptions: (options) => ({ ...options, dev: true }),\n onSubgraphsRegistering: async (ctx) => {\n const api = ctx.api as\n | (Pick<API, \"authorizationService\" | \"relationalDb\"> & {\n authService: unknown;\n })\n | undefined;\n const registry = ctx.graphqlManager as SubgraphRegistry | undefined;\n if (!api || !registry) {\n throw new Error(\n \"The vetra-studio plugin needs the switchboard's API and GraphQL manager at onSubgraphsRegistering; the host handed neither.\",\n );\n }\n const registration = registry.registerSubgraphInstance(\n createStudioSubgraph({\n api,\n relationalDb: api.relationalDb,\n renown: ctx.renown as StudioRenown | null | undefined,\n loadKeyPair: loadKeyPairFor(ctx.options),\n }),\n \"graphql\",\n false,\n );\n (ctx.lateSubgraphs ??= []).push(registration);\n await Promise.resolve();\n },\n },\n };\n}\n\nconst studioSwitchboardPlugin: HostPlugin<StudioHooks> =\n createStudioSwitchboardPlugin();\n\nexport default studioSwitchboardPlugin;\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,uBAAuB;AAEpC,MAAa,iBAAiB,MAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BjD;AAsBD,SAAS,UAAU,SAA+B;CAChD,OAAO,IAAI,aAAa,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,EAAE,CAAC;AACxE;AAEA,SAAgB,cACd,QACA,SACS;CACT,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,SAAS,QAAQ,YAAY;CACnC,OAAO,OAAO,MAAM,UAAU,MAAM,YAAY,MAAM,MAAM;AAC9D;AAEA,eAAsB,aACpB,MACA,KACA;CACA,IAAI,KAAK,IAAI,gBAAgB,KAAA,GAC3B,MAAM,UACJ,8GACF;CAEF,MAAM,UAAU,IAAI,MAAM;CAC1B,IAAI,CAAC,SACH,MAAM,UACJ,iEACF;CAEF,IAAI,CAAC,cAAc,KAAK,IAAI,qBAAqB,OAAO,QAAQ,OAAO,GACrE,MAAM,UAAU,0CAA0C;CAE5D,MAAM,OAAO,KAAK,QAAQ;CAC1B,IAAI,CAAC,KAAK,UAAU,CAAC,MACnB,MAAM,UACJ,+FACF;CAEF,MAAM,UAAU,MAAM,KAAK,YAAY;CACvC,IAAI,CAAC,SACH,MAAM,UAAU,2CAA2C;CAE7D,OAAO;EACL,SAAS,KAAK;EACd,KAAK,KAAK,OAAO;EACjB,SAAS,KAAK;EACd,SAAS,KAAK;EACd,SAAS;GACP,WAAW,KAAK,UAAU,QAAQ,SAAS;GAC3C,YAAY,KAAK,UAAU,QAAQ,UAAU;EAC/C;CACF;AACF;AAEA,SAAgB,qBACd,MACW;CACX,OAAO;EACL,MAAM;EACN,UAAU;EACV,cAAc,KAAK;EACnB,kBAAkB;EAClB,WAAW;GACT,OAAO,EAAE,6BAA6B,KAAK;GAC3C,UAAU,EACR,eAAe,SAAkB,OAAgB,QAC/C,aAAa,MAAM,GAAG,EAC1B;EACF;CACF;AACF;;;;;ACrFA,SAAgB,kBACd,SACoC;CACpC,MAAM,WAAW,SAAS;CAC1B,OAAO,YACJ,MAAM,IAAI,eAAe,UAAU,WAAW,CAAC,CAAC,YAAY;AAGjE;AAEA,SAAgB,8BACd,iBAE0C,mBACjB;CACzB,OAAO;EACL,MAAM;EACN,WAAW;EACX,OAAO;GACL,yBAAyB,aAAa;IAAE,GAAG;IAAS,KAAK;GAAK;GAC9D,wBAAwB,OAAO,QAAQ;IACrC,MAAM,MAAM,IAAI;IAKhB,MAAM,WAAW,IAAI;IACrB,IAAI,CAAC,OAAO,CAAC,UACX,MAAM,IAAI,MACR,6HACF;IAEF,MAAM,eAAe,SAAS,yBAC5B,qBAAqB;KACnB;KACA,cAAc,IAAI;KAClB,QAAQ,IAAI;KACZ,aAAa,eAAe,IAAI,OAAO;IACzC,CAAC,GACD,WACA,KACF;IACA,CAAC,IAAI,kBAAkB,CAAC,EAAA,CAAG,KAAK,YAAY;IAC5C,MAAM,QAAQ,QAAQ;GACxB;EACF;CACF;AACF;AAEA,MAAM,0BACJ,8BAA8B"}
1
+ {"version":3,"file":"switchboard.mjs","names":[],"sources":["../src/sign-in.ts","../src/switchboard.ts"],"sourcesContent":["import type { API, Context, ISubgraph } from \"@powerhousedao/reactor-api\";\nimport { GraphQLError, parse } from \"graphql\";\n\n/**\n * Studio sign-in: hands the studio's own Renown identity (the project's CLI\n * key pair and the user `ph login` delegated it to) to a caller that proves\n * it is a listed admin with a bearer, typically one `ph access-token` minted.\n * The browser installs the key pair as its Renown key and logs in with the\n * user's DID, so an agent reaches a real Renown session in Connect without a\n * wallet. Served only by a studio (dev verb) switchboard.\n */\n\nexport const STUDIO_SUBGRAPH_NAME = \"vetra-studio\";\n\nexport const studioTypeDefs = parse(/* GraphQL */ `\n type StudioKeyPair {\n \"The public JWK, as JSON.\"\n publicKey: String!\n \"The private JWK, as JSON.\"\n privateKey: String!\n }\n\n type StudioIdentity {\n \"did:pkh of the user the key is delegated by; log in with it.\"\n userDid: String!\n \"did:key of the key pair.\"\n did: String!\n address: String!\n chainId: Int!\n keyPair: StudioKeyPair!\n }\n\n type Query {\n \"Whether this switchboard serves studio sign-in (a studio dev host).\"\n studioSignInAvailable: Boolean!\n }\n\n type Mutation {\n \"\"\"\n The studio's Renown identity, for a listed admin's bearer: install the key\n pair in the browser and log in with userDid. Studio (dev) hosts only.\n \"\"\"\n studioSignIn: StudioIdentity!\n }\n`);\n\n/** The switchboard facts the sign-in decides from. */\nexport type StudioApi = Pick<API, \"authorizationService\"> & {\n authService: unknown;\n};\n\n/** The parts of the host's Renown instance the sign-in reads. */\nexport type StudioRenown = {\n readonly did: string;\n readonly user: { did: string; address: string; chainId: number } | undefined;\n};\n\nexport type JwkPair = { publicKey: JsonWebKey; privateKey: JsonWebKey };\n\nexport type StudioSignInDeps = {\n api: StudioApi;\n renown: StudioRenown | null | undefined;\n /** The key pair the host signs with (its NodeKeyStorage). */\n loadKeyPair: () => Promise<JwkPair | undefined>;\n};\n\nfunction forbidden(message: string): GraphQLError {\n return new GraphQLError(message, { extensions: { code: \"FORBIDDEN\" } });\n}\n\nexport function isListedAdmin(\n admins: readonly string[],\n address: string | undefined,\n): boolean {\n if (!address) return false;\n const caller = address.toLowerCase();\n return admins.some((admin) => admin.toLowerCase() === caller);\n}\n\nexport async function studioSignIn(\n deps: StudioSignInDeps,\n ctx: Pick<Context, \"user\">,\n) {\n if (deps.api.authService === undefined) {\n throw forbidden(\n \"Studio sign-in needs the switchboard to read bearers: set AUTH_ENABLED=true and list your address in ADMINS.\",\n );\n }\n const address = ctx.user?.address;\n if (!address) {\n throw forbidden(\n \"Studio sign-in needs a bearer: pass one from `ph access-token`.\",\n );\n }\n if (!isListedAdmin(deps.api.authorizationService.config.admins, address)) {\n throw forbidden(\"Studio sign-in is for the host's admins.\");\n }\n const user = deps.renown?.user;\n if (!deps.renown || !user) {\n throw forbidden(\n \"This studio has no signed-in Renown identity: run `ph login` in the project, then restart it.\",\n );\n }\n const keyPair = await deps.loadKeyPair();\n if (!keyPair) {\n throw forbidden(\"This studio has no key pair to hand over.\");\n }\n return {\n userDid: user.did,\n did: deps.renown.did,\n address: user.address,\n chainId: user.chainId,\n keyPair: {\n publicKey: JSON.stringify(keyPair.publicKey),\n privateKey: JSON.stringify(keyPair.privateKey),\n },\n };\n}\n\nexport function createStudioSubgraph(\n deps: StudioSignInDeps & { relationalDb: API[\"relationalDb\"] },\n): ISubgraph {\n return {\n name: STUDIO_SUBGRAPH_NAME,\n typeDefs: studioTypeDefs,\n relationalDb: deps.relationalDb,\n hasSubscriptions: false,\n resolvers: {\n Query: { studioSignInAvailable: () => true },\n Mutation: {\n studioSignIn: (_parent: unknown, _args: unknown, ctx: Context) =>\n studioSignIn(deps, ctx),\n },\n },\n };\n}\n","import type { HostPlugin } from \"@powerhousedao/host-core\";\nimport type { API, ISubgraph } from \"@powerhousedao/reactor-api\";\nimport { NodeKeyStorage } from \"@renown/sdk/node\";\nimport {\n createStudioSubgraph,\n type JwkPair,\n type StudioRenown,\n} from \"./sign-in.js\";\n\n/**\n * Vetra Studio, server side (rewire R4): what makes a switchboard the STUDIO\n * switchboard and cannot be expressed through other plugins — the dev-mode\n * machinery (Vite-loaded local document models with HMR), and studio sign-in\n * (an admin's bearer gets the studio's Renown identity, so an agent can log\n * the studio Connect in; see sign-in.ts). Listed verb-scoped (verbs: [\"dev\"])\n * in the vetra host; `ph run vetra` at the run verb is the same stack\n * headless, without dev tooling. The studio DRIVES are not this plugin's\n * business: they are core drive declarations in the host file\n * (reactor.drives with projectHash ids), seeded by the runner.\n *\n * Codegen hot-reload stays a runner/dev-verb concern (the project-level\n * watcher), tracked as the R4 follow-up alongside external browser plugin\n * loading.\n *\n * The codegen PROCESSOR is the server's own dev-mode machinery; its config\n * (`VetraConfig`: which drive it generates from, `--interactive`) reaches it\n * through this plugin's entry config, which the ph-cli switchboard runner\n * fills in from the invocation.\n */\n\n/** The entry config. Not for host files: the runner writes it. */\nexport interface StudioSwitchboardConfig {\n /** Entries for the server's `processorConfig` map, by processor config key\n * (classic `ph vetra` passes the same map to the same server option). */\n processorConfig?: Record<string, unknown>;\n}\n\nexport interface StudioHostContext {\n options?: Record<string, unknown>;\n renown?: unknown;\n api?: unknown;\n graphqlManager?: unknown;\n lateSubgraphs?: Promise<unknown>[];\n}\n\ninterface SubgraphRegistry {\n registerSubgraphInstance(\n subgraph: ISubgraph,\n supergraph?: string,\n core?: boolean,\n ): Promise<unknown>;\n}\n\nexport interface StudioHooks {\n transformServerOptions: (\n options: Record<string, unknown>,\n ) => Record<string, unknown>;\n onSubgraphsRegistering: (ctx: StudioHostContext) => Promise<void>;\n}\n\n/** The key pair the switchboard signs with: the same file and env var its\n * identity loads from (`options.identity.keypairPath`, else .ph/.keypair.json). */\nexport function hostKeyPairLoader(\n options: Record<string, unknown> | undefined,\n): () => Promise<JwkPair | undefined> {\n const identity = options?.identity as { keypairPath?: string } | undefined;\n return async () =>\n (await new NodeKeyStorage(identity?.keypairPath).loadKeyPair()) as\n | JwkPair\n | undefined;\n}\n\nexport function createStudioSwitchboardPlugin(\n loadKeyPairFor: (\n options: Record<string, unknown> | undefined,\n ) => () => Promise<JwkPair | undefined> = hostKeyPairLoader,\n config: StudioSwitchboardConfig = {},\n): HostPlugin<StudioHooks> {\n const processorConfig = Object.entries(config.processorConfig ?? {});\n return {\n name: \"vetra-studio-switchboard\",\n appliesTo: \"switchboard\",\n hooks: {\n transformServerOptions: (options) => {\n const transformed = { ...options, dev: true };\n if (processorConfig.length === 0) return transformed;\n const existing =\n options.processorConfig instanceof Map\n ? (options.processorConfig as Map<string, unknown>)\n : [];\n return {\n ...transformed,\n processorConfig: new Map([...existing, ...processorConfig]),\n };\n },\n onSubgraphsRegistering: async (ctx) => {\n const api = ctx.api as\n | (Pick<API, \"authorizationService\" | \"relationalDb\"> & {\n authService: unknown;\n })\n | undefined;\n const registry = ctx.graphqlManager as SubgraphRegistry | undefined;\n if (!api || !registry) {\n throw new Error(\n \"The vetra-studio plugin needs the switchboard's API and GraphQL manager at onSubgraphsRegistering; the host handed neither.\",\n );\n }\n const registration = registry.registerSubgraphInstance(\n createStudioSubgraph({\n api,\n relationalDb: api.relationalDb,\n renown: ctx.renown as StudioRenown | null | undefined,\n loadKeyPair: loadKeyPairFor(ctx.options),\n }),\n \"graphql\",\n false,\n );\n (ctx.lateSubgraphs ??= []).push(registration);\n await Promise.resolve();\n },\n },\n };\n}\n\n/** A factory, so the entry may carry config (host-core plugins-resolve). */\nconst studioSwitchboardPlugin = (\n config?: StudioSwitchboardConfig,\n): HostPlugin<StudioHooks> =>\n createStudioSwitchboardPlugin(hostKeyPairLoader, config);\n\nexport default studioSwitchboardPlugin;\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,uBAAuB;AAEpC,MAAa,iBAAiB,MAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BjD;AAsBD,SAAS,UAAU,SAA+B;CAChD,OAAO,IAAI,aAAa,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,EAAE,CAAC;AACxE;AAEA,SAAgB,cACd,QACA,SACS;CACT,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,SAAS,QAAQ,YAAY;CACnC,OAAO,OAAO,MAAM,UAAU,MAAM,YAAY,MAAM,MAAM;AAC9D;AAEA,eAAsB,aACpB,MACA,KACA;CACA,IAAI,KAAK,IAAI,gBAAgB,KAAA,GAC3B,MAAM,UACJ,8GACF;CAEF,MAAM,UAAU,IAAI,MAAM;CAC1B,IAAI,CAAC,SACH,MAAM,UACJ,iEACF;CAEF,IAAI,CAAC,cAAc,KAAK,IAAI,qBAAqB,OAAO,QAAQ,OAAO,GACrE,MAAM,UAAU,0CAA0C;CAE5D,MAAM,OAAO,KAAK,QAAQ;CAC1B,IAAI,CAAC,KAAK,UAAU,CAAC,MACnB,MAAM,UACJ,+FACF;CAEF,MAAM,UAAU,MAAM,KAAK,YAAY;CACvC,IAAI,CAAC,SACH,MAAM,UAAU,2CAA2C;CAE7D,OAAO;EACL,SAAS,KAAK;EACd,KAAK,KAAK,OAAO;EACjB,SAAS,KAAK;EACd,SAAS,KAAK;EACd,SAAS;GACP,WAAW,KAAK,UAAU,QAAQ,SAAS;GAC3C,YAAY,KAAK,UAAU,QAAQ,UAAU;EAC/C;CACF;AACF;AAEA,SAAgB,qBACd,MACW;CACX,OAAO;EACL,MAAM;EACN,UAAU;EACV,cAAc,KAAK;EACnB,kBAAkB;EAClB,WAAW;GACT,OAAO,EAAE,6BAA6B,KAAK;GAC3C,UAAU,EACR,eAAe,SAAkB,OAAgB,QAC/C,aAAa,MAAM,GAAG,EAC1B;EACF;CACF;AACF;;;;;ACzEA,SAAgB,kBACd,SACoC;CACpC,MAAM,WAAW,SAAS;CAC1B,OAAO,YACJ,MAAM,IAAI,eAAe,UAAU,WAAW,CAAC,CAAC,YAAY;AAGjE;AAEA,SAAgB,8BACd,iBAE0C,mBAC1C,SAAkC,CAAC,GACV;CACzB,MAAM,kBAAkB,OAAO,QAAQ,OAAO,mBAAmB,CAAC,CAAC;CACnE,OAAO;EACL,MAAM;EACN,WAAW;EACX,OAAO;GACL,yBAAyB,YAAY;IACnC,MAAM,cAAc;KAAE,GAAG;KAAS,KAAK;IAAK;IAC5C,IAAI,gBAAgB,WAAW,GAAG,OAAO;IACzC,MAAM,WACJ,QAAQ,2BAA2B,MAC9B,QAAQ,kBACT,CAAC;IACP,OAAO;KACL,GAAG;KACH,iBAAiB,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,eAAe,CAAC;IAC5D;GACF;GACA,wBAAwB,OAAO,QAAQ;IACrC,MAAM,MAAM,IAAI;IAKhB,MAAM,WAAW,IAAI;IACrB,IAAI,CAAC,OAAO,CAAC,UACX,MAAM,IAAI,MACR,6HACF;IAEF,MAAM,eAAe,SAAS,yBAC5B,qBAAqB;KACnB;KACA,cAAc,IAAI;KAClB,QAAQ,IAAI;KACZ,aAAa,eAAe,IAAI,OAAO;IACzC,CAAC,GACD,WACA,KACF;IACA,CAAC,IAAI,kBAAkB,CAAC,EAAA,CAAG,KAAK,YAAY;IAC5C,MAAM,QAAQ,QAAQ;GACxB;EACF;CACF;AACF;;AAGA,MAAM,2BACJ,WAEA,8BAA8B,mBAAmB,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/vetra-studio",
3
- "version": "6.2.3-dev.98",
3
+ "version": "6.3.0-dev.1",
4
4
  "description": "Vetra Studio as host plugins: the dev tooling composed onto a project's switchboard and Connect (uniform-runners rewire R4). EXPERIMENTAL.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -31,18 +31,18 @@
31
31
  "./package.json": "./package.json"
32
32
  },
33
33
  "dependencies": {
34
- "@powerhousedao/host-core": "6.2.3-dev.98",
35
- "@renown/sdk": "6.2.3-dev.98",
34
+ "@powerhousedao/host-core": "6.3.0-dev.1",
35
+ "@renown/sdk": "6.3.0-dev.1",
36
36
  "graphql": "^16"
37
37
  },
38
38
  "devDependencies": {
39
- "@powerhousedao/reactor-api": "6.2.3-dev.98",
39
+ "@powerhousedao/reactor-api": "6.3.0-dev.1",
40
40
  "tsdown": "0.23.0",
41
41
  "typescript": "7.0.2",
42
42
  "vitest": "5.0.3"
43
43
  },
44
44
  "peerDependencies": {
45
- "@powerhousedao/reactor-api": "6.2.3-dev.98"
45
+ "@powerhousedao/reactor-api": "6.3.0-dev.1"
46
46
  },
47
47
  "scripts": {
48
48
  "tsc": "tsc",