@sqb/migrator 4.20.6 → 4.21.0

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/migrator",
3
3
  "description": "Database migrator for SQB",
4
- "version": "4.20.6",
4
+ "version": "4.21.0",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
@@ -12,28 +12,23 @@
12
12
  "tslib": "^2.8.1"
13
13
  },
14
14
  "peerDependencies": {
15
- "@sqb/builder": "^4.20.6",
16
- "@sqb/connect": "^4.20.6",
17
- "@sqb/postgres": "^4.20.6"
15
+ "@sqb/builder": "^4.21.0",
16
+ "@sqb/connect": "^4.21.0",
17
+ "@sqb/postgres": "^4.21.0"
18
18
  },
19
19
  "type": "module",
20
+ "module": "./index.js",
21
+ "types": "./index.d.ts",
20
22
  "exports": {
21
23
  ".": {
22
- "import": {
23
- "types": "./types/index.d.ts",
24
- "default": "./esm/index.js"
25
- },
26
- "require": {
27
- "types": "./types/index.d.cts",
28
- "default": "./cjs/index.js"
29
- },
30
- "default": "./esm/index.js"
24
+ "types": "./index.d.ts",
25
+ "default": "./index.js"
31
26
  },
32
27
  "./package.json": "./package.json"
33
28
  },
34
- "main": "./cjs/index.js",
35
- "module": "./esm/index.js",
36
- "types": "./types/index.d.ts",
29
+ "engines": {
30
+ "node": ">=20.0"
31
+ },
37
32
  "contributors": [
38
33
  "Eray Hanoglu <e.hanoglu@panates.com>",
39
34
  "Ilker Gurelli <i.gurelli@panates.com>"
@@ -43,17 +38,6 @@
43
38
  "url": "https://github.com/panates/sqb.git",
44
39
  "directory": "packages/migrator"
45
40
  },
