api-farmer 0.0.0 → 0.0.1
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/acorn-O63CA7L4.js +3047 -0
- package/dist/angular-U44OZXUW.js +2794 -0
- package/dist/babel-VWJW3TNP.js +6946 -0
- package/dist/chunk-6N4OHGAC.js +72 -0
- package/dist/chunk-6OIOYGN7.js +17 -0
- package/dist/chunk-HMKED3BC.js +22949 -0
- package/dist/cli.cjs +102232 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +15 -0
- package/dist/estree-OIZOUIW7.js +4374 -0
- package/dist/flow-TDKVTHFE.js +26897 -0
- package/dist/generate-3DZVV2U4.js +14 -0
- package/dist/glimmer-AWQE7API.js +2847 -0
- package/dist/graphql-IJWEVF4G.js +1247 -0
- package/dist/html-7SW5PDZO.js +2716 -0
- package/dist/index.cjs +102265 -0
- package/dist/index.d.cts +129 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.js +57 -0
- package/dist/markdown-2BNVGUT3.js +3484 -0
- package/dist/meriyah-L52O7E6A.js +2474 -0
- package/dist/postcss-AOWY4ITF.js +5057 -0
- package/dist/typescript-ANND5E4Y.js +13104 -0
- package/dist/yaml-MB3PL3NY.js +4223 -0
- package/package.json +90 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__dirname
|
|
3
|
+
} from "./chunk-6OIOYGN7.js";
|
|
4
|
+
|
|
5
|
+
// src/constants.ts
|
|
6
|
+
import { resolve } from "path";
|
|
7
|
+
var CWD = process.cwd();
|
|
8
|
+
var CUSTOM_TEMPLATE_FILE = resolve(CWD, `./api-farmer.ejs`);
|
|
9
|
+
var CLI_PACKAGE_JSON = resolve(__dirname, "../package.json");
|
|
10
|
+
|
|
11
|
+
// src/utils.ts
|
|
12
|
+
import { resolve as resolve2 } from "path";
|
|
13
|
+
import fse from "fs-extra";
|
|
14
|
+
import swagger from "swagger2openapi";
|
|
15
|
+
import yaml from "yaml";
|
|
16
|
+
function createStatusCodesByStrategy(strategy) {
|
|
17
|
+
return {
|
|
18
|
+
strict: {
|
|
19
|
+
get: 200,
|
|
20
|
+
post: 201,
|
|
21
|
+
put: 200,
|
|
22
|
+
delete: 204,
|
|
23
|
+
patch: 200,
|
|
24
|
+
options: 204,
|
|
25
|
+
head: 200
|
|
26
|
+
},
|
|
27
|
+
loose: {
|
|
28
|
+
get: 200,
|
|
29
|
+
post: 200,
|
|
30
|
+
put: 200,
|
|
31
|
+
delete: 200,
|
|
32
|
+
patch: 200,
|
|
33
|
+
options: 200,
|
|
34
|
+
head: 200
|
|
35
|
+
}
|
|
36
|
+
}[strategy];
|
|
37
|
+
}
|
|
38
|
+
async function readSchema(input) {
|
|
39
|
+
const isYaml = input.endsWith(".yaml");
|
|
40
|
+
const path = resolve2(CWD, input);
|
|
41
|
+
const content = fse.readFileSync(path, "utf-8");
|
|
42
|
+
const swaggerOrOpenapiSchema = isYaml ? yaml.parse(content) : JSON.parse(content);
|
|
43
|
+
const schema = swaggerOrOpenapiSchema.swagger ? (await swagger.convert(swaggerOrOpenapiSchema, {})).openapi : swaggerOrOpenapiSchema;
|
|
44
|
+
return schema;
|
|
45
|
+
}
|
|
46
|
+
function readTemplateFile(preset = "axle") {
|
|
47
|
+
if (fse.existsSync(CUSTOM_TEMPLATE_FILE)) {
|
|
48
|
+
return fse.readFileSync(CUSTOM_TEMPLATE_FILE, "utf-8");
|
|
49
|
+
}
|
|
50
|
+
return fse.readFileSync(resolve2(__dirname, `../templates/${preset}.ejs`), "utf-8");
|
|
51
|
+
}
|
|
52
|
+
function hasQueryParameter(operation) {
|
|
53
|
+
return (operation.parameters ?? []).some((param) => "in" in param && param.in === "query");
|
|
54
|
+
}
|
|
55
|
+
function hasResponseBody(operation) {
|
|
56
|
+
return Object.values(operation.responses ?? {}).some(
|
|
57
|
+
(responseObject) => "content" in responseObject && responseObject.content
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function getCliVersion() {
|
|
61
|
+
return fse.readJsonSync(CLI_PACKAGE_JSON).version;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
CWD,
|
|
66
|
+
createStatusCodesByStrategy,
|
|
67
|
+
readSchema,
|
|
68
|
+
readTemplateFile,
|
|
69
|
+
hasQueryParameter,
|
|
70
|
+
hasResponseBody,
|
|
71
|
+
getCliVersion
|
|
72
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.5.1_tsx@4.19.2_typescript@5.3.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import path from "path";
|
|
10
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
11
|
+
var getDirname = () => path.dirname(getFilename());
|
|
12
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
__export,
|
|
16
|
+
__dirname
|
|
17
|
+
};
|