@drawbridge/drawbridge-utils 0.0.39 → 0.0.40
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/dist/orders.cjs +58 -0
- package/dist/orders.d.cts +36 -0
- package/dist/orders.d.ts +36 -0
- package/dist/orders.js +34 -0
- package/package.json +6 -1
package/dist/orders.cjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// orders.js
|
|
20
|
+
var orders_exports = {};
|
|
21
|
+
__export(orders_exports, {
|
|
22
|
+
byCurrency: () => byCurrency
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(orders_exports);
|
|
25
|
+
var byCurrency = ({ organization, period, onlyUnbilled = false } = {}) => {
|
|
26
|
+
const match = {
|
|
27
|
+
organization,
|
|
28
|
+
time: {
|
|
29
|
+
$gte: period.start,
|
|
30
|
+
$lt: period.end
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if (onlyUnbilled) {
|
|
34
|
+
match.billed = { $exists: false };
|
|
35
|
+
}
|
|
36
|
+
return [
|
|
37
|
+
{ $match: match },
|
|
38
|
+
{
|
|
39
|
+
$group: {
|
|
40
|
+
_id: "$currency",
|
|
41
|
+
gross: { $sum: "$gross" },
|
|
42
|
+
ids: { $push: "$id" }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
$project: {
|
|
47
|
+
_id: 0,
|
|
48
|
+
currency: "$_id",
|
|
49
|
+
gross: 1,
|
|
50
|
+
ids: 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
byCurrency
|
|
58
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const byCurrency = ({ organization, period, onlyUnbilled = false } = {}) => {
|
|
2
|
+
|
|
3
|
+
const match = {
|
|
4
|
+
organization,
|
|
5
|
+
time : {
|
|
6
|
+
$gte : period.start,
|
|
7
|
+
$lt : period.end
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
if( onlyUnbilled ){
|
|
12
|
+
match.billed = { $exists : false };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return [
|
|
16
|
+
{ $match : match },
|
|
17
|
+
{
|
|
18
|
+
$group : {
|
|
19
|
+
_id : '$currency',
|
|
20
|
+
gross : { $sum : '$gross' },
|
|
21
|
+
ids : { $push : '$id' }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
$project : {
|
|
26
|
+
_id : 0,
|
|
27
|
+
currency : '$_id',
|
|
28
|
+
gross : 1,
|
|
29
|
+
ids : 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { byCurrency };
|
package/dist/orders.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const byCurrency = ({ organization, period, onlyUnbilled = false } = {}) => {
|
|
2
|
+
|
|
3
|
+
const match = {
|
|
4
|
+
organization,
|
|
5
|
+
time : {
|
|
6
|
+
$gte : period.start,
|
|
7
|
+
$lt : period.end
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
if( onlyUnbilled ){
|
|
12
|
+
match.billed = { $exists : false };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return [
|
|
16
|
+
{ $match : match },
|
|
17
|
+
{
|
|
18
|
+
$group : {
|
|
19
|
+
_id : '$currency',
|
|
20
|
+
gross : { $sum : '$gross' },
|
|
21
|
+
ids : { $push : '$id' }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
$project : {
|
|
26
|
+
_id : 0,
|
|
27
|
+
currency : '$_id',
|
|
28
|
+
gross : 1,
|
|
29
|
+
ids : 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { byCurrency };
|
package/dist/orders.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// orders.js
|
|
2
|
+
var byCurrency = ({ organization, period, onlyUnbilled = false } = {}) => {
|
|
3
|
+
const match = {
|
|
4
|
+
organization,
|
|
5
|
+
time: {
|
|
6
|
+
$gte: period.start,
|
|
7
|
+
$lt: period.end
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
if (onlyUnbilled) {
|
|
11
|
+
match.billed = { $exists: false };
|
|
12
|
+
}
|
|
13
|
+
return [
|
|
14
|
+
{ $match: match },
|
|
15
|
+
{
|
|
16
|
+
$group: {
|
|
17
|
+
_id: "$currency",
|
|
18
|
+
gross: { $sum: "$gross" },
|
|
19
|
+
ids: { $push: "$id" }
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
$project: {
|
|
24
|
+
_id: 0,
|
|
25
|
+
currency: "$_id",
|
|
26
|
+
gross: 1,
|
|
27
|
+
ids: 1
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
byCurrency
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -48,6 +48,11 @@
|
|
|
48
48
|
"import": "./dist/nanoid.js",
|
|
49
49
|
"require": "./dist/nanoid.cjs"
|
|
50
50
|
},
|
|
51
|
+
"./orders": {
|
|
52
|
+
"types": "./dist/orders.d.ts",
|
|
53
|
+
"import": "./dist/orders.js",
|
|
54
|
+
"require": "./dist/orders.cjs"
|
|
55
|
+
},
|
|
51
56
|
"./redirect": {
|
|
52
57
|
"types": "./dist/redirect.d.ts",
|
|
53
58
|
"import": "./dist/redirect.js",
|
|
@@ -104,5 +109,5 @@
|
|
|
104
109
|
"build": "tsup && npm publish"
|
|
105
110
|
},
|
|
106
111
|
"types": "dist/index.d.ts",
|
|
107
|
-
"version": "0.0.
|
|
112
|
+
"version": "0.0.40"
|
|
108
113
|
}
|