@warmhub/sdk-ts 0.45.0 → 0.46.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/{chunk-ERGCQLFH.js → chunk-RX3ZL6P5.js} +525 -28
- package/dist/chunk-RX3ZL6P5.js.map +1 -0
- package/dist/index.d.ts +232 -13
- package/dist/index.js +1 -1
- package/dist/react.js +2 -2
- package/package.json +26 -2
- package/dist/chunk-ERGCQLFH.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -81,10 +81,12 @@ type CommitApplyResult = {
|
|
|
81
81
|
message?: string;
|
|
82
82
|
operationCount: number;
|
|
83
83
|
operations: Array<{
|
|
84
|
+
opIndex?: number;
|
|
84
85
|
name: string;
|
|
85
86
|
operation: 'add' | 'revise' | 'retract' | 'noop';
|
|
86
87
|
version: number;
|
|
87
88
|
dataHash: string;
|
|
89
|
+
status?: 'applied' | 'noop';
|
|
88
90
|
warnings?: {
|
|
89
91
|
undeclaredFields: Array<string>;
|
|
90
92
|
undeclaredFieldsTruncated?: true;
|
|
@@ -214,6 +216,7 @@ type StreamAppendInput$1 = {
|
|
|
214
216
|
componentId?: string;
|
|
215
217
|
workspaceName?: never;
|
|
216
218
|
committer?: string;
|
|
219
|
+
message?: string;
|
|
217
220
|
allocatedTokens?: Array<{
|
|
218
221
|
tokenNumber: number;
|
|
219
222
|
}>;
|
|
@@ -281,6 +284,7 @@ type StreamAppendResult$1 = {
|
|
|
281
284
|
tokenNumber: number;
|
|
282
285
|
}>;
|
|
283
286
|
results: Array<{
|
|
287
|
+
opIndex?: number;
|
|
284
288
|
name: string;
|
|
285
289
|
operation?: 'add' | 'revise' | 'retract' | 'noop';
|
|
286
290
|
version?: number;
|
|
@@ -290,12 +294,15 @@ type StreamAppendResult$1 = {
|
|
|
290
294
|
code: string;
|
|
291
295
|
message: string;
|
|
292
296
|
};
|
|
297
|
+
resolvedName?: string;
|
|
298
|
+
retryable?: boolean;
|
|
293
299
|
warnings?: {
|
|
294
300
|
undeclaredFields: Array<string>;
|
|
295
301
|
undeclaredFieldsTruncated?: true;
|
|
296
302
|
totalUndeclared?: number;
|
|
297
303
|
};
|
|
298
304
|
}>;
|
|
305
|
+
createdByEmail?: string;
|
|
299
306
|
appendTotalMs?: number;
|
|
300
307
|
appendResolveRepoMs?: number;
|
|
301
308
|
appendTokenResolveMs?: number;
|
|
@@ -572,7 +579,7 @@ type WireScopeEntry$1 = {
|
|
|
572
579
|
* Add operation accepted by `client.commit.apply`. Use this shape to create new
|
|
573
580
|
* shapes, things, assertions, or collections in a single commit.
|
|
574
581
|
*
|
|
575
|
-
* @see https://docs.warmhub.ai/
|
|
582
|
+
* @see https://docs.warmhub.ai/writes/operations/#add-operations
|
|
576
583
|
*/
|
|
577
584
|
interface AddOperation {
|
|
578
585
|
/**
|
|
@@ -622,7 +629,7 @@ interface AddOperation {
|
|
|
622
629
|
* field is declared `never` at the type level, so passing `active: false` is
|
|
623
630
|
* a compile error. Use a {@link RetractOperation} to mark an entity inactive.
|
|
624
631
|
*
|
|
625
|
-
* @see https://docs.warmhub.ai/
|
|
632
|
+
* @see https://docs.warmhub.ai/writes/operations/#revise-operations
|
|
626
633
|
*/
|
|
627
634
|
interface ReviseOperation {
|
|
628
635
|
/**
|
|
@@ -656,7 +663,7 @@ interface ReviseOperation {
|
|
|
656
663
|
* Retract operation accepted by `client.commit.apply`. Marks the target as
|
|
657
664
|
* retracted in a new version; prior versions remain queryable by history.
|
|
658
665
|
*
|
|
659
|
-
* @see https://docs.warmhub.ai/
|
|
666
|
+
* @see https://docs.warmhub.ai/writes/operations/#retract-operations
|
|
660
667
|
*/
|
|
661
668
|
interface RetractOperation {
|
|
662
669
|
/**
|
|
@@ -705,18 +712,20 @@ interface RetractOperation {
|
|
|
705
712
|
* await client.commit.apply("acme", "world", "seed", ops);
|
|
706
713
|
* ```
|
|
707
714
|
*
|
|
708
|
-
* @see https://docs.warmhub.ai/sdk/
|
|
715
|
+
* @see https://docs.warmhub.ai/sdk/write-methods/#typing-operation-arrays
|
|
709
716
|
*/
|
|
710
717
|
type Operation = AddOperation | ReviseOperation | RetractOperation;
|
|
711
718
|
|
|
712
719
|
/**
|
|
713
720
|
* Default number of operations the SDK sends per stream append chunk.
|
|
714
|
-
*
|
|
721
|
+
*
|
|
722
|
+
* @internal
|
|
715
723
|
*/
|
|
716
724
|
declare const DEFAULT_STREAM_CHUNK_SIZE = 1000;
|
|
717
725
|
/**
|
|
718
726
|
* Maximum number of operations accepted by one stream append chunk.
|
|
719
|
-
*
|
|
727
|
+
*
|
|
728
|
+
* @internal
|
|
720
729
|
*/
|
|
721
730
|
declare const MAX_STREAM_APPEND_OPERATION_COUNT = 10000;
|
|
722
731
|
interface OperationStreamClient {
|
|
@@ -726,18 +735,29 @@ interface OperationStreamClient {
|
|
|
726
735
|
}
|
|
727
736
|
type SubmittedStreamResult = {
|
|
728
737
|
committer?: string;
|
|
738
|
+
createdByEmail?: string;
|
|
729
739
|
message: string | undefined;
|
|
730
740
|
operationCount: number;
|
|
741
|
+
partial?: boolean;
|
|
742
|
+
statusCounts?: {
|
|
743
|
+
applied: number;
|
|
744
|
+
noop: number;
|
|
745
|
+
error: number;
|
|
746
|
+
};
|
|
731
747
|
operations: Array<{
|
|
748
|
+
opIndex?: number;
|
|
732
749
|
name: string;
|
|
733
750
|
operation: 'add' | 'revise' | 'retract' | 'noop';
|
|
734
751
|
dataHash: string;
|
|
735
752
|
version: number;
|
|
736
|
-
status?: '
|
|
753
|
+
status?: 'applied' | 'noop' | 'error';
|
|
737
754
|
error?: {
|
|
738
755
|
code: string;
|
|
739
756
|
message: string;
|
|
740
757
|
};
|
|
758
|
+
submittedName?: string;
|
|
759
|
+
resolvedName?: string;
|
|
760
|
+
retryable?: boolean;
|
|
741
761
|
/**
|
|
742
762
|
* Non-blocking warnings collected during shape validation — see GH-1418.
|
|
743
763
|
* Aliased to the generated wire shape so this type cannot drift from
|
|
@@ -746,6 +766,10 @@ type SubmittedStreamResult = {
|
|
|
746
766
|
warnings?: NonNullable<StreamAppendResult$1['results'][number]['warnings']>;
|
|
747
767
|
}>;
|
|
748
768
|
};
|
|
769
|
+
/** @internal */
|
|
770
|
+
declare function streamAppendResultStatus(result: StreamAppendResult$1['results'][number]): NonNullable<SubmittedStreamResult['operations'][number]['status']>;
|
|
771
|
+
/** @internal */
|
|
772
|
+
declare function countStreamAppendResultStatuses(results: StreamAppendResult$1['results']): NonNullable<SubmittedStreamResult['statusCounts']>;
|
|
749
773
|
/**
|
|
750
774
|
* Continuation state for caller-managed streamed commit submissions.
|
|
751
775
|
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/streamcontinuationstate/
|
|
@@ -769,6 +793,10 @@ type RetryPolicyOptions = {
|
|
|
769
793
|
baseDelayMs?: number;
|
|
770
794
|
maxDelayMs?: number;
|
|
771
795
|
};
|
|
796
|
+
type StreamFailureCause = {
|
|
797
|
+
code: string;
|
|
798
|
+
message: string;
|
|
799
|
+
};
|
|
772
800
|
/**
|
|
773
801
|
* Error raised when a streamed commit submission fails after an ambiguous or
|
|
774
802
|
* partial append.
|
|
@@ -802,6 +830,19 @@ declare class PartialStreamSubmissionError extends Error {
|
|
|
802
830
|
completedOperations: SubmittedStreamResult['operations'];
|
|
803
831
|
});
|
|
804
832
|
}
|
|
833
|
+
/**
|
|
834
|
+
* Error raised when the stream append path completed deterministically but
|
|
835
|
+
* every submitted operation failed.
|
|
836
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/allstreamoperationsfailederror/
|
|
837
|
+
*/
|
|
838
|
+
declare class AllStreamOperationsFailedError extends Error {
|
|
839
|
+
readonly code = "STREAM_ALL_OPERATIONS_FAILED";
|
|
840
|
+
readonly result: SubmittedStreamResult;
|
|
841
|
+
readonly operations: SubmittedStreamResult['operations'];
|
|
842
|
+
readonly statusCounts: NonNullable<SubmittedStreamResult['statusCounts']>;
|
|
843
|
+
readonly cause?: StreamFailureCause;
|
|
844
|
+
constructor(result: SubmittedStreamResult);
|
|
845
|
+
}
|
|
805
846
|
/**
|
|
806
847
|
* Submit `operations` to the WarmHub stream-append surface, chunked to
|
|
807
848
|
* stay under MAX_STREAM_APPEND_OPERATION_COUNT.
|
|
@@ -879,6 +920,7 @@ declare class PartialStreamSubmissionError extends Error {
|
|
|
879
920
|
* full idempotency contract.
|
|
880
921
|
*
|
|
881
922
|
* @see https://docs.warmhub.ai/sdk/transient-retry/
|
|
923
|
+
* @internal
|
|
882
924
|
*/
|
|
883
925
|
declare function submitOperationsViaStream(client: OperationStreamClient, args: {
|
|
884
926
|
orgName: string;
|
|
@@ -910,6 +952,61 @@ type CollectionAbout$1 = {
|
|
|
910
952
|
list: string[];
|
|
911
953
|
};
|
|
912
954
|
|
|
955
|
+
/**
|
|
956
|
+
* Canonical request signing for component CLI dispatch.
|
|
957
|
+
*
|
|
958
|
+
* Component workers expose CLI methods over HTTP. The platform dispatcher
|
|
959
|
+
* signs each call with HMAC-SHA256 over a canonical request representation
|
|
960
|
+
* so the worker can authenticate the caller without sharing more than a
|
|
961
|
+
* single secret. The same canonical input works for GET and POST methods:
|
|
962
|
+
* the difference is whether the method args ride in the query string or
|
|
963
|
+
* the body.
|
|
964
|
+
*
|
|
965
|
+
* Canonical signing input:
|
|
966
|
+
* <METHOD>\n<PATH>\n<CANONICAL_QUERY>\n<INSTALL_REPO>\n<SHA256_HEX(BODY)>\n<TIMESTAMP>
|
|
967
|
+
*
|
|
968
|
+
* Where:
|
|
969
|
+
* - METHOD is the uppercased HTTP method ('GET' | 'POST').
|
|
970
|
+
* - PATH is the URL path component (no scheme, host, or query).
|
|
971
|
+
* - CANONICAL_QUERY is `canonicalCliQueryString(query)` — sorted, RFC 3986
|
|
972
|
+
* percent-encoded, omitting undefined / null entries.
|
|
973
|
+
* - INSTALL_REPO is the `<org>/<repo>` slug of the install, transmitted on
|
|
974
|
+
* the wire as the `X-WarmHub-Install-Repo` header.
|
|
975
|
+
* - BODY is the raw request body string ('' for GET).
|
|
976
|
+
* - TIMESTAMP is unix-seconds since epoch (string-formatted).
|
|
977
|
+
*
|
|
978
|
+
* Verifiers should enforce a tolerance window on the timestamp to bound
|
|
979
|
+
* replay attacks (default 300 s); they should also compare signatures in
|
|
980
|
+
* constant time.
|
|
981
|
+
*
|
|
982
|
+
* This module is intentionally low-level: component authors import the
|
|
983
|
+
* higher-level `verifyCliCall(request, secret)` wrapper from
|
|
984
|
+
* `@warmhub/sdk-ts`, which extracts the canonical inputs from a Fetch
|
|
985
|
+
* `Request` and calls `verifyCliRequest` for them.
|
|
986
|
+
*/
|
|
987
|
+
/**
|
|
988
|
+
* Wire header names for component CLI dispatch — the single source of truth
|
|
989
|
+
* shared by the backend dispatcher (which sets them) and `verifyCliCall` (which
|
|
990
|
+
* reads them). The install repo always rides in {@link CLI_INSTALL_REPO_HEADER};
|
|
991
|
+
* the signing scheme adds {@link CLI_SIGNATURE_HEADER} + {@link CLI_TIMESTAMP_HEADER}.
|
|
992
|
+
* @see https://docs.warmhub.ai/sdk-reference/variables/cli_install_repo_header/
|
|
993
|
+
*/
|
|
994
|
+
declare const CLI_INSTALL_REPO_HEADER = "X-WarmHub-Install-Repo";
|
|
995
|
+
/**
|
|
996
|
+
* @see https://docs.warmhub.ai/sdk-reference/variables/cli_signature_header/
|
|
997
|
+
*/
|
|
998
|
+
declare const CLI_SIGNATURE_HEADER = "X-WarmHub-Signature";
|
|
999
|
+
/**
|
|
1000
|
+
* @see https://docs.warmhub.ai/sdk-reference/variables/cli_timestamp_header/
|
|
1001
|
+
*/
|
|
1002
|
+
declare const CLI_TIMESTAMP_HEADER = "X-WarmHub-Timestamp";
|
|
1003
|
+
/**
|
|
1004
|
+
* HTTP verbs a component CLI method can declare. No-body verbs (GET, DELETE)
|
|
1005
|
+
* carry args in the query string; body verbs (POST, PUT, PATCH) carry args in
|
|
1006
|
+
* the JSON body.
|
|
1007
|
+
*/
|
|
1008
|
+
type CliHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1009
|
+
|
|
913
1010
|
/**
|
|
914
1011
|
* Hardcoded meta-schema for validating shape definitions.
|
|
915
1012
|
* Shapes are NOT validated against a DB-stored shape — they validate against this constant.
|
|
@@ -991,6 +1088,103 @@ type ShapeValidatorResult = {
|
|
|
991
1088
|
warnings?: UndeclaredFieldsWarning;
|
|
992
1089
|
};
|
|
993
1090
|
|
|
1091
|
+
/**
|
|
1092
|
+
* Server-side verifier for component CLI dispatch calls.
|
|
1093
|
+
*
|
|
1094
|
+
* Workers that expose CLI methods declared in their component manifest
|
|
1095
|
+
* receive authenticated requests from the WarmHub platform. The platform
|
|
1096
|
+
* supports four CLI auth schemes (selected via the component's
|
|
1097
|
+
* `credentials[]` entry) and this verifier accepts a request authenticated
|
|
1098
|
+
* under whichever schemes the install configured:
|
|
1099
|
+
*
|
|
1100
|
+
* 1. `CLI_SIGNING_SECRET` — HMAC-SHA256 over the canonical request,
|
|
1101
|
+
* transmitted as `X-WarmHub-Signature` + `X-WarmHub-Timestamp`.
|
|
1102
|
+
* 2. `CLI_BEARER_TOKEN` — `Authorization: Bearer <token>`.
|
|
1103
|
+
* 3. `CLI_API_KEY` (+ optional `CLI_API_KEY_HEADER`, default `X-API-Key`)
|
|
1104
|
+
* — custom header carrying the key.
|
|
1105
|
+
* 4. `CLI_BASIC_USERNAME` + `CLI_BASIC_PASSWORD` — `Authorization: Basic …`.
|
|
1106
|
+
*
|
|
1107
|
+
* Multiple schemes can be configured at once; in that case the verifier
|
|
1108
|
+
* requires ALL of them to validate (downgrade-attack defense — an attacker
|
|
1109
|
+
* who learns only one credential can't drop the other from the request).
|
|
1110
|
+
* If none are configured, the call is rejected as misconfigured.
|
|
1111
|
+
*
|
|
1112
|
+
* import { verifyCliCall } from '@warmhub/sdk-ts'
|
|
1113
|
+
*
|
|
1114
|
+
* app.get('/list-reputations', async (c) => {
|
|
1115
|
+
* const { args, installRepo } = await verifyCliCall(c.req.raw, c.env)
|
|
1116
|
+
* return c.json(await listReputations(db, args.scope, args.limit, args.cursor))
|
|
1117
|
+
* })
|
|
1118
|
+
*
|
|
1119
|
+
* Wire format (orthogonal to the auth scheme):
|
|
1120
|
+
* - GET / DELETE: method args ride in the URL query string. Body is empty.
|
|
1121
|
+
* - POST / PUT / PATCH: method args are the JSON body (no envelope wrapper).
|
|
1122
|
+
* - The install repo always rides in `X-WarmHub-Install-Repo`.
|
|
1123
|
+
*
|
|
1124
|
+
* Throws `CliCallVerificationError` on any failure. The error's `reason`
|
|
1125
|
+
* field is one of a small fixed set so callers can map onto HTTP statuses
|
|
1126
|
+
* without string-matching messages.
|
|
1127
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/clicallverificationfailurereason/
|
|
1128
|
+
*/
|
|
1129
|
+
|
|
1130
|
+
type CliCallVerificationFailureReason = 'missing-signature' | 'missing-timestamp' | 'invalid-timestamp' | 'missing-install-repo' | 'unsupported-method' | 'invalid-signature' | 'invalid-format' | 'expired' | 'invalid-body' | 'no-scheme-configured' | 'invalid-bearer' | 'invalid-api-key' | 'invalid-basic';
|
|
1131
|
+
/**
|
|
1132
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/clicallverificationerror/
|
|
1133
|
+
*/
|
|
1134
|
+
declare class CliCallVerificationError extends Error {
|
|
1135
|
+
readonly reason: CliCallVerificationFailureReason;
|
|
1136
|
+
constructor(reason: CliCallVerificationFailureReason, message: string);
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* @see https://docs.warmhub.ai/sdk-reference/interfaces/verifiedclicall/
|
|
1140
|
+
*/
|
|
1141
|
+
interface VerifiedCliCall {
|
|
1142
|
+
/** HTTP method the request arrived on. */
|
|
1143
|
+
method: CliHttpMethod;
|
|
1144
|
+
/**
|
|
1145
|
+
* `<org>/<repo>` slug of the install, from the install-repo header.
|
|
1146
|
+
*
|
|
1147
|
+
* Only cryptographically bound under the signing scheme (the HMAC covers the
|
|
1148
|
+
* install repo). Under token schemes (bearer / api-key / basic) it is
|
|
1149
|
+
* caller-asserted — verifying the request does NOT prove the caller is
|
|
1150
|
+
* entitled to this install. When the install repo drives authorization, bind
|
|
1151
|
+
* it (resolve the per-install secret keyed by this value and verify with it)
|
|
1152
|
+
* or require the signing scheme. See docs/dev/component-rules.md → "What each
|
|
1153
|
+
* scheme binds".
|
|
1154
|
+
*/
|
|
1155
|
+
installRepo: string;
|
|
1156
|
+
/** Method args — query params for GET, parsed JSON body for POST/PUT/PATCH. */
|
|
1157
|
+
args: Record<string, string | number | boolean | undefined>;
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Secret bundle accepted by `verifyCliCall`. Pass your worker's full env
|
|
1161
|
+
* (e.g. `c.env`) or just the CLI_* subset — the verifier looks only at the
|
|
1162
|
+
* keys it knows.
|
|
1163
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/clicallsecrets/
|
|
1164
|
+
*/
|
|
1165
|
+
type CliCallSecrets = Partial<{
|
|
1166
|
+
CLI_SIGNING_SECRET: string;
|
|
1167
|
+
CLI_BEARER_TOKEN: string;
|
|
1168
|
+
CLI_API_KEY: string;
|
|
1169
|
+
/** Custom header name for `CLI_API_KEY`. Defaults to `X-API-Key`. */
|
|
1170
|
+
CLI_API_KEY_HEADER: string;
|
|
1171
|
+
CLI_BASIC_USERNAME: string;
|
|
1172
|
+
CLI_BASIC_PASSWORD: string;
|
|
1173
|
+
}> & Record<string, string | undefined>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Verify and parse an inbound component CLI call.
|
|
1176
|
+
*
|
|
1177
|
+
* @param request - The Fetch `Request` as received by the worker.
|
|
1178
|
+
* @param secrets - Credential set values (see `CliCallSecrets`).
|
|
1179
|
+
* @param opts - Optional overrides. `nowUnixSeconds` defaults to the
|
|
1180
|
+
* current wall clock; `toleranceSec` defaults to 300 s.
|
|
1181
|
+
* @see https://docs.warmhub.ai/sdk-reference/functions/verifyclicall/
|
|
1182
|
+
*/
|
|
1183
|
+
declare function verifyCliCall(request: Request, secrets: CliCallSecrets, opts?: {
|
|
1184
|
+
nowUnixSeconds?: number;
|
|
1185
|
+
toleranceSec?: number;
|
|
1186
|
+
}): Promise<VerifiedCliCall>;
|
|
1187
|
+
|
|
994
1188
|
/**
|
|
995
1189
|
* Shape field definitions — the value side of a shape's data.fields
|
|
996
1190
|
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/shapefields/
|
|
@@ -1169,7 +1363,7 @@ type ReviseInput = Omit<ReviseOp, 'operation'> | ReviseOp;
|
|
|
1169
1363
|
* const result = await cb.commit({ client, orgName: "acme", repoName: "world" });
|
|
1170
1364
|
* ```
|
|
1171
1365
|
*
|
|
1172
|
-
* @see https://docs.warmhub.ai/sdk/
|
|
1366
|
+
* @see https://docs.warmhub.ai/sdk/write-methods/
|
|
1173
1367
|
*/
|
|
1174
1368
|
declare class OperationBuilder {
|
|
1175
1369
|
private readonly ops;
|
|
@@ -1257,7 +1451,7 @@ declare class OperationBuilder {
|
|
|
1257
1451
|
/**
|
|
1258
1452
|
* Validate, submit, and seal the builder.
|
|
1259
1453
|
*
|
|
1260
|
-
* A successful call submits operations through the same stream path as `client.commit.apply` and makes the builder single-use. Validation failures throw before any server request is made. Ambiguous multi-chunk failures surface as `PartialStreamSubmissionError
|
|
1454
|
+
* A successful call submits operations through the same stream path as `client.commit.apply` and makes the builder single-use. Validation failures throw before any server request is made. Ambiguous multi-chunk failures surface as `PartialStreamSubmissionError`; deterministic all-failed batches surface as `AllStreamOperationsFailedError` with per-op failure data.
|
|
1261
1455
|
*
|
|
1262
1456
|
* @param params.client WarmHub client or compatible stream client used for submission.
|
|
1263
1457
|
* @param params.message Optional commit message.
|
|
@@ -2367,6 +2561,16 @@ declare function isConnectionError(error: unknown): boolean;
|
|
|
2367
2561
|
* @see https://docs.warmhub.ai/sdk-reference/functions/connectionerrormessage/
|
|
2368
2562
|
*/
|
|
2369
2563
|
declare function connectionErrorMessage(url: string): string;
|
|
2564
|
+
/**
|
|
2565
|
+
* Returns true when `version` is strictly older than `minimum`. Both
|
|
2566
|
+
* arguments must parse as semver-shaped strings (major.minor.patch with
|
|
2567
|
+
* optional prerelease and build metadata); non-parseable inputs return
|
|
2568
|
+
* false (fail-open) so a malformed `minSupportedSdk` from a future
|
|
2569
|
+
* backend cannot brick existing clients.
|
|
2570
|
+
*
|
|
2571
|
+
* @internal
|
|
2572
|
+
*/
|
|
2573
|
+
declare function sdkVersionIsBelowMinimum(version: string, minimum: string): boolean;
|
|
2370
2574
|
/**
|
|
2371
2575
|
* Primary TypeScript client for the WarmHub API.
|
|
2372
2576
|
*
|
|
@@ -2390,6 +2594,7 @@ declare class WarmHubClient {
|
|
|
2390
2594
|
protected readonly functionLogMode: FunctionLogMode;
|
|
2391
2595
|
protected readonly getToken?: () => Promise<string | undefined>;
|
|
2392
2596
|
private readonly trpc;
|
|
2597
|
+
private compatibilityCheck?;
|
|
2393
2598
|
/**
|
|
2394
2599
|
* Authentication helpers for browser sign-in flows, session checks, and token diagnostics.
|
|
2395
2600
|
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/#auth
|
|
@@ -2451,6 +2656,20 @@ declare class WarmHubClient {
|
|
|
2451
2656
|
* Return backend API version, minimum supported SDK version, and feature flags.
|
|
2452
2657
|
*/
|
|
2453
2658
|
capabilities: () => Promise<Capabilities>;
|
|
2659
|
+
/**
|
|
2660
|
+
* Verify the installed SDK is at or above the backend's advertised
|
|
2661
|
+
* minimum supported version, throwing a `WarmHubError` with a clear
|
|
2662
|
+
* "upgrade to >=X" message when it is not.
|
|
2663
|
+
*
|
|
2664
|
+
* Call this once at startup (e.g. immediately after constructing the
|
|
2665
|
+
* client) to fail fast on SDK version skew, rather than discovering a
|
|
2666
|
+
* removed route deep in the commit pipeline as an opaque error.
|
|
2667
|
+
* The result is cached on the client instance — repeated calls reuse
|
|
2668
|
+
* the first network round-trip and re-throw the same error if too old.
|
|
2669
|
+
*
|
|
2670
|
+
* @see https://github.com/warmhub/warmhub-app/issues/3081
|
|
2671
|
+
*/
|
|
2672
|
+
assertCompatible: () => Promise<void>;
|
|
2454
2673
|
};
|
|
2455
2674
|
/**
|
|
2456
2675
|
* Installed component inspection for packages that add shapes, subscriptions, credentials, and seed data to a repository.
|
|
@@ -2515,7 +2734,7 @@ declare class WarmHubClient {
|
|
|
2515
2734
|
/**
|
|
2516
2735
|
* High-level write surface for submitting WarmHub operations through the commit pipeline.
|
|
2517
2736
|
*
|
|
2518
|
-
* @see https://docs.warmhub.ai/sdk/
|
|
2737
|
+
* @see https://docs.warmhub.ai/sdk/write-methods/
|
|
2519
2738
|
*/
|
|
2520
2739
|
readonly commit: {
|
|
2521
2740
|
/**
|
|
@@ -2523,7 +2742,7 @@ declare class WarmHubClient {
|
|
|
2523
2742
|
*
|
|
2524
2743
|
* This is the primary write path for SDK callers. It streams operations to the backend, preserves server-side per-operation results, supports chunking for large submissions, and can attribute writes to a committer wref or installed component.
|
|
2525
2744
|
*
|
|
2526
|
-
* Simple first-chunk transport failures are retried by default.
|
|
2745
|
+
* Simple first-chunk transport failures are retried by default. Ambiguous failures surface as `PartialStreamSubmissionError`, including the case where an ambiguous attempt is followed by an all-failed retry; inspect `error.cause` for the underlying `AllStreamOperationsFailedError` or backend error. Deterministic all-failed submissions without prior ambiguity throw `AllStreamOperationsFailedError` directly so callers can inspect per-operation failure rows. Validation, auth, conflict, rate-limit, and other definite backend failures surface as `WarmHubError`. See [Transient Retry](/sdk/transient-retry/) for the full retry and partial-submission rules.
|
|
2527
2746
|
*
|
|
2528
2747
|
* Writing to an archived organization or repository fails with an `ARCHIVED` error before any operations are applied.
|
|
2529
2748
|
*
|
|
@@ -2670,7 +2889,7 @@ declare class WarmHubClient {
|
|
|
2670
2889
|
*
|
|
2671
2890
|
* The returned `total` is the sum of active shapes, things, and assertions. Use this when billing, quota checks, health reports, or per-shape breakdowns need single-repo stats.
|
|
2672
2891
|
*
|
|
2673
|
-
* The per-shape breakdown counts active things
|
|
2892
|
+
* The per-shape breakdown counts active things and assertions by shape.
|
|
2674
2893
|
*/
|
|
2675
2894
|
getStats: (orgName: string, repoName: string) => Promise<RepoStatsView>;
|
|
2676
2895
|
/**
|
|
@@ -3394,4 +3613,4 @@ declare class WarmHubClient {
|
|
|
3394
3613
|
private watchRepoQuery;
|
|
3395
3614
|
}
|
|
3396
3615
|
|
|
3397
|
-
export { type AboutOptions, type AboutResult, type AccessTokenProvider, type ActionAttemptInfo, type ActionLeaseAcquire, type ActionLeaseOp, type ActionListNotificationsOptions, type ActionListRunsOptions, type ActionLiveFeed, type ActionLiveFeedOptions, type ActionNotificationInfo, type ActionRunInfo, type AddOp, type AddOperation, type Assertion, CONTENT_FIELD_LIMIT_ERROR, type CollectionAbout, type CollectionTag, type ComponentInfo, type ComponentInstallSystemResult, type ComponentList, type ComponentListOptions, type ComponentView, type CoreErrorKind, type CountOptions, type CountResult, type CredentialAuditEntry, type CredentialDeleteResult, type CredentialGrantResult, type CredentialInfo, type CredentialKeyMutationResult, type CredentialRevokeResult, type CredentialUngrantResult, type CurrentUserInfo, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, type ErrorKind, type FilterOptions, type FilterResult, type FunctionLogMode, type HeadResult, type HistoryResult, type IndexedFieldEntry, type IndexedFieldsReport, type LiveHandle, type LiveRepoEvent, type LiveSubscriptionLogOptions, type LiveThingHeadOptions, type LiveThingHistoryOptions, type LiveWatchResult, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, type Operation, OperationBuilder, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationSubmitResult, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, type RefLink, type RefsOptions, type RefsResult, type RenameResult, type RepoConfigureStatsView, type RepoDescribeResult, type RepoInfo, type RepoList, type RepoListOptions, type RepoListPageOptions, type RepoListPageResult, type RepoLocator, type RepoRef, type RepoShapeInstanceCountsView, type RepoSort, type RepoStatsBatchResult, type RepoStatsView, type RepoWithStatsInfo, type RequestEvent, type ResolveWrefResult, type RetractOp, type RetractOperation, type RetryPolicyOptions, type ReviseOp, type ReviseOperation, SDK_VERSION, type SearchOptions, type SearchResult, type Shape, type ShapeChange, type ShapeCreateOptions, type ShapeFields, type ShapeGetOptions, type ShapeHistory, type ShapeHistoryOptions, type ShapeList, type ShapeListOptions, type ShapeRef, type ShapeRemove, type ShapeReviseOptions, type ShapeValidatorResult, type StreamAppendInput, type StreamAppendResult, type StreamContinuationState, type SubscriptionBindCredentialsResult, type SubscriptionCompatCreateInput, type SubscriptionCompatUpdateInput, type SubscriptionInfo, type SubscriptionList, type SubscriptionUnbindCredentialsResult, type SynthesizedRepoContent, type ThingDetail, type ThingGet, type ThingGetManyResult, type ThingGetOptions, type ThingGraphOptions, type ThingGraphResult, type ThingGraphValue, type ThingHead, type ThingHeadOptions, type ThingHeadRequest, type ThingHistory, type ThingHistoryOptions, type ThingItem, type TokenInfo, type TokenResult, type UndeclaredFieldsWarning, type ValidationDiagnostic, type ValidationResult, WarmHubClient, type WarmHubClientOptions, WarmHubError, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry, connectionErrorMessage, contentFieldLimitError, isConnectionError, isRetryable, isWarmHubError, normalizeWref, resolveFunctionLogMode, sanitizeErrorMessage, submitOperationsViaStream, toWarmHubError, validateAgainstShape };
|
|
3616
|
+
export { type AboutOptions, type AboutResult, type AccessTokenProvider, type ActionAttemptInfo, type ActionLeaseAcquire, type ActionLeaseOp, type ActionListNotificationsOptions, type ActionListRunsOptions, type ActionLiveFeed, type ActionLiveFeedOptions, type ActionNotificationInfo, type ActionRunInfo, type AddOp, type AddOperation, AllStreamOperationsFailedError, type Assertion, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, CONTENT_FIELD_LIMIT_ERROR, type CliCallSecrets, CliCallVerificationError, type CliCallVerificationFailureReason, type CollectionAbout, type CollectionTag, type ComponentInfo, type ComponentInstallSystemResult, type ComponentList, type ComponentListOptions, type ComponentView, type CoreErrorKind, type CountOptions, type CountResult, type CredentialAuditEntry, type CredentialDeleteResult, type CredentialGrantResult, type CredentialInfo, type CredentialKeyMutationResult, type CredentialRevokeResult, type CredentialUngrantResult, type CurrentUserInfo, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, type ErrorKind, type FilterOptions, type FilterResult, type FunctionLogMode, type HeadResult, type HistoryResult, type IndexedFieldEntry, type IndexedFieldsReport, type LiveHandle, type LiveRepoEvent, type LiveSubscriptionLogOptions, type LiveThingHeadOptions, type LiveThingHistoryOptions, type LiveWatchResult, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, type Operation, OperationBuilder, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationSubmitResult, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, type RefLink, type RefsOptions, type RefsResult, type RenameResult, type RepoConfigureStatsView, type RepoDescribeResult, type RepoInfo, type RepoList, type RepoListOptions, type RepoListPageOptions, type RepoListPageResult, type RepoLocator, type RepoRef, type RepoShapeInstanceCountsView, type RepoSort, type RepoStatsBatchResult, type RepoStatsView, type RepoWithStatsInfo, type RequestEvent, type ResolveWrefResult, type RetractOp, type RetractOperation, type RetryPolicyOptions, type ReviseOp, type ReviseOperation, SDK_VERSION, type SearchOptions, type SearchResult, type Shape, type ShapeChange, type ShapeCreateOptions, type ShapeFields, type ShapeGetOptions, type ShapeHistory, type ShapeHistoryOptions, type ShapeList, type ShapeListOptions, type ShapeRef, type ShapeRemove, type ShapeReviseOptions, type ShapeValidatorResult, type StreamAppendInput, type StreamAppendResult, type StreamContinuationState, type SubscriptionBindCredentialsResult, type SubscriptionCompatCreateInput, type SubscriptionCompatUpdateInput, type SubscriptionInfo, type SubscriptionList, type SubscriptionUnbindCredentialsResult, type SynthesizedRepoContent, type ThingDetail, type ThingGet, type ThingGetManyResult, type ThingGetOptions, type ThingGraphOptions, type ThingGraphResult, type ThingGraphValue, type ThingHead, type ThingHeadOptions, type ThingHeadRequest, type ThingHistory, type ThingHistoryOptions, type ThingItem, type TokenInfo, type TokenResult, type UndeclaredFieldsWarning, type ValidationDiagnostic, type ValidationResult, type VerifiedCliCall, WarmHubClient, type WarmHubClientOptions, WarmHubError, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, isConnectionError, isRetryable, isWarmHubError, normalizeWref, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CONTENT_FIELD_LIMIT_ERROR, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, OperationBuilder, PartialStreamSubmissionError, SDK_VERSION, WarmHubClient, WarmHubError, connectionErrorMessage, contentFieldLimitError, isConnectionError, isRetryable, isWarmHubError, normalizeWref, resolveFunctionLogMode, sanitizeErrorMessage, submitOperationsViaStream, toWarmHubError, validateAgainstShape } from './chunk-
|
|
1
|
+
export { AllStreamOperationsFailedError, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, CONTENT_FIELD_LIMIT_ERROR, CliCallVerificationError, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, OperationBuilder, PartialStreamSubmissionError, SDK_VERSION, WarmHubClient, WarmHubError, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, isConnectionError, isRetryable, isWarmHubError, normalizeWref, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall } from './chunk-RX3ZL6P5.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WarmHubClient } from './chunk-
|
|
2
|
-
export { DEFAULT_API_URL, SDK_VERSION, WarmHubClient, WarmHubError, toWarmHubError } from './chunk-
|
|
1
|
+
import { WarmHubClient } from './chunk-RX3ZL6P5.js';
|
|
2
|
+
export { DEFAULT_API_URL, SDK_VERSION, WarmHubClient, WarmHubError, toWarmHubError } from './chunk-RX3ZL6P5.js';
|
|
3
3
|
import { createContext, useMemo, useState, useEffect, useContext } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warmhub/sdk-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
6
|
+
"description": "The TypeScript SDK for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"warmhub",
|
|
9
|
+
"sdk",
|
|
10
|
+
"typescript",
|
|
11
|
+
"ai",
|
|
12
|
+
"agents",
|
|
13
|
+
"mcp",
|
|
14
|
+
"knowledge",
|
|
15
|
+
"knowledge-graph",
|
|
16
|
+
"assertions",
|
|
17
|
+
"trust",
|
|
18
|
+
"trpc"
|
|
19
|
+
],
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "WarmHub",
|
|
22
|
+
"url": "https://warmhub.ai"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://docs.warmhub.ai/get-started/quickstart/#connect-via-sdk",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"email": "support@warmhub.com"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22"
|
|
30
|
+
},
|
|
7
31
|
"main": "./dist/index.js",
|
|
8
32
|
"types": "./dist/index.d.ts",
|
|
9
33
|
"sideEffects": false,
|