@webiny/api-headless-cms-pg-os 0.0.0-unstable.5387e5f7c8 → 0.0.0-unstable.a85ef555b2

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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Claims the `cms.` debug namespace prefix.
3
+ *
4
+ * The module specifier has to be exactly this one: augmenting a relative path would silently do
5
+ * nothing.
6
+ */
7
+ declare module "@webiny/api-core/features/debugger/abstractions.js" {
8
+ interface DebugNamespaces {
9
+ cms: `cms.${string}`;
10
+ }
11
+ }
12
+ export {};
File without changes
@@ -4,11 +4,12 @@ import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry } f
4
4
  import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
5
5
  import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
6
6
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { Debugger } from "@webiny/api-core/features/debugger/index.js";
7
8
  declare class EntrySearchOperationsImpl implements IEntrySearchOperations {
8
9
  readonly list: IEntrySearchOperations["list"];
9
10
  readonly get: IEntrySearchOperations["get"];
10
11
  readonly getUniqueFieldValues: IEntrySearchOperations["getUniqueFieldValues"];
11
- constructor(openSearchClient: OpenSearchClient.Interface, bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface);
12
+ constructor(openSearchClient: OpenSearchClient.Interface, bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, debuggerService: Debugger.Interface);
12
13
  }
13
14
  export declare const EntrySearchOperations: typeof EntrySearchOperationsImpl & {
14
15
  __abstraction: import("@webiny/di").Abstraction<IEntrySearchOperations>;
@@ -4,18 +4,20 @@ import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry } f
4
4
  import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
5
5
  import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
6
6
  import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { Debugger } from "@webiny/api-core/features/debugger/index.js";
7
8
  import { createListOperation } from "./search/list.js";
8
9
  import { createGetOperation } from "./search/get.js";
9
10
  import { createGetUniqueFieldValuesOperation } from "./search/getUniqueFieldValues.js";
10
11
  class EntrySearchOperationsImpl {
11
- constructor(openSearchClient, bodyBuilder, fieldRegistry, fieldIndexRegistry, storageModelProvider, indexProvider){
12
+ constructor(openSearchClient, bodyBuilder, fieldRegistry, fieldIndexRegistry, storageModelProvider, indexProvider, debuggerService){
12
13
  const deps = {
13
14
  elasticsearch: openSearchClient.use(),
14
15
  bodyBuilder,
15
16
  fieldRegistry,
16
17
  fieldIndexRegistry,
17
18
  getStorageOperationsModel: (model)=>storageModelProvider.getModel(model),
18
- indexProvider
19
+ indexProvider,
20
+ debuggerService
19
21
  };
20
22
  this.list = createListOperation(deps);
21
23
  this.get = createGetOperation(deps);
@@ -30,7 +32,8 @@ const EntrySearchOperations_EntrySearchOperations = EntrySearchOperations.create
30
32
  CmsModelFieldToGraphQLRegistry,
31
33
  CmsEntryOpenSearchFieldIndexRegistry,
32
34
  CmsStorageModelProvider,
33
- CmsModelOpenSearchIndexProvider
35
+ CmsModelOpenSearchIndexProvider,
36
+ Debugger
34
37
  ]
35
38
  });
36
39
  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 { 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
+ {"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 { Debugger } from \"@webiny/api-core/features/debugger/index.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 debuggerService: Debugger.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 debuggerService\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 Debugger\n ]\n});\n"],"names":["EntrySearchOperationsImpl","openSearchClient","bodyBuilder","fieldRegistry","fieldIndexRegistry","storageModelProvider","indexProvider","debuggerService","deps","model","createListOperation","createGetOperation","createGetUniqueFieldValuesOperation","EntrySearchOperations","Abstraction","OpenSearchClient","CmsEntryOpenSearchBodyBuilder","CmsModelFieldToGraphQLRegistry","CmsEntryOpenSearchFieldIndexRegistry","CmsStorageModelProvider","CmsModelOpenSearchIndexProvider","Debugger"],"mappings":";;;;;;;;;;AAgBA,MAAMA;IAKF,YACIC,gBAA4C,EAC5CC,WAAoD,EACpDC,aAAuD,EACvDC,kBAAkE,EAClEC,oBAAuD,EACvDC,aAAwD,EACxDC,eAAmC,CACrC;QACE,MAAMC,OAA4B;YAC9B,eAAeP,iBAAiB,GAAG;YACnCC;YACAC;YACAC;YACA,2BAA2BK,CAAAA,QAASJ,qBAAqB,QAAQ,CAACI;YAClEH;YACAC;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,gBAAgBd;IAChB,cAAc;QACVe;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -1,3 +1,4 @@
1
1
  import type { CmsEntryValues, CmsModel, CmsEntryStorageOperationsListParams, CmsEntryStorageOperationsListResponse, CmsEntry } from "@webiny/api-headless-cms/types/index.js";
2
2
  import type { SearchOperationDeps } from "./types.js";
3
+ import "~/debuggerNamespaces.js";
3
4
  export declare const createListOperation: (deps: SearchOperationDeps) => <T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, listParams: CmsEntryStorageOperationsListParams) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;
