relq 1.0.2 → 1.0.3
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/cjs/cli/commands/add.cjs +403 -27
- package/dist/cjs/cli/commands/branch.cjs +13 -23
- package/dist/cjs/cli/commands/checkout.cjs +16 -29
- package/dist/cjs/cli/commands/cherry-pick.cjs +3 -4
- package/dist/cjs/cli/commands/commit.cjs +21 -29
- package/dist/cjs/cli/commands/diff.cjs +28 -32
- package/dist/cjs/cli/commands/export.cjs +7 -7
- package/dist/cjs/cli/commands/fetch.cjs +15 -21
- package/dist/cjs/cli/commands/generate.cjs +28 -54
- package/dist/cjs/cli/commands/history.cjs +19 -40
- package/dist/cjs/cli/commands/import.cjs +34 -41
- package/dist/cjs/cli/commands/init.cjs +69 -59
- package/dist/cjs/cli/commands/introspect.cjs +4 -8
- package/dist/cjs/cli/commands/log.cjs +26 -32
- package/dist/cjs/cli/commands/merge.cjs +24 -41
- package/dist/cjs/cli/commands/migrate.cjs +12 -25
- package/dist/cjs/cli/commands/pull.cjs +216 -106
- package/dist/cjs/cli/commands/push.cjs +35 -75
- package/dist/cjs/cli/commands/remote.cjs +2 -1
- package/dist/cjs/cli/commands/reset.cjs +22 -43
- package/dist/cjs/cli/commands/resolve.cjs +12 -14
- package/dist/cjs/cli/commands/rollback.cjs +16 -38
- package/dist/cjs/cli/commands/stash.cjs +5 -7
- package/dist/cjs/cli/commands/status.cjs +5 -10
- package/dist/cjs/cli/commands/sync.cjs +30 -50
- package/dist/cjs/cli/commands/tag.cjs +3 -4
- package/dist/cjs/cli/index.cjs +72 -9
- package/dist/cjs/cli/utils/change-tracker.cjs +107 -3
- package/dist/cjs/cli/utils/cli-utils.cjs +217 -0
- package/dist/cjs/cli/utils/config-loader.cjs +34 -8
- package/dist/cjs/cli/utils/fast-introspect.cjs +109 -3
- package/dist/cjs/cli/utils/git-utils.cjs +42 -161
- package/dist/cjs/cli/utils/pool-manager.cjs +156 -0
- package/dist/cjs/cli/utils/project-root.cjs +56 -5
- package/dist/cjs/cli/utils/relqignore.cjs +1 -0
- package/dist/cjs/cli/utils/repo-manager.cjs +47 -0
- package/dist/cjs/cli/utils/schema-comparator.cjs +301 -11
- package/dist/cjs/cli/utils/schema-diff.cjs +202 -1
- package/dist/cjs/cli/utils/schema-hash.cjs +2 -1
- package/dist/cjs/cli/utils/schema-introspect.cjs +7 -3
- package/dist/cjs/cli/utils/snapshot-manager.cjs +1 -0
- package/dist/cjs/cli/utils/spinner.cjs +14 -106
- package/dist/cjs/cli/utils/sql-generator.cjs +1 -1
- package/dist/cjs/cli/utils/type-generator.cjs +28 -16
- package/dist/config.d.ts +16 -25
- package/dist/esm/cli/commands/add.js +372 -29
- package/dist/esm/cli/commands/branch.js +14 -24
- package/dist/esm/cli/commands/checkout.js +16 -29
- package/dist/esm/cli/commands/cherry-pick.js +3 -4
- package/dist/esm/cli/commands/commit.js +22 -30
- package/dist/esm/cli/commands/diff.js +6 -10
- package/dist/esm/cli/commands/export.js +8 -8
- package/dist/esm/cli/commands/fetch.js +14 -20
- package/dist/esm/cli/commands/generate.js +28 -54
- package/dist/esm/cli/commands/history.js +11 -32
- package/dist/esm/cli/commands/import.js +35 -42
- package/dist/esm/cli/commands/init.js +65 -55
- package/dist/esm/cli/commands/introspect.js +4 -8
- package/dist/esm/cli/commands/log.js +6 -12
- package/dist/esm/cli/commands/merge.js +20 -37
- package/dist/esm/cli/commands/migrate.js +12 -25
- package/dist/esm/cli/commands/pull.js +204 -94
- package/dist/esm/cli/commands/push.js +21 -61
- package/dist/esm/cli/commands/remote.js +2 -1
- package/dist/esm/cli/commands/reset.js +16 -37
- package/dist/esm/cli/commands/resolve.js +13 -15
- package/dist/esm/cli/commands/rollback.js +16 -38
- package/dist/esm/cli/commands/stash.js +6 -8
- package/dist/esm/cli/commands/status.js +6 -11
- package/dist/esm/cli/commands/sync.js +30 -50
- package/dist/esm/cli/commands/tag.js +3 -4
- package/dist/esm/cli/index.js +72 -9
- package/dist/esm/cli/utils/change-tracker.js +107 -3
- package/dist/esm/cli/utils/cli-utils.js +169 -0
- package/dist/esm/cli/utils/config-loader.js +34 -8
- package/dist/esm/cli/utils/fast-introspect.js +109 -3
- package/dist/esm/cli/utils/git-utils.js +2 -124
- package/dist/esm/cli/utils/pool-manager.js +114 -0
- package/dist/esm/cli/utils/project-root.js +55 -5
- package/dist/esm/cli/utils/relqignore.js +1 -0
- package/dist/esm/cli/utils/repo-manager.js +42 -0
- package/dist/esm/cli/utils/schema-comparator.js +301 -11
- package/dist/esm/cli/utils/schema-diff.js +202 -1
- package/dist/esm/cli/utils/schema-hash.js +2 -1
- package/dist/esm/cli/utils/schema-introspect.js +7 -3
- package/dist/esm/cli/utils/snapshot-manager.js +1 -0
- package/dist/esm/cli/utils/spinner.js +1 -101
- package/dist/esm/cli/utils/sql-generator.js +1 -1
- package/dist/esm/cli/utils/type-generator.js +28 -16
- package/dist/index.d.ts +25 -8
- package/dist/schema-builder.d.ts +16 -6
- package/package.json +1 -1
|
@@ -1,108 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colors = void 0;
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
const render = () => {
|
|
19
|
-
if (!isSpinning)
|
|
20
|
-
return;
|
|
21
|
-
clearLine();
|
|
22
|
-
const frame = SPINNER_FRAMES[frameIndex];
|
|
23
|
-
process.stdout.write(`\x1b[36m${frame}\x1b[0m ${currentMessage}`);
|
|
24
|
-
frameIndex = (frameIndex + 1) % SPINNER_FRAMES.length;
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
start(message) {
|
|
28
|
-
if (isSpinning)
|
|
29
|
-
this.stop();
|
|
30
|
-
currentMessage = message;
|
|
31
|
-
isSpinning = true;
|
|
32
|
-
frameIndex = 0;
|
|
33
|
-
intervalId = setInterval(render, SPINNER_INTERVAL);
|
|
34
|
-
render();
|
|
35
|
-
},
|
|
36
|
-
update(message) {
|
|
37
|
-
currentMessage = message;
|
|
38
|
-
},
|
|
39
|
-
succeed(message) {
|
|
40
|
-
this.stop();
|
|
41
|
-
console.log(`\x1b[32m✓\x1b[0m ${message || currentMessage}`);
|
|
42
|
-
},
|
|
43
|
-
fail(message) {
|
|
44
|
-
this.stop();
|
|
45
|
-
console.log(`\x1b[31m✗\x1b[0m ${message || currentMessage}`);
|
|
46
|
-
},
|
|
47
|
-
info(message) {
|
|
48
|
-
this.stop();
|
|
49
|
-
console.log(`\x1b[34mℹ\x1b[0m ${message || currentMessage}`);
|
|
50
|
-
},
|
|
51
|
-
warn(message) {
|
|
52
|
-
this.stop();
|
|
53
|
-
console.log(`\x1b[33m⚠\x1b[0m ${message || currentMessage}`);
|
|
54
|
-
},
|
|
55
|
-
stop() {
|
|
56
|
-
if (intervalId) {
|
|
57
|
-
clearInterval(intervalId);
|
|
58
|
-
intervalId = null;
|
|
59
|
-
}
|
|
60
|
-
if (isSpinning) {
|
|
61
|
-
clearLine();
|
|
62
|
-
isSpinning = false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
exports.colors = {
|
|
68
|
-
reset: '\x1b[0m',
|
|
69
|
-
bold: (text) => `\x1b[1m${text}\x1b[0m`,
|
|
70
|
-
dim: (text) => `\x1b[2m${text}\x1b[0m`,
|
|
71
|
-
red: (text) => `\x1b[31m${text}\x1b[0m`,
|
|
72
|
-
green: (text) => `\x1b[32m${text}\x1b[0m`,
|
|
73
|
-
yellow: (text) => `\x1b[33m${text}\x1b[0m`,
|
|
74
|
-
blue: (text) => `\x1b[34m${text}\x1b[0m`,
|
|
75
|
-
magenta: (text) => `\x1b[35m${text}\x1b[0m`,
|
|
76
|
-
cyan: (text) => `\x1b[36m${text}\x1b[0m`,
|
|
77
|
-
gray: (text) => `\x1b[90m${text}\x1b[0m`,
|
|
78
|
-
white: (text) => `\x1b[37m${text}\x1b[0m`,
|
|
79
|
-
success: (text) => `\x1b[32m${text}\x1b[0m`,
|
|
80
|
-
error: (text) => `\x1b[31m${text}\x1b[0m`,
|
|
81
|
-
warning: (text) => `\x1b[33m${text}\x1b[0m`,
|
|
82
|
-
info: (text) => `\x1b[34m${text}\x1b[0m`,
|
|
83
|
-
muted: (text) => `\x1b[90m${text}\x1b[0m`,
|
|
84
|
-
};
|
|
85
|
-
function progressBar(current, total, width = 30) {
|
|
86
|
-
const percentage = Math.min(100, Math.round((current / total) * 100));
|
|
87
|
-
const filled = Math.round((percentage / 100) * width);
|
|
88
|
-
const empty = width - filled;
|
|
89
|
-
const bar = '█'.repeat(filled) + '░'.repeat(empty);
|
|
90
|
-
return `\x1b[36m${bar}\x1b[0m ${percentage}%`;
|
|
91
|
-
}
|
|
92
|
-
function formatBytes(bytes) {
|
|
93
|
-
if (bytes === 0)
|
|
94
|
-
return '0 B';
|
|
95
|
-
const k = 1024;
|
|
96
|
-
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
97
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
98
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
99
|
-
}
|
|
100
|
-
function formatDuration(ms) {
|
|
101
|
-
if (ms < 1000)
|
|
102
|
-
return `${ms}ms`;
|
|
103
|
-
if (ms < 60000)
|
|
104
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
105
|
-
const minutes = Math.floor(ms / 60000);
|
|
106
|
-
const seconds = Math.round((ms % 60000) / 1000);
|
|
107
|
-
return `${minutes}m ${seconds}s`;
|
|
108
|
-
}
|
|
3
|
+
exports.success = exports.confirm = exports.requireInit = exports.hint = exports.warning = exports.error = exports.fatal = exports.formatDuration = exports.formatBytes = exports.progressBar = exports.createSpinner = exports.colors = void 0;
|
|
4
|
+
var cli_utils_1 = require("./cli-utils.cjs");
|
|
5
|
+
Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return cli_utils_1.colors; } });
|
|
6
|
+
Object.defineProperty(exports, "createSpinner", { enumerable: true, get: function () { return cli_utils_1.createSpinner; } });
|
|
7
|
+
Object.defineProperty(exports, "progressBar", { enumerable: true, get: function () { return cli_utils_1.progressBar; } });
|
|
8
|
+
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return cli_utils_1.formatBytes; } });
|
|
9
|
+
Object.defineProperty(exports, "formatDuration", { enumerable: true, get: function () { return cli_utils_1.formatDuration; } });
|
|
10
|
+
Object.defineProperty(exports, "fatal", { enumerable: true, get: function () { return cli_utils_1.fatal; } });
|
|
11
|
+
Object.defineProperty(exports, "error", { enumerable: true, get: function () { return cli_utils_1.error; } });
|
|
12
|
+
Object.defineProperty(exports, "warning", { enumerable: true, get: function () { return cli_utils_1.warning; } });
|
|
13
|
+
Object.defineProperty(exports, "hint", { enumerable: true, get: function () { return cli_utils_1.hint; } });
|
|
14
|
+
Object.defineProperty(exports, "requireInit", { enumerable: true, get: function () { return cli_utils_1.requireInit; } });
|
|
15
|
+
Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return cli_utils_1.confirm; } });
|
|
16
|
+
Object.defineProperty(exports, "success", { enumerable: true, get: function () { return cli_utils_1.success; } });
|
|
@@ -340,7 +340,7 @@ function generateIndexSQL(index, tableName) {
|
|
|
340
340
|
if (index.expression) {
|
|
341
341
|
parts.push(`(${index.expression})`);
|
|
342
342
|
}
|
|
343
|
-
else if (index.columns && index.columns.length > 0) {
|
|
343
|
+
else if (index.columns && Array.isArray(index.columns) && index.columns.length > 0) {
|
|
344
344
|
const cols = index.columns.map(c => quoteColumnRef(c)).join(', ');
|
|
345
345
|
parts.push(`(${cols})`);
|
|
346
346
|
}
|
|
@@ -703,8 +703,18 @@ function formatDefaultValue(val, col, domainMap) {
|
|
|
703
703
|
}
|
|
704
704
|
if (cleaned === "'[]'" || cleaned === 'ARRAY[]')
|
|
705
705
|
return 'emptyArray()';
|
|
706
|
+
const isJsonColumn = col.dataType.toLowerCase().includes('json');
|
|
707
|
+
if (isJsonColumn && cleaned.startsWith("'") && cleaned.endsWith("'")) {
|
|
708
|
+
const jsonStr = cleaned.slice(1, -1).replace(/''/g, "'");
|
|
709
|
+
try {
|
|
710
|
+
const parsed = JSON.parse(jsonStr);
|
|
711
|
+
return JSON.stringify(parsed);
|
|
712
|
+
}
|
|
713
|
+
catch {
|
|
714
|
+
}
|
|
715
|
+
}
|
|
706
716
|
const pgArrayMatch = cleaned.match(/^'?\{([^}]*)\}'?$/);
|
|
707
|
-
if (pgArrayMatch) {
|
|
717
|
+
if (pgArrayMatch && !isJsonColumn) {
|
|
708
718
|
const contents = pgArrayMatch[1];
|
|
709
719
|
if (contents === '') {
|
|
710
720
|
return 'emptyArray()';
|
|
@@ -739,16 +749,6 @@ function formatDefaultValue(val, col, domainMap) {
|
|
|
739
749
|
}
|
|
740
750
|
return 'emptyArray()';
|
|
741
751
|
}
|
|
742
|
-
const isJsonColumn = col.dataType.toLowerCase().includes('json');
|
|
743
|
-
if (isJsonColumn && cleaned.startsWith("'") && cleaned.endsWith("'")) {
|
|
744
|
-
const jsonStr = cleaned.slice(1, -1).replace(/''/g, "'");
|
|
745
|
-
try {
|
|
746
|
-
const parsed = JSON.parse(jsonStr);
|
|
747
|
-
return JSON.stringify(parsed);
|
|
748
|
-
}
|
|
749
|
-
catch {
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
752
|
if (cleaned.startsWith("'") && cleaned.endsWith("'")) {
|
|
753
753
|
const str = cleaned.slice(1, -1).replace(/'/g, "\\'");
|
|
754
754
|
return `'${str}'`;
|
|
@@ -1432,6 +1432,17 @@ function parseCheckValue(value, camelCase) {
|
|
|
1432
1432
|
if (/^-?\d+(\.\d+)?$/.test(value)) {
|
|
1433
1433
|
return value;
|
|
1434
1434
|
}
|
|
1435
|
+
const castMatch = value.match(/^\(?(.+?)\)?::[a-z_][a-z0-9_]*(\[\])?$/i);
|
|
1436
|
+
if (castMatch) {
|
|
1437
|
+
const innerValue = castMatch[1].trim();
|
|
1438
|
+
if (/^-?\d+(\.\d+)?$/.test(innerValue)) {
|
|
1439
|
+
return innerValue;
|
|
1440
|
+
}
|
|
1441
|
+
if (/^'.*'$/.test(innerValue)) {
|
|
1442
|
+
return innerValue;
|
|
1443
|
+
}
|
|
1444
|
+
return parseCheckValue(innerValue, camelCase);
|
|
1445
|
+
}
|
|
1435
1446
|
if (/^TRUE$/i.test(value))
|
|
1436
1447
|
return 'true';
|
|
1437
1448
|
if (/^FALSE$/i.test(value))
|
|
@@ -1553,16 +1564,17 @@ function generateDefineTable(table, camelCase = true, childPartitions, enumNames
|
|
|
1553
1564
|
if (enumMatch) {
|
|
1554
1565
|
const colName = enumMatch[1];
|
|
1555
1566
|
const valuesStr = enumMatch[2];
|
|
1556
|
-
const values = valuesStr
|
|
1557
|
-
.match(/'([^']+)'/g)
|
|
1558
|
-
?.map(v => v.replace(/'/g, '')) || [];
|
|
1567
|
+
const values = valuesStr.match(/'([^']+)'/g)?.map(v => v.replace(/'/g, '')) || [];
|
|
1559
1568
|
if (values.length > 0) {
|
|
1560
|
-
columnChecks.set(colName
|
|
1569
|
+
columnChecks.set(colName, values);
|
|
1561
1570
|
}
|
|
1562
1571
|
}
|
|
1563
1572
|
}
|
|
1564
1573
|
const columns = table.columns
|
|
1565
|
-
.map(col =>
|
|
1574
|
+
.map(col => {
|
|
1575
|
+
const checkValues = columnChecks.get(col.name);
|
|
1576
|
+
return generateColumnDef(col, seenColumns, camelCase, checkValues, enumNames, domainNames, compositeNames, domainMap);
|
|
1577
|
+
})
|
|
1566
1578
|
.filter(Boolean);
|
|
1567
1579
|
const columnNames = Array.from(seenColumns);
|
|
1568
1580
|
const indexesFn = table.indexes ? generateIndexes(table.indexes, columnNames, camelCase) : null;
|
package/dist/config.d.ts
CHANGED
|
@@ -387,13 +387,23 @@ export type BuildSelectType<T extends Record<string, ColumnConfig>> = {
|
|
|
387
387
|
} & {
|
|
388
388
|
[K in keyof T as IsRequiredForSelect<T[K]> extends true ? never : K]?: T[K] extends ColumnConfig<infer U> ? U | null : unknown;
|
|
389
389
|
};
|
|
390
|
-
export type
|
|
391
|
-
[K in keyof T
|
|
390
|
+
export type RequiredInsertKeys<T extends Record<string, ColumnConfig>> = {
|
|
391
|
+
[K in keyof T]: IsRequiredForInsert<T[K]> extends true ? K : never;
|
|
392
|
+
}[keyof T];
|
|
393
|
+
export type OptionalInsertKeys<T extends Record<string, ColumnConfig>> = {
|
|
394
|
+
[K in keyof T]: IsRequiredForInsert<T[K]> extends true ? never : K;
|
|
395
|
+
}[keyof T];
|
|
396
|
+
export type InferInsertValue<C extends ColumnConfig> = C extends ColumnConfig<infer U> ? C extends {
|
|
397
|
+
$nullable: true;
|
|
398
|
+
} ? U | null : U : unknown;
|
|
399
|
+
export type Simplify<T> = {
|
|
400
|
+
[K in keyof T]: T[K];
|
|
401
|
+
} & {};
|
|
402
|
+
export type BuildInsertType<T extends Record<string, ColumnConfig>> = Simplify<{
|
|
403
|
+
[K in RequiredInsertKeys<T>]: InferInsertValue<T[K]>;
|
|
392
404
|
} & {
|
|
393
|
-
[K in
|
|
394
|
-
|
|
395
|
-
} ? U | null : U : unknown;
|
|
396
|
-
};
|
|
405
|
+
[K in OptionalInsertKeys<T>]?: InferInsertValue<T[K]>;
|
|
406
|
+
}>;
|
|
397
407
|
export interface TableDefinition<T extends Record<string, ColumnConfig>> {
|
|
398
408
|
$name: string;
|
|
399
409
|
$schema?: string;
|
|
@@ -632,24 +642,5 @@ export declare function validateConfig(config: RelqConfig): {
|
|
|
632
642
|
valid: boolean;
|
|
633
643
|
errors: string[];
|
|
634
644
|
};
|
|
635
|
-
interface Blob$1 extends BunConsumerConvenienceMethods {
|
|
636
|
-
// We have to specify bytes again even though it comes from
|
|
637
|
-
// BunConsumerConvenienceMethods, because inheritance in TypeScript is
|
|
638
|
-
// slightly different from just "copying in the methods" (the difference is
|
|
639
|
-
// related to how type parameters are resolved)
|
|
640
|
-
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
641
|
-
/**
|
|
642
|
-
* Consume the blob as a FormData instance
|
|
643
|
-
*/
|
|
644
|
-
formData(): Promise<FormData>;
|
|
645
|
-
/**
|
|
646
|
-
* Consume the blob as an ArrayBuffer
|
|
647
|
-
*/
|
|
648
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
649
|
-
/**
|
|
650
|
-
* Returns a readable stream of the blob's contents
|
|
651
|
-
*/
|
|
652
|
-
stream(): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
653
|
-
}
|
|
654
645
|
|
|
655
646
|
export {};
|