@devvit/public-api 0.11.8-next-2025-02-12-7f5055e0c.0 → 0.11.8-next-2025-02-12-ce9f2981c.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/apis/redis/RedisClient.d.ts +2 -1
- package/apis/redis/RedisClient.d.ts.map +1 -1
- package/apis/redis/RedisClient.js +78 -1
- package/apis/redis/RedisClient.tests.d.ts +2 -0
- package/apis/redis/RedisClient.tests.d.ts.map +1 -0
- package/apis/redis/RedisClient.tests.js +62 -0
- package/meta.json +7 -7
- package/meta.min.json +5 -5
- package/package.json +7 -7
- package/public-api.d.ts +244 -0
- package/public-api.iife.js +660 -2
- package/public-api.min.js +5 -5
- package/public-api.min.js.map +3 -3
- package/types/redis.d.ts +79 -0
- package/types/redis.d.ts.map +1 -1
- package/version.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HScanResponse, Metadata, RedisAPI, TransactionId, ZMember, ZScanResponse } from '@devvit/protos';
|
|
2
2
|
import { RedisKeyScope } from '@devvit/protos';
|
|
3
|
-
import type { RedisClient as RedisClientLike, SetOptions, TxClientLike, ZRangeOptions } from '../../types/redis.js';
|
|
3
|
+
import type { BitfieldCommand, RedisClient as RedisClientLike, SetOptions, TxClientLike, ZRangeOptions } from '../../types/redis.js';
|
|
4
4
|
export declare class TxClient implements TxClientLike {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(storage: RedisAPI, transactionId: TransactionId, metadata: Metadata);
|
|
@@ -129,5 +129,6 @@ export declare class RedisClient implements RedisClientLike {
|
|
|
129
129
|
hIncrBy(key: string, field: string, value: number): Promise<number>;
|
|
130
130
|
hlen(key: string): Promise<number>;
|
|
131
131
|
hLen(key: string): Promise<number>;
|
|
132
|
+
bitfield(key: string, ...cmds: [] | BitfieldCommand | [...BitfieldCommand, ...BitfieldCommand] | [...BitfieldCommand, ...BitfieldCommand, ...BitfieldCommand, ...(number | string)[]]): Promise<number[]>;
|
|
132
133
|
}
|
|
133
134
|
//# sourceMappingURL=RedisClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisClient.d.ts","sourceRoot":"","sources":["../../../src/apis/redis/RedisClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RedisClient.d.ts","sourceRoot":"","sources":["../../../src/apis/redis/RedisClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,OAAO,EAEP,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA4B,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,KAAK,EACV,eAAe,EACf,WAAW,IAAI,eAAe,EAC9B,UAAU,EACV,YAAY,EACZ,aAAa,EACd,MAAM,sBAAsB,CAAC;AAmB9B,qBAAa,QAAS,YAAW,YAAY;;gBAK/B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ;IAMzE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAKvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IAsB5E,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAK7C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAMxC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAsBtB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,KAAK,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAK/C,OAA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AAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKrC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQnE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQlC,QAAQ,CACZ,GAAG,EAAE,MAAM,EACX,GAAG,IAAI,EACH,EAAE,GACF,eAAe,GACf,CAAC,GAAG,eAAe,EAAE,GAAG,eAAe,CAAC,GACxC,CAAC,GAAG,eAAe,EAAE,GAAG,eAAe,EAAE,GAAG,eAAe,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,GACvF,OAAO,CAAC,MAAM,EAAE,CAAC;CA2ErB"}
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _TxClient_storage, _TxClient_transactionId, _TxClient_metadata, _RedisClient_metadata, _RedisClient_storage;
|
|
13
|
-
import { RedisKeyScope } from '@devvit/protos';
|
|
13
|
+
import { BitfieldOverflowBehavior, RedisKeyScope } from '@devvit/protos';
|
|
14
14
|
import { Devvit } from '../../devvit/Devvit.js';
|
|
15
15
|
function isRedisNilError(e) {
|
|
16
16
|
// TODO: Replace with impl in a Gatsby-only world
|
|
@@ -546,5 +546,82 @@ export class RedisClient {
|
|
|
546
546
|
});
|
|
547
547
|
return response.value;
|
|
548
548
|
}
|
|
549
|
+
async bitfield(key, ...cmds) {
|
|
550
|
+
const commands = [];
|
|
551
|
+
for (let argIndex = 0; argIndex < cmds.length;) {
|
|
552
|
+
const currentArg = cmds[argIndex];
|
|
553
|
+
const command = {};
|
|
554
|
+
switch (currentArg) {
|
|
555
|
+
case 'get': {
|
|
556
|
+
if (argIndex + 2 >= cmds.length) {
|
|
557
|
+
throw Error(`bitfield command parse failed; not enough arguments for 'get' command`);
|
|
558
|
+
}
|
|
559
|
+
command.get = {
|
|
560
|
+
encoding: cmds[argIndex + 1],
|
|
561
|
+
offset: cmds[argIndex + 2].toString(),
|
|
562
|
+
};
|
|
563
|
+
argIndex += 3;
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
case 'set': {
|
|
567
|
+
if (argIndex + 3 >= cmds.length) {
|
|
568
|
+
throw Error(`bitfield command parse failed; not enough arguments for 'set' command`);
|
|
569
|
+
}
|
|
570
|
+
command.set = {
|
|
571
|
+
encoding: cmds[argIndex + 1],
|
|
572
|
+
offset: cmds[argIndex + 2].toString(),
|
|
573
|
+
value: cmds[argIndex + 3].toString(),
|
|
574
|
+
};
|
|
575
|
+
argIndex += 4;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
case 'incrBy': {
|
|
579
|
+
if (argIndex + 3 >= cmds.length) {
|
|
580
|
+
throw Error(`bitfield command parse failed; not enough arguments for 'incrBy' command`);
|
|
581
|
+
}
|
|
582
|
+
command.incrBy = {
|
|
583
|
+
encoding: cmds[argIndex + 1],
|
|
584
|
+
offset: cmds[argIndex + 2].toString(),
|
|
585
|
+
increment: cmds[argIndex + 3].toString(),
|
|
586
|
+
};
|
|
587
|
+
argIndex += 4;
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
case 'overflow': {
|
|
591
|
+
if (argIndex + 1 >= cmds.length) {
|
|
592
|
+
throw Error(`bitfield command parse failed; not enough arguments for 'overflow' command`);
|
|
593
|
+
}
|
|
594
|
+
const behavior = cmds[argIndex + 1].toString();
|
|
595
|
+
command.overflow = {
|
|
596
|
+
behavior: toBehaviorProto(behavior),
|
|
597
|
+
};
|
|
598
|
+
argIndex += 2;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
default: {
|
|
602
|
+
throw Error(`bitfield command parse failed; ${currentArg} unrecognized (must be 'get', 'set', 'incrBy', or 'overflow')`);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
commands.push(command);
|
|
606
|
+
}
|
|
607
|
+
const response = await this.storage.Bitfield({
|
|
608
|
+
key,
|
|
609
|
+
commands,
|
|
610
|
+
});
|
|
611
|
+
return response.results;
|
|
612
|
+
}
|
|
549
613
|
}
|
|
550
614
|
_RedisClient_metadata = new WeakMap(), _RedisClient_storage = new WeakMap();
|
|
615
|
+
function toBehaviorProto(behavior) {
|
|
616
|
+
const lowercase = behavior.toLowerCase();
|
|
617
|
+
switch (lowercase) {
|
|
618
|
+
case 'wrap':
|
|
619
|
+
return BitfieldOverflowBehavior.BITFIELD_OVERFLOW_BEHAVIOR_WRAP;
|
|
620
|
+
case 'sat':
|
|
621
|
+
return BitfieldOverflowBehavior.BITFIELD_OVERFLOW_BEHAVIOR_SAT;
|
|
622
|
+
case 'fail':
|
|
623
|
+
return BitfieldOverflowBehavior.BITFIELD_OVERFLOW_BEHAVIOR_FAIL;
|
|
624
|
+
default:
|
|
625
|
+
throw Error(`unknown bitfield overflow behavior: ${lowercase}`);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisClient.tests.d.ts","sourceRoot":"","sources":["../../../src/apis/redis/RedisClient.tests.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { RedisClient } from './RedisClient.js';
|
|
2
|
+
test('bitfield typing is intuitive', () => {
|
|
3
|
+
const client = new RedisClient({});
|
|
4
|
+
client.bitfield('mykey');
|
|
5
|
+
// 'get' syntax
|
|
6
|
+
client.bitfield('mykey', 'get', 'i8', '#2');
|
|
7
|
+
client.bitfield('mykey', 'get', 'u8', '2');
|
|
8
|
+
client.bitfield('mykey', 'get', 'u4', 2);
|
|
9
|
+
// 'set' syntax
|
|
10
|
+
client.bitfield('mykey', 'set', 'i6', '#2', 2);
|
|
11
|
+
client.bitfield('mykey', 'set', 'u2', '#2', -2);
|
|
12
|
+
// 'incrBy' syntax
|
|
13
|
+
client.bitfield('mykey', 'incrBy', 'i8', '#2', 3);
|
|
14
|
+
client.bitfield('mykey', 'incrBy', 'u4', '2', -3);
|
|
15
|
+
// 'overflow' syntax
|
|
16
|
+
client.bitfield('mykey', 'overflow', 'sat', 'set', 'u4', 2, 4);
|
|
17
|
+
client.bitfield('mykey', 'overflow', 'fail', 'incrBy', 'u4', 2, 4);
|
|
18
|
+
client.bitfield('mykey', 'overflow', 'sat', 'set', 'u4', 2, 4, 'overflow', 'wrap', 'incrBy', 'u4', '2', -3);
|
|
19
|
+
// multiple operations in one call
|
|
20
|
+
client.bitfield('mykey', 'set', 'i6', '#2', 2, 'get', 'i8', '#2', 'overflow', 'sat', 'set', 'u4', 2, 4);
|
|
21
|
+
client.bitfield('mykey', 'get', 'i8', '#2', 'set', 'u2', '#2', -2, 'incrBy', 'u4', '2', -3, 'get', 'u4', 2, 'incrBy', 'u4', '2', -3);
|
|
22
|
+
client.bitfield('mykey', 'overflow', 'fail', 'get', 'u3', 2, 'set', 'i4', '#2', 4, 'incrBy', 'i4', '#2', 2, 'overflow', 'wrap', 'set', 'u7', 8, 1, 'incrBy', 'i7', '2', 5);
|
|
23
|
+
// Invalid type/syntax tests
|
|
24
|
+
// @ts-expect-error wrong operation types
|
|
25
|
+
client.bitfield('mykey', 3, true, 'abc');
|
|
26
|
+
// @ts-expect-error unknown operation
|
|
27
|
+
client.bitfield('mykey', 'range', 'u3', '#2', 4);
|
|
28
|
+
// @ts-expect-error 'get' missing parameters
|
|
29
|
+
client.bitfield('mykey', 'get');
|
|
30
|
+
// @ts-expect-error 'get' missing parameters
|
|
31
|
+
client.bitfield('mykey', 'get', 'u1');
|
|
32
|
+
// @ts-expect-error 'set' missing parameters
|
|
33
|
+
client.bitfield('mykey', 'set');
|
|
34
|
+
// @ts-expect-error 'get' missing parameters
|
|
35
|
+
client.bitfield('mykey', 'set', 'u1');
|
|
36
|
+
// @ts-expect-error 'get' missing parameters
|
|
37
|
+
client.bitfield('mykey', 'set', 'u1', '#2');
|
|
38
|
+
// @ts-expect-error 'incrBy' missing parameters
|
|
39
|
+
client.bitfield('mykey', 'incrBy');
|
|
40
|
+
// @ts-expect-error 'incrBy' missing parameters
|
|
41
|
+
client.bitfield('mykey', 'incrBy', 'u1');
|
|
42
|
+
// @ts-expect-error 'incrBy' missing parameters
|
|
43
|
+
client.bitfield('mykey', 'incrBy', 'u1', '#2');
|
|
44
|
+
// @ts-expect-error 'overflow' missing parameters
|
|
45
|
+
client.bitfield('mykey', 'overflow');
|
|
46
|
+
// @ts-expect-error 'get' missing parameters
|
|
47
|
+
client.bitfield('mykey', 'get', 'u1');
|
|
48
|
+
// @ts-expect-error 'get' missing parameters
|
|
49
|
+
client.bitfield('mykey', 'get', 'u1');
|
|
50
|
+
client.bitfield('mykey',
|
|
51
|
+
// @ts-expect-error missing parameters in multiple operations ('set' missing value)
|
|
52
|
+
'set', 'i6', '#2', 'get', 'i8', '#2', 'overflow', 'sat', 'set', 'u4', 2, 4);
|
|
53
|
+
client.bitfield('mykey',
|
|
54
|
+
// @ts-expect-error missing parameters in multiple operations ('get' missing offset)
|
|
55
|
+
'get', 'i8', 'set', 'u2', '#2', -2, 'incrBy', 'u4', '2', -3, 'get', 'u4', 2, 'incrBy', 'u4', '2', -3);
|
|
56
|
+
client.bitfield('mykey',
|
|
57
|
+
// @ts-expect-error missing parameters in multiple operations ('incrBy' missing encoding)
|
|
58
|
+
'overflow', 'fail', 'get', 'u3', 2, 'incrBy', '#2', 2, 'overflow', 'wrap', 'set', 'u7', 8, 1, 'incrBy', 'i7', '2', 5);
|
|
59
|
+
client.bitfield('mykey',
|
|
60
|
+
// @ts-expect-error missing parameters in multiple operations ('overflow' missing behavior)
|
|
61
|
+
'overflow', 'get', 'u3', 2, 'incrBy', 'u5', '#2', 2, 'overflow', 'wrap', 'set', 'u7', 8, 1, 'incrBy', 'i7', '2', 5);
|
|
62
|
+
});
|
package/meta.json
CHANGED
|
@@ -6492,7 +6492,7 @@
|
|
|
6492
6492
|
"format": "esm"
|
|
6493
6493
|
},
|
|
6494
6494
|
"../protos/dist/types/devvit/plugin/redis/redisapi.js": {
|
|
6495
|
-
"bytes":
|
|
6495
|
+
"bytes": 175098,
|
|
6496
6496
|
"imports": [
|
|
6497
6497
|
{
|
|
6498
6498
|
"path": "../../node_modules/long/src/long.js",
|
|
@@ -6906,7 +6906,7 @@
|
|
|
6906
6906
|
"format": "esm"
|
|
6907
6907
|
},
|
|
6908
6908
|
"../protos/dist/index.js": {
|
|
6909
|
-
"bytes":
|
|
6909
|
+
"bytes": 6416,
|
|
6910
6910
|
"imports": [
|
|
6911
6911
|
{
|
|
6912
6912
|
"path": "../protos/dist/lib/Defunct-Types.js",
|
|
@@ -7238,7 +7238,7 @@
|
|
|
7238
7238
|
"format": "esm"
|
|
7239
7239
|
},
|
|
7240
7240
|
"src/types/redis.ts": {
|
|
7241
|
-
"bytes":
|
|
7241
|
+
"bytes": 56961,
|
|
7242
7242
|
"imports": [],
|
|
7243
7243
|
"format": "esm"
|
|
7244
7244
|
},
|
|
@@ -7593,7 +7593,7 @@
|
|
|
7593
7593
|
"format": "esm"
|
|
7594
7594
|
},
|
|
7595
7595
|
"src/apis/redis/RedisClient.ts": {
|
|
7596
|
-
"bytes":
|
|
7596
|
+
"bytes": 26174,
|
|
7597
7597
|
"imports": [
|
|
7598
7598
|
{
|
|
7599
7599
|
"path": "../protos/dist/index.js",
|
|
@@ -9965,7 +9965,7 @@
|
|
|
9965
9965
|
"bytesInOutput": 57632
|
|
9966
9966
|
},
|
|
9967
9967
|
"../protos/dist/types/devvit/plugin/redis/redisapi.js": {
|
|
9968
|
-
"bytesInOutput":
|
|
9968
|
+
"bytesInOutput": 148591
|
|
9969
9969
|
},
|
|
9970
9970
|
"../protos/dist/types/devvit/plugin/scheduler/scheduler.js": {
|
|
9971
9971
|
"bytesInOutput": 22400
|
|
@@ -10073,7 +10073,7 @@
|
|
|
10073
10073
|
"bytesInOutput": 54359
|
|
10074
10074
|
},
|
|
10075
10075
|
"src/apis/redis/RedisClient.ts": {
|
|
10076
|
-
"bytesInOutput":
|
|
10076
|
+
"bytesInOutput": 23952
|
|
10077
10077
|
},
|
|
10078
10078
|
"src/apis/scheduler/SchedulerClient.ts": {
|
|
10079
10079
|
"bytesInOutput": 1819
|
|
@@ -10283,7 +10283,7 @@
|
|
|
10283
10283
|
"bytesInOutput": 2975
|
|
10284
10284
|
}
|
|
10285
10285
|
},
|
|
10286
|
-
"bytes":
|
|
10286
|
+
"bytes": 12374709
|
|
10287
10287
|
}
|
|
10288
10288
|
}
|
|
10289
10289
|
}
|
package/meta.min.json
CHANGED
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"format": "esm"
|
|
89
89
|
},
|
|
90
90
|
"src/types/redis.ts": {
|
|
91
|
-
"bytes":
|
|
91
|
+
"bytes": 56961,
|
|
92
92
|
"imports": [],
|
|
93
93
|
"format": "esm"
|
|
94
94
|
},
|
|
@@ -443,7 +443,7 @@
|
|
|
443
443
|
"format": "esm"
|
|
444
444
|
},
|
|
445
445
|
"src/apis/redis/RedisClient.ts": {
|
|
446
|
-
"bytes":
|
|
446
|
+
"bytes": 26174,
|
|
447
447
|
"imports": [
|
|
448
448
|
{
|
|
449
449
|
"path": "@devvit/protos",
|
|
@@ -2480,7 +2480,7 @@
|
|
|
2480
2480
|
"imports": [],
|
|
2481
2481
|
"exports": [],
|
|
2482
2482
|
"inputs": {},
|
|
2483
|
-
"bytes":
|
|
2483
|
+
"bytes": 1041873
|
|
2484
2484
|
},
|
|
2485
2485
|
"dist/public-api.min.js": {
|
|
2486
2486
|
"imports": [
|
|
@@ -2801,7 +2801,7 @@
|
|
|
2801
2801
|
"bytesInOutput": 7793
|
|
2802
2802
|
},
|
|
2803
2803
|
"src/apis/redis/RedisClient.ts": {
|
|
2804
|
-
"bytesInOutput":
|
|
2804
|
+
"bytesInOutput": 11632
|
|
2805
2805
|
},
|
|
2806
2806
|
"src/apis/scheduler/SchedulerClient.ts": {
|
|
2807
2807
|
"bytesInOutput": 709
|
|
@@ -3005,7 +3005,7 @@
|
|
|
3005
3005
|
"bytesInOutput": 1267
|
|
3006
3006
|
}
|
|
3007
3007
|
},
|
|
3008
|
-
"bytes":
|
|
3008
|
+
"bytes": 216473
|
|
3009
3009
|
}
|
|
3010
3010
|
}
|
|
3011
3011
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/public-api",
|
|
3
|
-
"version": "0.11.8-next-2025-02-12-
|
|
3
|
+
"version": "0.11.8-next-2025-02-12-ce9f2981c.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
},
|
|
31
31
|
"types": "./index.d.ts",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@devvit/protos": "0.11.8-next-2025-02-12-
|
|
34
|
-
"@devvit/shared-types": "0.11.8-next-2025-02-12-
|
|
33
|
+
"@devvit/protos": "0.11.8-next-2025-02-12-ce9f2981c.0",
|
|
34
|
+
"@devvit/shared-types": "0.11.8-next-2025-02-12-ce9f2981c.0",
|
|
35
35
|
"base64-js": "1.5.1",
|
|
36
36
|
"clone-deep": "4.0.1",
|
|
37
37
|
"moderndash": "4.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@ampproject/filesize": "4.3.0",
|
|
41
|
-
"@devvit/repo-tools": "0.11.8-next-2025-02-12-
|
|
42
|
-
"@devvit/tsconfig": "0.11.8-next-2025-02-12-
|
|
41
|
+
"@devvit/repo-tools": "0.11.8-next-2025-02-12-ce9f2981c.0",
|
|
42
|
+
"@devvit/tsconfig": "0.11.8-next-2025-02-12-ce9f2981c.0",
|
|
43
43
|
"@microsoft/api-extractor": "7.41.0",
|
|
44
44
|
"@reddit/faceplate-ui": "18.0.1",
|
|
45
45
|
"@types/clone-deep": "4.0.1",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"filesize": {
|
|
57
57
|
"dist/public-api.min.js": {
|
|
58
58
|
"gzip": "60 KB",
|
|
59
|
-
"none": "
|
|
59
|
+
"none": "212 KB"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"source": "./src/index.ts",
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "4aec92e65152252f8faebc32c5a157e753433b8b"
|
|
64
64
|
}
|
package/public-api.d.ts
CHANGED
|
@@ -1666,6 +1666,180 @@ declare const BasicWhereRequest: {
|
|
|
1666
1666
|
fromPartial(object: DeepPartial_11<BasicWhereRequest>): BasicWhereRequest;
|
|
1667
1667
|
};
|
|
1668
1668
|
|
|
1669
|
+
export declare type BitfieldCommand = BitfieldGet_2 | BitfieldSet_2 | BitfieldIncrBy_2 | BitfieldOverflow_2;
|
|
1670
|
+
|
|
1671
|
+
declare interface BitfieldCommand_2 {
|
|
1672
|
+
get?: BitfieldGet | undefined;
|
|
1673
|
+
set?: BitfieldSet | undefined;
|
|
1674
|
+
incrBy?: BitfieldIncrBy | undefined;
|
|
1675
|
+
overflow?: BitfieldOverflow | undefined;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
declare const BitfieldCommand_2: {
|
|
1679
|
+
$type: "devvit.plugin.redis.BitfieldCommand";
|
|
1680
|
+
encode(message: BitfieldCommand_2, writer?: _m0.Writer): _m0.Writer;
|
|
1681
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldCommand_2;
|
|
1682
|
+
fromJSON(object: any): BitfieldCommand_2;
|
|
1683
|
+
toJSON(message: BitfieldCommand_2): unknown;
|
|
1684
|
+
create(base?: DeepPartial_63<BitfieldCommand_2>): BitfieldCommand_2;
|
|
1685
|
+
fromPartial(object: DeepPartial_63<BitfieldCommand_2>): BitfieldCommand_2;
|
|
1686
|
+
};
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Encoding for operations in a bitfield command
|
|
1690
|
+
* Prefix with 'u' to encode as unsigned integers (e.g. 'u4' is a 4-bit unsigned integer)
|
|
1691
|
+
* Prefix with 'i' to encode as signed integers (e.g. 'i6' is a 6-bit signed integer)
|
|
1692
|
+
* Up to 64 bits for signed integers, and up to 63 bits for unsigned integers
|
|
1693
|
+
*/
|
|
1694
|
+
declare type BitfieldEncoding = `${'i' | 'u'}${number}`;
|
|
1695
|
+
|
|
1696
|
+
declare interface BitfieldGet {
|
|
1697
|
+
encoding: string;
|
|
1698
|
+
offset: string;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
declare const BitfieldGet: {
|
|
1702
|
+
$type: "devvit.plugin.redis.BitfieldGet";
|
|
1703
|
+
encode(message: BitfieldGet, writer?: _m0.Writer): _m0.Writer;
|
|
1704
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldGet;
|
|
1705
|
+
fromJSON(object: any): BitfieldGet;
|
|
1706
|
+
toJSON(message: BitfieldGet): unknown;
|
|
1707
|
+
create(base?: DeepPartial_63<BitfieldGet>): BitfieldGet;
|
|
1708
|
+
fromPartial(object: DeepPartial_63<BitfieldGet>): BitfieldGet;
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* Represents a 'get' operation in a bitfield command
|
|
1713
|
+
*/
|
|
1714
|
+
declare type BitfieldGet_2 = [get: 'get', encoding: BitfieldEncoding, offset: BitfieldOffset];
|
|
1715
|
+
|
|
1716
|
+
declare interface BitfieldIncrBy {
|
|
1717
|
+
encoding: string;
|
|
1718
|
+
offset: string;
|
|
1719
|
+
increment: string;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
declare const BitfieldIncrBy: {
|
|
1723
|
+
$type: "devvit.plugin.redis.BitfieldIncrBy";
|
|
1724
|
+
encode(message: BitfieldIncrBy, writer?: _m0.Writer): _m0.Writer;
|
|
1725
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldIncrBy;
|
|
1726
|
+
fromJSON(object: any): BitfieldIncrBy;
|
|
1727
|
+
toJSON(message: BitfieldIncrBy): unknown;
|
|
1728
|
+
create(base?: DeepPartial_63<BitfieldIncrBy>): BitfieldIncrBy;
|
|
1729
|
+
fromPartial(object: DeepPartial_63<BitfieldIncrBy>): BitfieldIncrBy;
|
|
1730
|
+
};
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* Represents an 'incrBy' operation in a bitfield command
|
|
1734
|
+
*/
|
|
1735
|
+
declare type BitfieldIncrBy_2 = [
|
|
1736
|
+
incrBy: 'incrBy',
|
|
1737
|
+
encoding: BitfieldEncoding,
|
|
1738
|
+
offset: BitfieldOffset,
|
|
1739
|
+
/**
|
|
1740
|
+
* Value to increment (or decrement if given a negative increment) the bitfield by
|
|
1741
|
+
*/
|
|
1742
|
+
increment: number | `${number}`
|
|
1743
|
+
];
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Offset to operate on for an operation in a bitfield command
|
|
1747
|
+
* If given a number without any prefix, it is used just as a zero based bit offset inside the string
|
|
1748
|
+
* if given a number prefixed with a # character, the specified offset is multiplied by the integer encoding's width
|
|
1749
|
+
*/
|
|
1750
|
+
declare type BitfieldOffset = number | string | `#${number}`;
|
|
1751
|
+
|
|
1752
|
+
declare interface BitfieldOverflow {
|
|
1753
|
+
behavior: BitfieldOverflowBehavior;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
declare const BitfieldOverflow: {
|
|
1757
|
+
$type: "devvit.plugin.redis.BitfieldOverflow";
|
|
1758
|
+
encode(message: BitfieldOverflow, writer?: _m0.Writer): _m0.Writer;
|
|
1759
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldOverflow;
|
|
1760
|
+
fromJSON(object: any): BitfieldOverflow;
|
|
1761
|
+
toJSON(message: BitfieldOverflow): unknown;
|
|
1762
|
+
create(base?: DeepPartial_63<BitfieldOverflow>): BitfieldOverflow;
|
|
1763
|
+
fromPartial(object: DeepPartial_63<BitfieldOverflow>): BitfieldOverflow;
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1766
|
+
/**
|
|
1767
|
+
* Represents an 'overflow' operation in a bitfield command
|
|
1768
|
+
*/
|
|
1769
|
+
declare type BitfieldOverflow_2 = [overflow: 'overflow', behavior: 'wrap' | 'sat' | 'fail'];
|
|
1770
|
+
|
|
1771
|
+
declare enum BitfieldOverflowBehavior {
|
|
1772
|
+
BITFIELD_OVERFLOW_BEHAVIOR_UNSPECIFIED = 0,
|
|
1773
|
+
BITFIELD_OVERFLOW_BEHAVIOR_WRAP = 1,
|
|
1774
|
+
BITFIELD_OVERFLOW_BEHAVIOR_SAT = 2,
|
|
1775
|
+
BITFIELD_OVERFLOW_BEHAVIOR_FAIL = 3,
|
|
1776
|
+
UNRECOGNIZED = -1
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
declare function bitfieldOverflowBehaviorFromJSON(object: any): BitfieldOverflowBehavior;
|
|
1780
|
+
|
|
1781
|
+
declare function bitfieldOverflowBehaviorToJSON(object: BitfieldOverflowBehavior): number;
|
|
1782
|
+
|
|
1783
|
+
declare interface BitfieldRequest {
|
|
1784
|
+
key: string;
|
|
1785
|
+
commands: BitfieldCommand_2[];
|
|
1786
|
+
/** Optional transaction id */
|
|
1787
|
+
transactionId?: TransactionId | undefined;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
declare const BitfieldRequest: {
|
|
1791
|
+
$type: "devvit.plugin.redis.BitfieldRequest";
|
|
1792
|
+
encode(message: BitfieldRequest, writer?: _m0.Writer): _m0.Writer;
|
|
1793
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldRequest;
|
|
1794
|
+
fromJSON(object: any): BitfieldRequest;
|
|
1795
|
+
toJSON(message: BitfieldRequest): unknown;
|
|
1796
|
+
create(base?: DeepPartial_63<BitfieldRequest>): BitfieldRequest;
|
|
1797
|
+
fromPartial(object: DeepPartial_63<BitfieldRequest>): BitfieldRequest;
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
declare interface BitfieldResponse {
|
|
1801
|
+
results: number[];
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
declare const BitfieldResponse: {
|
|
1805
|
+
$type: "devvit.plugin.redis.BitfieldResponse";
|
|
1806
|
+
encode(message: BitfieldResponse, writer?: _m0.Writer): _m0.Writer;
|
|
1807
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldResponse;
|
|
1808
|
+
fromJSON(object: any): BitfieldResponse;
|
|
1809
|
+
toJSON(message: BitfieldResponse): unknown;
|
|
1810
|
+
create(base?: DeepPartial_63<BitfieldResponse>): BitfieldResponse;
|
|
1811
|
+
fromPartial(object: DeepPartial_63<BitfieldResponse>): BitfieldResponse;
|
|
1812
|
+
};
|
|
1813
|
+
|
|
1814
|
+
declare interface BitfieldSet {
|
|
1815
|
+
encoding: string;
|
|
1816
|
+
offset: string;
|
|
1817
|
+
value: string;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
declare const BitfieldSet: {
|
|
1821
|
+
$type: "devvit.plugin.redis.BitfieldSet";
|
|
1822
|
+
encode(message: BitfieldSet, writer?: _m0.Writer): _m0.Writer;
|
|
1823
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldSet;
|
|
1824
|
+
fromJSON(object: any): BitfieldSet;
|
|
1825
|
+
toJSON(message: BitfieldSet): unknown;
|
|
1826
|
+
create(base?: DeepPartial_63<BitfieldSet>): BitfieldSet;
|
|
1827
|
+
fromPartial(object: DeepPartial_63<BitfieldSet>): BitfieldSet;
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* Represents a 'set' operation in a bitfield command
|
|
1832
|
+
*/
|
|
1833
|
+
declare type BitfieldSet_2 = [
|
|
1834
|
+
set: 'set',
|
|
1835
|
+
encoding: BitfieldEncoding,
|
|
1836
|
+
offset: BitfieldOffset,
|
|
1837
|
+
/**
|
|
1838
|
+
* Value to set the bitfield to
|
|
1839
|
+
*/
|
|
1840
|
+
value: number | `${number}`
|
|
1841
|
+
];
|
|
1842
|
+
|
|
1669
1843
|
declare interface Block {
|
|
1670
1844
|
type: BlockType;
|
|
1671
1845
|
/**
|
|
@@ -36035,6 +36209,7 @@ declare namespace protos {
|
|
|
36035
36209
|
WidgetsDefinition,
|
|
36036
36210
|
Wiki,
|
|
36037
36211
|
WikiDefinition,
|
|
36212
|
+
BitfieldOverflowBehavior,
|
|
36038
36213
|
RedisAPIDefinition,
|
|
36039
36214
|
RedisKeyScope,
|
|
36040
36215
|
Scheduler_2 as Scheduler,
|
|
@@ -36457,6 +36632,8 @@ declare namespace protos {
|
|
|
36457
36632
|
AllowEditorRequest,
|
|
36458
36633
|
redisKeyScopeFromJSON,
|
|
36459
36634
|
redisKeyScopeToJSON,
|
|
36635
|
+
bitfieldOverflowBehaviorFromJSON,
|
|
36636
|
+
bitfieldOverflowBehaviorToJSON,
|
|
36460
36637
|
TransactionResponses,
|
|
36461
36638
|
TransactionResponse,
|
|
36462
36639
|
ZRangeRequest,
|
|
@@ -36497,6 +36674,13 @@ declare namespace protos {
|
|
|
36497
36674
|
ZMember_2 as ZMember,
|
|
36498
36675
|
TransactionId,
|
|
36499
36676
|
WatchRequest,
|
|
36677
|
+
BitfieldRequest,
|
|
36678
|
+
BitfieldCommand_2 as BitfieldCommand,
|
|
36679
|
+
BitfieldGet,
|
|
36680
|
+
BitfieldSet,
|
|
36681
|
+
BitfieldIncrBy,
|
|
36682
|
+
BitfieldOverflow,
|
|
36683
|
+
BitfieldResponse,
|
|
36500
36684
|
RedisAPI,
|
|
36501
36685
|
RedisAPIServiceName,
|
|
36502
36686
|
RedisAPIClientImpl,
|
|
@@ -38562,6 +38746,8 @@ declare interface RedisAPI {
|
|
|
38562
38746
|
ZRank(request: ZRankRequest, metadata?: Metadata): Promise<Int64Value>;
|
|
38563
38747
|
ZIncrBy(request: ZIncrByRequest, metadata?: Metadata): Promise<DoubleValue>;
|
|
38564
38748
|
ZScan(request: ZScanRequest, metadata?: Metadata): Promise<ZScanResponse>;
|
|
38749
|
+
/** Bitfield */
|
|
38750
|
+
Bitfield(request: BitfieldRequest, metadata?: Metadata): Promise<BitfieldResponse>;
|
|
38565
38751
|
}
|
|
38566
38752
|
|
|
38567
38753
|
declare class RedisAPIClientImpl implements RedisAPI {
|
|
@@ -38607,6 +38793,7 @@ declare class RedisAPIClientImpl implements RedisAPI {
|
|
|
38607
38793
|
ZRank(request: ZRankRequest, metadata?: Metadata): Promise<Int64Value>;
|
|
38608
38794
|
ZIncrBy(request: ZIncrByRequest, metadata?: Metadata): Promise<DoubleValue>;
|
|
38609
38795
|
ZScan(request: ZScanRequest, metadata?: Metadata): Promise<ZScanResponse>;
|
|
38796
|
+
Bitfield(request: BitfieldRequest, metadata?: Metadata): Promise<BitfieldResponse>;
|
|
38610
38797
|
}
|
|
38611
38798
|
|
|
38612
38799
|
/**
|
|
@@ -39618,6 +39805,31 @@ declare const RedisAPIDefinition: {
|
|
|
39618
39805
|
readonly responseStream: false;
|
|
39619
39806
|
readonly options: {};
|
|
39620
39807
|
};
|
|
39808
|
+
/** Bitfield */
|
|
39809
|
+
readonly bitfield: {
|
|
39810
|
+
readonly name: "Bitfield";
|
|
39811
|
+
readonly requestType: {
|
|
39812
|
+
$type: "devvit.plugin.redis.BitfieldRequest";
|
|
39813
|
+
encode(message: BitfieldRequest, writer?: _m0.Writer): _m0.Writer;
|
|
39814
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldRequest;
|
|
39815
|
+
fromJSON(object: any): BitfieldRequest;
|
|
39816
|
+
toJSON(message: BitfieldRequest): unknown;
|
|
39817
|
+
create(base?: DeepPartial_63<BitfieldRequest>): BitfieldRequest;
|
|
39818
|
+
fromPartial(object: DeepPartial_63<BitfieldRequest>): BitfieldRequest;
|
|
39819
|
+
};
|
|
39820
|
+
readonly requestStream: false;
|
|
39821
|
+
readonly responseType: {
|
|
39822
|
+
$type: "devvit.plugin.redis.BitfieldResponse";
|
|
39823
|
+
encode(message: BitfieldResponse, writer?: _m0.Writer): _m0.Writer;
|
|
39824
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): BitfieldResponse;
|
|
39825
|
+
fromJSON(object: any): BitfieldResponse;
|
|
39826
|
+
toJSON(message: BitfieldResponse): unknown;
|
|
39827
|
+
create(base?: DeepPartial_63<BitfieldResponse>): BitfieldResponse;
|
|
39828
|
+
fromPartial(object: DeepPartial_63<BitfieldResponse>): BitfieldResponse;
|
|
39829
|
+
};
|
|
39830
|
+
readonly responseStream: false;
|
|
39831
|
+
readonly options: {};
|
|
39832
|
+
};
|
|
39621
39833
|
};
|
|
39622
39834
|
};
|
|
39623
39835
|
|
|
@@ -40340,6 +40552,38 @@ export declare type RedisClient = {
|
|
|
40340
40552
|
* ```
|
|
40341
40553
|
*/
|
|
40342
40554
|
hLen(key: string): Promise<number>;
|
|
40555
|
+
/**
|
|
40556
|
+
* Performs operations on a redis string treating it as an array of bits.
|
|
40557
|
+
* Operations available:
|
|
40558
|
+
* - get <encoding> <offset> -- Returns the specified bit field.
|
|
40559
|
+
* - set <encoding> <offset> <value> -- Sets the specified bit field and returns its old value.
|
|
40560
|
+
* - incrBy <encoding> <offset> <increment> -- Increments or decrements (if a negative increment is given) the specified bit field and returns the new value.
|
|
40561
|
+
* - overflow [wrap|sat|fail] -- Alters the overflow behavior of subsequent set's and incrBy's until the next overflow command
|
|
40562
|
+
* https://redis.io/docs/latest/commands/bitfield/
|
|
40563
|
+
* @arg {} key the redis key containing the string to operate on
|
|
40564
|
+
* @arg {} cmds the commands to perform on the string
|
|
40565
|
+
* @returns an array with the result of each command, in order
|
|
40566
|
+
* @example
|
|
40567
|
+
* ```ts
|
|
40568
|
+
* async function bitfieldExample(context: Devvit.Context) {
|
|
40569
|
+
* const fooResults : number[] =
|
|
40570
|
+
* await context.redis.bitfield('foo', 'incrBy', 'i5', 100, 1, 'get', 'u4' 0);
|
|
40571
|
+
* console.log("fooResults: " + fooResults); // [1, 0]
|
|
40572
|
+
*
|
|
40573
|
+
* const barResults : number[] =
|
|
40574
|
+
* await context.redis.bitfield('bar',
|
|
40575
|
+
* 'set', 'u2', 0, 3,
|
|
40576
|
+
* 'get', 'u2', 0,
|
|
40577
|
+
* 'incrBy', 'u2', 0, 1,
|
|
40578
|
+
* 'overflow', 'sat',
|
|
40579
|
+
* 'get', 'u2', 0,
|
|
40580
|
+
* 'set, 'u2', 0, 3,
|
|
40581
|
+
* 'incrBy', 'u2', 0, 1);
|
|
40582
|
+
* console.log("barResults: " + barResults); // [0, 3, 0, 0, 3, 3]
|
|
40583
|
+
* }
|
|
40584
|
+
* ```
|
|
40585
|
+
*/
|
|
40586
|
+
bitfield(key: string, ...cmds: [] | BitfieldCommand | [...BitfieldCommand, ...BitfieldCommand] | [...BitfieldCommand, ...BitfieldCommand, ...BitfieldCommand, ...(number | string)[]]): Promise<number[]>;
|
|
40343
40587
|
/**
|
|
40344
40588
|
* Allows read/write operations to global keys in Redis
|
|
40345
40589
|
* Global redis enables apps to persist and access state across subreddit installations
|