@warmhub/sdk-ts 0.97.0 → 0.98.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/checkpoint.js.map +1 -1
- package/dist/{chunk-6VZ76RF7.js → chunk-2E722CFI.js} +2 -2
- package/dist/{chunk-6VZ76RF7.js.map → chunk-2E722CFI.js.map} +1 -1
- package/dist/chunk-NVZAXZAI.js +10 -0
- package/dist/chunk-NVZAXZAI.js.map +1 -0
- package/dist/index.d.ts +105 -10
- package/dist/index.js +1 -1
- package/dist/react.d.ts +6 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6KI5UDCP.js +0 -10
- package/dist/chunk-6KI5UDCP.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1098,7 +1098,7 @@ type ComponentDetail = {
|
|
|
1098
1098
|
aboutWref?: string;
|
|
1099
1099
|
affirmedWrefs?: Array<string>;
|
|
1100
1100
|
roles?: Array<'from' | 'to' | 'ends' | 'first' | 'second'>;
|
|
1101
|
-
metadata
|
|
1101
|
+
metadata: {
|
|
1102
1102
|
durableId: string;
|
|
1103
1103
|
createdOn: number;
|
|
1104
1104
|
revisedOn: number;
|
|
@@ -4905,7 +4905,7 @@ type ThingHistoryResult = {
|
|
|
4905
4905
|
createdAt: number;
|
|
4906
4906
|
committerWref?: string;
|
|
4907
4907
|
revisedBy?: string;
|
|
4908
|
-
metadata
|
|
4908
|
+
metadata: {
|
|
4909
4909
|
durableId: string;
|
|
4910
4910
|
createdOn: number;
|
|
4911
4911
|
};
|
|
@@ -4942,7 +4942,7 @@ type ThingGetManyResult$1 = {
|
|
|
4942
4942
|
committerWref?: string;
|
|
4943
4943
|
createdBy?: string;
|
|
4944
4944
|
revisedBy?: string;
|
|
4945
|
-
metadata
|
|
4945
|
+
metadata: {
|
|
4946
4946
|
durableId: string;
|
|
4947
4947
|
createdOn: number;
|
|
4948
4948
|
revisedOn: number;
|
|
@@ -5312,7 +5312,7 @@ type ViewEvaluateResult$1 = {
|
|
|
5312
5312
|
aboutWref?: string;
|
|
5313
5313
|
affirmedWrefs?: Array<string>;
|
|
5314
5314
|
roles?: Array<'from' | 'to' | 'ends' | 'first' | 'second'>;
|
|
5315
|
-
metadata
|
|
5315
|
+
metadata: {
|
|
5316
5316
|
durableId: string;
|
|
5317
5317
|
createdOn: number;
|
|
5318
5318
|
revisedOn: number;
|
|
@@ -5927,6 +5927,60 @@ declare function encodeCommitValidateRequestBody(input: CommitValidateInput): st
|
|
|
5927
5927
|
*/
|
|
5928
5928
|
declare function commitValidateRequestBodyBytes(input: CommitValidateInput): number;
|
|
5929
5929
|
|
|
5930
|
+
/**
|
|
5931
|
+
* The one durable-token collector every decoration surface shares (GH-8699).
|
|
5932
|
+
* The SDK link, the CLI's sidecar subsetting, and the MCP dispatcher all
|
|
5933
|
+
* detect body references through this module, so the contract-critical skip
|
|
5934
|
+
* rule cannot drift between surfaces.
|
|
5935
|
+
*/
|
|
5936
|
+
/**
|
|
5937
|
+
* Collect the bare canonical durable ids referenced anywhere in `value` —
|
|
5938
|
+
* bare, `@vN|@HEAD|@ALL`-pinned, and `wh:`-prefixed spellings alike, deduped
|
|
5939
|
+
* by identity (pins select versions; they don't change identity, and labels
|
|
5940
|
+
* always carry the current name).
|
|
5941
|
+
*
|
|
5942
|
+
* Skip rule (structural metadata only): the `durableId` entry of a
|
|
5943
|
+
* `metadata` envelope is an id-typed field whose label already rides the
|
|
5944
|
+
* item's own top-level `wref` — looking it up would add one self-lookup per
|
|
5945
|
+
* list item. The check is path-aware (`metadata` → `durableId`) **and
|
|
5946
|
+
* fenced to structural positions**: a `metadata.durableId` pair anywhere
|
|
5947
|
+
* under a `data` key is arbitrary user body content and is decorated —
|
|
5948
|
+
* structural envelopes never live inside `data`, thing bodies always do.
|
|
5949
|
+
* The skip exists for economy only, so when in doubt the walk decorates:
|
|
5950
|
+
* over-skipping hides a user reference, under-skipping merely enlarges one
|
|
5951
|
+
* batched lookup.
|
|
5952
|
+
* @see https://docs.warmhub.ai/sdk-reference/functions/collectdurabletokens/
|
|
5953
|
+
*/
|
|
5954
|
+
declare function collectDurableTokens(value: unknown): Set<string>;
|
|
5955
|
+
|
|
5956
|
+
/**
|
|
5957
|
+
* Reference-decoration internals: discover durable reference tokens in a
|
|
5958
|
+
* response payload and fold `thing.headVersions` items into the additive
|
|
5959
|
+
* `decorations` sidecar (durable id → canonical wref; a miss has no entry).
|
|
5960
|
+
*
|
|
5961
|
+
* Public surface: the option, the `WarmHubDecorations` type, the
|
|
5962
|
+
* `getResponseDecorations` accessor, and `collectDurableTokens` (so CLI-side
|
|
5963
|
+
* sidecar subsetting shares the one collector and its skip rule). The rest —
|
|
5964
|
+
* walker composition, map-builder, link — is not.
|
|
5965
|
+
*/
|
|
5966
|
+
|
|
5967
|
+
/**
|
|
5968
|
+
* The decoration sidecar a decorated response carries: bare durable id →
|
|
5969
|
+
* canonical wref (`wh:org/repo/Shape/name`, unversioned, current-name text).
|
|
5970
|
+
* An id the caller cannot read — or that does not exist — has no entry.
|
|
5971
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/warmhubdecorations/
|
|
5972
|
+
*/
|
|
5973
|
+
type WarmHubDecorations = Record<string, string>;
|
|
5974
|
+
/**
|
|
5975
|
+
* Read the decoration sidecar off a response, typed. Returns `undefined`
|
|
5976
|
+
* when the response carries none: the client was constructed without
|
|
5977
|
+
* `decorateResponses`, the result held no durable tokens, or the payload
|
|
5978
|
+
* was not a plain object. Top-level result shapes are procedure-controlled,
|
|
5979
|
+
* so a present `decorations` object is always the link's sidecar.
|
|
5980
|
+
* @see https://docs.warmhub.ai/sdk-reference/functions/getresponsedecorations/
|
|
5981
|
+
*/
|
|
5982
|
+
declare function getResponseDecorations(result: unknown): WarmHubDecorations | undefined;
|
|
5983
|
+
|
|
5930
5984
|
/**
|
|
5931
5985
|
* Operations to submit, in order.
|
|
5932
5986
|
*
|
|
@@ -6913,6 +6967,17 @@ interface WarmHubClientOptions {
|
|
|
6913
6967
|
* server. Untrusted intent — never an authz signal.
|
|
6914
6968
|
*/
|
|
6915
6969
|
clientFlags?: readonly string[];
|
|
6970
|
+
/**
|
|
6971
|
+
* Opt into response auto-decoration. Query results are walked for durable
|
|
6972
|
+
* reference tokens; one batched `thing.headVersions` lookup resolves them
|
|
6973
|
+
* under this caller's authority, and the result carries an additive
|
|
6974
|
+
* `decorations` record mapping each bare durable id to its canonical wref.
|
|
6975
|
+
* Unreadable and nonexistent ids get no entry. Costs one extra request per
|
|
6976
|
+
* decorated response, chunked into further requests past 500 distinct ids;
|
|
6977
|
+
* a failed lookup fails the read with the error marked
|
|
6978
|
+
* {@link WarmHubError.decorationFailure}. Defaults to `false`.
|
|
6979
|
+
*/
|
|
6980
|
+
decorateResponses?: boolean;
|
|
6916
6981
|
}
|
|
6917
6982
|
|
|
6918
6983
|
/**
|
|
@@ -7738,6 +7803,13 @@ type ThingGetWithLease = ThingDetail & {
|
|
|
7738
7803
|
* row shape (no `shape`, `validatedShape`, or `committerWref`); use
|
|
7739
7804
|
* `client.thing.get` to hydrate a full `ThingDetail` from a list result.
|
|
7740
7805
|
*
|
|
7806
|
+
* Authored WREF values inside `data` and identity metadata such as
|
|
7807
|
+
* `aboutWref`, `committerWref`, `createdBy`, and `revisedBy` use durable ids in
|
|
7808
|
+
* the reader-independent base response. Body references preserve their exact
|
|
7809
|
+
* version pin; identity references are unpinned. With `decorateResponses`, a
|
|
7810
|
+
* separate `decorations` sidecar maps readable durable ids to current canonical
|
|
7811
|
+
* labels without rewriting the base body. A durable id grants no target access.
|
|
7812
|
+
*
|
|
7741
7813
|
* @see https://docs.warmhub.ai/data-modeling/things/
|
|
7742
7814
|
*/
|
|
7743
7815
|
type ThingDetail = {
|
|
@@ -7756,11 +7828,17 @@ type ThingDetail = {
|
|
|
7756
7828
|
/** Canonical unversioned shape name (e.g. `"Game"`). */
|
|
7757
7829
|
shapeName?: string;
|
|
7758
7830
|
/**
|
|
7759
|
-
* Version-pinned shape wref (e.g. `"Game@v3"`)
|
|
7760
|
-
*
|
|
7761
|
-
*
|
|
7762
|
-
*
|
|
7763
|
-
* this is
|
|
7831
|
+
* Version-pinned shape wref (e.g. `"Game@v3"`) — the shape version that
|
|
7832
|
+
* validated this thing version.
|
|
7833
|
+
*
|
|
7834
|
+
* Naming caveat, now retiring. Where the read path still sources the legacy
|
|
7835
|
+
* shape column, this is *synthesized* from the shape's current version at
|
|
7836
|
+
* read time, so revising a shape retroactively changes it for every thing
|
|
7837
|
+
* already validated against an older version. Where reads are served from
|
|
7838
|
+
* certificate records it is the captured fact and no longer moves. The two
|
|
7839
|
+
* sources give the same answer except when the shape was revised after the
|
|
7840
|
+
* thing version was written; the caveat goes away entirely once every
|
|
7841
|
+
* repository reads certificates.
|
|
7764
7842
|
*/
|
|
7765
7843
|
validatedShape?: string;
|
|
7766
7844
|
version: number;
|
|
@@ -8356,6 +8434,15 @@ declare class WarmHubError extends Error {
|
|
|
8356
8434
|
* backend wire carried `data.warmhub.details`. See {@link WarmHubErrorDetails}.
|
|
8357
8435
|
*/
|
|
8358
8436
|
readonly details?: WarmHubErrorDetails;
|
|
8437
|
+
/**
|
|
8438
|
+
* Present (`true`) when this error came from the response-decoration
|
|
8439
|
+
* label lookup rather than the read itself — the read may have succeeded.
|
|
8440
|
+
* Set by the decoration link (see
|
|
8441
|
+
* {@link WarmHubClientOptions.decorateResponses}); surfaces use it to
|
|
8442
|
+
* suggest retrying without decoration. `declare`: assigned by the link,
|
|
8443
|
+
* never by this constructor.
|
|
8444
|
+
*/
|
|
8445
|
+
readonly decorationFailure?: true;
|
|
8359
8446
|
constructor(code: string, message: string, status?: number, hint?: string, retryAfter?: number, errorCode?: string, details?: WarmHubErrorDetails);
|
|
8360
8447
|
get kind(): ErrorKind;
|
|
8361
8448
|
}
|
|
@@ -8469,6 +8556,8 @@ declare class WarmHubClient {
|
|
|
8469
8556
|
private readonly clientIdentity;
|
|
8470
8557
|
/** Normalized `clientFlags` option; stamped on every request. */
|
|
8471
8558
|
private readonly clientFlags;
|
|
8559
|
+
/** Whether query responses carry the decoration sidecar. */
|
|
8560
|
+
private readonly decorateResponses;
|
|
8472
8561
|
protected readonly functionLogMode: FunctionLogMode;
|
|
8473
8562
|
protected readonly getToken?: () => Promise<string | undefined>;
|
|
8474
8563
|
private readonly trpc;
|
|
@@ -9417,6 +9506,9 @@ declare class WarmHubClient {
|
|
|
9417
9506
|
* Query the live delivery feed for a subscription.
|
|
9418
9507
|
*
|
|
9419
9508
|
* Use this for polling or live-log views that need recent delivery status entries.
|
|
9509
|
+
* Matched operation bodies use the same reader-independent durable WREF
|
|
9510
|
+
* form as thing bodies. With `decorateResponses`, readable labels are
|
|
9511
|
+
* attached separately in the response's `decorations` sidecar.
|
|
9420
9512
|
*
|
|
9421
9513
|
* Cursor contract: cursors are short-lived resume tokens for the same query
|
|
9422
9514
|
* and result scope. If filters, visibility, or backing streams change, the
|
|
@@ -10165,6 +10257,9 @@ declare class WarmHubClient {
|
|
|
10165
10257
|
* Query the live delivery feed for a subscription.
|
|
10166
10258
|
*
|
|
10167
10259
|
* Use this for polling or live-log views that need recent delivery status entries.
|
|
10260
|
+
* Matched operation bodies use the same reader-independent durable WREF
|
|
10261
|
+
* form as thing bodies. With `decorateResponses`, readable labels are
|
|
10262
|
+
* attached separately in the response's `decorations` sidecar.
|
|
10168
10263
|
*
|
|
10169
10264
|
* Cursor contract: cursors are short-lived resume tokens for the same query
|
|
10170
10265
|
* and result scope. If filters, visibility, or backing streams change, the
|
|
@@ -10259,4 +10354,4 @@ declare class WarmHubClient {
|
|
|
10259
10354
|
private watchRepoQuery;
|
|
10260
10355
|
}
|
|
10261
10356
|
|
|
10262
|
-
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 CommitDiagnostic, type CommitRealOperationResult, type CommitValidateInput, type CommitValidateOptions, type CommitValidateResult, 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_COMMIT_VALIDATION_ENCODED_BYTES, MAX_COMMIT_VALIDATION_OPERATIONS, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, ORG_AUTH_SCOPES, type Operation, OperationBuilder, type OperationBuilderAddInput, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceipt, 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 StreamingSubmissionHandle, type StreamingSubmissionOptions, StreamingSubmissionOutcomeUnknownError, type StreamingSubmissionRetryIdentity, type StreamingSubmissionRow, 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, commitValidateRequestBodyBytes, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createCommitValidateInput, createOperationEventRequestId, createOperationEventSubmissionId, encodeCommitValidateRequestBody, isConnectionError, isDefiniteStreamAppendRejection, isKnownOrgAuthScope, isKnownRepoAuthScope, isRetryable, isWarmHubError, normalizeWref, operationEventStreamRequestId, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
|
10357
|
+
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 CommitDiagnostic, type CommitRealOperationResult, type CommitValidateInput, type CommitValidateOptions, type CommitValidateResult, 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_COMMIT_VALIDATION_ENCODED_BYTES, MAX_COMMIT_VALIDATION_OPERATIONS, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, ORG_AUTH_SCOPES, type Operation, OperationBuilder, type OperationBuilderAddInput, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceipt, 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 StreamingSubmissionHandle, type StreamingSubmissionOptions, StreamingSubmissionOutcomeUnknownError, type StreamingSubmissionRetryIdentity, type StreamingSubmissionRow, 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, type WarmHubDecorations, WarmHubError, type WarmHubErrorDetails, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry, collectDurableTokens, commitValidateRequestBodyBytes, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createCommitValidateInput, createOperationEventRequestId, createOperationEventSubmissionId, encodeCommitValidateRequestBody, getResponseDecorations, 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{o as AllStreamOperationsFailedError,v as CliCallVerificationError,z as DEFAULT_API_URL,l as DEFAULT_STREAM_CHUNK_SIZE,b as MAX_COMMIT_VALIDATION_ENCODED_BYTES,a as MAX_COMMIT_VALIDATION_OPERATIONS,m as MAX_STREAM_APPEND_OPERATION_COUNT,x as OperationBuilder,n as PartialStreamSubmissionError,u as SDK_VERSION,h as StreamSubmissionAggregator,t as StreamingSubmissionOutcomeUnknownError,J as WarmHubClient,C as WarmHubError,f as collectDurableTokens,e as commitValidateRequestBodyBytes,H as connectionErrorMessage,q as countStreamAppendResultStatuses,c as createCommitValidateInput,j as createOperationEventRequestId,i as createOperationEventSubmissionId,d as encodeCommitValidateRequestBody,g as getResponseDecorations,G as isConnectionError,r as isDefiniteStreamAppendRejection,F as isRetryable,E as isWarmHubError,y as normalizeWref,k as operationEventStreamRequestId,A as resolveFunctionLogMode,B as sanitizeErrorMessage,I as sdkVersionIsBelowMinimum,p as streamAppendResultStatus,s as submitOperationsViaStream,D as toWarmHubError,w as verifyCliCall}from'./chunk-NVZAXZAI.js';export{n as CLI_INSTALL_REPO_HEADER,o as CLI_SIGNATURE_HEADER,p as CLI_TIMESTAMP_HEADER,y as CONTENT_FIELD_LIMIT_ERROR,x as MAX_CONTENT_FIELD_BYTES,A as ORG_AUTH_SCOPES,s as REPO_AUTH_SCOPES,z as contentFieldLimitError,B as isKnownOrgAuthScope,t as isKnownRepoAuthScope,Q as validateAgainstShape}from'./chunk-2E722CFI.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react.d.ts
CHANGED
|
@@ -22,13 +22,18 @@ interface WarmHubProviderProps {
|
|
|
22
22
|
name?: string;
|
|
23
23
|
version?: string;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Opt the app's client into response auto-decoration; see
|
|
27
|
+
* `WarmHubClientOptions.decorateResponses`.
|
|
28
|
+
*/
|
|
29
|
+
decorateResponses?: boolean;
|
|
25
30
|
}
|
|
26
31
|
interface WarmHubAuthState {
|
|
27
32
|
isAuthenticated: boolean;
|
|
28
33
|
isLoading: boolean;
|
|
29
34
|
}
|
|
30
35
|
/** @internal */
|
|
31
|
-
declare function WarmHubProvider({ apiUrl, children, auth, client: clientIdentity, }: WarmHubProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare function WarmHubProvider({ apiUrl, children, auth, client: clientIdentity, decorateResponses, }: WarmHubProviderProps): react_jsx_runtime.JSX.Element;
|
|
32
37
|
/** @internal */
|
|
33
38
|
declare function useWarmHubClient(): WarmHubClient;
|
|
34
39
|
/** @internal */
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {J}from'./chunk-NVZAXZAI.js';export{z as DEFAULT_API_URL,u as SDK_VERSION,J as WarmHubClient,C as WarmHubError,D as toWarmHubError}from'./chunk-NVZAXZAI.js';import'./chunk-2E722CFI.js';import {createContext,useMemo,useState,useEffect,useContext}from'react';import {jsx}from'react/jsx-runtime';var p=createContext(null),f=createContext({isAuthenticated:false,isLoading:true});function P({apiUrl:e,children:t,auth:o,client:s,decorateResponses:r}){let n=s?.name,u=s?.version,i=useMemo(()=>new J({apiUrl:e,accessToken:async()=>await o.getAccessToken()??void 0,client:{name:n,version:u},decorateResponses:r}),[e,o.getAccessToken,n,u,r]);return jsx(p.Provider,{value:i,children:jsx(g,{auth:o,client:i,children:t})})}function g({auth:e,client:t,children:o}){let[s,r]=useState(null),n=e.isAuthenticated&&s===t;useEffect(()=>{if(!e.isAuthenticated){r(null);return}let i=false;return t.auth.sync().then(()=>{i||r(t);}).catch(c=>{console.error("auth.sync failed:",c),i||r(t);}),()=>{i=true;}},[e.isAuthenticated,t]);let u=useMemo(()=>({isAuthenticated:e.isAuthenticated&&n,isLoading:e.isLoading||e.isAuthenticated&&!n}),[e.isAuthenticated,e.isLoading,n]);return e.isLoading||e.isAuthenticated&&!n?null:jsx(f.Provider,{value:u,children:o})}function v(){let e=useContext(p);if(!e)throw new Error("useWarmHubClient must be used within a WarmHubProvider");return e}function S(){return useContext(f)}export{P as WarmHubProvider,S as useWarmHubAuth,v as useWarmHubClient};//# sourceMappingURL=react.js.map
|
|
2
2
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/provider.tsx"],"names":["ClientContext","createContext","AuthContext","WarmHubProvider","apiUrl","children","auth","clientIdentity","clientName","clientVersion","client","useMemo","WarmHubClient","jsx","AuthSyncGate","syncedClient","setSyncedClient","useState","synced","useEffect","cancelled","err","authState","useWarmHubClient","useContext","useWarmHubAuth"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/react/provider.tsx"],"names":["ClientContext","createContext","AuthContext","WarmHubProvider","apiUrl","children","auth","clientIdentity","decorateResponses","clientName","clientVersion","client","useMemo","WarmHubClient","jsx","AuthSyncGate","syncedClient","setSyncedClient","useState","synced","useEffect","cancelled","err","authState","useWarmHubClient","useContext","useWarmHubAuth"],"mappings":"4SAsCA,IAAMA,CAAAA,CAAgBC,aAAAA,CAAoC,IAAI,CAAA,CACxDC,CAAAA,CAAcD,aAAAA,CAAgC,CAClD,eAAA,CAAiB,KAAA,CACjB,SAAA,CAAW,IACb,CAAC,CAAA,CAGM,SAASE,CAAAA,CAAgB,CAC9B,MAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,MAAA,CAAQC,CAAAA,CACR,iBAAA,CAAAC,CACF,CAAA,CAAyB,CAKvB,IAAMC,CAAAA,CAAaF,CAAAA,EAAgB,IAAA,CAC7BG,CAAAA,CAAgBH,CAAAA,EAAgB,OAAA,CAChCI,CAAAA,CAASC,OAAAA,CACb,IACE,IAAIC,CAAAA,CAAc,CAChB,MAAA,CAAAT,CAAAA,CACA,WAAA,CAAa,SACG,MAAME,CAAAA,CAAK,cAAA,EAAe,EACxB,MAAA,CAElB,MAAA,CAAQ,CAAE,IAAA,CAAMG,CAAAA,CAAY,OAAA,CAASC,CAAc,CAAA,CACnD,iBAAA,CAAAF,CACF,CAAC,CAAA,CACH,CAACJ,CAAAA,CAAQE,CAAAA,CAAK,cAAA,CAAgBG,CAAAA,CAAYC,CAAAA,CAAeF,CAAiB,CAC5E,CAAA,CAEA,OACEM,GAAAA,CAACd,CAAAA,CAAc,QAAA,CAAd,CAAuB,KAAA,CAAOW,CAAAA,CAC7B,QAAA,CAAAG,GAAAA,CAACC,CAAAA,CAAA,CAAa,IAAA,CAAMT,CAAAA,CAAM,MAAA,CAAQK,CAAAA,CAC/B,QAAA,CAAAN,CAAAA,CACH,CAAA,CACF,CAEJ,CAEA,SAASU,CAAAA,CAAa,CACpB,IAAA,CAAAT,CAAAA,CACA,MAAA,CAAAK,CAAAA,CACA,QAAA,CAAAN,CACF,CAAA,CAIG,CACD,GAAM,CAACW,CAAAA,CAAcC,CAAe,CAAA,CAAIC,QAAAA,CAA+B,IAAI,CAAA,CACrEC,CAAAA,CAASb,CAAAA,CAAK,eAAA,EAAmBU,CAAAA,GAAiBL,CAAAA,CAExDS,SAAAA,CAAU,IAAM,CACd,GAAI,CAACd,CAAAA,CAAK,eAAA,CAAiB,CACzBW,CAAAA,CAAgB,IAAI,CAAA,CACpB,MACF,CAEA,IAAII,CAAAA,CAAY,KAAA,CAChB,OAAAV,CAAAA,CAAO,IAAA,CACJ,IAAA,EAAK,CACL,IAAA,CAAK,IAAM,CACLU,CAAAA,EAAWJ,CAAAA,CAAgBN,CAAM,EACxC,CAAC,CAAA,CACA,KAAA,CAAOW,CAAAA,EAAQ,CACd,OAAA,CAAQ,KAAA,CAAM,mBAAA,CAAqBA,CAAG,CAAA,CACjCD,CAAAA,EAAWJ,CAAAA,CAAgBN,CAAM,EACxC,CAAC,CAAA,CACI,IAAM,CACXU,CAAAA,CAAY,KACd,CACF,CAAA,CAAG,CAACf,CAAAA,CAAK,eAAA,CAAiBK,CAAM,CAAC,CAAA,CAEjC,IAAMY,CAAAA,CAAYX,OAAAA,CAChB,KAAO,CACL,eAAA,CAAiBN,CAAAA,CAAK,eAAA,EAAmBa,CAAAA,CACzC,SAAA,CAAWb,CAAAA,CAAK,SAAA,EAAcA,CAAAA,CAAK,eAAA,EAAmB,CAACa,CACzD,CAAA,CAAA,CACA,CAACb,CAAAA,CAAK,eAAA,CAAiBA,CAAAA,CAAK,SAAA,CAAWa,CAAM,CAC/C,CAAA,CAGA,OAAIb,CAAAA,CAAK,SAAA,EAAcA,CAAAA,CAAK,eAAA,EAAmB,CAACa,CAAAA,CACvC,IAAA,CAIPL,GAAAA,CAACZ,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAOqB,CAAAA,CAAY,QAAA,CAAAlB,CAAAA,CAAS,CAEtD,CAGO,SAASmB,CAAAA,EAAkC,CAChD,IAAMb,CAAAA,CAASc,UAAAA,CAAWzB,CAAa,CAAA,CACvC,GAAI,CAACW,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,wDAAwD,CAAA,CAE1E,OAAOA,CACT,CAGO,SAASe,CAAAA,EAAmC,CACjD,OAAOD,UAAAA,CAAWvB,CAAW,CAC/B","file":"react.js"}
|
package/package.json
CHANGED
package/dist/chunk-6KI5UDCP.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {j as j$1,D as D$1,n,q as q$1,o,p,r,P,C,u,v as v$1,b,f,e,i,a,d,m,B as B$1,y as y$1,O as O$1,N as N$1,k,c as c$1,l,g,h}from'./chunk-6VZ76RF7.js';import {TRPCClientError,createTRPCProxyClient,splitLink,httpBatchLink,httpLink}from'@trpc/client';import {observable}from'@trpc/server/observable';import {z as z$1}from'zod';var sr=new Set(["arc","bond","pair","set","list"]);function G(r,e){let t=ot(r,e,"add");return {operation:"add",kind:"collection",name:t.name,type:t.type,members:t.members,...r.skipExisting===true?{skipExisting:true}:{}}}function ie(r,e){let t=ot(r,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 r.expectedVersion=="number"?{expectedVersion:r.expectedVersion}:{},...typeof r.leaseId=="string"&&r.leaseId.length>0?{leaseId:r.leaseId}:{}}}function ot(r,e,t){let n=C({operation:t,kind:"collection",name:typeof r.name=="string"?r.name:void 0,type:typeof r.type=="string"?r.type:void 0,members:Array.isArray(r.members)?r.members:void 0},0);if(n.length>0)throw new Error(`${e}: ${n.map(s=>s.message).join("; ")}`);let i=cr(r.type);if(!i)throw new Error(`${e}: collection ${t} requires 'type'. Use one of: arc, bond, set, list`);if(!Array.isArray(r.members))throw new Error(`${e}: collection ${t} requires a 'members' array`);let o=ur(r.name);if(!o)throw new Error(`${e}: collection ${t} name must be a non-empty string`);return ar(r,e,t),{name:o,type:i,members:r.members}}function ar(r,e,t){let n=["about","aboutWref","shapeWref","data",...t==="revise"?["skipExisting"]:[]].filter(i=>r[i]!==void 0);if(n.length>0)throw new Error(`${e}: collection ${t} does not support ${n.map(i=>`'${i}'`).join(", ")}`)}function cr(r){if(typeof r!="string")return;let e=r.trim();if(sr.has(e))return e}function ur(r){if(typeof r=="string"&&!(r.length===0||r.trim()!==r))return r}function N(r){if(r.expectedVersion!==void 0&&r.operation!=="revise"&&r.operation!=="retract"&&r.operation!=="reaffirm")throw new Error("expectedVersion is only valid on revise, retract, or reaffirm operations \u2014 set an explicit operation discriminator");if(r.operation==="retract")return {operation:"retract",name:r.name,...r.kind?{kind:r.kind}:{},...r.reason?{reason:r.reason}:{},...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.leaseId?{leaseId:r.leaseId}:{}};if(r.operation==="reaffirm")return {operation:"reaffirm",name:r.name,...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.kind?{kind:r.kind}:{},...r.add?{add:r.add}:{},...r.remove?{remove:r.remove}:{},...r.leaseId?{leaseId:r.leaseId}:{}};if(r.operation==="rename")return {operation:"rename",name:r.name,newName:r.newName,...r.kind?{kind:r.kind}:{}};if(r.operation==="revise"){let n=r.name??r.wref;if(!n)throw new Error("revise operation requires a target");let i=m({kind:r.kind,name:n});if(Object.hasOwn(r,"active"))throw new Error(`${i} revise operation no longer supports 'active' \u2014 use retract('${n}') instead`);if(i!=="assertion"&&r.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 ie(r,"commit.apply");if(r.data===void 0)throw new Error(`${i} revise operation requires 'data'`);return i==="assertion"?{operation:"revise",kind:"assertion",name:n,data:r.data,...r.affirmedTargets?{affirmedTargets:r.affirmedTargets}:{},...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.leaseId?{leaseId:r.leaseId}:{}}:{operation:"revise",kind:i,name:n,data:r.data,...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.leaseId?{leaseId:r.leaseId}:{}}}let e=m(r),t="skipExisting"in r?r.skipExisting:void 0;if(e!=="collection"&&("type"in r&&r.type!==void 0||"members"in r&&r.members!==void 0))throw new Error(`add operation '${r.name??""}' has collection fields but resolved kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`);if(e!=="assertion"&&r.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 G({...r,skipExisting:t},"commit.apply");if(!r.name)throw new Error("add operation requires a name");if(e==="assertion"){if(!("about"in r)||r.about===void 0)throw new Error("assertion add operation requires 'about'");if(typeof r.about!="string")throw new Error(B$1);if(r.data===void 0)throw new Error("assertion add operation requires 'data'");return {operation:"add",kind:"assertion",name:r.name,about:r.about,data:r.data,...r.affirmedTargets?{affirmedTargets:r.affirmedTargets}:{},...t===true?{skipExisting:t}:{}}}if(r.data===void 0)throw new Error(`${e} add operation requires 'data'`);return {operation:"add",kind:e,name:r.name,data:r.data,...t===true?{skipExisting:t}:{}}}var pr=1e4,lr=4*1024*1024,ve=class extends Error{code="VALIDATION_ERROR";status=400;constructor(e){super(e),this.name="WarmHubError";}};function ke(r,e){return r.map((t,n)=>{let i;try{i=N(t);}catch(o){let s=o instanceof Error?o.message:String(o);throw new ve(`Invalid operation at index ${n}: ${s}`)}return e===true&&i.operation==="add"?{...i,skipExisting:true}:i})}function dr(r,e,t,n){return {orgName:r,repoName:e,...n?.committer!==void 0?{committer:n.committer}:{},...n?.message!==void 0?{message:n.message}:{},...n?.componentRef!==void 0?{componentRef:n.componentRef}:{},operations:ke(t,n?.skipExisting),...n?.includeWouldBeBody!==void 0?{includeWouldBeBody:n.includeWouldBeBody}:{}}}function st(r){return JSON.stringify(r)}function mr(r){return new TextEncoder().encode(st(r)).byteLength}function at(r,e){return {create:async(t,n,i)=>{try{return await r().grant.create.mutate({orgName:t,repoName:n,...i})}catch(o){throw e(o)}},get:async(t,n,i)=>{try{return await r().grant.get.query({orgName:t,repoName:n,grantId:i})}catch(o){throw e(o)}},list:async(t,n,i)=>{try{return await r().grant.list.query({orgName:t,repoName:n,limit:i?.limit,cursor:i?.cursor})}catch(o){throw e(o)}},revoke:async(t,n,i,o)=>{try{return await r().grant.revoke.mutate({orgName:t,repoName:n,grantId:i,reason:o?.reason})}catch(s){throw e(s)}}}}function oe(r){return {...r,createdAt:new Date(r.createdAt),updatedAt:new Date(r.updatedAt),runStartedAt:new Date(r.runStartedAt),...r.state==="complete"||r.state==="failed"?{completedAt:new Date(r.completedAt)}:{}}}function gr(r){return {...r,expiresAt:new Date(r.expiresAt)}}function ct(r){if(typeof r.checkpointId=="string"&&typeof r.repoSeq!="number")return {by:"id",checkpointId:r.checkpointId};if(typeof r.repoSeq=="number"&&typeof r.checkpointId!="string")return {by:"repoSeq",repoSeq:r.repoSeq};throw new TypeError("Repository checkpoint selector must contain exactly one of checkpointId or repoSeq")}function ut(r,e){return {generate:async(t,n,i)=>{try{let o=await r().repo.checkpoint.generate.mutate({orgName:t,repoName:n,atLeastRepoSeq:i?.atLeastRepoSeq});return oe(o.checkpoint)}catch(o){throw e(o)}},status:async(t,n,i)=>{try{let o=await r().repo.checkpoint.status.query({orgName:t,repoName:n,selector:ct(i)});return oe(o)}catch(o){throw e(o)}},latest:async(t,n)=>{try{let i=await r().repo.checkpoint.latest.query({orgName:t,repoName:n});return i.checkpoint?oe(i.checkpoint):null}catch(i){throw e(i)}},getAccess:async(t,n,i)=>{try{let o=await r().repo.checkpoint.access.query({orgName:t,repoName:n,selector:i.checkpoint==="latest"?{by:"latest"}:ct(i.checkpoint),artifact:i.artifact==="archive"||i.artifact==="manifest"?{kind:i.artifact}:{kind:"chunk",path:i.artifact.chunkPath}});return gr(o)}catch(o){throw e(o)}},retry:async(t,n,i)=>{try{let o=await r().repo.checkpoint.retry.mutate({orgName:t,repoName:n,checkpointId:i});return oe(o.checkpoint)}catch(o){throw e(o)}}}}function K(r,e,t){let n=O$1(e,t==="revise"?{allowUnsafeFieldNamePaths:N$1(e)}:void 0);return n.valid?null:`Invalid shape definition for "${r}": ${n.errors.join("; ")}`}function hr(r,e,t){let n=r.operation===void 0||r.operation==="noop"?t?.operation??"add":r.operation,i={opIndex:e,name:r.name??"",operation:n,...r.affirmations?{affirmations:r.affirmations}:{},...r.resolvedName!==void 0?{resolvedName:r.resolvedName}:{},...r.warnings?{warnings:r.warnings}:{}};return r.status==="failed"?{...i,status:"error",errors:[{code:r.error?.code??"BACKEND",message:r.error?.message??`Operation on "${r.name}" failed`,...r.error?.details?{details:r.error.details}:{},...r.retryable!==void 0?{retryable:r.retryable}:{}}],...t?.name!==void 0?{submittedName:t.name}:{}}:{...i,status:r.status==="noop"||r.operation==="noop"?"noop":"applied",...r.version!==void 0?{version:r.version}:{},...r.dataHash!==void 0?{dataHash:r.dataHash}:{}}}var D=class{receipts=[];operations=[];statusCounts={applied:0,noop:0,error:0};get allFailed(){return this.operations.length>0&&this.statusCounts.error===this.operations.length}addChunk(e){if(e.result.schemaVersion==="operation-event-receipt/v2"){e.result.results.forEach(t=>{this.statusCounts[t.status]++,this.operations.push({...t,opIndex:e.chunkStart+t.opIndex});});return}e.result.results.forEach((t,n)=>{let i=t.opIndex??n,o=e.submittedOperations[i],s=hr(t,e.chunkStart+i,o);this.statusCounts[s.status]++,this.operations.push(s);});}addReceipt(e){this.receipts.push(e);}completedOperations(){return this.operations.filter(e=>e.status!=="error")}toResult(e){let t=this.statusCounts.error>0;return {...e.committer!==void 0?{committer:e.committer}:{},...e.createdByEmail!==void 0?{createdByEmail:e.createdByEmail}:{},message:e.message,operationCount:this.operations.length,...e.repoSeq!==void 0?{repoSeq:e.repoSeq}:{},...t?{partial:t,statusCounts:{...this.statusCounts}}:{},operations:this.operations,receipts:this.receipts}}};var yr="003e7e6c-2f1e-53ea-9dfa-627edd04a8cc",fr=/^[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 pt(r){if(!fr.test(r))throw new Error("Operation-event submission ID must be a canonical UUID");let e=r.toLowerCase().replaceAll("-","");return Uint8Array.from({length:16},(t,n)=>Number.parseInt(e.slice(n*2,n*2+2),16))}function Ee(r,e){return (r<<e|r>>>32-e)>>>0}function Rr(r){let e=r.length*8,t=Math.ceil((r.length+9)/64)*64,n=new Uint8Array(t);n.set(r),n[r.length]=128;let i=new DataView(n.buffer);i.setUint32(t-8,Math.floor(e/4294967296)),i.setUint32(t-4,e>>>0);let o=1732584193,s=4023233417,u=2562383102,p=271733878,l=3285377520,d=new Uint32Array(80);for(let f=0;f<t;f+=64){for(let b=0;b<16;b+=1)d[b]=i.getUint32(f+b*4);for(let b=16;b<80;b+=1)d[b]=Ee(d[b-3]^d[b-8]^d[b-14]^d[b-16],1);let C=o,h=s,R=u,I=p,S=l;for(let b=0;b<80;b+=1){let H,F;b<20?(H=h&R|~h&I,F=1518500249):b<40?(H=h^R^I,F=1859775393):b<60?(H=h&R|h&I|R&I,F=2400959708):(H=h^R^I,F=3395469782);let or=Ee(C,5)+H+S+F+d[b]>>>0;S=I,I=R,R=Ee(h,30),h=C,C=or;}o=o+C>>>0,s=s+h>>>0,u=u+R>>>0,p=p+I>>>0,l=l+S>>>0;}let m=new Uint8Array(20),g=new DataView(m.buffer);for(let[f,C]of [o,s,u,p,l].entries())g.setUint32(f*4,C);return m}function br(r){let e=Array.from(r,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 M(){let r=globalThis.crypto?.randomUUID?.();if(!r)throw new Error("This runtime cannot mint a cryptographically secure UUID");return r.toLowerCase()}var Sr=M;function xe(r,e){if(!Number.isInteger(e)||e<0||e>2147483647)throw new Error("Stream chunk ordinal must be an integer from 0 through 2147483647");pt(r);let t=r.toLowerCase(),n=pt(yr),i=new TextEncoder().encode(`${t}:${e}`),o=Rr(Uint8Array.from([...n,...i])).slice(0,16);return o[6]=o[6]&15|80,o[8]=o[8]&63|128,br(o)}var se=1e3,ae=1e4,v=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(n=>n.status==="error")?.errors[0];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 Te(r){let e="status"in r?r.status:void 0;return e==="failed"||e==="error"?"error":e==="noop"||r.operation==="noop"?"noop":"applied"}function mt(r){let e={applied:0,noop:0,error:0};for(let t of r)e[Te(t)]++;return e}var Cr={maxAttempts:3,baseDelayMs:250,maxDelayMs:8e3},wr=10,lt=6e4;function Ne(r){if(r===false)return false;let e={};r!==void 0&&(Number.isFinite(r.maxAttempts)&&(e.maxAttempts=r.maxAttempts),Number.isFinite(r.baseDelayMs)&&(e.baseDelayMs=r.baseDelayMs),Number.isFinite(r.maxDelayMs)&&(e.maxDelayMs=r.maxDelayMs));let t={...Cr,...e};return {maxAttempts:Math.min(wr,Math.max(1,Math.trunc(t.maxAttempts))),baseDelayMs:Math.min(lt,Math.max(0,Math.trunc(t.baseDelayMs))),maxDelayMs:Math.min(lt,Math.max(0,Math.trunc(t.maxDelayMs)))}}var Or=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"]),Ir=new Set(["COMMIT_OUTCOME_UNKNOWN"]);function gt(r){if(!r||typeof r!="object")return;let e=r.code;if(typeof e=="string")return e;let t=r.data,n=t?.warmhub?.code;if(typeof n=="string")return n;let i=t?.code;if(typeof i=="string")return i}function Ar(r){if(!r||typeof r!="object")return;let e=r.data?.httpStatus;if(typeof e=="number")return e;let t=r.data?.warmhub?.status;if(typeof t=="number")return t;let n=r.status;return typeof n=="number"?n:void 0}function vr(r){return r!==void 0&&r>=400&&r<500&&r!==408}function ht(r){let e=gt(r);return e!==void 0&&Ir.has(e)}function z(r){if(ht(r))return false;let e=gt(r);return e!==void 0&&Or.has(e)||vr(Ar(r))}function _e(r){if(ht(r)||z(r))return false;if(dt(r))return true;if(r instanceof TypeError||r instanceof SyntaxError)return false;let e=r?.cause;return dt(e)?true:!(e instanceof TypeError||e instanceof SyntaxError)}function dt(r){return r instanceof TypeError&&/fetch/i.test(r.message)}function Pe(r,e){let t=e.baseDelayMs*2**Math.max(0,r-1),n=Math.random()*e.baseDelayMs;return Math.min(e.maxDelayMs,t+n)}function Le(r){return new Promise(e=>setTimeout(e,r))}var j=class extends Error{code;status=400;constructor(e,t="VALIDATION_ERROR"){super(e),this.code=t,this.name="WarmHubError";}},ce=class extends Error{constructor(t){super("operation source failed");this.reason=t;}reason};async function q(r,e){let t=pe(e.chunkSize),n=e.submissionId??M(),i=e.streamId??n,o=Ne(e.retry),s=new D,u=[],p,l,d=0,m,g=0,f=h=>new v({cause:h.cause,completedReceipts:s.receipts,completedOperations:s.completedOperations(),acknowledgedOperationCount:d,lastAcknowledgedRepoSeq:m,attemptedAppendOutcome:h.pendingOutcome==="absent"?"not_applied":"unknown",submissionId:n,eventRequestId:xe(n,g),chunkOrdinal:g,pendingOutcome:h.pendingOutcome});try{for await(let h of kr(e.operations,t,e.skipExisting===!0)){let R=1,I=!1;for(;;)try{let S=await r.stream.append({allocatedTokenRanges:u,chunkOrdinal:g,orgName:e.orgName,repoName:e.repoName,streamId:i,submissionId:n,componentRef:e.componentRef,committer:e.committer,message:e.message,...e.returnRepoSeq!==void 0?{returnRepoSeq:e.returnRepoSeq}:{},operations:h.operations});s.addReceipt(S.receipt),u=S.allocatedTokenRanges,p=S.createdByEmail??p,l=S.repoSeq??l,s.addChunk({result:S,chunkStart:h.start,submittedOperations:h.operations}),d+=h.operations.length;let b=xr(S.receipt);b!==void 0&&(m=b);break}catch(S){let b=z(S);if(s.receipts.length===0&&!I&&b)throw S;if(o!==!1&&R<o.maxAttempts&&_e(S)){await Le(Pe(R,o)),R+=1,I=!0;continue}throw f({cause:S,pendingOutcome:I||!b?"unknown":"absent"})}g+=1;}}catch(h){throw h instanceof ce?s.receipts.length===0?h.reason:f({cause:h.reason,pendingOutcome:"absent"}):h}if(g===0)throw new j("At least one operation is required for stream submission.");let C=s.toResult({committer:e.committer,createdByEmail:p,message:e.message,repoSeq:l});if(s.allFailed)throw new x(C);return C}async function*kr(r,e,t){try{if(Array.isArray(r)){let o=r.map((s,u)=>De(s,u,t));Rt(o,0);for(let s=0;s<o.length;s+=e)yield {operations:o.slice(s,s+e),start:s};return}let n=0,i=[];for await(let o of ft(r,t))i.push(o),n+=1,!(i.length<e)&&(yield yt(i,n),i=[]);i.length>0&&(yield yt(i,n));}catch(n){throw new ce(n)}}function yt(r,e){let t=e-r.length;return Rt(r,t),{operations:r,start:t}}function De(r,e,t){let n;try{n=N(r);}catch(i){let o=i instanceof Error?i.message:String(i);throw new j(`Invalid operation at index ${e}: ${o}`)}return t&&n.operation==="add"?{...n,skipExisting:true}:n}async function*ft(r,e){let t=ue(r,e);try{for(;;){let n=await t.next();if(n.done)return;yield n.value;}}finally{let n=t.returnSourceOnce();n&&await n;}}function ue(r,e){let t,n=0,i=false,o=false,s=()=>t||(t=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator](),t);return {async next(){let u=await s().next();if(u.done)return o=true,{done:true,value:void 0};let p=De(u.value,n,e);return n+=1,{done:false,value:p}},returnSourceOnce(){if(!i&&(i=true,!o))return t?.return?.()}}}function Me(r){return Er.encode(`${JSON.stringify(r)}
|
|
2
|
-
`)}var Er=new TextEncoder;function xr(r){let e=r.event?.repoSeq;if(e===void 0)return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function Rt(r,e){let t=D$1(r).find(n=>!Tr(n));if(t)throw new j(`Invalid operation at index ${e+t.operationIndex}: ${t.message}`,t.code)}function Tr(r){return r.code==="ILLEGAL_OP_SEQUENCE"&&r.message.includes("Cannot revise then add ")}function pe(r){return Number.isFinite(r)?Math.max(1,Math.min(ae,Math.trunc(r))):se}var Ct="warmhub/streaming-submission-manifest/v1",Nr=new TextEncoder,Be=z$1.string().regex(/^sha256:[0-9a-f]{64}$/),wt={type:z$1.literal("result"),chunkOrdinal:z$1.number().int().nonnegative(),opIndex:z$1.number().int().nonnegative(),submissionIndex:z$1.number().int().nonnegative(),name:z$1.string()},_r=z$1.enum(j$1),Pr=z$1.enum([...j$1,"noop"]),Ot=z$1.object({path:z$1.string(),message:z$1.string()}),It=z$1.object({undeclaredFields:z$1.array(z$1.string()).optional(),undeclaredFieldsTruncated:z$1.literal(true).optional(),totalUndeclared:z$1.number().int().nonnegative().optional(),coalescedWrefs:z$1.array(z$1.object({fieldPath:z$1.string(),wref:z$1.string(),reason:z$1.string()})).optional(),coalescedWrefsTruncated:z$1.literal(true).optional(),totalCoalescedWrefs:z$1.number().int().nonnegative().optional(),deprecations:z$1.array(z$1.object({shape:z$1.string(),message:z$1.string(),removalMilestone:z$1.string()})).optional()}).optional(),At=z$1.object({added:z$1.array(z$1.string()),removed:z$1.array(z$1.string()),ignored:z$1.array(z$1.string())}),Lr=z$1.discriminatedUnion("reason",[z$1.object({reason:z$1.literal("expected_version_mismatch"),expectedVersion:z$1.number().int().positive(),currentVersion:z$1.number().int().positive()}),z$1.object({reason:z$1.literal("lease_held"),leaseExpiresAt:z$1.string().datetime()}),z$1.object({reason:z$1.literal("validation_failed"),issues:z$1.array(Ot)}),z$1.object({reason:z$1.literal("rate_limit_reset"),retryAfterSeconds:z$1.number().int().positive(),resetAt:z$1.string().datetime()}),z$1.object({reason:z$1.literal("cursor_fence_unavailable"),cause:z$1.enum(["not_ready","below_floor","above_head"]),retryFromStart:z$1.literal(true)})]),Dr=z$1.discriminatedUnion("reason",[z$1.object({reason:z$1.literal("expected_version_mismatch"),expectedVersion:z$1.number().int().nonnegative(),currentVersion:z$1.number().int().nonnegative()}).strict(),z$1.object({reason:z$1.literal("lease_held"),leaseExpiresAt:z$1.string().datetime()}).strict(),z$1.object({reason:z$1.literal("validation_failed"),issues:z$1.array(Ot.strict())}).strict(),z$1.object({reason:z$1.literal("rate_limit_reset"),retryAfterSeconds:z$1.number().nonnegative(),resetAt:z$1.string().datetime()}).strict(),z$1.object({reason:z$1.literal("cursor_fence_unavailable"),cause:z$1.enum(["not_ready","below_floor","above_head"]),retryFromStart:z$1.literal(true)}).strict(),z$1.object({reason:z$1.literal("dependency_failed"),producerOpIndexes:z$1.array(z$1.number().int().nonnegative()).min(1)}).strict()]),bt={...wt,operation:_r,submittedName:z$1.string().optional(),resolvedName:z$1.string().optional(),warnings:It,affirmations:At.optional()},Mr=z$1.union([z$1.object({...wt,operation:Pr.optional(),version:z$1.number().optional(),dataHash:z$1.string().optional(),status:z$1.enum(["success","noop","failed"]).optional(),error:z$1.object({code:z$1.string(),message:z$1.string(),details:Lr.optional()}).optional(),resolvedName:z$1.string().optional(),retryable:z$1.boolean().optional(),warnings:It,affirmations:At.optional()}).passthrough(),z$1.object({...bt,status:z$1.enum(["applied","noop"]),version:z$1.number().int().positive().optional(),dataHash:z$1.string().min(1).optional()}).passthrough(),z$1.object({...bt,status:z$1.literal("error"),errors:z$1.array(z$1.object({code:z$1.string().min(1),message:z$1.string(),path:z$1.string().min(1).optional(),details:Dr.optional(),retryable:z$1.boolean().optional()}).strict()).min(1)}).passthrough()]),vt=z$1.object({applied:z$1.number().int().nonnegative(),noop:z$1.number().int().nonnegative(),failed:z$1.number().int().nonnegative()}),qr=z$1.object({type:z$1.literal("group"),chunkOrdinal:z$1.number().int().nonnegative(),eventRequestId:z$1.string().uuid(),requestDigest:Be,outcome:z$1.enum(["event","no_event"]),repoSeq:z$1.number().int().nonnegative().optional(),operations:vt,manifestDigest:Be}).passthrough(),Br=z$1.object({type:z$1.literal("summary"),submissionId:z$1.string().uuid(),streamId:z$1.string().min(1),groupSize:z$1.number().int().positive(),groups:z$1.number().int().nonnegative(),operations:vt.extend({total:z$1.number().int().nonnegative()}),repoSeq:z$1.object({first:z$1.number().int().nonnegative().nullable(),last:z$1.number().int().nonnegative().nullable()}),verdict:z$1.string().min(1),durationMs:z$1.number().nonnegative(),truncatedAt:z$1.object({lineNumber:z$1.number().int().positive(),message:z$1.string()}).optional(),manifest:z$1.object({groups:z$1.number().int().nonnegative(),digest:Be})}).passthrough(),Ur=z$1.object({type:z$1.literal("error"),code:z$1.string().min(1),message:z$1.string().optional()}).passthrough(),Vr=z$1.union([Mr,qr,Br,Ur]),qe=()=>({applied:0,noop:0,failed:0}),St=(r,e)=>r.applied===e.applied&&r.noop===e.noop&&r.failed===e.failed,Hr=new Set(["complete","operation-limit-reached","group-limit-reached"]),E=class extends Error{constructor(t,n){super(`Streaming submission protocol error at row ${n}: ${t}`);this.rowIndex=n;this.name="StreamingSubmissionProtocolError";}rowIndex};async function kt(r){let e=Nr.encode(r),t=await globalThis.crypto.subtle.digest("SHA-256",e);return `sha256:${Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}`}async function Fr(r,e,t){return kt(`${Ct}\0${r}\0${e}\0${t}`)}function Wr(r){return r.status==="failed"||r.status==="error"?"failed":r.status==="noop"||r.operation==="noop"?"noop":"applied"}var Ue=class{index=0;groupCount=0;resultCount=0;pendingCount=0;pendingCounts=qe();totalCounts=qe();firstRepoSeq=null;lastRepoSeq=null;manifestDigest=kt(Ct);terminalSeen=false;accept(e){let t=n=>{throw new E(n,this.index)};if(this.terminalSeen&&t("No row may follow the terminal row"),e.type==="result"){e.chunkOrdinal!==this.groupCount&&t(`Expected result chunkOrdinal ${this.groupCount}`),e.opIndex!==this.pendingCount&&t(`Expected result opIndex ${this.pendingCount}`),e.submissionIndex!==this.resultCount&&t(`Expected submissionIndex ${this.resultCount}`);let n=Wr(e);this.pendingCounts[n]+=1,this.totalCounts[n]+=1,this.pendingCount+=1,this.resultCount+=1,this.index+=1;return}if(e.type==="group")return e.chunkOrdinal!==this.groupCount&&t(`Expected group chunkOrdinal ${this.groupCount}`),this.pendingCount===0&&t("A group must close result rows"),St(this.pendingCounts,e.operations)||t("Group operation counters do not match its result rows"),this.acceptGroup(e,t);if(this.terminalSeen=true,this.pendingCount>0&&t("Terminal row cannot close a partial group"),e.type==="summary")return this.acceptSummary(e,t);this.index+=1;}async acceptGroup(e,t){this.manifestDigest=this.manifestDigest.then(n=>Fr(n,e.chunkOrdinal,e.requestDigest)),e.manifestDigest!==await this.manifestDigest&&t("Group manifest digest does not match the receipt chain"),e.repoSeq!==void 0&&(this.firstRepoSeq??=e.repoSeq,this.lastRepoSeq=e.repoSeq),this.groupCount+=1,this.pendingCount=0,this.pendingCounts=qe(),this.index+=1;}async acceptSummary(e,t){St(this.totalCounts,e.operations)||t("Summary operation counters do not match result rows"),(e.groups!==this.groupCount||e.manifest.groups!==this.groupCount)&&t("Summary group counters do not match group rows"),e.manifest.digest!==await this.manifestDigest&&t("Summary manifest digest does not match the receipt chain"),(e.repoSeq.first!==this.firstRepoSeq||e.repoSeq.last!==this.lastRepoSeq)&&t("Summary repo sequence does not match group rows"),(Hr.has(e.verdict)?e.operations.total!==this.resultCount:e.operations.total<this.resultCount)&&t("Summary total is incompatible with its verdict"),e.verdict==="truncated-by-parse-error"!=(e.truncatedAt!==void 0)&&t("truncatedAt must appear only for a parse-truncated verdict"),this.index+=1;}finish(){if(!this.terminalSeen)throw new E("Response must end with a summary or error row",this.index)}};function $r(r,e){let t;try{t=JSON.parse(r);}catch(i){throw new E(i instanceof Error?i.message:"Invalid JSON",e)}let n=Vr.safeParse(t);if(!n.success)throw new E(n.error.issues[0]?.message??"Malformed row",e);return n.data}async function*Et(r,e){let t=r.body?.getReader();if(!t)throw new E("Missing response body",0);let n=new Ue,i=new TextDecoder,o="",s=0,u=false,p,l=m=>{if(m.endsWith("\r")&&(m=m.slice(0,-1)),m.length===0)throw new E("Blank response row",s);let g=$r(m,s);return {pending:n.accept(g),row:g}},d=m=>{if(m.type==="summary"&&e!==void 0&&(m.submissionId!==e.submissionId||m.streamId!==e.streamId||m.groupSize!==e.groupSize))throw new E("Summary identity does not match the submission handle",s);s+=1;};try{for(;;){let{done:m,value:g}=await t.read();if(m)break;for(o+=i.decode(g,{stream:!0});;){let f=o.indexOf(`
|
|
3
|
-
`);if(f===-1)break;let C=o.slice(0,f);o=o.slice(f+1);let{pending:h,row:R}=l(C);h&&await h,d(R),R.type==="summary"||R.type==="error"?p=R:yield R;}}if(o+=i.decode(),o.length>0){let{pending:m,row:g}=l(o);m&&await m,d(g),g.type==="summary"||g.type==="error"?p=g:yield g;}n.finish(),u=!0,p&&(yield p);}finally{u||await t.cancel().catch(()=>{}),t.releaseLock();}}var T=class extends Error{code="STREAMING_SUBMISSION_OUTCOME_UNKNOWN";outcome="unknown";retryable=false;retryIdentity;cause;constructor(e,t){super(`Streaming submission outcome is unknown for ${e.submissionId}. Reconstruct the original source and copy every retryIdentity field into the next applyStreaming call.`),this.name="StreamingSubmissionOutcomeUnknownError",this.retryIdentity=e,this.cause=t;}};function le(r){return r===void 0||r===""?void 0:r}function Gr(){let r=globalThis;if(r.Bun!==void 0)return true;let e=r.process?.versions?.node;if(!e)return false;let[t=0,n=0]=e.split(".").map(Number);return t>22||t===22&&n>=2}function Kr(r){let e=new URLSearchParams({submissionId:r.submissionId,groupSize:String(r.groupSize)});return r.message!==void 0&&e.set("message",r.message),r.committer!==void 0&&e.set("committer",r.committer),`/api/repos/${encodeURIComponent(r.orgName)}/${encodeURIComponent(r.repoName)}/streams/${encodeURIComponent(r.streamId)}/submissions?${e}`}function zr(r){let e=ue(r,false),t=false,n=()=>{if(t)return;t=true;let o=e.returnSourceOnce();o&&Promise.resolve(o).catch(()=>{});};return {stream:new ReadableStream({async pull(o){try{let s=await e.next();if(t)return;if(s.done){o.close();return}o.enqueue(Me(s.value));}catch(s){o.error(s),n();}},cancel(){n();}}),returnSourceOnce:n}}function jr(r,e){if(!r)return ()=>{};let t=()=>e.abort(r.reason);return r.aborted?t():r.addEventListener("abort",t,{once:true}),()=>r.removeEventListener("abort",t)}function Yr(r){let e=r.options?.submissionId??M();return {orgName:r.orgName,repoName:r.repoName,streamId:r.options.streamId,submissionId:e,groupSize:pe(r.options.groupSize),...le(r.message)!==void 0?{message:le(r.message)}:{},...le(r.options?.committer)!==void 0?{committer:le(r.options?.committer)}:{}}}function xt(r,e){if(!r.options.streamId)throw e.localError("VALIDATION_ERROR","Streaming submissions require a non-empty streamId.");let t=Yr(r),n=new AbortController,i=()=>{},o,s=false,u=async function*(){let p=false,l=false,d;try{if(!(e.runtimeSupported??Gr)())throw e.localError("VALIDATION_ERROR","Streaming submissions require Bun or Node.js 22.2 or newer.");if(i=jr(r.options.signal,n),n.signal.aborted)throw e.localError("CANCELLED","Streaming submission was aborted.");let m=await e.prepare(Kr(t));if(n.signal.aborted)throw e.localError("CANCELLED","Streaming submission was aborted.");d=zr(r.operations),p=!0;let g=await m.dispatch(d.stream,n.signal);if(!g.ok)throw l=!0,await m.httpError(g);for await(let f of Et(g,t))yield f;}catch(m){throw m instanceof T?m:p&&!l?new T(t,m):e.normalizeLocalError(m)}finally{n.abort(),d?.returnSourceOnce(),i(),s=true;}};return {retryIdentity:t,[Symbol.asyncIterator](){return this},next(){return s?Promise.resolve({done:true,value:void 0}):(o??=u(),o.next())},async return(p){return n.abort(),o?o.return(p):(s=true,i(),{done:true,value:p})},async throw(p){if(n.abort(p),!o)throw s=true,i(),p;return o.throw(p)}}}var Qr="0.0.0-development";function B(r){return r===Qr}var Ve="0.97.0";var Tt=1;function Jr(r){return r===g?"Run: wh update --yes":r===f?"Run: npm install @warmhub/sdk-ts@latest (or your package manager's equivalent).":r===h?"Run: pip install --upgrade warmhub":`Deploy a released ${r} build that satisfies the backend compatibility contract.`}function Nt(r,e){if(typeof r?.minSupportedClients!="object"||r.minSupportedClients===null||!Number.isSafeInteger(r.writeContractVersion)||r.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=r.minSupportedClients[e.name],n=typeof t=="string"?u(t):null;if(!n)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(!B(e.version)){let i=u(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(v$1(i,n)<0)return {message:`${e.name} ${e.version} is older than the backend's minimum supported version ${n}.`,hint:Jr(e.name)}}if(r.writeContractVersion<Tt)return {message:`${e.name} requires write contract ${Tt}, but the backend provides ${r.writeContractVersion}.`,hint:"Upgrade the WarmHub backend before retrying this write."}}function He(r,e){try{return new URL(r).origin===new URL(e).origin}catch{return false}}var Xr=new Set(["GET","POST","PUT","PATCH","DELETE"]),A=class extends Error{reason;constructor(e,t){super(t),this.name="CliCallVerificationError",this.reason=e;}};async function Zr(r$1,e,t){let n$1=r$1.method.toUpperCase();if(!Xr.has(n$1))throw new A("unsupported-method",`Unsupported HTTP method "${r$1.method}" \u2014 component CLI dispatch only emits GET, POST, PUT, or PATCH`);let i=n$1,o$1=r$1.headers.get(n);if(!o$1)throw new A("missing-install-repo",`Missing ${n} header`);let s=U(e.CLI_SIGNING_SECRET),u=U(e.CLI_BEARER_TOKEN),p$1=U(e.CLI_API_KEY),l=U(e.CLI_BASIC_USERNAME)&&U(e.CLI_BASIC_PASSWORD);if(!s&&!u&&!p$1&&!l)throw new A("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(u&&l)throw new A("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 d=new URL(r$1.url),m=d.pathname,g,f,C;if(q$1(i)?g={}:(g=Object.fromEntries(d.searchParams.entries()),f="",C={...g}),s){let h=r$1.headers.get(o);if(!h)throw new A("missing-signature",`Missing ${o} header`);let R=r$1.headers.get(p);if(!R)throw new A("missing-timestamp",`Missing ${p} header`);let I=Number(R);if(!Number.isFinite(I)||!Number.isInteger(I))throw new A("invalid-timestamp",`${p} must be an integer unix seconds value; got "${R}"`);f=await _t(r$1,i,f);let S=await r({secret:e.CLI_SIGNING_SECRET,method:i,path:m,query:g,installRepo:o$1,body:f,signature:h,timestamp:I,nowUnixSeconds:t?.nowUnixSeconds??Math.floor(Date.now()/1e3),toleranceSec:t?.toleranceSec});if(!S.ok)throw new A(S.reason,`HMAC verification failed: ${S.reason}`)}if(u){let h=`Bearer ${e.CLI_BEARER_TOKEN}`,R=r$1.headers.get("authorization")??"";if(!await Fe(R,h))throw new A("invalid-bearer","invalid-bearer: bearer token mismatch")}if(p$1){let h=U(e.CLI_API_KEY_HEADER)?e.CLI_API_KEY_HEADER:"X-API-Key",R=r$1.headers.get(h)??"";if(!await Fe(R,e.CLI_API_KEY))throw new A("invalid-api-key",`invalid-api-key: mismatch on header "${h}"`)}if(l){let h=`Basic ${btoa(`${e.CLI_BASIC_USERNAME}:${e.CLI_BASIC_PASSWORD}`)}`,R=r$1.headers.get("authorization")??"";if(!await Fe(R,h))throw new A("invalid-basic","invalid-basic: basic auth mismatch")}return C===void 0&&(f=await _t(r$1,i,f),C=en(f)),{method:i,installRepo:o$1,args:C}}async function _t(r,e,t){return q$1(e)?t!==void 0?t:r.text():""}function en(r){let e;try{e=JSON.parse(r);}catch{throw new A("invalid-body","POST body is not valid JSON")}if(!tn(e))throw new A("invalid-body","POST body must be a JSON object of primitive args (string / number / boolean)");return e}function U(r){return typeof r=="string"&&r.length>0}function tn(r){if(typeof r!="object"||r===null||Array.isArray(r))return false;for(let e of Object.values(r))if(e!==void 0&&typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return false;return true}async function Fe(r,e){let[t,n]=await Promise.all([Pt(r),Pt(e)]),i=0;for(let o=0;o<t.length;o++)i|=t[o]^n[o];return i===0}async function Pt(r){return new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(r)))}function $e(r){if(r.includes("/"))return r.split("/")[0]}function Dt(r){if("shapeWref"in r&&typeof r.shapeWref=="string")return r.shapeWref;if(r.name)return $e(r.name)}function We(r){if(typeof r!="string")return;let e=r.trim();return e.length>0?e:void 0}function V(r){return m({kind:r.kind,name:r.name,about:ge(r),type:de(r),members:me(r)})}function ge(r){if("about"in r&&r.about!==void 0)return r.about;if("aboutWref"in r)return r.aboutWref}function Ge(r){return "data"in r?r.data:void 0}function de(r){return "type"in r?r.type:void 0}function me(r){return "members"in r?r.members:void 0}function Y(r,e){return m({kind:r.kind,name:e})}function Lt(r){return r.data??{}}function Mt(r){if(r.operation==="retract")return N(r);if(r.operation==="reaffirm")return N({operation:"reaffirm",name:r.name,...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.kind?{kind:r.kind}:{},...r.add?{add:[...r.add]}:{},...r.remove?{remove:[...r.remove]}:{},...r.leaseId?{leaseId:r.leaseId}:{}});if(r.operation==="add"){let n=V(r);if(n==="collection")return G(r,"OperationBuilder");let i=r,o=Lt(i),s=We(i.name);if(!s)throw new Error("OperationBuilder: add operation missing name");if(n==="assertion"){let u=ge(i);if(u===void 0)throw new Error(`OperationBuilder: assertion add '${s}' missing required 'about'`);if(typeof u!="string")throw new Error(B$1);return {operation:"add",kind:n,name:s,about:u,data:o,...i.affirmedTargets?{affirmedTargets:[...i.affirmedTargets]}:{},...i.skipExisting===true?{skipExisting:true}:{}}}return {operation:"add",kind:n,name:s,data:o,...i.skipExisting===true?{skipExisting:true}:{}}}let e=We(r.name)??We(r.wref);if(!e)throw new Error("OperationBuilder: revise operation missing required target ('name' or 'wref')");let t=Y(r,e);if(t==="collection")return ie({...r,name:e},"OperationBuilder");if(t==="assertion")return {operation:"revise",kind:t,name:e,data:r.data??{},...r.affirmedTargets?{affirmedTargets:[...r.affirmedTargets]}:{},...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.leaseId?{leaseId:r.leaseId}:{}};if(r.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:Lt(r),...r.expectedVersion!==void 0?{expectedVersion:r.expectedVersion}:{},...r.leaseId?{leaseId:r.leaseId}:{}}}function _(r,e){return r.operation==="add"?{operation:r.operation,kind:e,name:r.name,about:ge(r),type:de(r),members:me(r)}:{operation:r.operation,kind:e,name:r.name??r.wref,type:de(r),members:me(r)}}function qt(r){if(r.length!==0)throw new Error(r.join("; "))}function Bt(r,e,t,n){let i=[];if((e==="thing"||e==="assertion"||e==="collection"&&r==="REVISE")&&(l(t)||i.push(`${r} ${e} name must be a local path (Shape/name), got: "${t}"`)),e==="shape"&&(r==="ADD"||r==="REVISE")&&n!==void 0){let s=K(t,n,r==="REVISE"?"revise":"add");s&&i.push(s);}return i}function Ut(r,e){let t=[];if(r.name&&t.push(...Bt("ADD",e,r.name,Ge(r))),e==="assertion"&&ge(r)===void 0&&t.push(`ADD assertion '${r.name}' missing required 'about' \u2014 for hierarchical thing names set kind: 'thing' explicitly`),e!=="collection"&&(de(r)!==void 0||me(r)!==void 0)&&t.push(`ADD '${r.name}' has collection fields but inferred kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`),e!=="assertion"&&"affirmedTargets"in r&&r.affirmedTargets!==void 0&&t.push(`ADD '${r.name}' has affirmedTargets but inferred kind '${e}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`),e==="collection")try{G(r,"OperationBuilder");}catch(n){t.push(n instanceof Error?n.message:String(n));}for(let n of C(_(r,e),0))t.push(n.message);qt(t);}function Vt(r,e,t){let n=[];r!=="collection"&&t.data===void 0&&n.push(`OperationBuilder: ${r} revise requires 'data'`),r!=="assertion"&&t.affirmedTargets!==void 0&&n.push(`REVISE '${e}' has affirmedTargets but inferred kind '${r}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`),n.push(...Bt("REVISE",r,e,t.data),...C(_({...t,name:e},r),0).map(i=>i.message)),qt(n);}var he=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 n=Dt(t),i=Ge(t);if(this.shapes&&n&&i!==void 0){let p=this.shapes[n];if(p){let l=P(i,p);if(!l.valid)throw new Error(`Shape validation failed for '${t.name}' (shape: ${n}): ${l.errors.join("; ")}`)}}let o={operation:"add",...t},s=V(o);(o.name||s==="collection")&&Ut(o,s);let u=Object.freeze({operation:"add",...t});return this.ops.push(u),t.name&&(this.pendingNames.add(t.name),n&&this.wrefToShape.set(t.name,n)),this}revise(e){this.assertCanModify();let t={...e};delete t.operation;let n=t.name??t.wref;if(this.shapes&&n&&t.data!==void 0){let o=this.wrefToShape.get(n)??$e(n);if(o){let s=this.shapes[o];if(s){let u=P(t.data,s);if(!u.valid)throw new Error(`Shape validation failed for revise '${n}' (shape: ${o}): ${u.errors.join("; ")}`)}}}if(n){let o=Y({...t},n);Vt(o,n,{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=[],n=new Set,i=new Set;for(let p=0;p<this.ops.length;p+=1){let l=this.ops[p];if(l){if(l.operation==="add"){let d=V(l);!l.name&&d!=="collection"?e.push({code:"MISSING_NAME",operationIndex:p,message:`Add operation at index ${p} is missing required 'name' field`}):l.name&&(n.has(l.name)&&e.push({code:"DUPLICATE_NAME",operationIndex:p,message:`Duplicate name '${l.name}' at index ${p} (already added earlier in commit)`}),n.add(l.name));}if(l.operation==="revise"){let d=l.name??l.wref;d?i.has(d)?e.push({code:"REVISE_AFTER_RETRACT",operationIndex:p,message:`Revise at index ${p} targets '${d}' which was already retracted in this commit`}):n.has(d)||t.push({code:"REVISE_UNKNOWN_WREF",operationIndex:p,message:`Revise at index ${p} references '${d}' which was not added in this commit (assuming it exists server-side)`}):e.push({code:"MISSING_WREF",operationIndex:p,message:`Revise operation at index ${p} is missing required target ('name' or 'wref')`});}l.operation==="retract"&&(l.name?i.has(l.name)?t.push({code:"RETRACT_AFTER_RETRACT",operationIndex:p,message:`Retract at index ${p} targets '${l.name}' which was already retracted in this commit`}):(n.has(l.name)||t.push({code:"RETRACT_UNKNOWN_WREF",operationIndex:p,message:`Retract at index ${p} references '${l.name}' which was not added in this commit (assuming it exists server-side)`}),i.add(l.name)):e.push({code:"MISSING_NAME",operationIndex:p,message:`Retract operation at index ${p} is missing required 'name' field`}));}}let o=this.ops.flatMap((p,l)=>{if(p.operation==="add")return C(_(p,V(p)),l);if(p.operation==="revise"){let d=p.name??p.wref;return C(_(p,d?Y(p,d):"thing"),l)}return C({operation:"retract",kind:p.kind,name:p.name},l)});for(let p of o)e.push({code:p.code,operationIndex:p.operationIndex,message:p.message});let s=this.ops.flatMap((p,l)=>{if(p.operation==="retract"||p.operation==="reaffirm")return [];if(p.operation==="add")return [{op:_(p,V(p)),operationIndex:l}];let d=p.name??p.wref;return [{op:_(p,d?Y(p,d):"thing"),operationIndex:l}]}),u=D$1(s.map(({op:p})=>p),{checkAddAdd:false,sourceOperationIndexes:s.map(({operationIndex:p})=>p)});for(let p of u)e.push({code:p.code,operationIndex:p.operationIndex,message:p.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 n=t.errors.map(i=>i.message).join("; ");throw new Error(`OperationBuilder validation failed: ${n}`)}this.inFlight=true;try{let n=this.ops.map(o=>Mt(o)),i=await q(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:n});return this.submitted=!0,i}catch(n){throw n instanceof v&&(this.submitted=true),n}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 eo(r){return r.replace(/@(?:v\d+|HEAD|ALL)$/i,"")}var Zt=["apiUrl","fetch","accessToken","auth","functionLogs","client","clientFlags"],pn=new Set(Zt),ln=new Set(["token","apiKey","bearer"]);function dn(r){if(r)for(let e of Object.keys(r)){if(pn.has(e))continue;let t=ln.has(e)?'; did you mean "accessToken"?':`. Valid options are: ${Zt.join(", ")}.`;throw new TypeError(`Unknown WarmHubClient option "${e}"${t}`)}}function mn(r){if(!r||r.length===0)return [];for(let e of r)if(!c$1(e))throw new TypeError(`Invalid client flag "${e}": expected lowercase tokens matching [a-z0-9-]+.`);return [...new Set(r)].sort()}var Ke="https://api.warmhub.ai",gn=new Set(["commit.validate","repo.shapeInstanceCounts","thing.getMany","thing.headVersions"]),Ht=500,Ft=500,Wt=1,$t=8;function Re(r){return {...r,actionContainer:void 0,actionContainerConfig:void 0}}function hn(r){return r.map(e=>Re(e))}function er(r,e,t){if(e===r||t.has(e))throw new y("VALIDATION_ERROR","Paginated result cursor did not advance")}function Gt(r){if(r===void 0)throw new y("VALIDATION_ERROR","sinceRepoSeq is required for an incremental read")}async function*tr(r,e){let t=e,n=new Set;for(;;){t&&n.add(t);let i=await r(t);if(yield i,!i.nextCursor)return;er(t,i.nextCursor,n),t=i.nextCursor;}}async function*w(r,e,t){for await(let n of tr(r,t))yield*e(n);}async function O(r,e,t,n){if(t!==void 0&&(!Number.isFinite(t)||Math.trunc(t)!==t||t<0))throw new y("VALIDATION_ERROR","max must be a nonnegative integer");let i=[];for await(let o of tr(r,n)){let s=e(o);if(t!==void 0&&i.length+s.length>t)throw new y("VALIDATION_ERROR",`Paginated result exceeded max=${t}`);i.push(...s);}return i}function Kt(r){if(r?.slugs!==void 0)throw new y("VALIDATION_ERROR","repo.explore pagination helpers do not support slugs mode")}async function zt(r){let e=[],t,n=new Set;for(;;){t&&n.add(t);let i=await r(t);if(e.push(...i.items),!i.nextCursor){if(i.repoSeq===void 0)throw new y("VALIDATION_ERROR","Incremental read completed without repoSeq");return {items:e,repoSeq:i.repoSeq}}er(t,i.nextCursor,n),t=i.nextCursor;}}function ye(r,e,t){return Number.isFinite(r)?Math.max(1,Math.min(t,Math.trunc(r))):e}function jt(r,e){let t=[];for(let n=0;n<r.length;n+=e)t.push(r.slice(n,n+e));return t}function fe(r){return r!==void 0&&k.includes(r)?r:void 0}function Q(r){let[e,t,n]=r;return typeof e=="string"?{orgName:e,repoName:t,name:n}:e}function yn(r){let[e,t]=r;return typeof e=="string"?{orgName:e,repoName:t}:e}function fn(r){let[e,t,n,i]=r;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:n,credentialSetName:i}:e}function Rn(r){let[e,t,n]=r;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:n}:e}function bn(r){let{actionContainer:e,actionContainerConfig:t,...n}=r;return n}function Sn(r){let{actionContainer:e,actionContainerConfig:t,...n}=r;return n}function be(r){return !!r&&(!!r.shape||!!r.kind||!!r.about||!!r.match||!!r.componentRef||r.excludeComponents===true||(r.where?.length??0)>0)}function Se(r){return !!r&&(!!r.shape||!!r.about||!!r.match||!!r.componentRef||(r.where?.length??0)>0)}function rr(r){let e=r.members;return Array.isArray(e)&&e.length>0}function Cn(r){let t=r.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 wn(r,e){if(be(e.query)&&!Se(e.query))throw new y("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(e.sourceRepo&&!Se(e.query))throw new y("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(e.sourceRepo&&rr(e))throw new y("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(be(e.query)&&r!=="set")throw new y("VALIDATION_ERROR","Selector-backed collection sources are only supported for set collections")}function to(r){return r??"off"}function On(r){switch(r){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 In(r){if(r===void 0||r===408)return;if(r===405)return "NOT_FOUND";if(r===412)return "PRECONDITION_FAILED";if(r===422)return "VALIDATION_ERROR";let e=ir(r);return e!=="BACKEND"?e:r>=400&&r<500?"VALIDATION_ERROR":e}var An=[/\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 ze(r){for(let e of An)if(e.test(r))return "An internal error occurred. Please try again or contact support.";return r}var y=class extends Error{code;status;hint;retryAfter;errorCode;backendCode;details;constructor(e,t,n,i,o,s,u){super(t),this.name="WarmHubError",this.code=e,this.status=n,this.hint=i,this.retryAfter=o,this.errorCode=s,this.backendCode=s,this.details=u;}get kind(){return this.code}};function Yt(r,e){if(typeof e!="string")return;let t=y$1(r,e);if(t)throw new y("VALIDATION_ERROR",t)}function c(r){if(r instanceof y)return r;if(r instanceof TRPCClientError){if(r.cause instanceof y)return r.cause;let e=r.data,t=e?.warmhub?.code,n=typeof e?.code=="string"?On(e.code):void 0,i=In(e?.httpStatus),o=e?.warmhub?.message??ze(r.message);return new y(t??n??i??"BACKEND",o,e?.warmhub?.status??e?.httpStatus,e?.warmhub?.hint,e?.warmhub?.retryAfter??e?.retryAfter,t,e?.warmhub?.details)}if(r instanceof Error){let e=r;return r.name==="WarmHubError"&&typeof e.code=="string"?new y(e.code,ze(r.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):r.name==="AbortError"?new y("CANCELLED",r.message):r instanceof TypeError&&/fetch/i.test(r.message)?new y("NETWORK",r.message):new y("BACKEND",ze(r.message))}return new y("BACKEND","Unknown SDK error")}function vn(r){return r instanceof y}function ro(r){if(r instanceof T)return false;let e=c(r);return e.kind==="NETWORK"||e.kind==="CANCELLED"||e.kind==="BACKEND"||e.kind==="RATE_LIMITED"}var kn=new Set(["ConnectionRefused","ECONNREFUSED","ENOTFOUND","ETIMEDOUT","EAI_AGAIN"]);function En(r){if(r instanceof TypeError&&/fetch/i.test(r.message))return true;if(r&&typeof r=="object"){let e=r.code;if(typeof e=="string"&&kn.has(e))return true}return false}function xn(r){return `Unable to connect to ${r}. Is the computer able to access the url?`}function no(r,e){if(B(r))return false;let t=u(r),n=u(e);return !t||!n?false:v$1(t,n)<0}function nr(r,e){return new y("CLIENT_INCOMPATIBLE",r,412,e)}function Tn(r,e){let t=Nt(r,e);if(t)throw nr(t.message,t.hint)}var Qt=class r{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()):B(this.clientIdentity.version)&&He(this.apiUrl,Ke)?Promise.reject(nr(`Development client ${this.clientIdentity.name}/${this.clientIdentity.version} cannot write to production.`,"Install a released WarmHub client artifact before writing to api.warmhub.ai.")):B(this.clientIdentity.version)&&!He(this.apiUrl,Ke)?Promise.resolve():this.diagnostics.assertCompatible()}createCompatibilityLink(){return ()=>({op:e,next:t})=>e.type!=="mutation"||e.path==="commit.validate"?t(e):observable(n=>{let i=false,o;return this.assertWriteCompatible().then(()=>{i||(o=t(e).subscribe(n));}).catch(s=>{i||n.error(TRPCClientError.from(s));}),()=>{i=true,o?.unsubscribe();}})}auth={getClientId:async()=>{try{return await this.trpc.auth.getClientId.query()}catch(e){throw c(e)}},sync:async()=>{try{return await this.trpc.auth.sync.mutate()}catch(e){throw c(e)}},currentUser:async()=>{try{return await this.trpc.auth.currentUser.query()}catch(e){throw c(e)}},whoami:async()=>{try{return await this.trpc.auth.whoami.query()}catch(e){throw c(e)}}};homepage={featuredLists:async()=>{try{return await this.trpc.homepage.featuredLists.query()}catch(e){throw c(e)}}};access={resolve:async e=>{try{return await this.trpc.access.resolve.query(e)}catch(t){throw c(t)}}};diagnostics={ping:async()=>{let e=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/health`);if(!e.ok)throw new y("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 c(e)}},assertCompatible:()=>{if(this.compatibilityCheck)return this.compatibilityCheck;let e=(async()=>{let t=await this.diagnostics.capabilities();Tn(t,this.clientIdentity);})();return this.compatibilityCheck=e,e.catch(t=>{vn(t)&&t.code==="CLIENT_INCOMPATIBLE"||this.compatibilityCheck===e&&(this.compatibilityCheck=void 0);}),e}};component={list:async(e,t,n)=>{try{return await this.trpc.component.list.query({orgName:e,repoName:t,limit:n?.limit,cursor:n?.cursor})}catch(i){throw c(i)}},listIter:(e,t,n)=>w(i=>this.component.list(e,t,{...n,cursor:i}),i=>i.items,n?.cursor),listAll:async(e,t,n)=>{let{max:i,...o}=n??{};return await O(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(n){throw c(n)}},searchIter:(e,t)=>w(n=>this.component.search(e,{...t,cursor:n}),n=>n.items,t?.cursor),searchAll:async(e,t)=>{let{max:n,...i}=t??{};return await O(o=>this.component.search(e,{...i,cursor:o}),o=>o.items,n,i.cursor)},get:async(e,t,n)=>{try{return await this.trpc.component.get.query({orgName:e,repoName:t,componentRef:n})}catch(i){throw c(i)}},history:async(e,t,n)=>{try{return await this.trpc.component.history.query({orgName:e,repoName:t,componentRef:n?.componentRef,limit:n?.limit})}catch(i){throw c(i)}},install:async(e,t,n,i)=>{try{return await this.trpc.component.install.mutate({orgName:e,repoName:t,componentRef:n,submissionId:i.submissionId})}catch(o){throw c(o)}},uninstall:async(e,t,n,i)=>{try{return await this.trpc.component.uninstall.mutate({orgName:e,repoName:t,componentRef:n,submissionId:i.submissionId})}catch(o){throw c(o)}},registry:{register:async(e,t,n)=>{try{return await this.trpc.component.registry.register.mutate({orgName:e,componentName:t,...n})}catch(i){throw c(i)}},unregister:async(e,t)=>{try{return await this.trpc.component.registry.unregister.mutate({orgName:e,componentName:t})}catch(n){throw c(n)}},list:async e=>{try{return await this.trpc.component.registry.list.query({orgName:e})}catch(t){throw c(t)}},view:async(e,t)=>{try{return await this.trpc.component.registry.view.query({orgName:e,componentName:t})}catch(n){throw c(n)}},update:async(e,t,n)=>{try{return await this.trpc.component.registry.update.mutate({orgName:e,componentName:t,...n})}catch(i){throw c(i)}},resolve:async(e,t,n)=>await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/resolve`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({installRepo:n})}),setupCall:async(e,t,n)=>(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(n)}))},cli:{call:async(e,t,n,i)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cli/${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}))}};commit={validate:async(e,t,n,i)=>{try{return await this.trpc.commit.validate.mutate({orgName:e,repoName:t,committer:i?.committer,message:i?.message,componentRef:i?.componentRef,operations:ke(n,i?.skipExisting),includeWouldBeBody:i?.includeWouldBeBody},{signal:i?.signal})}catch(o){throw c(o)}},apply:async(e,t,n,i,o)=>{try{return await q(this,{orgName:e,repoName:t,committer:o?.committer,message:n,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 v||s instanceof x?s:c(s)}},applyStreaming:(e,t,n,i,o)=>xt({orgName:e,repoName:t,message:n,operations:i,options:o},{prepare:async s=>await this.prepareStreamingSubmissionRequest(s),localError:(s,u)=>new y(s,u),normalizeLocalError:c}),getReceipt:async(e,t,n)=>{try{return await this.trpc.commit.getReceipt.query({orgName:e,repoName:t,eventRequestId:n})}catch(i){throw c(i)}}};org={get:async e=>{try{return await this.trpc.org.get.query({orgName:e})}catch(t){throw c(t)}},getCallerRole:async e=>{try{return await this.trpc.org.getCallerRole.query({orgName:e})}catch(t){throw c(t)}},list:async e=>{try{return {items:await this.trpc.org.list.query({includeArchived:e?.includeArchived})}}catch(t){throw c(t)}},create:async(e,t,n)=>{try{return await this.trpc.org.create.mutate({name:e,displayName:t,description:n})}catch(i){throw c(i)}},setDescription:async(e,t)=>{try{return await this.trpc.org.setDescription.mutate({orgName:e,description:t})}catch(n){throw c(n)}},setDisplayName:async(e,t)=>{try{return await this.trpc.org.setDisplayName.mutate({orgName:e,displayName:t})}catch(n){throw c(n)}},rename:async(e,t)=>{try{return await this.trpc.org.rename.mutate({orgName:e,newName:t})}catch(n){throw c(n)}},update:async e=>{try{return await this.trpc.org.update.mutate(e)}catch(t){throw c(t)}},addMember:async(e,t,n="editor")=>{try{return await this.trpc.org.addMember.mutate({orgName:e,email:t,role:n})}catch(i){throw c(i)}},removeMember:async(e,t)=>{try{await this.trpc.org.removeMember.mutate({orgName:e,email:t});}catch(n){throw c(n)}},leave:async e=>{try{await this.trpc.org.leave.mutate({orgName:e});}catch(t){throw c(t)}},changeMemberRole:async(e,t,n)=>{try{return await this.trpc.org.changeMemberRole.mutate({orgName:e,email:t,role:n})}catch(i){throw c(i)}},setMemberScopes:async(e,t,n)=>{try{await this.trpc.org.setMemberScopes.mutate({orgName:e,email:t,scopes:n});}catch(i){throw c(i)}},clearMemberScopes:async(e,t)=>{try{await this.trpc.org.clearMemberScopes.mutate({orgName:e,email:t});}catch(n){throw c(n)}},listMembers:async(e,t)=>{try{return await this.trpc.org.listMembers.query({orgName:e,pending:t?.pending})}catch(n){throw c(n)}},archive:async e=>{try{return await this.trpc.org.archive.mutate({orgName:e})}catch(t){throw c(t)}},unarchive:async e=>{try{return await this.trpc.org.unarchive.mutate({orgName:e})}catch(t){throw c(t)}}};repo={checkpoint:ut(()=>this.trpc,c),get:async(e,t)=>{try{return await this.trpc.repo.get.query({orgName:e,repoName:t})}catch(n){throw c(n)}},getStats:async(e,t)=>{try{return await this.trpc.repo.stats.query({orgName:e,repoName:t})}catch(n){throw c(n)}},getStatsBatch:async(e,t)=>{try{return await this.trpc.repo.statsBatch.query({orgName:e,repoNames:t})}catch(n){throw c(n)}},getConfigureStats:async(e,t)=>{try{return await this.trpc.repo.configureStats.query({orgName:e,repoName:t})}catch(n){throw c(n)}},getShapeInstanceCounts:async(e,t)=>{try{return await this.trpc.repo.shapeInstanceCounts.query({orgName:e,repoName:t})}catch(n){throw c(n)}},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(n){throw c(n)}},listIter:(e,t)=>w(n=>this.repo.list(e,{...t,cursor:n}),n=>n.items,t?.cursor),listAll:async(e,t)=>{let{max:n,...i}=t??{};return await O(o=>this.repo.list(e,{...i,cursor:o}),o=>o.items,n,i.cursor)},search:async(e,t)=>{try{return await this.trpc.repo.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(n){throw c(n)}},searchIter:(e,t)=>w(n=>this.repo.search(e,{...t,cursor:n}),n=>n.items,t?.cursor),searchAll:async(e,t)=>{let{max:n,...i}=t??{};return await O(o=>this.repo.search(e,{...i,cursor:o}),o=>o.items,n,i.cursor)},create:async(e,t,n,i,o)=>{try{return await this.trpc.repo.create.mutate({orgName:e,repoName:t,description:n,visibility:i,displayName:o})}catch(s){throw c(s)}},setDescription:async(e,t,n)=>{try{return await this.trpc.repo.setDescription.mutate({orgName:e,repoName:t,description:n})}catch(i){throw c(i)}},setDisplayName:async(e,t,n)=>{try{return await this.trpc.repo.setDisplayName.mutate({orgName:e,repoName:t,displayName:n})}catch(i){throw c(i)}},setVisibility:async(e,t,n)=>{try{return await this.trpc.repo.setVisibility.mutate({orgName:e,repoName:t,visibility:n})}catch(i){throw c(i)}},rename:async(e,t,n)=>{try{return await this.trpc.repo.rename.mutate({orgName:e,repoName:t,newName:n})}catch(i){throw c(i)}},update:async e=>{try{return await this.trpc.repo.update.mutate(e)}catch(t){throw c(t)}},archive:async(e,t)=>{try{return await this.trpc.repo.archive.mutate({orgName:e,repoName:t})}catch(n){throw c(n)}},unarchive:async(e,t)=>{try{return await this.trpc.repo.unarchive.mutate({orgName:e,repoName:t})}catch(n){throw c(n)}},delete:async(e,t)=>{try{let n=await this.trpc.repo.delete.mutate({orgName:e,repoName:t});return {graceExpiresAt:new Date(n.graceExpiresAt)}}catch(n){throw c(n)}},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(n){throw c(n)}},listPageIter:(e,t)=>w(n=>this.repo.listPage(e,{...t,cursor:n}),n=>n.items,t?.cursor),listPageAll:async(e,t)=>{let{max:n,...i}=t??{};return await O(o=>this.repo.listPage(e,{...i,cursor:o}),o=>o.items,n,i.cursor)},listForCaller:async e=>{try{return await this.trpc.repo.listForCaller.query({limit:e?.limit,sort:e?.sort})}catch(t){throw c(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 c(t)}},exploreIter:e=>(Kt(e),w(t=>this.repo.explore({...e,cursor:t}),t=>t.items,e?.cursor)),exploreAll:async e=>{Kt(e);let{max:t,...n}=e??{};return await O(i=>this.repo.explore({...n,cursor:i}),i=>i.items,t,n.cursor)},getReadme:async(e,t)=>{try{return await this.trpc.repo.getReadme.query({orgName:e,repoName:t})}catch(n){throw c(n)}},getAgents:async(e,t)=>{try{return await this.trpc.repo.getAgents.query({orgName:e,repoName:t})}catch(n){throw c(n)}},getLicense:async(e,t)=>{try{return await this.trpc.repo.getLicense.query({orgName:e,repoName:t})}catch(n){throw c(n)}},describe:async(e,t)=>{try{return await this.trpc.repo.describe.query({orgName:e,repoName:t})}catch(n){throw c(n)}},setReadme:async(e,t,n,i)=>{try{return Yt("Content/Readme.content",n),await this.trpc.repo.setReadme.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:n})}catch(o){throw c(o)}},setAgents:async(e,t,n,i)=>{try{return Yt("Content/Agents.content",n),await this.trpc.repo.setAgents.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:n})}catch(o){throw c(o)}},getLlmsTxt:async(e,t)=>{try{return await this.trpc.repo.getLlmsTxt.query({orgName:e,repoName:t})}catch(n){throw c(n)}},index:{describe:async(e,t)=>{try{return await this.trpc.repo.index.describe.query({orgName:e,repoName:t})}catch(n){throw c(n)}}}};shape={list:async(e,t,n)=>{try{return await this.trpc.shape.list.query({orgName:e,repoName:t,match:n?.match,componentRef:n?.componentRef,excludeComponents:n?.excludeComponents,includeRetracted:n?.includeRetracted})}catch(i){throw c(i)}},get:async(e,t,n,i)=>{try{return await this.trpc.shape.get.query({orgName:e,repoName:t,shapeName:n,includeRetracted:i?.includeRetracted})}catch(o){throw c(o)}},create:async(e,t,n,i,o)=>{let s=K(n,{fields:i,...o.description!==void 0?{description:o.description}:{}},"add");if(s)throw new y("VALIDATION_ERROR",s);try{return await this.trpc.shape.create.mutate({orgName:e,repoName:t,shapeName:n,fields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(u){throw c(u)}},revise:async(e,t,n,i,o)=>{let s=K(n,{fields:i,...o.description!==void 0?{description:o.description}:{}},"revise");if(s)throw new y("VALIDATION_ERROR",s);try{return await this.trpc.shape.revise.mutate({orgName:e,repoName:t,shapeName:n,newFields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(u){throw c(u)}},remove:async(e,t,n,i)=>{try{return await this.trpc.shape.remove.mutate({orgName:e,repoName:t,shapeName:n,eventRequestId:i.eventRequestId})}catch(o){throw c(o)}},rename:async(e,t,n,i,o)=>{try{return await this.trpc.shape.rename.mutate({orgName:e,repoName:t,oldName:n,newName:i,eventRequestId:o.eventRequestId})}catch(s){throw c(s)}},history:async(e,t,n,i={})=>{try{return await this.trpc.shape.history.query({orgName:e,repoName:t,name:n,includeRetracted:i.includeRetracted,limit:i.limit,cursor:i.cursor})}catch(o){throw c(o)}},historyIter:(e,t,n,i={})=>w(o=>this.shape.history(e,t,n,{...i,cursor:o}),o=>o.versions,i.cursor),historyAll:async(e,t,n,i)=>{let{max:o,...s}=i??{};return await O(u=>this.shape.history(e,t,n,{...s,cursor:u}),u=>u.versions,o,s.cursor)}};subscription={create:async e=>{try{let t=await this.trpc.subscription.create.mutate(bn(e));return Re(t)}catch(t){throw c(t)}},get:async(...e)=>{try{let t=await this.trpc.subscription.get.query(Q(e));return Re(t)}catch(t){throw c(t)}},reveal:async(...e)=>{try{return await this.trpc.subscription.reveal.query(Q(e))}catch(t){throw c(t)}},list:async(...e)=>{try{let t=await this.trpc.subscription.list.query(yn(e));return hn(t)}catch(t){throw c(t)}},update:async e=>{try{let t=await this.trpc.subscription.update.mutate(Sn(e));return Re(t)}catch(t){throw c(t)}},pause:async(...e)=>{try{return await this.trpc.subscription.pause.mutate(Q(e))}catch(t){throw c(t)}},resume:async(...e)=>{try{return await this.trpc.subscription.resume.mutate(Q(e))}catch(t){throw c(t)}},remove:async(...e)=>{try{return await this.trpc.subscription.remove.mutate(Q(e))}catch(t){throw c(t)}},bindCredentials:async(...e)=>{try{return await this.trpc.subscription.bindCredentials.mutate(fn(e))}catch(t){throw c(t)}},unbindCredentials:async(...e)=>{try{return await this.trpc.subscription.unbindCredentials.mutate(Rn(e))}catch(t){throw c(t)}}};action={acquireLease:async(e,t,n,i,o,s)=>{try{return await this.trpc.action.acquireLease.mutate({orgName:e,repoName:t,subscriptionName:n,holderId:i,holderType:o,graceMs:s?.graceMs,ttlMs:s?.ttlMs})}catch(u){throw c(u)}},heartbeatLease:async(e,t,n,i,o)=>{try{return await this.trpc.action.heartbeatLease.mutate({orgName:e,repoName:t,subscriptionName:n,holderId:i,ttlMs:o})}catch(s){throw c(s)}},releaseLease:async(e,t,n,i)=>{try{return await this.trpc.action.releaseLease.mutate({orgName:e,repoName:t,subscriptionName:n,holderId:i})}catch(o){throw c(o)}},claimDelivery:async(e,t,n,i)=>{let o=typeof n=="string"?{runId:n}:n;try{return await this.trpc.action.claimDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw c(s)}},completeDelivery:async(e,t,n,i)=>{let o=typeof n=="string"?{runId:n}:n;try{return await this.trpc.action.completeDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw c(s)}},liveFeed:async(e,t,n,i)=>{try{return await this.trpc.action.liveFeed.query({orgName:e,repoName:t,subscriptionName:n,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},liveFeedIter:(e,t,n,i)=>w(o=>this.action.liveFeed(e,t,n,{...i,cursor:o}),o=>o.items,i?.cursor),liveFeedAll:async(e,t,n,i)=>{let{max:o,...s}=i??{};return await O(u=>this.action.liveFeed(e,t,n,{...s,cursor:u}),u=>u.items,o,s.cursor)},listRuns:async(e,t,n)=>{try{return await this.trpc.action.listRuns.query({orgName:e,repoName:t,runId:n?.runId,subscriptionName:n?.subscriptionName,status:n?.status,outcome:n?.outcome,since:n?.since,cursor:n?.cursor,limit:n?.limit})}catch(i){throw c(i)}},listRunsIter:(e,t,n)=>w(i=>this.action.listRuns(e,t,{...n,since:i===void 0?n?.since:void 0,cursor:i}),i=>i.items,n?.cursor),listRunsAll:async(e,t,n)=>{let{max:i,...o}=n??{};return await O(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(n){throw c(n)}},runStats:async(e,t,n)=>{try{return await this.trpc.action.runStats.query({orgName:e,repoName:t,subscriptionName:n?.subscriptionName,since:n?.since})}catch(i){throw c(i)}},getRunAttempts:async(e,t,n)=>{try{return await this.trpc.action.getRunAttempts.query({orgName:e,repoName:t,runId:n})}catch(i){throw c(i)}},listNotifications:async(e,t,n)=>{try{return await this.trpc.action.listNotifications.query({orgName:e,repoName:t,since:n?.since,limit:n?.limit})}catch(i){throw c(i)}}};collection={create:async(e,t,n)=>{try{return wn(n.type,n),await this.trpc.collection.create.mutate({orgName:e,repoName:t,eventRequestId:n.eventRequestId,type:n.type,name:n.name,members:n.members,from:n.from,add:n.add,remove:n.remove,replaceMembers:n.replaceMembers,query:n.query,sourceOrgName:n.sourceRepo?.orgName,sourceRepoName:n.sourceRepo?.repoName,skipExisting:n.skipExisting,message:n.message,committer:n.committer})}catch(i){throw c(i)}},members:async(e,t,n,i)=>{try{return await this.trpc.collection.members.query({orgName:e,repoName:t,wref:n,version:i?.version,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},membersIter:(e,t,n,i)=>{let o=i?.version;return w(async s=>{let u=await this.collection.members(e,t,n,{...i,version:o,cursor:s});return o??=u.version,u},s=>s.items,i?.cursor)},membersAll:async(e,t,n,i)=>{let{max:o,...s}=i??{},u=s.version;return await O(async p=>{let l=await this.collection.members(e,t,n,{...s,version:u,cursor:p});return u??=l.version,l},p=>p.items,o,s.cursor)},contains:async(e,t,n,i,o)=>{try{return await this.trpc.collection.contains.query({orgName:e,repoName:t,wref:n,version:o?.version,members:i,position:o?.position})}catch(s){throw c(s)}},diff:async(e,t,n,i,o)=>{try{return await this.trpc.collection.diff.query({orgName:e,repoName:t,leftWref:n,rightWref:i,leftVersion:o?.leftVersion,rightVersion:o?.rightVersion,mode:o?.mode})}catch(s){throw c(s)}},revise:async(e,t,n,i)=>{try{let o=Cn(n);if(be(i.query)&&!Se(i.query))throw new y("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(i.sourceRepo&&!Se(i.query))throw new y("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(i.sourceRepo&&rr(i))throw new y("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(be(i.query)&&o&&o!=="set")throw new y("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:n,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 c(o)}},stats:async(e,t,n,i)=>{try{return await this.trpc.collection.stats.query({orgName:e,repoName:t,wref:n,version:i?.version})}catch(o){throw c(o)}}};view={evaluate:async(e,t,n,i)=>{try{return await this.trpc.view.evaluate.query({orgName:e,repoName:t,wref:n,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},evaluateIter:(e,t,n,i)=>w(o=>this.view.evaluate(e,t,n,{...i,cursor:o}),o=>o.items,i?.cursor),evaluateAll:async(e,t,n,i)=>{let{max:o,...s}=i??{};return await O(u=>this.view.evaluate(e,t,n,{...s,cursor:u}),u=>u.items,o,s.cursor)}};grant=at(()=>this.trpc,c);thing={head:async(e,t,n)=>{try{return await this.trpc.thing.head.query({orgName:e,repoName:t,shape:n?.shape,kind:fe(n?.kind),match:n?.match,dataMode:n?.dataMode,includeRetracted:n?.includeRetracted,limit:n?.limit,cursor:n?.cursor,componentRef:n?.componentRef,excludeComponents:n?.excludeComponents,excludeInfraShapes:n?.excludeInfraShapes,where:n?.where,sinceRepoSeq:n?.sinceRepoSeq})}catch(i){throw c(i)}},headIter:(e,t,n)=>w(i=>this.thing.head(e,t,{...n,cursor:i}),i=>i.items,n?.cursor),headAll:async(e,t,n)=>{let{max:i,...o}=n??{};return await O(s=>this.thing.head(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},headChanges:async(e,t,n)=>(Gt(n?.sinceRepoSeq),await zt(i=>this.thing.head(e,t,{...n,includeRetracted:true,cursor:i}))),get:async(e,t,n,i,o)=>{try{return await this.trpc.thing.get.query({orgName:e,repoName:t,wref:n,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode})}catch(s){throw c(s)}},getWithLease:async(e,t,n,i)=>{try{return await this.trpc.thing.getWithLease.mutate({orgName:e,repoName:t,wref:n,ttlMs:i?.ttlMs})}catch(o){throw c(o)}},releaseLease:async(e,t,n,i)=>{try{await this.trpc.thing.releaseLease.mutate({orgName:e,repoName:t,wref:n,leaseId:i});}catch(o){throw c(o)}},graph:async(e,t,n,i)=>{try{return await this.trpc.thing.graph.query({orgName:e,repoName:t,wref:n,version:i?.version,depth:i?.depth,limit:i?.limit})}catch(o){throw c(o)}},getMany:async(e,t,n,i,o)=>{try{if(n.length===0)return {requested:0,items:[],missing:[]};let s=ye(o?.chunkSize,Ht,Ft),u=ye(o?.chunkConcurrency,Wt,$t),p=async m=>await this.trpc.thing.getMany.query({orgName:e,repoName:t,wrefs:m,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode});if(n.length<=s)return await p(n);let l=jt(n,s),d=[];for(let m=0;m<l.length;m+=u){let g=l.slice(m,m+u),f=await Promise.all(g.map(p));d.push(...f);}return {requested:n.length,items:d.flatMap(m=>m.items),missing:d.flatMap(m=>m.missing)}}catch(s){throw c(s)}},headVersions:async(e,t,n,i)=>{try{if(n.length===0)return {requested:0,items:[],missing:[]};let o=ye(i?.chunkSize,Ht,Ft),s=ye(i?.chunkConcurrency,Wt,$t),u=async d=>await this.trpc.thing.headVersions.query({orgName:e,repoName:t,wrefs:d});if(n.length<=o)return await u(n);let p=jt(n,o),l=[];for(let d=0;d<p.length;d+=s){let m=p.slice(d,d+s),g=await Promise.all(m.map(u));l.push(...g);}return {requested:n.length,items:l.flatMap(d=>d.items),missing:l.flatMap(d=>d.missing)}}catch(o){throw c(o)}},history:async(e,t,n)=>{try{return await this.trpc.thing.history.query({orgName:e,repoName:t,wref:n.wref,shape:n.shape,about:n.about,includeRetracted:n.includeRetracted,resolveCollections:n.resolveCollections,match:n.match,limit:n.limit,cursor:n.cursor})}catch(i){throw c(i)}},historyIter:(e,t,n)=>w(i=>this.thing.history(e,t,{...n,cursor:i}),i=>i.versions,n.cursor),historyAll:async(e,t,n)=>{let{max:i,...o}=n;return await O(s=>this.thing.history(e,t,{...o,cursor:s}),s=>s.versions,i,o.cursor)},rename:async(e,t,n,i,o,s)=>{try{return await this.trpc.thing.rename.mutate({orgName:e,repoName:t,shapeName:n,oldName:i,newName:o,eventRequestId:s.eventRequestId})}catch(u){throw c(u)}},resolve:async(e,t,n)=>{try{return await this.trpc.thing.resolve.query({orgName:e,repoName:t,wref:n})}catch(i){throw c(i)}},about:async(e,t,n,i)=>{try{return await this.trpc.thing.about.query({orgName:e,repoName:t,wref:n,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 c(o)}},aboutIter:(e,t,n,i)=>w(o=>this.thing.about(e,t,n,{...i,cursor:o}),o=>o.assertions,i?.cursor),aboutAll:async(e,t,n,i)=>{let{max:o,...s}=i??{};return await O(u=>this.thing.about(e,t,n,{...s,cursor:u}),u=>u.assertions,o,s.cursor)},query:async(e,t,n)=>{try{return await this.trpc.thing.query.query({orgName:e,repoName:t,shape:n?.shape,about:n?.about,affirmedAbout:n?.affirmedAbout,kind:fe(n?.kind),match:n?.match,includeRetracted:n?.includeRetracted,resolveCollections:n?.resolveCollections,role:n?.role,limit:n?.limit,cursor:n?.cursor,componentRef:n?.componentRef,excludeComponents:n?.excludeComponents,excludeInfraShapes:n?.excludeInfraShapes,where:n?.where,sinceRepoSeq:n?.sinceRepoSeq})}catch(i){throw c(i)}},queryIter:(e,t,n)=>w(i=>this.thing.query(e,t,{...n,cursor:i}),i=>i.items,n?.cursor),queryAll:async(e,t,n)=>{let{max:i,...o}=n??{};return await O(s=>this.thing.query(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},queryChanges:async(e,t,n)=>(Gt(n?.sinceRepoSeq),await zt(i=>this.thing.query(e,t,{...n,includeRetracted:true,cursor:i}))),search:async(e,t,n,i)=>{try{return await this.trpc.thing.search.query({orgName:e,repoName:t,query:n,shape:i?.shape,about:i?.about,affirmedAbout:i?.affirmedAbout,kind:fe(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 c(o)}},searchIter:(e,t,n,i)=>w(o=>this.thing.search(e,t,n,{...i,cursor:o}),o=>o.items,i?.cursor),searchAll:async(e,t,n,i)=>{let{max:o,...s}=i??{};return await O(u=>this.thing.search(e,t,n,{...s,cursor:u}),u=>u.items,o,s.cursor)},count:async(e,t,n)=>{try{return await this.trpc.thing.count.query({orgName:e,repoName:t,shape:n?.shape,about:n?.about,affirmedAbout:n?.affirmedAbout,kind:fe(n?.kind),match:n?.match,includeRetracted:n?.includeRetracted,resolveCollections:n?.resolveCollections,componentRef:n?.componentRef,excludeComponents:n?.excludeComponents,excludeInfraShapes:n?.excludeInfraShapes,where:n?.where,sinceRepoSeq:n?.sinceRepoSeq})}catch(i){throw c(i)}},refs:async(e,t,n,i)=>{try{return await this.trpc.thing.refs.query({orgName:e,repoName:t,wref:n,direction:i?.direction,fieldPath:i?.fieldPath,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},refsIter:(e,t,n,i)=>w(o=>this.thing.refs(e,t,n,{...i,cursor:o}),o=>o.items,i?.cursor),refsAll:async(e,t,n,i)=>{let{max:o,...s}=i??{};return await O(u=>this.thing.refs(e,t,n,{...s,cursor:u}),u=>u.items,o,s.cursor)}};live={thingHead:async(e,t,n,i)=>this.watchRepoQuery(e,t,n?.signal,()=>this.thing.head(e,t,{shape:n?.shape,kind:n?.kind,match:n?.match,dataMode:n?.dataMode,limit:n?.limit,cursor:n?.cursor,includeRetracted:n?.includeRetracted,where:n?.where}),i),thingHistory:async(e,t,n,i)=>this.watchRepoQuery(e,t,n.signal,()=>this.thing.history(e,t,{wref:n.wref,limit:n.limit,cursor:n.cursor,includeRetracted:n.includeRetracted}),i),subscriptionLog:async(e,t,n,i,o)=>this.watchRepoQuery(e,t,i?.signal,()=>this.action.liveFeed(e,t,n,{limit:i?.limit,cursor:i?.cursor}),o),subscribe:async(e,t,n,i)=>{let o=new AbortController,s=Jt(n?.signal,o),u=0,p=(async()=>{let l=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),d=await this.openSse(l.ticket,s,async m=>{if(m.type!=="invalidate")return;let g=m.data;u++,await i({topic:g.topic,affectedShapes:g.affectedShapes,affectedThings:g.affectedThings,affectedTargets:g.affectedTargets,hasNewCommit:g.hasNewCommit});});return await d.ready,s.aborted?{updates:u}:(await d.closed,{updates:u})})();return {close(){o.abort();},closed:p}}};token={create:async e=>{try{return await this.trpc.token.create.mutate(e)}catch(t){throw c(t)}},list:async e=>{try{return await this.trpc.token.list.query(e?.includeInactive?{includeInactive:!0}:void 0)}catch(t){throw c(t)}},get:async e=>{try{return await this.trpc.token.get.query({name:e})}catch(t){throw c(t)}},revoke:async e=>{try{return await this.trpc.token.revoke.mutate({name:e})}catch(t){throw c(t)}}};stream={append:async e=>{try{return await this.trpc.stream.append.mutate(e)}catch(t){throw c(t)}}};credential={createSet:async(e,t,n,i)=>{try{return await this.trpc.credential.createSet.mutate({orgName:e,repoName:t,name:n,scope:i?.scope??"repo",description:i?.description})}catch(o){throw c(o)}},listSets:async(e,t)=>{try{return await this.trpc.credential.listSets.query({orgName:e,repoName:t})}catch(n){throw c(n)}},getSet:async(e,t,n)=>{try{return await this.trpc.credential.getSet.query({orgName:e,repoName:t,name:n})}catch(i){throw c(i)}},setKey:async(e,t,n,i,o)=>{try{return await this.trpc.credential.setKey.mutate({orgName:e,repoName:t,setName:n,keyName:i,value:o})}catch(s){throw c(s)}},setKeys:async(e,t,n,i)=>{try{return await this.trpc.credential.setKeys.mutate({orgName:e,repoName:t,setName:n,secrets:i})}catch(o){throw c(o)}},unsetKey:async(e,t,n,i)=>{try{return await this.trpc.credential.unsetKey.mutate({orgName:e,repoName:t,setName:n,keyName:i})}catch(o){throw c(o)}},deleteSet:async(e,t,n)=>{try{return await this.trpc.credential.deleteSet.mutate({orgName:e,repoName:t,setName:n})}catch(i){throw c(i)}},listAuditLog:async(e,t,n,i)=>{try{return await this.trpc.credential.listAuditLog.query({orgName:e,repoName:t,setName:n,limit:i?.limit})}catch(o){throw c(o)}},revokeSet:async(e,t,n,i)=>{try{return await this.trpc.credential.revokeSet.mutate({orgName:e,repoName:t,setName:n,reason:i?.reason})}catch(o){throw c(o)}}};credentials=this.credential;constructor(e,t){let n=typeof e=="string"?t:e;dn(n);let i=typeof e=="string"?e:e?.apiUrl??Ke;if(this.apiUrl=i,this.fetchImpl=n?.fetch,this.accessToken=n?.accessToken??n?.auth?.getToken,this.functionLogMode=n?.functionLogs??"off",this.clientIdentity={name:n?.client?.name??f,version:n?.client?.version??Ve},this.clientFlags=mn(n?.clientFlags),typeof this.accessToken=="function"){let u=this.accessToken;this.getToken=async()=>await u();}else if(this.accessToken){let u=this.accessToken;this.getToken=async()=>u;}let o=`${i.replace(/\/$/,"")}/trpc`,s=((u,p)=>this.fetchWithAuth(u,p));Object.defineProperty(this,"trpc",{value:createTRPCProxyClient({links:[this.createCompatibilityLink(),splitLink({condition:u=>gn.has(u.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 r({apiUrl:this.apiUrl,fetch:this.fetchImpl,accessToken:e,client:this.clientIdentity,clientFlags:this.clientFlags})}actions=this.action;async openSse(e,t,n){let i=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/sse?ticket=${encodeURIComponent(e)}`,{headers:{accept:"text/event-stream"},signal:t});if(!i.ok)throw new y("BACKEND",`SSE request failed with status ${i.status}`,i.status);let o=i.body?.getReader();if(!o)throw new y("BACKEND","SSE response body is missing");let s=()=>{},u=new Promise(l=>{s=l;}),p=(async()=>{let l=new TextDecoder,d="";try{for(;;){let{done:m,value:g}=await o.read();if(m)break;for(d+=l.decode(g,{stream:!0}).replaceAll(`\r
|
|
4
|
-
`,`
|
|
5
|
-
`);;){let f=d.indexOf(`
|
|
6
|
-
|
|
7
|
-
`);if(f===-1)break;let C=d.slice(0,f);d=d.slice(f+2);let h=Nn(C);if(h){if(h.type==="ready"){s();continue}await n(h);}}}}catch(m){if(_n(m)||t.aborted)return;throw m}finally{s(),o.releaseLock();}})();return {ready:u,closed:p}}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)&&e$1.set(a,d(this.clientFlags));}async fetchWithAuth(e,t){let n=this.fetchImpl??globalThis.fetch,i=new Headers(t?.headers),o=await je(this.accessToken);o&&i.set("authorization",`Bearer ${o}`),this.applyClientHeader(i);let s=async p=>{try{return await n(e,p)}catch(l){throw En(l)?new y("NETWORK",xn(this.apiUrl)):l}},u=await s({...t,headers:i});if(u.status===401&&typeof this.accessToken=="function"){let p=await je(this.accessToken);if(p&&p!==o){let l=new Headers(t?.headers);return l.set("authorization",`Bearer ${p}`),this.applyClientHeader(l),s({...t,headers:l})}}return u}async requestResponse(e,t){let n=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}${e}`,t);if(!n.ok)throw await this.httpResponseError(n);return n}async prepareStreamingSubmissionRequest(e){let t=this.fetchImpl??globalThis.fetch,n=new Headers({accept:"application/x-ndjson","content-type":"application/x-ndjson"}),i=await je(this.accessToken);i&&n.set("authorization",`Bearer ${i}`),this.applyClientHeader(n);let o=`${this.apiUrl.replace(/\/$/,"")}${e}`;return {dispatch:async(s,u)=>await t(o,{method:"POST",headers:n,body:s,signal:u,duplex:"half"}),httpError:async s=>await this.httpResponseError(s)}}async httpResponseError(e){let t=`Request failed with status ${e.status}`,n=ir(e.status),i,o,s;try{let u=await e.json();typeof u.error?.message=="string"&&(t=u.error.message),typeof u.error?.code=="string"&&(n=u.error.code,i=u.error.code),typeof u.error?.hint=="string"&&(o=u.error.hint),typeof u.error?.retryAfter=="number"&&(s=u.error.retryAfter);}catch{}return new y(n,t,e.status,o,s,i)}async requestJson(e,t){return await(await this.requestResponse(e,t)).json()}async watchRepoQuery(e,t,n,i,o){let s=new AbortController,u=Jt(n,s),p=0,l=(async()=>{let d=async()=>{let f=await i();p+=1,await o(f);},m=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),g=await this.openSse(m.ticket,u,async f=>{f.type==="invalidate"&&await d();});return await g.ready,u.aborted?{updates:p}:(await d(),await g.closed,{updates:p})})();return {close(){s.abort();},closed:l}}};function ir(r){switch(r){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 je(r){if(r)return typeof r=="string"?r:r()}function Jt(r,e){return r?r.aborted?(e.abort(),e.signal):(r.addEventListener("abort",()=>e.abort(),{once:true}),e.signal):e.signal}function Nn(r){let e="message",t=[];for(let i of r.split(`
|
|
8
|
-
`))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 n=t.join(`
|
|
9
|
-
`);return {type:e,data:JSON.parse(n)}}function _n(r){return r instanceof Error&&r.name==="AbortError"}export{y as A,c as B,vn as C,ro as D,En as E,xn as F,no as G,Qt as H,pr as a,lr as b,dr as c,st as d,mr as e,D as f,M as g,Sr as h,xe as i,se as j,ae as k,v as l,x as m,Te as n,mt as o,z as p,q,T as r,Ve as s,A as t,Zr as u,he as v,eo as w,Ke as x,to as y,ze as z};//# sourceMappingURL=chunk-6KI5UDCP.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-6KI5UDCP.js.map
|