@seedprotocol/sdk 0.7.4 → 0.7.5-next.871.g8788c94
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/README.md +99 -0
- package/dist/{BasePathResolver-DrzGVH9L.js → BasePathResolver-B-fK7_N_.js} +142 -8
- package/dist/BasePathResolver-B-fK7_N_.js.map +1 -0
- package/dist/{ClientManager-Dfu4jcgm.js → ClientManager-C7VkO5Hg.js} +342 -206
- package/dist/ClientManager-C7VkO5Hg.js.map +1 -0
- package/dist/{Item-BUUFuywT.js → Item-BDmsdNTQ.js} +234 -163
- package/dist/Item-BDmsdNTQ.js.map +1 -0
- package/dist/{ModelProperty-B6cnRvIz.js → ModelProperty-Cqw6yn7y.js} +37 -37
- package/dist/{ModelProperty-B6cnRvIz.js.map → ModelProperty-Cqw6yn7y.js.map} +1 -1
- package/dist/{Schema-Bf-jOLq0.js → Schema-BJLYOUgp.js} +57 -37
- package/dist/Schema-BJLYOUgp.js.map +1 -0
- package/dist/{SchemaValidationService-BNYMacsx.js → SchemaValidationService-CzybXLiS.js} +6 -6
- package/dist/{SchemaValidationService-BNYMacsx.js.map → SchemaValidationService-CzybXLiS.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-C2-s_jUa.js → backfillMetadataPropertyIds-DAsETfD_.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-C2-s_jUa.js.map → backfillMetadataPropertyIds-DAsETfD_.js.map} +1 -1
- package/dist/{configurePlatform-BzfirKuM.js → configurePlatform-CFQF_i1T.js} +2 -2
- package/dist/{configurePlatform-BzfirKuM.js.map → configurePlatform-CFQF_i1T.js.map} +1 -1
- package/dist/{detachRowsBeforeDelete-B0Daoz9Z.js → detachRowsBeforeDelete-D4gxxk46.js} +2 -2
- package/dist/{detachRowsBeforeDelete-B0Daoz9Z.js.map → detachRowsBeforeDelete-D4gxxk46.js.map} +1 -1
- package/dist/discardNewDraft-g8w3uHFM.js +78 -0
- package/dist/discardNewDraft-g8w3uHFM.js.map +1 -0
- package/dist/{eas-Dq5Kx_Nd.js → eas-BcXZ2hIn.js} +25 -12
- package/dist/eas-BcXZ2hIn.js.map +1 -0
- package/dist/{errors-DdWbxb_n.js → errors-CCMxedOB.js} +43 -38
- package/dist/errors-CCMxedOB.js.map +1 -0
- package/dist/{getItem-9bYSErSj.js → getItem-BUs1Xa48.js} +4 -4
- package/dist/{getItem-9bYSErSj.js.map → getItem-BUs1Xa48.js.map} +1 -1
- package/dist/{getPublishPayload-DPy-uMrR.js → getPublishPayload-CwNOhnir.js} +25 -15
- package/dist/getPublishPayload-CwNOhnir.js.map +1 -0
- package/dist/{getPublishUploads-J-143iSV.js → getPublishUploads-pEOrXJbF.js} +506 -45
- package/dist/getPublishUploads-pEOrXJbF.js.map +1 -0
- package/dist/{index-7y2f_iQz.js → index-BQSK-r_A.js} +2 -2
- package/dist/index-BQSK-r_A.js.map +1 -0
- package/dist/{index-C61Rxy0F.js → index-zAs84LDi.js} +8 -8
- package/dist/index-zAs84LDi.js.map +1 -0
- package/dist/{index.browser-C1pisOEa.js → index.browser-irwaBIj0.js} +11 -11
- package/dist/{index.browser-C1pisOEa.js.map → index.browser-irwaBIj0.js.map} +1 -1
- package/dist/{index.node-BAlST8pD.js → index.node-BYkndQN7.js} +6 -6
- package/dist/{index.node-BAlST8pD.js.map → index.node-BYkndQN7.js.map} +1 -1
- package/dist/main.js +91 -504
- package/dist/main.js.map +1 -1
- package/dist/{mimeTypes-DHAHC4eZ.js → mimeTypes-C9r76DCH.js} +7 -2
- package/dist/{mimeTypes-DHAHC4eZ.js.map → mimeTypes-C9r76DCH.js.map} +1 -1
- package/dist/node.js +10 -10
- package/dist/platform.browser.js +6 -6
- package/dist/platform.node.js +4 -4
- package/dist/{property-zFPMtR3T.js → property-5AD2naVS.js} +7 -7
- package/dist/{property-zFPMtR3T.js.map → property-5AD2naVS.js.map} +1 -1
- package/dist/{propertyValidationRules-CeFVhdQg.js → propertyValidationRules-Bdgz0Nrr.js} +10 -10
- package/dist/{propertyValidationRules-CeFVhdQg.js.map → propertyValidationRules-Bdgz0Nrr.js.map} +1 -1
- package/dist/{publishDraftGraph-CuVq6iAR.js → publishDraftGraph-DGhC9ifI.js} +6 -6
- package/dist/{publishDraftGraph-CuVq6iAR.js.map → publishDraftGraph-DGhC9ifI.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-DsFTnMBz.js → resetAmbiguousLegacyItemData-HSB77N9c.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-DsFTnMBz.js.map → resetAmbiguousLegacyItemData-HSB77N9c.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-RUsgAZXG.js → resolveModelForSyncedSeed-CAKAJgr6.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-RUsgAZXG.js.map → resolveModelForSyncedSeed-CAKAJgr6.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +4 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/errors.d.ts +3 -1
- package/dist/src/Item/errors.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +2 -1
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/service/schemaMachine.d.ts +3 -0
- package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/db/alignRowPublishers.d.ts +25 -0
- package/dist/src/db/alignRowPublishers.d.ts.map +1 -0
- package/dist/src/db/canonicalizeModelTypes.d.ts +2 -2
- package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -1
- package/dist/src/db/read/getModelSchemas.d.ts +3 -2
- 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/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
- package/dist/src/db/read/getSeedPublisher.d.ts +7 -0
- package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -0
- package/dist/src/db/read/nameMatchLevels.d.ts +64 -0
- package/dist/src/db/read/nameMatchLevels.d.ts.map +1 -0
- package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
- package/dist/src/db/read/summarizePublishWork.d.ts +2 -0
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts +5 -3
- package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -1
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts +4 -2
- package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/db/write/createNewItem.d.ts.map +1 -1
- package/dist/src/db/write/createSeed.d.ts.map +1 -1
- package/dist/src/db/write/createVersion.d.ts.map +1 -1
- package/dist/src/db/write/discardNewDraft.d.ts +8 -0
- package/dist/src/db/write/discardNewDraft.d.ts.map +1 -0
- package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts +18 -0
- package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts.map +1 -0
- package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/easValueTypes.d.ts +16 -0
- package/dist/src/helpers/easValueTypes.d.ts.map +1 -0
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +13 -2
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
- package/dist/src/helpers/ownership.d.ts +9 -12
- package/dist/src/helpers/ownership.d.ts.map +1 -1
- package/dist/src/helpers/publishConfig.d.ts +9 -4
- package/dist/src/helpers/publishConfig.d.ts.map +1 -1
- package/dist/src/imports/index.d.ts +1 -1
- package/dist/src/imports/index.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types/import.d.ts +20 -0
- package/dist/src/types/import.d.ts.map +1 -1
- package/dist/{syncDbWithEas-CRpnkq00.js → syncDbWithEas-BmJXqfgN.js} +92 -22
- package/dist/syncDbWithEas-BmJXqfgN.js.map +1 -0
- package/dist/{tabEvents-nBUq_1u1.js → tabEvents-DXun7vdK.js} +4 -4
- package/dist/{tabEvents-nBUq_1u1.js.map → tabEvents-DXun7vdK.js.map} +1 -1
- package/dist/{tolerantWebAccess-DIt3R8_u.js → tolerantWebAccess-DXxgX2x7.js} +7 -7
- package/dist/{tolerantWebAccess-DIt3R8_u.js.map → tolerantWebAccess-DXxgX2x7.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-DtTPSzpM.js → updateSeedRevokedAt-DkLSDwUX.js} +3 -3
- package/dist/{updateSeedRevokedAt-DtTPSzpM.js.map → updateSeedRevokedAt-DkLSDwUX.js.map} +1 -1
- package/package.json +9 -5
- package/dist/BasePathResolver-DrzGVH9L.js.map +0 -1
- package/dist/ClientManager-Dfu4jcgm.js.map +0 -1
- package/dist/Item-BUUFuywT.js.map +0 -1
- package/dist/Schema-Bf-jOLq0.js.map +0 -1
- package/dist/eas-Dq5Kx_Nd.js.map +0 -1
- package/dist/errors-DdWbxb_n.js.map +0 -1
- package/dist/getPublishPayload-DPy-uMrR.js.map +0 -1
- package/dist/getPublishUploads-J-143iSV.js.map +0 -1
- package/dist/index-7y2f_iQz.js.map +0 -1
- package/dist/index-C61Rxy0F.js.map +0 -1
- package/dist/syncDbWithEas-CRpnkq00.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as resolveModelForSyncedSeed, s as skipSeedOnAmbiguousModel } from './resolveModelForSyncedSeed-
|
|
1
|
+
import { n as normalizeDataType, ac as INTERNAL_DATA_TYPES, B as BaseDb, s as modelUids, t as models, J as nameMatchLevels, ah as normalizePublisher, C as seeds, ai as getAllAddressesFromDb, aj as loadNameMatchLevels, ak as scheduleBulkFilesDownloadFromEasSync, ag as EAS_SEED_DATA_SYNCED_TO_DB_EVENT, al as generateId, am as normalizeHexAddress, F as versions, m as metadata, L as getPropertyIdForModelAndName, N as resolveItemModelFileId, ad as listRelationEasPropertyName, ae as easPropertyNameForPublish, an as toMetadataPropertyName, ao as getItemStoragePropertiesForModel } from './BasePathResolver-B-fK7_N_.js';
|
|
2
|
+
import { r as resolveModelForSyncedSeed, s as skipSeedOnAmbiguousModel } from './resolveModelForSyncedSeed-CAKAJgr6.js';
|
|
3
3
|
import { camelCase } from 'lodash-es';
|
|
4
|
-
import { easName, matchEasName, getSeedsFromSchemaUids, getItemVersionsFromEas, partitionByRefAttester, getItemPropertiesFromEas, BaseEasClient, GET_SEEDS, pickLatestPropertyAttestationsByRefAndSchema, setSchemaUidForSchemaDefinition } from '@seedprotocol/eas';
|
|
4
|
+
import { decodeEasNumber, isNumericEasType, easName, matchEasName, getSeedsFromSchemaUids, getItemVersionsFromEas, partitionByRefAttester, getItemPropertiesFromEas, BaseEasClient, GET_SEEDS, pickLatestPropertyAttestationsByRefAndSchema, setSchemaUidForSchemaDefinition, isNameMatchLevel } from '@seedprotocol/eas';
|
|
5
5
|
import pluralize from 'pluralize';
|
|
6
6
|
import { eq, inArray, and, or, isNull, ne, isNotNull } from 'drizzle-orm';
|
|
7
7
|
import { modelPropertiesToObject } from './model-oHA3YhOd.js';
|
|
8
8
|
import { parseEasPropertyMetadata, parseEasRelationPropertyName } from '@seedprotocol/query';
|
|
9
|
-
import {
|
|
10
|
-
import { u as updateSeedRevokedAt } from './updateSeedRevokedAt-
|
|
11
|
-
import { getModelSchemasFromEas } from './eas-
|
|
12
|
-
import { w as waitForEasReadChain,
|
|
13
|
-
import { e as emitAcrossTabs } from './tabEvents-
|
|
9
|
+
import { k as chunkValues, r as rowsPerInsert, l as getGetAdditionalSyncAddresses, s as selectInBatches, w as writeInBatches } from './Item-BDmsdNTQ.js';
|
|
10
|
+
import { u as updateSeedRevokedAt } from './updateSeedRevokedAt-DkLSDwUX.js';
|
|
11
|
+
import { getModelSchemasFromEas } from './eas-BcXZ2hIn.js';
|
|
12
|
+
import { w as waitForEasReadChain, d as assertLocalDbChain } from './ClientManager-C7VkO5Hg.js';
|
|
13
|
+
import { e as emitAcrossTabs } from './tabEvents-DXun7vdK.js';
|
|
14
14
|
import 'debug';
|
|
15
15
|
import '@seedprotocol/arweave';
|
|
16
16
|
import 'xstate';
|
|
@@ -23,12 +23,51 @@ import '@noble/hashes/sha3';
|
|
|
23
23
|
import '@noble/hashes/utils';
|
|
24
24
|
import 'rxjs';
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Whether an attestation's EAS type fits a local property (ADR 0008 "property types must agree",
|
|
28
|
+
* ADR 0010). The type publish writes for the property always fits. A Number also takes every
|
|
29
|
+
* integer type (older SDKs published `uint8`, other SDKs may use `uint256` or `int256`) and a
|
|
30
|
+
* `string` whose value is numeric, which is what keeps a Text value out of a Number property that
|
|
31
|
+
* shares its EAS schema. An attestation with no type, or a property with no known type, fits.
|
|
32
|
+
*/
|
|
33
|
+
function easTypeFitsProperty(dataType, easType, value) {
|
|
34
|
+
if (!easType)
|
|
35
|
+
return true;
|
|
36
|
+
const local = normalizeDataType(dataType);
|
|
37
|
+
if (local === 'Number') {
|
|
38
|
+
return isNumericEasType(easType) || (easType === 'string' && decodeEasNumber(value) !== undefined);
|
|
39
|
+
}
|
|
40
|
+
const expected = INTERNAL_DATA_TYPES[local]?.eas;
|
|
41
|
+
return !expected || expected === easType;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The value to store for a synced attestation, given the local property's type: a Number as its
|
|
45
|
+
* decimal string, a Date published as Unix seconds as an ISO string, and any other integer value
|
|
46
|
+
* as its decimal string instead of the indexer's `{ type: 'BigNumber', hex }`. Undefined: a
|
|
47
|
+
* Number or Date value that doesn't decode.
|
|
48
|
+
*/
|
|
49
|
+
function syncedPropertyValue(dataType, easType, value) {
|
|
50
|
+
const local = dataType ? normalizeDataType(dataType) : undefined;
|
|
51
|
+
if (local === 'Number')
|
|
52
|
+
return decodeEasNumber(value);
|
|
53
|
+
if (local === 'Date' && isNumericEasType(easType)) {
|
|
54
|
+
const seconds = decodeEasNumber(value);
|
|
55
|
+
if (seconds === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
const date = new Date(Number(seconds) * 1000);
|
|
58
|
+
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
|
|
59
|
+
}
|
|
60
|
+
if (isNumericEasType(easType) && typeof value !== 'string')
|
|
61
|
+
return decodeEasNumber(value) ?? value;
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
|
|
26
65
|
// Dynamic import to break circular dependency: Model -> BaseItem -> ... -> getModelSchemas -> Model
|
|
27
66
|
// import { Model } from '@/Model/Model'
|
|
28
67
|
const schemaStringToModelRecord = new Map();
|
|
29
68
|
const getModelSchemas = async () => {
|
|
30
69
|
// Dynamic import to break circular dependency
|
|
31
|
-
const _mod_0 = await import('./errors-
|
|
70
|
+
const _mod_0 = await import('./errors-CCMxedOB.js');
|
|
32
71
|
const _ns_0 = _mod_0.h;
|
|
33
72
|
const modelMod = _ns_0;
|
|
34
73
|
const { Model } = modelMod;
|
|
@@ -73,7 +112,13 @@ const getModelSchemas = async () => {
|
|
|
73
112
|
if (record.name !== 'Seed')
|
|
74
113
|
byName.set(record.name, record);
|
|
75
114
|
}
|
|
76
|
-
|
|
115
|
+
// ADR 0009: each model's name matches at its own nameMatch level.
|
|
116
|
+
const levels = await nameMatchLevels(appDb);
|
|
117
|
+
const candidates = [...byName.values()].map((record) => ({
|
|
118
|
+
value: record,
|
|
119
|
+
name: record.name,
|
|
120
|
+
level: levels.model(record.name),
|
|
121
|
+
}));
|
|
77
122
|
const matchModelRecord = (schemaString) => {
|
|
78
123
|
if (!schemaString.startsWith('bytes32 '))
|
|
79
124
|
return undefined;
|
|
@@ -157,7 +202,7 @@ const RELATION_DATA_TYPES = new Set(['Relation', 'Image', 'File', 'Html']);
|
|
|
157
202
|
* relations), so related seeds are still followed for discovery. Undefined: the name matches
|
|
158
203
|
* several local properties equally well, and the attestation is skipped.
|
|
159
204
|
*/
|
|
160
|
-
const resolveSyncedPropertyName = (easPropertyName, value, modelSchema) => {
|
|
205
|
+
const resolveSyncedPropertyName = (easPropertyName, value, modelSchema, easType) => {
|
|
161
206
|
const internal = easPropertyName === 'storage_transaction_id' || easPropertyName === 'storage_provider_transaction_id';
|
|
162
207
|
if (modelSchema && !internal) {
|
|
163
208
|
const candidates = Object.entries(modelSchema).map(([key, def]) => {
|
|
@@ -169,6 +214,8 @@ const resolveSyncedPropertyName = (easPropertyName, value, modelSchema) => {
|
|
|
169
214
|
value: { key, def, isListRelation, isSingleRef },
|
|
170
215
|
name: easPropertyNameForPublish(key, { ...def, name: key }),
|
|
171
216
|
relation: isListRelation || isSingleRef,
|
|
217
|
+
// ADR 0009: set by modelSchemaForSyncedProperty from the schema file.
|
|
218
|
+
level: isNameMatchLevel(def?.nameMatch) ? def.nameMatch : undefined,
|
|
172
219
|
};
|
|
173
220
|
});
|
|
174
221
|
const match = matchEasName(easPropertyName, candidates);
|
|
@@ -180,6 +227,11 @@ const resolveSyncedPropertyName = (easPropertyName, value, modelSchema) => {
|
|
|
180
227
|
}
|
|
181
228
|
if (match.kind === 'match') {
|
|
182
229
|
const { key, def, isListRelation, isSingleRef } = match.value;
|
|
230
|
+
// ADR 0008/0010: property types must agree. A mismatch is this property's, refused.
|
|
231
|
+
if (!easTypeFitsProperty(def?.dataType, easType, value)) {
|
|
232
|
+
console.warn(`[item/events] [syncDbWithEas] EAS property "${easPropertyName}" is ${easType}, which doesn't fit local property "${key}" (${def?.dataType}); skipping it`);
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
183
235
|
if (isListRelation) {
|
|
184
236
|
return { propertyName: key, isRelation: true, isList: true, refSeedType: def?.ref ? easName(def.ref) : undefined };
|
|
185
237
|
}
|
|
@@ -190,7 +242,12 @@ const resolveSyncedPropertyName = (easPropertyName, value, modelSchema) => {
|
|
|
190
242
|
isList: false,
|
|
191
243
|
};
|
|
192
244
|
}
|
|
193
|
-
return { propertyName: key, isRelation: false, isList: false };
|
|
245
|
+
return { propertyName: key, isRelation: false, isList: false, dataType: normalizeDataType(def?.dataType) };
|
|
246
|
+
}
|
|
247
|
+
// A name one of the model's properties would match at a looser level than its nameMatch
|
|
248
|
+
// allows is that property's, refused (ADR 0009): don't store it under a name of its own.
|
|
249
|
+
if (matchEasName(easPropertyName, candidates.map((c) => ({ ...c, level: 'fuzzy' }))).kind !== 'none') {
|
|
250
|
+
return undefined;
|
|
194
251
|
}
|
|
195
252
|
}
|
|
196
253
|
if (!isRelationPropertyName(easPropertyName)) {
|
|
@@ -215,14 +272,22 @@ const modelSchemaForSyncedProperty = async (Model, property, state) => {
|
|
|
215
272
|
return undefined;
|
|
216
273
|
const seedLocalId = state.seedUidToLocalId.get(seedUid);
|
|
217
274
|
const model = await skipSeedOnAmbiguousModel({ seedLocalId, seedUid }, 'easSync.metadata', async () => resolveSyncedSeedModel(Model, modelType, { seedLocalId, seedUid }));
|
|
218
|
-
|
|
275
|
+
if (!model?.properties)
|
|
276
|
+
return undefined;
|
|
277
|
+
// Each property's nameMatch level (ADR 0009), for resolveSyncedPropertyName.
|
|
278
|
+
const levels = await nameMatchLevels();
|
|
279
|
+
const schema = modelPropertiesToObject(model.properties);
|
|
280
|
+
for (const [key, def] of Object.entries(schema)) {
|
|
281
|
+
schema[key] = { ...def, nameMatch: levels.property(model.modelName ?? '', key, model.id) };
|
|
282
|
+
}
|
|
283
|
+
return schema;
|
|
219
284
|
};
|
|
220
285
|
/**
|
|
221
286
|
* Seed UIDs that relation properties point at. Collected from every property the run fetched, not
|
|
222
287
|
* only newly stored ones, so related seeds are refreshed (new versions, revocations) on each sync.
|
|
223
288
|
*/
|
|
224
289
|
const collectRelatedSeedUids = async (properties, state) => {
|
|
225
|
-
const _mod_1 = await import('./errors-
|
|
290
|
+
const _mod_1 = await import('./errors-CCMxedOB.js');
|
|
226
291
|
const _ns_1 = _mod_1.h;
|
|
227
292
|
const { Model } = _ns_1;
|
|
228
293
|
for (const property of properties) {
|
|
@@ -279,7 +344,7 @@ const isSqlEscapedAttestationRaw = (stored, fresh) => {
|
|
|
279
344
|
* of HTMLPage have. A name matching no local model, or several, is kept as it is.
|
|
280
345
|
*/
|
|
281
346
|
const localModelType = async (easModelName) => {
|
|
282
|
-
const _mod_2 = await import('./errors-
|
|
347
|
+
const _mod_2 = await import('./errors-CCMxedOB.js');
|
|
283
348
|
const _ns_2 = _mod_2.h;
|
|
284
349
|
const { Model } = _ns_2;
|
|
285
350
|
try {
|
|
@@ -677,7 +742,7 @@ const resolveSyncedSeedModel = async (Model, modelType, seed) => {
|
|
|
677
742
|
const insertSyncedProperties = async ({ newProperties, itemSeeds, state, }) => {
|
|
678
743
|
const { seedUidToLocalId, seedUidToModelType, versionUidToLocalId, versionUidToSeedUid } = state;
|
|
679
744
|
// Dynamic import to break circular dependency
|
|
680
|
-
const _mod_3 = await import('./errors-
|
|
745
|
+
const _mod_3 = await import('./errors-CCMxedOB.js');
|
|
681
746
|
const _ns_3 = _mod_3.h;
|
|
682
747
|
const modelMod = _ns_3;
|
|
683
748
|
const { Model } = modelMod;
|
|
@@ -725,7 +790,7 @@ const insertSyncedProperties = async ({ newProperties, itemSeeds, state, }) => {
|
|
|
725
790
|
const modelType = seedUidToModelType.get(seedUid);
|
|
726
791
|
const modelSchema = await modelSchemaForSyncedProperty(Model, property, state);
|
|
727
792
|
// ADR 0008: the local property this EAS name stands for, and whether it's a relation.
|
|
728
|
-
const resolvedName = resolveSyncedPropertyName(propertyNameSnake, propertyMetadata.value, modelSchema);
|
|
793
|
+
const resolvedName = resolveSyncedPropertyName(propertyNameSnake, propertyMetadata.value, modelSchema, easDataType);
|
|
729
794
|
if (!resolvedName)
|
|
730
795
|
continue;
|
|
731
796
|
const { propertyName, isRelation, isList } = resolvedName;
|
|
@@ -735,10 +800,13 @@ const insertSyncedProperties = async ({ newProperties, itemSeeds, state, }) => {
|
|
|
735
800
|
if (isRelation && !isList && relationValuesToExclude.includes(propertyMetadata.value)) {
|
|
736
801
|
continue;
|
|
737
802
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
803
|
+
// ADR 0010: numeric values decoded (Number as a decimal string, Date as ISO).
|
|
804
|
+
const decodedValue = syncedPropertyValue(resolvedName.dataType, easDataType, propertyMetadata.value);
|
|
805
|
+
if (decodedValue === undefined) {
|
|
806
|
+
console.warn(`[item/events] [syncDbWithEas] EAS property "${propertyNameSnake}" has a value that isn't a valid ${resolvedName.dataType}; skipping it`);
|
|
807
|
+
continue;
|
|
741
808
|
}
|
|
809
|
+
const propertyValue = typeof decodedValue === 'string' ? decodedValue : JSON.stringify(decodedValue);
|
|
742
810
|
if (isRelation && !isList) {
|
|
743
811
|
const relatedSeed = itemSeeds.find((seed) => seed.id === propertyMetadata.value);
|
|
744
812
|
if (relatedSeed && relatedSeed.schema && relatedSeed.schema.schemaNames) {
|
|
@@ -906,6 +974,8 @@ const runSyncFromEas = async (options) => {
|
|
|
906
974
|
// Never mix attestations from two chains in one local DB.
|
|
907
975
|
await assertLocalDbChain();
|
|
908
976
|
const appDb = BaseDb.getAppDb();
|
|
977
|
+
// ADR 0009: this run matches names at the levels the stored schema files set now.
|
|
978
|
+
await loadNameMatchLevels(appDb);
|
|
909
979
|
const { matchModelRecord } = await getModelSchemas();
|
|
910
980
|
const modelSchemas = await getModelSchemasFromEas();
|
|
911
981
|
const schemaUids = [];
|
|
@@ -957,7 +1027,7 @@ const runSyncFromEas = async (options) => {
|
|
|
957
1027
|
await getRelatedSeedsAndVersions(state);
|
|
958
1028
|
scheduleBulkFilesDownloadFromEasSync(addresses);
|
|
959
1029
|
try {
|
|
960
|
-
const _mod_4 = await import('./Item-
|
|
1030
|
+
const _mod_4 = await import('./Item-BDmsdNTQ.js');
|
|
961
1031
|
const _ns_4 = _mod_4.a6;
|
|
962
1032
|
const itemMod = _ns_4;
|
|
963
1033
|
await itemMod.Item.rehydrateCachedItemsFromDbAfterEasSync();
|
|
@@ -970,4 +1040,4 @@ const runSyncFromEas = async (options) => {
|
|
|
970
1040
|
};
|
|
971
1041
|
|
|
972
1042
|
export { VERSION_INSERT_BATCH, isSqlEscapedAttestationRaw, runSyncFromEas };
|
|
973
|
-
//# sourceMappingURL=syncDbWithEas-
|
|
1043
|
+
//# sourceMappingURL=syncDbWithEas-BmJXqfgN.js.map
|