@functionland/react-native-fula 0.4.2 → 1.1.4

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 (66) hide show
  1. package/README.md +99 -9
  2. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  6. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  7. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  13. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/android/.gradle/file-system.probe +0 -0
  15. package/android/.idea/jarRepositories.xml +9 -9
  16. package/android/.idea/sonarlint/issuestore/index.pb +0 -0
  17. package/android/build.gradle +7 -5
  18. package/android/gradle/wrapper/gradle-wrapper.properties +7 -6
  19. package/android/gradle.properties +1 -1
  20. package/android/gradlew +53 -2
  21. package/android/local.properties +1 -1
  22. package/android/src/main/java/land/fx/fula/FulaModule.java +840 -72
  23. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  24. package/lib/commonjs/index.js +5 -1
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/interfaces/api-lookup.js +1653 -0
  27. package/lib/commonjs/interfaces/api-lookup.js.map +1 -0
  28. package/lib/commonjs/interfaces/fulaNativeModule.js +1 -1
  29. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  30. package/lib/commonjs/protocols/blockchain.js +404 -0
  31. package/lib/commonjs/protocols/blockchain.js.map +1 -0
  32. package/lib/commonjs/protocols/chain-api.js +87 -0
  33. package/lib/commonjs/protocols/chain-api.js.map +1 -0
  34. package/lib/commonjs/protocols/fula.js +120 -7
  35. package/lib/commonjs/protocols/fula.js.map +1 -1
  36. package/lib/commonjs/types/blockchain.js +2 -0
  37. package/lib/commonjs/types/blockchain.js.map +1 -0
  38. package/lib/module/index.js +4 -0
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/interfaces/api-lookup.js +1648 -0
  41. package/lib/module/interfaces/api-lookup.js.map +1 -0
  42. package/lib/module/interfaces/fulaNativeModule.js +1 -1
  43. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  44. package/lib/module/protocols/blockchain.js +383 -0
  45. package/lib/module/protocols/blockchain.js.map +1 -0
  46. package/lib/module/protocols/chain-api.js +76 -0
  47. package/lib/module/protocols/chain-api.js.map +1 -0
  48. package/lib/module/protocols/fula.js +110 -4
  49. package/lib/module/protocols/fula.js.map +1 -1
  50. package/lib/module/types/blockchain.js +2 -0
  51. package/lib/module/types/blockchain.js.map +1 -0
  52. package/lib/typescript/index.d.ts +2 -0
  53. package/lib/typescript/interfaces/api-lookup.d.ts +1643 -0
  54. package/lib/typescript/interfaces/fulaNativeModule.d.ts +40 -3
  55. package/lib/typescript/protocols/blockchain.d.ts +17 -0
  56. package/lib/typescript/protocols/chain-api.d.ts +6 -0
  57. package/lib/typescript/protocols/fula.d.ts +52 -2
  58. package/lib/typescript/types/blockchain.d.ts +68 -0
  59. package/package.json +13 -8
  60. package/src/index.tsx +3 -1
  61. package/src/interfaces/api-lookup.ts +1647 -0
  62. package/src/interfaces/fulaNativeModule.ts +50 -7
  63. package/src/protocols/blockchain.ts +460 -0
  64. package/src/protocols/chain-api.ts +80 -0
  65. package/src/protocols/fula.ts +157 -12
  66. package/src/types/blockchain.ts +81 -0
