@sekiban/dcb-client 0.1.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/LICENSE +90 -0
- package/README.md +14 -0
- package/dist/executor.d.ts +75 -0
- package/dist/executor.js +515 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +15618 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
Acceptance
|
|
4
|
+
|
|
5
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
6
|
+
|
|
7
|
+
Copyright License
|
|
8
|
+
|
|
9
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
10
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
11
|
+
available, and prepare derivative works of the software, in each case subject
|
|
12
|
+
to the limitations and conditions below.
|
|
13
|
+
|
|
14
|
+
Limitations
|
|
15
|
+
|
|
16
|
+
You may not provide the software to third parties as a hosted or managed
|
|
17
|
+
service, where the service provides users with access to any substantial set
|
|
18
|
+
of the features or functionality of the software.
|
|
19
|
+
|
|
20
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
21
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
22
|
+
software that is protected by the license key.
|
|
23
|
+
|
|
24
|
+
You may not alter, remove, or obscure any licensing, copyright, or other
|
|
25
|
+
notices of the licensor. Any use of the licensor's trademarks is subject to
|
|
26
|
+
applicable law.
|
|
27
|
+
|
|
28
|
+
Patents
|
|
29
|
+
|
|
30
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
31
|
+
non-sublicensable, non-transferable license under any patent claims the
|
|
32
|
+
licensor can license, or becomes able to license, to make, have made, use,
|
|
33
|
+
sell, offer for sale, import and have imported the software. This license does
|
|
34
|
+
not cover any patent claims that you cause to be infringed by modifications or
|
|
35
|
+
additions to the software.
|
|
36
|
+
|
|
37
|
+
If you or your company make any written claim that the software infringes or
|
|
38
|
+
contributes to infringement of any patent, your patent license for the software
|
|
39
|
+
granted under these terms ends immediately. If your company makes such a
|
|
40
|
+
claim, your patent license ends immediately for work on behalf of your company.
|
|
41
|
+
|
|
42
|
+
Notices
|
|
43
|
+
|
|
44
|
+
You must ensure that anyone who gets a copy of any part of the software from
|
|
45
|
+
you also gets a copy of these terms.
|
|
46
|
+
|
|
47
|
+
If you modify the software, you must include in any modified copies of the
|
|
48
|
+
software prominent notices stating that you have modified the software.
|
|
49
|
+
|
|
50
|
+
No Other Rights
|
|
51
|
+
|
|
52
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
53
|
+
this license.
|
|
54
|
+
|
|
55
|
+
Termination
|
|
56
|
+
|
|
57
|
+
If you use the software in violation of these terms, your license is not
|
|
58
|
+
licensed, and your licenses will automatically terminate. If the licensor
|
|
59
|
+
provides you with a notice of your violation, and you cease all violation of
|
|
60
|
+
the license no later than 30 days after your receipt of the notice, your
|
|
61
|
+
licenses will be reinstated retroactively. However, if you violate these terms
|
|
62
|
+
after such reinstatement, any additional violation of these terms will cause
|
|
63
|
+
your licenses to terminate automatically and permanently.
|
|
64
|
+
|
|
65
|
+
No Liability
|
|
66
|
+
|
|
67
|
+
As far as the law allows, the software comes as is, without any warranty or
|
|
68
|
+
condition, and the licensor will not be liable for any damages arising out of
|
|
69
|
+
these terms or the use or nature of the software, under any kind of legal
|
|
70
|
+
claim.
|
|
71
|
+
|
|
72
|
+
Definitions
|
|
73
|
+
|
|
74
|
+
The licensor is the entity offering these terms, including any portion of the
|
|
75
|
+
software.
|
|
76
|
+
|
|
77
|
+
you refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
your company is any legal entity, sole proprietorship, or other entity that
|
|
80
|
+
has control over, is under the control of, or is under common control with
|
|
81
|
+
that organization.
|
|
82
|
+
|
|
83
|
+
control means ownership of substantially all the assets of an entity, or the
|
|
84
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
85
|
+
|
|
86
|
+
your licenses are all the licenses granted to you under these terms.
|
|
87
|
+
|
|
88
|
+
use means anything requiring one of your licenses.
|
|
89
|
+
|
|
90
|
+
trademark means trademarks, service marks, or trade names.
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @sekiban/dcb-client
|
|
2
|
+
|
|
3
|
+
Typed Serialized DCB V1 client and claim-ledger executor.
|
|
4
|
+
|
|
5
|
+
`createSekibanExecutor` and the transport helpers provide the portable client
|
|
6
|
+
surface for executing a V1 command without importing the Cloudflare runtime.
|
|
7
|
+
The package depends on the matched `@sekiban/dcb-core` and
|
|
8
|
+
`@sekiban/dcb-domain` `0.1.0` release set.
|
|
9
|
+
|
|
10
|
+
It is not the earlier, unrelated `@sekiban/core` package line.
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
Elastic License 2.0. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type CommandDefinition, type CommandInput, type PortableSnapshot, type ProjectorLike, type SnapshotReader, type Tag } from "@sekiban/dcb-domain";
|
|
2
|
+
import { type ExecuteCommitted, type ExecuteConflict, type ExecuteResult, type ListQueryRequest, type ListQueryResponse, type QueryRequest, type QueryResponse, type SerializedDcbTransport } from "./index";
|
|
3
|
+
/** The small Worker-side binding surface needed by the in-process adapter. */
|
|
4
|
+
export interface RuntimeBindings {
|
|
5
|
+
readonly fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
readonly RUNTIME?: {
|
|
7
|
+
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
8
|
+
};
|
|
9
|
+
readonly runtime?: {
|
|
10
|
+
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface ExecuteCommandOptions {
|
|
14
|
+
readonly snapshots?: SnapshotReader | readonly PortableSnapshot[];
|
|
15
|
+
readonly readMode?: "read-through" | "snapshot-only";
|
|
16
|
+
readonly maxConflictRetries?: number;
|
|
17
|
+
readonly signal?: AbortSignal;
|
|
18
|
+
readonly totalBudgetMs?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ReadOptions {
|
|
21
|
+
readonly consistency?: "safe" | "unsafe";
|
|
22
|
+
readonly signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
export interface WrittenEvent {
|
|
25
|
+
readonly [key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface TagWriteResult {
|
|
28
|
+
readonly [key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export type ExecutorCommitted = ExecuteCommitted & {
|
|
31
|
+
readonly writtenEvents: readonly WrittenEvent[];
|
|
32
|
+
readonly tagWriteResults: readonly TagWriteResult[];
|
|
33
|
+
readonly head: string;
|
|
34
|
+
readonly heads: readonly {
|
|
35
|
+
readonly tag: Tag;
|
|
36
|
+
readonly head: string;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
export type ExecutorConflict = ExecuteConflict & {
|
|
40
|
+
readonly conflicts: readonly {
|
|
41
|
+
readonly tag: Tag;
|
|
42
|
+
readonly expectedHead: string;
|
|
43
|
+
readonly actualHead?: string;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
export type ExecuteCommandResult = ExecutorCommitted | ExecutorConflict | Exclude<ExecuteResult, ExecuteCommitted | ExecuteConflict>;
|
|
47
|
+
export interface SekibanExecutor {
|
|
48
|
+
execute<C extends CommandDefinition>(command: C, input: CommandInput<C>, options?: ExecuteCommandOptions): Promise<ExecuteCommandResult>;
|
|
49
|
+
readState<P extends ProjectorLike>(projector: P, tag: Tag, options?: ReadOptions): Promise<PortableSnapshot>;
|
|
50
|
+
exists(tag: Tag, options?: ReadOptions): Promise<PortableSnapshot<undefined>>;
|
|
51
|
+
query(request: QueryRequest, options?: ReadOptions): Promise<QueryResponse>;
|
|
52
|
+
listQuery(request: ListQueryRequest, options?: ReadOptions): Promise<ListQueryResponse>;
|
|
53
|
+
readonly transport: SerializedDcbTransport;
|
|
54
|
+
}
|
|
55
|
+
export interface SekibanCloudTransportOptions {
|
|
56
|
+
readonly BaseUrl: string;
|
|
57
|
+
readonly ServiceId: string;
|
|
58
|
+
readonly CredentialId: string;
|
|
59
|
+
readonly CredentialSecret: string;
|
|
60
|
+
readonly fetch?: typeof fetch;
|
|
61
|
+
}
|
|
62
|
+
/** Use the Worker's internal service binding; no public HTTP hop is introduced. */
|
|
63
|
+
export declare function createInProcessTransport(env: RuntimeBindings, options?: {
|
|
64
|
+
readonly serviceId?: string;
|
|
65
|
+
}): SerializedDcbTransport;
|
|
66
|
+
export declare function createHttpTransport(options: {
|
|
67
|
+
readonly baseUrl: string;
|
|
68
|
+
readonly headers?: Record<string, string>;
|
|
69
|
+
readonly fetch?: typeof fetch;
|
|
70
|
+
}): SerializedDcbTransport;
|
|
71
|
+
export declare function createSekibanCloudTransport(options: SekibanCloudTransportOptions): SerializedDcbTransport;
|
|
72
|
+
export declare function createSekibanExecutor(transport: SerializedDcbTransport, options?: {
|
|
73
|
+
readonly serviceId?: string;
|
|
74
|
+
readonly clock?: () => number;
|
|
75
|
+
}): SekibanExecutor;
|