@instantdb/platform 1.0.60 → 1.0.61
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/.turbo/turbo-build.log +9 -9
- package/__tests__/src/backupDownload.test.ts +193 -0
- package/__tests__/src/backups.test.ts +168 -0
- package/dist/commonjs/api.d.ts +7 -0
- package/dist/commonjs/api.d.ts.map +1 -1
- package/dist/commonjs/api.js +10 -0
- package/dist/commonjs/api.js.map +1 -1
- package/dist/commonjs/backupDownload.d.ts +74 -0
- package/dist/commonjs/backupDownload.d.ts.map +1 -0
- package/dist/commonjs/backupDownload.js +255 -0
- package/dist/commonjs/backupDownload.js.map +1 -0
- package/dist/commonjs/backups.d.ts +146 -0
- package/dist/commonjs/backups.d.ts.map +1 -0
- package/dist/commonjs/backups.js +248 -0
- package/dist/commonjs/backups.js.map +1 -0
- package/dist/commonjs/index.d.ts +2 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +7 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/api.d.ts +7 -0
- package/dist/esm/api.d.ts.map +1 -1
- package/dist/esm/api.js +10 -0
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/backupDownload.d.ts +74 -0
- package/dist/esm/backupDownload.d.ts.map +1 -0
- package/dist/esm/backupDownload.js +252 -0
- package/dist/esm/backupDownload.js.map +1 -0
- package/dist/esm/backups.d.ts +146 -0
- package/dist/esm/backups.d.ts.map +1 -0
- package/dist/esm/backups.js +237 -0
- package/dist/esm/backups.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/standalone/index.js +1929 -1610
- package/dist/standalone/index.umd.cjs +24 -22
- package/package.json +4 -4
- package/src/api.ts +15 -0
- package/src/backupDownload.ts +364 -0
- package/src/backups.ts +342 -0
- package/src/index.ts +18 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
|
|
2
|
-
> @instantdb/platform@1.0.
|
|
2
|
+
> @instantdb/platform@1.0.61 build /home/runner/work/instant/instant/client/packages/platform
|
|
3
3
|
> rm -rf dist; npm run build:tshy && npm run build:standalone && npm run check-exports
|
|
4
4
|
|
|
5
5
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
6
6
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
7
7
|
|
|
8
|
-
> @instantdb/platform@1.0.
|
|
8
|
+
> @instantdb/platform@1.0.61 build:tshy
|
|
9
9
|
> tshy
|
|
10
10
|
|
|
11
11
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
12
12
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
13
13
|
|
|
14
|
-
> @instantdb/platform@1.0.
|
|
14
|
+
> @instantdb/platform@1.0.61 build:standalone
|
|
15
15
|
> vite build
|
|
16
16
|
|
|
17
17
|
[36mvite v5.4.14 [32mbuilding for production...[36m[39m
|
|
18
18
|
transforming...
|
|
19
|
-
[32m✓[39m
|
|
19
|
+
[32m✓[39m 88 modules transformed.
|
|
20
20
|
rendering chunks...
|
|
21
21
|
computing gzip size...
|
|
22
|
-
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[
|
|
23
|
-
[2mdist/standalone/[22m[36mindex.js [39m[1m[
|
|
24
|
-
[32m✓ built in
|
|
22
|
+
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m370.53 kB[22m[1m[22m[2m │ gzip: 102.56 kB[22m
|
|
23
|
+
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m496.65 kB[22m[1m[22m[2m │ gzip: 119.99 kB[22m
|
|
24
|
+
[32m✓ built in 2.75s[39m
|
|
25
25
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
26
26
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
27
27
|
|
|
28
|
-
> @instantdb/platform@1.0.
|
|
28
|
+
> @instantdb/platform@1.0.61 check-exports
|
|
29
29
|
> attw --pack .
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@instantdb/platform v1.0.
|
|
32
|
+
@instantdb/platform v1.0.61
|
|
33
33
|
|
|
34
34
|
Build tools:
|
|
35
35
|
- @arethetypeswrong/cli@^0.18.5
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { downloadBackupArchive } from '../../src/backupDownload.ts';
|
|
3
|
+
import type { AppBackup } from '../../src/backups.ts';
|
|
4
|
+
|
|
5
|
+
const backup: AppBackup = {
|
|
6
|
+
id: 'backup-1',
|
|
7
|
+
isn: '1',
|
|
8
|
+
backupAt: new Date('2026-08-01T00:00:00Z'),
|
|
9
|
+
filesSize: 16,
|
|
10
|
+
dbSize: 100,
|
|
11
|
+
uncompressedSize: 40,
|
|
12
|
+
description: null,
|
|
13
|
+
expiresAt: null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const bodyOf = (text: string) =>
|
|
17
|
+
new ReadableStream<Uint8Array>({
|
|
18
|
+
start(controller) {
|
|
19
|
+
controller.enqueue(new TextEncoder().encode(text));
|
|
20
|
+
controller.close();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const fetchBody = async (url: string) => bodyOf(`body:${url}`);
|
|
25
|
+
|
|
26
|
+
const listFiles = async () => [
|
|
27
|
+
{ name: 'config.json', size: 1 },
|
|
28
|
+
{ name: 'entities/todos.jsonl', size: 1 },
|
|
29
|
+
];
|
|
30
|
+
const getFileUrl = async (_backupId: string, name: string) => name;
|
|
31
|
+
|
|
32
|
+
// Minimal archive writer: records entry names, drains each input, and writes
|
|
33
|
+
// a byte through the counting sink so zipBytes moves like a real encoder.
|
|
34
|
+
const makeWriter =
|
|
35
|
+
(names: string[]) => async (sink: WritableStream<Uint8Array>) => {
|
|
36
|
+
const w = sink.getWriter();
|
|
37
|
+
return {
|
|
38
|
+
add: async (name: string, input: ReadableStream<Uint8Array>) => {
|
|
39
|
+
names.push(name);
|
|
40
|
+
for await (const _chunk of input) {
|
|
41
|
+
// drain
|
|
42
|
+
}
|
|
43
|
+
await w.write(new Uint8Array([0]));
|
|
44
|
+
},
|
|
45
|
+
close: () => w.close(),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const nullSink = () => new WritableStream<Uint8Array>({ write() {} });
|
|
50
|
+
|
|
51
|
+
describe('downloadBackupArchive', () => {
|
|
52
|
+
test('writes entries in canonical order through the injected writer', async () => {
|
|
53
|
+
const names: string[] = [];
|
|
54
|
+
const manager = {
|
|
55
|
+
listFiles,
|
|
56
|
+
getFileUrl,
|
|
57
|
+
streamStorageFiles: async function* () {
|
|
58
|
+
yield { locationId: 'loc-1', path: 'a.png', url: 'loc-1-url' };
|
|
59
|
+
},
|
|
60
|
+
} as any;
|
|
61
|
+
|
|
62
|
+
const result = await downloadBackupArchive({
|
|
63
|
+
manager,
|
|
64
|
+
backup,
|
|
65
|
+
fetchBody,
|
|
66
|
+
sink: nullSink(),
|
|
67
|
+
createWriter: makeWriter(names),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(names).toEqual([
|
|
71
|
+
'config.json',
|
|
72
|
+
'entities/todos.jsonl',
|
|
73
|
+
'files/loc-1',
|
|
74
|
+
]);
|
|
75
|
+
expect(result.entities).toBe(1);
|
|
76
|
+
expect(result.files).toBe(1);
|
|
77
|
+
expect(result.zipBytes).toBe(3);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('counts an entry as completed only after the writer consumed it', async () => {
|
|
81
|
+
const seen: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
entitiesCompleted: number;
|
|
84
|
+
filesCompleted: number;
|
|
85
|
+
}> = [];
|
|
86
|
+
let last = { entitiesCompleted: 0, filesCompleted: 0 };
|
|
87
|
+
const createWriter = async (sink: WritableStream<Uint8Array>) => {
|
|
88
|
+
const w = sink.getWriter();
|
|
89
|
+
return {
|
|
90
|
+
add: async (name: string, input: ReadableStream<Uint8Array>) => {
|
|
91
|
+
seen.push({ name, ...last });
|
|
92
|
+
for await (const _chunk of input) {
|
|
93
|
+
// drain
|
|
94
|
+
}
|
|
95
|
+
await w.write(new Uint8Array([0]));
|
|
96
|
+
},
|
|
97
|
+
close: () => w.close(),
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const manager = {
|
|
101
|
+
listFiles,
|
|
102
|
+
getFileUrl,
|
|
103
|
+
streamStorageFiles: async function* () {
|
|
104
|
+
yield { locationId: 'loc-1', path: 'a.png', url: 'loc-1-url' };
|
|
105
|
+
},
|
|
106
|
+
} as any;
|
|
107
|
+
|
|
108
|
+
await downloadBackupArchive({
|
|
109
|
+
manager,
|
|
110
|
+
backup,
|
|
111
|
+
fetchBody,
|
|
112
|
+
sink: nullSink(),
|
|
113
|
+
createWriter,
|
|
114
|
+
onProgress: (p) => {
|
|
115
|
+
last = {
|
|
116
|
+
entitiesCompleted: p.entitiesCompleted,
|
|
117
|
+
filesCompleted: p.filesCompleted,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// At the moment each add starts, the entry being written isn't counted.
|
|
123
|
+
expect(seen).toEqual([
|
|
124
|
+
{ name: 'config.json', entitiesCompleted: 0, filesCompleted: 0 },
|
|
125
|
+
{ name: 'entities/todos.jsonl', entitiesCompleted: 0, filesCompleted: 0 },
|
|
126
|
+
{ name: 'files/loc-1', entitiesCompleted: 1, filesCompleted: 0 },
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('a cancellation while storage discovery is idle rejects instead of completing', async () => {
|
|
131
|
+
const controller = new AbortController();
|
|
132
|
+
const manager = {
|
|
133
|
+
listFiles,
|
|
134
|
+
getFileUrl,
|
|
135
|
+
// Yields one file, then holds the stream open like a server with more
|
|
136
|
+
// to send, rejecting with AbortError when the download is cancelled —
|
|
137
|
+
// the same shape as a real aborted fetch.
|
|
138
|
+
streamStorageFiles: (
|
|
139
|
+
_backupId: string,
|
|
140
|
+
opts?: { signal?: AbortSignal },
|
|
141
|
+
) =>
|
|
142
|
+
(async function* () {
|
|
143
|
+
yield { locationId: 'loc-1', path: 'a.png', url: 'loc-1-url' };
|
|
144
|
+
yield await new Promise<never>((_resolve, reject) => {
|
|
145
|
+
opts?.signal?.addEventListener('abort', () =>
|
|
146
|
+
reject(
|
|
147
|
+
Object.assign(new Error('aborted'), { name: 'AbortError' }),
|
|
148
|
+
),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
})(),
|
|
152
|
+
} as any;
|
|
153
|
+
|
|
154
|
+
const promise = downloadBackupArchive({
|
|
155
|
+
manager,
|
|
156
|
+
backup,
|
|
157
|
+
fetchBody,
|
|
158
|
+
sink: nullSink(),
|
|
159
|
+
createWriter: makeWriter([]),
|
|
160
|
+
signal: controller.signal,
|
|
161
|
+
onProgress: (p) => {
|
|
162
|
+
// Cancel once the only discovered file is fully written and the
|
|
163
|
+
// drain loop is about to go idle.
|
|
164
|
+
if (p.filesCompleted === 1) controller.abort();
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
await expect(promise).rejects.toMatchObject({ name: 'AbortError' });
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('names a pathless storage file by locationId when its download fails', async () => {
|
|
172
|
+
const manager = {
|
|
173
|
+
listFiles,
|
|
174
|
+
getFileUrl,
|
|
175
|
+
streamStorageFiles: async function* () {
|
|
176
|
+
yield { locationId: 'loc-9', path: null, url: 'bad-url' };
|
|
177
|
+
},
|
|
178
|
+
} as any;
|
|
179
|
+
|
|
180
|
+
await expect(
|
|
181
|
+
downloadBackupArchive({
|
|
182
|
+
manager,
|
|
183
|
+
backup,
|
|
184
|
+
fetchBody: async (url: string) => {
|
|
185
|
+
if (url === 'bad-url') throw new Error('HTTP 500');
|
|
186
|
+
return bodyOf('x');
|
|
187
|
+
},
|
|
188
|
+
sink: nullSink(),
|
|
189
|
+
createWriter: makeWriter([]),
|
|
190
|
+
}),
|
|
191
|
+
).rejects.toThrow('Couldn\'t download storage file "loc-9" (HTTP 500).');
|
|
192
|
+
});
|
|
193
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
BackupsManager,
|
|
4
|
+
backupZipName,
|
|
5
|
+
formatFileSize,
|
|
6
|
+
type AppBackupStorageFile,
|
|
7
|
+
} from '../../src/backups.ts';
|
|
8
|
+
|
|
9
|
+
const makeManager = () =>
|
|
10
|
+
new BackupsManager({
|
|
11
|
+
appId: 'app-1',
|
|
12
|
+
apiURI: 'http://api.test',
|
|
13
|
+
withAuth: (operation) => operation('test-token'),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const streamOf = (chunks: string[]) =>
|
|
17
|
+
new ReadableStream<Uint8Array>({
|
|
18
|
+
start(controller) {
|
|
19
|
+
const encoder = new TextEncoder();
|
|
20
|
+
for (const chunk of chunks) {
|
|
21
|
+
controller.enqueue(encoder.encode(chunk));
|
|
22
|
+
}
|
|
23
|
+
controller.close();
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const stubFetchBody = (chunks: string[]) => {
|
|
28
|
+
vi.stubGlobal(
|
|
29
|
+
'fetch',
|
|
30
|
+
vi.fn(async () => new Response(streamOf(chunks), { status: 200 })),
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const collect = async (manager: BackupsManager) => {
|
|
35
|
+
const files: AppBackupStorageFile[] = [];
|
|
36
|
+
for await (const file of manager.streamStorageFiles('backup-1')) {
|
|
37
|
+
files.push(file);
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
vi.unstubAllGlobals();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('streamStorageFiles', () => {
|
|
47
|
+
test('yields files and completes on the done sentinel', async () => {
|
|
48
|
+
stubFetchBody([
|
|
49
|
+
'{"locationId":"loc-1","path":"a.png","url":"http://s3/loc-1"}\n',
|
|
50
|
+
'{"locationId":"loc-2","path":"b.png","url":"http://s3/loc-2"}\n',
|
|
51
|
+
'{"done":true}\n',
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
const files = await collect(makeManager());
|
|
55
|
+
expect(files).toEqual([
|
|
56
|
+
{ locationId: 'loc-1', path: 'a.png', url: 'http://s3/loc-1' },
|
|
57
|
+
{ locationId: 'loc-2', path: 'b.png', url: 'http://s3/loc-2' },
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('handles lines split across chunks', async () => {
|
|
62
|
+
stubFetchBody([
|
|
63
|
+
'{"locationId":"loc-1","pa',
|
|
64
|
+
'th":"a.png","url":"http://s3/loc-1"}\n{"done"',
|
|
65
|
+
':true}\n',
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
const files = await collect(makeManager());
|
|
69
|
+
expect(files).toEqual([
|
|
70
|
+
{ locationId: 'loc-1', path: 'a.png', url: 'http://s3/loc-1' },
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('throws on a record without a locationId or url', async () => {
|
|
75
|
+
stubFetchBody([
|
|
76
|
+
'{"path":"orphan.png"}\n',
|
|
77
|
+
'{"locationId":"loc-1","path":"a.png","url":"http://s3/loc-1"}\n',
|
|
78
|
+
'{"done":true}\n',
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
await expect(collect(makeManager())).rejects.toThrow(/malformed record/);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('only accepts an exact done sentinel', async () => {
|
|
85
|
+
stubFetchBody([
|
|
86
|
+
'{"locationId":"loc-1","path":"a.png","url":"http://s3/loc-1"}\n',
|
|
87
|
+
'{"done":1}\n',
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
await expect(collect(makeManager())).rejects.toThrow(/malformed record/);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('completes without files when the app has none', async () => {
|
|
94
|
+
stubFetchBody(['{"done":true}\n']);
|
|
95
|
+
expect(await collect(makeManager())).toEqual([]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('rejects a locationId that could escape the archive path', async () => {
|
|
99
|
+
stubFetchBody([
|
|
100
|
+
'{"locationId":"../evil","path":"a.png","url":"http://s3/loc-1"}\n',
|
|
101
|
+
'{"done":true}\n',
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
await expect(collect(makeManager())).rejects.toThrow(/malformed record/);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('throws when the stream ends without the done sentinel', async () => {
|
|
108
|
+
stubFetchBody([
|
|
109
|
+
'{"locationId":"loc-1","path":"a.png","url":"http://s3/loc-1"}\n',
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
await expect(collect(makeManager())).rejects.toThrow(
|
|
113
|
+
/ended before it finished/,
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('list', () => {
|
|
119
|
+
test('coerces the server row into an AppBackup', async () => {
|
|
120
|
+
vi.stubGlobal(
|
|
121
|
+
'fetch',
|
|
122
|
+
vi.fn(async () =>
|
|
123
|
+
Response.json({
|
|
124
|
+
backups: [
|
|
125
|
+
{
|
|
126
|
+
id: 'backup-1',
|
|
127
|
+
isn: '42',
|
|
128
|
+
backup_at: '2026-08-05T07:12:00Z',
|
|
129
|
+
files_size: 100,
|
|
130
|
+
db_size: 200,
|
|
131
|
+
uncompressed_size: 300,
|
|
132
|
+
description: 'Automated Daily Snapshot',
|
|
133
|
+
expires_at: '2026-08-12T07:12:00Z',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
}),
|
|
137
|
+
),
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const [backup] = await makeManager().list();
|
|
141
|
+
expect(backup).toEqual({
|
|
142
|
+
id: 'backup-1',
|
|
143
|
+
isn: '42',
|
|
144
|
+
backupAt: new Date('2026-08-05T07:12:00Z'),
|
|
145
|
+
filesSize: 100,
|
|
146
|
+
dbSize: 200,
|
|
147
|
+
uncompressedSize: 300,
|
|
148
|
+
description: 'Automated Daily Snapshot',
|
|
149
|
+
expiresAt: new Date('2026-08-12T07:12:00Z'),
|
|
150
|
+
});
|
|
151
|
+
expect(backupZipName(backup)).toBe(
|
|
152
|
+
'instant-backup-2026-08-05T07-12-00-000Z.zip',
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('formatFileSize', () => {
|
|
158
|
+
test('formats with decimal units and adaptive precision', () => {
|
|
159
|
+
expect(formatFileSize(999)).toBe('999 B');
|
|
160
|
+
expect(formatFileSize(3510)).toBe('3.51 KB');
|
|
161
|
+
expect(formatFileSize(1_540_000_000)).toBe('1.54 GB');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('promotes across the unit boundary when rounding', () => {
|
|
165
|
+
expect(formatFileSize(999_500)).toBe('1.00 MB');
|
|
166
|
+
expect(formatFileSize(999_999_500)).toBe('1.00 GB');
|
|
167
|
+
});
|
|
168
|
+
});
|
package/dist/commonjs/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InstantRules, InstantSchemaDef, InstantUnknownSchema, EntitiesDef, LinksDef, RoomsDef, InstantDBAttr, InstantDBIdent, InstantDBCheckedDataType } from '@instantdb/core';
|
|
2
2
|
import { Webhooks } from '@instantdb/webhooks';
|
|
3
|
+
import { BackupsManager } from './backups.ts';
|
|
3
4
|
import { InstantAPIPlatformSchema, InstantAPISchemaPlanStep, InstantAPISchemaPushStep } from './schema.ts';
|
|
4
5
|
import { ProgressPromise } from './ProgressPromise.ts';
|
|
5
6
|
import { RenameCommand } from './migrations.ts';
|
|
@@ -464,6 +465,12 @@ export declare class PlatformApi {
|
|
|
464
465
|
webhooks<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema>(appId: string, opts?: {
|
|
465
466
|
schema?: Schema;
|
|
466
467
|
}): Webhooks<Schema>;
|
|
468
|
+
/**
|
|
469
|
+
* Returns a {@link BackupsManager} scoped to `appId` for listing an app's
|
|
470
|
+
* backups and downloading their contents. Calls are routed through
|
|
471
|
+
* {@link withRetry}, so an expired access token is transparently refreshed.
|
|
472
|
+
*/
|
|
473
|
+
backups(appId: string): BackupsManager;
|
|
467
474
|
}
|
|
468
475
|
export {};
|
|
469
476
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EAIzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EAIzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAML,wBAAwB,E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ACrE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ,CAAC,MAAM,CAAC;IAc9D;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;CAQvC"}
|
package/dist/commonjs/api.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.apiSchemaToInstantSchemaDef = apiSchemaToInstantSchemaDef;
|
|
|
9
9
|
exports.translatePlanSteps = translatePlanSteps;
|
|
10
10
|
const core_1 = require("@instantdb/core");
|
|
11
11
|
const webhooks_1 = require("@instantdb/webhooks");
|
|
12
|
+
const backups_ts_1 = require("./backups.js");
|
|
12
13
|
const version_ts_1 = __importDefault(require("./version.js"));
|
|
13
14
|
const schema_ts_1 = require("./schema.js");
|
|
14
15
|
const ProgressPromise_ts_1 = require("./ProgressPromise.js");
|
|
@@ -1111,6 +1112,15 @@ class PlatformApi {
|
|
|
1111
1112
|
withAuth,
|
|
1112
1113
|
});
|
|
1113
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Returns a {@link BackupsManager} scoped to `appId` for listing an app's
|
|
1117
|
+
* backups and downloading their contents. Calls are routed through
|
|
1118
|
+
* {@link withRetry}, so an expired access token is transparently refreshed.
|
|
1119
|
+
*/
|
|
1120
|
+
backups(appId) {
|
|
1121
|
+
const withAuth = (operation) => this.withRetry((_apiURI, token) => operation(token), [this.#apiURI, this.token()]);
|
|
1122
|
+
return new backups_ts_1.BackupsManager({ appId, apiURI: this.#apiURI, withAuth });
|
|
1123
|
+
}
|
|
1114
1124
|
}
|
|
1115
1125
|
exports.PlatformApi = PlatformApi;
|
|
1116
1126
|
//# sourceMappingURL=api.js.map
|