Skip to content

Commit

Permalink
chore(git): fix conflict due to weird release
Browse files Browse the repository at this point in the history
  • Loading branch information
rolljee committed Oct 9, 2024
2 parents 0a7cd90 + dbc5168 commit 3c113c4
Show file tree
Hide file tree
Showing 10 changed files with 565 additions and 833 deletions.
5 changes: 1 addition & 4 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ runs:
shell: bash

- run: npm run test:unit
shell: bash

- run: npm run codecov
shell: bash
shell: bash
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# [2.32.0-beta.1](https://github.com/kuzzleio/kuzzle/compare/v2.31.0...v2.32.0-beta.1) (2024-09-13)
# [2.33.0](https://github.com/kuzzleio/kuzzle/compare/v2.32.0...v2.33.0) (2024-10-04)


### Bug Fixes

* improve typing to avoid typescript build errors ([569bf2c](https://github.com/kuzzleio/kuzzle/commit/569bf2c680e70c47cb5b8f81a326f4039e8a5214))


### Features

* **elasticsearch:** add flag to reindex collection after an update ([3cbc2b5](https://github.com/kuzzleio/kuzzle/commit/3cbc2b55e3ff1eb7ddd9c682fd34c87e18c86cbb))

# [2.32.0](https://github.com/kuzzleio/kuzzle/compare/v2.31.0...v2.32.0) (2024-10-02)


### Bug Fixes

* bump deps to remove vulnerabilities ([ef27719](https://github.com/kuzzleio/kuzzle/commit/ef277194e0ed355ca0a5c16c9131875094f3a0b8))
* **ci:** indent to pass linter ([f849e2c](https://github.com/kuzzleio/kuzzle/commit/f849e2c9d2aff5a3636a0b2fc0d11ac86561277a))
* **conflicts:** merge conflict ([e763392](https://github.com/kuzzleio/kuzzle/commit/e76339261029262aac31af972dc81f05a082e469))
* **es8:** add elasticsearch-8 in listened branches ([e59cedd](https://github.com/kuzzleio/kuzzle/commit/e59cedd2a2404e315024f18eb3823af03e341411))
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<p align="center">
<img alt="GitHub branch checks state" src="https://img.shields.io/github/checks-status/kuzzleio/kuzzle/master">
<img alt="Sonarcloud" src="https://sonarcloud.io/api/project_badges/measure?project=kuzzleio_kuzzle&metric=alert_status&branch=master">
<a href="https://codecov.io/gh/kuzzleio/kuzzle">
<img src="https://codecov.io/gh/kuzzleio/kuzzle/branch/master/graph/badge.svg?token=jOrGhzslSM"/>
</a>
<a href="https://lgtm.com/projects/g/kuzzleio/kuzzle/context:javascript">
<img src="https://img.shields.io/lgtm/grade/javascript/g/kuzzleio/kuzzle.svg?logo=lgtm&logoWidth=18" />
</a>
Expand Down
8 changes: 5 additions & 3 deletions doc/2/api/controllers/collection/update/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Body:
}
}
},
"reindexCollection": true|false,
"settings": {
"analysis" : {
"analyzer":{
Expand Down Expand Up @@ -92,6 +93,7 @@ Body:
}
}
},
"reindexCollection": true|false,
"settings": {
"analysis" : {
"analyzer":{
Expand All @@ -117,8 +119,9 @@ Body:

## Body properties

* `settings`: Elasticsearch index [settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
* `mappings`: [collection mappings](/core/2/guides/main-concepts/data-storage#mappings-properties)
- `settings`: Elasticsearch index [settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
- `mappings`: [collection mappings](/core/2/guides/main-concepts/data-storage#mappings-properties)
- `reindexCollection`: boolean, if `true`, the collection will be reindexed after the update

---

Expand All @@ -143,4 +146,3 @@ Body:

- [Common errors](/core/2/api/errors/types#common-errors)
- [NotFoundError](/core/2/api/errors/types#notfounderror)

74 changes: 74 additions & 0 deletions jest/api/controller/collection/update.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Kuzzle, WebSocket } from "kuzzle-sdk";

const kuzzle = new Kuzzle(new WebSocket("localhost"));
const index = "nyc-open-data";
const collection = "green-taxi";
const mappings = {
dynamic: "false" as const,
properties: {
name: {
type: "keyword",
},
},
};

beforeAll(async () => {
await kuzzle.connect();
if (await kuzzle.index.exists(index)) {
await kuzzle.index.delete(index);
}

await kuzzle.index.create(index);
await kuzzle.collection.create(index, collection, {
mappings,
});
});

afterAll(async () => {
await kuzzle.index.delete(index);
kuzzle.disconnect();
});

describe("collection:update", () => {
it("should reindex the collection if asked to", async () => {
await kuzzle.document.create(
index,
collection,
{ age: 42, name: "Bob" },
"document-1",
{ refresh: "wait_for" },
);

let result = await kuzzle.document.search(index, collection, {
query: {
range: {
age: {
gte: 40,
},
},
},
});

expect(result.hits.length).toEqual(0);

await kuzzle.collection.update(index, collection, {
mappings: { properties: { age: { type: "long" } } },
reindexCollection: true,
});

// Wait for the reindexing to complete
await new Promise((r) => setTimeout(r, 2000));

result = await kuzzle.document.search(index, collection, {
query: {
range: {
age: {
gte: 40,
},
},
},
});

expect(result.hits.length).toEqual(1);
});
});
10 changes: 5 additions & 5 deletions lib/kuzzle/kuzzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type ImportStatus = {

class Kuzzle extends KuzzleEventEmitter {
public config: KuzzleConfiguration;
private _state: kuzzleStateEnum = kuzzleStateEnum.STARTING;
private _state: typeof kuzzleStateEnum = kuzzleStateEnum.STARTING;
public log: Logger;
private rootPath: string;
/**
Expand Down Expand Up @@ -138,7 +138,7 @@ class Kuzzle extends KuzzleEventEmitter {
/**
* Validation core component
*/
public validation: Validation;
public validation: typeof Validation;

/**
* Dump generator
Expand All @@ -148,7 +148,7 @@ class Kuzzle extends KuzzleEventEmitter {
/**
* Vault component (will be initialized after bootstrap)
*/
public vault: vault;
public vault: typeof vault;

/**
* AsyncLocalStorage wrapper
Expand Down Expand Up @@ -833,11 +833,11 @@ class Kuzzle extends KuzzleEventEmitter {
);
}

get state() {
get state(): typeof kuzzleStateEnum {
return this._state;
}

set state(value) {
set state(value: typeof kuzzleStateEnum) {
this._state = value;
this.emit("kuzzle:state:change", value);
}
Expand Down
26 changes: 17 additions & 9 deletions lib/service/storage/7/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import _ from "lodash";

import { ApiResponse, RequestParams, Client } from "sdk-es7";
import { ApiResponse, Client, RequestParams } from "sdk-es7";
import { Index, IndicesCreate } from "sdk-es7/api/requestParams";
import { TypeMapping } from "sdk-es7/api/types";
import {
Expand All @@ -39,16 +39,16 @@ import ms from "ms";
import semver from "semver";
import debug from "../../../util/debug";

import ESWrapper from "./esWrapper";
import { QueryTranslator } from "../commons/queryTranslator";
import didYouMean from "../../../util/didYouMean";
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
import * as kerror from "../../../kerror";
import { assertIsObject } from "../../../util/requestAssertions";
import { isPlainObject } from "../../../util/safeObject";
import didYouMean from "../../../util/didYouMean";
import extractFields from "../../../util/extractFields";
import { Mutex } from "../../../util/mutex";
import { randomNumber } from "../../../util/name-generator";
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
import { assertIsObject } from "../../../util/requestAssertions";
import { isPlainObject } from "../../../util/safeObject";
import { QueryTranslator } from "../commons/queryTranslator";
import ESWrapper from "./esWrapper";

debug("kuzzle:services:elasticsearch");

Expand Down Expand Up @@ -1659,8 +1659,13 @@ export class ES7 {
collection: string,
{
mappings = {},
reindexCollection = false,
settings = {},
}: { mappings?: TypeMapping; settings?: Record<string, any> } = {},
}: {
mappings?: TypeMapping;
reindexCollection?: boolean;
settings?: Record<string, any>;
} = {},
) {
const esRequest = {
index: await this._getIndice(index, collection),
Expand Down Expand Up @@ -1690,7 +1695,10 @@ export class ES7 {

await this.updateMapping(index, collection, mappings);

if (this._dynamicChanges(previousMappings, mappings)) {
if (
reindexCollection ||
this._dynamicChanges(previousMappings, mappings)
) {
await this.updateSearchIndex(index, collection);
}
}
Expand Down
21 changes: 13 additions & 8 deletions lib/service/storage/8/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ import {

import assert from "assert";

import ms from "ms";
import Bluebird from "bluebird";
import ms from "ms";
import semver from "semver";

import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
import * as kerror from "../../../kerror";
import debug from "../../../util/debug";
import ESWrapper from "./esWrapper";
import { QueryTranslator } from "../commons/queryTranslator";
import didYouMean from "../../../util/didYouMean";
import * as kerror from "../../../kerror";
import { assertIsObject } from "../../../util/requestAssertions";
import { isPlainObject } from "../../../util/safeObject";
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
import extractFields from "../../../util/extractFields";
import { Mutex } from "../../../util/mutex";
import { randomNumber } from "../../../util/name-generator";
import { assertIsObject } from "../../../util/requestAssertions";
import { isPlainObject } from "../../../util/safeObject";
import { QueryTranslator } from "../commons/queryTranslator";
import ESWrapper from "./esWrapper";

debug("kuzzle:services:elasticsearch");

Expand Down Expand Up @@ -1666,9 +1666,11 @@ export class ES8 {
collection: string,
{
mappings = {},
reindexCollection = false,
settings = {},
}: {
mappings?: estypes.MappingTypeMapping;
reindexCollection?: boolean;
settings?: Record<string, any>;
} = {},
) {
Expand Down Expand Up @@ -1700,7 +1702,10 @@ export class ES8 {

await this.updateMapping(index, collection, mappings);

if (this._dynamicChanges(previousMappings, mappings)) {
if (
reindexCollection ||
this._dynamicChanges(previousMappings, mappings)
) {
await this.updateSearchIndex(index, collection);
}
}
Expand Down
Loading

0 comments on commit 3c113c4

Please sign in to comment.