@warmhub/sdk-ts 0.151.0 → 0.152.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/CHANGELOG.md +4 -0
- package/changelog.json +5 -0
- package/dist/checkpoint.js +1 -1
- package/dist/{chunk-LE6SDGKO.js → chunk-OBLKVPHV.js} +24 -24
- package/dist/chunk-OBLKVPHV.js.map +1 -0
- package/dist/chunk-YVTNE3EH.js +10 -0
- package/dist/chunk-YVTNE3EH.js.map +1 -0
- package/dist/index.d.ts +116 -9
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-FSZ4MCOS.js +0 -10
- package/dist/chunk-FSZ4MCOS.js.map +0 -1
- package/dist/chunk-LE6SDGKO.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -6463,6 +6463,16 @@ type OrgMember = {
|
|
|
6463
6463
|
invitedBy?: string;
|
|
6464
6464
|
createdAt: number;
|
|
6465
6465
|
};
|
|
6466
|
+
type ServiceAccount = {
|
|
6467
|
+
orgName: string;
|
|
6468
|
+
name: string;
|
|
6469
|
+
externalId: string;
|
|
6470
|
+
role: string;
|
|
6471
|
+
description?: string;
|
|
6472
|
+
disabled: boolean;
|
|
6473
|
+
createdBy: string | null;
|
|
6474
|
+
createdAt: number;
|
|
6475
|
+
};
|
|
6466
6476
|
type CollectionMembershipRole$1 = 'from' | 'to' | 'ends' | 'first' | 'second' | 'members' | 'items';
|
|
6467
6477
|
type RefsResult$1 = {
|
|
6468
6478
|
items: Array<{
|
|
@@ -6908,6 +6918,7 @@ type TokenCreateInput = {
|
|
|
6908
6918
|
description?: string;
|
|
6909
6919
|
expiresAt?: number;
|
|
6910
6920
|
committerIdentityWref?: string;
|
|
6921
|
+
serviceAccount?: string;
|
|
6911
6922
|
};
|
|
6912
6923
|
type TokenCreateResult = {
|
|
6913
6924
|
token: string;
|
|
@@ -6929,6 +6940,7 @@ type TokenCreateResult = {
|
|
|
6929
6940
|
warnings?: Array<string>;
|
|
6930
6941
|
expiresAt: number;
|
|
6931
6942
|
createdAt: number;
|
|
6943
|
+
serviceAccount?: string;
|
|
6932
6944
|
};
|
|
6933
6945
|
type TokenRevokeResult = {
|
|
6934
6946
|
ok: boolean;
|
|
@@ -7178,11 +7190,19 @@ declare const CLI_TIMESTAMP_HEADER = "X-WarmHub-Timestamp";
|
|
|
7178
7190
|
*/
|
|
7179
7191
|
type CliHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
7180
7192
|
|
|
7181
|
-
/**
|
|
7182
|
-
|
|
7193
|
+
/**
|
|
7194
|
+
* Every event type a webhook subscription can watch.
|
|
7195
|
+
* @see https://docs.warmhub.ai/sdk-reference/variables/subscribable_event_types/
|
|
7196
|
+
*/
|
|
7197
|
+
declare const SUBSCRIBABLE_EVENT_TYPES: readonly ["commit", "repo.renamed", "org.renamed", "org.member_added", "org.repo_created", "org.repo_published", "org.service_account_created", "org.service_account_role_changed", "org.service_account_disabled", "org.service_account_enabled", "org.service_account_deleted", "thing.renamed", "shape.renamed"];
|
|
7183
7198
|
type SubscribableEventType = (typeof SUBSCRIBABLE_EVENT_TYPES)[number];
|
|
7199
|
+
/**
|
|
7200
|
+
* Whether this build recognizes an event type; unknown strings remain valid on reads.
|
|
7201
|
+
* @see https://docs.warmhub.ai/sdk-reference/functions/isknownsubscribableeventtype/
|
|
7202
|
+
*/
|
|
7203
|
+
declare function isKnownSubscribableEventType(value: string): value is SubscribableEventType;
|
|
7184
7204
|
/** Org-scoped events — created with an `orgName` and no `repoName`. */
|
|
7185
|
-
declare const ORG_SCOPED_EVENT_TYPES: readonly ["org.renamed", "org.member_added", "org.repo_created", "org.repo_published"];
|
|
7205
|
+
declare const ORG_SCOPED_EVENT_TYPES: readonly ["org.renamed", "org.member_added", "org.repo_created", "org.repo_published", "org.service_account_created", "org.service_account_role_changed", "org.service_account_disabled", "org.service_account_enabled", "org.service_account_deleted"];
|
|
7186
7206
|
type OrgScopedEventType = (typeof ORG_SCOPED_EVENT_TYPES)[number];
|
|
7187
7207
|
|
|
7188
7208
|
/**
|
|
@@ -9255,7 +9275,8 @@ type CommitApplyCompatibilityResult = CommitApplyCompatibilityResult$1;
|
|
|
9255
9275
|
type SubscriptionInfo = {
|
|
9256
9276
|
name: string;
|
|
9257
9277
|
kind: 'webhook';
|
|
9258
|
-
|
|
9278
|
+
/** Open on the wire; narrow with `isKnownSubscribableEventType`. */
|
|
9279
|
+
eventType: string;
|
|
9259
9280
|
active: boolean;
|
|
9260
9281
|
shapeName?: string;
|
|
9261
9282
|
sourceRepo?: string;
|
|
@@ -9713,6 +9734,13 @@ type OrgDetail = OrgGetResult;
|
|
|
9713
9734
|
type OrgList = OrgListResult;
|
|
9714
9735
|
/** @internal */
|
|
9715
9736
|
type OrgMemberInfo = OrgMember;
|
|
9737
|
+
/**
|
|
9738
|
+
* A service account returned by `client.org.serviceAccounts`: an org-owned
|
|
9739
|
+
* principal for automation that cannot sign in and takes no seat.
|
|
9740
|
+
*
|
|
9741
|
+
* @internal
|
|
9742
|
+
*/
|
|
9743
|
+
type ServiceAccountInfo = ServiceAccount;
|
|
9716
9744
|
/** @internal */
|
|
9717
9745
|
type OrgMemberList = {
|
|
9718
9746
|
members: OrgMemberInfo[];
|
|
@@ -10342,6 +10370,11 @@ type TokenInfo = {
|
|
|
10342
10370
|
* associated identity.
|
|
10343
10371
|
*/
|
|
10344
10372
|
committerIdentityWref?: string | null;
|
|
10373
|
+
/**
|
|
10374
|
+
* Email of whoever minted a service account's token; null when unknown.
|
|
10375
|
+
* Present only when listing or getting with `serviceAccount`.
|
|
10376
|
+
*/
|
|
10377
|
+
createdBy?: string | null;
|
|
10345
10378
|
};
|
|
10346
10379
|
/** @internal */
|
|
10347
10380
|
type CredentialInfo = {
|
|
@@ -11283,6 +11316,66 @@ declare class WarmHubClient {
|
|
|
11283
11316
|
* Unarchive an organization.
|
|
11284
11317
|
*/
|
|
11285
11318
|
unarchive: (orgName: string) => Promise<OrgInfo>;
|
|
11319
|
+
/**
|
|
11320
|
+
* Service accounts: org-owned principals for automation, written
|
|
11321
|
+
* `{org}/{name}`. They cannot sign in and take no seat. Only owners and
|
|
11322
|
+
* admins of the org manage them; mint their tokens with
|
|
11323
|
+
* `client.token.create({ serviceAccount, ... })`.
|
|
11324
|
+
*/
|
|
11325
|
+
serviceAccounts: {
|
|
11326
|
+
/**
|
|
11327
|
+
* Create a service account with a viewer or editor role. Refused in an archived org.
|
|
11328
|
+
*/
|
|
11329
|
+
create: (input: {
|
|
11330
|
+
orgName: string;
|
|
11331
|
+
name: string;
|
|
11332
|
+
role: "viewer" | "editor";
|
|
11333
|
+
description?: string;
|
|
11334
|
+
}) => Promise<ServiceAccountInfo>;
|
|
11335
|
+
/**
|
|
11336
|
+
* List an org's service accounts. Disabled ones are included only with `includeDisabled`.
|
|
11337
|
+
*/
|
|
11338
|
+
list: (input: {
|
|
11339
|
+
orgName: string;
|
|
11340
|
+
includeDisabled?: boolean;
|
|
11341
|
+
}) => Promise<ServiceAccountInfo[]>;
|
|
11342
|
+
/**
|
|
11343
|
+
* Get one service account by name.
|
|
11344
|
+
*/
|
|
11345
|
+
get: (input: {
|
|
11346
|
+
orgName: string;
|
|
11347
|
+
name: string;
|
|
11348
|
+
}) => Promise<ServiceAccountInfo>;
|
|
11349
|
+
/**
|
|
11350
|
+
* Change a service account's role (viewer or editor). Its tokens narrow or widen at their next request.
|
|
11351
|
+
*/
|
|
11352
|
+
setRole: (input: {
|
|
11353
|
+
orgName: string;
|
|
11354
|
+
name: string;
|
|
11355
|
+
role: "viewer" | "editor";
|
|
11356
|
+
}) => Promise<ServiceAccountInfo>;
|
|
11357
|
+
/**
|
|
11358
|
+
* Disable a service account. Its tokens are rejected until it is enabled again.
|
|
11359
|
+
*/
|
|
11360
|
+
disable: (input: {
|
|
11361
|
+
orgName: string;
|
|
11362
|
+
name: string;
|
|
11363
|
+
}) => Promise<ServiceAccountInfo>;
|
|
11364
|
+
/**
|
|
11365
|
+
* Enable a disabled service account; its existing tokens work again.
|
|
11366
|
+
*/
|
|
11367
|
+
enable: (input: {
|
|
11368
|
+
orgName: string;
|
|
11369
|
+
name: string;
|
|
11370
|
+
}) => Promise<ServiceAccountInfo>;
|
|
11371
|
+
/**
|
|
11372
|
+
* Delete a service account: revokes its tokens and frees its name. Its history stays attributed to it.
|
|
11373
|
+
*/
|
|
11374
|
+
delete: (input: {
|
|
11375
|
+
orgName: string;
|
|
11376
|
+
name: string;
|
|
11377
|
+
}) => Promise<void>;
|
|
11378
|
+
};
|
|
11286
11379
|
};
|
|
11287
11380
|
/**
|
|
11288
11381
|
* Repository management surface for lifecycle operations, metadata, statistics, and content documents.
|
|
@@ -12477,6 +12570,7 @@ declare class WarmHubClient {
|
|
|
12477
12570
|
* @param input.scopes Scope entries narrowing the token's authority. Omit for full-principal authority.
|
|
12478
12571
|
* @param input.expiresAt Unix epoch milliseconds at which the token expires.
|
|
12479
12572
|
* @param input.description Human-readable description shown in token listings.
|
|
12573
|
+
* @param input.serviceAccount Mint for a service account (`{org}/{name}`) instead of yourself. Owners and admins of its org only; `scopes` is then required, and the scopes must be within both the service account's and your own access.
|
|
12480
12574
|
*/
|
|
12481
12575
|
create: (input: TokenCreateInput) => Promise<TokenResult>;
|
|
12482
12576
|
/**
|
|
@@ -12489,13 +12583,26 @@ declare class WarmHubClient {
|
|
|
12489
12583
|
includeInactive?: boolean;
|
|
12490
12584
|
}) => Promise<TokenInfo[]>;
|
|
12491
12585
|
/**
|
|
12492
|
-
*
|
|
12586
|
+
* List a service account's tokens (`{org}/{name}`), with who minted each.
|
|
12587
|
+
* Owners and admins of its org only; works while the account is disabled.
|
|
12588
|
+
*/
|
|
12589
|
+
listForServiceAccount: (serviceAccount: string, opts?: {
|
|
12590
|
+
includeInactive?: boolean;
|
|
12591
|
+
}) => Promise<TokenInfo[]>;
|
|
12592
|
+
/**
|
|
12593
|
+
* Get one personal access token by name. With `opts.serviceAccount`
|
|
12594
|
+
* (`{org}/{name}`), get one of that service account's tokens.
|
|
12493
12595
|
*/
|
|
12494
|
-
get: (name: string
|
|
12596
|
+
get: (name: string, opts?: {
|
|
12597
|
+
serviceAccount?: string;
|
|
12598
|
+
}) => Promise<TokenInfo | null>;
|
|
12495
12599
|
/**
|
|
12496
|
-
* Revoke a personal access token by name.
|
|
12600
|
+
* Revoke a personal access token by name. With `opts.serviceAccount`
|
|
12601
|
+
* (`{org}/{name}`), revoke one of that service account's tokens.
|
|
12497
12602
|
*/
|
|
12498
|
-
revoke: (name: string
|
|
12603
|
+
revoke: (name: string, opts?: {
|
|
12604
|
+
serviceAccount?: string;
|
|
12605
|
+
}) => Promise<TokenRevokeResult>;
|
|
12499
12606
|
};
|
|
12500
12607
|
/**
|
|
12501
12608
|
* Low-level stream append surface for callers that already have v2 wire operations.
|
|
@@ -12769,4 +12876,4 @@ declare class WarmHubClient {
|
|
|
12769
12876
|
private watchRepoQuery;
|
|
12770
12877
|
}
|
|
12771
12878
|
|
|
12772
|
-
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 AddInput, type AddOperation, AllStreamOperationsFailedError, type Assertion, CHECKPOINT_CONTENT_TYPES, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, COMPONENT_INSTALL_RESULT_STATES, COMPONENT_SUMMARY_STATES, CONTENT_FIELD_LIMIT_ERROR, CREDENTIAL_SCOPES, type CheckpointContentType, type CliCallSecrets, CliCallVerificationError, type CliCallVerificationFailureReason, 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 CollectionWriteType, type CommitApplyCompatibilityResult, type CommitDiagnostic, type CommitRealOperationResult, type CommitValidateInput, type CommitValidateOperation, type CommitValidateOperations, type CommitValidateOptions, type CommitValidateResult, type ComponentHistory, type ComponentHistoryOptions, type ComponentInfo, type ComponentInstallOptions, type ComponentInstallResult, type ComponentInstallResultState, type ComponentList, type ComponentListOptions, type ComponentSummaryState, 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 CredentialScope, type CredentialUngrantResult, type CurrentUserInfo, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, DEPENDENCY_FAILED, type DeclaredFieldEntry, type ErrorKind, type FieldIndexCarryingMarker, type FieldIndexCarryingShape, type FieldIndexConsistency, type FieldIndexPinResult, type FilterOptions, type FilterResult, type FunctionLogMode, GLOBAL_SEARCH_RESULT_ITEM_KINDS, type GlobalSearchOptions, type GlobalSearchResult, type GlobalSearchResultItem, type GlobalSearchResultItemKind, type Grant, type GrantCreateOptions, type GrantListOptions, type GrantListResult, type GrantRecipientSelector, type GrantRevokeResult, HOMEPAGE_FEATURED_ITEM_KINDS, type HeadResult, type HistoryResult, type HistoryVersion, type HomepageFeaturedItemKind, type HomepageFeaturedListsResult, type IndexedFieldEntry, type IndexedFieldsReport, type KeepShapesRevise, LEGACY_WREFS_REFUSAL, 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, MAX_WREFS_PER_THING_VERSION, type MemberScopeEntry, ORG_AUTH_SCOPES, ORG_MEMBER_STATUSES, ORG_ROLES, type OldNameDetails, type Operation, OperationBuilder, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceipt, type OperationEventReceiptMetadata, type OperationEventReceiptV1, type OperationSource, type OperationSubmitResult, type OrgAccessResult, type OrgAuthScope, type OrgDetail, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgMemberStatus, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, REPO_AUTH_SCOPES, type ReaffirmInput, type ReaffirmOperation, type RedactOptions, type RedactResult, type RefLink, type RefsOptions, type RefsResult, type RemoveOperation, type RemoveOptions, type RemoveResult, 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 RepositoryExportDeltaFormats, RepositoryExportError, type RepositoryExportErrorReason, type RepositoryExportExpectation, type RepositoryExportOptions, type RepositoryExportPreparation, type RepositoryExportPrepareOptions, type RepositoryExportRestoreOptions, type RepositoryExportRowMap, type RepositoryExportRows, type RepositoryExportSegmentOptions, RepositoryExportSession, type RequestEvent, type ResolveWrefResult, type RestoreInput, type RestoreOperation, type RetractInput, type RetractOperation, type RetryPolicyOptions, type ReviseInput, type ReviseOperation, type RewriteOperation, type RewriteOptions, type RewriteResult, SDK_VERSION, type ScopeAllowedShapes, type SearchOptions, type SearchResult, type Shape, type ShapeChange, type ShapeCountsUnavailableDetails, 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 ShapesChoice, 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 ThingDetailFields, 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 ThingNamesResult, type ThingQueryChangesOptions, type ThingShapesReader, 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, type WriteOperation, WriteOperationError, applyRepositoryExportDelta, collectDurableTokens, commitValidateRequestBodyBytes, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createCommitValidateInput, createKeepShapesResolver, createOperationEventRequestId, createOperationEventSubmissionId, createRepositoryExportSession, encodeCommitValidateRequestBody, getResponseDecorations, isAllStreamOperationsFailedError, isConnectionError, isDefiniteStreamAppendRejection, isKnownCheckpointContentType, isKnownComponentInstallResultState, isKnownComponentSummaryState, isKnownCredentialScope, isKnownGlobalSearchResultItemKind, isKnownHomepageFeaturedItemKind, isKnownOrgAuthScope, isKnownOrgMemberStatus, isKnownOrgRole, isKnownRepoAuthScope, isRetryable, isShapeReference, isWarmHubError, normalizeWref, operationEventStreamRequestId, readRepositoryExportStream, resolveFunctionLogMode, restoreRepositoryExportSession, sanitizeErrorMessage, sdkVersionIsBelowMinimum, shapeName, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
|
12879
|
+
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 AddInput, type AddOperation, AllStreamOperationsFailedError, type Assertion, CHECKPOINT_CONTENT_TYPES, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, COMPONENT_INSTALL_RESULT_STATES, COMPONENT_SUMMARY_STATES, CONTENT_FIELD_LIMIT_ERROR, CREDENTIAL_SCOPES, type CheckpointContentType, type CliCallSecrets, CliCallVerificationError, type CliCallVerificationFailureReason, 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 CollectionWriteType, type CommitApplyCompatibilityResult, type CommitDiagnostic, type CommitRealOperationResult, type CommitValidateInput, type CommitValidateOperation, type CommitValidateOperations, type CommitValidateOptions, type CommitValidateResult, type ComponentHistory, type ComponentHistoryOptions, type ComponentInfo, type ComponentInstallOptions, type ComponentInstallResult, type ComponentInstallResultState, type ComponentList, type ComponentListOptions, type ComponentSummaryState, 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 CredentialScope, type CredentialUngrantResult, type CurrentUserInfo, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, DEPENDENCY_FAILED, type DeclaredFieldEntry, type ErrorKind, type FieldIndexCarryingMarker, type FieldIndexCarryingShape, type FieldIndexConsistency, type FieldIndexPinResult, type FilterOptions, type FilterResult, type FunctionLogMode, GLOBAL_SEARCH_RESULT_ITEM_KINDS, type GlobalSearchOptions, type GlobalSearchResult, type GlobalSearchResultItem, type GlobalSearchResultItemKind, type Grant, type GrantCreateOptions, type GrantListOptions, type GrantListResult, type GrantRecipientSelector, type GrantRevokeResult, HOMEPAGE_FEATURED_ITEM_KINDS, type HeadResult, type HistoryResult, type HistoryVersion, type HomepageFeaturedItemKind, type HomepageFeaturedListsResult, type IndexedFieldEntry, type IndexedFieldsReport, type KeepShapesRevise, LEGACY_WREFS_REFUSAL, 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, MAX_WREFS_PER_THING_VERSION, type MemberScopeEntry, ORG_AUTH_SCOPES, ORG_MEMBER_STATUSES, ORG_ROLES, type OldNameDetails, type Operation, OperationBuilder, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceipt, type OperationEventReceiptMetadata, type OperationEventReceiptV1, type OperationSource, type OperationSubmitResult, type OrgAccessResult, type OrgAuthScope, type OrgDetail, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgMemberStatus, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, REPO_AUTH_SCOPES, type ReaffirmInput, type ReaffirmOperation, type RedactOptions, type RedactResult, type RefLink, type RefsOptions, type RefsResult, type RemoveOperation, type RemoveOptions, type RemoveResult, 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 RepositoryExportDeltaFormats, RepositoryExportError, type RepositoryExportErrorReason, type RepositoryExportExpectation, type RepositoryExportOptions, type RepositoryExportPreparation, type RepositoryExportPrepareOptions, type RepositoryExportRestoreOptions, type RepositoryExportRowMap, type RepositoryExportRows, type RepositoryExportSegmentOptions, RepositoryExportSession, type RequestEvent, type ResolveWrefResult, type RestoreInput, type RestoreOperation, type RetractInput, type RetractOperation, type RetryPolicyOptions, type ReviseInput, type ReviseOperation, type RewriteOperation, type RewriteOptions, type RewriteResult, SDK_VERSION, SUBSCRIBABLE_EVENT_TYPES, type ScopeAllowedShapes, type SearchOptions, type SearchResult, type ServiceAccountInfo, type Shape, type ShapeChange, type ShapeCountsUnavailableDetails, 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 ShapesChoice, 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 ThingDetailFields, 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 ThingNamesResult, type ThingQueryChangesOptions, type ThingShapesReader, 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, type WriteOperation, WriteOperationError, applyRepositoryExportDelta, collectDurableTokens, commitValidateRequestBodyBytes, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createCommitValidateInput, createKeepShapesResolver, createOperationEventRequestId, createOperationEventSubmissionId, createRepositoryExportSession, encodeCommitValidateRequestBody, getResponseDecorations, isAllStreamOperationsFailedError, isConnectionError, isDefiniteStreamAppendRejection, isKnownCheckpointContentType, isKnownComponentInstallResultState, isKnownComponentSummaryState, isKnownCredentialScope, isKnownGlobalSearchResultItemKind, isKnownHomepageFeaturedItemKind, isKnownOrgAuthScope, isKnownOrgMemberStatus, isKnownOrgRole, isKnownRepoAuthScope, isKnownSubscribableEventType, isRetryable, isShapeReference, isWarmHubError, normalizeWref, operationEventStreamRequestId, readRepositoryExportStream, resolveFunctionLogMode, restoreRepositoryExportSession, sanitizeErrorMessage, sdkVersionIsBelowMinimum, shapeName, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{m as AllStreamOperationsFailedError,I as CliCallVerificationError,L as DEFAULT_API_URL,j as DEFAULT_STREAM_CHUNK_SIZE,d as DEPENDENCY_FAILED,f as LEGACY_WREFS_REFUSAL,t as MAX_COMMIT_VALIDATION_ENCODED_BYTES,s as MAX_COMMIT_VALIDATION_OPERATIONS,k as MAX_STREAM_APPEND_OPERATION_COUNT,z as OperationBuilder,l as PartialStreamSubmissionError,A as RepositoryExportError,B as RepositoryExportSession,H as SDK_VERSION,i as StreamSubmissionAggregator,G as StreamingSubmissionOutcomeUnknownError,V as WarmHubClient,a as WarmHubError,c as WriteOperationError,D as applyRepositoryExportDelta,x as collectDurableTokens,w as commitValidateRequestBodyBytes,T as connectionErrorMessage,o as countStreamAppendResultStatuses,u as createCommitValidateInput,r as createKeepShapesResolver,h as createOperationEventRequestId,g as createOperationEventSubmissionId,C as createRepositoryExportSession,v as encodeCommitValidateRequestBody,y as getResponseDecorations,P as isAllStreamOperationsFailedError,S as isConnectionError,p as isDefiniteStreamAppendRejection,R as isRetryable,e as isShapeReference,Q as isWarmHubError,K as normalizeWref,E as readRepositoryExportStream,M as resolveFunctionLogMode,F as restoreRepositoryExportSession,N as sanitizeErrorMessage,U as sdkVersionIsBelowMinimum,b as shapeName,n as streamAppendResultStatus,q as submitOperationsViaStream,O as toWarmHubError,J as verifyCliCall}from'./chunk-
|
|
1
|
+
export{m as AllStreamOperationsFailedError,I as CliCallVerificationError,L as DEFAULT_API_URL,j as DEFAULT_STREAM_CHUNK_SIZE,d as DEPENDENCY_FAILED,f as LEGACY_WREFS_REFUSAL,t as MAX_COMMIT_VALIDATION_ENCODED_BYTES,s as MAX_COMMIT_VALIDATION_OPERATIONS,k as MAX_STREAM_APPEND_OPERATION_COUNT,z as OperationBuilder,l as PartialStreamSubmissionError,A as RepositoryExportError,B as RepositoryExportSession,H as SDK_VERSION,i as StreamSubmissionAggregator,G as StreamingSubmissionOutcomeUnknownError,V as WarmHubClient,a as WarmHubError,c as WriteOperationError,D as applyRepositoryExportDelta,x as collectDurableTokens,w as commitValidateRequestBodyBytes,T as connectionErrorMessage,o as countStreamAppendResultStatuses,u as createCommitValidateInput,r as createKeepShapesResolver,h as createOperationEventRequestId,g as createOperationEventSubmissionId,C as createRepositoryExportSession,v as encodeCommitValidateRequestBody,y as getResponseDecorations,P as isAllStreamOperationsFailedError,S as isConnectionError,p as isDefiniteStreamAppendRejection,R as isRetryable,e as isShapeReference,Q as isWarmHubError,K as normalizeWref,E as readRepositoryExportStream,M as resolveFunctionLogMode,F as restoreRepositoryExportSession,N as sanitizeErrorMessage,U as sdkVersionIsBelowMinimum,b as shapeName,n as streamAppendResultStatus,q as submitOperationsViaStream,O as toWarmHubError,J as verifyCliCall}from'./chunk-YVTNE3EH.js';export{fa as CHECKPOINT_CONTENT_TYPES,B as CLI_INSTALL_REPO_HEADER,C as CLI_SIGNATURE_HEADER,D as CLI_TIMESTAMP_HEADER,I as COMPONENT_INSTALL_RESULT_STATES,O as COMPONENT_SUMMARY_STATES,k as CONTENT_FIELD_LIMIT_ERROR,Q as CREDENTIAL_SCOPES,S as GLOBAL_SEARCH_RESULT_ITEM_KINDS,U as HOMEPAGE_FEATURED_ITEM_KINDS,j as MAX_CONTENT_FIELD_BYTES,y as MAX_WREFS_PER_THING_VERSION,W as ORG_AUTH_SCOPES,Z as ORG_MEMBER_STATUSES,$ as ORG_ROLES,K as REPO_AUTH_SCOPES,G as SUBSCRIBABLE_EVENT_TYPES,l as contentFieldLimitError,ga as isKnownCheckpointContentType,J as isKnownComponentInstallResultState,P as isKnownComponentSummaryState,R as isKnownCredentialScope,T as isKnownGlobalSearchResultItemKind,V as isKnownHomepageFeaturedItemKind,X as isKnownOrgAuthScope,_ as isKnownOrgMemberStatus,aa as isKnownOrgRole,L as isKnownRepoAuthScope,H as isKnownSubscribableEventType,Y as operationEventStreamRequestId,xa as validateAgainstShape}from'./chunk-OBLKVPHV.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {V}from'./chunk-
|
|
1
|
+
import {V}from'./chunk-YVTNE3EH.js';export{L as DEFAULT_API_URL,H as SDK_VERSION,V as WarmHubClient,a as WarmHubError,O as toWarmHubError}from'./chunk-YVTNE3EH.js';import'./chunk-OBLKVPHV.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=o.getAccessToken,a=useMemo(()=>new V({apiUrl:e,accessToken:async()=>await i()??void 0,client:{name:n,version:u},decorateResponses:r}),[e,n,u,r,i]);return jsx(p.Provider,{value:a,children:jsx(g,{auth:o,client:a,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(a=>{console.error("auth.sync failed:",a),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/package.json
CHANGED
package/dist/chunk-FSZ4MCOS.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {z as z$2,f as f$1,b,e,g,va,sa,na,oa,pa,ra,B as B$1,E,C,D as D$1,F as F$1,h,K as K$1,L as L$1,p,v,u,t,x as x$1,o,s,W as W$1,i,ua,ta,qa,la,q,l,A as A$1,r,$ as $$1,c as c$1,d,ma,w,m,n,a}from'./chunk-LE6SDGKO.js';import {TRPCClientError,createTRPCProxyClient,splitLink,httpBatchLink,httpLink}from'@trpc/client';import {observable}from'@trpc/server/observable';import {z as z$1}from'zod';function Dt(n,e){let{childContext:t,onStringValue:r,onObjectKey:i$1}=e,o=[{value:n,context:e.rootContext}];for(;o.length>0;){let{value:s,context:a}=o.pop();if(typeof s=="string"){r(s,a);continue}if(Array.isArray(s)){for(let d=s.length-1;d>=0;d--)o.push({value:s[d],context:t(a,d)});continue}if(!i(s))continue;let u=Object.entries(s).map(([d,l])=>[d,t(a,d),l]);if(i$1)for(let[d,l]of u)i$1(d,l);for(let d=u.length-1;d>=0;d--){let l=u[d];l&&o.push({value:l[2],context:l[1]});}}}var f=class extends Error{code;status;hint;retryAfter;errorCode;backendCode;details;constructor(e,t,r,i,o,s,a){super(t),this.name="WarmHubError",this.code=e,this.status=r,this.hint=i,this.retryAfter=o,this.errorCode=s,this.backendCode=s,this.details=a;}get kind(){return this.code}};var en=["kind","shape","wref","declaredShapes","about","type","members"];function tn(n){let e=n;for(let t of en)if(e[t]!==void 0)return `'${t}'`;if(e.operation===void 0)return "no 'operation'";if((e.operation==="add"||e.operation==="revise")&&e.shapes===void 0&&e.keepShapes===void 0)return qt}function Mt(n){let e=tn(n);if(e!==void 0)return e===qt?on(n):`this is the v1 write form (${e}). Write it in the v2 form: ${JSON.stringify(rn(n))}`}var Lt="...";function rn(n){return nn(sn(n),n)}function nn(n,e){let{data:t,type:r}=e;if(!("data"in n)||t===void 0||t===null||typeof r=="string"&&r in m)return n;let i=n.data;return typeof t=="object"&&!Array.isArray(t)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?{...n,data:Object.fromEntries(Object.entries(i).map(([o,s])=>[o,o in t?Lt:s]))}:{...n,data:Lt}}var qt="no 'shapes'";function on(n){let e=n,t=String(e.operation);return `${t} "${String(e.name)}" states no Shapes: pass shapes: ['Shape', ...], shapes: [] for shapeless${t==="revise"?", or keepShapes: true":""}`}function sn(n){let e=an(n),t=["operation","name","newName","shapes","keepShapes","data"];return Object.fromEntries([...t.filter(r=>r in e).map(r=>[r,e[r]]),...Object.entries(e).filter(([r])=>!t.includes(r))])}function an(n$1){let{kind:e,shape:t,wref:r,declaredShapes:i,about:o,type:s,members:a,...u}=n$1,d=u.operation??"add",l=typeof u.name=="string"?u.name:r,m$1={...u,operation:d,name:l};if(d==="rename"||d==="retract"||d==="reaffirm")return e==="shape"&&(m$1.name=`hub/shapes/${String(l)}`,typeof u.newName=="string"&&(m$1.newName=`hub/shapes/${u.newName}`)),m$1;if(e==="shape")return {...m$1,name:`hub/shapes/${String(l)}`,shapes:[]};if(typeof s=="string"&&s in m){let b=s;return {...m$1,shapes:[m[b]],data:n(b,Array.isArray(a)?a:[])}}let h=typeof o=="string"&&typeof u.data=="object"&&u.data!==null?{...u.data,about:o}:u.data;if(Array.isArray(i))return {...m$1,shapes:i,data:h};if(d==="revise")return {...m$1,keepShapes:true,data:h};let g=typeof l=="string"?l.indexOf("/"):-1;return typeof l=="string"&&g>0?{...m$1,name:l.slice(g+1),shapes:[l.slice(0,g)],data:h}:{...m$1,shapes:[],data:h}}function L(n){return n.keepShapes===true}var P=Symbol.for("warmhub.sdk.queuedOperations");function M(n){return typeof n=="object"&&n!==null&&typeof n[P]=="function"}function pn(n){return f$1(n)}var y=class extends f{operationIndex;constructor(e,t,r="VALIDATION_ERROR"){super(r,e===void 0?t:`Invalid operation at index ${e}: ${t}`,r==="NOT_FOUND"?404:400),this.operationIndex=e;}},cn="DEPENDENCY_FAILED",Be="`shapes` takes bare Shape names; writes always certify under the Shape's head version.",un=new Set(["add","revise","retract","restore","reaffirm","rename"]),dn=/@v\d+$/;function Ve(n){return dn.test(n)}function Bt(n){return typeof n=="string"&&n.length>0&&n.trim()===n&&!n.includes("/")&&!b(n)}function Ut(n,e,t){if(typeof n!="string"||n.length===0)throw new y(t,`'${e}' must be a non-empty name`);return n}function Z(n,e$1,t=false){if(typeof n!="object"||n===null)throw new y(e$1,"an operation must be an object");if(Object.hasOwn(n,"shapeless"))throw new y(e$1,"shapeless is a builder option; a raw operation states a shapeless write as shapes: []");let r=Mt(n);if(r!==void 0)throw new y(e$1,r);let i=n;if(typeof i.operation!="string"||!un.has(i.operation))throw new y(e$1,"'operation' must be one of add, revise, retract, restore, reaffirm, rename");let o=Ut(i.name,"name",e$1);if(i.operation==="rename"){let s=Ut(i.newName,"newName",e$1);if(e(o)!==e(s))throw new y(e$1,`a Shape renames to a Shape: rename "${o}" to hub/shapes/<Name>, and a Thing to a Thing name`)}if((i.operation==="add"||i.operation==="revise")&&(ln(i,o,e$1),i.data===void 0))throw new y(e$1,`${i.operation} requires 'data'`);if(i.operation==="add"&&i.expectedVersion!==void 0)throw new y(e$1,"expectedVersion is only valid on revise, retract, restore, or reaffirm operations");if(i.operation==="revise"&&Object.hasOwn(i,"active"))throw new y(e$1,`revise no longer supports 'active' \u2014 retract "${o}" instead`);return hn(i,o,e$1),t&&i.operation==="add"?{...i,skipExisting:true}:i}function ln(n,e$1,t){if(n.keepShapes!==void 0){if(n.operation!=="revise"||n.keepShapes!==true)throw new y(t,"keepShapes applies only to a revise: an add states its shapes, or shapeless");if(n.shapes!==void 0)throw new y(t,"state Shapes one way: shapes, shapeless, or keepShapes");return}let r=n.shapes;if(!Array.isArray(r))throw new y(t,`${String(n.operation)} "${e$1}" states no Shapes: pass shapes: ['Shape', ...], shapeless, or (revise only) keepShapes`);for(let i of r){if(typeof i=="string"&&Ve(i))throw new y(t,Be);if(!Bt(i))throw new y(t,`shapes holds bare Shape names ('Deal'); got ${JSON.stringify(i)}`)}if(e(e$1)&&r.length>0)throw new y(t,`"${e$1}" is a Shape: write it with shapes: []`);if(r.length===0&&n.affirmedTargets!==void 0)throw new y(t,"affirmedTargets needs a Shape that composes Assertion; a shapeless write has none")}var mn=n=>`Name "${n}" contains reserved character "+". The "+" character is reserved for the historical collection auto-name namespace and is not allowed in user-supplied names.`;function hn(n,e$1,t){let r=g(e$1);if(r!==void 0){let o=typeof n.newName=="string"?g(n.newName)??n.newName:void 0,s=$$1({operation:n.operation,kind:"shape",name:r,...o!==void 0?{newName:o}:{}},t)[0];if(s)throw new y(t,s.message,s.code);return}if(n.operation==="restore"&&typeof n.newName=="string"&&e(n.newName)){let o=$$1({operation:"restore",name:e$1,newName:n.newName},t)[0];if(o)throw new y(t,o.message,o.code);return}let i=n.operation==="add"?e$1:(n.operation==="rename"||n.operation==="restore")&&typeof n.newName=="string"?n.newName:void 0;if(i!==void 0){if(c$1(i))throw new y(t,d(i),"RESERVED_NAME");if(i.includes("+"))throw new y(t,mn(i))}}function ee(n,e=0){let t=new Set;n.forEach((r,i)=>{if(r.operation==="add"){if(t.has(r.name))throw new y(e+i,`Cannot add "${r.name}" twice in the same commit`,"ILLEGAL_OP_SEQUENCE");t.add(r.name);}});}var Vt=500;function Fe(n){let e=new Map,t=new Set;return async(r,i=0)=>{let o=new Set,s=new Set;for(let u of r){L(u)&&!s.has(u.name)&&!t.has(u.name)&&!e.has(u.name)&&o.add(u.name);for(let d of Ft(u))s.add(d);}let a=await gn([...o],n);return r.map((u,d)=>{if(!L(u)){if(u.operation==="revise")e.set(u.name,u.shapes);else if(u.operation==="add"||u.operation==="rename")for(let b of Ft(u))t.add(b);return u}if(t.has(u.name))throw new y(i+d,`keepShapes revise "${u.name}": an earlier operation in this submission adds or renames it, so its Shapes are not known until that commits; submit it in a later request, or pass \`shapes\``);let{keepShapes:l,...m}=u,h=e.get(u.name);if(h!==void 0)return {...m,shapes:h};let g=a.get(u.name);if(g===void 0)throw new y(i+d,`keepShapes revise "${u.name}": no such Thing`,"NOT_FOUND");return e.set(u.name,g.shapes),{...m,shapes:g.shapes,expectedVersion:u.expectedVersion??g.version}})}}function U(n,e){return n==="passThrough"?async t=>t:Fe(e)}function Ft(n){return n.operation==="rename"?[n.name,n.newName]:n.operation==="add"||n.operation==="revise"?[n.name]:[]}async function gn(n,e){let t=new Map;for(let r=0;r<n.length;r+=Vt){let i=n.slice(r,r+Vt),o=await e(i),s=new Set(o.missing),a=i.filter(u=>!s.has(u));if(a.length!==o.items.length)throw new Error(`keepShapes read returned ${o.items.length} items for ${a.length} found targets`);a.forEach((u,d)=>{let l=o.items[d];l!==void 0&&t.set(u,{shapes:l.declaredShapes.map(m=>h(m)),version:l.version});});}return t}var Ht=new WeakSet;function Wt(n){Ht.add(n);}function B(n){return Ht.has(n)}var $t="`legacy-wrefs` is set; the SDKs are v2-only. Unset it, or use the `wh` CLI for v1.",yn="Remove 'legacy-wrefs' from the client's options (clientFlags: ['legacy-wrefs'] is what sets it).";function He(){return new f("CLIENT_INCOMPATIBLE",$t,void 0,yn,void 0,void 0,{reason:"legacy-wrefs-sdk"})}function te(n){return n?.includes(q)===true}var Gt="`legacy-wrefs` is set: unset `legacy-wrefs` to run this command (WH_CLIENT_FLAGS, or the profile's client flag). Under it, wh sends only raw `wh commit submit` input, reads and sign-in.",Kt=new Set(["auth.sync"]),jt=new Set(["stream.append","commit.validate"]),zt="`legacy-wrefs` is set, so only raw v1 input is sent: builder output and keepShapes revises are v2 payloads and are never sent under it. Unset the flag to use them.";function V(n,e){let t=n.clientFlags;if(te(t)&&B(n)){if(M(e))throw new y(void 0,zt);return "passThrough"}if(te(t))throw He();return "v2"}function Qt(n,e){if(typeof n!="object"||n===null)throw new y(e,"an operation must be an object");if(L(n))throw new y(e,zt);return n}function F(){let n=globalThis.crypto?.randomUUID?.();if(!n)throw new Error("This runtime cannot mint a cryptographically secure UUID");return n.toLowerCase()}var fn=F;function Rn(n,e,t){let r=n.operation===void 0||n.operation==="noop"?t?.operation??"add":n.operation,i={opIndex:e,name:n.name??"",operation:r,...n.affirmations?{affirmations:n.affirmations}:{},...n.resolvedName!==void 0?{resolvedName:n.resolvedName}:{},...n.warnings?{warnings:n.warnings}:{}};return n.status==="failed"?{...i,status:"error",errors:[{code:n.error?.code??"BACKEND",message:n.error?.message??`Operation on "${n.name}" failed`,...n.error?.details?{details:n.error.details}:{},...n.retryable!==void 0?{retryable:n.retryable}:{}}],...t?.name!==void 0?{submittedName:t.name}:{}}:{...i,status:n.status==="noop"||n.operation==="noop"?"noop":"applied",...n.version!==void 0?{version:n.version}:{},...n.dataHash!==void 0?{dataHash:n.dataHash}:{}}}var H=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,r)=>{let i=t.opIndex??r,o=e.submittedOperations[i],s=Rn(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 Se=1e3,we=1e4,k=class extends Error{code="PARTIAL_STREAM_SUBMISSION";completedReceipts;completedOperations;submissionId;eventRequestId;chunkOrdinal;pendingOutcome;acknowledgedOperationCount;lastAcknowledgedRepoSeq;attemptedAppendOutcome;cause;constructor(e){super(e.pendingOutcome==="unknown"?`Stream submission outcome is unknown for event request ${e.eventRequestId}. Look up its immutable receipt before retrying.`:`Stream submission stopped at event request ${e.eventRequestId} after earlier chunks committed.`),this.name="WarmHubError",this.cause=e.cause,this.completedReceipts=e.completedReceipts,this.completedOperations=e.completedOperations??[],this.submissionId=e.submissionId,this.eventRequestId=e.eventRequestId,this.chunkOrdinal=e.chunkOrdinal,this.pendingOutcome=e.pendingOutcome,this.acknowledgedOperationCount=e.acknowledgedOperationCount??e.completedReceipts.length,this.attemptedAppendOutcome=e.attemptedAppendOutcome,e.lastAcknowledgedRepoSeq!==void 0&&(this.lastAcknowledgedRepoSeq=e.lastAcknowledgedRepoSeq);}},A=class extends Error{code;receipts;result;operations;statusCounts;cause;constructor(e){let t=e.operations.find(r=>r.status==="error")?.errors[0];super(t?`All ${e.operationCount} stream operations failed: ${t.message}`:`All ${e.operationCount} stream operations failed.`),this.name="WarmHubError",this.code=t&&e.operations.every(r=>r.status==="error"&&r.errors.length>0&&r.errors.every(i=>i.code===t.code))?t.code:"STREAM_ALL_OPERATIONS_FAILED",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 We(n){let e="status"in n?n.status:void 0;return e==="failed"||e==="error"?"error":e==="noop"||n.operation==="noop"?"noop":"applied"}function Xt(n){let e={applied:0,noop:0,error:0};for(let t of n)e[We(t)]++;return e}var bn={maxAttempts:3,baseDelayMs:250,maxDelayMs:8e3},Sn=10,Yt=6e4;function $e(n){if(n===false)return false;let e={};n!==void 0&&(Number.isFinite(n.maxAttempts)&&(e.maxAttempts=n.maxAttempts),Number.isFinite(n.baseDelayMs)&&(e.baseDelayMs=n.baseDelayMs),Number.isFinite(n.maxDelayMs)&&(e.maxDelayMs=n.maxDelayMs));let t={...bn,...e};return {maxAttempts:Math.min(Sn,Math.max(1,Math.trunc(t.maxAttempts))),baseDelayMs:Math.min(Yt,Math.max(0,Math.trunc(t.baseDelayMs))),maxDelayMs:Math.min(Yt,Math.max(0,Math.trunc(t.maxDelayMs)))}}var wn=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","NAME_TAKEN","TARGET_REMOVED","TARGET_REDACTED","ALREADY_RETRACTED","ARCHIVED","RATE_LIMITED","TOO_MANY_REQUESTS","UNRESOLVED_TOKEN"]),Cn=new Set(["COMMIT_OUTCOME_UNKNOWN"]);function Zt(n){if(!n||typeof n!="object")return;let e=n.code;if(typeof e=="string")return e;let t=n.data,r=t?.warmhub?.code;if(typeof r=="string")return r;let i=t?.code;if(typeof i=="string")return i}function En(n){if(!n||typeof n!="object")return;let e=n.data?.httpStatus;if(typeof e=="number")return e;let t=n.data?.warmhub?.status;if(typeof t=="number")return t;let r=n.status;return typeof r=="number"?r:void 0}function On(n){return n!==void 0&&n>=400&&n<500&&n!==408}function er(n){let e=Zt(n);return e!==void 0&&Cn.has(e)}function re(n){if(er(n))return false;let e=Zt(n);return e!==void 0&&wn.has(e)||On(En(n))}function Ge(n){if(er(n)||re(n))return false;if(Jt(n))return true;if(n instanceof TypeError||n instanceof SyntaxError)return false;let e=n?.cause;return Jt(e)?true:!(e instanceof TypeError||e instanceof SyntaxError)}function Jt(n){return n instanceof TypeError&&/fetch/i.test(n.message)}function Ke(n,e){let t=e.baseDelayMs*2**Math.max(0,n-1),r=Math.random()*e.baseDelayMs;return Math.min(e.maxDelayMs,t+r)}function je(n){return new Promise(e=>setTimeout(e,n))}var Ce=class extends Error{code;status=400;constructor(e,t="VALIDATION_ERROR"){super(e),this.code=t,this.name="WarmHubError";}},Ee=class extends Error{constructor(t){super("operation source failed");this.reason=t;}reason};async function W(n,e){let t=V(n,e.operations),r=Ie(e.chunkSize),i=e.submissionId??F(),o=e.streamId??i,s=$e(e.retry),a=new H,u=[],d,l,m=0,h,g=0,b=U(t,async C=>{if(!n.thing)throw new Ce("A keepShapes revise needs the client to read its Thing: this stream client has no thing.getMany");return await n.thing.getMany(e.orgName,e.repoName,C)}),S=C=>new k({cause:C.cause,completedReceipts:a.receipts,completedOperations:a.completedOperations(),acknowledgedOperationCount:m,lastAcknowledgedRepoSeq:h,attemptedAppendOutcome:C.pendingOutcome==="absent"?"not_applied":"unknown",submissionId:i,eventRequestId:W$1(i,g),chunkOrdinal:g,pendingOutcome:C.pendingOutcome});try{for await(let C of In(e.operations,r,e.skipExisting===!0,b,t)){let _=C.operations,Q=1,Y=!1;for(;;)try{let E=await n.stream.append({allocatedTokenRanges:u,chunkOrdinal:g,orgName:e.orgName,repoName:e.repoName,streamId:o,submissionId:i,componentRef:e.componentRef,committer:e.committer,message:e.message,...e.returnRepoSeq!==void 0?{returnRepoSeq:e.returnRepoSeq}:{},operations:_});a.addReceipt(E.receipt),u=E.allocatedTokenRanges,d=E.createdByEmail??d,l=E.repoSeq??l,a.addChunk({result:E,chunkStart:C.start,submittedOperations:C.operations}),m+=C.operations.length;let v=An(E.receipt);v!==void 0&&(h=v);break}catch(E){let v=re(E);if(a.receipts.length===0&&!Y&&v)throw E;if(s!==!1&&Q<s.maxAttempts&&Ge(E)){await je(Ke(Q,s)),Q+=1,Y=!0;continue}throw S({cause:E,pendingOutcome:Y||!v?"unknown":"absent"})}g+=1;}}catch(C){throw C instanceof Ee?a.receipts.length===0?C.reason:S({cause:C.reason,pendingOutcome:"absent"}):C}if(g===0)throw new Ce("At least one operation is required for stream submission.");let w=a.toResult({committer:e.committer,createdByEmail:d,message:e.message,repoSeq:l});if(a.allFailed)throw new A(w);return w}async function*In(n,e,t,r,i){let o=i==="passThrough";try{let s=vn(n);if(s!==void 0){let l=s.map((h,g)=>ne(h,g,t,i));o||ee(l);let m=await r(l);for(let h=0;h<m.length;h+=e)yield {operations:m.slice(h,h+e),start:h};return}let a=0,u=[],d=o?async(l,m)=>({operations:l,start:m-l.length}):async(l,m)=>await xn(l,m,r);for await(let l of rr(n,t,i))u.push(l),a+=1,!(u.length<e)&&(yield await d(u,a),u=[]);u.length>0&&(yield await d(u,a));}catch(s){throw new Ee(s)}}function vn(n){if(M(n))return n[P]();if(Array.isArray(n))return n}async function xn(n,e,t){let r=e-n.length;return ee(n,r),{operations:await t(n,r),start:r}}function ne(n,e,t,r="v2"){if(r==="v2")return Z(n,e,t);let i=Qt(n,e);return t&&i.operation==="add"?{...i,skipExisting:true}:i}function tr(n){let e=Fe(n),t=0;return async r=>{let i=t;return t+=r.length,await e(r.map((o,s)=>Z(o,i+s)),i)}}async function*rr(n,e,t="v2"){let r=Oe(n,e,t);try{for(;;){let i=await r.next();if(i.done)return;yield i.value;}}finally{let i=r.returnSourceOnce();i&&await i;}}function Oe(n,e,t="v2"){let r,i=0,o=false,s=false,a=()=>{if(r)return r;let u=M(n)?n[P]():n;return r=Symbol.asyncIterator in u?u[Symbol.asyncIterator]():u[Symbol.iterator](),r};return {async next(){let u=await a().next();if(u.done)return s=true,{done:true,value:void 0};let d=ne(u.value,i,e,t);return i+=1,{done:false,value:d}},returnSourceOnce(){if(o||s){o=true;return}return o=true,r?.return?.()}}}function ze(n){return kn.encode(`${JSON.stringify(n)}
|
|
2
|
-
`)}var kn=new TextEncoder;function An(n){let e=n.event?.repoSeq;if(e===void 0)return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function Ie(n){return Number.isFinite(n)?Math.max(1,Math.min(we,Math.trunc(n))):Se}var Tn=1e4,Qe=4*1024*1024,$=class extends Error{code="VALIDATION_ERROR";status=400;constructor(e,t){super(`Invalid operation at index ${e}: ${t}`),this.name="WarmHubError";}};function _n(n,e){if(typeof n.name!="string"||n.name.length===0)throw new $(e,`${String(n.operation)} requires 'name'`);return n.name}function nr(n,e,t){let r=n[t];if(typeof r!="number"||!Number.isInteger(r)||r<1)throw new $(e,`${String(n.operation)} requires a positive integer '${t}'`);return r}function Nn(n,e){let t=_n(n,e);if(n.operation==="remove")return {operation:"remove",name:t,expectedVersion:nr(n,e,"expectedVersion")};let r=n.data;if(typeof r!="object"||r===null||Array.isArray(r))throw new $(e,"rewrite requires 'data', the complete replacement body as an object");let i=n.shapes;if(!Array.isArray(i)||i.some(o=>typeof o!="string"||o.length===0))throw new $(e,"rewrite requires 'shapes', the version's declared Shapes plus CorrectedThing");return {operation:"rewrite",name:t,version:nr(n,e,"version"),shapes:i,data:r}}var ir=n=>{let e=typeof n=="object"&&n!==null?n.operation:void 0;return e==="remove"||e==="rewrite"},Ye=n=>!ir(n);function or(n,e,t="v2"){let i=(M(n)?n[P]():n).map((o,s)=>ir(o)?Nn(o,s):ne(o,s,e===true,t));return t==="v2"&&ee(i.filter(Ye)),i}async function Pn(n,e){let t=(await n(e.filter(Ye))).values();return e.map(r=>Ye(r)?t.next().value:r)}async function sr(n,e,t,r,i,o,s){let a=V(s,i),u=or(i,o?.skipExisting,a),d=U(a,e),l={...ar(t,r,[],o,a),operations:await Pn(d,u)},m=cr(l);if(m>Qe)throw new f("VALIDATION_ERROR",`Commit validation request exceeds the ${Qe}-byte encoded limit (${m} bytes).`,413,"Split the preview into smaller current-commit units.");return await n.mutate(l,{signal:o?.signal})}function ar(n,e,t,r,i="v2"){return {orgName:n,repoName:e,...r?.committer!==void 0?{committer:r.committer}:{},...r?.message!==void 0?{message:r.message}:{},...r?.componentRef!==void 0?{componentRef:r.componentRef}:{},operations:or(t,r?.skipExisting,i),...r?.includeWouldBeBody!==void 0?{includeWouldBeBody:r.includeWouldBeBody}:{}}}function pr(n){return JSON.stringify(n)}function cr(n){return new TextEncoder().encode(pr(n)).byteLength}function ve(n){let e=new Set;return Dt(n,{rootContext:{key:null,parentKey:null,insideData:false},childContext:(t,r)=>({key:r,parentKey:t.key,insideData:t.insideData||r==="data"}),onStringValue:(t,r)=>{if(r.key==="durableId"&&r.parentKey==="metadata"&&!r.insideData)return;let i=a(t);i&&e.add(i.durableId);}}),e}async function ur(n,e){let t=[...n],r={};for(let i=0;i<t.length;i+=500){let{items:o}=await e(t.slice(i,i+500));for(let s of o)r[s.durableId]=s.canonicalWref;}return r}function Je(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function qn(n){if(!Je(n))return;let e=n.decorations;return Je(e)?e:void 0}function Un(n){let e=n instanceof Error?n:new Error(String(n));return Object.assign(e,{decorationFailure:true})}function dr(n){return ()=>({op:e,next:t})=>!n.enabled||e.type!=="query"||e.path==="thing.names"||e.path==="thing.headVersions"?t(e):observable(r=>{let i=false,o=false,s=false,a=()=>{!i&&o&&!s&&r.complete();},u=t(e).subscribe({next:d=>{let l=d.result?.data;if(!Je(l)){r.next(d);return}let m=ve(l);if(m.size===0){r.next(d);return}s=true,ur(m,n.lookupNames).then(h=>{i||r.next({...d,result:{...d.result,data:{...l,decorations:h}}});}).catch(h=>{i||r.error(TRPCClientError.from(Un(h)));}).finally(()=>{s=false,a();});},error:d=>r.error(d),complete:()=>{o=true,a();}});return ()=>{i=true,u.unsubscribe();}})}function lr(n,e){return {create:async(t,r,i)=>{try{return await n().grant.create.mutate({orgName:t,repoName:r,...i})}catch(o){throw e(o)}},get:async(t,r,i)=>{try{return await n().grant.get.query({orgName:t,repoName:r,grantId:i})}catch(o){throw e(o)}},list:async(t,r,i)=>{try{return await n().grant.list.query({orgName:t,repoName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw e(o)}},revoke:async(t,r,i,o)=>{try{return await n().grant.revoke.mutate({orgName:t,repoName:r,grantId:i,reason:o?.reason})}catch(s){throw e(s)}}}}function ie(n,e,t){let r=ua(e,t==="revise"?{allowUnsafeFieldNamePaths:ta(e)}:void 0);return r.valid?null:`Invalid shape definition for "${n}": ${r.errors.join("; ")}`}var G=class{ops=[];shapes;submitted=false;inFlight=false;constructor(e){this.shapes=e?.shapes;}add(e,t){this.assertCanModify();let r=this.ops.length,i=this.statedShapes(t,r,"add",e);return this.queue({operation:"add",name:e,shapes:i??[],data:t.data,...t.affirmedTargets!==void 0?{affirmedTargets:[...t.affirmedTargets]}:{},...t.skipExisting===true?{skipExisting:true}:{}},t.data),this}revise(e,t){this.assertCanModify();let r=this.ops.length,i=this.statedShapes(t,r,"revise",e),o={data:t.data,...t.affirmedTargets!==void 0?{affirmedTargets:[...t.affirmedTargets]}:{},...t.expectedVersion!==void 0?{expectedVersion:t.expectedVersion}:{},...t.leaseId!==void 0?{leaseId:t.leaseId}:{}};return this.queue(i===void 0?{operation:"revise",name:e,keepShapes:true,...o}:{operation:"revise",name:e,shapes:i,...o},t.data),this}retract(e,t={}){return this.assertCanModify(),this.queue({operation:"retract",name:e,...t.reason!==void 0?{reason:t.reason}:{},...t.expectedVersion!==void 0?{expectedVersion:t.expectedVersion}:{},...t.leaseId!==void 0?{leaseId:t.leaseId}:{}}),this}restore(e,t={}){return this.assertCanModify(),this.queue({operation:"restore",name:e,...t.newName!==void 0?{newName:t.newName}:{},...t.expectedVersion!==void 0?{expectedVersion:t.expectedVersion}:{},...t.leaseId!==void 0?{leaseId:t.leaseId}:{}}),this}rename(e,t){return this.assertCanModify(),this.queue({operation:"rename",name:e,newName:t}),this}reaffirm(e,t){return this.assertCanModify(),this.queue({operation:"reaffirm",name:e,...t.add!==void 0?{add:[...t.add]}:{},...t.remove!==void 0?{remove:[...t.remove]}:{},...t.expectedVersion!==void 0?{expectedVersion:t.expectedVersion}:{},...t.leaseId!==void 0?{leaseId:t.leaseId}:{}}),this}get operations(){return Object.freeze([...this.ops])}get size(){return this.ops.length}has(e){return this.ops.some(t=>t.operation==="add"&&t.name===e)}[P](){return this.ops}validate(){let e=[],t=[],r=new Set,i=new Set;return this.ops.forEach((o,s)=>{if(o.operation==="add")r.has(o.name)&&e.push({code:"DUPLICATE_NAME",operationIndex:s,message:`Duplicate name '${o.name}' at index ${s} (already added earlier in commit)`}),r.add(o.name);else if(o.operation==="revise")i.has(o.name)?e.push({code:"REVISE_AFTER_RETRACT",operationIndex:s,message:`Revise at index ${s} targets '${o.name}' which was already retracted in this commit`}):r.has(o.name)||t.push({code:"REVISE_UNKNOWN_WREF",operationIndex:s,message:`Revise at index ${s} references '${o.name}' which was not added in this commit (assuming it exists server-side)`});else if(o.operation==="retract"){if(i.has(o.name)){t.push({code:"RETRACT_AFTER_RETRACT",operationIndex:s,message:`Retract at index ${s} targets '${o.name}' which was already retracted in this commit`});return}r.has(o.name)||t.push({code:"RETRACT_UNKNOWN_WREF",operationIndex:s,message:`Retract at index ${s} references '${o.name}' which was not added in this commit (assuming it exists server-side)`}),i.add(o.name);}else o.operation==="restore"&&i.clear();}),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 y(void 0,"OperationBuilder: stream submission already in flight");let t=this.validate(),[r]=t.errors;if(r!==void 0){let i=t.errors.map(o=>o.message).join("; ");throw new y(r.operationIndex<0?void 0:r.operationIndex,`OperationBuilder validation failed: ${i}`)}this.inFlight=true;try{let i=await W(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:this});return this.submitted=!0,i}catch(i){throw i instanceof k&&(this.submitted=true),i}finally{this.inFlight=false;}}statedShapes(e$1,t,r,i){let o=[e$1.shapes!==void 0,e$1.shapeless!==void 0,e$1.keepShapes!==void 0].filter(Boolean).length;if(o!==1)throw new y(t,o===0?`${r} states no Shapes: pass shapes: ['Shape', ...], shapeless: true${r==="revise"?", or keepShapes: true":""}`:"state Shapes one way: shapes, shapeless, or keepShapes");if(e$1.keepShapes!==void 0){if(r==="add"||e$1.keepShapes!==true)throw new y(t,"keepShapes applies only to a revise: an add states its shapes, or shapeless");return}if(e$1.shapeless!==void 0){if(e$1.shapeless!==true)throw new y(t,"shapeless must be true");if(e(i))throw new y(t,`"${i}" is a Shape: write it with shapes: [], not shapeless`);return []}let s=[...e$1.shapes??[]];if(s.length===0&&!e(i))throw new y(t,`${r} "${i}" with shapes: [] is the raw spelling of a shapeless write; the builder takes shapeless: true`);return s}queue(e,t){let r=this.ops.length,i=Z(e,r),o=g(i.name);if(o!==void 0&&(i.operation==="add"||i.operation==="revise")){let s=ie(o,i.data,i.operation);if(s)throw new y(r,s)}if(this.shapes&&t!==void 0&&(i.operation==="add"||i.operation==="revise")&&"shapes"in i&&i.shapes!==void 0)for(let s of i.shapes){let a=this.shapes[s];if(!a)continue;let u=va(t,a);if(!u.valid)throw new y(r,`Shape validation failed for '${i.name}' (shape: ${s}): ${u.errors.join("; ")}`)}this.ops.push(Object.freeze(i));}assertNotSubmitted(){if(this.submitted)throw new y(void 0,"OperationBuilder: already submitted, cannot modify")}assertCanModify(){if(this.assertNotSubmitted(),this.inFlight)throw new y(void 0,"OperationBuilder: stream submission already in flight, cannot modify")}};function mr(n){return {...n,createdAt:new Date(n.createdAt),updatedAt:new Date(n.updatedAt),runStartedAt:new Date(n.runStartedAt),...n.state==="complete"||n.state==="failed"?{completedAt:new Date(n.completedAt)}:{}}}function Fn(n){return {...n,expiresAt:new Date(n.expiresAt)}}function hr(n){if(typeof n.checkpointId=="string"&&typeof n.repoSeq!="number")return {by:"id",checkpointId:n.checkpointId};if(typeof n.repoSeq=="number"&&typeof n.checkpointId!="string")return {by:"repoSeq",repoSeq:n.repoSeq};throw new TypeError("Repository checkpoint selector must contain exactly one of checkpointId or repoSeq")}function gr(n,e){return {status:async(t,r,i)=>{try{let o=await n().repo.checkpoint.status.query({orgName:t,repoName:r,selector:hr(i)});return mr(o)}catch(o){throw e(o)}},latest:async(t,r)=>{try{let i=await n().repo.checkpoint.latest.query({orgName:t,repoName:r});return i.checkpoint?mr(i.checkpoint):null}catch(i){throw e(i)}},getAccess:async(t,r,i)=>{try{let o=await n().repo.checkpoint.access.query({orgName:t,repoName:r,selector:i.checkpoint==="latest"?{by:"latest"}:hr(i.checkpoint),artifact:i.artifact==="archive"||i.artifact==="manifest"?{kind:i.artifact}:{kind:"chunk",path:i.artifact.chunkPath}});return Fn(o)}catch(o){throw e(o)}}}}var R=class extends Error{constructor(t,r){super(r??Hn[t]);this.reason=t;}reason;name="RepositoryExportError"},Hn={count_mismatch:"Repository export trailer record count does not match the rows read",digest_mismatch:"Repository export content digest does not match the trailer",fence_mismatch:"Repository export header and trailer disagree about atRepoSeq",format_mismatch:"Repository export delta and base use different format versions; take a fresh full export",header_invalid:"Repository export header is invalid",row_invalid:"Repository export row is invalid or not canonical",row_out_of_order:"Repository export rows are not strictly increasing by durableId (and by version within one Shape)",since_below_epoch_floor:"Repository export delta base is below the epoch floor",trailer_invalid:"Repository export trailer is invalid",truncated:"Repository export stream ended before its trailer"},oe=class{#e=sa();#i=sa();#o=0;#t;#r;#a;#s=false;#p=false;#n;get header(){return this.#t}get lastDurableId(){return this.#r?.durableId}get lastShapeVersion(){let e=this.#r;return e?.kind==="shape"&&(this.#t?.formatVersion??0)>=6?e.version:void 0}get rowCount(){return this.#e.rowCount}get segmentRowCount(){return this.#o}get contentSha256(){return this.#n}finalizeContentSha256(){return this.#n===void 0&&(this.#n=this.#e.finalize(),this.#s=true),this.#n}beginSegment(){this.assertResumable(),this.#i=sa(),this.#o=0;}markUnverifiable(){this.#p=true;}finalizeSegment(){return this.#i.finalize()}get token(){return this.#a}set token(e){this.#a=e;}get complete(){return this.#s}markComplete(){this.finalizeContentSha256();}assertResumable(){if(this.#p)throw new R("digest_mismatch","Repository export session failed verification and cannot be resumed; start a new session");if(this.#s)throw new R("header_invalid","Repository export session is already complete; start a new session")}adoptHeader(e){this.assertResumable();let t=this.#t;if(t!==void 0&&(t.repo!==e.repo||t.mode!==e.mode||t.sinceRepoSeq!==e.sinceRepoSeq||t.atRepoSeq!==e.atRepoSeq))throw new R("header_invalid","Resumed repository export header does not match the opening header");if(t!==void 0&&t.formatVersion!==e.formatVersion)throw new R("header_invalid",`Resumed repository export is format ${e.formatVersion}, but it opened as format ${t.formatVersion}. Restart the export; a resume must use the format it started with.`);this.#t=e;}recordRow(e,t){let r=this.#t,i=this.#r;if(r?.mode==="heads"&&i!==void 0&&!na(i,e,r.formatVersion))throw new R("row_out_of_order",`Repository export row '${e.durableId}' v${e.version} does not follow '${i.durableId}' v${i.version}`);this.#e.update(t),this.#i.update(t),this.#o+=1,this.#r={durableId:e.durableId,kind:e.kind,version:e.version};}};function K(){return new oe}function Wn(n){return typeof n.get=="function"}function $n(n){return Wn(n)?n.values():n}function Gn(n,e){return e>=6&&n.kind==="shape"?`${n.durableId}@v${n.version}`:n.durableId}function yr(n,e,t){if(t.base>=6!=t.delta>=6)throw new R("format_mismatch",`Repository export delta is format ${t.delta} but its base is format ${t.base}; take a fresh full export instead of folding across formats`);let r=new Map;for(let[i,o]of [[n,t.base],[e,t.delta]])for(let s of $n(i)){if(!s.active&&o>=6&&s.kind==="shape"){let u=`${s.durableId}@v`;for(let d of r.keys())d.startsWith(u)&&r.delete(d);continue}let a=Gn(s,o);s.active?r.set(a,s):r.delete(a);}return r}var fr=10,Kn=new TextDecoder;function jn(n){let e=n.header;if(!e)throw new R("header_invalid","Repository export resumed without an opening header to inherit");return e}async function zn(n,e,t){let r=await n.next();if(r.done)throw new R("truncated");let i;try{i=qa(r.value);}catch(o){Xe("header_invalid",o);}if(!la.includes(i.formatVersion)||t!==void 0&&(i.repo!==t.repo||i.mode!==t.mode||t.sinceRepoSeq!==void 0&&i.sinceRepoSeq!==t.sinceRepoSeq||t.atRepoSeq!==void 0&&i.atRepoSeq!==t.atRepoSeq))throw new R("header_invalid",t===void 0?`Repository export header declares format version ${i.formatVersion}; expected one of ${la.join(", ")}`:`Repository export header describes ${i.repo} (${i.mode}, ${i.sinceRepoSeq}..${i.atRepoSeq}); expected ${t.repo} (${t.mode}${t.sinceRepoSeq!==void 0?`, since ${t.sinceRepoSeq}`:""}${t.atRepoSeq!==void 0?`, at ${t.atRepoSeq}`:""})`);return e.adoptHeader(i),i}async function*Qn(n,e){let t=new Uint8Array(0);for await(let r of Yn(n)){let i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),t=i;let o=t.indexOf(fr);for(;o!==-1;)yield t.subarray(0,o+1),t=t.subarray(o+1),o=t.indexOf(fr);}e.unterminated=t.length>0;}function Yn(n){return Symbol.asyncIterator in n?n:{async*[Symbol.asyncIterator](){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;r&&(yield r);}}finally{e.releaseLock();}}}}function Jn(n){try{let e=JSON.parse(Kn.decode(n));if(e!==null&&typeof e=="object"&&"kind"in e){let t=e.kind;if(typeof t=="string")return t}}catch{}return ""}function Xe(n,e){throw e instanceof R?e:new R(n,e instanceof Error?e.message:void 0)}async function*se(n,e,t,r={}){yield*br(n,e,t,r);}async function Rr(n,e={}){let t=K(),r=br(n,t,void 0,e);for await(let i of r)e.onRow?.(i);return t}async function*br(n,e,t,r){let i={unterminated:false},o=Qn(n,i);try{yield*Xn(o,i,e,t,r);}finally{await o.return(void 0);}}async function*Xn(n,e,t,r,i){t.assertResumable();let o=i.resumed===true?jn(t):await zn(n,t,r),s=oa(o);for(t.beginSegment();;){let a=await n.next();if(a.done){if(i.partial===true)return;throw new R("truncated")}let u=a.value;if(Jn(u)!=="trailer"){let l;try{l=pa(u);}catch(m){Xe("row_invalid",m);}if(!l.active&&!s)throw new R("row_invalid","Repository export tombstone is not legal in a full export");t.recordRow(l,u),yield l;continue}let d;try{if(d=ra(u),d.atRepoSeq!==o.atRepoSeq)throw new R("fence_mismatch");if(d.recordCount!==t.segmentRowCount)throw new R("count_mismatch");if(d.contentSha256!==t.finalizeSegment())throw new R("digest_mismatch")}catch(l){if(t.markUnverifiable(),l instanceof R)throw l;Xe("trailer_invalid",l);}if(!(await n.next()).done||e.unterminated)throw new R("trailer_invalid","Repository export stream continues past its trailer");t.markComplete();return}}var Zn="since-below-epoch-floor",ei=1e3,ti=50,ri=3;function Ze(n,e,t){let r=new URLSearchParams;for(let[o,s]of Object.entries(t))s!==void 0&&r.set(o,String(s));let i=r.toString();return `/api/repos/${encodeURIComponent(n)}/${encodeURIComponent(e)}/export${i?`?${i}`:""}`}function Sr(n){let e=n?.reason;return e instanceof Error?e:new Error("Repository export was aborted")}function ni(n){return n===void 0||!Number.isFinite(n)?ei:Math.max(n,ti)}async function ii(n,e){if(e?.aborted)throw Sr(e);await new Promise((t,r)=>{let i=()=>{clearTimeout(o),r(Sr(e));},o=setTimeout(()=>{e?.removeEventListener("abort",i),t();},n);e?.addEventListener("abort",i,{once:true});});}async function oi(n,e){let t;try{t=await n.clone().json();}catch{}return (t?.code??t?.error?.code)===Zn?new R("since_below_epoch_floor",t?.message):t?.code!==void 0&&t.error===void 0?await e(new Response(JSON.stringify({error:t}),{status:n.status,headers:{"content-type":"application/json"}})):await e(n)}function si(n){let e=n;return typeof e?.url=="string"&&e.url!==""&&typeof e.expiresAt=="number"&&typeof e.atRepoSeq=="number"&&typeof e.recordCount=="number"&&typeof e.contentSha256=="string"}async function ai(n){let e;try{e=await n.json();}catch{throw new R("header_invalid","Repository export redemption did not return a JSON download envelope")}if(!si(e))throw new R("header_invalid","Repository export download envelope must carry url, expiresAt, atRepoSeq, recordCount, and contentSha256");return e}function pi(n,e){let t=n.header?.atRepoSeq;if(t!==e.atRepoSeq)throw new R("fence_mismatch",`Repository export download is pinned to ${t}; the redemption named ${e.atRepoSeq}`);if(n.rowCount!==e.recordCount)throw new R("count_mismatch",`Repository export download carried ${n.rowCount} rows; the redemption named ${e.recordCount}`);if(n.contentSha256!==e.contentSha256)throw new R("digest_mismatch","Repository export download digest does not match the digest the redemption named")}function et(n,e,t=(r,i)=>globalThis.fetch(r,i)){let r=async(a,u)=>{let d=await n(a,{method:"GET",headers:{accept:ma},...u?{signal:u}:{}});if(!d.ok&&d.status!==202)throw await oi(d,e);return d},i=async(a,u,d={})=>{let m=await(await r(Ze(a,u,{mode:d.mode??"heads",sinceRepoSeq:d.sinceRepoSeq,atRepoSeq:d.atRepoSeq,prefer:"async"}),d.signal)).json();if(typeof m.exportToken!="string"||typeof m.atRepoSeq!="number")throw new R("header_invalid","Repository export async request did not return an exportToken and atRepoSeq");return {exportToken:m.exportToken,atRepoSeq:m.atRepoSeq}};return {prepare:i,stream:(a,u,d={})=>{let l=d.session?.lastDurableId??d.afterDurableId;if(l!==void 0&&(d.token!==void 0||d.session?.token!==void 0||d.prefer==="async"))throw new R("header_invalid",`Repository export token download cannot continue from '${l}': redemption returns the whole prepared object. Start a new session and redeem the token again.`);if(d.afterDurableId!==void 0&&d.session?.header===void 0)throw new R("header_invalid","Repository export afterDurableId needs a session carrying the opening header; reuse the session the broken stream wrote, or rebuild one with restoreRepositoryExportSession");return s(a,u,d)}};async function*s(a,u,d){let l=d.session??K(),m=l.header,h=d.signal,g=l.lastDurableId??d.afterDurableId,b={mode:m?.mode??d.mode??"heads",sinceRepoSeq:m?.sinceRepoSeq??d.sinceRepoSeq,atRepoSeq:m?.atRepoSeq??d.atRepoSeq,afterDurableId:g,afterVersion:l.lastDurableId===void 0?void 0:l.lastShapeVersion,formatVersion:g===void 0?void 0:m?.formatVersion},S={repo:`${a}/${u}`,mode:b.mode,...d.sinceRepoSeq===void 0?{}:{sinceRepoSeq:d.sinceRepoSeq},...d.atRepoSeq===void 0?{}:{atRepoSeq:d.atRepoSeq}};if(d.token!==void 0&&l.token!==void 0&&d.token!==l.token)throw new R("header_invalid",`Repository export session was redeeming token ${l.token}; resuming it with token ${d.token} would splice two exports`);let w=d.token??l.token;if(w!==void 0){l.token=w,yield*_(w);return}if(d.prefer==="async"){let E=await i(a,u,{mode:b.mode,...b.sinceRepoSeq===void 0?{}:{sinceRepoSeq:b.sinceRepoSeq},...b.atRepoSeq===void 0?{}:{atRepoSeq:b.atRepoSeq},...h?{signal:h}:{}});l.token=E.exportToken,yield*_(E.exportToken);return}let C=await r(Ze(a,u,b),h);if(!C.body)throw new R("truncated");yield*se(C.body,l,S,{resumed:b.afterDurableId!==void 0});async function*_(E){for(let v=1;;v+=1){let pe=await Y(E);try{yield*Q(pe);return}catch(_e){if(!(!(_e instanceof R)||_e.reason==="truncated")||l.rowCount>0||v>=ri||h?.aborted===true)throw _e}}}async function*Q(E){let v=await t(E.url,h?{signal:h}:{});if(!v.ok||!v.body)throw await v.body?.cancel(),new R("truncated",`Repository export download returned HTTP ${v.status}`);yield*se(v.body,l,S,{resumed:false}),pi(l,E);}async function Y(E){let v=Ze(a,u,{token:E});for(;;){let pe=await r(v,h);if(pe.status!==202)return await ai(pe);await ii(ni(d.pollIntervalMs),h);}}}}var Er="warmhub/streaming-submission-manifest/v1",ci=new TextEncoder,rt=z$1.string().regex(/^sha256:[0-9a-f]{64}$/),Or={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()},ui=z$1.enum(z$2),di=z$1.enum([...z$2,"noop"]),Ir=z$1.object({path:z$1.string(),message:z$1.string()}),vr=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(),xr=z$1.object({added:z$1.array(z$1.string()),removed:z$1.array(z$1.string()),ignored:z$1.array(z$1.string())}),li=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.iso.datetime()}),z$1.object({reason:z$1.literal("validation_failed"),issues:z$1.array(Ir)}),z$1.object({reason:z$1.literal("rate_limit_reset"),retryAfterSeconds:z$1.number().int().positive(),resetAt:z$1.iso.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)})]),mi=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.iso.datetime()}).strict(),z$1.object({reason:z$1.literal("validation_failed"),issues:z$1.array(Ir.strict())}).strict(),z$1.object({reason:z$1.literal("rate_limit_reset"),retryAfterSeconds:z$1.number().nonnegative(),resetAt:z$1.iso.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(),z$1.object({reason:z$1.literal("name_taken"),name:z$1.string().min(1),takenBy:z$1.object({durableId:z$1.string().min(1)}).loose().optional()}).loose(),z$1.object({reason:z$1.literal("target_removed"),targetDurableId:z$1.string().min(1),fieldPath:z$1.string().optional()}).loose(),z$1.object({reason:z$1.literal("target_redacted"),targetDurableId:z$1.string().min(1),fieldPath:z$1.string().optional()}).loose()]),wr={...Or,operation:ui,submittedName:z$1.string().optional(),resolvedName:z$1.string().optional(),warnings:vr,affirmations:xr.optional()},hi=z$1.union([z$1.looseObject({...Or,operation:di.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:li.optional()}).optional(),resolvedName:z$1.string().optional(),retryable:z$1.boolean().optional(),warnings:vr,affirmations:xr.optional()}),z$1.looseObject({...wr,status:z$1.enum(["applied","noop"]),version:z$1.number().int().positive().optional(),dataHash:z$1.string().min(1).optional()}),z$1.looseObject({...wr,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:mi.optional(),retryable:z$1.boolean().optional()}).strict()).min(1)})]),kr=z$1.object({applied:z$1.number().int().nonnegative(),noop:z$1.number().int().nonnegative(),failed:z$1.number().int().nonnegative()}),gi=z$1.looseObject({type:z$1.literal("group"),chunkOrdinal:z$1.number().int().nonnegative(),eventRequestId:z$1.uuid(),requestDigest:rt,outcome:z$1.enum(["event","no_event"]),repoSeq:z$1.number().int().nonnegative().optional(),operations:kr,manifestDigest:rt}),yi=z$1.looseObject({type:z$1.literal("summary"),submissionId:z$1.uuid(),streamId:z$1.string().min(1),groupSize:z$1.number().int().positive(),groups:z$1.number().int().nonnegative(),operations:kr.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:rt})}),fi=z$1.looseObject({type:z$1.literal("error"),code:z$1.string().min(1),message:z$1.string().optional()}),Ri=z$1.union([hi,gi,yi,fi]),tt=()=>({applied:0,noop:0,failed:0}),Cr=(n,e)=>n.applied===e.applied&&n.noop===e.noop&&n.failed===e.failed,bi=new Set(["complete","operation-limit-reached","group-limit-reached"]),T=class extends Error{constructor(t,r){super(`Streaming submission protocol error at row ${r}: ${t}`);this.rowIndex=r;this.name="StreamingSubmissionProtocolError";}rowIndex};async function Ar(n){let e=ci.encode(n),t=await globalThis.crypto.subtle.digest("SHA-256",e);return `sha256:${Array.from(new Uint8Array(t),r=>r.toString(16).padStart(2,"0")).join("")}`}async function Si(n,e,t){return Ar(`${Er}\0${n}\0${e}\0${t}`)}function wi(n){return n.status==="failed"||n.status==="error"?"failed":n.status==="noop"||n.operation==="noop"?"noop":"applied"}var nt=class{index=0;groupCount=0;resultCount=0;pendingCount=0;pendingCounts=tt();totalCounts=tt();firstRepoSeq=null;lastRepoSeq=null;manifestDigest=Ar(Er);terminalSeen=false;accept(e){let t=r=>{throw new T(r,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 r=wi(e);this.pendingCounts[r]+=1,this.totalCounts[r]+=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"),Cr(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(r=>Si(r,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=tt(),this.index+=1;}async acceptSummary(e,t){Cr(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"),(bi.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 T("Response must end with a summary or error row",this.index)}};function Ci(n,e){let t;try{t=JSON.parse(n);}catch(i){throw new T(i instanceof Error?i.message:"Invalid JSON",e)}let r=Ri.safeParse(t);if(!r.success)throw new T(r.error.issues[0]?.message??"Malformed row",e);return r.data}async function*Tr(n,e){let t=n.body?.getReader();if(!t)throw new T("Missing response body",0);let r=new nt,i=new TextDecoder,o="",s=0,a=false,u,d=m=>{if(m.endsWith("\r")&&(m=m.slice(0,-1)),m.length===0)throw new T("Blank response row",s);let h=Ci(m,s);return {pending:r.accept(h),row:h}},l=m=>{if(m.type==="summary"&&e!==void 0&&(m.submissionId!==e.submissionId||m.streamId!==e.streamId||m.groupSize!==e.groupSize))throw new T("Summary identity does not match the submission handle",s);s+=1;};try{for(;;){let{done:m,value:h}=await t.read();if(m)break;for(o+=i.decode(h,{stream:!0});;){let g=o.indexOf(`
|
|
3
|
-
`);if(g===-1)break;let b=o.slice(0,g);o=o.slice(g+1);let{pending:S,row:w}=d(b);S&&await S,l(w),w.type==="summary"||w.type==="error"?u=w:yield w;}}if(o+=i.decode(),o.length>0){let{pending:m,row:h}=d(o);m&&await m,l(h),h.type==="summary"||h.type==="error"?u=h:yield h;}r.finish(),a=!0,u&&(yield u);}finally{if(!a)try{await t.cancel();}catch{}t.releaseLock();}}var D=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 xe(n){return n===void 0||n===""?void 0:n}function Ei(){let n=globalThis;if(n.Bun!==void 0)return true;let e=n.process?.versions?.node;if(!e)return false;let[t=0,r=0]=e.split(".").map(Number);return t>22||t===22&&r>=2}function Oi(n){let e=new URLSearchParams({submissionId:n.submissionId,groupSize:String(n.groupSize)});return n.message!==void 0&&e.set("message",n.message),n.committer!==void 0&&e.set("committer",n.committer),`/api/repos/${encodeURIComponent(n.orgName)}/${encodeURIComponent(n.repoName)}/streams/${encodeURIComponent(n.streamId)}/submissions?${e}`}function Ii(n,e,t,r){let i=Oe(n,false,r),o=U(r,t),s=0,a=false,u=async m=>{try{await m;}catch{}},d=()=>{if(!a){a=true;try{let m=i.returnSourceOnce();m&&u(m);}catch{}}};return {stream:new ReadableStream({async pull(m){try{let h=[],g=s,b=!1;for(;;){let S=await i.next();if(a)return;if(!(!S.done&&(h.push(S.value),s+=1,b||=L(S.value),b&&s%e!==0))){for(let w of await o(h,g))m.enqueue(ze(w));S.done&&m.close();return}}}catch(h){m.error(h),d();}},cancel(){d();}}),returnSourceOnce:d}}function vi(n,e){if(!n)return ()=>{};let t=()=>e.abort(n.reason);return n.aborted?t():n.addEventListener("abort",t,{once:true}),()=>n.removeEventListener("abort",t)}function xi(n){let e=n.options?.submissionId??F();return {orgName:n.orgName,repoName:n.repoName,streamId:n.options.streamId,submissionId:e,groupSize:Ie(n.options.groupSize),...xe(n.message)!==void 0?{message:xe(n.message)}:{},...xe(n.options?.committer)!==void 0?{committer:xe(n.options?.committer)}:{}}}function Nr(n,e){if(!n.options.streamId)throw e.localError("VALIDATION_ERROR","Streaming submissions require a non-empty streamId.");let t=xi(n),r=new AbortController,i=()=>{},o,s=false,a=async function*(){let u=false,d=false,l;try{let m=V(e.sender??{},n.operations);if(!(e.runtimeSupported??Ei)())throw e.localError("VALIDATION_ERROR","Streaming submissions require Bun or Node.js 22.2 or newer.");if(i=vi(n.options.signal,r),r.signal.aborted)throw e.localError("CANCELLED","Streaming submission was aborted.");let h=await e.prepare(Oi(t));if(r.signal.aborted)throw e.localError("CANCELLED","Streaming submission was aborted.");l=Ii(n.operations,t.groupSize,e.readThings,m),u=!0;let g=await h.dispatch(l.stream,r.signal);if(!g.ok)throw d=!0,await h.httpError(g);for await(let b of Tr(g,t))yield b;}catch(m){throw m instanceof D?m:u&&!d?new D(t,m):e.normalizeLocalError(m)}finally{r.abort(),l?.returnSourceOnce(),i(),s=true;}};return {retryIdentity:t,[Symbol.asyncIterator](){return this},next(){return s?Promise.resolve({done:true,value:void 0}):(o??=a(),o.next())},async return(u){return r.abort(),o?o.return(u):(s=true,i(),{done:true,value:u})},async throw(u){if(r.abort(u),!o)throw s=true,i(),u;return o.throw(u)}}}var ki="0.0.0-development";function j(n){return n===ki}var it="0.151.0";var Pr=3;function Ai(n){return n===v?"Run: wh update --yes":n===u?"Run: npm install @warmhub/sdk-ts@latest (or your package manager's equivalent).":n===w?"Run: pip install --upgrade warmhub":`Deploy a released ${n} build that satisfies the backend compatibility contract.`}function Dr(n,e){if(typeof n?.minSupportedClients!="object"||n.minSupportedClients===null||!Number.isSafeInteger(n.writeContractVersion)||n.writeContractVersion<1)return {message:"The backend does not advertise valid per-client write compatibility data.",hint:"Upgrade the WarmHub backend before retrying this write."};let t=n.minSupportedClients[e.name],r=typeof t=="string"?K$1(t):null;if(!r)return {message:`The backend does not advertise a valid compatibility floor for ${e.name}.`,hint:"Upgrade the WarmHub backend or register this first-party client family before writing."};if(!j(e.version)){let i=K$1(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(L$1(i,r)<0)return {message:`${e.name} ${e.version} is older than the backend's minimum supported version ${r}.`,hint:Ai(e.name)}}if(n.writeContractVersion<Pr)return {message:`${e.name} requires write contract ${Pr}, but the backend provides ${n.writeContractVersion}.`,hint:"Upgrade the WarmHub backend before retrying this write."}}function Lr(n,e){try{return new URL(n).origin===new URL(e).origin}catch{return false}}var Ti=new Set(["GET","POST","PUT","PATCH","DELETE"]),x=class extends Error{reason;constructor(e,t){super(t),this.name="CliCallVerificationError",this.reason=e;}};async function _i(n,e,t){let r=n.method.toUpperCase();if(!Ti.has(r))throw new x("unsupported-method",`Unsupported HTTP method "${n.method}" \u2014 component CLI dispatch only emits GET, POST, PUT, or PATCH`);let i=r,o=n.headers.get(B$1);if(!o)throw new x("missing-install-repo",`Missing ${B$1} header`);let s=z(e.CLI_SIGNING_SECRET),a=z(e.CLI_BEARER_TOKEN),u=z(e.CLI_API_KEY),d=z(e.CLI_BASIC_USERNAME)&&z(e.CLI_BASIC_PASSWORD);if(!s&&!a&&!u&&!d)throw new x("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(a&&d)throw new x("no-scheme-configured","unsupported-scheme-combination: CLI_BEARER_TOKEN and CLI_BASIC_USERNAME + CLI_BASIC_PASSWORD both use the Authorization header and cannot be configured together");let l=new URL(n.url),m=l.pathname,h,g,b;if(E(i)?h={}:(h=Object.fromEntries(l.searchParams.entries()),g="",b={...h}),s){let S=n.headers.get(C);if(!S)throw new x("missing-signature",`Missing ${C} header`);let w=n.headers.get(D$1);if(!w)throw new x("missing-timestamp",`Missing ${D$1} header`);let C$1=Number(w);if(!Number.isFinite(C$1)||!Number.isInteger(C$1))throw new x("invalid-timestamp",`${D$1} must be an integer unix seconds value; got "${w}"`);g=await Mr(n,i,g);let _=await F$1({secret:e.CLI_SIGNING_SECRET,method:i,path:m,query:h,installRepo:o,body:g,signature:S,timestamp:C$1,nowUnixSeconds:t?.nowUnixSeconds??Math.floor(Date.now()/1e3),toleranceSec:t?.toleranceSec});if(!_.ok)throw new x(_.reason,`HMAC verification failed: ${_.reason}`)}if(a){let S=`Bearer ${e.CLI_BEARER_TOKEN}`,w=n.headers.get("authorization")??"";if(!await ot(w,S))throw new x("invalid-bearer","invalid-bearer: bearer token mismatch")}if(u){let S=z(e.CLI_API_KEY_HEADER)?e.CLI_API_KEY_HEADER:"X-API-Key",w=n.headers.get(S)??"";if(!await ot(w,e.CLI_API_KEY))throw new x("invalid-api-key",`invalid-api-key: mismatch on header "${S}"`)}if(d){let S=`Basic ${btoa(`${e.CLI_BASIC_USERNAME}:${e.CLI_BASIC_PASSWORD}`)}`,w=n.headers.get("authorization")??"";if(!await ot(w,S))throw new x("invalid-basic","invalid-basic: basic auth mismatch")}return b===void 0&&(g=await Mr(n,i,g),b=Ni(g)),{method:i,installRepo:o,args:b}}async function Mr(n,e,t){return E(e)?t!==void 0?t:n.text():""}function Ni(n){let e;try{e=JSON.parse(n);}catch{throw new x("invalid-body","POST body is not valid JSON")}if(!Pi(e))throw new x("invalid-body","POST body must be a JSON object of primitive args (string / number / boolean)");return e}function z(n){return typeof n=="string"&&n.length>0}function Pi(n){if(typeof n!="object"||n===null||Array.isArray(n))return false;for(let e of Object.values(n))if(e!==void 0&&typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return false;return true}async function ot(n,e){let[t,r]=await Promise.all([qr(n),qr(e)]),i=0;for(let o=0;o<t.length;o++)i|=t[o]^r[o];return i===0}async function qr(n){return new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)))}function za(n){return h(n)}var Ui={apiUrl:true,fetch:true,accessToken:true,auth:true,functionLogs:true,client:true,clientFlags:true,decorateResponses:true},jr=Object.keys(Ui),Bi=new Set(jr),Vi=new Set(["token","apiKey","bearer"]);function Fi(n){if(n)for(let e of Object.keys(n)){if(Bi.has(e))continue;let t=Vi.has(e)?'; did you mean "accessToken"?':`. Valid options are: ${jr.join(", ")}.`;throw new TypeError(`Unknown WarmHubClient option "${e}"${t}`)}}function Hi(n){if(!n||n.length===0)return [];for(let e of n)if(!r(e))throw new TypeError(`Invalid client flag "${e}": expected lowercase tokens matching [a-z0-9-]+.`);return [...new Set(n)].sort()}var Br="https://api.warmhub.ai",Wi=new Set(["commit.validate","repo.shapeInstanceCounts","thing.getMany","thing.headVersions","thing.names"]),$i=500,Gi=500,Ki=1,ji=8;function Ae(n){return {...n,actionContainer:void 0,actionContainerConfig:void 0}}function zi(n){return n.map(e=>Ae(e))}function zr(n,e,t){if(e===n||t.has(e))throw new f("VALIDATION_ERROR","Paginated result cursor did not advance")}function Vr(n){if(n===void 0)throw new f("VALIDATION_ERROR","sinceRepoSeq is required for an incremental read")}async function*Qr(n,e){let t=e,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(yield i,!i.nextCursor)return;zr(t,i.nextCursor,r),t=i.nextCursor;}}async function*O(n,e,t){for await(let r of Qr(n,t))yield*e(r);}async function I(n,e,t,r){if(t!==void 0&&(!Number.isFinite(t)||Math.trunc(t)!==t||t<0))throw new f("VALIDATION_ERROR","max must be a nonnegative integer");let i=[];for await(let o of Qr(n,r)){let s=e(o);if(t!==void 0&&i.length+s.length>t)throw new f("VALIDATION_ERROR",`Paginated result exceeded max=${t}`);i.push(...s);}return i}function Fr(n){if(n?.slugs!==void 0)throw new f("VALIDATION_ERROR","repo.explore pagination helpers do not support slugs mode")}async function Hr(n){let e=[],t,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(e.push(...i.items),!i.nextCursor){if(i.repoSeq===void 0)throw new f("VALIDATION_ERROR","Incremental read completed without repoSeq");return {items:e,repoSeq:i.repoSeq}}zr(t,i.nextCursor,r),t=i.nextCursor;}}function Wr(n,e,t){return Number.isFinite(n)?Math.max(1,Math.min(t,Math.trunc(n))):e}function Qi(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}async function st(n,e,t){if(n.length===0)return {requested:0,items:[],missing:[]};let r=Wr(e?.chunkSize,$i,Gi),i=Wr(e?.chunkConcurrency,Ki,ji);if(n.length<=r)return await t(n);let o=Qi(n,r),s=[];for(let a=0;a<o.length;a+=i){let u=o.slice(a,a+i),d=await Promise.all(u.map(t));s.push(...d);}return {requested:n.length,items:s.flatMap(a=>a.items),missing:s.flatMap(a=>a.missing)}}function ke(n){return n!==void 0&&A$1.includes(n)?n:void 0}function ae(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,name:r}:e}function Yi(n){let[e,t]=n;return typeof e=="string"?{orgName:e,repoName:t}:e}function Ji(n){let[e,t,r,i]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r,credentialSetName:i}:e}function Xi(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r}:e}function Zi(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function eo(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function ut(n){return !!n&&(!!n.shape||!!n.kind||!!n.about||!!n.match||!!n.componentRef||n.excludeComponents===true||(n.where?.length??0)>0)}function Te(n){return !!n&&(!!n.shape||!!n.about||!!n.match||!!n.componentRef||(n.where?.length??0)>0)}function Yr(n){let e=n.members;return Array.isArray(e)&&e.length>0}function to(n,e){if(ut(e.query)&&!Te(e.query))throw new f("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(e.sourceRepo&&!Te(e.query))throw new f("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(e.sourceRepo&&Yr(e))throw new f("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(ut(e.query)&&n!=="set")throw new f("VALIDATION_ERROR","Selector-backed collection sources are only supported for set collections")}function Qa(n){return n??"off"}function ro(n){if(n!==void 0)switch(n){case "BAD_REQUEST":case "PARSE_ERROR":case "PAYLOAD_TOO_LARGE":case "UNPROCESSABLE_CONTENT":case "UNSUPPORTED_MEDIA_TYPE":return "VALIDATION_ERROR";case "METHOD_NOT_SUPPORTED":return "NOT_FOUND";case "UNAUTHORIZED":return "UNAUTHENTICATED";case "FORBIDDEN":return "FORBIDDEN";case "NOT_FOUND":return "NOT_FOUND";case "CONFLICT":return "CONFLICT";case "PRECONDITION_FAILED":return "PRECONDITION_FAILED";case "TOO_MANY_REQUESTS":return "RATE_LIMITED";default:return}}function no(n){if(n===void 0||n===408)return;if(n===405)return "NOT_FOUND";if(n===412)return "PRECONDITION_FAILED";if(n===422)return "VALIDATION_ERROR";let e=Zr(n);return e!=="BACKEND"?e:n>=400&&n<500?"VALIDATION_ERROR":e}var io=[/\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 at(n){for(let e of io)if(e.test(n))return "An internal error occurred. Please try again or contact support.";return n}function $r(n,e){if(typeof e!="string")return;let t=l(n,e);if(t)throw new f("VALIDATION_ERROR",t)}function c(n){if(n instanceof f)return n;if(n instanceof TRPCClientError){if(n.cause instanceof f)return n.cause;let e=n.data,t=e?.warmhub?.code,r=typeof e?.code=="string"?ro(e.code):void 0,i=no(e?.httpStatus),o=e?.warmhub?.message??at(n.message);return new f(t??r??i??"BACKEND",o,e?.warmhub?.status??e?.httpStatus,e?.warmhub?.hint,e?.warmhub?.retryAfter??e?.retryAfter,t,e?.warmhub?.details)}if(n instanceof Error){let e=n;if(n.name==="WarmHubError"&&typeof e.code=="string"){let t=new f(e.code,at(n.message),typeof e.status=="number"?e.status:void 0,typeof e.hint=="string"?e.hint:void 0,typeof e.retryAfter=="number"?e.retryAfter:void 0,typeof e.errorCode=="string"?e.errorCode:typeof e.backendCode=="string"?e.backendCode:void 0,e.details);return dt(n)&&Object.defineProperty(t,Jr,{value:true}),t}return n.name==="AbortError"?new f("CANCELLED",n.message):n instanceof TypeError&&/fetch/i.test(n.message)?new f("NETWORK",n.message):new f("BACKEND",at(n.message))}return new f("BACKEND","Unknown SDK error")}var Jr=Symbol.for("@warmhub/sdk-ts:allStreamOperationsFailed");function dt(n){if(n instanceof A)return true;if(!(n instanceof Error))return false;let e=n;return e[Jr]===true||e.name==="WarmHubError"&&Array.isArray(e.receipts)&&Array.isArray(e.operations)}function Ya(n){return dt(n)}function oo(n){return n instanceof f}function Ja(n){if(n instanceof D||dt(n))return false;let e=c(n);return e.kind==="NETWORK"||e.kind==="CANCELLED"||e.kind==="BACKEND"||e.kind==="RATE_LIMITED"}var so=new Set(["ConnectionRefused","ECONNREFUSED","ENOTFOUND","ETIMEDOUT","EAI_AGAIN"]);function ao(n){if(n instanceof TypeError&&/fetch/i.test(n.message))return true;if(n&&typeof n=="object"){let e=n.code;if(typeof e=="string"&&so.has(e))return true}return false}function po(n){return `Unable to connect to ${n}. Is the computer able to access the url?`}function Xa(n,e){if(j(n))return false;let t=K$1(n),r=K$1(e);return !t||!r?false:L$1(t,r)<0}function Xr(n,e){return new f("CLIENT_INCOMPATIBLE",n,412,e)}function co(n,e){let t=Dr(n,e);if(t)throw Xr(t.message,t.hint)}function uo(n,e){if(!(n!=="thing.rename"||typeof e?.eventRequestId=="string"))return new f("VALIDATION_ERROR","thing.rename takes (orgName, repoName, name, newName, { eventRequestId }): name and newName are full Thing names. The v1 order (orgName, repoName, shapeName, oldName, newName, opts) is gone.")}var Gr=class n{apiUrl;fetchImpl;accessToken;clientIdentity;#e;decorateResponses;functionLogMode;getToken;compatibilityCheck;overrideNoticePrinted=false;repositoryExport=et((e,t)=>this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}${e}`,t),e=>this.httpResponseError(e),(e,t)=>{let r=this.legacyWrefsRefusal("read");if(r)throw r;return (this.fetchImpl??globalThis.fetch)(e,t)});noteCompatibilityOverride(){this.overrideNoticePrinted||(this.overrideNoticePrinted=true,console.error(`warmhub: compatibility checks overridden by client flag ${p}; the server remains authoritative.`));}assertWriteCompatible(){return this.clientFlags.includes(p)?(this.noteCompatibilityOverride(),Promise.resolve()):j(this.clientIdentity.version)&&Lr(this.apiUrl,Br)?Promise.reject(Xr(`Development client ${this.clientIdentity.name}/${this.clientIdentity.version} cannot write to production.`,"Install a released WarmHub client artifact before writing to api.warmhub.ai.")):j(this.clientIdentity.version)&&this.clientIdentity.name!==v?Promise.resolve():this.diagnostics.assertCompatible()}legacyWrefsRefusal(e){if(te(this.clientFlags)){if(!B(this))return He();if(e==="write")return new f("CLIENT_INCOMPATIBLE",Gt)}}pinnedShapeRefusal(e,t){if(e!=="stream.append"||te(this.clientFlags)&&B(this))return;let r=t?.operations;if(!Array.isArray(r))return;let i=r.findIndex(o=>Array.isArray(o?.shapes)&&o.shapes.some(s=>typeof s=="string"&&Ve(s)));return i<0?void 0:new y(i,Be)}createLegacyWrefsLink(){return ()=>({op:e,next:t})=>{let r=this.legacyWrefsRefusal(e.type!=="mutation"?"read":jt.has(e.path)||Kt.has(e.path)?"raw-commit":"write")??uo(e.path,e.input)??this.pinnedShapeRefusal(e.path,e.input);return r?observable(i=>{i.error(TRPCClientError.from(r));}):t(e)}}createCompatibilityLink(){return ()=>({op:e,next:t})=>e.type!=="mutation"||e.path==="commit.validate"?t(e):observable(r=>{let i=false,o;return (async()=>{try{await this.assertWriteCompatible();}catch(s){if(i)return;r.error(TRPCClientError.from(s));return}i||(o=t(e).subscribe(r));})(),()=>{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 f("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();co(t,this.clientIdentity);})();return this.compatibilityCheck=e,e.catch(t=>{oo(t)&&t.code==="CLIENT_INCOMPATIBLE"||this.compatibilityCheck===e&&(this.compatibilityCheck=void 0);}),e}};component={list:async(e,t,r)=>{try{return await this.trpc.component.list.query({orgName:e,repoName:t,limit:r?.limit,cursor:r?.cursor})}catch(i){throw c(i)}},listIter:(e,t,r)=>O(i=>this.component.list(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),listAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await I(s=>this.component.list(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},search:async(e,t)=>{try{return await this.trpc.component.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw c(r)}},searchIter:(e,t)=>O(r=>this.component.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await I(o=>this.component.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},get:async(e,t,r)=>{try{return await this.trpc.component.get.query({orgName:e,repoName:t,componentRef:r})}catch(i){throw c(i)}},history:async(e,t,r)=>{try{return await this.trpc.component.history.query({orgName:e,repoName:t,componentRef:r?.componentRef,limit:r?.limit})}catch(i){throw c(i)}},install:async(e,t,r,i)=>{try{return await this.trpc.component.install.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw c(o)}},uninstall:async(e,t,r,i)=>{try{return await this.trpc.component.uninstall.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw c(o)}},registry:{register:async(e,t,r)=>{try{return await this.trpc.component.registry.register.mutate({orgName:e,componentName:t,...r})}catch(i){throw c(i)}},unregister:async(e,t)=>{try{return await this.trpc.component.registry.unregister.mutate({orgName:e,componentName:t})}catch(r){throw c(r)}},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(r){throw c(r)}},update:async(e,t,r)=>{try{return await this.trpc.component.registry.update.mutate({orgName:e,componentName:t,...r})}catch(i){throw c(i)}},resolve:async(e,t,r)=>await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/resolve`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({installRepo:r})}),setupCall:async(e,t,r)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/setup-call`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)}))},cli:{call:async(e,t,r,i)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cli/${encodeURIComponent(r)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}))}};ops(e){return new G(e)}commit={validate:async(e,t,r,i)=>{try{return await sr(this.trpc.commit.validate,this.thingShapesReader(e,t),e,t,r,i,this)}catch(o){throw c(o)}},apply:async(e,t,r,i,o)=>{try{return await W(this,{orgName:e,repoName:t,committer:o?.committer,message:r,componentRef:o?.componentRef,chunkSize:o?.chunkSize,skipExisting:o?.skipExisting,streamId:o?.streamId,submissionId:o?.submissionId,returnRepoSeq:o?.returnRepoSeq,retry:o?.retry,operations:i})}catch(s){throw s instanceof k||s instanceof A?s:c(s)}},applyStreaming:(e,t,r,i,o)=>Nr({orgName:e,repoName:t,message:r,operations:i,options:o},{prepare:async s=>await this.prepareStreamingSubmissionRequest(s),localError:(s,a)=>new f(s,a),normalizeLocalError:c,readThings:this.thingShapesReader(e,t),sender:this}),getReceipt:async(e,t,r)=>{try{return await this.trpc.commit.getReceipt.query({orgName:e,repoName:t,eventRequestId:r})}catch(i){throw c(i)}},getReceiptMetadata:async(e,t,r)=>{try{return await this.trpc.commit.getReceiptMetadata.query({orgName:e,repoName:t,eventRequestId:r})}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,r)=>{try{return await this.trpc.org.create.mutate({name:e,displayName:t,description:r})}catch(i){throw c(i)}},setDescription:async(e,t)=>{try{return await this.trpc.org.setDescription.mutate({orgName:e,description:t})}catch(r){throw c(r)}},setDisplayName:async(e,t)=>{try{return await this.trpc.org.setDisplayName.mutate({orgName:e,displayName:t})}catch(r){throw c(r)}},rename:async(e,t)=>{try{return await this.trpc.org.rename.mutate({orgName:e,newName:t})}catch(r){throw c(r)}},update:async e=>{try{return await this.trpc.org.update.mutate(e)}catch(t){throw c(t)}},addMember:async(e,t,r="editor")=>{try{return await this.trpc.org.addMember.mutate({orgName:e,email:t,role:r})}catch(i){throw c(i)}},removeMember:async(e,t)=>{try{await this.trpc.org.removeMember.mutate({orgName:e,email:t});}catch(r){throw c(r)}},leave:async e=>{try{await this.trpc.org.leave.mutate({orgName:e});}catch(t){throw c(t)}},changeMemberRole:async(e,t,r)=>{try{return await this.trpc.org.changeMemberRole.mutate({orgName:e,email:t,role:r})}catch(i){throw c(i)}},setMemberScopes:async(e,t,r)=>{try{await this.trpc.org.setMemberScopes.mutate({orgName:e,email:t,scopes:r});}catch(i){throw c(i)}},clearMemberScopes:async(e,t)=>{try{await this.trpc.org.clearMemberScopes.mutate({orgName:e,email:t});}catch(r){throw c(r)}},listMembers:async(e,t)=>{try{return await this.trpc.org.listMembers.query({orgName:e,pending:t?.pending})}catch(r){throw c(r)}},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:gr(()=>this.trpc,c),export:(e,t,r)=>this.repositoryExport.stream(e,t,r),exportPrepare:(e,t,r)=>this.repositoryExport.prepare(e,t,r),get:async(e,t)=>{try{return await this.trpc.repo.get.query({orgName:e,repoName:t})}catch(r){throw c(r)}},getStats:async(e,t)=>{try{return await this.trpc.repo.stats.query({orgName:e,repoName:t})}catch(r){throw c(r)}},getStatsBatch:async(e,t)=>{try{return await this.trpc.repo.statsBatch.query({orgName:e,repoNames:t})}catch(r){throw c(r)}},getConfigureStats:async(e,t)=>{try{return await this.trpc.repo.configureStats.query({orgName:e,repoName:t})}catch(r){throw c(r)}},getShapeInstanceCounts:async(e,t)=>{try{return await this.trpc.repo.shapeInstanceCounts.query({orgName:e,repoName:t})}catch(r){throw c(r)}},list:async(e,t)=>{try{return await this.trpc.repo.list.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw c(r)}},listIter:(e,t)=>O(r=>this.repo.list(e,{...t,cursor:r}),r=>r.items,t?.cursor),listAll:async(e,t)=>{let{max:r,...i}=t??{};return await I(o=>this.repo.list(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},search:async(e,t)=>{try{return await this.trpc.repo.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw c(r)}},searchIter:(e,t)=>O(r=>this.repo.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await I(o=>this.repo.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},create:async(e,t,r,i,o)=>{try{return await this.trpc.repo.create.mutate({orgName:e,repoName:t,description:r,visibility:i,displayName:o})}catch(s){throw c(s)}},setDescription:async(e,t,r)=>{try{return await this.trpc.repo.setDescription.mutate({orgName:e,repoName:t,description:r})}catch(i){throw c(i)}},setDisplayName:async(e,t,r)=>{try{return await this.trpc.repo.setDisplayName.mutate({orgName:e,repoName:t,displayName:r})}catch(i){throw c(i)}},setVisibility:async(e,t,r)=>{try{return await this.trpc.repo.setVisibility.mutate({orgName:e,repoName:t,visibility:r})}catch(i){throw c(i)}},rename:async(e,t,r)=>{try{return await this.trpc.repo.rename.mutate({orgName:e,repoName:t,newName:r})}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(r){throw c(r)}},unarchive:async(e,t)=>{try{return await this.trpc.repo.unarchive.mutate({orgName:e,repoName:t})}catch(r){throw c(r)}},delete:async(e,t)=>{try{let r=await this.trpc.repo.delete.mutate({orgName:e,repoName:t});return {graceExpiresAt:new Date(r.graceExpiresAt)}}catch(r){throw c(r)}},listPage:async(e,t)=>{try{return await this.trpc.repo.listPage.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw c(r)}},listPageIter:(e,t)=>O(r=>this.repo.listPage(e,{...t,cursor:r}),r=>r.items,t?.cursor),listPageAll:async(e,t)=>{let{max:r,...i}=t??{};return await I(o=>this.repo.listPage(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},listForCaller:async e=>{try{return await this.trpc.repo.listForCaller.query({limit:e?.limit,sort:e?.sort})}catch(t){throw 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=>(Fr(e),O(t=>this.repo.explore({...e,cursor:t}),t=>t.items,e?.cursor)),exploreAll:async e=>{Fr(e);let{max:t,...r}=e??{};return await I(i=>this.repo.explore({...r,cursor:i}),i=>i.items,t,r.cursor)},getReadme:async(e,t)=>{try{return await this.trpc.repo.getReadme.query({orgName:e,repoName:t})}catch(r){throw c(r)}},getAgents:async(e,t)=>{try{return await this.trpc.repo.getAgents.query({orgName:e,repoName:t})}catch(r){throw c(r)}},getLicense:async(e,t)=>{try{return await this.trpc.repo.getLicense.query({orgName:e,repoName:t})}catch(r){throw c(r)}},describe:async(e,t,r={})=>{try{return await this.trpc.repo.describe.query({orgName:e,repoName:t,includeHead:r.includeHead})}catch(i){throw c(i)}},setReadme:async(e,t,r,i)=>{try{return $r("Readme.content",r),await this.trpc.repo.setReadme.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw c(o)}},setAgents:async(e,t,r,i)=>{try{return $r("Agents.content",r),await this.trpc.repo.setAgents.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw c(o)}},getLlmsTxt:async(e,t)=>{try{return await this.trpc.repo.getLlmsTxt.query({orgName:e,repoName:t})}catch(r){throw c(r)}},index:{describe:async(e,t)=>{try{return await this.trpc.repo.index.describe.query({orgName:e,repoName:t})}catch(r){throw c(r)}},pin:async(e,t,r,i)=>{try{return await this.trpc.repo.index.pin.mutate({orgName:e,repoName:t,shape:r,fieldPath:i})}catch(o){throw c(o)}},unpin:async(e,t,r,i)=>{try{return await this.trpc.repo.index.unpin.mutate({orgName:e,repoName:t,shape:r,fieldPath:i})}catch(o){throw c(o)}}}};shape={list:async(e,t,r)=>{try{return await this.trpc.shape.list.query({orgName:e,repoName:t,match:r?.match,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,includeRetracted:r?.includeRetracted})}catch(i){throw c(i)}},get:async(e,t,r,i)=>{try{return await this.trpc.shape.get.query({orgName:e,repoName:t,shapeName:r,includeRetracted:i?.includeRetracted})}catch(o){throw c(o)}},create:async(e,t,r,i,o)=>{let s=ie(r,{fields:i,...o.description!==void 0?{description:o.description}:{},...o.composes!==void 0?{composes:o.composes}:{}},"add");if(s)throw new f("VALIDATION_ERROR",s);try{return await this.trpc.shape.create.mutate({orgName:e,repoName:t,shapeName:r,fields:i,eventRequestId:o.eventRequestId,description:o.description,composes:o.composes})}catch(a){throw c(a)}},revise:async(...e)=>{let[t,r,i]=e,o=e.length===5?e[3]:void 0,s=e.length===5?e[4]:e[3],a=o?ie(i,{fields:o,...s.description!==void 0?{description:s.description}:{},...s.composes!==void 0?{composes:s.composes}:{}},"revise"):void 0;if(a)throw new f("VALIDATION_ERROR",a);try{return await this.trpc.shape.revise.mutate({orgName:t,repoName:r,shapeName:i,newFields:o,eventRequestId:s.eventRequestId,description:s.description,composes:s.composes})}catch(u){throw c(u)}},remove:async(e,t,r,i)=>{try{return await this.trpc.shape.remove.mutate({orgName:e,repoName:t,shapeName:r,eventRequestId:i.eventRequestId})}catch(o){throw c(o)}},rename:async(e,t,r,i,o)=>{try{return await this.trpc.shape.rename.mutate({orgName:e,repoName:t,oldName:r,newName:i,eventRequestId:o.eventRequestId})}catch(s){throw c(s)}},history:async(e,t,r,i={})=>{try{return await this.trpc.shape.history.query({orgName:e,repoName:t,name:r,includeRetracted:i.includeRetracted,limit:i.limit,cursor:i.cursor})}catch(o){throw c(o)}},historyIter:(e,t,r,i={})=>O(o=>this.shape.history(e,t,r,{...i,cursor:o}),o=>o.versions,i.cursor),historyAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await I(a=>this.shape.history(e,t,r,{...s,cursor:a}),a=>a.versions,o,s.cursor)}};subscription={create:async e=>{try{let t=await this.trpc.subscription.create.mutate(Zi(e));return Ae(t)}catch(t){throw c(t)}},get:async(...e)=>{try{let t=await this.trpc.subscription.get.query(ae(e));return Ae(t)}catch(t){throw c(t)}},reveal:async(...e)=>{try{return await this.trpc.subscription.reveal.query(ae(e))}catch(t){throw c(t)}},list:async(...e)=>{try{let t=await this.trpc.subscription.list.query(Yi(e));return zi(t)}catch(t){throw c(t)}},update:async e=>{try{let t=await this.trpc.subscription.update.mutate(eo(e));return Ae(t)}catch(t){throw c(t)}},pause:async(...e)=>{try{return await this.trpc.subscription.pause.mutate(ae(e))}catch(t){throw c(t)}},resume:async(...e)=>{try{return await this.trpc.subscription.resume.mutate(ae(e))}catch(t){throw c(t)}},remove:async(...e)=>{try{return await this.trpc.subscription.remove.mutate(ae(e))}catch(t){throw c(t)}},bindCredentials:async(...e)=>{try{return await this.trpc.subscription.bindCredentials.mutate(Ji(e))}catch(t){throw c(t)}},unbindCredentials:async(...e)=>{try{return await this.trpc.subscription.unbindCredentials.mutate(Xi(e))}catch(t){throw c(t)}}};action={acquireLease:async(e,t,r,i,o,s)=>{try{return await this.trpc.action.acquireLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,holderType:o,graceMs:s?.graceMs,ttlMs:s?.ttlMs})}catch(a){throw c(a)}},heartbeatLease:async(e,t,r,i,o)=>{try{return await this.trpc.action.heartbeatLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,ttlMs:o})}catch(s){throw c(s)}},releaseLease:async(e,t,r,i)=>{try{return await this.trpc.action.releaseLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i})}catch(o){throw c(o)}},claimDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.claimDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw c(s)}},completeDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.completeDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw c(s)}},liveFeed:async(e,t,r,i)=>{try{return await this.trpc.action.liveFeed.query({orgName:e,repoName:t,subscriptionName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},liveFeedIter:(e,t,r,i)=>O(o=>this.action.liveFeed(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),liveFeedAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await I(a=>this.action.liveFeed(e,t,r,{...s,cursor:a}),a=>a.items,o,s.cursor)},listRuns:async(e,t,r)=>{try{return await this.trpc.action.listRuns.query({orgName:e,repoName:t,runId:r?.runId,subscriptionName:r?.subscriptionName,status:r?.status,outcome:r?.outcome,since:r?.since,cursor:r?.cursor,limit:r?.limit})}catch(i){throw c(i)}},listRunsIter:(e,t,r)=>O(i=>this.action.listRuns(e,t,{...r,since:i===void 0?r?.since:void 0,cursor:i}),i=>i.items,r?.cursor),listRunsAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await I(s=>this.action.listRuns(e,t,{...o,since:s===void 0?o.since:void 0,cursor:s}),s=>s.items,i,o.cursor)},latestRuns:async(e,t)=>{try{return await this.trpc.action.latestRuns.query({orgName:e,repoName:t})}catch(r){throw c(r)}},runStats:async(e,t,r)=>{try{return await this.trpc.action.runStats.query({orgName:e,repoName:t,subscriptionName:r?.subscriptionName,since:r?.since})}catch(i){throw c(i)}},getRunAttempts:async(e,t,r)=>{try{return await this.trpc.action.getRunAttempts.query({orgName:e,repoName:t,runId:r})}catch(i){throw c(i)}},listNotifications:async(e,t,r)=>{try{return await this.trpc.action.listNotifications.query({orgName:e,repoName:t,since:r?.since,limit:r?.limit})}catch(i){throw c(i)}}};collection={create:async(e,t,r)=>{try{return to(r.type,r),await this.trpc.collection.create.mutate({orgName:e,repoName:t,eventRequestId:r.eventRequestId,type:r.type,name:r.name,members:r.members,from:r.from,add:r.add,remove:r.remove,replaceMembers:r.replaceMembers,query:r.query,sourceOrgName:r.sourceRepo?.orgName,sourceRepoName:r.sourceRepo?.repoName,skipExisting:r.skipExisting,message:r.message,committer:r.committer})}catch(i){throw c(i)}},members:async(e,t,r,i)=>{try{return await this.trpc.collection.members.query({orgName:e,repoName:t,wref:r,version:i?.version,limit:i?.limit,cursor:i?.cursor,shape:i?.shape})}catch(o){throw c(o)}},membersIter:(e,t,r,i)=>{let o=i?.version;return O(async s=>{let a=await this.collection.members(e,t,r,{...i,version:o,cursor:s});return o??=a.version,a},s=>s.items,i?.cursor)},membersAll:async(e,t,r,i)=>{let{max:o,...s}=i??{},a=s.version;return await I(async u=>{let d=await this.collection.members(e,t,r,{...s,version:a,cursor:u});return a??=d.version,d},u=>u.items,o,s.cursor)},contains:async(e,t,r,i,o)=>{try{return await this.trpc.collection.contains.query({orgName:e,repoName:t,wref:r,version:o?.version,members:i,position:o?.position,shape:o?.shape})}catch(s){throw c(s)}},diff:async(e,t,r,i,o)=>{try{return await this.trpc.collection.diff.query({orgName:e,repoName:t,leftWref:r,rightWref:i,leftVersion:o?.leftVersion,rightVersion:o?.rightVersion,mode:o?.mode,shape:o?.shape})}catch(s){throw c(s)}},revise:async(e,t,r,i)=>{try{if(ut(i.query)&&!Te(i.query))throw new f("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(i.sourceRepo&&!Te(i.query))throw new f("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(i.sourceRepo&&Yr(i))throw new f("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");return await this.trpc.collection.revise.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,wref:r,members:i.members,add:i.add,remove:i.remove,query:i.query,sourceOrgName:i.sourceRepo?.orgName,sourceRepoName:i.sourceRepo?.repoName,message:i.message,committer:i.committer})}catch(o){throw c(o)}},stats:async(e,t,r,i)=>{try{return await this.trpc.collection.stats.query({orgName:e,repoName:t,wref:r,version:i?.version,shape:i?.shape})}catch(o){throw c(o)}}};view={evaluate:async(e,t,r,i)=>{try{return await this.trpc.view.evaluate.query({orgName:e,repoName:t,wref:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},evaluateIter:(e,t,r,i)=>O(o=>this.view.evaluate(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),evaluateAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await I(a=>this.view.evaluate(e,t,r,{...s,cursor:a}),a=>a.items,o,s.cursor)}};grant=lr(()=>this.trpc,c);thing={head:async(e,t,r)=>{try{return await this.trpc.thing.head.query({orgName:e,repoName:t,shape:r?.shape,declaredShape:r?.declaredShape,shapeless:r?.shapeless,includeValidatedShapes:r?.includeValidatedShapes,kind:ke(r?.kind),match:r?.match,dataMode:r?.dataMode,includeRetracted:r?.includeRetracted,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw c(i)}},headIter:(e,t,r)=>O(i=>this.thing.head(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),headAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await I(s=>this.thing.head(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},headChanges:async(e,t,r)=>(Vr(r?.sinceRepoSeq),await Hr(i=>this.thing.head(e,t,{...r,includeRetracted:true,cursor:i}))),get:async(e,t,r,i,o)=>{try{return await this.trpc.thing.get.query({orgName:e,repoName:t,wref:r,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode})}catch(s){throw c(s)}},getWithLease:async(e,t,r,i)=>{try{return await this.trpc.thing.getWithLease.mutate({orgName:e,repoName:t,wref:r,ttlMs:i?.ttlMs})}catch(o){throw c(o)}},releaseLease:async(e,t,r,i)=>{try{await this.trpc.thing.releaseLease.mutate({orgName:e,repoName:t,wref:r,leaseId:i});}catch(o){throw c(o)}},graph:async(e,t,r,i)=>{try{return await this.trpc.thing.graph.query({orgName:e,repoName:t,wref:r,version:i?.version,depth:i?.depth,limit:i?.limit})}catch(o){throw c(o)}},getMany:async(e,t,r,i,o)=>{try{return await st(r,o,s=>this.trpc.thing.getMany.query({orgName:e,repoName:t,wrefs:s,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode}))}catch(s){throw c(s)}},headVersions:async(e,t,r,i)=>{try{return await st(r,i,o=>this.trpc.thing.headVersions.query({orgName:e,repoName:t,wrefs:o}))}catch(o){throw c(o)}},names:async(e,t,r,i)=>{try{return await st(r,i,o=>this.trpc.thing.names.query({orgName:e,repoName:t,durableIds:o}))}catch(o){throw c(o)}},history:async(e,t,r)=>{try{return await this.trpc.thing.history.query({orgName:e,repoName:t,wref:r.wref,shape:r.shape,declaredShape:r.declaredShape,about:r.about,includeRetracted:r.includeRetracted,resolveCollections:r.resolveCollections,match:r.match,limit:r.limit,cursor:r.cursor})}catch(i){throw c(i)}},historyIter:(e,t,r)=>O(i=>this.thing.history(e,t,{...r,cursor:i}),i=>i.versions,r.cursor),historyAll:async(e,t,r)=>{let{max:i,...o}=r;return await I(s=>this.thing.history(e,t,{...o,cursor:s}),s=>s.versions,i,o.cursor)},rename:async(e,t,r,i,o)=>{try{return await this.trpc.thing.rename.mutate({orgName:e,repoName:t,name:r,newName:i,eventRequestId:o.eventRequestId})}catch(s){throw c(s)}},remove:async(e,t,r,i)=>{try{return await this.trpc.thing.remove.mutate({orgName:e,repoName:t,wref:r,expectedVersion:i.expectedVersion,eventRequestId:i.eventRequestId})}catch(o){throw c(o)}},redact:async(e,t,r,i)=>{try{return await this.trpc.thing.redact.mutate({orgName:e,repoName:t,durableId:r,expectedVersion:i.expectedVersion,eventRequestId:i.eventRequestId})}catch(o){throw c(o)}},rewrite:async(e,t,r,i)=>{try{return await this.trpc.thing.rewrite.mutate({orgName:e,repoName:t,wref:r,version:i.version,shapes:i.shapes,data:i.data,eventRequestId:i.eventRequestId})}catch(o){throw c(o)}},resolve:async(e,t,r)=>{try{return await this.trpc.thing.resolve.query({orgName:e,repoName:t,wref:r})}catch(i){throw c(i)}},about:async(e,t,r,i)=>{try{return await this.trpc.thing.about.query({orgName:e,repoName:t,wref:r,shape:i?.shape,match:i?.match,includeRetracted:i?.includeRetracted,depth:i?.depth,resolveCollections:i?.resolveCollections,role:i?.role,limit:i?.limit,cursor:i?.cursor,where:i?.where})}catch(o){throw c(o)}},aboutIter:(e,t,r,i)=>O(o=>this.thing.about(e,t,r,{...i,cursor:o}),o=>o.assertions,i?.cursor),aboutAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await I(a=>this.thing.about(e,t,r,{...s,cursor:a}),a=>a.assertions,o,s.cursor)},query:async(e,t,r)=>{try{return await this.trpc.thing.query.query({orgName:e,repoName:t,shape:r?.shape,declaredShape:r?.declaredShape,shapeless:r?.shapeless,includeValidatedShapes:r?.includeValidatedShapes,about:r?.about,affirmedAbout:r?.affirmedAbout,kind:ke(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,role:r?.role,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw c(i)}},queryIter:(e,t,r)=>O(i=>this.thing.query(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),queryAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await I(s=>this.thing.query(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},queryChanges:async(e,t,r)=>(Vr(r?.sinceRepoSeq),await Hr(i=>this.thing.query(e,t,{...r,includeRetracted:true,cursor:i}))),search:async(e,t,r,i)=>{try{return await this.trpc.thing.search.query({orgName:e,repoName:t,query:r,shape:i?.shape,about:i?.about,affirmedAbout:i?.affirmedAbout,kind:ke(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,r,i)=>O(o=>this.thing.search(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),searchAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await I(a=>this.thing.search(e,t,r,{...s,cursor:a}),a=>a.items,o,s.cursor)},count:async(e,t,r)=>{try{return await this.trpc.thing.count.query({orgName:e,repoName:t,shape:r?.shape,declaredShape:r?.declaredShape,shapeless:r?.shapeless,about:r?.about,affirmedAbout:r?.affirmedAbout,kind:ke(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw c(i)}},refs:async(e,t,r,i)=>{try{return await this.trpc.thing.refs.query({orgName:e,repoName:t,wref:r,direction:i?.direction,fieldPath:i?.fieldPath,binding:i?.binding,limit:i?.limit,cursor:i?.cursor})}catch(o){throw c(o)}},refsIter:(e,t,r,i)=>O(o=>this.thing.refs(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),refsAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await I(a=>this.thing.refs(e,t,r,{...s,cursor:a}),a=>a.items,o,s.cursor)}};live={thingHead:async(e,t,r,i)=>this.watchRepoQuery(e,t,r?.signal,()=>this.thing.head(e,t,{shape:r?.shape,declaredShape:r?.declaredShape,shapeless:r?.shapeless,includeValidatedShapes:r?.includeValidatedShapes,kind:r?.kind,match:r?.match,dataMode:r?.dataMode,limit:r?.limit,cursor:r?.cursor,includeRetracted:r?.includeRetracted,where:r?.where}),i),thingHistory:async(e,t,r,i)=>this.watchRepoQuery(e,t,r.signal,()=>this.thing.history(e,t,{wref:r.wref,shape:r.shape,declaredShape:r.declaredShape,about:r.about,resolveCollections:r.resolveCollections,match:r.match,limit:r.limit,cursor:r.cursor,includeRetracted:r.includeRetracted}),i),subscriptionLog:async(e,t,r,i,o)=>this.watchRepoQuery(e,t,i?.signal,()=>this.action.liveFeed(e,t,r,{limit:i?.limit,cursor:i?.cursor}),o),subscribe:async(e,t,r,i)=>{let o=new AbortController,s=Kr(r?.signal,o),a=0,u=(async()=>{let d=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),l=await this.openSse(d.ticket,s,async m=>{if(m.type!=="invalidate")return;let h=m.data;a++,await i({topic:h.topic,affectedShapes:h.affectedShapes,affectedThings:h.affectedThings,affectedTargets:h.affectedTargets,hasNewCommit:h.hasNewCommit});});return await l.ready,s.aborted?{updates:a}:(await l.closed,{updates:a})})();return {close(){o.abort();},closed:u}}};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,r,i)=>{try{return await this.trpc.credential.createSet.mutate({orgName:e,repoName:t,name:r,scope:i?.scope??"repo",description:i?.description})}catch(o){throw c(o)}},listSets:async(e,t)=>{try{return await this.trpc.credential.listSets.query({orgName:e,repoName:t})}catch(r){throw c(r)}},getSet:async(e,t,r)=>{try{return await this.trpc.credential.getSet.query({orgName:e,repoName:t,name:r})}catch(i){throw c(i)}},setKey:async(e,t,r,i,o)=>{try{return await this.trpc.credential.setKey.mutate({orgName:e,repoName:t,setName:r,keyName:i,value:o})}catch(s){throw c(s)}},setKeys:async(e,t,r,i)=>{try{return await this.trpc.credential.setKeys.mutate({orgName:e,repoName:t,setName:r,secrets:i})}catch(o){throw c(o)}},unsetKey:async(e,t,r,i)=>{try{return await this.trpc.credential.unsetKey.mutate({orgName:e,repoName:t,setName:r,keyName:i})}catch(o){throw c(o)}},deleteSet:async(e,t,r)=>{try{return await this.trpc.credential.deleteSet.mutate({orgName:e,repoName:t,setName:r})}catch(i){throw c(i)}},listAuditLog:async(e,t,r,i)=>{try{return await this.trpc.credential.listAuditLog.query({orgName:e,repoName:t,setName:r,limit:i?.limit})}catch(o){throw c(o)}},revokeSet:async(e,t,r,i)=>{try{return await this.trpc.credential.revokeSet.mutate({orgName:e,repoName:t,setName:r,reason:i?.reason})}catch(o){throw c(o)}}};credentials=this.credential;constructor(e,t){let r=typeof e=="string"?t:e;Fi(r);let i=typeof e=="string"?e:e?.apiUrl??Br;if(this.apiUrl=i,this.fetchImpl=r?.fetch,this.accessToken=r?.accessToken??r?.auth?.getToken,this.functionLogMode=r?.functionLogs??"off",this.clientIdentity={name:r?.client?.name??u,version:r?.client?.version??it},this.#e=Object.freeze([...Hi(r?.clientFlags)]),this.decorateResponses=r?.decorateResponses??false,typeof this.accessToken=="function"){let a=this.accessToken;this.getToken=async()=>await a();}else if(this.accessToken){let a=this.accessToken;this.getToken=async()=>a;}let o=`${i.replace(/\/$/,"")}/trpc`,s=((a,u)=>this.fetchWithAuth(a,u,"trpc"));Object.defineProperty(this,"trpc",{value:createTRPCProxyClient({links:[this.createLegacyWrefsLink(),this.createCompatibilityLink(),dr({enabled:this.decorateResponses,lookupNames:async a=>{try{return await this.trpc.thing.names.query({durableIds:a})}catch(u){throw c(u)}}}),splitLink({condition:a=>Wi.has(a.path),true:httpLink({url:o,fetch:s,methodOverride:"POST"}),false:httpBatchLink({url:o,fetch:s,methodOverride:"POST"})})]}),enumerable:false,writable:false,configurable:true});}get clientFlags(){return this.#e}withAccessToken(e){let t={apiUrl:this.apiUrl,fetch:this.fetchImpl,accessToken:e,client:this.clientIdentity,clientFlags:this.clientFlags,decorateResponses:this.decorateResponses},r=new n(t);return B(this)&&Wt(r),r}actions=this.action;async openSse(e,t,r){let i=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/sse?ticket=${encodeURIComponent(e)}`,{headers:{accept:"text/event-stream"},signal:t});if(!i.ok)throw new f("BACKEND",`SSE request failed with status ${i.status}`,i.status);let o=i.body?.getReader();if(!o)throw new f("BACKEND","SSE response body is missing");let s=()=>{},a=new Promise(d=>{s=d;}),u=(async()=>{let d=new TextDecoder,l="";try{for(;;){let{done:m,value:h}=await o.read();if(m)break;for(l+=d.decode(h,{stream:!0}).replaceAll(`\r
|
|
4
|
-
`,`
|
|
5
|
-
`);;){let g=l.indexOf(`
|
|
6
|
-
|
|
7
|
-
`);if(g===-1)break;let b=l.slice(0,g);l=l.slice(g+2);let S=lo(b);if(S){if(S.type==="ready"){s();continue}await r(S);}}}}catch(m){if(mo(m)||t.aborted)return;throw m}finally{s(),o.releaseLock();}})();return {ready:a,closed:u}}applyClientHeader(e){e.has(t)||e.set(t,x$1(this.clientIdentity.name,this.clientIdentity.version)),this.clientFlags.length>0&&!e.has(o)&&e.set(o,s(this.clientFlags));}async fetchWithAuth(e,t,r="rest"){let i=(t?.method??"GET").toUpperCase(),o=this.legacyWrefsRefusal(r==="trpc"||i==="GET"||i==="HEAD"?"read":"write");if(o)throw o;let s=this.fetchImpl??globalThis.fetch,a=new Headers(t?.headers),u=await pt(this.accessToken);u&&a.set("authorization",`Bearer ${u}`),this.applyClientHeader(a);let d=async m=>{try{return await s(e,m)}catch(h){throw ao(h)?new f("NETWORK",po(this.apiUrl)):h}},l=await d({...t,headers:a});if(l.status===401&&typeof this.accessToken=="function"){let m=await pt(this.accessToken);if(m&&m!==u){let h=new Headers(t?.headers);return h.set("authorization",`Bearer ${m}`),this.applyClientHeader(h),d({...t,headers:h})}}return l}async requestResponse(e,t){let r=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}${e}`,t);if(!r.ok)throw await this.httpResponseError(r);return r}thingShapesReader(e,t){return async r=>await this.thing.getMany(e,t,r)}async prepareStreamingSubmissionRequest(e){let t=this.legacyWrefsRefusal("raw-commit");if(t)throw t;let r=this.fetchImpl??globalThis.fetch,i=new Headers({accept:"application/x-ndjson","content-type":"application/x-ndjson"}),o=await pt(this.accessToken);o&&i.set("authorization",`Bearer ${o}`),this.applyClientHeader(i);let s=`${this.apiUrl.replace(/\/$/,"")}${e}`;return {dispatch:async(a,u)=>await r(s,{method:"POST",headers:i,body:a,signal:u,duplex:"half"}),httpError:async a=>await this.httpResponseError(a)}}async httpResponseError(e){let t=`Request failed with status ${e.status}`,r=Zr(e.status),i,o,s;try{let a=await e.json();typeof a.error?.message=="string"&&(t=a.error.message),typeof a.error?.code=="string"&&(r=a.error.code,i=a.error.code),typeof a.error?.hint=="string"&&(o=a.error.hint),typeof a.error?.retryAfter=="number"&&(s=a.error.retryAfter);}catch{}return new f(r,t,e.status,o,s,i)}async requestJson(e,t){return await(await this.requestResponse(e,t)).json()}async watchRepoQuery(e,t,r,i,o){let s=new AbortController,a=Kr(r,s),u=0,d=(async()=>{let l=async()=>{let g=await i();u+=1,await o(g);},m=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),h=await this.openSse(m.ticket,a,async g=>{g.type==="invalidate"&&await l();});return await h.ready,a.aborted?{updates:u}:(await l(),await h.closed,{updates:u})})();return {close(){s.abort();},closed:d}}};function Zr(n){switch(n){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHENTICATED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 409:return "CONFLICT";case 429:return "RATE_LIMITED";default:return "BACKEND"}}async function pt(n){if(n)return typeof n=="string"?n:n()}function Kr(n,e){return n?n.aborted?(e.abort(),e.signal):(n.addEventListener("abort",()=>e.abort(),{once:true}),e.signal):e.signal}function lo(n){let e="message",t=[];for(let i of n.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 r=t.join(`
|
|
9
|
-
`);return {type:e,data:JSON.parse(r)}}function mo(n){return n instanceof Error&&n.name==="AbortError"}export{R as A,oe as B,K as C,yr as D,se as E,Rr as F,D as G,it as H,x as I,_i as J,za as K,Br as L,Qa as M,at as N,c as O,Ya as P,oo as Q,Ja as R,ao as S,po as T,Xa as U,Gr as V,f as a,pn as b,y as c,cn as d,Bt as e,$t as f,F as g,fn as h,H as i,Se as j,we as k,k as l,A as m,We as n,Xt as o,re as p,W as q,tr as r,Tn as s,Qe as t,ar as u,pr as v,cr as w,ve as x,qn as y,G as z};//# sourceMappingURL=chunk-FSZ4MCOS.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-FSZ4MCOS.js.map
|