@seedprotocol/sdk 0.1.83 → 0.1.85
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-dP9lYpUp.js → index-BFSW1upn.js} +2 -2
- package/dist/{index-dP9lYpUp.js.map → index-BFSW1upn.js.map} +1 -1
- package/dist/{index-LeMH3hHu.js → index-D0rjBEnK.js} +47 -50
- package/dist/index-D0rjBEnK.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-D-amxDm7.js → seed.schema.config-DjUwnjlb.js} +2 -2
- package/dist/{seed.schema.config-D-amxDm7.js.map → seed.schema.config-DjUwnjlb.js.map} +1 -1
- package/dist/src/actors.ts +289 -7
- package/dist/src/dbMachine.ts +1 -6
- package/dist/src/download.ts +6 -3
- package/dist/src/hydrateFromDb.ts +0 -1
- package/dist/src/index.ts +62 -10
- package/dist/src/syncDbWithEas.ts +12 -3
- package/dist/src/waitForFiles.ts +1 -1
- package/dist/types/src/browser/db/read/subqueries/versionData.d.ts +16 -4
- package/dist/types/src/browser/db/read/subqueries/versionData.d.ts.map +1 -1
- package/dist/types/src/browser/events/files/download.d.ts.map +1 -1
- package/dist/types/src/browser/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/browser/services/db/dbMachine.d.ts.map +1 -1
- package/dist/types/src/shared/helpers/files.d.ts +1 -1
- package/dist/types/src/shared/helpers/files.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/AppStateSchema.d.ts +12 -4
- package/dist/types/src/shared/seedSchema/AppStateSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/ConfigSchema.d.ts +16 -7
- package/dist/types/src/shared/seedSchema/ConfigSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/MetadataSchema.d.ts +82 -22
- package/dist/types/src/shared/seedSchema/MetadataSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/ModelSchema.d.ts +32 -10
- package/dist/types/src/shared/seedSchema/ModelSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/ModelUidSchema.d.ts +8 -3
- package/dist/types/src/shared/seedSchema/ModelUidSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/PropertyUidSchema.d.ts +8 -3
- package/dist/types/src/shared/seedSchema/PropertyUidSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/SeedSchema.d.ts +28 -9
- package/dist/types/src/shared/seedSchema/SeedSchema.d.ts.map +1 -1
- package/dist/types/src/shared/seedSchema/VersionSchema.d.ts +34 -10
- package/dist/types/src/shared/seedSchema/VersionSchema.d.ts.map +1 -1
- package/package.json +50 -50
- package/dist/index-LeMH3hHu.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-
|
|
1
|
+
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-D0rjBEnK.js';
|
|
2
2
|
import './constants-rmQ8zg8_.js';
|
|
3
3
|
import '@ethereum-attestation-service/eas-sdk';
|
|
4
4
|
import 'thirdweb';
|
|
@@ -29,4 +29,4 @@ import 'rxjs';
|
|
|
29
29
|
import 'drizzle-orm/sqlite-proxy';
|
|
30
30
|
import '@zenfs/dom';
|
|
31
31
|
import 'arweave';
|
|
32
|
-
//# sourceMappingURL=index-
|
|
32
|
+
//# sourceMappingURL=index-BFSW1upn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BFSW1upn.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,14 +2,14 @@ import { b as __awaiter, d as __rest, i as internalPropertyNames, I as INTERNAL_
|
|
|
2
2
|
import path, { basename } from 'path';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { Type } from '@sinclair/typebox';
|
|
5
|
-
import { fromCallback, assign, createActor, waitFor, setup,
|
|
5
|
+
import { fromCallback, assign, createActor, waitFor, setup, raise } from 'xstate';
|
|
6
6
|
import { sql, relations, and, eq, max, or, count, isNotNull, isNull, gt, inArray, like, getTableColumns } from 'drizzle-orm';
|
|
7
7
|
import { fs, configureSingle } from '@zenfs/core';
|
|
8
8
|
import 'dayjs';
|
|
9
9
|
import { customAlphabet } from 'nanoid';
|
|
10
10
|
import * as nanoIdDictionary from 'nanoid-dictionary';
|
|
11
11
|
import debug from 'debug';
|
|
12
|
-
import { startCase,
|
|
12
|
+
import { startCase, throttle, camelCase, orderBy } from 'lodash-es';
|
|
13
13
|
import { sqliteTable, text, int, blob, check, unique } from 'drizzle-orm/sqlite-core';
|
|
14
14
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
15
15
|
import { QueryClient } from '@tanstack/react-query';
|
|
@@ -1031,7 +1031,6 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1031
1031
|
refResolvedDisplayValue = URL.createObjectURL(fileHandler);
|
|
1032
1032
|
yield updateMetadata({
|
|
1033
1033
|
localId,
|
|
1034
|
-
refResolvedDisplayValue,
|
|
1035
1034
|
refResolvedValue: filename,
|
|
1036
1035
|
});
|
|
1037
1036
|
}
|
|
@@ -1062,7 +1061,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1062
1061
|
if (propertyRecordSchema &&
|
|
1063
1062
|
propertyRecordSchema.storageType &&
|
|
1064
1063
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1065
|
-
const { Item } = yield import('./index-
|
|
1064
|
+
const { Item } = yield import('./index-BFSW1upn.js');
|
|
1066
1065
|
const item = yield Item.find({
|
|
1067
1066
|
seedLocalId,
|
|
1068
1067
|
modelName: itemModelName,
|
|
@@ -2290,7 +2289,12 @@ const createMetadataRecordsForStorageTransactionId = (storageTransactionIdProper
|
|
|
2290
2289
|
});
|
|
2291
2290
|
}
|
|
2292
2291
|
});
|
|
2292
|
+
let isSavingToDb = false;
|
|
2293
2293
|
const saveEasPropertiesToDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ itemProperties, itemSeeds, }) {
|
|
2294
|
+
if (isSavingToDb) {
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
isSavingToDb = true;
|
|
2294
2298
|
const propertyUids = itemProperties.map((property) => property.id);
|
|
2295
2299
|
const models = getModels();
|
|
2296
2300
|
const appDb = getAppDb();
|
|
@@ -2411,6 +2415,7 @@ const saveEasPropertiesToDb = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
2411
2415
|
insertPropertiesQuery = insertPropertiesQuery.slice(0, -2) + ';';
|
|
2412
2416
|
}
|
|
2413
2417
|
yield appDb.run(sql.raw(insertPropertiesQuery));
|
|
2418
|
+
isSavingToDb = false;
|
|
2414
2419
|
return { propertyUids };
|
|
2415
2420
|
});
|
|
2416
2421
|
const getRelatedSeedsAndVersions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -2443,7 +2448,7 @@ const getRelatedSeedsAndVersions = () => __awaiter(void 0, void 0, void 0, funct
|
|
|
2443
2448
|
itemSeeds,
|
|
2444
2449
|
});
|
|
2445
2450
|
});
|
|
2446
|
-
const syncDbWithEasHandler =
|
|
2451
|
+
const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2447
2452
|
const appDb = getAppDb();
|
|
2448
2453
|
const { modelSchemas, schemaStringToModelRecord } = yield getModelSchemas();
|
|
2449
2454
|
if (!modelSchemas ||
|
|
@@ -2513,7 +2518,7 @@ const syncDbWithEasHandler = debounce((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
2513
2518
|
for (const modelName of getModelNames()) {
|
|
2514
2519
|
eventEmitter.emit('item.requestAll', { modelName });
|
|
2515
2520
|
}
|
|
2516
|
-
}),
|
|
2521
|
+
}), 30000, {
|
|
2517
2522
|
leading: true,
|
|
2518
2523
|
trailing: false,
|
|
2519
2524
|
});
|
|
@@ -2624,7 +2629,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2624
2629
|
if (!models$1) {
|
|
2625
2630
|
return;
|
|
2626
2631
|
}
|
|
2627
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2632
|
+
const { models: SeedModels } = yield import('./seed.schema.config-DjUwnjlb.js');
|
|
2628
2633
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2629
2634
|
let hasModelsInDb = false;
|
|
2630
2635
|
const schemaDefsByModelName = new Map();
|
|
@@ -3174,11 +3179,6 @@ const dbMachine = setup({
|
|
|
3174
3179
|
},
|
|
3175
3180
|
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
3176
3181
|
},
|
|
3177
|
-
entry: ({ context }) => {
|
|
3178
|
-
if (context.hasFiles) {
|
|
3179
|
-
emit({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
3180
|
-
}
|
|
3181
|
-
},
|
|
3182
3182
|
},
|
|
3183
3183
|
[MIGRATING]: {
|
|
3184
3184
|
on: {
|
|
@@ -3756,7 +3756,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3756
3756
|
});
|
|
3757
3757
|
}),
|
|
3758
3758
|
});
|
|
3759
|
-
if (tags && tags.length
|
|
3759
|
+
if (tags && tags.length > 0) {
|
|
3760
3760
|
for (const { name, value } of tags) {
|
|
3761
3761
|
if (name === 'Content-SHA-256') {
|
|
3762
3762
|
const metadataRecord = yield getMetadata({
|
|
@@ -3776,7 +3776,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3776
3776
|
const response = yield fetch(`https://${ARWEAVE_HOST}/raw/${transactionId}`);
|
|
3777
3777
|
return yield response.text();
|
|
3778
3778
|
}),
|
|
3779
|
-
networkMode:
|
|
3779
|
+
networkMode: 'offlineFirst',
|
|
3780
3780
|
});
|
|
3781
3781
|
// const dataString = await arweave.transactions.getData(transactionId, {
|
|
3782
3782
|
// decode: true,
|
|
@@ -3823,45 +3823,42 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3823
3823
|
let fileExtension = mimeType;
|
|
3824
3824
|
if (fileExtension && (fileExtension === null || fileExtension === void 0 ? void 0 : fileExtension.startsWith('image'))) {
|
|
3825
3825
|
fileExtension = fileExtension.replace('image/', '');
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
}
|
|
3831
|
-
// Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
|
|
3832
|
-
const base64Data = dataString.split(',').pop() || '';
|
|
3833
|
-
// Decode the Base64 string to binary
|
|
3834
|
-
const binaryString = atob(base64Data);
|
|
3835
|
-
const length = binaryString.length;
|
|
3836
|
-
const binaryData = new Uint8Array(length);
|
|
3837
|
-
for (let i = 0; i < length; i++) {
|
|
3838
|
-
binaryData[i] = binaryString.charCodeAt(i);
|
|
3839
|
-
}
|
|
3840
|
-
yield fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
|
|
3841
|
-
encoding: 'binary',
|
|
3842
|
-
});
|
|
3843
|
-
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
3844
|
-
// await fs.promises.writeFile(
|
|
3845
|
-
// `/files/images/${fileName}`,
|
|
3846
|
-
// dataUint8Array,
|
|
3847
|
-
// )
|
|
3848
|
-
// }
|
|
3849
|
-
}
|
|
3850
|
-
if (contentType === 'html') {
|
|
3851
|
-
fileName += '.html';
|
|
3852
|
-
yield fs.promises.writeFile(`/files/html/${fileName}`, dataString);
|
|
3826
|
+
}
|
|
3827
|
+
let fileName = transactionId;
|
|
3828
|
+
if (contentType === 'base64') {
|
|
3829
|
+
if (fileExtension) {
|
|
3830
|
+
fileName += `.${fileExtension}`;
|
|
3853
3831
|
}
|
|
3854
|
-
if (
|
|
3855
|
-
|
|
3856
|
-
|
|
3832
|
+
// Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
|
|
3833
|
+
const base64Data = dataString.split(',').pop() || '';
|
|
3834
|
+
// Decode the Base64 string to binary
|
|
3835
|
+
const binaryString = atob(base64Data);
|
|
3836
|
+
const length = binaryString.length;
|
|
3837
|
+
const binaryData = new Uint8Array(length);
|
|
3838
|
+
for (let i = 0; i < length; i++) {
|
|
3839
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
3857
3840
|
}
|
|
3841
|
+
yield fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
|
|
3842
|
+
encoding: 'binary',
|
|
3843
|
+
});
|
|
3844
|
+
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
3845
|
+
// await fs.promises.writeFile(
|
|
3846
|
+
// `/files/images/${fileName}`,
|
|
3847
|
+
// dataUint8Array,
|
|
3848
|
+
// )
|
|
3849
|
+
// }
|
|
3850
|
+
}
|
|
3851
|
+
if (contentType === 'html') {
|
|
3852
|
+
fileName += '.html';
|
|
3853
|
+
yield fs.promises.writeFile(`/files/html/${fileName}`, dataString);
|
|
3858
3854
|
}
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3855
|
+
if (contentType === 'json') {
|
|
3856
|
+
fileName += '.json';
|
|
3857
|
+
yield fs.promises.writeFile(`/files/json/${fileName}`, dataString);
|
|
3862
3858
|
}
|
|
3863
3859
|
}
|
|
3864
|
-
|
|
3860
|
+
catch (error) {
|
|
3861
|
+
logger$c(error);
|
|
3865
3862
|
}
|
|
3866
3863
|
}
|
|
3867
3864
|
});
|
|
@@ -6634,7 +6631,7 @@ const client = {
|
|
|
6634
6631
|
console.error('fs listeners not ready during init');
|
|
6635
6632
|
}
|
|
6636
6633
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6637
|
-
import('./seed.schema.config-
|
|
6634
|
+
import('./seed.schema.config-DjUwnjlb.js').then(({ models }) => {
|
|
6638
6635
|
for (const [key, value] of Object.entries(models)) {
|
|
6639
6636
|
setModel(key, value);
|
|
6640
6637
|
}
|
|
@@ -7588,4 +7585,4 @@ if (isNode()) {
|
|
|
7588
7585
|
}
|
|
7589
7586
|
|
|
7590
7587
|
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 };
|
|
7591
|
-
//# sourceMappingURL=index-
|
|
7588
|
+
//# sourceMappingURL=index-D0rjBEnK.js.map
|