@h3ravel/arquebus 0.3.6 → 0.4.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/bin/index.cjs +4269 -2733
- package/bin/index.js +4364 -2828
- package/dist/browser/index.cjs +2 -0
- package/dist/browser/index.d.cts +94 -7
- package/dist/browser/index.d.ts +94 -7
- package/dist/browser/index.js +2 -1
- package/dist/index.cjs +1501 -15
- package/dist/index.d.cts +130 -10
- package/dist/index.d.ts +130 -10
- package/dist/index.js +1501 -16
- package/dist/inspector/index.cjs +4885 -0
- package/dist/inspector/index.d.cts +83 -0
- package/dist/inspector/index.d.ts +83 -0
- package/dist/inspector/index.js +4859 -0
- package/dist/migrations/index.cjs +4389 -2904
- package/dist/migrations/index.d.cts +128 -9
- package/dist/migrations/index.d.ts +129 -10
- package/dist/migrations/index.js +4275 -2790
- package/package.json +12 -3
- package/types/query-builder.ts +37 -1
- package/src/migrations/stubs/migration-js.stub +0 -21
- package/src/migrations/stubs/migration-ts.stub +0 -18
- package/src/migrations/stubs/migration.create-js.stub +0 -24
- package/src/migrations/stubs/migration.create-ts.stub +0 -21
- package/src/migrations/stubs/migration.update-js.stub +0 -25
- package/src/migrations/stubs/migration.update-ts.stub +0 -22
- package/src/stubs/arquebus.config-js.stub +0 -25
- package/src/stubs/arquebus.config-ts.stub +0 -24
- package/src/stubs/model-js.stub +0 -5
- package/src/stubs/model-ts.stub +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/arquebus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Arquebus ORM is a Beautiful, expressive ORM inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework.",
|
|
5
5
|
"homepage": "https://h3ravel.toneflix.net/arquebus",
|
|
6
6
|
"bin": {
|
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
18
|
"bin",
|
|
19
|
-
"src/stubs",
|
|
20
|
-
"src/migrations/stubs",
|
|
21
19
|
"types"
|
|
22
20
|
],
|
|
23
21
|
"exports": {
|
|
@@ -83,6 +81,16 @@
|
|
|
83
81
|
"default": "./dist/migrations/index.cjs"
|
|
84
82
|
}
|
|
85
83
|
},
|
|
84
|
+
"./inspector": {
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./dist/inspector/index.d.ts",
|
|
87
|
+
"default": "./dist/inspector/index.js"
|
|
88
|
+
},
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./dist/inspector/index.d.cts",
|
|
91
|
+
"default": "./dist/inspector/index.cjs"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
86
94
|
"./browser": {
|
|
87
95
|
"import": {
|
|
88
96
|
"types": "./dist/browser/index.d.ts",
|
|
@@ -172,6 +180,7 @@
|
|
|
172
180
|
"lint": "eslint . --ext .ts",
|
|
173
181
|
"cmd": "cross-env TEST=true tsx --experimental-specifier-resolution=node src/cli",
|
|
174
182
|
"cmd:watch": "cross-env TEST=true tsx watch --experimental-specifier-resolution=node src/cli",
|
|
183
|
+
"test": "cross-env vitest --project generic",
|
|
175
184
|
"test:mysql": "cross-env DB=mysql vitest --project node",
|
|
176
185
|
"test:postgres": "cross-env DB=postgres vitest --project node",
|
|
177
186
|
"test:sqlite": "cross-env DB=sqlite vitest --project node",
|
package/types/query-builder.ts
CHANGED
|
@@ -3,11 +3,47 @@ import type { ICollection, IPaginator, IPaginatorParams } from './utils'
|
|
|
3
3
|
import type { TFunction, TGeneric } from './generics'
|
|
4
4
|
|
|
5
5
|
import type BModel from 'src/browser/model'
|
|
6
|
+
import type { Column } from 'src/inspector/types/column'
|
|
7
|
+
import type { ForeignKey } from 'src/inspector/types/foreign-key'
|
|
6
8
|
import type { Knex } from 'knex'
|
|
7
9
|
import type Model from 'src/model'
|
|
10
|
+
import type { Table } from 'src/inspector/types/table'
|
|
8
11
|
|
|
9
12
|
export interface SchemaBuilder extends Knex.SchemaBuilder {
|
|
10
13
|
[k: string]: any
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve all tables in the current database.
|
|
16
|
+
*/
|
|
17
|
+
tables (): Promise<string[]>
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve the table info for the given table, or all tables if no table is specified.
|
|
20
|
+
*
|
|
21
|
+
* @param table
|
|
22
|
+
*/
|
|
23
|
+
tableInfo (table?: string): Promise<Table | Table[]>
|
|
24
|
+
/**
|
|
25
|
+
* Retrieve all columns in a given table, or all columns if no table is specified.
|
|
26
|
+
*
|
|
27
|
+
* @param table
|
|
28
|
+
*/
|
|
29
|
+
columns (table?: string): Promise<{ table: string, column: string }[]>
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve all columns from a given table. Returns all columns if table parameter is undefined.
|
|
32
|
+
*
|
|
33
|
+
* @param table
|
|
34
|
+
* @param column
|
|
35
|
+
*/
|
|
36
|
+
columnInfo (table?: string, column?: string): Promise<Column[] | Column>
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve the primary key column for a given table.
|
|
39
|
+
*
|
|
40
|
+
* @param table
|
|
41
|
+
*/
|
|
42
|
+
primary (table: string): Promise<string>
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve all configured foreign key constraints
|
|
45
|
+
*/
|
|
46
|
+
foreignKeys (): Promise<ForeignKey>
|
|
11
47
|
};
|
|
12
48
|
|
|
13
49
|
interface AsMethod<QB extends AnyQueryBuilder> {
|
|
@@ -163,7 +199,7 @@ export interface IQueryBuilder<M extends Model | BModel = Model, R = M[] | M> {
|
|
|
163
199
|
take (count: number): this;
|
|
164
200
|
limit (count: number): this;
|
|
165
201
|
offset (count: number): this;
|
|
166
|
-
pluck<X extends Model = any> (column: string): Promise<
|
|
202
|
+
pluck<X extends Model = any> (column: string): Promise<Array<X>>;
|
|
167
203
|
chunk (count: number, callback: (rows: M[]) => any): Promise<boolean>;
|
|
168
204
|
forPage (page: number, perPage?: number): this;
|
|
169
205
|
paginate<F extends IPaginatorParams> (page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@h3ravel/arquebus'
|
|
2
|
-
|
|
3
|
-
export default class extends Migration {
|
|
4
|
-
/**
|
|
5
|
-
* Run the migrations.
|
|
6
|
-
*
|
|
7
|
-
* @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
|
|
8
|
-
*/
|
|
9
|
-
async up(schema) {
|
|
10
|
-
//
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Reverse the migrations.
|
|
15
|
-
*
|
|
16
|
-
* @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
|
|
17
|
-
*/
|
|
18
|
-
async down(schema) {
|
|
19
|
-
//
|
|
20
|
-
}
|
|
21
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@h3ravel/arquebus'
|
|
2
|
-
import { SchemaBuilder } from '@h3ravel/arquebus/types/query-builder';
|
|
3
|
-
|
|
4
|
-
export default class extends Migration {
|
|
5
|
-
/**
|
|
6
|
-
* Run the migrations.
|
|
7
|
-
*/
|
|
8
|
-
async up (schema: SchemaBuilder) {
|
|
9
|
-
//
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Reverse the migrations.
|
|
14
|
-
*/
|
|
15
|
-
async down (schema: SchemaBuilder) {
|
|
16
|
-
//
|
|
17
|
-
}
|
|
18
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@h3ravel/arquebus'
|
|
2
|
-
|
|
3
|
-
export default class extends Migration {
|
|
4
|
-
/**
|
|
5
|
-
* Run the migrations.
|
|
6
|
-
*
|
|
7
|
-
* @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
|
|
8
|
-
*/
|
|
9
|
-
async up(schema) {
|
|
10
|
-
await schema.createTable('{{ table }}', (table) => {
|
|
11
|
-
table.increments('id');
|
|
12
|
-
table.timestamps();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Reverse the migrations.
|
|
18
|
-
*
|
|
19
|
-
* @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
|
|
20
|
-
*/
|
|
21
|
-
async down(schema) {
|
|
22
|
-
await schema.dropTableIfExists('{{ table }}');
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@h3ravel/arquebus'
|
|
2
|
-
import { SchemaBuilder } from '@h3ravel/arquebus/types/query-builder';
|
|
3
|
-
|
|
4
|
-
export default class extends Migration {
|
|
5
|
-
/**
|
|
6
|
-
* Run the migrations.
|
|
7
|
-
*/
|
|
8
|
-
async up(schema: SchemaBuilder) {
|
|
9
|
-
await schema.createTable('{{ table }}', (table) => {
|
|
10
|
-
table.increments('id');
|
|
11
|
-
table.timestamps();
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Reverse the migrations.
|
|
17
|
-
*/
|
|
18
|
-
async down(schema: SchemaBuilder) {
|
|
19
|
-
await schema.dropTableIfExists('{{ table }}');
|
|
20
|
-
}
|
|
21
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@h3ravel/arquebus'
|
|
2
|
-
|
|
3
|
-
export default class extends Migration {
|
|
4
|
-
/**
|
|
5
|
-
* Run the migrations.
|
|
6
|
-
*
|
|
7
|
-
* @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
|
|
8
|
-
*/
|
|
9
|
-
async up(schema) {
|
|
10
|
-
await schema.table('{{ table }}', (table) => {
|
|
11
|
-
//
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Reverse the migrations.
|
|
17
|
-
*
|
|
18
|
-
* @param {(import('@h3ravel/arquebus/types/query-builder').SchemaBuilder)} schema
|
|
19
|
-
*/
|
|
20
|
-
async down(schema) {
|
|
21
|
-
await schema.table('{{ table }}', (table) => {
|
|
22
|
-
//
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@h3ravel/arquebus'
|
|
2
|
-
import { SchemaBuilder } from '@h3ravel/arquebus/types/query-builder';
|
|
3
|
-
|
|
4
|
-
export default class extends Migration {
|
|
5
|
-
/**
|
|
6
|
-
* Run the migrations.
|
|
7
|
-
*/
|
|
8
|
-
async up(schema: SchemaBuilder) {
|
|
9
|
-
await schema.table('{{ table }}', (table) => {
|
|
10
|
-
//
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Reverse the migrations.
|
|
16
|
-
*/
|
|
17
|
-
async down(schema: SchemaBuilder) {
|
|
18
|
-
await schema.table('{{ table }}', (table) => {
|
|
19
|
-
//
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from '@h3ravel/arquebus'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
client: 'mysql2',
|
|
5
|
-
connection: {
|
|
6
|
-
host: 'localhost',
|
|
7
|
-
database: 'database',
|
|
8
|
-
user: 'user',
|
|
9
|
-
password: 'password'
|
|
10
|
-
},
|
|
11
|
-
migrations: {
|
|
12
|
-
table: 'migrations',
|
|
13
|
-
path: './migrations',
|
|
14
|
-
},
|
|
15
|
-
factories: {
|
|
16
|
-
path: './factories',
|
|
17
|
-
},
|
|
18
|
-
seeders: {
|
|
19
|
-
path: './seeders',
|
|
20
|
-
},
|
|
21
|
-
models: {
|
|
22
|
-
path: './models'
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from '@h3ravel/arquebus'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
client: 'mysql2',
|
|
5
|
-
connection: {
|
|
6
|
-
host: 'localhost',
|
|
7
|
-
database: 'database',
|
|
8
|
-
user: 'user',
|
|
9
|
-
password: 'password'
|
|
10
|
-
},
|
|
11
|
-
migrations: {
|
|
12
|
-
table: 'migrations',
|
|
13
|
-
path: './migrations',
|
|
14
|
-
},
|
|
15
|
-
factories: {
|
|
16
|
-
path: './factories',
|
|
17
|
-
},
|
|
18
|
-
seeders: {
|
|
19
|
-
path: './seeders',
|
|
20
|
-
},
|
|
21
|
-
models: {
|
|
22
|
-
path: './models'
|
|
23
|
-
}
|
|
24
|
-
})
|
package/src/stubs/model-js.stub
DELETED