@devvit/protos 0.11.8-next-2025-02-25-5add1d1b7.0 → 0.11.8-next-2025-02-26-c7c2cd822.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/meta.min.json +4 -4
- package/package.json +5 -5
- package/protos.min.js +1 -1
- package/protos.min.js.map +3 -3
- package/schema/devvit/plugin/redis/redisapi.proto +11 -0
- package/schema/snootobuf.devenv.lock +1396 -1113
- package/schema/snootobuf.lock +1396 -1113
- package/schema/snootobuf.redditapi.lock +1396 -1113
- package/schema/snootobuf.ts.lock +1396 -1113
- package/types/devvit/plugin/redis/redisapi.d.ts +52 -0
- package/types/devvit/plugin/redis/redisapi.d.ts.map +1 -1
- package/types/devvit/plugin/redis/redisapi.js +148 -0
- package/types/devvit/plugin/redis/redisapi.twirp-client.d.ts +4 -1
- package/types/devvit/plugin/redis/redisapi.twirp-client.d.ts.map +1 -1
- package/types/devvit/plugin/redis/redisapi.twirp-client.js +13 -1
- package/types/devvit/plugin/redis/redisapi.twirp.d.ts +3 -1
- package/types/devvit/plugin/redis/redisapi.twirp.d.ts.map +1 -1
- package/types/devvit/plugin/redis/redisapi.twirp.js +67 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import { TwirpServer, TwirpError, TwirpErrorCode, TwirpContentType, chainInterceptors, } from 'twirp-ts';
|
2
|
-
import { KeyRequest, SetRequest, KeysRequest, ExistsResponse, IncrByRequest, HSetRequest, HGetRequest, HMGetRequest, RedisValues, RedisFieldValues, HDelRequest, HScanRequest, HScanResponse, KeysResponse, HIncrByRequest, HSetNXRequest, HSetNXResponse, TransactionId, TransactionResponses, WatchRequest, KeyRangeRequest, SetRangeRequest, KeyValuesRequest, ExpireRequest, ZAddRequest, ZRangeRequest, ZMembers, ZRemRequest, ZRemRangeByLexRequest, ZRemRangeByRankRequest, ZRemRangeByScoreRequest, ZScoreRequest, ZRankRequest, ZIncrByRequest, ZScanRequest, ZScanResponse, BitfieldRequest, BitfieldResponse, } from './redisapi.js';
|
2
|
+
import { KeyRequest, SetRequest, KeysRequest, ExistsResponse, RenameRequest, RenameResponse, IncrByRequest, HSetRequest, HGetRequest, HMGetRequest, RedisValues, RedisFieldValues, HDelRequest, HScanRequest, HScanResponse, KeysResponse, HIncrByRequest, HSetNXRequest, HSetNXResponse, TransactionId, TransactionResponses, WatchRequest, KeyRangeRequest, SetRangeRequest, KeyValuesRequest, ExpireRequest, ZAddRequest, ZRangeRequest, ZMembers, ZRemRequest, ZRemRangeByLexRequest, ZRemRangeByRankRequest, ZRemRangeByScoreRequest, ZScoreRequest, ZRankRequest, ZIncrByRequest, ZScanRequest, ZScanResponse, BitfieldRequest, BitfieldResponse, } from './redisapi.js';
|
3
3
|
import { StringValue, BytesValue, Int64Value, DoubleValue, } from '../../../google/protobuf/wrappers.js';
|
4
4
|
import { Empty } from '../../../google/protobuf/empty.js';
|
5
5
|
export var RedisAPIMethod;
|
@@ -10,6 +10,7 @@ export var RedisAPIMethod;
|
|
10
10
|
RedisAPIMethod["Exists"] = "Exists";
|
11
11
|
RedisAPIMethod["Del"] = "Del";
|
12
12
|
RedisAPIMethod["Type"] = "Type";
|
13
|
+
RedisAPIMethod["Rename"] = "Rename";
|
13
14
|
RedisAPIMethod["IncrBy"] = "IncrBy";
|
14
15
|
RedisAPIMethod["HSet"] = "HSet";
|
15
16
|
RedisAPIMethod["HGet"] = "HGet";
|
@@ -53,6 +54,7 @@ export const RedisAPIMethodList = [
|
|
53
54
|
RedisAPIMethod.Exists,
|
54
55
|
RedisAPIMethod.Del,
|
55
56
|
RedisAPIMethod.Type,
|
57
|
+
RedisAPIMethod.Rename,
|
56
58
|
RedisAPIMethod.IncrBy,
|
57
59
|
RedisAPIMethod.HSet,
|
58
60
|
RedisAPIMethod.HGet,
|
@@ -136,6 +138,12 @@ function matchRedisAPIRoute(method, events) {
|
|
136
138
|
await events.onMatch(ctx);
|
137
139
|
return handleRedisAPITypeRequest(ctx, service, data, interceptors);
|
138
140
|
};
|
141
|
+
case 'Rename':
|
142
|
+
return async (ctx, service, data, interceptors) => {
|
143
|
+
ctx = { ...ctx, methodName: 'Rename' };
|
144
|
+
await events.onMatch(ctx);
|
145
|
+
return handleRedisAPIRenameRequest(ctx, service, data, interceptors);
|
146
|
+
};
|
139
147
|
case 'IncrBy':
|
140
148
|
return async (ctx, service, data, interceptors) => {
|
141
149
|
ctx = { ...ctx, methodName: 'IncrBy' };
|
@@ -418,6 +426,17 @@ function handleRedisAPITypeRequest(ctx, service, data, interceptors) {
|
|
418
426
|
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
|
419
427
|
}
|
420
428
|
}
|
429
|
+
function handleRedisAPIRenameRequest(ctx, service, data, interceptors) {
|
430
|
+
switch (ctx.contentType) {
|
431
|
+
case TwirpContentType.JSON:
|
432
|
+
return handleRedisAPIRenameJSON(ctx, service, data, interceptors);
|
433
|
+
case TwirpContentType.Protobuf:
|
434
|
+
return handleRedisAPIRenameProtobuf(ctx, service, data, interceptors);
|
435
|
+
default:
|
436
|
+
const msg = 'unexpected Content-Type';
|
437
|
+
throw new TwirpError(TwirpErrorCode.BadRoute, msg);
|
438
|
+
}
|
439
|
+
}
|
421
440
|
function handleRedisAPIIncrByRequest(ctx, service, data, interceptors) {
|
422
441
|
switch (ctx.contentType) {
|
423
442
|
case TwirpContentType.JSON:
|
@@ -947,6 +966,30 @@ async function handleRedisAPITypeJSON(ctx, service, data, interceptors) {
|
|
947
966
|
}
|
948
967
|
return JSON.stringify(StringValue.toJSON(response));
|
949
968
|
}
|
969
|
+
async function handleRedisAPIRenameJSON(ctx, service, data, interceptors) {
|
970
|
+
let request;
|
971
|
+
let response;
|
972
|
+
try {
|
973
|
+
const body = JSON.parse(data.toString() || '{}');
|
974
|
+
request = RenameRequest.fromJSON(body);
|
975
|
+
}
|
976
|
+
catch (e) {
|
977
|
+
if (e instanceof Error) {
|
978
|
+
const msg = 'the json request could not be decoded';
|
979
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
980
|
+
}
|
981
|
+
}
|
982
|
+
if (interceptors && interceptors.length > 0) {
|
983
|
+
const interceptor = chainInterceptors(...interceptors);
|
984
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
985
|
+
return service.Rename(ctx, inputReq);
|
986
|
+
});
|
987
|
+
}
|
988
|
+
else {
|
989
|
+
response = await service.Rename(ctx, request);
|
990
|
+
}
|
991
|
+
return JSON.stringify(RenameResponse.toJSON(response));
|
992
|
+
}
|
950
993
|
async function handleRedisAPIIncrByJSON(ctx, service, data, interceptors) {
|
951
994
|
let request;
|
952
995
|
let response;
|
@@ -1925,6 +1968,29 @@ async function handleRedisAPITypeProtobuf(ctx, service, data, interceptors) {
|
|
1925
1968
|
}
|
1926
1969
|
return Buffer.from(StringValue.encode(response).finish());
|
1927
1970
|
}
|
1971
|
+
async function handleRedisAPIRenameProtobuf(ctx, service, data, interceptors) {
|
1972
|
+
let request;
|
1973
|
+
let response;
|
1974
|
+
try {
|
1975
|
+
request = RenameRequest.decode(data);
|
1976
|
+
}
|
1977
|
+
catch (e) {
|
1978
|
+
if (e instanceof Error) {
|
1979
|
+
const msg = 'the protobuf request could not be decoded';
|
1980
|
+
throw new TwirpError(TwirpErrorCode.Malformed, msg).withCause(e, true);
|
1981
|
+
}
|
1982
|
+
}
|
1983
|
+
if (interceptors && interceptors.length > 0) {
|
1984
|
+
const interceptor = chainInterceptors(...interceptors);
|
1985
|
+
response = await interceptor(ctx, request, (ctx, inputReq) => {
|
1986
|
+
return service.Rename(ctx, inputReq);
|
1987
|
+
});
|
1988
|
+
}
|
1989
|
+
else {
|
1990
|
+
response = await service.Rename(ctx, request);
|
1991
|
+
}
|
1992
|
+
return Buffer.from(RenameResponse.encode(response).finish());
|
1993
|
+
}
|
1928
1994
|
async function handleRedisAPIIncrByProtobuf(ctx, service, data, interceptors) {
|
1929
1995
|
let request;
|
1930
1996
|
let response;
|