@michelangelo-ai/rpc 0.3.0-nightly.20260708 → 0.3.0-nightly.20260709

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.
package/handlers.ts CHANGED
@@ -6,55 +6,35 @@ import type { ExtractUnaryRpc } from './types';
6
6
 
7
7
  let handlersPromise: Promise<Awaited<ReturnType<typeof createHandlers>>> | null = null;
8
8
 
9
+ function unary<Fn>(fn: Fn): ExtractUnaryRpc<Fn> {
10
+ // cast: TS can't resolve ExtractUnaryRpc's conditional type against the unconstrained generic Fn
11
+ // from within this function; fn always satisfies it at call sites
12
+ return fn as unknown as ExtractUnaryRpc<Fn>;
13
+ }
14
+
9
15
  async function createHandlers() {
10
16
  const services = await getServices();
11
17
 
12
18
  return {
13
- ListDeployment: services.DeploymentService.listDeployment as ExtractUnaryRpc<
14
- typeof services.DeploymentService.listDeployment
15
- >,
16
- GetDeployment: services.DeploymentService.getDeployment as ExtractUnaryRpc<
17
- typeof services.DeploymentService.getDeployment
18
- >,
19
- ListInferenceServer: services.InferenceServerService.listInferenceServer as ExtractUnaryRpc<
20
- typeof services.InferenceServerService.listInferenceServer
21
- >,
22
- GetInferenceServer: services.InferenceServerService.getInferenceServer as ExtractUnaryRpc<
23
- typeof services.InferenceServerService.getInferenceServer
24
- >,
25
- ListProject: services.ProjectService.listProject as ExtractUnaryRpc<
26
- typeof services.ProjectService.listProject
27
- >,
28
- GetProject: services.ProjectService.getProject as ExtractUnaryRpc<
29
- typeof services.ProjectService.getProject
30
- >,
31
- GetPipeline: services.PipelineService.getPipeline as ExtractUnaryRpc<
32
- typeof services.PipelineService.getPipeline
33
- >,
34
- ListPipeline: services.PipelineService.listPipeline as ExtractUnaryRpc<
35
- typeof services.PipelineService.listPipeline
36
- >,
37
- ListPipelineRun: services.PipelineRunService.listPipelineRun as ExtractUnaryRpc<
38
- typeof services.PipelineRunService.listPipelineRun
39
- >,
40
- GetPipelineRun: services.PipelineRunService.getPipelineRun as ExtractUnaryRpc<
41
- typeof services.PipelineRunService.getPipelineRun
42
- >,
43
- ListTriggerRun: services.TriggerRunService.listTriggerRun as ExtractUnaryRpc<
44
- typeof services.TriggerRunService.listTriggerRun
45
- >,
46
- GetTriggerRun: services.TriggerRunService.getTriggerRun as ExtractUnaryRpc<
47
- typeof services.TriggerRunService.getTriggerRun
48
- >,
19
+ ListDeployment: unary(services.DeploymentService.listDeployment),
20
+ GetDeployment: unary(services.DeploymentService.getDeployment),
21
+ ListInferenceServer: unary(services.InferenceServerService.listInferenceServer),
22
+ GetInferenceServer: unary(services.InferenceServerService.getInferenceServer),
23
+ ListProject: unary(services.ProjectService.listProject),
24
+ GetProject: unary(services.ProjectService.getProject),
25
+ GetPipeline: unary(services.PipelineService.getPipeline),
26
+ ListPipeline: unary(services.PipelineService.listPipeline),
27
+ ListPipelineRun: unary(services.PipelineRunService.listPipelineRun),
28
+ GetPipelineRun: unary(services.PipelineRunService.getPipelineRun),
29
+ ListTriggerRun: unary(services.TriggerRunService.listTriggerRun),
30
+ GetTriggerRun: unary(services.TriggerRunService.getTriggerRun),
49
31
  UpdateTriggerRun: (record: TriggerRun) =>
50
32
  services.TriggerRunService.updateTriggerRun({ triggerRun: record }),
51
33
  CreatePipelineRun: (record: PipelineRun) =>
52
34
  services.PipelineRunService.createPipelineRun({ pipelineRun: record }),
53
35
  UpdatePipelineRun: (record: PipelineRun) =>
54
36
  services.PipelineRunService.updatePipelineRun({ pipelineRun: record }),
55
- ListModel: services.ModelService.listModel as ExtractUnaryRpc<
56
- typeof services.ModelService.listModel
57
- >,
37
+ ListModel: unary(services.ModelService.listModel),
58
38
  } as const;
59
39
  }
60
40
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@michelangelo-ai/rpc",
3
3
  "license": "Apache-2.0",
4
4
  "type": "module",
5
- "version": "0.3.0-nightly.20260708",
5
+ "version": "0.3.0-nightly.20260709",
6
6
  "scripts": {
7
7
  "build": "vite build",
8
8
  "test": "cd ../../ && yarn test:rpc"
package/request.ts CHANGED
@@ -24,8 +24,13 @@ export async function request<RpcId extends keyof RpcHandlerType>(
24
24
  args: OmitTypeName<Parameters<RpcHandlerType[RpcId]>[0]>
25
25
  ): Promise<OmitTypeName<Awaited<ReturnType<RpcHandlerType[RpcId]>>>> {
26
26
  const handlers = await getRpcHandlers();
27
+ // cast: dynamic key lookup on handlers loses the specific RPC signature; we know RpcId is a valid
28
+ // key with matching handler shape
27
29
  const handler = handlers[rpcId] as (a: unknown) => Promise<unknown>;
30
+ // cast: handler returns unknown via dynamic dispatch; RpcId determines the concrete return type
28
31
  const response = (await handler(args)) as Awaited<ReturnType<RpcHandlerType[RpcId]>>;
32
+ // cast: toPlainObject returns unknown; RpcId determines the proto shape after stripping $typeName
33
+ // fields
29
34
  return toPlainObject(response) as OmitTypeName<Awaited<ReturnType<RpcHandlerType[RpcId]>>>;
30
35
  }
31
36
 
@@ -37,7 +42,7 @@ function toPlainObject(value: unknown): unknown {
37
42
  if (Array.isArray(value)) return value.map(toPlainObject);
38
43
 
39
44
  const result: Record<string, unknown> = {};
40
- for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
45
+ for (const [key, val] of Object.entries(value)) {
41
46
  if (key === '$typeName' || key === '$unknown') continue;
42
47
  result[key] = toPlainObject(val);
43
48
  }
package/runtime-config.ts CHANGED
@@ -23,6 +23,7 @@ export async function getRuntimeConfig(): Promise<RuntimeConfig> {
23
23
 
24
24
  let config: RuntimeConfig;
25
25
  try {
26
+ // cast: response.json() returns any; the config endpoint's shape is asserted, not validated
26
27
  config = (await response.json()) as RuntimeConfig;
27
28
  } catch (error) {
28
29
  console.error(
@@ -33,6 +33,9 @@ export function extractEntityFromResponse<T extends HasTypeName>(
33
33
  .toLowerCase();
34
34
 
35
35
  if (entityName in response) {
36
+ // cast: dynamic key access on response loses type; we've verified entityName exists in the
37
+ // response above (only true for Get/Create/Update prefixes; List/Delete are unstripped and
38
+ // unexercised — see #1461)
36
39
  return response[entityName] as ExtractEntityFromResponse<T>;
37
40
  }
38
41