@aromix/core 0.1.2 → 0.2.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/README.md +3 -0
- package/dist/index.d.ts +184 -36
- package/dist/index.js +212 -49
- package/package.json +7 -9
- package/dist/index.cjs +0 -65
- package/dist/index.d.cts +0 -63
package/README.md
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnySchema, Operator } from '@aromix/validator';
|
|
2
2
|
|
|
3
|
-
type Platform =
|
|
4
|
-
interface
|
|
3
|
+
type Platform = 'node' | 'bun' | 'cloudflare:worker';
|
|
4
|
+
interface BuildConfig {
|
|
5
5
|
entry: string;
|
|
6
6
|
outDir: string;
|
|
7
7
|
platform: Platform;
|
|
@@ -10,54 +10,202 @@ interface AromixBuildConfig {
|
|
|
10
10
|
tsConfig: string;
|
|
11
11
|
}
|
|
12
12
|
/** Identity fn :: exists purely for autocomplete and type safety */
|
|
13
|
-
declare function build(options:
|
|
13
|
+
declare function build(options: BuildConfig): BuildConfig;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
declare namespace Kv {
|
|
16
|
+
interface Adapter {
|
|
17
|
+
get(key: string): Promise<unknown>;
|
|
18
|
+
set(key: string, value: unknown): Promise<void>;
|
|
19
|
+
delete(key: string): Promise<void>;
|
|
20
|
+
has(key: string): Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
function adapter(adapter: Kv.Adapter): Adapter;
|
|
23
|
+
interface EntityInput<Schema extends AnySchema> {
|
|
24
|
+
name: string;
|
|
25
|
+
adapter: Kv.Adapter;
|
|
26
|
+
model: Schema;
|
|
27
|
+
}
|
|
28
|
+
interface EntityOutput<Schema extends AnySchema> {
|
|
29
|
+
get(key: string): Promise<Schema['$infer']>;
|
|
30
|
+
set(key: string, value: Schema['$infer']): Promise<void>;
|
|
31
|
+
delete(key: string): Promise<void>;
|
|
32
|
+
has(key: string): Promise<boolean>;
|
|
33
|
+
state: {
|
|
34
|
+
name: string;
|
|
35
|
+
adapter: Kv.Adapter;
|
|
36
|
+
model: Schema;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function entity<Schema extends AnySchema>(input: Kv.EntityInput<Schema>): Kv.EntityOutput<Schema>;
|
|
16
40
|
}
|
|
17
|
-
declare function config<T extends Config>(config: T | (() => T)): T;
|
|
18
41
|
|
|
19
|
-
interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
interface ColumnTypeMap {
|
|
43
|
+
int: number
|
|
44
|
+
real: number
|
|
45
|
+
text: string
|
|
46
|
+
blob: Uint8Array
|
|
23
47
|
}
|
|
24
|
-
|
|
48
|
+
|
|
49
|
+
type ColumnType = keyof ColumnTypeMap
|
|
50
|
+
|
|
51
|
+
type UniqueConflict = 'conflict:error' | 'conflict:replace' | 'conflict:ignore'
|
|
52
|
+
type Collation = 'binary' | 'nocase' | 'rtrim'
|
|
53
|
+
|
|
54
|
+
type ReferenceAction =
|
|
55
|
+
| 'delete:noAction'
|
|
56
|
+
| 'update:noAction'
|
|
57
|
+
| 'delete:restrict'
|
|
58
|
+
| 'update:restrict'
|
|
59
|
+
| 'delete:cascade'
|
|
60
|
+
| 'update:cascade'
|
|
61
|
+
| 'delete:setNull'
|
|
62
|
+
| 'update:setNull'
|
|
63
|
+
| 'delete:setDefault'
|
|
64
|
+
| 'update:setDefault'
|
|
65
|
+
|
|
66
|
+
interface CheckEntry {
|
|
67
|
+
op: 'gt' | 'gte' | 'lt' | 'lte' | 'minLength' | 'maxLength'
|
|
68
|
+
val: number
|
|
25
69
|
}
|
|
26
|
-
|
|
70
|
+
|
|
71
|
+
interface ColumnReference {
|
|
72
|
+
entityName: string
|
|
73
|
+
columnName: string
|
|
74
|
+
tableState: Record<string, ColumnState>
|
|
27
75
|
}
|
|
28
|
-
interface
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
76
|
+
interface ColumnState {
|
|
77
|
+
colType: ColumnType
|
|
78
|
+
primaryKey: boolean
|
|
79
|
+
autoIncrement: boolean
|
|
80
|
+
notNull: boolean
|
|
81
|
+
unique: boolean
|
|
82
|
+
uniqueConflict: UniqueConflict
|
|
83
|
+
index: boolean
|
|
84
|
+
checks: CheckEntry[]
|
|
85
|
+
in: string[]
|
|
86
|
+
collate?: Collation
|
|
87
|
+
references?: { col: ColumnReference; actions: ReferenceAction[] }
|
|
88
|
+
default?: unknown
|
|
89
|
+
defaultFn?: () => unknown
|
|
90
|
+
onUpdate?: () => unknown
|
|
91
|
+
pipes: Operator<any, any>[]
|
|
33
92
|
}
|
|
34
|
-
type EventMap = Record<string, unknown>;
|
|
35
93
|
|
|
36
|
-
|
|
37
|
-
|
|
94
|
+
type Chain<Type extends ColumnType, Used extends string = never, Output = ColumnTypeMap[Type]> = Omit<
|
|
95
|
+
{
|
|
96
|
+
readonly state: ColumnState
|
|
97
|
+
primaryKey(): Chain<Type, Used | 'primaryKey'>
|
|
98
|
+
autoIncrement(): Chain<Type, Used | 'autoIncrement'>
|
|
99
|
+
notNull(): Chain<Type, Used | 'notNull'>
|
|
100
|
+
unique(conflict?: UniqueConflict): Chain<Type, Used | 'unique'>
|
|
101
|
+
index(): Chain<Type, Used | 'index'>
|
|
102
|
+
collate(value: Collation): Chain<Type, Used | 'collate'>
|
|
103
|
+
gt(value: number): Chain<Type, Used>
|
|
104
|
+
gte(value: number): Chain<Type, Used>
|
|
105
|
+
lt(value: number): Chain<Type, Used>
|
|
106
|
+
lte(value: number): Chain<Type, Used>
|
|
107
|
+
minLength(value: number): Chain<Type, Used>
|
|
108
|
+
maxLength(value: number): Chain<Type, Used>
|
|
109
|
+
in(values: string[]): Chain<Type, Used | 'in'>
|
|
110
|
+
references(col: unknown, actions?: ReferenceAction[]): Chain<Type, Used | 'references'>
|
|
111
|
+
default(value: ColumnTypeMap[Type]): Chain<Type, Used | 'default'>
|
|
112
|
+
defaultFn(fn: () => ColumnTypeMap[Type]): Chain<Type, Used | 'defaultFn'>
|
|
113
|
+
onUpdate(fn: () => ColumnTypeMap[Type]): Chain<Type, Used | 'onUpdate'>
|
|
114
|
+
pipe<Next>(operator: Operator<Output, Next>): Chain<Type, Used, Next>
|
|
115
|
+
},
|
|
116
|
+
Used
|
|
117
|
+
>
|
|
118
|
+
|
|
119
|
+
type TableState = Record<string, { readonly state: ColumnState }>
|
|
38
120
|
|
|
39
|
-
interface
|
|
121
|
+
interface CheckExpression {
|
|
122
|
+
left: string
|
|
123
|
+
op: 'gt' | 'gte' | 'lt' | 'lte'
|
|
124
|
+
right: string
|
|
40
125
|
}
|
|
41
|
-
declare function entity(options: Entity): void;
|
|
42
126
|
|
|
43
|
-
|
|
44
|
-
encode(data: unknown): Uint8Array;
|
|
45
|
-
decode(buf: Uint8Array): unknown;
|
|
46
|
-
fromRequest(req: Request): Promise<unknown>;
|
|
47
|
-
response(data: unknown): Response;
|
|
48
|
-
};
|
|
127
|
+
type ColumnKey<State extends TableState> = keyof State & string
|
|
49
128
|
|
|
50
|
-
|
|
129
|
+
interface TableOptionsCtx<State extends TableState> {
|
|
130
|
+
unique(cols: ColumnKey<State>[], conflict: UniqueConflict): void
|
|
131
|
+
primaryKey(cols: ColumnKey<State>[]): void
|
|
132
|
+
index(cols: ColumnKey<State>[]): void
|
|
133
|
+
uniqueIndex(cols: ColumnKey<State>[]): void
|
|
134
|
+
checks(exprs: CheckExpression[]): void
|
|
135
|
+
gt(left: ColumnKey<State>, right: ColumnKey<State>): CheckExpression
|
|
136
|
+
gte(left: ColumnKey<State>, right: ColumnKey<State>): CheckExpression
|
|
137
|
+
lt(left: ColumnKey<State>, right: ColumnKey<State>): CheckExpression
|
|
138
|
+
lte(left: ColumnKey<State>, right: ColumnKey<State>): CheckExpression
|
|
139
|
+
withoutRowId(): void
|
|
140
|
+
}
|
|
51
141
|
|
|
52
|
-
declare
|
|
142
|
+
declare class Column<Type extends ColumnType> {
|
|
143
|
+
readonly state: ColumnState;
|
|
144
|
+
private constructor();
|
|
145
|
+
static create<Type extends ColumnType>(colType: Type): Chain<Type>;
|
|
146
|
+
primaryKey(): this;
|
|
147
|
+
autoIncrement(): this;
|
|
148
|
+
notNull(): this;
|
|
149
|
+
unique(conflict: UniqueConflict): this;
|
|
150
|
+
index(): this;
|
|
151
|
+
collate(value: Collation): this;
|
|
152
|
+
gt(value: number): this;
|
|
153
|
+
gte(value: number): this;
|
|
154
|
+
lt(value: number): this;
|
|
155
|
+
lte(value: number): this;
|
|
156
|
+
minLength(value: number): this;
|
|
157
|
+
maxLength(value: number): this;
|
|
158
|
+
in(values: string[]): this;
|
|
159
|
+
references(col: ColumnReference, actions?: ReferenceAction[]): this;
|
|
160
|
+
default(value: ColumnTypeMap[Type]): this;
|
|
161
|
+
defaultFn(fn: () => ColumnTypeMap[Type]): this;
|
|
162
|
+
onUpdate(fn: () => ColumnTypeMap[Type]): this;
|
|
163
|
+
pipe<Next>(operator: Operator<ColumnTypeMap[Type], Next>): this;
|
|
164
|
+
}
|
|
53
165
|
|
|
54
|
-
declare
|
|
166
|
+
declare const lite: {
|
|
167
|
+
int(): Chain<"int">;
|
|
168
|
+
real(): Chain<"real">;
|
|
169
|
+
text(): Chain<"text">;
|
|
170
|
+
blob(): Chain<"blob">;
|
|
171
|
+
};
|
|
55
172
|
|
|
56
|
-
declare
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
173
|
+
declare namespace Sqlite {
|
|
174
|
+
interface Adapter {
|
|
175
|
+
query(sql: string): Promise<unknown>;
|
|
176
|
+
}
|
|
177
|
+
function adapter(adapter: Sqlite.Adapter): Adapter;
|
|
178
|
+
interface EntityInput<State extends TableState> {
|
|
179
|
+
name: string;
|
|
180
|
+
adapter: Sqlite.Adapter;
|
|
181
|
+
columns: State;
|
|
182
|
+
options(ctx: TableOptionsCtx<State>): void;
|
|
183
|
+
}
|
|
184
|
+
interface EntityOutput<State extends TableState> {
|
|
185
|
+
state: {
|
|
186
|
+
name: string;
|
|
187
|
+
columns: {
|
|
188
|
+
[Key in keyof State]: ColumnState;
|
|
189
|
+
};
|
|
190
|
+
unique: {
|
|
191
|
+
cols: string[];
|
|
192
|
+
conflict?: UniqueConflict;
|
|
193
|
+
}[];
|
|
194
|
+
primaryKey: {
|
|
195
|
+
cols: string[];
|
|
196
|
+
}[];
|
|
197
|
+
index: {
|
|
198
|
+
cols: string[];
|
|
199
|
+
}[];
|
|
200
|
+
uniqueIndex: {
|
|
201
|
+
cols: string[];
|
|
202
|
+
}[];
|
|
203
|
+
checks: CheckExpression[];
|
|
204
|
+
withoutRowId: boolean;
|
|
205
|
+
};
|
|
206
|
+
col(columnName: ColumnKey<State>): ColumnReference;
|
|
60
207
|
}
|
|
208
|
+
function entity<State extends TableState>(input: Sqlite.EntityInput<State>): Sqlite.EntityOutput<State>;
|
|
61
209
|
}
|
|
62
210
|
|
|
63
|
-
export { type
|
|
211
|
+
export { type BuildConfig, type Chain, type CheckExpression, Column, type ColumnKey, type ColumnReference, type ColumnState, Kv, type Platform, Sqlite, type TableOptionsCtx, type TableState, type UniqueConflict, build, lite };
|
package/dist/index.js
CHANGED
|
@@ -3,63 +3,226 @@ function build(options) {
|
|
|
3
3
|
return options;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
// src/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
// src/drivers/kv.ts
|
|
7
|
+
var Kv;
|
|
8
|
+
((Kv2) => {
|
|
9
|
+
function adapter(adapter2) {
|
|
10
|
+
return adapter2;
|
|
11
|
+
}
|
|
12
|
+
Kv2.adapter = adapter;
|
|
13
|
+
function entity(input) {
|
|
14
|
+
const adapter2 = input.adapter;
|
|
15
|
+
return {
|
|
16
|
+
async get(key) {
|
|
17
|
+
const formattedKey = `${input.name}:${key}`;
|
|
18
|
+
const raw = await adapter2.get(formattedKey);
|
|
19
|
+
return input.model.parse(raw);
|
|
20
|
+
},
|
|
21
|
+
async set(key, value) {
|
|
22
|
+
const formattedKey = `${input.name}:${key}`;
|
|
23
|
+
const validated = input.model.parse(value);
|
|
24
|
+
await adapter2.set(formattedKey, validated);
|
|
25
|
+
},
|
|
26
|
+
async delete(key) {
|
|
27
|
+
const formattedKey = `${input.name}:${key}`;
|
|
28
|
+
await adapter2.delete(formattedKey);
|
|
29
|
+
},
|
|
30
|
+
async has(key) {
|
|
31
|
+
const formattedKey = `${input.name}:${key}`;
|
|
32
|
+
return await adapter2.has(formattedKey);
|
|
33
|
+
},
|
|
34
|
+
state: {
|
|
35
|
+
adapter: adapter2,
|
|
36
|
+
model: input.model,
|
|
37
|
+
name: input.name
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
Kv2.entity = entity;
|
|
42
|
+
})(Kv || (Kv = {}));
|
|
10
43
|
|
|
11
|
-
// src/
|
|
12
|
-
var
|
|
13
|
-
|
|
44
|
+
// src/drivers/sqlite.ts
|
|
45
|
+
var Sqlite;
|
|
46
|
+
((Sqlite2) => {
|
|
47
|
+
function adapter(adapter2) {
|
|
48
|
+
return adapter2;
|
|
49
|
+
}
|
|
50
|
+
Sqlite2.adapter = adapter;
|
|
51
|
+
function entity(input) {
|
|
52
|
+
const columns = {};
|
|
53
|
+
for (const key of Object.keys(input.columns)) {
|
|
54
|
+
columns[key] = input.columns[key].state;
|
|
55
|
+
}
|
|
56
|
+
const state = {
|
|
57
|
+
name: input.name,
|
|
58
|
+
columns,
|
|
59
|
+
unique: [],
|
|
60
|
+
primaryKey: [],
|
|
61
|
+
index: [],
|
|
62
|
+
uniqueIndex: [],
|
|
63
|
+
checks: [],
|
|
64
|
+
withoutRowId: false
|
|
65
|
+
};
|
|
66
|
+
input.options({
|
|
67
|
+
unique(cols, conflict) {
|
|
68
|
+
state.unique.push({ cols, conflict });
|
|
69
|
+
},
|
|
70
|
+
primaryKey(cols) {
|
|
71
|
+
state.primaryKey.push({ cols });
|
|
72
|
+
},
|
|
73
|
+
index(cols) {
|
|
74
|
+
state.index.push({ cols });
|
|
75
|
+
},
|
|
76
|
+
uniqueIndex(cols) {
|
|
77
|
+
state.uniqueIndex.push({ cols });
|
|
78
|
+
},
|
|
79
|
+
checks(exprs) {
|
|
80
|
+
state.checks = exprs;
|
|
81
|
+
},
|
|
82
|
+
gt(left, right) {
|
|
83
|
+
return { left, op: "gt", right };
|
|
84
|
+
},
|
|
85
|
+
gte(left, right) {
|
|
86
|
+
return { left, op: "gte", right };
|
|
87
|
+
},
|
|
88
|
+
lt(left, right) {
|
|
89
|
+
return { left, op: "lt", right };
|
|
90
|
+
},
|
|
91
|
+
lte(left, right) {
|
|
92
|
+
return { left, op: "lte", right };
|
|
93
|
+
},
|
|
94
|
+
withoutRowId() {
|
|
95
|
+
state.withoutRowId = true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
state,
|
|
100
|
+
col(columnName) {
|
|
101
|
+
return {
|
|
102
|
+
entityName: input.name,
|
|
103
|
+
columnName,
|
|
104
|
+
tableState: columns
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
Sqlite2.entity = entity;
|
|
110
|
+
})(Sqlite || (Sqlite = {}));
|
|
14
111
|
|
|
15
|
-
// src/
|
|
16
|
-
|
|
17
|
-
|
|
112
|
+
// src/lite/column.ts
|
|
113
|
+
var Column = class _Column {
|
|
114
|
+
constructor(state) {
|
|
115
|
+
this.state = state;
|
|
116
|
+
}
|
|
117
|
+
state;
|
|
118
|
+
static create(colType) {
|
|
119
|
+
return new _Column({
|
|
120
|
+
colType,
|
|
121
|
+
primaryKey: false,
|
|
122
|
+
autoIncrement: false,
|
|
123
|
+
notNull: false,
|
|
124
|
+
unique: false,
|
|
125
|
+
uniqueConflict: "conflict:error",
|
|
126
|
+
index: false,
|
|
127
|
+
checks: [],
|
|
128
|
+
in: [],
|
|
129
|
+
pipes: []
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
primaryKey() {
|
|
133
|
+
this.state.primaryKey = true;
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
autoIncrement() {
|
|
137
|
+
this.state.autoIncrement = true;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
notNull() {
|
|
141
|
+
this.state.notNull = true;
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
unique(conflict) {
|
|
145
|
+
this.state.unique = true;
|
|
146
|
+
this.state.uniqueConflict = conflict;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
index() {
|
|
150
|
+
this.state.index = true;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
collate(value) {
|
|
154
|
+
this.state.collate = value;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
gt(value) {
|
|
158
|
+
this.state.checks.push({ op: "gt", val: value });
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
gte(value) {
|
|
162
|
+
this.state.checks.push({ op: "gte", val: value });
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
lt(value) {
|
|
166
|
+
this.state.checks.push({ op: "lt", val: value });
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
lte(value) {
|
|
170
|
+
this.state.checks.push({ op: "lte", val: value });
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
minLength(value) {
|
|
174
|
+
this.state.checks.push({ op: "minLength", val: value });
|
|
175
|
+
return this;
|
|
176
|
+
}
|
|
177
|
+
maxLength(value) {
|
|
178
|
+
this.state.checks.push({ op: "maxLength", val: value });
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
in(values) {
|
|
182
|
+
this.state.in = values;
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
references(col, actions = []) {
|
|
186
|
+
this.state.references = { col, actions };
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
default(value) {
|
|
190
|
+
this.state.default = value;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
defaultFn(fn) {
|
|
194
|
+
this.state.defaultFn = fn;
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
onUpdate(fn) {
|
|
198
|
+
this.state.onUpdate = fn;
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
pipe(operator) {
|
|
202
|
+
this.state.pipes.push(operator);
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
18
206
|
|
|
19
|
-
// src/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return encode(data);
|
|
207
|
+
// src/lite/index.ts
|
|
208
|
+
var lite = {
|
|
209
|
+
int() {
|
|
210
|
+
return Column.create("int");
|
|
24
211
|
},
|
|
25
|
-
|
|
26
|
-
return
|
|
212
|
+
real() {
|
|
213
|
+
return Column.create("real");
|
|
27
214
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (contentType !== "application/x-msgpack") {
|
|
31
|
-
throw new Error(`Invalid content-type "${contentType}" \u2014 only application/x-msgpack is accepted`);
|
|
32
|
-
}
|
|
33
|
-
const buf = await req.arrayBuffer();
|
|
34
|
-
if (buf.byteLength === 0) return void 0;
|
|
35
|
-
return decode(new Uint8Array(buf));
|
|
215
|
+
text() {
|
|
216
|
+
return Column.create("text");
|
|
36
217
|
},
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
status: 200,
|
|
40
|
-
headers: { "Content-Type": "application/x-msgpack" }
|
|
41
|
-
});
|
|
218
|
+
blob() {
|
|
219
|
+
return Column.create("blob");
|
|
42
220
|
}
|
|
43
221
|
};
|
|
44
|
-
|
|
45
|
-
// src/fetch/fetch.ts
|
|
46
|
-
function toFetchHandler() {
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/make/impl.ts
|
|
50
|
-
function make() {
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/plugin.ts
|
|
54
|
-
function plugin() {
|
|
55
|
-
}
|
|
56
222
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
223
|
+
Column,
|
|
224
|
+
Kv,
|
|
225
|
+
Sqlite,
|
|
59
226
|
build,
|
|
60
|
-
|
|
61
|
-
entity,
|
|
62
|
-
make,
|
|
63
|
-
plugin,
|
|
64
|
-
toFetchHandler
|
|
227
|
+
lite
|
|
65
228
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aromix/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Core
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The Core Package For Aromix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://aromixjs.github.io/aromix",
|
|
@@ -27,26 +27,24 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
30
|
"exports": {
|
|
32
31
|
".": {
|
|
33
32
|
"types": "./dist/index.d.ts",
|
|
34
|
-
"import": "./dist/index.js"
|
|
35
|
-
"require": "./dist/index.cjs"
|
|
33
|
+
"import": "./dist/index.js"
|
|
36
34
|
}
|
|
37
35
|
},
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public",
|
|
40
38
|
"registry": "https://registry.npmjs.org"
|
|
41
39
|
},
|
|
42
|
-
"
|
|
43
|
-
"@
|
|
44
|
-
"@standard-schema/spec": "^1.1.0"
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@aromix/validator": "^0.2.0"
|
|
45
42
|
},
|
|
46
43
|
"devDependencies": {
|
|
47
44
|
"@types/node": "^22.10.2",
|
|
48
45
|
"tsup": "^8.3.5",
|
|
49
|
-
"typescript": "^5.7.2"
|
|
46
|
+
"typescript": "^5.7.2",
|
|
47
|
+
"@aromix/validator": "^0.2.0"
|
|
50
48
|
},
|
|
51
49
|
"scripts": {
|
|
52
50
|
"build": "tsup",
|
package/dist/index.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/build.ts
|
|
2
|
-
function build(options) {
|
|
3
|
-
return options;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// src/config.ts
|
|
7
|
-
function config(config2) {
|
|
8
|
-
return typeof config2 === "function" ? config2() : config2;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// src/entity/builder.ts
|
|
12
|
-
var Builder = class {
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/entity/entity.ts
|
|
16
|
-
function entity(options) {
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// src/fetch/codec.ts
|
|
20
|
-
var _msgpack = require('@msgpack/msgpack');
|
|
21
|
-
var Codec = {
|
|
22
|
-
encode(data) {
|
|
23
|
-
return _msgpack.encode.call(void 0, data);
|
|
24
|
-
},
|
|
25
|
-
decode(buf) {
|
|
26
|
-
return _msgpack.decode.call(void 0, buf);
|
|
27
|
-
},
|
|
28
|
-
async fromRequest(req) {
|
|
29
|
-
const contentType = req.headers.get("content-type");
|
|
30
|
-
if (contentType !== "application/x-msgpack") {
|
|
31
|
-
throw new Error(`Invalid content-type "${contentType}" \u2014 only application/x-msgpack is accepted`);
|
|
32
|
-
}
|
|
33
|
-
const buf = await req.arrayBuffer();
|
|
34
|
-
if (buf.byteLength === 0) return void 0;
|
|
35
|
-
return _msgpack.decode.call(void 0, new Uint8Array(buf));
|
|
36
|
-
},
|
|
37
|
-
response(data) {
|
|
38
|
-
return new Response(_msgpack.encode.call(void 0, data), {
|
|
39
|
-
status: 200,
|
|
40
|
-
headers: { "Content-Type": "application/x-msgpack" }
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/fetch/fetch.ts
|
|
46
|
-
function toFetchHandler() {
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/make/impl.ts
|
|
50
|
-
function make() {
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/plugin.ts
|
|
54
|
-
function plugin() {
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
exports.Builder = Builder; exports.Codec = Codec; exports.build = build; exports.config = config; exports.entity = entity; exports.make = make; exports.plugin = plugin; exports.toFetchHandler = toFetchHandler;
|
package/dist/index.d.cts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
|
|
3
|
-
type Platform = "node" | "bun" | "cloudflare:worker";
|
|
4
|
-
interface AromixBuildConfig {
|
|
5
|
-
entry: string;
|
|
6
|
-
outDir: string;
|
|
7
|
-
platform: Platform;
|
|
8
|
-
sourcemap: boolean;
|
|
9
|
-
minify: boolean;
|
|
10
|
-
tsConfig: string;
|
|
11
|
-
}
|
|
12
|
-
/** Identity fn :: exists purely for autocomplete and type safety */
|
|
13
|
-
declare function build(options: AromixBuildConfig): AromixBuildConfig;
|
|
14
|
-
|
|
15
|
-
interface Config {
|
|
16
|
-
}
|
|
17
|
-
declare function config<T extends Config>(config: T | (() => T)): T;
|
|
18
|
-
|
|
19
|
-
interface BaseCtx {
|
|
20
|
-
id: string;
|
|
21
|
-
payload: unknown;
|
|
22
|
-
args<T>(schema: StandardSchemaV1<T>): T;
|
|
23
|
-
}
|
|
24
|
-
interface CommandCtx extends BaseCtx {
|
|
25
|
-
}
|
|
26
|
-
interface StreamCtx extends BaseCtx {
|
|
27
|
-
}
|
|
28
|
-
interface SocketCtx<Receive extends EventMap, Send extends EventMap> extends BaseCtx {
|
|
29
|
-
on<E extends keyof Receive>(event: E, handler: (data: Receive[E]) => void | Promise<void>): void;
|
|
30
|
-
send<E extends keyof Send>(event: E, data: Send[E]): void;
|
|
31
|
-
onClose(handler: () => void): void;
|
|
32
|
-
close(): void;
|
|
33
|
-
}
|
|
34
|
-
type EventMap = Record<string, unknown>;
|
|
35
|
-
|
|
36
|
-
declare class Builder {
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface Entity {
|
|
40
|
-
}
|
|
41
|
-
declare function entity(options: Entity): void;
|
|
42
|
-
|
|
43
|
-
declare const Codec: {
|
|
44
|
-
encode(data: unknown): Uint8Array;
|
|
45
|
-
decode(buf: Uint8Array): unknown;
|
|
46
|
-
fromRequest(req: Request): Promise<unknown>;
|
|
47
|
-
response(data: unknown): Response;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
declare function toFetchHandler(): void;
|
|
51
|
-
|
|
52
|
-
declare function make(): void;
|
|
53
|
-
|
|
54
|
-
declare function plugin(): void;
|
|
55
|
-
|
|
56
|
-
declare global {
|
|
57
|
-
namespace Aromix {
|
|
58
|
-
type GlobPattern = string | string[];
|
|
59
|
-
function load(pattern: GlobPattern): string[];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { type AromixBuildConfig, type BaseCtx, Builder, Codec, type CommandCtx, type Config, type EventMap, type Platform, type SocketCtx, type StreamCtx, build, config, entity, make, plugin, toFetchHandler };
|