@webiny/api-elasticsearch 5.41.4 → 5.42.0-beta.0

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.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_awsElasticsearchConnector","_interopRequireDefault","require","_crypto","_error","_elasticsearch","clients","Map","createClientKey","options","key","JSON","stringify","hash","crypto","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","WebinyError","join","createAwsElasticsearchConnector","Client","ex","data","error","undefined","console","client","set","exports"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\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 = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n // @ts-expect-error\n credentials\n })\n };\n }\n\n try {\n return new Client(clientOptions);\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n };\n\n const client = cached();\n\n clients.set(key, client);\n return client;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAMA,MAAMI,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAmC,IAAK;EAC7D,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGC,eAAM,CAACC,UAAU,CAAC,MAAM,CAAC;EACtCF,IAAI,CAACG,MAAM,CAACN,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACI,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAIM,MAAMC,yBAAyB,GAAIT,OAAmC,IAAa;EACtF,MAAMC,GAAG,GAAGF,eAAe,CAACC,OAAO,CAAC;EACpC,MAAMU,QAAQ,GAAGb,OAAO,CAACc,GAAG,CAACV,GAAG,CAAC;EACjC,IAAIS,QAAQ,EAAE;IACV,OAAOA,QAAQ;EACnB;EAEA,MAAME,MAAM,GAAGA,CAAA,KAAc;IACzB,MAAM;MAAEC,QAAQ;MAAEC,I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L,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BK,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMI,MAAM,GAAGjC,MAAM,CAAC,CAAC;EAEvBf,OAAO,CAACiD,GAAG,CAAC7C,GAAG,EAAE4C,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC;AAACE,OAAA,CAAAtC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_awsElasticsearchConnector","_interopRequireDefault","require","_crypto","_error","_elasticsearch","clients","Map","createClientKey","options","key","JSON","stringify","hash","crypto","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","WebinyError","join","createAwsElasticsearchConnector","Client","ex","data","error","undefined","console","client","set","exports"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\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 = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n // @ts-expect-error\n credentials\n })\n };\n }\n\n try {\n return new Client(clientOptions);\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n };\n\n const client = cached();\n\n clients.set(key, client);\n return client;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAMA,MAAMI,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAmC,IAAK;EAC7D,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGC,eAAM,CAACC,UAAU,CAAC,MAAM,CAAC;EACtCF,IAAI,CAACG,MAAM,CAACN,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACI,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAIM,MAAMC,yBAAyB,GAAIT,OAAmC,IAAa;EACtF,MAAMC,GAAG,GAAGF,eAAe,CAACC,OAAO,CAAC;EACpC,MAAMU,QAAQ,GAAGb,OAAO,CAACc,GAAG,CAACV,GAAG,CAAC;EACjC,IA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GC,IAAI;QACPE,IAAI,EAAE0B;MACV,CAAC;MACDC,OAAO,CAACF,KAAK,CAAC;QACV,GAAGD;MACP,CAAC,CAAC;MACF,MAAM,IAAIL,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BK,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMI,MAAM,GAAGjC,MAAM,CAAC,CAAC;EAEvBf,OAAO,CAACiD,GAAG,CAAC7C,GAAG,EAAE4C,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC;AAACE,OAAA,CAAAtC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
package/indices.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","listIndicesPlugins","container","type","locale","byType","filter","plugin","canUse","getLastAddedIndexPlugin","params","plugins","length","WebinyError","pop","exports"],"sources":["indices.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"~/plugins/definition/ElasticsearchIndexPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n locale: string;\n}\nconst listIndicesPlugins = <T extends ElasticsearchIndexPlugin>({\n container,\n type,\n locale\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse(locale);\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends ElasticsearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single ElasticsearchIndexPlugin of type \"${params.type}\".`,\n \"ELASTICSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type,\n locale: params.locale\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOA,MAAMC,kBAAkB,GAAGA,CAAqC;EAC5DC,SAAS;EACTC,IAAI;EACJC;AACkB,CAAC,KAAU;EAC7B,OAAOF,SAAS,CAACG,MAAM,CAAIF,IAAI,CAAC,CAACG,MAAM,CAACC,MAAM,IAAI;IAC9C,OAAOA,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EAChC,CAAC,CAAC;AACN,CAAC;AAEM,MAAMK,uBAAuB,GAChCC,MAA4B,IACxB;EACJ,MAAMC,OAAO,GAAGV,kBAAkB,CAAIS,MAAM,CAAC;EAC7C,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIC,cAAW,CAChB,6DAA4DH,MAAM,CAACP,IAAK,IAAG,EAC5E,oCAAoC,EACpC;MACIA,IAAI,EAAEO,MAAM,CAACP,IAAI;MACjBC,MAAM,EAAEM,MAAM,CAACN;IACnB,CACJ,CAAC;EACL;EAEA,OAAOO,OAAO,CAACG,GAAG,CAAC,CAAC;AACxB,CAAC;AAACC,OAAA,CAAAN,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","listIndicesPlugins","container","type","locale","byType","filter","plugin","canUse","getLastAddedIndexPlugin","params","plugins","length","WebinyError","pop","exports"],"sources":["indices.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"~/plugins/definition/ElasticsearchIndexPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n locale: string;\n}\nconst listIndicesPlugins = <T extends ElasticsearchIndexPlugin>({\n container,\n type,\n locale\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse(locale);\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends ElasticsearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single ElasticsearchIndexPlugin of type \"${params.type}\".`,\n \"ELASTICSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type,\n locale: params.locale\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOA,MAAMC,kBAAkB,GAAGA,CAAqC;EAC5DC,SAAS;EACTC,IAAI;EACJC;AACkB,CAAC,KAAU;EAC7B,OAAOF,SAAS,CAACG,MAAM,CAAIF,IAAI,CAAC,CAACG,MAAM,CAACC,MAAM,IAAI;IAC9C,OAAOA,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EAChC,CAAC,CAAC;AACN,CAAC;AAEM,MAAMK,uBAAuB,GAChCC,MAA4B,IACxB;EACJ,MAAMC,OAAO,GAAGV,kBAAkB,CAAIS,MAAM,CAAC;EAC7C,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIC,cAAW,CACjB,6DAA6DH,MAAM,CAACP,IAAI,IAAI,EAC5E,oCAAoC,EACpC;MACIA,IAAI,EAAEO,MAAM,CAACP,IAAI;MACjBC,MAAM,EAAEM,MAAM,CAACN;IACnB,CACJ,CAAC;EACL;EAEA,OAAOO,OAAO,CAACG,GAAG,CAAC,CAAC;AACxB,CAAC;AAACC,OAAA,CAAAN,uBAAA,GAAAA,uBAAA","ignoreList":[]}
package/normalize.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp","exports","hasSpecialChar","match","normalizeValueWithAsterisk","initial","results","split","firstWord","lastWord","length"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `\\&`,\n `\\\\|`,\n \">\",\n \"<\",\n `\\!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `\\:`,\n `\\/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEA,MAAMA,yBAAyB,GAAG,CAAE,KAAI,CAAC;AAEzC,MAAMC,uBAAuB,GAAG,CAAC,GAAG,CAAC;AAErC,MAAMC,iBAAiB,GAAG,CACtB,MAAM,EACN,KAAK;AACL;AACA,KAAK,EACJ,IAAG,EACH,KAAI,EACL,GAAG,EACH,GAAG,EACF,IAAG,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL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AAS,CAAC,KAAK,KAAK,EAAE;IACrCX,MAAM,GAAI,IAAGA,MAAO,EAAC;EACzB;EACA;AACJ;AACA;EACI,MAAMY,QAAQ,GAAGH,OAAO,CAACA,OAAO,CAACI,MAAM,GAAG,CAAC,CAAC;EAC5C,IAAIR,cAAc,CAACO,QAAQ,CAAC,KAAK,KAAK,EAAE;IACpCZ,MAAM,GAAI,GAAEA,MAAO,GAAE;EACzB;EAEA,OAAOA,MAAM;AACjB,CAAC;AAACI,OAAA,CAAAG,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp","exports","hasSpecialChar","match","normalizeValueWithAsterisk","initial","results","split","firstWord","lastWord","length"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `\\&`,\n `\\\\|`,\n \">\",\n \"<\",\n `\\!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `\\:`,\n `\\/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEA,MAAMA,yBAAyB,GAAG,CAAC,KAAK,CAAC;AAEzC,MAAMC,uBAAuB,GAAG,CAAC,GAAG,CAAC;AAErC,MAAMC,iBAAiB,GAAG,CACtB,MAAM,EACN,KAAK;AACL;AACA,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,CACR;AAEM,MAAMC,cAAc,GAAIC,KAAa,IAAK;EAC7C,IAAIC,MAAM,GAAGD,KAAK,IAAI,EAAE;EACxB,IAAI,CAACC,MAAM,EAAE;IACT,OAAOA,MAAM;EACjB;EACA,KAAK,MAAMC,SAAS,IAAIN,yBAAyB,EAAE;IAC/CK,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;EAC3D;EACA,KAAK,MAAMA,SAAS,IAAIL,uBAAuB,EAAE;IAC7CI,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;EAC5D;EAEA,KAAK,MAAMA,SAAS,IAAIJ,iBAAiB,EAAE;IACvCG,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,KAAKA,SAAS,EAAE,CAAC;EACzE;EAEA,OAAOD,MAAM,IAAI,EAAE;AACvB,CAAC;AAACI,OAAA,CAAAN,cAAA,GAAAA,cAAA;AAEF,MAAMO,cAAc,GAAIN,KAAa,IAAqB;EACtD,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,OAAOA,KAAK,CAACO,KAAK,CAAC,mBAAmB,CAAC,KAAK,IAAI;AACpD,CAAC;AAEM,MAAMC,0BAA0B,GAAIC,OAAe,IAAK;EAC3D,MAAMT,KAAK,GAAGD,cAAc,CAACU,OAAO,CAAC;EACrC,MAAMC,OAAO,GAAGV,KAAK,CAACW,KAAK,CAAC,GAAG,CAAC;EAEhC,IAAIV,MAAM,GAAGD,KAAK;EAClB;AACJ;AACA;EACI,MAAMY,SAAS,GAAGF,OAAO,CAAC,CAAC,CAAC;EAC5B,IAAIJ,cAAc,CAACM,SAAS,CAAC,KAAK,KAAK,EAAE;IACrCX,MAAM,GAAG,IAAIA,MAAM,EAAE;EACzB;EACA;AACJ;AACA;EACI,MAAMY,QAAQ,GAAGH,OAAO,CAACA,OAAO,CAACI,MAAM,GAAG,CAAC,CAAC;EAC5C,IAAIR,cAAc,CAACO,QAAQ,CAAC,KAAK,KAAK,EAAE;IACpCZ,MAAM,GAAG,GAAGA,MAAM,GAAG;EACzB;EAEA,OAAOA,MAAM;AACjB,CAAC;AAACI,OAAA,CAAAG,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","require","_stripConnectionFromException","ElasticsearchCatHealth","constructor","client","getHealth","response","cat","health","format","Array","isArray","body","length","WebinyError","message","code","data","ex","console","error","stripConnectionFromException","log","JSON","stringify","exports"],"sources":["ElasticsearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { Client } from \"~/client\";\nimport { IElasticsearchCatHealthResponse } from \"./types\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException\";\n\nexport class ElasticsearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IElasticsearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health<\n unknown | [IElasticsearchCatHealthResponse]\n >({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"ELASTICSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,sBAAsB,CAAC;EAGzBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,SAASA,CAAA,EAA6C;IAC/D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,MAAM,CAE3C;QACEC,MAAM,EAAE;MACZ,CAAC,CAAC;MAEF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIC,kBAAW,CAAC;UAClBC,OAAO,EAAG,uDAAsD;UAChEC,IAAI,EAAE,uCAAuC;UAC7CC,IAAI,EAAEX,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MAEA,OAAO;QACH,GAAGN,QAAQ,CAACM,IAAI,CAAC,CAAC;MACtB,CAAC;IACL,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAE,+CAA8CF,EAAE,CAACH,OAAQ,EAAC,CAAC;MAC1E,MAAMK,KAAK,GAAG,IAAAC,0DAA4B,EAACH,EAAE,CAAC;MAC9CC,OAAO,CAACG,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ;AAACK,OAAA,CAAAvB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","require","_stripConnectionFromException","ElasticsearchCatHealth","constructor","client","getHealth","response","cat","health","format","Array","isArray","body","length","WebinyError","message","code","data","ex","console","error","stripConnectionFromException","log","JSON","stringify","exports"],"sources":["ElasticsearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { Client } from \"~/client\";\nimport { IElasticsearchCatHealthResponse } from \"./types\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException\";\n\nexport class ElasticsearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IElasticsearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health<\n unknown | [IElasticsearchCatHealthResponse]\n >({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"ELASTICSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,sBAAsB,CAAC;EAGzBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,SAASA,CAAA,EAA6C;IAC/D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,MAAM,CAE3C;QACEC,MAAM,EAAE;MACZ,CAAC,CAAC;MAEF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIC,kBAAW,CAAC;UAClBC,OAAO,EAAE,uDAAuD;UAChEC,IAAI,EAAE,uCAAuC;UAC7CC,IAAI,EAAEX,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MAEA,OAAO;QACH,GAAGN,QAAQ,CAACM,IAAI,CAAC,CAAC;MACtB,CAAC;IACL,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,+CAA+CF,EAAE,CAACH,OAAO,EAAE,CAAC;MAC1E,MAAMK,KAAK,GAAG,IAAAC,0DAA4B,EAACH,EAAE,CAAC;MAC9CC,OAAO,CAACG,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ;AAACK,OAAA,CAAAvB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","require","_stripConnectionFromException","ElasticsearchCatNodes","constructor","client","getNodes","response","cat","nodes","format","Array","isArray","body","length","WebinyError","message","code","data","ex","console","error","stripConnectionFromException","log","JSON","stringify","exports"],"sources":["ElasticsearchCatNodes.ts"],"sourcesContent":["import { IElasticsearchCatNodesResponse } from \"./types\";\nimport { Client } from \"~/client\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException\";\n\nexport class ElasticsearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IElasticsearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes<IElasticsearchCatNodesResponse>({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"ELASTICSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,qBAAqB,CAAC;EAGxBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,QAAQA,CAAA,EAA4C;IAC7D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,KAAK,CAAiC;QACzEC,MAAM,EAAE;MACZ,CAAC,CAAC;MACF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIC,kBAAW,CAAC;UAClBC,OAAO,EAAG,sDAAqD;UAC/DC,IAAI,EAAE,sCAAsC;UAC5CC,IAAI,EAAEX,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MACA,OAAON,QAAQ,CAACM,IAAI;IACxB,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAE,8CAA6CF,EAAE,CAACH,OAAQ,EAAC,CAAC;MACzE,MAAMK,KAAK,GAAG,IAAAC,0DAA4B,EAACH,EAAE,CAAC;MAC9CC,OAAO,CAACG,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ;AAACK,OAAA,CAAAvB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","require","_stripConnectionFromException","ElasticsearchCatNodes","constructor","client","getNodes","response","cat","nodes","format","Array","isArray","body","length","WebinyError","message","code","data","ex","console","error","stripConnectionFromException","log","JSON","stringify","exports"],"sources":["ElasticsearchCatNodes.ts"],"sourcesContent":["import { IElasticsearchCatNodesResponse } from \"./types\";\nimport { Client } from \"~/client\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException\";\n\nexport class ElasticsearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IElasticsearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes<IElasticsearchCatNodesResponse>({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"ELASTICSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,qBAAqB,CAAC;EAGxBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,QAAQA,CAAA,EAA4C;IAC7D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,KAAK,CAAiC;QACzEC,MAAM,EAAE;MACZ,CAAC,CAAC;MACF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIC,kBAAW,CAAC;UAClBC,OAAO,EAAE,sDAAsD;UAC/DC,IAAI,EAAE,sCAAsC;UAC5CC,IAAI,EAAEX,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MACA,OAAON,QAAQ,CAACM,IAAI;IACxB,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,8CAA8CF,EAAE,CAACH,OAAO,EAAE,CAAC;MACzE,MAAMK,KAAK,GAAG,IAAAC,0DAA4B,EAACH,EAAE,CAAC;MAC9CC,OAAO,CAACG,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ;AAACK,OAAA,CAAAvB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-elasticsearch",
3
- "version": "5.41.4",
3
+ "version": "5.42.0-beta.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/webiny/webiny-js.git",
@@ -13,19 +13,17 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@elastic/elasticsearch": "7.12.0",
16
- "@webiny/api": "5.41.4",
17
- "@webiny/error": "5.41.4",
18
- "@webiny/plugins": "5.41.4",
19
- "@webiny/utils": "5.41.4",
16
+ "@webiny/api": "5.42.0-beta.0",
17
+ "@webiny/error": "5.42.0-beta.0",
18
+ "@webiny/plugins": "5.42.0-beta.0",
19
+ "@webiny/utils": "5.42.0-beta.0",
20
20
  "aws-elasticsearch-connector": "9.2.0",
21
- "elastic-ts": "0.8.0"
21
+ "elastic-ts": "0.12.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@babel/cli": "7.24.1",
25
- "@babel/core": "7.24.3",
26
- "@webiny/cli": "5.41.4",
27
- "@webiny/project-utils": "5.41.4",
28
- "rimraf": "5.0.5",
24
+ "@webiny/cli": "5.42.0-beta.0",
25
+ "@webiny/project-utils": "5.42.0-beta.0",
26
+ "rimraf": "6.0.1",
29
27
  "ttypescript": "1.5.15",
30
28
  "typescript": "4.9.5"
31
29
  },
