@apimatic/cli 1.1.0-beta.1 → 1.1.0-beta.10
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 +14 -7
- package/lib/actions/action-result.d.ts +12 -6
- package/lib/actions/action-result.js +36 -10
- package/lib/actions/action-result.js.map +1 -1
- package/lib/actions/api/validate.d.ts +3 -1
- package/lib/actions/api/validate.js +14 -3
- package/lib/actions/api/validate.js.map +1 -1
- package/lib/actions/portal/copilot.js +2 -2
- package/lib/actions/portal/quickstart.d.ts +4 -3
- package/lib/actions/portal/quickstart.js +42 -19
- package/lib/actions/portal/quickstart.js.map +1 -1
- package/lib/actions/portal/serve.js +0 -14
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/portal/toc/new-toc.d.ts +5 -5
- package/lib/actions/portal/toc/new-toc.js +39 -40
- package/lib/actions/portal/toc/new-toc.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +1 -1
- package/lib/actions/sdk/generate.js +38 -8
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/actions/sdk/quickstart.d.ts +6 -3
- package/lib/actions/sdk/quickstart.js +48 -26
- package/lib/actions/sdk/quickstart.js.map +1 -1
- package/lib/application/portal/toc/toc-structure-generator.d.ts +23 -2
- package/lib/application/portal/toc/toc-structure-generator.js +131 -60
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -1
- package/lib/commands/portal/toc/new.d.ts +5 -3
- package/lib/commands/portal/toc/new.js +32 -24
- package/lib/commands/portal/toc/new.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +2 -2
- package/lib/commands/sdk/generate.js +10 -10
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/infrastructure/debounce-service.js +3 -0
- package/lib/infrastructure/debounce-service.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +1 -0
- package/lib/infrastructure/file-service.js +11 -0
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/services/api-service.d.ts +2 -1
- package/lib/infrastructure/services/api-service.js +24 -0
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/portal-service.d.ts +2 -4
- package/lib/infrastructure/services/portal-service.js +75 -57
- package/lib/infrastructure/services/portal-service.js.map +1 -1
- package/lib/infrastructure/services/validation-service.d.ts +28 -2
- package/lib/infrastructure/services/validation-service.js +108 -15
- package/lib/infrastructure/services/validation-service.js.map +1 -1
- package/lib/prompts/api/validate.d.ts +5 -2
- package/lib/prompts/api/validate.js +36 -0
- package/lib/prompts/api/validate.js.map +1 -1
- package/lib/prompts/format.d.ts +1 -1
- package/lib/prompts/format.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +3 -0
- package/lib/prompts/portal/quickstart.js +39 -2
- package/lib/prompts/portal/quickstart.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +1 -1
- package/lib/prompts/portal/toc/new-toc.js +10 -2
- package/lib/prompts/portal/toc/new-toc.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +8 -3
- package/lib/prompts/sdk/generate.js +25 -5
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/prompts/sdk/quickstart.d.ts +4 -1
- package/lib/prompts/sdk/quickstart.js +41 -4
- package/lib/prompts/sdk/quickstart.js.map +1 -1
- package/lib/types/sdl/sdl.d.ts +20 -3
- package/lib/types/sdl/sdl.js +120 -22
- package/lib/types/sdl/sdl.js.map +1 -1
- package/lib/types/toc/toc.d.ts +31 -6
- package/lib/types/versioned-build-context.d.ts +15 -0
- package/lib/types/versioned-build-context.js +28 -0
- package/lib/types/versioned-build-context.js.map +1 -0
- package/lib/utils/string-utils.d.ts +1 -0
- package/lib/utils/string-utils.js +42 -0
- package/lib/utils/string-utils.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ The official CLI for APIMatic.
|
|
|
14
14
|
To get started with APIMatic's CLI using a step by step wizard, run the following command:
|
|
15
15
|
|
|
16
16
|
```sh-session
|
|
17
|
-
$ apimatic
|
|
17
|
+
$ apimatic quickstart
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
# Usage
|
|
@@ -24,7 +24,7 @@ $ npm install -g @apimatic/cli
|
|
|
24
24
|
$ apimatic COMMAND
|
|
25
25
|
running command...
|
|
26
26
|
$ apimatic (--version)
|
|
27
|
-
@apimatic/cli/1.
|
|
27
|
+
@apimatic/cli/1.1.0-beta.8 win32-x64 node-v23.4.0
|
|
28
28
|
$ apimatic --help [COMMAND]
|
|
29
29
|
USAGE
|
|
30
30
|
$ apimatic COMMAND
|
|
@@ -349,16 +349,21 @@ Generate a Table of Contents (TOC) file for your API documentation portal
|
|
|
349
349
|
```
|
|
350
350
|
USAGE
|
|
351
351
|
$ apimatic portal toc new [-d <value>] [-i <value>] [-f] [--expand-endpoints] [--expand-models]
|
|
352
|
+
[--expand-webhooks] [--expand-callbacks]
|
|
352
353
|
|
|
353
354
|
FLAGS
|
|
354
355
|
-d, --destination=<value> [default: <input>/src/content] path where the toc.yml will be generated.
|
|
355
356
|
-f, --force overwrite changes without asking for user consent.
|
|
356
357
|
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
357
358
|
API specifications and configuration files.
|
|
359
|
+
--expand-callbacks include individual entries for each callback in the generated 'toc.yml'. Requires a valid
|
|
360
|
+
API specification in the working directory.
|
|
358
361
|
--expand-endpoints include individual entries for each endpoint in the generated 'toc.yml'. Requires a valid
|
|
359
362
|
API specification in the working directory.
|
|
360
363
|
--expand-models include individual entries for each model in the generated 'toc.yml'. Requires a valid API
|
|
361
364
|
specification in the working directory.
|
|
365
|
+
--expand-webhooks include individual entries for each webhook in the generated 'toc.yml'. Requires a valid
|
|
366
|
+
API specification in the working directory.
|
|
362
367
|
|
|
363
368
|
DESCRIPTION
|
|
364
369
|
Generate a Table of Contents (TOC) file for your API documentation portal
|
|
@@ -406,17 +411,19 @@ Generate an SDK for your API
|
|
|
406
411
|
|
|
407
412
|
```
|
|
408
413
|
USAGE
|
|
409
|
-
$ apimatic sdk generate -l csharp|java|php|python|ruby|typescript|go [
|
|
410
|
-
[-k <value>]
|
|
414
|
+
$ apimatic sdk generate -l csharp|java|php|python|ruby|typescript|go [-i <value>] [-d <value>] [--api-version
|
|
415
|
+
<value>] [-f] [--zip] [-k <value>]
|
|
411
416
|
|
|
412
417
|
FLAGS
|
|
413
418
|
-d, --destination=<value> directory where the SDK will be generated
|
|
414
419
|
-f, --force overwrite changes without asking for user consent.
|
|
420
|
+
-i, --input=<value> [default: ./] path to the parent directory containing the 'src' directory, which includes
|
|
421
|
+
API specifications and configuration files.
|
|
415
422
|
-k, --auth-key=<value> override current authentication state with an authentication key.
|
|
416
423
|
-l, --language=<option> (required) programming language for SDK generation
|
|
417
424
|
<options: csharp|java|php|python|ruby|typescript|go>
|
|
418
|
-
--
|
|
419
|
-
--zip
|
|
425
|
+
--api-version=<value> Version of the API to use for SDK generation (if multiple versions exist)
|
|
426
|
+
--zip Download the generated SDK as a .zip archive
|
|
420
427
|
|
|
421
428
|
DESCRIPTION
|
|
422
429
|
Generate an SDK for your API
|
|
@@ -427,7 +434,7 @@ DESCRIPTION
|
|
|
427
434
|
EXAMPLES
|
|
428
435
|
apimatic sdk generate --language=java
|
|
429
436
|
|
|
430
|
-
apimatic sdk generate --language=csharp --
|
|
437
|
+
apimatic sdk generate --language=csharp --input=./
|
|
431
438
|
|
|
432
439
|
apimatic sdk generate --language=python --destination=./sdk --zip
|
|
433
440
|
```
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
export declare class ActionResult {
|
|
1
|
+
export declare class ActionResult<T = void> {
|
|
2
2
|
private readonly message;
|
|
3
3
|
private readonly resultType;
|
|
4
|
+
private readonly value?;
|
|
4
5
|
private constructor();
|
|
5
|
-
static success(): ActionResult
|
|
6
|
-
static failed(): ActionResult
|
|
7
|
-
static cancelled(): ActionResult
|
|
8
|
-
static stopped(): ActionResult
|
|
6
|
+
static success<T>(value?: T): ActionResult<T>;
|
|
7
|
+
static failed<T = never>(message?: string): ActionResult<T>;
|
|
8
|
+
static cancelled<T = never>(message?: string): ActionResult<T>;
|
|
9
|
+
static stopped<T = never>(message?: string): ActionResult<T>;
|
|
9
10
|
getMessage(): string;
|
|
10
11
|
getExitCode(): number;
|
|
11
12
|
isFailed(): boolean;
|
|
12
|
-
|
|
13
|
+
isSuccess(): boolean;
|
|
14
|
+
isCancelled(): boolean;
|
|
15
|
+
match<R>(onSuccess: (value: T) => R, onFailure: (message: string) => R, onCancel: (message: string) => R): R;
|
|
16
|
+
getValue(): T;
|
|
17
|
+
getValueOr(defaultValue: T): T;
|
|
18
|
+
mapAll<R>(onSuccess: (value?: T) => R, onFailure: () => R, onCancel: () => R): R;
|
|
13
19
|
}
|
|
@@ -5,21 +5,22 @@ var ResultType;
|
|
|
5
5
|
ResultType[ResultType["Failure"] = 1] = "Failure";
|
|
6
6
|
})(ResultType || (ResultType = {}));
|
|
7
7
|
export class ActionResult {
|
|
8
|
-
constructor(resultType, message) {
|
|
8
|
+
constructor(resultType, message, value) {
|
|
9
9
|
this.resultType = resultType;
|
|
10
10
|
this.message = message;
|
|
11
|
+
this.value = value;
|
|
11
12
|
}
|
|
12
|
-
static success() {
|
|
13
|
-
return new ActionResult(ResultType.Success, "
|
|
13
|
+
static success(value) {
|
|
14
|
+
return new ActionResult(ResultType.Success, "Succeeded", value);
|
|
14
15
|
}
|
|
15
|
-
static failed() {
|
|
16
|
-
return new ActionResult(ResultType.Failure,
|
|
16
|
+
static failed(message = "Failed") {
|
|
17
|
+
return new ActionResult(ResultType.Failure, message);
|
|
17
18
|
}
|
|
18
|
-
static cancelled() {
|
|
19
|
-
return new ActionResult(ResultType.Cancel,
|
|
19
|
+
static cancelled(message = "Cancelled") {
|
|
20
|
+
return new ActionResult(ResultType.Cancel, message);
|
|
20
21
|
}
|
|
21
|
-
static stopped() {
|
|
22
|
-
return new ActionResult(ResultType.Cancel,
|
|
22
|
+
static stopped(message = "Stopped") {
|
|
23
|
+
return new ActionResult(ResultType.Cancel, message);
|
|
23
24
|
}
|
|
24
25
|
getMessage() {
|
|
25
26
|
return this.message;
|
|
@@ -30,10 +31,35 @@ export class ActionResult {
|
|
|
30
31
|
isFailed() {
|
|
31
32
|
return this.resultType === ResultType.Failure;
|
|
32
33
|
}
|
|
34
|
+
isSuccess() {
|
|
35
|
+
return this.resultType === ResultType.Success;
|
|
36
|
+
}
|
|
37
|
+
isCancelled() {
|
|
38
|
+
return this.resultType === ResultType.Cancel;
|
|
39
|
+
}
|
|
40
|
+
match(onSuccess, onFailure, onCancel) {
|
|
41
|
+
switch (this.resultType) {
|
|
42
|
+
case ResultType.Success:
|
|
43
|
+
return onSuccess(this.value);
|
|
44
|
+
case ResultType.Failure:
|
|
45
|
+
return onFailure(this.message);
|
|
46
|
+
case ResultType.Cancel:
|
|
47
|
+
return onCancel(this.message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
getValue() {
|
|
51
|
+
if (!this.isSuccess()) {
|
|
52
|
+
throw new Error(`Cannot unwrap ${ResultType[this.resultType]} result: ${this.message}`);
|
|
53
|
+
}
|
|
54
|
+
return this.value;
|
|
55
|
+
}
|
|
56
|
+
getValueOr(defaultValue) {
|
|
57
|
+
return this.isSuccess() ? this.value : defaultValue;
|
|
58
|
+
}
|
|
33
59
|
mapAll(onSuccess, onFailure, onCancel) {
|
|
34
60
|
switch (this.resultType) {
|
|
35
61
|
case ResultType.Success:
|
|
36
|
-
return onSuccess();
|
|
62
|
+
return onSuccess(this.value);
|
|
37
63
|
case ResultType.Failure:
|
|
38
64
|
return onFailure();
|
|
39
65
|
case ResultType.Cancel:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-result.js","sourceRoot":"","sources":["../../src/actions/action-result.ts"],"names":[],"mappings":"AAAA,IAAK,UAIJ;AAJD,WAAK,UAAU;IACb,
|
|
1
|
+
{"version":3,"file":"action-result.js","sourceRoot":"","sources":["../../src/actions/action-result.ts"],"names":[],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";
|
|
3
|
+
import { UnallowedFeaturesResponse } from "../../infrastructure/services/validation-service.js";
|
|
3
4
|
import { CommandMetadata } from "../../types/common/command-metadata.js";
|
|
4
5
|
import { ResourceInput } from "../../types/file/resource-input.js";
|
|
5
6
|
export declare class ValidateAction {
|
|
@@ -8,5 +9,6 @@ export declare class ValidateAction {
|
|
|
8
9
|
private readonly authKey;
|
|
9
10
|
private readonly commandMetadata;
|
|
10
11
|
constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
|
|
11
|
-
readonly execute: (resourcePath: ResourceInput, displayValidationSummary?: boolean) => Promise<ActionResult
|
|
12
|
+
readonly execute: (resourcePath: ResourceInput, displayValidationSummary?: boolean) => Promise<ActionResult<UnallowedFeaturesResponse | null>>;
|
|
13
|
+
private hasValidationIssues;
|
|
12
14
|
}
|
|
@@ -25,17 +25,28 @@ export class ValidateAction {
|
|
|
25
25
|
}
|
|
26
26
|
const validationSummary = validationSummaryResult.value;
|
|
27
27
|
if (displayValidationSummary) {
|
|
28
|
-
this.
|
|
28
|
+
if (this.hasValidationIssues(validationSummary.result.validation)) {
|
|
29
|
+
this.prompts.displayValidationSummary(validationSummary.result.validation);
|
|
30
|
+
}
|
|
31
|
+
if (this.hasValidationIssues(validationSummary.result.linting)) {
|
|
32
|
+
this.prompts.displayValidationSummary(validationSummary.result.linting);
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
|
-
if (!validationSummary.
|
|
35
|
+
if (!validationSummary.result.validation.isSuccess || !validationSummary.result.linting.isSuccess) {
|
|
31
36
|
return ActionResult.failed();
|
|
32
37
|
}
|
|
33
|
-
return ActionResult.success();
|
|
38
|
+
return ActionResult.success(validationSummary.unallowedFeatures);
|
|
34
39
|
});
|
|
35
40
|
};
|
|
36
41
|
this.authKey = authKey;
|
|
37
42
|
this.validationService = new ValidationService(configDir);
|
|
38
43
|
this.commandMetadata = commandMetadata;
|
|
39
44
|
}
|
|
45
|
+
hasValidationIssues(summary) {
|
|
46
|
+
return (summary.blocking.length > 0 ||
|
|
47
|
+
summary.errors.length > 0 ||
|
|
48
|
+
summary.warnings.length > 0 ||
|
|
49
|
+
summary.information.length > 0);
|
|
50
|
+
}
|
|
40
51
|
}
|
|
41
52
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/actions/api/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/actions/api/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAA6B,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGnH,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE,MAAM,OAAO,cAAc;IAMzB,YAAY,SAAwB,EAAE,eAAgC,EAAE,UAAyB,IAAI;QALpF,YAAO,GAAuB,IAAI,kBAAkB,EAAE,CAAC;QAWxD,YAAO,GAAG,KAAK,EAC7B,YAA2B,EAC3B,wBAAwB,GAAG,IAAI,EAC0B,EAAE;YAC3D,OAAO,MAAM,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAC/C,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;gBAC3D,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACxE,IAAI,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC;oBAC9B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,iBAA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AAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QA1CA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAyCO,mBAAmB,CAAC,OAA0B;QACpD,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAC3B,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAC/B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -76,8 +76,8 @@ export class CopilotAction {
|
|
|
76
76
|
"\n" +
|
|
77
77
|
"Ask me anything about this API or try one of these example prompts:\n" +
|
|
78
78
|
"\n" +
|
|
79
|
-
"
|
|
80
|
-
"
|
|
79
|
+
"- `What authentication methods does this API support?`\n" +
|
|
80
|
+
"- `[Enter another prompt here]`";
|
|
81
81
|
await this.fileService.writeContents(tempFile, defaultContent);
|
|
82
82
|
this.prompts.openWelcomeMessageEditor();
|
|
83
83
|
await this.launcherService.openInEditor(tempFile);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DirectoryPath } from
|
|
2
|
-
import { ActionResult } from
|
|
3
|
-
import { CommandMetadata } from
|
|
1
|
+
import { DirectoryPath } from '../../types/file/directoryPath.js';
|
|
2
|
+
import { ActionResult } from '../action-result.js';
|
|
3
|
+
import { CommandMetadata } from '../../types/common/command-metadata.js';
|
|
4
4
|
export declare class PortalQuickstartAction {
|
|
5
5
|
private readonly prompts;
|
|
6
6
|
private readonly zipService;
|
|
@@ -11,6 +11,7 @@ export declare class PortalQuickstartAction {
|
|
|
11
11
|
private readonly buildFileUrl;
|
|
12
12
|
private readonly defaultSpecUrl;
|
|
13
13
|
private readonly repositoryFolderName;
|
|
14
|
+
private readonly validationService;
|
|
14
15
|
constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata);
|
|
15
16
|
readonly execute: () => Promise<ActionResult>;
|
|
16
17
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { getAuthInfo } from
|
|
2
|
-
import { FileService } from
|
|
3
|
-
import { withDirPath } from
|
|
4
|
-
import { ZipService } from
|
|
5
|
-
import { PortalQuickstartPrompts } from
|
|
6
|
-
import { UrlPath } from
|
|
7
|
-
import { LoginAction } from
|
|
8
|
-
import { ActionResult } from
|
|
9
|
-
import { PortalServeAction } from
|
|
10
|
-
import { ValidateAction } from
|
|
11
|
-
import { BuildContext } from
|
|
12
|
-
import { TempContext } from
|
|
13
|
-
import { FileDownloadService } from
|
|
14
|
-
import { getLanguagesConfig } from
|
|
15
|
-
import { SpecContext } from
|
|
1
|
+
import { getAuthInfo } from '../../client-utils/auth-manager.js';
|
|
2
|
+
import { FileService } from '../../infrastructure/file-service.js';
|
|
3
|
+
import { withDirPath } from '../../infrastructure/tmp-extensions.js';
|
|
4
|
+
import { ZipService } from '../../infrastructure/zip-service.js';
|
|
5
|
+
import { PortalQuickstartPrompts } from '../../prompts/portal/quickstart.js';
|
|
6
|
+
import { UrlPath } from '../../types/file/urlPath.js';
|
|
7
|
+
import { LoginAction } from '../auth/login.js';
|
|
8
|
+
import { ActionResult } from '../action-result.js';
|
|
9
|
+
import { PortalServeAction } from './serve.js';
|
|
10
|
+
import { ValidateAction } from '../api/validate.js';
|
|
11
|
+
import { BuildContext } from '../../types/build-context.js';
|
|
12
|
+
import { TempContext } from '../../types/temp-context.js';
|
|
13
|
+
import { FileDownloadService } from '../../infrastructure/services/file-download-service.js';
|
|
14
|
+
import { getLanguagesConfig } from '../../types/build/build.js';
|
|
15
|
+
import { SpecContext } from '../../types/spec-context.js';
|
|
16
|
+
import { ValidationService } from '../../infrastructure/services/validation-service.js';
|
|
17
|
+
import { FileName } from '../../types/file/fileName.js';
|
|
16
18
|
const defaultPort = 3000;
|
|
17
19
|
export class PortalQuickstartAction {
|
|
18
20
|
constructor(configDir, commandMetadata) {
|
|
@@ -22,7 +24,7 @@ export class PortalQuickstartAction {
|
|
|
22
24
|
this.fileDownloadService = new FileDownloadService();
|
|
23
25
|
this.buildFileUrl = new UrlPath(`https://github.com/apimatic/sample-docs-as-code-portal/archive/refs/heads/master.zip`);
|
|
24
26
|
this.defaultSpecUrl = new UrlPath(`https://raw.githubusercontent.com/apimatic/sample-docs-as-code-portal/refs/heads/master/src/spec/openapi.json`);
|
|
25
|
-
this.repositoryFolderName =
|
|
27
|
+
this.repositoryFolderName = 'sample-docs-as-code-portal-master/src';
|
|
26
28
|
this.execute = async () => {
|
|
27
29
|
const storedAuth = await getAuthInfo(this.configDir.toString());
|
|
28
30
|
if (!(storedAuth === null || storedAuth === void 0 ? void 0 : storedAuth.authKey)) {
|
|
@@ -32,6 +34,7 @@ export class PortalQuickstartAction {
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
return await withDirPath(async (tempDirectory) => {
|
|
37
|
+
var _a;
|
|
35
38
|
// Step 1/4
|
|
36
39
|
this.prompts.importSpecStep();
|
|
37
40
|
let specPath;
|
|
@@ -80,6 +83,25 @@ export class PortalQuickstartAction {
|
|
|
80
83
|
specPath = await specContext.save(downloadFileResult.value.stream, downloadFileResult.value.filename);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
86
|
+
if (validationResult.isSuccess()) {
|
|
87
|
+
const unallowed = validationResult.getValue();
|
|
88
|
+
if (unallowed && (((_a = unallowed.Features) === null || _a === void 0 ? void 0 : _a.length) > 0 || unallowed.EndpointCount > unallowed.EndpointLimit)) {
|
|
89
|
+
const config = {
|
|
90
|
+
features: unallowed.Features.filter((name) => !!name),
|
|
91
|
+
endpointsToKeep: unallowed.EndpointLimit
|
|
92
|
+
};
|
|
93
|
+
const stripUnallowedFeaturesResult = await this.validationService.stripUnallowedFeatures(specPath, config);
|
|
94
|
+
if (stripUnallowedFeaturesResult.isErr()) {
|
|
95
|
+
this.prompts.splitSpecDetected(unallowed);
|
|
96
|
+
return ActionResult.failed();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.prompts.stripUnallowedFeaturesStep(unallowed);
|
|
100
|
+
const specContext = new SpecContext(tempDirectory);
|
|
101
|
+
specPath = await specContext.save(stripUnallowedFeaturesResult.value, new FileName('pruned-spec.zip'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
83
105
|
// Step 3/4
|
|
84
106
|
this.prompts.selectLanguagesStep();
|
|
85
107
|
const languages = await this.prompts.selectLanguagesPrompt();
|
|
@@ -121,14 +143,14 @@ export class PortalQuickstartAction {
|
|
|
121
143
|
const buildFile = await tempBuildContext.getBuildFileContents();
|
|
122
144
|
buildFile.generatePortal.languageConfig = getLanguagesConfig(languages);
|
|
123
145
|
await tempBuildContext.updateBuildFileContents(buildFile);
|
|
124
|
-
const sourceDirectory = inputDirectory.join(
|
|
146
|
+
const sourceDirectory = inputDirectory.join('src');
|
|
125
147
|
await this.fileService.copyDirectoryContents(extractedFolder, sourceDirectory);
|
|
126
|
-
const specDirectory = sourceDirectory.join(
|
|
148
|
+
const specDirectory = sourceDirectory.join('spec');
|
|
127
149
|
const specContext = new SpecContext(specDirectory);
|
|
128
150
|
await specContext.replaceDefaultSpec(specPath);
|
|
129
151
|
const buildDirectoryStructure = await this.fileService.getDirectory(sourceDirectory);
|
|
130
152
|
this.prompts.printDirectoryStructure(inputDirectory, buildDirectoryStructure);
|
|
131
|
-
const portalDirectory = inputDirectory.join(
|
|
153
|
+
const portalDirectory = inputDirectory.join('portal');
|
|
132
154
|
const portalServeAction = new PortalServeAction(this.configDir, this.commandMetadata, null);
|
|
133
155
|
const result = await portalServeAction.execute(sourceDirectory, portalDirectory, defaultPort, true, false, () => {
|
|
134
156
|
this.prompts.nextSteps();
|
|
@@ -141,6 +163,7 @@ export class PortalQuickstartAction {
|
|
|
141
163
|
};
|
|
142
164
|
this.configDir = configDir;
|
|
143
165
|
this.commandMetadata = commandMetadata;
|
|
166
|
+
this.validationService = new ValidationService(this.configDir);
|
|
144
167
|
}
|
|
145
168
|
}
|
|
146
169
|
//# sourceMappingURL=quickstart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/actions/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/actions/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE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AC,QAAQ,CAAC,CAAC;gBAE/C,MAAM,uBAAuB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;gBACrF,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;gBAE9E,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACtD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;gBAC5F,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;oBAC9G,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;gBAC3B,CAAC,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACtB,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBAED,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAhKA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;CA8JF"}
|
|
@@ -2,8 +2,6 @@ import { createServer as createLiveReloadServer } from "livereload";
|
|
|
2
2
|
import connectLiveReload from "connect-livereload";
|
|
3
3
|
import express from "express";
|
|
4
4
|
import chokidar from "chokidar";
|
|
5
|
-
import crypto from "crypto";
|
|
6
|
-
import { Mutex } from "async-mutex";
|
|
7
5
|
import { PortalServePrompts } from "../../prompts/portal/serve.js";
|
|
8
6
|
import { ActionResult } from "../action-result.js";
|
|
9
7
|
import { GenerateAction } from "./generate.js";
|
|
@@ -62,9 +60,6 @@ export class PortalServeAction {
|
|
|
62
60
|
atomic: true
|
|
63
61
|
});
|
|
64
62
|
const deletedDirectories = new Set();
|
|
65
|
-
// TODO: Verify if we need mutex and eventQueue after refactoring.
|
|
66
|
-
const eventQueue = new Map();
|
|
67
|
-
const mutex = new Mutex();
|
|
68
63
|
const debounceService = new DebounceService();
|
|
69
64
|
watcher
|
|
70
65
|
.on("all", async (event, path) => {
|
|
@@ -79,17 +74,8 @@ export class PortalServeAction {
|
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
|
-
const eventId = `${Date.now()}-${crypto.randomUUID()}`;
|
|
83
|
-
await mutex.runExclusive(async () => {
|
|
84
|
-
eventQueue.clear();
|
|
85
|
-
eventQueue.set(eventId, path);
|
|
86
|
-
});
|
|
87
77
|
await debounceService.batchSingleRequest(async () => {
|
|
88
78
|
this.prompts.changesDetected();
|
|
89
|
-
// TODO: Verify if this is needed.
|
|
90
|
-
if (!eventQueue.has(eventId)) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
79
|
await generatePortalAction.execute(buildDirectory, portalDirectory, true, false, false);
|
|
94
80
|
liveReloadServer.refresh(portalDirectory.toString());
|
|
95
81
|
this.clearStandardInput();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/actions/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,OAAoB,MAAM,SAAS,CAAC;AAC3C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/actions/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,sBAAsB,E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AE,KAAK,CAAC,CAAC;gBACxF,gBAAgB,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACrD,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEL,6BAA6B;QAC7B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAEpC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACtB,eAAe,CAAC,KAAK,EAAE,CAAC;QACxB,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,mFAAmF;IAC3E,kBAAkB;QACxB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACzD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAChC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TocGroup } from
|
|
2
|
-
import { DirectoryPath } from
|
|
3
|
-
import { CommandMetadata } from
|
|
4
|
-
import { ActionResult } from
|
|
1
|
+
import { TocGroup } from '../../../types/toc/toc.js';
|
|
2
|
+
import { DirectoryPath } from '../../../types/file/directoryPath.js';
|
|
3
|
+
import { CommandMetadata } from '../../../types/common/command-metadata.js';
|
|
4
|
+
import { ActionResult } from '../../action-result.js';
|
|
5
5
|
export declare class ContentContext {
|
|
6
6
|
private readonly contentDirectory;
|
|
7
7
|
private readonly fileService;
|
|
@@ -17,5 +17,5 @@ export declare class PortalNewTocAction {
|
|
|
17
17
|
private readonly fileService;
|
|
18
18
|
private readonly portalService;
|
|
19
19
|
constructor(configDirectory: DirectoryPath, commandMetadata: CommandMetadata);
|
|
20
|
-
execute(buildDirectory: DirectoryPath, tocDirectory?: DirectoryPath, force?: boolean, expandEndpoints?: boolean, expandModels?: boolean): Promise<ActionResult>;
|
|
20
|
+
execute(buildDirectory: DirectoryPath, tocDirectory?: DirectoryPath, force?: boolean, expandEndpoints?: boolean, expandModels?: boolean, expandWebhooks?: boolean, expandCallbacks?: boolean): Promise<ActionResult>;
|
|
21
21
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { PortalService } from "../../../infrastructure/services/portal-service.js";
|
|
1
|
+
import { PortalNewTocPrompts } from '../../../prompts/portal/toc/new-toc.js';
|
|
2
|
+
import { TocStructureGenerator } from '../../../application/portal/toc/toc-structure-generator.js';
|
|
3
|
+
import { ActionResult } from '../../action-result.js';
|
|
4
|
+
import { TocContext } from '../../../types/toc-context.js';
|
|
5
|
+
import { FileService } from '../../../infrastructure/file-service.js';
|
|
6
|
+
import { BuildContext } from '../../../types/build-context.js';
|
|
7
|
+
import { extractCallbacksForToc, extractEndpointGroupsForToc, extractModelsForToc, extractWebhooksForToc } from '../../../types/sdl/sdl.js';
|
|
8
|
+
import { withDirPath } from '../../../infrastructure/tmp-extensions.js';
|
|
9
|
+
import { TempContext } from '../../../types/temp-context.js';
|
|
10
|
+
import { PortalService } from '../../../infrastructure/services/portal-service.js';
|
|
12
11
|
export class ContentContext {
|
|
13
12
|
constructor(contentDirectory) {
|
|
14
13
|
this.contentDirectory = contentDirectory;
|
|
@@ -31,7 +30,7 @@ export class PortalNewTocAction {
|
|
|
31
30
|
this.fileService = new FileService();
|
|
32
31
|
this.portalService = new PortalService();
|
|
33
32
|
}
|
|
34
|
-
async execute(buildDirectory, tocDirectory, force = false, expandEndpoints = false, expandModels = false) {
|
|
33
|
+
async execute(buildDirectory, tocDirectory, force = false, expandEndpoints = false, expandModels = false, expandWebhooks = false, expandCallbacks = false) {
|
|
35
34
|
var _a, _b;
|
|
36
35
|
// Validate build directory
|
|
37
36
|
const buildContext = new BuildContext(buildDirectory);
|
|
@@ -40,43 +39,43 @@ export class PortalNewTocAction {
|
|
|
40
39
|
return ActionResult.failed();
|
|
41
40
|
}
|
|
42
41
|
const buildConfig = await buildContext.getBuildFileContents();
|
|
43
|
-
const contentDirectory = buildDirectory.join((_b = (_a = buildConfig.generatePortal) === null || _a === void 0 ? void 0 : _a.contentFolder) !== null && _b !== void 0 ? _b :
|
|
42
|
+
const contentDirectory = buildDirectory.join((_b = (_a = buildConfig.generatePortal) === null || _a === void 0 ? void 0 : _a.contentFolder) !== null && _b !== void 0 ? _b : 'content');
|
|
44
43
|
const tocDir = tocDirectory !== null && tocDirectory !== void 0 ? tocDirectory : contentDirectory;
|
|
45
44
|
const tocContext = new TocContext(tocDir);
|
|
46
45
|
if (!force && (await tocContext.exists()) && !(await this.prompts.overwriteToc(tocContext.tocPath))) {
|
|
47
46
|
this.prompts.tocFileAlreadyExists();
|
|
48
47
|
return ActionResult.cancelled();
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const sdlTocComponents = await (async () => {
|
|
50
|
+
const defaultComponents = {
|
|
51
|
+
endpointGroups: new Map(),
|
|
52
|
+
models: [],
|
|
53
|
+
webhookGroups: new Map(),
|
|
54
|
+
callbackGroups: new Map()
|
|
55
|
+
};
|
|
56
|
+
const specDirectory = buildDirectory.join('spec');
|
|
53
57
|
if (!(await this.fileService.directoryExists(specDirectory))) {
|
|
54
58
|
this.prompts.fallingBackToDefault();
|
|
59
|
+
return defaultComponents;
|
|
55
60
|
}
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return ok({ endpointGroups: new Map(), models: [] });
|
|
66
|
-
}
|
|
67
|
-
return ok(getEndpointGroupsAndModels(result.value));
|
|
68
|
-
}
|
|
69
|
-
finally {
|
|
70
|
-
specFileStream.close();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
if (sdlResult.isErr()) {
|
|
74
|
-
this.prompts.logError(sdlResult.error);
|
|
75
|
-
return ActionResult.failed();
|
|
61
|
+
return await withDirPath(async (tempDirectory) => {
|
|
62
|
+
const tempContext = new TempContext(tempDirectory);
|
|
63
|
+
const specZipPath = await tempContext.zip(specDirectory);
|
|
64
|
+
const specFileStream = await this.fileService.getStream(specZipPath);
|
|
65
|
+
const result = await this.prompts.extractComponents(this.portalService.generateSdl(specFileStream, this.configDirectory, this.commandMetadata), expandEndpoints, expandModels, expandWebhooks, expandCallbacks);
|
|
66
|
+
specFileStream.close();
|
|
67
|
+
if (result.isErr()) {
|
|
68
|
+
this.prompts.fallingBackToDefault();
|
|
69
|
+
return defaultComponents;
|
|
76
70
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
return {
|
|
72
|
+
endpointGroups: extractEndpointGroupsForToc(result.value),
|
|
73
|
+
models: extractModelsForToc(result.value),
|
|
74
|
+
webhookGroups: extractWebhooksForToc(result.value),
|
|
75
|
+
callbackGroups: extractCallbacksForToc(result.value)
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
})();
|
|
80
79
|
const contentContext = new ContentContext(contentDirectory);
|
|
81
80
|
const contentExists = await contentContext.exists();
|
|
82
81
|
let contentGroups;
|
|
@@ -87,7 +86,7 @@ export class PortalNewTocAction {
|
|
|
87
86
|
else {
|
|
88
87
|
contentGroups = await contentContext.extractContentGroups();
|
|
89
88
|
}
|
|
90
|
-
const toc = this.tocGenerator.createTocStructure(
|
|
89
|
+
const toc = this.tocGenerator.createTocStructure({ data: sdlTocComponents.endpointGroups, expand: expandEndpoints }, { data: sdlTocComponents.models, expand: expandModels }, { data: sdlTocComponents.webhookGroups, expand: expandWebhooks }, { data: sdlTocComponents.callbackGroups, expand: expandCallbacks }, contentGroups);
|
|
91
90
|
const yamlString = this.tocGenerator.transformToYaml(toc);
|
|
92
91
|
const tocFilePath = await tocContext.save(yamlString);
|
|
93
92
|
this.prompts.tocCreated(tocFilePath);
|