@nmshd/connector-tui 2.13.3 → 2.15.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.
@@ -1,12 +1,12 @@
1
- import { ConnectorClient } from "@nmshd/connector-sdk";
2
1
  import chalk from "chalk";
3
2
  import { readFile } from "fs/promises";
4
3
  import { DateTime } from "luxon";
5
4
  import prompts from "prompts";
5
+ import { ConnectorClient } from "./client/ConnectorClient.js";
6
6
  import { ConnectorTUIBaseWithMixins } from "./mixins/index.js";
7
7
  export class ConnectorTUI extends ConnectorTUIBaseWithMixins {
8
8
  static async create(baseUrl, apiKey) {
9
- const client = ConnectorClient.create({ baseUrl, apiKey });
9
+ const client = new ConnectorClient({ baseUrl, apiKey });
10
10
  const address = (await client.account.getIdentityInfo()).result.address;
11
11
  const support = await client.monitoring.getSupport();
12
12
  return new ConnectorTUI(client, address, support);
@@ -18,7 +18,7 @@ export class ConnectorTUI extends ConnectorTUIBaseWithMixins {
18
18
  await this.#showStartupMessage(connectorVersionInfo);
19
19
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
20
  while (true) {
21
- const activeIdentityDeletionProcess = this.isDebugMode() ? await this.identityDeletionProcessEndpoint.getActiveIdentityDeletionProcess() : undefined;
21
+ const activeIdentityDeletionProcess = this.isDebugMode() ? await this.connectorClient.identityDeletionProcess.getActiveIdentityDeletionProcess() : undefined;
22
22
  if (activeIdentityDeletionProcess?.isSuccess && activeIdentityDeletionProcess.result.status === "Approved") {
23
23
  const gracePeriodEndsAtDateTime = DateTime.fromISO(activeIdentityDeletionProcess.result.gracePeriodEndsAt);
24
24
  if (gracePeriodEndsAtDateTime.diffNow().milliseconds < 0) {
@@ -1,19 +1,16 @@
1
1
  import { RelationshipStatus } from "@nmshd/connector-sdk";
2
2
  import { DateTime } from "luxon";
3
3
  import prompts from "prompts";
4
- import { IdentityDeletionProcessEndpoint } from "./IdentityDeletionProcessEndpoint.js";
5
4
  export class ConnectorTUIBase {
6
5
  connectorClient;
7
6
  connectorAddress;
8
7
  support;
9
8
  choices = [];
10
9
  choicesInDeletion = [];
11
- identityDeletionProcessEndpoint;
12
10
  constructor(connectorClient, connectorAddress, support) {
13
11
  this.connectorClient = connectorClient;
14
12
  this.connectorAddress = connectorAddress;
15
13
  this.support = support;
16
- this.identityDeletionProcessEndpoint = new IdentityDeletionProcessEndpoint(this.connectorClient.account["httpClient"]);
17
14
  }
18
15
  async selectRelationship(prompt, ...status) {
19
16
  if (status.length === 0)
@@ -0,0 +1,9 @@
1
+ import { ConnectorClient as BaseConnectorClient } from "@nmshd/connector-sdk";
2
+ import { IdentityDeletionProcessEndpoint } from "./IdentityDeletionProcessEndpoint.js";
3
+ export class ConnectorClient extends BaseConnectorClient {
4
+ identityDeletionProcess;
5
+ constructor(config) {
6
+ super(config);
7
+ this.identityDeletionProcess = new IdentityDeletionProcessEndpoint(this.axiosInstance);
8
+ }
9
+ }
@@ -1,4 +1,4 @@
1
- import { Endpoint } from "@nmshd/connector-sdk/dist/endpoints/Endpoint.js";
1
+ import { Endpoint } from "@nmshd/connector-sdk";
2
2
  export var IdentityDeletionProcessStatus;
3
3
  (function (IdentityDeletionProcessStatus) {
4
4
  IdentityDeletionProcessStatus["WaitingForApproval"] = "WaitingForApproval";
@@ -13,7 +13,7 @@ export function AddIdentityDeletionProcess(Base) {
13
13
  }
14
14
  async identityDeletionProcess() {
15
15
  const choices = [];
16
- const activeIdentityDeletionProcess = await this.identityDeletionProcessEndpoint.getActiveIdentityDeletionProcess();
16
+ const activeIdentityDeletionProcess = await this.connectorClient.identityDeletionProcess.getActiveIdentityDeletionProcess();
17
17
  if (activeIdentityDeletionProcess.isSuccess) {
18
18
  choices.push({ title: "Show IdentityDeletionProcess", value: "Show" });
19
19
  if (activeIdentityDeletionProcess.result.status === "Approved") {
@@ -49,12 +49,12 @@ export function AddIdentityDeletionProcess(Base) {
49
49
  });
50
50
  const oneSecondInDays = 1 / (24 * 60 * 60);
51
51
  const lengthOfGracePeriodInDays = confirmation["IdentityDeletionProcess grace period"] ? oneSecondInDays : undefined;
52
- const identityDeletionProcess = (await this.identityDeletionProcessEndpoint.initiateIdentityDeletionProcess(lengthOfGracePeriodInDays)).result;
52
+ const identityDeletionProcess = (await this.connectorClient.identityDeletionProcess.initiateIdentityDeletionProcess(lengthOfGracePeriodInDays)).result;
53
53
  console.log("Identity Deletion Process initiated.");
54
54
  this.showIdentityDeletionProcesses(identityDeletionProcess);
55
55
  }
56
56
  async cancelIdentityDeletionProcess() {
57
- const identityDeletionProcess = (await this.identityDeletionProcessEndpoint.cancelIdentityDeletionProcess()).result;
57
+ const identityDeletionProcess = (await this.connectorClient.identityDeletionProcess.cancelIdentityDeletionProcess()).result;
58
58
  console.log("Identity Deletion Process canceled.");
59
59
  this.showIdentityDeletionProcesses(identityDeletionProcess);
60
60
  }
@@ -167,17 +167,23 @@ export function AddSendRequestByMessage(Base) {
167
167
  type: "text",
168
168
  name: "attributeType",
169
169
  },
170
+ {
171
+ message: "What's the description of the RequestItem?",
172
+ type: "text",
173
+ name: "requestItemDescription",
174
+ format: (value) => (value === "" ? undefined : value),
175
+ },
170
176
  {
171
177
  message: "What's the title of the RelationshipAttribute?",
172
178
  type: "text",
173
179
  name: "attributeTitle",
174
- initial: "Attribute Title",
180
+ format: (value) => (value === "" ? undefined : value),
175
181
  },
176
182
  {
177
183
  message: "What's the description of the RelationshipAttribute?",
178
184
  type: "text",
179
185
  name: "attributeDescription",
180
- initial: "Attribute Title",
186
+ format: (value) => (value === "" ? undefined : value),
181
187
  },
182
188
  {
183
189
  message: "What's the key of the attribute you would like to query?",
@@ -190,16 +196,18 @@ export function AddSendRequestByMessage(Base) {
190
196
  type: "select",
191
197
  name: "owner",
192
198
  choices: [
193
- { title: "The other side or a third party", value: "" },
194
- { title: "The other side", value: "recipient" },
195
- { title: "A third party", value: "thirdParty" },
199
+ { title: "Yourself", value: "yourself" },
200
+ { title: "The recipient", value: "" },
196
201
  ],
197
202
  },
198
203
  ]);
199
204
  const title = result.attributeTitle ?? `A ${result.attributeType} attribute`;
205
+ if (result.owner === "yourself")
206
+ result.owner = this.connectorAddress;
200
207
  const requestItem = {
201
208
  "@type": "ReadAttributeRequestItem",
202
209
  mustBeAccepted: true,
210
+ description: result.requestItemDescription,
203
211
  query: {
204
212
  "@type": "RelationshipAttributeQuery",
205
213
  owner: result.owner ?? "",
@@ -229,8 +237,13 @@ export function AddSendRequestByMessage(Base) {
229
237
  },
230
238
  {
231
239
  message: "Who is the owner of the RelationshipAttribute?",
232
- type: "text",
240
+ type: "select",
233
241
  name: "owner",
242
+ choices: [
243
+ { title: "The recipient or the third party", value: "" },
244
+ { title: "The recipient", value: "recipient" },
245
+ { title: "The third party", value: "thirdParty" },
246
+ ],
234
247
  },
235
248
  {
236
249
  message: "What are the third party addresses? (comma-separated)",
@@ -270,6 +283,15 @@ export function AddSendRequestByMessage(Base) {
270
283
  type: "text",
271
284
  name: "valueType",
272
285
  },
286
+ {
287
+ message: "Type in the comma separated tags the fallback attribute should have",
288
+ type: "text",
289
+ format: (value) => value
290
+ .split(",")
291
+ .map((tag) => tag.trim())
292
+ .filter((tag) => tag.length > 0),
293
+ name: "tags",
294
+ },
273
295
  ]);
274
296
  const requestItem = {
275
297
  "@type": "ReadAttributeRequestItem",
@@ -279,6 +301,7 @@ export function AddSendRequestByMessage(Base) {
279
301
  queryString: result.queryString,
280
302
  attributeCreationHints: {
281
303
  valueType: result.valueType,
304
+ tags: result.tags.length > 0 ? result.tags : undefined,
282
305
  },
283
306
  },
284
307
  };
@@ -390,6 +413,15 @@ export function AddSendRequestByMessage(Base) {
390
413
  type: "text",
391
414
  name: "value",
392
415
  },
416
+ {
417
+ message: "Type in the comma separated tags your proposed attribute or created attributes should have",
418
+ type: "text",
419
+ format: (value) => value
420
+ .split(",")
421
+ .map((tag) => tag.trim())
422
+ .filter((tag) => tag.length > 0),
423
+ name: "tags",
424
+ },
393
425
  ]);
394
426
  const requestItem = {
395
427
  "@type": "ProposeAttributeRequestItem",
@@ -397,6 +429,10 @@ export function AddSendRequestByMessage(Base) {
397
429
  query: {
398
430
  "@type": "IQLQuery",
399
431
  queryString: result.queryString,
432
+ attributeCreationHints: {
433
+ valueType: result.attributeType,
434
+ tags: result.tags.length > 0 ? result.tags : undefined,
435
+ },
400
436
  },
401
437
  attribute: {
402
438
  "@type": "IdentityAttribute",
@@ -405,6 +441,7 @@ export function AddSendRequestByMessage(Base) {
405
441
  "@type": result.attributeType,
406
442
  value: result.value,
407
443
  },
444
+ tags: result.tags.length > 0 ? result.tags : undefined,
408
445
  },
409
446
  };
410
447
  return requestItem;
package/package.json CHANGED
@@ -28,9 +28,9 @@
28
28
  "watch": "node --watch --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' src/run.ts"
29
29
  },
30
30
  "dependencies": {
31
- "@nmshd/connector-sdk": "^6.36.2",
31
+ "@nmshd/connector-sdk": "^6.36.4",
32
32
  "axios": "^1.11.0",
33
- "chalk": "^5.5.0",
33
+ "chalk": "^5.6.0",
34
34
  "dotenv": "^17.2.1",
35
35
  "luxon": "^3.7.1",
36
36
  "prompts": "^2.4.2",
@@ -41,21 +41,21 @@
41
41
  "@js-soft/eslint-config-ts": "^2.0.3",
42
42
  "@js-soft/license-check": "^1.0.9",
43
43
  "@types/luxon": "^3.7.1",
44
- "@types/node": "^24.2.0",
44
+ "@types/node": "^24.3.0",
45
45
  "@types/prompts": "^2.4.9",
46
46
  "@types/qrcode-terminal": "^0.12.2",
47
47
  "@types/yargs": "^17.0.33",
48
- "eslint": "^9.32.0",
48
+ "eslint": "^9.34.0",
49
49
  "prettier": "^3.6.2",
50
50
  "ts-node": "^10.9.2",
51
51
  "typescript": "^5.9.2"
52
52
  },
53
53
  "engines": {
54
- "node": ">=22.18.0"
54
+ "node": ">=22.19.0"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public",
58
58
  "provenance": true
59
59
  },
60
- "version": "2.13.3"
60
+ "version": "2.15.0"
61
61
  }