@webiny/api-opensearch 0.0.0-unstable.a4f3e4ea8b → 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.
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
- let clientOptions = {
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\";\nimport { AwsSigv4Signer } from \"@opensearch-project/opensearch/aws\";\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 let clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n const region = process.env.AWS_REGION;\n if (!region) {\n throw new WebinyError(\"Missing AWS_REGION environment variable.\", \"MISSING_AWS_REGION\");\n }\n\n clientOptions = {\n ...clientOptions,\n ...AwsSigv4Signer({\n region,\n service: \"es\",\n getCredentials: () => {\n const accessKeyId = process.env.AWS_ACCESS_KEY_ID;\n const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;\n const sessionToken = process.env.AWS_SESSION_TOKEN;\n\n if (!accessKeyId || !secretAccessKey) {\n throw new WebinyError(\n \"Missing AWS credentials (AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY).\",\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n return Promise.resolve({ accessKeyId, secretAccessKey, sessionToken });\n }\n })\n };\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","region","process","WebinyError","AwsSigv4Signer","accessKeyId","secretAccessKey","sessionToken","Promise","client","Client","ex","data","undefined","console"],"mappings":";;;;AAaA,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,IAAIU,gBAA+B;QAC/B,MAAMH,YAAYC;QAClB,GAAGC,IAAI;IACX;IAEA,IAAI,CAACC,cAAc,IAAI,EAAE;QACrB,MAAMC,SAASC,QAAQ,GAAG,CAAC,UAAU;QACrC,IAAI,CAACD,QACD,MAAM,IAAIE,MAAY,4CAA4C;QAGtEH,gBAAgB;YACZ,GAAGA,aAAa;YAChB,GAAGI,eAAe;gBACdH;gBACA,SAAS;gBACT,gBAAgB;oBACZ,MAAMI,cAAcH,QAAQ,GAAG,CAAC,iBAAiB;oBACjD,MAAMI,kBAAkBJ,QAAQ,GAAG,CAAC,qBAAqB;oBACzD,MAAMK,eAAeL,QAAQ,GAAG,CAAC,iBAAiB;oBAElD,IAAI,CAACG,eAAe,CAACC,iBACjB,MAAM,IAAIH,MACN,yEACA;oBAIR,OAAOK,QAAQ,OAAO,CAAC;wBAAEH;wBAAaC;wBAAiBC;oBAAa;gBACxE;YACJ,EAAE;QACN;IACJ;IAEA,IAAI;QACA,MAAME,SAAS,IAAIC,OAAOV;QAC1Bb,QAAQ,GAAG,CAACI,KAAKkB;QACjB,OAAOA;IACX,EAAE,OAAOE,IAAI;QACT,MAAMC,OAAO;YACT,OAAOD;YACP,MAAMd,YAAYC;YAClB,GAAGC,IAAI;YACP,MAAMc;QACV;QACAC,QAAQ,KAAK,CAACF;QACd,MAAM,IAAIT,MAAY,oCAAoC,2BAA2BS;IACzF;AACJ"}
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 OpenSearchFieldImpl implements OpenSearchField.Interface {
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
- constructor(params: OpenSearchField.Params);
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: OpenSearchField.SearchValueParams): any;
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 OpenSearchFieldImpl {
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 { OpenSearchFieldImpl };
47
+ export { OpenSearchField };
45
48
 
46
- //# sourceMappingURL=OpenSearchFieldImpl.js.map
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: OpenSearchField.Params): OpenSearchField.Interface;
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 { OpenSearchFieldImpl } from "./OpenSearchFieldImpl.js";
2
+ import { OpenSearchField } from "./OpenSearchField.js";
3
3
  class OpenSearchFieldFactoryImpl {
4
4
  create(params) {
5
- return new OpenSearchFieldImpl(params);
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 { OpenSearchFieldImpl } from \"./OpenSearchFieldImpl.js\";\n\nclass OpenSearchFieldFactoryImpl implements Abstraction.Interface {\n public create(params: OpenSearchField.Params): OpenSearchField.Interface {\n return new OpenSearchFieldImpl(params);\n }\n}\n\nexport const OpenSearchFieldFactory = Abstraction.createImplementation({\n implementation: OpenSearchFieldFactoryImpl,\n dependencies: []\n});\n"],"names":["OpenSearchFieldFactoryImpl","params","OpenSearchFieldImpl","OpenSearchFieldFactory","Abstraction"],"mappings":";;AAIA,MAAMA;IACK,OAAOC,MAA8B,EAA6B;QACrE,OAAO,IAAIC,oBAAoBD;IACnC;AACJ;AAEO,MAAME,gDAAyBC,uBAAAA,oBAAgC,CAAC;IACnE,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
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"}
@@ -3,7 +3,7 @@ import { OpenSearchIndexRegistry } from "./OpenSearchIndexRegistry.js";
3
3
  const OpenSearchIndexFeature = createFeature({
4
4
  name: "opensearch.internal.index",
5
5
  register (container) {
6
- container.register(OpenSearchIndexRegistry).inSingletonScope();
6
+ container.register(OpenSearchIndexRegistry).inContainerScope();
7
7
  }
8
8
  });
9
9
  export { OpenSearchIndexFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"features/OpenSearchIndex/feature.js","sources":["../../../src/features/OpenSearchIndex/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchIndexRegistry } from \"./OpenSearchIndexRegistry.js\";\n\nexport const OpenSearchIndexFeature = createFeature({\n name: \"opensearch.internal.index\",\n register(container) {\n container.register(OpenSearchIndexRegistry).inSingletonScope();\n }\n});\n"],"names":["OpenSearchIndexFeature","createFeature","container","OpenSearchIndexRegistry"],"mappings":";;AAGO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,yBAAyB,gBAAgB;IAChE;AACJ"}
1
+ {"version":3,"file":"features/OpenSearchIndex/feature.js","sources":["../../../src/features/OpenSearchIndex/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchIndexRegistry } from \"./OpenSearchIndexRegistry.js\";\n\nexport const OpenSearchIndexFeature = createFeature({\n name: \"opensearch.internal.index\",\n register(container) {\n // Container scoped: each request builds the registry from its own container, so indexes that\n // extensions register per request are included. As a singleton it would be built once, from\n // the root container's registrations only (@webiny/di builds a singleton from the container\n // that registers it), and would never see indexes registered in a request container.\n container.register(OpenSearchIndexRegistry).inContainerScope();\n }\n});\n"],"names":["OpenSearchIndexFeature","createFeature","container","OpenSearchIndexRegistry"],"mappings":";;AAGO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QAKdA,UAAU,QAAQ,CAACC,yBAAyB,gBAAgB;IAChE;AACJ"}
@@ -33,7 +33,7 @@ const OpenSearchQueryBuilderOperatorFeature = createFeature({
33
33
  container.register(NotIn).inSingletonScope();
34
34
  container.register(StartsWith).inSingletonScope();
35
35
  container.register(NotStartsWith).inSingletonScope();
36
- container.register(OpenSearchQueryBuilderOperatorRegistry).inSingletonScope();
36
+ container.register(OpenSearchQueryBuilderOperatorRegistry).inContainerScope();
37
37
  }
38
38
  });
