Skip to content

Commit 819085b

Browse files
committed
feat(rivetkit): add GET /actors/names
1 parent da963b1 commit 819085b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

rivetkit-typescript/packages/rivetkit/src/manager-api/actors.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export const ActorSchema = z.object({
1515
});
1616
export type Actor = z.infer<typeof ActorSchema>;
1717

18+
export const ActorNameSchema = z.object({
19+
metadata: z.record(z.string(), z.unknown()),
20+
});
21+
export type ActorName = z.infer<typeof ActorNameSchema>;
22+
1823
// MARK: GET /actors
1924
export const ActorsListResponseSchema = z.object({
2025
actors: z.array(ActorSchema),
@@ -61,3 +66,11 @@ export type ActorsGetOrCreateResponse = z.infer<
6166
// MARK: DELETE /actors/{}
6267
export const ActorsDeleteResponseSchema = z.object({});
6368
export type ActorsDeleteResponse = z.infer<typeof ActorsDeleteResponseSchema>;
69+
70+
// MARK: GET /actors/names
71+
export const ActorsListNamesResponseSchema = z.object({
72+
names: z.record(z.string(), ActorNameSchema),
73+
});
74+
export type ActorsListNamesResponse = z.infer<
75+
typeof ActorsListNamesResponseSchema
76+
>;

rivetkit-typescript/packages/rivetkit/src/manager/router.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ import {
4646
ActorsGetOrCreateRequestSchema,
4747
type ActorsGetOrCreateResponse,
4848
ActorsGetOrCreateResponseSchema,
49+
type ActorsListNamesResponse,
50+
ActorsListNamesResponseSchema,
4951
type ActorsListResponse,
5052
ActorsListResponseSchema,
5153
type Actor as ApiActor,
5254
} from "@/manager-api/actors";
5355
import type { AnyClient } from "@/mod";
54-
import type { RegistryConfig } from "@/registry/config";
56+
import { buildActorNames, type RegistryConfig } from "@/registry/config";
5557
import type { DriverConfig, RunnerConfig } from "@/registry/run-config";
5658
import type { ActorOutput, ManagerDriver } from "./driver";
5759
import { actorGateway, createTestWebSocketProxy } from "./gateway";
@@ -369,6 +371,27 @@ function addManagerRoutes(
369371
});
370372
}
371373

374+
// GET /actors/names
375+
{
376+
const route = createRoute({
377+
method: "get",
378+
path: "/actors/names",
379+
request: {
380+
query: z.object({
381+
namespace: z.string(),
382+
}),
383+
},
384+
responses: buildOpenApiResponses(ActorsListNamesResponseSchema),
385+
});
386+
387+
router.openapi(route, async (c) => {
388+
const names = buildActorNames(registryConfig);
389+
return c.json<ActorsListNamesResponse>({
390+
names,
391+
});
392+
});
393+
}
394+
372395
// PUT /actors
373396
{
374397
const route = createRoute({

0 commit comments

Comments
 (0)