From 4f2bb37e5962308e72b94ba0ff9e1b9138b059f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Sch=C3=B6nb=C3=A4chler?= <42278642+schoero@users.noreply.github.com> Date: Sat, 11 Nov 2023 06:47:01 +0100 Subject: [PATCH 1/3] docs: simplify types for easier documentation --- docs/bundle/index.md | 130 +++++++++++++++++++++---------------------- docs/pdf/types.md | 80 +++++++++++++------------- docs/svg/types.md | 80 +++++++++++++------------- src/shared/types.ts | 26 +++++---- 4 files changed, 155 insertions(+), 161 deletions(-) diff --git a/docs/bundle/index.md b/docs/bundle/index.md index 6ec301d..0efbc81 100644 --- a/docs/bundle/index.md +++ b/docs/bundle/index.md @@ -65,18 +65,16 @@ - [types](#namespace-types) - - Type aliases + - Interfaces - - [Currency](#type-alias-typescurrency) - - [Size](#type-alias-typessize) - - [Language](#type-alias-typeslanguage) - - [FontName](#type-alias-typesfontname) - [Data](#interface-typesdata) - [Debtor](#interface-typesdebtor) - [Creditor](#interface-typescreditor) - - [QRBillOptions](#interface-typesqrbilloptions) - [PDFOptions](#interface-typespdfoptions) - [SVGOptions](#interface-typessvgoptions) + - [Language](#type-alias-typeslanguage) + - [FontName](#type-alias-typesfontname) + - [Currency](#type-alias-typescurrency) - [utils](#namespace-utils) @@ -87,7 +85,7 @@ - [formatIBAN(iban)](#function-utilsformatibaniban) - [isQRReference(reference)](#function-utilsisqrreferencereference) - [isQRReferenceValid(reference)](#function-utilsisqrreferencevalidreference) - - [isSCORReference(reference)](#class-pdftable) + - [isSCORReference(reference)](#function-utilsisscorreferencereference) - [isSCORReferenceValid(reference)](#function-utilsisscorreferencevalidreference) - [calculateSCORReferenceChecksum(reference)](#function-utilscalculatescorreferencechecksumreference) - [calculateQRReferenceChecksum(reference)](#function-utilscalculateqrreferencechecksumreference) @@ -747,52 +745,12 @@ Defined in: [src/bundle/index.ts](../../src/bundle/index.ts#L4C7)
-#### Type alias: types.Currency - -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L2C0) - -##### Type - -`"CHF"` | `"EUR"` - -
- -#### Type alias: types.Size - -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L3C0) - -##### Type - -`"A4"` | `"A6"` | `"A6/5"` - -
- -#### Type alias: types.Language - -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L4C0) - -##### Type - -`"DE"` | `"EN"` | `"FR"` | `"IT"` - -
- -#### Type alias: types.FontName - -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L5C0) - -##### Type - -`"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` - -
- #### Interface: types.Data -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L7C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L1C0) - **types.creditor** [`Creditor`](#interface-typescreditor) Creditor related data. -- **types.currency** [`Currency`](#type-alias-typescurrency) The currency to be used. **3 characters.** +- **types.currency** `"CHF"` | `"EUR"` The currency to be used. **3 characters.** - **types.additionalInformation** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Additional information. **Max 140 characters.** Bill information contain coded information for automated booking of the payment. The data is not forwarded with the payment. `optional` @@ -816,7 +774,7 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L7C0) #### Interface: types.Debtor -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L66C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L60C0) - **types.address** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Address. **Max 70 characters.** - **types.city** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) City. **Max 35 characters.** @@ -829,7 +787,7 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L66C0) #### Interface: types.Creditor -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L99C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L93C0) - **types.address** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Address. **Max 70 characters.** - **types.city** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) City. **Max 35 characters.** @@ -841,25 +799,23 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L99C0)
-#### Interface: types.QRBillOptions +#### Interface: types.PDFOptions -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L107C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L139C0) -- **types.fontName** [`FontName`](#type-alias-typesfontname) Font used for the QR-Bill. +- **types.fontName** `"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` Font used for the QR-Bill. Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **types.language** [`Language`](#type-alias-typeslanguage) The language with which the bill is rendered. `optional` -- **types.outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` -- **types.scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` - -
-#### Interface: types.PDFOptions + *Example:* -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L137C0) + ```ts + // Register the font + pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); -- **types.fontName** [`FontName`](#type-alias-typesfontname) Font used for the QR-Bill. - Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **types.language** [`Language`](#type-alias-typeslanguage) The language with which the bill is rendered. `optional` + const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + ``` +- **types.language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **types.outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **types.scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` - **types.separate** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the text `Separate before paying in` `optional` @@ -868,16 +824,56 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L137C0) #### Interface: types.SVGOptions -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L148C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L150C0) -- **types.fontName** [`FontName`](#type-alias-typesfontname) Font used for the QR-Bill. +- **types.fontName** `"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` Font used for the QR-Bill. Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **types.language** [`Language`](#type-alias-typeslanguage) The language with which the bill is rendered. `optional` + + *Example:* + + ```ts + // Register the font + pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); + + const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + ``` +- **types.language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **types.outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **types.scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional`
+#### Type alias: types.Language + +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L154C0) + +##### Type + +`"DE"` | `"EN"` | `"FR"` | `"IT"` + +
+ +#### Type alias: types.FontName + +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L155C0) + +##### Type + +`"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` + +
+ +#### Type alias: types.Currency + +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L156C0) + +##### Type + +`"CHF"` | `"EUR"` + +
+ ### Namespace: utils Defined in: [src/bundle/index.ts](../../src/bundle/index.ts#L5C7) diff --git a/docs/pdf/types.md b/docs/pdf/types.md index dcb3210..6af894d 100644 --- a/docs/pdf/types.md +++ b/docs/pdf/types.md @@ -5,14 +5,12 @@ - Type aliases - - [Currency](#type-alias-currency) - - [Size](#type-alias-size) - [Language](#type-alias-language) - [FontName](#type-alias-fontname) + - [Currency](#type-alias-currency) - [Data](#interface-data) - [Debtor](#interface-debtor) - [Creditor](#interface-creditor) - - [QRBillOptions](#interface-qrbilloptions) - [PDFOptions](#interface-pdfoptions) - [SVGOptions](#interface-svgoptions) @@ -20,52 +18,42 @@ ## Type aliases -### Type alias: Currency - -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L2C0) - -#### Type - -`"CHF"` | `"EUR"` - -
- -### Type alias: Size +### Type alias: Language -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L3C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L154C0) #### Type -`"A4"` | `"A6"` | `"A6/5"` +`"DE"` | `"EN"` | `"FR"` | `"IT"`
-### Type alias: Language +### Type alias: FontName -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L4C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L155C0) #### Type -`"DE"` | `"EN"` | `"FR"` | `"IT"` +`"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"`
-### Type alias: FontName +### Type alias: Currency -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L5C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L156C0) #### Type -`"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` +`"CHF"` | `"EUR"`
### Interface: Data -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L7C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L1C0) - **creditor** [`Creditor`](#interface-creditor) Creditor related data. -- **currency** [`Currency`](#type-alias-currency) The currency to be used. **3 characters.** +- **currency** `"CHF"` | `"EUR"` The currency to be used. **3 characters.** - **additionalInformation** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Additional information. **Max 140 characters.** Bill information contain coded information for automated booking of the payment. The data is not forwarded with the payment. `optional` @@ -89,7 +77,7 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L7C0) ### Interface: Debtor -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L66C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L60C0) - **address** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Address. **Max 70 characters.** - **city** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) City. **Max 35 characters.** @@ -102,7 +90,7 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L66C0) ### Interface: Creditor -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L99C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L93C0) - **address** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Address. **Max 70 characters.** - **city** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) City. **Max 35 characters.** @@ -114,25 +102,23 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L99C0)
-### Interface: QRBillOptions +### Interface: PDFOptions -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L107C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L139C0) -- **fontName** [`FontName`](#type-alias-fontname) Font used for the QR-Bill. +- **fontName** `"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` Font used for the QR-Bill. Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **language** [`Language`](#type-alias-language) The language with which the bill is rendered. `optional` -- **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` -- **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` -
- -### Interface: PDFOptions + *Example:* -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L137C0) + ```ts + // Register the font + pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); -- **fontName** [`FontName`](#type-alias-fontname) Font used for the QR-Bill. - Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **language** [`Language`](#type-alias-language) The language with which the bill is rendered. `optional` + const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + ``` +- **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` - **separate** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the text `Separate before paying in` `optional` @@ -141,10 +127,20 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L137C0) ### Interface: SVGOptions -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L148C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L150C0) -- **fontName** [`FontName`](#type-alias-fontname) Font used for the QR-Bill. +- **fontName** `"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` Font used for the QR-Bill. Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **language** [`Language`](#type-alias-language) The language with which the bill is rendered. `optional` + + *Example:* + + ```ts + // Register the font + pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); + + const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + ``` +- **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` diff --git a/docs/svg/types.md b/docs/svg/types.md index dcb3210..6af894d 100644 --- a/docs/svg/types.md +++ b/docs/svg/types.md @@ -5,14 +5,12 @@ - Type aliases - - [Currency](#type-alias-currency) - - [Size](#type-alias-size) - [Language](#type-alias-language) - [FontName](#type-alias-fontname) + - [Currency](#type-alias-currency) - [Data](#interface-data) - [Debtor](#interface-debtor) - [Creditor](#interface-creditor) - - [QRBillOptions](#interface-qrbilloptions) - [PDFOptions](#interface-pdfoptions) - [SVGOptions](#interface-svgoptions) @@ -20,52 +18,42 @@ ## Type aliases -### Type alias: Currency - -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L2C0) - -#### Type - -`"CHF"` | `"EUR"` - -
- -### Type alias: Size +### Type alias: Language -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L3C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L154C0) #### Type -`"A4"` | `"A6"` | `"A6/5"` +`"DE"` | `"EN"` | `"FR"` | `"IT"`
-### Type alias: Language +### Type alias: FontName -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L4C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L155C0) #### Type -`"DE"` | `"EN"` | `"FR"` | `"IT"` +`"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"`
-### Type alias: FontName +### Type alias: Currency -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L5C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L156C0) #### Type -`"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` +`"CHF"` | `"EUR"`
### Interface: Data -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L7C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L1C0) - **creditor** [`Creditor`](#interface-creditor) Creditor related data. -- **currency** [`Currency`](#type-alias-currency) The currency to be used. **3 characters.** +- **currency** `"CHF"` | `"EUR"` The currency to be used. **3 characters.** - **additionalInformation** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Additional information. **Max 140 characters.** Bill information contain coded information for automated booking of the payment. The data is not forwarded with the payment. `optional` @@ -89,7 +77,7 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L7C0) ### Interface: Debtor -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L66C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L60C0) - **address** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Address. **Max 70 characters.** - **city** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) City. **Max 35 characters.** @@ -102,7 +90,7 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L66C0) ### Interface: Creditor -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L99C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L93C0) - **address** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) Address. **Max 70 characters.** - **city** [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) City. **Max 35 characters.** @@ -114,25 +102,23 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L99C0)
-### Interface: QRBillOptions +### Interface: PDFOptions -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L107C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L139C0) -- **fontName** [`FontName`](#type-alias-fontname) Font used for the QR-Bill. +- **fontName** `"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` Font used for the QR-Bill. Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **language** [`Language`](#type-alias-language) The language with which the bill is rendered. `optional` -- **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` -- **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` -
- -### Interface: PDFOptions + *Example:* -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L137C0) + ```ts + // Register the font + pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); -- **fontName** [`FontName`](#type-alias-fontname) Font used for the QR-Bill. - Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **language** [`Language`](#type-alias-language) The language with which the bill is rendered. `optional` + const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + ``` +- **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` - **separate** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the text `Separate before paying in` `optional` @@ -141,10 +127,20 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L137C0) ### Interface: SVGOptions -Defined in: [src/shared/types.ts](../../src/shared/types.ts#L148C0) +Defined in: [src/shared/types.ts](../../src/shared/types.ts#L150C0) -- **fontName** [`FontName`](#type-alias-fontname) Font used for the QR-Bill. +- **fontName** `"Arial"` | `"Frutiger"` | `"Helvetica"` | `"Liberation Sans"` Font used for the QR-Bill. Fonts other than Helvetica must be registered in the PDFKit document. [http://pdfkit.org/docs/text.html#fonts](http://pdfkit.org/docs/text.html#fonts) `optional` -- **language** [`Language`](#type-alias-language) The language with which the bill is rendered. `optional` + + *Example:* + + ```ts + // Register the font + pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); + + const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + ``` +- **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` diff --git a/src/shared/types.ts b/src/shared/types.ts index 36c6d33..4417913 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -1,9 +1,3 @@ -// SwissQRBill types -export type Currency = "CHF" | "EUR"; -export type Size = "A4" | "A6" | "A6/5"; -export type Language = "DE" | "EN" | "FR" | "IT"; -export type FontName = "Arial" | "Frutiger" | "Helvetica" | "Liberation Sans"; - export interface Data { /** @@ -14,7 +8,7 @@ export interface Data { /** * The currency to be used. **3 characters.** */ - currency: Currency; + currency: "CHF" | "EUR"; /** * Additional information. **Max 140 characters.** @@ -104,20 +98,28 @@ export interface Creditor extends Debtor { account: string; } -export interface QRBillOptions { +interface QRBillOptions { /** * Font used for the QR-Bill. * Fonts other than Helvetica must be registered in the PDFKit document. {@link http://pdfkit.org/docs/text.html#fonts} * @defaultValue 'Helvetica' + * @example + * ```ts + * // Register the font + * pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); + * pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); + * + * const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); + * ``` */ - fontName?: FontName; + fontName?: "Arial" | "Frutiger" | "Helvetica" | "Liberation Sans"; /** * The language with which the bill is rendered. * @defaultValue `DE` */ - language?: Language; + language?: "DE" | "EN" | "FR" | "IT"; /** * Whether you want render the outlines. This option may be disabled if you use perforated paper. @@ -148,3 +150,7 @@ export interface PDFOptions extends QRBillOptions { export interface SVGOptions extends QRBillOptions { } + +export type Language = Exclude; +export type FontName = Exclude; +export type Currency = Exclude; From 06816abb035e71742f6e47e45edb8e421584aaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Sch=C3=B6nb=C3=A4chler?= <42278642+schoero@users.noreply.github.com> Date: Sat, 11 Nov 2023 11:58:47 +0100 Subject: [PATCH 2/3] chore: update dependencies --- package-lock.json | 31 +++++++++++++++++-------------- package.json | 4 ++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index b89cd43..2ed0af6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "devDependencies": { "@cspell/dict-fr-fr": "^2.2.2", "@cspell/dict-it-it": "^3.1.0", - "@schoero/changelog-config": "^0.0.2", + "@schoero/changelog-config": "^0.0.3", "@schoero/cspell-config": "^1.9.0", "@schoero/eslint-config": "^1.42.0", "@schoero/markdownlint-config": "^1.1.7", @@ -30,7 +30,7 @@ "glob": "^10.3.10", "pdfkit": "^0.14.0", "typescript": "^5.2.2", - "unwritten": "^0.2.4", + "unwritten": "^0.2.5", "vite-plugin-dts": "^3.6.3", "vite-plugin-no-bundle": "^3.0.0", "vitest": "^0.34.6" @@ -1287,9 +1287,9 @@ } }, "node_modules/@microsoft/api-extractor": { - "version": "7.38.2", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.38.2.tgz", - "integrity": "sha512-JOARuhTwOcOMIU0O2czscoJy3ddVzIRhSA9/7T1ALuZSNphgWsPk+Bv4E7AnBDmTV4pP4lBNLtCxEHjjpWaytQ==", + "version": "7.38.3", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.38.3.tgz", + "integrity": "sha512-xt9iYyC5f39281j77JTA9C3ISJpW1XWkCcnw+2vM78CPnro6KhPfwQdPDfwS5JCPNuq0grm8cMdPUOPvrchDWw==", "dev": true, "dependencies": { "@microsoft/api-extractor-model": "7.28.2", @@ -1486,9 +1486,9 @@ } }, "node_modules/@schoero/changelog-config": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@schoero/changelog-config/-/changelog-config-0.0.2.tgz", - "integrity": "sha512-nYqUfJmNkHWxz8l+8rMc7zBnZjwERT0I2/qd5XM82eECDqRLWhv05giBX9g8iLiH5PXYAJhlpq7koxOFjy/p6A==", + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@schoero/changelog-config/-/changelog-config-0.0.3.tgz", + "integrity": "sha512-Zly0rLXnHfGCPDjX+QsF8LBymIvcCHY3gtxz9CYjR1nA59vD8AHvqvIhTeSfdC+cG02Hka3s2vxZTlnJuk1l+Q==", "dev": true, "peerDependencies": { "changelogen": "^0.5.3" @@ -5889,10 +5889,13 @@ } }, "node_modules/lru-cache": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", - "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.2.tgz", + "integrity": "sha512-Yj9mA8fPiVgOUpByoTZO5pNrcl5Yk37FcSHsUINpAsaBIEZIuqcCclDZJCVxqQShDsmYX8QG63svJiTbOATZwg==", "dev": true, + "dependencies": { + "semver": "^7.3.5" + }, "engines": { "node": "14 || >=16.14" } @@ -8315,9 +8318,9 @@ } }, "node_modules/unwritten": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/unwritten/-/unwritten-0.2.4.tgz", - "integrity": "sha512-oExbYkN4QprCiTtz2M2VrSsUBDxrbov5o3VhlmzhKMlAmFS0x6SmnPV8yrYgkHKfOtStJZs1ESMxg9mgnwm97A==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/unwritten/-/unwritten-0.2.5.tgz", + "integrity": "sha512-oLN8zB8Ocx91VBP88y4keMIkCLc2b2i0XXaN+LFyUbQ69XHASTI2H52q5R7g7G0LARseO2gsfKV6Yr7IvLrabw==", "dev": true, "dependencies": { "cac": "^6.7.14", diff --git a/package.json b/package.json index c69e594..a0408a6 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "devDependencies": { "@cspell/dict-fr-fr": "^2.2.2", "@cspell/dict-it-it": "^3.1.0", - "@schoero/changelog-config": "^0.0.2", + "@schoero/changelog-config": "^0.0.3", "@schoero/cspell-config": "^1.9.0", "@schoero/eslint-config": "^1.42.0", "@schoero/markdownlint-config": "^1.1.7", @@ -116,7 +116,7 @@ "glob": "^10.3.10", "pdfkit": "^0.14.0", "typescript": "^5.2.2", - "unwritten": "^0.2.4", + "unwritten": "^0.2.5", "vite-plugin-dts": "^3.6.3", "vite-plugin-no-bundle": "^3.0.0", "vitest": "^0.34.6" From 89d8301e541def5d712b0b06e19dc6b118442798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Sch=C3=B6nb=C3=A4chler?= <42278642+schoero@users.noreply.github.com> Date: Sat, 11 Nov 2023 11:59:21 +0100 Subject: [PATCH 3/3] docs: regenerate docs --- docs/bundle/index.md | 20 +++++++++----------- docs/pdf/index.md | 6 ++---- docs/pdf/types.md | 14 ++++++-------- docs/svg/index.md | 4 +--- docs/svg/types.md | 14 ++++++-------- docs/utils/utils.md | 2 -- 6 files changed, 24 insertions(+), 36 deletions(-) diff --git a/docs/bundle/index.md b/docs/bundle/index.md index 0efbc81..47d5c26 100644 --- a/docs/bundle/index.md +++ b/docs/bundle/index.md @@ -1,8 +1,6 @@ # Index -
- - Namespaces - [pdf](#namespace-pdf) @@ -164,7 +162,7 @@ const stream = createWriteStream("qr-bill.pdf"); qrBill.attachTo(pdf); pdf.pipe(stream); pdf.end(); -``` +```
@@ -512,7 +510,7 @@ const stream = createWriteStream("table.pdf"); table.attachTo(pdf); pdf.pipe(stream); pdf.end(); -``` +```
@@ -603,7 +601,7 @@ const data = { const svg = new SwissQRBill(data); writeFileSync("qr-bill.svg", svg.toString()); -``` +```
@@ -808,13 +806,13 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L139C0) *Example:* - ```ts + ```ts // Register the font pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); - const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); - ``` + ``` + - **types.language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **types.outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **types.scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` @@ -831,13 +829,13 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L150C0) *Example:* - ```ts + ```ts // Register the font pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); - const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); - ``` + ``` + - **types.language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **types.outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **types.scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` diff --git a/docs/pdf/index.md b/docs/pdf/index.md index a7e8a47..4281078 100644 --- a/docs/pdf/index.md +++ b/docs/pdf/index.md @@ -1,8 +1,6 @@ # Index -
- - Classes - [SwissQRBill](#class-swissqrbill) @@ -81,7 +79,7 @@ const stream = createWriteStream("qr-bill.pdf"); qrBill.attachTo(pdf); pdf.pipe(stream); pdf.end(); -``` +```
@@ -282,7 +280,7 @@ const stream = createWriteStream("table.pdf"); table.attachTo(pdf); pdf.pipe(stream); pdf.end(); -``` +```
diff --git a/docs/pdf/types.md b/docs/pdf/types.md index 6af894d..8ef4bb9 100644 --- a/docs/pdf/types.md +++ b/docs/pdf/types.md @@ -1,8 +1,6 @@ # Types -
- - Type aliases - [Language](#type-alias-language) @@ -111,13 +109,13 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L139C0) *Example:* - ```ts + ```ts // Register the font pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); - const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); - ``` + ``` + - **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` @@ -134,13 +132,13 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L150C0) *Example:* - ```ts + ```ts // Register the font pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); - const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); - ``` + ``` + - **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` diff --git a/docs/svg/index.md b/docs/svg/index.md index 10fa967..024cc8d 100644 --- a/docs/svg/index.md +++ b/docs/svg/index.md @@ -1,8 +1,6 @@ # Index -
- - Classes - [SwissQRBill](#class-swissqrbill) @@ -67,7 +65,7 @@ const data = { const svg = new SwissQRBill(data); writeFileSync("qr-bill.svg", svg.toString()); -``` +```
diff --git a/docs/svg/types.md b/docs/svg/types.md index 6af894d..8ef4bb9 100644 --- a/docs/svg/types.md +++ b/docs/svg/types.md @@ -1,8 +1,6 @@ # Types -
- - Type aliases - [Language](#type-alias-language) @@ -111,13 +109,13 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L139C0) *Example:* - ```ts + ```ts // Register the font pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); - const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); - ``` + ``` + - **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` @@ -134,13 +132,13 @@ Defined in: [src/shared/types.ts](../../src/shared/types.ts#L150C0) *Example:* - ```ts + ```ts // Register the font pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf"); pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf"); - const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" }); - ``` + ``` + - **language** `"DE"` | `"EN"` | `"FR"` | `"IT"` The language with which the bill is rendered. `optional` - **outlines** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want render the outlines. This option may be disabled if you use perforated paper. `optional` - **scissors** [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) Whether you want to show the scissors icons or the text `Separate before paying in` `optional` diff --git a/docs/utils/utils.md b/docs/utils/utils.md index de89184..bb833b3 100644 --- a/docs/utils/utils.md +++ b/docs/utils/utils.md @@ -1,8 +1,6 @@ # Utils -
- - Functions - [isQRIBAN(iban)](#function-isqribaniban)