@allorc/a423-sdk 0.6.0 → 0.8.1
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/CANCELLATION.md +36 -0
- package/CHANGELOG.md +28 -0
- package/ESCROW.md +2 -0
- package/INTEGRATION.md +11 -1
- package/OPERATIONS.md +2 -0
- package/PROFIT-POLICY.md +154 -0
- package/README.md +605 -64
- package/SECURITY.md +4 -0
- package/SETTLEMENT.md +2 -0
- package/examples/README.md +29 -0
- package/examples/operations-dashboard.html +3 -3
- package/examples/quickstart.mjs +33 -0
- package/package.json +12 -3
- package/src/escrow/index.cjs +8 -1
- package/src/escrow/index.d.mts +1 -1
- package/src/escrow/index.d.ts +1 -1
- package/src/escrow/services.cjs +1 -1
- package/src/operations/application.cjs +10 -5
- package/src/operations/factory.cjs +6 -4
- package/src/operations/index.d.ts +3 -3
- package/src/policy/index.cjs +94 -0
- package/src/policy/index.d.ts +23 -0
- package/src/policy/index.mjs +2 -0
- package/src/workflow.cjs +45 -7
- package/src/workflow.d.ts +7 -3
package/src/workflow.d.ts
CHANGED
|
@@ -19,7 +19,9 @@ export interface CancellationSubflow {
|
|
|
19
19
|
id: string;kind: 'cancellation';parent_job_id: string;status: 'proposal_pending'|'proposal_rejected'|'negotiating'|'acceptance_pending'|'accepted'|'execution_pending'|'execution_failed'|'completed'|'disputed';started_at: string;updated_at: string;proposal_revision: number;instruction: CancellationInstruction | null;receipt: CancellationReceipt | null;events: Array<{sequence: number;type: string;actor_id: string;at: string;data: Json}>;accepted_at?: string;approved_by?: string[];completed_at?: string;execution_reference?: string | null;closing_action?: string;last_error?: string | null;
|
|
20
20
|
}
|
|
21
21
|
export interface CancellationApproval {expected_revision: number;proposal_hash: string;payer_signature: string;worker_signature: string}
|
|
22
|
+
export interface PreFundingCancellation {id: string;epoch: number;action: 'cancel'|'decline';actor_id: string;prior_state: string;accepted_by: string[];agreement: Agreement | null;reason: string | null;at: string;reopen_approvals: string[];reopened_at: string | null}
|
|
22
23
|
export interface WorkflowJob {
|
|
24
|
+
epoch?: number;agreement_revision?: number;pre_funding_cancellations?: PreFundingCancellation[];
|
|
23
25
|
subflows?: CancellationSubflow[];active_subflow_id?: string | null;
|
|
24
26
|
work_status?: string;negotiation?: Negotiation | null;escrow_ledger?: EscrowLedger | null;
|
|
25
27
|
id: string; protocol: 'a423.workflow.v1'; version: number; state: string;
|
|
@@ -41,9 +43,10 @@ export type Effect = (context: AdapterContext) => Promise<AdapterResult>;
|
|
|
41
43
|
export interface Transition { from: string[]; roles: string[]; to: string; effect?: boolean }
|
|
42
44
|
export interface WorkflowOptions {
|
|
43
45
|
store: WorkflowStore;
|
|
44
|
-
adapters?: Record<string, Effect | { execute: Effect; reconcile?: Effect }>;
|
|
46
|
+
adapters?: Record<string, Effect | { execute: Effect; reconcile?: Effect; rejectPending?: Effect }>;
|
|
45
47
|
/** Return true to allow; authenticated actor ID must be supplied by your application. */
|
|
46
|
-
authorize?(context: { job: WorkflowJob; action: string; actor: string; input: Json }): boolean | Promise<boolean>;
|
|
48
|
+
authorize?(context: { job: WorkflowJob; action: string; actor: string; input: Json;phase?: 'execute'|'reconcile' }): boolean | Promise<boolean>;
|
|
49
|
+
prepareInput?(context: {job: WorkflowJob;action: string;actor: string;input: Json}): Promise<Json>;
|
|
47
50
|
/** Throw to reject application-specific terms. */
|
|
48
51
|
validateEvidence?(context: {job: WorkflowJob;action: string;evidence: {[key: string]: Json}}): void | Promise<void>;
|
|
49
52
|
validateTerms?(terms: { [key: string]: Json }): void | Promise<void>;
|
|
@@ -55,13 +58,14 @@ export interface Workflow {
|
|
|
55
58
|
get(id: string, actor: string): Promise<WorkflowJob>;
|
|
56
59
|
assertSafe(id: string, actor: string): Promise<WorkflowJob>;
|
|
57
60
|
act(id: string, action: string, input: Json, options: { actor: string; idempotencyKey: string }): Promise<WorkflowJob>;
|
|
61
|
+
rejectPendingOperation(id: string,input: {operation_id: string;reason: string},options: {actor: string}): Promise<WorkflowJob>;
|
|
58
62
|
resume(id: string, actor: string): Promise<WorkflowJob>;
|
|
59
63
|
reconcile(id: string, actor: string): Promise<WorkflowJob>;
|
|
60
64
|
cancellation(id: string, actor: string): Promise<CancellationSubflow | null>;
|
|
61
65
|
cancellationInstruction(id: string, actor: string): Promise<CancellationInstruction>;
|
|
62
66
|
cancellationReceipt(id: string, actor: string): Promise<CancellationReceipt>;
|
|
63
67
|
acceptCancellation(id: string,input: CancellationApproval,options: {actor: string;idempotencyKey: string;forward?: boolean}): Promise<WorkflowJob>;
|
|
64
|
-
receipts(id: string, actor: string): Promise<Pick<WorkflowJob, 'protocol' | 'state' | 'agreement' | 'submission' | 'evidence' | 'events' | 'pending' | 'work_status' | 'negotiation' | 'escrow_ledger' | 'subflows' | 'active_subflow_id'> & { job_id: string }>;
|
|
68
|
+
receipts(id: string, actor: string): Promise<Pick<WorkflowJob, 'epoch' | 'pre_funding_cancellations' | 'protocol' | 'state' | 'agreement' | 'submission' | 'evidence' | 'events' | 'pending' | 'work_status' | 'negotiation' | 'escrow_ledger' | 'subflows' | 'active_subflow_id'> & { job_id: string }>;
|
|
65
69
|
}
|
|
66
70
|
export function hashAgreement(terms: Json): string;
|
|
67
71
|
export function createWorkflow(options: WorkflowOptions): Workflow;
|