Socket
Socket
Sign inDemoInstall

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.19.1 to 0.19.2

18

dist/buildTemplate.js

@@ -38,14 +38,14 @@ "use strict";

};
var createTemplate = function (tree, baseURL, trailingSlash, appendPrefix) {
var _a = createTemplateValues_1.default(tree, trailingSlash), api = _a.api, imports = _a.imports, pathes = _a.pathes;
var createTemplate = function (tree, baseURL, trailingSlash, basePath) {
var _a = createTemplateValues_1.default(tree, basePath, trailingSlash), api = _a.api, imports = _a.imports, pathes = _a.pathes;
var text = ("/* eslint-disable */\nimport { AspidaClient" + (api.includes('BasicHeaders') ? ', BasicHeaders' : '') + " } from 'aspida'\n<% types %><% imports %>\n" + ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH', 'OPTIONS']
.filter(function (m) { return api.includes(", " + m + ", option"); })
.map(function (m) { return "\nconst " + m + " = '" + m + "'"; })
.join('') + pathes.map(function (p, i) { return "\nconst PATH" + i + " = " + p; }).join('') + "\nconst api = <T>({ baseURL, fetch }: AspidaClient<T>) => {\n const prefix = " + (appendPrefix ? '`${' : '') + "(baseURL === undefined ? '<% baseURL %>' : baseURL).replace(/\\/$/, '')" + (appendPrefix ? "}/" + appendPrefix + "`" : '') + "\n\n return <% api %>\n}\n\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n")
.join('') + pathes.map(function (p, i) { return "\nconst PATH" + i + " = " + p; }).join('') + "\nconst api = <T>({ baseURL, fetch }: AspidaClient<T>) => {\n const prefix = (baseURL === undefined ? '<% baseURL %>' : baseURL).replace(/\\/$/, '')\n\n return <% api %>\n}\n\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n")
.replace('<% types %>', api.includes(': ApiTypes.')
? "import * as ApiTypes from '" + (appendPrefix
? appendPrefix
? "import * as ApiTypes from '" + (basePath
? basePath
.split('/')
.map(function () { return '../'; })
.join('')
.map(function () { return ''; })
.join('../')
: './') + "@types'\n"

@@ -61,3 +61,3 @@ : '')

var direntTree = getDirentTree_1.getDirentTree(input);
var templates = [createTemplate(direntTree, baseURL, trailingSlash)];
var templates = [createTemplate(direntTree, baseURL, trailingSlash, '')];
if (outputEachDir) {

@@ -73,3 +73,3 @@ var notIndexFiles = listNotIndexFiles(direntTree);

return;
templates.push(createTemplate(c.tree, baseURL, trailingSlash, c.tree.path.replace(input, '').replace(/^\//, '')));
templates.push(createTemplate(c.tree, baseURL, trailingSlash, c.tree.path.replace(input, '')));
appendTemplate_1(c.tree);

@@ -76,0 +76,0 @@ });

import { Method } from './parseInterface';
declare const _default: (methods: Method[], indent: string, importName: string, newPrefix: string, path: string) => string;
declare const _default: (methods: Method[], indent: string, importName: string, path: string) => string;
export default _default;
//# sourceMappingURL=createMethodsString.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (function (methods, indent, importName, newPrefix, path) {
exports.default = (function (methods, indent, importName, path) {
return methods

@@ -57,3 +57,3 @@ .map(function (_a) {

"(" + option(name) + ") =>",
"fetch<" + resBody(name) + resHeaders(name) + status(name) + ">(" + newPrefix + ", " + path + ", " + name.toUpperCase() + request() + ")." + resMethodName() + "()"
"fetch<" + resBody(name) + resHeaders(name) + status(name) + ">(prefix, " + path + ", " + name.toUpperCase() + request() + ")." + resMethodName() + "()"
];

@@ -60,0 +60,0 @@ return indent + " " + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ".then(r => r.body)";

import { DirentTree } from './getDirentTree';
declare const _default: (direntTree: DirentTree, trailingSlash: boolean) => {
declare const _default: (direntTree: DirentTree, basePath: string, trailingSlash: boolean) => {
api: string;

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

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

var createMethodsString_1 = __importDefault(require("./createMethodsString"));
exports.default = (function (direntTree, trailingSlash) {
exports.default = (function (direntTree, basePath, trailingSlash) {
var imports = [];

@@ -37,3 +37,3 @@ var pathes = [];

}
return createMethodsString_1.default(methods, indent, importName, newPrefix, newPath);
return createMethodsString_1.default(methods, indent, importName, newPrefix && newPath.length > 2 ? "`${" + newPrefix + "}${" + newPath + "}`" : newPrefix || newPath);
};

@@ -62,3 +62,3 @@ var valCount = 0;

var duplicatedNames = tree.children.filter(function (d) { return d.name.startsWith(valName_1); });
var prefixVal = "`${" + prefix + "}" + (url.length ? "${PATH" + pathes.indexOf(prevUrl) + "}" : '') + (url.length && trailingSlash ? '' : '/') + "${val" + valCount + "}" + valName_1.replace(/^[^.]+/, '') + "`";
var prefixVal = "`" + (prefix ? "${" + prefix + "}" : '') + (url.length ? "${PATH" + pathes.indexOf(prevUrl) + "}" : '') + (url.length && trailingSlash ? '' : '/') + "${val" + valCount + "}" + valName_1.replace(/^[^.]+/, '') + "`";
newPrefix = "prefix" + valCount;

@@ -85,4 +85,4 @@ newUrl = '';

/* eslint-disable no-template-curly-in-string */
var api = createApiString(direntTree, '.', ' ', 'prefix', '', "{\n<% props %>\n }", rootIndexData && !rootIndexData.isDir
? getMethodsString('./index', rootIndexData.methods, ' ', 'prefix', '')
var api = createApiString(direntTree, '.', ' ', '', basePath, "{\n<% props %>\n }", rootIndexData && !rootIndexData.isDir
? getMethodsString('./index', rootIndexData.methods, ' ', '', basePath)
: undefined);

@@ -89,0 +89,0 @@ while (emptyMethodsRegExp.test(api)) {

{
"name": "aspida",
"version": "0.19.1",
"version": "0.19.2",
"description": "TypeScript friendly HTTP client wrapper for the browser and node.js",

@@ -5,0 +5,0 @@ "author": "Solufa <solufa2020@gmail.com>",

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