46
- "engines": {
47
- "node": ">=18.0"
48
- },
49
- "files": [
50
- "bin/",
51
- "cjs/",
52
- "esm/",
53
- "types/",
54
- "LICENSE",
55
- "README.md"
56
- ],
57
41
  "keywords": [
58
42
  "sqb",
59
43
  "sql",
@@ -1,234 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PgMigrationAdapter = void 0;
4
- const tslib_1 = require("tslib");
5
- const postgres_1 = require("@sqb/postgres");
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- const postgrejs_1 = require("postgrejs");
8
- const migration_adapter_js_1 = require("../migration-adapter.js");
9
- const migration_package_js_1 = require("../migration-package.js");
10
- const types_js_1 = require("../types.js");
11
- const pgAdapter = new postgres_1.PgAdapter();
12
- class PgMigrationAdapter extends migration_adapter_js_1.MigrationAdapter {
13
- _infoSchema = 'public';
14
- _version = 0;
15
- _status = types_js_1.MigrationStatus.idle;
16
- defaultVariables = {
17
- tablespace: 'pg_default',
18
- schema: 'public',
19
- owner: 'postgres',
20
- };
21
- summaryTable = 'migration_summary';
22
- eventTable = 'migration_events';
23
- get packageName() {
24
- return this._migrationPackage.name;
25
- }
26
- get version() {
27
- return this._version;
28
- }
29
- get status() {
30
- return this._status;
31
- }
32
- get infoSchema() {
33
- return this._infoSchema;
34
- }
35
- get summaryTableFull() {
36
- return this.infoSchema + '.' + this.summaryTable;
37
- }
38
- get eventTableFull() {
39
- return this.infoSchema + '.' + this.eventTable;
40
- }
41
- static async create(options) {
42
- // Create connection
43
- const connection = (await pgAdapter.connect(options.connection))
44
- .intlcon;
45
- try {
46
- const adapter = new PgMigrationAdapter();
47
- adapter._connection = connection;
48
- adapter._migrationPackage = options.migrationPackage;
49
- adapter._infoSchema = options.infoSchema || '__migration';
50
- adapter.defaultVariables.schema = options.connection.schema || '';
51
- if (!adapter.defaultVariables.schema) {
52
- const r = await connection.query('SELECT CURRENT_SCHEMA ', {
53
- objectRows: true,
54
- });
55
- adapter.defaultVariables.schema =
56
- r.rows?.[0]?.current_schema || 'public';
57
- }
58
- // Check if migration schema
59
- await connection.query(`CREATE SCHEMA IF NOT EXISTS ${adapter.infoSchema} AUTHORIZATION postgres;`);
60
- // Create summary table if not exists
61
- await connection.execute(`
62
- CREATE TABLE IF NOT EXISTS ${adapter.summaryTableFull}
63
- (
64
- package_name varchar not null,
65
- status varchar(16) not null,
66
- current_version integer not null default 0,
67
- created_at timestamp without time zone not null default current_timestamp,
68
- updated_at timestamp without time zone,
69
- CONSTRAINT pk_${adapter.summaryTable} PRIMARY KEY (package_name)
70
- )`);
71
- // Create events table if not exists
72
- await connection.execute(`
73
- CREATE TABLE IF NOT EXISTS ${adapter.eventTableFull}
74
- (
75
- id serial not null,
76
- package_name varchar not null,
77
- version integer not null default 0,
78
- event varchar(16) not null,
79
- event_time timestamp without time zone not null,
80
- title text,
81
- message text not null,
82
- filename text,
83
- details text,
84
- CONSTRAINT pk_${adapter.eventTable} PRIMARY KEY (id)
85
- )`);
86
- // Insert summary record if not exists
87
- const r = await connection.query(`SELECT status FROM ${adapter.summaryTableFull} WHERE package_name = $1`, {
88
- params: [adapter.packageName],
89
- objectRows: true,
90
- });
91
- if (!(r && r.rows?.length)) {
92
- await connection.query(`insert into ${adapter.summaryTableFull} (package_name, status) values ($1, $2)`, {
93
- params: [adapter.packageName, types_js_1.MigrationStatus.idle],
94
- });
95
- }
96
- await adapter.refresh();
97
- return adapter;
98
- }
99
- catch (e) {
100
- await connection.close(0);
101
- throw e;
102
- }
103
- }
104
- async close() {
105
- await this._connection.close();
106
- }
107
- async refresh() {
108
- const r = await this._connection.query(`SELECT * FROM ${this.summaryTableFull} WHERE package_name = $1`, {
109
- params: [this.packageName],
110
- objectRows: true,
111
- });
112
- const row = r.rows && r.rows[0];
113
- if (!row)
114
- throw new Error('Summary record did not created');
115
- this._version = row.current_version;
116
- this._status = row.status;
117
- }
118
- async update(info) {
119
- let sql = '';
120
- const params = [];
121
- if (info.status && info.status !== this.status) {
122
- params.push(info.status);
123
- sql += ',\n status = $' + params.length;
124
- }
125
- if (info.version && info.version !== this.version) {
126
- params.push(info.version);
127
- sql += ',\n current_version = $' + params.length;
128
- }
129
- if (sql) {
130
- params.push(this.packageName);
131
- sql =
132
- `update ${this.summaryTableFull} set updated_at = current_timestamp` +
133
- sql +
134
- `\n where package_name =$` +
135
- params.length;
136
- await this._connection.query(sql, { params });
137
- if (info.status)
138
- this._status = info.status;
139
- if (info.version)
140
- this._version = info.version;
141
- }
142
- }
143
- async writeEvent(event) {
144
- const sql = `insert into ${this.eventTableFull} ` +
145
- '(package_name, version, event, event_time, title, message, filename, details) ' +
146
- 'values ($1, $2, $3, CURRENT_TIMESTAMP, $4, $5, $6, $7)';
147
- await this._connection.query(sql, {
148
- params: [
149
- this.packageName,
150
- event.version,
151
- event.event,
152
- event.title,
153
- event.message,
154
- event.filename,
155
- event.details,
156
- ],
157
- });
158
- }
159
- async executeTask(migrationPackage, migration, task, variables) {
160
- variables = {
161
- ...this.defaultVariables,
162
- ...variables,
163
- };
164
- if ((0, migration_package_js_1.isSqlScriptMigrationTask)(task)) {
165
- try {
166
- let script;
167
- if (typeof task.script === 'function') {
168
- script = await task.script({
169
- migrationPackage,
170
- migration,
171
- task,
172
- variables,
173
- });
174
- }
175
- else
176
- script = task.script;
177
- if (typeof script !== 'string')
178
- return;
179
- script = this.replaceVariables(script, variables);
180
- await this._connection.execute(script);
181
- }
182
- catch (e) {
183
- let msg = `Error in task "${task.title}"`;
184
- if (task.filename)
185
- msg +=
186
- '\n at ' + path_1.default.relative(migrationPackage.baseDir, task.filename);
187
- if (e.lineNr) {
188
- if (!task.filename)
189
- e.message += '\n at';
190
- msg += ` (${e.lineNr},${e.colNr}):\n` + e.line;
191
- if (e.colNr)
192
- msg += '\n' + ' '.repeat(e.colNr - 1) + '^';
193
- }
194
- e.message = msg + '\n\n' + e.message;
195
- throw e;
196
- }
197
- return;
198
- }
199
- if ((0, migration_package_js_1.isCustomMigrationTask)(task)) {
200
- await task.fn(this._connection, this);
201
- return;
202
- }
203
- if ((0, migration_package_js_1.isInsertDataMigrationTask)(task)) {
204
- const tableName = this.replaceVariables(task.tableName, variables);
205
- const script = task.rows
206
- .map(row => this.rowToSql(tableName, row))
207
- .join('\n');
208
- await this._connection.execute(script);
209
- }
210
- }
211
- backupDatabase() {
212
- return Promise.resolve(undefined);
213
- }
214
- lockSchema() {
215
- return Promise.resolve(undefined);
216
- }
217
- restoreDatabase() {
218
- return Promise.resolve(undefined);
219
- }
220
- unlockSchema() {
221
- return Promise.resolve(undefined);
222
- }
223
- rowToSql(tableName, row) {
224
- let sql = '';
225
- const keys = Object.keys(row);
226
- sql += `insert into ${tableName} (${keys}) values (`;
227
- for (let i = 0; i < keys.length; i++) {
228
- sql += (i ? ', ' : '') + (0, postgrejs_1.stringifyValueForSQL)(row[keys[i]]);
229
- }
230
- sql += ');\n';
231
- return sql;
232
- }
233
- }
234
- exports.PgMigrationAdapter = PgMigrationAdapter;
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DbMigrator = void 0;
4
- const strict_typed_events_1 = require("strict-typed-events");
5
- const pg_migration_adapter_js_1 = require("./adapters/pg-migration-adapter.js");
6
- const migration_adapter_js_1 = require("./migration-adapter.js");
7
- const migration_package_js_1 = require("./migration-package.js");
8
- const types_js_1 = require("./types.js");
9
- class DbMigrator extends strict_typed_events_1.AsyncEventEmitter {
10
- async execute(options) {
11
- if (!options.connection.dialect)
12
- throw new TypeError(`You must provide connection.dialect`);
13
- const migrationPackage = await migration_package_js_1.MigrationPackage.load(options.migrationPackage);
14
- let minVersion = migrationPackage.migrations.reduce((a, m) => Math.min(a, m.version), Number.MAX_SAFE_INTEGER);
15
- if (minVersion === Number.MAX_SAFE_INTEGER)
16
- minVersion = 0;
17
- const maxVersion = migrationPackage.migrations.reduce((a, m) => Math.max(a, m.version), 0);
18
- const targetVersion = Math.min(options?.targetVersion || Number.MAX_SAFE_INTEGER, maxVersion);
19
- if (targetVersion && targetVersion < minVersion) {
20
- // noinspection ExceptionCaughtLocallyJS
21
- throw new Error(`Version mismatch. Target schema version (${targetVersion}) is lower than ` +
22
- `migration package min version (${minVersion})`);
23
- }
24
- let migrationAdapter;
25
- switch (options.connection.dialect) {
26
- case 'postgres': {
27
- migrationAdapter = await pg_migration_adapter_js_1.PgMigrationAdapter.create({
28
- ...options,
29
- migrationPackage,
30
- });
31
- break;
32
- }
33
- default:
34
- throw new TypeError(`Migration adapter for "${options.connection.dialect}" dialect is not implemented yet`);
35
- }
36
- let needBackup = false;
37
- try {
38
- if (migrationAdapter.version &&
39
- migrationAdapter.version < minVersion - 1) {
40
- // noinspection ExceptionCaughtLocallyJS
41
- throw new Error(`This package can migrate starting from ${minVersion - 1} but current version is ${migrationAdapter.version}`);
42
- }
43
- const { migrations } = migrationPackage;
44
- // calculate total scripts;
45
- const total = migrations.reduce((i, x) => i + x.tasks.length, 0);
46
- needBackup = !!migrations.find(x => !!x.backup);
47
- await this.emitAsync('start');
48
- let task;
49
- await migrationAdapter.lockSchema();
50
- if (needBackup) {
51
- await this.emitAsync('backup');
52
- await migrationAdapter.backupDatabase();
53
- }
54
- // Execute migration tasks
55
- let migrationIndex = -1;
56
- for (const migration of migrations) {
57
- migrationIndex++;
58
- if (migration.version > targetVersion ||
59
- migrationAdapter.version >= migration.version)
60
- continue;
61
- await this.emitAsync('migration-start', {
62
- migration,
63
- total: migrations.length,
64
- index: migrationIndex,
65
- });
66
- for (let index = 0; index < migration.tasks.length; index++) {
67
- task = migration.tasks[index];
68
- await this.emitAsync('task-start', { migration, task, total, index });
69
- await migrationAdapter.update({ status: types_js_1.MigrationStatus.busy });
70
- await migrationAdapter.writeEvent({
71
- event: migration_adapter_js_1.MigrationAdapter.EventKind.started,
72
- version: migration.version,
73
- title: task.title,
74
- filename: task.filename,
75
- message: `Task "${task.title}" started`,
76
- });
77
- try {
78
- await migrationAdapter.executeTask(migrationPackage, migration, task, {
79
- schema: options.connection.schema,
80
- ...options.scriptVariables,
81
- });
82
- await migrationAdapter.writeEvent({
83
- event: migration_adapter_js_1.MigrationAdapter.EventKind.success,
84
- version: migration.version,
85
- title: task.title,
86
- filename: task.filename,
87
- message: `Task "${task.title}" completed`,
88
- });
89
- }
90
- catch (e) {
91
- await migrationAdapter.writeEvent({
92
- event: migration_adapter_js_1.MigrationAdapter.EventKind.error,
93
- version: migration.version,
94
- title: task.title,
95
- filename: task.filename,
96
- message: String(e),
97
- details: e.message +
98
- '\n\n' +
99
- Object.keys(e)
100
- .filter(k => e[k] != null)
101
- .map(k => k + ': ' + e[k])
102
- .join('\n'),
103
- });
104
- // noinspection ExceptionCaughtLocallyJS
105
- throw e;
106
- }
107
- await this.emitAsync('task-finish', {
108
- migration,
109
- task,
110
- total,
111
- index,
112
- });
113
- }
114
- await migrationAdapter.update({
115
- version: migration.version,
116
- status: types_js_1.MigrationStatus.idle,
117
- });
118
- await this.emitAsync('migration-finish', {
119
- migration,
120
- total: migrations.length,
121
- index: migrationIndex,
122
- });
123
- }
124
- }
125
- catch (e) {
126
- if (needBackup) {
127
- await this.emitAsync('restore');
128
- await migrationAdapter.restoreDatabase();
129
- }
130
- throw e;
131
- }
132
- finally {
133
- try {
134
- await migrationAdapter.unlockSchema();
135
- }
136
- finally {
137
- await migrationAdapter.close();
138
- }
139
- }
140
- await this.emitAsync('finish');
141
- return true;
142
- }
143
- }
144
- exports.DbMigrator = DbMigrator;
package/cjs/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./db-migrator.js"), exports);
5
- tslib_1.__exportStar(require("./migration-adapter.js"), exports);
6
- tslib_1.__exportStar(require("./migration-package.js"), exports);
7
- tslib_1.__exportStar(require("./types.js"), exports);
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationAdapter = void 0;
4
- class MigrationAdapter {
5
- replaceVariables(text, variables) {
6
- return text.replace(/(\$\((\w+)\))/g, (s, ...args) => variables[args[1]] || s);
7
- }
8
- }
9
- exports.MigrationAdapter = MigrationAdapter;
10
- (function (MigrationAdapter) {
11
- let EventKind;
12
- (function (EventKind) {
13
- EventKind["started"] = "started";
14
- EventKind["success"] = "success";
15
- EventKind["error"] = "error";
16
- })(EventKind = MigrationAdapter.EventKind || (MigrationAdapter.EventKind = {}));
17
- })(MigrationAdapter || (exports.MigrationAdapter = MigrationAdapter = {}));
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationPackage = void 0;
4
- exports.isSqlScriptMigrationTask = isSqlScriptMigrationTask;
5
- exports.isInsertDataMigrationTask = isInsertDataMigrationTask;
6
- exports.isCustomMigrationTask = isCustomMigrationTask;
7
- const tslib_1 = require("tslib");
8
- const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
9
- const promises_1 = tslib_1.__importDefault(require("fs/promises"));
10
- const path_1 = tslib_1.__importDefault(require("path"));
11
- const get_calling_filename_js_1 = require("./utils/get-calling-filename.js");
12
- function isSqlScriptMigrationTask(x) {
13
- return (typeof x === 'object' &&
14
- (typeof x.script === 'string' || typeof x.script === 'function'));
15
- }
16
- function isInsertDataMigrationTask(x) {
17
- return (typeof x === 'object' &&
18
- typeof x.tableName === 'string' &&
19
- Array.isArray(x.rows));
20
- }
21
- function isCustomMigrationTask(x) {
22
- return typeof x === 'object' && typeof x.fn === 'function';
23
- }
24
- var MigrationPackage;
25
- (function (MigrationPackage) {
26
- async function load(asyncConfig) {
27
- const baseDir = asyncConfig.baseDir || path_1.default.dirname((0, get_calling_filename_js_1.getCallingFilename)(1));
28
- const out = {
29
- ...asyncConfig,
30
- baseDir,
31
- migrations: [],
32
- };
33
- if (!Array.isArray(asyncConfig.migrations)) {
34
- throw new TypeError('You must provide array of MigrationConfig in "migrations" property');
35
- }
36
- if (asyncConfig.migrations?.length) {
37
- const srcMigrations = [];
38
- const trgMigrations = [];
39
- out.migrations = trgMigrations;
40
- let x;
41
- for (x of asyncConfig.migrations) {
42
- x = typeof x === 'function' ? await x() : x;
43
- if (typeof x === 'object' && x.tasks)
44
- srcMigrations.push(x);
45
- else if (typeof x === 'string') {
46
- srcMigrations.push(...(await loadMigrations(baseDir, x.replace(/\\/g, '/'))));
47
- }
48
- }
49
- srcMigrations.sort((a, b) => a.version - b.version);
50
- for (const migration of srcMigrations) {
51
- const trgMigration = {
52
- baseDir: '',
53
- ...migration,
54
- tasks: [],
55
- };
56
- trgMigrations.push(trgMigration);
57
- const srcTasks = migration.tasks;
58
- trgMigration.tasks = [];
59
- for (const t of srcTasks) {
60
- if (typeof t === 'object') {
61
- trgMigration.tasks.push(t);
62
- }
63
- else if (typeof t === 'string') {
64
- let pattern = t.replace(/\\/g, '/');
65
- pattern = path_1.default.resolve(path_1.default.join(baseDir, trgMigration.baseDir, pattern));
66
- const files = await (0, fast_glob_1.default)(pattern, {
67
- absolute: true,
68
- onlyFiles: true,
69
- });
70
- files.sort();
71
- for (const filename of files) {
72
- const ext = path_1.default.extname(filename).toLowerCase();
73
- if (!path_1.default.basename(filename, ext).endsWith('.task'))
74
- continue;
75
- if (ext === '.sql') {
76
- const script = await promises_1.default.readFile(filename, 'utf-8');
77
- trgMigration.tasks.push({
78
- title: path_1.default.basename(filename, ext),
79
- filename,
80
- script,
81
- });
82
- }
83
- else if (['.json', '.js', '.ts', '.cjs', '.mjs'].includes(ext)) {
84
- try {
85
- let json = ext === '.json'
86
- ? JSON.parse(await promises_1.default.readFile(filename, 'utf-8'))
87
- : await Promise.resolve(`${filename}`).then(s => tslib_1.__importStar(require(s)));
88
- if (typeof json !== 'object')
89
- continue;
90
- if (json.__esModule)
91
- json = json.default;
92
- if (json.script) {
93
- json.title = json.title || 'Run sql script';
94
- json.filename = filename;
95
- trgMigration.tasks.push(json);
96
- continue;
97
- }
98
- if (json.tableName && json.rows) {
99
- json.title =
100
- json.title || 'Migrate data into ' + json.tableName;
101
- json.filename = filename;
102
- trgMigration.tasks.push(json);
103
- continue;
104
- }
105
- if (typeof json.fn === 'function') {
106
- json.title = json.title || 'Run custom function';
107
- json.filename = filename;
108
- trgMigration.tasks.push(json);
109
- }
110
- }
111
- catch (e) {
112
- e.message = `Error in ${filename}\n` + e.message;
113
- throw e;
114
- }
115
- }
116
- }
117
- }
118
- }
119
- }
120
- }
121
- return out;
122
- }
123
- MigrationPackage.load = load;
124
- })(MigrationPackage || (exports.MigrationPackage = MigrationPackage = {}));
125
- async function loadMigrations(baseDir, pattern) {
126
- const out = [];
127
- const files = await (0, fast_glob_1.default)(path_1.default.join(baseDir, pattern), {
128
- absolute: true,
129
- onlyFiles: true,
130
- });
131
- for (const filename of files) {
132
- const ext = path_1.default.extname(filename).toLowerCase();
133
- if (path_1.default.basename(filename, ext) !== 'migration')
134
- continue;
135
- let json;
136
- if (['.js', '.ts', '.cjs', '.mjs', 'mts', 'cts'].includes(ext)) {
137
- json = await Promise.resolve(`${filename}`).then(s => tslib_1.__importStar(require(s)));
138
- if (json.default?.version)
139
- json = json.default;
140
- }
141
- else if (ext === '.json') {
142
- try {
143
- json = JSON.parse(await promises_1.default.readFile(filename, 'utf-8'));
144
- }
145
- catch (e) {
146
- e.message = `Error in ${filename}\n` + e.message;
147
- throw e;
148
- }
149
- }
150
- if (json &&
151
- typeof json === 'object' &&
152
- json.version &&
153
- Array.isArray(json.tasks)) {
154
- json.baseDir = path_1.default.relative(baseDir, path_1.default.dirname(filename));
155
- out.push(json);
156
- }
157
- }
158
- return out;
159
- }
package/cjs/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
package/cjs/types.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationStatus = void 0;
4
- var MigrationStatus;
5
- (function (MigrationStatus) {
6
- MigrationStatus["idle"] = "idle";
7
- MigrationStatus["busy"] = "busy";
8
- })(MigrationStatus || (exports.MigrationStatus = MigrationStatus = {}));
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCallingFilename = getCallingFilename;
4
- const PATH_PATTERN = /^(?:file:\/\/)?(.+)$/;
5
- function getCallingFilename(position = 0) {
6
- position++;
7
- if (position >= Error.stackTraceLimit)
8
- return '';
9
- const oldPrepareStackTrace = Error.prepareStackTrace;
10
- Error.prepareStackTrace = (_, stack) => stack;
11
- const stack = new Error().stack;
12
- Error.prepareStackTrace = oldPrepareStackTrace;
13
- if (stack !== null && typeof stack === 'object') {
14
- // stack[0] holds this file
15
- // stack[1] holds where this function was called
16
- const s = stack[position]
17
- ? stack[position].getFileName()
18
- : undefined;
19
- const m = s ? PATH_PATTERN.exec(s) : undefined;
20
- return m ? m[1] : '';
21
- }
22
- return '';
23
- }
package/esm/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/types/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- export * from './db-migrator.js';
2
- export * from './migration-adapter.js';
3
- export * from './migration-package.js';
4
- export * from './types.js';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes