@seedprotocol/sdk 0.3.14 → 0.3.15

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 (180) hide show
  1. package/dist/addModel.js +93 -0
  2. package/dist/addModel.js.map +1 -0
  3. package/dist/bin.js +8 -5
  4. package/dist/bin.js.map +1 -1
  5. package/dist/main.js +1 -0
  6. package/dist/main.js.map +1 -1
  7. package/dist/protos/seed.proto +97 -0
  8. package/dist/rpcServer.js +358 -0
  9. package/dist/rpcServer.js.map +1 -0
  10. package/dist/scripts/addModel.d.ts +3 -0
  11. package/dist/scripts/addModel.d.ts.map +1 -0
  12. package/dist/scripts/bin.d.ts.map +1 -1
  13. package/dist/scripts/rpcServer.cursor.d.ts +2 -0
  14. package/dist/scripts/rpcServer.cursor.d.ts.map +1 -0
  15. package/dist/scripts/rpcServer.d.ts +3 -0
  16. package/dist/scripts/rpcServer.d.ts.map +1 -0
  17. package/dist/scripts/vite.config.d.ts +3 -0
  18. package/dist/scripts/vite.config.d.ts.map +1 -0
  19. package/dist/seedSchema/AppStateSchema.ts +2 -2
  20. package/dist/seedSchema/ConfigSchema.ts +18 -14
  21. package/dist/seedSchema/MetadataSchema.ts +2 -1
  22. package/dist/seedSchema/ModelSchema.ts +3 -3
  23. package/dist/seedSchema/SeedSchema.ts +2 -1
  24. package/dist/seedSchema/VersionSchema.ts +2 -1
  25. package/dist/seedSchema/index.ts +1 -0
  26. package/dist/src/Item/BaseItem.d.ts +1 -1
  27. package/dist/src/Item/BaseItem.d.ts.map +1 -1
  28. package/dist/src/Item/BaseItem.js.map +1 -1
  29. package/dist/src/ItemProperty/BaseItemProperty.d.ts +55 -192
  30. package/dist/src/ItemProperty/BaseItemProperty.d.ts.map +1 -1
  31. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +2 -1
  32. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  33. package/dist/src/ItemProperty/service/actors/hydrateFromDb.js +1 -0
  34. package/dist/src/ItemProperty/service/actors/hydrateFromDb.js.map +1 -1
  35. package/dist/src/ItemProperty/service/actors/initialize.d.ts +2 -1
  36. package/dist/src/ItemProperty/service/actors/initialize.d.ts.map +1 -1
  37. package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts +2 -1
  38. package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
  39. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts +2 -1
  40. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts.map +1 -1
  41. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +2 -2
  42. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
  43. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +2 -2
  44. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +1 -1
  45. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
  46. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  47. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.js +1 -0
  48. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.js.map +1 -1
  49. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts +2 -2
  50. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
  51. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +2 -2
  52. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts.map +1 -1
  53. package/dist/src/ItemProperty/service/propertyMachine.d.ts +60 -195
  54. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  55. package/dist/src/browser/react/services.js +1 -0
  56. package/dist/src/browser/react/services.js.map +1 -1
  57. package/dist/src/client/ClientManager.js +1 -0
  58. package/dist/src/client/ClientManager.js.map +1 -1
  59. package/dist/src/client/actors/initialize.d.ts.map +1 -1
  60. package/dist/src/client/actors/initialize.js +28 -14
  61. package/dist/src/client/actors/initialize.js.map +1 -1
  62. package/dist/src/client/actors/saveAppState.js +1 -0
  63. package/dist/src/client/actors/saveAppState.js.map +1 -1
  64. package/dist/src/client/index.d.ts +1 -1
  65. package/dist/src/client/index.d.ts.map +1 -1
  66. package/dist/src/db/Db/BaseDb.d.ts +1 -0
  67. package/dist/src/db/Db/BaseDb.d.ts.map +1 -1
  68. package/dist/src/db/Db/BaseDb.js +3 -0
  69. package/dist/src/db/Db/BaseDb.js.map +1 -1
  70. package/dist/src/db/read/getExistingItem.js +1 -0
  71. package/dist/src/db/read/getExistingItem.js.map +1 -1
  72. package/dist/src/db/read/getItemData.js +1 -0
  73. package/dist/src/db/read/getItemData.js.map +1 -1
  74. package/dist/src/db/read/getItemProperties.js +1 -0
  75. package/dist/src/db/read/getItemProperties.js.map +1 -1
  76. package/dist/src/db/read/getItemProperty.js +1 -0
  77. package/dist/src/db/read/getItemProperty.js.map +1 -1
  78. package/dist/src/db/read/getItems.js +1 -0
  79. package/dist/src/db/read/getItems.js.map +1 -1
  80. package/dist/src/db/read/getMetadata.js +1 -0
  81. package/dist/src/db/read/getMetadata.js.map +1 -1
  82. package/dist/src/db/read/getModelSchemas.js +1 -0
  83. package/dist/src/db/read/getModelSchemas.js.map +1 -1
  84. package/dist/src/db/read/getModels.js +1 -0
  85. package/dist/src/db/read/getModels.js.map +1 -1
  86. package/dist/src/db/read/getPropertyData.js +1 -0
  87. package/dist/src/db/read/getPropertyData.js.map +1 -1
  88. package/dist/src/db/read/getRelationValueData.js +1 -0
  89. package/dist/src/db/read/getRelationValueData.js.map +1 -1
  90. package/dist/src/db/read/getSeedData.js +1 -0
  91. package/dist/src/db/read/getSeedData.js.map +1 -1
  92. package/dist/src/db/read/getStorageTransactionIdForSeedUid.js +1 -0
  93. package/dist/src/db/read/getStorageTransactionIdForSeedUid.js.map +1 -1
  94. package/dist/src/db/read/getVersionData.js +1 -0
  95. package/dist/src/db/read/getVersionData.js.map +1 -1
  96. package/dist/src/db/read/subqueries/metadataLatest.js +1 -0
  97. package/dist/src/db/read/subqueries/metadataLatest.js.map +1 -1
  98. package/dist/src/db/read/subqueries/versionData.js +1 -0
  99. package/dist/src/db/read/subqueries/versionData.js.map +1 -1
  100. package/dist/src/db/write/createMetadata.js +1 -0
  101. package/dist/src/db/write/createMetadata.js.map +1 -1
  102. package/dist/src/db/write/createSeed.js +1 -0
  103. package/dist/src/db/write/createSeed.js.map +1 -1
  104. package/dist/src/db/write/createSeeds.js +1 -0
  105. package/dist/src/db/write/createSeeds.js.map +1 -1
  106. package/dist/src/db/write/createVersion.js +1 -0
  107. package/dist/src/db/write/createVersion.js.map +1 -1
  108. package/dist/src/db/write/deleteItem.js +1 -0
  109. package/dist/src/db/write/deleteItem.js.map +1 -1
  110. package/dist/src/db/write/saveAppState.js +1 -0
  111. package/dist/src/db/write/saveAppState.js.map +1 -1
  112. package/dist/src/db/write/saveMetadata.js +1 -0
  113. package/dist/src/db/write/saveMetadata.js.map +1 -1
  114. package/dist/src/db/write/updateItemPropertyValue.js +1 -0
  115. package/dist/src/db/write/updateItemPropertyValue.js.map +1 -1
  116. package/dist/src/db/write/updateMetadata.js +1 -0
  117. package/dist/src/db/write/updateMetadata.js.map +1 -1
  118. package/dist/src/events/files/download.js +1 -0
  119. package/dist/src/events/files/download.js.map +1 -1
  120. package/dist/src/events/item/syncDbWithEas.js +1 -0
  121. package/dist/src/events/item/syncDbWithEas.js.map +1 -1
  122. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +1 -1
  123. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  124. package/dist/src/helpers/FileManager/BaseFileManager.js.map +1 -1
  125. package/dist/src/helpers/db.js +1 -0
  126. package/dist/src/helpers/db.js.map +1 -1
  127. package/dist/src/helpers/environment.js +6 -1
  128. package/dist/src/helpers/environment.js.map +1 -1
  129. package/dist/src/helpers/index.d.ts.map +1 -1
  130. package/dist/src/helpers/index.js.map +1 -1
  131. package/dist/src/interfaces/IItem.d.ts +1 -1
  132. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  133. package/dist/src/node/Item/Item.js +11 -0
  134. package/dist/src/node/Item/Item.js.map +1 -0
  135. package/dist/src/node/ItemProperty/ItemProperty.js +10 -0
  136. package/dist/src/node/ItemProperty/ItemProperty.js.map +1 -0
  137. package/dist/src/node/codegen/drizzle.js +36 -2
  138. package/dist/src/node/codegen/drizzle.js.map +1 -1
  139. package/dist/src/node/db/Db.d.ts.map +1 -1
  140. package/dist/src/node/db/Db.js +64 -0
  141. package/dist/src/node/db/Db.js.map +1 -0
  142. package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
  143. package/dist/src/node/helpers/FileManager.js +50 -0
  144. package/dist/src/node/helpers/FileManager.js.map +1 -0
  145. package/dist/src/seedSchema/AppStateSchema.d.ts +2 -1
  146. package/dist/src/seedSchema/AppStateSchema.d.ts.map +1 -1
  147. package/dist/src/seedSchema/AppStateSchema.js.map +1 -1
  148. package/dist/src/seedSchema/ConfigSchema.d.ts +2 -0
  149. package/dist/src/seedSchema/ConfigSchema.d.ts.map +1 -1
  150. package/dist/src/seedSchema/ConfigSchema.js +5 -8
  151. package/dist/src/seedSchema/ConfigSchema.js.map +1 -1
  152. package/dist/src/seedSchema/MetadataSchema.d.ts +2 -1
  153. package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
  154. package/dist/src/seedSchema/MetadataSchema.js.map +1 -1
  155. package/dist/src/seedSchema/ModelSchema.d.ts +3 -2
  156. package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
  157. package/dist/src/seedSchema/ModelSchema.js.map +1 -1
  158. package/dist/src/seedSchema/SeedSchema.d.ts +2 -1
  159. package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
  160. package/dist/src/seedSchema/SeedSchema.js.map +1 -1
  161. package/dist/src/seedSchema/VersionSchema.d.ts +2 -1
  162. package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
  163. package/dist/src/seedSchema/VersionSchema.js.map +1 -1
  164. package/dist/src/seedSchema/index.d.ts +1 -0
  165. package/dist/src/seedSchema/index.d.ts.map +1 -1
  166. package/dist/src/services/allItems/actors/fetchRelatedItems.js +1 -0
  167. package/dist/src/services/allItems/actors/fetchRelatedItems.js.map +1 -1
  168. package/dist/src/services/allItems/actors/initialize.js +1 -0
  169. package/dist/src/services/allItems/actors/initialize.js.map +1 -1
  170. package/dist/src/services/global/actors/addModelsToDb.js +1 -0
  171. package/dist/src/services/global/actors/addModelsToDb.js.map +1 -1
  172. package/dist/src/services/global/actors/initialize.js +1 -0
  173. package/dist/src/services/global/actors/initialize.js.map +1 -1
  174. package/dist/src/services/internal/actors/saveConfig.js +1 -0
  175. package/dist/src/services/internal/actors/saveConfig.js.map +1 -1
  176. package/dist/src/services/publish/actors/preparePublishRequestData.js +1 -0
  177. package/dist/src/services/publish/actors/preparePublishRequestData.js.map +1 -1
  178. package/dist/src/types/item.d.ts +9 -8
  179. package/dist/src/types/item.d.ts.map +1 -1
  180. package/package.json +8 -2
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import { generateModelCode } from './src/node/codegen/drizzle.js';
4
+
5
+ // Parse command line arguments
6
+ const args = process.argv.slice(2);
7
+ const sourceSchemaFilePath = args[0];
8
+ const outputFilePath = args[1];
9
+ const jsonString = args[2];
10
+ if (!sourceSchemaFilePath || !outputFilePath || !jsonString) {
11
+ console.error('Usage: npx tsx bin/addModel.ts <source-schema-file-path> <output-file-path> <json-string>');
12
+ process.exit(1);
13
+ }
14
+ // Read the contents of the file
15
+ let fileContents;
16
+ try {
17
+ fileContents = fs.readFileSync(sourceSchemaFilePath, 'utf-8');
18
+ }
19
+ catch (error) {
20
+ console.error(`Error reading file at ${sourceSchemaFilePath}:`, error);
21
+ process.exit(1);
22
+ }
23
+ // Parse the JSON string
24
+ let jsonModel;
25
+ try {
26
+ jsonModel = JSON.parse(jsonString);
27
+ }
28
+ catch (error) {
29
+ console.error('Invalid JSON string:', error);
30
+ process.exit(1);
31
+ }
32
+ /**
33
+ * Simple function to inject a new model after the last model class and update the models object
34
+ * @param {string} schemaContent - The content of the schema file
35
+ * @param {string} newModelCode - The code for the new model to inject
36
+ * @returns {string} The updated schema content
37
+ */
38
+ const injectModel = (schemaContent, newModelCode) => {
39
+ // Extract the model name from the new code
40
+ const modelNameMatch = newModelCode.match(/class\s+(\w+)/);
41
+ if (!modelNameMatch) {
42
+ throw new Error("Could not extract model name from provided code");
43
+ }
44
+ const modelName = modelNameMatch[1];
45
+ // Find the 'const models' position
46
+ const modelsPos = schemaContent.indexOf('const models');
47
+ if (modelsPos === -1) {
48
+ throw new Error("Could not find 'const models' in the schema");
49
+ }
50
+ // Find the position of the last model class before 'const models'
51
+ const lastClassPos = schemaContent.lastIndexOf('@Model', modelsPos);
52
+ if (lastClassPos === -1) {
53
+ throw new Error("Could not find any model declarations in the schema");
54
+ }
55
+ // Find the end of the last class
56
+ const classEndPos = schemaContent.indexOf('}', lastClassPos);
57
+ if (classEndPos === -1) {
58
+ throw new Error("Could not find closing brace of the last model class");
59
+ }
60
+ // Find the position after the last class's closing brace
61
+ const insertModelPos = schemaContent.indexOf('\n', classEndPos) + 1;
62
+ // Insert the new model
63
+ let updatedSchema = schemaContent.slice(0, insertModelPos) +
64
+ "\n" + newModelCode + "\n\n" +
65
+ schemaContent.slice(insertModelPos);
66
+ // Find the closing brace of the models object
67
+ const modelsClosingBracePos = updatedSchema.indexOf('}', updatedSchema.indexOf('const models'));
68
+ // Add the new model to the models object
69
+ updatedSchema =
70
+ updatedSchema.slice(0, modelsClosingBracePos) +
71
+ ` ${modelName},\n` +
72
+ updatedSchema.slice(modelsClosingBracePos);
73
+ return updatedSchema;
74
+ };
75
+ if (fileContents.includes(`class ${jsonModel.name}`)) {
76
+ console.error(`Model with name ${jsonModel.name} already exists in the schema`);
77
+ process.exit(0);
78
+ }
79
+ const newModelCode = generateModelCode({
80
+ modelName: jsonModel.name,
81
+ properties: jsonModel.properties,
82
+ });
83
+ const updatedSchema = injectModel(fileContents, newModelCode);
84
+ // Write the new table file
85
+ try {
86
+ fs.writeFileSync(outputFilePath, updatedSchema, 'utf-8');
87
+ console.log(`Wrote updated schema file to ${outputFilePath}`);
88
+ }
89
+ catch (error) {
90
+ console.error('Error writing Drizzle table file:', error);
91
+ process.exit(1);
92
+ }
93
+ //# sourceMappingURL=addModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addModel.js","sources":["../../scripts/addModel.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport fs from 'fs';\nimport { generateModelCode } from '../src/node/codegen/drizzle';\n\n// Parse command line arguments\nconst args = process.argv.slice(2);\nconst sourceSchemaFilePath = args[0];\nconst outputFilePath = args[1];\nconst jsonString = args[2];\n\nif (!sourceSchemaFilePath || !outputFilePath || !jsonString) {\n console.error('Usage: npx tsx bin/addModel.ts <source-schema-file-path> <output-file-path> <json-string>');\n process.exit(1);\n}\n\n// Read the contents of the file\nlet fileContents;\ntry {\n fileContents = fs.readFileSync(sourceSchemaFilePath, 'utf-8');\n} catch (error) {\n console.error(`Error reading file at ${sourceSchemaFilePath}:`, error);\n process.exit(1);\n}\n\n// Parse the JSON string\nlet jsonModel;\ntry {\n jsonModel = JSON.parse(jsonString);\n} catch (error) {\n console.error('Invalid JSON string:', error);\n process.exit(1);\n}\n\n/**\n * Simple function to inject a new model after the last model class and update the models object\n * @param {string} schemaContent - The content of the schema file\n * @param {string} newModelCode - The code for the new model to inject\n * @returns {string} The updated schema content\n */\nconst injectModel = (schemaContent: string, newModelCode: string) => {\n // Extract the model name from the new code\n const modelNameMatch = newModelCode.match(/class\\s+(\\w+)/);\n if (!modelNameMatch) {\n throw new Error(\"Could not extract model name from provided code\");\n }\n const modelName = modelNameMatch[1];\n\n // Find the 'const models' position\n const modelsPos = schemaContent.indexOf('const models');\n if (modelsPos === -1) {\n throw new Error(\"Could not find 'const models' in the schema\");\n }\n\n // Find the position of the last model class before 'const models'\n const lastClassPos = schemaContent.lastIndexOf('@Model', modelsPos);\n if (lastClassPos === -1) {\n throw new Error(\"Could not find any model declarations in the schema\");\n }\n\n // Find the end of the last class\n const classEndPos = schemaContent.indexOf('}', lastClassPos);\n if (classEndPos === -1) {\n throw new Error(\"Could not find closing brace of the last model class\");\n }\n\n // Find the position after the last class's closing brace\n const insertModelPos = schemaContent.indexOf('\\n', classEndPos) + 1;\n \n // Insert the new model\n let updatedSchema = \n schemaContent.slice(0, insertModelPos) + \n \"\\n\" + newModelCode + \"\\n\\n\" + \n schemaContent.slice(insertModelPos);\n \n // Find the closing brace of the models object\n const modelsClosingBracePos = updatedSchema.indexOf('}', updatedSchema.indexOf('const models'));\n \n // Add the new model to the models object\n updatedSchema = \n updatedSchema.slice(0, modelsClosingBracePos) + \n ` ${modelName},\\n` + \n updatedSchema.slice(modelsClosingBracePos);\n \n return updatedSchema;\n}\n\nif (fileContents.includes(`class ${jsonModel.name}`)) {\n console.error(`Model with name ${jsonModel.name} already exists in the schema`);\n process.exit(0);\n}\n\nconst newModelCode = generateModelCode({\n modelName: jsonModel.name,\n properties: jsonModel.properties,\n});\n\nconst updatedSchema = injectModel(fileContents, newModelCode);\n\n// Write the new table file\ntry {\n fs.writeFileSync(outputFilePath, updatedSchema, 'utf-8');\n console.log(`Wrote updated schema file to ${outputFilePath}`);\n} catch (error) {\n console.error('Error writing Drizzle table file:', error);\n process.exit(1);\n} \n"],"names":[],"mappings":";;;;AAKA;AACA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,MAAM,oBAAoB,GAAG,IAAI,CAAC,CAAC,CAAC;AACpC,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC;AAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;AAE1B,IAAI,CAAC,oBAAoB,IAAI,CAAC,cAAc,IAAI,CAA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aAAa,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC;AACxD,IAAA,OAAO,CAAC,GAAG,CAAC,gCAAgC,cAAc,CAAA,CAAE,CAAC;AAC/D;AAAE,OAAO,KAAK,EAAE;AACd,IAAA,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC;AACzD,IAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB"}
package/dist/bin.js CHANGED
@@ -16,13 +16,13 @@ import { rimrafSync } from 'rimraf';
16
16
  import { getTsImport } from './src/node/helpers/index.js';
