api-farmer 0.0.6 → 0.0.8

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 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-TOPFUKIL.js";
9
+ } from "./chunk-OBPECFFY.js";
11
10
  import {
12
11
  __export
13
12
  } from "./chunk-6OIOYGN7.js";
@@ -22741,6 +22740,9 @@ import { camelize, pascalCase } from "rattail";
22741
22740
  function transformModuleName({ name }) {
22742
22741
  return camelize(name);
22743
22742
  }
22743
+ function transformUrl({ path: path13, base }) {
22744
+ return (base ? path13.replace(base, "") : path13).replace(/{/g, ":").replace(/}/g, "");
22745
+ }
22744
22746
  function transformVerb({ method }) {
22745
22747
  switch (method) {
22746
22748
  case "post":
@@ -22751,9 +22753,6 @@ function transformVerb({ method }) {
22751
22753
  return pascalCase(method);
22752
22754
  }
22753
22755
  }
22754
- function transformUrl({ path: path13, base }) {
22755
- return (base ? path13.replace(base, "") : path13).replace(/{/g, ":").replace(/}/g, "");
22756
- }
22757
22756
  function transformEntity({ path: path13, method, base }) {
22758
22757
  path13 = base ? path13.replace(base, "") : path13;
22759
22758
  const words = path13.split("/").filter(Boolean);
@@ -22777,19 +22776,33 @@ function transformType({ verb, entity }) {
22777
22776
  function transformTypeValue({ path: path13, method }) {
22778
22777
  return `paths['${path13}']['${method}']`;
22779
22778
  }
22780
- function transformTypeQuery({ verb, entity }) {
22779
+ function transformTypeQuery({
22780
+ verb,
22781
+ entity
22782
+ }) {
22781
22783
  return `Api${verb}${entity}Query`;
22782
22784
  }
22783
- function transformTypeQueryValue({ type: type2 }) {
22785
+ function transformTypeQueryValue({
22786
+ type: type2
22787
+ }) {
22784
22788
  return `${type2}['parameters']['query']`;
22785
22789
  }
22786
- function transformTypeRequestBody({ verb, entity }) {
22790
+ function transformTypeRequestBody({
22791
+ verb,
22792
+ entity
22793
+ }) {
22787
22794
  return `Api${verb}${entity}RequestBody`;
22788
22795
  }
22789
- function transformTypeRequestBodyValue({ type: type2, required }) {
22796
+ function transformTypeRequestBodyValue({
22797
+ type: type2,
22798
+ required
22799
+ }) {
22790
22800
  return required ? `${type2}['requestBody']['content']['application/json']` : `NonNullable<${type2}['requestBody']>['content']['application/json'] | undefined`;
22791
22801
  }
22792
- function transformTypeResponseBody({ verb, entity }) {
22802
+ function transformTypeResponseBody({
22803
+ verb,
22804
+ entity
22805
+ }) {
22793
22806
  return `Api${verb}${entity}ResponseBody`;
22794
22807
  }
22795
22808
  function transformTypeResponseBodyValue({
@@ -22829,22 +22842,26 @@ function partitionApiModules(schema2, transformer, options8) {
22829
22842
  const pathItems = schemaPaths[path13];
22830
22843
  const childPayloads = Object.entries(pathItems).reduce((payloads3, [method, operation]) => {
22831
22844
  const url2 = transformer.url({ path: path13, base });
22832
- const entity = transformer.entity({ path: path13, method, base });
22833
- const verb = transformer.verb({ method });
22834
- const fn = transformer.fn({ verb, entity });
22835
- const type2 = transformer.type({ verb, entity });
22836
- const typeValue = transformer.typeValue({ path: path13, method });
22837
- const typeQuery = transformer.typeQuery({ verb, entity });
22838
- const typeQueryValue = hasQueryParameter(operation) ? transformer.typeQueryValue({ type: type2 }) : "never";
22839
- const typeRequestBody = transformer.typeRequestBody({ verb, entity });
22845
+ const args = { path: path13, base, url: url2, method, operation };
22846
+ const entity = transformer.entity(args);
22847
+ const verb = transformer.verb(args);
22848
+ const fn = transformer.fn({ ...args, verb, entity });
22849
+ const type2 = transformer.type({ ...args, verb, entity });
22850
+ const typeValue = transformer.typeValue({ ...args, verb, entity });
22851
+ const typeQuery = transformer.typeQuery({ ...args, type: type2, verb, entity });
22852
+ const typeQueryValue = hasQueryParameter(operation) ? transformer.typeQueryValue({ ...args, type: type2, verb, entity }) : "never";
22853
+ const typeRequestBody = transformer.typeRequestBody({ ...args, type: type2, verb, entity });
22840
22854
  const typeRequestBodyValue = operation.requestBody ? transformer.typeRequestBodyValue({
22855
+ ...args,
22841
22856
  type: type2,
22857
+ verb,
22858
+ entity,
22842
22859
  required: isRequiredRequestBody(operation.requestBody)
22843
22860
  }) : "never";
22844
22861
  const statusCode = statusCodes[method] ?? 200;
22845
22862
  const mime = getResponseMime(operation, statusCode);
22846
- const typeResponseBody = transformer.typeResponseBody({ verb, entity });
22847
- const typeResponseBodyValue = hasResponseBody(operation) && mime ? transformer.typeResponseBodyValue({ type: type2, statusCode, mime }) : "never";
22863
+ const typeResponseBody = transformer.typeResponseBody({ ...args, type: type2, verb, entity });
22864
+ const typeResponseBodyValue = mime ? transformer.typeResponseBodyValue({ ...args, type: type2, verb, entity, statusCode, mime }) : "never";
22848
22865
  payloads3.push({
22849
22866
  fn,
22850
22867
  url: url2,
@@ -22943,8 +22960,8 @@ export {
22943
22960
  defineConfig,
22944
22961
  getConfig,
22945
22962
  transformModuleName,
22946
- transformVerb,
22947
22963
  transformUrl,
22964
+ transformVerb,
22948
22965
  transformEntity,
22949
22966
  transformFn,
22950
22967
  transformType,
@@ -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
  }
@@ -102005,6 +102000,9 @@ var init_config = __esm({
102005
102000
  function transformModuleName({ name }) {
102006
102001
  return (0, import_rattail.camelize)(name);
102007
102002
  }
102003
+ function transformUrl({ path: path13, base }) {
102004
+ return (base ? path13.replace(base, "") : path13).replace(/{/g, ":").replace(/}/g, "");
102005
+ }
102008
102006
  function transformVerb({ method }) {
102009
102007
  switch (method) {
102010
102008
  case "post":
@@ -102015,9 +102013,6 @@ function transformVerb({ method }) {
102015
102013
  return (0, import_rattail.pascalCase)(method);
102016
102014
  }
102017
102015
  }
102018
- function transformUrl({ path: path13, base }) {
102019
- return (base ? path13.replace(base, "") : path13).replace(/{/g, ":").replace(/}/g, "");
102020
- }
102021
102016
  function transformEntity({ path: path13, method, base }) {
102022
102017
  path13 = base ? path13.replace(base, "") : path13;
102023
102018
  const words = path13.split("/").filter(Boolean);
@@ -102041,19 +102036,33 @@ function transformType({ verb, entity }) {
102041
102036
  function transformTypeValue({ path: path13, method }) {
102042
102037
  return `paths['${path13}']['${method}']`;
102043
102038
  }
102044
- function transformTypeQuery({ verb, entity }) {
102039
+ function transformTypeQuery({
102040
+ verb,
102041
+ entity
102042
+ }) {
102045
102043
  return `Api${verb}${entity}Query`;
102046
102044
  }
102047
- function transformTypeQueryValue({ type: type2 }) {
102045
+ function transformTypeQueryValue({
102046
+ type: type2
102047
+ }) {
102048
102048
  return `${type2}['parameters']['query']`;
102049
102049
  }
102050
- function transformTypeRequestBody({ verb, entity }) {
102050
+ function transformTypeRequestBody({
102051
+ verb,
102052
+ entity
102053
+ }) {
102051
102054
  return `Api${verb}${entity}RequestBody`;
102052
102055
  }
102053
- function transformTypeRequestBodyValue({ type: type2, required }) {
102056
+ function transformTypeRequestBodyValue({
102057
+ type: type2,
102058
+ required
102059
+ }) {
102054
102060
  return required ? `${type2}['requestBody']['content']['application/json']` : `NonNullable<${type2}['requestBody']>['content']['application/json'] | undefined`;
102055
102061
  }
102056
- function transformTypeResponseBody({ verb, entity }) {
102062
+ function transformTypeResponseBody({
102063
+ verb,
102064
+ entity
102065
+ }) {
102057
102066
  return `Api${verb}${entity}ResponseBody`;
102058
102067
  }
102059
102068
  function transformTypeResponseBodyValue({
@@ -102109,22 +102118,26 @@ function partitionApiModules(schema2, transformer, options8) {
102109
102118
  const pathItems = schemaPaths[path13];
102110
102119
  const childPayloads = Object.entries(pathItems).reduce((payloads3, [method, operation]) => {
102111
102120
  const url2 = transformer.url({ path: path13, base });
102112
- const entity = transformer.entity({ path: path13, method, base });
102113
- const verb = transformer.verb({ method });
102114
- const fn8 = transformer.fn({ verb, entity });
102115
- const type2 = transformer.type({ verb, entity });
102116
- const typeValue = transformer.typeValue({ path: path13, method });
102117
- const typeQuery = transformer.typeQuery({ verb, entity });
102118
- const typeQueryValue = hasQueryParameter(operation) ? transformer.typeQueryValue({ type: type2 }) : "never";
102119
- const typeRequestBody = transformer.typeRequestBody({ verb, entity });
102121
+ const args = { path: path13, base, url: url2, method, operation };
102122
+ const entity = transformer.entity(args);
102123
+ const verb = transformer.verb(args);
102124
+ const fn8 = transformer.fn({ ...args, verb, entity });
102125
+ const type2 = transformer.type({ ...args, verb, entity });
102126
+ const typeValue = transformer.typeValue({ ...args, verb, entity });
102127
+ const typeQuery = transformer.typeQuery({ ...args, type: type2, verb, entity });
102128
+ const typeQueryValue = hasQueryParameter(operation) ? transformer.typeQueryValue({ ...args, type: type2, verb, entity }) : "never";
102129
+ const typeRequestBody = transformer.typeRequestBody({ ...args, type: type2, verb, entity });
102120
102130
  const typeRequestBodyValue = operation.requestBody ? transformer.typeRequestBodyValue({
102131
+ ...args,
102121
102132
  type: type2,
102133
+ verb,
102134
+ entity,
102122
102135
  required: isRequiredRequestBody(operation.requestBody)
102123
102136
  }) : "never";
102124
102137
  const statusCode = statusCodes[method] ?? 200;
102125
102138
  const mime = getResponseMime(operation, statusCode);
102126
- const typeResponseBody = transformer.typeResponseBody({ verb, entity });
102127
- const typeResponseBodyValue = hasResponseBody(operation) && mime ? transformer.typeResponseBodyValue({ type: type2, statusCode, mime }) : "never";
102139
+ const typeResponseBody = transformer.typeResponseBody({ ...args, type: type2, verb, entity });
102140
+ const typeResponseBodyValue = mime ? transformer.typeResponseBodyValue({ ...args, type: type2, verb, entity, statusCode, mime }) : "never";
102128
102141
  payloads3.push({
102129
102142
  fn: fn8,
102130
102143
  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-TOPFUKIL.js";
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-45FVXFDO.js");
12
+ const { generate } = await import("./generate-C3K2GRQJ.js");
13
13
  return generate();
14
14
  });
15
15
  program.parse();
@@ -3,8 +3,8 @@ import {
3
3
  generateTypes,
4
4
  partitionApiModules,
5
5
  renderApiModules
6
- } from "./chunk-BGSEKRRW.js";
7
- import "./chunk-TOPFUKIL.js";
6
+ } from "./chunk-L33J46FJ.js";
7
+ import "./chunk-OBPECFFY.js";
8
8
  import "./chunk-6OIOYGN7.js";
9
9
  export {
10
10
  generate,
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,
@@ -79265,6 +79264,9 @@ var import_rattail = require("rattail");
79265
79264
  function transformModuleName({ name }) {
79266
79265
  return (0, import_rattail.camelize)(name);
79267
79266
  }
79267
+ function transformUrl({ path: path13, base }) {
79268
+ return (base ? path13.replace(base, "") : path13).replace(/{/g, ":").replace(/}/g, "");
79269
+ }
79268
79270
  function transformVerb({ method }) {
79269
79271
  switch (method) {
79270
79272
  case "post":
@@ -79275,9 +79277,6 @@ function transformVerb({ method }) {
79275
79277
  return (0, import_rattail.pascalCase)(method);
79276
79278
  }
79277
79279
  }
79278
- function transformUrl({ path: path13, base }) {
79279
- return (base ? path13.replace(base, "") : path13).replace(/{/g, ":").replace(/}/g, "");
79280
- }
79281
79280
  function transformEntity({ path: path13, method, base }) {
79282
79281
  path13 = base ? path13.replace(base, "") : path13;
79283
79282
  const words = path13.split("/").filter(Boolean);
@@ -79301,19 +79300,33 @@ function transformType({ verb, entity }) {
79301
79300
  function transformTypeValue({ path: path13, method }) {
79302
79301
  return `paths['${path13}']['${method}']`;
79303
79302
  }
79304
- function transformTypeQuery({ verb, entity }) {
79303
+ function transformTypeQuery({
79304
+ verb,
79305
+ entity
79306
+ }) {
79305
79307
  return `Api${verb}${entity}Query`;
79306
79308
  }
79307
- function transformTypeQueryValue({ type: type2 }) {
79309
+ function transformTypeQueryValue({
79310
+ type: type2
79311
+ }) {
79308
79312
  return `${type2}['parameters']['query']`;
79309
79313
  }
79310
- function transformTypeRequestBody({ verb, entity }) {
79314
+ function transformTypeRequestBody({
79315
+ verb,
79316
+ entity
79317
+ }) {
79311
79318
  return `Api${verb}${entity}RequestBody`;
79312
79319
  }
79313
- function transformTypeRequestBodyValue({ type: type2, required }) {
79320
+ function transformTypeRequestBodyValue({
79321
+ type: type2,
79322
+ required
79323
+ }) {
79314
79324
  return required ? `${type2}['requestBody']['content']['application/json']` : `NonNullable<${type2}['requestBody']>['content']['application/json'] | undefined`;
79315
79325
  }
79316
- function transformTypeResponseBody({ verb, entity }) {
79326
+ function transformTypeResponseBody({
79327
+ verb,
79328
+ entity
79329
+ }) {
79317
79330
  return `Api${verb}${entity}ResponseBody`;
79318
79331
  }
79319
79332
  function transformTypeResponseBodyValue({
@@ -102120,11 +102133,6 @@ function readTemplateFile(preset = "axle") {
102120
102133
  function hasQueryParameter(operation) {
102121
102134
  return (operation.parameters ?? []).some((param) => "in" in param && param.in === "query");
102122
102135
  }
102123
- function hasResponseBody(operation) {
102124
- return Object.values(operation.responses ?? {}).some(
102125
- (responseObject) => "content" in responseObject && responseObject.content
102126
- );
102127
- }
102128
102136
  function getCliVersion() {
102129
102137
  return import_fs_extra.default.readJsonSync(CLI_PACKAGE_JSON).version;
102130
102138
  }
@@ -102148,22 +102156,26 @@ function partitionApiModules(schema2, transformer, options8) {
102148
102156
  const pathItems = schemaPaths[path13];
102149
102157
  const childPayloads = Object.entries(pathItems).reduce((payloads3, [method, operation]) => {
102150
102158
  const url2 = transformer.url({ path: path13, base });
102151
- const entity = transformer.entity({ path: path13, method, base });
102152
- const verb = transformer.verb({ method });
102153
- const fn8 = transformer.fn({ verb, entity });
102154
- const type2 = transformer.type({ verb, entity });
102155
- const typeValue = transformer.typeValue({ path: path13, method });
102156
- const typeQuery = transformer.typeQuery({ verb, entity });
102157
- const typeQueryValue = hasQueryParameter(operation) ? transformer.typeQueryValue({ type: type2 }) : "never";
102158
- const typeRequestBody = transformer.typeRequestBody({ verb, entity });
102159
+ const args = { path: path13, base, url: url2, method, operation };
102160
+ const entity = transformer.entity(args);
102161
+ const verb = transformer.verb(args);
102162
+ const fn8 = transformer.fn({ ...args, verb, entity });
102163
+ const type2 = transformer.type({ ...args, verb, entity });
102164
+ const typeValue = transformer.typeValue({ ...args, verb, entity });
102165
+ const typeQuery = transformer.typeQuery({ ...args, type: type2, verb, entity });
102166
+ const typeQueryValue = hasQueryParameter(operation) ? transformer.typeQueryValue({ ...args, type: type2, verb, entity }) : "never";
102167
+ const typeRequestBody = transformer.typeRequestBody({ ...args, type: type2, verb, entity });
102159
102168
  const typeRequestBodyValue = operation.requestBody ? transformer.typeRequestBodyValue({
102169
+ ...args,
102160
102170
  type: type2,
102171
+ verb,
102172
+ entity,
102161
102173
  required: isRequiredRequestBody(operation.requestBody)
102162
102174
  }) : "never";
102163
102175
  const statusCode = statusCodes[method] ?? 200;
102164
102176
  const mime = getResponseMime(operation, statusCode);
102165
- const typeResponseBody = transformer.typeResponseBody({ verb, entity });
102166
- const typeResponseBodyValue = hasResponseBody(operation) && mime ? transformer.typeResponseBodyValue({ type: type2, statusCode, mime }) : "never";
102177
+ const typeResponseBody = transformer.typeResponseBody({ ...args, type: type2, verb, entity });
102178
+ const typeResponseBodyValue = mime ? transformer.typeResponseBodyValue({ ...args, type: type2, verb, entity, statusCode, mime }) : "never";
102167
102179
  payloads3.push({
102168
102180
  fn: fn8,
102169
102181
  url: url2,
@@ -102271,7 +102283,6 @@ var import_pluralize2 = __toESM(require("pluralize"), 1);
102271
102283
  getConfig,
102272
102284
  getResponseMime,
102273
102285
  hasQueryParameter,
102274
- hasResponseBody,
102275
102286
  isRequiredRequestBody,
102276
102287
  partitionApiModules,
102277
102288
  pluralize,
package/dist/index.d.cts CHANGED
@@ -1,57 +1,69 @@
1
- import { OpenAPI3, OperationObject, RequestBodyObject, ReferenceObject } from 'openapi-typescript';
1
+ import { OperationObject, OpenAPI3, RequestBodyObject, ReferenceObject } from 'openapi-typescript';
2
2
  export { default as pluralize } from 'pluralize';
3
3
 
4
+ type TransformerBaseArgs = {
5
+ path: string;
6
+ base: string | undefined;
7
+ url: string;
8
+ method: string;
9
+ operation: OperationObject;
10
+ };
4
11
  declare function transformModuleName({ name }: {
5
12
  name: string;
6
13
  }): string;
7
- declare function transformVerb({ method }: {
8
- method: string;
9
- }): string;
10
14
  declare function transformUrl({ path, base }: {
11
15
  path: string;
12
- base?: string;
16
+ base: string | undefined;
13
17
  }): string;
14
- declare function transformEntity({ path, method, base }: {
15
- path: string;
18
+ declare function transformVerb({ method }: {
16
19
  method: string;
17
- base?: string;
18
20
  }): string;
21
+ declare function transformEntity({ path, method, base }: TransformerBaseArgs): string;
19
22
  declare function transformFn({ verb, entity }: {
20
23
  verb: string;
21
24
  entity: string;
22
- }): string;
25
+ } & TransformerBaseArgs): string;
23
26
  declare function transformType({ verb, entity }: {
24
27
  verb: string;
25
28
  entity: string;
26
- }): string;
29
+ } & TransformerBaseArgs): string;
27
30
  declare function transformTypeValue({ path, method }: {
28
- path: string;
29
- method: string;
30
- }): string;
31
- declare function transformTypeQuery({ verb, entity }: {
32
31
  verb: string;
33
32
  entity: string;
34
- }): string;
35
- declare function transformTypeQueryValue({ type }: {
33
+ } & TransformerBaseArgs): string;
34
+ declare function transformTypeQuery({ verb, entity, }: {
36
35
  type: string;
37
- }): string;
38
- declare function transformTypeRequestBody({ verb, entity }: {
39
36
  verb: string;
40
37
  entity: string;
41
- }): string;
42
- declare function transformTypeRequestBodyValue({ type, required }: {
38
+ } & TransformerBaseArgs): string;
39
+ declare function transformTypeQueryValue({ type, }: {
40
+ type: string;
41
+ verb: string;
42
+ entity: string;
43
+ } & TransformerBaseArgs): string;
44
+ declare function transformTypeRequestBody({ verb, entity, }: {
45
+ type: string;
46
+ verb: string;
47
+ entity: string;
48
+ } & TransformerBaseArgs): string;
49
+ declare function transformTypeRequestBodyValue({ type, required, }: {
43
50
  type: string;
51
+ verb: string;
52
+ entity: string;
44
53
  required: boolean;
45
- }): string;
46
- declare function transformTypeResponseBody({ verb, entity }: {
54
+ } & TransformerBaseArgs): string;
55
+ declare function transformTypeResponseBody({ verb, entity, }: {
56
+ type: string;
47
57
  verb: string;
48
58
  entity: string;
49
- }): string;
59
+ } & TransformerBaseArgs): string;
50
60
  declare function transformTypeResponseBodyValue({ type, statusCode, mime, }: {
51
61
  type: string;
62
+ verb: string;
63
+ entity: string;
52
64
  statusCode: number;
53
65
  mime: string;
54
- }): string;
66
+ } & TransformerBaseArgs): string;
55
67
  interface Transformer {
56
68
  moduleName: typeof transformModuleName;
57
69
  verb: typeof transformVerb;
@@ -100,7 +112,6 @@ declare function createStatusCodesByStrategy(strategy: StatusCodeStrategy): {
100
112
  declare function readSchema(input: string): Promise<OpenAPI3>;
101
113
  declare function readTemplateFile(preset?: Preset): string;
102
114
  declare function hasQueryParameter(operation: OperationObject): boolean;
103
- declare function hasResponseBody(operation: OperationObject): boolean;
104
115
  declare function getCliVersion(): any;
105
116
  declare function isRequiredRequestBody(value: RequestBodyObject | ReferenceObject): boolean;
106
117
  declare function getResponseMime(operation: OperationObject, statusCode: number): "application/json" | "*/*" | undefined;
@@ -252,4 +263,4 @@ type Config = GenerateOptions;
252
263
  declare function defineConfig(config: Config): GenerateOptions;
253
264
  declare function getConfig(): Promise<Config>;
254
265
 
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, hasResponseBody, isRequiredRequestBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformModuleName, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
266
+ export { type ApiModule, type ApiModulePayload, type ApiModuleTemplateData, type Config, type GenerateOptions, type Preset, type StatusCodeStrategy, type StatusCodes, type Transformer, type TransformerBaseArgs, 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
@@ -1,57 +1,69 @@
1
- import { OpenAPI3, OperationObject, RequestBodyObject, ReferenceObject } from 'openapi-typescript';
1
+ import { OperationObject, OpenAPI3, RequestBodyObject, ReferenceObject } from 'openapi-typescript';
2
2
  export { default as pluralize } from 'pluralize';
3
3
 
4
+ type TransformerBaseArgs = {
5
+ path: string;
6
+ base: string | undefined;
7
+ url: string;
8
+ method: string;
9
+ operation: OperationObject;
10
+ };
4
11
  declare function transformModuleName({ name }: {
5
12
  name: string;
6
13
  }): string;
7
- declare function transformVerb({ method }: {
8
- method: string;
9
- }): string;
10
14
  declare function transformUrl({ path, base }: {
11
15
  path: string;
12
- base?: string;
16
+ base: string | undefined;
13
17
  }): string;
14
- declare function transformEntity({ path, method, base }: {
15
- path: string;
18
+ declare function transformVerb({ method }: {
16
19
  method: string;
17
- base?: string;
18
20
  }): string;
21
+ declare function transformEntity({ path, method, base }: TransformerBaseArgs): string;
19
22
  declare function transformFn({ verb, entity }: {
20
23
  verb: string;
21
24
  entity: string;
22
- }): string;
25
+ } & TransformerBaseArgs): string;
23
26
  declare function transformType({ verb, entity }: {
24
27
  verb: string;
25
28
  entity: string;
26
- }): string;
29
+ } & TransformerBaseArgs): string;
27
30
  declare function transformTypeValue({ path, method }: {
28
- path: string;
29
- method: string;
30
- }): string;
31
- declare function transformTypeQuery({ verb, entity }: {
32
31
  verb: string;
33
32
  entity: string;
34
- }): string;
35
- declare function transformTypeQueryValue({ type }: {
33
+ } & TransformerBaseArgs): string;
34
+ declare function transformTypeQuery({ verb, entity, }: {
36
35
  type: string;
37
- }): string;
38
- declare function transformTypeRequestBody({ verb, entity }: {
39
36
  verb: string;
40
37
  entity: string;
41
- }): string;
42
- declare function transformTypeRequestBodyValue({ type, required }: {
38
+ } & TransformerBaseArgs): string;
39
+ declare function transformTypeQueryValue({ type, }: {
40
+ type: string;
41
+ verb: string;
42
+ entity: string;
43
+ } & TransformerBaseArgs): string;
44
+ declare function transformTypeRequestBody({ verb, entity, }: {
45
+ type: string;
46
+ verb: string;
47
+ entity: string;
48
+ } & TransformerBaseArgs): string;
49
+ declare function transformTypeRequestBodyValue({ type, required, }: {
43
50
  type: string;
51
+ verb: string;
52
+ entity: string;
44
53
  required: boolean;
45
- }): string;
46
- declare function transformTypeResponseBody({ verb, entity }: {
54
+ } & TransformerBaseArgs): string;
55
+ declare function transformTypeResponseBody({ verb, entity, }: {
56
+ type: string;
47
57
  verb: string;
48
58
  entity: string;
49
- }): string;
59
+ } & TransformerBaseArgs): string;
50
60
  declare function transformTypeResponseBodyValue({ type, statusCode, mime, }: {
51
61
  type: string;
62
+ verb: string;
63
+ entity: string;
52
64
  statusCode: number;
53
65
  mime: string;
54
- }): string;
66
+ } & TransformerBaseArgs): string;
55
67
  interface Transformer {
56
68
  moduleName: typeof transformModuleName;
57
69
  verb: typeof transformVerb;
@@ -100,7 +112,6 @@ declare function createStatusCodesByStrategy(strategy: StatusCodeStrategy): {
100
112
  declare function readSchema(input: string): Promise<OpenAPI3>;
101
113
  declare function readTemplateFile(preset?: Preset): string;
102
114
  declare function hasQueryParameter(operation: OperationObject): boolean;
103
- declare function hasResponseBody(operation: OperationObject): boolean;
104
115
  declare function getCliVersion(): any;
105
116
  declare function isRequiredRequestBody(value: RequestBodyObject | ReferenceObject): boolean;
106
117
  declare function getResponseMime(operation: OperationObject, statusCode: number): "application/json" | "*/*" | undefined;
@@ -252,4 +263,4 @@ type Config = GenerateOptions;
252
263
  declare function defineConfig(config: Config): GenerateOptions;
253
264
  declare function getConfig(): Promise<Config>;
254
265
 
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, hasResponseBody, isRequiredRequestBody, partitionApiModules, readSchema, readTemplateFile, renderApiModules, transformEntity, transformFn, transformModuleName, transformType, transformTypeQuery, transformTypeQueryValue, transformTypeRequestBody, transformTypeRequestBodyValue, transformTypeResponseBody, transformTypeResponseBodyValue, transformTypeValue, transformUrl, transformVerb };
266
+ export { type ApiModule, type ApiModulePayload, type ApiModuleTemplateData, type Config, type GenerateOptions, type Preset, type StatusCodeStrategy, type StatusCodes, type Transformer, type TransformerBaseArgs, 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-BGSEKRRW.js";
22
+ } from "./chunk-L33J46FJ.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-TOPFUKIL.js";
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-farmer",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "API module generation tool based on Openapi3/Swagger2.",
5
5
  "keywords": [
6
6
  "cli",