api-farmer 0.0.1 → 0.0.3
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/dist/{chunk-HMKED3BC.js → chunk-JWKB7AQQ.js} +7 -2
- package/dist/cli.cjs +5 -1
- package/dist/cli.js +1 -1
- package/dist/{generate-3DZVV2U4.js → generate-LOGO7XCM.js} +1 -1
- package/dist/index.cjs +12 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +7 -1
- package/package.json +2 -2
|
@@ -22735,7 +22735,10 @@ async function getConfig() {
|
|
|
22735
22735
|
|
|
22736
22736
|
// src/transformer.ts
|
|
22737
22737
|
import pluralize from "pluralize";
|
|
22738
|
-
import { pascalCase } from "rattail";
|
|
22738
|
+
import { camelize, pascalCase } from "rattail";
|
|
22739
|
+
function transformModuleName(name) {
|
|
22740
|
+
return camelize(name);
|
|
22741
|
+
}
|
|
22739
22742
|
function transformVerb(method) {
|
|
22740
22743
|
switch (method) {
|
|
22741
22744
|
case "post":
|
|
@@ -22792,6 +22795,7 @@ function transformTypeResponseBodyValue(type2, statusCode, mime) {
|
|
|
22792
22795
|
}
|
|
22793
22796
|
function createTransformer() {
|
|
22794
22797
|
return {
|
|
22798
|
+
moduleName: transformModuleName,
|
|
22795
22799
|
verb: transformVerb,
|
|
22796
22800
|
url: transformUrl,
|
|
22797
22801
|
entity: transformEntity,
|
|
@@ -22853,7 +22857,7 @@ function partitionApiModules(schema2, transformer, options8) {
|
|
|
22853
22857
|
payloads2.push(...childPayloads);
|
|
22854
22858
|
return payloads2;
|
|
22855
22859
|
}, []);
|
|
22856
|
-
apiModules2.push({ name, payloads });
|
|
22860
|
+
apiModules2.push({ name: transformer.moduleName(name), payloads });
|
|
22857
22861
|
return apiModules2;
|
|
22858
22862
|
}, []);
|
|
22859
22863
|
return apiModules;
|
|
@@ -22929,6 +22933,7 @@ async function generate(userOptions = {}) {
|
|
|
22929
22933
|
export {
|
|
22930
22934
|
defineConfig,
|
|
22931
22935
|
getConfig,
|
|
22936
|
+
transformModuleName,
|
|
22932
22937
|
transformVerb,
|
|
22933
22938
|
transformUrl,
|
|
22934
22939
|
transformEntity,
|
package/dist/cli.cjs
CHANGED
|
@@ -101995,6 +101995,9 @@ var init_config = __esm({
|
|
|
101995
101995
|
});
|
|
101996
101996
|
|
|
101997
101997
|
// src/transformer.ts
|
|
101998
|
+
function transformModuleName(name) {
|
|
101999
|
+
return (0, import_rattail.camelize)(name);
|
|
102000
|
+
}
|
|
101998
102001
|
function transformVerb(method) {
|
|
101999
102002
|
switch (method) {
|
|
102000
102003
|
case "post":
|
|
@@ -102051,6 +102054,7 @@ function transformTypeResponseBodyValue(type2, statusCode, mime) {
|
|
|
102051
102054
|
}
|
|
102052
102055
|
function createTransformer() {
|
|
102053
102056
|
return {
|
|
102057
|
+
moduleName: transformModuleName,
|
|
102054
102058
|
verb: transformVerb,
|
|
102055
102059
|
url: transformUrl,
|
|
102056
102060
|
entity: transformEntity,
|
|
@@ -102128,7 +102132,7 @@ function partitionApiModules(schema2, transformer, options8) {
|
|
|
102128
102132
|
payloads2.push(...childPayloads);
|
|
102129
102133
|
return payloads2;
|
|
102130
102134
|
}, []);
|
|
102131
|
-
apiModules2.push({ name, payloads });
|
|
102135
|
+
apiModules2.push({ name: transformer.moduleName(name), payloads });
|
|
102132
102136
|
return apiModules2;
|
|
102133
102137
|
}, []);
|
|
102134
102138
|
return apiModules;
|
package/dist/cli.js
CHANGED
|
@@ -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-LOGO7XCM.js");
|
|
13
13
|
return generate();
|
|
14
14
|
});
|
|
15
15
|
program.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -79235,11 +79235,13 @@ __export(index_exports, {
|
|
|
79235
79235
|
hasQueryParameter: () => hasQueryParameter,
|
|
79236
79236
|
hasResponseBody: () => hasResponseBody,
|
|
79237
79237
|
partitionApiModules: () => partitionApiModules,
|
|
79238
|
+
pluralize: () => import_pluralize2.default,
|
|
79238
79239
|
readSchema: () => readSchema,
|
|
79239
79240
|
readTemplateFile: () => readTemplateFile,
|
|
79240
79241
|
renderApiModules: () => renderApiModules,
|
|
79241
79242
|
transformEntity: () => transformEntity,
|
|
79242
79243
|
transformFn: () => transformFn,
|
|
79244
|
+
transformModuleName: () => transformModuleName,
|
|
79243
79245
|
transformType: () => transformType,
|
|
79244
79246
|
transformTypeQuery: () => transformTypeQuery,
|
|
79245
79247
|
transformTypeQueryValue: () => transformTypeQueryValue,
|
|
@@ -79258,6 +79260,9 @@ init_cjs_shims();
|
|
|
79258
79260
|
init_cjs_shims();
|
|
79259
79261
|
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
79260
79262
|
var import_rattail = require("rattail");
|
|
79263
|
+
function transformModuleName(name) {
|
|
79264
|
+
return (0, import_rattail.camelize)(name);
|
|
79265
|
+
}
|
|
79261
79266
|
function transformVerb(method) {
|
|
79262
79267
|
switch (method) {
|
|
79263
79268
|
case "post":
|
|
@@ -79314,6 +79319,7 @@ function transformTypeResponseBodyValue(type2, statusCode, mime) {
|
|
|
79314
79319
|
}
|
|
79315
79320
|
function createTransformer() {
|
|
79316
79321
|
return {
|
|
79322
|
+
moduleName: transformModuleName,
|
|
79317
79323
|
verb: transformVerb,
|
|
79318
79324
|
url: transformUrl,
|
|
79319
79325
|
entity: transformEntity,
|
|
@@ -102163,7 +102169,7 @@ function partitionApiModules(schema2, transformer, options8) {
|
|
|
102163
102169
|
payloads2.push(...childPayloads);
|
|
102164
102170
|
return payloads2;
|
|
102165
102171
|
}, []);
|
|
102166
|
-
apiModules2.push({ name, payloads });
|
|
102172
|
+
apiModules2.push({ name: transformer.moduleName(name), payloads });
|
|
102167
102173
|
return apiModules2;
|
|
102168
102174
|
}, []);
|
|
102169
102175
|
return apiModules;
|
|
@@ -102235,6 +102241,9 @@ async function generate(userOptions = {}) {
|
|
|
102235
102241
|
await renderApiModules(apiModules, { output, typesFilename, ts: ts9, override, preset });
|
|
102236
102242
|
import_rslog.logger.success("Done");
|
|
102237
102243
|
}
|
|
102244
|
+
|
|
102245
|
+
// src/index.ts
|
|
102246
|
+
var import_pluralize2 = __toESM(require("pluralize"), 1);
|
|
102238
102247
|
// Annotate the CommonJS export names for ESM import in node:
|
|
102239
102248
|
0 && (module.exports = {
|
|
102240
102249
|
createStatusCodesByStrategy,
|
|
@@ -102247,11 +102256,13 @@ async function generate(userOptions = {}) {
|
|
|
102247
102256
|
hasQueryParameter,
|
|
102248
102257
|
hasResponseBody,
|
|
102249
102258
|
partitionApiModules,
|
|
102259
|
+
pluralize,
|
|
102250
102260
|
readSchema,
|
|
102251
102261
|
readTemplateFile,
|
|
102252
102262
|
renderApiModules,
|
|
102253
102263
|
transformEntity,
|
|
102254
102264
|
transformFn,
|
|
102265
|
+
transformModuleName,
|
|
102255
102266
|
transformType,
|
|
102256
102267
|
transformTypeQuery,
|
|
102257
102268
|
transformTypeQueryValue,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { OpenAPI3, OperationObject } from 'openapi-typescript';
|
|
2
|
+
export { default as pluralize } from 'pluralize';
|
|
2
3
|
|
|
4
|
+
declare function transformModuleName(name: string): string;
|
|
3
5
|
declare function transformVerb(method: string): string;
|
|
4
6
|
declare function transformUrl(path: string, base?: string): string;
|
|
5
7
|
declare function transformEntity(path: string, method: string, base?: string): string;
|
|
@@ -13,6 +15,7 @@ declare function transformTypeRequestBodyValue(type: string): string;
|
|
|
13
15
|
declare function transformTypeResponseBody(verb: string, entity: string): string;
|
|
14
16
|
declare function transformTypeResponseBodyValue(type: string, statusCode: number, mime: string): string;
|
|
15
17
|
interface Transformer {
|
|
18
|
+
moduleName: typeof transformModuleName;
|
|
16
19
|
verb: typeof transformVerb;
|
|
17
20
|
url: typeof transformUrl;
|
|
18
21
|
entity: typeof transformEntity;
|
|
@@ -76,7 +79,7 @@ interface ApiModulePayload {
|
|
|
76
79
|
typeRequestBody: string;
|
|
77
80
|
typeRequestBodyValue: string;
|
|
78
81
|
typeResponseBody: string;
|
|
79
|
-
typeResponseBodyValue
|
|
82
|
+
typeResponseBodyValue: string;
|
|
80
83
|
}
|
|
81
84
|
interface ApiModule {
|
|
82
85
|
name: string;
|
|
@@ -126,4 +129,4 @@ type Config = GenerateOptions;
|
|
|
126
129
|
declare function defineConfig(config: Config): GenerateOptions;
|
|
127
130
|
declare function getConfig(): Promise<Config>;
|
|
128
131
|
|
|
129
|
-
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, hasQueryParameter, hasResponseBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
|
|
132
|
+
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, hasQueryParameter, hasResponseBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformModuleName, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { OpenAPI3, OperationObject } from 'openapi-typescript';
|
|
2
|
+
export { default as pluralize } from 'pluralize';
|
|
2
3
|
|
|
4
|
+
declare function transformModuleName(name: string): string;
|
|
3
5
|
declare function transformVerb(method: string): string;
|
|
4
6
|
declare function transformUrl(path: string, base?: string): string;
|
|
5
7
|
declare function transformEntity(path: string, method: string, base?: string): string;
|
|
@@ -13,6 +15,7 @@ declare function transformTypeRequestBodyValue(type: string): string;
|
|
|
13
15
|
declare function transformTypeResponseBody(verb: string, entity: string): string;
|
|
14
16
|
declare function transformTypeResponseBodyValue(type: string, statusCode: number, mime: string): string;
|
|
15
17
|
interface Transformer {
|
|
18
|
+
moduleName: typeof transformModuleName;
|
|
16
19
|
verb: typeof transformVerb;
|
|
17
20
|
url: typeof transformUrl;
|
|
18
21
|
entity: typeof transformEntity;
|
|
@@ -76,7 +79,7 @@ interface ApiModulePayload {
|
|
|
76
79
|
typeRequestBody: string;
|
|
77
80
|
typeRequestBodyValue: string;
|
|
78
81
|
typeResponseBody: string;
|
|
79
|
-
typeResponseBodyValue
|
|
82
|
+
typeResponseBodyValue: string;
|
|
80
83
|
}
|
|
81
84
|
interface ApiModule {
|
|
82
85
|
name: string;
|
|
@@ -126,4 +129,4 @@ type Config = GenerateOptions;
|
|
|
126
129
|
declare function defineConfig(config: Config): GenerateOptions;
|
|
127
130
|
declare function getConfig(): Promise<Config>;
|
|
128
131
|
|
|
129
|
-
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, hasQueryParameter, hasResponseBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
|
|
132
|
+
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, hasQueryParameter, hasResponseBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformModuleName, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
renderApiModules,
|
|
9
9
|
transformEntity,
|
|
10
10
|
transformFn,
|
|
11
|
+
transformModuleName,
|
|
11
12
|
transformType,
|
|
12
13
|
transformTypeQuery,
|
|
13
14
|
transformTypeQueryValue,
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
transformTypeValue,
|
|
19
20
|
transformUrl,
|
|
20
21
|
transformVerb
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-JWKB7AQQ.js";
|
|
22
23
|
import {
|
|
23
24
|
createStatusCodesByStrategy,
|
|
24
25
|
getCliVersion,
|
|
@@ -28,6 +29,9 @@ import {
|
|
|
28
29
|
readTemplateFile
|
|
29
30
|
} from "./chunk-6N4OHGAC.js";
|
|
30
31
|
import "./chunk-6OIOYGN7.js";
|
|
32
|
+
|
|
33
|
+
// src/index.ts
|
|
34
|
+
import { default as default2 } from "pluralize";
|
|
31
35
|
export {
|
|
32
36
|
createStatusCodesByStrategy,
|
|
33
37
|
createTransformer,
|
|
@@ -39,11 +43,13 @@ export {
|
|
|
39
43
|
hasQueryParameter,
|
|
40
44
|
hasResponseBody,
|
|
41
45
|
partitionApiModules,
|
|
46
|
+
default2 as pluralize,
|
|
42
47
|
readSchema,
|
|
43
48
|
readTemplateFile,
|
|
44
49
|
renderApiModules,
|
|
45
50
|
transformEntity,
|
|
46
51
|
transformFn,
|
|
52
|
+
transformModuleName,
|
|
47
53
|
transformType,
|
|
48
54
|
transformTypeQuery,
|
|
49
55
|
transformTypeQueryValue,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api-farmer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A cli to generate apis from a schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@types/pluralize": "^0.0.33",
|
|
50
51
|
"@varlet/axle": "^0.10.1",
|
|
51
52
|
"commander": "^13.0.0",
|
|
52
53
|
"ejs": "^3.1.10",
|
|
@@ -65,7 +66,6 @@
|
|
|
65
66
|
"@types/ejs": "^3.1.5",
|
|
66
67
|
"@types/fs-extra": "^11.0.4",
|
|
67
68
|
"@types/node": "^22.8.1",
|
|
68
|
-
"@types/pluralize": "^0.0.33",
|
|
69
69
|
"@types/swagger2openapi": "^7.0.4",
|
|
70
70
|
"@varlet/release": "^0.3.1",
|
|
71
71
|
"eslint": "^9.17.0",
|