@commercelayer/cli-plugin-metrics 1.0.1 → 1.0.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.
package/README.md CHANGED
@@ -130,10 +130,11 @@ Perform a Frequently Bought Together query on the Metrics API analysis endpoint.
130
130
 
131
131
  ```sh-session
132
132
  USAGE
133
- $ commercelayer metrics:fbt [-i <value>...]
133
+ $ commercelayer metrics:fbt [-F <value>] [-i <value>...]
134
134
 
135
135
  FLAGS
136
- -i, --in=<value>... a list of SKU or bundle IDs associated as line items to one or more orders
136
+ -F, --filter=<value> the filter to apply to the query in JSON format (enclosed in single quotes)
137
+ -i, --in=<value>... a list of SKU or bundle IDs associated as line items to one or more orders
137
138
 
138
139
  DESCRIPTION
139
140
  perform a Frequently Bought Together query on the Metrics API analysis endpoint
package/lib/base.d.ts CHANGED
@@ -15,7 +15,16 @@ export declare abstract class BaseCommand extends Command {
15
15
  protected multivalFlag(flag?: string[]): string[];
16
16
  protected printResponse(response: Response): Promise<void>;
17
17
  }
18
- export declare abstract class BaseResourceCommand extends BaseCommand {
18
+ export declare abstract class BaseFilterCommand extends BaseCommand {
19
+ static baseFlags: {
20
+ filter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
21
+ organization: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
22
+ domain: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
23
+ accessToken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
24
+ };
25
+ protected filterFlag(flag?: string): MetricsFilter | undefined;
26
+ }
27
+ export declare abstract class BaseResourceCommand extends BaseFilterCommand {
19
28
  static baseFlags: {
20
29
  filter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
21
30
  organization: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -25,7 +34,6 @@ export declare abstract class BaseResourceCommand extends BaseCommand {
25
34
  static args: {
26
35
  resource: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
27
36
  };
28
- protected filterFlag(flag?: string): MetricsFilter | undefined;
29
37
  }
30
38
  export declare abstract class BaseBreakdownCommand extends BaseResourceCommand {
31
39
  static baseFlags: {
package/lib/base.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Flags = exports.Args = exports.BaseBreakdownCommand = exports.BaseResourceCommand = exports.BaseCommand = void 0;
3
+ exports.Flags = exports.Args = exports.BaseBreakdownCommand = exports.BaseResourceCommand = exports.BaseFilterCommand = exports.BaseCommand = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const sdk_1 = tslib_1.__importStar(require("@commercelayer/sdk"));
6
6
  const core_1 = require("@oclif/core");
@@ -99,7 +99,7 @@ class BaseCommand extends core_1.Command {
99
99
  }
100
100
  }
101
101
  exports.BaseCommand = BaseCommand;
102
- class BaseResourceCommand extends BaseCommand {
102
+ class BaseFilterCommand extends BaseCommand {
103
103
  static baseFlags = {
104
104
  ...BaseCommand.baseFlags,
105
105
  filter: core_1.Flags.string({
@@ -107,9 +107,6 @@ class BaseResourceCommand extends BaseCommand {
107
107
  description: 'the filter to apply to the query in JSON format (enclosed in single quotes)'
108
108
  })
109
109
  };
110
- static args = {
111
- resource: core_1.Args.string({ resource: 'the resource name', options: common_1.resources, required: true })
112
- };
113
110
  filterFlag(flag) {
114
111
  let filter;
115
112
  if (flag) {
@@ -123,6 +120,15 @@ class BaseResourceCommand extends BaseCommand {
123
120
  return filter;
124
121
  }
125
122
  }
123
+ exports.BaseFilterCommand = BaseFilterCommand;
124
+ class BaseResourceCommand extends BaseFilterCommand {
125
+ static baseFlags = {
126
+ ...BaseFilterCommand.baseFlags
127
+ };
128
+ static args = {
129
+ resource: core_1.Args.string({ resource: 'the resource name', options: common_1.resources, required: true })
130
+ };
131
+ }
126
132
  exports.BaseResourceCommand = BaseResourceCommand;
127
133
  class BaseBreakdownCommand extends BaseResourceCommand {
128
134
  static baseFlags = {
@@ -1,5 +1,5 @@
1
- import { BaseCommand } from '../../base';
2
- export default class MetricsFbt extends BaseCommand {
1
+ import { BaseFilterCommand } from '../../base';
2
+ export default class MetricsFbt extends BaseFilterCommand {
3
3
  static operation: string;
4
4
  static aliases: string[];
5
5
  static description: string;
@@ -6,7 +6,7 @@ const base_1 = require("../../base");
6
6
  const request_1 = require("../../request");
7
7
  const cli_core_1 = require("@commercelayer/cli-core");
8
8
  const cliux = tslib_1.__importStar(require("@commercelayer/cli-ux"));
9
- class MetricsFbt extends base_1.BaseCommand {
9
+ class MetricsFbt extends base_1.BaseFilterCommand {
10
10
  static operation = 'fbt';
11
11
  static aliases = [MetricsFbt.operation];
12
12
  static description = 'perform a Frequently Bought Together query on the Metrics API analysis endpoint';
@@ -18,15 +18,20 @@ class MetricsFbt extends base_1.BaseCommand {
18
18
  char: 'i',
19
19
  description: 'a list of SKU or bundle IDs associated as line items to one or more orders',
20
20
  required: false,
21
- multiple: true
21
+ multiple: true,
22
+ relationships: [
23
+ { type: 'some', flags: ['in', 'filter'] }
24
+ ],
22
25
  })
23
26
  };
24
27
  async run() {
25
28
  const { flags } = await this.parse(MetricsFbt);
26
29
  this.checkAcessTokenData(flags.accessToken, flags);
27
30
  const ids = this.multivalFlag(flags.in);
31
+ const filterObject = this.filterFlag(flags.filter);
28
32
  const query = (ids.length > 0) ? {
29
33
  filter: {
34
+ ...filterObject,
30
35
  line_items: {
31
36
  item_ids: {
32
37
  in: ids
@@ -365,10 +365,27 @@
365
365
  "multiple": false,
366
366
  "type": "option"
367
367
  },
368
+ "filter": {
369
+ "char": "F",
370
+ "description": "the filter to apply to the query in JSON format (enclosed in single quotes)",
371
+ "name": "filter",
372
+ "hasDynamicHelp": false,
373
+ "multiple": false,
374
+ "type": "option"
375
+ },
368
376
  "in": {
369
377
  "char": "i",
370
378
  "description": "a list of SKU or bundle IDs associated as line items to one or more orders",
371
379
  "name": "in",
380
+ "relationships": [
381
+ {
382
+ "type": "some",
383
+ "flags": [
384
+ "in",
385
+ "filter"
386
+ ]
387
+ }
388
+ ],
372
389
  "required": false,
373
390
  "hasDynamicHelp": false,
374
391
  "multiple": true,
@@ -670,5 +687,5 @@
670
687
  ]
671
688
  }
672
689
  },
673
- "version": "1.0.1"
690
+ "version": "1.0.2"
674
691
  }
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.1",
4
+ "version": "1.0.2",
5
5
  "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
6
6
  "bugs": "https://github.com/commercelayer/commercelayer-cli-plugin-metrics/issues",
7
7
  "engines": {
@@ -63,20 +63,20 @@
63
63
  "@semantic-release/git": "^10.0.1",
64
64
  "@types/chai": "^4.3.20",
65
65
  "@types/mocha": "^10.0.10",
66
- "@types/node": "^22.15.18",
66
+ "@types/node": "^22.15.24",
67
67
  "chai": "^4.5.0",
68
68
  "eslint": "^8.57.1",
69
69
  "mocha": "^10.8.2",
70
70
  "nyc": "^15.1.0",
71
71
  "oclif": "^4.17.46",
72
- "semantic-release": "^24.2.3",
72
+ "semantic-release": "^24.2.5",
73
73
  "tsx": "^4.19.4",
74
74
  "typescript": "5.5.2"
75
75
  },
76
76
  "dependencies": {
77
77
  "@commercelayer/cli-core": "^5.9.0",
78
78
  "@commercelayer/cli-ux": "^1.0.7",
79
- "@commercelayer/sdk": "^6.41.0",
79
+ "@commercelayer/sdk": "^6.42.0",
80
80
  "@oclif/core": "^3.27.0",
81
81
  "tslib": "^2.8.1"
82
82
  },