@seedprotocol/sdk 0.1.84 → 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-CBTE_R-7.js → index-BFSW1upn.js} +2 -2
- package/dist/{index-CBTE_R-7.js.map → index-BFSW1upn.js.map} +1 -1
- package/dist/{index-JmHVBmP7.js → index-D0rjBEnK.js} +47 -49
- package/dist/index-D0rjBEnK.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-BSTzpuJg.js → seed.schema.config-DjUwnjlb.js} +2 -2
- package/dist/{seed.schema.config-BSTzpuJg.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/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/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-JmHVBmP7.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';
|
|
@@ -1061,7 +1061,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1061
1061
|
if (propertyRecordSchema &&
|
|
1062
1062
|
propertyRecordSchema.storageType &&
|
|
1063
1063
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1064
|
-
const { Item } = yield import('./index-
|
|
1064
|
+
const { Item } = yield import('./index-BFSW1upn.js');
|
|
1065
1065
|
const item = yield Item.find({
|
|
1066
1066
|
seedLocalId,
|
|
1067
1067
|
modelName: itemModelName,
|
|
@@ -2289,7 +2289,12 @@ const createMetadataRecordsForStorageTransactionId = (storageTransactionIdProper
|
|
|
2289
2289
|
});
|
|
2290
2290
|
}
|
|
2291
2291
|
});
|
|
2292
|
+
let isSavingToDb = false;
|
|
2292
2293
|
const saveEasPropertiesToDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ itemProperties, itemSeeds, }) {
|
|
2294
|
+
if (isSavingToDb) {
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
isSavingToDb = true;
|
|
2293
2298
|
const propertyUids = itemProperties.map((property) => property.id);
|
|
2294
2299
|
const models = getModels();
|
|
2295
2300
|
const appDb = getAppDb();
|
|
@@ -2410,6 +2415,7 @@ const saveEasPropertiesToDb = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
2410
2415
|
insertPropertiesQuery = insertPropertiesQuery.slice(0, -2) + ';';
|
|
2411
2416
|
}
|
|
2412
2417
|
yield appDb.run(sql.raw(insertPropertiesQuery));
|
|
2418
|
+
isSavingToDb = false;
|
|
2413
2419
|
return { propertyUids };
|
|
2414
2420
|
});
|
|
2415
2421
|
const getRelatedSeedsAndVersions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -2442,7 +2448,7 @@ const getRelatedSeedsAndVersions = () => __awaiter(void 0, void 0, void 0, funct
|
|
|
2442
2448
|
itemSeeds,
|
|
2443
2449
|
});
|
|
2444
2450
|
});
|
|
2445
|
-
const syncDbWithEasHandler =
|
|
2451
|
+
const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2446
2452
|
const appDb = getAppDb();
|
|
2447
2453
|
const { modelSchemas, schemaStringToModelRecord } = yield getModelSchemas();
|
|
2448
2454
|
if (!modelSchemas ||
|
|
@@ -2512,7 +2518,7 @@ const syncDbWithEasHandler = debounce((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
2512
2518
|
for (const modelName of getModelNames()) {
|
|
2513
2519
|
eventEmitter.emit('item.requestAll', { modelName });
|
|
2514
2520
|
}
|
|
2515
|
-
}),
|
|
2521
|
+
}), 30000, {
|
|
2516
2522
|
leading: true,
|
|
2517
2523
|
trailing: false,
|
|
2518
2524
|
});
|
|
@@ -2623,7 +2629,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2623
2629
|
if (!models$1) {
|
|
2624
2630
|
return;
|
|
2625
2631
|
}
|
|
2626
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2632
|
+
const { models: SeedModels } = yield import('./seed.schema.config-DjUwnjlb.js');
|
|
2627
2633
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2628
2634
|
let hasModelsInDb = false;
|
|
2629
2635
|
const schemaDefsByModelName = new Map();
|
|
@@ -3173,11 +3179,6 @@ const dbMachine = setup({
|
|
|
3173
3179
|
},
|
|
3174
3180
|
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
3175
3181
|
},
|
|
3176
|
-
entry: ({ context }) => {
|
|
3177
|
-
if (context.hasFiles) {
|
|
3178
|
-
emit({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
3179
|
-
}
|
|
3180
|
-
},
|
|
3181
3182
|
},
|
|
3182
3183
|
[MIGRATING]: {
|
|
3183
3184
|
on: {
|
|
@@ -3755,7 +3756,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3755
3756
|
});
|
|
3756
3757
|
}),
|
|
3757
3758
|
});
|
|
3758
|
-
if (tags && tags.length
|
|
3759
|
+
if (tags && tags.length > 0) {
|
|
3759
3760
|
for (const { name, value } of tags) {
|
|
3760
3761
|
if (name === 'Content-SHA-256') {
|
|
3761
3762
|
const metadataRecord = yield getMetadata({
|
|
@@ -3775,7 +3776,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3775
3776
|
const response = yield fetch(`https://${ARWEAVE_HOST}/raw/${transactionId}`);
|
|
3776
3777
|
return yield response.text();
|
|
3777
3778
|
}),
|
|
3778
|
-
networkMode:
|
|
3779
|
+
networkMode: 'offlineFirst',
|
|
3779
3780
|
});
|
|
3780
3781
|
// const dataString = await arweave.transactions.getData(transactionId, {
|
|
3781
3782
|
// decode: true,
|
|
@@ -3822,45 +3823,42 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3822
3823
|
let fileExtension = mimeType;
|
|
3823
3824
|
if (fileExtension && (fileExtension === null || fileExtension === void 0 ? void 0 : fileExtension.startsWith('image'))) {
|
|
3824
3825
|
fileExtension = fileExtension.replace('image/', '');
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
}
|
|
3830
|
-
// Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
|
|
3831
|
-
const base64Data = dataString.split(',').pop() || '';
|
|
3832
|
-
// Decode the Base64 string to binary
|
|
3833
|
-
const binaryString = atob(base64Data);
|
|
3834
|
-
const length = binaryString.length;
|
|
3835
|
-
const binaryData = new Uint8Array(length);
|
|
3836
|
-
for (let i = 0; i < length; i++) {
|
|
3837
|
-
binaryData[i] = binaryString.charCodeAt(i);
|
|
3838
|
-
}
|
|
3839
|
-
yield fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
|
|
3840
|
-
encoding: 'binary',
|
|
3841
|
-
});
|
|
3842
|
-
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
3843
|
-
// await fs.promises.writeFile(
|
|
3844
|
-
// `/files/images/${fileName}`,
|
|
3845
|
-
// dataUint8Array,
|
|
3846
|
-
// )
|
|
3847
|
-
// }
|
|
3848
|
-
}
|
|
3849
|
-
if (contentType === 'html') {
|
|
3850
|
-
fileName += '.html';
|
|
3851
|
-
yield fs.promises.writeFile(`/files/html/${fileName}`, dataString);
|
|
3826
|
+
}
|
|
3827
|
+
let fileName = transactionId;
|
|
3828
|
+
if (contentType === 'base64') {
|
|
3829
|
+
if (fileExtension) {
|
|
3830
|
+
fileName += `.${fileExtension}`;
|
|
3852
3831
|
}
|
|
3853
|
-
if (
|
|
3854
|
-
|
|
3855
|
-
|
|
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);
|
|
3856
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);
|
|
3857
3854
|
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3855
|
+
if (contentType === 'json') {
|
|
3856
|
+
fileName += '.json';
|
|
3857
|
+
yield fs.promises.writeFile(`/files/json/${fileName}`, dataString);
|
|
3861
3858
|
}
|
|
3862
3859
|
}
|
|
3863
|
-
|
|
3860
|
+
catch (error) {
|
|
3861
|
+
logger$c(error);
|
|
3864
3862
|
}
|
|
3865
3863
|
}
|
|
3866
3864
|
});
|
|
@@ -6633,7 +6631,7 @@ const client = {
|
|
|
6633
6631
|
console.error('fs listeners not ready during init');
|
|
6634
6632
|
}
|
|
6635
6633
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6636
|
-
import('./seed.schema.config-
|
|
6634
|
+
import('./seed.schema.config-DjUwnjlb.js').then(({ models }) => {
|
|
6637
6635
|
for (const [key, value] of Object.entries(models)) {
|
|
6638
6636
|
setModel(key, value);
|
|
6639
6637
|
}
|
|
@@ -7587,4 +7585,4 @@ if (isNode()) {
|
|
|
7587
7585
|
}
|
|
7588
7586
|
|
|
7589
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 };
|
|
7590
|
-
//# sourceMappingURL=index-
|
|
7588
|
+
//# sourceMappingURL=index-D0rjBEnK.js.map
|