New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@accounty/core

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@accounty/core - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

src/utils/assure-array.d.ts

11

CHANGELOG.md
# [0.2.0](https://github.com/PalmTreeCoding/Accounty/compare/packages-core-0.1.0...packages-core-0.2.0) (2024-08-02)
### Features
* Added emtpy Jortt and Billit ([aa0aa23](https://github.com/PalmTreeCoding/Accounty/commit/aa0aa236bd98adfec74ab51f9155633844711d66))
* Implemented Billit ([f3d1623](https://github.com/PalmTreeCoding/Accounty/commit/f3d16231705c04be470727b5b45ad617c0fbd9ff))
* Publish first version of packages so they can already be used ([37d577c](https://github.com/PalmTreeCoding/Accounty/commit/37d577c52033b040b69419b489074d599da99def))
# 0.1.0 (2024-07-25)

@@ -3,0 +14,0 @@

3

package.json
{
"name": "@accounty/core",
"version": "0.1.0",
"version": "0.2.0",
"dependencies": {
"axios": "^1.6.5",
"bignumber.js": "^9.1.2",
"date-fns": "^3.2.0",
"debug": "^4.3.4",

@@ -9,0 +8,0 @@ "libphonenumber-js": "^1.10.53",

import debug from 'debug';
import type { Company, FetchCompaniesOptions, FetchInvoicesOptions, FetchResponse, SalesInvoice } from './accounty-provider-core.interfaces';
import type { AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
import { Company, FetchInvoicesOptions, FetchOptions, FetchResponse, SalesInvoice } from './accounty-provider-core.interfaces';
export default abstract class AccountyProviderCore<Credentials, Settings = object> {

@@ -22,3 +22,3 @@ protected abstract log: debug.Debugger;

abstract testCredentials(): Promise<boolean>;
abstract fetchCompanies(options?: FetchOptions): Promise<FetchResponse<Company[]>>;
abstract fetchCompanies(options?: FetchCompaniesOptions): Promise<FetchResponse<Company[]>>;
abstract fetchInvoices(options?: FetchInvoicesOptions): Promise<FetchResponse<SalesInvoice[]>>;

@@ -30,12 +30,5 @@ protected waitForRateLimit(): Promise<void>;

protected processRateLimit(headers: RawAxiosResponseHeaders | AxiosResponseHeaders): void;
protected toCentAmount(amount: string | number): number;
protected getValidCountry(possibleCountryCode?: string): string | null;
protected getValidLanguage(possibleLanguageCode?: string): string | null;
protected formUrlEncoded(data: object): string;
protected buildQueryParams(data: object): string;
protected getInvoiceDateAndDueDate(invoiceDate: string | Date, invoiceDueDate?: string | Date): Pick<SalesInvoice, 'date' | 'dueDate' | 'termDays'>;
/**
* Used for SOAP providers as those values can be an object or array if multiple
*/
protected assureArray<Type>(item: Type | Type[]): Type[];
}

@@ -65,2 +65,4 @@ type RemoteDataJsonArray = ReadonlyArray<RemoteDataJsonValue | null>;

}
export interface FetchCompaniesOptions extends FetchOptions {
}
export interface FetchInvoicesOptions extends FetchOptions {

@@ -67,0 +69,0 @@ /**

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

const axios_1 = require("axios");
const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
const addDays_1 = require("date-fns/addDays");
const differenceInCalendarDays_1 = require("date-fns/differenceInCalendarDays");
const parseISO_1 = require("date-fns/parseISO");
const validator_1 = tslib_1.__importDefault(require("validator"));
const addDays_1 = tslib_1.__importDefault(require("date-fns/addDays"));
const differenceInCalendarDays_1 = tslib_1.__importDefault(require("date-fns/differenceInCalendarDays"));
const parseISO_1 = tslib_1.__importDefault(require("date-fns/parseISO"));
class AccountyProviderCore {

@@ -56,3 +54,3 @@ constructor() {

else if (this.rateLimitHeaders.resetDate) {
resetIn = (0, parseISO_1.parseISO)(`${axiosHeaders.get(this.rateLimitHeaders.resetDate)}`).getTime() - Date.now();
resetIn = (0, parseISO_1.default)(`${axiosHeaders.get(this.rateLimitHeaders.resetDate)}`).getTime() - Date.now();
}

@@ -65,22 +63,2 @@ this.rateLimit = {

}
toCentAmount(amount) {
return new bignumber_js_1.default(amount)
.times(100)
.decimalPlaces(0)
.toNumber();
}
getValidCountry(possibleCountryCode) {
const countryCode = possibleCountryCode?.toUpperCase();
if (countryCode && validator_1.default.isISO31661Alpha2(countryCode)) {
return countryCode;
}
return null;
}
getValidLanguage(possibleLanguageCode) {
const language = possibleLanguageCode?.toLowerCase();
if (language && validator_1.default.isISO6391(language)) {
return language;
}
return null;
}
formUrlEncoded(data) {

@@ -90,13 +68,13 @@ return Object.keys(data).reduce((p, c) => p + `&${c}=${encodeURIComponent(data[c])}`, '');

buildQueryParams(data) {
return Object.keys(data).reduce((p, c) => (`${p}&${c}=${data[c]}`), '?');
return Object.keys(data).reduce((p, c) => ([p, `${c}=${data[c]}`].filter(Boolean).join('&')), '');
}
getInvoiceDateAndDueDate(invoiceDate, invoiceDueDate) {
const date = typeof invoiceDate === 'string' ? (0, parseISO_1.parseISO)(invoiceDate) : invoiceDate;
const date = typeof invoiceDate === 'string' ? (0, parseISO_1.default)(invoiceDate) : invoiceDate;
let dueDate = null;
if (invoiceDueDate) {
dueDate = typeof invoiceDueDate === 'string' ? (0, parseISO_1.parseISO)(invoiceDueDate) : invoiceDueDate;
dueDate = typeof invoiceDueDate === 'string' ? (0, parseISO_1.default)(invoiceDueDate) : invoiceDueDate;
}
// If we still have no expire date do the default of 30 days
if (!dueDate) {
dueDate = (0, addDays_1.addDays)(date, 30);
dueDate = (0, addDays_1.default)(date, 30);
}

@@ -106,19 +84,7 @@ return {

dueDate,
termDays: (0, differenceInCalendarDays_1.differenceInCalendarDays)(dueDate, date)
termDays: (0, differenceInCalendarDays_1.default)(dueDate, date)
};
}
/**
* Used for SOAP providers as those values can be an object or array if multiple
*/
assureArray(item) {
if (!item) {
return [];
}
else if (Array.isArray(item)) {
return item;
}
return [item];
}
}
exports.default = AccountyProviderCore;
//# sourceMappingURL=accounty-provider-core.js.map

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

export * from './assure-array';
export * from './to-cent-amount';
export * from './to-country';
export * from './to-email';
export * from './to-language';
export * from './to-phone-number';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./assure-array"), exports);
tslib_1.__exportStar(require("./to-cent-amount"), exports);
tslib_1.__exportStar(require("./to-country"), exports);
tslib_1.__exportStar(require("./to-email"), exports);
tslib_1.__exportStar(require("./to-language"), exports);
tslib_1.__exportStar(require("./to-phone-number"), exports);
//# sourceMappingURL=index.js.map

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