react-native-cloud-sync 0.2.0 → 0.4.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.
Files changed (55) hide show
  1. package/README.md +120 -80
  2. package/lib/commonjs/config.js +11 -1
  3. package/lib/commonjs/config.js.map +1 -1
  4. package/lib/commonjs/hooks.js +242 -0
  5. package/lib/commonjs/hooks.js.map +1 -1
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/internal/cloudKitRest.js +205 -21
  8. package/lib/commonjs/internal/cloudKitRest.js.map +1 -1
  9. package/lib/commonjs/internal/googleDriveRest.js +173 -38
  10. package/lib/commonjs/internal/googleDriveRest.js.map +1 -1
  11. package/lib/commonjs/providers/cloudKit.js +89 -19
  12. package/lib/commonjs/providers/cloudKit.js.map +1 -1
  13. package/lib/module/config.js +10 -1
  14. package/lib/module/config.js.map +1 -1
  15. package/lib/module/hooks.js +240 -0
  16. package/lib/module/hooks.js.map +1 -1
  17. package/lib/module/index.js +2 -2
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/internal/cloudKitRest.js +205 -21
  20. package/lib/module/internal/cloudKitRest.js.map +1 -1
  21. package/lib/module/internal/googleDriveRest.js +174 -39
  22. package/lib/module/internal/googleDriveRest.js.map +1 -1
  23. package/lib/module/providers/cloudKit.js +92 -22
  24. package/lib/module/providers/cloudKit.js.map +1 -1
  25. package/lib/typescript/commonjs/config.d.ts +8 -0
  26. package/lib/typescript/commonjs/config.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/hooks.d.ts +68 -0
  28. package/lib/typescript/commonjs/hooks.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/index.d.ts +3 -3
  30. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/internal/cloudKitRest.d.ts +90 -0
  32. package/lib/typescript/commonjs/internal/cloudKitRest.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/internal/googleDriveRest.d.ts +73 -8
  34. package/lib/typescript/commonjs/internal/googleDriveRest.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/providers/cloudKit.d.ts +32 -13
  36. package/lib/typescript/commonjs/providers/cloudKit.d.ts.map +1 -1
  37. package/lib/typescript/module/config.d.ts +8 -0
  38. package/lib/typescript/module/config.d.ts.map +1 -1
  39. package/lib/typescript/module/hooks.d.ts +68 -0
  40. package/lib/typescript/module/hooks.d.ts.map +1 -1
  41. package/lib/typescript/module/index.d.ts +3 -3
  42. package/lib/typescript/module/index.d.ts.map +1 -1
  43. package/lib/typescript/module/internal/cloudKitRest.d.ts +90 -0
  44. package/lib/typescript/module/internal/cloudKitRest.d.ts.map +1 -1
  45. package/lib/typescript/module/internal/googleDriveRest.d.ts +73 -8
  46. package/lib/typescript/module/internal/googleDriveRest.d.ts.map +1 -1
  47. package/lib/typescript/module/providers/cloudKit.d.ts +32 -13
  48. package/lib/typescript/module/providers/cloudKit.d.ts.map +1 -1
  49. package/package.json +5 -2
  50. package/src/config.ts +12 -2
  51. package/src/hooks.ts +294 -0
  52. package/src/index.ts +5 -3
  53. package/src/internal/cloudKitRest.ts +272 -29
  54. package/src/internal/googleDriveRest.ts +196 -42
  55. package/src/providers/cloudKit.ts +138 -41
@@ -3,8 +3,11 @@ import { type AbortLike } from './timeout';
3
3
  * Google Drive `appDataFolder` REST client.
4
4
  *
5
5
  * `appDataFolder` is a hidden per-app, per-Google-account folder: nothing shows
6
- * up in the user's visible Drive, and the data survives an app uninstall because
7
- * it is tied to the account rather than the install.
6
+ * up in the user's visible Drive, and the data is tied to the Google account
7
+ * rather than the device or install, so reinstalling the app or switching
8
+ * devices doesn't lose it. It goes away only if the user disconnects the app
9
+ * from their Drive account or deletes the data folder directly - Google
10
+ * documents both as the ways this folder is actually removed.
8
11
  *
9
12
  * Auth is deliberately injected rather than owned. The library does not depend
10
13
  * on `@react-native-google-signin/google-signin` (or any other sign-in library),
