react-native-cloud-storage 1.2.3 → 1.3.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 (43) hide show
  1. package/README.md +66 -10
  2. package/ios/CloudStorage.m +1 -0
  3. package/ios/CloudStorage.swift +46 -0
  4. package/lib/commonjs/RNCloudStorage.js +10 -0
  5. package/lib/commonjs/RNCloudStorage.js.map +1 -1
  6. package/lib/commonjs/createRNCloudStorage.js.map +1 -1
  7. package/lib/commonjs/google-drive/client.js +172 -0
  8. package/lib/commonjs/google-drive/client.js.map +1 -0
  9. package/lib/commonjs/google-drive/index.js +72 -54
  10. package/lib/commonjs/google-drive/index.js.map +1 -1
  11. package/lib/commonjs/google-drive/types.js +15 -0
  12. package/lib/commonjs/google-drive/types.js.map +1 -1
  13. package/lib/commonjs/types/native.js +2 -0
  14. package/lib/commonjs/types/native.js.map +1 -1
  15. package/lib/module/RNCloudStorage.js +14 -4
  16. package/lib/module/RNCloudStorage.js.map +1 -1
  17. package/lib/module/createRNCloudStorage.js +2 -2
  18. package/lib/module/createRNCloudStorage.js.map +1 -1
  19. package/lib/module/google-drive/client.js +164 -0
  20. package/lib/module/google-drive/client.js.map +1 -0
  21. package/lib/module/google-drive/index.js +66 -49
  22. package/lib/module/google-drive/index.js.map +1 -1
  23. package/lib/module/google-drive/types.js +9 -1
  24. package/lib/module/google-drive/types.js.map +1 -1
  25. package/lib/module/types/native.js +2 -0
  26. package/lib/module/types/native.js.map +1 -1
  27. package/lib/typescript/RNCloudStorage.d.ts +12 -2
  28. package/lib/typescript/RNCloudStorage.d.ts.map +1 -1
  29. package/lib/typescript/google-drive/client.d.ts +33 -0
  30. package/lib/typescript/google-drive/client.d.ts.map +1 -0
  31. package/lib/typescript/google-drive/index.d.ts +7 -4
  32. package/lib/typescript/google-drive/index.d.ts.map +1 -1
  33. package/lib/typescript/google-drive/types.d.ts +10 -3
  34. package/lib/typescript/google-drive/types.d.ts.map +1 -1
  35. package/lib/typescript/types/native.d.ts +3 -0
  36. package/lib/typescript/types/native.d.ts.map +1 -1
  37. package/package.json +1 -4
  38. package/src/RNCloudStorage.ts +16 -5
  39. package/src/createRNCloudStorage.ts +2 -2
  40. package/src/google-drive/client.ts +180 -0
  41. package/src/google-drive/index.ts +97 -73
  42. package/src/google-drive/types.ts +12 -4
  43. package/src/types/native.ts +3 -0
package/README.md CHANGED
@@ -1,20 +1,80 @@
1
1
  # ☁️ react-native-cloud-storage
2
2
 
