terse-types 0.6.1 → 0.6.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.
@@ -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;
@@ -0,0 +1,4 @@
1
+ export declare const ACTOR_ENTRY_FILE = "src/actor.ts";
2
+ export declare const LEGACY_ACTOR_ENTRY_FILE = "src/actors.ts";
3
+ /** Share discovery between the local CLI and uploaded deployment archives. */
4
+ export declare function findActorEntryFile(hasFile: (file: string) => boolean): string | undefined;
@@ -0,0 +1,6 @@
1
+ export const ACTOR_ENTRY_FILE = "src/actor.ts";
2
+ export const LEGACY_ACTOR_ENTRY_FILE = "src/actors.ts";
3
+ /** Share discovery between the local CLI and uploaded deployment archives. */
4
+ export function findActorEntryFile(hasFile) {
5
+ return [ACTOR_ENTRY_FILE, LEGACY_ACTOR_ENTRY_FILE].find(hasFile);
6
+ }
@@ -0,0 +1,5 @@
1
+ /** Keep this key and cutoff aligned with the Actors-only flag in PostHog. */
2
+ export declare const ACTORS_ONLY_FLAG = "Actors-only";
3
+ export declare const ACTORS_ONLY_ROLLOUT_AT = "2026-09-23T18:23:42.000Z";
4
+ /** Preserve legacy accounts when flags are unavailable, including older identities without a date. */
5
+ export declare function actorsOnlyDefault(createdAt?: string): boolean;
@@ -0,0 +1,7 @@
1
+ /** Keep this key and cutoff aligned with the Actors-only flag in PostHog. */
2
+ export const ACTORS_ONLY_FLAG = "Actors-only";
3
+ export const ACTORS_ONLY_ROLLOUT_AT = "2026-09-23T18:23:42.000Z";
4
+ /** Preserve legacy accounts when flags are unavailable, including older identities without a date. */
5
+ export function actorsOnlyDefault(createdAt) {
6
+ return !!createdAt && Date.parse(createdAt) >= Date.parse(ACTORS_ONLY_ROLLOUT_AT);
7
+ }
package/dist/types.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare const userProfileSchema: z.ZodObject<{
13
13
  displayName: z.ZodString;
14
14
  firstName: z.ZodNullable<z.ZodString>;
15
15
  lastName: z.ZodNullable<z.ZodString>;
16
+ createdAt: z.ZodOptional<z.ZodString>;
16
17
  displayPhotoUrl: z.ZodString;
17
18
  }, z.core.$strip>;
18
19
  export type UserProfile = z.infer<typeof userProfileSchema>;
@@ -22,6 +23,7 @@ export declare const userSessionSchema: z.ZodObject<{
22
23
  displayName: z.ZodString;
23
24
  firstName: z.ZodNullable<z.ZodString>;
24
25
  lastName: z.ZodNullable<z.ZodString>;
26
+ createdAt: z.ZodOptional<z.ZodString>;
25
27
  displayPhotoUrl: z.ZodString;
26
28
  organizationId: z.ZodString;
27
29
  organizationName: z.ZodString;
@@ -29,6 +31,7 @@ export declare const userSessionSchema: z.ZodObject<{
29
31
  user: "user";
30
32
  admin: "admin";
31
33
  }>>;
34
+ actorsOnly: z.ZodOptional<z.ZodBoolean>;
32
35
  }, z.core.$strip>;
33
36
  export type UserSession = z.infer<typeof userSessionSchema>;
34
37
  export declare const organizationSchema: z.ZodObject<{
@@ -291,8 +294,8 @@ export declare const deviceTokenExchangeResponseSchema: z.ZodObject<{
291
294
  export type DeviceTokenExchangeResponse = z.infer<typeof deviceTokenExchangeResponseSchema>;
292
295
  export declare const authModeResponseSchema: z.ZodObject<{
293
296
  mode: z.ZodEnum<{
294
- workos: "workos";
295
297
  local: "local";
298
+ workos: "workos";
296
299
  }>;
297
300
  }, z.core.$strip>;
298
301
  export type AuthModeResponse = z.infer<typeof authModeResponseSchema>;
@@ -14212,6 +14215,7 @@ export declare const projectDetailResponseSchema: z.ZodObject<{
14212
14215
  isSelfHosted: z.ZodBoolean;
14213
14216
  hasSigningSecret: z.ZodBoolean;
14214
14217
  hasProjectApiKey: z.ZodBoolean;
14218
+ actorTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
14215
14219
  jobs: z.ZodArray<z.ZodObject<{
14216
14220
  id: z.ZodString;
14217
14221
  name: z.ZodString;
package/dist/types.js CHANGED
@@ -12,12 +12,14 @@ export const userProfileSchema = z.object({
12
12
  displayName: z.string(),
13
13
  firstName: z.string().nullable(),
14
14
  lastName: z.string().nullable(),
15
+ createdAt: z.string().optional(),
15
16
  displayPhotoUrl: z.string()
16
17
  });
17
18
  export const userSessionSchema = userProfileSchema.extend({
18
19
  organizationId: z.string(),
19
20
  organizationName: z.string(),
20
- roles: z.array(roleSchema)
21
+ roles: z.array(roleSchema),
22
+ actorsOnly: z.boolean().optional()
21
23
  });
22
24
  export const organizationSchema = z.object({
23
25
  id: z.string(),
@@ -624,6 +626,7 @@ export const projectDetailResponseSchema = z.object({
624
626
  isSelfHosted: z.boolean(),
625
627
  hasSigningSecret: z.boolean(),
626
628
  hasProjectApiKey: z.boolean(),
629
+ actorTypes: z.array(z.string()).optional(),
627
630
  jobs: z.array(z.object({
628
631
  id: z.string(),
629
632
  name: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terse-types",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "description": "Shared Terse TypeScript types, enums, constants, and helpers.",
6
6
  "main": "./dist/index.js",