stepzen 0.43.0 → 0.44.0-beta.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/README.md +145 -2
- package/lib/commands/import/db2.d.ts +78 -0
- package/lib/commands/import/db2.d.ts.map +1 -0
- package/lib/commands/import/db2.js +241 -0
- package/lib/commands/import/db2.js.map +1 -0
- package/lib/commands/import/index.d.ts.map +1 -1
- package/lib/commands/import/index.js +27 -5
- package/lib/commands/import/index.js.map +1 -1
- package/lib/commands/import/oracle.d.ts +73 -0
- package/lib/commands/import/oracle.d.ts.map +1 -0
- package/lib/commands/import/oracle.js +232 -0
- package/lib/commands/import/oracle.js.map +1 -0
- package/lib/generate/sql2sdl.d.ts +11 -2
- package/lib/generate/sql2sdl.d.ts.map +1 -1
- package/lib/generate/sql2sdl.js +9 -0
- package/lib/generate/sql2sdl.js.map +1 -1
- package/oclif.manifest.json +232 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ $ npm install -g stepzen
|
|
|
30
30
|
$ stepzen COMMAND
|
|
31
31
|
running command...
|
|
32
32
|
$ stepzen (--version|-v)
|
|
33
|
-
stepzen/0.
|
|
33
|
+
stepzen/0.44.0-beta.0 linux-x64 node-v18.20.4
|
|
34
34
|
$ stepzen --help [COMMAND]
|
|
35
35
|
USAGE
|
|
36
36
|
$ stepzen COMMAND
|
|
@@ -54,9 +54,11 @@ $ stepzen deploy ENDPOINT --schema=schema [--configurationsets=cs1[,cs2[,..]]]`]
|
|
|
54
54
|
* [`stepzen help [COMMANDS]`](#stepzen-help-commands)
|
|
55
55
|
* [`stepzen import [SOURCE]`](#stepzen-import-source)
|
|
56
56
|
* [`stepzen import curl`](#stepzen-import-curl)
|
|
57
|
+
* [`stepzen import db2 [DSN]`](#stepzen-import-db2-dsn)
|
|
57
58
|
* [`stepzen import flow [FLOW]`](#stepzen-import-flow-flow)
|
|
58
59
|
* [`stepzen import graphql [URL]`](#stepzen-import-graphql-url)
|
|
59
60
|
* [`stepzen import mysql [DSN]`](#stepzen-import-mysql-dsn)
|
|
61
|
+
* [`stepzen import oracle [DSN]`](#stepzen-import-oracle-dsn)
|
|
60
62
|
* [`stepzen import postgres [DSN]`](#stepzen-import-postgres-dsn)
|
|
61
63
|
* [`stepzen import postgresql [DSN]`](#stepzen-import-postgresql-dsn)
|
|
62
64
|
* [`stepzen import singlestore [DSN]`](#stepzen-import-singlestore-dsn)
|
|
@@ -180,7 +182,7 @@ USAGE
|
|
|
180
182
|
$ stepzen import [SOURCE] [-h] [--non-interactive] [--dir <value>]
|
|
181
183
|
|
|
182
184
|
ARGUMENTS
|
|
183
|
-
SOURCE kind of the data source: curl, graphql, mysql, postgresql, snowflake (or a full DSN string)
|
|
185
|
+
SOURCE kind of the data source: curl, graphql, mysql, postgresql, snowflake, db2, oracle (or a full DSN string)
|
|
184
186
|
|
|
185
187
|
FLAGS
|
|
186
188
|
-h, --help Show CLI help
|
|
@@ -255,6 +257,78 @@ DESCRIPTION
|
|
|
255
257
|
through a StepZen API, and adds the generated types and a query field into your GraphQL schema.
|
|
256
258
|
```
|
|
257
259
|
|
|
260
|
+
## `stepzen import db2 [DSN]`
|
|
261
|
+
|
|
262
|
+
Import a schema for a Db2 data source into your GraphQL API.
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
USAGE
|
|
266
|
+
$ stepzen import db2 [DSN] [-h] [--non-interactive] [--dir <value>] [--name <value>] [--db-host <value>]
|
|
267
|
+
[--db-user <value>] [--db-password <value>] [--db-database <value>] [--db-schema <value>] [--db-link-types]
|
|
268
|
+
[--db-include tables-only|views-only|tables-and-views] [--db-use-deprecated-2022-naming] [--ssl-connection]
|
|
269
|
+
|
|
270
|
+
ARGUMENTS
|
|
271
|
+
DSN (optional) Data Source Name (DSN) of a Db2 database.
|
|
272
|
+
Example: 'jdbc:db2://host:port/db:user=username;password=password;schema=schema;sslConnection=true/false;'
|
|
273
|
+
|
|
274
|
+
Flags, such as --db-host, override the corresponding parts of the DSN (if both are provided).
|
|
275
|
+
|
|
276
|
+
FLAGS
|
|
277
|
+
-h, --help
|
|
278
|
+
Show CLI help
|
|
279
|
+
|
|
280
|
+
--db-database=<value>
|
|
281
|
+
Name of database to import
|
|
282
|
+
|
|
283
|
+
--db-host=<value>
|
|
284
|
+
Database host and optional port (as HOST[:PORT])
|
|
285
|
+
|
|
286
|
+
--db-include=<option>
|
|
287
|
+
Should the generated GraphQL schema be based only on database views, only on tables or on both
|
|
288
|
+
<options: tables-only|views-only|tables-and-views>
|
|
289
|
+
|
|
290
|
+
--db-link-types
|
|
291
|
+
Automatically link types based on foreign key relationships using @materializer
|
|
292
|
+
(https://stepzen.com/docs/features/linking-types)
|
|
293
|
+
|
|
294
|
+
--db-password=<value>
|
|
295
|
+
Database password
|
|
296
|
+
|
|
297
|
+
--db-schema=<value>
|
|
298
|
+
Database schema to import tables from (default: public)
|
|
299
|
+
|
|
300
|
+
--db-use-deprecated-2022-naming
|
|
301
|
+
Use the deprecated pre-2023 naming convention in the generated GraphQL schema:
|
|
302
|
+
- the generated type and property names are auto-capitalized into PascalCase
|
|
303
|
+
- the generated field names use the getCustomer and getCustomerList style.
|
|
304
|
+
|
|
305
|
+
On the other hand, when using the default naming convention:
|
|
306
|
+
- the generated type and property names match exactly the DB table and column names
|
|
307
|
+
- the generated field names use the customer and customerList style.
|
|
308
|
+
|
|
309
|
+
--db-user=<value>
|
|
310
|
+
Database user name
|
|
311
|
+
|
|
312
|
+
--dir=<value>
|
|
313
|
+
Working directory
|
|
314
|
+
|
|
315
|
+
--name=<value>
|
|
316
|
+
Subfolder inside the workspace folder to save the imported schema files to. Defaults to the name of the imported
|
|
317
|
+
schema.
|
|
318
|
+
|
|
319
|
+
--non-interactive
|
|
320
|
+
Disable all interactive prompts
|
|
321
|
+
|
|
322
|
+
--ssl-connection
|
|
323
|
+
Is SSL enabled?
|
|
324
|
+
|
|
325
|
+
DESCRIPTION
|
|
326
|
+
Import a schema for a Db2 data source into your GraphQL API.
|
|
327
|
+
|
|
328
|
+
stepzen import db2 automatically introspects a Db2 database, generates a GraphQL schema for accessing this database
|
|
329
|
+
through a StepZen API, and merges the generated types, queries and mutations into your GraphQL schema.
|
|
330
|
+
```
|
|
331
|
+
|
|
258
332
|
## `stepzen import flow [FLOW]`
|
|
259
333
|
|
|
260
334
|
Import StepZen flow expression as a query field into your GraphQL API.
|
|
@@ -404,6 +478,75 @@ ALIASES
|
|
|
404
478
|
$ stepzen import singlestore
|
|
405
479
|
```
|
|
406
480
|
|
|
481
|
+
## `stepzen import oracle [DSN]`
|
|
482
|
+
|
|
483
|
+
Import a schema for a oracle data source into your GraphQL API.
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
USAGE
|
|
487
|
+
$ stepzen import oracle [DSN] [-h] [--non-interactive] [--dir <value>] [--name <value>] [--db-host <value>]
|
|
488
|
+
[--db-user <value>] [--db-password <value>] [--db-database <value>] [--db-schema <value>] [--db-link-types]
|
|
489
|
+
[--db-include tables-only|views-only|tables-and-views] [--db-use-deprecated-2022-naming]
|
|
490
|
+
|
|
491
|
+
ARGUMENTS
|
|
492
|
+
DSN (optional) Data Source Name (DSN) of an Oracle database.
|
|
493
|
+
Example: 'jdbc:oracle:thin:user/password@//host:port/db?currentschema=schema'
|
|
494
|
+
|
|
495
|
+
Flags, such as --db-host, override the corresponding parts of the DSN (if both are provided).
|
|
496
|
+
|
|
497
|
+
FLAGS
|
|
498
|
+
-h, --help
|
|
499
|
+
Show CLI help
|
|
500
|
+
|
|
501
|
+
--db-database=<value>
|
|
502
|
+
Name of database to import
|
|
503
|
+
|
|
504
|
+
--db-host=<value>
|
|
505
|
+
Database host and optional port (as HOST[:PORT])
|
|
506
|
+
|
|
507
|
+
--db-include=<option>
|
|
508
|
+
Should the generated GraphQL schema be based only on database views, only on tables or on both
|
|
509
|
+
<options: tables-only|views-only|tables-and-views>
|
|
510
|
+
|
|
511
|
+
--db-link-types
|
|
512
|
+
Automatically link types based on foreign key relationships using @materializer
|
|
513
|
+
(https://stepzen.com/docs/features/linking-types)
|
|
514
|
+
|
|
515
|
+
--db-password=<value>
|
|
516
|
+
Database password
|
|
517
|
+
|
|
518
|
+
--db-schema=<value>
|
|
519
|
+
Database schema to import tables from (default: public)
|
|
520
|
+
|
|
521
|
+
--db-use-deprecated-2022-naming
|
|
522
|
+
Use the deprecated pre-2023 naming convention in the generated GraphQL schema:
|
|
523
|
+
- the generated type and property names are auto-capitalized into PascalCase
|
|
524
|
+
- the generated field names use the getCustomer and getCustomerList style.
|
|
525
|
+
|
|
526
|
+
On the other hand, when using the default naming convention:
|
|
527
|
+
- the generated type and property names match exactly the DB table and column names
|
|
528
|
+
- the generated field names use the customer and customerList style.
|
|
529
|
+
|
|
530
|
+
--db-user=<value>
|
|
531
|
+
Database user name
|
|
532
|
+
|
|
533
|
+
--dir=<value>
|
|
534
|
+
Working directory
|
|
535
|
+
|
|
536
|
+
--name=<value>
|
|
537
|
+
Subfolder inside the workspace folder to save the imported schema files to. Defaults to the name of the imported
|
|
538
|
+
schema.
|
|
539
|
+
|
|
540
|
+
--non-interactive
|
|
541
|
+
Disable all interactive prompts
|
|
542
|
+
|
|
543
|
+
DESCRIPTION
|
|
544
|
+
Import a schema for a oracle data source into your GraphQL API.
|
|
545
|
+
|
|
546
|
+
stepzen import oracle automatically introspects an Oracle database, generates a GraphQL schema for accessing this
|
|
547
|
+
database through a StepZen API, and merges the generated types, queries and mutations into your GraphQL schema.
|
|
548
|
+
```
|
|
549
|
+
|
|
407
550
|
## `stepzen import postgres [DSN]`
|
|
408
551
|
|
|
409
552
|
Import a schema for a PostgreSQL data source into your GraphQL API.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ImportCommandBase } from '../../generate/import-command';
|
|
2
|
+
import type { CommonImportOptions } from '../../generate/import-command';
|
|
3
|
+
import type { DBIntrospectionOptions, Db2sqlImportOptions } from '../../generate/sql2sdl';
|
|
4
|
+
import type { FlagsT } from '../../shared/types';
|
|
5
|
+
declare type ParserSuccessResult = {
|
|
6
|
+
success: true;
|
|
7
|
+
value: ParsedDsn;
|
|
8
|
+
};
|
|
9
|
+
declare type ParserErrorResult = {
|
|
10
|
+
success: false;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
export declare type ParserResult = ParserSuccessResult | ParserErrorResult;
|
|
14
|
+
declare type ParsedDsn = {
|
|
15
|
+
driver: string;
|
|
16
|
+
host: string;
|
|
17
|
+
user?: string;
|
|
18
|
+
password?: string;
|
|
19
|
+
port?: number;
|
|
20
|
+
db?: string;
|
|
21
|
+
schema?: string;
|
|
22
|
+
sslConnection?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare type Db2SQLAnswers = Pick<Db2sqlImportOptions, 'host' | 'user' | 'password' | 'database' | 'schema' | 'linkTypes' | 'sslConnection'>;
|
|
25
|
+
export default class ImportDb2SQL extends ImportCommandBase {
|
|
26
|
+
static description: string;
|
|
27
|
+
get source(): "db2";
|
|
28
|
+
static flags: {
|
|
29
|
+
'db-host': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
30
|
+
'db-user': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
31
|
+
'db-password': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
32
|
+
'db-database': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
33
|
+
'db-schema': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
34
|
+
'db-link-types': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
35
|
+
'db-include': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
36
|
+
'db-use-deprecated-2022-naming': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
37
|
+
'ssl-connection': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
38
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
39
|
+
silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
40
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
41
|
+
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
42
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
43
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
44
|
+
};
|
|
45
|
+
static args: {
|
|
46
|
+
dsn: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
47
|
+
};
|
|
48
|
+
protected import(commonOptions: CommonImportOptions): Promise<import("../../shared/types").ErrorOr<import("../../generate/helpers").IntrospectionServiceResponse, {
|
|
49
|
+
message: string;
|
|
50
|
+
}>>;
|
|
51
|
+
getImportOptionsFromFlags(flags: FlagsT<typeof ImportDb2SQL>): {
|
|
52
|
+
host: string | undefined;
|
|
53
|
+
user: string | undefined;
|
|
54
|
+
password: string | undefined;
|
|
55
|
+
database: string | undefined;
|
|
56
|
+
schema: string | undefined;
|
|
57
|
+
linkTypes: boolean;
|
|
58
|
+
include: "tables-only" | "views-only" | "tables-and-views" | undefined;
|
|
59
|
+
sslConnection: boolean;
|
|
60
|
+
introspectionOptions: DBIntrospectionOptions;
|
|
61
|
+
};
|
|
62
|
+
getImportOptionsFromDsn(possibleDsn: string): {
|
|
63
|
+
host: string;
|
|
64
|
+
user: string | undefined;
|
|
65
|
+
password: string | undefined;
|
|
66
|
+
database: string | undefined;
|
|
67
|
+
schema: string | undefined;
|
|
68
|
+
sslConnection: boolean | undefined;
|
|
69
|
+
};
|
|
70
|
+
getImportOptionsInteractively(defaults?: Partial<Db2SQLAnswers>): Promise<Db2SQLAnswers>;
|
|
71
|
+
parseDsn(dsn: string): ParserResult;
|
|
72
|
+
isValidJdbcDb2Url(dsnString: string): {
|
|
73
|
+
status: boolean;
|
|
74
|
+
message?: string;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=db2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db2.d.ts","sourceRoot":"","sources":["../../../src/commands/import/db2.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAA;AAO/D,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAU,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAEvD,aAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,IAAI,CAAA;IACb,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AACD,aAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,oBAAY,YAAY,GAAG,mBAAmB,GAAG,iBAAiB,CAAA;AAElE,aAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,oBAAY,aAAa,GAAG,IAAI,CAC9B,mBAAmB,EACjB,MAAM,GACN,MAAM,GACN,UAAU,GACV,UAAU,GACV,QAAQ,GACR,WAAW,GACX,eAAe,CAClB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB;IACzD,MAAM,CAAC,WAAW,SAMkC;IAEpD,IAAI,MAAM,UAET;IAED,MAAM,CAAC,KAAK;;;;;;;;;;;;;;;;MAaX;IAED,MAAM,CAAC,IAAI;;MASV;cAEe,MAAM,CAAC,aAAa,EAAE,mBAAmB;;;IAuFzD,yBAAyB,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,YAAY,CAAC;;;;;;;;;;;IAoB5D,uBAAuB,CAAC,WAAW,EAAE,MAAM;;;;;;;;IAyBrC,6BAA6B,CACjC,QAAQ,GAAE,OAAO,CAAC,aAAa,CAAM,GACpC,OAAO,CAAC,aAAa,CAAC;IAkBzB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAiDnC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC;CAiC1E"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2020, 2024
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
const flags_1 = require("../../generate/flags");
|
|
9
|
+
const import_command_1 = require("../../generate/import-command");
|
|
10
|
+
const questions_1 = require("../../generate/questions");
|
|
11
|
+
const sql2sdl_1 = require("../../generate/sql2sdl");
|
|
12
|
+
const configuration_1 = require("../../shared/configuration");
|
|
13
|
+
const inquirer = require("../../shared/inquirer");
|
|
14
|
+
const utils_1 = require("../../shared/utils");
|
|
15
|
+
class ImportDb2SQL extends import_command_1.ImportCommandBase {
|
|
16
|
+
get source() {
|
|
17
|
+
return 'db2';
|
|
18
|
+
}
|
|
19
|
+
async import(commonOptions) {
|
|
20
|
+
const { args, flags } = await this.parse(ImportDb2SQL);
|
|
21
|
+
const nonInteractiveOptions = {
|
|
22
|
+
...(args.dsn ? this.getImportOptionsFromDsn(args.dsn) : {}),
|
|
23
|
+
...this.getImportOptionsFromFlags(flags),
|
|
24
|
+
};
|
|
25
|
+
const requiredOptions = [
|
|
26
|
+
'host',
|
|
27
|
+
'user',
|
|
28
|
+
'password',
|
|
29
|
+
'database',
|
|
30
|
+
'sslConnection',
|
|
31
|
+
'schema',
|
|
32
|
+
];
|
|
33
|
+
const hasRequiredOptions = requiredOptions.every(option => nonInteractiveOptions[option] !== undefined);
|
|
34
|
+
let sql2sdlOptions;
|
|
35
|
+
if (hasRequiredOptions) {
|
|
36
|
+
// an ugly hint for the TS compiler because it is not smart enough to figure this :(
|
|
37
|
+
const typedNonInteractiveOptions = nonInteractiveOptions;
|
|
38
|
+
// run non-interactively
|
|
39
|
+
sql2sdlOptions = {
|
|
40
|
+
dbType: this.source,
|
|
41
|
+
...commonOptions,
|
|
42
|
+
...typedNonInteractiveOptions,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (flags['non-interactive']) {
|
|
47
|
+
throw new errors_1.CLIError('Please provide a Data Source Name (DSN) string for a Db2 database.' +
|
|
48
|
+
chalk `\nSee more help with {bold stepzen import db2 --help}`);
|
|
49
|
+
}
|
|
50
|
+
// no parameters given: start an interactive prompt
|
|
51
|
+
if (!flags.silent) {
|
|
52
|
+
this.log();
|
|
53
|
+
this.log(chalk `{bold stepzen import db2} - ` +
|
|
54
|
+
chalk.dim('introspect a Db2 database and extend your GraphQL schema' +
|
|
55
|
+
' with the types, queries and mutations for accessing it through' +
|
|
56
|
+
' a StepZen API.'));
|
|
57
|
+
this.log();
|
|
58
|
+
}
|
|
59
|
+
// one or more required parameters are missing: start an interactive prompt
|
|
60
|
+
const interactiveOptions = await this.getImportOptionsInteractively(nonInteractiveOptions);
|
|
61
|
+
sql2sdlOptions = {
|
|
62
|
+
dbType: this.source,
|
|
63
|
+
...commonOptions,
|
|
64
|
+
// Some options that may have been provided via the command line are
|
|
65
|
+
// excluded from the interactive prompts (e.g. `--db-include`). That's
|
|
66
|
+
// why the non-interactive options are also included here.
|
|
67
|
+
...nonInteractiveOptions,
|
|
68
|
+
...interactiveOptions,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const configuration = await (0, configuration_1.readConfiguration)();
|
|
72
|
+
sql2sdlOptions.host = (0, utils_1.rewriteLocalhostToHostGateway)(configuration, sql2sdlOptions.host);
|
|
73
|
+
return this.wrapInProgressAndTimeout((0, sql2sdl_1.sql2sdl)(sql2sdlOptions, configuration));
|
|
74
|
+
}
|
|
75
|
+
getImportOptionsFromFlags(flags) {
|
|
76
|
+
const options = {
|
|
77
|
+
host: flags['db-host'],
|
|
78
|
+
user: flags['db-user'],
|
|
79
|
+
password: flags['db-password'],
|
|
80
|
+
database: flags['db-database'],
|
|
81
|
+
schema: flags['db-schema'],
|
|
82
|
+
linkTypes: flags['db-link-types'],
|
|
83
|
+
include: flags['db-include'],
|
|
84
|
+
sslConnection: flags['ssl-connection'],
|
|
85
|
+
introspectionOptions: {
|
|
86
|
+
// Use the 2023 naming convention by default, and the 2022 naming
|
|
87
|
+
// convention only if explicitly requested by the user.
|
|
88
|
+
naming: flags['db-use-deprecated-2022-naming'] ? '2022' : '2023',
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
// Remove `undefined`-valued properties
|
|
92
|
+
return (0, lodash_1.pickBy)(options, value => value !== undefined);
|
|
93
|
+
}
|
|
94
|
+
getImportOptionsFromDsn(possibleDsn) {
|
|
95
|
+
/**
|
|
96
|
+
According to the documentation for Db2, customers are required to provide the JDBC URL.
|
|
97
|
+
However, introspection does not currently support this feature, so the `jdbc:` keyword will need to be removed from the URL.
|
|
98
|
+
*/
|
|
99
|
+
possibleDsn = possibleDsn.replace('jdbc:', '');
|
|
100
|
+
const parsed = this.parseDsn(possibleDsn);
|
|
101
|
+
if (parsed.success) {
|
|
102
|
+
const value = parsed.value;
|
|
103
|
+
const options = {
|
|
104
|
+
host: value.host + (value.port ? `:${value.port}` : ''),
|
|
105
|
+
user: value.user,
|
|
106
|
+
password: value.password,
|
|
107
|
+
database: value.db,
|
|
108
|
+
schema: value.schema,
|
|
109
|
+
sslConnection: value.sslConnection,
|
|
110
|
+
};
|
|
111
|
+
// Remove `undefined`-valued properties
|
|
112
|
+
return (0, lodash_1.pickBy)(options, value => value !== undefined);
|
|
113
|
+
}
|
|
114
|
+
throw new errors_1.CLIError(parsed.message);
|
|
115
|
+
}
|
|
116
|
+
async getImportOptionsInteractively(defaults = {}) {
|
|
117
|
+
const questions = inquirer.overrideDefaults([
|
|
118
|
+
questions_1.ImportQuestions.dbHost(),
|
|
119
|
+
questions_1.ImportQuestions.dbUser(),
|
|
120
|
+
questions_1.ImportQuestions.dbPassword(),
|
|
121
|
+
questions_1.ImportQuestions.dbDatabase(),
|
|
122
|
+
questions_1.ImportQuestions.dbSchema({ required: true }),
|
|
123
|
+
questions_1.ImportQuestions.dbLinkTypes(),
|
|
124
|
+
questions_1.ImportQuestions.sslConnection(),
|
|
125
|
+
], defaults);
|
|
126
|
+
return inquirer.prompt(`import-${this.source}`, questions);
|
|
127
|
+
}
|
|
128
|
+
// Created a new function as parseDsn from '@soluble/dsn-parser' is not supporting the jdbc db2 url format
|
|
129
|
+
parseDsn(dsn) {
|
|
130
|
+
const isValidDsn = this.isValidJdbcDb2Url(dsn);
|
|
131
|
+
if (isValidDsn.status) {
|
|
132
|
+
// const urlWithoutPrefix = dsn.replace(/^jdbc:db2:\/\//i, '') Commented as jdbc is not supported by introspection right now
|
|
133
|
+
// Remove the jdbc:db2:// prefix
|
|
134
|
+
const urlWithoutPrefix = dsn.replace(/^db2:\/\//i, '');
|
|
135
|
+
const parsedDsn = { driver: 'jdbc:db2' };
|
|
136
|
+
const seperateHost = urlWithoutPrefix.split('/');
|
|
137
|
+
const hostPort = seperateHost[0].split(':');
|
|
138
|
+
parsedDsn.host = hostPort[0];
|
|
139
|
+
parsedDsn.port = parseInt(hostPort[1], 10);
|
|
140
|
+
const manageParams = seperateHost[1].split(':');
|
|
141
|
+
parsedDsn.db = manageParams[0];
|
|
142
|
+
// Split by ; to separate key-value pairs
|
|
143
|
+
const keyValuePairs = manageParams[1].split(';');
|
|
144
|
+
keyValuePairs.forEach(pair => {
|
|
145
|
+
const [key, value] = pair.split('=');
|
|
146
|
+
switch (key.toLowerCase()) {
|
|
147
|
+
case 'user':
|
|
148
|
+
parsedDsn.user = value;
|
|
149
|
+
break;
|
|
150
|
+
case 'password':
|
|
151
|
+
parsedDsn.password = value;
|
|
152
|
+
break;
|
|
153
|
+
case 'currentschema':
|
|
154
|
+
parsedDsn.schema = value;
|
|
155
|
+
break;
|
|
156
|
+
case 'sslconnection':
|
|
157
|
+
parsedDsn.sslConnection = value.toLowerCase() === 'true';
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
success: true,
|
|
165
|
+
value: parsedDsn,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
success: false,
|
|
170
|
+
message: isValidDsn && isValidDsn.message
|
|
171
|
+
? isValidDsn.message
|
|
172
|
+
: 'Cannot parse DSN',
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
isValidJdbcDb2Url(dsnString) {
|
|
176
|
+
// const pattern = /^jdbc:db2:\/\/[a-zA-Z0-9.-]+:\d+\/[a-zA-Z0-9_-]+?(?::[a-zA-Z]+=[\w-]+(?:;[a-zA-Z]+=[\w-]+)*;)*$/; Commented as jdbc is not suppported by introspection right now
|
|
177
|
+
const pattern = /^db2:\/\/[a-zA-Z0-9.-]+:\d+\/[a-zA-Z0-9_-]+?(?::[a-zA-Z]+=[\w-]+(?:;[a-zA-Z]+=[\w-]+)*;)*$/;
|
|
178
|
+
if (!pattern.test(dsnString)) {
|
|
179
|
+
// To identify what is missing or incorrect:
|
|
180
|
+
// 1. Check for missing mandatory parts
|
|
181
|
+
let message;
|
|
182
|
+
if (dsnString.match(/^db2:\/\//) === undefined) {
|
|
183
|
+
message = `Missing 'db2://' prefix`;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const urlWithoutPrefix = dsnString.replace(/^db2:\/\//i, '');
|
|
187
|
+
if (urlWithoutPrefix.charAt(urlWithoutPrefix.length - 1) !== ';') {
|
|
188
|
+
// If not, add a semicolon at the end
|
|
189
|
+
message = `Missing ';' at the end of the url`;
|
|
190
|
+
}
|
|
191
|
+
const separateHost = urlWithoutPrefix.split('/');
|
|
192
|
+
const hostPort = separateHost[0].split(':');
|
|
193
|
+
if (hostPort[1] === undefined) {
|
|
194
|
+
message = `Port number missing`;
|
|
195
|
+
}
|
|
196
|
+
else if (separateHost[1] === undefined) {
|
|
197
|
+
message = `database name not present in the provided url, should follow the format jdbc:db2://hostname/databasename:<params separated by ;>`;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const manageParams = separateHost[1].split(':');
|
|
201
|
+
if (manageParams[1] === undefined) {
|
|
202
|
+
message = `expected : after the database name, should follow the format jdbc:db2://hostname/databasename:<params separated by ;>`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return { status: false, message };
|
|
207
|
+
}
|
|
208
|
+
return { status: true };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.default = ImportDb2SQL;
|
|
212
|
+
ImportDb2SQL.description = `Import a schema for a Db2 data source into your GraphQL API.` +
|
|
213
|
+
`\n` +
|
|
214
|
+
chalk `\n{bold stepzen import db2} automatically introspects a` +
|
|
215
|
+
` Db2 database, generates a GraphQL schema for accessing this` +
|
|
216
|
+
` database through a StepZen API, and merges the generated types,` +
|
|
217
|
+
` queries and mutations into your GraphQL schema.`;
|
|
218
|
+
ImportDb2SQL.flags = {
|
|
219
|
+
...import_command_1.ImportCommandBase.flags,
|
|
220
|
+
'db-host': flags_1.ImportFlags.dbHost(),
|
|
221
|
+
'db-user': flags_1.ImportFlags.dbUser(),
|
|
222
|
+
'db-password': flags_1.ImportFlags.dbPassword(),
|
|
223
|
+
'db-database': flags_1.ImportFlags.dbDatabase(),
|
|
224
|
+
'db-schema': flags_1.ImportFlags.dbSchema(),
|
|
225
|
+
'db-link-types': flags_1.ImportFlags.dbLinkTypes(),
|
|
226
|
+
'db-include': flags_1.ImportFlags.dbInclude(),
|
|
227
|
+
'db-use-deprecated-2022-naming': flags_1.ImportFlags.dbUseDeprecatedNaming(),
|
|
228
|
+
'ssl-connection': core_1.Flags.boolean({
|
|
229
|
+
description: 'Is SSL enabled?',
|
|
230
|
+
}),
|
|
231
|
+
};
|
|
232
|
+
ImportDb2SQL.args = {
|
|
233
|
+
dsn: core_1.Args.string({
|
|
234
|
+
description: chalk `{italic (optional)} Data Source Name (DSN) of a Db2 database.` +
|
|
235
|
+
chalk `\nExample: {bold 'jdbc:db2://host:port/db:user=username;password=password;schema=schema;sslConnection=true/false;'}` +
|
|
236
|
+
chalk `\n` +
|
|
237
|
+
chalk `\nFlags, such as {bold --db-host}, override the corresponding` +
|
|
238
|
+
chalk ` parts of the DSN (if both are provided).`,
|
|
239
|
+
}),
|
|
240
|
+
};
|
|
241
|
+
//# sourceMappingURL=db2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db2.js","sourceRoot":"","sources":["../../../src/commands/import/db2.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAEjC,sCAAuC;AACvC,mDAA+C;AAC/C,+BAA8B;AAC9B,mCAA6B;AAC7B,gDAAgD;AAChD,kEAA+D;AAC/D,wDAAwD;AACxD,oDAA8C;AAC9C,8DAA4D;AAC5D,kDAAiD;AACjD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AC;CACH,CAAA;AAEM,iBAAI,GAAG;IACZ,GAAG,EAAE,WAAI,CAAC,MAAM,CAAC;QACf,WAAW,EACT,KAAK,CAAA,+DAA+D;YACpE,KAAK,CAAA,qHAAqH;YAC1H,KAAK,CAAA,IAAI;YACT,KAAK,CAAA,+DAA+D;YACpE,KAAK,CAAA,2CAA2C;KACnD,CAAC;CACH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/import/index.ts"],"names":[],"mappings":"AAUA,OAAO,UAAU,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/import/index.ts"],"names":[],"mappings":"AAUA,OAAO,UAAU,MAAM,0BAA0B,CAAA;AAYjD,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,KAAK,EACL,YAAY,EACb,MAAM,mCAAmC,CAAA;AAa1C,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAC5C,MAAM,CAAC,WAAW,SAEoD;IAEtE,MAAM,CAAC,KAAK;;;;MAGX;IAED,MAAM,CAAC,IAAI;;MAMV;IAEK,GAAG;cA4HO,KAAK,CACnB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,SAAS,EAEnB,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACxB,IAAI,GAAE,MAAM,EAAc,GACzB,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC;IAkBpD,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;KAAC;CA0CvE"}
|
|
@@ -16,7 +16,17 @@ const mysql_1 = require("./mysql");
|
|
|
16
16
|
const postgresql_1 = require("./postgresql");
|
|
17
17
|
const presto_1 = require("./presto");
|
|
18
18
|
const snowflake_1 = require("./snowflake");
|
|
19
|
-
const
|
|
19
|
+
const oracle_1 = require("./oracle");
|
|
20
|
+
const db2_1 = require("./db2");
|
|
21
|
+
const SOURCES = [
|
|
22
|
+
'curl',
|
|
23
|
+
'graphql',
|
|
24
|
+
'mysql',
|
|
25
|
+
'postgresql',
|
|
26
|
+
'snowflake',
|
|
27
|
+
'db2',
|
|
28
|
+
'oracle',
|
|
29
|
+
];
|
|
20
30
|
class Import extends zen_command_1.default {
|
|
21
31
|
async run() {
|
|
22
32
|
const { args, flags } = await this.parse(Import);
|
|
@@ -56,6 +66,8 @@ class Import extends zen_command_1.default {
|
|
|
56
66
|
: []),
|
|
57
67
|
{ value: 'singlestore', name: 'SingleStore' },
|
|
58
68
|
{ value: 'snowflake', name: 'Snowflake' },
|
|
69
|
+
{ value: 'db2', name: 'Db2' },
|
|
70
|
+
{ value: 'oracle', name: 'Oracle' },
|
|
59
71
|
],
|
|
60
72
|
},
|
|
61
73
|
]);
|
|
@@ -92,13 +104,15 @@ class Import extends zen_command_1.default {
|
|
|
92
104
|
case 'snowflake':
|
|
93
105
|
ImportCommand = snowflake_1.default;
|
|
94
106
|
break;
|
|
107
|
+
case 'db2':
|
|
108
|
+
ImportCommand = db2_1.default;
|
|
109
|
+
break;
|
|
95
110
|
case 'presto':
|
|
96
111
|
ImportCommand = presto_1.default;
|
|
97
112
|
break;
|
|
98
|
-
case '
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
chalk `In the meantime, please consider using another supported data source.`);
|
|
113
|
+
case 'oracle':
|
|
114
|
+
ImportCommand = oracle_1.default;
|
|
115
|
+
break;
|
|
102
116
|
default:
|
|
103
117
|
throw new errors_1.CLIError(chalk `Unsupported data source: {bold ${source}}.` +
|
|
104
118
|
chalk `\n\tStepZen CLI does not support introspection and automatic` +
|
|
@@ -149,6 +163,10 @@ class Import extends zen_command_1.default {
|
|
|
149
163
|
}
|
|
150
164
|
source = trimmed;
|
|
151
165
|
}
|
|
166
|
+
// support to handle id the driver is not explicitly provided eg: stepzen import "jdbc:db2://url"
|
|
167
|
+
if (source.toLocaleLowerCase() === 'jdbc:db2') {
|
|
168
|
+
source = 'db2';
|
|
169
|
+
}
|
|
152
170
|
// support `postgres` as an alias to `postgresql`
|
|
153
171
|
// https://github.com/steprz/stepzen-cli/issues/431
|
|
154
172
|
if (source.toLowerCase() === 'postgres') {
|
|
@@ -158,6 +176,10 @@ class Import extends zen_command_1.default {
|
|
|
158
176
|
if (source.toLowerCase() === 'singlestore') {
|
|
159
177
|
source = 'mysql';
|
|
160
178
|
}
|
|
179
|
+
// support the Oracle JDBC URL format: e.g., jdbc:oracle:thin://url
|
|
180
|
+
if (source.toLowerCase().startsWith('oracle:thin')) {
|
|
181
|
+
source = 'oracle';
|
|
182
|
+
}
|
|
161
183
|
return { source, dsn };
|
|
162
184
|
}
|
|
163
185
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/import/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAEjC,sCAAuC;AACvC,mDAA+C;AAC/C,0DAA2D;AAC3D,+BAA8B;AAE9B,sDAA2D;AAC3D,kDAAiD;AACjD,8CAAiD;AACjD,0DAAiD;AAEjD,iCAA+B;AAC/B,iCAA+B;AAC/B,uCAAqC;AACrC,mCAAiC;AACjC,6CAA2C;AAC3C,qCAAmC;AACnC,2CAAyC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/import/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAEjC,sCAAuC;AACvC,mDAA+C;AAC/C,0DAA2D;AAC3D,+BAA8B;AAE9B,sDAA2D;AAC3D,kDAAiD;AACjD,8CAAiD;AACjD,0DAAiD;AAEjD,iCAA+B;AAC/B,iCAA+B;AAC/B,uCAAqC;AACrC,mCA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