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

@doczilla/node

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@doczilla/node - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

.eslintignore

13

CHANGELOG.md

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

# [1.2.0](https://github.com/doczilla-app/doczilla-node/compare/v1.1.0...v1.2.0) (2023-12-23)
### Features
* Automatically encode `page.html`, `pdf.headerTemplate` and `pdf.footerTemplate` ([3a62a32](https://github.com/doczilla-app/doczilla-node/commit/3a62a3249e64195a322cb614802023d95d0dd526))
# [1.1.0](https://github.com/doczilla-app/doczilla-node/compare/v1.0.7...v1.1.0) (2023-12-21)

@@ -28,5 +37,1 @@

# 1.0.0 (2023-12-16)

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

const axios_1 = __importDefault(require("axios"));
const package_json_1 = require("../package.json");
const PdfService_1 = require("./services/PdfService");
const ScreenshotService_1 = require("./services/ScreenshotService");
const WebhookService_1 = require("./services/WebhookService");
const package_json_1 = require("../package.json");
class Doczilla {
constructor(token, options = {}) {
if (!token) {
throw new Error('No token provided!');
}
this.client = axios_1.default.create({

@@ -15,0 +18,0 @@ baseURL: options.baseURL || 'https://api.doczilla.app',

import axios from 'axios';
import { version } from '../package.json';
import { PdfService } from './services/PdfService';
import { ScreenshotService } from './services/ScreenshotService';
import { WebhookService } from './services/WebhookService';
import { version } from '../package.json';
export default class Doczilla {
constructor(token, options = {}) {
if (!token) {
throw new Error('No token provided!');
}
this.client = axios.create({

@@ -9,0 +12,0 @@ baseURL: options.baseURL || 'https://api.doczilla.app',

import { Axios, AxiosRequestConfig } from 'axios';
import type { AsyncPdf, AsyncScreenshot, CreatePdf, CreateScreenshot, SyncPdf, SyncScreenshot } from '../generated';
type PdfRequests = CreatePdf | SyncPdf | AsyncPdf;
type ScreenshotRequests = CreateScreenshot | SyncScreenshot | AsyncScreenshot;
type RequestBody = PdfRequests | ScreenshotRequests;
export declare class BaseService {

@@ -11,5 +15,8 @@ private readonly client;

constructor(client: Axios);
protected post<T>(url: string, requestBody: object, config?: AxiosRequestConfig, retries?: number): Promise<T>;
protected post<T>(url: string, requestBody: RequestBody, config?: AxiosRequestConfig, retries?: number): Promise<T>;
private encodeRequestBody;
private waitForRateLimit;
private processRateLimit;
private baseEncodeContent;
}
export {};

@@ -29,3 +29,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

yield this.waitForRateLimit();
const axiosResponse = yield this.client.post(url, requestBody, config);
const axiosResponse = yield this.client.post(url, this.encodeRequestBody(requestBody), config);
this.processRateLimit(new AxiosHeaders(axiosResponse.headers));

@@ -45,2 +45,15 @@ if (config.responseType === 'arraybuffer') {

}
encodeRequestBody(requestBody) {
var _a, _b;
if (requestBody.page.html) {
requestBody.page.html = this.baseEncodeContent(requestBody.page.html);
}
if ((_a = requestBody.pdf) === null || _a === void 0 ? void 0 : _a.headerTemplate) {
requestBody.pdf.headerTemplate = this.baseEncodeContent(requestBody.pdf.headerTemplate);
}
if ((_b = requestBody.pdf) === null || _b === void 0 ? void 0 : _b.footerTemplate) {
requestBody.pdf.footerTemplate = this.baseEncodeContent(requestBody.pdf.footerTemplate);
}
return requestBody;
}
waitForRateLimit() {

@@ -65,2 +78,5 @@ return __awaiter(this, void 0, void 0, function* () {

}
baseEncodeContent(content) {
return Buffer.from(content).toString('base64');
}
}
/// <reference types="node" />
import type { AsyncJob, AsyncScreenshot, CreateScreenshot, SyncJob, SyncScreenshot } from '../generated';
import { BaseService } from './BaseService';
import type { AsyncJob, AsyncScreenshot, CreateScreenshot, SyncJob, SyncScreenshot } from '../generated';
export declare class ScreenshotService extends BaseService {

@@ -5,0 +5,0 @@ /**

import { Axios, AxiosRequestConfig } from 'axios';
import type { AsyncPdf, AsyncScreenshot, CreatePdf, CreateScreenshot, SyncPdf, SyncScreenshot } from '../generated';
type PdfRequests = CreatePdf | SyncPdf | AsyncPdf;
type ScreenshotRequests = CreateScreenshot | SyncScreenshot | AsyncScreenshot;
type RequestBody = PdfRequests | ScreenshotRequests;
export declare class BaseService {

@@ -11,5 +15,8 @@ private readonly client;

constructor(client: Axios);
protected post<T>(url: string, requestBody: object, config?: AxiosRequestConfig, retries?: number): Promise<T>;
protected post<T>(url: string, requestBody: RequestBody, config?: AxiosRequestConfig, retries?: number): Promise<T>;
private encodeRequestBody;
private waitForRateLimit;
private processRateLimit;
private baseEncodeContent;
}
export {};

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

yield this.waitForRateLimit();
const axiosResponse = yield this.client.post(url, requestBody, config);
const axiosResponse = yield this.client.post(url, this.encodeRequestBody(requestBody), config);
this.processRateLimit(new axios_1.AxiosHeaders(axiosResponse.headers));

@@ -48,2 +48,15 @@ if (config.responseType === 'arraybuffer') {

}
encodeRequestBody(requestBody) {
var _a, _b;
if (requestBody.page.html) {
requestBody.page.html = this.baseEncodeContent(requestBody.page.html);
}
if ((_a = requestBody.pdf) === null || _a === void 0 ? void 0 : _a.headerTemplate) {
requestBody.pdf.headerTemplate = this.baseEncodeContent(requestBody.pdf.headerTemplate);
}
if ((_b = requestBody.pdf) === null || _b === void 0 ? void 0 : _b.footerTemplate) {
requestBody.pdf.footerTemplate = this.baseEncodeContent(requestBody.pdf.footerTemplate);
}
return requestBody;
}
waitForRateLimit() {

@@ -68,3 +81,6 @@ return __awaiter(this, void 0, void 0, function* () {

}
baseEncodeContent(content) {
return Buffer.from(content).toString('base64');
}
}
exports.BaseService = BaseService;
/// <reference types="node" />
import type { AsyncJob, AsyncScreenshot, CreateScreenshot, SyncJob, SyncScreenshot } from '../generated';
import { BaseService } from './BaseService';
import type { AsyncJob, AsyncScreenshot, CreateScreenshot, SyncJob, SyncScreenshot } from '../generated';
export declare class ScreenshotService extends BaseService {

@@ -5,0 +5,0 @@ /**

{
"name": "@doczilla/node",
"version": "1.1.0",
"version": "1.2.0",
"description": "Doczilla API wrapper",

@@ -32,3 +32,5 @@ "keywords": [

"build": "tsc && tsc -p tsconfig.esm.json",
"generate:sdk": "node ./generate-models.js && yarn build"
"generate:sdk": "node ./generate-models.js && yarn build",
"lint": "eslint --ext .ts .",
"test": "jest"
},

@@ -39,7 +41,20 @@ "dependencies": {

"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"axios-mock-adapter": "^1.22.0",
"eslint": "8.56.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"jest": "^29.7.0",
"openapi-typescript-codegen": "^0.25.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3"
},
"packageManager": "yarn@4.0.2"
"packageManager": "yarn@4.0.2",
"engines": {
"node": ">=18.*"
}
}
import axios, { Axios } from 'axios'
import { version } from '../package.json'
import { PdfService } from './services/PdfService'
import { ScreenshotService } from './services/ScreenshotService'
import { WebhookService } from './services/WebhookService'
import { version } from '../package.json'

@@ -21,2 +21,6 @@ interface DoczillaOptions {

constructor(token: string, options: DoczillaOptions = {}) {
if (!token) {
throw new Error('No token provided!')
}
this.client = axios.create({

@@ -23,0 +27,0 @@ baseURL: options.baseURL || 'https://api.doczilla.app',

import { Axios, AxiosHeaders, AxiosRequestConfig, isAxiosError } from 'axios'
import type { AsyncPdf, AsyncScreenshot, CreatePdf, CreateScreenshot, SyncPdf, SyncScreenshot } from '../generated'
type PdfRequests = CreatePdf | SyncPdf | AsyncPdf
type ScreenshotRequests = CreateScreenshot | SyncScreenshot | AsyncScreenshot
type RequestBody = PdfRequests | ScreenshotRequests
export class BaseService {

@@ -19,7 +25,7 @@

protected async post<T>(url: string, requestBody: object, config: AxiosRequestConfig = {}, retries = 1): Promise<T> {
protected async post<T>(url: string, requestBody: RequestBody, config: AxiosRequestConfig = {}, retries = 1): Promise<T> {
try {
await this.waitForRateLimit()
const axiosResponse = await this.client.post<T>(url, requestBody, config)
const axiosResponse = await this.client.post<T>(url, this.encodeRequestBody(requestBody), config)
this.processRateLimit(new AxiosHeaders(axiosResponse.headers))

@@ -41,2 +47,18 @@

private encodeRequestBody(requestBody: PdfRequests): object {
if (requestBody.page.html) {
requestBody.page.html = this.baseEncodeContent(requestBody.page.html)
}
if (requestBody.pdf?.headerTemplate) {
requestBody.pdf.headerTemplate = this.baseEncodeContent(requestBody.pdf.headerTemplate)
}
if (requestBody.pdf?.footerTemplate) {
requestBody.pdf.footerTemplate = this.baseEncodeContent(requestBody.pdf.footerTemplate)
}
return requestBody
}
private async waitForRateLimit(): Promise<void> {

@@ -61,2 +83,5 @@ // Minus 1 to be safe

private baseEncodeContent(content: string): string {
return Buffer.from(content).toString('base64')
}
}
import type { AsyncJob, AsyncPdf, CreatePdf, SyncJob, SyncPdf } from '../generated'
import { BaseService } from './BaseService'

@@ -3,0 +4,0 @@

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

import { BaseService } from './BaseService'
import type { AsyncJob, AsyncScreenshot, CreateScreenshot, SyncJob, SyncScreenshot } from '../generated'
import { BaseService } from './BaseService'
export class ScreenshotService extends BaseService {

@@ -5,0 +6,0 @@

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