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

aspida

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aspida - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

7

dist/buildTemplate.d.ts
import { BaseConfig } from './getConfig';
import { Template } from './build/template';
declare const _default: ({ input, baseURL }: BaseConfig) => Template;
export interface Template {
text: string;
filePath: string;
}
declare const _default: ({ input, baseURL, trailingSlash }: BaseConfig) => Template;
export default _default;
//# sourceMappingURL=buildTemplate.d.ts.map

@@ -28,21 +28,14 @@ "use strict";

var path_1 = __importDefault(require("path"));
var template_1 = __importDefault(require("./template"));
var createTemplateValues_1 = __importDefault(require("./createTemplateValues"));
exports.default = (function (_a) {
var input = _a.input, baseURL = _a.baseURL;
var _b = createTemplateValues_1.default(input), api = _b.api, imports = _b.imports;
var input = _a.input, baseURL = _a.baseURL, trailingSlash = _a.trailingSlash;
var _b = createTemplateValues_1.default(input, trailingSlash), api = _b.api, imports = _b.imports;
var hasTypes = fs_1.default.existsSync(path_1.default.join(input, '@types')) || fs_1.default.existsSync(path_1.default.join(input, '@types.ts'));
var hasUtils = fs_1.default.existsSync(path_1.default.join(input, '@utils')) || fs_1.default.existsSync(path_1.default.join(input, '@utils.ts'));
var exportsList = __spread((hasTypes ? ['ApiTypes'] : []), (hasUtils ? ['apiUtils'] : []));
var text = template_1.default
.replace('<% types %>', hasTypes
? "import * as ApiTypes from './@types'\n"
: '')
.replace('<% utils %>', hasUtils
? "import * as apiUtils from './@utils'\n"
: '')
var text = "/* eslint-disable */\nimport { AspidaClient } from 'aspida'\n<% types %><% utils %><% imports %>\n\nconst api = <U>(client: AspidaClient<U>) => {\n const prefix = (client.baseURL === undefined ? '<% baseURL %>' : client.baseURL).replace(/\\/$/, '')\n\n return <% api %>\n}\n<% exports %>\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n"
.replace('<% types %>', hasTypes ? "import * as ApiTypes from './@types'\n" : '')
.replace('<% utils %>', hasUtils ? "import * as apiUtils from './@utils'\n" : '')
.replace('<% imports %>', imports.map(function (i) { return i.replace(input, '.'); }).join('\n'))
.replace('<% exports %>', exportsList.length
? "\nexport { " + exportsList.join(', ') + " }"
: '')
.replace('<% exports %>', exportsList.length ? "\nexport { " + exportsList.join(', ') + " }" : '')
.replace('<% api %>', api)

@@ -49,0 +42,0 @@ .replace('<% baseURL %>', baseURL);

import { BaseConfig } from '../getConfig';
import { Template } from '../build/template';
import { Template } from '../buildTemplate';
import { Command } from './command';

@@ -4,0 +4,0 @@ export declare class CommandToBuild implements Command {

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

declare const _default: (target: string, indent: string, importName: string, newUrl: string) => string;
declare const _default: (target: string, indent: string, importName: string, newUrl: string, trailingSlash: boolean) => string;
export default _default;
//# sourceMappingURL=createMethodsString.d.ts.map

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

var typescript_1 = require("typescript");
exports.default = (function (target, indent, importName, newUrl) {
exports.default = (function (target, indent, importName, newUrl, trailingSlash) {
var source = new ts_morph_1.Project().addSourceFileAtPath(target);

@@ -64,5 +64,6 @@ var chanks = [];

};
var quotation = newUrl.includes('${') ? '`' : "'";
var tmpChanks = [
"(" + option(methodName) + ") =>",
"client.fetch<" + resData(methodName) + resHeaders(methodName) + ">(prefix, " + (newUrl.includes('${') ? '`' : "'") + newUrl + (newUrl.includes('${') ? '`' : "'") + ", '" + methodName.toUpperCase() + "'" + request() + ")." + resMethodName() + "()"
"client.fetch<" + resData(methodName) + resHeaders(methodName) + ">(prefix, " + quotation + newUrl + (trailingSlash ? '/' : '') + quotation + ", '" + methodName.toUpperCase() + "'" + request() + ")." + resMethodName() + "()"
];

@@ -69,0 +70,0 @@ chanks.push(indent + " " + methodName + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + methodName + ": async " + tmpChanks[0] + "\n" + indent + " (await " + tmpChanks[1] + ").data");

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

declare const _default: (input: string) => {
declare const _default: (input: string, trailingSlash: boolean) => {
api: string;

@@ -3,0 +3,0 @@ imports: string[];

@@ -25,4 +25,9 @@ "use strict";

var createMethodsString_1 = __importDefault(require("./createMethodsString"));
exports.default = (function (input) {
exports.default = (function (input, trailingSlash) {
var imports = [];
var getMethodsString = function (file, target, indent, newUrl) {
var importName = "Methods" + imports.length;
imports.push("import { Methods as " + importName + " } from '" + file + "'");
return createMethodsString_1.default(target, indent, importName, newUrl, trailingSlash);
};
var valCount = 0;

@@ -37,10 +42,10 @@ var createApiString = function (mockDir, importBasePath, indent, url, text, methodsOfIndexTsFile) {

return;
var valFn = "" + indent + file
.replace(/\.ts$/, '')
var basename = path_1.default.basename(file, '.ts');
var valFn = "" + indent + basename
.replace(/(-|\.|!| |'|\*|\(|\))/g, '_')
.replace(/^(\d)/, '$$$1') + ": {\n<% next %>\n" + indent + "}";
var newUrl = url + "/" + file.replace(/\.ts$/, '');
var newUrl = url + "/" + basename;
if (file.startsWith('_')) {
var _a = __read(file.replace(/\.ts$/, '').split('@'), 2), valName = _a[0], _b = _a[1], valType = _b === void 0 ? 'number | string' : _b;
if (/^[A-Z]/.test(valType) && valType.indexOf(valType) > -1) {
var _a = __read(basename.split('@'), 2), valName = _a[0], _b = _a[1], valType = _b === void 0 ? 'number | string' : _b;
if (/^[A-Z]/.test(valType)) {
valType = "ApiTypes." + valType;

@@ -53,19 +58,11 @@ }

var target = path_1.default.posix.join(mockDir, file);
if (fs_1.default.statSync(target).isFile() && file !== 'index.ts') {
if (path_1.default.extname(file) !== '.ts')
return;
var importName = "Methods" + imports.length;
imports.push("import { Methods as " + importName + " } from '" + importBasePath + "/" + file.replace(/\.ts$/, '') + "'");
props.push(valFn.replace('<% next %>', createMethodsString_1.default(target, indent, importName, newUrl)));
}
else if (fs_1.default.statSync(target).isDirectory()) {
if (fs_1.default.statSync(target).isDirectory()) {
var indexPath = path_1.default.posix.join(target, 'index.ts');
var methods = void 0;
if (fs_1.default.existsSync(indexPath)) {
var importName = "Methods" + imports.length;
imports.push("import { Methods as " + importName + " } from '" + importBasePath + "/" + file + "/index'");
methods = createMethodsString_1.default(indexPath, indent, importName, newUrl);
}
props.push(createApiString(target, importBasePath + "/" + file, indent, newUrl, valFn.replace('<% next %>', '<% props %>'), methods));
props.push(createApiString(target, importBasePath + "/" + file, indent, newUrl, valFn.replace('<% next %>', '<% props %>'), fs_1.default.existsSync(indexPath)
? getMethodsString(importBasePath + "/" + file + "/index", indexPath, indent, newUrl)
: undefined));
}
else if (path_1.default.extname(file) === '.ts' && file !== 'index.ts') {
props.push(valFn.replace('<% next %>', getMethodsString(importBasePath + "/" + basename, target, indent, newUrl)));
}
});

@@ -76,10 +73,6 @@ return text.replace('<% props %>', "" + props.join(',\n') + (methodsOfIndexTsFile ? "" + (props.length ? ',\n' : '') + methodsOfIndexTsFile : ''));

var rootIndent = ' ';
var rootMethods;
if (fs_1.default.existsSync(rootIndexPath)) {
var importName = 'Methods0';
imports.push("import { Methods as " + importName + " } from './index'");
rootMethods = createMethodsString_1.default(rootIndexPath, rootIndent, importName, '/');
}
return {
api: createApiString(input, '.', rootIndent, '', "{\n<% props %>\n }", rootMethods),
api: createApiString(input, '.', rootIndent, '', "{\n<% props %>\n }", fs_1.default.existsSync(rootIndexPath)
? getMethodsString('./index', rootIndexPath, rootIndent, '')
: undefined),
imports: imports

@@ -86,0 +79,0 @@ };

export interface BaseConfig {
input: string;
baseURL: string;
trailingSlash: boolean;
}

@@ -5,0 +6,0 @@ declare const _default: (configPath?: string) => BaseConfig[];

@@ -19,3 +19,3 @@ "use strict";

var path_1 = __importDefault(require("path"));
var defaultConfig = { input: 'apis', baseURL: '' };
var defaultConfig = { input: 'apis', baseURL: '', trailingSlash: false };
exports.default = (function (configPath) {

@@ -22,0 +22,0 @@ if (configPath === void 0) { configPath = 'aspida.config.js'; }

@@ -1,4 +0,4 @@

import { Template } from './build/template';
import { Template } from './buildTemplate';
declare const _default: ({ filePath, text }: Template) => void;
export default _default;
//# sourceMappingURL=writeRouteFile.d.ts.map
{
"name": "aspida",
"version": "0.11.0",
"version": "0.12.0",
"description": "Type safe HTTP client wrapper for the browser and node.js",

@@ -5,0 +5,0 @@ "author": "m-mitsuhide <m.mitsuhide@amatelus.com>",

@@ -0,4 +1,10 @@

| aspida | [aspida-mock] | [openapi2aspida] | [pathpida] | [@aspida/axios] | [@aspida/ky] | [@aspida/fetch] |
| ------ | ------------- | ---------------- | ---------- | --------------- | ------------ | --------------- |
<br />
<br />
<br />
<br />
<br />
<div align="center">

@@ -333,1 +339,8 @@ <img src="https://aspidajs.github.io/aspida/logos/svg/black.svg" alt="aspida" title="aspida" width="600" />

aspida is licensed under a [MIT License](https://github.com/aspidajs/aspida/blob/master/packages/aspida/LICENSE).
[aspida-mock]: https://github.com/aspidajs/aspida/tree/master/packages/aspida-mock
[openapi2aspida]: https://github.com/aspidajs/aspida/tree/master/packages/openapi2aspida
[pathpida]: https://github.com/aspidajs/aspida/tree/master/packages/pathpida
[@aspida/axios]: https://github.com/aspidajs/aspida/tree/master/packages/aspida-axios
[@aspida/ky]: https://github.com/aspidajs/aspida/tree/master/packages/aspida-ky
[@aspida/fetch]: https://github.com/aspidajs/aspida/tree/master/packages/aspida-fetch

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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