@warmhub/sdk-ts 0.85.0 → 0.87.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/README.md +4 -0
- package/dist/checkpoint.js +1 -1
- package/dist/checkpoint.js.map +1 -1
- package/dist/{chunk-FDD3D4H7.js → chunk-2SDARM7P.js} +24 -24
- package/dist/chunk-2SDARM7P.js.map +1 -0
- package/dist/chunk-7C47GTDA.js +8 -0
- package/dist/chunk-7C47GTDA.js.map +1 -0
- package/dist/index.d.ts +210 -9
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CNOPJLT7.js +0 -8
- package/dist/chunk-CNOPJLT7.js.map +0 -1
- package/dist/chunk-FDD3D4H7.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -583,6 +583,83 @@ type Capabilities = {
|
|
|
583
583
|
minSupportedClients: Record<string, string>;
|
|
584
584
|
writeContractVersion: number;
|
|
585
585
|
features: Record<string, boolean>;
|
|
586
|
+
honoredClientFlags: Array<string>;
|
|
587
|
+
};
|
|
588
|
+
type GrantCreateInput = {
|
|
589
|
+
orgName: string;
|
|
590
|
+
repoName: string;
|
|
591
|
+
idempotencyKey: string;
|
|
592
|
+
grantee: {
|
|
593
|
+
principalId: string;
|
|
594
|
+
principalKind: 'member' | 'pat' | 'component';
|
|
595
|
+
};
|
|
596
|
+
coverage?: {
|
|
597
|
+
include: Array<string>;
|
|
598
|
+
exclude?: Array<string>;
|
|
599
|
+
};
|
|
600
|
+
viewRef?: string;
|
|
601
|
+
ops: Array<string>;
|
|
602
|
+
};
|
|
603
|
+
type GrantListInput = {
|
|
604
|
+
orgName: string;
|
|
605
|
+
repoName: string;
|
|
606
|
+
limit: number;
|
|
607
|
+
cursor?: string;
|
|
608
|
+
};
|
|
609
|
+
type GrantListResult$1 = {
|
|
610
|
+
items: Array<{
|
|
611
|
+
id: string;
|
|
612
|
+
grantee: {
|
|
613
|
+
principalId: string;
|
|
614
|
+
principalKind: 'anonymous' | 'member' | 'pat' | 'component';
|
|
615
|
+
};
|
|
616
|
+
issuer: {
|
|
617
|
+
principalId: string;
|
|
618
|
+
principalKind: 'anonymous' | 'member' | 'pat' | 'component';
|
|
619
|
+
};
|
|
620
|
+
idempotencyKey: string;
|
|
621
|
+
requestHash: string;
|
|
622
|
+
coverage: {
|
|
623
|
+
include: Array<string>;
|
|
624
|
+
exclude?: Array<string>;
|
|
625
|
+
} | null;
|
|
626
|
+
viewRef: string | null;
|
|
627
|
+
ops: Array<string>;
|
|
628
|
+
createdBy: string;
|
|
629
|
+
createdAt: string;
|
|
630
|
+
revokedAt: string | null;
|
|
631
|
+
revokedBy: string | null;
|
|
632
|
+
revokedReason: string | null;
|
|
633
|
+
}>;
|
|
634
|
+
nextCursor?: string;
|
|
635
|
+
};
|
|
636
|
+
type GrantRevokeResult$1 = {
|
|
637
|
+
grantId: string;
|
|
638
|
+
revoked: boolean;
|
|
639
|
+
};
|
|
640
|
+
type GrantView = {
|
|
641
|
+
id: string;
|
|
642
|
+
grantee: {
|
|
643
|
+
principalId: string;
|
|
644
|
+
principalKind: 'anonymous' | 'member' | 'pat' | 'component';
|
|
645
|
+
};
|
|
646
|
+
issuer: {
|
|
647
|
+
principalId: string;
|
|
648
|
+
principalKind: 'anonymous' | 'member' | 'pat' | 'component';
|
|
649
|
+
};
|
|
650
|
+
idempotencyKey: string;
|
|
651
|
+
requestHash: string;
|
|
652
|
+
coverage: {
|
|
653
|
+
include: Array<string>;
|
|
654
|
+
exclude?: Array<string>;
|
|
655
|
+
} | null;
|
|
656
|
+
viewRef: string | null;
|
|
657
|
+
ops: Array<string>;
|
|
658
|
+
createdBy: string;
|
|
659
|
+
createdAt: string;
|
|
660
|
+
revokedAt: string | null;
|
|
661
|
+
revokedBy: string | null;
|
|
662
|
+
revokedReason: string | null;
|
|
586
663
|
};
|
|
587
664
|
type HomepageFeaturedListsResult$1 = {
|
|
588
665
|
lists: Array<{
|
|
@@ -772,7 +849,6 @@ type StreamAppendResult$1 = {
|
|
|
772
849
|
createdByEmail?: string;
|
|
773
850
|
appendTotalMs?: number;
|
|
774
851
|
appendResolveRepoMs?: number;
|
|
775
|
-
appendTokenResolveMs?: number;
|
|
776
852
|
appendApplyMs?: number;
|
|
777
853
|
applySubphases?: {
|
|
778
854
|
addThingMs?: number;
|
|
@@ -783,7 +859,6 @@ type StreamAppendResult$1 = {
|
|
|
783
859
|
reviseCollectionMs?: number;
|
|
784
860
|
preparePinnedLoadShapeFieldsMs?: number;
|
|
785
861
|
preparePinnedPinWrefsMs?: number;
|
|
786
|
-
preparePinnedResolveTokensMs?: number;
|
|
787
862
|
preparePinnedValidateMs?: number;
|
|
788
863
|
operationLoopMs?: number;
|
|
789
864
|
persistMs?: number;
|
|
@@ -2381,6 +2456,58 @@ type WireScopeEntry$1 = {
|
|
|
2381
2456
|
permissions: Array<string>;
|
|
2382
2457
|
allowedMatches?: Array<string>;
|
|
2383
2458
|
};
|
|
2459
|
+
type ViewEvaluateInput = {
|
|
2460
|
+
orgName: string;
|
|
2461
|
+
repoName: string;
|
|
2462
|
+
wref: string;
|
|
2463
|
+
limit?: number;
|
|
2464
|
+
cursor?: string;
|
|
2465
|
+
};
|
|
2466
|
+
type ViewEvaluateResult$1 = {
|
|
2467
|
+
items: Array<{
|
|
2468
|
+
wref: string;
|
|
2469
|
+
name: string;
|
|
2470
|
+
kind: 'shape' | 'thing' | 'assertion' | 'collection';
|
|
2471
|
+
shapeName?: string;
|
|
2472
|
+
componentRef?: string;
|
|
2473
|
+
version: number;
|
|
2474
|
+
createdAt: number;
|
|
2475
|
+
data?: unknown;
|
|
2476
|
+
active: boolean;
|
|
2477
|
+
aboutWref?: string;
|
|
2478
|
+
roles?: Array<'from' | 'to' | 'ends' | 'first' | 'second'>;
|
|
2479
|
+
metadata?: {
|
|
2480
|
+
durableId: string;
|
|
2481
|
+
createdOn: number;
|
|
2482
|
+
revisedOn: number;
|
|
2483
|
+
};
|
|
2484
|
+
}>;
|
|
2485
|
+
nextCursor?: string;
|
|
2486
|
+
repoSeq?: number;
|
|
2487
|
+
view: {
|
|
2488
|
+
wref: string;
|
|
2489
|
+
version: number;
|
|
2490
|
+
};
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
* Input for idempotently creating an inline-coverage repository Grant.
|
|
2495
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/grantcreateoptions/
|
|
2496
|
+
*/
|
|
2497
|
+
type GrantCreateOptions = Omit<GrantCreateInput, 'orgName' | 'repoName' | 'coverage' | 'viewRef'> & {
|
|
2498
|
+
coverage: NonNullable<GrantCreateInput['coverage']>;
|
|
2499
|
+
};
|
|
2500
|
+
/** @internal */
|
|
2501
|
+
type GrantListOptions = Partial<Omit<GrantListInput, 'orgName' | 'repoName'>>;
|
|
2502
|
+
/**
|
|
2503
|
+
* An immutable active or revoked repository Grant record.
|
|
2504
|
+
* @see https://docs.warmhub.ai/sdk-reference/type-aliases/grant/
|
|
2505
|
+
*/
|
|
2506
|
+
type Grant = GrantView;
|
|
2507
|
+
/** @internal */
|
|
2508
|
+
type GrantListResult = GrantListResult$1;
|
|
2509
|
+
/** @internal */
|
|
2510
|
+
type GrantRevokeResult = GrantRevokeResult$1;
|
|
2384
2511
|
|
|
2385
2512
|
type DateMappedRepositoryCheckpointStatus<T> = T extends {
|
|
2386
2513
|
createdAt: number;
|
|
@@ -3630,6 +3757,13 @@ interface WarmHubClientOptions {
|
|
|
3630
3757
|
name?: string;
|
|
3631
3758
|
version?: string;
|
|
3632
3759
|
};
|
|
3760
|
+
/**
|
|
3761
|
+
* Client-declared opt-in flags sent on `X-WarmHub-Client-Flags`. Flag names
|
|
3762
|
+
* are defined by the backend deployment; see your deployment's
|
|
3763
|
+
* documentation. Grammar-checked here; validated and honored only by the
|
|
3764
|
+
* server. Untrusted intent — never an authz signal.
|
|
3765
|
+
*/
|
|
3766
|
+
clientFlags?: readonly string[];
|
|
3633
3767
|
}
|
|
3634
3768
|
|
|
3635
3769
|
/**
|
|
@@ -4545,6 +4679,18 @@ type ThingHeadRequest = {
|
|
|
4545
4679
|
};
|
|
4546
4680
|
/** @internal */
|
|
4547
4681
|
type ThingHead = HeadResult;
|
|
4682
|
+
/**
|
|
4683
|
+
* Page options for evaluating a stored View.
|
|
4684
|
+
*
|
|
4685
|
+
* The View definition version is selected by the single versionable `wref`
|
|
4686
|
+
* passed to `view.evaluate`; there is no separate version option.
|
|
4687
|
+
*/
|
|
4688
|
+
/** @internal */
|
|
4689
|
+
type ViewEvaluateOptions = Omit<ViewEvaluateInput, 'orgName' | 'repoName' | 'wref'>;
|
|
4690
|
+
/** One page of live results from a selected stored View definition. */
|
|
4691
|
+
/** @internal */
|
|
4692
|
+
type ViewEvaluateResult = ViewEvaluateResult$1;
|
|
4693
|
+
|
|
4548
4694
|
/** @internal */
|
|
4549
4695
|
type LiveWatchResult = {
|
|
4550
4696
|
updates: number;
|
|
@@ -5091,10 +5237,11 @@ declare function isConnectionError(error: unknown): boolean;
|
|
|
5091
5237
|
*/
|
|
5092
5238
|
declare function connectionErrorMessage(url: string): string;
|
|
5093
5239
|
/**
|
|
5094
|
-
* Returns true when `version` is strictly older than `minimum`.
|
|
5095
|
-
*
|
|
5096
|
-
*
|
|
5097
|
-
*
|
|
5240
|
+
* Returns true when `version` is strictly older than `minimum`. This is the
|
|
5241
|
+
* parse boundary for the read-side compatibility hint: both arguments arrive
|
|
5242
|
+
* as unproved strings, and a string that is not SemVer returns false rather
|
|
5243
|
+
* than failing the read. Write admission parses both values separately and
|
|
5244
|
+
* fails closed.
|
|
5098
5245
|
*
|
|
5099
5246
|
* @internal
|
|
5100
5247
|
*/
|
|
@@ -5145,10 +5292,14 @@ declare class WarmHubClient {
|
|
|
5145
5292
|
private readonly accessToken;
|
|
5146
5293
|
/** Resolved `X-WarmHub-Client` identity; defaults to this SDK's name/version. */
|
|
5147
5294
|
private readonly clientIdentity;
|
|
5295
|
+
/** Normalized `clientFlags` option; stamped on every request. */
|
|
5296
|
+
private readonly clientFlags;
|
|
5148
5297
|
protected readonly functionLogMode: FunctionLogMode;
|
|
5149
5298
|
protected readonly getToken?: () => Promise<string | undefined>;
|
|
5150
5299
|
private readonly trpc;
|
|
5151
5300
|
private compatibilityCheck?;
|
|
5301
|
+
private overrideNoticePrinted;
|
|
5302
|
+
private noteCompatibilityOverride;
|
|
5152
5303
|
private assertWriteCompatible;
|
|
5153
5304
|
private createCompatibilityLink;
|
|
5154
5305
|
/**
|
|
@@ -6177,6 +6328,55 @@ declare class WarmHubClient {
|
|
|
6177
6328
|
revise: (orgName: string, repoName: string, wref: string, opts: CollectionReviseOptions) => Promise<CollectionMutationResult>;
|
|
6178
6329
|
stats: (orgName: string | undefined, repoName: string | undefined, wref: string, opts?: CollectionStatsOptions) => Promise<CollectionStatsResult>;
|
|
6179
6330
|
};
|
|
6331
|
+
/**
|
|
6332
|
+
* Execute stored View definitions against the repository's live read model.
|
|
6333
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/#view
|
|
6334
|
+
*/
|
|
6335
|
+
readonly view: {
|
|
6336
|
+
/**
|
|
6337
|
+
* Evaluate one identity-scoped or pinned View definition and return one page.
|
|
6338
|
+
*
|
|
6339
|
+
* The `wref` is the sole definition selector. Cursors are short-lived resume
|
|
6340
|
+
* tokens for the same query and result scope. If the selected identity-scoped
|
|
6341
|
+
* View changes, the backend may reject a saved cursor with
|
|
6342
|
+
* `CURSOR_EPOCH_INVALID`; restart the query without `cursor`.
|
|
6343
|
+
*/
|
|
6344
|
+
evaluate: (orgName: string, repoName: string, wref: string, opts?: ViewEvaluateOptions) => Promise<ViewEvaluateResult>;
|
|
6345
|
+
/**
|
|
6346
|
+
* Iterate every live result from an identity-scoped or pinned View.
|
|
6347
|
+
*
|
|
6348
|
+
* The iterator preserves the caller's page size and optional resume cursor,
|
|
6349
|
+
* and rejects non-advancing or cyclic backend cursors.
|
|
6350
|
+
*
|
|
6351
|
+
* Cursors resume the same query and result scope. If the backend reports
|
|
6352
|
+
* `CURSOR_EPOCH_INVALID`, restart the query without `cursor`.
|
|
6353
|
+
*/
|
|
6354
|
+
evaluateIter: (orgName: string, repoName: string, wref: string, opts?: ViewEvaluateOptions) => AsyncIterableIterator<ThingItem>;
|
|
6355
|
+
/**
|
|
6356
|
+
* Materialize every live result from an identity-scoped or pinned View.
|
|
6357
|
+
*
|
|
6358
|
+
* Use `max` to guard memory usage. The call throws `VALIDATION_ERROR` only
|
|
6359
|
+
* after more than `max` items have actually been observed.
|
|
6360
|
+
*
|
|
6361
|
+
* Cursors resume the same query and result scope. If the backend reports
|
|
6362
|
+
* `CURSOR_EPOCH_INVALID`, restart the query without `cursor`.
|
|
6363
|
+
*/
|
|
6364
|
+
evaluateAll: (orgName: string, repoName: string, wref: string, opts?: ViewEvaluateOptions & {
|
|
6365
|
+
max?: number;
|
|
6366
|
+
}) => Promise<ThingItem[]>;
|
|
6367
|
+
};
|
|
6368
|
+
/**
|
|
6369
|
+
* Create and administer immutable repository Grants.
|
|
6370
|
+
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/#grant
|
|
6371
|
+
*/
|
|
6372
|
+
readonly grant: {
|
|
6373
|
+
create: (orgName: string, repoName: string, input: GrantCreateOptions) => Promise<Grant>;
|
|
6374
|
+
get: (orgName: string, repoName: string, grantId: string) => Promise<Grant>;
|
|
6375
|
+
list: (orgName: string, repoName: string, opts?: GrantListOptions) => Promise<GrantListResult>;
|
|
6376
|
+
revoke: (orgName: string, repoName: string, grantId: string, opts?: {
|
|
6377
|
+
reason?: string;
|
|
6378
|
+
}) => Promise<GrantRevokeResult>;
|
|
6379
|
+
};
|
|
6180
6380
|
/**
|
|
6181
6381
|
* Read surface for things, assertions, histories, references, search, and in-place thing renames.
|
|
6182
6382
|
* @see https://docs.warmhub.ai/sdk-reference/classes/warmhubclient/#thing
|
|
@@ -6851,8 +7051,9 @@ declare class WarmHubClient {
|
|
|
6851
7051
|
};
|
|
6852
7052
|
private openSse;
|
|
6853
7053
|
/**
|
|
6854
|
-
* Stamp the `X-WarmHub-Client` self-identification
|
|
6855
|
-
* already set
|
|
7054
|
+
* Stamp the `X-WarmHub-Client` self-identification and `X-WarmHub-Client-Flags`
|
|
7055
|
+
* headers, unless the caller already set them on the request (a per-request
|
|
7056
|
+
* header wins over the default).
|
|
6856
7057
|
*/
|
|
6857
7058
|
private applyClientHeader;
|
|
6858
7059
|
private fetchWithAuth;
|
|
@@ -6861,4 +7062,4 @@ declare class WarmHubClient {
|
|
|
6861
7062
|
private watchRepoQuery;
|
|
6862
7063
|
}
|
|
6863
7064
|
|
|
6864
|
-
export { type AboutOptions, type AboutResult, type AccessResolveInput, type AccessResolveResult, type AccessTokenProvider, type ActionAttemptInfo, type ActionDeliveryTarget, type ActionLeaseAcquire, type ActionLeaseOp, type ActionListNotificationsOptions, type ActionListRunsOptions, type ActionLiveFeed, type ActionLiveFeedItem, type ActionLiveFeedOptions, type ActionNotificationInfo, type ActionRunInfo, type ActionRunStatsInfo, type ActionRunStatsOptions, type AddOp, type AddOperation, AllStreamOperationsFailedError, type Assertion, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, CONTENT_FIELD_LIMIT_ERROR, type CliCallSecrets, CliCallVerificationError, type CliCallVerificationFailureReason, type CollectionAddOp, type CollectionAddType, type CollectionContainsOptions, type CollectionContainsResult, type CollectionCreateOptions, type CollectionDiffOptions, type CollectionDiffResult, type CollectionMember, type CollectionMembersOptions, type CollectionMembersPage, type CollectionMembershipRole, type CollectionMutationResult, type CollectionQuerySourceOptions, type CollectionReadDataMode, type CollectionReadSummary, type CollectionReviseOptions, type CollectionStatsOptions, type CollectionStatsResult, type CollectionTag, type CollectionType, type CommitApplyCompatibilityResult, type ComponentHistory, type ComponentHistoryOptions, type ComponentInfo, type ComponentInstallOptions, type ComponentInstallResult, type ComponentList, type ComponentListOptions, type ComponentUninstallOptions, type ComponentUninstallResult, type ComponentView, type CoreErrorKind, type CountOptions, type CountResult, type CredentialAuditEntry, type CredentialDeleteResult, type CredentialGrantResult, type CredentialInfo, type CredentialKeyMutationResult, type CredentialRevokeResult, type CredentialUngrantResult, type CurrentUserInfo, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, type ErrorKind, type FilterOptions, type FilterResult, type FunctionLogMode, type GlobalSearchOptions, type GlobalSearchResult, type GlobalSearchResultItem, type HeadResult, type HistoryResult, type HistoryVersion, type HomepageFeaturedListsResult, type IndexedFieldEntry, type IndexedFieldsReport, type LiveHandle, type LiveRepoEvent, type LiveSubscriptionLogOptions, type LiveThingHeadOptions, type LiveThingHistoryOptions, type LiveWatchResult, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, type Operation, OperationBuilder, type OperationBuilderAddInput, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceiptV1, type OperationSubmitResult, type OrgAccessResult, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, type RefLink, type RefsOptions, type RefsResult, type RenameOperation, type RenameOptions, type RenameResult, type RepoAccessResult, type RepoConfigureStatsView, type RepoDescribeResult, type RepoExploreBrowseOptions, type RepoExploreItem, type RepoExploreOptions, type RepoExploreResult, type RepoInfo, type RepoLicense, type RepoList, type RepoListForCallerOptions, type RepoListOptions, type RepoListPageOptions, type RepoListPageResult, type RepoLocator, type RepoRecentInfo, type RepoRef, type RepoShapeInstanceCountsView, type RepoSort, type RepoStatsBatchResult, type RepoStatsView, type RepoWithStatsInfo, type RepositoryCheckpointAccess, type RepositoryCheckpointStatus, type RequestEvent, type ResolveWrefResult, type RetractOp, type RetractOperation, type RetryPolicyOptions, type ReviseOp, type ReviseOperation, SDK_VERSION, type SearchOptions, type SearchResult, type Shape, type ShapeChange, type ShapeCreateOptions, type ShapeFields, type ShapeGetOptions, type ShapeHistory, type ShapeHistoryOptions, type ShapeList, type ShapeListOptions, type ShapeRef, type ShapeRemove, type ShapeRemoveOptions, type ShapeReviseOptions, type ShapeValidatorResult, type StreamAppendInput, type StreamAppendResult, type StreamContinuationState, type SubscriptionBindCredentialsResult, type SubscriptionCompatCreateInput, type SubscriptionCompatUpdateInput, type SubscriptionInfo, type SubscriptionList, type SubscriptionUnbindCredentialsResult, type SynthesizedRepoContent, type ThingChanges, type ThingDetail, type ThingGet, type ThingGetManyResult, type ThingGetOptions, type ThingGetWithLease, type ThingGraphOptions, type ThingGraphResult, type ThingGraphValue, type ThingHead, type ThingHeadChangesOptions, type ThingHeadOptions, type ThingHeadRequest, type ThingHeadVersionsResult, type ThingHistory, type ThingHistoryOptions, type ThingItem, type ThingMetadata, type ThingQueryChangesOptions, type TokenInfo, type TokenResult, type UndeclaredFieldsWarning, type ValidationDiagnostic, type ValidationResult, type VerifiedCliCall, WarmHubClient, type WarmHubClientOptions, WarmHubError, type WarmHubErrorDetails, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry, aggregateSubmittedStreamResult, completedOperationsFrom, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createOperationEventRequestId, createOperationEventSubmissionId, isConnectionError, isDefiniteStreamAppendRejection, isRetryable, isWarmHubError, normalizeWref, offsetChunkResultIndexes, operationEventStreamRequestId, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
|
7065
|
+
export { type AboutOptions, type AboutResult, type AccessResolveInput, type AccessResolveResult, type AccessTokenProvider, type ActionAttemptInfo, type ActionDeliveryTarget, type ActionLeaseAcquire, type ActionLeaseOp, type ActionListNotificationsOptions, type ActionListRunsOptions, type ActionLiveFeed, type ActionLiveFeedItem, type ActionLiveFeedOptions, type ActionNotificationInfo, type ActionRunInfo, type ActionRunStatsInfo, type ActionRunStatsOptions, type AddOp, type AddOperation, AllStreamOperationsFailedError, type Assertion, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, CONTENT_FIELD_LIMIT_ERROR, type CliCallSecrets, CliCallVerificationError, type CliCallVerificationFailureReason, type CollectionAddOp, type CollectionAddType, type CollectionContainsOptions, type CollectionContainsResult, type CollectionCreateOptions, type CollectionDiffOptions, type CollectionDiffResult, type CollectionMember, type CollectionMembersOptions, type CollectionMembersPage, type CollectionMembershipRole, type CollectionMutationResult, type CollectionQuerySourceOptions, type CollectionReadDataMode, type CollectionReadSummary, type CollectionReviseOptions, type CollectionStatsOptions, type CollectionStatsResult, type CollectionTag, type CollectionType, type CommitApplyCompatibilityResult, type ComponentHistory, type ComponentHistoryOptions, type ComponentInfo, type ComponentInstallOptions, type ComponentInstallResult, type ComponentList, type ComponentListOptions, type ComponentUninstallOptions, type ComponentUninstallResult, type ComponentView, type CoreErrorKind, type CountOptions, type CountResult, type CredentialAuditEntry, type CredentialDeleteResult, type CredentialGrantResult, type CredentialInfo, type CredentialKeyMutationResult, type CredentialRevokeResult, type CredentialUngrantResult, type CurrentUserInfo, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, type ErrorKind, type FilterOptions, type FilterResult, type FunctionLogMode, type GlobalSearchOptions, type GlobalSearchResult, type GlobalSearchResultItem, type Grant, type GrantCreateOptions, type GrantListOptions, type GrantListResult, type GrantRevokeResult, type HeadResult, type HistoryResult, type HistoryVersion, type HomepageFeaturedListsResult, type IndexedFieldEntry, type IndexedFieldsReport, type LiveHandle, type LiveRepoEvent, type LiveSubscriptionLogOptions, type LiveThingHeadOptions, type LiveThingHistoryOptions, type LiveWatchResult, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT, type Operation, OperationBuilder, type OperationBuilderAddInput, type OperationBuilderClient, type OperationBuilderOp, type OperationBuilderOptions, type OperationEventReceiptV1, type OperationSubmitResult, type OrgAccessResult, type OrgInfo, type OrgList, type OrgListMembersOptions, type OrgListOptions, type OrgMemberInfo, type OrgMemberList, type OrgRef, type OrgRole, type Page, type PageRequest, PartialStreamSubmissionError, type PingResult, type RefLink, type RefsOptions, type RefsResult, type RenameOperation, type RenameOptions, type RenameResult, type RepoAccessResult, type RepoConfigureStatsView, type RepoDescribeResult, type RepoExploreBrowseOptions, type RepoExploreItem, type RepoExploreOptions, type RepoExploreResult, type RepoInfo, type RepoLicense, type RepoList, type RepoListForCallerOptions, type RepoListOptions, type RepoListPageOptions, type RepoListPageResult, type RepoLocator, type RepoRecentInfo, type RepoRef, type RepoShapeInstanceCountsView, type RepoSort, type RepoStatsBatchResult, type RepoStatsView, type RepoWithStatsInfo, type RepositoryCheckpointAccess, type RepositoryCheckpointStatus, type RequestEvent, type ResolveWrefResult, type RetractOp, type RetractOperation, type RetryPolicyOptions, type ReviseOp, type ReviseOperation, SDK_VERSION, type SearchOptions, type SearchResult, type Shape, type ShapeChange, type ShapeCreateOptions, type ShapeFields, type ShapeGetOptions, type ShapeHistory, type ShapeHistoryOptions, type ShapeList, type ShapeListOptions, type ShapeRef, type ShapeRemove, type ShapeRemoveOptions, type ShapeReviseOptions, type ShapeValidatorResult, type StreamAppendInput, type StreamAppendResult, type StreamContinuationState, type SubscriptionBindCredentialsResult, type SubscriptionCompatCreateInput, type SubscriptionCompatUpdateInput, type SubscriptionInfo, type SubscriptionList, type SubscriptionUnbindCredentialsResult, type SynthesizedRepoContent, type ThingChanges, type ThingDetail, type ThingGet, type ThingGetManyResult, type ThingGetOptions, type ThingGetWithLease, type ThingGraphOptions, type ThingGraphResult, type ThingGraphValue, type ThingHead, type ThingHeadChangesOptions, type ThingHeadOptions, type ThingHeadRequest, type ThingHeadVersionsResult, type ThingHistory, type ThingHistoryOptions, type ThingItem, type ThingMetadata, type ThingQueryChangesOptions, type TokenInfo, type TokenResult, type UndeclaredFieldsWarning, type ValidationDiagnostic, type ValidationResult, type VerifiedCliCall, type ViewEvaluateOptions, type ViewEvaluateResult, WarmHubClient, type WarmHubClientOptions, WarmHubError, type WarmHubErrorDetails, type WherePredicate, type WhoamiInfo, type WhoamiScopeEntry, type WireScopeEntry, aggregateSubmittedStreamResult, completedOperationsFrom, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, createOperationEventRequestId, createOperationEventSubmissionId, isConnectionError, isDefiniteStreamAppendRejection, isRetryable, isWarmHubError, normalizeWref, offsetChunkResultIndexes, operationEventStreamRequestId, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{g as AllStreamOperationsFailedError,p as CliCallVerificationError,t as DEFAULT_API_URL,d as DEFAULT_STREAM_CHUNK_SIZE,e as MAX_STREAM_APPEND_OPERATION_COUNT,r as OperationBuilder,f as PartialStreamSubmissionError,o as SDK_VERSION,D as WarmHubClient,w as WarmHubError,m as aggregateSubmittedStreamResult,n as completedOperationsFrom,B as connectionErrorMessage,i as countStreamAppendResultStatuses,b as createOperationEventRequestId,a as createOperationEventSubmissionId,A as isConnectionError,j as isDefiniteStreamAppendRejection,z as isRetryable,y as isWarmHubError,s as normalizeWref,l as offsetChunkResultIndexes,c as operationEventStreamRequestId,u as resolveFunctionLogMode,v as sanitizeErrorMessage,C as sdkVersionIsBelowMinimum,h as streamAppendResultStatus,k as submitOperationsViaStream,x as toWarmHubError,q as verifyCliCall}from'./chunk-
|
|
1
|
+
export{g as AllStreamOperationsFailedError,p as CliCallVerificationError,t as DEFAULT_API_URL,d as DEFAULT_STREAM_CHUNK_SIZE,e as MAX_STREAM_APPEND_OPERATION_COUNT,r as OperationBuilder,f as PartialStreamSubmissionError,o as SDK_VERSION,D as WarmHubClient,w as WarmHubError,m as aggregateSubmittedStreamResult,n as completedOperationsFrom,B as connectionErrorMessage,i as countStreamAppendResultStatuses,b as createOperationEventRequestId,a as createOperationEventSubmissionId,A as isConnectionError,j as isDefiniteStreamAppendRejection,z as isRetryable,y as isWarmHubError,s as normalizeWref,l as offsetChunkResultIndexes,c as operationEventStreamRequestId,u as resolveFunctionLogMode,v as sanitizeErrorMessage,C as sdkVersionIsBelowMinimum,h as streamAppendResultStatus,k as submitOperationsViaStream,x as toWarmHubError,q as verifyCliCall}from'./chunk-7C47GTDA.js';export{m as CLI_INSTALL_REPO_HEADER,n as CLI_SIGNATURE_HEADER,o as CLI_TIMESTAMP_HEADER,u as CONTENT_FIELD_LIMIT_ERROR,t as MAX_CONTENT_FIELD_BYTES,v as contentFieldLimitError,I as validateAgainstShape}from'./chunk-2SDARM7P.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {D}from'./chunk-
|
|
1
|
+
import {D}from'./chunk-7C47GTDA.js';export{t as DEFAULT_API_URL,o as SDK_VERSION,D as WarmHubClient,w as WarmHubError,x as toWarmHubError}from'./chunk-7C47GTDA.js';import'./chunk-2SDARM7P.js';import {createContext,useMemo,useState,useEffect,useContext}from'react';import {jsx}from'react/jsx-runtime';var b=createContext(null),p=createContext({isAuthenticated:false,isLoading:true});function P({apiUrl:e,children:t,auth:i,client:o}){let r=o?.name,n=o?.version,s=useMemo(()=>new D({apiUrl:e,accessToken:async()=>await i.getAccessToken()??void 0,client:{name:r,version:n}}),[e,i.getAccessToken,r,n]);return jsx(b.Provider,{value:s,children:jsx(g,{auth:i,client:s,children:t})})}function g({auth:e,client:t,children:i}){let[o,r]=useState(null),n=e.isAuthenticated&&o===t;useEffect(()=>{if(!e.isAuthenticated){r(null);return}let u=false;return t.auth.sync().then(()=>{u||r(t);}).catch(f=>{console.error("auth.sync failed:",f),u||r(t);}),()=>{u=true;}},[e.isAuthenticated,t]);let s=useMemo(()=>({isAuthenticated:e.isAuthenticated&&n,isLoading:e.isLoading||e.isAuthenticated&&!n}),[e.isAuthenticated,e.isLoading,n]);return e.isLoading||e.isAuthenticated&&!n?null:jsx(p.Provider,{value:s,children:i})}function v(){let e=useContext(b);if(!e)throw new Error("useWarmHubClient must be used within a WarmHubProvider");return e}function S(){return useContext(p)}export{P as WarmHubProvider,S as useWarmHubAuth,v as useWarmHubClient};//# sourceMappingURL=react.js.map
|
|
2
2
|
//# sourceMappingURL=react.js.map
|
package/package.json
CHANGED
package/dist/chunk-CNOPJLT7.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {u,i,l,j,k as k$1,m,E,t,n,o,b,a as a$1,e,h,s,r,G as G$1,F as F$1,f,g,c,d as d$1}from'./chunk-FDD3D4H7.js';import {TRPCClientError,createTRPCProxyClient,splitLink,httpBatchLink,httpLink}from'@trpc/client';import {observable}from'@trpc/server/observable';function ee(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 Et(n){return {...n,expiresAt:new Date(n.expiresAt)}}function We(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 $e(n,e){return {generate:async(t,r,i)=>{try{let o=await n().repo.checkpoint.generate.mutate({orgName:t,repoName:r,atLeastRepoSeq:i?.atLeastRepoSeq});return ee(o.checkpoint)}catch(o){throw e(o)}},status:async(t,r,i)=>{try{let o=await n().repo.checkpoint.status.query({orgName:t,repoName:r,selector:We(i)});return ee(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?ee(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"}:We(i.checkpoint),artifact:i.artifact==="archive"||i.artifact==="manifest"?{kind:i.artifact}:{kind:"chunk",path:i.artifact.chunkPath}});return Et(o)}catch(o){throw e(o)}},retry:async(t,r,i)=>{try{let o=await n().repo.checkpoint.retry.mutate({orgName:t,repoName:r,checkpointId:i});return ee(o.checkpoint)}catch(o){throw e(o)}}}}function H(n,e,t){let r=G$1(e,t==="revise"?{allowUnsafeFieldNamePaths:F$1(e)}:void 0);return r.valid?null:`Invalid shape definition for "${n}": ${r.errors.join("; ")}`}var kt="003e7e6c-2f1e-53ea-9dfa-627edd04a8cc",vt=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;function Ke(n){if(!vt.test(n))throw new Error("Operation-event submission ID must be a canonical UUID");let e=n.toLowerCase().replaceAll("-","");return Uint8Array.from({length:16},(t,r)=>Number.parseInt(e.slice(r*2,r*2+2),16))}function be(n,e){return (n<<e|n>>>32-e)>>>0}function xt(n){let e=n.length*8,t=Math.ceil((n.length+9)/64)*64,r=new Uint8Array(t);r.set(n),r[n.length]=128;let i=new DataView(r.buffer);i.setUint32(t-8,Math.floor(e/4294967296)),i.setUint32(t-4,e>>>0);let o=1732584193,s=4023233417,p=2562383102,c=271733878,u=3285377520,l=new Uint32Array(80);for(let g=0;g<t;g+=64){for(let y=0;y<16;y+=1)l[y]=i.getUint32(g+y*4);for(let y=16;y<80;y+=1)l[y]=be(l[y-3]^l[y-8]^l[y-14]^l[y-16],1);let C=o,h=s,R=p,b=c,I=u;for(let y=0;y<80;y+=1){let S,E;y<20?(S=h&R|~h&b,E=1518500249):y<40?(S=h^R^b,E=1859775393):y<60?(S=h&R|h&b|R&b,E=2400959708):(S=h^R^b,E=3395469782);let T=be(C,5)+S+I+E+l[y]>>>0;I=b,b=R,R=be(h,30),h=C,C=T;}o=o+C>>>0,s=s+h>>>0,p=p+R>>>0,c=c+b>>>0,u=u+I>>>0;}let m=new Uint8Array(20),f=new DataView(m.buffer);for(let[g,C]of [o,s,p,c,u].entries())f.setUint32(g*4,C);return m}function Tt(n){let e=Array.from(n,t=>t.toString(16).padStart(2,"0")).join("").slice(0,32);return `${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function te(){let n=globalThis.crypto?.randomUUID?.();if(!n)throw new Error("This runtime cannot mint a cryptographically secure UUID");return n.toLowerCase()}var Nt=te;function Ce(n,e){if(!Number.isInteger(e)||e<0||e>2147483647)throw new Error("Stream chunk ordinal must be an integer from 0 through 2147483647");Ke(n);let t=n.toLowerCase(),r=Ke(kt),i=new TextEncoder().encode(`${t}:${e}`),o=xt(Uint8Array.from([...r,...i])).slice(0,16);return o[6]=o[6]&15|80,o[8]=o[8]&63|128,Tt(o)}var _t=new Set(["arc","bond","pair","set","list"]);function V(n,e){let t=Ge(n,e,"add");return {operation:"add",kind:"collection",name:t.name,type:t.type,members:t.members,...n.skipExisting===true?{skipExisting:true}:{}}}function re(n,e){let t=Ge(n,e,"revise");if(!t.name)throw new Error(`${e}: collection revise requires a target name`);return {operation:"revise",kind:"collection",name:t.name,type:t.type,members:t.members,...typeof n.expectedVersion=="number"?{expectedVersion:n.expectedVersion}:{},...typeof n.leaseId=="string"&&n.leaseId.length>0?{leaseId:n.leaseId}:{}}}function Ge(n,e,t$1){let r=t({operation:t$1,kind:"collection",name:typeof n.name=="string"?n.name:void 0,type:typeof n.type=="string"?n.type:void 0,members:Array.isArray(n.members)?n.members:void 0},0);if(r.length>0)throw new Error(`${e}: ${r.map(s=>s.message).join("; ")}`);let i=Lt(n.type);if(!i)throw new Error(`${e}: collection ${t$1} requires 'type'. Use one of: arc, bond, set, list`);if(!Array.isArray(n.members))throw new Error(`${e}: collection ${t$1} requires a 'members' array`);let o=Dt(n.name);if(!o)throw new Error(`${e}: collection ${t$1} name must be a non-empty string`);return Pt(n,e,t$1),{name:o,type:i,members:n.members}}function Pt(n,e,t){let r=["about","aboutWref","shapeWref","data",...t==="revise"?["skipExisting"]:[]].filter(i=>n[i]!==void 0);if(r.length>0)throw new Error(`${e}: collection ${t} does not support ${r.map(i=>`'${i}'`).join(", ")}`)}function Lt(n){if(typeof n!="string")return;let e=n.trim();if(_t.has(e))return e}function Dt(n){if(typeof n=="string"&&!(n.length===0||n.trim()!==n))return n}function ne(n){if(n.expectedVersion!==void 0&&n.operation!=="revise"&&n.operation!=="retract")throw new Error("expectedVersion is only valid on revise or retract operations \u2014 set an explicit operation discriminator");if(n.operation==="retract")return {operation:"retract",name:n.name,...n.kind?{kind:n.kind}:{},...n.reason?{reason:n.reason}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.operation==="rename")return {operation:"rename",name:n.name,newName:n.newName,...n.kind?{kind:n.kind}:{}};if(n.operation==="revise"){let r=n.name??n.wref;if(!r)throw new Error("revise operation requires a target");let i=h({kind:n.kind,name:r});if(Object.hasOwn(n,"active"))throw new Error(`${i} revise operation no longer supports 'active' \u2014 use retract('${r}') instead`);if(i==="collection")return re(n,"commit.apply");if(n.data===void 0)throw new Error(`${i} revise operation requires 'data'`);return i==="assertion"?{operation:"revise",kind:"assertion",name:r,data:n.data,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}:{operation:"revise",kind:i,name:r,data:n.data,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}}let e=h(n),t="skipExisting"in n?n.skipExisting:void 0;if(e!=="collection"&&("type"in n&&n.type!==void 0||"members"in n&&n.members!==void 0))throw new Error(`add operation '${n.name??""}' has collection fields but resolved kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`);if(e==="collection")return V({...n,skipExisting:t},"commit.apply");if(!n.name)throw new Error("add operation requires a name");if(e==="assertion"){if(!("about"in n)||n.about===void 0)throw new Error("assertion add operation requires 'about'");if(typeof n.about!="string")throw new Error(s);if(n.data===void 0)throw new Error("assertion add operation requires 'data'");return {operation:"add",kind:"assertion",name:n.name,about:n.about,data:n.data,...t===true?{skipExisting:t}:{}}}if(n.data===void 0)throw new Error(`${e} add operation requires 'data'`);return {operation:"add",kind:e,name:n.name,data:n.data,...t===true?{skipExisting:t}:{}}}var ie=1e3,oe=1e4,k=class extends Error{code="PARTIAL_STREAM_SUBMISSION";completedReceipts;completedOperations;submissionId;eventRequestId;chunkOrdinal;pendingOutcome;acknowledgedOperationCount;lastAcknowledgedRepoSeq;attemptedAppendOutcome;cause;constructor(e){super(e.pendingOutcome==="unknown"?`Stream submission outcome is unknown for event request ${e.eventRequestId}. Look up its immutable receipt before retrying.`:`Stream submission stopped at event request ${e.eventRequestId} after earlier chunks committed.`),this.name="WarmHubError",this.cause=e.cause,this.completedReceipts=e.completedReceipts,this.completedOperations=e.completedOperations??[],this.submissionId=e.submissionId,this.eventRequestId=e.eventRequestId,this.chunkOrdinal=e.chunkOrdinal,this.pendingOutcome=e.pendingOutcome,this.acknowledgedOperationCount=e.acknowledgedOperationCount??e.completedReceipts.length,this.attemptedAppendOutcome=e.attemptedAppendOutcome,e.lastAcknowledgedRepoSeq!==void 0&&(this.lastAcknowledgedRepoSeq=e.lastAcknowledgedRepoSeq);}},x=class extends Error{code="STREAM_ALL_OPERATIONS_FAILED";receipts;result;operations;statusCounts;cause;constructor(e){let t=e.operations.find(r=>r.error!==void 0)?.error;super(t?`All ${e.operationCount} stream operations failed: ${t.message}`:`All ${e.operationCount} stream operations failed.`),this.name="WarmHubError",this.cause=t,this.result=e,this.receipts=e.receipts,this.operations=e.operations,this.statusCounts=e.statusCounts??{applied:0,noop:0,error:e.operationCount};}};function F(n){let e="status"in n?n.status:void 0;return e==="failed"?"error":e==="noop"||n.operation==="noop"?"noop":"applied"}function se(n){let e={applied:0,noop:0,error:0};for(let t of n)e[F(t)]++;return e}var Mt={maxAttempts:3,baseDelayMs:250,maxDelayMs:8e3},qt=10,ze=6e4;function Se(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={...Mt,...e};return {maxAttempts:Math.min(qt,Math.max(1,Math.trunc(t.maxAttempts))),baseDelayMs:Math.min(ze,Math.max(0,Math.trunc(t.baseDelayMs))),maxDelayMs:Math.min(ze,Math.max(0,Math.trunc(t.maxDelayMs)))}}var Ut=new Set(["BAD_REQUEST","METHOD_NOT_SUPPORTED","PARSE_ERROR","PAYLOAD_TOO_LARGE","PRECONDITION_FAILED","UNAUTHORIZED","UNPROCESSABLE_CONTENT","UNSUPPORTED_MEDIA_TYPE","UNAUTHENTICATED","FORBIDDEN","VALIDATION_ERROR","SHAPE_MISMATCH","RESERVED_NAME","ILLEGAL_OP_SEQUENCE","NOT_FOUND","KIND_MISMATCH","CONFLICT","ALREADY_RETRACTED","ARCHIVED","RATE_LIMITED","TOO_MANY_REQUESTS","UNRESOLVED_TOKEN"]),Bt=new Set(["COMMIT_OUTCOME_UNKNOWN"]);function Ye(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 Ht(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 Vt(n){return n!==void 0&&n>=400&&n<500&&n!==408}function Qe(n){let e=Ye(n);return e!==void 0&&Bt.has(e)}function W(n){if(Qe(n))return false;let e=Ye(n);return e!==void 0&&Ut.has(e)||Vt(Ht(n))}function we(n){if(Qe(n)||W(n))return false;if(je(n))return true;if(n instanceof TypeError||n instanceof SyntaxError)return false;let e=n?.cause;return je(e)?true:!(e instanceof TypeError||e instanceof SyntaxError)}function je(n){return n instanceof TypeError&&/fetch/i.test(n.message)}function Ae(n,e){let t=e.baseDelayMs*2**Math.max(0,n-1),r=Math.random()*e.baseDelayMs;return Math.min(e.maxDelayMs,t+r)}function Oe(n){return new Promise(e=>setTimeout(e,n))}var $=class extends Error{code;status=400;constructor(e,t="VALIDATION_ERROR"){super(e),this.code=t,this.name="WarmHubError";}};async function L(n,e){if(e.operations.length===0)throw new $("At least one operation is required for stream submission.");let t=e.operations.map((h,R)=>{let b;try{b=ne(h);}catch(I){let y=I instanceof Error?I.message:String(I);throw new $(`Invalid operation at index ${R}: ${y}`)}return e.skipExisting===true&&b.operation==="add"?{...b,skipExisting:true}:b});Wt(t);let r=Kt(e.chunkSize),i=e.submissionId??te(),o=e.streamId??i,s=Se(e.retry),p=[],c,u,l=[],m=[],f=0,g;for(let[h,R]of Gt(t,r).entries()){let b=Ce(i,h),I=1,y=false;for(;;)try{let S=await n.stream.append({allocatedTokenRanges:p,chunkOrdinal:h,orgName:e.orgName,repoName:e.repoName,streamId:o,submissionId:i,componentRef:e.componentRef,committer:e.committer,message:e.message,...e.returnRepoSeq!==void 0?{returnRepoSeq:e.returnRepoSeq}:{},operations:R.operations}),E=S.receipt;m.push(E),p=S.allocatedTokenRanges,c=S.createdByEmail??c,u=S.repoSeq??u,l.push(...Ie(S.results,R.start)),f+=R.operations.length;let T=Ft(E);T!==void 0&&(g=T);break}catch(S){let E=W(S);if(m.length===0&&!y&&E)throw S;if(s!==false&&I<s.maxAttempts&&we(S)){await Oe(Ae(I,s)),I+=1,y=true;continue}let T=y||!E?"unknown":"absent";throw new k({cause:S,completedReceipts:m,completedOperations:Ee(ae({committer:e.committer,createdByEmail:c,message:e.message,operations:t,repoSeq:u,receipts:m,results:l})),acknowledgedOperationCount:f,lastAcknowledgedRepoSeq:g,attemptedAppendOutcome:T==="absent"?"not_applied":"unknown",submissionId:i,eventRequestId:b,chunkOrdinal:h,pendingOutcome:T})}}let C=ae({committer:e.committer,createdByEmail:c,message:e.message,operations:t,repoSeq:u,receipts:m,results:l});if(C.operations.length>0&&C.operations.every(h=>h.status==="error"))throw new x(C);return C}function Ft(n){let e=n.event?.repoSeq;if(e===void 0)return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function Wt(n){let t=u(n).filter(r=>!$t(r))[0];if(t)throw new $(`Invalid operation at index ${t.operationIndex}: ${t.message}`,t.code)}function $t(n){return n.code==="ILLEGAL_OP_SEQUENCE"&&n.message.includes("Cannot revise then add ")}function Kt(n){return Number.isFinite(n)?Math.max(1,Math.min(oe,Math.trunc(n))):ie}function Gt(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push({operations:n.slice(r,r+e),start:r});return t}function Ie(n,e){return n.map((t,r)=>({...t,opIndex:e+(t.opIndex??r)}))}function ae(n){let e=se(n.results),t=e.error>0;return {...n.committer!==void 0?{committer:n.committer}:{},...n.createdByEmail!==void 0?{createdByEmail:n.createdByEmail}:{},message:n.message,operationCount:n.results.length,...n.repoSeq!==void 0?{repoSeq:n.repoSeq}:{},...t?{partial:t,statusCounts:e}:{},operations:n.results.map(r=>({...r.opIndex!==void 0?{opIndex:r.opIndex}:{},name:r.name??"",operation:r.operation==="revise"||r.operation==="retract"||r.operation==="rename"||r.operation==="noop"?r.operation:"add",dataHash:r.dataHash??"",version:r.version??0,status:F(r),error:r.error,...r.status==="failed"&&r.opIndex!==void 0&&n.operations[r.opIndex]?.name!==void 0?{submittedName:n.operations[r.opIndex]?.name}:{},...r.resolvedName!==void 0?{resolvedName:r.resolvedName}:{},...r.retryable!==void 0?{retryable:r.retryable}:{},...r.warnings?{warnings:r.warnings}:{}})),receipts:n.receipts}}function Ee(n){return n.operations.filter(e=>e.status!=="error")}var zt="0.0.0-development";function D(n){return n===zt}var ke="0.85.0";var Je=1;function jt(n){return n===c?"Run: wh update --yes":n===b?"Run: npm install @warmhub/sdk-ts@latest (or your package manager's equivalent).":n===d$1?"Run: pip install --upgrade warmhub":`Deploy a released ${n} build that satisfies the backend compatibility contract.`}function Xe(n$1,e){if(typeof n$1?.minSupportedClients!="object"||n$1.minSupportedClients===null||!Number.isSafeInteger(n$1.writeContractVersion)||n$1.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$1.minSupportedClients[e.name];if(typeof t!="string"||!n(t))return {message:`The backend does not advertise a valid compatibility floor for ${e.name}.`,hint:"Upgrade the WarmHub backend or register this first-party client family before writing."};if(!D(e.version)){if(!n(e.version))return {message:`${e.name} reported malformed version "${e.version}".`,hint:"Use a released WarmHub client with a SemVer package version."};if(o(e.version,t)<0)return {message:`${e.name} ${e.version} is older than the backend's minimum supported version ${t}.`,hint:jt(e.name)}}if(n$1.writeContractVersion<Je)return {message:`${e.name} requires write contract ${Je}, but the backend provides ${n$1.writeContractVersion}.`,hint:"Upgrade the WarmHub backend before retrying this write."}}function ve(n,e){try{return new URL(n).origin===new URL(e).origin}catch{return false}}var Yt=new Set(["GET","POST","PUT","PATCH","DELETE"]),w=class extends Error{reason;constructor(e,t){super(t),this.name="CliCallVerificationError",this.reason=e;}};async function Qt(n,e,t){let r=n.method.toUpperCase();if(!Yt.has(r))throw new w("unsupported-method",`Unsupported HTTP method "${n.method}" \u2014 component CLI dispatch only emits GET, POST, PUT, or PATCH`);let i$1=r,o=n.headers.get(i);if(!o)throw new w("missing-install-repo",`Missing ${i} header`);let s=M(e.CLI_SIGNING_SECRET),p=M(e.CLI_BEARER_TOKEN),c=M(e.CLI_API_KEY),u=M(e.CLI_BASIC_USERNAME)&&M(e.CLI_BASIC_PASSWORD);if(!s&&!p&&!c&&!u)throw new w("no-scheme-configured","no-scheme-configured: need at least one of CLI_SIGNING_SECRET, CLI_BEARER_TOKEN, CLI_API_KEY, or CLI_BASIC_USERNAME + CLI_BASIC_PASSWORD");if(p&&u)throw new w("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$1=new URL(n.url),m$1=l$1.pathname,f,g,C;if(l(i$1)?f={}:(f=Object.fromEntries(l$1.searchParams.entries()),g="",C={...f}),s){let h=n.headers.get(j);if(!h)throw new w("missing-signature",`Missing ${j} header`);let R=n.headers.get(k$1);if(!R)throw new w("missing-timestamp",`Missing ${k$1} header`);let b=Number(R);if(!Number.isFinite(b)||!Number.isInteger(b))throw new w("invalid-timestamp",`${k$1} must be an integer unix seconds value; got "${R}"`);g=await Ze(n,i$1,g);let I=await m({secret:e.CLI_SIGNING_SECRET,method:i$1,path:m$1,query:f,installRepo:o,body:g,signature:h,timestamp:b,nowUnixSeconds:t?.nowUnixSeconds??Math.floor(Date.now()/1e3),toleranceSec:t?.toleranceSec});if(!I.ok)throw new w(I.reason,`HMAC verification failed: ${I.reason}`)}if(p){let h=`Bearer ${e.CLI_BEARER_TOKEN}`,R=n.headers.get("authorization")??"";if(!await xe(R,h))throw new w("invalid-bearer","invalid-bearer: bearer token mismatch")}if(c){let h=M(e.CLI_API_KEY_HEADER)?e.CLI_API_KEY_HEADER:"X-API-Key",R=n.headers.get(h)??"";if(!await xe(R,e.CLI_API_KEY))throw new w("invalid-api-key",`invalid-api-key: mismatch on header "${h}"`)}if(u){let h=`Basic ${btoa(`${e.CLI_BASIC_USERNAME}:${e.CLI_BASIC_PASSWORD}`)}`,R=n.headers.get("authorization")??"";if(!await xe(R,h))throw new w("invalid-basic","invalid-basic: basic auth mismatch")}return C===void 0&&(g=await Ze(n,i$1,g),C=Jt(g)),{method:i$1,installRepo:o,args:C}}async function Ze(n,e,t){return l(e)?t!==void 0?t:n.text():""}function Jt(n){let e;try{e=JSON.parse(n);}catch{throw new w("invalid-body","POST body is not valid JSON")}if(!Xt(e))throw new w("invalid-body","POST body must be a JSON object of primitive args (string / number / boolean)");return e}function M(n){return typeof n=="string"&&n.length>0}function Xt(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 xe(n,e){let[t,r]=await Promise.all([et(n),et(e)]),i=0;for(let o=0;o<t.length;o++)i|=t[o]^r[o];return i===0}async function et(n){return new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)))}function Ne(n){if(n.includes("/"))return n.split("/")[0]}function tt(n){if("shapeWref"in n&&typeof n.shapeWref=="string")return n.shapeWref;if(n.name)return Ne(n.name)}function Te(n){if(typeof n!="string")return;let e=n.trim();return e.length>0?e:void 0}function q(n){return h({kind:n.kind,name:n.name,about:ue(n),type:ce(n),members:pe(n)})}function ue(n){if("about"in n&&n.about!==void 0)return n.about;if("aboutWref"in n)return n.aboutWref}function _e(n){return "data"in n?n.data:void 0}function ce(n){return "type"in n?n.type:void 0}function pe(n){return "members"in n?n.members:void 0}function K(n,e){return h({kind:n.kind,name:e})}function rt(n){if(n.operation==="retract")return ne(n);if(n.operation==="add"){let r=q(n);if(r==="collection")return V(n,"OperationBuilder");let i=n,o=Te(i.name);if(!o)throw new Error("OperationBuilder: add operation missing name");if(r==="assertion"){let s$1=ue(i);if(s$1===void 0)throw new Error(`OperationBuilder: assertion add '${o}' missing required 'about'`);if(typeof s$1!="string")throw new Error(s);return {operation:"add",kind:r,name:o,about:s$1,data:i.data??{},...i.skipExisting===true?{skipExisting:true}:{}}}return {operation:"add",kind:r,name:o,data:i.data??{},...i.skipExisting===true?{skipExisting:true}:{}}}let e=Te(n.name)??Te(n.wref);if(!e)throw new Error("OperationBuilder: revise operation missing required target ('name' or 'wref')");let t=K(n,e);return t==="collection"?re({...n,name:e},"OperationBuilder"):{operation:"revise",kind:t,name:e,data:n.data??{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}}function N(n,e){return n.operation==="add"?{operation:n.operation,kind:e,name:n.name,about:ue(n),type:ce(n),members:pe(n)}:{operation:n.operation,kind:e,name:n.name??n.wref,type:ce(n),members:pe(n)}}function nt(n){if(n.length!==0)throw new Error(n.join("; "))}function it(n,e,t,r){let i=[];if((e==="thing"||e==="assertion"||e==="collection"&&n==="REVISE")&&(g(t)||i.push(`${n} ${e} name must be a local path (Shape/name), got: "${t}"`)),e==="shape"&&(n==="ADD"||n==="REVISE")&&r!==void 0){let s=H(t,r,n==="REVISE"?"revise":"add");s&&i.push(s);}return i}function ot(n,e){let t$1=[];if(n.name&&t$1.push(...it("ADD",e,n.name,_e(n))),e==="assertion"&&ue(n)===void 0&&t$1.push(`ADD assertion '${n.name}' missing required 'about' \u2014 for hierarchical thing names set kind: 'thing' explicitly`),e!=="collection"&&(ce(n)!==void 0||pe(n)!==void 0)&&t$1.push(`ADD '${n.name}' has collection fields but inferred kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`),e==="collection")try{V(n,"OperationBuilder");}catch(r){t$1.push(r instanceof Error?r.message:String(r));}for(let r of t(N(n,e),0))t$1.push(r.message);nt(t$1);}function st(n,e,t$1){let r=[];n!=="collection"&&t$1.data===void 0&&r.push(`OperationBuilder: ${n} revise requires 'data'`),r.push(...it("REVISE",n,e,t$1.data),...t(N({...t$1,name:e},n),0).map(i=>i.message)),nt(r);}var le=class{ops=[];pendingNames=new Set;shapes;wrefToShape=new Map;submitted=false;inFlight=false;constructor(e){this.shapes=e?.shapes;}add(e){this.assertCanModify();let t={...e};delete t.operation;let r=tt(t),i=_e(t);if(this.shapes&&r&&i!==void 0){let c=this.shapes[r];if(c){let u=E(i,c);if(!u.valid)throw new Error(`Shape validation failed for '${t.name}' (shape: ${r}): ${u.errors.join("; ")}`)}}let o={operation:"add",...t},s=q(o);(o.name||s==="collection")&&ot(o,s);let p=Object.freeze({operation:"add",...t});return this.ops.push(p),t.name&&(this.pendingNames.add(t.name),r&&this.wrefToShape.set(t.name,r)),this}revise(e){this.assertCanModify();let t={...e};delete t.operation;let r=t.name??t.wref;if(this.shapes&&r&&t.data!==void 0){let o=this.wrefToShape.get(r)??Ne(r);if(o){let s=this.shapes[o];if(s){let p=E(t.data,s);if(!p.valid)throw new Error(`Shape validation failed for revise '${r}' (shape: ${o}): ${p.errors.join("; ")}`)}}}if(r){let o=K({...t},r);st(o,r,{operation:"revise",...t});}let i=Object.freeze({operation:"revise",...t});return this.ops.push(i),this}retract(e){this.assertCanModify();let t=Object.freeze(typeof e=="string"?{operation:"retract",name:e}:{operation:"retract",name:e.name,...e.kind?{kind:e.kind}:{},...e.reason?{reason:e.reason}:{},...e.expectedVersion!==void 0?{expectedVersion:e.expectedVersion}:{},...e.leaseId?{leaseId:e.leaseId}:{}});return this.ops.push(t),this}get operations(){return Object.freeze([...this.ops])}get size(){return this.ops.length}has(e){return this.pendingNames.has(e)}validate(){let e=[],t$1=[],r=new Set,i=new Set;for(let c=0;c<this.ops.length;c+=1){let u=this.ops[c];if(u){if(u.operation==="add"){let l=q(u);!u.name&&l!=="collection"?e.push({code:"MISSING_NAME",operationIndex:c,message:`Add operation at index ${c} is missing required 'name' field`}):u.name&&(r.has(u.name)&&e.push({code:"DUPLICATE_NAME",operationIndex:c,message:`Duplicate name '${u.name}' at index ${c} (already added earlier in commit)`}),r.add(u.name));}if(u.operation==="revise"){let l=u.name??u.wref;l?i.has(l)?e.push({code:"REVISE_AFTER_RETRACT",operationIndex:c,message:`Revise at index ${c} targets '${l}' which was already retracted in this commit`}):r.has(l)||t$1.push({code:"REVISE_UNKNOWN_WREF",operationIndex:c,message:`Revise at index ${c} references '${l}' which was not added in this commit (assuming it exists server-side)`}):e.push({code:"MISSING_WREF",operationIndex:c,message:`Revise operation at index ${c} is missing required target ('name' or 'wref')`});}u.operation==="retract"&&(u.name?i.has(u.name)?t$1.push({code:"RETRACT_AFTER_RETRACT",operationIndex:c,message:`Retract at index ${c} targets '${u.name}' which was already retracted in this commit`}):(r.has(u.name)||t$1.push({code:"RETRACT_UNKNOWN_WREF",operationIndex:c,message:`Retract at index ${c} references '${u.name}' which was not added in this commit (assuming it exists server-side)`}),i.add(u.name)):e.push({code:"MISSING_NAME",operationIndex:c,message:`Retract operation at index ${c} is missing required 'name' field`}));}}let o=this.ops.flatMap((c,u)=>{if(c.operation==="add")return t(N(c,q(c)),u);if(c.operation==="revise"){let l=c.name??c.wref;return t(N(c,l?K(c,l):"thing"),u)}return t({operation:"retract",kind:c.kind,name:c.name},u)});for(let c of o)e.push({code:c.code,operationIndex:c.operationIndex,message:c.message});let s=this.ops.flatMap((c,u)=>{if(c.operation==="retract")return [];if(c.operation==="add")return [{op:N(c,q(c)),operationIndex:u}];let l=c.name??c.wref;return [{op:N(c,l?K(c,l):"thing"),operationIndex:u}]}),p=u(s.map(({op:c})=>c),{checkAddAdd:false,sourceOperationIndexes:s.map(({operationIndex:c})=>c)});for(let c of p)e.push({code:c.code,operationIndex:c.operationIndex,message:c.message});return this.ops.length===0&&e.push({code:"EMPTY_COMMIT",operationIndex:-1,message:"OperationBuilder has no operations"}),{valid:e.length===0,errors:e,warnings:t$1}}async commit(e){if(this.assertNotSubmitted(),this.inFlight)throw new Error("OperationBuilder: stream submission already in flight");let t=this.validate();if(!t.valid){let r=t.errors.map(i=>i.message).join("; ");throw new Error(`OperationBuilder validation failed: ${r}`)}this.inFlight=true;try{let r=this.ops.map(o=>rt(o)),i=await L(e.client,{orgName:e.orgName,repoName:e.repoName,committer:e.committer,message:e.message,chunkSize:e.chunkSize,streamId:e.streamId,submissionId:e.submissionId,returnRepoSeq:e.returnRepoSeq,retry:e.retry,operations:r});return this.submitted=!0,i}catch(r){throw r instanceof k&&(this.submitted=true),r}finally{this.inFlight=false;}}assertNotSubmitted(){if(this.submitted)throw new Error("OperationBuilder: already submitted, cannot modify")}assertCanModify(){if(this.assertNotSubmitted(),this.inFlight)throw new Error("OperationBuilder: stream submission already in flight, cannot modify")}};function kn(n){return n.replace(/@(?:v\d+|HEAD|ALL)$/i,"")}var Ct=["apiUrl","fetch","accessToken","auth","functionLogs","client"],sr=new Set(Ct),ar=new Set(["token","apiKey","bearer"]);function cr(n){if(n)for(let e of Object.keys(n)){if(sr.has(e))continue;let t=ar.has(e)?'; did you mean "accessToken"?':`. Valid options are: ${Ct.join(", ")}.`;throw new TypeError(`Unknown WarmHubClient option "${e}"${t}`)}}var Pe="https://api.warmhub.ai",pr=new Set(["repo.shapeInstanceCounts","thing.getMany","thing.headVersions"]),at=500,ct=500,pt=1,ut=8;function he(n){return {...n,actionContainer:void 0,actionContainerConfig:void 0}}function ur(n){return n.map(e=>he(e))}function St(n,e,t){if(e===n||t.has(e))throw new d("VALIDATION_ERROR","Paginated result cursor did not advance")}function lt(n){if(n===void 0)throw new d("VALIDATION_ERROR","sinceRepoSeq is required for an incremental read")}async function*wt(n,e){let t=e,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(yield i,!i.nextCursor)return;St(t,i.nextCursor,r),t=i.nextCursor;}}async function*A(n,e,t){for await(let r of wt(n,t))yield*e(r);}async function O(n,e,t,r){if(t!==void 0&&(!Number.isFinite(t)||Math.trunc(t)!==t||t<0))throw new d("VALIDATION_ERROR","max must be a nonnegative integer");let i=[];for await(let o of wt(n,r)){let s=e(o);if(t!==void 0&&i.length+s.length>t)throw new d("VALIDATION_ERROR",`Paginated result exceeded max=${t}`);i.push(...s);}return i}function dt(n){if(n?.slugs!==void 0)throw new d("VALIDATION_ERROR","repo.explore pagination helpers do not support slugs mode")}async function mt(n){let e=[],t,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(e.push(...i.items),!i.nextCursor){if(i.repoSeq===void 0)throw new d("VALIDATION_ERROR","Incremental read completed without repoSeq");return {items:e,repoSeq:i.repoSeq}}St(t,i.nextCursor,r),t=i.nextCursor;}}function de(n,e,t){return Number.isFinite(n)?Math.max(1,Math.min(t,Math.trunc(n))):e}function ht(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function me(n){return n!==void 0&&f.includes(n)?n:void 0}function G(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,name:r}:e}function lr(n){let[e,t]=n;return typeof e=="string"?{orgName:e,repoName:t}:e}function dr(n){let[e,t,r,i]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r,credentialSetName:i}:e}function mr(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r}:e}function hr(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function gr(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function ge(n){return !!n&&(!!n.shape||!!n.kind||!!n.about||!!n.match||!!n.componentRef||n.excludeComponents===true||(n.where?.length??0)>0)}function ye(n){return !!n&&(!!n.shape||!!n.about||!!n.match||!!n.componentRef||(n.where?.length??0)>0)}function At(n){let e=n.members;return Array.isArray(e)&&e.length>0}function yr(n){let t=n.replace(/^wh:[^/]+\/[^/]+\//,"").replace(/@(?:HEAD|ALL|v\d+)$/,"").split("/")[0]?.toLowerCase();return t==="arc"||t==="bond"||t==="pair"||t==="set"||t==="list"?t:void 0}function fr(n,e){if(ge(e.query)&&!ye(e.query))throw new d("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(e.sourceRepo&&!ye(e.query))throw new d("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(e.sourceRepo&&At(e))throw new d("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(ge(e.query)&&n!=="set")throw new d("VALIDATION_ERROR","Selector-backed collection sources are only supported for set collections")}function vn(n){return n??"off"}function Rr(n){switch(n){case "BAD_REQUEST":case "PARSE_ERROR":case "PAYLOAD_TOO_LARGE":case "UNPROCESSABLE_CONTENT":case "UNSUPPORTED_MEDIA_TYPE":return "VALIDATION_ERROR";case "METHOD_NOT_SUPPORTED":return "NOT_FOUND";case "UNAUTHORIZED":return "UNAUTHENTICATED";case "FORBIDDEN":return "FORBIDDEN";case "NOT_FOUND":return "NOT_FOUND";case "CONFLICT":return "CONFLICT";case "PRECONDITION_FAILED":return "PRECONDITION_FAILED";case "TOO_MANY_REQUESTS":return "RATE_LIMITED";default:return}}function br(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=It(n);return e!=="BACKEND"?e:n>=400&&n<500?"VALIDATION_ERROR":e}var Cr=[/\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 Le(n){for(let e of Cr)if(e.test(n))return "An internal error occurred. Please try again or contact support.";return n}var d=class extends Error{code;status;hint;retryAfter;errorCode;backendCode;details;constructor(e,t,r,i,o,s,p){super(t),this.name="WarmHubError",this.code=e,this.status=r,this.hint=i,this.retryAfter=o,this.errorCode=s,this.backendCode=s,this.details=p;}get kind(){return this.code}};function gt(n,e){if(typeof e!="string")return;let t=r(n,e);if(t)throw new d("VALIDATION_ERROR",t)}function a(n){if(n instanceof d)return n;if(n instanceof TRPCClientError){if(n.cause instanceof d)return n.cause;let e=n.data,t=e?.warmhub?.code,r=typeof e?.code=="string"?Rr(e.code):void 0,i=br(e?.httpStatus),o=e?.warmhub?.message??Le(n.message);return new d(t??r??i??"BACKEND",o,e?.warmhub?.status??e?.httpStatus,e?.warmhub?.hint,e?.warmhub?.retryAfter??e?.retryAfter,t,e?.warmhub?.details)}if(n instanceof Error){let e=n;return n.name==="WarmHubError"&&typeof e.code=="string"?new d(e.code,Le(n.message),typeof e.status=="number"?e.status:void 0,typeof e.hint=="string"?e.hint:void 0,typeof e.retryAfter=="number"?e.retryAfter:void 0,typeof e.errorCode=="string"?e.errorCode:typeof e.backendCode=="string"?e.backendCode:void 0,e.details):n.name==="AbortError"?new d("CANCELLED",n.message):n instanceof TypeError&&/fetch/i.test(n.message)?new d("NETWORK",n.message):new d("BACKEND",Le(n.message))}return new d("BACKEND","Unknown SDK error")}function Sr(n){return n instanceof d}function xn(n){let e=a(n);return e.kind==="NETWORK"||e.kind==="CANCELLED"||e.kind==="BACKEND"||e.kind==="RATE_LIMITED"}var wr=new Set(["ConnectionRefused","ECONNREFUSED","ENOTFOUND","ETIMEDOUT","EAI_AGAIN"]);function Ar(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"&&wr.has(e))return true}return false}function Or(n){return `Unable to connect to ${n}. Is the computer able to access the url?`}function Tn(n$1,e){return D(n$1)||!n(n$1)||!n(e)?false:o(n$1,e)<0}function Ot(n,e){return new d("CLIENT_INCOMPATIBLE",n,412,e)}function Ir(n,e){let t=Xe(n,e);if(t)throw Ot(t.message,t.hint)}var yt=class n{apiUrl;fetchImpl;accessToken;clientIdentity;functionLogMode;getToken;compatibilityCheck;assertWriteCompatible(){return D(this.clientIdentity.version)&&ve(this.apiUrl,Pe)?Promise.reject(Ot(`Development client ${this.clientIdentity.name}/${this.clientIdentity.version} cannot write to production.`,"Install a released WarmHub client artifact before writing to api.warmhub.ai.")):D(this.clientIdentity.version)&&!ve(this.apiUrl,Pe)?Promise.resolve():this.diagnostics.assertCompatible()}createCompatibilityLink(){return ()=>({op:e,next:t})=>e.type!=="mutation"?t(e):observable(r=>{let i=false,o;return this.assertWriteCompatible().then(()=>{i||(o=t(e).subscribe(r));}).catch(s=>{i||r.error(TRPCClientError.from(s));}),()=>{i=true,o?.unsubscribe();}})}auth={getClientId:async()=>{try{return await this.trpc.auth.getClientId.query()}catch(e){throw a(e)}},sync:async()=>{try{return await this.trpc.auth.sync.mutate()}catch(e){throw a(e)}},currentUser:async()=>{try{return await this.trpc.auth.currentUser.query()}catch(e){throw a(e)}},whoami:async()=>{try{return await this.trpc.auth.whoami.query()}catch(e){throw a(e)}}};homepage={featuredLists:async()=>{try{return await this.trpc.homepage.featuredLists.query()}catch(e){throw a(e)}}};access={resolve:async e=>{try{return await this.trpc.access.resolve.query(e)}catch(t){throw a(t)}}};diagnostics={ping:async()=>{let e=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/health`);if(!e.ok)throw new d("BACKEND",`Health request failed with status ${e.status}`,e.status);return await e.json()},capabilities:async()=>{try{return await this.trpc.diagnostics.capabilities.query()}catch(e){throw a(e)}},assertCompatible:()=>{if(this.compatibilityCheck)return this.compatibilityCheck;let e=(async()=>{let t=await this.diagnostics.capabilities();Ir(t,this.clientIdentity);})();return this.compatibilityCheck=e,e.catch(t=>{Sr(t)&&t.code==="CLIENT_INCOMPATIBLE"||this.compatibilityCheck===e&&(this.compatibilityCheck=void 0);}),e}};component={list:async(e,t,r)=>{try{return await this.trpc.component.list.query({orgName:e,repoName:t,limit:r?.limit,cursor:r?.cursor})}catch(i){throw a(i)}},listIter:(e,t,r)=>A(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 O(s=>this.component.list(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},search:async(e,t)=>{try{return await this.trpc.component.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw a(r)}},searchIter:(e,t)=>A(r=>this.component.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await O(o=>this.component.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},get:async(e,t,r)=>{try{return await this.trpc.component.get.query({orgName:e,repoName:t,componentRef:r})}catch(i){throw a(i)}},history:async(e,t,r)=>{try{return await this.trpc.component.history.query({orgName:e,repoName:t,componentRef:r?.componentRef,limit:r?.limit})}catch(i){throw a(i)}},install:async(e,t,r,i)=>{try{return await this.trpc.component.install.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw a(o)}},uninstall:async(e,t,r,i)=>{try{return await this.trpc.component.uninstall.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw a(o)}},registry:{register:async(e,t,r)=>{try{return await this.trpc.component.registry.register.mutate({orgName:e,componentName:t,...r})}catch(i){throw a(i)}},unregister:async(e,t)=>{try{return await this.trpc.component.registry.unregister.mutate({orgName:e,componentName:t})}catch(r){throw a(r)}},list:async e=>{try{return await this.trpc.component.registry.list.query({orgName:e})}catch(t){throw a(t)}},view:async(e,t)=>{try{return await this.trpc.component.registry.view.query({orgName:e,componentName:t})}catch(r){throw a(r)}},update:async(e,t,r)=>{try{return await this.trpc.component.registry.update.mutate({orgName:e,componentName:t,...r})}catch(i){throw a(i)}},resolve:async(e,t,r)=>await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/resolve`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({installRepo:r})}),setupCall:async(e,t,r)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/setup-call`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)}))},cli:{call:async(e,t,r,i)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cli/${encodeURIComponent(r)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}))}};commit={apply:async(e,t,r,i,o)=>{try{return await L(this,{orgName:e,repoName:t,committer:o?.committer,message:r,componentRef:o?.componentRef,chunkSize:o?.chunkSize,skipExisting:o?.skipExisting,streamId:o?.streamId,submissionId:o?.submissionId,returnRepoSeq:o?.returnRepoSeq,retry:o?.retry,operations:i})}catch(s){throw s instanceof k||s instanceof x?s:a(s)}},getReceipt:async(e,t,r)=>{try{return await this.trpc.commit.getReceipt.query({orgName:e,repoName:t,eventRequestId:r})}catch(i){throw a(i)}}};org={get:async e=>{try{return await this.trpc.org.get.query({orgName:e})}catch(t){throw a(t)}},getCallerRole:async e=>{try{return await this.trpc.org.getCallerRole.query({orgName:e})}catch(t){throw a(t)}},list:async e=>{try{return {items:await this.trpc.org.list.query({includeArchived:e?.includeArchived})}}catch(t){throw a(t)}},create:async(e,t,r)=>{try{return await this.trpc.org.create.mutate({name:e,displayName:t,description:r})}catch(i){throw a(i)}},setDescription:async(e,t)=>{try{return await this.trpc.org.setDescription.mutate({orgName:e,description:t})}catch(r){throw a(r)}},setDisplayName:async(e,t)=>{try{return await this.trpc.org.setDisplayName.mutate({orgName:e,displayName:t})}catch(r){throw a(r)}},rename:async(e,t)=>{try{return await this.trpc.org.rename.mutate({orgName:e,newName:t})}catch(r){throw a(r)}},update:async e=>{try{return await this.trpc.org.update.mutate(e)}catch(t){throw a(t)}},addMember:async(e,t,r="editor")=>{try{return await this.trpc.org.addMember.mutate({orgName:e,email:t,role:r})}catch(i){throw a(i)}},removeMember:async(e,t)=>{try{await this.trpc.org.removeMember.mutate({orgName:e,email:t});}catch(r){throw a(r)}},leave:async e=>{try{await this.trpc.org.leave.mutate({orgName:e});}catch(t){throw a(t)}},changeMemberRole:async(e,t,r)=>{try{return await this.trpc.org.changeMemberRole.mutate({orgName:e,email:t,role:r})}catch(i){throw a(i)}},setMemberScopes:async(e,t,r)=>{try{await this.trpc.org.setMemberScopes.mutate({orgName:e,email:t,scopes:r});}catch(i){throw a(i)}},clearMemberScopes:async(e,t)=>{try{await this.trpc.org.clearMemberScopes.mutate({orgName:e,email:t});}catch(r){throw a(r)}},listMembers:async(e,t)=>{try{return await this.trpc.org.listMembers.query({orgName:e,pending:t?.pending})}catch(r){throw a(r)}},archive:async e=>{try{return await this.trpc.org.archive.mutate({orgName:e})}catch(t){throw a(t)}},unarchive:async e=>{try{return await this.trpc.org.unarchive.mutate({orgName:e})}catch(t){throw a(t)}}};repo={checkpoint:$e(()=>this.trpc,a),get:async(e,t)=>{try{return await this.trpc.repo.get.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getStats:async(e,t)=>{try{return await this.trpc.repo.stats.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getStatsBatch:async(e,t)=>{try{return await this.trpc.repo.statsBatch.query({orgName:e,repoNames:t})}catch(r){throw a(r)}},getConfigureStats:async(e,t)=>{try{return await this.trpc.repo.configureStats.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getShapeInstanceCounts:async(e,t)=>{try{return await this.trpc.repo.shapeInstanceCounts.query({orgName:e,repoName:t})}catch(r){throw a(r)}},list:async(e,t)=>{try{return await this.trpc.repo.list.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw a(r)}},listIter:(e,t)=>A(r=>this.repo.list(e,{...t,cursor:r}),r=>r.items,t?.cursor),listAll:async(e,t)=>{let{max:r,...i}=t??{};return await O(o=>this.repo.list(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},search:async(e,t)=>{try{return await this.trpc.repo.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw a(r)}},searchIter:(e,t)=>A(r=>this.repo.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await O(o=>this.repo.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},create:async(e,t,r,i,o)=>{try{return await this.trpc.repo.create.mutate({orgName:e,repoName:t,description:r,visibility:i,displayName:o})}catch(s){throw a(s)}},setDescription:async(e,t,r)=>{try{return await this.trpc.repo.setDescription.mutate({orgName:e,repoName:t,description:r})}catch(i){throw a(i)}},setDisplayName:async(e,t,r)=>{try{return await this.trpc.repo.setDisplayName.mutate({orgName:e,repoName:t,displayName:r})}catch(i){throw a(i)}},setVisibility:async(e,t,r)=>{try{return await this.trpc.repo.setVisibility.mutate({orgName:e,repoName:t,visibility:r})}catch(i){throw a(i)}},rename:async(e,t,r)=>{try{return await this.trpc.repo.rename.mutate({orgName:e,repoName:t,newName:r})}catch(i){throw a(i)}},update:async e=>{try{return await this.trpc.repo.update.mutate(e)}catch(t){throw a(t)}},archive:async(e,t)=>{try{return await this.trpc.repo.archive.mutate({orgName:e,repoName:t})}catch(r){throw a(r)}},unarchive:async(e,t)=>{try{return await this.trpc.repo.unarchive.mutate({orgName:e,repoName:t})}catch(r){throw a(r)}},delete:async(e,t)=>{try{let r=await this.trpc.repo.delete.mutate({orgName:e,repoName:t});return {graceExpiresAt:new Date(r.graceExpiresAt)}}catch(r){throw a(r)}},listPage:async(e,t)=>{try{return await this.trpc.repo.listPage.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw a(r)}},listPageIter:(e,t)=>A(r=>this.repo.listPage(e,{...t,cursor:r}),r=>r.items,t?.cursor),listPageAll:async(e,t)=>{let{max:r,...i}=t??{};return await O(o=>this.repo.listPage(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},listForCaller:async e=>{try{return await this.trpc.repo.listForCaller.query({limit:e?.limit,sort:e?.sort})}catch(t){throw a(t)}},explore:async e=>{try{return await this.trpc.repo.explore.query({search:e?.search,org:e?.org,activity:e?.activity,hasSubscriptions:e?.hasSubscriptions,minThings:e?.minThings,sort:e?.sort,limit:e?.limit,cursor:e?.cursor,slugs:e?.slugs})}catch(t){throw a(t)}},exploreIter:e=>(dt(e),A(t=>this.repo.explore({...e,cursor:t}),t=>t.items,e?.cursor)),exploreAll:async e=>{dt(e);let{max:t,...r}=e??{};return await O(i=>this.repo.explore({...r,cursor:i}),i=>i.items,t,r.cursor)},getReadme:async(e,t)=>{try{return await this.trpc.repo.getReadme.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getAgents:async(e,t)=>{try{return await this.trpc.repo.getAgents.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getLicense:async(e,t)=>{try{return await this.trpc.repo.getLicense.query({orgName:e,repoName:t})}catch(r){throw a(r)}},describe:async(e,t)=>{try{return await this.trpc.repo.describe.query({orgName:e,repoName:t})}catch(r){throw a(r)}},setReadme:async(e,t,r,i)=>{try{return gt("Content/Readme.content",r),await this.trpc.repo.setReadme.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw a(o)}},setAgents:async(e,t,r,i)=>{try{return gt("Content/Agents.content",r),await this.trpc.repo.setAgents.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw a(o)}},getLlmsTxt:async(e,t)=>{try{return await this.trpc.repo.getLlmsTxt.query({orgName:e,repoName:t})}catch(r){throw a(r)}},index:{describe:async(e,t)=>{try{return await this.trpc.repo.index.describe.query({orgName:e,repoName:t})}catch(r){throw a(r)}}}};shape={list:async(e,t,r)=>{try{return await this.trpc.shape.list.query({orgName:e,repoName:t,match:r?.match,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,includeRetracted:r?.includeRetracted})}catch(i){throw a(i)}},get:async(e,t,r,i)=>{try{return await this.trpc.shape.get.query({orgName:e,repoName:t,shapeName:r,includeRetracted:i?.includeRetracted})}catch(o){throw a(o)}},create:async(e,t,r,i,o)=>{let s=H(r,{fields:i,...o.description!==void 0?{description:o.description}:{}},"add");if(s)throw new d("VALIDATION_ERROR",s);try{return await this.trpc.shape.create.mutate({orgName:e,repoName:t,shapeName:r,fields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(p){throw a(p)}},revise:async(e,t,r,i,o)=>{let s=H(r,{fields:i,...o.description!==void 0?{description:o.description}:{}},"revise");if(s)throw new d("VALIDATION_ERROR",s);try{return await this.trpc.shape.revise.mutate({orgName:e,repoName:t,shapeName:r,newFields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(p){throw a(p)}},remove:async(e,t,r,i)=>{try{return await this.trpc.shape.remove.mutate({orgName:e,repoName:t,shapeName:r,eventRequestId:i.eventRequestId})}catch(o){throw a(o)}},rename:async(e,t,r,i,o)=>{try{return await this.trpc.shape.rename.mutate({orgName:e,repoName:t,oldName:r,newName:i,eventRequestId:o.eventRequestId})}catch(s){throw a(s)}},history:async(e,t,r,i={})=>{try{return await this.trpc.shape.history.query({orgName:e,repoName:t,name:r,includeRetracted:i.includeRetracted,limit:i.limit,cursor:i.cursor})}catch(o){throw a(o)}},historyIter:(e,t,r,i={})=>A(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 O(p=>this.shape.history(e,t,r,{...s,cursor:p}),p=>p.versions,o,s.cursor)}};subscription={create:async e=>{try{let t=await this.trpc.subscription.create.mutate(hr(e));return he(t)}catch(t){throw a(t)}},get:async(...e)=>{try{let t=await this.trpc.subscription.get.query(G(e));return he(t)}catch(t){throw a(t)}},reveal:async(...e)=>{try{return await this.trpc.subscription.reveal.query(G(e))}catch(t){throw a(t)}},list:async(...e)=>{try{let t=await this.trpc.subscription.list.query(lr(e));return ur(t)}catch(t){throw a(t)}},update:async e=>{try{let t=await this.trpc.subscription.update.mutate(gr(e));return he(t)}catch(t){throw a(t)}},pause:async(...e)=>{try{return await this.trpc.subscription.pause.mutate(G(e))}catch(t){throw a(t)}},resume:async(...e)=>{try{return await this.trpc.subscription.resume.mutate(G(e))}catch(t){throw a(t)}},remove:async(...e)=>{try{return await this.trpc.subscription.remove.mutate(G(e))}catch(t){throw a(t)}},bindCredentials:async(...e)=>{try{return await this.trpc.subscription.bindCredentials.mutate(dr(e))}catch(t){throw a(t)}},unbindCredentials:async(...e)=>{try{return await this.trpc.subscription.unbindCredentials.mutate(mr(e))}catch(t){throw a(t)}}};action={acquireLease:async(e,t,r,i,o,s)=>{try{return await this.trpc.action.acquireLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,holderType:o,graceMs:s?.graceMs,ttlMs:s?.ttlMs})}catch(p){throw a(p)}},heartbeatLease:async(e,t,r,i,o)=>{try{return await this.trpc.action.heartbeatLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,ttlMs:o})}catch(s){throw a(s)}},releaseLease:async(e,t,r,i)=>{try{return await this.trpc.action.releaseLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i})}catch(o){throw a(o)}},claimDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.claimDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw a(s)}},completeDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.completeDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw a(s)}},liveFeed:async(e,t,r,i)=>{try{return await this.trpc.action.liveFeed.query({orgName:e,repoName:t,subscriptionName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},liveFeedIter:(e,t,r,i)=>A(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 O(p=>this.action.liveFeed(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)},listRuns:async(e,t,r)=>{try{return await this.trpc.action.listRuns.query({orgName:e,repoName:t,runId:r?.runId,subscriptionName:r?.subscriptionName,status:r?.status,outcome:r?.outcome,since:r?.since,cursor:r?.cursor,limit:r?.limit})}catch(i){throw a(i)}},listRunsIter:(e,t,r)=>A(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 O(s=>this.action.listRuns(e,t,{...o,since:s===void 0?o.since:void 0,cursor:s}),s=>s.items,i,o.cursor)},latestRuns:async(e,t)=>{try{return await this.trpc.action.latestRuns.query({orgName:e,repoName:t})}catch(r){throw a(r)}},runStats:async(e,t,r)=>{try{return await this.trpc.action.runStats.query({orgName:e,repoName:t,subscriptionName:r?.subscriptionName,since:r?.since})}catch(i){throw a(i)}},getRunAttempts:async(e,t,r)=>{try{return await this.trpc.action.getRunAttempts.query({orgName:e,repoName:t,runId:r})}catch(i){throw a(i)}},listNotifications:async(e,t,r)=>{try{return await this.trpc.action.listNotifications.query({orgName:e,repoName:t,since:r?.since,limit:r?.limit})}catch(i){throw a(i)}}};collection={create:async(e,t,r)=>{try{return fr(r.type,r),await this.trpc.collection.create.mutate({orgName:e,repoName:t,eventRequestId:r.eventRequestId,type:r.type,name:r.name,members:r.members,from:r.from,add:r.add,remove:r.remove,replaceMembers:r.replaceMembers,query:r.query,sourceOrgName:r.sourceRepo?.orgName,sourceRepoName:r.sourceRepo?.repoName,skipExisting:r.skipExisting,message:r.message,committer:r.committer})}catch(i){throw a(i)}},members:async(e,t,r,i)=>{try{return await this.trpc.collection.members.query({orgName:e,repoName:t,wref:r,version:i?.version,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},membersIter:(e,t,r,i)=>{let o=i?.version;return A(async s=>{let p=await this.collection.members(e,t,r,{...i,version:o,cursor:s});return o??=p.version,p},s=>s.items,i?.cursor)},membersAll:async(e,t,r,i)=>{let{max:o,...s}=i??{},p=s.version;return await O(async c=>{let u=await this.collection.members(e,t,r,{...s,version:p,cursor:c});return p??=u.version,u},c=>c.items,o,s.cursor)},contains:async(e,t,r,i,o)=>{try{return await this.trpc.collection.contains.query({orgName:e,repoName:t,wref:r,version:o?.version,members:i,position:o?.position})}catch(s){throw a(s)}},diff:async(e,t,r,i,o)=>{try{return await this.trpc.collection.diff.query({orgName:e,repoName:t,leftWref:r,rightWref:i,leftVersion:o?.leftVersion,rightVersion:o?.rightVersion,mode:o?.mode})}catch(s){throw a(s)}},revise:async(e,t,r,i)=>{try{let o=yr(r);if(ge(i.query)&&!ye(i.query))throw new d("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(i.sourceRepo&&!ye(i.query))throw new d("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(i.sourceRepo&&At(i))throw new d("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(ge(i.query)&&o&&o!=="set")throw new d("VALIDATION_ERROR","Selector-backed revise requires a Set/<name> target wref");return await this.trpc.collection.revise.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,wref:r,members:i.members,add:i.add,remove:i.remove,query:i.query,sourceOrgName:i.sourceRepo?.orgName,sourceRepoName:i.sourceRepo?.repoName,message:i.message,committer:i.committer})}catch(o){throw a(o)}},stats:async(e,t,r,i)=>{try{return await this.trpc.collection.stats.query({orgName:e,repoName:t,wref:r,version:i?.version})}catch(o){throw a(o)}}};thing={head:async(e,t,r)=>{try{return await this.trpc.thing.head.query({orgName:e,repoName:t,shape:r?.shape,kind:me(r?.kind),match:r?.match,dataMode:r?.dataMode,includeRetracted:r?.includeRetracted,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},headIter:(e,t,r)=>A(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 O(s=>this.thing.head(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},headChanges:async(e,t,r)=>(lt(r?.sinceRepoSeq),await mt(i=>this.thing.head(e,t,{...r,includeRetracted:true,cursor:i}))),get:async(e,t,r,i,o)=>{try{return await this.trpc.thing.get.query({orgName:e,repoName:t,wref:r,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode})}catch(s){throw a(s)}},getWithLease:async(e,t,r,i)=>{try{return await this.trpc.thing.getWithLease.mutate({orgName:e,repoName:t,wref:r,ttlMs:i?.ttlMs})}catch(o){throw a(o)}},releaseLease:async(e,t,r,i)=>{try{await this.trpc.thing.releaseLease.mutate({orgName:e,repoName:t,wref:r,leaseId:i});}catch(o){throw a(o)}},graph:async(e,t,r,i)=>{try{return await this.trpc.thing.graph.query({orgName:e,repoName:t,wref:r,version:i?.version,depth:i?.depth,limit:i?.limit})}catch(o){throw a(o)}},getMany:async(e,t,r,i,o)=>{try{if(r.length===0)return {requested:0,items:[],missing:[]};let s=de(o?.chunkSize,at,ct),p=de(o?.chunkConcurrency,pt,ut),c=async m=>await this.trpc.thing.getMany.query({orgName:e,repoName:t,wrefs:m,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode});if(r.length<=s)return await c(r);let u=ht(r,s),l=[];for(let m=0;m<u.length;m+=p){let f=u.slice(m,m+p),g=await Promise.all(f.map(c));l.push(...g);}return {requested:r.length,items:l.flatMap(m=>m.items),missing:l.flatMap(m=>m.missing)}}catch(s){throw a(s)}},headVersions:async(e,t,r,i)=>{try{if(r.length===0)return {requested:0,items:[],missing:[]};let o=de(i?.chunkSize,at,ct),s=de(i?.chunkConcurrency,pt,ut),p=async l=>await this.trpc.thing.headVersions.query({orgName:e,repoName:t,wrefs:l});if(r.length<=o)return await p(r);let c=ht(r,o),u=[];for(let l=0;l<c.length;l+=s){let m=c.slice(l,l+s),f=await Promise.all(m.map(p));u.push(...f);}return {requested:r.length,items:u.flatMap(l=>l.items),missing:u.flatMap(l=>l.missing)}}catch(o){throw a(o)}},history:async(e,t,r)=>{try{return await this.trpc.thing.history.query({orgName:e,repoName:t,wref:r.wref,shape:r.shape,about:r.about,includeRetracted:r.includeRetracted,resolveCollections:r.resolveCollections,match:r.match,limit:r.limit,cursor:r.cursor})}catch(i){throw a(i)}},historyIter:(e,t,r)=>A(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 O(s=>this.thing.history(e,t,{...o,cursor:s}),s=>s.versions,i,o.cursor)},rename:async(e,t,r,i,o,s)=>{try{return await this.trpc.thing.rename.mutate({orgName:e,repoName:t,shapeName:r,oldName:i,newName:o,eventRequestId:s.eventRequestId})}catch(p){throw a(p)}},resolve:async(e,t,r)=>{try{return await this.trpc.thing.resolve.query({orgName:e,repoName:t,wref:r})}catch(i){throw a(i)}},about:async(e,t,r,i)=>{try{return await this.trpc.thing.about.query({orgName:e,repoName:t,wref:r,shape:i?.shape,match:i?.match,includeRetracted:i?.includeRetracted,depth:i?.depth,resolveCollections:i?.resolveCollections,role:i?.role,limit:i?.limit,cursor:i?.cursor,where:i?.where})}catch(o){throw a(o)}},aboutIter:(e,t,r,i)=>A(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 O(p=>this.thing.about(e,t,r,{...s,cursor:p}),p=>p.assertions,o,s.cursor)},query:async(e,t,r)=>{try{return await this.trpc.thing.query.query({orgName:e,repoName:t,shape:r?.shape,about:r?.about,kind:me(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,role:r?.role,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},queryIter:(e,t,r)=>A(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 O(s=>this.thing.query(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},queryChanges:async(e,t,r)=>(lt(r?.sinceRepoSeq),await mt(i=>this.thing.query(e,t,{...r,includeRetracted:true,cursor:i}))),search:async(e,t,r,i)=>{try{return await this.trpc.thing.search.query({orgName:e,repoName:t,query:r,shape:i?.shape,about:i?.about,kind:me(i?.kind),match:i?.match,includeRetracted:i?.includeRetracted,resolveCollections:i?.resolveCollections,limit:i?.limit,cursor:i?.cursor,componentRef:i?.componentRef,excludeComponents:i?.excludeComponents,excludeInfraShapes:i?.excludeInfraShapes,mode:i?.mode,nameMatch:i?.nameMatch})}catch(o){throw a(o)}},searchIter:(e,t,r,i)=>A(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 O(p=>this.thing.search(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)},count:async(e,t,r)=>{try{return await this.trpc.thing.count.query({orgName:e,repoName:t,shape:r?.shape,about:r?.about,kind:me(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},refs:async(e,t,r,i)=>{try{return await this.trpc.thing.refs.query({orgName:e,repoName:t,wref:r,direction:i?.direction,fieldPath:i?.fieldPath,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},refsIter:(e,t,r,i)=>A(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 O(p=>this.thing.refs(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)}};live={thingHead:async(e,t,r,i)=>this.watchRepoQuery(e,t,r?.signal,()=>this.thing.head(e,t,{shape:r?.shape,kind:r?.kind,match:r?.match,dataMode:r?.dataMode,limit:r?.limit,cursor:r?.cursor,includeRetracted:r?.includeRetracted,where:r?.where}),i),thingHistory:async(e,t,r,i)=>this.watchRepoQuery(e,t,r.signal,()=>this.thing.history(e,t,{wref:r.wref,limit:r.limit,cursor:r.cursor,includeRetracted:r.includeRetracted}),i),subscriptionLog:async(e,t,r,i,o)=>this.watchRepoQuery(e,t,i?.signal,()=>this.action.liveFeed(e,t,r,{limit:i?.limit,cursor:i?.cursor}),o),subscribe:async(e,t,r,i)=>{let o=new AbortController,s=Rt(r?.signal,o),p=0,c=(async()=>{let u=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),l=await this.openSse(u.ticket,s,async m=>{if(m.type!=="invalidate")return;let f=m.data;p++,await i({topic:f.topic,affectedShapes:f.affectedShapes,affectedThings:f.affectedThings,affectedTargets:f.affectedTargets,hasNewCommit:f.hasNewCommit});});return await l.ready,s.aborted?{updates:p}:(await l.closed,{updates:p})})();return {close(){o.abort();},closed:c}}};token={create:async e=>{try{return await this.trpc.token.create.mutate(e)}catch(t){throw a(t)}},list:async e=>{try{return await this.trpc.token.list.query(e?.includeInactive?{includeInactive:!0}:void 0)}catch(t){throw a(t)}},get:async e=>{try{return await this.trpc.token.get.query({name:e})}catch(t){throw a(t)}},revoke:async e=>{try{return await this.trpc.token.revoke.mutate({name:e})}catch(t){throw a(t)}}};stream={append:async e=>{try{return await this.trpc.stream.append.mutate(e)}catch(t){throw a(t)}}};credential={createSet:async(e,t,r,i)=>{try{return await this.trpc.credential.createSet.mutate({orgName:e,repoName:t,name:r,scope:i?.scope??"repo",description:i?.description})}catch(o){throw a(o)}},listSets:async(e,t)=>{try{return await this.trpc.credential.listSets.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getSet:async(e,t,r)=>{try{return await this.trpc.credential.getSet.query({orgName:e,repoName:t,name:r})}catch(i){throw a(i)}},setKey:async(e,t,r,i,o)=>{try{return await this.trpc.credential.setKey.mutate({orgName:e,repoName:t,setName:r,keyName:i,value:o})}catch(s){throw a(s)}},setKeys:async(e,t,r,i)=>{try{return await this.trpc.credential.setKeys.mutate({orgName:e,repoName:t,setName:r,secrets:i})}catch(o){throw a(o)}},unsetKey:async(e,t,r,i)=>{try{return await this.trpc.credential.unsetKey.mutate({orgName:e,repoName:t,setName:r,keyName:i})}catch(o){throw a(o)}},deleteSet:async(e,t,r)=>{try{return await this.trpc.credential.deleteSet.mutate({orgName:e,repoName:t,setName:r})}catch(i){throw a(i)}},listAuditLog:async(e,t,r,i)=>{try{return await this.trpc.credential.listAuditLog.query({orgName:e,repoName:t,setName:r,limit:i?.limit})}catch(o){throw a(o)}},revokeSet:async(e,t,r,i)=>{try{return await this.trpc.credential.revokeSet.mutate({orgName:e,repoName:t,setName:r,reason:i?.reason})}catch(o){throw a(o)}}};credentials=this.credential;constructor(e,t){let r=typeof e=="string"?t:e;cr(r);let i=typeof e=="string"?e:e?.apiUrl??Pe;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??b,version:r?.client?.version??ke},typeof this.accessToken=="function"){let p=this.accessToken;this.getToken=async()=>await p();}else if(this.accessToken){let p=this.accessToken;this.getToken=async()=>p;}let o=`${i.replace(/\/$/,"")}/trpc`,s=((p,c)=>this.fetchWithAuth(p,c));Object.defineProperty(this,"trpc",{value:createTRPCProxyClient({links:[this.createCompatibilityLink(),splitLink({condition:p=>pr.has(p.path),true:httpLink({url:o,fetch:s,methodOverride:"POST"}),false:httpBatchLink({url:o,fetch:s,methodOverride:"POST"})})]}),enumerable:false,writable:false,configurable:true});}withAccessToken(e){return new n({apiUrl:this.apiUrl,fetch:this.fetchImpl,accessToken:e,client:this.clientIdentity})}actions=this.action;async openSse(e,t,r){let i=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/sse?ticket=${encodeURIComponent(e)}`,{headers:{accept:"text/event-stream"},signal:t});if(!i.ok)throw new d("BACKEND",`SSE request failed with status ${i.status}`,i.status);let o=i.body?.getReader();if(!o)throw new d("BACKEND","SSE response body is missing");let s=()=>{},p=new Promise(u=>{s=u;}),c=(async()=>{let u=new TextDecoder,l="";try{for(;;){let{done:m,value:f}=await o.read();if(m)break;for(l+=u.decode(f,{stream:!0}).replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`);;){let g=l.indexOf(`
|
|
4
|
-
|
|
5
|
-
`);if(g===-1)break;let C=l.slice(0,g);l=l.slice(g+2);let h=Er(C);if(h){if(h.type==="ready"){s();continue}await r(h);}}}}catch(m){if(kr(m)||t.aborted)return;throw m}finally{s(),o.releaseLock();}})();return {ready:p,closed:c}}applyClientHeader(e$1){e$1.has(a$1)||e$1.set(a$1,e(this.clientIdentity.name,this.clientIdentity.version));}async fetchWithAuth(e,t){let r=this.fetchImpl??globalThis.fetch,i=new Headers(t?.headers),o=await ft(this.accessToken);o&&i.set("authorization",`Bearer ${o}`),this.applyClientHeader(i);let s=async c=>{try{return await r(e,c)}catch(u){throw Ar(u)?new d("NETWORK",Or(this.apiUrl)):u}},p=await s({...t,headers:i});if(p.status===401&&typeof this.accessToken=="function"){let c=await ft(this.accessToken);if(c&&c!==o){let u=new Headers(t?.headers);return u.set("authorization",`Bearer ${c}`),this.applyClientHeader(u),s({...t,headers:u})}}return p}async requestResponse(e,t){let r=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}${e}`,t);if(!r.ok){let i=`Request failed with status ${r.status}`,o=It(r.status),s,p,c;try{let u=await r.json();typeof u.error?.message=="string"&&(i=u.error.message),typeof u.error?.code=="string"&&(o=u.error.code,s=u.error.code),typeof u.error?.hint=="string"&&(p=u.error.hint),typeof u.error?.retryAfter=="number"&&(c=u.error.retryAfter);}catch{}throw new d(o,i,r.status,p,c,s)}return r}async requestJson(e,t){return await(await this.requestResponse(e,t)).json()}async watchRepoQuery(e,t,r,i,o){let s=new AbortController,p=Rt(r,s),c=0,u=(async()=>{let l=async()=>{let g=await i();c+=1,await o(g);},m=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),f=await this.openSse(m.ticket,p,async g=>{g.type==="invalidate"&&await l();});return await f.ready,p.aborted?{updates:c}:(await l(),await f.closed,{updates:c})})();return {close(){s.abort();},closed:u}}};function It(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 ft(n){if(n)return typeof n=="string"?n:n()}function Rt(n,e){return n?n.aborted?(e.abort(),e.signal):(n.addEventListener("abort",()=>e.abort(),{once:true}),e.signal):e.signal}function Er(n){let e="message",t=[];for(let i of n.split(`
|
|
6
|
-
`))if(!(!i||i.startsWith(":"))){if(i.startsWith("event:")){e=i.slice(6).trim();continue}i.startsWith("data:")&&t.push(i.slice(5).trim());}if(t.length===0)return null;let r=t.join(`
|
|
7
|
-
`);return {type:e,data:JSON.parse(r)}}function kr(n){return n instanceof Error&&n.name==="AbortError"}export{Ar as A,Or as B,Tn as C,yt as D,te as a,Nt as b,Ce as c,ie as d,oe as e,k as f,x as g,F as h,se as i,W as j,L as k,Ie as l,ae as m,Ee as n,ke as o,w as p,Qt as q,le as r,kn as s,Pe as t,vn as u,Le as v,d as w,a as x,Sr as y,xn as z};//# sourceMappingURL=chunk-CNOPJLT7.js.map
|
|
8
|
-
//# sourceMappingURL=chunk-CNOPJLT7.js.map
|