@@ -52,6 +55,37 @@ export interface GoogleDriveConfig {
52
55
  * its own, so without this a dead socket hangs the transfer forever.
53
56
  */
54
57
  timeoutMs?: number;
58
+ /**
59
+ * Persists `uploadFile`'s resumable-session URI across process restarts.
60
+ *
61
+ * Without this, the session lives only in memory: a process killed mid-upload
62
+ * loses it, and the next `uploadFile` for the same name starts over from byte
63
+ * 0 even though Drive still has the bytes already accepted. With it, the next
64
+ * call finds the persisted session, asks Drive for the real offset, and
65
+ * resumes from there instead.
66
+ *
67
+ * A tiny JSON record, not file I/O - back it with AsyncStorage, MMKV, or a
68
+ * single row in whatever the host app already uses. Optional; omitting it
69
+ * keeps today's in-memory-only behaviour.
70
+ */
71
+ sessionStore?: GoogleDriveSessionStore;
72
+ }
73
+ /** What `uploadFile` needs to resume a resumable-upload session later. */
74
+ export interface GoogleDriveUploadSession {
75
+ sessionUrl: string;
76
+ /** The source size the session was started against - resuming into a file
77
+ * that has since changed size would corrupt it, so a mismatch is treated
78
+ * as "start fresh" rather than resumed. */
79
+ size: number;
80
+ }
81
+ /**
82
+ * Host-supplied persistence for in-flight `uploadFile` sessions, keyed by the
83
+ * Drive file name. See {@link GoogleDriveConfig.sessionStore}.
84
+ */
85
+ export interface GoogleDriveSessionStore {
86
+ get: (name: string) => Promise<GoogleDriveUploadSession | null>;
87
+ set: (name: string, session: GoogleDriveUploadSession) => Promise<void>;
88
+ remove: (name: string) => Promise<void>;
55
89
  }
56
90
  /** A local file `uploadFile` reads from, in fixed-size pieces. */
