react-native-cloud-storage 2.2.1 → 2.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.
- package/LICENSE +1 -1
- package/android/build.gradle +101 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/voicekit/CloudStorageError.kt +86 -0
- package/android/src/main/java/com/voicekit/CloudStorageLocalFileSystemModule.kt +236 -0
- package/android/src/main/java/com/voicekit/CloudStoragePackage.kt +17 -0
- package/android/src/main/java/com/voicekit/FileUtils.kt +41 -0
- package/android/src/main/java/com/voicekit/Types.kt +6 -0
- package/app.plugin.js +1 -1
- package/{lib/commonjs/RNCloudStorage.js → dist/commonjs/cloud-storage.js} +130 -80
- package/dist/commonjs/cloud-storage.js.map +1 -0
- package/dist/commonjs/expo-plugin/index.js +13 -0
- package/dist/commonjs/expo-plugin/index.js.map +1 -0
- package/{lib/commonjs/expo-plugin/withRNCloudStorageIos.js → dist/commonjs/expo-plugin/ios.js} +1 -1
- package/dist/commonjs/expo-plugin/ios.js.map +1 -0
- package/{lib/commonjs/hooks/useCloudFile.js → dist/commonjs/hooks/use-cloud-file.js} +26 -8
- package/dist/commonjs/hooks/use-cloud-file.js.map +1 -0
- package/{lib/commonjs/hooks/useIsCloudAvailable.js → dist/commonjs/hooks/use-is-cloud-available.js} +3 -3
- package/dist/commonjs/hooks/use-is-cloud-available.js.map +1 -0
- package/{lib → dist}/commonjs/index.js +10 -10
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/storages/cloudkit.js +10 -0
- package/dist/commonjs/storages/cloudkit.js.map +1 -0
- package/{lib/commonjs → dist/commonjs/storages}/google-drive/client.js +82 -39
- package/dist/commonjs/storages/google-drive/client.js.map +1 -0
- package/{lib/commonjs → dist/commonjs/storages}/google-drive/index.js +120 -64
- package/dist/commonjs/storages/google-drive/index.js.map +1 -0
- package/dist/commonjs/storages/google-drive/types.js.map +1 -0
- package/dist/commonjs/types/native.js +28 -0
- package/dist/commonjs/types/native.js.map +1 -0
- package/{lib/commonjs/utils/CloudStorageError.js → dist/commonjs/utils/cloud-storage-error.js} +3 -1
- package/dist/commonjs/utils/cloud-storage-error.js.map +1 -0
- package/dist/commonjs/utils/constants.js +24 -0
- package/dist/commonjs/utils/constants.js.map +1 -0
- package/dist/commonjs/utils/local-fs.js +16 -0
- package/dist/commonjs/utils/local-fs.js.map +1 -0
- package/dist/commonjs/utils/native.js +35 -0
- package/dist/commonjs/utils/native.js.map +1 -0
- package/{lib/module/RNCloudStorage.js → dist/module/cloud-storage.js} +130 -80
- package/dist/module/cloud-storage.js.map +1 -0
- package/dist/module/expo-plugin/index.js +8 -0
- package/dist/module/expo-plugin/index.js.map +1 -0
- package/{lib/module/expo-plugin/withRNCloudStorageIos.js → dist/module/expo-plugin/ios.js} +1 -1
- package/dist/module/expo-plugin/ios.js.map +1 -0
- package/{lib/module/hooks/useCloudFile.js → dist/module/hooks/use-cloud-file.js} +25 -7
- package/dist/module/hooks/use-cloud-file.js.map +1 -0
- package/{lib/module/hooks/useIsCloudAvailable.js → dist/module/hooks/use-is-cloud-available.js} +2 -2
- package/dist/module/hooks/use-is-cloud-available.js.map +1 -0
- package/dist/module/index.js +9 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/storages/cloudkit.js +6 -0
- package/dist/module/storages/cloudkit.js.map +1 -0
- package/{lib/module → dist/module/storages}/google-drive/client.js +82 -39
- package/dist/module/storages/google-drive/client.js.map +1 -0
- package/{lib/module → dist/module/storages}/google-drive/index.js +119 -62
- package/dist/module/storages/google-drive/index.js.map +1 -0
- package/dist/module/storages/google-drive/types.js.map +1 -0
- package/dist/module/types/native.js +24 -0
- package/dist/module/types/native.js.map +1 -0
- package/{lib/module/utils/CloudStorageError.js → dist/module/utils/cloud-storage-error.js} +3 -1
- package/dist/module/utils/cloud-storage-error.js.map +1 -0
- package/dist/module/utils/constants.js +20 -0
- package/dist/module/utils/constants.js.map +1 -0
- package/dist/module/utils/local-fs.js +12 -0
- package/dist/module/utils/local-fs.js.map +1 -0
- package/dist/module/utils/native.js +30 -0
- package/dist/module/utils/native.js.map +1 -0
- package/{lib/typescript/RNCloudStorage.d.ts → dist/typescript/cloud-storage.d.ts} +60 -8
- package/dist/typescript/cloud-storage.d.ts.map +1 -0
- package/{lib/typescript/expo-plugin/withRNCloudStorage.d.ts → dist/typescript/expo-plugin/index.d.ts} +1 -1
- package/dist/typescript/expo-plugin/index.d.ts.map +1 -0
- package/{lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts → dist/typescript/expo-plugin/ios.d.ts} +1 -1
- package/dist/typescript/expo-plugin/ios.d.ts.map +1 -0
- package/{lib/typescript/hooks/useCloudFile.d.ts → dist/typescript/hooks/use-cloud-file.d.ts} +22 -4
- package/dist/typescript/hooks/use-cloud-file.d.ts.map +1 -0
- package/{lib/typescript/hooks/useIsCloudAvailable.d.ts → dist/typescript/hooks/use-is-cloud-available.d.ts} +2 -2
- package/dist/typescript/hooks/use-is-cloud-available.d.ts.map +1 -0
- package/dist/typescript/index.d.ts +7 -0
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/storages/cloudkit.d.ts +3 -0
- package/dist/typescript/storages/cloudkit.d.ts.map +1 -0
- package/{lib/typescript → dist/typescript/storages}/google-drive/client.d.ts +9 -2
- package/dist/typescript/storages/google-drive/client.d.ts.map +1 -0
- package/dist/typescript/storages/google-drive/index.d.ts +35 -0
- package/dist/typescript/storages/google-drive/index.d.ts.map +1 -0
- package/dist/typescript/storages/google-drive/types.d.ts.map +1 -0
- package/dist/typescript/types/native.d.ts +64 -0
- package/dist/typescript/types/native.d.ts.map +1 -0
- package/dist/typescript/utils/cloud-storage-error.d.ts +8 -0
- package/dist/typescript/utils/cloud-storage-error.d.ts.map +1 -0
- package/dist/typescript/utils/constants.d.ts +4 -0
- package/dist/typescript/utils/constants.d.ts.map +1 -0
- package/{lib → dist}/typescript/utils/helpers.d.ts.map +1 -1
- package/dist/typescript/utils/local-fs.d.ts +3 -0
- package/dist/typescript/utils/local-fs.d.ts.map +1 -0
- package/dist/typescript/utils/native.d.ts +7 -0
- package/dist/typescript/utils/native.d.ts.map +1 -0
- package/ios/CloudStorage.xcodeproj/project.pbxproj +12 -6
- package/ios/{CloudStorage.m → CloudStorageCloudKit.m} +4 -2
- package/ios/{CloudStorage.swift → CloudStorageCloudKit.swift} +60 -5
- package/ios/CloudStorageLocalFileSystem.m +15 -0
- package/ios/CloudStorageLocalFileSystem.swift +215 -0
- package/ios/Utils/CloudKitUtils.swift +4 -4
- package/ios/Utils/CloudStorageError.swift +8 -0
- package/ios/Utils/FileUtils.swift +19 -0
- package/ios/Utils/Types.swift +7 -1
- package/package.json +44 -103
- package/src/{RNCloudStorage.ts → cloud-storage.ts} +147 -85
- package/src/expo-plugin/{withRNCloudStorage.ts → index.ts} +2 -2
- package/src/hooks/{useCloudFile.ts → use-cloud-file.ts} +24 -6
- package/src/hooks/{useIsCloudAvailable.ts → use-is-cloud-available.ts} +1 -1
- package/src/index.ts +5 -6
- package/src/storages/cloudkit.ts +5 -0
- package/src/{google-drive → storages/google-drive}/client.ts +99 -40
- package/src/{google-drive → storages/google-drive}/index.ts +172 -89
- package/src/types/native.ts +50 -14
- package/src/utils/cloud-storage-error.ts +15 -0
- package/src/utils/constants.ts +20 -0
- package/src/utils/local-fs.ts +19 -0
- package/src/utils/native.ts +40 -0
- package/lib/commonjs/RNCloudStorage.js.map +0 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js +0 -13
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +0 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +0 -1
- package/lib/commonjs/google-drive/client.js.map +0 -1
- package/lib/commonjs/google-drive/index.js.map +0 -1
- package/lib/commonjs/google-drive/types.js.map +0 -1
- package/lib/commonjs/hooks/useCloudFile.js.map +0 -1
- package/lib/commonjs/hooks/useIsCloudAvailable.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types/native.js +0 -26
- package/lib/commonjs/types/native.js.map +0 -1
- package/lib/commonjs/utils/CloudStorageError.js.map +0 -1
- package/lib/module/RNCloudStorage.js.map +0 -1
- package/lib/module/expo-plugin/withRNCloudStorage.js +0 -8
- package/lib/module/expo-plugin/withRNCloudStorage.js.map +0 -1
- package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +0 -1
- package/lib/module/google-drive/client.js.map +0 -1
- package/lib/module/google-drive/index.js.map +0 -1
- package/lib/module/google-drive/types.js.map +0 -1
- package/lib/module/hooks/useCloudFile.js.map +0 -1
- package/lib/module/hooks/useIsCloudAvailable.js.map +0 -1
- package/lib/module/index.js +0 -10
- package/lib/module/index.js.map +0 -1
- package/lib/module/types/native.js +0 -22
- package/lib/module/types/native.js.map +0 -1
- package/lib/module/utils/CloudStorageError.js.map +0 -1
- package/lib/typescript/RNCloudStorage.d.ts.map +0 -1
- package/lib/typescript/expo-plugin/withRNCloudStorage.d.ts.map +0 -1
- package/lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts.map +0 -1
- package/lib/typescript/google-drive/client.d.ts.map +0 -1
- package/lib/typescript/google-drive/index.d.ts +0 -34
- package/lib/typescript/google-drive/index.d.ts.map +0 -1
- package/lib/typescript/google-drive/types.d.ts.map +0 -1
- package/lib/typescript/hooks/useCloudFile.d.ts.map +0 -1
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -8
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/types/native.d.ts +0 -40
- package/lib/typescript/types/native.d.ts.map +0 -1
- package/lib/typescript/utils/CloudStorageError.d.ts +0 -8
- package/lib/typescript/utils/CloudStorageError.d.ts.map +0 -1
- package/src/utils/CloudStorageError.ts +0 -14
- /package/{lib → dist}/commonjs/expo-plugin/types/index.js +0 -0
- /package/{lib → dist}/commonjs/expo-plugin/types/index.js.map +0 -0
- /package/{lib/commonjs → dist/commonjs/storages}/google-drive/types.js +0 -0
- /package/{lib → dist}/commonjs/types/main.js +0 -0
- /package/{lib → dist}/commonjs/types/main.js.map +0 -0
- /package/{lib → dist}/commonjs/utils/helpers.js +0 -0
- /package/{lib → dist}/commonjs/utils/helpers.js.map +0 -0
- /package/{lib → dist}/module/expo-plugin/types/index.js +0 -0
- /package/{lib → dist}/module/expo-plugin/types/index.js.map +0 -0
- /package/{lib → dist}/module/package.json +0 -0
- /package/{lib/module → dist/module/storages}/google-drive/types.js +0 -0
- /package/{lib → dist}/module/types/main.js +0 -0
- /package/{lib → dist}/module/types/main.js.map +0 -0
- /package/{lib → dist}/module/utils/helpers.js +0 -0
- /package/{lib → dist}/module/utils/helpers.js.map +0 -0
- /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts +0 -0
- /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts.map +0 -0
- /package/{lib/typescript → dist/typescript/storages}/google-drive/types.d.ts +0 -0
- /package/{lib → dist}/typescript/types/main.d.ts +0 -0
- /package/{lib → dist}/typescript/types/main.d.ts.map +0 -0
- /package/{lib → dist}/typescript/utils/helpers.d.ts +0 -0
- /package/src/expo-plugin/{withRNCloudStorageIos.ts → ios.ts} +0 -0
- /package/src/{google-drive → storages/google-drive}/types.ts +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { MimeTypes } from './types';
|
|
4
|
+
import { localFileSystem } from '../../utils/local-fs';
|
|
4
5
|
const BASE_URL = 'https://www.googleapis.com/drive/v3';
|
|
5
6
|
const BASE_UPLOAD_URL = 'https://www.googleapis.com/upload/drive/v3';
|
|
6
7
|
const MULTIPART_BOUNDARY = 'foo_bar_baz';
|
|
7
8
|
export class GoogleDriveHttpError extends Error {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
|
|
8
11
|
constructor(message, status, json) {
|
|
9
12
|
super(message);
|
|
10
13
|
this.status = status;
|
|
@@ -12,21 +15,21 @@ export class GoogleDriveHttpError extends Error {
|
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
// TODO: fetch timeout
|
|
16
18
|
// TODO: properly handle errors
|
|
17
19
|
export default class GoogleDriveApiClient {
|
|
20
|
+
_fetchTimeout = null;
|
|
18
21
|
constructor(options) {
|
|
19
22
|
this.options = options;
|
|
20
23
|
}
|
|
21
24
|
buildQueryString(query) {
|
|
22
|
-
let
|
|
25
|
+
let result = Object.entries(query).filter(([, value]) => value !== undefined).map(([key, value]) => {
|
|
23
26
|
if (typeof value === 'boolean') return `${encodeURIComponent(key)}=${value ? 'true' : 'false'}`;
|
|
24
27
|
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
25
28
|
}).join('&');
|
|
26
|
-
if (
|
|
27
|
-
|
|
29
|
+
if (result) {
|
|
30
|
+
result = `?${result}`;
|
|
28
31
|
}
|
|
29
|
-
return
|
|
32
|
+
return result;
|
|
30
33
|
}
|
|
31
34
|
async request(operation, {
|
|
32
35
|
queryParameters,
|
|
@@ -41,7 +44,7 @@ export default class GoogleDriveApiClient {
|
|
|
41
44
|
if (queryParameters) {
|
|
42
45
|
path += this.buildQueryString(queryParameters);
|
|
43
46
|
}
|
|
44
|
-
clearTimeout(this._fetchTimeout);
|
|
47
|
+
if (this._fetchTimeout !== null) clearTimeout(this._fetchTimeout);
|
|
45
48
|
const abortController = new AbortController();
|
|
46
49
|
this._fetchTimeout = setTimeout(() => {
|
|
47
50
|
abortController.abort();
|
|
@@ -59,8 +62,8 @@ export default class GoogleDriveApiClient {
|
|
|
59
62
|
let json = null;
|
|
60
63
|
try {
|
|
61
64
|
json = await response.json();
|
|
62
|
-
errorMessage = json.error
|
|
63
|
-
} catch
|
|
65
|
+
errorMessage = typeof json === 'object' && json !== null && 'error' in json && typeof json.error === 'object' && json.error !== null && 'message' in json.error && typeof json.error.message === 'string' ? json.error.message : `Request failed with status ${response.status}`;
|
|
66
|
+
} catch {
|
|
64
67
|
errorMessage = `Request failed with status ${response.status}`;
|
|
65
68
|
}
|
|
66
69
|
throw new GoogleDriveHttpError(errorMessage, response.status, json);
|
|
@@ -75,13 +78,7 @@ export default class GoogleDriveApiClient {
|
|
|
75
78
|
}
|
|
76
79
|
buildMultiPartBody(metadata, media) {
|
|
77
80
|
const body = [];
|
|
78
|
-
body.push(`--${MULTIPART_BOUNDARY}\r\n`);
|
|
79
|
-
body.push(`Content-Type: ${MimeTypes.JSON}; charset=UTF-8\r\n\r\n`);
|
|
80
|
-
body.push(`${JSON.stringify(metadata)}\r\n`);
|
|
81
|
-
body.push(`--${MULTIPART_BOUNDARY}\r\n`);
|
|
82
|
-
body.push(`Content-Type: ${media.mimeType}\r\n\r\n`);
|
|
83
|
-
body.push(`${media.body}\r\n`);
|
|
84
|
-
body.push(`--${MULTIPART_BOUNDARY}--`);
|
|
81
|
+
body.push(`--${MULTIPART_BOUNDARY}\r\n`, `Content-Type: ${MimeTypes.JSON}; charset=UTF-8\r\n\r\n`, `${JSON.stringify(metadata)}\r\n`, `--${MULTIPART_BOUNDARY}\r\n`, `Content-Type: ${media.mimeType}\r\n\r\n`, `${media.body}\r\n`, `--${MULTIPART_BOUNDARY}--`);
|
|
85
82
|
return body.join('');
|
|
86
83
|
}
|
|
87
84
|
async listFiles(space) {
|
|
@@ -91,7 +88,8 @@ export default class GoogleDriveApiClient {
|
|
|
91
88
|
do {
|
|
92
89
|
const queryParameters = {
|
|
93
90
|
fields: `files(${fields.join(',')}),nextPageToken`,
|
|
94
|
-
spaces: space
|
|
91
|
+
spaces: space,
|
|
92
|
+
pageToken
|
|
95
93
|
};
|
|
96
94
|
const response = await this.request(`/files`, {
|
|
97
95
|
queryParameters
|
|
@@ -125,19 +123,44 @@ export default class GoogleDriveApiClient {
|
|
|
125
123
|
});
|
|
126
124
|
}
|
|
127
125
|
async createFile(metadata, media) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
if ('body' in media) {
|
|
127
|
+
const multipartRequestBody = this.buildMultiPartBody(metadata, media);
|
|
128
|
+
await this.request(`/files`, {
|
|
129
|
+
queryParameters: {
|
|
130
|
+
uploadType: 'multipart'
|
|
131
|
+
},
|
|
132
|
+
method: 'POST',
|
|
133
|
+
headers: {
|
|
134
|
+
'Content-Type': `multipart/related; boundary=${MULTIPART_BOUNDARY}`,
|
|
135
|
+
'Content-Length': multipartRequestBody.length.toString()
|
|
136
|
+
},
|
|
137
|
+
body: multipartRequestBody,
|
|
138
|
+
baseUrl: BASE_UPLOAD_URL
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
// First, create an empty file with the required metadata
|
|
142
|
+
const file = await this.request(`/files`, {
|
|
143
|
+
method: 'POST',
|
|
144
|
+
headers: {
|
|
145
|
+
'Content-Type': MimeTypes.JSON
|
|
146
|
+
},
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
...metadata,
|
|
149
|
+
mimeType: media.mimeType
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Then, upload the binary content via the native helper module
|
|
154
|
+
const remoteUri = `${BASE_UPLOAD_URL}/files/${file.id}?uploadType=media`;
|
|
155
|
+
await localFileSystem.uploadFile(media.localPath, remoteUri, {
|
|
156
|
+
method: 'PATCH',
|
|
157
|
+
uploadType: 'binary',
|
|
158
|
+
headers: {
|
|
159
|
+
'Authorization': `Bearer ${this.options.accessToken}`,
|
|
160
|
+
'Content-Type': media.mimeType
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
141
164
|
}
|
|
142
165
|
async createDirectory(metadata) {
|
|
143
166
|
await this.request(`/files`, {
|
|
@@ -152,17 +175,37 @@ export default class GoogleDriveApiClient {
|
|
|
152
175
|
});
|
|
153
176
|
}
|
|
154
177
|
async updateFile(fileId, media) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
178
|
+
if ('body' in media) {
|
|
179
|
+
await this.request(`/files/${fileId}`, {
|
|
180
|
+
queryParameters: {
|
|
181
|
+
uploadType: 'media'
|
|
182
|
+
},
|
|
183
|
+
method: 'PATCH',
|
|
184
|
+
headers: {
|
|
185
|
+
'Content-Type': media.mimeType,
|
|
186
|
+
'Content-Length': media.body.length.toString()
|
|
187
|
+
},
|
|
188
|
+
body: media.body,
|
|
189
|
+
baseUrl: BASE_UPLOAD_URL
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
const remoteUri = `${BASE_UPLOAD_URL}/files/${fileId}?uploadType=media`;
|
|
193
|
+
await localFileSystem.uploadFile(media.localPath, remoteUri, {
|
|
194
|
+
method: 'PATCH',
|
|
195
|
+
uploadType: 'binary',
|
|
196
|
+
headers: {
|
|
197
|
+
'Authorization': `Bearer ${this.options.accessToken}`,
|
|
198
|
+
'Content-Type': media.mimeType
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async downloadFile(fileId, localPath) {
|
|
204
|
+
const remoteUri = `${BASE_URL}/files/${fileId}?alt=media`;
|
|
205
|
+
await localFileSystem.downloadFile(remoteUri, localPath, {
|
|
160
206
|
headers: {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
body: media.body,
|
|
165
|
-
baseUrl: BASE_UPLOAD_URL
|
|
207
|
+
Authorization: `Bearer ${this.options.accessToken}`
|
|
208
|
+
}
|
|
166
209
|
});
|
|
167
210
|
}
|
|
168
211
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MimeTypes","localFileSystem","BASE_URL","BASE_UPLOAD_URL","MULTIPART_BOUNDARY","GoogleDriveHttpError","Error","constructor","message","status","json","GoogleDriveApiClient","_fetchTimeout","options","buildQueryString","query","result","Object","entries","filter","value","undefined","map","key","encodeURIComponent","join","request","operation","queryParameters","baseUrl","timeout","accessToken","path","clearTimeout","abortController","AbortController","setTimeout","abort","response","fetch","headers","Authorization","signal","ok","errorMessage","error","Accept","text","buildMultiPartBody","metadata","media","body","push","JSON","stringify","mimeType","listFiles","space","files","pageToken","fields","spaces","nextPageToken","getFile","fileId","getFileText","alt","deleteFile","method","createFile","multipartRequestBody","uploadType","length","toString","file","remoteUri","id","uploadFile","localPath","createDirectory","FOLDER","updateFile","downloadFile"],"sourceRoot":"../../../../src","sources":["storages/google-drive/client.ts"],"mappings":";;AACA,SACEA,SAAS,QAKJ,SAAS;AAChB,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,MAAMC,QAAQ,GAAG,qCAAqC;AACtD,MAAMC,eAAe,GAAG,4CAA4C;AACpE,MAAMC,kBAAkB,GAAG,aAAa;AAExC,OAAO,MAAMC,oBAAoB,SAASC,KAAK,CAAC;EAE9C;;EAGAC,WAAWA,CAACC,OAAe,EAAEC,MAAc,EAAEC,IAAa,EAAE;IAC1D,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,IAAI,GAAGA,IAAI;EAClB;AACF;;AAEA;AACA,eAAe,MAAMC,oBAAoB,CAAC;EAChCC,aAAa,GAA0B,IAAI;EAGnDL,WAAWA,CAACM,OAAiE,EAAE;IAC7E,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;EAEQC,gBAAgBA,CAACC,KAAa,EAAU;IAC9C,IAAIC,MAAM,GAAGC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAC/BI,MAAM,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAKA,KAAK,KAAKC,SAAS,CAAC,CAC1CC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEH,KAAK,CAAC,KAAK;MACrB,IAAI,OAAOA,KAAK,KAAK,SAAS,EAAE,OAAO,GAAGI,kBAA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Q;QACpB/B,OAAO,EAAE;UACP,eAAe,EAAE,UAAU,IAAI,CAAC3B,OAAO,CAACkB,WAAW,EAAE;UACrD,cAAc,EAAEmB,KAAK,CAACK;QACxB;MACF,CAAC,CAAC;IACJ;EACF;EAEA,MAAa2B,YAAYA,CAAClB,MAAc,EAAEc,SAAiB,EAAiB;IAC1E,MAAMH,SAAS,GAAG,GAAGzE,QAAQ,UAAU8D,MAAM,YAAY;IACzD,MAAM/D,eAAe,CAACiF,YAAY,CAACP,SAAS,EAAEG,SAAS,EAAE;MACvDtC,OAAO,EAAE;QACPC,aAAa,EAAE,UAAU,IAAI,CAAC5B,OAAO,CAACkB,WAAW;MACnD;IACF,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import CloudStorageError from '
|
|
3
|
+
import { NativeCloudStorageErrorCode } from '../../types/native';
|
|
4
|
+
import CloudStorageError from '../../utils/cloud-storage-error';
|
|
5
5
|
import { MimeTypes } from './types';
|
|
6
6
|
import GoogleDriveApiClient, { GoogleDriveHttpError } from './client';
|
|
7
7
|
/**
|
|
8
|
-
* A
|
|
8
|
+
* A JavaScript-based implementation of the Google Drive API that implements the cloud storage interface.
|
|
9
9
|
*/
|
|
10
10
|
export default class GoogleDrive {
|
|
11
11
|
constructor(options) {
|
|
@@ -13,17 +13,17 @@ export default class GoogleDrive {
|
|
|
13
13
|
this.drive = new GoogleDriveApiClient(options);
|
|
14
14
|
return new Proxy(this, {
|
|
15
15
|
// before calling any function, check if the access token is set
|
|
16
|
-
get(target,
|
|
16
|
+
get(target, property) {
|
|
17
17
|
const allowedFunctions = ['isCloudAvailable'];
|
|
18
|
-
if (typeof target[
|
|
18
|
+
if (typeof target[property] === 'function' && !allowedFunctions.includes(property.toString())) {
|
|
19
19
|
const {
|
|
20
20
|
accessToken
|
|
21
21
|
} = options;
|
|
22
22
|
if (!accessToken?.length) {
|
|
23
|
-
throw new CloudStorageError(`Google Drive access token is not set, cannot call function ${
|
|
23
|
+
throw new CloudStorageError(`Google Drive access token is not set, cannot call function ${property.toString()}`, NativeCloudStorageErrorCode.ACCESS_TOKEN_MISSING);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
return target[
|
|
26
|
+
return target[property];
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
}
|
|
@@ -36,9 +36,13 @@ export default class GoogleDrive {
|
|
|
36
36
|
getRootDirectory(scope) {
|
|
37
37
|
switch (scope) {
|
|
38
38
|
case 'documents':
|
|
39
|
-
|
|
39
|
+
{
|
|
40
|
+
return 'drive';
|
|
41
|
+
}
|
|
40
42
|
case 'app_data':
|
|
41
|
-
|
|
43
|
+
{
|
|
44
|
+
return 'appDataFolder';
|
|
45
|
+
}
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
resolvePathToDirectories(path) {
|
|
@@ -61,23 +65,23 @@ export default class GoogleDrive {
|
|
|
61
65
|
the files array - if it does not, it means that the directory is a child of the root directory and the one we're
|
|
62
66
|
looking for */
|
|
63
67
|
for (const possibleTopDirectory of possibleTopDirectories) {
|
|
64
|
-
if (!files.
|
|
68
|
+
if (!files.some(f => f.id === possibleTopDirectory.parents[0] && f.mimeType === MimeTypes.FOLDER)) {
|
|
65
69
|
topDirectoryId = possibleTopDirectory.id;
|
|
66
70
|
break;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
if (!topDirectoryId) {
|
|
71
|
-
throw new CloudStorageError(`Could not find top directory with name ${directoryTree[0]}`,
|
|
75
|
+
throw new CloudStorageError(`Could not find top directory with name ${directoryTree[0]}`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
// now, we traverse the directories array and get the id of the last directory from the files array
|
|
75
79
|
let currentDirectoryId = topDirectoryId;
|
|
76
|
-
for (let
|
|
80
|
+
for (let index = 1; index < directoryTree.length; index++) {
|
|
77
81
|
const currentDirectory = files.find(f => f.id === currentDirectoryId);
|
|
78
|
-
if (!currentDirectory) throw new CloudStorageError(`Could not find directory with id ${currentDirectoryId}`,
|
|
79
|
-
const nextDirectory = files.find(f => f.name === directoryTree[
|
|
80
|
-
if (!nextDirectory) throw new CloudStorageError(`Could not find directory with name ${directoryTree[
|
|
82
|
+
if (!currentDirectory) throw new CloudStorageError(`Could not find directory with id ${currentDirectoryId}`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
|
|
83
|
+
const nextDirectory = files.find(f => f.name === directoryTree[index] && f.parents[0] === currentDirectoryId);
|
|
84
|
+
if (!nextDirectory) throw new CloudStorageError(`Could not find directory with name ${directoryTree[index]}`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
|
|
81
85
|
currentDirectoryId = nextDirectory.id;
|
|
82
86
|
}
|
|
83
87
|
return currentDirectoryId;
|
|
@@ -91,7 +95,7 @@ export default class GoogleDrive {
|
|
|
91
95
|
async getRootDirectoryId(scope) {
|
|
92
96
|
const files = await this.drive.listFiles(this.getRootDirectory(scope));
|
|
93
97
|
for (const file of files) {
|
|
94
|
-
if (!files.
|
|
98
|
+
if (!files.some(f => f.id === file.parents[0])) return file.parents[0] ?? null;
|
|
95
99
|
}
|
|
96
100
|
return null;
|
|
97
101
|
}
|
|
@@ -99,15 +103,10 @@ export default class GoogleDrive {
|
|
|
99
103
|
const {
|
|
100
104
|
strictFilenames
|
|
101
105
|
} = this.options;
|
|
102
|
-
|
|
103
|
-
if (parentDirectoryId) {
|
|
104
|
-
possibleFiles = files.filter(f => f.name === filename && f.parents[0] === parentDirectoryId);
|
|
105
|
-
} else {
|
|
106
|
-
possibleFiles = files.filter(f => f.name === filename && !files.find(f2 => f2.id === f.parents[0]));
|
|
107
|
-
}
|
|
106
|
+
const possibleFiles = parentDirectoryId ? files.filter(f => f.name === filename && f.parents[0] === parentDirectoryId) : files.filter(f => f.name === filename && !files.some(f2 => f2.id === f.parents[0]));
|
|
108
107
|
if (possibleFiles.length <= 1) return;
|
|
109
108
|
if (strictFilenames) {
|
|
110
|
-
throw new CloudStorageError(`Multiple files with the same name found at path ${path}: ${possibleFiles.map(f => f.id).join(', ')}`,
|
|
109
|
+
throw new CloudStorageError(`Multiple files with the same name found at path ${path}: ${possibleFiles.map(f => f.id).join(', ')}`, NativeCloudStorageErrorCode.MULTIPLE_FILES_SAME_NAME);
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
async getFileId(path, scope, throwIf = false) {
|
|
@@ -115,7 +114,7 @@ export default class GoogleDrive {
|
|
|
115
114
|
const files = await this.drive.listFiles(this.getRootDirectory(scope));
|
|
116
115
|
if (path === '' || path === '/') {
|
|
117
116
|
const rootDirectoryId = await this.getRootDirectoryId(scope);
|
|
118
|
-
if (!rootDirectoryId) throw new CloudStorageError(`Root directory in scope ${scope} not found`,
|
|
117
|
+
if (!rootDirectoryId) throw new CloudStorageError(`Root directory in scope ${scope} not found`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
|
|
119
118
|
return rootDirectoryId;
|
|
120
119
|
}
|
|
121
120
|
const {
|
|
@@ -128,24 +127,24 @@ export default class GoogleDrive {
|
|
|
128
127
|
this.checkIfMultipleFilesWithSameName(path, files, filename, null);
|
|
129
128
|
/* when the file is supposed to be in the root directory, we need to get the file where the name is the filename
|
|
130
129
|
and the first parent has an id which does not exist in the files array */
|
|
131
|
-
file = files.find(f => f.name === filename && !files.
|
|
130
|
+
file = files.find(f => f.name === filename && !files.some(f2 => f2.id === f.parents[0]));
|
|
132
131
|
} else {
|
|
133
132
|
this.checkIfMultipleFilesWithSameName(path, files, filename, parentDirectoryId);
|
|
134
133
|
file = files.find(f => f.name === filename && f.parents[0] === parentDirectoryId);
|
|
135
134
|
}
|
|
136
|
-
if (!file) throw new CloudStorageError(`File not found`,
|
|
135
|
+
if (!file) throw new CloudStorageError(`File not found`, NativeCloudStorageErrorCode.FILE_NOT_FOUND);
|
|
137
136
|
if (file.mimeType === MimeTypes.FOLDER && throwIf === 'directory') {
|
|
138
|
-
throw new CloudStorageError(`Path ${path} is a directory`,
|
|
137
|
+
throw new CloudStorageError(`Path ${path} is a directory`, NativeCloudStorageErrorCode.PATH_IS_DIRECTORY);
|
|
139
138
|
} else if (file.mimeType !== MimeTypes.FOLDER && throwIf === 'file') {
|
|
140
|
-
throw new CloudStorageError(`Path ${path} is a file`,
|
|
139
|
+
throw new CloudStorageError(`Path ${path} is a file`, NativeCloudStorageErrorCode.FILE_NOT_FOUND);
|
|
141
140
|
}
|
|
142
141
|
return file.id;
|
|
143
|
-
} catch (
|
|
144
|
-
if (
|
|
145
|
-
throw new CloudStorageError(`Could not authenticate with Google Drive`,
|
|
142
|
+
} catch (error) {
|
|
143
|
+
if (error instanceof GoogleDriveHttpError && error.json?.error?.status === 'UNAUTHENTICATED') {
|
|
144
|
+
throw new CloudStorageError(`Could not authenticate with Google Drive`, NativeCloudStorageErrorCode.AUTHENTICATION_FAILED, error.json);
|
|
146
145
|
} else {
|
|
147
|
-
if (
|
|
148
|
-
throw new CloudStorageError(`Could not get file id for path ${path}`,
|
|
146
|
+
if (error instanceof CloudStorageError) throw error;
|
|
147
|
+
throw new CloudStorageError(`Could not get file id for path ${path}`, NativeCloudStorageErrorCode.UNKNOWN, error);
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
}
|
|
@@ -153,26 +152,26 @@ export default class GoogleDrive {
|
|
|
153
152
|
try {
|
|
154
153
|
await this.getFileId(path, scope);
|
|
155
154
|
return true;
|
|
156
|
-
} catch (
|
|
157
|
-
if (
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) return false;else throw error;
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
159
|
async appendToFile(path, data, scope) {
|
|
161
160
|
let fileId;
|
|
162
|
-
let
|
|
161
|
+
let previousContent = '';
|
|
163
162
|
try {
|
|
164
163
|
fileId = await this.getFileId(path, scope);
|
|
165
|
-
|
|
166
|
-
} catch (
|
|
167
|
-
if (
|
|
164
|
+
previousContent = await this.drive.getFileText(fileId);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
|
|
168
167
|
/* do nothing, simply create the file */
|
|
169
168
|
} else {
|
|
170
|
-
throw
|
|
169
|
+
throw error;
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
if (fileId) {
|
|
174
173
|
await this.drive.updateFile(fileId, {
|
|
175
|
-
body:
|
|
174
|
+
body: previousContent + data,
|
|
176
175
|
mimeType: MimeTypes.TEXT
|
|
177
176
|
});
|
|
178
177
|
} else {
|
|
@@ -196,22 +195,22 @@ export default class GoogleDrive {
|
|
|
196
195
|
if (overwrite) {
|
|
197
196
|
try {
|
|
198
197
|
fileId = await this.getFileId(path, scope);
|
|
199
|
-
} catch (
|
|
200
|
-
if (
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
|
|
201
200
|
/* do nothing, simply create the file */
|
|
202
201
|
} else {
|
|
203
|
-
throw
|
|
202
|
+
throw error;
|
|
204
203
|
}
|
|
205
204
|
}
|
|
206
205
|
} else {
|
|
207
206
|
try {
|
|
208
207
|
await this.getFileId(path, scope);
|
|
209
|
-
throw new CloudStorageError(`File ${path} already exists`,
|
|
210
|
-
} catch (
|
|
211
|
-
if (
|
|
208
|
+
throw new CloudStorageError(`File ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
|
|
212
211
|
/* do nothing, simply create the file */
|
|
213
212
|
} else {
|
|
214
|
-
throw
|
|
213
|
+
throw error;
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
216
|
}
|
|
@@ -238,26 +237,26 @@ export default class GoogleDrive {
|
|
|
238
237
|
}
|
|
239
238
|
async listFiles(path, scope) {
|
|
240
239
|
const allFiles = await this.drive.listFiles(this.getRootDirectory(scope));
|
|
241
|
-
if (path
|
|
240
|
+
if (path === '') {
|
|
241
|
+
const rootDirectoryId = await this.getRootDirectoryId(scope);
|
|
242
|
+
return [...new Set(allFiles.filter(f => (f.parents ?? [])[0] === rootDirectoryId).map(f => f.name))];
|
|
243
|
+
} else {
|
|
242
244
|
const fileId = await this.getFileId(path, scope);
|
|
243
245
|
const files = allFiles.filter(f => (f.parents ?? [])[0] === fileId);
|
|
244
|
-
return
|
|
245
|
-
} else {
|
|
246
|
-
const rootDirectoryId = await this.getRootDirectoryId(scope);
|
|
247
|
-
return Array.from(new Set(allFiles.filter(f => (f.parents ?? [])[0] === rootDirectoryId).map(f => f.name)));
|
|
246
|
+
return [...new Set(files.map(f => f.name))];
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
async createDirectory(path, scope) {
|
|
251
250
|
try {
|
|
252
251
|
await this.getFileId(path, scope);
|
|
253
|
-
throw new CloudStorageError(`File ${path} already exists`,
|
|
254
|
-
} catch (
|
|
255
|
-
if (
|
|
252
|
+
throw new CloudStorageError(`File ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
|
|
256
255
|
/* do nothing, simply create the file */
|
|
257
|
-
} else if (
|
|
258
|
-
throw new CloudStorageError(`Directory ${path} already exists`,
|
|
256
|
+
} else if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.PATH_IS_DIRECTORY) {
|
|
257
|
+
throw new CloudStorageError(`Directory ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
|
|
259
258
|
} else {
|
|
260
|
-
throw
|
|
259
|
+
throw error;
|
|
261
260
|
}
|
|
262
261
|
}
|
|
263
262
|
const files = await this.drive.listFiles(this.getRootDirectory(scope));
|
|
@@ -276,8 +275,8 @@ export default class GoogleDrive {
|
|
|
276
275
|
const content = await this.drive.getFileText(fileId);
|
|
277
276
|
return content;
|
|
278
277
|
}
|
|
279
|
-
async
|
|
280
|
-
//
|
|
278
|
+
async triggerSync(_path, _scope) {
|
|
279
|
+
// Triggering file synchronization in Google Drive is not necessary / possible, as they need to be downloaded on every read operation via the API anyway
|
|
281
280
|
return;
|
|
282
281
|
}
|
|
283
282
|
async deleteFile(path, scope) {
|
|
@@ -293,7 +292,7 @@ export default class GoogleDrive {
|
|
|
293
292
|
const files = await this.drive.listFiles(this.getRootDirectory(scope));
|
|
294
293
|
const filesInDirectory = files.filter(f => (f.parents ?? [])[0] === fileId);
|
|
295
294
|
if (filesInDirectory.length > 0) {
|
|
296
|
-
throw new CloudStorageError(`Directory ${path} is not empty`,
|
|
295
|
+
throw new CloudStorageError(`Directory ${path} is not empty`, NativeCloudStorageErrorCode.DELETE_ERROR, filesInDirectory);
|
|
297
296
|
}
|
|
298
297
|
}
|
|
299
298
|
await this.drive.deleteFile(fileId);
|
|
@@ -309,5 +308,63 @@ export default class GoogleDrive {
|
|
|
309
308
|
isFile: file.mimeType !== MimeTypes.FOLDER
|
|
310
309
|
};
|
|
311
310
|
}
|
|
311
|
+
async downloadFile(remotePath, localPath, scope) {
|
|
312
|
+
const fileId = await this.getFileId(remotePath, scope, 'directory');
|
|
313
|
+
try {
|
|
314
|
+
await this.drive.downloadFile(fileId, localPath);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
if (error instanceof CloudStorageError) throw error;
|
|
317
|
+
throw new CloudStorageError(`Could not download file ${remotePath} to ${localPath}`, NativeCloudStorageErrorCode.UNKNOWN, error);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async uploadFile(remotePath, localPath, mimeType, scope, overwrite) {
|
|
321
|
+
let fileId;
|
|
322
|
+
if (overwrite) {
|
|
323
|
+
try {
|
|
324
|
+
fileId = await this.getFileId(remotePath, scope);
|
|
325
|
+
} catch (error) {
|
|
326
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
|
|
327
|
+
/* File doesn't exist -> we'll create it below */
|
|
328
|
+
} else {
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
try {
|
|
334
|
+
await this.getFileId(remotePath, scope);
|
|
335
|
+
throw new CloudStorageError(`File ${remotePath} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
|
|
338
|
+
/* not found -> ok, we'll create */
|
|
339
|
+
} else if (error instanceof CloudStorageError) {
|
|
340
|
+
throw error;
|
|
341
|
+
} else {
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (fileId) {
|
|
347
|
+
// Overwrite existing file
|
|
348
|
+
await this.drive.updateFile(fileId, {
|
|
349
|
+
mimeType,
|
|
350
|
+
localPath
|
|
351
|
+
});
|
|
352
|
+
} else {
|
|
353
|
+
// Need to create a new file first
|
|
354
|
+
const files = await this.drive.listFiles(this.getRootDirectory(scope));
|
|
355
|
+
const {
|
|
356
|
+
directories,
|
|
357
|
+
filename
|
|
358
|
+
} = this.resolvePathToDirectories(remotePath);
|
|
359
|
+
const parentDirectoryId = this.findParentDirectoryId(files, directories);
|
|
360
|
+
await this.drive.createFile({
|
|
361
|
+
name: filename,
|
|
362
|
+
parents: parentDirectoryId ? [parentDirectoryId] : scope === 'app_data' ? [this.getRootDirectory(scope)] : undefined
|
|
363
|
+
}, {
|
|
364
|
+
mimeType,
|
|
365
|
+
localPath
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
312
369
|
}
|
|
313
370
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeCloudStorageErrorCode","CloudStorageError","MimeTypes","GoogleDriveApiClient","GoogleDriveHttpError","GoogleDrive","constructor","options","drive","Proxy","get","target","property","allowedFunctions","includes","toString","accessToken","length","ACCESS_TOKEN_MISSING","isCloudAvailable","getRootDirectory","scope","resolvePathToDirectories","path","startsWith","slice","endsWith","directories","split","actualFilename","pop","filename","findParentDirectoryId","files","directoryTree","possibleTopDirectories","filter","f","mimeType","FOLDER","name","topDirectoryId","id","possibleTopDirectory","some","parents","DIRECTORY_NOT_FOUND","currentDirectoryId","index","currentDirectory","find","nextDirectory","getRootDirectoryId","listFiles","file","checkIfMultipleFilesWithSameName","parentDirectoryId","strictFilenames","possibleFiles","f2","map","join","MULTIPLE_FILES_SAME_NAME","getFileId","throwIf","rootDirectoryId","FILE_NOT_FOUND","PATH_IS_DIRECTORY","error","json","status","AUTHENTICATION_FAILED","UNKNOWN","fileExists","code","appendToFile","data","fileId","previousContent","getFileText","updateFile","body","TEXT","createFile","undefined","overwrite","FILE_ALREADY_EXISTS","allFiles","Set","createDirectory","readFile","content","triggerSync","_path","_scope","deleteFile","deleteDirectory","recursive","filesInDirectory","DELETE_ERROR","statFile","getFile","size","birthtimeMs","Date","createdTime","getTime","mtimeMs","modifiedTime","isDirectory","isFile","downloadFile","remotePath","localPath","uploadFile"],"sourceRoot":"../../../../src","sources":["storages/google-drive/index.ts"],"mappings":";;AAAA,SACEA,2BAA2B,QAItB,oBAAoB;AAC3B,OAAOC,iBAAiB,MAAM,iCAAiC;AAC/D,SAASC,SAAS,QAAyD,SAAS;AACpF,OAAOC,oBAAoB,IAAIC,oBAAoB,QAAQ,UAAU;AAGrE;AACA;AACA;AACA,eAAe,MAAMC,WAAW,CAA0B;EAIxDC,WAAWA,CAACC,OAAiE,EAAE;IAC7E,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,K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"],"sourceRoot":"../../../../src","sources":["storages/google-drive/types.ts"],"mappings":";;AAEA,WAAYA,SAAS,0BAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export let NativeCloudStorageErrorCode = /*#__PURE__*/function (NativeCloudStorageErrorCode) {
|
|
4
|
+
NativeCloudStorageErrorCode["INVALID_SCOPE"] = "ERR_INVALID_SCOPE";
|
|
5
|
+
NativeCloudStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
|
|
6
|
+
NativeCloudStorageErrorCode["PATH_IS_FILE"] = "ERR_PATH_IS_FILE";
|
|
7
|
+
NativeCloudStorageErrorCode["PATH_IS_DIRECTORY"] = "ERR_PATH_IS_DIRECTORY";
|
|
8
|
+
NativeCloudStorageErrorCode["DIRECTORY_NOT_FOUND"] = "ERR_DIRECTORY_NOT_FOUND";
|
|
9
|
+
NativeCloudStorageErrorCode["DIRECTORY_NOT_EMPTY"] = "ERR_DIRECTORY_NOT_EMPTY";
|
|
10
|
+
NativeCloudStorageErrorCode["FILE_ALREADY_EXISTS"] = "ERR_FILE_EXISTS";
|
|
11
|
+
NativeCloudStorageErrorCode["MULTIPLE_FILES_SAME_NAME"] = "ERR_MULTIPLE_FILES_SAME_NAME";
|
|
12
|
+
NativeCloudStorageErrorCode["AUTHENTICATION_FAILED"] = "ERR_AUTHENTICATION_FAILED";
|
|
13
|
+
NativeCloudStorageErrorCode["WRITE_ERROR"] = "ERR_WRITE_ERROR";
|
|
14
|
+
NativeCloudStorageErrorCode["READ_ERROR"] = "ERR_READ_ERROR";
|
|
15
|
+
NativeCloudStorageErrorCode["DELETE_ERROR"] = "ERR_DELETE_ERROR";
|
|
16
|
+
NativeCloudStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
|
|
17
|
+
NativeCloudStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
|
|
18
|
+
NativeCloudStorageErrorCode["FILE_NOT_DOWNLOADABLE"] = "ERR_FILE_NOT_DOWNLOADABLE";
|
|
19
|
+
NativeCloudStorageErrorCode["ACCESS_TOKEN_MISSING"] = "ERR_ACCESS_TOKEN_MISSING";
|
|
20
|
+
NativeCloudStorageErrorCode["INVALID_URL"] = "ERR_INVALID_URL";
|
|
21
|
+
NativeCloudStorageErrorCode["NETWORK_ERROR"] = "ERR_NETWORK_ERROR";
|
|
22
|
+
return NativeCloudStorageErrorCode;
|
|
23
|
+
}({});
|
|
24
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeCloudStorageErrorCode"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":";;AAUA,WAAYA,2BAA2B,0BAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAAA,OAA3BA,2BAA2B;AAAA","ignoreList":[]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
|
|
3
5
|
class CloudStorageError extends Error {
|
|
4
6
|
constructor(message, code, details) {
|
|
5
7
|
super(message);
|
|
@@ -8,4 +10,4 @@ class CloudStorageError extends Error {
|
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
12
|
export default CloudStorageError;
|
|
11
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=cloud-storage-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CloudStorageError","Error","constructor","message","code","details"],"sourceRoot":"../../../src","sources":["utils/cloud-storage-error.ts"],"mappings":";;AAAA;;AAGA,MAAMA,iBAAiB,SAASC,KAAK,CAAC;EAIpCC,WAAWA,CAACC,OAAe,EAAEC,IAAiC,EAAEC,OAAa,EAAE;IAC7E,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;AAEA,eAAeL,iBAAiB","ignoreList":[]}
|