39
39
  export { OpenSearchQueryBuilderOperatorFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"features/OpenSearchQueryBuilderOperator/feature.js","sources":["../../../src/features/OpenSearchQueryBuilderOperator/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchQueryBuilderOperatorRegistry } from \"./OpenSearchQueryBuilderOperatorRegistry.js\";\nimport { Equal } from \"./operators/Equal.js\";\nimport { Not } from \"./operators/Not.js\";\nimport { Contains } from \"./operators/Contains.js\";\nimport { NotContains } from \"./operators/NotContains.js\";\nimport { Between } from \"./operators/Between.js\";\nimport { NotBetween } from \"./operators/NotBetween.js\";\nimport { GreaterThan } from \"./operators/GreaterThan.js\";\nimport { GreaterThanOrEqual } from \"./operators/GreaterThanOrEqual.js\";\nimport { LesserThan } from \"./operators/LesserThan.js\";\nimport { LesserThanOrEqual } from \"./operators/LesserThanOrEqual.js\";\nimport { In } from \"./operators/In.js\";\nimport { AndIn } from \"./operators/AndIn.js\";\nimport { NotIn } from \"./operators/NotIn.js\";\nimport { StartsWith } from \"./operators/StartsWith.js\";\nimport { NotStartsWith } from \"./operators/NotStartsWith.js\";\n\nexport const OpenSearchQueryBuilderOperatorFeature = createFeature({\n name: \"opensearch.internal.queryBuilderOperator\",\n register(container) {\n container.register(Equal).inSingletonScope();\n container.register(Not).inSingletonScope();\n container.register(Contains).inSingletonScope();\n container.register(NotContains).inSingletonScope();\n container.register(Between).inSingletonScope();\n container.register(NotBetween).inSingletonScope();\n container.register(GreaterThan).inSingletonScope();\n container.register(GreaterThanOrEqual).inSingletonScope();\n container.register(LesserThan).inSingletonScope();\n container.register(LesserThanOrEqual).inSingletonScope();\n container.register(In).inSingletonScope();\n container.register(AndIn).inSingletonScope();\n container.register(NotIn).inSingletonScope();\n container.register(StartsWith).inSingletonScope();\n container.register(NotStartsWith).inSingletonScope();\n container.register(OpenSearchQueryBuilderOperatorRegistry).inSingletonScope();\n }\n});\n"],"names":["OpenSearchQueryBuilderOperatorFeature","createFeature","container","Equal","Not","Contains","NotContains","Between","NotBetween","GreaterThan","GreaterThanOrEqual","LesserThan","LesserThanOrEqual","In","AndIn","NotIn","StartsWith","NotStartsWith","OpenSearchQueryBuilderOperatorRegistry"],"mappings":";;;;;;;;;;;;;;;;;AAkBO,MAAMA,wCAAwCC,cAAc;IAC/D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,OAAO,gBAAgB;QAC1CD,UAAU,QAAQ,CAACE,KAAK,gBAAgB;QACxCF,UAAU,QAAQ,CAACG,UAAU,gBAAgB;QAC7CH,UAAU,QAAQ,CAACI,aAAa,gBAAgB;QAChDJ,UAAU,QAAQ,CAACK,SAAS,gBAAgB;QAC5CL,UAAU,QAAQ,CAACM,YAAY,gBAAgB;QAC/CN,UAAU,QAAQ,CAACO,aAAa,gBAAgB;QAChDP,UAAU,QAAQ,CAACQ,oBAAoB,gBAAgB;QACvDR,UAAU,QAAQ,CAACS,YAAY,gBAAgB;QAC/CT,UAAU,QAAQ,CAACU,mBAAmB,gBAAgB;QACtDV,UAAU,QAAQ,CAACW,IAAI,gBAAgB;QACvCX,UAAU,QAAQ,CAACY,OAAO,gBAAgB;QAC1CZ,UAAU,QAAQ,CAACa,OAAO,gBAAgB;QAC1Cb,UAAU,QAAQ,CAACc,YAAY,gBAAgB;QAC/Cd,UAAU,QAAQ,CAACe,eAAe,gBAAgB;QAClDf,UAAU,QAAQ,CAACgB,wCAAwC,gBAAgB;IAC/E;AACJ"}
