@webiny/api-opensearch 6.2.0 → 6.3.0-beta.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.
@@ -1 +1,4 @@
1
- export declare const OpenSearchClientFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const OpenSearchClientFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1 +1,4 @@
1
- export declare const OpenSearchClientFactoryFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const OpenSearchClientFactoryFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1,2 +1,5 @@
1
1
  import { OpenSearchContext as OpenSearchContextType } from "../../types.js";
2
- export declare const OpenSearchContextFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<OpenSearchContextType>;
2
+ export declare const OpenSearchContextFeature: {
3
+ name: string;
4
+ register(container: import("@webiny/di").Container, context: OpenSearchContextType): void;
5
+ };
@@ -1,10 +1,12 @@
1
- import type { HealthRecord } from "@opensearch-project/opensearch/api/_types/cat.health";
2
- import type { NodesRecord } from "@opensearch-project/opensearch/api/_types/cat.nodes";
1
+ import type { Cat_Health_ResponseBody, Cat_Nodes_ResponseBody } from "@opensearch-project/opensearch/api/index.js";
3
2
  export declare enum OpenSearchCatClusterHealthStatus {
4
3
  Green = "green",
5
4
  Yellow = "yellow",
6
5
  Red = "red"
7
6
  }
7
+ type HealthRecord = Cat_Health_ResponseBody[number];
8
+ type NodesRecord = Cat_Nodes_ResponseBody[number];
8
9
  export type IOpenSearchCatHealthResponse = HealthRecord;
9
10
  export type IOpenSearchCatNodeResponse = NodesRecord;
10
11
  export type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];
12
+ export {};
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchCatClusterHealthStatus"],"sources":["types.ts"],"sourcesContent":["import type { HealthRecord } from \"@opensearch-project/opensearch/api/_types/cat.health\";\nimport type { NodesRecord } from \"@opensearch-project/opensearch/api/_types/cat.nodes\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"mappings":"AAGA,WAAYA,gCAAgC,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["OpenSearchCatClusterHealthStatus"],"sources":["types.ts"],"sourcesContent":["import type {\n Cat_Health_ResponseBody,\n Cat_Nodes_ResponseBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\ntype HealthRecord = Cat_Health_ResponseBody[number];\n\ntype NodesRecord = Cat_Nodes_ResponseBody[number];\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"mappings":"AAKA,WAAYA,gCAAgC,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-opensearch",
3
- "version": "6.2.0",
3
+ "version": "6.3.0-beta.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,23 +14,23 @@
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
16
  "@opensearch-project/opensearch": "3.5.1",
17
- "@webiny/api": "6.2.0",
18
- "@webiny/aws-sdk": "6.2.0",
19
- "@webiny/db-dynamodb": "6.2.0",
20
- "@webiny/error": "6.2.0",
21
- "@webiny/feature": "6.2.0",
22
- "@webiny/plugins": "6.2.0"
17
+ "@webiny/api": "6.3.0-beta.1",
18
+ "@webiny/aws-sdk": "6.3.0-beta.1",
19
+ "@webiny/db-dynamodb": "6.3.0-beta.1",
20
+ "@webiny/error": "6.3.0-beta.1",
21
+ "@webiny/feature": "6.3.0-beta.1",
22
+ "@webiny/plugins": "6.3.0-beta.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@webiny/build-tools": "6.2.0",
26
- "@webiny/project-utils": "6.2.0",
25
+ "@webiny/build-tools": "6.3.0-beta.1",
26
+ "@webiny/project-utils": "6.3.0-beta.1",
27
27
  "rimraf": "6.1.3",
28
- "typescript": "5.9.3",
28
+ "typescript": "6.0.3",
29
29
  "vitest": "4.1.4"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public",
33
33
  "directory": "dist"
34
34
  },
35
- "gitHead": "3d3148358b6febbc857371930871743bec3b3939"
35
+ "gitHead": "664b273a9f0a971f9ca7e6ffe920db77fefdced1"
36
36
  }
@@ -35,6 +35,7 @@ export class OpenSearchFieldPlugin extends Plugin {
35
35
  }
36
36
  return {
37
37
  ...options,
38
+ // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.
38
39
  unmapped_type: this.unmappedType
39
40
  };
