@dvsa/cvs-db-schemas 0.1.1 → 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/helper/format-schema-name.d.ts +9 -0
- package/helper/format-schema-name.js +10 -1
- package/outbox/outbox.d.ts +16 -16
- package/outbox/outbox.js +14 -14
- package/package.json +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { MySqlColumn } from 'drizzle-orm/mysql-core';
|
|
2
|
+
import type { SQL } from 'drizzle-orm/sql/sql';
|
|
1
3
|
/**
|
|
2
4
|
* Format schema name to append a branch identifier if on a CB2 branch
|
|
3
5
|
* @param {string} baseSchemaName
|
|
@@ -13,3 +15,10 @@
|
|
|
13
15
|
* console.log(schema); // test_facility_CB21234
|
|
14
16
|
*/
|
|
15
17
|
export declare const formatSchemaName: (baseSchemaName: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert a MySQL column that uses 1/0 for boolean values into an actual boolean type in the query result
|
|
20
|
+
* @param {MySqlColumn} column
|
|
21
|
+
* @param {string} alias - Optional Alias, defaults back to `column.name` otherwise
|
|
22
|
+
* @return {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export declare const toBoolean: (column: MySqlColumn, alias?: string | undefined) => SQL.Aliased<boolean>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatSchemaName = void 0;
|
|
3
|
+
exports.toBoolean = exports.formatSchemaName = void 0;
|
|
4
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
4
5
|
/**
|
|
5
6
|
* Format schema name to append a branch identifier if on a CB2 branch
|
|
6
7
|
* @param {string} baseSchemaName
|
|
@@ -20,3 +21,11 @@ const formatSchemaName = (baseSchemaName) => {
|
|
|
20
21
|
return branch?.includes('CB2') ? `${baseSchemaName}_${branch.replace('-', '')}` : baseSchemaName;
|
|
21
22
|
};
|
|
22
23
|
exports.formatSchemaName = formatSchemaName;
|
|
24
|
+
/**
|
|
25
|
+
* Convert a MySQL column that uses 1/0 for boolean values into an actual boolean type in the query result
|
|
26
|
+
* @param {MySqlColumn} column
|
|
27
|
+
* @param {string} alias - Optional Alias, defaults back to `column.name` otherwise
|
|
28
|
+
* @return {boolean}
|
|
29
|
+
*/
|
|
30
|
+
const toBoolean = (column, alias = undefined) => (0, drizzle_orm_1.sql) `IF(${column} = 1, CAST(TRUE AS JSON), CAST(FALSE AS JSON))`.as(alias ?? column.name);
|
|
31
|
+
exports.toBoolean = toBoolean;
|
package/outbox/outbox.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* @generated-schema-doc
|
|
3
3
|
* Schema: `outbox` | Table: `outbox`
|
|
4
4
|
*
|
|
5
|
-
* | Column | Type
|
|
6
|
-
* | ------------- |
|
|
7
|
-
* | id | serial
|
|
8
|
-
* | eventType | enum(created, updated, deleted)
|
|
9
|
-
* | aggregateType | enum(activity, tech-record, test-result
|
|
10
|
-
* | payload | json
|
|
11
|
-
* | status | enum(pending,
|
|
12
|
-
* | attemptCount | int
|
|
13
|
-
* | createdAt | datetime(3)
|
|
14
|
-
* | updatedAt | datetime(3)
|
|
15
|
-
* | errorMessage | text
|
|
16
|
-
* | completedAt | datetime
|
|
5
|
+
* | Column | Type | Nullable | Constraints |
|
|
6
|
+
* | ------------- | ------------------------------------------ | -------- | -------------------------- |
|
|
7
|
+
* | id | serial | No | PK, NOT NULL |
|
|
8
|
+
* | eventType | enum(created, updated, deleted) | No | NOT NULL |
|
|
9
|
+
* | aggregateType | enum(activity, tech-record, test-result) | No | NOT NULL |
|
|
10
|
+
* | payload | json | No | NOT NULL |
|
|
11
|
+
* | status | enum(pending, processing, created, failed) | No | NOT NULL, default: pending |
|
|
12
|
+
* | attemptCount | int | No | NOT NULL, default: 0 |
|
|
13
|
+
* | createdAt | datetime(3) | Yes | default: sql`(now(3 |
|
|
14
|
+
* | updatedAt | datetime(3) | Yes | default: sql`(now(3 |
|
|
15
|
+
* | errorMessage | text | Yes | |
|
|
16
|
+
* | completedAt | datetime | Yes | |
|
|
17
17
|
*/
|
|
18
18
|
export declare const outbox: import("drizzle-orm/mysql-core").MySqlTableWithColumns<{
|
|
19
19
|
name: "outbox";
|
|
@@ -58,14 +58,14 @@ export declare const outbox: import("drizzle-orm/mysql-core").MySqlTableWithColu
|
|
|
58
58
|
tableName: "outbox";
|
|
59
59
|
dataType: "string";
|
|
60
60
|
columnType: "MySqlEnumColumn";
|
|
61
|
-
data: "activity" | "tech-record" | "test-result"
|
|
61
|
+
data: "activity" | "tech-record" | "test-result";
|
|
62
62
|
driverParam: string;
|
|
63
63
|
notNull: true;
|
|
64
64
|
hasDefault: false;
|
|
65
65
|
isPrimaryKey: false;
|
|
66
66
|
isAutoincrement: false;
|
|
67
67
|
hasRuntimeDefault: false;
|
|
68
|
-
enumValues: ["activity", "tech-record", "test-result"
|
|
68
|
+
enumValues: ["activity", "tech-record", "test-result"];
|
|
69
69
|
baseColumn: never;
|
|
70
70
|
identity: undefined;
|
|
71
71
|
generated: undefined;
|
|
@@ -92,14 +92,14 @@ export declare const outbox: import("drizzle-orm/mysql-core").MySqlTableWithColu
|
|
|
92
92
|
tableName: "outbox";
|
|
93
93
|
dataType: "string";
|
|
94
94
|
columnType: "MySqlEnumColumn";
|
|
95
|
-
data: "pending" | "
|
|
95
|
+
data: "created" | "pending" | "processing" | "failed";
|
|
96
96
|
driverParam: string;
|
|
97
97
|
notNull: true;
|
|
98
98
|
hasDefault: true;
|
|
99
99
|
isPrimaryKey: false;
|
|
100
100
|
isAutoincrement: false;
|
|
101
101
|
hasRuntimeDefault: false;
|
|
102
|
-
enumValues: ["pending", "
|
|
102
|
+
enumValues: ["pending", "processing", "created", "failed"];
|
|
103
103
|
baseColumn: never;
|
|
104
104
|
identity: undefined;
|
|
105
105
|
generated: undefined;
|
package/outbox/outbox.js
CHANGED
|
@@ -8,25 +8,25 @@ const format_schema_name_1 = require("../helper/format-schema-name");
|
|
|
8
8
|
* @generated-schema-doc
|
|
9
9
|
* Schema: `outbox` | Table: `outbox`
|
|
10
10
|
*
|
|
11
|
-
* | Column | Type
|
|
12
|
-
* | ------------- |
|
|
13
|
-
* | id | serial
|
|
14
|
-
* | eventType | enum(created, updated, deleted)
|
|
15
|
-
* | aggregateType | enum(activity, tech-record, test-result
|
|
16
|
-
* | payload | json
|
|
17
|
-
* | status | enum(pending,
|
|
18
|
-
* | attemptCount | int
|
|
19
|
-
* | createdAt | datetime(3)
|
|
20
|
-
* | updatedAt | datetime(3)
|
|
21
|
-
* | errorMessage | text
|
|
22
|
-
* | completedAt | datetime
|
|
11
|
+
* | Column | Type | Nullable | Constraints |
|
|
12
|
+
* | ------------- | ------------------------------------------ | -------- | -------------------------- |
|
|
13
|
+
* | id | serial | No | PK, NOT NULL |
|
|
14
|
+
* | eventType | enum(created, updated, deleted) | No | NOT NULL |
|
|
15
|
+
* | aggregateType | enum(activity, tech-record, test-result) | No | NOT NULL |
|
|
16
|
+
* | payload | json | No | NOT NULL |
|
|
17
|
+
* | status | enum(pending, processing, created, failed) | No | NOT NULL, default: pending |
|
|
18
|
+
* | attemptCount | int | No | NOT NULL, default: 0 |
|
|
19
|
+
* | createdAt | datetime(3) | Yes | default: sql`(now(3 |
|
|
20
|
+
* | updatedAt | datetime(3) | Yes | default: sql`(now(3 |
|
|
21
|
+
* | errorMessage | text | Yes | |
|
|
22
|
+
* | completedAt | datetime | Yes | |
|
|
23
23
|
*/
|
|
24
24
|
exports.outbox = (0, mysql_core_1.mysqlSchema)((0, format_schema_name_1.formatSchemaName)('outbox')).table('outbox', {
|
|
25
25
|
id: (0, mysql_core_1.serial)().notNull().primaryKey(),
|
|
26
26
|
eventType: (0, mysql_core_1.mysqlEnum)('event_type', ['created', 'updated', 'deleted']).notNull(),
|
|
27
|
-
aggregateType: (0, mysql_core_1.mysqlEnum)('aggregate_type', ['activity', 'tech-record', 'test-result'
|
|
27
|
+
aggregateType: (0, mysql_core_1.mysqlEnum)('aggregate_type', ['activity', 'tech-record', 'test-result']).notNull(),
|
|
28
28
|
payload: (0, mysql_core_1.json)().notNull(),
|
|
29
|
-
status: (0, mysql_core_1.mysqlEnum)('status', ['pending', '
|
|
29
|
+
status: (0, mysql_core_1.mysqlEnum)('status', ['pending', 'processing', 'created', 'failed']).notNull().default('pending'),
|
|
30
30
|
attemptCount: (0, mysql_core_1.int)('attempt_count').notNull().default(0),
|
|
31
31
|
createdAt: (0, mysql_core_1.datetime)('created_at', { mode: 'string', fsp: 3 }).default((0, drizzle_orm_1.sql) `(now(3))`),
|
|
32
32
|
updatedAt: (0, mysql_core_1.datetime)('updated_at', { mode: 'string', fsp: 3 }).default((0, drizzle_orm_1.sql) `(now(3))`),
|