@unchainedshop/core-orders 1.2.1 → 1.2.11
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SortDirection } from '@unchainedshop/types/api';
|
|
2
|
+
import { generateDbFilterById, buildSortOptions } from '@unchainedshop/utils';
|
|
2
3
|
const buildFindSelector = ({ includeCarts, status, userId, queryString }) => {
|
|
3
4
|
const selector = {};
|
|
4
5
|
if (userId) {
|
|
@@ -26,13 +27,12 @@ export const configureOrdersModuleQueries = ({ Orders, }) => {
|
|
|
26
27
|
const selector = orderId ? generateDbFilterById(orderId) : { orderNumber };
|
|
27
28
|
return Orders.findOne(selector, options);
|
|
28
29
|
},
|
|
29
|
-
findOrders: async ({ limit, offset, queryString, ...query }, options) => {
|
|
30
|
+
findOrders: async ({ limit, offset, queryString, sort, ...query }, options) => {
|
|
31
|
+
const defaultSortOption = [{ key: 'created', value: SortDirection.DESC }];
|
|
30
32
|
const findOptions = {
|
|
31
33
|
skip: offset,
|
|
32
34
|
limit,
|
|
33
|
-
sort:
|
|
34
|
-
created: -1,
|
|
35
|
-
},
|
|
35
|
+
sort: buildSortOptions(sort || defaultSortOption),
|
|
36
36
|
};
|
|
37
37
|
const selector = buildFindSelector({ queryString, ...query });
|
|
38
38
|
if (queryString) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureOrdersModule-queries.js","sourceRoot":"","sources":["../../src/module/configureOrdersModule-queries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configureOrdersModule-queries.js","sourceRoot":"","sources":["../../src/module/configureOrdersModule-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,MAAM,iBAAiB,GAAG,CAAC,EA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EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7F,MAAM,WAAW,GAAgB;gBAC/B,IAAI,EAAE,MAAM;gBACZ,KAAK;gBACL,IAAI,EAAE,gBAAgB,CAAC,IAAI,IAAI,iBAAiB,CAAC;aAClD,CAAC;YACF,MAAM,QAAQ,GAAG,iBAAiB,CAAC,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YAE9D,IAAI,WAAW,EAAE;gBACf,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAC3B,GAAG,OAAO;oBACV,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;oBAC7C,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;iBACxC,CAAC,CAAC,OAAO,EAAE,CAAC;aACd;YAED,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC;QACtD,CAAC;QAED,WAAW,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YACjC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE;gBAC5E,KAAK,EAAE,CAAC;aACT,CAAC,CAAC;YACH,OAAO,CAAC,CAAC,UAAU,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-orders",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"main": "lib/orders-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/orders-index.js",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"types": "lib/orders-index.d.ts",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"prepublishOnly": "npm install && npm run build || :",
|
|
13
12
|
"clean": "rm -rf lib",
|
|
14
13
|
"build": "npm run clean && tsc",
|
|
15
14
|
"watch": "tsc -w",
|
|
@@ -31,14 +30,14 @@
|
|
|
31
30
|
},
|
|
32
31
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@unchainedshop/events": "
|
|
35
|
-
"@unchainedshop/logger": "
|
|
36
|
-
"@unchainedshop/utils": "
|
|
33
|
+
"@unchainedshop/events": "1.x",
|
|
34
|
+
"@unchainedshop/logger": "1.x",
|
|
35
|
+
"@unchainedshop/utils": "1.x",
|
|
37
36
|
"simpl-schema": "^1.12.2"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
39
|
"@types/node": "^16.11.44",
|
|
41
|
-
"@unchainedshop/types": "
|
|
40
|
+
"@unchainedshop/types": "1.x",
|
|
42
41
|
"jest": "^28.1.2",
|
|
43
42
|
"ts-jest": "^28.0.5",
|
|
44
43
|
"typescript": "^4.7.4"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { SortDirection, SortOption } from '@unchainedshop/types/api';
|
|
1
2
|
import { Collection, FindOptions, Query } from '@unchainedshop/types/common';
|
|
2
3
|
import { Order, OrderQueries, OrderQuery } from '@unchainedshop/types/orders';
|
|
3
|
-
import { generateDbFilterById } from '@unchainedshop/utils';
|
|
4
|
+
import { generateDbFilterById, buildSortOptions } from '@unchainedshop/utils';
|
|
4
5
|
|
|
5
6
|
const buildFindSelector = ({ includeCarts, status, userId, queryString }: OrderQuery) => {
|
|
6
7
|
const selector: Query = {};
|
|
@@ -40,13 +41,12 @@ export const configureOrdersModuleQueries = ({
|
|
|
40
41
|
return Orders.findOne(selector, options);
|
|
41
42
|
},
|
|
42
43
|
|
|
43
|
-
findOrders: async ({ limit, offset, queryString, ...query }, options) => {
|
|
44
|
+
findOrders: async ({ limit, offset, queryString, sort, ...query }, options) => {
|
|
45
|
+
const defaultSortOption: Array<SortOption> = [{ key: 'created', value: SortDirection.DESC }];
|
|
44
46
|
const findOptions: FindOptions = {
|
|
45
47
|
skip: offset,
|
|
46
48
|
limit,
|
|
47
|
-
sort:
|
|
48
|
-
created: -1,
|
|
49
|
-
},
|
|
49
|
+
sort: buildSortOptions(sort || defaultSortOption),
|
|
50
50
|
};
|
|
51
51
|
const selector = buildFindSelector({ queryString, ...query });
|
|
52
52
|
|