@@ -3,6 +3,7 @@ import { createLimit, decodeCursor, encodeCursor, getTotalCount } from "@webiny/
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
5
  import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
6
+ import "../../../debuggerNamespaces.js";
6
7
  const createListOperation = (deps)=>async (initialModel, listParams)=>{
7
8
  const model = deps.getStorageOperationsModel(initialModel);
8
9
  const limit = createLimit(listParams.limit);
@@ -19,12 +20,26 @@ const createListOperation = (deps)=>async (initialModel, listParams)=>{
19
20
  }
20
21
  });
21
22
  let response;
23
+ const startedAt = Date.now();
22
24
  try {
23
25
  response = await deps.elasticsearch.search({
24
26
  index,
25
27
  body
26
28
  });
29
+ deps.debuggerService.log("cms.os.list", ()=>({
30
+ index,
31
+ query: body,
32
+ body: response.body,
33
+ statusCode: response.statusCode,
34
+ tookMs: Date.now() - startedAt
35
+ }));
27
36
  } catch (error) {
37
+ deps.debuggerService.log("cms.os.list", ()=>({
38
+ index,
39
+ query: body,
40
+ error,
41
+ tookMs: Date.now() - startedAt
42
+ }));
28
43
  if (shouldIgnoreEsResponseError(error)) return {
29
44
  hasMoreItems: false,
30
45
  totalCount: 0,
@@ -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 { 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"}
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\";\nimport \"~/debuggerNamespaces.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 const startedAt = Date.now();\n try {\n response = await deps.elasticsearch.search({ index, body });\n\n deps.debuggerService.log(\"cms.os.list\", () => ({\n index,\n query: body,\n /**\n * Only the response body and status. The full client response also carries\n * `meta.connection.url` (the cluster endpoint) plus request headers.\n */\n body: response.body,\n statusCode: response.statusCode,\n tookMs: Date.now() - startedAt\n }));\n } catch (error) {\n /**\n * Logged before the `index_not_found` check below, which swallows the error and returns\n * an empty result. That silent exit is exactly what is hard to see from the outside.\n */\n deps.debuggerService.log(\"cms.os.list\", () => ({\n index,\n query: body,\n error,\n tookMs: Date.now() - startedAt\n }));\n\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","startedAt","Date","error","shouldIgnoreEsResponseError","WebinyError","hits","total","items","extractEntriesFromIndex","item","hasMoreItems","cursor","encodeCursor","getTotalCount"],"mappings":";;;;;;AAsBO,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,MAAMC,YAAYC,KAAK,GAAG;QAC1B,IAAI;YACAF,WAAW,MAAMX,KAAK,aAAa,CAAC,MAAM,CAAC;gBAAEQ;gBAAOC;YAAK;YAEzDT,KAAK,eAAe,CAAC,GAAG,CAAC,eAAe,IAAO;oBAC3CQ;oBACA,OAAOC;oBAKP,MAAME,SAAS,IAAI;oBACnB,YAAYA,SAAS,UAAU;oBAC/B,QAAQE,KAAK,GAAG,KAAKD;gBACzB;QACJ,EAAE,OAAOE,OAAO;YAKZd,KAAK,eAAe,CAAC,GAAG,CAAC,eAAe,IAAO;oBAC3CQ;oBACA,OAAOC;oBACPK;oBACA,QAAQD,KAAK,GAAG,KAAKD;gBACzB;YAEA,IAAIG,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;gBACAN;gBACAC;gBACAN;YACJ;QACJ;QAEA,MAAM,EAAEc,IAAI,EAAEC,KAAK,EAAE,GAAGP,SAAS,IAAI,CAAC,IAAI;QAE1C,MAAMQ,QAAQC,wBAA2B;YACrC,eAAepB,KAAK,aAAa;YACjC,oBAAoBA,KAAK,kBAAkB;YAC3CG;YACA,SAASc,KAAK,GAAG,CAACI,CAAAA,OAAQA,KAAK,OAAO;QAC1C;QAEA,MAAMC,eAAeH,MAAM,MAAM,GAAGf;QACpC,IAAIkB,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"}
@@ -3,6 +3,7 @@ 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
5
  import type { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
6
+ import type { Debugger } from "@webiny/api-core/features/debugger/index.js";
6
7
  export type GetStorageOperationsModel = <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel) => StorageOperationsCmsModel<T>;
7
8
  export interface OpenSearchBodyBuilderBuildParams {
8
9
  model: CmsModel;
@@ -18,4 +19,5 @@ export interface SearchOperationDeps {
18
19
  fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
19
20
  getStorageOperationsModel: GetStorageOperationsModel;
20
21
  indexProvider: CmsModelOpenSearchIndexProvider.Interface;
22
+ debuggerService: Debugger.Interface;
21
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-pg-os",
3
- "version": "0.0.0-unstable.5387e5f7c8",
3
+ "version": "0.0.0-unstable.a85ef555b2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -23,28 +23,28 @@
23
23
  "license": "MIT",
24
24
  "author": "Webiny Ltd.",
25
25
  "dependencies": {
26
- "@webiny/api": "0.0.0-unstable.5387e5f7c8",
27
- "@webiny/api-core-sql": "0.0.0-unstable.5387e5f7c8",
28
- "@webiny/api-headless-cms": "0.0.0-unstable.5387e5f7c8",
29
- "@webiny/api-headless-cms-sql": "0.0.0-unstable.5387e5f7c8",
30
- "@webiny/api-headless-cms-storage": "0.0.0-unstable.5387e5f7c8",
31
- "@webiny/api-headless-cms-utils-os": "0.0.0-unstable.5387e5f7c8",
32
- "@webiny/api-opensearch": "0.0.0-unstable.5387e5f7c8",
33
- "@webiny/api-sync-to-opensearch": "0.0.0-unstable.5387e5f7c8",
34
- "@webiny/db-utils": "0.0.0-unstable.5387e5f7c8",
35
- "@webiny/error": "0.0.0-unstable.5387e5f7c8",
36
- "@webiny/feature": "0.0.0-unstable.5387e5f7c8",
37
- "@webiny/handler": "0.0.0-unstable.5387e5f7c8",
38
- "@webiny/plugins": "0.0.0-unstable.5387e5f7c8",
39
- "@webiny/utils": "0.0.0-unstable.5387e5f7c8",
26
+ "@webiny/api": "0.0.0-unstable.a85ef555b2",
27
+ "@webiny/api-core": "0.0.0-unstable.a85ef555b2",
28
+ "@webiny/api-core-sql": "0.0.0-unstable.a85ef555b2",
29
+ "@webiny/api-headless-cms": "0.0.0-unstable.a85ef555b2",
30
+ "@webiny/api-headless-cms-sql": "0.0.0-unstable.a85ef555b2",
31
+ "@webiny/api-headless-cms-storage": "0.0.0-unstable.a85ef555b2",
32
+ "@webiny/api-headless-cms-utils-os": "0.0.0-unstable.a85ef555b2",
33
+ "@webiny/api-opensearch": "0.0.0-unstable.a85ef555b2",
34
+ "@webiny/api-sync-to-opensearch": "0.0.0-unstable.a85ef555b2",
35
+ "@webiny/db-utils": "0.0.0-unstable.a85ef555b2",
36
+ "@webiny/error": "0.0.0-unstable.a85ef555b2",
37
+ "@webiny/feature": "0.0.0-unstable.a85ef555b2",
38
+ "@webiny/handler": "0.0.0-unstable.a85ef555b2",
39
+ "@webiny/plugins": "0.0.0-unstable.a85ef555b2",
40
+ "@webiny/utils": "0.0.0-unstable.a85ef555b2",
40
41
  "knex": "3.3.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@electric-sql/pglite": "0.5.5",
44
45
  "@electric-sql/pglite-socket": "0.2.8",
45
- "@webiny/api-core": "0.0.0-unstable.5387e5f7c8",
46
- "@webiny/api-sync-pg-to-opensearch": "0.0.0-unstable.5387e5f7c8",
47
- "@webiny/build-tools": "0.0.0-unstable.5387e5f7c8",
46
+ "@webiny/api-sync-pg-to-opensearch": "0.0.0-unstable.a85ef555b2",
47
+ "@webiny/build-tools": "0.0.0-unstable.a85ef555b2",
48
48
  "@webiny/di": "2.0.0",
49
49
  "@webiny/stdlib": "0.0.21",
50
50
  "typescript": "7.0.2",