@seedprotocol/sdk 0.1.62 → 0.1.64
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-DZr1ley6.js → index-9o1LuAwu.js} +2 -2
- package/dist/index-9o1LuAwu.js.map +1 -0
- package/dist/{index-BRj0FIK5.js → index-bNy6MtOd.js} +73 -39
- package/dist/index-bNy6MtOd.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-CumSjbki.js → seed.schema.config-BcB0_Har.js} +2 -2
- package/dist/{seed.schema.config-CumSjbki.js.map → seed.schema.config-BcB0_Har.js.map} +1 -1
- package/dist/src/getItems.ts +2 -2
- package/dist/src/item.ts +52 -6
- package/dist/src/property.ts +27 -36
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/react/property.d.ts +0 -1
- package/dist/types/src/browser/react/property.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-BRj0FIK5.js.map +0 -1
- package/dist/index-DZr1ley6.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { f as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, e as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SEEDS, b as GET_SEED_IDS, c as GET_STORAGE_TRANSACTION_ID, d as GET_VERSIONS, I as Item, g as itemMachineAll, i as itemMachineSingle } from './index-
|
|
1
|
+
export { f as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, e as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SEEDS, b as GET_SEED_IDS, c as GET_STORAGE_TRANSACTION_ID, d as GET_VERSIONS, I as Item, g as itemMachineAll, i as itemMachineSingle } from './index-bNy6MtOd.js';
|
|
2
2
|
import './constants-BLctWkrn.js';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'reflect-metadata';
|
|
@@ -27,4 +27,4 @@ import '@zenfs/dom';
|
|
|
27
27
|
import 'arweave';
|
|
28
28
|
import 'use-immer';
|
|
29
29
|
import '@xstate/react';
|
|
30
|
-
//# sourceMappingURL=index-
|
|
30
|
+
//# sourceMappingURL=index-9o1LuAwu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-9o1LuAwu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,7 +3,7 @@ import path, { basename } from 'path';
|
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { Type } from '@sinclair/typebox';
|
|
5
5
|
import { fromCallback, assign, createActor, waitFor, setup, emit, raise } from 'xstate';
|
|
6
|
-
import { sql, relations, and, eq, max, or, count, isNotNull, isNull, inArray, like, getTableColumns
|
|
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';
|
|
@@ -989,7 +989,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
989
989
|
if (propertyRecordSchema &&
|
|
990
990
|
propertyRecordSchema.storageType &&
|
|
991
991
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
992
|
-
const { Item } = yield import('./index-
|
|
992
|
+
const { Item } = yield import('./index-9o1LuAwu.js');
|
|
993
993
|
const item = yield Item.find({
|
|
994
994
|
seedLocalId,
|
|
995
995
|
modelName: itemModelName,
|
|
@@ -1688,7 +1688,7 @@ const getItemsData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelN
|
|
|
1688
1688
|
})
|
|
1689
1689
|
.from(seeds)
|
|
1690
1690
|
.leftJoin(versionData, eq(seeds.localId, versionData.seedLocalId))
|
|
1691
|
-
.where(and(...conditions))
|
|
1691
|
+
.where(and(gt(versionData.versionsCount, 0), ...conditions))
|
|
1692
1692
|
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'))
|
|
1693
1693
|
.groupBy(seeds.localId);
|
|
1694
1694
|
const itemsData = (yield query);
|
|
@@ -2877,7 +2877,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2877
2877
|
if (!models$1) {
|
|
2878
2878
|
return;
|
|
2879
2879
|
}
|
|
2880
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2880
|
+
const { models: SeedModels } = yield import('./seed.schema.config-BcB0_Har.js');
|
|
2881
2881
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2882
2882
|
let hasModelsInDb = false;
|
|
2883
2883
|
const schemaDefsByModelName = new Map();
|
|
@@ -6423,6 +6423,54 @@ const useGlobalServiceStatus = () => {
|
|
|
6423
6423
|
|
|
6424
6424
|
const logger$2 = debug('app:react:item');
|
|
6425
6425
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
6426
|
+
// const [itemSubscription, setItemSubscription] = useState<
|
|
6427
|
+
// Subscription | undefined
|
|
6428
|
+
// >()
|
|
6429
|
+
//
|
|
6430
|
+
// const queryClient = useQueryClient()
|
|
6431
|
+
//
|
|
6432
|
+
// const { data: item } = useQuery({
|
|
6433
|
+
// queryKey: ['item', modelName, seedLocalId, seedUid],
|
|
6434
|
+
// queryFn: async () =>
|
|
6435
|
+
// Item.find({
|
|
6436
|
+
// modelName,
|
|
6437
|
+
// seedLocalId,
|
|
6438
|
+
// seedUid,
|
|
6439
|
+
// }),
|
|
6440
|
+
// networkMode: 'offlineFirst',
|
|
6441
|
+
// })
|
|
6442
|
+
//
|
|
6443
|
+
// const updateItem = async (newItem: Item<any>) => {
|
|
6444
|
+
// queryClient.setQueryData(['item', modelName, seedLocalId, seedUid], newItem)
|
|
6445
|
+
// }
|
|
6446
|
+
//
|
|
6447
|
+
// useEffect(() => {
|
|
6448
|
+
// if (item && item.subscribe && !itemSubscription) {
|
|
6449
|
+
// const subscription = item.subscribe(async (_) => {
|
|
6450
|
+
// const newItem = await Item.find({ modelName, seedLocalId, seedUid })
|
|
6451
|
+
// if (!newItem) {
|
|
6452
|
+
// logger(
|
|
6453
|
+
// '[useItem] [itemSubscription] no item found',
|
|
6454
|
+
// modelName,
|
|
6455
|
+
// seedLocalId,
|
|
6456
|
+
// )
|
|
6457
|
+
// return
|
|
6458
|
+
// }
|
|
6459
|
+
// updateItem(newItem)
|
|
6460
|
+
// })
|
|
6461
|
+
// setItemSubscription(subscription)
|
|
6462
|
+
// }
|
|
6463
|
+
//
|
|
6464
|
+
// return () => {
|
|
6465
|
+
// itemSubscription?.unsubscribe()
|
|
6466
|
+
// }
|
|
6467
|
+
// }, [item, itemSubscription])
|
|
6468
|
+
//
|
|
6469
|
+
// return {
|
|
6470
|
+
// item,
|
|
6471
|
+
// itemData: {},
|
|
6472
|
+
// itemStatus: undefined,
|
|
6473
|
+
// }
|
|
6426
6474
|
const [itemData, setItemData] = useImmer({});
|
|
6427
6475
|
const [item, setItem] = useState();
|
|
6428
6476
|
const [itemSubscription, setItemSubscription] = useState();
|
|
@@ -6490,7 +6538,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6490
6538
|
listenerRef.current();
|
|
6491
6539
|
});
|
|
6492
6540
|
return () => {
|
|
6493
|
-
eventEmitter.removeListener(`item.${modelName}.${seedId}.update
|
|
6541
|
+
eventEmitter.removeListener(`item.${modelName}.${seedId}.update`);
|
|
6494
6542
|
};
|
|
6495
6543
|
}, []);
|
|
6496
6544
|
return {
|
|
@@ -6592,10 +6640,9 @@ const useCreateItem = (modelName) => {
|
|
|
6592
6640
|
const logger$1 = debug('app:react:property');
|
|
6593
6641
|
const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
6594
6642
|
const [property, setProperty] = useState();
|
|
6595
|
-
const [isReadingFromDb, setIsReadingFromDb] = useState(false);
|
|
6596
6643
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
6597
|
-
// const isDbReady = useMemo(() => useIsDbReady(), [])
|
|
6598
6644
|
const { internalStatus } = useGlobalServiceStatus();
|
|
6645
|
+
const isReadingDb = useRef(false);
|
|
6599
6646
|
const value = useSelector(property === null || property === void 0 ? void 0 : property.getService(), (snapshot) => {
|
|
6600
6647
|
if (!snapshot || !snapshot.context) {
|
|
6601
6648
|
return;
|
|
@@ -6603,26 +6650,21 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
6603
6650
|
return snapshot.context.renderValue || snapshot.context.propertyValue;
|
|
6604
6651
|
});
|
|
6605
6652
|
const status = useSelector(property === null || property === void 0 ? void 0 : property.getService(), (snapshot) => snapshot === null || snapshot === void 0 ? void 0 : snapshot.value);
|
|
6606
|
-
// useEffect(() => {
|
|
6607
|
-
// if (property && property.value !== value) {
|
|
6608
|
-
// readFromDb()
|
|
6609
|
-
// }
|
|
6610
|
-
// }, [property, value])
|
|
6611
6653
|
const readFromDb = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
6612
6654
|
if (internalStatus !== 'ready' ||
|
|
6613
|
-
|
|
6655
|
+
isReadingDb.current ||
|
|
6614
6656
|
(!seedLocalId && !seedUid)) {
|
|
6615
6657
|
return;
|
|
6616
6658
|
}
|
|
6617
|
-
|
|
6659
|
+
isReadingDb.current = true;
|
|
6618
6660
|
const foundProperty = yield ItemProperty.find({
|
|
6619
6661
|
propertyName,
|
|
6620
6662
|
seedLocalId,
|
|
6621
6663
|
seedUid,
|
|
6622
6664
|
});
|
|
6623
|
-
setIsReadingFromDb(false);
|
|
6624
6665
|
if (!foundProperty) {
|
|
6625
6666
|
logger$1(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
6667
|
+
isReadingDb.current = false;
|
|
6626
6668
|
return;
|
|
6627
6669
|
}
|
|
6628
6670
|
if (foundProperty.status === 'waitingForDb') {
|
|
@@ -6630,36 +6672,28 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
6630
6672
|
}
|
|
6631
6673
|
setProperty(foundProperty);
|
|
6632
6674
|
setIsInitialized(true);
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
// }, [property])
|
|
6675
|
+
isReadingDb.current = false;
|
|
6676
|
+
}), [internalStatus]);
|
|
6677
|
+
const listenerRef = useRef(readFromDb);
|
|
6678
|
+
useEffect(() => {
|
|
6679
|
+
listenerRef.current = readFromDb;
|
|
6680
|
+
}, [readFromDb]);
|
|
6640
6681
|
useEffect(() => {
|
|
6641
6682
|
if (internalStatus === 'ready') {
|
|
6642
6683
|
readFromDb();
|
|
6643
6684
|
}
|
|
6644
6685
|
}, [internalStatus]);
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
// return () => {
|
|
6654
|
-
// eventEmitter.removeListener(
|
|
6655
|
-
// `property.${seedUid || seedLocalId}.${propertyName}.update`,
|
|
6656
|
-
// )
|
|
6657
|
-
// }
|
|
6658
|
-
// }, [])
|
|
6686
|
+
useEffect(() => {
|
|
6687
|
+
eventEmitter.addListener(`property.${seedUid || seedLocalId}.${propertyName}.update`, () => {
|
|
6688
|
+
listenerRef.current();
|
|
6689
|
+
});
|
|
6690
|
+
return () => {
|
|
6691
|
+
eventEmitter.removeListener(`property.${seedUid || seedLocalId}.${propertyName}.update`);
|
|
6692
|
+
};
|
|
6693
|
+
}, []);
|
|
6659
6694
|
return {
|
|
6660
6695
|
property,
|
|
6661
6696
|
isInitialized,
|
|
6662
|
-
isReadingFromDb,
|
|
6663
6697
|
value,
|
|
6664
6698
|
status,
|
|
6665
6699
|
};
|
|
@@ -6768,7 +6802,7 @@ const client = {
|
|
|
6768
6802
|
console.error('fs listeners not ready during init');
|
|
6769
6803
|
}
|
|
6770
6804
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6771
|
-
import('./seed.schema.config-
|
|
6805
|
+
import('./seed.schema.config-BcB0_Har.js').then(({ models }) => {
|
|
6772
6806
|
for (const [key, value] of Object.entries(models)) {
|
|
6773
6807
|
setModel(key, value);
|
|
6774
6808
|
}
|
|
@@ -7341,4 +7375,4 @@ if (isNode()) {
|
|
|
7341
7375
|
}
|
|
7342
7376
|
|
|
7343
7377
|
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_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, ImageSrc as h, itemMachineSingle as i, ItemProperty as j, useItem as k, useItemProperties as l, useCreateItem as m, useItemProperty as n, useDeleteItem as o, useGlobalServiceStatus as p, useServices as q, getGlobalService as r, client as s, getCorrectId as t, useItems as u, withSeed as w };
|
|
7344
|
-
//# sourceMappingURL=index-
|
|
7378
|
+
//# sourceMappingURL=index-bNy6MtOd.js.map
|