@novasamatech/host-api 0.5.0-17 → 0.5.0-18
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/dist/interactions/commonCodecs.d.ts +7 -0
- package/dist/interactions/commonCodecs.js +8 -0
- package/dist/interactions/message.d.ts +1704 -0
- package/dist/interactions/message.js +60 -0
- package/dist/interactions/types.d.ts +1 -0
- package/dist/interactions/types.js +1 -0
- package/dist/interactions/v1/accounts.d.ts +128 -0
- package/dist/interactions/v1/accounts.js +51 -0
- package/dist/interactions/v1/chat.d.ts +295 -0
- package/dist/interactions/v1/chat.js +73 -0
- package/dist/interactions/v1/createTransaction.d.ts +197 -0
- package/dist/interactions/v1/createTransaction.js +41 -0
- package/dist/interactions/v1/feature.d.ts +11 -0
- package/dist/interactions/v1/feature.js +7 -0
- package/dist/interactions/v1/handshake.d.ts +28 -0
- package/dist/interactions/v1/handshake.js +12 -0
- package/dist/interactions/v1/jsonRpc.d.ts +6 -0
- package/dist/interactions/v1/jsonRpc.js +6 -0
- package/dist/interactions/v1/permission.d.ts +48 -0
- package/dist/interactions/v1/permission.js +18 -0
- package/dist/interactions/v1/sign.d.ts +92 -0
- package/dist/interactions/v1/sign.js +43 -0
- package/dist/interactions/v1/statementStore.d.ts +118 -0
- package/dist/interactions/v1/statementStore.js +47 -0
- package/dist/interactions/v1/storage.d.ts +41 -0
- package/dist/interactions/v1/storage.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Enum, Struct, _void, str } from 'scale-ts';
|
|
2
|
+
import { AccountCreateProofV1_request, AccountCreateProofV1_response, AccountGetAliasV1_request, AccountGetAliasV1_response, AccountGetV1_request, AccountGetV1_response, GetNonProductAccountsV1_request, GetNonProductAccountsV1_response, } from './v1/accounts.js';
|
|
3
|
+
import { ChatActionSubscribeV1_receive, ChatActionSubscribeV1_start, ChatCreateContactV1_request, ChatCreateContactV1_response, ChatPostMessageV1_request, ChatPostMessageV1_response, } from './v1/chat.js';
|
|
4
|
+
import { CreateTransactionV1_request, CreateTransactionV1_response, CreateTransactionWithNonProductAccountV1_request, CreateTransactionWithNonProductAccountV1_response, } from './v1/createTransaction.js';
|
|
5
|
+
import { FeatureV1_request, FeatureV1_response } from './v1/feature.js';
|
|
6
|
+
import { HandshakeV1_request, HandshakeV1_response } from './v1/handshake.js';
|
|
7
|
+
import { JsonRpcMessageSendV1_request, JsonRpcMessageSendV1_response, JsonRpcMessageSubscribeV1_receive, JsonRpcMessageSubscribeV1_start, } from './v1/jsonRpc.js';
|
|
8
|
+
import { PermissionRequestV1_request, PermissionRequestV1_response } from './v1/permission.js';
|
|
9
|
+
import { SignPayloadV1_request, SignPayloadV1_response, SignRawV1_request, SignRawV1_response } from './v1/sign.js';
|
|
10
|
+
import { StatementStoreCreateProofV1_request, StatementStoreCreateProofV1_response } from './v1/statementStore.js';
|
|
11
|
+
import { StorageClearV1_request, StorageClearV1_response, StorageReadV1_request, StorageReadV1_response, StorageWriteV1_request, StorageWriteV1_response, } from './v1/storage.js';
|
|
12
|
+
const createRequest = (key, request, response) => {
|
|
13
|
+
return {
|
|
14
|
+
[`${key}_request`]: request,
|
|
15
|
+
[`${key}_response`]: response,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const createSubscription = (key, start, receive) => {
|
|
19
|
+
return {
|
|
20
|
+
[`${key}_start`]: start,
|
|
21
|
+
[`${key}_stop`]: _void,
|
|
22
|
+
[`${key}_receive`]: receive,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const MessagePayloadV1 = Enum({
|
|
26
|
+
// host requests
|
|
27
|
+
...createRequest('handshake', HandshakeV1_request, HandshakeV1_response),
|
|
28
|
+
...createRequest('feature', FeatureV1_request, FeatureV1_response),
|
|
29
|
+
...createRequest('permission_request', PermissionRequestV1_request, PermissionRequestV1_response),
|
|
30
|
+
// storage
|
|
31
|
+
...createRequest('storage_read', StorageReadV1_request, StorageReadV1_response),
|
|
32
|
+
...createRequest('storage_write', StorageWriteV1_request, StorageWriteV1_response),
|
|
33
|
+
...createRequest('storage_clear', StorageClearV1_request, StorageClearV1_response),
|
|
34
|
+
// accounts
|
|
35
|
+
...createRequest('account_get', AccountGetV1_request, AccountGetV1_response),
|
|
36
|
+
...createRequest('account_get_alias', AccountGetAliasV1_request, AccountGetAliasV1_response),
|
|
37
|
+
...createRequest('account_create_proof', AccountCreateProofV1_request, AccountCreateProofV1_response),
|
|
38
|
+
...createRequest('get_non_product_accounts', GetNonProductAccountsV1_request, GetNonProductAccountsV1_response),
|
|
39
|
+
// signing
|
|
40
|
+
...createRequest('create_transaction', CreateTransactionV1_request, CreateTransactionV1_response),
|
|
41
|
+
...createRequest('create_transaction_with_non_product_account', CreateTransactionWithNonProductAccountV1_request, CreateTransactionWithNonProductAccountV1_response),
|
|
42
|
+
...createRequest('sign_raw', SignRawV1_request, SignRawV1_response),
|
|
43
|
+
...createRequest('sign_payload', SignPayloadV1_request, SignPayloadV1_response),
|
|
44
|
+
// chat
|
|
45
|
+
...createRequest('chat_create_contact', ChatCreateContactV1_request, ChatCreateContactV1_response),
|
|
46
|
+
...createRequest('chat_post_message', ChatPostMessageV1_request, ChatPostMessageV1_response),
|
|
47
|
+
...createSubscription('chat_action_subscribe', ChatActionSubscribeV1_start, ChatActionSubscribeV1_receive),
|
|
48
|
+
// statement store
|
|
49
|
+
...createRequest('statement_store_create_proof', StatementStoreCreateProofV1_request, StatementStoreCreateProofV1_response),
|
|
50
|
+
// json rpc
|
|
51
|
+
...createRequest('jsonrpc_message_send', JsonRpcMessageSendV1_request, JsonRpcMessageSendV1_response),
|
|
52
|
+
...createSubscription('jsonrpc_message_subscribe', JsonRpcMessageSubscribeV1_start, JsonRpcMessageSubscribeV1_receive),
|
|
53
|
+
});
|
|
54
|
+
export const MessagePayload = Enum({
|
|
55
|
+
v1: MessagePayloadV1,
|
|
56
|
+
});
|
|
57
|
+
export const Message = Struct({
|
|
58
|
+
requestId: str,
|
|
59
|
+
payload: MessagePayload,
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HexString = `0x${string}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
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").Codec<{
|
|
27
|
+
tag: "NotConnected";
|
|
28
|
+
value: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
tag: "Rejected";
|
|
31
|
+
value: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
tag: "DomainNotValid";
|
|
34
|
+
value: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
tag: "Unknown";
|
|
37
|
+
value: {
|
|
38
|
+
reason: string;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export declare const CreateProofErr: import("scale-ts").Codec<{
|
|
42
|
+
tag: "Rejected";
|
|
43
|
+
value: undefined;
|
|
44
|
+
} | {
|
|
45
|
+
tag: "Unknown";
|
|
46
|
+
value: {
|
|
47
|
+
reason: string;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
tag: "RingNotFound";
|
|
51
|
+
value: undefined;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const AccountGetV1_request: import("scale-ts").Codec<[string, number]>;
|
|
54
|
+
export declare const AccountGetV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
55
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
56
|
+
name: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
tag: "NotConnected";
|
|
59
|
+
value: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
tag: "Rejected";
|
|
62
|
+
value: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
tag: "DomainNotValid";
|
|
65
|
+
value: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
tag: "Unknown";
|
|
68
|
+
value: {
|
|
69
|
+
reason: string;
|
|
70
|
+
};
|
|
71
|
+
}>>;
|
|
72
|
+
export declare const AccountGetAliasV1_request: import("scale-ts").Codec<[string, number]>;
|
|
73
|
+
export declare const AccountGetAliasV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
74
|
+
context: Uint8Array<ArrayBufferLike>;
|
|
75
|
+
alias: Uint8Array<ArrayBufferLike>;
|
|
76
|
+
}, {
|
|
77
|
+
tag: "NotConnected";
|
|
78
|
+
value: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
tag: "Rejected";
|
|
81
|
+
value: undefined;
|
|
82
|
+
} | {
|
|
83
|
+
tag: "DomainNotValid";
|
|
84
|
+
value: undefined;
|
|
85
|
+
} | {
|
|
86
|
+
tag: "Unknown";
|
|
87
|
+
value: {
|
|
88
|
+
reason: string;
|
|
89
|
+
};
|
|
90
|
+
}>>;
|
|
91
|
+
export declare const AccountCreateProofV1_request: import("scale-ts").Codec<[[string, number], {
|
|
92
|
+
genesisHash: `0x${string}`;
|
|
93
|
+
ringRootHash: `0x${string}`;
|
|
94
|
+
hints: {
|
|
95
|
+
palletInstance: number | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}, Uint8Array<ArrayBufferLike>]>;
|
|
98
|
+
export declare const AccountCreateProofV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, {
|
|
99
|
+
tag: "Rejected";
|
|
100
|
+
value: undefined;
|
|
101
|
+
} | {
|
|
102
|
+
tag: "Unknown";
|
|
103
|
+
value: {
|
|
104
|
+
reason: string;
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
tag: "RingNotFound";
|
|
108
|
+
value: undefined;
|
|
109
|
+
}>>;
|
|
110
|
+
export declare const GetNonProductAccountsV1_request: import("scale-ts").Codec<undefined>;
|
|
111
|
+
export declare const GetNonProductAccountsV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
112
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
113
|
+
name: string | undefined;
|
|
114
|
+
}[], {
|
|
115
|
+
tag: "NotConnected";
|
|
116
|
+
value: undefined;
|
|
117
|
+
} | {
|
|
118
|
+
tag: "Rejected";
|
|
119
|
+
value: undefined;
|
|
120
|
+
} | {
|
|
121
|
+
tag: "DomainNotValid";
|
|
122
|
+
value: undefined;
|
|
123
|
+
} | {
|
|
124
|
+
tag: "Unknown";
|
|
125
|
+
value: {
|
|
126
|
+
reason: string;
|
|
127
|
+
};
|
|
128
|
+
}>>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Bytes, Enum, Option, Result, Struct, Tuple, Vector, _void, str, u32 } from 'scale-ts';
|
|
2
|
+
import { GenericErr, GenesisHash, Hex } from '../commonCodecs.js';
|
|
3
|
+
// common types
|
|
4
|
+
export const AccountId = Bytes(32);
|
|
5
|
+
export const PublicKey = Bytes();
|
|
6
|
+
export const DotNsIdentifier = str;
|
|
7
|
+
export const DerivationIndex = u32;
|
|
8
|
+
export const ProductAccountId = Tuple(DotNsIdentifier, DerivationIndex);
|
|
9
|
+
export const RingVrfProof = Bytes();
|
|
10
|
+
export const RingVrgAlias = Bytes();
|
|
11
|
+
// structs
|
|
12
|
+
export const Account = Struct({
|
|
13
|
+
publicKey: PublicKey,
|
|
14
|
+
name: Option(str),
|
|
15
|
+
});
|
|
16
|
+
export const ContextualAlias = Struct({
|
|
17
|
+
context: Bytes(32),
|
|
18
|
+
alias: RingVrgAlias,
|
|
19
|
+
});
|
|
20
|
+
export const RingLocationHint = Struct({
|
|
21
|
+
palletInstance: Option(u32),
|
|
22
|
+
});
|
|
23
|
+
export const RingLocation = Struct({
|
|
24
|
+
genesisHash: GenesisHash,
|
|
25
|
+
ringRootHash: Hex(),
|
|
26
|
+
hints: Option(RingLocationHint),
|
|
27
|
+
});
|
|
28
|
+
// errors
|
|
29
|
+
export const RequestCredentialsErr = Enum({
|
|
30
|
+
NotConnected: _void,
|
|
31
|
+
Rejected: _void,
|
|
32
|
+
DomainNotValid: _void,
|
|
33
|
+
Unknown: GenericErr,
|
|
34
|
+
});
|
|
35
|
+
export const CreateProofErr = Enum({
|
|
36
|
+
RingNotFound: _void,
|
|
37
|
+
Rejected: _void,
|
|
38
|
+
Unknown: GenericErr,
|
|
39
|
+
});
|
|
40
|
+
// account_get
|
|
41
|
+
export const AccountGetV1_request = ProductAccountId;
|
|
42
|
+
export const AccountGetV1_response = Result(Account, RequestCredentialsErr);
|
|
43
|
+
// account_get_alias
|
|
44
|
+
export const AccountGetAliasV1_request = ProductAccountId;
|
|
45
|
+
export const AccountGetAliasV1_response = Result(ContextualAlias, RequestCredentialsErr);
|
|
46
|
+
// account_create_proof
|
|
47
|
+
export const AccountCreateProofV1_request = Tuple(ProductAccountId, RingLocation, Bytes());
|
|
48
|
+
export const AccountCreateProofV1_response = Result(RingVrfProof, CreateProofErr);
|
|
49
|
+
// get_non_product_accounts
|
|
50
|
+
export const GetNonProductAccountsV1_request = _void;
|
|
51
|
+
export const GetNonProductAccountsV1_response = Result(Vector(Account), RequestCredentialsErr);
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
export declare const ChatContactRegistrationErr: import("scale-ts").Codec<{
|
|
2
|
+
tag: "Unknown";
|
|
3
|
+
value: {
|
|
4
|
+
reason: string;
|
|
5
|
+
};
|
|
6
|
+
}>;
|
|
7
|
+
export declare const ChatContact: import("scale-ts").Codec<{
|
|
8
|
+
name: string;
|
|
9
|
+
icon: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const ChatCreateContactV1_request: import("scale-ts").Codec<{
|
|
12
|
+
name: string;
|
|
13
|
+
icon: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const ChatCreateContactV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, {
|
|
16
|
+
tag: "Unknown";
|
|
17
|
+
value: {
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
20
|
+
}>>;
|
|
21
|
+
export declare const ChatAction: import("scale-ts").Codec<{
|
|
22
|
+
actionId: string;
|
|
23
|
+
title: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const ChatActionLayout: import("scale-ts").Codec<{
|
|
26
|
+
tag: "Column";
|
|
27
|
+
value: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
tag: "Grid";
|
|
30
|
+
value: undefined;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const ChatActions: import("scale-ts").Codec<{
|
|
33
|
+
text: string | undefined;
|
|
34
|
+
actions: {
|
|
35
|
+
actionId: string;
|
|
36
|
+
title: string;
|
|
37
|
+
}[];
|
|
38
|
+
layout: {
|
|
39
|
+
tag: "Column";
|
|
40
|
+
value: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
tag: "Grid";
|
|
43
|
+
value: undefined;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
export declare const ChatMedia: import("scale-ts").Codec<{
|
|
47
|
+
url: string;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const ChatRichText: import("scale-ts").Codec<{
|
|
50
|
+
text: string | undefined;
|
|
51
|
+
media: {
|
|
52
|
+
url: string;
|
|
53
|
+
}[];
|
|
54
|
+
}>;
|
|
55
|
+
export declare const ChatFile: import("scale-ts").Codec<{
|
|
56
|
+
url: string;
|
|
57
|
+
fileName: string;
|
|
58
|
+
mimeType: string;
|
|
59
|
+
sizeBytes: bigint;
|
|
60
|
+
text: string | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
export declare const ChatReaction: import("scale-ts").Codec<{
|
|
63
|
+
messageId: string;
|
|
64
|
+
emoji: string;
|
|
65
|
+
}>;
|
|
66
|
+
export declare const ChatMessage: import("scale-ts").Codec<{
|
|
67
|
+
tag: "Text";
|
|
68
|
+
value: string;
|
|
69
|
+
} | {
|
|
70
|
+
tag: "Actions";
|
|
71
|
+
value: {
|
|
72
|
+
text: string | undefined;
|
|
73
|
+
actions: {
|
|
74
|
+
actionId: string;
|
|
75
|
+
title: string;
|
|
76
|
+
}[];
|
|
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;
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
tag: "File";
|
|
92
|
+
value: {
|
|
93
|
+
url: string;
|
|
94
|
+
fileName: string;
|
|
95
|
+
mimeType: string;
|
|
96
|
+
sizeBytes: bigint;
|
|
97
|
+
text: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
tag: "Reaction";
|
|
101
|
+
value: {
|
|
102
|
+
messageId: string;
|
|
103
|
+
emoji: string;
|
|
104
|
+
};
|
|
105
|
+
} | {
|
|
106
|
+
tag: "ReactionRemoved";
|
|
107
|
+
value: {
|
|
108
|
+
messageId: string;
|
|
109
|
+
emoji: string;
|
|
110
|
+
};
|
|
111
|
+
}>;
|
|
112
|
+
export declare const ChatMessagePostingErr: import("scale-ts").Codec<{
|
|
113
|
+
tag: "Unknown";
|
|
114
|
+
value: {
|
|
115
|
+
reason: string;
|
|
116
|
+
};
|
|
117
|
+
} | {
|
|
118
|
+
tag: "OverflowMessageSize";
|
|
119
|
+
value: undefined;
|
|
120
|
+
}>;
|
|
121
|
+
export declare const ChatPostMessageResult: import("scale-ts").Codec<{
|
|
122
|
+
messageId: string;
|
|
123
|
+
}>;
|
|
124
|
+
export declare const ChatPostMessageV1_request: import("scale-ts").Codec<{
|
|
125
|
+
tag: "Text";
|
|
126
|
+
value: string;
|
|
127
|
+
} | {
|
|
128
|
+
tag: "Actions";
|
|
129
|
+
value: {
|
|
130
|
+
text: string | undefined;
|
|
131
|
+
actions: {
|
|
132
|
+
actionId: string;
|
|
133
|
+
title: string;
|
|
134
|
+
}[];
|
|
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;
|
|
147
|
+
};
|
|
148
|
+
} | {
|
|
149
|
+
tag: "File";
|
|
150
|
+
value: {
|
|
151
|
+
url: string;
|
|
152
|
+
fileName: string;
|
|
153
|
+
mimeType: string;
|
|
154
|
+
sizeBytes: bigint;
|
|
155
|
+
text: string | undefined;
|
|
156
|
+
};
|
|
157
|
+
} | {
|
|
158
|
+
tag: "Reaction";
|
|
159
|
+
value: {
|
|
160
|
+
messageId: string;
|
|
161
|
+
emoji: string;
|
|
162
|
+
};
|
|
163
|
+
} | {
|
|
164
|
+
tag: "ReactionRemoved";
|
|
165
|
+
value: {
|
|
166
|
+
messageId: string;
|
|
167
|
+
emoji: string;
|
|
168
|
+
};
|
|
169
|
+
}>;
|
|
170
|
+
export declare const ChatPostMessageV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
171
|
+
messageId: string;
|
|
172
|
+
}, {
|
|
173
|
+
tag: "Unknown";
|
|
174
|
+
value: {
|
|
175
|
+
reason: string;
|
|
176
|
+
};
|
|
177
|
+
} | {
|
|
178
|
+
tag: "OverflowMessageSize";
|
|
179
|
+
value: undefined;
|
|
180
|
+
}>>;
|
|
181
|
+
export declare const ActionTrigger: import("scale-ts").Codec<{
|
|
182
|
+
messageId: string;
|
|
183
|
+
actionId: string;
|
|
184
|
+
}>;
|
|
185
|
+
export declare const ReceivedChatAction: import("scale-ts").Codec<{
|
|
186
|
+
tag: "MessagePosted";
|
|
187
|
+
value: {
|
|
188
|
+
tag: "Text";
|
|
189
|
+
value: string;
|
|
190
|
+
} | {
|
|
191
|
+
tag: "Actions";
|
|
192
|
+
value: {
|
|
193
|
+
text: string | undefined;
|
|
194
|
+
actions: {
|
|
195
|
+
actionId: string;
|
|
196
|
+
title: string;
|
|
197
|
+
}[];
|
|
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;
|
|
210
|
+
};
|
|
211
|
+
} | {
|
|
212
|
+
tag: "File";
|
|
213
|
+
value: {
|
|
214
|
+
url: string;
|
|
215
|
+
fileName: string;
|
|
216
|
+
mimeType: string;
|
|
217
|
+
sizeBytes: bigint;
|
|
218
|
+
text: string | undefined;
|
|
219
|
+
};
|
|
220
|
+
} | {
|
|
221
|
+
tag: "Reaction";
|
|
222
|
+
value: {
|
|
223
|
+
messageId: string;
|
|
224
|
+
emoji: string;
|
|
225
|
+
};
|
|
226
|
+
} | {
|
|
227
|
+
tag: "ReactionRemoved";
|
|
228
|
+
value: {
|
|
229
|
+
messageId: string;
|
|
230
|
+
emoji: string;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
} | {
|
|
234
|
+
tag: "ActionTriggered";
|
|
235
|
+
value: {
|
|
236
|
+
messageId: string;
|
|
237
|
+
actionId: string;
|
|
238
|
+
};
|
|
239
|
+
}>;
|
|
240
|
+
export declare const ChatActionSubscribeV1_start: import("scale-ts").Codec<undefined>;
|
|
241
|
+
export declare const ChatActionSubscribeV1_receive: import("scale-ts").Codec<{
|
|
242
|
+
tag: "MessagePosted";
|
|
243
|
+
value: {
|
|
244
|
+
tag: "Text";
|
|
245
|
+
value: string;
|
|
246
|
+
} | {
|
|
247
|
+
tag: "Actions";
|
|
248
|
+
value: {
|
|
249
|
+
text: string | undefined;
|
|
250
|
+
actions: {
|
|
251
|
+
actionId: string;
|
|
252
|
+
title: string;
|
|
253
|
+
}[];
|
|
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;
|
|
266
|
+
};
|
|
267
|
+
} | {
|
|
268
|
+
tag: "File";
|
|
269
|
+
value: {
|
|
270
|
+
url: string;
|
|
271
|
+
fileName: string;
|
|
272
|
+
mimeType: string;
|
|
273
|
+
sizeBytes: bigint;
|
|
274
|
+
text: string | undefined;
|
|
275
|
+
};
|
|
276
|
+
} | {
|
|
277
|
+
tag: "Reaction";
|
|
278
|
+
value: {
|
|
279
|
+
messageId: string;
|
|
280
|
+
emoji: string;
|
|
281
|
+
};
|
|
282
|
+
} | {
|
|
283
|
+
tag: "ReactionRemoved";
|
|
284
|
+
value: {
|
|
285
|
+
messageId: string;
|
|
286
|
+
emoji: string;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
} | {
|
|
290
|
+
tag: "ActionTriggered";
|
|
291
|
+
value: {
|
|
292
|
+
messageId: string;
|
|
293
|
+
actionId: string;
|
|
294
|
+
};
|
|
295
|
+
}>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Enum, Option, Result, Struct, Vector, _void, str, u64 } from 'scale-ts';
|
|
2
|
+
import { GenericErr } from '../commonCodecs.js';
|
|
3
|
+
// contact
|
|
4
|
+
export const ChatContactRegistrationErr = Enum({
|
|
5
|
+
Unknown: GenericErr,
|
|
6
|
+
});
|
|
7
|
+
export const ChatContact = Struct({
|
|
8
|
+
name: str,
|
|
9
|
+
icon: str, // url or base64 encoded image for contact
|
|
10
|
+
});
|
|
11
|
+
export const ChatCreateContactV1_request = ChatContact;
|
|
12
|
+
export const ChatCreateContactV1_response = Result(_void, ChatContactRegistrationErr);
|
|
13
|
+
// message format
|
|
14
|
+
export const ChatAction = Struct({
|
|
15
|
+
actionId: str,
|
|
16
|
+
title: str,
|
|
17
|
+
});
|
|
18
|
+
export const ChatActionLayout = Enum({
|
|
19
|
+
Column: _void,
|
|
20
|
+
Grid: _void,
|
|
21
|
+
});
|
|
22
|
+
export const ChatActions = Struct({
|
|
23
|
+
text: Option(str),
|
|
24
|
+
actions: Vector(ChatAction),
|
|
25
|
+
layout: ChatActionLayout,
|
|
26
|
+
});
|
|
27
|
+
export const ChatMedia = Struct({
|
|
28
|
+
url: str,
|
|
29
|
+
});
|
|
30
|
+
export const ChatRichText = Struct({
|
|
31
|
+
text: Option(str),
|
|
32
|
+
media: Vector(ChatMedia),
|
|
33
|
+
});
|
|
34
|
+
export const ChatFile = Struct({
|
|
35
|
+
url: str,
|
|
36
|
+
fileName: str,
|
|
37
|
+
mimeType: str,
|
|
38
|
+
sizeBytes: u64,
|
|
39
|
+
text: Option(str),
|
|
40
|
+
});
|
|
41
|
+
export const ChatReaction = Struct({
|
|
42
|
+
messageId: str,
|
|
43
|
+
emoji: str,
|
|
44
|
+
});
|
|
45
|
+
export const ChatMessage = Enum({
|
|
46
|
+
Text: str,
|
|
47
|
+
Actions: ChatActions,
|
|
48
|
+
RichText: ChatMedia,
|
|
49
|
+
File: ChatFile,
|
|
50
|
+
Reaction: ChatReaction,
|
|
51
|
+
ReactionRemoved: ChatReaction,
|
|
52
|
+
});
|
|
53
|
+
// sending message
|
|
54
|
+
export const ChatMessagePostingErr = Enum({
|
|
55
|
+
OverflowMessageSize: _void,
|
|
56
|
+
Unknown: GenericErr,
|
|
57
|
+
});
|
|
58
|
+
export const ChatPostMessageResult = Struct({
|
|
59
|
+
messageId: str,
|
|
60
|
+
});
|
|
61
|
+
export const ChatPostMessageV1_request = ChatMessage;
|
|
62
|
+
export const ChatPostMessageV1_response = Result(ChatPostMessageResult, ChatMessagePostingErr);
|
|
63
|
+
// receiving message
|
|
64
|
+
export const ActionTrigger = Struct({
|
|
65
|
+
messageId: str,
|
|
66
|
+
actionId: str,
|
|
67
|
+
});
|
|
68
|
+
export const ReceivedChatAction = Enum({
|
|
69
|
+
MessagePosted: ChatMessage,
|
|
70
|
+
ActionTriggered: ActionTrigger,
|
|
71
|
+
});
|
|
72
|
+
export const ChatActionSubscribeV1_start = _void;
|
|
73
|
+
export const ChatActionSubscribeV1_receive = ReceivedChatAction;
|