node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

44
server/node_modules/umzug/lib/cli.d.ts generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import * as cli from '@rushstack/ts-command-line';
import type { Umzug } from './umzug';
export declare class UpAction extends cli.CommandLineAction {
protected umzug: Umzug;
private _params;
constructor(umzug: Umzug);
private static _defineParameters;
onDefineParameters(): void;
onExecute(): Promise<void>;
}
export declare class DownAction extends cli.CommandLineAction {
protected umzug: Umzug;
private _params;
constructor(umzug: Umzug);
private static _defineParameters;
onDefineParameters(): void;
onExecute(): Promise<void>;
}
export declare class ListAction extends cli.CommandLineAction {
private readonly action;
private readonly umzug;
private _params;
constructor(action: 'pending' | 'executed', umzug: Umzug);
private static _defineParameters;
onDefineParameters(): void;
onExecute(): Promise<void>;
}
export declare class CreateAction extends cli.CommandLineAction {
readonly umzug: Umzug;
private _params;
constructor(umzug: Umzug);
private static _defineParameters;
onDefineParameters(): void;
onExecute(): Promise<void>;
}
export type CommandLineParserOptions = {
toolFileName?: string;
toolDescription?: string;
};
export declare class UmzugCLI extends cli.CommandLineParser {
readonly umzug: Umzug;
constructor(umzug: Umzug, commandLineParserOptions?: CommandLineParserOptions);
onDefineParameters(): void;
}

275
server/node_modules/umzug/lib/cli.js generated vendored Normal file
View File

@@ -0,0 +1,275 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UmzugCLI = exports.CreateAction = exports.ListAction = exports.DownAction = exports.UpAction = void 0;
const cli = __importStar(require("@rushstack/ts-command-line"));
class UpAction extends cli.CommandLineAction {
constructor(umzug) {
super({
actionName: 'up',
summary: 'Applies pending migrations',
documentation: 'Performs all migrations. See --help for more options',
});
this.umzug = umzug;
}
static _defineParameters(action) {
return {
to: action.defineStringParameter({
parameterLongName: '--to',
argumentName: 'NAME',
description: `All migrations up to and including this one should be applied`,
}),
step: action.defineIntegerParameter({
parameterLongName: '--step',
argumentName: 'COUNT',
description: `Apply this many migrations. If not specified, all will be applied.`,
}),
name: action.defineStringListParameter({
parameterLongName: '--name',
argumentName: 'MIGRATION',
description: `Explicity declare migration name(s) to be applied. Only these migrations will be applied.`,
}),
rerun: action.defineChoiceParameter({
parameterLongName: '--rerun',
description: `Specify what action should be taken when a migration that has already been applied is passed to --name.`,
alternatives: ['THROW', 'SKIP', 'ALLOW'],
defaultValue: 'THROW',
}),
};
}
onDefineParameters() {
this._params = UpAction._defineParameters(this);
}
async onExecute() {
var _a;
const { to: { value: to }, step: { value: step }, name: { values: nameArray }, rerun: { value: rerun }, } = this._params;
// string list parameters are always defined. When they're empty it means nothing was passed.
const migrations = nameArray.length > 0 ? nameArray : undefined;
if (to && migrations) {
throw new Error(`Can't specify 'to' and 'name' together`);
}
if (to && typeof step === 'number') {
throw new Error(`Can't specify 'to' and 'step' together`);
}
if (typeof step === 'number' && migrations) {
throw new Error(`Can't specify 'step' and 'name' together`);
}
if (rerun !== 'THROW' && !migrations) {
throw new Error(`Can't specify 'rerun' without 'name'`);
}
const result = await this.umzug.up({ to, step, migrations, rerun });
(_a = this.umzug.options.logger) === null || _a === void 0 ? void 0 : _a.info({ event: this.actionName, message: `applied ${result.length} migrations.` });
}
}
exports.UpAction = UpAction;
class DownAction extends cli.CommandLineAction {
constructor(umzug) {
super({
actionName: 'down',
summary: 'Revert migrations',
documentation: 'Undoes previously-applied migrations. By default, undoes the most recent migration only. Use --help for more options. Useful in development to start from a clean slate. Use with care in production!',
});
this.umzug = umzug;
}
static _defineParameters(action) {
return {
to: action.defineStringParameter({
parameterLongName: '--to',
argumentName: 'NAME',
description: `All migrations up to and including this one should be reverted. Pass '0' to revert all.`,
}),
step: action.defineIntegerParameter({
parameterLongName: '--step',
argumentName: 'COUNT',
description: `Revert this many migrations. If not specified, only the most recent migration will be reverted.`,
}),
name: action.defineStringListParameter({
parameterLongName: '--name',
argumentName: 'MIGRATION',
description: `Explicity declare migration name(s) to be reverted. Only these migrations will be reverted.`,
}),
// todo: come up with a better word for this
rerun: action.defineChoiceParameter({
parameterLongName: '--rerun',
description: `Specify what action should be taken when a migration that has already been applied is passed to --name.`,
alternatives: ['THROW', 'SKIP', 'ALLOW'],
defaultValue: 'THROW',
}),
};
}
onDefineParameters() {
this._params = DownAction._defineParameters(this);
}
async onExecute() {
var _a;
const { to: { value: to }, step: { value: step }, name: { values: nameArray }, rerun: { value: rerun }, } = this._params;
// string list parameters are always defined. When they're empty it means nothing was passed.
const migrations = nameArray.length > 0 ? nameArray : undefined;
if (to && migrations) {
throw new Error(`Can't specify 'to' and 'name' together`);
}
if (to && typeof step === 'number') {
throw new Error(`Can't specify 'to' and 'step' together`);
}
if (typeof step === 'number' && migrations) {
throw new Error(`Can't specify 'step' and 'name' together`);
}
if (rerun !== 'THROW' && !migrations) {
throw new Error(`Can't specify 'rerun' without 'name'`);
}
const result = await this.umzug.down({
to: to === '0' ? 0 : to,
step,
migrations,
rerun,
});
(_a = this.umzug.options.logger) === null || _a === void 0 ? void 0 : _a.info({ event: this.actionName, message: `reverted ${result.length} migrations.` });
}
}
exports.DownAction = DownAction;
class ListAction extends cli.CommandLineAction {
constructor(action, umzug) {
super({
actionName: action,
summary: `Lists ${action} migrations`,
documentation: `Prints migrations returned by \`umzug.${action}()\`. By default, prints migration names one per line.`,
});
this.action = action;
this.umzug = umzug;
}
static _defineParameters(action) {
return {
json: action.defineFlagParameter({
parameterLongName: '--json',
description: `Print ${action.actionName} migrations in a json format including names and paths. This allows piping output to tools like jq. ` +
`Without this flag, the migration names will be printed one per line.`,
}),
};
}
onDefineParameters() {
this._params = ListAction._defineParameters(this);
}
async onExecute() {
const migrations = await this.umzug[this.action]();
const formatted = this._params.json.value
? JSON.stringify(migrations, null, 2)
: migrations.map(m => m.name).join('\n');
// eslint-disable-next-line no-console
console.log(formatted);
}
}
exports.ListAction = ListAction;
class CreateAction extends cli.CommandLineAction {
constructor(umzug) {
super({
actionName: 'create',
summary: 'Create a migration file',
documentation: 'Generates a placeholder migration file using a timestamp as a prefix. By default, mimics the last existing migration, or guesses where to generate the file if no migration exists yet.',
});
this.umzug = umzug;
}
static _defineParameters(action) {
return {
name: action.defineStringParameter({
parameterLongName: '--name',
argumentName: 'NAME',
description: `The name of the migration file. e.g. my-migration.js, my-migration.ts or my-migration.sql. Note - a prefix will be added to this name, usually based on a timestamp. See --prefix`,
required: true,
}),
prefix: action.defineChoiceParameter({
parameterLongName: '--prefix',
description: 'The prefix format for generated files. TIMESTAMP uses a second-resolution timestamp, DATE uses a day-resolution timestamp, and NONE removes the prefix completely',
alternatives: ['TIMESTAMP', 'DATE', 'NONE'],
defaultValue: 'TIMESTAMP',
}),
folder: action.defineStringParameter({
parameterLongName: '--folder',
argumentName: 'PATH',
description: `Path on the filesystem where the file should be created. The new migration will be created as a sibling of the last existing one if this is omitted.`,
}),
allowExtension: action.defineStringListParameter({
parameterLongName: '--allow-extension',
argumentName: 'EXTENSION',
environmentVariable: 'UMZUG_ALLOW_EXTENSION',
description: `Allowable extension for created files. By default .js, .ts and .sql files can be created. To create txt file migrations, for example, you could use '--name my-migration.txt --allow-extension .txt'`,
}),
skipVerify: action.defineFlagParameter({
parameterLongName: '--skip-verify',
description: `By default, the generated file will be checked after creation to make sure it is detected as a pending migration. This catches problems like creation in the wrong folder, or invalid naming conventions. ` +
`This flag bypasses that verification step.`,
}),
allowConfusingOrdering: action.defineFlagParameter({
parameterLongName: '--allow-confusing-ordering',
description: `By default, an error will be thrown if you try to create a migration that will run before a migration that already exists. ` +
`This catches errors which can cause problems if you change file naming conventions. ` +
`If you use a custom ordering system, you can disable this behavior, but it's strongly recommended that you don't! ` +
`If you're unsure, just ignore this option.`,
}),
};
}
onDefineParameters() {
this._params = CreateAction._defineParameters(this);
}
async onExecute() {
await this.umzug
.create({
name: this._params.name.value,
prefix: this._params.prefix.value,
folder: this._params.folder.value,
allowExtension: this._params.allowExtension.values.length > 0 ? this._params.allowExtension.values[0] : undefined,
allowConfusingOrdering: this._params.allowConfusingOrdering.value,
skipVerify: this._params.skipVerify.value,
})
.catch((e) => {
Object.entries(this._params)
.filter(entry => entry[0] !== 'name')
.forEach(([name, param]) => {
var _a;
// replace `skipVerify` in error messages with `--skip-verify`, etc.
e.message = (_a = e.message) === null || _a === void 0 ? void 0 : _a.split(name).join(param.longName);
});
throw e;
});
}
}
exports.CreateAction = CreateAction;
class UmzugCLI extends cli.CommandLineParser {
constructor(umzug, commandLineParserOptions = {}) {
var _a, _b;
super({
toolFilename: (_a = commandLineParserOptions.toolFileName) !== null && _a !== void 0 ? _a : '<script>',
toolDescription: (_b = commandLineParserOptions.toolDescription) !== null && _b !== void 0 ? _b : 'Umzug migrator',
});
this.umzug = umzug;
this.addAction(new UpAction(umzug));
this.addAction(new DownAction(umzug));
this.addAction(new ListAction('pending', umzug));
this.addAction(new ListAction('executed', umzug));
this.addAction(new CreateAction(umzug));
}
onDefineParameters() { }
}
exports.UmzugCLI = UmzugCLI;
//# sourceMappingURL=cli.js.map

