terse-types 0.6.0 → 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
+ }
@@ -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
- /** The URL selects the API explicitly; localhost alone never changes authentication or routing. */
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;
@@ -1,4 +1,10 @@
1
- /** The URL selects the API explicitly; localhost alone never changes authentication or routing. */
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>;
package/dist/types.js CHANGED
@@ -698,7 +698,7 @@ export const sdkDeployRequestBodySchema = z
698
698
  cliVersion: z.string(),
699
699
  jobs: z.array(sdkDeployJobSchema),
700
700
  actorTypes: z.array(z.string().min(1)).optional(),
701
- /** Public actor API compiled by little-actors; validated by the control plane on registration. */
701
+ /** Public actor API compiled by durable-actors; validated by the control plane on registration. */
702
702
  actorContract: z.record(z.string(), z.json()).optional(),
703
703
  remoteServerUrl: z.string().optional(),
704
704
  sourceZipBase64: z.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terse-types",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "Shared Terse TypeScript types, enums, constants, and helpers.",
6
6
  "main": "./dist/index.js",