@seedprotocol/sdk 0.3.16 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,10 +24,14 @@ yarn add @seedprotocol/sdk
24
24
 
25
25
  ## Getting Started
26
26
 
27
- The first thing to do when integrating Seed SDK is define your data model by placing a `schema.ts` file in the root
28
- of your project.
27
+ The first thing to do when integrating Seed SDK is define your data model by creating a configuration file in the root
28
+ of your project. The SDK supports the following file names (in order of preference):
29
29
 
30
- As an example, here's the actual data model for PermaPress:
30
+ - `seed.config.ts` (recommended)
31
+ - `seed.schema.ts`
32
+ - `schema.ts` (legacy)
33
+
34
+ As an example, here's the actual data model for PermaPress using `seed.config.ts`:
31
35
 
32
36
  ```typescript
33
37
  import { ImageSrc, List, Model, Relation, Text } from '@/browser/schema'
package/dist/bin.js CHANGED
@@ -9,7 +9,7 @@ import './src/node/helpers/QueryClient.js';
9
9
  import 'fs/promises';
10
10
  import './src/helpers/FileManager/BaseFileManager.js';
11
11
  import './src/node/helpers/ArweaveClient.js';
12
- import { SCHEMA_TS, INIT_SCRIPT_SUCCESS_MESSAGE } from './src/helpers/constants.js';
12
+ import { INIT_SCRIPT_SUCCESS_MESSAGE } from './src/helpers/constants.js';
13
13
  import { PathResolver } from './src/node/PathResolver.js';
14
14
  import { createDrizzleSchemaFilesFromConfig } from './src/node/codegen/drizzle.js';
15
15
  import { rimrafSync } from 'rimraf';
@@ -22,7 +22,7 @@ import { metadata } from './src/seedSchema/MetadataSchema.js';
22
22
  import { appState } from './src/seedSchema/AppStateSchema.js';
23
23
  import { models } from './src/seedSchema/ModelSchema.js';
24
24
  import { modelUids } from './src/seedSchema/ModelUidSchema.js';
25
- import './src/seedSchema/ConfigSchema.js';
25
+ import { config } from './src/seedSchema/ConfigSchema.js';
26
26
  import { commandExists } from './src/helpers/scripts.js';
27
27
 
28
28
  const __filename = fileURLToPath(import.meta.url);
@@ -126,17 +126,23 @@ const init = (args) => {
126
126
  }
127
127
  console.log('[Seed Protocol] schemaFileDir', schemaFileDir);
128
128
  if (!schemaFileDir) {
129
- const defaultSchemaFilePath = path.join(process.cwd(), 'schema.ts');
130
- if (fs.existsSync(defaultSchemaFilePath)) {
131
- schemaFileDir = process.cwd();
129
+ // Use the new config file finding logic
130
+ const foundConfigFile = pathResolver.findConfigFile();
131
+ if (foundConfigFile) {
132
+ schemaFileDir = path.dirname(foundConfigFile);
132
133
  }
133
134
  else {
134
- console.error('No schema file path provided and no default schema file found.');
135
+ console.error('No config file found. Please create a seed.config.ts, seed.schema.ts, or schema.ts file in your project root.');
135
136
  return;
136
137
  }
137
138
  }
138
139
  const { dotSeedDir, appSchemaDir, appMetaDir, drizzleDbConfigPath, drizzleKitPath, sdkRootDir, } = pathResolver.getAppPaths(schemaFileDir);
139
- const schemaFilePath = path.join(schemaFileDir, SCHEMA_TS);
140
+ // Find the actual config file in the schema file directory
141
+ const configFilePath = pathResolver.findConfigFile(schemaFileDir);
142
+ if (!configFilePath) {
143
+ console.error('Config file not found in the specified directory.');
144
+ return;
145
+ }
140
146
  // Remove dotSeedDir to start fresh each time
141
147
  if (fs.existsSync(dotSeedDir)) {
142
148
  fs.rmSync(dotSeedDir, { recursive: true, force: true });
@@ -180,7 +186,7 @@ const init = (args) => {
180
186
  };
181
187
  const copyDotSeedFilesToAppFiles = async (_appFilesDirPath) => {
182
188
  console.log('[Seed Protocol] Copying dot seed files to app files');
183
- const { endpoints } = await getTsImport(schemaFilePath);
189
+ const { endpoints } = await getTsImport(configFilePath);
184
190
  const outputDirPath = endpoints.localOutputDir || _appFilesDirPath;
185
191
  const exists = await fs.promises.access(outputDirPath).then(() => true).catch(() => false);
186
192
  if (exists) {
@@ -206,7 +212,7 @@ const init = (args) => {
206
212
  if (!tsxExists) {
207
213
  execSync(`npm install -g tsx`, { stdio: 'inherit' });
208
214
  }
209
- await createDrizzleSchemaFilesFromConfig(schemaFilePath, undefined);
215
+ await createDrizzleSchemaFilesFromConfig(configFilePath, undefined);
210
216
  ensureIndexExports(appSchemaDir);
211
217
  await updateSchema(drizzleDbConfigPath, appMetaDir);
212
218
  const seedDataFilePath = path.join(__dirname, 'seedData.json');
@@ -217,8 +223,8 @@ const init = (args) => {
217
223
  // path.join(pathResolver.getSdkRootDir(), 'node', 'codegen'),
218
224
  // path.join(dotSeedDir, 'codegen'),
219
225
  // )
220
- console.log('copying', schemaFilePath, path.join(dotSeedDir, 'schema.ts'));
221
- fs.copyFileSync(schemaFilePath, path.join(dotSeedDir, 'schema.ts'));
226
+ console.log('copying', configFilePath, path.join(dotSeedDir, 'seed.config.ts'));
227
+ fs.copyFileSync(configFilePath, path.join(dotSeedDir, 'seed.config.ts'));
222
228
  runCommands()
223
229
  .then(() => {
224
230
  if (!appFilesDirPath) {
@@ -246,7 +252,8 @@ const calledFrom = pathToFileURL(process.argv[1]).href;
246
252
  console.log('calledFrom', calledFrom);
247
253
  if (calledFrom.endsWith('node_modules/.bin/seed') ||
248
254
  import.meta.url.endsWith('@seedprotocol/sdk/node/bin.js') ||
249
- import.meta.url.endsWith('scripts/bin.ts')) {
255
+ import.meta.url.endsWith('scripts/bin.ts') ||
256
+ import.meta.url.endsWith('dist/bin.js')) {
250
257
  // module was not imported but called directly
251
258
  init(a);
252
259
  }
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, 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,SAAiB,EAAA;;IAEpE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;;IAI9C,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;;AAGzC,IAAA,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC;;QAG9C,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;AAErC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;;AAElB,YAAA,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU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AC,CAAC,CAAC;;aAChB;AACL,YAAA,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC;AACnD,YAAA,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC;AACzE,YAAA,OAAO,CAAC,GAAG,CAAC,kEAAkE,CAAC;;;AAGrF;AAEA,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;AAEtD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC;AAErC,IACE,UAAU,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC7C,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, config, 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 // Use the new config file finding logic\n const foundConfigFile = pathResolver.findConfigFile()\n if (foundConfigFile) {\n schemaFileDir = path.dirname(foundConfigFile)\n } else {\n console.error('No config file found. Please create a seed.config.ts, seed.schema.ts, or schema.ts file in your project root.')\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 // Find the actual config file in the schema file directory\n const configFilePath = pathResolver.findConfigFile(schemaFileDir)\n if (!configFilePath) {\n console.error('Config file not found in the specified directory.')\n return\n }\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 }>(configFilePath)\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(configFilePath, 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', configFilePath, path.join(dotSeedDir, 'seed.config.ts'))\n\n fs.copyFileSync(configFilePath, path.join(dotSeedDir, 'seed.config.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 import.meta.url.endsWith('dist/bin.js')\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,SAAiB,EAAA;;IAEpE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;;IAI9C,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;;AAGzC,IAAA,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC;;QAG9C,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;AAErC,QAAA,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;;AAElB,YAAA,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,CAAA,aAAA,EAAgB,UAAU,CAAM,GAAA,EAAA,UAAU,CAAE,CAAA,CAAC;;AAEtD,aAAA,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;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AC,GAAG,CAAC,kEAAkE,CAAC;;;AAGrF;AAEA,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;AAEtD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC;AAErC,IACE,UAAU,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IACzD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAC1C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,EACvC;;IAEA,IAAI,CAAC,CAAC,CAAC;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../scripts/bin.ts"],"names":[],"mappings":";AAMA,OAAO,0BAA0B,CAAA;AACjC,OAAO,4BAA4B,CAAA;AACnC,OAAO,4BAA4B,CAAA;AACnC,OAAO,8BAA8B,CAAA;AA8GrC,QAAA,MAAM,IAAI,SAAU,MAAM,EAAE,SAyL3B,CAAA;AAeD,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../scripts/bin.ts"],"names":[],"mappings":";AAMA,OAAO,0BAA0B,CAAA;AACjC,OAAO,4BAA4B,CAAA;AACnC,OAAO,4BAA4B,CAAA;AACnC,OAAO,8BAA8B,CAAA;AA8GrC,QAAA,MAAM,IAAI,SAAU,MAAM,EAAE,SA+L3B,CAAA;AAgBD,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,6 +1,8 @@
1
1
  import { AttestationRequestData } from '@ethereum-attestation-service/eas-sdk';
2
2
  export declare const SCHEMA_NJK = "schema.njk";
3
- export declare const SCHEMA_TS = "schema.ts";
3
+ export declare const SEED_CONFIG_FILE = "seed.config.ts";
4
+ export declare const SEED_CONFIG_FALLBACKS: string[];
5
+ export declare const SCHEMA_TS = "seed.config.ts";
4
6
  export declare const INTERNAL_DATA_TYPES: {
5
7
  Text: {
6
8
  eas: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAIvB,MAAM,uCAAuC,CAAA;AAG9C,eAAO,MAAM,UAAU,eAAe,CAAA;AACtC,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;CAyB/B,CAAA;AAED,eAAO,MAAM,uBAAuB,UA6BnC,CAAA;AAED,eAAO,MAAM,mCAAmC,uEACsB,CAAA;AAEtE,eAAO,MAAM,sBAAsB,EAAE,sBAOpC,CAAA;AAED,oBAAY,SAAS;IACnB,WAAW,MAAM;IACjB,KAAK,MAAM;IACX,MAAM,OAAO;IACb,KAAK,OAAO;IACZ,WAAW,OAAO;CACnB;AAED,eAAO,MAAM,sBAAsB,gEAAgE,CAAA;AAEnG,eAAO,MAAM,2BAA2B,iDAAiD,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAIvB,MAAM,uCAAuC,CAAA;AAG9C,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC,eAAO,MAAM,gBAAgB,mBAAmB,CAAA;AAEhD,eAAO,MAAM,qBAAqB,UAAkC,CAAA;AAEpE,eAAO,MAAM,SAAS,mBAAmB,CAAA;AAEzC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;CAyB/B,CAAA;AAED,eAAO,MAAM,uBAAuB,UA6BnC,CAAA;AAED,eAAO,MAAM,mCAAmC,uEACsB,CAAA;AAEtE,eAAO,MAAM,sBAAsB,EAAE,sBAOpC,CAAA;AAED,oBAAY,SAAS;IACnB,WAAW,MAAM;IACjB,KAAK,MAAM;IACX,MAAM,OAAO;IACb,KAAK,OAAO;IACZ,WAAW,OAAO;CACnB;AAED,eAAO,MAAM,sBAAsB,gEAAgE,CAAA;AAEnG,eAAO,MAAM,2BAA2B,iDAAiD,CAAA"}
@@ -1,7 +1,10 @@
1
1
  import { ZERO_BYTES, ZERO_BYTES32, ZERO_ADDRESS } from '@ethereum-attestation-service/eas-sdk';
2
2
 
3
3
  const SCHEMA_NJK = 'schema.njk';
4
- const SCHEMA_TS = 'schema.ts';
4
+ // Primary config file name for Seed Protocol SDK
5
+ const SEED_CONFIG_FILE = 'seed.config.ts';
6
+ // Fallback config file names (in order of preference)
7
+ const SEED_CONFIG_FALLBACKS = ['seed.schema.ts', 'schema.ts'];
5
8
  const INTERNAL_DATA_TYPES = {
6
9
  Text: {
7
10
  eas: 'string',
@@ -78,5 +81,5 @@ var ImageSize;
78
81
  const CLIENT_NOT_INITIALIZED = 'ClientManager is not initialized. Please call init() first.';
79
82
  const INIT_SCRIPT_SUCCESS_MESSAGE = '[Seed Protocol] Finished running init script';
80
83
 
81
- export { CLIENT_NOT_INITIALIZED, INIT_SCRIPT_SUCCESS_MESSAGE, INTERNAL_DATA_TYPES, INTERNAL_PROPERTY_NAMES, ImageSize, SCHEMA_NJK, SCHEMA_TS, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, defaultAttestationData };
84
+ export { CLIENT_NOT_INITIALIZED, INIT_SCRIPT_SUCCESS_MESSAGE, INTERNAL_DATA_TYPES, INTERNAL_PROPERTY_NAMES, ImageSize, SCHEMA_NJK, SEED_CONFIG_FALLBACKS, SEED_CONFIG_FILE, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, defaultAttestationData };
82
85
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/helpers/constants.ts"],"sourcesContent":["import {\n AttestationRequestData,\n ZERO_BYTES,\n ZERO_BYTES32,\n ZERO_ADDRESS,\n} from '@ethereum-attestation-service/eas-sdk'\n\n\nexport const SCHEMA_NJK = 'schema.njk'\nexport const SCHEMA_TS = 'schema.ts'\n\nexport const INTERNAL_DATA_TYPES = {\n Text: {\n eas: 'string',\n },\n Number: {\n eas: 'uint8',\n },\n Image: {\n eas: 'string',\n },\n Relation: {\n eas: 'bytes32',\n },\n List: {\n eas: 'bytes32[]',\n },\n File: {\n eas: 'string',\n },\n Json: {\n eas: 'string',\n },\n Blob: {\n eas: 'bytes32',\n },\n}\n\nexport const INTERNAL_PROPERTY_NAMES = [\n 'localId',\n 'uid',\n 'seedLocalId',\n 'seedUid',\n 'schemaUid',\n 'attestationCreatedAt',\n 'attestationRaw',\n 'createdAt',\n 'updatedAt',\n 'lastVersionPublishedAt',\n 'latestVersionLocalId',\n 'latestVersionUid',\n 'lastLocalUpdateAt',\n 'modelName',\n 'storageTransactionId',\n 'refSeedType',\n 'refValueType',\n 'refResolvedValue',\n 'refResolvedDisplayValue',\n 'type',\n // Image\n 'src',\n 'alt',\n //\n 'versionLocalId',\n 'versionsCount',\n 'versionUid',\n '_markedForDeletion',\n]\n\nexport const VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA =\n '0x13c0fd59d69dbce40501a41f8b37768d26dd2e2bb0cad64615334d84f7b9bdf6'\n\nexport const defaultAttestationData: AttestationRequestData = {\n recipient: ZERO_ADDRESS,\n revocable: true,\n value: BigInt(0),\n refUID: ZERO_BYTES32,\n expirationTime: BigInt(0),\n data: ZERO_BYTES,\n}\n\nexport enum ImageSize {\n EXTRA_SMALL = 480,\n SMALL = 760,\n MEDIUM = 1024,\n LARGE = 1440,\n EXTRA_LARGE = 1920,\n}\n\nexport const CLIENT_NOT_INITIALIZED = 'ClientManager is not initialized. Please call init() first.'\n\nexport const INIT_SCRIPT_SUCCESS_MESSAGE = '[Seed Protocol] Finished running init script'\n"],"names":[],"mappings":";;AAQO,MAAM,UAAU,GAAG;AACnB,MAAM,SAAS,GAAG;AAEZ,MAAA,m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AAA,CAAA,GAAA,GAAA,CAAA,GAAA,aAAiB;AACjB,IAAA,SAAA,CAAA,SAAA,CAAA,OAAA,CAAA,GAAA,GAAA,CAAA,GAAA,OAAW;AACX,IAAA,SAAA,CAAA,SAAA,CAAA,QAAA,CAAA,GAAA,IAAA,CAAA,GAAA,QAAa;AACb,IAAA,SAAA,CAAA,SAAA,CAAA,OAAA,CAAA,GAAA,IAAA,CAAA,GAAA,OAAY;AACZ,IAAA,SAAA,CAAA,SAAA,CAAA,aAAA,CAAA,GAAA,IAAA,CAAA,GAAA,aAAkB;AACpB,CAAC,EANW,SAAS,KAAT,SAAS,GAMpB,EAAA,CAAA,CAAA;AAEM,MAAM,sBAAsB,GAAG;AAE/B,MAAM,2BAA2B,GAAG;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/helpers/constants.ts"],"sourcesContent":["import {\n AttestationRequestData,\n ZERO_BYTES,\n ZERO_BYTES32,\n ZERO_ADDRESS,\n} from '@ethereum-attestation-service/eas-sdk'\n\n\nexport const SCHEMA_NJK = 'schema.njk'\n// Primary config file name for Seed Protocol SDK\nexport const SEED_CONFIG_FILE = 'seed.config.ts'\n// Fallback config file names (in order of preference)\nexport const SEED_CONFIG_FALLBACKS = ['seed.schema.ts', 'schema.ts']\n// Legacy constant for backward compatibility\nexport const SCHEMA_TS = SEED_CONFIG_FILE\n\nexport const INTERNAL_DATA_TYPES = {\n Text: {\n eas: 'string',\n },\n Number: {\n eas: 'uint8',\n },\n Image: {\n eas: 'string',\n },\n Relation: {\n eas: 'bytes32',\n },\n List: {\n eas: 'bytes32[]',\n },\n File: {\n eas: 'string',\n },\n Json: {\n eas: 'string',\n },\n Blob: {\n eas: 'bytes32',\n },\n}\n\nexport const INTERNAL_PROPERTY_NAMES = [\n 'localId',\n 'uid',\n 'seedLocalId',\n 'seedUid',\n 'schemaUid',\n 'attestationCreatedAt',\n 'attestationRaw',\n 'createdAt',\n 'updatedAt',\n 'lastVersionPublishedAt',\n 'latestVersionLocalId',\n 'latestVersionUid',\n 'lastLocalUpdateAt',\n 'modelName',\n 'storageTransactionId',\n 'refSeedType',\n 'refValueType',\n 'refResolvedValue',\n 'refResolvedDisplayValue',\n 'type',\n // Image\n 'src',\n 'alt',\n //\n 'versionLocalId',\n 'versionsCount',\n 'versionUid',\n '_markedForDeletion',\n]\n\nexport const VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA =\n '0x13c0fd59d69dbce40501a41f8b37768d26dd2e2bb0cad64615334d84f7b9bdf6'\n\nexport const defaultAttestationData: AttestationRequestData = {\n recipient: ZERO_ADDRESS,\n revocable: true,\n value: BigInt(0),\n refUID: ZERO_BYTES32,\n expirationTime: BigInt(0),\n data: ZERO_BYTES,\n}\n\nexport enum ImageSize {\n EXTRA_SMALL = 480,\n SMALL = 760,\n MEDIUM = 1024,\n LARGE = 1440,\n EXTRA_LARGE = 1920,\n}\n\nexport const CLIENT_NOT_INITIALIZED = 'ClientManager is not initialized. Please call init() first.'\n\nexport const INIT_SCRIPT_SUCCESS_MESSAGE = '[Seed Protocol] Finished running init script'\n"],"names":[],"mappings":";;AAQO,MAAM,UAAU,GAAG;AAC1B;AACO,MAAM,gBAAgB,GAAG;AAChC;MACa,qBAAqB,GAAG,CAAC,gBAAgB,EAAE,WAAW;AAItD,MAAA,mBAAmB,GAAG;AACjC,IAAA,IAAI,EAAE;AACJ,QAAA,GAAG,EAAE,QAAQ;AACd,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,GAAG,EAAE,OAAO;AACb,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,QAAQ;AACd,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE,SAAS;AACf,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,GAAG,EAAE,WAAW;AACjB,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,GAAG,EAAE,QAAQ;AACd,KAAA;AACD,IAAA,IAAI,EAAE;AACJ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BAAsB,GAAG;AAE/B,MAAM,2BAA2B,GAAG;;;;"}
@@ -3,6 +3,12 @@ export * from './ArweaveClient/BaseArweaveClient';
3
3
  export * from './EasClient/BaseEasClient';
4
4
  export * from './QueryClient/BaseQueryClient';
5
5
  export * from './FileManager/BaseFileManager';
6
+ /**
7
+ * Finds the Seed Protocol config file in the given directory
8
+ * @param searchDir - Directory to search for the config file (defaults to process.cwd())
9
+ * @returns The path to the found config file, or null if not found
10
+ */
11
+ export declare const findSeedConfigFile: (searchDir?: string) => string | null;
6
12
  export declare const generateId: () => string;
7
13
  export declare const toSnakeCase: (str: string) => string;
8
14
  export declare const identifyString: (str: string) => "json" | "text" | "base64" | "html" | "markdown" | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAK7C,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,MAAM,WAEtC,CAAA;AAED,eAAO,MAAM,cAAc,QAAS,MAAM,iEA2BzC,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,kBAWzC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,YAe1B,CAAA;AAED,eAAO,MAAM,qBAAqB,SAC1B,MAAM,KACX,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,IAwBrC,CAAA;AAED,eAAO,MAAM,kBAAkB,SACvB,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAc5B,CAAA;AAED,eAAO,MAAM,gBAAgB,2CAI5B,CAAA;AAED,eAAO,MAAM,qBAAqB,WAAY,MAAM,WACF,CAAA;AAElD,eAAO,MAAM,4BAA4B,oBAAqB,MAAM;;;;CAiBnE,CAAA;AAGD,eAAO,MAAM,QAAQ,gBAAiB,WAAW,KAAG,OAwBnD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAM9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAK7C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,eAAe,MAAM,KAAmB,MAAM,GAAG,IAgB/E,CAAA;AAED,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,MAAM,WAEtC,CAAA;AAED,eAAO,MAAM,cAAc,QAAS,MAAM,iEA2BzC,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,kBAWzC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,YAe1B,CAAA;AAED,eAAO,MAAM,qBAAqB,SAC1B,MAAM,KACX,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,IAwBrC,CAAA;AAED,eAAO,MAAM,kBAAkB,SACvB,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAc5B,CAAA;AAED,eAAO,MAAM,gBAAgB,2CAI5B,CAAA;AAED,eAAO,MAAM,qBAAqB,WAAY,MAAM,WACF,CAAA;AAElD,eAAO,MAAM,4BAA4B,oBAAqB,MAAM;;;;CAiBnE,CAAA;AAGD,eAAO,MAAM,QAAQ,gBAAiB,WAAW,KAAG,OAwBnD,CAAA"}
@@ -2,11 +2,34 @@ import { customAlphabet } from 'nanoid';
2
2
  import * as nanoIdDictionary from 'nanoid-dictionary';
3
3
  import debug from 'debug';
4
4
  import { BaseFileManager } from './FileManager/BaseFileManager.js';
5
+ import { SEED_CONFIG_FILE, SEED_CONFIG_FALLBACKS } from './constants.js';
6
+ import fs from 'fs';
7
+ import path from 'path';
5
8
  import 'graphql-request';
6
9
  import '../services/internal/constants.js';
7
10
 
8
11
  const logger = debug('seedSdk:shared:helpers');
9
12
  const { alphanumeric } = nanoIdDictionary;
13
+ /**
14
+ * Finds the Seed Protocol config file in the given directory
15
+ * @param searchDir - Directory to search for the config file (defaults to process.cwd())
16
+ * @returns The path to the found config file, or null if not found
17
+ */
18
+ const findSeedConfigFile = (searchDir = process.cwd()) => {
19
+ // First try the primary config file name
20
+ const primaryPath = path.join(searchDir, SEED_CONFIG_FILE);
21
+ if (fs.existsSync(primaryPath)) {
22
+ return primaryPath;
23
+ }
24
+ // Then try fallback names in order
25
+ for (const fallbackName of SEED_CONFIG_FALLBACKS) {
26
+ const fallbackPath = path.join(searchDir, fallbackName);
27
+ if (fs.existsSync(fallbackPath)) {
28
+ return fallbackPath;
29
+ }
30
+ }
31
+ return null;
32
+ };
10
33
  const generateId = () => {
11
34
  return customAlphabet(alphanumeric, 10)();
12
35
  };
@@ -86,5 +109,5 @@ const parseEasRelationPropertyName = (easPropertyName) => {
86
109
  };
87
110
  };
88
111
 
89
- export { BaseFileManager, convertTxIdToImage, generateId, getCorrectId, getDataTypeFromString, getMimeType, parseEasRelationPropertyName, toSnakeCase };
112
+ export { BaseFileManager, convertTxIdToImage, findSeedConfigFile, generateId, getCorrectId, getDataTypeFromString, getMimeType, parseEasRelationPropertyName, toSnakeCase };
90
113
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/helpers/index.ts"],"sourcesContent":["import { customAlphabet } from 'nanoid'\nimport * as nanoIdDictionary from 'nanoid-dictionary'\nimport debug from 'debug'\nimport { GetCorrectId } from '@/types/helpers'\nimport { GetCorrectIdReturn } from '@/types/helpers'\nimport { BaseFileManager } from './FileManager/BaseFileManager'\nexport * from './ArweaveClient/BaseArweaveClient'\nexport * from './EasClient/BaseEasClient'\nexport * from './QueryClient/BaseQueryClient'\nexport * from './FileManager/BaseFileManager'\nconst logger = debug('seedSdk:shared:helpers')\n\nconst { alphanumeric } = nanoIdDictionary\n\nexport const generateId = (): string => {\n return customAlphabet(alphanumeric, 10)()\n}\n\nexport const toSnakeCase = (str: string) => {\n return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()\n}\n\nexport const identifyString = (str: string) => {\n try {\n JSON.parse(str)\n return 'json'\n } catch (e) {\n // Not JSON\n }\n\n if (!str) {\n return\n }\n\n if (str.trim().startsWith('<') && str.trim().endsWith('>')) {\n return 'html'\n }\n\n // Simple markdown checks (very naive)\n if (/^#{1,6}\\s|^-{3,}|\\*{3,}|^-{1,2}\\s|\\*\\s/.test(str)) {\n return 'markdown'\n }\n\n if (/^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/.test(str)) {\n return 'base64'\n }\n\n // Default to plain text if unsure\n return 'text'\n}\n\nexport const getMimeType = (base64: string) => {\n if (!base64) {\n return null\n }\n const result = base64.match(/^data:([a-zA-Z0-9]+\\/[a-zA-Z0-9-.+]+).*,/)\n\n if (result && result.length > 1) {\n return result[1]\n } else {\n return null // MIME type could not be determined\n }\n}\n\nexport const getCorrectId: GetCorrectId = (localIdOrUid: string) => {\n const id: GetCorrectIdReturn = {\n localId: undefined,\n uid: undefined,\n }\n if (!localIdOrUid) {\n return id\n }\n if (localIdOrUid.length === 10) {\n id.localId = localIdOrUid\n }\n if (localIdOrUid.startsWith('0x') && localIdOrUid.length === 66) {\n id.uid = localIdOrUid\n }\n return id\n}\n\nexport const getDataTypeFromString = (\n data: string,\n): 'imageBase64' | 'base64' | 'url' | null => {\n const nonImageBase64Regex =\n /^(?!data:image\\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/\n\n if (nonImageBase64Regex.test(data)) {\n return 'base64'\n }\n\n // Regular expression for base64 (simple version, checking for base64 format)\n const imageBase64Regex = /^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/\n\n if (imageBase64Regex.test(data)) {\n return 'imageBase64'\n }\n\n // Regular expression for URL (simple version, checking for common URL format)\n const urlRegex =\n /^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/\n\n if (urlRegex.test(data)) {\n return 'url'\n }\n\n return null\n}\n\nexport const convertTxIdToImage = async (\n txId: string,\n): Promise<string | undefined> => {\n const imageFilePath = `/files/images/${txId}`\n const fileExists = await BaseFileManager.pathExists(imageFilePath)\n if (!fileExists) {\n logger(`[ItemView] [updateImage] ${imageFilePath} does not exist`)\n return\n }\n const buffer = await BaseFileManager.readFileAsBuffer(imageFilePath)\n\n const uint = new Uint8Array(buffer)\n\n const imageBlob = new Blob([uint])\n\n return URL.createObjectURL(imageBlob)\n}\n\nexport const getExecutionTime = async (task, args) => {\n const start = Date.now()\n await task(...args)\n return Date.now() - start\n}\n\nexport const capitalizeFirstLetter = (string: string) =>\n string.charAt(0).toUpperCase() + string.slice(1)\n\nexport const parseEasRelationPropertyName = (easPropertyName: string) => {\n // Split the input string on the first underscore\n const [singularProperty, modelName, idSegment] = easPropertyName.split('_')\n\n // If there are any other parts, assume it is a list (e.g., has 'ids' or other suffix)\n const isList = idSegment === 'ids'\n\n // Create the final property name by pluralizing the singular part\n const propertyName = singularProperty.endsWith('s')\n ? singularProperty\n : singularProperty + 's'\n\n return {\n propertyName, // Plural form of the property name\n modelName, // Model name extracted from the second part\n isList, // True if the property is a list (e.g., 'ids' is present)\n }\n}\n\n\nexport const isBinary = (arrayBuffer: ArrayBuffer): boolean => {\n const view = new Uint8Array(arrayBuffer);\n\n let nonTextCount = 0;\n const threshold = 0.2; // Adjust as needed (e.g., 20% non-text implies binary)\n\n for (let i = 0; i < view.length; i++) {\n const byte = view[i];\n\n // ASCII printable characters (32-126) and common whitespace (9, 10, 13)\n if (\n (byte >= 32 && byte <= 126) || // Printable ASCII\n byte === 9 || byte === 10 || byte === 13 // Tab, LF, CR\n ) {\n continue;\n }\n\n nonTextCount++;\n if (nonTextCount / view.length > threshold) {\n return true; // More than threshold are non-text bytes\n }\n }\n\n return false; // Fewer than threshold are non-text bytes\n}\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,MAAM,GAAG,KAAK,CAAC,wBAAwB,CAAC;AAE9C,MAAM,EAAE,YAAY,EAAE,GAAG,gBAAgB;AAElC,MAAM,UAAU,GAAG,MAAa;AACrC,IAAA,OAAO,cAAc,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE;AAC3C;AAEa,MAAA,WAAW,GAAG,CAAC,GAAW,KAAI;IACzC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE;AAC9D;AA+Ba,MAAA,WAAW,GAAG,CAAC,MAAc,KAAI;IAC5C,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,IAAI;;IAEb,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC;IAEvE,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;AAC/B,QAAA,OAAO,MAAM,CAAC,CAAC,CAAC;;SACX;QACL,OAAO,IAAI,CAAA;;AAEf;AAEa,MAAA,YAAY,GAAiB,CAAC,YAAoB,KAAI;AACjE,IAAA,MAAM,EAAE,GAAuB;AAC7B,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,GAAG,EAAE,SAAS;KACf;IACD,IAAI,CAAC,YAAY,EAAE;AACjB,QAAA,OAAO,EAAE;;AAEX,IAAA,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE;AAC9B,QAAA,EAAE,CAAC,OAAO,GAAG,YAAY;;AAE3B,IAAA,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE;AAC/D,QAAA,EAAE,CAAC,GAAG,GAAG,YAAY;;AAEvB,IA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,YAAY,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG;AAChD,UAAE;AACF,UAAE,gBAAgB,GAAG,GAAG;IAE1B,OAAO;AACL,QAAA,YAAY;AACZ,QAAA,SAAS;AACT,QAAA,MAAM;KACP;AACH;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/helpers/index.ts"],"sourcesContent":["import { customAlphabet } from 'nanoid'\nimport * as nanoIdDictionary from 'nanoid-dictionary'\nimport debug from 'debug'\nimport { GetCorrectId } from '@/types/helpers'\nimport { GetCorrectIdReturn } from '@/types/helpers'\nimport { BaseFileManager } from './FileManager/BaseFileManager'\nimport { SEED_CONFIG_FILE, SEED_CONFIG_FALLBACKS } from './constants'\nimport fs from 'fs'\nimport path from 'path'\nexport * from './ArweaveClient/BaseArweaveClient'\nexport * from './EasClient/BaseEasClient'\nexport * from './QueryClient/BaseQueryClient'\nexport * from './FileManager/BaseFileManager'\nconst logger = debug('seedSdk:shared:helpers')\n\nconst { alphanumeric } = nanoIdDictionary\n\n/**\n * Finds the Seed Protocol config file in the given directory\n * @param searchDir - Directory to search for the config file (defaults to process.cwd())\n * @returns The path to the found config file, or null if not found\n */\nexport const findSeedConfigFile = (searchDir: string = process.cwd()): string | null => {\n // First try the primary config file name\n const primaryPath = path.join(searchDir, SEED_CONFIG_FILE)\n if (fs.existsSync(primaryPath)) {\n return primaryPath\n }\n\n // Then try fallback names in order\n for (const fallbackName of SEED_CONFIG_FALLBACKS) {\n const fallbackPath = path.join(searchDir, fallbackName)\n if (fs.existsSync(fallbackPath)) {\n return fallbackPath\n }\n }\n\n return null\n}\n\nexport const generateId = (): string => {\n return customAlphabet(alphanumeric, 10)()\n}\n\nexport const toSnakeCase = (str: string) => {\n return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()\n}\n\nexport const identifyString = (str: string) => {\n try {\n JSON.parse(str)\n return 'json'\n } catch (e) {\n // Not JSON\n }\n\n if (!str) {\n return\n }\n\n if (str.trim().startsWith('<') && str.trim().endsWith('>')) {\n return 'html'\n }\n\n // Simple markdown checks (very naive)\n if (/^#{1,6}\\s|^-{3,}|\\*{3,}|^-{1,2}\\s|\\*\\s/.test(str)) {\n return 'markdown'\n }\n\n if (/^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/.test(str)) {\n return 'base64'\n }\n\n // Default to plain text if unsure\n return 'text'\n}\n\nexport const getMimeType = (base64: string) => {\n if (!base64) {\n return null\n }\n const result = base64.match(/^data:([a-zA-Z0-9]+\\/[a-zA-Z0-9-.+]+).*,/)\n\n if (result && result.length > 1) {\n return result[1]\n } else {\n return null // MIME type could not be determined\n }\n}\n\nexport const getCorrectId: GetCorrectId = (localIdOrUid: string) => {\n const id: GetCorrectIdReturn = {\n localId: undefined,\n uid: undefined,\n }\n if (!localIdOrUid) {\n return id\n }\n if (localIdOrUid.length === 10) {\n id.localId = localIdOrUid\n }\n if (localIdOrUid.startsWith('0x') && localIdOrUid.length === 66) {\n id.uid = localIdOrUid\n }\n return id\n}\n\nexport const getDataTypeFromString = (\n data: string,\n): 'imageBase64' | 'base64' | 'url' | null => {\n const nonImageBase64Regex =\n /^(?!data:image\\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/\n\n if (nonImageBase64Regex.test(data)) {\n return 'base64'\n }\n\n // Regular expression for base64 (simple version, checking for base64 format)\n const imageBase64Regex = /^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/\n\n if (imageBase64Regex.test(data)) {\n return 'imageBase64'\n }\n\n // Regular expression for URL (simple version, checking for common URL format)\n const urlRegex =\n /^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/\n\n if (urlRegex.test(data)) {\n return 'url'\n }\n\n return null\n}\n\nexport const convertTxIdToImage = async (\n txId: string,\n): Promise<string | undefined> => {\n const imageFilePath = `/files/images/${txId}`\n const fileExists = await BaseFileManager.pathExists(imageFilePath)\n if (!fileExists) {\n logger(`[ItemView] [updateImage] ${imageFilePath} does not exist`)\n return\n }\n const buffer = await BaseFileManager.readFileAsBuffer(imageFilePath)\n\n const uint = new Uint8Array(buffer)\n\n const imageBlob = new Blob([uint])\n\n return URL.createObjectURL(imageBlob)\n}\n\nexport const getExecutionTime = async (task, args) => {\n const start = Date.now()\n await task(...args)\n return Date.now() - start\n}\n\nexport const capitalizeFirstLetter = (string: string) =>\n string.charAt(0).toUpperCase() + string.slice(1)\n\nexport const parseEasRelationPropertyName = (easPropertyName: string) => {\n // Split the input string on the first underscore\n const [singularProperty, modelName, idSegment] = easPropertyName.split('_')\n\n // If there are any other parts, assume it is a list (e.g., has 'ids' or other suffix)\n const isList = idSegment === 'ids'\n\n // Create the final property name by pluralizing the singular part\n const propertyName = singularProperty.endsWith('s')\n ? singularProperty\n : singularProperty + 's'\n\n return {\n propertyName, // Plural form of the property name\n modelName, // Model name extracted from the second part\n isList, // True if the property is a list (e.g., 'ids' is present)\n }\n}\n\n\nexport const isBinary = (arrayBuffer: ArrayBuffer): boolean => {\n const view = new Uint8Array(arrayBuffer);\n\n let nonTextCount = 0;\n const threshold = 0.2; // Adjust as needed (e.g., 20% non-text implies binary)\n\n for (let i = 0; i < view.length; i++) {\n const byte = view[i];\n\n // ASCII printable characters (32-126) and common whitespace (9, 10, 13)\n if (\n (byte >= 32 && byte <= 126) || // Printable ASCII\n byte === 9 || byte === 10 || byte === 13 // Tab, LF, CR\n ) {\n continue;\n }\n\n nonTextCount++;\n if (nonTextCount / view.length > threshold) {\n return true; // More than threshold are non-text bytes\n }\n }\n\n return false; // Fewer than threshold are non-text bytes\n}\n"],"names":[],"mappings":";;;;;;;;;;AAaA,MAAM,MAAM,GAAG,KAAK,CAAC,wBAAwB,CAAC;AAE9C,MAAM,EAAE,YAAY,EAAE,GAAG,gBAAgB;AAEzC;;;;AAIG;AACU,MAAA,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MAAA,4BAA4B,GAAG,CAAC,eAAuB,KAAI;;AAEtE,IAAA,MAAM,CAAC,gBAAgB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC;;AAG3E,IAAA,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK;;AAGlC,IAAA,MAAM,YAAY,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG;AAChD,UAAE;AACF,UAAE,gBAAgB,GAAG,GAAG;IAE1B,OAAO;AACL,QAAA,YAAY;AACZ,QAAA,SAAS;AACT,QAAA,MAAM;KACP;AACH;;;;"}
@@ -21,6 +21,12 @@ export declare class PathResolver {
21
21
  * Gets the .seed directory path
22
22
  */
23
23
  getDotSeedDir(schemaFileDir?: string): string;
24
+ /**
25
+ * Finds the Seed Protocol config file in the given directory
26
+ * @param searchDir - Directory to search for the config file
27
+ * @returns The path to the found config file, or null if not found
28
+ */
29
+ findConfigFile(searchDir?: string): string | null;
24
30
  /**
25
31
  * Gets paths for app-specific directories
26
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PathResolver.d.ts","sourceRoot":"","sources":["../../../src/node/PathResolver.ts"],"names":[],"mappings":"AAIA,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,gBAAgB;IAcxB;;OAEG;IACH,sBAAsB,IAAI,MAAM;IAYhC;;OAEG;IACH,aAAa,IAAI,MAAM;IAmCvB,iBAAiB,IAAI,MAAM;IAa3B;;OAEG;IACH,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;IAO7C;;OAEG;IACH,WAAW,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS;;;;;;;;;;;CA4B/C"}
1
+ {"version":3,"file":"PathResolver.d.ts","sourceRoot":"","sources":["../../../src/node/PathResolver.ts"],"names":[],"mappings":"AAKA,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,gBAAgB;IAcxB;;OAEG;IACH,sBAAsB,IAAI,MAAM;IAYhC;;OAEG;IACH,aAAa,IAAI,MAAM;IAmCvB,iBAAiB,IAAI,MAAM;IAa3B;;OAEG;IACH,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;IAO7C;;;;OAIG;IACH,cAAc,CAAC,SAAS,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI;IAIhE;;OAEG;IACH,WAAW,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS;;;;;;;;;;;CA4B/C"}
@@ -1,6 +1,7 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
3
  import { NODE_APP_DB_CONFIG } from './constants.js';
4
+ import { findSeedConfigFile } from '../helpers/index.js';
4
5
 
5
6
  class PathResolver {
6
7
  constructor() { }
@@ -94,8 +95,8 @@ class PathResolver {
94
95
  // This should be {localDir}/seed-protocol-sdk/src
95
96
  return path.join(rootWithNodeModules, 'src');
96
97
  default:
97
- // This should be {projectDir}/node_modules/@seedprotocol/sdk
98
- return path.join(rootWithNodeModules, 'node_modules', '@seedprotocol', 'sdk');
98
+ // This should be {projectDir}/node_modules/@seedprotocol/sdk/dist
99
+ return path.join(rootWithNodeModules, 'node_modules', '@seedprotocol', 'sdk', 'dist');
99
100
  }
100
101
  }
101
102
  getNodeModulesDir() {
@@ -116,6 +117,14 @@ class PathResolver {
116
117
  }
117
118
  return path.join(schemaFileDir || process.cwd(), '.seed');
118
119
  }
120
+ /**
121
+ * Finds the Seed Protocol config file in the given directory
122
+ * @param searchDir - Directory to search for the config file
123
+ * @returns The path to the found config file, or null if not found
124
+ */
125
+ findConfigFile(searchDir = process.cwd()) {
126
+ return findSeedConfigFile(searchDir);
127
+ }
119
128
  /**
120
129
  * Gets paths for app-specific directories
121
130
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PathResolver.js","sources":["../../../../src/node/PathResolver.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport { NODE_APP_DB_CONFIG } from './constants'\n\nexport class PathResolver {\n private static instance: PathResolver\n private constructor() {}\n\n static getInstance(): PathResolver {\n if (!PathResolver.instance) {\n PathResolver.instance = new PathResolver()\n }\n return PathResolver.instance\n }\n\n /**\n * Detects the current environment based on filesystem structure and package.json\n */\n private detectEnvironment(): 'sdk-dev' | 'linked-sdk' | 'test' | 'production' {\n // Check if we're in the SDK repo itself\n if (process.env.NODE_ENV !== 'test' && this.isInSdkRepo()) {\n return 'sdk-dev'\n }\n\n // Check if we're running tests\n if (process.env.NODE_ENV === 'test') {\n return 'test'\n }\n\n // Check if we're using a linked version of the SDK\n if (this.isUsingLinkedSdk()) {\n return 'linked-sdk'\n }\n\n // Default to production environment\n return 'production'\n }\n\n private isInSdkRepo(): boolean {\n try {\n // Check if we're in the SDK repo by looking for specific SDK files/directories\n const currentDir = process.cwd()\n return fs.existsSync(path.join(currentDir, 'src', 'node')) &&\n fs.existsSync(path.join(currentDir, 'package.json')) &&\n JSON.parse(fs.readFileSync(path.join(currentDir, 'package.json'), 'utf8')).name === '@seedprotocol/sdk'\n } catch {\n return false\n }\n }\n\n private isUsingLinkedSdk(): boolean {\n try {\n const pkgPath = path.join(process.cwd(), 'package.json')\n if (!fs.existsSync(pkgPath)) return false\n \n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))\n const sdkDep = pkg.dependencies?.['@seedprotocol/sdk']\n \n return sdkDep && (sdkDep.startsWith('link:') || sdkDep.startsWith('portal:'))\n } catch {\n return false\n }\n }\n\n /**\n * Gets the root directory containing node_modules\n */\n getRootWithNodeModules(): string {\n const processCwd = process.cwd()\n\n const calledFromMocks = processCwd.includes('__mocks__')\n\n if (calledFromMocks) {\n return path.join(processCwd, '..', '..', '..', '..',)\n }\n\n return processCwd\n }\n\n /**\n * Gets the SDK root directory\n */\n getSdkRootDir(): string {\n const env = this.detectEnvironment()\n const rootWithNodeModules = this.getRootWithNodeModules()\n const processCwd = process.cwd()\n\n if (process.cwd().includes('__mocks__')) {\n return path.join(rootWithNodeModules, 'src')\n }\n\n if (env === 'linked-sdk') {\n // For linked packages, find the package directory\n const pkgJson = JSON.parse(fs.readFileSync(path.join(processCwd, 'package.json'), 'utf8'))\n const sdkPath = pkgJson.dependencies?.['@seedprotocol/sdk'] || pkgJson.devDependencies?.['@seedprotocol/sdk']\n console.log(sdkPath)\n if (sdkPath === 'link:@seedprotocol/sdk') {\n return path.join(processCwd, 'node_modules', '@seedprotocol', 'sdk', 'src')\n }\n return path.resolve(processCwd, sdkPath.replace(/^(link:|portal:)/, ''))\n }\n\n console.log('getSdkRootDir', rootWithNodeModules, env)\n\n switch (env) {\n case 'sdk-dev':\n // This should be {localDir}/seed-protocol-sdk/src\n return path.join(rootWithNodeModules, 'src')\n case 'test':\n // This should be {localDir}/seed-protocol-sdk/src\n return path.join(rootWithNodeModules, 'src')\n default:\n // This should be {projectDir}/node_modules/@seedprotocol/sdk\n return path.join(rootWithNodeModules, 'node_modules', '@seedprotocol', 'sdk',)\n }\n }\n\n getNodeModulesDir(): string {\n const env = this.detectEnvironment()\n const rootWithNodeModules = this.getRootWithNodeModules()\n\n let nodeModulesDir = path.join(rootWithNodeModules, 'node_modules')\n\n if (env !== 'linked-sdk' && env !== 'sdk-dev' && nodeModulesDir.includes('__tests__')) {\n nodeModulesDir = path.join(process.cwd(), '..', '..', '..', '..', 'node_modules',)\n }\n\n return nodeModulesDir\n }\n\n /**\n * Gets the .seed directory path\n */\n getDotSeedDir(schemaFileDir?: string): string {\n if (!schemaFileDir && process.env.SEED_SDK_TEST_PROJECT_TYPE && !process.cwd().includes('__mocks__')) {\n return path.join(process.cwd(), '__tests__', '__mocks__', process.env.SEED_SDK_TEST_PROJECT_TYPE, 'project', '.seed')\n }\n return path.join(schemaFileDir || process.cwd(), '.seed')\n }\n\n /**\n * Gets paths for app-specific directories\n */\n getAppPaths(schemaFileDir?: string | undefined) {\n const env = this.detectEnvironment()\n const dotSeedDir = this.getDotSeedDir(schemaFileDir)\n const nodeModulesDir = this.getNodeModulesDir()\n\n let drizzleKitPath = path.join(nodeModulesDir, 'drizzle-kit', 'bin.cjs')\n\n if (env === 'linked-sdk') {\n const sdkRootDir = this.getSdkRootDir()\n console.log(`sdkRootDir: ${sdkRootDir}`)\n const sdkPackageDir = path.dirname(sdkRootDir)\n console.log(`sdkPackageDir: ${sdkPackageDir}`)\n const sdkNodeModulesDir = path.join(sdkPackageDir, 'node_modules')\n drizzleKitPath = path.join(sdkNodeModulesDir, 'drizzle-kit', 'bin.cjs')\n }\n\n return {\n sdkRootDir: this.getSdkRootDir(),\n dotSeedDir,\n nodeModulesDir,\n appSchemaDir: path.join(dotSeedDir, 'schema'),\n appDbDir: path.join(dotSeedDir, 'db'),\n appMetaDir: path.join(dotSeedDir, 'db', 'meta'),\n drizzleDbConfigPath: path.join(this.getSdkRootDir(), 'node', 'db', NODE_APP_DB_CONFIG),\n drizzleKitPath,\n templatePath: path.join(this.getSdkRootDir(), 'node', 'codegen', 'templates')\n }\n }\n} \n"],"names":[],"mappings":";;;;MAIa,YAAY,CAAA;AAEvB,IAAA,WAAA,GAAA;AAEA,IAAA,OAAO,WAAW,GAAA;AAChB,QAAA,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;AAC1B,YAAA,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE;;QAE5C,OAAO,YAAY,CAAC,QAAQ;;AAG9B;;AAEG;IACK,iBAAiB,GAAA;;AAEvB,QAAA,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,EAA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AI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC;YACtF,cAAc;AACd,YAAA,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW;SAC7E;;AAEJ;;;;"}
1
+ {"version":3,"file":"PathResolver.js","sources":["../../../../src/node/PathResolver.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport { NODE_APP_DB_CONFIG } from './constants'\nimport { findSeedConfigFile } from '@/helpers'\n\nexport class PathResolver {\n private static instance: PathResolver\n private constructor() {}\n\n static getInstance(): PathResolver {\n if (!PathResolver.instance) {\n PathResolver.instance = new PathResolver()\n }\n return PathResolver.instance\n }\n\n /**\n * Detects the current environment based on filesystem structure and package.json\n */\n private detectEnvironment(): 'sdk-dev' | 'linked-sdk' | 'test' | 'production' {\n // Check if we're in the SDK repo itself\n if (process.env.NODE_ENV !== 'test' && this.isInSdkRepo()) {\n return 'sdk-dev'\n }\n\n // Check if we're running tests\n if (process.env.NODE_ENV === 'test') {\n return 'test'\n }\n\n // Check if we're using a linked version of the SDK\n if (this.isUsingLinkedSdk()) {\n return 'linked-sdk'\n }\n\n // Default to production environment\n return 'production'\n }\n\n private isInSdkRepo(): boolean {\n try {\n // Check if we're in the SDK repo by looking for specific SDK files/directories\n const currentDir = process.cwd()\n return fs.existsSync(path.join(currentDir, 'src', 'node')) &&\n fs.existsSync(path.join(currentDir, 'package.json')) &&\n JSON.parse(fs.readFileSync(path.join(currentDir, 'package.json'), 'utf8')).name === '@seedprotocol/sdk'\n } catch {\n return false\n }\n }\n\n private isUsingLinkedSdk(): boolean {\n try {\n const pkgPath = path.join(process.cwd(), 'package.json')\n if (!fs.existsSync(pkgPath)) return false\n \n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))\n const sdkDep = pkg.dependencies?.['@seedprotocol/sdk']\n \n return sdkDep && (sdkDep.startsWith('link:') || sdkDep.startsWith('portal:'))\n } catch {\n return false\n }\n }\n\n /**\n * Gets the root directory containing node_modules\n */\n getRootWithNodeModules(): string {\n const processCwd = process.cwd()\n\n const calledFromMocks = processCwd.includes('__mocks__')\n\n if (calledFromMocks) {\n return path.join(processCwd, '..', '..', '..', '..',)\n }\n\n return processCwd\n }\n\n /**\n * Gets the SDK root directory\n */\n getSdkRootDir(): string {\n const env = this.detectEnvironment()\n const rootWithNodeModules = this.getRootWithNodeModules()\n const processCwd = process.cwd()\n\n if (process.cwd().includes('__mocks__')) {\n return path.join(rootWithNodeModules, 'src')\n }\n\n if (env === 'linked-sdk') {\n // For linked packages, find the package directory\n const pkgJson = JSON.parse(fs.readFileSync(path.join(processCwd, 'package.json'), 'utf8'))\n const sdkPath = pkgJson.dependencies?.['@seedprotocol/sdk'] || pkgJson.devDependencies?.['@seedprotocol/sdk']\n console.log(sdkPath)\n if (sdkPath === 'link:@seedprotocol/sdk') {\n return path.join(processCwd, 'node_modules', '@seedprotocol', 'sdk', 'src')\n }\n return path.resolve(processCwd, sdkPath.replace(/^(link:|portal:)/, ''))\n }\n\n console.log('getSdkRootDir', rootWithNodeModules, env)\n\n switch (env) {\n case 'sdk-dev':\n // This should be {localDir}/seed-protocol-sdk/src\n return path.join(rootWithNodeModules, 'src')\n case 'test':\n // This should be {localDir}/seed-protocol-sdk/src\n return path.join(rootWithNodeModules, 'src')\n default:\n // This should be {projectDir}/node_modules/@seedprotocol/sdk/dist\n return path.join(rootWithNodeModules, 'node_modules', '@seedprotocol', 'sdk', 'dist')\n }\n }\n\n getNodeModulesDir(): string {\n const env = this.detectEnvironment()\n const rootWithNodeModules = this.getRootWithNodeModules()\n\n let nodeModulesDir = path.join(rootWithNodeModules, 'node_modules')\n\n if (env !== 'linked-sdk' && env !== 'sdk-dev' && nodeModulesDir.includes('__tests__')) {\n nodeModulesDir = path.join(process.cwd(), '..', '..', '..', '..', 'node_modules',)\n }\n\n return nodeModulesDir\n }\n\n /**\n * Gets the .seed directory path\n */\n getDotSeedDir(schemaFileDir?: string): string {\n if (!schemaFileDir && process.env.SEED_SDK_TEST_PROJECT_TYPE && !process.cwd().includes('__mocks__')) {\n return path.join(process.cwd(), '__tests__', '__mocks__', process.env.SEED_SDK_TEST_PROJECT_TYPE, 'project', '.seed')\n }\n return path.join(schemaFileDir || process.cwd(), '.seed')\n }\n\n /**\n * Finds the Seed Protocol config file in the given directory\n * @param searchDir - Directory to search for the config file\n * @returns The path to the found config file, or null if not found\n */\n findConfigFile(searchDir: string = process.cwd()): string | null {\n return findSeedConfigFile(searchDir)\n }\n\n /**\n * Gets paths for app-specific directories\n */\n getAppPaths(schemaFileDir?: string | undefined) {\n const env = this.detectEnvironment()\n const dotSeedDir = this.getDotSeedDir(schemaFileDir)\n const nodeModulesDir = this.getNodeModulesDir()\n\n let drizzleKitPath = path.join(nodeModulesDir, 'drizzle-kit', 'bin.cjs')\n\n if (env === 'linked-sdk') {\n const sdkRootDir = this.getSdkRootDir()\n console.log(`sdkRootDir: ${sdkRootDir}`)\n const sdkPackageDir = path.dirname(sdkRootDir)\n console.log(`sdkPackageDir: ${sdkPackageDir}`)\n const sdkNodeModulesDir = path.join(sdkPackageDir, 'node_modules')\n drizzleKitPath = path.join(sdkNodeModulesDir, 'drizzle-kit', 'bin.cjs')\n }\n\n return {\n sdkRootDir: this.getSdkRootDir(),\n dotSeedDir,\n nodeModulesDir,\n appSchemaDir: path.join(dotSeedDir, 'schema'),\n appDbDir: path.join(dotSeedDir, 'db'),\n appMetaDir: path.join(dotSeedDir, 'db', 'meta'),\n drizzleDbConfigPath: path.join(this.getSdkRootDir(), 'node', 'db', NODE_APP_DB_CONFIG),\n drizzleKitPath,\n templatePath: path.join(this.getSdkRootDir(), 'node', 'codegen', 'templates')\n }\n }\n} \n"],"names":[],"mappings":";;;;;MAKa,YAAY,CAAA;AAEvB,IAAA,WAAA,GAAA;AAEA,IAAA,OAAO,WAAW,GAAA;AAChB,QAAA,IAAI,CAAC,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CAAC,iBAAiB,EAAE,aAAa,EAAE,SAAS,CAAC;;QAGzE,OAAO;AACL,YAAA,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;YAChC,UAAU;YACV,cAAc;YACd,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;YAC7C,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;YACrC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC;AAC/C,YAAA,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC;YACtF,cAAc;AACd,YAAA,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW;SAC7E;;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"drizzle.d.ts","sourceRoot":"","sources":["../../../../src/node/codegen/drizzle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAY,SAAS,CAAA;AA4C9C,eAAO,MAAM,yBAAyB,cACzB,MAAM,cACL,cAAc,KACzB,MAgBF,CAAA;AAED,eAAO,MAAM,kCAAkC,mBAC7B,MAAM,GAAG,SAAS,iBACnB,MAAM,GAAG,SAAS,kBA0BlC,CAAA;AA2BD,eAAO,MAAM,iBAAiB,WAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAY/D,CAAC"}
1
+ {"version":3,"file":"drizzle.d.ts","sourceRoot":"","sources":["../../../../src/node/codegen/drizzle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAY,SAAS,CAAA;AA4C9C,eAAO,MAAM,yBAAyB,cACzB,MAAM,cACL,cAAc,KACzB,MAgBF,CAAA;AAED,eAAO,MAAM,kCAAkC,mBAC7B,MAAM,GAAG,SAAS,iBACnB,MAAM,GAAG,SAAS,kBA2BlC,CAAA;AA2BD,eAAO,MAAM,iBAAiB,WAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAY/D,CAAC"}
@@ -55,7 +55,8 @@ const createDrizzleSchemaFilesFromConfig = async (configFilePath, outputDirPath)
55
55
  const pathResolver = PathResolver.getInstance();
56
56
  const { dotSeedDir, appSchemaDir } = pathResolver.getAppPaths();
57
57
  console.log('createDrizzleSchemaFilesFromConfig', configFilePath, outputDirPath);
58
- const schemaFilePath = configFilePath || path.join(dotSeedDir, 'schema.ts'); // Developer created file with model definitions
58
+ // Use provided config file path or find the config file in the project root
59
+ const schemaFilePath = configFilePath || pathResolver.findConfigFile() || path.join(dotSeedDir, 'seed.config.ts');
59
60
  console.log('schemaFilePath', schemaFilePath);
60
61
  const { models, } = await getTsImport(schemaFilePath);
61
62
  const writeToDir = appSchemaDir;
@@ -1 +1 @@
1
- {"version":3,"file":"drizzle.js","sources":["../../../../../src/node/codegen/drizzle.ts"],"sourcesContent":["import path from 'path'\nimport pluralize from 'pluralize'\nimport { camelCase, snakeCase } from 'lodash-es'\nimport * as nunjucks from 'nunjucks'\nimport { ILoader } from 'nunjucks'\nimport { ModelClassType } from '@/types'\nimport { SCHEMA_NJK } from '@/helpers/constants'\nimport { getTsImport } from '@/node/helpers'\nimport fs from 'fs'\nimport {PathResolver} from '@/node/PathResolver'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:codegen:drizzle')\n\n\nconst TemplateLoader: ILoader = {\n getSource: (name: string) => {\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n let templateFilePath = templatePath\n if (name.includes(templatePath)) {\n templateFilePath = name\n } else {\n templateFilePath = path.join(templatePath, path.basename(name))\n }\n const src = fs.readFileSync(templateFilePath, 'utf-8')\n\n return {\n path: name,\n src,\n noCache: false,\n }\n },\n}\n\n// Configure Nunjucks\nconst env = new nunjucks.Environment(TemplateLoader)\n\nenv.addFilter('camelCase', camelCase)\nenv.addFilter('snakeCase', snakeCase)\nenv.addFilter('pluralize', pluralize)\n\nconst refNamesToExcludeFromRelations = [\n 'Text',\n 'Number',\n 'Boolean',\n 'Date',\n]\n\nexport const generateDrizzleSchemaCode = (\n modelName: string,\n modelClass: ModelClassType,\n): string => {\n const listProperties = Object.entries(modelClass.schema).filter(\n ([key, propertyDef]) => propertyDef?.dataType === 'List' && !refNamesToExcludeFromRelations.includes(propertyDef?.ref!),\n )\n\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n const filePath = path.join(templatePath, SCHEMA_NJK)\n\n const schemaCode = env.render(filePath, {\n modelName,\n modelClass,\n listProperties,\n })\n\n return schemaCode\n}\n\nexport const createDrizzleSchemaFilesFromConfig = async (\n configFilePath: string | undefined,\n outputDirPath: string | undefined,\n) => {\n const pathResolver = PathResolver.getInstance()\n const { dotSeedDir, appSchemaDir } = pathResolver.getAppPaths()\n console.log('createDrizzleSchemaFilesFromConfig', configFilePath, outputDirPath)\n\n const schemaFilePath = configFilePath || path.join(dotSeedDir, 'schema.ts') // Developer created file with model definitions\n console.log('schemaFilePath', schemaFilePath)\n\n const { models, } = await getTsImport<{\n models: Record<string, ModelClassType>\n }>(schemaFilePath)\n\n const writeToDir = outputDirPath || appSchemaDir\n\n for (const [modelName, modelClass] of Object.entries(models)) {\n const code = generateDrizzleSchemaCode(modelName, modelClass)\n\n if (!fs.existsSync(writeToDir)) {\n fs.mkdirSync(writeToDir)\n }\n\n const filePath = path.join(writeToDir, `${modelName}Schema.ts`)\n\n await fs.promises.writeFile(filePath, code).catch((e) => console.error(e))\n }\n}\n\n // Helper to determine TypeScript type based on property type\n const seedTypeToJsType = (propertyType: string): string => {\n switch (propertyType) {\n case 'Text':\n return 'string';\n case 'Number':\n return 'number';\n case 'Boolean':\n return 'boolean';\n case 'Date':\n return 'string';\n case 'List':\n return 'string[]';\n case 'Relation':\n return 'string';\n case 'Image':\n return 'string';\n case 'File':\n return 'string';\n default:\n return 'any';\n }\n};\n\n\nexport const generateModelCode = (values: Record<string, any>): string => {\n const { modelName, properties } = values;\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n\n if (modelName === 'Text' || modelName === 'TestModel') {\n logger(`Model name is ${modelName}.`)\n }\n\n const njkEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatePath))\n njkEnv.addFilter('seedTypeToJsType', seedTypeToJsType)\n return njkEnv.render('model.njk', { modelName, properties })\n};\n"],"names":[],"mappings":";;;;;;;;;;AAYA,MAAM,MAAM,GAAG,KAAK,CAAC,yBAAyB,CAAC;AAG/C,MAAM,cAAc,GAAY;AAC9B,IAAA,SAAS,EAAE,CAAC,IAAY,KAAI;AAC1B,QAAA,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE;QAC/C,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE;QACnD,IAAI,gBAAgB,GAAG,YAAY;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YAC/B,gBAAgB,GAAG,IAAI;;aAClB;AACL,YAAA,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;QAEjE,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC;QAEtD,OAAO;AACL,YAAA,IAAI,EAAE,IAAI;YACV,GAAG;AACH,YAAA,OAAO,EAAE,KAAK;SACf;KACF;CACF;AAED;AACA,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC;AAEpD,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;AACrC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;AACrC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,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AAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE;IAEnD,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,WAAW,EAAE;AACrD,QAAA,MAAM,CAAC,CAAA,cAAA,EAAiB,SAAS,CAAA,CAAA,CAAG,CAAC;;AAGvC,IAAA,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACpF,IAAA,MAAM,CAAC,SAAS,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;AACtD,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAC9D;;;;"}
1
+ {"version":3,"file":"drizzle.js","sources":["../../../../../src/node/codegen/drizzle.ts"],"sourcesContent":["import path from 'path'\nimport pluralize from 'pluralize'\nimport { camelCase, snakeCase } from 'lodash-es'\nimport * as nunjucks from 'nunjucks'\nimport { ILoader } from 'nunjucks'\nimport { ModelClassType } from '@/types'\nimport { SCHEMA_NJK } from '@/helpers/constants'\nimport { getTsImport } from '@/node/helpers'\nimport fs from 'fs'\nimport {PathResolver} from '@/node/PathResolver'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:codegen:drizzle')\n\n\nconst TemplateLoader: ILoader = {\n getSource: (name: string) => {\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n let templateFilePath = templatePath\n if (name.includes(templatePath)) {\n templateFilePath = name\n } else {\n templateFilePath = path.join(templatePath, path.basename(name))\n }\n const src = fs.readFileSync(templateFilePath, 'utf-8')\n\n return {\n path: name,\n src,\n noCache: false,\n }\n },\n}\n\n// Configure Nunjucks\nconst env = new nunjucks.Environment(TemplateLoader)\n\nenv.addFilter('camelCase', camelCase)\nenv.addFilter('snakeCase', snakeCase)\nenv.addFilter('pluralize', pluralize)\n\nconst refNamesToExcludeFromRelations = [\n 'Text',\n 'Number',\n 'Boolean',\n 'Date',\n]\n\nexport const generateDrizzleSchemaCode = (\n modelName: string,\n modelClass: ModelClassType,\n): string => {\n const listProperties = Object.entries(modelClass.schema).filter(\n ([key, propertyDef]) => propertyDef?.dataType === 'List' && !refNamesToExcludeFromRelations.includes(propertyDef?.ref!),\n )\n\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n const filePath = path.join(templatePath, SCHEMA_NJK)\n\n const schemaCode = env.render(filePath, {\n modelName,\n modelClass,\n listProperties,\n })\n\n return schemaCode\n}\n\nexport const createDrizzleSchemaFilesFromConfig = async (\n configFilePath: string | undefined,\n outputDirPath: string | undefined,\n) => {\n const pathResolver = PathResolver.getInstance()\n const { dotSeedDir, appSchemaDir } = pathResolver.getAppPaths()\n console.log('createDrizzleSchemaFilesFromConfig', configFilePath, outputDirPath)\n\n // Use provided config file path or find the config file in the project root\n const schemaFilePath = configFilePath || pathResolver.findConfigFile() || path.join(dotSeedDir, 'seed.config.ts')\n console.log('schemaFilePath', schemaFilePath)\n\n const { models, } = await getTsImport<{\n models: Record<string, ModelClassType>\n }>(schemaFilePath)\n\n const writeToDir = outputDirPath || appSchemaDir\n\n for (const [modelName, modelClass] of Object.entries(models)) {\n const code = generateDrizzleSchemaCode(modelName, modelClass)\n\n if (!fs.existsSync(writeToDir)) {\n fs.mkdirSync(writeToDir)\n }\n\n const filePath = path.join(writeToDir, `${modelName}Schema.ts`)\n\n await fs.promises.writeFile(filePath, code).catch((e) => console.error(e))\n }\n}\n\n // Helper to determine TypeScript type based on property type\n const seedTypeToJsType = (propertyType: string): string => {\n switch (propertyType) {\n case 'Text':\n return 'string';\n case 'Number':\n return 'number';\n case 'Boolean':\n return 'boolean';\n case 'Date':\n return 'string';\n case 'List':\n return 'string[]';\n case 'Relation':\n return 'string';\n case 'Image':\n return 'string';\n case 'File':\n return 'string';\n default:\n return 'any';\n }\n};\n\n\nexport const generateModelCode = (values: Record<string, any>): string => {\n const { modelName, properties } = values;\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n\n if (modelName === 'Text' || modelName === 'TestModel') {\n logger(`Model name is ${modelName}.`)\n }\n\n const njkEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatePath))\n njkEnv.addFilter('seedTypeToJsType', seedTypeToJsType)\n return njkEnv.render('model.njk', { modelName, properties })\n};\n"],"names":[],"mappings":";;;;;;;;;;AAYA,MAAM,MAAM,GAAG,KAAK,CAAC,yBAAyB,CAAC;AAG/C,MAAM,cAAc,GAAY;AAC9B,IAAA,SAAS,EAAE,CAAC,IAAY,KAAI;AAC1B,QAAA,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE;QAC/C,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE;QACnD,IAAI,gBAAgB,GAAG,YAAY;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YAC/B,gBAAgB,GAAG,IAAI;;aAClB;AACL,YAAA,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;QAEjE,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC;QAEtD,OAAO;AACL,YAAA,IAAI,EAAE,IAAI;YACV,GAAG;AACH,YAAA,OAAO,EAAE,KAAK;SACf;KACF;CACF;AAED;AACA,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC;AAEpD,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;AACrC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;AACrC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;AAErC,MAAM,8BAA8B,GAAG;IACrC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;CACP;MAEY,yBAAy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AK,MAAM,IAAI,SAAS,KAAK,WAAW,EAAE;AACrD,QAAA,MAAM,CAAC,CAAA,cAAA,EAAiB,SAAS,CAAA,CAAA,CAAG,CAAC;;AAGvC,IAAA,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACpF,IAAA,MAAM,CAAC,SAAS,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;AACtD,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAC9D;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { sqliteTable, blob, text, int, check } from 'drizzle-orm/sqlite-core';
2
2
  import { sql } from 'drizzle-orm';
3
3
 
4
- sqliteTable('config', {
4
+ const config = sqliteTable('config', {
5
5
  id: int('id').primaryKey({ autoIncrement: true }),
6
6
  key: text('key').notNull(),
7
7
  text: text('text'),
@@ -12,4 +12,6 @@ sqliteTable('config', {
12
12
  check('hasValue', sql `key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),