57
91
  export interface DriveChunkSource {
@@ -114,6 +148,14 @@ export declare class GoogleDriveClient {
114
148
  * caller inspects the response itself rather than getting a thrown rejection.
115
149
  */
116
150
  private request;
151
+ /**
152
+ * Best-effort read of Drive's `error.errors[0].reason` from a failed
153
+ * response body - the only way a 403 status distinguishes an invalid token
154
+ * from quota-exceeded from a rate limit. Returns undefined for a body that
155
+ * is missing, unparseable, or doesn't carry the shape Drive documents,
156
+ * rather than throwing a second error while already handling one.
157
+ */
158
+ private driveErrorReason;
117
159
  /**
118
160
  * Resolves a file name to its id within appDataFolder, or null if absent.
119
161
  *
@@ -171,18 +213,41 @@ export declare class GoogleDriveClient {
171
213
  * how many bytes it actually has and resuming from there - rather than
172
214
  * restarting the transfer.
173
215
  *
174
- * That resumability is scoped to this call: the session lives only in
175
- * memory, so if the process dies mid-upload, the next call to `uploadFile`
176
- * starts a fresh session from byte 0. Persisting the session URI so a
177
- * restart can resume it too is future scope, not something callers should
178
- * assume works today.
216
+ * That resumability spans a process restart too, when {@link
217
+ * GoogleDriveConfig.sessionStore} is configured: the session URI is persisted
218
+ * before the first chunk goes out, and a later `uploadFile` for the same name
219
+ * finds it, asks Drive for the real offset, and resumes from there instead of
220
+ * byte 0. Without a `sessionStore`, the session lives only in memory, exactly
221
+ * as before - a process that dies mid-upload loses it, and the next call
222
+ * starts fresh.
179
223
  */
180
224
  uploadFile(name: string, source: DriveChunkSource, onProgress?: (bytesTransferred: number, bytesTotal: number) => void, signal?: AbortLike): Promise<void>;
225
+ /**
226
+ * Finds an existing session to resume, or starts a new one.
227
+ *
228
+ * A persisted session is trusted only when its recorded size still matches
229
+ * `total` - resuming a byte-range PUT into a file that has since changed
230
+ * would corrupt it, so a mismatch is treated the same as no session at all.
231
+ * A persisted session Drive no longer recognises (expired, or the upload id
232
+ * was never valid) is also treated as absent: `queryUploadOffset` failing is
233
+ * the signal, since there is no cheaper way to ask than trying to use it.
234
+ */
235
+ private resumeOrStartSession;
181
236
  private startResumableSession;
182
237
  /** One chunk, with a single retry that re-queries the server's real offset first. */
183
238
  private putChunkWithRetry;
184
239
  private putChunk;
185
- /** Asks Drive how much of an in-flight resumable session it actually has. */
240
+ /**
241
+ * Asks Drive how much of an in-flight resumable session it actually has, or
242
+ * discovers the upload was already complete server-side - the completing
243
+ * chunk's own response can be lost the same way any other one can, and this
244
+ * status check gets the same completion response back in that case,
245
+ * `id` included.
246
+ *
247
+ * Throws (via `request`) when `sessionUrl` is not a session Drive
248
+ * recognises any more - expired, or never valid. Callers treat that as the
249
+ * signal to stop trusting it, since there is no cheaper way to ask.
250
+ */
186
251
  private queryUploadOffset;
187
252
  /**
188
253
  * Downloads `name` into `sink`, in the same fixed-size chunks `uploadFile`
@@ -1 +1 @@
1
- {"version":3,"file":"googleDriveRest.d.ts","sourceRoot":"","sources":["../../../../src/internal/googleDriveRest.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,WAAW,CAAA;AAEvE;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5D,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC1C,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACxB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IACpC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AASD,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CAC7D;AAED,oEAAoE;AACpE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACnE;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,sBAAsB;IACrC,gDAAgD;IAChD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1C,gGAAgG;IAChG,SAAS,EAAE,CAAC,GAAG,EAAE,M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AaG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAuDrF,2DAA2D;IAC3D,OAAO,CAAC,UAAU;IASlB;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IASlC,6DAA6D;IAC7D,UAAU,IAAI,IAAI;CAInB"}
@@ -26,11 +26,13 @@ export declare const zones: {
26
26
  /**
27
27
  * Binary assets (`CKAsset`).
28
28
  *
29
- * Native only. CloudKit Web Services does expose an asset upload flow, but it
30
- * is a separate multi-step protocol (request an upload URL, POST the bytes,
31
- * then reference the returned token in a record) that this package does not
32
- * implement yet - so on Android and web these reject with
33
- * `ERR_UNSUPPORTED_PLATFORM` rather than appearing to work.
29
+ * Native on iOS/macOS. On Android and web, `save`/`fetch` go through CloudKit
30
+ * Web Services' own asset-upload protocol (request a single-use upload URL,
31
+ * POST the bytes, attach the returned descriptor to the record) - see
32
+ * {@link MAX_ASSET_UPLOAD_BYTES} for the one hard limit that comes with it.
33
+ * Custom zones and the native temporary-directory fallback remain native-only
34
+ * (`ERR_UNSUPPORTED_PLATFORM`), since the REST client has no equivalent of
35
+ * either.
34
36
  *
35
37
  * Assets are deliberately an explicit API rather than something the store
36
38
  * facade routes to automatically: the caller passes a file path, not a string,
@@ -40,9 +42,12 @@ export declare const assets: {
40
42
  /**
41
43
  * Uploads a local file as a field on a record.
42
44
  *
43
- * Progress is reported per record through {@link onProgress}; a CKAsset is
44
- * streamed from disk, so a large file does not have to be held in memory the
45
- * way a base64 round trip would.
45
+ * Progress is reported per record through {@link onProgress}. Natively, a
46
+ * `CKAsset` is streamed from disk so a large file never has to be held in
47
+ * memory; over REST the whole file is read once, which is fine given
48
+ * {@link MAX_ASSET_UPLOAD_BYTES} - CloudKit Web Services itself caps a
49
+ * single asset upload at 15 MB, so nothing this package could stream would
50
+ * ever be large enough to need it.
46
51
  */
47
52
  save: (options: {
48
53
  recordName: string;
@@ -57,10 +62,12 @@ export declare const assets: {
57
62
  * record or field does not exist.
58
63
  *
59
64
  * Pass `destinationUri` for anything the user is going to keep or hand to a
60
- * share sheet. Without it the file lands in the app's temporary directory
61
- * under a name derived from the record, and iOS may reclaim that at any
62
- * time - fine for restoring straight back into the app, wrong for an export.
63
- * Parent directories are created if they do not exist.
65
+ * share sheet. Natively, without it the file lands in the app's temporary
66
+ * directory under a name derived from the record, and iOS may reclaim that
67
+ * at any time - fine for restoring straight back into the app, wrong for an
68
+ * export. Parent directories are created if they do not exist. Over REST,
69
+ * `destinationUri` is required: there is no OS-managed temporary directory
70
+ * this package can fall back to without a native module.
64
71
  */
65
72
  fetch: (options: {
66
73
  recordName: string;
@@ -75,12 +82,24 @@ export declare const assets: {
75
82
  * Identified by record and field rather than by a handle, because that is
76
83
  * what identifies a transfer everywhere else in this API - `onProgress`
77
84
  * reports the same pair, so a UI already has it.
85
+ *
86
+ * Native only, still - the REST transfer has no in-flight handle to cancel
87
+ * yet. Resolves `false` on Android/web rather than throwing, the same as
88
+ * before, so this is a known gap rather than a broken promise: a REST
89
+ * `save`/`fetch` cannot currently be stopped once started.
78
90
  */
79
91
  cancel: (options: {
80
92
  recordName: string;
81
93
  fieldName: string;
82
94
  }) => Promise<boolean>;
83
- /** Upload/download progress for asset transfers. Native only. */
95
+ /**
96
+ * Upload/download progress for asset transfers.
97
+ *
98
+ * Native on iOS/macOS, bridged from the same event every transfer already
99
+ * reports. On Android/web there is no native module to bridge, so this
100
+ * subscribes to the in-JS feed the REST `save`/`fetch` path publishes into
101
+ * instead - same event shape either way.
102
+ */
84
103
  onProgress: (listener: (e: AssetProgressEvent) => void) => Unsubscribe;
85
104
  };
86
105
  //# sourceMappingURL=cloudKit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudKit.d.ts","sourceRoot":"","sources":["../../../../src/providers/cloudKit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,K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KACjD,OAAO,CAAC,OAAO,CAAC;IAUnB;;;;;;;OAOG;2BACoB,CAAC,CAAC,EAAE,kBAAkB,KAAK,IAAI,KAAG,WAAW;CAkBrE,CAAA"}
@@ -27,6 +27,14 @@ export declare function isGoogleDriveConfigured(): boolean;
27
27
  */
28
28
  export declare function configureGoogleDriveFiles(adapter: GoogleDriveFileAdapter): void;
29
29
  export declare function getGoogleDriveFileAdapter(): GoogleDriveFileAdapter;
30
+ /**
31
+ * Same adapter and same `configureGoogleDriveFiles` call, under a name that
32
+ * doesn't imply it's Drive-specific. `cloudKitAssets`'s REST path (Android/web)
33
+ * reads and writes local files the exact same way `googleDriveFiles` does, and
34
+ * asking a host app to register two near-identical adapters for that would be
35
+ * pure friction for no benefit.
36
+ */
37
+ export declare const getSharedFileAdapter: typeof getGoogleDriveFileAdapter;
30
38
  export declare function isGoogleDriveFilesConfigured(): boolean;
31
39
  /** Test seam - drops all configured clients. */
32
40
  export declare function __resetConfig(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAAyB,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,+BAA4B,CAAA;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA4B,CAAA;AAO9D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAElE;AAED,wBAAgB,iBAAiB,IAAI,kBAAkB,CAWtD;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAEpE;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAUxD;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAE/E;AAED,wBAAgB,yBAAyB,IAAI,sBAAsB,CAUlE;AAED,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAED,gDAAgD;AAChD,wBAAgB,aAAa,IAAI,IAAI,CAIpC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAAyB,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,+BAA4B,CAAA;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA4B,CAAA;AAO9D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAElE;AAED,wBAAgB,iBAAiB,IAAI,kBAAkB,CAWtD;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAEpE;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAUxD;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAE/E;AAED,wBAAgB,yBAAyB,IAAI,sBAAsB,CAWlE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,kCAA4B,CAAA;AAE7D,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAED,gDAAgD;AAChD,wBAAgB,aAAa,IAAI,IAAI,CAIpC"}
@@ -52,6 +52,74 @@ export interface UseCloudItemOptions<T> {
52
52
  * ```
53
53
  */
54
54
  export declare function useCloudItem<T = unknown>(store: CloudStore, key: string, options?: UseCloudItemOptions<T>): UseCloudItemResult<T>;
55
+ export interface UseCloudItemsResult<T> {
56
+ /**
57
+ * Parsed value per key. A key mapped to `null` was fetched and does not
58
+ * exist; a key absent from this object has not been fetched yet.
59
+ */
60
+ values: Record<string, T | null>;
61
+ /** True only during the initial fetch of `keys`, and during an explicit `refresh()`. */
62
+ loading: boolean;
63
+ /** The last read or write failure, or null. Cleared by the next success. */
64
+ error: CloudSyncError | null;
65
+ /** Writes through to the store and updates local state optimistically. */
66
+ setValue: (key: string, next: T) => Promise<void>;
67
+ remove: (key: string) => Promise<void>;
68
+ /** Re-fetches every key currently tracked. */
69
+ refresh: () => Promise<void>;
70
+ }
71
+ export interface UseCloudItemsOptions<T> {
72
+ parse?: (raw: string) => T;
73
+ serialize?: (value: T) => string;
74
+ /**
75
+ * Re-fetch a key when another device changes it. Default true.
76
+ *
77
+ * An event naming no keys (an account or quota event) re-fetches every
78
+ * tracked key, same as `useCloudItem`.
79
+ */
80
+ watch?: boolean;
81
+ }
82
+ /**
83
+ * Binds a list of keys to component state with one batched `multiGet`.
84
+ *
85
+ * The multi-key sibling of `useCloudItem` - a screen with many cloud-backed
86
+ * records (a list, one key per item) otherwise ends up calling `useCloudItem`
87
+ * once per row: one `getItem` and one `onRemoteChange` subscription each,
88
+ * instead of a single batched read.
89
+ *
90
+ * Only ever fetches keys it does not already hold an answer for. Mount,
91
+ * `refresh()`, and a matching remote-change event all fetch normally, but a
92
+ * key merely joining the tracked list - because a caller like
93
+ * `useCloudCollection` just added it after a local write - is never
94
+ * re-fetched on that account alone, so a slow fetch elsewhere in the list
95
+ * can't land a stale value on top of a write that already resolved locally.
96
+ *
97
+ * ```tsx
98
+ * const { values, setValue } = useCloudItems<Note>(store, noteIds)
99
+ * ```
100
+ */
101
+ export declare function useCloudItems<T = unknown>(store: CloudStore, keys: string[], options?: UseCloudItemsOptions<T>): UseCloudItemsResult<T>;
102
+ export interface UseCloudCollectionResult<T> extends UseCloudItemsResult<T> {
103
+ /** Keys currently in the collection. */
104
+ keys: string[];
105
+ }
106
+ /**
107
+ * Live-binds every key starting with `prefix` to component state.
108
+ *
109
+ * Adds the membership index `useCloudItems` needs but does not derive
110
+ * itself: `getAllKeys()` filtered by prefix on mount and after any remote
111
+ * change that could plausibly have added or removed a member, then
112
+ * `useCloudItems` for the values.
113
+ *
114
+ * A `setValue` for a key not seen before joins the collection immediately -
115
+ * a newly created record should appear in its own list without waiting on a
116
+ * round trip to confirm it.
117
+ *
118
+ * ```tsx
119
+ * const { keys, values, setValue, remove } = useCloudCollection<Note>(store, 'note:')
120
+ * ```
121
+ */
122
+ export declare function useCloudCollection<T = unknown>(store: CloudStore, prefix: string, options?: UseCloudItemsOptions<T>): UseCloudCollectionResult<T>;
55
123
  export interface UseAccountStatusResult {
56
124
  status: AccountStatus | null;
57
125
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAS,CAAA;AACzC,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,aAAU,CAAA;AAC9D,OAAO,KAAK,EAEV,aAAa,EACb,aAAa,EACb,WAAW,EACX,iBAAiB,EAClB,MAAM,YAAS,CAAA;AAEhB;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IACf,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAA;IAChB,4EAA4E;IAC5E,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,+BAA+B;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AAQ,CAAC,KAAK,EAAE,UAAU,GAAG;IAC3C,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B,CAyBA"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * react-native-cloud-sync
3
3
  *
4
- * iCloud key-value store, CloudKit and Google Drive behind one API, on iOS,
5
- * Android and the web, on both React Native architectures.
4
+ * iCloud key-value store, CloudKit, iCloud Drive and Google Drive behind one API,
5
+ * on iOS, Android and the web, on both React Native architectures.
6
6
  */
7
7
  export { icloudKV, getAllItems as icloudKVGetAllItems, sync as icloudKVSync } from './providers/icloudKV';
8
8
  export { cloudKit, createCloudKitProvider, zones as cloudKitZones, assets as cloudKitAssets } from './providers/cloudKit.js';
@@ -24,7 +24,7 @@ export { checkKey, sanitizeKey } from './internal/keys.js';
24
24
  export type { AbortLike } from './internal/timeout.js';
25
25
  export { configureCloudKit, configureGoogleDrive, configureGoogleDriveFiles, isCloudKitConfigured, isGoogleDriveConfigured, isGoogleDriveFilesConfigured } from './config.js';
26
26
  export type { CloudKitRestConfig } from './internal/cloudKitRest.js';
27
- export type { GoogleDriveConfig, GoogleDriveFileAdapter } from './internal/googleDriveRest.js';
27
+ export type { GoogleDriveConfig, GoogleDriveFileAdapter, GoogleDriveSessionStore, GoogleDriveUploadSession } from './internal/googleDriveRest.js';
28
28
  export { base64ToBytes, bytesToBase64 } from './internal/base64.js';
29
29
  export { CloudSyncError, ErrorCode, isCancelled, isCloudSyncError, isRetryable, requiresUserAction } from './errors.js';
30
30
  export type { CloudSyncErrorInfo } from './errors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,QAAQ,EACR,WAAW,IAAI,mBA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BAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,YAAS,CAAA;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAS,CAAA;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAmB,CAAA"}
@@ -42,6 +42,16 @@ export interface CloudKitRestConfig {
42
42
  onAuthExpired?: () => Promise<void> | void;
43
43
  /** Overridable for tests. Defaults to global `fetch`. */
44
44
  fetchImpl?: typeof fetch;
45
+ /**
46
+ * Overridable for tests. Defaults to the global `XMLHttpRequest` constructor.
47
+ *
48
+ * Only used for the raw asset-bytes upload/download - `fetch` in React
49
+ * Native exposes no upload-progress events at all, and `XMLHttpRequest.upload
50
+ * .onprogress` (and its response-side `.onprogress`) are what the per-record
51
+ * progress `cloudKitAssets.onProgress` promises actually needs. Every other
52
+ * request in this client stays on `fetch`.
53
+ */
54
+ xhrImpl?: () => XMLHttpRequest;
45
55
  /**
46
56
  * Abandon a request that has not answered in this long. Default 30000.
47
57
  *
@@ -51,6 +61,29 @@ export interface CloudKitRestConfig {
51
61
  */
52
62
  timeoutMs?: number;
53
63
  }
64
+ /**
65
+ * CloudKit Web Services' own ceiling on a single asset upload, undocumented
66
+ * anywhere except the upload endpoint's own reference page: 15 MB, and the
67
+ * upload URL it hands out is valid for 15 minutes. Native `CKAsset` has no such
68
+ * limit - this is specific to the REST upload-token protocol.
69
+ */
70
+ export declare const MAX_ASSET_UPLOAD_BYTES: number;
71
+ /**
72
+ * The "Asset Dictionary" CloudKit Web Services deals in - what the upload
73
+ * endpoint returns after receiving bytes, and what a fetched record's Asset
74
+ * field value looks like. Passed back verbatim as a record field's value to
75
+ * attach an upload to a record; never reconstructed field-by-field, since it
76
+ * is an opaque blob the server itself validates.
77
+ */
78
+ export interface CloudKitAssetDescriptor {
79
+ fileChecksum: string;
80
+ size: string | number;
81
+ receipt: string;
82
+ referenceChecksum?: string;
83
+ wrappingKey?: string;
84
+ /** Present only when fetching the record that owns this field, not on upload. */
85
+ downloadURL?: string;
86
+ }
54
87
  export declare const RECORD_TYPE_DEFAULT = "KVBlob";
55
88
  export declare const VALUE_FIELD = "value";
56
89
  /** CloudKit's documented per-record ceiling, excluding assets. */
@@ -68,6 +101,13 @@ export declare class CloudKitRestClient {
68
101
  * Codes are from Apple's CloudKit Web Services error reference.
69
102
  */
70
103
  private toError;
104
+ /**
105
+ * HTTP-status classification for a response with no CloudKit error envelope
106
+ * of its own to inspect - `post()`'s fallback tail, and the raw asset-bytes
107
+ * transfer, which talks to an opaque single-use upload/download URL rather
108
+ * than a `/records/...` JSON endpoint.
109
+ */
110
+ private classifyHttpStatus;
71
111
  private post;
72
112
  getRecord(recordName: string, recordType?: string): Promise<string | null>;
73
113
  /**
@@ -109,6 +149,56 @@ export declare class CloudKitRestClient {
109
149
  /** Deletes many records in one request, with the same per-record rules. */
110
150
  deleteRecords(recordNames: string[], recordType?: string): Promise<void>;
111
151
  saveRecord(recordName: string, value: string, recordType?: string): Promise<void>;
152
+ /**
153
+ * Creates `recordName`, falling back to an unconditional update when it
154
+ * already exists - the create-then-fall-back dance every write after the
155
+ * first one takes. Shared by {@link saveRecord} (a `value` field) and
156
+ * {@link uploadAsset} (an Asset field plus its `__size` sidecar), which need
157
+ * the exact same dance for a different field set.
158
+ */
159
+ private saveFields;
160
+ /**
161
+ * Uploads `bytes` as `fieldName` on `recordName`, via CloudKit Web Services'
162
+ * asset-upload protocol: request a single-use upload URL, POST the raw bytes
163
+ * to it, then attach the descriptor it returns (plus a `__size` sidecar, so
164
+ * a later {@link fetchAsset} can report real download progress) to the
165
+ * record - the same create-then-update dance {@link saveRecord} uses.
166
+ *
167
+ * `onProgress` reports real bytes transferred, via `XMLHttpRequest` rather
168
+ * than `fetch` - see {@link CloudKitRestConfig.xhrImpl}.
169
+ */
170
+ uploadAsset(recordName: string, fieldName: string, bytes: Uint8Array, onProgress?: (bytesTransferred: number, bytesTotal: number) => void, recordType?: string): Promise<void>;
171
+ /**
172
+ * Downloads the bytes behind `fieldName` on `recordName`, or `null` when the
173
+ * record or the field's asset does not exist.
174
+ *
175
+ * A fetched record's Asset field carries a `downloadURL` - that is the only
176
+ * step this needs beyond the usual record lookup; there is no separate
177
+ * "request a download token" round trip the way upload has one.
178
+ */
179
+ fetchAsset(recordName: string, fieldName: string, onProgress?: (bytesTransferred: number, bytesTotal: number) => void, recordType?: string): Promise<Uint8Array | null>;
180
+ private requestAssetUploadUrl;
181
+ private get xhr();
182
+ /**
183
+ * POSTs raw bytes to a single-use CKWS asset-upload URL, reporting real
184
+ * upload progress via `XMLHttpRequest.upload.onprogress` - `fetch` exposes no
185
+ * upload-progress events in React Native. Scoped to just this one call:
186
+ * every other CloudKit REST request stays on `fetch` through `post()`, for
187
+ * the timeout/error handling already built there.
188
+ */
189
+ private putAssetBytes;
190
+ /**
191
+ * GETs raw bytes from a record's asset `downloadURL`, reporting real
192
+ * download progress via `XMLHttpRequest.onprogress`, for the same reason
193
+ * {@link putAssetBytes} uses XHR rather than `fetch`.
194
+ *
195
+ * Treated as self-contained, the same way the upload URL is (Apple's own
196
+ * reference issues that one with no `ckAPIToken`/`ckWebAuthToken` at all) -
197
+ * if that assumption is ever wrong for a download URL specifically, it
198
+ * surfaces as an HTTP-level auth failure here rather than a silent wrong
199
+ * answer.
200
+ */
201
+ private fetchAssetBytes;
112
202
  /**
113
203
  * A write that fails instead of clobbering, when the server's copy has moved
114
204
  * on since `recordChangeTag` was read.
@@ -1 +1 @@
1
- {"version":3,"file":"cloudKitRest.d.ts","sourceRoot":"","sources":["../../../../src/internal/cloudKitRest.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,kBAAkB;IAC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GAEd;IAED;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IA8CrB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,eAAe;IAoCvB;;;;;;;;;;;;;;OAcG;IACG,qBAAqB,CACzB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,UAAU,SAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC;IAqCV,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,SAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAejF,gBAAgB,CAAC,UAAU,SAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA8B3E;;;;;;;;OAQG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAoBrC;;;;;OAKG;IACH,UAAU,IAAI,IAAI;CAGnB;AAaD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAS,CAAA"}
@@ -3,8 +3,11 @@ import { type AbortLike } from './timeout.js';
3
3
  * Google Drive `appDataFolder` REST client.
4
4
  *
5
5
  * `appDataFolder` is a hidden per-app, per-Google-account folder: nothing shows
6
- * up in the user's visible Drive, and the data survives an app uninstall because
7
- * it is tied to the account rather than the install.
6
+ * up in the user's visible Drive, and the data is tied to the Google account
7
+ * rather than the device or install, so reinstalling the app or switching
8
+ * devices doesn't lose it. It goes away only if the user disconnects the app
9
+ * from their Drive account or deletes the data folder directly - Google
10
+ * documents both as the ways this folder is actually removed.
8
11
  *
9
12
  * Auth is deliberately injected rather than owned. The library does not depend
10
13
  * on `@react-native-google-signin/google-signin` (or any other sign-in library),
@@ -52,6 +55,37 @@ export interface GoogleDriveConfig {
52
55
  * its own, so without this a dead socket hangs the transfer forever.
53
56
  */
54
57
  timeoutMs?: number;
58
+ /**
59
+ * Persists `uploadFile`'s resumable-session URI across process restarts.
60
+ *
61
+ * Without this, the session lives only in memory: a process killed mid-upload
62
+ * loses it, and the next `uploadFile` for the same name starts over from byte
63
+ * 0 even though Drive still has the bytes already accepted. With it, the next
64
+ * call finds the persisted session, asks Drive for the real offset, and
65
+ * resumes from there instead.
66
+ *
67
+ * A tiny JSON record, not file I/O - back it with AsyncStorage, MMKV, or a
68
+ * single row in whatever the host app already uses. Optional; omitting it
69
+ * keeps today's in-memory-only behaviour.
70
+ */
71
+ sessionStore?: GoogleDriveSessionStore;
72
+ }
73
+ /** What `uploadFile` needs to resume a resumable-upload session later. */
74
+ export interface GoogleDriveUploadSession {
75
+ sessionUrl: string;
76
+ /** The source size the session was started against - resuming into a file
77
+ * that has since changed size would corrupt it, so a mismatch is treated
78
+ * as "start fresh" rather than resumed. */
79
+ size: number;
80
+ }
81
+ /**
82
+ * Host-supplied persistence for in-flight `uploadFile` sessions, keyed by the
83
+ * Drive file name. See {@link GoogleDriveConfig.sessionStore}.
84
+ */
85
+ export interface GoogleDriveSessionStore {
86
+ get: (name: string) => Promise<GoogleDriveUploadSession | null>;
87
+ set: (name: string, session: GoogleDriveUploadSession) => Promise<void>;
88
+ remove: (name: string) => Promise<void>;
55
89
  }
56
90
  /** A local file `uploadFile` reads from, in fixed-size pieces. */
57
91
  export interface DriveChunkSource {
@@ -114,6 +148,14 @@ export declare class GoogleDriveClient {
114
148
  * caller inspects the response itself rather than getting a thrown rejection.
115
149
  */
116
150
  private request;
151
+ /**
152
+ * Best-effort read of Drive's `error.errors[0].reason` from a failed
153
+ * response body - the only way a 403 status distinguishes an invalid token
154
+ * from quota-exceeded from a rate limit. Returns undefined for a body that
155
+ * is missing, unparseable, or doesn't carry the shape Drive documents,
156
+ * rather than throwing a second error while already handling one.
157
+ */
158
+ private driveErrorReason;
117
159
  /**
118
160
  * Resolves a file name to its id within appDataFolder, or null if absent.
119
161
  *
@@ -171,18 +213,41 @@ export declare class GoogleDriveClient {
171
213
  * how many bytes it actually has and resuming from there - rather than
172
214
  * restarting the transfer.
173
215
  *
174
- * That resumability is scoped to this call: the session lives only in
175
- * memory, so if the process dies mid-upload, the next call to `uploadFile`
176
- * starts a fresh session from byte 0. Persisting the session URI so a
177
- * restart can resume it too is future scope, not something callers should
178
- * assume works today.
216
+ * That resumability spans a process restart too, when {@link
217
+ * GoogleDriveConfig.sessionStore} is configured: the session URI is persisted
218
+ * before the first chunk goes out, and a later `uploadFile` for the same name
219
+ * finds it, asks Drive for the real offset, and resumes from there instead of
220
+ * byte 0. Without a `sessionStore`, the session lives only in memory, exactly
221
+ * as before - a process that dies mid-upload loses it, and the next call
222
+ * starts fresh.
179
223
  */
180
224
  uploadFile(name: string, source: DriveChunkSource, onProgress?: (bytesTransferred: number, bytesTotal: number) => void, signal?: AbortLike): Promise<void>;
225
+ /**
226
+ * Finds an existing session to resume, or starts a new one.
227
+ *
228
+ * A persisted session is trusted only when its recorded size still matches
229
+ * `total` - resuming a byte-range PUT into a file that has since changed
230
+ * would corrupt it, so a mismatch is treated the same as no session at all.
231
+ * A persisted session Drive no longer recognises (expired, or the upload id
232
+ * was never valid) is also treated as absent: `queryUploadOffset` failing is
233
+ * the signal, since there is no cheaper way to ask than trying to use it.
234
+ */
235
+ private resumeOrStartSession;
181
236
  private startResumableSession;
182
237
  /** One chunk, with a single retry that re-queries the server's real offset first. */
183
238
  private putChunkWithRetry;
184
239
  private putChunk;
185
- /** Asks Drive how much of an in-flight resumable session it actually has. */
240
+ /**
241
+ * Asks Drive how much of an in-flight resumable session it actually has, or
242
+ * discovers the upload was already complete server-side - the completing
243
+ * chunk's own response can be lost the same way any other one can, and this
244
+ * status check gets the same completion response back in that case,
245
+ * `id` included.
246
+ *
247
+ * Throws (via `request`) when `sessionUrl` is not a session Drive
248
+ * recognises any more - expired, or never valid. Callers treat that as the
249
+ * signal to stop trusting it, since there is no cheaper way to ask.
250
+ */
186
251
  private queryUploadOffset;
187
252
  /**
188
253
  * Downloads `name` into `sink`, in the same fixed-size chunks `uploadFile`
@@ -1 +1 @@
1
- {"version":3,"file":"googleDriveRest.d.ts","sourceRoot":"","sources":["../../../../src/internal/googleDriveRest.ts"],"names":[],"mappings":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