@mittwald/cli 1.0.0-alpha.10 → 1.0.0-alpha.13
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/README.md +1136 -579
- package/dist/esm/DeleteBaseCommand.js +1 -1
- package/dist/esm/Formatter.js +3 -0
- package/dist/esm/Helpers.d.ts +1 -0
- package/dist/esm/Helpers.js +7 -1
- package/dist/esm/ListBaseCommand.js +6 -1
- package/dist/esm/Translator.d.ts +1 -0
- package/dist/esm/Translator.js +11 -0
- package/dist/esm/commands/app/install/wordpress.js +1 -1
- package/dist/esm/commands/context/set.js +4 -3
- package/dist/esm/commands/database/mysql/charsets.d.ts +14 -3
- package/dist/esm/commands/database/mysql/charsets.js +25 -2
- package/dist/esm/commands/database/mysql/create.d.ts +23 -0
- package/dist/esm/commands/database/mysql/create.js +103 -0
- package/dist/esm/commands/database/mysql/delete.d.ts +14 -0
- package/dist/esm/commands/database/mysql/delete.js +20 -0
- package/dist/esm/commands/database/mysql/dump.d.ts +15 -0
- package/dist/esm/commands/database/mysql/dump.js +70 -0
- package/dist/esm/commands/database/mysql/get.d.ts +14 -2
- package/dist/esm/commands/database/mysql/get.js +14 -5
- package/dist/esm/commands/database/mysql/list.d.ts +11 -3
- package/dist/esm/commands/database/mysql/list.js +23 -13
- package/dist/esm/commands/database/mysql/phpmyadmin.d.ts +8 -0
- package/dist/esm/commands/database/mysql/phpmyadmin.js +25 -0
- package/dist/esm/commands/database/mysql/port-forward.d.ts +14 -0
- package/dist/esm/commands/database/mysql/port-forward.js +44 -0
- package/dist/esm/commands/database/mysql/shell.d.ts +14 -0
- package/dist/esm/commands/database/mysql/shell.js +39 -0
- package/dist/esm/commands/database/mysql/user/get.d.ts +13 -2
- package/dist/esm/commands/database/mysql/user/get.js +18 -5
- package/dist/esm/commands/database/mysql/user/list.d.ts +13 -3
- package/dist/esm/commands/database/mysql/user/list.js +38 -2
- package/dist/esm/commands/database/mysql/versions.d.ts +13 -3
- package/dist/esm/commands/database/mysql/versions.js +19 -2
- package/dist/esm/commands/database/redis/get.d.ts +15 -2
- package/dist/esm/commands/database/redis/get.js +21 -5
- package/dist/esm/commands/database/redis/list.d.ts +13 -3
- package/dist/esm/commands/database/redis/list.js +26 -2
- package/dist/esm/commands/database/redis/shell.d.ts +13 -0
- package/dist/esm/commands/database/redis/shell.js +26 -0
- package/dist/esm/commands/database/redis/versions.d.ts +11 -3
- package/dist/esm/commands/database/redis/versions.js +12 -2
- package/dist/esm/commands/domain/ownership/list.js +1 -0
- package/dist/esm/commands/domain/virtualhost/create.d.ts +26 -0
- package/dist/esm/commands/domain/virtualhost/create.js +122 -0
- package/dist/esm/commands/domain/virtualhost/delete.d.ts +13 -0
- package/dist/esm/commands/domain/virtualhost/delete.js +21 -0
- package/dist/esm/commands/domain/virtualhost/get.d.ts +13 -2
- package/dist/esm/commands/domain/virtualhost/get.js +85 -5
- package/dist/esm/commands/domain/virtualhost/list.d.ts +1 -1
- package/dist/esm/commands/domain/virtualhost/list.js +29 -13
- package/dist/esm/commands/login/reset.js +1 -1
- package/dist/esm/commands/mail/address/create.d.ts +16 -8
- package/dist/esm/commands/mail/address/create.js +52 -10
- package/dist/esm/commands/org/delete.d.ts +13 -0
- package/dist/esm/commands/org/delete.js +16 -0
- package/dist/esm/commands/org/invite/list-own.d.ts +46 -5
- package/dist/esm/commands/org/invite/list-own.js +38 -3
- package/dist/esm/commands/org/invite/list.d.ts +13 -3
- package/dist/esm/commands/org/invite/list.js +31 -2
- package/dist/esm/commands/org/invite/revoke.d.ts +17 -0
- package/dist/esm/commands/org/invite/revoke.js +39 -0
- package/dist/esm/commands/org/invite.d.ts +21 -0
- package/dist/esm/commands/org/invite.js +66 -0
- package/dist/esm/commands/org/list.d.ts +13 -4
- package/dist/esm/commands/org/list.js +21 -3
- package/dist/esm/commands/org/membership/list-own.d.ts +45 -5
- package/dist/esm/commands/org/membership/list-own.js +41 -3
- package/dist/esm/commands/org/membership/list.d.ts +33 -5
- package/dist/esm/commands/org/membership/list.js +40 -3
- package/dist/esm/commands/org/membership/revoke.d.ts +17 -0
- package/dist/esm/commands/org/membership/revoke.js +43 -0
- package/dist/esm/commands/project/create.js +1 -1
- package/dist/esm/commands/project/get.js +8 -4
- package/dist/esm/commands/project/list-react.js +1 -1
- package/dist/esm/commands/user/api-token/create.js +1 -1
- package/dist/esm/commands/user/ssh-key/create.js +1 -1
- package/dist/esm/generated/domain/listDomainOwnerships.d.ts +1 -1
- package/dist/esm/generated/domain/listDomainOwnerships.js +3 -6
- package/dist/esm/lib/context_flags.js +2 -1
- package/dist/esm/lib/database/common.d.ts +8 -0
- package/dist/esm/lib/database/common.js +17 -0
- package/dist/esm/lib/database/mysql/connect.d.ts +19 -0
- package/dist/esm/lib/database/mysql/connect.js +50 -0
- package/dist/esm/lib/database/mysql/flags.d.ts +10 -0
- package/dist/esm/lib/database/mysql/flags.js +48 -0
- package/dist/esm/lib/database/redis/connect.d.ts +8 -0
- package/dist/esm/lib/database/redis/connect.js +22 -0
- package/dist/esm/lib/database/redis/flags.d.ts +7 -0
- package/dist/esm/lib/database/redis/flags.js +35 -0
- package/dist/esm/lib/handleError.js +11 -0
- package/dist/esm/lib/org/flags.js +2 -1
- package/dist/esm/rendering/process/components/ProcessConfirmation.d.ts +6 -0
- package/dist/esm/rendering/process/components/ProcessConfirmation.js +12 -0
- package/dist/esm/rendering/process/components/ProcessConfirmationStateSummary.d.ts +5 -0
- package/dist/esm/rendering/process/components/ProcessConfirmationStateSummary.js +18 -0
- package/dist/esm/rendering/process/components/ProcessError.d.ts +4 -0
- package/dist/esm/rendering/process/components/ProcessError.js +10 -0
- package/dist/esm/rendering/process/components/ProcessInput.d.ts +6 -0
- package/dist/esm/rendering/process/components/ProcessInput.js +15 -0
- package/dist/esm/rendering/process/components/ProcessInputStateSummary.d.ts +5 -0
- package/dist/esm/rendering/process/components/ProcessInputStateSummary.js +13 -0
- package/dist/esm/rendering/process/components/ProcessState.d.ts +5 -0
- package/dist/esm/rendering/process/components/ProcessState.js +8 -0
- package/dist/esm/rendering/process/components/ProcessStateIcon.d.ts +5 -0
- package/dist/esm/rendering/process/components/ProcessStateIcon.js +22 -0
- package/dist/esm/rendering/process/components/ProcessStateSummary.d.ts +5 -0
- package/dist/esm/rendering/process/components/ProcessStateSummary.js +27 -0
- package/dist/esm/rendering/process/components/ProcessValidationErrors.d.ts +7 -0
- package/dist/esm/rendering/process/components/ProcessValidationErrors.js +15 -0
- package/dist/esm/rendering/{react → process}/process.d.ts +5 -5
- package/dist/esm/rendering/{react → process}/process_fancy.d.ts +1 -12
- package/dist/esm/rendering/process/process_fancy.js +119 -0
- package/dist/esm/rendering/process/process_flags.d.ts +20 -0
- package/dist/esm/rendering/process/process_flags.js +29 -0
- package/dist/esm/rendering/{react → process}/process_quiet.d.ts +2 -2
- package/dist/esm/rendering/react/components/ErrorBox.d.ts +11 -0
- package/dist/esm/rendering/react/components/ErrorBox.js +45 -0
- package/dist/esm/rendering/react/components/Ingress/DnsValidationErrors.d.ts +8 -0
- package/dist/esm/rendering/react/components/Ingress/DnsValidationErrors.js +17 -0
- package/dist/esm/rendering/react/components/Ingress/DomainOwnership.d.ts +8 -0
- package/dist/esm/rendering/react/components/Ingress/DomainOwnership.js +7 -0
- package/dist/esm/rendering/react/components/Note.d.ts +1 -2
- package/dist/esm/rendering/react/components/{ProjectReadiness.js → Project/ProjectReadiness.js} +1 -1
- package/dist/esm/rendering/react/components/Project/ProjectStatus.d.ts +18 -0
- package/dist/esm/rendering/react/components/Warning.d.ts +4 -0
- package/dist/esm/rendering/react/components/Warning.js +7 -0
- package/dist/esm/rendering/react/error.d.ts +7 -0
- package/dist/esm/rendering/react/error.js +12 -0
- package/package.json +28 -8
- package/dist/esm/commands/database/mysql/user/getMysqlUserPhpMyAdminUrl.d.ts +0 -3
- package/dist/esm/commands/database/mysql/user/getMysqlUserPhpMyAdminUrl.js +0 -7
- package/dist/esm/commands/org/invite/get.d.ts +0 -3
- package/dist/esm/commands/org/invite/get.js +0 -6
- package/dist/esm/commands/org/membership/get.d.ts +0 -3
- package/dist/esm/commands/org/membership/get.js +0 -6
- package/dist/esm/generated/customer/getCustomerCategory.d.ts +0 -16
- package/dist/esm/generated/customer/getCustomerCategory.js +0 -25
- package/dist/esm/generated/customer/getCustomerInvite.d.ts +0 -16
- package/dist/esm/generated/customer/getCustomerInvite.js +0 -25
- package/dist/esm/generated/customer/getCustomerMembership.d.ts +0 -16
- package/dist/esm/generated/customer/getCustomerMembership.js +0 -25
- package/dist/esm/generated/customer/listCustomerInvites.d.ts +0 -13
- package/dist/esm/generated/customer/listCustomerInvites.js +0 -17
- package/dist/esm/generated/customer/listCustomerMemberships.d.ts +0 -13
- package/dist/esm/generated/customer/listCustomerMemberships.js +0 -17
- package/dist/esm/generated/customer/listCustomers.d.ts +0 -13
- package/dist/esm/generated/customer/listCustomers.js +0 -17
- package/dist/esm/generated/customer/listInvitesForCustomer.d.ts +0 -13
- package/dist/esm/generated/customer/listInvitesForCustomer.js +0 -24
- package/dist/esm/generated/customer/listMembershipsForCustomer.d.ts +0 -13
- package/dist/esm/generated/customer/listMembershipsForCustomer.js +0 -24
- package/dist/esm/generated/customer/listOfCustomerCategories.d.ts +0 -13
- package/dist/esm/generated/customer/listOfCustomerCategories.js +0 -17
- package/dist/esm/generated/database/getMysqlDatabase.d.ts +0 -16
- package/dist/esm/generated/database/getMysqlDatabase.js +0 -25
- package/dist/esm/generated/database/getMysqlUser.d.ts +0 -16
- package/dist/esm/generated/database/getMysqlUser.js +0 -25
- package/dist/esm/generated/database/getMysqlUserPhpMyAdminUrl.d.ts +0 -14
- package/dist/esm/generated/database/getMysqlUserPhpMyAdminUrl.js +0 -24
- package/dist/esm/generated/database/getRedisDatabase.d.ts +0 -16
- package/dist/esm/generated/database/getRedisDatabase.js +0 -25
- package/dist/esm/generated/database/listMysqlCharsets.d.ts +0 -13
- package/dist/esm/generated/database/listMysqlCharsets.js +0 -17
- package/dist/esm/generated/database/listMysqlDatabases.d.ts +0 -13
- package/dist/esm/generated/database/listMysqlDatabases.js +0 -24
- package/dist/esm/generated/database/listMysqlUsers.d.ts +0 -13
- package/dist/esm/generated/database/listMysqlUsers.js +0 -24
- package/dist/esm/generated/database/listMysqlVersions.d.ts +0 -13
- package/dist/esm/generated/database/listMysqlVersions.js +0 -17
- package/dist/esm/generated/database/listRedisDatabases.d.ts +0 -13
- package/dist/esm/generated/database/listRedisDatabases.js +0 -24
- package/dist/esm/generated/database/listRedisVersions.d.ts +0 -13
- package/dist/esm/generated/database/listRedisVersions.js +0 -17
- package/dist/esm/generated/domain/ingressGetSpecific.d.ts +0 -16
- package/dist/esm/generated/domain/ingressGetSpecific.js +0 -25
- package/dist/esm/rendering/react/components/ProjectStatus.d.ts +0 -7
- package/dist/esm/rendering/react/process_fancy.js +0 -221
- package/dist/esm/rendering/react/process_flags.d.ts +0 -9
- package/dist/esm/rendering/react/process_flags.js +0 -15
- /package/dist/esm/rendering/{react → process}/process.js +0 -0
- /package/dist/esm/rendering/{react → process}/process_quiet.js +0 -0
- /package/dist/esm/rendering/react/components/{ProjectEnabled.d.ts → Project/ProjectEnabled.d.ts} +0 -0
- /package/dist/esm/rendering/react/components/{ProjectEnabled.js → Project/ProjectEnabled.js} +0 -0
- /package/dist/esm/rendering/react/components/{ProjectReadiness.d.ts → Project/ProjectReadiness.d.ts} +0 -0
- /package/dist/esm/rendering/react/components/{ProjectStatus.js → Project/ProjectStatus.js} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExecRenderBaseCommand } from "../../rendering/react/ExecRenderBaseCommand.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare class Invite extends ExecRenderBaseCommand<typeof Invite, {
|
|
4
|
+
inviteId: string;
|
|
5
|
+
}> {
|
|
6
|
+
static description: string;
|
|
7
|
+
static flags: {
|
|
8
|
+
email: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
role: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
message: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
expires: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
quiet: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
protected getExpirationDate(): Date | undefined;
|
|
15
|
+
protected exec(): Promise<{
|
|
16
|
+
inviteId: string;
|
|
17
|
+
}>;
|
|
18
|
+
protected render(executionResult: {
|
|
19
|
+
inviteId: string;
|
|
20
|
+
}): ReactNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ExecRenderBaseCommand } from "../../rendering/react/ExecRenderBaseCommand.js";
|
|
3
|
+
import { orgFlags, withOrgId } from "../../lib/org/flags.js";
|
|
4
|
+
import { makeProcessRenderer, processFlags, } from "../../rendering/process/process_flags.js";
|
|
5
|
+
import { Flags } from "@oclif/core";
|
|
6
|
+
import parseDuration from "parse-duration";
|
|
7
|
+
import { assertStatus } from "@mittwald/api-client-commons";
|
|
8
|
+
import { Success } from "../../rendering/react/components/Success.js";
|
|
9
|
+
import { Value } from "../../rendering/react/components/Value.js";
|
|
10
|
+
const inviteFlags = {
|
|
11
|
+
email: Flags.string({
|
|
12
|
+
description: "The email address of the user to invite.",
|
|
13
|
+
required: true,
|
|
14
|
+
}),
|
|
15
|
+
role: Flags.string({
|
|
16
|
+
description: "The role of the user to invite.",
|
|
17
|
+
options: ["owner", "member", "accountant"],
|
|
18
|
+
default: "member",
|
|
19
|
+
}),
|
|
20
|
+
message: Flags.string({
|
|
21
|
+
description: "A message to include in the invitation email.",
|
|
22
|
+
}),
|
|
23
|
+
expires: Flags.string({
|
|
24
|
+
description: "An interval after which the invitation expires (examples: 30m, 30d, 1y).",
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
export class Invite extends ExecRenderBaseCommand {
|
|
28
|
+
static description = "Invite a user to an organization.";
|
|
29
|
+
static flags = { ...orgFlags, ...processFlags, ...inviteFlags };
|
|
30
|
+
getExpirationDate() {
|
|
31
|
+
if (!this.flags.expires) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const d = new Date();
|
|
35
|
+
const i = parseDuration(this.flags.expires);
|
|
36
|
+
if (!i) {
|
|
37
|
+
throw new Error("could not parse duration: " + this.flags.expires);
|
|
38
|
+
}
|
|
39
|
+
return new Date(d.getTime() + i);
|
|
40
|
+
}
|
|
41
|
+
async exec() {
|
|
42
|
+
const process = makeProcessRenderer(this.flags, "Inviting user to organization");
|
|
43
|
+
const customerId = await withOrgId(this.apiClient, this.flags, this.args, this.config);
|
|
44
|
+
const invite = await process.runStep("Creating invite", async () => {
|
|
45
|
+
const result = await this.apiClient.customer.createCustomerInvite({
|
|
46
|
+
pathParameters: { customerId },
|
|
47
|
+
data: {
|
|
48
|
+
mailAddress: this.flags.email,
|
|
49
|
+
role: this.flags.role,
|
|
50
|
+
message: this.flags.message,
|
|
51
|
+
membershipExpiresAt: this.getExpirationDate()?.toJSON(),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
assertStatus(result, 201);
|
|
55
|
+
return result;
|
|
56
|
+
});
|
|
57
|
+
process.complete(_jsxs(Success, { children: ["The user ", _jsx(Value, { children: this.flags.email }), " was successfully invited to your organization!"] }));
|
|
58
|
+
return { inviteId: invite.data.id };
|
|
59
|
+
}
|
|
60
|
+
render(executionResult) {
|
|
61
|
+
if (this.flags.quiet) {
|
|
62
|
+
return executionResult.inviteId;
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { Simplify } from "@mittwald/api-client-commons";
|
|
2
|
-
import { MittwaldAPIV2 } from "@mittwald/api-client";
|
|
2
|
+
import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
3
3
|
import { SuccessfulResponse } from "../../types.js";
|
|
4
|
-
import { GeneratedCustomerListCustomers, Response } from "../../generated/customer/listCustomers.js";
|
|
5
4
|
import { ListColumns } from "../../Formatter.js";
|
|
5
|
+
import { ListBaseCommand } from "../../ListBaseCommand.js";
|
|
6
6
|
type ResponseItem = Simplify<MittwaldAPIV2.Paths.V2Customers.Get.Responses.$200.Content.ApplicationJson[number]>;
|
|
7
|
-
export
|
|
7
|
+
export type PathParams = MittwaldAPIV2.Paths.V2Customers.Get.Parameters.Path;
|
|
8
|
+
export type Response = Awaited<ReturnType<MittwaldAPIV2Client["customer"]["listCustomers"]>>;
|
|
9
|
+
export declare class List extends ListBaseCommand<typeof List, ResponseItem, Response> {
|
|
10
|
+
static description: string;
|
|
11
|
+
static args: {};
|
|
12
|
+
static flags: {
|
|
13
|
+
[x: string]: import("@oclif/core/lib/interfaces/parser.js").CompletableFlag<any>;
|
|
14
|
+
};
|
|
15
|
+
getData(): Promise<Response>;
|
|
16
|
+
protected mapParams(input: PathParams): Promise<PathParams> | PathParams;
|
|
8
17
|
protected mapData(data: SuccessfulResponse<Response, 200>["data"]): MittwaldAPIV2.Components.Schemas.CustomerCustomer[];
|
|
9
|
-
protected getColumns(
|
|
18
|
+
protected getColumns(): ListColumns<ResponseItem>;
|
|
10
19
|
}
|
|
11
20
|
export {};
|
|
@@ -1,14 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { ListBaseCommand } from "../../ListBaseCommand.js";
|
|
2
|
+
export class List extends ListBaseCommand {
|
|
3
|
+
static description = "Get all organizations the authenticated user has access to.";
|
|
4
|
+
static args = {};
|
|
5
|
+
static flags = {
|
|
6
|
+
...ListBaseCommand.baseFlags,
|
|
7
|
+
};
|
|
8
|
+
async getData() {
|
|
9
|
+
const pathParams = {};
|
|
10
|
+
return await this.apiClient.customer.listCustomers({
|
|
11
|
+
pathParameters: await this.mapParams(pathParams),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
mapParams(input) {
|
|
15
|
+
return input;
|
|
16
|
+
}
|
|
3
17
|
mapData(data) {
|
|
4
18
|
return data;
|
|
5
19
|
}
|
|
6
|
-
getColumns(
|
|
20
|
+
getColumns() {
|
|
7
21
|
return {
|
|
8
22
|
id: {
|
|
23
|
+
header: "ID",
|
|
9
24
|
get: (r) => r.customerId,
|
|
10
25
|
minWidth: 36,
|
|
11
26
|
},
|
|
27
|
+
customerNumber: {
|
|
28
|
+
header: "Customer No.",
|
|
29
|
+
},
|
|
12
30
|
name: {},
|
|
13
31
|
owner: {
|
|
14
32
|
get: (r) => {
|
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import { Simplify } from "@mittwald/api-client-commons";
|
|
2
|
-
import { MittwaldAPIV2 } from "@mittwald/api-client";
|
|
2
|
+
import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
3
3
|
import { SuccessfulResponse } from "../../../types.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { ListBaseCommand } from "../../../ListBaseCommand.js";
|
|
5
|
+
import { ListColumns } from "../../../Formatter.js";
|
|
6
|
+
import CustomerCustomer = MittwaldAPIV2.Components.Schemas.CustomerCustomer;
|
|
7
|
+
type ResponseItem = Simplify<MittwaldAPIV2.Paths.V2CustomerMemberships.Get.Responses.$200.Content.ApplicationJson[number]> & {
|
|
8
|
+
org?: CustomerCustomer;
|
|
9
|
+
};
|
|
10
|
+
export type PathParams = MittwaldAPIV2.Paths.V2CustomerMemberships.Get.Parameters.Path;
|
|
11
|
+
export type Response = Awaited<ReturnType<MittwaldAPIV2Client["customer"]["listCustomerMemberships"]>>;
|
|
12
|
+
export declare class ListOwn extends ListBaseCommand<typeof ListOwn, ResponseItem, Response> {
|
|
13
|
+
static description: string;
|
|
14
|
+
static args: {};
|
|
15
|
+
static flags: {
|
|
16
|
+
[x: string]: import("@oclif/core/lib/interfaces/parser.js").CompletableFlag<any>;
|
|
17
|
+
};
|
|
18
|
+
getData(): Promise<Response>;
|
|
19
|
+
protected mapParams(input: PathParams): Promise<PathParams> | PathParams;
|
|
20
|
+
protected mapData(data: SuccessfulResponse<Response, 200>["data"]): Promise<(MittwaldAPIV2.Components.Schemas.MembershipCustomerMembership | {
|
|
21
|
+
org: {
|
|
22
|
+
activeSuspension?: {
|
|
23
|
+
createdAt?: string | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
avatarRefId?: string | undefined;
|
|
26
|
+
categoryId?: string | undefined;
|
|
27
|
+
creationDate: string;
|
|
28
|
+
customerId: string;
|
|
29
|
+
customerNumber: string;
|
|
30
|
+
executingUserRoles?: MittwaldAPIV2.Components.Schemas.CustomerRole[] | undefined;
|
|
31
|
+
isInDefaultOfPayment?: boolean | undefined;
|
|
32
|
+
memberCount: number;
|
|
33
|
+
name: string;
|
|
34
|
+
owner?: MittwaldAPIV2.Components.Schemas.CustomerContact | undefined;
|
|
35
|
+
projectCount: number;
|
|
36
|
+
vatId?: string | undefined;
|
|
37
|
+
vatIdValidationState?: "pending" | "valid" | "invalid" | "unspecified" | undefined;
|
|
38
|
+
};
|
|
39
|
+
customerId: string;
|
|
40
|
+
expiresAt?: string | undefined;
|
|
41
|
+
id: string;
|
|
42
|
+
inviteId: string;
|
|
43
|
+
memberSince?: string | undefined;
|
|
44
|
+
role: MittwaldAPIV2.Components.Schemas.MembershipCustomerRoles;
|
|
45
|
+
userId: string;
|
|
46
|
+
})[]>;
|
|
47
|
+
protected getColumns(data: ResponseItem[]): ListColumns<ResponseItem>;
|
|
8
48
|
}
|
|
9
49
|
export {};
|
|
@@ -1,6 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ListBaseCommand } from "../../../ListBaseCommand.js";
|
|
2
|
+
import { formatRelativeDate } from "../../../lib/viewhelpers/date.js";
|
|
3
|
+
export class ListOwn extends ListBaseCommand {
|
|
4
|
+
static description = "List all organization memberships for the executing user.";
|
|
5
|
+
static args = {};
|
|
6
|
+
static flags = {
|
|
7
|
+
...ListBaseCommand.baseFlags,
|
|
8
|
+
};
|
|
9
|
+
async getData() {
|
|
10
|
+
const pathParams = {};
|
|
11
|
+
return await this.apiClient.customer.listCustomerMemberships({
|
|
12
|
+
pathParameters: await this.mapParams(pathParams),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
mapParams(input) {
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
3
18
|
mapData(data) {
|
|
4
|
-
return data
|
|
19
|
+
return Promise.all(data.map(async (item) => {
|
|
20
|
+
const { customerId } = item;
|
|
21
|
+
const org = await this.apiClient.customer.getCustomer({
|
|
22
|
+
pathParameters: { customerId },
|
|
23
|
+
});
|
|
24
|
+
if (org.status === 200) {
|
|
25
|
+
return { ...item, org: org.data };
|
|
26
|
+
}
|
|
27
|
+
return item;
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
getColumns(data) {
|
|
31
|
+
const baseColumns = super.getColumns(data);
|
|
32
|
+
return {
|
|
33
|
+
id: baseColumns.id,
|
|
34
|
+
role: {},
|
|
35
|
+
org: {
|
|
36
|
+
get: (item) => item.org?.name ?? "(unknown org)",
|
|
37
|
+
},
|
|
38
|
+
memberSince: {
|
|
39
|
+
header: "Member since",
|
|
40
|
+
get: (item) => formatRelativeDate(item.memberSince),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
5
43
|
}
|
|
6
44
|
}
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import { Simplify } from "@mittwald/api-client-commons";
|
|
2
|
-
import { MittwaldAPIV2 } from "@mittwald/api-client";
|
|
2
|
+
import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
3
3
|
import { SuccessfulResponse } from "../../../types.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { ListBaseCommand } from "../../../ListBaseCommand.js";
|
|
5
|
+
import { ListColumns } from "../../../Formatter.js";
|
|
6
|
+
import UserUser = MittwaldAPIV2.Components.Schemas.UserUser;
|
|
7
|
+
type ResponseItem = Simplify<MittwaldAPIV2.Paths.V2CustomersCustomerIdMemberships.Get.Responses.$200.Content.ApplicationJson[number]> & {
|
|
8
|
+
user?: UserUser;
|
|
9
|
+
};
|
|
10
|
+
export type PathParams = MittwaldAPIV2.Paths.V2CustomersCustomerIdMemberships.Get.Parameters.Path;
|
|
11
|
+
export type Response = Awaited<ReturnType<MittwaldAPIV2Client["customer"]["listMembershipsForCustomer"]>>;
|
|
12
|
+
export declare class List extends ListBaseCommand<typeof List, ResponseItem, Response> {
|
|
13
|
+
static description: string;
|
|
14
|
+
static args: {};
|
|
15
|
+
static flags: {
|
|
16
|
+
[x: string]: import("@oclif/core/lib/interfaces/parser.js").CompletableFlag<any> | import("@oclif/core/lib/interfaces/parser.js").OptionFlag<unknown>;
|
|
17
|
+
};
|
|
18
|
+
getData(): Promise<Response>;
|
|
19
|
+
protected mapData(data: SuccessfulResponse<Response, 200>["data"]): Promise<(MittwaldAPIV2.Components.Schemas.MembershipCustomerMembership | {
|
|
20
|
+
user: {
|
|
21
|
+
avatarRef?: string | undefined;
|
|
22
|
+
email?: string | undefined;
|
|
23
|
+
person: MittwaldAPIV2.Components.Schemas.CommonsPerson;
|
|
24
|
+
phoneNumber?: string | undefined;
|
|
25
|
+
userId: string;
|
|
26
|
+
};
|
|
27
|
+
customerId: string;
|
|
28
|
+
expiresAt?: string | undefined;
|
|
29
|
+
id: string;
|
|
30
|
+
inviteId: string;
|
|
31
|
+
memberSince?: string | undefined;
|
|
32
|
+
role: MittwaldAPIV2.Components.Schemas.MembershipCustomerRoles;
|
|
33
|
+
userId: string;
|
|
34
|
+
})[]>;
|
|
35
|
+
protected getColumns(data: ResponseItem[]): ListColumns<ResponseItem>;
|
|
8
36
|
}
|
|
9
37
|
export {};
|
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ListBaseCommand } from "../../../ListBaseCommand.js";
|
|
2
|
+
import { orgFlags, withOrgId } from "../../../lib/org/flags.js";
|
|
3
|
+
import { formatRelativeDate } from "../../../lib/viewhelpers/date.js";
|
|
4
|
+
export class List extends ListBaseCommand {
|
|
5
|
+
static description = "List all memberships belonging to an organization.";
|
|
6
|
+
static args = {};
|
|
7
|
+
static flags = {
|
|
8
|
+
...ListBaseCommand.baseFlags,
|
|
9
|
+
...orgFlags,
|
|
10
|
+
};
|
|
11
|
+
async getData() {
|
|
12
|
+
const customerId = await withOrgId(this.apiClient, this.flags, this.args, this.config);
|
|
13
|
+
return await this.apiClient.customer.listMembershipsForCustomer({
|
|
14
|
+
pathParameters: { customerId },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
3
17
|
mapData(data) {
|
|
4
|
-
return data
|
|
18
|
+
return Promise.all(data.map(async (item) => {
|
|
19
|
+
const { userId } = item;
|
|
20
|
+
const user = await this.apiClient.user.getUser({
|
|
21
|
+
pathParameters: { userId },
|
|
22
|
+
});
|
|
23
|
+
if (user.status === 200) {
|
|
24
|
+
return { ...item, user: user.data };
|
|
25
|
+
}
|
|
26
|
+
return item;
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
getColumns(data) {
|
|
30
|
+
const baseColumns = super.getColumns(data);
|
|
31
|
+
return {
|
|
32
|
+
id: baseColumns.id,
|
|
33
|
+
role: {},
|
|
34
|
+
user: {
|
|
35
|
+
get: (item) => item.user?.email ?? "(unknown user)",
|
|
36
|
+
},
|
|
37
|
+
memberSince: {
|
|
38
|
+
header: "Member since",
|
|
39
|
+
get: (item) => formatRelativeDate(item.memberSince),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
5
42
|
}
|
|
6
43
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExecRenderBaseCommand } from "../../../rendering/react/ExecRenderBaseCommand.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare class Revoke extends ExecRenderBaseCommand<typeof Revoke, {
|
|
4
|
+
deleted: boolean;
|
|
5
|
+
}> {
|
|
6
|
+
static description: string;
|
|
7
|
+
static flags: {
|
|
8
|
+
quiet: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
"membership-id": import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
protected exec(): Promise<{
|
|
14
|
+
deleted: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
protected render(): ReactNode;
|
|
17
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ExecRenderBaseCommand } from "../../../rendering/react/ExecRenderBaseCommand.js";
|
|
3
|
+
import { makeProcessRenderer, processFlags, } from "../../../rendering/process/process_flags.js";
|
|
4
|
+
import { Args } from "@oclif/core";
|
|
5
|
+
import { assertStatus } from "@mittwald/api-client-commons";
|
|
6
|
+
import { Success } from "../../../rendering/react/components/Success.js";
|
|
7
|
+
import { Value } from "../../../rendering/react/components/Value.js";
|
|
8
|
+
export class Revoke extends ExecRenderBaseCommand {
|
|
9
|
+
static description = "Revoke a user's membership to an organization";
|
|
10
|
+
static flags = { ...processFlags };
|
|
11
|
+
static args = {
|
|
12
|
+
"membership-id": Args.string({
|
|
13
|
+
description: "The ID of the membership to revoke",
|
|
14
|
+
required: true,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
async exec() {
|
|
18
|
+
const membershipId = this.args["membership-id"];
|
|
19
|
+
const process = makeProcessRenderer(this.flags, "Revoking organization membership");
|
|
20
|
+
const user = await process.runStep("Fetching existing member", async () => {
|
|
21
|
+
const memberResponse = await this.apiClient.customer.getCustomerMembership({
|
|
22
|
+
pathParameters: { membershipId },
|
|
23
|
+
});
|
|
24
|
+
assertStatus(memberResponse, 200);
|
|
25
|
+
const userResponse = await this.apiClient.user.getUser({
|
|
26
|
+
pathParameters: { userId: memberResponse.data.userId },
|
|
27
|
+
});
|
|
28
|
+
assertStatus(userResponse, 200);
|
|
29
|
+
return userResponse.data;
|
|
30
|
+
});
|
|
31
|
+
await process.runStep("Revoking membership", async () => {
|
|
32
|
+
const response = await this.apiClient.customer.deleteCustomerMembership({
|
|
33
|
+
pathParameters: { membershipId },
|
|
34
|
+
});
|
|
35
|
+
assertStatus(response, 204);
|
|
36
|
+
});
|
|
37
|
+
process.complete(_jsxs(Success, { children: ["User ", _jsx(Value, { children: user.email }), " was removed from the organization."] }));
|
|
38
|
+
return { deleted: true };
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -6,7 +6,7 @@ import { ExecRenderBaseCommand } from "../../rendering/react/ExecRenderBaseComma
|
|
|
6
6
|
import { Text } from "ink";
|
|
7
7
|
import { Success } from "../../rendering/react/components/Success.js";
|
|
8
8
|
import { Value } from "../../rendering/react/components/Value.js";
|
|
9
|
-
import { makeProcessRenderer, processFlags, } from "../../rendering/
|
|
9
|
+
import { makeProcessRenderer, processFlags, } from "../../rendering/process/process_flags.js";
|
|
10
10
|
import { waitUntil } from "../../lib/wait.js";
|
|
11
11
|
import { Context } from "../../lib/context.js";
|
|
12
12
|
export default class Create extends ExecRenderBaseCommand {
|
|
@@ -15,7 +15,7 @@ import { assertStatus } from "@mittwald/api-client-commons";
|
|
|
15
15
|
import { ByteFormat } from "../../rendering/react/components/ByteFormat.js";
|
|
16
16
|
import { RenderJson } from "../../rendering/react/json/RenderJson.js";
|
|
17
17
|
import Link from "ink-link";
|
|
18
|
-
import { ProjectStatus } from "../../rendering/react/components/ProjectStatus.js";
|
|
18
|
+
import { ProjectStatus } from "../../rendering/react/components/Project/ProjectStatus.js";
|
|
19
19
|
const ProjectSpecs = ({ projectId, spec }) => {
|
|
20
20
|
if ("cpu" in spec) {
|
|
21
21
|
const { apiClient } = useRenderContext();
|
|
@@ -40,9 +40,13 @@ const ProjectCustomer = ({ customer }) => {
|
|
|
40
40
|
const GetProject = ({ response }) => {
|
|
41
41
|
const { apiClient } = useRenderContext();
|
|
42
42
|
const customer = usePromise((id) => apiClient.customer.getCustomer({ pathParameters: { customerId: id } }), [response.customerId]);
|
|
43
|
+
const vhosts = usePromise((id) => apiClient.domain.ingressListForProject({
|
|
44
|
+
pathParameters: { projectId: id },
|
|
45
|
+
}), [response.id]);
|
|
43
46
|
assertStatus(customer, 200);
|
|
44
|
-
|
|
45
|
-
const
|
|
47
|
+
assertStatus(vhosts, 200);
|
|
48
|
+
const host = vhosts.data.find((h) => h.isDefault)?.hostname;
|
|
49
|
+
const url = host ? `https://${host}` : undefined;
|
|
46
50
|
const rows = {
|
|
47
51
|
"Project ID": _jsx(IDAndShortID, { object: response }),
|
|
48
52
|
"Created At": _jsx(CreatedAt, { object: response }),
|
|
@@ -52,7 +56,7 @@ const GetProject = ({ response }) => {
|
|
|
52
56
|
const sections = [
|
|
53
57
|
_jsx(SingleResult, { title: _jsxs(_Fragment, { children: ["PROJECT DETAILS: ", _jsx(Value, { children: response.description })] }), rows: rows }, "primary"),
|
|
54
58
|
_jsx(SingleResult, { title: "Access", rows: {
|
|
55
|
-
"HTTP(S)": (_jsx(Link, { url: url, children: _jsx(Value, { children: host }) })),
|
|
59
|
+
"HTTP(S)": host && url ? (_jsx(Link, { url: url, children: _jsx(Value, { children: host }) })) : (_jsx(Value, { notSet: true })),
|
|
56
60
|
"SSH/SFTP": (_jsxs(Text, { children: [_jsxs(Value, { children: ["ssh.", response.clusterID, ".", response.clusterDomain] }), " ", _jsx(Text, { color: "gray", children: "(Use the \"project ssh\" command to connect directly using the CLI)" })] })),
|
|
57
61
|
} }, "access"),
|
|
58
62
|
];
|
|
@@ -6,7 +6,7 @@ import { useRenderContext } from "../../rendering/react/context.js";
|
|
|
6
6
|
import { Table } from "../../rendering/react/components/Table/index.js";
|
|
7
7
|
import { UsePromiseRenderSetup } from "../../rendering/setup/usePromiseSetup.js";
|
|
8
8
|
import { TableRenderSetup } from "../../rendering/setup/TableRenderSetup.js";
|
|
9
|
-
import { ProjectStatus } from "../../rendering/react/components/ProjectStatus.js";
|
|
9
|
+
import { ProjectStatus } from "../../rendering/react/components/Project/ProjectStatus.js";
|
|
10
10
|
const usePromiseSetup = new UsePromiseRenderSetup();
|
|
11
11
|
const tableSetupInstance = new TableRenderSetup();
|
|
12
12
|
export default class List extends RenderBaseCommand {
|
|
@@ -3,7 +3,7 @@ import { Flags } from "@oclif/core";
|
|
|
3
3
|
import { assertStatus } from "@mittwald/api-client-commons";
|
|
4
4
|
import parseDuration from "parse-duration";
|
|
5
5
|
import { ExecRenderBaseCommand } from "../../../rendering/react/ExecRenderBaseCommand.js";
|
|
6
|
-
import { makeProcessRenderer, processFlags, } from "../../../rendering/
|
|
6
|
+
import { makeProcessRenderer, processFlags, } from "../../../rendering/process/process_flags.js";
|
|
7
7
|
import { Success } from "../../../rendering/react/components/Success.js";
|
|
8
8
|
import { Newline, Text } from "ink";
|
|
9
9
|
import { Value } from "../../../rendering/react/components/Value.js";
|
|
@@ -7,7 +7,7 @@ import * as os from "os";
|
|
|
7
7
|
import * as fs from "fs/promises";
|
|
8
8
|
import parseDuration from "parse-duration";
|
|
9
9
|
import { ExecRenderBaseCommand } from "../../../rendering/react/ExecRenderBaseCommand.js";
|
|
10
|
-
import { makeProcessRenderer, processFlags, } from "../../../rendering/
|
|
10
|
+
import { makeProcessRenderer, processFlags, } from "../../../rendering/process/process_flags.js";
|
|
11
11
|
import { Success } from "../../../rendering/react/components/Success.js";
|
|
12
12
|
import { Filename } from "../../../rendering/react/components/Filename.js";
|
|
13
13
|
import { Text } from "ink";
|
|
@@ -6,7 +6,7 @@ export declare abstract class GeneratedDomainListDomainOwnerships<TItem extends
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static args: {};
|
|
8
8
|
static flags: {
|
|
9
|
-
|
|
9
|
+
[x: string]: import("@oclif/core/lib/interfaces/parser.js").CompletableFlag<any> | import("@oclif/core/lib/interfaces/parser.js").OptionFlag<unknown>;
|
|
10
10
|
};
|
|
11
11
|
getData(): Promise<Response>;
|
|
12
12
|
protected mapParams(input: PathParams): Promise<PathParams> | PathParams;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
1
|
import { ListBaseCommand } from "../../ListBaseCommand.js";
|
|
2
|
+
import { projectFlags, withProjectId } from "../../lib/project/flags.js";
|
|
3
3
|
export class GeneratedDomainListDomainOwnerships extends ListBaseCommand {
|
|
4
4
|
static description = "List all domain ownerships of a project.";
|
|
5
5
|
static args = {};
|
|
6
6
|
static flags = {
|
|
7
7
|
...ListBaseCommand.baseFlags,
|
|
8
|
-
|
|
9
|
-
description: "undefined",
|
|
10
|
-
required: true,
|
|
11
|
-
}),
|
|
8
|
+
...projectFlags,
|
|
12
9
|
};
|
|
13
10
|
async getData() {
|
|
14
11
|
const pathParams = {
|
|
15
|
-
projectId: this.flags
|
|
12
|
+
projectId: await withProjectId(this.apiClient, this.flags, this.args, this.config),
|
|
16
13
|
};
|
|
17
14
|
return await this.apiClient.domain.listDomainOwnerships({
|
|
18
15
|
pathParameters: await this.mapParams(pathParams),
|
|
@@ -6,7 +6,8 @@ export function makeFlagSet(name, char, normalize = (_, id) => id) {
|
|
|
6
6
|
[flagName]: Flags.string({
|
|
7
7
|
char,
|
|
8
8
|
required: false,
|
|
9
|
-
|
|
9
|
+
summary: `ID or short ID of a ${name}; this flag is optional if a default ${name} is set in the context`,
|
|
10
|
+
description: `May contain a short ID or a full ID of a ${name}; you can also use the "<%= config.bin %> context set --${name}-id=<VALUE>" command to persistently set a default ${name} for all commands that accept this flag.`,
|
|
10
11
|
}),
|
|
11
12
|
};
|
|
12
13
|
const args = {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
2
|
+
import { ProcessRenderer } from "../../rendering/process/process.js";
|
|
3
|
+
import ProjectProject = MittwaldAPIV2.Components.Schemas.ProjectProject;
|
|
4
|
+
import SignupAccount = MittwaldAPIV2.Components.Schemas.SignupAccount;
|
|
5
|
+
export declare function getUser(apiClient: MittwaldAPIV2Client, p: ProcessRenderer): Promise<SignupAccount>;
|
|
6
|
+
export declare function getProject(apiClient: MittwaldAPIV2Client, p: ProcessRenderer, database: {
|
|
7
|
+
projectId: string;
|
|
8
|
+
}): Promise<ProjectProject>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { assertStatus } from "@mittwald/api-client-commons";
|
|
2
|
+
export async function getUser(apiClient, p) {
|
|
3
|
+
return await p.runStep("fetching user", async () => {
|
|
4
|
+
const r = await apiClient.user.getOwnAccount();
|
|
5
|
+
assertStatus(r, 200);
|
|
6
|
+
return r.data;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export async function getProject(apiClient, p, database) {
|
|
10
|
+
return await p.runStep("fetching project", async () => {
|
|
11
|
+
const r = await apiClient.project.getProject({
|
|
12
|
+
pathParameters: { id: database.projectId },
|
|
13
|
+
});
|
|
14
|
+
assertStatus(r, 200);
|
|
15
|
+
return r.data;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ProcessRenderer } from "../../../rendering/process/process.js";
|
|
2
|
+
import { MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
3
|
+
export declare function getConnectionDetailsWithPassword(apiClient: MittwaldAPIV2Client, databaseId: string, p: ProcessRenderer, flags: {
|
|
4
|
+
"mysql-password": string | undefined;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
password: string;
|
|
7
|
+
hostname: string;
|
|
8
|
+
database: string;
|
|
9
|
+
user: string;
|
|
10
|
+
sshHost: string;
|
|
11
|
+
sshUser: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function getConnectionDetails(apiClient: MittwaldAPIV2Client, databaseId: string, p: ProcessRenderer): Promise<{
|
|
14
|
+
hostname: string;
|
|
15
|
+
database: string;
|
|
16
|
+
user: string;
|
|
17
|
+
sshHost: string;
|
|
18
|
+
sshUser: string;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { assertStatus } from "@mittwald/api-client-commons";
|
|
2
|
+
import { getProject, getUser } from "../common.js";
|
|
3
|
+
export async function getConnectionDetailsWithPassword(apiClient, databaseId, p, flags) {
|
|
4
|
+
const password = await getPassword(p, flags);
|
|
5
|
+
return {
|
|
6
|
+
...(await getConnectionDetails(apiClient, databaseId, p)),
|
|
7
|
+
password,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export async function getConnectionDetails(apiClient, databaseId, p) {
|
|
11
|
+
const database = await getDatabase(apiClient, p, databaseId);
|
|
12
|
+
const databaseUser = await getDatabaseUser(apiClient, p, databaseId);
|
|
13
|
+
const project = await getProject(apiClient, p, database);
|
|
14
|
+
const user = await getUser(apiClient, p);
|
|
15
|
+
return {
|
|
16
|
+
hostname: database.hostname,
|
|
17
|
+
database: database.name,
|
|
18
|
+
user: databaseUser.name,
|
|
19
|
+
sshHost: `ssh.${project.clusterID}.${project.clusterDomain}`,
|
|
20
|
+
sshUser: `${user.email}@${project.shortId}`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async function getPassword(p, flags) {
|
|
24
|
+
if (flags["mysql-password"]) {
|
|
25
|
+
return flags["mysql-password"];
|
|
26
|
+
}
|
|
27
|
+
return await p.addInput("enter password for MySQL user", true);
|
|
28
|
+
}
|
|
29
|
+
async function getDatabase(apiClient, p, id) {
|
|
30
|
+
return await p.runStep("fetching database", async () => {
|
|
31
|
+
const r = await apiClient.database.getMysqlDatabase({
|
|
32
|
+
pathParameters: { id },
|
|
33
|
+
});
|
|
34
|
+
assertStatus(r, 200);
|
|
35
|
+
return r.data;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function getDatabaseUser(apiClient, p, databaseId) {
|
|
39
|
+
return await p.runStep("fetching main user", async () => {
|
|
40
|
+
const r = await apiClient.database.listMysqlUsers({
|
|
41
|
+
pathParameters: { databaseId },
|
|
42
|
+
});
|
|
43
|
+
assertStatus(r, 200);
|
|
44
|
+
const mainUser = r.data.find((u) => u.mainUser);
|
|
45
|
+
if (!mainUser) {
|
|
46
|
+
throw new Error("No main user found");
|
|
47
|
+
}
|
|
48
|
+
return mainUser;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from "@oclif/core";
|
|
2
|
+
import { MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
3
|
+
import { ArgOutput, FlagOutput } from "@oclif/core/lib/interfaces/parser.js";
|
|
4
|
+
export declare const mysqlConnectionFlags: {
|
|
5
|
+
"mysql-password": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
6
|
+
};
|
|
7
|
+
export declare const mysqlArgs: {
|
|
8
|
+
"database-id": import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
9
|
+
};
|
|
10
|
+
export declare function withMySQLId(apiClient: MittwaldAPIV2Client, flags: FlagOutput, args: ArgOutput, cfg: Config): Promise<string>;
|