@seedprotocol/sdk 0.1.122 → 0.1.124
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/dist/{index-D30kap8f.js → index-B_wcyM6Y.js} +93 -38
- package/dist/index-B_wcyM6Y.js.map +1 -0
- package/dist/{index-IgTStLC1.js → index-Bh9mwpKP.js} +2 -2
- package/dist/index-Bh9mwpKP.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-BHoBrAJe.js → seed.schema.config-B_quI2AB.js} +2 -2
- package/dist/{seed.schema.config-BHoBrAJe.js.map → seed.schema.config-B_quI2AB.js.map} +1 -1
- package/dist/src/ItemProperty.ts +37 -30
- package/dist/src/download.ts +67 -4
- package/dist/src/hydrateFromDb.ts +8 -0
- package/dist/src/index.ts +4 -21
- package/dist/src/saveItemStorage.ts +5 -1
- package/dist/types/src/browser/events/files/download.d.ts.map +1 -1
- package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-D30kap8f.js.map +0 -1
- package/dist/index-IgTStLC1.js.map +0 -1
|
@@ -917,15 +917,7 @@ class ItemProperty {
|
|
|
917
917
|
return;
|
|
918
918
|
}
|
|
919
919
|
const { context } = snapshot;
|
|
920
|
-
|
|
921
|
-
// context.propertyName &&
|
|
922
|
-
// context.propertyName.includes('featureImage')
|
|
923
|
-
// ) {
|
|
924
|
-
// console.log(
|
|
925
|
-
// `${context.localId} context for ${snapshot.value}`,
|
|
926
|
-
// context,
|
|
927
|
-
// )
|
|
928
|
-
// }
|
|
920
|
+
const { propertyRecordSchema } = context;
|
|
929
921
|
if (context.seedLocalId) {
|
|
930
922
|
const cacheKey = ItemProperty.cacheKey(context.seedLocalId, context.propertyName);
|
|
931
923
|
if (!ItemProperty.instanceCache.has(cacheKey)) {
|
|
@@ -940,27 +932,32 @@ class ItemProperty {
|
|
|
940
932
|
// this._updateResponseListener,
|
|
941
933
|
// )
|
|
942
934
|
}
|
|
935
|
+
if (context.seedUid ===
|
|
936
|
+
'0x66922b8f40057eb04f94983d59a608e32bceb95b47134dd5b550688940c64f1d' &&
|
|
937
|
+
propertyName === 'featureImage') {
|
|
938
|
+
console.log('context', context);
|
|
939
|
+
}
|
|
943
940
|
let renderValue;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
941
|
+
if (propertyRecordSchema &&
|
|
942
|
+
propertyRecordSchema.storageType &&
|
|
943
|
+
propertyRecordSchema.storageType === 'ItemStorage' &&
|
|
944
|
+
context.refResolvedValue &&
|
|
945
|
+
context.localStorageDir) {
|
|
946
|
+
const filePath = `/files/${context.localStorageDir}/${context.refResolvedValue}`;
|
|
947
|
+
try {
|
|
948
|
+
const exists = yield fs.promises.exists(filePath);
|
|
949
|
+
if (exists) {
|
|
950
|
+
renderValue = yield fs.promises.readFile(filePath, 'utf-8');
|
|
951
|
+
}
|
|
952
|
+
if (!exists) {
|
|
953
|
+
renderValue = 'No file found';
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
catch (e) {
|
|
957
|
+
logger$o(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
958
|
+
renderValue = 'No file found';
|
|
959
|
+
}
|
|
960
|
+
}
|
|
964
961
|
if (!renderValue) {
|
|
965
962
|
renderValue = context.renderValue || context.propertyValue;
|
|
966
963
|
}
|
|
@@ -976,6 +973,9 @@ class ItemProperty {
|
|
|
976
973
|
transformedPropertyName = this._alias;
|
|
977
974
|
}
|
|
978
975
|
if (skipTransform && !this._alias) ;
|
|
976
|
+
if (this._subject.value === renderValue) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
979
|
this._subject.next(renderValue);
|
|
980
980
|
if (context.seedLocalId) {
|
|
981
981
|
eventEmitter.emit(`item.${modelName}.${context.seedLocalId}.update`);
|
|
@@ -2114,7 +2114,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2114
2114
|
if (!models$1) {
|
|
2115
2115
|
return;
|
|
2116
2116
|
}
|
|
2117
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2117
|
+
const { models: SeedModels } = yield import('./seed.schema.config-B_quI2AB.js');
|
|
2118
2118
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2119
2119
|
let hasModelsInDb = false;
|
|
2120
2120
|
const schemaDefsByModelName = new Map();
|
|
@@ -3300,7 +3300,10 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3300
3300
|
yield saveAppState('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
3301
3301
|
continue;
|
|
3302
3302
|
}
|
|
3303
|
-
|
|
3303
|
+
if (transactionId === 'ZXnDkNk_PHRl5Yqu90kEJn_R3LS3Tl9P8eLtlJTqB-M') {
|
|
3304
|
+
console.log('transactionId', transactionId);
|
|
3305
|
+
}
|
|
3306
|
+
const { tags: tagsResult } = yield queryClient.fetchQuery({
|
|
3304
3307
|
queryKey: ['getTransactionTags', transactionId],
|
|
3305
3308
|
queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3306
3309
|
return arweaveClient.request(GET_TRANSACTION_TAGS, {
|
|
@@ -3308,7 +3311,8 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3308
3311
|
});
|
|
3309
3312
|
}),
|
|
3310
3313
|
});
|
|
3311
|
-
|
|
3314
|
+
const tags = tagsResult.tags || [];
|
|
3315
|
+
if (tagsResult.tags && tagsResult.tags.length > 0) {
|
|
3312
3316
|
for (const { name, value } of tags) {
|
|
3313
3317
|
if (name === 'Content-SHA-256') {
|
|
3314
3318
|
const metadataRecord = yield getMetadata({
|
|
@@ -3322,21 +3326,62 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3322
3326
|
}
|
|
3323
3327
|
}
|
|
3324
3328
|
}
|
|
3325
|
-
const
|
|
3329
|
+
const data = yield queryClient.fetchQuery({
|
|
3326
3330
|
queryKey: ['fetchTransaction', transactionId],
|
|
3327
3331
|
queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3328
3332
|
const response = yield fetch(`https://${ARWEAVE_HOST}/raw/${transactionId}`);
|
|
3333
|
+
const responseContentType = response.headers.get('Content-Type');
|
|
3334
|
+
console.log('Content type', responseContentType);
|
|
3335
|
+
if (responseContentType === 'application/octet-stream') {
|
|
3336
|
+
return yield response.arrayBuffer();
|
|
3337
|
+
}
|
|
3329
3338
|
return yield response.text();
|
|
3330
3339
|
}),
|
|
3331
3340
|
networkMode: 'offlineFirst',
|
|
3332
3341
|
});
|
|
3342
|
+
let dataString;
|
|
3343
|
+
let arrayBuffer;
|
|
3344
|
+
if (data instanceof ArrayBuffer) {
|
|
3345
|
+
arrayBuffer = data;
|
|
3346
|
+
}
|
|
3347
|
+
if (typeof data === 'string') {
|
|
3348
|
+
dataString = data;
|
|
3349
|
+
}
|
|
3333
3350
|
// const dataString = await arweave.transactions.getData(transactionId, {
|
|
3334
3351
|
// decode: true,
|
|
3335
3352
|
// string: true,
|
|
3336
3353
|
// })
|
|
3337
|
-
if (!dataString) {
|
|
3354
|
+
if (!dataString && !arrayBuffer) {
|
|
3338
3355
|
logger$f(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not found`);
|
|
3339
3356
|
}
|
|
3357
|
+
if (dataString && dataString.startsWith('===FILE_SEPARATOR===')) {
|
|
3358
|
+
const dataStringParts = dataString
|
|
3359
|
+
.split('===FILE_SEPARATOR===')
|
|
3360
|
+
.slice(1);
|
|
3361
|
+
if (dataStringParts.length % 2 !== 0) {
|
|
3362
|
+
throw new Error('Input array must have an even number of elements.');
|
|
3363
|
+
}
|
|
3364
|
+
for (let i = 0; i < dataStringParts.length; i += 2) {
|
|
3365
|
+
const contentType = dataStringParts[i];
|
|
3366
|
+
const content = dataStringParts[i + 1];
|
|
3367
|
+
if (contentType === 'html') {
|
|
3368
|
+
const fileName = `${transactionId}.html`;
|
|
3369
|
+
yield fs.promises.writeFile(`/files/html/${fileName}`, content);
|
|
3370
|
+
}
|
|
3371
|
+
if (contentType === 'json') {
|
|
3372
|
+
const fileName = `${transactionId}.json`;
|
|
3373
|
+
yield fs.promises.writeFile(`/files/json/${fileName}`, content);
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
continue;
|
|
3377
|
+
}
|
|
3378
|
+
if (!dataString && arrayBuffer) {
|
|
3379
|
+
yield fs.promises.writeFile(`/files/images/${transactionId}`, new Uint8Array(arrayBuffer));
|
|
3380
|
+
continue;
|
|
3381
|
+
}
|
|
3382
|
+
if (!dataString) {
|
|
3383
|
+
continue;
|
|
3384
|
+
}
|
|
3340
3385
|
let contentType = identifyString(dataString);
|
|
3341
3386
|
if (contentType !== 'json' &&
|
|
3342
3387
|
contentType !== 'base64' &&
|
|
@@ -6564,7 +6609,7 @@ const client = {
|
|
|
6564
6609
|
addresses,
|
|
6565
6610
|
arweaveDomain,
|
|
6566
6611
|
});
|
|
6567
|
-
import('./seed.schema.config-
|
|
6612
|
+
import('./seed.schema.config-B_quI2AB.js').then(({ models }) => {
|
|
6568
6613
|
for (const [key, value] of Object.entries(models)) {
|
|
6569
6614
|
setModel(key, value);
|
|
6570
6615
|
}
|
|
@@ -7142,6 +7187,11 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
7142
7187
|
if (seedUidFromDb !== seedUid) {
|
|
7143
7188
|
logger$1(`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`);
|
|
7144
7189
|
}
|
|
7190
|
+
if (seedUidFromDb ===
|
|
7191
|
+
'0x66922b8f40057eb04f94983d59a608e32bceb95b47134dd5b550688940c64f1d' &&
|
|
7192
|
+
propertyName === 'featureImage') {
|
|
7193
|
+
console.log('Property featureImage', firstRow);
|
|
7194
|
+
}
|
|
7145
7195
|
if (propertyRecordSchema &&
|
|
7146
7196
|
propertyRecordSchema.refValueType === 'ImageSrc') {
|
|
7147
7197
|
let shouldReadFromFile = true;
|
|
@@ -7239,7 +7289,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
7239
7289
|
if (propertyRecordSchema &&
|
|
7240
7290
|
propertyRecordSchema.storageType &&
|
|
7241
7291
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
7242
|
-
const { Item } = yield import('./index-
|
|
7292
|
+
const { Item } = yield import('./index-Bh9mwpKP.js');
|
|
7243
7293
|
const item = yield Item.find({
|
|
7244
7294
|
seedLocalId,
|
|
7245
7295
|
modelName,
|
|
@@ -7824,7 +7874,12 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
|
|
|
7824
7874
|
throw new Error(`Missing localStorageDir: ${localStorageDir} or fileName: ${fileName}`);
|
|
7825
7875
|
}
|
|
7826
7876
|
const filePath = `/files/${localStorageDir}/${fileName}`;
|
|
7827
|
-
|
|
7877
|
+
try {
|
|
7878
|
+
yield fs.promises.writeFile(filePath, newValue);
|
|
7879
|
+
}
|
|
7880
|
+
catch (error) {
|
|
7881
|
+
fs.writeFileSync(filePath, newValue);
|
|
7882
|
+
}
|
|
7828
7883
|
yield appDb
|
|
7829
7884
|
.update(metadata)
|
|
7830
7885
|
.set({
|
|
@@ -8181,4 +8236,4 @@ if (isNode()) {
|
|
|
8181
8236
|
}
|
|
8182
8237
|
|
|
8183
8238
|
export { GET_SCHEMAS as G, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, GET_SCHEMA_BY_NAME as a, GET_SEEDS as b, GET_SEED_IDS as c, GET_STORAGE_TRANSACTION_ID as d, GET_VERSIONS as e, GET_PROPERTIES as f, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as g, itemMachineAll as h, itemMachineSingle as i, ImageSrc as j, ItemProperty as k, useItem as l, useItemProperties as m, useCreateItem as n, useItemProperty as o, useDeleteItem as p, useGlobalServiceStatus as q, useServices as r, getGlobalService as s, client as t, useItems as u, getCorrectId as v, withSeed as w };
|
|
8184
|
-
//# sourceMappingURL=index-
|
|
8239
|
+
//# sourceMappingURL=index-B_wcyM6Y.js.map
|