@michelangelo-ai/rpc 0.8.0 → 0.9.0

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.
@@ -8,6 +8,7 @@ vi.mock('../services', () => ({ getServices: mockGetServices }));
8
8
  const createPipelineRun = vi.fn().mockResolvedValue({});
9
9
  const updatePipelineRun = vi.fn().mockResolvedValue({});
10
10
  const updateTriggerRun = vi.fn().mockResolvedValue({});
11
+ const deletePipeline = vi.fn().mockResolvedValue({});
11
12
 
12
13
  mockGetServices.mockResolvedValue(
13
14
  new Proxy({} as Record<string, Record<string, unknown>>, {
@@ -18,6 +19,9 @@ mockGetServices.mockResolvedValue(
18
19
  if (serviceName === 'TriggerRunService') {
19
20
  return { updateTriggerRun };
20
21
  }
22
+ if (serviceName === 'PipelineService') {
23
+ return { deletePipeline };
24
+ }
21
25
  return new Proxy({}, { get: () => vi.fn().mockResolvedValue({}) });
22
26
  },
23
27
  })
@@ -64,4 +68,18 @@ describe('rpc handlers — mutation envelope wrapping', () => {
64
68
 
65
69
  expect((record.spec as Record<string, unknown>).actor).toBeUndefined();
66
70
  });
71
+
72
+ it('DeletePipeline extracts name/namespace from the full record', async () => {
73
+ const handlers = await getRpcHandlers();
74
+ const record = {
75
+ metadata: { name: 'eval-pipeline', namespace: 'ma-dev-test' },
76
+ spec: { owner: { name: 'me' } },
77
+ };
78
+ await handlers.DeletePipeline(record as never);
79
+
80
+ expect(deletePipeline).toHaveBeenCalledWith(
81
+ { name: 'eval-pipeline', namespace: 'ma-dev-test' },
82
+ undefined
83
+ );
84
+ });
67
85
  });
package/handlers.ts CHANGED
@@ -15,6 +15,21 @@ function unary<Fn>(fn: Fn): ExtractUnaryRpc<Fn> {
15
15
  return fn as unknown as ExtractUnaryRpc<Fn>;
16
16
  }
17
17
 
18
+ // Delete<CRD>Request messages are uniformly { name, namespace, deleteOptions? } across every
19
+ // service, while actions send the full CRD record (metadata/spec/status/typeMeta). Wrapping a
20
+ // generated deleteX method here lets every Delete* handler share this reshape instead of each
21
+ // entity config repeating it as mutation middleware.
22
+ function deleteCrd<Req extends { name: string; namespace: string }, Res>(
23
+ deleteFn: (request: Req, headers?: Record<string, string>) => Promise<Res>
24
+ ) {
25
+ return (
26
+ record: { metadata: { name: string; namespace: string } },
27
+ headers?: Record<string, string>
28
+ ) =>
29
+ // cast: Req may carry additional optional fields (e.g. deleteOptions) beyond name/namespace
30
+ deleteFn({ name: record.metadata.name, namespace: record.metadata.namespace } as Req, headers);
31
+ }
32
+
18
33
  async function createHandlers() {
19
34
  const services = await getServices();
20
35
 
@@ -27,6 +42,7 @@ async function createHandlers() {
27
42
  GetProject: unary(services.ProjectService.getProject),
28
43
  GetPipeline: unary(services.PipelineService.getPipeline),
29
44
  ListPipeline: unary(services.PipelineService.listPipeline),
45
+ DeletePipeline: deleteCrd(services.PipelineService.deletePipeline),
30
46
  ListPipelineRun: unary(services.PipelineRunService.listPipelineRun),
31
47
  GetPipelineRun: unary(services.PipelineRunService.getPipelineRun),
32
48
  ListTriggerRun: unary(services.TriggerRunService.listTriggerRun),
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.8.0",
5
+ "version": "0.9.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/michelangelo-ai/michelangelo"
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@bufbuild/protobuf": "^2.2.5",
20
- "@michelangelo-ai/core": "0.8.0"
20
+ "@michelangelo-ai/core": "0.9.0"
21
21
  },
22
22
  "exports": {
23
23
  ".": {