@opengeni/core 2.7.5-canary.2 → 2.7.5-canary.4
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/access/index.d.ts +7 -0
- package/dist/application/session-commands.d.ts +1 -0
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/access/index.ts +30 -0
- package/src/application/session-commands.ts +32 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/core",
|
|
3
|
-
"version": "2.7.5-canary.
|
|
3
|
+
"version": "2.7.5-canary.4",
|
|
4
4
|
"description": "OpenGeni framework-agnostic core: the domain, access, and billing layers (neutral access, off-HTTP V2 surface). Behavior-preserving extraction from apps/api — keeps Hono's HTTPException for error throwing (typed-errors cleanup deferred).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
57
|
-
"@opengeni/capabilities": "^0.3.2-canary.
|
|
58
|
-
"@opengeni/codex": "^0.2.21-canary.
|
|
59
|
-
"@opengeni/config": "^1.0.0-canary.
|
|
60
|
-
"@opengeni/contracts": "^2.13.0-canary.
|
|
61
|
-
"@opengeni/db": "^4.0.0-canary.
|
|
62
|
-
"@opengeni/documents": "^0.8.19-canary.
|
|
63
|
-
"@opengeni/events": "^0.4.17-canary.
|
|
64
|
-
"@opengeni/network": "^0.3.0-canary.
|
|
65
|
-
"@opengeni/observability": "^0.8.19-canary.
|
|
66
|
-
"@opengeni/runtime": "^2.3.0-canary.
|
|
67
|
-
"@opengeni/storage": "^0.2.120-canary.
|
|
57
|
+
"@opengeni/capabilities": "^0.3.2-canary.4",
|
|
58
|
+
"@opengeni/codex": "^0.2.21-canary.4",
|
|
59
|
+
"@opengeni/config": "^1.0.0-canary.4",
|
|
60
|
+
"@opengeni/contracts": "^2.13.0-canary.4",
|
|
61
|
+
"@opengeni/db": "^4.0.0-canary.4",
|
|
62
|
+
"@opengeni/documents": "^0.8.19-canary.4",
|
|
63
|
+
"@opengeni/events": "^0.4.17-canary.4",
|
|
64
|
+
"@opengeni/network": "^0.3.0-canary.4",
|
|
65
|
+
"@opengeni/observability": "^0.8.19-canary.4",
|
|
66
|
+
"@opengeni/runtime": "^2.3.0-canary.4",
|
|
67
|
+
"@opengeni/storage": "^0.2.120-canary.4",
|
|
68
68
|
"hono": "^4.12.18",
|
|
69
69
|
"zod": "^4.2.1"
|
|
70
70
|
},
|
package/src/access/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
findActiveApiKeyByHash,
|
|
13
13
|
getWorkspaceGrant,
|
|
14
14
|
requireWorkspace,
|
|
15
|
+
resolveNamedManagedPersonalWorkspaceGrant,
|
|
15
16
|
type Database,
|
|
16
17
|
} from "@opengeni/db";
|
|
17
18
|
import type { Context } from "hono";
|
|
@@ -309,6 +310,35 @@ export async function requireAccessGrantAuthorization(
|
|
|
309
310
|
return await accessGrantAuthorization(context, deps, workspaceId, permission);
|
|
310
311
|
}
|
|
311
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Settings administration is narrower than workspace administration. The
|
|
315
|
+
* canonical managed-cookie owner may configure their Personal workspace, but
|
|
316
|
+
* never acquires the admin wildcard (and its membership/delegation powers).
|
|
317
|
+
* Only use this boundary for workspace configuration, not access management.
|
|
318
|
+
*/
|
|
319
|
+
export async function requireWorkspaceSettingsGrant(
|
|
320
|
+
c: Context,
|
|
321
|
+
deps: AccessDeps,
|
|
322
|
+
workspaceId: string,
|
|
323
|
+
): Promise<AccessGrant> {
|
|
324
|
+
const authorization = await requireAccessGrantAuthorization(c, deps, workspaceId);
|
|
325
|
+
const grant = requireResolvedAccessGrantAuthorization(authorization, workspaceId);
|
|
326
|
+
if (hasPermission(grant.permissions, "workspace:admin")) return grant;
|
|
327
|
+
if (
|
|
328
|
+
authorization.canonicalManagedHumanSession &&
|
|
329
|
+
(await resolveNamedManagedPersonalWorkspaceGrant(deps.db, {
|
|
330
|
+
accountId: grant.accountId,
|
|
331
|
+
workspaceId,
|
|
332
|
+
subjectId: authorization.authenticatedSubjectId,
|
|
333
|
+
}))
|
|
334
|
+
) {
|
|
335
|
+
return grant;
|
|
336
|
+
}
|
|
337
|
+
throw new HTTPException(403, {
|
|
338
|
+
message: "workspace settings require a workspace administrator or Personal workspace owner",
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
312
342
|
async function accessGrantAuthorization(
|
|
313
343
|
context: AccessContext,
|
|
314
344
|
deps: AccessDeps,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
moveQueuedTurnInTransaction,
|
|
29
29
|
mutateSessionControlInTransaction,
|
|
30
30
|
mutateWorkspaceControlInTransaction,
|
|
31
|
+
setWorkspacePauseTimerInTransaction,
|
|
31
32
|
projectEffectiveControlForRelatedAccess,
|
|
32
33
|
runIdempotentPersistenceTransaction,
|
|
33
34
|
saveComposerDraftInTransaction,
|
|
@@ -1065,3 +1066,34 @@ export async function saveHumanComposerDraft(
|
|
|
1065
1066
|
);
|
|
1066
1067
|
return composerDraft(row)!;
|
|
1067
1068
|
}
|
|
1069
|
+
|
|
1070
|
+
export async function controlHumanWorkspaceTimer(
|
|
1071
|
+
deps: Parameters<typeof controlHumanWorkspace>[0],
|
|
1072
|
+
context: Parameters<typeof controlHumanWorkspace>[1],
|
|
1073
|
+
input: import("@opengeni/contracts").WorkspacePauseTimerRequest,
|
|
1074
|
+
): Promise<void> {
|
|
1075
|
+
const result = await withWorkspaceRls(deps.db, context.workspaceId, (scoped) =>
|
|
1076
|
+
scoped.transaction((tx) =>
|
|
1077
|
+
setWorkspacePauseTimerInTransaction(tx as unknown as Database, {
|
|
1078
|
+
...input,
|
|
1079
|
+
...context,
|
|
1080
|
+
}),
|
|
1081
|
+
),
|
|
1082
|
+
);
|
|
1083
|
+
scheduleSessionCommandPostCommit(deps, "human_workspace_timer", [
|
|
1084
|
+
...(result.workspaceControlEventId
|
|
1085
|
+
? [
|
|
1086
|
+
{
|
|
1087
|
+
kind: "workspace_control_fanout" as const,
|
|
1088
|
+
run: async () =>
|
|
1089
|
+
await publishWorkspaceControlEvent(
|
|
1090
|
+
deps,
|
|
1091
|
+
context.workspaceId,
|
|
1092
|
+
result.workspaceControlEventId!,
|
|
1093
|
+
),
|
|
1094
|
+
},
|
|
1095
|
+
]
|
|
1096
|
+
: []),
|
|
1097
|
+
{ kind: "workflow_wake" as const, run: async () => await requestControlWakeDispatch(deps, 1) },
|
|
1098
|
+
]);
|
|
1099
|
+
}
|