@nomux-sh/extension 0.0.0-stage → 0.1.3
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/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +22 -0
- package/README.md +144 -2
- package/dist/api-version.d.ts +22 -0
- package/dist/api-version.js +48 -0
- package/dist/call.d.ts +12 -0
- package/dist/call.js +1 -0
- package/dist/codec.d.ts +22 -0
- package/dist/codec.js +5 -0
- package/dist/connection.d.ts +57 -0
- package/dist/connection.js +183 -0
- package/dist/error.d.ts +41 -0
- package/dist/error.js +61 -0
- package/dist/extension.d.ts +90 -0
- package/dist/extension.js +153 -0
- package/dist/frame.d.ts +32 -0
- package/dist/frame.js +99 -0
- package/dist/generated/nomux/extension/v1/call.d.ts +29 -0
- package/dist/generated/nomux/extension/v1/call.js +103 -0
- package/dist/generated/nomux/extension/v1/envelope.d.ts +176 -0
- package/dist/generated/nomux/extension/v1/envelope.js +476 -0
- package/dist/generated/nomux/extension/v1/handshake.d.ts +66 -0
- package/dist/generated/nomux/extension/v1/handshake.js +269 -0
- package/dist/generated/nomux/extension/v1/lifecycle.d.ts +36 -0
- package/dist/generated/nomux/extension/v1/lifecycle.js +205 -0
- package/dist/handshake.d.ts +21 -0
- package/dist/handshake.js +36 -0
- package/dist/host.d.ts +37 -0
- package/dist/host.js +73 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +16 -0
- package/dist/outbound.d.ts +16 -0
- package/dist/outbound.js +30 -0
- package/dist/pending-calls.d.ts +20 -0
- package/dist/pending-calls.js +43 -0
- package/package.json +53 -4
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.18.5
|
|
4
|
+
// protoc unknown
|
|
5
|
+
// source: nomux/extension/v1/call.proto
|
|
6
|
+
/* eslint-disable */
|
|
7
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
|
+
function createBaseCallRequest() {
|
|
9
|
+
return { method: "", payload: new Uint8Array(0) };
|
|
10
|
+
}
|
|
11
|
+
export const CallRequest = {
|
|
12
|
+
encode(message, writer = new BinaryWriter()) {
|
|
13
|
+
if (message.method !== "") {
|
|
14
|
+
writer.uint32(10).string(message.method);
|
|
15
|
+
}
|
|
16
|
+
if (message.payload.length !== 0) {
|
|
17
|
+
writer.uint32(18).bytes(message.payload);
|
|
18
|
+
}
|
|
19
|
+
return writer;
|
|
20
|
+
},
|
|
21
|
+
decode(input, length) {
|
|
22
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
23
|
+
const previousRecursionDepth = reader.__tsProtoDecodeDepth ?? 0;
|
|
24
|
+
if (previousRecursionDepth >= 100) {
|
|
25
|
+
throw new globalThis.Error("protobuf decode recursion limit exceeded");
|
|
26
|
+
}
|
|
27
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth + 1;
|
|
28
|
+
try {
|
|
29
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
30
|
+
const message = createBaseCallRequest();
|
|
31
|
+
while (reader.pos < end) {
|
|
32
|
+
const tag = reader.uint32();
|
|
33
|
+
switch (tag >>> 3) {
|
|
34
|
+
case 1: {
|
|
35
|
+
if (tag !== 10) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
message.method = reader.string();
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
case 2: {
|
|
42
|
+
if (tag !== 18) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
message.payload = reader.bytes();
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
reader.skip(tag & 7);
|
|
53
|
+
}
|
|
54
|
+
return message;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
function createBaseCallResponse() {
|
|
62
|
+
return { payload: new Uint8Array(0) };
|
|
63
|
+
}
|
|
64
|
+
export const CallResponse = {
|
|
65
|
+
encode(message, writer = new BinaryWriter()) {
|
|
66
|
+
if (message.payload.length !== 0) {
|
|
67
|
+
writer.uint32(10).bytes(message.payload);
|
|
68
|
+
}
|
|
69
|
+
return writer;
|
|
70
|
+
},
|
|
71
|
+
decode(input, length) {
|
|
72
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
73
|
+
const previousRecursionDepth = reader.__tsProtoDecodeDepth ?? 0;
|
|
74
|
+
if (previousRecursionDepth >= 100) {
|
|
75
|
+
throw new globalThis.Error("protobuf decode recursion limit exceeded");
|
|
76
|
+
}
|
|
77
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth + 1;
|
|
78
|
+
try {
|
|
79
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
80
|
+
const message = createBaseCallResponse();
|
|
81
|
+
while (reader.pos < end) {
|
|
82
|
+
const tag = reader.uint32();
|
|
83
|
+
switch (tag >>> 3) {
|
|
84
|
+
case 1: {
|
|
85
|
+
if (tag !== 10) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
message.payload = reader.bytes();
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
reader.skip(tag & 7);
|
|
96
|
+
}
|
|
97
|
+
return message;
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import { CallRequest, CallResponse } from "./call.js";
|
|
3
|
+
import { Hello, Welcome } from "./handshake.js";
|
|
4
|
+
import { HealthRequest, HealthResponse, InitializeRequest, InitializeResponse, ShutdownRequest, ShutdownResponse } from "./lifecycle.js";
|
|
5
|
+
/**
|
|
6
|
+
* The reason for a failed request.
|
|
7
|
+
*
|
|
8
|
+
* The values 1 to 5 are equal to the values of `ErrorCode` in the nomux
|
|
9
|
+
* control protocol (package `nomux.wire.v1`).
|
|
10
|
+
*/
|
|
11
|
+
export declare enum ErrorCode {
|
|
12
|
+
/**
|
|
13
|
+
* UNSPECIFIED - The sender did not set the field. The receiver treats this as
|
|
14
|
+
* `ERROR_CODE_FAILED`. The receiver does the same for a value that it does
|
|
15
|
+
* not know.
|
|
16
|
+
*/
|
|
17
|
+
UNSPECIFIED = 0,
|
|
18
|
+
/** FAILED - The request failed, and no other code gives the reason. */
|
|
19
|
+
FAILED = 1,
|
|
20
|
+
/** NOT_FOUND - The method or the item that the request names does not exist. */
|
|
21
|
+
NOT_FOUND = 2,
|
|
22
|
+
/** TIMEOUT - The receiver did not complete the request in the permitted time. */
|
|
23
|
+
TIMEOUT = 3,
|
|
24
|
+
/** PERMISSION_DENIED - The extension does not have the permission that the request needs. */
|
|
25
|
+
PERMISSION_DENIED = 4,
|
|
26
|
+
/**
|
|
27
|
+
* VERSION_INCOMPATIBLE - The host does not supply the extension API version that the extension
|
|
28
|
+
* needs. Only the reply to `Hello` uses this code.
|
|
29
|
+
*/
|
|
30
|
+
VERSION_INCOMPATIBLE = 5,
|
|
31
|
+
/** INVALID_ARGUMENT - The receiver cannot read the payload of the request. */
|
|
32
|
+
INVALID_ARGUMENT = 6,
|
|
33
|
+
/** CANCELLED - The receiver stopped the request because the sender sent `Cancel`. */
|
|
34
|
+
CANCELLED = 7,
|
|
35
|
+
UNRECOGNIZED = -1
|
|
36
|
+
}
|
|
37
|
+
/** The failure result of a request. */
|
|
38
|
+
export interface Error {
|
|
39
|
+
/** The reason for the failure. */
|
|
40
|
+
code: ErrorCode;
|
|
41
|
+
/**
|
|
42
|
+
* A message in English for the user. The text is not stable: a peer must
|
|
43
|
+
* not parse it.
|
|
44
|
+
*/
|
|
45
|
+
message: string;
|
|
46
|
+
}
|
|
47
|
+
/** A numbered request from one peer to the other peer. */
|
|
48
|
+
export interface Request {
|
|
49
|
+
/**
|
|
50
|
+
* The request number. The sender selects the value. The value is not 0 and
|
|
51
|
+
* is different from the `id` of each request of the same sender that has
|
|
52
|
+
* no response yet. Each peer has its own numbers.
|
|
53
|
+
*/
|
|
54
|
+
id: bigint;
|
|
55
|
+
/** The request body. See the field number plan at the top of this file. */
|
|
56
|
+
body: //
|
|
57
|
+
/** Handshake: the first request. Only the host sends it. */
|
|
58
|
+
{
|
|
59
|
+
$case: "hello";
|
|
60
|
+
value: Hello;
|
|
61
|
+
} | //
|
|
62
|
+
/** Life cycle: prepare for calls. Only the host sends it. */
|
|
63
|
+
{
|
|
64
|
+
$case: "initialize";
|
|
65
|
+
value: InitializeRequest;
|
|
66
|
+
} | //
|
|
67
|
+
/** Life cycle: stop. Only the host sends it. */
|
|
68
|
+
{
|
|
69
|
+
$case: "shutdown";
|
|
70
|
+
value: ShutdownRequest;
|
|
71
|
+
} | //
|
|
72
|
+
/** Life cycle: liveness check. Only the host sends it. */
|
|
73
|
+
{
|
|
74
|
+
$case: "health";
|
|
75
|
+
value: HealthRequest;
|
|
76
|
+
} | //
|
|
77
|
+
/**
|
|
78
|
+
* A call. The host calls a method of the extension, or the extension
|
|
79
|
+
* calls a method of a host service.
|
|
80
|
+
*/
|
|
81
|
+
{
|
|
82
|
+
$case: "call";
|
|
83
|
+
value: CallRequest;
|
|
84
|
+
} | undefined;
|
|
85
|
+
}
|
|
86
|
+
/** The response to one request. */
|
|
87
|
+
export interface Response {
|
|
88
|
+
/** The `id` of the request that this response answers. */
|
|
89
|
+
id: bigint;
|
|
90
|
+
/**
|
|
91
|
+
* The result of the request. See the field number plan at the top of this
|
|
92
|
+
* file.
|
|
93
|
+
*/
|
|
94
|
+
result: //
|
|
95
|
+
/** The request failed. */
|
|
96
|
+
{
|
|
97
|
+
$case: "error";
|
|
98
|
+
value: Error;
|
|
99
|
+
} | //
|
|
100
|
+
/** Handshake: the reply to `Hello`. */
|
|
101
|
+
{
|
|
102
|
+
$case: "welcome";
|
|
103
|
+
value: Welcome;
|
|
104
|
+
} | //
|
|
105
|
+
/** The reply to `InitializeRequest`. */
|
|
106
|
+
{
|
|
107
|
+
$case: "initialize";
|
|
108
|
+
value: InitializeResponse;
|
|
109
|
+
} | //
|
|
110
|
+
/** The reply to `ShutdownRequest`. */
|
|
111
|
+
{
|
|
112
|
+
$case: "shutdown";
|
|
113
|
+
value: ShutdownResponse;
|
|
114
|
+
} | //
|
|
115
|
+
/** The reply to `HealthRequest`. */
|
|
116
|
+
{
|
|
117
|
+
$case: "health";
|
|
118
|
+
value: HealthResponse;
|
|
119
|
+
} | //
|
|
120
|
+
/** The reply to `CallRequest`. */
|
|
121
|
+
{
|
|
122
|
+
$case: "call";
|
|
123
|
+
value: CallResponse;
|
|
124
|
+
} | undefined;
|
|
125
|
+
}
|
|
126
|
+
/** A message from the extension that no request asked for. */
|
|
127
|
+
export interface Event {
|
|
128
|
+
/**
|
|
129
|
+
* The name of the event. The extension selects the name. The host adds the
|
|
130
|
+
* identifier of the extension, thus two extensions can use the same name.
|
|
131
|
+
*/
|
|
132
|
+
name: string;
|
|
133
|
+
/** The data of the event. The host does not read it. */
|
|
134
|
+
payload: Uint8Array;
|
|
135
|
+
}
|
|
136
|
+
/** Tells the receiver to stop a request. */
|
|
137
|
+
export interface Cancel {
|
|
138
|
+
/** The `id` of a request that the sender of this message sent before. */
|
|
139
|
+
id: bigint;
|
|
140
|
+
}
|
|
141
|
+
/** One message between the host and the extension. */
|
|
142
|
+
export interface Envelope {
|
|
143
|
+
/** The content of the envelope. */
|
|
144
|
+
kind: //
|
|
145
|
+
/** A request. */
|
|
146
|
+
{
|
|
147
|
+
$case: "request";
|
|
148
|
+
value: Request;
|
|
149
|
+
} | //
|
|
150
|
+
/** The response to a request of the other peer. */
|
|
151
|
+
{
|
|
152
|
+
$case: "response";
|
|
153
|
+
value: Response;
|
|
154
|
+
} | //
|
|
155
|
+
/** An event from the extension. */
|
|
156
|
+
{
|
|
157
|
+
$case: "event";
|
|
158
|
+
value: Event;
|
|
159
|
+
} | //
|
|
160
|
+
/** The cancellation of a request. */
|
|
161
|
+
{
|
|
162
|
+
$case: "cancel";
|
|
163
|
+
value: Cancel;
|
|
164
|
+
} | undefined;
|
|
165
|
+
}
|
|
166
|
+
export declare const Error: MessageFns<Error>;
|
|
167
|
+
export declare const Request: MessageFns<Request>;
|
|
168
|
+
export declare const Response: MessageFns<Response>;
|
|
169
|
+
export declare const Event: MessageFns<Event>;
|
|
170
|
+
export declare const Cancel: MessageFns<Cancel>;
|
|
171
|
+
export declare const Envelope: MessageFns<Envelope>;
|
|
172
|
+
interface MessageFns<T> {
|
|
173
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
174
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
175
|
+
}
|
|
176
|
+
export {};
|