@electric-ax/agents-server 0.4.18 → 0.4.19
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/entrypoint.js +4 -1
- package/dist/index.cjs +4 -1
- package/dist/index.js +4 -1
- package/package.json +5 -5
- package/src/routing/durable-streams-router.ts +13 -0
package/dist/entrypoint.js
CHANGED
|
@@ -2235,7 +2235,10 @@ async function authorizeDurableStreamAccess(request, ctx) {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
if (method === `PUT` || method === `POST`) {
|
|
2237
2237
|
const ownerEntityUrl = request.headers.get(SHARED_STATE_OWNER_ENTITY_HEADER)?.trim() || void 0;
|
|
2238
|
-
if (await canAccessSharedState(ctx, sharedStateId, `write`, request, ownerEntityUrl))
|
|
2238
|
+
if (await canAccessSharedState(ctx, sharedStateId, `write`, request, ownerEntityUrl)) {
|
|
2239
|
+
if (ownerEntityUrl) await ctx.entityManager.registry.replaceSharedStateLink(ownerEntityUrl, `shared-state:${sharedStateId}`, sharedStateId);
|
|
2240
|
+
return void 0;
|
|
2241
|
+
}
|
|
2239
2242
|
return apiError(401, ErrCodeUnauthorized, `Principal is not allowed to write shared state`);
|
|
2240
2243
|
}
|
|
2241
2244
|
return apiError(401, ErrCodeUnauthorized, `Principal is not allowed to access shared state`);
|
package/dist/index.cjs
CHANGED
|
@@ -7922,7 +7922,10 @@ async function authorizeDurableStreamAccess(request, ctx) {
|
|
|
7922
7922
|
}
|
|
7923
7923
|
if (method === `PUT` || method === `POST`) {
|
|
7924
7924
|
const ownerEntityUrl = request.headers.get(SHARED_STATE_OWNER_ENTITY_HEADER)?.trim() || void 0;
|
|
7925
|
-
if (await canAccessSharedState(ctx, sharedStateId, `write`, request, ownerEntityUrl))
|
|
7925
|
+
if (await canAccessSharedState(ctx, sharedStateId, `write`, request, ownerEntityUrl)) {
|
|
7926
|
+
if (ownerEntityUrl) await ctx.entityManager.registry.replaceSharedStateLink(ownerEntityUrl, `shared-state:${sharedStateId}`, sharedStateId);
|
|
7927
|
+
return void 0;
|
|
7928
|
+
}
|
|
7926
7929
|
return apiError(401, ErrCodeUnauthorized, `Principal is not allowed to write shared state`);
|
|
7927
7930
|
}
|
|
7928
7931
|
return apiError(401, ErrCodeUnauthorized, `Principal is not allowed to access shared state`);
|
package/dist/index.js
CHANGED
|
@@ -7893,7 +7893,10 @@ async function authorizeDurableStreamAccess(request, ctx) {
|
|
|
7893
7893
|
}
|
|
7894
7894
|
if (method === `PUT` || method === `POST`) {
|
|
7895
7895
|
const ownerEntityUrl = request.headers.get(SHARED_STATE_OWNER_ENTITY_HEADER)?.trim() || void 0;
|
|
7896
|
-
if (await canAccessSharedState(ctx, sharedStateId, `write`, request, ownerEntityUrl))
|
|
7896
|
+
if (await canAccessSharedState(ctx, sharedStateId, `write`, request, ownerEntityUrl)) {
|
|
7897
|
+
if (ownerEntityUrl) await ctx.entityManager.registry.replaceSharedStateLink(ownerEntityUrl, `shared-state:${sharedStateId}`, sharedStateId);
|
|
7898
|
+
return void 0;
|
|
7899
|
+
}
|
|
7897
7900
|
return apiError(401, ErrCodeUnauthorized, `Principal is not allowed to write shared state`);
|
|
7898
7901
|
}
|
|
7899
7902
|
return apiError(401, ErrCodeUnauthorized, `Principal is not allowed to access shared state`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electric-ax/agents-server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.19",
|
|
4
4
|
"description": "Electric Agents entity runtime server",
|
|
5
5
|
"author": "Durable Stream contributors",
|
|
6
6
|
"bin": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"pino-pretty": "^13.0.0",
|
|
55
55
|
"postgres": "^3.4.0",
|
|
56
56
|
"undici": "^7.24.7",
|
|
57
|
-
"@electric-ax/agents-runtime": "0.3.
|
|
57
|
+
"@electric-ax/agents-runtime": "0.3.12"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^22.19.15",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"tsx": "^4.19.0",
|
|
66
66
|
"typescript": "^5.0.0",
|
|
67
67
|
"vitest": "^4.1.0",
|
|
68
|
-
"@electric-ax/agents
|
|
69
|
-
"@electric-ax/agents": "0.
|
|
70
|
-
"@electric-ax/agents-server-
|
|
68
|
+
"@electric-ax/agents": "0.4.16",
|
|
69
|
+
"@electric-ax/agents-server-conformance-tests": "0.1.11",
|
|
70
|
+
"@electric-ax/agents-server-ui": "0.4.19"
|
|
71
71
|
},
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|
|
@@ -717,6 +717,19 @@ async function authorizeDurableStreamAccess(
|
|
|
717
717
|
ownerEntityUrl
|
|
718
718
|
)
|
|
719
719
|
) {
|
|
720
|
+
// Bootstrap the link synchronously so subsequent reads on this stream
|
|
721
|
+
// (e.g. the runtime's preload right after `mkdb`) can resolve the owner
|
|
722
|
+
// without waiting for the entity's manifest stream event to be
|
|
723
|
+
// processed eventually-consistently. Without this, a brand-new
|
|
724
|
+
// shared-state always 401s on the first preload because the link row
|
|
725
|
+
// is only created later via `applyManifestEntitySource`.
|
|
726
|
+
if (ownerEntityUrl) {
|
|
727
|
+
await ctx.entityManager.registry.replaceSharedStateLink(
|
|
728
|
+
ownerEntityUrl,
|
|
729
|
+
`shared-state:${sharedStateId}`,
|
|
730
|
+
sharedStateId
|
|
731
|
+
)
|
|
732
|
+
}
|
|
720
733
|
return undefined
|
|
721
734
|
}
|
|
722
735
|
return apiError(
|