@platformatic/db 3.38.0 → 3.38.1
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/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 +1 -1
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.38.
|
|
3
|
+
"version": "3.38.1",
|
|
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/
|
|
70
|
-
"@platformatic/
|
|
71
|
-
"@platformatic/db-core": "3.38.
|
|
72
|
-
"@platformatic/
|
|
73
|
-
"@platformatic/
|
|
74
|
-
"@platformatic/
|
|
75
|
-
"@platformatic/sql-
|
|
76
|
-
"@platformatic/sql-
|
|
77
|
-
"@platformatic/sql-
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/
|
|
69
|
+
"@platformatic/basic": "3.38.1",
|
|
70
|
+
"@platformatic/db-authorization": "3.38.1",
|
|
71
|
+
"@platformatic/db-core": "3.38.1",
|
|
72
|
+
"@platformatic/foundation": "3.38.1",
|
|
73
|
+
"@platformatic/service": "3.38.1",
|
|
74
|
+
"@platformatic/sql-events": "3.38.1",
|
|
75
|
+
"@platformatic/sql-graphql": "3.38.1",
|
|
76
|
+
"@platformatic/sql-json-schema-mapper": "3.38.1",
|
|
77
|
+
"@platformatic/sql-mapper": "3.38.1",
|
|
78
|
+
"@platformatic/sql-openapi": "3.38.1",
|
|
79
|
+
"@platformatic/telemetry": "3.38.1"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED