api 7.0.0-beta.0 → 7.0.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 +1 -2
- package/dist/bin.js +8 -1
- package/dist/bin.js.map +1 -1
- package/dist/codegen/codegenerator.d.ts +44 -11
- package/dist/codegen/codegenerator.d.ts.map +1 -1
- package/dist/codegen/codegenerator.js +77 -0
- package/dist/codegen/codegenerator.js.map +1 -1
- package/dist/codegen/factory.d.ts +19 -3
- package/dist/codegen/factory.d.ts.map +1 -1
- package/dist/codegen/factory.js +12 -5
- package/dist/codegen/factory.js.map +1 -1
- package/dist/codegen/languages/typescript/index.d.ts +39 -5
- package/dist/codegen/languages/typescript/index.d.ts.map +1 -1
- package/dist/codegen/languages/typescript/index.js +268 -62
- package/dist/codegen/languages/typescript/index.js.map +1 -1
- package/dist/codegen/languages/typescript/util.d.ts.map +1 -1
- package/dist/codegen/languages/typescript/util.js +1 -3
- package/dist/codegen/languages/typescript/util.js.map +1 -1
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +4 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +71 -58
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +37 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/uninstall.d.ts +4 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +69 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/fetcher.d.ts +17 -17
- package/dist/fetcher.d.ts.map +1 -1
- package/dist/fetcher.js +7 -1
- package/dist/fetcher.js.map +1 -1
- package/dist/lib/isCI.d.ts +8 -0
- package/dist/lib/isCI.d.ts.map +1 -0
- package/dist/lib/isCI.js +18 -0
- package/dist/lib/isCI.js.map +1 -0
- package/dist/lib/prompt.d.ts +1 -1
- package/dist/lib/prompt.d.ts.map +1 -1
- package/dist/lib/prompt.js +33 -8
- package/dist/lib/prompt.js.map +1 -1
- package/dist/lib/suggestedOperations.d.ts +31 -0
- package/dist/lib/suggestedOperations.d.ts.map +1 -0
- package/dist/lib/suggestedOperations.js +108 -0
- package/dist/lib/suggestedOperations.js.map +1 -0
- package/dist/lockfileSchema.d.ts +125 -0
- package/dist/lockfileSchema.d.ts.map +1 -0
- package/dist/lockfileSchema.js +78 -0
- package/dist/lockfileSchema.js.map +1 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +5 -1
- package/dist/logger.js.map +1 -1
- package/dist/packageInfo.d.ts +1 -1
- package/dist/packageInfo.d.ts.map +1 -1
- package/dist/packageInfo.js +1 -1
- package/dist/packageInfo.js.map +1 -1
- package/dist/storage.d.ts +79 -62
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +112 -30
- package/dist/storage.js.map +1 -1
- package/legacy-require-handler.cjs +29 -0
- package/legacy-require-handler.d.cts +2 -0
- package/package.json +49 -35
- package/schema.json +69 -0
- package/src/bin.ts +0 -21
- package/src/codegen/codegenerator.ts +0 -75
- package/src/codegen/factory.ts +0 -23
- package/src/codegen/languages/typescript/index.ts +0 -984
- package/src/codegen/languages/typescript/util.ts +0 -174
- package/src/commands/index.ts +0 -5
- package/src/commands/install.ts +0 -196
- package/src/fetcher.ts +0 -145
- package/src/lib/prompt.ts +0 -29
- package/src/logger.ts +0 -10
- package/src/packageInfo.ts +0 -3
- package/src/storage.ts +0 -333
- package/tsconfig.json +0 -10
package/dist/lib/prompt.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
|
+
import isCI from './isCI.js';
|
|
2
3
|
/**
|
|
3
4
|
* The `prompts` library doesn't always interpret CTRL+C and release the terminal back to the user
|
|
4
5
|
* so we need handle this ourselves. This function is just a simple overload of the main `prompts`
|
|
@@ -6,19 +7,43 @@ import prompts from 'prompts';
|
|
|
6
7
|
*
|
|
7
8
|
* @see {@link https://github.com/terkelg/prompts/issues/252}
|
|
8
9
|
*/
|
|
9
|
-
export default async function promptTerminal(
|
|
10
|
+
export default async function promptTerminal(questions, options) {
|
|
10
11
|
const enableTerminalCursor = () => {
|
|
11
12
|
process.stdout.write('\x1B[?25h');
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The CTRL+C handler discussed above.
|
|
16
|
+
* @see {@link https://github.com/terkelg/prompts#optionsoncancel}
|
|
17
|
+
*/
|
|
18
|
+
const onCancel = () => {
|
|
19
|
+
// If we don't re-enable the terminal cursor before exiting the program, the cursor will
|
|
20
|
+
// remain hidden.
|
|
21
|
+
enableTerminalCursor();
|
|
22
|
+
process.stdout.write('\n');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Runs a check before every prompt renders to make sure that
|
|
27
|
+
* prompt is not being run in a CI environment.
|
|
28
|
+
*/
|
|
29
|
+
function onRender() {
|
|
30
|
+
if (isCI()) {
|
|
18
31
|
process.stdout.write('\n');
|
|
32
|
+
process.stdout.write('Yikes! Looks like we were about to prompt you for something in a CI environment. Are you missing an argument?');
|
|
33
|
+
process.stdout.write('\n\n');
|
|
34
|
+
process.stdout.write('Try running `api <command> --help` to get more information.');
|
|
35
|
+
process.stdout.write('\n\n');
|
|
19
36
|
process.exit(1);
|
|
20
37
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(questions)) {
|
|
40
|
+
// eslint-disable-next-line no-param-reassign
|
|
41
|
+
questions = questions.map(question => ({ onRender, ...question }));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// eslint-disable-next-line no-param-reassign
|
|
45
|
+
questions.onRender = onRender;
|
|
46
|
+
}
|
|
47
|
+
return prompts(questions, { onCancel, ...options });
|
|
23
48
|
}
|
|
24
49
|
//# sourceMappingURL=prompt.js.map
|
package/dist/lib/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/lib/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAC1C,
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/lib/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAC1C,SAA8D,EAC9D,OAAyB;IAEzB,MAAM,oBAAoB,GAAG,GAAG,EAAE;QAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF;;;OAGG;IACH,MAAM,QAAQ,GAAG,GAAG,EAAE;QACpB,wFAAwF;QACxF,iBAAiB;QACjB,oBAAoB,EAAE,CAAC;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF;;;OAGG;IACH,SAAS,QAAQ;QACf,IAAI,IAAI,EAAE,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,+GAA+G,CAChH,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACpF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,6CAA6C;QAC7C,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,6CAA6C;QAC7C,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type Oas from 'oas';
|
|
2
|
+
import type { Operation } from 'oas/operation';
|
|
3
|
+
/**
|
|
4
|
+
* Return a list of suggested and "good first issue" types of endpoints that we can build a post-SDK
|
|
5
|
+
* code generation code snippet around to demo the power of `api`.
|
|
6
|
+
*
|
|
7
|
+
* The criteria for a suggested endpoint are the following:
|
|
8
|
+
* - GET request
|
|
9
|
+
* - Has no required query or body parameters
|
|
10
|
+
* - Endpoint has not been deprecated
|
|
11
|
+
*
|
|
12
|
+
* @param oas
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSuggestedOperation(oas: Oas): false | Operation;
|
|
15
|
+
/**
|
|
16
|
+
* Generate an example code snippet for a given (suggested) operation. We'll show this to users
|
|
17
|
+
* post-codegeneration so they can see how to use the SDK we created for them.
|
|
18
|
+
*
|
|
19
|
+
* We're intentionally using `httpsnippet-client-api` and not `@readme/oas-to-snippet` here,
|
|
20
|
+
* which would handle HAR and snippet generation, because don't need the entire `oas-to-snippet`
|
|
21
|
+
* and `@readme/httpsnippet` libraries for what we're doing here.
|
|
22
|
+
*
|
|
23
|
+
* All we want to do is generate a very simple code example for `api` snippets and as we're
|
|
24
|
+
* controlling which kinds of endpoints we're generating these for the HAR dataset we're working
|
|
25
|
+
* with is a mostly fully known object.
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildCodeSnippetForOperation(oas: Oas, operation: Operation, opts: {
|
|
29
|
+
identifier: string;
|
|
30
|
+
}): Promise<string | false>;
|
|
31
|
+
//# sourceMappingURL=suggestedOperations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestedOperations.d.ts","sourceRoot":"","sources":["../../src/lib/suggestedOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM/C;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,qBAgC7C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,4BAA4B,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,2BA2D9G"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import APICore from '@readme/api-core';
|
|
2
|
+
import apiSnippetPlugin from 'httpsnippet-client-api';
|
|
3
|
+
import { Webhook } from 'oas/operation';
|
|
4
|
+
/**
|
|
5
|
+
* Return a list of suggested and "good first issue" types of endpoints that we can build a post-SDK
|
|
6
|
+
* code generation code snippet around to demo the power of `api`.
|
|
7
|
+
*
|
|
8
|
+
* The criteria for a suggested endpoint are the following:
|
|
9
|
+
* - GET request
|
|
10
|
+
* - Has no required query or body parameters
|
|
11
|
+
* - Endpoint has not been deprecated
|
|
12
|
+
*
|
|
13
|
+
* @param oas
|
|
14
|
+
*/
|
|
15
|
+
export function getSuggestedOperation(oas) {
|
|
16
|
+
const suggested = [];
|
|
17
|
+
Object.values(oas.getPaths()).forEach(path => {
|
|
18
|
+
Object.values(path).forEach(operation => {
|
|
19
|
+
// We don't really support webhooks with this library so if this operation is one we shouldn't
|
|
20
|
+
// return it as a recommended operation.
|
|
21
|
+
if (operation instanceof Webhook) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (operation.isDeprecated()) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (operation.method.toLowerCase() === 'get') {
|
|
28
|
+
const hasRequiredParameters = operation.hasRequiredParameters();
|
|
29
|
+
const hasRequiredRequestBody = operation.hasRequiredRequestBody();
|
|
30
|
+
// If the criteria matches, push it into a recommended array
|
|
31
|
+
if (!hasRequiredParameters && !hasRequiredRequestBody) {
|
|
32
|
+
suggested.push(operation);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
if (suggested.length) {
|
|
38
|
+
return suggested[0];
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate an example code snippet for a given (suggested) operation. We'll show this to users
|
|
44
|
+
* post-codegeneration so they can see how to use the SDK we created for them.
|
|
45
|
+
*
|
|
46
|
+
* We're intentionally using `httpsnippet-client-api` and not `@readme/oas-to-snippet` here,
|
|
47
|
+
* which would handle HAR and snippet generation, because don't need the entire `oas-to-snippet`
|
|
48
|
+
* and `@readme/httpsnippet` libraries for what we're doing here.
|
|
49
|
+
*
|
|
50
|
+
* All we want to do is generate a very simple code example for `api` snippets and as we're
|
|
51
|
+
* controlling which kinds of endpoints we're generating these for the HAR dataset we're working
|
|
52
|
+
* with is a mostly fully known object.
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
export async function buildCodeSnippetForOperation(oas, operation, opts) {
|
|
56
|
+
const core = new APICore();
|
|
57
|
+
core.setSpec(oas);
|
|
58
|
+
// If this endpoint has authentication on it then we should try to flesh out some placeholder
|
|
59
|
+
// values in the `.auth()` SDK method for them so they can see how to use auth.
|
|
60
|
+
let auth = {};
|
|
61
|
+
const hasAuth = !!operation.getSecurity()?.length;
|
|
62
|
+
if (hasAuth) {
|
|
63
|
+
operation.getSecurityWithTypes().forEach(schemes => {
|
|
64
|
+
if (!schemes)
|
|
65
|
+
return;
|
|
66
|
+
schemes.filter(Boolean).forEach(scheme => {
|
|
67
|
+
if (!scheme)
|
|
68
|
+
return;
|
|
69
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
70
|
+
const schemeName = scheme.security._key;
|
|
71
|
+
if (scheme?.type === 'Basic') {
|
|
72
|
+
auth[schemeName] = { user: 'username', pass: 'password' };
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
auth[schemeName] = 'token';
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
auth = oas.getAuth(auth);
|
|
80
|
+
}
|
|
81
|
+
const har = core.getHARForRequest(operation, {}, auth)?.log?.entries?.[0]?.request;
|
|
82
|
+
if (!har) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const snippet = apiSnippetPlugin.client.convert({
|
|
86
|
+
...har,
|
|
87
|
+
cookiesObj: har.cookies.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {}),
|
|
88
|
+
fullUrl: har.url,
|
|
89
|
+
headersObj: har.headers.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {}),
|
|
90
|
+
postData: {
|
|
91
|
+
mimeType: 'application/json',
|
|
92
|
+
text: '',
|
|
93
|
+
},
|
|
94
|
+
queryObj: har.queryString.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {}),
|
|
95
|
+
url: har.url,
|
|
96
|
+
// These aren't used in `httpsnippet-client-api` so we don't need to bother hooking them up.
|
|
97
|
+
allHeaders: {},
|
|
98
|
+
uriObj: {},
|
|
99
|
+
}, {
|
|
100
|
+
api: {
|
|
101
|
+
definition: oas.getDefinition(),
|
|
102
|
+
identifier: opts.identifier,
|
|
103
|
+
registryURI: opts.identifier,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
return snippet;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=suggestedOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestedOperations.js","sourceRoot":"","sources":["../../src/lib/suggestedOperations.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ;IAC5C,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtC,8FAA8F;YAC9F,wCAAwC;YACxC,IAAI,SAAS,YAAY,OAAO,EAAE,CAAC;gBACjC,OAAO;YACT,CAAC;YAED,IAAI,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC;gBAC7B,OAAO;YACT,CAAC;YAED,IAAI,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;gBAC7C,MAAM,qBAAqB,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;gBAChE,MAAM,sBAAsB,GAAG,SAAS,CAAC,sBAAsB,EAAE,CAAC;gBAElE,4DAA4D;gBAC5D,IAAI,CAAC,qBAAqB,IAAI,CAAC,sBAAsB,EAAE,CAAC;oBACtD,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO,SA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|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { FromSchema } from '@readme/api-core/types';
|
|
2
|
+
declare const lockfileApiSchema: {
|
|
3
|
+
readonly type: "object";
|
|
4
|
+
readonly required: readonly ["createdAt", "identifier", "installerVersion", "integrity"];
|
|
5
|
+
readonly properties: {
|
|
6
|
+
readonly createdAt: {
|
|
7
|
+
readonly type: "string";
|
|
8
|
+
readonly format: "date-time";
|
|
9
|
+
readonly description: "The date that this SDK was installed.";
|
|
10
|
+
readonly examples: readonly ["2023-10-19T20:35:39.268Z"];
|
|
11
|
+
};
|
|
12
|
+
readonly identifier: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "A unique identifier of the API. This'll be used to do imports on `@api/<identifier>` and also where the SDK code will be located in `.api/apis/<identifier>`";
|
|
15
|
+
readonly examples: readonly ["petstore"];
|
|
16
|
+
};
|
|
17
|
+
readonly installerVersion: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "The version of `api` that was used to install this SDK.";
|
|
20
|
+
readonly examples: readonly ["7.0.0"];
|
|
21
|
+
};
|
|
22
|
+
readonly integrity: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "An integrity hash that will be used to determine on `npx api update` calls if the API has changed since the SDK was last generated.";
|
|
25
|
+
readonly examples: readonly ["sha512-otRF5TLMeDczSJlrmWLNDHLfmXg+C98oa/I/X2WWycwngh+a6WsbnjTbfwKGRU5DFbagOn2qX2SRvtBGOBRVGg=="];
|
|
26
|
+
};
|
|
27
|
+
readonly language: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly description: "The language that this SDK was generated for.";
|
|
30
|
+
readonly default: "js";
|
|
31
|
+
readonly enum: "js"[];
|
|
32
|
+
};
|
|
33
|
+
readonly private: {
|
|
34
|
+
readonly type: "boolean";
|
|
35
|
+
readonly description: "Was this SDK installed as a private, unpublished, package to the filesystem?";
|
|
36
|
+
};
|
|
37
|
+
readonly source: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly description: "The original source that was used to generate the SDK with.";
|
|
40
|
+
readonly examples: readonly ["https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json", "./petstore.json", "@developers/v2.0#nysezql0wwo236"];
|
|
41
|
+
};
|
|
42
|
+
readonly updatedAt: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly format: "date-time";
|
|
45
|
+
readonly description: "The date that this SDK was last rebuilt or updated.";
|
|
46
|
+
readonly examples: readonly ["2023-10-19T20:35:39.268Z"];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly additionalProperties: false;
|
|
50
|
+
};
|
|
51
|
+
export declare const lockfileSchema: {
|
|
52
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
53
|
+
readonly title: "api storage lockfile";
|
|
54
|
+
readonly description: "See https://api.readme.dev/docs";
|
|
55
|
+
readonly type: "object";
|
|
56
|
+
readonly required: readonly ["apis"];
|
|
57
|
+
readonly additionalProperties: false;
|
|
58
|
+
readonly properties: {
|
|
59
|
+
readonly $schema: {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
};
|
|
62
|
+
readonly apis: {
|
|
63
|
+
readonly type: "array";
|
|
64
|
+
readonly description: "The list of installed APIs";
|
|
65
|
+
readonly items: {
|
|
66
|
+
readonly $ref: "#/definitions/api";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly definitions: {
|
|
71
|
+
readonly api: {
|
|
72
|
+
readonly type: "object";
|
|
73
|
+
readonly required: readonly ["createdAt", "identifier", "installerVersion", "integrity"];
|
|
74
|
+
readonly properties: {
|
|
75
|
+
readonly createdAt: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly format: "date-time";
|
|
78
|
+
readonly description: "The date that this SDK was installed.";
|
|
79
|
+
readonly examples: readonly ["2023-10-19T20:35:39.268Z"];
|
|
80
|
+
};
|
|
81
|
+
readonly identifier: {
|
|
82
|
+
readonly type: "string";
|
|
83
|
+
readonly description: "A unique identifier of the API. This'll be used to do imports on `@api/<identifier>` and also where the SDK code will be located in `.api/apis/<identifier>`";
|
|
84
|
+
readonly examples: readonly ["petstore"];
|
|
85
|
+
};
|
|
86
|
+
readonly installerVersion: {
|
|
87
|
+
readonly type: "string";
|
|
88
|
+
readonly description: "The version of `api` that was used to install this SDK.";
|
|
89
|
+
readonly examples: readonly ["7.0.0"];
|
|
90
|
+
};
|
|
91
|
+
readonly integrity: {
|
|
92
|
+
readonly type: "string";
|
|
93
|
+
readonly description: "An integrity hash that will be used to determine on `npx api update` calls if the API has changed since the SDK was last generated.";
|
|
94
|
+
readonly examples: readonly ["sha512-otRF5TLMeDczSJlrmWLNDHLfmXg+C98oa/I/X2WWycwngh+a6WsbnjTbfwKGRU5DFbagOn2qX2SRvtBGOBRVGg=="];
|
|
95
|
+
};
|
|
96
|
+
readonly language: {
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
readonly description: "The language that this SDK was generated for.";
|
|
99
|
+
readonly default: "js";
|
|
100
|
+
readonly enum: "js"[];
|
|
101
|
+
};
|
|
102
|
+
readonly private: {
|
|
103
|
+
readonly type: "boolean";
|
|
104
|
+
readonly description: "Was this SDK installed as a private, unpublished, package to the filesystem?";
|
|
105
|
+
};
|
|
106
|
+
readonly source: {
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
readonly description: "The original source that was used to generate the SDK with.";
|
|
109
|
+
readonly examples: readonly ["https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json", "./petstore.json", "@developers/v2.0#nysezql0wwo236"];
|
|
110
|
+
};
|
|
111
|
+
readonly updatedAt: {
|
|
112
|
+
readonly type: "string";
|
|
113
|
+
readonly format: "date-time";
|
|
114
|
+
readonly description: "The date that this SDK was last rebuilt or updated.";
|
|
115
|
+
readonly examples: readonly ["2023-10-19T20:35:39.268Z"];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly additionalProperties: false;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export type Lockfile = FromSchema<typeof lockfileSchema>;
|
|
123
|
+
export type LockfileAPI = FromSchema<typeof lockfileApiSchema>;
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=lockfileSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockfileSchema.d.ts","sourceRoot":"","sources":["../src/lockfileSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDb,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBjB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { SupportedLanguages } from './codegen/factory.js';
|
|
2
|
+
const lockfileApiSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
required: ['createdAt', 'identifier', 'installerVersion', 'integrity'],
|
|
5
|
+
properties: {
|
|
6
|
+
createdAt: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
format: 'date-time',
|
|
9
|
+
description: 'The date that this SDK was installed.',
|
|
10
|
+
examples: ['2023-10-19T20:35:39.268Z'],
|
|
11
|
+
},
|
|
12
|
+
identifier: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: "A unique identifier of the API. This'll be used to do imports on `@api/<identifier>` and also where the SDK code will be located in `.api/apis/<identifier>`",
|
|
15
|
+
examples: ['petstore'],
|
|
16
|
+
},
|
|
17
|
+
installerVersion: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'The version of `api` that was used to install this SDK.',
|
|
20
|
+
examples: ['7.0.0'],
|
|
21
|
+
},
|
|
22
|
+
integrity: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'An integrity hash that will be used to determine on `npx api update` calls if the API has changed since the SDK was last generated.',
|
|
25
|
+
examples: ['sha512-otRF5TLMeDczSJlrmWLNDHLfmXg+C98oa/I/X2WWycwngh+a6WsbnjTbfwKGRU5DFbagOn2qX2SRvtBGOBRVGg=='],
|
|
26
|
+
},
|
|
27
|
+
language: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'The language that this SDK was generated for.',
|
|
30
|
+
default: SupportedLanguages.JS,
|
|
31
|
+
enum: Object.values(SupportedLanguages),
|
|
32
|
+
},
|
|
33
|
+
private: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Was this SDK installed as a private, unpublished, package to the filesystem?',
|
|
36
|
+
},
|
|
37
|
+
source: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'The original source that was used to generate the SDK with.',
|
|
40
|
+
examples: [
|
|
41
|
+
'https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json',
|
|
42
|
+
'./petstore.json',
|
|
43
|
+
'@developers/v2.0#nysezql0wwo236',
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
updatedAt: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
format: 'date-time',
|
|
49
|
+
description: 'The date that this SDK was last rebuilt or updated.',
|
|
50
|
+
examples: ['2023-10-19T20:35:39.268Z'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
};
|
|
55
|
+
export const lockfileSchema = {
|
|
56
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
57
|
+
title: 'api storage lockfile',
|
|
58
|
+
description: 'See https://api.readme.dev/docs',
|
|
59
|
+
type: 'object',
|
|
60
|
+
required: ['apis'],
|
|
61
|
+
additionalProperties: false,
|
|
62
|
+
properties: {
|
|
63
|
+
$schema: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
},
|
|
66
|
+
apis: {
|
|
67
|
+
type: 'array',
|
|
68
|
+
description: 'The list of installed APIs',
|
|
69
|
+
items: {
|
|
70
|
+
$ref: '#/definitions/api',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
definitions: {
|
|
75
|
+
api: lockfileApiSchema,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=lockfileSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockfileSchema.js","sourceRoot":"","sources":["../src/lockfileSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,CAAC;IACtE,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,CAAC,0BAA0B,CAAC;SACvC;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,8JAA8J;YAChK,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,qIAAqI;YACvI,QAAQ,EAAE,CAAC,iGAAiG,CAAC;SAC9G;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,+CAA+C;YAC5D,OAAO,EAAE,kBAAkB,CAAC,EAAE;YAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;SACxC;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,8EAA8E;SAC5F;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6DAA6D;YAC1E,QAAQ,EAAE;gBACR,4FAA4F;gBAC5F,iBAAiB;gBACjB,iCAAiC;aAClC;SACF;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,qDAAqD;YAClE,QAAQ,EAAE,CAAC,0BAA0B,CAAC;SACvC;KACF;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EAAE,iCAAiC;IAC9C,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,CAAC;IAClB,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;SACf;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,4BAA4B;YACzC,KAAK,EAAE;gBACL,IAAI,EAAE,mBAAmB;aAC1B;SACF;KACF;IACD,WAAW,EAAE;QACX,GAAG,EAAE,iBAAiB;KACvB;CACO,CAAC"}
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,KAAK,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,QAM1D;AAED,wBAAgB,UAAU,eAKzB"}
|
package/dist/logger.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import chalk from 'chalk';
|
|
3
2
|
export default function logger(log, error) {
|
|
4
3
|
if (error) {
|
|
@@ -8,4 +7,9 @@ export default function logger(log, error) {
|
|
|
8
7
|
console.log(log);
|
|
9
8
|
}
|
|
10
9
|
}
|
|
10
|
+
export function oraOptions() {
|
|
11
|
+
// Disables spinner in tests so it doesn't pollute test output
|
|
12
|
+
const opts = { isSilent: process.env.NODE_ENV === 'test' };
|
|
13
|
+
return opts;
|
|
14
|
+
}
|
|
11
15
|
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAW,EAAE,KAAe;IACzD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,8DAA8D;IAC9D,MAAM,IAAI,GAAe,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;IAEvE,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/packageInfo.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageInfo.d.ts","sourceRoot":"","sources":["../src/packageInfo.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"packageInfo.d.ts","sourceRoot":"","sources":["../src/packageInfo.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,kBAAkB,CAAC"}
|
package/dist/packageInfo.js
CHANGED
package/dist/packageInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageInfo.js","sourceRoot":"","sources":["../src/packageInfo.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"packageInfo.js","sourceRoot":"","sources":["../src/packageInfo.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC"}
|