@ez4/database 0.35.0 → 0.37.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 +119 -2
- package/dist/library.cjs +143 -143
- package/dist/library.mjs +136 -136
- package/dist/main.cjs +3 -3
- package/dist/metadata/engine.d.ts +2 -2
- package/dist/metadata/handler.d.ts +2 -3
- package/dist/metadata/indexes.d.ts +2 -2
- package/dist/metadata/relations.d.ts +2 -2
- package/dist/metadata/scalability.d.ts +2 -2
- package/dist/metadata/schema.d.ts +2 -2
- package/dist/metadata/service.d.ts +2 -2
- package/dist/metadata/stream.d.ts +2 -2
- package/dist/metadata/table.d.ts +2 -2
- package/dist/services/contract.d.ts +4 -0
- package/dist/services/query.d.ts +66 -0
- package/dist/services/streams.d.ts +3 -3
- package/dist/types/handler.d.ts +2 -6
- package/dist/types/service.d.ts +11 -1
- package/package.json +6 -6
- package/dist/services/database.d.ts +0 -142
package/dist/types/service.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { DatabaseScalability } from './scalability';
|
|
|
3
3
|
import type { DatabaseEngine } from './engine';
|
|
4
4
|
import type { DatabaseTable } from './table';
|
|
5
5
|
export declare const ServiceType = "@ez4/database";
|
|
6
|
-
export type DatabaseService = ServiceMetadata & {
|
|
6
|
+
export type DatabaseService = Omit<ServiceMetadata, 'variables' | 'services'> & Required<Pick<ServiceMetadata, 'variables' | 'services'>> & {
|
|
7
7
|
type: typeof ServiceType;
|
|
8
8
|
scalability?: DatabaseScalability;
|
|
9
9
|
engine: DatabaseEngine;
|
|
@@ -11,3 +11,13 @@ export type DatabaseService = ServiceMetadata & {
|
|
|
11
11
|
name: string;
|
|
12
12
|
};
|
|
13
13
|
export declare const isDatabaseService: (service: ServiceMetadata) => service is DatabaseService;
|
|
14
|
+
export declare const createDatabaseService: (name: string) => {
|
|
15
|
+
variables: {};
|
|
16
|
+
services: {};
|
|
17
|
+
type: "@ez4/database";
|
|
18
|
+
name: string;
|
|
19
|
+
context: Record<string, import("@ez4/project/library").LinkedContext>;
|
|
20
|
+
scalability?: DatabaseScalability | null | undefined;
|
|
21
|
+
engine?: DatabaseEngine | null | undefined;
|
|
22
|
+
tables?: DatabaseTable[] | null | undefined;
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ez4/database",
|
|
3
3
|
"description": "EZ4: Components to build database services",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.37.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"live:publish": "npm run build && npm publish --access public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@ez4/common": "^0.
|
|
50
|
-
"@ez4/project": "^0.
|
|
51
|
-
"@ez4/reflection": "^0.
|
|
52
|
-
"@ez4/schema": "^0.
|
|
53
|
-
"@ez4/utils": "^0.
|
|
49
|
+
"@ez4/common": "^0.37.0",
|
|
50
|
+
"@ez4/project": "^0.37.0",
|
|
51
|
+
"@ez4/reflection": "^0.37.0",
|
|
52
|
+
"@ez4/schema": "^0.37.0",
|
|
53
|
+
"@ez4/utils": "^0.37.0"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import type { Service as CommonService } from '@ez4/common';
|
|
2
|
-
import type { LinkedVariables } from '@ez4/project/library';
|
|
3
|
-
import type { StreamChange } from './streams';
|
|
4
|
-
import type { DatabaseEngine } from './engine';
|
|
5
|
-
import type { Client } from './client';
|
|
6
|
-
/**
|
|
7
|
-
* Given a database service `T`, it returns all its table.
|
|
8
|
-
*/
|
|
9
|
-
export type DatabaseTables<T> = T extends {
|
|
10
|
-
tables: infer U;
|
|
11
|
-
} ? U : [];
|
|
12
|
-
/**
|
|
13
|
-
* Provide all contracts for a self-managed database service.
|
|
14
|
-
*/
|
|
15
|
-
export declare namespace Database {
|
|
16
|
-
/**
|
|
17
|
-
* Table schema.
|
|
18
|
-
*/
|
|
19
|
-
interface Schema {
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Table relations.
|
|
23
|
-
*/
|
|
24
|
-
interface Relations {
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Table indexes.
|
|
28
|
-
*/
|
|
29
|
-
type Indexes = {};
|
|
30
|
-
/**
|
|
31
|
-
* Incoming stream event.
|
|
32
|
-
*/
|
|
33
|
-
type Incoming<T extends Schema> = StreamChange<T> & Request;
|
|
34
|
-
/**
|
|
35
|
-
* Incoming request.
|
|
36
|
-
*/
|
|
37
|
-
type Request = {
|
|
38
|
-
/**
|
|
39
|
-
* Request tracking Id.
|
|
40
|
-
*/
|
|
41
|
-
requestId: string;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Stream listener.
|
|
45
|
-
*/
|
|
46
|
-
type Listener<T extends Schema> = (event: CommonService.AnyEvent<Incoming<T>>, context: CommonService.Context<Database.Service>) => Promise<void> | void;
|
|
47
|
-
/**
|
|
48
|
-
* Stream handler.
|
|
49
|
-
*/
|
|
50
|
-
type Handler<T extends Schema> = (request: Incoming<T>, context: CommonService.Context<Database.Service>) => Promise<void> | void;
|
|
51
|
-
/**
|
|
52
|
-
* Service event.
|
|
53
|
-
*/
|
|
54
|
-
type ServiceEvent<T extends Schema = Schema> = CommonService.BeginEvent<Request> | CommonService.ReadyEvent<Incoming<T>> | CommonService.DoneEvent<Incoming<T>> | CommonService.ErrorEvent<Request | Incoming<T>> | CommonService.EndEvent<Request>;
|
|
55
|
-
/**
|
|
56
|
-
* Service engine.
|
|
57
|
-
*/
|
|
58
|
-
type Engine = DatabaseEngine;
|
|
59
|
-
/**
|
|
60
|
-
* Service scalability configuration.
|
|
61
|
-
*/
|
|
62
|
-
interface Scalability {
|
|
63
|
-
minCapacity: number;
|
|
64
|
-
maxCapacity: number;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Table stream.
|
|
68
|
-
*/
|
|
69
|
-
interface Stream<T extends Schema = Schema> {
|
|
70
|
-
/**
|
|
71
|
-
* Stream listener.
|
|
72
|
-
*/
|
|
73
|
-
listener?: Listener<T>;
|
|
74
|
-
/**
|
|
75
|
-
* Stream handler.
|
|
76
|
-
*/
|
|
77
|
-
handler: Handler<T>;
|
|
78
|
-
/**
|
|
79
|
-
* Variables associated to the handler.
|
|
80
|
-
*/
|
|
81
|
-
variables?: LinkedVariables;
|
|
82
|
-
/**
|
|
83
|
-
* Log retention (in days) for the handler.
|
|
84
|
-
*/
|
|
85
|
-
logRetention?: number;
|
|
86
|
-
/**
|
|
87
|
-
* Max execution time (in seconds) for the handler.
|
|
88
|
-
*/
|
|
89
|
-
timeout?: number;
|
|
90
|
-
/**
|
|
91
|
-
* Amount of memory available for the handler.
|
|
92
|
-
*/
|
|
93
|
-
memory?: number;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Database table.
|
|
97
|
-
*/
|
|
98
|
-
interface Table<T extends Schema = Schema> {
|
|
99
|
-
/**
|
|
100
|
-
* Table name.
|
|
101
|
-
*/
|
|
102
|
-
name: string;
|
|
103
|
-
/**
|
|
104
|
-
* Table schema.
|
|
105
|
-
*/
|
|
106
|
-
schema: T;
|
|
107
|
-
/**
|
|
108
|
-
* Table relations.
|
|
109
|
-
*/
|
|
110
|
-
relations?: Relations;
|
|
111
|
-
/**
|
|
112
|
-
* Table indexes.
|
|
113
|
-
*/
|
|
114
|
-
indexes: Indexes;
|
|
115
|
-
/**
|
|
116
|
-
* Table stream configuration.
|
|
117
|
-
*/
|
|
118
|
-
stream?: Stream<T>;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Database service.
|
|
122
|
-
*/
|
|
123
|
-
abstract class Service implements CommonService.Provider {
|
|
124
|
-
/**
|
|
125
|
-
* Determines which database engine to use.
|
|
126
|
-
* Check the provider package to know all the possible values.
|
|
127
|
-
*/
|
|
128
|
-
abstract engine: Engine;
|
|
129
|
-
/**
|
|
130
|
-
* Describe all available tables for the service.
|
|
131
|
-
*/
|
|
132
|
-
abstract tables: Table<any>[];
|
|
133
|
-
/**
|
|
134
|
-
* Scalability configuration.
|
|
135
|
-
*/
|
|
136
|
-
scalability: Scalability;
|
|
137
|
-
/**
|
|
138
|
-
* Service client.
|
|
139
|
-
*/
|
|
140
|
-
client: Client<Service>;
|
|
141
|
-
}
|
|
142
|
-
}
|