@n42/cli 0.1.83 → 0.1.89

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
@@ -11,13 +11,14 @@ routing, SMP resolution, and Access Point behavior.
11
11
 
12
12
  ## Features
13
13
 
14
- - Peppol eDelivery path discovery
15
- - SMP and Access Point resolution diagnostics
16
- - Supported document type detection
17
- - PlantUML and SVG visualizations
18
- - Authenticated API access
19
- - Deterministic, script-friendly output
20
- - No browser automation or UI side effects
14
+ - Peppol eDelivery path discovery
15
+ - SMP and Access Point resolution diagnostics
16
+ - Supported document type detection
17
+ - PlantUML and SVG visualizations
18
+ - Authenticated API access
19
+ - Deterministic, script-friendly output
20
+ - No browser automation or UI side effects
21
+ - Local artefact history inspection
21
22
 
22
23
  ## Installation
23
24
 
@@ -43,7 +44,7 @@ n42 --version
43
44
  ## Authentication
44
45
 
45
46
  Authenticate once using your Node42 account credentials.\
46
- Tokens are stored locally under `~/.node42/`.
47
+ Tokens are stored locally under `~/.node42/tokens.json`.
47
48
 
48
49
  ``` bash
49
50
  n42 login
@@ -65,6 +66,35 @@ n42 me
65
66
  n42 discover peppol <participantId>
66
67
  ```
67
68
 
69
+ #### Available options:
70
+ - **-e**, **--env** `<environment>` Environment (TEST | PROD)
71
+ - **-o**, **--output** `<type>` Result type (json | plantuml)
72
+ - **-f**, **--format** `<format>` When output=plantuml (svg | text)
73
+ - **--force-https** Force HTTPS endpoints
74
+ - **--insecure** Disable TLS certificate validation
75
+ - **--fetch-business-card** Fetch Peppol business card
76
+ - **--reverse-lookup** Enable reverse lookup
77
+ - **--probe-endpoints** Probe resolved endpoints
78
+
79
+ ### History
80
+
81
+ ``` bash
82
+ n42 history <participantId>
83
+ ```
84
+
85
+ Example output:
86
+
87
+ ```bash
88
+ DATE PID FILE
89
+ 2026-01-30 15:42:18 9915:helger ~/.node42/artefacts/discovery/b91f83e2.svg
90
+ 2026-01-30 15:42:10 9915:helger ~/.node42/artefacts/discovery/ba1cbc8d.svg
91
+ ```
92
+
93
+ #### Available options:
94
+ - **--today** Show only today's artefacts
95
+ - **--day** `<yyyy-mm-dd>` Show artefacts for a specific day
96
+ - **--last** `<n>` Show only last N results
97
+
68
98
  ------------------------------------------------------------------------
69
99
 
70
100
  ## Artefacts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n42/cli",
3
- "version": "0.1.83",
3
+ "version": "0.1.89",
4
4
  "description": "Node42 CLI – Command-line interface for Peppol eDelivery path discovery, diagnostics, and tooling",
