@seedprotocol/sdk 0.5.1 → 0.5.2

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 (111) hide show
  1. package/dist/{ModelProperty-D-ysg8zA.js → ModelProperty-BBXBvgvy.js} +19 -18
  2. package/dist/ModelProperty-BBXBvgvy.js.map +1 -0
  3. package/dist/{Schema-CyCftnKI.js → Schema-xAt7jWlW.js} +36 -36
  4. package/dist/{Schema-CyCftnKI.js.map → Schema-xAt7jWlW.js.map} +1 -1
  5. package/dist/{SchemaValidationService-POM6jHbJ.js → SchemaValidationService-CLzAdBm-.js} +5 -4
  6. package/dist/{SchemaValidationService-POM6jHbJ.js.map → SchemaValidationService-CLzAdBm-.js.map} +1 -1
  7. package/dist/{backfillMetadataPropertyIds-DzZw57iJ.js → backfillMetadataPropertyIds-DBVaIs7O.js} +2 -2
  8. package/dist/{backfillMetadataPropertyIds-DzZw57iJ.js.map → backfillMetadataPropertyIds-DBVaIs7O.js.map} +1 -1
  9. package/dist/cjs/{ModelProperty-CmuGJvyi.js → ModelProperty-Dgd4tGrB.js} +18 -18
  10. package/dist/cjs/{ModelProperty-CmuGJvyi.js.map → ModelProperty-Dgd4tGrB.js.map} +1 -1
  11. package/dist/cjs/{Schema-gpFnZMhB.js → Schema-dkd-eo3B.js} +21 -21
  12. package/dist/cjs/{Schema-gpFnZMhB.js.map → Schema-dkd-eo3B.js.map} +1 -1
  13. package/dist/cjs/{SchemaValidationService-E3xTSRai.js → SchemaValidationService-BMnjcVWV.js} +3 -3
  14. package/dist/cjs/{SchemaValidationService-E3xTSRai.js.map → SchemaValidationService-BMnjcVWV.js.map} +1 -1
  15. package/dist/cjs/{backfillMetadataPropertyIds-_bivrvRs.js → backfillMetadataPropertyIds-ClLuj3s6.js} +3 -3
  16. package/dist/cjs/{backfillMetadataPropertyIds-_bivrvRs.js.map → backfillMetadataPropertyIds-ClLuj3s6.js.map} +1 -1
  17. package/dist/cjs/{eas-BwDKJmlb.js → eas-nWAzbl_F.js} +4 -4
  18. package/dist/cjs/{eas-BwDKJmlb.js.map → eas-nWAzbl_F.js.map} +1 -1
  19. package/dist/cjs/{getItem-MShQw3sz.js → getItem-B08FgglK.js} +3 -3
  20. package/dist/cjs/{getItem-MShQw3sz.js.map → getItem-B08FgglK.js.map} +1 -1
  21. package/dist/cjs/{getPublishPayload-C1nOOXp_.js → getPublishPayload-B_G_6qkE.js} +12 -12
  22. package/dist/cjs/{getPublishPayload-C1nOOXp_.js.map → getPublishPayload-B_G_6qkE.js.map} +1 -1
  23. package/dist/cjs/{getPublishUploads-BjgxgrKD.js → getPublishUploads-Dt-DS-lo.js} +5 -5
  24. package/dist/cjs/{getPublishUploads-BjgxgrKD.js.map → getPublishUploads-Dt-DS-lo.js.map} +1 -1
  25. package/dist/cjs/{getSegmentedItemProperties-Cuw7wcxb.js → getSegmentedItemProperties-BDGbeDW7.js} +3 -3
  26. package/dist/cjs/{getSegmentedItemProperties-Cuw7wcxb.js.map → getSegmentedItemProperties-BDGbeDW7.js.map} +1 -1
  27. package/dist/cjs/{index-vk2DeF2D.js → index-CRBI6dSD.js} +475 -58
  28. package/dist/cjs/index-CRBI6dSD.js.map +1 -0
  29. package/dist/cjs/{index-9Z2FOvLD.js → index-Dx19j60c.js} +4 -4
  30. package/dist/cjs/index-Dx19j60c.js.map +1 -0
  31. package/dist/cjs/{ownership-DhWda0J9.js → ownership-3Tc1-Yrc.js} +3 -3
  32. package/dist/cjs/{ownership-DhWda0J9.js.map → ownership-3Tc1-Yrc.js.map} +1 -1
  33. package/dist/cjs/{property-D3Ww2_Qh.js → property-628qAHpN.js} +5 -5
  34. package/dist/cjs/{property-D3Ww2_Qh.js.map → property-628qAHpN.js.map} +1 -1
  35. package/dist/cjs/{syncDbWithEas-Dht3_7UD.js → syncDbWithEas-DOBtMPw-.js} +46 -49
  36. package/dist/cjs/syncDbWithEas-DOBtMPw-.js.map +1 -0
  37. package/dist/{configurePlatform-R5neRbQ9.js → configurePlatform-Ce6NIKRP.js} +3 -2
  38. package/dist/{configurePlatform-R5neRbQ9.js.map → configurePlatform-Ce6NIKRP.js.map} +1 -1
  39. package/dist/{constants-B5S5JPDK.js → constants-slkc9uq0.js} +13 -18
  40. package/dist/constants-slkc9uq0.js.map +1 -0
  41. package/dist/{db-Cvh84NY7.js → db-CSmK0c3e.js} +9 -9
  42. package/dist/{db-Cvh84NY7.js.map → db-CSmK0c3e.js.map} +1 -1
  43. package/dist/{eas-D9b7z2Wn.js → eas-rx1grht5.js} +5 -4
  44. package/dist/eas-rx1grht5.js.map +1 -0
  45. package/dist/{getItem-B81V3m4S.js → getItem-hPBJU5JF.js} +5 -4
  46. package/dist/{getItem-B81V3m4S.js.map → getItem-hPBJU5JF.js.map} +1 -1
  47. package/dist/{getPublishPayload-CNYsn8-6.js → getPublishPayload-5ugovGK5.js} +16 -15
  48. package/dist/getPublishPayload-5ugovGK5.js.map +1 -0
  49. package/dist/{getPublishUploads-D9rPHkB7.js → getPublishUploads-CdWeci-s.js} +7 -6
  50. package/dist/{getPublishUploads-D9rPHkB7.js.map → getPublishUploads-CdWeci-s.js.map} +1 -1
  51. package/dist/{getSegmentedItemProperties-Bg3_b-b1.js → getSegmentedItemProperties-DV2LHElJ.js} +4 -4
  52. package/dist/{getSegmentedItemProperties-Bg3_b-b1.js.map → getSegmentedItemProperties-DV2LHElJ.js.map} +1 -1
  53. package/dist/{index-oi4roUVf.js → index-CcH2e0Zr.js} +6 -5
  54. package/dist/index-CcH2e0Zr.js.map +1 -0
  55. package/dist/{index--F3Wolt5.js → index-ClwdGWfr.js} +477 -45
  56. package/dist/index-ClwdGWfr.js.map +1 -0
  57. package/dist/{index.node-Bow8kHew.js → index.node-CrXwRoiB.js} +2 -2
  58. package/dist/{index.node-Bow8kHew.js.map → index.node-CrXwRoiB.js.map} +1 -1
  59. package/dist/main.cjs +3 -6
  60. package/dist/main.cjs.map +1 -1
  61. package/dist/main.js +19 -18
  62. package/dist/main.js.map +1 -1
  63. package/dist/node.js +30 -9
  64. package/dist/node.js.map +1 -1
  65. package/dist/{ownership-BF_ZUKIp.js → ownership-58i0iyD9.js} +5 -4
  66. package/dist/{ownership-BF_ZUKIp.js.map → ownership-58i0iyD9.js.map} +1 -1
  67. package/dist/platform.browser.js +16 -3
  68. package/dist/platform.browser.js.map +1 -1
  69. package/dist/platform.node.js +1 -1
  70. package/dist/{property-BdyDfcSc.js → property-CKhOxRNt.js} +8 -7
  71. package/dist/property-CKhOxRNt.js.map +1 -0
  72. package/dist/src/Item/service/actors/saveDataToDb.d.ts.map +1 -1
  73. package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
  74. package/dist/src/client/ClientManager.d.ts.map +1 -1
  75. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  76. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  77. package/dist/src/db/read/getItemData.d.ts +8 -0
  78. package/dist/src/db/read/getItemData.d.ts.map +1 -1
  79. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  80. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +1 -1
  81. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +1 -1
  82. package/dist/src/helpers/index.d.ts +1 -5
  83. package/dist/src/helpers/index.d.ts.map +1 -1
  84. package/dist/src/helpers/mediaRef.d.ts +3 -0
  85. package/dist/src/helpers/mediaRef.d.ts.map +1 -1
  86. package/dist/src/index.d.ts +4 -0
  87. package/dist/src/index.d.ts.map +1 -1
  88. package/dist/src/node/webpack/index.d.ts +4 -1
  89. package/dist/src/node/webpack/index.d.ts.map +1 -1
  90. package/dist/src/query/createLocalQueryDataSource.d.ts +6 -0
  91. package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -0
  92. package/dist/src/query/index.d.ts +4 -0
  93. package/dist/src/query/index.d.ts.map +1 -0
  94. package/dist/src/query/registerSeedQueryLocalSource.d.ts +25 -0
  95. package/dist/src/query/registerSeedQueryLocalSource.d.ts.map +1 -0
  96. package/dist/src/types/machines.d.ts +2 -0
  97. package/dist/src/types/machines.d.ts.map +1 -1
  98. package/dist/{syncDbWithEas-DMOJHtkP.js → syncDbWithEas-GsaXzTIY.js} +50 -52
  99. package/dist/syncDbWithEas-GsaXzTIY.js.map +1 -0
  100. package/package.json +5 -5
  101. package/dist/ModelProperty-D-ysg8zA.js.map +0 -1
  102. package/dist/cjs/index-9Z2FOvLD.js.map +0 -1
  103. package/dist/cjs/index-vk2DeF2D.js.map +0 -1
  104. package/dist/cjs/syncDbWithEas-Dht3_7UD.js.map +0 -1
  105. package/dist/constants-B5S5JPDK.js.map +0 -1
  106. package/dist/eas-D9b7z2Wn.js.map +0 -1
  107. package/dist/getPublishPayload-CNYsn8-6.js.map +0 -1
  108. package/dist/index--F3Wolt5.js.map +0 -1
  109. package/dist/index-oi4roUVf.js.map +0 -1
  110. package/dist/property-BdyDfcSc.js.map +0 -1
  111. package/dist/syncDbWithEas-DMOJHtkP.js.map +0 -1