40
41
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","OpenSearchFieldPlugin","ALL","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","toSearchValue","value"],"sources":["OpenSearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { FieldType as MappingFieldType } from \"@opensearch-project/opensearch/api/_types/_common.mapping\";\nimport type { FieldSortOptions, SortOrder } from \"~/types.js\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface OpenSearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class OpenSearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: OpenSearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n unmapped_type: this.unmappedType as MappingFieldType\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === OpenSearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAMxC,MAAMC,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAIF,uBAAuB,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC/C,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkDD,OAAO,MAAME,qBAAqB,SAASL,MAAM,CAAC;EAC9C,OAAgCG,IAAI,GAAW,4BAA4B;EAC3E,OAAuBG,GAAG,GAAW,GAAG;EASxCC,WAAWA,CAACC,MAAmC,EAAE;IAC7C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK;IACvC,IAAI,CAACE,OAAO,GAAGH,MAAM,CAACG,OAAO,KAAKC,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACG,OAAO;IACnE,IAAI,CAACE,YAAY,GAAGL,MAAM,CAACK,YAAY;IACvC,IAAIX,sBAAsB,CAACM,MAAM,CAACK,YAAY,CAAC,KAAK,KAAK,EAAE;MACvD,IAAI,CAACF,OAAO,GAAG,KAAK;IACxB;IACA,IAAI,CAACG,QAAQ,GAAGN,MAAM,CAACM,QAAQ,KAAKF,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACM,QAAQ;IACtE,IAAI,CAACC,UAAU,GAAGP,MAAM,CAACO,UAAU,KAAKH,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACO,UAAU;EAChF;EACA;AACJ;AACA;EACWC,cAAcA,CAACC,KAAgB,EAAoB;IACtD,MAAMC,OAAO,GAAG;MACZD;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,CAACJ,YAAY,EAAE;MACpB,OAAOK,OAAO;IAClB;IACA,OAAO;MACH,GAAGA,OAAO;MACVC,aAAa,EAAE,IAAI,CAACN;IACxB,CAAC;EACL;EACA;AACJ;AACA;AACA;EACWO,OAAOA,CAACX,KAAa,EAAU;IAClC,OAAO,GAAG,IAAI,CAACY,WAAW,CAACZ,KAAK,CAAC,GAAG,IAAI,CAACE,OAAO,GAAG,UAAU,GAAG,EAAE,EAAE;EACxE;EACA;AACJ;AACA;AACA;AACA;EACWU,WAAWA,CAACZ,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKL,qBAAqB,CAACC,GAAG,EAAE;MACzC,OAAOG,KAAK;IAChB;IACA,OAAO,IAAI,CAACC,IAAI;EACpB;EACA;AACJ;AACA;AACA;EACWY,aAAaA,CAACd,MAA2B,EAAO;IACnD,OAAOA,MAAM,CAACe,KAAK;EACvB;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","OpenSearchFieldPlugin","ALL","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","toSearchValue","value"],"sources":["OpenSearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { FieldSortOptions, SortOrder } from \"~/types.js\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface OpenSearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class OpenSearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: OpenSearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: this.unmappedType as any\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === OpenSearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAKxC,MAAMC,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAIF,uBAAuB,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC/C,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkDD,OAAO,MAAME,qBAAqB,SAASL,MAAM,CAAC;EAC9C,OAAgCG,IAAI,GAAW,4BAA4B;EAC3E,OAAuBG,GAAG,GAAW,GAAG;EASxCC,WAAWA,CAACC,MAAmC,EAAE;IAC7C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK;IACvC,IAAI,CAACE,OAAO,GAAGH,MAAM,CAACG,OAAO,KAAKC,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACG,OAAO;IACnE,IAAI,CAACE,YAAY,GAAGL,MAAM,CAACK,YAAY;IACvC,IAAIX,sBAAsB,CAACM,MAAM,CAACK,YAAY,CAAC,KAAK,KAAK,EAAE;MACvD,IAAI,CAACF,OAAO,GAAG,KAAK;IACxB;IACA,IAAI,CAACG,QAAQ,GAAGN,MAAM,CAACM,QAAQ,KAAKF,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACM,QAAQ;IACtE,IAAI,CAACC,UAAU,GAAGP,MAAM,CAACO,UAAU,KAAKH,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACO,UAAU;EAChF;EACA;AACJ;AACA;EACWC,cAAcA,CAACC,KAAgB,EAAoB;IACtD,MAAMC,OAAO,GAAG;MACZD;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,CAACJ,YAAY,EAAE;MACpB,OAAOK,OAAO;IAClB;IACA,OAAO;MACH,GAAGA,OAAO;MACV;MACAC,aAAa,EAAE,IAAI,CAACN;IACxB,CAAC;EACL;EACA;AACJ;AACA;AACA;EACWO,OAAOA,CAACX,KAAa,EAAU;IAClC,OAAO,GAAG,IAAI,CAACY,WAAW,CAACZ,KAAK,CAAC,GAAG,IAAI,CAACE,OAAO,GAAG,UAAU,GAAG,EAAE,EAAE;EACxE;EACA;AACJ;AACA;AACA;AACA;EACWU,WAAWA,CAACZ,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKL,qBAAqB,CAACC,GAAG,EAAE;MACzC,OAAOG,KAAK;IAChB;IACA,OAAO,IAAI,CAACC,IAAI;EACpB;EACA;AACJ;AACA;AACA;EACWY,aAAaA,CAACd,MAA2B,EAAO;IACnD,OAAOA,MAAM,CAACe,KAAK;EACvB;AACJ","ignoreList":[]}
package/sort.js CHANGED
@@ -19,6 +19,7 @@ export const createSort = params => {
19
19
  return {
20
20
  [field || "id.keyword"]: {
21
21
  order: order || "desc",
22
+ // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.
22
23
  unmapped_type: unmappedType || undefined
23
24
  }
24
25
  };
package/sort.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","OpenSearchFieldPlugin","sortRegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","result","reduce","acc","value","match","initialOrder","toLowerCase","plugin","ALL","path","getPath","getSortOptions"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport type { FieldType as MappingFieldType } from \"@opensearch-project/opensearch/api/_types/_common.mapping\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/index.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, OpenSearchFieldPlugin>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n /**\n * We say that our system defaults is always id since all records we create have some kind of primary ID.\n */\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n unmapped_type: (unmappedType || undefined) as MappingFieldType | undefined\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce(\n (acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: OpenSearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\n );\n }\n /**\n * In case field plugin is the global one, change the * with actual field name.\n * Custom path methods will return their own values anyway so replacing * will not matter.\n */\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n },\n {} as Record<string, FieldSortOptions>\n );\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch to be able to sort consistently.\n */\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAGvC,SAASC,qBAAqB;AAE9B,MAAMC,UAAU,GAAG,6CAA6C;AAYhE,OAAO,MAAMC,UAAU,GAAIC,MAAwB,IAAe;EAC9D,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGH,MAAM;EAC/C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAGL,QAAQ,IAAI,CAAC,CAAC;IACrD;AACR;AACA;IACQ,OAAO;MACH,CAACG,KAAK,IAAI,YAAY,GAAG;QACrBC,KAAK,EAAEA,KAAK,IAAI,MAAM;QACtBE,aAAa,EAAGD,YAAY,IAAIE;MACpC;IACJ,CAAC;EACL;EACA;AACJ;AACA;EACI,MAAMC,MAAM,GAAGT,IAAI,CAACU,MAAM,CACtB,CAACC,GAAG,EAAEC,KAAK,KAAK;IACZ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,MAAM,IAAIjB,WAAW,CAAC,mCAAmC,CAAC;IAC9D;IACA,MAAMkB,KAAK,GAAGD,KAAK,CAACC,KAAK,CAAChB,UAAU,CAAC;IAErC,IAAI,CAACgB,KAAK,EAAE;MACR,MAAM,IAAIlB,WAAW,CAAC,mBAAmBiB,KAAK,IAAI,CAAC;IACvD;IAEA,MAAM,GAAGR,KAAK,EAAEU,YAAY,CAAC,GAAGD,KAAK;IACrC,MAAMR,KAAgB,GAAGS,YAAY,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK,GAAG,KAAK,GAAG,MAAM;IAE9E,MAAMC,MAA6B,GAC/Bd,YAAY,CAACE,KAAK,CAAC,IAAIF,YAAY,CAACN,qBAAqB,CAACqB,GAAG,CAAC;IAClE,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIrB,WAAW,CACjB,iCAAiCS,KAAK,GAAG,EACzC,mBAAmB,EACnB;QACIA;MACJ,CACJ,CAAC;IACL;IACA;AACZ;AACA;AACA;IACY,MAAMc,IAAI,GAAGF,MAAM,CAACG,OAAO,CAACf,KAAK,CAAC;IAElCO,GAAG,CAACO,IAAI,CAAC,GAAGF,MAAM,CAACI,cAAc,CAACf,KAAK,CAAC;IAExC,OAAOM,GAAG;EACd,CAAC,EACD,CAAC,CACL,CAAC;EACD;AACJ;AACA;EACI,IAAI,CAACF,MAAM,CAAC,YAAY,CAAC,IAAI,CAACA,MAAM,CAAC,IAAI,CAAC,EAAE;IACxCA,MAAM,CAAC,YAAY,CAAC,GAAG;MACnBJ,KAAK,EAAE;IACX,CAAC;EACL;EACA,OAAOI,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","OpenSearchFieldPlugin","sortRegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","result","reduce","acc","value","match","initialOrder","toLowerCase","plugin","ALL","path","getPath","getSortOptions"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/index.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, OpenSearchFieldPlugin>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n /**\n * We say that our system defaults is always id since all records we create have some kind of primary ID.\n */\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: (unmappedType || undefined) as any\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce(\n (acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: OpenSearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\n );\n }\n /**\n * In case field plugin is the global one, change the * with actual field name.\n * Custom path methods will return their own values anyway so replacing * will not matter.\n */\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n },\n {} as Record<string, FieldSortOptions>\n );\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch to be able to sort consistently.\n */\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,qBAAqB;AAE9B,MAAMC,UAAU,GAAG,6CAA6C;AAYhE,OAAO,MAAMC,UAAU,GAAIC,MAAwB,IAAe;EAC9D,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGH,MAAM;EAC/C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAGL,QAAQ,IAAI,CAAC,CAAC;IACrD;AACR;AACA;IACQ,OAAO;MACH,CAACG,KAAK,IAAI,YAAY,GAAG;QACrBC,KAAK,EAAEA,KAAK,IAAI,MAAM;QACtB;QACAE,aAAa,EAAGD,YAAY,IAAIE;MACpC;IACJ,CAAC;EACL;EACA;AACJ;AACA;EACI,MAAMC,MAAM,GAAGT,IAAI,CAACU,MAAM,CACtB,CAACC,GAAG,EAAEC,KAAK,KAAK;IACZ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,MAAM,IAAIjB,WAAW,CAAC,mCAAmC,CAAC;IAC9D;IACA,MAAMkB,KAAK,GAAGD,KAAK,CAACC,KAAK,CAAChB,UAAU,CAAC;IAErC,IAAI,CAACgB,KAAK,EAAE;MACR,MAAM,IAAIlB,WAAW,CAAC,mBAAmBiB,KAAK,IAAI,CAAC;IACvD;IAEA,MAAM,GAAGR,KAAK,EAAEU,YAAY,CAAC,GAAGD,KAAK;IACrC,MAAMR,KAAgB,GAAGS,YAAY,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK,GAAG,KAAK,GAAG,MAAM;IAE9E,MAAMC,MAA6B,GAC/Bd,YAAY,CAACE,KAAK,CAAC,IAAIF,YAAY,CAACN,qBAAqB,CAACqB,GAAG,CAAC;IAClE,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIrB,WAAW,CACjB,iCAAiCS,KAAK,GAAG,EACzC,mBAAmB,EACnB;QACIA;MACJ,CACJ,CAAC;IACL;IACA;AACZ;AACA;AACA;IACY,MAAMc,IAAI,GAAGF,MAAM,CAACG,OAAO,CAACf,KAAK,CAAC;IAElCO,GAAG,CAACO,IAAI,CAAC,GAAGF,MAAM,CAACI,cAAc,CAACf,KAAK,CAAC;IAExC,OAAOM,GAAG;EACd,CAAC,EACD,CAAC,CACL,CAAC;EACD;AACJ;AACA;EACI,IAAI,CAACF,MAAM,CAAC,YAAY,CAAC,IAAI,CAACA,MAAM,CAAC,IAAI,CAAC,EAAE;IACxCA,MAAM,CAAC,YAAY,CAAC,GAAG;MACnBJ,KAAK,EAAE;IACX,CAAC;EACL;EACA,OAAOI,MAAM;AACjB,CAAC","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import type { Client } from "@opensearch-project/opensearch";
2
- import type { QueryContainer as QueryDslQueryContainer, BoolQuery as QueryDslBoolQuery } from "@opensearch-project/opensearch/api/_types/_common.query_dsl";
3
- import type { FieldSort as SearchFieldSort, SortOrder as SearchSortOrder, Sort as SearchSort } from "@opensearch-project/opensearch/api/_types/_common";
4
- import type { Search_RequestBody as SearchRequestBody, Search_Response } from "@opensearch-project/opensearch/api/_core/search";
5
- import type { Indices_Create_RequestBody } from "@opensearch-project/opensearch/api/indices/create";
6
- import type { DynamicTemplate } from "@opensearch-project/opensearch/api/_types/_common.mapping";
2
+ import type { Search_RequestBody as SearchRequestBody, Search_Response, Indices_Create_RequestBody } from "@opensearch-project/opensearch/api/index.js";
7
3
  import type { Context } from "@webiny/api/types.js";
