@supacloud/commands 0.5.0 → 0.6.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/dist/context.d.ts +2 -2
- package/dist/index.js +13 -3
- package/dist/store.d.ts +1 -1
- package/dist/transactional.d.ts +2 -2
- package/dist/typebox.js +13 -3
- package/package.json +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CommandAuthorization, type CommandIdentity, type ContractDecoder, type DurableCommandReceipt } from "@supacloud/contracts";
|
|
2
|
-
import type { CommandStore, CommandStoreSession, OperationReference, StoredCommand } from "./store";
|
|
2
|
+
import type { CommandStore, CommandStoreSession, OperationReference, StoredCommand, ValidatedOperationReference } from "./store";
|
|
3
3
|
export interface CommandInputCodec {
|
|
4
4
|
encode(canonicalInput: string): string | Promise<string>;
|
|
5
5
|
decode(payload: string): string | Promise<string>;
|
|
@@ -25,7 +25,7 @@ export interface PersistentCommandDefinition<Input, Result, Transaction> {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
interface Prepared<Input> {
|
|
28
|
-
reference:
|
|
28
|
+
reference: ValidatedOperationReference;
|
|
29
29
|
input: Input;
|
|
30
30
|
fingerprint: string;
|
|
31
31
|
payload: string;
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// src/transactional.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
CommandError as CommandError2,
|
|
4
|
+
canonicalCommandJson as canonicalCommandJson2
|
|
5
|
+
} from "@supacloud/contracts";
|
|
3
6
|
|
|
4
7
|
// src/context.ts
|
|
5
8
|
import {
|
|
6
9
|
CommandError,
|
|
7
10
|
canonicalCommandJson,
|
|
8
11
|
commandIdentifier,
|
|
9
|
-
|
|
12
|
+
decodeValidatedCommandReference,
|
|
10
13
|
decodeDurableCommandReceipt
|
|
11
14
|
} from "@supacloud/contracts";
|
|
12
15
|
var plaintextCommandInput = {
|
|
@@ -33,7 +36,14 @@ function commandContext(definition) {
|
|
|
33
36
|
const name = commandIdentifier(definition.name), event = commandIdentifier(definition.audit.event);
|
|
34
37
|
const reference = (identity, key) => {
|
|
35
38
|
try {
|
|
36
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...decodeValidatedCommandReference({
|
|
41
|
+
...identity,
|
|
42
|
+
command: name,
|
|
43
|
+
operationId: key,
|
|
44
|
+
dispatchKey: key
|
|
45
|
+
})
|
|
46
|
+
};
|
|
37
47
|
} catch {
|
|
38
48
|
throw new CommandError("COMMAND_INPUT_INVALID");
|
|
39
49
|
}
|
package/dist/store.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { OperationReference, StoredCommand, CommandStoreSession, CommandStore, RecoveryScope, CommandRetentionStore, } from "@supacloud/contracts";
|
|
1
|
+
export type { OperationReference, ValidatedOperationReference, StoredCommand, CommandStoreSession, CommandStore, RecoveryScope, RecoveryClaim, CommandRecoveryStore, CommandRetentionStore, } from "@supacloud/contracts";
|
package/dist/transactional.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CommandIdentity, type DurableCommandReceipt } from "@supacloud/contracts";
|
|
1
|
+
import { type CommandIdentity, type DurableCommandReceipt, type ValidatedOperationReference } from "@supacloud/contracts";
|
|
2
2
|
import { type PersistentCommandDefinition } from "./context";
|
|
3
3
|
import type { CommandStore } from "./store";
|
|
4
4
|
import { type ExecutionPolicyOptions } from "./execution-policy";
|
|
@@ -6,7 +6,7 @@ type TransactionOf<Store extends CommandStore<unknown>> = Store extends CommandS
|
|
|
6
6
|
type TransactionalCommandDefinition<Input, Result, Store extends CommandStore<unknown>> = Omit<PersistentCommandDefinition<Input, Result, TransactionOf<Store>>, "store"> & {
|
|
7
7
|
executionPolicy?: Omit<ExecutionPolicyOptions, "kind">;
|
|
8
8
|
store: Store;
|
|
9
|
-
execute(transaction: TransactionOf<Store>, input: Input, identity:
|
|
9
|
+
execute(transaction: TransactionOf<Store>, input: Input, identity: ValidatedOperationReference, signal: AbortSignal): Promise<unknown>;
|
|
10
10
|
};
|
|
11
11
|
export declare function createTransactionalCommand<Input, Result, Store extends CommandStore<unknown>>(definition: TransactionalCommandDefinition<Input, Result, Store>): {
|
|
12
12
|
kind: "transactional";
|
package/dist/typebox.js
CHANGED
|
@@ -3,14 +3,17 @@ import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
|
3
3
|
import { Value } from "@sinclair/typebox/value";
|
|
4
4
|
|
|
5
5
|
// src/transactional.ts
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
CommandError as CommandError2,
|
|
8
|
+
canonicalCommandJson as canonicalCommandJson2
|
|
9
|
+
} from "@supacloud/contracts";
|
|
7
10
|
|
|
8
11
|
// src/context.ts
|
|
9
12
|
import {
|
|
10
13
|
CommandError,
|
|
11
14
|
canonicalCommandJson,
|
|
12
15
|
commandIdentifier,
|
|
13
|
-
|
|
16
|
+
decodeValidatedCommandReference,
|
|
14
17
|
decodeDurableCommandReceipt
|
|
15
18
|
} from "@supacloud/contracts";
|
|
16
19
|
var plaintextCommandInput = {
|
|
@@ -37,7 +40,14 @@ function commandContext(definition) {
|
|
|
37
40
|
const name = commandIdentifier(definition.name), event = commandIdentifier(definition.audit.event);
|
|
38
41
|
const reference = (identity, key) => {
|
|
39
42
|
try {
|
|
40
|
-
return {
|
|
43
|
+
return {
|
|
44
|
+
...decodeValidatedCommandReference({
|
|
45
|
+
...identity,
|
|
46
|
+
command: name,
|
|
47
|
+
operationId: key,
|
|
48
|
+
dispatchKey: key
|
|
49
|
+
})
|
|
50
|
+
};
|
|
41
51
|
} catch {
|
|
42
52
|
throw new CommandError("COMMAND_INPUT_INVALID");
|
|
43
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/commands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Storage-independent durable command execution and recovery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"prepublishOnly": "bun run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@supacloud/contracts": "0.
|
|
32
|
+
"@supacloud/contracts": "0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@sinclair/typebox": "0.34.52",
|