@seedprotocol/sdk 0.7.4-next.784.g879c6a3 → 0.7.4
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/{BasePathResolver-DxdS0wJ0.js → BasePathResolver-DrzGVH9L.js} +232 -40
- package/dist/BasePathResolver-DrzGVH9L.js.map +1 -0
- package/dist/{ClientManager-De-vKHGe.js → ClientManager-Dfu4jcgm.js} +583 -219
- package/dist/ClientManager-Dfu4jcgm.js.map +1 -0
- package/dist/{Item-cq9VcsAY.js → Item-BUUFuywT.js} +175 -306
- package/dist/Item-BUUFuywT.js.map +1 -0
- package/dist/{ModelProperty-DuuoFXaC.js → ModelProperty-B6cnRvIz.js} +38 -39
- package/dist/ModelProperty-B6cnRvIz.js.map +1 -0
- package/dist/{Schema-Dc5EA8Yb.js → Schema-Bf-jOLq0.js} +37 -36
- package/dist/{Schema-Dc5EA8Yb.js.map → Schema-Bf-jOLq0.js.map} +1 -1
- package/dist/{SchemaValidationService-DViJ056F.js → SchemaValidationService-BNYMacsx.js} +7 -8
- package/dist/{SchemaValidationService-DViJ056F.js.map → SchemaValidationService-BNYMacsx.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-DacVthS5.js → backfillMetadataPropertyIds-C2-s_jUa.js} +4 -5
- package/dist/{backfillMetadataPropertyIds-DacVthS5.js.map → backfillMetadataPropertyIds-C2-s_jUa.js.map} +1 -1
- package/dist/{configurePlatform-DlZ23w7e.js → configurePlatform-BzfirKuM.js} +3 -4
- package/dist/{configurePlatform-DlZ23w7e.js.map → configurePlatform-BzfirKuM.js.map} +1 -1
- package/dist/{detachRowsBeforeDelete-YRSZY6dO.js → detachRowsBeforeDelete-B0Daoz9Z.js} +3 -4
- package/dist/{detachRowsBeforeDelete-YRSZY6dO.js.map → detachRowsBeforeDelete-B0Daoz9Z.js.map} +1 -1
- package/dist/{eas-D_6ptL_F.js → eas-Dq5Kx_Nd.js} +14 -32
- package/dist/eas-Dq5Kx_Nd.js.map +1 -0
- package/dist/{errors-Cl8rbtKR.js → errors-DdWbxb_n.js} +42 -39
- package/dist/errors-DdWbxb_n.js.map +1 -0
- package/dist/{getItem-BcmJcUZB.js → getItem-9bYSErSj.js} +4 -5
- package/dist/{getItem-BcmJcUZB.js.map → getItem-9bYSErSj.js.map} +1 -1
- package/dist/{getPublishPayload-C278kK9P.js → getPublishPayload-DPy-uMrR.js} +28 -29
- package/dist/getPublishPayload-DPy-uMrR.js.map +1 -0
- package/dist/{getPublishUploads-DJ1UPh7i.js → getPublishUploads-J-143iSV.js} +10 -11
- package/dist/{getPublishUploads-DJ1UPh7i.js.map → getPublishUploads-J-143iSV.js.map} +1 -1
- package/dist/{index-DAl9U4rn.js → index-7y2f_iQz.js} +2 -2
- package/dist/index-7y2f_iQz.js.map +1 -0
- package/dist/{index-CqnU-5i0.js → index-C61Rxy0F.js} +9 -10
- package/dist/index-C61Rxy0F.js.map +1 -0
- package/dist/{index.browser-J6QZ9smP.js → index.browser-C1pisOEa.js} +10 -10
- package/dist/{index.browser-J6QZ9smP.js.map → index.browser-C1pisOEa.js.map} +1 -1
- package/dist/{index.node-C9VB9NlX.js → index.node-BAlST8pD.js} +6 -6
- package/dist/{index.node-C9VB9NlX.js.map → index.node-BAlST8pD.js.map} +1 -1
- package/dist/main.js +27 -28
- package/dist/main.js.map +1 -1
- package/dist/node.js +12 -13
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +6 -7
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +5 -6
- package/dist/platform.node.js.map +1 -1
- package/dist/{property-Brgr5RdT.js → property-zFPMtR3T.js} +10 -14
- package/dist/property-zFPMtR3T.js.map +1 -0
- package/dist/{propertyValidationRules-CDRitiiK.js → propertyValidationRules-CeFVhdQg.js} +10 -10
- package/dist/{propertyValidationRules-CDRitiiK.js.map → propertyValidationRules-CeFVhdQg.js.map} +1 -1
- package/dist/{publishDraftGraph-C37ibxb5.js → publishDraftGraph-CuVq6iAR.js} +7 -6
- package/dist/{publishDraftGraph-C37ibxb5.js.map → publishDraftGraph-CuVq6iAR.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-CcLFRREE.js → resetAmbiguousLegacyItemData-DsFTnMBz.js} +5 -6
- package/dist/resetAmbiguousLegacyItemData-DsFTnMBz.js.map +1 -0
- package/dist/{resolveModelForSyncedSeed-BTAeCOJE.js → resolveModelForSyncedSeed-RUsgAZXG.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-BTAeCOJE.js.map → resolveModelForSyncedSeed-RUsgAZXG.js.map} +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +4 -4
- package/dist/src/Model/Model.d.ts +3 -2
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +1 -1
- package/dist/src/Schema/service/schemaMachine.d.ts +2 -2
- package/dist/src/client/ClientManager.d.ts +6 -6
- package/dist/src/client/ClientManager.d.ts.map +1 -1
- package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +2 -2
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/db/canonicalizeModelTypes.d.ts +18 -0
- package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -0
- package/dist/src/db/read/getModelSchemas.d.ts +6 -0
- package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getSchemaUidForModel.d.ts +6 -0
- package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
- package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
- package/dist/src/db/removeForeignAttestationRows.d.ts +27 -0
- package/dist/src/db/removeForeignAttestationRows.d.ts.map +1 -0
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/easSyncProcess.d.ts +9 -1
- package/dist/src/db/write/easSyncProcess.d.ts.map +1 -1
- package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/item/easSyncManager.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +20 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +3 -1
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/metadataPropertyNames.d.ts +12 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/retryWhenOnline.d.ts +20 -0
- package/dist/src/helpers/retryWhenOnline.d.ts.map +1 -0
- package/dist/src/imports/json.d.ts +10 -0
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
- package/dist/src/types/import.d.ts +4 -0
- package/dist/src/types/import.d.ts.map +1 -1
- package/dist/{syncDbWithEas-B-Ho0IOB.js → syncDbWithEas-CRpnkq00.js} +157 -61
- package/dist/syncDbWithEas-CRpnkq00.js.map +1 -0
- package/dist/{tabEvents-BTzckWrN.js → tabEvents-nBUq_1u1.js} +6 -6
- package/dist/{tabEvents-BTzckWrN.js.map → tabEvents-nBUq_1u1.js.map} +1 -1
- package/dist/{tolerantWebAccess-DOm2Xv-f.js → tolerantWebAccess-DIt3R8_u.js} +7 -8
- package/dist/{tolerantWebAccess-DOm2Xv-f.js.map → tolerantWebAccess-DIt3R8_u.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-IHXnJI-i.js → updateSeedRevokedAt-DtTPSzpM.js} +3 -3
- package/dist/{updateSeedRevokedAt-IHXnJI-i.js.map → updateSeedRevokedAt-DtTPSzpM.js.map} +1 -1
- package/package.json +5 -5
- package/dist/BasePathResolver-DxdS0wJ0.js.map +0 -1
- package/dist/ClientManager-De-vKHGe.js.map +0 -1
- package/dist/Item-cq9VcsAY.js.map +0 -1
- package/dist/ModelProperty-DuuoFXaC.js.map +0 -1
- package/dist/eas-D_6ptL_F.js.map +0 -1
- package/dist/errors-Cl8rbtKR.js.map +0 -1
- package/dist/getPublishPayload-C278kK9P.js.map +0 -1
- package/dist/index-CqnU-5i0.js.map +0 -1
- package/dist/index-DAl9U4rn.js.map +0 -1
- package/dist/property-Brgr5RdT.js.map +0 -1
- package/dist/resetAmbiguousLegacyItemData-CcLFRREE.js.map +0 -1
- package/dist/syncDbWithEas-B-Ho0IOB.js.map +0 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { waitFor, fromCallback, setup, assign, stateIn, createActor, isMachineSnapshot } from 'xstate';
|
|
2
|
-
import {
|
|
2
|
+
import { E as BaseDb, C as versions, m as metadata, A as seeds, F as resolveStorageNameToSchemaName, aV as toSchemaPropertyName, z as schemas, s as models, q as modelSchemas, aT as getOwnedAddressesFromDb, ac as ZERO_BYTES32, aE as normalizeAddressList, a0 as normalizeHexAddress, aB as getAddressesForItemsFilter, ag as INTERNAL_PROPERTY_NAMES, J as BaseFileManager, aW as getStorageTransactionIdForSeedUid, aX as convertTxIdToImage, i as isDataType, X as normalizePublisher, n as normalizeDataType, aY as getMetadataPropertyNamesForQuery, aA as ensureImageLocal, as as ImageSize, aZ as downloadTransactionIdWithDedupe, a_ as resolveMetadataRecord, u as properties, M as ModelPropertyDataTypes, $ as generateId, aj as INTERNAL_DATA_TYPES, r as modelUids, a1 as listRelationEasPropertyName, a2 as easPropertyNameForPublish, L as resolveItemModelFileId, a$ as getPropertyIdForSchemaFileId, K as getPropertyIdForModelAndName, a3 as toMetadataPropertyName, b0 as getDataTypeFromString, b1 as getMimeType, ap as INTERNAL_STORAGE_MODEL_FILE_IDS, V as getItemStorageSubdir, W as getItemStorageLocalFileName, g as normalizePropertyRecordSchema, b2 as listRelationStoragePropertyName, b3 as PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, a8 as getCorrectId, H as eventEmitter, b4 as getAlternatePropertyNameForInstanceLookup, ah as isStorageSeedRef } from './BasePathResolver-DrzGVH9L.js';
|
|
3
3
|
import { or, isNull, eq, max, count, and, getTableColumns, sql, desc, inArray, isNotNull, gt } from 'drizzle-orm';
|
|
4
|
-
import pluralize from 'pluralize';
|
|
5
4
|
import debug from 'debug';
|
|
6
5
|
import { BehaviorSubject } from 'rxjs';
|
|
6
|
+
import pluralize from 'pluralize';
|
|
7
7
|
import { startCase, upperFirst, camelCase, orderBy } from 'lodash-es';
|
|
8
|
-
import {
|
|
9
|
-
import { isValidEasAttestationUid, isPlaceholderUid, BaseQueryClient, BaseEasClient, GET_SCHEMAS, getEasSchemaUidForSchemaDefinition, getSchemaUidForModelFromCache, cachedSchemaLookup, setSchemaUidForModel, getEasSchemaUidForExactDefinition } from '@seedprotocol/eas';
|
|
8
|
+
import { isValidEasAttestationUid, easName, isPlaceholderUid, BaseQueryClient, BaseEasClient, GET_SCHEMAS, getEasSchemaUidForSchemaDefinition, getSchemaUidForModelFromCache, setSchemaUidForModel, cachedSchemaLookup, getEasSchemaUidForExactDefinition } from '@seedprotocol/eas';
|
|
10
9
|
import { fetchArweaveRawTextAcrossGateways } from '@seedprotocol/arweave';
|
|
11
|
-
import { d as notifyFileSaved, f as withTabLock } from './tabEvents-
|
|
10
|
+
import { d as notifyFileSaved, f as withTabLock } from './tabEvents-nBUq_1u1.js';
|
|
12
11
|
import { modelPropertiesToObject } from './model-oHA3YhOd.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -145,150 +144,6 @@ var publishConfig = /*#__PURE__*/Object.freeze({
|
|
|
145
144
|
setUploadExecutor: setUploadExecutor
|
|
146
145
|
});
|
|
147
146
|
|
|
148
|
-
/** Ref model name when propDef is a List of Relation, else undefined. */
|
|
149
|
-
function listRelationRef(propDef) {
|
|
150
|
-
if (!propDef)
|
|
151
|
-
return undefined;
|
|
152
|
-
if (normalizeDataType(propDef.dataType) !== 'List')
|
|
153
|
-
return undefined;
|
|
154
|
-
return propDef.ref || propDef.refModelName || undefined;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Storage/EAS name for a List-of-relation property (`authorIdentityIds`), given either its
|
|
158
|
-
* schema key (`authors`) or its storage name. A name already in storage form is returned as-is,
|
|
159
|
-
* so this is safe on ItemProperties built before their schema was known.
|
|
160
|
-
* Returns undefined when propDef is not a List of Relation.
|
|
161
|
-
*/
|
|
162
|
-
function listRelationEasPropertyName(propertyName, propDef) {
|
|
163
|
-
const ref = listRelationRef(propDef);
|
|
164
|
-
if (!ref || !propertyName)
|
|
165
|
-
return undefined;
|
|
166
|
-
if (propertyName.endsWith(`${ref}Ids`))
|
|
167
|
-
return propertyName;
|
|
168
|
-
return `${pluralize(propertyName, 1)}${ref}Ids`;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* For a schema property key like `authors` (List of Relation to Identity), returns the
|
|
172
|
-
* internal storage/EAS name: `authorIdentityIds` (singular + ref + Ids).
|
|
173
|
-
*/
|
|
174
|
-
function listRelationStoragePropertyName(propertySchemas, schemaPropertyKey) {
|
|
175
|
-
return listRelationEasPropertyName(schemaPropertyKey, propertySchemas[schemaPropertyKey]);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Reverse of listRelationStoragePropertyName: maps DB/EAS name `authorIdentityIds` to schema key `authors`.
|
|
179
|
-
*/
|
|
180
|
-
function resolveStorageNameToSchemaName(propertySchemas, storagePropertyName) {
|
|
181
|
-
for (const [schemaKey, propDef] of Object.entries(propertySchemas)) {
|
|
182
|
-
if (normalizeDataType(propDef?.dataType) !== 'List')
|
|
183
|
-
continue;
|
|
184
|
-
const ref = propDef.ref || propDef.refModelName;
|
|
185
|
-
if (!ref)
|
|
186
|
-
continue;
|
|
187
|
-
const internalName = `${pluralize(schemaKey, 1)}${ref}Ids`;
|
|
188
|
-
if (internalName === storagePropertyName) {
|
|
189
|
-
return schemaKey;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return undefined;
|
|
193
|
-
}
|
|
194
|
-
/** Internal property names that never use Id-suffix metadata convention */
|
|
195
|
-
const ID_SUFFIX_EXCLUDE = new Set(['storageTransactionId', 'transactionId']);
|
|
196
|
-
/** Data types that store metadata with Id suffix in DB */
|
|
197
|
-
const METADATA_ID_SUFFIX_TYPES = ['Image', 'File', 'Html', 'Relation'];
|
|
198
|
-
/**
|
|
199
|
-
* Whether this type uses Id suffix in metadata table.
|
|
200
|
-
*/
|
|
201
|
-
function needsMetadataIdSuffix(dataType, refValueType) {
|
|
202
|
-
const dt = normalizeDataType(dataType);
|
|
203
|
-
const rvt = normalizeDataType(refValueType);
|
|
204
|
-
return (METADATA_ID_SUFFIX_TYPES.includes(dt) ||
|
|
205
|
-
METADATA_ID_SUFFIX_TYPES.includes(rvt));
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Canonical metadata property name for WRITES.
|
|
209
|
-
* Use when creating/updating metadata.
|
|
210
|
-
*/
|
|
211
|
-
function toMetadataPropertyName(propertyName, dataType, refValueType) {
|
|
212
|
-
if (ID_SUFFIX_EXCLUDE.has(propertyName))
|
|
213
|
-
return propertyName;
|
|
214
|
-
if (propertyName.endsWith('Ids'))
|
|
215
|
-
return propertyName;
|
|
216
|
-
if (propertyName.endsWith('Id'))
|
|
217
|
-
return propertyName;
|
|
218
|
-
if (needsMetadataIdSuffix(dataType, refValueType)) {
|
|
219
|
-
return `${propertyName}Id`;
|
|
220
|
-
}
|
|
221
|
-
return propertyName;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* For READS: property names to include in OR query (both variants).
|
|
225
|
-
* When dataType is undefined, includes all variants for safety (backwards compat with getPropertyData).
|
|
226
|
-
*/
|
|
227
|
-
function getMetadataPropertyNamesForQuery(propertyName, dataType, refValueType) {
|
|
228
|
-
if (ID_SUFFIX_EXCLUDE.has(propertyName))
|
|
229
|
-
return [propertyName];
|
|
230
|
-
if (propertyName.endsWith('Ids'))
|
|
231
|
-
return [propertyName];
|
|
232
|
-
if (propertyName.endsWith('Id')) {
|
|
233
|
-
const base = propertyName.slice(0, -2);
|
|
234
|
-
return [propertyName, base];
|
|
235
|
-
}
|
|
236
|
-
const needsId = needsMetadataIdSuffix(dataType, refValueType) ||
|
|
237
|
-
(dataType === undefined && refValueType === undefined);
|
|
238
|
-
if (needsId) {
|
|
239
|
-
return [propertyName, `${propertyName}Id`, `${propertyName}Ids`];
|
|
240
|
-
}
|
|
241
|
-
return [propertyName];
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Schema property name from metadata name (strip Id/Ids suffix).
|
|
245
|
-
*/
|
|
246
|
-
function toSchemaPropertyName(propertyName) {
|
|
247
|
-
if (propertyName.endsWith('Ids'))
|
|
248
|
-
return propertyName.slice(0, -3);
|
|
249
|
-
if (propertyName.endsWith('Id'))
|
|
250
|
-
return propertyName.slice(0, -2);
|
|
251
|
-
return undefined;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Alternate property name for instance lookup (base <-> Id variant).
|
|
255
|
-
*/
|
|
256
|
-
function getAlternatePropertyNameForInstanceLookup(propertyName) {
|
|
257
|
-
if (ID_SUFFIX_EXCLUDE.has(propertyName))
|
|
258
|
-
return undefined;
|
|
259
|
-
if (propertyName.endsWith('Id'))
|
|
260
|
-
return propertyName.slice(0, -2);
|
|
261
|
-
return `${propertyName}Id`;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Resolve the best metadata record when multiple variants exist (base + Id).
|
|
265
|
-
* For Image/File/Html: prefer the record with refResolvedValue (Id variant has filename).
|
|
266
|
-
*/
|
|
267
|
-
function resolveMetadataRecord(records, preferredPropertyName, dataType, refValueType) {
|
|
268
|
-
if (records.length === 0)
|
|
269
|
-
throw new Error('No records to resolve');
|
|
270
|
-
if (records.length === 1)
|
|
271
|
-
return records[0];
|
|
272
|
-
const needsId = needsMetadataIdSuffix(dataType, refValueType) ||
|
|
273
|
-
(dataType === undefined && refValueType === undefined);
|
|
274
|
-
// For Image/File/Html: prefer the record with refResolvedValue (Id variant has filename)
|
|
275
|
-
if (needsId) {
|
|
276
|
-
const withRef = records.find((r) => r.refResolvedValue);
|
|
277
|
-
if (withRef)
|
|
278
|
-
return withRef;
|
|
279
|
-
}
|
|
280
|
-
// Also prefer by refSeedType when we need file ref
|
|
281
|
-
if (needsId) {
|
|
282
|
-
const byRefSeed = records.find((r) => r.refSeedType === 'image' ||
|
|
283
|
-
r.refSeedType === 'file' ||
|
|
284
|
-
r.refSeedType === 'html');
|
|
285
|
-
if (byRefSeed)
|
|
286
|
-
return byRefSeed;
|
|
287
|
-
}
|
|
288
|
-
// Fallback: prefer exact propertyName match, else first
|
|
289
|
-
return (records.find((r) => r.propertyName === preferredPropertyName) ?? records[0]);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
147
|
/**
|
|
293
148
|
* Proxy [[GetOwnProperty]] that stays compatible with the target.
|
|
294
149
|
* Never overrides an own descriptor, never invents on a non-extensible target,
|
|
@@ -649,7 +504,7 @@ var metadataLatest = /*#__PURE__*/Object.freeze({
|
|
|
649
504
|
getMetadataLatest: getMetadataLatest
|
|
650
505
|
});
|
|
651
506
|
|
|
652
|
-
const logger$
|
|
507
|
+
const logger$9 = debug('seedSdk:item:actors:loadOrCreateItem');
|
|
653
508
|
/**
|
|
654
509
|
* Maps metadata.property_name to the ItemProperty Map key (same rules as the instance loop below).
|
|
655
510
|
*/
|
|
@@ -725,7 +580,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
725
580
|
const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
|
|
726
581
|
const { ItemProperty } = itemPropertyMod;
|
|
727
582
|
const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
|
|
728
|
-
const _mod_0 = await import('./errors-
|
|
583
|
+
const _mod_0 = await import('./errors-DdWbxb_n.js');
|
|
729
584
|
const _ns_0 = _mod_0.h;
|
|
730
585
|
const { Model } = _ns_0;
|
|
731
586
|
// Resolve Model and build property schemas (use getByNameAsync for models not yet in cache)
|
|
@@ -743,24 +598,24 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
743
598
|
const schemaNameToTry = schemaName ?? model?.schemaName;
|
|
744
599
|
if (schemaNameToTry) {
|
|
745
600
|
try {
|
|
746
|
-
const _mod_1 = await import('./Schema-
|
|
601
|
+
const _mod_1 = await import('./Schema-Bf-jOLq0.js');
|
|
747
602
|
const _ns_1 = _mod_1.b;
|
|
748
603
|
const { Schema } = _ns_1;
|
|
749
604
|
const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
|
|
750
605
|
const schemaContext = schemaInstance.getService().getSnapshot().context;
|
|
751
606
|
if (schemaContext.models?.[modelName]?.properties) {
|
|
752
607
|
propertySchemas = schemaContext.models[modelName].properties;
|
|
753
|
-
logger$
|
|
608
|
+
logger$9(`Fallback: got ${Object.keys(propertySchemas).length} property schemas from Schema context for ${modelName}`);
|
|
754
609
|
}
|
|
755
610
|
}
|
|
756
611
|
catch (err) {
|
|
757
|
-
logger$
|
|
612
|
+
logger$9(`Fallback Schema context failed for ${modelName}: ${err}`);
|
|
758
613
|
}
|
|
759
614
|
}
|
|
760
615
|
if (Object.keys(propertySchemas).length === 0) {
|
|
761
616
|
try {
|
|
762
|
-
const _mod_2 = await import('./ClientManager-
|
|
763
|
-
const _ns_2 = _mod_2.
|
|
617
|
+
const _mod_2 = await import('./ClientManager-Dfu4jcgm.js');
|
|
618
|
+
const _ns_2 = _mod_2.L;
|
|
764
619
|
const { loadAllSchemasFromDb } = _ns_2;
|
|
765
620
|
const allSchemas = await loadAllSchemasFromDb();
|
|
766
621
|
for (const { schema: schemaFile } of allSchemas) {
|
|
@@ -769,22 +624,22 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
769
624
|
const models = schemaFile.models;
|
|
770
625
|
if (models?.[modelName]?.properties) {
|
|
771
626
|
propertySchemas = models[modelName].properties;
|
|
772
|
-
logger$
|
|
627
|
+
logger$9(`Fallback: got ${Object.keys(propertySchemas).length} property schemas from loadAllSchemasFromDb for ${modelName}`);
|
|
773
628
|
break;
|
|
774
629
|
}
|
|
775
630
|
}
|
|
776
631
|
}
|
|
777
632
|
catch (err) {
|
|
778
|
-
logger$
|
|
633
|
+
logger$9(`Fallback loadAllSchemasFromDb failed for ${modelName}: ${err}`);
|
|
779
634
|
}
|
|
780
635
|
}
|
|
781
636
|
if (Object.keys(propertySchemas).length === 0) {
|
|
782
637
|
try {
|
|
783
|
-
const _mod_3 = await import('./ClientManager-
|
|
784
|
-
const _ns_3 = _mod_3.
|
|
638
|
+
const _mod_3 = await import('./ClientManager-Dfu4jcgm.js');
|
|
639
|
+
const _ns_3 = _mod_3.L;
|
|
785
640
|
const { listCompleteSchemaFiles } = _ns_3;
|
|
786
|
-
const _mod_4 = await import('./BasePathResolver-
|
|
787
|
-
const _ns_4 = _mod_4.
|
|
641
|
+
const _mod_4 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
642
|
+
const _ns_4 = _mod_4.b7;
|
|
788
643
|
const { BaseFileManager } = _ns_4;
|
|
789
644
|
const schemaFiles = await listCompleteSchemaFiles();
|
|
790
645
|
for (const { filePath } of schemaFiles) {
|
|
@@ -794,17 +649,17 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
794
649
|
continue;
|
|
795
650
|
if (schemaFile.models?.[modelName]?.properties) {
|
|
796
651
|
propertySchemas = schemaFile.models[modelName].properties;
|
|
797
|
-
logger$
|
|
652
|
+
logger$9(`Fallback: got ${Object.keys(propertySchemas).length} property schemas from schema file for ${modelName}`);
|
|
798
653
|
break;
|
|
799
654
|
}
|
|
800
655
|
}
|
|
801
656
|
}
|
|
802
657
|
catch (err) {
|
|
803
|
-
logger$
|
|
658
|
+
logger$9(`Fallback schema file scan failed for ${modelName}: ${err}`);
|
|
804
659
|
}
|
|
805
660
|
}
|
|
806
661
|
if (Object.keys(propertySchemas).length === 0) {
|
|
807
|
-
const schemaMod = await import('./index-
|
|
662
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
808
663
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
809
664
|
const KNOWN_MODEL_FALLBACKS = {
|
|
810
665
|
Post: {
|
|
@@ -816,12 +671,12 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
816
671
|
};
|
|
817
672
|
if (KNOWN_MODEL_FALLBACKS[modelName]) {
|
|
818
673
|
propertySchemas = KNOWN_MODEL_FALLBACKS[modelName];
|
|
819
|
-
logger$
|
|
674
|
+
logger$9(`Fallback: using known model schema for ${modelName} (${Object.keys(propertySchemas).length} properties)`);
|
|
820
675
|
}
|
|
821
676
|
}
|
|
822
677
|
}
|
|
823
678
|
// Fallbacks above may return schema-file shape ({ type, model, items }); normalize to dataType/ref/refValueType.
|
|
824
|
-
const { normalizePropertyRecordSchema } = await import('./property-
|
|
679
|
+
const { normalizePropertyRecordSchema } = await import('./property-zFPMtR3T.js');
|
|
825
680
|
propertySchemas = Object.fromEntries(Object.entries(propertySchemas).map(([name, def]) => [name, normalizePropertyRecordSchema(def)]));
|
|
826
681
|
// Collapse rows that map to the same instance key (e.g. authorIdentityIds + authors -> authors).
|
|
827
682
|
// ItemProperty.create cache does not sync propertyValue on hit; processing order would otherwise
|
|
@@ -834,7 +689,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
834
689
|
try {
|
|
835
690
|
let propertyName = metaRow.propertyName;
|
|
836
691
|
if (!propertyName) {
|
|
837
|
-
logger$
|
|
692
|
+
logger$9(`Metadata row missing propertyName, skipping`);
|
|
838
693
|
continue;
|
|
839
694
|
}
|
|
840
695
|
const listSchemaKey = resolveStorageNameToSchemaName(propertySchemas, propertyName);
|
|
@@ -854,7 +709,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
854
709
|
// Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
|
|
855
710
|
let propSchema = propertySchemas[propertyName];
|
|
856
711
|
if (!propSchema && isRefTypeFromMeta) {
|
|
857
|
-
const schemaMod = await import('./index-
|
|
712
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
858
713
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
859
714
|
propSchema = {
|
|
860
715
|
dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
|
|
@@ -884,14 +739,14 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
884
739
|
const property = ItemProperty.create(createProps, { waitForReady: false });
|
|
885
740
|
if (property) {
|
|
886
741
|
propertyInstances.set(propertyName, property);
|
|
887
|
-
logger$
|
|
742
|
+
logger$9(`Created/cached ItemProperty instance for propertyName "${propertyName}" with propertyRecordSchema: ${!!createProps.propertyRecordSchema}`);
|
|
888
743
|
}
|
|
889
744
|
else {
|
|
890
|
-
logger$
|
|
745
|
+
logger$9(`ItemProperty.create returned undefined for propertyName "${propertyName}"`);
|
|
891
746
|
}
|
|
892
747
|
}
|
|
893
748
|
catch (error) {
|
|
894
|
-
logger$
|
|
749
|
+
logger$9(`Error creating ItemProperty instance for propertyName "${metaRow.propertyName}": ${error}`);
|
|
895
750
|
}
|
|
896
751
|
}
|
|
897
752
|
// Create placeholder ItemProperty instances for model schema properties without metadata
|
|
@@ -914,17 +769,17 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
914
769
|
const property = ItemProperty.create(createProps, { waitForReady: false });
|
|
915
770
|
if (property) {
|
|
916
771
|
propertyInstances.set(propertyName, property);
|
|
917
|
-
logger$
|
|
772
|
+
logger$9(`Created placeholder ItemProperty for model property "${propertyName}" (no metadata)`);
|
|
918
773
|
}
|
|
919
774
|
}
|
|
920
775
|
catch (error) {
|
|
921
|
-
logger$
|
|
776
|
+
logger$9(`Error creating placeholder ItemProperty for "${propertyName}": ${error}`);
|
|
922
777
|
}
|
|
923
778
|
}
|
|
924
|
-
logger$
|
|
779
|
+
logger$9(`Finished creating/caching ${propertyInstances.size} ItemProperty instances`);
|
|
925
780
|
}
|
|
926
781
|
catch (error) {
|
|
927
|
-
logger$
|
|
782
|
+
logger$9(`Error in createItemPropertyInstances: ${error}`);
|
|
928
783
|
// Don't throw - this is best-effort to pre-populate cache
|
|
929
784
|
}
|
|
930
785
|
return propertyInstances;
|
|
@@ -932,7 +787,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
932
787
|
const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
933
788
|
const _loadOrCreateItem = async () => {
|
|
934
789
|
const { seedLocalId, seedUid, modelName } = context;
|
|
935
|
-
logger$
|
|
790
|
+
logger$9(`loadOrCreateItem called for modelName: ${modelName}, seedLocalId: ${seedLocalId}, seedUid: ${seedUid}`);
|
|
936
791
|
if (!seedLocalId && !seedUid) {
|
|
937
792
|
throw new Error('seedLocalId or seedUid is required');
|
|
938
793
|
}
|
|
@@ -962,7 +817,7 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
962
817
|
.limit(1);
|
|
963
818
|
if (seedRecords.length === 0) {
|
|
964
819
|
// Seed not found - this is a new item, will be created elsewhere
|
|
965
|
-
logger$
|
|
820
|
+
logger$9(`Seed not found in database for seedLocalId: ${seedLocalId}, seedUid: ${seedUid}`);
|
|
966
821
|
sendBack({
|
|
967
822
|
type: 'loadOrCreateItemSuccess',
|
|
968
823
|
item: {
|
|
@@ -1005,7 +860,7 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1005
860
|
.where(eq(seeds.localId, resolvedSeedLocalId))
|
|
1006
861
|
.limit(1);
|
|
1007
862
|
if (versionRecords.length === 0) {
|
|
1008
|
-
logger$
|
|
863
|
+
logger$9(`No version data found for seedLocalId: ${resolvedSeedLocalId}`);
|
|
1009
864
|
sendBack({
|
|
1010
865
|
type: 'loadOrCreateItemSuccess',
|
|
1011
866
|
item: {
|
|
@@ -1032,7 +887,7 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1032
887
|
// A seed whose versions are all revoked (fully unpublished) has no latest version but still has
|
|
1033
888
|
// its last property values; load those like any other item. Only a seed without versions stops here.
|
|
1034
889
|
if (!latestVersionLocalId && !versionRecord.versionsCount) {
|
|
1035
|
-
logger$
|
|
890
|
+
logger$9(`No latest version found for seedLocalId: ${resolvedSeedLocalId}`);
|
|
1036
891
|
sendBack({
|
|
1037
892
|
type: 'loadOrCreateItemSuccess',
|
|
1038
893
|
item: {
|
|
@@ -1064,7 +919,7 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1064
919
|
.select()
|
|
1065
920
|
.from(metadataLatest)
|
|
1066
921
|
.where(eq(metadataLatest.rowNum, 1));
|
|
1067
|
-
logger$
|
|
922
|
+
logger$9(`Found ${metadataRecords.length} latest-per-property metadata rows for seed ${resolvedSeedLocalId} (latestVersionLocalId=${latestVersionLocalId} used for placeholders only)`);
|
|
1068
923
|
// Step 4: Create ItemProperty instances from metadata records + placeholders for model schema properties
|
|
1069
924
|
// Always call when we have a valid version so placeholders are created for properties without metadata
|
|
1070
925
|
const propertyInstances = await createItemPropertyInstances(metadataRecords, resolvedSeedLocalId, resolvedSeedUid, modelName, latestVersionLocalId, latestVersionUid, modelScope);
|
|
@@ -1097,7 +952,7 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1097
952
|
});
|
|
1098
953
|
};
|
|
1099
954
|
_loadOrCreateItem().catch((error) => {
|
|
1100
|
-
logger$
|
|
955
|
+
logger$9(`Error in loadOrCreateItem: ${error}`);
|
|
1101
956
|
sendBack({
|
|
1102
957
|
type: 'loadOrCreateItemError',
|
|
1103
958
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -1105,7 +960,7 @@ const loadOrCreateItem = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1105
960
|
});
|
|
1106
961
|
});
|
|
1107
962
|
|
|
1108
|
-
const logger$
|
|
963
|
+
const logger$8 = debug('seedSdk:Item:runPublish');
|
|
1109
964
|
/**
|
|
1110
965
|
* Runs the publish for item.publish() by handing the item to the PublishExecutor that
|
|
1111
966
|
* @seedprotocol/publish registers, which uploads to Arweave and writes to EAS.
|
|
@@ -1134,7 +989,7 @@ const runPublish = fromCallback(({ sendBack, input: { context, item: itemFromEve
|
|
|
1134
989
|
sendBack({ type: 'publishSuccess' });
|
|
1135
990
|
}
|
|
1136
991
|
catch (error) {
|
|
1137
|
-
logger$
|
|
992
|
+
logger$8('runPublish error:', error);
|
|
1138
993
|
sendBack({ type: 'publishError', error: error instanceof Error ? error : new Error(String(error)) });
|
|
1139
994
|
}
|
|
1140
995
|
};
|
|
@@ -1413,7 +1268,7 @@ async function getLatestPublishedVersionRow(seedLocalId) {
|
|
|
1413
1268
|
return null;
|
|
1414
1269
|
}
|
|
1415
1270
|
|
|
1416
|
-
const logger$
|
|
1271
|
+
const logger$7 = debug('seedSdk:db:read:getItemData');
|
|
1417
1272
|
/**
|
|
1418
1273
|
* Assemble flat ItemData for Item / liveQuery / draft-head authoring.
|
|
1419
1274
|
*
|
|
@@ -1429,7 +1284,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
1429
1284
|
if (seedUid && !seedLocalId) {
|
|
1430
1285
|
const seedData = await getSeedData({ seedUid });
|
|
1431
1286
|
if (!seedData) {
|
|
1432
|
-
logger$
|
|
1287
|
+
logger$7('[db/queries] [getItem] no seedData seedUid', seedUid);
|
|
1433
1288
|
return;
|
|
1434
1289
|
}
|
|
1435
1290
|
seedLocalId = seedData.localId || undefined;
|
|
@@ -1438,7 +1293,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
1438
1293
|
const { localId, uid, ...rest } = getTableColumns(seeds);
|
|
1439
1294
|
const whereClauses = [];
|
|
1440
1295
|
if (modelName) {
|
|
1441
|
-
whereClauses.push(eq(seeds.type,
|
|
1296
|
+
whereClauses.push(eq(seeds.type, easName(modelName)));
|
|
1442
1297
|
}
|
|
1443
1298
|
if (seedUid) {
|
|
1444
1299
|
whereClauses.push(eq(seeds.uid, seedUid));
|
|
@@ -1456,9 +1311,9 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
1456
1311
|
.from(seeds)
|
|
1457
1312
|
.where(and(...whereClauses))
|
|
1458
1313
|
.limit(1);
|
|
1459
|
-
logger$
|
|
1314
|
+
logger$7('[getItemData] Seed query result', { rowsCount: seedRows?.length || 0, firstRow: seedRows?.[0] });
|
|
1460
1315
|
if (!seedRows || seedRows.length === 0) {
|
|
1461
|
-
logger$
|
|
1316
|
+
logger$7('[db/queries] [getItemDataFromDb] no seedRows found', { modelName, seedLocalId, seedUid });
|
|
1462
1317
|
return;
|
|
1463
1318
|
}
|
|
1464
1319
|
const seedRow = seedRows[0];
|
|
@@ -1484,7 +1339,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
1484
1339
|
}
|
|
1485
1340
|
}
|
|
1486
1341
|
catch (error) {
|
|
1487
|
-
logger$
|
|
1342
|
+
logger$7('[getItemData] Error deriving schemaName:', error);
|
|
1488
1343
|
}
|
|
1489
1344
|
}
|
|
1490
1345
|
// Now get version data if it exists - query versions table directly
|
|
@@ -1857,11 +1712,11 @@ const getItemsData = async ({ modelName, modelFileId, schemaName, deleted, inclu
|
|
|
1857
1712
|
conditions.push(placeholderUidSql(seeds.uid));
|
|
1858
1713
|
}
|
|
1859
1714
|
if (modelName) {
|
|
1860
|
-
conditions.push(eq(seeds.type,
|
|
1715
|
+
conditions.push(eq(seeds.type, easName(modelName)));
|
|
1861
1716
|
}
|
|
1862
1717
|
if (!modelFileId && schemaName && modelName) {
|
|
1863
|
-
const _mod_5 = await import('./BasePathResolver-
|
|
1864
|
-
const _ns_5 = _mod_5.
|
|
1718
|
+
const _mod_5 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
1719
|
+
const _ns_5 = _mod_5.ba;
|
|
1865
1720
|
const { resolveModelRecord } = _ns_5;
|
|
1866
1721
|
modelFileId = (await resolveModelRecord(modelName, { schemaName }))?.schemaFileId ?? undefined;
|
|
1867
1722
|
if (!modelFileId)
|
|
@@ -1949,12 +1804,12 @@ async function getLatestVersionRow(seedLocalId) {
|
|
|
1949
1804
|
return rows[0] ?? null;
|
|
1950
1805
|
}
|
|
1951
1806
|
|
|
1952
|
-
const logger$
|
|
1807
|
+
const logger$6 = debug('seedSdk:ItemProperty:service:actors:waitForDb');
|
|
1953
1808
|
const waitForDb = fromCallback(({ sendBack }) => {
|
|
1954
1809
|
// Check immediately first
|
|
1955
1810
|
const appDb = BaseDb.getAppDb();
|
|
1956
1811
|
if (appDb) {
|
|
1957
|
-
logger$
|
|
1812
|
+
logger$6('Database is ready (immediate check)');
|
|
1958
1813
|
sendBack({ type: 'waitForDbSuccess' });
|
|
1959
1814
|
return;
|
|
1960
1815
|
}
|
|
@@ -1966,31 +1821,31 @@ const waitForDb = fromCallback(({ sendBack }) => {
|
|
|
1966
1821
|
const appDb = BaseDb.getAppDb();
|
|
1967
1822
|
if (appDb) {
|
|
1968
1823
|
clearInterval(interval);
|
|
1969
|
-
logger$
|
|
1824
|
+
logger$6('Database is ready (after polling)');
|
|
1970
1825
|
resolve();
|
|
1971
1826
|
}
|
|
1972
1827
|
else if (Date.now() - startTime > timeout) {
|
|
1973
1828
|
clearInterval(interval);
|
|
1974
1829
|
const error = new Error('Database not available after timeout');
|
|
1975
|
-
logger$
|
|
1830
|
+
logger$6(`Database wait timeout: ${error.message}`);
|
|
1976
1831
|
reject(error);
|
|
1977
1832
|
}
|
|
1978
1833
|
}, 100);
|
|
1979
1834
|
});
|
|
1980
1835
|
_waitForDb
|
|
1981
1836
|
.then(() => {
|
|
1982
|
-
logger$
|
|
1837
|
+
logger$6('Sending waitForDbSuccess event');
|
|
1983
1838
|
sendBack({ type: 'waitForDbSuccess' });
|
|
1984
1839
|
})
|
|
1985
1840
|
.catch((error) => {
|
|
1986
|
-
logger$
|
|
1841
|
+
logger$6(`Error waiting for database: ${error}`);
|
|
1987
1842
|
sendBack({ type: 'waitForDbError', error: error.message });
|
|
1988
1843
|
});
|
|
1989
1844
|
});
|
|
1990
1845
|
|
|
1991
1846
|
const getEasSchemaForItemProperty = async ({ schemaUid, propertyName, easDataType, }) => {
|
|
1992
1847
|
try {
|
|
1993
|
-
const propertyNameSnakeCase =
|
|
1848
|
+
const propertyNameSnakeCase = easName(propertyName);
|
|
1994
1849
|
const isMissingSchemaUid = !schemaUid || schemaUid === 'null' || schemaUid === 'undefined';
|
|
1995
1850
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
1996
1851
|
const easClient = BaseEasClient.getEasClient();
|
|
@@ -2135,7 +1990,7 @@ const getRelationValueData = async (propertyValue) => {
|
|
|
2135
1990
|
|
|
2136
1991
|
// Dynamic import to break circular dependency: schema/index -> ... -> resolveRelatedValue -> schema/index
|
|
2137
1992
|
// import { ModelPropertyDataTypes } from '@/schema'
|
|
2138
|
-
const logger$
|
|
1993
|
+
const logger$5 = debug('seedSdk:property:actors:resolveRelatedValue');
|
|
2139
1994
|
const storageTransactionIdToContentUrl = new Map();
|
|
2140
1995
|
const refResolvedValueToContentUrl = new Map();
|
|
2141
1996
|
const seedUidToContentUrl = new Map();
|
|
@@ -2143,14 +1998,14 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2143
1998
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
2144
1999
|
const _resolveRelatedValue = async () => {
|
|
2145
2000
|
// Use dynamic import to break circular dependency
|
|
2146
|
-
const schemaMod = await import('./index-
|
|
2001
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
2147
2002
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
2148
2003
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
2149
2004
|
return;
|
|
2150
2005
|
}
|
|
2151
2006
|
if (Array.isArray(propertyValue)) {
|
|
2152
2007
|
// TODO: Handle array of seedUids
|
|
2153
|
-
logger$
|
|
2008
|
+
logger$5(`${propertyName} value is an array of seedUids`);
|
|
2154
2009
|
return;
|
|
2155
2010
|
}
|
|
2156
2011
|
if (typeof propertyValue === 'object') {
|
|
@@ -2162,7 +2017,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2162
2017
|
parsedValue = JSON.parse(relationKey);
|
|
2163
2018
|
}
|
|
2164
2019
|
catch (error) {
|
|
2165
|
-
logger$
|
|
2020
|
+
logger$5(`${propertyName} value is not a JSON string.`);
|
|
2166
2021
|
}
|
|
2167
2022
|
if (!parsedValue && seedUidToContentUrl.has(relationKey)) {
|
|
2168
2023
|
const contentUrl = seedUidToContentUrl.get(relationKey);
|
|
@@ -2177,7 +2032,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2177
2032
|
return true;
|
|
2178
2033
|
}
|
|
2179
2034
|
if (Array.isArray(parsedValue)) {
|
|
2180
|
-
logger$
|
|
2035
|
+
logger$5(`${propertyName} value is a stringified array of seedUids`);
|
|
2181
2036
|
return;
|
|
2182
2037
|
}
|
|
2183
2038
|
const storageTransactionId = await getStorageTransactionIdForSeedUid(relationKey);
|
|
@@ -2578,8 +2433,8 @@ async function readHtmlBodyFromChildStorageArweave(seedLocalId) {
|
|
|
2578
2433
|
/* offline / bad tx id */
|
|
2579
2434
|
}
|
|
2580
2435
|
try {
|
|
2581
|
-
const _mod_6 = await import('./BasePathResolver-
|
|
2582
|
-
const _ns_6 = _mod_6.
|
|
2436
|
+
const _mod_6 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
2437
|
+
const _ns_6 = _mod_6.bc;
|
|
2583
2438
|
const { downloadTransactionIdWithDedupe } = _ns_6;
|
|
2584
2439
|
await downloadTransactionIdWithDedupe(txId);
|
|
2585
2440
|
const retryFp = BaseFileManager.getFilesPath('html', `${seedLocalId}.html`);
|
|
@@ -2628,7 +2483,7 @@ async function readHtmlBodyForStorageSeedPropertyValue(propertyValue) {
|
|
|
2628
2483
|
|
|
2629
2484
|
// Dynamic import to break circular dependency: schema/index -> ... -> hydrateFromDb -> schema/index
|
|
2630
2485
|
// import { ModelPropertyDataTypes } from '@/schema'
|
|
2631
|
-
const logger$
|
|
2486
|
+
const logger$4 = debug('seedSdk:property:actors:hydrateFromDb');
|
|
2632
2487
|
const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2633
2488
|
const { seedUid, seedLocalId, propertyName: propertyNameRaw, propertyRecordSchema, modelName, } = context;
|
|
2634
2489
|
if (!propertyNameRaw) {
|
|
@@ -2639,7 +2494,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2639
2494
|
// to use dynamically imported ModelPropertyDataTypes
|
|
2640
2495
|
const _hydrateFromDb = async () => {
|
|
2641
2496
|
// Use dynamic import to break circular dependency
|
|
2642
|
-
const schemaMod = await import('./index-
|
|
2497
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
2643
2498
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
2644
2499
|
const appDb = BaseDb.getAppDb();
|
|
2645
2500
|
const whereClauses = [];
|
|
@@ -2745,7 +2600,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2745
2600
|
}
|
|
2746
2601
|
}
|
|
2747
2602
|
catch (e) {
|
|
2748
|
-
logger$
|
|
2603
|
+
logger$4('[hydrateFromDb] Image file resolution error', e);
|
|
2749
2604
|
}
|
|
2750
2605
|
}
|
|
2751
2606
|
}
|
|
@@ -2778,7 +2633,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2778
2633
|
}
|
|
2779
2634
|
}
|
|
2780
2635
|
catch (e) {
|
|
2781
|
-
logger$
|
|
2636
|
+
logger$4('[hydrateFromDb] File resolution error', e);
|
|
2782
2637
|
}
|
|
2783
2638
|
}
|
|
2784
2639
|
if (propertyRecordSchema &&
|
|
@@ -2881,11 +2736,11 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2881
2736
|
});
|
|
2882
2737
|
});
|
|
2883
2738
|
|
|
2884
|
-
const logger$
|
|
2739
|
+
const logger$3 = debug('seedSdk:itemProperty:actors:loadOrCreateProperty');
|
|
2885
2740
|
const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) => {
|
|
2886
2741
|
const _loadOrCreateProperty = async () => {
|
|
2887
2742
|
const { seedLocalId, seedUid, propertyName, versionLocalId } = context;
|
|
2888
|
-
logger$
|
|
2743
|
+
logger$3(`loadOrCreateProperty called for propertyName: ${propertyName}, seedLocalId: ${seedLocalId}, seedUid: ${seedUid}`);
|
|
2889
2744
|
if (!seedLocalId && !seedUid) {
|
|
2890
2745
|
throw new Error('seedLocalId or seedUid is required');
|
|
2891
2746
|
}
|
|
@@ -2920,12 +2775,12 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
2920
2775
|
const modelNameForNew = context.modelName;
|
|
2921
2776
|
if (modelNameForNew) {
|
|
2922
2777
|
try {
|
|
2923
|
-
const _mod_7 = await import('./errors-
|
|
2778
|
+
const _mod_7 = await import('./errors-DdWbxb_n.js');
|
|
2924
2779
|
const _ns_7 = _mod_7.h;
|
|
2925
2780
|
const { Model } = _ns_7;
|
|
2926
2781
|
const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
|
|
2927
|
-
const _mod_8 = await import('./BasePathResolver-
|
|
2928
|
-
const _ns_8 = _mod_8.
|
|
2782
|
+
const _mod_8 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
2783
|
+
const _ns_8 = _mod_8.ba;
|
|
2929
2784
|
const { resolveItemModelFileId } = _ns_8;
|
|
2930
2785
|
const normalizedModelName = upperFirst(camelCase(modelNameForNew));
|
|
2931
2786
|
const itemModelFileId = await resolveItemModelFileId({
|
|
@@ -2935,21 +2790,21 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
2935
2790
|
});
|
|
2936
2791
|
let model = await Model.resolveAsync(normalizedModelName, { modelFileId: itemModelFileId });
|
|
2937
2792
|
if (!model?.properties?.length && !itemModelFileId) {
|
|
2938
|
-
model = Model.findByModelType(
|
|
2793
|
+
model = Model.findByModelType(easName(modelNameForNew));
|
|
2939
2794
|
}
|
|
2940
2795
|
if (model?.properties?.length) {
|
|
2941
2796
|
const schemas = modelPropertiesToObject(model.properties);
|
|
2942
2797
|
propertyRecordSchema = schemas[propertyName];
|
|
2943
2798
|
if (propertyRecordSchema) {
|
|
2944
|
-
logger$
|
|
2799
|
+
logger$3(`Metadata not found: loaded propertyRecordSchema from Model for propertyName "${propertyName}"`);
|
|
2945
2800
|
}
|
|
2946
2801
|
}
|
|
2947
2802
|
}
|
|
2948
2803
|
catch (error) {
|
|
2949
|
-
logger$
|
|
2804
|
+
logger$3(`Metadata not found: Model fallback failed for propertyName "${propertyName}": ${error}`);
|
|
2950
2805
|
}
|
|
2951
2806
|
}
|
|
2952
|
-
logger$
|
|
2807
|
+
logger$3(`Metadata not found in database for propertyName: ${propertyName}, seedLocalId: ${seedLocalId}`);
|
|
2953
2808
|
sendBack({
|
|
2954
2809
|
type: 'loadOrCreatePropertySuccess',
|
|
2955
2810
|
property: {
|
|
@@ -2978,8 +2833,8 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
2978
2833
|
// It ends up in the context below, and later lookups by name (Model.getByName) can't match it.
|
|
2979
2834
|
const modelName = context.modelName || (metadataRecord.modelType ? upperFirst(camelCase(metadataRecord.modelType)) : undefined);
|
|
2980
2835
|
// Model names are only unique per schema: pin lookups to the item's own model row.
|
|
2981
|
-
const _mod_9 = await import('./BasePathResolver-
|
|
2982
|
-
const _ns_9 = _mod_9.
|
|
2836
|
+
const _mod_9 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
2837
|
+
const _ns_9 = _mod_9.ba;
|
|
2983
2838
|
const { resolveItemModelFileId, resolveModelRecord } = _ns_9;
|
|
2984
2839
|
const modelFileId = await resolveItemModelFileId({
|
|
2985
2840
|
modelFileId: context.modelFileId,
|
|
@@ -3023,7 +2878,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3023
2878
|
required: propRecord.required ?? undefined,
|
|
3024
2879
|
};
|
|
3025
2880
|
// Validation rules (enum, pattern, ...) aren't in the properties table
|
|
3026
|
-
const { resolvePropertyValidationRules } = await import('./propertyValidationRules-
|
|
2881
|
+
const { resolvePropertyValidationRules } = await import('./propertyValidationRules-CeFVhdQg.js');
|
|
3027
2882
|
const validation = await resolvePropertyValidationRules(normalizedModelName, propertyName, {
|
|
3028
2883
|
modelFileId: modelRecord?.schemaFileId ?? modelFileId,
|
|
3029
2884
|
});
|
|
@@ -3034,13 +2889,13 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3034
2889
|
}
|
|
3035
2890
|
}
|
|
3036
2891
|
catch (error) {
|
|
3037
|
-
logger$
|
|
2892
|
+
logger$3(`Error loading propertyRecordSchema from database: ${error}`);
|
|
3038
2893
|
// Continue without propertyRecordSchema
|
|
3039
2894
|
}
|
|
3040
2895
|
}
|
|
3041
2896
|
if (!propertyRecordSchema && modelName) {
|
|
3042
2897
|
try {
|
|
3043
|
-
const _mod_10 = await import('./errors-
|
|
2898
|
+
const _mod_10 = await import('./errors-DdWbxb_n.js');
|
|
3044
2899
|
const _ns_10 = _mod_10.h;
|
|
3045
2900
|
const { Model } = _ns_10;
|
|
3046
2901
|
const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
|
|
@@ -3048,18 +2903,18 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3048
2903
|
// Try PascalCase first ("post" -> "Post"); then findByModelType for names with spaces ("new_model" -> "New model")
|
|
3049
2904
|
let model = Model.resolve(normalizedModelName, { modelFileId });
|
|
3050
2905
|
if (!model?.properties?.length && !modelFileId) {
|
|
3051
|
-
model = Model.findByModelType(
|
|
2906
|
+
model = Model.findByModelType(easName(modelName));
|
|
3052
2907
|
}
|
|
3053
2908
|
if (model?.properties?.length) {
|
|
3054
2909
|
const schemas = modelPropertiesToObject(model.properties);
|
|
3055
2910
|
propertyRecordSchema = schemas[propertyName];
|
|
3056
2911
|
if (propertyRecordSchema) {
|
|
3057
|
-
logger$
|
|
2912
|
+
logger$3(`Fallback: loaded propertyRecordSchema from Model for propertyName "${propertyName}"`);
|
|
3058
2913
|
}
|
|
3059
2914
|
}
|
|
3060
2915
|
}
|
|
3061
2916
|
catch (error) {
|
|
3062
|
-
logger$
|
|
2917
|
+
logger$3(`Fallback Model lookup failed for propertyName "${propertyName}": ${error}`);
|
|
3063
2918
|
}
|
|
3064
2919
|
}
|
|
3065
2920
|
// For Html: read file content for renderValue (propertyValue is seed ID; blob URLs in DB are invalid after reload)
|
|
@@ -3100,7 +2955,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3100
2955
|
}
|
|
3101
2956
|
}
|
|
3102
2957
|
catch (e) {
|
|
3103
|
-
logger$
|
|
2958
|
+
logger$3(`Failed to read Html file for ${propertyName}: ${e}`);
|
|
3104
2959
|
}
|
|
3105
2960
|
}
|
|
3106
2961
|
// Covers missing ref row, wrong ref, or DB dataType casing "html" (handled by isHtml above).
|
|
@@ -3158,7 +3013,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3158
3013
|
});
|
|
3159
3014
|
}
|
|
3160
3015
|
catch (e) {
|
|
3161
|
-
logger$
|
|
3016
|
+
logger$3(`loadOrCreateProperty: updateMetadata refResolvedValue failed for ${propertyName}:`, e);
|
|
3162
3017
|
}
|
|
3163
3018
|
}
|
|
3164
3019
|
}
|
|
@@ -3180,7 +3035,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3180
3035
|
}
|
|
3181
3036
|
}
|
|
3182
3037
|
catch (e) {
|
|
3183
|
-
logger$
|
|
3038
|
+
logger$3(`Failed to resolve Image file for ${propertyName}: ${e}`);
|
|
3184
3039
|
}
|
|
3185
3040
|
}
|
|
3186
3041
|
const isFile = refSeedType === 'file' ||
|
|
@@ -3199,7 +3054,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3199
3054
|
}
|
|
3200
3055
|
}
|
|
3201
3056
|
catch (e) {
|
|
3202
|
-
logger$
|
|
3057
|
+
logger$3(`Failed to resolve File for ${propertyName}: ${e}`);
|
|
3203
3058
|
}
|
|
3204
3059
|
}
|
|
3205
3060
|
let propertyValueOut = metadataRecord.propertyValue || undefined;
|
|
@@ -3232,7 +3087,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
3232
3087
|
});
|
|
3233
3088
|
};
|
|
3234
3089
|
_loadOrCreateProperty().catch((error) => {
|
|
3235
|
-
logger$
|
|
3090
|
+
logger$3(`Error in loadOrCreateProperty: ${error}`);
|
|
3236
3091
|
sendBack({
|
|
3237
3092
|
type: 'loadOrCreatePropertyError',
|
|
3238
3093
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -3262,10 +3117,10 @@ const getVersionData = async ({ localId, seedLocalId, uid, }) => {
|
|
|
3262
3117
|
return queryRows[0];
|
|
3263
3118
|
};
|
|
3264
3119
|
|
|
3265
|
-
const logger$
|
|
3120
|
+
const logger$2 = debug('seedSdk:write:updateItemPropertyValue');
|
|
3266
3121
|
const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, dataType, refValueType, }) => {
|
|
3267
3122
|
if (!localIdParam && !seedLocalId) {
|
|
3268
|
-
logger$
|
|
3123
|
+
logger$2(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
3269
3124
|
return;
|
|
3270
3125
|
}
|
|
3271
3126
|
// Every write below binds parameters: store the value as given (no SQL escaping).
|
|
@@ -3317,7 +3172,7 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
|
|
|
3317
3172
|
modelType === modelName?.toLowerCase() &&
|
|
3318
3173
|
refSeedTypeFromDb === refSeedType &&
|
|
3319
3174
|
refResolvedValueFromDb === refResolvedValue) {
|
|
3320
|
-
logger$
|
|
3175
|
+
logger$2(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
3321
3176
|
return;
|
|
3322
3177
|
}
|
|
3323
3178
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -3474,9 +3329,9 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
3474
3329
|
return false;
|
|
3475
3330
|
}
|
|
3476
3331
|
// Use dynamic import to break circular dependency
|
|
3477
|
-
const schemaMod = await import('./index-
|
|
3332
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
3478
3333
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
3479
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
3334
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-BNYMacsx.js');
|
|
3480
3335
|
let propertyName = propertyNameRaw;
|
|
3481
3336
|
if (!propertyName) {
|
|
3482
3337
|
throw new Error('propertyName is required');
|
|
@@ -3642,36 +3497,17 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
3642
3497
|
});
|
|
3643
3498
|
});
|
|
3644
3499
|
|
|
3500
|
+
const logger$1 = debug('seedSdk:db:read:getSchemaUidForModel');
|
|
3501
|
+
/**
|
|
3502
|
+
* EAS schema UID of a model's seeds: the in-memory cache, then `model_uids` (written from EAS by
|
|
3503
|
+
* startup and sync), then EAS itself. The DB comes before EAS so creating items and saving
|
|
3504
|
+
* images, files and Html bodies works offline. A failed EAS request (offline) counts as "no UID":
|
|
3505
|
+
* the seed is created without one and publish looks it up again.
|
|
3506
|
+
*/
|
|
3645
3507
|
const getEasSchemaUidForModel = async (modelName) => {
|
|
3646
3508
|
const cached = getSchemaUidForModelFromCache(modelName);
|
|
3647
3509
|
if (cached)
|
|
3648
3510
|
return cached;
|
|
3649
|
-
const modeType = modelName.toLowerCase();
|
|
3650
|
-
// Misses are cached too (most local models have no EAS schema); the DB fallback below still runs.
|
|
3651
|
-
const easSchemaUid = await cachedSchemaLookup(`model:${modeType}`, async () => {
|
|
3652
|
-
const queryClient = BaseQueryClient.getQueryClient();
|
|
3653
|
-
const easClient = BaseEasClient.getEasClient();
|
|
3654
|
-
const modelSchemaQuery = await queryClient.fetchQuery({
|
|
3655
|
-
queryKey: [`getEasSchemaUidForModel`, modeType],
|
|
3656
|
-
queryFn: async () => easClient.request(GET_SCHEMAS, {
|
|
3657
|
-
where: {
|
|
3658
|
-
schemaNames: {
|
|
3659
|
-
some: {
|
|
3660
|
-
name: {
|
|
3661
|
-
equals: modeType,
|
|
3662
|
-
},
|
|
3663
|
-
},
|
|
3664
|
-
},
|
|
3665
|
-
},
|
|
3666
|
-
}),
|
|
3667
|
-
});
|
|
3668
|
-
return modelSchemaQuery.schemas[0]?.id;
|
|
3669
|
-
});
|
|
3670
|
-
if (easSchemaUid) {
|
|
3671
|
-
setSchemaUidForModel({ modelName, schemaUid: easSchemaUid });
|
|
3672
|
-
return easSchemaUid;
|
|
3673
|
-
}
|
|
3674
|
-
// Fallback: use schema UID from local DB when EAS has no schema (e.g. test schemas)
|
|
3675
3511
|
const appDb = BaseDb.getAppDb();
|
|
3676
3512
|
if (appDb) {
|
|
3677
3513
|
const row = await appDb
|
|
@@ -3686,6 +3522,38 @@ const getEasSchemaUidForModel = async (modelName) => {
|
|
|
3686
3522
|
return uid;
|
|
3687
3523
|
}
|
|
3688
3524
|
}
|
|
3525
|
+
const modeType = modelName.toLowerCase();
|
|
3526
|
+
let easSchemaUid;
|
|
3527
|
+
try {
|
|
3528
|
+
// Misses are cached too (most local models have no EAS schema).
|
|
3529
|
+
easSchemaUid = await cachedSchemaLookup(`model:${modeType}`, async () => {
|
|
3530
|
+
const queryClient = BaseQueryClient.getQueryClient();
|
|
3531
|
+
const easClient = BaseEasClient.getEasClient();
|
|
3532
|
+
const modelSchemaQuery = await queryClient.fetchQuery({
|
|
3533
|
+
queryKey: [`getEasSchemaUidForModel`, modeType],
|
|
3534
|
+
queryFn: async () => easClient.request(GET_SCHEMAS, {
|
|
3535
|
+
where: {
|
|
3536
|
+
schemaNames: {
|
|
3537
|
+
some: {
|
|
3538
|
+
name: {
|
|
3539
|
+
equals: modeType,
|
|
3540
|
+
},
|
|
3541
|
+
},
|
|
3542
|
+
},
|
|
3543
|
+
},
|
|
3544
|
+
}),
|
|
3545
|
+
});
|
|
3546
|
+
return modelSchemaQuery.schemas[0]?.id;
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3549
|
+
catch (error) {
|
|
3550
|
+
logger$1(`EAS schema lookup for model ${modelName} failed (offline?): ${error}`);
|
|
3551
|
+
return undefined;
|
|
3552
|
+
}
|
|
3553
|
+
if (easSchemaUid) {
|
|
3554
|
+
setSchemaUidForModel({ modelName, schemaUid: easSchemaUid });
|
|
3555
|
+
return easSchemaUid;
|
|
3556
|
+
}
|
|
3689
3557
|
return undefined;
|
|
3690
3558
|
};
|
|
3691
3559
|
|
|
@@ -3740,7 +3608,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
3740
3608
|
metadataValues.publisher = publisher;
|
|
3741
3609
|
}
|
|
3742
3610
|
if (!metadataValues.modelType && metadataValues.modelName) {
|
|
3743
|
-
metadataValues.modelType =
|
|
3611
|
+
metadataValues.modelType = easName(metadataValues.modelName);
|
|
3744
3612
|
}
|
|
3745
3613
|
// List of Relation rows live under the storage name (authors → authorIdentityIds), never the schema key.
|
|
3746
3614
|
if (metadataValues.propertyName) {
|
|
@@ -3775,7 +3643,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
3775
3643
|
propertyRecordSchema?.validation &&
|
|
3776
3644
|
metadataValues.propertyValue != null &&
|
|
3777
3645
|
metadataValues.propertyValue !== '') {
|
|
3778
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
3646
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-BNYMacsx.js');
|
|
3779
3647
|
const validationService = new SchemaValidationService();
|
|
3780
3648
|
const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
|
|
3781
3649
|
? normalizeDataType(String(propertyRecordSchema.refValueType))
|
|
@@ -3797,7 +3665,8 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
3797
3665
|
const dataTypeKey = normalizeDataType(propertyRecordSchema.dataType);
|
|
3798
3666
|
const easDataType = INTERNAL_DATA_TYPES[dataTypeKey]?.eas;
|
|
3799
3667
|
if (easDataType) {
|
|
3800
|
-
|
|
3668
|
+
// The name publish registers (ADR 0008): a single relation's key, not its authorId storage name.
|
|
3669
|
+
const propertyNameSnakeCase = easPropertyNameForPublish(metadataValues.propertyName, propertyRecordSchema);
|
|
3801
3670
|
// Cached, including misses: every item of a model looks up the same property schemas.
|
|
3802
3671
|
const schemaUid = await getEasSchemaUidForExactDefinition(`${easDataType} ${propertyNameSnakeCase}`);
|
|
3803
3672
|
if (schemaUid) {
|
|
@@ -4387,7 +4256,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
4387
4256
|
}
|
|
4388
4257
|
const _saveRelation = async () => {
|
|
4389
4258
|
// Use dynamic import to break circular dependency
|
|
4390
|
-
const schemaMod = await import('./index-
|
|
4259
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
4391
4260
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
4392
4261
|
if (!propertyNameRaw) {
|
|
4393
4262
|
throw new Error('propertyName is required');
|
|
@@ -5106,11 +4975,11 @@ const getPropertyData = async ({ propertyName, seedLocalId, seedUid, modelName,
|
|
|
5106
4975
|
let names = [...getMetadataPropertyNamesForQuery(propertyName)];
|
|
5107
4976
|
if (modelName) {
|
|
5108
4977
|
try {
|
|
5109
|
-
const _mod_11 = await import('./errors-
|
|
4978
|
+
const _mod_11 = await import('./errors-DdWbxb_n.js');
|
|
5110
4979
|
const _ns_11 = _mod_11.h;
|
|
5111
4980
|
const { Model } = _ns_11;
|
|
5112
|
-
const _mod_12 = await import('./BasePathResolver-
|
|
5113
|
-
const _ns_12 = _mod_12.
|
|
4981
|
+
const _mod_12 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
4982
|
+
const _ns_12 = _mod_12.ba;
|
|
5114
4983
|
const { resolveItemModelFileId } = _ns_12;
|
|
5115
4984
|
// Model names are only unique per schema: use the seed's own model when it is recorded.
|
|
5116
4985
|
const modelFileId = await resolveItemModelFileId({ seedLocalId, seedUid });
|
|
@@ -5310,8 +5179,8 @@ const HTML_PROP_SEED_UID_RE = /^0x[a-fA-F0-9]{64}$/;
|
|
|
5310
5179
|
*/
|
|
5311
5180
|
const resolvePropertyRecordSchemaFromSchemaData = async (modelName, propertyName, modelType, schemaName) => {
|
|
5312
5181
|
try {
|
|
5313
|
-
const _mod_13 = await import('./ClientManager-
|
|
5314
|
-
const _ns_13 = _mod_13.
|
|
5182
|
+
const _mod_13 = await import('./ClientManager-Dfu4jcgm.js');
|
|
5183
|
+
const _ns_13 = _mod_13.L;
|
|
5315
5184
|
const { loadAllSchemasFromDb } = _ns_13;
|
|
5316
5185
|
const allSchemas = await loadAllSchemasFromDb();
|
|
5317
5186
|
const modelNameAlt = modelType ? upperFirst(camelCase(modelType)) : '';
|
|
@@ -5364,12 +5233,12 @@ hints = {}) => {
|
|
|
5364
5233
|
return undefined;
|
|
5365
5234
|
}
|
|
5366
5235
|
try {
|
|
5367
|
-
const _mod_14 = await import('./errors-
|
|
5236
|
+
const _mod_14 = await import('./errors-DdWbxb_n.js');
|
|
5368
5237
|
const _ns_14 = _mod_14.h;
|
|
5369
5238
|
const { Model } = _ns_14;
|
|
5370
5239
|
const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
|
|
5371
|
-
const _mod_15 = await import('./BasePathResolver-
|
|
5372
|
-
const _ns_15 = _mod_15.
|
|
5240
|
+
const _mod_15 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
5241
|
+
const _ns_15 = _mod_15.ba;
|
|
5373
5242
|
const { resolveItemModelFileId } = _ns_15;
|
|
5374
5243
|
const modelFileId = await resolveItemModelFileId(hints);
|
|
5375
5244
|
let model = modelFileId
|
|
@@ -5528,7 +5397,7 @@ class ItemProperty {
|
|
|
5528
5397
|
return;
|
|
5529
5398
|
}
|
|
5530
5399
|
// Use dynamic import to break circular dependency
|
|
5531
|
-
const schemaMod = await import('./index-
|
|
5400
|
+
const schemaMod = await import('./index-C61Rxy0F.js');
|
|
5532
5401
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
5533
5402
|
const { context } = snapshot;
|
|
5534
5403
|
const { propertyRecordSchema } = context;
|
|
@@ -5699,7 +5568,7 @@ class ItemProperty {
|
|
|
5699
5568
|
const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
|
|
5700
5569
|
const propertyNames = getMetadataPropertyNamesForQuery(propertyName, normalizedDataType, normalizedRefValueType);
|
|
5701
5570
|
const propertyNameVariant = propertyNames.length > 1 ? propertyNames[1] : undefined;
|
|
5702
|
-
const _mod_16 = await import('./index-
|
|
5571
|
+
const _mod_16 = await import('./index-7y2f_iQz.js');
|
|
5703
5572
|
const _ns_16 = _mod_16.s;
|
|
5704
5573
|
const seedSchemaMod = _ns_16;
|
|
5705
5574
|
const { metadata } = seedSchemaMod;
|
|
@@ -5923,8 +5792,8 @@ class ItemProperty {
|
|
|
5923
5792
|
const ctx = this._service.getSnapshot().context;
|
|
5924
5793
|
let modelFileId;
|
|
5925
5794
|
try {
|
|
5926
|
-
const _mod_17 = await import('./BasePathResolver-
|
|
5927
|
-
const _ns_17 = _mod_17.
|
|
5795
|
+
const _mod_17 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
5796
|
+
const _ns_17 = _mod_17.ba;
|
|
5928
5797
|
const { resolveItemModelFileId } = _ns_17;
|
|
5929
5798
|
modelFileId = await resolveItemModelFileId({
|
|
5930
5799
|
modelFileId: ctx.modelFileId,
|
|
@@ -6286,8 +6155,8 @@ class ItemProperty {
|
|
|
6286
6155
|
const propertiesData = await getItemProperties({ seedLocalId, seedUid });
|
|
6287
6156
|
const instances = [];
|
|
6288
6157
|
const seenNormalized = new Set();
|
|
6289
|
-
const _mod_18 = await import('./BasePathResolver-
|
|
6290
|
-
const _ns_18 = _mod_18.
|
|
6158
|
+
const _mod_18 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
6159
|
+
const _ns_18 = _mod_18.ba;
|
|
6291
6160
|
const { resolveItemModelFileId } = _ns_18;
|
|
6292
6161
|
const itemModelFileId = await resolveItemModelFileId({ seedLocalId, seedUid });
|
|
6293
6162
|
for (const data of propertiesData) {
|
|
@@ -6304,7 +6173,7 @@ class ItemProperty {
|
|
|
6304
6173
|
}
|
|
6305
6174
|
else if (baseName) {
|
|
6306
6175
|
try {
|
|
6307
|
-
const _mod_19 = await import('./errors-
|
|
6176
|
+
const _mod_19 = await import('./errors-DdWbxb_n.js');
|
|
6308
6177
|
const _ns_19 = _mod_19.h;
|
|
6309
6178
|
const { Model } = _ns_19;
|
|
6310
6179
|
const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
|
|
@@ -6321,7 +6190,7 @@ class ItemProperty {
|
|
|
6321
6190
|
}
|
|
6322
6191
|
if (modelName && propertyName) {
|
|
6323
6192
|
try {
|
|
6324
|
-
const _mod_20 = await import('./errors-
|
|
6193
|
+
const _mod_20 = await import('./errors-DdWbxb_n.js');
|
|
6325
6194
|
const _ns_20 = _mod_20.h;
|
|
6326
6195
|
const { Model } = _ns_20;
|
|
6327
6196
|
const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
|
|
@@ -6653,7 +6522,7 @@ class ItemProperty {
|
|
|
6653
6522
|
if (!propertyName || (!seedLocalId && !seedUid))
|
|
6654
6523
|
return;
|
|
6655
6524
|
if (db) {
|
|
6656
|
-
const _mod_21 = await import('./index-
|
|
6525
|
+
const _mod_21 = await import('./index-7y2f_iQz.js');
|
|
6657
6526
|
const _ns_21 = _mod_21.s;
|
|
6658
6527
|
const seedSchemaMod = _ns_21;
|
|
6659
6528
|
const { metadata } = seedSchemaMod;
|
|
@@ -6696,9 +6565,9 @@ const createNewItem = async ({ modelName, modelFileId, ...propertyData }) => {
|
|
|
6696
6565
|
if (!modelName) {
|
|
6697
6566
|
throw new Error('A model name is required for createNewItem');
|
|
6698
6567
|
}
|
|
6699
|
-
const seedType =
|
|
6568
|
+
const seedType = easName(modelName);
|
|
6700
6569
|
// Dynamic import to break circular dependency
|
|
6701
|
-
const _mod_22 = await import('./errors-
|
|
6570
|
+
const _mod_22 = await import('./errors-DdWbxb_n.js');
|
|
6702
6571
|
const _ns_22 = _mod_22.h;
|
|
6703
6572
|
const modelMod = _ns_22;
|
|
6704
6573
|
const { Model } = modelMod;
|
|
@@ -6706,7 +6575,7 @@ const createNewItem = async ({ modelName, modelFileId, ...propertyData }) => {
|
|
|
6706
6575
|
const propertySchemas = model?.properties ? modelPropertiesToObject(model.properties) : undefined;
|
|
6707
6576
|
modelFileId ?? (modelFileId = model?.id);
|
|
6708
6577
|
const newSeedId = await createSeed({ type: seedType, modelFileId });
|
|
6709
|
-
const newVersionId = await createVersion({ seedLocalId: newSeedId, seedType:
|
|
6578
|
+
const newVersionId = await createVersion({ seedLocalId: newSeedId, seedType: easName(modelName) });
|
|
6710
6579
|
// Build set of all properties to create metadata for: union of model schema + propertyData
|
|
6711
6580
|
// This ensures we create metadata for ALL model properties even when creating with no initial values
|
|
6712
6581
|
// (fixes first-item persistence: loadOrCreateItem needs metadata rows to run createItemPropertyInstances)
|
|
@@ -6881,7 +6750,7 @@ const getModel = () => {
|
|
|
6881
6750
|
// the fragile `import(...).then(n => n.X)` chunk-namespace pattern.
|
|
6882
6751
|
if (!modelImportPromise) {
|
|
6883
6752
|
modelImportPromise = (async () => {
|
|
6884
|
-
const _mod_23 = await import('./errors-
|
|
6753
|
+
const _mod_23 = await import('./errors-DdWbxb_n.js');
|
|
6885
6754
|
const _ns_23 = _mod_23.h;
|
|
6886
6755
|
const mod = _ns_23;
|
|
6887
6756
|
ModelClass = mod.Model;
|
|
@@ -7049,12 +6918,12 @@ class Item {
|
|
|
7049
6918
|
};
|
|
7050
6919
|
this.getPublishUploads = async (options) => {
|
|
7051
6920
|
// Use dynamic import to break circular dependency
|
|
7052
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
6921
|
+
const getPublishUploadsMod = await import('./getPublishUploads-J-143iSV.js');
|
|
7053
6922
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
7054
6923
|
return await getPublishUploads(this, [], undefined, options);
|
|
7055
6924
|
};
|
|
7056
6925
|
this.getPublishPayload = async (uploadedTransactions, options) => {
|
|
7057
|
-
const _mod_24 = await import('./getPublishPayload-
|
|
6926
|
+
const _mod_24 = await import('./getPublishPayload-DPy-uMrR.js');
|
|
7058
6927
|
const _ns_24 = _mod_24.g;
|
|
7059
6928
|
const getPublishPayloadMod = _ns_24;
|
|
7060
6929
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
@@ -7590,8 +7459,8 @@ class Item {
|
|
|
7590
7459
|
const db = BaseDb.getAppDb();
|
|
7591
7460
|
if (db && props.modelName) {
|
|
7592
7461
|
// Model names are only unique per schema: resolve the exact models row from the most specific scope.
|
|
7593
|
-
const _mod_25 = await import('./BasePathResolver-
|
|
7594
|
-
const _ns_25 = _mod_25.
|
|
7462
|
+
const _mod_25 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
7463
|
+
const _ns_25 = _mod_25.ba;
|
|
7595
7464
|
const { resolveModelRecord } = _ns_25;
|
|
7596
7465
|
const modelRecord = await resolveModelRecord(props.modelName, {
|
|
7597
7466
|
modelFileId: props.modelFileId ?? modelInstance?.id,
|
|
@@ -7599,7 +7468,7 @@ class Item {
|
|
|
7599
7468
|
});
|
|
7600
7469
|
const modelRecords = modelRecord ? [modelRecord] : [];
|
|
7601
7470
|
if (!modelRecord) {
|
|
7602
|
-
const _mod_26 = await import('./errors-
|
|
7471
|
+
const _mod_26 = await import('./errors-DdWbxb_n.js');
|
|
7603
7472
|
const _ns_26 = _mod_26.j;
|
|
7604
7473
|
const { UnknownModelError } = _ns_26;
|
|
7605
7474
|
throw new UnknownModelError(props.modelName, schemaName ?? modelInstance?.schemaName);
|
|
@@ -7610,11 +7479,11 @@ class Item {
|
|
|
7610
7479
|
// Scope the constructor's Model lookup to this model's schema (as getItemData does on reload),
|
|
7611
7480
|
// so a same-named model cached from another schema can't supply the property set.
|
|
7612
7481
|
if (modelRecord && !props.schemaName) {
|
|
7613
|
-
const _mod_27 = await import('./BasePathResolver-
|
|
7614
|
-
const _ns_27 = _mod_27.
|
|
7482
|
+
const _mod_27 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
7483
|
+
const _ns_27 = _mod_27.b9;
|
|
7615
7484
|
const { modelSchemas } = _ns_27;
|
|
7616
|
-
const _mod_28 = await import('./BasePathResolver-
|
|
7617
|
-
const _ns_28 = _mod_28.
|
|
7485
|
+
const _mod_28 = await import('./BasePathResolver-DrzGVH9L.js');
|
|
7486
|
+
const _ns_28 = _mod_28.b8;
|
|
7618
7487
|
const { schemas: schemasTable } = _ns_28;
|
|
7619
7488
|
const schemaRows = await db
|
|
7620
7489
|
.select({ schemaName: schemasTable.name })
|
|
@@ -7972,7 +7841,7 @@ class Item {
|
|
|
7972
7841
|
if (!appDb || Item.instanceCache.size === 0) {
|
|
7973
7842
|
return;
|
|
7974
7843
|
}
|
|
7975
|
-
const _mod_29 = await import('./index-
|
|
7844
|
+
const _mod_29 = await import('./index-7y2f_iQz.js');
|
|
7976
7845
|
const _ns_29 = _mod_29.s;
|
|
7977
7846
|
const { metadata } = _ns_29;
|
|
7978
7847
|
const { eq, and } = await import('drizzle-orm');
|
|
@@ -8135,11 +8004,11 @@ class Item {
|
|
|
8135
8004
|
}
|
|
8136
8005
|
/** Throws ItemCreateValidationError for unknown keys and values that break their property's rules. */
|
|
8137
8006
|
static async assertValidCreateValues(props, propertyNames, dataTypeByPropertyName, skipKeys) {
|
|
8138
|
-
const _mod_30 = await import('./errors-
|
|
8007
|
+
const _mod_30 = await import('./errors-DdWbxb_n.js');
|
|
8139
8008
|
const _ns_30 = _mod_30.j;
|
|
8140
8009
|
const { ItemCreateValidationError } = _ns_30;
|
|
8141
|
-
const { getPropertySchema } = await import('./property-
|
|
8142
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
8010
|
+
const { getPropertySchema } = await import('./property-zFPMtR3T.js');
|
|
8011
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-BNYMacsx.js');
|
|
8143
8012
|
const validationService = new SchemaValidationService();
|
|
8144
8013
|
const modelName = props.modelName;
|
|
8145
8014
|
const known = new Set(propertyNames);
|
|
@@ -8176,7 +8045,7 @@ class Item {
|
|
|
8176
8045
|
// Not JSON: validated as given, and rejected as a non-array
|
|
8177
8046
|
}
|
|
8178
8047
|
}
|
|
8179
|
-
const { resolvePropertyValidationRules } = await import('./propertyValidationRules-
|
|
8048
|
+
const { resolvePropertyValidationRules } = await import('./propertyValidationRules-CeFVhdQg.js');
|
|
8180
8049
|
const rules = propertySchema?.validation ??
|
|
8181
8050
|
(await resolvePropertyValidationRules(modelName, key, {
|
|
8182
8051
|
modelFileId: props.modelFileId,
|
|
@@ -8507,7 +8376,7 @@ class Item {
|
|
|
8507
8376
|
itemActor.send(event);
|
|
8508
8377
|
};
|
|
8509
8378
|
try {
|
|
8510
|
-
const _mod_31 = await import('./index-
|
|
8379
|
+
const _mod_31 = await import('./index-7y2f_iQz.js');
|
|
8511
8380
|
const _ns_31 = _mod_31.s;
|
|
8512
8381
|
const seedSchemaMod = _ns_31;
|
|
8513
8382
|
const { seeds, versions, metadata } = seedSchemaMod;
|
|
@@ -8871,5 +8740,5 @@ var Item$1 = /*#__PURE__*/Object.freeze({
|
|
|
8871
8740
|
Item: Item
|
|
8872
8741
|
});
|
|
8873
8742
|
|
|
8874
|
-
export {
|
|
8875
|
-
//# sourceMappingURL=Item-
|
|
8743
|
+
export { unloadEntity as $, getPublishExecutor as A, getRevokeExecutor as B, ClientManagerState as C, DEFAULT_READY_TIMEOUT_MS as D, getUploadExecutor as E, getVersionData$1 as F, isLocalUnsealedDraft as G, isSeedRowOwned as H, Item as I, localUnsealedDraftSql as J, ownedPublisherSql as K, ownedSeedsSql as L, METADATA_LATEST_FIRST_ORDER_SQL as M, pickLatestMetadataRowPerProperty as N, OwnershipError as O, PUBLISH_NOT_CONFIGURED_MESSAGE as P, placeholderUidSql as Q, propertyMachine as R, publisherInAddressListSql as S, publisherIsInOwnedSet as T, setAdditionalSyncAddresses as U, setGetPublisherForNewSeeds as V, setPublishExecutor as W, setRevokeExecutor as X, setUploadExecutor as Y, getInvariantSafePropertyDescriptor as Z, clearDestroySubscriptions as _, chunkValues as a, ClientManagerEvents as a0, withLockedItemStorageRow as a1, getItemStorageFilePath as a2, writeItemStorageFile as a3, resolvePublisherFromSeedRow as a4, getPropertyData$1 as a5, Item$1 as a6, getGetAdditionalSyncAddresses as b, compareMetadataRowsLatestFirst as c, ItemProperty as d, ItemPropertySaveValidationError as e, assertItemOwned as f, getItemData as g, getEasSchemaUidForModel as h, isItemOwned as i, getLatestPublishedVersionRow as j, isVersionRevoked as k, waitForEntityIdle as l, createReactiveProxy as m, findEntity as n, forceRemoveFromCaches as o, parseListPropertyValueFromStorage as p, runDestroyLifecycle as q, rowsPerInsert as r, selectInBatches as s, isPublishedMetadataRow as t, MachineIds as u, createNewItem as v, writeInBatches as w, getEasSchemaForItemProperty as x, getGetPublisherForNewSeeds as y, getMetadataLatest as z };
|
|
8744
|
+
//# sourceMappingURL=Item-BUUFuywT.js.map
|