1
server/node_modules/umzug/lib/cli.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

46
server/node_modules/umzug/lib/file-locker.d.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/// <reference types="node" />
import * as fs from 'fs';
import type { Umzug } from './umzug';
export type FileLockerOptions = {
path: string;
fs?: typeof fs;
};
/**
* Simple locker using the filesystem. Only one lock can be held per file. An error will be thrown if the
* lock file already exists.
*
* @example
* const umzug = new Umzug({ ... })
* FileLocker.attach(umzug, { path: 'path/to/lockfile' })
*
* @docs
* To wait for the lock to be free instead of throwing, you could extend it (the below example uses `setInterval`,
* but depending on your use-case, you may want to use a library with retry/backoff):
*
* @example
* class WaitingFileLocker extends FileLocker {
* async getLock() {
* return new Promise(resolve => setInterval(
* () => super.getLock().then(resolve).catch(),
* 500,
* )
* }
* }
*
* const locker = new WaitingFileLocker({ path: 'path/to/lockfile' })
* locker.attachTo(umzug)
*/
export declare class FileLocker {
private readonly lockFile;
private readonly fs;
constructor(params: FileLockerOptions);
/** Attach `beforeAll` and `afterAll` events to an umzug instance which use the specified filepath */
static attach(umzug: Umzug, params: FileLockerOptions): void;
/** Attach lock handlers to `beforeCommand` and `afterCommand` events on an umzug instance */
attachTo(umzug: Umzug): void;
private readFile;
private writeFile;
private removeFile;
getLock(): Promise<void>;
releaseLock(): Promise<void>;
}

96
server/node_modules/umzug/lib/file-locker.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileLocker = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
/**
* Simple locker using the filesystem. Only one lock can be held per file. An error will be thrown if the
* lock file already exists.
*
* @example
* const umzug = new Umzug({ ... })
* FileLocker.attach(umzug, { path: 'path/to/lockfile' })
*
* @docs
* To wait for the lock to be free instead of throwing, you could extend it (the below example uses `setInterval`,
* but depending on your use-case, you may want to use a library with retry/backoff):
*
* @example
* class WaitingFileLocker extends FileLocker {
* async getLock() {
* return new Promise(resolve => setInterval(
* () => super.getLock().then(resolve).catch(),
* 500,
* )
* }
* }
*
* const locker = new WaitingFileLocker({ path: 'path/to/lockfile' })
* locker.attachTo(umzug)
*/
class FileLocker {
constructor(params) {
var _a;
this.lockFile = params.path;
this.fs = (_a = params.fs) !== null && _a !== void 0 ? _a : fs;
}
/** Attach `beforeAll` and `afterAll` events to an umzug instance which use the specified filepath */
static attach(umzug, params) {
const locker = new FileLocker(params);
locker.attachTo(umzug);
}
/** Attach lock handlers to `beforeCommand` and `afterCommand` events on an umzug instance */
attachTo(umzug) {
umzug.on('beforeCommand', async () => this.getLock());
umzug.on('afterCommand', async () => this.releaseLock());
}
async readFile(filepath) {
return this.fs.promises.readFile(filepath).then(buf => buf.toString(), () => undefined);
}
async writeFile(filepath, content) {
await this.fs.promises.mkdir(path.dirname(filepath), { recursive: true });
await this.fs.promises.writeFile(filepath, content);
}
async removeFile(filepath) {
await this.fs.promises.unlink(filepath);
}
async getLock() {
const existing = await this.readFile(this.lockFile);
if (existing) {
throw new Error(`Can't acquire lock. ${this.lockFile} exists`);
}
await this.writeFile(this.lockFile, 'lock');
}
async releaseLock() {
const existing = await this.readFile(this.lockFile);
if (!existing) {
throw new Error(`Nothing to unlock`);
}
await this.removeFile(this.lockFile);
}
}
exports.FileLocker = FileLocker;
//# sourceMappingURL=file-locker.js.map

