@sparkvault/sdk-js 11.3.1 → 12.0.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/dist/folders/index.d.ts +12 -5
- package/dist/folders/types.d.ts +28 -1
- package/dist/index.cjs +58 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +106 -20
- package/dist/index.mjs +58 -11
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/index.d.ts +11 -3
- package/dist/ingots/types.d.ts +22 -11
- package/dist/sparks/index.d.ts +16 -3
- package/dist/sparks/types.d.ts +42 -2
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/folders/index.d.ts
CHANGED
|
@@ -6,17 +6,24 @@
|
|
|
6
6
|
* with its short-lived Vault Access Token (VAT).
|
|
7
7
|
*/
|
|
8
8
|
import { HttpClient } from '../http';
|
|
9
|
-
import type { UnsealedVault, Folder, FolderBreadcrumbItem, CreateFolderOptions, UpdateFolderOptions, FolderWire } from './types';
|
|
9
|
+
import type { UnsealedVault, Folder, FolderBreadcrumbItem, CreateFolderOptions, UpdateFolderOptions, FolderWire, FolderPage, ListFoldersOptions } from './types';
|
|
10
10
|
export declare class FoldersModule {
|
|
11
11
|
private readonly http;
|
|
12
12
|
constructor(http: HttpClient);
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* One page of the vault's folders ({@link FolderPage}). Pass a page's
|
|
15
|
+
* `nextPageToken` back as `pageToken` until it is null. To show one
|
|
16
|
+
* folder's subfolders, list its contents (`ingots.listContents`) instead.
|
|
15
17
|
*
|
|
16
18
|
* @example
|
|
17
|
-
*
|
|
19
|
+
* let pageToken: string | undefined;
|
|
20
|
+
* do {
|
|
21
|
+
* const page = await sv.folders.list(unsealed, { pageToken });
|
|
22
|
+
* page.folders.forEach((f) => console.log(f.name));
|
|
23
|
+
* pageToken = page.nextPageToken ?? undefined;
|
|
24
|
+
* } while (pageToken);
|
|
18
25
|
*/
|
|
19
|
-
list(vault: UnsealedVault): Promise<
|
|
26
|
+
list(vault: UnsealedVault, options?: ListFoldersOptions): Promise<FolderPage>;
|
|
20
27
|
/**
|
|
21
28
|
* The folder at `path`, or null when the vault has none there. `path` is an
|
|
22
29
|
* upload's folder path (`folder` on an upload): slash-delimited from the
|
|
@@ -92,4 +99,4 @@ export declare class FoldersModule {
|
|
|
92
99
|
}
|
|
93
100
|
/** A folder as the API sends it, in the SDK's shape (also the contents listing's subfolders). */
|
|
94
101
|
export declare function mapFolder(wire: FolderWire): Folder;
|
|
95
|
-
export type { UnsealedVault, Folder, FolderBreadcrumbItem, CreateFolderOptions, UpdateFolderOptions, } from './types';
|
|
102
|
+
export type { UnsealedVault, Folder, FolderBreadcrumbItem, FolderPage, ListFoldersOptions, CreateFolderOptions, UpdateFolderOptions, } from './types';
|
package/dist/folders/types.d.ts
CHANGED
|
@@ -28,6 +28,26 @@ export interface FolderBreadcrumbItem {
|
|
|
28
28
|
/** Folder name */
|
|
29
29
|
name: string;
|
|
30
30
|
}
|
|
31
|
+
/** Options for one page of a vault's folders. */
|
|
32
|
+
export interface ListFoldersOptions {
|
|
33
|
+
/** Most folders on one page (1-500; server default 100) */
|
|
34
|
+
limit?: number;
|
|
35
|
+
/** A prior page's `nextPageToken` */
|
|
36
|
+
pageToken?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One page of a vault's folders: at most `limit` of them, in an order that
|
|
40
|
+
* holds from page to page and is not by name. A page can hold fewer, even
|
|
41
|
+
* none, and still not be the last: follow `nextPageToken`, never the count,
|
|
42
|
+
* and sort what you hold. To show one folder's subfolders, list its contents
|
|
43
|
+
* (`ingots.listContents`), which pages them first.
|
|
44
|
+
*/
|
|
45
|
+
export interface FolderPage {
|
|
46
|
+
/** This page's folders */
|
|
47
|
+
folders: Folder[];
|
|
48
|
+
/** The next page's `pageToken`; null on the last page */
|
|
49
|
+
nextPageToken: string | null;
|
|
50
|
+
}
|
|
31
51
|
/** Options for creating a folder. */
|
|
32
52
|
export interface CreateFolderOptions {
|
|
33
53
|
/** Folder name */
|
|
@@ -59,6 +79,13 @@ export interface FolderDetailWire extends FolderWire {
|
|
|
59
79
|
}[];
|
|
60
80
|
subfolder_count?: number;
|
|
61
81
|
}
|
|
82
|
+
/** GET /vaults/:id/folders: one page */
|
|
62
83
|
export interface ListFoldersResponse {
|
|
63
|
-
folders
|
|
84
|
+
folders?: FolderWire[];
|
|
85
|
+
/** Null on the last page; read as null when absent, so a page without it ends the walk instead of looping. */
|
|
86
|
+
next_page_token?: string | null;
|
|
87
|
+
}
|
|
88
|
+
/** GET /vaults/:id/folders?path=: the folder at the path, or none (never paged) */
|
|
89
|
+
export interface FolderPathLookupResponse {
|
|
90
|
+
folders?: FolderWire[];
|
|
64
91
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -16120,15 +16120,25 @@ class FoldersModule {
|
|
|
16120
16120
|
this.http = http;
|
|
16121
16121
|
}
|
|
16122
16122
|
/**
|
|
16123
|
-
*
|
|
16123
|
+
* One page of the vault's folders ({@link FolderPage}). Pass a page's
|
|
16124
|
+
* `nextPageToken` back as `pageToken` until it is null. To show one
|
|
16125
|
+
* folder's subfolders, list its contents (`ingots.listContents`) instead.
|
|
16124
16126
|
*
|
|
16125
16127
|
* @example
|
|
16126
|
-
*
|
|
16128
|
+
* let pageToken: string | undefined;
|
|
16129
|
+
* do {
|
|
16130
|
+
* const page = await sv.folders.list(unsealed, { pageToken });
|
|
16131
|
+
* page.folders.forEach((f) => console.log(f.name));
|
|
16132
|
+
* pageToken = page.nextPageToken ?? undefined;
|
|
16133
|
+
* } while (pageToken);
|
|
16127
16134
|
*/
|
|
16128
|
-
async list(vault) {
|
|
16135
|
+
async list(vault, options = {}) {
|
|
16129
16136
|
const vaultId = requireVaultId(vault);
|
|
16130
|
-
const response = await this.http.get(apiPath `/v1/vaults/${vaultId}/folders`, { vat: vault.vatToken });
|
|
16131
|
-
return
|
|
16137
|
+
const response = await this.http.get(apiPath `/v1/vaults/${vaultId}/folders`, { vat: vault.vatToken, query: { limit: options.limit, page_token: options.pageToken } });
|
|
16138
|
+
return {
|
|
16139
|
+
folders: (response.data.folders ?? []).map(mapFolder),
|
|
16140
|
+
nextPageToken: response.data.next_page_token ?? null,
|
|
16141
|
+
};
|
|
16132
16142
|
}
|
|
16133
16143
|
/**
|
|
16134
16144
|
* The folder at `path`, or null when the vault has none there. `path` is an
|
|
@@ -16619,11 +16629,19 @@ class IngotsModule {
|
|
|
16619
16629
|
return mapIngotPage(response.data);
|
|
16620
16630
|
}
|
|
16621
16631
|
/**
|
|
16622
|
-
* List a folder, or the vault root,
|
|
16623
|
-
*
|
|
16632
|
+
* List one page of a folder's, or the vault root's, children: every direct
|
|
16633
|
+
* subfolder first, then the ingots directly in it in creation order
|
|
16634
|
+
* ({@link FolderContents}). Pass a page's `nextPageToken` back as
|
|
16635
|
+
* `pageToken`, with the same folder and order, until it is null.
|
|
16624
16636
|
*
|
|
16625
16637
|
* @example
|
|
16626
|
-
*
|
|
16638
|
+
* let pageToken: string | undefined;
|
|
16639
|
+
* do {
|
|
16640
|
+
* const page = await sv.ingots.listContents(unsealed, { folderId: 'fld_x', pageToken });
|
|
16641
|
+
* page.folders.forEach((f) => console.log(f.name));
|
|
16642
|
+
* page.ingots.forEach((i) => console.log(i.name));
|
|
16643
|
+
* pageToken = page.nextPageToken ?? undefined;
|
|
16644
|
+
* } while (pageToken);
|
|
16627
16645
|
*/
|
|
16628
16646
|
async listContents(vault, options = {}) {
|
|
16629
16647
|
const vaultId = requireVaultId(vault);
|
|
@@ -16631,7 +16649,8 @@ class IngotsModule {
|
|
|
16631
16649
|
vat: vault.vatToken,
|
|
16632
16650
|
query: {
|
|
16633
16651
|
folder_id: options.folderId,
|
|
16634
|
-
|
|
16652
|
+
limit: options.limit,
|
|
16653
|
+
page_token: options.pageToken,
|
|
16635
16654
|
sort_order: options.sortOrder,
|
|
16636
16655
|
},
|
|
16637
16656
|
});
|
|
@@ -16889,6 +16908,7 @@ function mapFolderContents(wire) {
|
|
|
16889
16908
|
breadcrumb: (wire.breadcrumb ?? []).map((item) => ({ id: item.folder_id, name: item.name })),
|
|
16890
16909
|
folders: (wire.folders ?? []).map(mapFolder),
|
|
16891
16910
|
ingots: (wire.ingots ?? []).map(mapIngot),
|
|
16911
|
+
nextPageToken: wire.next_page_token ?? null,
|
|
16892
16912
|
};
|
|
16893
16913
|
}
|
|
16894
16914
|
function mapIngotPage(response) {
|
|
@@ -16967,10 +16987,12 @@ class SparksModule {
|
|
|
16967
16987
|
};
|
|
16968
16988
|
}
|
|
16969
16989
|
/**
|
|
16970
|
-
* Create a spark.
|
|
16990
|
+
* Create a spark. A link spark (contentType text/uri-list, the payload its
|
|
16991
|
+
* destination URL) is created with its x.sv link, `linkUrl`.
|
|
16971
16992
|
*
|
|
16972
16993
|
* @example
|
|
16973
16994
|
* const spark = await sv.sparks.create({ payload: 'top secret', ttlMinutes: 60 });
|
|
16995
|
+
* const { linkUrl } = await sv.sparks.create({ payload: 'https://example.com', contentType: 'text/uri-list' });
|
|
16974
16996
|
*/
|
|
16975
16997
|
async create(options) {
|
|
16976
16998
|
if (typeof options.payload !== 'string' || options.payload.length === 0) {
|
|
@@ -16997,6 +17019,8 @@ class SparksModule {
|
|
|
16997
17019
|
ttlMinutes: data.ttl_minutes,
|
|
16998
17020
|
filename: data.filename,
|
|
16999
17021
|
kindling: data.kindling,
|
|
17022
|
+
linkUrl: data.link_url,
|
|
17023
|
+
linkCode: data.link_code,
|
|
17000
17024
|
};
|
|
17001
17025
|
}
|
|
17002
17026
|
/**
|
|
@@ -17025,6 +17049,27 @@ class SparksModule {
|
|
|
17025
17049
|
});
|
|
17026
17050
|
return mapShare(response.data);
|
|
17027
17051
|
}
|
|
17052
|
+
/**
|
|
17053
|
+
* Deliver an invite-only spark's link to its invitee again, changing
|
|
17054
|
+
* nothing about the link: the way on from an invitation that could not be
|
|
17055
|
+
* delivered (a share rejected with INVITATION_DELIVERY_FAILED leaves its
|
|
17056
|
+
* link in place, and the same share again delivers nothing), or one the
|
|
17057
|
+
* invitee never received.
|
|
17058
|
+
*
|
|
17059
|
+
* @example
|
|
17060
|
+
* const { identity } = await sv.sparks.resendInvite('spk_abc');
|
|
17061
|
+
*/
|
|
17062
|
+
async resendInvite(sparkId) {
|
|
17063
|
+
const id = requireResourceId(sparkId, 'sparkId');
|
|
17064
|
+
const response = await this.http.post(apiPath `/v1/sparks/${id}/share/resend`);
|
|
17065
|
+
const data = response.data;
|
|
17066
|
+
return {
|
|
17067
|
+
sparkId: data.spark_id,
|
|
17068
|
+
identity: data.identity,
|
|
17069
|
+
identityType: data.identity_type,
|
|
17070
|
+
sentAt: data.sent_at,
|
|
17071
|
+
};
|
|
17072
|
+
}
|
|
17028
17073
|
/**
|
|
17029
17074
|
* Get a spark's sharing status.
|
|
17030
17075
|
*
|
|
@@ -17060,6 +17105,7 @@ function mapSummary(wire) {
|
|
|
17060
17105
|
timeRemaining: wire.time_remaining ?? 0,
|
|
17061
17106
|
filename: wire.filename,
|
|
17062
17107
|
kindling: wire.kindling,
|
|
17108
|
+
linkUrl: wire.link_url,
|
|
17063
17109
|
};
|
|
17064
17110
|
}
|
|
17065
17111
|
function mapShare(wire) {
|
|
@@ -17071,6 +17117,7 @@ function mapShare(wire) {
|
|
|
17071
17117
|
invites: wire.invites,
|
|
17072
17118
|
expiresAt: wire.expires_at,
|
|
17073
17119
|
createdAt: wire.created_at,
|
|
17120
|
+
deliveredTo: wire.delivered_to,
|
|
17074
17121
|
};
|
|
17075
17122
|
}
|
|
17076
17123
|
|
|
@@ -17605,7 +17652,7 @@ class SparkVault {
|
|
|
17605
17652
|
}
|
|
17606
17653
|
/** Get the SDK version */
|
|
17607
17654
|
static get version() {
|
|
17608
|
-
return '
|
|
17655
|
+
return '12.0.1';
|
|
17609
17656
|
}
|
|
17610
17657
|
}
|
|
17611
17658
|
if (typeof window !== 'undefined') {
|