@seedprotocol/sdk 0.6.7 → 0.6.8
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-qV0apdVY.js → BasePathResolver-B6CKqoKw.js} +16 -5
- package/dist/BasePathResolver-B6CKqoKw.js.map +1 -0
- package/dist/{ClientManager-Y5EWQuJj.js → ClientManager-ChcmUL47.js} +619 -264
- package/dist/ClientManager-ChcmUL47.js.map +1 -0
- package/dist/{ModelProperty-DuB5nk6A.js → ModelProperty-D79uV42p.js} +33 -30
- package/dist/ModelProperty-D79uV42p.js.map +1 -0
- package/dist/{Schema-BYM-GNdE.js → Schema-a8uO-hIZ.js} +43 -43
- package/dist/Schema-a8uO-hIZ.js.map +1 -0
- package/dist/{SchemaValidationService-Dr6nmwPm.js → SchemaValidationService-Y49vqast.js} +13 -12
- package/dist/SchemaValidationService-Y49vqast.js.map +1 -0
- package/dist/{backfillMetadataPropertyIds-BzbAB-C5.js → backfillMetadataPropertyIds-CBsf7LnU.js} +5 -3
- package/dist/{backfillMetadataPropertyIds-BzbAB-C5.js.map → backfillMetadataPropertyIds-CBsf7LnU.js.map} +1 -1
- package/dist/cjs/{ModelProperty-CDTOx5zi.js → ModelProperty-D9FGaGuE.js} +21 -17
- package/dist/cjs/ModelProperty-D9FGaGuE.js.map +1 -0
- package/dist/cjs/{Schema-XXcwj3hV.js → Schema-BiJIPLEL.js} +25 -24
- package/dist/cjs/Schema-BiJIPLEL.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-Z7OhtGn5.js → SchemaValidationService-DtYs_CNY.js} +5 -3
- package/dist/cjs/SchemaValidationService-DtYs_CNY.js.map +1 -0
- package/dist/cjs/{backfillMetadataPropertyIds-Bt4fzfIV.js → backfillMetadataPropertyIds-2XaN3b9S.js} +3 -2
- package/dist/cjs/{backfillMetadataPropertyIds-Bt4fzfIV.js.map → backfillMetadataPropertyIds-2XaN3b9S.js.map} +1 -1
- package/dist/cjs/{eas-DdI-4vwl.js → eas-CMNppmGE.js} +4 -3
- package/dist/cjs/{eas-DdI-4vwl.js.map → eas-CMNppmGE.js.map} +1 -1
- package/dist/cjs/{getItem-B_2GeTQf.js → getItem-B6jEINjW.js} +3 -2
- package/dist/cjs/{getItem-B_2GeTQf.js.map → getItem-B6jEINjW.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-Jmgi1RUj.js → getPublishPayload-D5DhLGvN.js} +64 -59
- package/dist/cjs/getPublishPayload-D5DhLGvN.js.map +1 -0
- package/dist/cjs/{getPublishUploads-DNULcrN5.js → getPublishUploads-DMhCCKYF.js} +17 -10
- package/dist/cjs/getPublishUploads-DMhCCKYF.js.map +1 -0
- package/dist/cjs/{getSegmentedItemProperties-DK82kjri.js → getSegmentedItemProperties-CU8rtBAo.js} +3 -51
- package/dist/cjs/getSegmentedItemProperties-CU8rtBAo.js.map +1 -0
- package/dist/cjs/{index-DM1WR83P.js → index-CSNtEnbF.js} +879 -467
- package/dist/cjs/index-CSNtEnbF.js.map +1 -0
- package/dist/cjs/{index-tpO1Nj4v.js → index-DPp9rdRL.js} +6 -3
- package/dist/cjs/index-DPp9rdRL.js.map +1 -0
- package/dist/cjs/{property-DmvgA8FD.js → property-DlKiAWt4.js} +7 -4
- package/dist/cjs/{property-DmvgA8FD.js.map → property-DlKiAWt4.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-3hOoPdu1.js → syncDbWithEas-C6n34o_Q.js} +11 -6
- package/dist/cjs/syncDbWithEas-C6n34o_Q.js.map +1 -0
- package/dist/{configurePlatform-CCYQruij.js → configurePlatform-CE0Vew17.js} +5 -5
- package/dist/{configurePlatform-CCYQruij.js.map → configurePlatform-CE0Vew17.js.map} +1 -1
- package/dist/db/drizzle/0014_add_error_code_to_publish_processes.sql +1 -0
- package/dist/db/drizzle/meta/0014_snapshot.json +1269 -0
- package/dist/db/drizzle/meta/_journal.json +7 -0
- package/dist/{db-CceyWksv.js → db-WbrzEf7c.js} +254 -35
- package/dist/db-WbrzEf7c.js.map +1 -0
- package/dist/{eas-CH8iFIST.js → eas-CfYCu4IX.js} +6 -6
- package/dist/{eas-CH8iFIST.js.map → eas-CfYCu4IX.js.map} +1 -1
- package/dist/{getItem-C7Mtfz6O.js → getItem-Br-bGNFO.js} +6 -6
- package/dist/{getItem-C7Mtfz6O.js.map → getItem-Br-bGNFO.js.map} +1 -1
- package/dist/{getPublishPayload-2gnnDdMh.js → getPublishPayload-BIrTVUxb.js} +66 -62
- package/dist/getPublishPayload-BIrTVUxb.js.map +1 -0
- package/dist/{getPublishUploads-AKISt3JA.js → getPublishUploads-C6cDeZdz.js} +19 -13
- package/dist/getPublishUploads-C6cDeZdz.js.map +1 -0
- package/dist/{getSegmentedItemProperties-eIjvhCP_.js → getSegmentedItemProperties-BmKE71vU.js} +5 -5
- package/dist/{getSegmentedItemProperties-eIjvhCP_.js.map → getSegmentedItemProperties-BmKE71vU.js.map} +1 -1
- package/dist/{constants-DSqHBPNe.js → index-280bL-n4.js} +32 -257
- package/dist/index-280bL-n4.js.map +1 -0
- package/dist/{index-CHi212ST.js → index-ClSv5pTA.js} +13 -13
- package/dist/index-ClSv5pTA.js.map +1 -0
- package/dist/{index-CsmiM0RI.js → index-Djd3667v.js} +2 -2
- package/dist/index-Djd3667v.js.map +1 -0
- package/dist/{index-BFpbtEsg.js → index-HRHkbVQd.js} +24 -24
- package/dist/{index-BFpbtEsg.js.map → index-HRHkbVQd.js.map} +1 -1
- package/dist/{index.node-CbWB4MDz.js → index.node-DBtQkEfz.js} +8 -6
- package/dist/index.node-DBtQkEfz.js.map +1 -0
- package/dist/main.cjs +6 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +36 -38
- package/dist/main.js.map +1 -1
- package/dist/node.js +15 -14
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +108 -46
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +4 -3
- package/dist/platform.node.js.map +1 -1
- package/dist/{property-CWKcZ5YZ.js → property-CQjuZ4JW.js} +14 -13
- package/dist/property-CQjuZ4JW.js.map +1 -0
- package/dist/seedSchema/PublishProcessSchema.ts +1 -0
- package/dist/src/Item/Item.d.ts +6 -0
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +10 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +1 -1
- package/dist/src/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/src/Schema/service/validation/SchemaValidationService.d.ts.map +1 -1
- package/dist/src/browser/db/drizzleFiles.d.ts +3 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
- package/dist/src/browser/helpers/EasClient.d.ts +2 -1
- package/dist/src/browser/helpers/EasClient.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/constants.d.ts +4 -0
- package/dist/src/client/constants.d.ts.map +1 -1
- package/dist/src/client/nodeEndpointDefaults.d.ts +8 -0
- package/dist/src/client/nodeEndpointDefaults.d.ts.map +1 -0
- 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/getRelatedItemsForPublish.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/ArweaveClient/index.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -2
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +4 -0
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts +8 -0
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +6 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts +1 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts.map +1 -1
- package/dist/src/helpers/localDbChain.d.ts +22 -0
- package/dist/src/helpers/localDbChain.d.ts.map +1 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts +9 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/property/index.d.ts +12 -0
- package/dist/src/helpers/property/index.d.ts.map +1 -1
- package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
- package/dist/src/helpers/relationSeedRef.d.ts +8 -0
- package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
- package/dist/src/index.d.ts +9 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/easLodashHook.d.ts +2 -0
- package/dist/src/node/easLodashHook.d.ts.map +1 -0
- package/dist/src/node/easLodashRegister.d.ts +2 -0
- package/dist/src/node/easLodashRegister.d.ts.map +1 -0
- package/dist/src/node/helpers/FileManager.d.ts +2 -1
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +2 -1
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/seedSchema/PublishProcessSchema.d.ts +19 -0
- package/dist/src/seedSchema/PublishProcessSchema.d.ts.map +1 -1
- package/dist/src/types/fileManager.d.ts +4 -0
- package/dist/src/types/fileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +15 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-5kZneTEL.js → syncDbWithEas-CuARXfyN.js} +16 -12
- package/dist/syncDbWithEas-CuARXfyN.js.map +1 -0
- package/dist/{updateSeedRevokedAt-CgfOBtqJ.js → updateSeedRevokedAt-CBcLfHWs.js} +2 -2
- package/dist/{updateSeedRevokedAt-CgfOBtqJ.js.map → updateSeedRevokedAt-CBcLfHWs.js.map} +1 -1
- package/package.json +11 -7
- package/src/node/easLodashHook.js +22 -0
- package/src/node/easLodashRegister.js +13 -0
- package/dist/BasePathResolver-qV0apdVY.js.map +0 -1
- package/dist/ClientManager-Y5EWQuJj.js.map +0 -1
- package/dist/ModelProperty-DuB5nk6A.js.map +0 -1
- package/dist/Schema-BYM-GNdE.js.map +0 -1
- package/dist/SchemaValidationService-Dr6nmwPm.js.map +0 -1
- package/dist/cjs/ModelProperty-CDTOx5zi.js.map +0 -1
- package/dist/cjs/Schema-XXcwj3hV.js.map +0 -1
- package/dist/cjs/SchemaValidationService-Z7OhtGn5.js.map +0 -1
- package/dist/cjs/getPublishPayload-Jmgi1RUj.js.map +0 -1
- package/dist/cjs/getPublishUploads-DNULcrN5.js.map +0 -1
- package/dist/cjs/getSegmentedItemProperties-DK82kjri.js.map +0 -1
- package/dist/cjs/index-DM1WR83P.js.map +0 -1
- package/dist/cjs/index-tpO1Nj4v.js.map +0 -1
- package/dist/cjs/syncDbWithEas-3hOoPdu1.js.map +0 -1
- package/dist/constants-DSqHBPNe.js.map +0 -1
- package/dist/db-CceyWksv.js.map +0 -1
- package/dist/getPublishPayload-2gnnDdMh.js.map +0 -1
- package/dist/getPublishUploads-AKISt3JA.js.map +0 -1
- package/dist/index-CHi212ST.js.map +0 -1
- package/dist/index-CsmiM0RI.js.map +0 -1
- package/dist/index.node-CbWB4MDz.js.map +0 -1
- package/dist/property-CWKcZ5YZ.js.map +0 -1
- package/dist/seedSchema/AppStateSchema.d.ts +0 -82
- package/dist/seedSchema/AppStateSchema.d.ts.map +0 -1
- package/dist/seedSchema/ConfigSchema.d.ts +0 -101
- package/dist/seedSchema/ConfigSchema.d.ts.map +0 -1
- package/dist/seedSchema/MetadataSchema.d.ts +0 -422
- package/dist/seedSchema/MetadataSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelSchema.d.ts +0 -243
- package/dist/seedSchema/ModelSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelSchemaSchema.d.ts +0 -61
- package/dist/seedSchema/ModelSchemaSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelUidSchema.d.ts +0 -64
- package/dist/seedSchema/ModelUidSchema.d.ts.map +0 -1
- package/dist/seedSchema/PropertyUidSchema.d.ts +0 -64
- package/dist/seedSchema/PropertyUidSchema.d.ts.map +0 -1
- package/dist/seedSchema/SchemaSchema.d.ts +0 -169
- package/dist/seedSchema/SchemaSchema.d.ts.map +0 -1
- package/dist/seedSchema/SeedSchema.d.ts +0 -192
- package/dist/seedSchema/SeedSchema.d.ts.map +0 -1
- package/dist/seedSchema/VersionSchema.d.ts +0 -194
- package/dist/seedSchema/VersionSchema.d.ts.map +0 -1
- package/dist/seedSchema/index.d.ts +0 -14
- package/dist/seedSchema/index.d.ts.map +0 -1
- package/dist/syncDbWithEas-5kZneTEL.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaValidationService-Z7OhtGn5.js","sources":["../../../src/Schema/service/validation/SchemaValidationService.ts"],"sourcesContent":["import { Value } from '@sinclair/typebox/value'\nimport { TProperty } from '@/Schema'\nimport { ModelPropertyDataTypes, TPropertyDataType, normalizeDataType } from '@/helpers/property'\nimport { ValidationResult, ValidationError, ValidationRules, DEFAULT_TEXT_MAX_LENGTH } from '@/Schema/validation'\nimport { SchemaMachineContext } from '../schemaMachine'\nimport { ModelPropertyMachineContext } from '@/ModelProperty/service/modelPropertyMachine'\nimport { ModelMachineContext } from '@/Model/service/modelMachine'\nimport { Type, TSchema, TUnion, TLiteral } from '@sinclair/typebox'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:schema:validation')\n\n/**\n * Service for validating schemas, models, and properties using TypeBox\n */\nexport class SchemaValidationService {\n /**\n * Enhance TypeBox error message with expected values for union/literal types\n */\n private enhanceErrorMessage(\n error: any,\n schema: TSchema,\n fieldPath: string\n ): string {\n const originalMessage = error.message || 'Validation failed'\n \n // Handle Union type errors (like TPropertyDataType)\n if (error.type === 'Union' || originalMessage.includes('union')) {\n const expectedValues = this.extractExpectedValues(schema, fieldPath)\n if (expectedValues.length > 0) {\n return `Expected one of: ${expectedValues.join(', ')}. Received: ${JSON.stringify(error.value)}`\n }\n }\n \n // Handle Literal type errors\n if (error.type === 'Literal') {\n const expectedValue = this.extractLiteralValue(schema, fieldPath)\n if (expectedValue !== undefined) {\n return `Expected: ${JSON.stringify(expectedValue)}. Received: ${JSON.stringify(error.value)}`\n }\n }\n \n // Return enhanced message with value info if available\n if (error.value !== undefined) {\n return `${originalMessage}. Received: ${JSON.stringify(error.value)}`\n }\n \n return originalMessage\n }\n\n /**\n * Extract expected values from a schema for a given field path\n */\n private extractExpectedValues(schema: TSchema | null, fieldPath: string): string[] {\n try {\n // Handle TProperty schema - check if this is the dataType field\n if (fieldPath === '/dataType' || fieldPath.endsWith('/dataType')) {\n // Return all ModelPropertyDataTypes enum values\n return Object.values(ModelPropertyDataTypes) as string[]\n }\n \n // Handle TStorageType\n if (fieldPath === '/storageType' || fieldPath.endsWith('/storageType')) {\n return ['ItemStorage', 'PropertyStorage']\n }\n \n // If we have a schema, try to extract from it\n if (!schema) {\n return []\n }\n \n // Try to extract from TypeBox Union type using the schema directly\n const schemaObj = schema as any\n const kind = schemaObj[Symbol.for('TypeBox.Kind')]\n \n if (kind === 'Union') {\n const union = schemaObj as TUnion<any>\n const anyOf = union.anyOf || []\n const values: string[] = []\n \n for (const item of anyOf) {\n const itemKind = item?.[Symbol.for('TypeBox.Kind')]\n if (itemKind === 'Literal') {\n const literal = item as TLiteral<any>\n if (literal.const !== undefined) {\n values.push(String(literal.const))\n }\n }\n }\n \n if (values.length > 0) {\n return values\n }\n }\n \n // Fallback: try to extract from JSON schema format\n if (typeof schema === 'object' && 'anyOf' in schema) {\n const union = schema as any\n if (Array.isArray(union.anyOf)) {\n return union.anyOf\n .map((item: any) => {\n if (item.const !== undefined) return String(item.const)\n if (item.enum && Array.isArray(item.enum)) return item.enum.map(String)\n return null\n })\n .filter((val: any) => val !== null)\n .flat()\n .map(String)\n }\n }\n } catch (error) {\n logger('Error extracting expected values:', error)\n }\n \n return []\n }\n\n /**\n * Extract literal value from a schema\n */\n private extractLiteralValue(schema: TSchema, fieldPath: string): any {\n try {\n if (schema && typeof schema === 'object') {\n const schemaObj = schema as any\n if (schemaObj[Symbol.for('TypeBox.Kind')] === 'Literal') {\n return (schemaObj as TLiteral<any>).const\n }\n if (schemaObj.const !== undefined) {\n return schemaObj.const\n }\n }\n } catch (error) {\n logger('Error extracting literal value:', error)\n }\n \n return undefined\n }\n\n /**\n * Get the schema for a specific field path\n */\n private getSchemaForField(schema: TSchema, fieldPath: string): TSchema | null {\n try {\n if (!schema || typeof schema !== 'object') return null\n \n // Remove leading slash\n const path = fieldPath.replace(/^\\//, '')\n if (!path) return schema\n \n const schemaObj = schema as any\n const kind = schemaObj[Symbol.for('TypeBox.Kind')]\n \n // For TProperty (Object type), check properties\n if (kind === 'Object') {\n const properties = schemaObj.properties\n if (properties && properties[path]) {\n return properties[path]\n }\n }\n \n // Special handling for known fields - return the actual schema\n if (path === 'dataType') {\n return TPropertyDataType as TSchema\n }\n \n // Fallback: check if schema has the property\n if (path in schemaObj) {\n return schemaObj[path]\n }\n } catch (error) {\n logger('Error getting schema for field:', error)\n }\n \n return null\n }\n\n /**\n * Validate a property structure against TProperty schema\n */\n validatePropertyStructure(\n property: ModelPropertyMachineContext\n ): ValidationResult {\n try {\n // Normalize dataType and refValueType for case-insensitive schema support (e.g. \"relation\" -> \"Relation\")\n const normalized = { ...property }\n if (typeof normalized.dataType === 'string') {\n normalized.dataType = normalizeDataType(normalized.dataType) as any\n }\n if (typeof normalized.refValueType === 'string') {\n normalized.refValueType = normalizeDataType(normalized.refValueType) as any\n }\n const isValid = Value.Check(TProperty, normalized)\n \n const errors: ValidationError[] = []\n \n if (!isValid) {\n const typeBoxErrors = [...Value.Errors(TProperty, normalized)]\n errors.push(...typeBoxErrors.map(err => {\n const fieldPath = err.path || 'unknown'\n const fieldSchema = this.getSchemaForField(TProperty, fieldPath)\n const enhancedMessage = this.enhanceErrorMessage(err, fieldSchema || TProperty, fieldPath)\n \n return {\n field: fieldPath,\n message: enhancedMessage,\n code: String(err.type || 'validation_error'),\n severity: 'error' as const,\n }\n }))\n }\n \n // Non-List types: refValueType is only valid for Relation+Image (related entity type). Reject otherwise.\n const nonListTypes = [\n ModelPropertyDataTypes.Text,\n ModelPropertyDataTypes.Number,\n ModelPropertyDataTypes.Boolean,\n ModelPropertyDataTypes.Date,\n ModelPropertyDataTypes.Json,\n ModelPropertyDataTypes.Image,\n ModelPropertyDataTypes.File,\n ModelPropertyDataTypes.Html,\n ModelPropertyDataTypes.Relation,\n ]\n if (nonListTypes.includes(normalized.dataType as ModelPropertyDataTypes)) {\n const hasRefValueType = normalized.refValueType != null && String(normalized.refValueType).trim() !== ''\n if (hasRefValueType) {\n // Relation may keep refValueType only for Image (relation to Image entity)\n if (normalized.dataType === ModelPropertyDataTypes.Relation && normalized.refValueType === ModelPropertyDataTypes.Image) {\n // Allowed: Relation to Image\n } else {\n errors.push({\n field: 'refValueType',\n message: `refValueType is only valid for List properties. Use dataType 'List' with refValueType '${normalized.refValueType}' for lists of ${normalized.refValueType}.`,\n code: 'invalid_ref_value_type',\n severity: 'error' as const,\n })\n }\n }\n }\n\n // List: refValueType is required\n if (normalized.dataType === ModelPropertyDataTypes.List) {\n const hasRefValueType = normalized.refValueType != null && String(normalized.refValueType).trim() !== ''\n if (!hasRefValueType) {\n errors.push({\n field: 'refValueType',\n message: `List properties require refValueType (e.g. 'Text', 'Number', 'Relation') to specify the element type.`,\n code: 'missing_ref_value_type',\n severity: 'error' as const,\n })\n }\n // List of relations: ref is required\n if (hasRefValueType && normalized.refValueType === ModelPropertyDataTypes.Relation) {\n const hasRef = normalized.ref && normalized.ref.trim() !== ''\n const hasRefModelName = normalized.refModelName && normalized.refModelName.trim() !== ''\n const hasRefModelId = normalized.refModelId !== undefined && normalized.refModelId !== null\n if (!hasRef && !hasRefModelName && !hasRefModelId) {\n errors.push({\n field: 'ref',\n message: `List properties with refValueType 'Relation' require either a \"ref\", \"refModelName\", or \"refModelId\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n }\n }\n }\n\n // Relation (single): ref is required\n if (normalized.dataType === ModelPropertyDataTypes.Relation) {\n const hasRef = normalized.ref && normalized.ref.trim() !== ''\n const hasRefModelName = normalized.refModelName && normalized.refModelName.trim() !== ''\n const hasRefModelId = normalized.refModelId !== undefined && normalized.refModelId !== null\n if (!hasRef && !hasRefModelName && !hasRefModelId) {\n errors.push({\n field: 'ref',\n message: `Property with dataType \"Relation\" requires either a \"ref\", \"refModelName\", or \"refModelId\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n }\n if ((hasRef || hasRefModelName) && !hasRefModelId) {\n logger(`Property \"${normalized.name}\" has ref/refModelName but no refModelId - will be resolved asynchronously`)\n }\n }\n \n return {\n isValid: errors.length === 0,\n errors,\n }\n } catch (error) {\n logger('Error validating property structure:', error)\n return {\n isValid: false,\n errors: [{\n field: 'property',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n }\n }\n }\n\n /**\n * Validate a property value against its validation rules\n * @param value - The value to validate\n * @param dataType - The property's data type\n * @param validationRules - Optional validation rules (enum, pattern, minLength, maxLength)\n * @param refValueType - For List properties: the element type (Text, Number, etc.). When set, each array element is validated against this type + validationRules.\n */\n validatePropertyValue(\n value: any,\n dataType: ModelPropertyDataTypes,\n validationRules?: ValidationRules,\n refValueType?: ModelPropertyDataTypes | string\n ): ValidationResult {\n const errors: ValidationError[] = []\n const warnings: ValidationError[] = []\n\n try {\n // Array values are only allowed for List properties\n if (dataType !== ModelPropertyDataTypes.List && Array.isArray(value)) {\n errors.push({\n field: 'value',\n message: 'Array values are only allowed for List properties. Use dataType \"List\" with refValueType to store multiple values.',\n code: 'array_not_allowed',\n severity: 'error' as const,\n })\n }\n\n // File/Image: accept File objects from OS picker (TypeBox schema only allows string|null)\n if (\n (dataType === ModelPropertyDataTypes.File || dataType === ModelPropertyDataTypes.Image) &&\n typeof File !== 'undefined' &&\n value instanceof File\n ) {\n if (validationRules) {\n const customErrors = this.validateCustomRules(value, validationRules)\n errors.push(...customErrors)\n }\n return {\n isValid: errors.length === 0,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n }\n\n // List with refValueType: validate each element against element schema + validation rules\n if (dataType === ModelPropertyDataTypes.List && refValueType && Array.isArray(value)) {\n const elementDataType = normalizeDataType(String(refValueType)) as ModelPropertyDataTypes\n // Apply default maxLength for Text elements in List. Html elements hold arbitrary-length content.\n const elementEffectiveRules = validationRules ? { ...validationRules } : {}\n if (elementDataType === ModelPropertyDataTypes.Text && elementEffectiveRules.maxLength === undefined) {\n elementEffectiveRules.maxLength = DEFAULT_TEXT_MAX_LENGTH\n }\n for (let i = 0; i < value.length; i++) {\n const elementResult = this.validatePropertyValue(\n value[i],\n elementDataType,\n elementEffectiveRules\n )\n if (!elementResult.isValid && elementResult.errors.length > 0) {\n for (const err of elementResult.errors) {\n errors.push({\n field: `value[${i}]`,\n message: `Element at index ${i}: ${err.message}`,\n code: validationRules?.enum && Array.isArray(validationRules.enum) && validationRules.enum.length > 0 ? 'enum_violation' : err.code,\n severity: err.severity,\n })\n }\n }\n }\n if (validationRules) {\n const customErrors = this.validateCustomRules(value, validationRules)\n errors.push(...customErrors)\n }\n return {\n isValid: errors.length === 0,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n }\n\n // List without refValueType or non-array: validate as scalar/array\n if (dataType === ModelPropertyDataTypes.List && !Array.isArray(value) && value != null) {\n errors.push({\n field: 'value',\n message: 'List properties require an array value.',\n code: 'array_required',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n // Build base TypeBox schema from dataType\n let schema: TSchema = this.getBaseSchemaForDataType(dataType)\n\n // Apply default maxLength for Text when not explicitly set. Html holds arbitrary-length content (e.g. article body) and must not default to 255.\n const effectiveRules = validationRules ? { ...validationRules } : {}\n if (dataType === ModelPropertyDataTypes.Text && effectiveRules.maxLength === undefined) {\n effectiveRules.maxLength = DEFAULT_TEXT_MAX_LENGTH\n }\n\n // Apply validation rules\n const hasEnumRules = !!(validationRules?.enum && Array.isArray(validationRules.enum) && validationRules.enum.length > 0)\n if (Object.keys(effectiveRules).length > 0) {\n schema = this.applyValidationRules(schema, dataType, effectiveRules)\n }\n\n // Validate using TypeBox\n const isValid = Value.Check(schema, value)\n \n if (!isValid) {\n const typeBoxErrors = [...Value.Errors(schema, value)]\n const effectiveMaxLength = effectiveRules.maxLength\n const isDefaultTextLimit =\n dataType === ModelPropertyDataTypes.Text &&\n effectiveMaxLength === DEFAULT_TEXT_MAX_LENGTH &&\n validationRules?.maxLength === undefined\n errors.push(...typeBoxErrors.map(err => {\n const fieldPath = err.path || 'value'\n const originalMessage = (err.message || '').toLowerCase()\n // TypeBox maxLength errors have message like \"Expected string length less or equal to X\"\n const isMaxLengthError = originalMessage.includes('length') && (originalMessage.includes('less') || originalMessage.includes('equal') || originalMessage.includes('max'))\n let enhancedMessage: string\n if (isMaxLengthError && effectiveMaxLength !== undefined) {\n const typeLabel = dataType === ModelPropertyDataTypes.Html ? 'Html' : 'Text'\n if (isDefaultTextLimit) {\n enhancedMessage = `Text properties have a default limit of 255 characters. For longer content, use a File property instead, which can hold arbitrary amounts of text or data.`\n } else {\n enhancedMessage = `${typeLabel} must be ${effectiveMaxLength} characters or less. For longer content, use a File property instead, which can hold arbitrary amounts of text or data.`\n }\n } else {\n enhancedMessage = this.enhanceErrorMessage(err, schema, fieldPath)\n }\n // Use max_length_exceeded when failure is due to maxLength; enum_violation when enum rules; else generic\n const code = isMaxLengthError\n ? 'max_length_exceeded'\n : hasEnumRules\n ? 'enum_violation'\n : String(err.type || 'value_validation_error')\n\n return {\n field: fieldPath,\n message: enhancedMessage,\n code,\n severity: 'error' as const,\n }\n }))\n }\n\n // Additional custom validations\n if (validationRules) {\n const customErrors = this.validateCustomRules(value, validationRules)\n errors.push(...customErrors)\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n }\n } catch (error) {\n logger('Error validating property value:', error)\n return {\n isValid: false,\n errors: [{\n field: 'value',\n message: error instanceof Error ? error.message : 'Unknown validation error',\n code: 'validation_exception',\n severity: 'error' as const,\n }],\n }\n }\n }\n\n /**\n * Validate a specific property within a schema\n */\n validateProperty(\n schema: SchemaMachineContext,\n modelName: string,\n propertyName: string,\n propertyData?: ModelPropertyMachineContext\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Check if model exists\n if (!schema.models || !schema.models[modelName]) {\n errors.push({\n field: 'model',\n message: `Model \"${modelName}\" not found in schema`,\n code: 'model_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n const model = schema.models[modelName]\n\n // Check if property exists in model\n // If the property name has changed (renamed), check if the original name exists\n let propertyDefinition = model.properties?.[propertyName]\n let actualPropertyName = propertyName\n \n if (!propertyDefinition && propertyData?._originalValues?.name) {\n const originalName = propertyData._originalValues.name\n // If the current name differs from the original, check if original exists\n if (originalName !== propertyName && model.properties?.[originalName]) {\n propertyDefinition = model.properties[originalName]\n actualPropertyName = originalName\n // Property is being renamed, which is allowed - continue validation\n }\n }\n \n if (!propertyDefinition) {\n errors.push({\n field: 'property',\n message: `Property \"${propertyName}\" not found in model \"${modelName}\"`,\n code: 'property_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n // If propertyData is provided, validate its structure\n if (propertyData) {\n const structureResult = this.validatePropertyStructure(propertyData)\n errors.push(...structureResult.errors)\n }\n\n // Validate property definition structure\n if (!propertyDefinition.type) {\n errors.push({\n field: 'property.type',\n message: 'Property type is required',\n code: 'missing_type',\n severity: 'error' as const,\n })\n }\n\n // Validate Relation: requires model\n if (propertyDefinition.type === 'Relation') {\n if (!propertyDefinition.model || propertyDefinition.model.trim() === '') {\n errors.push({\n field: 'property.model',\n message: `Property with type \"Relation\" requires a \"model\" field to be defined`,\n code: 'missing_ref',\n severity: 'error' as const,\n })\n } else if (!schema.models[propertyDefinition.model]) {\n errors.push({\n field: 'property.model',\n message: `Referenced model \"${propertyDefinition.model}\" not found in schema`,\n code: 'invalid_reference',\n severity: 'error' as const,\n })\n }\n }\n\n // Validate List: requires refValueType; ref (model) required only when refValueType === 'Relation' (case-insensitive)\n if (propertyDefinition.type === 'List' || (propertyDefinition as any).dataType === 'List') {\n const rawRefValueType = (propertyDefinition as any).refValueType ?? (propertyDefinition as any).items?.type ?? (propertyDefinition as any).refvaluetype\n const refValueType = rawRefValueType ? normalizeDataType(String(rawRefValueType)) : undefined\n if (!refValueType || String(refValueType).trim() === '') {\n errors.push({\n field: 'property.refValueType',\n message: 'List properties require \"refValueType\" (e.g. refValueType: \"Text\" or refValueType: \"Relation\" with ref: \"Tag\")',\n code: 'missing_ref_value_type',\n severity: 'error' as const,\n })\n } else if (refValueType === 'Relation' || refValueType === 'RelationProperty') {\n const model = (propertyDefinition as any).ref ?? (propertyDefinition as any).model ?? (propertyDefinition as any).items?.model\n if (!model || String(model).trim() === '') {\n errors.push({\n field: 'property.ref',\n message: 'List of relations requires \"ref\" to specify the related model',\n code: 'missing_ref',\n severity: 'error' as const,\n })\n } else if (schema.models && !schema.models[model]) {\n errors.push({\n field: 'property.ref',\n message: `Referenced model \"${model}\" not found in schema`,\n code: 'invalid_reference',\n severity: 'error' as const,\n })\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate model structure (basic structure checks)\n */\n validateModelStructure(\n model: ModelMachineContext & { properties?: { [key: string]: any } }\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Validate model name\n if (!model.modelName || model.modelName.trim() === '') {\n errors.push({\n field: 'modelName',\n message: 'Model name is required',\n code: 'missing_model_name',\n severity: 'error' as const,\n })\n }\n\n // Validate schema name\n if (!model.schemaName || model.schemaName.trim() === '') {\n errors.push({\n field: 'schemaName',\n message: 'Schema name is required',\n code: 'missing_schema_name',\n severity: 'error' as const,\n })\n }\n\n // Validate properties is an object\n if (model.properties && typeof model.properties !== 'object') {\n errors.push({\n field: 'properties',\n message: 'Properties must be an object',\n code: 'invalid_properties',\n severity: 'error' as const,\n })\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate a model against a schema WITHOUT requiring it to be in the schema's context\n * This allows validation before registration, preventing update loops\n */\n validateModelAgainstSchema(\n schema: SchemaMachineContext,\n modelName: string,\n modelData: ModelMachineContext & { properties?: { [key: string]: any } }\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n // Create a temporary schema context that includes this model for validation purposes\n // This allows validateProperty to work without actually adding the model to the real schema\n const tempSchemaContext: SchemaMachineContext = {\n ...schema,\n models: {\n ...schema.models,\n [modelName]: {\n properties: modelData.properties || {},\n },\n },\n }\n\n // Use validateModel which now works because the model is in the temp context\n return this.validateModel(tempSchemaContext, modelName, modelData)\n }\n\n /**\n * Validate a model within a schema (requires model to already be in schema context)\n */\n validateModel(\n schema: SchemaMachineContext,\n modelName: string,\n modelData?: ModelMachineContext\n ): ValidationResult {\n const errors: ValidationError[] = []\n\n if (!schema.models || !schema.models[modelName]) {\n errors.push({\n field: 'model',\n message: `Model \"${modelName}\" not found in schema`,\n code: 'model_not_found',\n severity: 'error' as const,\n })\n return { isValid: false, errors }\n }\n\n const model = schema.models[modelName]\n\n // Validate all properties in the model\n if (model.properties) {\n for (const [propertyName, propertyDef] of Object.entries(model.properties)) {\n const propertyResult = this.validateProperty(schema, modelName, propertyName)\n if (!propertyResult.isValid) {\n errors.push(...propertyResult.errors.map(err => ({\n ...err,\n field: `${modelName}.${propertyName}.${err.field}`,\n })))\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Validate entire schema\n */\n validateSchema(schema: SchemaMachineContext): ValidationResult {\n const errors: ValidationError[] = []\n\n // Validate schema name\n if (!schema.schemaName || schema.schemaName.trim() === '') {\n errors.push({\n field: 'schemaName',\n message: 'Schema name is required',\n code: 'missing_schema_name',\n severity: 'error' as const,\n })\n }\n\n // Validate metadata\n if (!schema.metadata) {\n errors.push({\n field: 'metadata',\n message: 'Schema metadata is required',\n code: 'missing_metadata',\n severity: 'error' as const,\n })\n } else {\n if (!schema.metadata.name || schema.metadata.name.trim() === '') {\n errors.push({\n field: 'metadata.name',\n message: 'Schema metadata name is required',\n code: 'missing_metadata_name',\n severity: 'error' as const,\n })\n }\n }\n\n // Validate models if they exist\n if (schema.models && Object.keys(schema.models).length > 0) {\n // Validate each model\n for (const modelName of Object.keys(schema.models)) {\n const modelResult = this.validateModel(schema, modelName)\n if (!modelResult.isValid) {\n errors.push(...modelResult.errors)\n }\n }\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n }\n }\n\n /**\n * Get base TypeBox schema for a data type\n */\n private getBaseSchemaForDataType(dataType: ModelPropertyDataTypes): TSchema {\n switch (dataType) {\n case ModelPropertyDataTypes.Text:\n case ModelPropertyDataTypes.Html:\n return Type.String()\n case ModelPropertyDataTypes.Number:\n return Type.Number()\n case ModelPropertyDataTypes.Boolean:\n return Type.Boolean()\n case ModelPropertyDataTypes.Date:\n return Type.String({ format: 'date-time' })\n case ModelPropertyDataTypes.Json:\n return Type.Any()\n case ModelPropertyDataTypes.List:\n return Type.Array(Type.Any())\n case ModelPropertyDataTypes.Relation:\n case ModelPropertyDataTypes.Image:\n case ModelPropertyDataTypes.File:\n return Type.Union([Type.String(), Type.Null()])\n default:\n return Type.Any()\n }\n }\n\n /**\n * Apply validation rules to a TypeBox schema\n */\n private applyValidationRules(\n schema: TSchema,\n dataType: ModelPropertyDataTypes,\n rules: ValidationRules\n ): TSchema {\n let result = schema\n\n // Apply pattern (regex) for strings\n if (rules.pattern && (dataType === ModelPropertyDataTypes.Text || dataType === ModelPropertyDataTypes.Html)) {\n try {\n const regex = new RegExp(rules.pattern)\n result = Type.RegExp(regex)\n } catch (error) {\n logger('Invalid regex pattern:', rules.pattern, error)\n }\n }\n\n // Apply minLength/maxLength for strings\n if (dataType === ModelPropertyDataTypes.Text || dataType === ModelPropertyDataTypes.Html) {\n const stringSchema = Type.String()\n if (rules.minLength !== undefined) {\n result = Type.String({ minLength: rules.minLength })\n }\n if (rules.maxLength !== undefined) {\n if (rules.minLength !== undefined) {\n result = Type.String({ minLength: rules.minLength, maxLength: rules.maxLength })\n } else {\n result = Type.String({ maxLength: rules.maxLength })\n }\n }\n }\n\n // Apply enum\n if (rules.enum && Array.isArray(rules.enum) && rules.enum.length > 0) {\n result = Type.Union(rules.enum.map(val => Type.Literal(val)))\n }\n\n return result\n }\n\n /**\n * Validate custom validation rules\n */\n private validateCustomRules(\n value: any,\n rules: ValidationRules\n ): ValidationError[] {\n const errors: ValidationError[] = []\n\n // Custom validator reference (would need to be implemented based on your needs)\n if (rules.custom) {\n // TODO: Implement custom validator lookup and execution\n logger('Custom validator not yet implemented:', rules.custom)\n }\n\n return errors\n }\n}\n\n"],"names":["ModelPropertyDataTypes","TPropertyDataType","normalizeDataType","Value","TProperty","value","DEFAULT_TEXT_MAX_LENGTH","Type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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S,EAAE,CAAC;gBAClF;qBAAO;AACL,oBAAA,MAAM,GAAGA,YAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;gBACtD;YACF;QACF;;QAGA,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACpE,MAAM,GAAGA,YAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAIA,YAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/D;AAEA,QAAA,OAAO,MAAM;IACf;AAEA;;AAEG;IACK,mBAAmB,CACzB,KAAU,EACV,KAAsB,EAAA;QAEtB,MAAM,MAAM,GAAsB,EAAE;;AAGpC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE;;AAEhB,YAAA,MAAM,CAAC,uCAAuC,EAAE,KAAK,CAAC,MAAM,CAAC;QAC/D;AAEA,QAAA,OAAO,MAAM;IACf;AACD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishPayload-Jmgi1RUj.js","sources":["../../../src/helpers/ethereumUtils.ts","../../../src/db/read/getPublishPayload.ts"],"sourcesContent":["import { keccak_256 } from '@noble/hashes/sha3'\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils'\n\n/** EIP-55 checksum for a 20-byte hex address (with or without 0x prefix). */\nexport function checksumAddress(address: string): string {\n const addr = address.toLowerCase().replace(/^0x/, '')\n if (addr.length !== 40 || !/^[0-9a-f]+$/.test(addr)) {\n return address\n }\n const hash = bytesToHex(keccak_256(utf8ToBytes(addr)))\n let result = '0x'\n for (let i = 0; i < 40; i++) {\n result += parseInt(hash[i]!, 16) >= 8 ? addr[i]!.toUpperCase() : addr[i]!\n }\n return result\n}\n\n/** UTF-8 string to 0x-prefixed bytes32 hex (right-padded with zeros). */\nexport function encodeBytes32String(value: string): string {\n const bytes = new TextEncoder().encode(value)\n if (bytes.length > 32) {\n throw new Error(`encodeBytes32String: value exceeds 32 bytes (${bytes.length})`)\n }\n const hex = Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n return `0x${hex.padEnd(64, '0')}`\n}\n","// Dynamic import to break circular dependency with getItem -> BaseItem\n// import { getItem } from '@/db/read/getItem'\nimport {\n defaultAttestationData,\n INTERNAL_DATA_TYPES,\n INTERNAL_PROPERTY_NAMES,\n VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n ZERO_BYTES32,\n} from '@/helpers/constants'\nimport {\n AttestationRequest,\n AttestationRequestData,\n SchemaEncoder,\n} from '@ethereum-attestation-service/eas-sdk'\n\nimport { getEasSchemaForItemProperty } from '@/helpers/getSchemaForItemProperty'\nimport { toSnakeCase } from '@/helpers'\nimport { toSnakeCase as toSnakeCaseDb } from 'drizzle-orm/casing'\nimport pluralize from 'pluralize'\nimport { getEasSchemaUidForModel } from './getSchemaUidForModel'\nimport { getEasSchemaUidForSchemaDefinition } from '@/stores/eas'\nimport { getCorrectId } from '@/helpers'\nimport { isValidEasAttestationUid } from '@/helpers/easUid'\nimport { getLatestPublishedVersionRow } from '@/db/read/getLatestPublishedVersionRow'\nimport {\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport { getPropertySchema } from '@/helpers/property'\nimport { modelPropertiesToObject } from '@/helpers/model'\nimport { IItemProperty } from '@/interfaces'\nimport { camelCase, upperFirst } from 'lodash-es'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { IItem } from '@/interfaces'\nimport debug from 'debug'\nimport { encodeBytes32String } from '@/helpers/ethereumUtils'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport type { ValidationError } from '@/Schema/validation'\nconst logger = debug('seedSdk:db:getPublishPayload')\n\n/** Case-insensitive dataType match (schema JSON may use \"text\" vs \"Text\"). */\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\n\n/** Validation error collected during publish payload building. */\nexport type PublishValidationError = Pick<ValidationError, 'field' | 'message'> & { code?: string }\n\n/** Context for collecting validation errors instead of throwing on first error. */\nexport type PublishValidationContext = { errors: PublishValidationError[] }\n\n/** `patch` (default): new property attestations on the current Version. `new_version`: new Version attestation + attest all properties. */\nexport type PublishMode = 'patch' | 'new_version'\n\nexport type GetPublishPayloadOptions = {\n publishMode?: PublishMode\n}\n\nfunction addValidationError(\n ctx: PublishValidationContext,\n message: string,\n field?: string,\n code = 'publish_validation',\n): void {\n ctx.errors.push({ field: field ?? '', message, code })\n}\n\nfunction isStorageTransactionPropertyName(name: string | undefined): boolean {\n return name === 'storageTransactionId' || name === 'storage_transaction_id'\n}\n\n/**\n * Segmentation or naming variants can leave two rows for the same logical field; keep one\n * resolved slot so processBasicProperties emits a single storage tx attestation.\n */\nfunction replaceStorageTransactionInBasicProperties(\n itemBasicProperties: IItemProperty<any>[],\n resolved: IItemProperty<any>,\n): void {\n const filtered = itemBasicProperties.filter(\n (p) => !isStorageTransactionPropertyName(p.propertyName),\n )\n itemBasicProperties.length = 0\n itemBasicProperties.push(...filtered, resolved)\n}\n\n/** If multiple storageTransactionId ItemProperty rows slipped in, keep one (last wins). */\nfunction dedupeOneStorageTransactionPropertyInList(itemBasicProperties: IItemProperty<any>[]): void {\n const nonStorage: IItemProperty<any>[] = []\n const storage: IItemProperty<any>[] = []\n for (const p of itemBasicProperties) {\n if (isStorageTransactionPropertyName(p.propertyName)) {\n storage.push(p)\n } else {\n nonStorage.push(p)\n }\n }\n if (storage.length <= 1) return\n itemBasicProperties.length = 0\n itemBasicProperties.push(...nonStorage, storage[storage.length - 1]!)\n}\n\n/**\n * Two relation/image props (e.g. content + featureImage) can reference the same File/Image seed.\n * Only one child PublishPayload should exist per related seedLocalId; merge propertiesToUpdate instead.\n */\nfunction mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload: MultiPublishPayload,\n relatedSeedLocalId: string,\n publishLocalId: string,\n propertySchemaUid: string | undefined,\n): boolean {\n const existing = multiPublishPayload.find((p) => p.localId === relatedSeedLocalId)\n if (!existing) return false\n const pts = existing.propertiesToUpdate ?? []\n const already = pts.some(\n (e) =>\n e.publishLocalId === publishLocalId &&\n String(e.propertySchemaUid ?? '').toLowerCase() ===\n String(propertySchemaUid ?? '').toLowerCase(),\n )\n if (!already) {\n pts.push({ publishLocalId, propertySchemaUid })\n }\n return true\n}\n\nconst getVersionUid = (item: IItem<any>): string => {\n const latestVersion = item.latestVersionUid\n if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {\n const u = latestVersion.uid\n return isValidEasAttestationUid(u) ? u : ZERO_BYTES32\n }\n if (latestVersion && typeof latestVersion === 'string') {\n return isValidEasAttestationUid(latestVersion) ? latestVersion : ZERO_BYTES32\n }\n return ZERO_BYTES32\n}\n\n/**\n * Resolve versionUid when item.latestVersionUid is empty but item has been published (has seedUid).\n * Tries DB first, then EAS. If the local versions row still has a placeholder uid after publish,\n * EAS fallback queries attestations where refUID=seedUid (Version attestations).\n */\nasync function resolveVersionUid(\n seedLocalId: string,\n seedUid: string | undefined,\n): Promise<string> {\n if (!seedLocalId || !seedUid || seedUid === ZERO_BYTES32) return ZERO_BYTES32\n\n const published = await getLatestPublishedVersionRow(seedLocalId)\n if (published?.uid) return published.uid\n\n try {\n const { getItemVersionsFromEas } = await import('@/eas')\n const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] })\n const latest = attestations?.[0]\n if (latest?.id) return latest.id\n } catch {\n // EAS client may not be initialized or network error\n }\n return ZERO_BYTES32\n}\n\ntype PropertyDataResult = {\n schemaUid: string | undefined\n easDataType: string\n schemaDef: string\n propertyNameForSchema: string\n}\n\nconst getPropertyData = async (\n itemProperty: IItemProperty<any>,\n ctx?: PublishValidationContext,\n): Promise<PropertyDataResult | null> => {\n const rawDataType = itemProperty.propertyDef?.dataType\n const dataType = rawDataType ? normalizeDataType(String(rawDataType)) : undefined\n const entry = dataType\n ? INTERNAL_DATA_TYPES[dataType as keyof typeof INTERNAL_DATA_TYPES]\n : undefined\n const easDataType = entry?.eas\n if (!easDataType) {\n if (ctx) {\n addValidationError(\n ctx,\n `Unknown or unsupported property data type \"${rawDataType ?? 'undefined'}\" for property: ${itemProperty.propertyName}. Supported types: ${Object.keys(INTERNAL_DATA_TYPES).join(', ')}.`,\n itemProperty.propertyName,\n )\n }\n return null\n }\n\n let schemaUid: string | undefined = itemProperty.schemaUid\n\n const ip = itemProperty as IItemProperty<any> & { storagePropertyName?: string }\n const propertyDefForName = itemProperty.propertyDef as\n | { dataType?: string; ref?: string; refModelName?: string }\n | undefined\n let nameForEas =\n ip.storagePropertyName && ip.storagePropertyName.length > 0\n ? ip.storagePropertyName\n : itemProperty.propertyName\n // Align List-of-relation EAS field name with processListProperty (authorIdentityIds for authors → Identity)\n if (\n matchesDataType(propertyDefForName?.dataType, ModelPropertyDataTypes.List) &&\n (propertyDefForName?.ref || propertyDefForName?.refModelName) &&\n !(ip.storagePropertyName && ip.storagePropertyName.length > 0)\n ) {\n const ref = propertyDefForName?.ref ?? propertyDefForName?.refModelName\n if (ref) {\n const singular = pluralize.singular(itemProperty.propertyName)\n nameForEas = `${singular}${ref}Ids`\n }\n }\n const propertyNameForSchema = toSnakeCase(nameForEas)\n\n const schemaDef = `${easDataType} ${propertyNameForSchema}`\n\n if (!schemaUid) {\n schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef })\n if (!schemaUid) {\n const schema = await getEasSchemaForItemProperty({\n propertyName: 'version',\n easDataType: 'bytes32',\n })\n if (schema) {\n schemaUid = schema.id\n }\n }\n }\n\n return {\n schemaUid,\n easDataType,\n schemaDef,\n propertyNameForSchema,\n }\n}\n\n/** Resolve propertyDef from Model for properties that lack it (e.g. cached instances\n * created before loadOrCreateProperty was fixed). Ensures both new and existing items get property attestations.\n * Also ensures Relation/Image properties have required from schema when missing (for publish validation). */\nconst ensurePropertyDefs = async (targetItem: IItem<any>) => {\n const toFix = targetItem.properties.filter(\n (p) =>\n targetItem.modelName &&\n (!p.propertyDef ||\n (matchesDataType(p.propertyDef?.dataType, ModelPropertyDataTypes.Relation) &&\n p.propertyDef?.required === undefined)),\n )\n let schema: any\n for (const itemProperty of targetItem.properties) {\n if (!itemProperty.propertyDef && targetItem.modelName) {\n schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName)\n if (!schema) {\n try {\n const { Model } = await import('@/Model/Model')\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n let model = Model.getByName(normalizedModelName)\n if (!model?.properties?.length) {\n model = Model.findByModelType(toSnakeCaseDb(targetItem.modelName))\n }\n const modelFound = !!model\n const propsCount = model?.properties?.length ?? 0\n const schemaKeys: string[] = []\n if (model?.properties?.length) {\n const schemas = modelPropertiesToObject(model.properties)\n schemaKeys.push(...Object.keys(schemas))\n schema = schemas[itemProperty.propertyName]\n }\n } catch (err) {\n schema = undefined\n }\n }\n if (!schema) {\n const db = BaseDb.getAppDb()\n if (db) {\n try {\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n const modelRecords = await db\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length > 0 && modelRecords[0].id) {\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, itemProperty.propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0) {\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n schema = {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n }\n }\n } catch {\n schema = undefined\n }\n }\n }\n if (schema) {\n itemProperty.getService().send({\n type: 'updateContext',\n propertyRecordSchema: schema,\n })\n }\n }\n }\n}\n\ntype PublishBuildOpts = { forceFullSnapshot?: boolean }\n\nconst processBasicProperties = async (\n itemBasicProperties: IItemProperty<any>[],\n itemPublishData: PublishPayload,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<PublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n for (const basicProperty of itemBasicProperties) {\n // Skip SDK-internal properties (e.g. publisher) - never attest to EAS\n if (INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {\n continue\n }\n const snapshot = basicProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n const propertyDef =\n basicProperty.propertyDef ?? (context ? (context as any).propertyRecordSchema : undefined)\n const isFileImageHtml =\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html)\n const isJsonStorage =\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json)\n const isRelation = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation)\n // storageTransactionId is usually Text in the schema; .value still prefers renderValue (URL, label).\n const isStorageTransactionIdProp = isStorageTransactionPropertyName(basicProperty.propertyName)\n // File/Image/Html + Relation + Json storage + storage tx id: use propertyValue (canonical).\n // basicProperty.value prefers renderValue (filename, blob URL, display text)—never use that for publish.\n const preferPropertyValueForPublish =\n isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp\n let value =\n preferPropertyValueForPublish && context\n ? (context as any).propertyValue\n : ((basicProperty as IItemProperty<any>).value ??\n (context ? (context as any).propertyValue : undefined))\n const hasContext = !!context\n const hasValue = value != null && value !== ''\n const hasUid = !!basicProperty.uid\n const skipReason = !hasContext ? 'no_context' : (!hasValue || hasUid) ? (hasUid ? 'has_uid' : 'no_value') : null\n if (!context) {\n continue\n }\n // Relation + Image/File/Html/Json refs often expose seedLocalId on context.propertyValue while .value is an object — align for encode + resolve hints\n if (\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation) ||\n isFileImageHtml ||\n isJsonStorage\n ) {\n const pv = (context as any).propertyValue\n if (typeof value === 'object' || value == null) {\n if (typeof pv === 'string' && pv.trim()) value = pv.trim()\n else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string') value = pv.seedLocalId\n }\n }\n if (!value) {\n continue\n }\n // Patch mode skips properties that already have an EAS uid. storageTransactionId must still\n // attest after Arweave upload when we have a tx id; metadata uid can be stale or set without a chain attestation.\n if (basicProperty.uid && !forceFullSnapshot) {\n const allowStorageTxAttestation =\n isStorageTransactionIdProp &&\n typeof value === 'string' &&\n value.trim() !== ''\n if (!allowStorageTxAttestation) {\n continue\n }\n }\n\n const propertyData = await getPropertyData(basicProperty, ctx)\n if (!propertyData) continue\n const { schemaUid, easDataType, schemaDef, propertyNameForSchema } = propertyData\n if (!schemaDef) continue\n\n // Normalize value: string that parses to array (e.g. from browser storage) -> array\n if (schemaDef.startsWith('bytes32[]') && typeof value === 'string' && value.trim().startsWith('[')) {\n try {\n value = JSON.parse(value)\n } catch {\n // fall through to array check\n }\n }\n\n // Legacy comma-separated ids (pre-JSON List storage)\n if (\n schemaDef.startsWith('bytes32[]') &&\n typeof value === 'string' &&\n !value.trim().startsWith('[') &&\n value.includes(',')\n ) {\n value = value\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean)\n }\n\n if (schemaDef.startsWith('bytes32[]') && !Array.isArray(value)) {\n addValidationError(\n ctx,\n `Invalid value for property: ${basicProperty.propertyName}. Expected an array of bytes32, got ${value}.`,\n basicProperty.propertyName,\n )\n continue\n }\n\n // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding\n if (propertyDef?.validation) {\n const { SchemaValidationService } = await import(\n '@/Schema/service/validation/SchemaValidationService'\n )\n const validationService = new SchemaValidationService()\n const validationResult = validationService.validatePropertyValue(\n value,\n normalizeDataType(propertyDef.dataType) as ModelPropertyDataTypes,\n propertyDef.validation,\n propertyDef.refValueType\n ? (normalizeDataType(propertyDef.refValueType) as string)\n : undefined,\n )\n if (!validationResult.isValid && validationResult.errors.length > 0) {\n const firstError = validationResult.errors[0]\n addValidationError(\n ctx,\n firstError.message,\n basicProperty.propertyName,\n firstError.code ?? 'publish_validation',\n )\n continue\n }\n }\n\n /** Raw id per list slot (nanoid local id or 0x… uid) for resolvePublishPayloadValues after sequential publish */\n let rawListIdsForResolve: string[] | undefined\n if (schemaDef.startsWith('bytes32[]')) {\n const newValues: string[] = []\n const rawIds: string[] = []\n const iterableValue =\n Array.isArray(value) ? value\n : value != null && typeof value[Symbol.iterator] === 'function' ? value\n : []\n for (const seedId of iterableValue) {\n const idStr =\n typeof seedId === 'string'\n ? seedId\n : seedId &&\n typeof seedId === 'object' &&\n (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)\n ? String(\n (seedId as { seedLocalId?: string; seedUid?: string }).seedLocalId ??\n (seedId as { seedUid?: string }).seedUid ??\n '',\n )\n : ''\n if (!idStr) continue\n const trimmed = idStr.trim()\n if (!trimmed) continue\n rawIds.push(trimmed)\n if (trimmed.length !== 66 && !trimmed.startsWith('0x')) {\n newValues.push(encodeBytes32String(trimmed))\n } else {\n newValues.push(trimmed)\n }\n }\n value = newValues\n const needsUidResolve = rawIds.some(\n (id) => id.length !== 66 || !id.startsWith('0x'),\n )\n if (needsUidResolve && rawIds.length > 0) {\n rawListIdsForResolve = rawIds\n }\n }\n\n // uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds\n if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {\n const ms = value instanceof Date ? value.getTime() : new Date(value).getTime()\n value = BigInt(Math.floor(ms / 1000))\n }\n\n let data = [\n {\n name: propertyNameForSchema,\n type: easDataType,\n value,\n },\n ]\n\n let encodedData: string\n try {\n const dataEncoder = new SchemaEncoder(schemaDef)\n encodedData = dataEncoder.encodeData(data) as string\n } catch (encodeErr) {\n addValidationError(\n ctx,\n `Failed to encode property ${basicProperty.propertyName}: ${encodeErr instanceof Error ? encodeErr.message : String(encodeErr)}`,\n basicProperty.propertyName,\n )\n continue\n }\n\n // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)\n const refUid = isStorageTransactionIdProp\n ? itemPublishData.versionUid\n : defaultAttestationData.refUID\n\n const attestationEntry: Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n /** Same as encode step (getPropertyData); resolvePublishPayloadValues must use this, not toSnakeCase(propertyName). */\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n /** Per-slot raw ids (local or 0x) before encodeBytes32String; re-encoded after sequential publish. */\n _rawListIdsForResolve?: string[]\n } = {\n schema: schemaUid!,\n data: [\n {\n ...defaultAttestationData,\n refUID: refUid,\n data: encodedData,\n } as AttestationRequestData,\n ],\n // Always set so persist can match metadata rows that lack schemaUid\n _propertyName: basicProperty.propertyName,\n }\n\n // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues\n const looksLikeLocalSeedRef =\n typeof value === 'string' &&\n !value.startsWith('0x') &&\n value.length !== 66 &&\n /^[a-zA-Z0-9_-]{10,21}$/.test(value.trim())\n if (\n looksLikeLocalSeedRef &&\n (easDataType === 'bytes32' || easDataType === 'string')\n ) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._propertyNameForSchema = propertyNameForSchema\n attestationEntry._schemaDef = schemaDef\n attestationEntry._unresolvedValue = value.trim()\n attestationEntry._easDataType = easDataType\n }\n if (rawListIdsForResolve && rawListIdsForResolve.length > 0) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._propertyNameForSchema = propertyNameForSchema\n attestationEntry._schemaDef = schemaDef\n attestationEntry._easDataType = 'bytes32[]'\n attestationEntry._rawListIdsForResolve = rawListIdsForResolve\n }\n\n itemPublishData.listOfAttestations.push(attestationEntry)\n }\n\n return itemPublishData\n}\n\n\nconst processRelationOrImageProperty = async (\n relationOrImageProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n uploadedTransactions: UploadedTransaction[],\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n let relationOrImageSchemaUid = relationOrImageProperty.schemaUid\n if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {\n const propertyData = await getPropertyData(relationOrImageProperty, ctx)\n if (!propertyData) return multiPublishPayload\n relationOrImageSchemaUid = propertyData.schemaUid\n }\n if (!relationOrImageSchemaUid) {\n addValidationError(\n ctx,\n `Schema uid not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const snapshot = relationOrImageProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n return multiPublishPayload\n }\n let value = (context as any).propertyValue\n // File/Image/Html/Json metadata is stored with Id suffix (e.g. \"textId\"); context may not have propertyValue\n // if the property was created from schema before metadata loaded. Fallback to metadata lookup.\n const isStorageSeed =\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Json)))\n if (isStorageSeed && ((context as any).seedLocalId || (context as any).seedUid)) {\n const { getPropertyData: getPropertyDataFromDb } = await import('@/db/read/getPropertyData')\n const metaRow = await getPropertyDataFromDb({\n propertyName: relationOrImageProperty.propertyName,\n seedLocalId: (context as any).seedLocalId,\n seedUid: (context as any).seedUid,\n })\n const fromMeta = metaRow?.propertyValue\n if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {\n const idsCtx = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(value) ?? '')\n const idsDb = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(fromMeta) ?? '')\n if (!value) {\n value = fromMeta\n } else if (!idsCtx.seedLocalId && !idsCtx.seedUid && (idsDb.seedLocalId || idsDb.seedUid)) {\n value = fromMeta\n }\n }\n }\n const propertyDef = relationOrImageProperty.propertyDef\n let isRequired = propertyDef?.required === true\n // Resolve required from schema/DB when propertyDef lacks it\n if (!isRequired && relationOrImageProperty.modelName) {\n let schema = await getPropertySchema(\n relationOrImageProperty.modelName,\n relationOrImageProperty.propertyName,\n )\n if (!schema && BaseDb.getAppDb()) {\n const normalizedModelName = upperFirst(camelCase(relationOrImageProperty.modelName))\n const modelRecords = await BaseDb.getAppDb()!\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length > 0 && modelRecords[0].id) {\n const propertyRecords = await BaseDb.getAppDb()!\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, relationOrImageProperty.propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0) {\n schema = {\n dataType: propertyRecords[0].dataType,\n ref: undefined,\n required: propertyRecords[0].required ?? undefined,\n } as any\n }\n }\n }\n if (schema?.required === true || (schema as any)?.required === 1) {\n isRequired = true\n }\n }\n\n // Required relation/image/file/html/json with no value: cannot publish\n if (isRequired && !value) {\n const typeLabel =\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.File)\n ? 'file'\n : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Image)\n ? 'image'\n : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Html)\n ? 'html'\n : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json)\n ? 'json'\n : 'relation'\n const refLabel = propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'\n addValidationError(\n ctx,\n `Required ${typeLabel} ${relationOrImageProperty.propertyName} has no value. ` +\n `A value pointing to a valid ${refLabel} item is required to publish.`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n if (!value) {\n return multiPublishPayload\n }\n if (relationOrImageProperty.uid && !forceFullSnapshot) {\n return multiPublishPayload\n }\n\n const normalizedRef = normalizeRelationPropertyValue(value)\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalizedRef ?? '')\n\n // Value is not a valid seed reference (local id or 0x uid)\n if (!seedLocalId && !seedUid) {\n if (isRequired) {\n addValidationError(\n ctx,\n `Required relation ${relationOrImageProperty.propertyName} has invalid value: ${JSON.stringify(value)}. ` +\n `Value must be a valid seed reference (localId or uid) pointing to a ${propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'} item.`,\n relationOrImageProperty.propertyName,\n )\n }\n return multiPublishPayload\n }\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n // When related item not found (e.g. different DB, not yet created)\n if (!relatedItem) {\n if (isRequired) {\n addValidationError(\n ctx,\n `No related item found for required relation: ${relationOrImageProperty.propertyName}. ` +\n `Value: ${JSON.stringify(value)} (seedLocalId/seedUid). ` +\n `The related item may be missing, in a different database, or the reference may be broken.`,\n relationOrImageProperty.propertyName,\n )\n }\n return multiPublishPayload\n }\n\n // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {\n modelName = 'Image'\n }\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.File)) {\n modelName = 'File'\n }\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html)) {\n modelName = 'Html'\n }\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Relation)) {\n const def = relationOrImageProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (!modelName) {\n addValidationError(\n ctx,\n `Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n addValidationError(\n ctx,\n `Schema UID not found for model: ${modelName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n relationOrImageSchemaUid,\n )\n ) {\n return multiPublishPayload\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: relationOrImageSchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties, itemUploadProperties } =\n await getSegmentedItemProperties(relatedItem)\n\n const relatedStorageUpload = resolveStorageTransactionUploadSlot(\n relatedItem,\n itemUploadProperties,\n )\n if (relatedStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(\n uploadedTransactions,\n relatedItem.seedLocalId,\n )\n if (transactionData) {\n const itemProperty = relatedStorageUpload.itemProperty\n // Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it\n // uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const p of itemBasicProperties) {\n if (\n isStorageTransactionPropertyName(p.propertyName) &&\n !p.propertyDef &&\n relatedItem.modelName\n ) {\n const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n\n return multiPublishPayload\n}\n\nasync function resolveHtmlPropertySchemaUidByHtmlSeed(\n item: IItem<any>,\n htmlSeedLocalId: string,\n ctx: PublishValidationContext,\n): Promise<string | undefined> {\n const want = htmlSeedLocalId.trim()\n for (const p of item.properties) {\n if (!matchesDataType(p.propertyDef?.dataType, ModelPropertyDataTypes.Html)) continue\n const snap = p.getService().getSnapshot()\n const c = 'context' in snap ? snap.context : null\n const pv = typeof (c as any)?.propertyValue === 'string' ? (c as any).propertyValue.trim() : ''\n if (pv !== want) continue\n let uid = p.schemaUid\n if (!uid) {\n const pd = await getPropertyData(p, ctx)\n uid = pd?.schemaUid\n }\n return uid\n }\n addValidationError(\n ctx,\n `Could not find Html property for embedded image rewrite (html seed ${want}).`,\n 'html',\n 'html_embed_schema',\n )\n return undefined\n}\n\nasync function processHtmlEmbeddedCoPublishImagePayloads(\n item: IItem<any>,\n multiPublishPayload: MultiPublishPayload,\n uploadedTransactions: UploadedTransaction[],\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return multiPublishPayload\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n if (rows.length === 0) return multiPublishPayload\n\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const doneImages = new Set<string>()\n\n for (const row of rows) {\n if (doneImages.has(row.imageSeedLocalId)) continue\n doneImages.add(row.imageSeedLocalId)\n\n const htmlSchemaUid = await resolveHtmlPropertySchemaUidByHtmlSeed(item, row.htmlSeedLocalId, ctx)\n if (!htmlSchemaUid) continue\n\n const relatedItem = await getItem({ seedLocalId: row.imageSeedLocalId })\n if (!relatedItem) {\n addValidationError(\n ctx,\n `Embedded Image item not found for seed ${row.imageSeedLocalId}.`,\n 'html',\n 'html_embed_image_missing',\n )\n continue\n }\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n continue\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel('Image')\n if (!seedSchemaUid) {\n addValidationError(ctx, `Schema UID not found for model: Image`, 'html')\n continue\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n htmlSchemaUid,\n )\n ) {\n continue\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: relatedItem.seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: htmlSchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties, itemUploadProperties } =\n await getSegmentedItemProperties(relatedItem)\n\n const relatedStorageUpload = resolveStorageTransactionUploadSlot(\n relatedItem,\n itemUploadProperties,\n )\n if (relatedStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(\n uploadedTransactions,\n relatedItem.seedLocalId,\n )\n if (transactionData) {\n const itemProperty = relatedStorageUpload.itemProperty\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const p of itemBasicProperties) {\n if (\n isStorageTransactionPropertyName(p.propertyName) &&\n !p.propertyDef &&\n relatedItem.modelName\n ) {\n const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\nconst processListProperty = async (\n listProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties\n if (!listProperty.propertyDef?.ref) {\n addValidationError(\n ctx,\n `processListProperty requires ref (list of relations). List property \"${listProperty.propertyName}\" has no ref. List-of-primitives should be in itemBasicProperties.`,\n listProperty.propertyName,\n )\n return multiPublishPayload\n }\n let listPropertySchemaUid = listProperty.schemaUid\n if (!listPropertySchemaUid && listProperty.propertyDef) {\n const propertyData = await getPropertyData(listProperty, ctx)\n if (!propertyData) return multiPublishPayload\n listPropertySchemaUid = propertyData.schemaUid\n }\n if (!listPropertySchemaUid) {\n addValidationError(\n ctx,\n `Schema uid not found for list property: ${listProperty.propertyName}`,\n listProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const snapshot = listProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n return multiPublishPayload\n }\n let value = (context as any).propertyValue\n if (!value) {\n return multiPublishPayload\n }\n if (listProperty.uid && !forceFullSnapshot) {\n return multiPublishPayload\n }\n\n const singularPropertyName = pluralize.singular(listProperty.propertyName)\n const propertyNameForSchema = `${singularPropertyName}${listProperty.propertyDef!.ref}Ids`\n if (typeof value === 'string') {\n value = parseListPropertyValueFromStorage(value)\n }\n\n const iterableValue = Array.isArray(value)\n ? value\n : value != null\n ? [value]\n : []\n\n for (const seedId of iterableValue) {\n const idStr =\n typeof seedId === 'string'\n ? seedId\n : seedId &&\n typeof seedId === 'object' &&\n (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)\n if (!idStr) continue\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(idStr)\n if (!seedLocalId && !seedUid) continue\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n console.error(\n `No related item found for list property: ${listProperty.propertyName}`,\n )\n continue\n }\n\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n continue\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (listProperty.propertyDef?.ref || (listProperty.propertyDef as { refModelName?: string }).refModelName) {\n const def = listProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {\n modelName = 'Image'\n }\n\n if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.File)) {\n modelName = 'File'\n }\n\n if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html)) {\n modelName = 'Html'\n }\n\n if (!modelName) {\n addValidationError(\n ctx,\n `Model name not found for list property: ${listProperty.propertyName}`,\n listProperty.propertyName,\n )\n continue\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n addValidationError(\n ctx,\n `Schema UID not found for model: ${modelName}`,\n listProperty.propertyName,\n )\n continue\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n listPropertySchemaUid,\n )\n ) {\n continue\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: listPropertySchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties } = await getSegmentedItemProperties(relatedItem)\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\ntype PublishPayload = {\n localId: string\n seedIsRevocable: boolean\n seedSchemaUid: string\n seedUid: string\n versionSchemaUid: string\n versionUid: string\n listOfAttestations: (Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n _rawListIdsForResolve?: string[]\n })[]\n propertiesToUpdate: any[]\n}\n\ntype MultiPublishPayload = PublishPayload[]\n\n/**\n * Same EAS schema + same encoded attestation bytes (data field). Intentionally ignores refUID so\n * duplicate storageTransactionId rows that only differ by ref (e.g. 0x0 vs version uid) collapse.\n */\nfunction attestationPayloadDedupeKey(att: PublishPayload['listOfAttestations'][number]): string {\n const schema = String((att as { schema?: string }).schema ?? '').toLowerCase()\n const dataArr = (att as { data?: unknown[] }).data\n const d0 = Array.isArray(dataArr) ? dataArr[0] : undefined\n const dataHex =\n d0 && typeof d0 === 'object' && d0 !== null && 'data' in d0\n ? String((d0 as { data?: string }).data ?? '').toLowerCase()\n : ''\n return `${schema}:${dataHex}`\n}\n\n/**\n * Collapse duplicate rows in listOfAttestations (same schema + encoded payload).\n */\nfunction dedupeListOfAttestationsInEachPayload(payload: MultiPublishPayload): MultiPublishPayload {\n for (const p of payload) {\n const list = p.listOfAttestations ?? []\n if (list.length <= 1) continue\n const seen = new Set<string>()\n const out: PublishPayload['listOfAttestations'] = []\n for (const a of list) {\n const k = attestationPayloadDedupeKey(a)\n if (seen.has(k)) continue\n seen.add(k)\n out.push(a)\n }\n p.listOfAttestations = out\n }\n return payload\n}\n\n/**\n * Merge duplicate PublishPayload rows with the same localId (ordering / batch edge cases).\n * Dedupe listOfAttestations so identical storage tx attestations are not emitted twice.\n */\nfunction dedupeMultiPublishPayloadByLocalId(payload: MultiPublishPayload): MultiPublishPayload {\n const map = new Map<string, PublishPayload>()\n const order: string[] = []\n\n for (const p of payload) {\n const id = p.localId\n const existing = map.get(id)\n if (!existing) {\n map.set(id, p)\n order.push(id)\n continue\n }\n const ptu = [...(existing.propertiesToUpdate ?? [])]\n for (const u of p.propertiesToUpdate ?? []) {\n if (\n !ptu.some(\n (e) =>\n e.publishLocalId === u.publishLocalId &&\n String(e.propertySchemaUid ?? '').toLowerCase() ===\n String(u.propertySchemaUid ?? '').toLowerCase(),\n )\n ) {\n ptu.push(u)\n }\n }\n existing.propertiesToUpdate = ptu\n const seenKeys = new Set((existing.listOfAttestations ?? []).map((a) => attestationPayloadDedupeKey(a)))\n const merged = [...(existing.listOfAttestations ?? [])]\n for (const a of p.listOfAttestations ?? []) {\n const k = attestationPayloadDedupeKey(a)\n if (seenKeys.has(k)) continue\n seenKeys.add(k)\n merged.push(a)\n }\n existing.listOfAttestations = merged\n }\n\n return order.map((id) => map.get(id)!).filter(Boolean) as MultiPublishPayload\n}\n\n/** Map of seed localId -> attestation uid for resolving relation/image property values after dependent seeds are published */\nexport type ResolvedSeedUids = Record<string, string>\n\ntype UploadedTransaction = {\n txId: string\n itemPropertyLocalId?: string\n seedLocalId?: string\n versionLocalId?: string\n itemPropertyName?: string\n}\n\n/** Same shape as UploadProperty in getPublishUploads */\ntype StorageUploadSlot = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\n\n/**\n * Child File/Image items may keep storageTransactionId only on the item machine's\n * propertyInstances map; allProperties / item.properties can omit it during publish.\n */\nfunction getStorageTransactionPropertyFromItemInstances(\n item: IItem<any>,\n): IItemProperty<any> | undefined {\n try {\n const svc = (item as { getService?: () => { getSnapshot: () => unknown } }).getService?.()\n if (!svc) return undefined\n const snap = svc.getSnapshot() as {\n context?: { propertyInstances?: Map<string, IItemProperty<any>> }\n }\n const instances = snap.context?.propertyInstances\n if (!instances || !(instances instanceof Map)) return undefined\n const direct =\n instances.get('storageTransactionId') ?? instances.get('storage_transaction_id')\n if (direct) return direct\n for (const [, p] of instances) {\n if (p && isStorageTransactionPropertyName(p.propertyName)) return p\n }\n } catch {\n return undefined\n }\n return undefined\n}\n\n/**\n * Resolve storageTransactionId (+ ItemStorage children) for publish.\n * getSegmentedItemProperties can yield empty itemUploadProperties when the child Item never\n * hydrated storageTransactionId into the upload bucket (e.g. only uri/metadata rows), while\n * getStorageSeedUploads still creates an Arweave upload keyed by child seedLocalId.\n */\nfunction resolveStorageTransactionUploadSlot(\n item: IItem<any>,\n itemUploadProperties: StorageUploadSlot[],\n): StorageUploadSlot | undefined {\n const named = itemUploadProperties.find((u) =>\n isStorageTransactionPropertyName(u.itemProperty.propertyName),\n )\n if (named) return named\n if (itemUploadProperties.length === 1) return itemUploadProperties[0]\n\n const all = (item as { allProperties?: Record<string, IItemProperty<any>> }).allProperties\n const fromInstances = getStorageTransactionPropertyFromItemInstances(item)\n const storagePropEarly =\n all?.['storageTransactionId'] ??\n all?.['storage_transaction_id'] ??\n Object.values(all ?? {}).find(\n (p): p is IItemProperty<any> =>\n !!p && isStorageTransactionPropertyName((p as IItemProperty<any>).propertyName),\n ) ??\n item.properties?.find((p) => isStorageTransactionPropertyName(p.propertyName))\n const storageProp = storagePropEarly ?? fromInstances\n if (!storageProp) return undefined\n\n const childProps =\n item.properties?.filter(\n (p) =>\n p.propertyDef &&\n (p.propertyDef as { storageType?: string }).storageType === 'ItemStorage',\n ) ?? []\n return { itemProperty: storageProp, childProperties: childProps }\n}\n\nfunction findUploadedTxForSeedLocalId(\n uploadedTransactions: UploadedTransaction[],\n seedLocalId: string,\n): UploadedTransaction | undefined {\n const t = seedLocalId.trim()\n return (\n uploadedTransactions.find((u) => u.seedLocalId === t) ??\n uploadedTransactions.find((u) => u.seedLocalId != null && u.seedLocalId.trim() === t)\n )\n}\n\n/** Error thrown when publish validation fails. Includes all validation errors for user to fix. */\nexport class PublishValidationFailedError extends Error {\n constructor(\n message: string,\n public readonly validationErrors: PublishValidationError[],\n ) {\n super(message)\n this.name = 'PublishValidationFailedError'\n }\n}\n\nexport const getPublishPayload = async (\n item: IItem<any>,\n uploadedTransactions: UploadedTransaction[],\n options?: GetPublishPayloadOptions,\n): Promise<MultiPublishPayload> => {\n const validationCtx: PublishValidationContext = { errors: [] }\n const publishMode: PublishMode = options?.publishMode ?? 'patch'\n const forceFullSnapshot = publishMode === 'new_version'\n\n if (publishMode === 'new_version' && (!item.seedUid || item.seedUid === ZERO_BYTES32)) {\n addValidationError(\n validationCtx,\n 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).',\n 'seedUid',\n 'publish_new_version_requires_seed',\n )\n }\n\n let multiPublishPayload: MultiPublishPayload = []\n\n // Each PublishPayload is generated from a Seed that needs publishing\n\n // First we need to determine all Seeds to publish\n\n // That means the Seed of the Item, plus any Seeds pointed to by Relations\n\n // Check if the item has a schema UID\n let itemSchemaUid = item.schemaUid\n if (!itemSchemaUid) {\n const schemaUid = await getEasSchemaUidForModel(item.modelName)\n if (!schemaUid) {\n addValidationError(validationCtx, `Schema UID not found for model: ${item.modelName}`)\n itemSchemaUid = ZERO_BYTES32 // placeholder so we can continue collecting errors\n } else {\n itemSchemaUid = schemaUid\n }\n }\n\n let versionUid = getVersionUid(item)\n if (versionUid === ZERO_BYTES32 && item.seedUid && item.seedUid !== ZERO_BYTES32) {\n versionUid = await resolveVersionUid(item.seedLocalId, item.seedUid)\n }\n if (forceFullSnapshot && item.seedUid && item.seedUid !== ZERO_BYTES32) {\n versionUid = ZERO_BYTES32\n }\n\n let itemPublishData: PublishPayload = {\n localId: item.seedLocalId,\n seedUid: item.seedUid || ZERO_BYTES32,\n seedIsRevocable: true,\n seedSchemaUid: itemSchemaUid,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [],\n }\n\n await ensurePropertyDefs(item)\n\n const {\n itemBasicProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n itemRelationProperties,\n } = await getSegmentedItemProperties(item)\n\n const relationAndImageProperties = [...itemRelationProperties, ...itemImageProperties]\n\n // Validate required relations have values before processing\n for (const relProp of itemRelationProperties) {\n const snapshot = relProp.getService().getSnapshot()\n const ctx = 'context' in snapshot ? snapshot.context : null\n const val = ctx ? (ctx as any).renderValue ?? (ctx as any).propertyValue : undefined\n if (val != null && typeof val === 'string' && val.trim() !== '') continue\n // No value - check if required from propertyDef or DB\n let isRequired = relProp.propertyDef?.required === true\n if (!isRequired && BaseDb.getAppDb() && item.modelName) {\n const normalizedModelName = upperFirst(camelCase(item.modelName))\n const modelRows = await BaseDb.getAppDb()!\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRows.length > 0) {\n const propRows = await BaseDb.getAppDb()!\n .select({ required: properties.required, refModelId: properties.refModelId })\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRows[0].id),\n eq(properties.name, relProp.propertyName),\n eq(properties.dataType, 'Relation'),\n ),\n )\n .limit(1)\n if (propRows.length > 0 && (propRows[0].required === true || propRows[0].required === 1)) {\n isRequired = true\n }\n }\n }\n if (isRequired) {\n const refModel = relProp.propertyDef?.ref ?? relProp.propertyDef?.refModelName ?? 'related'\n addValidationError(\n validationCtx,\n `Required relation ${relProp.propertyName} has no value. ` +\n `A value pointing to a valid ${refModel} item is required to publish.`,\n relProp.propertyName,\n )\n }\n }\n\n const rootStorageUpload = resolveStorageTransactionUploadSlot(item, itemUploadProperties)\n if (rootStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, item.seedLocalId)\n if (transactionData) {\n const itemProperty = rootStorageUpload.itemProperty\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const relationProperty of relationAndImageProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n relationProperty,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n itemBasicProperties.push(relationProperty)\n }\n\n multiPublishPayload = await processHtmlEmbeddedCoPublishImagePayloads(\n item,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n\n for (const listProperty of itemListProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n itemBasicProperties.push(listProperty)\n }\n\n for (const p of itemBasicProperties) {\n if (isStorageTransactionPropertyName(p.propertyName) && !p.propertyDef && item.modelName) {\n const schema = await getPropertySchema(item.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n itemPublishData = await processBasicProperties(\n itemBasicProperties,\n itemPublishData,\n validationCtx,\n { forceFullSnapshot },\n )\n\n multiPublishPayload.push(itemPublishData)\n\n // Ensure requests are ordered so that when A has propertiesToUpdate pointing to B (publishLocalId),\n // A (the updater) is published before B (the updatee). The contract injects A's seedUid into B's\n // attestation before B is sent to EAS.\n multiPublishPayload = dedupeMultiPublishPayloadByLocalId(multiPublishPayload)\n multiPublishPayload = orderPayloadByDependencies(multiPublishPayload)\n\n // Ensure attestations referenced in propertiesToUpdate have at least one data element.\n // The contract writes the seed UID into data[0].data; empty data causes Panic 50.\n multiPublishPayload = ensurePropertiesToUpdateAttestationsHaveData(multiPublishPayload)\n multiPublishPayload = dedupeListOfAttestationsInEachPayload(multiPublishPayload)\n\n if (publishMode === 'new_version') {\n const rootPayload = multiPublishPayload.find((p) => p.localId === item.seedLocalId)\n const listLen = rootPayload?.listOfAttestations?.length ?? 0\n if (!rootPayload || listLen === 0) {\n addValidationError(\n validationCtx,\n 'Publishing as a new version requires at least one property attestation for the item. ' +\n 'Ensure required fields have values and that publishable properties are present.',\n 'listOfAttestations',\n 'publish_new_version_empty_snapshot',\n )\n }\n }\n\n if (validationCtx.errors.length > 0) {\n const combinedMessage = validationCtx.errors.map((e) => e.message).join('\\n')\n throw new PublishValidationFailedError(\n `Validation failed (${validationCtx.errors.length} error${validationCtx.errors.length === 1 ? '' : 's'}):\\n${combinedMessage}`,\n validationCtx.errors,\n )\n }\n\n return multiPublishPayload\n}\n\nexport type ValidateItemForPublishResult = {\n isValid: boolean\n errors: PublishValidationError[]\n}\n\n/**\n * Validates an item for publishing without performing Arweave or EAS work.\n * Use in the checking step to fail fast before creating transactions.\n * Pass empty array for uploadedTransactions when validating before Arweave upload.\n */\nexport const validateItemForPublish = async (\n item: IItem<any>,\n uploadedTransactions: UploadedTransaction[] = [],\n options?: GetPublishPayloadOptions,\n): Promise<ValidateItemForPublishResult> => {\n try {\n await getPublishPayload(item, uploadedTransactions, options)\n return { isValid: true, errors: [] }\n } catch (err) {\n if (err instanceof PublishValidationFailedError) {\n return { isValid: false, errors: err.validationErrors }\n }\n throw err\n }\n}\n\n/**\n * Normalize a schema UID to 0x-prefixed 64-char hex for comparison.\n */\nfunction normalizeSchemaUid(v: string | undefined): string {\n if (v == null || v === '') return ''\n const raw = v.startsWith('0x') ? v.slice(2) : v\n const hex = raw.replace(/[^0-9a-fA-F]/g, '0').padStart(64, '0').slice(-64)\n return ('0x' + hex).toLowerCase()\n}\n\n/**\n * Ensure that when request A has propertiesToUpdate with (publishLocalId: B, propertySchemaUid: X),\n * request B has an attestation for schema X with at least one data element. The contract writes\n * the seed UID into data[0].data; empty data causes Panic 50.\n */\nfunction ensurePropertiesToUpdateAttestationsHaveData(\n payload: MultiPublishPayload,\n): MultiPublishPayload {\n const byLocalId = new Map<string, PublishPayload>()\n for (const p of payload) {\n byLocalId.set(p.localId, p)\n }\n\n const placeholderData: AttestationRequestData = {\n ...defaultAttestationData,\n data: ZERO_BYTES32,\n }\n\n for (const req of payload) {\n for (const pu of req.propertiesToUpdate ?? []) {\n const targetId = (pu as { publishLocalId?: string }).publishLocalId\n const schemaUid = (pu as { propertySchemaUid?: string }).propertySchemaUid\n if (!targetId || !schemaUid) continue\n\n const targetReq = byLocalId.get(targetId)\n if (!targetReq?.listOfAttestations) continue\n\n const wantSchema = normalizeSchemaUid(schemaUid)\n const att = targetReq.listOfAttestations.find(\n (a) => normalizeSchemaUid(a?.schema) === wantSchema,\n )\n if (!att) continue\n\n if (!Array.isArray(att.data) || att.data.length === 0) {\n att.data = [placeholderData]\n }\n }\n }\n\n return payload\n}\n\n/**\n * LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.\n */\nfunction collectAttestationLocalRefIds(\n req: PublishPayload,\n allLocalIds: Set<string>,\n): string[] {\n const refs: string[] = []\n for (const a of req.listOfAttestations ?? []) {\n const att = a as {\n _unresolvedValue?: string\n _rawListIdsForResolve?: string[]\n }\n if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) {\n refs.push(att._unresolvedValue)\n }\n if (Array.isArray(att._rawListIdsForResolve)) {\n for (const id of att._rawListIdsForResolve) {\n const t = id != null ? String(id).trim() : ''\n if (t && allLocalIds.has(t)) refs.push(t)\n }\n }\n }\n return refs\n}\n\n/**\n * Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.\n * - propertiesToUpdate: updater before updatee (contract injection).\n * - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.\n * The previous DFS visit could order [Post, Image] when Post appeared first in the input array,\n * so resolvedUids was empty when Post was published and attestations kept local ids.\n */\nfunction orderPayloadByDependencies(payload: MultiPublishPayload): MultiPublishPayload {\n if (payload.length <= 1) return payload\n\n const byLocalId = new Map<string, PublishPayload>()\n const allIds = new Set<string>()\n const indexOrder = new Map<string, number>()\n for (let i = 0; i < payload.length; i++) {\n const p = payload[i]\n byLocalId.set(p.localId, p)\n allIds.add(p.localId)\n indexOrder.set(p.localId, i)\n }\n\n const indegree = new Map<string, number>()\n for (const id of allIds) indegree.set(id, 0)\n\n const adj = new Map<string, Set<string>>()\n\n const addEdge = (from: string, to: string) => {\n if (from === to || !allIds.has(from) || !allIds.has(to)) return\n if (!adj.has(from)) adj.set(from, new Set())\n const set = adj.get(from)!\n if (set.has(to)) return\n set.add(to)\n indegree.set(to, (indegree.get(to) ?? 0) + 1)\n }\n\n for (const p of payload) {\n for (const u of p.propertiesToUpdate ?? []) {\n const targetId = (u as { publishLocalId?: string }).publishLocalId\n if (targetId && targetId !== p.localId) addEdge(p.localId, targetId)\n }\n for (const refId of collectAttestationLocalRefIds(p, allIds)) {\n addEdge(refId, p.localId)\n }\n }\n\n const zero: string[] = []\n for (const id of allIds) {\n if ((indegree.get(id) ?? 0) === 0) zero.push(id)\n }\n zero.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0))\n\n const result: PublishPayload[] = []\n const queue = zero\n\n while (queue.length > 0) {\n const id = queue.shift()!\n const p = byLocalId.get(id)\n if (p) result.push(p)\n for (const to of adj.get(id) ?? []) {\n const next = (indegree.get(to) ?? 0) - 1\n indegree.set(to, next)\n if (next === 0) {\n queue.push(to)\n queue.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0))\n }\n }\n }\n\n if (result.length !== payload.length) {\n const seen = new Set(result.map((r) => r.localId))\n for (const p of payload) {\n if (!seen.has(p.localId)) result.push(p)\n }\n }\n\n return result\n}\n\n/** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */\nfunction padUidForBytes32Schema(uid: string): string {\n const t = uid.trim()\n if (!t.startsWith('0x')) return uid\n const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '')\n if (hex.length === 0) return uid\n return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase()\n}\n\n/**\n * Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.\n * Call after each payload is published, passing the returned attestation uid for that seed's localId.\n * Returns an updated multiPayload with re-encoded attestations where resolution was applied.\n */\nexport const resolvePublishPayloadValues = async (\n multiPayload: MultiPublishPayload,\n resolvedUids: ResolvedSeedUids,\n): Promise<MultiPublishPayload> => {\n if (Object.keys(resolvedUids).length === 0) {\n return multiPayload\n }\n\n const result: MultiPublishPayload = []\n\n for (const payload of multiPayload) {\n const updatedAttestations: PublishPayload['listOfAttestations'] = []\n\n for (const attestation of payload.listOfAttestations) {\n const entry = attestation as PublishPayload['listOfAttestations'][0] & {\n _easDataType?: string\n _propertyNameForSchema?: string\n _rawListIdsForResolve?: string[]\n data?: AttestationRequestData[] | AttestationRequestData\n }\n\n const rawList = entry._rawListIdsForResolve\n if (\n rawList &&\n rawList.length > 0 &&\n entry._schemaDef &&\n (entry._propertyNameForSchema || entry._propertyName)\n ) {\n const fieldName =\n entry._propertyNameForSchema ?? toSnakeCase(entry._propertyName as string)\n const resolvedValues: string[] = []\n let allSlotsResolved = true\n for (const id of rawList) {\n const trimmed = id.trim()\n if (trimmed.length === 66 && trimmed.startsWith('0x')) {\n resolvedValues.push(padUidForBytes32Schema(trimmed))\n continue\n }\n const r = resolvedUids[trimmed]\n if (r) {\n resolvedValues.push(padUidForBytes32Schema(r))\n continue\n }\n allSlotsResolved = false\n break\n }\n // Do not encode or clear hints until every slot has a real uid — otherwise sequential\n // publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.\n if (!allSlotsResolved) {\n updatedAttestations.push({\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n })\n continue\n }\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: 'bytes32[]',\n value: resolvedValues,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _rawListIdsForResolve: undefined,\n _easDataType: undefined,\n })\n continue\n }\n\n const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue]\n const easType = (entry._easDataType as 'bytes32' | 'string') || 'bytes32'\n if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {\n const fieldName =\n entry._propertyNameForSchema ?? toSnakeCase(entry._propertyName as string)\n const valueForEncode =\n easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: easType,\n value: valueForEncode,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _unresolvedValue: undefined,\n })\n } else {\n const normalizedEntry: PublishPayload['listOfAttestations'][0] = {\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n }\n updatedAttestations.push(normalizedEntry)\n }\n }\n\n result.push({\n ...payload,\n listOfAttestations: updatedAttestations,\n })\n }\n\n return result\n}\n"],"names":["normalizeDataType","isValidEasAttestationUid","ZERO_BYTES32","getLatestPublishedVersionRow","INTERNAL_DATA_TYPES","ModelPropertyDataTypes","toSnakeCase","getEasSchemaUidForSchemaDefinition","getEasSchemaForItemProperty","getPropertySchema","upperFirst","camelCase","toSnakeCaseDb","modelPropertiesToObject","BaseDb","models","eq","properties","and","INTERNAL_PROPERTY_NAMES","SchemaEncoder","defaultAttestationData","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","getEasSchemaUidForModel","VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA","getSegmentedItemProperties","htmlEmbeddedImageCoPublish","parseListPropertyValueFromStorage","getCorrectId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;AACM,SAAU,mBAAmB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tB,qBAAA;AACF,iBAAA,CAAC;gBACF,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAI,KAAK,CAAC,IAA+B;gBACnG,mBAAmB,CAAC,IAAI,CAAC;AACvB,oBAAA,GAAG,KAAK;AACR,oBAAA,IAAI,EAAE;AACJ,wBAAA;AACE,4BAAA,GAAG,QAAQ;AACX,4BAAA,IAAI,EAAE,WAAW;AACQ,yBAAA;AAC5B,qBAAA;AACD,oBAAA,gBAAgB,EAAE,SAAS;AAC5B,iBAAA,CAAC;YACJ;iBAAO;AACL,gBAAA,MAAM,eAAe,GAA4C;AAC/D,oBAAA,GAAG,KAAK;oBACR,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAA8B,CAAC;iBACtF;AACD,gBAAA,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC;YAC3C;QACF;QAEA,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,GAAG,OAAO;AACV,YAAA,kBAAkB,EAAE,mBAAmB;AACxC,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,MAAM;AACf;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishUploads-DNULcrN5.js","sources":["../../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { BaseFileManager } from '@/helpers'\nimport {\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport debug from 'debug'\nimport { IItem, IItemProperty } from '@/interfaces'\nimport { getContentHash } from '@/helpers/crypto'\nimport { Item } from '@/Item/Item'\nimport type { ArweaveTransaction, TransactionTag } from '@/types/arweave'\nimport { PublishUpload } from '@/types/publish'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq } from 'drizzle-orm'\nimport { ModelPropertyDataTypes } from '@/helpers/property'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n /** When true, do not recurse into relation properties (phase 2 must not re-upload related items). */\n skipRelationRecursion?: boolean\n}\n\nconst EXTENSION_TO_MIME: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n html: 'text/html',\n htm: 'text/html',\n json: 'application/json',\n txt: 'text/plain',\n}\n\nconst getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const ext = filePathOrName.split('.').pop()?.toLowerCase()\n return ext ? EXTENSION_TO_MIME[ext] : undefined\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\nexport const prepareArweaveTransaction = async (\n data: string | Uint8Array,\n contentHash: string | undefined,\n contentType?: string,\n additionalTags?: TransactionTag[],\n): Promise<ArweaveTransaction> => {\n const tags: TransactionTag[] = []\n if (contentHash) {\n tags.push({ name: 'Content-SHA-256', value: contentHash })\n logger('contentHash', contentHash)\n logger('adding content hash tag')\n }\n if (contentType) {\n tags.push({ name: 'Content-Type', value: contentType })\n }\n if (additionalTags?.length) {\n tags.push(...additionalTags)\n }\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\n\nconst getStorageDirForDataType = (dataType: string): string => {\n switch (dataType) {\n case 'Image':\n return BaseFileManager.getFilesPath('images')\n case 'File':\n return BaseFileManager.getFilesPath('files')\n case 'Html':\n return BaseFileManager.getFilesPath('html')\n case 'Json':\n return BaseFileManager.getFilesPath('json')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nfunction decodeDataUriImage(dataUri: string): { mimeType: string; bytes: Uint8Array } | null {\n const m = DATA_URI_IMAGE.exec((dataUri ?? '').trim())\n if (!m) return null\n try {\n const mimeType = m[1]!.toLowerCase().trim()\n const base64 = m[2]!.replace(/\\s/g, '')\n const binary = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))\n return { mimeType, bytes: binary }\n } catch {\n return null\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n) => {\n const uploads: PublishUpload[] = []\n const extra = options?.arweaveUploadTags\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (dataType === ModelPropertyDataTypes.Html) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n const fileContents = await toUint8Array(fileBuffer)\n\n const contentHash = await getContentHash(fileContents)\n const contentType = getMimeTypeFromPath(refResolvedValue)\n\n const transaction = await prepareArweaveTransaction(\n fileContents,\n contentHash,\n contentType,\n extra,\n )\n\n uploads.push({\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n }\n\n return uploads\n}\n\nasync function appendCoPublishedImageUploads(\n item: IItem<any>,\n uploads: PublishUpload[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || options?.onlyHtmlStorageSeedLocalIds?.length) return uploads\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n const seen = new Set(uploads.map((u) => u.seedLocalId))\n\n for (const row of rows) {\n if (seen.has(row.imageSeedLocalId)) continue\n const imageItem = await Item.find({ seedLocalId: row.imageSeedLocalId, modelName: 'Image' })\n if (!imageItem) continue\n const st =\n imageItem.internalProperties['storageTransactionId'] ??\n imageItem.allProperties['storageTransactionId']\n const stSnap = st?.getService().getSnapshot()\n const stCtx = stSnap && 'context' in stSnap ? stSnap.context : undefined\n const stValue = typeof (stCtx as { propertyValue?: unknown } | undefined)?.propertyValue === 'string'\n ? ((stCtx as { propertyValue?: string }).propertyValue ?? '')\n : ''\n const decoded = decodeDataUriImage(stValue)\n\n const more: PublishUpload[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n const contentHash = await getContentHash(decoded.bytes)\n const transaction = await prepareArweaveTransaction(\n decoded.bytes,\n contentHash,\n decoded.mimeType,\n options?.arweaveUploadTags,\n )\n more.push({\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n transactionToSign: transaction,\n })\n }\n for (const u of more) {\n if (!seen.has(u.seedLocalId)) {\n uploads.push(u)\n seen.add(u.seedLocalId)\n }\n }\n }\n return uploads\n}\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present).\n * Does not create Arweave transactions or hit the network — use for routing (e.g. skip EAS-only)\n * when {@link getPublishUploads} would fail early (e.g. gateway unreachable during tx creation).\n */\nasync function storageSeedHasUploadCandidates(\n itemStorageSeedProperties: IItemProperty<any>[],\n): Promise<boolean> {\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n if (await BaseFileManager.pathExists(filePath)) {\n return true\n }\n }\n\n return false\n}\n\nasync function uploadPropertyWouldUpload(\n uploadProperty: UploadProperty,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n if (childUploads.length > 0) {\n return true\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n if (await uploadPropertyWouldUpload(uploadProperty, relatedItemProperty)) {\n return true\n }\n }\n\n if (await storageSeedHasUploadCandidates(itemImageProperties)) {\n return true\n }\n\n for (const relationProperty of itemRelationProperties) {\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemHasPublishUploadCandidates(relatedItem, relationProperty)) {\n return true\n }\n }\n\n return false\n}\n\nconst processUploadProperty = async (\n uploadProperty: UploadProperty,\n uploads: PublishUpload[],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const extra = options?.arweaveUploadTags\n const itemProperty = uploadProperty.itemProperty\n\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n let fileContents\n let transaction: ArweaveTransaction\n\n if (!childUploads || childUploads.length === 0) {\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return uploads\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n return uploads\n }\n\n try {\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n fileContents = await toUint8Array(fileBuffer)\n } catch (e) {\n const fs = await BaseFileManager.getFs()\n fileContents = await toUint8Array(fs.readFileSync(filePath))\n }\n }\n if (!fileContents) {\n return uploads\n }\n }\n\n if (childUploads.length > 0) {\n const separator = '===FILE_SEPARATOR==='\n // let compositeFileContents = `${itemProperty.propertyName}${separator}${mainFileContents}`\n let compositeFileContents = ''\n\n for (const childUpload of childUploads) {\n let childUploadContents\n\n const fs = await BaseFileManager.getFs()\n\n try {\n childUploadContents = await fs.promises.readFile(\n childUpload.localStoragePath,\n )\n } catch (e) {\n childUploadContents = fs.readFileSync(childUpload.localStoragePath)\n }\n\n compositeFileContents += `${separator}${childUpload.propertyName}${separator}${childUploadContents}`\n }\n\n if (typeof document !== 'undefined') {\n fileContents = new TextEncoder().encode(compositeFileContents)\n } else {\n fileContents = Buffer.from(compositeFileContents)\n }\n }\n\n if (!fileContents) {\n throw new Error(`No file contents found for ${itemProperty.propertyName}`)\n }\n\n const uint8Array = new Uint8Array(fileContents)\n\n const contentHash = await getContentHash(uint8Array)\n\n let contentType: string | undefined\n if (childUploads.length === 0 && relatedItemProperty?.localStoragePath) {\n contentType = getMimeTypeFromPath(relatedItemProperty.localStoragePath)\n } else if (childUploads.length > 0) {\n contentType = 'application/octet-stream'\n }\n\n transaction = await prepareArweaveTransaction(\n uint8Array,\n contentHash,\n contentType,\n extra,\n )\n\n let itemPropertyLocalId = relatedItemProperty\n ? relatedItemProperty.localId\n : itemProperty.localId\n let itemPropertyName = relatedItemProperty\n ? relatedItemProperty.propertyName\n : itemProperty.propertyName\n\n uploads.push({\n itemPropertyName,\n itemPropertyLocalId,\n seedLocalId: itemProperty.seedLocalId!,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n\n return uploads\n}\n\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n) => {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n if (!relatedItemProperty && options?.onlyHtmlStorageSeedLocalIds?.length) {\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n return uploads\n }\n\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadProperty(\n uploadProperty,\n uploads,\n relatedItemProperty,\n options,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n\n if (!relatedItemProperty && !options?.onlyHtmlStorageSeedLocalIds?.length) {\n uploads = await appendCoPublishedImageUploads(item, uploads, options)\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n for (const relationProperty of itemRelationProperties) {\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getPublishUploads(relatedItem, uploads, relationProperty, options)\n }\n\n return uploads\n}\n"],"names":["BaseArweaveClient","BaseFileManager","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","ModelPropertyDataTypes","getContentHash","BaseDb","htmlEmbeddedImageCoPublish","eq","Item","getSegmentedItemProperties"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAiBtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,GAAG,EAAE,YAAY;CAClB;AAED,MAAM,mBAAmB,GAAG,CAAC,cAAsB,KAAwB;AACzE,IAAA,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE;AAC1D,IAAA,OAAO,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS;AACjD,CAAC;AAED,MAAM,YAAY,GAAG,OAAO,IAAmB,KAAyB;IACtE,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IA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K82kjri.js","sources":["../../../src/helpers/relationSeedRef.ts","../../../src/helpers/getSegmentedItemProperties.ts"],"sourcesContent":["/** Same rules as getCorrectId in helpers/index (avoid barrel circular import). */\nfunction parseLocalIdOrUid(localIdOrUid: string): { localId?: string; uid?: string } {\n const id = { localId: undefined as string | undefined, uid: undefined as string | undefined }\n if (!localIdOrUid) return id\n if (localIdOrUid.length === 10) {\n id.localId = localIdOrUid\n }\n if (localIdOrUid.startsWith('0x') && localIdOrUid.length === 66) {\n id.uid = localIdOrUid\n }\n return id\n}\n\n/** Relation/image refs may be string ids or `{ seedLocalId?, seedUid? }`. */\nexport function normalizeRelationPropertyValue(value: unknown): string | undefined {\n if (value == null) return undefined\n if (typeof value === 'string') {\n const t = value.trim()\n return t !== '' ? t : undefined\n }\n if (typeof value === 'object' && value !== null) {\n const o = value as { seedLocalId?: string; seedUid?: string }\n if (typeof o.seedLocalId === 'string' && o.seedLocalId.trim() !== '') {\n return o.seedLocalId.trim()\n }\n if (typeof o.seedUid === 'string' && o.seedUid.trim() !== '') {\n return o.seedUid.trim()\n }\n }\n return undefined\n}\n\n/** getCorrectId only accepts 10-char local ids and 0x66 uids; local seed refs can be up to 21 chars. */\nconst LOCAL_SEED_REF = /^[a-zA-Z0-9_-]{10,21}$/\n\n/** Resolve seed ids from a single string (context propertyValue or DB row). */\nexport function resolveSeedIdsFromRefString(s: string): { seedLocalId?: string; seedUid?: string } {\n const fromCorrect = parseLocalIdOrUid(s)\n if (fromCorrect.localId || fromCorrect.uid) {\n return { seedLocalId: fromCorrect.localId, seedUid: fromCorrect.uid }\n }\n if (LOCAL_SEED_REF.test(s) && !s.startsWith('0x')) {\n return { seedLocalId: s }\n }\n return {}\n}\n","import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\n\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n let schema = await getPropertySchema(modelName, propertyName)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecords = await db\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (item: IItem<any>) => {\n const itemBasicProperties = []\n const itemRelationProperties = []\n const itemListProperties = []\n const itemUploadProperties: UploadProperty[] = []\n const itemImageProperties = []\n const itemStorageProperties = []\n let itemStorageTransactionProperty: UploadProperty | undefined\n\n for (const itemProperty of item.properties) {\n let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Json)))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.List)) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\n itemListProperties.push(itemProperty)\n } else {\n itemBasicProperties.push(itemProperty)\n }\n continue\n }\n\n if (isItemStorage) {\n itemStorageProperties.push(itemProperty)\n continue\n }\n\n if (isStorageTransaction) {\n itemStorageTransactionProperty = { itemProperty, childProperties: [] }\n continue\n }\n\n itemBasicProperties.push(itemProperty)\n }\n\n if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {\n itemStorageTransactionProperty.childProperties = itemStorageProperties\n }\n\n if (itemStorageTransactionProperty) {\n itemUploadProperties.push(itemStorageTransactionProperty)\n }\n\n return {\n itemBasicProperties,\n itemRelationProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n }\n}\n"],"names":["normalizeDataType","getPropertySchema","BaseDb","upperFirst","camelCase","models","eq","properties","and","ModelPropertyDataTypes"],"mappings":";;;;;;;;AAAA;AACA,SAAS,iBAAiB,CAAC,YAAoB,EAAA;IAC7C,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,SAA+B,EAAE,GAAG,EAAE,SAA+B,EAAE;AAC7F,IAAA,IAAI,CAAC,YAAY;AAAE,QAAA,OAAO,EAAE;AAC5B,IAAA,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE;AAC9B,QAAA,EAAE,CAAC,OAAO,GAAG,YAAY;IAC3B;AACA,IAAA,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE;AAC/D,QAAA,EAAE,CAAC,GAAG,GAAG,YAAY;IACvB;AACA,IAAA,OAAO,EAAE;AACX;AAEA;AACM,SAAU,8BAA8B,CAAC,KAAc,EAAA;IAC3D,IAAI,KAAK,IAAI,IAAI;AAAE,QAAA,OAAO,SAAS;AACnC,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,MAAM,CAAC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