4
+ type QueryDslQueryContainer = NonNullable<SearchRequestBody["query"]>;
5
+ type QueryDslBoolQuery = NonNullable<QueryDslQueryContainer["bool"]>;
6
+ type SearchSort = NonNullable<SearchRequestBody["sort"]>;
7
+ type SearchSortOrder = "asc" | "desc";
8
+ type _ExtractRecordValue<T> = T extends Record<string, infer V> ? V : never;
9
+ type _SortMember = NonNullable<SearchRequestBody["sort"]> extends (infer U)[] | (infer U) ? U : never;
10
+ type SearchFieldSort = _ExtractRecordValue<Exclude<_SortMember, string>>;
11
+ type DynamicTemplate = NonNullable<NonNullable<Indices_Create_RequestBody["mappings"]>["dynamic_templates"]>[number][string];
8
12
  export type { ApiResponse } from "@opensearch-project/opensearch";
9
13
  export type { Client };
10
14
  /** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */
package/types.js CHANGED
@@ -1,3 +1,14 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Types inferred from the accessible API surface.
3
+ // The `_types/` directory in the opensearch package only ships `.d.ts` files
4
+ // (no `.js` runtime modules), so deep imports are unresolvable under
5
+ // `moduleResolution: "bundler"`. We infer what we can from the public
6
+ // barrel (`api/index.js`) and use `string` where structural extraction
7
+ // is not possible.
8
+ // ---------------------------------------------------------------------------
9
+
10
+ // Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.
11
+
1
12
  // ---------------------------------------------------------------------------
