@devvit/protos 0.12.0-next-2025-03-31-fec8fadd5.0 → 0.12.0-next-2025-04-10-2ee75c532.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.
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/meta.min.json +35 -5
- package/package.json +5 -5
- package/protos.min.js +1 -1
- package/protos.min.js.map +4 -4
- package/schema/devvit/actor/webbit/webbit.proto +34 -0
- package/schema/devvit/dev_portal/nutrition/nutrition.proto +2 -0
- package/schema/devvit/plugin/useractions/useractions.proto +18 -0
- package/schema/devvit/ui/effects/web_view/v1alpha/post_message.proto +19 -1
- package/schema/snootobuf.devenv.lock +1390 -91
- package/schema/snootobuf.lock +1394 -91
- package/schema/snootobuf.redditapi.lock +1386 -91
- package/schema/snootobuf.ts.lock +1392 -91
- package/types/devvit/actor/webbit/webbit.d.ts +131 -0
- package/types/devvit/actor/webbit/webbit.d.ts.map +1 -0
- package/types/devvit/actor/webbit/webbit.js +485 -0
- package/types/devvit/actor/webbit/webbit.twirp-client.d.ts +19 -0
- package/types/devvit/actor/webbit/webbit.twirp-client.d.ts.map +1 -0
- package/types/devvit/actor/webbit/webbit.twirp-client.js +23 -0
- package/types/devvit/actor/webbit/webbit.twirp.d.ts +12 -0
- package/types/devvit/actor/webbit/webbit.twirp.d.ts.map +1 -0
- package/types/devvit/actor/webbit/webbit.twirp.js +88 -0
- package/types/devvit/dev_portal/nutrition/nutrition.d.ts +2 -0
- package/types/devvit/dev_portal/nutrition/nutrition.d.ts.map +1 -1
- package/types/devvit/dev_portal/nutrition/nutrition.js +7 -0
- package/types/devvit/plugin/useractions/useractions.d.ts +576 -0
- package/types/devvit/plugin/useractions/useractions.d.ts.map +1 -0
- package/types/devvit/plugin/useractions/useractions.js +66 -0
- package/types/devvit/plugin/useractions/useractions.twirp-client.d.ts +25 -0
- package/types/devvit/plugin/useractions/useractions.twirp-client.d.ts.map +1 -0
- package/types/devvit/plugin/useractions/useractions.twirp-client.js +47 -0
- package/types/devvit/plugin/useractions/useractions.twirp.d.ts +16 -0
- package/types/devvit/plugin/useractions/useractions.twirp.d.ts.map +1 -0
- package/types/devvit/plugin/useractions/useractions.twirp.js +222 -0
- package/types/devvit/ui/effects/web_view/v1alpha/post_message.d.ts +29 -0
- package/types/devvit/ui/effects/web_view/v1alpha/post_message.d.ts.map +1 -1
- package/types/devvit/ui/effects/web_view/v1alpha/post_message.js +108 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
import { CommentRequest, JsonWrappedComment, SubmitRequest, SubmitResponse } from '../redditapi/linksandcomments/linksandcomments_msg.js';
|
2
|
+
interface Rpc {
|
3
|
+
request(service: string, method: string, contentType: 'application/json' | 'application/protobuf', data: object | Uint8Array): Promise<object | Uint8Array>;
|
4
|
+
}
|
5
|
+
export interface UserActionsClient {
|
6
|
+
Comment(request: CommentRequest): Promise<JsonWrappedComment>;
|
7
|
+
Submit(request: SubmitRequest): Promise<SubmitResponse>;
|
8
|
+
SubmitCustomPost(request: SubmitRequest): Promise<SubmitResponse>;
|
9
|
+
}
|
10
|
+
export declare class UserActionsClientJSON implements UserActionsClient {
|
11
|
+
private readonly rpc;
|
12
|
+
constructor(rpc: Rpc);
|
13
|
+
Comment(request: CommentRequest): Promise<JsonWrappedComment>;
|
14
|
+
Submit(request: SubmitRequest): Promise<SubmitResponse>;
|
15
|
+
SubmitCustomPost(request: SubmitRequest): Promise<SubmitResponse>;
|
16
|
+
}
|
17
|
+
export declare class UserActionsClientProtobuf implements UserActionsClient {
|
18
|
+
private readonly rpc;
|
19
|
+
constructor(rpc: Rpc);
|
20
|
+
Comment(request: CommentRequest): Promise<JsonWrappedComment>;
|
21
|
+
Submit(request: SubmitRequest): Promise<SubmitResponse>;
|
22
|
+
SubmitCustomPost(request: SubmitRequest): Promise<SubmitResponse>;
|
23
|
+
}
|
24
|
+
export {};
|
25
|
+
//# sourceMappingURL=useractions.twirp-client.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useractions.twirp-client.d.ts","sourceRoot":"","sources":["../../../../../src/types/devvit/plugin/useractions/useractions.twirp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,cAAc,EACf,MAAM,uDAAuD,CAAC;AAM/D,UAAU,GAAG;IACX,OAAO,CACL,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,GAAG,sBAAsB,EACxD,IAAI,EAAE,MAAM,GAAG,UAAU,GACxB,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC9D,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACxD,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACnE;AAED,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;gBACd,GAAG,EAAE,GAAG;IAMpB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAW7D,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAWvD,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;CAUlE;AAED,qBAAa,yBAA0B,YAAW,iBAAiB;IACjE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;gBACd,GAAG,EAAE,GAAG;IAMpB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAa7D,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAWvD,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;CAUlE"}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { CommentRequest, JsonWrappedComment, SubmitRequest, SubmitResponse, } from '../redditapi/linksandcomments/linksandcomments_msg.js';
|
2
|
+
export class UserActionsClientJSON {
|
3
|
+
constructor(rpc) {
|
4
|
+
this.rpc = rpc;
|
5
|
+
this.Comment.bind(this);
|
6
|
+
this.Submit.bind(this);
|
7
|
+
this.SubmitCustomPost.bind(this);
|
8
|
+
}
|
9
|
+
Comment(request) {
|
10
|
+
const data = CommentRequest.toJSON(request);
|
11
|
+
const promise = this.rpc.request('devvit.plugin.useractions.UserActions', 'Comment', 'application/json', data);
|
12
|
+
return promise.then((data) => JsonWrappedComment.fromJSON(data));
|
13
|
+
}
|
14
|
+
Submit(request) {
|
15
|
+
const data = SubmitRequest.toJSON(request);
|
16
|
+
const promise = this.rpc.request('devvit.plugin.useractions.UserActions', 'Submit', 'application/json', data);
|
17
|
+
return promise.then((data) => SubmitResponse.fromJSON(data));
|
18
|
+
}
|
19
|
+
SubmitCustomPost(request) {
|
20
|
+
const data = SubmitRequest.toJSON(request);
|
21
|
+
const promise = this.rpc.request('devvit.plugin.useractions.UserActions', 'SubmitCustomPost', 'application/json', data);
|
22
|
+
return promise.then((data) => SubmitResponse.fromJSON(data));
|
23
|
+
}
|
24
|
+
}
|
25
|
+
export class UserActionsClientProtobuf {
|
26
|
+
constructor(rpc) {
|
27
|
+
this.rpc = rpc;
|
28
|
+
this.Comment.bind(this);
|
29
|
+
this.Submit.bind(this);
|
30
|
+
this.SubmitCustomPost.bind(this);
|
31
|
+
}
|
32
|
+
Comment(request) {
|
33
|
+
const data = CommentRequest.encode(request).finish();
|
34
|
+
const promise = this.rpc.request('devvit.plugin.useractions.UserActions', 'Comment', 'application/protobuf', data);
|
35
|
+
return promise.then((data) => JsonWrappedComment.decode(data));
|
36
|
+
}
|
37
|
+
Submit(request) {
|
38
|
+
const data = SubmitRequest.encode(request).finish();
|
39
|
+
const promise = this.rpc.request('devvit.plugin.useractions.UserActions', 'Submit', 'application/protobuf', data);
|
40
|
+
return promise.then((data) => SubmitResponse.decode(data));
|
41
|
+
}
|
42
|
+
SubmitCustomPost(request) {
|
43
|
+
const data = SubmitRequest.encode(request).finish();
|
44
|
+
const promise = this.rpc.request('devvit.plugin.useractions.UserActions', 'SubmitCustomPost', 'application/protobuf', data);
|
45
|
+
return promise.then((data) => SubmitResponse.decode(data));
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
2
|
+
import { TwirpContext, TwirpServer } from 'twirp-ts';
|
3
|
+
import { CommentRequest, JsonWrappedComment, SubmitRequest, SubmitResponse } from '../redditapi/linksandcomments/linksandcomments_msg.js';
|
4
|
+
export interface UserActionsTwirp<T extends TwirpContext = TwirpContext> {
|
5
|
+
Comment(ctx: T, request: CommentRequest): Promise<JsonWrappedComment>;
|
6
|
+
Submit(ctx: T, request: SubmitRequest): Promise<SubmitResponse>;
|
7
|
+
SubmitCustomPost(ctx: T, request: SubmitRequest): Promise<SubmitResponse>;
|
8
|
+
}
|
9
|
+
export declare enum UserActionsMethod {
|
10
|
+
Comment = "Comment",
|
11
|
+
Submit = "Submit",
|
12
|
+
SubmitCustomPost = "SubmitCustomPost"
|
13
|
+
}
|
14
|
+
export declare const UserActionsMethodList: UserActionsMethod[];
|
15
|
+
export declare function createUserActionsServer<T extends TwirpContext = TwirpContext>(service: UserActionsTwirp<T>): TwirpServer<UserActionsTwirp<TwirpContext<import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>>>, T>;
|
16
|
+
//# sourceMappingURL=useractions.twirp.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useractions.twirp.d.ts","sourceRoot":"","sources":["../../../../../src/types/devvit/plugin/useractions/useractions.twirp.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EAOZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,cAAc,EACf,MAAM,uDAAuD,CAAC;AAM/D,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IACrE,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtE,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAChE,gBAAgB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC3E;AAED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,gBAAgB,qBAAqB;CACtC;AAED,eAAO,MAAM,qBAAqB,qBAIjC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAC3E,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,iJAS7B"}
|
@@ -0,0 +1,222 @@
|
|
1
|
+
import { TwirpServer, TwirpError, TwirpErrorCode, TwirpContentType, chainInterceptors, } from 'twirp-ts';
|
2
|
+
import { CommentRequest, JsonWrappedComment, SubmitRequest, SubmitResponse, } from '../redditapi/linksandcomments/linksandcomments_msg.js';
|
3
|
+
export var UserActionsMethod;
|
4
|
+
(function (UserActionsMethod) {
|
5
|
+
UserActionsMethod["Comment"] = "Comment";
|
6
|
+
UserActionsMethod["Submit"] = "Submit";
|
7
|
+
UserActionsMethod["SubmitCustomPost"] = "SubmitCustomPost";
|
8
|
+
})(UserActionsMethod || (UserActionsMethod = {}));
|
9
|
+
export const UserActionsMethodList = [
|
10
|
+
UserActionsMethod.Comment,
|
11
|
+
UserActionsMethod.Submit,
|
12
|
+
UserActionsMethod.SubmitCustomPost,
|
13
|
+
];
|
14
|
+
export function createUserActionsServer(service) {
|
15
|
+
return new TwirpServer({
|
16
|
+
service,
|
17
|
+
packageName: 'devvit.plugin.useractions',
|
18
|
+
serviceName: 'UserActions',
|
19
|
+
methodList: UserActionsMethodList,
|
20
|
+
matchRoute: matchUserActionsRoute,
|
21
|
+
});
|
22
|
+
}
|
23
|
+
function matchUserActionsRoute(method, events) {
|
24
|
+
switch (method) {
|
25
|
+
case 'Comment':
|
26
|
+
return async (ctx, service, data, interceptors) => {
|
27
|
+
ctx = { ...ctx, methodName: 'Comment' };
|
28
|
+
await events.onMatch(ctx);
|
29
|
+
return handleUserActionsCommentRequest(ctx, service, data, interceptors);
|
30
|
+
};
|
31
|
+
case 'Submit':
|
32
|
+
return async (ctx, service, data, interceptors) => {
|
33
|
+
ctx = { ...ctx, methodName: 'Submit' };
|
34
|
+
await events.onMatch(ctx);
|
35
|
+
return handleUserActionsSubmitRequest(ctx, service, data, interceptors);
|
36
|
+
};
|
37
|
+
case 'SubmitCustomPost':
|
38
|
+
return async (ctx, service, data, interceptors) => {
|
39
|
+
ctx = { ...ctx, methodName: 'SubmitCustomPost' };
|
40
|
+
await events.onMatch(ctx);
|
41
|
+
return handleUserActionsSubmitCustomPostRequest(ctx, service, data, interceptors);
|
42
|
+
};
|
43
|
+
default:
|
44
|
+
events.onNotFound();
|
45
|
+
const msg = `no handler found`;
|
46
|
+
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
function handleUserActionsCommentRequest(ctx, service, data, interceptors) {
|
50
|
+
switch (ctx.contentType) {
|
51
|
+
case TwirpContentType.JSON:
|
52
|
+
return handleUserActionsCommentJSON(ctx, service, data, interceptors);
|
53
|
+
case TwirpContentType.Protobuf:
|
54
|
+
return handleUserActionsCommentProtobuf(ctx, service, data, interceptors);
|
55
|
+
default:
|
56
|
+
const msg = 'unexpected Content-Type';
|
57
|
+
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
function handleUserActionsSubmitRequest(ctx, service, data, interceptors) {
|
61
|
+
switch (ctx.contentType) {
|
62
|
+
case TwirpContentType.JSON:
|
63
|
+
return handleUserActionsSubmitJSON(ctx, service, data, interceptors);
|
64
|
+
case TwirpContentType.Protobuf:
|
65
|
+
return handleUserActionsSubmitProtobuf(ctx, service, data, interceptors);
|
66
|
+
default:
|
67
|
+
const msg = 'unexpected Content-Type';
|
68
|
+
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
function handleUserActionsSubmitCustomPostRequest(ctx, service, data, interceptors) {
|
72
|
+
switch (ctx.contentType) {
|
73
|
+
case TwirpContentType.JSON:
|
74
|
+
return handleUserActionsSubmitCustomPostJSON(ctx, service, data, interceptors);
|
75
|
+
case TwirpContentType.Protobuf:
|
76
|
+
return handleUserActionsSubmitCustomPostProtobuf(ctx, service, data, interceptors);
|
77
|
+
default:
|
78
|
+
const msg = 'unexpected Content-Type';
|
79
|
+
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
async function handleUserActionsCommentJSON(ctx, service, data, interceptors) {
|
83
|
+
let request;
|
84
|
+
let response;
|
85
|
+
try {
|
86
|
+
const body = JSON.parse(data.toString() || '{}');
|
87
|
+
request = CommentRequest.fromJSON(body);
|
88
|
+
}
|
89
|
+
catch (e) {
|
90
|
+
if (e instanceof Error) {
|
91
|
+
const msg = 'the json request could not be decoded';
|
92
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
if (interceptors && interceptors.length > 0) {
|
96
|
+
const interceptor = chainInterceptors(...interceptors);
|
97
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
98
|
+
return service.Comment(ctx, inputReq);
|
99
|
+
});
|
100
|
+
}
|
101
|
+
else {
|
102
|
+
response = await service.Comment(ctx, request);
|
103
|
+
}
|
104
|
+
return JSON.stringify(JsonWrappedComment.toJSON(response));
|
105
|
+
}
|
106
|
+
async function handleUserActionsSubmitJSON(ctx, service, data, interceptors) {
|
107
|
+
let request;
|
108
|
+
let response;
|
109
|
+
try {
|
110
|
+
const body = JSON.parse(data.toString() || '{}');
|
111
|
+
request = SubmitRequest.fromJSON(body);
|
112
|
+
}
|
113
|
+
catch (e) {
|
114
|
+
if (e instanceof Error) {
|
115
|
+
const msg = 'the json request could not be decoded';
|
116
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
if (interceptors && interceptors.length > 0) {
|
120
|
+
const interceptor = chainInterceptors(...interceptors);
|
121
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
122
|
+
return service.Submit(ctx, inputReq);
|
123
|
+
});
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
response = await service.Submit(ctx, request);
|
127
|
+
}
|
128
|
+
return JSON.stringify(SubmitResponse.toJSON(response));
|
129
|
+
}
|
130
|
+
async function handleUserActionsSubmitCustomPostJSON(ctx, service, data, interceptors) {
|
131
|
+
let request;
|
132
|
+
let response;
|
133
|
+
try {
|
134
|
+
const body = JSON.parse(data.toString() || '{}');
|
135
|
+
request = SubmitRequest.fromJSON(body);
|
136
|
+
}
|
137
|
+
catch (e) {
|
138
|
+
if (e instanceof Error) {
|
139
|
+
const msg = 'the json request could not be decoded';
|
140
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
if (interceptors && interceptors.length > 0) {
|
144
|
+
const interceptor = chainInterceptors(...interceptors);
|
145
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
146
|
+
return service.SubmitCustomPost(ctx, inputReq);
|
147
|
+
});
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
response = await service.SubmitCustomPost(ctx, request);
|
151
|
+
}
|
152
|
+
return JSON.stringify(SubmitResponse.toJSON(response));
|
153
|
+
}
|
154
|
+
async function handleUserActionsCommentProtobuf(ctx, service, data, interceptors) {
|
155
|
+
let request;
|
156
|
+
let response;
|
157
|
+
try {
|
158
|
+
request = CommentRequest.decode(data);
|
159
|
+
}
|
160
|
+
catch (e) {
|
161
|
+
if (e instanceof Error) {
|
162
|
+
const msg = 'the protobuf request could not be decoded';
|
163
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
if (interceptors && interceptors.length > 0) {
|
167
|
+
const interceptor = chainInterceptors(...interceptors);
|
168
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
169
|
+
return service.Comment(ctx, inputReq);
|
170
|
+
});
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
response = await service.Comment(ctx, request);
|
174
|
+
}
|
175
|
+
return Buffer.from(JsonWrappedComment.encode(response).finish());
|
176
|
+
}
|
177
|
+
async function handleUserActionsSubmitProtobuf(ctx, service, data, interceptors) {
|
178
|
+
let request;
|
179
|
+
let response;
|
180
|
+
try {
|
181
|
+
request = SubmitRequest.decode(data);
|
182
|
+
}
|
183
|
+
catch (e) {
|
184
|
+
if (e instanceof Error) {
|
185
|
+
const msg = 'the protobuf request could not be decoded';
|
186
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (interceptors && interceptors.length > 0) {
|
190
|
+
const interceptor = chainInterceptors(...interceptors);
|
191
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
192
|
+
return service.Submit(ctx, inputReq);
|
193
|
+
});
|
194
|
+
}
|
195
|
+
else {
|
196
|
+
response = await service.Submit(ctx, request);
|
197
|
+
}
|
198
|
+
return Buffer.from(SubmitResponse.encode(response).finish());
|
199
|
+
}
|
200
|
+
async function handleUserActionsSubmitCustomPostProtobuf(ctx, service, data, interceptors) {
|
201
|
+
let request;
|
202
|
+
let response;
|
203
|
+
try {
|
204
|
+
request = SubmitRequest.decode(data);
|
205
|
+
}
|
206
|
+
catch (e) {
|
207
|
+
if (e instanceof Error) {
|
208
|
+
const msg = 'the protobuf request could not be decoded';
|
209
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
210
|
+
}
|
211
|
+
}
|
212
|
+
if (interceptors && interceptors.length > 0) {
|
213
|
+
const interceptor = chainInterceptors(...interceptors);
|
214
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
215
|
+
return service.SubmitCustomPost(ctx, inputReq);
|
216
|
+
});
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
response = await service.SubmitCustomPost(ctx, request);
|
220
|
+
}
|
221
|
+
return Buffer.from(SubmitResponse.encode(response).finish());
|
222
|
+
}
|
@@ -4,6 +4,26 @@
|
|
4
4
|
* @packageDocumentation
|
5
5
|
*/
|
6
6
|
import _m0 from "protobufjs/minimal.js";
|
7
|
+
export declare enum WebViewInternalMessageScope {
|
8
|
+
/** CLIENT - Message is intended for the client only */
|
9
|
+
CLIENT = 0,
|
10
|
+
UNRECOGNIZED = -1
|
11
|
+
}
|
12
|
+
export declare function webViewInternalMessageScopeFromJSON(object: any): WebViewInternalMessageScope;
|
13
|
+
export declare function webViewInternalMessageScopeToJSON(object: WebViewInternalMessageScope): number;
|
14
|
+
/**
|
15
|
+
* Internal message, sent by web-view-scripts via postMessage
|
16
|
+
* type: devvit-internal
|
17
|
+
*/
|
18
|
+
export interface WebViewInternalMessage {
|
19
|
+
type: string;
|
20
|
+
/** Scope of the message, used to determine where the message should be sent */
|
21
|
+
scope: WebViewInternalMessageScope;
|
22
|
+
/** Origin: devvit-analytics */
|
23
|
+
analytics?: {
|
24
|
+
[key: string]: any;
|
25
|
+
} | undefined;
|
26
|
+
}
|
7
27
|
/** Structure of messages sent via postMessage */
|
8
28
|
export interface WebViewPostMessage {
|
9
29
|
/** See comments for each message */
|
@@ -46,6 +66,15 @@ export interface WebViewPostMessageEffect {
|
|
46
66
|
*/
|
47
67
|
state?: WebViewStateMessage | undefined;
|
48
68
|
}
|
69
|
+
export declare const WebViewInternalMessage: {
|
70
|
+
$type: "devvit.ui.effects.web_view.v1alpha.WebViewInternalMessage";
|
71
|
+
encode(message: WebViewInternalMessage, writer?: _m0.Writer): _m0.Writer;
|
72
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): WebViewInternalMessage;
|
73
|
+
fromJSON(object: any): WebViewInternalMessage;
|
74
|
+
toJSON(message: WebViewInternalMessage): unknown;
|
75
|
+
create(base?: DeepPartial<WebViewInternalMessage>): WebViewInternalMessage;
|
76
|
+
fromPartial(object: DeepPartial<WebViewInternalMessage>): WebViewInternalMessage;
|
77
|
+
};
|
49
78
|
export declare const WebViewPostMessage: {
|
50
79
|
$type: "devvit.ui.effects.web_view.v1alpha.WebViewPostMessage";
|
51
80
|
encode(message: WebViewPostMessage, writer?: _m0.Writer): _m0.Writer;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"post_message.d.ts","sourceRoot":"","sources":["../../../../../../../src/types/devvit/ui/effects/web_view/v1alpha/post_message.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,GAAG,MAAM,uBAAuB,CAAC;AAIxC,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC;CAC3C;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EACJ,GAAG,GACH,SAAS,CAAC;IACd,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,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AajF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,wBAAwB;qBAqChE,GAAG,GAAG,wBAAwB;oBAQ/B,wBAAwB,GAAG,OAAO;kBAcpC,YAAY,wBAAwB,CAAC,GAAG,wBAAwB;wBAG1D,YAAY,wBAAwB,CAAC,GAAG,wBAAwB;CAWrF,CAAC;AAIF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACvC,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
1
|
+
{"version":3,"file":"post_message.d.ts","sourceRoot":"","sources":["../../../../../../../src/types/devvit/ui/effects/web_view/v1alpha/post_message.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,GAAG,MAAM,uBAAuB,CAAC;AAIxC,oBAAY,2BAA2B;IACrC,uDAAuD;IACvD,MAAM,IAAI;IACV,YAAY,KAAK;CAClB;AAED,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,GAAG,GAAG,2BAA2B,CAU5F;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,CAQ7F;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;I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KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACvC,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
@@ -7,6 +7,114 @@
|
|
7
7
|
import _m0 from "protobufjs/minimal.js";
|
8
8
|
import { Struct, Value } from "../../../../../google/protobuf/struct.js";
|
9
9
|
import { messageTypeRegistry } from "../../../../../typeRegistry.js";
|
10
|
+
export var WebViewInternalMessageScope;
|
11
|
+
(function (WebViewInternalMessageScope) {
|
12
|
+
/** CLIENT - Message is intended for the client only */
|
13
|
+
WebViewInternalMessageScope[WebViewInternalMessageScope["CLIENT"] = 0] = "CLIENT";
|
14
|
+
WebViewInternalMessageScope[WebViewInternalMessageScope["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
15
|
+
})(WebViewInternalMessageScope || (WebViewInternalMessageScope = {}));
|
16
|
+
export function webViewInternalMessageScopeFromJSON(object) {
|
17
|
+
switch (object) {
|
18
|
+
case 0:
|
19
|
+
case "CLIENT":
|
20
|
+
return WebViewInternalMessageScope.CLIENT;
|
21
|
+
case -1:
|
22
|
+
case "UNRECOGNIZED":
|
23
|
+
default:
|
24
|
+
return WebViewInternalMessageScope.UNRECOGNIZED;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
export function webViewInternalMessageScopeToJSON(object) {
|
28
|
+
switch (object) {
|
29
|
+
case WebViewInternalMessageScope.CLIENT:
|
30
|
+
return 0;
|
31
|
+
case WebViewInternalMessageScope.UNRECOGNIZED:
|
32
|
+
default:
|
33
|
+
return -1;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
function createBaseWebViewInternalMessage() {
|
37
|
+
return { type: "", scope: 0, analytics: undefined };
|
38
|
+
}
|
39
|
+
export const WebViewInternalMessage = {
|
40
|
+
$type: "devvit.ui.effects.web_view.v1alpha.WebViewInternalMessage",
|
41
|
+
encode(message, writer = _m0.Writer.create()) {
|
42
|
+
if (message.type !== "") {
|
43
|
+
writer.uint32(10).string(message.type);
|
44
|
+
}
|
45
|
+
if (message.scope !== 0) {
|
46
|
+
writer.uint32(16).int32(message.scope);
|
47
|
+
}
|
48
|
+
if (message.analytics !== undefined) {
|
49
|
+
Struct.encode(Struct.wrap(message.analytics), writer.uint32(26).fork()).ldelim();
|
50
|
+
}
|
51
|
+
return writer;
|
52
|
+
},
|
53
|
+
decode(input, length) {
|
54
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
55
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
56
|
+
const message = createBaseWebViewInternalMessage();
|
57
|
+
while (reader.pos < end) {
|
58
|
+
const tag = reader.uint32();
|
59
|
+
switch (tag >>> 3) {
|
60
|
+
case 1:
|
61
|
+
if (tag !== 10) {
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
message.type = reader.string();
|
65
|
+
continue;
|
66
|
+
case 2:
|
67
|
+
if (tag !== 16) {
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
message.scope = reader.int32();
|
71
|
+
continue;
|
72
|
+
case 3:
|
73
|
+
if (tag !== 26) {
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
message.analytics = Struct.unwrap(Struct.decode(reader, reader.uint32()));
|
77
|
+
continue;
|
78
|
+
}
|
79
|
+
if ((tag & 7) === 4 || tag === 0) {
|
80
|
+
break;
|
81
|
+
}
|
82
|
+
reader.skipType(tag & 7);
|
83
|
+
}
|
84
|
+
return message;
|
85
|
+
},
|
86
|
+
fromJSON(object) {
|
87
|
+
return {
|
88
|
+
type: isSet(object.type) ? globalThis.String(object.type) : "",
|
89
|
+
scope: isSet(object.scope) ? webViewInternalMessageScopeFromJSON(object.scope) : 0,
|
90
|
+
analytics: isObject(object.analytics) ? object.analytics : undefined,
|
91
|
+
};
|
92
|
+
},
|
93
|
+
toJSON(message) {
|
94
|
+
const obj = {};
|
95
|
+
if (message.type !== "") {
|
96
|
+
obj.type = message.type;
|
97
|
+
}
|
98
|
+
if (message.scope !== 0) {
|
99
|
+
obj.scope = webViewInternalMessageScopeToJSON(message.scope);
|
100
|
+
}
|
101
|
+
if (message.analytics !== undefined) {
|
102
|
+
obj.analytics = message.analytics;
|
103
|
+
}
|
104
|
+
return obj;
|
105
|
+
},
|
106
|
+
create(base) {
|
107
|
+
return WebViewInternalMessage.fromPartial(base ?? {});
|
108
|
+
},
|
109
|
+
fromPartial(object) {
|
110
|
+
const message = createBaseWebViewInternalMessage();
|
111
|
+
message.type = object.type ?? "";
|
112
|
+
message.scope = object.scope ?? 0;
|
113
|
+
message.analytics = object.analytics ?? undefined;
|
114
|
+
return message;
|
115
|
+
},
|
116
|
+
};
|
117
|
+
messageTypeRegistry.set(WebViewInternalMessage.$type, WebViewInternalMessage);
|
10
118
|
function createBaseWebViewPostMessage() {
|
11
119
|
return { type: "", data: undefined };
|
12
120
|
}
|