orchid-orm 1.17.28 → 1.17.30

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/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "orchid-orm",
3
- "version": "1.17.28",
3
+ "version": "1.17.30",
4
4
  "description": "Postgres ORM",
5
5
  "homepage": "https://orchid-orm.netlify.app/guide/orm-and-query-builder.html",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/romeerez/orchid-orm/tree/main/packages/orm"
9
9
  },
10
- "bin": "dist/bin.js",
11
10
  "main": "dist/index.js",
12
11
  "module": "dist/index.mjs",
13
12
  "typings": "dist/index.d.ts",
@@ -53,12 +52,12 @@
53
52
  "inflection": "*",
54
53
  "prompts": "^2.4.2",
55
54
  "orchid-core": "0.10.14",
56
- "pqb": "0.18.28"
55
+ "pqb": "0.18.29"
57
56
  },
58
57
  "devDependencies": {
59
58
  "@types/prompts": "^2.4.2",
60
- "orchid-orm-schema-to-zod": "0.4.31",
61
- "rake-db": "2.10.62",
59
+ "orchid-orm-schema-to-zod": "0.4.32",
60
+ "rake-db": "2.10.65",
62
61
  "test-utils": "0.0.3"
63
62
  },
64
63
  "peerDependencies": {
@@ -69,7 +68,6 @@
69
68
  "check": "jest",
70
69
  "types": "tsc",
71
70
  "test:ci": "jest --coverage --coverageReporters json-summary",
72
- "build": "rimraf ./dist/ ./codegen/ && rollup -c ./rollup.config.mjs",
73
- "db": "ts-node src/db/dbScripts.ts"
71
+ "build": "rimraf ./dist/ ./codegen/ && rollup -c ./rollup.config.mjs"
74
72
  }
75
73
  }