17
17
  import { drizzle } from 'drizzle-orm/better-sqlite3';
18
18
  import Database from 'better-sqlite3';
19
- import { appState } from './src/seedSchema/AppStateSchema.js';
20
- import { config } from './src/seedSchema/ConfigSchema.js';
19
+ import { seeds } from './src/seedSchema/SeedSchema.js';
20
+ import { versions } from './src/seedSchema/VersionSchema.js';
21
21
  import { metadata } from './src/seedSchema/MetadataSchema.js';
22
+ import { appState } from './src/seedSchema/AppStateSchema.js';
22
23
  import { models } from './src/seedSchema/ModelSchema.js';
23
24
  import { modelUids } from './src/seedSchema/ModelUidSchema.js';
24
- import { seeds } from './src/seedSchema/SeedSchema.js';
25
- import { versions } from './src/seedSchema/VersionSchema.js';
25
+ import './src/seedSchema/ConfigSchema.js';
26
26
  import { commandExists } from './src/helpers/scripts.js';
27
27
 
28
28
  const __filename = fileURLToPath(import.meta.url);
@@ -213,7 +213,10 @@ const init = (args) => {
213
213
  await seedDatabase(seedDataFilePath);
214
214
  };
215
215
  copyDirectoryRecursively(path.join(pathResolver.getSdkRootDir(), 'seedSchema'), path.join(dotSeedDir, 'schema'));