5
5
  "keywords": [
6
6
  "node42"
package/src/auth.js CHANGED
@@ -1,14 +1,14 @@
1
1
  const fs = require("fs");
2
- const { NODE42_DIR, TOKENS_FILE, API_URL, EP_SIGNIN, EP_REFRESH } = require("./config");
2
+ const { NODE42_DIR, TOKENS_FILE, API_URL, EP_SIGNIN, EP_REFRESH, EP_ME } = require("./config");
3
3
  const { handleError } = require("./errors");
4
- const { getUser } = require("./user");
4
+ const { getUserWithIndex } = require("./user");
5
5
  const { clearScreen, ask, startSpinner } = require("./utils");
6
6
  const db = require("./db");
7
7
 
8
8
 
9
9
  async function login() {
10
10
  clearScreen("Sign in to Node42");
11
- let user = getUser();
11
+ let user = getUserWithIndex(0);
12
12
 
13
13
  const username = await ask("Username", user.userMail ?? "");
14
14
  const password = await ask("Password", null, true);
@@ -54,7 +54,7 @@ async function login() {
54
54
  process.exit(1);
55
55
  }
56
56
 
57
- user = getUser();
57
+ user = getUserWithIndex(0);
58
58
  console.log(
59
59
  `Authenticated as ${user.userName} <${user.userMail}> (${user.role})`
60
60
  );
@@ -81,7 +81,7 @@ async function checkAuth() {
81
81
  return false;
82
82
  }
83
83
 
84
- const res = await fetchWithAuth(`${API_URL}/users/me`, {
84
+ const res = await fetchWithAuth(`${API_URL}/${EP_ME}`, {
85
85
  method: "GET",
86
86
  headers: {
87
87
  "Content-Type": "application/json"
package/src/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { Command } = require("commander");
4
4
  const { login, logout, checkAuth } = require("./auth");
5
- const { getUser, getUserUsage } = require("./user");
5
+ const { getUserWithIndex, getUserUsage } = require("./user");
6
6
  const { runDiscovery } = require("./discover");
7
7
  const { clearScreen, startSpinner, validateEnv, validateId, createAppDirs, getArtefactExt, cleanAppDirs } = require("./utils");
8
8
  const { NODE42_DIR, ARTEFACTS_DIR, DEFAULT_OUTPUT, DEFAULT_FORMAT } = require("./config");
@@ -77,7 +77,7 @@ program
77
77
  process.exit(1);
78
78
  }
79
79
 
80
- const user = getUser();
80
+ const user = getUserWithIndex(0);
81
81
  const currentMonth = new Date().toISOString().slice(0, 7);
82
82
  console.log(`Node42 CLI v${pkg.version}
83
83
  User
@@ -103,7 +103,7 @@ program
103
103
  .description("Returns usage for the authenticated user.")
104
104
  .option("-m, --month <yyyy-mm>", "Show usage for a specific month")
105
105
  .action((service, options) => {
106
- const user = getUser();
106
+ const user = getUserWithIndex(0);
107
107
  const currentMonth = options.month ? options.month : new Date().toISOString().slice(0, 7);
108
108
  let usage = getUserUsage(user.id, service, currentMonth);
109
109
  if (!usage) {
@@ -156,7 +156,8 @@ program
156
156
 
157
157
  if (!artefacts.length) {
158
158
  clearScreen(`Node42 CLI v${pkg.version}`);
159
- console.log(`No artefacts found. (${dayFilter})`);
159
+ const filter = dayFilter !== null ? ` (${dayFilter})` : ``;
160
+ console.log(`No artefacts found.${filter}`);
160
161
  return;
161
162
  }
162
163
 
@@ -172,8 +173,6 @@ program
172
173
  for (const item of artefacts) {
173
174
  const d = new Date(item.createdAt);
174
175
  const dt = d.toISOString().slice(0, 19).replace("T", " ");
175
-
176
- const ext = getArtefactExt(item.output, item.format);
177
176
  const file = path.join(ARTEFACTS_DIR, `${item.file}`);
178
177
 
179
178
  let pid = item.participantId;
package/src/config.js CHANGED
@@ -23,6 +23,7 @@ const config = {
23
23
 
24
24
  EP_SIGNIN: "auth/signin",
25
25
  EP_REFRESH: "auth/refresh",
26
+ EP_ME: "users/me",
26
27
  EP_DISCOVER: "discover/peppol"
27
28
  };
28
29
 
package/src/discover.js CHANGED
@@ -5,7 +5,7 @@ const db = require("./db");
5
5
 
6
6
  const { fetchWithAuth } = require("./auth");
7
7
  const { API_URL, EP_DISCOVER, DEFAULT_OUTPUT, DEFAULT_FORMAT, ARTEFACTS_DIR } = require("./config");
8
- const { getUser, setUserUsage } = require("./user");
8
+ const { getUserWithIndex, setUserUsage } = require("./user");
9
9
  const { clearScreen, startSpinner, buildDocLabel, promptForDocument, getShortId, getArtefactExt } = require("./utils");
10
10
  const { handleError } = require("./errors");
11
11
 
@@ -117,7 +117,7 @@ async function runDiscovery(participantId, options) {
117
117
  const encodedDocs = res.headers.get("X-Node42-Documents");
118
118
  const currentMonth = new Date().toISOString().slice(0, 7);
119
119
 
120
- const user = getUser();
120
+ const user = getUserWithIndex(0);
121
121
  setUserUsage(
122
122
  user.id,
123
123
  "discovery",
package/src/user.js CHANGED
@@ -1,8 +1,8 @@
1
1
  const db = require("./db");
2
2
 
3
- function getUser() {
3
+ function getUserWithIndex(index) {
4
4
  const users = db.get("user");
5
- return users.length ? users[0] : {
5
+ return users.length ? users[index] : {
6
6
  "id": "n/a",
7
7
  "userName": "n/a",
8
8
  "userMail": "n/a",
@@ -10,6 +10,21 @@ function getUser() {
10
10
  };
11
11
  }
12
12
 
13
+ function getUserWithId(userId) {
14
+ const database = db.load();
15
+
16
+ const u = database.user.find(x => x.id === userId);
17
+ if (!u) {
18
+ return {
19
+ "id": "n/a",
20
+ "userName": "n/a",
21
+ "userMail": "n/a",
22
+ "role": "n/a"
23
+ }
24
+ }
25
+ return u;
26
+ }
27
+
13
28
  function getUserUsage(userId, service, month) {
14
29
  const database = db.load();
15
30
 
@@ -34,4 +49,4 @@ function setUserUsage(userId, service, month, value) {
34
49
  db.save(database);
35
50
  }
36
51
 
37
- module.exports = { getUser, getUserUsage, setUserUsage };
52
+ module.exports = { getUserWithIndex, getUserWithId, getUserUsage, setUserUsage };
package/test/auth.test.js CHANGED
@@ -36,7 +36,9 @@ describe("auth", () => {
36
36
  .onSecondCall().resolves("secret");
37
37
 
38
38
  sinon.stub(utils, "startSpinner").callsFake(() => () => {});
39
- sinon.stub(user, "getUser").returns({
39
+ sinon.stub(user, "getUserWithIndex")
40
+ .withArgs(0)
41
+ .returns({
40
42
  id: "1",
41
43
  userName: "User",
42
44
  userMail: "user@test.com",