Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,7 @@
/types/is-color/ @VitorLuizC
/types/is-core-module/ @peterblazejewicz
/types/is-data-descriptor/ @Richienb
/types/is-deflate/ @MattIPv4
/types/is-dom/ @peterblazejewicz
/types/is-domain-name/ @BendingBender
/types/is-dotdir/ @BendingBender
Expand Down Expand Up @@ -3618,6 +3619,7 @@
/types/jquery/ @leonard-thieu @borisyankov @choffmeister @Steve-Fenton @Diullei @tasoili @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @JoshStrobl @johnnyreilly @DickvdBrink @King2500 @terrymun @martin-badin @princefishthrower
/types/jquery/v1/ @borisyankov @choffmeister @Steve-Fenton @Diullei @tasoili @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @JoshStrobl @johnnyreilly @DickvdBrink @King2500 @leonard-thieu
/types/jquery/v2/ @borisyankov @choffmeister @Steve-Fenton @Diullei @tasoili @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @JoshStrobl @johnnyreilly @DickvdBrink @King2500 @leonard-thieu
/types/jquery/v3/ @leonard-thieu @borisyankov @choffmeister @Steve-Fenton @Diullei @tasoili @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @JoshStrobl @johnnyreilly @DickvdBrink @King2500 @terrymun @martin-badin @princefishthrower
/types/jquery-ajax-chain/ @humana-fragilitas
/types/jquery-alertable/ @stever
/types/jquery-animate-scroll/ @AndersonFriaca
Expand Down
13 changes: 9 additions & 4 deletions types/invity-api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export interface BuySellProviderMetadata extends ProviderMetadata {
disabledSubdivisions?: Subdivisions;
}

export interface TradeCommon {
statusUrl?: string | null; // URL with ID assigned to the trade by the provider to check status; if null, do not show any status url
}

// buy types