1
+ {"version":3,"file":"features/OpenSearchQueryBuilderOperator/feature.js","sources":["../../../src/features/OpenSearchQueryBuilderOperator/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { OpenSearchQueryBuilderOperatorRegistry } from \"./OpenSearchQueryBuilderOperatorRegistry.js\";\nimport { Equal } from \"./operators/Equal.js\";\nimport { Not } from \"./operators/Not.js\";\nimport { Contains } from \"./operators/Contains.js\";\nimport { NotContains } from \"./operators/NotContains.js\";\nimport { Between } from \"./operators/Between.js\";\nimport { NotBetween } from \"./operators/NotBetween.js\";\nimport { GreaterThan } from \"./operators/GreaterThan.js\";\nimport { GreaterThanOrEqual } from \"./operators/GreaterThanOrEqual.js\";\nimport { LesserThan } from \"./operators/LesserThan.js\";\nimport { LesserThanOrEqual } from \"./operators/LesserThanOrEqual.js\";\nimport { In } from \"./operators/In.js\";\nimport { AndIn } from \"./operators/AndIn.js\";\nimport { NotIn } from \"./operators/NotIn.js\";\nimport { StartsWith } from \"./operators/StartsWith.js\";\nimport { NotStartsWith } from \"./operators/NotStartsWith.js\";\n\nexport const OpenSearchQueryBuilderOperatorFeature = createFeature({\n name: \"opensearch.internal.queryBuilderOperator\",\n register(container) {\n container.register(Equal).inSingletonScope();\n container.register(Not).inSingletonScope();\n container.register(Contains).inSingletonScope();\n container.register(NotContains).inSingletonScope();\n container.register(Between).inSingletonScope();\n container.register(NotBetween).inSingletonScope();\n container.register(GreaterThan).inSingletonScope();\n container.register(GreaterThanOrEqual).inSingletonScope();\n container.register(LesserThan).inSingletonScope();\n container.register(LesserThanOrEqual).inSingletonScope();\n container.register(In).inSingletonScope();\n container.register(AndIn).inSingletonScope();\n container.register(NotIn).inSingletonScope();\n container.register(StartsWith).inSingletonScope();\n container.register(NotStartsWith).inSingletonScope();\n // Container scoped: each request builds the registry from its own container, so operators that\n // extensions register per request are included. As a singleton it would be built once, from\n // the root container's registrations only (@webiny/di builds a singleton from the container\n // that registers it), and would never see operators registered in a request container.\n container.register(OpenSearchQueryBuilderOperatorRegistry).inContainerScope();\n }\n});\n"],"names":["OpenSearchQueryBuilderOperatorFeature","createFeature","container","Equal","Not","Contains","NotContains","Between","NotBetween","GreaterThan","GreaterThanOrEqual","LesserThan","LesserThanOrEqual","In","AndIn","NotIn","StartsWith","NotStartsWith","OpenSearchQueryBuilderOperatorRegistry"],"mappings":";;;;;;;;;;;;;;;;;AAkBO,MAAMA,wCAAwCC,cAAc;IAC/D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,OAAO,gBAAgB;QAC1CD,UAAU,QAAQ,CAACE,KAAK,gBAAgB;QACxCF,UAAU,QAAQ,CAACG,UAAU,gBAAgB;QAC7CH,UAAU,QAAQ,CAACI,aAAa,gBAAgB;QAChDJ,UAAU,QAAQ,CAACK,SAAS,gBAAgB;QAC5CL,UAAU,QAAQ,CAACM,YAAY,gBAAgB;QAC/CN,UAAU,QAAQ,CAACO,aAAa,gBAAgB;QAChDP,UAAU,QAAQ,CAACQ,oBAAoB,gBAAgB;QACvDR,UAAU,QAAQ,CAACS,YAAY,gBAAgB;QAC/CT,UAAU,QAAQ,CAACU,mBAAmB,gBAAgB;QACtDV,UAAU,QAAQ,CAACW,IAAI,gBAAgB;QACvCX,UAAU,QAAQ,CAACY,OAAO,gBAAgB;QAC1CZ,UAAU,QAAQ,CAACa,OAAO,gBAAgB;QAC1Cb,UAAU,QAAQ,CAACc,YAAY,gBAAgB;QAC/Cd,UAAU,QAAQ,CAACe,eAAe,gBAAgB;QAKlDf,UAAU,QAAQ,CAACgB,wCAAwC,gBAAgB;IAC/E;AACJ"}
package/index.d.ts CHANGED
@@ -10,5 +10,4 @@ export * from "./utils/index.js";
10
10
  export * from "./operations/index.js";
