Skip to content

Commit eaaa7dd

Browse files
Merge pull request #4156 from RedisInsight/feature/RI-4985-use-new-jsonpath
RI-4985 use new jsonpath syntax
2 parents 6cfa524 + 5794de9 commit eaaa7dd

File tree

21 files changed

+339
-250
lines changed

21 files changed

+339
-250
lines changed

redisinsight/api/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@nestjs/websockets": "^10.4.5",
6464
"@okta/okta-auth-js": "^7.8.1",
6565
"@segment/analytics-node": "^2.1.3",
66+
"@types/json-bigint": "^1.0.4",
6667
"adm-zip": "^0.5.9",
6768
"axios": "^1.7.4",
6869
"body-parser": "^1.20.3",
@@ -78,6 +79,7 @@
7879
"fs-extra": "^10.0.0",
7980
"ioredis": "^5.2.2",
8081
"is-glob": "^4.0.1",
82+
"json-bigint": "^1.0.0",
8183
"jsonwebtoken": "^9.0.2",
8284
"keytar": "^7.9.0",
8385
"lodash": "^4.17.20",
@@ -173,10 +175,13 @@
173175
},
174176
"reporters": [
175177
"default",
176-
["jest-html-reporters", {
177-
"publicPath": "./report",
178-
"filename": "index.html"
179-
}]
178+
[
179+
"jest-html-reporters",
180+
{
181+
"publicPath": "./report",
182+
"filename": "index.html"
183+
}
184+
]
180185
]
181186
}
182187
}

redisinsight/api/src/__mocks__/databases.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export const mockDatabaseModules = [
8080
semanticVersion: '1.2.5',
8181
},
8282
];
83+
84+
export const mockDatabaseWithModules = Object.assign(new Database(), {
85+
...mockDatabase,
86+
modules: mockDatabaseModules,
87+
});
88+
8389
export const mockDatabaseWithCloudDetails = Object.assign(new Database(), {
8490
...mockDatabase,
8591
cloudDetails: mockCloudDatabaseDetails,

redisinsight/api/src/modules/browser/keys/key-info/strategies/rejson-rl.key-info.strategy.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe('RejsonRlKeyInfoStrategy', () => {
3535

3636
describe('getInfo', () => {
3737
const key = getKeyInfoResponse.name;
38-
const path = '.';
3938
beforeEach(() => {
4039
when(mockStandaloneRedisClient.sendPipeline)
4140
.calledWith([
@@ -48,13 +47,13 @@ describe('RejsonRlKeyInfoStrategy', () => {
4847
]);
4948
when(mockStandaloneRedisClient.sendCommand)
5049
.calledWith(
51-
[BrowserToolRejsonRlCommands.JsonType, key, path],
50+
[BrowserToolRejsonRlCommands.JsonType, key],
5251
{ replyEncoding: 'utf8' },
5352
)
5453
.mockResolvedValue('object');
5554
when(mockStandaloneRedisClient.sendCommand)
5655
.calledWith(
57-
[BrowserToolRejsonRlCommands.JsonObjLen, key, path],
56+
[BrowserToolRejsonRlCommands.JsonObjLen, key],
5857
{ replyEncoding: 'utf8' },
5958
)
6059
.mockResolvedValue(10);
@@ -71,13 +70,13 @@ describe('RejsonRlKeyInfoStrategy', () => {
7170
it('should return appropriate value for key that store string', async () => {
7271
when(mockStandaloneRedisClient.sendCommand)
7372
.calledWith(
74-
[BrowserToolRejsonRlCommands.JsonType, key, path],
73+
[BrowserToolRejsonRlCommands.JsonType, key],
7574
{ replyEncoding: 'utf8' },
7675
)
7776
.mockResolvedValue('string');
7877
when(mockStandaloneRedisClient.sendCommand)
7978
.calledWith(
80-
[BrowserToolRejsonRlCommands.JsonStrLen, key, path],
79+
[BrowserToolRejsonRlCommands.JsonStrLen, key],
8180
{ replyEncoding: 'utf8' },
8281
)
8382
.mockResolvedValue(10);
@@ -93,13 +92,13 @@ describe('RejsonRlKeyInfoStrategy', () => {
9392
it('should return appropriate value for key that store array', async () => {
9493
when(mockStandaloneRedisClient.sendCommand)
9594
.calledWith(
96-
[BrowserToolRejsonRlCommands.JsonType, key, path],
95+
[BrowserToolRejsonRlCommands.JsonType, key],
9796
{ replyEncoding: 'utf8' },
9897
)
9998
.mockResolvedValue('array');
10099
when(mockStandaloneRedisClient.sendCommand)
101100
.calledWith(
102-
[BrowserToolRejsonRlCommands.JsonArrLen, key, path],
101+
[BrowserToolRejsonRlCommands.JsonArrLen, key],
103102
{ replyEncoding: 'utf8' },
104103
)
105104
.mockResolvedValue(10);
@@ -115,7 +114,7 @@ describe('RejsonRlKeyInfoStrategy', () => {
115114
it('should return appropriate value for key that store not iterable type', async () => {
116115
when(mockStandaloneRedisClient.sendCommand)
117116
.calledWith(
118-
[BrowserToolRejsonRlCommands.JsonType, key, path],
117+
[BrowserToolRejsonRlCommands.JsonType, key],
119118
{ replyEncoding: 'utf8' },
120119
)
121120
.mockResolvedValue('boolean');

redisinsight/api/src/modules/browser/keys/key-info/strategies/rejson-rl.key-info.strategy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@ export class RejsonRlKeyInfoStrategy extends KeyInfoStrategy {
3636
private async getLength(client: RedisClient, key: RedisString): Promise<number> {
3737
try {
3838
const objectKeyType = await client.sendCommand(
39-
[BrowserToolRejsonRlCommands.JsonType, key, '.'],
39+
[BrowserToolRejsonRlCommands.JsonType, key],
4040
{ replyEncoding: 'utf8' },
4141
);
4242

4343
switch (objectKeyType) {
4444
case 'object':
4545
return await client.sendCommand(
46-
[BrowserToolRejsonRlCommands.JsonObjLen, key, '.'],
46+
[BrowserToolRejsonRlCommands.JsonObjLen, key],
4747
{ replyEncoding: 'utf8' },
4848
) as number;
4949
case 'array':
5050
return await client.sendCommand(
51-
[BrowserToolRejsonRlCommands.JsonArrLen, key, '.'],
51+
[BrowserToolRejsonRlCommands.JsonArrLen, key],
5252
{ replyEncoding: 'utf8' },
5353
) as number;
5454
case 'string':
5555
return await client.sendCommand(
56-
[BrowserToolRejsonRlCommands.JsonStrLen, key, '.'],
56+
[BrowserToolRejsonRlCommands.JsonStrLen, key],
5757
{ replyEncoding: 'utf8' },
5858
) as number;
5959
default:

redisinsight/api/src/modules/browser/rejson-rl/dto/get.rejson-rl.dto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ export class GetRejsonRlDto extends KeyDto {
66
@ApiPropertyOptional({
77
type: String,
88
description: 'Path to look for data',
9-
})
9+
})
1010
@IsString()
1111
@IsNotEmpty()
12-
path?: string = '.';
12+
path?: string = '$';
1313

1414
@ApiPropertyOptional({
1515
type: Boolean,
1616
description:
17-
"Don't check for json size and return whole json in path when enabled",
18-
})
17+
"Don't check for json size and return whole json in path when enabled",
18+
})
1919
@IsBoolean()
2020
forceRetrieve?: boolean;
2121
}

0 commit comments

Comments
 (0)