216
- copyDirectoryRecursively(path.join(pathResolver.getSdkRootDir(), 'node', 'codegen'), path.join(dotSeedDir, 'codegen'));
216
+ // copyDirectoryRecursively(
217
+ // path.join(pathResolver.getSdkRootDir(), 'node', 'codegen'),
218
+ // path.join(dotSeedDir, 'codegen'),
219
+ // )
217
220
  console.log('copying', schemaFilePath, path.join(dotSeedDir, 'schema.ts'));
218
221
  fs.copyFileSync(schemaFilePath, path.join(dotSeedDir, 'schema.ts'));
219
222
  runCommands()
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sources":["../../scripts/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport path from 'path'\nimport fs from 'fs'\nimport { execSync, } from 'child_process'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport process from 'node:process'\nimport '@/node/helpers/EasClient'\nimport '@/node/helpers/QueryClient'\nimport '@/node/helpers/FileManager'\nimport '@/node/helpers/ArweaveClient'\nimport { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from '@/helpers/constants'\nimport { PathResolver } from '@/node/PathResolver'\nimport { createDrizzleSchemaFilesFromConfig } from '@/node/codegen'\nimport { rimrafSync } from 'rimraf'\nimport { getTsImport } from '@/node/helpers'\nimport { ModelClassType } from '@/types/model'\nimport { drizzle } from 'drizzle-orm/better-sqlite3'\nimport Database from 'better-sqlite3'\nimport { appState } from '@/seedSchema/AppStateSchema'\nimport { config } from '@/seedSchema/ConfigSchema'\nimport { metadata } from '@/seedSchema/MetadataSchema'\nimport { models } from '@/seedSchema/ModelSchema'\nimport { modelUids } from '@/seedSchema/ModelUidSchema'\nimport { seeds } from '@/seedSchema/SeedSchema'\nimport { versions } from '@/seedSchema/VersionSchema'\nimport { commandExists } from '@/helpers/scripts'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nlet a\n\na = process.argv.splice(2)\nconst pathResolver = PathResolver.getInstance()\n\n/**\n * Copy a directory and all its contents recursively\n * @param {string} sourceDir - Path to the source directory\n * @param {string} targetDir - Path to the target directory\n */\nfunction copyDirectoryRecursively(sourceDir: string, targetDir: string) {\n // Create the target directory if it doesn't exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n\n // Read all entries in the source directory\n const entries = fs.readdirSync(sourceDir);\n\n // Process each entry\n for (const entry of entries) {\n const sourcePath = path.join(sourceDir, entry);\n const targetPath = path.join(targetDir, entry);\n \n // Check if the entry is a file or directory\n const stats = fs.statSync(sourcePath);\n \n if (stats.isFile()) {\n // Copy the file directly\n fs.copyFileSync(sourcePath, targetPath);\n console.log(`Copied file: ${sourcePath} → ${targetPath}`);\n } \n else if (stats.isDirectory()) {\n // Recursively copy the subdirectory\n copyDirectoryRecursively(sourcePath, targetPath);\n }\n }\n}\n\nconst seedDatabase = async (seedDataPath: string) => {\n console.log('[Seed Protocol] Running seed script')\n\n try {\n // Read the seed data file\n const seedData = JSON.parse(fs.readFileSync(seedDataPath, 'utf-8'))\n \n // Connect to the database\n const dotSeedDir = pathResolver.getDotSeedDir()\n const dbPath = path.join(dotSeedDir, 'db', 'app_db.sqlite3')\n const sqlite = new Database(dbPath)\n const db = drizzle(sqlite)\n \n // Seed each table based on the provided data\n if (seedData.appState && seedData.appState.length > 0) {\n await db.insert(appState).values(seedData.appState)\n console.log('Seeded appState table')\n }\n \n if (seedData.config && seedData.config.length > 0) {\n await db.insert(config).values(seedData.config)\n console.log('Seeded config table')\n }\n \n if (seedData.models && seedData.models.length > 0) {\n await db.insert(models).values(seedData.models)\n console.log('Seeded models table')\n }\n \n if (seedData.modelUids && seedData.modelUids.length > 0) {\n await db.insert(modelUids).values(seedData.modelUids)\n console.log('Seeded modelUids table')\n }\n \n if (seedData.metadata && seedData.metadata.length > 0) {\n await db.insert(metadata).values(seedData.metadata)\n console.log('Seeded metadata table')\n }\n \n if (seedData.seeds && seedData.seeds.length > 0) {\n await db.insert(seeds).values(seedData.seeds)\n console.log('Seeded seeds table')\n }\n \n if (seedData.versions && seedData.versions.length > 0) {\n await db.insert(versions).values(seedData.versions)\n console.log('Seeded versions table')\n }\n \n console.log('[Seed Protocol] Successfully seeded database')\n } catch (error) {\n console.error('[Seed Protocol] Error seeding database:', error)\n process.exit(1)\n }\n}\n\nconst init = (args: string[],) => {\n console.log('args:', args)\n\n if (args && args.length) {\n if (args[0] === 'init') {\n console.log('[Seed Protocol] Running init script')\n\n let appFilesDirPath = args[2] || undefined\n let schemaFileDir = args[1]\n\n if (schemaFileDir && schemaFileDir.startsWith('.')) {\n const relativePath = schemaFileDir.replace('./', '')\n if (!process.cwd().includes(relativePath)) {\n schemaFileDir = path.resolve(schemaFileDir,)\n }\n if (process.cwd().includes(relativePath)) {\n schemaFileDir = process.cwd()\n }\n }\n\n if (!schemaFileDir && !process.cwd().includes('seed-protocol-sdk')) {\n schemaFileDir = process.cwd()\n }\n\n console.log('[Seed Protocol] schemaFileDir', schemaFileDir)\n\n if (!schemaFileDir) {\n const defaultSchemaFilePath = path.join(process.cwd(), 'schema.ts')\n if (fs.existsSync(defaultSchemaFilePath)) {\n schemaFileDir = process.cwd()\n } else {\n console.error('No schema file path provided and no default schema file found.')\n return\n }\n }\n\n const {\n dotSeedDir,\n appSchemaDir,\n appMetaDir,\n drizzleDbConfigPath,\n drizzleKitPath,\n sdkRootDir,\n } = pathResolver.getAppPaths(schemaFileDir)\n\n const schemaFilePath = path.join(schemaFileDir, SCHEMA_TS)\n\n // Remove dotSeedDir to start fresh each time\n if (fs.existsSync(dotSeedDir)) {\n fs.rmSync(dotSeedDir, { recursive: true, force: true })\n }\n\n console.log('[Seed Protocol] dotSeedDir', dotSeedDir)\n\n const tsconfigArg = `--tsconfig ${sdkRootDir}/tsconfig.json`\n\n const drizzleKitCommand = `npx --yes tsx ${drizzleKitPath}`\n\n const ensureIndexExports = (dirPath: string): void => {\n try {\n // Get all file names in the directory\n const files = fs.readdirSync(dirPath)\n\n // Filter for .ts files excluding index.ts\n const tsFiles = files.filter(\n (file) => file.endsWith('.ts') && file !== 'index.ts',\n )\n\n // Check if index.ts exists\n const indexFilePath = path.join(dirPath, 'index.ts')\n try {\n fs.accessSync(indexFilePath)\n } catch (error) {\n console.error(`index.ts not found in the directory: ${dirPath}`)\n return\n }\n\n // Read the content of index.ts\n const indexContent = fs.readFileSync(indexFilePath, 'utf8')\n\n // Create export statements for each .ts file\n const exportStatements = tsFiles.map(\n (file) => `export * from './${path.basename(file, '.ts')}';`,\n )\n\n // Check if each export statement is already present in index.ts\n const missingExports = exportStatements.filter(\n (statement) => !indexContent.includes(statement),\n )\n\n if (missingExports.length > 0) {\n // Append missing export statements to index.ts\n const newContent =\n indexContent + '\\n' + missingExports.join('\\n') + '\\n'\n fs.writeFileSync(indexFilePath, newContent, 'utf8')\n console.log(\n `Updated index.ts with missing exports:\\n${missingExports.join('\\n')}`,\n )\n } else {\n console.log('All exports are already present in index.ts')\n }\n } catch (error) {\n console.error(`Error processing directory: ${dirPath}`, error)\n }\n }\n\n const copyDotSeedFilesToAppFiles = async (_appFilesDirPath: string) => {\n console.log('[Seed Protocol] Copying dot seed files to app files')\n const { endpoints } = await getTsImport<{\n models: Record<string, ModelClassType>,\n endpoints: Record<string, string>\n }>(schemaFilePath)\n\n const outputDirPath = endpoints.localOutputDir || _appFilesDirPath\n\n const exists = await fs.promises.access(outputDirPath).then(() => true).catch(() => false)\n if (exists) {\n await fs.promises.rm(outputDirPath, { recursive: true, force: true })\n }\n \n console.log(`[Seed Protocol] making dir at ${outputDirPath}`)\n fs.mkdirSync(outputDirPath, { recursive: true })\n console.log('[Seed Protocol] copying app files')\n fs.cpSync(dotSeedDir, outputDirPath, { recursive: true })\n console.log('[Seed Protocol] removing sqlite3 files and index.ts files')\n rimrafSync(`${outputDirPath}/**/*.sqlite3`, { glob: true })\n rimrafSync(`${outputDirPath}/**/index.ts`, { glob: true })\n }\n\n const updateSchema = async (pathToConfig: string, pathToMeta: string) => {\n if (!fs.existsSync(pathToMeta)) {\n console.log(`${drizzleKitCommand} generate --config=${pathToConfig}`)\n execSync(\n `${drizzleKitCommand} generate --config=${pathToConfig}`,\n )\n }\n execSync(`${drizzleKitCommand} migrate --config=${pathToConfig}`)\n }\n\n const runCommands = async () => {\n const tsxExists = commandExists('tsx')\n if (!tsxExists) {\n execSync(`npm install -g tsx`, {stdio: 'inherit'})\n }\n\n await createDrizzleSchemaFilesFromConfig(schemaFilePath, undefined)\n ensureIndexExports(appSchemaDir!)\n await updateSchema(drizzleDbConfigPath, appMetaDir!)\n const seedDataFilePath = path.join(__dirname, 'seedData.json')\n await seedDatabase(seedDataFilePath)\n }\n\n copyDirectoryRecursively(\n path.join(pathResolver.getSdkRootDir(), 'seedSchema'),\n path.join(dotSeedDir, 'schema'),\n )\n\n copyDirectoryRecursively(\n path.join(pathResolver.getSdkRootDir(), 'node', 'codegen'),\n path.join(dotSeedDir, 'codegen'),\n )\n\n console.log('copying', schemaFilePath, path.join(dotSeedDir, 'schema.ts'))\n\n fs.copyFileSync(schemaFilePath, path.join(dotSeedDir, 'schema.ts'))\n\n runCommands()\n .then(() => {\n if (!appFilesDirPath) {\n console.log('[Seed Protocol] Finished running init script')\n } else {\n return copyDotSeedFilesToAppFiles(appFilesDirPath)\n }\n })\n .then(() => {\n console.log(INIT_SCRIPT_SUCCESS_MESSAGE)\n })\n } else if (args[0] === 'seed' && args[1]) {\n seedDatabase(args[1])\n } else {\n console.log('Unknown command. Available commands:')\n console.log('init [schemaPath] [appFilesPath] - Initialize the database')\n console.log('seed [seedDataPath] - Seed the database with data from JSON file')\n }\n }\n}\n\nconst calledFrom = pathToFileURL(process.argv[1]).href\n\nconsole.log('calledFrom', calledFrom)\n\nif (\n calledFrom.endsWith('node_modules/.bin/seed') ||\n import.meta.url.endsWith('@seedprotocol/sdk/node/bin.js') ||\n import.meta.url.endsWith('scripts/bin.ts')\n) {\n // module was not imported but called directly\n init(a)\n}\n\nexport { init }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;AAE1C,IAAI,CAAC;AAEL,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,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MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IACzD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAC1C;;IAEA,IAAI,CAAC,CAAC,CAAC;AACT;;;;"}
1
+ {"version":3,"file":"bin.js","sources":["../../scripts/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport path from 'path'\nimport fs from 'fs'\nimport { execSync, } from 'child_process'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport process from 'node:process'\nimport '@/node/helpers/EasClient'\nimport '@/node/helpers/QueryClient'\nimport '@/node/helpers/FileManager'\nimport '@/node/helpers/ArweaveClient'\nimport { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from '@/helpers/constants'\nimport { PathResolver } from '@/node/PathResolver'\nimport { createDrizzleSchemaFilesFromConfig } from '@/node/codegen'\nimport { rimrafSync } from 'rimraf'\nimport { getTsImport } from '@/node/helpers'\nimport { ModelClassType } from '@/types/model'\nimport { drizzle } from 'drizzle-orm/better-sqlite3'\nimport Database from 'better-sqlite3'\nimport { appState, metadata, models, modelUids, seeds, versions } from '@/seedSchema'\nimport { commandExists } from '@/helpers/scripts'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nlet a\n\na = process.argv.splice(2)\nconst pathResolver = PathResolver.getInstance()\n\n/**\n * Copy a directory and all its contents recursively\n * @param {string} sourceDir - Path to the source directory\n * @param {string} targetDir - Path to the target directory\n */\nfunction copyDirectoryRecursively(sourceDir: string, targetDir: string) {\n // Create the target directory if it doesn't exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n\n // Read all entries in the source directory\n const entries = fs.readdirSync(sourceDir);\n\n // Process each entry\n for (const entry of entries) {\n const sourcePath = path.join(sourceDir, entry);\n const targetPath = path.join(targetDir, entry);\n \n // Check if the entry is a file or directory\n const stats = fs.statSync(sourcePath);\n \n if (stats.isFile()) {\n // Copy the file directly\n fs.copyFileSync(sourcePath, targetPath);\n console.log(`Copied file: ${sourcePath} → ${targetPath}`);\n } \n else if (stats.isDirectory()) {\n // Recursively copy the subdirectory\n copyDirectoryRecursively(sourcePath, targetPath);\n }\n }\n}\n\nconst seedDatabase = async (seedDataPath: string) => {\n console.log('[Seed Protocol] Running seed script')\n\n try {\n // Read the seed data file\n const seedData = JSON.parse(fs.readFileSync(seedDataPath, 'utf-8'))\n \n // Connect to the database\n const dotSeedDir = pathResolver.getDotSeedDir()\n const dbPath = path.join(dotSeedDir, 'db', 'app_db.sqlite3')\n const sqlite = new Database(dbPath)\n const db = drizzle(sqlite)\n \n // Seed each table based on the provided data\n if (seedData.appState && seedData.appState.length > 0) {\n await db.insert(appState).values(seedData.appState)\n console.log('Seeded appState table')\n }\n \n if (seedData.config && seedData.config.length > 0) {\n await db.insert(config).values(seedData.config)\n console.log('Seeded config table')\n }\n \n if (seedData.models && seedData.models.length > 0) {\n await db.insert(models).values(seedData.models)\n console.log('Seeded models table')\n }\n \n if (seedData.modelUids && seedData.modelUids.length > 0) {\n await db.insert(modelUids).values(seedData.modelUids)\n console.log('Seeded modelUids table')\n }\n \n if (seedData.metadata && seedData.metadata.length > 0) {\n await db.insert(metadata).values(seedData.metadata)\n console.log('Seeded metadata table')\n }\n \n if (seedData.seeds && seedData.seeds.length > 0) {\n await db.insert(seeds).values(seedData.seeds)\n console.log('Seeded seeds table')\n }\n \n if (seedData.versions && seedData.versions.length > 0) {\n await db.insert(versions).values(seedData.versions)\n console.log('Seeded versions table')\n }\n \n console.log('[Seed Protocol] Successfully seeded database')\n } catch (error) {\n console.error('[Seed Protocol] Error seeding database:', error)\n process.exit(1)\n }\n}\n\nconst init = (args: string[],) => {\n console.log('args:', args)\n\n if (args && args.length) {\n if (args[0] === 'init') {\n console.log('[Seed Protocol] Running init script')\n\n let appFilesDirPath = args[2] || undefined\n let schemaFileDir = args[1]\n\n if (schemaFileDir && schemaFileDir.startsWith('.')) {\n const relativePath = schemaFileDir.replace('./', '')\n if (!process.cwd().includes(relativePath)) {\n schemaFileDir = path.resolve(schemaFileDir,)\n }\n if (process.cwd().includes(relativePath)) {\n schemaFileDir = process.cwd()\n }\n }\n\n if (!schemaFileDir && !process.cwd().includes('seed-protocol-sdk')) {\n schemaFileDir = process.cwd()\n }\n\n console.log('[Seed Protocol] schemaFileDir', schemaFileDir)\n\n if (!schemaFileDir) {\n const defaultSchemaFilePath = path.join(process.cwd(), 'schema.ts')\n if (fs.existsSync(defaultSchemaFilePath)) {\n schemaFileDir = process.cwd()\n } else {\n console.error('No schema file path provided and no default schema file found.')\n return\n }\n }\n\n const {\n dotSeedDir,\n appSchemaDir,\n appMetaDir,\n drizzleDbConfigPath,\n drizzleKitPath,\n sdkRootDir,\n } = pathResolver.getAppPaths(schemaFileDir)\n\n const schemaFilePath = path.join(schemaFileDir, SCHEMA_TS)\n\n // Remove dotSeedDir to start fresh each time\n if (fs.existsSync(dotSeedDir)) {\n fs.rmSync(dotSeedDir, { recursive: true, force: true })\n }\n\n console.log('[Seed Protocol] dotSeedDir', dotSeedDir)\n\n const tsconfigArg = `--tsconfig ${sdkRootDir}/tsconfig.json`\n\n const drizzleKitCommand = `npx --yes tsx ${drizzleKitPath}`\n\n const ensureIndexExports = (dirPath: string): void => {\n try {\n // Get all file names in the directory\n const files = fs.readdirSync(dirPath)\n\n // Filter for .ts files excluding index.ts\n const tsFiles = files.filter(\n (file) => file.endsWith('.ts') && file !== 'index.ts',\n )\n\n // Check if index.ts exists\n const indexFilePath = path.join(dirPath, 'index.ts')\n try {\n fs.accessSync(indexFilePath)\n } catch (error) {\n console.error(`index.ts not found in the directory: ${dirPath}`)\n return\n }\n\n // Read the content of index.ts\n const indexContent = fs.readFileSync(indexFilePath, 'utf8')\n\n // Create export statements for each .ts file\n const exportStatements = tsFiles.map(\n (file) => `export * from './${path.basename(file, '.ts')}';`,\n )\n\n // Check if each export statement is already present in index.ts\n const missingExports = exportStatements.filter(\n (statement) => !indexContent.includes(statement),\n )\n\n if (missingExports.length > 0) {\n // Append missing export statements to index.ts\n const newContent =\n indexContent + '\\n' + missingExports.join('\\n') + '\\n'\n fs.writeFileSync(indexFilePath, newContent, 'utf8')\n console.log(\n `Updated index.ts with missing exports:\\n${missingExports.join('\\n')}`,\n )\n } else {\n console.log('All exports are already present in index.ts')\n }\n } catch (error) {\n console.error(`Error processing directory: ${dirPath}`, error)\n }\n }\n\n const copyDotSeedFilesToAppFiles = async (_appFilesDirPath: string) => {\n console.log('[Seed Protocol] Copying dot seed files to app files')\n const { endpoints } = await getTsImport<{\n models: Record<string, ModelClassType>,\n endpoints: Record<string, string>\n }>(schemaFilePath)\n\n const outputDirPath = endpoints.localOutputDir || _appFilesDirPath\n\n const exists = await fs.promises.access(outputDirPath).then(() => true).catch(() => false)\n if (exists) {\n await fs.promises.rm(outputDirPath, { recursive: true, force: true })\n }\n \n console.log(`[Seed Protocol] making dir at ${outputDirPath}`)\n fs.mkdirSync(outputDirPath, { recursive: true })\n console.log('[Seed Protocol] copying app files')\n fs.cpSync(dotSeedDir, outputDirPath, { recursive: true })\n console.log('[Seed Protocol] removing sqlite3 files and index.ts files')\n rimrafSync(`${outputDirPath}/**/*.sqlite3`, { glob: true })\n rimrafSync(`${outputDirPath}/**/index.ts`, { glob: true })\n }\n\n const updateSchema = async (pathToConfig: string, pathToMeta: string) => {\n if (!fs.existsSync(pathToMeta)) {\n console.log(`${drizzleKitCommand} generate --config=${pathToConfig}`)\n execSync(\n `${drizzleKitCommand} generate --config=${pathToConfig}`,\n )\n }\n execSync(`${drizzleKitCommand} migrate --config=${pathToConfig}`)\n }\n\n const runCommands = async () => {\n const tsxExists = commandExists('tsx')\n if (!tsxExists) {\n execSync(`npm install -g tsx`, {stdio: 'inherit'})\n }\n\n await createDrizzleSchemaFilesFromConfig(schemaFilePath, undefined)\n ensureIndexExports(appSchemaDir!)\n await updateSchema(drizzleDbConfigPath, appMetaDir!)\n const seedDataFilePath = path.join(__dirname, 'seedData.json')\n await seedDatabase(seedDataFilePath)\n }\n\n copyDirectoryRecursively(\n path.join(pathResolver.getSdkRootDir(), 'seedSchema'),\n path.join(dotSeedDir, 'schema'),\n )\n\n // copyDirectoryRecursively(\n // path.join(pathResolver.getSdkRootDir(), 'node', 'codegen'),\n // path.join(dotSeedDir, 'codegen'),\n // )\n\n console.log('copying', schemaFilePath, path.join(dotSeedDir, 'schema.ts'))\n\n fs.copyFileSync(schemaFilePath, path.join(dotSeedDir, 'schema.ts'))\n\n runCommands()\n .then(() => {\n if (!appFilesDirPath) {\n console.log('[Seed Protocol] Finished running init script')\n } else {\n return copyDotSeedFilesToAppFiles(appFilesDirPath)\n }\n })\n .then(() => {\n console.log(INIT_SCRIPT_SUCCESS_MESSAGE)\n })\n } else if (args[0] === 'seed' && args[1]) {\n seedDatabase(args[1])\n } else {\n console.log('Unknown command. Available commands:')\n console.log('init [schemaPath] [appFilesPath] - Initialize the database')\n console.log('seed [seedDataPath] - Seed the database with data from JSON file')\n }\n }\n}\n\nconst calledFrom = pathToFileURL(process.argv[1]).href\n\nconsole.log('calledFrom', calledFrom)\n\nif (\n calledFrom.endsWith('node_modules/.bin/seed') ||\n import.meta.url.endsWith('@seedprotocol/sdk/node/bin.js') ||\n import.meta.url.endsWith('scripts/bin.ts')\n) {\n // module was not imported but called directly\n init(a)\n}\n\nexport { init }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;AAE1C,IAAI,CAAC;AAEL,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1B,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE;AAE/C;;;;AAIG;AACH,SAAS,wBAAwB,CAAC,SAAiB,EAAE,SAAi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ema/AppStateSchema.js';
20
20
  export { models } from './src/seedSchema/ModelSchema.js';
21
21
  import './src/seedSchema/ModelUidSchema.js';
22
+ import './src/seedSchema/ConfigSchema.js';
22
23
  export { getModel, getModelNames, getModels } from './src/stores/modelClass.js';
23
24
  export { getCorrectId } from './src/helpers/index.js';
24
25
  export { eventEmitter } from './src/eventBus.js';
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":["../../src/index.ts"],"sourcesContent":["import SeedImage from './browser/react/SeedImage'\nimport { enableMapSet } from 'immer'\n\nexport {\n Model,\n Property,\n Image,\n List,\n Text,\n Json,\n Relation,\n Boolean,\n Number,\n Date,\n} from './schema'\n\nexport { BaseItem as Item } from './Item/BaseItem'\nexport { BaseItemProperty as ItemProperty } from './ItemProperty/BaseItemProperty'\n\nexport {\n useItems,\n useItem,\n useItemProperties,\n useCreateItem,\n useItemProperty,\n useDeleteItem,\n useGlobalServiceStatus,\n usePublishItem,\n usePersistedSnapshots,\n useServices,\n useService,\n useModels,\n} from './browser/react'\n\n\nexport { SeedImage }\n\nexport {FileManager as FileManagerBrowser} from './browser/helpers/FileManager'\nexport {Db as DbBrowser} from './browser/db/Db'\n\nexport {models, versions, seeds, metadata, } from './seedSchema'\n\nexport {getModels, getModel, getModelNames,} from './stores/modelClass'\n\nexport { getCorrectId, } from './helpers'\n\nexport {\n eventEmitter,\n} from './eventBus'\n\nenableMapSet()\n\nexport { withSeed } from './node/webpack'\n\nexport type { PublishUpload } from './db/read/getPublishUploads'\n\n\nexport { client } from './client'\n\nexport * from './types'\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,YAAY,EAAE"}
1
+ {"version":3,"file":"main.js","sources":["../../src/index.ts"],"sourcesContent":["import SeedImage from './browser/react/SeedImage'\nimport { enableMapSet } from 'immer'\n\nexport {\n Model,\n Property,\n Image,\n List,\n Text,\n Json,\n Relation,\n Boolean,\n Number,\n Date,\n} from './schema'\n\nexport { BaseItem as Item } from './Item/BaseItem'\nexport { BaseItemProperty as ItemProperty } from './ItemProperty/BaseItemProperty'\n\nexport {\n useItems,\n useItem,\n useItemProperties,\n useCreateItem,\n useItemProperty,\n useDeleteItem,\n useGlobalServiceStatus,\n usePublishItem,\n usePersistedSnapshots,\n useServices,\n useService,\n useModels,\n} from './browser/react'\n\n\nexport { SeedImage }\n\nexport {FileManager as FileManagerBrowser} from './browser/helpers/FileManager'\nexport {Db as DbBrowser} from './browser/db/Db'\n\nexport {models, versions, seeds, metadata, } from './seedSchema'\n\nexport {getModels, getModel, getModelNames,} from './stores/modelClass'\n\nexport { getCorrectId, } from './helpers'\n\nexport {\n eventEmitter,\n} from './eventBus'\n\nenableMapSet()\n\nexport { withSeed } from './node/webpack'\n\nexport type { PublishUpload } from './db/read/getPublishUploads'\n\n\nexport { client } from './client'\n\nexport * from './types'\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,YAAY,EAAE"}
@@ -0,0 +1,97 @@
1
+ syntax = "proto3";
2
+
3
+ package seed;
4
+
5
+ // Main service definition
6
+ service SeedService {
7
+ // Model operations
8
+ rpc GetModels (Empty) returns (ModelsResponse);
9
+ rpc GetModel (ModelRequest) returns (ModelResponse);
10
+
11
+ // Item operations
12
+ rpc CreateItem (CreateItemRequest) returns (ItemResponse);
13
+ rpc GetItem (ItemRequest) returns (ItemResponse);
14
+ rpc UpdateItem (UpdateItemRequest) returns (ItemResponse);
15
+ rpc DeleteItem (ItemRequest) returns (StatusResponse);
16
+ rpc PublishItem (ItemRequest) returns (StatusResponse);
17
+
18
+ // Query operations
19
+ rpc QueryItems (QueryRequest) returns (ItemsResponse);
20
+ }
21
+
22
+ // Empty message for requests that don't need parameters
23
+ message Empty {}
24
+
25
+ // Request to get a specific model
26
+ message ModelRequest {
27
+ string model_name = 1;
28
+ }
29
+
30
+ // Response containing all available models
31
+ message ModelsResponse {
32
+ repeated ModelDefinition models = 1;
33
+ }
34
+
35
+ // Response containing a single model definition
36
+ message ModelResponse {
37
+ ModelDefinition model = 1;
38
+ }
39
+
40
+ // Model definition with properties
41
+ message ModelDefinition {
42
+ string name = 1;
43
+ repeated PropertyDefinition properties = 2;
44
+ }
45
+
46
+ // Property definition for a model
47
+ message PropertyDefinition {
48
+ string name = 1;
49
+ string type = 2;
50
+ string relation_model = 3; // If property is a relation, the model it relates to
51
+ bool is_list = 4; // If property is a list of items
52
+ }
53
+
54
+ // Request to create a new item
55
+ message CreateItemRequest {
56
+ string model_name = 1;
57
+ map<string, string> properties = 2;
58
+ }
59
+
60
+ // Request to get a specific item
61
+ message ItemRequest {
62
+ string id = 1;
63
+ string model_name = 2;
64
+ }
65
+
66
+ // Request to update an existing item
67
+ message UpdateItemRequest {
68
+ string id = 1;
69
+ string model_name = 2;
70
+ map<string, string> properties = 3;
71
+ }
72
+
73
+ // Response containing an item
74
+ message ItemResponse {
75
+ string id = 1;
76
+ string model_name = 2;
77
+ map<string, string> properties = 3;
78
+ }
79
+
80
+ // Response containing multiple items
81
+ message ItemsResponse {
82
+ repeated ItemResponse items = 1;
83
+ }
84
+
85
+ // Query request to filter items
86
+ message QueryRequest {
87
+ string model_name = 1;
88
+ map<string, string> filters = 2;
89
+ int32 limit = 3;
90
+ int32 offset = 4;
91
+ }
92
+
93
+ // Simple status response
94
+ message StatusResponse {
95
+ bool success = 1;
96
+ string message = 2;
97
+ }