package/dist/node.js CHANGED
@@ -1,22 +1,21 @@
1
1
  import { enableMapSet } from 'immer';
2
2
  import 'reflect-metadata';
3
- export { I as Item, h as ItemProperty, M as Model, C as client, i as eventEmitter, j as getRefValueType, k as importJsonSchema, l as loadSchemaFromFile, n as readJsonImportFile, s as syncSchemaFromSource, t as transformImportToSchemaFile } from './index--F3Wolt5.js';
4
- import { M as ModelPropertyDataTypes, P as Property } from './constants-B5S5JPDK.js';
5
- export { B as Boolean, D as Date, I as Image, J as Json, L as List, N as Number, R as Relation, h as Text, l as getCorrectId } from './constants-B5S5JPDK.js';
3
+ export { I as Item, j as ItemProperty, M as Model, C as client, h as eventEmitter, k as getRefValueType, l as importJsonSchema, n as loadSchemaFromFile, o as readJsonImportFile, q as syncSchemaFromSource, t as transformImportToSchemaFile } from './index-ClwdGWfr.js';
4
+ import { M as ModelPropertyDataTypes, P as Property } from './constants-slkc9uq0.js';
5
+ export { B as Boolean, D as Date, I as Image, J as Json, L as List, N as Number, R as Relation, h as Text, l as getCorrectId } from './constants-slkc9uq0.js';
6
6
  import 'pluralize';
7
7
  import { B as BaseDb } from './BasePathResolver-BDgc7c4T.js';
8
8
  export { t as BasePathResolver, b as appState, d as config, f as metadata, j as modelUids, m as models, s as seeds, v as versions } from './BasePathResolver-BDgc7c4T.js';
9
9
  import 'drizzle-orm';
