@platformatic/db 3.38.0 → 3.39.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/config.d.ts +8 -0
- package/lib/application.js +3 -1
- package/lib/errors.js +4 -0
- package/lib/utils.js +13 -0
- package/package.json +13 -13
- package/schema.json +41 -1
package/config.d.ts
CHANGED
|
@@ -96,6 +96,10 @@ export interface PlatformaticDatabaseConfig {
|
|
|
96
96
|
customLevels?: {
|
|
97
97
|
[k: string]: unknown;
|
|
98
98
|
};
|
|
99
|
+
openTelemetryExporter?: {
|
|
100
|
+
protocol: "grpc" | "http";
|
|
101
|
+
url: string;
|
|
102
|
+
};
|
|
99
103
|
[k: string]: unknown;
|
|
100
104
|
};
|
|
101
105
|
loggerInstance?: {
|
|
@@ -548,6 +552,10 @@ export interface PlatformaticDatabaseConfig {
|
|
|
548
552
|
customLevels?: {
|
|
549
553
|
[k: string]: unknown;
|
|
550
554
|
};
|
|
555
|
+
openTelemetryExporter?: {
|
|
556
|
+
protocol: "grpc" | "http";
|
|
557
|
+
url: string;
|
|
558
|
+
};
|
|
551
559
|
[k: string]: unknown;
|
|
552
560
|
};
|
|
553
561
|
server?: {
|
package/lib/application.js
CHANGED
|
@@ -6,7 +6,7 @@ import { readFile, writeFile } from 'node:fs/promises'
|
|
|
6
6
|
import { execute as applyMigrations } from './migrator.js'
|
|
7
7
|
import { root } from './root.js'
|
|
8
8
|
import { execute as generateTypes } from './types.js'
|
|
9
|
-
import { locateSchemaLock, updateSchemaLock } from './utils.js'
|
|
9
|
+
import { locateSchemaLock, updateSchemaLock, validateSchemaLockFormat } from './utils.js'
|
|
10
10
|
|
|
11
11
|
async function healthCheck (app) {
|
|
12
12
|
const { db, sql } = app.platformatic
|
|
@@ -27,6 +27,8 @@ export async function platformaticDatabase (app, capability) {
|
|
|
27
27
|
|
|
28
28
|
async function loadSchemaLock () {
|
|
29
29
|
if (config.db.schemalock) {
|
|
30
|
+
validateSchemaLockFormat(config.db.schemalock)
|
|
31
|
+
|
|
30
32
|
// ignore errors, this is an optimization
|
|
31
33
|
try {
|
|
32
34
|
const path = locateSchemaLock(config)
|
package/lib/errors.js
CHANGED
|
@@ -16,3 +16,7 @@ export const MigrationsToApplyError = createError(
|
|
|
16
16
|
`${ERROR_PREFIX}_MIGRATIONS_TO_APPLY_ERROR`,
|
|
17
17
|
'You have migrations to apply.'
|
|
18
18
|
)
|
|
19
|
+
export const InvalidSchemaLockError = createError(
|
|
20
|
+
`${ERROR_PREFIX}_INVALID_SCHEMA_LOCK_ERROR`,
|
|
21
|
+
'Invalid schema lock format.'
|
|
22
|
+
)
|
package/lib/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ import { kMetadata } from '@platformatic/foundation'
|
|
|
3
3
|
import fs from 'node:fs/promises'
|
|
4
4
|
import { dirname, join } from 'node:path'
|
|
5
5
|
import { fileURLToPath } from 'node:url'
|
|
6
|
+
import { InvalidSchemaLockError } from './errors.js'
|
|
6
7
|
|
|
7
8
|
export async function setupDB (log, config) {
|
|
8
9
|
const { db, sql, entities, dbschema } = await connect({ ...config, log })
|
|
@@ -32,3 +33,15 @@ export async function updateSchemaLock (logger, config) {
|
|
|
32
33
|
await conn.db.dispose()
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
|
|
37
|
+
export function validateSchemaLockFormat (schemaLock) {
|
|
38
|
+
const isBoolean = typeof schemaLock === 'boolean'
|
|
39
|
+
const isObject = typeof schemaLock === 'object'
|
|
40
|
+
|
|
41
|
+
if (!isBoolean && !isObject) {
|
|
42
|
+
throw new InvalidSchemaLockError()
|
|
43
|
+
}
|
|
44
|
+
if (isObject && typeof schemaLock.path !== 'string') {
|
|
45
|
+
throw new InvalidSchemaLockError()
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/db",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.39.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"neostandard": "^0.12.0",
|
|
31
31
|
"openapi-types": "^12.1.3",
|
|
32
32
|
"split2": "^4.2.0",
|
|
33
|
-
"
|
|
33
|
+
"tstyche": "^6.2.0",
|
|
34
34
|
"typescript": "^5.5.4",
|
|
35
35
|
"undici": "^7.0.0",
|
|
36
36
|
"vscode-json-languageservice": "^5.3.9",
|
|
@@ -66,17 +66,17 @@
|
|
|
66
66
|
"rfdc": "^1.3.1",
|
|
67
67
|
"rimraf": "^4.4.1",
|
|
68
68
|
"semgrator": "^0.3.0",
|
|
69
|
-
"@platformatic/db-authorization": "3.
|
|
70
|
-
"@platformatic/basic": "3.
|
|
71
|
-
"@platformatic/db-core": "3.
|
|
72
|
-
"@platformatic/
|
|
73
|
-
"@platformatic/
|
|
74
|
-
"@platformatic/
|
|
75
|
-
"@platformatic/sql-json-schema-mapper": "3.
|
|
76
|
-
"@platformatic/
|
|
77
|
-
"@platformatic/sql-
|
|
78
|
-
"@platformatic/telemetry": "3.
|
|
79
|
-
"@platformatic/sql-mapper": "3.
|
|
69
|
+
"@platformatic/db-authorization": "3.39.0",
|
|
70
|
+
"@platformatic/basic": "3.39.0",
|
|
71
|
+
"@platformatic/db-core": "3.39.0",
|
|
72
|
+
"@platformatic/sql-events": "3.39.0",
|
|
73
|
+
"@platformatic/foundation": "3.39.0",
|
|
74
|
+
"@platformatic/sql-graphql": "3.39.0",
|
|
75
|
+
"@platformatic/sql-json-schema-mapper": "3.39.0",
|
|
76
|
+
"@platformatic/service": "3.39.0",
|
|
77
|
+
"@platformatic/sql-openapi": "3.39.0",
|
|
78
|
+
"@platformatic/telemetry": "3.39.0",
|
|
79
|
+
"@platformatic/sql-mapper": "3.39.0"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/db/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/db/3.39.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Database Config",
|
|
5
5
|
"type": "object",
|
|
@@ -238,6 +238,26 @@
|
|
|
238
238
|
"customLevels": {
|
|
239
239
|
"type": "object",
|
|
240
240
|
"additionalProperties": true
|
|
241
|
+
},
|
|
242
|
+
"openTelemetryExporter": {
|
|
243
|
+
"type": "object",
|
|
244
|
+
"properties": {
|
|
245
|
+
"protocol": {
|
|
246
|
+
"type": "string",
|
|
247
|
+
"enum": [
|
|
248
|
+
"grpc",
|
|
249
|
+
"http"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
"url": {
|
|
253
|
+
"type": "string"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"required": [
|
|
257
|
+
"protocol",
|
|
258
|
+
"url"
|
|
259
|
+
],
|
|
260
|
+
"additionalProperties": false
|
|
241
261
|
}
|
|
242
262
|
},
|
|
243
263
|
"default": {},
|
|
@@ -1870,6 +1890,26 @@
|
|
|
1870
1890
|
"customLevels": {
|
|
1871
1891
|
"type": "object",
|
|
1872
1892
|
"additionalProperties": true
|
|
1893
|
+
},
|
|
1894
|
+
"openTelemetryExporter": {
|
|
1895
|
+
"type": "object",
|
|
1896
|
+
"properties": {
|
|
1897
|
+
"protocol": {
|
|
1898
|
+
"type": "string",
|
|
1899
|
+
"enum": [
|
|
1900
|
+
"grpc",
|
|
1901
|
+
"http"
|
|
1902
|
+
]
|
|
1903
|
+
},
|
|
1904
|
+
"url": {
|
|
1905
|
+
"type": "string"
|
|
1906
|
+
}
|
|
1907
|
+
},
|
|
1908
|
+
"required": [
|
|
1909
|
+
"protocol",
|
|
1910
|
+
"url"
|
|
1911
|
+
],
|
|
1912
|
+
"additionalProperties": false
|
|
1873
1913
|
}
|
|
1874
1914
|
},
|
|
1875
1915
|
"default": {},
|