@wavyx/pdcli 0.3.0 → 0.5.0
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/CHANGELOG.md +34 -0
- package/README.md +24 -0
- package/oclif.manifest.json +1003 -106
- package/package.json +1 -1
- package/src/commands/audit.js +137 -0
- package/src/commands/deal/bulk-update.js +131 -0
- package/src/commands/funnel.js +92 -0
- package/src/commands/metrics/velocity.js +81 -0
- package/src/commands/org/import.js +109 -0
- package/src/commands/person/import.js +118 -0
- package/src/commands/pipeline/health.js +78 -0
- package/src/lib/analytics.js +154 -0
- package/src/lib/audit.js +228 -0
- package/src/lib/bulk.js +106 -0
- package/src/lib/csv-parse.js +88 -0
- package/src/lib/import.js +49 -0
- package/src/lib/period.js +33 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CliError } from './errors.js'
|
|
2
|
+
|
|
3
|
+
const DAY_MS = 86_400_000
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse a trailing period like "90d", "30d", or "3m" (months = 30 days)
|
|
7
|
+
* into the start date of the window.
|
|
8
|
+
* @param {string} period
|
|
9
|
+
* @param {Date} [now]
|
|
10
|
+
* @returns {Date}
|
|
11
|
+
*/
|
|
12
|
+
export function parsePeriod(period, now = new Date()) {
|
|
13
|
+
const match = /^(\d+)([dm])$/.exec(period)
|
|
14
|
+
if (!match) {
|
|
15
|
+
throw new CliError(
|
|
16
|
+
`Invalid period "${period}" — use Nd (days) or Nm (months), e.g. 90d`,
|
|
17
|
+
{ exitCode: 64 },
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
const amount = Number(match[1])
|
|
21
|
+
const days = match[2] === 'm' ? amount * 30 : amount
|
|
22
|
+
return new Date(now.getTime() - days * DAY_MS)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Format a date the way v2 query params accept it: RFC 3339 seconds
|
|
27
|
+
* precision, no milliseconds (the API rejects fractional seconds).
|
|
28
|
+
* @param {Date} date
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function formatApiDatetime(date) {
|
|
32
|
+
return date.toISOString().replace(/\.\d{3}Z$/, 'Z')
|
|
33
|
+
}
|