@valon-technologies/gestalt 0.0.1-alpha.35 → 0.0.1-alpha.37
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/package.json +1 -1
- package/src/agent-access.ts +2 -5
- package/src/agent-conversions.ts +29 -2
- package/src/agent.ts +90 -26
- package/src/api.ts +45 -1
- package/src/app-access.ts +5 -2
- package/src/authorization.ts +258 -0
- package/src/index.ts +1 -1
- package/src/internal/gen/v1/agent_pb.ts +77 -2
- package/src/internal/gen/v1/app_pb.ts +184 -23
- package/src/internal/gen/v1/runtime_pb.ts +6 -1
- package/src/internal/gen/v1/test_pb.ts +66 -0
- package/src/internal/gen/v1/workflow_pb.ts +77 -2
- package/src/invocation-context.ts +20 -7
- package/src/runtime.ts +50 -24
- package/src/workflow-access.ts +26 -43
- package/src/workflow.ts +94 -14
package/src/workflow.ts
CHANGED
|
@@ -18,9 +18,16 @@ import {
|
|
|
18
18
|
type Request,
|
|
19
19
|
type Subject,
|
|
20
20
|
type SubjectInput,
|
|
21
|
+
type SubjectPermission,
|
|
21
22
|
errorMessage,
|
|
22
23
|
} from "./api.ts";
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
SubjectContextSchema,
|
|
26
|
+
SubjectPermissionContextSchema,
|
|
27
|
+
type RequestContext as ProtoRequestContext,
|
|
28
|
+
type SubjectContext,
|
|
29
|
+
type SubjectPermissionContext,
|
|
30
|
+
} from "./internal/gen/v1/app_pb.ts";
|
|
24
31
|
import {
|
|
25
32
|
ApplyWorkflowProviderDefinitionRequestSchema,
|
|
26
33
|
BoundWorkflowTargetSchema,
|
|
@@ -65,6 +72,7 @@ import {
|
|
|
65
72
|
type ApplyWorkflowProviderDefinitionRequest as ProtoApplyWorkflowProviderDefinitionRequest,
|
|
66
73
|
type BoundWorkflowTarget as ProtoBoundWorkflowTarget,
|
|
67
74
|
type CancelWorkflowProviderRunRequest as ProtoCancelWorkflowProviderRunRequest,
|
|
75
|
+
type DeleteWorkflowProviderDefinitionRequest as ProtoDeleteWorkflowProviderDefinitionRequest,
|
|
68
76
|
type DeliverWorkflowProviderEventRequest as ProtoDeliverWorkflowProviderEventRequest,
|
|
69
77
|
type GetWorkflowProviderDefinitionRequest as ProtoGetWorkflowProviderDefinitionRequest,
|
|
70
78
|
type GetWorkflowProviderRunEventsRequest as ProtoGetWorkflowProviderRunEventsRequest,
|
|
@@ -402,18 +410,27 @@ export interface ApplyWorkflowProviderDefinitionRequest {
|
|
|
402
410
|
spec?: WorkflowDefinitionSpec | undefined;
|
|
403
411
|
idempotencyKey?: string | undefined;
|
|
404
412
|
requestedBySubjectId?: string | undefined;
|
|
413
|
+
invocationToken?: string | undefined;
|
|
414
|
+
context?: ProtoRequestContext | undefined;
|
|
405
415
|
}
|
|
406
416
|
|
|
407
417
|
export interface GetWorkflowProviderDefinitionRequest {
|
|
408
418
|
definitionId: string;
|
|
419
|
+
invocationToken?: string | undefined;
|
|
420
|
+
context?: ProtoRequestContext | undefined;
|
|
409
421
|
}
|
|
410
422
|
|
|
411
|
-
export interface ListWorkflowProviderDefinitionsRequest {
|
|
423
|
+
export interface ListWorkflowProviderDefinitionsRequest {
|
|
424
|
+
invocationToken?: string | undefined;
|
|
425
|
+
context?: ProtoRequestContext | undefined;
|
|
426
|
+
}
|
|
412
427
|
|
|
413
428
|
export interface SetWorkflowProviderDefinitionPausedRequest {
|
|
414
429
|
definitionId: string;
|
|
415
430
|
paused: boolean;
|
|
416
431
|
requestedBySubjectId?: string | undefined;
|
|
432
|
+
invocationToken?: string | undefined;
|
|
433
|
+
context?: ProtoRequestContext | undefined;
|
|
417
434
|
}
|
|
418
435
|
|
|
419
436
|
export interface SetWorkflowProviderActivationPausedRequest {
|
|
@@ -421,10 +438,14 @@ export interface SetWorkflowProviderActivationPausedRequest {
|
|
|
421
438
|
activationId: string;
|
|
422
439
|
paused: boolean;
|
|
423
440
|
requestedBySubjectId?: string | undefined;
|
|
441
|
+
invocationToken?: string | undefined;
|
|
442
|
+
context?: ProtoRequestContext | undefined;
|
|
424
443
|
}
|
|
425
444
|
|
|
426
445
|
export interface DeleteWorkflowProviderDefinitionRequest {
|
|
427
446
|
definitionId: string;
|
|
447
|
+
invocationToken?: string | undefined;
|
|
448
|
+
context?: ProtoRequestContext | undefined;
|
|
428
449
|
}
|
|
429
450
|
|
|
430
451
|
export interface StartWorkflowProviderRunRequest {
|
|
@@ -435,10 +456,14 @@ export interface StartWorkflowProviderRunRequest {
|
|
|
435
456
|
createdBySubjectId?: string | undefined;
|
|
436
457
|
runAs?: SubjectInput | undefined;
|
|
437
458
|
workflowKey?: string | undefined;
|
|
459
|
+
invocationToken?: string | undefined;
|
|
460
|
+
context?: ProtoRequestContext | undefined;
|
|
438
461
|
}
|
|
439
462
|
|
|
440
463
|
export interface GetWorkflowProviderRunRequest {
|
|
441
464
|
runId: string;
|
|
465
|
+
invocationToken?: string | undefined;
|
|
466
|
+
context?: ProtoRequestContext | undefined;
|
|
442
467
|
}
|
|
443
468
|
|
|
444
469
|
export interface ListWorkflowProviderRunsRequest {
|
|
@@ -446,24 +471,34 @@ export interface ListWorkflowProviderRunsRequest {
|
|
|
446
471
|
pageToken?: string | undefined;
|
|
447
472
|
status?: WorkflowRunStatus | undefined;
|
|
448
473
|
targetApp?: string | undefined;
|
|
474
|
+
invocationToken?: string | undefined;
|
|
475
|
+
context?: ProtoRequestContext | undefined;
|
|
449
476
|
}
|
|
450
477
|
|
|
451
478
|
export interface GetWorkflowProviderRunEventsRequest {
|
|
452
479
|
runId: string;
|
|
480
|
+
invocationToken?: string | undefined;
|
|
481
|
+
context?: ProtoRequestContext | undefined;
|
|
453
482
|
}
|
|
454
483
|
|
|
455
484
|
export interface GetWorkflowProviderRunOutputRequest {
|
|
456
485
|
runId: string;
|
|
486
|
+
invocationToken?: string | undefined;
|
|
487
|
+
context?: ProtoRequestContext | undefined;
|
|
457
488
|
}
|
|
458
489
|
|
|
459
490
|
export interface CancelWorkflowProviderRunRequest {
|
|
460
491
|
runId: string;
|
|
461
492
|
reason: string;
|
|
493
|
+
invocationToken?: string | undefined;
|
|
494
|
+
context?: ProtoRequestContext | undefined;
|
|
462
495
|
}
|
|
463
496
|
|
|
464
497
|
export interface SignalWorkflowProviderRunRequest {
|
|
465
498
|
runId: string;
|
|
466
499
|
signal?: WorkflowSignal | undefined;
|
|
500
|
+
invocationToken?: string | undefined;
|
|
501
|
+
context?: ProtoRequestContext | undefined;
|
|
467
502
|
}
|
|
468
503
|
|
|
469
504
|
export interface SignalOrStartWorkflowProviderRunRequest {
|
|
@@ -475,6 +510,8 @@ export interface SignalOrStartWorkflowProviderRunRequest {
|
|
|
475
510
|
createdBySubjectId?: string | undefined;
|
|
476
511
|
runAs?: SubjectInput | undefined;
|
|
477
512
|
signal?: WorkflowSignal | undefined;
|
|
513
|
+
invocationToken?: string | undefined;
|
|
514
|
+
context?: ProtoRequestContext | undefined;
|
|
478
515
|
}
|
|
479
516
|
|
|
480
517
|
export interface SignalWorkflowRunResponse {
|
|
@@ -488,6 +525,8 @@ export interface DeliverWorkflowProviderEventRequest {
|
|
|
488
525
|
appName?: string | undefined;
|
|
489
526
|
event?: WorkflowEvent | undefined;
|
|
490
527
|
deliveredBySubjectId?: string | undefined;
|
|
528
|
+
invocationToken?: string | undefined;
|
|
529
|
+
context?: ProtoRequestContext | undefined;
|
|
491
530
|
}
|
|
492
531
|
|
|
493
532
|
export function workflowText(input: WorkflowText | string = {}): WorkflowText {
|
|
@@ -910,8 +949,7 @@ export function createWorkflowProviderService(provider: WorkflowProvider): Workf
|
|
|
910
949
|
));
|
|
911
950
|
},
|
|
912
951
|
async listDefinitions(request) {
|
|
913
|
-
const result = listDefinitionsResult(await invokeWorkflowProvider("list definitions", () => provider.listDefinitions(
|
|
914
|
-
void request;
|
|
952
|
+
const result = listDefinitionsResult(await invokeWorkflowProvider("list definitions", () => provider.listDefinitions(listWorkflowProviderDefinitionsRequestFromProto(request))));
|
|
915
953
|
return create(ListWorkflowProviderDefinitionsResponseSchema, {
|
|
916
954
|
definitions: result.definitions.map(workflowDefinitionToProto),
|
|
917
955
|
});
|
|
@@ -1570,23 +1608,29 @@ function applyWorkflowProviderDefinitionRequestFromProto(input: ProtoApplyWorkfl
|
|
|
1570
1608
|
spec: workflowDefinitionSpecFromProto(input.spec),
|
|
1571
1609
|
idempotencyKey: input.idempotencyKey,
|
|
1572
1610
|
requestedBySubjectId: input.requestedBySubjectId,
|
|
1611
|
+
invocationToken: input.invocationToken,
|
|
1612
|
+
context: input.context,
|
|
1573
1613
|
};
|
|
1574
1614
|
}
|
|
1575
1615
|
|
|
1576
1616
|
function getWorkflowProviderDefinitionRequestFromProto(input: ProtoGetWorkflowProviderDefinitionRequest): GetWorkflowProviderDefinitionRequest {
|
|
1577
|
-
return { definitionId: input.definitionId };
|
|
1617
|
+
return { definitionId: input.definitionId, invocationToken: input.invocationToken, context: input.context };
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
function listWorkflowProviderDefinitionsRequestFromProto(input: ProtoListWorkflowProviderDefinitionsRequest): ListWorkflowProviderDefinitionsRequest {
|
|
1621
|
+
return { invocationToken: input.invocationToken, context: input.context };
|
|
1578
1622
|
}
|
|
1579
1623
|
|
|
1580
1624
|
function setWorkflowProviderDefinitionPausedRequestFromProto(input: ProtoSetWorkflowProviderDefinitionPausedRequest): SetWorkflowProviderDefinitionPausedRequest {
|
|
1581
|
-
return { definitionId: input.definitionId, paused: input.paused, requestedBySubjectId: input.requestedBySubjectId };
|
|
1625
|
+
return { definitionId: input.definitionId, paused: input.paused, requestedBySubjectId: input.requestedBySubjectId, invocationToken: input.invocationToken, context: input.context };
|
|
1582
1626
|
}
|
|
1583
1627
|
|
|
1584
1628
|
function setWorkflowProviderActivationPausedRequestFromProto(input: ProtoSetWorkflowProviderActivationPausedRequest): SetWorkflowProviderActivationPausedRequest {
|
|
1585
|
-
return { definitionId: input.definitionId, activationId: input.activationId, paused: input.paused, requestedBySubjectId: input.requestedBySubjectId };
|
|
1629
|
+
return { definitionId: input.definitionId, activationId: input.activationId, paused: input.paused, requestedBySubjectId: input.requestedBySubjectId, invocationToken: input.invocationToken, context: input.context };
|
|
1586
1630
|
}
|
|
1587
1631
|
|
|
1588
|
-
function deleteWorkflowProviderDefinitionRequestFromProto(input:
|
|
1589
|
-
return { definitionId: input.definitionId };
|
|
1632
|
+
function deleteWorkflowProviderDefinitionRequestFromProto(input: ProtoDeleteWorkflowProviderDefinitionRequest): DeleteWorkflowProviderDefinitionRequest {
|
|
1633
|
+
return { definitionId: input.definitionId, invocationToken: input.invocationToken, context: input.context };
|
|
1590
1634
|
}
|
|
1591
1635
|
|
|
1592
1636
|
function startWorkflowProviderRunRequestFromProto(input: ProtoStartWorkflowProviderRunRequest): StartWorkflowProviderRunRequest {
|
|
@@ -1598,11 +1642,13 @@ function startWorkflowProviderRunRequestFromProto(input: ProtoStartWorkflowProvi
|
|
|
1598
1642
|
createdBySubjectId: input.createdBySubjectId,
|
|
1599
1643
|
runAs: subjectInputFromProto(input.runAs),
|
|
1600
1644
|
workflowKey: input.workflowKey,
|
|
1645
|
+
invocationToken: input.invocationToken,
|
|
1646
|
+
context: input.context,
|
|
1601
1647
|
};
|
|
1602
1648
|
}
|
|
1603
1649
|
|
|
1604
1650
|
function getWorkflowProviderRunRequestFromProto(input: ProtoGetWorkflowProviderRunRequest): GetWorkflowProviderRunRequest {
|
|
1605
|
-
return { runId: input.runId };
|
|
1651
|
+
return { runId: input.runId, invocationToken: input.invocationToken, context: input.context };
|
|
1606
1652
|
}
|
|
1607
1653
|
|
|
1608
1654
|
function listWorkflowProviderRunsRequestFromProto(input: ProtoListWorkflowProviderRunsRequest): ListWorkflowProviderRunsRequest {
|
|
@@ -1611,23 +1657,25 @@ function listWorkflowProviderRunsRequestFromProto(input: ProtoListWorkflowProvid
|
|
|
1611
1657
|
pageToken: input.pageToken,
|
|
1612
1658
|
status: input.status as WorkflowRunStatus,
|
|
1613
1659
|
targetApp: input.targetApp,
|
|
1660
|
+
invocationToken: input.invocationToken,
|
|
1661
|
+
context: input.context,
|
|
1614
1662
|
};
|
|
1615
1663
|
}
|
|
1616
1664
|
|
|
1617
1665
|
function getWorkflowProviderRunEventsRequestFromProto(input: ProtoGetWorkflowProviderRunEventsRequest): GetWorkflowProviderRunEventsRequest {
|
|
1618
|
-
return { runId: input.runId };
|
|
1666
|
+
return { runId: input.runId, invocationToken: input.invocationToken, context: input.context };
|
|
1619
1667
|
}
|
|
1620
1668
|
|
|
1621
1669
|
function getWorkflowProviderRunOutputRequestFromProto(input: ProtoGetWorkflowProviderRunOutputRequest): GetWorkflowProviderRunOutputRequest {
|
|
1622
|
-
return { runId: input.runId };
|
|
1670
|
+
return { runId: input.runId, invocationToken: input.invocationToken, context: input.context };
|
|
1623
1671
|
}
|
|
1624
1672
|
|
|
1625
1673
|
function cancelWorkflowProviderRunRequestFromProto(input: ProtoCancelWorkflowProviderRunRequest): CancelWorkflowProviderRunRequest {
|
|
1626
|
-
return { runId: input.runId, reason: input.reason };
|
|
1674
|
+
return { runId: input.runId, reason: input.reason, invocationToken: input.invocationToken, context: input.context };
|
|
1627
1675
|
}
|
|
1628
1676
|
|
|
1629
1677
|
function signalWorkflowProviderRunRequestFromProto(input: ProtoSignalWorkflowProviderRunRequest): SignalWorkflowProviderRunRequest {
|
|
1630
|
-
return { runId: input.runId, signal: workflowSignalFromProto(input.signal) };
|
|
1678
|
+
return { runId: input.runId, signal: workflowSignalFromProto(input.signal), invocationToken: input.invocationToken, context: input.context };
|
|
1631
1679
|
}
|
|
1632
1680
|
|
|
1633
1681
|
function signalOrStartWorkflowProviderRunRequestFromProto(input: ProtoSignalOrStartWorkflowProviderRunRequest): SignalOrStartWorkflowProviderRunRequest {
|
|
@@ -1640,6 +1688,8 @@ function signalOrStartWorkflowProviderRunRequestFromProto(input: ProtoSignalOrSt
|
|
|
1640
1688
|
createdBySubjectId: input.createdBySubjectId,
|
|
1641
1689
|
runAs: subjectInputFromProto(input.runAs),
|
|
1642
1690
|
signal: workflowSignalFromProto(input.signal),
|
|
1691
|
+
invocationToken: input.invocationToken,
|
|
1692
|
+
context: input.context,
|
|
1643
1693
|
};
|
|
1644
1694
|
}
|
|
1645
1695
|
|
|
@@ -1648,6 +1698,8 @@ function deliverWorkflowProviderEventRequestFromProto(input: ProtoDeliverWorkflo
|
|
|
1648
1698
|
appName: input.appName,
|
|
1649
1699
|
event: workflowEventFromProto(input.event),
|
|
1650
1700
|
deliveredBySubjectId: input.deliveredBySubjectId,
|
|
1701
|
+
invocationToken: input.invocationToken,
|
|
1702
|
+
context: input.context,
|
|
1651
1703
|
};
|
|
1652
1704
|
}
|
|
1653
1705
|
|
|
@@ -1844,6 +1896,9 @@ export function subjectToProto(input?: SubjectInput | Subject): SubjectContext |
|
|
|
1844
1896
|
id: input.id ?? "",
|
|
1845
1897
|
credentialSubjectId: input.credentialSubjectId ?? "",
|
|
1846
1898
|
email: input.email ?? "",
|
|
1899
|
+
displayName: input.displayName ?? "",
|
|
1900
|
+
scopes: [...(input.scopes ?? [])],
|
|
1901
|
+
permissions: subjectPermissionsToProto(input.permissions),
|
|
1847
1902
|
});
|
|
1848
1903
|
}
|
|
1849
1904
|
|
|
@@ -1853,6 +1908,9 @@ export function subjectFromProto(input?: SubjectContext): Subject | undefined {
|
|
|
1853
1908
|
id: input.id,
|
|
1854
1909
|
credentialSubjectId: input.credentialSubjectId,
|
|
1855
1910
|
email: input.email,
|
|
1911
|
+
displayName: input.displayName,
|
|
1912
|
+
scopes: [...input.scopes],
|
|
1913
|
+
permissions: subjectPermissionsFromProto(input.permissions),
|
|
1856
1914
|
};
|
|
1857
1915
|
}
|
|
1858
1916
|
|
|
@@ -1862,9 +1920,31 @@ export function subjectInputFromProto(input?: SubjectContext): SubjectInput | un
|
|
|
1862
1920
|
id: input.id,
|
|
1863
1921
|
credentialSubjectId: input.credentialSubjectId,
|
|
1864
1922
|
email: input.email,
|
|
1923
|
+
displayName: input.displayName,
|
|
1924
|
+
scopes: [...input.scopes],
|
|
1925
|
+
permissions: subjectPermissionsFromProto(input.permissions),
|
|
1865
1926
|
};
|
|
1866
1927
|
}
|
|
1867
1928
|
|
|
1929
|
+
function subjectPermissionsFromProto(
|
|
1930
|
+
permissions: readonly SubjectPermissionContext[],
|
|
1931
|
+
): SubjectPermission[] {
|
|
1932
|
+
return permissions.map((permission) => ({
|
|
1933
|
+
app: permission.app,
|
|
1934
|
+
operations: permission.allOperations ? [] : [...permission.operations],
|
|
1935
|
+
}));
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
function subjectPermissionsToProto(
|
|
1939
|
+
permissions?: readonly SubjectPermission[] | undefined,
|
|
1940
|
+
): SubjectPermissionContext[] {
|
|
1941
|
+
return permissions?.map((permission) => create(SubjectPermissionContextSchema, {
|
|
1942
|
+
app: permission.app,
|
|
1943
|
+
operations: [...permission.operations],
|
|
1944
|
+
allOperations: permission.operations.length === 0,
|
|
1945
|
+
})) ?? [];
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1868
1948
|
function listDefinitionsResult(value: readonly WorkflowDefinition[] | ListWorkflowProviderDefinitionsResponse): ListWorkflowProviderDefinitionsResponse {
|
|
1869
1949
|
return "definitions" in value ? value : { definitions: value };
|
|
1870
1950
|
}
|