Skip to content

Commit a1d78e6

Browse files
committed
bump!: bump elastic to version 9
1 parent 27a9671 commit a1d78e6

3 files changed

Lines changed: 49 additions & 8 deletions

File tree

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"homepage": "https://github.com/Twiddlle/elasticsearch-orm#readme",
3333
"devDependencies": {
34-
"@elastic/elasticsearch": "^8.7.0",
34+
"@elastic/elasticsearch": "^9.0.0",
3535
"@types/dotenv": "^8.2.0",
3636
"@types/jest": "^27.4.1",
3737
"@types/lorem-ipsum": "^2.0.0",
@@ -54,14 +54,16 @@
5454
"reflect-metadata": "^0.2.2"
5555
},
5656
"peerDependencies": {
57-
"@elastic/elasticsearch": "^7.0.0 || ^8.0.0"
57+
"@elastic/elasticsearch": "^8.0.0 || ^9.0.0"
5858
},
5959
"jest": {
6060
"moduleFileExtensions": [
6161
"js",
6262
"ts"
6363
],
64-
"setupFiles": ["<rootDir>/test/setup.ts"],
64+
"setupFiles": [
65+
"<rootDir>/test/setup.ts"
66+
],
6567
"rootDir": ".",
6668
"testEnvironment": "node",
6769
"testRegex": "\\.(integration|spec|performance)\\.ts$",

src/repository/EsRepository.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class EsRepository<Entity> implements EsRepositoryInterface<Entity> {
256256
index: this.getIndex(entity),
257257
id: dbEntity.id,
258258
refresh: this.getRefreshOption(entity),
259-
body: { doc: dbEntity.data },
259+
doc: dbEntity.data,
260260
},
261261
params,
262262
);
@@ -324,7 +324,7 @@ export class EsRepository<Entity> implements EsRepositoryInterface<Entity> {
324324
const esParams = Object.assign(
325325
{
326326
index: this.metaLoader.getIndex(this.Entity),
327-
body: indexInterface,
327+
...indexInterface,
328328
},
329329
params,
330330
);
@@ -363,7 +363,7 @@ export class EsRepository<Entity> implements EsRepositoryInterface<Entity> {
363363
const esParams = Object.assign(
364364
{
365365
index: this.metaLoader.getIndex(this.Entity),
366-
body: mapping,
366+
...mapping,
367367
},
368368
params,
369369
);

test/setup.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
import { ReadableStream } from 'web-streams-polyfill';
2-
// eslint-disable-next-line no-undef
3-
global.ReadableStream = ReadableStream;
2+
import { Blob } from 'buffer';
3+
import { MessageChannel, MessagePort } from 'worker_threads';
4+
5+
// File class polyfill for Node.js environments
6+
class File extends Blob {
7+
name: string;
8+
lastModified: number;
9+
10+
constructor(
11+
chunks: Array<ArrayBuffer | ArrayBufferView | Blob | string>,
12+
name: string,
13+
options?: { type?: string; lastModified?: number },
14+
) {
15+
super(chunks as unknown as Array<ArrayBuffer | Blob>, options);
16+
this.name = name;
17+
this.lastModified = options?.lastModified ?? Date.now();
18+
}
19+
}
20+
21+
// DOMException polyfill
22+
class DOMException extends Error {
23+
code: number;
24+
constructor(message?: string, name?: string) {
25+
super(message);
26+
this.name = name || 'Error';
27+
this.code = 0;
28+
}
29+
}
30+
31+
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
32+
(global as any).ReadableStream = ReadableStream;
33+
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
34+
(global as any).Blob = Blob;
35+
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
36+
(global as any).File = File;
37+
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
38+
(global as any).MessagePort = MessagePort;
39+
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
40+
(global as any).MessageChannel = MessageChannel;
41+
// eslint-disable-next-line no-undef, @typescript-eslint/no-explicit-any
42+
(global as any).DOMException = DOMException;

0 commit comments

Comments
 (0)