@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/ingots/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { type ResolvedConfig } from '../config';
|
|
13
13
|
import { HttpClient } from '../http';
|
|
14
|
-
import type { UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, DownloadIngotOptions, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvitation, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
14
|
+
import type { UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, IngotDownload, DeleteIngotOptions, DownloadIngotOptions, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvitation, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
15
15
|
export declare class IngotsModule {
|
|
16
16
|
private readonly config;
|
|
17
17
|
private readonly http;
|
|
@@ -184,7 +184,10 @@ export declare class IngotsModule {
|
|
|
184
184
|
* before the replacement is staged where there is no XMLHttpRequest.
|
|
185
185
|
*
|
|
186
186
|
* @example
|
|
187
|
-
* await sv.ingots.
|
|
187
|
+
* const original = await sv.ingots.downloadWithRevision(unsealed, 'ing_abc');
|
|
188
|
+
* await sv.ingots.replace(unsealed, 'ing_abc', {
|
|
189
|
+
* file: updatedFile, expectedRevision: original.revision,
|
|
190
|
+
* });
|
|
188
191
|
*/
|
|
189
192
|
replace(vault: UnsealedVault, ingotId: string, options: ReplaceIngotOptions): Promise<CreatedIngot>;
|
|
190
193
|
/**
|
|
@@ -206,9 +209,11 @@ export declare class IngotsModule {
|
|
|
206
209
|
* Delete an ingot.
|
|
207
210
|
*
|
|
208
211
|
* @example
|
|
209
|
-
* await sv.ingots.
|
|
212
|
+
* const original = await sv.ingots.get(unsealed, 'ing_abc');
|
|
213
|
+
* if (!original.revision) throw new Error('This server does not support guarded deletion');
|
|
214
|
+
* await sv.ingots.delete(unsealed, original.id, { expectedRevision: original.revision });
|
|
210
215
|
*/
|
|
211
|
-
delete(vault: UnsealedVault, ingotId: string): Promise<void>;
|
|
216
|
+
delete(vault: UnsealedVault, ingotId: string, options?: DeleteIngotOptions): Promise<void>;
|
|
212
217
|
/**
|
|
213
218
|
* Get ingot metadata.
|
|
214
219
|
*
|
|
@@ -299,6 +304,12 @@ export declare class IngotsModule {
|
|
|
299
304
|
* link.click();
|
|
300
305
|
*/
|
|
301
306
|
download(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<Blob>;
|
|
307
|
+
/**
|
|
308
|
+
* Download bytes with their identity-bound revision. Use the returned revision
|
|
309
|
+
* for replace/delete preconditions; the link's earlier metadata may already
|
|
310
|
+
* have been superseded when Forge begins serving the bytes.
|
|
311
|
+
*/
|
|
312
|
+
downloadWithRevision(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<IngotDownload>;
|
|
302
313
|
/**
|
|
303
314
|
* Get an ingot's sharing configuration.
|
|
304
315
|
*
|
|
@@ -368,4 +379,4 @@ export { NAME_CONFLICT_POLICIES } from './types';
|
|
|
368
379
|
export { fetchDownload } from './fetch-download';
|
|
369
380
|
export { isReceivedUploadFailure } from '../vaults/upload/api';
|
|
370
381
|
export type { FetchDownloadOptions, FetchedDownload } from './fetch-download';
|
|
371
|
-
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, DownloadIngotOptions, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotInvitation, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
|
382
|
+
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, IngotDownload, DeleteIngotOptions, DownloadIngotOptions, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotInvitation, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Validate an opaque server revision without interpreting it as a credential. */
|
|
2
|
+
export declare function expectedRevision(value: unknown): string | undefined;
|
|
3
|
+
/** Older servers omit the revision; never invent a precondition from metadata. */
|
|
4
|
+
export declare function readRevision(value: unknown): string | undefined;
|
package/dist/ingots/types.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export interface Ingot {
|
|
|
69
69
|
contentHmac: string | null;
|
|
70
70
|
/** Opaque published-content revision; null for legacy/unpublished content. */
|
|
71
71
|
contentVersion: string | null;
|
|
72
|
+
/** Object identity and publication together; absent on older servers. */
|
|
73
|
+
revision?: string;
|
|
72
74
|
}
|
|
73
75
|
/** The discrete primitive returned by createUpload — a Forge TUS session. */
|
|
74
76
|
export interface IngotUpload {
|
|
@@ -131,6 +133,8 @@ export interface DownloadIngotOptions {
|
|
|
131
133
|
export interface IngotDownloadLink {
|
|
132
134
|
/** Opaque published-content revision; null for legacy content. */
|
|
133
135
|
contentVersion: string | null;
|
|
136
|
+
/** Revision observed when the link was minted, not necessarily the bytes it later serves. */
|
|
137
|
+
revision?: string;
|
|
134
138
|
/** Short-lived signed Forge download URL */
|
|
135
139
|
downloadUrl: string;
|
|
136
140
|
/** Ingot ID */
|
|
@@ -142,6 +146,15 @@ export interface IngotDownloadLink {
|
|
|
142
146
|
/** Content type (MIME) */
|
|
143
147
|
contentType: string;
|
|
144
148
|
}
|
|
149
|
+
/** Downloaded bytes and the revision they belong to, for guarded read-modify-write. */
|
|
150
|
+
export interface IngotDownload {
|
|
151
|
+
blob: Blob;
|
|
152
|
+
revision: string;
|
|
153
|
+
}
|
|
154
|
+
export interface DeleteIngotOptions {
|
|
155
|
+
/** Delete only this object publication. Omitted preserves unconditional deletion. */
|
|
156
|
+
expectedRevision?: string;
|
|
157
|
+
}
|
|
145
158
|
/** Options for the createUpload primitive. */
|
|
146
159
|
export interface CreateUploadOptions {
|
|
147
160
|
/** Unsealed vault the ingot belongs to */
|
|
@@ -215,6 +228,8 @@ export type ResumeUploadOptions = Omit<SendUploadOptions, 'onSessionCreated'>;
|
|
|
215
228
|
export interface ReplaceIngotOptions {
|
|
216
229
|
/** File or Blob to upload as the new content */
|
|
217
230
|
file: File | Blob;
|
|
231
|
+
/** Replace only the object publication read; stale or recreated targets return 412. */
|
|
232
|
+
expectedRevision?: string;
|
|
218
233
|
/** Optional new name (defaults to file name) */
|
|
219
234
|
name?: string;
|
|
220
235
|
/** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
|
|
@@ -409,6 +424,7 @@ export interface IngotWire {
|
|
|
409
424
|
folder_id?: string | null;
|
|
410
425
|
content_hmac?: string | null;
|
|
411
426
|
content_version?: string | null;
|
|
427
|
+
revision?: string;
|
|
412
428
|
}
|
|
413
429
|
/** One hash-check hit: this HMAC exists on an active ingot in the vault. */
|
|
414
430
|
export interface HashCheckMatch {
|
|
@@ -459,6 +475,7 @@ export interface ListContentsResponse {
|
|
|
459
475
|
}
|
|
460
476
|
export interface DownloadIngotResponse {
|
|
461
477
|
content_version?: string | null;
|
|
478
|
+
revision?: string;
|
|
462
479
|
download_url: string;
|
|
463
480
|
ingot_id: string;
|
|
464
481
|
name: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpClient } from '../../http';
|
|
2
2
|
import type { UnsealedVault } from '../../vaults/types';
|
|
3
3
|
import { StructuredIngotTypesModule } from './types-client';
|
|
4
|
-
import type { BatchGetStructuredIngotsOptions, CreateStructuredIngotOptions, GetStructuredIngotOptions, ImportStructuredIngotsOptions, PatchStructuredIngotOptions, PortableStructuredIngot, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotSummary, StructuredIterateOptions, StructuredPage, StructuredPageOptions, StructuredReadOutcome, StructuredValues, StructuredAccountActivity, StructuredActivityOptions, StructuredVaultActivity } from './types';
|
|
4
|
+
import type { BatchGetStructuredIngotsOptions, CreateStructuredIngotOptions, DeleteStructuredIngotOptions, GetStructuredIngotOptions, ImportStructuredIngotsOptions, PatchStructuredIngotOptions, PortableStructuredIngot, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotSummary, StructuredIterateOptions, StructuredPage, StructuredPageOptions, StructuredReadOutcome, StructuredValues, RestoreStructuredIngotOptions, StructuredAccountActivity, StructuredActivityOptions, StructuredVaultActivity } from './types';
|
|
5
5
|
/** Typed record operations using the caller's existing account and vault session. */
|
|
6
6
|
export declare class StructuredIngotsModule {
|
|
7
7
|
private readonly http;
|
|
@@ -17,11 +17,9 @@ export declare class StructuredIngotsModule {
|
|
|
17
17
|
/** Names use the server's documented Unicode caseless matching rules. */
|
|
18
18
|
create<T extends object = StructuredValues>(vault: UnsealedVault, options: CreateStructuredIngotOptions<T>): Promise<StructuredIngotMutation>;
|
|
19
19
|
patch<T extends object = StructuredValues>(vault: UnsealedVault, ref: string, options: PatchStructuredIngotOptions<T>): Promise<StructuredIngotMutation>;
|
|
20
|
-
delete(vault: UnsealedVault, ref: string): Promise<void>;
|
|
20
|
+
delete(vault: UnsealedVault, ref: string, options?: DeleteStructuredIngotOptions): Promise<void>;
|
|
21
21
|
history(vault: UnsealedVault, ref: string): Promise<StructuredIngotHistory>;
|
|
22
|
-
restore(vault: UnsealedVault, ref: string, versionId: string, options:
|
|
23
|
-
expectedVersion: number;
|
|
24
|
-
}): Promise<StructuredIngotMutation>;
|
|
22
|
+
restore(vault: UnsealedVault, ref: string, versionId: string, options: RestoreStructuredIngotOptions): Promise<StructuredIngotMutation>;
|
|
25
23
|
/** Bounded parallel reads with independent, ordered success/error outcomes. */
|
|
26
24
|
batchGet<T extends object = StructuredValues>(vault: UnsealedVault, refs: string[], options?: BatchGetStructuredIngotsOptions): Promise<StructuredReadOutcome<T>[]>;
|
|
27
25
|
/** Sequential record reads, not a transactionally consistent vault snapshot. */
|
|
@@ -25,6 +25,8 @@ export interface StructuredPage<T> {
|
|
|
25
25
|
export interface StructuredIngotSummary {
|
|
26
26
|
id: string;
|
|
27
27
|
name: string;
|
|
28
|
+
/** Publication observed by the metadata page; absent when the server cannot supply it. */
|
|
29
|
+
revision?: string;
|
|
28
30
|
sizeBytes: number;
|
|
29
31
|
createdAt: number;
|
|
30
32
|
updatedAt: number | null;
|
|
@@ -33,6 +35,8 @@ export interface StructuredIngot<T extends object = StructuredValues> {
|
|
|
33
35
|
id: string;
|
|
34
36
|
name: string;
|
|
35
37
|
version: number;
|
|
38
|
+
/** Identity-bound content revision from the bytes read; absent on older servers. */
|
|
39
|
+
revision?: string;
|
|
36
40
|
keyCount: number;
|
|
37
41
|
values: T;
|
|
38
42
|
missingKeys: string[];
|
|
@@ -45,6 +49,8 @@ export interface StructuredIngot<T extends object = StructuredValues> {
|
|
|
45
49
|
export interface StructuredIngotMutation {
|
|
46
50
|
id: string;
|
|
47
51
|
version: number;
|
|
52
|
+
/** The publication this operation committed; absent on older servers/creation receipts. */
|
|
53
|
+
revision?: string;
|
|
48
54
|
keyCount: number;
|
|
49
55
|
type: StructuredTypePin | null;
|
|
50
56
|
createdAt?: number;
|
|
@@ -64,14 +70,26 @@ export interface CreateStructuredIngotOptions<T extends object = StructuredValue
|
|
|
64
70
|
/** 8–128 printable ASCII characters; bound to this name and semantic payload. */
|
|
65
71
|
idempotencyKey?: string;
|
|
66
72
|
}
|
|
67
|
-
|
|
73
|
+
/** Prefer the opaque revision: it also rejects deletion and recreation under the same name. */
|
|
74
|
+
export type StructuredIngotPrecondition = {
|
|
75
|
+
expectedRevision: string;
|
|
76
|
+
expectedVersion?: number;
|
|
77
|
+
} | {
|
|
78
|
+
expectedRevision?: undefined;
|
|
68
79
|
expectedVersion: number;
|
|
80
|
+
};
|
|
81
|
+
export type PatchStructuredIngotOptions<T extends object = StructuredValues> = StructuredIngotPrecondition & {
|
|
69
82
|
set?: Partial<T>;
|
|
70
83
|
delete?: string[];
|
|
71
84
|
/** Omitted preserves the current type; null explicitly removes it. */
|
|
72
85
|
type?: StructuredTypePin | null;
|
|
73
86
|
/** Paths are relative to the `set` object. */
|
|
74
87
|
binaryPaths?: StructuredBinaryPath[];
|
|
88
|
+
};
|
|
89
|
+
export type RestoreStructuredIngotOptions = StructuredIngotPrecondition;
|
|
90
|
+
export interface DeleteStructuredIngotOptions {
|
|
91
|
+
/** Delete only this object publication. Omitted preserves unconditional deletion. */
|
|
92
|
+
expectedRevision?: string;
|
|
75
93
|
}
|
|
76
94
|
export interface StructuredIngotVersion {
|
|
77
95
|
versionId: string;
|
|
@@ -212,6 +230,7 @@ export interface StructuredIngotSummaryWire {
|
|
|
212
230
|
size_bytes: number;
|
|
213
231
|
created_at: number;
|
|
214
232
|
updated_at?: number | null;
|
|
233
|
+
revision?: string | null;
|
|
215
234
|
}
|
|
216
235
|
export interface StructuredIngotWire<T extends object = StructuredValues> {
|
|
217
236
|
ingot_id: string;
|
|
@@ -220,6 +239,7 @@ export interface StructuredIngotWire<T extends object = StructuredValues> {
|
|
|
220
239
|
key_count: number;
|
|
221
240
|
values: T;
|
|
222
241
|
missing_keys: string[];
|
|
242
|
+
revision?: string;
|
|
223
243
|
binary_paths?: StructuredBinaryPath[];
|
|
224
244
|
binary_keys?: string[];
|
|
225
245
|
type?: StructuredTypePinWire | null;
|
|
@@ -232,6 +252,7 @@ export interface StructuredMutationWire {
|
|
|
232
252
|
version: number;
|
|
233
253
|
key_count: number;
|
|
234
254
|
type?: StructuredTypePinWire | null;
|
|
255
|
+
revision?: string;
|
|
235
256
|
created_at?: number;
|
|
236
257
|
updated_at?: number;
|
|
237
258
|
created?: boolean;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { UnsealedVault } from '../../vaults/types';
|
|
2
|
-
import type { StructuredBinaryPath, StructuredPageOptions, StructuredPageWire, StructuredPage, StructuredTypePin, StructuredTypePinWire } from './types';
|
|
2
|
+
import type { StructuredBinaryPath, StructuredIngotPrecondition, StructuredPageOptions, StructuredPageWire, StructuredPage, StructuredTypePin, StructuredTypePinWire } from './types';
|
|
3
3
|
export declare function requireVault(vault: UnsealedVault): string;
|
|
4
4
|
export declare function requireRef(ref: string): string;
|
|
5
5
|
export declare function integer(value: number, field: string, minimum: number, maximum: number): number;
|
|
6
6
|
export declare function expectedVersion(value: number): number;
|
|
7
|
+
export declare function mutationPrecondition(options: StructuredIngotPrecondition): {
|
|
8
|
+
expected_revision?: string;
|
|
9
|
+
expected_version?: number;
|
|
10
|
+
};
|
|
7
11
|
export declare function keysQuery(keys: string[] | undefined): string | undefined;
|
|
8
12
|
export declare function pageQuery(options: StructuredPageOptions): {
|
|
9
13
|
limit?: number;
|