@daileyos/mcp-server 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { registerScaleTools } from './tools/scale.js';
11
11
  import { registerEnvTools } from './tools/env.js';
12
12
  import { registerDomainTools } from './tools/domains.js';
13
13
  import { registerDbTools } from './tools/db.js';
14
+ import { registerMigrateTools } from './tools/db-migrate.js';
14
15
  import { registerExecRunTools } from './tools/exec-run.js';
15
16
  import { registerProjectTransferTools } from './tools/project-transfer.js';
16
17
  import { registerAdminTools } from './tools/admin.js';
@@ -115,6 +116,7 @@ registerLinkTools(server);
115
116
  registerCredentialRevealTools(server);
116
117
  // Data
117
118
  registerDbTools(server);
119
+ registerMigrateTools(server);
118
120
  registerStorageTools(server);
119
121
  registerBackupTools(server);
120
122
  registerWordPressMigrateTools(server);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM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CAAC,CAAC;AAE7B,qDAAqD;AACrD,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC3B,4BAA4B,CAAC,MAAM,CAAC,CAAC;AAErC,aAAa;AACb,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAEzB,uBAAuB;AACvB,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE5B,2EAA2E;AAC3E,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAE9B,uCAAuC;AACvC,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAE7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerMigrateTools(server: McpServer): void;
