@seedprotocol/sdk 0.1.64 → 0.1.66
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-bNy6MtOd.js → index-BYbqQltB.js} +57 -11
- package/dist/index-BYbqQltB.js.map +1 -0
- package/dist/{index-9o1LuAwu.js → index-C-vHwxAS.js} +2 -2
- package/dist/index-C-vHwxAS.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-BcB0_Har.js → seed.schema.config-PwtELm7X.js} +2 -2
- package/dist/{seed.schema.config-BcB0_Har.js.map → seed.schema.config-PwtELm7X.js.map} +1 -1
- package/dist/src/arweave.ts +7 -0
- package/dist/src/hydrateFromDb.ts +46 -3
- package/dist/src/saveImageSrc.ts +2 -2
- package/dist/src/write.ts +15 -51
- package/dist/types/src/browser/db/write.d.ts +0 -15
- package/dist/types/src/browser/db/write.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/index.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/arweave.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-9o1LuAwu.js.map +0 -1
- package/dist/index-bNy6MtOd.js.map +0 -1
- package/dist/src/save.ts +0 -183
- package/dist/types/src/browser/db/save.d.ts +0 -5
- package/dist/types/src/browser/db/save.d.ts.map +0 -1
|
@@ -950,7 +950,9 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
950
950
|
return;
|
|
951
951
|
}
|
|
952
952
|
const firstRow = rows[0];
|
|
953
|
-
const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, seedLocalId: seedLocalIdFromDb, seedUid: seedUidFromDb, schemaUid: schemaUidFromDb, versionLocalId: versionLocalIdFromDb, versionUid: versionUidFromDb, refValueType, refResolvedValue,
|
|
953
|
+
const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, seedLocalId: seedLocalIdFromDb, seedUid: seedUidFromDb, schemaUid: schemaUidFromDb, versionLocalId: versionLocalIdFromDb, versionUid: versionUidFromDb, refValueType, refResolvedValue, localStorageDir, } = firstRow;
|
|
954
|
+
let { refResolvedDisplayValue } = firstRow;
|
|
955
|
+
let propertyValueProcessed = propertyValueFromDb;
|
|
954
956
|
if (propertyName && !propertyNameFromDb) {
|
|
955
957
|
logger$m(`Property name from code is ${propertyName} but has not value in db ${propertyNameFromDb} for Property.${localId}`);
|
|
956
958
|
}
|
|
@@ -970,11 +972,43 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
970
972
|
if (seedUidFromDb !== seedUid) {
|
|
971
973
|
logger$m(`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`);
|
|
972
974
|
}
|
|
975
|
+
if (refResolvedValue &&
|
|
976
|
+
refResolvedDisplayValue &&
|
|
977
|
+
refResolvedDisplayValue.includes('http')) {
|
|
978
|
+
let urlNeedsToBeRefreshed = false;
|
|
979
|
+
try {
|
|
980
|
+
const response = yield fetch(refResolvedDisplayValue, {
|
|
981
|
+
method: 'HEAD',
|
|
982
|
+
});
|
|
983
|
+
// Check if the status is in the 200-299 range
|
|
984
|
+
if (!response.ok) {
|
|
985
|
+
urlNeedsToBeRefreshed = true;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
catch (error) {
|
|
989
|
+
urlNeedsToBeRefreshed = true;
|
|
990
|
+
}
|
|
991
|
+
if (urlNeedsToBeRefreshed) {
|
|
992
|
+
const filePath = `/files/${localStorageDir}/${refResolvedValue}`;
|
|
993
|
+
const fileExists = yield fs.promises.exists(filePath);
|
|
994
|
+
if (fileExists) {
|
|
995
|
+
const fileContents = yield fs.promises.readFile(filePath);
|
|
996
|
+
const fileHandler = new File([fileContents], refResolvedValue);
|
|
997
|
+
refResolvedDisplayValue = URL.createObjectURL(fileHandler);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (propertyRecordSchema &&
|
|
1002
|
+
propertyRecordSchema.dataType === 'List' &&
|
|
1003
|
+
propertyRecordSchema.ref &&
|
|
1004
|
+
typeof propertyValueFromDb === 'string') {
|
|
1005
|
+
propertyValueProcessed = propertyValueFromDb.split(',');
|
|
1006
|
+
}
|
|
973
1007
|
sendBack({
|
|
974
1008
|
type: 'updateContext',
|
|
975
1009
|
localId,
|
|
976
1010
|
uid,
|
|
977
|
-
propertyValue:
|
|
1011
|
+
propertyValue: propertyValueProcessed,
|
|
978
1012
|
seedLocalId: seedLocalIdFromDb,
|
|
979
1013
|
seedUid: seedUidFromDb,
|
|
980
1014
|
versionLocalId: versionLocalIdFromDb,
|
|
@@ -989,7 +1023,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
989
1023
|
if (propertyRecordSchema &&
|
|
990
1024
|
propertyRecordSchema.storageType &&
|
|
991
1025
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
992
|
-
const { Item } = yield import('./index-
|
|
1026
|
+
const { Item } = yield import('./index-C-vHwxAS.js');
|
|
993
1027
|
const item = yield Item.find({
|
|
994
1028
|
seedLocalId,
|
|
995
1029
|
modelName: itemModelName,
|
|
@@ -1120,7 +1154,6 @@ const createNewItem = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
1120
1154
|
if (!modelName) {
|
|
1121
1155
|
throw new Error('A model name is required for createNewItem');
|
|
1122
1156
|
}
|
|
1123
|
-
getAppDb();
|
|
1124
1157
|
const seedType = modelName.toLowerCase();
|
|
1125
1158
|
const newSeedId = yield createSeed({ type: seedType });
|
|
1126
1159
|
const newVersionId = yield createVersion({ seedLocalId: newSeedId });
|
|
@@ -1164,6 +1197,12 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
1164
1197
|
!refResolvedValue) {
|
|
1165
1198
|
safeNewValue = escapeSqliteString(newValue);
|
|
1166
1199
|
}
|
|
1200
|
+
const appDb = getAppDb();
|
|
1201
|
+
yield appDb
|
|
1202
|
+
.select()
|
|
1203
|
+
.from(metadata)
|
|
1204
|
+
.where(and(eq(metadata.propertyName, propertyName), eq(metadata.seedLocalId, seedLocalId)))
|
|
1205
|
+
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'));
|
|
1167
1206
|
const mostRecentRecordStatement = `SELECT local_id,
|
|
1168
1207
|
uid,
|
|
1169
1208
|
property_name,
|
|
@@ -1514,7 +1553,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
1514
1553
|
}
|
|
1515
1554
|
}
|
|
1516
1555
|
const filePath = `/files/images/${fileName}`;
|
|
1517
|
-
|
|
1556
|
+
yield createVersion({
|
|
1518
1557
|
seedLocalId: newImageSeedLocalId,
|
|
1519
1558
|
seedType: 'image',
|
|
1520
1559
|
});
|
|
@@ -1531,7 +1570,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
1531
1570
|
propertyValue: newImageSeedLocalId,
|
|
1532
1571
|
seedLocalId,
|
|
1533
1572
|
seedUid,
|
|
1534
|
-
versionLocalId
|
|
1573
|
+
versionLocalId,
|
|
1535
1574
|
versionUid,
|
|
1536
1575
|
modelName: itemModelName,
|
|
1537
1576
|
schemaUid,
|
|
@@ -1546,7 +1585,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
1546
1585
|
propertyName: propertyNameRaw,
|
|
1547
1586
|
newValue: newImageSeedLocalId,
|
|
1548
1587
|
seedLocalId,
|
|
1549
|
-
versionLocalId
|
|
1588
|
+
versionLocalId,
|
|
1550
1589
|
modelName: itemModelName,
|
|
1551
1590
|
schemaUid,
|
|
1552
1591
|
refSeedType: 'image',
|
|
@@ -2877,7 +2916,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2877
2916
|
if (!models$1) {
|
|
2878
2917
|
return;
|
|
2879
2918
|
}
|
|
2880
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2919
|
+
const { models: SeedModels } = yield import('./seed.schema.config-PwtELm7X.js');
|
|
2881
2920
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2882
2921
|
let hasModelsInDb = false;
|
|
2883
2922
|
const schemaDefsByModelName = new Map();
|
|
@@ -3827,6 +3866,12 @@ const getArweave = () => {
|
|
|
3827
3866
|
return;
|
|
3828
3867
|
}
|
|
3829
3868
|
if (process.env.NODE_ENV === 'production') {
|
|
3869
|
+
if (Object.keys(Arweave).includes('default')) {
|
|
3870
|
+
return Arweave.default.init({
|
|
3871
|
+
host: process.env.NEXT_PUBLIC_ARWEAVE_HOST,
|
|
3872
|
+
protocol: 'https',
|
|
3873
|
+
});
|
|
3874
|
+
}
|
|
3830
3875
|
return Arweave.init({
|
|
3831
3876
|
host: process.env.NEXT_PUBLIC_ARWEAVE_HOST,
|
|
3832
3877
|
protocol: 'https',
|
|
@@ -6802,7 +6847,7 @@ const client = {
|
|
|
6802
6847
|
console.error('fs listeners not ready during init');
|
|
6803
6848
|
}
|
|
6804
6849
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6805
|
-
import('./seed.schema.config-
|
|
6850
|
+
import('./seed.schema.config-PwtELm7X.js').then(({ models }) => {
|
|
6806
6851
|
for (const [key, value] of Object.entries(models)) {
|
|
6807
6852
|
setModel(key, value);
|
|
6808
6853
|
}
|
|
@@ -6962,7 +7007,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
|
|
|
6962
7007
|
});
|
|
6963
7008
|
|
|
6964
7009
|
const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
6965
|
-
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, propertyValue: existingValue, propertyRecordSchema, itemModelName, schemaUid, } = context;
|
|
7010
|
+
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, itemModelName, schemaUid, } = context;
|
|
6966
7011
|
let newValue;
|
|
6967
7012
|
if (event) {
|
|
6968
7013
|
newValue = event.newValue;
|
|
@@ -7007,6 +7052,7 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
7007
7052
|
newValue,
|
|
7008
7053
|
seedLocalId,
|
|
7009
7054
|
versionLocalId,
|
|
7055
|
+
versionUid,
|
|
7010
7056
|
modelName: itemModelName,
|
|
7011
7057
|
schemaUid,
|
|
7012
7058
|
});
|
|
@@ -7375,4 +7421,4 @@ if (isNode()) {
|
|
|
7375
7421
|
}
|
|
7376
7422
|
|
|
7377
7423
|
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 };
|
|
7378
|
-
//# sourceMappingURL=index-
|
|
7424
|
+
//# sourceMappingURL=index-BYbqQltB.js.map
|