@seedprotocol/sdk 0.1.25 → 0.1.27
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-Cy_HipO3.js → index-D26v76gh.js} +56 -82
- package/dist/index-D26v76gh.js.map +1 -0
- package/dist/{index-CckBxrSh.js → index-OeIV396w.js} +2 -2
- package/dist/index-OeIV396w.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/node/db/node.app.db.config.ts +7 -1
- package/dist/{seed-CKCT_cl0.js → seed-BpwPgvGq.js} +3 -3
- package/dist/{seed-CKCT_cl0.js.map → seed-BpwPgvGq.js.map} +1 -1
- package/dist/{seed-D12qMUYl.js → seed-CXWpd_ga.js} +2 -2
- package/dist/{seed-D12qMUYl.js.map → seed-CXWpd_ga.js.map} +1 -1
- package/dist/{seed-BPdYo60X.js → seed-DYYqlEb1.js} +3 -3
- package/dist/{seed-BPdYo60X.js.map → seed-DYYqlEb1.js.map} +1 -1
- package/dist/{seed.schema.config-CoTyC5sz.js → seed.schema.config-B8k6uQFV.js} +2 -2
- package/dist/{seed.schema.config-CoTyC5sz.js.map → seed.schema.config-B8k6uQFV.js.map} +1 -1
- package/dist/types/src/browser/db/read/getSeedData.d.ts +2 -11
- package/dist/types/src/browser/db/read/getSeedData.d.ts.map +1 -1
- package/dist/types/src/browser/db/read.d.ts +2 -2
- package/dist/types/src/browser/db/read.d.ts.map +1 -1
- package/dist/types/src/browser/item/class.d.ts +1 -0
- package/dist/types/src/browser/item/class.d.ts.map +1 -1
- package/dist/types/src/browser/property/class.d.ts +5 -4
- package/dist/types/src/browser/property/class.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts +1 -1
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/react/property.d.ts +9 -1
- package/dist/types/src/browser/react/property.d.ts.map +1 -1
- package/dist/types/src/node/db/node.app.db.config.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-CckBxrSh.js.map +0 -1
- package/dist/index-Cy_HipO3.js.map +0 -1
|
@@ -405,45 +405,21 @@ relations(propertyUids, ({ one }) => ({
|
|
|
405
405
|
property: one(properties),
|
|
406
406
|
}));
|
|
407
407
|
|
|
408
|
-
const getPropertyData = (propertyName, seedLocalId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
seed_local_id,
|
|
419
|
-
seed_uid,
|
|
420
|
-
created_at,
|
|
421
|
-
updated_at
|
|
422
|
-
FROM metadata
|
|
423
|
-
WHERE property_name = '${propertyName}'
|
|
424
|
-
AND seed_local_id = '${seedLocalId}'
|
|
425
|
-
ORDER BY COALESCE(attestation_created_at, created_at) DESC
|
|
426
|
-
LIMIT 1;`;
|
|
427
|
-
const { rows } = yield runQueryForStatement(query);
|
|
408
|
+
const getPropertyData = (propertyName, seedLocalId, seedUid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
409
|
+
const appDb = getAppDb();
|
|
410
|
+
const queryBase = appDb.select().from(metadata);
|
|
411
|
+
if (seedLocalId) {
|
|
412
|
+
queryBase.where(and(eq(metadata.propertyName, propertyName), eq(metadata.seedLocalId, seedLocalId)));
|
|
413
|
+
}
|
|
414
|
+
if (seedUid) {
|
|
415
|
+
queryBase.where(and(eq(metadata.propertyName, propertyName), eq(metadata.seedUid, seedUid)));
|
|
416
|
+
}
|
|
417
|
+
const rows = (yield queryBase.orderBy(sql.raw(`COALESCE(attestation_created_at, created_at) DESC`)));
|
|
428
418
|
if (!rows || rows.length === 0) {
|
|
429
419
|
return;
|
|
430
420
|
}
|
|
431
421
|
const row = rows[0];
|
|
432
|
-
return {
|
|
433
|
-
localId: row[0],
|
|
434
|
-
uid: row[1],
|
|
435
|
-
schemaUid: row[2],
|
|
436
|
-
propertyName: row[3],
|
|
437
|
-
propertyValue: row[4],
|
|
438
|
-
itemModelName: startCase(row[5]),
|
|
439
|
-
attestationCreatedAt: row[6],
|
|
440
|
-
refSeedType: row[7],
|
|
441
|
-
refValueType: row[8],
|
|
442
|
-
seedLocalId: row[9],
|
|
443
|
-
seedUid: row[10],
|
|
444
|
-
createdAt: row[11],
|
|
445
|
-
updatedAt: row[12],
|
|
446
|
-
};
|
|
422
|
+
return Object.assign(Object.assign({}, row), { itemModelName: startCase(row.modelType) });
|
|
447
423
|
});
|
|
448
424
|
const seedUidToStorageTransactionId = new Map();
|
|
449
425
|
const getStorageTransactionIdForSeedUid = (seedUid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1023,7 +999,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1023
999
|
renderValue: refResolvedDisplayValue,
|
|
1024
1000
|
});
|
|
1025
1001
|
if (propertyNameFromDb === 'storageTransactionId') {
|
|
1026
|
-
const { Item } = yield import('./index-
|
|
1002
|
+
const { Item } = yield import('./index-OeIV396w.js');
|
|
1027
1003
|
const item = yield Item.find({
|
|
1028
1004
|
seedLocalId,
|
|
1029
1005
|
modelName: itemModelName,
|
|
@@ -1058,34 +1034,20 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1058
1034
|
});
|
|
1059
1035
|
|
|
1060
1036
|
const getSeedData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLocalId, seedUid }) {
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
updated_at
|
|
1072
|
-
FROM seeds
|
|
1073
|
-
WHERE ${whereStatement};`;
|
|
1074
|
-
const { rows } = yield runQueryForStatement(getSeedStatement);
|
|
1037
|
+
const appDb = getAppDb();
|
|
1038
|
+
let query;
|
|
1039
|
+
const queryBase = appDb.select().from(seeds);
|
|
1040
|
+
if (seedLocalId) {
|
|
1041
|
+
query = queryBase.where(eq(seeds.localId, seedLocalId));
|
|
1042
|
+
}
|
|
1043
|
+
if (seedUid) {
|
|
1044
|
+
query = queryBase.where(eq(seeds.uid, seedUid));
|
|
1045
|
+
}
|
|
1046
|
+
const rows = yield query;
|
|
1075
1047
|
if (!rows || !rows.length) {
|
|
1076
1048
|
return;
|
|
1077
1049
|
}
|
|
1078
|
-
|
|
1079
|
-
return {
|
|
1080
|
-
localId: seedValues[0],
|
|
1081
|
-
uid: seedValues[1],
|
|
1082
|
-
schemaUid: seedValues[2],
|
|
1083
|
-
type: seedValues[3],
|
|
1084
|
-
attestationCreatedAt: seedValues[4],
|
|
1085
|
-
attestationRaw: seedValues[5],
|
|
1086
|
-
createdAt: seedValues[6],
|
|
1087
|
-
updatedAt: seedValues[7],
|
|
1088
|
-
};
|
|
1050
|
+
return rows[0];
|
|
1089
1051
|
});
|
|
1090
1052
|
|
|
1091
1053
|
const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLocalId }) {
|
|
@@ -1794,9 +1756,12 @@ class ItemProperty {
|
|
|
1794
1756
|
logger$k(`[ItemProperty] [_updateResponseListener] [${this.itemModelName}.${this.seedLocalId}] ${this.propertyName} event`, event);
|
|
1795
1757
|
}
|
|
1796
1758
|
static create(props) {
|
|
1797
|
-
const { propertyName, seedLocalId,
|
|
1759
|
+
const { propertyName, seedLocalId, seedUid } = props;
|
|
1760
|
+
if (!propertyName || (!seedLocalId && !seedUid)) {
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
const cacheKey = ItemProperty.cacheKey((seedUid || seedLocalId), propertyName);
|
|
1798
1764
|
if (seedLocalId && propertyName) {
|
|
1799
|
-
const cacheKey = ItemProperty.cacheKey(seedLocalId, propertyName);
|
|
1800
1765
|
if (ItemProperty.instanceCache.has(cacheKey)) {
|
|
1801
1766
|
const { instance, refCount } = ItemProperty.instanceCache.get(cacheKey);
|
|
1802
1767
|
ItemProperty.instanceCache.set(cacheKey, {
|
|
@@ -1814,26 +1779,27 @@ class ItemProperty {
|
|
|
1814
1779
|
return newInstance;
|
|
1815
1780
|
}
|
|
1816
1781
|
}
|
|
1817
|
-
if (
|
|
1818
|
-
if (this.instanceCache.has(
|
|
1819
|
-
const { instance, refCount } = this.instanceCache.get(
|
|
1820
|
-
this.instanceCache.set(
|
|
1782
|
+
if (seedUid && propertyName) {
|
|
1783
|
+
if (this.instanceCache.has(cacheKey)) {
|
|
1784
|
+
const { instance, refCount } = this.instanceCache.get(cacheKey);
|
|
1785
|
+
this.instanceCache.set(cacheKey, { instance, refCount: refCount + 1 });
|
|
1821
1786
|
return instance;
|
|
1822
1787
|
}
|
|
1823
|
-
if (!this.instanceCache.has(
|
|
1788
|
+
if (!this.instanceCache.has(cacheKey)) {
|
|
1824
1789
|
const newInstance = new ItemProperty(props);
|
|
1825
|
-
this.instanceCache.set(
|
|
1790
|
+
this.instanceCache.set(cacheKey, { instance: newInstance, refCount: 1 });
|
|
1826
1791
|
return newInstance;
|
|
1827
1792
|
}
|
|
1828
1793
|
}
|
|
1829
1794
|
return new ItemProperty(props);
|
|
1830
1795
|
}
|
|
1831
1796
|
static find(_b) {
|
|
1832
|
-
return __awaiter(this, arguments, void 0, function* ({ propertyName, seedLocalId, }) {
|
|
1833
|
-
if (!seedLocalId || !propertyName) {
|
|
1797
|
+
return __awaiter(this, arguments, void 0, function* ({ propertyName, seedLocalId, seedUid, }) {
|
|
1798
|
+
if ((!seedLocalId && !seedUid) || !propertyName) {
|
|
1834
1799
|
return;
|
|
1835
1800
|
}
|
|
1836
|
-
const
|
|
1801
|
+
const cacheKeyId = seedUid || seedLocalId;
|
|
1802
|
+
const cacheKey = ItemProperty.cacheKey(cacheKeyId, propertyName);
|
|
1837
1803
|
if (this.instanceCache.has(cacheKey)) {
|
|
1838
1804
|
const { instance, refCount } = this.instanceCache.get(cacheKey);
|
|
1839
1805
|
this.instanceCache.set(cacheKey, {
|
|
@@ -1845,15 +1811,16 @@ class ItemProperty {
|
|
|
1845
1811
|
}
|
|
1846
1812
|
return instance;
|
|
1847
1813
|
}
|
|
1848
|
-
const propertyData = yield getPropertyData(propertyName, seedLocalId);
|
|
1814
|
+
const propertyData = yield getPropertyData(propertyName, seedLocalId, seedUid);
|
|
1849
1815
|
if (!propertyData) {
|
|
1850
1816
|
return;
|
|
1851
1817
|
}
|
|
1852
1818
|
return ItemProperty.create(propertyData);
|
|
1853
1819
|
});
|
|
1854
1820
|
}
|
|
1855
|
-
static cacheKey(
|
|
1856
|
-
|
|
1821
|
+
static cacheKey(seedLocalIdOrUid, propertyName) {
|
|
1822
|
+
const { uid, localId } = getCorrectId(seedLocalIdOrUid);
|
|
1823
|
+
return `Item_${uid || localId}_${propertyName}`;
|
|
1857
1824
|
}
|
|
1858
1825
|
getService() {
|
|
1859
1826
|
return this._service;
|
|
@@ -3460,6 +3427,9 @@ class Item {
|
|
|
3460
3427
|
get seedLocalId() {
|
|
3461
3428
|
return this._service.getSnapshot().context.seedLocalId;
|
|
3462
3429
|
}
|
|
3430
|
+
get seedUid() {
|
|
3431
|
+
return this._service.getSnapshot().context.seedUid;
|
|
3432
|
+
}
|
|
3463
3433
|
get properties() {
|
|
3464
3434
|
return this._propertiesSubject.value;
|
|
3465
3435
|
// if (this._propertiesSubject) {
|
|
@@ -4351,7 +4321,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4351
4321
|
if (!models$1) {
|
|
4352
4322
|
return;
|
|
4353
4323
|
}
|
|
4354
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
4324
|
+
const { models: SeedModels } = yield import('./seed.schema.config-B8k6uQFV.js');
|
|
4355
4325
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
4356
4326
|
let hasModelsInDb = false;
|
|
4357
4327
|
const schemaDefsByModelName = new Map();
|
|
@@ -5815,11 +5785,11 @@ const globalMachine = setup({
|
|
|
5815
5785
|
(_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
|
|
5816
5786
|
let SeedClass;
|
|
5817
5787
|
if (context.environment === 'node') {
|
|
5818
|
-
const { SeedNode } = yield import('./seed-
|
|
5788
|
+
const { SeedNode } = yield import('./seed-DYYqlEb1.js');
|
|
5819
5789
|
SeedClass = SeedNode;
|
|
5820
5790
|
}
|
|
5821
5791
|
else {
|
|
5822
|
-
const { SeedBrowser } = yield import('./seed-
|
|
5792
|
+
const { SeedBrowser } = yield import('./seed-BpwPgvGq.js');
|
|
5823
5793
|
SeedClass = SeedBrowser;
|
|
5824
5794
|
}
|
|
5825
5795
|
return SeedClass;
|
|
@@ -6275,7 +6245,7 @@ const useDeleteItem = () => {
|
|
|
6275
6245
|
};
|
|
6276
6246
|
|
|
6277
6247
|
const logger$1 = debug('app:react:property');
|
|
6278
|
-
const useItemProperty = (propertyName, seedLocalId) => {
|
|
6248
|
+
const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
6279
6249
|
const [property, setProperty] = useImmer(undefined);
|
|
6280
6250
|
const [isReadingFromDb, setIsReadingFromDb] = useState(false);
|
|
6281
6251
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
@@ -6297,7 +6267,11 @@ const useItemProperty = (propertyName, seedLocalId) => {
|
|
|
6297
6267
|
return;
|
|
6298
6268
|
}
|
|
6299
6269
|
setIsReadingFromDb(true);
|
|
6300
|
-
const foundProperty = yield ItemProperty.find({
|
|
6270
|
+
const foundProperty = yield ItemProperty.find({
|
|
6271
|
+
propertyName,
|
|
6272
|
+
seedLocalId,
|
|
6273
|
+
seedUid,
|
|
6274
|
+
});
|
|
6301
6275
|
setIsReadingFromDb(false);
|
|
6302
6276
|
if (!foundProperty) {
|
|
6303
6277
|
logger$1(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
@@ -6626,7 +6600,7 @@ const client = {
|
|
|
6626
6600
|
console.error('fs listeners not ready during init');
|
|
6627
6601
|
}
|
|
6628
6602
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6629
|
-
import('./seed.schema.config-
|
|
6603
|
+
import('./seed.schema.config-B8k6uQFV.js').then(({ models }) => {
|
|
6630
6604
|
for (const [key, value] of Object.entries(models)) {
|
|
6631
6605
|
setModel(key, value);
|
|
6632
6606
|
}
|
|
@@ -6683,4 +6657,4 @@ if (isNode()) {
|
|
|
6683
6657
|
}
|
|
6684
6658
|
|
|
6685
6659
|
export { CHILD_SNAPSHOT as C, 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, internalMachine as h, itemMachineSingle as i, isNode as j, isBrowser as k, isReactNative as l, ImageSrc as m, ItemProperty as n, useItem as o, useItemProperties as p, useCreateItem as q, useItemProperty as r, useDeleteItem as s, useServices as t, useItems as u, getGlobalService as v, withSeed as w, client as x, getCorrectId as y };
|
|
6686
|
-
//# sourceMappingURL=index-
|
|
6660
|
+
//# sourceMappingURL=index-D26v76gh.js.map
|