@seedprotocol/sdk 0.4.5 → 0.4.6
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/{ArweaveClient-CgWK-JgT.js → ArweaveClient-Caio37h1.js} +3 -3
- package/dist/ArweaveClient-Caio37h1.js.map +1 -0
- package/dist/{ArweaveClient-WcG8CZAE.js → ArweaveClient-DLKAaS3K.js} +3 -3
- package/dist/ArweaveClient-DLKAaS3K.js.map +1 -0
- package/dist/{Db-DjFdIdR9.js → Db-C9fppVRl.js} +3 -3
- package/dist/Db-C9fppVRl.js.map +1 -0
- package/dist/{Db-DjofXdeU.js → Db-DJAG-5Di.js} +7 -5
- package/dist/Db-DJAG-5Di.js.map +1 -0
- package/dist/{EasClient-Aojewp6P.js → EasClient-DQGAIj-b.js} +2 -2
- package/dist/EasClient-DQGAIj-b.js.map +1 -0
- package/dist/{EasClient-BVFXp2O6.js → EasClient-T7Nx9185.js} +2 -2
- package/dist/EasClient-T7Nx9185.js.map +1 -0
- package/dist/{FileManager-C9zr4AJe.js → FileManager-BohtoKYo.js} +4 -3
- package/dist/FileManager-BohtoKYo.js.map +1 -0
- package/dist/{FileManager-CxGJLw5C.js → FileManager-d64CkqXy.js} +2 -2
- package/dist/FileManager-d64CkqXy.js.map +1 -0
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/service/actors/fetchDataFromEas.d.ts.map +1 -1
- package/dist/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/Item/service/actors/runPublish.d.ts.map +1 -1
- package/dist/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/Model/Model.d.ts.map +1 -1
- package/dist/Model/service/actors/createModelProperties.d.ts.map +1 -1
- package/dist/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
- package/dist/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/saveToSchema.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/{ModelProperty-CGdkocQ8.js → ModelProperty-Cpd9xiIM.js} +52 -18
- package/dist/ModelProperty-Cpd9xiIM.js.map +1 -0
- package/dist/{PathResolver-CX6GHoTS.js → PathResolver-CLZUWoX2.js} +2 -2
- package/dist/PathResolver-CLZUWoX2.js.map +1 -0
- package/dist/{PathResolver-z_WX47_o.js → PathResolver-D6M0rzKV.js} +2 -2
- package/dist/PathResolver-D6M0rzKV.js.map +1 -0
- package/dist/{QueryClient-ByKPdRmE.js → QueryClient-BUoz2Vb0.js} +2 -2
- package/dist/QueryClient-BUoz2Vb0.js.map +1 -0
- package/dist/{QueryClient-Cb1iJO-x.js → QueryClient-COQ_Rs4-.js} +2 -2
- package/dist/QueryClient-COQ_Rs4-.js.map +1 -0
- package/dist/Schema/Schema.d.ts.map +1 -1
- package/dist/Schema/service/actors/createModelInstances.d.ts.map +1 -1
- package/dist/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/Schema/service/actors/verifyModelInstancesInCache.d.ts.map +1 -1
- package/dist/Schema/service/actors/writePropertiesToDb.d.ts.map +1 -1
- package/dist/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/{Schema-D1eqDHyt.js → Schema-BZKBy5Tx.js} +63 -24
- package/dist/Schema-BZKBy5Tx.js.map +1 -0
- package/dist/{SchemaValidationService-DyttFaV_.js → SchemaValidationService-F8No7BHp.js} +2 -2
- package/dist/SchemaValidationService-F8No7BHp.js.map +1 -0
- package/dist/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/browser/react/itemProperty.d.ts.map +1 -1
- package/dist/cjs/{ModelProperty-BeJvgKMw.js → ModelProperty-B4pV91tc.js} +32 -18
- package/dist/cjs/ModelProperty-B4pV91tc.js.map +1 -0
- package/dist/cjs/{Schema-CVs9J6eP.js → Schema-TErl3J36.js} +33 -24
- package/dist/cjs/Schema-TErl3J36.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-CDKcVRFQ.js → SchemaValidationService-p5BbJV9T.js} +2 -2
- package/dist/cjs/{SchemaValidationService-CDKcVRFQ.js.map → SchemaValidationService-p5BbJV9T.js.map} +1 -1
- package/dist/cjs/{getItem-B5RYPvrG.js → getItem-BrnLfC12.js} +2 -2
- package/dist/cjs/{getItem-B5RYPvrG.js.map → getItem-BrnLfC12.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-BD1qRob1.js → getPublishPayload-BcjCN_bD.js} +7 -5
- package/dist/cjs/getPublishPayload-BcjCN_bD.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CnC9aYxs.js → getPublishUploads-5_oXzwol.js} +3 -3
- package/dist/cjs/{getPublishUploads-CnC9aYxs.js.map → getPublishUploads-5_oXzwol.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-B_njnntx.js → getSegmentedItemProperties-WFdizUDv.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-B_njnntx.js.map → getSegmentedItemProperties-WFdizUDv.js.map} +1 -1
- package/dist/cjs/{index-Dnywap_P.js → index-BrmvhXsG.js} +2 -2
- package/dist/cjs/index-BrmvhXsG.js.map +1 -0
- package/dist/cjs/{index-BeKPbbk0.js → index-CXI4VF1H.js} +330 -88
- package/dist/cjs/index-CXI4VF1H.js.map +1 -0
- package/dist/db/read/getModelSchemas.d.ts.map +1 -1
- package/dist/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/db/write/createNewItem.d.ts.map +1 -1
- package/dist/eas.d.ts.map +1 -1
- package/dist/events/files/download.d.ts.map +1 -1
- package/dist/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/{getItem-BB5HBCbK.js → getItem-DaQVdeae.js} +2 -2
- package/dist/getItem-DaQVdeae.js.map +1 -0
- package/dist/{getPublishPayload-uLm0AqN_.js → getPublishPayload-CWiLI1yd.js} +7 -5
- package/dist/getPublishPayload-CWiLI1yd.js.map +1 -0
- package/dist/{getPublishUploads-Dc-HqhO8.js → getPublishUploads-DhvcKD_9.js} +3 -3
- package/dist/getPublishUploads-DhvcKD_9.js.map +1 -0
- package/dist/{getSegmentedItemProperties-BrIqFNfD.js → getSegmentedItemProperties-Cp4kcWIF.js} +2 -2
- package/dist/getSegmentedItemProperties-Cp4kcWIF.js.map +1 -0
- package/dist/helpers/db.d.ts.map +1 -1
- package/dist/helpers/property.d.ts.map +1 -1
- package/dist/helpers/updateSchema.d.ts.map +1 -1
- package/dist/imports/json.d.ts.map +1 -1
- package/dist/{index-2FcQHgKp.js → index-DBy53qbb.js} +2 -2
- package/dist/index-DBy53qbb.js.map +1 -0
- package/dist/{index-DPll6EAp.js → index-Dk73a7JE.js} +343 -97
- package/dist/index-Dk73a7JE.js.map +1 -0
- package/dist/{index-LEY0Og1p.js → index-LfXKx_PE.js} +3 -3
- package/dist/index-LfXKx_PE.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +11 -8
- package/dist/main.js.map +1 -1
- package/dist/node/db/Db.d.ts.map +1 -1
- package/dist/node.js +10 -10
- package/dist/node.js.map +1 -1
- package/dist/{property-B15X7jLX.js → property-1o2MvYTm.js} +10 -4
- package/dist/property-1o2MvYTm.js.map +1 -0
- package/dist/{queries-BPDSpiEX.js → queries-DA4G0iEN.js} +2 -2
- package/dist/queries-DA4G0iEN.js.map +1 -0
- package/dist/services/publish/actors/preparePublishRequestData.d.ts.map +1 -1
- package/dist/services/publish/actors/upload.d.ts.map +1 -1
- package/dist/services/write/actors/validateEntity.d.ts.map +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +3 -3
- package/dist/ArweaveClient-CgWK-JgT.js.map +0 -1
- package/dist/ArweaveClient-WcG8CZAE.js.map +0 -1
- package/dist/Db-DjFdIdR9.js.map +0 -1
- package/dist/Db-DjofXdeU.js.map +0 -1
- package/dist/EasClient-Aojewp6P.js.map +0 -1
- package/dist/EasClient-BVFXp2O6.js.map +0 -1
- package/dist/FileManager-C9zr4AJe.js.map +0 -1
- package/dist/FileManager-CxGJLw5C.js.map +0 -1
- package/dist/ModelProperty-CGdkocQ8.js.map +0 -1
- package/dist/PathResolver-CX6GHoTS.js.map +0 -1
- package/dist/PathResolver-z_WX47_o.js.map +0 -1
- package/dist/QueryClient-ByKPdRmE.js.map +0 -1
- package/dist/QueryClient-Cb1iJO-x.js.map +0 -1
- package/dist/Schema-D1eqDHyt.js.map +0 -1
- package/dist/SchemaValidationService-DyttFaV_.js.map +0 -1
- package/dist/cjs/ModelProperty-BeJvgKMw.js.map +0 -1
- package/dist/cjs/Schema-CVs9J6eP.js.map +0 -1
- package/dist/cjs/getPublishPayload-BD1qRob1.js.map +0 -1
- package/dist/cjs/index-BeKPbbk0.js.map +0 -1
- package/dist/cjs/index-Dnywap_P.js.map +0 -1
- package/dist/getItem-BB5HBCbK.js.map +0 -1
- package/dist/getPublishPayload-uLm0AqN_.js.map +0 -1
- package/dist/getPublishUploads-Dc-HqhO8.js.map +0 -1
- package/dist/getSegmentedItemProperties-BrIqFNfD.js.map +0 -1
- package/dist/index-2FcQHgKp.js.map +0 -1
- package/dist/index-DPll6EAp.js.map +0 -1
- package/dist/index-LEY0Og1p.js.map +0 -1
- package/dist/property-B15X7jLX.js.map +0 -1
- package/dist/queries-BPDSpiEX.js.map +0 -1
|
@@ -464,6 +464,30 @@ const generateId = () => {
|
|
|
464
464
|
const toSnakeCase = (str) => {
|
|
465
465
|
return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
466
466
|
};
|
|
467
|
+
const identifyString = (str) => {
|
|
468
|
+
try {
|
|
469
|
+
JSON.parse(str);
|
|
470
|
+
return 'json';
|
|
471
|
+
}
|
|
472
|
+
catch (e) {
|
|
473
|
+
// Not JSON
|
|
474
|
+
}
|
|
475
|
+
if (!str) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (str.trim().startsWith('<') && str.trim().endsWith('>')) {
|
|
479
|
+
return 'html';
|
|
480
|
+
}
|
|
481
|
+
// Simple markdown checks (very naive)
|
|
482
|
+
if (/^#{1,6}\s|^-{3,}|\*{3,}|^-{1,2}\s|\*\s/.test(str)) {
|
|
483
|
+
return 'markdown';
|
|
484
|
+
}
|
|
485
|
+
if (/^data:image\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/.test(str)) {
|
|
486
|
+
return 'base64';
|
|
487
|
+
}
|
|
488
|
+
// Default to plain text if unsure
|
|
489
|
+
return 'text';
|
|
490
|
+
};
|
|
467
491
|
const getMimeType = (base64) => {
|
|
468
492
|
if (!base64) {
|
|
469
493
|
return null;
|
|
@@ -541,6 +565,21 @@ const convertTxIdToImage = async (txId) => {
|
|
|
541
565
|
const imageBlob = new Blob([uint]);
|
|
542
566
|
return URL.createObjectURL(imageBlob);
|
|
543
567
|
};
|
|
568
|
+
/**
|
|
569
|
+
* Constructs an Arweave URL for a storage transaction ID
|
|
570
|
+
* @param storageTransactionId - The Arweave transaction ID
|
|
571
|
+
* @returns The full URL to access the transaction data on Arweave (e.g., https://arweave.net/raw/{transactionId})
|
|
572
|
+
* @deprecated Use BaseArweaveClient.getRawUrl() instead for better consistency and testability
|
|
573
|
+
*/
|
|
574
|
+
const getArweaveUrlForTransaction = (storageTransactionId) => {
|
|
575
|
+
return BaseArweaveClient.getRawUrl(storageTransactionId);
|
|
576
|
+
};
|
|
577
|
+
const getExecutionTime = async (task, args) => {
|
|
578
|
+
const start = Date.now();
|
|
579
|
+
await task(...args);
|
|
580
|
+
return Date.now() - start;
|
|
581
|
+
};
|
|
582
|
+
const capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1);
|
|
544
583
|
const parseEasRelationPropertyName = (easPropertyName) => {
|
|
545
584
|
// Split the input string on the first underscore
|
|
546
585
|
const [singularProperty, modelName, idSegment] = easPropertyName.split('_');
|
|
@@ -556,6 +595,25 @@ const parseEasRelationPropertyName = (easPropertyName) => {
|
|
|
556
595
|
isList, // True if the property is a list (e.g., 'ids' is present)
|
|
557
596
|
};
|
|
558
597
|
};
|
|
598
|
+
const isBinary = (arrayBuffer) => {
|
|
599
|
+
const view = new Uint8Array(arrayBuffer);
|
|
600
|
+
let nonTextCount = 0;
|
|
601
|
+
const threshold = 0.2; // Adjust as needed (e.g., 20% non-text implies binary)
|
|
602
|
+
for (let i = 0; i < view.length; i++) {
|
|
603
|
+
const byte = view[i];
|
|
604
|
+
// ASCII printable characters (32-126) and common whitespace (9, 10, 13)
|
|
605
|
+
if ((byte >= 32 && byte <= 126) || // Printable ASCII
|
|
606
|
+
byte === 9 || byte === 10 || byte === 13 // Tab, LF, CR
|
|
607
|
+
) {
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
nonTextCount++;
|
|
611
|
+
if (nonTextCount / view.length > threshold) {
|
|
612
|
+
return true; // More than threshold are non-text bytes
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return false; // Fewer than threshold are non-text bytes
|
|
616
|
+
};
|
|
559
617
|
|
|
560
618
|
var index = /*#__PURE__*/Object.freeze({
|
|
561
619
|
__proto__: null,
|
|
@@ -563,11 +621,16 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
563
621
|
BaseEasClient: BaseEasClient,
|
|
564
622
|
BaseFileManager: BaseFileManager,
|
|
565
623
|
BaseQueryClient: BaseQueryClient,
|
|
624
|
+
capitalizeFirstLetter: capitalizeFirstLetter,
|
|
566
625
|
convertTxIdToImage: convertTxIdToImage,
|
|
567
626
|
generateId: generateId,
|
|
627
|
+
getArweaveUrlForTransaction: getArweaveUrlForTransaction,
|
|
568
628
|
getCorrectId: getCorrectId,
|
|
569
629
|
getDataTypeFromString: getDataTypeFromString,
|
|
630
|
+
getExecutionTime: getExecutionTime,
|
|
570
631
|
getMimeType: getMimeType,
|
|
632
|
+
identifyString: identifyString,
|
|
633
|
+
isBinary: isBinary,
|
|
571
634
|
parseEasRelationPropertyName: parseEasRelationPropertyName,
|
|
572
635
|
toSnakeCase: toSnakeCase,
|
|
573
636
|
waitForEntityIdle: waitForEntityIdle
|
|
@@ -584,7 +647,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
584
647
|
return;
|
|
585
648
|
}
|
|
586
649
|
try {
|
|
587
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
650
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B4pV91tc.js'); });
|
|
588
651
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
589
652
|
if (!ModelProperty) {
|
|
590
653
|
logger$x('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -667,7 +730,8 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
667
730
|
// schemaFileId to match the database, both will point to the same cached instance.
|
|
668
731
|
if (dbSchemaFileId) {
|
|
669
732
|
try {
|
|
670
|
-
const
|
|
733
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
734
|
+
const { Model } = modelMod;
|
|
671
735
|
// Access instanceCacheById via type assertion since it's protected
|
|
672
736
|
const cacheById = Model.instanceCacheById;
|
|
673
737
|
if (cacheById.has(dbSchemaFileId)) {
|
|
@@ -772,7 +836,8 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
772
836
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
773
837
|
// This handles the case where model exists in schema file but not yet in database
|
|
774
838
|
try {
|
|
775
|
-
const
|
|
839
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TErl3J36.js'); }).then(function (n) { return n.Schema$1; });
|
|
840
|
+
const { Schema } = schemaMod;
|
|
776
841
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
777
842
|
const schemaSnapshot = schema.getService().getSnapshot();
|
|
778
843
|
// Wait for schema to load if it's still loading
|
|
@@ -843,7 +908,8 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
843
908
|
let finalModelName = modelName;
|
|
844
909
|
if (db) {
|
|
845
910
|
// Check if this is an internal schema (Seed Protocol)
|
|
846
|
-
const
|
|
911
|
+
const constantsMod = await Promise.resolve().then(function () { return constants; });
|
|
912
|
+
const { isInternalSchema } = constantsMod;
|
|
847
913
|
const isInternal = isInternalSchema(schemaName);
|
|
848
914
|
// Only skip duplicate check if:
|
|
849
915
|
// 1. We found a model record to use (modelRecord is set), OR
|
|
@@ -858,7 +924,8 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
858
924
|
const existingNumbers = new Set(existingNumbersFromSchemaContext ?? []);
|
|
859
925
|
// First, check Model cache for models (includes models from imported schemas that may not be in DB yet)
|
|
860
926
|
try {
|
|
861
|
-
const
|
|
927
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
928
|
+
const { Model } = modelMod;
|
|
862
929
|
// Check name-based cache for this schema
|
|
863
930
|
// Skip the current model (context.id): Model.create() adds the new instance to the cache
|
|
864
931
|
// before this callback runs, so we must not count it as a duplicate.
|
|
@@ -917,8 +984,10 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
917
984
|
}
|
|
918
985
|
// Also check database for models (in case they're persisted but not in Schema context)
|
|
919
986
|
if (db) {
|
|
920
|
-
const
|
|
921
|
-
const {
|
|
987
|
+
const modelSchemaSchemaMod = await Promise.resolve().then(function () { return ModelSchemaSchema; });
|
|
988
|
+
const { modelSchemas } = modelSchemaSchemaMod;
|
|
989
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
990
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
922
991
|
// Query all models for this schema to check for duplicates (case-insensitive)
|
|
923
992
|
logger$x(`Checking database for duplicate model names in schema "${schemaName}"`);
|
|
924
993
|
const allModelsForSchema = await db
|
|
@@ -991,7 +1060,8 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
991
1060
|
}
|
|
992
1061
|
// Runtime creates use a placeholder cache key in Model.create; move it to the final name. Skip when schema model (_idFromSchema).
|
|
993
1062
|
if (!_idFromSchema) {
|
|
994
|
-
const
|
|
1063
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
1064
|
+
const { Model } = modelMod;
|
|
995
1065
|
Model.updateNameIndex('__pending__' + schemaFileId, finalModelName, schemaName, schemaFileId);
|
|
996
1066
|
}
|
|
997
1067
|
// If model name was changed, store it in a temporary internal field so loadOrCreateModelSuccess can apply it
|
|
@@ -1010,7 +1080,8 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
1010
1080
|
}
|
|
1011
1081
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
1012
1082
|
try {
|
|
1013
|
-
const
|
|
1083
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TErl3J36.js'); }).then(function (n) { return n.Schema$1; });
|
|
1084
|
+
const { Schema } = schemaMod;
|
|
1014
1085
|
const schema = Schema.create(schemaName, { waitForReady: false });
|
|
1015
1086
|
schema.getService().send({ type: 'markAsDraft', propertyKey: 'schema:models' });
|
|
1016
1087
|
}
|
|
@@ -1053,9 +1124,11 @@ const validateModel = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
1053
1124
|
const _validateModel = async () => {
|
|
1054
1125
|
try {
|
|
1055
1126
|
// Use dynamic imports to break circular dependencies
|
|
1056
|
-
const
|
|
1127
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-p5BbJV9T.js'); });
|
|
1128
|
+
const { SchemaValidationService } = validationServiceMod;
|
|
1057
1129
|
const validationService = new SchemaValidationService();
|
|
1058
|
-
const
|
|
1130
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TErl3J36.js'); }).then(function (n) { return n.Schema$1; });
|
|
1131
|
+
const { Schema } = schemaMod;
|
|
1059
1132
|
// Validate model structure
|
|
1060
1133
|
const structureResult = validationService.validateModelStructure(context);
|
|
1061
1134
|
if (!structureResult.isValid) {
|
|
@@ -1166,19 +1239,21 @@ const createModelProperties = xstate.fromCallback(({ sendBack, input }) => {
|
|
|
1166
1239
|
return;
|
|
1167
1240
|
}
|
|
1168
1241
|
logger$v(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
1169
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
1242
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B4pV91tc.js'); });
|
|
1170
1243
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1171
1244
|
if (!ModelProperty) {
|
|
1172
1245
|
logger$v('ModelProperty not available from dynamic import');
|
|
1173
1246
|
sendBack({ type: 'createModelPropertiesError', error: new Error('ModelProperty not available') });
|
|
1174
1247
|
return;
|
|
1175
1248
|
}
|
|
1176
|
-
const
|
|
1249
|
+
const drizzleMod = await import('drizzle-orm');
|
|
1250
|
+
const { eq } = drizzleMod;
|
|
1177
1251
|
const db = BaseDb.getAppDb();
|
|
1178
1252
|
for (const [propName, propData] of Object.entries(propertyDefinitions)) {
|
|
1179
1253
|
// Use provided ID or generate a random one
|
|
1180
1254
|
// IDs should be generated in the import process before creating properties
|
|
1181
|
-
const
|
|
1255
|
+
const helpersMod = await Promise.resolve().then(function () { return index; });
|
|
1256
|
+
const { generateId } = helpersMod;
|
|
1182
1257
|
const propertyFileId = propData.id || generateId();
|
|
1183
1258
|
logger$v(`Creating property "${propName}" with fileId "${propertyFileId}"`);
|
|
1184
1259
|
// Query database to get refModelId if the property has ref/refModelName
|
|
@@ -1269,7 +1344,8 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1269
1344
|
logger$u(structureMsg);
|
|
1270
1345
|
console.log(structureMsg); // Always log to console
|
|
1271
1346
|
// Use existing Model validation
|
|
1272
|
-
const
|
|
1347
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-p5BbJV9T.js'); });
|
|
1348
|
+
const { SchemaValidationService } = validationServiceMod;
|
|
1273
1349
|
const validationService = new SchemaValidationService();
|
|
1274
1350
|
// Validate model structure
|
|
1275
1351
|
const structureResult = validationService.validateModelStructure(entityInput.entityData);
|
|
@@ -1287,7 +1363,8 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1287
1363
|
if (entityInput.entityData.schemaName) {
|
|
1288
1364
|
try {
|
|
1289
1365
|
logger$u(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
|
|
1290
|
-
const
|
|
1366
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TErl3J36.js'); }).then(function (n) { return n.Schema$1; });
|
|
1367
|
+
const { Schema } = schemaMod;
|
|
1291
1368
|
const schema = Schema.create(entityInput.entityData.schemaName, {
|
|
1292
1369
|
waitForReady: false,
|
|
1293
1370
|
});
|
|
@@ -1322,7 +1399,8 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1322
1399
|
}
|
|
1323
1400
|
else if (entityInput.entityType === 'modelProperty') {
|
|
1324
1401
|
// Use existing ModelProperty validation
|
|
1325
|
-
const
|
|
1402
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-p5BbJV9T.js'); });
|
|
1403
|
+
const { SchemaValidationService } = validationServiceMod;
|
|
1326
1404
|
const validationService = new SchemaValidationService();
|
|
1327
1405
|
// Validate property structure
|
|
1328
1406
|
const structureResult = validationService.validatePropertyStructure(entityInput.entityData);
|
|
@@ -1336,7 +1414,8 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1336
1414
|
// If schema name and model name provided, validate against schema
|
|
1337
1415
|
if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
|
|
1338
1416
|
try {
|
|
1339
|
-
const
|
|
1417
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TErl3J36.js'); }).then(function (n) { return n.Schema$1; });
|
|
1418
|
+
const { Schema } = schemaMod;
|
|
1340
1419
|
const schema = Schema.create(entityInput.entityData._schemaName, {
|
|
1341
1420
|
waitForReady: false,
|
|
1342
1421
|
});
|
|
@@ -1364,7 +1443,8 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
|
|
|
1364
1443
|
}
|
|
1365
1444
|
else if (entityInput.entityType === 'schema') {
|
|
1366
1445
|
// Schema validation - use existing validation
|
|
1367
|
-
const
|
|
1446
|
+
const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-p5BbJV9T.js'); });
|
|
1447
|
+
const { SchemaValidationService } = validationServiceMod;
|
|
1368
1448
|
const validationService = new SchemaValidationService();
|
|
1369
1449
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
1370
1450
|
if (!schemaResult.isValid) {
|
|
@@ -1542,6 +1622,42 @@ const escapeSqliteString = (value) => {
|
|
|
1542
1622
|
}
|
|
1543
1623
|
return value.replace(/'/g, "''");
|
|
1544
1624
|
};
|
|
1625
|
+
const getObjectForRow = (row) => {
|
|
1626
|
+
const obj = {};
|
|
1627
|
+
row.columnNames.forEach((colName, index) => {
|
|
1628
|
+
const value = row.row[index];
|
|
1629
|
+
if (typeof value !== 'string') {
|
|
1630
|
+
obj[colName] = row.row[index];
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
// Try to parse the value as JSON
|
|
1634
|
+
try {
|
|
1635
|
+
obj[colName] = JSON.parse(value);
|
|
1636
|
+
}
|
|
1637
|
+
catch (e) {
|
|
1638
|
+
// If it fails, just set the value as a string
|
|
1639
|
+
obj[colName] = value;
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
return obj;
|
|
1643
|
+
};
|
|
1644
|
+
const getSqlResultObject = (queryResult) => {
|
|
1645
|
+
if (!queryResult || !queryResult.rows || queryResult.rows.length === 0) {
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
let obj;
|
|
1649
|
+
if (queryResult.rows.length === 1) {
|
|
1650
|
+
obj = getObjectForRow(queryResult.rows[0]);
|
|
1651
|
+
}
|
|
1652
|
+
if (queryResult.rows.length > 1) {
|
|
1653
|
+
obj = queryResult.rows.reduce((acc, row) => {
|
|
1654
|
+
const rowObj = getObjectForRow(row);
|
|
1655
|
+
acc.push(rowObj);
|
|
1656
|
+
return acc;
|
|
1657
|
+
}, []);
|
|
1658
|
+
}
|
|
1659
|
+
return obj;
|
|
1660
|
+
};
|
|
1545
1661
|
const createOrUpdate = async (db, table, values) => {
|
|
1546
1662
|
const valueFilters = [];
|
|
1547
1663
|
const propertiesToExcludeFromDb = ['ref'];
|
|
@@ -1877,7 +1993,7 @@ async function checkIfPropertyIsEdited(modelName, propertyName, schemaFileValue)
|
|
|
1877
1993
|
const cacheKey = `${modelName}:${propertyName}`;
|
|
1878
1994
|
// First, check the in-memory cache (for current session edits)
|
|
1879
1995
|
// Robust dynamic import for consumer re-bundling (named or default export)
|
|
1880
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
1996
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B4pV91tc.js'); });
|
|
1881
1997
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1882
1998
|
if (!ModelProperty) {
|
|
1883
1999
|
logger$t('ModelProperty not available from dynamic import');
|
|
@@ -2120,7 +2236,8 @@ const addModelsToDb$1 = async (models, schema, modelRenames, schemaFileData) =>
|
|
|
2120
2236
|
schema = pendingProperties;
|
|
2121
2237
|
}
|
|
2122
2238
|
else {
|
|
2123
|
-
const
|
|
2239
|
+
const modelHelpersMod = await Promise.resolve().then(function () { return model; });
|
|
2240
|
+
const { modelPropertiesToObject } = modelHelpersMod;
|
|
2124
2241
|
const modelProperties = modelClass.properties || [];
|
|
2125
2242
|
schema = modelPropertiesToObject(modelProperties);
|
|
2126
2243
|
}
|
|
@@ -2140,7 +2257,8 @@ const addModelsToDb$1 = async (models, schema, modelRenames, schemaFileData) =>
|
|
|
2140
2257
|
// If no propertyFileId from map, generate a random ID
|
|
2141
2258
|
// IDs should be generated in the import process before calling addModelsToDb
|
|
2142
2259
|
if (!propertyFileId) {
|
|
2143
|
-
const
|
|
2260
|
+
const helpersIndexMod = await Promise.resolve().then(function () { return index; });
|
|
2261
|
+
const { generateId } = helpersIndexMod;
|
|
2144
2262
|
propertyFileId = generateId();
|
|
2145
2263
|
logger$t(`Generated propertyFileId "${propertyFileId}" for property "${modelName}:${propertyName}" (not found in propertyFileIds map)`);
|
|
2146
2264
|
}
|
|
@@ -2685,7 +2803,8 @@ async function writeModelToDb(modelFileId, data) {
|
|
|
2685
2803
|
throw new Error(`Model with id ${modelId} does not exist in database. Cannot create join record.`);
|
|
2686
2804
|
}
|
|
2687
2805
|
// Verify schemaId exists and get name/fileId for invalidation broadcast
|
|
2688
|
-
const
|
|
2806
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
2807
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
2689
2808
|
const schemaCheck = await db
|
|
2690
2809
|
.select({
|
|
2691
2810
|
id: schemasTable.id,
|
|
@@ -2751,7 +2870,8 @@ async function writeModelToDb(modelFileId, data) {
|
|
|
2751
2870
|
else {
|
|
2752
2871
|
// Generate random propertyFileId
|
|
2753
2872
|
// IDs should be generated in the import process before calling writeModelToDb
|
|
2754
|
-
const
|
|
2873
|
+
const helpersIndexMod = await Promise.resolve().then(function () { return index; });
|
|
2874
|
+
const { generateId } = helpersIndexMod;
|
|
2755
2875
|
propertyFileId = generateId();
|
|
2756
2876
|
logger$t(`Generated propertyFileId "${propertyFileId}" for property "${data.modelName}:${propName}"`);
|
|
2757
2877
|
}
|
|
@@ -2877,6 +2997,68 @@ async function writePropertyToDb(propertyFileId, data, isEdited = false) {
|
|
|
2877
2997
|
}
|
|
2878
2998
|
}
|
|
2879
2999
|
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Get schema database ID from schema name or schemaFileId
|
|
3002
|
+
* @param schemaNameOrFileId - Schema name (string) or schemaFileId (string)
|
|
3003
|
+
* @returns Schema database ID
|
|
3004
|
+
* @throws Error if schema not found
|
|
3005
|
+
*/
|
|
3006
|
+
async function getSchemaId(schemaNameOrFileId) {
|
|
3007
|
+
const db = BaseDb.getAppDb();
|
|
3008
|
+
if (!db) {
|
|
3009
|
+
throw new Error('Database not available');
|
|
3010
|
+
}
|
|
3011
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
3012
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
3013
|
+
const drizzleMod = await import('drizzle-orm');
|
|
3014
|
+
const { eq, desc } = drizzleMod;
|
|
3015
|
+
// Try to find by schemaFileId first (more reliable)
|
|
3016
|
+
let records = await db
|
|
3017
|
+
.select()
|
|
3018
|
+
.from(schemasTable)
|
|
3019
|
+
.where(eq(schemasTable.schemaFileId, schemaNameOrFileId))
|
|
3020
|
+
.orderBy(desc(schemasTable.version))
|
|
3021
|
+
.limit(1);
|
|
3022
|
+
// If not found by schemaFileId, try by name
|
|
3023
|
+
if (records.length === 0) {
|
|
3024
|
+
records = await db
|
|
3025
|
+
.select()
|
|
3026
|
+
.from(schemasTable)
|
|
3027
|
+
.where(eq(schemasTable.name, schemaNameOrFileId))
|
|
3028
|
+
.orderBy(desc(schemasTable.version))
|
|
3029
|
+
.limit(1);
|
|
3030
|
+
}
|
|
3031
|
+
if (records.length === 0) {
|
|
3032
|
+
throw new Error(`Schema "${schemaNameOrFileId}" not found in database`);
|
|
3033
|
+
}
|
|
3034
|
+
return records[0].id;
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
* Get schema database ID from schemaFileId
|
|
3038
|
+
* @param schemaFileId - The schema file ID
|
|
3039
|
+
* @returns Schema database ID
|
|
3040
|
+
* @throws Error if schema not found
|
|
3041
|
+
*/
|
|
3042
|
+
async function getSchemaIdByFileId(schemaFileId) {
|
|
3043
|
+
const db = BaseDb.getAppDb();
|
|
3044
|
+
if (!db) {
|
|
3045
|
+
throw new Error('Database not available');
|
|
3046
|
+
}
|
|
3047
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
3048
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
3049
|
+
const drizzleMod = await import('drizzle-orm');
|
|
3050
|
+
const { eq, desc } = drizzleMod;
|
|
3051
|
+
const records = await db
|
|
3052
|
+
.select()
|
|
3053
|
+
.from(schemasTable)
|
|
3054
|
+
.where(eq(schemasTable.schemaFileId, schemaFileId))
|
|
3055
|
+
.orderBy(desc(schemasTable.version))
|
|
3056
|
+
.limit(1);
|
|
3057
|
+
if (records.length === 0) {
|
|
3058
|
+
throw new Error(`Schema with file ID "${schemaFileId}" not found in database`);
|
|
3059
|
+
}
|
|
3060
|
+
return records[0].id;
|
|
3061
|
+
}
|
|
2880
3062
|
/**
|
|
2881
3063
|
* Get model database ID from model name or modelFileId
|
|
2882
3064
|
* @param modelNameOrFileId - Model name (string) or modelFileId (string)
|
|
@@ -2889,8 +3071,10 @@ async function getModelId(modelNameOrFileId, schemaNameOrId) {
|
|
|
2889
3071
|
if (!db) {
|
|
2890
3072
|
throw new Error('Database not available');
|
|
2891
3073
|
}
|
|
2892
|
-
const
|
|
2893
|
-
const {
|
|
3074
|
+
const modelSchemaMod = await Promise.resolve().then(function () { return ModelSchema; });
|
|
3075
|
+
const { models: modelsTable } = modelSchemaMod;
|
|
3076
|
+
const drizzleMod = await import('drizzle-orm');
|
|
3077
|
+
const { eq, and, or } = drizzleMod;
|
|
2894
3078
|
// Try to find by modelFileId first (more reliable)
|
|
2895
3079
|
let records = await db
|
|
2896
3080
|
.select()
|
|
@@ -2902,8 +3086,10 @@ async function getModelId(modelNameOrFileId, schemaNameOrId) {
|
|
|
2902
3086
|
[eq(modelsTable.name, modelNameOrFileId)];
|
|
2903
3087
|
// If schema is provided, narrow the search
|
|
2904
3088
|
if (schemaNameOrId !== undefined) {
|
|
2905
|
-
const
|
|
2906
|
-
const {
|
|
3089
|
+
const modelSchemaSchemaMod = await Promise.resolve().then(function () { return ModelSchemaSchema; });
|
|
3090
|
+
const { modelSchemas } = modelSchemaSchemaMod;
|
|
3091
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
3092
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
2907
3093
|
if (typeof schemaNameOrId === 'number') {
|
|
2908
3094
|
// schemaNameOrId is schemaId
|
|
2909
3095
|
records = await db
|
|
@@ -2950,8 +3136,10 @@ async function getModelIdByFileId(modelFileId) {
|
|
|
2950
3136
|
if (!db) {
|
|
2951
3137
|
throw new Error('Database not available');
|
|
2952
3138
|
}
|
|
2953
|
-
const
|
|
2954
|
-
const {
|
|
3139
|
+
const modelSchemaMod = await Promise.resolve().then(function () { return ModelSchema; });
|
|
3140
|
+
const { models: modelsTable } = modelSchemaMod;
|
|
3141
|
+
const drizzleMod = await import('drizzle-orm');
|
|
3142
|
+
const { eq } = drizzleMod;
|
|
2955
3143
|
const records = await db
|
|
2956
3144
|
.select()
|
|
2957
3145
|
.from(modelsTable)
|
|
@@ -2973,7 +3161,11 @@ var db = /*#__PURE__*/Object.freeze({
|
|
|
2973
3161
|
getModelId: getModelId,
|
|
2974
3162
|
getModelIdByFileId: getModelIdByFileId,
|
|
2975
3163
|
getModelNameByModelId: getModelNameByModelId,
|
|
3164
|
+
getObjectForRow: getObjectForRow,
|
|
2976
3165
|
getPropertyModelNameAndDataType: getPropertyModelNameAndDataType,
|
|
3166
|
+
getSchemaId: getSchemaId,
|
|
3167
|
+
getSchemaIdByFileId: getSchemaIdByFileId,
|
|
3168
|
+
getSqlResultObject: getSqlResultObject,
|
|
2977
3169
|
loadModelsFromDbForSchema: loadModelsFromDbForSchema,
|
|
2978
3170
|
renameModelInDb: renameModelInDb,
|
|
2979
3171
|
savePropertyToDb: savePropertyToDb,
|
|
@@ -3027,7 +3219,7 @@ const writeToDatabase = xstate.fromCallback(({ sendBack, input }) => {
|
|
|
3027
3219
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
3028
3220
|
let dataToWrite = input.entityData;
|
|
3029
3221
|
try {
|
|
3030
|
-
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-
|
|
3222
|
+
const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B4pV91tc.js'); });
|
|
3031
3223
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
3032
3224
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
3033
3225
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -3418,7 +3610,7 @@ const modelMachine = xstate.setup({
|
|
|
3418
3610
|
// Create ModelProperty instances for any new property IDs
|
|
3419
3611
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
3420
3612
|
// Import and create instances asynchronously (fire-and-forget)
|
|
3421
|
-
Promise.resolve().then(function () { return require('./ModelProperty-
|
|
3613
|
+
Promise.resolve().then(function () { return require('./ModelProperty-B4pV91tc.js'); }).then(({ ModelProperty }) => {
|
|
3422
3614
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
3423
3615
|
try {
|
|
3424
3616
|
const property = await ModelProperty.createById(propertyFileId);
|
|
@@ -4264,7 +4456,8 @@ const fetchDataFromEas = xstate.fromCallback(({ sendBack, input: { context } })
|
|
|
4264
4456
|
}
|
|
4265
4457
|
else if (modelName) {
|
|
4266
4458
|
// Dynamic import to break circular dependency
|
|
4267
|
-
const
|
|
4459
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
4460
|
+
const { Model } = modelMod;
|
|
4268
4461
|
const model = Model.getByName(modelName);
|
|
4269
4462
|
modelSchema = model?.properties ? modelPropertiesToObject(model.properties) : undefined;
|
|
4270
4463
|
}
|
|
@@ -4395,7 +4588,8 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid) =
|
|
|
4395
4588
|
return propertyInstances;
|
|
4396
4589
|
}
|
|
4397
4590
|
try {
|
|
4398
|
-
const
|
|
4591
|
+
const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
|
|
4592
|
+
const { ItemProperty } = itemPropertyMod;
|
|
4399
4593
|
// Create instances for all metadata records in parallel
|
|
4400
4594
|
const createPromises = metadataRows.map(async (metaRow) => {
|
|
4401
4595
|
try {
|
|
@@ -4588,14 +4782,17 @@ const runPublish = xstate.fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4588
4782
|
return;
|
|
4589
4783
|
}
|
|
4590
4784
|
try {
|
|
4591
|
-
const
|
|
4785
|
+
const itemMod = await Promise.resolve().then(function () { return Item$1; });
|
|
4786
|
+
const { Item } = itemMod;
|
|
4592
4787
|
const item = await Item.find({ seedLocalId });
|
|
4593
4788
|
if (!item) {
|
|
4594
4789
|
sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
|
|
4595
4790
|
return;
|
|
4596
4791
|
}
|
|
4597
|
-
const
|
|
4598
|
-
const {
|
|
4792
|
+
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-5_oXzwol.js'); });
|
|
4793
|
+
const { getPublishUploads } = getPublishUploadsMod;
|
|
4794
|
+
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-BcjCN_bD.js'); });
|
|
4795
|
+
const { getPublishPayload } = getPublishPayloadMod;
|
|
4599
4796
|
await getPublishUploads(item);
|
|
4600
4797
|
// For first iteration: no Arweave sign/upload - pass empty uploadedTransactions.
|
|
4601
4798
|
// Real upload/submit can be wired in later.
|
|
@@ -5325,7 +5522,8 @@ const getModelSchemasFromEas = async () => {
|
|
|
5325
5522
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
5326
5523
|
const easClient = BaseEasClient.getEasClient();
|
|
5327
5524
|
// Dynamic import to break circular dependency
|
|
5328
|
-
const
|
|
5525
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
5526
|
+
const { Model } = modelMod;
|
|
5329
5527
|
const allModels = await Model.all();
|
|
5330
5528
|
const modelNames = allModels.map(m => m.modelName).filter((name) => !!name);
|
|
5331
5529
|
// If there are no models, return empty array instead of querying
|
|
@@ -5654,7 +5852,8 @@ const resolveRelatedValue = xstate.fromCallback(({ sendBack, input: { context }
|
|
|
5654
5852
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
5655
5853
|
const _resolveRelatedValue = async () => {
|
|
5656
5854
|
// Use dynamic import to break circular dependency
|
|
5657
|
-
const
|
|
5855
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-BrmvhXsG.js'); });
|
|
5856
|
+
const { ModelPropertyDataTypes } = schemaMod;
|
|
5658
5857
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
5659
5858
|
return;
|
|
5660
5859
|
}
|
|
@@ -5992,7 +6191,8 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
5992
6191
|
// to use dynamically imported ModelPropertyDataTypes
|
|
5993
6192
|
const _hydrateFromDb = async () => {
|
|
5994
6193
|
// Use dynamic import to break circular dependency
|
|
5995
|
-
const
|
|
6194
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-BrmvhXsG.js'); });
|
|
6195
|
+
const { ModelPropertyDataTypes } = schemaMod;
|
|
5996
6196
|
const appDb = BaseDb.getAppDb();
|
|
5997
6197
|
const whereClauses = [];
|
|
5998
6198
|
// Re-check types with dynamically imported ModelPropertyDataTypes
|
|
@@ -6144,7 +6344,8 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
|
|
|
6144
6344
|
if (propertyRecordSchema &&
|
|
6145
6345
|
propertyRecordSchema.storageType &&
|
|
6146
6346
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
6147
|
-
const
|
|
6347
|
+
const itemMod = await Promise.resolve().then(function () { return Item$1; });
|
|
6348
|
+
const { Item } = itemMod;
|
|
6148
6349
|
const item = await Item.find({
|
|
6149
6350
|
seedLocalId: seedLocalId ?? undefined,
|
|
6150
6351
|
modelName,
|
|
@@ -6464,7 +6665,8 @@ const analyzeInput = xstate.fromCallback(({ sendBack, input: { context, event }
|
|
|
6464
6665
|
}
|
|
6465
6666
|
const _analyzeInput = async () => {
|
|
6466
6667
|
// Use dynamic import to break circular dependency
|
|
6467
|
-
const
|
|
6668
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-BrmvhXsG.js'); });
|
|
6669
|
+
const { ModelPropertyDataTypes } = schemaMod;
|
|
6468
6670
|
let propertyName = propertyNameRaw;
|
|
6469
6671
|
if (!propertyName) {
|
|
6470
6672
|
throw new Error('propertyName is required');
|
|
@@ -6821,7 +7023,8 @@ const saveRelation = xstate.fromCallback(({ sendBack, input: { context, event }
|
|
|
6821
7023
|
}
|
|
6822
7024
|
const _saveRelation = async () => {
|
|
6823
7025
|
// Use dynamic import to break circular dependency
|
|
6824
|
-
const
|
|
7026
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-BrmvhXsG.js'); });
|
|
7027
|
+
const { ModelPropertyDataTypes } = schemaMod;
|
|
6825
7028
|
if (!propertyNameRaw) {
|
|
6826
7029
|
throw new Error('propertyName is required');
|
|
6827
7030
|
}
|
|
@@ -7619,7 +7822,8 @@ class ItemProperty {
|
|
|
7619
7822
|
return;
|
|
7620
7823
|
}
|
|
7621
7824
|
// Use dynamic import to break circular dependency
|
|
7622
|
-
const
|
|
7825
|
+
const schemaMod = await Promise.resolve().then(function () { return require('./index-BrmvhXsG.js'); });
|
|
7826
|
+
const { ModelPropertyDataTypes } = schemaMod;
|
|
7623
7827
|
const { context } = snapshot;
|
|
7624
7828
|
const { propertyRecordSchema } = context;
|
|
7625
7829
|
if (context.seedLocalId && context.propertyName) {
|
|
@@ -7732,9 +7936,12 @@ class ItemProperty {
|
|
|
7732
7936
|
setupState.subscriptionSetUp = true;
|
|
7733
7937
|
logger(`[ItemProperty._setupLiveQuerySubscription] Setting up liveQuery for propertyName: ${propertyName}, seedLocalId: ${seedLocalId}`);
|
|
7734
7938
|
try {
|
|
7735
|
-
const
|
|
7736
|
-
const {
|
|
7737
|
-
const
|
|
7939
|
+
const seedSchemaMod = await Promise.resolve().then(function () { return schema$1; });
|
|
7940
|
+
const { metadata } = seedSchemaMod;
|
|
7941
|
+
const drizzleMod = await import('drizzle-orm');
|
|
7942
|
+
const { eq, and, isNotNull } = drizzleMod;
|
|
7943
|
+
const metadataLatestMod = await Promise.resolve().then(function () { return metadataLatest; });
|
|
7944
|
+
const { getMetadataLatest } = metadataLatestMod;
|
|
7738
7945
|
const db = BaseDb.getAppDb();
|
|
7739
7946
|
if (!db) {
|
|
7740
7947
|
logger('[ItemProperty._setupLiveQuerySubscription] Database not available');
|
|
@@ -8247,8 +8454,10 @@ class ItemProperty {
|
|
|
8247
8454
|
if (!propertyName || (!seedLocalId && !seedUid))
|
|
8248
8455
|
return;
|
|
8249
8456
|
if (db) {
|
|
8250
|
-
const
|
|
8251
|
-
const {
|
|
8457
|
+
const seedSchemaMod = await Promise.resolve().then(function () { return schema$1; });
|
|
8458
|
+
const { metadata } = seedSchemaMod;
|
|
8459
|
+
const drizzleMod = await import('drizzle-orm');
|
|
8460
|
+
const { and, eq, or } = drizzleMod;
|
|
8252
8461
|
const conditions = [eq(metadata.propertyName, propertyName)];
|
|
8253
8462
|
if (seedLocalId && seedUid) {
|
|
8254
8463
|
conditions.push(or(eq(metadata.seedLocalId, seedLocalId), eq(metadata.seedUid, seedUid)));
|
|
@@ -8263,7 +8472,8 @@ class ItemProperty {
|
|
|
8263
8472
|
await db.delete(metadata).where(and(...conditions));
|
|
8264
8473
|
}
|
|
8265
8474
|
}
|
|
8266
|
-
const
|
|
8475
|
+
const itemMod = await Promise.resolve().then(function () { return Item$1; });
|
|
8476
|
+
const { Item } = itemMod;
|
|
8267
8477
|
const item = Item.getById((seedLocalId || seedUid));
|
|
8268
8478
|
if (item) {
|
|
8269
8479
|
item.getService().send({ type: 'removePropertyInstance', propertyName });
|
|
@@ -8289,7 +8499,8 @@ const createNewItem = async ({ modelName, ...propertyData }) => {
|
|
|
8289
8499
|
const newSeedId = await createSeed({ type: seedType });
|
|
8290
8500
|
const newVersionId = await createVersion({ seedLocalId: newSeedId, seedType: casing.toSnakeCase(modelName) });
|
|
8291
8501
|
// Dynamic import to break circular dependency
|
|
8292
|
-
const
|
|
8502
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
8503
|
+
const { Model } = modelMod;
|
|
8293
8504
|
const model = await Model.getByNameAsync(modelName);
|
|
8294
8505
|
const propertySchemas = model?.properties ? modelPropertiesToObject(model.properties) : undefined;
|
|
8295
8506
|
for (const [propertyName, propertyValue] of Object.entries(propertyData)) {
|
|
@@ -8497,12 +8708,14 @@ class Item {
|
|
|
8497
8708
|
};
|
|
8498
8709
|
this.getPublishUploads = async () => {
|
|
8499
8710
|
// Use dynamic import to break circular dependency
|
|
8500
|
-
const
|
|
8711
|
+
const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-5_oXzwol.js'); });
|
|
8712
|
+
const { getPublishUploads } = getPublishUploadsMod;
|
|
8501
8713
|
return await getPublishUploads(this);
|
|
8502
8714
|
};
|
|
8503
8715
|
this.getPublishPayload = async (uploadedTransactions) => {
|
|
8504
8716
|
// Use dynamic import to break circular dependency
|
|
8505
|
-
const
|
|
8717
|
+
const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-BcjCN_bD.js'); });
|
|
8718
|
+
const { getPublishPayload } = getPublishPayloadMod;
|
|
8506
8719
|
return await getPublishPayload(this, uploadedTransactions);
|
|
8507
8720
|
};
|
|
8508
8721
|
this.persistSeedUid = async () => {
|
|
@@ -8777,8 +8990,10 @@ class Item {
|
|
|
8777
8990
|
let modelRecords;
|
|
8778
8991
|
// If we have a schema name, join with modelSchemas to filter by schema
|
|
8779
8992
|
if (schemaName) {
|
|
8780
|
-
const
|
|
8781
|
-
const {
|
|
8993
|
+
const modelSchemaSchemaMod = await Promise.resolve().then(function () { return ModelSchemaSchema; });
|
|
8994
|
+
const { modelSchemas } = modelSchemaSchemaMod;
|
|
8995
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
8996
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
8782
8997
|
modelRecords = await db
|
|
8783
8998
|
.select({ id: models$1.id })
|
|
8784
8999
|
.from(models$1)
|
|
@@ -9368,9 +9583,12 @@ class Item {
|
|
|
9368
9583
|
setupState.subscriptionSetUp = true;
|
|
9369
9584
|
logger(`[Item._setupLiveQuerySubscription] Setting up liveQuery for seedLocalId: ${seedLocalId}`);
|
|
9370
9585
|
try {
|
|
9371
|
-
const
|
|
9372
|
-
const {
|
|
9373
|
-
const
|
|
9586
|
+
const seedSchemaMod = await Promise.resolve().then(function () { return schema$1; });
|
|
9587
|
+
const { seeds, versions, metadata } = seedSchemaMod;
|
|
9588
|
+
const drizzleMod = await import('drizzle-orm');
|
|
9589
|
+
const { eq, and } = drizzleMod;
|
|
9590
|
+
const versionDataMod = await Promise.resolve().then(function () { return versionData; });
|
|
9591
|
+
const { getVersionData } = versionDataMod;
|
|
9374
9592
|
const db = BaseDb.getAppDb();
|
|
9375
9593
|
if (!db) {
|
|
9376
9594
|
logger('[Item._setupLiveQuerySubscription] Database not available');
|
|
@@ -9413,7 +9631,8 @@ class Item {
|
|
|
9413
9631
|
// CRITICAL: Create ItemProperty instances BEFORE updating context
|
|
9414
9632
|
if (initialMetadataIds.length > 0) {
|
|
9415
9633
|
try {
|
|
9416
|
-
const
|
|
9634
|
+
const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
|
|
9635
|
+
const { ItemProperty } = itemPropertyMod;
|
|
9417
9636
|
const itemModelName = this._service.getSnapshot().context.modelName;
|
|
9418
9637
|
const createPromises = initialMetadata.map(async (metaRow) => {
|
|
9419
9638
|
try {
|
|
@@ -9521,7 +9740,8 @@ class Item {
|
|
|
9521
9740
|
// CRITICAL: Create ItemProperty instances BEFORE updating context
|
|
9522
9741
|
if (metadataRows.length > 0) {
|
|
9523
9742
|
try {
|
|
9524
|
-
const
|
|
9743
|
+
const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
|
|
9744
|
+
const { ItemProperty } = itemPropertyMod;
|
|
9525
9745
|
const itemModelName = this._service.getSnapshot().context.modelName;
|
|
9526
9746
|
const createPromises = metadataRows.map(async (metaRow) => {
|
|
9527
9747
|
try {
|
|
@@ -9719,7 +9939,8 @@ const setupServicesEventHandlers = () => {
|
|
|
9719
9939
|
const schemaStringToModelRecord = new Map();
|
|
9720
9940
|
const getModelSchemas = async () => {
|
|
9721
9941
|
// Dynamic import to break circular dependency
|
|
9722
|
-
const
|
|
9942
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
9943
|
+
const { Model } = modelMod;
|
|
9723
9944
|
const allModels = await Model.all();
|
|
9724
9945
|
const modelRecords = [];
|
|
9725
9946
|
const appDb = BaseDb.getAppDb();
|
|
@@ -9954,7 +10175,8 @@ const saveEasPropertiesToDb = async ({ itemProperties, itemSeeds, }) => {
|
|
|
9954
10175
|
isSavingToDb = true;
|
|
9955
10176
|
const propertyUids = itemProperties.map((property) => property.id);
|
|
9956
10177
|
// Dynamic import to break circular dependency
|
|
9957
|
-
const
|
|
10178
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
10179
|
+
const { Model } = modelMod;
|
|
9958
10180
|
const allModels = await Model.all();
|
|
9959
10181
|
const models = Object.fromEntries(allModels.map(m => [m.modelName, m]));
|
|
9960
10182
|
const appDb = BaseDb.getAppDb();
|
|
@@ -10544,7 +10766,8 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
10544
10766
|
}
|
|
10545
10767
|
if (!BaseDb.isAppDbReady()) {
|
|
10546
10768
|
// Wait for ClientManager to be ready (DB_INIT state or later)
|
|
10547
|
-
const
|
|
10769
|
+
const clientManagerMod = await Promise.resolve().then(function () { return ClientManager$1; });
|
|
10770
|
+
const { getClient } = clientManagerMod;
|
|
10548
10771
|
const clientManager = getClient();
|
|
10549
10772
|
const clientService = clientManager.getService();
|
|
10550
10773
|
await xstate.waitFor(clientService, (snapshot) => {
|
|
@@ -11374,8 +11597,10 @@ const logger$8 = debug('seedSdk:imports:json');
|
|
|
11374
11597
|
* @returns Promise that resolves when properties are found, or rejects if not found after max retries
|
|
11375
11598
|
*/
|
|
11376
11599
|
const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10, retryDelay = 100) => {
|
|
11377
|
-
const
|
|
11378
|
-
const {
|
|
11600
|
+
const modelSchemaMod = await Promise.resolve().then(function () { return ModelSchema; });
|
|
11601
|
+
const { properties: propertiesTable } = modelSchemaMod;
|
|
11602
|
+
const drizzleMod = await import('drizzle-orm');
|
|
11603
|
+
const { eq } = drizzleMod;
|
|
11379
11604
|
console.log(`[verifyPropertiesPersisted] Starting verification for model "${modelName}" (modelId: ${modelId})`);
|
|
11380
11605
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
11381
11606
|
const props = await db
|
|
@@ -11691,7 +11916,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
11691
11916
|
schemaFile = transformImportToSchemaFile(importData, version);
|
|
11692
11917
|
}
|
|
11693
11918
|
// Check if this is an internal SDK schema (should not create files in app directory)
|
|
11694
|
-
const
|
|
11919
|
+
const constantsMod = await Promise.resolve().then(function () { return constants; });
|
|
11920
|
+
const { isInternalSchema } = constantsMod;
|
|
11695
11921
|
const isInternal = isInternalSchema(schemaFile.metadata.name, schemaFile.id);
|
|
11696
11922
|
if (isInternal) {
|
|
11697
11923
|
logger$8(`Skipping file creation for internal schema: ${schemaFile.metadata.name}`);
|
|
@@ -11785,7 +12011,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
11785
12011
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
11786
12012
|
};
|
|
11787
12013
|
// Use dynamic import to break circular dependency
|
|
11788
|
-
const
|
|
12014
|
+
const dbMod = await Promise.resolve().then(function () { return db; });
|
|
12015
|
+
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
11789
12016
|
// Try to add schema and models to database if database is available
|
|
11790
12017
|
try {
|
|
11791
12018
|
const db = BaseDb.getAppDb();
|
|
@@ -11806,9 +12033,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
11806
12033
|
// CRITICAL: Verify all expected models are linked via join table
|
|
11807
12034
|
// Retry querying until all models are visible (browser environments may have delays)
|
|
11808
12035
|
const expectedModelNames = Object.keys(schemaFile.models || {});
|
|
11809
|
-
const
|
|
11810
|
-
const {
|
|
11811
|
-
const
|
|
12036
|
+
const modelSchemaSchemaMod = await Promise.resolve().then(function () { return ModelSchemaSchema; });
|
|
12037
|
+
const { modelSchemas } = modelSchemaSchemaMod;
|
|
12038
|
+
const modelSchemaMod = await Promise.resolve().then(function () { return ModelSchema; });
|
|
12039
|
+
const { models: modelsTable } = modelSchemaMod;
|
|
12040
|
+
const drizzleMod = await import('drizzle-orm');
|
|
12041
|
+
const { eq, and } = drizzleMod;
|
|
11812
12042
|
let allModelsLinked = false;
|
|
11813
12043
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
11814
12044
|
const modelLinks = await db
|
|
@@ -11979,10 +12209,11 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
11979
12209
|
}
|
|
11980
12210
|
}
|
|
11981
12211
|
}
|
|
11982
|
-
// After properties are created, ensure schemaFile has the correct IDs from database
|
|
12212
|
+
// After properties are created (internal schema path), ensure schemaFile has the correct IDs from database
|
|
11983
12213
|
// Query the database to get the actual schemaFileId values that were used
|
|
11984
12214
|
// This ensures schemaData matches what's actually in the database
|
|
11985
|
-
const
|
|
12215
|
+
const modelSchemaMod1 = await Promise.resolve().then(function () { return ModelSchema; });
|
|
12216
|
+
const { properties: propertiesTable } = modelSchemaMod1;
|
|
11986
12217
|
let schemaFileUpdated = false;
|
|
11987
12218
|
for (const [modelName, modelFileId] of modelFileIds.entries()) {
|
|
11988
12219
|
// Get model record to find modelId
|
|
@@ -12015,7 +12246,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
|
|
|
12015
12246
|
// This is important even if nothing changed, to ensure consistency
|
|
12016
12247
|
const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
|
|
12017
12248
|
// Update the schema record in the database with current schemaData
|
|
12018
|
-
const
|
|
12249
|
+
const schemaSchemaMod1 = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
12250
|
+
const { schemas: schemasTable } = schemaSchemaMod1;
|
|
12019
12251
|
await db
|
|
12020
12252
|
.update(schemasTable)
|
|
12021
12253
|
.set({ schemaData: updatedSchemaData })
|
|
@@ -12229,7 +12461,8 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12229
12461
|
updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
|
|
12230
12462
|
};
|
|
12231
12463
|
// Use dynamic import to break circular dependency
|
|
12232
|
-
const
|
|
12464
|
+
const dbMod = await Promise.resolve().then(function () { return db; });
|
|
12465
|
+
const { addSchemaToDb, addModelsToDb } = dbMod;
|
|
12233
12466
|
// Try to add schema and models to database if database is available
|
|
12234
12467
|
try {
|
|
12235
12468
|
const db = BaseDb.getAppDb();
|
|
@@ -12251,9 +12484,12 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12251
12484
|
await new Promise(resolve => setTimeout(resolve, 200));
|
|
12252
12485
|
console.log(`[importJsonSchema] Starting property verification for schema "${schemaName}" (schemaRecord.id: ${schemaRecord.id})`);
|
|
12253
12486
|
// Query the database to get model IDs that were just created
|
|
12254
|
-
const
|
|
12255
|
-
const {
|
|
12256
|
-
const
|
|
12487
|
+
const modelSchemaSchemaMod = await Promise.resolve().then(function () { return ModelSchemaSchema; });
|
|
12488
|
+
const { modelSchemas } = modelSchemaSchemaMod;
|
|
12489
|
+
const modelSchemaMod = await Promise.resolve().then(function () { return ModelSchema; });
|
|
12490
|
+
const { models: modelsTable } = modelSchemaMod;
|
|
12491
|
+
const drizzleMod = await import('drizzle-orm');
|
|
12492
|
+
const { eq } = drizzleMod;
|
|
12257
12493
|
// Try to find models directly by schemaFileId first (more reliable than join table)
|
|
12258
12494
|
const seedModelId = modelFileIds.get('Seed');
|
|
12259
12495
|
let seedModel = [];
|
|
@@ -12315,10 +12551,11 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12315
12551
|
}
|
|
12316
12552
|
}
|
|
12317
12553
|
}
|
|
12318
|
-
// After properties are created, ensure schemaFile has the correct IDs from database
|
|
12554
|
+
// After properties are created (file path), ensure schemaFile has the correct IDs from database
|
|
12319
12555
|
// Query the database to get the actual schemaFileId values that were used
|
|
12320
12556
|
// This ensures schemaData matches what's actually in the database
|
|
12321
|
-
const
|
|
12557
|
+
const modelSchemaMod2 = await Promise.resolve().then(function () { return ModelSchema; });
|
|
12558
|
+
const { properties: propertiesTable } = modelSchemaMod2;
|
|
12322
12559
|
let schemaFileUpdated = false;
|
|
12323
12560
|
for (const [modelName, modelFileId] of modelFileIds.entries()) {
|
|
12324
12561
|
// Get model record to find modelId
|
|
@@ -12351,7 +12588,8 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12351
12588
|
// This is important even if nothing changed, to ensure consistency
|
|
12352
12589
|
const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
|
|
12353
12590
|
// Update the schema record in the database with current schemaData
|
|
12354
|
-
const
|
|
12591
|
+
const schemaSchemaMod = await Promise.resolve().then(function () { return SchemaSchema; });
|
|
12592
|
+
const { schemas: schemasTable } = schemaSchemaMod;
|
|
12355
12593
|
await db
|
|
12356
12594
|
.update(schemasTable)
|
|
12357
12595
|
.set({ schemaData: updatedSchemaData })
|
|
@@ -12392,7 +12630,8 @@ const loadSchemaFromFile = async (schemaFilePath) => {
|
|
|
12392
12630
|
*/
|
|
12393
12631
|
const createModelFromJson = async (modelName, modelDef, schemaName, modelFileId, // Optional modelFileId from JSON file
|
|
12394
12632
|
propertyFileIds) => {
|
|
12395
|
-
const
|
|
12633
|
+
const modelMod = await Promise.resolve().then(function () { return Model$1; });
|
|
12634
|
+
const { Model } = modelMod;
|
|
12396
12635
|
// Convert JSON properties to schema format
|
|
12397
12636
|
const convertedProperties = {};
|
|
12398
12637
|
if (modelDef.properties) {
|
|
@@ -13243,7 +13482,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
13243
13482
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
13244
13483
|
// Eagerly start loading to minimize delay on first access
|
|
13245
13484
|
let ModelPropertyClass = null;
|
|
13246
|
-
const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-
|
|
13485
|
+
const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-B4pV91tc.js'); })
|
|
13247
13486
|
.then(module => {
|
|
13248
13487
|
ModelPropertyClass = module.ModelProperty;
|
|
13249
13488
|
return ModelPropertyClass;
|
|
@@ -13260,7 +13499,7 @@ function getModelProperty() {
|
|
|
13260
13499
|
}
|
|
13261
13500
|
// Lazy import cache for Schema to avoid circular dependency
|
|
13262
13501
|
let SchemaClass = null;
|
|
13263
|
-
const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-
|
|
13502
|
+
const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-TErl3J36.js'); }).then(function (n) { return n.Schema$1; })
|
|
13264
13503
|
.then(module => {
|
|
13265
13504
|
SchemaClass = module.Schema;
|
|
13266
13505
|
return SchemaClass;
|
|
@@ -14761,7 +15000,8 @@ class Model {
|
|
|
14761
15000
|
doDestroy: async () => {
|
|
14762
15001
|
const db = BaseDb.getAppDb();
|
|
14763
15002
|
if (db && modelFileId) {
|
|
14764
|
-
const
|
|
15003
|
+
const drizzleMod = await import('drizzle-orm');
|
|
15004
|
+
const { eq } = drizzleMod;
|
|
14765
15005
|
const modelRecords = await db
|
|
14766
15006
|
.select()
|
|
14767
15007
|
.from(models$1)
|
|
@@ -15244,7 +15484,8 @@ var FileManager$1 = /*#__PURE__*/Object.freeze({
|
|
|
15244
15484
|
const logger$4 = debug('seedSdk:node:db:Db');
|
|
15245
15485
|
const getConfig = async (dotSeedDir, config) => {
|
|
15246
15486
|
// Create config inline - config values can be passed in or use defaults
|
|
15247
|
-
const
|
|
15487
|
+
const drizzleKitMod = await import('drizzle-kit');
|
|
15488
|
+
const { defineConfig } = drizzleKitMod;
|
|
15248
15489
|
const appSchemaDir = config?.schemaDir || path.join(dotSeedDir, 'schema');
|
|
15249
15490
|
const outDir = config?.outDir || `${dotSeedDir}/db`;
|
|
15250
15491
|
const dbUrl = config?.dbUrl || `${dotSeedDir}/db/seed.db`;
|
|
@@ -15460,7 +15701,8 @@ class Db extends BaseDb {
|
|
|
15460
15701
|
// In drizzle-kit, migrations are generated in the 'out' directory (which is pathToDbDir)
|
|
15461
15702
|
// migrate(this.db, { migrationsFolder: pathToDbDir })
|
|
15462
15703
|
// NEW CODE: Use libsql migrator
|
|
15463
|
-
const
|
|
15704
|
+
const migratorMod = await import('drizzle-orm/libsql/migrator');
|
|
15705
|
+
const { migrate } = migratorMod;
|
|
15464
15706
|
// migrationsFolder should point to the directory containing migration SQL files
|
|
15465
15707
|
// In drizzle-kit, migrations are generated in the 'out' directory (which is pathToDbDir)
|
|
15466
15708
|
await migrate(this.db, { migrationsFolder: pathToDbDir });
|
|
@@ -16008,7 +16250,7 @@ const getTsImport = async (filePath) => {
|
|
|
16008
16250
|
|
|
16009
16251
|
// Get the directory of this file to resolve relative paths
|
|
16010
16252
|
// @ts-ignore - rollup plugin-typescript doesn't recognize import.meta with module: "preserve"
|
|
16011
|
-
const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-
|
|
16253
|
+
const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-CXI4VF1H.js', document.baseURI).href)));
|
|
16012
16254
|
path.dirname(__filename$1);
|
|
16013
16255
|
const commandExists = (command) => {
|
|
16014
16256
|
try {
|
|
@@ -16559,4 +16801,4 @@ exports.versions = versions;
|
|
|
16559
16801
|
exports.waitForEntityIdle = waitForEntityIdle;
|
|
16560
16802
|
exports.withSeed = withSeed;
|
|
16561
16803
|
exports.writeProcessMachine = writeProcessMachine;
|
|
16562
|
-
//# sourceMappingURL=index-
|
|
16804
|
+
//# sourceMappingURL=index-CXI4VF1H.js.map
|