Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

api-gensdk

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-gensdk - npm Package Compare versions

Comparing version 0.1.12 to 0.1.13

lib/type.d.ts

40

lib/gen.d.ts

@@ -1,40 +0,2 @@

export interface RouteMetadataType {
/** 类名 */
className: string;
/** 方法名 */
functionName: string;
/** 路由名称 */
name: string;
/** 路由描述 */
description: string;
/** http method */
method: string;
/** http url */
url: string;
/** 参数定义 */
params: ParamType[];
}
export interface ParamType {
/** 函数参数名 */
name: string;
/** 请求参数名 */
paramName: string;
/** 类型 */
type: string;
in: 'path' | 'query' | 'body';
}
export interface TemplateRouteType extends RouteMetadataType {
/** path中参数定义 */
paramsInPath: ParamType[];
}
export declare class GenConfig {
/** 生成目录 */
sdkDir: string;
/** 模版目录 */
templatePath: string;
/** filename style */
camelCase?: boolean;
/** gen type */
type?: 'ts' | 'js';
}
import { RouteMetadataType, GenConfig } from './type';
/**

@@ -41,0 +3,0 @@ * 生成APISDK

@@ -7,11 +7,3 @@ "use strict";

const util_1 = require("./util");
class GenConfig {
constructor() {
/** filename style */
this.camelCase = false;
/** gen type */
this.type = 'ts';
}
}
exports.GenConfig = GenConfig;
const type_1 = require("./type");
function genDefaultTemplate(config) {

@@ -45,3 +37,3 @@ const templatePath = config.templatePath || path.join(config.sdkDir, 'sdk.njk');

function genAPISDK(data, config) {
config = Object.assign({}, new GenConfig, config || {});
config = Object.assign({}, new type_1.GenConfig, config || {});
const { sdkDir } = config;

@@ -52,2 +44,3 @@ util_1.mkdir(sdkDir);

const metadata = {};
// 数据分类
data.forEach(route => {

@@ -77,2 +70,3 @@ const ClassName = route.className;

});
util_1.functionNameRD(metadata);
const fileTemplate = fs.readFileSync(templatePath, 'utf8');

@@ -79,0 +73,0 @@ Object.keys(metadata).forEach(className => {

export * from './gen';
export { RouteMetadataType, ParamType, GenConfig } from './type';

@@ -5,1 +5,3 @@ "use strict";

tslib_1.__exportStar(require("./gen"), exports);
var type_1 = require("./type");
exports.GenConfig = type_1.GenConfig;

@@ -0,3 +1,6 @@

import { TemplateVarType } from './type';
export declare function toHyphenCase(s: string): string;
export declare function toCamelCase(s: string): string;
export declare function mkdir(dir: string): void;
/** 函数名防重 */
export declare function functionNameRD(metadata: TemplateVarType): void;

@@ -26,1 +26,16 @@ "use strict";

exports.mkdir = mkdir;
/** 函数名防重 */
function functionNameRD(metadata) {
Object.keys(metadata).forEach(className => {
const clsMetadata = metadata[className];
const functionName = {};
clsMetadata.forEach(route => {
const count = functionName[route.functionName];
if (count) {
route.functionName += `_${count}`;
}
functionName[route.functionName] = count ? count + 1 : 1;
});
});
}
exports.functionNameRD = functionNameRD;
{
"name": "api-gensdk",
"version": "0.1.12",
"version": "0.1.13",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc