@webiny/api-opensearch 0.0.0-unstable.b6d7105cee → 0.0.0-unstable.eb81deee7e
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/client.js +1 -24
- package/client.js.map +1 -1
- package/features/OpenSearchField/{OpenSearchFieldImpl.d.ts → OpenSearchField.d.ts} +5 -4
- package/features/OpenSearchField/{OpenSearchFieldImpl.js → OpenSearchField.js} +6 -3
- package/features/OpenSearchField/OpenSearchField.js.map +1 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +2 -2
- package/features/OpenSearchField/OpenSearchFieldFactory.js +2 -2
- package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +7 -11
- package/db/entity.d.ts +0 -7
- package/db/entity.js +0 -18
- package/db/entity.js.map +0 -1
- package/db/index.d.ts +0 -3
- package/db/index.js +0 -3
- package/db/table.d.ts +0 -7
- package/db/table.js +0 -13
- package/db/table.js.map +0 -1
- package/db/types.d.ts +0 -6
- package/db/types.js +0 -0
- package/features/OpenSearchField/OpenSearchFieldImpl.js.map +0 -1
package/client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import crypto_0 from "crypto";
|
|
2
2
|
import error from "@webiny/error";
|
|
3
3
|
import { Client } from "@opensearch-project/opensearch";
|
|
4
|
-
import { AwsSigv4Signer } from "@opensearch-project/opensearch/aws";
|
|
5
4
|
const clients = new Map();
|
|
6
5
|
const createClientKey = (options)=>{
|
|
7
6
|
const key = JSON.stringify(options);
|
|
@@ -14,32 +13,10 @@ const createOpenSearchClient = (options)=>{
|
|
|
14
13
|
const existing = clients.get(key);
|
|
15
14
|
if (existing) return existing;
|
|
16
15
|
const { endpoint, node, ...rest } = options;
|
|
17
|
-
|
|
16
|
+
const clientOptions = {
|
|
18
17
|
node: endpoint || node,
|
|
19
18
|
...rest
|
|
20
19
|
};
|
|
21
|
-
if (!clientOptions.auth) {
|
|
22
|
-
const region = process.env.AWS_REGION;
|
|
23
|
-
if (!region) throw new error("Missing AWS_REGION environment variable.", "MISSING_AWS_REGION");
|
|
24
|
-
clientOptions = {
|
|
25
|
-
...clientOptions,
|
|
26
|
-
...AwsSigv4Signer({
|
|
27
|
-
region,
|
|
28
|
-
service: "es",
|
|
29
|
-
getCredentials: ()=>{
|
|
30
|
-
const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
|
31
|
-
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
32
|
-
const sessionToken = process.env.AWS_SESSION_TOKEN;
|
|
33
|
-
if (!accessKeyId || !secretAccessKey) throw new error("Missing AWS credentials (AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY).", "MISSING_AWS_CREDENTIALS");
|
|
34
|
-
return Promise.resolve({
|
|
35
|
-
accessKeyId,
|
|
36
|
-
secretAccessKey,
|
|
37
|
-
sessionToken
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
20
|
try {
|
|
44
21
|
const client = new Client(clientOptions);
|
|
45
22
|
clients.set(key, client);
|
package/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client } from \"@opensearch-project/opensearch\";\nimport type { ClientOptions } from \"@opensearch-project/opensearch\";\
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client } from \"@opensearch-project/opensearch\";\nimport type { ClientOptions } from \"@opensearch-project/opensearch\";\n\nexport interface OpenSearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nexport { Client };\nexport type { OpenSearchClientOptions as ClientOptions };\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: OpenSearchClientOptions): string => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha256\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport const createOpenSearchClient = (options: OpenSearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const { endpoint, node, ...rest } = options;\n\n const clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n try {\n const client = new Client(clientOptions);\n clients.set(key, client);\n return client;\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error(data);\n throw new WebinyError(\"Could not connect to OpenSearch.\", \"OPENSEARCH_CLIENT_ERROR\", data);\n }\n};\n"],"names":["clients","Map","createClientKey","options","key","JSON","hash","crypto","createOpenSearchClient","existing","endpoint","node","rest","clientOptions","client","Client","ex","data","undefined","console","WebinyError"],"mappings":";;;AAYA,MAAMA,UAAU,IAAIC;AAEpB,MAAMC,kBAAkB,CAACC;IACrB,MAAMC,MAAMC,KAAK,SAAS,CAACF;IAC3B,MAAMG,OAAOC,SAAAA,UAAiB,CAAC;IAC/BD,KAAK,MAAM,CAACF;IACZ,OAAOE,KAAK,MAAM,CAAC;AACvB;AAEO,MAAME,yBAAyB,CAACL;IACnC,MAAMC,MAAMF,gBAAgBC;IAC5B,MAAMM,WAAWT,QAAQ,GAAG,CAACI;IAC7B,IAAIK,UACA,OAAOA;IAGX,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGC,MAAM,GAAGT;IAEpC,MAAMU,gBAA+B;QACjC,MAAMH,YAAYC;QAClB,GAAGC,IAAI;IACX;IAEA,IAAI;QACA,MAAME,SAAS,IAAIC,OAAOF;QAC1Bb,QAAQ,GAAG,CAACI,KAAKU;QACjB,OAAOA;IACX,EAAE,OAAOE,IAAI;QACT,MAAMC,OAAO;YACT,OAAOD;YACP,MAAMN,YAAYC;YAClB,GAAGC,IAAI;YACP,MAAMM;QACV;QACAC,QAAQ,KAAK,CAACF;QACd,MAAM,IAAIG,MAAY,oCAAoC,2BAA2BH;IACzF;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FieldSortOptions } from "../../types.js";
|
|
2
2
|
import type { SortOrder } from "../../types.js";
|
|
3
|
-
import type { OpenSearchField } from "./abstractions/OpenSearchField.js";
|
|
4
|
-
export declare class
|
|
3
|
+
import type { OpenSearchField as OpenSearchFieldAbstraction } from "./abstractions/OpenSearchField.js";
|
|
4
|
+
export declare class OpenSearchField implements OpenSearchFieldAbstraction.Interface {
|
|
5
5
|
readonly field: string;
|
|
6
6
|
readonly path: string;
|
|
7
7
|
readonly keyword: boolean;
|
|
@@ -9,9 +9,10 @@ export declare class OpenSearchFieldImpl implements OpenSearchField.Interface {
|
|
|
9
9
|
readonly sortable: boolean;
|
|
10
10
|
readonly searchable: boolean;
|
|
11
11
|
private readonly searchValueFn?;
|
|
12
|
-
|
|
12
|
+
static create(params: OpenSearchFieldAbstraction.Params): OpenSearchField;
|
|
13
|
+
private constructor();
|
|
13
14
|
getSortOptions(order: SortOrder): FieldSortOptions;
|
|
14
15
|
getPath(field: string): string;
|
|
15
16
|
getBasePath(field: string): string;
|
|
16
|
-
toSearchValue(params:
|
|
17
|
+
toSearchValue(params: OpenSearchFieldAbstraction.SearchValueParams): any;
|
|
17
18
|
}
|
|
@@ -8,7 +8,10 @@ const unmappedTypeHasKeyword = (type)=>{
|
|
|
8
8
|
}
|
|
9
9
|
return true;
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class OpenSearchField {
|
|
12
|
+
static create(params) {
|
|
13
|
+
return new OpenSearchField(params);
|
|
14
|
+
}
|
|
12
15
|
constructor(params){
|
|
13
16
|
this.field = params.field;
|
|
14
17
|
this.path = params.path || params.field;
|
|
@@ -41,6 +44,6 @@ class OpenSearchFieldImpl {
|
|
|
41
44
|
return params.value;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
|
-
export {
|
|
47
|
+
export { OpenSearchField };
|
|
45
48
|
|
|
46
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=OpenSearchField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/OpenSearchField/OpenSearchField.js","sources":["../../../src/features/OpenSearchField/OpenSearchField.ts"],"sourcesContent":["import type { FieldSortOptions } from \"~/types.js\";\nimport type { SortOrder } from \"~/types.js\";\nimport type { OpenSearchField as OpenSearchFieldAbstraction } from \"./abstractions/OpenSearchField.js\";\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 class OpenSearchField implements OpenSearchFieldAbstraction.Interface {\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 private readonly searchValueFn?: (params: OpenSearchFieldAbstraction.SearchValueParams) => any;\n\n public static create(params: OpenSearchFieldAbstraction.Params) {\n return new OpenSearchField(params);\n }\n\n private constructor(params: OpenSearchFieldAbstraction.Params) {\n this.field = params.field;\n this.path = params.path || params.field;\n this.unmappedType = params.unmappedType;\n const keyword = params.keyword === undefined ? true : params.keyword;\n this.keyword = unmappedTypeHasKeyword(params.unmappedType) ? keyword : false;\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n this.searchValueFn = params.toSearchValue;\n }\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 any\n };\n }\n\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n\n public getBasePath(field: string): string {\n if (this.path === \"*\") {\n return field;\n }\n return this.path;\n }\n\n public toSearchValue(params: OpenSearchFieldAbstraction.SearchValueParams): any {\n if (this.searchValueFn) {\n return this.searchValueFn(params);\n }\n return params.value;\n }\n}\n"],"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","OpenSearchField","params","keyword","undefined","order","options","field"],"mappings":"AAIA,MAAMA,0BAA0B;IAAC;IAAQ;CAAO;AAEhD,MAAMC,yBAAyB,CAACC;IAC5B,IAAKA,MAEE;QAAA,IAAIF,wBAAwB,QAAQ,CAACE,OACxC,OAAO;IACX;IACA,OAAO;AACX;AAEO,MAAMC;IAST,OAAc,OAAOC,MAAyC,EAAE;QAC5D,OAAO,IAAID,gBAAgBC;IAC/B;IAEA,YAAoBA,MAAyC,CAAE;QAC3D,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAIA,OAAO,KAAK;QACvC,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,MAAMC,UAAUD,AAAmBE,WAAnBF,OAAO,OAAO,GAAiB,OAAOA,OAAO,OAAO;QACpE,IAAI,CAAC,OAAO,GAAGH,uBAAuBG,OAAO,YAAY,IAAIC,UAAU;QACvE,IAAI,CAAC,QAAQ,GAAGD,AAAoBE,WAApBF,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAGA,AAAsBE,WAAtBF,OAAO,UAAU,GAAiB,OAAOA,OAAO,UAAU;QAC5E,IAAI,CAAC,aAAa,GAAGA,OAAO,aAAa;IAC7C;IAEO,eAAeG,KAAgB,EAAoB;QACtD,MAAMC,UAAU;YACZD;QACJ;QACA,IAAI,CAAC,IAAI,CAAC,YAAY,EAClB,OAAOC;QAEX,OAAO;YACH,GAAGA,OAAO;YACV,eAAe,IAAI,CAAC,YAAY;QACpC;IACJ;IAEO,QAAQC,KAAa,EAAU;QAClC,OAAO,GAAG,IAAI,CAAC,WAAW,CAACA,SAAS,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI;IACxE;IAEO,YAAYA,KAAa,EAAU;QACtC,IAAI,AAAc,QAAd,IAAI,CAAC,IAAI,EACT,OAAOA;QAEX,OAAO,IAAI,CAAC,IAAI;IACpB;IAEO,cAAcL,MAAoD,EAAO;QAC5E,IAAI,IAAI,CAAC,aAAa,EAClB,OAAO,IAAI,CAAC,aAAa,CAACA;QAE9B,OAAOA,OAAO,KAAK;IACvB;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenSearchFieldFactory as Abstraction } from "./abstractions/OpenSearchFieldFactory.js";
|
|
2
|
-
import type { OpenSearchField } from "./abstractions/OpenSearchField.js";
|
|
2
|
+
import type { OpenSearchField as OpenSearchFieldAbstraction } from "./abstractions/OpenSearchField.js";
|
|
3
3
|
declare class OpenSearchFieldFactoryImpl implements Abstraction.Interface {
|
|
4
|
-
create(params:
|
|
4
|
+
create(params: OpenSearchFieldAbstraction.Params): OpenSearchFieldAbstraction.Interface;
|
|
5
5
|
}
|
|
6
6
|
export declare const OpenSearchFieldFactory: typeof OpenSearchFieldFactoryImpl & {
|
|
7
7
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/OpenSearchFieldFactory.js").IOpenSearchFieldFactory>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenSearchFieldFactory } from "./abstractions/OpenSearchFieldFactory.js";
|
|
2
|
-
import {
|
|
2
|
+
import { OpenSearchField } from "./OpenSearchField.js";
|
|
3
3
|
class OpenSearchFieldFactoryImpl {
|
|
4
4
|
create(params) {
|
|
5
|
-
return
|
|
5
|
+
return OpenSearchField.create(params);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
const OpenSearchFieldFactory_OpenSearchFieldFactory = OpenSearchFieldFactory.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/OpenSearchField/OpenSearchFieldFactory.js","sources":["../../../src/features/OpenSearchField/OpenSearchFieldFactory.ts"],"sourcesContent":["import { OpenSearchFieldFactory as Abstraction } from \"./abstractions/OpenSearchFieldFactory.js\";\nimport type { OpenSearchField } from \"./abstractions/OpenSearchField.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/OpenSearchField/OpenSearchFieldFactory.js","sources":["../../../src/features/OpenSearchField/OpenSearchFieldFactory.ts"],"sourcesContent":["import { OpenSearchFieldFactory as Abstraction } from \"./abstractions/OpenSearchFieldFactory.js\";\nimport type { OpenSearchField as OpenSearchFieldAbstraction } from \"./abstractions/OpenSearchField.js\";\nimport { OpenSearchField } from \"./OpenSearchField.js\";\n\nclass OpenSearchFieldFactoryImpl implements Abstraction.Interface {\n public create(params: OpenSearchFieldAbstraction.Params): OpenSearchFieldAbstraction.Interface {\n return OpenSearchField.create(params);\n }\n}\n\nexport const OpenSearchFieldFactory = Abstraction.createImplementation({\n implementation: OpenSearchFieldFactoryImpl,\n dependencies: []\n});\n"],"names":["OpenSearchFieldFactoryImpl","params","OpenSearchField","OpenSearchFieldFactory","Abstraction"],"mappings":";;AAIA,MAAMA;IACK,OAAOC,MAAyC,EAAwC;QAC3F,OAAOC,gBAAgB,MAAM,CAACD;IAClC;AACJ;AAEO,MAAME,gDAAyBC,uBAAAA,oBAAgC,CAAC;IACnE,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -7,7 +7,6 @@ export * from "./utils/index.js";
|
|
|
7
7
|
export * from "./operations/index.js";
|
|
8
8
|
export * from "./sharedIndex.js";
|
|
9
9
|
export * from "./indexPrefix.js";
|
|
10
|
-
export * from "./db/index.js";
|
|
11
10
|
export * from "./types.js";
|
|
12
11
|
export { registerOpenSearchCore } from "./registerOpenSearchCore.js";
|
|
13
12
|
export { getBaseConfiguration, getCommonMappings } from "./indexConfiguration/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-opensearch",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.eb81deee7e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,20 +18,16 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@opensearch-project/opensearch": "3.6.0",
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/error": "0.0.0-unstable.b6d7105cee",
|
|
25
|
-
"@webiny/feature": "0.0.0-unstable.b6d7105cee",
|
|
26
|
-
"@webiny/handler": "0.0.0-unstable.b6d7105cee"
|
|
21
|
+
"@webiny/error": "0.0.0-unstable.eb81deee7e",
|
|
22
|
+
"@webiny/feature": "0.0.0-unstable.eb81deee7e",
|
|
23
|
+
"@webiny/handler": "0.0.0-unstable.eb81deee7e"
|
|
27
24
|
},
|
|
28
25
|
"devDependencies": {
|
|
29
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
30
|
-
"@webiny/di": "1.0
|
|
31
|
-
"@webiny/project-utils": "0.0.0-unstable.b6d7105cee",
|
|
26
|
+
"@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
|
|
27
|
+
"@webiny/di": "1.1.0",
|
|
32
28
|
"rimraf": "6.1.3",
|
|
33
29
|
"typescript": "7.0.2",
|
|
34
|
-
"vitest": "4.1.
|
|
30
|
+
"vitest": "4.1.11"
|
|
35
31
|
},
|
|
36
32
|
"publishConfig": {
|
|
37
33
|
"access": "public"
|
package/db/entity.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ITable } from "@webiny/db-dynamodb";
|
|
2
|
-
import type { IOpenSearchEntity } from "../db/types.js";
|
|
3
|
-
export interface ICreateOpenSearchEntityParams {
|
|
4
|
-
table: ITable;
|
|
5
|
-
entityName: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const createOpenSearchEntity: (params: ICreateOpenSearchEntityParams) => IOpenSearchEntity;
|
package/db/entity.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createEntity, standardEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
-
const createOpenSearchEntity = (params)=>{
|
|
3
|
-
const { table, entityName } = params;
|
|
4
|
-
return createEntity({
|
|
5
|
-
name: entityName,
|
|
6
|
-
table: table.table,
|
|
7
|
-
attributes: {
|
|
8
|
-
...standardEntityAttributes,
|
|
9
|
-
index: {
|
|
10
|
-
type: "string",
|
|
11
|
-
required: true
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
export { createOpenSearchEntity };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=entity.js.map
|
package/db/entity.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db/entity.js","sources":["../../src/db/entity.ts"],"sourcesContent":["import { createEntity, type ITable, standardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { IOpenSearchEntity, IOpenSearchEntityAttributes } from \"~/db/types.js\";\n\nexport interface ICreateOpenSearchEntityParams {\n table: ITable;\n entityName: string;\n}\n\nexport const createOpenSearchEntity = (\n params: ICreateOpenSearchEntityParams\n): IOpenSearchEntity => {\n const { table, entityName } = params;\n return createEntity<IOpenSearchEntityAttributes>({\n name: entityName,\n table: table.table,\n attributes: {\n ...standardEntityAttributes,\n index: {\n type: \"string\",\n required: true\n }\n }\n });\n};\n"],"names":["createOpenSearchEntity","params","table","entityName","createEntity","standardEntityAttributes"],"mappings":";AAQO,MAAMA,yBAAyB,CAClCC;IAEA,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,aAA0C;QAC7C,MAAMD;QACN,OAAOD,MAAM,KAAK;QAClB,YAAY;YACR,GAAGG,wBAAwB;YAC3B,OAAO;gBACH,MAAM;gBACN,UAAU;YACd;QACJ;IACJ;AACJ"}
|
package/db/index.d.ts
DELETED
package/db/index.js
DELETED
package/db/table.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
-
import { type ITable } from "@webiny/db-dynamodb";
|
|
3
|
-
export interface ICreateOpenSearchTableParams {
|
|
4
|
-
name?: string;
|
|
5
|
-
documentClient: DynamoDBDocument;
|
|
6
|
-
}
|
|
7
|
-
export declare const createOpenSearchTable: ({ name, documentClient }: ICreateOpenSearchTableParams) => ITable;
|
package/db/table.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createTable } from "@webiny/db-dynamodb";
|
|
2
|
-
const createOpenSearchTable = ({ name, documentClient })=>createTable({
|
|
3
|
-
name: name || process.env.DB_TABLE_OPENSEARCH,
|
|
4
|
-
indexes: {
|
|
5
|
-
GSI_TENANT: {
|
|
6
|
-
partitionKey: "GSI_TENANT"
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
documentClient
|
|
10
|
-
});
|
|
11
|
-
export { createOpenSearchTable };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=table.js.map
|
package/db/table.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db/table.js","sources":["../../src/db/table.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createTable, type ITable } from \"@webiny/db-dynamodb\";\n\nexport interface ICreateOpenSearchTableParams {\n name?: string;\n documentClient: DynamoDBDocument;\n}\n\nexport const createOpenSearchTable = ({\n name,\n documentClient\n}: ICreateOpenSearchTableParams): ITable => {\n return createTable({\n name: name || (process.env.DB_TABLE_OPENSEARCH as string),\n indexes: {\n GSI_TENANT: {\n partitionKey: \"GSI_TENANT\"\n }\n },\n documentClient\n });\n};\n"],"names":["createOpenSearchTable","name","documentClient","createTable","process"],"mappings":";AAQO,MAAMA,wBAAwB,CAAC,EAClCC,IAAI,EACJC,cAAc,EACa,GACpBC,YAAY;QACf,MAAMF,QAASG,QAAQ,GAAG,CAAC,mBAAmB;QAC9C,SAAS;YACL,YAAY;gBACR,cAAc;YAClB;QACJ;QACAF;IACJ"}
|
package/db/types.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
-
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
-
export interface IOpenSearchEntityAttributes extends IStandardEntityAttributes<GenericRecord> {
|
|
4
|
-
index: string;
|
|
5
|
-
}
|
|
6
|
-
export type IOpenSearchEntity = IEntity<IOpenSearchEntityAttributes>;
|
package/db/types.js
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/OpenSearchField/OpenSearchFieldImpl.js","sources":["../../../src/features/OpenSearchField/OpenSearchFieldImpl.ts"],"sourcesContent":["import type { FieldSortOptions } from \"~/types.js\";\nimport type { SortOrder } from \"~/types.js\";\nimport type { OpenSearchField } from \"./abstractions/OpenSearchField.js\";\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 class OpenSearchFieldImpl implements OpenSearchField.Interface {\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 private readonly searchValueFn?: (params: OpenSearchField.SearchValueParams) => any;\n\n public constructor(params: OpenSearchField.Params) {\n this.field = params.field;\n this.path = params.path || params.field;\n this.unmappedType = params.unmappedType;\n const keyword = params.keyword === undefined ? true : params.keyword;\n this.keyword = unmappedTypeHasKeyword(params.unmappedType) ? keyword : false;\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n this.searchValueFn = params.toSearchValue;\n }\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 any\n };\n }\n\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n\n public getBasePath(field: string): string {\n if (this.path === \"*\") {\n return field;\n }\n return this.path;\n }\n\n public toSearchValue(params: OpenSearchField.SearchValueParams): any {\n if (this.searchValueFn) {\n return this.searchValueFn(params);\n }\n return params.value;\n }\n}\n"],"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","OpenSearchFieldImpl","params","keyword","undefined","order","options","field"],"mappings":"AAIA,MAAMA,0BAA0B;IAAC;IAAQ;CAAO;AAEhD,MAAMC,yBAAyB,CAACC;IAC5B,IAAKA,MAEE;QAAA,IAAIF,wBAAwB,QAAQ,CAACE,OACxC,OAAO;IACX;IACA,OAAO;AACX;AAEO,MAAMC;IAST,YAAmBC,MAA8B,CAAE;QAC/C,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAIA,OAAO,KAAK;QACvC,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,MAAMC,UAAUD,AAAmBE,WAAnBF,OAAO,OAAO,GAAiB,OAAOA,OAAO,OAAO;QACpE,IAAI,CAAC,OAAO,GAAGH,uBAAuBG,OAAO,YAAY,IAAIC,UAAU;QACvE,IAAI,CAAC,QAAQ,GAAGD,AAAoBE,WAApBF,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAGA,AAAsBE,WAAtBF,OAAO,UAAU,GAAiB,OAAOA,OAAO,UAAU;QAC5E,IAAI,CAAC,aAAa,GAAGA,OAAO,aAAa;IAC7C;IAEO,eAAeG,KAAgB,EAAoB;QACtD,MAAMC,UAAU;YACZD;QACJ;QACA,IAAI,CAAC,IAAI,CAAC,YAAY,EAClB,OAAOC;QAEX,OAAO;YACH,GAAGA,OAAO;YACV,eAAe,IAAI,CAAC,YAAY;QACpC;IACJ;IAEO,QAAQC,KAAa,EAAU;QAClC,OAAO,GAAG,IAAI,CAAC,WAAW,CAACA,SAAS,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI;IACxE;IAEO,YAAYA,KAAa,EAAU;QACtC,IAAI,AAAc,QAAd,IAAI,CAAC,IAAI,EACT,OAAOA;QAEX,OAAO,IAAI,CAAC,IAAI;IACpB;IAEO,cAAcL,MAAyC,EAAO;QACjE,IAAI,IAAI,CAAC,aAAa,EAClB,OAAO,IAAI,CAAC,aAAa,CAACA;QAE9B,OAAOA,OAAO,KAAK;IACvB;AACJ"}
|