@sparkvault/sdk-js 15.9.0 → 15.9.1
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 +23 -5
- package/dist/index.cjs +115 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +54 -9
- package/dist/index.mjs +115 -12
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/index.d.ts +16 -5
- package/dist/ingots/revision.d.ts +4 -0
- package/dist/ingots/types.d.ts +17 -0
- package/dist/products/structured-ingots/index.d.ts +3 -5
- package/dist/products/structured-ingots/types.d.ts +22 -1
- package/dist/products/structured-ingots/validation.d.ts +5 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3007,6 +3007,8 @@ interface Ingot {
|
|
|
3007
3007
|
contentHmac: string | null;
|
|
3008
3008
|
/** Opaque published-content revision; null for legacy/unpublished content. */
|
|
3009
3009
|
contentVersion: string | null;
|
|
3010
|
+
/** Object identity and publication together; absent on older servers. */
|
|
3011
|
+
revision?: string;
|
|
3010
3012
|
}
|
|
3011
3013
|
/** The discrete primitive returned by createUpload — a Forge TUS session. */
|
|
3012
3014
|
interface IngotUpload {
|
|
@@ -3069,6 +3071,8 @@ interface DownloadIngotOptions {
|
|
|
3069
3071
|
interface IngotDownloadLink {
|
|
3070
3072
|
/** Opaque published-content revision; null for legacy content. */
|
|
3071
3073
|
contentVersion: string | null;
|
|
3074
|
+
/** Revision observed when the link was minted, not necessarily the bytes it later serves. */
|
|
3075
|
+
revision?: string;
|
|
3072
3076
|
/** Short-lived signed Forge download URL */
|
|
3073
3077
|
downloadUrl: string;
|
|
3074
3078
|
/** Ingot ID */
|
|
@@ -3080,6 +3084,15 @@ interface IngotDownloadLink {
|
|
|
3080
3084
|
/** Content type (MIME) */
|
|
3081
3085
|
contentType: string;
|
|
3082
3086
|
}
|
|
3087
|
+
/** Downloaded bytes and the revision they belong to, for guarded read-modify-write. */
|
|
3088
|
+
interface IngotDownload {
|
|
3089
|
+
blob: Blob;
|
|
3090
|
+
revision: string;
|
|
3091
|
+
}
|
|
3092
|
+
interface DeleteIngotOptions {
|
|
3093
|
+
/** Delete only this object publication. Omitted preserves unconditional deletion. */
|
|
3094
|
+
expectedRevision?: string;
|
|
3095
|
+
}
|
|
3083
3096
|
/** Options for the createUpload primitive. */
|
|
3084
3097
|
interface CreateUploadOptions {
|
|
3085
3098
|
/** Unsealed vault the ingot belongs to */
|
|
@@ -3153,6 +3166,8 @@ type ResumeUploadOptions = Omit<SendUploadOptions, 'onSessionCreated'>;
|
|
|
3153
3166
|
interface ReplaceIngotOptions {
|
|
3154
3167
|
/** File or Blob to upload as the new content */
|
|
3155
3168
|
file: File | Blob;
|
|
3169
|
+
/** Replace only the object publication read; stale or recreated targets return 412. */
|
|
3170
|
+
expectedRevision?: string;
|
|
3156
3171
|
/** Optional new name (defaults to file name) */
|
|
3157
3172
|
name?: string;
|
|
3158
3173
|
/** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
|
|
@@ -3879,6 +3894,8 @@ interface StructuredPage<T> {
|
|
|
3879
3894
|
interface StructuredIngotSummary {
|
|
3880
3895
|
id: string;
|
|
3881
3896
|
name: string;
|
|
3897
|
+
/** Publication observed by the metadata page; absent when the server cannot supply it. */
|
|
3898
|
+
revision?: string;
|
|
3882
3899
|
sizeBytes: number;
|
|
3883
3900
|
createdAt: number;
|
|
3884
3901
|
updatedAt: number | null;
|
|
@@ -3887,6 +3904,8 @@ interface StructuredIngot<T extends object = StructuredValues> {
|
|
|
3887
3904
|
id: string;
|
|
3888
3905
|
name: string;
|
|
3889
3906
|
version: number;
|
|
3907
|
+
/** Identity-bound content revision from the bytes read; absent on older servers. */
|
|
3908
|
+
revision?: string;
|
|
3890
3909
|
keyCount: number;
|
|
3891
3910
|
values: T;
|
|
3892
3911
|
missingKeys: string[];
|
|
@@ -3899,6 +3918,8 @@ interface StructuredIngot<T extends object = StructuredValues> {
|
|
|
3899
3918
|
interface StructuredIngotMutation {
|
|
3900
3919
|
id: string;
|
|
3901
3920
|
version: number;
|
|
3921
|
+
/** The publication this operation committed; absent on older servers/creation receipts. */
|
|
3922
|
+
revision?: string;
|
|
3902
3923
|
keyCount: number;
|
|
3903
3924
|
type: StructuredTypePin | null;
|
|
3904
3925
|
createdAt?: number;
|
|
@@ -3918,14 +3939,26 @@ interface CreateStructuredIngotOptions<T extends object = StructuredValues> {
|
|
|
3918
3939
|
/** 8–128 printable ASCII characters; bound to this name and semantic payload. */
|
|
3919
3940
|
idempotencyKey?: string;
|
|
3920
3941
|
}
|
|
3921
|
-
|
|
3942
|
+
/** Prefer the opaque revision: it also rejects deletion and recreation under the same name. */
|
|
3943
|
+
type StructuredIngotPrecondition = {
|
|
3944
|
+
expectedRevision: string;
|
|
3945
|
+
expectedVersion?: number;
|
|
3946
|
+
} | {
|
|
3947
|
+
expectedRevision?: undefined;
|
|
3922
3948
|
expectedVersion: number;
|
|
3949
|
+
};
|
|
3950
|
+
type PatchStructuredIngotOptions<T extends object = StructuredValues> = StructuredIngotPrecondition & {
|
|
3923
3951
|
set?: Partial<T>;
|
|
3924
3952
|
delete?: string[];
|
|
3925
3953
|
/** Omitted preserves the current type; null explicitly removes it. */
|
|
3926
3954
|
type?: StructuredTypePin | null;
|
|
3927
3955
|
/** Paths are relative to the `set` object. */
|
|
3928
3956
|
binaryPaths?: StructuredBinaryPath[];
|
|
3957
|
+
};
|
|
3958
|
+
type RestoreStructuredIngotOptions = StructuredIngotPrecondition;
|
|
3959
|
+
interface DeleteStructuredIngotOptions {
|
|
3960
|
+
/** Delete only this object publication. Omitted preserves unconditional deletion. */
|
|
3961
|
+
expectedRevision?: string;
|
|
3929
3962
|
}
|
|
3930
3963
|
interface StructuredIngotVersion {
|
|
3931
3964
|
versionId: string;
|
|
@@ -4066,6 +4099,7 @@ interface StructuredIngotSummaryWire {
|
|
|
4066
4099
|
size_bytes: number;
|
|
4067
4100
|
created_at: number;
|
|
4068
4101
|
updated_at?: number | null;
|
|
4102
|
+
revision?: string | null;
|
|
4069
4103
|
}
|
|
4070
4104
|
interface StructuredIngotWire<T extends object = StructuredValues> {
|
|
4071
4105
|
ingot_id: string;
|
|
@@ -4074,6 +4108,7 @@ interface StructuredIngotWire<T extends object = StructuredValues> {
|
|
|
4074
4108
|
key_count: number;
|
|
4075
4109
|
values: T;
|
|
4076
4110
|
missing_keys: string[];
|
|
4111
|
+
revision?: string;
|
|
4077
4112
|
binary_paths?: StructuredBinaryPath[];
|
|
4078
4113
|
binary_keys?: string[];
|
|
4079
4114
|
type?: StructuredTypePinWire | null;
|
|
@@ -4086,6 +4121,7 @@ interface StructuredMutationWire {
|
|
|
4086
4121
|
version: number;
|
|
4087
4122
|
key_count: number;
|
|
4088
4123
|
type?: StructuredTypePinWire | null;
|
|
4124
|
+
revision?: string;
|
|
4089
4125
|
created_at?: number;
|
|
4090
4126
|
updated_at?: number;
|
|
4091
4127
|
created?: boolean;
|
|
@@ -4164,11 +4200,9 @@ declare class StructuredIngotsModule {
|
|
|
4164
4200
|
/** Names use the server's documented Unicode caseless matching rules. */
|
|
4165
4201
|
create<T extends object = StructuredValues>(vault: UnsealedVault, options: CreateStructuredIngotOptions<T>): Promise<StructuredIngotMutation>;
|
|
4166
4202
|
patch<T extends object = StructuredValues>(vault: UnsealedVault, ref: string, options: PatchStructuredIngotOptions<T>): Promise<StructuredIngotMutation>;
|
|
4167
|
-
delete(vault: UnsealedVault, ref: string): Promise<void>;
|
|
4203
|
+
delete(vault: UnsealedVault, ref: string, options?: DeleteStructuredIngotOptions): Promise<void>;
|
|
4168
4204
|
history(vault: UnsealedVault, ref: string): Promise<StructuredIngotHistory>;
|
|
4169
|
-
restore(vault: UnsealedVault, ref: string, versionId: string, options:
|
|
4170
|
-
expectedVersion: number;
|
|
4171
|
-
}): Promise<StructuredIngotMutation>;
|
|
4205
|
+
restore(vault: UnsealedVault, ref: string, versionId: string, options: RestoreStructuredIngotOptions): Promise<StructuredIngotMutation>;
|
|
4172
4206
|
/** Bounded parallel reads with independent, ordered success/error outcomes. */
|
|
4173
4207
|
batchGet<T extends object = StructuredValues>(vault: UnsealedVault, refs: string[], options?: BatchGetStructuredIngotsOptions): Promise<StructuredReadOutcome<T>[]>;
|
|
4174
4208
|
/** Sequential record reads, not a transactionally consistent vault snapshot. */
|
|
@@ -4982,7 +5016,10 @@ declare class IngotsModule {
|
|
|
4982
5016
|
* before the replacement is staged where there is no XMLHttpRequest.
|
|
4983
5017
|
*
|
|
4984
5018
|
* @example
|
|
4985
|
-
* await sv.ingots.
|
|
5019
|
+
* const original = await sv.ingots.downloadWithRevision(unsealed, 'ing_abc');
|
|
5020
|
+
* await sv.ingots.replace(unsealed, 'ing_abc', {
|
|
5021
|
+
* file: updatedFile, expectedRevision: original.revision,
|
|
5022
|
+
* });
|
|
4986
5023
|
*/
|
|
4987
5024
|
replace(vault: UnsealedVault, ingotId: string, options: ReplaceIngotOptions): Promise<CreatedIngot>;
|
|
4988
5025
|
/**
|
|
@@ -5004,9 +5041,11 @@ declare class IngotsModule {
|
|
|
5004
5041
|
* Delete an ingot.
|
|
5005
5042
|
*
|
|
5006
5043
|
* @example
|
|
5007
|
-
* await sv.ingots.
|
|
5044
|
+
* const original = await sv.ingots.get(unsealed, 'ing_abc');
|
|
5045
|
+
* if (!original.revision) throw new Error('This server does not support guarded deletion');
|
|
5046
|
+
* await sv.ingots.delete(unsealed, original.id, { expectedRevision: original.revision });
|
|
5008
5047
|
*/
|
|
5009
|
-
delete(vault: UnsealedVault, ingotId: string): Promise<void>;
|
|
5048
|
+
delete(vault: UnsealedVault, ingotId: string, options?: DeleteIngotOptions): Promise<void>;
|
|
5010
5049
|
/**
|
|
5011
5050
|
* Get ingot metadata.
|
|
5012
5051
|
*
|
|
@@ -5097,6 +5136,12 @@ declare class IngotsModule {
|
|
|
5097
5136
|
* link.click();
|
|
5098
5137
|
*/
|
|
5099
5138
|
download(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<Blob>;
|
|
5139
|
+
/**
|
|
5140
|
+
* Download bytes with their identity-bound revision. Use the returned revision
|
|
5141
|
+
* for replace/delete preconditions; the link's earlier metadata may already
|
|
5142
|
+
* have been superseded when Forge begins serving the bytes.
|
|
5143
|
+
*/
|
|
5144
|
+
downloadWithRevision(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<IngotDownload>;
|
|
5100
5145
|
/**
|
|
5101
5146
|
* Get an ingot's sharing configuration.
|
|
5102
5147
|
*
|
|
@@ -5930,4 +5975,4 @@ declare global {
|
|
|
5930
5975
|
}
|
|
5931
5976
|
|
|
5932
5977
|
export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, StructuredIngotTypesModule, StructuredIngotsModule, TimeoutError, UnauthorizedError, UsageCreditFundingReviewError, UsageCreditsExhaustedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
|
|
5933
|
-
export type { AccessLogRetention, AccessLogsOptions, BatchGetStructuredIngotsOptions, CreateFolderOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateStructuredIngotOptions, CreateStructuredTypeOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, GetStructuredIngotOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, ImportStructuredIngotsOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PatchStructuredIngotOptions, PortableStructuredIngot, PortableStructuredType, PreviewNotifyProjectSubscriptionOptions, PublishStructuredTypeOptions, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, StructuredAccountActivity, StructuredActivity, StructuredActivityOptions, StructuredActivityPeriod, StructuredActivityTotals, StructuredActivityTotalsWire, StructuredActivityWire, StructuredBinaryPath, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotSummary, StructuredIngotSummaryWire, StructuredIngotVersion, StructuredIngotWire, StructuredIterateOptions, StructuredJsonValue, StructuredMutationWire, StructuredOutcome, StructuredPage, StructuredPageOptions, StructuredPageWire, StructuredReadOutcome, StructuredTypeCreation, StructuredTypeDefinition, StructuredTypeDefinitionWire, StructuredTypePin, StructuredTypePinWire, StructuredTypeSummary, StructuredTypeSummaryWire, StructuredTypeTransform, StructuredValues, StructuredVaultActivity, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
|
|
5978
|
+
export type { AccessLogRetention, AccessLogsOptions, BatchGetStructuredIngotsOptions, CreateFolderOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateStructuredIngotOptions, CreateStructuredTypeOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DeleteIngotOptions, DeleteStructuredIngotOptions, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, GetStructuredIngotOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, ImportStructuredIngotsOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownload, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PatchStructuredIngotOptions, PortableStructuredIngot, PortableStructuredType, PreviewNotifyProjectSubscriptionOptions, PublishStructuredTypeOptions, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, RestoreStructuredIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, StructuredAccountActivity, StructuredActivity, StructuredActivityOptions, StructuredActivityPeriod, StructuredActivityTotals, StructuredActivityTotalsWire, StructuredActivityWire, StructuredBinaryPath, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotPrecondition, StructuredIngotSummary, StructuredIngotSummaryWire, StructuredIngotVersion, StructuredIngotWire, StructuredIterateOptions, StructuredJsonValue, StructuredMutationWire, StructuredOutcome, StructuredPage, StructuredPageOptions, StructuredPageWire, StructuredReadOutcome, StructuredTypeCreation, StructuredTypeDefinition, StructuredTypeDefinitionWire, StructuredTypePin, StructuredTypePinWire, StructuredTypeSummary, StructuredTypeSummaryWire, StructuredTypeTransform, StructuredValues, StructuredVaultActivity, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
|
package/dist/index.mjs
CHANGED
|
@@ -13268,6 +13268,47 @@ function readIngotAccess(entry) {
|
|
|
13268
13268
|
};
|
|
13269
13269
|
}
|
|
13270
13270
|
|
|
13271
|
+
/**
|
|
13272
|
+
* Opaque optimistic-concurrency identity for one publication of one ingot.
|
|
13273
|
+
* A legacy publication has no content marker, but still names its immutable
|
|
13274
|
+
* ingot id: deleting and recreating a logical name never reuses its revision.
|
|
13275
|
+
* This is a precondition, not a credential or a content digest.
|
|
13276
|
+
*/
|
|
13277
|
+
|
|
13278
|
+
const INGOT_REVISION_MAX_LENGTH = 4096;
|
|
13279
|
+
const MAX_CONTENT_VERSION_LENGTH = 256;
|
|
13280
|
+
|
|
13281
|
+
/** @returns {string} A portable, canonical revision for the actual publication. */
|
|
13282
|
+
function formatIngotRevision(ingotId, contentVersion) {
|
|
13283
|
+
if (!isResourceIdOf('ingot', ingotId) ||
|
|
13284
|
+
(contentVersion !== null && (typeof contentVersion !== 'string' || !contentVersion.length || contentVersion.length > MAX_CONTENT_VERSION_LENGTH))) {
|
|
13285
|
+
throw new TypeError('An ingot revision requires an ingot id and its content version');
|
|
13286
|
+
}
|
|
13287
|
+
try {
|
|
13288
|
+
return `ir1:${ingotId}:${contentVersion === null ? '' : encodeURIComponent(contentVersion)}`;
|
|
13289
|
+
} catch {
|
|
13290
|
+
throw new TypeError('An ingot revision requires a valid content version');
|
|
13291
|
+
}
|
|
13292
|
+
}
|
|
13293
|
+
|
|
13294
|
+
/** @returns {{ ingotId: string, contentVersion: string|null }} */
|
|
13295
|
+
function parseIngotRevision(revision) {
|
|
13296
|
+
if (typeof revision !== 'string' || revision.length > INGOT_REVISION_MAX_LENGTH) {
|
|
13297
|
+
throw new TypeError('revision must be an opaque ingot revision returned by the server');
|
|
13298
|
+
}
|
|
13299
|
+
const parts = revision.split(':');
|
|
13300
|
+
if (parts.length !== 3 || parts[0] !== 'ir1') {
|
|
13301
|
+
throw new TypeError('revision must be an opaque ingot revision returned by the server');
|
|
13302
|
+
}
|
|
13303
|
+
try {
|
|
13304
|
+
const contentVersion = parts[2] === '' ? null : decodeURIComponent(parts[2]);
|
|
13305
|
+
if (formatIngotRevision(parts[1], contentVersion) !== revision) throw new TypeError();
|
|
13306
|
+
return { ingotId: parts[1], contentVersion };
|
|
13307
|
+
} catch {
|
|
13308
|
+
throw new TypeError('revision must be an opaque ingot revision returned by the server');
|
|
13309
|
+
}
|
|
13310
|
+
}
|
|
13311
|
+
|
|
13271
13312
|
/**
|
|
13272
13313
|
* SparkVault Debug Logger
|
|
13273
13314
|
*
|
|
@@ -13989,6 +14030,31 @@ class ReceivedBytes {
|
|
|
13989
14030
|
}
|
|
13990
14031
|
}
|
|
13991
14032
|
|
|
14033
|
+
/** Validate an opaque server revision without interpreting it as a credential. */
|
|
14034
|
+
function expectedRevision(value) {
|
|
14035
|
+
if (value === undefined)
|
|
14036
|
+
return undefined;
|
|
14037
|
+
try {
|
|
14038
|
+
parseIngotRevision(value);
|
|
14039
|
+
return value;
|
|
14040
|
+
}
|
|
14041
|
+
catch {
|
|
14042
|
+
throw new ValidationError('expectedRevision must be a revision returned by an ingot read');
|
|
14043
|
+
}
|
|
14044
|
+
}
|
|
14045
|
+
/** Older servers omit the revision; never invent a precondition from metadata. */
|
|
14046
|
+
function readRevision(value) {
|
|
14047
|
+
if (value === undefined)
|
|
14048
|
+
return undefined;
|
|
14049
|
+
try {
|
|
14050
|
+
parseIngotRevision(value);
|
|
14051
|
+
return value;
|
|
14052
|
+
}
|
|
14053
|
+
catch {
|
|
14054
|
+
throw new SparkVaultError('The server returned an invalid ingot revision', 'invalid_response');
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
|
|
13992
14058
|
/**
|
|
13993
14059
|
* Folders Module
|
|
13994
14060
|
*
|
|
@@ -15532,12 +15598,16 @@ class IngotsModule {
|
|
|
15532
15598
|
* before the replacement is staged where there is no XMLHttpRequest.
|
|
15533
15599
|
*
|
|
15534
15600
|
* @example
|
|
15535
|
-
* await sv.ingots.
|
|
15601
|
+
* const original = await sv.ingots.downloadWithRevision(unsealed, 'ing_abc');
|
|
15602
|
+
* await sv.ingots.replace(unsealed, 'ing_abc', {
|
|
15603
|
+
* file: updatedFile, expectedRevision: original.revision,
|
|
15604
|
+
* });
|
|
15536
15605
|
*/
|
|
15537
15606
|
async replace(vault, ingotId, options) {
|
|
15538
15607
|
this.validateFile(options.file);
|
|
15539
15608
|
const vaultId = requireVaultId(vault);
|
|
15540
15609
|
const id = requireResourceId(ingotId, 'ingotId');
|
|
15610
|
+
const revision = expectedRevision(options.expectedRevision);
|
|
15541
15611
|
const name = options.name ?? getBlobName(options.file);
|
|
15542
15612
|
const contentType = sentContentType(options);
|
|
15543
15613
|
assertBrowserTransfer();
|
|
@@ -15547,6 +15617,7 @@ class IngotsModule {
|
|
|
15547
15617
|
...(contentType !== undefined && { content_type: contentType }),
|
|
15548
15618
|
size_bytes: options.file.size,
|
|
15549
15619
|
...(options.contentHmac && { content_hmac: options.contentHmac }),
|
|
15620
|
+
...(revision === undefined ? {} : { expected_revision: revision }),
|
|
15550
15621
|
}, { vat: vault.vatToken }).catch((error) => {
|
|
15551
15622
|
throw stagingRefusalOf(error);
|
|
15552
15623
|
});
|
|
@@ -15588,12 +15659,16 @@ class IngotsModule {
|
|
|
15588
15659
|
* Delete an ingot.
|
|
15589
15660
|
*
|
|
15590
15661
|
* @example
|
|
15591
|
-
* await sv.ingots.
|
|
15662
|
+
* const original = await sv.ingots.get(unsealed, 'ing_abc');
|
|
15663
|
+
* if (!original.revision) throw new Error('This server does not support guarded deletion');
|
|
15664
|
+
* await sv.ingots.delete(unsealed, original.id, { expectedRevision: original.revision });
|
|
15592
15665
|
*/
|
|
15593
|
-
async delete(vault, ingotId) {
|
|
15666
|
+
async delete(vault, ingotId, options = {}) {
|
|
15594
15667
|
const vaultId = requireVaultId(vault);
|
|
15595
15668
|
const id = requireResourceId(ingotId, 'ingotId');
|
|
15596
|
-
await this.http.delete(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
|
|
15669
|
+
await this.http.delete(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
|
|
15670
|
+
vat: vault.vatToken, query: { expected_revision: expectedRevision(options.expectedRevision) },
|
|
15671
|
+
});
|
|
15597
15672
|
}
|
|
15598
15673
|
/**
|
|
15599
15674
|
* Get ingot metadata.
|
|
@@ -15713,6 +15788,7 @@ class IngotsModule {
|
|
|
15713
15788
|
return {
|
|
15714
15789
|
downloadUrl: response.data.download_url,
|
|
15715
15790
|
contentVersion: response.data.content_version ?? null,
|
|
15791
|
+
...(response.data.revision === undefined ? {} : { revision: readRevision(response.data.revision) }),
|
|
15716
15792
|
id: response.data.ingot_id,
|
|
15717
15793
|
name: response.data.name,
|
|
15718
15794
|
size: response.data.size_bytes,
|
|
@@ -15746,8 +15822,19 @@ class IngotsModule {
|
|
|
15746
15822
|
* link.click();
|
|
15747
15823
|
*/
|
|
15748
15824
|
async download(vault, ingotId, options = {}) {
|
|
15825
|
+
return (await this.downloadWithRevision(vault, ingotId, options)).blob;
|
|
15826
|
+
}
|
|
15827
|
+
/**
|
|
15828
|
+
* Download bytes with their identity-bound revision. Use the returned revision
|
|
15829
|
+
* for replace/delete preconditions; the link's earlier metadata may already
|
|
15830
|
+
* have been superseded when Forge begins serving the bytes.
|
|
15831
|
+
*/
|
|
15832
|
+
async downloadWithRevision(vault, ingotId, options = {}) {
|
|
15833
|
+
requireVaultId(vault);
|
|
15834
|
+
const id = requireResourceId(ingotId, 'ingotId');
|
|
15749
15835
|
const mint = async () => (await this.createDownloadLink(vault, ingotId, options)).downloadUrl;
|
|
15750
|
-
|
|
15836
|
+
const download = await fetchMintedDownload(mint, { isAllowedHost: this.allowsTransferHost });
|
|
15837
|
+
return { blob: download.blob, revision: formatIngotRevision(id, download.contentVersion) };
|
|
15751
15838
|
}
|
|
15752
15839
|
/**
|
|
15753
15840
|
* Get an ingot's sharing configuration.
|
|
@@ -15943,6 +16030,7 @@ function mapIngot(wire) {
|
|
|
15943
16030
|
folderId: wire.folder_id ?? null,
|
|
15944
16031
|
contentHmac: wire.content_hmac ?? null,
|
|
15945
16032
|
contentVersion: wire.content_version ?? null,
|
|
16033
|
+
...(wire.revision === undefined ? {} : { revision: readRevision(wire.revision) }),
|
|
15946
16034
|
};
|
|
15947
16035
|
}
|
|
15948
16036
|
function mapFolderContents(wire) {
|
|
@@ -21389,6 +21477,16 @@ function integer(value, field, minimum, maximum) {
|
|
|
21389
21477
|
return value;
|
|
21390
21478
|
}
|
|
21391
21479
|
function expectedVersion(value) { return integer(value, 'expectedVersion', 1, 0xFFFFFFFF); }
|
|
21480
|
+
function mutationPrecondition(options) {
|
|
21481
|
+
const revision = expectedRevision(options.expectedRevision);
|
|
21482
|
+
const version = options.expectedVersion;
|
|
21483
|
+
if (version !== undefined)
|
|
21484
|
+
expectedVersion(version);
|
|
21485
|
+
if (revision === undefined && version === undefined) {
|
|
21486
|
+
throw new ValidationError('expectedRevision or expectedVersion is required');
|
|
21487
|
+
}
|
|
21488
|
+
return { expected_revision: revision, expected_version: version };
|
|
21489
|
+
}
|
|
21392
21490
|
function keysQuery(keys) {
|
|
21393
21491
|
if (keys === undefined)
|
|
21394
21492
|
return undefined;
|
|
@@ -21520,6 +21618,7 @@ class StructuredIngotTypesModule {
|
|
|
21520
21618
|
|
|
21521
21619
|
function mutation(wire) {
|
|
21522
21620
|
return { id: wire.ingot_id, version: wire.version, keyCount: wire.key_count, type: readPin(wire.type),
|
|
21621
|
+
...(wire.revision === undefined ? {} : { revision: readRevision(wire.revision) }),
|
|
21523
21622
|
...(wire.created_at === undefined ? {} : { createdAt: wire.created_at }),
|
|
21524
21623
|
...(wire.updated_at === undefined ? {} : { updatedAt: wire.updated_at }),
|
|
21525
21624
|
...(wire.created === undefined ? {} : { created: wire.created }),
|
|
@@ -21564,6 +21663,7 @@ class StructuredIngotsModule {
|
|
|
21564
21663
|
if (data.inline !== true)
|
|
21565
21664
|
throw new SparkVaultError('This server did not return a typed record response', 'invalid_response');
|
|
21566
21665
|
return { id: data.ingot_id, name: data.name, version: data.version, keyCount: data.key_count,
|
|
21666
|
+
...(data.revision === undefined ? {} : { revision: readRevision(data.revision) }),
|
|
21567
21667
|
values: data.values, missingKeys: data.missing_keys, type: readPin(data.type),
|
|
21568
21668
|
binaryPaths: data.binary_paths ?? data.binary_keys?.map((key) => [key]) ?? [],
|
|
21569
21669
|
createdAt: data.created_at, updatedAt: data.updated_at };
|
|
@@ -21572,6 +21672,7 @@ class StructuredIngotsModule {
|
|
|
21572
21672
|
const id = requireVault(vault);
|
|
21573
21673
|
const { data } = await this.http.get(apiPath `/v1/products/structured-ingots/${id}`, { vat: vault.vatToken, query: pageQuery(options) });
|
|
21574
21674
|
return page(data, data.ingots.map((record) => ({ id: record.ingot_id, name: record.name, sizeBytes: record.size_bytes,
|
|
21675
|
+
...(record.revision == null ? {} : { revision: readRevision(record.revision) }),
|
|
21575
21676
|
createdAt: record.created_at, updatedAt: record.updated_at ?? null })));
|
|
21576
21677
|
}
|
|
21577
21678
|
iterate(vault, options = {}) {
|
|
@@ -21588,20 +21689,22 @@ class StructuredIngotsModule {
|
|
|
21588
21689
|
async patch(vault, ref, options) {
|
|
21589
21690
|
const id = requireVault(vault);
|
|
21590
21691
|
const record = requireRef(ref);
|
|
21591
|
-
|
|
21692
|
+
const precondition = mutationPrecondition(options);
|
|
21592
21693
|
if (options.set !== undefined)
|
|
21593
21694
|
validateValues(options.set);
|
|
21594
21695
|
if (options.delete !== undefined && (!Array.isArray(options.delete) || options.delete.some((key) => typeof key !== 'string' || !key.length))) {
|
|
21595
21696
|
throw new ValidationError('delete must contain non-empty field names');
|
|
21596
21697
|
}
|
|
21597
21698
|
validateBinaryPaths(options.binaryPaths);
|
|
21598
|
-
const { data } = await this.http.patch(apiPath `/v1/products/structured-ingots/${id}/${record}`, {
|
|
21699
|
+
const { data } = await this.http.patch(apiPath `/v1/products/structured-ingots/${id}/${record}`, { ...precondition, set: options.set, delete: options.delete, type: wirePin(options.type), binary_paths: options.binaryPaths }, { vat: vault.vatToken });
|
|
21599
21700
|
return mutation(data);
|
|
21600
21701
|
}
|
|
21601
|
-
async delete(vault, ref) {
|
|
21702
|
+
async delete(vault, ref, options = {}) {
|
|
21602
21703
|
const id = requireVault(vault);
|
|
21603
21704
|
const record = requireRef(ref);
|
|
21604
|
-
await this.http.delete(apiPath `/v1/products/structured-ingots/${id}/${record}`, {
|
|
21705
|
+
await this.http.delete(apiPath `/v1/products/structured-ingots/${id}/${record}`, {
|
|
21706
|
+
vat: vault.vatToken, query: { expected_revision: expectedRevision(options.expectedRevision) },
|
|
21707
|
+
});
|
|
21605
21708
|
}
|
|
21606
21709
|
async history(vault, ref) {
|
|
21607
21710
|
const id = requireVault(vault);
|
|
@@ -21614,10 +21717,10 @@ class StructuredIngotsModule {
|
|
|
21614
21717
|
async restore(vault, ref, versionId, options) {
|
|
21615
21718
|
const id = requireVault(vault);
|
|
21616
21719
|
const record = requireRef(ref);
|
|
21617
|
-
|
|
21720
|
+
const precondition = mutationPrecondition(options);
|
|
21618
21721
|
if (typeof versionId !== 'string' || !/^[A-Za-z0-9:_-]{1,128}$/.test(versionId))
|
|
21619
21722
|
throw new ValidationError('versionId must name a retained publication');
|
|
21620
|
-
const { data } = await this.http.post(apiPath `/v1/products/structured-ingots/${id}/${record}/versions/${versionId}/restore`,
|
|
21723
|
+
const { data } = await this.http.post(apiPath `/v1/products/structured-ingots/${id}/${record}/versions/${versionId}/restore`, precondition, { vat: vault.vatToken });
|
|
21621
21724
|
return mutation(data);
|
|
21622
21725
|
}
|
|
21623
21726
|
/** Bounded parallel reads with independent, ordered success/error outcomes. */
|
|
@@ -25649,7 +25752,7 @@ class SparkVault {
|
|
|
25649
25752
|
}
|
|
25650
25753
|
/** Get the SDK version */
|
|
25651
25754
|
static get version() {
|
|
25652
|
-
return '15.9.
|
|
25755
|
+
return '15.9.1';
|
|
25653
25756
|
}
|
|
25654
25757
|
}
|
|
25655
25758
|
if (typeof window !== 'undefined') {
|