export type BuyTradeFinalStatus =
Expand Down Expand Up @@ -160,6 +164,7 @@ export interface BuyProviderInfo extends BuySellProviderMetadata {

export interface BuyListResponse {
country: string;
subdivision?: string;
suggestedFiatCurrency?: string | undefined; // optional field, fiat currency based on user's IP
providers: BuyProviderInfo[];
defaultAmountsOfFiatCurrencies: FiatCurrenciesProps;
Expand All @@ -180,7 +185,7 @@ export interface BuyTradeQuoteRequest {

export type BuyTradeQuoteResponse = BuyTrade[];

export interface BuyTrade {
export interface BuyTrade extends TradeCommon {
fiatAmount?: number | undefined; // 1000 - DEPRECATED, used only for TREZOR
fiatStringAmount?: string | undefined; // 1000 - will pay fiat amount
fiatCurrency?: string | undefined; // EUR
Expand Down Expand Up @@ -294,7 +299,7 @@ export type DexApprovalType =
| "ZERO" // resets approval
| "PRESET"; // PRESET takes value from approvalStringAmount

export interface ExchangeTrade {
export interface ExchangeTrade extends TradeCommon {
send?: CryptoId | undefined; // bitcoin

sendStringAmount?: string | undefined; // "0.01"
Expand All @@ -314,7 +319,6 @@ export interface ExchangeTrade {
signature?: string | undefined; // Evercoin only, passed from createTrade response to confirmTrade request
orderId?: string | undefined; // internal ID assigned to the trade by the exchange
quoteId?: string | undefined;
statusUrl?: string | undefined; // internal URL + ID assigned to the trade by the exchange to check status
status?: ExchangeTradeStatus | undefined; // state of trade after confirmTrade
error?: string | undefined; // something went wrong after confirmTrade
receiveTxHash?: string | undefined; // hash of tx from exchange to user or DEX swap
Expand Down Expand Up @@ -494,6 +498,7 @@ export interface SellProviderInfo extends BuySellProviderMetadata {

export interface SellListResponse {
country: string;
subdivision?: string;
providers: SellProviderInfo[];
}

Expand All @@ -515,7 +520,7 @@ export interface SellFiatTradeQuoteRequest {

export type SellFiatTradeQuoteResponse = SellFiatTrade[];

export interface SellFiatTrade {
export interface SellFiatTrade extends TradeCommon {
amountInCrypto?: boolean | undefined; // true for cryptoAmount, false for fiatAmount
fiatStringAmount?: string | undefined; // 1000
fiatCurrency?: string | undefined; // EUR
Expand Down
55 changes: 55 additions & 0 deletions types/invity-api/invity-api-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BuyListResponse,
BuyProviderInfo,
BuyTrade,
ConfirmExchangeTradeRequest,
Expand All @@ -12,6 +13,7 @@ import {
InfoResponse,
SellFiatTrade,
SellFiatTradeSigned,
SellListResponse,
SellProviderInfo,
WatchSellTradeResponse,
} from "invity-api";
Expand Down Expand Up @@ -178,3 +180,56 @@ const exchangeTradeQuoteRequest: ExchangeTradeQuoteRequest = {
fromAddress: "fromAddress",
receiveAddress: "receiveAddress",
};

const buyListResponse: BuyListResponse = {
country: "US",
subdivision: "WA",
suggestedFiatCurrency: "USD",
providers: [providerInfo],
defaultAmountsOfFiatCurrencies: {
usd: 1,
eur: 1,
gbp: 1,
aed: 1,
ars: 1,
aud: 1,
bdt: 1,
brl: 1,
cad: 1,
chf: 1,
clp: 1,
cny: 1,
czk: 1,
dkk: 1,
hkd: 1,
huf: 1,
idr: 1,
ils: 1,
inr: 1,
jpy: 1,
krw: 1,
kwd: 1,
lkr: 1,
mxn: 1,
myr: 1,
nok: 1,
nzd: 1,
php: 1,
pln: 1,
rub: 1,
sar: 1,
sek: 1,
sgd: 1,
thb: 1,
try: 1,
twd: 1,
vnd: 1,
zar: 1,
},
};

const sellListResponse: SellListResponse = {
country: "US",
subdivision: "WA",
providers: [sellProviderInfo],
};
43 changes: 38 additions & 5 deletions types/svg-to-pdfkit/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
import PDFDocument = require("pdfkit");

/**
* Insert SVG into a PDF document created with PDFKit.
*
* @param doc the PDF document created with PDFKit
* @param svg the SVG object or XML code
* @param x the x position where the SVG will be added
* @param y the y position where the SVG will be added
* @param options See {@link SVGtoPDF.Options}
*/
declare function SVGtoPDF(
doc: typeof PDFDocument,
svg: SVGElement | string,
x?: number,
y?: number,
options?: SVGtoPDF.SVGtoPDFOptions,
options?: SVGtoPDF.Options,
): void;

declare namespace SVGtoPDF {
interface SVGtoPDFOptions {
type Color = [[number, number, number], number];
interface Options {
/** initial viewport width, by default it's the page width */
width?: number;

/** initial viewport width, by default it's the page height */
height?: number;

/** override alignment of the SVG content inside its viewport */
preserveAspectRatio?: string;

/** use the CSS styles computed by the browser (for SVGElement only) */
useCSS?: boolean;

/** function called to get the fonts, see source code */
fontCallback?: (
family: string,
bold: boolean,
italic: boolean,
fontOptions: { fauxItalic: boolean; fauxBold: boolean },
) => string;

/** same as above for the images (for Node.js) */
imageCallback?: (link: string) => string;
documentCallback?: (file: string) => string;
colorCallback?: (result: string, raw: string) => [[number, number, number], number];
warningCallback?: (str: string) => void;

/** same as above for the external SVG documents */
documentCallback?: (
file: string,
) => SVGElement | string | (SVGElement | string)[];

/** function called to get color, making mapping to CMYK possible */
colorCallback?: (color: Color) => Color;

/** function called when there is a warning */
warningCallback?: (warning: string) => void;

/** assume that units are PDF points instead of SVG pixels */
assumePt?: boolean;

/** precision factor for approximate calculations (default = 3) */
precision?: number;
}
}
Expand Down
17 changes: 8 additions & 9 deletions types/svg-to-pdfkit/svg-to-pdfkit-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ SvgToPdf(doc, "<svg>", 100, 100); // $ExpectType void

SvgToPdf(doc, "<svg>", 100, 100, {}); // $ExpectType void

// https://github.com/alafr/SVG-to-PDFKit/blob/4d2d8746bda1e9335c47bbe9ad91277c51fd5a07/source.js#L2477
const options: SvgToPdf.SVGtoPDFOptions = {
// https://github.com/alafr/SVG-to-PDFKit/blob/b091ebd4e7b7d2310eb1003511cd5de480f7e0e1/source.js#L2617
const options: SvgToPdf.Options = {
width: 100,
height: 100,
preserveAspectRatio: "xMinYMin",
useCSS: true,
// https://github.com/alafr/SVG-to-PDFKit/blob/4d2d8746bda1e9335c47bbe9ad91277c51fd5a07/source.js#L2500
// https://github.com/alafr/SVG-to-PDFKit/blob/b091ebd4e7b7d2310eb1003511cd5de480f7e0e1/source.js#L2640
fontCallback: (family, bold, italic, fontOptions) => {
family; // $ExpectType string
bold; // $ExpectType boolean
Expand All @@ -24,18 +24,17 @@ const options: SvgToPdf.SVGtoPDFOptions = {
fontOptions.fauxItalic; // $ExpectType boolean
return family;
},
// https://github.com/alafr/SVG-to-PDFKit/blob/4d2d8746bda1e9335c47bbe9ad91277c51fd5a07/source.js#L2558
// https://github.com/alafr/SVG-to-PDFKit/blob/b091ebd4e7b7d2310eb1003511cd5de480f7e0e1/source.js#L2698
imageCallback: link => {
link; // $ExpectType string
return link;
},
// https://github.com/alafr/SVG-to-PDFKit/blob/4d2d8746bda1e9335c47bbe9ad91277c51fd5a07/source.js#L2562
colorCallback: (result, row) => {
result; // $ExpectType string
row; // $ExpectType string
// https://github.com/alafr/SVG-to-PDFKit/blob/b091ebd4e7b7d2310eb1003511cd5de480f7e0e1/source.js#L2703
colorCallback: (color) => {
color; // $ExpectType Color
return [[255, 255, 255], 1];
},
// https://github.com/alafr/SVG-to-PDFKit/blob/4d2d8746bda1e9335c47bbe9ad91277c51fd5a07/source.js#L2494
// https://github.com/alafr/SVG-to-PDFKit/blob/b091ebd4e7b7d2310eb1003511cd5de480f7e0e1/source.js#L2635
warningCallback: str => {
str; // $ExpectType string
console.log(str);
Expand Down