3
- Save to & read from iCloud and Google Drive using React Native
4
-
5
3
  ![npm bundle size](https://img.shields.io/bundlephobia/min/react-native-cloud-storage?style=flat-square) ![GitHub](https://img.shields.io/github/license/kuatsu/react-native-cloud-storage?style=flat-square) ![GitHub last commit](https://img.shields.io/github/last-commit/kuatsu/react-native-cloud-storage?style=flat-square)
6
4
 
5
+ This library provides a unified and streamlined API for accessing cloud storage services on iOS, Android and Web. It supports iCloud on iOS and Google Drive on all other platforms.
6
+
7
+ - 💾 Read and write files to the cloud
8
+ - 🧪 Fully compatible with Expo
9
+ - 📱 iOS, Android & Web support
10
+ - 🏎️ Lightning fast iCloud performance using native iOS APIs
11
+ - 🌐 Google Drive REST API implementation for other platforms
12
+ - 🧬 Easy to use React Hooks API, or use the imperative `fs`-style API
13
+ - 👌 Zero dependencies, small bundle size
14
+
7
15
  ## Installation
8
16
 
17
+ ### React Native
18
+
9
19
  ```sh
10
20
  npm install react-native-cloud-storage
11
- # or
12
- yarn add react-native-cloud-storage
21
+ cd ios && pod install
22
+ ```
23
+
24
+ Afterwards, follow the [configuration instructions](https://react-native-cloud-storage.oss.kuatsu.de/docs/installation/react-native).
25
+
26
+ ### Expo
27
+
28
+ ```sh
29
+ npx expo install react-native-cloud-storage
30
+ ```
31
+
32
+ Afterwards, [add the provided config plugin](https://react-native-cloud-storage.oss.kuatsu.de/docs/installation/expo) and `expo prebuild` or rebuild your development client.
33
+
34
+ ## Quick Start
35
+
36
+ ```jsx
37
+ import React from 'react';
38
+ import { Platform, View, Text, Button } from 'react-native';
39
+ import { CloudStorage, useCloudAvailable } from 'react-native-cloud-storage';
40
+
41
+ const App = () => {
42
+ const cloudAvailable = useCloudAvailable();
43
+
44
+ React.useEffect(() => {
45
+ if (Platform.OS !== 'ios') {
46
+ CloudStorage.setGoogleDriveAccessToken('some-access-token'); // get via @react-native-google-signin/google-signin or similar
47
+ }
48
+ }, []);
49
+
50
+ const writeToCloud = async () => {
51
+ await CloudStorage.writeFile('/file.txt', 'Hello, world!');
52
+ console.log('Successfully wrote file to cloud');
53
+ };
54
+
55
+ const readFromCloud = async () => {
56
+ const value = await CloudStorage.readFile('/file.txt');
57
+ console.log('Successfully read file from cloud:', value);
58
+ };
59
+
60
+ return (
61
+ <View>
62
+ {cloudAvailable ? (
63
+ <>
64
+ <Button onPress={writeToCloud} title="Write to Cloud" />
65
+ <Button onPress={readFromCloud} title="Read from Cloud" />
66
+ </>
67
+ ) : (
68
+ <Text>The cloud storage is not available. Are you logged in?</Text>
69
+ )}
70
+ </View>
71
+ );
72
+ };
13
73
  ```
14
74
 
15
75
  ## Documentation
16
76
 
17
- The documentation is located [here](https://react-native-cloud-storage.oss.kuatsu.de/docs/intro).
77
+ A detailed documentation is located [here](https://react-native-cloud-storage.oss.kuatsu.de/docs/intro).
18
78
 
19
79
  ## Contributing
20
80
 
@@ -22,12 +82,8 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
22
82
 
23
83
  ## Example Project
24
84
 
25
- There's a demo application available within the `example` directory. To use the Google Drive implementation for Android (and any other platforms except iOS), you'll need to provide a valid access token for the Google Drive API. You can create one using the [Google OAuth 2.0 Playground](https://developers.google.com/oauthplayground). If you're using an Android emulator, you can make your life easier by feeding the token into the emulator using `adb shell input text '{some_token}'`.
85
+ There's an example app available in the `example` directory. To use the Google Drive implementation (for any platforms other than iOS), you'll need to provide a valid access token for the Google Drive API. For testing purposes, you can create one using the [Google OAuth 2.0 Playground](https://developers.google.com/oauthplayground).
26
86
 
27
87
  ## License
28
88
 
29
89
  MIT
30
-
31
- ---
32
-
33
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -10,6 +10,7 @@ RCT_EXTERN_METHOD(listFiles:(NSString *)path withScope:(NSString *)scope withRes
10
10
  RCT_EXTERN_METHOD(readFile:(NSString *)path withScope:(NSString *)scope withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
11
11
  RCT_EXTERN_METHOD(downloadFile:(NSString *)path withScope:(NSString *)scope withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
12
12
  RCT_EXTERN_METHOD(deleteFile:(NSString *)path withScope:(NSString *)scope withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
13
+ RCT_EXTERN_METHOD(deleteDirectory:(NSString *)path withRecursive:(BOOL)recursive withScope:(NSString *)scope withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
13
14
  RCT_EXTERN_METHOD(statFile:(NSString *)path withScope:(NSString *)scope withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
14
15
  RCT_EXTERN_METHOD(isCloudAvailable:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
15
16
 
@@ -167,6 +167,11 @@ class CloudStorage: NSObject {
167
167
  return
168
168
  }
169
169
 
170
+ if (fileUrl!.hasDirectoryPath) {
171
+ reject("ERR_PATH_IS_DIRECTORY", "Path \(path) is a directory", nil)
172
+ return
173
+ }
174
+
170
175
  let fileManager = FileManager.default
171
176
  do {
172
177
  try fileManager.removeItem(at: fileUrl!)
@@ -176,6 +181,47 @@ class CloudStorage: NSObject {
176
181
  }
177
182
  }
178
183
 
184
+ @objc(deleteDirectory:withRecursive:withScope:withResolver:withRejecter:)
185
+ func deleteDirectory(path: String, recursive: Bool, scope: String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
186
+ let fileUrl: URL?
187
+ do {
188
+ fileUrl = try getFileURL(path, scope, true)
189
+ } catch let error as NSError {
190
+ reject(error.domain, error.userInfo["message"] as? String, error)
191
+ return
192
+ }
193
+
194
+ if (!fileUrl!.hasDirectoryPath) {
195
+ reject("ERR_PATH_IS_FILE", "Path \(path) is a file", nil)
196
+ return
197
+ }
198
+
199
+ if (!recursive) {
200
+ // check if directory is empty
201
+ let fileManager = FileManager.default
202
+ do {
203
+ print(fileUrl!.path)
204
+ let files = try fileManager.contentsOfDirectory(atPath: fileUrl!.path)
205
+ print(files)
206
+ if (files.count > 0) {
207
+ reject("ERR_DIRECTORY_NOT_EMPTY", "Directory \(path) is not empty", nil)
208
+ return
209
+ }
210
+ } catch {
211
+ reject("ERR_UNKNOWN", "Error reading directory \(path)", error)
212
+ return
213
+ }
214
+ }
215
+
216
+ let fileManager = FileManager.default
217
+ do {
218
+ try fileManager.removeItem(at: fileUrl!)
219
+ resolve(true)
220
+ } catch {
221
+ reject("ERR_DELETE_ERROR", "Error deleting directory \(path)", error)
222
+ }
223
+ }
224
+
179
225
  @objc(statFile:withScope:withResolver:withRejecter:)
180
226
  func statFile(path: String, scope: String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
181
227
  let fileUrl: URL?
@@ -108,6 +108,16 @@ const RNCloudStorage = {
108
108
  unlink: (path, scope) => {
109
109
  return nativeInstance.deleteFile((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
110
110
  },
111
+ /**
112
+ * Deletes the directory at the given path.
113
+ * @param path The directory to delete.
114
+ * @param options Options for the delete operation. Defaults to { recursive: false }.
115
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
116
+ * @returns A promise that resolves when the directory has been deleted.
117
+ */
118
+ rmdir: (path, options, scope) => {
119
+ return nativeInstance.deleteDirectory((0, _helpers.verifyLeadingSlash)(path), (options === null || options === void 0 ? void 0 : options.recursive) ?? false, scope ?? defaultScope);
120
+ },
111
121
  /**
112
122
  * Gets the size, creation time, and modification time of the file at the given path.
113
123
  * @param path The file to stat.
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_createRNCloudStorage","_interopRequireDefault","_googleDrive","_main","_helpers","obj","__esModule","default","nativeInstance","createRNCloudStorage","defaultScope","CloudStorageScope","AppData","RNCloudStorage","getDefaultScope","setDefaultScope","scope","getGoogleDriveAccessToken","GoogleDriveApiClient","accessToken","setGoogleDriveAccessToken","setThrowOnFilesWithSameName","enable","throwOnFilesWithSameName","subscribeToFilesWithSameName","Platform","OS","subscriber","remove","bind","isCloudAvailable","appendFile","path","data","appendToFile","verifyLeadingSlash","exists","fileExists","writeFile","createFile","mkdir","createDirectory","readdir","listFiles","readFile","downloadFile","unlink","deleteFile","stat","native","statFile","birthtime","Date","birthtimeMs","mtime","mtimeMs","isDirectory","isFile","_default","exports"],"sourceRoot":"../../src","sources":["RNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAAqD,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAErD,MAAMG,cAAc,GAAG,IAAAC,6BAAoB,GAAE;AAC7C,IAAIC,YAAY,GAAGC,uBAAiB,CAACC,OAAO;AAE5C,MAAMC,cAAc,GAAG;EACrBC,eAAe,EAAEA,CAAA,KAAMJ,YAAY;EACnCK,eAAe,EAAGC,KAAwB,IAAMN,YAAY,GAAGM,KAAM;EACrEC,yBAAyB,EAAEA,CAAA,KAAMC,oBAAoB,CAACC,WAAW;EACjEC,yBAAyB,EAAGD,WAAmB,IAAMD,oBAAoB,CAACC,WAAW,GAAGA,WAAY;EACpGE,2B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AM,CAACM,OAAO,CAAC;MAC/BC,WAAW,EAAEA,CAAA,KAAMP,MAAM,CAACO,WAAW;MACrCC,MAAM,EAAEA,CAAA,KAAMR,MAAM,CAACQ;IACvB,CAAC;EACH;AACF,CAAC;AAAC,IAAAC,QAAA,GAEa7C,cAAc;AAAA8C,OAAA,CAAApD,OAAA,GAAAmD,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_createRNCloudStorage","_interopRequireDefault","_googleDrive","_main","_helpers","obj","__esModule","default","nativeInstance","createRNCloudStorage","defaultScope","CloudStorageScope","AppData","RNCloudStorage","getDefaultScope","setDefaultScope","scope","getGoogleDriveAccessToken","GoogleDrive","accessToken","setGoogleDriveAccessToken","setThrowOnFilesWithSameName","enable","throwOnFilesWithSameName","subscribeToFilesWithSameName","Platform","OS","subscriber","remove","bind","isCloudAvailable","appendFile","path","data","appendToFile","verifyLeadingSlash","exists","fileExists","writeFile","createFile","mkdir","createDirectory","readdir","listFiles","readFile","downloadFile","unlink","deleteFile","rmdir","options","deleteDirectory","recursive","stat","native","statFile","birthtime","Date","birthtimeMs","mtime","mtimeMs","isDirectory","isFile","_default","exports"],"sourceRoot":"../../src","sources":["RNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAAqD,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAErD,MAAMG,cAAc,GAAG,IAAAC,6BAAoB,GAAE;AAC7C,IAAIC,YAAY,GAAGC,uBAAiB,CAACC,OAAO;AAE5C,MAAMC,cAAc,GAAG;EACrBC,eAAe,EAAEA,CAAA,KAAMJ,YAAY;EACnCK,eAAe,E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CAAAiB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,SAAS,KAAI,KAAK,EAAEnC,KAAK,IAAIN,YAAY,CAAC;EACrH,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACE0C,IAAI,EAAE,MAAAA,CAAOpB,IAAY,EAAEhB,KAAyB,KAAoC;IACtF,MAAMqC,MAAM,GAAG,MAAM7C,cAAc,CAAC8C,QAAQ,CAAC,IAAAnB,2BAAkB,EAACH,IAAI,CAAC,EAAEhB,KAAK,IAAIN,YAAY,CAAC;IAE7F,OAAO;MACL,GAAG2C,MAAM;MACTE,SAAS,EAAE,IAAIC,IAAI,CAACH,MAAM,CAACI,WAAW,CAAC;MACvCC,KAAK,EAAE,IAAIF,IAAI,CAACH,MAAM,CAACM,OAAO,CAAC;MAC/BC,WAAW,EAAEA,CAAA,KAAMP,MAAM,CAACO,WAAW;MACrCC,MAAM,EAAEA,CAAA,KAAMR,MAAM,CAACQ;IACvB,CAAC;EACH;AACF,CAAC;AAAC,IAAAC,QAAA,GAEajD,cAAc;AAAAkD,OAAA,CAAAxD,OAAA,GAAAuD,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_googleDrive","_interopRequireDefault","_native","_CloudStorageError","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","nativeIosInstance","NativeModules","CloudStorage","Proxy","get","target","prop","originalFunction","arguments","error","code","Object","values","CloudStorageErrorCode","includes","CloudStorageError","message","UNKNOWN","createRNCloudStorage","OS","Error","GoogleDriveApiClient"],"sourceRoot":"../../src","sources":["createRNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAA0D,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,G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AAIgB,KAAK,CAACxB,aAAa,CAAC;MAChC;IACF,CAAC,CACF;EAEL;EAEA,OAAO,IAAIyB,oBAAoB,EAAE;AACnC"}
1
+ {"version":3,"names":["_reactNative","require","_googleDrive","_interopRequireDefault","_native","_CloudStorageError","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","nativeIosInstance","NativeModules","CloudStorage","Proxy","get","target","prop","originalFunction","arguments","error","code","Object","values","CloudStorageErrorCode","includes","CloudStorageError","message","UNKNOWN","createRNCloudStorage","OS","Error","GoogleDrive"],"sourceRoot":"../../src","sources":["createRNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAA0D,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1D,MAAMG,aAAa,GAChB,qFAAoF,GACrFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEJ,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMK,iBAAiB,GAAGC,0BAAa,CAACC,YAAY,GAChD,IAAIC,KAAK,CAACF,0BAAa,CAACC,YAAY,EAAE;EACpCE,GAAGA,CAACC,MAA4B,EAAEC,IAAgC,EAAE;IAClE,MAAMC,gBAAgB,GAAGF,MAAM,CAACC,IAAI,CAAC;IACrC,IAAI,OAAOC,gBAAgB,KAAK,UAAU,EAAE;MAC1C,OAAO,kBAA0B;QAC/B,IAAI;UACF;UACA,OAAO,MAAMA,gBAAgB,CAAC,GAAAC,SAAO,CAAC;QACxC,CAAC,CAAC,OAAOC,KAAU,EAAE;UACnB,IAAIA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEC,IAAI,IAAIC,MAAM,CAACC,MAAM,CAACC,6BAAqB,CAAC,CAACC,QAAQ,CAACL,KAAK,CAACC,IAAI,CAAC,EAAE;YAC5E,MAAM,IAAIK,0BAAiB,CAAC,CAAAN,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEO,OAAO,KAAI,EAAE,EAAEP,KAAK,CAACC,IAAI,CAA0B;UACxF,CAAC,MAAM;YACL,MAAM,IAAIK,0BAAiB,CAAC,eAAe,EAAEF,6BAAqB,CAACI,OAAO,EAAER,KAAK,CAAC;UACpF;QACF;MACF,CAAC;IACH;IACA,OAAOF,gBAAgB;EACzB;AACF,CAAC,CAAC,GACF,IAAI;AAEO,SAASW,oBAAoBA,CAAA,EAAyB;EACnE,IAAIrB,qBAAQ,CAACsB,EAAE,KAAK,KAAK,EAAE;IACzB,OACEnB,iBAAiB,IACjB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;MACEC,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIgB,KAAK,CAACxB,aAAa,CAAC;MAChC;IACF,CAAC,CACF;EAEL;EAEA,OAAO,IAAIyB,oBAAW,EAAE;AAC1B"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.GoogleDriveHttpError = void 0;
7
+ var _types = require("./types");
8
+ const BASE_URL = 'https://www.googleapis.com/drive/v3';
9
+ const BASE_UPLOAD_URL = 'https://www.googleapis.com/upload/drive/v3';
10
+ const MULTIPART_BOUNDARY = 'foo_bar_baz';
11
+ class GoogleDriveHttpError extends Error {
12
+ constructor(message, status, json) {
13
+ super(message);
14
+ this.status = status;
15
+ this.json = json;
16
+ }
17
+ }
18
+
19
+ // TODO: fetch timeout
20
+ // TODO: properly handle errors
21
+ exports.GoogleDriveHttpError = GoogleDriveHttpError;
22
+ class GoogleDriveApiClient {
23
+ constructor() {
24
+ let accessToken = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
25
+ this.accessToken = accessToken;
26
+ }
27
+ buildQueryString(query) {
28
+ let res = Object.entries(query).filter(_ref => {
29
+ let [, value] = _ref;
30
+ return value !== undefined;
31
+ }).map(_ref2 => {
32
+ let [key, value] = _ref2;
33
+ if (typeof value === 'boolean') return `${encodeURIComponent(key)}=${value ? 'true' : 'false'}`;
34
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
35
+ }).join('&');
36
+ if (res) {
37
+ res = `?${res}`;
38
+ }
39
+ return res;
40
+ }
41
+ async request(operation) {
42
+ let {
43
+ queryParameters,
44
+ baseUrl,
45
+ ...options
46
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
47
+ let path = `${baseUrl ?? BASE_URL}${operation}`;
48
+ if (queryParameters) {
49
+ path += this.buildQueryString(queryParameters);
50
+ }
51
+ const response = await fetch(path, {
52
+ ...options,
53
+ headers: {
54
+ ...options.headers,
55
+ Authorization: `Bearer ${this.accessToken}`
56
+ }
57
+ });
58
+ if (!response.ok) {
59
+ let errorMessage;
60
+ let json = null;
61
+ try {
62
+ var _json$error;
63
+ json = await response.json();
64
+ errorMessage = ((_json$error = json.error) === null || _json$error === void 0 ? void 0 : _json$error.message) ?? `Request failed with status ${response.status}`;
65
+ } catch (e) {
66
+ errorMessage = `Request failed with status ${response.status}`;
67
+ }
68
+ throw new GoogleDriveHttpError(errorMessage, response.status, json);
69
+ }
70
+ if (response.status === 204) {
71
+ return undefined;
72
+ }
73
+ if (options !== null && options !== void 0 && options.headers && 'Accept' in options.headers && options.headers.Accept !== 'application/json') {
74
+ return response.text();
75
+ }
76
+ return response.json();
77
+ }
78
+ buildMultiPartBody(metadata, media) {
79
+ const body = [];
80
+ body.push(`--${MULTIPART_BOUNDARY}\r\n`);
81
+ body.push(`Content-Type: ${_types.MimeTypes.JSON}; charset=UTF-8\r\n\r\n`);
82
+ body.push(`${JSON.stringify(metadata)}\r\n`);
83
+ body.push(`--${MULTIPART_BOUNDARY}\r\n`);
84
+ body.push(`Content-Type: ${media.mimeType}\r\n\r\n`);
85
+ body.push(`${media.body}\r\n`);
86
+ body.push(`--${MULTIPART_BOUNDARY}--`);
87
+ return body.join('');
88
+ }
89
+ async listFiles(space) {
90
+ const files = [];
91
+ let pageToken;
92
+ const fields = ['id', 'kind', 'mimeType', 'name', 'parents', 'spaces', 'size', 'createdTime', 'modifiedTime'];
93
+ do {
94
+ const queryParameters = {
95
+ fields: `files(${fields.join(',')}),nextPageToken`,
96
+ spaces: space
97
+ };
98
+ const response = await this.request(`/files`, {
99
+ queryParameters
100
+ });
101
+ files.push(...response.files);
102
+ pageToken = response.nextPageToken ?? undefined;
103
+ } while (pageToken);
104
+ return files;
105
+ }
106
+ async getFile(fileId) {
107
+ const queryParameters = {
108
+ fields: ['id', 'kind', 'mimeType', 'name', 'parents', 'spaces', 'size', 'createdTime', 'modifiedTime'].join(',')
109
+ };
110
+ return this.request(`/files/${fileId}`, {
111
+ queryParameters
112
+ });
113
+ }
114
+ async getFileText(fileId) {
115
+ return this.request(`/files/${fileId}`, {
116
+ queryParameters: {
117
+ alt: 'media'
118
+ },
119
+ headers: {
120
+ Accept: 'text/plain'
121
+ }
122
+ });
123
+ }
124
+ async deleteFile(fileId) {
125
+ return this.request(`/files/${fileId}`, {
126
+ method: 'DELETE'
127
+ });
128
+ }
129
+ async createFile(metadata, media) {
130
+ const multipartRequestBody = this.buildMultiPartBody(metadata, media);
131
+ await this.request(`/files`, {
132
+ queryParameters: {
133
+ uploadType: 'multipart'
134
+ },
135
+ method: 'POST',
136
+ headers: {
137
+ 'Content-Type': `multipart/related; boundary=${MULTIPART_BOUNDARY}`,
138
+ 'Content-Length': multipartRequestBody.length.toString()
139
+ },
140
+ body: multipartRequestBody,
141
+ baseUrl: BASE_UPLOAD_URL
142
+ });
143
+ }
144
+ async createDirectory(metadata) {
145
+ await this.request(`/files`, {
146
+ method: 'POST',
147
+ headers: {
148
+ 'Content-Type': `application/json`
149
+ },
150
+ body: JSON.stringify({
151
+ ...metadata,
152
+ mimeType: _types.MimeTypes.FOLDER
153
+ })
154
+ });
155
+ }
156
+ async updateFile(fileId, media) {
157
+ await this.request(`/files/${fileId}`, {
158
+ queryParameters: {
159
+ uploadType: 'media'
160
+ },
161
+ method: 'PATCH',
162
+ headers: {
163
+ 'Content-Type': media.mimeType,
164
+ 'Content-Length': media.body.length.toString()
165
+ },
166
+ body: media.body,
167
+ baseUrl: BASE_UPLOAD_URL
168
+ });
169
+ }
170
+ }
171
+ exports.default = GoogleDriveApiClient;
172
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","BASE_URL","BASE_UPLOAD_URL","MULTIPART_BOUNDARY","GoogleDriveHttpError","Error","constructor","message","status","json","exports","GoogleDriveApiClient","accessToken","arguments","length","undefined","buildQueryString","query","res","Object","entries","filter","_ref","value","map","_ref2","key","encodeURIComponent","join","request","operation","queryParameters","baseUrl","options","path","response","fetch","headers","Authorization","ok","errorMessage","_json$error","error","e","Accept","text","buildMultiPartBody","metadata","media","body","push","MimeTypes","JSON","stringify","mimeType","listFiles","space","files","pageToken","fields","spaces","nextPageToken","getFile","fileId","getFileText","alt","deleteFile","method","createFile","multipartRequestBody","uploadType","toString","createDirectory","FOLDER","updateFile","default"],"sourceRoot":"../../../src","sources":["google-drive/client.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQA,MAAMC,QAAQ,GAAG,qCAAqC;AACtD,MAAMC,eAAe,GAAG,4CAA4C;AACpE,MAAMC,kBAAkB,GAAG,aAAa;AAEjC,MAAMC,oBAAoB,SAASC,KAAK,CAAC;EAI9CC,WAAWA,CAACC,OAAe,EAAEC,MAAc,EAAEC,IAAS,EAAE;IACtD,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,IAAI,GAAGA,IAAI;EAClB;AACF;;AAEA;AACA;AAAAC,OAAA,CAAAN,oBAA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