@haneinfo/state-machine 0.8.0 → 0.10.0
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 +65 -0
- package/agent-guide.md +65 -0
- package/dist/access.d.ts +28 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +21 -0
- package/dist/access.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/instance-access.controller.d.ts +24 -0
- package/dist/instance-access.controller.d.ts.map +1 -0
- package/dist/instance-access.controller.js +67 -0
- package/dist/instance-access.controller.js.map +1 -0
- package/dist/instance-access.service.d.ts +53 -0
- package/dist/instance-access.service.d.ts.map +1 -0
- package/dist/instance-access.service.js +208 -0
- package/dist/instance-access.service.js.map +1 -0
- package/dist/mcp-tools.d.ts +3 -1
- package/dist/mcp-tools.d.ts.map +1 -1
- package/dist/mcp-tools.js +37 -2
- package/dist/mcp-tools.js.map +1 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -2
- package/dist/plugin.js.map +1 -1
- package/dist/prisma-store.d.ts.map +1 -1
- package/dist/prisma-store.js +52 -11
- package/dist/prisma-store.js.map +1 -1
- package/dist/reader-grants.d.ts +1 -1
- package/dist/reader-grants.d.ts.map +1 -1
- package/dist/reader-grants.js +4 -2
- package/dist/reader-grants.js.map +1 -1
- package/dist/runtime.service.d.ts +4 -2
- package/dist/runtime.service.d.ts.map +1 -1
- package/dist/runtime.service.js +65 -33
- package/dist/runtime.service.js.map +1 -1
- package/dist/state-machine.module.d.ts.map +1 -1
- package/dist/state-machine.module.js +5 -1
- package/dist/state-machine.module.js.map +1 -1
- package/dist/store.d.ts +11 -3
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +42 -8
- package/dist/store.js.map +1 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/haneinfo.plugin.json +10 -4
- package/package.json +5 -5
- package/prisma/instance-access.sql +50 -0
- package/prisma/state-machine.prisma +13 -9
package/README.md
CHANGED
|
@@ -41,3 +41,68 @@ matching instants with different textual offsets are still unequal for those ope
|
|
|
41
41
|
All person-facing instance reads (detail including history, available transitions and exact number lookup) return `INSTANCE_NOT_FOUND`, HTTP 404, message `Instance not found`, with no suggestion for both missing and unreadable instances. No read permission name is exposed. USER transitions and data updates check readability before revision, state and write authorization; readable users missing the write/business permission still receive 403. Submitter ownership, effective instance:read and permanent reader grants are unchanged. Internal `get`/`history` remain trusted mechanism APIs without a person parameter; there is no delete endpoint.
|
|
42
42
|
|
|
43
43
|
Authorized detail, instance list and numbering reads include `submitterName: string | null`. Optional identity-store `findActiveNamesByIds` resolves unique submitter ids once per result batch. Missing, inactive and deleted identities, absent identity capability and older providers return null without per-row fallbacks. No schema migration or people-lookup HTTP route is added. Numbering MCP wraps names in `$userContent`; exact unreadable/missing numbers return the same error, while recent-number lists still filter before paging.
|
|
44
|
+
|
|
45
|
+
## Delegated Assignment attribution
|
|
46
|
+
|
|
47
|
+
ASSIGNMENT triggers may include optional actingUserId and onBehalfOfId. Existing userId and
|
|
48
|
+
triggerUserId remain the actual actor. Attribution is persisted in the existing transition decision
|
|
49
|
+
JSON and exposed as optional history fields, including getFor's embedded history. Notification
|
|
50
|
+
outcomes merge with this metadata instead of replacing it. No history schema migration is needed.
|
|
51
|
+
The decision remains draft (202610-6b1f). Assignment owns delegation validity and response policy.
|
|
52
|
+
|
|
53
|
+
When the resolver is installed, StateMachine takes its optional shared transaction advisory lock
|
|
54
|
+
before instance creation or any instance row lock/write. Delegation creation/revocation takes the
|
|
55
|
+
exclusive lock on the same key. Normal instance transactions remain concurrent; a graph mutation
|
|
56
|
+
briefly blocks new instance writers until its backfill/cancellation commits. This closes the race
|
|
57
|
+
where creation and state entry could otherwise miss each other's uncommitted rows. The advisory lock always precedes instance locks; task CAS and delegation-row shared locks
|
|
58
|
+
remain inside that transaction. No extra table or worker is added.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Instance access lists (draft implementation)
|
|
62
|
+
|
|
63
|
+
Implemented against draft decision 202610-c8e3; the decision remains draft. This section supersedes
|
|
64
|
+
the earlier reader-only model and human transition eligibility. Upgrade the affected
|
|
65
|
+
mechanisms together and apply the App migration before starting the new runtime. The maintainer
|
|
66
|
+
selected source-specific uniqueness: `(instanceId, principalType, principalId, source)`. Existing
|
|
67
|
+
model/table names are retained. `principalType` is USER or ROLE; `principalId` is a user id or role
|
|
68
|
+
machine name; `level` is READ or WRITE; `source` is ASSIGNED, DELEGATED or GRANTED. Each row also
|
|
69
|
+
has nullable grantedBy and createdAt. Indexes cover instanceId and (principalType, principalId).
|
|
70
|
+
Permanent ASSIGNED/DELEGATED entries are READ and survive every task/delegation status. Manual
|
|
71
|
+
GRANTED entries coexist with them; removing GRANTED never removes permanent readership.
|
|
72
|
+
|
|
73
|
+
All instance reads use submitter, effective state-machine:instance:read, or a matching USER/ROLE
|
|
74
|
+
entry. Roles come from RBAC authorizationOfUser once per query, passed into persistence; no direct
|
|
75
|
+
RBAC-table joins. WRITE also requires an existing readable instance, then submitter, effective
|
|
76
|
+
state-machine:instance:write, or matching WRITE. Human transitions still check their declared
|
|
77
|
+
business permission. Assignment/Timer transition authorization is unchanged. Unreadable instances
|
|
78
|
+
return INSTANCE_NOT_FOUND/404; readable callers without write/manage eligibility receive 403.
|
|
79
|
+
|
|
80
|
+
Only the submitter or state-machine:instance:admin can manage access; instance administrators can
|
|
81
|
+
manage any instance list. Grantees cannot regrant. InteractiveAuthGuard protects GET/PUT
|
|
82
|
+
/state-machine-instances/:id/access and DELETE /state-machine-instances/:id/access/:principalType/:principalId.
|
|
83
|
+
PUT targets GRANTED only, never changes permanent rows. DELETE removes GRANTED if present; a
|
|
84
|
+
permanent-only target returns ACCESS_NOT_MANAGEABLE/409. Missing manual targets are idempotent.
|
|
85
|
+
GET returns sources, levels, principalName and grantedByName; user names share one authorized
|
|
86
|
+
findActiveNamesByIds batch, role display labels share one RBAC lookup, unavailable names are null.
|
|
87
|
+
Names are plain text. maxGrantedAccess defaults to 100. Only active users or existing roles can be
|
|
88
|
+
granted; the submitter cannot receive a USER grant. Errors include ACCESS_PRINCIPAL_INVALID/400,
|
|
89
|
+
ACCESS_LIMIT_EXCEEDED/409 and ACCESS_NOT_MANAGEABLE/409. Repeated equal grants have no effects.
|
|
90
|
+
|
|
91
|
+
StateMachineMcpTools.registerInto now also registers list_instance_access using <namespace>:instance:read.
|
|
92
|
+
It returns items in $userContent and offers no grant/remove tools. Changed individual grants notify
|
|
93
|
+
with state-machine-access:<historyId>; equal retries do not notify again. Role grants and removals
|
|
94
|
+
never notify. Missing inbox capability skips delivery. Actual inbox failures roll back the mutation.
|
|
95
|
+
ACCESS history uses the existing decision JSON and emits state-machine.access.recorded in the
|
|
96
|
+
same transaction; collaboration adds ACCESS to its existing SQL timeline union. State, revision and
|
|
97
|
+
transition events do not change for access mutations. List/export counts and pagination include
|
|
98
|
+
personal and role access in one parameterized EXISTS; snapshot exports abort on role-name changes.
|
|
99
|
+
|
|
100
|
+
Migration SQL ships at @haneinfo/state-machine/prisma/instance-access.sql. It renames user_id to
|
|
101
|
+
principal_id and reason to source, preserves created_at, adds principal_type/level/granted_by,
|
|
102
|
+
converts legacy rows to USER/READ and ASSIGNED (recognized delegation becomes DELEGATED), and
|
|
103
|
+
backfills every assignment task regardless of status. It expects the Assignment delegation columns;
|
|
104
|
+
Apps without Assignment/Delegation must omit the corresponding task queries/backfill. Do not reset
|
|
105
|
+
an existing database. See the package repository validation/equipment-loan/instance-access/report.md
|
|
106
|
+
for adoption evidence and the explicitly selected uniqueness adjustment; no decision text is changed.
|
|
107
|
+
|
|
108
|
+
Configure runtime.stateMachine.maxGrantedAccess (positive integer, default 100). Apply prisma/instance-access.sql in your App migration before upgrading. Custom StateMachineStore implementations must implement listAccess, putGranted and deleteGranted and accept optional roles/source/level in reader methods. The new optional RBAC role-label lookup requires plugin API 1.14.0.
|
package/agent-guide.md
CHANGED
|
@@ -281,3 +281,68 @@ matching instants with different textual offsets are still unequal for those ope
|
|
|
281
281
|
All person-facing instance reads (detail including history, available transitions and exact number lookup) return `INSTANCE_NOT_FOUND`, HTTP 404, message `Instance not found`, with no suggestion for both missing and unreadable instances. No read permission name is exposed. USER transitions and data updates check readability before revision, state and write authorization; readable users missing the write/business permission still receive 403. Submitter ownership, effective instance:read and permanent reader grants are unchanged. Internal `get`/`history` remain trusted mechanism APIs without a person parameter; there is no delete endpoint.
|
|
282
282
|
|
|
283
283
|
Authorized detail, instance list and numbering reads include `submitterName: string | null`. Optional identity-store `findActiveNamesByIds` resolves unique submitter ids once per result batch. Missing, inactive and deleted identities, absent identity capability and older providers return null without per-row fallbacks. No schema migration or people-lookup HTTP route is added. Numbering MCP wraps names in `$userContent`; exact unreadable/missing numbers return the same error, while recent-number lists still filter before paging.
|
|
284
|
+
|
|
285
|
+
## Delegated Assignment attribution
|
|
286
|
+
|
|
287
|
+
ASSIGNMENT triggers may include optional actingUserId and onBehalfOfId. Existing userId and
|
|
288
|
+
triggerUserId remain the actual actor. Attribution is persisted in the existing transition decision
|
|
289
|
+
JSON and exposed as optional history fields, including getFor's embedded history. Notification
|
|
290
|
+
outcomes merge with this metadata instead of replacing it. No history schema migration is needed.
|
|
291
|
+
The decision remains draft (202610-6b1f). Assignment owns delegation validity and response policy.
|
|
292
|
+
|
|
293
|
+
When the resolver is installed, StateMachine takes its optional shared transaction advisory lock
|
|
294
|
+
before instance creation or any instance row lock/write. Delegation creation/revocation takes the
|
|
295
|
+
exclusive lock on the same key. Normal instance transactions remain concurrent; a graph mutation
|
|
296
|
+
briefly blocks new instance writers until its backfill/cancellation commits. This closes the race
|
|
297
|
+
where creation and state entry could otherwise miss each other's uncommitted rows. The advisory lock always precedes instance locks; task CAS and delegation-row shared locks
|
|
298
|
+
remain inside that transaction. No extra table or worker is added.
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
## Instance access lists (draft implementation)
|
|
302
|
+
|
|
303
|
+
Implemented against draft decision 202610-c8e3; the decision remains draft. This section supersedes
|
|
304
|
+
the earlier reader-only model and human transition eligibility. Upgrade the affected
|
|
305
|
+
mechanisms together and apply the App migration before starting the new runtime. The maintainer
|
|
306
|
+
selected source-specific uniqueness: `(instanceId, principalType, principalId, source)`. Existing
|
|
307
|
+
model/table names are retained. `principalType` is USER or ROLE; `principalId` is a user id or role
|
|
308
|
+
machine name; `level` is READ or WRITE; `source` is ASSIGNED, DELEGATED or GRANTED. Each row also
|
|
309
|
+
has nullable grantedBy and createdAt. Indexes cover instanceId and (principalType, principalId).
|
|
310
|
+
Permanent ASSIGNED/DELEGATED entries are READ and survive every task/delegation status. Manual
|
|
311
|
+
GRANTED entries coexist with them; removing GRANTED never removes permanent readership.
|
|
312
|
+
|
|
313
|
+
All instance reads use submitter, effective state-machine:instance:read, or a matching USER/ROLE
|
|
314
|
+
entry. Roles come from RBAC authorizationOfUser once per query, passed into persistence; no direct
|
|
315
|
+
RBAC-table joins. WRITE also requires an existing readable instance, then submitter, effective
|
|
316
|
+
state-machine:instance:write, or matching WRITE. Human transitions still check their declared
|
|
317
|
+
business permission. Assignment/Timer transition authorization is unchanged. Unreadable instances
|
|
318
|
+
return INSTANCE_NOT_FOUND/404; readable callers without write/manage eligibility receive 403.
|
|
319
|
+
|
|
320
|
+
Only the submitter or state-machine:instance:admin can manage access; instance administrators can
|
|
321
|
+
manage any instance list. Grantees cannot regrant. InteractiveAuthGuard protects GET/PUT
|
|
322
|
+
/state-machine-instances/:id/access and DELETE /state-machine-instances/:id/access/:principalType/:principalId.
|
|
323
|
+
PUT targets GRANTED only, never changes permanent rows. DELETE removes GRANTED if present; a
|
|
324
|
+
permanent-only target returns ACCESS_NOT_MANAGEABLE/409. Missing manual targets are idempotent.
|
|
325
|
+
GET returns sources, levels, principalName and grantedByName; user names share one authorized
|
|
326
|
+
findActiveNamesByIds batch, role display labels share one RBAC lookup, unavailable names are null.
|
|
327
|
+
Names are plain text. maxGrantedAccess defaults to 100. Only active users or existing roles can be
|
|
328
|
+
granted; the submitter cannot receive a USER grant. Errors include ACCESS_PRINCIPAL_INVALID/400,
|
|
329
|
+
ACCESS_LIMIT_EXCEEDED/409 and ACCESS_NOT_MANAGEABLE/409. Repeated equal grants have no effects.
|
|
330
|
+
|
|
331
|
+
StateMachineMcpTools.registerInto now also registers list_instance_access using <namespace>:instance:read.
|
|
332
|
+
It returns items in $userContent and offers no grant/remove tools. Changed individual grants notify
|
|
333
|
+
with state-machine-access:<historyId>; equal retries do not notify again. Role grants and removals
|
|
334
|
+
never notify. Missing inbox capability skips delivery. Actual inbox failures roll back the mutation.
|
|
335
|
+
ACCESS history uses the existing decision JSON and emits state-machine.access.recorded in the
|
|
336
|
+
same transaction; collaboration adds ACCESS to its existing SQL timeline union. State, revision and
|
|
337
|
+
transition events do not change for access mutations. List/export counts and pagination include
|
|
338
|
+
personal and role access in one parameterized EXISTS; snapshot exports abort on role-name changes.
|
|
339
|
+
|
|
340
|
+
Migration SQL ships at @haneinfo/state-machine/prisma/instance-access.sql. It renames user_id to
|
|
341
|
+
principal_id and reason to source, preserves created_at, adds principal_type/level/granted_by,
|
|
342
|
+
converts legacy rows to USER/READ and ASSIGNED (recognized delegation becomes DELEGATED), and
|
|
343
|
+
backfills every assignment task regardless of status. It expects the Assignment delegation columns;
|
|
344
|
+
Apps without Assignment/Delegation must omit the corresponding task queries/backfill. Do not reset
|
|
345
|
+
an existing database. See the package repository validation/equipment-loan/instance-access/report.md
|
|
346
|
+
for adoption evidence and the explicitly selected uniqueness adjustment; no decision text is changed.
|
|
347
|
+
|
|
348
|
+
Configure runtime.stateMachine.maxGrantedAccess (positive integer, default 100). Apply prisma/instance-access.sql in your App migration before upgrading. Custom StateMachineStore implementations must implement listAccess, putGranted and deleteGranted and accept optional roles/source/level in reader methods. The new optional RBAC role-label lookup requires plugin API 1.14.0.
|
package/dist/access.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type PrincipalAuthorization } from '@haneinfo/plugin-api';
|
|
2
|
+
import type { InstanceRecord, StateMachineStoreTx } from './store';
|
|
3
|
+
export type AccessPrincipalType = 'USER' | 'ROLE';
|
|
4
|
+
export type AccessLevel = 'READ' | 'WRITE';
|
|
5
|
+
export type AccessSource = 'ASSIGNED' | 'DELEGATED' | 'GRANTED';
|
|
6
|
+
export interface InstanceAccessRecord {
|
|
7
|
+
instanceId: string;
|
|
8
|
+
principalType: AccessPrincipalType;
|
|
9
|
+
principalId: string;
|
|
10
|
+
level: AccessLevel;
|
|
11
|
+
source: AccessSource;
|
|
12
|
+
grantedBy: string | null;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
}
|
|
15
|
+
/** Roles are resolved once by the caller, never by the persistence layer. */
|
|
16
|
+
export declare function instanceAccessAllowed(userId: string, record: InstanceRecord, authorization: PrincipalAuthorization, store: StateMachineStoreTx, level?: AccessLevel): Promise<boolean>;
|
|
17
|
+
export declare function accessPrincipalWhere(userId: string, roleNames?: readonly string[]): {
|
|
18
|
+
OR: ({
|
|
19
|
+
principalType: string;
|
|
20
|
+
principalId: string;
|
|
21
|
+
} | {
|
|
22
|
+
principalType: string;
|
|
23
|
+
principalId: {
|
|
24
|
+
in: string[];
|
|
25
|
+
};
|
|
26
|
+
})[];
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;AAC3C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAChE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,mBAAmB,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,6EAA6E;AAC7E,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,sBAAsB,EACrC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,GAAE,WAAoB,oBAQ5B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAS,MAAM,EAAO;;;;;;;;;;EAOrF"}
|
package/dist/access.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instanceAccessAllowed = instanceAccessAllowed;
|
|
4
|
+
exports.accessPrincipalWhere = accessPrincipalWhere;
|
|
5
|
+
const plugin_api_1 = require("@haneinfo/plugin-api");
|
|
6
|
+
/** Roles are resolved once by the caller, never by the persistence layer. */
|
|
7
|
+
async function instanceAccessAllowed(userId, record, authorization, store, level = 'READ') {
|
|
8
|
+
return Boolean(userId &&
|
|
9
|
+
(record.submitterId === userId ||
|
|
10
|
+
(0, plugin_api_1.hasPermission)(authorization, `state-machine:instance:${level.toLowerCase()}`) ||
|
|
11
|
+
(await store.isReader(record.id, userId, authorization.roleNames, level))));
|
|
12
|
+
}
|
|
13
|
+
function accessPrincipalWhere(userId, roleNames = []) {
|
|
14
|
+
return {
|
|
15
|
+
OR: [
|
|
16
|
+
{ principalType: 'USER', principalId: userId },
|
|
17
|
+
{ principalType: 'ROLE', principalId: { in: [...roleNames] } },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":";;AAiBA,sDAaC;AAED,oDAOC;AAvCD,qDAAkF;AAgBlF,6EAA6E;AACtE,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,MAAsB,EACtB,aAAqC,EACrC,KAA0B,EAC1B,QAAqB,MAAM;IAE3B,OAAO,OAAO,CACZ,MAAM;QACJ,CAAC,MAAM,CAAC,WAAW,KAAK,MAAM;YAC5B,IAAA,0BAAa,EAAC,aAAa,EAAE,0BAA0B,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7E,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAC/E,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAc,EAAE,YAA+B,EAAE;IACpF,OAAO;QACL,EAAE,EAAE;YACF,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE;YAC9C,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE;SAC/D;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export * from './access';
|
|
2
|
+
export * from './instance-access.controller';
|
|
3
|
+
export * from './instance-access.service';
|
|
1
4
|
export { STATE_MACHINE_KIND, STATE_MACHINE_SCHEMA_VERSION, stateMachineDefinitionKind, stateMachineExample, stateMachineSpecSchema, } from './kind';
|
|
2
5
|
export * from './list-view-fields';
|
|
3
6
|
export { SIMULATE_TOOL_NAME, StateMachineMcpTools, } from './mcp-tools';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,QAAQ,CAAC;AAChB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,KAAK,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EACL,KAAK,aAAa,EAClB,yBAAyB,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,oBAAoB,GAC1B,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,QAAQ,CAAC;AAChB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,KAAK,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EACL,KAAK,aAAa,EAClB,yBAAyB,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,oBAAoB,GAC1B,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.initialStateOf = exports.STATE_MACHINE_STORE = exports.InMemoryStateMachineStore = exports.StateMachineModule = exports.StateMachineKindRegistration = exports.StateMachineController = exports.runHttp = exports.simulateStateMachine = exports.validateStateMachineSpec = exports.StateMachineRuntime = exports.STATE_MACHINE_CLOCK = exports.INSTANCE_WRITE_PERMISSION = exports.INSTANCE_READ_PERMISSION = exports.StateMachineReaderGrants = exports.PrismaStateMachineStore = exports.StateMachineMcpTools = exports.SIMULATE_TOOL_NAME = exports.stateMachineSpecSchema = exports.stateMachineExample = exports.stateMachineDefinitionKind = exports.STATE_MACHINE_SCHEMA_VERSION = exports.STATE_MACHINE_KIND = void 0;
|
|
18
|
+
__exportStar(require("./access"), exports);
|
|
19
|
+
__exportStar(require("./instance-access.controller"), exports);
|
|
20
|
+
__exportStar(require("./instance-access.service"), exports);
|
|
18
21
|
var kind_1 = require("./kind");
|
|
19
22
|
Object.defineProperty(exports, "STATE_MACHINE_KIND", { enumerable: true, get: function () { return kind_1.STATE_MACHINE_KIND; } });
|
|
20
23
|
Object.defineProperty(exports, "STATE_MACHINE_SCHEMA_VERSION", { enumerable: true, get: function () { return kind_1.STATE_MACHINE_SCHEMA_VERSION; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAMgB;AALd,0GAAA,kBAAkB,OAAA;AAClB,oHAAA,4BAA4B,OAAA;AAC5B,kHAAA,0BAA0B,OAAA;AAC1B,2GAAA,mBAAmB,OAAA;AACnB,8GAAA,sBAAsB,OAAA;AAExB,qDAAmC;AACnC,yCAGqB;AAFnB,+GAAA,kBAAkB,OAAA;AAClB,iHAAA,oBAAoB,OAAA;AAEtB,wDAAsC;AACtC,+CAAyD;AAAhD,uH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E,mHAAA,OAAO,OAAA;AAAE,kIAAA,sBAAsB,OAAA;AACxC,+DAA0F;AAAjF,oIAAA,4BAA4B,OAAA;AAAE,0HAAA,kBAAkB,OAAA;AACzD,iCAQiB;AANf,kHAAA,yBAAyB,OAAA;AAGzB,4GAAA,mBAAmB,OAAA;AAIrB,iCAMiB;AALf,uGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InteractivePrincipal } from '@haneinfo/plugin-api';
|
|
2
|
+
import { InstanceAccessService } from './instance-access.service';
|
|
3
|
+
export declare class InstanceAccessController {
|
|
4
|
+
private readonly access;
|
|
5
|
+
constructor(access: InstanceAccessService);
|
|
6
|
+
list(user: InteractivePrincipal, id: string): Promise<{
|
|
7
|
+
items: {
|
|
8
|
+
principalName: string | null;
|
|
9
|
+
grantedByName: string | null;
|
|
10
|
+
instanceId: string;
|
|
11
|
+
principalType: import("./access").AccessPrincipalType;
|
|
12
|
+
principalId: string;
|
|
13
|
+
level: import("./access").AccessLevel;
|
|
14
|
+
source: import("./access").AccessSource;
|
|
15
|
+
grantedBy: string | null;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
grant(user: InteractivePrincipal, id: string, body: unknown): Promise<import("./access").InstanceAccessRecord>;
|
|
20
|
+
remove(user: InteractivePrincipal, id: string, principalType: string, principalId: string): Promise<{
|
|
21
|
+
removed: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=instance-access.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-access.controller.d.ts","sourceRoot":"","sources":["../src/instance-access.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,qBAEa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,qBAAqB;IAG1D,IAAI,CAAgB,IAAI,EAAE,oBAAoB,EAAe,EAAE,EAAE,MAAM;;;;;;;;;;;;;IAKvE,KAAK,CAAgB,IAAI,EAAE,oBAAoB,EAAe,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,OAAO;IAK/F,MAAM,CACW,IAAI,EAAE,oBAAoB,EAC5B,EAAE,EAAE,MAAM,EACC,aAAa,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM;;;CAI5C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InstanceAccessController = void 0;
|
|
16
|
+
const plugin_host_nest_1 = require("@haneinfo/plugin-host-nest");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const instance_access_service_1 = require("./instance-access.service");
|
|
19
|
+
const state_machine_controller_1 = require("./state-machine.controller");
|
|
20
|
+
let InstanceAccessController = class InstanceAccessController {
|
|
21
|
+
constructor(access) {
|
|
22
|
+
this.access = access;
|
|
23
|
+
}
|
|
24
|
+
list(user, id) {
|
|
25
|
+
return (0, state_machine_controller_1.runHttp)(() => this.access.listFor(user.sub, id));
|
|
26
|
+
}
|
|
27
|
+
grant(user, id, body) {
|
|
28
|
+
return (0, state_machine_controller_1.runHttp)(() => this.access.grantFor(user.sub, id, body));
|
|
29
|
+
}
|
|
30
|
+
remove(user, id, principalType, principalId) {
|
|
31
|
+
return (0, state_machine_controller_1.runHttp)(() => this.access.removeFor(user.sub, id, { principalType, principalId }));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.InstanceAccessController = InstanceAccessController;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, common_1.Get)(),
|
|
37
|
+
__param(0, (0, plugin_host_nest_1.CurrentUser)()),
|
|
38
|
+
__param(1, (0, common_1.Param)('id')),
|
|
39
|
+
__metadata("design:type", Function),
|
|
40
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
41
|
+
__metadata("design:returntype", void 0)
|
|
42
|
+
], InstanceAccessController.prototype, "list", null);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, common_1.Put)(),
|
|
45
|
+
__param(0, (0, plugin_host_nest_1.CurrentUser)()),
|
|
46
|
+
__param(1, (0, common_1.Param)('id')),
|
|
47
|
+
__param(2, (0, common_1.Body)()),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
50
|
+
__metadata("design:returntype", void 0)
|
|
51
|
+
], InstanceAccessController.prototype, "grant", null);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, common_1.Delete)(':principalType/:principalId'),
|
|
54
|
+
__param(0, (0, plugin_host_nest_1.CurrentUser)()),
|
|
55
|
+
__param(1, (0, common_1.Param)('id')),
|
|
56
|
+
__param(2, (0, common_1.Param)('principalType')),
|
|
57
|
+
__param(3, (0, common_1.Param)('principalId')),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
60
|
+
__metadata("design:returntype", void 0)
|
|
61
|
+
], InstanceAccessController.prototype, "remove", null);
|
|
62
|
+
exports.InstanceAccessController = InstanceAccessController = __decorate([
|
|
63
|
+
(0, common_1.Controller)('state-machine-instances/:id/access'),
|
|
64
|
+
(0, common_1.UseGuards)(plugin_host_nest_1.InteractiveAuthGuard),
|
|
65
|
+
__metadata("design:paramtypes", [instance_access_service_1.InstanceAccessService])
|
|
66
|
+
], InstanceAccessController);
|
|
67
|
+
//# sourceMappingURL=instance-access.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-access.controller.js","sourceRoot":"","sources":["../src/instance-access.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,iEAA+E;AAC/E,2CAAsF;AACtF,uEAAkE;AAClE,yEAAqD;AAI9C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YAA6B,MAA6B;QAA7B,WAAM,GAAN,MAAM,CAAuB;IAAG,CAAC;IAG9D,IAAI,CAAgB,IAA0B,EAAe,EAAU;QACrE,OAAO,IAAA,kCAAO,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAGD,KAAK,CAAgB,IAA0B,EAAe,EAAU,EAAU,IAAa;QAC7F,OAAO,IAAA,kCAAO,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;IAGD,MAAM,CACW,IAA0B,EAC5B,EAAU,EACC,aAAqB,EACvB,WAAmB;QAEzC,OAAO,IAAA,kCAAO,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;CACF,CAAA;AAtBY,4DAAwB;AAInC;IADC,IAAA,YAAG,GAAE;IACA,WAAA,IAAA,8BAAW,GAAE,CAAA;IAA8B,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;oDAE3D;AAGD;IADC,IAAA,YAAG,GAAE;IACC,WAAA,IAAA,8BAAW,GAAE,CAAA;IAA8B,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;;;qDAEhF;AAGD;IADC,IAAA,eAAM,EAAC,6BAA6B,CAAC;IAEnC,WAAA,IAAA,8BAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,cAAK,EAAC,eAAe,CAAC,CAAA;IACtB,WAAA,IAAA,cAAK,EAAC,aAAa,CAAC,CAAA;;;;sDAGtB;mCArBU,wBAAwB;IAFpC,IAAA,mBAAU,EAAC,oCAAoC,CAAC;IAChD,IAAA,kBAAS,EAAC,uCAAoB,CAAC;qCAEO,+CAAqB;GAD/C,wBAAwB,CAsBpC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type IdentityStorePort, type NotificationInboxPort, type RbacPolicyPort } from '@haneinfo/plugin-api';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type Clock, StateMachineRuntime } from './runtime.service';
|
|
4
|
+
import { type StateMachineStore } from './store';
|
|
5
|
+
import type { StateMachineConfig } from './types';
|
|
6
|
+
export declare const INSTANCE_ADMIN_PERMISSION = "state-machine:instance:admin";
|
|
7
|
+
export declare const accessPrincipalSchema: z.ZodObject<{
|
|
8
|
+
principalType: z.ZodEnum<{
|
|
9
|
+
USER: "USER";
|
|
10
|
+
ROLE: "ROLE";
|
|
11
|
+
}>;
|
|
12
|
+
principalId: z.ZodString;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const accessGrantSchema: z.ZodObject<{
|
|
15
|
+
principalType: z.ZodEnum<{
|
|
16
|
+
USER: "USER";
|
|
17
|
+
ROLE: "ROLE";
|
|
18
|
+
}>;
|
|
19
|
+
principalId: z.ZodString;
|
|
20
|
+
level: z.ZodEnum<{
|
|
21
|
+
READ: "READ";
|
|
22
|
+
WRITE: "WRITE";
|
|
23
|
+
}>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export declare class InstanceAccessService {
|
|
26
|
+
private readonly store;
|
|
27
|
+
private readonly runtime;
|
|
28
|
+
private readonly rbac?;
|
|
29
|
+
private readonly identity?;
|
|
30
|
+
private readonly inbox?;
|
|
31
|
+
private readonly config;
|
|
32
|
+
private readonly now;
|
|
33
|
+
constructor(store: StateMachineStore, runtime: StateMachineRuntime, rbac?: RbacPolicyPort | undefined, identity?: IdentityStorePort | undefined, inbox?: NotificationInboxPort | undefined, config?: StateMachineConfig, now?: Clock);
|
|
34
|
+
private authorized;
|
|
35
|
+
listFor(userId: string, id: string): Promise<{
|
|
36
|
+
items: {
|
|
37
|
+
principalName: string | null;
|
|
38
|
+
grantedByName: string | null;
|
|
39
|
+
instanceId: string;
|
|
40
|
+
principalType: import("./access").AccessPrincipalType;
|
|
41
|
+
principalId: string;
|
|
42
|
+
level: import("./access").AccessLevel;
|
|
43
|
+
source: import("./access").AccessSource;
|
|
44
|
+
grantedBy: string | null;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
}[];
|
|
47
|
+
}>;
|
|
48
|
+
grantFor(userId: string, id: string, input: unknown): Promise<import("./access").InstanceAccessRecord>;
|
|
49
|
+
removeFor(userId: string, id: string, input: unknown): Promise<{
|
|
50
|
+
removed: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=instance-access.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-access.service.d.ts","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,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;;;CA8C3D"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InstanceAccessService = exports.accessGrantSchema = exports.accessPrincipalSchema = exports.INSTANCE_ADMIN_PERMISSION = void 0;
|
|
16
|
+
const plugin_api_1 = require("@haneinfo/plugin-api");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const access_1 = require("./access");
|
|
20
|
+
const runtime_service_1 = require("./runtime.service");
|
|
21
|
+
const store_1 = require("./store");
|
|
22
|
+
exports.INSTANCE_ADMIN_PERMISSION = 'state-machine:instance:admin';
|
|
23
|
+
exports.accessPrincipalSchema = zod_1.z
|
|
24
|
+
.object({
|
|
25
|
+
principalType: zod_1.z.enum(['USER', 'ROLE']),
|
|
26
|
+
principalId: zod_1.z.string().min(1).max(128),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
exports.accessGrantSchema = exports.accessPrincipalSchema.extend({ level: zod_1.z.enum(['READ', 'WRITE']) });
|
|
30
|
+
let InstanceAccessService = class InstanceAccessService {
|
|
31
|
+
constructor(store, runtime, rbac, identity, inbox, config = {}, now = () => new Date()) {
|
|
32
|
+
this.store = store;
|
|
33
|
+
this.runtime = runtime;
|
|
34
|
+
this.rbac = rbac;
|
|
35
|
+
this.identity = identity;
|
|
36
|
+
this.inbox = inbox;
|
|
37
|
+
this.config = config;
|
|
38
|
+
this.now = now;
|
|
39
|
+
}
|
|
40
|
+
async authorized(store, userId, id, manage) {
|
|
41
|
+
const instance = await store.find(id, manage);
|
|
42
|
+
const auth = await (0, plugin_api_1.authorizationOfUser)(this.rbac, userId);
|
|
43
|
+
const admin = Boolean(userId) && (0, plugin_api_1.hasPermission)(auth, exports.INSTANCE_ADMIN_PERMISSION);
|
|
44
|
+
// Instance administrators can manage any list (decision 4); ordinary readers cannot regrant.
|
|
45
|
+
if (!instance || (!admin && !(await (0, access_1.instanceAccessAllowed)(userId, instance, auth, store))))
|
|
46
|
+
throw new plugin_api_1.MechanismError('INSTANCE_NOT_FOUND', 'Instance not found', 404);
|
|
47
|
+
if (manage && !admin && instance.submitterId !== userId)
|
|
48
|
+
throw new plugin_api_1.MechanismError('FORBIDDEN', 'Only the submitter or an instance administrator may manage access', 403);
|
|
49
|
+
return instance;
|
|
50
|
+
}
|
|
51
|
+
async listFor(userId, id) {
|
|
52
|
+
return this.store.run(undefined, async (store, tx) => {
|
|
53
|
+
await this.authorized(store, userId, id, false);
|
|
54
|
+
const items = await store.listAccess(id);
|
|
55
|
+
const ids = [
|
|
56
|
+
...new Set(items.flatMap((r) => [
|
|
57
|
+
...(r.principalType === 'USER' ? [r.principalId] : []),
|
|
58
|
+
...(r.grantedBy ? [r.grantedBy] : []),
|
|
59
|
+
])),
|
|
60
|
+
];
|
|
61
|
+
const names = new Map(ids.length && this.identity?.findActiveNamesByIds
|
|
62
|
+
? (await this.identity.findActiveNamesByIds(ids, tx)).map((r) => [r.id, r.name])
|
|
63
|
+
: []);
|
|
64
|
+
const roleIds = [
|
|
65
|
+
...new Set(items.filter((r) => r.principalType === 'ROLE').map((r) => r.principalId)),
|
|
66
|
+
];
|
|
67
|
+
const roles = new Map(roleIds.length && this.rbac?.findRolesByNames
|
|
68
|
+
? (await this.rbac.findRolesByNames(roleIds, tx)).map((r) => [r.name, r.displayName])
|
|
69
|
+
: []);
|
|
70
|
+
return {
|
|
71
|
+
items: items.map((r) => ({
|
|
72
|
+
...r,
|
|
73
|
+
principalName: (r.principalType === 'USER' ? names : roles).get(r.principalId) ?? null,
|
|
74
|
+
grantedByName: names.get(r.grantedBy ?? '') ?? null,
|
|
75
|
+
})),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async grantFor(userId, id, input) {
|
|
80
|
+
return this.store.run(undefined, async (store, tx) => {
|
|
81
|
+
await this.runtime.get(id, tx, { lock: true });
|
|
82
|
+
const instance = await this.authorized(store, userId, id, true);
|
|
83
|
+
const parsed = exports.accessGrantSchema.safeParse(input);
|
|
84
|
+
if (!parsed.success)
|
|
85
|
+
throw new plugin_api_1.MechanismError('ACCESS_PRINCIPAL_INVALID', 'Invalid access principal or level');
|
|
86
|
+
const grant = parsed.data;
|
|
87
|
+
if (grant.principalType === 'USER') {
|
|
88
|
+
const principal = await this.identity?.findById(grant.principalId);
|
|
89
|
+
if (!principal?.isActive || grant.principalId === instance.submitterId)
|
|
90
|
+
throw new plugin_api_1.MechanismError('ACCESS_PRINCIPAL_INVALID', 'An active user other than the submitter is required');
|
|
91
|
+
}
|
|
92
|
+
else if (!(await this.rbac?.findRolesByNames?.([grant.principalId], tx))?.some((r) => r.name === grant.principalId)) {
|
|
93
|
+
throw new plugin_api_1.MechanismError('ACCESS_PRINCIPAL_INVALID', 'An existing role is required');
|
|
94
|
+
}
|
|
95
|
+
const entries = await store.listAccess(id);
|
|
96
|
+
const previous = entries.find((r) => r.source === 'GRANTED' &&
|
|
97
|
+
r.principalType === grant.principalType &&
|
|
98
|
+
r.principalId === grant.principalId);
|
|
99
|
+
if (previous?.level === grant.level)
|
|
100
|
+
return previous;
|
|
101
|
+
const limit = this.config.maxGrantedAccess ?? 100;
|
|
102
|
+
if (!previous && entries.filter((r) => r.source === 'GRANTED').length >= limit)
|
|
103
|
+
throw new plugin_api_1.MechanismError('ACCESS_LIMIT_EXCEEDED', 'The instance access limit has been reached', 409);
|
|
104
|
+
const entry = await store.putGranted({
|
|
105
|
+
...grant,
|
|
106
|
+
instanceId: id,
|
|
107
|
+
source: 'GRANTED',
|
|
108
|
+
grantedBy: userId,
|
|
109
|
+
createdAt: previous?.createdAt ?? this.now(),
|
|
110
|
+
});
|
|
111
|
+
const at = this.now();
|
|
112
|
+
const historyId = await store.appendHistory({
|
|
113
|
+
instanceId: id,
|
|
114
|
+
transition: null,
|
|
115
|
+
fromState: instance.state,
|
|
116
|
+
toState: instance.state,
|
|
117
|
+
triggerType: 'ACCESS',
|
|
118
|
+
triggerUserId: userId,
|
|
119
|
+
triggerRef: null,
|
|
120
|
+
at,
|
|
121
|
+
decision: {
|
|
122
|
+
access: {
|
|
123
|
+
action: previous ? 'ADJUSTED' : 'GRANTED',
|
|
124
|
+
...grant,
|
|
125
|
+
previousLevel: previous?.level ?? null,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
if (grant.principalType === 'USER')
|
|
130
|
+
await this.inbox?.notify({
|
|
131
|
+
recipientUserId: grant.principalId,
|
|
132
|
+
idempotencyKey: `state-machine-access:${historyId}`,
|
|
133
|
+
type: 'state-machine.access.granted',
|
|
134
|
+
title: 'Instance access granted',
|
|
135
|
+
body: `Access level: ${grant.level}`,
|
|
136
|
+
sourceApp: this.config.appName ?? 'app',
|
|
137
|
+
sourceEntityType: 'StateMachineInstance',
|
|
138
|
+
sourceEntityId: id,
|
|
139
|
+
targetPath: `/instances/${id}`,
|
|
140
|
+
}, { tx });
|
|
141
|
+
await this.runtime.emit({
|
|
142
|
+
name: 'state-machine.access.recorded',
|
|
143
|
+
instanceId: id,
|
|
144
|
+
payload: {
|
|
145
|
+
historyId,
|
|
146
|
+
action: previous ? 'ADJUSTED' : 'GRANTED',
|
|
147
|
+
...grant,
|
|
148
|
+
at: at.toISOString(),
|
|
149
|
+
},
|
|
150
|
+
}, tx);
|
|
151
|
+
return entry;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async removeFor(userId, id, input) {
|
|
155
|
+
return this.store.run(undefined, async (store, tx) => {
|
|
156
|
+
await this.runtime.get(id, tx, { lock: true });
|
|
157
|
+
const instance = await this.authorized(store, userId, id, true);
|
|
158
|
+
const parsed = exports.accessPrincipalSchema.safeParse(input);
|
|
159
|
+
if (!parsed.success)
|
|
160
|
+
throw new plugin_api_1.MechanismError('ACCESS_PRINCIPAL_INVALID', 'Invalid access principal');
|
|
161
|
+
const principal = parsed.data;
|
|
162
|
+
const entries = (await store.listAccess(id)).filter((r) => r.principalType === principal.principalType && r.principalId === principal.principalId);
|
|
163
|
+
const previous = entries.find((r) => r.source === 'GRANTED');
|
|
164
|
+
if (!previous) {
|
|
165
|
+
if (entries.length)
|
|
166
|
+
throw new plugin_api_1.MechanismError('ACCESS_NOT_MANAGEABLE', 'Permanent access cannot be removed or adjusted', 409);
|
|
167
|
+
return { removed: false };
|
|
168
|
+
}
|
|
169
|
+
await store.deleteGranted(id, principal.principalType, principal.principalId);
|
|
170
|
+
const at = this.now();
|
|
171
|
+
const historyId = await store.appendHistory({
|
|
172
|
+
instanceId: id,
|
|
173
|
+
transition: null,
|
|
174
|
+
fromState: instance.state,
|
|
175
|
+
toState: instance.state,
|
|
176
|
+
triggerType: 'ACCESS',
|
|
177
|
+
triggerUserId: userId,
|
|
178
|
+
triggerRef: null,
|
|
179
|
+
at,
|
|
180
|
+
decision: { access: { action: 'REMOVED', ...principal, previousLevel: previous.level } },
|
|
181
|
+
});
|
|
182
|
+
await this.runtime.emit({
|
|
183
|
+
name: 'state-machine.access.recorded',
|
|
184
|
+
instanceId: id,
|
|
185
|
+
payload: { historyId, action: 'REMOVED', ...principal, at: at.toISOString() },
|
|
186
|
+
}, tx);
|
|
187
|
+
return { removed: true };
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
exports.InstanceAccessService = InstanceAccessService;
|
|
192
|
+
exports.InstanceAccessService = InstanceAccessService = __decorate([
|
|
193
|
+
(0, common_1.Injectable)(),
|
|
194
|
+
__param(0, (0, common_1.Inject)(store_1.STATE_MACHINE_STORE)),
|
|
195
|
+
__param(1, (0, common_1.Inject)(runtime_service_1.StateMachineRuntime)),
|
|
196
|
+
__param(2, (0, common_1.Optional)()),
|
|
197
|
+
__param(2, (0, common_1.Inject)(plugin_api_1.RBAC_POLICY)),
|
|
198
|
+
__param(3, (0, common_1.Optional)()),
|
|
199
|
+
__param(3, (0, common_1.Inject)(plugin_api_1.IDENTITY_STORE)),
|
|
200
|
+
__param(4, (0, common_1.Optional)()),
|
|
201
|
+
__param(4, (0, common_1.Inject)(plugin_api_1.NOTIFICATION_INBOX)),
|
|
202
|
+
__param(5, (0, common_1.Optional)()),
|
|
203
|
+
__param(5, (0, common_1.Inject)(runtime_service_1.STATE_MACHINE_CONFIG)),
|
|
204
|
+
__param(6, (0, common_1.Optional)()),
|
|
205
|
+
__param(6, (0, common_1.Inject)(runtime_service_1.STATE_MACHINE_CLOCK)),
|
|
206
|
+
__metadata("design:paramtypes", [Object, runtime_service_1.StateMachineRuntime, Object, Object, Object, Object, Function])
|
|
207
|
+
], InstanceAccessService);
|
|
208
|
+
//# sourceMappingURL=instance-access.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-access.service.js","sourceRoot":"","sources":["../src/instance-access.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qDAU8B;AAC9B,2CAA8D;AAC9D,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