terse-types 0.6.1 → 0.6.2
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.
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Translate known runtime guidance, leaving source paths and dependency details intact. */
|
|
2
|
+
export declare function formatActorDiagnostic(message: string): string;
|
|
3
|
+
/** Keep the error class, invocation code, request ID, cause, and stack frames. */
|
|
4
|
+
export declare function rethrowActorError(error: unknown): never;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Translate known runtime guidance, leaving source paths and dependency details intact. */
|
|
2
|
+
export function formatActorDiagnostic(message) {
|
|
3
|
+
return message
|
|
4
|
+
.split("\n")
|
|
5
|
+
.map(line => {
|
|
6
|
+
if (/^\s*at\s/.test(line))
|
|
7
|
+
return line;
|
|
8
|
+
return line
|
|
9
|
+
.replaceAll("cannot resolve the durable-actors SDK", "Cannot resolve the Terse SDK. Install terse-sdk in your actor project")
|
|
10
|
+
.replaceAll("the durable-actors application credential was rejected", "Actor authentication failed. Check TERSE_API_KEY for the selected server")
|
|
11
|
+
.replaceAll("durable-actors client settings are invalid", "Terse actor client settings are invalid")
|
|
12
|
+
.replace(/\bdurable-actors generate --remote\b/g, "terse actor generate")
|
|
13
|
+
.replace(/\bdurable-actors dev\b/g, "terse actor dev")
|
|
14
|
+
.replace(/\bDURABLE_ACTORS_PROJECT_ID\b/g, "TERSE_ACTOR_PROJECT_ID")
|
|
15
|
+
.replace(/\bDURABLE_ACTORS_PORT\b/g, "TERSE_ACTOR_PORT")
|
|
16
|
+
.replace(/\bDURABLE_ACTORS_SECRET\b/g, "TERSE_ACTOR_SECRET");
|
|
17
|
+
})
|
|
18
|
+
.join("\n");
|
|
19
|
+
}
|
|
20
|
+
/** Keep the error class, invocation code, request ID, cause, and stack frames. */
|
|
21
|
+
export function rethrowActorError(error) {
|
|
22
|
+
if (error instanceof Error) {
|
|
23
|
+
const message = formatActorDiagnostic(error.message);
|
|
24
|
+
if (message !== error.message) {
|
|
25
|
+
const heading = `${error.name}: ${error.message}`;
|
|
26
|
+
const stack = error.stack;
|
|
27
|
+
error.message = message;
|
|
28
|
+
if (stack?.startsWith(heading))
|
|
29
|
+
error.stack = `${error.name}: ${message}${stack.slice(heading.length)}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
package/dist/ActorEndpoint.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_ACTOR_DEV_PORT = 7100;
|
|
2
|
+
export declare const DEFAULT_ACTOR_DEV_PROJECT_ID = "local";
|
|
3
|
+
export declare const DEFAULT_ACTOR_URL = "http://127.0.0.1:7100/v1/projects/local/actors";
|
|
1
4
|
export interface ActorEndpoint {
|
|
2
5
|
kind: "terse" | "runtime";
|
|
3
6
|
origin: string;
|
|
@@ -5,5 +8,6 @@ export interface ActorEndpoint {
|
|
|
5
8
|
actorUrl: string;
|
|
6
9
|
contractUrl: string;
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
export declare function isLocalActorEndpoint(endpoint: ActorEndpoint): boolean;
|
|
12
|
+
/** The URL path selects the Terse API or native actor runtime explicitly. */
|
|
9
13
|
export declare function parseActorEndpoint(value: string): ActorEndpoint;
|
package/dist/ActorEndpoint.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
export const DEFAULT_ACTOR_DEV_PORT = 7100;
|
|
2
|
+
export const DEFAULT_ACTOR_DEV_PROJECT_ID = "local";
|
|
3
|
+
export const DEFAULT_ACTOR_URL = `http://127.0.0.1:${DEFAULT_ACTOR_DEV_PORT}/v1/projects/${DEFAULT_ACTOR_DEV_PROJECT_ID}/actors`;
|
|
4
|
+
export function isLocalActorEndpoint(endpoint) {
|
|
5
|
+
return endpoint.kind === "runtime" && ["localhost", "127.0.0.1", "[::1]"].includes(new URL(endpoint.origin).hostname);
|
|
6
|
+
}
|
|
7
|
+
/** The URL path selects the Terse API or native actor runtime explicitly. */
|
|
2
8
|
export function parseActorEndpoint(value) {
|
|
3
9
|
const invalid = () => new Error("TERSE_ACTOR_URL must be an HTTP(S) URL ending in /<projectId>/actors or /v1/projects/<projectId>/actors, without credentials, query, or fragment");
|
|
4
10
|
let url;
|
package/dist/types.d.ts
CHANGED
|
@@ -291,8 +291,8 @@ export declare const deviceTokenExchangeResponseSchema: z.ZodObject<{
|
|
|
291
291
|
export type DeviceTokenExchangeResponse = z.infer<typeof deviceTokenExchangeResponseSchema>;
|
|
292
292
|
export declare const authModeResponseSchema: z.ZodObject<{
|
|
293
293
|
mode: z.ZodEnum<{
|
|
294
|
-
workos: "workos";
|
|
295
294
|
local: "local";
|
|
295
|
+
workos: "workos";
|
|
296
296
|
}>;
|
|
297
297
|
}, z.core.$strip>;
|
|
298
298
|
export type AuthModeResponse = z.infer<typeof authModeResponseSchema>;
|