Skip to content

Commit 44ab040

Browse files
committed
feat(rivetkit): add GET /actors/names
1 parent 4f3a2a9 commit 44ab040

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
@@ -50,12 +50,14 @@ import {
5050
ActorsGetOrCreateRequestSchema,
5151
type ActorsGetOrCreateResponse,
5252
ActorsGetOrCreateResponseSchema,
53+
type ActorsListNamesResponse,
54+
ActorsListNamesResponseSchema,
5355
type ActorsListResponse,
5456
ActorsListResponseSchema,
5557
type Actor as ApiActor,
5658
} from "@/manager-api/actors";
5759
import type { AnyClient } from "@/mod";
58-
import type { RegistryConfig } from "@/registry/config";
60+
import { buildActorNames, type RegistryConfig } from "@/registry/config";
5961
import type { DriverConfig, RunnerConfig } from "@/registry/run-config";
6062
import type { ActorOutput, ManagerDriver } from "./driver";
6163
import { actorGateway, createTestWebSocketProxy } from "./gateway";
@@ -373,6 +375,27 @@ function addManagerRoutes(
373375
});
374376
}
375377

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

0 commit comments

Comments
 (0)