@milaboratories/pl-client 2.9.2 → 2.9.3
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/core/errors.d.ts +5 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/errors.ts +5 -0
- package/src/test/test_config.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-client",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20.3.0"
|
|
6
6
|
},
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"undici": "~7.5.0",
|
|
33
33
|
"utility-types": "^3.11.0",
|
|
34
34
|
"yaml": "^2.7.0",
|
|
35
|
-
"@milaboratories/
|
|
36
|
-
"@milaboratories/
|
|
35
|
+
"@milaboratories/ts-helpers": "^1.3.1",
|
|
36
|
+
"@milaboratories/pl-http": "^1.1.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "~5.5.4",
|
package/src/core/errors.ts
CHANGED
|
@@ -36,6 +36,7 @@ export function isTimeoutOrCancelError(err: unknown, nested: boolean = false): b
|
|
|
36
36
|
export const PlErrorCodeNotFound = 5;
|
|
37
37
|
|
|
38
38
|
export class PlError extends Error {
|
|
39
|
+
name = 'PlError';
|
|
39
40
|
constructor(public readonly status: Status) {
|
|
40
41
|
super(`code=${status.code} ${status.message}`);
|
|
41
42
|
}
|
|
@@ -46,12 +47,14 @@ export function throwPlNotFoundError(message: string): never {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export class RecoverablePlError extends PlError {
|
|
50
|
+
name = 'RecoverablePlError';
|
|
49
51
|
constructor(status: Status) {
|
|
50
52
|
super(status);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
export class UnrecoverablePlError extends PlError {
|
|
57
|
+
name = 'UnrecoverablePlError';
|
|
55
58
|
constructor(status: Status) {
|
|
56
59
|
super(status);
|
|
57
60
|
}
|
|
@@ -64,12 +67,14 @@ export function isNotFoundError(err: unknown, nested: boolean = false): boolean
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
export class UnauthenticatedError extends Error {
|
|
70
|
+
name = 'UnauthenticatedError';
|
|
67
71
|
constructor(message: string) {
|
|
68
72
|
super('LoginFailed: ' + message);
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
export class DisconnectedError extends Error {
|
|
77
|
+
name = 'DisconnectedError';
|
|
73
78
|
constructor(message: string) {
|
|
74
79
|
super('Disconnected: ' + message);
|
|
75
80
|
}
|
package/src/test/test_config.ts
CHANGED
|
@@ -152,17 +152,17 @@ export async function getTestClient(alternativeRoot?: string) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
export async function withTempRoot<T>(body: (pl: PlClient) => Promise<T>): Promise<T> {
|
|
155
|
-
const
|
|
155
|
+
const alternativeRoot = `test_${Date.now()}_${randomUUID()}`;
|
|
156
156
|
let altRootId: OptionalResourceId = NullResourceId;
|
|
157
157
|
try {
|
|
158
|
-
const client = await getTestClient(
|
|
158
|
+
const client = await getTestClient(alternativeRoot);
|
|
159
159
|
altRootId = client.clientRoot;
|
|
160
160
|
const value = await body(client);
|
|
161
161
|
const rawClient = await getTestClient();
|
|
162
|
-
await rawClient.deleteAlternativeRoot(
|
|
162
|
+
await rawClient.deleteAlternativeRoot(alternativeRoot);
|
|
163
163
|
return value;
|
|
164
164
|
} catch (err: any) {
|
|
165
|
-
console.log(`ALTERNATIVE ROOT: ${
|
|
165
|
+
console.log(`ALTERNATIVE ROOT: ${alternativeRoot} (${resourceIdToString(altRootId)})`);
|
|
166
166
|
throw new Error(err.message, { cause: err });
|
|
167
167
|
}
|
|
168
168
|
}
|