@webiny/api-headless-cms-pg-os 6.6.0-alpha.0 → 6.6.0-alpha.1
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.
- package/features/SyncWriter/BuildSyncRecord.d.ts +3 -1
- package/features/SyncWriter/BuildSyncRecord.js +8 -4
- package/features/SyncWriter/BuildSyncRecord.js.map +1 -1
- package/operations/entry/EntrySearchOperations.d.ts +2 -1
- package/operations/entry/EntrySearchOperations.js +6 -3
- package/operations/entry/EntrySearchOperations.js.map +1 -1
- package/operations/entry/search/getUniqueFieldValues.js +3 -2
- package/operations/entry/search/getUniqueFieldValues.js.map +1 -1
- package/operations/entry/search/list.js +3 -2
- package/operations/entry/search/list.js.map +1 -1
- package/operations/entry/search/types.d.ts +2 -0
- package/package.json +23 -23
|
@@ -2,11 +2,13 @@ import type { CmsEntryValues } from "@webiny/api-headless-cms/types/index.js";
|
|
|
2
2
|
import { BuildSyncRecord as Abstraction } from "./abstractions/BuildSyncRecord.js";
|
|
3
3
|
import { CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
4
4
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
5
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
|
|
5
6
|
import { OperationType } from "@webiny/api-sync-to-opensearch/features/Operations/Operations.js";
|
|
6
7
|
declare class BuildSyncRecordImpl implements Abstraction.Interface {
|
|
7
8
|
private readonly fieldIndexRegistry;
|
|
8
9
|
private readonly compressionHandler;
|
|
9
|
-
|
|
10
|
+
private readonly indexProvider;
|
|
11
|
+
constructor(fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface);
|
|
10
12
|
execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>): Promise<{
|
|
11
13
|
id: string;
|
|
12
14
|
entryId: string;
|
|
@@ -3,12 +3,14 @@ import { CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-u
|
|
|
3
3
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
4
4
|
import { transformEntryToIndex } from "@webiny/api-headless-cms-utils-os/operations/entry/transformations/transformEntryToIndex.js";
|
|
5
5
|
import { createLatestRecordType, createPublishedRecordType } from "@webiny/api-headless-cms-utils-os/operations/entry/recordType.js";
|
|
6
|
-
import {
|
|
6
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
|
|
7
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
7
8
|
import { OperationType } from "@webiny/api-sync-to-opensearch/features/Operations/Operations.js";
|
|
8
9
|
class BuildSyncRecordImpl {
|
|
9
|
-
constructor(fieldIndexRegistry, compressionHandler){
|
|
10
|
+
constructor(fieldIndexRegistry, compressionHandler, indexProvider){
|
|
10
11
|
this.fieldIndexRegistry = fieldIndexRegistry;
|
|
11
12
|
this.compressionHandler = compressionHandler;
|
|
13
|
+
this.indexProvider = indexProvider;
|
|
12
14
|
}
|
|
13
15
|
async execute(params) {
|
|
14
16
|
const { model, entry, storageEntry, kind } = params;
|
|
@@ -31,7 +33,8 @@ class BuildSyncRecordImpl {
|
|
|
31
33
|
__type: recordType
|
|
32
34
|
};
|
|
33
35
|
const compressed = await this.compressionHandler.compress(document);
|
|
34
|
-
const
|
|
36
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
37
|
+
const { index } = await configurations.es({
|
|
35
38
|
model
|
|
36
39
|
});
|
|
37
40
|
return {
|
|
@@ -48,7 +51,8 @@ const BuildSyncRecord_BuildSyncRecord = BuildSyncRecord.createImplementation({
|
|
|
48
51
|
implementation: BuildSyncRecordImpl,
|
|
49
52
|
dependencies: [
|
|
50
53
|
CmsEntryOpenSearchFieldIndexRegistry,
|
|
51
|
-
CompressionHandler
|
|
54
|
+
CompressionHandler,
|
|
55
|
+
CmsModelOpenSearchIndexProvider
|
|
52
56
|
]
|
|
53
57
|
});
|
|
54
58
|
export { BuildSyncRecord_BuildSyncRecord as BuildSyncRecord };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/SyncWriter/BuildSyncRecord.js","sources":["../../../src/features/SyncWriter/BuildSyncRecord.ts"],"sourcesContent":["import type { CmsEntryValues } from \"@webiny/api-headless-cms/types/index.js\";\nimport { BuildSyncRecord as Abstraction } from \"./abstractions/BuildSyncRecord.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { transformEntryToIndex } from \"@webiny/api-headless-cms-utils-os/operations/entry/transformations/transformEntryToIndex.js\";\nimport {\n createLatestRecordType,\n createPublishedRecordType\n} from \"@webiny/api-headless-cms-utils-os/operations/entry/recordType.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/BuildSyncRecord.js","sources":["../../../src/features/SyncWriter/BuildSyncRecord.ts"],"sourcesContent":["import type { CmsEntryValues } from \"@webiny/api-headless-cms/types/index.js\";\nimport { BuildSyncRecord as Abstraction } from \"./abstractions/BuildSyncRecord.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { transformEntryToIndex } from \"@webiny/api-headless-cms-utils-os/operations/entry/transformations/transformEntryToIndex.js\";\nimport {\n createLatestRecordType,\n createPublishedRecordType\n} from \"@webiny/api-headless-cms-utils-os/operations/entry/recordType.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { OperationType } from \"@webiny/api-sync-to-opensearch/features/Operations/Operations.js\";\n\nclass BuildSyncRecordImpl implements Abstraction.Interface {\n public constructor(\n private readonly fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private readonly compressionHandler: CompressionHandler.Interface,\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>) {\n const { model, entry, storageEntry, kind } = params;\n\n const indexEntry = transformEntryToIndex({\n model,\n entry,\n storageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry\n });\n\n const isLatest = kind === \"latest\";\n const recordType = isLatest ? createLatestRecordType() : createPublishedRecordType();\n\n const document = {\n ...indexEntry,\n ...(isLatest ? { latest: true } : { published: true }),\n TYPE: recordType,\n __type: recordType\n };\n\n const compressed = await this.compressionHandler.compress(document);\n const configurations = createConfigurations(this.indexProvider);\n const { index } = await configurations.es({ model });\n\n return {\n id: `${entry.entryId}:${isLatest ? \"L\" : \"P\"}`,\n entryId: entry.entryId,\n index,\n operation: OperationType.MODIFY,\n data: JSON.stringify(compressed),\n tenant: entry.tenant\n };\n }\n}\n\nexport const BuildSyncRecord = Abstraction.createImplementation({\n implementation: BuildSyncRecordImpl,\n dependencies: [\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider\n ]\n});\n"],"names":["BuildSyncRecordImpl","fieldIndexRegistry","compressionHandler","indexProvider","params","model","entry","storageEntry","kind","indexEntry","transformEntryToIndex","isLatest","recordType","createLatestRecordType","createPublishedRecordType","document","compressed","configurations","createConfigurations","index","OperationType","JSON","BuildSyncRecord","Abstraction","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider"],"mappings":";;;;;;;;AAaA,MAAMA;IACF,YACqBC,kBAAkE,EAClEC,kBAAgD,EAChDC,aAAwD,CAC3E;aAHmBF,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,QAAmDC,MAA6B,EAAE;QAC3F,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAE,GAAGJ;QAE7C,MAAMK,aAAaC,sBAAsB;YACrCL;YACAC;YACAC;YACA,oBAAoB,IAAI,CAAC,kBAAkB;QAC/C;QAEA,MAAMI,WAAWH,AAAS,aAATA;QACjB,MAAMI,aAAaD,WAAWE,2BAA2BC;QAEzD,MAAMC,WAAW;YACb,GAAGN,UAAU;YACb,GAAIE,WAAW;gBAAE,QAAQ;YAAK,IAAI;gBAAE,WAAW;YAAK,CAAC;YACrD,MAAMC;YACN,QAAQA;QACZ;QAEA,MAAMI,aAAa,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAACD;QAC1D,MAAME,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAC9D,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMF,eAAe,EAAE,CAAC;YAAEZ;QAAM;QAElD,OAAO;YACH,IAAI,GAAGC,MAAM,OAAO,CAAC,CAAC,EAAEK,WAAW,MAAM,KAAK;YAC9C,SAASL,MAAM,OAAO;YACtBa;YACA,WAAWC,cAAc,MAAM;YAC/B,MAAMC,KAAK,SAAS,CAACL;YACrB,QAAQV,MAAM,MAAM;QACxB;IACJ;AACJ;AAEO,MAAMgB,kCAAkBC,gBAAAA,oBAAgC,CAAC;IAC5D,gBAAgBvB;IAChB,cAAc;QACVwB;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { IEntrySearchOperations } from "./abstractions/EntrySearchOperations.js";
|
|
2
2
|
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
3
3
|
import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
4
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
|
|
4
5
|
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
5
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
7
|
declare class EntrySearchOperationsImpl implements IEntrySearchOperations {
|
|
7
8
|
readonly list: IEntrySearchOperations["list"];
|
|
8
9
|
readonly get: IEntrySearchOperations["get"];
|
|
9
10
|
readonly getUniqueFieldValues: IEntrySearchOperations["getUniqueFieldValues"];
|
|
10
|
-
constructor(openSearchClient: OpenSearchClient.Interface, bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
11
|
+
constructor(openSearchClient: OpenSearchClient.Interface, bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface);
|
|
11
12
|
}
|
|
12
13
|
export declare const EntrySearchOperations: typeof EntrySearchOperationsImpl & {
|
|
13
14
|
__abstraction: import("@webiny/di").Abstraction<IEntrySearchOperations>;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { EntrySearchOperations } from "./abstractions/EntrySearchOperations.js";
|
|
2
2
|
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
3
3
|
import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
4
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
|
|
4
5
|
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
5
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
7
|
import { createListOperation } from "./search/list.js";
|
|
7
8
|
import { createGetOperation } from "./search/get.js";
|
|
8
9
|
import { createGetUniqueFieldValuesOperation } from "./search/getUniqueFieldValues.js";
|
|
9
10
|
class EntrySearchOperationsImpl {
|
|
10
|
-
constructor(openSearchClient, bodyBuilder, fieldRegistry, fieldIndexRegistry, storageModelProvider){
|
|
11
|
+
constructor(openSearchClient, bodyBuilder, fieldRegistry, fieldIndexRegistry, storageModelProvider, indexProvider){
|
|
11
12
|
const deps = {
|
|
12
13
|
elasticsearch: openSearchClient.use(),
|
|
13
14
|
bodyBuilder,
|
|
14
15
|
fieldRegistry,
|
|
15
16
|
fieldIndexRegistry,
|
|
16
|
-
getStorageOperationsModel: (model)=>storageModelProvider.getModel(model)
|
|
17
|
+
getStorageOperationsModel: (model)=>storageModelProvider.getModel(model),
|
|
18
|
+
indexProvider
|
|
17
19
|
};
|
|
18
20
|
this.list = createListOperation(deps);
|
|
19
21
|
this.get = createGetOperation(deps);
|
|
@@ -27,7 +29,8 @@ const EntrySearchOperations_EntrySearchOperations = EntrySearchOperations.create
|
|
|
27
29
|
CmsEntryOpenSearchBodyBuilder,
|
|
28
30
|
CmsModelFieldToGraphQLRegistry,
|
|
29
31
|
CmsEntryOpenSearchFieldIndexRegistry,
|
|
30
|
-
CmsStorageModelProvider
|
|
32
|
+
CmsStorageModelProvider,
|
|
33
|
+
CmsModelOpenSearchIndexProvider
|
|
31
34
|
]
|
|
32
35
|
});
|
|
33
36
|
export { EntrySearchOperations_EntrySearchOperations as EntrySearchOperations };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/EntrySearchOperations.js","sources":["../../../src/operations/entry/EntrySearchOperations.ts"],"sourcesContent":["import { EntrySearchOperations as Abstraction } from \"./abstractions/EntrySearchOperations.js\";\nimport type { IEntrySearchOperations } from \"./abstractions/EntrySearchOperations.js\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport {\n CmsEntryOpenSearchBodyBuilder,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { SearchOperationDeps } from \"./search/types.js\";\nimport { createListOperation } from \"./search/list.js\";\nimport { createGetOperation } from \"./search/get.js\";\nimport { createGetUniqueFieldValuesOperation } from \"./search/getUniqueFieldValues.js\";\n\nclass EntrySearchOperationsImpl implements IEntrySearchOperations {\n public readonly list: IEntrySearchOperations[\"list\"];\n public readonly get: IEntrySearchOperations[\"get\"];\n public readonly getUniqueFieldValues: IEntrySearchOperations[\"getUniqueFieldValues\"];\n\n public constructor(\n openSearchClient: OpenSearchClient.Interface,\n bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface,\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface,\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n storageModelProvider: CmsStorageModelProvider.Interface\n ) {\n const deps: SearchOperationDeps = {\n elasticsearch: openSearchClient.use(),\n bodyBuilder,\n fieldRegistry,\n fieldIndexRegistry,\n getStorageOperationsModel: model => storageModelProvider.getModel(model)\n };\n\n this.list = createListOperation(deps);\n this.get = createGetOperation(deps);\n this.getUniqueFieldValues = createGetUniqueFieldValuesOperation(deps);\n }\n}\n\nexport const EntrySearchOperations = Abstraction.createImplementation({\n implementation: EntrySearchOperationsImpl,\n dependencies: [\n OpenSearchClient,\n CmsEntryOpenSearchBodyBuilder,\n CmsModelFieldToGraphQLRegistry,\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsStorageModelProvider\n ]\n});\n"],"names":["EntrySearchOperationsImpl","openSearchClient","bodyBuilder","fieldRegistry","fieldIndexRegistry","storageModelProvider","deps","model","createListOperation","createGetOperation","createGetUniqueFieldValuesOperation","EntrySearchOperations","Abstraction","OpenSearchClient","CmsEntryOpenSearchBodyBuilder","CmsModelFieldToGraphQLRegistry","CmsEntryOpenSearchFieldIndexRegistry","CmsStorageModelProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations/entry/EntrySearchOperations.js","sources":["../../../src/operations/entry/EntrySearchOperations.ts"],"sourcesContent":["import { EntrySearchOperations as Abstraction } from \"./abstractions/EntrySearchOperations.js\";\nimport type { IEntrySearchOperations } from \"./abstractions/EntrySearchOperations.js\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport {\n CmsEntryOpenSearchBodyBuilder,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { SearchOperationDeps } from \"./search/types.js\";\nimport { createListOperation } from \"./search/list.js\";\nimport { createGetOperation } from \"./search/get.js\";\nimport { createGetUniqueFieldValuesOperation } from \"./search/getUniqueFieldValues.js\";\n\nclass EntrySearchOperationsImpl implements IEntrySearchOperations {\n public readonly list: IEntrySearchOperations[\"list\"];\n public readonly get: IEntrySearchOperations[\"get\"];\n public readonly getUniqueFieldValues: IEntrySearchOperations[\"getUniqueFieldValues\"];\n\n public constructor(\n openSearchClient: OpenSearchClient.Interface,\n bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface,\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface,\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n storageModelProvider: CmsStorageModelProvider.Interface,\n indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {\n const deps: SearchOperationDeps = {\n elasticsearch: openSearchClient.use(),\n bodyBuilder,\n fieldRegistry,\n fieldIndexRegistry,\n getStorageOperationsModel: model => storageModelProvider.getModel(model),\n indexProvider\n };\n\n this.list = createListOperation(deps);\n this.get = createGetOperation(deps);\n this.getUniqueFieldValues = createGetUniqueFieldValuesOperation(deps);\n }\n}\n\nexport const EntrySearchOperations = Abstraction.createImplementation({\n implementation: EntrySearchOperationsImpl,\n dependencies: [\n OpenSearchClient,\n CmsEntryOpenSearchBodyBuilder,\n CmsModelFieldToGraphQLRegistry,\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsStorageModelProvider,\n CmsModelOpenSearchIndexProvider\n ]\n});\n"],"names":["EntrySearchOperationsImpl","openSearchClient","bodyBuilder","fieldRegistry","fieldIndexRegistry","storageModelProvider","indexProvider","deps","model","createListOperation","createGetOperation","createGetUniqueFieldValuesOperation","EntrySearchOperations","Abstraction","OpenSearchClient","CmsEntryOpenSearchBodyBuilder","CmsModelFieldToGraphQLRegistry","CmsEntryOpenSearchFieldIndexRegistry","CmsStorageModelProvider","CmsModelOpenSearchIndexProvider"],"mappings":";;;;;;;;;AAeA,MAAMA;IAKF,YACIC,gBAA4C,EAC5CC,WAAoD,EACpDC,aAAuD,EACvDC,kBAAkE,EAClEC,oBAAuD,EACvDC,aAAwD,CAC1D;QACE,MAAMC,OAA4B;YAC9B,eAAeN,iBAAiB,GAAG;YACnCC;YACAC;YACAC;YACA,2BAA2BI,CAAAA,QAASH,qBAAqB,QAAQ,CAACG;YAClEF;QACJ;QAEA,IAAI,CAAC,IAAI,GAAGG,oBAAoBF;QAChC,IAAI,CAAC,GAAG,GAAGG,mBAAmBH;QAC9B,IAAI,CAAC,oBAAoB,GAAGI,oCAAoCJ;IACpE;AACJ;AAEO,MAAMK,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBb;IAChB,cAAc;QACVc;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _webiny_error from "@webiny/error";
|
|
2
2
|
import { shouldIgnoreEsResponseError } from "@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
4
4
|
const createGetUniqueFieldValuesOperation = (deps)=>async (model, uniqueFieldValuesParams)=>{
|
|
5
5
|
const { where, fieldId } = uniqueFieldValuesParams;
|
|
6
|
-
const
|
|
6
|
+
const configurations = createConfigurations(deps.indexProvider);
|
|
7
|
+
const { index } = await configurations.es({
|
|
7
8
|
model
|
|
8
9
|
});
|
|
9
10
|
const field = model.fields.find((f)=>f.fieldId === fieldId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/search/getUniqueFieldValues.js","sources":["../../../../src/operations/entry/search/getUniqueFieldValues.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { OpenSearchSearchResponse } from \"@webiny/api-opensearch\";\nimport { shouldIgnoreEsResponseError } from \"@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"operations/entry/search/getUniqueFieldValues.js","sources":["../../../../src/operations/entry/search/getUniqueFieldValues.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { OpenSearchSearchResponse } from \"@webiny/api-opensearch\";\nimport { shouldIgnoreEsResponseError } from \"@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport type { SearchOperationDeps } from \"./types.js\";\nimport type { GetUniqueFieldValuesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js\";\n\nexport const createGetUniqueFieldValuesOperation = (\n deps: SearchOperationDeps\n): GetUniqueFieldValuesStorageOperation.Interface[\"execute\"] => {\n return async (model, uniqueFieldValuesParams) => {\n const { where, fieldId } = uniqueFieldValuesParams;\n const configurations = createConfigurations(deps.indexProvider);\n const { index } = await configurations.es({ model });\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n return [];\n }\n\n const initialBody = deps.bodyBuilder.build({\n model,\n params: { limit: 1, where }\n });\n\n const body = {\n ...initialBody,\n size: 0,\n aggregations: {\n getUniqueFieldValues: {\n terms: {\n field: `values.${field.storageId}.keyword`,\n size: 1000000\n }\n }\n }\n };\n\n let response: OpenSearchSearchResponse;\n try {\n response = await deps.elasticsearch.search({ index, body });\n } catch (error) {\n if (shouldIgnoreEsResponseError(error)) {\n return [];\n }\n throw new WebinyError(error.message, error.code || \"OPENSEARCH_ERROR\", {\n error,\n index,\n model,\n body\n });\n }\n\n const aggregations = response.body.aggregations || {};\n const agg = aggregations[\"getUniqueFieldValues\"];\n const buckets = agg && \"buckets\" in agg && Array.isArray(agg.buckets) ? agg.buckets : [];\n return buckets.map((bucket: { key: string; doc_count: number }) => ({\n value: bucket.key,\n count: bucket.doc_count\n }));\n };\n};\n"],"names":["createGetUniqueFieldValuesOperation","deps","model","uniqueFieldValuesParams","where","fieldId","configurations","createConfigurations","index","field","f","initialBody","body","response","error","shouldIgnoreEsResponseError","WebinyError","aggregations","agg","buckets","Array","bucket"],"mappings":";;;AAOO,MAAMA,sCAAsC,CAC/CC,OAEO,OAAOC,OAAOC;QACjB,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAE,GAAGF;QAC3B,MAAMG,iBAAiBC,qBAAqBN,KAAK,aAAa;QAC9D,MAAM,EAAEO,KAAK,EAAE,GAAG,MAAMF,eAAe,EAAE,CAAC;YAAEJ;QAAM;QAElD,MAAMO,QAAQP,MAAM,MAAM,CAAC,IAAI,CAACQ,CAAAA,IAAKA,EAAE,OAAO,KAAKL;QACnD,IAAI,CAACI,OACD,OAAO,EAAE;QAGb,MAAME,cAAcV,KAAK,WAAW,CAAC,KAAK,CAAC;YACvCC;YACA,QAAQ;gBAAE,OAAO;gBAAGE;YAAM;QAC9B;QAEA,MAAMQ,OAAO;YACT,GAAGD,WAAW;YACd,MAAM;YACN,cAAc;gBACV,sBAAsB;oBAClB,OAAO;wBACH,OAAO,CAAC,OAAO,EAAEF,MAAM,SAAS,CAAC,QAAQ,CAAC;wBAC1C,MAAM;oBACV;gBACJ;YACJ;QACJ;QAEA,IAAII;QACJ,IAAI;YACAA,WAAW,MAAMZ,KAAK,aAAa,CAAC,MAAM,CAAC;gBAAEO;gBAAOI;YAAK;QAC7D,EAAE,OAAOE,OAAO;YACZ,IAAIC,4BAA4BD,QAC5B,OAAO,EAAE;YAEb,MAAM,IAAIE,cAAYF,MAAM,OAAO,EAAEA,MAAM,IAAI,IAAI,oBAAoB;gBACnEA;gBACAN;gBACAN;gBACAU;YACJ;QACJ;QAEA,MAAMK,eAAeJ,SAAS,IAAI,CAAC,YAAY,IAAI,CAAC;QACpD,MAAMK,MAAMD,YAAY,CAAC,uBAAuB;QAChD,MAAME,UAAUD,OAAO,aAAaA,OAAOE,MAAM,OAAO,CAACF,IAAI,OAAO,IAAIA,IAAI,OAAO,GAAG,EAAE;QACxF,OAAOC,QAAQ,GAAG,CAAC,CAACE,SAAgD;gBAChE,OAAOA,OAAO,GAAG;gBACjB,OAAOA,OAAO,SAAS;YAC3B;IACJ"}
|
|
@@ -2,11 +2,12 @@ import _webiny_error from "@webiny/error";
|
|
|
2
2
|
import { createLimit, decodeCursor, encodeCursor, getTotalCount } from "@webiny/api-opensearch";
|
|
3
3
|
import { shouldIgnoreEsResponseError } from "@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js";
|
|
4
4
|
import { extractEntriesFromIndex } from "@webiny/api-headless-cms-utils-os/helpers/entryIndexHelpers.js";
|
|
5
|
-
import {
|
|
5
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
6
6
|
const createListOperation = (deps)=>async (initialModel, listParams)=>{
|
|
7
7
|
const model = deps.getStorageOperationsModel(initialModel);
|
|
8
8
|
const limit = createLimit(listParams.limit);
|
|
9
|
-
const
|
|
9
|
+
const configurations = createConfigurations(deps.indexProvider);
|
|
10
|
+
const { index } = await configurations.es({
|
|
10
11
|
model
|
|
11
12
|
});
|
|
12
13
|
const body = deps.bodyBuilder.build({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/search/list.js","sources":["../../../../src/operations/entry/search/list.ts"],"sourcesContent":["import type {\n CmsEntryValues,\n CmsModel,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsListResponse,\n CmsEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {\n createLimit,\n decodeCursor,\n encodeCursor,\n getTotalCount,\n type OpenSearchSearchResponse\n} from \"@webiny/api-opensearch\";\nimport { shouldIgnoreEsResponseError } from \"@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js\";\nimport { extractEntriesFromIndex } from \"@webiny/api-headless-cms-utils-os/helpers/entryIndexHelpers.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"operations/entry/search/list.js","sources":["../../../../src/operations/entry/search/list.ts"],"sourcesContent":["import type {\n CmsEntryValues,\n CmsModel,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsListResponse,\n CmsEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {\n createLimit,\n decodeCursor,\n encodeCursor,\n getTotalCount,\n type OpenSearchSearchResponse\n} from \"@webiny/api-opensearch\";\nimport { shouldIgnoreEsResponseError } from \"@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js\";\nimport { extractEntriesFromIndex } from \"@webiny/api-headless-cms-utils-os/helpers/entryIndexHelpers.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport type { CmsIndexEntry } from \"@webiny/api-headless-cms-utils-os/types.js\";\nimport type { SearchOperationDeps } from \"./types.js\";\n\nexport const createListOperation = (deps: SearchOperationDeps) => {\n return async <T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n listParams: CmsEntryStorageOperationsListParams\n ): Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>> => {\n const model = deps.getStorageOperationsModel<T>(initialModel);\n const limit = createLimit(listParams.limit);\n\n const configurations = createConfigurations(deps.indexProvider);\n const { index } = await configurations.es({ model });\n\n const body = deps.bodyBuilder.build({\n model,\n params: {\n ...listParams,\n limit,\n after: decodeCursor(listParams.after)\n }\n });\n\n let response: OpenSearchSearchResponse;\n try {\n response = await deps.elasticsearch.search({ index, body });\n } catch (error) {\n if (shouldIgnoreEsResponseError(error)) {\n return { hasMoreItems: false, totalCount: 0, cursor: null, items: [] };\n }\n throw new WebinyError(error.message, error.code || \"OPENSEARCH_ERROR\", {\n error,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response.body.hits;\n\n const items = extractEntriesFromIndex<T>({\n fieldRegistry: deps.fieldRegistry,\n fieldIndexRegistry: deps.fieldIndexRegistry,\n model,\n entries: hits.map(item => item._source as CmsIndexEntry<T>)\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n items.pop();\n }\n\n // @ts-expect-error - `sort` is present on the hit, but narrowed away by `_source: false` typing.\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n\n return {\n hasMoreItems,\n totalCount: getTotalCount(total),\n cursor,\n items\n };\n };\n};\n"],"names":["createListOperation","deps","initialModel","listParams","model","limit","createLimit","configurations","createConfigurations","index","body","decodeCursor","response","error","shouldIgnoreEsResponseError","WebinyError","hits","total","items","extractEntriesFromIndex","item","hasMoreItems","cursor","encodeCursor","getTotalCount"],"mappings":";;;;;AAqBO,MAAMA,sBAAsB,CAACC,OACzB,OACHC,cACAC;QAEA,MAAMC,QAAQH,KAAK,yBAAyB,CAAIC;QAChD,MAAMG,QAAQC,YAAYH,WAAW,KAAK;QAE1C,MAAMI,iBAAiBC,qBAAqBP,KAAK,aAAa;QAC9D,MAAM,EAAEQ,KAAK,EAAE,GAAG,MAAMF,eAAe,EAAE,CAAC;YAAEH;QAAM;QAElD,MAAMM,OAAOT,KAAK,WAAW,CAAC,KAAK,CAAC;YAChCG;YACA,QAAQ;gBACJ,GAAGD,UAAU;gBACbE;gBACA,OAAOM,aAAaR,WAAW,KAAK;YACxC;QACJ;QAEA,IAAIS;QACJ,IAAI;YACAA,WAAW,MAAMX,KAAK,aAAa,CAAC,MAAM,CAAC;gBAAEQ;gBAAOC;YAAK;QAC7D,EAAE,OAAOG,OAAO;YACZ,IAAIC,4BAA4BD,QAC5B,OAAO;gBAAE,cAAc;gBAAO,YAAY;gBAAG,QAAQ;gBAAM,OAAO,EAAE;YAAC;YAEzE,MAAM,IAAIE,cAAYF,MAAM,OAAO,EAAEA,MAAM,IAAI,IAAI,oBAAoB;gBACnEA;gBACAJ;gBACAC;gBACAN;YACJ;QACJ;QAEA,MAAM,EAAEY,IAAI,EAAEC,KAAK,EAAE,GAAGL,SAAS,IAAI,CAAC,IAAI;QAE1C,MAAMM,QAAQC,wBAA2B;YACrC,eAAelB,KAAK,aAAa;YACjC,oBAAoBA,KAAK,kBAAkB;YAC3CG;YACA,SAASY,KAAK,GAAG,CAACI,CAAAA,OAAQA,KAAK,OAAO;QAC1C;QAEA,MAAMC,eAAeH,MAAM,MAAM,GAAGb;QACpC,IAAIgB,cACAH,MAAM,GAAG;QAIb,MAAMI,SAASJ,MAAM,MAAM,GAAG,IAAIK,aAAaP,IAAI,CAACE,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,KAAK,OAAO;QAEtF,OAAO;YACHG;YACA,YAAYG,cAAcP;YAC1BK;YACAJ;QACJ;IACJ"}
|
|
@@ -2,6 +2,7 @@ import type { CmsEntryValues, CmsModel, StorageOperationsCmsModel } from "@webin
|
|
|
2
2
|
import type { Client as OpenSearchClient } from "@webiny/api-opensearch";
|
|
3
3
|
import type { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
4
4
|
import type { CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
5
|
+
import type { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
|
|
5
6
|
export type GetStorageOperationsModel = <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel) => StorageOperationsCmsModel<T>;
|
|
6
7
|
export interface OpenSearchBodyBuilderBuildParams {
|
|
7
8
|
model: CmsModel;
|
|
@@ -16,4 +17,5 @@ export interface SearchOperationDeps {
|
|
|
16
17
|
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
17
18
|
fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
|
|
18
19
|
getStorageOperationsModel: GetStorageOperationsModel;
|
|
20
|
+
indexProvider: CmsModelOpenSearchIndexProvider.Interface;
|
|
19
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-pg-os",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -23,32 +23,32 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Webiny Ltd.",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webiny/api": "6.6.0-alpha.
|
|
27
|
-
"@webiny/api-core-sql": "6.6.0-alpha.
|
|
28
|
-
"@webiny/api-headless-cms": "6.6.0-alpha.
|
|
29
|
-
"@webiny/api-headless-cms-sql": "6.6.0-alpha.
|
|
30
|
-
"@webiny/api-headless-cms-storage": "6.6.0-alpha.
|
|
31
|
-
"@webiny/api-headless-cms-utils-os": "6.6.0-alpha.
|
|
32
|
-
"@webiny/api-opensearch": "6.6.0-alpha.
|
|
33
|
-
"@webiny/api-sync-to-opensearch": "6.6.0-alpha.
|
|
34
|
-
"@webiny/db-utils": "6.6.0-alpha.
|
|
35
|
-
"@webiny/error": "6.6.0-alpha.
|
|
36
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
37
|
-
"@webiny/handler": "6.6.0-alpha.
|
|
38
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
39
|
-
"@webiny/utils": "6.6.0-alpha.
|
|
26
|
+
"@webiny/api": "6.6.0-alpha.1",
|
|
27
|
+
"@webiny/api-core-sql": "6.6.0-alpha.1",
|
|
28
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.1",
|
|
29
|
+
"@webiny/api-headless-cms-sql": "6.6.0-alpha.1",
|
|
30
|
+
"@webiny/api-headless-cms-storage": "6.6.0-alpha.1",
|
|
31
|
+
"@webiny/api-headless-cms-utils-os": "6.6.0-alpha.1",
|
|
32
|
+
"@webiny/api-opensearch": "6.6.0-alpha.1",
|
|
33
|
+
"@webiny/api-sync-to-opensearch": "6.6.0-alpha.1",
|
|
34
|
+
"@webiny/db-utils": "6.6.0-alpha.1",
|
|
35
|
+
"@webiny/error": "6.6.0-alpha.1",
|
|
36
|
+
"@webiny/feature": "6.6.0-alpha.1",
|
|
37
|
+
"@webiny/handler": "6.6.0-alpha.1",
|
|
38
|
+
"@webiny/plugins": "6.6.0-alpha.1",
|
|
39
|
+
"@webiny/utils": "6.6.0-alpha.1",
|
|
40
40
|
"knex": "3.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@electric-sql/pglite": "0.5.
|
|
44
|
-
"@electric-sql/pglite-socket": "0.2.
|
|
45
|
-
"@webiny/api-
|
|
46
|
-
"@webiny/
|
|
47
|
-
"@webiny/
|
|
48
|
-
"@webiny/
|
|
49
|
-
"@webiny/stdlib": "0.0.
|
|
43
|
+
"@electric-sql/pglite": "0.5.5",
|
|
44
|
+
"@electric-sql/pglite-socket": "0.2.8",
|
|
45
|
+
"@webiny/api-core": "6.6.0-alpha.1",
|
|
46
|
+
"@webiny/api-sync-pg-to-opensearch": "6.6.0-alpha.1",
|
|
47
|
+
"@webiny/build-tools": "6.6.0-alpha.1",
|
|
48
|
+
"@webiny/di": "1.1.0",
|
|
49
|
+
"@webiny/stdlib": "0.0.17",
|
|
50
50
|
"typescript": "7.0.2",
|
|
51
|
-
"vitest": "4.1.
|
|
51
|
+
"vitest": "4.1.11"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|