arcanajs 3.0.1 → 5.0.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/dist/529.js +2 -0
- package/dist/529.js.map +1 -0
- package/dist/630.js +3 -0
- package/dist/630.js.LICENSE.txt +14 -0
- package/dist/630.js.map +1 -0
- package/dist/arcanajs.auth.js +3 -0
- package/dist/arcanajs.auth.js.LICENSE.txt +14 -0
- package/dist/arcanajs.auth.js.map +1 -0
- package/dist/arcanajs.js +2 -1
- package/dist/arcanajs.js.LICENSE.txt +14 -0
- package/dist/arcanajs.js.map +1 -1
- package/dist/arcanajs.mail.js +2 -0
- package/dist/arcanajs.mail.js.map +1 -0
- package/dist/arcanajs.validator.js +2 -0
- package/dist/arcanajs.validator.js.map +1 -0
- package/dist/arcanox.js +2 -0
- package/dist/arcanox.js.map +1 -0
- package/dist/cli/commands/db.d.ts +1 -0
- package/dist/cli/commands/dependency.d.ts +1 -0
- package/dist/cli/commands/make/Controller.d.ts +3 -0
- package/dist/cli/commands/make/Factory.d.ts +2 -0
- package/dist/cli/commands/make/Middleware.d.ts +1 -0
- package/dist/cli/commands/make/Migration.d.ts +2 -0
- package/dist/cli/commands/make/Model.d.ts +2 -0
- package/dist/cli/commands/make/Provider.d.ts +1 -0
- package/dist/cli/commands/make/Request.d.ts +1 -0
- package/dist/cli/commands/make/Seeder.d.ts +2 -0
- package/dist/cli/commands/make.d.ts +1 -0
- package/dist/cli/commands/migrate.d.ts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/toPascalCase.d.ts +1 -0
- package/dist/cli/utils/writeFile.d.ts +1 -0
- package/dist/lib/arcanox/Model.d.ts +203 -0
- package/dist/lib/arcanox/QueryBuilder.d.ts +141 -0
- package/dist/lib/arcanox/adapters/MongoAdapter.d.ts +22 -0
- package/dist/lib/arcanox/adapters/MySQLAdapter.d.ts +27 -0
- package/dist/lib/arcanox/adapters/PostgresAdapter.d.ts +27 -0
- package/dist/lib/arcanox/extensions/MongoExtensions.d.ts +33 -0
- package/dist/lib/arcanox/factory/Factory.d.ts +26 -0
- package/dist/lib/arcanox/factory/index.d.ts +1 -0
- package/dist/lib/arcanox/providers/DatabaseProvider.d.ts +10 -0
- package/dist/lib/arcanox/relations/BelongsTo.d.ts +11 -0
- package/dist/lib/arcanox/relations/BelongsToMany.d.ts +15 -0
- package/dist/lib/arcanox/relations/HasMany.d.ts +11 -0
- package/dist/lib/arcanox/relations/HasOne.d.ts +11 -0
- package/dist/lib/arcanox/relations/Relation.d.ts +14 -0
- package/dist/lib/arcanox/schema/Blueprint.d.ts +183 -0
- package/dist/lib/arcanox/schema/Migration.d.ts +76 -0
- package/dist/lib/arcanox/schema/Schema.d.ts +49 -0
- package/dist/lib/arcanox/schema/index.d.ts +4 -0
- package/dist/lib/arcanox/seeder/Seeder.d.ts +13 -0
- package/dist/lib/arcanox/seeder/index.d.ts +1 -0
- package/dist/lib/arcanox/support/Macroable.d.ts +19 -0
- package/dist/lib/arcanox/types.d.ts +76 -0
- package/dist/lib/auth/AuthProvider.d.ts +10 -0
- package/dist/lib/auth/JWTService.d.ts +11 -0
- package/dist/lib/auth/SessionManager.d.ts +4 -0
- package/dist/lib/auth/middleware/AuthMiddleware.d.ts +5 -0
- package/dist/lib/auth/middleware/AuthenticatedMiddleware.d.ts +5 -0
- package/dist/lib/auth/middleware/GuestMiddleware.d.ts +5 -0
- package/dist/lib/auth/middleware/RoleMiddleware.d.ts +7 -0
- package/dist/lib/auth/types/AuthConfig.d.ts +24 -0
- package/dist/lib/auth/types/JWTPayload.d.ts +10 -0
- package/dist/lib/auth/types/index.d.ts +2 -0
- package/dist/lib/auth/utils/PasswordHasher.d.ts +16 -0
- package/dist/lib/auth/utils/TokenBlacklist.d.ts +9 -0
- package/dist/lib/index.arcanox.d.ts +20 -0
- package/dist/lib/index.auth.d.ts +11 -0
- package/dist/lib/index.client.d.ts +2 -0
- package/dist/lib/index.mail.d.ts +8 -0
- package/dist/lib/{index.d.ts → index.server.d.ts} +6 -12
- package/dist/lib/index.validator.d.ts +6 -0
- package/dist/lib/mail/MailProvider.d.ts +10 -0
- package/dist/lib/mail/MailService.d.ts +57 -0
- package/dist/lib/mail/Mailable.d.ts +106 -0
- package/dist/lib/mail/index.d.ts +6 -0
- package/dist/lib/mail/queue/MailQueue.d.ts +51 -0
- package/dist/lib/mail/queue/index.d.ts +1 -0
- package/dist/lib/mail/types/MailConfig.d.ts +146 -0
- package/dist/lib/mail/types/index.d.ts +1 -0
- package/dist/lib/mail/utils/TemplateRenderer.d.ts +34 -0
- package/dist/lib/mail/utils/index.d.ts +1 -0
- package/dist/lib/server/ArcanaJSServer.d.ts +49 -16
- package/dist/lib/server/Container.d.ts +39 -0
- package/dist/lib/server/MiddlewareBinder.d.ts +4 -0
- package/dist/lib/server/ResponseHandlerMiddleware.d.ts +0 -25
- package/dist/lib/server/Router.d.ts +31 -32
- package/dist/lib/server/http/FormRequest.d.ts +10 -0
- package/dist/lib/server/http/JsonResource.d.ts +13 -0
- package/dist/lib/server/http/Middleware.d.ts +4 -0
- package/dist/lib/server/support/ServiceProvider.d.ts +17 -0
- package/dist/lib/server/utils/dynamicRequire.d.ts +6 -0
- package/dist/lib/validation/ValidationException.d.ts +5 -0
- package/dist/lib/validation/Validator.d.ts +55 -0
- package/dist/types/global.d.ts +102 -0
- package/package.json +90 -25
- package/dist/lib/global.d.ts +0 -61
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { ColumnDefinition } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Column definition builder - fluent interface for defining columns
|
|
4
|
+
*/
|
|
5
|
+
export declare class ColumnBuilder {
|
|
6
|
+
private definition;
|
|
7
|
+
constructor(name: string, type: string, length?: number);
|
|
8
|
+
/**
|
|
9
|
+
* Make column nullable
|
|
10
|
+
*/
|
|
11
|
+
nullable(): this;
|
|
12
|
+
/**
|
|
13
|
+
* Set default value
|
|
14
|
+
*/
|
|
15
|
+
default(value: any): this;
|
|
16
|
+
/**
|
|
17
|
+
* Make column unique
|
|
18
|
+
*/
|
|
19
|
+
unique(): this;
|
|
20
|
+
/**
|
|
21
|
+
* Make column primary key
|
|
22
|
+
*/
|
|
23
|
+
primary(): this;
|
|
24
|
+
/**
|
|
25
|
+
* Make column auto-increment
|
|
26
|
+
*/
|
|
27
|
+
autoIncrement(): this;
|
|
28
|
+
/**
|
|
29
|
+
* Make column unsigned (for numbers)
|
|
30
|
+
*/
|
|
31
|
+
unsigned(): this;
|
|
32
|
+
/**
|
|
33
|
+
* Get the column definition
|
|
34
|
+
*/
|
|
35
|
+
getDefinition(): ColumnDefinition;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Foreign key definition builder
|
|
39
|
+
*/
|
|
40
|
+
export declare class ForeignKeyBuilder {
|
|
41
|
+
private column;
|
|
42
|
+
private referencedTable?;
|
|
43
|
+
private referencedColumn?;
|
|
44
|
+
private onDeleteAction?;
|
|
45
|
+
private onUpdateAction?;
|
|
46
|
+
constructor(column: string);
|
|
47
|
+
/**
|
|
48
|
+
* Set referenced table and column
|
|
49
|
+
*/
|
|
50
|
+
references(column: string): this;
|
|
51
|
+
/**
|
|
52
|
+
* Set referenced table
|
|
53
|
+
*/
|
|
54
|
+
on(table: string): this;
|
|
55
|
+
/**
|
|
56
|
+
* Set ON DELETE action
|
|
57
|
+
*/
|
|
58
|
+
onDelete(action: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION"): this;
|
|
59
|
+
/**
|
|
60
|
+
* Set ON UPDATE action
|
|
61
|
+
*/
|
|
62
|
+
onUpdate(action: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION"): this;
|
|
63
|
+
/**
|
|
64
|
+
* Get foreign key SQL
|
|
65
|
+
*/
|
|
66
|
+
toSQL(): string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Blueprint - defines table structure
|
|
70
|
+
* Arcanox's Schema Blueprint
|
|
71
|
+
*/
|
|
72
|
+
export declare class Blueprint {
|
|
73
|
+
private tableName;
|
|
74
|
+
private columns;
|
|
75
|
+
private indexes;
|
|
76
|
+
private foreignKeys;
|
|
77
|
+
private primaryKeys;
|
|
78
|
+
constructor(tableName: string);
|
|
79
|
+
/**
|
|
80
|
+
* Add auto-incrementing ID column
|
|
81
|
+
*/
|
|
82
|
+
id(name?: string): ColumnBuilder;
|
|
83
|
+
/**
|
|
84
|
+
* Add UUID column
|
|
85
|
+
*/
|
|
86
|
+
uuid(name?: string): ColumnBuilder;
|
|
87
|
+
/**
|
|
88
|
+
* Add string column
|
|
89
|
+
*/
|
|
90
|
+
string(name: string, length?: number): ColumnBuilder;
|
|
91
|
+
/**
|
|
92
|
+
* Add text column
|
|
93
|
+
*/
|
|
94
|
+
text(name: string): ColumnBuilder;
|
|
95
|
+
/**
|
|
96
|
+
* Add integer column
|
|
97
|
+
*/
|
|
98
|
+
integer(name: string): ColumnBuilder;
|
|
99
|
+
/**
|
|
100
|
+
* Add big integer column
|
|
101
|
+
*/
|
|
102
|
+
bigInteger(name: string): ColumnBuilder;
|
|
103
|
+
/**
|
|
104
|
+
* Add decimal column
|
|
105
|
+
*/
|
|
106
|
+
decimal(name: string, precision?: number, scale?: number): ColumnBuilder;
|
|
107
|
+
/**
|
|
108
|
+
* Add float column
|
|
109
|
+
*/
|
|
110
|
+
float(name: string): ColumnBuilder;
|
|
111
|
+
/**
|
|
112
|
+
* Add double column
|
|
113
|
+
*/
|
|
114
|
+
double(name: string): ColumnBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Add boolean column
|
|
117
|
+
*/
|
|
118
|
+
boolean(name: string): ColumnBuilder;
|
|
119
|
+
/**
|
|
120
|
+
* Add date column
|
|
121
|
+
*/
|
|
122
|
+
date(name: string): ColumnBuilder;
|
|
123
|
+
/**
|
|
124
|
+
* Add datetime column
|
|
125
|
+
*/
|
|
126
|
+
datetime(name: string): ColumnBuilder;
|
|
127
|
+
/**
|
|
128
|
+
* Add timestamp column
|
|
129
|
+
*/
|
|
130
|
+
timestamp(name: string): ColumnBuilder;
|
|
131
|
+
/**
|
|
132
|
+
* Add created_at and updated_at timestamps
|
|
133
|
+
*/
|
|
134
|
+
timestamps(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Add deleted_at timestamp for soft deletes
|
|
137
|
+
*/
|
|
138
|
+
softDeletes(name?: string): ColumnBuilder;
|
|
139
|
+
/**
|
|
140
|
+
* Add JSON column
|
|
141
|
+
*/
|
|
142
|
+
json(name: string): ColumnBuilder;
|
|
143
|
+
/**
|
|
144
|
+
* Add enum column
|
|
145
|
+
*/
|
|
146
|
+
enum(name: string, values: string[]): ColumnBuilder;
|
|
147
|
+
/**
|
|
148
|
+
* Add foreign key constraint
|
|
149
|
+
*/
|
|
150
|
+
foreign(column: string): ForeignKeyBuilder;
|
|
151
|
+
/**
|
|
152
|
+
* Add index
|
|
153
|
+
*/
|
|
154
|
+
index(columns: string | string[], name?: string): void;
|
|
155
|
+
/**
|
|
156
|
+
* Add unique index
|
|
157
|
+
*/
|
|
158
|
+
unique(columns: string | string[], name?: string): void;
|
|
159
|
+
/**
|
|
160
|
+
* Set primary key
|
|
161
|
+
*/
|
|
162
|
+
primary(columns: string | string[]): void;
|
|
163
|
+
/**
|
|
164
|
+
* Get all columns
|
|
165
|
+
*/
|
|
166
|
+
getColumns(): ColumnDefinition[];
|
|
167
|
+
/**
|
|
168
|
+
* Get table name
|
|
169
|
+
*/
|
|
170
|
+
getTableName(): string;
|
|
171
|
+
/**
|
|
172
|
+
* Get indexes
|
|
173
|
+
*/
|
|
174
|
+
getIndexes(): {
|
|
175
|
+
columns: string[];
|
|
176
|
+
unique: boolean;
|
|
177
|
+
name?: string;
|
|
178
|
+
}[];
|
|
179
|
+
/**
|
|
180
|
+
* Get foreign keys
|
|
181
|
+
*/
|
|
182
|
+
getForeignKeys(): ForeignKeyBuilder[];
|
|
183
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Migration class
|
|
3
|
+
* All migrations should extend this class and implement up() and down() methods
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class Migration {
|
|
6
|
+
/**
|
|
7
|
+
* Run the migration
|
|
8
|
+
*/
|
|
9
|
+
abstract up(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Reverse the migration
|
|
12
|
+
*/
|
|
13
|
+
abstract down(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Migration status
|
|
17
|
+
*/
|
|
18
|
+
export interface MigrationStatus {
|
|
19
|
+
name: string;
|
|
20
|
+
batch: number;
|
|
21
|
+
ranAt: Date;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Migration record in database
|
|
25
|
+
*/
|
|
26
|
+
export interface MigrationRecord {
|
|
27
|
+
id?: number;
|
|
28
|
+
migration: string;
|
|
29
|
+
batch: number;
|
|
30
|
+
created_at?: Date;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Migration Runner - executes migrations
|
|
34
|
+
*/
|
|
35
|
+
export declare class MigrationRunner {
|
|
36
|
+
private adapter;
|
|
37
|
+
private migrationsTable;
|
|
38
|
+
private migrationsPath;
|
|
39
|
+
constructor(adapter: any, migrationsPath: string);
|
|
40
|
+
/**
|
|
41
|
+
* Ensure migrations table exists
|
|
42
|
+
*/
|
|
43
|
+
private ensureMigrationsTable;
|
|
44
|
+
/**
|
|
45
|
+
* Get all ran migrations
|
|
46
|
+
*/
|
|
47
|
+
private getRanMigrations;
|
|
48
|
+
/**
|
|
49
|
+
* Get pending migrations
|
|
50
|
+
*/
|
|
51
|
+
private getPendingMigrations;
|
|
52
|
+
/**
|
|
53
|
+
* Run pending migrations
|
|
54
|
+
*/
|
|
55
|
+
run(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Rollback last batch of migrations
|
|
58
|
+
*/
|
|
59
|
+
rollback(steps?: number): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Reset all migrations
|
|
62
|
+
*/
|
|
63
|
+
reset(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Reset and re-run all migrations
|
|
66
|
+
*/
|
|
67
|
+
fresh(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Get migration status
|
|
70
|
+
*/
|
|
71
|
+
status(): Promise<MigrationStatus[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Load migration class from file
|
|
74
|
+
*/
|
|
75
|
+
private loadMigration;
|
|
76
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../types";
|
|
2
|
+
import { Blueprint } from "./Blueprint";
|
|
3
|
+
/**
|
|
4
|
+
* Schema - ArcnanJS schema builder
|
|
5
|
+
* Provides fluent interface for creating and modifying database tables
|
|
6
|
+
*/
|
|
7
|
+
export declare class Schema {
|
|
8
|
+
private static adapter;
|
|
9
|
+
/**
|
|
10
|
+
* Set the database adapter
|
|
11
|
+
*/
|
|
12
|
+
static setAdapter(adapter: DatabaseAdapter): void;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new table
|
|
15
|
+
*/
|
|
16
|
+
static create(tableName: string, callback: (table: Blueprint) => void): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Modify an existing table
|
|
19
|
+
*/
|
|
20
|
+
static table(tableName: string, callback: (table: Blueprint) => void): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Drop a table
|
|
23
|
+
*/
|
|
24
|
+
static drop(tableName: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Drop a table if it exists
|
|
27
|
+
*/
|
|
28
|
+
static dropIfExists(tableName: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Rename a table
|
|
31
|
+
*/
|
|
32
|
+
static rename(from: string, to: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a table exists
|
|
35
|
+
*/
|
|
36
|
+
static hasTable(tableName: string): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a column exists in a table
|
|
39
|
+
*/
|
|
40
|
+
static hasColumn(tableName: string, columnName: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Get all tables
|
|
43
|
+
*/
|
|
44
|
+
static getTables(): Promise<string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get all columns for a table
|
|
47
|
+
*/
|
|
48
|
+
static getColumns(tableName: string): Promise<string[]>;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Seeder } from "./Seeder";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Macroable trait
|
|
3
|
+
* Allows adding custom methods to a class at runtime
|
|
4
|
+
*/
|
|
5
|
+
export declare class Macroable {
|
|
6
|
+
protected static macros: Record<string, Function>;
|
|
7
|
+
/**
|
|
8
|
+
* Register a custom macro
|
|
9
|
+
*/
|
|
10
|
+
static macro(name: string, macro: Function): void;
|
|
11
|
+
/**
|
|
12
|
+
* Mix another object into the class
|
|
13
|
+
*/
|
|
14
|
+
static mixin(mixin: Record<string, Function>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Check if macro exists
|
|
17
|
+
*/
|
|
18
|
+
static hasMacro(name: string): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database connection interface
|
|
3
|
+
*/
|
|
4
|
+
export interface Connection {
|
|
5
|
+
query(sql: string, params?: any[]): Promise<any>;
|
|
6
|
+
execute(sql: string, params?: any[]): Promise<any>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Database adapter interface - implements database-specific operations
|
|
11
|
+
*/
|
|
12
|
+
export interface DatabaseAdapter {
|
|
13
|
+
connect(config: DatabaseConfig): Promise<Connection>;
|
|
14
|
+
disconnect(): Promise<void>;
|
|
15
|
+
createTable(tableName: string, columns: ColumnDefinition[]): Promise<void>;
|
|
16
|
+
dropTable(tableName: string): Promise<void>;
|
|
17
|
+
hasTable(tableName: string): Promise<boolean>;
|
|
18
|
+
hasColumn(tableName: string, columnName: string): Promise<boolean>;
|
|
19
|
+
select(table: string, options: SelectOptions): Promise<any[]>;
|
|
20
|
+
insert(table: string, data: Record<string, any>): Promise<any>;
|
|
21
|
+
update(table: string, id: any, data: Record<string, any>): Promise<any>;
|
|
22
|
+
delete(table: string, id: any): Promise<boolean>;
|
|
23
|
+
beginTransaction(): Promise<void>;
|
|
24
|
+
commit(): Promise<void>;
|
|
25
|
+
rollback(): Promise<void>;
|
|
26
|
+
raw(query: string, params?: any[]): Promise<any>;
|
|
27
|
+
}
|
|
28
|
+
export interface DatabaseConfig {
|
|
29
|
+
type: "postgres" | "mysql" | "mongodb";
|
|
30
|
+
host: string;
|
|
31
|
+
port: number;
|
|
32
|
+
database: string;
|
|
33
|
+
username?: string;
|
|
34
|
+
password?: string;
|
|
35
|
+
ssl?: boolean;
|
|
36
|
+
pool?: {
|
|
37
|
+
min?: number;
|
|
38
|
+
max?: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface ColumnDefinition {
|
|
42
|
+
name: string;
|
|
43
|
+
type: string;
|
|
44
|
+
length?: number;
|
|
45
|
+
nullable?: boolean;
|
|
46
|
+
default?: any;
|
|
47
|
+
unique?: boolean;
|
|
48
|
+
primary?: boolean;
|
|
49
|
+
autoIncrement?: boolean;
|
|
50
|
+
unsigned?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface SelectOptions {
|
|
53
|
+
columns?: string[];
|
|
54
|
+
where?: WhereClause[];
|
|
55
|
+
orderBy?: OrderByClause[];
|
|
56
|
+
limit?: number;
|
|
57
|
+
offset?: number;
|
|
58
|
+
joins?: JoinClause[];
|
|
59
|
+
}
|
|
60
|
+
export interface WhereClause {
|
|
61
|
+
column: string;
|
|
62
|
+
operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "BETWEEN" | "IS NULL" | "IS NOT NULL";
|
|
63
|
+
value: any;
|
|
64
|
+
boolean?: "AND" | "OR";
|
|
65
|
+
}
|
|
66
|
+
export interface OrderByClause {
|
|
67
|
+
column: string;
|
|
68
|
+
direction: "ASC" | "DESC";
|
|
69
|
+
}
|
|
70
|
+
export interface JoinClause {
|
|
71
|
+
type: "INNER" | "LEFT" | "RIGHT";
|
|
72
|
+
table: string;
|
|
73
|
+
first: string;
|
|
74
|
+
operator: string;
|
|
75
|
+
second: string;
|
|
76
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceProvider } from "../server/support/ServiceProvider";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication Service Provider
|
|
4
|
+
*
|
|
5
|
+
* Registers and bootstraps the authentication system
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthProvider extends ServiceProvider {
|
|
8
|
+
register(): Promise<void>;
|
|
9
|
+
boot(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import jwt from "jsonwebtoken";
|
|
2
|
+
import { AuthConfig, JWTPayload } from "./types";
|
|
3
|
+
export declare class JWTService {
|
|
4
|
+
private static config;
|
|
5
|
+
static init(config: AuthConfig["jwt"]): void;
|
|
6
|
+
static generateToken(payload: JWTPayload, options?: jwt.SignOptions): string;
|
|
7
|
+
static generateRefreshToken(payload: JWTPayload): string;
|
|
8
|
+
static verifyToken(token: string): Promise<JWTPayload>;
|
|
9
|
+
static revokeToken(token: string): Promise<void>;
|
|
10
|
+
static refreshAccessToken(refreshToken: string): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuthConfig } from "./types";
|
|
2
|
+
export declare class SessionManager {
|
|
3
|
+
static createMiddleware(config: AuthConfig["session"]): import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
4
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
|
+
import { Middleware } from "../../server/http/Middleware";
|
|
3
|
+
export declare class RoleMiddleware implements Middleware {
|
|
4
|
+
private roles;
|
|
5
|
+
constructor(...roles: string[]);
|
|
6
|
+
handle(req: Request, res: Response, next: NextFunction): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface AuthConfig {
|
|
2
|
+
jwt: {
|
|
3
|
+
secret: string;
|
|
4
|
+
accessTokenExpiry?: string | number;
|
|
5
|
+
refreshTokenExpiry?: string | number;
|
|
6
|
+
algorithm?: "HS256" | "RS256";
|
|
7
|
+
};
|
|
8
|
+
session: {
|
|
9
|
+
secret: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
maxAge?: number;
|
|
12
|
+
secure?: boolean;
|
|
13
|
+
redis?: {
|
|
14
|
+
host: string;
|
|
15
|
+
port: number;
|
|
16
|
+
password?: string;
|
|
17
|
+
db?: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
tokenBlacklist?: {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
storage: "memory" | "redis";
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class PasswordHasher {
|
|
2
|
+
private static readonly SALT_ROUNDS;
|
|
3
|
+
/**
|
|
4
|
+
* Hash a password.
|
|
5
|
+
* @param password The password to hash.
|
|
6
|
+
* @returns The hashed password.
|
|
7
|
+
*/
|
|
8
|
+
static hash(password: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Verify a password against a hash.
|
|
11
|
+
* @param password The plain text password.
|
|
12
|
+
* @param hash The hashed password.
|
|
13
|
+
* @returns True if the password matches the hash.
|
|
14
|
+
*/
|
|
15
|
+
static verify(password: string, hash: string): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthConfig } from "../types";
|
|
2
|
+
export declare class TokenBlacklist {
|
|
3
|
+
private static redisClient;
|
|
4
|
+
private static memoryStore;
|
|
5
|
+
private static config;
|
|
6
|
+
static init(config: AuthConfig["tokenBlacklist"], redisConfig?: AuthConfig["session"]["redis"]): Promise<void>;
|
|
7
|
+
static add(token: string, expiresInSeconds: number): Promise<void>;
|
|
8
|
+
static isRevoked(token: string): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { MongoAdapter } from "./arcanox/adapters/MongoAdapter";
|
|
4
|
+
export { MySQLAdapter } from "./arcanox/adapters/MySQLAdapter";
|
|
5
|
+
export { PostgresAdapter } from "./arcanox/adapters/PostgresAdapter";
|
|
6
|
+
export { Model } from "./arcanox/Model";
|
|
7
|
+
export { QueryBuilder } from "./arcanox/QueryBuilder";
|
|
8
|
+
export { BelongsTo } from "./arcanox/relations/BelongsTo";
|
|
9
|
+
export { BelongsToMany } from "./arcanox/relations/BelongsToMany";
|
|
10
|
+
export { HasMany } from "./arcanox/relations/HasMany";
|
|
11
|
+
export { HasOne } from "./arcanox/relations/HasOne";
|
|
12
|
+
export { Relation } from "./arcanox/relations/Relation";
|
|
13
|
+
export { Macroable } from "./arcanox/support/Macroable";
|
|
14
|
+
export type { ColumnDefinition, Connection, DatabaseAdapter, DatabaseConfig, JoinClause, OrderByClause, SelectOptions, WhereClause, } from "./arcanox/types";
|
|
15
|
+
export { Blueprint, Migration, MigrationRunner, Schema, } from "./arcanox/schema";
|
|
16
|
+
export type { MigrationStatus } from "./arcanox/schema";
|
|
17
|
+
export { Factory } from "./arcanox/factory";
|
|
18
|
+
export { Seeder } from "./arcanox/seeder";
|
|
19
|
+
export * from "./arcanox/extensions/MongoExtensions";
|
|
20
|
+
export { DatabaseProvider } from "./arcanox/providers/DatabaseProvider";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { AuthProvider } from "./auth/AuthProvider";
|
|
4
|
+
export { JWTService } from "./auth/JWTService";
|
|
5
|
+
export { AuthenticatedMiddleware } from "./auth/middleware/AuthenticatedMiddleware";
|
|
6
|
+
export { AuthMiddleware } from "./auth/middleware/AuthMiddleware";
|
|
7
|
+
export { GuestMiddleware } from "./auth/middleware/GuestMiddleware";
|
|
8
|
+
export { RoleMiddleware } from "./auth/middleware/RoleMiddleware";
|
|
9
|
+
export { SessionManager } from "./auth/SessionManager";
|
|
10
|
+
export type { AuthConfig, JWTPayload } from "./auth/types";
|
|
11
|
+
export { PasswordHasher } from "./auth/utils/PasswordHasher";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { Mailable } from "./mail/Mailable";
|
|
4
|
+
export { MailProvider } from "./mail/MailProvider";
|
|
5
|
+
export { MailService } from "./mail/MailService";
|
|
6
|
+
export { MailQueue } from "./mail/queue/MailQueue";
|
|
7
|
+
export type { MailAttachment, MailConfig, MailDriver, MailFromConfig, MailgunConfig, MailMessage, MailQueueConfig, MailTemplateConfig, SendGridConfig, SESConfig, SMTPConfig, } from "./mail/types";
|
|
8
|
+
export { TemplateRenderer } from "./mail/utils/TemplateRenderer";
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
1
3
|
import { Express } from "express";
|
|
2
4
|
import ArcanaJSServer, { ArcanaJSConfig } from "./server/ArcanaJSServer";
|
|
3
|
-
export { default as Body } from "./shared/components/Body";
|
|
4
|
-
export { default as Head } from "./shared/components/Head";
|
|
5
|
-
export { default as Link } from "./shared/components/Link";
|
|
6
|
-
export { default as NavLink } from "./shared/components/NavLink";
|
|
7
|
-
export { default as Page } from "./shared/components/Page";
|
|
8
|
-
export { default as hydrateArcanaJS } from "./client/index";
|
|
9
|
-
export { default as useLocation } from "./shared/hooks/useLocation";
|
|
10
|
-
export { default as usePage } from "./shared/hooks/usePage";
|
|
11
|
-
export { default as useParams } from "./shared/hooks/useParams";
|
|
12
|
-
export { default as useQuery } from "./shared/hooks/useQuery";
|
|
13
|
-
export { default as useRouter } from "./shared/hooks/useRouter";
|
|
14
5
|
export { default as ArcanaJSServer } from "./server/ArcanaJSServer";
|
|
6
|
+
export { Container } from "./server/Container";
|
|
15
7
|
export { Express, NextFunction, Request, Response } from "express";
|
|
16
8
|
export { default as Route } from "./server/Router";
|
|
9
|
+
export type { Middleware } from "./server/http/Middleware";
|
|
10
|
+
export { ServiceProvider } from "./server/support/ServiceProvider";
|
|
17
11
|
/**
|
|
18
12
|
* Create an ArcanaJS server with the given Express app
|
|
19
13
|
*
|
|
@@ -29,7 +23,7 @@ export { default as Route } from "./server/Router";
|
|
|
29
23
|
* const app = express();
|
|
30
24
|
* const server = createArcanaServer(app, {
|
|
31
25
|
* port: 3000,
|
|
32
|
-
* viewsDir: 'src/views',
|
|
26
|
+
* viewsDir: 'src/resources/views',
|
|
33
27
|
* });
|
|
34
28
|
*
|
|
35
29
|
* server.start();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference path="../types/global.d.ts" />
|
|
2
|
+
|
|
3
|
+
export { FormRequest } from "./server/http/FormRequest";
|
|
4
|
+
export { JsonResource } from "./server/http/JsonResource";
|
|
5
|
+
export { ValidationException } from "./validation/ValidationException";
|
|
6
|
+
export { Validator } from "./validation/Validator";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceProvider } from "../server/support/ServiceProvider";
|
|
2
|
+
/**
|
|
3
|
+
* Mail Service Provider
|
|
4
|
+
*
|
|
5
|
+
* Registers and bootstraps the mail system
|
|
6
|
+
*/
|
|
7
|
+
export declare class MailProvider extends ServiceProvider {
|
|
8
|
+
register(): Promise<void>;
|
|
9
|
+
boot(): Promise<void>;
|
|
10
|
+
}
|