@bairock/lenz 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -4
- package/dist/cli/commands/generate.js +36 -75
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/init.js +22 -28
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/studio.js +15 -21
- package/dist/cli/commands/studio.js.map +1 -1
- package/dist/cli/index.js +13 -18
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.js +7 -12
- package/dist/config/index.js.map +1 -1
- package/dist/engine/CodeGenerator.d.ts +2 -1
- package/dist/engine/CodeGenerator.d.ts.map +1 -1
- package/dist/engine/CodeGenerator.js +78 -43
- package/dist/engine/CodeGenerator.js.map +1 -1
- package/dist/engine/GraphQLParser.d.ts +2 -0
- package/dist/engine/GraphQLParser.d.ts.map +1 -1
- package/dist/engine/GraphQLParser.js +19 -16
- package/dist/engine/GraphQLParser.js.map +1 -1
- package/dist/engine/LenzEngine.d.ts +3 -3
- package/dist/engine/LenzEngine.js +32 -39
- package/dist/engine/LenzEngine.js.map +1 -1
- package/dist/engine/SchemaValidator.d.ts +1 -1
- package/dist/engine/SchemaValidator.d.ts.map +1 -1
- package/dist/engine/SchemaValidator.js +44 -32
- package/dist/engine/SchemaValidator.js.map +1 -1
- package/dist/engine/directives.d.ts.map +1 -1
- package/dist/engine/directives.js +44 -45
- package/dist/engine/directives.js.map +1 -1
- package/dist/engine/index.d.ts +3 -3
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +3 -9
- package/dist/engine/index.js.map +1 -1
- package/dist/errors/index.js +14 -31
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -489,9 +489,6 @@ import { defineConfig } from 'lenz/config'
|
|
|
489
489
|
|
|
490
490
|
export default defineConfig({
|
|
491
491
|
schema: 'schema.graphql',
|
|
492
|
-
migrations: {
|
|
493
|
-
path: 'migrations',
|
|
494
|
-
},
|
|
495
492
|
datasource: {
|
|
496
493
|
url: process.env.MONGODB_URI,
|
|
497
494
|
database: process.env.MONGODB_DATABASE || 'myapp',
|
|
@@ -543,7 +540,7 @@ Lenz extends GraphQL with custom directives:
|
|
|
543
540
|
- `@unique` - Creates a unique index
|
|
544
541
|
- `@index` - Creates a regular index
|
|
545
542
|
- `@default(value: "...")` - Sets default value
|
|
546
|
-
- `@relation(field: "...", strategy: "populate|lookup", index: true|false)` - Defines relation with loading strategy and
|
|
543
|
+
- `@relation(field: "...", strategy: "populate|lookup", index: true|false, onDelete: "NoAction|Cascade|SetNull")` - Defines relation with loading strategy, index control, and cascade delete behavior (default: `NoAction`)
|
|
547
544
|
- `@createdAt` - Auto-sets creation timestamp
|
|
548
545
|
- `@updatedAt` - Auto-updates timestamp
|
|
549
546
|
- `@embedded` - Marks a type as embedded document
|
|
@@ -762,6 +759,36 @@ type Category @model {
|
|
|
762
759
|
}
|
|
763
760
|
```
|
|
764
761
|
|
|
762
|
+
### Cascade Delete Behavior (`onDelete`)
|
|
763
|
+
|
|
764
|
+
Lenz supports cascade delete operations on relations. By default, **no cascade is performed** (`onDelete: "NoAction"`) for performance and safety. You must explicitly opt in.
|
|
765
|
+
|
|
766
|
+
| Value | Behavior |
|
|
767
|
+
|-------|----------|
|
|
768
|
+
| `NoAction` (default) | No cascade. Deleted document's related references become orphaned. |
|
|
769
|
+
| `Cascade` | When a document is deleted, all related documents are also deleted. |
|
|
770
|
+
| `SetNull` | When a document is deleted, foreign key fields in related documents are set to `null` (only for nullable FK fields). |
|
|
771
|
+
|
|
772
|
+
**Important:** Cascade operations negatively impact write performance because each delete triggers additional queries. Use only when necessary.
|
|
773
|
+
|
|
774
|
+
Examples:
|
|
775
|
+
|
|
776
|
+
```graphql
|
|
777
|
+
type Author @model {
|
|
778
|
+
id: ID! @id
|
|
779
|
+
posts: [Post!]! @relation(field: "postIds", onDelete: "Cascade") # Deletes all posts when author is deleted
|
|
780
|
+
postIds: [ID!]!
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
type Profile @model {
|
|
784
|
+
id: ID! @id
|
|
785
|
+
user: User @relation(field: "userId", onDelete: "SetNull") # Sets userId to null when user is deleted
|
|
786
|
+
userId: ID
|
|
787
|
+
}
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
**Note:** `onDelete: "SetNull"` is only supported on nullable foreign key fields (optional `ID` fields, not `ID!`). Using it on required fields will cause a validation error.
|
|
791
|
+
|
|
765
792
|
### Automatic Indexing
|
|
766
793
|
|
|
767
794
|
Lenz automatically creates indexes for foreign key fields when `index: true` (default). You can disable this:
|
|
@@ -1,94 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.generateCommand = void 0;
|
|
40
|
-
const commander_1 = require("commander");
|
|
41
|
-
const LenzEngine_1 = require("../../engine/LenzEngine");
|
|
42
|
-
const fs_1 = require("fs");
|
|
43
|
-
const path_1 = require("path");
|
|
44
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
-
exports.generateCommand = new commander_1.Command('generate')
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { LenzEngine } from '../../engine/LenzEngine.js';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { resolve, dirname } from 'path';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
export const generateCommand = new Command('generate')
|
|
46
7
|
.description('Generate Lenz client from GraphQL schema')
|
|
47
8
|
.option('-c, --config <path>', 'Path to lenz config file', 'lenz/lenz.config.ts')
|
|
48
9
|
.option('-s, --schema <path>', 'Path to GraphQL schema file')
|
|
49
10
|
.option('-o, --output <path>', 'Output directory for generated client')
|
|
50
11
|
.option('-n, --name <name>', 'Name of the generated client', 'LenzClient')
|
|
51
12
|
.action(async (options) => {
|
|
52
|
-
console.log(
|
|
13
|
+
console.log(chalk.blue('🚀 Generating Lenz client...'));
|
|
53
14
|
try {
|
|
54
15
|
let config = {};
|
|
55
16
|
// Автоматически определяем конфиг по типу проекта, если используется значение по умолчанию
|
|
56
17
|
let configFile = options.config;
|
|
57
18
|
if (configFile === 'lenz/lenz.config.ts') {
|
|
58
|
-
const tsConfigPath =
|
|
59
|
-
const jsConfigPath =
|
|
60
|
-
if (!
|
|
19
|
+
const tsConfigPath = resolve(process.cwd(), 'lenz/lenz.config.ts');
|
|
20
|
+
const jsConfigPath = resolve(process.cwd(), 'lenz/lenz.config.js');
|
|
21
|
+
if (!existsSync(tsConfigPath) && existsSync(jsConfigPath)) {
|
|
61
22
|
configFile = 'lenz/lenz.config.js';
|
|
62
|
-
console.log(
|
|
23
|
+
console.log(chalk.gray(`📦 Using JavaScript config: ${configFile}`));
|
|
63
24
|
}
|
|
64
25
|
}
|
|
65
|
-
const configPath =
|
|
26
|
+
const configPath = resolve(process.cwd(), configFile);
|
|
66
27
|
// Загружаем конфигурацию
|
|
67
|
-
if (
|
|
28
|
+
if (existsSync(configPath)) {
|
|
68
29
|
if (configPath.endsWith('.ts')) {
|
|
69
30
|
// Для TypeScript конфига
|
|
70
|
-
const configModule = await
|
|
31
|
+
const configModule = await import(configPath);
|
|
71
32
|
config = configModule.default || configModule;
|
|
72
33
|
}
|
|
73
34
|
else if (configPath.endsWith('.js') || configPath.endsWith('.mjs')) {
|
|
74
35
|
// Для JavaScript конфига (только ESM)
|
|
75
|
-
const configModule = await
|
|
36
|
+
const configModule = await import(configPath);
|
|
76
37
|
config = configModule.default || configModule;
|
|
77
38
|
}
|
|
78
39
|
}
|
|
79
40
|
else {
|
|
80
|
-
console.log(
|
|
41
|
+
console.log(chalk.yellow('⚠️ Config file not found, using defaults'));
|
|
81
42
|
}
|
|
82
43
|
// Определяем пути
|
|
83
|
-
const schemaPath =
|
|
84
|
-
if (!
|
|
85
|
-
console.log(
|
|
86
|
-
console.log(
|
|
44
|
+
const schemaPath = resolve(dirname(configPath), options.schema || config.schema || 'schema.graphql');
|
|
45
|
+
if (!existsSync(schemaPath)) {
|
|
46
|
+
console.log(chalk.red(`❌ Schema file not found: ${schemaPath}`));
|
|
47
|
+
console.log(chalk.yellow('💡 Try running: lenz init'));
|
|
87
48
|
process.exit(1);
|
|
88
49
|
}
|
|
89
|
-
const outputPath =
|
|
50
|
+
const outputPath = resolve(dirname(configPath), options.output || config.generate?.client?.output || '../generated/lenz/client');
|
|
90
51
|
// Создаем движок и генерируем
|
|
91
|
-
const engine = new
|
|
52
|
+
const engine = new LenzEngine({
|
|
92
53
|
schemaPath,
|
|
93
54
|
outputPath,
|
|
94
55
|
clientName: options.name
|
|
@@ -97,23 +58,23 @@ exports.generateCommand = new commander_1.Command('generate')
|
|
|
97
58
|
// Отображаем информацию
|
|
98
59
|
const schemaInfo = engine.getSchemaInfo();
|
|
99
60
|
if (schemaInfo) {
|
|
100
|
-
console.log(
|
|
101
|
-
console.log(
|
|
102
|
-
console.log(
|
|
103
|
-
console.log(
|
|
104
|
-
console.log(
|
|
105
|
-
console.log(
|
|
106
|
-
console.log(
|
|
107
|
-
console.log(
|
|
108
|
-
console.log(
|
|
109
|
-
console.log(
|
|
110
|
-
console.log(
|
|
111
|
-
console.log(
|
|
61
|
+
console.log(chalk.green('✅ Generation complete!'));
|
|
62
|
+
console.log(chalk.gray('================================'));
|
|
63
|
+
console.log(chalk.cyan('📊 Generated:'));
|
|
64
|
+
console.log(chalk.white(` • ${schemaInfo.modelCount} models`));
|
|
65
|
+
console.log(chalk.white(` • ${schemaInfo.enumCount} enums`));
|
|
66
|
+
console.log(chalk.white(` • ${schemaInfo.relationCount} relations`));
|
|
67
|
+
console.log(chalk.gray('================================\n'));
|
|
68
|
+
console.log(chalk.yellow('🚀 Next steps:'));
|
|
69
|
+
console.log(chalk.white(` 1. Import client: ${chalk.cyan(`import { LenzClient } from '../generated/lenz/client'`)}`));
|
|
70
|
+
console.log(chalk.white(` 2. Create instance: ${chalk.cyan(`const lenz = new LenzClient({ url: 'mongodb://...' })`)}`));
|
|
71
|
+
console.log(chalk.white(` 3. Connect: ${chalk.cyan(`await lenz.$connect()`)}`));
|
|
72
|
+
console.log(chalk.white(` 4. Use models: ${chalk.cyan(`await lenz.user.findMany()`)}\n`));
|
|
112
73
|
}
|
|
113
74
|
}
|
|
114
75
|
catch (error) {
|
|
115
|
-
console.log(
|
|
116
|
-
console.log(
|
|
76
|
+
console.log(chalk.red('❌ Generation failed:'));
|
|
77
|
+
console.log(chalk.red(error instanceof Error ? error.message : String(error)));
|
|
117
78
|
process.exit(1);
|
|
118
79
|
}
|
|
119
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,qBAAqB,EAAE,0BAA0B,EAAE,qBAAqB,CAAC;KAChF,MAAM,CAAC,qBAAqB,EAAE,6BAA6B,CAAC;KAC5D,MAAM,CAAC,qBAAqB,EAAE,uCAAuC,CAAC;KACtE,MAAM,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,YAAY,CAAC;KACzE,MAAM,CAAC,KAAK,EAAE,OAAwB,EAAE,EAAE;IACzC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC;QACH,IAAI,MAAM,GAAQ,EAAE,CAAC;QAErB,2FAA2F;QAC3F,IAAI,UAAU,GAAG,OAAO,CAAC,MAAO,CAAC;QACjC,IAAI,UAAU,KAAK,qBAAqB,EAAE,CAAC;YACzC,MAA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(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initCommand = void 0;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
11
5
|
const DEFAULT_SCHEMA = `# Welcome to Lenz!
|
|
12
6
|
# This is your GraphQL schema file.
|
|
13
7
|
# Define your models here using GraphQL SDL syntax.
|
|
@@ -81,12 +75,12 @@ LOG_LEVEL=info
|
|
|
81
75
|
|
|
82
76
|
# Enable query logging
|
|
83
77
|
LOG_QUERIES=true`;
|
|
84
|
-
|
|
78
|
+
export const initCommand = new Command('init')
|
|
85
79
|
.description('Initialize a new Lenz project')
|
|
86
80
|
.option('--skip-prompts', 'Skip interactive prompts')
|
|
87
81
|
.action(async (options) => {
|
|
88
|
-
console.log(
|
|
89
|
-
const answers = options.skipPrompts ? {} : await
|
|
82
|
+
console.log(chalk.blue('🚀 Initializing Lenz project...\n'));
|
|
83
|
+
const answers = options.skipPrompts ? {} : await inquirer.prompt([
|
|
90
84
|
{
|
|
91
85
|
type: 'input',
|
|
92
86
|
name: 'url',
|
|
@@ -103,16 +97,16 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
103
97
|
// Создаем директории
|
|
104
98
|
const dirs = ['lenz', 'generated'];
|
|
105
99
|
for (const dir of dirs) {
|
|
106
|
-
if (!
|
|
107
|
-
|
|
108
|
-
console.log(
|
|
100
|
+
if (!existsSync(dir)) {
|
|
101
|
+
mkdirSync(dir, { recursive: true });
|
|
102
|
+
console.log(chalk.green(`📁 Created directory: ./${dir}`));
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
105
|
// Определяем тип проекта (TypeScript или JavaScript)
|
|
112
|
-
const isTypeScriptProject =
|
|
106
|
+
const isTypeScriptProject = existsSync('tsconfig.json');
|
|
113
107
|
const configExtension = isTypeScriptProject ? 'ts' : 'js';
|
|
114
108
|
const configTemplate = isTypeScriptProject ? DEFAULT_CONFIG_TS : DEFAULT_CONFIG_JS;
|
|
115
|
-
console.log(
|
|
109
|
+
console.log(chalk.gray(`📦 Detected ${isTypeScriptProject ? 'TypeScript' : 'JavaScript (ESM)'} project`));
|
|
116
110
|
// Создаем файлы
|
|
117
111
|
const files = [
|
|
118
112
|
{
|
|
@@ -137,19 +131,19 @@ generated/
|
|
|
137
131
|
}
|
|
138
132
|
];
|
|
139
133
|
for (const file of files) {
|
|
140
|
-
if (!
|
|
141
|
-
|
|
142
|
-
console.log(
|
|
134
|
+
if (!existsSync(file.path)) {
|
|
135
|
+
writeFileSync(file.path, file.content, 'utf-8');
|
|
136
|
+
console.log(chalk.green(`📄 Created file: ${file.path}`));
|
|
143
137
|
}
|
|
144
138
|
else {
|
|
145
|
-
console.log(
|
|
139
|
+
console.log(chalk.yellow(`⚠️ File already exists: ${file.path}`));
|
|
146
140
|
}
|
|
147
141
|
}
|
|
148
|
-
console.log(
|
|
149
|
-
console.log(
|
|
150
|
-
console.log(
|
|
151
|
-
console.log(
|
|
152
|
-
console.log(
|
|
153
|
-
console.log(
|
|
142
|
+
console.log(chalk.green('\n✅ Lenz project initialized!'));
|
|
143
|
+
console.log(chalk.gray('\nNext steps:'));
|
|
144
|
+
console.log(chalk.white(' 1. Edit your schema: ') + chalk.cyan('lenz/schema.graphql'));
|
|
145
|
+
console.log(chalk.white(' 2. Configure database: ') + chalk.cyan(`lenz/lenz.config.${configExtension}`));
|
|
146
|
+
console.log(chalk.white(' 3. Generate client: ') + chalk.cyan('npx lenz generate'));
|
|
147
|
+
console.log(chalk.white(' 4. Start coding! 🚀\n'));
|
|
154
148
|
});
|
|
155
149
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAgCe,CAAC;AAEvC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;GAevB,CAAC;AAEJ,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;IAetB,CAAC;AAGL,MAAM,WAAW,GAAG;;;;;;;iBAOH,CAAC;AAElB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,gBAAgB,EAAE,0BAA0B,CAAC;KACpD,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC;QAC/D;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,sCAAsC;YAC/C,OAAO,EAAE,iCAAiC;SAC3C;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,wBAAwB;YACjC,OAAO,EAAE,IAAI;SACd;KACF,CAAC,CAAC;IAEH,qBAAqB;IACrB,MAAM,IAAI,GAAG,CA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const boxen_1 = __importDefault(require("boxen"));
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
exports.studioCommand = new commander_1.Command('studio')
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import boxen from 'boxen';
|
|
4
|
+
import { existsSync } from 'fs';
|
|
5
|
+
export const studioCommand = new Command('studio')
|
|
12
6
|
.description('Open Lenz Studio - visual database management')
|
|
13
7
|
.option('-p, --port <port>', 'Port for Lenz Studio', '5555')
|
|
14
8
|
.option('--host <host>', 'Host for Lenz Studio', 'localhost')
|
|
15
9
|
.action(async (options) => {
|
|
16
|
-
console.log(
|
|
10
|
+
console.log(chalk.blue(boxen('🚀 Lenz Studio', { padding: 1, borderStyle: 'round' })));
|
|
17
11
|
// Проверяем наличие схемы
|
|
18
12
|
const schemaPath = 'lenz/schema.graphql';
|
|
19
|
-
if (!
|
|
20
|
-
console.log(
|
|
21
|
-
console.log(
|
|
13
|
+
if (!existsSync(schemaPath)) {
|
|
14
|
+
console.log(chalk.red('❌ Schema file not found'));
|
|
15
|
+
console.log(chalk.yellow('💡 Run: lenz init'));
|
|
22
16
|
process.exit(1);
|
|
23
17
|
}
|
|
24
|
-
console.log(
|
|
25
|
-
console.log(
|
|
18
|
+
console.log(chalk.green('📡 Starting Lenz Studio...'));
|
|
19
|
+
console.log(chalk.gray(`🌐 Available at: http://${options.host}:${options.port}`));
|
|
26
20
|
// В реальности здесь будет запуск веб-сервера с интерфейсом
|
|
27
|
-
console.log(
|
|
28
|
-
console.log(
|
|
29
|
-
console.log(
|
|
30
|
-
console.log(
|
|
21
|
+
console.log(chalk.yellow('⚠️ Studio is under development'));
|
|
22
|
+
console.log(chalk.gray('\nIn the meantime, you can use:'));
|
|
23
|
+
console.log(chalk.white(' • MongoDB Compass'));
|
|
24
|
+
console.log(chalk.white(' • Generated TypeScript client\n'));
|
|
31
25
|
});
|
|
32
26
|
//# sourceMappingURL=studio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio.js","sourceRoot":"","sources":["../../../src/cli/commands/studio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studio.js","sourceRoot":"","sources":["../../../src/cli/commands/studio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,+CAA+C,CAAC;KAC5D,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,CAAC;KAC3D,MAAM,CAAC,eAAe,EAAE,sBAAsB,EAAE,WAAW,CAAC;KAC5D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAEvF,0BAA0B;IAC1B,MAAM,UAAU,GAAG,qBAAqB,CAAC;IACzC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEnF,4DAA4D;IAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const init_1 = require("./commands/init");
|
|
10
|
-
const studio_1 = require("./commands/studio");
|
|
11
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
-
const figlet_1 = __importDefault(require("figlet"));
|
|
13
|
-
const program = new commander_1.Command();
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { generateCommand } from './commands/generate.js';
|
|
4
|
+
import { initCommand } from './commands/init.js';
|
|
5
|
+
import { studioCommand } from './commands/studio.js';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import figlet from 'figlet';
|
|
8
|
+
const program = new Command();
|
|
14
9
|
program
|
|
15
10
|
.name('lenz')
|
|
16
11
|
.description('Lenz CLI - GraphQL-based ORM for MongoDB')
|
|
17
12
|
.version('1.0.0')
|
|
18
13
|
.configureOutput({
|
|
19
|
-
outputError: (str, write) => write(
|
|
14
|
+
outputError: (str, write) => write(chalk.red(str))
|
|
20
15
|
});
|
|
21
|
-
program.addCommand(
|
|
22
|
-
program.addCommand(
|
|
23
|
-
program.addCommand(
|
|
16
|
+
program.addCommand(initCommand);
|
|
17
|
+
program.addCommand(generateCommand);
|
|
18
|
+
program.addCommand(studioCommand);
|
|
24
19
|
if (process.argv.length === 2) {
|
|
25
|
-
console.log(
|
|
26
|
-
console.log(
|
|
20
|
+
console.log(chalk.cyan(figlet.textSync('Lenz', { horizontalLayout: 'full' })));
|
|
21
|
+
console.log(chalk.gray('GraphQL-based ORM for MongoDB\n'));
|
|
27
22
|
program.outputHelp();
|
|
28
23
|
}
|
|
29
24
|
else {
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,OAAO,CAAC;KAChB,eAAe,CAAC;IACf,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnD,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAElC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Lenz configuration utilities
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.defaultConfig = void 0;
|
|
7
|
-
exports.defineConfig = defineConfig;
|
|
8
|
-
exports.env = env;
|
|
9
4
|
/**
|
|
10
5
|
* Define a Lenz configuration
|
|
11
6
|
*/
|
|
12
|
-
function defineConfig(config) {
|
|
7
|
+
export function defineConfig(config) {
|
|
13
8
|
const result = {
|
|
14
|
-
...
|
|
9
|
+
...defaultConfig,
|
|
15
10
|
...config,
|
|
16
11
|
};
|
|
17
12
|
// Deep merge for datasource
|
|
18
13
|
if (config.datasource) {
|
|
19
14
|
result.datasource = {
|
|
20
|
-
...
|
|
15
|
+
...defaultConfig.datasource,
|
|
21
16
|
...config.datasource,
|
|
22
17
|
};
|
|
23
18
|
}
|
|
24
19
|
// Deep merge for generate
|
|
25
20
|
if (config.generate) {
|
|
26
21
|
result.generate = {
|
|
27
|
-
...
|
|
22
|
+
...defaultConfig.generate,
|
|
28
23
|
...config.generate,
|
|
29
24
|
};
|
|
30
25
|
if (config.generate.client) {
|
|
31
26
|
result.generate.client = {
|
|
32
|
-
...
|
|
27
|
+
...defaultConfig.generate?.client,
|
|
33
28
|
...config.generate.client,
|
|
34
29
|
};
|
|
35
30
|
}
|
|
@@ -39,13 +34,13 @@ function defineConfig(config) {
|
|
|
39
34
|
/**
|
|
40
35
|
* Load environment variables
|
|
41
36
|
*/
|
|
42
|
-
function env(key, defaultValue) {
|
|
37
|
+
export function env(key, defaultValue) {
|
|
43
38
|
return process.env[key] || defaultValue || '';
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
46
41
|
* Default configuration
|
|
47
42
|
*/
|
|
48
|
-
|
|
43
|
+
export const defaultConfig = {
|
|
49
44
|
schema: 'schema.graphql',
|
|
50
45
|
datasource: {
|
|
51
46
|
url: 'mongodb://localhost:27017/myapp',
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgCH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,MAAM,MAAM,GAAe;QACzB,GAAG,aAAa;QAChB,GAAG,MAAM;KACV,CAAC;IAEF,4BAA4B;IAC5B,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,CAAC,UAAU,GAAG;YAClB,GAAG,aAAa,CAAC,UAAU;YAC3B,GAAG,MAAM,CAAC,UAAU;SACrB,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,QAAQ,GAAG;YAChB,GAAG,aAAa,CAAC,QAAQ;YACzB,GAAG,MAAM,CAAC,QAAQ;SACnB,CAAC;QACF,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG;gBACvB,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM;gBACjC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM;aAC1B,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,YAAqB;IACpD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,YAAY,IAAI,EAAE,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAe;IACvC,MAAM,EAAE,gBAAgB;IACxB,UAAU,EAAE;QACV,GAAG,EAAE,iCAAiC;KACvC;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,MAAM,EAAE,0BAA0B;SACnC;KACF;IACD,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,IAAI;IAC3B,WAAW,EAAE,EAAE;IACf,gBAAgB,EAAE,KAAK;IACvB,eAAe,EAAE,KAAK;CACvB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLModel, GraphQLEnum, ModelRelation } from './GraphQLParser';
|
|
1
|
+
import { GraphQLModel, GraphQLEnum, ModelRelation } from './GraphQLParser.js';
|
|
2
2
|
export interface GenerateOptions {
|
|
3
3
|
models: GraphQLModel[];
|
|
4
4
|
enums: GraphQLEnum[];
|
|
@@ -28,6 +28,7 @@ export declare class CodeGenerator {
|
|
|
28
28
|
private generateRuntimeRelations;
|
|
29
29
|
private generateModelsIndex;
|
|
30
30
|
private generateModelFiles;
|
|
31
|
+
private generateCascadeMethod;
|
|
31
32
|
private generateModelDelegate;
|
|
32
33
|
private generateRelationInclusionCode;
|
|
33
34
|
private toCamelCase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeGenerator.d.ts","sourceRoot":"","sources":["../../src/engine/CodeGenerator.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