@warmhub/sdk-ts 0.83.0 → 0.84.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-6AHGGJL6.js → chunk-CLDVXOJD.js} +57 -29
- package/dist/chunk-CLDVXOJD.js.map +1 -0
- package/dist/index.d.ts +67 -31
- package/dist/index.js +1 -1
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-6AHGGJL6.js.map +0 -1
|
@@ -56,6 +56,12 @@ var DEFAULT_STREAM_APPEND_CHUNK_SIZE = 1e3;
|
|
|
56
56
|
var MAX_STREAM_APPEND_OPERATION_COUNT = 1e4;
|
|
57
57
|
|
|
58
58
|
// ../rules/src/commit-types.ts
|
|
59
|
+
var COMMIT_OPERATION_KINDS = [
|
|
60
|
+
"shape",
|
|
61
|
+
"thing",
|
|
62
|
+
"assertion",
|
|
63
|
+
"collection"
|
|
64
|
+
];
|
|
59
65
|
function splitLocalPath(name) {
|
|
60
66
|
const idx = name.indexOf("/");
|
|
61
67
|
if (idx === -1) return null;
|
|
@@ -7897,9 +7903,9 @@ function normalizeOptionalName(value) {
|
|
|
7897
7903
|
|
|
7898
7904
|
// src/operation-normalize.ts
|
|
7899
7905
|
function toBackendStreamOperation(operation) {
|
|
7900
|
-
if (operation.expectedVersion !== void 0 && operation.operation !== "revise") {
|
|
7906
|
+
if (operation.expectedVersion !== void 0 && operation.operation !== "revise" && operation.operation !== "retract") {
|
|
7901
7907
|
throw new Error(
|
|
7902
|
-
"expectedVersion is only valid on revise operations \u2014 set operation
|
|
7908
|
+
"expectedVersion is only valid on revise or retract operations \u2014 set an explicit operation discriminator"
|
|
7903
7909
|
);
|
|
7904
7910
|
}
|
|
7905
7911
|
if (operation.operation === "retract") {
|
|
@@ -7908,6 +7914,7 @@ function toBackendStreamOperation(operation) {
|
|
|
7908
7914
|
name: operation.name,
|
|
7909
7915
|
...operation.kind ? { kind: operation.kind } : {},
|
|
7910
7916
|
...operation.reason ? { reason: operation.reason } : {},
|
|
7917
|
+
...operation.expectedVersion !== void 0 ? { expectedVersion: operation.expectedVersion } : {},
|
|
7911
7918
|
...operation.leaseId ? { leaseId: operation.leaseId } : {}
|
|
7912
7919
|
};
|
|
7913
7920
|
}
|
|
@@ -8012,8 +8019,8 @@ var PartialStreamSubmissionError = class extends Error {
|
|
|
8012
8019
|
code = "PARTIAL_STREAM_SUBMISSION";
|
|
8013
8020
|
/**
|
|
8014
8021
|
* Operations the SDK confirmed completed before the ambiguous or failing
|
|
8015
|
-
* append. The
|
|
8016
|
-
*
|
|
8022
|
+
* append. The attempted append may or may not have landed; do not blindly
|
|
8023
|
+
* replay it.
|
|
8017
8024
|
*/
|
|
8018
8025
|
completedOperations;
|
|
8019
8026
|
/**
|
|
@@ -8022,19 +8029,36 @@ var PartialStreamSubmissionError = class extends Error {
|
|
|
8022
8029
|
* returns sparse or empty result rows.
|
|
8023
8030
|
*/
|
|
8024
8031
|
acknowledgedOperationCount;
|
|
8032
|
+
/**
|
|
8033
|
+
* Last repository sequence returned by an acknowledged chunk that persisted
|
|
8034
|
+
* an event. This is a lower bound for known completed work, never evidence
|
|
8035
|
+
* that the attempted append did not land.
|
|
8036
|
+
*/
|
|
8037
|
+
lastAcknowledgedRepoSeq;
|
|
8038
|
+
/**
|
|
8039
|
+
* Authoritative outcome of the attempted append. `not_applied` is used only
|
|
8040
|
+
* when the SDK received explicit server rejection evidence; `unknown` means
|
|
8041
|
+
* callers must stop writes and reconcile from a later verified checkpoint.
|
|
8042
|
+
*/
|
|
8043
|
+
attemptedAppendOutcome;
|
|
8025
8044
|
/**
|
|
8026
8045
|
* Underlying error that triggered the partial submission, preserved for
|
|
8027
|
-
* diagnostics.
|
|
8046
|
+
* diagnostics. Do not infer append outcome from this field; branch on
|
|
8047
|
+
* `attemptedAppendOutcome` instead.
|
|
8028
8048
|
*/
|
|
8029
8049
|
cause;
|
|
8030
8050
|
constructor(input) {
|
|
8031
8051
|
super(
|
|
8032
|
-
"Stream submission
|
|
8052
|
+
"Stream submission outcome is incomplete or unknown. Stop sending writes; once any outstanding append can no longer apply, obtain a later verified checkpoint and reconcile before replanning."
|
|
8033
8053
|
);
|
|
8034
8054
|
this.name = "WarmHubError";
|
|
8035
8055
|
this.cause = input.cause;
|
|
8036
8056
|
this.completedOperations = input.completedOperations;
|
|
8037
8057
|
this.acknowledgedOperationCount = input.acknowledgedOperationCount ?? input.completedOperations.length;
|
|
8058
|
+
this.attemptedAppendOutcome = input.attemptedAppendOutcome;
|
|
8059
|
+
if (input.lastAcknowledgedRepoSeq !== void 0) {
|
|
8060
|
+
this.lastAcknowledgedRepoSeq = input.lastAcknowledgedRepoSeq;
|
|
8061
|
+
}
|
|
8038
8062
|
}
|
|
8039
8063
|
};
|
|
8040
8064
|
var AllStreamOperationsFailedError = class extends Error {
|
|
@@ -8189,6 +8213,9 @@ function isTransientStreamFailure(cause) {
|
|
|
8189
8213
|
function isFetchNetworkTypeError(cause) {
|
|
8190
8214
|
return cause instanceof TypeError && /fetch/i.test(cause.message);
|
|
8191
8215
|
}
|
|
8216
|
+
function isReplaySafeOperation(operation) {
|
|
8217
|
+
return operation.operation !== "revise" || operation.expectedVersion !== void 0;
|
|
8218
|
+
}
|
|
8192
8219
|
function computeBackoffDelayMs(attempt, policy) {
|
|
8193
8220
|
const exponential = policy.baseDelayMs * 2 ** Math.max(0, attempt - 1);
|
|
8194
8221
|
const jitter = Math.random() * policy.baseDelayMs;
|
|
@@ -8245,7 +8272,8 @@ async function submitOperationsViaStream(client, args) {
|
|
|
8245
8272
|
)) {
|
|
8246
8273
|
let attempt = 1;
|
|
8247
8274
|
let priorAttemptAmbiguous = false;
|
|
8248
|
-
const
|
|
8275
|
+
const chunkIsSingleOperation = chunk.length === 1;
|
|
8276
|
+
const chunkIsReplaySafe = chunk.every(isReplaySafeOperation);
|
|
8249
8277
|
while (true) {
|
|
8250
8278
|
try {
|
|
8251
8279
|
const appendResult = await client.stream.append({
|
|
@@ -8275,7 +8303,7 @@ async function submitOperationsViaStream(client, args) {
|
|
|
8275
8303
|
if (acknowledgedOperationCount === 0 && !priorAttemptAmbiguous && isDefiniteClientError(cause)) {
|
|
8276
8304
|
throw cause;
|
|
8277
8305
|
}
|
|
8278
|
-
if (acknowledgedOperationCount === 0 &&
|
|
8306
|
+
if (acknowledgedOperationCount === 0 && chunkIsSingleOperation && chunkIsReplaySafe && policy !== false && attempt < policy.maxAttempts && isTransientStreamFailure(cause)) {
|
|
8279
8307
|
await sleep(computeBackoffDelayMs(attempt, policy));
|
|
8280
8308
|
attempt += 1;
|
|
8281
8309
|
priorAttemptAmbiguous = true;
|
|
@@ -8300,7 +8328,9 @@ async function submitOperationsViaStream(client, args) {
|
|
|
8300
8328
|
throw new PartialStreamSubmissionError({
|
|
8301
8329
|
cause,
|
|
8302
8330
|
completedOperations,
|
|
8303
|
-
acknowledgedOperationCount
|
|
8331
|
+
acknowledgedOperationCount,
|
|
8332
|
+
lastAcknowledgedRepoSeq: repoSeq,
|
|
8333
|
+
attemptedAppendOutcome: !priorAttemptAmbiguous && isDefiniteClientError(cause) ? "not_applied" : "unknown"
|
|
8304
8334
|
});
|
|
8305
8335
|
}
|
|
8306
8336
|
}
|
|
@@ -8322,7 +8352,9 @@ async function submitOperationsViaStream(client, args) {
|
|
|
8322
8352
|
throw new PartialStreamSubmissionError({
|
|
8323
8353
|
cause: failure,
|
|
8324
8354
|
completedOperations: completedOperationsFrom(result),
|
|
8325
|
-
acknowledgedOperationCount
|
|
8355
|
+
acknowledgedOperationCount,
|
|
8356
|
+
lastAcknowledgedRepoSeq: repoSeq,
|
|
8357
|
+
attemptedAppendOutcome: "unknown"
|
|
8326
8358
|
});
|
|
8327
8359
|
}
|
|
8328
8360
|
throw failure;
|
|
@@ -8449,7 +8481,7 @@ var SDK_DEVELOPMENT_VERSION = "0.0.0-development";
|
|
|
8449
8481
|
function sdkVersionIsDevelopment(version) {
|
|
8450
8482
|
return version === SDK_DEVELOPMENT_VERSION;
|
|
8451
8483
|
}
|
|
8452
|
-
var SDK_VERSION = "0.
|
|
8484
|
+
var SDK_VERSION = "0.84.0" ;
|
|
8453
8485
|
|
|
8454
8486
|
// src/component-cli.ts
|
|
8455
8487
|
var SUPPORTED_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -8689,13 +8721,7 @@ function normalizeReviseKind(op, name) {
|
|
|
8689
8721
|
}
|
|
8690
8722
|
function toBackendOp(op) {
|
|
8691
8723
|
if (op.operation === "retract") {
|
|
8692
|
-
return
|
|
8693
|
-
operation: "retract",
|
|
8694
|
-
name: op.name,
|
|
8695
|
-
...op.kind ? { kind: op.kind } : {},
|
|
8696
|
-
...op.reason ? { reason: op.reason } : {},
|
|
8697
|
-
...op.leaseId ? { leaseId: op.leaseId } : {}
|
|
8698
|
-
};
|
|
8724
|
+
return toBackendStreamOperation(op);
|
|
8699
8725
|
}
|
|
8700
8726
|
if (op.operation === "add") {
|
|
8701
8727
|
const kind2 = normalizeAddKind(op);
|
|
@@ -8948,7 +8974,8 @@ var OperationBuilder = class {
|
|
|
8948
8974
|
/**
|
|
8949
8975
|
* Add a retract operation.
|
|
8950
8976
|
*
|
|
8951
|
-
* Pass a wref string shorthand or an object with
|
|
8977
|
+
* Pass a wref string shorthand or an object with retract options such as a
|
|
8978
|
+
* kind safety hint, reason, expected version, or lease ID.
|
|
8952
8979
|
*/
|
|
8953
8980
|
retract(target) {
|
|
8954
8981
|
this.assertCanModify();
|
|
@@ -8957,6 +8984,7 @@ var OperationBuilder = class {
|
|
|
8957
8984
|
name: target.name,
|
|
8958
8985
|
...target.kind ? { kind: target.kind } : {},
|
|
8959
8986
|
...target.reason ? { reason: target.reason } : {},
|
|
8987
|
+
...target.expectedVersion !== void 0 ? { expectedVersion: target.expectedVersion } : {},
|
|
8960
8988
|
...target.leaseId ? { leaseId: target.leaseId } : {}
|
|
8961
8989
|
});
|
|
8962
8990
|
this.ops.push(op);
|
|
@@ -9364,6 +9392,9 @@ function chunkArray(items, chunkSize) {
|
|
|
9364
9392
|
}
|
|
9365
9393
|
return chunks;
|
|
9366
9394
|
}
|
|
9395
|
+
function narrowKind(kind) {
|
|
9396
|
+
return kind !== void 0 && COMMIT_OPERATION_KINDS.includes(kind) ? kind : void 0;
|
|
9397
|
+
}
|
|
9367
9398
|
function toSubscriptionRef(args) {
|
|
9368
9399
|
const [first, repoName, name] = args;
|
|
9369
9400
|
return typeof first === "string" ? { orgName: first, repoName, name } : first;
|
|
@@ -11577,6 +11608,7 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
11577
11608
|
return await this.trpc.action.listRuns.query({
|
|
11578
11609
|
orgName,
|
|
11579
11610
|
repoName,
|
|
11611
|
+
runId: opts?.runId,
|
|
11580
11612
|
subscriptionName: opts?.subscriptionName,
|
|
11581
11613
|
status: opts?.status,
|
|
11582
11614
|
outcome: opts?.outcome,
|
|
@@ -11881,12 +11913,11 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
11881
11913
|
*/
|
|
11882
11914
|
head: async (orgName, repoName, opts) => {
|
|
11883
11915
|
try {
|
|
11884
|
-
const kind = opts?.kind === "shape" || opts?.kind === "thing" || opts?.kind === "assertion" || opts?.kind === "collection" ? opts.kind : void 0;
|
|
11885
11916
|
return await this.trpc.thing.head.query({
|
|
11886
11917
|
orgName,
|
|
11887
11918
|
repoName,
|
|
11888
11919
|
shape: opts?.shape,
|
|
11889
|
-
kind,
|
|
11920
|
+
kind: narrowKind(opts?.kind),
|
|
11890
11921
|
match: opts?.match,
|
|
11891
11922
|
dataMode: opts?.dataMode,
|
|
11892
11923
|
includeRetracted: opts?.includeRetracted,
|
|
@@ -12345,13 +12376,12 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
12345
12376
|
*/
|
|
12346
12377
|
query: async (orgName, repoName, opts) => {
|
|
12347
12378
|
try {
|
|
12348
|
-
const kind = opts?.kind === "shape" || opts?.kind === "thing" || opts?.kind === "assertion" || opts?.kind === "collection" ? opts.kind : void 0;
|
|
12349
12379
|
return await this.trpc.thing.query.query({
|
|
12350
12380
|
orgName,
|
|
12351
12381
|
repoName,
|
|
12352
12382
|
shape: opts?.shape,
|
|
12353
12383
|
about: opts?.about,
|
|
12354
|
-
kind,
|
|
12384
|
+
kind: narrowKind(opts?.kind),
|
|
12355
12385
|
match: opts?.match,
|
|
12356
12386
|
includeRetracted: opts?.includeRetracted,
|
|
12357
12387
|
resolveCollections: opts?.resolveCollections,
|
|
@@ -12439,14 +12469,13 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
12439
12469
|
*/
|
|
12440
12470
|
search: async (orgName, repoName, query, opts) => {
|
|
12441
12471
|
try {
|
|
12442
|
-
const kind = opts?.kind === "shape" || opts?.kind === "thing" || opts?.kind === "assertion" || opts?.kind === "collection" ? opts.kind : void 0;
|
|
12443
12472
|
return await this.trpc.thing.search.query({
|
|
12444
12473
|
orgName,
|
|
12445
12474
|
repoName,
|
|
12446
12475
|
query,
|
|
12447
12476
|
shape: opts?.shape,
|
|
12448
12477
|
about: opts?.about,
|
|
12449
|
-
kind,
|
|
12478
|
+
kind: narrowKind(opts?.kind),
|
|
12450
12479
|
match: opts?.match,
|
|
12451
12480
|
includeRetracted: opts?.includeRetracted,
|
|
12452
12481
|
resolveCollections: opts?.resolveCollections,
|
|
@@ -12496,13 +12525,12 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
12496
12525
|
*/
|
|
12497
12526
|
count: async (orgName, repoName, opts) => {
|
|
12498
12527
|
try {
|
|
12499
|
-
const kind = opts?.kind === "shape" || opts?.kind === "thing" || opts?.kind === "assertion" || opts?.kind === "collection" ? opts.kind : void 0;
|
|
12500
12528
|
return await this.trpc.thing.count.query({
|
|
12501
12529
|
orgName,
|
|
12502
12530
|
repoName,
|
|
12503
12531
|
shape: opts?.shape,
|
|
12504
12532
|
about: opts?.about,
|
|
12505
|
-
kind,
|
|
12533
|
+
kind: narrowKind(opts?.kind),
|
|
12506
12534
|
match: opts?.match,
|
|
12507
12535
|
includeRetracted: opts?.includeRetracted,
|
|
12508
12536
|
resolveCollections: opts?.resolveCollections,
|
|
@@ -13272,5 +13300,5 @@ re2js/build/index.js:
|
|
|
13272
13300
|
*/
|
|
13273
13301
|
|
|
13274
13302
|
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_COUNT2 as 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 };
|
|
13275
|
-
//# sourceMappingURL=chunk-
|
|
13276
|
-
//# sourceMappingURL=chunk-
|
|
13303
|
+
//# sourceMappingURL=chunk-CLDVXOJD.js.map
|
|
13304
|
+
//# sourceMappingURL=chunk-CLDVXOJD.js.map
|