@contember/cli 2.1.0-alpha.2 → 2.1.0-alpha.21
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/commands/actions/ActionsGetEventCommand.cjs +31 -0
- package/dist/development/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsGetEventCommand.js +31 -0
- package/dist/development/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
- package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.js +29 -0
- package/dist/development/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.js +32 -0
- package/dist/development/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs +40 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js +40 -0
- package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.js +32 -0
- package/dist/development/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
- package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.js +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/ExportCommand.cjs +7 -2
- package/dist/development/src/commands/transfer/ExportCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/ExportCommand.js +8 -3
- package/dist/development/src/commands/transfer/ExportCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/ImportCommand.cjs +7 -4
- package/dist/development/src/commands/transfer/ImportCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/ImportCommand.js +5 -2
- package/dist/development/src/commands/transfer/ImportCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/TransferCommand.cjs +4 -5
- package/dist/development/src/commands/transfer/TransferCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/TransferCommand.js +4 -5
- package/dist/development/src/commands/transfer/TransferCommand.js.map +1 -1
- package/dist/development/src/dic.cjs +14 -2
- package/dist/development/src/dic.cjs.map +1 -1
- package/dist/development/src/dic.js +14 -2
- package/dist/development/src/dic.js.map +1 -1
- package/dist/development/src/lib/VersionChecker.cjs +7 -9
- package/dist/development/src/lib/VersionChecker.cjs.map +1 -1
- package/dist/development/src/lib/VersionChecker.js +7 -9
- package/dist/development/src/lib/VersionChecker.js.map +1 -1
- package/dist/development/src/lib/actions/ActionsClient.cjs +91 -0
- package/dist/development/src/lib/actions/ActionsClient.cjs.map +1 -0
- package/dist/development/src/lib/actions/ActionsClient.js +91 -0
- package/dist/development/src/lib/actions/ActionsClient.js.map +1 -0
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs +2 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.js +2 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationPrinter.cjs +7 -2
- package/dist/development/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationPrinter.js +7 -2
- package/dist/development/src/lib/migrations/MigrationPrinter.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.js +3 -3
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
- package/dist/development/src/lib/stream.cjs +0 -7
- package/dist/development/src/lib/stream.cjs.map +1 -1
- package/dist/development/src/lib/stream.js +1 -8
- package/dist/development/src/lib/stream.js.map +1 -1
- package/dist/development/src/lib/transfer/DataTransferClient.cjs +24 -34
- package/dist/development/src/lib/transfer/DataTransferClient.cjs.map +1 -1
- package/dist/development/src/lib/transfer/DataTransferClient.js +26 -36
- package/dist/development/src/lib/transfer/DataTransferClient.js.map +1 -1
- package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
- package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsGetEventCommand.js +31 -0
- package/dist/production/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
- package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.js +29 -0
- package/dist/production/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.js +32 -0
- package/dist/production/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs +40 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js +40 -0
- package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.js +32 -0
- package/dist/production/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
- package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.js +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/ExportCommand.cjs +7 -2
- package/dist/production/src/commands/transfer/ExportCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/ExportCommand.js +8 -3
- package/dist/production/src/commands/transfer/ExportCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/ImportCommand.cjs +7 -4
- package/dist/production/src/commands/transfer/ImportCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/ImportCommand.js +5 -2
- package/dist/production/src/commands/transfer/ImportCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/TransferCommand.cjs +4 -5
- package/dist/production/src/commands/transfer/TransferCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/TransferCommand.js +4 -5
- package/dist/production/src/commands/transfer/TransferCommand.js.map +1 -1
- package/dist/production/src/dic.cjs +14 -2
- package/dist/production/src/dic.cjs.map +1 -1
- package/dist/production/src/dic.js +14 -2
- package/dist/production/src/dic.js.map +1 -1
- package/dist/production/src/lib/VersionChecker.cjs +7 -9
- package/dist/production/src/lib/VersionChecker.cjs.map +1 -1
- package/dist/production/src/lib/VersionChecker.js +7 -9
- package/dist/production/src/lib/VersionChecker.js.map +1 -1
- package/dist/production/src/lib/actions/ActionsClient.cjs +91 -0
- package/dist/production/src/lib/actions/ActionsClient.cjs.map +1 -0
- package/dist/production/src/lib/actions/ActionsClient.js +91 -0
- package/dist/production/src/lib/actions/ActionsClient.js.map +1 -0
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs +2 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.js +2 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationPrinter.cjs +7 -2
- package/dist/production/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationPrinter.js +7 -2
- package/dist/production/src/lib/migrations/MigrationPrinter.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.js +3 -3
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
- package/dist/production/src/lib/stream.cjs +0 -7
- package/dist/production/src/lib/stream.cjs.map +1 -1
- package/dist/production/src/lib/stream.js +1 -8
- package/dist/production/src/lib/stream.js.map +1 -1
- package/dist/production/src/lib/transfer/DataTransferClient.cjs +24 -34
- package/dist/production/src/lib/transfer/DataTransferClient.cjs.map +1 -1
- package/dist/production/src/lib/transfer/DataTransferClient.js +26 -36
- package/dist/production/src/lib/transfer/DataTransferClient.js.map +1 -1
- package/dist/types/commands/actions/ActionsGetEventCommand.d.ts +16 -0
- package/dist/types/commands/actions/ActionsGetEventCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts +15 -0
- package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts +14 -0
- package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts +16 -0
- package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts +19 -0
- package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts.map +1 -0
- package/dist/types/commands/actions/ActionsStopEventCommand.d.ts +16 -0
- package/dist/types/commands/actions/ActionsStopEventCommand.d.ts.map +1 -0
- package/dist/types/commands/transfer/ExportCommand.d.ts.map +1 -1
- package/dist/types/commands/transfer/ImportCommand.d.ts.map +1 -1
- package/dist/types/commands/transfer/TransferCommand.d.ts.map +1 -1
- package/dist/types/dic.d.ts +18 -0
- package/dist/types/dic.d.ts.map +1 -1
- package/dist/types/lib/VersionChecker.d.ts.map +1 -1
- package/dist/types/lib/actions/ActionsClient.d.ts +33 -0
- package/dist/types/lib/actions/ActionsClient.d.ts.map +1 -0
- package/dist/types/lib/migrations/MigrationExecutionFacade.d.ts.map +1 -1
- package/dist/types/lib/migrations/MigrationPrinter.d.ts +1 -1
- package/dist/types/lib/migrations/MigrationPrinter.d.ts.map +1 -1
- package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts +3 -1
- package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts.map +1 -1
- package/dist/types/lib/transfer/DataTransferClient.d.ts +2 -4
- package/dist/types/lib/transfer/DataTransferClient.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/commands/actions/ActionsGetEventCommand.ts +42 -0
- package/src/commands/actions/ActionsListFailedEventsCommand.ts +70 -0
- package/src/commands/actions/ActionsListVariablesCommand.ts +37 -0
- package/src/commands/actions/ActionsRetryEventCommand.ts +42 -0
- package/src/commands/actions/ActionsSetVariablesCommand.ts +56 -0
- package/src/commands/actions/ActionsStopEventCommand.ts +42 -0
- package/src/commands/migrations/MigrationStatusCommand.ts +1 -1
- package/src/commands/transfer/ExportCommand.ts +9 -4
- package/src/commands/transfer/ImportCommand.ts +6 -1
- package/src/commands/transfer/TransferCommand.ts +4 -3
- package/src/dic.ts +27 -2
- package/src/lib/VersionChecker.ts +13 -9
- package/src/lib/actions/ActionsClient.ts +112 -0
- package/src/lib/migrations/MigrationExecutionFacade.ts +1 -0
- package/src/lib/migrations/MigrationPrinter.ts +7 -2
- package/src/lib/migrations/MigrationsStatusFacade.ts +4 -3
- package/src/lib/transfer/DataTransferClient.ts +25 -43
- package/dist/development/src/lib/migrations/migrations.cjs +0 -43
- package/dist/development/src/lib/migrations/migrations.cjs.map +0 -1
- package/dist/development/src/lib/migrations/migrations.js +0 -43
- package/dist/development/src/lib/migrations/migrations.js.map +0 -1
- package/dist/production/src/lib/migrations/migrations.cjs +0 -43
- package/dist/production/src/lib/migrations/migrations.cjs.map +0 -1
- package/dist/production/src/lib/migrations/migrations.js +0 -43
- package/dist/production/src/lib/migrations/migrations.js.map +0 -1
- package/dist/types/lib/migrations/migrations.d.ts +0 -3
- package/dist/types/lib/migrations/migrations.d.ts.map +0 -1
- package/src/lib/migrations/migrations.ts +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/cli",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.21",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contember": "./dist/production/run.js"
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"tailwindcss": "^3.4.14"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@contember/cli-common": "2.1.0-alpha.
|
|
24
|
-
"@contember/config-loader": "2.1.0-alpha.
|
|
25
|
-
"@contember/database": "2.1.0-alpha.
|
|
26
|
-
"@contember/dic": "2.1.0-alpha.
|
|
27
|
-
"@contember/engine-common": "2.1.0-alpha.
|
|
28
|
-
"@contember/engine-content-api": "2.1.0-alpha.
|
|
29
|
-
"@contember/graphql-client": "2.1.0-alpha.
|
|
30
|
-
"@contember/migrations-client": "2.1.0-alpha.
|
|
31
|
-
"@contember/schema": "2.1.0-alpha.
|
|
32
|
-
"@contember/schema-migrations": "2.1.0-alpha.
|
|
33
|
-
"@contember/schema-utils": "2.1.0-alpha.
|
|
34
|
-
"@contember/typesafe": "2.1.0-alpha.
|
|
23
|
+
"@contember/cli-common": "2.1.0-alpha.21",
|
|
24
|
+
"@contember/config-loader": "2.1.0-alpha.21",
|
|
25
|
+
"@contember/database": "2.1.0-alpha.21",
|
|
26
|
+
"@contember/dic": "2.1.0-alpha.21",
|
|
27
|
+
"@contember/engine-common": "2.1.0-alpha.21",
|
|
28
|
+
"@contember/engine-content-api": "2.1.0-alpha.21",
|
|
29
|
+
"@contember/graphql-client": "2.1.0-alpha.21",
|
|
30
|
+
"@contember/migrations-client": "2.1.0-alpha.21",
|
|
31
|
+
"@contember/schema": "2.1.0-alpha.21",
|
|
32
|
+
"@contember/schema-migrations": "2.1.0-alpha.21",
|
|
33
|
+
"@contember/schema-utils": "2.1.0-alpha.21",
|
|
34
|
+
"@contember/typesafe": "2.1.0-alpha.21",
|
|
35
35
|
"@graphql-tools/schema": "^10.0.7",
|
|
36
36
|
"chalk": "^5.3.0",
|
|
37
37
|
"chalk-table": "^1.0.2",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
+
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
3
|
+
import { ActionsClient } from '../../lib/actions/ActionsClient'
|
|
4
|
+
|
|
5
|
+
type Args = {
|
|
6
|
+
eventId: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Options = {
|
|
10
|
+
project?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ActionsGetEventCommand extends Command<Args, Options> {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly remoteProjectResolver: RemoteProjectResolver,
|
|
16
|
+
) {
|
|
17
|
+
super()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected configure(configuration: CommandConfiguration<Args, Options>): void {
|
|
21
|
+
configuration.description('Get single event')
|
|
22
|
+
configuration.argument('eventId')
|
|
23
|
+
configuration.option('project').valueRequired()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async execute(input: Input<Args, Options>): Promise<void | number> {
|
|
27
|
+
const dsn = input.getOption('project')
|
|
28
|
+
const project = await this.remoteProjectResolver.resolve(dsn)
|
|
29
|
+
if (!project) {
|
|
30
|
+
throw `Project not defined`
|
|
31
|
+
}
|
|
32
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token)
|
|
33
|
+
|
|
34
|
+
const result = await api.getEvent(input.getArgument('eventId'))
|
|
35
|
+
if (!result) {
|
|
36
|
+
console.log('Event not found')
|
|
37
|
+
return 1
|
|
38
|
+
}
|
|
39
|
+
console.log(JSON.stringify(result, null, 2))
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
+
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
3
|
+
import { ActionsClient } from '../../lib/actions/ActionsClient'
|
|
4
|
+
import chalkTable from 'chalk-table'
|
|
5
|
+
type Args = {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type Options = {
|
|
9
|
+
project?: string
|
|
10
|
+
json?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ActionsListFailedEventsCommand extends Command<Args, Options> {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly remoteProjectResolver: RemoteProjectResolver,
|
|
16
|
+
) {
|
|
17
|
+
super()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected configure(configuration: CommandConfiguration<Args, Options>): void {
|
|
21
|
+
configuration.description('Show failed events')
|
|
22
|
+
configuration.option('project').valueRequired()
|
|
23
|
+
configuration.option('json').valueNone()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async execute(input: Input<Args, Options>): Promise<void | number> {
|
|
27
|
+
const dsn = input.getOption('project')
|
|
28
|
+
const project = await this.remoteProjectResolver.resolve(dsn)
|
|
29
|
+
if (!project) {
|
|
30
|
+
throw `Project not defined`
|
|
31
|
+
}
|
|
32
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token)
|
|
33
|
+
|
|
34
|
+
const result = await api.listFailedEvents()
|
|
35
|
+
if (input.getOption('json')) {
|
|
36
|
+
console.log(JSON.stringify(result, null, 2))
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
if (result.length === 0) {
|
|
40
|
+
console.log('No failed events')
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
const table = chalkTable(
|
|
44
|
+
{
|
|
45
|
+
columns: [
|
|
46
|
+
{ field: 'id', name: 'ID' },
|
|
47
|
+
{ field: 'createdAt', name: 'Created at' },
|
|
48
|
+
{ field: 'lastStateChange', name: 'Last state change' },
|
|
49
|
+
{ field: 'visibleAt', name: 'Visible at' },
|
|
50
|
+
{ field: 'numRetries', name: 'Retries' },
|
|
51
|
+
{ field: 'state', name: 'State' },
|
|
52
|
+
{ field: 'target', name: 'Target' },
|
|
53
|
+
{ field: 'log', name: 'Log' },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
result.map(it => ({
|
|
57
|
+
id: it.id,
|
|
58
|
+
createdAt: it.createdAt,
|
|
59
|
+
lastStateChange: it.lastStateChange,
|
|
60
|
+
visibleAt: it.visibleAt || '',
|
|
61
|
+
numRetries: it.numRetries.toString(),
|
|
62
|
+
state: it.state,
|
|
63
|
+
target: it.target,
|
|
64
|
+
log: JSON.stringify(it.log.length > 0 ? it.log[it.log.length - 1] : {}),
|
|
65
|
+
})),
|
|
66
|
+
)
|
|
67
|
+
console.log(table)
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
+
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
3
|
+
import { ActionsClient } from '../../lib/actions/ActionsClient'
|
|
4
|
+
import chalkTable from 'chalk-table'
|
|
5
|
+
|
|
6
|
+
type Args = {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Options = {
|
|
10
|
+
project?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ActionsListVariablesCommand extends Command<Args, Options> {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly remoteProjectResolver: RemoteProjectResolver,
|
|
16
|
+
) {
|
|
17
|
+
super()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected configure(configuration: CommandConfiguration<Args, Options>): void {
|
|
21
|
+
configuration.description('Show action variables')
|
|
22
|
+
configuration.option('project').valueRequired()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected async execute(input: Input<Args, Options>): Promise<void | number> {
|
|
26
|
+
const dsn = input.getOption('project')
|
|
27
|
+
const project = await this.remoteProjectResolver.resolve(dsn)
|
|
28
|
+
if (!project) {
|
|
29
|
+
throw `Project not defined`
|
|
30
|
+
}
|
|
31
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token)
|
|
32
|
+
const result = await api.listVariables()
|
|
33
|
+
console.log(chalkTable({
|
|
34
|
+
columns: ['name', 'value'],
|
|
35
|
+
}, result))
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
+
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
3
|
+
import { ActionsClient } from '../../lib/actions/ActionsClient'
|
|
4
|
+
import chalkTable from 'chalk-table'
|
|
5
|
+
type Args = {
|
|
6
|
+
eventId: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Options = {
|
|
10
|
+
project?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ActionsRetryEventCommand extends Command<Args, Options> {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly remoteProjectResolver: RemoteProjectResolver,
|
|
16
|
+
) {
|
|
17
|
+
super()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected configure(configuration: CommandConfiguration<Args, Options>): void {
|
|
21
|
+
configuration.description('Retry given event')
|
|
22
|
+
configuration.argument('eventId')
|
|
23
|
+
configuration.option('project').valueRequired()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async execute(input: Input<Args, Options>): Promise<void | number> {
|
|
27
|
+
const dsn = input.getOption('project')
|
|
28
|
+
const project = await this.remoteProjectResolver.resolve(dsn)
|
|
29
|
+
if (!project) {
|
|
30
|
+
throw `Project not defined`
|
|
31
|
+
}
|
|
32
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token)
|
|
33
|
+
|
|
34
|
+
const result = await api.retryEvent(input.getArgument('eventId'))
|
|
35
|
+
if (result) {
|
|
36
|
+
console.log('Event requeued for processing')
|
|
37
|
+
} else {
|
|
38
|
+
console.log('Failed to requeue event. Check the event status')
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
+
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
3
|
+
import { ActionsClient } from '../../lib/actions/ActionsClient'
|
|
4
|
+
|
|
5
|
+
type Args = {
|
|
6
|
+
variables: string[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Options = {
|
|
10
|
+
project?: string
|
|
11
|
+
merge?: boolean
|
|
12
|
+
set?: boolean
|
|
13
|
+
['append-only-missing']?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ActionsSetVariablesCommand extends Command<Args, Options> {
|
|
17
|
+
constructor(
|
|
18
|
+
private readonly remoteProjectResolver: RemoteProjectResolver,
|
|
19
|
+
) {
|
|
20
|
+
super()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected configure(configuration: CommandConfiguration<Args, Options>): void {
|
|
24
|
+
configuration.description('Set action variables')
|
|
25
|
+
configuration.option('project').valueRequired()
|
|
26
|
+
configuration.option('merge').valueNone().description('merges with new values (default behaviour)')
|
|
27
|
+
configuration.option('set').valueNone().description('replaces all variables')
|
|
28
|
+
configuration.option('append-only-missing').valueNone().description('appends values if not already exist')
|
|
29
|
+
configuration.argument('variables').variadic().description('variables to set, in the form of name=value')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected async execute(input: Input<Args, Options>): Promise<void | number> {
|
|
33
|
+
const dsn = input.getOption('project')
|
|
34
|
+
const project = await this.remoteProjectResolver.resolve(dsn)
|
|
35
|
+
if (!project) {
|
|
36
|
+
throw `Project not defined`
|
|
37
|
+
}
|
|
38
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token)
|
|
39
|
+
const mode = input.getOption('merge')
|
|
40
|
+
? 'MERGE' as const : input.getOption('set')
|
|
41
|
+
? 'SET' as const : input.getOption('append-only-missing')
|
|
42
|
+
? 'APPEND_ONLY_MISSING' as const : 'MERGE' as const
|
|
43
|
+
|
|
44
|
+
const variables = input.getArgument('variables').flatMap(it => it.split('\n')).filter(it => it.trim().length > 0)
|
|
45
|
+
const result = await api.setVariables(variables.map(it => {
|
|
46
|
+
const [name, value] = it.split('=')
|
|
47
|
+
return { name, value }
|
|
48
|
+
}), mode)
|
|
49
|
+
if (result) {
|
|
50
|
+
console.log('Success')
|
|
51
|
+
} else {
|
|
52
|
+
console.error('Failed')
|
|
53
|
+
return 1
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
+
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
3
|
+
import { ActionsClient } from '../../lib/actions/ActionsClient'
|
|
4
|
+
import chalkTable from 'chalk-table'
|
|
5
|
+
type Args = {
|
|
6
|
+
eventId: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Options = {
|
|
10
|
+
project?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ActionsStopEventCommand extends Command<Args, Options> {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly remoteProjectResolver: RemoteProjectResolver,
|
|
16
|
+
) {
|
|
17
|
+
super()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected configure(configuration: CommandConfiguration<Args, Options>): void {
|
|
21
|
+
configuration.description('Stop given event')
|
|
22
|
+
configuration.argument('eventId')
|
|
23
|
+
configuration.option('project').valueRequired()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async execute(input: Input<Args, Options>): Promise<void | number> {
|
|
27
|
+
const dsn = input.getOption('project')
|
|
28
|
+
const project = await this.remoteProjectResolver.resolve(dsn)
|
|
29
|
+
if (!project) {
|
|
30
|
+
throw `Project not defined`
|
|
31
|
+
}
|
|
32
|
+
const api = ActionsClient.create(project.endpoint, project.name, project.token)
|
|
33
|
+
|
|
34
|
+
const result = await api.stopEvent(input.getArgument('eventId'))
|
|
35
|
+
if (result) {
|
|
36
|
+
console.log('Event stopped')
|
|
37
|
+
} else {
|
|
38
|
+
console.log('Failed to stop event. Check the event id.')
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -78,7 +78,7 @@ export class MigrationStatusCommand extends Command<Args, Options> {
|
|
|
78
78
|
])
|
|
79
79
|
: status.allMigrations
|
|
80
80
|
|
|
81
|
-
this.migrationPrinter.printStatusTable(filtered)
|
|
81
|
+
console.log(this.migrationPrinter.printStatusTable(filtered))
|
|
82
82
|
|
|
83
83
|
const hasErrors = status.errorMigrations.length > 0
|
|
84
84
|
|
|
@@ -6,6 +6,7 @@ import { printProgressLine } from '../../lib/transfer/stdio'
|
|
|
6
6
|
import { createGunzip, createGzip } from 'node:zlib'
|
|
7
7
|
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
8
8
|
import { DataTransferClient } from '../../lib/transfer/DataTransferClient'
|
|
9
|
+
import { Readable } from 'node:stream'
|
|
9
10
|
|
|
10
11
|
type Args = {
|
|
11
12
|
source?: string
|
|
@@ -64,12 +65,16 @@ export class ExportCommand extends Command<Args, Options> {
|
|
|
64
65
|
includeSystem,
|
|
65
66
|
gzip: gzipTransfer,
|
|
66
67
|
})
|
|
68
|
+
if (!response.body) {
|
|
69
|
+
throw new Error('Response does not contain a readable stream.')
|
|
70
|
+
}
|
|
67
71
|
|
|
68
72
|
let transferred = 0
|
|
69
73
|
let start = Date.now()
|
|
70
74
|
let lastMbReported = 0
|
|
71
75
|
console.log('')
|
|
72
|
-
response.
|
|
76
|
+
const stream = Readable.fromWeb(response.body as any)
|
|
77
|
+
stream.on('data', chunk => {
|
|
73
78
|
transferred += chunk.length
|
|
74
79
|
const currentMb = Math.floor(transferred / 1024 / 1024)
|
|
75
80
|
if (currentMb > lastMbReported) {
|
|
@@ -82,9 +87,9 @@ export class ExportCommand extends Command<Args, Options> {
|
|
|
82
87
|
const fileName = input.getOption('output') ?? `${project.name}.jsonl${gzipOutput ? '.gz' : ''}`
|
|
83
88
|
const fileStream = createWriteStream(fileName)
|
|
84
89
|
|
|
85
|
-
const responseStream = gzipOutput
|
|
86
|
-
?
|
|
87
|
-
:
|
|
90
|
+
const responseStream = !gzipOutput
|
|
91
|
+
? stream
|
|
92
|
+
: stream.pipe(createGzip())
|
|
88
93
|
|
|
89
94
|
await pipeline(responseStream, fileStream)
|
|
90
95
|
|
|
@@ -52,6 +52,10 @@ export class ImportCommand extends Command<Args, Options> {
|
|
|
52
52
|
const file = input.getArgument('file')
|
|
53
53
|
const baseInputStream = createReadStream(file)
|
|
54
54
|
const stream = (file.endsWith('.gz') ? baseInputStream.pipe(createGunzip()) : baseInputStream)
|
|
55
|
+
stream.on('error', (err: any) => {
|
|
56
|
+
console.error('Error in import stream:', err)
|
|
57
|
+
})
|
|
58
|
+
|
|
55
59
|
const gzipTransfer = !input.getOption('no-gzip-transfer')
|
|
56
60
|
const response = await this.dataTransferClient.dataImport({
|
|
57
61
|
stream: stream,
|
|
@@ -60,12 +64,13 @@ export class ImportCommand extends Command<Args, Options> {
|
|
|
60
64
|
gzip: gzipTransfer,
|
|
61
65
|
})
|
|
62
66
|
console.log('')
|
|
63
|
-
const responseData =
|
|
67
|
+
const responseData = await response.json()
|
|
64
68
|
if (responseData.ok) {
|
|
65
69
|
console.log('Import done.')
|
|
66
70
|
} else {
|
|
67
71
|
console.error('Import failed:')
|
|
68
72
|
console.log(responseData)
|
|
73
|
+
return 1
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
}
|
|
@@ -6,6 +6,7 @@ import { readStream } from '../../lib/stream'
|
|
|
6
6
|
import { createGunzip } from 'node:zlib'
|
|
7
7
|
import { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'
|
|
8
8
|
import { DataTransferClient } from '../../lib/transfer/DataTransferClient'
|
|
9
|
+
import { Duplex, Readable } from 'node:stream'
|
|
9
10
|
|
|
10
11
|
type Args = {
|
|
11
12
|
source: string
|
|
@@ -73,16 +74,16 @@ export class TransferCommand extends Command<Args, Options> {
|
|
|
73
74
|
excludeTables: input.getOption('exclude-table') ?? [],
|
|
74
75
|
gzip: gzipTransfer,
|
|
75
76
|
}))
|
|
76
|
-
const
|
|
77
|
+
const stream = Readable.fromWeb(exportResponse.body! as any)
|
|
77
78
|
const importResponse = await this.dataTransferClient.dataImport({
|
|
78
|
-
stream:
|
|
79
|
+
stream: stream,
|
|
79
80
|
project: targetProject,
|
|
80
81
|
printProgress: printProgressLine,
|
|
81
82
|
gzip: gzipTransfer,
|
|
82
83
|
})
|
|
83
84
|
console.log('')
|
|
84
85
|
|
|
85
|
-
const responseData =
|
|
86
|
+
const responseData = await importResponse.json()
|
|
86
87
|
if (responseData.ok) {
|
|
87
88
|
console.log('Transfer done.')
|
|
88
89
|
} else {
|
package/src/dic.ts
CHANGED
|
@@ -66,6 +66,12 @@ import { RemoteProjectProvider } from './lib/project/RemoteProjectProvider'
|
|
|
66
66
|
import { SystemClientProvider } from './lib/SystemClientProvider'
|
|
67
67
|
import { TenantClientProvider } from './lib/TenantClientProvider'
|
|
68
68
|
import { Workspace } from './lib/workspace/Workspace'
|
|
69
|
+
import { ActionsListVariablesCommand } from './commands/actions/ActionsListVariablesCommand'
|
|
70
|
+
import { ActionsSetVariablesCommand } from './commands/actions/ActionsSetVariablesCommand'
|
|
71
|
+
import { ActionsListFailedEventsCommand } from './commands/actions/ActionsListFailedEventsCommand'
|
|
72
|
+
import { ActionsRetryEventCommand } from './commands/actions/ActionsRetryEventCommand'
|
|
73
|
+
import { ActionsGetEventCommand } from './commands/actions/ActionsGetEventCommand'
|
|
74
|
+
import { ActionsStopEventCommand } from './commands/actions/ActionsStopEventCommand'
|
|
69
75
|
|
|
70
76
|
const jsSample = `
|
|
71
77
|
export const query = \`\`
|
|
@@ -169,8 +175,8 @@ export const createContainer = ({ env, version, runtime, workspace }: {
|
|
|
169
175
|
new MigrationExecutor())
|
|
170
176
|
.addService('migrationsStatusResolver', () =>
|
|
171
177
|
new MigrationsStatusResolver())
|
|
172
|
-
.addService('migrationsStatusFacade', ({ systemClientProvider, migrationsResolver, migrationsStatusResolver }) =>
|
|
173
|
-
new MigrationsStatusFacade(systemClientProvider, migrationsResolver, migrationsStatusResolver))
|
|
178
|
+
.addService('migrationsStatusFacade', ({ systemClientProvider, migrationsResolver, migrationsStatusResolver, migrationPrinter }) =>
|
|
179
|
+
new MigrationsStatusFacade(systemClientProvider, migrationsResolver, migrationsStatusResolver, migrationPrinter))
|
|
174
180
|
.addService('migrationExecutionFacade', ({ systemClientProvider, tenantClientProvider, remoteProjectProvider, schemaVersionBuilder, migrationPrinter, migrationsExecutor, migrationsStatusFacade }) =>
|
|
175
181
|
new MigrationExecutionFacade(systemClientProvider, tenantClientProvider, remoteProjectProvider, schemaVersionBuilder, migrationPrinter, migrationsExecutor, migrationsStatusFacade))
|
|
176
182
|
.addService('migrationsValidator', ({ migrationDescriber, schemaMigrator }) =>
|
|
@@ -218,6 +224,19 @@ export const createContainer = ({ env, version, runtime, workspace }: {
|
|
|
218
224
|
new TransferCommand(remoteProjectResolver, dataTransferClient))
|
|
219
225
|
.addService('workspaceUpdateCommand', ({ packageWorkspaceResolver, dockerComposeManager }) =>
|
|
220
226
|
new WorkspaceUpdateApiCommand(packageWorkspaceResolver, dockerComposeManager))
|
|
227
|
+
.addService('actionsListVariables', ({ remoteProjectResolver }) =>
|
|
228
|
+
new ActionsListVariablesCommand(remoteProjectResolver))
|
|
229
|
+
.addService('actionsSetVariables', ({ remoteProjectResolver }) =>
|
|
230
|
+
new ActionsSetVariablesCommand(remoteProjectResolver))
|
|
231
|
+
.addService('actionsListFailedEvents', ({ remoteProjectResolver }) =>
|
|
232
|
+
new ActionsListFailedEventsCommand(remoteProjectResolver))
|
|
233
|
+
.addService('actionsRetryEvent', ({ remoteProjectResolver }) =>
|
|
234
|
+
new ActionsRetryEventCommand(remoteProjectResolver))
|
|
235
|
+
.addService('actionsGetEvent', ({ remoteProjectResolver }) =>
|
|
236
|
+
new ActionsGetEventCommand(remoteProjectResolver))
|
|
237
|
+
.addService('actionsStopEvent', ({ remoteProjectResolver }) =>
|
|
238
|
+
new ActionsStopEventCommand(remoteProjectResolver))
|
|
239
|
+
|
|
221
240
|
.addService('commandList', dic => {
|
|
222
241
|
const commands: CommandFactoryList = {
|
|
223
242
|
['deploy']: () => dic.deployCommand,
|
|
@@ -236,6 +255,12 @@ export const createContainer = ({ env, version, runtime, workspace }: {
|
|
|
236
255
|
['project:validate']: () => dic.projectValidateCommand,
|
|
237
256
|
['project:print-schema']: () => dic.projectPrintSchemaCommand,
|
|
238
257
|
['project:generate-doc']: () => dic.projectGenerateDocumentationCommand,
|
|
258
|
+
['actions:list-variables']: () => dic.actionsListVariables,
|
|
259
|
+
['actions:set-variables']: () => dic.actionsSetVariables,
|
|
260
|
+
['actions:failed-events']: () => dic.actionsListFailedEvents,
|
|
261
|
+
['actions:retry-event']: () => dic.actionsRetryEvent,
|
|
262
|
+
['actions:get-event']: () => dic.actionsGetEvent,
|
|
263
|
+
['actions:stop-event']: () => dic.actionsStopEvent,
|
|
239
264
|
}
|
|
240
265
|
return commands
|
|
241
266
|
})
|
|
@@ -46,17 +46,13 @@ export class VersionChecker {
|
|
|
46
46
|
if (!def.image) {
|
|
47
47
|
continue
|
|
48
48
|
}
|
|
49
|
-
const [image,
|
|
50
|
-
if (!
|
|
49
|
+
const [image, tag] = def.image.split(':')
|
|
50
|
+
if (!tag || !contemberDockerImages.includes(image)) {
|
|
51
51
|
continue
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
const cliVersionParts = cliVersion.split(/[.-]/).slice(0, versionParts.length)
|
|
58
|
-
if (versionParts.join('.') !== cliVersionParts.join('.')) {
|
|
59
|
-
errors.push(`Docker service ${name} with image ${image}:${version} does not match version of CLI ${cliVersion}.`)
|
|
53
|
+
|
|
54
|
+
if (extractVersion(tag) !== cliVersion) {
|
|
55
|
+
errors.push(`Docker service ${name} with image ${image}:${tag} does not match version of CLI ${cliVersion}.`)
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
58
|
}
|
|
@@ -69,3 +65,11 @@ Please make sure all dependencies are up to date.\nIf you are really certain abo
|
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const extractVersion = (tag: string) => {
|
|
71
|
+
// e.g.
|
|
72
|
+
// 2.1.0-alpha.15-foo-bar => 2.1.0-alpha.15
|
|
73
|
+
// 2.1.0-debian => 2.1.0
|
|
74
|
+
return tag.match(/^\d+\.\d+\.\d+(-\w+\.\d+)?/)?.[0] ?? tag
|
|
75
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { GraphQlClient } from '@contember/graphql-client'
|
|
2
|
+
|
|
3
|
+
const createActionsApiUrl = (url: string, project: string) => {
|
|
4
|
+
if (url.endsWith('/')) {
|
|
5
|
+
url = url.substring(0, url.length - 1)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return url + '/actions/' + project
|
|
9
|
+
}
|
|
10
|
+
export class ActionsClient {
|
|
11
|
+
constructor(private readonly apiClient: GraphQlClient) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static create(url: string, project: string, apiToken: string): ActionsClient {
|
|
15
|
+
const graphqlClient = new GraphQlClient({ url: createActionsApiUrl(url, project), apiToken })
|
|
16
|
+
return new ActionsClient(graphqlClient)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async listVariables(): Promise<{ name: string; value: string }[]> {
|
|
20
|
+
const query = `query {
|
|
21
|
+
variables {
|
|
22
|
+
name
|
|
23
|
+
value
|
|
24
|
+
}
|
|
25
|
+
}`
|
|
26
|
+
const result = await this.apiClient.execute<{
|
|
27
|
+
variables: Array<{ name: string; value: string }>
|
|
28
|
+
}>(query)
|
|
29
|
+
return result.variables
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async setVariables(variables: { name: string; value: string }[], mode: 'MERGE' | 'SET' | 'APPEND_ONLY_MISSING'): Promise<boolean> {
|
|
33
|
+
const query = `mutation($variables: [VariableInput!]!, $mode: SetVariablesMode) {
|
|
34
|
+
setVariables(args: { variables: $variables, mode: $mode }) {
|
|
35
|
+
ok
|
|
36
|
+
}
|
|
37
|
+
}`
|
|
38
|
+
const result = await this.apiClient.execute<{ setVariables: { ok: boolean } }>(query, { variables: { mode, variables } })
|
|
39
|
+
return result.setVariables.ok
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public async listFailedEvents({ offset, limit }: { offset?: number; limit?: number } = {}): Promise<Event[]> {
|
|
43
|
+
const query = `query($offset: Int, $limit: Int) {
|
|
44
|
+
failedEvents(args: { offset: $offset, limit: $limit }) {
|
|
45
|
+
id
|
|
46
|
+
createdAt
|
|
47
|
+
lastStateChange
|
|
48
|
+
visibleAt
|
|
49
|
+
numRetries
|
|
50
|
+
state
|
|
51
|
+
target
|
|
52
|
+
payload
|
|
53
|
+
log
|
|
54
|
+
}
|
|
55
|
+
}`
|
|
56
|
+
const result = await this.apiClient.execute<{
|
|
57
|
+
failedEvents: Event[]
|
|
58
|
+
}>(query, { variables: { offset, limit } })
|
|
59
|
+
return result.failedEvents
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public async retryEvent(id: string): Promise<boolean> {
|
|
63
|
+
const query = `mutation($id: UUID!) {
|
|
64
|
+
retryEvent(id: $id) {
|
|
65
|
+
ok
|
|
66
|
+
}
|
|
67
|
+
}`
|
|
68
|
+
const result = await this.apiClient.execute<{ retryEvent: { ok: boolean } }>(query, { variables: { id } })
|
|
69
|
+
return result.retryEvent.ok
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public async stopEvent(id: string): Promise<boolean> {
|
|
73
|
+
const query = `mutation($id: UUID!) {
|
|
74
|
+
stopEvent(id: $id) {
|
|
75
|
+
ok
|
|
76
|
+
}
|
|
77
|
+
}`
|
|
78
|
+
const result = await this.apiClient.execute<{ stopEvent: { ok: boolean } }>(query, { variables: { id } })
|
|
79
|
+
return result.stopEvent.ok
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
public async getEvent(id: string): Promise<Event | null> {
|
|
84
|
+
const query = `query($id: UUID!) {
|
|
85
|
+
event(id: $id) {
|
|
86
|
+
id
|
|
87
|
+
createdAt
|
|
88
|
+
lastStateChange
|
|
89
|
+
visibleAt
|
|
90
|
+
numRetries
|
|
91
|
+
state
|
|
92
|
+
target
|
|
93
|
+
payload
|
|
94
|
+
log
|
|
95
|
+
}
|
|
96
|
+
}`
|
|
97
|
+
const result = await this.apiClient.execute<{ event: Event | null }>(query, { variables: { id } })
|
|
98
|
+
return result.event
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type Event = {
|
|
103
|
+
id: string
|
|
104
|
+
createdAt: string
|
|
105
|
+
lastStateChange: string
|
|
106
|
+
visibleAt: string | null
|
|
107
|
+
numRetries: number
|
|
108
|
+
state: 'retrying' | 'failed'
|
|
109
|
+
target: string
|
|
110
|
+
payload: any
|
|
111
|
+
log: any
|
|
112
|
+
}
|