@webiny/api-headless-cms-ddb 5.41.1-beta.0 → 5.41.1-beta.2
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.
|
@@ -22,8 +22,8 @@ const sort = params => {
|
|
|
22
22
|
} else if (sort.length === 0) {
|
|
23
23
|
sort.push("savedOn_DESC");
|
|
24
24
|
} else if (sort.length > 1) {
|
|
25
|
-
throw new _error.default("Sorting is limited to a single field.", "SORT_MULTIPLE_FIELDS_ERROR", {
|
|
26
|
-
sort
|
|
25
|
+
throw new _error.default("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
|
|
26
|
+
sort
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
const [firstSort] = sort;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_dotProp","_sortBy","_extractSort","sort","params","model","items","fields","plugins","length","push","WebinyError","firstSort","fieldId","field","valuePath","reverse","extractSort","sortBy","itemsToSort","map","item","id","value","transform","dotProp","get","sortedItems","lodashSortBy","newItems","s","find","i","sortingBy","exports"],"sources":["sort.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy\";\nimport { extractSort } from \"./extractSort\";\nimport { Field } from \"./types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params {\n model: CmsModel;\n items: CmsEntry[];\n sort?: string[];\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = (params: Params): CmsEntry[] => {\n const { model, items, sort = [], fields, plugins } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_dotProp","_sortBy","_extractSort","sort","params","model","items","fields","plugins","length","push","WebinyError","firstSort","fieldId","field","valuePath","reverse","extractSort","sortBy","itemsToSort","map","item","id","value","transform","dotProp","get","sortedItems","lodashSortBy","newItems","s","find","i","sortingBy","exports"],"sources":["sort.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy\";\nimport { extractSort } from \"./extractSort\";\nimport { Field } from \"./types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params {\n model: CmsModel;\n items: CmsEntry[];\n sort?: string[];\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = (params: Params): CmsEntry[] => {\n const { model, items, sort = [], fields, plugins } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field on DynamoDB only system.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort\n }\n );\n }\n const [firstSort] = sort;\n if (!firstSort) {\n throw new WebinyError(\"Empty sort array item.\", \"SORT_EMPTY_ERROR\", {\n sort\n });\n }\n\n const { fieldId, field, valuePath, reverse } = extractSort({\n model,\n sortBy: firstSort,\n fields,\n plugins\n });\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.transform(dotProp.get(item, valuePath))\n };\n });\n const sortedItems: SortedItem[] = lodashSortBy(itemsToSort, \"value\");\n const newItems = sortedItems.map(s => {\n const item = items.find(i => i.id === s.id);\n if (item) {\n return item;\n }\n throw new WebinyError(\n \"Could not find item by given id after the sorting.\",\n \"SORTING_ITEMS_ERROR\",\n {\n id: s.id,\n sortingB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CAACC,GAAG,CAACL,IAAI,EAAEN,SAAS,CAAC;IACvD,CAAC;EACL,CAAC,CAAC;EACF,MAAMY,WAAyB,GAAG,IAAAC,eAAY,EAACT,WAAW,EAAE,OAAO,CAAC;EACpE,MAAMU,QAAQ,GAAGF,WAAW,CAACP,GAAG,CAACU,CAAC,IAAI;IAClC,MAAMT,IAAI,GAAGf,KAAK,CAACyB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACV,EAAE,KAAKQ,CAAC,CAACR,EAAE,CAAC;IAC3C,IAAID,IAAI,EAAE;MACN,OAAOA,IAAI;IACf;IACA,MAAM,IAAIV,cAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIW,EAAE,EAAEQ,CAAC,CAACR,EAAE;MACRW,SAAS,EAAEpB,OAAO;MAClBG;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOa,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACb,OAAO,CAAC,CAAC;AAC7B,CAAC;AAACkB,OAAA,CAAA/B,IAAA,GAAAA,IAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "5.41.1-beta.
|
|
3
|
+
"version": "5.41.1-beta.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "7.24.1",
|
|
26
|
-
"@webiny/api": "5.41.1-beta.
|
|
27
|
-
"@webiny/api-headless-cms": "5.41.1-beta.
|
|
28
|
-
"@webiny/aws-sdk": "5.41.1-beta.
|
|
29
|
-
"@webiny/db-dynamodb": "5.41.1-beta.
|
|
30
|
-
"@webiny/error": "5.41.1-beta.
|
|
31
|
-
"@webiny/handler-db": "5.41.1-beta.
|
|
32
|
-
"@webiny/utils": "5.41.1-beta.
|
|
26
|
+
"@webiny/api": "5.41.1-beta.2",
|
|
27
|
+
"@webiny/api-headless-cms": "5.41.1-beta.2",
|
|
28
|
+
"@webiny/aws-sdk": "5.41.1-beta.2",
|
|
29
|
+
"@webiny/db-dynamodb": "5.41.1-beta.2",
|
|
30
|
+
"@webiny/error": "5.41.1-beta.2",
|
|
31
|
+
"@webiny/handler-db": "5.41.1-beta.2",
|
|
32
|
+
"@webiny/utils": "5.41.1-beta.2",
|
|
33
33
|
"dataloader": "2.2.1",
|
|
34
34
|
"dot-prop": "6.0.1",
|
|
35
35
|
"jsonpack": "1.1.5",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@babel/core": "7.24.3",
|
|
41
41
|
"@babel/preset-env": "7.24.3",
|
|
42
42
|
"@types/jsonpack": "1.1.2",
|
|
43
|
-
"@webiny/cli": "5.41.1-beta.
|
|
44
|
-
"@webiny/plugins": "5.41.1-beta.
|
|
45
|
-
"@webiny/project-utils": "5.41.1-beta.
|
|
43
|
+
"@webiny/cli": "5.41.1-beta.2",
|
|
44
|
+
"@webiny/plugins": "5.41.1-beta.2",
|
|
45
|
+
"@webiny/project-utils": "5.41.1-beta.2",
|
|
46
46
|
"jest": "29.7.0",
|
|
47
47
|
"jest-dynalite": "3.6.1",
|
|
48
48
|
"ttypescript": "1.5.15",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"build": "yarn webiny run build",
|
|
57
57
|
"watch": "yarn webiny run watch"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "17dbed5d7696bf87439eabe5540af95103d0e99e"
|
|
60
60
|
}
|