@syncular/core 0.1.2 → 0.2.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 +5 -19
- package/dist/blob-ref.d.ts +21 -0
- package/dist/blob-ref.js +97 -0
- package/dist/bytes.d.ts +45 -0
- package/dist/bytes.js +242 -0
- package/dist/canonical-json.d.ts +10 -0
- package/dist/canonical-json.js +18 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +5 -0
- package/dist/crypto.d.ts +60 -0
- package/dist/crypto.js +251 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +17 -0
- package/dist/frames.d.ts +24 -0
- package/dist/frames.js +42 -0
- package/dist/index.d.ts +18 -26
- package/dist/index.js +18 -43
- package/dist/message.d.ts +157 -0
- package/dist/message.js +786 -0
- package/dist/realtime.d.ts +92 -0
- package/dist/realtime.js +222 -0
- package/dist/render.d.ts +22 -0
- package/dist/render.js +273 -0
- package/dist/row-codec.d.ts +39 -0
- package/dist/row-codec.js +176 -0
- package/dist/segment.d.ts +18 -0
- package/dist/segment.js +105 -0
- package/dist/stream.d.ts +20 -0
- package/dist/stream.js +102 -0
- package/package.json +7 -59
- package/src/blob-ref.ts +135 -0
- package/src/bytes.ts +301 -0
- package/src/canonical-json.ts +20 -0
- package/src/constants.ts +7 -0
- package/src/crypto.ts +335 -0
- package/src/errors.ts +18 -0
- package/src/frames.ts +47 -0
- package/src/index.ts +18 -43
- package/src/message.ts +1024 -0
- package/src/realtime.ts +340 -0
- package/src/render.ts +325 -0
- package/src/row-codec.ts +265 -0
- package/src/segment.ts +150 -0
- package/src/stream.ts +128 -0
- package/dist/blobs.d.ts +0 -153
- package/dist/blobs.d.ts.map +0 -1
- package/dist/blobs.js +0 -47
- package/dist/blobs.js.map +0 -1
- package/dist/column-codecs.d.ts +0 -59
- package/dist/column-codecs.d.ts.map +0 -1
- package/dist/column-codecs.js +0 -159
- package/dist/column-codecs.js.map +0 -1
- package/dist/conflict.d.ts +0 -22
- package/dist/conflict.d.ts.map +0 -1
- package/dist/conflict.js +0 -81
- package/dist/conflict.js.map +0 -1
- package/dist/database.d.ts +0 -7
- package/dist/database.d.ts.map +0 -1
- package/dist/database.js +0 -14
- package/dist/database.js.map +0 -1
- package/dist/dialect.d.ts +0 -7
- package/dist/dialect.d.ts.map +0 -1
- package/dist/dialect.js +0 -2
- package/dist/dialect.js.map +0 -1
- package/dist/error-responses.d.ts +0 -393
- package/dist/error-responses.d.ts.map +0 -1
- package/dist/error-responses.js +0 -393
- package/dist/error-responses.js.map +0 -1
- package/dist/http/api-client.d.ts +0 -11
- package/dist/http/api-client.d.ts.map +0 -1
- package/dist/http/api-client.js +0 -30
- package/dist/http/api-client.js.map +0 -1
- package/dist/http/blob.d.ts +0 -6
- package/dist/http/blob.d.ts.map +0 -1
- package/dist/http/blob.js +0 -46
- package/dist/http/blob.js.map +0 -1
- package/dist/http/generated/api.d.ts +0 -5241
- package/dist/http/generated/api.d.ts.map +0 -1
- package/dist/http/generated/api.js +0 -6
- package/dist/http/generated/api.js.map +0 -1
- package/dist/http/index.d.ts +0 -18
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -212
- package/dist/http/index.js.map +0 -1
- package/dist/http/shared.d.ts +0 -45
- package/dist/http/shared.d.ts.map +0 -1
- package/dist/http/shared.js +0 -122
- package/dist/http/shared.js.map +0 -1
- package/dist/http/transport-client.d.ts +0 -31
- package/dist/http/transport-client.d.ts.map +0 -1
- package/dist/http/transport-client.js +0 -193
- package/dist/http/transport-client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kysely-column-codecs.d.ts +0 -31
- package/dist/kysely-column-codecs.d.ts.map +0 -1
- package/dist/kysely-column-codecs.js +0 -452
- package/dist/kysely-column-codecs.js.map +0 -1
- package/dist/logger.d.ts +0 -29
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -26
- package/dist/logger.js.map +0 -1
- package/dist/proxy/index.d.ts +0 -54
- package/dist/proxy/index.d.ts.map +0 -1
- package/dist/proxy/index.js +0 -7
- package/dist/proxy/index.js.map +0 -1
- package/dist/schemas/blobs.d.ts +0 -82
- package/dist/schemas/blobs.d.ts.map +0 -1
- package/dist/schemas/blobs.js +0 -64
- package/dist/schemas/blobs.js.map +0 -1
- package/dist/schemas/common.d.ts +0 -100
- package/dist/schemas/common.d.ts.map +0 -1
- package/dist/schemas/common.js +0 -64
- package/dist/schemas/common.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -7
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/index.js +0 -7
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/sync.d.ts +0 -1065
- package/dist/schemas/sync.d.ts.map +0 -1
- package/dist/schemas/sync.js +0 -361
- package/dist/schemas/sync.js.map +0 -1
- package/dist/scopes/index.d.ts +0 -113
- package/dist/scopes/index.d.ts.map +0 -1
- package/dist/scopes/index.js +0 -103
- package/dist/scopes/index.js.map +0 -1
- package/dist/sentry.d.ts +0 -31
- package/dist/sentry.d.ts.map +0 -1
- package/dist/sentry.js +0 -147
- package/dist/sentry.js.map +0 -1
- package/dist/snapshot-chunks.d.ts +0 -110
- package/dist/snapshot-chunks.d.ts.map +0 -1
- package/dist/snapshot-chunks.js +0 -682
- package/dist/snapshot-chunks.js.map +0 -1
- package/dist/sync-packs.d.ts +0 -33
- package/dist/sync-packs.d.ts.map +0 -1
- package/dist/sync-packs.js +0 -821
- package/dist/sync-packs.js.map +0 -1
- package/dist/telemetry.d.ts +0 -114
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js +0 -114
- package/dist/telemetry.js.map +0 -1
- package/dist/transforms.d.ts +0 -146
- package/dist/transforms.d.ts.map +0 -1
- package/dist/transforms.js +0 -155
- package/dist/transforms.js.map +0 -1
- package/dist/types.d.ts +0 -210
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -20
- package/dist/types.js.map +0 -1
- package/dist/utils/bytes.d.ts +0 -4
- package/dist/utils/bytes.d.ts.map +0 -1
- package/dist/utils/bytes.js +0 -66
- package/dist/utils/bytes.js.map +0 -1
- package/dist/utils/compression.d.ts +0 -22
- package/dist/utils/compression.d.ts.map +0 -1
- package/dist/utils/compression.js +0 -129
- package/dist/utils/compression.js.map +0 -1
- package/dist/utils/crypto.d.ts +0 -13
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/crypto.js +0 -107
- package/dist/utils/crypto.js.map +0 -1
- package/dist/utils/id.d.ts +0 -3
- package/dist/utils/id.d.ts.map +0 -1
- package/dist/utils/id.js +0 -25
- package/dist/utils/id.js.map +0 -1
- package/dist/utils/index.d.ts +0 -10
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -10
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/internal-runtime.d.ts +0 -16
- package/dist/utils/internal-runtime.d.ts.map +0 -1
- package/dist/utils/internal-runtime.js +0 -14
- package/dist/utils/internal-runtime.js.map +0 -1
- package/dist/utils/object.d.ts +0 -2
- package/dist/utils/object.d.ts.map +0 -1
- package/dist/utils/object.js +0 -4
- package/dist/utils/object.js.map +0 -1
- package/dist/utils/realtime-change-index.d.ts +0 -9
- package/dist/utils/realtime-change-index.d.ts.map +0 -1
- package/dist/utils/realtime-change-index.js +0 -36
- package/dist/utils/realtime-change-index.js.map +0 -1
- package/dist/utils/realtime-connection-registry.d.ts +0 -40
- package/dist/utils/realtime-connection-registry.d.ts.map +0 -1
- package/dist/utils/realtime-connection-registry.js +0 -237
- package/dist/utils/realtime-connection-registry.js.map +0 -1
- package/dist/utils/table-registry.d.ts +0 -10
- package/dist/utils/table-registry.d.ts.map +0 -1
- package/dist/utils/table-registry.js +0 -54
- package/dist/utils/table-registry.js.map +0 -1
- package/dist/utils/url.d.ts +0 -3
- package/dist/utils/url.d.ts.map +0 -1
- package/dist/utils/url.js +0 -20
- package/dist/utils/url.js.map +0 -1
- package/src/blobs.ts +0 -219
- package/src/column-codecs.ts +0 -262
- package/src/conflict.ts +0 -92
- package/src/database.ts +0 -21
- package/src/dialect.ts +0 -8
- package/src/error-responses.ts +0 -423
- package/src/http/api-client.ts +0 -39
- package/src/http/blob.ts +0 -95
- package/src/http/generated/api.ts +0 -5241
- package/src/http/index.ts +0 -365
- package/src/http/shared.ts +0 -220
- package/src/http/transport-client.ts +0 -314
- package/src/kysely-column-codecs.ts +0 -585
- package/src/logger.ts +0 -38
- package/src/proxy/index.ts +0 -57
- package/src/schemas/blobs.ts +0 -110
- package/src/schemas/common.ts +0 -89
- package/src/schemas/index.ts +0 -7
- package/src/schemas/sync.ts +0 -517
- package/src/scopes/index.ts +0 -237
- package/src/sentry.ts +0 -200
- package/src/snapshot-chunks.ts +0 -964
- package/src/sync-packs.ts +0 -1096
- package/src/telemetry.ts +0 -243
- package/src/transforms.ts +0 -256
- package/src/types.ts +0 -267
- package/src/utils/bytes.ts +0 -75
- package/src/utils/compression.ts +0 -187
- package/src/utils/crypto.ts +0 -146
- package/src/utils/id.ts +0 -34
- package/src/utils/index.ts +0 -9
- package/src/utils/internal-runtime.ts +0 -39
- package/src/utils/object.ts +0 -3
- package/src/utils/realtime-change-index.ts +0 -44
- package/src/utils/realtime-connection-registry.ts +0 -286
- package/src/utils/table-registry.ts +0 -67
- package/src/utils/url.ts +0 -29
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SyncAuthErrorContext,
|
|
3
|
-
SyncAuthLifecycle,
|
|
4
|
-
SyncCombinedRequest,
|
|
5
|
-
SyncCombinedResponse,
|
|
6
|
-
} from '@syncular/core';
|
|
7
|
-
import {
|
|
8
|
-
decodeBinarySyncPack,
|
|
9
|
-
isBinarySyncPackContentType,
|
|
10
|
-
} from '@syncular/core';
|
|
11
|
-
import type { SyncClient } from './api-client';
|
|
12
|
-
import {
|
|
13
|
-
type ApiResult,
|
|
14
|
-
type ClientOptions,
|
|
15
|
-
encodeSnapshotScopes,
|
|
16
|
-
type ResolveAuthRetry,
|
|
17
|
-
resolveRequestUrl,
|
|
18
|
-
SNAPSHOT_SCOPES_HEADER,
|
|
19
|
-
} from './shared';
|
|
20
|
-
|
|
21
|
-
export type { ClientOptions };
|
|
22
|
-
|
|
23
|
-
export const HTTP_TRANSPORT_SOURCE = Symbol.for('@syncular/core/http/source');
|
|
24
|
-
|
|
25
|
-
export type HttpTransportSource = SyncClient | ClientOptions;
|
|
26
|
-
|
|
27
|
-
function isApiClientLike(value: unknown): value is SyncClient {
|
|
28
|
-
return (
|
|
29
|
-
typeof value === 'object' &&
|
|
30
|
-
value !== null &&
|
|
31
|
-
typeof (value as SyncClient).GET === 'function' &&
|
|
32
|
-
typeof (value as SyncClient).POST === 'function'
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface TransportApiClient {
|
|
37
|
-
sync(
|
|
38
|
-
request: SyncCombinedRequest,
|
|
39
|
-
signal?: AbortSignal
|
|
40
|
-
): Promise<ApiResult<SyncCombinedResponse>>;
|
|
41
|
-
initiateUpload(
|
|
42
|
-
args: { hash: string; size: number; mimeType: string },
|
|
43
|
-
signal?: AbortSignal
|
|
44
|
-
): Promise<
|
|
45
|
-
ApiResult<{
|
|
46
|
-
exists: boolean;
|
|
47
|
-
uploadUrl?: string;
|
|
48
|
-
uploadMethod?: 'PUT' | 'POST';
|
|
49
|
-
uploadHeaders?: Record<string, string>;
|
|
50
|
-
}>
|
|
51
|
-
>;
|
|
52
|
-
completeUpload(
|
|
53
|
-
hash: string,
|
|
54
|
-
signal?: AbortSignal
|
|
55
|
-
): Promise<ApiResult<{ ok: boolean; error?: string }>>;
|
|
56
|
-
getDownloadUrl(
|
|
57
|
-
hash: string,
|
|
58
|
-
signal?: AbortSignal
|
|
59
|
-
): Promise<ApiResult<{ url: string; expiresAt: string }>>;
|
|
60
|
-
getSnapshotChunk(
|
|
61
|
-
chunkId: string,
|
|
62
|
-
scopeValues: Record<string, string | string[]> | undefined,
|
|
63
|
-
signal?: AbortSignal
|
|
64
|
-
): Promise<ApiResult<Blob>>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function isJsonContentType(contentType: string | null): boolean {
|
|
68
|
-
return contentType?.includes('application/json') === true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function parseErrorBody(response: Response): Promise<unknown> {
|
|
72
|
-
if (!isJsonContentType(response.headers.get('content-type'))) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
return (await response.json()) as unknown;
|
|
77
|
-
} catch {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function parseJsonBody<T>(response: Response): Promise<T | undefined> {
|
|
83
|
-
if (!isJsonContentType(response.headers.get('content-type'))) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
return (await response.json()) as T;
|
|
88
|
-
} catch {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function createAuthRetryResolver(
|
|
94
|
-
defaultAuthLifecycle: SyncAuthLifecycle | undefined
|
|
95
|
-
): ResolveAuthRetry {
|
|
96
|
-
let refreshInFlight: Promise<boolean> | null = null;
|
|
97
|
-
|
|
98
|
-
const runRefreshSingleFlight = async (
|
|
99
|
-
lifecycle: SyncAuthLifecycle,
|
|
100
|
-
context: SyncAuthErrorContext
|
|
101
|
-
): Promise<boolean> => {
|
|
102
|
-
if (!lifecycle.refreshToken) return false;
|
|
103
|
-
|
|
104
|
-
if (!refreshInFlight) {
|
|
105
|
-
refreshInFlight = Promise.resolve(lifecycle.refreshToken(context))
|
|
106
|
-
.then((result) => Boolean(result))
|
|
107
|
-
.finally(() => {
|
|
108
|
-
refreshInFlight = null;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return refreshInFlight;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
return async (context, options) => {
|
|
116
|
-
const lifecycle = options?.authLifecycle ?? defaultAuthLifecycle;
|
|
117
|
-
if (!lifecycle) return false;
|
|
118
|
-
|
|
119
|
-
await lifecycle.onAuthExpired?.(context);
|
|
120
|
-
|
|
121
|
-
const refreshResult = await runRefreshSingleFlight(lifecycle, context);
|
|
122
|
-
if (lifecycle.retryWithFreshToken) {
|
|
123
|
-
return Boolean(
|
|
124
|
-
await lifecycle.retryWithFreshToken({ ...context, refreshResult })
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
return refreshResult;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function createRequestHeaders(
|
|
132
|
-
baseOptions: ClientOptions,
|
|
133
|
-
extraHeaders?: Record<string, string>
|
|
134
|
-
): Promise<Headers> {
|
|
135
|
-
return Promise.resolve(baseOptions.getHeaders?.()).then((dynamicHeaders) => {
|
|
136
|
-
const headers = new Headers(extraHeaders);
|
|
137
|
-
if (dynamicHeaders) {
|
|
138
|
-
for (const [key, value] of Object.entries(dynamicHeaders)) {
|
|
139
|
-
headers.set(key, value);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (!headers.has('x-syncular-transport-path')) {
|
|
143
|
-
headers.set(
|
|
144
|
-
'x-syncular-transport-path',
|
|
145
|
-
baseOptions.transportPath ?? 'direct'
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
return headers;
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function createFetchApiClient(baseOptions: ClientOptions): TransportApiClient {
|
|
153
|
-
const fetchImpl = baseOptions.fetch ?? globalThis.fetch;
|
|
154
|
-
|
|
155
|
-
const request = async <T>(args: {
|
|
156
|
-
method: 'GET' | 'POST';
|
|
157
|
-
path: string;
|
|
158
|
-
body?: unknown;
|
|
159
|
-
headers?: Record<string, string>;
|
|
160
|
-
signal?: AbortSignal;
|
|
161
|
-
parseAs?: 'json' | 'blob';
|
|
162
|
-
}): Promise<ApiResult<T>> => {
|
|
163
|
-
const headers = await createRequestHeaders(baseOptions, args.headers);
|
|
164
|
-
let body: BodyInit | undefined;
|
|
165
|
-
if (args.body !== undefined) {
|
|
166
|
-
headers.set('content-type', 'application/json');
|
|
167
|
-
body = JSON.stringify(args.body);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const response = await fetchImpl(
|
|
171
|
-
resolveRequestUrl(baseOptions.baseUrl, args.path),
|
|
172
|
-
{
|
|
173
|
-
method: args.method,
|
|
174
|
-
headers,
|
|
175
|
-
body,
|
|
176
|
-
...(args.signal ? { signal: args.signal } : {}),
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
if (!response.ok) {
|
|
181
|
-
return {
|
|
182
|
-
response,
|
|
183
|
-
error: await parseErrorBody(response),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (args.parseAs === 'blob') {
|
|
188
|
-
return {
|
|
189
|
-
response,
|
|
190
|
-
data: (await response.blob()) as T,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (isBinarySyncPackContentType(response.headers.get('content-type'))) {
|
|
195
|
-
return {
|
|
196
|
-
response,
|
|
197
|
-
data: decodeBinarySyncPack(
|
|
198
|
-
new Uint8Array(await response.arrayBuffer())
|
|
199
|
-
) as T,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
response,
|
|
205
|
-
data: await parseJsonBody<T>(response),
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
sync: (requestBody, signal) =>
|
|
211
|
-
request({
|
|
212
|
-
method: 'POST',
|
|
213
|
-
path: '/sync',
|
|
214
|
-
body: requestBody,
|
|
215
|
-
signal,
|
|
216
|
-
}),
|
|
217
|
-
initiateUpload: (args, signal) =>
|
|
218
|
-
request({
|
|
219
|
-
method: 'POST',
|
|
220
|
-
path: '/sync/blobs/upload',
|
|
221
|
-
body: args,
|
|
222
|
-
signal,
|
|
223
|
-
}),
|
|
224
|
-
completeUpload: (hash, signal) =>
|
|
225
|
-
request({
|
|
226
|
-
method: 'POST',
|
|
227
|
-
path: `/sync/blobs/${encodeURIComponent(hash)}/complete`,
|
|
228
|
-
signal,
|
|
229
|
-
}),
|
|
230
|
-
getDownloadUrl: (hash, signal) =>
|
|
231
|
-
request({
|
|
232
|
-
method: 'GET',
|
|
233
|
-
path: `/sync/blobs/${encodeURIComponent(hash)}/url`,
|
|
234
|
-
signal,
|
|
235
|
-
}),
|
|
236
|
-
getSnapshotChunk: (chunkId, scopeValues, signal) =>
|
|
237
|
-
request({
|
|
238
|
-
method: 'GET',
|
|
239
|
-
path: `/sync/snapshot-chunks/${encodeURIComponent(chunkId)}`,
|
|
240
|
-
headers: (() => {
|
|
241
|
-
const encodedScopes = encodeSnapshotScopes(scopeValues);
|
|
242
|
-
return encodedScopes
|
|
243
|
-
? {
|
|
244
|
-
[SNAPSHOT_SCOPES_HEADER]: encodedScopes,
|
|
245
|
-
}
|
|
246
|
-
: undefined;
|
|
247
|
-
})(),
|
|
248
|
-
signal,
|
|
249
|
-
parseAs: 'blob',
|
|
250
|
-
}),
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function createTypedTransportClient(client: SyncClient): TransportApiClient {
|
|
255
|
-
return {
|
|
256
|
-
sync: (request, signal) =>
|
|
257
|
-
client.POST('/sync', {
|
|
258
|
-
body: request,
|
|
259
|
-
...(signal ? { signal } : {}),
|
|
260
|
-
}) as Promise<ApiResult<SyncCombinedResponse>>,
|
|
261
|
-
initiateUpload: (args, signal) =>
|
|
262
|
-
client.POST('/sync/blobs/upload', {
|
|
263
|
-
body: args,
|
|
264
|
-
...(signal ? { signal } : {}),
|
|
265
|
-
}) as Promise<
|
|
266
|
-
ApiResult<{
|
|
267
|
-
exists: boolean;
|
|
268
|
-
uploadUrl?: string;
|
|
269
|
-
uploadMethod?: 'PUT' | 'POST';
|
|
270
|
-
uploadHeaders?: Record<string, string>;
|
|
271
|
-
}>
|
|
272
|
-
>,
|
|
273
|
-
completeUpload: (hash, signal) =>
|
|
274
|
-
client.POST('/sync/blobs/{hash}/complete', {
|
|
275
|
-
params: { path: { hash } },
|
|
276
|
-
...(signal ? { signal } : {}),
|
|
277
|
-
}) as Promise<ApiResult<{ ok: boolean; error?: string }>>,
|
|
278
|
-
getDownloadUrl: (hash, signal) =>
|
|
279
|
-
client.GET('/sync/blobs/{hash}/url', {
|
|
280
|
-
params: { path: { hash } },
|
|
281
|
-
...(signal ? { signal } : {}),
|
|
282
|
-
}) as Promise<ApiResult<{ url: string; expiresAt: string }>>,
|
|
283
|
-
getSnapshotChunk: (chunkId, scopeValues, signal) =>
|
|
284
|
-
client.GET('/sync/snapshot-chunks/{chunkId}', {
|
|
285
|
-
params: { path: { chunkId } },
|
|
286
|
-
parseAs: 'blob',
|
|
287
|
-
headers: (() => {
|
|
288
|
-
const encodedScopes = encodeSnapshotScopes(scopeValues);
|
|
289
|
-
return encodedScopes
|
|
290
|
-
? {
|
|
291
|
-
[SNAPSHOT_SCOPES_HEADER]: encodedScopes,
|
|
292
|
-
}
|
|
293
|
-
: undefined;
|
|
294
|
-
})(),
|
|
295
|
-
...(signal ? { signal } : {}),
|
|
296
|
-
}) as Promise<ApiResult<Blob>>,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export function createTransportApiClient(
|
|
301
|
-
source: HttpTransportSource
|
|
302
|
-
): TransportApiClient {
|
|
303
|
-
return isApiClientLike(source)
|
|
304
|
-
? createTypedTransportClient(source)
|
|
305
|
-
: createFetchApiClient(source);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export function createTransportAuthRetryResolver(
|
|
309
|
-
source: HttpTransportSource
|
|
310
|
-
): ResolveAuthRetry {
|
|
311
|
-
return createAuthRetryResolver(
|
|
312
|
-
isApiClientLike(source) ? undefined : source.authLifecycle
|
|
313
|
-
);
|
|
314
|
-
}
|