10
- import { c as createPlatformServices } from './index.node-Bow8kHew.js';
11
- export { D as Db, F as FileManager, P as PathResolver, r as resolveSdkDrizzleMigrationsDir } from './index.node-Bow8kHew.js';
10
+ import { c as createPlatformServices } from './index.node-CrXwRoiB.js';
11
+ export { D as Db, F as FileManager, P as PathResolver, r as resolveSdkDrizzleMigrationsDir } from './index.node-CrXwRoiB.js';
12
12
  import yaml from 'js-yaml';
13
13
  import fs__default, { readFileSync } from 'fs';
14
- import { addModelsToDb } from './db-Cvh84NY7.js';
15
- export { withSeed } from '@seedprotocol/webpack';
14
+ import { addModelsToDb } from './db-CSmK0c3e.js';
16
15
  import { execSync } from 'child_process';
17
16
  import path from 'path';
18
17
  export { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from './constants-DMHTYMgJ.js';
19
- import { configurePlatform } from './configurePlatform-R5neRbQ9.js';
18
+ import { configurePlatform } from './configurePlatform-Ce6NIKRP.js';
20
19
  import 'xstate';
21
20
  import 'debug';
22
21
  import 'nanoid';
@@ -27,6 +26,7 @@ import 'lodash-es';
27
26
  import 'drizzle-orm/casing';
28
27
  import '@seedprotocol/arweave';
29
28
  import 'js-sha3';
29
+ import '@seedprotocol/query';
30
30
  import '@sinclair/typebox';
31
31
  import 'drizzle-orm/sqlite-core';
32
32
  import 'fs/promises';
@@ -172,6 +172,27 @@ const saveModelsFromMarkdown = async (filePath, db) => {
172
172
  return modelDefinitions;
173
173
  };
174
174
 
175
+ /**
176
+ * Webpack / Next.js config helper for Seed Protocol apps.
177
+ */
178
+ const withSeed = (config, webpack, isServer) => {
179
+ config.plugins.push(new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
180
+ resource.request = resource.request.replace(/^node:/, '');
181
+ }));
182
+ if (!isServer) {
183
+ config.resolve.alias['fs'] = '@zenfs/core';
184
+ config.resolve.alias['node:fs'] = '@zenfs/core';
185
+ config.resolve.alias['node:path'] = 'path-browserify';
186
+ config.resolve.alias['path'] = 'path-browserify';
187
+ }
188
+ if (isServer) {
189
+ config.externals.push('@sqlite.org/sqlite-wasm');
190
+ config.externals.push('chokidar');
191
+ config.externals.push('arweave');
192
+ }
193
+ return config;
194
+ };
195
+
175
196
  const commandExists = (command) => {
176
197
  try {
177
198
  execSync(`which ${command}`, { stdio: 'ignore' });
@@ -218,5 +239,5 @@ const runSeedInit = ensureNodeDbSchema;
218
239
  configurePlatform(createPlatformServices());
219
240
  enableMapSet();
220
241
 
221
- export { Property, commandExists, ensureNodeDbSchema, findSeedBinary, parseMarkdownFrontmatter, processSeedConfig, runSeedInit, saveModelsFromMarkdown };
242
+ export { Property, commandExists, ensureNodeDbSchema, findSeedBinary, parseMarkdownFrontmatter, processSeedConfig, runSeedInit, saveModelsFromMarkdown, withSeed };
222
243
  //# sourceMappingURL=node.js.map
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sources":["../../src/imports/markdown.ts","../../src/node/helpers/scripts.ts","../../src/node/index.ts"],"sourcesContent":["import yaml from 'js-yaml'\nimport { readFileSync } from 'fs'\nimport { Property, ModelPropertyDataTypes } from '@/Schema'\nimport { ModelDefinitions } from '@/types'\nimport { addModelsToDb } from '../helpers/db'\nimport type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'\nimport { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'\nimport type { Model } from '@/Model/Model'\n\n/**\n * Configuration structure expected in markdown frontmatter\n */\ntype SeedConfig = {\n seed: {\n model: string\n properties: {\n [propertyName: string]: {\n type: string\n target?: string\n /** For List: element type when primitive (e.g. 'Text', 'Number'). Use target for list of relations. */\n itemsType?: string\n }\n }\n }\n}\n\n/**\n * Parses markdown frontmatter from a file\n * @param filePath Path to the markdown file\n * @returns The parsed frontmatter as an object, or null if no frontmatter found\n */\nexport const parseMarkdownFrontmatter = (\n filePath: string,\n): Record<string, any> | null => {\n const content = readFileSync(filePath, 'utf-8')\n \n // Check for frontmatter delimiters (more flexible regex)\n // Matches --- at start, optional whitespace, content, ---, optional whitespace\n const frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)\\n---(\\s*\\n|$)/\n const match = content.match(frontmatterRegex)\n \n if (!match) {\n return null\n }\n \n const frontmatterYaml = match[1]\n \n try {\n const frontmatter = yaml.load(frontmatterYaml) as Record<string, any>\n return frontmatter\n } catch (error) {\n throw new Error(\n `Failed to parse YAML frontmatter in ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/**\n * Converts a seed config from frontmatter to ModelDefinitions format\n * @param config The seed configuration from frontmatter\n * @returns ModelDefinitions object ready to be saved to database\n */\nexport const processSeedConfig = (config: SeedConfig): ModelDefinitions => {\n if (!config.seed) {\n throw new Error('No seed configuration found in frontmatter')\n }\n \n const { model: modelName, properties: propertiesConfig } = config.seed\n \n if (!modelName) {\n throw new Error('Model name is required in seed configuration')\n }\n \n if (!propertiesConfig || Object.keys(propertiesConfig).length === 0) {\n throw new Error('Properties are required in seed configuration')\n }\n \n // Convert property configs to Property definitions\n const schema: Record<string, any> = {}\n \n for (const [propertyName, propertyConfig] of Object.entries(propertiesConfig)) {\n const { type, target, itemsType } = propertyConfig\n \n if (!type) {\n throw new Error(`Property type is required for ${propertyName}`)\n }\n \n // Map the type to Property constructor\n switch (type) {\n case ModelPropertyDataTypes.Text:\n schema[propertyName] = Property.Text()\n break\n case ModelPropertyDataTypes.Number:\n schema[propertyName] = Property.Number()\n break\n case ModelPropertyDataTypes.Boolean:\n schema[propertyName] = Property.Boolean()\n break\n case ModelPropertyDataTypes.Date:\n schema[propertyName] = Property.Date()\n break\n case ModelPropertyDataTypes.Image:\n schema[propertyName] = Property.Image()\n break\n case ModelPropertyDataTypes.Json:\n schema[propertyName] = Property.Json()\n break\n case ModelPropertyDataTypes.File:\n schema[propertyName] = Property.File()\n break\n case ModelPropertyDataTypes.Relation:\n if (!target) {\n throw new Error(\n `Target model is required for Relation property ${propertyName}`,\n )\n }\n schema[propertyName] = Property.Relation(target)\n break\n case ModelPropertyDataTypes.List:\n if (itemsType) {\n // List of primitives: itemsType = 'Text', 'Number', etc.\n if (itemsType === ModelPropertyDataTypes.Relation && target) {\n schema[propertyName] = Property.List('Relation', target)\n } else if (itemsType !== ModelPropertyDataTypes.Relation) {\n schema[propertyName] = Property.List(itemsType as any)\n } else {\n throw new Error(\n `List of relations requires target model for property ${propertyName}`,\n )\n }\n } else if (target) {\n // Backward compat: target = model name for list of relations\n schema[propertyName] = Property.List('Relation', target)\n } else {\n throw new Error(\n `List property ${propertyName} requires either itemsType (e.g. 'Text') or target (model name for list of relations)`,\n )\n }\n break\n default:\n throw new Error(\n `Unknown property type: ${type} for property ${propertyName}`,\n )\n }\n }\n \n // Create a mock ModelClass structure that matches ModelDefinitions\n // This is a simplified version that works with addModelsToInternalDb\n const modelClass = {\n schema,\n create: async () => {\n throw new Error('Model.create() should not be called directly')\n },\n originalConstructor: class {},\n }\n \n return {\n [modelName]: modelClass as any as Model,\n }\n}\n\n/**\n * Reads a markdown file, parses frontmatter, and saves models/properties to database\n * @param filePath Path to the markdown file\n * @param db Database instance (BetterSQLite3Database or SqliteRemoteDatabase)\n * @returns The created ModelDefinitions\n */\nexport const saveModelsFromMarkdown = async (\n filePath: string,\n db: BetterSQLite3Database<any> | SqliteRemoteDatabase<any>,\n): Promise<ModelDefinitions> => {\n // Parse frontmatter\n const frontmatter = parseMarkdownFrontmatter(filePath)\n \n if (!frontmatter) {\n throw new Error(`No frontmatter found in ${filePath}`)\n }\n \n // Validate and process seed config\n const seedConfig = frontmatter as SeedConfig\n const modelDefinitions = processSeedConfig(seedConfig)\n \n // Save to database\n await addModelsToDb(modelDefinitions, undefined, undefined, undefined)\n \n return modelDefinitions\n}\n","import { execSync } from 'child_process'\nimport path from 'path'\nimport fs from 'fs'\nimport { BaseDb } from '@/db/Db/BaseDb'\n\nexport const commandExists = (command: string): boolean => {\n try {\n execSync(`which ${command}`, { stdio: 'ignore' })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Finds the seed binary path, trying multiple locations\n * @returns The path to the seed binary, or null if not found\n */\nexport const findSeedBinary = (): string | null => {\n const cwd = process.cwd()\n\n const possiblePaths = [\n path.join(cwd, 'node_modules', '.bin', 'seed'),\n path.join(cwd, 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n ]\n\n for (const binPath of possiblePaths) {\n if (fs.existsSync(binPath)) {\n return binPath\n }\n }\n\n return null\n}\n\n/**\n * Ensures the Node app DB exists and SDK migrations are applied.\n * (Formerly `runSeedInit`; CLI spawn / npx fallbacks archived under docs/archive/commented/.)\n */\nexport const ensureNodeDbSchema = async (\n _schemaFileDir?: string,\n appFilesDirPath?: string\n): Promise<void> => {\n if (!appFilesDirPath) {\n throw new Error('ensureNodeDbSchema requires appFilesDirPath')\n }\n\n await BaseDb.prepareDb(appFilesDirPath)\n}\n\n/** @deprecated Use ensureNodeDbSchema */\nexport const runSeedInit = ensureNodeDbSchema\n","import { enableMapSet } from 'immer'\n\n// Core schema exports\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\n// Core classes\nexport { Item } from '../Item/Item'\nexport { ItemProperty } from '../ItemProperty/ItemProperty'\n\n// Node.js specific exports\nexport { FileManager } from './helpers/FileManager'\nexport { Db, resolveSdkDrizzleMigrationsDir } from './db/Db'\n\n// Schema exports\nexport { models, versions, seeds, metadata, appState, config, modelUids } from '../seedSchema'\n\n// Model access - use Model static methods instead\n// Models are accessible via Model.all(), Model.getById(), Model.getByName(), etc.\n\n// Helper exports\nexport { getCorrectId } from '../helpers'\n\n// Import exports\nexport * from '../imports'\n\n// Event bus\nexport { eventEmitter } from '../eventBus'\n\n// Webpack helper\nexport { withSeed } from './webpack'\n\n// Types\n// Note: PublishUpload type is available from '../db/read/getPublishUploads'\n// Type-only exports cause issues with Rollup's parser. Import directly if needed:\n// import type { PublishUpload } from '@seedprotocol/sdk/db/read/getPublishUploads'\n\n// Client\nexport { client } from '../client'\n\n// All types\nexport * from '../types'\n\n// CLI exports\nexport { PathResolver } from './helpers/PathResolver'\nexport { BasePathResolver } from '../helpers/PathResolver/BasePathResolver'\nexport {\n commandExists,\n ensureNodeDbSchema,\n runSeedInit,\n findSeedBinary,\n} from './helpers/scripts'\nexport { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from '../helpers/constants'\n\n// Side effect imports for CLI — register platform services\nimport { createPlatformServices } from '../platform/index.node'\nimport { configurePlatform } from '../platform/configurePlatform'\nconfigurePlatform(createPlatformServices())\n\nenableMapSet() "],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;;AAIG;AACI,MAAM,wBAAwB,GAAG,CACtC,QAAgB,KACc;IAC9B,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;;;IAI/C,MAAM,gBAAgB,GAAG,mCAAmC;IAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC;IAE7C,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC;AAEhC,IAAA,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAwB;A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AiB,CAAC,sBAAsB,EAAE,CAAC;AAE3C,YAAY,EAAE;;;;"}
1
+ {"version":3,"file":"node.js","sources":["../../src/imports/markdown.ts","../../src/node/webpack/index.ts","../../src/node/helpers/scripts.ts","../../src/node/index.ts"],"sourcesContent":["import yaml from 'js-yaml'\nimport { readFileSync } from 'fs'\nimport { Property, ModelPropertyDataTypes } from '@/Schema'\nimport { ModelDefinitions } from '@/types'\nimport { addModelsToDb } from '../helpers/db'\nimport type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'\nimport { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'\nimport type { Model } from '@/Model/Model'\n\n/**\n * Configuration structure expected in markdown frontmatter\n */\ntype SeedConfig = {\n seed: {\n model: string\n properties: {\n [propertyName: string]: {\n type: string\n target?: string\n /** For List: element type when primitive (e.g. 'Text', 'Number'). Use target for list of relations. */\n itemsType?: string\n }\n }\n }\n}\n\n/**\n * Parses markdown frontmatter from a file\n * @param filePath Path to the markdown file\n * @returns The parsed frontmatter as an object, or null if no frontmatter found\n */\nexport const parseMarkdownFrontmatter = (\n filePath: string,\n): Record<string, any> | null => {\n const content = readFileSync(filePath, 'utf-8')\n \n // Check for frontmatter delimiters (more flexible regex)\n // Matches --- at start, optional whitespace, content, ---, optional whitespace\n const frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)\\n---(\\s*\\n|$)/\n const match = content.match(frontmatterRegex)\n \n if (!match) {\n return null\n }\n \n const frontmatterYaml = match[1]\n \n try {\n const frontmatter = yaml.load(frontmatterYaml) as Record<string, any>\n return frontmatter\n } catch (error) {\n throw new Error(\n `Failed to parse YAML frontmatter in ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/**\n * Converts a seed config from frontmatter to ModelDefinitions format\n * @param config The seed configuration from frontmatter\n * @returns ModelDefinitions object ready to be saved to database\n */\nexport const processSeedConfig = (config: SeedConfig): ModelDefinitions => {\n if (!config.seed) {\n throw new Error('No seed configuration found in frontmatter')\n }\n \n const { model: modelName, properties: propertiesConfig } = config.seed\n \n if (!modelName) {\n throw new Error('Model name is required in seed configuration')\n }\n \n if (!propertiesConfig || Object.keys(propertiesConfig).length === 0) {\n throw new Error('Properties are required in seed configuration')\n }\n \n // Convert property configs to Property definitions\n const schema: Record<string, any> = {}\n \n for (const [propertyName, propertyConfig] of Object.entries(propertiesConfig)) {\n const { type, target, itemsType } = propertyConfig\n \n if (!type) {\n throw new Error(`Property type is required for ${propertyName}`)\n }\n \n // Map the type to Property constructor\n switch (type) {\n case ModelPropertyDataTypes.Text:\n schema[propertyName] = Property.Text()\n break\n case ModelPropertyDataTypes.Number:\n schema[propertyName] = Property.Number()\n break\n case ModelPropertyDataTypes.Boolean:\n schema[propertyName] = Property.Boolean()\n break\n case ModelPropertyDataTypes.Date:\n schema[propertyName] = Property.Date()\n break\n case ModelPropertyDataTypes.Image:\n schema[propertyName] = Property.Image()\n break\n case ModelPropertyDataTypes.Json:\n schema[propertyName] = Property.Json()\n break\n case ModelPropertyDataTypes.File:\n schema[propertyName] = Property.File()\n break\n case ModelPropertyDataTypes.Relation:\n if (!target) {\n throw new Error(\n `Target model is required for Relation property ${propertyName}`,\n )\n }\n schema[propertyName] = Property.Relation(target)\n break\n case ModelPropertyDataTypes.List:\n if (itemsType) {\n // List of primitives: itemsType = 'Text', 'Number', etc.\n if (itemsType === ModelPropertyDataTypes.Relation && target) {\n schema[propertyName] = Property.List('Relation', target)\n } else if (itemsType !== ModelPropertyDataTypes.Relation) {\n schema[propertyName] = Property.List(itemsType as any)\n } else {\n throw new Error(\n `List of relations requires target model for property ${propertyName}`,\n )\n }\n } else if (target) {\n // Backward compat: target = model name for list of relations\n schema[propertyName] = Property.List('Relation', target)\n } else {\n throw new Error(\n `List property ${propertyName} requires either itemsType (e.g. 'Text') or target (model name for list of relations)`,\n )\n }\n break\n default:\n throw new Error(\n `Unknown property type: ${type} for property ${propertyName}`,\n )\n }\n }\n \n // Create a mock ModelClass structure that matches ModelDefinitions\n // This is a simplified version that works with addModelsToInternalDb\n const modelClass = {\n schema,\n create: async () => {\n throw new Error('Model.create() should not be called directly')\n },\n originalConstructor: class {},\n }\n \n return {\n [modelName]: modelClass as any as Model,\n }\n}\n\n/**\n * Reads a markdown file, parses frontmatter, and saves models/properties to database\n * @param filePath Path to the markdown file\n * @param db Database instance (BetterSQLite3Database or SqliteRemoteDatabase)\n * @returns The created ModelDefinitions\n */\nexport const saveModelsFromMarkdown = async (\n filePath: string,\n db: BetterSQLite3Database<any> | SqliteRemoteDatabase<any>,\n): Promise<ModelDefinitions> => {\n // Parse frontmatter\n const frontmatter = parseMarkdownFrontmatter(filePath)\n \n if (!frontmatter) {\n throw new Error(`No frontmatter found in ${filePath}`)\n }\n \n // Validate and process seed config\n const seedConfig = frontmatter as SeedConfig\n const modelDefinitions = processSeedConfig(seedConfig)\n \n // Save to database\n await addModelsToDb(modelDefinitions, undefined, undefined, undefined)\n \n return modelDefinitions\n}\n","/**\n * Webpack / Next.js config helper for Seed Protocol apps.\n */\nexport const withSeed = (config: any, webpack: any, isServer: boolean) => {\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/node:/, (resource: { request: string }) => {\n resource.request = resource.request.replace(/^node:/, '')\n }),\n )\n\n if (!isServer) {\n config.resolve.alias['fs'] = '@zenfs/core'\n config.resolve.alias['node:fs'] = '@zenfs/core'\n config.resolve.alias['node:path'] = 'path-browserify'\n config.resolve.alias['path'] = 'path-browserify'\n }\n\n if (isServer) {\n config.externals.push('@sqlite.org/sqlite-wasm')\n config.externals.push('chokidar')\n config.externals.push('arweave')\n }\n\n return config\n}\n","import { execSync } from 'child_process'\nimport path from 'path'\nimport fs from 'fs'\nimport { BaseDb } from '@/db/Db/BaseDb'\n\nexport const commandExists = (command: string): boolean => {\n try {\n execSync(`which ${command}`, { stdio: 'ignore' })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Finds the seed binary path, trying multiple locations\n * @returns The path to the seed binary, or null if not found\n */\nexport const findSeedBinary = (): string | null => {\n const cwd = process.cwd()\n\n const possiblePaths = [\n path.join(cwd, 'node_modules', '.bin', 'seed'),\n path.join(cwd, 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n path.join(cwd, '..', '..', 'node_modules', '.bin', 'seed'),\n path.join(cwd, '..', '..', 'node_modules', '@seedprotocol', 'cli', 'dist', 'bin.js'),\n ]\n\n for (const binPath of possiblePaths) {\n if (fs.existsSync(binPath)) {\n return binPath\n }\n }\n\n return null\n}\n\n/**\n * Ensures the Node app DB exists and SDK migrations are applied.\n * (Formerly `runSeedInit`; CLI spawn / npx fallbacks archived under docs/archive/commented/.)\n */\nexport const ensureNodeDbSchema = async (\n _schemaFileDir?: string,\n appFilesDirPath?: string\n): Promise<void> => {\n if (!appFilesDirPath) {\n throw new Error('ensureNodeDbSchema requires appFilesDirPath')\n }\n\n await BaseDb.prepareDb(appFilesDirPath)\n}\n\n/** @deprecated Use ensureNodeDbSchema */\nexport const runSeedInit = ensureNodeDbSchema\n","import { enableMapSet } from 'immer'\n\n// Core schema exports\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\n// Core classes\nexport { Item } from '../Item/Item'\nexport { ItemProperty } from '../ItemProperty/ItemProperty'\n\n// Node.js specific exports\nexport { FileManager } from './helpers/FileManager'\nexport { Db, resolveSdkDrizzleMigrationsDir } from './db/Db'\n\n// Schema exports\nexport { models, versions, seeds, metadata, appState, config, modelUids } from '../seedSchema'\n\n// Model access - use Model static methods instead\n// Models are accessible via Model.all(), Model.getById(), Model.getByName(), etc.\n\n// Helper exports\nexport { getCorrectId } from '../helpers'\n\n// Import exports\nexport * from '../imports'\n\n// Event bus\nexport { eventEmitter } from '../eventBus'\n\n// Webpack helper\nexport { withSeed } from './webpack'\n\n// Types\n// Note: PublishUpload type is available from '../db/read/getPublishUploads'\n// Type-only exports cause issues with Rollup's parser. Import directly if needed:\n// import type { PublishUpload } from '@seedprotocol/sdk/db/read/getPublishUploads'\n\n// Client\nexport { client } from '../client'\n\n// All types\nexport * from '../types'\n\n// CLI exports\nexport { PathResolver } from './helpers/PathResolver'\nexport { BasePathResolver } from '../helpers/PathResolver/BasePathResolver'\nexport {\n commandExists,\n ensureNodeDbSchema,\n runSeedInit,\n findSeedBinary,\n} from './helpers/scripts'\nexport { INIT_SCRIPT_SUCCESS_MESSAGE, SCHEMA_TS } from '../helpers/constants'\n\n// Side effect imports for CLI — register platform services\nimport { createPlatformServices } from '../platform/index.node'\nimport { configurePlatform } from '../platform/configurePlatform'\nconfigurePlatform(createPlatformServices())\n\nenableMapSet() "],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;;AAIG;AACI,MAAM,wBAAwB,GAAG,CACtC,QAAgB,KACc;IAC9B,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;;;IAI/C,MAAM,gBAAgB,GAAG,mCAAmC;IAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC;IAE7C,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC;AAEhC,IAAA,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAwB;AACrE,QAAA,OAAO,WAAW;IACpB;IAAE,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,CAAA,oCAAA,EAAuC,QAAQ,KAAK,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA,CAAE,CAC7G;IACH;AACF;AAEA;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC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AAc,EAAE,MAAM,EAAE,MAAM,CAAC;AAC1D,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC;KACrF;AAED,IAAA,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;AACnC,QAAA,IAAIA,WAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;AAC1B,YAAA,OAAO,OAAO;QAChB;IACF;AAEA,IAAA,OAAO,IAAI;AACb;AAEA;;;AAGG;AACI,MAAM,kBAAkB,GAAG,OAChC,cAAuB,EACvB,eAAwB,KACP;IACjB,IAAI,CAAC,eAAe,EAAE;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC;IAChE;AAEA,IAAA,MAAM,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;AACzC;AAEA;AACO,MAAM,WAAW,GAAG;;ACY3B,iBAAiB,CAAC,sBAAsB,EAAE,CAAC;AAE3C,YAAY,EAAE;;;;"}
@@ -1,19 +1,20 @@
1
1
  import { B as BaseDb, s as seeds } from './BasePathResolver-BDgc7c4T.js';
2
2
  import { eq, or } from 'drizzle-orm';
3
- import { getOwnedAddressesFromDb } from './db-Cvh84NY7.js';
4
- import { g as getGetAdditionalSyncAddresses } from './index--F3Wolt5.js';
3
+ import { getOwnedAddressesFromDb } from './db-CSmK0c3e.js';
4
+ import { g as getGetAdditionalSyncAddresses } from './index-ClwdGWfr.js';
5
5
  import 'drizzle-orm/sqlite-core';
6
6
  import 'drizzle-orm/casing';
7
7
  import 'lodash-es';
8
8
  import 'debug';
9
9
  import 'xstate';
10
- import './constants-B5S5JPDK.js';
10
+ import './constants-slkc9uq0.js';
11
11
  import '@seedprotocol/arweave';
12
12
  import '@seedprotocol/eas';
13
13
  import 'pluralize';
14
14
  import '@sinclair/typebox';
15
15
  import 'nanoid';
16
16
  import 'nanoid-dictionary';
17
+ import '@seedprotocol/query';
17
18
  import './constants-DMHTYMgJ.js';
18
19
  import 'rxjs';
19
20
  import 'js-sha3';
@@ -102,4 +103,4 @@ async function assertItemOwned(item) {
102
103
  }
103
104
 
104
105
  export { assertItemOwned, isItemOwned };
105
- //# sourceMappingURL=ownership-BF_ZUKIp.js.map
106
+ //# sourceMappingURL=ownership-58i0iyD9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ownership-BF_ZUKIp.js","sources":["../../src/helpers/ownership.ts"],"sourcesContent":["import type { IItem } from '@/interfaces/IItem'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq, or } from 'drizzle-orm'\nimport { getOwnedAddressesFromDb } from '@/helpers/db'\nimport { getGetAdditionalSyncAddresses } from '@/helpers/publishConfig'\n\nconst READ_ONLY_ERROR = 'Item is read-only: you do not own this item'\n\ntype ItemLike = { seedLocalId?: string; seedUid?: string }\n\ntype SeedRow = { publisher: string | null; attestationRaw: string | null; uid: string | null }\n\nasync function getSeedRowForItem(item: ItemLike): Promise<SeedRow | null> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n\n const conditions = []\n if (item.seedLocalId) conditions.push(eq(seeds.localId, item.seedLocalId))\n if (item.seedUid) conditions.push(eq(seeds.uid, item.seedUid))\n if (conditions.length === 0) return null\n\n const seedRows = await appDb\n .select({\n publisher: seeds.publisher,\n attestationRaw: seeds.attestationRaw,\n uid: seeds.uid,\n })\n .from(seeds)\n .where(conditions.length === 1 ? conditions[0] : (or(...conditions) as any))\n .limit(1)\n\n if (!seedRows || seedRows.length === 0) return null\n return seedRows[0]\n}\n\nfunction getPublisherFromRow(row: SeedRow): string | null {\n if (row.publisher) return row.publisher\n if (row.attestationRaw) {\n try {\n const parsed = JSON.parse(row.attestationRaw) as { attester?: string }\n return parsed.attester ?? null\n } catch {\n return null\n }\n }\n return null\n}\n\n/**\n * Checks if the current user owns the item (publisher is in owned addresses).\n * Locally created items (no publisher, no attestationRaw) are considered owned.\n * Includes getAdditionalSyncAddresses (e.g. `modularAccountModuleContract` when configured)\n * so ownership aligns with EAS sync when the publisher/attester matches those addresses.\n */\nexport async function isItemOwned(item: ItemLike | IItem<any>): Promise<boolean> {\n const row = await getSeedRowForItem(item)\n if (!row) return false\n\n const publisher = getPublisherFromRow(row)\n if (!publisher) {\n if (!row.uid && !row.attestationRaw) {\n return true\n }\n return false\n }\n\n let addressesToCheck = await getOwnedAddressesFromDb()\n const additionalGetter = getGetAdditionalSyncAddresses()\n if (additionalGetter) {\n const additional = await additionalGetter()\n if (additional?.length) {\n const seen = new Set(addressesToCheck.map((a) => a.toLowerCase()))\n for (const addr of additional) {\n if (addr && !seen.has(addr.toLowerCase())) {\n seen.add(addr.toLowerCase())\n addressesToCheck = [...addressesToCheck, addr]\n }\n }\n }\n }\n\n const ownedSet = new Set(addressesToCheck.map((a) => a.toLowerCase()))\n return ownedSet.has(publisher.toLowerCase())\n}\n\n/**\n * Throws if the item is not owned. Use before write operations (publish, save, destroy).\n */\nexport async function assertItemOwned(item: ItemLike | IItem<any>): Promise<void> {\n const owned = await isItemOwned(item)\n if (!owned) {\n throw new Error(READ_ONLY_ERROR)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAe,GAAG,6CAA6C;AAMrE,eAAe,iBAAiB,CAAC,IAAc,EAAA;AAC7C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC/B,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI;IAEvB,MAAM,UAAU,GAAG,EAAE;IACrB,IAAI,IAAI,CAAC,WAAW;AAAE,QAAA,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1E,IAAI,IAAI,CAAC,OAAO;AAAE,QAAA,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC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AI,CAAC,GAAG,CAAC,cAAc,EAAE;AACnC,YAAA,OAAO,IAAI;QACb;AACA,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,gBAAgB,GAAG,MAAM,uBAAuB,EAAE;AACtD,IAAA,MAAM,gBAAgB,GAAG,6BAA6B,EAAE;IACxD,IAAI,gBAAgB,EAAE;AACpB,QAAA,MAAM,UAAU,GAAG,MAAM,gBAAgB,EAAE;AAC3C,QAAA,IAAI,UAAU,EAAE,MAAM,EAAE;YACtB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAClE,YAAA,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE;AAC7B,gBAAA,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE;oBACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,oBAAA,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,EAAE,IAAI,CAAC;gBAChD;YACF;QACF;IACF;IAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;AAC9C;AAEA;;AAEG;AACI,eAAe,eAAe,CAAC,IAA2B,EAAA;AAC/D,IAAA,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAClC;AACF;;;;"}
1
+ {"version":3,"file":"ownership-58i0iyD9.js","sources":["../../src/helpers/ownership.ts"],"sourcesContent":["import type { IItem } from '@/interfaces/IItem'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq, or } from 'drizzle-orm'\nimport { getOwnedAddressesFromDb } from '@/helpers/db'\nimport { getGetAdditionalSyncAddresses } from '@/helpers/publishConfig'\n\nconst READ_ONLY_ERROR = 'Item is read-only: you do not own this item'\n\ntype ItemLike = { seedLocalId?: string; seedUid?: string }\n\ntype SeedRow = { publisher: string | null; attestationRaw: string | null; uid: string | null }\n\nasync function getSeedRowForItem(item: ItemLike): Promise<SeedRow | null> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n\n const conditions = []\n if (item.seedLocalId) conditions.push(eq(seeds.localId, item.seedLocalId))\n if (item.seedUid) conditions.push(eq(seeds.uid, item.seedUid))\n if (conditions.length === 0) return null\n\n const seedRows = await appDb\n .select({\n publisher: seeds.publisher,\n attestationRaw: seeds.attestationRaw,\n uid: seeds.uid,\n })\n .from(seeds)\n .where(conditions.length === 1 ? conditions[0] : (or(...conditions) as any))\n .limit(1)\n\n if (!seedRows || seedRows.length === 0) return null\n return seedRows[0]\n}\n\nfunction getPublisherFromRow(row: SeedRow): string | null {\n if (row.publisher) return row.publisher\n if (row.attestationRaw) {\n try {\n const parsed = JSON.parse(row.attestationRaw) as { attester?: string }\n return parsed.attester ?? null\n } catch {\n return null\n }\n }\n return null\n}\n\n/**\n * Checks if the current user owns the item (publisher is in owned addresses).\n * Locally created items (no publisher, no attestationRaw) are considered owned.\n * Includes getAdditionalSyncAddresses (e.g. `modularAccountModuleContract` when configured)\n * so ownership aligns with EAS sync when the publisher/attester matches those addresses.\n */\nexport async function isItemOwned(item: ItemLike | IItem<any>): Promise<boolean> {\n const row = await getSeedRowForItem(item)\n if (!row) return false\n\n const publisher = getPublisherFromRow(row)\n if (!publisher) {\n if (!row.uid && !row.attestationRaw) {\n return true\n }\n return false\n }\n\n let addressesToCheck = await getOwnedAddressesFromDb()\n const additionalGetter = getGetAdditionalSyncAddresses()\n if (additionalGetter) {\n const additional = await additionalGetter()\n if (additional?.length) {\n const seen = new Set(addressesToCheck.map((a) => a.toLowerCase()))\n for (const addr of additional) {\n if (addr && !seen.has(addr.toLowerCase())) {\n seen.add(addr.toLowerCase())\n addressesToCheck = [...addressesToCheck, addr]\n }\n }\n }\n }\n\n const ownedSet = new Set(addressesToCheck.map((a) => a.toLowerCase()))\n return ownedSet.has(publisher.toLowerCase())\n}\n\n/**\n * Throws if the item is not owned. Use before write operations (publish, save, destroy).\n */\nexport async function assertItemOwned(item: ItemLike | IItem<any>): Promise<void> {\n const owned = await isItemOwned(item)\n if (!owned) {\n throw new Error(READ_ONLY_ERROR)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAe,GAAG,6CAA6C;AAMrE,eAAe,iBAAiB,CAAC,IAAc,EAAA;AAC7C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC/B,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI;IAEvB,MAAM,UAAU,GAAG,EAAE;IACrB,IAAI,IAAI,CAAC,WAAW;AAAE,QAAA,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1E,IAAI,IAAI,CAAC,OAAO;AAAE,QAAA,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AAC9D,IAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;IAExC,MAAM,QAAQ,GAAG,MAAM;AACpB,SAAA,MAAM,CAAC;QACN,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,GAAG,EAAE,KAAK,CAAC,GAAG;KACf;SACA,IAAI,CAAC,KAAK;SACV,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,GAAG,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AI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAClE,YAAA,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE;AAC7B,gBAAA,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE;oBACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,oBAAA,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,EAAE,IAAI,CAAC;gBAChD;YACF;QACF;IACF;IAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;AAC9C;AAEA;;AAEG;AACI,eAAe,eAAe,CAAC,IAA2B,EAAA;AAC/D,IAAA,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAClC;AACF;;;;"}
@@ -4,7 +4,7 @@ import { sql } from 'drizzle-orm';
4
4
  import { readMigrationFiles } from 'drizzle-orm/migrator';
5
5
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
6
6
  import { migrate } from 'drizzle-orm/sqlite-proxy/migrator';
7
- import { E as EAS_ENDPOINT } from './constants-B5S5JPDK.js';
7
+ import { E as EAS_ENDPOINT } from './constants-slkc9uq0.js';
8
8
  import { s as schema } from './index-QMrBK-L3.js';
9
9
  import { SQLocalDrizzle } from 'sqlocal/drizzle';
10
10
  import { Observable, distinctUntilChanged } from 'rxjs';
@@ -19,6 +19,7 @@ import 'pluralize';
19
19
  import '@sinclair/typebox';
20
20
  import 'nanoid';
21
21
  import 'nanoid-dictionary';
22
+ import '@seedprotocol/query';
22
23
 
23
24
  const saveAppState = async (key, value) => {
24
25
  const appDb = BaseDb.getAppDb();
@@ -3067,7 +3068,7 @@ class BrowserDb {
3067
3068
  logger$1('[Db.prepareDb] database prepared');
3068
3069
  await this.runMigrations(db);
3069
3070
  this.appDb = db;
3070
- const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-DzZw57iJ.js');
3071
+ const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-DBVaIs7O.js');
3071
3072
  await backfillMetadataPropertyIds();
3072
3073
  return this.appDb;
3073
3074
  }
@@ -3289,7 +3290,7 @@ const getArweaveInstance = () => {
3289
3290
  return _arweaveInstance;
3290
3291
  }
3291
3292
  _arweaveGatewayKey = gatewayKey;
3292
- const host = BaseArweaveClient.getHost();
3293
+ const host = BaseArweaveClient.getArweaveSdkHost();
3293
3294
  const protocol = BaseArweaveClient.getProtocol();
3294
3295
  // Handle both ES modules and CommonJS exports from arweave package
3295
3296
  if ("default" in Arweave && typeof Arweave.default?.init === "function") {
@@ -3343,6 +3344,18 @@ class BrowserArweaveClient {
3343
3344
  }
3344
3345
  }
3345
3346
  async getTransactionData(transactionId, options) {
3347
+ // Path-prefixed proxies (app-server Hyper proxy) are not supported by arweave.init host;
3348
+ // fetch via getRawUrl so /api/seed-gateway/... works.
3349
+ if (BaseArweaveClient.getGatewayPath()) {
3350
+ const response = await fetch(BaseArweaveClient.getRawUrl(transactionId));
3351
+ if (!response.ok) {
3352
+ throw new Error(`Failed to fetch transaction data: HTTP ${response.status}`);
3353
+ }
3354
+ if (options?.string) {
3355
+ return response.text();
3356
+ }
3357
+ return new Uint8Array(await response.arrayBuffer());
3358
+ }
3346
3359
  const arweave = getArweaveInstance();
3347
3360
  try {
3348
3361
  const data = await arweave.transactions.getData(transactionId, {