@@ -37,5 +35,5 @@
37
35
  "build": "yarn webiny run build",
38
36
  "watch": "yarn webiny run watch"
39
37
  },
40
- "gitHead": "94922b33af59db5afe75127bb07443ce7f1448c4"
38
+ "gitHead": "ebf90f62ed3f28114ffdb012b7e5f80988af53d3"
41
39
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_CompressionPlugin","require","_gzip","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","GzipCompression","CompressionPlugin","canCompress","data","compression","console","log","compress","gzip","JSON","stringify","toString","canDecompress","decompress","buf","ungzip","parse","ex","createGzipCompression","exports","_default","default"],"sources":["GzipCompression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer) => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface CompressedData {\n compression: string;\n value: string;\n}\n\nexport interface OriginalData {\n [key: string]: any;\n}\n\nclass GzipCompression extends CompressionPlugin {\n public canCompress(data: any): boolean {\n /**\n * If already compressed, skip this.\n */\n if (data.compression) {\n if (data.compression !== \"GZIP\") {\n console.log(`Data is already compressed with \"${data.compression}\".`);\n }\n return false;\n }\n return true;\n }\n public async compress(data: any) {\n const value = await gzip(JSON.stringify(data));\n\n return {\n compression: GZIP,\n value: value.toString(TO_STORAGE_ENCODING)\n };\n }\n\n public canDecompress(data: CompressedData | Record<string, any>): boolean {\n if (!data || !data.compression) {\n return false;\n } else if (data.compression !== GZIP) {\n console.log(\n `Could not decompress given data since its compression is not \"${GZIP}\". It is \"${data.compression}\".`\n );\n return false;\n }\n return true;\n }\n\n public async decompress(data: CompressedData): Promise<OriginalData | null> {\n try {\n const buf = await ungzip(convertToBuffer(data.value));\n const value = buf.toString(FROM_STORAGE_ENCODING);\n return JSON.parse(value);\n } catch (ex) {\n return null;\n }\n }\n}\n\nexport const createGzipCompression = () => {\n return new GzipCompression();\n};\n/**\n * Left due to backward compatibility with older systems.\n * Remove when upgraded the system to run from @webiny/api-serverless-cms-aws\n */\nexport default () => {\n return createGzipCompression();\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,MAAME,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAK;EAChD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAWD,MAAMG,eAAe,SAASC,oCAAiB,CAAC;EACrCC,WAAWA,CAACC,IAAS,EAAW;IACnC;AACR;AACA;IACQ,IAAIA,IAAI,CAACC,WAAW,EAAE;MAClB,IAAID,IAAI,CAACC,WAAW,KAAK,MAAM,EAAE;QAC7BC,OAAO,CAACC,GAAG,CAAE,oCAAmCH,IAAI,CAACC,WAAY,IAAG,CAAC;MACzE;MACA,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf;EACA,MAAaG,QAAQA,CAACJ,IAAS,EAAE;IAC7B,MAAMN,KAAK,GAAG,MAAM,IAAAW,cAAI,EAACC,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC,CAAC;IAE9C,OAAO;MACHC,WAAW,EAAEX,IAAI;MACjBI,KAAK,EAAEA,KAAK,CAACc,QAAQ,CAACjB,mBAAmB;IAC7C,CAAC;EACL;EAEOkB,aAAaA,CAACT,IAA0C,EAAW;IACtE,IAAI,CAACA,IAAI,IAAI,CAACA,IAAI,CAACC,WAAW,EAAE;MAC5B,OAAO,KAAK;IAChB,CAAC,MAAM,IAAID,IAAI,CAACC,WAAW,KAAKX,IAAI,EAAE;MAClCY,OAAO,CAACC,GAAG,CACN,iEAAgEb,IAAK,aAAYU,IAAI,CAACC,WAAY,IACvG,CAAC;MACD,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf;EAEA,MAAaS,UAAUA,CAACV,IAAoB,EAAgC;IACxE,IAAI;MACA,MAAMW,GAAG,GAAG,MAAM,IAAAC,gBAAM,EAACnB,eAAe,CAACO,IAAI,CAACN,KAAK,CAAC,CAAC;MACrD,MAAMA,KAAK,GAAGiB,GAAG,CAACH,QAAQ,CAAChB,qBAAqB,CAAC;MACjD,OAAOc,IAAI,CAACO,KAAK,CAACnB,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOoB,EAAE,EAAE;MACT,OAAO,IAAI;IACf;EACJ;AACJ;AAEO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,IAAIlB,eAAe,CAAC,CAAC;AAChC,CAAC;AACD;AACA;AACA;AACA;AAHAmB,OAAA,CAAAD,qBAAA,GAAAA,qBAAA;AAAA,IAAAE,QAAA,GAIeA,CAAA,KAAM;EACjB,OAAOF,qBAAqB,CAAC,CAAC;AAClC,CAAC;AAAAC,OAAA,CAAAE,OAAA,GAAAD,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["_CompressionPlugin","require","_gzip","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","GzipCompression","CompressionPlugin","canCompress","data","compression","console","log","compress","gzip","JSON","stringify","toString","canDecompress","decompress","buf","ungzip","parse","ex","createGzipCompression","exports","_default","default"],"sources":["GzipCompression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer) => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface CompressedData {\n compression: string;\n value: string;\n}\n\nexport interface OriginalData {\n [key: string]: any;\n}\n\nclass GzipCompression extends CompressionPlugin {\n public canCompress(data: any): boolean {\n /**\n * If already compressed, skip this.\n */\n if (data.compression) {\n if (data.compression !== \"GZIP\") {\n console.log(`Data is already compressed with \"${data.compression}\".`);\n }\n return false;\n }\n return true;\n }\n public async compress(data: any) {\n const value = await gzip(JSON.stringify(data));\n\n return {\n compression: GZIP,\n value: value.toString(TO_STORAGE_ENCODING)\n };\n }\n\n public canDecompress(data: CompressedData | Record<string, any>): boolean {\n if (!data || !data.compression) {\n return false;\n } else if (data.compression !== GZIP) {\n console.log(\n `Could not decompress given data since its compression is not \"${GZIP}\". It is \"${data.compression}\".`\n );\n return false;\n }\n return true;\n }\n\n public async decompress(data: CompressedData): Promise<OriginalData | null> {\n try {\n const buf = await ungzip(convertToBuffer(data.value));\n const value = buf.toString(FROM_STORAGE_ENCODING);\n return JSON.parse(value);\n } catch (ex) {\n return null;\n }\n }\n}\n\nexport const createGzipCompression = () => {\n return new GzipCompression();\n};\n/**\n * Left due to backward compatibility with older systems.\n * Remove when upgraded the system to run from @webiny/api-serverless-cms-aws\n */\nexport default () => {\n return createGzipCompression();\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,MAAME,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB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AAQ,CAAChB,qBAAqB,CAAC;MACjD,OAAOc,IAAI,CAACO,KAAK,CAACnB,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOoB,EAAE,EAAE;MACT,OAAO,IAAI;IACf;EACJ;AACJ;AAEO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,IAAIlB,eAAe,CAAC,CAAC;AAChC,CAAC;AACD;AACA;AACA;AACA;AAHAmB,OAAA,CAAAD,qBAAA,GAAAA,qBAAA;AAAA,IAAAE,QAAA,GAIeA,CAAA,KAAM;EACjB,OAAOF,qBAAqB,CAAC,CAAC;AAClC,CAAC;AAAAC,OAAA,CAAAE,OAAA,GAAAD,QAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","modifyBody","params","WebinyError","exports"],"sources":["ElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { SearchBody } from \"elastic-ts\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,+BAAA,GAAAA,+BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","modifyBody","params","WebinyError","exports"],"sources":["ElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { SearchBody } from \"elastic-ts\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CACjB,oCAAoC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","ALL","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","toSearchValue","value","exports"],"sources":["ElasticsearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FieldSortOptions, SortOrder } from \"elastic-ts\";\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 ElasticsearchFieldPluginParams {\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 ElasticsearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.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: ElasticsearchFieldPluginParams) {\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\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 === ElasticsearchFieldPlugin.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,IAAAA,QAAA,GAAAC,OAAA;AAKA,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,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EACxE;EACA;AACJ;AACA;AACA;AACA;EACWU,WAAWA,CAACZ,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKN,wBAAwB,CAACE,GAAG,EAAE;MAC5C,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;AAACC,OAAA,CAAApB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_plugins","require","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","ALL","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","toSearchValue","value","exports"],"sources":["ElasticsearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FieldSortOptions, SortOrder } from \"elastic-ts\";\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 ElasticsearchFieldPluginParams {\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 ElasticsearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.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: ElasticsearchFieldPluginParams) {\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\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 === ElasticsearchFieldPlugin.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,IAAAA,QAAA,GAAAC,OAAA;AAKA,MAAMC,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EA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ACZ,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,KAAKN,wBAAwB,CAACE,GAAG,EAAE;MAC5C,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;AAACC,OAAA,CAAApB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchQueryModifierPlugin","Plugin","constructor","callable","modifyQuery","params","WebinyError","exports"],"sources":["ElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig } from \"~/types\";\n\nexport interface ModifyQueryParams {\n query: ElasticsearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchQueryModifierPlugin<\n T extends ModifyQueryParams = ModifyQueryParams\n> extends Plugin {\n private readonly callable?: ModifyQueryCallable<T>;\n\n public constructor(callable?: ModifyQueryCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyQuery(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the query.`,\n \"QUERY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAYO,MAAeE,gCAAgC,SAE5CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,WAAWA,CAACC,MAAS,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,qCAAoC,EACrC,4BAA4B,EAC5B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,gCAAA,GAAAA,gCAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchQueryModifierPlugin","Plugin","constructor","callable","modifyQuery","params","WebinyError","exports"],"sources":["ElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig } from \"~/types\";\n\nexport interface ModifyQueryParams {\n query: ElasticsearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchQueryModifierPlugin<\n T extends ModifyQueryParams = ModifyQueryParams\n> extends Plugin {\n private readonly callable?: ModifyQueryCallable<T>;\n\n public constructor(callable?: ModifyQueryCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyQuery(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the query.`,\n \"QUERY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAYO,MAAeE,gCAAgC,SAE5CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,WAAWA,CAACC,MAAS,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,gCAAA,GAAAA,gCAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchSortModifierPlugin","Plugin","constructor","callable","modifySort","params","WebinyError","exports"],"sources":["ElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { Sort } from \"elastic-ts\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchSortModifierPlugin<\n T extends ModifySortParams = ModifySortParams\n> extends Plugin {\n private readonly callable?: ModifySortCallable<T>;\n\n public constructor(callable?: ModifySortCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifySort(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the sort.`,\n \"SORT_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,+BAAA,GAAAA,+BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","ElasticsearchSortModifierPlugin","Plugin","constructor","callable","modifySort","params","WebinyError","exports"],"sources":["ElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { Sort } from \"elastic-ts\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchSortModifierPlugin<\n T extends ModifySortParams = ModifySortParams\n> extends Plugin {\n private readonly callable?: ModifySortCallable<T>;\n\n public constructor(callable?: ModifySortCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifySort(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the sort.`,\n \"SORT_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAWO,MAAeE,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CACjB,oCAAoC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAACE,OAAA,CAAAP,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","filter","push","term","exports"],"sources":["andIn.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorAndInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.andIn.default\";\n\n public getOperator(): string {\n return \"and_in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${path}\" with \"in\" operator and not send an array of values.`\n );\n }\n\n let useBasePath = false;\n // Only use \".keyword\" if all of the provided values are strings.\n for (const value of values) {\n if (typeof value !== \"string\") {\n useBasePath = true;\n break;\n }\n }\n\n for (const value of values) {\n query.filter.push({\n term: {\n [useBasePath ? basePath : path]: value\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGJ,MAAM;IAChD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACV,4BAA2BL,IAAK,uDACrC,CAAC;IACL;IAEA,IAAIM,WAAW,GAAG,KAAK;IACvB;IACA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxB,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;QAC3BQ,WAAW,GAAG,IAAI;QAClB;MACJ;IACJ;IAEA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxBH,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC;QACdC,IAAI,EAAE;UACF,CAACH,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGF;QACrC;MACJ,CAAC,CAAC;IACN;EACJ;AACJ;AAACY,OAAA,CAAAnB,4CAAA,GAAAA,4CAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","filter","push","term","exports"],"sources":["andIn.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorAndInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.andIn.default\";\n\n public getOperator(): string {\n return \"and_in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${path}\" with \"in\" operator and not send an array of values.`\n );\n }\n\n let useBasePath = false;\n // Only use \".keyword\" if all of the provided values are strings.\n for (const value of values) {\n if (typeof value !== \"string\") {\n useBasePath = true;\n break;\n }\n }\n\n for (const value of values) {\n query.filter.push({\n term: {\n [useBasePath ? basePath : path]: value\n }\n });\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGJ,MAAM;IAChD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACX,4BAA4BL,IAAI,uDACpC,CAAC;IACL;IAEA,IAAIM,WAAW,GAAG,KAAK;IACvB;IACA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxB,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;QAC3BQ,WAAW,GAAG,IAAI;QAClB;MACJ;IACJ;IAEA,KAAK,MAAMR,KAAK,IAAIC,MAAM,EAAE;MACxBH,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC;QACdC,IAAI,EAAE;UACF,CAACH,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGF;QACrC;MACJ,CAAC,CAAC;IACN;EACJ;AACJ;AAACY,OAAA,CAAAnB,4CAAA,GAAAA,4CAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","filter","push","range","exports"],"sources":["between.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.between.default\";\n\n public getOperator(): string {\n return \"between\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with between query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte\n const [gte, lte] = value;\n query.filter.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,8CAA8C,SAASC,gFAAuC,CAAC;EACxFC,IAAI,GAAG,qDAAqD;EAErEC,WAAWA,CAAA,EAAW;IACzB,OAAO,SAAS;EACpB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEN;IAAK,CAAC,GAAGI,MAAM;IACxC,IAAIG,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAII,KAAK,CACV,iCAAgCT,IAAK,uDAC1C,CAAC;IACL,CAAC,MAAM,IAAIK,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACV,uDAAsDT,IAAK,cAChE,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACW,GAAG,EAAEC,GAAG,CAAC,GAAGP,KAAK;IACxBF,KAAK,CAACU,MAAM,CAACC,IAAI,CAAC;MACdC,KAAK,EAAE;QACH,CAACT,QAAQ,GAAG;UACRM,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAAlB,8CAAA,GAAAA,8CAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","filter","push","range","exports"],"sources":["between.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.between.default\";\n\n public getOperator(): string {\n return \"between\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with between query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte\n const [gte, lte] = value;\n query.filter.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,8CAA8C,SAASC,gFAAuC,CAAC;EACxFC,IAAI,GAAG,qDAAqD;EAErEC,WAAWA,CAAA,EAAW;IACzB,OAAO,SAAS;EACpB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEN;IAAK,CAAC,GAAGI,MAAM;IACxC,IAAIG,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAII,KAAK,CACX,iCAAiCT,IAAI,uDACzC,CAAC;IACL,CAAC,MAAM,IAAIK,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACX,uDAAuDT,IAAI,cAC/D,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACW,GAAG,EAAEC,GAAG,CAAC,GAAGP,KAAK;IACxBF,KAAK,CAACU,MAAM,CAACC,IAAI,CAAC;MACdC,KAAK,EAAE;QACH,CAACT,QAAQ,GAAG;UACRM,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAAlB,8CAAA,GAAAA,8CAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","some","filter","push","terms","exports"],"sources":["in.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.in.default\";\n\n public getOperator(): string {\n return \"in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"in\" operator and not send an array of values.`\n );\n }\n\n // Only use \".keyword\" if all of the provided values are strings.\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.filter.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,yCAAyC,SAASC,gFAAuC,CAAC;EACnFC,IAAI,GAAG,gDAAgD;EAEhEC,WAAWA,CAAA,EAAW;IACzB,OAAO,IAAI;EACf;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAER;IAAK,CAAC,GAAGI,MAAM;IACtD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACV,4BAA2BZ,IAAK,uDACrC,CAAC;IACL;;IAEA;IACA,MAAMa,WAAW,GAAGP,MAAM,CAACQ,IAAI,CAC1BT,KAAmD,IAAK,OAAOA,KAAK,KAAK,QAC9E,CAAC;IAEDF,KAAK,CAACY,MAAM,CAACC,IAAI,CAAC;MACdC,KAAK,EAAE;QACH,CAACJ,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGD;MACrC;IACJ,CAAC,CAAC;EACN;AACJ;AAACY,OAAA,CAAApB,yCAAA,GAAAA,yCAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","some","filter","push","terms","exports"],"sources":["in.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.in.default\";\n\n public getOperator(): string {\n return \"in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"in\" operator and not send an array of values.`\n );\n }\n\n // Only use \".keyword\" if all of the provided values are strings.\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.filter.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,yCAAyC,SAASC,gFAAuC,CAAC;EACnFC,IAAI,GAAG,gDAAgD;EAEhEC,WAAWA,CAAA,EAAW;IACzB,OAAO,IAAI;EACf;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAER;IAAK,CAAC,GAAGI,MAAM;IACtD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACX,4BAA4BZ,IAAI,uDACpC,CAAC;IACL;;IAEA;IACA,MAAMa,WAAW,GAAGP,MAAM,CAACQ,IAAI,CAC1BT,KAAmD,IAAK,OAAOA,KAAK,KAAK,QAC9E,CAAC;IAEDF,KAAK,CAACY,MAAM,CAACC,IAAI,CAAC;MACdC,KAAK,EAAE;QACH,CAACJ,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGD;MACrC;IACJ,CAAC,CAAC;EACN;AACJ;AAACY,OAAA,CAAApB,yCAAA,GAAAA,yCAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","_normalize","ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","isLocaleSupported","code","includes","toLowerCase","getOperator","apply","query","params","value","initialValue","basePath","normalizeValueWithAsterisk","must","push","multi_match","type","fields","should","exports"],"sources":["contains.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { normalizeValueWithAsterisk } from \"~/normalize\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.contains.japanese\";\n\n public override isLocaleSupported(code: string): boolean {\n if (!code) {\n return false;\n }\n return [\"ja\", \"ja-jp\"].includes(code.toLowerCase());\n }\n\n public getOperator(): string {\n return \"contains\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: initialValue, basePath } = params;\n\n const value = normalizeValueWithAsterisk(initialValue);\n query.must.push({\n multi_match: {\n query: value,\n type: \"phrase\",\n fields: [`${basePath}.ngram`]\n }\n });\n query.should.push({\n multi_match: {\n query: value,\n type: \"phrase\",\n fields: [`${basePath}`]\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,uDAAuD,SAASC,gFAAuC,CAAC;EACjGC,IAAI,GAAG,uDAAuD;EAE9DC,iBAAiBA,CAACC,IAAY,EAAW;IACrD,IAAI,CAACA,IAAI,EAAE;MACP,OAAO,KAAK;IAChB;IACA,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAACC,QAAQ,CAACD,IAAI,CAACE,WAAW,CAAC,CAAC,CAAC;EACvD;EAEOC,WAAWA,CAAA,EAAW;IACzB,OAAO,UAAU;EACrB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,YAAY;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAEhD,MAAMC,KAAK,GAAG,IAAAG,qCAA0B,EAACF,YAAY,CAAC;IACtDH,KAAK,CAACM,IAAI,CAACC,IAAI,CAAC;MACZC,WAAW,EAAE;QACTR,KAAK,EAAEE,KAAK;QACZO,IAAI,EAAE,QAAQ;QACdC,MAAM,EAAE,CAAE,GAAEN,QAAS,QAAO;MAChC;IACJ,CAAC,CAAC;IACFJ,KAAK,CAACW,MAAM,CAACJ,IAAI,CAAC;MACdC,WAAW,EAAE;QACTR,KAAK,EAAEE,KAAK;QACZO,IAAI,EAAE,QAAQ;QACdC,MAAM,EAAE,CAAE,GAAEN,QAAS,EAAC;MAC1B;IACJ,CAAC,CAAC;EACN;AACJ;AAACQ,OAAA,CAAArB,uDAAA,GAAAA,uDAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","_normalize","ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","isLocaleSupported","code","includes","toLowerCase","getOperator","apply","query","params","value","initialValue","basePath","normalizeValueWithAsterisk","must","push","multi_match","type","fields","should","exports"],"sources":["contains.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { normalizeValueWithAsterisk } from \"~/normalize\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.contains.japanese\";\n\n public override isLocaleSupported(code: string): boolean {\n if (!code) {\n return false;\n }\n return [\"ja\", \"ja-jp\"].includes(code.toLowerCase());\n }\n\n public getOperator(): string {\n return \"contains\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: initialValue, basePath } = params;\n\n const value = normalizeValueWithAsterisk(initialValue);\n query.must.push({\n multi_match: {\n query: value,\n type: \"phrase\",\n fields: [`${basePath}.ngram`]\n }\n });\n query.should.push({\n multi_match: {\n query: value,\n type: \"phrase\",\n fields: [`${basePath}`]\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,uDAAuD,SAASC,gFAAuC,CAAC;EACjGC,IAAI,GAAG,uDAAuD;EAE9DC,iBAAiBA,CAACC,IAAY,EAAW;IACrD,IAAI,CAACA,IAAI,EAAE;MACP,OAAO,KAAK;IAChB;IACA,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAACC,QAAQ,CAACD,IAAI,CAACE,WAAW,CAAC,CAAC,CAAC;EACvD;EAEOC,WAAWA,CAAA,EAAW;IACzB,OAAO,UAAU;EACrB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,YAAY;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAEhD,MAAMC,KAAK,GAAG,IAAAG,qCAA0B,EAACF,YAAY,CAAC;IACtDH,KAAK,CAACM,IAAI,CAACC,IAAI,CAAC;MACZC,WAAW,EAAE;QACTR,KAAK,EAAEE,KAAK;QACZO,IAAI,EAAE,QAAQ;QACdC,MAAM,EAAE,CAAC,GAAGN,QAAQ,QAAQ;MAChC;IACJ,CAAC,CAAC;IACFJ,KAAK,CAACW,MAAM,CAACJ,IAAI,CAAC;MACdC,WAAW,EAAE;QACTR,KAAK,EAAEE,KAAK;QACZO,IAAI,EAAE,QAAQ;QACdC,MAAM,EAAE,CAAC,GAAGN,QAAQ,EAAE;MAC1B;IACJ,CAAC,CAAC;EACN;AACJ;AAACQ,OAAA,CAAArB,uDAAA,GAAAA,uDAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorNotBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","must_not","push","range","exports"],"sources":["notBetween.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorNotBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.notBetween.default\";\n\n public getOperator(): string {\n return \"not_between\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with \"not_between\" query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte === true which in this case it means that record will not match\n const [gte, lte] = value;\n query.must_not.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,iDAAiD,SAASC,gFAAuC,CAAC;EAC3FC,IAAI,GAAG,wDAAwD;EAExEC,WAAWA,CAAA,EAAW;IACzB,OAAO,aAAa;EACxB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEN;IAAK,CAAC,GAAGI,MAAM;IACxC,IAAIG,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAII,KAAK,CACV,iCAAgCT,IAAK,6DAC1C,CAAC;IACL,CAAC,MAAM,IAAIK,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACV,uDAAsDT,IAAK,cAChE,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACW,GAAG,EAAEC,GAAG,CAAC,GAAGP,KAAK;IACxBF,KAAK,CAACU,QAAQ,CAACC,IAAI,CAAC;MAChBC,KAAK,EAAE;QACH,CAACT,QAAQ,GAAG;UACRM,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAAlB,iDAAA,GAAAA,iDAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorNotBetweenPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","must_not","push","range","exports"],"sources":["notBetween.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorNotBetweenPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.notBetween.default\";\n\n public getOperator(): string {\n return \"not_between\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with \"not_between\" query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte === true which in this case it means that record will not match\n const [gte, lte] = value;\n query.must_not.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,iDAAiD,SAASC,gFAAuC,CAAC;EAC3FC,IAAI,GAAG,wDAAwD;EAExEC,WAAWA,CAAA,EAAW;IACzB,OAAO,aAAa;EACxB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEN;IAAK,CAAC,GAAGI,MAAM;IACxC,IAAIG,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAII,KAAK,CACX,iCAAiCT,IAAI,6DACzC,CAAC;IACL,CAAC,MAAM,IAAIK,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACX,uDAAuDT,IAAI,cAC/D,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACW,GAAG,EAAEC,GAAG,CAAC,GAAGP,KAAK;IACxBF,KAAK,CAACU,QAAQ,CAACC,IAAI,CAAC;MAChBC,KAAK,EAAE;QACH,CAACT,QAAQ,GAAG;UACRM,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACK,OAAA,CAAAlB,iDAAA,GAAAA,iDAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorNotInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","some","must_not","push","terms","exports"],"sources":["notIn.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorNotInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.notIn.default\";\n\n public getOperator(): string {\n return \"not_in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"not_in\" operator and not send an array of values.`\n );\n }\n\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.must_not.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAER;IAAK,CAAC,GAAGI,MAAM;IACtD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACV,4BAA2BZ,IAAK,2DACrC,CAAC;IACL;IAEA,MAAMa,WAAW,GAAGP,MAAM,CAACQ,IAAI,CAC1BT,KAAmD,IAAK,OAAOA,KAAK,KAAK,QAC9E,CAAC;IAEDF,KAAK,CAACY,QAAQ,CAACC,IAAI,CAAC;MAChBC,KAAK,EAAE;QACH,CAACJ,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGD;MACrC;IACJ,CAAC,CAAC;EACN;AACJ;AAACY,OAAA,CAAApB,4CAAA,GAAAA,4CAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchQueryBuilderOperatorPlugin","require","ElasticsearchQueryBuilderOperatorNotInPlugin","ElasticsearchQueryBuilderOperatorPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","some","must_not","push","terms","exports"],"sources":["notIn.ts"],"sourcesContent":["import { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { ElasticsearchBoolQueryConfig, ElasticsearchQueryBuilderArgsPlugin } from \"~/types\";\n\nexport class ElasticsearchQueryBuilderOperatorNotInPlugin extends ElasticsearchQueryBuilderOperatorPlugin {\n public override name = \"elasticsearch.queryBuilder.operator.notIn.default\";\n\n public getOperator(): string {\n return \"not_in\";\n }\n\n public apply(\n query: ElasticsearchBoolQueryConfig,\n params: ElasticsearchQueryBuilderArgsPlugin\n ): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"not_in\" operator and not send an array of values.`\n );\n }\n\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.must_not.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wCAAA,GAAAC,OAAA;AAGO,MAAMC,4CAA4C,SAASC,gFAAuC,CAAC;EACtFC,IAAI,GAAG,mDAAmD;EAEnEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CACRC,KAAmC,EACnCC,MAA2C,EACvC;IACJ,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAER;IAAK,CAAC,GAAGI,MAAM;IACtD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACX,4BAA4BZ,IAAI,2DACpC,CAAC;IACL;IAEA,MAAMa,WAAW,GAAGP,MAAM,CAACQ,IAAI,CAC1BT,KAAmD,IAAK,OAAOA,KAAK,KAAK,QAC9E,CAAC;IAEDF,KAAK,CAACY,QAAQ,CAACC,IAAI,CAAC;MAChBC,KAAK,EAAE;QACH,CAACJ,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGD;MACrC;IACJ,CAAC,CAAC;EACN;AACJ;AAACY,OAAA,CAAApB,4CAAA,GAAAA,4CAAA","ignoreList":[]}
package/sort.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","sortRegExp","RegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","result","reduce","acc","value","WebinyError","match","initialOrder","toLowerCase","plugin","ElasticsearchFieldPlugin","ALL","path","getPath","getSortOptions","exports"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { FieldSortOptions, SortOrder, SortType } from \"~/types\";\nimport { ElasticsearchFieldPlugin } from \"~/plugins\";\n\nconst sortRegExp = new RegExp(/^([a-zA-Z-0-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, ElasticsearchFieldPlugin>;\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\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce((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: ElasticsearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[ElasticsearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(`Missing plugin for the field \"${field}\"`, \"PLUGIN_SORT_ERROR\", {\n field\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 }, {} as Record<string, FieldSortOptions>);\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the Elasticsearch 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAG,IAAIC,MAAM,CAAC,gC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CAACI,OAAO,CAACjB,KAAK,CAAC;IAElCO,GAAG,CAACS,IAAI,CAAC,GAAGH,MAAM,CAACK,cAAc,CAACjB,KAAK,CAAC;IAExC,OAAOM,GAAG;EACd,CAAC,EAAE,CAAC,CAAqC,CAAC;EAC1C;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;AAACc,OAAA,CAAAzB,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_plugins","sortRegExp","RegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","result","reduce","acc","value","WebinyError","match","initialOrder","toLowerCase","plugin","ElasticsearchFieldPlugin","ALL","path","getPath","getSortOptions","exports"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { FieldSortOptions, SortOrder, SortType } from \"~/types\";\nimport { ElasticsearchFieldPlugin } from \"~/plugins\";\n\nconst sortRegExp = new RegExp(/^([a-zA-Z-0-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, ElasticsearchFieldPlugin>;\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\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce((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: ElasticsearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[ElasticsearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(`Missing plugin for the field \"${field}\"`, \"PLUGIN_SORT_ERROR\", {\n field\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 }, {} as Record<string, FieldSortOptions>);\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the Elasticsearch 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAG,IAAIC,MAAM,CAAC,gCAAgC,CAAC;AAYxD,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,EAAED,YAAY,IAAIE;MACnC;IACJ,CAAC;EACL;EACA;AACJ;AACA;EACI,MAAMC,MAAM,GAAGT,IAAI,CAACU,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;IACvC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,MAAM,IAAIC,cAAW,CAAC,mCAAmC,CAAC;IAC9D;IACA,MAAMC,KAAK,GAAGF,KAAK,CAACE,KAAK,CAAClB,UAAU,CAAC;IAErC,IAAI,CAACkB,KAAK,EAAE;MACR,MAAM,IAAID,cAAW,CAAC,mBAAmBD,KAAK,IAAI,CAAC;IACvD;IAEA,MAAM,GAAGR,KAAK,EAAEW,YAAY,CAAC,GAAGD,KAAK;IACrC,MAAMT,KAAgB,GAAGU,YAAY,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK,GAAG,KAAK,GAAG,MAAM;IAE9E,MAAMC,MAAgC,GAClCf,YAAY,CAACE,KAAK,CAAC,IAAIF,YAAY,CAACgB,iCAAwB,CAACC,GAAG,CAAC;IACrE,IAAI,CAACF,MAAM,EAAE;MACT,MAAM,IAAIJ,cAAW,CAAC,iCAAiCT,KAAK,GAAG,EAAE,mBAAmB,EAAE;QAClFA;MACJ,CAAC,CAAC;IACN;IACA;AACR;AACA;AACA;IACQ,MAAMgB,IAAI,GAAGH,MAAM,CAACI,OAAO,CAACjB,KAAK,CAAC;IAElCO,GAAG,CAACS,IAAI,CAAC,GAAGH,MAAM,CAACK,cAAc,CAACjB,KAAK,CAAC;IAExC,OAAOM,GAAG;EACd,CAAC,EAAE,CAAC,CAAqC,CAAC;EAC1C;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;AAACc,OAAA,CAAAzB,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_indices","require","_error","_interopRequireDefault","indexExists","params","client","index","onExists","response","indices","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","body","ex","console","error","indexCreate","plugin","tenant","locale","type","onError","create","WebinyError","message","code","data","createIndex","plugins","getLastAddedIndexPlugin","container","exports"],"sources":["createIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getLastAddedIndexPlugin } from \"~/indices\";\nimport { ElasticsearchIndexPlugin } from \"~/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface OnExists {\n (): void;\n}\n\ninterface OnError {\n (ex: Error): Error;\n}\n\ninterface ExistsIndexParams {\n client: Client;\n index: string;\n onExists?: OnExists;\n}\n\nconst indexExists = async (params: ExistsIndexParams): Promise<boolean> => {\n const { client, index, onExists } = params;\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (!response.body) {\n return false;\n }\n if (onExists) {\n onExists();\n }\n return true;\n } catch (ex) {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n return false;\n};\n\ninterface IndexCreateParams {\n client: Client;\n index: string;\n type: string;\n tenant: string;\n locale: string;\n plugin: ElasticsearchIndexPlugin;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, locale, type, onError } = params;\n\n try {\n await client.indices.create({\n index,\n body: {\n ...plugin.body\n }\n });\n } catch (ex) {\n let error = ex;\n if (onError) {\n error = onError(ex);\n }\n throw new WebinyError(\n error.message || `Could not create Elasticsearch index for the ${type}.`,\n error.code || \"CREATE_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\n locale,\n tenant,\n index,\n body: plugin.body\n }\n );\n }\n};\n\ninterface CreateIndexParams {\n client: Client;\n plugins: PluginsContainer;\n type: string;\n tenant: string;\n locale: string;\n index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugins, type, locale, onExists } = params;\n const plugin = getLastAddedIndexPlugin<ElasticsearchIndexPlugin>({\n container: plugins,\n type,\n locale\n });\n\n const exists = await indexExists(params);\n if (exists) {\n if (onExists) {\n onExists();\n }\n return;\n }\n\n await indexCreate({\n ...params,\n plugin\n });\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAgBA,MAAMG,WAAW,GAAG,MAAOC,MAAyB,IAAuB;EACvE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAE1C,IAAI;IACA,MAAMI,QAAQ,GAAG,MAAMH,MAAM,CAACI,OAAO,CAACC,MAAM,CAAC;MACzCJ,KAAK;MACLK,kBAAkB,EAAE,KAAK;MACzBC,gBAAgB,EAAE,IAAI;MACtBC,gBAAgB,EAAE,IAAI;MACtBC,aAAa,EAAE,KAAK;MACpBC,KAAK,EAAE;IACX,CAAC,CAAC;IACF,IAAI,CAACP,QAAQ,CAACQ,IAAI,EAAE;MAChB,OAAO,KAAK;IAChB;IACA,IAAIT,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA,OAAO,IAAI;EACf,CAAC,CAAC,OAAOU,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAAE,qCAAoCb,KAAM,WAAU,CAAC;EACxE;EACA,OAAO,KAAK;AAChB,CAAC;AAYD,MAAMc,WAAW,GAAG,MAAOhB,MAAyB,IAAoB;EACpE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEe,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGrB,MAAM;EAEvE,IAAI;IACA,MAAMC,MAAM,CAACI,OAAO,CAACiB,MAAM,CAAC;MACxBpB,KAAK;MACLU,IAAI,EAAE;QACF,GAAGK,MAAM,CAACL;MACd;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,IAAIE,KAAK,GAAGF,EAAE;IACd,IAAIQ,OAAO,EAAE;MACTN,KAAK,GAAGM,OAAO,CAACR,EAAE,CAAC;IACvB;IACA,MAAM,IAAIU,cAAW,CACjBR,KAAK,CAACS,OAAO,IAAK,gDAA+CJ,IAAK,GAAE,EACxEL,KAAK,CAACU,IAAI,IAAI,kCAAkC,EAChD;MACIV,KAAK,EAAE;QACH,GAAGA,KAAK;QACRS,OAAO,EAAET,KAAK,CAACS,OAAO;QACtBC,IAAI,EAAEV,KAAK,CAACU,IAAI;QAChBC,IAAI,EAAEX,KAAK,CAACW;MAChB,CAAC;MACDN,IAAI;MACJD,MAAM;MACND,MAAM;MACNhB,KAAK;MACLU,IAAI,EAAEK,MAAM,CAACL;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAaM,MAAMe,WAAW,GAAG,MAAO3B,MAAyB,IAAoB;EAC3E,MAAM;IAAE4B,OAAO;IAAER,IAAI;IAAED,MAAM;IAAEhB;EAAS,CAAC,GAAGH,MAAM;EAClD,MAAMiB,MAAM,GAAG,IAAAY,gCAAuB,EAA2B;IAC7DC,SAAS,EAAEF,OAAO;IAClBR,IAAI;IACJD;EACJ,CAAC,CAAC;EAEF,MAAMb,MAAM,GAAG,MAAMP,WAAW,CAACC,MAAM,CAAC;EACxC,IAAIM,MAAM,EAAE;IACR,IAAIH,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA;EACJ;EAEA,MAAMa,WAAW,CAAC;IACd,GAAGhB,MAAM;IACTiB;EACJ,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAJ,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_indices","require","_error","_interopRequireDefault","indexExists","params","client","index","onExists","response","indices","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","body","ex","console","error","indexCreate","plugin","tenant","locale","type","onError","create","WebinyError","message","code","data","createIndex","plugins","getLastAddedIndexPlugin","container","exports"],"sources":["createIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getLastAddedIndexPlugin } from \"~/indices\";\nimport { ElasticsearchIndexPlugin } from \"~/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface OnExists {\n (): void;\n}\n\ninterface OnError {\n (ex: Error): Error;\n}\n\ninterface ExistsIndexParams {\n client: Client;\n index: string;\n onExists?: OnExists;\n}\n\nconst indexExists = async (params: ExistsIndexParams): Promise<boolean> => {\n const { client, index, onExists } = params;\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (!response.body) {\n return false;\n }\n if (onExists) {\n onExists();\n }\n return true;\n } catch (ex) {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n return false;\n};\n\ninterface IndexCreateParams {\n client: Client;\n index: string;\n type: string;\n tenant: string;\n locale: string;\n plugin: ElasticsearchIndexPlugin;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, locale, type, onError } = params;\n\n try {\n await client.indices.create({\n index,\n body: {\n ...plugin.body\n }\n });\n } catch (ex) {\n let error = ex;\n if (onError) {\n error = onError(ex);\n }\n throw new WebinyError(\n error.message || `Could not create Elasticsearch index for the ${type}.`,\n error.code || \"CREATE_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\n locale,\n tenant,\n index,\n body: plugin.body\n }\n );\n }\n};\n\ninterface CreateIndexParams {\n client: Client;\n plugins: PluginsContainer;\n type: string;\n tenant: string;\n locale: string;\n index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugins, type, locale, onExists } = params;\n const plugin = getLastAddedIndexPlugin<ElasticsearchIndexPlugin>({\n container: plugins,\n type,\n locale\n });\n\n const exists = await indexExists(params);\n if (exists) {\n if (onExists) {\n onExists();\n }\n return;\n }\n\n await indexCreate({\n ...params,\n plugin\n });\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAgBA,MAAMG,WAAW,GAAG,MAAOC,MAAyB,IAAuB;EACvE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAE1C,IAAI;IACA,MAAMI,QAAQ,GAAG,MAAMH,MAAM,CAACI,OAAO,CAACC,MAAM,CAAC;MACzCJ,KAAK;MACLK,kBAAkB,EAAE,KAAK;MACzBC,gBAAgB,EAAE,IAAI;MACtBC,gBAAgB,EAAE,IAAI;MACtBC,aAAa,EAAE,KAAK;MACpBC,KAAK,EAAE;IACX,CAAC,CAAC;IACF,IAAI,CAACP,QAAQ,CAACQ,IAAI,EAAE;MAChB,OAAO,KAAK;IAChB;IACA,IAAIT,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA,OAAO,IAAI;EACf,CAAC,CAAC,OAAOU,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAAC,qCAAqCb,KAAK,WAAW,CAAC;EACxE;EACA,OAAO,KAAK;AAChB,CAAC;AAYD,MAAMc,WAAW,GAAG,MAAOhB,MAAyB,IAAoB;EACpE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEe,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGrB,MAAM;EAEvE,IAAI;IACA,MAAMC,MAAM,CAACI,OAAO,CAACiB,MAAM,CAAC;MACxBpB,KAAK;MACLU,IAAI,EAAE;QACF,GAAGK,MAAM,CAACL;MACd;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,IAAIE,KAAK,GAAGF,EAAE;IACd,IAAIQ,OAAO,EAAE;MACTN,KAAK,GAAGM,OAAO,CAACR,EAAE,CAAC;IACvB;IACA,MAAM,IAAIU,cAAW,CACjBR,KAAK,CAACS,OAAO,IAAI,gDAAgDJ,IAAI,GAAG,EACxEL,KAAK,CAACU,IAAI,IAAI,kCAAkC,EAChD;MACIV,KAAK,EAAE;QACH,GAAGA,KAAK;QACRS,OAAO,EAAET,KAAK,CAACS,OAAO;QACtBC,IAAI,EAAEV,KAAK,CAACU,IAAI;QAChBC,IAAI,EAAEX,KAAK,CAACW;MAChB,CAAC;MACDN,IAAI;MACJD,MAAM;MACND,MAAM;MACNhB,KAAK;MACLU,IAAI,EAAEK,MAAM,CAACL;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAaM,MAAMe,WAAW,GAAG,MAAO3B,MAAyB,IAAoB;EAC3E,MAAM;IAAE4B,OAAO;IAAER,IAAI;IAAED,MAAM;IAAEhB;EAAS,CAAC,GAAGH,MAAM;EAClD,MAAMiB,MAAM,GAAG,IAAAY,gCAAuB,EAA2B;IAC7DC,SAAS,EAAEF,OAAO;IAClBR,IAAI;IACJD;EACJ,CAAC,CAAC;EAEF,MAAMb,MAAM,GAAG,MAAMP,WAAW,CAACC,MAAM,CAAC;EACxC,IAAIM,MAAM,EAAE;IACR,IAAIH,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA;EACJ;EAEA,MAAMa,WAAW,CAAC;IACd,GAAGhB,MAAM;IACTiB;EACJ,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAJ,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","require","UnhealthyClusterError","WebinyError","constructor","maxWaitingTime","message","code","exports"],"sources":["UnhealthyClusterError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class UnhealthyClusterError extends WebinyError {\n public constructor(maxWaitingTime: number) {\n super({\n message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,\n code: \"UNHEALTHY_CLUSTER\"\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,qBAAqB,SAASC,kBAAW,CAAC;EAC5CC,WAAWA,CAACC,cAAsB,EAAE;IACvC,KAAK,CAAC;MACFC,OAAO,EAAG,qCAAoCD,cAAe,WAAU;MACvEE,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAN,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","require","UnhealthyClusterError","WebinyError","constructor","maxWaitingTime","message","code","exports"],"sources":["UnhealthyClusterError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class UnhealthyClusterError extends WebinyError {\n public constructor(maxWaitingTime: number) {\n super({\n message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,\n code: \"UNHEALTHY_CLUSTER\"\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,qBAAqB,SAASC,kBAAW,CAAC;EAC5CC,WAAWA,CAACC,cAAsB,EAAE;IACvC,KAAK,CAAC;MACFC,OAAO,EAAE,qCAAqCD,cAAc,WAAW;MACvEE,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAN,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchCatHealth","require","_ElasticsearchCatNodes","_types","_UnhealthyClusterError","_reason","_WaitingHealthyClusterAbortedError","WAITING_TIME_STEP","WaitUntilHealthy","aborted","constructor","client","options","catHealth","ElasticsearchCatHealth","catNodes","ElasticsearchCatNodes","abort","wait","WaitingHealthyClusterAbortedError","startedAt","Date","mustEndAt","getTime","maxWaitingTime","waitingTimeStep","runs","waitingReason","shouldWait","onTimeout","UnhealthyClusterError","onUnhealthy","Promise","resolve","setTimeout","runningTime","health","nodes","getHealth","ex","createClusterHealthStatusReason","description","message","minimum","minClusterHealthStatus","current","ElasticsearchCatClusterHealthStatus","Red","getNodes","clusterHealthStatus","transformClusterHealthStatus","status","processorPercent","getProcessorPercent","maxProcessorPercent","createProcessorReason","maximum","maxRamPercent","undefined","ramPercent","getRamPercent","createMemoryReason","total","reduce","node","parseFloat","cpu","length","Green","Yellow","createWaitUntilHealthy","params","exports"],"sources":["WaitUntilHealthy.ts"],"sourcesContent":["import { Client } from \"~/client\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes\";\nimport {\n ElasticsearchCatClusterHealthStatus,\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError\";\nimport {\n ClusterHealthReason,\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason,\n MemoryReason,\n ProcessorReason\n} from \"./reason\";\nimport { WaitingHealthyClusterAbortedError } from \"./WaitingHealthyClusterAbortedError\";\n\nconst WAITING_TIME_STEP = 10;\n\nexport type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;\n\nexport interface IWaitUntilHealthyParams {\n /**\n * Minimum status allowed, otherwise the cluster is considered unhealthy.\n */\n minClusterHealthStatus:\n | ElasticsearchCatClusterHealthStatus.Green\n | ElasticsearchCatClusterHealthStatus.Yellow;\n /**\n * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxProcessorPercent: number;\n /**\n * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxRamPercent?: number;\n /**\n * Maximum time to wait in seconds.\n * This is to prevent infinite waiting in case the cluster never becomes healthy.\n */\n maxWaitingTime: number;\n /**\n * Time in seconds to wait between each check.\n * This is to prevent spamming the cluster with requests.\n * Default is WAITING_TIME_STEP seconds.\n */\n waitingTimeStep?: number;\n}\n\nexport interface IWaitOptionsOnUnhealthyParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptionsOnTimeoutParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptions {\n onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;\n onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;\n}\n\nexport interface IWaitUntilHealthyWaitResponse {\n runningTime: number;\n runs: number;\n}\n\nclass WaitUntilHealthy {\n private readonly client: Client;\n private readonly options: IWaitUntilHealthyParams;\n\n private readonly catHealth: ElasticsearchCatHealth;\n private readonly catNodes: ElasticsearchCatNodes;\n\n private aborted = false;\n\n public constructor(client: Client, options: IWaitUntilHealthyParams) {\n this.client = client;\n this.options = options;\n\n this.catHealth = new ElasticsearchCatHealth(this.client);\n this.catNodes = new ElasticsearchCatNodes(this.client);\n }\n\n public abort(): void {\n this.aborted = true;\n }\n /**\n * @throws UnhealthyClusterError\n * @throws WaitingHealthyClusterAbortedError\n */\n public async wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse> {\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError(\n `Waiting for the cluster to become healthy was aborted even before it started.`\n );\n }\n const startedAt = new Date();\n const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);\n const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;\n let runs = 1;\n let waitingReason: WaitingReason | false;\n while ((waitingReason = await this.shouldWait())) {\n if (new Date() >= mustEndAt) {\n if (options?.onTimeout) {\n await options.onTimeout({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n throw new UnhealthyClusterError(this.options.maxWaitingTime);\n } else if (options?.onUnhealthy) {\n await options.onUnhealthy({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n /**\n * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.\n */\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError();\n }\n runs++;\n await new Promise(resolve => {\n setTimeout(resolve, waitingTimeStep * 1000);\n });\n }\n\n const runningTime = new Date().getTime() - startedAt.getTime();\n\n return {\n runningTime,\n runs\n };\n }\n\n private async shouldWait(): Promise<WaitingReason | false> {\n let health: IElasticsearchCatHealthResponse;\n let nodes: IElasticsearchCatNodesResponse;\n try {\n health = await this.catHealth.getHealth();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n try {\n nodes = await this.catNodes.getNodes();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n\n const clusterHealthStatus = this.transformClusterHealthStatus(health.status);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: health.status\n });\n }\n\n const processorPercent = this.getProcessorPercent(nodes);\n if (processorPercent > this.options.maxProcessorPercent) {\n return createProcessorReason({\n maximum: this.options.maxProcessorPercent,\n current: processorPercent\n });\n }\n /**\n * Possibly no max ram definition?\n */\n if (this.options.maxRamPercent === undefined) {\n return false;\n }\n\n const ramPercent = this.getRamPercent(nodes);\n if (ramPercent > this.options.maxRamPercent) {\n return createMemoryReason({\n maximum: this.options.maxRamPercent,\n current: ramPercent\n });\n }\n return false;\n }\n\n private getProcessorPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu);\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"]);\n }, 0);\n return total / nodes.length;\n }\n\n private transformClusterHealthStatus(status: ElasticsearchCatClusterHealthStatus): number {\n switch (status) {\n case ElasticsearchCatClusterHealthStatus.Green:\n return 1;\n case ElasticsearchCatClusterHealthStatus.Yellow:\n return 2;\n case ElasticsearchCatClusterHealthStatus.Red:\n return 3;\n default:\n return 99;\n }\n }\n}\n\nexport type { WaitUntilHealthy };\n\nexport const createWaitUntilHealthy = (\n client: Client,\n params: IWaitUntilHealthyParams\n): WaitUntilHealthy => {\n return new WaitUntilHealthy(client, params);\n};\n"],"mappings":";;;;;;AACA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAQA,IAAAK,kCAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAG,EAAE;AA0D5B,MAAMC,gBAAgB,CAAC;EAOXC,OAAO,GAAG,KAAK;EAEhBC,WAAWA,CAACC,MAAc,EAAEC,OAAgC,EAAE;IACjE,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACC,SAAS,GAAG,IAAIC,8CAAsB,CAAC,IAAI,CAACH,MAAM,CAAC;IACxD,IAAI,CAACI,QAAQ,GAAG,IAAIC,4CAAqB,CAAC,IAAI,CAACL,MAAM,CAAC;EAC1D;EAEOM,KAAKA,CAAA,EAAS;IACjB,IAAI,CAACR,OAAO,GAAG,IAAI;EACvB;EACA;AACJ;AACA;AACA;EACI,MAAaS,IAAIA,CAACN,OAAsB,EAA0C;IAC9E,IAAI,IAAI,CAACH,OAAO,EAAE;MACd,MAAM,IAAIU,oEAAiC,CACtC,+EACL,CAAC;IACL;IACA,MAAMC,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,EAAE;IACjB;EACJ;AACJ;AAIO,MAAMuB,sBAAsB,GAAGA,CAClC3D,MAAc,EACd4D,MAA+B,KACZ;EACnB,OAAO,IAAI/D,gBAAgB,CAACG,MAAM,EAAE4D,MAAM,CAAC;AAC/C,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchCatHealth","require","_ElasticsearchCatNodes","_types","_UnhealthyClusterError","_reason","_WaitingHealthyClusterAbortedError","WAITING_TIME_STEP","WaitUntilHealthy","aborted","constructor","client","options","catHealth","ElasticsearchCatHealth","catNodes","ElasticsearchCatNodes","abort","wait","WaitingHealthyClusterAbortedError","startedAt","Date","mustEndAt","getTime","maxWaitingTime","waitingTimeStep","runs","waitingReason","shouldWait","onTimeout","UnhealthyClusterError","onUnhealthy","Promise","resolve","setTimeout","runningTime","health","nodes","getHealth","ex","createClusterHealthStatusReason","description","message","minimum","minClusterHealthStatus","current","ElasticsearchCatClusterHealthStatus","Red","getNodes","clusterHealthStatus","transformClusterHealthStatus","status","processorPercent","getProcessorPercent","maxProcessorPercent","createProcessorReason","maximum","maxRamPercent","undefined","ramPercent","getRamPercent","createMemoryReason","total","reduce","node","parseFloat","cpu","length","Green","Yellow","createWaitUntilHealthy","params","exports"],"sources":["WaitUntilHealthy.ts"],"sourcesContent":["import { Client } from \"~/client\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes\";\nimport {\n ElasticsearchCatClusterHealthStatus,\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError\";\nimport {\n ClusterHealthReason,\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason,\n MemoryReason,\n ProcessorReason\n} from \"./reason\";\nimport { WaitingHealthyClusterAbortedError } from \"./WaitingHealthyClusterAbortedError\";\n\nconst WAITING_TIME_STEP = 10;\n\nexport type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;\n\nexport interface IWaitUntilHealthyParams {\n /**\n * Minimum status allowed, otherwise the cluster is considered unhealthy.\n */\n minClusterHealthStatus:\n | ElasticsearchCatClusterHealthStatus.Green\n | ElasticsearchCatClusterHealthStatus.Yellow;\n /**\n * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxProcessorPercent: number;\n /**\n * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxRamPercent?: number;\n /**\n * Maximum time to wait in seconds.\n * This is to prevent infinite waiting in case the cluster never becomes healthy.\n */\n maxWaitingTime: number;\n /**\n * Time in seconds to wait between each check.\n * This is to prevent spamming the cluster with requests.\n * Default is WAITING_TIME_STEP seconds.\n */\n waitingTimeStep?: number;\n}\n\nexport interface IWaitOptionsOnUnhealthyParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptionsOnTimeoutParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptions {\n onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;\n onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;\n}\n\nexport interface IWaitUntilHealthyWaitResponse {\n runningTime: number;\n runs: number;\n}\n\nclass WaitUntilHealthy {\n private readonly client: Client;\n private readonly options: IWaitUntilHealthyParams;\n\n private readonly catHealth: ElasticsearchCatHealth;\n private readonly catNodes: ElasticsearchCatNodes;\n\n private aborted = false;\n\n public constructor(client: Client, options: IWaitUntilHealthyParams) {\n this.client = client;\n this.options = options;\n\n this.catHealth = new ElasticsearchCatHealth(this.client);\n this.catNodes = new ElasticsearchCatNodes(this.client);\n }\n\n public abort(): void {\n this.aborted = true;\n }\n /**\n * @throws UnhealthyClusterError\n * @throws WaitingHealthyClusterAbortedError\n */\n public async wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse> {\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError(\n `Waiting for the cluster to become healthy was aborted even before it started.`\n );\n }\n const startedAt = new Date();\n const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);\n const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;\n let runs = 1;\n let waitingReason: WaitingReason | false;\n while ((waitingReason = await this.shouldWait())) {\n if (new Date() >= mustEndAt) {\n if (options?.onTimeout) {\n await options.onTimeout({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n throw new UnhealthyClusterError(this.options.maxWaitingTime);\n } else if (options?.onUnhealthy) {\n await options.onUnhealthy({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n /**\n * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.\n */\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError();\n }\n runs++;\n await new Promise(resolve => {\n setTimeout(resolve, waitingTimeStep * 1000);\n });\n }\n\n const runningTime = new Date().getTime() - startedAt.getTime();\n\n return {\n runningTime,\n runs\n };\n }\n\n private async shouldWait(): Promise<WaitingReason | false> {\n let health: IElasticsearchCatHealthResponse;\n let nodes: IElasticsearchCatNodesResponse;\n try {\n health = await this.catHealth.getHealth();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n try {\n nodes = await this.catNodes.getNodes();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n\n const clusterHealthStatus = this.transformClusterHealthStatus(health.status);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: health.status\n });\n }\n\n const processorPercent = this.getProcessorPercent(nodes);\n if (processorPercent > this.options.maxProcessorPercent) {\n return createProcessorReason({\n maximum: this.options.maxProcessorPercent,\n current: processorPercent\n });\n }\n /**\n * Possibly no max ram definition?\n */\n if (this.options.maxRamPercent === undefined) {\n return false;\n }\n\n const ramPercent = this.getRamPercent(nodes);\n if (ramPercent > this.options.maxRamPercent) {\n return createMemoryReason({\n maximum: this.options.maxRamPercent,\n current: ramPercent\n });\n }\n return false;\n }\n\n private getProcessorPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu);\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"]);\n }, 0);\n return total / nodes.length;\n }\n\n private transformClusterHealthStatus(status: ElasticsearchCatClusterHealthStatus): number {\n switch (status) {\n case ElasticsearchCatClusterHealthStatus.Green:\n return 1;\n case ElasticsearchCatClusterHealthStatus.Yellow:\n return 2;\n case ElasticsearchCatClusterHealthStatus.Red:\n return 3;\n default:\n return 99;\n }\n }\n}\n\nexport type { WaitUntilHealthy };\n\nexport const createWaitUntilHealthy = (\n client: Client,\n params: IWaitUntilHealthyParams\n): WaitUntilHealthy => {\n return new WaitUntilHealthy(client, params);\n};\n"],"mappings":";;;;;;AACA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAQA,IAAAK,kCAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAG,EAAE;AA0D5B,MAAMC,gBAAgB,CAAC;EAOXC,OAAO,GAAG,KAAK;EAEhBC,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QP,aAAaA,CAACvB,KAAqC,EAAU;IACjE,MAAMyB,KAAK,GAAGzB,KAAK,CAAC0B,MAAM,CAAS,CAACD,KAAK,EAAEE,IAAI,KAAK;MAChD,OAAOF,KAAK,GAAGG,UAAU,CAACD,IAAI,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,CAAC;IACL,OAAOF,KAAK,GAAGzB,KAAK,CAAC8B,MAAM;EAC/B;EAEQjB,4BAA4BA,CAACC,MAA2C,EAAU;IACtF,QAAQA,MAAM;MACV,KAAKL,0CAAmC,CAACsB,KAAK;QAC1C,OAAO,CAAC;MACZ,KAAKtB,0CAAmC,CAACuB,MAAM;QAC3C,OAAO,CAAC;MACZ,KAAKvB,0CAAmC,CAACC,GAAG;QACxC,OAAO,CAAC;MACZ;QACI,OAAO,EAAE;IACjB;EACJ;AACJ;AAIO,MAAMuB,sBAAsB,GAAGA,CAClC3D,MAAc,EACd4D,MAA+B,KACZ;EACnB,OAAO,IAAI/D,gBAAgB,CAACG,MAAM,EAAE4D,MAAM,CAAC;AAC/C,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_error","require","WaitingHealthyClusterAbortedError","WebinyError","constructor","message","code","exports"],"sources":["WaitingHealthyClusterAbortedError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class WaitingHealthyClusterAbortedError extends WebinyError {\n public constructor(message?: string) {\n super({\n message: message || `Waiting for the cluster to become healthy was aborted.`,\n code: \"WAITING_HEALTHY_CLUSTER_ABORTED\"\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,iCAAiC,SAASC,kBAAW,CAAC;EACxDC,WAAWA,CAACC,OAAgB,EAAE;IACjC,KAAK,CAAC;MACFA,OAAO,EAAEA,OAAO,IAAK,wDAAuD;MAC5EC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAL,iCAAA,GAAAA,iCAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","require","WaitingHealthyClusterAbortedError","WebinyError","constructor","message","code","exports"],"sources":["WaitingHealthyClusterAbortedError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class WaitingHealthyClusterAbortedError extends WebinyError {\n public constructor(message?: string) {\n super({\n message: message || `Waiting for the cluster to become healthy was aborted.`,\n code: \"WAITING_HEALTHY_CLUSTER_ABORTED\"\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,iCAAiC,SAASC,kBAAW,CAAC;EACxDC,WAAWA,CAACC,OAAgB,EAAE;IACjC,KAAK,CAAC;MACFA,OAAO,EAAEA,OAAO,IAAI,wDAAwD;MAC5EC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAL,iCAAA,GAAAA,iCAAA","ignoreList":[]}
package/where.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_ElasticsearchFieldPlugin","require","_error","_interopRequireDefault","parseWhereKeyRegExp","RegExp","parseWhereKey","key","match","Error","field","operation","operator","slice","exports","ALL","ElasticsearchFieldPlugin","applyWhere","params","query","where","fields","operators","hasOwnProperty","initialValue","undefined","fieldPlugin","WebinyError","operatorPlugin","path","getPath","basePath","getBasePath","value","toSearchValue","apply","name","keyword"],"sources":["where.ts"],"sourcesContent":["import { ElasticsearchBoolQueryConfig } from \"~/types\";\nimport { ElasticsearchFieldPlugin } from \"~/plugins/definition/ElasticsearchFieldPlugin\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ntype Records<T> = Record<string, T>;\n\nexport interface ApplyWhereParams {\n query: ElasticsearchBoolQueryConfig;\n where: Records<any>;\n fields: Records<ElasticsearchFieldPlugin>;\n operators: Records<ElasticsearchQueryBuilderOperatorPlugin>;\n}\n\nexport interface ParseWhereKeyResult {\n field: string;\n operator: string;\n}\n\n/**\n * TODO remove the wbyAco prefix when we move the user fields to the values property.\n */\nconst parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);\n\nexport const parseWhereKey = (key: string): ParseWhereKeyResult => {\n const match = key.match(parseWhereKeyRegExp);\n\n if (!match) {\n throw new Error(`It is not possible to search by key \"${key}\"`);\n }\n\n const [, field, operation = \"eq\"] = match;\n\n if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {\n throw new Error(`Cannot filter by \"${field}\".`);\n }\n\n const operator = operation.match(/^_/) ? operation.slice(1) : operation;\n\n return { field, operator };\n};\n\nconst ALL = ElasticsearchFieldPlugin.ALL;\n\nexport const applyWhere = (params: ApplyWhereParams): void => {\n const { query, where, fields, operators } = params;\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n const initialValue = where[key];\n /**\n * There is a possibility that undefined is sent as a value, so just skip it.\n */\n if (initialValue === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n const fieldPlugin: ElasticsearchFieldPlugin = fields[field] || fields[ALL];\n if (!fieldPlugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\".`,\n \"PLUGIN_WHERE_ERROR\",\n {\n field\n }\n );\n }\n const operatorPlugin = operators[operator];\n if (!operatorPlugin) {\n throw new WebinyError(\n `Missing plugin for the operator \"${operator}\"`,\n \"PLUGIN_WHERE_ERROR\",\n {\n operator\n }\n );\n }\n\n /**\n * Get the path but in the case of * (all fields, replace * with the field.\n * Custom path would return its own value anyways.\n */\n const path = fieldPlugin.getPath(field);\n const basePath = fieldPlugin.getBasePath(field);\n /**\n * Transform the value for the search.\n */\n const value = fieldPlugin.toSearchValue({\n value: initialValue,\n path,\n basePath\n });\n\n operatorPlugin.apply(query, {\n name: field,\n value,\n path,\n basePath,\n keyword: f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ACJ;IACA,MAAM;MAAEf,KAAK;MAAEE;IAAS,CAAC,GAAGN,aAAa,CAACC,GAAG,CAAC;IAC9C,MAAMmB,WAAqC,GAAGL,MAAM,CAACX,KAAK,CAAC,IAAIW,MAAM,CAACN,GAAG,CAAC;IAC1E,IAAI,CAACW,WAAW,EAAE;MACd,MAAM,IAAIC,cAAW,CAChB,iCAAgCjB,KAAM,IAAG,EAC1C,oBAAoB,EACpB;QACIA;MACJ,CACJ,CAAC;IACL;IACA,MAAMkB,cAAc,GAAGN,SAAS,CAACV,QAAQ,CAAC;IAC1C,IAAI,CAACgB,cAAc,EAAE;MACjB,MAAM,IAAID,cAAW,CAChB,oCAAmCf,QAAS,GAAE,EAC/C,oBAAoB,EACpB;QACIA;MACJ,CACJ,CAAC;IACL;;IAEA;AACR;AACA;AACA;IACQ,MAAMiB,IAAI,GAAGH,WAAW,CAACI,OAAO,CAACpB,KAAK,CAAC;IACvC,MAAMqB,QAAQ,GAAGL,WAAW,CAACM,WAAW,CAACtB,KAAK,CAAC;IAC/C;AACR;AACA;IACQ,MAAMuB,KAAK,GAAGP,WAAW,CAACQ,aAAa,CAAC;MACpCD,KAAK,EAAET,YAAY;MACnBK,IAAI;MACJE;IACJ,CAAC,CAAC;IAEFH,cAAc,CAACO,KAAK,CAAChB,KAAK,EAAE;MACxBiB,IAAI,EAAE1B,KAAK;MACXuB,KAAK;MACLJ,IAAI;MACJE,QAAQ;MACRM,OAAO,EAAEX,WAAW,CAACW;IACzB,CAAC,CAAC;EACN;AACJ,CAAC;AAACvB,OAAA,CAAAG,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ElasticsearchFieldPlugin","require","_error","_interopRequireDefault","parseWhereKeyRegExp","RegExp","parseWhereKey","key","match","Error","field","operation","operator","slice","exports","ALL","ElasticsearchFieldPlugin","applyWhere","params","query","where","fields","operators","hasOwnProperty","initialValue","undefined","fieldPlugin","WebinyError","operatorPlugin","path","getPath","basePath","getBasePath","value","toSearchValue","apply","name","keyword"],"sources":["where.ts"],"sourcesContent":["import { ElasticsearchBoolQueryConfig } from \"~/types\";\nimport { ElasticsearchFieldPlugin } from \"~/plugins/definition/ElasticsearchFieldPlugin\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ntype Records<T> = Record<string, T>;\n\nexport interface ApplyWhereParams {\n query: ElasticsearchBoolQueryConfig;\n where: Records<any>;\n fields: Records<ElasticsearchFieldPlugin>;\n operators: Records<ElasticsearchQueryBuilderOperatorPlugin>;\n}\n\nexport interface ParseWhereKeyResult {\n field: string;\n operator: string;\n}\n\n/**\n * TODO remove the wbyAco prefix when we move the user fields to the values property.\n */\nconst parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);\n\nexport const parseWhereKey = (key: string): ParseWhereKeyResult => {\n const match = key.match(parseWhereKeyRegExp);\n\n if (!match) {\n throw new Error(`It is not possible to search by key \"${key}\"`);\n }\n\n const [, field, operation = \"eq\"] = match;\n\n if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {\n throw new Error(`Cannot filter by \"${field}\".`);\n }\n\n const operator = operation.match(/^_/) ? operation.slice(1) : operation;\n\n return { field, operator };\n};\n\nconst ALL = ElasticsearchFieldPlugin.ALL;\n\nexport const applyWhere = (params: ApplyWhereParams): void => {\n const { query, where, fields, operators } = params;\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n const initialValue = where[key];\n /**\n * There is a possibility that undefined is sent as a value, so just skip it.\n */\n if (initialValue === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n const fieldPlugin: ElasticsearchFieldPlugin = fields[field] || fields[ALL];\n if (!fieldPlugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\".`,\n \"PLUGIN_WHERE_ERROR\",\n {\n field\n }\n );\n }\n const operatorPlugin = operators[operator];\n if (!operatorPlugin) {\n throw new WebinyError(\n `Missing plugin for the operator \"${operator}\"`,\n \"PLUGIN_WHERE_ERROR\",\n {\n operator\n }\n );\n }\n\n /**\n * Get the path but in the case of * (all fields, replace * with the field.\n * Custom path would return its own value anyways.\n */\n const path = fieldPlugin.getPath(field);\n const basePath = fieldPlugin.getBasePath(field);\n /**\n * Transform the value for the search.\n */\n const value = fieldPlugin.toSearchValue({\n value: initialValue,\n path,\n basePath\n });\n\n operatorPlugin.apply(query, {\n name: field,\n value,\n path,\n basePath,\n keyword: fieldPlugin.keyword\n });\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,yBAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAgBA;AACA;AACA;AACA,MAAMG,mBAAmB,GAAG,IAAIC,MAAM,CAAC,+CAA+C,CAAC;AAEhF,MAAMC,aAAa,GAAIC,GAAW,IAA0B;EAC/D,MAAMC,KAAK,GAAGD,GAAG,CAACC,KAAK,CAACJ,mBAAmB,CAAC;EAE5C,IAAI,CAACI,KAAK,EAAE;IACR,MAAM,IAAIC,KAAK,CAAC,wCAAwCF,GAAG,GAAG,CAAC;EACnE;EAEA,MAAM,GAAGG,KAAK,EAAEC,SAAS,GAAG,IAAI,CAAC,GAAGH,KAAK;EAEzC,IAAI,CAACE,KAAK,CAACF,KAAK,CAAC,8BAA8B,CAAC,EAAE;IAC9C,MAAM,IAAIC,KAAK,CAAC,qBAAqBC,KAAK,IAAI,CAAC;EACnD;EAEA,MAAME,QAAQ,GAAGD,SAAS,CAACH,KAAK,CAAC,IAAI,CAAC,GAAGG,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC,GAAGF,SAAS;EAEvE,OAAO;IAAED,KAAK;IAAEE;EAAS,CAAC;AAC9B,CAAC;AAACE,OAAA,CAAAR,aAAA,GAAAA,aAAA;AAEF,MAAMS,GAAG,GAAGC,kDAAwB,CAACD,GAAG;AAEjC,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