@dvsa/cvs-db-schemas 0.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/LICENSE +21 -0
- package/README.md +212 -0
- package/index.d.ts +3 -0
- package/index.js +19 -0
- package/misc/outbox.d.ts +160 -0
- package/misc/outbox.js +22 -0
- package/package.json +53 -0
- package/test-facility/activity.d.ts +330 -0
- package/test-facility/activity.js +37 -0
- package/test-facility/test-station.d.ts +279 -0
- package/test-facility/test-station.js +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Driver & Vehicle Standards Agency
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# cvs-microservice-common
|
|
2
|
+
|
|
3
|
+
Common code used by the various serverless microservices within the Commercial Vehicle Services (CVS) system, published as a GitHub package.
|
|
4
|
+
|
|
5
|
+
### Pre-requisites
|
|
6
|
+
|
|
7
|
+
- Node.js (Please see `.nvmrc` for specific version)
|
|
8
|
+
- `npm` (If using [n](https://github.com/tj/n) or [nvm](https://github.com/nvm-sh/nvm), this will be automatically managed)
|
|
9
|
+
- Security
|
|
10
|
+
- [Git secrets](https://github.com/awslabs/git-secrets)
|
|
11
|
+
- [ScanRepo](https://github.com/UKHomeOffice/repo-security-scanner)
|
|
12
|
+
- Unzip `repo-security-scanner_<version>_Darwin_<architercture>.tar.gz` and rename the executable inside the folder
|
|
13
|
+
to `scanrepo` - Add executable to path (using `echo $PATH` to find your path)
|
|
14
|
+
|
|
15
|
+
### Getting started
|
|
16
|
+
|
|
17
|
+
###### Run the following command after cloning the project
|
|
18
|
+
|
|
19
|
+
1. `npm install` (or `npm i`)
|
|
20
|
+
|
|
21
|
+
###### The code that will be published lives inside the ./src directory.
|
|
22
|
+
|
|
23
|
+
If wishing to add new top level directories to the output, then they must be included in the `files` array inside `package.json` as well as included in the `clean:temp` command.
|
|
24
|
+
|
|
25
|
+
### Publishing
|
|
26
|
+
|
|
27
|
+
In order to see the output of what will be published, run the following command:
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
npm publish --dry-run
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
There are two ways in which this package can/should be published:
|
|
34
|
+
|
|
35
|
+
###### Requires manual version bump via the PR
|
|
36
|
+
|
|
37
|
+
- Upon merge into `main` branch, the package will be published via a GHA workflow.
|
|
38
|
+
|
|
39
|
+
# Contents
|
|
40
|
+
|
|
41
|
+
## EnvironmentVariables
|
|
42
|
+
|
|
43
|
+
### Overview
|
|
44
|
+
`EnvironmentVariables` is a utility class for managing environment variables in a structured way. It ensures that required environment variables are present and provides default values when necessary.
|
|
45
|
+
|
|
46
|
+
### Usage
|
|
47
|
+
|
|
48
|
+
#### Importing the `EnvironmentVariables` Class
|
|
49
|
+
```ts
|
|
50
|
+
import { EnvironmentVariables } from '@dvsa/cvs-microservice-common';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Retrieving a Required Environment Variable
|
|
54
|
+
Use the `get` method to retrieve an environment variable. If the variable is missing, an error is thrown.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const apiKey = EnvironmentVariables.get("API_KEY");
|
|
58
|
+
console.log("API Key:", apiKey);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
##### Example with Missing Variable
|
|
62
|
+
If `API_KEY` is not set in the environment, the following error will be thrown:
|
|
63
|
+
```sh
|
|
64
|
+
Error: Configuration item API_KEY was not provided with a value
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Using a Default Value When a Variable is Absent
|
|
68
|
+
If an environment variable may be missing, you can use `defaultIfNotPresent` to provide a fallback value.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const logLevel = EnvironmentVariables.defaultIfNotPresent(process.env.LOG_LEVEL, "info");
|
|
72
|
+
console.log("Log Level:", logLevel);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Ensuring an Environment Variable is Set Before Proceeding
|
|
76
|
+
Use `throwIfNotPresent` when checking a variable's existence but wanting an explicit error if it's missing.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const dbHost = EnvironmentVariables.throwIfNotPresent(process.env.DB_HOST, "DB_HOST");
|
|
80
|
+
console.log("Database Host:", dbHost);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Error Handling
|
|
84
|
+
- If `get` or `throwIfNotPresent` is used on an unset variable, an error is thrown.
|
|
85
|
+
- `defaultIfNotPresent` prevents errors by returning a default value when the variable is missing.
|
|
86
|
+
|
|
87
|
+
### Example `.env` File
|
|
88
|
+
```sh
|
|
89
|
+
API_KEY=my-secret-api-key
|
|
90
|
+
DB_HOST=database.example.com
|
|
91
|
+
LOG_LEVEL=debug
|
|
92
|
+
```
|
|
93
|
+
## Custom Routing Decorators
|
|
94
|
+
|
|
95
|
+
### Overview
|
|
96
|
+
This module provides custom decorators (`GET`, `POST`, and `PUT`) for `routing-controllers`, allowing API routes to be automatically prefixed with a branch name when the `BRANCH` environment variable is set.
|
|
97
|
+
|
|
98
|
+
### Installation
|
|
99
|
+
Ensure you have `routing-controllers` installed in your project:
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
npm install routing-controllers
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Usage
|
|
106
|
+
|
|
107
|
+
#### Importing the Custom Route Decorators
|
|
108
|
+
```ts
|
|
109
|
+
import { GET, POST, PUT } from '@dvsa/cvs-microservice-common/api/routing-decorators';
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Defining API Endpoints with Branch-Aware Routing
|
|
113
|
+
These decorators extend `routing-controllers`' `@Get`, `@Post`, and `@Put` decorators by applying both the original route and a prefixed route (if `BRANCH` is set).
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { JsonController } from "routing-controllers";
|
|
117
|
+
import { GET, POST, PUT } from "@dvsa/cvs-microservice-common/api/routing-decorators";
|
|
118
|
+
|
|
119
|
+
@JsonController("/users")
|
|
120
|
+
export class UserController {
|
|
121
|
+
@GET("/")
|
|
122
|
+
getUsers() {
|
|
123
|
+
return { message: "List of users" };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@POST("/")
|
|
127
|
+
createUser() {
|
|
128
|
+
return { message: "User created" };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@PUT("/:id")
|
|
132
|
+
updateUser() {
|
|
133
|
+
return { message: "User updated" };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Effect of `BRANCH` Environment Variable
|
|
139
|
+
If `BRANCH=feature-x`, the above routes will be accessible at:
|
|
140
|
+
|
|
141
|
+
- `GET /users/` → List users
|
|
142
|
+
- `GET /feature-x/users/` → List users (branch-prefixed)
|
|
143
|
+
- `POST /users/` → Create a user
|
|
144
|
+
- `POST /feature-x/users/` → Create a user (branch-prefixed)
|
|
145
|
+
- `PUT /users/:id` → Update a user
|
|
146
|
+
- `PUT /feature-x/users/:id` → Update a user (branch-prefixed)
|
|
147
|
+
|
|
148
|
+
#### Setting the `BRANCH` Environment Variable
|
|
149
|
+
To enable branch-prefixed routes, set the `BRANCH` environment variable:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
export BRANCH=feature-x
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Benefits
|
|
156
|
+
- **Supports Feature Branching**: Easily test feature-specific API versions.
|
|
157
|
+
- **Automatic Routing Prefixing**: No need to manually adjust routes for different environments.
|
|
158
|
+
- **Seamless Integration**: Works with `routing-controllers` decorators.
|
|
159
|
+
|
|
160
|
+
## HttpStatus
|
|
161
|
+
|
|
162
|
+
### Overview
|
|
163
|
+
`HttpStatus` is an enumeration representing common HTTP status codes. It provides a readable and maintainable way to reference standard HTTP response codes in your application.
|
|
164
|
+
|
|
165
|
+
### Usage
|
|
166
|
+
|
|
167
|
+
#### Importing the `HttpStatus` Enum
|
|
168
|
+
```ts
|
|
169
|
+
import { HttpStatus } from '@domain/enums/HttpStatus.enum';
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Using HTTP Status Codes in API Responses
|
|
173
|
+
The `HttpStatus` enum can be used to improve readability and maintainability in HTTP responses.
|
|
174
|
+
|
|
175
|
+
##### Example Usage in an Express API
|
|
176
|
+
```ts
|
|
177
|
+
import express from "express";
|
|
178
|
+
import { HttpStatus } from "@domain/enums/HttpStatus.enum";
|
|
179
|
+
|
|
180
|
+
const app = express();
|
|
181
|
+
|
|
182
|
+
app.get("/status", (req, res) => {
|
|
183
|
+
res.status(HttpStatus.OK).json({ message: "Success" });
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
app.use((req, res) => {
|
|
187
|
+
res.status(HttpStatus.NOT_FOUND).json({ error: "Not Found" });
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
app.listen(3000, () => console.log("Server running on port 3000"));
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### Common Status Codes
|
|
194
|
+
| Status Code | Enum Value | Description |
|
|
195
|
+
|------------|--------------------------|--------------------------------|
|
|
196
|
+
| 200 | `HttpStatus.OK` | Request was successful |
|
|
197
|
+
| 201 | `HttpStatus.CREATED` | Resource was successfully created |
|
|
198
|
+
| 202 | `HttpStatus.ACCEPTED` | Request has been accepted but not processed yet |
|
|
199
|
+
| 204 | `HttpStatus.NO_CONTENT` | Request was successful but no content returned |
|
|
200
|
+
| 400 | `HttpStatus.BAD_REQUEST` | Client error - invalid request |
|
|
201
|
+
| 401 | `HttpStatus.UNAUTHORIZED` | Authentication required |
|
|
202
|
+
| 403 | `HttpStatus.FORBIDDEN` | Insufficient permissions |
|
|
203
|
+
| 404 | `HttpStatus.NOT_FOUND` | Resource not found |
|
|
204
|
+
| 500 | `HttpStatus.INTERNAL_SERVER_ERROR` | Server error |
|
|
205
|
+
| 502 | `HttpStatus.BAD_GATEWAY` | Invalid response from upstream server |
|
|
206
|
+
| 504 | `HttpStatus.GATEWAY_TIMEOUT` | Upstream server timeout |
|
|
207
|
+
|
|
208
|
+
### Benefits of Using `HttpStatus`
|
|
209
|
+
- **Improved Readability**: Instead of using magic numbers, named constants make code clearer.
|
|
210
|
+
- **Better Maintainability**: Centralized status codes make updates easier.
|
|
211
|
+
- **Reduced Errors**: Avoid mistyping HTTP status codes.
|
|
212
|
+
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./misc/outbox"), exports);
|
|
18
|
+
__exportStar(require("./test-facility/activity"), exports);
|
|
19
|
+
__exportStar(require("./test-facility/test-station"), exports);
|
package/misc/outbox.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export declare const outbox: import("drizzle-orm/mysql-core").MySqlTableWithColumns<{
|
|
2
|
+
name: "outbox";
|
|
3
|
+
schema: "test_facility";
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "outbox";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "MySqlBigInt53";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: string | number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: true;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
eventType: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
23
|
+
name: "event_type";
|
|
24
|
+
tableName: "outbox";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "MySqlEnumColumn";
|
|
27
|
+
data: "created" | "updated" | "deleted";
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: ["created", "updated", "deleted"];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
aggregateType: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
40
|
+
name: "aggregate_type";
|
|
41
|
+
tableName: "outbox";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "MySqlEnumColumn";
|
|
44
|
+
data: "activity" | "tech-record" | "test-result" | "test-station";
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: ["activity", "tech-record", "test-result", "test-station"];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
payload: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
57
|
+
name: "payload";
|
|
58
|
+
tableName: "outbox";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "MySqlText";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
status: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
74
|
+
name: "status";
|
|
75
|
+
tableName: "outbox";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "MySqlEnumColumn";
|
|
78
|
+
data: "pending" | "completed" | "failed";
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: true;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: ["pending", "completed", "failed"];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
attemptCount: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
91
|
+
name: "attempt_count";
|
|
92
|
+
tableName: "outbox";
|
|
93
|
+
dataType: "number";
|
|
94
|
+
columnType: "MySqlInt";
|
|
95
|
+
data: number;
|
|
96
|
+
driverParam: string | number;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: true;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: undefined;
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
createdAt: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
108
|
+
name: "created_at";
|
|
109
|
+
tableName: "outbox";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "MySqlDateTimeString";
|
|
112
|
+
data: string;
|
|
113
|
+
driverParam: string | number;
|
|
114
|
+
notNull: false;
|
|
115
|
+
hasDefault: true;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: undefined;
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
completedAt: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
125
|
+
name: "completed_at";
|
|
126
|
+
tableName: "outbox";
|
|
127
|
+
dataType: "date";
|
|
128
|
+
columnType: "MySqlDateTime";
|
|
129
|
+
data: Date;
|
|
130
|
+
driverParam: string | number;
|
|
131
|
+
notNull: false;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: undefined;
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
errorMessage: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
142
|
+
name: "error_message";
|
|
143
|
+
tableName: "outbox";
|
|
144
|
+
dataType: "string";
|
|
145
|
+
columnType: "MySqlText";
|
|
146
|
+
data: string;
|
|
147
|
+
driverParam: string;
|
|
148
|
+
notNull: false;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: [string, ...string[]];
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
};
|
|
159
|
+
dialect: "mysql";
|
|
160
|
+
}>;
|
package/misc/outbox.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.outbox = void 0;
|
|
4
|
+
const mysql_core_1 = require("drizzle-orm/mysql-core");
|
|
5
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
6
|
+
exports.outbox = (0, mysql_core_1.mysqlSchema)('test_facility').table('outbox', {
|
|
7
|
+
id: (0, mysql_core_1.bigint)({ mode: 'number', unsigned: true }).autoincrement().primaryKey(),
|
|
8
|
+
eventType: (0, mysql_core_1.mysqlEnum)('event_type', ['created', 'updated', 'deleted']).notNull(),
|
|
9
|
+
aggregateType: (0, mysql_core_1.mysqlEnum)('aggregate_type', ['activity', 'tech-record', 'test-result', 'test-station']).notNull(),
|
|
10
|
+
payload: (0, mysql_core_1.text)('payload').notNull(),
|
|
11
|
+
status: (0, mysql_core_1.mysqlEnum)('status', ['pending', 'completed', 'failed']).notNull().default('pending'),
|
|
12
|
+
attemptCount: (0, mysql_core_1.int)('attempt_count').notNull().default(0),
|
|
13
|
+
createdAt: (0, mysql_core_1.datetime)('created_at', { mode: 'string', fsp: 3 }).default((0, drizzle_orm_1.sql) `(CURRENT_TIMESTAMP(3))`),
|
|
14
|
+
completedAt: (0, mysql_core_1.datetime)('completed_at'),
|
|
15
|
+
errorMessage: (0, mysql_core_1.text)('error_message'),
|
|
16
|
+
}, (table) => [
|
|
17
|
+
(0, mysql_core_1.unique)('uq_outbox_aggregate_id_event').on(table.aggregateType, table.id, table.eventType),
|
|
18
|
+
(0, mysql_core_1.index)('idx_outbox_status_created_at').on(table.status, table.createdAt),
|
|
19
|
+
(0, mysql_core_1.index)('idx_outbox_event_type').on(table.eventType),
|
|
20
|
+
(0, mysql_core_1.index)('idx_outbox_aggregate_type').on(table.aggregateType),
|
|
21
|
+
(0, mysql_core_1.primaryKey)({ columns: [table.id], name: 'outbox_id' }),
|
|
22
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dvsa/cvs-db-schemas",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "CVS Drizzle Schema Common Package",
|
|
5
|
+
"author": "DVSA",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dvsa/appdev-packages.git",
|
|
10
|
+
"directory": "packages/cvs-db-schemas"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"typescript",
|
|
14
|
+
"nodejs"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"directory": "dist",
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "rimraf coverage dist",
|
|
22
|
+
"clean:temp": "rimraf auth api",
|
|
23
|
+
"lint": "biome check src",
|
|
24
|
+
"lint:fix": "npm run lint -- --write",
|
|
25
|
+
"build": "npm run clean && tsc",
|
|
26
|
+
"build:package": "npm run build",
|
|
27
|
+
"test": "jest",
|
|
28
|
+
"test:coverage": "jest --coverage",
|
|
29
|
+
"prepublishOnly": "npm run build:package && cp -r ./dist/* . && rm -rf ./dist",
|
|
30
|
+
"postpublish": "git clean -fd && npm run clean:temp",
|
|
31
|
+
"gitSecrets": "git secrets --scan . && git log -p -- . | scanrepo"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"drizzle-orm": "^0.45.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@biomejs/biome": "2.1.3",
|
|
38
|
+
"@dvsa/biome-config": "1.0.0",
|
|
39
|
+
"@types/aws-lambda": "^8.10.160",
|
|
40
|
+
"@types/jest": "^30.0.0",
|
|
41
|
+
"@types/node": "^22.19.7",
|
|
42
|
+
"husky": "^9.1.7",
|
|
43
|
+
"jest": "^30.2.0",
|
|
44
|
+
"lint-staged": "^15.2.10",
|
|
45
|
+
"rimraf": "^6.0.1",
|
|
46
|
+
"ts-jest": "^29.2.5",
|
|
47
|
+
"ts-node": "^10.9.2",
|
|
48
|
+
"typescript": "^5.5.2"
|
|
49
|
+
},
|
|
50
|
+
"lint-staged": {
|
|
51
|
+
"*.{js,ts,mjs,css,md,ts,json}": "npm run lint:fix -- --no-errors-on-unmatched"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
export declare const activity: import("drizzle-orm/mysql-core").MySqlTableWithColumns<{
|
|
2
|
+
name: "activity";
|
|
3
|
+
schema: "test_facility";
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "activity";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "MySqlBigInt53";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: string | number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: true;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
activityUuid: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
23
|
+
name: "activity_uuid";
|
|
24
|
+
tableName: "activity";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "MySqlVarChar";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string | number;
|
|
29
|
+
notNull: false;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
testerStaffId: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
40
|
+
name: "tester_staff_id";
|
|
41
|
+
tableName: "activity";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "MySqlVarChar";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string | number;
|
|
46
|
+
notNull: false;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
testerStaffName: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
57
|
+
name: "tester_staff_name";
|
|
58
|
+
tableName: "activity";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "MySqlVarChar";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string | number;
|
|
63
|
+
notNull: false;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
testerStaffEmail: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
74
|
+
name: "tester_staff_email";
|
|
75
|
+
tableName: "activity";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "MySqlVarChar";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string | number;
|
|
80
|
+
notNull: false;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
testStationId: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
91
|
+
name: "test_station_id";
|
|
92
|
+
tableName: "activity";
|
|
93
|
+
dataType: "number";
|
|
94
|
+
columnType: "MySqlBigInt53";
|
|
95
|
+
data: number;
|
|
96
|
+
driverParam: string | number;
|
|
97
|
+
notNull: true;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: undefined;
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
parentActivityId: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
108
|
+
name: "parent_activity_id";
|
|
109
|
+
tableName: "activity";
|
|
110
|
+
dataType: "number";
|
|
111
|
+
columnType: "MySqlBigInt53";
|
|
112
|
+
data: number;
|
|
113
|
+
driverParam: string | number;
|
|
114
|
+
notNull: false;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: undefined;
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
activityType: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
125
|
+
name: "activity_type";
|
|
126
|
+
tableName: "activity";
|
|
127
|
+
dataType: "string";
|
|
128
|
+
columnType: "MySqlVarChar";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string | number;
|
|
131
|
+
notNull: false;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
startDatetime: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
142
|
+
name: "start_datetime";
|
|
143
|
+
tableName: "activity";
|
|
144
|
+
dataType: "string";
|
|
145
|
+
columnType: "MySqlDateTimeString";
|
|
146
|
+
data: string;
|
|
147
|
+
driverParam: string | number;
|
|
148
|
+
notNull: false;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: undefined;
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
endDatetime: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
159
|
+
name: "end_datetime";
|
|
160
|
+
tableName: "activity";
|
|
161
|
+
dataType: "string";
|
|
162
|
+
columnType: "MySqlDateTimeString";
|
|
163
|
+
data: string;
|
|
164
|
+
driverParam: string | number;
|
|
165
|
+
notNull: false;
|
|
166
|
+
hasDefault: false;
|
|
167
|
+
isPrimaryKey: false;
|
|
168
|
+
isAutoincrement: false;
|
|
169
|
+
hasRuntimeDefault: false;
|
|
170
|
+
enumValues: undefined;
|
|
171
|
+
baseColumn: never;
|
|
172
|
+
identity: undefined;
|
|
173
|
+
generated: undefined;
|
|
174
|
+
}, {}, {}>;
|
|
175
|
+
waitReason: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
176
|
+
name: "wait_reason";
|
|
177
|
+
tableName: "activity";
|
|
178
|
+
dataType: "string";
|
|
179
|
+
columnType: "MySqlVarChar";
|
|
180
|
+
data: string;
|
|
181
|
+
driverParam: string | number;
|
|
182
|
+
notNull: false;
|
|
183
|
+
hasDefault: false;
|
|
184
|
+
isPrimaryKey: false;
|
|
185
|
+
isAutoincrement: false;
|
|
186
|
+
hasRuntimeDefault: false;
|
|
187
|
+
enumValues: [string, ...string[]];
|
|
188
|
+
baseColumn: never;
|
|
189
|
+
identity: undefined;
|
|
190
|
+
generated: undefined;
|
|
191
|
+
}, {}, {}>;
|
|
192
|
+
notes: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
193
|
+
name: "notes";
|
|
194
|
+
tableName: "activity";
|
|
195
|
+
dataType: "string";
|
|
196
|
+
columnType: "MySqlVarChar";
|
|
197
|
+
data: string;
|
|
198
|
+
driverParam: string | number;
|
|
199
|
+
notNull: false;
|
|
200
|
+
hasDefault: false;
|
|
201
|
+
isPrimaryKey: false;
|
|
202
|
+
isAutoincrement: false;
|
|
203
|
+
hasRuntimeDefault: false;
|
|
204
|
+
enumValues: [string, ...string[]];
|
|
205
|
+
baseColumn: never;
|
|
206
|
+
identity: undefined;
|
|
207
|
+
generated: undefined;
|
|
208
|
+
}, {}, {}>;
|
|
209
|
+
closureReason: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
210
|
+
name: "closure_reason";
|
|
211
|
+
tableName: "activity";
|
|
212
|
+
dataType: "string";
|
|
213
|
+
columnType: "MySqlVarChar";
|
|
214
|
+
data: string;
|
|
215
|
+
driverParam: string | number;
|
|
216
|
+
notNull: false;
|
|
217
|
+
hasDefault: false;
|
|
218
|
+
isPrimaryKey: false;
|
|
219
|
+
isAutoincrement: false;
|
|
220
|
+
hasRuntimeDefault: false;
|
|
221
|
+
enumValues: [string, ...string[]];
|
|
222
|
+
baseColumn: never;
|
|
223
|
+
identity: undefined;
|
|
224
|
+
generated: undefined;
|
|
225
|
+
}, {}, {}>;
|
|
226
|
+
createdById: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
227
|
+
name: "created_by_id";
|
|
228
|
+
tableName: "activity";
|
|
229
|
+
dataType: "string";
|
|
230
|
+
columnType: "MySqlVarChar";
|
|
231
|
+
data: string;
|
|
232
|
+
driverParam: string | number;
|
|
233
|
+
notNull: false;
|
|
234
|
+
hasDefault: false;
|
|
235
|
+
isPrimaryKey: false;
|
|
236
|
+
isAutoincrement: false;
|
|
237
|
+
hasRuntimeDefault: false;
|
|
238
|
+
enumValues: [string, ...string[]];
|
|
239
|
+
baseColumn: never;
|
|
240
|
+
identity: undefined;
|
|
241
|
+
generated: undefined;
|
|
242
|
+
}, {}, {}>;
|
|
243
|
+
createdByName: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
244
|
+
name: "created_by_name";
|
|
245
|
+
tableName: "activity";
|
|
246
|
+
dataType: "string";
|
|
247
|
+
columnType: "MySqlVarChar";
|
|
248
|
+
data: string;
|
|
249
|
+
driverParam: string | number;
|
|
250
|
+
notNull: false;
|
|
251
|
+
hasDefault: false;
|
|
252
|
+
isPrimaryKey: false;
|
|
253
|
+
isAutoincrement: false;
|
|
254
|
+
hasRuntimeDefault: false;
|
|
255
|
+
enumValues: [string, ...string[]];
|
|
256
|
+
baseColumn: never;
|
|
257
|
+
identity: undefined;
|
|
258
|
+
generated: undefined;
|
|
259
|
+
}, {}, {}>;
|
|
260
|
+
insertedDatetime: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
261
|
+
name: "inserted_datetime";
|
|
262
|
+
tableName: "activity";
|
|
263
|
+
dataType: "string";
|
|
264
|
+
columnType: "MySqlDateTimeString";
|
|
265
|
+
data: string;
|
|
266
|
+
driverParam: string | number;
|
|
267
|
+
notNull: false;
|
|
268
|
+
hasDefault: true;
|
|
269
|
+
isPrimaryKey: false;
|
|
270
|
+
isAutoincrement: false;
|
|
271
|
+
hasRuntimeDefault: false;
|
|
272
|
+
enumValues: undefined;
|
|
273
|
+
baseColumn: never;
|
|
274
|
+
identity: undefined;
|
|
275
|
+
generated: undefined;
|
|
276
|
+
}, {}, {}>;
|
|
277
|
+
lastUpdatedById: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
278
|
+
name: "last_updated_by_id";
|
|
279
|
+
tableName: "activity";
|
|
280
|
+
dataType: "string";
|
|
281
|
+
columnType: "MySqlVarChar";
|
|
282
|
+
data: string;
|
|
283
|
+
driverParam: string | number;
|
|
284
|
+
notNull: false;
|
|
285
|
+
hasDefault: false;
|
|
286
|
+
isPrimaryKey: false;
|
|
287
|
+
isAutoincrement: false;
|
|
288
|
+
hasRuntimeDefault: false;
|
|
289
|
+
enumValues: [string, ...string[]];
|
|
290
|
+
baseColumn: never;
|
|
291
|
+
identity: undefined;
|
|
292
|
+
generated: undefined;
|
|
293
|
+
}, {}, {}>;
|
|
294
|
+
lastUpdatedByName: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
295
|
+
name: "last_updated_by_name";
|
|
296
|
+
tableName: "activity";
|
|
297
|
+
dataType: "string";
|
|
298
|
+
columnType: "MySqlVarChar";
|
|
299
|
+
data: string;
|
|
300
|
+
driverParam: string | number;
|
|
301
|
+
notNull: false;
|
|
302
|
+
hasDefault: false;
|
|
303
|
+
isPrimaryKey: false;
|
|
304
|
+
isAutoincrement: false;
|
|
305
|
+
hasRuntimeDefault: false;
|
|
306
|
+
enumValues: [string, ...string[]];
|
|
307
|
+
baseColumn: never;
|
|
308
|
+
identity: undefined;
|
|
309
|
+
generated: undefined;
|
|
310
|
+
}, {}, {}>;
|
|
311
|
+
lastUpdatedDatetime: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
312
|
+
name: "last_updated_datetime";
|
|
313
|
+
tableName: "activity";
|
|
314
|
+
dataType: "string";
|
|
315
|
+
columnType: "MySqlDateTimeString";
|
|
316
|
+
data: string;
|
|
317
|
+
driverParam: string | number;
|
|
318
|
+
notNull: false;
|
|
319
|
+
hasDefault: true;
|
|
320
|
+
isPrimaryKey: false;
|
|
321
|
+
isAutoincrement: false;
|
|
322
|
+
hasRuntimeDefault: false;
|
|
323
|
+
enumValues: undefined;
|
|
324
|
+
baseColumn: never;
|
|
325
|
+
identity: undefined;
|
|
326
|
+
generated: undefined;
|
|
327
|
+
}, {}, {}>;
|
|
328
|
+
};
|
|
329
|
+
dialect: "mysql";
|
|
330
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activity = void 0;
|
|
4
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
5
|
+
const mysql_core_1 = require("drizzle-orm/mysql-core");
|
|
6
|
+
exports.activity = (0, mysql_core_1.mysqlSchema)('test_facility').table('activity', {
|
|
7
|
+
id: (0, mysql_core_1.bigint)({ mode: 'number', unsigned: true }).autoincrement().primaryKey(),
|
|
8
|
+
activityUuid: (0, mysql_core_1.varchar)('activity_uuid', { length: 36 }),
|
|
9
|
+
testerStaffId: (0, mysql_core_1.varchar)('tester_staff_id', { length: 40 }),
|
|
10
|
+
testerStaffName: (0, mysql_core_1.varchar)('tester_staff_name', { length: 100 }),
|
|
11
|
+
testerStaffEmail: (0, mysql_core_1.varchar)('tester_staff_email', { length: 200 }),
|
|
12
|
+
testStationId: (0, mysql_core_1.bigint)('test_station_id', { mode: 'number', unsigned: true }).notNull(),
|
|
13
|
+
parentActivityId: (0, mysql_core_1.bigint)('parent_activity_id', { mode: 'number', unsigned: true }),
|
|
14
|
+
activityType: (0, mysql_core_1.varchar)('activity_type', { length: 50 }),
|
|
15
|
+
startDatetime: (0, mysql_core_1.datetime)('start_datetime', { mode: 'string', fsp: 3 }),
|
|
16
|
+
endDatetime: (0, mysql_core_1.datetime)('end_datetime', { mode: 'string', fsp: 3 }),
|
|
17
|
+
waitReason: (0, mysql_core_1.varchar)('wait_reason', { length: 150 }),
|
|
18
|
+
notes: (0, mysql_core_1.varchar)({ length: 500 }),
|
|
19
|
+
closureReason: (0, mysql_core_1.varchar)('closure_reason', { length: 20 }),
|
|
20
|
+
createdById: (0, mysql_core_1.varchar)('created_by_id', { length: 40 }),
|
|
21
|
+
createdByName: (0, mysql_core_1.varchar)('created_by_name', { length: 200 }),
|
|
22
|
+
insertedDatetime: (0, mysql_core_1.datetime)('inserted_datetime', { mode: 'string', fsp: 3 }).default((0, drizzle_orm_1.sql) `(CURRENT_TIMESTAMP(3))`),
|
|
23
|
+
lastUpdatedById: (0, mysql_core_1.varchar)('last_updated_by_id', { length: 40 }),
|
|
24
|
+
lastUpdatedByName: (0, mysql_core_1.varchar)('last_updated_by_name', { length: 200 }),
|
|
25
|
+
lastUpdatedDatetime: (0, mysql_core_1.datetime)('last_updated_datetime', { mode: 'string', fsp: 3 }).default((0, drizzle_orm_1.sql) `(CURRENT_TIMESTAMP(3))`),
|
|
26
|
+
}, (table) => [
|
|
27
|
+
(0, mysql_core_1.index)('idx_test_station_id').on(table.testStationId),
|
|
28
|
+
(0, mysql_core_1.index)('idx_tester_staff_id').on(table.testerStaffId),
|
|
29
|
+
(0, mysql_core_1.index)('idx_activity_type').on(table.activityType),
|
|
30
|
+
(0, mysql_core_1.foreignKey)({
|
|
31
|
+
columns: [table.parentActivityId],
|
|
32
|
+
foreignColumns: [table.id],
|
|
33
|
+
name: 'fk_parent_activity_id',
|
|
34
|
+
}),
|
|
35
|
+
(0, mysql_core_1.primaryKey)({ columns: [table.id], name: 'activity_id' }),
|
|
36
|
+
(0, mysql_core_1.unique)('idx_activity_uuid_uq').on(table.activityUuid),
|
|
37
|
+
]);
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
export declare const testStation: import("drizzle-orm/mysql-core").MySqlTableWithColumns<{
|
|
2
|
+
name: "test_station";
|
|
3
|
+
schema: "test_facility";
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "test_station";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "MySqlBigInt53";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: string | number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: true;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
dynamicsTestStationId: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
23
|
+
name: "dynamics_test_station_id";
|
|
24
|
+
tableName: "test_station";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "MySqlVarChar";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string | number;
|
|
29
|
+
notNull: false;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
accessNotes: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
40
|
+
name: "access_notes";
|
|
41
|
+
tableName: "test_station";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "MySqlText";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: false;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
address: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
57
|
+
name: "address";
|
|
58
|
+
tableName: "test_station";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "MySqlVarChar";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string | number;
|
|
63
|
+
notNull: false;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
contactNumber: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
74
|
+
name: "contact_number";
|
|
75
|
+
tableName: "test_station";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "MySqlVarChar";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string | number;
|
|
80
|
+
notNull: false;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
90
|
+
country: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
91
|
+
name: "country";
|
|
92
|
+
tableName: "test_station";
|
|
93
|
+
dataType: "string";
|
|
94
|
+
columnType: "MySqlVarChar";
|
|
95
|
+
data: string;
|
|
96
|
+
driverParam: string | number;
|
|
97
|
+
notNull: false;
|
|
98
|
+
hasDefault: false;
|
|
99
|
+
isPrimaryKey: false;
|
|
100
|
+
isAutoincrement: false;
|
|
101
|
+
hasRuntimeDefault: false;
|
|
102
|
+
enumValues: [string, ...string[]];
|
|
103
|
+
baseColumn: never;
|
|
104
|
+
identity: undefined;
|
|
105
|
+
generated: undefined;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
emailAddressesJson: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
108
|
+
name: "email_addresses_json";
|
|
109
|
+
tableName: "test_station";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "MySqlVarChar";
|
|
112
|
+
data: string;
|
|
113
|
+
driverParam: string | number;
|
|
114
|
+
notNull: false;
|
|
115
|
+
hasDefault: false;
|
|
116
|
+
isPrimaryKey: false;
|
|
117
|
+
isAutoincrement: false;
|
|
118
|
+
hasRuntimeDefault: false;
|
|
119
|
+
enumValues: [string, ...string[]];
|
|
120
|
+
baseColumn: never;
|
|
121
|
+
identity: undefined;
|
|
122
|
+
generated: undefined;
|
|
123
|
+
}, {}, {}>;
|
|
124
|
+
generalNotes: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
125
|
+
name: "general_notes";
|
|
126
|
+
tableName: "test_station";
|
|
127
|
+
dataType: "string";
|
|
128
|
+
columnType: "MySqlText";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: false;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {}>;
|
|
141
|
+
latitude: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
142
|
+
name: "latitude";
|
|
143
|
+
tableName: "test_station";
|
|
144
|
+
dataType: "string";
|
|
145
|
+
columnType: "MySqlDecimal";
|
|
146
|
+
data: string;
|
|
147
|
+
driverParam: string;
|
|
148
|
+
notNull: false;
|
|
149
|
+
hasDefault: false;
|
|
150
|
+
isPrimaryKey: false;
|
|
151
|
+
isAutoincrement: false;
|
|
152
|
+
hasRuntimeDefault: false;
|
|
153
|
+
enumValues: undefined;
|
|
154
|
+
baseColumn: never;
|
|
155
|
+
identity: undefined;
|
|
156
|
+
generated: undefined;
|
|
157
|
+
}, {}, {}>;
|
|
158
|
+
longitude: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
159
|
+
name: "longitude";
|
|
160
|
+
tableName: "test_station";
|
|
161
|
+
dataType: "string";
|
|
162
|
+
columnType: "MySqlDecimal";
|
|
163
|
+
data: string;
|
|
164
|
+
driverParam: string;
|
|
165
|
+
notNull: false;
|
|
166
|
+
hasDefault: false;
|
|
167
|
+
isPrimaryKey: false;
|
|
168
|
+
isAutoincrement: false;
|
|
169
|
+
hasRuntimeDefault: false;
|
|
170
|
+
enumValues: undefined;
|
|
171
|
+
baseColumn: never;
|
|
172
|
+
identity: undefined;
|
|
173
|
+
generated: undefined;
|
|
174
|
+
}, {}, {}>;
|
|
175
|
+
name: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
176
|
+
name: "name";
|
|
177
|
+
tableName: "test_station";
|
|
178
|
+
dataType: "string";
|
|
179
|
+
columnType: "MySqlVarChar";
|
|
180
|
+
data: string;
|
|
181
|
+
driverParam: string | number;
|
|
182
|
+
notNull: false;
|
|
183
|
+
hasDefault: false;
|
|
184
|
+
isPrimaryKey: false;
|
|
185
|
+
isAutoincrement: false;
|
|
186
|
+
hasRuntimeDefault: false;
|
|
187
|
+
enumValues: [string, ...string[]];
|
|
188
|
+
baseColumn: never;
|
|
189
|
+
identity: undefined;
|
|
190
|
+
generated: undefined;
|
|
191
|
+
}, {}, {}>;
|
|
192
|
+
pNumber: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
193
|
+
name: "p_number";
|
|
194
|
+
tableName: "test_station";
|
|
195
|
+
dataType: "string";
|
|
196
|
+
columnType: "MySqlVarChar";
|
|
197
|
+
data: string;
|
|
198
|
+
driverParam: string | number;
|
|
199
|
+
notNull: false;
|
|
200
|
+
hasDefault: false;
|
|
201
|
+
isPrimaryKey: false;
|
|
202
|
+
isAutoincrement: false;
|
|
203
|
+
hasRuntimeDefault: false;
|
|
204
|
+
enumValues: [string, ...string[]];
|
|
205
|
+
baseColumn: never;
|
|
206
|
+
identity: undefined;
|
|
207
|
+
generated: undefined;
|
|
208
|
+
}, {}, {}>;
|
|
209
|
+
postcode: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
210
|
+
name: "postcode";
|
|
211
|
+
tableName: "test_station";
|
|
212
|
+
dataType: "string";
|
|
213
|
+
columnType: "MySqlVarChar";
|
|
214
|
+
data: string;
|
|
215
|
+
driverParam: string | number;
|
|
216
|
+
notNull: false;
|
|
217
|
+
hasDefault: false;
|
|
218
|
+
isPrimaryKey: false;
|
|
219
|
+
isAutoincrement: false;
|
|
220
|
+
hasRuntimeDefault: false;
|
|
221
|
+
enumValues: [string, ...string[]];
|
|
222
|
+
baseColumn: never;
|
|
223
|
+
identity: undefined;
|
|
224
|
+
generated: undefined;
|
|
225
|
+
}, {}, {}>;
|
|
226
|
+
status: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
227
|
+
name: "status";
|
|
228
|
+
tableName: "test_station";
|
|
229
|
+
dataType: "string";
|
|
230
|
+
columnType: "MySqlVarChar";
|
|
231
|
+
data: string;
|
|
232
|
+
driverParam: string | number;
|
|
233
|
+
notNull: false;
|
|
234
|
+
hasDefault: false;
|
|
235
|
+
isPrimaryKey: false;
|
|
236
|
+
isAutoincrement: false;
|
|
237
|
+
hasRuntimeDefault: false;
|
|
238
|
+
enumValues: [string, ...string[]];
|
|
239
|
+
baseColumn: never;
|
|
240
|
+
identity: undefined;
|
|
241
|
+
generated: undefined;
|
|
242
|
+
}, {}, {}>;
|
|
243
|
+
town: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
244
|
+
name: "town";
|
|
245
|
+
tableName: "test_station";
|
|
246
|
+
dataType: "string";
|
|
247
|
+
columnType: "MySqlVarChar";
|
|
248
|
+
data: string;
|
|
249
|
+
driverParam: string | number;
|
|
250
|
+
notNull: false;
|
|
251
|
+
hasDefault: false;
|
|
252
|
+
isPrimaryKey: false;
|
|
253
|
+
isAutoincrement: false;
|
|
254
|
+
hasRuntimeDefault: false;
|
|
255
|
+
enumValues: [string, ...string[]];
|
|
256
|
+
baseColumn: never;
|
|
257
|
+
identity: undefined;
|
|
258
|
+
generated: undefined;
|
|
259
|
+
}, {}, {}>;
|
|
260
|
+
type: import("drizzle-orm/mysql-core").MySqlColumn<{
|
|
261
|
+
name: "type";
|
|
262
|
+
tableName: "test_station";
|
|
263
|
+
dataType: "string";
|
|
264
|
+
columnType: "MySqlVarChar";
|
|
265
|
+
data: string;
|
|
266
|
+
driverParam: string | number;
|
|
267
|
+
notNull: false;
|
|
268
|
+
hasDefault: false;
|
|
269
|
+
isPrimaryKey: false;
|
|
270
|
+
isAutoincrement: false;
|
|
271
|
+
hasRuntimeDefault: false;
|
|
272
|
+
enumValues: [string, ...string[]];
|
|
273
|
+
baseColumn: never;
|
|
274
|
+
identity: undefined;
|
|
275
|
+
generated: undefined;
|
|
276
|
+
}, {}, {}>;
|
|
277
|
+
};
|
|
278
|
+
dialect: "mysql";
|
|
279
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testStation = void 0;
|
|
4
|
+
const mysql_core_1 = require("drizzle-orm/mysql-core");
|
|
5
|
+
exports.testStation = (0, mysql_core_1.mysqlSchema)('test_facility').table('test_station', {
|
|
6
|
+
id: (0, mysql_core_1.bigint)({ mode: 'number', unsigned: true }).autoincrement().primaryKey(),
|
|
7
|
+
dynamicsTestStationId: (0, mysql_core_1.varchar)('dynamics_test_station_id', { length: 36 }),
|
|
8
|
+
accessNotes: (0, mysql_core_1.text)('access_notes'),
|
|
9
|
+
address: (0, mysql_core_1.varchar)({ length: 100 }),
|
|
10
|
+
contactNumber: (0, mysql_core_1.varchar)('contact_number', { length: 30 }),
|
|
11
|
+
country: (0, mysql_core_1.varchar)({ length: 30 }),
|
|
12
|
+
emailAddressesJson: (0, mysql_core_1.varchar)('email_addresses_json', { length: 2000 }),
|
|
13
|
+
generalNotes: (0, mysql_core_1.text)('general_notes'),
|
|
14
|
+
latitude: (0, mysql_core_1.decimal)({ precision: 9, scale: 6 }),
|
|
15
|
+
longitude: (0, mysql_core_1.decimal)({ precision: 9, scale: 6 }),
|
|
16
|
+
name: (0, mysql_core_1.varchar)({ length: 160 }),
|
|
17
|
+
pNumber: (0, mysql_core_1.varchar)('p_number', { length: 256 }),
|
|
18
|
+
postcode: (0, mysql_core_1.varchar)({ length: 20 }),
|
|
19
|
+
status: (0, mysql_core_1.varchar)({ length: 10 }),
|
|
20
|
+
town: (0, mysql_core_1.varchar)({ length: 30 }),
|
|
21
|
+
type: (0, mysql_core_1.varchar)({ length: 4 }),
|
|
22
|
+
}, (table) => [
|
|
23
|
+
(0, mysql_core_1.index)('idx_p_number_idx').on(table.pNumber),
|
|
24
|
+
(0, mysql_core_1.primaryKey)({ columns: [table.id], name: 'test_station_id' }),
|
|
25
|
+
(0, mysql_core_1.unique)('idx_dynamics_test_station_id_uq').on(table.dynamicsTestStationId),
|
|
26
|
+
]);
|