@7k-inari/api-client 0.6.0 → 0.7.0-0933ff8

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/gen/ts/smoke.ts CHANGED
@@ -1,45 +1,56 @@
1
- import { ConnectRequest, Event, EventType } from "./proto/inari/agent/v1/agent_pb";
1
+ import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
2
+ import {
3
+ ConnectRequestSchema,
4
+ EventSchema,
5
+ EventType,
6
+ } from "./proto/inari/agent/v1/agent_pb";
2
7
  import {
3
8
  CapabilityAction,
4
9
  CapabilityKind,
5
- CapabilityUpdate,
10
+ CapabilityUpdateSchema,
6
11
  ManagementMode,
7
- Ping,
8
- ResyncResponse,
9
- StatusUpdate,
12
+ PingSchema,
13
+ ResyncResponseSchema,
14
+ StatusUpdateSchema,
10
15
  } from "./proto/inari/agent/v1/events_pb";
11
16
  import {
12
- ApplyBundle,
13
- CommandAck,
17
+ ApplyBundleSchema,
18
+ CommandAckSchema,
14
19
  CommandResult,
15
20
  CommitPolicy,
16
- InvokeAction,
17
- RegisterArgoCDApp,
18
- RenderRgdInstance,
21
+ InvokeActionSchema,
22
+ RegisterArgoCDAppSchema,
23
+ RenderRgdInstanceSchema,
19
24
  } from "./proto/inari/agent/v1/commands_pb";
20
25
  import {
21
- RegisterClusterRequest,
22
- RegisterClusterResponse,
26
+ RegisterClusterRequestSchema,
27
+ RegisterClusterResponseSchema,
28
+ RegistrationService,
23
29
  } from "./proto/inari/agent/v1/registration_pb";
24
- import { RegistrationService } from "./proto/inari/agent/v1/registration_connect";
25
- import { EventStreamService } from "./proto/inari/agent/v1/agent_connect";
26
- import { getHealth } from "./rest/client";
30
+ import { EventStreamService } from "./proto/inari/agent/v1/agent_pb";
31
+ import {
32
+ TunnelCloseSchema,
33
+ TunnelMessageSchema,
34
+ TunnelOpenSchema,
35
+ TunnelService,
36
+ } from "./proto/inari/tunnel/v1/tunnel_pb";
37
+ import { getHealth, getGetClusterKubeconfigUrl } from "./rest/client";
27
38
 
