mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 23:40:38 +01:00
Compare commits
8 Commits
socket-not
...
v3.5.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7e2a2f488 | ||
|
|
245e5df385 | ||
|
|
c1f82b78a8 | ||
|
|
c434262e21 | ||
|
|
17cd19c701 | ||
|
|
e2e85053a6 | ||
|
|
f31faa457d | ||
|
|
6790000d1a |
41
CHANGELOG.md
41
CHANGELOG.md
@@ -1,3 +1,44 @@
|
|||||||
|
#### v3.5.2 (2023-11-29)
|
||||||
|
|
||||||
|
##### Chores
|
||||||
|
|
||||||
|
* up composer (49013f81)
|
||||||
|
* incrementing version number - v3.5.1 (4c543488)
|
||||||
|
* update changelog for v3.5.1 (48f7ae99)
|
||||||
|
* incrementing version number - v3.5.0 (d06fb4f0)
|
||||||
|
* incrementing version number - v3.4.3 (5c984250)
|
||||||
|
* incrementing version number - v3.4.2 (3f0dac38)
|
||||||
|
* incrementing version number - v3.4.1 (01e69574)
|
||||||
|
* incrementing version number - v3.4.0 (fd9247c5)
|
||||||
|
* incrementing version number - v3.3.9 (5805e770)
|
||||||
|
* incrementing version number - v3.3.8 (a5603565)
|
||||||
|
* incrementing version number - v3.3.7 (b26f1744)
|
||||||
|
* incrementing version number - v3.3.6 (7fb38792)
|
||||||
|
* incrementing version number - v3.3.4 (a67f84ea)
|
||||||
|
* incrementing version number - v3.3.3 (f94d239b)
|
||||||
|
* incrementing version number - v3.3.2 (ec9dac97)
|
||||||
|
* incrementing version number - v3.3.1 (151cc68f)
|
||||||
|
* incrementing version number - v3.3.0 (fc1ad70f)
|
||||||
|
* incrementing version number - v3.2.3 (b06d3e63)
|
||||||
|
* incrementing version number - v3.2.2 (758ecfcd)
|
||||||
|
* incrementing version number - v3.2.1 (20145074)
|
||||||
|
* incrementing version number - v3.2.0 (9ecac38e)
|
||||||
|
* incrementing version number - v3.1.7 (0b4e81ab)
|
||||||
|
* incrementing version number - v3.1.6 (b3a3b130)
|
||||||
|
* incrementing version number - v3.1.5 (ec19343a)
|
||||||
|
* incrementing version number - v3.1.4 (2452783c)
|
||||||
|
* incrementing version number - v3.1.3 (3b4e9d3f)
|
||||||
|
* incrementing version number - v3.1.2 (40fa3489)
|
||||||
|
* incrementing version number - v3.1.1 (40250733)
|
||||||
|
* incrementing version number - v3.1.0 (0cb386bd)
|
||||||
|
* incrementing version number - v3.0.1 (26f6ea49)
|
||||||
|
* incrementing version number - v3.0.0 (224e08cd)
|
||||||
|
|
||||||
|
##### Bug Fixes
|
||||||
|
|
||||||
|
* closes #12185, fix cli user password reset (6790000d)
|
||||||
|
* thumb width (a9ef58a5)
|
||||||
|
|
||||||
#### v3.5.1 (2023-11-14)
|
#### v3.5.1 (2023-11-14)
|
||||||
|
|
||||||
##### Chores
|
##### Chores
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "nodebb",
|
"name": "nodebb",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"description": "NodeBB Forum",
|
"description": "NodeBB Forum",
|
||||||
"version": "3.5.1",
|
"version": "3.5.3",
|
||||||
"homepage": "https://www.nodebb.org",
|
"homepage": "https://www.nodebb.org",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
"multiparty": "4.2.3",
|
"multiparty": "4.2.3",
|
||||||
"nconf": "0.12.1",
|
"nconf": "0.12.1",
|
||||||
"nodebb-plugin-2factor": "7.4.0",
|
"nodebb-plugin-2factor": "7.4.0",
|
||||||
"nodebb-plugin-composer-default": "10.2.27",
|
"nodebb-plugin-composer-default": "10.2.29",
|
||||||
"nodebb-plugin-dbsearch": "6.2.2",
|
"nodebb-plugin-dbsearch": "6.2.2",
|
||||||
"nodebb-plugin-emoji": "5.1.13",
|
"nodebb-plugin-emoji": "5.1.13",
|
||||||
"nodebb-plugin-emoji-android": "4.0.0",
|
"nodebb-plugin-emoji-android": "4.0.0",
|
||||||
|
|||||||
@@ -463,7 +463,9 @@ module.exports = function (utils, load, warn) {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
Translator.escape = function escape(text) {
|
Translator.escape = function escape(text) {
|
||||||
return typeof text === 'string' ? text.replace(/\[\[/g, '[[').replace(/\]\]/g, ']]') : text;
|
return typeof text === 'string' ?
|
||||||
|
text.replace(/\[\[/g, '[[').replace(/\]\]/g, ']]') :
|
||||||
|
text;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -473,8 +475,7 @@ module.exports = function (utils, load, warn) {
|
|||||||
*/
|
*/
|
||||||
Translator.unescape = function unescape(text) {
|
Translator.unescape = function unescape(text) {
|
||||||
return typeof text === 'string' ?
|
return typeof text === 'string' ?
|
||||||
text.replace(/[/g, '[').replace(/\\\[/g, '[')
|
text.replace(/]]/g, ']]').replace(/[[/g, '[[') :
|
||||||
.replace(/]/g, ']').replace(/\\\]/g, ']') :
|
|
||||||
text;
|
text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const util = require('util');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
@@ -330,10 +329,6 @@ usersAPI.deleteToken = async (caller, { uid, token }) => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSessionAsync = util.promisify((sid, callback) => {
|
|
||||||
db.sessionStore.get(sid, (err, sessionObj) => callback(err, sessionObj || null));
|
|
||||||
});
|
|
||||||
|
|
||||||
usersAPI.revokeSession = async (caller, { uid, uuid }) => {
|
usersAPI.revokeSession = async (caller, { uid, uuid }) => {
|
||||||
// Only admins or global mods (besides the user themselves) can revoke sessions
|
// Only admins or global mods (besides the user themselves) can revoke sessions
|
||||||
if (parseInt(uid, 10) !== caller.uid && !await user.isAdminOrGlobalMod(caller.uid)) {
|
if (parseInt(uid, 10) !== caller.uid && !await user.isAdminOrGlobalMod(caller.uid)) {
|
||||||
@@ -344,7 +339,7 @@ usersAPI.revokeSession = async (caller, { uid, uuid }) => {
|
|||||||
let _id;
|
let _id;
|
||||||
for (const sid of sids) {
|
for (const sid of sids) {
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
const sessionObj = await getSessionAsync(sid);
|
const sessionObj = await db.sessionStoreGet(sid);
|
||||||
if (sessionObj && sessionObj.meta && sessionObj.meta.uuid === uuid) {
|
if (sessionObj && sessionObj.meta && sessionObj.meta.uuid === uuid) {
|
||||||
_id = sid;
|
_id = sid;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ let winston;
|
|||||||
async function init() {
|
async function init() {
|
||||||
db = require('../database');
|
db = require('../database');
|
||||||
await db.init();
|
await db.init();
|
||||||
|
await db.initSessionStore();
|
||||||
|
|
||||||
user = require('../user');
|
user = require('../user');
|
||||||
groups = require('../groups');
|
groups = require('../groups');
|
||||||
|
|||||||
@@ -34,4 +34,26 @@ primaryDB.initSessionStore = async function () {
|
|||||||
primaryDB.sessionStore = await sessionStoreDB.createSessionStore(sessionStoreConfig);
|
primaryDB.sessionStore = await sessionStoreDB.createSessionStore(sessionStoreConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function promisifySessionStoreMethod(method, sid) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!primaryDB.sessionStore) {
|
||||||
|
resolve(method === 'get' ? null : undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
primaryDB.sessionStore[method](sid, (err, result) => {
|
||||||
|
if (err) reject(err);
|
||||||
|
else resolve(method === 'get' ? result || null : undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
primaryDB.sessionStoreGet = function (sid) {
|
||||||
|
return promisifySessionStoreMethod('get', sid);
|
||||||
|
};
|
||||||
|
|
||||||
|
primaryDB.sessionStoreDestroy = function (sid) {
|
||||||
|
return promisifySessionStoreMethod('destroy', sid);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = primaryDB;
|
module.exports = primaryDB;
|
||||||
|
|||||||
@@ -241,10 +241,6 @@ async function checkMaintenance(socket) {
|
|||||||
throw new Error(`[[pages:maintenance.text, ${validator.escape(String(meta.config.title || 'NodeBB'))}]]`);
|
throw new Error(`[[pages:maintenance.text, ${validator.escape(String(meta.config.title || 'NodeBB'))}]]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSessionAsync = util.promisify(
|
|
||||||
(sid, callback) => db.sessionStore.get(sid, (err, sessionObj) => callback(err, sessionObj || null))
|
|
||||||
);
|
|
||||||
|
|
||||||
async function validateSession(socket, errorMsg) {
|
async function validateSession(socket, errorMsg) {
|
||||||
const req = socket.request;
|
const req = socket.request;
|
||||||
const { sessionId } = await plugins.hooks.fire('filter:sockets.sessionId', {
|
const { sessionId } = await plugins.hooks.fire('filter:sockets.sessionId', {
|
||||||
@@ -256,7 +252,7 @@ async function validateSession(socket, errorMsg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionData = await getSessionAsync(sessionId);
|
const sessionData = await db.sessionStoreGet(sessionId);
|
||||||
if (!sessionData) {
|
if (!sessionData) {
|
||||||
throw new Error(errorMsg);
|
throw new Error(errorMsg);
|
||||||
}
|
}
|
||||||
@@ -282,7 +278,7 @@ async function authorize(request, callback) {
|
|||||||
request: request,
|
request: request,
|
||||||
});
|
});
|
||||||
|
|
||||||
const sessionData = await getSessionAsync(sessionId);
|
const sessionData = await db.sessionStoreGet(sessionId);
|
||||||
request.session = sessionData;
|
request.session = sessionData;
|
||||||
let uid = 0;
|
let uid = 0;
|
||||||
if (sessionData && sessionData.passport && sessionData.passport.user) {
|
if (sessionData && sessionData.passport && sessionData.passport.user) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const winston = require('winston');
|
const winston = require('winston');
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
const util = require('util');
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
@@ -62,17 +61,10 @@ module.exports = function (User) {
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSessionFromStore = util.promisify(
|
|
||||||
(sid, callback) => db.sessionStore.get(sid, (err, sessObj) => callback(err, sessObj || null))
|
|
||||||
);
|
|
||||||
const sessionStoreDestroy = util.promisify(
|
|
||||||
(sid, callback) => db.sessionStore.destroy(sid, err => callback(err))
|
|
||||||
);
|
|
||||||
|
|
||||||
User.auth.getSessions = async function (uid, curSessionId) {
|
User.auth.getSessions = async function (uid, curSessionId) {
|
||||||
await cleanExpiredSessions(uid);
|
await cleanExpiredSessions(uid);
|
||||||
const sids = await db.getSortedSetRevRange(`uid:${uid}:sessions`, 0, 19);
|
const sids = await db.getSortedSetRevRange(`uid:${uid}:sessions`, 0, 19);
|
||||||
let sessions = await Promise.all(sids.map(sid => getSessionFromStore(sid)));
|
let sessions = await Promise.all(sids.map(sid => db.sessionStoreGet(sid)));
|
||||||
sessions = sessions.map((sessObj, idx) => {
|
sessions = sessions.map((sessObj, idx) => {
|
||||||
if (sessObj && sessObj.meta) {
|
if (sessObj && sessObj.meta) {
|
||||||
sessObj.meta.current = curSessionId === sids[idx];
|
sessObj.meta.current = curSessionId === sids[idx];
|
||||||
@@ -93,7 +85,7 @@ module.exports = function (User) {
|
|||||||
const expiredSids = [];
|
const expiredSids = [];
|
||||||
await Promise.all(Object.keys(uuidMapping).map(async (uuid) => {
|
await Promise.all(Object.keys(uuidMapping).map(async (uuid) => {
|
||||||
const sid = uuidMapping[uuid];
|
const sid = uuidMapping[uuid];
|
||||||
const sessionObj = await getSessionFromStore(sid);
|
const sessionObj = await db.sessionStoreGet(sid);
|
||||||
const expired = !sessionObj || !sessionObj.hasOwnProperty('passport') ||
|
const expired = !sessionObj || !sessionObj.hasOwnProperty('passport') ||
|
||||||
!sessionObj.passport.hasOwnProperty('user') ||
|
!sessionObj.passport.hasOwnProperty('user') ||
|
||||||
parseInt(sessionObj.passport.user, 10) !== parseInt(uid, 10);
|
parseInt(sessionObj.passport.user, 10) !== parseInt(uid, 10);
|
||||||
@@ -128,13 +120,13 @@ module.exports = function (User) {
|
|||||||
|
|
||||||
User.auth.revokeSession = async function (sessionId, uid) {
|
User.auth.revokeSession = async function (sessionId, uid) {
|
||||||
winston.verbose(`[user.auth] Revoking session ${sessionId} for user ${uid}`);
|
winston.verbose(`[user.auth] Revoking session ${sessionId} for user ${uid}`);
|
||||||
const sessionObj = await getSessionFromStore(sessionId);
|
const sessionObj = await db.sessionStoreGet(sessionId);
|
||||||
if (sessionObj && sessionObj.meta && sessionObj.meta.uuid) {
|
if (sessionObj && sessionObj.meta && sessionObj.meta.uuid) {
|
||||||
await db.deleteObjectField(`uid:${uid}:sessionUUID:sessionId`, sessionObj.meta.uuid);
|
await db.deleteObjectField(`uid:${uid}:sessionUUID:sessionId`, sessionObj.meta.uuid);
|
||||||
}
|
}
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
db.sortedSetRemove(`uid:${uid}:sessions`, sessionId),
|
db.sortedSetRemove(`uid:${uid}:sessions`, sessionId),
|
||||||
sessionStoreDestroy(sessionId),
|
db.sessionStoreDestroy(sessionId),
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,7 +151,7 @@ module.exports = function (User) {
|
|||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
db.deleteAll(sessionKeys.concat(sessionUUIDKeys)),
|
db.deleteAll(sessionKeys.concat(sessionUUIDKeys)),
|
||||||
...sids.map(sid => sessionStoreDestroy(sid)),
|
...sids.map(sid => db.sessionStoreDestroy(sid)),
|
||||||
]);
|
]);
|
||||||
}, { batch: 1000 });
|
}, { batch: 1000 });
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -308,10 +308,6 @@ describe('Translator static methods', () => {
|
|||||||
|
|
||||||
describe('.unescape', () => {
|
describe('.unescape', () => {
|
||||||
it('should unescape escaped translation patterns within text', (done) => {
|
it('should unescape escaped translation patterns within text', (done) => {
|
||||||
assert.strictEqual(
|
|
||||||
Translator.unescape('some nice text \\[\\[global:home\\]\\] here'),
|
|
||||||
'some nice text [[global:home]] here'
|
|
||||||
);
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
Translator.unescape('some nice text [[global:home]] here'),
|
Translator.unescape('some nice text [[global:home]] here'),
|
||||||
'some nice text [[global:home]] here'
|
'some nice text [[global:home]] here'
|
||||||
|
|||||||
56
types/database/hash.d.ts
vendored
Normal file
56
types/database/hash.d.ts
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
export interface Hash {
|
||||||
|
decrObjectField(
|
||||||
|
key: string | string[],
|
||||||
|
field: string,
|
||||||
|
): Promise<number | number[]>
|
||||||
|
|
||||||
|
deleteObjectField(key: string, field: string): Promise<void>
|
||||||
|
|
||||||
|
deleteObjectFields(key: string, fields: string[]): Promise<void>
|
||||||
|
|
||||||
|
getObject(key: string, fields: string[]): Promise<object>
|
||||||
|
|
||||||
|
getObjectField(key: string, field: string): Promise<any>
|
||||||
|
|
||||||
|
getObjectFields(key: string, fields: string[]): Promise<Record<string, any>>
|
||||||
|
|
||||||
|
getObjectKeys(key: string): Promise<string[]>
|
||||||
|
|
||||||
|
getObjectValues(key: string): Promise<any[]>
|
||||||
|
|
||||||
|
getObjects(keys: string[], fields: string[]): Promise<any[]>
|
||||||
|
|
||||||
|
getObjectsFields(
|
||||||
|
keys: string[],
|
||||||
|
fields: string[],
|
||||||
|
): Promise<Record<string, any>[]>
|
||||||
|
|
||||||
|
incrObjectField(
|
||||||
|
key: string | string[],
|
||||||
|
field: string,
|
||||||
|
): Promise<number | number[]>
|
||||||
|
|
||||||
|
incrObjectFieldBy(
|
||||||
|
key: string | string[],
|
||||||
|
field: string,
|
||||||
|
value: number,
|
||||||
|
): Promise<number | number[]>
|
||||||
|
|
||||||
|
incrObjectFieldByBulk(
|
||||||
|
data: [key: string, batch: Record<string, number>][],
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
isObjectField(key: string, field: string): Promise<boolean>
|
||||||
|
|
||||||
|
isObjectFields(key: string, fields: string[]): Promise<boolean[]>
|
||||||
|
|
||||||
|
setObject(key: string | string[], data: Record<string, any>): Promise<void>
|
||||||
|
|
||||||
|
setObjectBulk(args: [key: string, data: Record<string, any>][]): Promise<void>
|
||||||
|
|
||||||
|
setObjectField(
|
||||||
|
key: string | string[],
|
||||||
|
field: string,
|
||||||
|
value: any,
|
||||||
|
): Promise<void>
|
||||||
|
}
|
||||||
54
types/database/index.d.ts
vendored
Normal file
54
types/database/index.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Store } from 'express-session'
|
||||||
|
|
||||||
|
export { Hash } from './hash'
|
||||||
|
export { List } from './list'
|
||||||
|
export { Set } from './set'
|
||||||
|
export { Item } from './string'
|
||||||
|
export {
|
||||||
|
SortedSet,
|
||||||
|
SortedSetTheoryOperation,
|
||||||
|
SortedSetScanBaseParameters,
|
||||||
|
} from './zset'
|
||||||
|
|
||||||
|
export interface Database {
|
||||||
|
checkCompatibility(callback: () => void): Promise<void>
|
||||||
|
|
||||||
|
checkCompatibilityVersion(
|
||||||
|
version: string,
|
||||||
|
callback: () => void,
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
close(): Promise<void>
|
||||||
|
|
||||||
|
createIndices(callback: () => void): Promise<void>
|
||||||
|
|
||||||
|
createSessionStore(options: any): Promise<Store>
|
||||||
|
|
||||||
|
emptydb(): Promise<void>
|
||||||
|
|
||||||
|
flushdb(): Promise<void>
|
||||||
|
|
||||||
|
info(db: any): Promise<any>
|
||||||
|
|
||||||
|
init(): Promise<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RedisStyleMatchString =
|
||||||
|
| string
|
||||||
|
| `*${string}`
|
||||||
|
| `${string}*`
|
||||||
|
| `*${string}*`
|
||||||
|
export type RedisStyleRangeString = `${'(' | '['}${string}` | `${string}`
|
||||||
|
|
||||||
|
export enum ObjectType {
|
||||||
|
HASH = 'hash',
|
||||||
|
LIST = 'list',
|
||||||
|
SET = 'set',
|
||||||
|
STRING = 'string',
|
||||||
|
SORTED_SET = 'zset',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ValueAndScore = { value: string; score: number }
|
||||||
|
export type RedisStyleAggregate = 'SUM' | 'MIN' | 'MAX'
|
||||||
|
export type NumberTowardsMinima = number | '-inf'
|
||||||
|
export type NumberTowardsMaxima = number | '+inf'
|
||||||
15
types/database/list.d.ts
vendored
Normal file
15
types/database/list.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export interface List {
|
||||||
|
listPrepend(key: string, value: string): Promise<void>
|
||||||
|
|
||||||
|
listAppend(key: string, value: string): Promise<void>
|
||||||
|
|
||||||
|
listRemoveLast(key: string): Promise<string | null>
|
||||||
|
|
||||||
|
listRemoveAll(key: string, value: string | string[]): Promise<void>
|
||||||
|
|
||||||
|
listTrim(key: string, start: number, stop: number): Promise<void>
|
||||||
|
|
||||||
|
getListRange(key: string, start: number, stop: number): Promise<string[]>
|
||||||
|
|
||||||
|
listLength(key: string): Promise<number>
|
||||||
|
}
|
||||||
25
types/database/set.d.ts
vendored
Normal file
25
types/database/set.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
export interface Set {
|
||||||
|
getSetMembers(key: string): Promise<string[]>
|
||||||
|
|
||||||
|
getSetsMembers(keys: string[]): Promise<string[][]>
|
||||||
|
|
||||||
|
isMemberOfSets(sets: string[], value: string): Promise<boolean[]>
|
||||||
|
|
||||||
|
isSetMember(key: string, value: string): Promise<boolean>
|
||||||
|
|
||||||
|
isSetMembers(key: string, values: string[]): Promise<boolean[]>
|
||||||
|
|
||||||
|
setAdd(key: string, value: string | string[]): Promise<void>
|
||||||
|
|
||||||
|
setCount(key: string): Promise<number>
|
||||||
|
|
||||||
|
setRemove(key: string | string[], value: string | string[]): Promise<void>
|
||||||
|
|
||||||
|
setRemoveRandom(key: string): Promise<string>
|
||||||
|
|
||||||
|
setsAdd(keys: string[], value: string | string[]): Promise<void>
|
||||||
|
|
||||||
|
setsCount(keys: string[]): Promise<number[]>
|
||||||
|
|
||||||
|
setsRemove(keys: string[], value: string): Promise<void>
|
||||||
|
}
|
||||||
35
types/database/string.d.ts
vendored
Normal file
35
types/database/string.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { ObjectType, RedisStyleMatchString } from './index'
|
||||||
|
|
||||||
|
export interface Item {
|
||||||
|
delete(key: string): Promise<void>
|
||||||
|
|
||||||
|
deleteAll(keys: string[]): Promise<void>
|
||||||
|
|
||||||
|
exists(key: string): Promise<boolean>
|
||||||
|
|
||||||
|
exists(key: string[]): Promise<boolean[]>
|
||||||
|
|
||||||
|
expire(key: string, seconds: number): Promise<void>
|
||||||
|
|
||||||
|
expireAt(key: string, timestampInSeconds: number): Promise<void>
|
||||||
|
|
||||||
|
get(key: string): Promise<string | null>
|
||||||
|
|
||||||
|
increment(key: string): Promise<number>
|
||||||
|
|
||||||
|
pexpire(key: string, ms: number): Promise<void>
|
||||||
|
|
||||||
|
pexpireAt(key: string, timestampInMs: number): Promise<void>
|
||||||
|
|
||||||
|
pttl(key: string): Promise<number>
|
||||||
|
|
||||||
|
rename(oldkey: string, newkey: string): Promise<void>
|
||||||
|
|
||||||
|
scan(params: { match: RedisStyleMatchString }): Promise<string[]>
|
||||||
|
|
||||||
|
set(key: string, value: string): Promise<void>
|
||||||
|
|
||||||
|
ttl(key: string): Promise<number>
|
||||||
|
|
||||||
|
type(key: string): Promise<ObjectType | null>
|
||||||
|
}
|
||||||
245
types/database/zset.d.ts
vendored
Normal file
245
types/database/zset.d.ts
vendored
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
import {
|
||||||
|
NumberTowardsMaxima,
|
||||||
|
NumberTowardsMinima,
|
||||||
|
RedisStyleAggregate,
|
||||||
|
RedisStyleMatchString,
|
||||||
|
RedisStyleRangeString,
|
||||||
|
ValueAndScore,
|
||||||
|
} from './index'
|
||||||
|
|
||||||
|
export type SortedSetTheoryOperation = {
|
||||||
|
sets: string[]
|
||||||
|
sort?: 'ASC' | 'DESC'
|
||||||
|
start?: number
|
||||||
|
stop?: number
|
||||||
|
weights?: number[]
|
||||||
|
aggregate?: RedisStyleAggregate
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SortedSetScanBaseParameters = {
|
||||||
|
key: string
|
||||||
|
match: RedisStyleMatchString
|
||||||
|
limit?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SortedSet {
|
||||||
|
getSortedSetIntersect(
|
||||||
|
params: SortedSetTheoryOperation & { withScores: true },
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetIntersect(
|
||||||
|
params: SortedSetTheoryOperation & { withScores?: false },
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetMembers(key: string): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetMembersWithScores(key: string): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetRange(
|
||||||
|
key: string | string[],
|
||||||
|
start: number,
|
||||||
|
stop: number,
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRangeByLex(
|
||||||
|
key: string | string[],
|
||||||
|
min: RedisStyleRangeString | '-',
|
||||||
|
max: RedisStyleRangeString | '+',
|
||||||
|
start?: number,
|
||||||
|
count?: number,
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRangeByScore(
|
||||||
|
key: string | string[],
|
||||||
|
start: number,
|
||||||
|
count: number,
|
||||||
|
min: NumberTowardsMinima,
|
||||||
|
max: NumberTowardsMaxima,
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRangeByScoreWithScores(
|
||||||
|
key: string | string[],
|
||||||
|
start: number,
|
||||||
|
count: number,
|
||||||
|
min: NumberTowardsMinima,
|
||||||
|
max: NumberTowardsMaxima,
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetRangeWithScores(
|
||||||
|
key: string | string[],
|
||||||
|
start: number,
|
||||||
|
stop: number,
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetRevIntersect(
|
||||||
|
params: SortedSetTheoryOperation & { withScores: true },
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetRevIntersect(
|
||||||
|
params: SortedSetTheoryOperation & { withScores?: false },
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRevRange(
|
||||||
|
key: string | string[],
|
||||||
|
start: number,
|
||||||
|
stop: number,
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRevRangeByLex(
|
||||||
|
key: string,
|
||||||
|
max: RedisStyleRangeString | '+',
|
||||||
|
min: RedisStyleRangeString | '-',
|
||||||
|
start?: number,
|
||||||
|
count?: number,
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRevRangeByScore(
|
||||||
|
key: string,
|
||||||
|
start: number,
|
||||||
|
count: number,
|
||||||
|
max: NumberTowardsMaxima | '+',
|
||||||
|
min: NumberTowardsMinima | '-',
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRevRangeByScoreWithScores(
|
||||||
|
key: string,
|
||||||
|
start: number,
|
||||||
|
count: number,
|
||||||
|
max: NumberTowardsMaxima,
|
||||||
|
min: NumberTowardsMinima,
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetRevRangeWithScores(
|
||||||
|
key: string,
|
||||||
|
start: number,
|
||||||
|
stop: number,
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetRevUnion(
|
||||||
|
params: SortedSetTheoryOperation & { withScores?: false },
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetRevUnion(
|
||||||
|
params: SortedSetTheoryOperation & { withScores: true },
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetScan(
|
||||||
|
params: SortedSetScanBaseParameters & { withScores: true },
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetScan(
|
||||||
|
params: SortedSetScanBaseParameters & { withScores?: false },
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetUnion(
|
||||||
|
params: SortedSetTheoryOperation & { withScores: true },
|
||||||
|
): Promise<ValueAndScore[]>
|
||||||
|
|
||||||
|
getSortedSetUnion(
|
||||||
|
params: SortedSetTheoryOperation & { withScores?: false },
|
||||||
|
): Promise<string[]>
|
||||||
|
|
||||||
|
getSortedSetsMembers(keys: string[]): Promise<string[][]>
|
||||||
|
|
||||||
|
getSortedSetsMembersWithScores(keys: string[]): Promise<ValueAndScore[][]>
|
||||||
|
|
||||||
|
isMemberOfSortedSets(keys: string[], value: string): Promise<boolean[]>
|
||||||
|
|
||||||
|
isSortedSetMember(key: string, value: string): Promise<boolean>
|
||||||
|
|
||||||
|
isSortedSetMembers(key: string, values: string[]): Promise<boolean[]>
|
||||||
|
|
||||||
|
processSortedSet(
|
||||||
|
setKey: string,
|
||||||
|
processFn: (ids: number[]) => Promise<void> | void,
|
||||||
|
options: { withScores?: boolean; batch?: number; interval?: number, reverse?: boolean; },
|
||||||
|
): Promise<any>
|
||||||
|
|
||||||
|
sortedSetAdd(key: string, score: number, value: string): Promise<void>
|
||||||
|
|
||||||
|
sortedSetAdd(key: string, score: number[], value: string[]): Promise<void>
|
||||||
|
|
||||||
|
sortedSetAddBulk(
|
||||||
|
args: [key: string, score: number[], value: string[]][],
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
sortedSetCard(key: string): Promise<number>
|
||||||
|
|
||||||
|
sortedSetCount(
|
||||||
|
key: string,
|
||||||
|
min: NumberTowardsMinima,
|
||||||
|
max: NumberTowardsMaxima,
|
||||||
|
): Promise<number>
|
||||||
|
|
||||||
|
sortedSetIncrBy(
|
||||||
|
key: string,
|
||||||
|
increment: number,
|
||||||
|
value: string,
|
||||||
|
): Promise<number>
|
||||||
|
|
||||||
|
sortedSetIncrByBulk(
|
||||||
|
data: [key: string, increment: number, value: string][],
|
||||||
|
): Promise<number[]>
|
||||||
|
|
||||||
|
sortedSetIntersectCard(keys: string[]): Promise<number>
|
||||||
|
|
||||||
|
sortedSetLexCount(
|
||||||
|
key: string,
|
||||||
|
min: RedisStyleRangeString,
|
||||||
|
max: RedisStyleRangeString,
|
||||||
|
): Promise<number>
|
||||||
|
|
||||||
|
sortedSetRank(key: string, value: string): Promise<number | null>
|
||||||
|
|
||||||
|
sortedSetRanks(key: string, values: string[]): Promise<(number | null)[]>
|
||||||
|
|
||||||
|
sortedSetRemove(
|
||||||
|
key: string | string[],
|
||||||
|
value: string | string[],
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
sortedSetRemoveBulk(data: [key: string, member: string][]): Promise<void>
|
||||||
|
|
||||||
|
sortedSetRemoveRangeByLex(
|
||||||
|
key: string,
|
||||||
|
min: RedisStyleRangeString | '-',
|
||||||
|
max: RedisStyleRangeString | '+',
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
sortedSetRevRank(key: string, value: string): Promise<number>
|
||||||
|
|
||||||
|
sortedSetRevRanks(key: string, values: string[]): Promise<number[]>
|
||||||
|
|
||||||
|
sortedSetScore(key: string, value: string): Promise<number | null>
|
||||||
|
|
||||||
|
sortedSetScores(key: string, values: string[]): Promise<number[]>
|
||||||
|
|
||||||
|
sortedSetUnionCard(keys: string[]): Promise<number>
|
||||||
|
|
||||||
|
sortedSetsAdd(
|
||||||
|
keys: string[],
|
||||||
|
scores: number | number[],
|
||||||
|
value: string,
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
sortedSetsCard(keys: string[]): Promise<number[]>
|
||||||
|
|
||||||
|
sortedSetsCardSum(keys: string[]): Promise<number>
|
||||||
|
|
||||||
|
sortedSetsRanks<T extends readonly [] | readonly string[]>(
|
||||||
|
keys: T,
|
||||||
|
values: { [K in keyof T]: string },
|
||||||
|
): Promise<number[]>
|
||||||
|
|
||||||
|
sortedSetsRemove(keys: string[], value: string): Promise<void>
|
||||||
|
|
||||||
|
sortedSetsRemoveRangeByScore(
|
||||||
|
keys: string[],
|
||||||
|
min: NumberTowardsMinima,
|
||||||
|
max: NumberTowardsMaxima,
|
||||||
|
): Promise<void>
|
||||||
|
|
||||||
|
sortedSetsRevRanks(keys: string[], values: string[]): Promise<number[]>
|
||||||
|
|
||||||
|
sortedSetsScore(keys: string[], value: string): Promise<number[]>
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user