bedrock-ts-sdk 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1015,10 +1015,10 @@ var FileService = class {
|
|
|
1015
1015
|
try {
|
|
1016
1016
|
for (const path of filePaths) {
|
|
1017
1017
|
const file = await this.getFile(path);
|
|
1018
|
-
await aleph.updatePost(
|
|
1018
|
+
const updatedPost = await aleph.updatePost(
|
|
1019
1019
|
POST_TYPES.FILE,
|
|
1020
1020
|
file.post_hash,
|
|
1021
|
-
[
|
|
1021
|
+
[aleph.getAddress()],
|
|
1022
1022
|
FileMetaEncryptedSchema,
|
|
1023
1023
|
async (encryptedMeta) => {
|
|
1024
1024
|
const decryptedMeta = await this.decryptFileMeta(encryptedMeta);
|
|
@@ -1026,6 +1026,11 @@ var FileService = class {
|
|
|
1026
1026
|
return await this.encryptFileMeta(decryptedMeta);
|
|
1027
1027
|
}
|
|
1028
1028
|
);
|
|
1029
|
+
await aleph.updateAggregate(AGGREGATE_KEYS.FILE_ENTRIES, FileEntriesAggregateSchema, async (aggregate) => ({
|
|
1030
|
+
files: aggregate.files.map(
|
|
1031
|
+
(entry) => entry.post_hash === file.post_hash ? { ...entry, post_hash: updatedPost.item_hash } : entry
|
|
1032
|
+
)
|
|
1033
|
+
}));
|
|
1029
1034
|
}
|
|
1030
1035
|
} catch (error) {
|
|
1031
1036
|
throw new FileError(`Failed to soft delete files: ${error.message}`);
|
|
@@ -1040,10 +1045,10 @@ var FileService = class {
|
|
|
1040
1045
|
try {
|
|
1041
1046
|
for (const path of filePaths) {
|
|
1042
1047
|
const file = await this.getFile(path);
|
|
1043
|
-
await aleph.updatePost(
|
|
1048
|
+
const updatedPost = await aleph.updatePost(
|
|
1044
1049
|
POST_TYPES.FILE,
|
|
1045
1050
|
file.post_hash,
|
|
1046
|
-
[
|
|
1051
|
+
[aleph.getAddress()],
|
|
1047
1052
|
FileMetaEncryptedSchema,
|
|
1048
1053
|
async (encryptedMeta) => {
|
|
1049
1054
|
const decryptedMeta = await this.decryptFileMeta(encryptedMeta);
|
|
@@ -1051,6 +1056,11 @@ var FileService = class {
|
|
|
1051
1056
|
return await this.encryptFileMeta(decryptedMeta);
|
|
1052
1057
|
}
|
|
1053
1058
|
);
|
|
1059
|
+
await aleph.updateAggregate(AGGREGATE_KEYS.FILE_ENTRIES, FileEntriesAggregateSchema, async (aggregate) => ({
|
|
1060
|
+
files: aggregate.files.map(
|
|
1061
|
+
(entry) => entry.post_hash === file.post_hash ? { ...entry, post_hash: updatedPost.item_hash } : entry
|
|
1062
|
+
)
|
|
1063
|
+
}));
|
|
1054
1064
|
}
|
|
1055
1065
|
} catch (error) {
|
|
1056
1066
|
throw new FileError(`Failed to restore files: ${error.message}`);
|
|
@@ -1083,10 +1093,10 @@ var FileService = class {
|
|
|
1083
1093
|
try {
|
|
1084
1094
|
for (const { oldPath, newPath } of moves) {
|
|
1085
1095
|
const file = await this.getFile(oldPath);
|
|
1086
|
-
await aleph.updatePost(
|
|
1096
|
+
const updatedPost = await aleph.updatePost(
|
|
1087
1097
|
POST_TYPES.FILE,
|
|
1088
1098
|
file.post_hash,
|
|
1089
|
-
[
|
|
1099
|
+
[aleph.getAddress()],
|
|
1090
1100
|
FileMetaEncryptedSchema,
|
|
1091
1101
|
async (encryptedMeta) => {
|
|
1092
1102
|
const decryptedMeta = await this.decryptFileMeta(encryptedMeta);
|
|
@@ -1098,7 +1108,7 @@ var FileService = class {
|
|
|
1098
1108
|
const newEncryptedPath = EncryptionService.encryptEcies(newPath, publicKey);
|
|
1099
1109
|
await aleph.updateAggregate(AGGREGATE_KEYS.FILE_ENTRIES, FileEntriesAggregateSchema, async (aggregate) => ({
|
|
1100
1110
|
files: aggregate.files.map(
|
|
1101
|
-
(entry) => entry.post_hash === file.post_hash ? { ...entry, path: newEncryptedPath } : entry
|
|
1111
|
+
(entry) => entry.post_hash === file.post_hash ? { ...entry, path: newEncryptedPath, post_hash: updatedPost.item_hash } : entry
|
|
1102
1112
|
)
|
|
1103
1113
|
}));
|
|
1104
1114
|
}
|
|
@@ -1138,10 +1148,10 @@ var FileService = class {
|
|
|
1138
1148
|
const file = await this.getFile(filePath);
|
|
1139
1149
|
const encryptedKey = EncryptionService.encryptEcies(file.key, contactPublicKey);
|
|
1140
1150
|
const encryptedIv = EncryptionService.encryptEcies(file.iv, contactPublicKey);
|
|
1141
|
-
await aleph.updatePost(
|
|
1151
|
+
const updatedPost = await aleph.updatePost(
|
|
1142
1152
|
POST_TYPES.FILE,
|
|
1143
1153
|
file.post_hash,
|
|
1144
|
-
[
|
|
1154
|
+
[aleph.getAddress()],
|
|
1145
1155
|
FileMetaEncryptedSchema,
|
|
1146
1156
|
async (encryptedMeta) => {
|
|
1147
1157
|
const decryptedMeta = await this.decryptFileMeta(encryptedMeta);
|
|
@@ -1154,7 +1164,11 @@ var FileService = class {
|
|
|
1154
1164
|
);
|
|
1155
1165
|
await aleph.updateAggregate(AGGREGATE_KEYS.FILE_ENTRIES, FileEntriesAggregateSchema, async (aggregate) => ({
|
|
1156
1166
|
files: aggregate.files.map(
|
|
1157
|
-
(entry) => entry.post_hash === file.post_hash ? {
|
|
1167
|
+
(entry) => entry.post_hash === file.post_hash ? {
|
|
1168
|
+
...entry,
|
|
1169
|
+
post_hash: updatedPost.item_hash,
|
|
1170
|
+
shared_with: [.../* @__PURE__ */ new Set([...entry.shared_with, contactPublicKey])]
|
|
1171
|
+
} : entry
|
|
1158
1172
|
)
|
|
1159
1173
|
}));
|
|
1160
1174
|
} catch (error) {
|
|
@@ -1170,10 +1184,10 @@ var FileService = class {
|
|
|
1170
1184
|
const aleph = this.core.getAlephService();
|
|
1171
1185
|
try {
|
|
1172
1186
|
const file = await this.getFile(filePath);
|
|
1173
|
-
await aleph.updatePost(
|
|
1187
|
+
const updatedPost = await aleph.updatePost(
|
|
1174
1188
|
POST_TYPES.FILE,
|
|
1175
1189
|
file.post_hash,
|
|
1176
|
-
[
|
|
1190
|
+
[aleph.getAddress()],
|
|
1177
1191
|
FileMetaEncryptedSchema,
|
|
1178
1192
|
async (encryptedMeta) => {
|
|
1179
1193
|
const decryptedMeta = await this.decryptFileMeta(encryptedMeta);
|
|
@@ -1183,7 +1197,11 @@ var FileService = class {
|
|
|
1183
1197
|
);
|
|
1184
1198
|
await aleph.updateAggregate(AGGREGATE_KEYS.FILE_ENTRIES, FileEntriesAggregateSchema, async (aggregate) => ({
|
|
1185
1199
|
files: aggregate.files.map(
|
|
1186
|
-
(entry) => entry.post_hash === file.post_hash ? {
|
|
1200
|
+
(entry) => entry.post_hash === file.post_hash ? {
|
|
1201
|
+
...entry,
|
|
1202
|
+
post_hash: updatedPost.item_hash,
|
|
1203
|
+
shared_with: entry.shared_with.filter((pk) => pk !== contactPublicKey)
|
|
1204
|
+
} : entry
|
|
1187
1205
|
)
|
|
1188
1206
|
}));
|
|
1189
1207
|
} catch (error) {
|