28
- const event = new Event({
39
+ const event = create(EventSchema, {
29
40
  eventId: "evt-1",
30
41
  resourceId: "res-1",
31
42
  type: "inari.agent.heartbeat.v1",
32
43
  sequence: 7n,
33
44
  });
34
- const bytes = event.toBinary();
35
- const decoded = Event.fromBinary(bytes);
45
+ const bytes = toBinary(EventSchema, event);
46
+ const decoded = fromBinary(EventSchema, bytes);
36
47
  if (decoded.eventId !== "evt-1") throw new Error("round trip failed");
37
48
  if (decoded.sequence !== 7n) throw new Error("sequence round trip failed");
38
49
 
39
- const req = new ConnectRequest({ event });
50
+ const req = create(ConnectRequestSchema, { event });
40
51
  if (req.event?.type !== event.type) throw new Error("wrapper failed");
41
52
 
42
- const cap = new CapabilityUpdate({
53
+ const cap = create(CapabilityUpdateSchema, {
43
54
  fullSync: true,
44
55
  stateChecksum: "sha256:abc",
45
56
  capabilities: [
@@ -53,36 +64,55 @@ const cap = new CapabilityUpdate({
53
64
  });
54
65
  if (cap.capabilities[0]?.kind !== CapabilityKind.CRD) throw new Error("capability failed");
55
66
 
56
- const status = new StatusUpdate({ message: "ok" });
67
+ const status = create(StatusUpdateSchema, { message: "ok" });
57
68
  if (status.message !== "ok") throw new Error("status failed");
58
69
 
59
- const ping = new Ping({ sequence: 1n });
70
+ const ping = create(PingSchema, { sequence: 1n });
60
71
  if (ping.sequence !== 1n) throw new Error("ping failed");
61
72
 
62
- const resync = new ResyncResponse({ appliedThroughSequence: 42n });
73
+ const resync = create(ResyncResponseSchema, { appliedThroughSequence: 42n });
63
74
  if (resync.appliedThroughSequence !== 42n) throw new Error("resync failed");
64
75
 
65
- const bundle = new ApplyBundle({
76
+ const bundle = create(ApplyBundleSchema, {
66
77
  commandId: "cmd-1",
67
78
  source: { case: "ociRef", value: "oci://registry/bundle:v1" },
68
79
  policy: CommitPolicy.PULL_REQUEST,
69
80
  });
70
81
  if (bundle.source.case !== "ociRef") throw new Error("apply-bundle failed");
71
82
 
72
- const app = new RegisterArgoCDApp({ commandId: "cmd-2", name: "web" });
73
- const action = new InvokeAction({ commandId: "cmd-3", action: "restart" });
74
- const rgd = new RenderRgdInstance({ commandId: "cmd-4", rgdRef: "oci://registry/rgd:v1" });
75
- const ack = new CommandAck({ commandId: "cmd-1", result: CommandResult.APPLIED });
83
+ const app = create(RegisterArgoCDAppSchema, { commandId: "cmd-2", name: "web" });
84
+ const action = create(InvokeActionSchema, { commandId: "cmd-3", action: "restart" });
85
+ const rgd = create(RenderRgdInstanceSchema, { commandId: "cmd-4", rgdRef: "oci://registry/rgd:v1" });
86
+ const ack = create(CommandAckSchema, { commandId: "cmd-1", result: CommandResult.APPLIED });
76
87
  void [app, action, rgd, ack];
77
88
 
78
- const regReq = new RegisterClusterRequest({ registrationToken: "tok-1" });
79
- const regResp = new RegisterClusterResponse({ clientId: "cluster-1" });
89
+ const regReq = create(RegisterClusterRequestSchema, { registrationToken: "tok-1" });
90
+ const regResp = create(RegisterClusterResponseSchema, { clientId: "cluster-1" });
80
91
  if (regReq.registrationToken !== "tok-1" || regResp.clientId !== "cluster-1") {
81
92
  throw new Error("registration failed");
82
93
  }
83
94
 
84
95
  if (EventType.CAPABILITY_UPDATE !== 1) throw new Error("enum failed");
85
96
 
97
+ const tunnelOpen = create(TunnelMessageSchema, {
98
+ connectionId: "conn-1",
99
+ payload: { case: "open", value: create(TunnelOpenSchema, { method: "GET", path: "/api/v1/pods" }) },
100
+ });
101
+ const tunnelBytes = toBinary(TunnelMessageSchema, tunnelOpen);
102
+ const tunnelDecoded = fromBinary(TunnelMessageSchema, tunnelBytes);
103
+ if (tunnelDecoded.payload.case !== "open" || tunnelDecoded.payload.value.method !== "GET") {
104
+ throw new Error("tunnel open round trip failed");
105
+ }
106
+
107
+ const tunnelClose = create(TunnelMessageSchema, {
108
+ connectionId: "conn-1",
109
+ payload: { case: "close", value: create(TunnelCloseSchema, { reason: "done" }) },
110
+ });
111
+ if (tunnelClose.payload.case !== "close") throw new Error("tunnel close payload failed");
112
+
113
+ void TunnelService;
114
+ void getGetClusterKubeconfigUrl;
115
+
86
116
  void RegistrationService;
87
117
  void EventStreamService;
88
118
  void getHealth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7k-inari/api-client",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-0933ff8",
4
4
  "description": "Generated TypeScript client for the Inari control plane contract (inari-api).",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -14,16 +14,16 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "dependencies": {
17
- "@bufbuild/protobuf": "^1.10.0",
18
- "@connectrpc/connect": "^1.6.1"
17
+ "@bufbuild/protobuf": "^2.16.0",
18
+ "@connectrpc/connect": "^2.2.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@redocly/cli": "^1.25.0",
22
- "orval": "^7.5.0",
23
- "typescript": "^5.6.0"
21
+ "@redocly/cli": "^2.0.0",
22
+ "orval": "^8.0.0",
23
+ "typescript": "^7.0.0"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
27
  "url": "https://github.com/7K-Inari/inari-api"
28
28
  }
29
- }
29
+ }
@@ -1,30 +0,0 @@
1
- // @generated by protoc-gen-connect-es v1.6.1 with parameter "target=ts"
2
- // @generated from file inari/agent/v1/agent.proto (package inari.agent.v1, syntax proto3)
3
- /* eslint-disable */
4
- // @ts-nocheck
5
-
6
- import { ConnectRequest, ConnectResponse } from "./agent_pb.js";
7
- import { MethodKind } from "@bufbuild/protobuf";
8
-
9
- /**
10
- * EventStreamService is the bidirectional gRPC stream between an in-cluster
11
- * agent and the Agent Gateway (plan §5.2). Delivery is at-least-once;
12
- * command handlers must be idempotent (command_id is the idempotency key).
13
- *
14
- * @generated from service inari.agent.v1.EventStreamService
15
- */
16
- export const EventStreamService = {
17
- typeName: "inari.agent.v1.EventStreamService",
18
- methods: {
19
- /**
20
- * @generated from rpc inari.agent.v1.EventStreamService.Connect
21
- */
22
- connect: {
23
- name: "Connect",
24
- I: ConnectRequest,
25
- O: ConnectResponse,
26
- kind: MethodKind.BiDiStreaming,
27
- },
28
- }
29
- } as const;
30
-
@@ -1,30 +0,0 @@
1
- // @generated by protoc-gen-connect-es v1.6.1 with parameter "target=ts"
2
- // @generated from file inari/agent/v1/registration.proto (package inari.agent.v1, syntax proto3)
3
- /* eslint-disable */
4
- // @ts-nocheck
5
-
6
- import { RegisterClusterRequest, RegisterClusterResponse } from "./registration_pb.js";
7
- import { MethodKind } from "@bufbuild/protobuf";
8
-
9
- /**
10
- * RegistrationService is the one-time bootstrap RPC an agent calls before it
11
- * can open the EventStream (plan §5.3). It is unauthenticated except for the
12
- * registration token itself.
13
- *
14
- * @generated from service inari.agent.v1.RegistrationService
15
- */
16
- export const RegistrationService = {
17
- typeName: "inari.agent.v1.RegistrationService",
18
- methods: {
19
- /**
20
- * @generated from rpc inari.agent.v1.RegistrationService.RegisterCluster
21
- */
22
- registerCluster: {
23
- name: "RegisterCluster",
24
- I: RegisterClusterRequest,
25
- O: RegisterClusterResponse,
26
- kind: MethodKind.Unary,
27
- },
28
- }
29
- } as const;
30
-
@@ -1,56 +0,0 @@
1
- // @generated by protoc-gen-connect-es v1.6.1 with parameter "target=ts"
2
- // @generated from file inari/plugin/v1/plugin.proto (package inari.plugin.v1, syntax proto3)
3
- /* eslint-disable */
4
- // @ts-nocheck
5
-
6
- import { GetCapabilitiesRequest, GetCapabilitiesResponse, GetInfoRequest, GetInfoResponse, HealthCheckRequest, HealthCheckResponse, InvokeRequest, InvokeResponse } from "./plugin_pb.js";
7
- import { MethodKind } from "@bufbuild/protobuf";
8
-
9
- /**
10
- * PluginContractService is the versioned gRPC surface every plugin serves
11
- * (platform plan §5.8). Changes are additive within inari.plugin.v1.
12
- *
13
- * @generated from service inari.plugin.v1.PluginContractService
14
- */
15
- export const PluginContractService = {
16
- typeName: "inari.plugin.v1.PluginContractService",
17
- methods: {
18
- /**
19
- * @generated from rpc inari.plugin.v1.PluginContractService.GetInfo
20
- */
21
- getInfo: {
22
- name: "GetInfo",
23
- I: GetInfoRequest,
24
- O: GetInfoResponse,
25
- kind: MethodKind.Unary,
26
- },
27
- /**
28
- * @generated from rpc inari.plugin.v1.PluginContractService.GetCapabilities
29
- */
30
- getCapabilities: {
31
- name: "GetCapabilities",
32
- I: GetCapabilitiesRequest,
33
- O: GetCapabilitiesResponse,
34
- kind: MethodKind.Unary,
35
- },
36
- /**
37
- * @generated from rpc inari.plugin.v1.PluginContractService.Invoke
38
- */
39
- invoke: {
40
- name: "Invoke",
41
- I: InvokeRequest,
42
- O: InvokeResponse,
43
- kind: MethodKind.Unary,
44
- },
45
- /**
46
- * @generated from rpc inari.plugin.v1.PluginContractService.HealthCheck
47
- */
48
- healthCheck: {
49
- name: "HealthCheck",
50
- I: HealthCheckRequest,
51
- O: HealthCheckResponse,
52
- kind: MethodKind.Unary,
53
- },
54
- }
55
- } as const;
56
-