@seedprotocol/sdk 0.7.3-next.654.g52217f6 → 0.7.3

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.
Files changed (187) hide show
  1. package/dist/{db-D9K_f5cF.js → BasePathResolver-Cm4apKRb.js} +2041 -127
  2. package/dist/BasePathResolver-Cm4apKRb.js.map +1 -0
  3. package/dist/{ClientManager-C-QXqUK9.js → ClientManager-i3nJASkg.js} +249 -147
  4. package/dist/ClientManager-i3nJASkg.js.map +1 -0
  5. package/dist/{Item-C7sUUu2B.js → Item-DBFchXpC.js} +259 -169
  6. package/dist/Item-DBFchXpC.js.map +1 -0
  7. package/dist/{ModelProperty-DJxeOOrc.js → ModelProperty-BS49g01Y.js} +166 -47
  8. package/dist/ModelProperty-BS49g01Y.js.map +1 -0
  9. package/dist/{Schema-fXtvd-yL.js → Schema-CpMNEnUO.js} +53 -42
  10. package/dist/Schema-CpMNEnUO.js.map +1 -0
  11. package/dist/{SchemaValidationService-CvRS2HSO.js → SchemaValidationService-DieV4KL-.js} +15 -17
  12. package/dist/{SchemaValidationService-CvRS2HSO.js.map → SchemaValidationService-DieV4KL-.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-SXW-8C64.js → backfillMetadataPropertyIds-DSoOoTnX.js} +14 -7
  14. package/dist/{backfillMetadataPropertyIds-SXW-8C64.js.map → backfillMetadataPropertyIds-DSoOoTnX.js.map} +1 -1
  15. package/dist/{configurePlatform-BRw2j0ZN.js → configurePlatform-D0lQGAMQ.js} +5 -7
  16. package/dist/{configurePlatform-BRw2j0ZN.js.map → configurePlatform-D0lQGAMQ.js.map} +1 -1
  17. package/dist/detachRowsBeforeDelete-S0q-DJPT.js +50 -0
  18. package/dist/detachRowsBeforeDelete-S0q-DJPT.js.map +1 -0
  19. package/dist/{eas-DHxfswCt.js → eas-6pjU-OuX.js} +6 -8
  20. package/dist/eas-6pjU-OuX.js.map +1 -0
  21. package/dist/{getItem-d6N_aM6S.js → getItem-CxBNZ-WL.js} +10 -11
  22. package/dist/{getItem-d6N_aM6S.js.map → getItem-CxBNZ-WL.js.map} +1 -1
  23. package/dist/{getPublishPayload-BHrxVtzY.js → getPublishPayload-CTCvRUoU.js} +50 -18
  24. package/dist/getPublishPayload-CTCvRUoU.js.map +1 -0
  25. package/dist/{getPublishUploads-BEqRiKIS.js → getPublishUploads-SFHCbf_y.js} +13 -22
  26. package/dist/{getPublishUploads-BEqRiKIS.js.map → getPublishUploads-SFHCbf_y.js.map} +1 -1
  27. package/dist/{index-s15q14rm.js → index-8O3Uow-Y.js} +125 -57
  28. package/dist/index-8O3Uow-Y.js.map +1 -0
  29. package/dist/{index-DglvthOk.js → index-AVFTVp1m.js} +2 -2
  30. package/dist/index-AVFTVp1m.js.map +1 -0
  31. package/dist/index-Cvt5UBz4.js +30 -0
  32. package/dist/index-Cvt5UBz4.js.map +1 -0
  33. package/dist/{index.browser-Cm06tP4X.js → index.browser-DBhxRoe8.js} +11 -10
  34. package/dist/{index.browser-Cm06tP4X.js.map → index.browser-DBhxRoe8.js.map} +1 -1
  35. package/dist/{index.node-C30dmFgn.js → index.node-CJhlcNHM.js} +25 -13
  36. package/dist/index.node-CJhlcNHM.js.map +1 -0
  37. package/dist/main.js +27 -32
  38. package/dist/main.js.map +1 -1
  39. package/dist/node.js +19 -22
  40. package/dist/node.js.map +1 -1
  41. package/dist/platform.browser.js +9 -9
  42. package/dist/platform.node.js +18 -5
  43. package/dist/platform.node.js.map +1 -1
  44. package/dist/{property-DhmmYAvQ.js → property-DwPD283A.js} +11 -12
  45. package/dist/property-DwPD283A.js.map +1 -0
  46. package/dist/{publishDraftGraph-yYP74WRt.js → publishDraftGraph-BOn3_Occ.js} +6 -9
  47. package/dist/{publishDraftGraph-yYP74WRt.js.map → publishDraftGraph-BOn3_Occ.js.map} +1 -1
  48. package/dist/{resetAmbiguousLegacyItemData-Bk0QyDW8.js → resetAmbiguousLegacyItemData-BkYmBeJc.js} +14 -3
  49. package/dist/{resetAmbiguousLegacyItemData-Bk0QyDW8.js.map → resetAmbiguousLegacyItemData-BkYmBeJc.js.map} +1 -1
  50. package/dist/{resolveModelForSyncedSeed-8cAzvUFd.js → resolveModelForSyncedSeed-BL24nLa7.js} +2 -2
  51. package/dist/{resolveModelForSyncedSeed-8cAzvUFd.js.map → resolveModelForSyncedSeed-BL24nLa7.js.map} +1 -1
  52. package/dist/src/Item/Item.d.ts +20 -2
  53. package/dist/src/Item/Item.d.ts.map +1 -1
  54. package/dist/src/Item/service/actors/runPublish.d.ts +11 -2
  55. package/dist/src/Item/service/actors/runPublish.d.ts.map +1 -1
  56. package/dist/src/Item/service/itemMachineSingle.d.ts +12 -2
  57. package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
  58. package/dist/src/ItemProperty/ItemProperty.d.ts +5 -3
  59. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  60. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
  61. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  62. package/dist/src/Model/Model.d.ts +10 -4
  63. package/dist/src/Model/Model.d.ts.map +1 -1
  64. package/dist/src/Model/index.d.ts +2 -2
  65. package/dist/src/ModelProperty/ModelProperty.d.ts +10 -2
  66. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  67. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +3 -0
  68. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
  69. package/dist/src/Schema/Schema.d.ts +2 -2
  70. package/dist/src/Schema/Schema.d.ts.map +1 -1
  71. package/dist/src/Schema/index.d.ts +0 -1
  72. package/dist/src/Schema/index.d.ts.map +1 -1
  73. package/dist/src/client/ClientManager.d.ts +30 -11
  74. package/dist/src/client/ClientManager.d.ts.map +1 -1
  75. package/dist/src/client/actors/platformClassesInit.d.ts +6 -0
  76. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  77. package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
  78. package/dist/src/client/actors/saveConfig.d.ts +13 -6
  79. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  80. package/dist/src/db/read/getPublishPayload.d.ts +1 -1
  81. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  82. package/dist/src/db/write/claimUnpublishedDrafts.d.ts +2 -0
  83. package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
  84. package/dist/src/eventBus.d.ts +5 -0
  85. package/dist/src/eventBus.d.ts.map +1 -1
  86. package/dist/src/helpers/cachedPropertyRefresh.d.ts +12 -0
  87. package/dist/src/helpers/cachedPropertyRefresh.d.ts.map +1 -0
  88. package/dist/src/helpers/db.d.ts +3 -0
  89. package/dist/src/helpers/db.d.ts.map +1 -1
  90. package/dist/src/helpers/easSdk.d.ts +16 -0
  91. package/dist/src/helpers/easSdk.d.ts.map +1 -0
  92. package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts +16 -0
  93. package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts.map +1 -0
  94. package/dist/src/helpers/entity/entityDestroy.d.ts +2 -0
  95. package/dist/src/helpers/entity/entityDestroy.d.ts.map +1 -1
  96. package/dist/src/helpers/ownership.d.ts +9 -1
  97. package/dist/src/helpers/ownership.d.ts.map +1 -1
  98. package/dist/src/helpers/property/index.d.ts +37 -51
  99. package/dist/src/helpers/property/index.d.ts.map +1 -1
  100. package/dist/src/helpers/publishConfig.d.ts +27 -8
  101. package/dist/src/helpers/publishConfig.d.ts.map +1 -1
  102. package/dist/src/helpers/updateSchema.d.ts +5 -0
  103. package/dist/src/helpers/updateSchema.d.ts.map +1 -1
  104. package/dist/src/helpers/waitForEntityIdle.d.ts +5 -0
  105. package/dist/src/helpers/waitForEntityIdle.d.ts.map +1 -1
  106. package/dist/src/imports/json.d.ts +9 -0
  107. package/dist/src/imports/json.d.ts.map +1 -1
  108. package/dist/src/index.d.ts +6 -4
  109. package/dist/src/index.d.ts.map +1 -1
  110. package/dist/src/interfaces/IItem.d.ts +7 -1
  111. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  112. package/dist/src/node/db/Db.d.ts.map +1 -1
  113. package/dist/src/node/helpers/PathResolver.d.ts.map +1 -1
  114. package/dist/src/node/index.d.ts +8 -1
  115. package/dist/src/node/index.d.ts.map +1 -1
  116. package/dist/src/platform/index.browser.d.ts +2 -0
  117. package/dist/src/platform/index.browser.d.ts.map +1 -1
  118. package/dist/src/platform/index.node.d.ts +2 -0
  119. package/dist/src/platform/index.node.d.ts.map +1 -1
  120. package/dist/src/types/index.d.ts +12 -1
  121. package/dist/src/types/index.d.ts.map +1 -1
  122. package/dist/src/types/machines.d.ts +2 -0
  123. package/dist/src/types/machines.d.ts.map +1 -1
  124. package/dist/src/types/property.d.ts +8 -0
  125. package/dist/src/types/property.d.ts.map +1 -1
  126. package/dist/{syncDbWithEas--HUA9WNb.js → syncDbWithEas-Bv2Fe38J.js} +15 -16
  127. package/dist/syncDbWithEas-Bv2Fe38J.js.map +1 -0
  128. package/dist/tabEvents-9s2WCYw-.js +335 -0
  129. package/dist/tabEvents-9s2WCYw-.js.map +1 -0
  130. package/dist/{tolerantWebAccess-BZYWt09Y.js → tolerantWebAccess-iUu80pAP.js} +9 -9
  131. package/dist/{tolerantWebAccess-BZYWt09Y.js.map → tolerantWebAccess-iUu80pAP.js.map} +1 -1
  132. package/dist/{updateSeedRevokedAt-D_EG-q3b.js → updateSeedRevokedAt-zBfi931j.js} +3 -3
  133. package/dist/{updateSeedRevokedAt-D_EG-q3b.js.map → updateSeedRevokedAt-zBfi931j.js.map} +1 -1
  134. package/package.json +11 -12
  135. package/src/node/easLodashRegister.js +4 -0
  136. package/dist/BasePathResolver-CfSfMW5_.js +0 -676
  137. package/dist/BasePathResolver-CfSfMW5_.js.map +0 -1
  138. package/dist/ClientManager-C-QXqUK9.js.map +0 -1
  139. package/dist/Item-C7sUUu2B.js.map +0 -1
  140. package/dist/ModelProperty-DJxeOOrc.js.map +0 -1
  141. package/dist/Schema-fXtvd-yL.js.map +0 -1
  142. package/dist/cjs/ModelProperty-DXZ39Wyv.js +0 -1978
  143. package/dist/cjs/ModelProperty-DXZ39Wyv.js.map +0 -1
  144. package/dist/cjs/Schema-DdP109QD.js +0 -5257
  145. package/dist/cjs/Schema-DdP109QD.js.map +0 -1
  146. package/dist/cjs/SchemaValidationService-CSXxx7sQ.js +0 -779
  147. package/dist/cjs/SchemaValidationService-CSXxx7sQ.js.map +0 -1
  148. package/dist/cjs/backfillMetadataPropertyIds-CPYoaMl4.js +0 -90
  149. package/dist/cjs/backfillMetadataPropertyIds-CPYoaMl4.js.map +0 -1
  150. package/dist/cjs/eas-B2YDQssV.js +0 -139
  151. package/dist/cjs/eas-B2YDQssV.js.map +0 -1
  152. package/dist/cjs/getItem-DgnaQzbE.js +0 -59
  153. package/dist/cjs/getItem-DgnaQzbE.js.map +0 -1
  154. package/dist/cjs/getPublishPayload-CqlqRdot.js +0 -1604
  155. package/dist/cjs/getPublishPayload-CqlqRdot.js.map +0 -1
  156. package/dist/cjs/getPublishUploads-DsXY9S4U.js +0 -872
  157. package/dist/cjs/getPublishUploads-DsXY9S4U.js.map +0 -1
  158. package/dist/cjs/index-BHaWOwNF.js +0 -71
  159. package/dist/cjs/index-BHaWOwNF.js.map +0 -1
  160. package/dist/cjs/index-C4XlgCJ4.js +0 -22801
  161. package/dist/cjs/index-C4XlgCJ4.js.map +0 -1
  162. package/dist/cjs/index.browser-BSf8HpnU.js +0 -22
  163. package/dist/cjs/index.browser-BSf8HpnU.js.map +0 -1
  164. package/dist/cjs/property-fa0iju0J.js +0 -328
  165. package/dist/cjs/property-fa0iju0J.js.map +0 -1
  166. package/dist/cjs/publishDraftGraph-3ASwAlD7.js +0 -403
  167. package/dist/cjs/publishDraftGraph-3ASwAlD7.js.map +0 -1
  168. package/dist/cjs/resetAmbiguousLegacyItemData-Bu_MBBYt.js +0 -117
  169. package/dist/cjs/resetAmbiguousLegacyItemData-Bu_MBBYt.js.map +0 -1
  170. package/dist/cjs/resolveModelForSyncedSeed-BANIiuFU.js +0 -49
  171. package/dist/cjs/resolveModelForSyncedSeed-BANIiuFU.js.map +0 -1
  172. package/dist/cjs/syncDbWithEas-CrmxxmUW.js +0 -887
  173. package/dist/cjs/syncDbWithEas-CrmxxmUW.js.map +0 -1
  174. package/dist/db-D9K_f5cF.js.map +0 -1
  175. package/dist/eas-DHxfswCt.js.map +0 -1
  176. package/dist/getPublishPayload-BHrxVtzY.js.map +0 -1
  177. package/dist/index-CiMEoGu3.js +0 -32
  178. package/dist/index-CiMEoGu3.js.map +0 -1
  179. package/dist/index-DglvthOk.js.map +0 -1
  180. package/dist/index-s15q14rm.js.map +0 -1
  181. package/dist/index.node-C30dmFgn.js.map +0 -1
  182. package/dist/main.cjs +0 -85
  183. package/dist/main.cjs.map +0 -1
  184. package/dist/property-DhmmYAvQ.js.map +0 -1
  185. package/dist/syncDbWithEas--HUA9WNb.js.map +0 -1
  186. package/dist/tabEvents-DguZpCCv.js +0 -1580
  187. package/dist/tabEvents-DguZpCCv.js.map +0 -1
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- var PathResolver = require('@/browser/helpers/PathResolver');
4
- var FileManager = require('@/browser/helpers/FileManager');
5
- var Db = require('@/browser/db/Db');
6
- var ArweaveClient = require('@/browser/helpers/ArweaveClient');
7
- var EasClient = require('@/browser/helpers/EasClient');
8
- var QueryClient = require('@/browser/helpers/QueryClient');
9
-
10
- function createPlatformServices() {
11
- return {
12
- pathResolver: new PathResolver.BrowserPathResolver(),
13
- fileManager: new FileManager.BrowserFileManager(),
14
- db: new Db.BrowserDb(),
15
- arweaveClient: new ArweaveClient.BrowserArweaveClient(),
16
- easClient: new EasClient.BrowserEasClient(),
17
- queryClient: new QueryClient.BrowserQueryClient(),
18
- };
19
- }
20
-
21
- exports.createPlatformServices = createPlatformServices;
22
- //# sourceMappingURL=index.browser-BSf8HpnU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.browser-BSf8HpnU.js","sources":["../../../src/platform/index.browser.ts"],"sourcesContent":["import { BrowserPathResolver } from '@/browser/helpers/PathResolver'\nimport { BrowserFileManager } from '@/browser/helpers/FileManager'\nimport { BrowserDb } from '@/browser/db/Db'\nimport { BrowserArweaveClient } from '@/browser/helpers/ArweaveClient'\nimport { BrowserEasClient } from '@/browser/helpers/EasClient'\nimport { BrowserQueryClient } from '@/browser/helpers/QueryClient'\nimport type { PlatformServices } from './types'\n\nexport function createPlatformServices(): PlatformServices {\n return {\n pathResolver: new BrowserPathResolver(),\n fileManager: new BrowserFileManager(),\n db: new BrowserDb(),\n arweaveClient: new BrowserArweaveClient(),\n easClient: new BrowserEasClient(),\n queryClient: new BrowserQueryClient(),\n }\n}\n"],"names":["BrowserPathResolver","BrowserFileManager","BrowserDb","BrowserArweaveClient","BrowserEasClient","BrowserQueryClient"],"mappings":";;;;;;;;;SAQgB,sBAAsB,GAAA;IACpC,OAAO;QACL,YAAY,EAAE,IAAIA,gCAAmB,EAAE;QACvC,WAAW,EAAE,IAAIC,8BAAkB,EAAE;QACrC,EAAE,EAAE,IAAIC,YAAS,EAAE;QACnB,aAAa,EAAE,IAAIC,kCAAoB,EAAE;QACzC,SAAS,EAAE,IAAIC,0BAAgB,EAAE;QACjC,WAAW,EAAE,IAAIC,8BAAkB,EAAE;KACtC;AACH;;"}
@@ -1,328 +0,0 @@
1
- 'use strict';
2
-
3
- var pluralize = require('pluralize');
4
- var main_cjs = require('./index-C4XlgCJ4.js');
5
- var drizzleOrm = require('drizzle-orm');
6
- require('immer');
7
- require('reflect-metadata');
8
- require('xstate');
9
- require('drizzle-orm/sqlite-core');
10
- require('debug');
11
- require('@seedprotocol/arweave');
12
- require('@seedprotocol/eas');
13
- require('@sinclair/typebox');
14
- require('drizzle-orm/casing');
15
- require('lodash-es');
16
- require('@noble/hashes/sha256');
17
- require('@noble/hashes/sha3');
18
- require('@noble/hashes/utils');
19
- require('nanoid');
20
- require('nanoid-dictionary');
21
- require('@seedprotocol/query');
22
- require('rxjs');
23
- require('fs/promises');
24
- require('fs');
25
- require('path');
26
- require('url');
27
- require('node:url');
28
- require('@libsql/client');
29
- require('drizzle-orm/libsql');
30
- require('drizzle-orm/libsql/migrator');
31
- require('js-yaml');
32
- require('child_process');
33
- require('@seedprotocol/arweave/node');
34
- require('@seedprotocol/eas/node');
35
-
36
- // Dynamic import to break circular dependency: Model -> ... -> helpers/property -> Model
37
- // import { Model } from '@/Model/Model'
38
- /**
39
- * Gets the propertyRecordSchema object for a given model and property name.
40
- *
41
- * The propertyRecordSchema is the property definition object that contains
42
- * information about the property's data type, storage configuration, and
43
- * relationship details (for Relation and List types).
44
- *
45
- * This function first checks the database for property definitions (which may
46
- * have been edited), then falls back to schema files. This ensures that
47
- * edited properties persist across page reloads.
48
- *
49
- * This function handles property names that end with 'Id' or 'Ids' by automatically
50
- * looking up the base property name in the schema (e.g., 'authorId' -> 'author',
51
- * 'tagIds' -> 'tags').
52
- *
53
- * @param modelName - The name of the model (e.g., 'Article', 'Author')
54
- * @param propertyName - The name of the property (e.g., 'title', 'author', 'authorId', 'tags', 'tagIds')
55
- * @returns The propertyRecordSchema object (TProperty with optional _propertyFileId) or undefined if not found
56
- *
57
- * @example
58
- * ```typescript
59
- * const schema = await getPropertySchema('Article', 'title')
60
- * // Returns: { dataType: 'Text', ... }
61
- *
62
- * const relationSchema = await getPropertySchema('Article', 'author')
63
- * // Returns: { dataType: 'Relation', ref: 'Author', ... }
64
- *
65
- * // Also works with Id/Ids suffixes
66
- * const relationSchemaById = await getPropertySchema('Article', 'authorId')
67
- * // Returns: { dataType: 'Relation', ref: 'Author', ... }
68
- * ```
69
- */
70
- const getPropertySchema = async (modelName, propertyName,
71
- /** Which model is meant when several schemas define one named modelName (Model.id and/or schema). */
72
- scope = {}) => {
73
- // Dynamic import to break circular dependency
74
- const modelMod = await Promise.resolve().then(function () { return require('./index-C4XlgCJ4.js'); }).then(function (n) { return n.Model$1; });
75
- const { Model } = modelMod;
76
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DdP109QD.js'); });
77
- const { Schema } = schemaMod;
78
- const { resolveModelRecord } = await Promise.resolve().then(function () { return require('./index-C4XlgCJ4.js'); }).then(function (n) { return n.resolveModelRecord$1; });
79
- const model = await Model.resolveAsync(modelName, scope);
80
- if (!model) {
81
- return undefined;
82
- }
83
- // Get the original schema from Schema instance context (has ref fields from schema file)
84
- // This is more reliable than modelPropertiesToObject which depends on ModelProperty instances
85
- let schema = {};
86
- try {
87
- const schemaName = model.schemaName;
88
- if (schemaName) {
89
- const schemaInstance = Schema.create(schemaName, {
90
- waitForReady: false,
91
- });
92
- const schemaContext = schemaInstance.getService().getSnapshot().context;
93
- if (schemaContext.models && schemaContext.models[modelName]) {
94
- // Get properties from Schema context (original schema file data)
95
- const modelDef = schemaContext.models[modelName];
96
- schema = modelDef.properties || {};
97
- }
98
- }
99
- }
100
- catch (error) {
101
- // Fall through to modelPropertiesToObject
102
- }
103
- // Fallback to modelPropertiesToObject if Schema context doesn't have the data
104
- const usingModelProperties = Object.keys(schema).length === 0;
105
- if (usingModelProperties) {
106
- const properties = model.properties || [];
107
- if (properties.length === 0) {
108
- return undefined;
109
- }
110
- schema = main_cjs.modelPropertiesToObject(properties);
111
- }
112
- // Helper to resolve property name (handles Id/Ids suffixes)
113
- const resolvePropertyName = (propName) => {
114
- // First, try direct lookup
115
- if (schema[propName]) {
116
- return propName;
117
- }
118
- // List-of-relation storage name (e.g. authorIdentityIds) -> schema key (authors)
119
- const listSchemaKey = main_cjs.resolveStorageNameToSchemaName(schema, propName);
120
- if (listSchemaKey && schema[listSchemaKey]) {
121
- return listSchemaKey;
122
- }
123
- // Handle properties ending with 'Id' or 'Ids'
124
- let propertyNameWithoutId;
125
- if (propName.endsWith('Id')) {
126
- propertyNameWithoutId = propName.slice(0, -2);
127
- }
128
- else if (propName.endsWith('Ids')) {
129
- propertyNameWithoutId = propName.slice(0, -3);
130
- propertyNameWithoutId = pluralize(propertyNameWithoutId);
131
- }
132
- if (propertyNameWithoutId && schema[propertyNameWithoutId]) {
133
- return propertyNameWithoutId;
134
- }
135
- return undefined;
136
- };
137
- let resolvedPropertyName = resolvePropertyName(propertyName);
138
- if (!resolvedPropertyName && !usingModelProperties) {
139
- // A property added at runtime (ModelProperty.create) to a schema-file model isn't in the
140
- // Schema context. The schema file's definitions still win.
141
- const runtimeProperties = model.properties || [];
142
- if (runtimeProperties.length > 0) {
143
- schema = { ...main_cjs.modelPropertiesToObject(runtimeProperties), ...schema };
144
- resolvedPropertyName = resolvePropertyName(propertyName);
145
- }
146
- // model.properties can lag behind the properties table (in Node it never follows rows added
147
- // after the model found its own), so also look for a row with this exact name below.
148
- if (!resolvedPropertyName)
149
- resolvedPropertyName = propertyName;
150
- }
151
- if (!resolvedPropertyName) {
152
- return undefined;
153
- }
154
- // Try to get property from database first (may have edited values)
155
- try {
156
- const db = main_cjs.BaseDb.getAppDb();
157
- if (db) {
158
- // Find the model in the database (the same row as `model`, not just any model with this name)
159
- const resolvedModelRecord = await resolveModelRecord(modelName, { modelFileId: model.id ?? scope.modelFileId, schemaName: model.schemaName ?? scope.schemaName }, db);
160
- const modelRecords = resolvedModelRecord ? [resolvedModelRecord] : [];
161
- if (modelRecords.length > 0) {
162
- const modelRecord = modelRecords[0];
163
- // Find the property in the database by name
164
- let propertyRecords = await db
165
- .select()
166
- .from(main_cjs.properties)
167
- .where(drizzleOrm.and(drizzleOrm.eq(main_cjs.properties.name, resolvedPropertyName), drizzleOrm.eq(main_cjs.properties.modelId, modelRecord.id)))
168
- .limit(1);
169
- // If not found by name, check for renamed properties (orphaned DB properties)
170
- if (propertyRecords.length === 0) {
171
- // Get all properties for this model
172
- const allDbProperties = await db
173
- .select()
174
- .from(main_cjs.properties)
175
- .where(drizzleOrm.eq(main_cjs.properties.modelId, modelRecord.id));
176
- // Get all schema property names to identify orphaned properties
177
- const schemaPropertyNames = new Set(Object.keys(schema));
178
- // Get the schema property definition to match characteristics
179
- const schemaPropertyDef = schema[resolvedPropertyName];
180
- if (schemaPropertyDef) {
181
- // Find orphaned properties (don't match any schema property name) that match characteristics
182
- const orphanedProperties = allDbProperties.filter((p) => !schemaPropertyNames.has(p.name) && // Doesn't match any schema property name
183
- p.dataType === schemaPropertyDef.dataType // Same dataType
184
- );
185
- // If there's exactly one orphaned property with matching characteristics, it's likely the renamed property
186
- // We can also match by refModelId if it's a relation
187
- if (orphanedProperties.length > 0) {
188
- let matchedProperty = orphanedProperties[0];
189
- // If it's a relation, try to match by refModelId
190
- if (schemaPropertyDef.ref) {
191
- const refModelRecord = await resolveModelRecord(schemaPropertyDef.ref, { schemaName: model.schemaName }, db);
192
- if (refModelRecord) {
193
- const expectedRefModelId = refModelRecord.id;
194
- const matchingByRef = orphanedProperties.find((p) => p.refModelId === expectedRefModelId);
195
- if (matchingByRef) {
196
- matchedProperty = matchingByRef;
197
- }
198
- }
199
- }
200
- else {
201
- // For non-relation properties, prefer ones without refModelId
202
- const withoutRef = orphanedProperties.find((p) => p.refModelId === null);
203
- if (withoutRef) {
204
- matchedProperty = withoutRef;
205
- }
206
- }
207
- propertyRecords = [matchedProperty];
208
- }
209
- }
210
- }
211
- if (propertyRecords.length > 0) {
212
- const propertyRecord = propertyRecords[0];
213
- // Get the base schema from file to merge with database values
214
- // Use the schema object created earlier, not model.schema (which doesn't exist)
215
- const schemaFromFile = schema[resolvedPropertyName];
216
- // Build property schema from database, merging with file schema for fields not in DB
217
- // Use the schema property name (resolvedPropertyName) even if DB has different name (renamed)
218
- const propertySchema = {
219
- ...schemaFromFile, // Start with file schema (has all fields like storageType, etc.)
220
- id: propertyRecord.schemaFileId || propertyRecord.id?.toString(), // id should be schemaFileId (string), not database ID
221
- _dbId: propertyRecord.id, // Store database integer ID separately
222
- name: resolvedPropertyName, // Use schema name, not DB name (for renamed properties)
223
- dataType: propertyRecord.dataType,
224
- modelId: propertyRecord.modelId,
225
- modelName,
226
- refModelId: propertyRecord.refModelId || undefined,
227
- refValueType: propertyRecord.refValueType || undefined,
228
- required: propertyRecord.required ?? undefined,
229
- storageType: propertyRecord.storageType ?? schemaFromFile?.storageType,
230
- localStorageDir: propertyRecord.localStorageDir ?? schemaFromFile?.localStorageDir,
231
- filenameSuffix: propertyRecord.filenameSuffix ?? schemaFromFile?.filenameSuffix,
232
- // Include schemaFileId from database as _propertyFileId for ModelProperty.create()
233
- _propertyFileId: propertyRecord.schemaFileId || undefined,
234
- };
235
- // If refModelId is set, try to get the refModelName
236
- if (propertyRecord.refModelId) {
237
- const refModelRecords = await db
238
- .select()
239
- .from(main_cjs.models)
240
- .where(drizzleOrm.eq(main_cjs.models.id, propertyRecord.refModelId))
241
- .limit(1);
242
- if (refModelRecords.length > 0) {
243
- propertySchema.refModelName = refModelRecords[0].name;
244
- propertySchema.ref = refModelRecords[0].name;
245
- }
246
- }
247
- else if (schemaFromFile?.ref) {
248
- // If refModelId is not set but schema file has ref, resolve it from the database
249
- // This handles cases where the property was just created and refModelId hasn't been set yet
250
- propertySchema.ref = schemaFromFile.ref;
251
- propertySchema.refModelName = schemaFromFile.ref;
252
- // Try to resolve refModelId from the database using the model name
253
- try {
254
- const refModelRecord = await resolveModelRecord(schemaFromFile.ref, { schemaName: model.schemaName }, db);
255
- if (refModelRecord?.id) {
256
- propertySchema.refModelId = refModelRecord.id;
257
- }
258
- }
259
- catch (error) {
260
- // Ignore errors - model might not exist yet
261
- }
262
- }
263
- return propertySchema;
264
- }
265
- }
266
- }
267
- }
268
- catch (error) {
269
- // Database not available or error - fall through to schema file lookup
270
- }
271
- // Fall back to schema file lookup
272
- const schemaFromFile = schema[resolvedPropertyName];
273
- if (schemaFromFile) {
274
- const propertySchema = { ...schemaFromFile, name: resolvedPropertyName };
275
- // If schema file has id as a string (propertyFileId), set it as _propertyFileId
276
- // This handles cases where the property hasn't been saved to the database yet
277
- if (typeof schemaFromFile.id === 'string') {
278
- propertySchema._propertyFileId = schemaFromFile.id;
279
- }
280
- // If the schema file has ref but no refModelId, try to resolve it from the database
281
- if (schemaFromFile.ref && !propertySchema.refModelId) {
282
- try {
283
- const db = main_cjs.BaseDb.getAppDb();
284
- if (db) {
285
- const refModelRecord = await resolveModelRecord(schemaFromFile.ref, { schemaName: model.schemaName }, db);
286
- if (refModelRecord?.id) {
287
- propertySchema.refModelId = refModelRecord.id;
288
- propertySchema.refModelName = schemaFromFile.ref;
289
- }
290
- }
291
- }
292
- catch (error) {
293
- // Ignore errors - model might not exist yet or database not available
294
- }
295
- }
296
- return propertySchema;
297
- }
298
- return undefined;
299
- };
300
-
301
- exports.Boolean = main_cjs.Boolean;
302
- exports.Date = main_cjs.Date;
303
- exports.File = main_cjs.File;
304
- exports.Html = main_cjs.Html;
305
- exports.Image = main_cjs.Image;
306
- exports.Json = main_cjs.Json;
307
- exports.List = main_cjs.List;
308
- Object.defineProperty(exports, "ModelPropertyDataTypes", {
309
- enumerable: true,
310
- get: function () { return main_cjs.ModelPropertyDataTypes; }
311
- });
312
- exports.Number = main_cjs.Number;
313
- exports.Property = main_cjs.Property;
314
- exports.PropertyConstructor = main_cjs.PropertyConstructor;
315
- exports.PropertyMetadataKey = main_cjs.PropertyMetadataKey;
316
- exports.Relation = main_cjs.Relation;
317
- exports.THtmlEmbeddedDataUriPolicy = main_cjs.THtmlEmbeddedDataUriPolicy;
318
- exports.TProperty = main_cjs.TProperty;
319
- exports.TPropertyConstructor = main_cjs.TPropertyConstructor;
320
- exports.TPropertyDataType = main_cjs.TPropertyDataType;
321
- exports.TPropertyDefs = main_cjs.TPropertyDefs;
322
- exports.TStorageType = main_cjs.TStorageType;
323
- exports.Text = main_cjs.Text;
324
- exports.isDataType = main_cjs.isDataType;
325
- exports.normalizeDataType = main_cjs.normalizeDataType;
326
- exports.normalizePropertyRecordSchema = main_cjs.normalizePropertyRecordSchema;
327
- exports.getPropertySchema = getPropertySchema;
328
- //# sourceMappingURL=property-fa0iju0J.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"property-fa0iju0J.js","sources":["../../../src/helpers/property.ts"],"sourcesContent":["import { Static } from '@sinclair/typebox'\nimport { TProperty } from '@/Schema'\n// Dynamic import to break circular dependency: Model -> ... -> helpers/property -> Model\n// import { Model } from '@/Model/Model'\nimport pluralize from 'pluralize'\nimport { resolveStorageNameToSchemaName } from '@/helpers/metadataPropertyNames'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models as modelsTable, properties, PropertyType } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { modelPropertiesToObject } from '@/helpers/model'\n\n// Re-export everything from property/index.ts to make it available when importing from helpers/property\nexport * from './property/index'\n\n/**\n * Gets the propertyRecordSchema object for a given model and property name.\n * \n * The propertyRecordSchema is the property definition object that contains\n * information about the property's data type, storage configuration, and\n * relationship details (for Relation and List types).\n * \n * This function first checks the database for property definitions (which may\n * have been edited), then falls back to schema files. This ensures that\n * edited properties persist across page reloads.\n * \n * This function handles property names that end with 'Id' or 'Ids' by automatically\n * looking up the base property name in the schema (e.g., 'authorId' -> 'author',\n * 'tagIds' -> 'tags').\n * \n * @param modelName - The name of the model (e.g., 'Article', 'Author')\n * @param propertyName - The name of the property (e.g., 'title', 'author', 'authorId', 'tags', 'tagIds')\n * @returns The propertyRecordSchema object (TProperty with optional _propertyFileId) or undefined if not found\n * \n * @example\n * ```typescript\n * const schema = await getPropertySchema('Article', 'title')\n * // Returns: { dataType: 'Text', ... }\n * \n * const relationSchema = await getPropertySchema('Article', 'author')\n * // Returns: { dataType: 'Relation', ref: 'Author', ... }\n * \n * // Also works with Id/Ids suffixes\n * const relationSchemaById = await getPropertySchema('Article', 'authorId')\n * // Returns: { dataType: 'Relation', ref: 'Author', ... }\n * ```\n */\nexport const getPropertySchema = async (\n modelName: string,\n propertyName: string,\n /** Which model is meant when several schemas define one named modelName (Model.id and/or schema). */\n scope: { modelFileId?: string | null; schemaName?: string | null } = {},\n): Promise<(Static<typeof TProperty> & { _propertyFileId?: string }) | undefined> => {\n // Dynamic import to break circular dependency\n const modelMod = await import('../Model/Model')\n const { Model } = modelMod\n const schemaMod = await import('../Schema/Schema')\n const { Schema } = schemaMod\n const { resolveModelRecord } = await import('../db/read/resolveModelRecord')\n const model = await Model.resolveAsync(modelName, scope)\n\n if (!model) {\n return undefined\n }\n \n // Get the original schema from Schema instance context (has ref fields from schema file)\n // This is more reliable than modelPropertiesToObject which depends on ModelProperty instances\n let schema: { [propertyName: string]: any } = {}\n try {\n const schemaName = model.schemaName\n if (schemaName) {\n const schemaInstance = Schema.create(schemaName, {\n waitForReady: false,\n }) as import('@/Schema/Schema').Schema\n const schemaContext = schemaInstance.getService().getSnapshot().context\n if (schemaContext.models && schemaContext.models[modelName]) {\n // Get properties from Schema context (original schema file data)\n const modelDef = schemaContext.models[modelName]\n schema = modelDef.properties || {}\n }\n }\n } catch (error) {\n // Fall through to modelPropertiesToObject\n }\n \n // Fallback to modelPropertiesToObject if Schema context doesn't have the data\n const usingModelProperties = Object.keys(schema).length === 0\n if (usingModelProperties) {\n const properties = model.properties || []\n if (properties.length === 0) {\n return undefined\n }\n schema = modelPropertiesToObject(properties)\n }\n \n // Helper to resolve property name (handles Id/Ids suffixes)\n const resolvePropertyName = (propName: string): string | undefined => {\n // First, try direct lookup\n if (schema[propName]) {\n return propName\n }\n\n // List-of-relation storage name (e.g. authorIdentityIds) -> schema key (authors)\n const listSchemaKey = resolveStorageNameToSchemaName(schema, propName)\n if (listSchemaKey && schema[listSchemaKey]) {\n return listSchemaKey\n }\n\n // Handle properties ending with 'Id' or 'Ids'\n let propertyNameWithoutId: string | undefined\n \n if (propName.endsWith('Id')) {\n propertyNameWithoutId = propName.slice(0, -2)\n } else if (propName.endsWith('Ids')) {\n propertyNameWithoutId = propName.slice(0, -3)\n propertyNameWithoutId = pluralize(propertyNameWithoutId)\n }\n \n if (propertyNameWithoutId && schema[propertyNameWithoutId]) {\n return propertyNameWithoutId\n }\n \n return undefined\n }\n \n let resolvedPropertyName = resolvePropertyName(propertyName)\n if (!resolvedPropertyName && !usingModelProperties) {\n // A property added at runtime (ModelProperty.create) to a schema-file model isn't in the\n // Schema context. The schema file's definitions still win.\n const runtimeProperties = model.properties || []\n if (runtimeProperties.length > 0) {\n schema = { ...modelPropertiesToObject(runtimeProperties), ...schema }\n resolvedPropertyName = resolvePropertyName(propertyName)\n }\n // model.properties can lag behind the properties table (in Node it never follows rows added\n // after the model found its own), so also look for a row with this exact name below.\n if (!resolvedPropertyName) resolvedPropertyName = propertyName\n }\n if (!resolvedPropertyName) {\n return undefined\n }\n \n // Try to get property from database first (may have edited values)\n try {\n const db = BaseDb.getAppDb()\n if (db) {\n // Find the model in the database (the same row as `model`, not just any model with this name)\n const resolvedModelRecord = await resolveModelRecord(\n modelName,\n { modelFileId: model.id ?? scope.modelFileId, schemaName: model.schemaName ?? scope.schemaName },\n db,\n )\n const modelRecords = resolvedModelRecord ? [resolvedModelRecord] : []\n \n if (modelRecords.length > 0) {\n const modelRecord = modelRecords[0]\n \n // Find the property in the database by name\n let propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.name, resolvedPropertyName),\n eq(properties.modelId, modelRecord.id!),\n ),\n )\n .limit(1)\n \n // If not found by name, check for renamed properties (orphaned DB properties)\n if (propertyRecords.length === 0) {\n // Get all properties for this model\n const allDbProperties = await db\n .select()\n .from(properties)\n .where(eq(properties.modelId, modelRecord.id!))\n \n // Get all schema property names to identify orphaned properties\n const schemaPropertyNames = new Set(Object.keys(schema))\n \n // Get the schema property definition to match characteristics\n const schemaPropertyDef = schema[resolvedPropertyName]\n \n if (schemaPropertyDef) {\n // Find orphaned properties (don't match any schema property name) that match characteristics\n const orphanedProperties = allDbProperties.filter((p: PropertyType) => \n !schemaPropertyNames.has(p.name) && // Doesn't match any schema property name\n p.dataType === schemaPropertyDef.dataType // Same dataType\n )\n \n // If there's exactly one orphaned property with matching characteristics, it's likely the renamed property\n // We can also match by refModelId if it's a relation\n if (orphanedProperties.length > 0) {\n let matchedProperty = orphanedProperties[0]\n \n // If it's a relation, try to match by refModelId\n if (schemaPropertyDef.ref) {\n const refModelRecord = await resolveModelRecord(\n schemaPropertyDef.ref,\n { schemaName: model.schemaName },\n db,\n )\n \n if (refModelRecord) {\n const expectedRefModelId = refModelRecord.id\n const matchingByRef = orphanedProperties.find((p: PropertyType) => p.refModelId === expectedRefModelId)\n if (matchingByRef) {\n matchedProperty = matchingByRef\n }\n }\n } else {\n // For non-relation properties, prefer ones without refModelId\n const withoutRef = orphanedProperties.find((p: PropertyType) => p.refModelId === null)\n if (withoutRef) {\n matchedProperty = withoutRef\n }\n }\n \n propertyRecords = [matchedProperty]\n }\n }\n }\n \n if (propertyRecords.length > 0) {\n const propertyRecord = propertyRecords[0]\n \n // Get the base schema from file to merge with database values\n // Use the schema object created earlier, not model.schema (which doesn't exist)\n const schemaFromFile = schema[resolvedPropertyName]\n \n // Build property schema from database, merging with file schema for fields not in DB\n // Use the schema property name (resolvedPropertyName) even if DB has different name (renamed)\n const propertySchema: Static<typeof TProperty> & { _propertyFileId?: string; _dbId?: number } = {\n ...schemaFromFile, // Start with file schema (has all fields like storageType, etc.)\n id: propertyRecord.schemaFileId || propertyRecord.id?.toString(), // id should be schemaFileId (string), not database ID\n _dbId: propertyRecord.id, // Store database integer ID separately\n name: resolvedPropertyName, // Use schema name, not DB name (for renamed properties)\n dataType: propertyRecord.dataType as any,\n modelId: propertyRecord.modelId,\n modelName,\n refModelId: propertyRecord.refModelId || undefined,\n refValueType: (propertyRecord.refValueType as any) || undefined,\n required: (propertyRecord as { required?: boolean }).required ?? undefined,\n storageType: (propertyRecord.storageType as any) ?? schemaFromFile?.storageType,\n localStorageDir: propertyRecord.localStorageDir ?? schemaFromFile?.localStorageDir,\n filenameSuffix: propertyRecord.filenameSuffix ?? schemaFromFile?.filenameSuffix,\n // Include schemaFileId from database as _propertyFileId for ModelProperty.create()\n _propertyFileId: propertyRecord.schemaFileId || undefined,\n }\n \n // If refModelId is set, try to get the refModelName\n if (propertyRecord.refModelId) {\n const refModelRecords = await db\n .select()\n .from(modelsTable)\n .where(eq(modelsTable.id, propertyRecord.refModelId))\n .limit(1)\n \n if (refModelRecords.length > 0) {\n propertySchema.refModelName = refModelRecords[0].name\n propertySchema.ref = refModelRecords[0].name\n }\n } else if (schemaFromFile?.ref) {\n // If refModelId is not set but schema file has ref, resolve it from the database\n // This handles cases where the property was just created and refModelId hasn't been set yet\n propertySchema.ref = schemaFromFile.ref\n propertySchema.refModelName = schemaFromFile.ref\n \n // Try to resolve refModelId from the database using the model name\n try {\n const refModelRecord = await resolveModelRecord(\n schemaFromFile.ref,\n { schemaName: model.schemaName },\n db,\n )\n \n if (refModelRecord?.id) {\n propertySchema.refModelId = refModelRecord.id\n }\n } catch (error) {\n // Ignore errors - model might not exist yet\n }\n }\n \n return propertySchema\n }\n }\n }\n } catch (error) {\n // Database not available or error - fall through to schema file lookup\n }\n \n // Fall back to schema file lookup\n const schemaFromFile = schema[resolvedPropertyName]\n if (schemaFromFile) {\n const propertySchema: Static<typeof TProperty> & { _propertyFileId?: string } = { ...schemaFromFile, name: resolvedPropertyName }\n \n // If schema file has id as a string (propertyFileId), set it as _propertyFileId\n // This handles cases where the property hasn't been saved to the database yet\n if (typeof schemaFromFile.id === 'string') {\n propertySchema._propertyFileId = schemaFromFile.id\n }\n \n // If the schema file has ref but no refModelId, try to resolve it from the database\n if (schemaFromFile.ref && !propertySchema.refModelId) {\n try {\n const db = BaseDb.getAppDb()\n if (db) {\n const refModelRecord = await resolveModelRecord(\n schemaFromFile.ref,\n { schemaName: model.schemaName },\n db,\n )\n \n if (refModelRecord?.id) {\n propertySchema.refModelId = refModelRecord.id\n propertySchema.refModelName = schemaFromFile.ref\n }\n }\n } catch (error) {\n // Ignore errors - model might not exist yet or database not available\n }\n }\n \n return propertySchema\n }\n return undefined\n}\n"],"names":["modelPropertiesToObject","resolveStorageNameToSchemaName","BaseDb","properties","and","eq","modelsTable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA;AAWA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