2
13
  // Local type aliases replacing elastic-ts
3
14
  // ---------------------------------------------------------------------------
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["getTotalCount","total","undefined","value"],"sources":["types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n QueryContainer as QueryDslQueryContainer,\n BoolQuery as QueryDslBoolQuery\n} from \"@opensearch-project/opensearch/api/_types/_common.query_dsl\";\nimport type {\n FieldSort as SearchFieldSort,\n SortOrder as SearchSortOrder,\n Sort as SearchSort\n} from \"@opensearch-project/opensearch/api/_types/_common\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response\n} from \"@opensearch-project/opensearch/api/_core/search\";\nimport type { Indices_Create_RequestBody } from \"@opensearch-project/opensearch/api/indices/create\";\nimport type { DynamicTemplate } from \"@opensearch-project/opensearch/api/_types/_common.mapping\";\nimport type { Context } from \"@webiny/api/types.js\";\n\nexport type { ApiResponse } from \"@opensearch-project/opensearch\";\n\nexport type { Client };\n\n// ---------------------------------------------------------------------------\n// Local type aliases replacing elastic-ts\n// ---------------------------------------------------------------------------\n\n/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */\nexport type PrimitiveValue = boolean | undefined | number | string;\n\n/** Replaces elastic-ts Query */\nexport type { QueryDslQueryContainer };\n\n/** Replaces elastic-ts BoolQueryConfig */\nexport type { QueryDslBoolQuery };\n\n/** Replaces elastic-ts FieldSortOptions */\nexport type FieldSortOptions = SearchFieldSort;\n\n/** Replaces elastic-ts SortOrder. Narrowed to \"asc\" | \"desc\" (excludes \"_doc\"). */\nexport type SortOrder = \"asc\" | \"desc\";\n\n/** Replaces elastic-ts Sort */\nexport type { SearchSort as Sort };\n\n/** Single sort entry as an object map. Replaces elastic-ts SortType. */\nexport type SortType = Record<string, FieldSortOptions>;\n\n/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */\nexport type SearchBody = Omit<SearchRequestBody, \"search_after\"> & {\n search_after?: PrimitiveValue[];\n};\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchContext extends Context {\n /**\n * @deprecated Use `context.opensearch` instead.\n */\n elasticsearch: Client;\n opensearch: Client;\n}\n\n// ---------------------------------------------------------------------------\n// Bool query with required arrays (our convention)\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {\n must: QueryDslQueryContainer[];\n filter: QueryDslQueryContainer[];\n should: QueryDslQueryContainer[];\n must_not: QueryDslQueryContainer[];\n}\n\n// ---------------------------------------------------------------------------\n// Operator plugin types\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\nexport interface OpenSearchQueryBuilderArgsPlugin {\n name: string;\n path: string;\n basePath: string;\n value: any;\n keyword: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Search response shapes (aligned with @opensearch-project/opensearch v3)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchSearchResponseHit = Search_Response[\"body\"][\"hits\"][\"hits\"][number];\n\nexport interface OpenSearchSearchResponseAggregationBucket {\n key: PrimitiveValue;\n doc_count: number;\n}\n\nexport type OpenSearchSearchResponseBodyHits = Search_Response[\"body\"][\"hits\"];\n\nexport type OpenSearchSearchResponseBody = Search_Response[\"body\"];\n\nexport type OpenSearchSearchResponse = Search_Response;\n\n/**\n * Extract the total count from an opensearch hits response.\n * Handles both `TotalHits` (object with `value`) and plain `number` formats.\n */\nexport const getTotalCount = (total: OpenSearchSearchResponseBodyHits[\"total\"]): number => {\n if (total === undefined || total === null) {\n return 0;\n }\n if (typeof total === \"number\") {\n return total;\n }\n return total.value;\n};\n\n// ---------------------------------------------------------------------------\n// Index request body shapes (re-exported from opensearch package)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchIndexRequestBodyMappingsDynamicTemplate = Record<string, DynamicTemplate>;\n\nexport type OpenSearchIndexRequestBody = Indices_Create_RequestBody;\n\n// Re-export SearchSortOrder for consumers that need it (including \"_doc\")\nexport type { SearchSortOrder };\n"],"mappings":"AAsBA;AACA;AACA;;AAEA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAKA;AACA;AACA;;AAUA;AACA;AACA;;AASA;AACA;AACA;;AAyBA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAIC,KAAgD,IAAa;EACvF,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;IACvC,OAAO,CAAC;EACZ;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EACA,OAAOA,KAAK,CAACE,KAAK;AACtB,CAAC;;AAED;AACA;AACA;;AAMA","ignoreList":[]}
1
+ {"version":3,"names":["getTotalCount","total","undefined","value"],"sources":["types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response,\n Indices_Create_RequestBody\n} from \"@opensearch-project/opensearch/api/index.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\n// ---------------------------------------------------------------------------\n// Types inferred from the accessible API surface.\n// The `_types/` directory in the opensearch package only ships `.d.ts` files\n// (no `.js` runtime modules), so deep imports are unresolvable under\n// `moduleResolution: \"bundler\"`. We infer what we can from the public\n// barrel (`api/index.js`) and use `string` where structural extraction\n// is not possible.\n// ---------------------------------------------------------------------------\n\ntype QueryDslQueryContainer = NonNullable<SearchRequestBody[\"query\"]>;\ntype QueryDslBoolQuery = NonNullable<QueryDslQueryContainer[\"bool\"]>;\ntype SearchSort = NonNullable<SearchRequestBody[\"sort\"]>;\ntype SearchSortOrder = \"asc\" | \"desc\";\n\n// Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.\ntype _ExtractRecordValue<T> = T extends Record<string, infer V> ? V : never;\ntype _SortMember =\n NonNullable<SearchRequestBody[\"sort\"]> extends (infer U)[] | (infer U) ? U : never;\ntype SearchFieldSort = _ExtractRecordValue<Exclude<_SortMember, string>>;\n\ntype DynamicTemplate = NonNullable<\n NonNullable<Indices_Create_RequestBody[\"mappings\"]>[\"dynamic_templates\"]\n>[number][string];\n\nexport type { ApiResponse } from \"@opensearch-project/opensearch\";\n\nexport type { Client };\n\n// ---------------------------------------------------------------------------\n// Local type aliases replacing elastic-ts\n// ---------------------------------------------------------------------------\n\n/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */\nexport type PrimitiveValue = boolean | undefined | number | string;\n\n/** Replaces elastic-ts Query */\nexport type { QueryDslQueryContainer };\n\n/** Replaces elastic-ts BoolQueryConfig */\nexport type { QueryDslBoolQuery };\n\n/** Replaces elastic-ts FieldSortOptions */\nexport type FieldSortOptions = SearchFieldSort;\n\n/** Replaces elastic-ts SortOrder. Narrowed to \"asc\" | \"desc\" (excludes \"_doc\"). */\nexport type SortOrder = \"asc\" | \"desc\";\n\n/** Replaces elastic-ts Sort */\nexport type { SearchSort as Sort };\n\n/** Single sort entry as an object map. Replaces elastic-ts SortType. */\nexport type SortType = Record<string, FieldSortOptions>;\n\n/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */\nexport type SearchBody = Omit<SearchRequestBody, \"search_after\"> & {\n search_after?: PrimitiveValue[];\n};\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchContext extends Context {\n /**\n * @deprecated Use `context.opensearch` instead.\n */\n elasticsearch: Client;\n opensearch: Client;\n}\n\n// ---------------------------------------------------------------------------\n// Bool query with required arrays (our convention)\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {\n must: QueryDslQueryContainer[];\n filter: QueryDslQueryContainer[];\n should: QueryDslQueryContainer[];\n must_not: QueryDslQueryContainer[];\n}\n\n// ---------------------------------------------------------------------------\n// Operator plugin types\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\nexport interface OpenSearchQueryBuilderArgsPlugin {\n name: string;\n path: string;\n basePath: string;\n value: any;\n keyword: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Search response shapes (aligned with @opensearch-project/opensearch v3)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchSearchResponseHit = Search_Response[\"body\"][\"hits\"][\"hits\"][number];\n\nexport interface OpenSearchSearchResponseAggregationBucket {\n key: PrimitiveValue;\n doc_count: number;\n}\n\nexport type OpenSearchSearchResponseBodyHits = Search_Response[\"body\"][\"hits\"];\n\nexport type OpenSearchSearchResponseBody = Search_Response[\"body\"];\n\nexport type OpenSearchSearchResponse = Search_Response;\n\n/**\n * Extract the total count from an opensearch hits response.\n * Handles both `TotalHits` (object with `value`) and plain `number` formats.\n */\nexport const getTotalCount = (total: OpenSearchSearchResponseBodyHits[\"total\"]): number => {\n if (total === undefined || total === null) {\n return 0;\n }\n if (typeof total === \"number\") {\n return total;\n }\n return total.value;\n};\n\n// ---------------------------------------------------------------------------\n// Index request body shapes (re-exported from opensearch package)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchIndexRequestBodyMappingsDynamicTemplate = Record<string, DynamicTemplate>;\n\nexport type OpenSearchIndexRequestBody = Indices_Create_RequestBody;\n\n// Re-export SearchSortOrder for consumers that need it (including \"_doc\")\nexport type { SearchSortOrder };\n"],"mappings":"AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAcA;AACA;AACA;;AAEA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAKA;AACA;AACA;;AAUA;AACA;AACA;;AASA;AACA;AACA;;AAyBA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAIC,KAAgD,IAAa;EACvF,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;IACvC,OAAO,CAAC;EACZ;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EACA,OAAOA,KAAK,CAACE,KAAK;AACtB,CAAC;;AAED;AACA;AACA;;AAMA","ignoreList":[]}