@warmhub/sdk-ts 0.88.0 → 0.90.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/checkpoint.js +1 -1
- package/dist/{chunk-YWDIWGQP.js → chunk-AMPLDVYO.js} +3 -3
- package/dist/chunk-AMPLDVYO.js.map +1 -0
- package/dist/chunk-GRGWPGK4.js +8 -0
- package/dist/chunk-GRGWPGK4.js.map +1 -0
- package/dist/index.d.ts +77 -43
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CZI7BWOX.js +0 -8
- package/dist/chunk-CZI7BWOX.js.map +0 -1
- package/dist/chunk-YWDIWGQP.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -2367,7 +2367,7 @@ type RepositoryCheckpointStatus$1 = {
|
|
|
2367
2367
|
runStartedAt: number;
|
|
2368
2368
|
state: 'failed';
|
|
2369
2369
|
completedAt: number;
|
|
2370
|
-
failureCode: 'deadline_exceeded';
|
|
2370
|
+
failureCode: 'deadline_exceeded' | 'attempts_exhausted';
|
|
2371
2371
|
nextAction: 'retry';
|
|
2372
2372
|
} | {
|
|
2373
2373
|
checkpointId: string;
|
|
@@ -2764,7 +2764,7 @@ declare function isKnownOrgAuthScope(value: string): value is OrgAuthScope;
|
|
|
2764
2764
|
* capabilities this build understands, not to validate a response.
|
|
2765
2765
|
* @see https://docs.warmhub.ai/sdk-reference/variables/repo_auth_scopes/
|
|
2766
2766
|
*/
|
|
2767
|
-
declare const REPO_AUTH_SCOPES: readonly ["repo:read", "repo:checkpoint-read", "repo:write", "repo:configure", "repo:admin", "repo:action-callback"];
|
|
2767
|
+
declare const REPO_AUTH_SCOPES: readonly ["repo:read", "repo:checkpoint-read", "repo:checkpoint-generate", "repo:write", "repo:configure", "repo:admin", "repo:action-callback"];
|
|
2768
2768
|
/**
|
|
2769
2769
|
* A repository capability scope this build knows about. The DOMAIN type, which
|
|
2770
2770
|
* stays closed — the wire type is an open string. See `REPO_AUTH_SCOPES`.
|
|
@@ -3219,6 +3219,17 @@ interface RenameOperation {
|
|
|
3219
3219
|
*/
|
|
3220
3220
|
type Operation = AddOperation | ReviseOperation | RetractOperation | ReaffirmOperation | RenameOperation;
|
|
3221
3221
|
|
|
3222
|
+
/**
|
|
3223
|
+
* Operations to submit, in order.
|
|
3224
|
+
*
|
|
3225
|
+
* An array is normalized and preflighted as a whole before the first append.
|
|
3226
|
+
* A sync or async iterable is consumed one chunk at a time, so a producer of
|
|
3227
|
+
* unbounded length never has to be materialized — at the cost of per-chunk
|
|
3228
|
+
* rather than whole-submission validation.
|
|
3229
|
+
*
|
|
3230
|
+
* @internal
|
|
3231
|
+
*/
|
|
3232
|
+
type OperationSource = readonly Operation[] | Iterable<Operation> | AsyncIterable<Operation>;
|
|
3222
3233
|
/**
|
|
3223
3234
|
* Default number of operations the SDK sends per stream append chunk.
|
|
3224
3235
|
*
|
|
@@ -3389,6 +3400,49 @@ declare class AllStreamOperationsFailedError extends Error {
|
|
|
3389
3400
|
constructor(result: SubmittedStreamResult);
|
|
3390
3401
|
}
|
|
3391
3402
|
|
|
3403
|
+
/**
|
|
3404
|
+
* Running reducer over stream-append chunk outputs.
|
|
3405
|
+
*
|
|
3406
|
+
* Owns the receipt-era → legacy status projection for streamed submissions.
|
|
3407
|
+
* Each chunk is folded in as it is acknowledged, so the only per-operation
|
|
3408
|
+
* state that survives a chunk is the projected result row the caller is
|
|
3409
|
+
* contractually owed — no raw chunk-result array, and no submission-wide copy
|
|
3410
|
+
* of the submitted operations. Chunk-local submitted names are read for the
|
|
3411
|
+
* `submittedName` echo on failed rows and then released with the chunk.
|
|
3412
|
+
*
|
|
3413
|
+
* @internal
|
|
3414
|
+
*/
|
|
3415
|
+
declare class StreamSubmissionAggregator {
|
|
3416
|
+
readonly receipts: OperationEventReceiptV1$1[];
|
|
3417
|
+
private readonly operations;
|
|
3418
|
+
private readonly statusCounts;
|
|
3419
|
+
/** True once at least one row landed and every row failed. */
|
|
3420
|
+
get allFailed(): boolean;
|
|
3421
|
+
/**
|
|
3422
|
+
* Fold one chunk's result rows into the aggregate.
|
|
3423
|
+
*
|
|
3424
|
+
* `submittedNames` is chunk-local: entry 0 is the operation at
|
|
3425
|
+
* `chunkStart`. Pass the chunk that was submitted; it is not retained.
|
|
3426
|
+
*/
|
|
3427
|
+
addChunk(input: {
|
|
3428
|
+
results: StreamAppendResult$1['results'];
|
|
3429
|
+
chunkStart: number;
|
|
3430
|
+
submittedNames?: ReadonlyArray<{
|
|
3431
|
+
name?: string;
|
|
3432
|
+
}>;
|
|
3433
|
+
}): void;
|
|
3434
|
+
addReceipt(receipt: OperationEventReceiptV1$1): void;
|
|
3435
|
+
/** Rows confirmed applied or noop, for partial-submission recovery. */
|
|
3436
|
+
completedOperations(): SubmittedStreamResult['operations'];
|
|
3437
|
+
/** Project the accumulated state into the legacy aggregate write result. */
|
|
3438
|
+
toResult(meta: {
|
|
3439
|
+
committer?: string;
|
|
3440
|
+
createdByEmail?: string;
|
|
3441
|
+
message?: string;
|
|
3442
|
+
repoSeq?: number;
|
|
3443
|
+
}): SubmittedStreamResult;
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3392
3446
|
/**
|
|
3393
3447
|
* Submit `operations` to the WarmHub stream-append surface, chunked to
|
|
3394
3448
|
* stay under MAX_STREAM_APPEND_OPERATION_COUNT.
|
|
@@ -3417,6 +3471,22 @@ declare class AllStreamOperationsFailedError extends Error {
|
|
|
3417
3471
|
* `Operation[]` write contract. The SDK normalizes operations to the
|
|
3418
3472
|
* backend stream shape before chunking, token checks, and appends.
|
|
3419
3473
|
*
|
|
3474
|
+
* **Iterable sources.** `args.operations` also accepts a sync or async
|
|
3475
|
+
* iterable, so a caller producing millions of operations never has to
|
|
3476
|
+
* materialize them. Memory then stays flat in the *input*: only the chunk
|
|
3477
|
+
* being submitted is held. Two consequences follow from never seeing the whole
|
|
3478
|
+
* submission up front, and they are the price of the flat memory:
|
|
3479
|
+
*
|
|
3480
|
+
* - Validation is per chunk, not whole-submission. An array input is
|
|
3481
|
+
* preflighted in full before the first append, so a bad operation anywhere
|
|
3482
|
+
* rejects with nothing written. An iterable input preflights each chunk as
|
|
3483
|
+
* it fills, so a bad operation — or an error thrown by the producer itself —
|
|
3484
|
+
* surfaces only after every earlier chunk has already been committed, and
|
|
3485
|
+
* arrives as `PartialStreamSubmissionError` with `attemptedAppendOutcome:
|
|
3486
|
+
* 'not_applied'`.
|
|
3487
|
+
* - Degenerate operation sequences that span a chunk boundary are left to the
|
|
3488
|
+
* server, which already applies the identical per-chunk verdict.
|
|
3489
|
+
*
|
|
3420
3490
|
* Pass `args.retry: false` to disable retry entirely; pass
|
|
3421
3491
|
* `args.retry: { maxAttempts, baseDelayMs, maxDelayMs }` to override
|
|
3422
3492
|
* any subset of the defaults (`{ 3, 250, 8_000 }`).
|
|
@@ -3429,7 +3499,7 @@ declare function submitOperationsViaStream(client: OperationStreamClient, args:
|
|
|
3429
3499
|
repoName: string;
|
|
3430
3500
|
committer?: string;
|
|
3431
3501
|
message?: string;
|
|
3432
|
-
operations:
|
|
3502
|
+
operations: OperationSource;
|
|
3433
3503
|
componentRef?: string;
|
|
3434
3504
|
chunkSize?: number;
|
|
3435
3505
|
skipExisting?: boolean;
|
|
@@ -3444,43 +3514,6 @@ declare function submitOperationsViaStream(client: OperationStreamClient, args:
|
|
|
3444
3514
|
*/
|
|
3445
3515
|
retry?: RetryPolicyOptions | false;
|
|
3446
3516
|
}): Promise<SubmittedStreamResult>;
|
|
3447
|
-
/**
|
|
3448
|
-
* Rebase one chunk's result rows onto submission-global operation indexes.
|
|
3449
|
-
* Single owner of the `chunkStart + (opIndex ?? position)` convention — chunk
|
|
3450
|
-
* accumulators (SDK and CLI) must use this rather than re-deriving it.
|
|
3451
|
-
*
|
|
3452
|
-
* @internal
|
|
3453
|
-
*/
|
|
3454
|
-
declare function offsetChunkResultIndexes(results: StreamAppendResult$1['results'], chunkStart: number): StreamAppendResult$1['results'];
|
|
3455
|
-
/**
|
|
3456
|
-
* Derive the legacy aggregate write result from accumulated stream-append
|
|
3457
|
-
* outputs. This is the single owner of the receipt-era → legacy status
|
|
3458
|
-
* mapping; CLI and other callers that accumulate chunks themselves must use
|
|
3459
|
-
* this rather than re-implementing the projection.
|
|
3460
|
-
*
|
|
3461
|
-
* `operations` only needs the submitted names (used to echo `submittedName`
|
|
3462
|
-
* on failed rows); pass lightweight `{name}` records when the full submitted
|
|
3463
|
-
* operations are not retained.
|
|
3464
|
-
*
|
|
3465
|
-
* @internal
|
|
3466
|
-
*/
|
|
3467
|
-
declare function aggregateSubmittedStreamResult(input: {
|
|
3468
|
-
committer?: string;
|
|
3469
|
-
createdByEmail?: string;
|
|
3470
|
-
message?: string;
|
|
3471
|
-
operations: ReadonlyArray<{
|
|
3472
|
-
name?: string;
|
|
3473
|
-
}>;
|
|
3474
|
-
repoSeq?: number;
|
|
3475
|
-
receipts: OperationEventReceiptV1$1[];
|
|
3476
|
-
results: StreamAppendResult$1['results'];
|
|
3477
|
-
}): SubmittedStreamResult;
|
|
3478
|
-
/**
|
|
3479
|
-
* Operations from an aggregate that were confirmed applied or noop.
|
|
3480
|
-
*
|
|
3481
|
-
* @internal
|
|
3482
|
-
*/
|
|
3483
|
-
declare function completedOperationsFrom(result: SubmittedStreamResult): SubmittedStreamResult['operations'];
|
|
3484
3517
|
|
|
3485
3518
|
/**
|
|
3486
3519
|
* Exposed for unit tests and internal callers to avoid re-deriving status values.
|
|
@@ -5384,7 +5417,7 @@ type SearchOptions = Omit<FilterOptions, 'where' | 'role' | 'sinceRepoSeq' | 'af
|
|
|
5384
5417
|
* pagination fields (`limit`, `cursor`) are ignored.
|
|
5385
5418
|
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/countoptions/
|
|
5386
5419
|
*/
|
|
5387
|
-
type CountOptions = Omit<FilterOptions, 'role'
|
|
5420
|
+
type CountOptions = Omit<FilterOptions, 'role'>;
|
|
5388
5421
|
/**
|
|
5389
5422
|
* Options for `client.thing.refs` — wref-field reverse and forward lookups.
|
|
5390
5423
|
*
|
|
@@ -6066,7 +6099,8 @@ declare class WarmHubClient {
|
|
|
6066
6099
|
* Repository checkpoint lifecycle and artifact-access operations.
|
|
6067
6100
|
*
|
|
6068
6101
|
* Reads require unrestricted `repo:read` plus `repo:checkpoint-read`;
|
|
6069
|
-
* generation and retry additionally require `repo:
|
|
6102
|
+
* generation and retry additionally require `repo:checkpoint-generate`;
|
|
6103
|
+
* `repo:admin` remains compatible for them.
|
|
6070
6104
|
*
|
|
6071
6105
|
* `getAccess` returns a signed artifact descriptor only. It does not fetch
|
|
6072
6106
|
* the signed URL or attach the WarmHub bearer token to that URL.
|
|
@@ -7432,4 +7466,4 @@ declare class WarmHubClient {
|
|
|
7432
7466
|
private watchRepoQuery;
|
|
7433
7467
|
}
|
|
7434
7468
|
|
|
7435
|
-
export { type AboutOptions, type AboutResult, type AccessResolveInput, type AccessResolveResult, type AccessTokenProvider, type ActionAttemptInfo, type ActionDeliveryTarget, type ActionLeaseAcquire, type ActionLeaseOp, type ActionListNotificationsOptions, type ActionListRunsOptions, type ActionLiveFeed, type ActionLiveFeedItem, type ActionLiveFeedOptions, type ActionNotificationInfo, type ActionRunInfo, type ActionRunStatsInfo, type ActionRunStatsOptions, 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 CollectionAddOp, type CollectionAddType, type CollectionContainsOptions, type CollectionContainsResult, type CollectionCreateOptions, type CollectionDiffOptions, type CollectionDiffResult, type CollectionMember, type CollectionMembersOptions, type CollectionMembersPage, type CollectionMembershipRole, type CollectionMutationResult, type CollectionQuerySourceOptions, type CollectionReadDataMode, type CollectionReadSummary, type CollectionReviseOptions, type CollectionStatsOptions, type CollectionStatsResult, type CollectionTag, type CollectionType, type CommitApplyCompatibilityResult, type ComponentHistory, type ComponentHistoryOptions, type ComponentInfo, type ComponentInstallOptions, type ComponentInstallResult, type ComponentList, type ComponentListOptions, type ComponentUninstallOptions, type ComponentUninstallResult, 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 GlobalSearchOptions, type GlobalSearchResult, type GlobalSearchResultItem, type Grant, type GrantCreateOptions, type GrantListOptions, type GrantListResult, type GrantRecipientSelector, type GrantRevokeResult, type HeadResult, type HistoryResult, type HistoryVersion, type HomepageFeaturedListsResult, 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, ORG_AUTH_SCOPES, type Operation, OperationBuilder, type OperationBuilderAddInput, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceiptV1, type OperationSubmitResult, type OrgAccessResult, type OrgAuthScope, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, REPO_AUTH_SCOPES, type ReaffirmOperation, type RefLink, type RefsOptions, type RefsResult, type RenameOperation, type RenameOptions, type RenameResult, type RepoAccessResult, type RepoAuthScope, type RepoConfigureStatsView, type RepoDescribeResult, type RepoExploreBrowseOptions, type RepoExploreItem, type RepoExploreOptions, type RepoExploreResult, type RepoInfo, type RepoLicense, type RepoList, type RepoListForCallerOptions, type RepoListOptions, type RepoListPageOptions, type RepoListPageResult, type RepoLocator, type RepoRecentInfo, type RepoRef, type RepoShapeInstanceCountsView, type RepoSort, type RepoStatsBatchResult, type RepoStatsView, type RepoWithStatsInfo, type RepositoryCheckpointAccess, type RepositoryCheckpointStatus, 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 ShapeRemoveOptions, 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 ThingChanges, type ThingDetail, type ThingGet, type ThingGetManyResult, type ThingGetOptions, type ThingGetWithLease, type ThingGraphOptions, type ThingGraphResult, type ThingGraphValue, type ThingHead, type ThingHeadChangesOptions, type ThingHeadOptions, type ThingHeadRequest, type ThingHeadVersionsResult, type ThingHistory, type ThingHistoryOptions, type ThingItem, type ThingMetadata, type ThingQueryChangesOptions, type TokenInfo, type TokenResult, type UndeclaredFieldsWarning, type ValidationDiagnostic, type ValidationResult, type VerifiedCliCall, type ViewEvaluateOptions, type ViewEvaluateResult, WarmHubClient, type WarmHubClientOptions, WarmHubError, type WarmHubErrorDetails, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry,
|
|
7469
|
+
export { type AboutOptions, type AboutResult, type AccessResolveInput, type AccessResolveResult, type AccessTokenProvider, type ActionAttemptInfo, type ActionDeliveryTarget, type ActionLeaseAcquire, type ActionLeaseOp, type ActionListNotificationsOptions, type ActionListRunsOptions, type ActionLiveFeed, type ActionLiveFeedItem, type ActionLiveFeedOptions, type ActionNotificationInfo, type ActionRunInfo, type ActionRunStatsInfo, type ActionRunStatsOptions, 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 CollectionAddOp, type CollectionAddType, type CollectionContainsOptions, type CollectionContainsResult, type CollectionCreateOptions, type CollectionDiffOptions, type CollectionDiffResult, type CollectionMember, type CollectionMembersOptions, type CollectionMembersPage, type CollectionMembershipRole, type CollectionMutationResult, type CollectionQuerySourceOptions, type CollectionReadDataMode, type CollectionReadSummary, type CollectionReviseOptions, type CollectionStatsOptions, type CollectionStatsResult, type CollectionTag, type CollectionType, type CommitApplyCompatibilityResult, type ComponentHistory, type ComponentHistoryOptions, type ComponentInfo, type ComponentInstallOptions, type ComponentInstallResult, type ComponentList, type ComponentListOptions, type ComponentUninstallOptions, type ComponentUninstallResult, 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 GlobalSearchOptions, type GlobalSearchResult, type GlobalSearchResultItem, type Grant, type GrantCreateOptions, type GrantListOptions, type GrantListResult, type GrantRecipientSelector, type GrantRevokeResult, type HeadResult, type HistoryResult, type HistoryVersion, type HomepageFeaturedListsResult, 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, ORG_AUTH_SCOPES, type Operation, OperationBuilder, type OperationBuilderAddInput, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceiptV1, type OperationSource, type OperationSubmitResult, type OrgAccessResult, type OrgAuthScope, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, REPO_AUTH_SCOPES, type ReaffirmOperation, type RefLink, type RefsOptions, type RefsResult, type RenameOperation, type RenameOptions, type RenameResult, type RepoAccessResult, type RepoAuthScope, type RepoConfigureStatsView, type RepoDescribeResult, type RepoExploreBrowseOptions, type RepoExploreItem, type RepoExploreOptions, type RepoExploreResult, type RepoInfo, type RepoLicense, type RepoList, type RepoListForCallerOptions, type RepoListOptions, type RepoListPageOptions, type RepoListPageResult, type RepoLocator, type RepoRecentInfo, type RepoRef, type RepoShapeInstanceCountsView, type RepoSort, type RepoStatsBatchResult, type RepoStatsView, type RepoWithStatsInfo, type RepositoryCheckpointAccess, type RepositoryCheckpointStatus, 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 ShapeRemoveOptions, type ShapeReviseOptions, type ShapeValidatorResult, type StreamAppendInput, type StreamAppendResult, type StreamContinuationState, StreamSubmissionAggregator, type SubscriptionBindCredentialsResult, type SubscriptionCompatCreateInput, type SubscriptionCompatUpdateInput, type SubscriptionInfo, type SubscriptionList, type SubscriptionUnbindCredentialsResult, type SynthesizedRepoContent, type ThingChanges, type ThingDetail, type ThingGet, type ThingGetManyResult, type ThingGetOptions, type ThingGetWithLease, type ThingGraphOptions, type ThingGraphResult, type ThingGraphValue, type ThingHead, type ThingHeadChangesOptions, type ThingHeadOptions, type ThingHeadRequest, type ThingHeadVersionsResult, type ThingHistory, type ThingHistoryOptions, type ThingItem, type ThingMetadata, type ThingQueryChangesOptions, type TokenInfo, type TokenResult, type UndeclaredFieldsWarning, type ValidationDiagnostic, type ValidationResult, type VerifiedCliCall, type ViewEvaluateOptions, type ViewEvaluateResult, WarmHubClient, type WarmHubClientOptions, WarmHubError, type WarmHubErrorDetails, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createOperationEventRequestId, createOperationEventSubmissionId, isConnectionError, isDefiniteStreamAppendRejection, isKnownOrgAuthScope, isKnownRepoAuthScope, isRetryable, isWarmHubError, normalizeWref, operationEventStreamRequestId, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{k as AllStreamOperationsFailedError,n as CliCallVerificationError,r as DEFAULT_API_URL,h as DEFAULT_STREAM_CHUNK_SIZE,i as MAX_STREAM_APPEND_OPERATION_COUNT,p as OperationBuilder,j as PartialStreamSubmissionError,m as SDK_VERSION,d as StreamSubmissionAggregator,B as WarmHubClient,u as WarmHubError,z as connectionErrorMessage,b as countStreamAppendResultStatuses,f as createOperationEventRequestId,e as createOperationEventSubmissionId,y as isConnectionError,c as isDefiniteStreamAppendRejection,x as isRetryable,w as isWarmHubError,q as normalizeWref,g as operationEventStreamRequestId,s as resolveFunctionLogMode,t as sanitizeErrorMessage,A as sdkVersionIsBelowMinimum,a as streamAppendResultStatus,l as submitOperationsViaStream,v as toWarmHubError,o as verifyCliCall}from'./chunk-GRGWPGK4.js';export{m as CLI_INSTALL_REPO_HEADER,n as CLI_SIGNATURE_HEADER,o as CLI_TIMESTAMP_HEADER,w as CONTENT_FIELD_LIMIT_ERROR,v as MAX_CONTENT_FIELD_BYTES,y as ORG_AUTH_SCOPES,r as REPO_AUTH_SCOPES,x as contentFieldLimitError,z as isKnownOrgAuthScope,s as isKnownRepoAuthScope,M as validateAgainstShape}from'./chunk-AMPLDVYO.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {B}from'./chunk-GRGWPGK4.js';export{r as DEFAULT_API_URL,m as SDK_VERSION,B as WarmHubClient,u as WarmHubError,v as toWarmHubError}from'./chunk-GRGWPGK4.js';import'./chunk-AMPLDVYO.js';import {createContext,useMemo,useState,useEffect,useContext}from'react';import {jsx}from'react/jsx-runtime';var b=createContext(null),p=createContext({isAuthenticated:false,isLoading:true});function P({apiUrl:e,children:t,auth:i,client:o}){let r=o?.name,n=o?.version,s=useMemo(()=>new B({apiUrl:e,accessToken:async()=>await i.getAccessToken()??void 0,client:{name:r,version:n}}),[e,i.getAccessToken,r,n]);return jsx(b.Provider,{value:s,children:jsx(g,{auth:i,client:s,children:t})})}function g({auth:e,client:t,children:i}){let[o,r]=useState(null),n=e.isAuthenticated&&o===t;useEffect(()=>{if(!e.isAuthenticated){r(null);return}let u=false;return t.auth.sync().then(()=>{u||r(t);}).catch(f=>{console.error("auth.sync failed:",f),u||r(t);}),()=>{u=true;}},[e.isAuthenticated,t]);let s=useMemo(()=>({isAuthenticated:e.isAuthenticated&&n,isLoading:e.isLoading||e.isAuthenticated&&!n}),[e.isAuthenticated,e.isLoading,n]);return e.isLoading||e.isAuthenticated&&!n?null:jsx(p.Provider,{value:s,children:i})}function v(){let e=useContext(b);if(!e)throw new Error("useWarmHubClient must be used within a WarmHubProvider");return e}function S(){return useContext(p)}export{P as WarmHubProvider,S as useWarmHubAuth,v as useWarmHubClient};//# sourceMappingURL=react.js.map
|
|
2
2
|
//# sourceMappingURL=react.js.map
|
package/package.json
CHANGED
package/dist/chunk-CZI7BWOX.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {C,m,p,n,o,q as q$1,M as M$1,B,t,u,b,f,e,i,a as a$1,d as d$1,l,A,x as x$1,O,N as N$1,j,c,k as k$1,g,h}from'./chunk-YWDIWGQP.js';import {TRPCClientError,createTRPCProxyClient,splitLink,httpBatchLink,httpLink}from'@trpc/client';import {observable}from'@trpc/server/observable';function ze(n,e){return {create:async(t,r,i)=>{try{return await n().grant.create.mutate({orgName:t,repoName:r,...i})}catch(o){throw e(o)}},get:async(t,r,i)=>{try{return await n().grant.get.query({orgName:t,repoName:r,grantId:i})}catch(o){throw e(o)}},list:async(t,r,i)=>{try{return await n().grant.list.query({orgName:t,repoName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw e(o)}},revoke:async(t,r,i,o)=>{try{return await n().grant.revoke.mutate({orgName:t,repoName:r,grantId:i,reason:o?.reason})}catch(s){throw e(s)}}}}function te(n){return {...n,createdAt:new Date(n.createdAt),updatedAt:new Date(n.updatedAt),runStartedAt:new Date(n.runStartedAt),...n.state==="complete"||n.state==="failed"?{completedAt:new Date(n.completedAt)}:{}}}function _t(n){return {...n,expiresAt:new Date(n.expiresAt)}}function je(n){if(typeof n.checkpointId=="string"&&typeof n.repoSeq!="number")return {by:"id",checkpointId:n.checkpointId};if(typeof n.repoSeq=="number"&&typeof n.checkpointId!="string")return {by:"repoSeq",repoSeq:n.repoSeq};throw new TypeError("Repository checkpoint selector must contain exactly one of checkpointId or repoSeq")}function Ye(n,e){return {generate:async(t,r,i)=>{try{let o=await n().repo.checkpoint.generate.mutate({orgName:t,repoName:r,atLeastRepoSeq:i?.atLeastRepoSeq});return te(o.checkpoint)}catch(o){throw e(o)}},status:async(t,r,i)=>{try{let o=await n().repo.checkpoint.status.query({orgName:t,repoName:r,selector:je(i)});return te(o)}catch(o){throw e(o)}},latest:async(t,r)=>{try{let i=await n().repo.checkpoint.latest.query({orgName:t,repoName:r});return i.checkpoint?te(i.checkpoint):null}catch(i){throw e(i)}},getAccess:async(t,r,i)=>{try{let o=await n().repo.checkpoint.access.query({orgName:t,repoName:r,selector:i.checkpoint==="latest"?{by:"latest"}:je(i.checkpoint),artifact:i.artifact==="archive"||i.artifact==="manifest"?{kind:i.artifact}:{kind:"chunk",path:i.artifact.chunkPath}});return _t(o)}catch(o){throw e(o)}},retry:async(t,r,i)=>{try{let o=await n().repo.checkpoint.retry.mutate({orgName:t,repoName:r,checkpointId:i});return te(o.checkpoint)}catch(o){throw e(o)}}}}function V(n,e,t){let r=O(e,t==="revise"?{allowUnsafeFieldNamePaths:N$1(e)}:void 0);return r.valid?null:`Invalid shape definition for "${n}": ${r.errors.join("; ")}`}var Pt="003e7e6c-2f1e-53ea-9dfa-627edd04a8cc",Lt=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;function Qe(n){if(!Lt.test(n))throw new Error("Operation-event submission ID must be a canonical UUID");let e=n.toLowerCase().replaceAll("-","");return Uint8Array.from({length:16},(t,r)=>Number.parseInt(e.slice(r*2,r*2+2),16))}function we(n,e){return (n<<e|n>>>32-e)>>>0}function Dt(n){let e=n.length*8,t=Math.ceil((n.length+9)/64)*64,r=new Uint8Array(t);r.set(n),r[n.length]=128;let i=new DataView(r.buffer);i.setUint32(t-8,Math.floor(e/4294967296)),i.setUint32(t-4,e>>>0);let o=1732584193,s=4023233417,p=2562383102,c=271733878,u=3285377520,l=new Uint32Array(80);for(let h=0;h<t;h+=64){for(let y=0;y<16;y+=1)l[y]=i.getUint32(h+y*4);for(let y=16;y<80;y+=1)l[y]=we(l[y-3]^l[y-8]^l[y-14]^l[y-16],1);let C=o,g=s,R=p,b=c,A=u;for(let y=0;y<80;y+=1){let O,v;y<20?(O=g&R|~g&b,v=1518500249):y<40?(O=g^R^b,v=1859775393):y<60?(O=g&R|g&b|R&b,v=2400959708):(O=g^R^b,v=3395469782);let T=we(C,5)+O+A+v+l[y]>>>0;A=b,b=R,R=we(g,30),g=C,C=T;}o=o+C>>>0,s=s+g>>>0,p=p+R>>>0,c=c+b>>>0,u=u+A>>>0;}let m=new Uint8Array(20),f=new DataView(m.buffer);for(let[h,C]of [o,s,p,c,u].entries())f.setUint32(h*4,C);return m}function Mt(n){let e=Array.from(n,t=>t.toString(16).padStart(2,"0")).join("").slice(0,32);return `${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function re(){let n=globalThis.crypto?.randomUUID?.();if(!n)throw new Error("This runtime cannot mint a cryptographically secure UUID");return n.toLowerCase()}var qt=re;function Se(n,e){if(!Number.isInteger(e)||e<0||e>2147483647)throw new Error("Stream chunk ordinal must be an integer from 0 through 2147483647");Qe(n);let t=n.toLowerCase(),r=Qe(Pt),i=new TextEncoder().encode(`${t}:${e}`),o=Dt(Uint8Array.from([...r,...i])).slice(0,16);return o[6]=o[6]&15|80,o[8]=o[8]&63|128,Mt(o)}var Bt=new Set(["arc","bond","pair","set","list"]);function H(n,e){let t=Je(n,e,"add");return {operation:"add",kind:"collection",name:t.name,type:t.type,members:t.members,...n.skipExisting===true?{skipExisting:true}:{}}}function ne(n,e){let t=Je(n,e,"revise");if(!t.name)throw new Error(`${e}: collection revise requires a target name`);return {operation:"revise",kind:"collection",name:t.name,type:t.type,members:t.members,...typeof n.expectedVersion=="number"?{expectedVersion:n.expectedVersion}:{},...typeof n.leaseId=="string"&&n.leaseId.length>0?{leaseId:n.leaseId}:{}}}function Je(n,e,t){let r=B({operation:t,kind:"collection",name:typeof n.name=="string"?n.name:void 0,type:typeof n.type=="string"?n.type:void 0,members:Array.isArray(n.members)?n.members:void 0},0);if(r.length>0)throw new Error(`${e}: ${r.map(s=>s.message).join("; ")}`);let i=Vt(n.type);if(!i)throw new Error(`${e}: collection ${t} requires 'type'. Use one of: arc, bond, set, list`);if(!Array.isArray(n.members))throw new Error(`${e}: collection ${t} requires a 'members' array`);let o=Ht(n.name);if(!o)throw new Error(`${e}: collection ${t} name must be a non-empty string`);return Ut(n,e,t),{name:o,type:i,members:n.members}}function Ut(n,e,t){let r=["about","aboutWref","shapeWref","data",...t==="revise"?["skipExisting"]:[]].filter(i=>n[i]!==void 0);if(r.length>0)throw new Error(`${e}: collection ${t} does not support ${r.map(i=>`'${i}'`).join(", ")}`)}function Vt(n){if(typeof n!="string")return;let e=n.trim();if(Bt.has(e))return e}function Ht(n){if(typeof n=="string"&&!(n.length===0||n.trim()!==n))return n}function F(n){if(n.expectedVersion!==void 0&&n.operation!=="revise"&&n.operation!=="retract"&&n.operation!=="reaffirm")throw new Error("expectedVersion is only valid on revise, retract, or reaffirm operations \u2014 set an explicit operation discriminator");if(n.operation==="retract")return {operation:"retract",name:n.name,...n.kind?{kind:n.kind}:{},...n.reason?{reason:n.reason}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.operation==="reaffirm")return {operation:"reaffirm",name:n.name,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.kind?{kind:n.kind}:{},...n.add?{add:n.add}:{},...n.remove?{remove:n.remove}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.operation==="rename")return {operation:"rename",name:n.name,newName:n.newName,...n.kind?{kind:n.kind}:{}};if(n.operation==="revise"){let r=n.name??n.wref;if(!r)throw new Error("revise operation requires a target");let i=l({kind:n.kind,name:r});if(Object.hasOwn(n,"active"))throw new Error(`${i} revise operation no longer supports 'active' \u2014 use retract('${r}') instead`);if(i!=="assertion"&&n.affirmedTargets!==void 0)throw new Error(`${i} revise operation does not support 'affirmedTargets' \u2014 it applies only to assertions; set kind: 'assertion' explicitly`);if(i==="collection")return ne(n,"commit.apply");if(n.data===void 0)throw new Error(`${i} revise operation requires 'data'`);return i==="assertion"?{operation:"revise",kind:"assertion",name:r,data:n.data,...n.affirmedTargets?{affirmedTargets:n.affirmedTargets}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}:{operation:"revise",kind:i,name:r,data:n.data,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}}let e=l(n),t="skipExisting"in n?n.skipExisting:void 0;if(e!=="collection"&&("type"in n&&n.type!==void 0||"members"in n&&n.members!==void 0))throw new Error(`add operation '${n.name??""}' has collection fields but resolved kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`);if(e!=="assertion"&&n.affirmedTargets!==void 0)throw new Error(`${e} add operation does not support 'affirmedTargets' \u2014 it applies only to assertions; set kind: 'assertion' explicitly`);if(e==="collection")return H({...n,skipExisting:t},"commit.apply");if(!n.name)throw new Error("add operation requires a name");if(e==="assertion"){if(!("about"in n)||n.about===void 0)throw new Error("assertion add operation requires 'about'");if(typeof n.about!="string")throw new Error(A);if(n.data===void 0)throw new Error("assertion add operation requires 'data'");return {operation:"add",kind:"assertion",name:n.name,about:n.about,data:n.data,...n.affirmedTargets?{affirmedTargets:n.affirmedTargets}:{},...t===true?{skipExisting:t}:{}}}if(n.data===void 0)throw new Error(`${e} add operation requires 'data'`);return {operation:"add",kind:e,name:n.name,data:n.data,...t===true?{skipExisting:t}:{}}}var ie=1e3,oe=1e4,k=class extends Error{code="PARTIAL_STREAM_SUBMISSION";completedReceipts;completedOperations;submissionId;eventRequestId;chunkOrdinal;pendingOutcome;acknowledgedOperationCount;lastAcknowledgedRepoSeq;attemptedAppendOutcome;cause;constructor(e){super(e.pendingOutcome==="unknown"?`Stream submission outcome is unknown for event request ${e.eventRequestId}. Look up its immutable receipt before retrying.`:`Stream submission stopped at event request ${e.eventRequestId} after earlier chunks committed.`),this.name="WarmHubError",this.cause=e.cause,this.completedReceipts=e.completedReceipts,this.completedOperations=e.completedOperations??[],this.submissionId=e.submissionId,this.eventRequestId=e.eventRequestId,this.chunkOrdinal=e.chunkOrdinal,this.pendingOutcome=e.pendingOutcome,this.acknowledgedOperationCount=e.acknowledgedOperationCount??e.completedReceipts.length,this.attemptedAppendOutcome=e.attemptedAppendOutcome,e.lastAcknowledgedRepoSeq!==void 0&&(this.lastAcknowledgedRepoSeq=e.lastAcknowledgedRepoSeq);}},x=class extends Error{code="STREAM_ALL_OPERATIONS_FAILED";receipts;result;operations;statusCounts;cause;constructor(e){let t=e.operations.find(r=>r.error!==void 0)?.error;super(t?`All ${e.operationCount} stream operations failed: ${t.message}`:`All ${e.operationCount} stream operations failed.`),this.name="WarmHubError",this.cause=t,this.result=e,this.receipts=e.receipts,this.operations=e.operations,this.statusCounts=e.statusCounts??{applied:0,noop:0,error:e.operationCount};}};function W(n){let e="status"in n?n.status:void 0;return e==="failed"?"error":e==="noop"||n.operation==="noop"?"noop":"applied"}function se(n){let e={applied:0,noop:0,error:0};for(let t of n)e[W(t)]++;return e}var Ft={maxAttempts:3,baseDelayMs:250,maxDelayMs:8e3},Wt=10,Xe=6e4;function Oe(n){if(n===false)return false;let e={};n!==void 0&&(Number.isFinite(n.maxAttempts)&&(e.maxAttempts=n.maxAttempts),Number.isFinite(n.baseDelayMs)&&(e.baseDelayMs=n.baseDelayMs),Number.isFinite(n.maxDelayMs)&&(e.maxDelayMs=n.maxDelayMs));let t={...Ft,...e};return {maxAttempts:Math.min(Wt,Math.max(1,Math.trunc(t.maxAttempts))),baseDelayMs:Math.min(Xe,Math.max(0,Math.trunc(t.baseDelayMs))),maxDelayMs:Math.min(Xe,Math.max(0,Math.trunc(t.maxDelayMs)))}}var Gt=new Set(["BAD_REQUEST","METHOD_NOT_SUPPORTED","PARSE_ERROR","PAYLOAD_TOO_LARGE","PRECONDITION_FAILED","UNAUTHORIZED","UNPROCESSABLE_CONTENT","UNSUPPORTED_MEDIA_TYPE","UNAUTHENTICATED","FORBIDDEN","VALIDATION_ERROR","SHAPE_MISMATCH","RESERVED_NAME","ILLEGAL_OP_SEQUENCE","NOT_FOUND","KIND_MISMATCH","CONFLICT","ALREADY_RETRACTED","ARCHIVED","RATE_LIMITED","TOO_MANY_REQUESTS","UNRESOLVED_TOKEN"]),$t=new Set(["COMMIT_OUTCOME_UNKNOWN"]);function et(n){if(!n||typeof n!="object")return;let e=n.code;if(typeof e=="string")return e;let t=n.data,r=t?.warmhub?.code;if(typeof r=="string")return r;let i=t?.code;if(typeof i=="string")return i}function Kt(n){if(!n||typeof n!="object")return;let e=n.data?.httpStatus;if(typeof e=="number")return e;let t=n.data?.warmhub?.status;if(typeof t=="number")return t;let r=n.status;return typeof r=="number"?r:void 0}function zt(n){return n!==void 0&&n>=400&&n<500&&n!==408}function tt(n){let e=et(n);return e!==void 0&&$t.has(e)}function G(n){if(tt(n))return false;let e=et(n);return e!==void 0&&Gt.has(e)||zt(Kt(n))}function Ie(n){if(tt(n)||G(n))return false;if(Ze(n))return true;if(n instanceof TypeError||n instanceof SyntaxError)return false;let e=n?.cause;return Ze(e)?true:!(e instanceof TypeError||e instanceof SyntaxError)}function Ze(n){return n instanceof TypeError&&/fetch/i.test(n.message)}function Ae(n,e){let t=e.baseDelayMs*2**Math.max(0,n-1),r=Math.random()*e.baseDelayMs;return Math.min(e.maxDelayMs,t+r)}function ve(n){return new Promise(e=>setTimeout(e,n))}var $=class extends Error{code;status=400;constructor(e,t="VALIDATION_ERROR"){super(e),this.code=t,this.name="WarmHubError";}};async function L(n,e){if(e.operations.length===0)throw new $("At least one operation is required for stream submission.");let t=e.operations.map((g,R)=>{let b;try{b=F(g);}catch(A){let y=A instanceof Error?A.message:String(A);throw new $(`Invalid operation at index ${R}: ${y}`)}return e.skipExisting===true&&b.operation==="add"?{...b,skipExisting:true}:b});Yt(t);let r=Jt(e.chunkSize),i=e.submissionId??re(),o=e.streamId??i,s=Oe(e.retry),p=[],c,u,l=[],m=[],f=0,h;for(let[g,R]of Xt(t,r).entries()){let b=Se(i,g),A=1,y=false;for(;;)try{let O=await n.stream.append({allocatedTokenRanges:p,chunkOrdinal:g,orgName:e.orgName,repoName:e.repoName,streamId:o,submissionId:i,componentRef:e.componentRef,committer:e.committer,message:e.message,...e.returnRepoSeq!==void 0?{returnRepoSeq:e.returnRepoSeq}:{},operations:R.operations}),v=O.receipt;m.push(v),p=O.allocatedTokenRanges,c=O.createdByEmail??c,u=O.repoSeq??u,l.push(...ke(O.results,R.start)),f+=R.operations.length;let T=jt(v);T!==void 0&&(h=T);break}catch(O){let v=G(O);if(m.length===0&&!y&&v)throw O;if(s!==false&&A<s.maxAttempts&&Ie(O)){await ve(Ae(A,s)),A+=1,y=true;continue}let T=y||!v?"unknown":"absent";throw new k({cause:O,completedReceipts:m,completedOperations:Ee(ae({committer:e.committer,createdByEmail:c,message:e.message,operations:t,repoSeq:u,receipts:m,results:l})),acknowledgedOperationCount:f,lastAcknowledgedRepoSeq:h,attemptedAppendOutcome:T==="absent"?"not_applied":"unknown",submissionId:i,eventRequestId:b,chunkOrdinal:g,pendingOutcome:T})}}let C=ae({committer:e.committer,createdByEmail:c,message:e.message,operations:t,repoSeq:u,receipts:m,results:l});if(C.operations.length>0&&C.operations.every(g=>g.status==="error"))throw new x(C);return C}function jt(n){let e=n.event?.repoSeq;if(e===void 0)return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function Yt(n){let t=C(n).filter(r=>!Qt(r))[0];if(t)throw new $(`Invalid operation at index ${t.operationIndex}: ${t.message}`,t.code)}function Qt(n){return n.code==="ILLEGAL_OP_SEQUENCE"&&n.message.includes("Cannot revise then add ")}function Jt(n){return Number.isFinite(n)?Math.max(1,Math.min(oe,Math.trunc(n))):ie}function Xt(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push({operations:n.slice(r,r+e),start:r});return t}function ke(n,e){return n.map((t,r)=>({...t,opIndex:e+(t.opIndex??r)}))}function ae(n){let e=se(n.results),t=e.error>0;return {...n.committer!==void 0?{committer:n.committer}:{},...n.createdByEmail!==void 0?{createdByEmail:n.createdByEmail}:{},message:n.message,operationCount:n.results.length,...n.repoSeq!==void 0?{repoSeq:n.repoSeq}:{},...t?{partial:t,statusCounts:e}:{},operations:n.results.map(r=>({...r.opIndex!==void 0?{opIndex:r.opIndex}:{},name:r.name??"",operation:r.operation==="revise"||r.operation==="retract"||r.operation==="reaffirm"||r.operation==="rename"||r.operation==="noop"?r.operation:"add",dataHash:r.dataHash??"",version:r.version??0,status:W(r),error:r.error,...r.affirmations?{affirmations:r.affirmations}:{},...r.status==="failed"&&r.opIndex!==void 0&&n.operations[r.opIndex]?.name!==void 0?{submittedName:n.operations[r.opIndex]?.name}:{},...r.resolvedName!==void 0?{resolvedName:r.resolvedName}:{},...r.retryable!==void 0?{retryable:r.retryable}:{},...r.warnings?{warnings:r.warnings}:{}})),receipts:n.receipts}}function Ee(n){return n.operations.filter(e=>e.status!=="error")}var Zt="0.0.0-development";function D(n){return n===Zt}var xe="0.88.0";var rt=1;function er(n){return n===g?"Run: wh update --yes":n===f?"Run: npm install @warmhub/sdk-ts@latest (or your package manager's equivalent).":n===h?"Run: pip install --upgrade warmhub":`Deploy a released ${n} build that satisfies the backend compatibility contract.`}function nt(n,e){if(typeof n?.minSupportedClients!="object"||n.minSupportedClients===null||!Number.isSafeInteger(n.writeContractVersion)||n.writeContractVersion<1)return {message:"The backend does not advertise valid per-client write compatibility data.",hint:"Upgrade the WarmHub backend before retrying this write."};let t$1=n.minSupportedClients[e.name],r=typeof t$1=="string"?t(t$1):null;if(!r)return {message:`The backend does not advertise a valid compatibility floor for ${e.name}.`,hint:"Upgrade the WarmHub backend or register this first-party client family before writing."};if(!D(e.version)){let i=t(e.version);if(!i)return {message:`${e.name} reported malformed version "${e.version}".`,hint:"Use a released WarmHub client with a SemVer package version."};if(u(i,r)<0)return {message:`${e.name} ${e.version} is older than the backend's minimum supported version ${r}.`,hint:er(e.name)}}if(n.writeContractVersion<rt)return {message:`${e.name} requires write contract ${rt}, but the backend provides ${n.writeContractVersion}.`,hint:"Upgrade the WarmHub backend before retrying this write."}}function Te(n,e){try{return new URL(n).origin===new URL(e).origin}catch{return false}}var tr=new Set(["GET","POST","PUT","PATCH","DELETE"]),I=class extends Error{reason;constructor(e,t){super(t),this.name="CliCallVerificationError",this.reason=e;}};async function rr(n$1,e,t){let r=n$1.method.toUpperCase();if(!tr.has(r))throw new I("unsupported-method",`Unsupported HTTP method "${n$1.method}" \u2014 component CLI dispatch only emits GET, POST, PUT, or PATCH`);let i=r,o$1=n$1.headers.get(m);if(!o$1)throw new I("missing-install-repo",`Missing ${m} header`);let s=M(e.CLI_SIGNING_SECRET),p$1=M(e.CLI_BEARER_TOKEN),c=M(e.CLI_API_KEY),u=M(e.CLI_BASIC_USERNAME)&&M(e.CLI_BASIC_PASSWORD);if(!s&&!p$1&&!c&&!u)throw new I("no-scheme-configured","no-scheme-configured: need at least one of CLI_SIGNING_SECRET, CLI_BEARER_TOKEN, CLI_API_KEY, or CLI_BASIC_USERNAME + CLI_BASIC_PASSWORD");if(p$1&&u)throw new I("no-scheme-configured","unsupported-scheme-combination: CLI_BEARER_TOKEN and CLI_BASIC_USERNAME + CLI_BASIC_PASSWORD both use the Authorization header and cannot be configured together");let l=new URL(n$1.url),m$1=l.pathname,f,h,C;if(p(i)?f={}:(f=Object.fromEntries(l.searchParams.entries()),h="",C={...f}),s){let g=n$1.headers.get(n);if(!g)throw new I("missing-signature",`Missing ${n} header`);let R=n$1.headers.get(o);if(!R)throw new I("missing-timestamp",`Missing ${o} header`);let b=Number(R);if(!Number.isFinite(b)||!Number.isInteger(b))throw new I("invalid-timestamp",`${o} must be an integer unix seconds value; got "${R}"`);h=await it(n$1,i,h);let A=await q$1({secret:e.CLI_SIGNING_SECRET,method:i,path:m$1,query:f,installRepo:o$1,body:h,signature:g,timestamp:b,nowUnixSeconds:t?.nowUnixSeconds??Math.floor(Date.now()/1e3),toleranceSec:t?.toleranceSec});if(!A.ok)throw new I(A.reason,`HMAC verification failed: ${A.reason}`)}if(p$1){let g=`Bearer ${e.CLI_BEARER_TOKEN}`,R=n$1.headers.get("authorization")??"";if(!await Ne(R,g))throw new I("invalid-bearer","invalid-bearer: bearer token mismatch")}if(c){let g=M(e.CLI_API_KEY_HEADER)?e.CLI_API_KEY_HEADER:"X-API-Key",R=n$1.headers.get(g)??"";if(!await Ne(R,e.CLI_API_KEY))throw new I("invalid-api-key",`invalid-api-key: mismatch on header "${g}"`)}if(u){let g=`Basic ${btoa(`${e.CLI_BASIC_USERNAME}:${e.CLI_BASIC_PASSWORD}`)}`,R=n$1.headers.get("authorization")??"";if(!await Ne(R,g))throw new I("invalid-basic","invalid-basic: basic auth mismatch")}return C===void 0&&(h=await it(n$1,i,h),C=nr(h)),{method:i,installRepo:o$1,args:C}}async function it(n,e,t){return p(e)?t!==void 0?t:n.text():""}function nr(n){let e;try{e=JSON.parse(n);}catch{throw new I("invalid-body","POST body is not valid JSON")}if(!ir(e))throw new I("invalid-body","POST body must be a JSON object of primitive args (string / number / boolean)");return e}function M(n){return typeof n=="string"&&n.length>0}function ir(n){if(typeof n!="object"||n===null||Array.isArray(n))return false;for(let e of Object.values(n))if(e!==void 0&&typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return false;return true}async function Ne(n,e){let[t,r]=await Promise.all([ot(n),ot(e)]),i=0;for(let o=0;o<t.length;o++)i|=t[o]^r[o];return i===0}async function ot(n){return new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)))}function Pe(n){if(n.includes("/"))return n.split("/")[0]}function at(n){if("shapeWref"in n&&typeof n.shapeWref=="string")return n.shapeWref;if(n.name)return Pe(n.name)}function _e(n){if(typeof n!="string")return;let e=n.trim();return e.length>0?e:void 0}function q(n){return l({kind:n.kind,name:n.name,about:ue(n),type:ce(n),members:pe(n)})}function ue(n){if("about"in n&&n.about!==void 0)return n.about;if("aboutWref"in n)return n.aboutWref}function Le(n){return "data"in n?n.data:void 0}function ce(n){return "type"in n?n.type:void 0}function pe(n){return "members"in n?n.members:void 0}function K(n,e){return l({kind:n.kind,name:e})}function st(n){return n.data??{}}function ct(n){if(n.operation==="retract")return F(n);if(n.operation==="reaffirm")return F({operation:"reaffirm",name:n.name,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.kind?{kind:n.kind}:{},...n.add?{add:[...n.add]}:{},...n.remove?{remove:[...n.remove]}:{},...n.leaseId?{leaseId:n.leaseId}:{}});if(n.operation==="add"){let r=q(n);if(r==="collection")return H(n,"OperationBuilder");let i=n,o=st(i),s=_e(i.name);if(!s)throw new Error("OperationBuilder: add operation missing name");if(r==="assertion"){let p=ue(i);if(p===void 0)throw new Error(`OperationBuilder: assertion add '${s}' missing required 'about'`);if(typeof p!="string")throw new Error(A);return {operation:"add",kind:r,name:s,about:p,data:o,...i.affirmedTargets?{affirmedTargets:[...i.affirmedTargets]}:{},...i.skipExisting===true?{skipExisting:true}:{}}}return {operation:"add",kind:r,name:s,data:o,...i.skipExisting===true?{skipExisting:true}:{}}}let e=_e(n.name)??_e(n.wref);if(!e)throw new Error("OperationBuilder: revise operation missing required target ('name' or 'wref')");let t=K(n,e);if(t==="collection")return ne({...n,name:e},"OperationBuilder");if(t==="assertion")return {operation:"revise",kind:t,name:e,data:n.data??{},...n.affirmedTargets?{affirmedTargets:[...n.affirmedTargets]}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.affirmedTargets!==void 0)throw new Error(`OperationBuilder: REVISE '${e}' has affirmedTargets but inferred kind '${t}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`);return {operation:"revise",kind:t,name:e,data:st(n),...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}}function N(n,e){return n.operation==="add"?{operation:n.operation,kind:e,name:n.name,about:ue(n),type:ce(n),members:pe(n)}:{operation:n.operation,kind:e,name:n.name??n.wref,type:ce(n),members:pe(n)}}function pt(n){if(n.length!==0)throw new Error(n.join("; "))}function ut(n,e,t,r){let i=[];if((e==="thing"||e==="assertion"||e==="collection"&&n==="REVISE")&&(k$1(t)||i.push(`${n} ${e} name must be a local path (Shape/name), got: "${t}"`)),e==="shape"&&(n==="ADD"||n==="REVISE")&&r!==void 0){let s=V(t,r,n==="REVISE"?"revise":"add");s&&i.push(s);}return i}function lt(n,e){let t=[];if(n.name&&t.push(...ut("ADD",e,n.name,Le(n))),e==="assertion"&&ue(n)===void 0&&t.push(`ADD assertion '${n.name}' missing required 'about' \u2014 for hierarchical thing names set kind: 'thing' explicitly`),e!=="collection"&&(ce(n)!==void 0||pe(n)!==void 0)&&t.push(`ADD '${n.name}' has collection fields but inferred kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`),e!=="assertion"&&"affirmedTargets"in n&&n.affirmedTargets!==void 0&&t.push(`ADD '${n.name}' has affirmedTargets but inferred kind '${e}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`),e==="collection")try{H(n,"OperationBuilder");}catch(r){t.push(r instanceof Error?r.message:String(r));}for(let r of B(N(n,e),0))t.push(r.message);pt(t);}function dt(n,e,t){let r=[];n!=="collection"&&t.data===void 0&&r.push(`OperationBuilder: ${n} revise requires 'data'`),n!=="assertion"&&t.affirmedTargets!==void 0&&r.push(`REVISE '${e}' has affirmedTargets but inferred kind '${n}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`),r.push(...ut("REVISE",n,e,t.data),...B(N({...t,name:e},n),0).map(i=>i.message)),pt(r);}var le=class{ops=[];pendingNames=new Set;shapes;wrefToShape=new Map;submitted=false;inFlight=false;constructor(e){this.shapes=e?.shapes;}add(e){this.assertCanModify();let t={...e};delete t.operation;let r=at(t),i=Le(t);if(this.shapes&&r&&i!==void 0){let c=this.shapes[r];if(c){let u=M$1(i,c);if(!u.valid)throw new Error(`Shape validation failed for '${t.name}' (shape: ${r}): ${u.errors.join("; ")}`)}}let o={operation:"add",...t},s=q(o);(o.name||s==="collection")&<(o,s);let p=Object.freeze({operation:"add",...t});return this.ops.push(p),t.name&&(this.pendingNames.add(t.name),r&&this.wrefToShape.set(t.name,r)),this}revise(e){this.assertCanModify();let t={...e};delete t.operation;let r=t.name??t.wref;if(this.shapes&&r&&t.data!==void 0){let o=this.wrefToShape.get(r)??Pe(r);if(o){let s=this.shapes[o];if(s){let p=M$1(t.data,s);if(!p.valid)throw new Error(`Shape validation failed for revise '${r}' (shape: ${o}): ${p.errors.join("; ")}`)}}}if(r){let o=K({...t},r);dt(o,r,{operation:"revise",...t});}let i=Object.freeze({operation:"revise",...t});return this.ops.push(i),this}retract(e){this.assertCanModify();let t=Object.freeze(typeof e=="string"?{operation:"retract",name:e}:{operation:"retract",name:e.name,...e.kind?{kind:e.kind}:{},...e.reason?{reason:e.reason}:{},...e.expectedVersion!==void 0?{expectedVersion:e.expectedVersion}:{},...e.leaseId?{leaseId:e.leaseId}:{}});return this.ops.push(t),this}reaffirm(e){this.assertCanModify();let t=Object.freeze({operation:"reaffirm",name:e.name,...e.expectedVersion!==void 0?{expectedVersion:e.expectedVersion}:{},...e.kind?{kind:e.kind}:{},...e.add?{add:Object.freeze([...e.add])}:{},...e.remove?{remove:Object.freeze([...e.remove])}:{},...e.leaseId?{leaseId:e.leaseId}:{}});return this.ops.push(t),this}get operations(){return Object.freeze([...this.ops])}get size(){return this.ops.length}has(e){return this.pendingNames.has(e)}validate(){let e=[],t=[],r=new Set,i=new Set;for(let c=0;c<this.ops.length;c+=1){let u=this.ops[c];if(u){if(u.operation==="add"){let l=q(u);!u.name&&l!=="collection"?e.push({code:"MISSING_NAME",operationIndex:c,message:`Add operation at index ${c} is missing required 'name' field`}):u.name&&(r.has(u.name)&&e.push({code:"DUPLICATE_NAME",operationIndex:c,message:`Duplicate name '${u.name}' at index ${c} (already added earlier in commit)`}),r.add(u.name));}if(u.operation==="revise"){let l=u.name??u.wref;l?i.has(l)?e.push({code:"REVISE_AFTER_RETRACT",operationIndex:c,message:`Revise at index ${c} targets '${l}' which was already retracted in this commit`}):r.has(l)||t.push({code:"REVISE_UNKNOWN_WREF",operationIndex:c,message:`Revise at index ${c} references '${l}' which was not added in this commit (assuming it exists server-side)`}):e.push({code:"MISSING_WREF",operationIndex:c,message:`Revise operation at index ${c} is missing required target ('name' or 'wref')`});}u.operation==="retract"&&(u.name?i.has(u.name)?t.push({code:"RETRACT_AFTER_RETRACT",operationIndex:c,message:`Retract at index ${c} targets '${u.name}' which was already retracted in this commit`}):(r.has(u.name)||t.push({code:"RETRACT_UNKNOWN_WREF",operationIndex:c,message:`Retract at index ${c} references '${u.name}' which was not added in this commit (assuming it exists server-side)`}),i.add(u.name)):e.push({code:"MISSING_NAME",operationIndex:c,message:`Retract operation at index ${c} is missing required 'name' field`}));}}let o=this.ops.flatMap((c,u)=>{if(c.operation==="add")return B(N(c,q(c)),u);if(c.operation==="revise"){let l=c.name??c.wref;return B(N(c,l?K(c,l):"thing"),u)}return B({operation:"retract",kind:c.kind,name:c.name},u)});for(let c of o)e.push({code:c.code,operationIndex:c.operationIndex,message:c.message});let s=this.ops.flatMap((c,u)=>{if(c.operation==="retract"||c.operation==="reaffirm")return [];if(c.operation==="add")return [{op:N(c,q(c)),operationIndex:u}];let l=c.name??c.wref;return [{op:N(c,l?K(c,l):"thing"),operationIndex:u}]}),p=C(s.map(({op:c})=>c),{checkAddAdd:false,sourceOperationIndexes:s.map(({operationIndex:c})=>c)});for(let c of p)e.push({code:c.code,operationIndex:c.operationIndex,message:c.message});return this.ops.length===0&&e.push({code:"EMPTY_COMMIT",operationIndex:-1,message:"OperationBuilder has no operations"}),{valid:e.length===0,errors:e,warnings:t}}async commit(e){if(this.assertNotSubmitted(),this.inFlight)throw new Error("OperationBuilder: stream submission already in flight");let t=this.validate();if(!t.valid){let r=t.errors.map(i=>i.message).join("; ");throw new Error(`OperationBuilder validation failed: ${r}`)}this.inFlight=true;try{let r=this.ops.map(o=>ct(o)),i=await L(e.client,{orgName:e.orgName,repoName:e.repoName,committer:e.committer,message:e.message,chunkSize:e.chunkSize,streamId:e.streamId,submissionId:e.submissionId,returnRepoSeq:e.returnRepoSeq,retry:e.retry,operations:r});return this.submitted=!0,i}catch(r){throw r instanceof k&&(this.submitted=true),r}finally{this.inFlight=false;}}assertNotSubmitted(){if(this.submitted)throw new Error("OperationBuilder: already submitted, cannot modify")}assertCanModify(){if(this.assertNotSubmitted(),this.inFlight)throw new Error("OperationBuilder: stream submission already in flight, cannot modify")}};function Vn(n){return n.replace(/@(?:v\d+|HEAD|ALL)$/i,"")}var vt=["apiUrl","fetch","accessToken","auth","functionLogs","client","clientFlags"],dr=new Set(vt),mr=new Set(["token","apiKey","bearer"]);function gr(n){if(n)for(let e of Object.keys(n)){if(dr.has(e))continue;let t=mr.has(e)?'; did you mean "accessToken"?':`. Valid options are: ${vt.join(", ")}.`;throw new TypeError(`Unknown WarmHubClient option "${e}"${t}`)}}function hr(n){if(!n||n.length===0)return [];for(let e of n)if(!c(e))throw new TypeError(`Invalid client flag "${e}": expected lowercase tokens matching [a-z0-9-]+.`);return [...new Set(n)].sort()}var De="https://api.warmhub.ai",yr=new Set(["repo.shapeInstanceCounts","thing.getMany","thing.headVersions"]),mt=500,gt=500,ht=1,yt=8;function ge(n){return {...n,actionContainer:void 0,actionContainerConfig:void 0}}function fr(n){return n.map(e=>ge(e))}function kt(n,e,t){if(e===n||t.has(e))throw new d("VALIDATION_ERROR","Paginated result cursor did not advance")}function ft(n){if(n===void 0)throw new d("VALIDATION_ERROR","sinceRepoSeq is required for an incremental read")}async function*Et(n,e){let t=e,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(yield i,!i.nextCursor)return;kt(t,i.nextCursor,r),t=i.nextCursor;}}async function*w(n,e,t){for await(let r of Et(n,t))yield*e(r);}async function S(n,e,t,r){if(t!==void 0&&(!Number.isFinite(t)||Math.trunc(t)!==t||t<0))throw new d("VALIDATION_ERROR","max must be a nonnegative integer");let i=[];for await(let o of Et(n,r)){let s=e(o);if(t!==void 0&&i.length+s.length>t)throw new d("VALIDATION_ERROR",`Paginated result exceeded max=${t}`);i.push(...s);}return i}function Rt(n){if(n?.slugs!==void 0)throw new d("VALIDATION_ERROR","repo.explore pagination helpers do not support slugs mode")}async function bt(n){let e=[],t,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(e.push(...i.items),!i.nextCursor){if(i.repoSeq===void 0)throw new d("VALIDATION_ERROR","Incremental read completed without repoSeq");return {items:e,repoSeq:i.repoSeq}}kt(t,i.nextCursor,r),t=i.nextCursor;}}function de(n,e,t){return Number.isFinite(n)?Math.max(1,Math.min(t,Math.trunc(n))):e}function Ct(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function me(n){return n!==void 0&&j.includes(n)?n:void 0}function z(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,name:r}:e}function Rr(n){let[e,t]=n;return typeof e=="string"?{orgName:e,repoName:t}:e}function br(n){let[e,t,r,i]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r,credentialSetName:i}:e}function Cr(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r}:e}function wr(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function Sr(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function he(n){return !!n&&(!!n.shape||!!n.kind||!!n.about||!!n.match||!!n.componentRef||n.excludeComponents===true||(n.where?.length??0)>0)}function ye(n){return !!n&&(!!n.shape||!!n.about||!!n.match||!!n.componentRef||(n.where?.length??0)>0)}function xt(n){let e=n.members;return Array.isArray(e)&&e.length>0}function Or(n){let t=n.replace(/^wh:[^/]+\/[^/]+\//,"").replace(/@(?:HEAD|ALL|v\d+)$/,"").split("/")[0]?.toLowerCase();return t==="arc"||t==="bond"||t==="pair"||t==="set"||t==="list"?t:void 0}function Ir(n,e){if(he(e.query)&&!ye(e.query))throw new d("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(e.sourceRepo&&!ye(e.query))throw new d("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(e.sourceRepo&&xt(e))throw new d("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(he(e.query)&&n!=="set")throw new d("VALIDATION_ERROR","Selector-backed collection sources are only supported for set collections")}function Hn(n){return n??"off"}function Ar(n){switch(n){case "BAD_REQUEST":case "PARSE_ERROR":case "PAYLOAD_TOO_LARGE":case "UNPROCESSABLE_CONTENT":case "UNSUPPORTED_MEDIA_TYPE":return "VALIDATION_ERROR";case "METHOD_NOT_SUPPORTED":return "NOT_FOUND";case "UNAUTHORIZED":return "UNAUTHENTICATED";case "FORBIDDEN":return "FORBIDDEN";case "NOT_FOUND":return "NOT_FOUND";case "CONFLICT":return "CONFLICT";case "PRECONDITION_FAILED":return "PRECONDITION_FAILED";case "TOO_MANY_REQUESTS":return "RATE_LIMITED";default:return}}function vr(n){if(n===void 0||n===408)return;if(n===405)return "NOT_FOUND";if(n===412)return "PRECONDITION_FAILED";if(n===422)return "VALIDATION_ERROR";let e=Nt(n);return e!=="BACKEND"?e:n>=400&&n<500?"VALIDATION_ERROR":e}var kr=[/\bselect\b.+?\bfrom\b/i,/\binsert\b.+?\binto\b/i,/\bupdate\b.+?\bset\b/i,/\bdelete\b.+?\bfrom\b/i,/\bparams:\s/i,/\.ts\(\d+,\d+\)/,/at\s+\S+\s+\(.*:\d+:\d+\)/,/node_modules\//,/drizzle/i];function Me(n){for(let e of kr)if(e.test(n))return "An internal error occurred. Please try again or contact support.";return n}var d=class extends Error{code;status;hint;retryAfter;errorCode;backendCode;details;constructor(e,t,r,i,o,s,p){super(t),this.name="WarmHubError",this.code=e,this.status=r,this.hint=i,this.retryAfter=o,this.errorCode=s,this.backendCode=s,this.details=p;}get kind(){return this.code}};function wt(n,e){if(typeof e!="string")return;let t=x$1(n,e);if(t)throw new d("VALIDATION_ERROR",t)}function a(n){if(n instanceof d)return n;if(n instanceof TRPCClientError){if(n.cause instanceof d)return n.cause;let e=n.data,t=e?.warmhub?.code,r=typeof e?.code=="string"?Ar(e.code):void 0,i=vr(e?.httpStatus),o=e?.warmhub?.message??Me(n.message);return new d(t??r??i??"BACKEND",o,e?.warmhub?.status??e?.httpStatus,e?.warmhub?.hint,e?.warmhub?.retryAfter??e?.retryAfter,t,e?.warmhub?.details)}if(n instanceof Error){let e=n;return n.name==="WarmHubError"&&typeof e.code=="string"?new d(e.code,Me(n.message),typeof e.status=="number"?e.status:void 0,typeof e.hint=="string"?e.hint:void 0,typeof e.retryAfter=="number"?e.retryAfter:void 0,typeof e.errorCode=="string"?e.errorCode:typeof e.backendCode=="string"?e.backendCode:void 0,e.details):n.name==="AbortError"?new d("CANCELLED",n.message):n instanceof TypeError&&/fetch/i.test(n.message)?new d("NETWORK",n.message):new d("BACKEND",Me(n.message))}return new d("BACKEND","Unknown SDK error")}function Er(n){return n instanceof d}function Fn(n){let e=a(n);return e.kind==="NETWORK"||e.kind==="CANCELLED"||e.kind==="BACKEND"||e.kind==="RATE_LIMITED"}var xr=new Set(["ConnectionRefused","ECONNREFUSED","ENOTFOUND","ETIMEDOUT","EAI_AGAIN"]);function Tr(n){if(n instanceof TypeError&&/fetch/i.test(n.message))return true;if(n&&typeof n=="object"){let e=n.code;if(typeof e=="string"&&xr.has(e))return true}return false}function Nr(n){return `Unable to connect to ${n}. Is the computer able to access the url?`}function Wn(n,e){if(D(n))return false;let t$1=t(n),r=t(e);return !t$1||!r?false:u(t$1,r)<0}function Tt(n,e){return new d("CLIENT_INCOMPATIBLE",n,412,e)}function _r(n,e){let t=nt(n,e);if(t)throw Tt(t.message,t.hint)}var St=class n{apiUrl;fetchImpl;accessToken;clientIdentity;clientFlags;functionLogMode;getToken;compatibilityCheck;overrideNoticePrinted=false;noteCompatibilityOverride(){this.overrideNoticePrinted||(this.overrideNoticePrinted=true,console.error(`warmhub: compatibility checks overridden by client flag ${b}; the server remains authoritative.`));}assertWriteCompatible(){return this.clientFlags.includes(b)?(this.noteCompatibilityOverride(),Promise.resolve()):D(this.clientIdentity.version)&&Te(this.apiUrl,De)?Promise.reject(Tt(`Development client ${this.clientIdentity.name}/${this.clientIdentity.version} cannot write to production.`,"Install a released WarmHub client artifact before writing to api.warmhub.ai.")):D(this.clientIdentity.version)&&!Te(this.apiUrl,De)?Promise.resolve():this.diagnostics.assertCompatible()}createCompatibilityLink(){return ()=>({op:e,next:t})=>e.type!=="mutation"?t(e):observable(r=>{let i=false,o;return this.assertWriteCompatible().then(()=>{i||(o=t(e).subscribe(r));}).catch(s=>{i||r.error(TRPCClientError.from(s));}),()=>{i=true,o?.unsubscribe();}})}auth={getClientId:async()=>{try{return await this.trpc.auth.getClientId.query()}catch(e){throw a(e)}},sync:async()=>{try{return await this.trpc.auth.sync.mutate()}catch(e){throw a(e)}},currentUser:async()=>{try{return await this.trpc.auth.currentUser.query()}catch(e){throw a(e)}},whoami:async()=>{try{return await this.trpc.auth.whoami.query()}catch(e){throw a(e)}}};homepage={featuredLists:async()=>{try{return await this.trpc.homepage.featuredLists.query()}catch(e){throw a(e)}}};access={resolve:async e=>{try{return await this.trpc.access.resolve.query(e)}catch(t){throw a(t)}}};diagnostics={ping:async()=>{let e=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/health`);if(!e.ok)throw new d("BACKEND",`Health request failed with status ${e.status}`,e.status);return await e.json()},capabilities:async()=>{try{return await this.trpc.diagnostics.capabilities.query()}catch(e){throw a(e)}},assertCompatible:()=>{if(this.compatibilityCheck)return this.compatibilityCheck;let e=(async()=>{let t=await this.diagnostics.capabilities();_r(t,this.clientIdentity);})();return this.compatibilityCheck=e,e.catch(t=>{Er(t)&&t.code==="CLIENT_INCOMPATIBLE"||this.compatibilityCheck===e&&(this.compatibilityCheck=void 0);}),e}};component={list:async(e,t,r)=>{try{return await this.trpc.component.list.query({orgName:e,repoName:t,limit:r?.limit,cursor:r?.cursor})}catch(i){throw a(i)}},listIter:(e,t,r)=>w(i=>this.component.list(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),listAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.component.list(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},search:async(e,t)=>{try{return await this.trpc.component.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw a(r)}},searchIter:(e,t)=>w(r=>this.component.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.component.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},get:async(e,t,r)=>{try{return await this.trpc.component.get.query({orgName:e,repoName:t,componentRef:r})}catch(i){throw a(i)}},history:async(e,t,r)=>{try{return await this.trpc.component.history.query({orgName:e,repoName:t,componentRef:r?.componentRef,limit:r?.limit})}catch(i){throw a(i)}},install:async(e,t,r,i)=>{try{return await this.trpc.component.install.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw a(o)}},uninstall:async(e,t,r,i)=>{try{return await this.trpc.component.uninstall.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw a(o)}},registry:{register:async(e,t,r)=>{try{return await this.trpc.component.registry.register.mutate({orgName:e,componentName:t,...r})}catch(i){throw a(i)}},unregister:async(e,t)=>{try{return await this.trpc.component.registry.unregister.mutate({orgName:e,componentName:t})}catch(r){throw a(r)}},list:async e=>{try{return await this.trpc.component.registry.list.query({orgName:e})}catch(t){throw a(t)}},view:async(e,t)=>{try{return await this.trpc.component.registry.view.query({orgName:e,componentName:t})}catch(r){throw a(r)}},update:async(e,t,r)=>{try{return await this.trpc.component.registry.update.mutate({orgName:e,componentName:t,...r})}catch(i){throw a(i)}},resolve:async(e,t,r)=>await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/resolve`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({installRepo:r})}),setupCall:async(e,t,r)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/setup-call`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)}))},cli:{call:async(e,t,r,i)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cli/${encodeURIComponent(r)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}))}};commit={apply:async(e,t,r,i,o)=>{try{return await L(this,{orgName:e,repoName:t,committer:o?.committer,message:r,componentRef:o?.componentRef,chunkSize:o?.chunkSize,skipExisting:o?.skipExisting,streamId:o?.streamId,submissionId:o?.submissionId,returnRepoSeq:o?.returnRepoSeq,retry:o?.retry,operations:i})}catch(s){throw s instanceof k||s instanceof x?s:a(s)}},getReceipt:async(e,t,r)=>{try{return await this.trpc.commit.getReceipt.query({orgName:e,repoName:t,eventRequestId:r})}catch(i){throw a(i)}}};org={get:async e=>{try{return await this.trpc.org.get.query({orgName:e})}catch(t){throw a(t)}},getCallerRole:async e=>{try{return await this.trpc.org.getCallerRole.query({orgName:e})}catch(t){throw a(t)}},list:async e=>{try{return {items:await this.trpc.org.list.query({includeArchived:e?.includeArchived})}}catch(t){throw a(t)}},create:async(e,t,r)=>{try{return await this.trpc.org.create.mutate({name:e,displayName:t,description:r})}catch(i){throw a(i)}},setDescription:async(e,t)=>{try{return await this.trpc.org.setDescription.mutate({orgName:e,description:t})}catch(r){throw a(r)}},setDisplayName:async(e,t)=>{try{return await this.trpc.org.setDisplayName.mutate({orgName:e,displayName:t})}catch(r){throw a(r)}},rename:async(e,t)=>{try{return await this.trpc.org.rename.mutate({orgName:e,newName:t})}catch(r){throw a(r)}},update:async e=>{try{return await this.trpc.org.update.mutate(e)}catch(t){throw a(t)}},addMember:async(e,t,r="editor")=>{try{return await this.trpc.org.addMember.mutate({orgName:e,email:t,role:r})}catch(i){throw a(i)}},removeMember:async(e,t)=>{try{await this.trpc.org.removeMember.mutate({orgName:e,email:t});}catch(r){throw a(r)}},leave:async e=>{try{await this.trpc.org.leave.mutate({orgName:e});}catch(t){throw a(t)}},changeMemberRole:async(e,t,r)=>{try{return await this.trpc.org.changeMemberRole.mutate({orgName:e,email:t,role:r})}catch(i){throw a(i)}},setMemberScopes:async(e,t,r)=>{try{await this.trpc.org.setMemberScopes.mutate({orgName:e,email:t,scopes:r});}catch(i){throw a(i)}},clearMemberScopes:async(e,t)=>{try{await this.trpc.org.clearMemberScopes.mutate({orgName:e,email:t});}catch(r){throw a(r)}},listMembers:async(e,t)=>{try{return await this.trpc.org.listMembers.query({orgName:e,pending:t?.pending})}catch(r){throw a(r)}},archive:async e=>{try{return await this.trpc.org.archive.mutate({orgName:e})}catch(t){throw a(t)}},unarchive:async e=>{try{return await this.trpc.org.unarchive.mutate({orgName:e})}catch(t){throw a(t)}}};repo={checkpoint:Ye(()=>this.trpc,a),get:async(e,t)=>{try{return await this.trpc.repo.get.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getStats:async(e,t)=>{try{return await this.trpc.repo.stats.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getStatsBatch:async(e,t)=>{try{return await this.trpc.repo.statsBatch.query({orgName:e,repoNames:t})}catch(r){throw a(r)}},getConfigureStats:async(e,t)=>{try{return await this.trpc.repo.configureStats.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getShapeInstanceCounts:async(e,t)=>{try{return await this.trpc.repo.shapeInstanceCounts.query({orgName:e,repoName:t})}catch(r){throw a(r)}},list:async(e,t)=>{try{return await this.trpc.repo.list.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw a(r)}},listIter:(e,t)=>w(r=>this.repo.list(e,{...t,cursor:r}),r=>r.items,t?.cursor),listAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.repo.list(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},search:async(e,t)=>{try{return await this.trpc.repo.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw a(r)}},searchIter:(e,t)=>w(r=>this.repo.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.repo.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},create:async(e,t,r,i,o)=>{try{return await this.trpc.repo.create.mutate({orgName:e,repoName:t,description:r,visibility:i,displayName:o})}catch(s){throw a(s)}},setDescription:async(e,t,r)=>{try{return await this.trpc.repo.setDescription.mutate({orgName:e,repoName:t,description:r})}catch(i){throw a(i)}},setDisplayName:async(e,t,r)=>{try{return await this.trpc.repo.setDisplayName.mutate({orgName:e,repoName:t,displayName:r})}catch(i){throw a(i)}},setVisibility:async(e,t,r)=>{try{return await this.trpc.repo.setVisibility.mutate({orgName:e,repoName:t,visibility:r})}catch(i){throw a(i)}},rename:async(e,t,r)=>{try{return await this.trpc.repo.rename.mutate({orgName:e,repoName:t,newName:r})}catch(i){throw a(i)}},update:async e=>{try{return await this.trpc.repo.update.mutate(e)}catch(t){throw a(t)}},archive:async(e,t)=>{try{return await this.trpc.repo.archive.mutate({orgName:e,repoName:t})}catch(r){throw a(r)}},unarchive:async(e,t)=>{try{return await this.trpc.repo.unarchive.mutate({orgName:e,repoName:t})}catch(r){throw a(r)}},delete:async(e,t)=>{try{let r=await this.trpc.repo.delete.mutate({orgName:e,repoName:t});return {graceExpiresAt:new Date(r.graceExpiresAt)}}catch(r){throw a(r)}},listPage:async(e,t)=>{try{return await this.trpc.repo.listPage.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw a(r)}},listPageIter:(e,t)=>w(r=>this.repo.listPage(e,{...t,cursor:r}),r=>r.items,t?.cursor),listPageAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.repo.listPage(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},listForCaller:async e=>{try{return await this.trpc.repo.listForCaller.query({limit:e?.limit,sort:e?.sort})}catch(t){throw a(t)}},explore:async e=>{try{return await this.trpc.repo.explore.query({search:e?.search,org:e?.org,activity:e?.activity,hasSubscriptions:e?.hasSubscriptions,minThings:e?.minThings,sort:e?.sort,limit:e?.limit,cursor:e?.cursor,slugs:e?.slugs})}catch(t){throw a(t)}},exploreIter:e=>(Rt(e),w(t=>this.repo.explore({...e,cursor:t}),t=>t.items,e?.cursor)),exploreAll:async e=>{Rt(e);let{max:t,...r}=e??{};return await S(i=>this.repo.explore({...r,cursor:i}),i=>i.items,t,r.cursor)},getReadme:async(e,t)=>{try{return await this.trpc.repo.getReadme.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getAgents:async(e,t)=>{try{return await this.trpc.repo.getAgents.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getLicense:async(e,t)=>{try{return await this.trpc.repo.getLicense.query({orgName:e,repoName:t})}catch(r){throw a(r)}},describe:async(e,t)=>{try{return await this.trpc.repo.describe.query({orgName:e,repoName:t})}catch(r){throw a(r)}},setReadme:async(e,t,r,i)=>{try{return wt("Content/Readme.content",r),await this.trpc.repo.setReadme.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw a(o)}},setAgents:async(e,t,r,i)=>{try{return wt("Content/Agents.content",r),await this.trpc.repo.setAgents.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw a(o)}},getLlmsTxt:async(e,t)=>{try{return await this.trpc.repo.getLlmsTxt.query({orgName:e,repoName:t})}catch(r){throw a(r)}},index:{describe:async(e,t)=>{try{return await this.trpc.repo.index.describe.query({orgName:e,repoName:t})}catch(r){throw a(r)}}}};shape={list:async(e,t,r)=>{try{return await this.trpc.shape.list.query({orgName:e,repoName:t,match:r?.match,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,includeRetracted:r?.includeRetracted})}catch(i){throw a(i)}},get:async(e,t,r,i)=>{try{return await this.trpc.shape.get.query({orgName:e,repoName:t,shapeName:r,includeRetracted:i?.includeRetracted})}catch(o){throw a(o)}},create:async(e,t,r,i,o)=>{let s=V(r,{fields:i,...o.description!==void 0?{description:o.description}:{}},"add");if(s)throw new d("VALIDATION_ERROR",s);try{return await this.trpc.shape.create.mutate({orgName:e,repoName:t,shapeName:r,fields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(p){throw a(p)}},revise:async(e,t,r,i,o)=>{let s=V(r,{fields:i,...o.description!==void 0?{description:o.description}:{}},"revise");if(s)throw new d("VALIDATION_ERROR",s);try{return await this.trpc.shape.revise.mutate({orgName:e,repoName:t,shapeName:r,newFields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(p){throw a(p)}},remove:async(e,t,r,i)=>{try{return await this.trpc.shape.remove.mutate({orgName:e,repoName:t,shapeName:r,eventRequestId:i.eventRequestId})}catch(o){throw a(o)}},rename:async(e,t,r,i,o)=>{try{return await this.trpc.shape.rename.mutate({orgName:e,repoName:t,oldName:r,newName:i,eventRequestId:o.eventRequestId})}catch(s){throw a(s)}},history:async(e,t,r,i={})=>{try{return await this.trpc.shape.history.query({orgName:e,repoName:t,name:r,includeRetracted:i.includeRetracted,limit:i.limit,cursor:i.cursor})}catch(o){throw a(o)}},historyIter:(e,t,r,i={})=>w(o=>this.shape.history(e,t,r,{...i,cursor:o}),o=>o.versions,i.cursor),historyAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.shape.history(e,t,r,{...s,cursor:p}),p=>p.versions,o,s.cursor)}};subscription={create:async e=>{try{let t=await this.trpc.subscription.create.mutate(wr(e));return ge(t)}catch(t){throw a(t)}},get:async(...e)=>{try{let t=await this.trpc.subscription.get.query(z(e));return ge(t)}catch(t){throw a(t)}},reveal:async(...e)=>{try{return await this.trpc.subscription.reveal.query(z(e))}catch(t){throw a(t)}},list:async(...e)=>{try{let t=await this.trpc.subscription.list.query(Rr(e));return fr(t)}catch(t){throw a(t)}},update:async e=>{try{let t=await this.trpc.subscription.update.mutate(Sr(e));return ge(t)}catch(t){throw a(t)}},pause:async(...e)=>{try{return await this.trpc.subscription.pause.mutate(z(e))}catch(t){throw a(t)}},resume:async(...e)=>{try{return await this.trpc.subscription.resume.mutate(z(e))}catch(t){throw a(t)}},remove:async(...e)=>{try{return await this.trpc.subscription.remove.mutate(z(e))}catch(t){throw a(t)}},bindCredentials:async(...e)=>{try{return await this.trpc.subscription.bindCredentials.mutate(br(e))}catch(t){throw a(t)}},unbindCredentials:async(...e)=>{try{return await this.trpc.subscription.unbindCredentials.mutate(Cr(e))}catch(t){throw a(t)}}};action={acquireLease:async(e,t,r,i,o,s)=>{try{return await this.trpc.action.acquireLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,holderType:o,graceMs:s?.graceMs,ttlMs:s?.ttlMs})}catch(p){throw a(p)}},heartbeatLease:async(e,t,r,i,o)=>{try{return await this.trpc.action.heartbeatLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,ttlMs:o})}catch(s){throw a(s)}},releaseLease:async(e,t,r,i)=>{try{return await this.trpc.action.releaseLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i})}catch(o){throw a(o)}},claimDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.claimDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw a(s)}},completeDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.completeDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw a(s)}},liveFeed:async(e,t,r,i)=>{try{return await this.trpc.action.liveFeed.query({orgName:e,repoName:t,subscriptionName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},liveFeedIter:(e,t,r,i)=>w(o=>this.action.liveFeed(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),liveFeedAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.action.liveFeed(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)},listRuns:async(e,t,r)=>{try{return await this.trpc.action.listRuns.query({orgName:e,repoName:t,runId:r?.runId,subscriptionName:r?.subscriptionName,status:r?.status,outcome:r?.outcome,since:r?.since,cursor:r?.cursor,limit:r?.limit})}catch(i){throw a(i)}},listRunsIter:(e,t,r)=>w(i=>this.action.listRuns(e,t,{...r,since:i===void 0?r?.since:void 0,cursor:i}),i=>i.items,r?.cursor),listRunsAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.action.listRuns(e,t,{...o,since:s===void 0?o.since:void 0,cursor:s}),s=>s.items,i,o.cursor)},latestRuns:async(e,t)=>{try{return await this.trpc.action.latestRuns.query({orgName:e,repoName:t})}catch(r){throw a(r)}},runStats:async(e,t,r)=>{try{return await this.trpc.action.runStats.query({orgName:e,repoName:t,subscriptionName:r?.subscriptionName,since:r?.since})}catch(i){throw a(i)}},getRunAttempts:async(e,t,r)=>{try{return await this.trpc.action.getRunAttempts.query({orgName:e,repoName:t,runId:r})}catch(i){throw a(i)}},listNotifications:async(e,t,r)=>{try{return await this.trpc.action.listNotifications.query({orgName:e,repoName:t,since:r?.since,limit:r?.limit})}catch(i){throw a(i)}}};collection={create:async(e,t,r)=>{try{return Ir(r.type,r),await this.trpc.collection.create.mutate({orgName:e,repoName:t,eventRequestId:r.eventRequestId,type:r.type,name:r.name,members:r.members,from:r.from,add:r.add,remove:r.remove,replaceMembers:r.replaceMembers,query:r.query,sourceOrgName:r.sourceRepo?.orgName,sourceRepoName:r.sourceRepo?.repoName,skipExisting:r.skipExisting,message:r.message,committer:r.committer})}catch(i){throw a(i)}},members:async(e,t,r,i)=>{try{return await this.trpc.collection.members.query({orgName:e,repoName:t,wref:r,version:i?.version,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},membersIter:(e,t,r,i)=>{let o=i?.version;return w(async s=>{let p=await this.collection.members(e,t,r,{...i,version:o,cursor:s});return o??=p.version,p},s=>s.items,i?.cursor)},membersAll:async(e,t,r,i)=>{let{max:o,...s}=i??{},p=s.version;return await S(async c=>{let u=await this.collection.members(e,t,r,{...s,version:p,cursor:c});return p??=u.version,u},c=>c.items,o,s.cursor)},contains:async(e,t,r,i,o)=>{try{return await this.trpc.collection.contains.query({orgName:e,repoName:t,wref:r,version:o?.version,members:i,position:o?.position})}catch(s){throw a(s)}},diff:async(e,t,r,i,o)=>{try{return await this.trpc.collection.diff.query({orgName:e,repoName:t,leftWref:r,rightWref:i,leftVersion:o?.leftVersion,rightVersion:o?.rightVersion,mode:o?.mode})}catch(s){throw a(s)}},revise:async(e,t,r,i)=>{try{let o=Or(r);if(he(i.query)&&!ye(i.query))throw new d("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(i.sourceRepo&&!ye(i.query))throw new d("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(i.sourceRepo&&xt(i))throw new d("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(he(i.query)&&o&&o!=="set")throw new d("VALIDATION_ERROR","Selector-backed revise requires a Set/<name> target wref");return await this.trpc.collection.revise.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,wref:r,members:i.members,add:i.add,remove:i.remove,query:i.query,sourceOrgName:i.sourceRepo?.orgName,sourceRepoName:i.sourceRepo?.repoName,message:i.message,committer:i.committer})}catch(o){throw a(o)}},stats:async(e,t,r,i)=>{try{return await this.trpc.collection.stats.query({orgName:e,repoName:t,wref:r,version:i?.version})}catch(o){throw a(o)}}};view={evaluate:async(e,t,r,i)=>{try{return await this.trpc.view.evaluate.query({orgName:e,repoName:t,wref:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},evaluateIter:(e,t,r,i)=>w(o=>this.view.evaluate(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),evaluateAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.view.evaluate(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)}};grant=ze(()=>this.trpc,a);thing={head:async(e,t,r)=>{try{return await this.trpc.thing.head.query({orgName:e,repoName:t,shape:r?.shape,kind:me(r?.kind),match:r?.match,dataMode:r?.dataMode,includeRetracted:r?.includeRetracted,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},headIter:(e,t,r)=>w(i=>this.thing.head(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),headAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.thing.head(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},headChanges:async(e,t,r)=>(ft(r?.sinceRepoSeq),await bt(i=>this.thing.head(e,t,{...r,includeRetracted:true,cursor:i}))),get:async(e,t,r,i,o)=>{try{return await this.trpc.thing.get.query({orgName:e,repoName:t,wref:r,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode})}catch(s){throw a(s)}},getWithLease:async(e,t,r,i)=>{try{return await this.trpc.thing.getWithLease.mutate({orgName:e,repoName:t,wref:r,ttlMs:i?.ttlMs})}catch(o){throw a(o)}},releaseLease:async(e,t,r,i)=>{try{await this.trpc.thing.releaseLease.mutate({orgName:e,repoName:t,wref:r,leaseId:i});}catch(o){throw a(o)}},graph:async(e,t,r,i)=>{try{return await this.trpc.thing.graph.query({orgName:e,repoName:t,wref:r,version:i?.version,depth:i?.depth,limit:i?.limit})}catch(o){throw a(o)}},getMany:async(e,t,r,i,o)=>{try{if(r.length===0)return {requested:0,items:[],missing:[]};let s=de(o?.chunkSize,mt,gt),p=de(o?.chunkConcurrency,ht,yt),c=async m=>await this.trpc.thing.getMany.query({orgName:e,repoName:t,wrefs:m,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode});if(r.length<=s)return await c(r);let u=Ct(r,s),l=[];for(let m=0;m<u.length;m+=p){let f=u.slice(m,m+p),h=await Promise.all(f.map(c));l.push(...h);}return {requested:r.length,items:l.flatMap(m=>m.items),missing:l.flatMap(m=>m.missing)}}catch(s){throw a(s)}},headVersions:async(e,t,r,i)=>{try{if(r.length===0)return {requested:0,items:[],missing:[]};let o=de(i?.chunkSize,mt,gt),s=de(i?.chunkConcurrency,ht,yt),p=async l=>await this.trpc.thing.headVersions.query({orgName:e,repoName:t,wrefs:l});if(r.length<=o)return await p(r);let c=Ct(r,o),u=[];for(let l=0;l<c.length;l+=s){let m=c.slice(l,l+s),f=await Promise.all(m.map(p));u.push(...f);}return {requested:r.length,items:u.flatMap(l=>l.items),missing:u.flatMap(l=>l.missing)}}catch(o){throw a(o)}},history:async(e,t,r)=>{try{return await this.trpc.thing.history.query({orgName:e,repoName:t,wref:r.wref,shape:r.shape,about:r.about,includeRetracted:r.includeRetracted,resolveCollections:r.resolveCollections,match:r.match,limit:r.limit,cursor:r.cursor})}catch(i){throw a(i)}},historyIter:(e,t,r)=>w(i=>this.thing.history(e,t,{...r,cursor:i}),i=>i.versions,r.cursor),historyAll:async(e,t,r)=>{let{max:i,...o}=r;return await S(s=>this.thing.history(e,t,{...o,cursor:s}),s=>s.versions,i,o.cursor)},rename:async(e,t,r,i,o,s)=>{try{return await this.trpc.thing.rename.mutate({orgName:e,repoName:t,shapeName:r,oldName:i,newName:o,eventRequestId:s.eventRequestId})}catch(p){throw a(p)}},resolve:async(e,t,r)=>{try{return await this.trpc.thing.resolve.query({orgName:e,repoName:t,wref:r})}catch(i){throw a(i)}},about:async(e,t,r,i)=>{try{return await this.trpc.thing.about.query({orgName:e,repoName:t,wref:r,shape:i?.shape,match:i?.match,includeRetracted:i?.includeRetracted,depth:i?.depth,resolveCollections:i?.resolveCollections,role:i?.role,limit:i?.limit,cursor:i?.cursor,where:i?.where})}catch(o){throw a(o)}},aboutIter:(e,t,r,i)=>w(o=>this.thing.about(e,t,r,{...i,cursor:o}),o=>o.assertions,i?.cursor),aboutAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.thing.about(e,t,r,{...s,cursor:p}),p=>p.assertions,o,s.cursor)},query:async(e,t,r)=>{try{return await this.trpc.thing.query.query({orgName:e,repoName:t,shape:r?.shape,about:r?.about,affirmedAbout:r?.affirmedAbout,kind:me(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,role:r?.role,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},queryIter:(e,t,r)=>w(i=>this.thing.query(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),queryAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.thing.query(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},queryChanges:async(e,t,r)=>(ft(r?.sinceRepoSeq),await bt(i=>this.thing.query(e,t,{...r,includeRetracted:true,cursor:i}))),search:async(e,t,r,i)=>{try{return await this.trpc.thing.search.query({orgName:e,repoName:t,query:r,shape:i?.shape,about:i?.about,kind:me(i?.kind),match:i?.match,includeRetracted:i?.includeRetracted,resolveCollections:i?.resolveCollections,limit:i?.limit,cursor:i?.cursor,componentRef:i?.componentRef,excludeComponents:i?.excludeComponents,excludeInfraShapes:i?.excludeInfraShapes,mode:i?.mode,nameMatch:i?.nameMatch})}catch(o){throw a(o)}},searchIter:(e,t,r,i)=>w(o=>this.thing.search(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),searchAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.thing.search(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)},count:async(e,t,r)=>{try{return await this.trpc.thing.count.query({orgName:e,repoName:t,shape:r?.shape,about:r?.about,kind:me(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},refs:async(e,t,r,i)=>{try{return await this.trpc.thing.refs.query({orgName:e,repoName:t,wref:r,direction:i?.direction,fieldPath:i?.fieldPath,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},refsIter:(e,t,r,i)=>w(o=>this.thing.refs(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),refsAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.thing.refs(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)}};live={thingHead:async(e,t,r,i)=>this.watchRepoQuery(e,t,r?.signal,()=>this.thing.head(e,t,{shape:r?.shape,kind:r?.kind,match:r?.match,dataMode:r?.dataMode,limit:r?.limit,cursor:r?.cursor,includeRetracted:r?.includeRetracted,where:r?.where}),i),thingHistory:async(e,t,r,i)=>this.watchRepoQuery(e,t,r.signal,()=>this.thing.history(e,t,{wref:r.wref,limit:r.limit,cursor:r.cursor,includeRetracted:r.includeRetracted}),i),subscriptionLog:async(e,t,r,i,o)=>this.watchRepoQuery(e,t,i?.signal,()=>this.action.liveFeed(e,t,r,{limit:i?.limit,cursor:i?.cursor}),o),subscribe:async(e,t,r,i)=>{let o=new AbortController,s=It(r?.signal,o),p=0,c=(async()=>{let u=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),l=await this.openSse(u.ticket,s,async m=>{if(m.type!=="invalidate")return;let f=m.data;p++,await i({topic:f.topic,affectedShapes:f.affectedShapes,affectedThings:f.affectedThings,affectedTargets:f.affectedTargets,hasNewCommit:f.hasNewCommit});});return await l.ready,s.aborted?{updates:p}:(await l.closed,{updates:p})})();return {close(){o.abort();},closed:c}}};token={create:async e=>{try{return await this.trpc.token.create.mutate(e)}catch(t){throw a(t)}},list:async e=>{try{return await this.trpc.token.list.query(e?.includeInactive?{includeInactive:!0}:void 0)}catch(t){throw a(t)}},get:async e=>{try{return await this.trpc.token.get.query({name:e})}catch(t){throw a(t)}},revoke:async e=>{try{return await this.trpc.token.revoke.mutate({name:e})}catch(t){throw a(t)}}};stream={append:async e=>{try{return await this.trpc.stream.append.mutate(e)}catch(t){throw a(t)}}};credential={createSet:async(e,t,r,i)=>{try{return await this.trpc.credential.createSet.mutate({orgName:e,repoName:t,name:r,scope:i?.scope??"repo",description:i?.description})}catch(o){throw a(o)}},listSets:async(e,t)=>{try{return await this.trpc.credential.listSets.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getSet:async(e,t,r)=>{try{return await this.trpc.credential.getSet.query({orgName:e,repoName:t,name:r})}catch(i){throw a(i)}},setKey:async(e,t,r,i,o)=>{try{return await this.trpc.credential.setKey.mutate({orgName:e,repoName:t,setName:r,keyName:i,value:o})}catch(s){throw a(s)}},setKeys:async(e,t,r,i)=>{try{return await this.trpc.credential.setKeys.mutate({orgName:e,repoName:t,setName:r,secrets:i})}catch(o){throw a(o)}},unsetKey:async(e,t,r,i)=>{try{return await this.trpc.credential.unsetKey.mutate({orgName:e,repoName:t,setName:r,keyName:i})}catch(o){throw a(o)}},deleteSet:async(e,t,r)=>{try{return await this.trpc.credential.deleteSet.mutate({orgName:e,repoName:t,setName:r})}catch(i){throw a(i)}},listAuditLog:async(e,t,r,i)=>{try{return await this.trpc.credential.listAuditLog.query({orgName:e,repoName:t,setName:r,limit:i?.limit})}catch(o){throw a(o)}},revokeSet:async(e,t,r,i)=>{try{return await this.trpc.credential.revokeSet.mutate({orgName:e,repoName:t,setName:r,reason:i?.reason})}catch(o){throw a(o)}}};credentials=this.credential;constructor(e,t){let r=typeof e=="string"?t:e;gr(r);let i=typeof e=="string"?e:e?.apiUrl??De;if(this.apiUrl=i,this.fetchImpl=r?.fetch,this.accessToken=r?.accessToken??r?.auth?.getToken,this.functionLogMode=r?.functionLogs??"off",this.clientIdentity={name:r?.client?.name??f,version:r?.client?.version??xe},this.clientFlags=hr(r?.clientFlags),typeof this.accessToken=="function"){let p=this.accessToken;this.getToken=async()=>await p();}else if(this.accessToken){let p=this.accessToken;this.getToken=async()=>p;}let o=`${i.replace(/\/$/,"")}/trpc`,s=((p,c)=>this.fetchWithAuth(p,c));Object.defineProperty(this,"trpc",{value:createTRPCProxyClient({links:[this.createCompatibilityLink(),splitLink({condition:p=>yr.has(p.path),true:httpLink({url:o,fetch:s,methodOverride:"POST"}),false:httpBatchLink({url:o,fetch:s,methodOverride:"POST"})})]}),enumerable:false,writable:false,configurable:true});}withAccessToken(e){return new n({apiUrl:this.apiUrl,fetch:this.fetchImpl,accessToken:e,client:this.clientIdentity,clientFlags:this.clientFlags})}actions=this.action;async openSse(e,t,r){let i=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/sse?ticket=${encodeURIComponent(e)}`,{headers:{accept:"text/event-stream"},signal:t});if(!i.ok)throw new d("BACKEND",`SSE request failed with status ${i.status}`,i.status);let o=i.body?.getReader();if(!o)throw new d("BACKEND","SSE response body is missing");let s=()=>{},p=new Promise(u=>{s=u;}),c=(async()=>{let u=new TextDecoder,l="";try{for(;;){let{done:m,value:f}=await o.read();if(m)break;for(l+=u.decode(f,{stream:!0}).replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`);;){let h=l.indexOf(`
|
|
4
|
-
|
|
5
|
-
`);if(h===-1)break;let C=l.slice(0,h);l=l.slice(h+2);let g=Pr(C);if(g){if(g.type==="ready"){s();continue}await r(g);}}}}catch(m){if(Lr(m)||t.aborted)return;throw m}finally{s(),o.releaseLock();}})();return {ready:p,closed:c}}applyClientHeader(e$1){e$1.has(e)||e$1.set(e,i(this.clientIdentity.name,this.clientIdentity.version)),this.clientFlags.length>0&&!e$1.has(a$1)&&e$1.set(a$1,d$1(this.clientFlags));}async fetchWithAuth(e,t){let r=this.fetchImpl??globalThis.fetch,i=new Headers(t?.headers),o=await Ot(this.accessToken);o&&i.set("authorization",`Bearer ${o}`),this.applyClientHeader(i);let s=async c=>{try{return await r(e,c)}catch(u){throw Tr(u)?new d("NETWORK",Nr(this.apiUrl)):u}},p=await s({...t,headers:i});if(p.status===401&&typeof this.accessToken=="function"){let c=await Ot(this.accessToken);if(c&&c!==o){let u=new Headers(t?.headers);return u.set("authorization",`Bearer ${c}`),this.applyClientHeader(u),s({...t,headers:u})}}return p}async requestResponse(e,t){let r=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}${e}`,t);if(!r.ok){let i=`Request failed with status ${r.status}`,o=Nt(r.status),s,p,c;try{let u=await r.json();typeof u.error?.message=="string"&&(i=u.error.message),typeof u.error?.code=="string"&&(o=u.error.code,s=u.error.code),typeof u.error?.hint=="string"&&(p=u.error.hint),typeof u.error?.retryAfter=="number"&&(c=u.error.retryAfter);}catch{}throw new d(o,i,r.status,p,c,s)}return r}async requestJson(e,t){return await(await this.requestResponse(e,t)).json()}async watchRepoQuery(e,t,r,i,o){let s=new AbortController,p=It(r,s),c=0,u=(async()=>{let l=async()=>{let h=await i();c+=1,await o(h);},m=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),f=await this.openSse(m.ticket,p,async h=>{h.type==="invalidate"&&await l();});return await f.ready,p.aborted?{updates:c}:(await l(),await f.closed,{updates:c})})();return {close(){s.abort();},closed:u}}};function Nt(n){switch(n){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHENTICATED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 409:return "CONFLICT";case 429:return "RATE_LIMITED";default:return "BACKEND"}}async function Ot(n){if(n)return typeof n=="string"?n:n()}function It(n,e){return n?n.aborted?(e.abort(),e.signal):(n.addEventListener("abort",()=>e.abort(),{once:true}),e.signal):e.signal}function Pr(n){let e="message",t=[];for(let i of n.split(`
|
|
6
|
-
`))if(!(!i||i.startsWith(":"))){if(i.startsWith("event:")){e=i.slice(6).trim();continue}i.startsWith("data:")&&t.push(i.slice(5).trim());}if(t.length===0)return null;let r=t.join(`
|
|
7
|
-
`);return {type:e,data:JSON.parse(r)}}function Lr(n){return n instanceof Error&&n.name==="AbortError"}export{Tr as A,Nr as B,Wn as C,St as D,re as a,qt as b,Se as c,ie as d,oe as e,k as f,x as g,W as h,se as i,G as j,L as k,ke as l,ae as m,Ee as n,xe as o,I as p,rr as q,le as r,Vn as s,De as t,Hn as u,Me as v,d as w,a as x,Er as y,Fn as z};//# sourceMappingURL=chunk-CZI7BWOX.js.map
|
|
8
|
-
//# sourceMappingURL=chunk-CZI7BWOX.js.map
|