@commercelayer/cli-plugin-metrics 1.0.0 → 1.0.1
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/README.md +209 -1
- package/lib/commands/metrics/fbt.d.ts +1 -1
- package/lib/commands/metrics/fbt.js +3 -3
- package/lib/common.d.ts +1 -1
- package/oclif.manifest.json +2 -2
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1 +1,209 @@
|
|
|
1
|
-
# commercelayer
|
|
1
|
+
# @commercelayer/cli-plugin-metrics
|
|
2
|
+
|
|
3
|
+
Commerce Layer CLI Metrics plugin
|
|
4
|
+
|
|
5
|
+
[](https://oclif.io)
|
|
6
|
+
[](https://npmjs.org/package/@commercelayer/cli-plugin-metrics)
|
|
7
|
+
[](https://npmjs.org/package/@commercelayer/cli-plugin-metrics)
|
|
8
|
+
[](https://github.com/@commercelayer/cli-plugin-metrics/blob/master/package.json)
|
|
9
|
+
|
|
10
|
+
<!-- toc -->
|
|
11
|
+
|
|
12
|
+
* [Usage](#usage)
|
|
13
|
+
* [Commands](#commands)
|
|
14
|
+
<!-- tocstop -->
|
|
15
|
+
## Usage
|
|
16
|
+
<!-- usage -->
|
|
17
|
+
|
|
18
|
+
```sh-session
|
|
19
|
+
commercelayer COMMAND
|
|
20
|
+
|
|
21
|
+
commercelayer [COMMAND] (--help | -h) for detailed information about plugin commands.
|
|
22
|
+
```
|
|
23
|
+
<!-- usagestop -->
|
|
24
|
+
## Commands
|
|
25
|
+
<!-- commands -->
|
|
26
|
+
|
|
27
|
+
* [`commercelayer metrics:breakdown RESOURCE`](#commercelayer-metricsbreakdown-resource)
|
|
28
|
+
* [`commercelayer metrics:date_breakdown RESOURCE`](#commercelayer-metricsdate_breakdown-resource)
|
|
29
|
+
* [`commercelayer metrics:fbt`](#commercelayer-metricsfbt)
|
|
30
|
+
* [`commercelayer metrics:search RESOURCE`](#commercelayer-metricssearch-resource)
|
|
31
|
+
* [`commercelayer metrics:stats RESOURCE`](#commercelayer-metricsstats-resource)
|
|
32
|
+
|
|
33
|
+
### `commercelayer metrics:breakdown RESOURCE`
|
|
34
|
+
|
|
35
|
+
Perform a breakdown query on the Metrics API endpoint.
|
|
36
|
+
|
|
37
|
+
```sh-session
|
|
38
|
+
USAGE
|
|
39
|
+
$ commercelayer metrics:breakdown RESOURCE -b <value> -f <value> -O
|
|
40
|
+
avg|cardinality|max|min|percentiles|stats|sum|value_count [-F <value>] [-B <value>] [-c <value>] [-s asc|desc] [-l
|
|
41
|
+
<value>]
|
|
42
|
+
|
|
43
|
+
FLAGS
|
|
44
|
+
-B, --breakdown=<value> the optional nested breakdown
|
|
45
|
+
-F, --filter=<value> the filter to apply to the query in JSON format (enclosed in single quotes)
|
|
46
|
+
-O, --operator=<option> (required) the computing operator
|
|
47
|
+
<options: avg|cardinality|max|min|percentiles|stats|sum|value_count>
|
|
48
|
+
-b, --by=<value> (required) the field you want the results of the query aggragated by
|
|
49
|
+
-c, --condition=<value> an additional constraint to fine-tune the set of records
|
|
50
|
+
-f, --field=<value> (required) the field you want the metrics or statistics computed on
|
|
51
|
+
-l, --limit=<value> the maximum number of records shown in the response
|
|
52
|
+
-s, --sort=<option> the way you want the results of the query to be sorted
|
|
53
|
+
<options: asc|desc>
|
|
54
|
+
|
|
55
|
+
DESCRIPTION
|
|
56
|
+
perform a breakdown query on the Metrics API endpoint
|
|
57
|
+
|
|
58
|
+
ALIASES
|
|
59
|
+
$ commercelayer metrics:break
|
|
60
|
+
$ commercelayer breakdown
|
|
61
|
+
|
|
62
|
+
EXAMPLES
|
|
63
|
+
$ commercelayer metrics:breakdown orders -b order.country_code -f order.id -O value_count -s desc -l 20
|
|
64
|
+
|
|
65
|
+
cl breakdown orders -b order.country_code -f order.id -O value_count -s desc -l 20 -B '{"by": "line_items.name","field": "line_items.id","operator": "value_count","sort": "desc","limit": 20}'
|
|
66
|
+
|
|
67
|
+
FLAG DESCRIPTIONS
|
|
68
|
+
-B, --breakdown=<value> the optional nested breakdown
|
|
69
|
+
|
|
70
|
+
a JSON object (enclosed in single quotes) containing the nested breakdown
|
|
71
|
+
|
|
72
|
+
-O, --operator=avg|cardinality|max|min|percentiles|stats|sum|value_count the computing operator
|
|
73
|
+
|
|
74
|
+
the list of valid operators depends on the value of the field key
|
|
75
|
+
|
|
76
|
+
-c, --condition=<value> an additional constraint to fine-tune the set of records
|
|
77
|
+
|
|
78
|
+
the condition is applied to the computed results of the query and it is available for operators that return single
|
|
79
|
+
numeric (float or integer) values.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
_See code: [src/commands/metrics/breakdown.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/breakdown.ts)_
|
|
83
|
+
|
|
84
|
+
### `commercelayer metrics:date_breakdown RESOURCE`
|
|
85
|
+
|
|
86
|
+
Perform a date breakdown query on the Metrics API endpoint.
|
|
87
|
+
|
|
88
|
+
```sh-session
|
|
89
|
+
USAGE
|
|
90
|
+
$ commercelayer metrics:date_breakdown RESOURCE -b <value> -f <value> -O
|
|
91
|
+
avg|cardinality|max|min|percentiles|stats|sum|value_count [-F <value>] [-B <value>] [-i hour|day|week|month|year]
|
|
92
|
+
|
|
93
|
+
FLAGS
|
|
94
|
+
-B, --breakdown=<value> the optional nested breakdown
|
|
95
|
+
-F, --filter=<value> the filter to apply to the query in JSON format (enclosed in single quotes)
|
|
96
|
+
-O, --operator=<option> (required) the computing operator
|
|
97
|
+
<options: avg|cardinality|max|min|percentiles|stats|sum|value_count>
|
|
98
|
+
-b, --by=<value> (required) the field you want the results of the query aggragated by
|
|
99
|
+
-f, --field=<value> (required) the field you want the metrics or statistics computed on
|
|
100
|
+
-i, --interval=<option> the time interval over which the metrics are computed
|
|
101
|
+
<options: hour|day|week|month|year>
|
|
102
|
+
|
|
103
|
+
DESCRIPTION
|
|
104
|
+
perform a date breakdown query on the Metrics API endpoint
|
|
105
|
+
|
|
106
|
+
ALIASES
|
|
107
|
+
$ commercelayer metrics:breakdate
|
|
108
|
+
$ commercelayer metrics:date
|
|
109
|
+
$ commercelayer breakdate
|
|
110
|
+
$ commercelayer date_breakdown
|
|
111
|
+
|
|
112
|
+
EXAMPLES
|
|
113
|
+
$ commercelayer metrics:date_breakdown orders -b order.placed_at -f order.total_amount_with_taxes -O stats -i month
|
|
114
|
+
|
|
115
|
+
FLAG DESCRIPTIONS
|
|
116
|
+
-B, --breakdown=<value> the optional nested breakdown
|
|
117
|
+
|
|
118
|
+
a JSON object (enclosed in single quotes) containing the nested breakdown
|
|
119
|
+
|
|
120
|
+
-O, --operator=avg|cardinality|max|min|percentiles|stats|sum|value_count the computing operator
|
|
121
|
+
|
|
122
|
+
the list of valid operators depends on the value of the field key
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
_See code: [src/commands/metrics/date_breakdown.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/date_breakdown.ts)_
|
|
126
|
+
|
|
127
|
+
### `commercelayer metrics:fbt`
|
|
128
|
+
|
|
129
|
+
Perform a Frequently Bought Together query on the Metrics API analysis endpoint.
|
|
130
|
+
|
|
131
|
+
```sh-session
|
|
132
|
+
USAGE
|
|
133
|
+
$ commercelayer metrics:fbt [-i <value>...]
|
|
134
|
+
|
|
135
|
+
FLAGS
|
|
136
|
+
-i, --in=<value>... a list of SKU or bundle IDs associated as line items to one or more orders
|
|
137
|
+
|
|
138
|
+
DESCRIPTION
|
|
139
|
+
perform a Frequently Bought Together query on the Metrics API analysis endpoint
|
|
140
|
+
|
|
141
|
+
ALIASES
|
|
142
|
+
$ commercelayer fbt
|
|
143
|
+
|
|
144
|
+
EXAMPLES
|
|
145
|
+
$ commercelayer metrics:fbt --in xYZkjABcde,yzXKjYzaCx
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
_See code: [src/commands/metrics/fbt.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/fbt.ts)_
|
|
149
|
+
|
|
150
|
+
### `commercelayer metrics:search RESOURCE`
|
|
151
|
+
|
|
152
|
+
Perform a search query on the Metrics API endpoint.
|
|
153
|
+
|
|
154
|
+
```sh-session
|
|
155
|
+
USAGE
|
|
156
|
+
$ commercelayer metrics:search RESOURCE -f <value>... [-F <value>] [-l <value>] [-s asc|desc -b <value>] [-c
|
|
157
|
+
<value>]
|
|
158
|
+
|
|
159
|
+
FLAGS
|
|
160
|
+
-F, --filter=<value> the filter to apply to the query in JSON format (enclosed in single quotes)
|
|
161
|
+
-b, --sort_by=<value> the date field you want the results of the query sorted by
|
|
162
|
+
-c, --cursor=<value> the cursor pointing to a specific page in the paginated search results
|
|
163
|
+
-f, --fields=<value>... (required) comma-separated list of fields you want to be returned for each record in the
|
|
164
|
+
response
|
|
165
|
+
-l, --limit=<value> the maximum number of records shown in the response
|
|
166
|
+
-s, --sort=<option> the way you want the results of the query to be sorted
|
|
167
|
+
<options: asc|desc>
|
|
168
|
+
|
|
169
|
+
DESCRIPTION
|
|
170
|
+
perform a search query on the Metrics API endpoint
|
|
171
|
+
|
|
172
|
+
ALIASES
|
|
173
|
+
$ commercelayer search
|
|
174
|
+
|
|
175
|
+
EXAMPLES
|
|
176
|
+
commercelayewr metrics:search orders -l 5 -s asc -b order.placed_at -f order.id,order.number,order.placed_at,customer.email
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
_See code: [src/commands/metrics/search.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/search.ts)_
|
|
180
|
+
|
|
181
|
+
### `commercelayer metrics:stats RESOURCE`
|
|
182
|
+
|
|
183
|
+
Perform a stats query on the Metrics API endpoint.
|
|
184
|
+
|
|
185
|
+
```sh-session
|
|
186
|
+
USAGE
|
|
187
|
+
$ commercelayer metrics:stats RESOURCE -f <value> -O avg|cardinality|max|min|percentiles|stats|sum|value_count
|
|
188
|
+
[-F <value>]
|
|
189
|
+
|
|
190
|
+
FLAGS
|
|
191
|
+
-F, --filter=<value> the filter to apply to the query in JSON format (enclosed in single quotes)
|
|
192
|
+
-O, --operator=<option> (required) the computing operator
|
|
193
|
+
<options: avg|cardinality|max|min|percentiles|stats|sum|value_count>
|
|
194
|
+
-f, --field=<value> (required) the field you want the metrics or statistics computed on
|
|
195
|
+
|
|
196
|
+
DESCRIPTION
|
|
197
|
+
perform a stats query on the Metrics API endpoint
|
|
198
|
+
|
|
199
|
+
ALIASES
|
|
200
|
+
$ commercelayer stats
|
|
201
|
+
|
|
202
|
+
EXAMPLES
|
|
203
|
+
$ commercelayer metrics:stats orders -f order.total_amount_with_taxes --op avg
|
|
204
|
+
|
|
205
|
+
cl stats orders -f order.total_amount_with_taxes -O stats
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
_See code: [src/commands/metrics/stats.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/stats.ts)_
|
|
209
|
+
<!-- commandsstop -->
|
|
@@ -5,7 +5,7 @@ export default class MetricsFbt extends BaseCommand {
|
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
7
7
|
static flags: {
|
|
8
|
-
in: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
in: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
};
|
|
10
10
|
run(): Promise<void>;
|
|
11
11
|
}
|
|
@@ -17,7 +17,7 @@ class MetricsFbt extends base_1.BaseCommand {
|
|
|
17
17
|
in: core_1.Flags.string({
|
|
18
18
|
char: 'i',
|
|
19
19
|
description: 'a list of SKU or bundle IDs associated as line items to one or more orders',
|
|
20
|
-
required:
|
|
20
|
+
required: false,
|
|
21
21
|
multiple: true
|
|
22
22
|
})
|
|
23
23
|
};
|
|
@@ -25,7 +25,7 @@ class MetricsFbt extends base_1.BaseCommand {
|
|
|
25
25
|
const { flags } = await this.parse(MetricsFbt);
|
|
26
26
|
this.checkAcessTokenData(flags.accessToken, flags);
|
|
27
27
|
const ids = this.multivalFlag(flags.in);
|
|
28
|
-
const query = {
|
|
28
|
+
const query = (ids.length > 0) ? {
|
|
29
29
|
filter: {
|
|
30
30
|
line_items: {
|
|
31
31
|
item_ids: {
|
|
@@ -33,7 +33,7 @@ class MetricsFbt extends base_1.BaseCommand {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
};
|
|
36
|
+
} : {};
|
|
37
37
|
const response = await (0, request_1.metricsRequest)(MetricsFbt.operation, query, undefined, flags);
|
|
38
38
|
if (response.ok) {
|
|
39
39
|
cliux.action.stop(cli_core_1.clColor.msg.success('Done'));
|
package/lib/common.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
"char": "i",
|
|
370
370
|
"description": "a list of SKU or bundle IDs associated as line items to one or more orders",
|
|
371
371
|
"name": "in",
|
|
372
|
-
"required":
|
|
372
|
+
"required": false,
|
|
373
373
|
"hasDynamicHelp": false,
|
|
374
374
|
"multiple": true,
|
|
375
375
|
"type": "option"
|
|
@@ -670,5 +670,5 @@
|
|
|
670
670
|
]
|
|
671
671
|
}
|
|
672
672
|
},
|
|
673
|
-
"version": "1.0.
|
|
673
|
+
"version": "1.0.1"
|
|
674
674
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/cli-plugin-metrics",
|
|
3
3
|
"description": "Commerce Layer CLI metrics plugin",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"author": "Pierluigi Viti <pierluigi@commercelayer.io>",
|
|
6
6
|
"bugs": "https://github.com/commercelayer/commercelayer-cli-plugin-metrics/issues",
|
|
7
7
|
"engines": {
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"@semantic-release/changelog": "^6.0.3",
|
|
63
63
|
"@semantic-release/git": "^10.0.1",
|
|
64
64
|
"@types/chai": "^4.3.20",
|
|
65
|
-
"@types/lodash.isempty": "^4.4.9",
|
|
66
65
|
"@types/mocha": "^10.0.10",
|
|
67
66
|
"@types/node": "^22.15.18",
|
|
68
67
|
"chai": "^4.5.0",
|