@webiny/api-search-index-tasks-os 6.6.0-alpha.1 → 6.6.0-alpha.10
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.
|
@@ -6,8 +6,8 @@ const defaultIndexSettings = {
|
|
|
6
6
|
const indexPrefix = process.env.OPENSEARCH_INDEX_PREFIX || "";
|
|
7
7
|
const filterIndex = (item)=>{
|
|
8
8
|
if (!item) return false;
|
|
9
|
-
if (item.startsWith(".")) return false;
|
|
10
|
-
if (indexPrefix) return item.startsWith(indexPrefix);
|
|
9
|
+
else if (item.startsWith(".")) return false;
|
|
10
|
+
else if (indexPrefix) return item.startsWith(indexPrefix);
|
|
11
11
|
return true;
|
|
12
12
|
};
|
|
13
13
|
class OsIndexManager {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexManager/IndexManager.js","sources":["../../src/indexManager/IndexManager.ts"],"sourcesContent":["import type { IndexManager as IndexManagerAbstraction } from \"@webiny/api-search-index-tasks/abstractions/IndexManager.js\";\nimport type { DisableIndexing } from \"@webiny/api-search-index-tasks/settings/abstractions/DisableIndexing.js\";\nimport type { EnableIndexing } from \"@webiny/api-search-index-tasks/settings/abstractions/EnableIndexing.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { getObjectProperties } from \"@webiny/utils\";\n\nconst defaultIndexSettings: IndexManagerAbstraction.Settings = {\n numberOfReplicas: 1,\n refreshInterval: \"1s\"\n};\n\nconst indexPrefix = process.env.OPENSEARCH_INDEX_PREFIX || \"\";\nconst filterIndex = (item?: string) => {\n if (!item) {\n return false;\n } else if (item.startsWith(\".\")) {\n return false;\n } else if (indexPrefix) {\n return item.startsWith(indexPrefix);\n }\n return true;\n};\n\nexport class OsIndexManager implements IndexManagerAbstraction.Interface {\n private readonly client: Client;\n private readonly disable: DisableIndexing.Interface;\n private readonly enable: EnableIndexing.Interface;\n private readonly _settings: IndexManagerAbstraction.SettingsMap;\n private readonly defaults: IndexManagerAbstraction.Settings;\n\n public get settings(): IndexManagerAbstraction.SettingsMap {\n return this._settings;\n }\n\n public constructor(\n client: Client,\n disableIndexing: DisableIndexing.Interface,\n enableIndexing: EnableIndexing.Interface,\n settings: IndexManagerAbstraction.SettingsMap,\n defaults?: Partial<IndexManagerAbstraction.Settings>\n ) {\n this.client = client;\n this.disable = disableIndexing;\n this.enable = enableIndexing;\n this._settings = settings;\n this.defaults = {\n refreshInterval: defaults?.refreshInterval || defaultIndexSettings.refreshInterval,\n numberOfReplicas: defaults?.numberOfReplicas || defaultIndexSettings.numberOfReplicas\n };\n }\n\n public async list(): Promise<string[]> {\n try {\n const response = await this.client.cat.indices({\n format: \"json\"\n });\n if (!Array.isArray(response.body)) {\n return [];\n }\n return response.body\n .map(item => item.index)\n .filter((index): index is string => filterIndex(index));\n } catch (ex) {\n console.error(\n JSON.stringify({\n message: \"Failed to list indices.\",\n error: getObjectProperties(ex)\n })\n );\n return [];\n }\n }\n\n public async disableIndexing(index: string): Promise<IndexManagerAbstraction.Settings> {\n if (this._settings[index]) {\n return this._settings[index];\n }\n const settings = await this.disable.execute(index);\n this._settings[index] = settings;\n return settings;\n }\n\n public async enableIndexing(index?: string): Promise<void> {\n if (!index) {\n const indexes = Object.keys(this._settings);\n for (const index of indexes) {\n await this.enableIndexing(index);\n }\n return;\n }\n const settings = this._settings[index] || this.defaults;\n await this.enable.execute(index, settings);\n }\n\n public async createIndex(index: string, settings?: GenericRecord): Promise<void> {\n await this.client.indices.create({\n index,\n body: settings\n });\n }\n\n public async indexExists(index: string): Promise<boolean> {\n const response = await this.client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n return !!response.body;\n }\n}\n"],"names":["defaultIndexSettings","indexPrefix","process","filterIndex","item","OsIndexManager","client","disableIndexing","enableIndexing","settings","defaults","response","Array","index","ex","console","JSON","getObjectProperties","indexes","Object"],"mappings":";AAOA,MAAMA,uBAAyD;IAC3D,kBAAkB;IAClB,iBAAiB;AACrB;AAEA,MAAMC,cAAcC,QAAQ,GAAG,CAAC,uBAAuB,IAAI;AAC3D,MAAMC,cAAc,CAACC;IACjB,IAAI,CAACA,MACD,OAAO;
|
|
1
|
+
{"version":3,"file":"indexManager/IndexManager.js","sources":["../../src/indexManager/IndexManager.ts"],"sourcesContent":["import type { IndexManager as IndexManagerAbstraction } from \"@webiny/api-search-index-tasks/abstractions/IndexManager.js\";\nimport type { DisableIndexing } from \"@webiny/api-search-index-tasks/settings/abstractions/DisableIndexing.js\";\nimport type { EnableIndexing } from \"@webiny/api-search-index-tasks/settings/abstractions/EnableIndexing.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { getObjectProperties } from \"@webiny/utils\";\n\nconst defaultIndexSettings: IndexManagerAbstraction.Settings = {\n numberOfReplicas: 1,\n refreshInterval: \"1s\"\n};\n\nconst indexPrefix = process.env.OPENSEARCH_INDEX_PREFIX || \"\";\nconst filterIndex = (item?: string) => {\n if (!item) {\n return false;\n } else if (item.startsWith(\".\")) {\n return false;\n } else if (indexPrefix) {\n return item.startsWith(indexPrefix);\n }\n return true;\n};\n\nexport class OsIndexManager implements IndexManagerAbstraction.Interface {\n private readonly client: Client;\n private readonly disable: DisableIndexing.Interface;\n private readonly enable: EnableIndexing.Interface;\n private readonly _settings: IndexManagerAbstraction.SettingsMap;\n private readonly defaults: IndexManagerAbstraction.Settings;\n\n public get settings(): IndexManagerAbstraction.SettingsMap {\n return this._settings;\n }\n\n public constructor(\n client: Client,\n disableIndexing: DisableIndexing.Interface,\n enableIndexing: EnableIndexing.Interface,\n settings: IndexManagerAbstraction.SettingsMap,\n defaults?: Partial<IndexManagerAbstraction.Settings>\n ) {\n this.client = client;\n this.disable = disableIndexing;\n this.enable = enableIndexing;\n this._settings = settings;\n this.defaults = {\n refreshInterval: defaults?.refreshInterval || defaultIndexSettings.refreshInterval,\n numberOfReplicas: defaults?.numberOfReplicas || defaultIndexSettings.numberOfReplicas\n };\n }\n\n public async list(): Promise<string[]> {\n try {\n const response = await this.client.cat.indices({\n format: \"json\"\n });\n if (!Array.isArray(response.body)) {\n return [];\n }\n return response.body\n .map(item => item.index)\n .filter((index): index is string => filterIndex(index));\n } catch (ex) {\n console.error(\n JSON.stringify({\n message: \"Failed to list indices.\",\n error: getObjectProperties(ex)\n })\n );\n return [];\n }\n }\n\n public async disableIndexing(index: string): Promise<IndexManagerAbstraction.Settings> {\n if (this._settings[index]) {\n return this._settings[index];\n }\n const settings = await this.disable.execute(index);\n this._settings[index] = settings;\n return settings;\n }\n\n public async enableIndexing(index?: string): Promise<void> {\n if (!index) {\n const indexes = Object.keys(this._settings);\n for (const index of indexes) {\n await this.enableIndexing(index);\n }\n return;\n }\n const settings = this._settings[index] || this.defaults;\n await this.enable.execute(index, settings);\n }\n\n public async createIndex(index: string, settings?: GenericRecord): Promise<void> {\n await this.client.indices.create({\n index,\n body: settings\n });\n }\n\n public async indexExists(index: string): Promise<boolean> {\n const response = await this.client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n return !!response.body;\n }\n}\n"],"names":["defaultIndexSettings","indexPrefix","process","filterIndex","item","OsIndexManager","client","disableIndexing","enableIndexing","settings","defaults","response","Array","index","ex","console","JSON","getObjectProperties","indexes","Object"],"mappings":";AAOA,MAAMA,uBAAyD;IAC3D,kBAAkB;IAClB,iBAAiB;AACrB;AAEA,MAAMC,cAAcC,QAAQ,GAAG,CAAC,uBAAuB,IAAI;AAC3D,MAAMC,cAAc,CAACC;IACjB,IAAI,CAACA,MACD,OAAO;SACJ,IAAIA,KAAK,UAAU,CAAC,MACvB,OAAO;SACJ,IAAIH,aACP,OAAOG,KAAK,UAAU,CAACH;IAE3B,OAAO;AACX;AAEO,MAAMI;IAOT,IAAW,WAAgD;QACvD,OAAO,IAAI,CAAC,SA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AAMJ,WAAW,IAAI,CAAC,SAAS,CAACI,MAAM,IAAI,IAAI,CAAC,QAAQ;QACvD,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACA,OAAOJ;IACrC;IAEA,MAAa,YAAYI,KAAa,EAAEJ,QAAwB,EAAiB;QAC7E,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAC7BI;YACA,MAAMJ;QACV;IACJ;IAEA,MAAa,YAAYI,KAAa,EAAoB;QACtD,MAAMF,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAC9CE;YACA,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,eAAe;YACf,OAAO;QACX;QACA,OAAO,CAAC,CAACF,SAAS,IAAI;IAC1B;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-search-index-tasks-os",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "Webiny Ltd.",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@webiny/api": "6.6.0-alpha.
|
|
19
|
-
"@webiny/api-opensearch": "6.6.0-alpha.
|
|
20
|
-
"@webiny/api-search-index-tasks": "6.6.0-alpha.
|
|
21
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
22
|
-
"@webiny/utils": "6.6.0-alpha.
|
|
18
|
+
"@webiny/api": "6.6.0-alpha.10",
|
|
19
|
+
"@webiny/api-opensearch": "6.6.0-alpha.10",
|
|
20
|
+
"@webiny/api-search-index-tasks": "6.6.0-alpha.10",
|
|
21
|
+
"@webiny/feature": "6.6.0-alpha.10",
|
|
22
|
+
"@webiny/utils": "6.6.0-alpha.10"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
25
|
+
"@webiny/build-tools": "6.6.0-alpha.10",
|
|
26
26
|
"typescript": "7.0.2",
|
|
27
|
-
"vitest": "
|
|
27
|
+
"vitest": "5.0.5"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|