api-farmer 0.0.6 → 0.0.7
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 -0
- package/dist/{chunk-BGSEKRRW.js → chunk-GHW46C2M.js} +2 -3
- package/dist/{chunk-TOPFUKIL.js → chunk-OBPECFFY.js} +0 -6
- package/dist/cli.cjs +1 -6
- package/dist/cli.js +2 -2
- package/dist/{generate-45FVXFDO.js → generate-QIKM4YKD.js} +2 -2
- package/dist/index.cjs +1 -8
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ npx af
|
|
|
51
51
|
|
|
52
52
|
> [!TIP]
|
|
53
53
|
> The generated content does not include the integration of the request client.
|
|
54
|
+
> If you allow ts code output, you will see a custom type called `Res`. This type needs to be defined in `global.d.ts` for use.
|
|
54
55
|
|
|
55
56
|
#### Some Examples
|
|
56
57
|
|
|
@@ -3,11 +3,10 @@ import {
|
|
|
3
3
|
createStatusCodesByStrategy,
|
|
4
4
|
getResponseMime,
|
|
5
5
|
hasQueryParameter,
|
|
6
|
-
hasResponseBody,
|
|
7
6
|
isRequiredRequestBody,
|
|
8
7
|
readSchema,
|
|
9
8
|
readTemplateFile
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OBPECFFY.js";
|
|
11
10
|
import {
|
|
12
11
|
__export
|
|
13
12
|
} from "./chunk-6OIOYGN7.js";
|
|
@@ -22844,7 +22843,7 @@ function partitionApiModules(schema2, transformer, options8) {
|
|
|
22844
22843
|
const statusCode = statusCodes[method] ?? 200;
|
|
22845
22844
|
const mime = getResponseMime(operation, statusCode);
|
|
22846
22845
|
const typeResponseBody = transformer.typeResponseBody({ verb, entity });
|
|
22847
|
-
const typeResponseBodyValue =
|
|
22846
|
+
const typeResponseBodyValue = mime ? transformer.typeResponseBodyValue({ type: type2, statusCode, mime }) : "never";
|
|
22848
22847
|
payloads3.push({
|
|
22849
22848
|
fn,
|
|
22850
22849
|
url: url2,
|
|
@@ -52,11 +52,6 @@ function readTemplateFile(preset = "axle") {
|
|
|
52
52
|
function hasQueryParameter(operation) {
|
|
53
53
|
return (operation.parameters ?? []).some((param) => "in" in param && param.in === "query");
|
|
54
54
|
}
|
|
55
|
-
function hasResponseBody(operation) {
|
|
56
|
-
return Object.values(operation.responses ?? {}).some(
|
|
57
|
-
(responseObject) => "content" in responseObject && responseObject.content
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
55
|
function getCliVersion() {
|
|
61
56
|
return fse.readJsonSync(CLI_PACKAGE_JSON).version;
|
|
62
57
|
}
|
|
@@ -74,7 +69,6 @@ export {
|
|
|
74
69
|
readSchema,
|
|
75
70
|
readTemplateFile,
|
|
76
71
|
hasQueryParameter,
|
|
77
|
-
hasResponseBody,
|
|
78
72
|
getCliVersion,
|
|
79
73
|
isRequiredRequestBody,
|
|
80
74
|
getResponseMime
|
package/dist/cli.cjs
CHANGED
|
@@ -93,11 +93,6 @@ function readTemplateFile(preset = "axle") {
|
|
|
93
93
|
function hasQueryParameter(operation) {
|
|
94
94
|
return (operation.parameters ?? []).some((param) => "in" in param && param.in === "query");
|
|
95
95
|
}
|
|
96
|
-
function hasResponseBody(operation) {
|
|
97
|
-
return Object.values(operation.responses ?? {}).some(
|
|
98
|
-
(responseObject) => "content" in responseObject && responseObject.content
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
96
|
function getCliVersion() {
|
|
102
97
|
return import_fs_extra.default.readJsonSync(CLI_PACKAGE_JSON).version;
|
|
103
98
|
}
|
|
@@ -102124,7 +102119,7 @@ function partitionApiModules(schema2, transformer, options8) {
|
|
|
102124
102119
|
const statusCode = statusCodes[method] ?? 200;
|
|
102125
102120
|
const mime = getResponseMime(operation, statusCode);
|
|
102126
102121
|
const typeResponseBody = transformer.typeResponseBody({ verb, entity });
|
|
102127
|
-
const typeResponseBodyValue =
|
|
102122
|
+
const typeResponseBodyValue = mime ? transformer.typeResponseBodyValue({ type: type2, statusCode, mime }) : "never";
|
|
102128
102123
|
payloads3.push({
|
|
102129
102124
|
fn: fn8,
|
|
102130
102125
|
url: url2,
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
getCliVersion
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OBPECFFY.js";
|
|
5
5
|
import "./chunk-6OIOYGN7.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
@@ -9,7 +9,7 @@ import { Command } from "commander";
|
|
|
9
9
|
var program = new Command();
|
|
10
10
|
program.version(getCliVersion());
|
|
11
11
|
program.action(async () => {
|
|
12
|
-
const { generate } = await import("./generate-
|
|
12
|
+
const { generate } = await import("./generate-QIKM4YKD.js");
|
|
13
13
|
return generate();
|
|
14
14
|
});
|
|
15
15
|
program.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -79234,7 +79234,6 @@ __export(index_exports, {
|
|
|
79234
79234
|
getConfig: () => getConfig,
|
|
79235
79235
|
getResponseMime: () => getResponseMime,
|
|
79236
79236
|
hasQueryParameter: () => hasQueryParameter,
|
|
79237
|
-
hasResponseBody: () => hasResponseBody,
|
|
79238
79237
|
isRequiredRequestBody: () => isRequiredRequestBody,
|
|
79239
79238
|
partitionApiModules: () => partitionApiModules,
|
|
79240
79239
|
pluralize: () => import_pluralize2.default,
|
|
@@ -102120,11 +102119,6 @@ function readTemplateFile(preset = "axle") {
|
|
|
102120
102119
|
function hasQueryParameter(operation) {
|
|
102121
102120
|
return (operation.parameters ?? []).some((param) => "in" in param && param.in === "query");
|
|
102122
102121
|
}
|
|
102123
|
-
function hasResponseBody(operation) {
|
|
102124
|
-
return Object.values(operation.responses ?? {}).some(
|
|
102125
|
-
(responseObject) => "content" in responseObject && responseObject.content
|
|
102126
|
-
);
|
|
102127
|
-
}
|
|
102128
102122
|
function getCliVersion() {
|
|
102129
102123
|
return import_fs_extra.default.readJsonSync(CLI_PACKAGE_JSON).version;
|
|
102130
102124
|
}
|
|
@@ -102163,7 +102157,7 @@ function partitionApiModules(schema2, transformer, options8) {
|
|
|
102163
102157
|
const statusCode = statusCodes[method] ?? 200;
|
|
102164
102158
|
const mime = getResponseMime(operation, statusCode);
|
|
102165
102159
|
const typeResponseBody = transformer.typeResponseBody({ verb, entity });
|
|
102166
|
-
const typeResponseBodyValue =
|
|
102160
|
+
const typeResponseBodyValue = mime ? transformer.typeResponseBodyValue({ type: type2, statusCode, mime }) : "never";
|
|
102167
102161
|
payloads3.push({
|
|
102168
102162
|
fn: fn8,
|
|
102169
102163
|
url: url2,
|
|
@@ -102271,7 +102265,6 @@ var import_pluralize2 = __toESM(require("pluralize"), 1);
|
|
|
102271
102265
|
getConfig,
|
|
102272
102266
|
getResponseMime,
|
|
102273
102267
|
hasQueryParameter,
|
|
102274
|
-
hasResponseBody,
|
|
102275
102268
|
isRequiredRequestBody,
|
|
102276
102269
|
partitionApiModules,
|
|
102277
102270
|
pluralize,
|
package/dist/index.d.cts
CHANGED
|
@@ -100,7 +100,6 @@ declare function createStatusCodesByStrategy(strategy: StatusCodeStrategy): {
|
|
|
100
100
|
declare function readSchema(input: string): Promise<OpenAPI3>;
|
|
101
101
|
declare function readTemplateFile(preset?: Preset): string;
|
|
102
102
|
declare function hasQueryParameter(operation: OperationObject): boolean;
|
|
103
|
-
declare function hasResponseBody(operation: OperationObject): boolean;
|
|
104
103
|
declare function getCliVersion(): any;
|
|
105
104
|
declare function isRequiredRequestBody(value: RequestBodyObject | ReferenceObject): boolean;
|
|
106
105
|
declare function getResponseMime(operation: OperationObject, statusCode: number): "application/json" | "*/*" | undefined;
|
|
@@ -252,4 +251,4 @@ type Config = GenerateOptions;
|
|
|
252
251
|
declare function defineConfig(config: Config): GenerateOptions;
|
|
253
252
|
declare function getConfig(): Promise<Config>;
|
|
254
253
|
|
|
255
|
-
export { type ApiModule, type ApiModulePayload, type ApiModuleTemplateData, type Config, type GenerateOptions, type Preset, type StatusCodeStrategy, type StatusCodes, type Transformer, createStatusCodesByStrategy, createTransformer, defineConfig, generate, generateTypes, getCliVersion, getConfig, getResponseMime, hasQueryParameter,
|
|
254
|
+
export { type ApiModule, type ApiModulePayload, type ApiModuleTemplateData, type Config, type GenerateOptions, type Preset, type StatusCodeStrategy, type StatusCodes, type Transformer, createStatusCodesByStrategy, createTransformer, defineConfig, generate, generateTypes, getCliVersion, getConfig, getResponseMime, hasQueryParameter, isRequiredRequestBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformModuleName, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
|
package/dist/index.d.ts
CHANGED
|
@@ -100,7 +100,6 @@ declare function createStatusCodesByStrategy(strategy: StatusCodeStrategy): {
|
|
|
100
100
|
declare function readSchema(input: string): Promise<OpenAPI3>;
|
|
101
101
|
declare function readTemplateFile(preset?: Preset): string;
|
|
102
102
|
declare function hasQueryParameter(operation: OperationObject): boolean;
|
|
103
|
-
declare function hasResponseBody(operation: OperationObject): boolean;
|
|
104
103
|
declare function getCliVersion(): any;
|
|
105
104
|
declare function isRequiredRequestBody(value: RequestBodyObject | ReferenceObject): boolean;
|
|
106
105
|
declare function getResponseMime(operation: OperationObject, statusCode: number): "application/json" | "*/*" | undefined;
|
|
@@ -252,4 +251,4 @@ type Config = GenerateOptions;
|
|
|
252
251
|
declare function defineConfig(config: Config): GenerateOptions;
|
|
253
252
|
declare function getConfig(): Promise<Config>;
|
|
254
253
|
|
|
255
|
-
export { type ApiModule, type ApiModulePayload, type ApiModuleTemplateData, type Config, type GenerateOptions, type Preset, type StatusCodeStrategy, type StatusCodes, type Transformer, createStatusCodesByStrategy, createTransformer, defineConfig, generate, generateTypes, getCliVersion, getConfig, getResponseMime, hasQueryParameter,
|
|
254
|
+
export { type ApiModule, type ApiModulePayload, type ApiModuleTemplateData, type Config, type GenerateOptions, type Preset, type StatusCodeStrategy, type StatusCodes, type Transformer, createStatusCodesByStrategy, createTransformer, defineConfig, generate, generateTypes, getCliVersion, getConfig, getResponseMime, hasQueryParameter, isRequiredRequestBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformModuleName, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
|
package/dist/index.js
CHANGED
|
@@ -19,17 +19,16 @@ import {
|
|
|
19
19
|
transformTypeValue,
|
|
20
20
|
transformUrl,
|
|
21
21
|
transformVerb
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GHW46C2M.js";
|
|
23
23
|
import {
|
|
24
24
|
createStatusCodesByStrategy,
|
|
25
25
|
getCliVersion,
|
|
26
26
|
getResponseMime,
|
|
27
27
|
hasQueryParameter,
|
|
28
|
-
hasResponseBody,
|
|
29
28
|
isRequiredRequestBody,
|
|
30
29
|
readSchema,
|
|
31
30
|
readTemplateFile
|
|
32
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-OBPECFFY.js";
|
|
33
32
|
import "./chunk-6OIOYGN7.js";
|
|
34
33
|
|
|
35
34
|
// src/index.ts
|
|
@@ -44,7 +43,6 @@ export {
|
|
|
44
43
|
getConfig,
|
|
45
44
|
getResponseMime,
|
|
46
45
|
hasQueryParameter,
|
|
47
|
-
hasResponseBody,
|
|
48
46
|
isRequiredRequestBody,
|
|
49
47
|
partitionApiModules,
|
|
50
48
|
default2 as pluralize,
|