@novasamatech/host-api 0.5.0-18 → 0.5.0-19
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/README.md +103 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/helpers.d.ts +33 -0
- package/dist/helpers.js +46 -0
- package/dist/hostApi.d.ts +31 -0
- package/dist/hostApi.js +345 -0
- package/dist/index.d.ts +18 -7
- package/dist/index.js +14 -6
- package/dist/protocol/commonCodecs.d.ts +42 -0
- package/dist/protocol/commonCodecs.js +64 -0
- package/dist/protocol/commonCodecs.spec.js +72 -0
- package/dist/protocol/impl.d.ts +93 -0
- package/dist/protocol/impl.js +97 -0
- package/dist/protocol/messageCodec.d.ts +1245 -0
- package/dist/protocol/messageCodec.js +24 -0
- package/dist/protocol/types.js +1 -0
- package/dist/protocol/v1/accounts.d.ts +265 -0
- package/dist/{interactions → protocol}/v1/accounts.js +11 -11
- package/dist/{interactions → protocol}/v1/chat.d.ts +129 -83
- package/dist/{interactions → protocol}/v1/chat.js +12 -14
- package/dist/{interactions → protocol}/v1/createTransaction.d.ts +119 -78
- package/dist/protocol/v1/createTransaction.js +58 -0
- package/dist/{interactions → protocol}/v1/feature.d.ts +8 -4
- package/dist/protocol/v1/feature.js +7 -0
- package/dist/protocol/v1/handshake.d.ts +85 -0
- package/dist/protocol/v1/handshake.js +12 -0
- package/dist/{interactions → protocol}/v1/jsonRpc.d.ts +6 -2
- package/dist/{interactions → protocol}/v1/jsonRpc.js +2 -2
- package/dist/protocol/v1/permission.d.ts +90 -0
- package/dist/protocol/v1/permission.js +18 -0
- package/dist/protocol/v1/sign.d.ts +152 -0
- package/dist/{interactions → protocol}/v1/sign.js +6 -6
- package/dist/{interactions → protocol}/v1/statementStore.d.ts +77 -20
- package/dist/{interactions → protocol}/v1/statementStore.js +6 -6
- package/dist/protocol/v1/storage.d.ts +87 -0
- package/dist/{interactions → protocol}/v1/storage.js +5 -5
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +1 -0
- package/dist/transport.d.ts +3 -0
- package/dist/transport.js +248 -0
- package/dist/types.d.ts +15 -15
- package/package.json +2 -4
- package/dist/commonEncoders.d.ts +0 -2
- package/dist/commonEncoders.js +0 -8
- package/dist/createTransport.d.ts +0 -6
- package/dist/createTransport.js +0 -183
- package/dist/createTransportEncoder.d.ts +0 -7
- package/dist/createTransportEncoder.js +0 -5
- package/dist/interactions/accounts.d.ts +0 -12
- package/dist/interactions/accounts.js +0 -40
- package/dist/interactions/commonCodecs.d.ts +0 -7
- package/dist/interactions/commonCodecs.js +0 -8
- package/dist/interactions/features.d.ts +0 -13
- package/dist/interactions/features.js +0 -13
- package/dist/interactions/handshake.d.ts +0 -2
- package/dist/interactions/handshake.js +0 -3
- package/dist/interactions/message.d.ts +0 -1704
- package/dist/interactions/message.js +0 -60
- package/dist/interactions/papiProvider.d.ts +0 -8
- package/dist/interactions/papiProvider.js +0 -10
- package/dist/interactions/sign.d.ts +0 -118
- package/dist/interactions/sign.js +0 -127
- package/dist/interactions/v1/accounts.d.ts +0 -128
- package/dist/interactions/v1/createTransaction.js +0 -41
- package/dist/interactions/v1/feature.js +0 -7
- package/dist/interactions/v1/handshake.d.ts +0 -28
- package/dist/interactions/v1/handshake.js +0 -12
- package/dist/interactions/v1/permission.d.ts +0 -48
- package/dist/interactions/v1/permission.js +0 -18
- package/dist/interactions/v1/sign.d.ts +0 -92
- package/dist/interactions/v1/storage.d.ts +0 -41
- package/dist/messageEncoder.d.ts +0 -178
- package/dist/messageEncoder.js +0 -34
- /package/dist/{interactions/types.js → protocol/commonCodecs.spec.d.ts} +0 -0
- /package/dist/{interactions → protocol}/types.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Struct, _void, str } from 'scale-ts';
|
|
2
|
+
import { Enum } from './commonCodecs.js';
|
|
3
|
+
import { hostApiProtocol } from './impl.js';
|
|
4
|
+
const createPayload = (hostApi) => {
|
|
5
|
+
const fields = {};
|
|
6
|
+
for (const [method, payload] of Object.entries(hostApi)) {
|
|
7
|
+
if (payload.type === 'request') {
|
|
8
|
+
fields[`${method}_request`] = payload.request;
|
|
9
|
+
fields[`${method}_response`] = payload.response;
|
|
10
|
+
}
|
|
11
|
+
if (payload.type === 'subscription') {
|
|
12
|
+
fields[`${method}_start`] = payload.start;
|
|
13
|
+
fields[`${method}_stop`] = _void;
|
|
14
|
+
fields[`${method}_interrupt`] = _void;
|
|
15
|
+
fields[`${method}_receive`] = payload.receive;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return Enum(fields);
|
|
19
|
+
};
|
|
20
|
+
export const MessagePayload = createPayload(hostApiProtocol);
|
|
21
|
+
export const Message = Struct({
|
|
22
|
+
requestId: str,
|
|
23
|
+
payload: MessagePayload,
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
export declare const AccountId: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
2
|
+
export declare const PublicKey: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
3
|
+
export declare const DotNsIdentifier: import("scale-ts").Codec<string>;
|
|
4
|
+
export declare const DerivationIndex: import("scale-ts").Codec<number>;
|
|
5
|
+
export declare const ProductAccountId: import("scale-ts").Codec<[string, number]>;
|
|
6
|
+
export declare const RingVrfProof: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
7
|
+
export declare const RingVrgAlias: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
8
|
+
export declare const Account: import("scale-ts").Codec<{
|
|
9
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
10
|
+
name: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const ContextualAlias: import("scale-ts").Codec<{
|
|
13
|
+
context: Uint8Array<ArrayBufferLike>;
|
|
14
|
+
alias: Uint8Array<ArrayBufferLike>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const RingLocationHint: import("scale-ts").Codec<{
|
|
17
|
+
palletInstance: number | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const RingLocation: import("scale-ts").Codec<{
|
|
20
|
+
genesisHash: `0x${string}`;
|
|
21
|
+
ringRootHash: `0x${string}`;
|
|
22
|
+
hints: {
|
|
23
|
+
palletInstance: number | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const RequestCredentialsErr: [import("scale-ts").Encoder<(Error & {
|
|
27
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
28
|
+
className: string;
|
|
29
|
+
payload: undefined;
|
|
30
|
+
}) | (Error & {
|
|
31
|
+
name: "RequestCredentialsErr::Rejected";
|
|
32
|
+
className: string;
|
|
33
|
+
payload: undefined;
|
|
34
|
+
}) | (Error & {
|
|
35
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
36
|
+
className: string;
|
|
37
|
+
payload: undefined;
|
|
38
|
+
}) | (Error & {
|
|
39
|
+
name: "RequestCredentialsErr::Unknown";
|
|
40
|
+
className: string;
|
|
41
|
+
payload: {
|
|
42
|
+
reason: string;
|
|
43
|
+
};
|
|
44
|
+
})>, import("scale-ts").Decoder<(Error & {
|
|
45
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
46
|
+
className: string;
|
|
47
|
+
payload: undefined;
|
|
48
|
+
}) | (Error & {
|
|
49
|
+
name: "RequestCredentialsErr::Rejected";
|
|
50
|
+
className: string;
|
|
51
|
+
payload: undefined;
|
|
52
|
+
}) | (Error & {
|
|
53
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
54
|
+
className: string;
|
|
55
|
+
payload: undefined;
|
|
56
|
+
}) | (Error & {
|
|
57
|
+
name: "RequestCredentialsErr::Unknown";
|
|
58
|
+
className: string;
|
|
59
|
+
payload: {
|
|
60
|
+
reason: string;
|
|
61
|
+
};
|
|
62
|
+
})>] & {
|
|
63
|
+
enc: import("scale-ts").Encoder<(Error & {
|
|
64
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
65
|
+
className: string;
|
|
66
|
+
payload: undefined;
|
|
67
|
+
}) | (Error & {
|
|
68
|
+
name: "RequestCredentialsErr::Rejected";
|
|
69
|
+
className: string;
|
|
70
|
+
payload: undefined;
|
|
71
|
+
}) | (Error & {
|
|
72
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
73
|
+
className: string;
|
|
74
|
+
payload: undefined;
|
|
75
|
+
}) | (Error & {
|
|
76
|
+
name: "RequestCredentialsErr::Unknown";
|
|
77
|
+
className: string;
|
|
78
|
+
payload: {
|
|
79
|
+
reason: string;
|
|
80
|
+
};
|
|
81
|
+
})>;
|
|
82
|
+
dec: import("scale-ts").Decoder<(Error & {
|
|
83
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
84
|
+
className: string;
|
|
85
|
+
payload: undefined;
|
|
86
|
+
}) | (Error & {
|
|
87
|
+
name: "RequestCredentialsErr::Rejected";
|
|
88
|
+
className: string;
|
|
89
|
+
payload: undefined;
|
|
90
|
+
}) | (Error & {
|
|
91
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
92
|
+
className: string;
|
|
93
|
+
payload: undefined;
|
|
94
|
+
}) | (Error & {
|
|
95
|
+
name: "RequestCredentialsErr::Unknown";
|
|
96
|
+
className: string;
|
|
97
|
+
payload: {
|
|
98
|
+
reason: string;
|
|
99
|
+
};
|
|
100
|
+
})>;
|
|
101
|
+
} & {
|
|
102
|
+
readonly NotConnected: import("../commonCodecs.js").ErrCodec<undefined, "RequestCredentialsErr::NotConnected">;
|
|
103
|
+
readonly Rejected: import("../commonCodecs.js").ErrCodec<undefined, "RequestCredentialsErr::Rejected">;
|
|
104
|
+
readonly DomainNotValid: import("../commonCodecs.js").ErrCodec<undefined, "RequestCredentialsErr::DomainNotValid">;
|
|
105
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
106
|
+
reason: string;
|
|
107
|
+
}, "RequestCredentialsErr::Unknown">;
|
|
108
|
+
};
|
|
109
|
+
export declare const CreateProofErr: [import("scale-ts").Encoder<(Error & {
|
|
110
|
+
name: "CreateProofErr::Rejected";
|
|
111
|
+
className: string;
|
|
112
|
+
payload: undefined;
|
|
113
|
+
}) | (Error & {
|
|
114
|
+
name: "CreateProofErr::Unknown";
|
|
115
|
+
className: string;
|
|
116
|
+
payload: {
|
|
117
|
+
reason: string;
|
|
118
|
+
};
|
|
119
|
+
}) | (Error & {
|
|
120
|
+
name: "CreateProofErr::RingNotFound";
|
|
121
|
+
className: string;
|
|
122
|
+
payload: undefined;
|
|
123
|
+
})>, import("scale-ts").Decoder<(Error & {
|
|
124
|
+
name: "CreateProofErr::Rejected";
|
|
125
|
+
className: string;
|
|
126
|
+
payload: undefined;
|
|
127
|
+
}) | (Error & {
|
|
128
|
+
name: "CreateProofErr::Unknown";
|
|
129
|
+
className: string;
|
|
130
|
+
payload: {
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
}) | (Error & {
|
|
134
|
+
name: "CreateProofErr::RingNotFound";
|
|
135
|
+
className: string;
|
|
136
|
+
payload: undefined;
|
|
137
|
+
})>] & {
|
|
138
|
+
enc: import("scale-ts").Encoder<(Error & {
|
|
139
|
+
name: "CreateProofErr::Rejected";
|
|
140
|
+
className: string;
|
|
141
|
+
payload: undefined;
|
|
142
|
+
}) | (Error & {
|
|
143
|
+
name: "CreateProofErr::Unknown";
|
|
144
|
+
className: string;
|
|
145
|
+
payload: {
|
|
146
|
+
reason: string;
|
|
147
|
+
};
|
|
148
|
+
}) | (Error & {
|
|
149
|
+
name: "CreateProofErr::RingNotFound";
|
|
150
|
+
className: string;
|
|
151
|
+
payload: undefined;
|
|
152
|
+
})>;
|
|
153
|
+
dec: import("scale-ts").Decoder<(Error & {
|
|
154
|
+
name: "CreateProofErr::Rejected";
|
|
155
|
+
className: string;
|
|
156
|
+
payload: undefined;
|
|
157
|
+
}) | (Error & {
|
|
158
|
+
name: "CreateProofErr::Unknown";
|
|
159
|
+
className: string;
|
|
160
|
+
payload: {
|
|
161
|
+
reason: string;
|
|
162
|
+
};
|
|
163
|
+
}) | (Error & {
|
|
164
|
+
name: "CreateProofErr::RingNotFound";
|
|
165
|
+
className: string;
|
|
166
|
+
payload: undefined;
|
|
167
|
+
})>;
|
|
168
|
+
} & {
|
|
169
|
+
readonly RingNotFound: import("../commonCodecs.js").ErrCodec<undefined, "CreateProofErr::RingNotFound">;
|
|
170
|
+
readonly Rejected: import("../commonCodecs.js").ErrCodec<undefined, "CreateProofErr::Rejected">;
|
|
171
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
172
|
+
reason: string;
|
|
173
|
+
}, "CreateProofErr::Unknown">;
|
|
174
|
+
};
|
|
175
|
+
export declare const AccountGetV1_request: import("scale-ts").Codec<[string, number]>;
|
|
176
|
+
export declare const AccountGetV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
177
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
178
|
+
name: string | undefined;
|
|
179
|
+
}, (Error & {
|
|
180
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
181
|
+
className: string;
|
|
182
|
+
payload: undefined;
|
|
183
|
+
}) | (Error & {
|
|
184
|
+
name: "RequestCredentialsErr::Rejected";
|
|
185
|
+
className: string;
|
|
186
|
+
payload: undefined;
|
|
187
|
+
}) | (Error & {
|
|
188
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
189
|
+
className: string;
|
|
190
|
+
payload: undefined;
|
|
191
|
+
}) | (Error & {
|
|
192
|
+
name: "RequestCredentialsErr::Unknown";
|
|
193
|
+
className: string;
|
|
194
|
+
payload: {
|
|
195
|
+
reason: string;
|
|
196
|
+
};
|
|
197
|
+
})>>;
|
|
198
|
+
export declare const AccountGetAliasV1_request: import("scale-ts").Codec<[string, number]>;
|
|
199
|
+
export declare const AccountGetAliasV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
200
|
+
context: Uint8Array<ArrayBufferLike>;
|
|
201
|
+
alias: Uint8Array<ArrayBufferLike>;
|
|
202
|
+
}, (Error & {
|
|
203
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
204
|
+
className: string;
|
|
205
|
+
payload: undefined;
|
|
206
|
+
}) | (Error & {
|
|
207
|
+
name: "RequestCredentialsErr::Rejected";
|
|
208
|
+
className: string;
|
|
209
|
+
payload: undefined;
|
|
210
|
+
}) | (Error & {
|
|
211
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
212
|
+
className: string;
|
|
213
|
+
payload: undefined;
|
|
214
|
+
}) | (Error & {
|
|
215
|
+
name: "RequestCredentialsErr::Unknown";
|
|
216
|
+
className: string;
|
|
217
|
+
payload: {
|
|
218
|
+
reason: string;
|
|
219
|
+
};
|
|
220
|
+
})>>;
|
|
221
|
+
export declare const AccountCreateProofV1_request: import("scale-ts").Codec<[[string, number], {
|
|
222
|
+
genesisHash: `0x${string}`;
|
|
223
|
+
ringRootHash: `0x${string}`;
|
|
224
|
+
hints: {
|
|
225
|
+
palletInstance: number | undefined;
|
|
226
|
+
} | undefined;
|
|
227
|
+
}, Uint8Array<ArrayBufferLike>]>;
|
|
228
|
+
export declare const AccountCreateProofV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, (Error & {
|
|
229
|
+
name: "CreateProofErr::Rejected";
|
|
230
|
+
className: string;
|
|
231
|
+
payload: undefined;
|
|
232
|
+
}) | (Error & {
|
|
233
|
+
name: "CreateProofErr::Unknown";
|
|
234
|
+
className: string;
|
|
235
|
+
payload: {
|
|
236
|
+
reason: string;
|
|
237
|
+
};
|
|
238
|
+
}) | (Error & {
|
|
239
|
+
name: "CreateProofErr::RingNotFound";
|
|
240
|
+
className: string;
|
|
241
|
+
payload: undefined;
|
|
242
|
+
})>>;
|
|
243
|
+
export declare const GetNonProductAccountsV1_request: import("scale-ts").Codec<undefined>;
|
|
244
|
+
export declare const GetNonProductAccountsV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
245
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
246
|
+
name: string | undefined;
|
|
247
|
+
}[], (Error & {
|
|
248
|
+
name: "RequestCredentialsErr::NotConnected";
|
|
249
|
+
className: string;
|
|
250
|
+
payload: undefined;
|
|
251
|
+
}) | (Error & {
|
|
252
|
+
name: "RequestCredentialsErr::Rejected";
|
|
253
|
+
className: string;
|
|
254
|
+
payload: undefined;
|
|
255
|
+
}) | (Error & {
|
|
256
|
+
name: "RequestCredentialsErr::DomainNotValid";
|
|
257
|
+
className: string;
|
|
258
|
+
payload: undefined;
|
|
259
|
+
}) | (Error & {
|
|
260
|
+
name: "RequestCredentialsErr::Unknown";
|
|
261
|
+
className: string;
|
|
262
|
+
payload: {
|
|
263
|
+
reason: string;
|
|
264
|
+
};
|
|
265
|
+
})>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bytes,
|
|
2
|
-
import { GenericErr, GenesisHash, Hex } from '../commonCodecs.js';
|
|
1
|
+
import { Bytes, Option, Result, Struct, Tuple, Vector, _void, str, u32 } from 'scale-ts';
|
|
2
|
+
import { ErrEnum, GenericErr, GenesisHash, Hex } from '../commonCodecs.js';
|
|
3
3
|
// common types
|
|
4
4
|
export const AccountId = Bytes(32);
|
|
5
5
|
export const PublicKey = Bytes();
|
|
@@ -26,16 +26,16 @@ export const RingLocation = Struct({
|
|
|
26
26
|
hints: Option(RingLocationHint),
|
|
27
27
|
});
|
|
28
28
|
// errors
|
|
29
|
-
export const RequestCredentialsErr =
|
|
30
|
-
NotConnected: _void,
|
|
31
|
-
Rejected: _void,
|
|
32
|
-
DomainNotValid: _void,
|
|
33
|
-
Unknown: GenericErr,
|
|
29
|
+
export const RequestCredentialsErr = ErrEnum('RequestCredentialsErr', {
|
|
30
|
+
NotConnected: [_void, 'RequestCredentials: not connected'],
|
|
31
|
+
Rejected: [_void, 'RequestCredentials: rejected'],
|
|
32
|
+
DomainNotValid: [_void, 'RequestCredentials: domain not valid'],
|
|
33
|
+
Unknown: [GenericErr, 'RequestCredentials: unknown error'],
|
|
34
34
|
});
|
|
35
|
-
export const CreateProofErr =
|
|
36
|
-
RingNotFound: _void,
|
|
37
|
-
Rejected: _void,
|
|
38
|
-
Unknown: GenericErr,
|
|
35
|
+
export const CreateProofErr = ErrEnum('CreateProofErr', {
|
|
36
|
+
RingNotFound: [_void, 'CreateProof: ring not found'],
|
|
37
|
+
Rejected: [_void, 'CreateProof: rejected'],
|
|
38
|
+
Unknown: [GenericErr, 'CreateProof: unknown error'],
|
|
39
39
|
});
|
|
40
40
|
// account_get
|
|
41
41
|
export const AccountGetV1_request = ProductAccountId;
|
|
@@ -1,9 +1,36 @@
|
|
|
1
|
-
export declare const ChatContactRegistrationErr: import("scale-ts").
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const ChatContactRegistrationErr: [import("scale-ts").Encoder<Error & {
|
|
2
|
+
name: "ChatContactRegistrationErr::Unknown";
|
|
3
|
+
className: string;
|
|
4
|
+
payload: {
|
|
4
5
|
reason: string;
|
|
5
6
|
};
|
|
6
|
-
}
|
|
7
|
+
}>, import("scale-ts").Decoder<Error & {
|
|
8
|
+
name: "ChatContactRegistrationErr::Unknown";
|
|
9
|
+
className: string;
|
|
10
|
+
payload: {
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
}>] & {
|
|
14
|
+
enc: import("scale-ts").Encoder<Error & {
|
|
15
|
+
name: "ChatContactRegistrationErr::Unknown";
|
|
16
|
+
className: string;
|
|
17
|
+
payload: {
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
dec: import("scale-ts").Decoder<Error & {
|
|
22
|
+
name: "ChatContactRegistrationErr::Unknown";
|
|
23
|
+
className: string;
|
|
24
|
+
payload: {
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
} & {
|
|
29
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
30
|
+
reason: string;
|
|
31
|
+
}, "ChatContactRegistrationErr::Unknown">;
|
|
32
|
+
};
|
|
33
|
+
export declare const ChatContactRegistrationStatus: import("scale-ts").Codec<"New" | "Exists">;
|
|
7
34
|
export declare const ChatContact: import("scale-ts").Codec<{
|
|
8
35
|
name: string;
|
|
9
36
|
icon: string;
|
|
@@ -12,9 +39,10 @@ export declare const ChatCreateContactV1_request: import("scale-ts").Codec<{
|
|
|
12
39
|
name: string;
|
|
13
40
|
icon: string;
|
|
14
41
|
}>;
|
|
15
|
-
export declare const ChatCreateContactV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<
|
|
16
|
-
|
|
17
|
-
|
|
42
|
+
export declare const ChatCreateContactV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<"New" | "Exists", Error & {
|
|
43
|
+
name: "ChatContactRegistrationErr::Unknown";
|
|
44
|
+
className: string;
|
|
45
|
+
payload: {
|
|
18
46
|
reason: string;
|
|
19
47
|
};
|
|
20
48
|
}>>;
|
|
@@ -22,26 +50,14 @@ export declare const ChatAction: import("scale-ts").Codec<{
|
|
|
22
50
|
actionId: string;
|
|
23
51
|
title: string;
|
|
24
52
|
}>;
|
|
25
|
-
export declare const ChatActionLayout: import("scale-ts").Codec<
|
|
26
|
-
tag: "Column";
|
|
27
|
-
value: undefined;
|
|
28
|
-
} | {
|
|
29
|
-
tag: "Grid";
|
|
30
|
-
value: undefined;
|
|
31
|
-
}>;
|
|
53
|
+
export declare const ChatActionLayout: import("scale-ts").Codec<"Column" | "Grid">;
|
|
32
54
|
export declare const ChatActions: import("scale-ts").Codec<{
|
|
33
55
|
text: string | undefined;
|
|
34
56
|
actions: {
|
|
35
57
|
actionId: string;
|
|
36
58
|
title: string;
|
|
37
59
|
}[];
|
|
38
|
-
layout:
|
|
39
|
-
tag: "Column";
|
|
40
|
-
value: undefined;
|
|
41
|
-
} | {
|
|
42
|
-
tag: "Grid";
|
|
43
|
-
value: undefined;
|
|
44
|
-
};
|
|
60
|
+
layout: "Column" | "Grid";
|
|
45
61
|
}>;
|
|
46
62
|
export declare const ChatMedia: import("scale-ts").Codec<{
|
|
47
63
|
url: string;
|
|
@@ -66,6 +82,14 @@ export declare const ChatReaction: import("scale-ts").Codec<{
|
|
|
66
82
|
export declare const ChatMessage: import("scale-ts").Codec<{
|
|
67
83
|
tag: "Text";
|
|
68
84
|
value: string;
|
|
85
|
+
} | {
|
|
86
|
+
tag: "RichText";
|
|
87
|
+
value: {
|
|
88
|
+
text: string | undefined;
|
|
89
|
+
media: {
|
|
90
|
+
url: string;
|
|
91
|
+
}[];
|
|
92
|
+
};
|
|
69
93
|
} | {
|
|
70
94
|
tag: "Actions";
|
|
71
95
|
value: {
|
|
@@ -74,18 +98,7 @@ export declare const ChatMessage: import("scale-ts").Codec<{
|
|
|
74
98
|
actionId: string;
|
|
75
99
|
title: string;
|
|
76
100
|
}[];
|
|
77
|
-
layout:
|
|
78
|
-
tag: "Column";
|
|
79
|
-
value: undefined;
|
|
80
|
-
} | {
|
|
81
|
-
tag: "Grid";
|
|
82
|
-
value: undefined;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
} | {
|
|
86
|
-
tag: "RichText";
|
|
87
|
-
value: {
|
|
88
|
-
url: string;
|
|
101
|
+
layout: "Column" | "Grid";
|
|
89
102
|
};
|
|
90
103
|
} | {
|
|
91
104
|
tag: "File";
|
|
@@ -109,21 +122,69 @@ export declare const ChatMessage: import("scale-ts").Codec<{
|
|
|
109
122
|
emoji: string;
|
|
110
123
|
};
|
|
111
124
|
}>;
|
|
112
|
-
export declare const ChatMessagePostingErr: import("scale-ts").
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
export declare const ChatMessagePostingErr: [import("scale-ts").Encoder<(Error & {
|
|
126
|
+
name: "ChatMessagePostingErr::Unknown";
|
|
127
|
+
className: string;
|
|
128
|
+
payload: {
|
|
115
129
|
reason: string;
|
|
116
130
|
};
|
|
117
|
-
} | {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
}) | (Error & {
|
|
132
|
+
name: "ChatMessagePostingErr::MessageTooLarge";
|
|
133
|
+
className: string;
|
|
134
|
+
payload: undefined;
|
|
135
|
+
})>, import("scale-ts").Decoder<(Error & {
|
|
136
|
+
name: "ChatMessagePostingErr::Unknown";
|
|
137
|
+
className: string;
|
|
138
|
+
payload: {
|
|
139
|
+
reason: string;
|
|
140
|
+
};
|
|
141
|
+
}) | (Error & {
|
|
142
|
+
name: "ChatMessagePostingErr::MessageTooLarge";
|
|
143
|
+
className: string;
|
|
144
|
+
payload: undefined;
|
|
145
|
+
})>] & {
|
|
146
|
+
enc: import("scale-ts").Encoder<(Error & {
|
|
147
|
+
name: "ChatMessagePostingErr::Unknown";
|
|
148
|
+
className: string;
|
|
149
|
+
payload: {
|
|
150
|
+
reason: string;
|
|
151
|
+
};
|
|
152
|
+
}) | (Error & {
|
|
153
|
+
name: "ChatMessagePostingErr::MessageTooLarge";
|
|
154
|
+
className: string;
|
|
155
|
+
payload: undefined;
|
|
156
|
+
})>;
|
|
157
|
+
dec: import("scale-ts").Decoder<(Error & {
|
|
158
|
+
name: "ChatMessagePostingErr::Unknown";
|
|
159
|
+
className: string;
|
|
160
|
+
payload: {
|
|
161
|
+
reason: string;
|
|
162
|
+
};
|
|
163
|
+
}) | (Error & {
|
|
164
|
+
name: "ChatMessagePostingErr::MessageTooLarge";
|
|
165
|
+
className: string;
|
|
166
|
+
payload: undefined;
|
|
167
|
+
})>;
|
|
168
|
+
} & {
|
|
169
|
+
readonly MessageTooLarge: import("../commonCodecs.js").ErrCodec<undefined, "ChatMessagePostingErr::MessageTooLarge">;
|
|
170
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
171
|
+
reason: string;
|
|
172
|
+
}, "ChatMessagePostingErr::Unknown">;
|
|
173
|
+
};
|
|
121
174
|
export declare const ChatPostMessageResult: import("scale-ts").Codec<{
|
|
122
175
|
messageId: string;
|
|
123
176
|
}>;
|
|
124
177
|
export declare const ChatPostMessageV1_request: import("scale-ts").Codec<{
|
|
125
178
|
tag: "Text";
|
|
126
179
|
value: string;
|
|
180
|
+
} | {
|
|
181
|
+
tag: "RichText";
|
|
182
|
+
value: {
|
|
183
|
+
text: string | undefined;
|
|
184
|
+
media: {
|
|
185
|
+
url: string;
|
|
186
|
+
}[];
|
|
187
|
+
};
|
|
127
188
|
} | {
|
|
128
189
|
tag: "Actions";
|
|
129
190
|
value: {
|
|
@@ -132,18 +193,7 @@ export declare const ChatPostMessageV1_request: import("scale-ts").Codec<{
|
|
|
132
193
|
actionId: string;
|
|
133
194
|
title: string;
|
|
134
195
|
}[];
|
|
135
|
-
layout:
|
|
136
|
-
tag: "Column";
|
|
137
|
-
value: undefined;
|
|
138
|
-
} | {
|
|
139
|
-
tag: "Grid";
|
|
140
|
-
value: undefined;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
} | {
|
|
144
|
-
tag: "RichText";
|
|
145
|
-
value: {
|
|
146
|
-
url: string;
|
|
196
|
+
layout: "Column" | "Grid";
|
|
147
197
|
};
|
|
148
198
|
} | {
|
|
149
199
|
tag: "File";
|
|
@@ -169,15 +219,17 @@ export declare const ChatPostMessageV1_request: import("scale-ts").Codec<{
|
|
|
169
219
|
}>;
|
|
170
220
|
export declare const ChatPostMessageV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
171
221
|
messageId: string;
|
|
172
|
-
}, {
|
|
173
|
-
|
|
174
|
-
|
|
222
|
+
}, (Error & {
|
|
223
|
+
name: "ChatMessagePostingErr::Unknown";
|
|
224
|
+
className: string;
|
|
225
|
+
payload: {
|
|
175
226
|
reason: string;
|
|
176
227
|
};
|
|
177
|
-
} | {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
228
|
+
}) | (Error & {
|
|
229
|
+
name: "ChatMessagePostingErr::MessageTooLarge";
|
|
230
|
+
className: string;
|
|
231
|
+
payload: undefined;
|
|
232
|
+
})>>;
|
|
181
233
|
export declare const ActionTrigger: import("scale-ts").Codec<{
|
|
182
234
|
messageId: string;
|
|
183
235
|
actionId: string;
|
|
@@ -187,6 +239,14 @@ export declare const ReceivedChatAction: import("scale-ts").Codec<{
|
|
|
187
239
|
value: {
|
|
188
240
|
tag: "Text";
|
|
189
241
|
value: string;
|
|
242
|
+
} | {
|
|
243
|
+
tag: "RichText";
|
|
244
|
+
value: {
|
|
245
|
+
text: string | undefined;
|
|
246
|
+
media: {
|
|
247
|
+
url: string;
|
|
248
|
+
}[];
|
|
249
|
+
};
|
|
190
250
|
} | {
|
|
191
251
|
tag: "Actions";
|
|
192
252
|
value: {
|
|
@@ -195,18 +255,7 @@ export declare const ReceivedChatAction: import("scale-ts").Codec<{
|
|
|
195
255
|
actionId: string;
|
|
196
256
|
title: string;
|
|
197
257
|
}[];
|
|
198
|
-
layout:
|
|
199
|
-
tag: "Column";
|
|
200
|
-
value: undefined;
|
|
201
|
-
} | {
|
|
202
|
-
tag: "Grid";
|
|
203
|
-
value: undefined;
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
} | {
|
|
207
|
-
tag: "RichText";
|
|
208
|
-
value: {
|
|
209
|
-
url: string;
|
|
258
|
+
layout: "Column" | "Grid";
|
|
210
259
|
};
|
|
211
260
|
} | {
|
|
212
261
|
tag: "File";
|
|
@@ -243,6 +292,14 @@ export declare const ChatActionSubscribeV1_receive: import("scale-ts").Codec<{
|
|
|
243
292
|
value: {
|
|
244
293
|
tag: "Text";
|
|
245
294
|
value: string;
|
|
295
|
+
} | {
|
|
296
|
+
tag: "RichText";
|
|
297
|
+
value: {
|
|
298
|
+
text: string | undefined;
|
|
299
|
+
media: {
|
|
300
|
+
url: string;
|
|
301
|
+
}[];
|
|
302
|
+
};
|
|
246
303
|
} | {
|
|
247
304
|
tag: "Actions";
|
|
248
305
|
value: {
|
|
@@ -251,18 +308,7 @@ export declare const ChatActionSubscribeV1_receive: import("scale-ts").Codec<{
|
|
|
251
308
|
actionId: string;
|
|
252
309
|
title: string;
|
|
253
310
|
}[];
|
|
254
|
-
layout:
|
|
255
|
-
tag: "Column";
|
|
256
|
-
value: undefined;
|
|
257
|
-
} | {
|
|
258
|
-
tag: "Grid";
|
|
259
|
-
value: undefined;
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
} | {
|
|
263
|
-
tag: "RichText";
|
|
264
|
-
value: {
|
|
265
|
-
url: string;
|
|
311
|
+
layout: "Column" | "Grid";
|
|
266
312
|
};
|
|
267
313
|
} | {
|
|
268
314
|
tag: "File";
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GenericErr } from '../commonCodecs.js';
|
|
1
|
+
import { Option, Result, Struct, Vector, _void, str, u64 } from 'scale-ts';
|
|
2
|
+
import { Enum, ErrEnum, GenericErr, Status } from '../commonCodecs.js';
|
|
3
3
|
// contact
|
|
4
|
-
export const ChatContactRegistrationErr =
|
|
5
|
-
Unknown: GenericErr,
|
|
4
|
+
export const ChatContactRegistrationErr = ErrEnum('ChatContactRegistrationErr', {
|
|
5
|
+
Unknown: [GenericErr, 'Unknown error while chat registration'],
|
|
6
6
|
});
|
|
7
|
+
export const ChatContactRegistrationStatus = Status('New', 'Exists');
|
|
7
8
|
export const ChatContact = Struct({
|
|
8
9
|
name: str,
|
|
9
10
|
icon: str, // url or base64 encoded image for contact
|
|
10
11
|
});
|
|
11
12
|
export const ChatCreateContactV1_request = ChatContact;
|
|
12
|
-
export const ChatCreateContactV1_response = Result(
|
|
13
|
+
export const ChatCreateContactV1_response = Result(ChatContactRegistrationStatus, ChatContactRegistrationErr);
|
|
13
14
|
// message format
|
|
14
15
|
export const ChatAction = Struct({
|
|
15
16
|
actionId: str,
|
|
16
17
|
title: str,
|
|
17
18
|
});
|
|
18
|
-
export const ChatActionLayout =
|
|
19
|
-
Column: _void,
|
|
20
|
-
Grid: _void,
|
|
21
|
-
});
|
|
19
|
+
export const ChatActionLayout = Status('Column', 'Grid');
|
|
22
20
|
export const ChatActions = Struct({
|
|
23
21
|
text: Option(str),
|
|
24
22
|
actions: Vector(ChatAction),
|
|
@@ -44,23 +42,23 @@ export const ChatReaction = Struct({
|
|
|
44
42
|
});
|
|
45
43
|
export const ChatMessage = Enum({
|
|
46
44
|
Text: str,
|
|
45
|
+
RichText: ChatRichText,
|
|
47
46
|
Actions: ChatActions,
|
|
48
|
-
RichText: ChatMedia,
|
|
49
47
|
File: ChatFile,
|
|
50
48
|
Reaction: ChatReaction,
|
|
51
49
|
ReactionRemoved: ChatReaction,
|
|
52
50
|
});
|
|
53
51
|
// sending message
|
|
54
|
-
export const ChatMessagePostingErr =
|
|
55
|
-
|
|
56
|
-
Unknown: GenericErr,
|
|
52
|
+
export const ChatMessagePostingErr = ErrEnum('ChatMessagePostingErr', {
|
|
53
|
+
MessageTooLarge: [_void, 'ChatMessagePosting: message too large'],
|
|
54
|
+
Unknown: [GenericErr, 'ChatMessagePosting: unknown error'],
|
|
57
55
|
});
|
|
58
56
|
export const ChatPostMessageResult = Struct({
|
|
59
57
|
messageId: str,
|
|
60
58
|
});
|
|
61
59
|
export const ChatPostMessageV1_request = ChatMessage;
|
|
62
60
|
export const ChatPostMessageV1_response = Result(ChatPostMessageResult, ChatMessagePostingErr);
|
|
63
|
-
// receiving message
|
|
61
|
+
// receiving a message
|
|
64
62
|
export const ActionTrigger = Struct({
|
|
65
63
|
messageId: str,
|
|
66
64
|
actionId: str,
|