@seedprotocol/sdk 0.1.74 → 0.1.76
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/bin.js +1 -6
- package/dist/bin.js.map +1 -1
- package/dist/{constants-CtmwCBma.js → constants-rmQ8zg8_.js} +2 -1
- package/dist/{constants-CtmwCBma.js.map → constants-rmQ8zg8_.js.map} +1 -1
- package/dist/{index-3ASvLLXY.js → index-D5bGQvS6.js} +3 -3
- package/dist/{index-3ASvLLXY.js.map → index-D5bGQvS6.js.map} +1 -1
- package/dist/{index-Br7jo_vg.js → index-nyYoS6hl.js} +254 -333
- package/dist/index-nyYoS6hl.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{seed.schema.config-BHNlL53f.js → seed.schema.config-CaxQONHV.js} +3 -3
- package/dist/{seed.schema.config-BHNlL53f.js.map → seed.schema.config-CaxQONHV.js.map} +1 -1
- package/dist/src/ItemProperty.ts +21 -25
- package/dist/src/actors.ts +7 -282
- package/dist/src/analyzeInput.ts +102 -0
- package/dist/src/db.ts +0 -29
- package/dist/src/drizzle.ts +0 -4
- package/dist/src/getItem.ts +12 -32
- package/dist/src/getItemProperties.ts +17 -113
- package/dist/src/hydrateFromDb.ts +198 -218
- package/dist/src/index.ts +10 -62
- package/dist/src/item.ts +1 -2
- package/dist/src/itemMachineSingle.ts +12 -29
- package/dist/src/propertyMachine.ts +3 -14
- package/dist/src/reload.ts +33 -0
- package/dist/src/request.ts +0 -9
- package/dist/src/resolveRelatedValue.ts +25 -4
- package/dist/src/resolveRemoteStorage.ts +3 -2
- package/dist/src/saveImageSrc.ts +0 -4
- package/dist/src/services.ts +0 -3
- package/dist/src/updateItemPropertyValue.ts +1 -0
- package/dist/src/waitForFiles.ts +33 -0
- package/dist/types/src/browser/db/read/getItem.d.ts.map +1 -1
- package/dist/types/src/browser/db/read/getItemProperties.d.ts.map +1 -1
- package/dist/types/src/browser/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/types/src/browser/events/item/request.d.ts.map +1 -1
- package/dist/types/src/browser/item/Item.d.ts.map +1 -1
- package/dist/types/src/browser/item/single/actors/reload.d.ts +5 -0
- package/dist/types/src/browser/item/single/actors/reload.d.ts.map +1 -0
- package/dist/types/src/browser/item/single/actors/saveDataToDb.d.ts +1 -55
- package/dist/types/src/browser/item/single/actors/saveDataToDb.d.ts.map +1 -1
- package/dist/types/src/browser/item/single/itemMachineSingle.d.ts +1 -56
- package/dist/types/src/browser/item/single/itemMachineSingle.d.ts.map +1 -1
- package/dist/types/src/browser/property/ItemProperty.d.ts +4 -112
- package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts +4 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts +4 -1
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts +3 -55
- package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts +5 -0
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts.map +1 -0
- package/dist/types/src/browser/property/actors/saveValueToDb/index.d.ts +1 -4
- package/dist/types/src/browser/property/actors/saveValueToDb/index.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts.map +1 -1
- package/dist/types/src/browser/property/propertyMachine.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/react/services.d.ts.map +1 -1
- package/dist/types/src/browser/services/db/actors/waitForFiles.d.ts +4 -0
- package/dist/types/src/browser/services/db/actors/waitForFiles.d.ts.map +1 -0
- package/dist/types/src/node/codegen/drizzle.d.ts.map +1 -1
- package/dist/types/src/node/constants.d.ts.map +1 -1
- package/dist/types/src/node/webpack/index.d.ts.map +1 -1
- package/dist/types/src/shared/helpers/constants.d.ts.map +1 -1
- package/dist/types/src/shared/helpers/db.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-Br7jo_vg.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as __awaiter, d as __rest, i as internalPropertyNames, I as INTERNAL_DATA_TYPES, e as defaultAttestationData, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA } from './constants-
|
|
1
|
+
import { b as __awaiter, d as __rest, i as internalPropertyNames, I as INTERNAL_DATA_TYPES, e as defaultAttestationData, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA } from './constants-rmQ8zg8_.js';
|
|
2
2
|
import path, { basename } from 'path';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { Type } from '@sinclair/typebox';
|
|
@@ -60,7 +60,6 @@ const withSeed$1 = (config, webpack, isServer) => {
|
|
|
60
60
|
// console.log('crypto-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/crypto-browserify')))
|
|
61
61
|
// console.log('path-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/path-browserify')))
|
|
62
62
|
if (!isServer) {
|
|
63
|
-
console.log('config.resolve.alias:', config.resolve.alias);
|
|
64
63
|
config.resolve.alias['fs'] = path.resolve(process.cwd(), './node_modules/@zenfs/core');
|
|
65
64
|
config.resolve.alias['node:fs'] = path.resolve(process.cwd(), './node_modules/@zenfs/core');
|
|
66
65
|
config.resolve.alias['@schema'] = path.resolve(process.cwd(), 'schema.ts');
|
|
@@ -208,7 +207,7 @@ const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
208
207
|
}
|
|
209
208
|
});
|
|
210
209
|
|
|
211
|
-
const logger$
|
|
210
|
+
const logger$o = debug('app:shared:helpers');
|
|
212
211
|
const { alphanumeric } = nanoIdDictionary;
|
|
213
212
|
const generateId = () => {
|
|
214
213
|
return customAlphabet(alphanumeric, 10)();
|
|
@@ -273,7 +272,7 @@ const convertTxIdToImageSrc = (txId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
273
272
|
const imageFilePath = `/files/images/${txId}`;
|
|
274
273
|
const fileExists = yield fs.promises.exists(imageFilePath);
|
|
275
274
|
if (!fileExists) {
|
|
276
|
-
logger$
|
|
275
|
+
logger$o(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
|
|
277
276
|
return;
|
|
278
277
|
}
|
|
279
278
|
const uint = yield fs.promises.readFile(imageFilePath);
|
|
@@ -513,6 +512,7 @@ const getExistingItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ see
|
|
|
513
512
|
return existingItem;
|
|
514
513
|
});
|
|
515
514
|
|
|
515
|
+
const logger$n = debug('app:property:actors:resolveRelatedValue');
|
|
516
516
|
const storageTransactionIdToContentUrl = new Map();
|
|
517
517
|
const refResolvedValueToContentUrl = new Map();
|
|
518
518
|
const seedUidToContentUrl = new Map();
|
|
@@ -522,7 +522,14 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
522
522
|
if (!propertyValue || !isRelation) {
|
|
523
523
|
return;
|
|
524
524
|
}
|
|
525
|
-
|
|
525
|
+
let parsedValue;
|
|
526
|
+
try {
|
|
527
|
+
parsedValue = JSON.parse(propertyValue);
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
logger$n(`${propertyName} value is not a JSON string.`);
|
|
531
|
+
}
|
|
532
|
+
if (!parsedValue && seedUidToContentUrl.has(propertyValue)) {
|
|
526
533
|
const contentUrl = seedUidToContentUrl.get(propertyValue);
|
|
527
534
|
sendBack({
|
|
528
535
|
type: 'updateRenderValue',
|
|
@@ -536,6 +543,11 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
536
543
|
}
|
|
537
544
|
if (Array.isArray(propertyValue)) {
|
|
538
545
|
// TODO: Handle array of seedUids
|
|
546
|
+
logger$n(`${propertyName} value is an array of seedUids`);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
if (Array.isArray(parsedValue)) {
|
|
550
|
+
logger$n(`${propertyName} value is a stringified array of seedUids`);
|
|
539
551
|
return;
|
|
540
552
|
}
|
|
541
553
|
const storageTransactionId = yield getStorageTransactionIdForSeedUid(propertyValue);
|
|
@@ -608,7 +620,8 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
608
620
|
}
|
|
609
621
|
if (typeof propertyValueFromDb === 'string') {
|
|
610
622
|
// Check files for a filename that matches the propertyValue
|
|
611
|
-
if (propertyRecordSchema
|
|
623
|
+
if (propertyRecordSchema &&
|
|
624
|
+
propertyRecordSchema.refValueType === 'ImageSrc') {
|
|
612
625
|
let contentUrl;
|
|
613
626
|
if (storageTransactionIdToContentUrl.has(propertyValueFromDb)) {
|
|
614
627
|
contentUrl =
|
|
@@ -866,38 +879,6 @@ const resolveRemoteStorage = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
866
879
|
});
|
|
867
880
|
});
|
|
868
881
|
|
|
869
|
-
const escapeSqliteString = (value) => {
|
|
870
|
-
if (typeof value !== 'string') {
|
|
871
|
-
throw new Error(`Value must be a string, instead got: ${JSON.stringify(value)}`);
|
|
872
|
-
}
|
|
873
|
-
return value.replace(/'/g, "''");
|
|
874
|
-
};
|
|
875
|
-
const getAddressesFromDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
876
|
-
const appDb = getAppDb();
|
|
877
|
-
if (!appDb) {
|
|
878
|
-
return new Promise((resolve) => {
|
|
879
|
-
setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
880
|
-
const addresses = yield getAddressesFromDb();
|
|
881
|
-
resolve(addresses);
|
|
882
|
-
}), 500);
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
const appStatesRecords = yield appDb
|
|
886
|
-
.select()
|
|
887
|
-
.from(appState)
|
|
888
|
-
.where(eq(appState.key, 'addresses'))
|
|
889
|
-
.limit(1);
|
|
890
|
-
if (!appStatesRecords || appStatesRecords.length === 0) {
|
|
891
|
-
throw new Error('No appStatesRecords for addresses found');
|
|
892
|
-
}
|
|
893
|
-
const addressRecord = appStatesRecords[0];
|
|
894
|
-
const addressArrayString = addressRecord.value;
|
|
895
|
-
if (!addressArrayString) {
|
|
896
|
-
throw new Error('No addresses found');
|
|
897
|
-
}
|
|
898
|
-
return JSON.parse(addressArrayString);
|
|
899
|
-
});
|
|
900
|
-
|
|
901
882
|
const updateMetadata = (metadataValues) => __awaiter(void 0, void 0, void 0, function* () {
|
|
902
883
|
const appDb = getAppDb();
|
|
903
884
|
const { localId } = metadataValues, rest = __rest(metadataValues, ["localId"]);
|
|
@@ -924,13 +905,8 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
924
905
|
propertyName = propertyNameRaw + 'Ids';
|
|
925
906
|
}
|
|
926
907
|
const _hydrateFromDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
let safeValue = propertyValue;
|
|
930
|
-
let propertyNameQuery = eq(metadata.propertyName, propertyName);
|
|
931
|
-
if (safeValue && typeof propertyValue === 'string') {
|
|
932
|
-
safeValue = escapeSqliteString(propertyValue);
|
|
933
|
-
}
|
|
908
|
+
const appDb = getAppDb();
|
|
909
|
+
const whereClauses = [];
|
|
934
910
|
if (propertyRecordSchema &&
|
|
935
911
|
propertyRecordSchema.ref &&
|
|
936
912
|
propertyRecordSchema.dataType === 'Relation') {
|
|
@@ -941,22 +917,27 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
941
917
|
if (!propertyName.endsWith('Id')) {
|
|
942
918
|
missingPropertyNameVariant = propertyName + 'Id';
|
|
943
919
|
}
|
|
944
|
-
|
|
920
|
+
if (missingPropertyNameVariant) {
|
|
921
|
+
whereClauses.push(or(eq(metadata.propertyName, propertyName), eq(metadata.propertyName, missingPropertyNameVariant)));
|
|
922
|
+
}
|
|
923
|
+
if (!missingPropertyNameVariant) {
|
|
924
|
+
whereClauses.push(eq(metadata.propertyName, propertyName));
|
|
925
|
+
}
|
|
945
926
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
hydrateQuery = selectFromStatement.where(and(eq(metadata.seedUid, seedUid), propertyNameQuery));
|
|
927
|
+
else {
|
|
928
|
+
whereClauses.push(eq(metadata.propertyName, propertyName));
|
|
949
929
|
}
|
|
950
|
-
if (seedUid
|
|
951
|
-
|
|
930
|
+
if (seedUid) {
|
|
931
|
+
whereClauses.push(eq(metadata.seedUid, seedUid));
|
|
952
932
|
}
|
|
953
|
-
if (
|
|
954
|
-
|
|
933
|
+
if (seedLocalId) {
|
|
934
|
+
whereClauses.push(eq(metadata.seedLocalId, seedLocalId));
|
|
955
935
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
936
|
+
const rows = yield appDb
|
|
937
|
+
.select()
|
|
938
|
+
.from(metadata)
|
|
939
|
+
.where(and(...whereClauses))
|
|
940
|
+
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'));
|
|
960
941
|
if (!rows || !rows.length) {
|
|
961
942
|
return;
|
|
962
943
|
}
|
|
@@ -983,23 +964,26 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
983
964
|
if (seedUidFromDb !== seedUid) {
|
|
984
965
|
logger$m(`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`);
|
|
985
966
|
}
|
|
986
|
-
if (
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
967
|
+
if (propertyRecordSchema &&
|
|
968
|
+
propertyRecordSchema.refValueType === 'ImageSrc') {
|
|
969
|
+
let shouldReadFromFile = true;
|
|
970
|
+
if (refResolvedValue &&
|
|
971
|
+
refResolvedDisplayValue &&
|
|
972
|
+
refResolvedDisplayValue.includes('http')) {
|
|
973
|
+
try {
|
|
974
|
+
const response = yield fetch(refResolvedDisplayValue, {
|
|
975
|
+
method: 'HEAD',
|
|
976
|
+
});
|
|
977
|
+
// Check if the status is in the 200-299 range
|
|
978
|
+
if (response.ok) {
|
|
979
|
+
shouldReadFromFile = false;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
catch (error) {
|
|
983
|
+
shouldReadFromFile = true;
|
|
997
984
|
}
|
|
998
985
|
}
|
|
999
|
-
|
|
1000
|
-
urlNeedsToBeRefreshed = true;
|
|
1001
|
-
}
|
|
1002
|
-
if (urlNeedsToBeRefreshed) {
|
|
986
|
+
if (shouldReadFromFile) {
|
|
1003
987
|
let dir = localStorageDir;
|
|
1004
988
|
if (!dir &&
|
|
1005
989
|
propertyRecordSchema &&
|
|
@@ -1044,7 +1028,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1044
1028
|
if (propertyRecordSchema &&
|
|
1045
1029
|
propertyRecordSchema.storageType &&
|
|
1046
1030
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1047
|
-
const { Item } = yield import('./index-
|
|
1031
|
+
const { Item } = yield import('./index-D5bGQvS6.js');
|
|
1048
1032
|
const item = yield Item.find({
|
|
1049
1033
|
seedLocalId,
|
|
1050
1034
|
modelName: itemModelName,
|
|
@@ -1067,6 +1051,38 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1067
1051
|
});
|
|
1068
1052
|
});
|
|
1069
1053
|
|
|
1054
|
+
const escapeSqliteString = (value) => {
|
|
1055
|
+
if (typeof value !== 'string') {
|
|
1056
|
+
throw new Error(`Value must be a string, instead got: ${JSON.stringify(value)}`);
|
|
1057
|
+
}
|
|
1058
|
+
return value.replace(/'/g, "''");
|
|
1059
|
+
};
|
|
1060
|
+
const getAddressesFromDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1061
|
+
const appDb = getAppDb();
|
|
1062
|
+
if (!appDb) {
|
|
1063
|
+
return new Promise((resolve) => {
|
|
1064
|
+
setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
1065
|
+
const addresses = yield getAddressesFromDb();
|
|
1066
|
+
resolve(addresses);
|
|
1067
|
+
}), 500);
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
const appStatesRecords = yield appDb
|
|
1071
|
+
.select()
|
|
1072
|
+
.from(appState)
|
|
1073
|
+
.where(eq(appState.key, 'addresses'))
|
|
1074
|
+
.limit(1);
|
|
1075
|
+
if (!appStatesRecords || appStatesRecords.length === 0) {
|
|
1076
|
+
throw new Error('No appStatesRecords for addresses found');
|
|
1077
|
+
}
|
|
1078
|
+
const addressRecord = appStatesRecords[0];
|
|
1079
|
+
const addressArrayString = addressRecord.value;
|
|
1080
|
+
if (!addressArrayString) {
|
|
1081
|
+
throw new Error('No addresses found');
|
|
1082
|
+
}
|
|
1083
|
+
return JSON.parse(addressArrayString);
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1070
1086
|
const getVersionData$1 = () => {
|
|
1071
1087
|
const appDb = getAppDb();
|
|
1072
1088
|
return appDb.$with('versionData').as(appDb
|
|
@@ -1452,14 +1468,6 @@ class ItemProperty {
|
|
|
1452
1468
|
return;
|
|
1453
1469
|
}
|
|
1454
1470
|
const { context } = snapshot;
|
|
1455
|
-
const { propertyRecordSchema } = context;
|
|
1456
|
-
// if (this.uid && !cacheHasProperty(this.uid)) {
|
|
1457
|
-
// addPropertyToCache(this)
|
|
1458
|
-
// }
|
|
1459
|
-
//
|
|
1460
|
-
// if (!this.uid && this.localId && !cacheHasProperty(this.localId,)) {
|
|
1461
|
-
// addPropertyToCache(this)
|
|
1462
|
-
// }
|
|
1463
1471
|
if (context.seedLocalId) {
|
|
1464
1472
|
const cacheKey = ItemProperty.cacheKey(context.seedLocalId, context.propertyName);
|
|
1465
1473
|
if (!ItemProperty.instanceCache.has(cacheKey)) {
|
|
@@ -1475,17 +1483,26 @@ class ItemProperty {
|
|
|
1475
1483
|
// )
|
|
1476
1484
|
}
|
|
1477
1485
|
let renderValue;
|
|
1478
|
-
if (
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1486
|
+
// if (
|
|
1487
|
+
// propertyRecordSchema &&
|
|
1488
|
+
// propertyRecordSchema.storageType &&
|
|
1489
|
+
// propertyRecordSchema.storageType === 'ItemStorage' &&
|
|
1490
|
+
// context.resolvedValue &&
|
|
1491
|
+
// context.localStorageDir
|
|
1492
|
+
// ) {
|
|
1493
|
+
// const filePath = `/files/${context.localStorageDir}/${context.resolvedValue}`
|
|
1494
|
+
// try {
|
|
1495
|
+
// const exists = await fs.promises.exists(filePath)
|
|
1496
|
+
// if (exists) {
|
|
1497
|
+
// renderValue = await fs.promises.readFile(filePath, 'utf-8')
|
|
1498
|
+
// }
|
|
1499
|
+
// } catch (e) {
|
|
1500
|
+
// logger(
|
|
1501
|
+
// `[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`,
|
|
1502
|
+
// e,
|
|
1503
|
+
// )
|
|
1504
|
+
// }
|
|
1505
|
+
// }
|
|
1489
1506
|
if (!renderValue) {
|
|
1490
1507
|
renderValue = context.renderValue || context.propertyValue;
|
|
1491
1508
|
}
|
|
@@ -1561,13 +1578,11 @@ class ItemProperty {
|
|
|
1561
1578
|
const cacheKey = ItemProperty.cacheKey(cacheKeyId, propertyName);
|
|
1562
1579
|
if (this.instanceCache.has(cacheKey)) {
|
|
1563
1580
|
const { instance, refCount } = this.instanceCache.get(cacheKey);
|
|
1581
|
+
instance.getService().send({ type: 'reload' });
|
|
1564
1582
|
this.instanceCache.set(cacheKey, {
|
|
1565
1583
|
instance,
|
|
1566
1584
|
refCount: refCount + 1,
|
|
1567
1585
|
});
|
|
1568
|
-
if (instance.status === 'idle') {
|
|
1569
|
-
instance.getService().send({ type: 'refresh' });
|
|
1570
|
-
}
|
|
1571
1586
|
return instance;
|
|
1572
1587
|
}
|
|
1573
1588
|
const propertyData = yield getPropertyData(propertyName, seedLocalId, seedUid);
|
|
@@ -2575,7 +2590,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2575
2590
|
if (!models$1) {
|
|
2576
2591
|
return;
|
|
2577
2592
|
}
|
|
2578
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2593
|
+
const { models: SeedModels } = yield import('./seed.schema.config-CaxQONHV.js');
|
|
2579
2594
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2580
2595
|
let hasModelsInDb = false;
|
|
2581
2596
|
const schemaDefsByModelName = new Map();
|
|
@@ -5429,6 +5444,28 @@ const fetchDataFromEas = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5429
5444
|
});
|
|
5430
5445
|
});
|
|
5431
5446
|
|
|
5447
|
+
const reload = fromCallback(({ sendBack, input: { context } }) => {
|
|
5448
|
+
const { propertyInstances } = context;
|
|
5449
|
+
const _reload = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5450
|
+
if (!propertyInstances) {
|
|
5451
|
+
return;
|
|
5452
|
+
}
|
|
5453
|
+
for (const propertyInstance of propertyInstances.values()) {
|
|
5454
|
+
if (propertyInstance) {
|
|
5455
|
+
const propertyRecordSchema = propertyInstance.propertyDef;
|
|
5456
|
+
if (propertyRecordSchema &&
|
|
5457
|
+
propertyRecordSchema.storageType &&
|
|
5458
|
+
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
5459
|
+
propertyInstance.getService().send({ type: 'reload' });
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
});
|
|
5464
|
+
_reload().then(() => {
|
|
5465
|
+
sendBack({ type: 'reloadSuccess' });
|
|
5466
|
+
});
|
|
5467
|
+
});
|
|
5468
|
+
|
|
5432
5469
|
const itemMachineSingle = setup({
|
|
5433
5470
|
types: {
|
|
5434
5471
|
context: {},
|
|
@@ -5440,6 +5477,7 @@ const itemMachineSingle = setup({
|
|
|
5440
5477
|
hydrateExistingItem,
|
|
5441
5478
|
hydrateNewItem,
|
|
5442
5479
|
fetchDataFromEas,
|
|
5480
|
+
reload,
|
|
5443
5481
|
},
|
|
5444
5482
|
}).createMachine({
|
|
5445
5483
|
id: MachineIds.ITEM,
|
|
@@ -5491,17 +5529,7 @@ const itemMachineSingle = setup({
|
|
|
5491
5529
|
};
|
|
5492
5530
|
}),
|
|
5493
5531
|
},
|
|
5494
|
-
|
|
5495
|
-
// actions: assign(({ context, event }) => {
|
|
5496
|
-
// console.log('[singleItemMachine] [addPropertyAttestation] event', event)
|
|
5497
|
-
// const propertyInstances =
|
|
5498
|
-
// context.propertyInstances || new Map<string, typeof ItemProperty>()
|
|
5499
|
-
// propertyInstances.set(event.propertyName, event.propertyInstances)
|
|
5500
|
-
// return {
|
|
5501
|
-
// propertyInstances,
|
|
5502
|
-
// }
|
|
5503
|
-
// }),
|
|
5504
|
-
// },
|
|
5532
|
+
reload: '.reloading',
|
|
5505
5533
|
},
|
|
5506
5534
|
states: {
|
|
5507
5535
|
idle: {},
|
|
@@ -5566,24 +5594,15 @@ const itemMachineSingle = setup({
|
|
|
5566
5594
|
input: ({ context }) => ({ context }),
|
|
5567
5595
|
},
|
|
5568
5596
|
},
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
// savingDataToDb: {
|
|
5579
|
-
// on: {
|
|
5580
|
-
// saveDataToDbSuccess: 'idle',
|
|
5581
|
-
// },
|
|
5582
|
-
// invoke: {
|
|
5583
|
-
// src: 'saveDataToDb',
|
|
5584
|
-
// input: ({ context }) => ({ context }),
|
|
5585
|
-
// },
|
|
5586
|
-
// },
|
|
5597
|
+
reloading: {
|
|
5598
|
+
on: {
|
|
5599
|
+
reloadSuccess: 'idle',
|
|
5600
|
+
},
|
|
5601
|
+
invoke: {
|
|
5602
|
+
src: 'reload',
|
|
5603
|
+
input: ({ context }) => ({ context }),
|
|
5604
|
+
},
|
|
5605
|
+
},
|
|
5587
5606
|
destroying: {
|
|
5588
5607
|
type: 'final',
|
|
5589
5608
|
},
|
|
@@ -5593,15 +5612,21 @@ const itemMachineSingle = setup({
|
|
|
5593
5612
|
const getItemProperties = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLocalId, seedUid, edited, }) {
|
|
5594
5613
|
const appDb = getAppDb();
|
|
5595
5614
|
const whereClauses = [isNotNull(metadata.propertyName)];
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5615
|
+
if (seedUid) {
|
|
5616
|
+
whereClauses.push(eq(seeds.uid, seedUid));
|
|
5617
|
+
}
|
|
5618
|
+
if (seedLocalId) {
|
|
5619
|
+
whereClauses.push(eq(seeds.localId, seedLocalId));
|
|
5620
|
+
}
|
|
5621
|
+
// const uidWhereClause: SQL = seedUid
|
|
5622
|
+
// ? eq(seeds.uid, seedUid)
|
|
5623
|
+
// : isNull(seeds.uid)
|
|
5624
|
+
// const localWhereClause: SQL = seedLocalId
|
|
5625
|
+
// ? eq(seeds.localId, seedLocalId)
|
|
5626
|
+
// : isNull(seeds.localId)
|
|
5627
|
+
// whereClauses.push(or(localWhereClause, uidWhereClause) as SQL)
|
|
5603
5628
|
whereClauses.push(isNotNull(metadata.propertyName));
|
|
5604
|
-
whereClauses.push(isNotNull(metadata.easDataType))
|
|
5629
|
+
// whereClauses.push(isNotNull(metadata.easDataType))
|
|
5605
5630
|
if (typeof edited !== 'undefined') {
|
|
5606
5631
|
if (edited) {
|
|
5607
5632
|
whereClauses.push(isNull(metadata.uid));
|
|
@@ -5610,20 +5635,6 @@ const getItemProperties = (_a) => __awaiter(void 0, [_a], void 0, function* ({ s
|
|
|
5610
5635
|
whereClauses.push(isNotNull(metadata.uid));
|
|
5611
5636
|
}
|
|
5612
5637
|
}
|
|
5613
|
-
// if (!seedLocalId || !seedUid) {
|
|
5614
|
-
// const seedRows = await appDb
|
|
5615
|
-
// .select({
|
|
5616
|
-
// localId: seeds.localId,
|
|
5617
|
-
// uid: seeds.uid,
|
|
5618
|
-
// })
|
|
5619
|
-
// .from(seeds)
|
|
5620
|
-
// .where(or(localWhereClause, uidWhereClause))
|
|
5621
|
-
//
|
|
5622
|
-
// if (seedRows && seedRows.length > 0) {
|
|
5623
|
-
// seedUid = seedRows[0].uid as string
|
|
5624
|
-
// seedLocalId = seedRows[0].localId as string
|
|
5625
|
-
// }
|
|
5626
|
-
// }
|
|
5627
5638
|
const metadataColumns = getTableColumns(metadata);
|
|
5628
5639
|
const propertiesData = yield appDb
|
|
5629
5640
|
.select(Object.assign({}, metadataColumns))
|
|
@@ -5634,86 +5645,6 @@ const getItemProperties = (_a) => __awaiter(void 0, [_a], void 0, function* ({ s
|
|
|
5634
5645
|
.groupBy(metadata.propertyName);
|
|
5635
5646
|
return propertiesData;
|
|
5636
5647
|
});
|
|
5637
|
-
// const localIdWhere = seedLocalId
|
|
5638
|
-
// ? `s.local_id = '${seedLocalId}'`
|
|
5639
|
-
// : 's.local_id IS NULL'
|
|
5640
|
-
// const uidWhere = seedUid ? `s.uid = '${seedUid}'` : 's.uid IS NULL'
|
|
5641
|
-
//
|
|
5642
|
-
// const queryStatement = `WITH LatestMetadata as (SELECT m.property_name,
|
|
5643
|
-
// m.property_value,
|
|
5644
|
-
// m.version_local_id,
|
|
5645
|
-
// MAX(m.attestation_created_at),
|
|
5646
|
-
// m.uid,
|
|
5647
|
-
// m.seed_local_id,
|
|
5648
|
-
// seed_uid
|
|
5649
|
-
// FROM metadata m
|
|
5650
|
-
// JOIN seeds s ON s.local_id = m.seed_local_id
|
|
5651
|
-
// GROUP BY m.property_name),
|
|
5652
|
-
//
|
|
5653
|
-
// LatestVersion as (SELECT v.local_id,
|
|
5654
|
-
// MAX(v.attestation_created_at) as attestation_created_at,
|
|
5655
|
-
// v.uid,
|
|
5656
|
-
// v.seed_local_id,
|
|
5657
|
-
// v.seed_uid
|
|
5658
|
-
// FROM versions v
|
|
5659
|
-
// JOIN seeds s ON s.local_id = v.seed_local_id
|
|
5660
|
-
// GROUP BY s.local_id)
|
|
5661
|
-
//
|
|
5662
|
-
//
|
|
5663
|
-
// SELECT s.local_id,
|
|
5664
|
-
// s.uid,
|
|
5665
|
-
// s.schema_uid,
|
|
5666
|
-
// m.property_name,
|
|
5667
|
-
// m.property_value,
|
|
5668
|
-
// COUNT(v.local_id) as versions_count,
|
|
5669
|
-
// m.model_type,
|
|
5670
|
-
// lv.attestation_created_at,
|
|
5671
|
-
// m.local_id,
|
|
5672
|
-
// m.uid,
|
|
5673
|
-
// MAX(m.attestation_created_at),
|
|
5674
|
-
// m.ref_seed_type,
|
|
5675
|
-
// m.ref_value_type,
|
|
5676
|
-
// m.seed_local_id,
|
|
5677
|
-
// m.seed_uid,
|
|
5678
|
-
// m.created_at,
|
|
5679
|
-
// m.updated_at,
|
|
5680
|
-
// m.version_uid
|
|
5681
|
-
// FROM seeds s
|
|
5682
|
-
// JOIN LatestMetadata lm ON s.local_id = m.seed_local_id
|
|
5683
|
-
// JOIN LatestVersion lv ON lv.seed_local_id = m.seed_local_id
|
|
5684
|
-
// JOIN metadata m ON m.property_name = lm.property_name OR lm.property_value = s.uid
|
|
5685
|
-
// JOIN versions v ON s.local_id = v.seed_local_id
|
|
5686
|
-
// WHERE ${localIdWhere}
|
|
5687
|
-
// OR ${uidWhere}
|
|
5688
|
-
// GROUP BY m.property_name;
|
|
5689
|
-
// `
|
|
5690
|
-
//
|
|
5691
|
-
// const { rows } = await runQueryForStatement(queryStatement)
|
|
5692
|
-
//
|
|
5693
|
-
// const propertiesDataOld: PropertyData[] = []
|
|
5694
|
-
//
|
|
5695
|
-
// for (const row of rows) {
|
|
5696
|
-
// propertiesDataOld.push({
|
|
5697
|
-
// localId: row[0],
|
|
5698
|
-
// uid: row[1],
|
|
5699
|
-
// schemaUid: row[2],
|
|
5700
|
-
// propertyName: row[3],
|
|
5701
|
-
// propertyValue: row[4],
|
|
5702
|
-
// versionsCount: row[5],
|
|
5703
|
-
// itemModelName: row[6],
|
|
5704
|
-
// attestationCreatedAt: row[7],
|
|
5705
|
-
// metadataLocalId: row[8],
|
|
5706
|
-
// metadataUid: row[9],
|
|
5707
|
-
// metadataAttestationCreatedAt: row[10],
|
|
5708
|
-
// refSeedType: row[11],
|
|
5709
|
-
// refValueType: row[12],
|
|
5710
|
-
// seedLocalId: row[13],
|
|
5711
|
-
// seedUid: row[14],
|
|
5712
|
-
// createdAt: row[15],
|
|
5713
|
-
// updatedAt: row[16],
|
|
5714
|
-
// versionUid: row[17],
|
|
5715
|
-
// })
|
|
5716
|
-
// }
|
|
5717
5648
|
|
|
5718
5649
|
const getSeedData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLocalId, seedUid }) {
|
|
5719
5650
|
const appDb = getAppDb();
|
|
@@ -5771,39 +5702,22 @@ const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
5771
5702
|
return;
|
|
5772
5703
|
}
|
|
5773
5704
|
let itemData = itemDataRows[0];
|
|
5774
|
-
const propertiesData = yield getItemProperties({
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
// modelName,
|
|
5779
|
-
// }
|
|
5705
|
+
const propertiesData = yield getItemProperties({
|
|
5706
|
+
seedLocalId,
|
|
5707
|
+
seedUid: itemData.seedUid || undefined,
|
|
5708
|
+
});
|
|
5780
5709
|
if (!propertiesData || propertiesData.length === 0) {
|
|
5781
5710
|
return itemData;
|
|
5782
5711
|
}
|
|
5783
|
-
propertiesData[0];
|
|
5784
5712
|
for (const propertyData of propertiesData) {
|
|
5785
5713
|
const propertyName = propertyData.propertyName;
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
// initObj.refSeedType = refSeedType
|
|
5794
|
-
// }
|
|
5795
|
-
// const refValueType = propertyDbValues[12]
|
|
5796
|
-
// if (refValueType) {
|
|
5797
|
-
// initObj.refValueType = refValueType
|
|
5798
|
-
// }
|
|
5799
|
-
//
|
|
5800
|
-
// if (
|
|
5801
|
-
// refSeedType &&
|
|
5802
|
-
// refValueType === 'list' &&
|
|
5803
|
-
// propertyName.endsWith('Ids')
|
|
5804
|
-
// ) {
|
|
5805
|
-
// logger('[db/queries] [getItemDataFromDb] propertyName', propertyName)
|
|
5806
|
-
// }
|
|
5714
|
+
let propertyValue = propertyData.propertyValue;
|
|
5715
|
+
if (propertyName.endsWith('Id') || propertyName.endsWith('Ids')) {
|
|
5716
|
+
if (propertyData.refSeedType) {
|
|
5717
|
+
const propertyNameVariant = propertyName.replace(/Ids?$/, '');
|
|
5718
|
+
itemData[propertyNameVariant] = propertyValue;
|
|
5719
|
+
}
|
|
5720
|
+
}
|
|
5807
5721
|
itemData[propertyName] = propertyValue;
|
|
5808
5722
|
}
|
|
5809
5723
|
return itemData;
|
|
@@ -6001,9 +5915,6 @@ class Item {
|
|
|
6001
5915
|
}
|
|
6002
5916
|
static create(props) {
|
|
6003
5917
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6004
|
-
if (!props.seedUid) {
|
|
6005
|
-
console.log('Creating new item without seedUid');
|
|
6006
|
-
}
|
|
6007
5918
|
if (props.seedUid || props.seedLocalId) {
|
|
6008
5919
|
const seedId = (props.seedUid || props.seedLocalId);
|
|
6009
5920
|
if (Item.instanceCache.has(seedId)) {
|
|
@@ -6012,6 +5923,23 @@ class Item {
|
|
|
6012
5923
|
instance,
|
|
6013
5924
|
refCount: refCount + 1,
|
|
6014
5925
|
});
|
|
5926
|
+
for (const [propertyName, propertyValue] of Object.entries(props)) {
|
|
5927
|
+
const propertyInstances = instance.getService().getSnapshot()
|
|
5928
|
+
.context.propertyInstances;
|
|
5929
|
+
if (!propertyInstances || !propertyInstances.has(propertyName)) {
|
|
5930
|
+
continue;
|
|
5931
|
+
}
|
|
5932
|
+
const propertyInstance = propertyInstances.get(propertyName);
|
|
5933
|
+
if (!propertyInstance) {
|
|
5934
|
+
continue;
|
|
5935
|
+
}
|
|
5936
|
+
propertyInstance.getService().send({
|
|
5937
|
+
type: 'updateContext',
|
|
5938
|
+
propertyValue,
|
|
5939
|
+
});
|
|
5940
|
+
// propertyInstance.getService().send({ type: 'reload' })
|
|
5941
|
+
}
|
|
5942
|
+
// instance.getService().send({ type: 'reload' })
|
|
6015
5943
|
return instance;
|
|
6016
5944
|
}
|
|
6017
5945
|
if (!Item.instanceCache.has(seedId)) {
|
|
@@ -6445,7 +6373,7 @@ const useItems = ({ modelName, deleted }) => {
|
|
|
6445
6373
|
(item) => item.lastVersionPublishedAt ||
|
|
6446
6374
|
item.attestationCreatedAt ||
|
|
6447
6375
|
item.createdAt,
|
|
6448
|
-
], ['desc'])
|
|
6376
|
+
], ['desc']),
|
|
6449
6377
|
isReadingDb,
|
|
6450
6378
|
};
|
|
6451
6379
|
};
|
|
@@ -6662,7 +6590,7 @@ const client = {
|
|
|
6662
6590
|
console.error('fs listeners not ready during init');
|
|
6663
6591
|
}
|
|
6664
6592
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6665
|
-
import('./seed.schema.config-
|
|
6593
|
+
import('./seed.schema.config-CaxQONHV.js').then(({ models }) => {
|
|
6666
6594
|
for (const [key, value] of Object.entries(models)) {
|
|
6667
6595
|
setModel(key, value);
|
|
6668
6596
|
}
|
|
@@ -6874,11 +6802,75 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
6874
6802
|
${refSeedType ? `'${refSeedType}'` : 'NULL'},
|
|
6875
6803
|
${refResolvedValue ? `'${refResolvedValue}'` : 'NULL'},
|
|
6876
6804
|
${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
6805
|
+
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
6877
6806
|
${Date.now()});`;
|
|
6878
6807
|
yield runQueryForStatement(newPropertyStatement);
|
|
6879
6808
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
6880
6809
|
});
|
|
6881
6810
|
|
|
6811
|
+
const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
6812
|
+
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, itemModelName, schemaUid, } = context;
|
|
6813
|
+
let newValue;
|
|
6814
|
+
if (event) {
|
|
6815
|
+
newValue = event.newValue;
|
|
6816
|
+
}
|
|
6817
|
+
if (existingValue === newValue) {
|
|
6818
|
+
sendBack({ type: 'saveValueToDbSuccess' });
|
|
6819
|
+
return;
|
|
6820
|
+
}
|
|
6821
|
+
if (!propertyRecordSchema) {
|
|
6822
|
+
throw new Error('Missing propertyRecordSchema');
|
|
6823
|
+
}
|
|
6824
|
+
const _analyzeInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6825
|
+
let propertyName = propertyNameRaw;
|
|
6826
|
+
if (propertyRecordSchema.refValueType &&
|
|
6827
|
+
propertyRecordSchema.refValueType !== 'ImageSrc' &&
|
|
6828
|
+
propertyRecordSchema.dataType === 'Relation') {
|
|
6829
|
+
sendBack({
|
|
6830
|
+
type: 'saveRelation',
|
|
6831
|
+
newValue,
|
|
6832
|
+
});
|
|
6833
|
+
return false;
|
|
6834
|
+
}
|
|
6835
|
+
if (propertyRecordSchema.refValueType === 'ImageSrc' ||
|
|
6836
|
+
propertyRecordSchema.dataType === 'ImageSrc') {
|
|
6837
|
+
sendBack({
|
|
6838
|
+
type: 'saveImageSrc',
|
|
6839
|
+
newValue,
|
|
6840
|
+
});
|
|
6841
|
+
return false;
|
|
6842
|
+
}
|
|
6843
|
+
if (propertyRecordSchema.storageType &&
|
|
6844
|
+
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
6845
|
+
sendBack({
|
|
6846
|
+
type: 'saveItemStorage',
|
|
6847
|
+
newValue,
|
|
6848
|
+
});
|
|
6849
|
+
return false;
|
|
6850
|
+
}
|
|
6851
|
+
yield updateItemPropertyValue({
|
|
6852
|
+
localId: localId,
|
|
6853
|
+
propertyName,
|
|
6854
|
+
newValue,
|
|
6855
|
+
seedLocalId,
|
|
6856
|
+
versionLocalId,
|
|
6857
|
+
versionUid,
|
|
6858
|
+
modelName: itemModelName,
|
|
6859
|
+
schemaUid,
|
|
6860
|
+
});
|
|
6861
|
+
sendBack({
|
|
6862
|
+
type: 'updateContext',
|
|
6863
|
+
propertyValue: newValue,
|
|
6864
|
+
});
|
|
6865
|
+
return true;
|
|
6866
|
+
});
|
|
6867
|
+
_analyzeInput().then((isDone) => {
|
|
6868
|
+
if (isDone) {
|
|
6869
|
+
sendBack({ type: 'saveValueToDbSuccess' });
|
|
6870
|
+
}
|
|
6871
|
+
});
|
|
6872
|
+
});
|
|
6873
|
+
|
|
6882
6874
|
const readFileAsArrayBuffer = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6883
6875
|
return new Promise((resolve) => {
|
|
6884
6876
|
const reader = new FileReader();
|
|
@@ -6903,9 +6895,6 @@ const fetchImage = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
6903
6895
|
});
|
|
6904
6896
|
const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
6905
6897
|
const { localId, propertyName: propertyNameRaw, propertyValue: existingValue, propertyRecordSchema, itemModelName, seedLocalId, seedUid, versionLocalId, versionUid, schemaUid, } = context;
|
|
6906
|
-
if (seedLocalId === 'qpIzW1e52r') {
|
|
6907
|
-
console.log(`[saveImageSrc] versionLocaId is : ${versionLocalId}`);
|
|
6908
|
-
}
|
|
6909
6898
|
let newValue;
|
|
6910
6899
|
if (event) {
|
|
6911
6900
|
newValue = event.newValue;
|
|
@@ -7202,69 +7191,6 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
|
|
|
7202
7191
|
});
|
|
7203
7192
|
});
|
|
7204
7193
|
|
|
7205
|
-
const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
7206
|
-
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, itemModelName, schemaUid, } = context;
|
|
7207
|
-
let newValue;
|
|
7208
|
-
if (event) {
|
|
7209
|
-
newValue = event.newValue;
|
|
7210
|
-
}
|
|
7211
|
-
if (existingValue === newValue) {
|
|
7212
|
-
sendBack({ type: 'saveValueToDbSuccess' });
|
|
7213
|
-
return;
|
|
7214
|
-
}
|
|
7215
|
-
if (!propertyRecordSchema) {
|
|
7216
|
-
throw new Error('Missing propertyRecordSchema');
|
|
7217
|
-
}
|
|
7218
|
-
const _analyzeInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7219
|
-
let propertyName = propertyNameRaw;
|
|
7220
|
-
if (propertyRecordSchema.refValueType &&
|
|
7221
|
-
propertyRecordSchema.refValueType !== 'ImageSrc' &&
|
|
7222
|
-
propertyRecordSchema.dataType === 'Relation') {
|
|
7223
|
-
sendBack({
|
|
7224
|
-
type: 'saveRelation',
|
|
7225
|
-
newValue,
|
|
7226
|
-
});
|
|
7227
|
-
return false;
|
|
7228
|
-
}
|
|
7229
|
-
if (propertyRecordSchema.refValueType === 'ImageSrc' ||
|
|
7230
|
-
propertyRecordSchema.dataType === 'ImageSrc') {
|
|
7231
|
-
sendBack({
|
|
7232
|
-
type: 'saveImageSrc',
|
|
7233
|
-
newValue,
|
|
7234
|
-
});
|
|
7235
|
-
return false;
|
|
7236
|
-
}
|
|
7237
|
-
if (propertyRecordSchema.storageType &&
|
|
7238
|
-
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
7239
|
-
sendBack({
|
|
7240
|
-
type: 'saveItemStorage',
|
|
7241
|
-
newValue,
|
|
7242
|
-
});
|
|
7243
|
-
return false;
|
|
7244
|
-
}
|
|
7245
|
-
yield updateItemPropertyValue({
|
|
7246
|
-
localId: localId,
|
|
7247
|
-
propertyName,
|
|
7248
|
-
newValue,
|
|
7249
|
-
seedLocalId,
|
|
7250
|
-
versionLocalId,
|
|
7251
|
-
versionUid,
|
|
7252
|
-
modelName: itemModelName,
|
|
7253
|
-
schemaUid,
|
|
7254
|
-
});
|
|
7255
|
-
sendBack({
|
|
7256
|
-
type: 'updateContext',
|
|
7257
|
-
propertyValue: newValue,
|
|
7258
|
-
});
|
|
7259
|
-
return true;
|
|
7260
|
-
});
|
|
7261
|
-
_analyzeInput().then((isDone) => {
|
|
7262
|
-
if (isDone) {
|
|
7263
|
-
sendBack({ type: 'saveValueToDbSuccess' });
|
|
7264
|
-
}
|
|
7265
|
-
});
|
|
7266
|
-
});
|
|
7267
|
-
|
|
7268
7194
|
// import { updateMachineContext } from '@/browser/helpers'
|
|
7269
7195
|
const propertyMachine = setup({
|
|
7270
7196
|
types: {
|
|
@@ -7306,6 +7232,7 @@ const propertyMachine = setup({
|
|
|
7306
7232
|
};
|
|
7307
7233
|
}),
|
|
7308
7234
|
},
|
|
7235
|
+
reload: '.hydratingFromDb',
|
|
7309
7236
|
save: {
|
|
7310
7237
|
actions: assign({
|
|
7311
7238
|
isSaving: true,
|
|
@@ -7315,9 +7242,6 @@ const propertyMachine = setup({
|
|
|
7315
7242
|
updateContext: {
|
|
7316
7243
|
actions: assign(({ context, event }) => {
|
|
7317
7244
|
const newContext = Object.assign({}, context);
|
|
7318
|
-
if (context.seedLocalId === 'qpIzW1e52r') {
|
|
7319
|
-
console.log(`[updateContext] before update versionLocalId is ${context.versionLocalId}`);
|
|
7320
|
-
}
|
|
7321
7245
|
for (let i = 0; i < Object.keys(event).length; i++) {
|
|
7322
7246
|
const key = Object.keys(event)[i];
|
|
7323
7247
|
if (key === 'type') {
|
|
@@ -7325,9 +7249,6 @@ const propertyMachine = setup({
|
|
|
7325
7249
|
}
|
|
7326
7250
|
newContext[key] = event[key];
|
|
7327
7251
|
}
|
|
7328
|
-
if (context.seedLocalId === 'qpIzW1e52r') {
|
|
7329
|
-
console.log(`[updateContext] after update versionLocalId is ${newContext.versionLocalId}`);
|
|
7330
|
-
}
|
|
7331
7252
|
return newContext;
|
|
7332
7253
|
}),
|
|
7333
7254
|
},
|
|
@@ -7623,4 +7544,4 @@ if (isNode()) {
|
|
|
7623
7544
|
}
|
|
7624
7545
|
|
|
7625
7546
|
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 };
|
|
7626
|
-
//# sourceMappingURL=index-
|
|
7547
|
+
//# sourceMappingURL=index-nyYoS6hl.js.map
|