3
+ //# sourceMappingURL=db-migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-migrate.d.ts","sourceRoot":"","sources":["../../src/tools/db-migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkGpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,QAgHrD"}
@@ -0,0 +1,153 @@
1
+ import { z } from 'zod';
2
+ import { apiRequest, formatError, textResult } from '../api.js';
3
+ const sshSchema = z
4
+ .object({
5
+ host: z.string().describe('SSH bastion/tunnel host'),
6
+ port: z.number().int().optional().describe('SSH port (default 22)'),
7
+ user: z.string().describe('SSH user'),
8
+ password: z.string().optional().describe('SSH password (do not echo back)'),
9
+ private_key: z.string().optional().describe('SSH private key (PEM)'),
10
+ passphrase: z.string().optional().describe('Passphrase for the private key'),
11
+ })
12
+ .passthrough();
13
+ const sourceSchema = z.object({
14
+ host: z.string().describe('Source database host'),
15
+ port: z.number().int().optional().describe('Source database port'),
16
+ database: z.string().describe('Source database name'),
17
+ user: z.string().describe('Source database user'),
18
+ password: z.string().describe('Source database password — never echoed back in tool output'),
19
+ ssh: sshSchema.optional().describe('Optional SSH tunnel config for reaching the source DB'),
20
+ });
21
+ function progressLines(m) {
22
+ const lines = [
23
+ `Migration ${m.id}`,
24
+ '─'.repeat(40),
25
+ `Status: ${m.status || 'unknown'}`,
26
+ ];
27
+ if (m.phase)
28
+ lines.push(`Phase: ${m.phase}`);
29
+ if (m.message)
30
+ lines.push(`Message: ${m.message}`);
31
+ if (m.rows_total !== undefined && m.rows_total !== null) {
32
+ const copied = m.rows_copied ?? 0;
33
+ lines.push(`Rows: ${copied}/${m.rows_total} copied`);
34
+ }
35
+ else if (m.rows_copied !== undefined && m.rows_copied !== null) {
36
+ lines.push(`Rows: ${m.rows_copied} copied`);
37
+ }
38
+ if (m.target_user)
39
+ lines.push(`Target user: ${m.target_user}`);
40
+ if (m.target_db)
41
+ lines.push(`Target db: ${m.target_db}`);
42
+ if (m.error)
43
+ lines.push(`Error: ${m.error}`);
44
+ if (m.report_json) {
45
+ try {
46
+ const parsed = typeof m.report_json === 'string' ? JSON.parse(m.report_json) : m.report_json;
47
+ if (parsed && typeof parsed === 'object') {
48
+ lines.push(`Report: ${JSON.stringify(parsed)}`);
49
+ }
50
+ }
51
+ catch {
52
+ // report_json did not parse — skip the summary line.
53
+ }
54
+ }
55
+ return lines;
56
+ }
57
+ export function registerMigrateTools(server) {
58
+ server.tool('dailey_db_migrate_start', 'Start a managed database migration from an external source DB into a project\'s managed database. Submits the source connection and kicks off an estimate (dry-run) — it does NOT copy data yet. The server derives the target engine from the project\'s managed DB (mysql | postgres); the source DB must be the SAME engine. Returns a migration id and status="estimating". Poll dailey_db_migrate_status until status="awaiting_confirm", review rows_total, then call dailey_db_migrate_confirm to run the real copy. The source password is used only to connect — it is never echoed back in any output.', {
59
+ project_id: z.string().describe('The project ID (or name) to migrate INTO'),
60
+ source: sourceSchema.describe('External source database connection details'),
61
+ allow_non_empty: z.boolean().optional().describe('Allow migrating into a target DB that already has data'),
62
+ row_ceiling: z.number().int().optional().describe('Optional safety cap on total rows to migrate'),
63
+ }, async ({ project_id, source, allow_non_empty, row_ceiling }) => {
64
+ const body = {
65
+ host: source.host,
66
+ database: source.database,
67
+ user: source.user,
68
+ password: source.password,
69
+ };
70
+ if (source.port !== undefined)
71
+ body.port = source.port;
72
+ if (source.ssh !== undefined)
73
+ body.ssh = source.ssh;
74
+ if (allow_non_empty !== undefined)
75
+ body.allow_non_empty = allow_non_empty;
76
+ if (row_ceiling !== undefined)
77
+ body.row_ceiling = row_ceiling;
78
+ const res = await apiRequest('POST', `/projects/${project_id}/migrations`, body);
79
+ if (!res.ok)
80
+ return textResult(formatError(res));
81
+ const d = res.data;
82
+ const lines = [
83
+ `Migration started`,
84
+ '─'.repeat(40),
85
+ `ID: ${d.id}`,
86
+ `Status: ${d.status}`,
87
+ '',
88
+ `Estimating now. Poll dailey_db_migrate_status project_id=${project_id} id=${d.id} until status=awaiting_confirm,`,
89
+ `then dailey_db_migrate_confirm to run the real copy.`,
90
+ ];
91
+ return textResult(lines.join('\n'));
92
+ });
93
+ server.tool('dailey_db_migrate_status', 'Check the status/progress of a managed migration. With an id, returns that migration\'s progress fields (status, phase, message, rows_total, rows_copied, target_user, target_db, error). Without an id, lists all migrations for the project. Live progress is rows_copied/rows_total. Terminal statuses are completed | failed | canceled.', {
94
+ project_id: z.string().describe('The project ID (or name)'),
95
+ id: z.string().optional().describe('Migration id. Omit to list all migrations for the project.'),
96
+ }, async ({ project_id, id }) => {
97
+ if (!id) {
98
+ const res = await apiRequest('GET', `/projects/${project_id}/migrations`);
99
+ if (!res.ok)
100
+ return textResult(formatError(res));
101
+ const migrations = res.data.migrations || [];
102
+ if (migrations.length === 0)
103
+ return textResult('No migrations for this project.');
104
+ const lines = [`Migrations (${migrations.length})`, '─'.repeat(40)];
105
+ for (const m of migrations) {
106
+ const rows = m.rows_total !== undefined && m.rows_total !== null
107
+ ? ` ${m.rows_copied ?? 0}/${m.rows_total} rows`
108
+ : '';
109
+ lines.push(`• ${m.id} status=${m.status}${m.phase ? ` phase=${m.phase}` : ''}${rows}`);
110
+ }
111
+ return textResult(lines.join('\n'));
112
+ }
113
+ const res = await apiRequest('GET', `/projects/${project_id}/migrations/${id}`);
114
+ if (!res.ok)
115
+ return textResult(formatError(res));
116
+ return textResult(progressLines(res.data.migration).join('\n'));
117
+ });
118
+ server.tool('dailey_db_migrate_confirm', 'Confirm a managed migration that is awaiting confirmation. This triggers the REAL data copy and mints a temporary target user for the load — it is only valid from status=awaiting_confirm. Returns the id and status="queued". After confirming, poll dailey_db_migrate_status to watch rows_copied/rows_total until a terminal status (completed | failed | canceled).', {
119
+ project_id: z.string().describe('The project ID (or name)'),
120
+ id: z.string().describe('Migration id to confirm (must be awaiting_confirm)'),
121
+ }, async ({ project_id, id }) => {
122
+ const res = await apiRequest('POST', `/projects/${project_id}/migrations/${id}/confirm`);
123
+ if (!res.ok)
124
+ return textResult(formatError(res));
125
+ const d = res.data;
126
+ const lines = [
127
+ `Migration confirmed — real data copy queued`,
128
+ '─'.repeat(40),
129
+ `ID: ${d.id}`,
130
+ `Status: ${d.status}`,
131
+ '',
132
+ `Poll dailey_db_migrate_status project_id=${project_id} id=${d.id} to watch progress to completion.`,
133
+ ];
134
+ return textResult(lines.join('\n'));
135
+ });
136
+ server.tool('dailey_db_migrate_cancel', 'Cancel a managed migration. Valid from status pending | estimating | awaiting_confirm | queued (409 otherwise). Returns the id and status="canceled".', {
137
+ project_id: z.string().describe('The project ID (or name)'),
138
+ id: z.string().describe('Migration id to cancel'),
139
+ }, async ({ project_id, id }) => {
140
+ const res = await apiRequest('POST', `/projects/${project_id}/migrations/${id}/cancel`);
141
+ if (!res.ok)
142
+ return textResult(formatError(res));
143
+ const d = res.data;
144
+ const lines = [
145
+ `Migration canceled`,
146
+ '─'.repeat(40),
147
+ `ID: ${d.id}`,
148
+ `Status: ${d.status}`,
149
+ ];
150
+ return textResult(lines.join('\n'));
151
+ });
152
+ }
153
+ //# sourceMappingURL=db-migrate.js.map
@@ -0,0 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AC;KAClD,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE;QAC3B,MAAM,GAAG,GAAG,MAAM,UAAU,CAAiB,MAAM,EAAE,aAAa,UAAU,eAAe,EAAE,SAAS,CAAC,CAAC;QACxG,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC;QACnB,MAAM,KAAK,GAAG;YACZ,oBAAoB;YACpB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACd,WAAW,CAAC,CAAC,EAAE,EAAE;YACjB,WAAW,CAAC,CAAC,MAAM,EAAE;SACtB,CAAC;QACF,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daileyos/mcp-server",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Dailey OS MCP server for Claude Code and AI assistants",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ import { registerScaleTools } from './tools/scale.js';
13
13
  import { registerEnvTools } from './tools/env.js';
