@contember/migrations-client 2.0.0-alpha.9 → 2.0.0-beta.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/dist/development/src/JsLoader.cjs.map +1 -1
- package/dist/development/src/JsLoader.js.map +1 -1
- package/dist/development/src/JsonLoader.cjs.map +1 -1
- package/dist/development/src/JsonLoader.js.map +1 -1
- package/dist/development/src/MigrationCreator.cjs.map +1 -1
- package/dist/development/src/MigrationCreator.js.map +1 -1
- package/dist/development/src/MigrationExecuteHelper.cjs.map +1 -1
- package/dist/development/src/MigrationExecuteHelper.js.map +1 -1
- package/dist/development/src/MigrationFilesManager.cjs.map +1 -1
- package/dist/development/src/MigrationFilesManager.js.map +1 -1
- package/dist/development/src/MigrationParser.cjs.map +1 -1
- package/dist/development/src/MigrationParser.js.map +1 -1
- package/dist/development/src/MigrationsResolver.cjs.map +1 -1
- package/dist/development/src/MigrationsResolver.js.map +1 -1
- package/dist/development/src/SchemaVersionBuilder.cjs.map +1 -1
- package/dist/development/src/SchemaVersionBuilder.js.map +1 -1
- package/dist/development/src/SystemClient.cjs +18 -16
- package/dist/development/src/SystemClient.cjs.map +1 -1
- package/dist/development/src/SystemClient.js +17 -15
- package/dist/development/src/SystemClient.js.map +1 -1
- package/dist/development/src/migrations.cjs.map +1 -1
- package/dist/development/src/migrations.js.map +1 -1
- package/dist/production/src/JsLoader.cjs.map +1 -1
- package/dist/production/src/JsLoader.js.map +1 -1
- package/dist/production/src/JsonLoader.cjs.map +1 -1
- package/dist/production/src/JsonLoader.js.map +1 -1
- package/dist/production/src/MigrationCreator.cjs.map +1 -1
- package/dist/production/src/MigrationCreator.js.map +1 -1
- package/dist/production/src/MigrationExecuteHelper.cjs.map +1 -1
- package/dist/production/src/MigrationExecuteHelper.js.map +1 -1
- package/dist/production/src/MigrationFilesManager.cjs.map +1 -1
- package/dist/production/src/MigrationFilesManager.js.map +1 -1
- package/dist/production/src/MigrationParser.cjs.map +1 -1
- package/dist/production/src/MigrationParser.js.map +1 -1
- package/dist/production/src/MigrationsResolver.cjs.map +1 -1
- package/dist/production/src/MigrationsResolver.js.map +1 -1
- package/dist/production/src/SchemaVersionBuilder.cjs.map +1 -1
- package/dist/production/src/SchemaVersionBuilder.js.map +1 -1
- package/dist/production/src/SystemClient.cjs +18 -16
- package/dist/production/src/SystemClient.cjs.map +1 -1
- package/dist/production/src/SystemClient.js +17 -15
- package/dist/production/src/SystemClient.js.map +1 -1
- package/dist/production/src/migrations.cjs.map +1 -1
- package/dist/production/src/migrations.js.map +1 -1
- package/dist/types/SystemClient.d.ts +2 -2
- package/dist/types/SystemClient.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/SystemClient.ts +19 -17
- package/src/tsconfig.json +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/migrations-client",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"test": "echo 'No tests'"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/engine-common": "2.0.0-
|
|
30
|
-
"@contember/
|
|
31
|
-
"@contember/schema
|
|
32
|
-
"@contember/schema-
|
|
33
|
-
"
|
|
29
|
+
"@contember/engine-common": "2.0.0-beta.1",
|
|
30
|
+
"@contember/graphql-client": "2.0.0-beta.1",
|
|
31
|
+
"@contember/schema": "2.0.0-beta.1",
|
|
32
|
+
"@contember/schema-migrations": "2.0.0-beta.1",
|
|
33
|
+
"@contember/schema-utils": "2.0.0-beta.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^20.
|
|
36
|
+
"@types/node": "^20.16.11"
|
|
37
37
|
},
|
|
38
38
|
"type": "module"
|
|
39
|
-
}
|
|
39
|
+
}
|
package/src/SystemClient.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQlClient } from '@contember/graphql-client'
|
|
2
2
|
import { ExecutedMigration, ExecutedMigrationInfo } from './migrations'
|
|
3
3
|
|
|
4
4
|
export type MigrateError = {
|
|
@@ -21,14 +21,10 @@ export type MigrateResponse = {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class SystemClient {
|
|
24
|
-
constructor(private readonly apiClient:
|
|
24
|
+
constructor(private readonly apiClient: GraphQlClient) {}
|
|
25
25
|
|
|
26
26
|
public static create(baseUrl: string, projectName: string, apiToken: string): SystemClient {
|
|
27
|
-
const graphqlClient = new
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${apiToken}`,
|
|
30
|
-
},
|
|
31
|
-
})
|
|
27
|
+
const graphqlClient = new GraphQlClient({ url: createSystemUrl(baseUrl, projectName), apiToken })
|
|
32
28
|
return new SystemClient(graphqlClient)
|
|
33
29
|
}
|
|
34
30
|
|
|
@@ -46,10 +42,12 @@ mutation($migrations: [Migration!]!) {
|
|
|
46
42
|
}
|
|
47
43
|
`
|
|
48
44
|
const result = (
|
|
49
|
-
await this.apiClient.
|
|
45
|
+
await this.apiClient.execute<{
|
|
50
46
|
migrate: { ok: boolean; errors: { code: MigrateErrorCode; migration: string; message: string }[] }
|
|
51
47
|
}>(query, {
|
|
52
|
-
|
|
48
|
+
variables: {
|
|
49
|
+
migrations,
|
|
50
|
+
},
|
|
53
51
|
})
|
|
54
52
|
).migrate
|
|
55
53
|
if (!result.ok) {
|
|
@@ -69,10 +67,12 @@ mutation($version: String!) {
|
|
|
69
67
|
}
|
|
70
68
|
`
|
|
71
69
|
const result = (
|
|
72
|
-
await this.apiClient.
|
|
70
|
+
await this.apiClient.execute<{
|
|
73
71
|
migrationDelete: { ok: boolean; error?: { developerMessage: string } }
|
|
74
72
|
}>(query, {
|
|
75
|
-
|
|
73
|
+
variables: {
|
|
74
|
+
version,
|
|
75
|
+
},
|
|
76
76
|
})
|
|
77
77
|
).migrationDelete
|
|
78
78
|
if (!result.ok) {
|
|
@@ -92,11 +92,13 @@ mutation($version: String!, $modification: MigrationModification!) {
|
|
|
92
92
|
}
|
|
93
93
|
`
|
|
94
94
|
const result = (
|
|
95
|
-
await this.apiClient.
|
|
95
|
+
await this.apiClient.execute<{
|
|
96
96
|
migrationModify: { ok: boolean; error?: { developerMessage: string } }
|
|
97
97
|
}>(query, {
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
variables: {
|
|
99
|
+
version,
|
|
100
|
+
modification,
|
|
101
|
+
},
|
|
100
102
|
})
|
|
101
103
|
).migrationModify
|
|
102
104
|
if (!result.ok) {
|
|
@@ -115,7 +117,7 @@ mutation($version: String!, $modification: MigrationModification!) {
|
|
|
115
117
|
}
|
|
116
118
|
}`
|
|
117
119
|
return (
|
|
118
|
-
await this.apiClient.
|
|
120
|
+
await this.apiClient.execute<{
|
|
119
121
|
executedMigrations: ExecutedMigrationInfo[]
|
|
120
122
|
}>(query, {})
|
|
121
123
|
).executedMigrations.map(it => ({ ...it, executedAt: new Date(it.executedAt) }))
|
|
@@ -134,9 +136,9 @@ mutation($version: String!, $modification: MigrationModification!) {
|
|
|
134
136
|
}`
|
|
135
137
|
return (
|
|
136
138
|
(
|
|
137
|
-
await this.apiClient.
|
|
139
|
+
await this.apiClient.execute<{
|
|
138
140
|
executedMigrations: ExecutedMigration[]
|
|
139
|
-
}>(query, { version })
|
|
141
|
+
}>(query, { variables: { version } })
|
|
140
142
|
).executedMigrations.map(it => ({ ...it, executedAt: new Date(it.executedAt) }))[0] || null
|
|
141
143
|
)
|
|
142
144
|
}
|