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

@burdy-cms/web-utils

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@burdy-cms/web-utils - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

16

dist/api/burdy-api.d.ts

@@ -27,3 +27,3 @@ import { IBurdyPage, IBurdySearch, IBurdyTag } from '../types';

page?: number;
xContentToken: string;
xContentToken?: string;
};

@@ -40,8 +40,18 @@ export declare type SearchTagsOptions = {

page?: number;
xContentToken: string;
xContentToken?: string;
};
export declare const BurdyApi: {
getPage: <T = any>(url: string, options?: GetPageOptions) => Promise<IBurdyPage<T>>;
getPage: <T = any>(host?: string, slugPath?: string, options?: GetPageOptions) => Promise<IBurdyPage<T>>;
searchPages: <T_1 = any>(host: string, options: SearchPagesOptions) => Promise<IBurdySearch<IBurdyPage<T_1>>>;
searchTags: (host: string, options: SearchTagsOptions) => Promise<IBurdySearch<IBurdyTag>>;
};
export declare type ApiConfig = {
host: string;
xContentToken?: string;
};
export declare type CreateApiType = {
getPage: <T = any>(slugPath: string, options?: GetPageOptions) => Promise<IBurdyPage<T>>;
searchPages: <T = any>(options: SearchPagesOptions) => Promise<IBurdySearch<IBurdyPage<T>>>;
searchTags: (options: SearchTagsOptions) => Promise<IBurdySearch<IBurdyTag>>;
};
export declare const createApi: (apiConfig: ApiConfig) => CreateApiType;

@@ -15,6 +15,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.BurdyApi = void 0;
exports.createApi = exports.BurdyApi = void 0;
const axios_1 = __importDefault(require("axios"));
exports.BurdyApi = {
getPage: (url, options) => __awaiter(void 0, void 0, void 0, function* () {
getPage: (host, slugPath, options) => __awaiter(void 0, void 0, void 0, function* () {
const headers = {};

@@ -36,3 +36,3 @@ const params = {};

params.draft = options === null || options === void 0 ? void 0 : options.draft;
const { data: page } = yield axios_1.default.get(url, {
const { data: page } = yield axios_1.default.get(`${host}/api/content/${slugPath}`, {
params,

@@ -114,1 +114,13 @@ headers

};
const createApi = (apiConfig) => ({
getPage: (slugPath, options) => __awaiter(void 0, void 0, void 0, function* () {
return exports.BurdyApi.getPage(apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.host, slugPath, Object.assign({ xContentToken: apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.xContentToken }, (options || {})));
}),
searchPages: (options) => __awaiter(void 0, void 0, void 0, function* () {
return exports.BurdyApi.searchPages(apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.host, Object.assign({ xContentToken: apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.xContentToken }, (options || {})));
}),
searchTags: (options) => __awaiter(void 0, void 0, void 0, function* () {
return exports.BurdyApi.searchTags(apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.host, Object.assign({ xContentToken: apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.xContentToken }, (options || {})));
})
});
exports.createApi = createApi;

4

dist/rewrites/build-path.d.ts
import { Key } from 'path-to-regexp';
import { RewriteDestination, RewritesMap } from '../types';
import { RewritesMap } from '../types';
export declare const rewrite: (string: string, params?: Record<Key['name'], string | undefined>) => string;
export declare const matchAndRewriteMap: <T>(path: string, map?: RewritesMap<T>[], baseUrl?: string) => RewriteDestination<T>;
export declare const matchAndRewriteMap: <T = any>(path: string, map?: RewritesMap<T>[], baseUrl?: string) => string | T;

@@ -9,3 +9,2 @@ "use strict";

const deepcopy_1 = __importDefault(require("deepcopy"));
const RESERVED_KEY = '$__path';
const escapeRegExp = (str) => {

@@ -22,14 +21,6 @@ return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');

exports.rewrite = rewrite;
const normalizeRewritesMap = (rewrites) => rewrites.map(rewrite => (Object.assign(Object.assign({}, rewrite), { destination: typeof rewrite.destination === 'string' ?
{ [RESERVED_KEY]: rewrite.destination } :
rewrite.destination })));
const normalizeDestination = (destination) => Object.keys(destination).length === 1 && (destination === null || destination === void 0 ? void 0 : destination[RESERVED_KEY]) ?
destination[RESERVED_KEY] :
destination;
const matchAndRewriteMap = (path, map = [], baseUrl = '') => {
var _a;
let resultArray;
let keys = [];
map = (0, deepcopy_1.default)(map);
map = normalizeRewritesMap(map);
const rule = map.find((rule) => {

@@ -42,6 +33,3 @@ keys = [];

if (!rule) {
const firstDestination = normalizeDestination(((_a = map === null || map === void 0 ? void 0 : map[0]) === null || _a === void 0 ? void 0 : _a.destination) || '');
return typeof firstDestination === 'string' ?
null :
Object.keys(firstDestination).reduce((previousValue, currentValue) => (Object.assign(Object.assign({}, previousValue), { [currentValue]: null })), {});
return null;
}

@@ -52,8 +40,15 @@ const params = {};

});
Object.keys(rule.destination || {}).forEach((key) => {
var _a;
rule.destination[key] = baseUrl.replace(/\/$/i, '') + (0, exports.rewrite)((_a = rule.destination) === null || _a === void 0 ? void 0 : _a[key], params);
});
return normalizeDestination(rule.destination);
if (typeof (rule === null || rule === void 0 ? void 0 : rule.destination) === 'string') {
return baseUrl.replace(/\/$/i, '') + (0, exports.rewrite)((rule === null || rule === void 0 ? void 0 : rule.destination) || '', params);
}
if (typeof (rule === null || rule === void 0 ? void 0 : rule.destination) === 'object') {
let destination = {};
Object.keys(rule.destination || {}).forEach((key) => {
var _a;
destination = Object.assign(Object.assign({}, destination), { [key]: baseUrl.replace(/\/$/i, '') + (0, exports.rewrite)((_a = rule.destination) === null || _a === void 0 ? void 0 : _a[key], params) });
});
return destination;
}
return null;
};
exports.matchAndRewriteMap = matchAndRewriteMap;

@@ -18,5 +18,5 @@ export * from './model';

export declare type RewritesObject<T extends {} | string> = {
rewrite: (path: string) => RewriteDestination<T>;
rewrite: (path: string) => string | null | T;
getOrigin: () => string | undefined;
getRewrite: () => RewritesMap<T>[];
};
{
"name": "@burdy-cms/web-utils",
"version": "1.2.0",
"version": "1.2.1",
"description": "Burdy web utilities",

@@ -5,0 +5,0 @@ "author": "Team Burdy <team@burdy.io>",

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