relq 1.0.85 → 1.0.87
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/export.cjs +2 -2
- package/dist/cjs/cli/commands/generate.cjs +2 -2
- package/dist/cjs/cli/commands/import.cjs +2 -2
- package/dist/cjs/cli/commands/init.cjs +2 -2
- package/dist/cjs/cli/commands/introspect.cjs +2 -2
- package/dist/cjs/cli/commands/migrate.cjs +2 -2
- package/dist/cjs/cli/commands/pull.cjs +2 -2
- package/dist/cjs/cli/commands/push.cjs +2 -2
- package/dist/cjs/cli/commands/rollback.cjs +2 -2
- package/dist/cjs/cli/commands/seed.cjs +2 -2
- package/dist/cjs/cli/commands/status.cjs +2 -2
- package/dist/cjs/cli/commands/validate.cjs +1 -1
- package/dist/cjs/cli/utils/change-tracker.cjs +1 -1
- package/dist/cjs/cli/utils/commit-manager.cjs +3 -3
- package/dist/cjs/cli/utils/config-loader.cjs +2 -2
- package/dist/cjs/cli/utils/context.cjs +2 -2
- package/dist/cjs/cli/utils/project-root.cjs +3 -3
- package/dist/cjs/cli/utils/relqignore.cjs +2 -2
- package/dist/cjs/cli/utils/repo-manager.cjs +3 -3
- package/dist/cjs/cli/utils/schema-hash.cjs +1 -1
- package/dist/cjs/cli/utils/schema-loader.cjs +2 -2
- package/dist/cjs/cli/utils/schema-validator.cjs +2 -2
- package/dist/cjs/cli/utils/snapshot-manager.cjs +2 -2
- package/dist/cjs/cli/utils/types-manager.cjs +2 -2
- package/dist/cjs/config/config.cjs +5 -1
- package/dist/cjs/config/env.cjs +7 -3
- package/dist/cjs/core/helpers/select-joins.cjs +8 -3
- package/dist/cjs/core/pg-family/shared/pg-base.cjs +5 -18
- package/dist/cjs/core/shared/cleanup.cjs +6 -2
- package/dist/cjs/errors/relq-errors.cjs +9 -5
- package/dist/cjs/pubsub/listener-connection.cjs +3 -3
- package/dist/cjs/utils/aws-dsql.cjs +8 -4
- package/dist/cjs/utils/env-resolver.cjs +19 -15
- package/dist/cjs/utils/environment-detection.cjs +27 -23
- package/dist/cjs/utils/pool-defaults.cjs +8 -23
- package/dist/esm/cli/commands/export.js +2 -2
- package/dist/esm/cli/commands/generate.js +2 -2
- package/dist/esm/cli/commands/import.js +2 -2
- package/dist/esm/cli/commands/init.js +2 -2
- package/dist/esm/cli/commands/introspect.js +2 -2
- package/dist/esm/cli/commands/migrate.js +2 -2
- package/dist/esm/cli/commands/pull.js +2 -2
- package/dist/esm/cli/commands/push.js +2 -2
- package/dist/esm/cli/commands/rollback.js +2 -2
- package/dist/esm/cli/commands/seed.js +2 -2
- package/dist/esm/cli/commands/status.js +2 -2
- package/dist/esm/cli/commands/validate.js +1 -1
- package/dist/esm/cli/utils/change-tracker.js +1 -1
- package/dist/esm/cli/utils/commit-manager.js +3 -3
- package/dist/esm/cli/utils/config-loader.js +2 -2
- package/dist/esm/cli/utils/context.js +2 -2
- package/dist/esm/cli/utils/project-root.js +3 -3
- package/dist/esm/cli/utils/relqignore.js +2 -2
- package/dist/esm/cli/utils/repo-manager.js +3 -3
- package/dist/esm/cli/utils/schema-hash.js +1 -1
- package/dist/esm/cli/utils/schema-loader.js +2 -2
- package/dist/esm/cli/utils/schema-validator.js +2 -2
- package/dist/esm/cli/utils/snapshot-manager.js +2 -2
- package/dist/esm/cli/utils/types-manager.js +2 -2
- package/dist/esm/config/config.js +1 -0
- package/dist/esm/config/env.js +1 -0
- package/dist/esm/core/helpers/select-joins.js +8 -3
- package/dist/esm/core/pg-family/shared/pg-base.js +6 -19
- package/dist/esm/core/shared/cleanup.js +1 -0
- package/dist/esm/errors/relq-errors.js +1 -0
- package/dist/esm/pubsub/listener-connection.js +1 -1
- package/dist/esm/utils/aws-dsql.js +1 -0
- package/dist/esm/utils/env-resolver.js +3 -2
- package/dist/esm/utils/environment-detection.js +1 -0
- package/dist/esm/utils/pool-defaults.js +8 -23
- package/dist/index.d.ts +71 -52
- package/package.json +1 -1
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const p = __importStar(require("@clack/prompts"));
|
|
40
40
|
const context_1 = require("../utils/context.cjs");
|
|
41
41
|
const colors_1 = require("../utils/colors.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const p = __importStar(require("@clack/prompts"));
|
|
40
40
|
const context_1 = require("../utils/context.cjs");
|
|
41
41
|
const colors_1 = require("../utils/colors.cjs");
|
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
36
|
+
const fs = __importStar(require("node:fs"));
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
38
|
const p = __importStar(require("@clack/prompts"));
|
|
39
39
|
const citty_1 = require("citty");
|
|
40
40
|
const sql_parser_1 = require("../utils/sql-parser.cjs");
|
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
36
|
+
const fs = __importStar(require("node:fs"));
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
38
|
const p = __importStar(require("@clack/prompts"));
|
|
39
39
|
const citty_1 = require("citty");
|
|
40
40
|
const env_loader_1 = require("../utils/env-loader.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const readline = __importStar(require("readline"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const readline = __importStar(require("node:readline"));
|
|
39
39
|
const context_1 = require("../utils/context.cjs");
|
|
40
40
|
const ui_1 = require("../utils/ui.cjs");
|
|
41
41
|
const index_1 = require("../../introspect/index.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const p = __importStar(require("@clack/prompts"));
|
|
40
40
|
const context_1 = require("../utils/context.cjs");
|
|
41
41
|
const colors_1 = require("../utils/colors.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.runPull = runPull;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const citty_1 = require("citty");
|
|
40
40
|
const p = __importStar(require("@clack/prompts"));
|
|
41
41
|
const context_1 = require("../utils/context.cjs");
|
|
@@ -35,8 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.runPush = runPush;
|
|
37
37
|
const citty_1 = require("citty");
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
40
|
const p = __importStar(require("@clack/prompts"));
|
|
41
41
|
const context_1 = require("../utils/context.cjs");
|
|
42
42
|
const colors_1 = require("../utils/colors.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const p = __importStar(require("@clack/prompts"));
|
|
40
40
|
const context_1 = require("../utils/context.cjs");
|
|
41
41
|
const colors_1 = require("../utils/colors.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const p = __importStar(require("@clack/prompts"));
|
|
40
40
|
const context_1 = require("../utils/context.cjs");
|
|
41
41
|
const colors_1 = require("../utils/colors.cjs");
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
39
|
const context_1 = require("../utils/context.cjs");
|
|
40
40
|
const colors_1 = require("../utils/colors.cjs");
|
|
41
41
|
const ui_1 = require("../utils/ui.cjs");
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const citty_1 = require("citty");
|
|
37
|
-
const path = __importStar(require("path"));
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
38
|
const context_1 = require("../utils/context.cjs");
|
|
39
39
|
const colors_1 = require("../utils/colors.cjs");
|
|
40
40
|
const config_loader_1 = require("../utils/config-loader.cjs");
|
|
@@ -40,7 +40,7 @@ exports.getChangeDisplayName = getChangeDisplayName;
|
|
|
40
40
|
exports.sortChangesByDependency = sortChangesByDependency;
|
|
41
41
|
exports.generateCombinedSQL = generateCombinedSQL;
|
|
42
42
|
exports.generateDownSQL = generateDownSQL;
|
|
43
|
-
const crypto = __importStar(require("crypto"));
|
|
43
|
+
const crypto = __importStar(require("node:crypto"));
|
|
44
44
|
function generateChangeId(type, objectType, objectName, parentName) {
|
|
45
45
|
const input = `${type}:${objectType}:${parentName || ''}:${objectName}:${Date.now()}`;
|
|
46
46
|
return crypto.createHash('sha1').update(input).digest('hex').substring(0, 12);
|
|
@@ -49,9 +49,9 @@ exports.checkSyncStatus = checkSyncStatus;
|
|
|
49
49
|
exports.generateASTHash = generateASTHash;
|
|
50
50
|
exports.createCommitFromSchema = createCommitFromSchema;
|
|
51
51
|
exports.createCommitFromSchemaWithRemote = createCommitFromSchemaWithRemote;
|
|
52
|
-
const fs = __importStar(require("fs"));
|
|
53
|
-
const path = __importStar(require("path"));
|
|
54
|
-
const crypto = __importStar(require("crypto"));
|
|
52
|
+
const fs = __importStar(require("node:fs"));
|
|
53
|
+
const path = __importStar(require("node:path"));
|
|
54
|
+
const crypto = __importStar(require("node:crypto"));
|
|
55
55
|
const config_1 = require("../../config/index.cjs");
|
|
56
56
|
const dialect_router_1 = require("./dialect-router.cjs");
|
|
57
57
|
const schema_hash_1 = require("./schema-hash.cjs");
|
|
@@ -44,8 +44,8 @@ exports.requireValidSchema = requireValidSchema;
|
|
|
44
44
|
const config_1 = require("../../config/config.cjs");
|
|
45
45
|
const ui_1 = require("./ui.cjs");
|
|
46
46
|
const env_loader_1 = require("./env-loader.cjs");
|
|
47
|
-
const fs = __importStar(require("fs"));
|
|
48
|
-
const path = __importStar(require("path"));
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
49
|
const CONFIG_FILENAMES = [
|
|
50
50
|
'relq.config.ts',
|
|
51
51
|
'relq.config.mjs',
|
|
@@ -35,8 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.loadEnvFile = loadEnvFile;
|
|
37
37
|
exports.buildContext = buildContext;
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
40
|
const project_root_1 = require("./project-root.cjs");
|
|
41
41
|
const config_loader_1 = require("./config-loader.cjs");
|
|
42
42
|
const ui_1 = require("./ui.cjs");
|
|
@@ -36,9 +36,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.findProjectRoot = findProjectRoot;
|
|
37
37
|
exports.getRelqDir = getRelqDir;
|
|
38
38
|
exports.getProjectRoot = getProjectRoot;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const os = __importStar(require("os"));
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
41
|
+
const os = __importStar(require("node:os"));
|
|
42
42
|
const CONFIG_FILENAMES = [
|
|
43
43
|
'relq.config.ts',
|
|
44
44
|
'relq.config.mjs',
|
|
@@ -56,8 +56,8 @@ exports.filterEnums = filterEnums;
|
|
|
56
56
|
exports.filterDomains = filterDomains;
|
|
57
57
|
exports.getIgnorePatterns = getIgnorePatterns;
|
|
58
58
|
exports.filterIgnored = filterIgnored;
|
|
59
|
-
const fs = __importStar(require("fs"));
|
|
60
|
-
const path = __importStar(require("path"));
|
|
59
|
+
const fs = __importStar(require("node:fs"));
|
|
60
|
+
const path = __importStar(require("node:path"));
|
|
61
61
|
const REQUIRES_PARENT = [
|
|
62
62
|
'COLUMN', 'INDEX', 'CONSTRAINT', 'CHECK', 'PRIMARY_KEY',
|
|
63
63
|
'FOREIGN_KEY', 'EXCLUSION', 'PARTITION', 'TRIGGER'
|
|
@@ -89,9 +89,9 @@ exports.loadTags = loadTags;
|
|
|
89
89
|
exports.saveTags = saveTags;
|
|
90
90
|
exports.resolveRef = resolveRef;
|
|
91
91
|
exports.loadParentCommit = loadParentCommit;
|
|
92
|
-
const fs = __importStar(require("fs"));
|
|
93
|
-
const path = __importStar(require("path"));
|
|
94
|
-
const crypto = __importStar(require("crypto"));
|
|
92
|
+
const fs = __importStar(require("node:fs"));
|
|
93
|
+
const path = __importStar(require("node:path"));
|
|
94
|
+
const crypto = __importStar(require("node:crypto"));
|
|
95
95
|
const config_1 = require("../../config/config.cjs");
|
|
96
96
|
const dialect_router_1 = require("./dialect-router.cjs");
|
|
97
97
|
const RELQ_DIR = '.relq';
|
|
@@ -37,7 +37,7 @@ exports.normalizeSchema = normalizeSchema;
|
|
|
37
37
|
exports.generateSchemaHash = generateSchemaHash;
|
|
38
38
|
exports.generateShortHash = generateShortHash;
|
|
39
39
|
exports.schemasMatch = schemasMatch;
|
|
40
|
-
const crypto = __importStar(require("crypto"));
|
|
40
|
+
const crypto = __importStar(require("node:crypto"));
|
|
41
41
|
function normalizeSchema(schema) {
|
|
42
42
|
const userTables = schema.tables.filter(t => !t.name.startsWith('_relq') &&
|
|
43
43
|
!t.name.startsWith('relq_'));
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.loadSchemaFile = loadSchemaFile;
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
39
|
const jiti_1 = require("jiti");
|
|
40
40
|
const schema_to_ast_1 = require("./schema-to-ast.cjs");
|
|
41
41
|
function hasMissingTrackingIds(ast) {
|
|
@@ -36,8 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.validateSchemaFile = validateSchemaFile;
|
|
37
37
|
exports.formatValidationErrors = formatValidationErrors;
|
|
38
38
|
const ts = __importStar(require("typescript"));
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
41
41
|
function validateSchemaFile(schemaPath) {
|
|
42
42
|
const absolutePath = path.resolve(schemaPath);
|
|
43
43
|
if (!fs.existsSync(absolutePath)) {
|
|
@@ -42,8 +42,8 @@ exports.listBackups = listBackups;
|
|
|
42
42
|
exports.restoreBackup = restoreBackup;
|
|
43
43
|
exports.addMigrationToSnapshot = addMigrationToSnapshot;
|
|
44
44
|
exports.getAppliedMigrations = getAppliedMigrations;
|
|
45
|
-
const fs = __importStar(require("fs"));
|
|
46
|
-
const path = __importStar(require("path"));
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
47
|
const SNAPSHOT_VERSION = 1;
|
|
48
48
|
const DEFAULT_SNAPSHOT_PATH = '.relq/snapshot.json';
|
|
49
49
|
function loadSnapshot(snapshotPath) {
|
|
@@ -51,8 +51,8 @@ exports.isValidTypesFilePath = isValidTypesFilePath;
|
|
|
51
51
|
exports.getTypesFilePath = getTypesFilePath;
|
|
52
52
|
exports.syncTypesToDb = syncTypesToDb;
|
|
53
53
|
exports.syncTypesFromDb = syncTypesFromDb;
|
|
54
|
-
const fs = __importStar(require("fs"));
|
|
55
|
-
const path = __importStar(require("path"));
|
|
54
|
+
const fs = __importStar(require("node:fs"));
|
|
55
|
+
const path = __importStar(require("node:path"));
|
|
56
56
|
const config_1 = require("../../config/config.cjs");
|
|
57
57
|
const dialect_router_1 = require("./dialect-router.cjs");
|
|
58
58
|
function getCreateTableSql(isDsql) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isAwsDsqlConfig = isAwsDsqlConfig;
|
|
4
7
|
exports.buildPoolConfig = buildPoolConfig;
|
|
@@ -7,6 +10,7 @@ exports.loadConfig = loadConfig;
|
|
|
7
10
|
exports.parseConnectionUrl = parseConnectionUrl;
|
|
8
11
|
exports.mergeConfigs = mergeConfigs;
|
|
9
12
|
exports.validateConfig = validateConfig;
|
|
13
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
10
14
|
const node_path_1 = require("node:path");
|
|
11
15
|
const node_fs_1 = require("node:fs");
|
|
12
16
|
const jiti_1 = require("jiti");
|
|
@@ -124,7 +128,7 @@ function findConfigFile(startPath) {
|
|
|
124
128
|
catch {
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
|
-
let currentDir = startPath ||
|
|
131
|
+
let currentDir = startPath || node_process_1.default.cwd();
|
|
128
132
|
try {
|
|
129
133
|
const stats = (0, node_fs_1.statSync)(currentDir);
|
|
130
134
|
if (stats.isFile()) {
|
package/dist/cjs/config/env.cjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ENV_VARS = void 0;
|
|
4
7
|
exports.loadEnvConfig = loadEnvConfig;
|
|
5
8
|
exports.hasEnvConfig = hasEnvConfig;
|
|
6
9
|
exports.describeEnvConfig = describeEnvConfig;
|
|
10
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
7
11
|
const types_1 = require("./types.cjs");
|
|
8
12
|
const url_parser_1 = require("./url-parser.cjs");
|
|
9
13
|
exports.ENV_VARS = {
|
|
@@ -48,7 +52,7 @@ exports.ENV_VARS = {
|
|
|
48
52
|
PLANETSCALE_URL: 'PLANETSCALE_URL',
|
|
49
53
|
PLANETSCALE_HOST: 'PLANETSCALE_HOST',
|
|
50
54
|
};
|
|
51
|
-
function loadEnvConfig(env =
|
|
55
|
+
function loadEnvConfig(env = node_process_1.default.env) {
|
|
52
56
|
const usedVars = [];
|
|
53
57
|
const dialectOverride = env[exports.ENV_VARS.RELQ_DIALECT];
|
|
54
58
|
if (dialectOverride) {
|
|
@@ -258,7 +262,7 @@ function tryLoadXataParams(env, usedVars) {
|
|
|
258
262
|
found: true,
|
|
259
263
|
};
|
|
260
264
|
}
|
|
261
|
-
function hasEnvConfig(env =
|
|
265
|
+
function hasEnvConfig(env = node_process_1.default.env) {
|
|
262
266
|
const urlVars = [
|
|
263
267
|
exports.ENV_VARS.DATABASE_URL,
|
|
264
268
|
exports.ENV_VARS.POSTGRES_URL,
|
|
@@ -291,7 +295,7 @@ function hasEnvConfig(env = process.env) {
|
|
|
291
295
|
return true;
|
|
292
296
|
return false;
|
|
293
297
|
}
|
|
294
|
-
function describeEnvConfig(env =
|
|
298
|
+
function describeEnvConfig(env = node_process_1.default.env) {
|
|
295
299
|
const result = loadEnvConfig(env);
|
|
296
300
|
if (!result.found) {
|
|
297
301
|
return 'No database configuration found in environment';
|
|
@@ -25,7 +25,12 @@ function executeTypeSafeJoin(ctx, joinType, tableOrAlias, callback) {
|
|
|
25
25
|
const rightProxy = (0, table_proxy_1.createTableProxy)(rightTableName, rightAlias, rightTableDef);
|
|
26
26
|
const conditionBuilder = new join_condition_builder_1.JoinConditionBuilder();
|
|
27
27
|
if (callback) {
|
|
28
|
-
|
|
28
|
+
if (joinType === 'RIGHT JOIN') {
|
|
29
|
+
callback(conditionBuilder, leftProxy, rightProxy);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
callback(conditionBuilder, rightProxy, leftProxy);
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
const conditionInternals = conditionBuilder[join_internals_1.JOIN_INTERNAL];
|
|
31
36
|
if (!conditionInternals.hasConditions() && schema && relations) {
|
|
@@ -37,7 +42,7 @@ function executeTypeSafeJoin(ctx, joinType, tableOrAlias, callback) {
|
|
|
37
42
|
}
|
|
38
43
|
else {
|
|
39
44
|
throw new relq_errors_1.RelqQueryError(`Cannot auto-resolve FK relationship between "${ctx.schemaKey || ctx.tableName}" and "${rightTableKey}". ` +
|
|
40
|
-
`Either provide a callback with explicit join conditions, or define the relationship in your relations config.`, { hint: `Use .join('${rightTableKey}', (on,
|
|
45
|
+
`Either provide a callback with explicit join conditions, or define the relationship in your relations config.`, { hint: `Use .join('${rightTableKey}', (on, ${rightTableKey}, source) => on.equal(${rightTableKey}.id, source.columnName))` });
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
const selectedProps = conditionInternals.getSelectedColumns();
|
|
@@ -93,7 +98,7 @@ function executeTypeSafeJoinMany(ctx, joinType, tableOrAlias, callback) {
|
|
|
93
98
|
};
|
|
94
99
|
};
|
|
95
100
|
conditionBuilder[join_internals_1.JOIN_SETUP](proxyCreator, rightProxy);
|
|
96
|
-
callback(conditionBuilder,
|
|
101
|
+
callback(conditionBuilder, rightProxy, leftProxy);
|
|
97
102
|
const lateralSQL = buildLateralSubquery(rightTableName, rightAlias, conditionBuilder, rightTableDef);
|
|
98
103
|
const lateralJoinType = joinType === 'LEFT JOIN' ? 'LEFT JOIN LATERAL' : 'JOIN LATERAL';
|
|
99
104
|
const joinClause = {
|
|
@@ -40,7 +40,6 @@ const aws_dsql_1 = require("../../../utils/aws-dsql.cjs");
|
|
|
40
40
|
const relq_errors_1 = require("../../../errors/relq-errors.cjs");
|
|
41
41
|
const environment_detection_1 = require("../../../utils/environment-detection.cjs");
|
|
42
42
|
const pool_defaults_1 = require("../../../utils/pool-defaults.cjs");
|
|
43
|
-
const relq_errors_2 = require("../../../errors/relq-errors.cjs");
|
|
44
43
|
const methods_1 = require("../../helpers/methods.cjs");
|
|
45
44
|
const relq_base_1 = require("../../relq-base.cjs");
|
|
46
45
|
const pg_dialect_1 = require("./pg-dialect.cjs");
|
|
@@ -205,19 +204,11 @@ class PgBase extends relq_base_1.RelqBase {
|
|
|
205
204
|
return config.pooling;
|
|
206
205
|
if (config.disableSmartDefaults)
|
|
207
206
|
return true;
|
|
208
|
-
return
|
|
207
|
+
return true;
|
|
209
208
|
}
|
|
210
209
|
validateConfiguration() {
|
|
211
210
|
if (this.config.disableSmartDefaults)
|
|
212
211
|
return;
|
|
213
|
-
if (this.environment.type === 'edge') {
|
|
214
|
-
throw new relq_errors_2.RelqEnvironmentError('Cannot use Relq with database connections in edge runtime.\n' +
|
|
215
|
-
'Edge runtimes (Cloudflare Workers, Deno Deploy) do not support TCP connections.\n\n' +
|
|
216
|
-
'Options:\n' +
|
|
217
|
-
'1. Use query builder only: relq("table").select().toString()\n' +
|
|
218
|
-
'2. Use HTTP-based database (Supabase, Neon, Xata)\n' +
|
|
219
|
-
'3. Deploy to Node.js runtime', (0, environment_detection_1.getEnvironmentDescription)(this.environment), 'No TCP/PostgreSQL support');
|
|
220
|
-
}
|
|
221
212
|
const poolConfig = {
|
|
222
213
|
min: this.config.pool?.min,
|
|
223
214
|
max: this.config.pool?.max
|
|
@@ -248,20 +239,16 @@ class PgBase extends relq_base_1.RelqBase {
|
|
|
248
239
|
idleTimeoutMillis: this.config.pool?.idleTimeoutMillis ?? smartDefaults.idleTimeoutMillis,
|
|
249
240
|
connectionTimeoutMillis: this.config.pool?.connectionTimeoutMillis ?? smartDefaults.connectionTimeoutMillis
|
|
250
241
|
});
|
|
251
|
-
if (this.environment.type === 'serverless') {
|
|
242
|
+
if (this.environment.type === 'serverless' || this.environment.type === 'edge') {
|
|
252
243
|
if (logLevel === 'info' || logLevel === 'debug') {
|
|
253
|
-
console.log(`\n🔵 Relq: ${this.environment.provider} detected (
|
|
254
|
-
`
|
|
255
|
-
` Pool config: ${poolConfig}\n` +
|
|
256
|
-
` Recommendation: Use min: 0, max: 1 for serverless`);
|
|
244
|
+
console.log(`\n🔵 Relq: ${this.environment.provider} detected (${this.environment.type})\n` +
|
|
245
|
+
` Pool config: ${poolConfig}`);
|
|
257
246
|
}
|
|
258
247
|
}
|
|
259
248
|
else if (this.environment.type === 'traditional') {
|
|
260
249
|
if (logLevel === 'debug') {
|
|
261
250
|
console.log(`\n🟢 Relq: Traditional server environment\n` +
|
|
262
|
-
`
|
|
263
|
-
` Pool config: ${poolConfig}\n` +
|
|
264
|
-
` Connections created on demand, scale up under load`);
|
|
251
|
+
` Pool config: ${poolConfig}`);
|
|
265
252
|
}
|
|
266
253
|
}
|
|
267
254
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.activeInstances = void 0;
|
|
4
7
|
exports.registerGlobalCleanupHandlers = registerGlobalCleanupHandlers;
|
|
5
8
|
exports.registerInstance = registerInstance;
|
|
6
9
|
exports.unregisterInstance = unregisterInstance;
|
|
10
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
7
11
|
exports.activeInstances = new Set();
|
|
8
12
|
let cleanupHandlersRegistered = false;
|
|
9
13
|
function registerGlobalCleanupHandlers() {
|
|
10
14
|
if (cleanupHandlersRegistered)
|
|
11
15
|
return;
|
|
12
|
-
if (typeof
|
|
16
|
+
if (typeof node_process_1.default === 'undefined' || !node_process_1.default.on)
|
|
13
17
|
return;
|
|
14
|
-
|
|
18
|
+
node_process_1.default.on('beforeExit', async () => {
|
|
15
19
|
if (exports.activeInstances.size === 0)
|
|
16
20
|
return;
|
|
17
21
|
await Promise.all(Array.from(exports.activeInstances).map(instance => instance.close().catch(err => console.error('Error closing database connection:', err))));
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.RelqBuilderError = exports.RelqEnvironmentError = exports.RelqPoolError = exports.RelqTimeoutError = exports.RelqConfigError = exports.RelqTransactionError = exports.RelqQueryError = exports.RelqConnectionError = exports.RelqError = void 0;
|
|
4
7
|
exports.setupErrorHandler = setupErrorHandler;
|
|
@@ -8,10 +11,11 @@ exports.isRelqQueryError = isRelqQueryError;
|
|
|
8
11
|
exports.isRelqBuilderError = isRelqBuilderError;
|
|
9
12
|
exports.wrapError = wrapError;
|
|
10
13
|
exports.parsePostgresError = parsePostgresError;
|
|
14
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
11
15
|
function setupErrorHandler() {
|
|
12
|
-
if (typeof
|
|
16
|
+
if (typeof node_process_1.default === 'undefined' || !node_process_1.default.on)
|
|
13
17
|
return;
|
|
14
|
-
|
|
18
|
+
node_process_1.default.on('uncaughtException', (error) => {
|
|
15
19
|
if (error instanceof RelqError) {
|
|
16
20
|
const inspect = error[Symbol.for('nodejs.util.inspect.custom')];
|
|
17
21
|
if (typeof inspect === 'function') {
|
|
@@ -28,9 +32,9 @@ function setupErrorHandler() {
|
|
|
28
32
|
console.error(stackLines.slice(0, 5).join('\n'));
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
|
-
|
|
35
|
+
node_process_1.default.exit(1);
|
|
32
36
|
});
|
|
33
|
-
|
|
37
|
+
node_process_1.default.on('unhandledRejection', (reason) => {
|
|
34
38
|
if (reason instanceof RelqError) {
|
|
35
39
|
const inspect = reason[Symbol.for('nodejs.util.inspect.custom')];
|
|
36
40
|
if (typeof inspect === 'function') {
|
|
@@ -50,7 +54,7 @@ function setupErrorHandler() {
|
|
|
50
54
|
else {
|
|
51
55
|
console.error('Unhandled rejection:', reason);
|
|
52
56
|
}
|
|
53
|
-
|
|
57
|
+
node_process_1.default.exit(1);
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
60
|
class RelqError extends Error {
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ListenerConnection = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_events_1 = require("node:events");
|
|
8
8
|
const pg_1 = require("pg");
|
|
9
9
|
const pg_format_1 = __importDefault(require("../utils/pg-format.cjs"));
|
|
10
|
-
class ListenerConnection extends
|
|
10
|
+
class ListenerConnection extends node_events_1.EventEmitter {
|
|
11
11
|
client = null;
|
|
12
12
|
config;
|
|
13
13
|
connected = false;
|
|
@@ -34,7 +34,7 @@ class ListenerConnection extends events_1.EventEmitter {
|
|
|
34
34
|
this.subscriptions.set(channel, channelSub);
|
|
35
35
|
await this.executeListen(channel);
|
|
36
36
|
}
|
|
37
|
-
const emitter = new
|
|
37
|
+
const emitter = new node_events_1.EventEmitter();
|
|
38
38
|
channelSub.subscribers.push(emitter);
|
|
39
39
|
const subscription = {
|
|
40
40
|
on(event, listener) {
|
|
@@ -32,10 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.getAwsDsqlToken = getAwsDsqlToken;
|
|
37
40
|
exports.clearAwsDsqlToken = clearAwsDsqlToken;
|
|
38
41
|
exports.isAwsDsql = isAwsDsql;
|
|
42
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
39
43
|
const node_fs_1 = require("node:fs");
|
|
40
44
|
const node_path_1 = require("node:path");
|
|
41
45
|
const node_os_1 = require("node:os");
|
|
@@ -69,7 +73,7 @@ function getFromCache(cacheKey) {
|
|
|
69
73
|
return memoryToken;
|
|
70
74
|
}
|
|
71
75
|
const envName = `DSQL_TOKEN_${cacheKey}`;
|
|
72
|
-
const envToken =
|
|
76
|
+
const envToken = node_process_1.default.env[envName];
|
|
73
77
|
if (envToken) {
|
|
74
78
|
try {
|
|
75
79
|
const parsed = JSON.parse(envToken);
|
|
@@ -87,7 +91,7 @@ function getFromCache(cacheKey) {
|
|
|
87
91
|
const parsed = JSON.parse((0, node_fs_1.readFileSync)(tokenFile, 'utf8'));
|
|
88
92
|
if (parsed.expiresAt > Date.now()) {
|
|
89
93
|
tokenCache.set(cacheKey, parsed);
|
|
90
|
-
|
|
94
|
+
node_process_1.default.env[envName] = JSON.stringify(parsed);
|
|
91
95
|
return parsed;
|
|
92
96
|
}
|
|
93
97
|
}
|
|
@@ -99,7 +103,7 @@ function getFromCache(cacheKey) {
|
|
|
99
103
|
function saveToCache(cacheKey, token) {
|
|
100
104
|
tokenCache.set(cacheKey, token);
|
|
101
105
|
const envName = `DSQL_TOKEN_${cacheKey}`;
|
|
102
|
-
|
|
106
|
+
node_process_1.default.env[envName] = JSON.stringify(token);
|
|
103
107
|
if (isTempFolderAvailable()) {
|
|
104
108
|
const tokenFile = (0, node_path_1.join)(getTempFolder(), `${cacheKey}.json`);
|
|
105
109
|
try {
|
|
@@ -161,7 +165,7 @@ function clearAwsDsqlToken(config) {
|
|
|
161
165
|
const cacheKey = getCacheKey(config);
|
|
162
166
|
tokenCache.delete(cacheKey);
|
|
163
167
|
const envName = `DSQL_TOKEN_${cacheKey}`;
|
|
164
|
-
delete
|
|
168
|
+
delete node_process_1.default.env[envName];
|
|
165
169
|
if (isTempFolderAvailable()) {
|
|
166
170
|
const tokenFile = (0, node_path_1.join)(getTempFolder(), `${cacheKey}.json`);
|
|
167
171
|
try {
|