1
server/node_modules/umzug/lib/file-locker.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"file-locker.js","sourceRoot":"","sources":["../src/file-locker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAQ5B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,UAAU;IAIrB,YAAY,MAAyB;;QACnC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,EAAE,GAAG,MAAA,MAAM,CAAC,EAAE,mCAAI,EAAE,CAAA;IAC3B,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,MAAM,CAAC,KAAY,EAAE,MAAyB;QACnD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;QACrC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IAED,6FAA6F;IAC7F,QAAQ,CAAC,KAAY;QACnB,KAAK,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QACrD,KAAK,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IAC1D,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,QAAgB;QACrC,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC7C,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EACrB,GAAG,EAAE,CAAC,SAAS,CAChB,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,OAAe;QACvD,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAA;QACvE,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,QAAgB;QACvC,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACnD,IAAI,QAAQ,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,QAAQ,SAAS,CAAC,CAAA;SAC/D;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC7C,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACnD,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACrC;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtC,CAAC;CACF;AAtDD,gCAsDC"}

5
server/node_modules/umzug/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export * from './umzug';
export * from './storage';
export * from './file-locker';
export * from './types';
export * from './cli';

22
server/node_modules/umzug/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./umzug"), exports);
__exportStar(require("./storage"), exports);
__exportStar(require("./file-locker"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./cli"), exports);
//# sourceMappingURL=index.js.map

1
server/node_modules/umzug/lib/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,4CAAyB;AACzB,gDAA6B;AAC7B,0CAAuB;AACvB,wCAAqB"}

17
server/node_modules/umzug/lib/storage/contract.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { MigrationParams } from '../types';
export type UmzugStorage<Ctx = unknown> = {
/**
* Logs migration to be considered as executed.
*/
logMigration: (params: MigrationParams<Ctx>) => Promise<void>;
/**
* Unlogs migration (makes it to be considered as pending).
*/
unlogMigration: (params: MigrationParams<Ctx>) => Promise<void>;
/**
* Gets list of executed migrations.
*/
executed: (meta: Pick<MigrationParams<Ctx>, 'context'>) => Promise<string[]>;
};
export declare function isUmzugStorage(arg: Partial<UmzugStorage>): arg is UmzugStorage;
export declare const verifyUmzugStorage: (arg: Partial<UmzugStorage>) => UmzugStorage;

18
server/node_modules/umzug/lib/storage/contract.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyUmzugStorage = exports.isUmzugStorage = void 0;
function isUmzugStorage(arg) {
return (arg &&
typeof arg.logMigration === 'function' &&
typeof arg.unlogMigration === 'function' &&
typeof arg.executed === 'function');
}
exports.isUmzugStorage = isUmzugStorage;
const verifyUmzugStorage = (arg) => {
if (!isUmzugStorage(arg)) {
throw new Error(`Invalid umzug storage`);
}
return arg;
};
exports.verifyUmzugStorage = verifyUmzugStorage;
//# sourceMappingURL=contract.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/storage/contract.ts"],"names":[],"mappings":";;;AAmBA,SAAgB,cAAc,CAAC,GAA0B;IACvD,OAAO,CACL,GAAG;QACH,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU;QACtC,OAAO,GAAG,CAAC,cAAc,KAAK,UAAU;QACxC,OAAO,GAAG,CAAC,QAAQ,KAAK,UAAU,CACnC,CAAA;AACH,CAAC;AAPD,wCAOC;AAEM,MAAM,kBAAkB,GAAG,CAAC,GAA0B,EAAgB,EAAE;IAC7E,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;KACzC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AANY,QAAA,kBAAkB,sBAM9B"}

5
server/node_modules/umzug/lib/storage/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export * from './contract';
export * from './json';
export * from './memory';
export * from './mongodb';
export * from './sequelize';

24
server/node_modules/umzug/lib/storage/index.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
// codegen:start {preset: barrel}
__exportStar(require("./contract"), exports);
__exportStar(require("./json"), exports);
__exportStar(require("./memory"), exports);
__exportStar(require("./mongodb"), exports);
__exportStar(require("./sequelize"), exports);
// codegen:end
//# sourceMappingURL=index.js.map

1
server/node_modules/umzug/lib/storage/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,6CAA0B;AAC1B,yCAAsB;AACtB,2CAAwB;AACxB,4CAAyB;AACzB,8CAA2B;AAC3B,cAAc"}

20
server/node_modules/umzug/lib/storage/json.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import type { UmzugStorage } from './contract';
export type JSONStorageConstructorOptions = {
/**
Path to JSON file where the log is stored.
@default './umzug.json'
*/
readonly path?: string;
};
export declare class JSONStorage implements UmzugStorage {
readonly path: string;
constructor(options?: JSONStorageConstructorOptions);
logMigration({ name: migrationName }: {
name: string;
}): Promise<void>;
unlogMigration({ name: migrationName }: {
name: string;
}): Promise<void>;
executed(): Promise<string[]>;
}

61
server/node_modules/umzug/lib/storage/json.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JSONStorage = void 0;
const fs_1 = require("fs");
const path = __importStar(require("path"));
const filesystem = {
/** reads a file as a string or returns null if file doesn't exist */
async readAsync(filepath) {
return fs_1.promises.readFile(filepath).then(c => c.toString(), () => null);
},
/** writes a string as file contents, creating its parent directory if necessary */
async writeAsync(filepath, content) {
await fs_1.promises.mkdir(path.dirname(filepath), { recursive: true });
await fs_1.promises.writeFile(filepath, content);
},
};
class JSONStorage {
constructor(options) {
var _a;
this.path = (_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : path.join(process.cwd(), 'umzug.json');
}
async logMigration({ name: migrationName }) {
const loggedMigrations = await this.executed();
loggedMigrations.push(migrationName);
await filesystem.writeAsync(this.path, JSON.stringify(loggedMigrations, null, 2));
}
async unlogMigration({ name: migrationName }) {
const loggedMigrations = await this.executed();
const updatedMigrations = loggedMigrations.filter(name => name !== migrationName);
await filesystem.writeAsync(this.path, JSON.stringify(updatedMigrations, null, 2));
}
async executed() {
const content = await filesystem.readAsync(this.path);
return content ? JSON.parse(content) : [];
}
}
exports.JSONStorage = JSONStorage;
//# sourceMappingURL=json.js.map

1
server/node_modules/umzug/lib/storage/json.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/storage/json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAiC;AACjC,2CAA4B;AAG5B,MAAM,UAAU,GAAG;IACjB,qEAAqE;IACrE,KAAK,CAAC,SAAS,CAAC,QAAgB;QAC9B,OAAO,aAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC/B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,EACjB,GAAG,EAAE,CA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AAC,QAAQ;QACZ,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,OAAO,OAAO,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IACzD,CAAC;CACF;AAzBD,kCAyBC"}

2
server/node_modules/umzug/lib/storage/memory.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import type { UmzugStorage } from './contract';
export declare const memoryStorage: () => UmzugStorage;

17
server/node_modules/umzug/lib/storage/memory.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.memoryStorage = void 0;
const memoryStorage = () => {
let executed = [];
return {
async logMigration({ name }) {
executed.push(name);
},
async unlogMigration({ name }) {
executed = executed.filter(n => n !== name);
},
executed: async () => [...executed],
};
};
exports.memoryStorage = memoryStorage;
//# sourceMappingURL=memory.js.map

1
server/node_modules/umzug/lib/storage/memory.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/storage/memory.ts"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,GAAiB,EAAE;IAC9C,IAAI,QAAQ,GAAa,EAAE,CAAA;IAC3B,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,EAAC,IAAI,EAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;QACD,KAAK,CAAC,cAAc,CAAC,EAAC,IAAI,EAAC;YACzB,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;QAC7C,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;KACpC,CAAA;AACH,CAAC,CAAA;AAXY,QAAA,aAAa,iBAWzB"}

35
server/node_modules/umzug/lib/storage/mongodb.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
import type { UmzugStorage } from './contract';
type AnyObject = Record<string, any>;
export type MongoDBConnectionOptions = {
/**
A connection to target database established with MongoDB Driver
*/
readonly connection: AnyObject;
/**
The name of the migration collection in MongoDB
@default 'migrations'
*/
readonly collectionName?: string;
};
export type MongoDBCollectionOptions = {
/**
A reference to a MongoDB Driver collection
*/
readonly collection: AnyObject;
};
export type MongoDBStorageConstructorOptions = MongoDBConnectionOptions | MongoDBCollectionOptions;
export declare class MongoDBStorage implements UmzugStorage {
readonly collection: AnyObject;
readonly connection: any;
readonly collectionName: string;
constructor(options: MongoDBStorageConstructorOptions);
logMigration({ name: migrationName }: {
name: string;
}): Promise<void>;
unlogMigration({ name: migrationName }: {
name: string;
}): Promise<void>;
executed(): Promise<string[]>;
}
export {};

31
server/node_modules/umzug/lib/storage/mongodb.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MongoDBStorage = void 0;
function isMongoDBCollectionOptions(arg) {
return Boolean(arg.collection);
}
class MongoDBStorage {
constructor(options) {
var _a, _b;
if (!options || (!options.collection && !options.connection)) {
throw new Error('MongoDB Connection or Collection required');
}
this.collection = isMongoDBCollectionOptions(options)
? options.collection
: options.connection.collection((_a = options.collectionName) !== null && _a !== void 0 ? _a : 'migrations');
this.connection = options.connection; // TODO remove this
this.collectionName = (_b = options.collectionName) !== null && _b !== void 0 ? _b : 'migrations'; // TODO remove this
}
async logMigration({ name: migrationName }) {
await this.collection.insertOne({ migrationName });
}
async unlogMigration({ name: migrationName }) {
await this.collection.deleteOne({ migrationName });
}
async executed() {
const records = await this.collection.find({}).sort({ migrationName: 1 }).toArray();
return records.map(r => r.migrationName);
}
}
exports.MongoDBStorage = MongoDBStorage;
//# sourceMappingURL=mongodb.js.map

1
server/node_modules/umzug/lib/storage/mongodb.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
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O,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;IAC1C,CAAC;CACF;AA/BD,wCA+BC"}

106
server/node_modules/umzug/lib/storage/sequelize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,106 @@
import type { SetRequired } from 'type-fest';
import type { UmzugStorage } from './contract';
type ModelTempInterface = {} & ModelClass & Record<string, any>;
/**
* Minimal structure of a sequelize model, defined here to avoid a hard dependency.
* The type expected is `import { Model } from 'sequelize'`
*/
export type ModelClass = {
tableName: string;
sequelize?: SequelizeType;
getTableName(): string;
sync(): Promise<void>;
findAll(options?: {}): Promise<any[]>;
create(options: {}): Promise<void>;
destroy(options: {}): Promise<void>;
};
/**
* Minimal structure of a sequelize model, defined here to avoid a hard dependency.
* The type expected is `import { Sequelize } from 'sequelize'`
*/
export type SequelizeType = {
getQueryInterface(): any;
isDefined(modelName: string): boolean;
model(modelName: string): any;
define(modelName: string, columns: {}, options: {}): {};
dialect?: {
name?: string;
};
};
type ModelClassType = ModelClass & (new (values?: object, options?: any) => ModelTempInterface);
type _SequelizeStorageConstructorOptions = {
/**
The configured instance of Sequelize. If omitted, it is inferred from the `model` option.
*/
readonly sequelize?: SequelizeType;
/**
The model representing the SequelizeMeta table. Must have a column that matches the `columnName` option. If omitted, it is created automatically.
*/
readonly model?: any;
/**
The name of the model.
@default 'SequelizeMeta'
*/
readonly modelName?: string;
/**
The name of the table. If omitted, defaults to the model name.
*/
readonly tableName?: string;
/**
Name of the schema under which the table is to be created.
@default undefined
*/
readonly schema?: any;
/**
Name of the table column holding the executed migration names.
@default 'name'
*/
readonly columnName?: string;
/**
The type of the column holding the executed migration names.
For `utf8mb4` charsets under InnoDB, you may need to set this to less than 190
@default Sequelize.DataTypes.STRING
*/
readonly columnType?: any;
/**
Option to add timestamps to the table
@default false
*/
readonly timestamps?: boolean;
};
export type SequelizeStorageConstructorOptions = SetRequired<_SequelizeStorageConstructorOptions, 'sequelize'> | SetRequired<_SequelizeStorageConstructorOptions, 'model'>;
export declare class SequelizeStorage implements UmzugStorage {
readonly sequelize: SequelizeType;
readonly columnType: string;
readonly columnName: string;
readonly timestamps: boolean;
readonly modelName: string;
readonly tableName?: string;
readonly schema: any;
readonly model: ModelClassType;
/**
Constructs Sequelize based storage. Migrations will be stored in a SequelizeMeta table using the given instance of Sequelize.
If a model is given, it will be used directly as the model for the SequelizeMeta table. Otherwise, it will be created automatically according to the given options.
If the table does not exist it will be created automatically upon the logging of the first migration.
*/
constructor(options: SequelizeStorageConstructorOptions);
getModel(): ModelClassType;
protected syncModel(): Promise<void>;
logMigration({ name: migrationName }: {
name: string;
}): Promise<void>;
unlogMigration({ name: migrationName }: {
name: string;
}): Promise<void>;
executed(): Promise<string[]>;
_model(): ModelClassType;
}
export {};

85
server/node_modules/umzug/lib/storage/sequelize.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SequelizeStorage = void 0;
const DIALECTS_WITH_CHARSET_AND_COLLATE = new Set(['mysql', 'mariadb']);
class SequelizeStorage {
/**
Constructs Sequelize based storage. Migrations will be stored in a SequelizeMeta table using the given instance of Sequelize.
If a model is given, it will be used directly as the model for the SequelizeMeta table. Otherwise, it will be created automatically according to the given options.
If the table does not exist it will be created automatically upon the logging of the first migration.
*/
constructor(options) {
var _a, _b, _c, _d, _e, _f;
if (!options || (!options.model && !options.sequelize)) {
throw new Error('One of "sequelize" or "model" storage option is required');
}
this.sequelize = (_a = options.sequelize) !== null && _a !== void 0 ? _a : options.model.sequelize;
this.columnType = (_b = options.columnType) !== null && _b !== void 0 ? _b : this.sequelize.constructor.DataTypes.STRING;
this.columnName = (_c = options.columnName) !== null && _c !== void 0 ? _c : 'name';
this.timestamps = (_d = options.timestamps) !== null && _d !== void 0 ? _d : false;
this.modelName = (_e = options.modelName) !== null && _e !== void 0 ? _e : 'SequelizeMeta';
this.tableName = options.tableName;
this.schema = options.schema;
this.model = (_f = options.model) !== null && _f !== void 0 ? _f : this.getModel();
}
getModel() {
var _a;
if (this.sequelize.isDefined(this.modelName)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this.sequelize.model(this.modelName);
}
const dialectName = (_a = this.sequelize.dialect) === null || _a === void 0 ? void 0 : _a.name;
const hasCharsetAndCollate = dialectName && DIALECTS_WITH_CHARSET_AND_COLLATE.has(dialectName);
return this.sequelize.define(this.modelName, {
[this.columnName]: {
type: this.columnType,
allowNull: false,
unique: true,
primaryKey: true,
autoIncrement: false,
},
}, {
tableName: this.tableName,
schema: this.schema,
timestamps: this.timestamps,
charset: hasCharsetAndCollate ? 'utf8' : undefined,
collate: hasCharsetAndCollate ? 'utf8_unicode_ci' : undefined,
});
}
async syncModel() {
await this.model.sync();
}
async logMigration({ name: migrationName }) {
await this.syncModel();
await this.model.create({
[this.columnName]: migrationName,
});
}
async unlogMigration({ name: migrationName }) {
await this.syncModel();
await this.model.destroy({
where: {
[this.columnName]: migrationName,
},
});
}
async executed() {
await this.syncModel();
const migrations = await this.model.findAll({ order: [[this.columnName, 'ASC']] });
return migrations.map(migration => {
const name = migration[this.columnName];
if (typeof name !== 'string') {
throw new TypeError(`Unexpected migration name type: expected string, got ${typeof name}`);
}
return name;
});
}
// TODO remove this
_model() {
return this.model;
}
}
exports.SequelizeStorage = SequelizeStorage;
//# sourceMappingURL=sequelize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sequelize.js","sourceRoot":"","sources":["../../src/storage/sequelize.ts"],"names":[],"mappings":";;;AAmCA,MAAM,iCAAiC,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;AA8DvE,MAAa,gBAAgB;IAU3B;;;;;;QAMC;IACD,YAAY,OAA2C;;QACrD,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtD,MAAM,IAAI,KAAK,CA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AI,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,MAAM,IAAI,SAAS,CAAC,wDAAwD,OAAO,IAAI,EAAE,CAAC,CAAA;aAC3F;YAED,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,mBAAmB;IACnB,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAnGD,4CAmGC"}

5
server/node_modules/umzug/lib/templates.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export declare const js: string;
export declare const ts: string;
export declare const mjs: string;
export declare const sqlUp: string;
export declare const sqlDown: string;

32
server/node_modules/umzug/lib/templates.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
/* eslint-disable unicorn/template-indent */
// templates for migration file creation
Object.defineProperty(exports, "__esModule", { value: true });
exports.sqlDown = exports.sqlUp = exports.mjs = exports.ts = exports.js = void 0;
exports.js = `
/** @type {import('umzug').MigrationFn<any>} */
exports.up = async params => {};
/** @type {import('umzug').MigrationFn<any>} */
exports.down = async params => {};
`.trimStart();
exports.ts = `
import type { MigrationFn } from 'umzug';
export const up: MigrationFn = async params => {};
export const down: MigrationFn = async params => {};
`.trimStart();
exports.mjs = `
/** @type {import('umzug').MigrationFn<any>} */
export const up = async params => {};
/** @type {import('umzug').MigrationFn<any>} */
export const down = async params => {};
`.trimStart();
exports.sqlUp = `
-- up migration
`.trimStart();
exports.sqlDown = `
-- down migration
`.trimStart();
//# sourceMappingURL=templates.js.map

1
server/node_modules/umzug/lib/templates.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,wCAAwC;;;AAE3B,QAAA,EAAE,GAAG;;;;;;CAMjB,CAAC,SAAS,EAAE,CAAA;AAEA,QAAA,EAAE,GAAG;;;;;CAKjB,CAAC,SAAS,EAAE,CAAA;AAEA,QAAA,GAAG,GAAG;;;;;;CAMlB,CAAC,SAAS,EAAE,CAAA;AAEA,QAAA,KAAK,GAAG;;CAEpB,CAAC,SAAS,EAAE,CAAA;AAEA,QAAA,OAAO,GAAG;;CAEtB,CAAC,SAAS,EAAE,CAAA"}

129
server/node_modules/umzug/lib/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,129 @@
import type * as typeFest from 'type-fest';
import type { UmzugStorage } from './storage';
/**
* Create a type that has mutually exclusive keys.
* Wrapper for @see `import('type-fest').MergeExclusive` that works for three types
*/
export type MergeExclusive<A, B, C> = typeFest.MergeExclusive<A, typeFest.MergeExclusive<B, C>>;
export type Promisable<T> = T | PromiseLike<T>;
export type LogFn = (message: Record<string, unknown>) => void;
/** Constructor options for the Umzug class */
export type UmzugOptions<Ctx extends {} = Record<string, unknown>> = {
/** The migrations that the Umzug instance should perform */
migrations: InputMigrations<Ctx>;
/** A logging function. Pass `console` to use stdout, or pass in your own logger. Pass `undefined` explicitly to disable logging. */
logger: Record<'info' | 'warn' | 'error' | 'debug', LogFn> | undefined;
/** The storage implementation. By default, `JSONStorage` will be used */
storage?: UmzugStorage<Ctx>;
/** An optional context object, which will be passed to each migration function, if defined */
context?: Ctx | (() => Promise<Ctx> | Ctx);
/** Options for file creation */
create?: {
/**
* A function for generating placeholder migration files. Specify to make sure files generated via CLI or using `.create` follow team conventions.
* Should return an array of [filepath, content] pairs. Usually, only one pair is needed, but to put `down` migrations in a separate
* file, more than one can be returned.
*/
template?: (filepath: string) => Promisable<Array<[string, string]>>;
/**
* The default folder that new migration files should be generated in. If this is not specified, the new migration file will be created
* in the same folder as the last existing migration. The value here can be overriden by passing `folder` when calling `create`.
*/
folder?: string;
};
};
/** Serializeable metadata for a migration. The structure returned by the external-facing `pending()` and `executed()` methods. */
export type MigrationMeta = {
/** Name - this is used as the migration unique identifier within storage */
name: string;
/** An optional filepath for the migration. Note: this may be undefined, since not all migrations correspond to files on the filesystem */
path?: string;
};
export type MigrationParams<T> = {
name: string;
path?: string;
context: T;
};
/** A callable function for applying or reverting a migration */
export type MigrationFn<T = unknown> = (params: MigrationParams<T>) => Promise<unknown>;
/**
* A runnable migration. Represents a migration object with an `up` function which can be called directly, with no arguments, and an optional `down` function to revert it.
*/
export type RunnableMigration<T> = {
/** The effect of applying the migration */
up: MigrationFn<T>;
/** The effect of reverting the migration */
down?: MigrationFn<T>;
} & MigrationMeta;
/** Glob instructions for migration files */
export type GlobInputMigrations<T> = {
/**
* A glob string for migration files. Can also be in the format `[path/to/migrations/*.js', {cwd: 'some/base/dir', ignore: '**ignoreme.js' }]`
* See https://npmjs.com/package/glob for more details on the glob format - this package is used internally.
*/
glob: string | [string, {
cwd?: string;
ignore?: string | string[];
}];
/** Will be supplied to every migration function. Can be a database client, for example */
/** A function which takes a migration name, path and context, and returns an object with `up` and `down` functions. */
resolve?: Resolver<T>;
};
/**
* Allowable inputs for migrations. Can be either glob instructions for migration files, a list of runnable migrations, or a
* function which receives a context and returns a list of migrations.
*/
export type InputMigrations<T> = GlobInputMigrations<T> | Array<RunnableMigration<T>> | ((context: T) => Promisable<InputMigrations<T>>);
/** A function which takes a migration name, path and context, and returns an object with `up` and `down` functions. */
export type Resolver<T> = (params: MigrationParams<T>) => RunnableMigration<T>;
export declare const RerunBehavior: {
/** Hard error if an up migration that has already been run, or a down migration that hasn't, is encountered */
readonly THROW: "THROW";
/** Silently skip up migrations that have already been run, or down migrations that haven't */
readonly SKIP: "SKIP";
/** Re-run up migrations that have already been run, or down migrations that haven't */
readonly ALLOW: "ALLOW";
};
export type RerunBehavior = keyof typeof RerunBehavior;
export type MigrateUpOptions = MergeExclusive<{
/** If specified, migrations up to and including this name will be run. Otherwise, all pending migrations will be run */
to?: string;
}, {
/** Only run this many migrations. If not specified, all pending migrations will be run */
step: number;
}, {
/** If specified, only the migrations with these names migrations will be run. An error will be thrown if any of the names are not found in the list of available migrations */
migrations: string[];
/** What to do if a migration that has already been run is explicitly specified. Default is `THROW`. */
rerun?: RerunBehavior;
}>;
export type MigrateDownOptions = MergeExclusive<{
/** If specified, migrations down to and including this name will be revert. Otherwise, only the last executed will be reverted */
to?: string | 0;
}, {
/** Revert this many migrations. If not specified, only the most recent migration will be reverted */
step: number;
}, {
/**
* If specified, only the migrations with these names migrations will be reverted. An error will be thrown if any of the names are not found in the list of executed migrations.
* Note, migrations will be run in the order specified.
*/
migrations: string[];
/** What to do if a migration that has not been run is explicitly specified. Default is `THROW`. */
rerun?: RerunBehavior;
}>;
/** Map of eventName -> eventData type, where the keys are the string events that are emitted by an umzug instances, and the values are the payload emitted with the corresponding event. */
export type UmzugEvents<Ctx> = {
migrating: MigrationParams<Ctx>;
migrated: MigrationParams<Ctx>;
reverting: MigrationParams<Ctx>;
reverted: MigrationParams<Ctx>;
beforeCommand: {
command: string;
context: Ctx;
};
afterCommand: {
command: string;
context: Ctx;
};
};

12
server/node_modules/umzug/lib/types.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RerunBehavior = void 0;
exports.RerunBehavior = {
/** Hard error if an up migration that has already been run, or a down migration that hasn't, is encountered */
THROW: 'THROW',
/** Silently skip up migrations that have already been run, or down migrations that haven't */
SKIP: 'SKIP',
/** Re-run up migrations that have already been run, or down migrations that haven't */
ALLOW: 'ALLOW',
};
//# sourceMappingURL=types.js.map

1
server/node_modules/umzug/lib/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA0Fa,QAAA,aAAa,GAAG;IAC3B,+GAA+G;IAC/G,KAAK,EAAE,OAAO;IACd,8FAA8F;IAC9F,IAAI,EAAE,MAAM;IACZ,uFAAuF;IACvF,KAAK,EAAE,OAAO;CACN,CAAA"}

105
server/node_modules/umzug/lib/umzug.d.ts generated vendored Normal file
View File

@@ -0,0 +1,105 @@
import emittery from 'emittery';
import * as errorCause from 'pony-cause';
import type { CommandLineParserOptions } from './cli';
import { UmzugCLI } from './cli';
import type { MigrateDownOptions, MigrateUpOptions, MigrationMeta, MigrationParams, Resolver, RunnableMigration, UmzugEvents, UmzugOptions } from './types';
type MigrationErrorParams = {
direction: 'up' | 'down';
} & MigrationParams<unknown>;
export declare class MigrationError extends errorCause.ErrorWithCause<unknown> {
name: string;
migration: MigrationErrorParams;
jse_cause: unknown;
constructor(migration: MigrationErrorParams, original: unknown);
get info(): MigrationErrorParams;
private static errorString;
}
export declare class Umzug<Ctx extends object = object> extends emittery<UmzugEvents<Ctx>> {
readonly options: UmzugOptions<Ctx>;
private readonly storage;
readonly migrations: (ctx: Ctx) => Promise<ReadonlyArray<RunnableMigration<Ctx>>>;
/**
* Compile-time only property for type inference. After creating an Umzug instance, it can be used as type alias for
* a user-defined migration. The function receives a migration name, path and the context for an umzug instance
* @example
* ```
* // migrator.ts
* import { Umzug } from 'umzug'
*
* const umzug = new Umzug({...})
* export type Migration = typeof umzug._types.migration;
*
* umzug.up();
* ```
* ___
*
* ```
* // migration-1.ts
* import type { Migration } from '../migrator'
*
* // name and context will now be strongly-typed
* export const up: Migration = ({name, context}) => context.query(...)
* export const down: Migration = ({name, context}) => context.query(...)
* ```
*/
readonly _types: {
migration: (params: MigrationParams<Ctx>) => Promise<unknown>;
context: Ctx;
};
/** creates a new Umzug instance */
constructor(options: UmzugOptions<Ctx>);
private logging;
static defaultResolver: Resolver<unknown>;
/**
* Get an UmzugCLI instance. This can be overriden in a subclass to add/remove commands - only use if you really know you need this,
* and are OK to learn about/interact with the API of @rushstack/ts-command-line.
*/
protected getCli(options?: CommandLineParserOptions): UmzugCLI;
/**
* 'Run' an umzug instance as a CLI. This will read `process.argv`, execute commands based on that, and call
* `process.exit` after running. If that isn't what you want, stick to the programmatic API.
* You probably want to run only if a file is executed as the process's 'main' module with something like:
* @example
* if (require.main === module) {
* myUmzugInstance.runAsCLI()
* }
*/
runAsCLI(argv?: string[]): Promise<boolean>;
/** Get the list of migrations which have already been applied */
executed(): Promise<MigrationMeta[]>;
/** Get the list of migrations which have already been applied */
private _executed;
/** Get the list of migrations which are yet to be applied */
pending(): Promise<MigrationMeta[]>;
private _pending;
protected runCommand<T>(command: string, cb: (commandParams: {
context: Ctx;
}) => Promise<T>): Promise<T>;
/**
* Apply migrations. By default, runs all pending migrations.
* @see MigrateUpOptions for other use cases using `to`, `migrations` and `rerun`.
*/
up(options?: MigrateUpOptions): Promise<MigrationMeta[]>;
/**
* Revert migrations. By default, the last executed migration is reverted.
* @see MigrateDownOptions for other use cases using `to`, `migrations` and `rerun`.
*/
down(options?: MigrateDownOptions): Promise<MigrationMeta[]>;
create(options: {
name: string;
folder?: string;
prefix?: 'TIMESTAMP' | 'DATE' | 'NONE';
allowExtension?: string;
allowConfusingOrdering?: boolean;
skipVerify?: boolean;
/** Optionally define the content for the new file. If not set, the configured template will be used. */
content?: string;
}): Promise<void>;
private static defaultCreationTemplate;
private findNameIndex;
private findMigrations;
private getContext;
/** helper for parsing input migrations into a callback returning a list of ready-to-run migrations */
private getMigrationsResolver;
}
export {};

412
server/node_modules/umzug/lib/umzug.js generated vendored Normal file
View File

@@ -0,0 +1,412 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Umzug = exports.MigrationError = void 0;
const emittery_1 = __importDefault(require("emittery"));
const fast_glob_1 = require("fast-glob");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const errorCause = __importStar(require("pony-cause"));
const cli_1 = require("./cli");
const storage_1 = require("./storage");
const templates = __importStar(require("./templates"));
const types_1 = require("./types");
class MigrationError extends errorCause.ErrorWithCause {
// TODO [>=4.0.0] Take a `{ cause: ... }` options bag like the default `Error`, it looks like this because of verror backwards-compatibility.
constructor(migration, original) {
super(`Migration ${migration.name} (${migration.direction}) failed: ${MigrationError.errorString(original)}`, {
cause: original,
});
this.name = 'MigrationError';
this.jse_cause = original;
this.migration = migration;
}
// TODO [>=4.0.0] Remove this backwards-compatibility alias
get info() {
return this.migration;
}
static errorString(cause) {
return cause instanceof Error
? `Original error: ${cause.message}`
: `Non-error value thrown. See info for full props: ${cause}`;
}
}
exports.MigrationError = MigrationError;
class Umzug extends emittery_1.default {
/** creates a new Umzug instance */
constructor(options) {
var _b;
super();
this.options = options;
this.storage = (0, storage_1.verifyUmzugStorage)((_b = options.storage) !== null && _b !== void 0 ? _b : new storage_1.JSONStorage());
this.migrations = this.getMigrationsResolver(this.options.migrations);
}
logging(message) {
var _b;
(_b = this.options.logger) === null || _b === void 0 ? void 0 : _b.info(message);
}
/**
* Get an UmzugCLI instance. This can be overriden in a subclass to add/remove commands - only use if you really know you need this,
* and are OK to learn about/interact with the API of @rushstack/ts-command-line.
*/
getCli(options) {
return new cli_1.UmzugCLI(this, options);
}
/**
* 'Run' an umzug instance as a CLI. This will read `process.argv`, execute commands based on that, and call
* `process.exit` after running. If that isn't what you want, stick to the programmatic API.
* You probably want to run only if a file is executed as the process's 'main' module with something like:
* @example
* if (require.main === module) {
* myUmzugInstance.runAsCLI()
* }
*/
async runAsCLI(argv) {
const cli = this.getCli();
return cli.execute(argv);
}
/** Get the list of migrations which have already been applied */
async executed() {
return this.runCommand('executed', async ({ context }) => {
const list = await this._executed(context);
// We do the following to not expose the `up` and `down` functions to the user
return list.map(m => ({ name: m.name, path: m.path }));
});
}
/** Get the list of migrations which have already been applied */
async _executed(context) {
const [migrations, executedNames] = await Promise.all([this.migrations(context), this.storage.executed({ context })]);
const executedSet = new Set(executedNames);
return migrations.filter(m => executedSet.has(m.name));
}
/** Get the list of migrations which are yet to be applied */
async pending() {
return this.runCommand('pending', async ({ context }) => {
const list = await this._pending(context);
// We do the following to not expose the `up` and `down` functions to the user
return list.map(m => ({ name: m.name, path: m.path }));
});
}
async _pending(context) {
const [migrations, executedNames] = await Promise.all([this.migrations(context), this.storage.executed({ context })]);
const executedSet = new Set(executedNames);
return migrations.filter(m => !executedSet.has(m.name));
}
async runCommand(command, cb) {
const context = await this.getContext();
await this.emit('beforeCommand', { command, context });
try {
return await cb({ context });
}
finally {
await this.emit('afterCommand', { command, context });
}
}
/**
* Apply migrations. By default, runs all pending migrations.
* @see MigrateUpOptions for other use cases using `to`, `migrations` and `rerun`.
*/
async up(options = {}) {
const eligibleMigrations = async (context) => {
var _b;
if (options.migrations && options.rerun === types_1.RerunBehavior.ALLOW) {
// Allow rerun means the specified migrations should be run even if they've run before - so get all migrations, not just pending
const list = await this.migrations(context);
return this.findMigrations(list, options.migrations);
}
if (options.migrations && options.rerun === types_1.RerunBehavior.SKIP) {
const executedNames = new Set((await this._executed(context)).map(m => m.name));
const filteredMigrations = options.migrations.filter(m => !executedNames.has(m));
return this.findMigrations(await this.migrations(context), filteredMigrations);
}
if (options.migrations) {
return this.findMigrations(await this._pending(context), options.migrations);
}
const allPending = await this._pending(context);
let sliceIndex = (_b = options.step) !== null && _b !== void 0 ? _b : allPending.length;
if (options.to) {
sliceIndex = this.findNameIndex(allPending, options.to) + 1;
}
return allPending.slice(0, sliceIndex);
};
return this.runCommand('up', async ({ context }) => {
const toBeApplied = await eligibleMigrations(context);
for (const m of toBeApplied) {
const start = Date.now();
const params = { name: m.name, path: m.path, context };
this.logging({ event: 'migrating', name: m.name });
await this.emit('migrating', params);
try {
await m.up(params);
}
catch (e) {
throw new MigrationError({ direction: 'up', ...params }, e);
}
await this.storage.logMigration(params);
const duration = (Date.now() - start) / 1000;
this.logging({ event: 'migrated', name: m.name, durationSeconds: duration });
await this.emit('migrated', params);
}
return toBeApplied.map(m => ({ name: m.name, path: m.path }));
});
}
/**
* Revert migrations. By default, the last executed migration is reverted.
* @see MigrateDownOptions for other use cases using `to`, `migrations` and `rerun`.
*/
async down(options = {}) {
const eligibleMigrations = async (context) => {
var _b;
if (options.migrations && options.rerun === types_1.RerunBehavior.ALLOW) {
const list = await this.migrations(context);
return this.findMigrations(list, options.migrations);
}
if (options.migrations && options.rerun === types_1.RerunBehavior.SKIP) {
const pendingNames = new Set((await this._pending(context)).map(m => m.name));
const filteredMigrations = options.migrations.filter(m => !pendingNames.has(m));
return this.findMigrations(await this.migrations(context), filteredMigrations);
}
if (options.migrations) {
return this.findMigrations(await this._executed(context), options.migrations);
}
const executedReversed = (await this._executed(context)).slice().reverse();
let sliceIndex = (_b = options.step) !== null && _b !== void 0 ? _b : 1;
if (options.to === 0 || options.migrations) {
sliceIndex = executedReversed.length;
}
else if (options.to) {
sliceIndex = this.findNameIndex(executedReversed, options.to) + 1;
}
return executedReversed.slice(0, sliceIndex);
};
return this.runCommand('down', async ({ context }) => {
var _b;
const toBeReverted = await eligibleMigrations(context);
for (const m of toBeReverted) {
const start = Date.now();
const params = { name: m.name, path: m.path, context };
this.logging({ event: 'reverting', name: m.name });
await this.emit('reverting', params);
try {
await ((_b = m.down) === null || _b === void 0 ? void 0 : _b.call(m, params));
}
catch (e) {
throw new MigrationError({ direction: 'down', ...params }, e);
}
await this.storage.unlogMigration(params);
const duration = Number.parseFloat(((Date.now() - start) / 1000).toFixed(3));
this.logging({ event: 'reverted', name: m.name, durationSeconds: duration });
await this.emit('reverted', params);
}
return toBeReverted.map(m => ({ name: m.name, path: m.path }));
});
}
async create(options) {
await this.runCommand('create', async ({ context }) => {
var _b, _c, _d, _e;
const isoDate = new Date().toISOString();
const prefixes = {
TIMESTAMP: isoDate.replace(/\.\d{3}Z$/, '').replace(/\W/g, '.'),
DATE: isoDate.split('T')[0].replace(/\W/g, '.'),
NONE: '',
};
const prefixType = (_b = options.prefix) !== null && _b !== void 0 ? _b : 'TIMESTAMP';
const fileBasename = [prefixes[prefixType], options.name].filter(Boolean).join('.');
const allowedExtensions = options.allowExtension
? [options.allowExtension]
: ['.js', '.cjs', '.mjs', '.ts', '.cts', '.mts', '.sql'];
const existing = await this.migrations(context);
const last = existing.slice(-1)[0];
const folder = options.folder || ((_c = this.options.create) === null || _c === void 0 ? void 0 : _c.folder) || ((last === null || last === void 0 ? void 0 : last.path) && path.dirname(last.path));
if (!folder) {
throw new Error(`Couldn't infer a directory to generate migration file in. Pass folder explicitly`);
}
const filepath = path.join(folder, fileBasename);
if (!options.allowConfusingOrdering) {
const confusinglyOrdered = existing.find(e => e.path && e.path >= filepath);
if (confusinglyOrdered) {
throw new Error(`Can't create ${fileBasename}, since it's unclear if it should run before or after existing migration ${confusinglyOrdered.name}. Use allowConfusingOrdering to bypass this error.`);
}
}
const template = typeof options.content === 'string'
? async () => [[filepath, options.content]]
: // eslint-disable-next-line @typescript-eslint/unbound-method
(_e = (_d = this.options.create) === null || _d === void 0 ? void 0 : _d.template) !== null && _e !== void 0 ? _e : Umzug.defaultCreationTemplate;
const toWrite = await template(filepath);
if (toWrite.length === 0) {
toWrite.push([filepath, '']);
}
toWrite.forEach(pair => {
if (!Array.isArray(pair) || pair.length !== 2) {
throw new Error(`Expected [filepath, content] pair. Check that the file template function returns an array of pairs.`);
}
const ext = path.extname(pair[0]);
if (!allowedExtensions.includes(ext)) {
const allowStr = allowedExtensions.join(', ');
const message = `Extension ${ext} not allowed. Allowed extensions are ${allowStr}. See help for allowExtension to avoid this error.`;
throw new Error(message);
}
fs.mkdirSync(path.dirname(pair[0]), { recursive: true });
fs.writeFileSync(pair[0], pair[1]);
this.logging({ event: 'created', path: pair[0] });
});
if (!options.skipVerify) {
const [firstFilePath] = toWrite[0];
const pending = await this._pending(context);
if (!pending.some(p => p.path && path.resolve(p.path) === path.resolve(firstFilePath))) {
const paths = pending.map(p => p.path).join(', ');
throw new Error(`Expected ${firstFilePath} to be a pending migration but it wasn't! Pending migration paths: ${paths}. You should investigate this. Use skipVerify to bypass this error.`);
}
}
});
}
static defaultCreationTemplate(filepath) {
const ext = path.extname(filepath);
if ((ext === '.js' && typeof require.main === 'object') || ext === '.cjs') {
return [[filepath, templates.js]];
}
if (ext === '.ts' || ext === '.mts' || ext === '.cts') {
return [[filepath, templates.ts]];
}
if ((ext === '.js' && require.main === undefined) || ext === '.mjs') {
return [[filepath, templates.mjs]];
}
if (ext === '.sql') {
const downFilepath = path.join(path.dirname(filepath), 'down', path.basename(filepath));
return [
[filepath, templates.sqlUp],
[downFilepath, templates.sqlDown],
];
}
return [];
}
findNameIndex(migrations, name) {
const index = migrations.findIndex(m => m.name === name);
if (index === -1) {
throw new Error(`Couldn't find migration to apply with name ${JSON.stringify(name)}`);
}
return index;
}
findMigrations(migrations, names) {
const map = new Map(migrations.map(m => [m.name, m]));
return names.map(name => {
const migration = map.get(name);
if (!migration) {
throw new Error(`Couldn't find migration to apply with name ${JSON.stringify(name)}`);
}
return migration;
});
}
async getContext() {
const { context = {} } = this.options;
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return typeof context === 'function' ? context() : context;
}
/** helper for parsing input migrations into a callback returning a list of ready-to-run migrations */
getMigrationsResolver(inputMigrations) {
var _b;
if (Array.isArray(inputMigrations)) {
return async () => inputMigrations;
}
if (typeof inputMigrations === 'function') {
// Lazy migrations definition, recurse.
return async (ctx) => {
const resolved = await inputMigrations(ctx);
return this.getMigrationsResolver(resolved)(ctx);
};
}
const fileGlob = inputMigrations.glob;
const [globString, globOptions] = Array.isArray(fileGlob) ? fileGlob : [fileGlob];
const ignore = typeof (globOptions === null || globOptions === void 0 ? void 0 : globOptions.ignore) === 'string' ? [globOptions.ignore] : globOptions === null || globOptions === void 0 ? void 0 : globOptions.ignore;
const resolver = (_b = inputMigrations.resolve) !== null && _b !== void 0 ? _b : Umzug.defaultResolver;
return async (context) => {
const paths = await (0, fast_glob_1.glob)(globString, { ...globOptions, ignore, absolute: true });
paths.sort(); // glob returns results in reverse alphabetical order these days, but it has never guaranteed not to do that https://github.com/isaacs/node-glob/issues/570
return paths.map(unresolvedPath => {
const filepath = path.resolve(unresolvedPath);
const name = path.basename(filepath);
return {
path: filepath,
...resolver({ name, path: filepath, context }),
};
});
};
}
}
exports.Umzug = Umzug;
_a = Umzug;
Umzug.defaultResolver = ({ name, path: filepath }) => {
if (!filepath) {
throw new Error(`Can't use default resolver for non-filesystem migrations`);
}
const ext = path.extname(filepath);
const languageSpecificHelp = {
'.ts': "TypeScript files can be required by adding `ts-node` as a dependency and calling `require('ts-node/register')` at the program entrypoint before running migrations.",
'.sql': 'Try writing a resolver which reads file content and executes it as a sql query.',
};
languageSpecificHelp['.cts'] = languageSpecificHelp['.ts'];
languageSpecificHelp['.mts'] = languageSpecificHelp['.ts'];
let loadModule;
const jsExt = ext.replace(/\.([cm]?)ts$/, '.$1js');
const getModule = async () => {
try {
return await loadModule();
}
catch (e) {
if ((e instanceof SyntaxError || e instanceof MissingResolverError) && ext in languageSpecificHelp) {
e.message += '\n\n' + languageSpecificHelp[ext];
}
throw e;
}
};
if ((jsExt === '.js' && typeof require.main === 'object') || jsExt === '.cjs') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
loadModule = async () => require(filepath);
}
else if (jsExt === '.js' || jsExt === '.mjs') {
loadModule = async () => import(filepath);
}
else {
loadModule = async () => {
throw new MissingResolverError(filepath);
};
}
return {
name,
path: filepath,
up: async ({ context }) => (await getModule()).up({ path: filepath, name, context }),
down: async ({ context }) => { var _b, _c; return (_c = (_b = (await getModule())).down) === null || _c === void 0 ? void 0 : _c.call(_b, { path: filepath, name, context }); },
};
};
class MissingResolverError extends Error {
constructor(filepath) {
super(`No resolver specified for file ${filepath}. See docs for guidance on how to write a custom resolver.`);
}
}
//# sourceMappingURL=umzug.js.map

1
server/node_modules/umzug/lib/umzug.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long