11
11
  export * from "./sharedIndex.js";
12
12
  export * from "./indexPrefix.js";
13
- export * from "./db/index.js";
14
13
  export * from "./types.js";
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.a4f3e4ea8b",
3
+ "version": "0.0.0-unstable.a85ef555b2",
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/api": "0.0.0-unstable.a4f3e4ea8b",
22
- "@webiny/aws-sdk": "0.0.0-unstable.a4f3e4ea8b",
23
- "@webiny/db-dynamodb": "0.0.0-unstable.a4f3e4ea8b",
24
- "@webiny/error": "0.0.0-unstable.a4f3e4ea8b",
25
- "@webiny/feature": "0.0.0-unstable.a4f3e4ea8b",
26
- "@webiny/handler": "0.0.0-unstable.a4f3e4ea8b"
21
+ "@webiny/error": "0.0.0-unstable.a85ef555b2",
22
+ "@webiny/feature": "0.0.0-unstable.a85ef555b2",
23
+ "@webiny/handler": "0.0.0-unstable.a85ef555b2"
27
24
  },
28
25
  "devDependencies": {
29
- "@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b",
30
- "@webiny/di": "1.0.2",
31
- "@webiny/project-utils": "0.0.0-unstable.a4f3e4ea8b",
26
+ "@webiny/build-tools": "0.0.0-unstable.a85ef555b2",
27
+ "@webiny/di": "2.0.0",
32
28
  "rimraf": "6.1.3",
33
29
  "typescript": "7.0.2",
34
- "vitest": "4.1.10"
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
@@ -1,3 +0,0 @@
1
- export * from "./table.js";
2
- export * from "./entity.js";
3
- export * from "./types.js";
package/db/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./table.js";
2
- export * from "./entity.js";
3
- export * from "./types.js";
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"}