@attlaz/client 1.118.0 → 1.120.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/dist/Client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { OAuthClientToken } from './Http/OAuthClientToken.js';
2
2
  import { ITransport, ParseErrorHandler } from './Http/Transport/ITransport.js';
3
3
  import { OAuthClient, TokenChangeHandler } from './Http/Transport/OAuthClient.js';
4
- import { ApiInformation } from './Model/ApiInformation.js';
4
+ import { ApiInfo } from './Model/ApiInformation.js';
5
5
  import { AccessTokenEndpoint } from './Service/AccessTokenEndpoint.js';
6
6
  import { AdapterConnectionEndpoint } from './Service/AdapterConnectionEndpoint.js';
7
7
  import { ConnectionBundleEndpoint } from './Service/ConnectionBundleEndpoint.js';
@@ -112,7 +112,8 @@ export declare class Client {
112
112
  * rejected. Pass null to stop observing. OAuth-only; a custom transport has no token.
113
113
  */
114
114
  setTokenChangeHandler(handler: TokenChangeHandler | null): void;
115
- getApiInformation(): Promise<ApiInformation>;
115
+ /** The gateway first, then every API it routes to. A non-administrator is shown the gateway alone. */
116
+ getApiInformation(): Promise<ApiInfo[]>;
116
117
  getAdapterEndpoint(): AdapterEndpoint;
117
118
  getAdapterConnectionEndpoint(): AdapterConnectionEndpoint;
118
119
  getConnectionBundleEndpoint(): ConnectionBundleEndpoint;
package/dist/Client.js CHANGED
@@ -211,14 +211,13 @@ export class Client {
211
211
  setTokenChangeHandler(handler) {
212
212
  this.httpClient.setTokenChangeHandler(handler);
213
213
  }
214
+ /** The gateway first, then every API it routes to. A non-administrator is shown the gateway alone. */
214
215
  async getApiInformation() {
215
216
  const result = await this.httpClient.request('/system/info', null, 'GET', true);
216
- // The gateway is the first entry, and the only one a non-administrator is shown.
217
- const gateway = result.apis?.[0];
218
- if (gateway === undefined || gateway.version === null) {
217
+ if (result.apis === undefined || result.apis.length === 0) {
219
218
  throw new Error('Unable to get API information: invalid response');
220
219
  }
221
- return { version: gateway.version, apis: result.apis ?? [] };
220
+ return result.apis;
222
221
  }
223
222
  /* Endpoints */
224
223
  getAdapterEndpoint() {
@@ -16,14 +16,3 @@ export type ApiInfo = {
16
16
  }[];
17
17
  error: string | null;
18
18
  };
19
- /**
20
- * What the endpoint is running.
21
- *
22
- * `apis` lists the gateway first, then every API it routes to — but only an administrator is shown
23
- * more than the gateway, so a normal caller gets a single entry.
24
- */
25
- export type ApiInformation = {
26
- /** The gateway's version — what `version` meant before `apis` existed. */
27
- version: string;
28
- apis: ApiInfo[];
29
- };
@@ -14,6 +14,13 @@ export declare class McpAccess implements StateAware {
14
14
  state: State;
15
15
  revokedAt: Date | null;
16
16
  createdAt: Date;
17
+ /**
18
+ * When a client last called this access's URL, or null if it never has.
19
+ *
20
+ * ⚠️ Nothing writes this yet — the column and the plumbing exist so the recording can be added
21
+ * in one place later. Until then it is always null, which reads as "Never".
22
+ */
23
+ lastUsedAt: Date | null;
17
24
  /**
18
25
  * The full URL to hand to a client, or null when the access has no live key — the state an
19
26
  * interrupted rotation leaves behind, which the UI has to be able to show rather than assume away.
@@ -13,6 +13,13 @@ export class McpAccess {
13
13
  state = State.Active;
14
14
  revokedAt = null;
15
15
  createdAt;
16
+ /**
17
+ * When a client last called this access's URL, or null if it never has.
18
+ *
19
+ * ⚠️ Nothing writes this yet — the column and the plumbing exist so the recording can be added
20
+ * in one place later. Until then it is always null, which reads as "Never".
21
+ */
22
+ lastUsedAt = null;
16
23
  /**
17
24
  * The full URL to hand to a client, or null when the access has no live key — the state an
18
25
  * interrupted rotation leaves behind, which the UI has to be able to show rather than assume away.
@@ -45,6 +52,7 @@ export class McpAccess {
45
52
  access.revokedAt = (raw.revoked_at === null || raw.revoked_at === undefined) ? null : Utils.parseRawDate(raw.revoked_at);
46
53
  access.createdAt = Utils.parseRawDate(raw.created_at);
47
54
  access.url = (raw.url === null || raw.url === undefined) ? null : raw.url;
55
+ access.lastUsedAt = (raw.last_used_at === null || raw.last_used_at === undefined) ? null : Utils.parseRawDate(raw.last_used_at);
48
56
  return access;
49
57
  }
50
58
  }
@@ -1,5 +1,16 @@
1
1
  export declare class CursorPagination {
2
+ /** Guards against a limit no server would honour; mirrors the bound Core validates against. */
3
+ private static readonly MAX_LIMIT;
2
4
  limit: number | null;
3
5
  startingAfter: string | null;
4
6
  endingBefore: string | null;
7
+ /**
8
+ * `limit` stays optional, and null keeps meaning "let the server decide" — that is a real
9
+ * intent, and what every existing caller wants. What the constructor adds is validation and a
10
+ * way to state a limit in one expression instead of constructing and then assigning.
11
+ *
12
+ * Core's equivalent defaults to 10 because a repository always needs a number. This one must
13
+ * not: defaulting here would silently start sending `limit=10` on every call that omits it.
14
+ */
15
+ constructor(limit?: number | null);
5
16
  }
@@ -1,5 +1,29 @@
1
1
  export class CursorPagination {
2
+ /** Guards against a limit no server would honour; mirrors the bound Core validates against. */
3
+ static MAX_LIMIT = 1000000;
2
4
  limit = null;
3
5
  startingAfter = null;
4
6
  endingBefore = null;
7
+ /**
8
+ * `limit` stays optional, and null keeps meaning "let the server decide" — that is a real
9
+ * intent, and what every existing caller wants. What the constructor adds is validation and a
10
+ * way to state a limit in one expression instead of constructing and then assigning.
11
+ *
12
+ * Core's equivalent defaults to 10 because a repository always needs a number. This one must
13
+ * not: defaulting here would silently start sending `limit=10` on every call that omits it.
14
+ */
15
+ constructor(limit = null) {
16
+ if (limit !== null) {
17
+ if (!Number.isInteger(limit)) {
18
+ throw new Error('Limit should be a whole number');
19
+ }
20
+ if (limit < 1) {
21
+ throw new Error('Limit should be at least 1');
22
+ }
23
+ if (limit > CursorPagination.MAX_LIMIT) {
24
+ throw new Error('Limit should not exceed ' + CursorPagination.MAX_LIMIT);
25
+ }
26
+ }
27
+ this.limit = limit;
28
+ }
5
29
  }
@@ -12,6 +12,8 @@ export declare class McpAccessEndpoint extends Endpoint {
12
12
  getAccessById(accessId: string): Promise<McpAccess | null>;
13
13
  /** Creates the access and its first URL together — an access with no URL cannot be reached. */
14
14
  createAccess(name: string, target: string): Promise<McpAccess>;
15
+ /** Renames only. The target is write-once and the URL is changed by rotating, not here. */
16
+ renameAccess(accessId: string, name: string): Promise<McpAccess>;
15
17
  /** New URL, old one dead, and every token bound to the old one revoked. */
16
18
  rotateKey(accessId: string): Promise<McpAccess>;
17
19
  /** Reversible, and keeps its tokens, so resuming needs no re-authentication. */
@@ -52,6 +52,24 @@ export class McpAccessEndpoint extends Endpoint {
52
52
  throw error;
53
53
  }
54
54
  }
55
+ /** Renames only. The target is write-once and the URL is changed by rotating, not here. */
56
+ async renameAccess(accessId, name) {
57
+ try {
58
+ const url = path('/mcp-accesses/:accessId', { accessId });
59
+ const result = await this.requestObject(url, { name }, McpAccess.parse, 'PATCH');
60
+ const access = result.getData();
61
+ if (access === null) {
62
+ throw new Error('MCP access not found: ' + accessId);
63
+ }
64
+ return access;
65
+ }
66
+ catch (error) {
67
+ if (this.httpClient.isDebugEnabled()) {
68
+ console.error('Failed to rename the MCP access: ', error);
69
+ }
70
+ throw error;
71
+ }
72
+ }
55
73
  /** New URL, old one dead, and every token bound to the old one revoked. */
56
74
  async rotateKey(accessId) {
57
75
  return await this.lifecycle(accessId, path('/mcp-accesses/:accessId/rotate-key', { accessId }), 'POST', 'rotate the MCP URL');
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export type { TokenChangeHandler } from './Http/Transport/OAuthClient.js';
15
15
  export { OAuthClientOptions } from './Http/OAuthClientOptions.js';
16
16
  export { OAuthClientToken } from './Http/OAuthClientToken.js';
17
17
  export { ClientError } from './Http/ClientError.js';
18
- export { ApiInfo, ApiInformation } from './Model/ApiInformation.js';
18
+ export { ApiInfo } from './Model/ApiInformation.js';
19
19
  export { ApiError } from './Model/Error/ApiError.js';
20
20
  export type { ParseErrorHandler } from './Http/Transport/ITransport.js';
21
21
  export { HttpStatus } from './Http/HttpStatus.js';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.117.0";
1
+ export declare const VERSION = "1.119.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.117.0";
1
+ export const VERSION = "1.119.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attlaz/client",
3
- "version": "1.118.0",
3
+ "version": "1.120.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",