13
13
  ],
14
14
  });
15
+
16
+ export { config };
15
17
  //# sourceMappingURL=ConfigSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigSchema.js","sources":["../../../../src/seedSchema/ConfigSchema.ts"],"sourcesContent":["import { int, sqliteTable, text, check, blob, } from 'drizzle-orm/sqlite-core'\nimport { InferSelectModel, sql } from 'drizzle-orm'\n\nexport const config = sqliteTable(\n 'config',\n {\n id: int('id').primaryKey({ autoIncrement: true }),\n key: text('key').notNull(),\n text: text('text'),\n json: text('json', {mode: 'json'}),\n blob: blob('blob', {mode: 'buffer'}),\n},\n{\n checks: [\n check('hasValue', sql`key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),\n ],\n})\n\nexport type configType = InferSelectModel<typeof config>"],"names":[],"mappings":";;;AAGsB,WAAW,CAC/B,QAAQ,EACR;AACE,IAAA,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACjD,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE;AAC1B,IAAA,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;CACvC,EACD;AACE,IAAA,MAAM,EAAE;AACN,QAAA,KAAK,CAAC,UAAU,EAAE,GAAG,CAAA,6EAA6E,CAAC;AACpG,KAAA;AACF,CAAA"}
1
+ {"version":3,"file":"ConfigSchema.js","sources":["../../../../src/seedSchema/ConfigSchema.ts"],"sourcesContent":["import { int, sqliteTable, text, check, blob, } from 'drizzle-orm/sqlite-core'\nimport { InferSelectModel, sql } from 'drizzle-orm'\n\nexport const config = sqliteTable(\n 'config',\n {\n id: int('id').primaryKey({ autoIncrement: true }),\n key: text('key').notNull(),\n text: text('text'),\n json: text('json', {mode: 'json'}),\n blob: blob('blob', {mode: 'buffer'}),\n},\n{\n checks: [\n check('hasValue', sql`key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),\n ],\n})\n\nexport type configType = InferSelectModel<typeof config>"],"names":[],"mappings":";;;AAGa,MAAA,MAAM,GAAG,WAAW,CAC/B,QAAQ,EACR;AACE,IAAA,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACjD,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE;AAC1B,IAAA,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;CACvC,EACD;AACE,IAAA,MAAM,EAAE;AACN,QAAA,KAAK,CAAC,UAAU,EAAE,GAAG,CAAA,6EAA6E,CAAC;AACpG,KAAA;AACF,CAAA;;;;"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@seedprotocol/sdk",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "The SDK for Seed Protocol",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">= 20 < 23"
7
+ "node": ">= 20 < 24"
8
8
  },
9
9
  "files": [
10
10
  "dist"