@@ -11,10 +11,77 @@ export const init = (
11
11
  identity: string, //privateKey of did identity
12
12
  storePath: string,
13
13
  bloxAddr: string,
14
- exchange: string
15
- ): Promise<[string, string, string]> => {
16
- console.log('init in react-native started',identity, storePath, bloxAddr, exchange);
17
- return Fula.init(identity, storePath, bloxAddr, exchange);
14
+ exchange: string,
15
+ autoFlush: boolean = false,
16
+ rootCid: string | null = null,
17
+ useRelay: boolean = true,
18
+ refresh: boolean = false
19
+ ): Promise<{ peerId: string; rootCid: string; private_ref: string }> => {
20
+ console.log(
21
+ 'init in react-native started',
22
+ identity,
23
+ storePath,
24
+ bloxAddr,
25
+ exchange,
26
+ autoFlush,
27
+ useRelay
28
+ );
29
+ return Fula.init(identity, storePath, bloxAddr, exchange, autoFlush, rootCid, useRelay, refresh);
30
+ };
31
+
32
+ /**
33
+ * Get gets the value corresponding to the given key from the local datastore.
34
+ // The key must be a valid ipld.Link.
35
+ * @param config
36
+ * @returns boolean
37
+ */
38
+
39
+ export const newClient = (
40
+ identity: string, //privateKey of did identity
41
+ storePath: string,
42
+ bloxAddr: string,
43
+ exchange: string,
44
+ autoFlush: boolean = false,
45
+ useRelay: boolean = true
46
+ ): Promise<string> => {
47
+ console.log(
48
+ 'newClient in react-native started',
49
+ identity,
50
+ storePath,
51
+ bloxAddr,
52
+ exchange,
53
+ autoFlush,
54
+ useRelay
55
+ );
56
+ return Fula.newClient(identity, storePath, bloxAddr, exchange, autoFlush, useRelay);
57
+ };
58
+
59
+ /**
60
+ * rm removes all data
61
+ * @param path
62
+ * @returns string: new cid of the root
63
+ */
64
+ export const logout = (
65
+ identity: string,
66
+ storePath: string
67
+ ): Promise<boolean> => {
68
+ return Fula.logout(identity, storePath);
69
+ };
70
+
71
+ /**
72
+ * Checks if there are any un-synced changes on the device
73
+ */
74
+ export const checkFailedActions = (
75
+ retry: boolean = false
76
+ ): Promise<boolean> => {
77
+ return Fula.checkFailedActions(retry);
78
+ };
79
+
80
+ /**
81
+ * Checks if there are any un-synced changes on the device
82
+ */
83
+ export const checkConnection = (): Promise<boolean> => {
84
+ return Fula.checkConnection();
18
85
  };
19
86
 
20
87
  /**
@@ -73,18 +140,25 @@ export const mkdir = (path: string): Promise<string> => {
73
140
  * @param path
74
141
  * @returns string: new cid of the root
75
142
  */
