terse-sdk 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.
- package/README.md +1 -1
- package/dist/actorHost.d.ts +1 -1
- package/dist/actorHost.d.ts.map +1 -1
- package/dist/actorHost.js +1 -1
- package/dist/actorHost.js.map +1 -1
- package/dist/actors.d.ts.map +1 -1
- package/dist/actors.js +19 -9
- package/dist/actors.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ createJob({
|
|
|
51
51
|
|
|
52
52
|
## Core concepts
|
|
53
53
|
|
|
54
|
-
For actor development, run `terse actor
|
|
54
|
+
For actor development, run `terse actor dev` in the actor source project, then `terse actor generate` in your app project. Both the generator and SDK default to the local server on port `7100`, project `local`, with no API key. Set `TERSE_ACTOR_URL` and, when required, `TERSE_API_KEY` only to override those defaults or connect to deployed actors. Regenerate after public API changes. See the [local actor development guide](../terse-cli/README.md#developing-actors).
|
|
55
55
|
|
|
56
56
|
| Concept | What it is |
|
|
57
57
|
|---|---|
|
package/dist/actorHost.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { runActorHost } from "durable-actors/host";
|
|
2
2
|
//# sourceMappingURL=actorHost.d.ts.map
|
package/dist/actorHost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actorHost.d.ts","sourceRoot":"","sources":["../src/actorHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"actorHost.d.ts","sourceRoot":"","sources":["../src/actorHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/actorHost.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { runActorHost } from "durable-actors/host";
|
|
2
2
|
//# sourceMappingURL=actorHost.js.map
|
package/dist/actorHost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actorHost.js","sourceRoot":"","sources":["../src/actorHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"actorHost.js","sourceRoot":"","sources":["../src/actorHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/actors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../src/actors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAmE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../src/actors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAmE,MAAM,wBAAwB,CAAA;AAMrJ,OAAO,EAAc,KAAK,UAAU,EAAE,KAAK,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAmCzG,wBAAgB,eAAe,CAAC,IAAI,SAAS,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,SAAS,GAAE,iBAAkC,GAAG,IAAI,CAEhL;AAWD,MAAM,WAAW,uBAAuB;IACpC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAClC;AAED,qBAAa,WAAW,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,uBAA4B;IAGzD,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;CAkBjF;AAED,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/actors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createActorTransport, createActorStub as createDurableActorStub } from "durable-actors/backend";
|
|
2
2
|
import { SocketProxy as RuntimeSocketProxy } from "durable-actors/proxy";
|
|
3
|
-
import {
|
|
3
|
+
import { rethrowActorError } from "terse-types/ActorDiagnostics";
|
|
4
|
+
import { DEFAULT_ACTOR_URL, isLocalActorEndpoint, parseActorEndpoint } from "terse-types/ActorEndpoint";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import { ActorProxy } from "./actorProxy.js";
|
|
6
7
|
const invocationResultSchema = z.object({ result: z.json() });
|
|
@@ -9,7 +10,12 @@ const terseTransport = {
|
|
|
9
10
|
const { endpoint, apiKey } = actorConnectionSettings();
|
|
10
11
|
if (endpoint.kind === "runtime") {
|
|
11
12
|
// Source reloads replace actor hosts. Resolve the current host for each call.
|
|
12
|
-
|
|
13
|
+
try {
|
|
14
|
+
return await createActorTransport({ projectId: endpoint.projectId, controlPlaneUrl: endpoint.origin, apiKey: apiKey || undefined }).invoke(actorName, actorId, method, args);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
rethrowActorError(error);
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
const response = await fetch(`${endpoint.actorUrl}/invoke`, {
|
|
15
21
|
method: "POST",
|
|
@@ -33,13 +39,12 @@ export function createActorStub(actorName, actorId, methods, transport = terseTr
|
|
|
33
39
|
return createDurableActorStub(actorName, actorId, methods, transport);
|
|
34
40
|
}
|
|
35
41
|
function actorConnectionSettings() {
|
|
36
|
-
const
|
|
37
|
-
const apiKey = process.env.TERSE_API_KEY?.trim();
|
|
38
|
-
if (!
|
|
39
|
-
|
|
40
|
-
throw new Error(`Missing ${missing.join(" and ")}. Set ${missing.length === 1 ? "it" : "them"} in the .env of the project calling the actor.`);
|
|
42
|
+
const endpoint = parseActorEndpoint(process.env.TERSE_ACTOR_URL?.trim() || DEFAULT_ACTOR_URL);
|
|
43
|
+
const apiKey = process.env.TERSE_API_KEY?.trim() || "";
|
|
44
|
+
if (!apiKey && !isLocalActorEndpoint(endpoint)) {
|
|
45
|
+
throw new Error("Missing TERSE_API_KEY. Set it in the .env of the project calling the actor.");
|
|
41
46
|
}
|
|
42
|
-
return { endpoint
|
|
47
|
+
return { endpoint, apiKey };
|
|
43
48
|
}
|
|
44
49
|
export class SocketProxy {
|
|
45
50
|
actors;
|
|
@@ -51,7 +56,12 @@ export class SocketProxy {
|
|
|
51
56
|
async handle(authorization) {
|
|
52
57
|
const { endpoint, apiKey } = actorConnectionSettings();
|
|
53
58
|
if (endpoint.kind === "runtime") {
|
|
54
|
-
|
|
59
|
+
try {
|
|
60
|
+
return await new RuntimeSocketProxy(this.actors, { projectId: endpoint.projectId, controlPlaneUrl: endpoint.origin, apiKey: apiKey || undefined }, this.dependencies).handle(authorization);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
rethrowActorError(error);
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
return new ActorProxy(this.actors, {
|
|
57
67
|
projectId: endpoint.projectId,
|
package/dist/actors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actors.js","sourceRoot":"","sources":["../src/actors.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,oBAAoB,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACrJ,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"actors.js","sourceRoot":"","sources":["../src/actors.ts"],"names":[],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,YACqB,MAAc,EACd,eAAwC,EAAE;QAD1C,WAAM,GAAN,MAAM,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAA8B;IAC5D,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,aAA0C;QACnD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,uBAAuB,EAAE,CAAA;QACtD,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC;gBACD,OAAO,MAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,SAAS,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CACxK,aAAa,CAChB,CAAA;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,iBAAiB,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;QACL,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE;YAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,UAAU,EAAE,MAAM;YAClB,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK;SACjC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IAC5B,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terse-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"repository": {
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"zod": "^4.3.6"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"durable-actors": "0.
|
|
45
|
+
"durable-actors": "0.3.1",
|
|
46
46
|
"little-durable": "0.1.3",
|
|
47
47
|
"ms": "2.1.3",
|
|
48
|
-
"terse-types": "0.6.
|
|
48
|
+
"terse-types": "0.6.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "rm -rf dist && tsc",
|