monorise 0.0.1 → 0.0.2-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/cli.js CHANGED
@@ -121,6 +121,18 @@ declare module '@monorise/base' {
121
121
  ${schemaMapEntries.join("\n ")}
122
122
  }
123
123
  }
124
+
125
+ declare module 'monorise/base' {
126
+ export enum Entity {
127
+ ${enumEntries.join(",\n ")}
128
+ }
129
+
130
+ ${typeEntries.join("\n ")}
131
+
132
+ export interface EntitySchemaMap {
133
+ ${schemaMapEntries.join("\n ")}
134
+ }
135
+ }
124
136
  `;
125
137
  fs.writeFileSync(configOutputPath, configOutputContent);
126
138
  console.log("Successfully generated config.ts!");
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport 'tsx';\nimport 'tsconfig-paths/register.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport chokidar from 'chokidar';\n\nfunction kebabToCamel(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nfunction kebabToPascal(kebab: string): string {\n return kebab\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n}\n\nasync function generateConfigFile(\n configDir: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const configOutputPath = path.join(monoriseOutputDir, 'config.ts');\n const initialConfigContent = `\nexport enum Entity {}\n`;\n fs.writeFileSync(configOutputPath, initialConfigContent);\n\n const files = fs\n .readdirSync(configDir)\n .filter((file) => file.endsWith('.ts') && file !== 'index.ts');\n\n const names = new Set<string>();\n const nameRegex = /^[a-z]+(-[a-z]+)*$/;\n const imports: string[] = [];\n\n const enumEntries: string[] = [];\n const typeEntries: string[] = [];\n const schemaMapEntries: string[] = [];\n const configEntries: string[] = [];\n const schemaEntries: string[] = [];\n const allowedEntityEntries: string[] = [];\n const entityWithEmailAuthEntries: string[] = [];\n\n const relativePathToConfigDir = path.relative(monoriseOutputDir, configDir);\n const importPathPrefix = relativePathToConfigDir\n ? `${relativePathToConfigDir}/`\n : './';\n\n for (const file of files) {\n const fullPath = path.join(configDir, file);\n const module = await import(fullPath);\n const config = module.default;\n\n if (!nameRegex.test(config.name)) {\n throw new Error(\n `Invalid name format: ${config.name} in ${file}. Must be kebab-case.`,\n );\n }\n\n if (names.has(config.name)) {\n throw new Error(`Duplicate name found: ${config.name} in ${file}`);\n }\n names.add(config.name);\n\n const fileName = file.replace(/\\.ts$/, '');\n const variableName = kebabToCamel(fileName);\n imports.push(\n `import ${variableName} from '${importPathPrefix}${fileName}';`,\n );\n\n const enumKey = config.name.toUpperCase().replace(/-/g, '_');\n enumEntries.push(`${enumKey} = '${config.name}'`);\n typeEntries.push(\n `export type ${kebabToPascal(config.name)}Type = z.infer<(typeof ${variableName})['finalSchema']>;`,\n );\n schemaMapEntries.push(\n `[Entity.${enumKey}]: ${kebabToPascal(config.name)}Type;`,\n );\n\n configEntries.push(`[Entity.${enumKey}]: ${kebabToCamel(config.name)},`);\n schemaEntries.push(\n `[Entity.${enumKey}]: ${kebabToCamel(config.name)}.finalSchema,`,\n );\n\n allowedEntityEntries.push(`Entity.${enumKey}`);\n\n if (config.authMethod?.email) {\n entityWithEmailAuthEntries.push(`Entity.${enumKey}`);\n }\n }\n\n const configOutputContent = `\nimport type { z } from 'zod';\n${imports.join('\\n')}\n\nexport enum Entity {\n ${enumEntries.join(',\\n ')}\n}\n\n${typeEntries.join('\\n')}\n\nexport interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n}\n\nconst EntityConfig = {\n ${configEntries.join('\\n ')}\n};\n\nconst FormSchema = {\n ${schemaEntries.join('\\n ')}\n};\n\nconst AllowedEntityTypes = [\n ${allowedEntityEntries.join(',\\n ')}\n];\n\nconst EmailAuthEnabledEntities: Entity[] = [${entityWithEmailAuthEntries.join(', ')}];\n\nexport {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nconst config = {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nexport default config;\n\ndeclare module '@monorise/base' {\n export enum Entity {\n ${enumEntries.join(',\\n ')}\n }\n\n ${typeEntries.join('\\n ')}\n\n export interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n }\n}\n`;\n\n fs.writeFileSync(configOutputPath, configOutputContent);\n console.log('Successfully generated config.ts!');\n return configOutputPath;\n}\n\nasync function generateHandleFile(\n monoriseConfig: { customRoutes?: string; configDir: string },\n projectRoot: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const handleOutputPath = path.join(monoriseOutputDir, 'handle.ts');\n const customRoutesPath = monoriseConfig.customRoutes;\n\n let routesImportLine = '';\n let appHandlerPayload = '{}'; // Default to an empty object for appHandler if no custom routes\n\n if (customRoutesPath) {\n const absoluteCustomRoutesPath = path.resolve(\n projectRoot,\n customRoutesPath,\n );\n\n if (\n !fs.existsSync(absoluteCustomRoutesPath) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.ts`) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.js`)\n ) {\n throw new Error(\n `Custom routes file not found: '${absoluteCustomRoutesPath}'. Please ensure 'customRoutes' in monorise.config.ts points to a valid file.`,\n );\n }\n\n let routesModule;\n try {\n routesModule = await import(absoluteCustomRoutesPath);\n } catch (e: any) {\n throw new Error(\n `Failed to load custom routes file at '${absoluteCustomRoutesPath}'. Ensure it's a valid JavaScript/TypeScript module. Error: ${e.message}`,\n );\n }\n\n const routesExport = routesModule.default;\n\n if (\n !routesExport ||\n routesExport === null ||\n (typeof routesExport === 'object' &&\n !(\n 'get' in routesExport &&\n 'post' in routesExport &&\n 'use' in routesExport\n ))\n ) {\n throw new Error(\n `Custom routes file at '${absoluteCustomRoutesPath}' must default export an instance of Hono (or an object with .get, .post, .use methods). Or a function that consume the dependency container provided by route handler.`,\n );\n }\n\n let relativePathToRoutes = path.relative(\n monoriseOutputDir,\n absoluteCustomRoutesPath,\n );\n relativePathToRoutes = relativePathToRoutes.replace(\n /\\.(ts|js|mjs|cjs)$/,\n '',\n );\n\n // If custom routes are provided, include the import statement and pass 'routes' to appHandler\n routesImportLine = `import routes from '${relativePathToRoutes}';`;\n appHandlerPayload = '{ routes }';\n }\n // If customRoutesPath is not provided, routesImportLine remains empty and appHandlerPayload remains `{}`\n\n const combinedContent = `\nimport CoreFactory from 'monorise/core';\nimport config from './config';\n${routesImportLine ? `${routesImportLine}\\n` : ''}const coreFactory = new CoreFactory(config);\n\nexport const replicationHandler = coreFactory.replicationProcessor;\nexport const mutualHandler = coreFactory.mutualProcessor;\nexport const tagHandler = coreFactory.tagProcessor;\nexport const treeHandler = coreFactory.prejoinProcessor;\nexport const appHandler = coreFactory.appHandler(${appHandlerPayload});\n`;\n fs.writeFileSync(handleOutputPath, combinedContent);\n console.log('Successfully generated handle.ts!');\n\n return handleOutputPath;\n}\n\nasync function generateFiles(rootPath?: string): Promise<string> {\n const baseDir = rootPath ? path.resolve(rootPath) : process.cwd();\n const configFilePathTS = path.join(baseDir, 'monorise.config.ts');\n const configFilePathJS = path.join(baseDir, 'monorise.config.js');\n\n let configFilePath: string;\n if (fs.existsSync(configFilePathTS)) {\n configFilePath = configFilePathTS;\n } else if (fs.existsSync(configFilePathJS)) {\n configFilePath = configFilePathJS;\n } else {\n throw new Error(\n 'Neither monorise.config.ts nor monorise.config.js found in the root of the project.',\n );\n }\n\n const projectRoot = path.dirname(configFilePath);\n const monoriseConfigModule = await import(configFilePath);\n const monoriseConfig = monoriseConfigModule.default;\n\n const configDir = path.resolve(projectRoot, monoriseConfig.configDir);\n const monoriseOutputDir = path.join(projectRoot, '.monorise');\n\n fs.mkdirSync(monoriseOutputDir, { recursive: true });\n\n await generateConfigFile(configDir, monoriseOutputDir);\n await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);\n\n return configDir;\n}\n\nconst MONORISE_LOGO = `\n\n\n\n ░░░░░░░\n ░░▒▒▒░░░░░░▒▒▒░\n ░▒▒░ ░▒▒░\n ░▒▒░ ░▒▒░\n ░▒░ ░▒▒░\n ░▒▒░ ▒▒▒░\n ░▒░░░▒░ ░▒░░▒▒░\n ░▒▒░ ░▒▒▒░ ░▒▒░ ░▒░░\n ░▒▒ ░▒▒░ ░▒▒░ ░▒░ ░▒░ ░▒░\n ░▒▒░ ░▒░ ░▒░░▒▒░░░ ░░▒▒░░▒░ ░▒▒ ░▒░\n ░░▒░ ░▒░ ░▒░ ░▒▒░░▒▒▒▒▒▒░░▒░ ░▒░░ ░▒░ ░▒░\n ░▒░ ░░▒░ ░▒░ ░░░ ░▒░ ░░ ░▒░ ░▒░ ░▒░░ ░░▒░\n ░▒░ ░▒░ ░▒░ ░▒ ░░ ░▒░ ░▒░ ░▒░ ░▒░ ░░░░\n ░░░ ░░░░ ░░░ ░░ ▒░ ░░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░ ░░░ ░░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░░ ░░░░ ░░░ ░░░ ░░ ░░░ ░░ ░░░ ░░░ ░░░\n ░░ ░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░ ░░ ░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░░ ░░░\n ░░░ ░░ ░░░ ░░░ ░░░\n ░░░░░▒░░░░░░░░░▒░░░░░░░░░ ░ ░░ ░░░ ░░░ ░░\n ░░░ ░░░░░░░░░ ░░░ ░░░\n ░░░ ░░░░░░ ░░ ░░░░░▒░░░░░░▒░░░░\n ░░░░░░░░░░░░░░░░░ ░░░░░ ░░░░░░░░ ░░\n ░░░░░░░ ░░░░░░░░░░░░░░ ░░░░ ░░░░░ ░▒░\n ░░░ ░░░░░░░ ░░░░░░ ░░░░░░░░\n ░░░░░░░░░░░░ ░░░░░░ ░░░░ ░░░░░░░░░░░░░\n ░▒▒░░░░░░░░░░░▒▒░░ ░░▒▒▒░░ ░▒▒░░ ░░░░\n ░▒░ ░░▒▒░ ░▒░ ░▒▒░ ░░▒░\n ░▒░ ░░░░▒▒▒▒▒▒▒▒▒▒░░ ░▒░ ▒▒░ ░░▒▒▒░\n ░▒▒▒▒▒░░░ ░░░▒▒▒▒▒░ ▒▒░ ░▒▒▒▒▒▒░\n ░▒▒░ ░▒▒▒▒ ▒▒▒ ▒▒▒\n ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░▒▒▒▒▒░ ░▒▒\n ▒▒▒ ░░▒▒▒▒▒▒░ ▒▒▒ ░▒▒\n ▒▒▒ ░▒▒▒▒ ░▒▒▒░\n ▒▓▓▓▒▒▒▓▓▒▒▒░ ▒▒▒░░▒▒░\n ▒▓░ ░▒▒▓▓▒░ ▒▓▓░\n ░▒▓░ ░▒▓▒░▒▓▒\n ░▒▓▒░ ░▒▓▓▒\n ░▒▒▓▓▓▓▓▓▒▒░\n\n\n\n`;\n\nasync function runInitCommand(rootPath?: string) {\n const projectRoot = rootPath ? path.resolve(rootPath) : process.cwd();\n console.log(MONORISE_LOGO);\n console.log(`Initializing Monorise project in ${projectRoot}...`);\n\n // 1. Create monorise.config.ts\n const monoriseConfigTsPath = path.join(projectRoot, 'monorise.config.ts');\n const monoriseConfigContent = `\nconst config = {\n configDir: './monorise/entities',\n // custom route file should export default an Hono object.\n // customRoutes: './path/to/custom/routes.ts'\n};\n\nexport default config;\n`;\n if (!fs.existsSync(monoriseConfigTsPath)) {\n fs.writeFileSync(monoriseConfigTsPath, monoriseConfigContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, monoriseConfigTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, monoriseConfigTsPath)} already exists. Skipping.`,\n );\n }\n\n // 2. Create ./monorise/entities/user.ts\n const monoriseEntitiesDir = path.join(projectRoot, 'monorise', 'entities');\n fs.mkdirSync(monoriseEntitiesDir, { recursive: true });\n\n const userEntityTsPath = path.join(monoriseEntitiesDir, 'user.ts');\n const userEntityContent = `\nimport { createEntityConfig } from 'monorise/base';\nimport { z } from 'zod';\n\nconst baseSchema = z\n .object({\n displayName: z\n .string()\n .min(1, 'Please provide a name for this user account'),\n firstName: z.string().min(1, 'Please provide first name'),\n lastName: z.string().min(1, 'Please provide last name'),\n jobTitle: z.string(),\n })\n .partial();\n\nconst config = createEntityConfig({\n name: 'user',\n baseSchema,\n});\n\nexport default config;\n`;\n if (!fs.existsSync(userEntityTsPath)) {\n fs.writeFileSync(userEntityTsPath, userEntityContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, userEntityTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, userEntityTsPath)} already exists. Skipping.`,\n );\n }\n\n // 3. Update package.json\n const packageJsonPath = path.join(projectRoot, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent);\n\n if (packageJson.type !== 'module') {\n packageJson.type = 'module';\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n console.log(\n `Updated 'type' to 'module' in ${path.relative(projectRoot, packageJsonPath)}`,\n );\n } else {\n console.log(\n `'type: \"module\"' already set in ${path.relative(projectRoot, packageJsonPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error reading or parsing ${path.relative(projectRoot, packageJsonPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, packageJsonPath)} not found. Cannot update 'type'.`,\n );\n }\n\n // 4. Add tsconfig path alias for .monorise directory\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n if (fs.existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n const pathKey = '#/monorise/*';\n const pathValue = ['./.monorise/*'];\n\n if (!tsconfig.compilerOptions.paths[pathKey]) {\n tsconfig.compilerOptions.paths[pathKey] = pathValue;\n fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));\n console.log(\n `Added '${pathKey}' path alias in ${path.relative(projectRoot, tsconfigPath)}`,\n );\n } else {\n console.log(\n `'${pathKey}' path alias already set in ${path.relative(projectRoot, tsconfigPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error updating ${path.relative(projectRoot, tsconfigPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, tsconfigPath)} not found. Cannot add path alias.`,\n );\n }\n\n console.log('Monorise initialization complete!');\n}\n\nasync function runDevCommand(configDir: string, rootPath?: string) {\n console.log(MONORISE_LOGO);\n console.log(`Watching for changes in ${configDir}...`);\n const watcher = chokidar.watch(configDir, {\n ignored: (watchedPath: string) => {\n const fileName = path.basename(watchedPath);\n return (\n fileName === 'index.ts' || // Old name, still ignore in case it exists\n fileName === 'config.ts' || // Generated config file\n fileName === 'processors.ts' || // Generated processors file\n fileName === 'app.ts' || // Generated app file\n fileName.startsWith('.') ||\n watchedPath.endsWith('.js') ||\n watchedPath.endsWith('.jsx') ||\n watchedPath.endsWith('.d.ts')\n );\n },\n persistent: true,\n ignoreInitial: true,\n });\n\n watcher.on('add', async (filePath) => {\n console.log(`File ${filePath} has been added. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('change', async (filePath) => {\n console.log(`File ${filePath} has been changed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('unlink', async (filePath) => {\n console.log(`File ${filePath} has been removed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n process.on('SIGINT', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n process.on('SIGTERM', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n}\n\nasync function runBuildCommand(rootPath?: string) {\n console.log('Starting sst build...');\n await generateFiles(rootPath);\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n const command = args[0];\n\n let rootPath: string | undefined;\n const rootFlagIndex = args.indexOf('--config-root');\n if (rootFlagIndex > -1 && args[rootFlagIndex + 1]) {\n rootPath = args[rootFlagIndex + 1];\n }\n\n try {\n if (command === 'dev') {\n const configDir = await generateFiles(rootPath);\n await runDevCommand(configDir, rootPath);\n } else if (command === 'build') {\n await runBuildCommand(rootPath);\n } else if (command === 'init') {\n await runInitCommand(rootPath);\n } else {\n console.error(\n 'Unknown command. Usage: monorise [dev|build|init] [--config-root <path>]',\n );\n process.exit(1);\n }\n } catch (err) {\n console.error('Monorise process failed:', err);\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('Monorise encountered an unhandled error:', err);\n process.exit(1);\n});\n"],"mappings":";;;AAEA,OAAO;AACP,OAAO;AACP,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAErB,SAAS,aAAa,KAAqB;AACzC,SAAO,IAAI,QAAQ,aAAa,CAAC,GAAG,WAAW,OAAO,YAAY,CAAC;AACrE;AAEA,SAAS,cAAc,OAAuB;AAC5C,SAAO,MACJ,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;AACZ;AAEA,eAAe,mBACb,WACA,mBACiB;AACjB,QAAM,mBAAmB,KAAK,KAAK,mBAAmB,WAAW;AACjE,QAAM,uBAAuB;AAAA;AAAA;AAG7B,KAAG,cAAc,kBAAkB,oBAAoB;AAEvD,QAAM,QAAQ,GACX,YAAY,SAAS,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AAmB;AAChD,UAAQ,IAAI,uBAAuB;AACnC,QAAM,cAAc,QAAQ;AAC9B;AAEA,eAAe,OAAO;AACpB,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,UAAU,KAAK,CAAC;AAEtB,MAAI;AACJ,QAAM,gBAAgB,KAAK,QAAQ,eAAe;AAClD,MAAI,gBAAgB,MAAM,KAAK,gBAAgB,CAAC,GAAG;AACjD,eAAW,KAAK,gBAAgB,CAAC;AAAA,EACnC;AAEA,MAAI;AACF,QAAI,YAAY,OAAO;AACrB,YAAM,YAAY,MAAM,cAAc,QAAQ;AAC9C,YAAM,cAAc,WAAW,QAAQ;AAAA,IACzC,WAAW,YAAY,SAAS;AAC9B,YAAM,gBAAgB,QAAQ;AAAA,IAChC,WAAW,YAAY,QAAQ;AAC7B,YAAM,eAAe,QAAQ;AAAA,IAC/B,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,4BAA4B,GAAG;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,4CAA4C,GAAG;AAC7D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport 'tsx';\nimport 'tsconfig-paths/register.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport chokidar from 'chokidar';\n\nfunction kebabToCamel(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nfunction kebabToPascal(kebab: string): string {\n return kebab\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n}\n\nasync function generateConfigFile(\n configDir: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const configOutputPath = path.join(monoriseOutputDir, 'config.ts');\n const initialConfigContent = `\nexport enum Entity {}\n`;\n fs.writeFileSync(configOutputPath, initialConfigContent);\n\n const files = fs\n .readdirSync(configDir)\n .filter((file) => file.endsWith('.ts') && file !== 'index.ts');\n\n const names = new Set<string>();\n const nameRegex = /^[a-z]+(-[a-z]+)*$/;\n const imports: string[] = [];\n\n const enumEntries: string[] = [];\n const typeEntries: string[] = [];\n const schemaMapEntries: string[] = [];\n const configEntries: string[] = [];\n const schemaEntries: string[] = [];\n const allowedEntityEntries: string[] = [];\n const entityWithEmailAuthEntries: string[] = [];\n\n const relativePathToConfigDir = path.relative(monoriseOutputDir, configDir);\n const importPathPrefix = relativePathToConfigDir\n ? `${relativePathToConfigDir}/`\n : './';\n\n for (const file of files) {\n const fullPath = path.join(configDir, file);\n const module = await import(fullPath);\n const config = module.default;\n\n if (!nameRegex.test(config.name)) {\n throw new Error(\n `Invalid name format: ${config.name} in ${file}. Must be kebab-case.`,\n );\n }\n\n if (names.has(config.name)) {\n throw new Error(`Duplicate name found: ${config.name} in ${file}`);\n }\n names.add(config.name);\n\n const fileName = file.replace(/\\.ts$/, '');\n const variableName = kebabToCamel(fileName);\n imports.push(\n `import ${variableName} from '${importPathPrefix}${fileName}';`,\n );\n\n const enumKey = config.name.toUpperCase().replace(/-/g, '_');\n enumEntries.push(`${enumKey} = '${config.name}'`);\n typeEntries.push(\n `export type ${kebabToPascal(config.name)}Type = z.infer<(typeof ${variableName})['finalSchema']>;`,\n );\n schemaMapEntries.push(\n `[Entity.${enumKey}]: ${kebabToPascal(config.name)}Type;`,\n );\n\n configEntries.push(`[Entity.${enumKey}]: ${kebabToCamel(config.name)},`);\n schemaEntries.push(\n `[Entity.${enumKey}]: ${kebabToCamel(config.name)}.finalSchema,`,\n );\n\n allowedEntityEntries.push(`Entity.${enumKey}`);\n\n if (config.authMethod?.email) {\n entityWithEmailAuthEntries.push(`Entity.${enumKey}`);\n }\n }\n\n const configOutputContent = `\nimport type { z } from 'zod';\n${imports.join('\\n')}\n\nexport enum Entity {\n ${enumEntries.join(',\\n ')}\n}\n\n${typeEntries.join('\\n')}\n\nexport interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n}\n\nconst EntityConfig = {\n ${configEntries.join('\\n ')}\n};\n\nconst FormSchema = {\n ${schemaEntries.join('\\n ')}\n};\n\nconst AllowedEntityTypes = [\n ${allowedEntityEntries.join(',\\n ')}\n];\n\nconst EmailAuthEnabledEntities: Entity[] = [${entityWithEmailAuthEntries.join(', ')}];\n\nexport {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nconst config = {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nexport default config;\n\ndeclare module '@monorise/base' {\n export enum Entity {\n ${enumEntries.join(',\\n ')}\n }\n\n ${typeEntries.join('\\n ')}\n\n export interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n }\n}\n\ndeclare module 'monorise/base' {\n export enum Entity {\n ${enumEntries.join(',\\n ')}\n }\n\n ${typeEntries.join('\\n ')}\n\n export interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n }\n}\n`;\n\n fs.writeFileSync(configOutputPath, configOutputContent);\n console.log('Successfully generated config.ts!');\n return configOutputPath;\n}\n\nasync function generateHandleFile(\n monoriseConfig: { customRoutes?: string; configDir: string },\n projectRoot: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const handleOutputPath = path.join(monoriseOutputDir, 'handle.ts');\n const customRoutesPath = monoriseConfig.customRoutes;\n\n let routesImportLine = '';\n let appHandlerPayload = '{}'; // Default to an empty object for appHandler if no custom routes\n\n if (customRoutesPath) {\n const absoluteCustomRoutesPath = path.resolve(\n projectRoot,\n customRoutesPath,\n );\n\n if (\n !fs.existsSync(absoluteCustomRoutesPath) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.ts`) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.js`)\n ) {\n throw new Error(\n `Custom routes file not found: '${absoluteCustomRoutesPath}'. Please ensure 'customRoutes' in monorise.config.ts points to a valid file.`,\n );\n }\n\n let routesModule;\n try {\n routesModule = await import(absoluteCustomRoutesPath);\n } catch (e: any) {\n throw new Error(\n `Failed to load custom routes file at '${absoluteCustomRoutesPath}'. Ensure it's a valid JavaScript/TypeScript module. Error: ${e.message}`,\n );\n }\n\n const routesExport = routesModule.default;\n\n if (\n !routesExport ||\n routesExport === null ||\n (typeof routesExport === 'object' &&\n !(\n 'get' in routesExport &&\n 'post' in routesExport &&\n 'use' in routesExport\n ))\n ) {\n throw new Error(\n `Custom routes file at '${absoluteCustomRoutesPath}' must default export an instance of Hono (or an object with .get, .post, .use methods). Or a function that consume the dependency container provided by route handler.`,\n );\n }\n\n let relativePathToRoutes = path.relative(\n monoriseOutputDir,\n absoluteCustomRoutesPath,\n );\n relativePathToRoutes = relativePathToRoutes.replace(\n /\\.(ts|js|mjs|cjs)$/,\n '',\n );\n\n // If custom routes are provided, include the import statement and pass 'routes' to appHandler\n routesImportLine = `import routes from '${relativePathToRoutes}';`;\n appHandlerPayload = '{ routes }';\n }\n // If customRoutesPath is not provided, routesImportLine remains empty and appHandlerPayload remains `{}`\n\n const combinedContent = `\nimport CoreFactory from 'monorise/core';\nimport config from './config';\n${routesImportLine ? `${routesImportLine}\\n` : ''}const coreFactory = new CoreFactory(config);\n\nexport const replicationHandler = coreFactory.replicationProcessor;\nexport const mutualHandler = coreFactory.mutualProcessor;\nexport const tagHandler = coreFactory.tagProcessor;\nexport const treeHandler = coreFactory.prejoinProcessor;\nexport const appHandler = coreFactory.appHandler(${appHandlerPayload});\n`;\n fs.writeFileSync(handleOutputPath, combinedContent);\n console.log('Successfully generated handle.ts!');\n\n return handleOutputPath;\n}\n\nasync function generateFiles(rootPath?: string): Promise<string> {\n const baseDir = rootPath ? path.resolve(rootPath) : process.cwd();\n const configFilePathTS = path.join(baseDir, 'monorise.config.ts');\n const configFilePathJS = path.join(baseDir, 'monorise.config.js');\n\n let configFilePath: string;\n if (fs.existsSync(configFilePathTS)) {\n configFilePath = configFilePathTS;\n } else if (fs.existsSync(configFilePathJS)) {\n configFilePath = configFilePathJS;\n } else {\n throw new Error(\n 'Neither monorise.config.ts nor monorise.config.js found in the root of the project.',\n );\n }\n\n const projectRoot = path.dirname(configFilePath);\n const monoriseConfigModule = await import(configFilePath);\n const monoriseConfig = monoriseConfigModule.default;\n\n const configDir = path.resolve(projectRoot, monoriseConfig.configDir);\n const monoriseOutputDir = path.join(projectRoot, '.monorise');\n\n fs.mkdirSync(monoriseOutputDir, { recursive: true });\n\n await generateConfigFile(configDir, monoriseOutputDir);\n await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);\n\n return configDir;\n}\n\nconst MONORISE_LOGO = `\n\n\n\n ░░░░░░░\n ░░▒▒▒░░░░░░▒▒▒░\n ░▒▒░ ░▒▒░\n ░▒▒░ ░▒▒░\n ░▒░ ░▒▒░\n ░▒▒░ ▒▒▒░\n ░▒░░░▒░ ░▒░░▒▒░\n ░▒▒░ ░▒▒▒░ ░▒▒░ ░▒░░\n ░▒▒ ░▒▒░ ░▒▒░ ░▒░ ░▒░ ░▒░\n ░▒▒░ ░▒░ ░▒░░▒▒░░░ ░░▒▒░░▒░ ░▒▒ ░▒░\n ░░▒░ ░▒░ ░▒░ ░▒▒░░▒▒▒▒▒▒░░▒░ ░▒░░ ░▒░ ░▒░\n ░▒░ ░░▒░ ░▒░ ░░░ ░▒░ ░░ ░▒░ ░▒░ ░▒░░ ░░▒░\n ░▒░ ░▒░ ░▒░ ░▒ ░░ ░▒░ ░▒░ ░▒░ ░▒░ ░░░░\n ░░░ ░░░░ ░░░ ░░ ▒░ ░░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░ ░░░ ░░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░░ ░░░░ ░░░ ░░░ ░░ ░░░ ░░ ░░░ ░░░ ░░░\n ░░ ░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░ ░░ ░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░░ ░░░\n ░░░ ░░ ░░░ ░░░ ░░░\n ░░░░░▒░░░░░░░░░▒░░░░░░░░░ ░ ░░ ░░░ ░░░ ░░\n ░░░ ░░░░░░░░░ ░░░ ░░░\n ░░░ ░░░░░░ ░░ ░░░░░▒░░░░░░▒░░░░\n ░░░░░░░░░░░░░░░░░ ░░░░░ ░░░░░░░░ ░░\n ░░░░░░░ ░░░░░░░░░░░░░░ ░░░░ ░░░░░ ░▒░\n ░░░ ░░░░░░░ ░░░░░░ ░░░░░░░░\n ░░░░░░░░░░░░ ░░░░░░ ░░░░ ░░░░░░░░░░░░░\n ░▒▒░░░░░░░░░░░▒▒░░ ░░▒▒▒░░ ░▒▒░░ ░░░░\n ░▒░ ░░▒▒░ ░▒░ ░▒▒░ ░░▒░\n ░▒░ ░░░░▒▒▒▒▒▒▒▒▒▒░░ ░▒░ ▒▒░ ░░▒▒▒░\n ░▒▒▒▒▒░░░ ░░░▒▒▒▒▒░ ▒▒░ ░▒▒▒▒▒▒░\n ░▒▒░ ░▒▒▒▒ ▒▒▒ ▒▒▒\n ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░▒▒▒▒▒░ ░▒▒\n ▒▒▒ ░░▒▒▒▒▒▒░ ▒▒▒ ░▒▒\n ▒▒▒ ░▒▒▒▒ ░▒▒▒░\n ▒▓▓▓▒▒▒▓▓▒▒▒░ ▒▒▒░░▒▒░\n ▒▓░ ░▒▒▓▓▒░ ▒▓▓░\n ░▒▓░ ░▒▓▒░▒▓▒\n ░▒▓▒░ ░▒▓▓▒\n ░▒▒▓▓▓▓▓▓▒▒░\n\n\n\n`;\n\nasync function runInitCommand(rootPath?: string) {\n const projectRoot = rootPath ? path.resolve(rootPath) : process.cwd();\n console.log(MONORISE_LOGO);\n console.log(`Initializing Monorise project in ${projectRoot}...`);\n\n // 1. Create monorise.config.ts\n const monoriseConfigTsPath = path.join(projectRoot, 'monorise.config.ts');\n const monoriseConfigContent = `\nconst config = {\n configDir: './monorise/entities',\n // custom route file should export default an Hono object.\n // customRoutes: './path/to/custom/routes.ts'\n};\n\nexport default config;\n`;\n if (!fs.existsSync(monoriseConfigTsPath)) {\n fs.writeFileSync(monoriseConfigTsPath, monoriseConfigContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, monoriseConfigTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, monoriseConfigTsPath)} already exists. Skipping.`,\n );\n }\n\n // 2. Create ./monorise/entities/user.ts\n const monoriseEntitiesDir = path.join(projectRoot, 'monorise', 'entities');\n fs.mkdirSync(monoriseEntitiesDir, { recursive: true });\n\n const userEntityTsPath = path.join(monoriseEntitiesDir, 'user.ts');\n const userEntityContent = `\nimport { createEntityConfig } from 'monorise/base';\nimport { z } from 'zod';\n\nconst baseSchema = z\n .object({\n displayName: z\n .string()\n .min(1, 'Please provide a name for this user account'),\n firstName: z.string().min(1, 'Please provide first name'),\n lastName: z.string().min(1, 'Please provide last name'),\n jobTitle: z.string(),\n })\n .partial();\n\nconst config = createEntityConfig({\n name: 'user',\n baseSchema,\n});\n\nexport default config;\n`;\n if (!fs.existsSync(userEntityTsPath)) {\n fs.writeFileSync(userEntityTsPath, userEntityContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, userEntityTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, userEntityTsPath)} already exists. Skipping.`,\n );\n }\n\n // 3. Update package.json\n const packageJsonPath = path.join(projectRoot, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent);\n\n if (packageJson.type !== 'module') {\n packageJson.type = 'module';\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n console.log(\n `Updated 'type' to 'module' in ${path.relative(projectRoot, packageJsonPath)}`,\n );\n } else {\n console.log(\n `'type: \"module\"' already set in ${path.relative(projectRoot, packageJsonPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error reading or parsing ${path.relative(projectRoot, packageJsonPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, packageJsonPath)} not found. Cannot update 'type'.`,\n );\n }\n\n // 4. Add tsconfig path alias for .monorise directory\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n if (fs.existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n const pathKey = '#/monorise/*';\n const pathValue = ['./.monorise/*'];\n\n if (!tsconfig.compilerOptions.paths[pathKey]) {\n tsconfig.compilerOptions.paths[pathKey] = pathValue;\n fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));\n console.log(\n `Added '${pathKey}' path alias in ${path.relative(projectRoot, tsconfigPath)}`,\n );\n } else {\n console.log(\n `'${pathKey}' path alias already set in ${path.relative(projectRoot, tsconfigPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error updating ${path.relative(projectRoot, tsconfigPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, tsconfigPath)} not found. Cannot add path alias.`,\n );\n }\n\n console.log('Monorise initialization complete!');\n}\n\nasync function runDevCommand(configDir: string, rootPath?: string) {\n console.log(MONORISE_LOGO);\n console.log(`Watching for changes in ${configDir}...`);\n const watcher = chokidar.watch(configDir, {\n ignored: (watchedPath: string) => {\n const fileName = path.basename(watchedPath);\n return (\n fileName === 'index.ts' || // Old name, still ignore in case it exists\n fileName === 'config.ts' || // Generated config file\n fileName === 'processors.ts' || // Generated processors file\n fileName === 'app.ts' || // Generated app file\n fileName.startsWith('.') ||\n watchedPath.endsWith('.js') ||\n watchedPath.endsWith('.jsx') ||\n watchedPath.endsWith('.d.ts')\n );\n },\n persistent: true,\n ignoreInitial: true,\n });\n\n watcher.on('add', async (filePath) => {\n console.log(`File ${filePath} has been added. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('change', async (filePath) => {\n console.log(`File ${filePath} has been changed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('unlink', async (filePath) => {\n console.log(`File ${filePath} has been removed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n process.on('SIGINT', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n process.on('SIGTERM', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n}\n\nasync function runBuildCommand(rootPath?: string) {\n console.log('Starting sst build...');\n await generateFiles(rootPath);\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n const command = args[0];\n\n let rootPath: string | undefined;\n const rootFlagIndex = args.indexOf('--config-root');\n if (rootFlagIndex > -1 && args[rootFlagIndex + 1]) {\n rootPath = args[rootFlagIndex + 1];\n }\n\n try {\n if (command === 'dev') {\n const configDir = await generateFiles(rootPath);\n await runDevCommand(configDir, rootPath);\n } else if (command === 'build') {\n await runBuildCommand(rootPath);\n } else if (command === 'init') {\n await runInitCommand(rootPath);\n } else {\n console.error(\n 'Unknown command. Usage: monorise [dev|build|init] [--config-root <path>]',\n );\n process.exit(1);\n }\n } catch (err) {\n console.error('Monorise process failed:', err);\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('Monorise encountered an unhandled error:', err);\n process.exit(1);\n});\n"],"mappings":";;;AAEA,OAAO;AACP,O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;AAAA,QACN;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,4BAA4B,GAAG;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,4CAA4C,GAAG;AAC7D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
@@ -7676,7 +7676,7 @@ var ListTagsController = class {
7676
7676
  const results = yield this.tagRepository.listTags({
7677
7677
  entityType,
7678
7678
  tagName,
7679
- limit: Number(limit),
7679
+ limit: limit ? Number(limit) : void 0,
7680
7680
  options: {
7681
7681
  lastKey
7682
7682
  },