@bairock/lenz 0.0.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/LICENSE +21 -0
- package/README.md +224 -0
- package/dist/cli/commands/generate.d.ts +3 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +110 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +145 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/studio.d.ts +3 -0
- package/dist/cli/commands/studio.d.ts.map +1 -0
- package/dist/cli/commands/studio.js +32 -0
- package/dist/cli/commands/studio.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +32 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/index.d.ts +47 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +42 -0
- package/dist/config/index.js.map +1 -0
- package/dist/engine/CodeGenerator.d.ts +37 -0
- package/dist/engine/CodeGenerator.d.ts.map +1 -0
- package/dist/engine/CodeGenerator.js +1604 -0
- package/dist/engine/CodeGenerator.js.map +1 -0
- package/dist/engine/GraphQLParser.d.ts +74 -0
- package/dist/engine/GraphQLParser.d.ts.map +1 -0
- package/dist/engine/GraphQLParser.js +269 -0
- package/dist/engine/GraphQLParser.js.map +1 -0
- package/dist/engine/LenzEngine.d.ts +23 -0
- package/dist/engine/LenzEngine.d.ts.map +1 -0
- package/dist/engine/LenzEngine.js +112 -0
- package/dist/engine/LenzEngine.js.map +1 -0
- package/dist/engine/SchemaValidator.d.ts +63 -0
- package/dist/engine/SchemaValidator.d.ts.map +1 -0
- package/dist/engine/SchemaValidator.js +268 -0
- package/dist/engine/SchemaValidator.js.map +1 -0
- package/dist/engine/directives.d.ts +15 -0
- package/dist/engine/directives.d.ts.map +1 -0
- package/dist/engine/directives.js +91 -0
- package/dist/engine/directives.js.map +1 -0
- package/dist/engine/index.d.ts +4 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +10 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/errors/index.d.ts +46 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +133 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bairock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Lenz 🚀
|
|
2
|
+
|
|
3
|
+
GraphQL-based ORM for MongoDB (Prisma 7.0 style)
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **GraphQL SDL Schema** - Define models using GraphQL syntax
|
|
8
|
+
- ✅ **TypeScript First** - Full type safety and autocompletion
|
|
9
|
+
- ✅ **MongoDB Native** - Leverage all MongoDB features
|
|
10
|
+
- ✅ **Prisma 7.0 Style** - Familiar configuration and client generation
|
|
11
|
+
- ✅ **Auto-generated Client** - Generate TypeScript client from GraphQL schema
|
|
12
|
+
- ✅ **Relations Support** - One-to-One, One-to-Many, Many-to-Many
|
|
13
|
+
- ✅ **Transactions** - ACID transactions with MongoDB
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Install Lenz
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install lenz
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. Initialize your project
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx lenz init
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This creates:
|
|
30
|
+
|
|
31
|
+
- `lenz/schema.graphql` - Your GraphQL schema
|
|
32
|
+
- `lenz/lenz.config.ts` - Configuration file
|
|
33
|
+
- `.env.example` - Environment variables template
|
|
34
|
+
|
|
35
|
+
### 3. Edit your schema
|
|
36
|
+
|
|
37
|
+
Edit `lenz/schema.graphql`:
|
|
38
|
+
|
|
39
|
+
```graphql
|
|
40
|
+
type User @model {
|
|
41
|
+
id: ID! @id
|
|
42
|
+
email: String! @unique
|
|
43
|
+
name: String!
|
|
44
|
+
posts: [Post!]! @relation(field: "authorId")
|
|
45
|
+
createdAt: DateTime! @createdAt
|
|
46
|
+
updatedAt: DateTime! @updatedAt
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type Post @model {
|
|
50
|
+
id: ID! @id
|
|
51
|
+
title: String!
|
|
52
|
+
content: String
|
|
53
|
+
author: User! @relation(field: "authorId")
|
|
54
|
+
authorId: ID!
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 4. Generate the client
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx lenz generate
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This generates the client in `generated/lenz/client`.
|
|
65
|
+
|
|
66
|
+
### 5. Use in your code
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { LenzClient } from '../generated/lenz/client';
|
|
70
|
+
|
|
71
|
+
async function main() {
|
|
72
|
+
const lenz = new LenzClient({
|
|
73
|
+
url: process.env.MONGODB_URI,
|
|
74
|
+
database: 'myapp'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await lenz.$connect();
|
|
78
|
+
|
|
79
|
+
// Create a user
|
|
80
|
+
const user = await lenz.user.create({
|
|
81
|
+
data: {
|
|
82
|
+
email: 'alice@example.com',
|
|
83
|
+
name: 'Alice',
|
|
84
|
+
posts: {
|
|
85
|
+
create: [
|
|
86
|
+
{ title: 'Hello World', content: 'My first post' }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
include: {
|
|
91
|
+
posts: true
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Query users
|
|
96
|
+
const users = await lenz.user.findMany({
|
|
97
|
+
where: {
|
|
98
|
+
email: {
|
|
99
|
+
contains: 'example'
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
await lenz.$disconnect();
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Configuration
|
|
109
|
+
|
|
110
|
+
### `lenz/lenz.config.ts`
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import 'dotenv/config'
|
|
114
|
+
import { defineConfig } from 'lenz/config'
|
|
115
|
+
|
|
116
|
+
export default defineConfig({
|
|
117
|
+
schema: 'schema.graphql',
|
|
118
|
+
migrations: {
|
|
119
|
+
path: 'migrations',
|
|
120
|
+
},
|
|
121
|
+
datasource: {
|
|
122
|
+
url: process.env.MONGODB_URI,
|
|
123
|
+
database: process.env.MONGODB_DATABASE || 'myapp',
|
|
124
|
+
},
|
|
125
|
+
generate: {
|
|
126
|
+
client: {
|
|
127
|
+
output: '../generated/lenz/client',
|
|
128
|
+
generator: 'lenz-client-js',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
log: ['query', 'info', 'warn', 'error'] as const,
|
|
132
|
+
autoCreateCollections: true,
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## GraphQL Directives
|
|
137
|
+
|
|
138
|
+
Lenz extends GraphQL with custom directives:
|
|
139
|
+
|
|
140
|
+
- `@model` - Marks a type as a database model
|
|
141
|
+
- `@id` - Marks a field as primary key (auto-generated ObjectId)
|
|
142
|
+
- `@unique` - Creates a unique index
|
|
143
|
+
- `@index` - Creates a regular index
|
|
144
|
+
- `@default(value: "...")` - Sets default value
|
|
145
|
+
- `@relation(field: "...")` - Defines relation field
|
|
146
|
+
- `@createdAt` - Auto-sets creation timestamp
|
|
147
|
+
- `@updatedAt` - Auto-updates timestamp
|
|
148
|
+
|
|
149
|
+
## Supported Field Types
|
|
150
|
+
|
|
151
|
+
- `String`
|
|
152
|
+
- `Int`
|
|
153
|
+
- `Float`
|
|
154
|
+
- `Boolean`
|
|
155
|
+
- `ID` (stored as String)
|
|
156
|
+
- `DateTime` (JavaScript Date)
|
|
157
|
+
- `Date` (JavaScript Date)
|
|
158
|
+
- `Json` (any JSON value)
|
|
159
|
+
- `ObjectId` (MongoDB ObjectId as string)
|
|
160
|
+
|
|
161
|
+
## CLI Commands
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Initialize project
|
|
165
|
+
npx lenz init
|
|
166
|
+
|
|
167
|
+
# Generate client
|
|
168
|
+
npx lenz generate
|
|
169
|
+
|
|
170
|
+
# Generate with custom config
|
|
171
|
+
npx lenz generate --config lenz/lenz.config.js
|
|
172
|
+
|
|
173
|
+
# Show help
|
|
174
|
+
npx lenz --help
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Structure After Generation
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
my-app/
|
|
181
|
+
├── lenz/
|
|
182
|
+
│ ├── schema.graphql # Your GraphQL schema
|
|
183
|
+
│ └── lenz.config.ts # Configuration
|
|
184
|
+
├── generated/
|
|
185
|
+
│ └── lenz/
|
|
186
|
+
│ └── client/ # Generated client
|
|
187
|
+
│ ├── index.ts # Main export
|
|
188
|
+
│ ├── client.ts # LenzClient class
|
|
189
|
+
│ ├── types.ts # TypeScript types
|
|
190
|
+
│ ├── enums.ts # Enum definitions
|
|
191
|
+
│ ├── runtime/ # Runtime utilities
|
|
192
|
+
│ └── models/ # Model delegates
|
|
193
|
+
└── .env # Environment variables
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
### Build
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npm run build
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Watch mode
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm run dev
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Lint
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm run lint
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Format
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm run format
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,eAAO,MAAM,eAAe,SA6ExB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
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')
|
|
46
|
+
.description('Generate Lenz client from GraphQL schema')
|
|
47
|
+
.option('-c, --config <path>', 'Path to lenz config file', 'lenz/lenz.config.ts')
|
|
48
|
+
.option('-s, --schema <path>', 'Path to GraphQL schema file')
|
|
49
|
+
.option('-o, --output <path>', 'Output directory for generated client')
|
|
50
|
+
.option('-n, --name <name>', 'Name of the generated client', 'LenzClient')
|
|
51
|
+
.action(async (options) => {
|
|
52
|
+
console.log(chalk_1.default.blue('🚀 Generating Lenz client...'));
|
|
53
|
+
try {
|
|
54
|
+
let config = {};
|
|
55
|
+
const configPath = (0, path_1.resolve)(process.cwd(), options.config);
|
|
56
|
+
// Загружаем конфигурацию
|
|
57
|
+
if ((0, fs_1.existsSync)(configPath)) {
|
|
58
|
+
if (configPath.endsWith('.ts')) {
|
|
59
|
+
// Для TypeScript конфига
|
|
60
|
+
const configModule = await Promise.resolve(`${configPath}`).then(s => __importStar(require(s)));
|
|
61
|
+
config = configModule.default || configModule;
|
|
62
|
+
}
|
|
63
|
+
else if (configPath.endsWith('.js')) {
|
|
64
|
+
// Для JavaScript конфига
|
|
65
|
+
const configModule = require(configPath);
|
|
66
|
+
config = configModule.default || configModule;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.log(chalk_1.default.yellow('⚠️ Config file not found, using defaults'));
|
|
71
|
+
}
|
|
72
|
+
// Определяем пути
|
|
73
|
+
const schemaPath = (0, path_1.resolve)((0, path_1.dirname)(configPath), options.schema || config.schema || 'schema.graphql');
|
|
74
|
+
if (!(0, fs_1.existsSync)(schemaPath)) {
|
|
75
|
+
console.log(chalk_1.default.red(`❌ Schema file not found: ${schemaPath}`));
|
|
76
|
+
console.log(chalk_1.default.yellow('💡 Try running: lenz init'));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
const outputPath = (0, path_1.resolve)((0, path_1.dirname)(configPath), options.output || config.generate?.client?.output || '../generated/lenz/client');
|
|
80
|
+
// Создаем движок и генерируем
|
|
81
|
+
const engine = new LenzEngine_1.LenzEngine({
|
|
82
|
+
schemaPath,
|
|
83
|
+
outputPath,
|
|
84
|
+
clientName: options.name
|
|
85
|
+
});
|
|
86
|
+
await engine.generate();
|
|
87
|
+
// Отображаем информацию
|
|
88
|
+
const schemaInfo = engine.getSchemaInfo();
|
|
89
|
+
if (schemaInfo) {
|
|
90
|
+
console.log(chalk_1.default.green('✅ Generation complete!'));
|
|
91
|
+
console.log(chalk_1.default.gray('================================'));
|
|
92
|
+
console.log(chalk_1.default.cyan('📊 Generated:'));
|
|
93
|
+
console.log(chalk_1.default.white(` • ${schemaInfo.modelCount} models`));
|
|
94
|
+
console.log(chalk_1.default.white(` • ${schemaInfo.enumCount} enums`));
|
|
95
|
+
console.log(chalk_1.default.white(` • ${schemaInfo.relationCount} relations`));
|
|
96
|
+
console.log(chalk_1.default.gray('================================\n'));
|
|
97
|
+
console.log(chalk_1.default.yellow('🚀 Next steps:'));
|
|
98
|
+
console.log(chalk_1.default.white(` 1. Import client: ${chalk_1.default.cyan(`import { LenzClient } from '../generated/lenz/client'`)}`));
|
|
99
|
+
console.log(chalk_1.default.white(` 2. Create instance: ${chalk_1.default.cyan(`const lenz = new LenzClient({ url: 'mongodb://...' })`)}`));
|
|
100
|
+
console.log(chalk_1.default.white(` 3. Connect: ${chalk_1.default.cyan(`await lenz.$connect()`)}`));
|
|
101
|
+
console.log(chalk_1.default.white(` 4. Use models: ${chalk_1.default.cyan(`await lenz.user.findMany()`)}\n`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.log(chalk_1.default.red('❌ Generation failed:'));
|
|
106
|
+
console.log(chalk_1.default.red(error instanceof Error ? error.message : String(error)));
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,wDAAqD;AACrD,2BAAgC;AAChC,+BAAwC;AACxC,kDAA0B;AASb,QAAA,eAAe,GAAG,IAAI,mBAAO,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,eAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC;QACH,IAAI,MAAM,GAAQ,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,MAAO,CAAC,CAAC;QAE3D,yBAAyB;QACzB,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,yBAAyB;gBACzB,MAAM,YAA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C,oBAAoB,eAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7F,CAAC;IAEH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuEpC,eAAO,MAAM,WAAW,SA2EpB,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(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"));
|
|
11
|
+
const DEFAULT_SCHEMA = `# Welcome to Lenz!
|
|
12
|
+
# This is your GraphQL schema file.
|
|
13
|
+
# Define your models here using GraphQL SDL syntax.
|
|
14
|
+
|
|
15
|
+
type User @model {
|
|
16
|
+
id: ID! @id
|
|
17
|
+
email: String! @unique
|
|
18
|
+
name: String!
|
|
19
|
+
age: Int
|
|
20
|
+
posts: [Post!]! @relation(field: "authorId")
|
|
21
|
+
createdAt: DateTime! @createdAt
|
|
22
|
+
updatedAt: DateTime! @updatedAt
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type Post @model {
|
|
26
|
+
id: ID! @id
|
|
27
|
+
title: String!
|
|
28
|
+
content: String
|
|
29
|
+
published: Boolean! @default(value: false)
|
|
30
|
+
author: User! @relation(field: "authorId")
|
|
31
|
+
authorId: ID!
|
|
32
|
+
tags: [String!]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Directives available:
|
|
36
|
+
# @model - Marks a type as a database model
|
|
37
|
+
# @id - Marks a field as primary key
|
|
38
|
+
# @unique - Creates a unique index
|
|
39
|
+
# @index - Creates a regular index
|
|
40
|
+
# @default(value: "...") - Sets default value
|
|
41
|
+
# @relation(field: "...") - Defines relation field
|
|
42
|
+
# @createdAt - Auto-sets creation timestamp
|
|
43
|
+
# @updatedAt - Auto-updates timestamp`;
|
|
44
|
+
const DEFAULT_CONFIG_TS = `import 'dotenv/config'
|
|
45
|
+
import { defineConfig } from 'lenz/config'
|
|
46
|
+
|
|
47
|
+
export default defineConfig({
|
|
48
|
+
schema: 'schema.graphql',
|
|
49
|
+
datasource: {
|
|
50
|
+
url: process.env.MONGODB_URI,
|
|
51
|
+
database: process.env.MONGODB_DATABASE || 'myapp',
|
|
52
|
+
},
|
|
53
|
+
generate: {
|
|
54
|
+
client: {
|
|
55
|
+
output: '../generated/lenz/client',
|
|
56
|
+
generator: 'lenz-client-js',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
log: ['query', 'info', 'warn', 'error'] as const,
|
|
60
|
+
autoCreateCollections: true,
|
|
61
|
+
})`;
|
|
62
|
+
const EXAMPLE_ENV = `# MongoDB connection string
|
|
63
|
+
MONGODB_URI=mongodb://localhost:27017
|
|
64
|
+
|
|
65
|
+
# Database name
|
|
66
|
+
MONGODB_DATABASE=myapp
|
|
67
|
+
|
|
68
|
+
# Log level (debug, info, warn, error)
|
|
69
|
+
LOG_LEVEL=info
|
|
70
|
+
|
|
71
|
+
# Enable query logging
|
|
72
|
+
LOG_QUERIES=true`;
|
|
73
|
+
exports.initCommand = new commander_1.Command('init')
|
|
74
|
+
.description('Initialize a new Lenz project')
|
|
75
|
+
.option('--skip-prompts', 'Skip interactive prompts')
|
|
76
|
+
.action(async (options) => {
|
|
77
|
+
console.log(chalk_1.default.blue('🚀 Initializing Lenz project...\n'));
|
|
78
|
+
const answers = options.skipPrompts ? {} : await inquirer_1.default.prompt([
|
|
79
|
+
{
|
|
80
|
+
type: 'input',
|
|
81
|
+
name: 'database',
|
|
82
|
+
message: 'Database name:',
|
|
83
|
+
default: 'myapp'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'input',
|
|
87
|
+
name: 'url',
|
|
88
|
+
message: 'MongoDB URL:',
|
|
89
|
+
default: 'mongodb://localhost:27017'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'confirm',
|
|
93
|
+
name: 'createExample',
|
|
94
|
+
message: 'Create example schema?',
|
|
95
|
+
default: true
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
// Создаем директории
|
|
99
|
+
const dirs = ['lenz', 'generated'];
|
|
100
|
+
for (const dir of dirs) {
|
|
101
|
+
if (!(0, fs_1.existsSync)(dir)) {
|
|
102
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
103
|
+
console.log(chalk_1.default.green(`📁 Created directory: ./${dir}`));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Создаем файлы
|
|
107
|
+
const files = [
|
|
108
|
+
{
|
|
109
|
+
path: 'lenz/schema.graphql',
|
|
110
|
+
content: answers.createExample ? DEFAULT_SCHEMA : '# Your GraphQL schema here'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: 'lenz/lenz.config.ts',
|
|
114
|
+
content: DEFAULT_CONFIG_TS.replace('myapp', answers.database || 'myapp')
|
|
115
|
+
.replace('mongodb://localhost:27017', answers.url || 'mongodb://localhost:27017')
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
path: '.env.example',
|
|
119
|
+
content: EXAMPLE_ENV
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
path: '.gitignore',
|
|
123
|
+
content: `node_modules/
|
|
124
|
+
dist/
|
|
125
|
+
generated/
|
|
126
|
+
.env
|
|
127
|
+
*.log`
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
for (const file of files) {
|
|
131
|
+
if (!(0, fs_1.existsSync)(file.path)) {
|
|
132
|
+
(0, fs_1.writeFileSync)(file.path, file.content, 'utf-8');
|
|
133
|
+
console.log(chalk_1.default.green(`📄 Created file: ${file.path}`));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.log(chalk_1.default.yellow(`⚠️ File already exists: ${file.path}`));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
console.log(chalk_1.default.green('\n✅ Lenz project initialized!'));
|
|
140
|
+
console.log(chalk_1.default.gray('\nNext steps:'));
|
|
141
|
+
console.log(chalk_1.default.white(' 1. Edit your schema: ') + chalk_1.default.cyan('lenz/schema.graphql'));
|
|
142
|
+
console.log(chalk_1.default.white(' 2. Generate client: ') + chalk_1.default.cyan('npx lenz generate'));
|
|
143
|
+
console.log(chalk_1.default.white(' 3. Start coding! 🚀\n'));
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,2BAA0D;AAC1D,kDAA0B;AAC1B,wDAAgC;AAEhC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAgCe,CAAC;AAEvC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;GAiBvB,CAAC;AAGJ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AAG,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACrF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/studio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SAuBtB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.studioCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const boxen_1 = __importDefault(require("boxen"));
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
exports.studioCommand = new commander_1.Command('studio')
|
|
12
|
+
.description('Open Lenz Studio - visual database management')
|
|
13
|
+
.option('-p, --port <port>', 'Port for Lenz Studio', '5555')
|
|
14
|
+
.option('--host <host>', 'Host for Lenz Studio', 'localhost')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
console.log(chalk_1.default.blue((0, boxen_1.default)('🚀 Lenz Studio', { padding: 1, borderStyle: 'round' })));
|
|
17
|
+
// Проверяем наличие схемы
|
|
18
|
+
const schemaPath = 'lenz/schema.graphql';
|
|
19
|
+
if (!(0, fs_1.existsSync)(schemaPath)) {
|
|
20
|
+
console.log(chalk_1.default.red('❌ Schema file not found'));
|
|
21
|
+
console.log(chalk_1.default.yellow('💡 Run: lenz init'));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
console.log(chalk_1.default.green('📡 Starting Lenz Studio...'));
|
|
25
|
+
console.log(chalk_1.default.gray(`🌐 Available at: http://${options.host}:${options.port}`));
|
|
26
|
+
// В реальности здесь будет запуск веб-сервера с интерфейсом
|
|
27
|
+
console.log(chalk_1.default.yellow('⚠️ Studio is under development'));
|
|
28
|
+
console.log(chalk_1.default.gray('\nIn the meantime, you can use:'));
|
|
29
|
+
console.log(chalk_1.default.white(' • MongoDB Compass'));
|
|
30
|
+
console.log(chalk_1.default.white(' • Generated TypeScript client\n'));
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=studio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio.js","sourceRoot":"","sources":["../../../src/cli/commands/studio.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,kDAA0B;AAC1B,2BAAgC;AAEnB,QAAA,aAAa,GAAG,IAAI,mBAAO,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,eAAK,CAAC,IAAI,CAAC,IAAA,eAAK,EAAC,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,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEnF,4DAA4D;IAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const generate_1 = require("./commands/generate");
|
|
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();
|
|
14
|
+
program
|
|
15
|
+
.name('lenz')
|
|
16
|
+
.description('Lenz CLI - GraphQL-based ORM for MongoDB')
|
|
17
|
+
.version('1.0.0')
|
|
18
|
+
.configureOutput({
|
|
19
|
+
outputError: (str, write) => write(chalk_1.default.red(str))
|
|
20
|
+
});
|
|
21
|
+
program.addCommand(init_1.initCommand);
|
|
22
|
+
program.addCommand(generate_1.generateCommand);
|
|
23
|
+
program.addCommand(studio_1.studioCommand);
|
|
24
|
+
if (process.argv.length === 2) {
|
|
25
|
+
console.log(chalk_1.default.cyan(figlet_1.default.textSync('Lenz', { horizontalLayout: 'full' })));
|
|
26
|
+
console.log(chalk_1.default.gray('GraphQL-based ORM for MongoDB\n'));
|
|
27
|
+
program.outputHelp();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
program.parse(process.argv);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAAsD;AACtD,0CAA8C;AAC9C,8CAAkD;AAClD,kDAA0B;AAC1B,oDAA4B;AAE5B,MAAM,OAAO,GAAG,IAAI,mBAAO,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,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnD,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,0BAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,sBAAa,CAAC,CAAC;AAElC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gBAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,eAAK,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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lenz configuration utilities
|
|
3
|
+
*/
|
|
4
|
+
export interface LenzConfig {
|
|
5
|
+
/** Path to GraphQL schema file */
|
|
6
|
+
schema?: string;
|
|
7
|
+
/** Data source configuration */
|
|
8
|
+
datasource?: {
|
|
9
|
+
/** MongoDB connection URL */
|
|
10
|
+
url?: string;
|
|
11
|
+
/** Database name */
|
|
12
|
+
database?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Generation configuration */
|
|
15
|
+
generate?: {
|
|
16
|
+
/** Client generation options */
|
|
17
|
+
client?: {
|
|
18
|
+
/** Output directory for generated client */
|
|
19
|
+
output?: string;
|
|
20
|
+
/** Generator name */
|
|
21
|
+
generator?: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** Logging levels */
|
|
25
|
+
log?: ('query' | 'info' | 'warn' | 'error')[];
|
|
26
|
+
/** Auto-create collections */
|
|
27
|
+
autoCreateCollections?: boolean;
|
|
28
|
+
/** Connection pool size */
|
|
29
|
+
maxPoolSize?: number;
|
|
30
|
+
/** Connection timeout */
|
|
31
|
+
connectTimeoutMS?: number;
|
|
32
|
+
/** Socket timeout */
|
|
33
|
+
socketTimeoutMS?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Define a Lenz configuration
|
|
37
|
+
*/
|
|
38
|
+
export declare function defineConfig(config: LenzConfig): LenzConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Load environment variables
|
|
41
|
+
*/
|
|
42
|
+
export declare function env(key: string, defaultValue?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Default configuration
|
|
45
|
+
*/
|
|
46
|
+
export declare const defaultConfig: LenzConfig;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|