76
- export const writeFileContent = (path: string, content: string): Promise<string> => {
143
+ export const writeFileContent = (
144
+ path: string,
145
+ content: string
146
+ ): Promise<string> => {
77
147
  return Fula.writeFileContent(path, content);
78
148
  };
79
149
 
80
150
  /*
81
151
  // reads content of the file form localFilename (should include full absolute path to local file with read permission
82
152
  // writes content to the specified location by fulaTargetFilename in Fula filesystem
153
+ // It keeps the original file modiifcation date
83
154
  // fulaTargetFilename: a string including full path and filename of target file on Fula (e.g. root/pictures/cat.jpg)
84
155
  // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
85
156
  // Returns: new cid of the root after this file is placed in the tree
86
157
  */
87
- export const writeFile = (fulaTargetFilename: string, localFilename: string): Promise<string> => {
158
+ export const writeFile = (
159
+ fulaTargetFilename: string,
160
+ localFilename: string
161
+ ): Promise<string> => {
88
162
  return Fula.writeFile(fulaTargetFilename, localFilename);
89
163
  };
90
164
 
@@ -94,8 +168,35 @@ export const writeFile = (fulaTargetFilename: string, localFilename: string): Pr
94
168
  * @returns string: list of items
95
169
  * TODO: Findout how is the string and convert to array
96
170
  */
97
- export const ls = (path: string): Promise<string> => {
98
- return Fula.ls(path);
171
+ export const ls = (path: string): Promise<void | JSON> => {
172
+ return Fula.ls(path)
173
+ .then((res) => {
174
+ let lsResult = [];
175
+ let lsRows = res.split('!!!');
176
+ for (const element of lsRows) {
177
+ let rowItems = element.split('???');
178
+ if (rowItems && rowItems[0]) {
179
+ let item = {
180
+ name: '',
181
+ created: '',
182
+ modified: '',
183
+ };
184
+ item.name = rowItems[0];
185
+ if (rowItems[1]) {
186
+ item.created = rowItems[1];
187
+ }
188
+ if (rowItems[2]) {
189
+ item.modified = rowItems[2];
190
+ }
191
+ lsResult.push(item);
192
+ }
193
+ }
194
+ let jsonRes = JSON.parse(JSON.stringify(lsResult));
195
+ return jsonRes;
196
+ })
197
+ .catch((e) => {
198
+ return e;
199
+ });
99
200
  };
100
201
 
101
202
  /**
@@ -107,6 +208,24 @@ export const rm = (path: string): Promise<string> => {
107
208
  return Fula.rm(path);
108
209
  };
109
210
 
211
+ /**
212
+ * cp copies the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
213
+ * @param sourcePath, targetPath
214
+ * @returns string: new cid of the root
215
+ */
216
+ export const cp = (sourcePath: string, targetPath: string): Promise<string> => {
217
+ return Fula.cp(sourcePath, targetPath);
218
+ };
219
+
220
+ /**
221
+ * mv moves the file or folder at the sourcePath to targetPath. targetPath is a folder that must exist already
222
+ * @param sourcePath, targetPath
223
+ * @returns string: new cid of the root
224
+ */
225
+ export const mv = (sourcePath: string, targetPath: string): Promise<string> => {
226
+ return Fula.mv(sourcePath, targetPath);
227
+ };
228
+
110
229
  /*
111
230
  // reads content of the file form localFilename (should include full absolute path to local file with read permission
112
231
  // writes content to the specified location by fulaTargetFilename in Fula filesystem
@@ -114,16 +233,19 @@ export const rm = (path: string): Promise<string> => {
114
233
  // localFilename: a string containing full path and filename of local file on hte device (e.g /usr/bin/cat.jpg)
115
234
  // Returns: new cid of the root after this file is placed in the tree
116
235
  */
117
- export const readFile = (fulaTargetFilename: string, localFilename: string): Promise<string> => {
118
- return Fula.readFile(fulaTargetFilename, localFilename);
119
- };
236
+ export const readFile = (
237
+ fulaTargetFilename: string,
238
+ localFilename: string
239
+ ): Promise<string> => {
240
+ return Fula.readFile(fulaTargetFilename, localFilename);
241
+ };
120
242
 
121
243
  /**
122
244
  * readFile reads content of a given path
123
245
  * @param path
124
246
  * @returns string: cotent
125
247
  */
126
- export const readFileContent = (path: string): Promise<string> => {
248
+ export const readFileContent = (path: string): Promise<string> => {
127
249
  return Fula.readFileContent(path);
128
250
  };
129
251
 
@@ -136,3 +258,26 @@ export const rm = (path: string): Promise<string> => {
136
258
  export const shutdown = (): Promise<void> => {
137
259
  return Fula.shutdown();
138
260
  };
261
+
262
+ /**
263
+ * setAuth adds or removes a peer from the list of peers that are allowed to push to this node.
264
+ * This can only be called on a peer that is added as an owner of blox by --authorizer parameter
265
+ * @param peerId, allow
266
+ * @returns boolean: true if successful or false if not
267
+ */
268
+ export const setAuth = (
269
+ peerId: string,
270
+ allow: boolean
271
+ ): Promise<boolean> => {
272
+ return Fula.setAuth(peerId, allow);
273
+ };
274
+
275
+
276
+ /**
277
+ * isReady checks if the connection is ready to be used.
278
+ * @param filesystemCheck: also check if the wnfs is ready
279
+ * @returns boolean: true if ready or false if not
280
+ */
281
+ export const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {
282
+ return Fula.isReady(filesystemCheck);
283
+ };
@@ -0,0 +1,81 @@
1
+ export interface SeededResponse {
2
+ seed: string;
3
+ account: string;
4
+ }
5
+
6
+ export interface AccountExistsResponse {
7
+ account: string;
8
+ exists: boolean;
9
+ }
10
+
11
+ export interface PoolCreateResponse {
12
+ owner: string;
13
+ poolID: number;
14
+ }
15
+
16
+ export interface PoolJoinResponse {
17
+ account: string;
18
+ poolID: number;
19
+ }
20
+
21
+ export interface PoolCancelJoinResponse {
22
+ account: string;
23
+ poolID: number;
24
+ }
25
+
26
+ export interface PoolRequestsResponse {
27
+ poolRequests: PoolRequest[];
28
+ }
29
+
30
+ export interface PoolListResponse {
31
+ pools: Pool[];
32
+ }
33
+
34
+ export interface PoolVoteResponse {
35
+ account: string;
36
+ poolID: number;
37
+ }
38
+
39
+ export interface PoolLeaveResponse {
40
+ account: string;
41
+ poolID: number;
42
+ }
43
+
44
+ export interface ManifestUploadResponse {
45
+ uploader: string;
46
+ storage: string[];
47
+ manifestMetadata: ManifestMetadata;
48
+ poolID: number;
49
+ }
50
+
51
+ export interface PoolRequest {
52
+ poolID: number;
53
+ account: string;
54
+ voted: string[];
55
+ positiveVotes: number;
56
+ peerID: string;
57
+ }
58
+
59
+ export interface Pool {
60
+ poolID: number;
61
+ owner: string;
62
+ poolName: string;
63
+ parent: string;
64
+ participants: string[];
65
+ }
66
+
67
+ export interface ManifestMetadata {
68
+ job: ManifestJob;
69
+ }
70
+
71
+ export interface ManifestJob {
72
+ work: string;
73
+ engine: string;
74
+ uri: string;
75
+ }
76
+ export interface BloxFreeSpaceResponse {
77
+ size: number;
78
+ avail: number;
79
+ used: number;
80
+ used_percentage: number;
81
+ }