14
14
  import { registerDomainTools } from './tools/domains.js';
15
15
  import { registerDbTools } from './tools/db.js';
16
+ import { registerMigrateTools } from './tools/db-migrate.js';
16
17
  import { registerExecRunTools } from './tools/exec-run.js';
17
18
  import { registerProjectTransferTools } from './tools/project-transfer.js';
18
19
  import { registerAdminTools } from './tools/admin.js';
@@ -135,6 +136,7 @@ registerCredentialRevealTools(server);
135
136
 
136
137
  // Data
137
138
  registerDbTools(server);
139
+ registerMigrateTools(server);
138
140
  registerStorageTools(server);
139
141
  registerBackupTools(server);
140
142
  registerWordPressMigrateTools(server);
@@ -0,0 +1,211 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ import { apiRequest, formatError, textResult } from '../api.js';
4
+
5
+ // MigrationRow as returned by the customer-api managed-migrations endpoints.
6
+ // callback_token_hash is never returned by the server, and we never echo the
7
+ // source password back in tool output (security hard rule).
8
+ interface MigrationRow {
9
+ id: string;
10
+ project_id: string;
11
+ engine: string;
12
+ status: string;
13
+ phase?: string;
14
+ message?: string;
15
+ rows_total?: number;
16
+ rows_copied?: number;
17
+ target_user?: string;
18
+ target_db?: string;
19
+ report_json?: unknown;
20
+ error?: string;
21
+ dispatch_count?: number;
22
+ created_at?: string;
23
+ updated_at?: string;
24
+ }
25
+
26
+ interface StartResponse {
27
+ id: string;
28
+ status: string;
29
+ }
30
+
31
+ interface ListResponse {
32
+ migrations: MigrationRow[];
33
+ }
34
+
35
+ interface GetResponse {
36
+ migration: MigrationRow;
37
+ }
38
+
39
+ interface ConfirmResponse {
40
+ id: string;
41
+ status: string;
42
+ }
43
+
44
+ interface CancelResponse {
45
+ id: string;
46
+ status: string;
47
+ }
48
+
49
+ const sshSchema = z
50
+ .object({
51
+ host: z.string().describe('SSH bastion/tunnel host'),
52
+ port: z.number().int().optional().describe('SSH port (default 22)'),
53
+ user: z.string().describe('SSH user'),
54
+ password: z.string().optional().describe('SSH password (do not echo back)'),
55
+ private_key: z.string().optional().describe('SSH private key (PEM)'),
56
+ passphrase: z.string().optional().describe('Passphrase for the private key'),
57
+ })
58
+ .passthrough();
59
+
60
+ const sourceSchema = z.object({
61
+ host: z.string().describe('Source database host'),
62
+ port: z.number().int().optional().describe('Source database port'),
63
+ database: z.string().describe('Source database name'),
64
+ user: z.string().describe('Source database user'),
65
+ password: z.string().describe('Source database password — never echoed back in tool output'),
66
+ ssh: sshSchema.optional().describe('Optional SSH tunnel config for reaching the source DB'),
67
+ });
68
+
69
+ function progressLines(m: MigrationRow): string[] {
70
+ const lines = [
71
+ `Migration ${m.id}`,
72
+ '─'.repeat(40),
73
+ `Status: ${m.status || 'unknown'}`,
74
+ ];
75
+ if (m.phase) lines.push(`Phase: ${m.phase}`);
76
+ if (m.message) lines.push(`Message: ${m.message}`);
77
+ if (m.rows_total !== undefined && m.rows_total !== null) {
78
+ const copied = m.rows_copied ?? 0;
79
+ lines.push(`Rows: ${copied}/${m.rows_total} copied`);
80
+ } else if (m.rows_copied !== undefined && m.rows_copied !== null) {
81
+ lines.push(`Rows: ${m.rows_copied} copied`);
82
+ }
83
+ if (m.target_user) lines.push(`Target user: ${m.target_user}`);
84
+ if (m.target_db) lines.push(`Target db: ${m.target_db}`);
85
+ if (m.error) lines.push(`Error: ${m.error}`);
86
+ if (m.report_json) {
87
+ try {
88
+ const parsed = typeof m.report_json === 'string' ? JSON.parse(m.report_json) : m.report_json;
89
+ if (parsed && typeof parsed === 'object') {
90
+ lines.push(`Report: ${JSON.stringify(parsed)}`);
91
+ }
92
+ } catch {
93
+ // report_json did not parse — skip the summary line.
94
+ }
95
+ }
96
+ return lines;
97
+ }
98
+
99
+ export function registerMigrateTools(server: McpServer) {
100
+ server.tool(
101
+ 'dailey_db_migrate_start',
102
+ 'Start a managed database migration from an external source DB into a project\'s managed database. Submits the source connection and kicks off an estimate (dry-run) — it does NOT copy data yet. The server derives the target engine from the project\'s managed DB (mysql | postgres); the source DB must be the SAME engine. Returns a migration id and status="estimating". Poll dailey_db_migrate_status until status="awaiting_confirm", review rows_total, then call dailey_db_migrate_confirm to run the real copy. The source password is used only to connect — it is never echoed back in any output.',
103
+ {
104
+ project_id: z.string().describe('The project ID (or name) to migrate INTO'),
105
+ source: sourceSchema.describe('External source database connection details'),
106
+ allow_non_empty: z.boolean().optional().describe('Allow migrating into a target DB that already has data'),
107
+ row_ceiling: z.number().int().optional().describe('Optional safety cap on total rows to migrate'),
108
+ },
109
+ async ({ project_id, source, allow_non_empty, row_ceiling }) => {
110
+ const body: Record<string, unknown> = {
111
+ host: source.host,
112
+ database: source.database,
113
+ user: source.user,
114
+ password: source.password,
115
+ };
116
+ if (source.port !== undefined) body.port = source.port;
117
+ if (source.ssh !== undefined) body.ssh = source.ssh;
118
+ if (allow_non_empty !== undefined) body.allow_non_empty = allow_non_empty;
119
+ if (row_ceiling !== undefined) body.row_ceiling = row_ceiling;
120
+
121
+ const res = await apiRequest<StartResponse>('POST', `/projects/${project_id}/migrations`, body);
122
+ if (!res.ok) return textResult(formatError(res));
123
+
124
+ const d = res.data;
125
+ const lines = [
126
+ `Migration started`,
127
+ '─'.repeat(40),
128
+ `ID: ${d.id}`,
129
+ `Status: ${d.status}`,
130
+ '',
131
+ `Estimating now. Poll dailey_db_migrate_status project_id=${project_id} id=${d.id} until status=awaiting_confirm,`,
132
+ `then dailey_db_migrate_confirm to run the real copy.`,
133
+ ];
134
+ return textResult(lines.join('\n'));
135
+ },
136
+ );
137
+
138
+ server.tool(
139
+ 'dailey_db_migrate_status',
140
+ 'Check the status/progress of a managed migration. With an id, returns that migration\'s progress fields (status, phase, message, rows_total, rows_copied, target_user, target_db, error). Without an id, lists all migrations for the project. Live progress is rows_copied/rows_total. Terminal statuses are completed | failed | canceled.',
141
+ {
142
+ project_id: z.string().describe('The project ID (or name)'),
143
+ id: z.string().optional().describe('Migration id. Omit to list all migrations for the project.'),
144
+ },
145
+ async ({ project_id, id }) => {
146
+ if (!id) {
147
+ const res = await apiRequest<ListResponse>('GET', `/projects/${project_id}/migrations`);
148
+ if (!res.ok) return textResult(formatError(res));
149
+ const migrations = res.data.migrations || [];
150
+ if (migrations.length === 0) return textResult('No migrations for this project.');
151
+ const lines = [`Migrations (${migrations.length})`, '─'.repeat(40)];
152
+ for (const m of migrations) {
153
+ const rows =
154
+ m.rows_total !== undefined && m.rows_total !== null
155
+ ? ` ${m.rows_copied ?? 0}/${m.rows_total} rows`
156
+ : '';
157
+ lines.push(`• ${m.id} status=${m.status}${m.phase ? ` phase=${m.phase}` : ''}${rows}`);
158
+ }
159
+ return textResult(lines.join('\n'));
160
+ }
161
+
162
+ const res = await apiRequest<GetResponse>('GET', `/projects/${project_id}/migrations/${id}`);
163
+ if (!res.ok) return textResult(formatError(res));
164
+ return textResult(progressLines(res.data.migration).join('\n'));
165
+ },
166
+ );
167
+
168
+ server.tool(
169
+ 'dailey_db_migrate_confirm',
170
+ 'Confirm a managed migration that is awaiting confirmation. This triggers the REAL data copy and mints a temporary target user for the load — it is only valid from status=awaiting_confirm. Returns the id and status="queued". After confirming, poll dailey_db_migrate_status to watch rows_copied/rows_total until a terminal status (completed | failed | canceled).',
171
+ {
172
+ project_id: z.string().describe('The project ID (or name)'),
173
+ id: z.string().describe('Migration id to confirm (must be awaiting_confirm)'),
174
+ },
175
+ async ({ project_id, id }) => {
176
+ const res = await apiRequest<ConfirmResponse>('POST', `/projects/${project_id}/migrations/${id}/confirm`);
177
+ if (!res.ok) return textResult(formatError(res));
178
+ const d = res.data;
179
+ const lines = [
180
+ `Migration confirmed — real data copy queued`,
181
+ '─'.repeat(40),
182
+ `ID: ${d.id}`,
183
+ `Status: ${d.status}`,
184
+ '',
185
+ `Poll dailey_db_migrate_status project_id=${project_id} id=${d.id} to watch progress to completion.`,
186
+ ];
187
+ return textResult(lines.join('\n'));
188
+ },
189
+ );
190
+
191
+ server.tool(
192
+ 'dailey_db_migrate_cancel',
193
+ 'Cancel a managed migration. Valid from status pending | estimating | awaiting_confirm | queued (409 otherwise). Returns the id and status="canceled".',
194
+ {
195
+ project_id: z.string().describe('The project ID (or name)'),
196
+ id: z.string().describe('Migration id to cancel'),
197
+ },
198
+ async ({ project_id, id }) => {
199
+ const res = await apiRequest<CancelResponse>('POST', `/projects/${project_id}/migrations/${id}/cancel`);
200
+ if (!res.ok) return textResult(formatError(res));
201
+ const d = res.data;
202
+ const lines = [
203
+ `Migration canceled`,
204
+ '─'.repeat(40),
205
+ `ID: ${d.id}`,
206
+ `Status: ${d.status}`,
207
+ ];
208
+ return textResult(lines.join('\n'));
209
+ },
210
+ );
211
+ }