@seedprotocol/sdk 0.1.107 → 0.1.109
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 -1
- package/dist/{constants-qIJt7998.js → constants-CEnkzyny.js} +3 -3
- package/dist/{constants-qIJt7998.js.map → constants-CEnkzyny.js.map} +1 -1
- package/dist/{index-BmzLHFCL.js → index-vHcSfvyu.js} +3 -3
- package/dist/{index-BmzLHFCL.js.map → index-vHcSfvyu.js.map} +1 -1
- package/dist/{index-Dg23uBJg.js → index-vtm826YJ.js} +377 -161
- package/dist/index-vtm826YJ.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{seed.schema.config-C1zm5m77.js → seed.schema.config-Brb7H5eC.js} +3 -3
- package/dist/{seed.schema.config-C1zm5m77.js.map → seed.schema.config-Brb7H5eC.js.map} +1 -1
- package/dist/src/ItemProperty.ts +32 -11
- package/dist/src/actors.ts +289 -7
- package/dist/src/analyzeInput.ts +2 -2
- package/dist/src/getItem.ts +1 -1
- package/dist/src/getPublishPayload.ts +54 -59
- package/dist/src/getPublishUploads.ts +240 -0
- package/dist/src/getSegmentedItemProperties.ts +65 -0
- package/dist/src/hydrateFromDb.ts +4 -4
- package/dist/src/index.ts +62 -10
- package/dist/src/propertyMachine.ts +3 -2
- package/dist/src/read.ts +1 -1
- package/dist/src/resolveRelatedValue.ts +12 -12
- package/dist/src/saveImageSrc.ts +5 -5
- package/dist/src/saveItemStorage.ts +2 -2
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts +9 -1
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/types/src/browser/db/read/getPublishUploads.d.ts +17 -0
- package/dist/types/src/browser/db/read/getPublishUploads.d.ts.map +1 -0
- package/dist/types/src/browser/helpers/arweave.d.ts.map +1 -0
- package/dist/types/src/browser/helpers/getSegmentedItemProperties.d.ts +9 -0
- package/dist/types/src/browser/helpers/getSegmentedItemProperties.d.ts.map +1 -0
- package/dist/types/src/browser/item/Item.d.ts +3 -1
- package/dist/types/src/browser/item/Item.d.ts.map +1 -1
- package/dist/types/src/browser/property/ItemProperty.d.ts +195 -56
- package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts +1 -2
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/initialize.d.ts +1 -2
- package/dist/types/src/browser/property/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts +1 -2
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts +1 -2
- package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveRelation.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/waitForDb.d.ts +2 -2
- package/dist/types/src/browser/property/actors/waitForDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/propertyMachine.d.ts +195 -60
- package/dist/types/src/browser/property/propertyMachine.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/index.d.ts +1 -1
- package/dist/types/src/browser/schema/file/index.d.ts.map +1 -1
- package/dist/types/src/types/item.d.ts +1 -1
- package/dist/types/src/types/item.d.ts.map +1 -1
- package/dist/types/src/types/property.d.ts +3 -36
- package/dist/types/src/types/property.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-Dg23uBJg.js.map +0 -1
- package/dist/types/src/browser/schema/file/arweave.d.ts.map +0 -1
- /package/dist/types/src/browser/{schema/file → helpers}/arweave.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as __awaiter, d as __rest, i as internalPropertyNames, I as INTERNAL_DATA_TYPES, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, e as defaultAttestationData } from './constants-
|
|
1
|
+
import { b as __awaiter, d as __rest, i as internalPropertyNames, I as INTERNAL_DATA_TYPES, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, e as defaultAttestationData } from './constants-CEnkzyny.js';
|
|
2
2
|
import path, { basename } from 'path';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { Type } from '@sinclair/typebox';
|
|
@@ -26,7 +26,7 @@ import { BehaviorSubject } from 'rxjs';
|
|
|
26
26
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
27
27
|
import { WebAccess } from '@zenfs/dom';
|
|
28
28
|
import Arweave from 'arweave';
|
|
29
|
-
import { ZERO_BYTES32, SchemaEncoder
|
|
29
|
+
import { ZERO_BYTES32, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
|
|
30
30
|
|
|
31
31
|
const isNode = () => {
|
|
32
32
|
return (typeof process !== 'undefined' &&
|
|
@@ -214,7 +214,7 @@ const waitForDb$1 = fromCallback(({ sendBack }) => {
|
|
|
214
214
|
});
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
-
const logger$
|
|
217
|
+
const logger$p = debug('app:shared:helpers');
|
|
218
218
|
const { alphanumeric } = nanoIdDictionary;
|
|
219
219
|
const generateId = () => {
|
|
220
220
|
return customAlphabet(alphanumeric, 10)();
|
|
@@ -279,7 +279,7 @@ const convertTxIdToImageSrc = (txId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
279
279
|
const imageFilePath = `/files/images/${txId}`;
|
|
280
280
|
const fileExists = yield fs.promises.exists(imageFilePath);
|
|
281
281
|
if (!fileExists) {
|
|
282
|
-
logger$
|
|
282
|
+
logger$p(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
const uint = yield fs.promises.readFile(imageFilePath);
|
|
@@ -744,7 +744,7 @@ const getPropertyData$1 = (propertyName, seedLocalId, seedUid) => __awaiter(void
|
|
|
744
744
|
return;
|
|
745
745
|
}
|
|
746
746
|
const row = rows[0];
|
|
747
|
-
return Object.assign(Object.assign({}, row), {
|
|
747
|
+
return Object.assign(Object.assign({}, row), { modelName: startCase(row.modelType) });
|
|
748
748
|
});
|
|
749
749
|
const seedUidToStorageTransactionId = new Map();
|
|
750
750
|
const getStorageTransactionIdForSeedUid = (seedUid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -826,18 +826,18 @@ const getExistingItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ see
|
|
|
826
826
|
});
|
|
827
827
|
|
|
828
828
|
var _a$2;
|
|
829
|
-
const logger$
|
|
829
|
+
const logger$o = debug('app:property:class');
|
|
830
830
|
const namesThatEndWithId = [];
|
|
831
831
|
class ItemProperty {
|
|
832
832
|
// private constructor(localIdOrUid) {
|
|
833
833
|
// }
|
|
834
|
-
constructor({ propertyValue, seedUid, seedLocalId, versionLocalId, versionUid,
|
|
834
|
+
constructor({ propertyValue, seedUid, seedLocalId, versionLocalId, versionUid, modelName, propertyName, storageTransactionId, schemaUid, }) {
|
|
835
835
|
this._isRelation = false;
|
|
836
836
|
this._isList = false;
|
|
837
837
|
this[_a$2] = true;
|
|
838
|
-
const ModelClass = getModel(
|
|
838
|
+
const ModelClass = getModel(modelName);
|
|
839
839
|
if (!ModelClass) {
|
|
840
|
-
throw new Error(`Model ${
|
|
840
|
+
throw new Error(`Model ${modelName} not found`);
|
|
841
841
|
}
|
|
842
842
|
if (!propertyName) {
|
|
843
843
|
throw new Error(`Property name not provided`);
|
|
@@ -849,7 +849,7 @@ class ItemProperty {
|
|
|
849
849
|
seedUid,
|
|
850
850
|
versionLocalId,
|
|
851
851
|
versionUid,
|
|
852
|
-
|
|
852
|
+
modelName: modelName,
|
|
853
853
|
storageTransactionId,
|
|
854
854
|
propertyRecordSchema: ModelClass.schema[propertyName],
|
|
855
855
|
schemaUid,
|
|
@@ -876,7 +876,7 @@ class ItemProperty {
|
|
|
876
876
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
877
877
|
}
|
|
878
878
|
catch (e) {
|
|
879
|
-
logger$
|
|
879
|
+
logger$o('List property value is not JSON', e);
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
882
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -898,6 +898,15 @@ class ItemProperty {
|
|
|
898
898
|
return;
|
|
899
899
|
}
|
|
900
900
|
const { context } = snapshot;
|
|
901
|
+
// if (
|
|
902
|
+
// context.propertyName &&
|
|
903
|
+
// context.propertyName.includes('featureImage')
|
|
904
|
+
// ) {
|
|
905
|
+
// console.log(
|
|
906
|
+
// `${context.localId} context for ${snapshot.value}`,
|
|
907
|
+
// context,
|
|
908
|
+
// )
|
|
909
|
+
// }
|
|
901
910
|
if (context.seedLocalId) {
|
|
902
911
|
const cacheKey = ItemProperty.cacheKey(context.seedLocalId, context.propertyName);
|
|
903
912
|
if (!ItemProperty.instanceCache.has(cacheKey)) {
|
|
@@ -950,16 +959,16 @@ class ItemProperty {
|
|
|
950
959
|
if (skipTransform && !this._alias) ;
|
|
951
960
|
this._subject.next(renderValue);
|
|
952
961
|
if (context.seedLocalId) {
|
|
953
|
-
eventEmitter.emit(`item.${
|
|
962
|
+
eventEmitter.emit(`item.${modelName}.${context.seedLocalId}.update`);
|
|
954
963
|
}
|
|
955
964
|
if (context.seedUid) {
|
|
956
|
-
eventEmitter.emit(`item.${
|
|
965
|
+
eventEmitter.emit(`item.${modelName}.${context.seedUid}.update`);
|
|
957
966
|
}
|
|
958
967
|
}));
|
|
959
968
|
this._service.start();
|
|
960
969
|
}
|
|
961
970
|
_updateResponseListener(event) {
|
|
962
|
-
logger$
|
|
971
|
+
logger$o(`[ItemProperty] [_updateResponseListener] [${this.modelName}.${this.seedLocalId}] ${this.propertyName} event`, event);
|
|
963
972
|
}
|
|
964
973
|
static create(props) {
|
|
965
974
|
const { propertyName, seedLocalId, seedUid, versionLocalId, versionUid } = props;
|
|
@@ -1052,12 +1061,23 @@ class ItemProperty {
|
|
|
1052
1061
|
}
|
|
1053
1062
|
return this._getSnapshot().context.propertyName;
|
|
1054
1063
|
}
|
|
1055
|
-
get
|
|
1056
|
-
return this._getSnapshot().context.
|
|
1064
|
+
get modelName() {
|
|
1065
|
+
return this._getSnapshot().context.modelName;
|
|
1057
1066
|
}
|
|
1058
1067
|
get propertyDef() {
|
|
1059
1068
|
return this._getSnapshot().context.propertyRecordSchema;
|
|
1060
1069
|
}
|
|
1070
|
+
get localStoragePath() {
|
|
1071
|
+
if (this.propertyDef && this.propertyDef.localStorageDir) {
|
|
1072
|
+
return `/files${this.propertyDef.localStorageDir}/${this._getSnapshot().context.refResolvedValue}`;
|
|
1073
|
+
}
|
|
1074
|
+
if (this._getSnapshot().context.localStorageDir) {
|
|
1075
|
+
return `/files${this._getSnapshot().context.localStorageDir}/${this._getSnapshot().context.refResolvedValue}`;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
get versionLocalId() {
|
|
1079
|
+
return this._getSnapshot().context.versionLocalId;
|
|
1080
|
+
}
|
|
1061
1081
|
get status() {
|
|
1062
1082
|
return this._getSnapshot().value;
|
|
1063
1083
|
}
|
|
@@ -1106,7 +1126,7 @@ class ItemProperty {
|
|
|
1106
1126
|
}
|
|
1107
1127
|
unload() {
|
|
1108
1128
|
this._service.stop();
|
|
1109
|
-
logger$
|
|
1129
|
+
logger$o(`[XXXXXX] [ItemProperty] [${this.seedLocalId}] [unload] removing listener`, this._updateResponseEvent);
|
|
1110
1130
|
eventEmitter.removeListener(this._updateResponseEvent, this._updateResponseListener);
|
|
1111
1131
|
}
|
|
1112
1132
|
}
|
|
@@ -1958,7 +1978,7 @@ const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
1958
1978
|
trailing: false,
|
|
1959
1979
|
});
|
|
1960
1980
|
|
|
1961
|
-
const logger$
|
|
1981
|
+
const logger$n = debug('app:services:global:actors:initialize');
|
|
1962
1982
|
const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
1963
1983
|
const { internalService, models, endpoints } = context;
|
|
1964
1984
|
const { addresses } = event;
|
|
@@ -1979,7 +1999,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1979
1999
|
const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1980
2000
|
return new Promise((resolve) => {
|
|
1981
2001
|
internalSubscription = internalService.subscribe((snapshot) => {
|
|
1982
|
-
logger$
|
|
2002
|
+
logger$n('[sdk] [internal] snapshot', snapshot);
|
|
1983
2003
|
if (snapshot.value === 'ready') {
|
|
1984
2004
|
resolve();
|
|
1985
2005
|
}
|
|
@@ -2016,7 +2036,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
2016
2036
|
yield fetchSchemaUids();
|
|
2017
2037
|
});
|
|
2018
2038
|
_initFileSystem().then(() => {
|
|
2019
|
-
logger$
|
|
2039
|
+
logger$n('[global/actors] File system initialized');
|
|
2020
2040
|
});
|
|
2021
2041
|
_initInternal()
|
|
2022
2042
|
.then(() => {
|
|
@@ -2026,7 +2046,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
2026
2046
|
return _initEas();
|
|
2027
2047
|
})
|
|
2028
2048
|
.then(() => {
|
|
2029
|
-
logger$
|
|
2049
|
+
logger$n('[global/actors] Internal initialized');
|
|
2030
2050
|
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
2031
2051
|
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
2032
2052
|
});
|
|
@@ -2040,7 +2060,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
2040
2060
|
};
|
|
2041
2061
|
});
|
|
2042
2062
|
|
|
2043
|
-
const logger$
|
|
2063
|
+
const logger$m = debug('app:services:global:actors:getSchemaForModel');
|
|
2044
2064
|
const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
2045
2065
|
const { modelName } = event;
|
|
2046
2066
|
if (!modelName) {
|
|
@@ -2056,12 +2076,12 @@ const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } })
|
|
|
2056
2076
|
if (!model) {
|
|
2057
2077
|
throw new Error(`Model ${modelName} not found`);
|
|
2058
2078
|
}
|
|
2059
|
-
logger$
|
|
2079
|
+
logger$m('[service/actor] [getSchemaForModel] model:', model);
|
|
2060
2080
|
sendBack({ type: 'schemaForModel', schema: model.schema });
|
|
2061
2081
|
return () => { };
|
|
2062
2082
|
});
|
|
2063
2083
|
|
|
2064
|
-
const logger$
|
|
2084
|
+
const logger$l = debug('app:services:global:actors:addModelsToDb');
|
|
2065
2085
|
const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2066
2086
|
const { models: models$1 } = context;
|
|
2067
2087
|
const _addModelsToDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -2070,12 +2090,12 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2070
2090
|
if (!models$1) {
|
|
2071
2091
|
return;
|
|
2072
2092
|
}
|
|
2073
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2093
|
+
const { models: SeedModels } = yield import('./seed.schema.config-Brb7H5eC.js');
|
|
2074
2094
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2075
2095
|
let hasModelsInDb = false;
|
|
2076
2096
|
const schemaDefsByModelName = new Map();
|
|
2077
2097
|
for (const [modelName, _] of Object.entries(allModels)) {
|
|
2078
|
-
logger$
|
|
2098
|
+
logger$l('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
|
|
2079
2099
|
let foundModel;
|
|
2080
2100
|
const foundModelsQuery = yield appDb
|
|
2081
2101
|
.select()
|
|
@@ -2085,7 +2105,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2085
2105
|
yield appDb.insert(models).values({
|
|
2086
2106
|
name: modelName,
|
|
2087
2107
|
});
|
|
2088
|
-
logger$
|
|
2108
|
+
logger$l('[global/actors] [addModelsToDb] inserted model:', modelName);
|
|
2089
2109
|
const foundModels = yield appDb
|
|
2090
2110
|
.select({
|
|
2091
2111
|
id: models.id,
|
|
@@ -2155,10 +2175,10 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2155
2175
|
return () => { };
|
|
2156
2176
|
});
|
|
2157
2177
|
|
|
2158
|
-
const logger$
|
|
2178
|
+
const logger$k = debug('app:services:db:actors:checkStatus');
|
|
2159
2179
|
const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
2160
2180
|
const { dbName } = context;
|
|
2161
|
-
logger$
|
|
2181
|
+
logger$k('[db/actors] checkStatus context', context);
|
|
2162
2182
|
const pathToDir = `${BROWSER_FS_TOP_DIR}`;
|
|
2163
2183
|
const pathToDbDir = `${pathToDir}/db`;
|
|
2164
2184
|
const pathToDb = `${pathToDbDir}/${dbName}.sqlite3`;
|
|
@@ -2189,9 +2209,9 @@ const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2189
2209
|
});
|
|
2190
2210
|
});
|
|
2191
2211
|
|
|
2192
|
-
const logger$
|
|
2212
|
+
const logger$j = debug('app:services:db:actors:connectToDb');
|
|
2193
2213
|
const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2194
|
-
logger$
|
|
2214
|
+
logger$j('[db/actors] connectToDb context', context);
|
|
2195
2215
|
const { dbName, pathToDir } = context;
|
|
2196
2216
|
let isConnecting = false;
|
|
2197
2217
|
let dbId;
|
|
@@ -2204,16 +2224,16 @@ const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2204
2224
|
const sqliteWasmClient = yield getSqliteWasmClient();
|
|
2205
2225
|
//@ts-ignore
|
|
2206
2226
|
response = yield sqliteWasmClient('config-get', {});
|
|
2207
|
-
logger$
|
|
2208
|
-
logger$
|
|
2227
|
+
logger$j(response);
|
|
2228
|
+
logger$j('Running SQLite3 version', response.result.version.libVersion);
|
|
2209
2229
|
//@ts-ignore
|
|
2210
2230
|
response = yield sqliteWasmClient('open', {
|
|
2211
2231
|
filename: `file:${pathToDir}/db/${dbName}.sqlite3?vfs=opfs`,
|
|
2212
2232
|
});
|
|
2213
|
-
logger$
|
|
2233
|
+
logger$j(response);
|
|
2214
2234
|
dbId = response.dbId;
|
|
2215
2235
|
// logger(`dbId: ${dbId}`)
|
|
2216
|
-
logger$
|
|
2236
|
+
logger$j('OPFS is available, created persisted database at', response.result.filename.replace(/^file:(.*?)\?vfs=opfs$/, '$1'));
|
|
2217
2237
|
});
|
|
2218
2238
|
const interval = setInterval(() => {
|
|
2219
2239
|
// TODO: Add a timeout
|
|
@@ -2270,7 +2290,7 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2270
2290
|
});
|
|
2271
2291
|
});
|
|
2272
2292
|
|
|
2273
|
-
const logger$
|
|
2293
|
+
const logger$i = debug('app:services:db:actors:migrate');
|
|
2274
2294
|
const dbExec = (dbId_1, params_1, sql_1, dbName_1, ...args_1) => __awaiter(void 0, [dbId_1, params_1, sql_1, dbName_1, ...args_1], void 0, function* (dbId, params, sql, dbName, retries = 2) {
|
|
2275
2295
|
const rowsToReturnRaw = [];
|
|
2276
2296
|
const sqliteWasmClient = yield getSqliteWasmClient();
|
|
@@ -2336,7 +2356,7 @@ const dbExec = (dbId_1, params_1, sql_1, dbName_1, ...args_1) => __awaiter(void
|
|
|
2336
2356
|
});
|
|
2337
2357
|
const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
2338
2358
|
const { pathToDbDir, dbId, dbName } = context;
|
|
2339
|
-
logger$
|
|
2359
|
+
logger$i('[db/actors] migrate context', context);
|
|
2340
2360
|
const schemaGlobString = `${BROWSER_FS_TOP_DIR}/schema/*`;
|
|
2341
2361
|
let journalExists = false;
|
|
2342
2362
|
// const _initFs = async (): Promise<void> => {
|
|
@@ -2500,7 +2520,7 @@ const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2500
2520
|
return () => { };
|
|
2501
2521
|
});
|
|
2502
2522
|
|
|
2503
|
-
const logger$
|
|
2523
|
+
const logger$h = debug('app:services:db:machine');
|
|
2504
2524
|
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
2505
2525
|
const dbMachine = setup({
|
|
2506
2526
|
types: {
|
|
@@ -2521,7 +2541,7 @@ const dbMachine = setup({
|
|
|
2521
2541
|
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
2522
2542
|
actions: assign({
|
|
2523
2543
|
hasFiles: ({ event }) => {
|
|
2524
|
-
logger$
|
|
2544
|
+
logger$h('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
2525
2545
|
return true;
|
|
2526
2546
|
},
|
|
2527
2547
|
}),
|
|
@@ -2530,8 +2550,8 @@ const dbMachine = setup({
|
|
|
2530
2550
|
target: `.${CHECKING_STATUS}`,
|
|
2531
2551
|
actions: assign({
|
|
2532
2552
|
hasFiles: ({ context, event }) => {
|
|
2533
|
-
logger$
|
|
2534
|
-
logger$
|
|
2553
|
+
logger$h('[db/machine] updateHasFiles event:', event);
|
|
2554
|
+
logger$h('[db/machine] updateHasFiles context:', context);
|
|
2535
2555
|
return event.hasFiles;
|
|
2536
2556
|
},
|
|
2537
2557
|
}),
|
|
@@ -2747,7 +2767,7 @@ const prepareDb = fromCallback(({ sendBack }) => {
|
|
|
2747
2767
|
};
|
|
2748
2768
|
});
|
|
2749
2769
|
|
|
2750
|
-
const logger$
|
|
2770
|
+
const logger$g = debug('app:services:internal:helpers');
|
|
2751
2771
|
/**
|
|
2752
2772
|
* Recursively create directories if they don't exist.
|
|
2753
2773
|
* @param {string} dirPath - The directory path to create.
|
|
@@ -2823,7 +2843,7 @@ const downloadFile = (url, localFilePath) => __awaiter(void 0, void 0, void 0, f
|
|
|
2823
2843
|
if (JSON.stringify(error).includes('File exists')) {
|
|
2824
2844
|
yield fs.promises.readFile(localFilePath, 'utf-8');
|
|
2825
2845
|
}
|
|
2826
|
-
logger$
|
|
2846
|
+
logger$g(`[Error] Failed to download file from ${url}:`, error);
|
|
2827
2847
|
}
|
|
2828
2848
|
busy = false;
|
|
2829
2849
|
});
|
|
@@ -2861,7 +2881,7 @@ const syncDbFiles = (_a) => __awaiter(void 0, [_a], void 0, function* ({ filePat
|
|
|
2861
2881
|
const fileList = yield fetchDirectory(filePaths);
|
|
2862
2882
|
yield fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList);
|
|
2863
2883
|
yield confirmFilesExist(fileList);
|
|
2864
|
-
logger$
|
|
2884
|
+
logger$g('[syncDbFiles] Files synced!');
|
|
2865
2885
|
});
|
|
2866
2886
|
|
|
2867
2887
|
const uploadBinaryData = fromCallback(({ sendBack, receive, input }) => { });
|
|
@@ -3100,7 +3120,7 @@ const saveAppState = (key, value) => __awaiter(void 0, void 0, void 0, function*
|
|
|
3100
3120
|
});
|
|
3101
3121
|
});
|
|
3102
3122
|
|
|
3103
|
-
const logger$
|
|
3123
|
+
const logger$f = debug('app:files:download');
|
|
3104
3124
|
const downloadAllFilesRequestHandler = (_a) => __awaiter(void 0, [_a], void 0, function* ({ endpoints, eventId, }) {
|
|
3105
3125
|
yield syncDbFiles(endpoints);
|
|
3106
3126
|
eventEmitter.emit('fs.downloadAll.success', { eventId });
|
|
@@ -3184,7 +3204,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3184
3204
|
try {
|
|
3185
3205
|
const res = yield fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
|
|
3186
3206
|
if (res.status !== 200) {
|
|
3187
|
-
logger$
|
|
3207
|
+
logger$f(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
3188
3208
|
excludedTransactions.add(transactionId);
|
|
3189
3209
|
yield saveAppState('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
3190
3210
|
continue;
|
|
@@ -3224,7 +3244,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3224
3244
|
// string: true,
|
|
3225
3245
|
// })
|
|
3226
3246
|
if (!dataString) {
|
|
3227
|
-
logger$
|
|
3247
|
+
logger$f(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not found`);
|
|
3228
3248
|
}
|
|
3229
3249
|
let contentType = identifyString(dataString);
|
|
3230
3250
|
if (contentType !== 'json' &&
|
|
@@ -3232,7 +3252,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3232
3252
|
contentType !== 'html') {
|
|
3233
3253
|
const possibleImageType = getDataTypeFromString(dataString);
|
|
3234
3254
|
if (!possibleImageType) {
|
|
3235
|
-
logger$
|
|
3255
|
+
logger$f(`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`);
|
|
3236
3256
|
continue;
|
|
3237
3257
|
}
|
|
3238
3258
|
contentType = possibleImageType;
|
|
@@ -3299,7 +3319,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
3299
3319
|
}
|
|
3300
3320
|
}
|
|
3301
3321
|
catch (error) {
|
|
3302
|
-
logger$
|
|
3322
|
+
logger$f(error);
|
|
3303
3323
|
}
|
|
3304
3324
|
}
|
|
3305
3325
|
});
|
|
@@ -3345,14 +3365,14 @@ const isFsInitialized = () => {
|
|
|
3345
3365
|
return isInitialized;
|
|
3346
3366
|
};
|
|
3347
3367
|
|
|
3348
|
-
const logger$
|
|
3368
|
+
const logger$e = debug('app:internal:actors:configureFs');
|
|
3349
3369
|
const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
3350
3370
|
const { endpoints, appDbService } = context;
|
|
3351
|
-
logger$
|
|
3371
|
+
logger$e('[internal/actors] [configureFs] Configuring FS');
|
|
3352
3372
|
const _configureFs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3353
|
-
logger$
|
|
3354
|
-
logger$
|
|
3355
|
-
logger$
|
|
3373
|
+
logger$e('[internal/actors] [configureFs] calling _configureFs');
|
|
3374
|
+
logger$e('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
|
|
3375
|
+
logger$e('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
|
|
3356
3376
|
yield waitForEvent({
|
|
3357
3377
|
req: {
|
|
3358
3378
|
eventLabel: 'fs.downloadAll.request',
|
|
@@ -3381,7 +3401,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3381
3401
|
// }
|
|
3382
3402
|
// }, 200)
|
|
3383
3403
|
// })
|
|
3384
|
-
logger$
|
|
3404
|
+
logger$e('[internal/actors] [configureFs] fs configured!');
|
|
3385
3405
|
});
|
|
3386
3406
|
// Some of our dependencies use fs sync functions, which don't work with
|
|
3387
3407
|
// OPFS. ZenFS creates an async cache of all files so that the sync functions
|
|
@@ -3394,7 +3414,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3394
3414
|
return () => { };
|
|
3395
3415
|
});
|
|
3396
3416
|
|
|
3397
|
-
const logger$
|
|
3417
|
+
const logger$d = debug('app:services:internal:actors:saveConfig');
|
|
3398
3418
|
const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
3399
3419
|
if (typeof window === 'undefined') {
|
|
3400
3420
|
console.error('seedInitBrowser called from non-browser context');
|
|
@@ -3445,20 +3465,20 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3445
3465
|
},
|
|
3446
3466
|
setWhere: sql `key = 'addresses'`,
|
|
3447
3467
|
});
|
|
3448
|
-
logger$
|
|
3468
|
+
logger$d('[sdk] [internal/actors] Should be done saving');
|
|
3449
3469
|
}
|
|
3450
3470
|
catch (error) {
|
|
3451
3471
|
console.error('Error saving config:', error);
|
|
3452
3472
|
}
|
|
3453
3473
|
});
|
|
3454
3474
|
_saveConfig().then(() => {
|
|
3455
|
-
logger$
|
|
3475
|
+
logger$d('[sdk] [internal/actors] Successfully saved config');
|
|
3456
3476
|
return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
|
|
3457
3477
|
});
|
|
3458
3478
|
return () => { };
|
|
3459
3479
|
});
|
|
3460
3480
|
|
|
3461
|
-
const logger$
|
|
3481
|
+
const logger$c = debug('app:services:internal:actors:loadAppDb');
|
|
3462
3482
|
const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
3463
3483
|
const { appDbService } = context;
|
|
3464
3484
|
let subscription;
|
|
@@ -3479,7 +3499,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3479
3499
|
});
|
|
3480
3500
|
_loadAppDb().then(() => {
|
|
3481
3501
|
sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
|
|
3482
|
-
logger$
|
|
3502
|
+
logger$c('[sdk] [internal/actors] Successfully loaded app DB');
|
|
3483
3503
|
});
|
|
3484
3504
|
return () => {
|
|
3485
3505
|
if (subscription) {
|
|
@@ -3488,7 +3508,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3488
3508
|
};
|
|
3489
3509
|
});
|
|
3490
3510
|
|
|
3491
|
-
const logger$
|
|
3511
|
+
const logger$b = debug('app:services:internal:machine');
|
|
3492
3512
|
createBrowserInspector({
|
|
3493
3513
|
autoStart: false,
|
|
3494
3514
|
});
|
|
@@ -3587,7 +3607,7 @@ const internalMachine = setup({
|
|
|
3587
3607
|
[INTERNAL_LOADING_APP_DB_SUCCESS]: {
|
|
3588
3608
|
target: SAVING_CONFIG,
|
|
3589
3609
|
actions: () => {
|
|
3590
|
-
logger$
|
|
3610
|
+
logger$b('[sdk] [internal/index] App DB loaded!');
|
|
3591
3611
|
},
|
|
3592
3612
|
},
|
|
3593
3613
|
},
|
|
@@ -3613,7 +3633,7 @@ const internalMachine = setup({
|
|
|
3613
3633
|
},
|
|
3614
3634
|
ready: {
|
|
3615
3635
|
entry: () => {
|
|
3616
|
-
logger$
|
|
3636
|
+
logger$b('[sdk] [internal/index] Ready!');
|
|
3617
3637
|
},
|
|
3618
3638
|
meta: {
|
|
3619
3639
|
displayText: "Crossing the t's ...",
|
|
@@ -3628,7 +3648,7 @@ const internalMachine = setup({
|
|
|
3628
3648
|
},
|
|
3629
3649
|
},
|
|
3630
3650
|
entry: () => {
|
|
3631
|
-
logger$
|
|
3651
|
+
logger$b('[sdk] [internal/index] Error!');
|
|
3632
3652
|
},
|
|
3633
3653
|
meta: {
|
|
3634
3654
|
displayText: 'Whoops! Something went wrong.',
|
|
@@ -3864,7 +3884,7 @@ const fetchDbData = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3864
3884
|
return () => { };
|
|
3865
3885
|
});
|
|
3866
3886
|
|
|
3867
|
-
const logger$
|
|
3887
|
+
const logger$a = debug('app:allItemsActors:fetchSeeds');
|
|
3868
3888
|
const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
3869
3889
|
const { queryVariables, modelName } = context;
|
|
3870
3890
|
if (!queryVariables) {
|
|
@@ -3874,7 +3894,7 @@ const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3874
3894
|
const _fetchSeeds = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3875
3895
|
const queryKey = [`getSeeds${modelName}`];
|
|
3876
3896
|
const cachedResults = queryClient.getQueryData(queryKey);
|
|
3877
|
-
logger$
|
|
3897
|
+
logger$a(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
|
|
3878
3898
|
const results = yield queryClient.fetchQuery({
|
|
3879
3899
|
queryKey,
|
|
3880
3900
|
queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return easClient.request(GET_SEEDS, queryVariables); }),
|
|
@@ -4319,13 +4339,13 @@ const preparePublishRequestData = fromCallback(({ sendBack, input: { context } }
|
|
|
4319
4339
|
});
|
|
4320
4340
|
});
|
|
4321
4341
|
|
|
4322
|
-
const logger$
|
|
4342
|
+
const logger$9 = debug('app:services:publish:actors:upload');
|
|
4323
4343
|
const upload = fromCallback(({ sendBack, input: { context } }) => {
|
|
4324
4344
|
const { localId } = context;
|
|
4325
4345
|
const _upload = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4326
4346
|
const item = yield Item.find({ seedLocalId: localId });
|
|
4327
4347
|
if (!item) {
|
|
4328
|
-
logger$
|
|
4348
|
+
logger$9('no item with localId', localId);
|
|
4329
4349
|
return false;
|
|
4330
4350
|
}
|
|
4331
4351
|
const editedProperties = yield item.getEditedProperties();
|
|
@@ -5159,7 +5179,7 @@ const getSeedData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLoc
|
|
|
5159
5179
|
return rows[0];
|
|
5160
5180
|
});
|
|
5161
5181
|
|
|
5162
|
-
const logger$
|
|
5182
|
+
const logger$8 = debug('app:db:queries:getItem');
|
|
5163
5183
|
const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName, seedLocalId, seedUid, }) {
|
|
5164
5184
|
if (!seedLocalId && !seedUid) {
|
|
5165
5185
|
throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
|
|
@@ -5167,7 +5187,7 @@ const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
5167
5187
|
if (seedUid && !seedLocalId) {
|
|
5168
5188
|
const seedData = yield getSeedData({ seedUid });
|
|
5169
5189
|
if (!seedData) {
|
|
5170
|
-
logger$
|
|
5190
|
+
logger$8('[db/queries] [getItem] no seedData seedUid', seedUid);
|
|
5171
5191
|
return;
|
|
5172
5192
|
}
|
|
5173
5193
|
seedLocalId = seedData.localId;
|
|
@@ -5194,7 +5214,7 @@ const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
5194
5214
|
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'))
|
|
5195
5215
|
.groupBy(seeds.localId);
|
|
5196
5216
|
if (!itemDataRows || itemDataRows.length === 0) {
|
|
5197
|
-
logger$
|
|
5217
|
+
logger$8('[db/queries] [getItemDataFromDb] no itemDataRows');
|
|
5198
5218
|
return;
|
|
5199
5219
|
}
|
|
5200
5220
|
let itemData = itemDataRows[0];
|
|
@@ -5216,7 +5236,8 @@ const getItemDataFromDb = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
5216
5236
|
}
|
|
5217
5237
|
itemData[propertyName] = propertyValue;
|
|
5218
5238
|
}
|
|
5219
|
-
|
|
5239
|
+
if (itemData)
|
|
5240
|
+
return itemData;
|
|
5220
5241
|
});
|
|
5221
5242
|
const getItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName, seedLocalId, seedUid }) {
|
|
5222
5243
|
const itemInitObj = yield getItemDataFromDb({
|
|
@@ -5235,6 +5256,55 @@ const getItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName,
|
|
|
5235
5256
|
return Item.create(itemInitObj);
|
|
5236
5257
|
});
|
|
5237
5258
|
|
|
5259
|
+
const getSegmentedItemProperties = (item) => {
|
|
5260
|
+
const itemBasicProperties = [];
|
|
5261
|
+
const itemRelationProperties = [];
|
|
5262
|
+
const itemListProperties = [];
|
|
5263
|
+
const itemUploadProperties = [];
|
|
5264
|
+
const itemStorageProperties = [];
|
|
5265
|
+
let itemStorageTransactionProperty;
|
|
5266
|
+
for (const itemProperty of Object.values(item.properties)) {
|
|
5267
|
+
if (!itemProperty.propertyDef) {
|
|
5268
|
+
continue;
|
|
5269
|
+
}
|
|
5270
|
+
const isItemStorage = itemProperty.propertyDef.storageType &&
|
|
5271
|
+
itemProperty.propertyDef.storageType === 'ItemStorage';
|
|
5272
|
+
itemProperty.propertyDef.dataType === 'Relation' &&
|
|
5273
|
+
itemProperty.propertyDef.refValueType === 'ImageSrc';
|
|
5274
|
+
const isStorageTransaction = itemProperty.propertyName === 'storageTransactionId';
|
|
5275
|
+
if (itemProperty.propertyDef.dataType === 'Relation') {
|
|
5276
|
+
itemRelationProperties.push(itemProperty);
|
|
5277
|
+
continue;
|
|
5278
|
+
}
|
|
5279
|
+
if (itemProperty.propertyDef.dataType === 'List') {
|
|
5280
|
+
itemListProperties.push(itemProperty);
|
|
5281
|
+
continue;
|
|
5282
|
+
}
|
|
5283
|
+
if (isItemStorage) {
|
|
5284
|
+
itemStorageProperties.push(itemProperty);
|
|
5285
|
+
continue;
|
|
5286
|
+
}
|
|
5287
|
+
if (isStorageTransaction) {
|
|
5288
|
+
itemStorageTransactionProperty = { itemProperty, childProperties: [] };
|
|
5289
|
+
continue;
|
|
5290
|
+
}
|
|
5291
|
+
itemBasicProperties.push(itemProperty);
|
|
5292
|
+
}
|
|
5293
|
+
if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {
|
|
5294
|
+
itemStorageTransactionProperty.childProperties = itemStorageProperties;
|
|
5295
|
+
}
|
|
5296
|
+
if (itemStorageTransactionProperty) {
|
|
5297
|
+
itemUploadProperties.push(itemStorageTransactionProperty);
|
|
5298
|
+
}
|
|
5299
|
+
return {
|
|
5300
|
+
itemBasicProperties,
|
|
5301
|
+
itemRelationProperties,
|
|
5302
|
+
itemListProperties,
|
|
5303
|
+
itemUploadProperties,
|
|
5304
|
+
};
|
|
5305
|
+
};
|
|
5306
|
+
|
|
5307
|
+
debug('app:item:getPublishPayload');
|
|
5238
5308
|
const getVersionUid = (item) => {
|
|
5239
5309
|
let versionUid;
|
|
5240
5310
|
if (item.latestVersionUid &&
|
|
@@ -5242,7 +5312,7 @@ const getVersionUid = (item) => {
|
|
|
5242
5312
|
item.latestVersionUid !== 'undefined') {
|
|
5243
5313
|
versionUid = item.latestVersionUid;
|
|
5244
5314
|
}
|
|
5245
|
-
return versionUid ||
|
|
5315
|
+
return versionUid || ZERO_BYTES32;
|
|
5246
5316
|
};
|
|
5247
5317
|
const getPropertyData = (itemProperty) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5248
5318
|
const easDataType = INTERNAL_DATA_TYPES[itemProperty.propertyDef.dataType].eas;
|
|
@@ -5268,37 +5338,6 @@ const getPropertyData = (itemProperty) => __awaiter(void 0, void 0, void 0, func
|
|
|
5268
5338
|
propertyNameForSchema,
|
|
5269
5339
|
};
|
|
5270
5340
|
});
|
|
5271
|
-
const getSegmentedItemProperties = (item) => {
|
|
5272
|
-
const itemBasicProperties = [];
|
|
5273
|
-
const itemRelationProperties = [];
|
|
5274
|
-
const itemListProperties = [];
|
|
5275
|
-
const itemStorageProperties = [];
|
|
5276
|
-
for (const itemProperty of Object.values(item.properties)) {
|
|
5277
|
-
if (!itemProperty.propertyDef) {
|
|
5278
|
-
continue;
|
|
5279
|
-
}
|
|
5280
|
-
if (itemProperty.propertyDef.dataType === 'Relation') {
|
|
5281
|
-
itemRelationProperties.push(itemProperty);
|
|
5282
|
-
continue;
|
|
5283
|
-
}
|
|
5284
|
-
if (itemProperty.propertyDef.dataType === 'List') {
|
|
5285
|
-
itemListProperties.push(itemProperty);
|
|
5286
|
-
continue;
|
|
5287
|
-
}
|
|
5288
|
-
if (itemProperty.propertyDef.storageType &&
|
|
5289
|
-
itemProperty.propertyDef.storageType === 'ItemStorage') {
|
|
5290
|
-
itemStorageProperties.push(itemProperty);
|
|
5291
|
-
continue;
|
|
5292
|
-
}
|
|
5293
|
-
itemBasicProperties.push(itemProperty);
|
|
5294
|
-
}
|
|
5295
|
-
return {
|
|
5296
|
-
itemBasicProperties,
|
|
5297
|
-
itemRelationProperties,
|
|
5298
|
-
itemListProperties,
|
|
5299
|
-
itemStorageProperties,
|
|
5300
|
-
};
|
|
5301
|
-
};
|
|
5302
5341
|
const processBasicProperties = (itemBasicProperties, itemPublishData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5303
5342
|
for (const basicProperty of itemBasicProperties) {
|
|
5304
5343
|
const value = basicProperty.getService().getSnapshot().context.propertyValue;
|
|
@@ -5325,7 +5364,7 @@ const processBasicProperties = (itemBasicProperties, itemPublishData) => __await
|
|
|
5325
5364
|
}
|
|
5326
5365
|
return itemPublishData;
|
|
5327
5366
|
});
|
|
5328
|
-
const processRelationProperty = (relationProperty, multiPublishPayload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5367
|
+
const processRelationProperty = (relationProperty, multiPublishPayload, uploadedTransactions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5329
5368
|
const value = relationProperty.getService().getSnapshot()
|
|
5330
5369
|
.context.propertyValue;
|
|
5331
5370
|
if (!value || relationProperty.uid) {
|
|
@@ -5345,13 +5384,23 @@ const processRelationProperty = (relationProperty, multiPublishPayload) => __awa
|
|
|
5345
5384
|
localId: relationProperty.localId,
|
|
5346
5385
|
seedIsRevocable: true,
|
|
5347
5386
|
versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,
|
|
5348
|
-
seedUid: seedUid ||
|
|
5387
|
+
seedUid: seedUid || ZERO_BYTES32,
|
|
5349
5388
|
seedSchemaUid,
|
|
5350
5389
|
versionUid,
|
|
5351
5390
|
listOfAttestations: [],
|
|
5352
5391
|
propertiesToUpdate: [],
|
|
5353
5392
|
};
|
|
5354
|
-
const { itemBasicProperties } = getSegmentedItemProperties(relatedItem);
|
|
5393
|
+
const { itemBasicProperties, itemUploadProperties } = getSegmentedItemProperties(relatedItem);
|
|
5394
|
+
if (itemUploadProperties.length === 1) {
|
|
5395
|
+
const uploadProperty = itemUploadProperties[0];
|
|
5396
|
+
const itemProperty = uploadProperty.itemProperty;
|
|
5397
|
+
const transactionData = uploadedTransactions.find((transaction) => transaction.seedLocalId === relatedItem.seedLocalId);
|
|
5398
|
+
if (transactionData) {
|
|
5399
|
+
itemProperty.value = transactionData.txId;
|
|
5400
|
+
yield itemProperty.save();
|
|
5401
|
+
itemBasicProperties.push(itemProperty);
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5355
5404
|
publishPayload = yield processBasicProperties(itemBasicProperties, publishPayload);
|
|
5356
5405
|
multiPublishPayload.push(publishPayload);
|
|
5357
5406
|
return multiPublishPayload;
|
|
@@ -5392,7 +5441,7 @@ const processListProperty = (listProperty, multiPublishPayload) => __awaiter(voi
|
|
|
5392
5441
|
localId: relatedItem.seedLocalId,
|
|
5393
5442
|
seedIsRevocable: true,
|
|
5394
5443
|
versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,
|
|
5395
|
-
seedUid: seedUid ||
|
|
5444
|
+
seedUid: seedUid || ZERO_BYTES32,
|
|
5396
5445
|
seedSchemaUid,
|
|
5397
5446
|
versionUid,
|
|
5398
5447
|
listOfAttestations: [],
|
|
@@ -5409,17 +5458,13 @@ const processListProperty = (listProperty, multiPublishPayload) => __awaiter(voi
|
|
|
5409
5458
|
}
|
|
5410
5459
|
return multiPublishPayload;
|
|
5411
5460
|
});
|
|
5412
|
-
const getPublishPayload = (
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5461
|
+
const getPublishPayload = (item, uploadedTransactions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5462
|
+
if (item.modelName === 'Post') {
|
|
5463
|
+
item.authors = [
|
|
5464
|
+
'Sr0bIx9Fwj',
|
|
5465
|
+
'0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',
|
|
5466
|
+
];
|
|
5416
5467
|
}
|
|
5417
|
-
// if (item.modelName === 'Post') {
|
|
5418
|
-
// item.authors = [
|
|
5419
|
-
// 'Sr0bIx9Fwj',
|
|
5420
|
-
// '0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',
|
|
5421
|
-
// ]
|
|
5422
|
-
// }
|
|
5423
5468
|
let multiPublishPayload = [];
|
|
5424
5469
|
// Each PublishPayload is generated from a Seed that needs publishing
|
|
5425
5470
|
// First we need to determine all Seeds to publish
|
|
@@ -5430,15 +5475,25 @@ const getPublishPayload = (seedLocalId) => __awaiter(void 0, void 0, void 0, fun
|
|
|
5430
5475
|
seedIsRevocable: true,
|
|
5431
5476
|
seedSchemaUid: item.schemaUid,
|
|
5432
5477
|
versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,
|
|
5433
|
-
versionUid: item
|
|
5478
|
+
versionUid: getVersionUid(item),
|
|
5434
5479
|
listOfAttestations: [],
|
|
5435
5480
|
propertiesToUpdate: [],
|
|
5436
5481
|
};
|
|
5437
|
-
const { itemBasicProperties, itemRelationProperties, itemListProperties,
|
|
5482
|
+
const { itemBasicProperties, itemRelationProperties, itemListProperties, itemUploadProperties, } = getSegmentedItemProperties(item);
|
|
5483
|
+
if (itemUploadProperties.length === 1) {
|
|
5484
|
+
const uploadProperty = itemUploadProperties[0];
|
|
5485
|
+
const itemProperty = uploadProperty.itemProperty;
|
|
5486
|
+
const transactionData = uploadedTransactions.find((transaction) => transaction.seedLocalId === item.seedLocalId);
|
|
5487
|
+
if (transactionData) {
|
|
5488
|
+
itemProperty.value = transactionData.txId;
|
|
5489
|
+
yield itemProperty.save();
|
|
5490
|
+
itemBasicProperties.push(itemProperty);
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5438
5493
|
itemPublishData = yield processBasicProperties(itemBasicProperties, itemPublishData);
|
|
5439
5494
|
multiPublishPayload.push(itemPublishData);
|
|
5440
5495
|
for (const relationProperty of itemRelationProperties) {
|
|
5441
|
-
multiPublishPayload = yield processRelationProperty(relationProperty, multiPublishPayload);
|
|
5496
|
+
multiPublishPayload = yield processRelationProperty(relationProperty, multiPublishPayload, uploadedTransactions);
|
|
5442
5497
|
}
|
|
5443
5498
|
for (const listProperty of itemListProperties) {
|
|
5444
5499
|
multiPublishPayload = yield processListProperty(listProperty, multiPublishPayload);
|
|
@@ -5446,6 +5501,153 @@ const getPublishPayload = (seedLocalId) => __awaiter(void 0, void 0, void 0, fun
|
|
|
5446
5501
|
return multiPublishPayload;
|
|
5447
5502
|
});
|
|
5448
5503
|
|
|
5504
|
+
const logger$7 = debug('app:item:getPublishUploads');
|
|
5505
|
+
const getContentHash = (base64, uint) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5506
|
+
let data;
|
|
5507
|
+
if (uint) {
|
|
5508
|
+
data = uint;
|
|
5509
|
+
}
|
|
5510
|
+
// Hash the data with SHA-256
|
|
5511
|
+
const hashBuffer = yield crypto.subtle.digest('SHA-256', data);
|
|
5512
|
+
// Convert the ArrayBuffer to a hex string
|
|
5513
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
5514
|
+
return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
5515
|
+
});
|
|
5516
|
+
const prepareArweaveTransaction = (data, contentHash) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5517
|
+
const transactionData = {
|
|
5518
|
+
data,
|
|
5519
|
+
tags: [],
|
|
5520
|
+
};
|
|
5521
|
+
const tx = yield getArweave().createTransaction(transactionData);
|
|
5522
|
+
if (contentHash) {
|
|
5523
|
+
logger$7('contentHash', contentHash);
|
|
5524
|
+
logger$7('adding content hash tag to tx.id:', tx.id);
|
|
5525
|
+
tx.addTag('Content-SHA-256', contentHash);
|
|
5526
|
+
}
|
|
5527
|
+
return tx;
|
|
5528
|
+
});
|
|
5529
|
+
const processUploadProperty = (uploadProperty, uploads, relatedItemProperty) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5530
|
+
const itemProperty = uploadProperty.itemProperty;
|
|
5531
|
+
const childUploads = [];
|
|
5532
|
+
for (const childProperty of uploadProperty.childProperties) {
|
|
5533
|
+
const filePath = childProperty.localStoragePath;
|
|
5534
|
+
if (!filePath) {
|
|
5535
|
+
throw new Error(`No localStoragePath found for ItemProperty ${childProperty.propertyName}`);
|
|
5536
|
+
}
|
|
5537
|
+
const exists = yield fs.promises.exists(filePath);
|
|
5538
|
+
if (!exists) {
|
|
5539
|
+
throw new Error(`File doesn't exist at ${filePath}`);
|
|
5540
|
+
}
|
|
5541
|
+
childUploads.push({
|
|
5542
|
+
propertyName: childProperty.propertyName,
|
|
5543
|
+
localStoragePath: filePath,
|
|
5544
|
+
});
|
|
5545
|
+
}
|
|
5546
|
+
// const filePath = itemProperty.localStoragePath
|
|
5547
|
+
//
|
|
5548
|
+
// if (!filePath) {
|
|
5549
|
+
// throw new Error(
|
|
5550
|
+
// `No localStoragePath found for ItemProperty ${itemProperty.propertyName}`,
|
|
5551
|
+
// )
|
|
5552
|
+
// }
|
|
5553
|
+
//
|
|
5554
|
+
// const exists = await fs.promises.exists(filePath)
|
|
5555
|
+
// if (!exists) {
|
|
5556
|
+
// throw new Error(`File doesn't exist at ${filePath}`)
|
|
5557
|
+
//
|
|
5558
|
+
// // const handle = await navigator.storage.getDirectory()
|
|
5559
|
+
// //
|
|
5560
|
+
// // await configureSingle({
|
|
5561
|
+
// // backend: WebAccess,
|
|
5562
|
+
// // handle,
|
|
5563
|
+
// // })
|
|
5564
|
+
// }
|
|
5565
|
+
//
|
|
5566
|
+
// const mainFileContents = await fs.promises.readFile(filePath)
|
|
5567
|
+
let fileContents;
|
|
5568
|
+
let transaction;
|
|
5569
|
+
if (!childUploads || childUploads.length === 0) {
|
|
5570
|
+
if (relatedItemProperty && relatedItemProperty.localStoragePath) {
|
|
5571
|
+
const filePath = relatedItemProperty.localStoragePath;
|
|
5572
|
+
const exists = yield fs.promises.exists(filePath);
|
|
5573
|
+
if (!exists) {
|
|
5574
|
+
throw new Error(`File doesn't exist at ${filePath}`);
|
|
5575
|
+
// const handle = await navigator.storage.getDirectory()
|
|
5576
|
+
//
|
|
5577
|
+
// await configureSingle({
|
|
5578
|
+
// backend: WebAccess,
|
|
5579
|
+
// handle,
|
|
5580
|
+
// })
|
|
5581
|
+
}
|
|
5582
|
+
fileContents = yield fs.promises.readFile(filePath);
|
|
5583
|
+
}
|
|
5584
|
+
if (!fileContents) {
|
|
5585
|
+
return uploads;
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
if (childUploads.length > 0) {
|
|
5589
|
+
const separator = '===FILE_SEPARATOR===';
|
|
5590
|
+
// let compositeFileContents = `${itemProperty.propertyName}${separator}${mainFileContents}`
|
|
5591
|
+
let compositeFileContents = '';
|
|
5592
|
+
for (const childUpload of childUploads) {
|
|
5593
|
+
const childUploadContents = yield fs.promises.readFile(childUpload.localStoragePath);
|
|
5594
|
+
compositeFileContents += `${separator}${childUpload.propertyName}${separator}${childUploadContents}`;
|
|
5595
|
+
}
|
|
5596
|
+
fileContents = Buffer.from(compositeFileContents);
|
|
5597
|
+
}
|
|
5598
|
+
if (!fileContents) {
|
|
5599
|
+
throw new Error(`No file contents found for ${itemProperty.propertyName}`);
|
|
5600
|
+
}
|
|
5601
|
+
const uint8Array = new Uint8Array(fileContents.buffer, fileContents.byteOffset, fileContents.byteLength);
|
|
5602
|
+
const contentHash = yield getContentHash(null, uint8Array);
|
|
5603
|
+
transaction = yield prepareArweaveTransaction(fileContents, contentHash);
|
|
5604
|
+
let itemPropertyLocalId = relatedItemProperty
|
|
5605
|
+
? relatedItemProperty.localId
|
|
5606
|
+
: itemProperty.localId;
|
|
5607
|
+
let itemPropertyName = relatedItemProperty
|
|
5608
|
+
? relatedItemProperty.propertyName
|
|
5609
|
+
: itemProperty.propertyName;
|
|
5610
|
+
uploads.push({
|
|
5611
|
+
itemPropertyName,
|
|
5612
|
+
itemPropertyLocalId,
|
|
5613
|
+
seedLocalId: itemProperty.seedLocalId,
|
|
5614
|
+
versionLocalId: itemProperty.versionLocalId,
|
|
5615
|
+
transactionToSign: transaction,
|
|
5616
|
+
});
|
|
5617
|
+
return uploads;
|
|
5618
|
+
});
|
|
5619
|
+
const getPublishUploads = (item_1, ...args_1) => __awaiter(void 0, [item_1, ...args_1], void 0, function* (item, uploads = [], relatedItemProperty) {
|
|
5620
|
+
if (item.modelName === 'Post') {
|
|
5621
|
+
if (!item.authors) {
|
|
5622
|
+
item.authors = [
|
|
5623
|
+
'Sr0bIx9Fwj',
|
|
5624
|
+
'0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',
|
|
5625
|
+
];
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5628
|
+
const { itemUploadProperties, itemRelationProperties } = getSegmentedItemProperties(item);
|
|
5629
|
+
for (const uploadProperty of itemUploadProperties) {
|
|
5630
|
+
uploads = yield processUploadProperty(uploadProperty, uploads, relatedItemProperty);
|
|
5631
|
+
}
|
|
5632
|
+
for (const relationProperty of itemRelationProperties) {
|
|
5633
|
+
const propertyValue = relationProperty.getService().getSnapshot()
|
|
5634
|
+
.context.propertyValue;
|
|
5635
|
+
if (!propertyValue || relationProperty.uid) {
|
|
5636
|
+
continue;
|
|
5637
|
+
}
|
|
5638
|
+
const { localId: seedLocalId, uid: seedUid } = getCorrectId(propertyValue);
|
|
5639
|
+
const relatedItem = yield Item.find({
|
|
5640
|
+
seedLocalId,
|
|
5641
|
+
seedUid,
|
|
5642
|
+
});
|
|
5643
|
+
if (!relatedItem) {
|
|
5644
|
+
throw new Error(`No relatedItem found for ${relationProperty.propertyName}`);
|
|
5645
|
+
}
|
|
5646
|
+
uploads = yield getPublishUploads(relatedItem, uploads, relationProperty);
|
|
5647
|
+
}
|
|
5648
|
+
return uploads;
|
|
5649
|
+
});
|
|
5650
|
+
|
|
5449
5651
|
var _a$1;
|
|
5450
5652
|
class Item {
|
|
5451
5653
|
constructor(initialValues) {
|
|
@@ -5478,8 +5680,11 @@ class Item {
|
|
|
5478
5680
|
},
|
|
5479
5681
|
});
|
|
5480
5682
|
});
|
|
5481
|
-
this.
|
|
5482
|
-
return yield
|
|
5683
|
+
this.getPublishUploads = () => __awaiter(this, void 0, void 0, function* () {
|
|
5684
|
+
return yield getPublishUploads(this);
|
|
5685
|
+
});
|
|
5686
|
+
this.getPublishPayload = (uploadedTransactions) => __awaiter(this, void 0, void 0, function* () {
|
|
5687
|
+
return yield getPublishPayload(this, uploadedTransactions);
|
|
5483
5688
|
});
|
|
5484
5689
|
const { modelName, seedUid, schemaUid, seedLocalId, latestVersionLocalId, latestVersionUid, } = initialValues;
|
|
5485
5690
|
const ModelClass = getModel(modelName);
|
|
@@ -5535,7 +5740,7 @@ class Item {
|
|
|
5535
5740
|
seedUid,
|
|
5536
5741
|
versionLocalId: latestVersionLocalId,
|
|
5537
5742
|
versionUid: latestVersionUid,
|
|
5538
|
-
|
|
5743
|
+
modelName: modelName,
|
|
5539
5744
|
};
|
|
5540
5745
|
if (ModelClass && ModelClass.schema) {
|
|
5541
5746
|
const schema = ModelClass.schema;
|
|
@@ -5545,6 +5750,16 @@ class Item {
|
|
|
5545
5750
|
}
|
|
5546
5751
|
this._createPropertyInstance(Object.assign(Object.assign({}, itemPropertyBase), { propertyName, propertyValue: initialValues[propertyName] }));
|
|
5547
5752
|
definedKeys.push(propertyName);
|
|
5753
|
+
if (propertyRecordSchema.dataType === 'Relation' &&
|
|
5754
|
+
!propertyName.endsWith('Id')) {
|
|
5755
|
+
definedKeys.push(`${propertyName}Id`);
|
|
5756
|
+
}
|
|
5757
|
+
if (propertyRecordSchema.dataType === 'List' &&
|
|
5758
|
+
!propertyName.endsWith('Ids')) {
|
|
5759
|
+
const singularPropertyName = pluralize.singular(propertyName);
|
|
5760
|
+
const propertyNameForSchema = `${singularPropertyName}${propertyRecordSchema.ref}Ids`;
|
|
5761
|
+
definedKeys.push(propertyNameForSchema);
|
|
5762
|
+
}
|
|
5548
5763
|
}
|
|
5549
5764
|
}
|
|
5550
5765
|
Object.keys(initialValues).forEach((key) => {
|
|
@@ -5582,9 +5797,7 @@ class Item {
|
|
|
5582
5797
|
type: 'updateContext',
|
|
5583
5798
|
propertyValue,
|
|
5584
5799
|
});
|
|
5585
|
-
// propertyInstance.getService().send({ type: 'reload' })
|
|
5586
5800
|
}
|
|
5587
|
-
// instance.getService().send({ type: 'reload' })
|
|
5588
5801
|
return instance;
|
|
5589
5802
|
}
|
|
5590
5803
|
if (!Item.instanceCache.has(seedId)) {
|
|
@@ -5672,20 +5885,23 @@ class Item {
|
|
|
5672
5885
|
enumerable: true,
|
|
5673
5886
|
});
|
|
5674
5887
|
}
|
|
5888
|
+
get serviceContext() {
|
|
5889
|
+
return this._service.getSnapshot().context;
|
|
5890
|
+
}
|
|
5675
5891
|
get seedLocalId() {
|
|
5676
|
-
return this.
|
|
5892
|
+
return this.serviceContext.seedLocalId;
|
|
5677
5893
|
}
|
|
5678
5894
|
get seedUid() {
|
|
5679
|
-
return this.
|
|
5895
|
+
return this.serviceContext.seedUid;
|
|
5680
5896
|
}
|
|
5681
5897
|
get schemaUid() {
|
|
5682
|
-
return this.
|
|
5898
|
+
return this.serviceContext.schemaUid;
|
|
5683
5899
|
}
|
|
5684
5900
|
get latestVersionUid() {
|
|
5685
|
-
return this.
|
|
5901
|
+
return this.serviceContext.latestVersionUid;
|
|
5686
5902
|
}
|
|
5687
5903
|
get modelName() {
|
|
5688
|
-
return this.
|
|
5904
|
+
return this.serviceContext.modelName;
|
|
5689
5905
|
}
|
|
5690
5906
|
get properties() {
|
|
5691
5907
|
return this._propertiesSubject.value;
|
|
@@ -6235,7 +6451,7 @@ const client = {
|
|
|
6235
6451
|
console.error('fs listeners not ready during init');
|
|
6236
6452
|
}
|
|
6237
6453
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6238
|
-
import('./seed.schema.config-
|
|
6454
|
+
import('./seed.schema.config-Brb7H5eC.js').then(({ models }) => {
|
|
6239
6455
|
for (const [key, value] of Object.entries(models)) {
|
|
6240
6456
|
setModel(key, value);
|
|
6241
6457
|
}
|
|
@@ -6442,7 +6658,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6442
6658
|
});
|
|
6443
6659
|
sendBack({
|
|
6444
6660
|
type: 'resolvingRelatedValueSuccess',
|
|
6445
|
-
|
|
6661
|
+
refResolvedDisplayValue: contentUrl,
|
|
6446
6662
|
});
|
|
6447
6663
|
return true;
|
|
6448
6664
|
}
|
|
@@ -6465,8 +6681,8 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6465
6681
|
});
|
|
6466
6682
|
sendBack({
|
|
6467
6683
|
type: 'resolvingRelatedValueSuccess',
|
|
6468
|
-
|
|
6469
|
-
|
|
6684
|
+
refResolvedDisplayValue: contentUrl,
|
|
6685
|
+
refResolvedValue: storageTransactionId,
|
|
6470
6686
|
});
|
|
6471
6687
|
return true;
|
|
6472
6688
|
}
|
|
@@ -6480,8 +6696,8 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6480
6696
|
});
|
|
6481
6697
|
sendBack({
|
|
6482
6698
|
type: 'resolvingRelatedValueSuccess',
|
|
6483
|
-
|
|
6484
|
-
|
|
6699
|
+
refResolvedDisplayValue: contentUrl,
|
|
6700
|
+
refResolvedValue: storageTransactionId,
|
|
6485
6701
|
});
|
|
6486
6702
|
return true;
|
|
6487
6703
|
}
|
|
@@ -6502,7 +6718,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6502
6718
|
});
|
|
6503
6719
|
sendBack({
|
|
6504
6720
|
type: 'resolvingRelatedValueSuccess',
|
|
6505
|
-
|
|
6721
|
+
refResolvedDisplayValue: contentUrl,
|
|
6506
6722
|
});
|
|
6507
6723
|
return true;
|
|
6508
6724
|
}
|
|
@@ -6518,7 +6734,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6518
6734
|
});
|
|
6519
6735
|
sendBack({
|
|
6520
6736
|
type: 'resolvingRelatedValueSuccess',
|
|
6521
|
-
|
|
6737
|
+
refResolvedDisplayValue: contentUrl,
|
|
6522
6738
|
});
|
|
6523
6739
|
return true;
|
|
6524
6740
|
}
|
|
@@ -6548,7 +6764,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6548
6764
|
});
|
|
6549
6765
|
sendBack({
|
|
6550
6766
|
type: 'resolvingRelatedValueSuccess',
|
|
6551
|
-
|
|
6767
|
+
refResolvedDisplayValue: contentUrl,
|
|
6552
6768
|
});
|
|
6553
6769
|
return true;
|
|
6554
6770
|
}
|
|
@@ -6641,13 +6857,13 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6641
6857
|
// )
|
|
6642
6858
|
// }
|
|
6643
6859
|
//
|
|
6644
|
-
// const
|
|
6860
|
+
// const refResolvedDisplayValue = storageIdQuery.rows[0][2]
|
|
6645
6861
|
// let resolvedValue = storageIdQuery.rows[0][3]
|
|
6646
6862
|
//
|
|
6647
|
-
// if (
|
|
6863
|
+
// if (refResolvedDisplayValue && resolvedValue) {
|
|
6648
6864
|
// sendBack({
|
|
6649
6865
|
// type: 'resolvingRelatedValueSuccess',
|
|
6650
|
-
//
|
|
6866
|
+
// refResolvedDisplayValue,
|
|
6651
6867
|
// resolvedValue,
|
|
6652
6868
|
// })
|
|
6653
6869
|
// return
|
|
@@ -6679,7 +6895,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6679
6895
|
//
|
|
6680
6896
|
// sendBack({
|
|
6681
6897
|
// type: 'resolvingRelatedValueSuccess',
|
|
6682
|
-
//
|
|
6898
|
+
// refResolvedDisplayValue: contentUrl,
|
|
6683
6899
|
// resolvedValue: storageId,
|
|
6684
6900
|
// })
|
|
6685
6901
|
// }
|
|
@@ -6738,7 +6954,7 @@ const updateMetadata = (metadataValues) => __awaiter(void 0, void 0, void 0, fun
|
|
|
6738
6954
|
|
|
6739
6955
|
const logger$1 = debug('app:property:actors:hydrateFromDb');
|
|
6740
6956
|
const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
6741
|
-
const { seedUid, seedLocalId, propertyName: propertyNameRaw, propertyValue, propertyRecordSchema,
|
|
6957
|
+
const { seedUid, seedLocalId, propertyName: propertyNameRaw, propertyValue, propertyRecordSchema, modelName, } = context;
|
|
6742
6958
|
let propertyName = propertyNameRaw;
|
|
6743
6959
|
if (propertyRecordSchema &&
|
|
6744
6960
|
propertyRecordSchema.ref &&
|
|
@@ -6902,18 +7118,18 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6902
7118
|
schemaUid: schemaUidFromDb,
|
|
6903
7119
|
refValueType,
|
|
6904
7120
|
localStorageDir,
|
|
6905
|
-
|
|
6906
|
-
|
|
7121
|
+
refResolvedValue,
|
|
7122
|
+
refResolvedDisplayValue,
|
|
6907
7123
|
renderValue: refResolvedDisplayValue,
|
|
6908
7124
|
populatedFromDb: true,
|
|
6909
7125
|
});
|
|
6910
7126
|
if (propertyRecordSchema &&
|
|
6911
7127
|
propertyRecordSchema.storageType &&
|
|
6912
7128
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
6913
|
-
const { Item } = yield import('./index-
|
|
7129
|
+
const { Item } = yield import('./index-vHcSfvyu.js');
|
|
6914
7130
|
const item = yield Item.find({
|
|
6915
7131
|
seedLocalId,
|
|
6916
|
-
modelName
|
|
7132
|
+
modelName,
|
|
6917
7133
|
});
|
|
6918
7134
|
if (item) {
|
|
6919
7135
|
const filePath = `/files/${localStorageDir}/${refResolvedValue}`;
|
|
@@ -7103,7 +7319,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
7103
7319
|
});
|
|
7104
7320
|
|
|
7105
7321
|
const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
7106
|
-
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema,
|
|
7322
|
+
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, modelName, } = context;
|
|
7107
7323
|
let { schemaUid } = context;
|
|
7108
7324
|
let newValue;
|
|
7109
7325
|
if (event) {
|
|
@@ -7164,7 +7380,7 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
7164
7380
|
seedLocalId,
|
|
7165
7381
|
versionLocalId,
|
|
7166
7382
|
versionUid,
|
|
7167
|
-
modelName
|
|
7383
|
+
modelName,
|
|
7168
7384
|
schemaUid,
|
|
7169
7385
|
});
|
|
7170
7386
|
sendBack({
|
|
@@ -7204,7 +7420,7 @@ const fetchImage = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
7204
7420
|
});
|
|
7205
7421
|
let imageSchemaUid;
|
|
7206
7422
|
const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
7207
|
-
const { localId, propertyName: propertyNameRaw, propertyValue: existingValue, propertyRecordSchema,
|
|
7423
|
+
const { localId, propertyName: propertyNameRaw, propertyValue: existingValue, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
|
|
7208
7424
|
let { schemaUid } = context;
|
|
7209
7425
|
let newValue;
|
|
7210
7426
|
if (event) {
|
|
@@ -7283,7 +7499,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
7283
7499
|
seedUid,
|
|
7284
7500
|
versionLocalId,
|
|
7285
7501
|
versionUid,
|
|
7286
|
-
modelName
|
|
7502
|
+
modelName,
|
|
7287
7503
|
schemaUid,
|
|
7288
7504
|
refSeedType: 'image',
|
|
7289
7505
|
refModelUid: imageSchemaUid,
|
|
@@ -7301,7 +7517,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
7301
7517
|
newValue: newImageSeedLocalId,
|
|
7302
7518
|
seedLocalId,
|
|
7303
7519
|
versionLocalId,
|
|
7304
|
-
modelName
|
|
7520
|
+
modelName,
|
|
7305
7521
|
schemaUid,
|
|
7306
7522
|
refSeedType: 'image',
|
|
7307
7523
|
refResolvedDisplayValue,
|
|
@@ -7318,8 +7534,8 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
7318
7534
|
refSeedType: 'image',
|
|
7319
7535
|
refSchemaUid: imageSchemaUid,
|
|
7320
7536
|
renderValue: refResolvedDisplayValue,
|
|
7321
|
-
|
|
7322
|
-
|
|
7537
|
+
refResolvedDisplayValue: refResolvedDisplayValue,
|
|
7538
|
+
refResolvedValue: fileName,
|
|
7323
7539
|
localStorageDir: '/images',
|
|
7324
7540
|
easDataType: 'bytes32',
|
|
7325
7541
|
});
|
|
@@ -7425,7 +7641,7 @@ const getItemPropertyData = (props) => __awaiter(void 0, void 0, void 0, functio
|
|
|
7425
7641
|
});
|
|
7426
7642
|
|
|
7427
7643
|
const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
7428
|
-
const { localId, seedLocalId, seedUid, propertyName, propertyRecordSchema,
|
|
7644
|
+
const { localId, seedLocalId, seedUid, propertyName, propertyRecordSchema, modelName, propertyValue: existingValue, } = context;
|
|
7429
7645
|
if (!propertyRecordSchema) {
|
|
7430
7646
|
throw new Error('Missing propertyRecordSchema');
|
|
7431
7647
|
}
|
|
@@ -7468,7 +7684,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
|
|
|
7468
7684
|
if (!propertyData) {
|
|
7469
7685
|
const propertyDataRows = yield createMetadata({
|
|
7470
7686
|
propertyName,
|
|
7471
|
-
modelType:
|
|
7687
|
+
modelType: modelName.toLowerCase(),
|
|
7472
7688
|
seedLocalId,
|
|
7473
7689
|
seedUid,
|
|
7474
7690
|
versionLocalId: itemData.latestVersionLocalId,
|
|
@@ -7606,8 +7822,8 @@ const propertyMachine = setup({
|
|
|
7606
7822
|
resolvingRelatedValueSuccess: {
|
|
7607
7823
|
target: 'idle',
|
|
7608
7824
|
actions: assign({
|
|
7609
|
-
|
|
7610
|
-
resolvedValue: ({ event }) => event.
|
|
7825
|
+
refResolvedDisplayValue: ({ event }) => event.refResolvedDisplayValue,
|
|
7826
|
+
resolvedValue: ({ event }) => event.refResolvedValue,
|
|
7611
7827
|
}),
|
|
7612
7828
|
},
|
|
7613
7829
|
resolvingRelatedValueDone: {
|
|
@@ -7852,4 +8068,4 @@ if (isNode()) {
|
|
|
7852
8068
|
}
|
|
7853
8069
|
|
|
7854
8070
|
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 };
|
|
7855
|
-
//# sourceMappingURL=index-
|
|
8071
|
+
//# sourceMappingURL=index-vtm826YJ.js.map
|