faros-airbyte-cdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/lib/connector.d.ts +17 -0
- package/lib/connector.js +7 -0
- package/lib/connector.js.map +1 -0
- package/lib/destinations/destination-runner.d.ts +17 -0
- package/lib/destinations/destination-runner.js +151 -0
- package/lib/destinations/destination-runner.js.map +1 -0
- package/lib/destinations/destination.d.ts +13 -0
- package/lib/destinations/destination.js +12 -0
- package/lib/destinations/destination.js.map +1 -0
- package/lib/errors.d.ts +2 -0
- package/lib/errors.js +61 -0
- package/lib/errors.js.map +1 -0
- package/lib/help.d.ts +22 -0
- package/lib/help.js +371 -0
- package/lib/help.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +31 -0
- package/lib/index.js.map +1 -0
- package/lib/logger.d.ts +21 -0
- package/lib/logger.js +100 -0
- package/lib/logger.js.map +1 -0
- package/lib/prompts.d.ts +14 -0
- package/lib/prompts.js +28 -0
- package/lib/prompts.js.map +1 -0
- package/lib/protocol.d.ts +189 -0
- package/lib/protocol.js +181 -0
- package/lib/protocol.js.map +1 -0
- package/lib/runner.d.ts +5 -0
- package/lib/runner.js +18 -0
- package/lib/runner.js.map +1 -0
- package/lib/sources/source-base.d.ts +59 -0
- package/lib/sources/source-base.js +168 -0
- package/lib/sources/source-base.js.map +1 -0
- package/lib/sources/source-runner.d.ts +17 -0
- package/lib/sources/source-runner.js +154 -0
- package/lib/sources/source-runner.js.map +1 -0
- package/lib/sources/source.d.ts +20 -0
- package/lib/sources/source.js +12 -0
- package/lib/sources/source.js.map +1 -0
- package/lib/sources/streams/stream-base.d.ts +94 -0
- package/lib/sources/streams/stream-base.js +139 -0
- package/lib/sources/streams/stream-base.js.map +1 -0
- package/lib/spec-loader.d.ts +4 -0
- package/lib/spec-loader.js +23 -0
- package/lib/spec-loader.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/utils.d.ts +13 -0
- package/lib/utils.js +77 -0
- package/lib/utils.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AirbyteConfig, AirbyteConnectionStatusMessage, AirbyteSpec } from './protocol';
|
|
2
|
+
export declare abstract class AirbyteConnector {
|
|
3
|
+
/**
|
|
4
|
+
* @returns the spec for this integration. The spec is a JSON-Schema object
|
|
5
|
+
* describing the required configurations (e.g: username and password)
|
|
6
|
+
* required to run this integration.
|
|
7
|
+
*/
|
|
8
|
+
abstract spec(): Promise<AirbyteSpec>;
|
|
9
|
+
/**
|
|
10
|
+
* Tests if the input configuration can be used to successfully connect to the
|
|
11
|
+
* integration e.g: if a provided Stripe API token can be used to connect to
|
|
12
|
+
* the Stripe API.
|
|
13
|
+
*
|
|
14
|
+
* @returns Whether the check succeeds or fails with an error message.
|
|
15
|
+
*/
|
|
16
|
+
abstract check(config: AirbyteConfig): Promise<AirbyteConnectionStatusMessage>;
|
|
17
|
+
}
|
package/lib/connector.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":";;;AAMA,MAAsB,gBAAgB;CAkBrC;AAlBD,4CAkBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AirbyteLogger } from '../logger';
|
|
3
|
+
import { AirbyteConfig } from '../protocol';
|
|
4
|
+
import { Runner } from '../runner';
|
|
5
|
+
import { AirbyteDestination } from './destination';
|
|
6
|
+
export declare class AirbyteDestinationRunner<Config extends AirbyteConfig> extends Runner {
|
|
7
|
+
protected readonly logger: AirbyteLogger;
|
|
8
|
+
protected readonly destination: AirbyteDestination<Config>;
|
|
9
|
+
constructor(logger: AirbyteLogger, destination: AirbyteDestination<Config>);
|
|
10
|
+
mainCommand(): Command;
|
|
11
|
+
specCommand(): Command;
|
|
12
|
+
checkCommand(): Command;
|
|
13
|
+
writeCommand(): Command;
|
|
14
|
+
specPrettyCommand(): Command;
|
|
15
|
+
airbyteLocalCLIWizardCommand(): Command;
|
|
16
|
+
private loadConfig;
|
|
17
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AirbyteDestinationRunner = void 0;
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const errors_1 = require("../errors");
|
|
12
|
+
const help_1 = require("../help");
|
|
13
|
+
const runner_1 = require("../runner");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
class AirbyteDestinationRunner extends runner_1.Runner {
|
|
16
|
+
constructor(logger, destination) {
|
|
17
|
+
super(logger);
|
|
18
|
+
this.logger = logger;
|
|
19
|
+
this.destination = destination;
|
|
20
|
+
}
|
|
21
|
+
mainCommand() {
|
|
22
|
+
return new commander_1.Command()
|
|
23
|
+
.name('main')
|
|
24
|
+
.version('v' + utils_1.PACKAGE_VERSION)
|
|
25
|
+
.addCommand(this.specCommand())
|
|
26
|
+
.addCommand(this.specPrettyCommand())
|
|
27
|
+
.addCommand(this.airbyteLocalCLIWizardCommand())
|
|
28
|
+
.addCommand(this.checkCommand())
|
|
29
|
+
.addCommand(this.writeCommand());
|
|
30
|
+
}
|
|
31
|
+
specCommand() {
|
|
32
|
+
return new commander_1.Command()
|
|
33
|
+
.command('spec')
|
|
34
|
+
.description('spec command')
|
|
35
|
+
.alias('s')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
const spec = await this.destination.spec();
|
|
38
|
+
// Expected output
|
|
39
|
+
this.logger.write(spec);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
checkCommand() {
|
|
43
|
+
return new commander_1.Command()
|
|
44
|
+
.command('check')
|
|
45
|
+
.description('check command')
|
|
46
|
+
.alias('c')
|
|
47
|
+
.requiredOption('--config <path to json>', 'config json')
|
|
48
|
+
.action(async (opts) => {
|
|
49
|
+
const config = require(path_1.default.resolve(opts.config));
|
|
50
|
+
const status = await this.destination.check(config);
|
|
51
|
+
// Expected output
|
|
52
|
+
this.logger.write(status);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
writeCommand() {
|
|
56
|
+
return new commander_1.Command()
|
|
57
|
+
.command('write')
|
|
58
|
+
.description('write command')
|
|
59
|
+
.alias('w')
|
|
60
|
+
.requiredOption('--config <path to json>', 'config json')
|
|
61
|
+
.requiredOption('--catalog <path to json>', 'catalog json')
|
|
62
|
+
.option('--dry-run', 'dry run to skip writing records to destination', false)
|
|
63
|
+
.action(async (opts) => {
|
|
64
|
+
const { catalog, spec, config } = await this.loadConfig(opts);
|
|
65
|
+
this.logger.info(`Config: ${(0, utils_1.redactConfig)(config, spec)}`);
|
|
66
|
+
this.logger.info(`Catalog: ${JSON.stringify(catalog)}`);
|
|
67
|
+
try {
|
|
68
|
+
process.stdin.setEncoding('utf-8');
|
|
69
|
+
const iter = this.destination.write(config, catalog, process.stdin, opts.dryRun);
|
|
70
|
+
for await (const message of iter) {
|
|
71
|
+
this.logger.write(message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
const w = (0, errors_1.wrapApiError)(e);
|
|
76
|
+
const s = JSON.stringify(w);
|
|
77
|
+
this.logger.error(`Encountered an error while writing to destination: ${w} - ${s}`, w.stack);
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
process.stdin.destroy();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
specPrettyCommand() {
|
|
86
|
+
return new commander_1.Command()
|
|
87
|
+
.command('spec-pretty')
|
|
88
|
+
.description('pretty spec command')
|
|
89
|
+
.action(async () => {
|
|
90
|
+
const spec = await this.destination.spec();
|
|
91
|
+
const rows = (0, help_1.traverseObject)(spec.spec.connectionSpecification, [
|
|
92
|
+
// Prefix argument names with --dst
|
|
93
|
+
'--dst',
|
|
94
|
+
],
|
|
95
|
+
// Assign section = 0 to the root object's row, which
|
|
96
|
+
// will be removed, so that the remaining rows are
|
|
97
|
+
// numbered 1..N
|
|
98
|
+
0);
|
|
99
|
+
// Drop the first row since it corresponds to the root
|
|
100
|
+
// (connectionSpecification) object
|
|
101
|
+
rows.shift();
|
|
102
|
+
console.log((0, help_1.helpTable)(rows));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
airbyteLocalCLIWizardCommand() {
|
|
106
|
+
return new commander_1.Command()
|
|
107
|
+
.command('airbyte-local-cli-wizard')
|
|
108
|
+
.option('--json <path to json>', 'Output the destination configuration as JSON')
|
|
109
|
+
.option('--spec-file <path to spec>', 'Path to the spec file. If not provided, the spec will be fetched from the destination')
|
|
110
|
+
.option('--include-deprecated-fields', 'Include fields marked as deprecated in the spec', false)
|
|
111
|
+
.option('--include-hidden-fields', 'Include fields marked as hidden in the spec', false)
|
|
112
|
+
.description('Run a wizard command to prepare arguments for Airbyte Local CLI')
|
|
113
|
+
.action(async (opts) => {
|
|
114
|
+
const spec = opts.specFile
|
|
115
|
+
? JSON.parse(fs_1.default.readFileSync(opts.specFile, 'utf8'))
|
|
116
|
+
: await this.destination.spec();
|
|
117
|
+
const rows = (0, help_1.traverseObject)(spec.spec.connectionSpecification, opts.json
|
|
118
|
+
? []
|
|
119
|
+
: [
|
|
120
|
+
// Prefix argument names with --dst
|
|
121
|
+
'--dst',
|
|
122
|
+
],
|
|
123
|
+
// Assign section = 0 to the root object's row
|
|
124
|
+
0, opts.includeDeprecatedFields, opts.includeHiddenFields);
|
|
125
|
+
if (opts.json) {
|
|
126
|
+
fs_1.default.writeFileSync(opts.json, await (0, help_1.buildJson)(rows));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.log('\n\nUse the arguments below when running this destination' +
|
|
130
|
+
' with Airbyte Local CLI (https://github.com/faros-ai/airbyte-local-cli):' +
|
|
131
|
+
`\n\n${await (0, help_1.buildArgs)(rows)}`);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async loadConfig(opts) {
|
|
136
|
+
try {
|
|
137
|
+
const catalog = require(path_1.default.resolve(opts.catalog));
|
|
138
|
+
const spec = await this.destination.spec();
|
|
139
|
+
const config = (0, utils_1.withDefaults)(require(path_1.default.resolve(opts.config)), spec);
|
|
140
|
+
return { catalog, spec, config };
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
const w = (0, errors_1.wrapApiError)(e);
|
|
144
|
+
const s = JSON.stringify(w);
|
|
145
|
+
this.logger.error(`Encountered an error while loading configuration: ${w} - ${s}`, w.stack);
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.AirbyteDestinationRunner = AirbyteDestinationRunner;
|
|
151
|
+
//# sourceMappingURL=destination-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination-runner.js","sourceRoot":"","sources":["../../src/destinations/destination-runner.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;AAEvD,yCAAkC;AAClC,4CAAoB;AACpB,gDAAwB;AAExB,sCAAuC;AACvC,kCAAwE;AAGxE,sCAAiC;AACjC,oCAAqE;AAGrE,MAAa,wBAEX,SAAQ,eAAM;IACd,YACqB,MAAqB,EACrB,WAAuC;QAE1D,KAAK,CAAC,MAAM,CAAC,CAAC;QAHK,WAAM,GAAN,MAAM,CAAe;QACrB,gBAAW,GAAX,WAAW,CAA4B;IAG5D,CAAC;IAED,WAAW;QACT,OAAO,IAAI,mBAAO,EAAE;aACjB,IAAI,C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AAC,EAAE,EAC/D,CAAC,CAAC,KAAK,CACR,CAAC;YACF,MAAM,CAAC,CAAC;SACT;IACH,CAAC;CACF;AAhMD,4DAgMC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AirbyteConnector } from '../connector';
|
|
3
|
+
import { AirbyteConfig, AirbyteConfiguredCatalog, AirbyteStateMessage } from '../protocol';
|
|
4
|
+
/**
|
|
5
|
+
* Airbyte Destination
|
|
6
|
+
* https://docs.airbyte.io/understanding-airbyte/airbyte-specification#destination
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class AirbyteDestination<Config extends AirbyteConfig> extends AirbyteConnector {
|
|
9
|
+
/**
|
|
10
|
+
* Implement to define how the connector writes data to the destination
|
|
11
|
+
*/
|
|
12
|
+
abstract write(config: Config, catalog: AirbyteConfiguredCatalog, stdin: NodeJS.ReadStream, dryRun: boolean): AsyncGenerator<AirbyteStateMessage>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AirbyteDestination = void 0;
|
|
4
|
+
const connector_1 = require("../connector");
|
|
5
|
+
/**
|
|
6
|
+
* Airbyte Destination
|
|
7
|
+
* https://docs.airbyte.io/understanding-airbyte/airbyte-specification#destination
|
|
8
|
+
*/
|
|
9
|
+
class AirbyteDestination extends connector_1.AirbyteConnector {
|
|
10
|
+
}
|
|
11
|
+
exports.AirbyteDestination = AirbyteDestination;
|
|
12
|
+
//# sourceMappingURL=destination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.js","sourceRoot":"","sources":["../../src/destinations/destination.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAO9C;;;GAGG;AACH,MAAsB,kBAEpB,SAAQ,4BAAgB;CAUzB;AAZD,gDAYC"}
|
package/lib/errors.d.ts
ADDED
package/lib/errors.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.wrapApiError = void 0;
|
|
7
|
+
const stream_1 = __importDefault(require("stream"));
|
|
8
|
+
const verror_1 = require("verror");
|
|
9
|
+
function formatMessageData(data) {
|
|
10
|
+
return data instanceof stream_1.default.Readable ? '[Stream]' : data;
|
|
11
|
+
}
|
|
12
|
+
function formatRequest(req) {
|
|
13
|
+
return {
|
|
14
|
+
baseUrl: req === null || req === void 0 ? void 0 : req.baseURL,
|
|
15
|
+
url: req === null || req === void 0 ? void 0 : req.url,
|
|
16
|
+
method: req === null || req === void 0 ? void 0 : req.method,
|
|
17
|
+
params: req === null || req === void 0 ? void 0 : req.params,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function formatResponse(res) {
|
|
21
|
+
return {
|
|
22
|
+
status: res.status,
|
|
23
|
+
headers: res.headers,
|
|
24
|
+
data: formatMessageData(res.data),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function isAxiosError(error) {
|
|
28
|
+
return error.isAxiosError;
|
|
29
|
+
}
|
|
30
|
+
/** Strips verbose properties that libraries like Axios attach to errors */
|
|
31
|
+
function wrapApiError(error, message) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!isAxiosError(error)) {
|
|
34
|
+
const cause = verror_1.VError.cause(error);
|
|
35
|
+
if (cause) {
|
|
36
|
+
// Wrap the cause recursively since it could contain an Axios error
|
|
37
|
+
error = new verror_1.WError(wrapApiError(cause), error.message);
|
|
38
|
+
}
|
|
39
|
+
return message ? new verror_1.WError(error, message) : error;
|
|
40
|
+
}
|
|
41
|
+
const prefix = message ? `${message}: ` : '';
|
|
42
|
+
const res = error.response;
|
|
43
|
+
const info = {
|
|
44
|
+
req: error.request
|
|
45
|
+
? formatRequest({ ...error.config, ...error.request })
|
|
46
|
+
: formatRequest(error.config),
|
|
47
|
+
res: res ? formatResponse(res) : undefined,
|
|
48
|
+
};
|
|
49
|
+
if (!res) {
|
|
50
|
+
return new verror_1.VError({ info }, '%sAPI request failed: %s', prefix, error.message);
|
|
51
|
+
}
|
|
52
|
+
const { data, status } = res;
|
|
53
|
+
let msg = `${prefix}API responded with status ${status}`;
|
|
54
|
+
const causeMsg = typeof data == 'string' ? data : (_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
55
|
+
if (causeMsg) {
|
|
56
|
+
msg += `: ${causeMsg}`;
|
|
57
|
+
}
|
|
58
|
+
return new verror_1.VError({ info }, msg);
|
|
59
|
+
}
|
|
60
|
+
exports.wrapApiError = wrapApiError;
|
|
61
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAC5B,mCAAsC;AAEtC,SAAS,iBAAiB,CAAC,IAAS;IAClC,OAAO,IAAI,YAAY,gBAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC;AAED,SAAS,aAAa,CAAC,GAAuB;IAC5C,OAAO;QACL,OAAO,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO;QACrB,GAAG,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,GAAG;QACb,MAAM,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM;QACnB,MAAM,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,GAAkB;IACxC,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,C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MAAM,EAAC,GAAG,GAAG,CAAC;IAC3B,IAAI,GAAG,GAAG,GAAG,MAAM,6BAA6B,MAAM,EAAE,CAAC;IACzD,MAAM,QAAQ,GAAG,OAAO,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,OAAO,CAAC;IACvE,IAAI,QAAQ,EAAE;QACZ,GAAG,IAAI,KAAK,QAAQ,EAAE,CAAC;KACxB;IACD,OAAO,IAAI,eAAM,CAAC,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAjCD,oCAiCC"}
|
package/lib/help.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Dictionary } from 'ts-essentials';
|
|
2
|
+
export interface TableRow {
|
|
3
|
+
title: string;
|
|
4
|
+
path: string;
|
|
5
|
+
section: number;
|
|
6
|
+
children?: ReadonlyArray<number>;
|
|
7
|
+
oneOf?: boolean;
|
|
8
|
+
description?: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
constValue?: string;
|
|
11
|
+
default?: any;
|
|
12
|
+
examples: ReadonlyArray<any>;
|
|
13
|
+
airbyte_secret?: boolean;
|
|
14
|
+
multiline?: boolean;
|
|
15
|
+
type: string;
|
|
16
|
+
items_type?: string;
|
|
17
|
+
enum?: ReadonlyArray<string>;
|
|
18
|
+
}
|
|
19
|
+
export declare function traverseObject(startObject: Dictionary<any>, startPath: string[], section?: number, useDeprecatedFields?: boolean, useHiddenFields?: boolean): TableRow[];
|
|
20
|
+
export declare function helpTable(rows: ReadonlyArray<TableRow>): string;
|
|
21
|
+
export declare function buildJson(rows: ReadonlyArray<TableRow>): Promise<string>;
|
|
22
|
+
export declare function buildArgs(rows: ReadonlyArray<TableRow>): Promise<string>;
|