This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80f4f40
commit e981ce2
Showing
7 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Service from './service' | ||
import ModelsHook from './models' | ||
import RelationsHook from './relations' | ||
import MigrationAction from './migration' | ||
import { | ||
Model, | ||
DataTypes, | ||
Deferrable, | ||
Op, | ||
} from 'sequelize' | ||
import * as sequelize from 'sequelize' | ||
|
||
declare module '@atlas.js/sequelize' { | ||
|
||
export { | ||
Service, | ||
ModelsHook, | ||
RelationsHook, | ||
MigrationAction, | ||
Op, | ||
Model, | ||
DataTypes, | ||
Deferrable, | ||
sequelize, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Action from '@atlas.js/action' | ||
|
||
/** | ||
* This action allows you to programmatically execute migrations using the Umzug migrator. | ||
* | ||
* ## Usage: | ||
* | ||
* First, add this action to your Atlas instance, and then: | ||
* | ||
* `await atlas.actions.migration.up()` | ||
* `await atlas.actions.migration.down()` | ||
* | ||
* You can also execute the action's methods from the Atlas CLI: | ||
* | ||
* `npx atlas exec migration up` | ||
* | ||
* @see https://www.npmjs.com/package/umzug | ||
*/ | ||
declare class Migration extends Action { | ||
/** | ||
* Migrate upwards/apply | ||
* | ||
* @see https://www.npmjs.com/package/umzug#executing-pending-migrations | ||
*/ | ||
up(options: { from?: string, to?: string, migrations?: string[] }): Promise<string[]> | ||
up(migration: string): Promise<string[]> | ||
up(migrations: string[]): Promise<string[]> | ||
|
||
/** | ||
* Migrate downwards/revert | ||
* | ||
* @see https://www.npmjs.com/package/umzug#reverting-executed-migration | ||
*/ | ||
down(options: { to?: string | 0, migration?: string[] }): Promise<string[]> | ||
down(migration: string): Promise<string[]> | ||
down(migrations: string[]): Promise<string[]> | ||
|
||
/** Get a list of all pending migrations */ | ||
pending(): Promise<string[]> | ||
} | ||
|
||
declare namespace Migration { | ||
interface Config { | ||
/** | ||
* Module location, relative to `atlas.root`, from which to load migration files | ||
* @default migration | ||
*/ | ||
module: string | ||
} | ||
} | ||
|
||
export default Migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import AtlasHook from '@atlas.js/hook' | ||
import * as sequelize from 'sequelize' | ||
|
||
/** | ||
* This hook allows you to import your Sequelize models from a particular module location into the | ||
* sequelize service | ||
*/ | ||
declare class ModelsHook extends AtlasHook { | ||
/** Hook runtime configuration values */ | ||
config: ModelsHook.Config | ||
|
||
afterPrepare(): void | ||
} | ||
|
||
declare namespace ModelsHook { | ||
/** Configuration schema available to this hook */ | ||
interface Config { | ||
/** | ||
* Module location from which to load Sequelize models | ||
* @default models | ||
*/ | ||
module: string | ||
} | ||
} | ||
|
||
export default ModelsHook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import AtlasHook from '@atlas.js/hook' | ||
|
||
/** | ||
* This hook allows you to describe your model's associations (relations) directly on the model | ||
*/ | ||
declare class RelationsHook extends AtlasHook { | ||
afterPrepare(): void | ||
} | ||
|
||
export default RelationsHook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import AtlasService from '@atlas.js/service' | ||
import * as sequelize from 'sequelize' | ||
|
||
/** | ||
* Use Sequelize ORM from within Atlas | ||
* | ||
* This service allows you to use Sequelize for connecting to various SQL databases | ||
*/ | ||
declare class Service extends AtlasService { | ||
/** Service runtime configuration values */ | ||
config: Service.Config | ||
|
||
prepare(): Promise<sequelize.Sequelize> | ||
start(service: sequelize.Sequelize): Promise<sequelize.Sequelize> | ||
stop(service: sequelize.Sequelize): Promise<void> | ||
} | ||
|
||
declare namespace Service { | ||
/** Configuration schema available to this service */ | ||
interface Config { | ||
/** | ||
* URI to connect to | ||
* @default sqlite://atlas-db.sqlite | ||
*/ | ||
uri?: string | ||
/** | ||
* Connection options | ||
*/ | ||
options?: sequelize.Options | ||
} | ||
} | ||
|
||
export default Service |