MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / driveOpenApiWork

Function driveOpenApiWork

apps/local/src/db/v1-v2-boot-drive.test.ts:171–215  ·  view source on GitHub ↗
(
  stack: Awaited<ReturnType<typeof bootRealStack>>,
  server: { readonly specJson: string },
  slug: string,
)

Source from the content-addressed store, hash-verified

169
170/** addSpec + connection + live invocation through the booted executor. */
171const driveOpenApiWork = (
172 stack: Awaited<ReturnType<typeof bootRealStack>>,
173 server: { readonly specJson: string },
174 slug: string,
175) =>
176 Effect.gen(function* () {
177 const added = yield* stack.executor.openapi.addSpec({
178 spec: { kind: "blob", value: server.specJson },
179 slug,
180 authenticationTemplate: [
181 {
182 slug: AuthTemplateSlug.make("apiKey"),
183 type: "apiKey",
184 headers: { "x-api-key": [{ type: "variable" as const, name: "token" }] },
185 },
186 ],
187 });
188 expect(added.toolCount).toBeGreaterThanOrEqual(2);
189
190 yield* stack.executor.connections.create({
191 owner: "org",
192 name: ConnectionName.make("main"),
193 integration: IntegrationSlug.make(slug),
194 template: AuthTemplateSlug.make("apiKey"),
195 value: "test-key-123",
196 });
197
198 const list = yield* stack.executor.execute(
199 ToolAddress.make(`tools.${slug}.org.main.widgets.listWidgets`),
200 {},
201 );
202 expect(isToolResult(list) && list.ok).toBe(true);
203 if (!isToolResult(list) || !list.ok) return;
204 // Payload-first contract holds through a migrated database too.
205 expect(list.data).toEqual(WIDGETS);
206 expect((list as { http?: { status: number } }).http?.status).toBe(200);
207
208 const created = yield* stack.executor.execute(
209 ToolAddress.make(`tools.${slug}.org.main.widgets.createWidget`),
210 { body: { name: "doodad" } },
211 );
212 expect(isToolResult(created) && created.ok).toBe(true);
213 if (!isToolResult(created) || !created.ok) return;
214 expect(created.data).toEqual({ id: 3, name: "doodad" });
215 });
216
217const expectToolRows = async (dbPath: string, slug: string, minCount: number) => {
218 const client = await openLocalLibsql(dbPath);

Callers 1

Calls 2

isToolResultFunction · 0.90
executeMethod · 0.65

Tested by

no test coverage detected