@blaze-cms/plugin-media-ui 0.140.0 → 0.140.1-alpha.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/CHANGELOG.md +11 -0
- package/lib/components/FileList/useGetFiles/getFiles.js +2 -1
- package/lib/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/lib-es/components/FileList/useGetFiles/getFiles.js +2 -1
- package/lib-es/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/package.json +2 -2
- package/src/components/FileList/useGetFiles/getFiles.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.140.1-alpha.0](https://github.com/thebyte9/blaze/compare/v0.140.0...v0.140.1-alpha.0) (2024-03-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* media search by filename ([#4280](https://github.com/thebyte9/blaze/issues/4280)) ([3a52a49](https://github.com/thebyte9/blaze/commit/3a52a49e390db06ac13ec20a895d9684ece83a78))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.140.0](https://github.com/thebyte9/blaze/compare/v0.140.0-alpha.0...v0.140.0) (2024-03-01)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @blaze-cms/plugin-media-ui
|
|
@@ -46,7 +46,8 @@ var getFromSearch = /*#__PURE__*/function () {
|
|
|
46
46
|
mustMatch.push({
|
|
47
47
|
simple_query_string: {
|
|
48
48
|
query: "".concat(searchTerm, "*"),
|
|
49
|
-
|
|
49
|
+
analyze_wildcard: true,
|
|
50
|
+
fields: ['name', 'filename', 'data.altText', 'data.caption', 'data.title', 'data.credits']
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFiles.js","names":["_adminUiUtils","require","_constants","getFromSearch","_ref2","_asyncToGenerator2","_regenerator","mark","_callee","_ref","searchTerm","offset","limit","where","client","_ref$fileStores","fileStores","allTypesMatches","matchSpecificType","match","mustMatch","storeKeys","_yield$client$query","_yield$client$query$d","files","all","image","video","text","wrap","_callee$","_context","prev","next","type","ALL","push","simple_query_string","query","concat","fields","INVALID_STORE_KEY_VALUES","includes","storeKey","apply","_toConsumableArray2","map","_ref3","key","bool","should","minimum_should_match","getQuery","fetchPolicy","variables","sort","rawQuery","must","rawQueryAllResults","rawQueryImages","rawQueryVideos","rawQueryDocs","sent","data","results","abrupt","stop","_x","arguments","getFiles","_ref4","_default","exports"],"sources":["../../../../src/components/FileList/useGetFiles/getFiles.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ALL, INVALID_STORE_KEY_VALUES } from '../../../constants';\n\nconst getFromSearch = async ({ searchTerm, offset, limit, where, client, fileStores = [] }) => {\n const allTypesMatches = [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ];\n const matchSpecificType = [\n {\n match: { type: where.type }\n }\n ];\n const match = !where.type || where.type === ALL ? allTypesMatches : matchSpecificType;\n const mustMatch = [];\n\n if (searchTerm) {\n mustMatch.push({\n simple_query_string: {\n query: `${searchTerm}*`,\n fields: []\n }\n });\n }\n\n const storeKeys = [];\n if (INVALID_STORE_KEY_VALUES.includes(where.storeKey)) {\n storeKeys.push(...fileStores.map(({ key }) => key));\n } else if (where.storeKey) {\n storeKeys.push(where.storeKey);\n }\n\n mustMatch.push({\n bool: {\n should: storeKeys.map(storeKey => ({\n match: { storeKey }\n })),\n minimum_should_match: 1\n }\n });\n\n const {\n data: {\n files: { results: files },\n all,\n image,\n video,\n text\n }\n } = await client.query({\n query: getQuery('SEARCH_ADMIN_MEDIA'),\n fetchPolicy: 'network-only',\n variables: {\n offset,\n limit,\n sort: searchTerm ? null : 'updated:desc',\n rawQuery: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: match\n }\n }\n ]\n }\n }\n },\n rawQueryAllResults: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryImages: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryVideos: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'video' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryDocs: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n }\n }\n });\n\n return { files, all, image, video, text };\n};\n\nconst getFiles = ({ offset, limit, where, searchTerm, fileStores }, client) =>\n getFromSearch({ searchTerm, offset, limit, where, client, fileStores });\n\nexport default getFiles;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAME,aAAa;EAAA,IAAAC,KAAA,OAAAC,kBAAA,2BAAAC,YAAA,YAAAC,IAAA,CAAG,SAAAC,QAAAC,IAAA;IAAA,IAAAC,UAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,eAAA,EAAAC,UAAA,EAAAC,eAAA,EAAAC,iBAAA,EAAAC,KAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,mBAAA,EAAAC,qBAAA,EAAAC,KAAA,EAAAC,GAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,IAAA;IAAA,OAAAtB,YAAA,YAAAuB,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAASvB,UAAU,GAAAD,IAAA,CAAVC,UAAU,EAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM,EAAEC,KAAK,GAAAH,IAAA,CAALG,KAAK,EAAEC,KAAK,GAAAJ,IAAA,CAALI,KAAK,EAAEC,MAAM,GAAAL,IAAA,CAANK,MAAM,EAAAC,eAAA,GAAAN,IAAA,CAAEO,UAAU,EAAVA,UAAU,GAAAD,eAAA,cAAG,EAAE,GAAAA,eAAA;UAChFE,eAAe,GAAG,CACtB;YACEE,KAAK,EAAE;cAAEe,IAAI,EAAE;YAAQ;UACzB,CAAC,EACD;YACEf,KAAK,EAAE;cAAEe,IAAI,EAAE;YAAQ;UACzB,CAAC,EACD;YACEf,KAAK,EAAE;cAAEe,IAAI,EAAE;YAAO;UACxB,CAAC,CACF;UACKhB,iBAAiB,GAAG,CACxB;YACEC,KAAK,EAAE;cAAEe,IAAI,EAAErB,KAAK,CAACqB;YAAK;UAC5B,CAAC,CACF;UACKf,KAAK,GAAG,CAACN,KAAK,CAACqB,IAAI,IAAIrB,KAAK,CAACqB,IAAI,KAAKC,cAAG,GAAGlB,eAAe,GAAGC,iBAAiB;UAC/EE,SAAS,GAAG,EAAE;UAEpB,IAAIV,UAAU,EAAE;YACdU,SAAS,CAACgB,IAAI,CAAC;cACbC,mBAAmB,EAAE;gBACnBC,KAAK,KAAAC,MAAA,CAAK7B,UAAU,MAAG;gBACvB8B,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"getFiles.js","names":["_adminUiUtils","require","_constants","getFromSearch","_ref2","_asyncToGenerator2","_regenerator","mark","_callee","_ref","searchTerm","offset","limit","where","client","_ref$fileStores","fileStores","allTypesMatches","matchSpecificType","match","mustMatch","storeKeys","_yield$client$query","_yield$client$query$d","files","all","image","video","text","wrap","_callee$","_context","prev","next","type","ALL","push","simple_query_string","query","concat","analyze_wildcard","fields","INVALID_STORE_KEY_VALUES","includes","storeKey","apply","_toConsumableArray2","map","_ref3","key","bool","should","minimum_should_match","getQuery","fetchPolicy","variables","sort","rawQuery","must","rawQueryAllResults","rawQueryImages","rawQueryVideos","rawQueryDocs","sent","data","results","abrupt","stop","_x","arguments","getFiles","_ref4","_default","exports"],"sources":["../../../../src/components/FileList/useGetFiles/getFiles.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ALL, INVALID_STORE_KEY_VALUES } from '../../../constants';\n\nconst getFromSearch = async ({ searchTerm, offset, limit, where, client, fileStores = [] }) => {\n const allTypesMatches = [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ];\n const matchSpecificType = [\n {\n match: { type: where.type }\n }\n ];\n const match = !where.type || where.type === ALL ? allTypesMatches : matchSpecificType;\n const mustMatch = [];\n\n if (searchTerm) {\n mustMatch.push({\n simple_query_string: {\n query: `${searchTerm}*`,\n analyze_wildcard: true,\n fields: ['name', 'filename', 'data.altText', 'data.caption', 'data.title', 'data.credits']\n }\n });\n }\n\n const storeKeys = [];\n if (INVALID_STORE_KEY_VALUES.includes(where.storeKey)) {\n storeKeys.push(...fileStores.map(({ key }) => key));\n } else if (where.storeKey) {\n storeKeys.push(where.storeKey);\n }\n\n mustMatch.push({\n bool: {\n should: storeKeys.map(storeKey => ({\n match: { storeKey }\n })),\n minimum_should_match: 1\n }\n });\n\n const {\n data: {\n files: { results: files },\n all,\n image,\n video,\n text\n }\n } = await client.query({\n query: getQuery('SEARCH_ADMIN_MEDIA'),\n fetchPolicy: 'network-only',\n variables: {\n offset,\n limit,\n sort: searchTerm ? null : 'updated:desc',\n rawQuery: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: match\n }\n }\n ]\n }\n }\n },\n rawQueryAllResults: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryImages: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryVideos: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'video' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryDocs: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n }\n }\n });\n\n return { files, all, image, video, text };\n};\n\nconst getFiles = ({ offset, limit, where, searchTerm, fileStores }, client) =>\n getFromSearch({ searchTerm, offset, limit, where, client, fileStores });\n\nexport default getFiles;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAME,aAAa;EAAA,IAAAC,KAAA,OAAAC,kBAAA,2BAAAC,YAAA,YAAAC,IAAA,CAAG,SAAAC,QAAAC,IAAA;IAAA,IAAAC,UAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,eAAA,EAAAC,UAAA,EAAAC,eAAA,EAAAC,iBAAA,EAAAC,KAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,mBAAA,EAAAC,qBAAA,EAAAC,KAAA,EAAAC,GAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,IAAA;IAAA,OAAAtB,YAAA,YAAAuB,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAASvB,UAAU,GAAAD,IAAA,CAAVC,UAAU,EAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM,EAAEC,KAAK,GAAAH,IAAA,CAALG,KAAK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AAJA;UAAK,CAAC;QAAA;QAAA;UAAA,OAAAG,QAAA,CAAAoC,IAAA;MAAA;IAAA,GAAA3D,OAAA;EAAA,CAC1C;EAAA,gBA7JKL,aAAaA,CAAAiE,EAAA;IAAA,OAAAhE,KAAA,CAAAyC,KAAA,OAAAwB,SAAA;EAAA;AAAA,GA6JlB;AAED,IAAMC,QAAQ,GAAG,SAAXA,QAAQA,CAAAC,KAAA,EAAsDzD,MAAM;EAAA,IAAtDH,MAAM,GAAA4D,KAAA,CAAN5D,MAAM;IAAEC,KAAK,GAAA2D,KAAA,CAAL3D,KAAK;IAAEC,KAAK,GAAA0D,KAAA,CAAL1D,KAAK;IAAEH,UAAU,GAAA6D,KAAA,CAAV7D,UAAU;IAAEM,UAAU,GAAAuD,KAAA,CAAVvD,UAAU;EAAA,OAC9Db,aAAa,CAAC;IAAEO,UAAU,EAAVA,UAAU;IAAEC,MAAM,EAANA,MAAM;IAAEC,KAAK,EAALA,KAAK;IAAEC,KAAK,EAALA,KAAK;IAAEC,MAAM,EAANA,MAAM;IAAEE,UAAU,EAAVA;EAAW,CAAC,CAAC;AAAA;AAAC,IAAAwD,QAAA,GAAAC,OAAA,cAE3DH,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFiles.js","names":["getQuery","ALL","INVALID_STORE_KEY_VALUES","getFromSearch","searchTerm","offset","limit","where","client","fileStores","allTypesMatches","match","type","matchSpecificType","mustMatch","push","simple_query_string","query","fields","storeKeys","includes","storeKey","map","key","bool","should","minimum_should_match","data","files","results","all","image","video","text","fetchPolicy","variables","sort","rawQuery","must","rawQueryAllResults","rawQueryImages","rawQueryVideos","rawQueryDocs","getFiles"],"sources":["../../../../src/components/FileList/useGetFiles/getFiles.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ALL, INVALID_STORE_KEY_VALUES } from '../../../constants';\n\nconst getFromSearch = async ({ searchTerm, offset, limit, where, client, fileStores = [] }) => {\n const allTypesMatches = [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ];\n const matchSpecificType = [\n {\n match: { type: where.type }\n }\n ];\n const match = !where.type || where.type === ALL ? allTypesMatches : matchSpecificType;\n const mustMatch = [];\n\n if (searchTerm) {\n mustMatch.push({\n simple_query_string: {\n query: `${searchTerm}*`,\n fields: []\n }\n });\n }\n\n const storeKeys = [];\n if (INVALID_STORE_KEY_VALUES.includes(where.storeKey)) {\n storeKeys.push(...fileStores.map(({ key }) => key));\n } else if (where.storeKey) {\n storeKeys.push(where.storeKey);\n }\n\n mustMatch.push({\n bool: {\n should: storeKeys.map(storeKey => ({\n match: { storeKey }\n })),\n minimum_should_match: 1\n }\n });\n\n const {\n data: {\n files: { results: files },\n all,\n image,\n video,\n text\n }\n } = await client.query({\n query: getQuery('SEARCH_ADMIN_MEDIA'),\n fetchPolicy: 'network-only',\n variables: {\n offset,\n limit,\n sort: searchTerm ? null : 'updated:desc',\n rawQuery: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: match\n }\n }\n ]\n }\n }\n },\n rawQueryAllResults: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryImages: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryVideos: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'video' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryDocs: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n }\n }\n });\n\n return { files, all, image, video, text };\n};\n\nconst getFiles = ({ offset, limit, where, searchTerm, fileStores }, client) =>\n getFromSearch({ searchTerm, offset, limit, where, client, fileStores });\n\nexport default getFiles;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,GAAG,EAAEC,wBAAwB,QAAQ,oBAAoB;AAElE,MAAMC,aAAa,GAAG,MAAAA,CAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,KAAK;EAAEC,MAAM;EAAEC,UAAU,GAAG;AAAG,CAAC,KAAK;EAC7F,MAAMC,eAAe,GAAG,CACtB;IACEC,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAQ;EACzB,CAAC,EACD;IACED,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAQ;EACzB,CAAC,EACD;IACED,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAO;EACxB,CAAC,CACF;EACD,MAAMC,iBAAiB,GAAG,CACxB;IACEF,KAAK,EAAE;MAAEC,IAAI,EAAEL,KAAK,CAACK;IAAK;EAC5B,CAAC,CACF;EACD,MAAMD,KAAK,GAAG,CAACJ,KAAK,CAACK,IAAI,IAAIL,KAAK,CAACK,IAAI,KAAKX,GAAG,GAAGS,eAAe,GAAGG,iBAAiB;EACrF,MAAMC,SAAS,GAAG,EAAE;EAEpB,IAAIV,UAAU,EAAE;IACdU,SAAS,CAACC,IAAI,CAAC;MACbC,mBAAmB,EAAE;QACnBC,KAAK,EAAG,GAAEb,UAAW,GAAE;QACvBc,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"getFiles.js","names":["getQuery","ALL","INVALID_STORE_KEY_VALUES","getFromSearch","searchTerm","offset","limit","where","client","fileStores","allTypesMatches","match","type","matchSpecificType","mustMatch","push","simple_query_string","query","analyze_wildcard","fields","storeKeys","includes","storeKey","map","key","bool","should","minimum_should_match","data","files","results","all","image","video","text","fetchPolicy","variables","sort","rawQuery","must","rawQueryAllResults","rawQueryImages","rawQueryVideos","rawQueryDocs","getFiles"],"sources":["../../../../src/components/FileList/useGetFiles/getFiles.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ALL, INVALID_STORE_KEY_VALUES } from '../../../constants';\n\nconst getFromSearch = async ({ searchTerm, offset, limit, where, client, fileStores = [] }) => {\n const allTypesMatches = [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ];\n const matchSpecificType = [\n {\n match: { type: where.type }\n }\n ];\n const match = !where.type || where.type === ALL ? allTypesMatches : matchSpecificType;\n const mustMatch = [];\n\n if (searchTerm) {\n mustMatch.push({\n simple_query_string: {\n query: `${searchTerm}*`,\n analyze_wildcard: true,\n fields: ['name', 'filename', 'data.altText', 'data.caption', 'data.title', 'data.credits']\n }\n });\n }\n\n const storeKeys = [];\n if (INVALID_STORE_KEY_VALUES.includes(where.storeKey)) {\n storeKeys.push(...fileStores.map(({ key }) => key));\n } else if (where.storeKey) {\n storeKeys.push(where.storeKey);\n }\n\n mustMatch.push({\n bool: {\n should: storeKeys.map(storeKey => ({\n match: { storeKey }\n })),\n minimum_should_match: 1\n }\n });\n\n const {\n data: {\n files: { results: files },\n all,\n image,\n video,\n text\n }\n } = await client.query({\n query: getQuery('SEARCH_ADMIN_MEDIA'),\n fetchPolicy: 'network-only',\n variables: {\n offset,\n limit,\n sort: searchTerm ? null : 'updated:desc',\n rawQuery: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: match\n }\n }\n ]\n }\n }\n },\n rawQueryAllResults: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryImages: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryVideos: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'video' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryDocs: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n }\n }\n });\n\n return { files, all, image, video, text };\n};\n\nconst getFiles = ({ offset, limit, where, searchTerm, fileStores }, client) =>\n getFromSearch({ searchTerm, offset, limit, where, client, fileStores });\n\nexport default getFiles;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,GAAG,EAAEC,wBAAwB,QAAQ,oBAAoB;AAElE,MAAMC,aAAa,GAAG,MAAAA,CAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,KAAK;EAAEC,MAAM;EAAEC,UAAU,GAAG;AAAG,CAAC,KAAK;EAC7F,MAAMC,eAAe,GAAG,CACtB;IACEC,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAQ;EACzB,CAAC,EACD;IACED,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAQ;EACzB,CAAC,EACD;IACED,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAO;EACxB,CAAC,CACF;EACD,MAAMC,iBAAiB,GAAG,CACxB;IACEF,KAAK,EAAE;MAAEC,IAAI,EAAEL,KAAK,CAACK;IAAK;EAC5B,CAAC,CACF;EACD,MAAMD,KAAK,GAAG,CAACJ,KAAK,CAACK,IAAI,IAAIL,KAAK,CAACK,IAAI,KAAKX,GAAG,GAAGS,eAAe,GAAGG,iBAAiB;EACrF,MAAMC,SAAS,GAAG,EAAE;EAEpB,IAAIV,UAAU,EAAE;IACdU,SAAS,CAACC,IAAI,CAAC;MACbC,mBAAmB,EAAE;QACnBC,KAAK,EAAG,GAAEb,UAAW,GAAE;QACvBc,gBAAgB,EAAE,IAAI;QACtBC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE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EL,aAAa,CAAC;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAW,CAAC,CAAC;AAEzE,eAAemC,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-media-ui",
|
|
3
|
-
"version": "0.140.0",
|
|
3
|
+
"version": "0.140.1-alpha.0",
|
|
4
4
|
"description": "Blaze plugin media ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"lib/*",
|
|
58
58
|
"lib-es/*"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "fc6283e44f209a08f51cfa34323a50fba5ccc841"
|
|
61
61
|
}
|
|
@@ -25,7 +25,8 @@ const getFromSearch = async ({ searchTerm, offset, limit, where, client, fileSto
|
|
|
25
25
|
mustMatch.push({
|
|
26
26
|
simple_query_string: {
|
|
27
27
|
query: `${searchTerm}*`,
|
|
28
|
-
|
|
28
|
+
analyze_wildcard: true,
|
|
29
|
+
fields: ['name', 'filename', 'data.altText', 'data.caption', 'data.title', 'data.credits']
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
32
|
}
|