package/dist/bin.js DELETED
@@ -1,507 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- var fs = require('fs/promises');
5
- var path = require('path');
6
- var https = require('https');
7
- var prompts = require('prompts');
8
-
9
- const askOrchidORMConfig = async () => {
10
- let cancelled = false;
11
- const response = await prompts(
12
- [
13
- {
14
- type: "text",
15
- name: "path",
16
- message: "Where would you like to install Orchid ORM?",
17
- initial: process.cwd()
18
- },
19
- {
20
- type: "select",
21
- name: "timestamp",
22
- message: "Preferred type of returned timestamps:",
23
- choices: [
24
- {
25
- title: "string (as returned from db)"
26
- },
27
- {
28
- title: "number (epoch)",
29
- value: "number"
30
- },
31
- {
32
- title: "Date object",
33
- value: "date"
34
- }
35
- ]
36
- },
37
- {
38
- type: "confirm",
39
- name: "testDatabase",
40
- message: "Should I add a separate database for tests?"
41
- },
42
- {
43
- type: "confirm",
44
- name: "addSchemaToZod",
45
- message: "Are you going to use Zod for validation?"
46
- },
47
- {
48
- type: "confirm",
49
- name: "addTestFactory",
50
- message: "Do you want object factories for writing tests?"
51
- },
52
- {
53
- type: "confirm",
54
- name: "demoTables",
55
- message: "Should I add demo tables?"
56
- }
57
- ],
58
- {
59
- onCancel() {
60
- cancelled = true;
61
- }
62
- }
63
- );
64
- if (cancelled)
65
- return;
66
- const tsConfigPath = path.join(response.path, "tsconfig.json");
67
- const hasTsConfig = await readFileSafe(tsConfigPath);
68
- response.hasTsConfig = !!hasTsConfig;
69
- if (!hasTsConfig) {
70
- const res = await prompts(
71
- [
72
- {
73
- type: "confirm",
74
- name: "swc",
75
- initial: true,
76
- message: `Let's add fast TS compiler swc?`
77
- }
78
- ],
79
- {
80
- onCancel() {
81
- cancelled = true;
82
- }
83
- }
84
- );
85
- if (cancelled)
86
- return;
87
- response.swc = res.swc;
88
- }
89
- return response;
90
- };
91
- const initOrchidORM = async (config) => {
92
- config.path = path.resolve(config.path);
93
- const dirPath = path.join(config.path, "src", "db");
94
- await fs.mkdir(dirPath, { recursive: true });
95
- await setupPackageJson(config);
96
- await setupTSConfig(config);
97
- await setupEnv(config);
98
- await setupGitIgnore(config);
99
- await setupBaseTable(config, dirPath);
100
- await setupTables(config, dirPath);
101
- await setupConfig(config, dirPath);
102
- await setupMainDb(config, dirPath);
103
- await setupMigrationScript(config, dirPath);
104
- await createMigrations(config, dirPath);
105
- await createSeed(config, dirPath);
106
- greet(config);
107
- };
108
- const setupPackageJson = async (config) => {
109
- const pairs = await Promise.all([
110
- getLatestPackageVersion("dotenv", "dependencies"),
111
- getLatestPackageVersion("orchid-orm", "dependencies"),
112
- getLatestPackageVersion("pqb", "dependencies"),
113
- config.addSchemaToZod && getLatestPackageVersion("orchid-orm-schema-to-zod", "dependencies"),
114
- getLatestPackageVersion("rake-db", "devDependencies"),
115
- config.addTestFactory && getLatestPackageVersion("orchid-orm-test-factory", "devDependencies"),
116
- config.swc && getLatestPackageVersion("@swc/core", "devDependencies"),
117
- getLatestPackageVersion("@types/node", "devDependencies"),
118
- getLatestPackageVersion("ts-node", "devDependencies"),
119
- getLatestPackageVersion("typescript", "devDependencies")
120
- ]);
121
- const deps = {};
122
- const devDeps = {};
123
- for (const item of pairs) {
124
- if (!item)
125
- continue;
126
- const [key, { version, kind }] = item;
127
- (kind === "dependencies" ? deps : devDeps)[key] = version;
128
- }
129
- const packageJsonPath = path.join(config.path, "package.json");
130
- const content = await readFileSafe(packageJsonPath);
131
- const json = content ? JSON.parse(content) : {};
132
- if (!json.scripts)
133
- json.scripts = {};
134
- json.scripts.db = "ts-node src/db/dbScript.ts";
135
- if (!json.dependencies)
136
- json.dependencies = {};
137
- for (const key in deps) {
138
- json.dependencies[key] = deps[key];
139
- }
140
- if (!json.devDependencies)
141
- json.devDependencies = {};
142
- for (const key in devDeps) {
143
- json.devDependencies[key] = devDeps[key];
144
- }
145
- await fs.writeFile(packageJsonPath, JSON.stringify(json, null, " ") + "\n");
146
- };
147
- const getLatestPackageVersion = (name, kind) => {
148
- return new Promise((resolve2, reject) => {
149
- https.get(`https://registry.npmjs.org/${name}/latest`, (res) => {
150
- let data = "";
151
- res.on("data", (chunk) => data += chunk);
152
- res.on(
153
- "end",
154
- () => resolve2([name, { version: `^${JSON.parse(data).version}`, kind }])
155
- );
156
- }).on("error", reject);
157
- });
158
- };
159
- const readFileSafe = async (path) => {
160
- try {
161
- return await fs.readFile(path, "utf-8");
162
- } catch (err) {
163
- if (err.code === "ENOENT") {
164
- return void 0;
165
- }
166
- throw err;
167
- }
168
- };
169
- const setupTSConfig = async (config) => {
170
- if (config.hasTsConfig)
171
- return;
172
- const tsConfigPath = path.join(config.path, "tsconfig.json");
173
- await fs.writeFile(
174
- tsConfigPath,
175
- `{${config.swc ? `
176
- "ts-node": {
177
- "swc": true
178
- },` : ""}
179
- "compilerOptions": {
180
- "strict": true
181
- }
182
- }
183
- `
184
- );
185
- };
186
- const setupEnv = async (config) => {
187
- const envPath = path.join(config.path, ".env");
188
- let content = (await readFileSafe(envPath) || "").trim();
189
- let changed = false;
190
- if (!content.match(/^DATABASE_URL=/m)) {
191
- content += `
192
- DATABASE_URL=postgres://user:password@localhost:5432/dbname?ssl=false`;
193
- changed = true;
194
- }
195
- if (config.testDatabase && !content.match(/^DATABASE_TEST_URL=/m)) {
196
- content += `
197
- DATABASE_TEST_URL=postgres://user:password@localhost:5432/dbname-test?ssl=false`;
198
- changed = true;
199
- }
200
- if (changed) {
201
- await fs.writeFile(envPath, `${content.trim()}
202
- `);
203
- }
204
- };
205
- const setupGitIgnore = async (config) => {
206
- const gitignorePath = path.join(config.path, ".gitignore");
207
- let content = (await readFileSafe(gitignorePath) || "").trim();
208
- let changed = false;
209
- if (!content.match(/^node_modules\b/m)) {
210
- content += `
211
- node_modules`;
212
- changed = true;
213
- }
214
- if (!content.match(/^.env\b/m)) {
215
- content += `
216
- .env`;
217
- changed = true;
218
- }
219
- if (changed) {
220
- await fs.writeFile(gitignorePath, `${content.trim()}
221
- `);
222
- }
223
- };
224
- const setupBaseTable = async (config, dirPath) => {
225
- const filePath = path.join(dirPath, "baseTable.ts");
226
- let content = `import { createBaseTable } from 'orchid-orm';${config.addSchemaToZod ? `
227
- import { zodSchemaProvider } from 'orchid-orm-schema-to-zod';` : ""}
228
-
229
- export const BaseTable = createBaseTable({
230
- columnTypes: (t) => ({
231
- ...t,
232
- text: (min = 0, max = Infinity) => t.text(min, max),`;
233
- const { timestamp } = config;
234
- if (timestamp) {
235
- content += `
236
- timestamp: <P extends number>(precision?: P) =>
237
- t.timestamp<P>(precision).${timestamp === "date" ? "asDate" : "asNumber"}(),`;
238
- }
239
- content += `
240
- }),${config.addSchemaToZod ? `
241
- schemaProvider: zodSchemaProvider,` : ""}
242
- });
243
- `;
244
- await fs.writeFile(filePath, content);
245
- };
246
- const setupTables = async (config, dirPath) => {
247
- if (!config.demoTables)
248
- return;
249
- const tablesDir = path.join(dirPath, "tables");
250
- await fs.mkdir(tablesDir, { recursive: true });
251
- await fs.writeFile(
252
- path.join(tablesDir, "post.table.ts"),
253
- `import { TableType } from 'orchid-orm';
254
- import { BaseTable } from '../baseTable';
255
- import { CommentTable } from './comment.table';
256
-
257
- export type Post = TableType<PostTable>;
258
- export class PostTable extends BaseTable {
259
- readonly table = 'post';
260
- columns = this.setColumns((t) => ({
261
- id: t.identity().primaryKey(),
262
- title: t.text(3, 100).unique(),
263
- text: t.text(20, 10000),
264
- ...t.timestamps(),
265
- }));
266
-
267
- relations = {
268
- comments: this.hasMany(() => CommentTable, {
269
- primaryKey: 'id',
270
- foreignKey: 'postId',
271
- }),
272
- };
273
- }
274
- `
275
- );
276
- await fs.writeFile(
277
- path.join(tablesDir, "comment.table.ts"),
278
- `import { TableType } from 'orchid-orm';
279
- import { BaseTable } from '../baseTable';
280
- import { PostTable } from './post.table';
281
-
282
- export type Comment = TableType<CommentTable>;
283
- export class CommentTable extends BaseTable {
284
- readonly table = 'comment';
285
- columns = this.setColumns((t) => ({
286
- id: t.identity().primaryKey(),
287
- postId: t
288
- .integer()
289
- .foreignKey(() => PostTable, 'id')
290
- .index(),
291
- text: t.text(5, 1000),
292
- ...t.timestamps(),
293
- }));
294
-
295
- relations = {
296
- post: this.belongsTo(() => PostTable, {
297
- primaryKey: 'id',
298
- foreignKey: 'postId',
299
- }),
300
- };
301
- }
302
- `
303
- );
304
- };
305
- const setupConfig = async (config, dirPath) => {
306
- const configPath = path.join(dirPath, "config.ts");
307
- let content = `import 'dotenv/config';
308
-
309
- const database = {
310
- databaseURL: process.env.DATABASE_URL,
311
- };
312
- if (!database.databaseURL) throw new Error('DATABASE_URL is missing in .env');`;
313
- if (config.testDatabase) {
314
- content += `
315
-
316
- const testDatabase = {
317
- databaseURL: process.env.DATABASE_TEST_URL,
318
- };
319
-
320
- const allDatabases = [database];
321
-
322
- if (testDatabase.databaseURL) {
323
- allDatabases.push(testDatabase);
324
- }`;
325
- }
326
- content += `
327
-
328
- export const config = {`;
329
- if (config.testDatabase) {
330
- content += `
331
- allDatabases,`;
332
- }
333
- if (config.testDatabase) {
334
- content += `
335
- database: process.env.NODE_ENV === 'test' ? testDatabase : database,`;
336
- } else {
337
- content += `
338
- database,`;
339
- }
340
- content += `
341
- };
342
- `;
343
- await fs.writeFile(configPath, content);
344
- };
345
- const setupMainDb = async (config, dirPath) => {
346
- let imports = "";
347
- let tables = "";
348
- if (config.demoTables) {
349
- imports += `
350
- import { PostTable } from './tables/post.table';
351
- import { CommentTable } from './tables/comment.table';`;
352
- tables += `
353
- post: PostTable,
354
- comment: CommentTable,`;
355
- }
356
- const dbPath = path.join(dirPath, "db.ts");
357
- await fs.writeFile(
358
- dbPath,
359
- `import { orchidORM } from 'orchid-orm';
360
- import { config } from './config';${imports}
361
-
362
- export const db = orchidORM(config.database, {${tables}
363
- });
364
- `
365
- );
366
- };
367
- const setupMigrationScript = async (config, dirPath) => {
368
- const filePath = path.join(dirPath, "dbScript.ts");
369
- await fs.writeFile(
370
- filePath,
371
- `import { rakeDb } from 'rake-db';
372
- import { appCodeUpdater } from 'orchid-orm/codegen';
373
- import { config } from './config';
374
- import { BaseTable } from './baseTable';
375
-
376
- export const change = rakeDb(${config.testDatabase ? "config.allDatabases" : "config.database"}, {
377
- baseTable: BaseTable,
378
- migrationsPath: './migrations',
379
- appCodeUpdater: appCodeUpdater({
380
- tablePath: (tableName) => \`./tables/\${tableName}.table.ts\`,
381
- ormPath: './db.ts',
382
- }),
383
- useCodeUpdater: true, // set to false to disable code updater
384
- commands: {
385
- async seed() {
386
- const { seed } = await import('./seed');
387
- await seed();
388
- },
389
- },
390
- import: (path) => import(path),
391
- });
392
- `
393
- );
394
- };
395
- const createMigrations = async (config, dirPath) => {
396
- const migrationsPath = path.join(dirPath, "migrations");
397
- await fs.mkdir(migrationsPath, { recursive: true });
398
- if (!config.demoTables)
399
- return;
400
- const now = /* @__PURE__ */ new Date();
401
- const postPath = path.join(
402
- migrationsPath,
403
- `${makeFileTimeStamp(now)}_createPost.ts`
404
- );
405
- await fs.writeFile(
406
- postPath,
407
- `import { change } from '../dbScript';
408
-
409
- change(async (db) => {
410
- await db.createTable('post', (t) => ({
411
- id: t.identity().primaryKey(),
412
- title: t.text().unique(),
413
- text: t.text(),
414
- ...t.timestamps(),
415
- }));
416
- });
417
- `
418
- );
419
- now.setTime(now.getTime() + 1e3);
420
- const commentPath = path.join(
421
- migrationsPath,
422
- `${makeFileTimeStamp(now)}_createComment.ts`
423
- );
424
- await fs.writeFile(
425
- commentPath,
426
- `import { change } from '../dbScript';
427
-
428
- change(async (db) => {
429
- await db.createTable('comment', (t) => ({
430
- id: t.identity().primaryKey(),
431
- postId: t.integer().foreignKey('post', 'id').index(),
432
- text: t.text(),
433
- ...t.timestamps(),
434
- }));
435
- });
436
- `
437
- );
438
- };
439
- const makeFileTimeStamp = (now) => {
440
- return [
441
- now.getUTCFullYear(),
442
- now.getUTCMonth() + 1,
443
- now.getUTCDate(),
444
- now.getUTCHours(),
445
- now.getUTCMinutes(),
446
- now.getUTCSeconds()
447
- ].map((value) => value < 10 ? `0${value}` : value).join("");
448
- };
449
- const createSeed = async (config, dirPath) => {
450
- const filePath = path.join(dirPath, "seed.ts");
451
- let content;
452
- if (config.demoTables) {
453
- content = `await db.post.findBy({ title: 'Sample post' }).orCreate({
454
- title: 'Post',
455
- text: 'This is a text for a sample post. It contains words, spaces, and punctuation.',
456
- comments: {
457
- create: [
458
- {
459
- text: 'Nice post!',
460
- },
461
- {
462
- text: \`Too long, didn't read\`,
463
- },
464
- ],
465
- },
466
- });`;
467
- } else {
468
- content = `// create records here`;
469
- }
470
- await fs.writeFile(
471
- filePath,
472
- `import { db } from './db';
473
-
474
- export const seed = async () => {
475
- ${content}
476
-
477
- await db.$close();
478
- };
479
- `
480
- );
481
- };
482
- const greet = (config) => {
483
- const relativePath = path.relative(process.cwd(), config.path);
484
- console.log(`
485
- Thank you for trying Orchid ORM!
486
-
487
- To finish setup,${relativePath ? ` cd to the project and` : ""} install dependencies:
488
- ${relativePath ? `
489
- > cd ${relativePath}` : ""}
490
- > npm i
491
-
492
- Enter the correct database credentials to the .env file,
493
- then create the database:
494
-
495
- > npm run db create
496
-
497
- And run the migrations:
498
-
499
- > npm run db migrate
500
- `);
501
- };
502
-
503
- askOrchidORMConfig().then((config) => {
504
- if (config)
505
- initOrchidORM(config);
506
- });
507
- //# sourceMappingURL=bin.js.map
package/dist/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.js","sources":["../src/bin/init.ts","../src/bin/bin.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport { resolve, join, relative } from 'path';\nimport https from 'https';\nimport prompts from 'prompts';\n\nexport type InitConfig = {\n path: string;\n hasTsConfig: boolean;\n testDatabase?: boolean;\n addSchemaToZod?: boolean;\n addTestFactory?: boolean;\n demoTables?: boolean;\n timestamp?: 'date' | 'number';\n swc?: boolean;\n};\n\ntype DependencyKind = 'dependencies' | 'devDependencies';\n\nexport const askOrchidORMConfig = async () => {\n let cancelled = false;\n\n const response = await prompts(\n [\n {\n type: 'text',\n name: 'path',\n message: 'Where would you like to install Orchid ORM?',\n initial: process.cwd(),\n },\n {\n type: 'select',\n name: 'timestamp',\n message: 'Preferred type of returned timestamps:',\n choices: [\n {\n title: 'string (as returned from db)',\n },\n {\n title: 'number (epoch)',\n value: 'number',\n },\n {\n title: 'Date object',\n value: 'date',\n },\n ],\n },\n {\n type: 'confirm',\n name: 'testDatabase',\n message: 'Should I add a separate database for tests?',\n },\n {\n type: 'confirm',\n name: 'addSchemaToZod',\n message: 'Are you going to use Zod for validation?',\n },\n {\n type: 'confirm',\n name: 'addTestFactory',\n message: 'Do you want object factories for writing tests?',\n },\n {\n type: 'confirm',\n name: 'demoTables',\n message: 'Should I add demo tables?',\n },\n ],\n {\n onCancel() {\n cancelled = true;\n },\n },\n );\n\n if (cancelled) return;\n\n const tsConfigPath = join(response.path, 'tsconfig.json');\n const hasTsConfig = await readFileSafe(tsConfigPath);\n (response as InitConfig).hasTsConfig = !!hasTsConfig;\n\n if (!hasTsConfig) {\n const res = await prompts(\n [\n {\n type: 'confirm',\n name: 'swc',\n initial: true,\n message: `Let's add fast TS compiler swc?`,\n },\n ],\n {\n onCancel() {\n cancelled = true;\n },\n },\n );\n\n if (cancelled) return;\n\n (response as InitConfig).swc = res.swc;\n }\n\n return response as InitConfig;\n};\n\nexport const initOrchidORM = async (config: InitConfig) => {\n config.path = resolve(config.path);\n const dirPath = join(config.path, 'src', 'db');\n\n await fs.mkdir(dirPath, { recursive: true });\n\n await setupPackageJson(config);\n await setupTSConfig(config);\n await setupEnv(config);\n await setupGitIgnore(config);\n await setupBaseTable(config, dirPath);\n await setupTables(config, dirPath);\n await setupConfig(config, dirPath);\n await setupMainDb(config, dirPath);\n await setupMigrationScript(config, dirPath);\n await createMigrations(config, dirPath);\n await createSeed(config, dirPath);\n\n greet(config);\n};\n\nconst setupPackageJson = async (config: InitConfig) => {\n const pairs = await Promise.all([\n getLatestPackageVersion('dotenv', 'dependencies'),\n getLatestPackageVersion('orchid-orm', 'dependencies'),\n getLatestPackageVersion('pqb', 'dependencies'),\n config.addSchemaToZod &&\n getLatestPackageVersion('orchid-orm-schema-to-zod', 'dependencies'),\n getLatestPackageVersion('rake-db', 'devDependencies'),\n config.addTestFactory &&\n getLatestPackageVersion('orchid-orm-test-factory', 'devDependencies'),\n config.swc && getLatestPackageVersion('@swc/core', 'devDependencies'),\n getLatestPackageVersion('@types/node', 'devDependencies'),\n getLatestPackageVersion('ts-node', 'devDependencies'),\n getLatestPackageVersion('typescript', 'devDependencies'),\n ]);\n\n const deps: Record<string, string> = {};\n const devDeps: Record<string, string> = {};\n for (const item of pairs) {\n if (!item) continue;\n const [key, { version, kind }] = item;\n (kind === 'dependencies' ? deps : devDeps)[key] = version;\n }\n\n const packageJsonPath = join(config.path, 'package.json');\n const content = await readFileSafe(packageJsonPath);\n const json = content ? JSON.parse(content) : {};\n\n if (!json.scripts) json.scripts = {};\n json.scripts.db = 'ts-node src/db/dbScript.ts';\n\n if (!json.dependencies) json.dependencies = {};\n\n for (const key in deps) {\n json.dependencies[key] = deps[key];\n }\n\n if (!json.devDependencies) json.devDependencies = {};\n for (const key in devDeps) {\n json.devDependencies[key] = devDeps[key];\n }\n\n await fs.writeFile(packageJsonPath, JSON.stringify(json, null, ' ') + '\\n');\n};\n\nconst getLatestPackageVersion = (\n name: string,\n kind: DependencyKind,\n): Promise<[string, { version: string; kind: DependencyKind }]> => {\n return new Promise((resolve, reject) => {\n https\n .get(`https://registry.npmjs.org/${name}/latest`, (res) => {\n let data = '';\n res.on('data', (chunk) => (data += chunk));\n res.on('end', () =>\n resolve([name, { version: `^${JSON.parse(data).version}`, kind }]),\n );\n })\n .on('error', reject);\n });\n};\n\nconst readFileSafe = async (path: string) => {\n try {\n return await fs.readFile(path, 'utf-8');\n } catch (err) {\n if ((err as unknown as { code: string }).code === 'ENOENT') {\n return undefined;\n }\n throw err;\n }\n};\n\nconst setupTSConfig = async (config: InitConfig) => {\n if (config.hasTsConfig) return;\n\n const tsConfigPath = join(config.path, 'tsconfig.json');\n await fs.writeFile(\n tsConfigPath,\n `{${\n config.swc\n ? `\n \"ts-node\": {\n \"swc\": true\n },`\n : ''\n }\n \"compilerOptions\": {\n \"strict\": true\n }\n}\n`,\n );\n};\n\nconst setupEnv = async (config: InitConfig) => {\n const envPath = join(config.path, '.env');\n let content = ((await readFileSafe(envPath)) || '').trim();\n let changed = false;\n\n if (!content.match(/^DATABASE_URL=/m)) {\n content += `\\nDATABASE_URL=postgres://user:password@localhost:5432/dbname?ssl=false`;\n changed = true;\n }\n\n if (config.testDatabase && !content.match(/^DATABASE_TEST_URL=/m)) {\n content += `\\nDATABASE_TEST_URL=postgres://user:password@localhost:5432/dbname-test?ssl=false`;\n changed = true;\n }\n\n if (changed) {\n await fs.writeFile(envPath, `${content.trim()}\\n`);\n }\n};\n\nconst setupGitIgnore = async (config: InitConfig) => {\n const gitignorePath = join(config.path, '.gitignore');\n let content = ((await readFileSafe(gitignorePath)) || '').trim();\n let changed = false;\n\n if (!content.match(/^node_modules\\b/m)) {\n content += `\\nnode_modules`;\n changed = true;\n }\n\n if (!content.match(/^.env\\b/m)) {\n content += `\\n.env`;\n changed = true;\n }\n\n if (changed) {\n await fs.writeFile(gitignorePath, `${content.trim()}\\n`);\n }\n};\n\nconst setupBaseTable = async (config: InitConfig, dirPath: string) => {\n const filePath = join(dirPath, 'baseTable.ts');\n\n let content = `import { createBaseTable } from 'orchid-orm';${\n config.addSchemaToZod\n ? `\\nimport { zodSchemaProvider } from 'orchid-orm-schema-to-zod';`\n : ''\n }\n\nexport const BaseTable = createBaseTable({\n columnTypes: (t) => ({\n ...t,\n text: (min = 0, max = Infinity) => t.text(min, max),`;\n\n const { timestamp } = config;\n if (timestamp) {\n content += `\n timestamp: <P extends number>(precision?: P) =>\n t.timestamp<P>(precision).${\n timestamp === 'date' ? 'asDate' : 'asNumber'\n }(),`;\n }\n\n content += `\n }),${\n config.addSchemaToZod\n ? `\n schemaProvider: zodSchemaProvider,`\n : ''\n }\n});\n`;\n\n await fs.writeFile(filePath, content);\n};\n\nconst setupTables = async (config: InitConfig, dirPath: string) => {\n if (!config.demoTables) return;\n\n const tablesDir = join(dirPath, 'tables');\n await fs.mkdir(tablesDir, { recursive: true });\n\n await fs.writeFile(\n join(tablesDir, 'post.table.ts'),\n `import { TableType } from 'orchid-orm';\nimport { BaseTable } from '../baseTable';\nimport { CommentTable } from './comment.table';\n\nexport type Post = TableType<PostTable>;\nexport class PostTable extends BaseTable {\n readonly table = 'post';\n columns = this.setColumns((t) => ({\n id: t.identity().primaryKey(),\n title: t.text(3, 100).unique(),\n text: t.text(20, 10000),\n ...t.timestamps(),\n }));\n\n relations = {\n comments: this.hasMany(() => CommentTable, {\n primaryKey: 'id',\n foreignKey: 'postId',\n }),\n };\n}\n`,\n );\n\n await fs.writeFile(\n join(tablesDir, 'comment.table.ts'),\n `import { TableType } from 'orchid-orm';\nimport { BaseTable } from '../baseTable';\nimport { PostTable } from './post.table';\n\nexport type Comment = TableType<CommentTable>;\nexport class CommentTable extends BaseTable {\n readonly table = 'comment';\n columns = this.setColumns((t) => ({\n id: t.identity().primaryKey(),\n postId: t\n .integer()\n .foreignKey(() => PostTable, 'id')\n .index(),\n text: t.text(5, 1000),\n ...t.timestamps(),\n }));\n\n relations = {\n post: this.belongsTo(() => PostTable, {\n primaryKey: 'id',\n foreignKey: 'postId',\n }),\n };\n}\n`,\n );\n};\n\nconst setupConfig = async (config: InitConfig, dirPath: string) => {\n const configPath = join(dirPath, 'config.ts');\n\n let content = `import 'dotenv/config';\n\nconst database = {\n databaseURL: process.env.DATABASE_URL,\n};\nif (!database.databaseURL) throw new Error('DATABASE_URL is missing in .env');`;\n\n if (config.testDatabase) {\n content += `\n\nconst testDatabase = {\n databaseURL: process.env.DATABASE_TEST_URL,\n};\n\nconst allDatabases = [database];\n\nif (testDatabase.databaseURL) {\n allDatabases.push(testDatabase);\n}`;\n }\n\n content += `\n\nexport const config = {`;\n\n if (config.testDatabase) {\n content += `\n allDatabases,`;\n }\n\n if (config.testDatabase) {\n content += `\n database: process.env.NODE_ENV === 'test' ? testDatabase : database,`;\n } else {\n content += `\n database,`;\n }\n content += `\n};\n`;\n\n await fs.writeFile(configPath, content);\n};\n\nconst setupMainDb = async (config: InitConfig, dirPath: string) => {\n let imports = '';\n let tables = '';\n if (config.demoTables) {\n imports += `\nimport { PostTable } from './tables/post.table';\nimport { CommentTable } from './tables/comment.table';`;\n tables += `\n post: PostTable,\n comment: CommentTable,`;\n }\n\n const dbPath = join(dirPath, 'db.ts');\n await fs.writeFile(\n dbPath,\n `import { orchidORM } from 'orchid-orm';\nimport { config } from './config';${imports}\n\nexport const db = orchidORM(config.database, {${tables}\n});\n`,\n );\n};\n\nconst setupMigrationScript = async (config: InitConfig, dirPath: string) => {\n const filePath = join(dirPath, 'dbScript.ts');\n await fs.writeFile(\n filePath,\n `import { rakeDb } from 'rake-db';\nimport { appCodeUpdater } from 'orchid-orm/codegen';\nimport { config } from './config';\nimport { BaseTable } from './baseTable';\n\nexport const change = rakeDb(${\n config.testDatabase ? 'config.allDatabases' : 'config.database'\n }, {\n baseTable: BaseTable,\n migrationsPath: './migrations',\n appCodeUpdater: appCodeUpdater({\n tablePath: (tableName) => \\`./tables/\\${tableName}.table.ts\\`,\n ormPath: './db.ts',\n }),\n useCodeUpdater: true, // set to false to disable code updater\n commands: {\n async seed() {\n const { seed } = await import('./seed');\n await seed();\n },\n },\n import: (path) => import(path),\n});\n`,\n );\n};\n\nconst createMigrations = async (config: InitConfig, dirPath: string) => {\n const migrationsPath = join(dirPath, 'migrations');\n await fs.mkdir(migrationsPath, { recursive: true });\n\n if (!config.demoTables) return;\n\n const now = new Date();\n\n const postPath = join(\n migrationsPath,\n `${makeFileTimeStamp(now)}_createPost.ts`,\n );\n await fs.writeFile(\n postPath,\n `import { change } from '../dbScript';\n\nchange(async (db) => {\n await db.createTable('post', (t) => ({\n id: t.identity().primaryKey(),\n title: t.text().unique(),\n text: t.text(),\n ...t.timestamps(),\n }));\n});\n`,\n );\n\n now.setTime(now.getTime() + 1000);\n\n const commentPath = join(\n migrationsPath,\n `${makeFileTimeStamp(now)}_createComment.ts`,\n );\n await fs.writeFile(\n commentPath,\n `import { change } from '../dbScript';\n\nchange(async (db) => {\n await db.createTable('comment', (t) => ({\n id: t.identity().primaryKey(),\n postId: t.integer().foreignKey('post', 'id').index(),\n text: t.text(),\n ...t.timestamps(),\n }));\n});\n`,\n );\n};\n\nconst makeFileTimeStamp = (now: Date) => {\n return [\n now.getUTCFullYear(),\n now.getUTCMonth() + 1,\n now.getUTCDate(),\n now.getUTCHours(),\n now.getUTCMinutes(),\n now.getUTCSeconds(),\n ]\n .map((value) => (value < 10 ? `0${value}` : value))\n .join('');\n};\n\nconst createSeed = async (config: InitConfig, dirPath: string) => {\n const filePath = join(dirPath, 'seed.ts');\n\n let content;\n if (config.demoTables) {\n content = `await db.post.findBy({ title: 'Sample post' }).orCreate({\n title: 'Post',\n text: 'This is a text for a sample post. It contains words, spaces, and punctuation.',\n comments: {\n create: [\n {\n text: 'Nice post!',\n },\n {\n text: \\`Too long, didn't read\\`,\n },\n ],\n },\n });`;\n } else {\n content = `// create records here`;\n }\n\n await fs.writeFile(\n filePath,\n `import { db } from './db';\n\nexport const seed = async () => {\n ${content}\n\n await db.$close();\n};\n`,\n );\n};\n\nconst greet = (config: InitConfig) => {\n const relativePath = relative(process.cwd(), config.path);\n\n console.log(`\nThank you for trying Orchid ORM!\n \nTo finish setup,${\n relativePath ? ` cd to the project and` : ''\n } install dependencies:\n${\n relativePath\n ? `\n> cd ${relativePath}`\n : ''\n}\n> npm i\n\nEnter the correct database credentials to the .env file,\nthen create the database:\n\n> npm run db create\n\nAnd run the migrations:\n\n> npm run db migrate\n`);\n};\n","import { askOrchidORMConfig, initOrchidORM } from './init';\n\naskOrchidORMConfig().then((config) => {\n if (config) initOrchidORM(config);\n});\n"],"names":["join","resolve","relative"],"mappings":";;;;;;;;AAkBO,MAAM,qBAAqB,YAAY;AAC5C,EAAA,IAAI,SAAY,GAAA,KAAA,CAAA;AAEhB,EAAA,MAAM,WAAW,MAAM,OAAA;AAAA,IACrB;AAAA,MACE;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,IAAM,EAAA,MAAA;AAAA,QACN,OAAS,EAAA,6CAAA;AAAA,QACT,OAAA,EAAS,QAAQ,GAAI,EAAA;AAAA,OACvB;AAAA,MACA;AAA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