@miguelmorales13/nestkit 0.11.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +619 -35
- package/dist/audit/audit.module.d.ts +23 -0
- package/dist/audit/audit.options.d.ts +16 -0
- package/dist/audit/audit.port.d.ts +37 -0
- package/dist/audit/audit.service.d.ts +29 -0
- package/dist/audit/index.cjs +72 -0
- package/dist/audit/index.d.ts +7 -0
- package/dist/audit/index.js +72 -0
- package/dist/audit/sinks.d.ts +18 -0
- package/dist/auth/index.cjs +12 -10
- package/dist/auth/index.js +5 -3
- package/dist/auth/oauth/http.d.ts +10 -3
- package/dist/auth/oauth/index.cjs +189 -29
- package/dist/auth/oauth/index.d.ts +6 -4
- package/dist/auth/oauth/index.js +169 -9
- package/dist/auth/oauth/magic-link.dto.d.ts +6 -0
- package/dist/auth/oauth/memory-magic-link.store.d.ts +19 -0
- package/dist/auth/oauth/oauth-auth.service.d.ts +46 -5
- package/dist/auth/oauth/oauth.controller.d.ts +5 -1
- package/dist/auth/oauth/oauth.options.d.ts +34 -1
- package/dist/auth/oauth/oauth.ports.d.ts +38 -0
- package/dist/bootstrap/index.cjs +9 -6
- package/dist/bootstrap/index.js +8 -5
- package/dist/{chunk-TJHRABML.cjs → chunk-3AUOOEQO.cjs} +12 -7
- package/dist/{chunk-NVCI3CQI.cjs → chunk-4HHZFOVC.cjs} +10 -5
- package/dist/{chunk-EYURGACO.js → chunk-4PFAKLT3.js} +1 -1
- package/dist/chunk-52IOOHNX.cjs +205 -0
- package/dist/chunk-6RAPVLJM.js +212 -0
- package/dist/{chunk-7I2Y7V52.js → chunk-A2DGK4ZL.js} +26 -3
- package/dist/chunk-APUFKA4K.cjs +212 -0
- package/dist/chunk-AXMW5JF7.cjs +83 -0
- package/dist/{chunk-KDAA6GFF.js → chunk-DYHSOULW.js} +12 -7
- package/dist/chunk-ETRUVZTJ.js +43 -0
- package/dist/{chunk-54ZXIB5T.cjs → chunk-FNUZGYUF.cjs} +4 -4
- package/dist/{chunk-FDNGAYTZ.cjs → chunk-HDFPSA2V.cjs} +6 -6
- package/dist/{chunk-V2M75FN3.cjs → chunk-HVHYZXBB.cjs} +2 -2
- package/dist/chunk-IFNYRZP2.js +205 -0
- package/dist/{chunk-A3B2EY4V.js → chunk-IKXSVEJ7.js} +7 -2
- package/dist/{chunk-YFYHLYHN.js → chunk-M3GQDRWR.js} +7 -1
- package/dist/{chunk-J7TURDAL.cjs → chunk-MSTXS3MU.cjs} +28 -5
- package/dist/chunk-PNK5WMPP.cjs +30 -0
- package/dist/chunk-Q5Y33L7B.cjs +19 -0
- package/dist/{chunk-ZA56XBCK.cjs → chunk-SDWHKPXI.cjs} +23 -0
- package/dist/chunk-TCAMLNUZ.js +27 -0
- package/dist/{chunk-AOCF5QCZ.js → chunk-UNEVXCFW.js} +2 -2
- package/dist/chunk-VVMRZEIW.js +30 -0
- package/dist/chunk-W2T2VFLC.cjs +57 -0
- package/dist/chunk-X4PQJZ4G.js +83 -0
- package/dist/chunk-Y72D5L6I.cjs +27 -0
- package/dist/{chunk-ORWJ7LES.js → chunk-ZFIDAX7K.js} +1 -1
- package/dist/chunk-ZJMLEP5H.js +57 -0
- package/dist/crud/crud.controller.d.ts +3 -1
- package/dist/crud/crud.service.d.ts +63 -4
- package/dist/crud/index.cjs +7 -2
- package/dist/crud/index.d.ts +2 -1
- package/dist/crud/index.js +6 -1
- package/dist/crud/list-query.dto.d.ts +23 -0
- package/dist/crud/repository.port.d.ts +33 -1
- package/dist/errors/app.exception.d.ts +9 -1
- package/dist/errors/common.exceptions.d.ts +6 -5
- package/dist/errors/global-exception.filter.d.ts +9 -0
- package/dist/errors/index.cjs +8 -5
- package/dist/errors/index.js +9 -6
- package/dist/i18n/i18n.interceptor.d.ts +16 -0
- package/dist/i18n/i18n.module.d.ts +49 -3
- package/dist/i18n/index.cjs +26 -2
- package/dist/i18n/index.d.ts +8 -0
- package/dist/i18n/index.js +25 -1
- package/dist/i18n/locale.d.ts +53 -0
- package/dist/i18n/message.d.ts +36 -0
- package/dist/i18n/nestjs-i18n.translator.d.ts +9 -0
- package/dist/i18n/runtime.d.ts +55 -0
- package/dist/i18n/translator.port.d.ts +29 -0
- package/dist/idempotency/idempotency.interceptor.d.ts +35 -0
- package/dist/idempotency/idempotency.module.d.ts +27 -0
- package/dist/idempotency/idempotency.options.d.ts +29 -0
- package/dist/idempotency/idempotency.port.d.ts +43 -0
- package/dist/idempotency/index.cjs +207 -0
- package/dist/idempotency/index.d.ts +7 -0
- package/dist/idempotency/index.js +207 -0
- package/dist/idempotency/memory.store.d.ts +24 -0
- package/dist/index.cjs +48 -15
- package/dist/index.js +51 -18
- package/dist/invoicing/adapters/facturama.invoicing.d.ts +50 -0
- package/dist/invoicing/adapters/facturapi.invoicing.d.ts +35 -0
- package/dist/invoicing/amounts.d.ts +52 -0
- package/dist/invoicing/index.cjs +578 -0
- package/dist/invoicing/index.d.ts +11 -0
- package/dist/invoicing/index.js +578 -0
- package/dist/invoicing/invoicing.module.d.ts +42 -0
- package/dist/invoicing/invoicing.options.d.ts +51 -0
- package/dist/invoicing/invoicing.port.d.ts +156 -0
- package/dist/invoicing/lines.d.ts +21 -0
- package/dist/invoicing/provider-http.d.ts +21 -0
- package/dist/payments/adapters/clip.terminal.d.ts +101 -0
- package/dist/payments/adapters/mercadopago.terminal.d.ts +74 -0
- package/dist/payments/index.cjs +796 -0
- package/dist/payments/index.d.ts +12 -0
- package/dist/payments/index.js +796 -0
- package/dist/payments/money.d.ts +20 -0
- package/dist/payments/payments-webhook.controller.d.ts +30 -0
- package/dist/payments/payments.module.d.ts +45 -0
- package/dist/payments/payments.options.d.ts +84 -0
- package/dist/payments/payments.port.d.ts +174 -0
- package/dist/payments/provider-http.d.ts +26 -0
- package/dist/response/api-response.d.ts +7 -0
- package/dist/response/index.cjs +12 -4
- package/dist/response/index.d.ts +2 -0
- package/dist/response/index.js +12 -4
- package/dist/response/paginated.d.ts +25 -0
- package/dist/response/response.interceptor.d.ts +4 -0
- package/dist/stripe/index.cjs +4 -3
- package/dist/stripe/index.js +3 -2
- package/dist/tracking/index.cjs +3 -3
- package/dist/tracking/index.d.ts +1 -1
- package/dist/tracking/index.js +2 -2
- package/dist/tracking/request-context.d.ts +32 -0
- package/package.json +25 -3
- package/dist/chunk-3CLYZC3T.cjs +0 -104
- package/dist/chunk-EBO6UKHL.js +0 -20
- package/dist/chunk-IYUUYCP5.js +0 -36
- package/dist/chunk-JOVBJDJ2.js +0 -104
- package/dist/chunk-M3EL5O6T.cjs +0 -36
- package/dist/chunk-R7BVS6CI.cjs +0 -13
- /package/dist/{chunk-MR2IFCZE.cjs → chunk-H2EHN366.cjs} +0 -0
- /package/dist/{chunk-NAK4WDKS.js → chunk-ODPSIFOB.js} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { FacturamaOptions } from '../invoicing.options.js';
|
|
2
|
+
import type { CancelMotive, Invoice, InvoiceDraft, InvoicingPort } from '../invoicing.port.js';
|
|
3
|
+
/**
|
|
4
|
+
* Facturama, over its API Web (single issuer).
|
|
5
|
+
*
|
|
6
|
+
* Two differences from Facturapi that shape this adapter:
|
|
7
|
+
*
|
|
8
|
+
* - **The environment is the host**, not the key: the sandbox is a different
|
|
9
|
+
* base URL with its own credentials. The default here is the sandbox, so
|
|
10
|
+
* forgetting to configure it cannot produce a real invoice.
|
|
11
|
+
* - **It prints the numbers it is given.** Subtotal, tax base, tax amount and
|
|
12
|
+
* total all travel on the request, and the SAT validates that they add up —
|
|
13
|
+
* which is exactly why the arithmetic lives in the port and not in each
|
|
14
|
+
* adapter.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FacturamaInvoicing implements InvoicingPort {
|
|
17
|
+
private readonly options;
|
|
18
|
+
readonly provider = "facturama";
|
|
19
|
+
private readonly baseUrl;
|
|
20
|
+
private readonly fetchImpl;
|
|
21
|
+
private readonly token;
|
|
22
|
+
private readonly documentType;
|
|
23
|
+
constructor(options: FacturamaOptions);
|
|
24
|
+
/** True while this adapter points at the sandbox host. */
|
|
25
|
+
get isSandbox(): boolean;
|
|
26
|
+
private headers;
|
|
27
|
+
issue(draft: InvoiceDraft): Promise<Invoice>;
|
|
28
|
+
get(id: string): Promise<Invoice>;
|
|
29
|
+
/**
|
|
30
|
+
* Cancels with a motive.
|
|
31
|
+
*
|
|
32
|
+
* Facturama documents this route twice — once with the parameters in the path
|
|
33
|
+
* and once, in its how-to guide, with them in the query string. The guide's
|
|
34
|
+
* form is the one with a working example next to it, so it is the one used
|
|
35
|
+
* here.
|
|
36
|
+
*/
|
|
37
|
+
cancel(id: string, options: {
|
|
38
|
+
motive: CancelMotive;
|
|
39
|
+
substitutionId?: string;
|
|
40
|
+
}): Promise<Invoice>;
|
|
41
|
+
pdf(id: string): Promise<Uint8Array>;
|
|
42
|
+
xml(id: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Facturama hands files back as base64 inside a JSON envelope rather than as
|
|
45
|
+
* bytes, so this decodes rather than streams.
|
|
46
|
+
*/
|
|
47
|
+
private download;
|
|
48
|
+
sendByEmail(_id: string, _to?: string): Promise<void>;
|
|
49
|
+
private toInvoice;
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FacturapiOptions } from '../invoicing.options.js';
|
|
2
|
+
import type { CancelMotive, Invoice, InvoiceDraft, InvoicingPort } from '../invoicing.port.js';
|
|
3
|
+
/**
|
|
4
|
+
* Facturapi.
|
|
5
|
+
*
|
|
6
|
+
* It builds, signs and stamps from JSON, so nothing here touches XML or a CSD.
|
|
7
|
+
* The environment is decided by the key alone (`sk_test_` vs `sk_live_`), which
|
|
8
|
+
* is convenient and dangerous in equal measure: the same code against the same
|
|
9
|
+
* URL either validates a draft or issues a document with fiscal effects.
|
|
10
|
+
*
|
|
11
|
+
* Line amounts are recomputed on their side from the unit price, so what the
|
|
12
|
+
* port computes is not what ends up on this invoice — it is still computed,
|
|
13
|
+
* because the same draft has to produce the same document on a PAC that does
|
|
14
|
+
* not recompute.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FacturapiInvoicing implements InvoicingPort {
|
|
17
|
+
private readonly options;
|
|
18
|
+
readonly provider = "facturapi";
|
|
19
|
+
private readonly baseUrl;
|
|
20
|
+
private readonly fetchImpl;
|
|
21
|
+
constructor(options: FacturapiOptions);
|
|
22
|
+
/** True when the configured key cannot produce a document with fiscal effects. */
|
|
23
|
+
get isTestKey(): boolean;
|
|
24
|
+
private headers;
|
|
25
|
+
issue(draft: InvoiceDraft): Promise<Invoice>;
|
|
26
|
+
get(id: string): Promise<Invoice>;
|
|
27
|
+
cancel(id: string, options: {
|
|
28
|
+
motive: CancelMotive;
|
|
29
|
+
substitutionId?: string;
|
|
30
|
+
}): Promise<Invoice>;
|
|
31
|
+
pdf(id: string): Promise<Uint8Array>;
|
|
32
|
+
xml(id: string): Promise<string>;
|
|
33
|
+
sendByEmail(id: string, to?: string): Promise<void>;
|
|
34
|
+
private toInvoice;
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CFDI arithmetic, done once here so both adapters put the same numbers on the
|
|
3
|
+
* invoice.
|
|
4
|
+
*
|
|
5
|
+
* This is not the same problem as `payments/money.ts`, which only formats an
|
|
6
|
+
* amount someone already decided. Here the amounts are *derived* — importe from
|
|
7
|
+
* price and quantity, tax from importe, total from both — and the SAT checks
|
|
8
|
+
* that the derivation holds. Facturapi recomputes everything from the unit
|
|
9
|
+
* price and would forgive us; Facturama puts our numbers straight on the
|
|
10
|
+
* document, so if they do not add up the stamp is rejected, or worse, accepted
|
|
11
|
+
* wrong.
|
|
12
|
+
*
|
|
13
|
+
* Everything is integer cents until the last step. The rounding rule is
|
|
14
|
+
* half-up on the absolute value, which is what the SAT's own validation
|
|
15
|
+
* assumes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function roundHalfUp(value: number): number;
|
|
18
|
+
export declare function assertCents(cents: number, field: string): void;
|
|
19
|
+
/** `2450` -> `"24.50"`. Two decimals, which is what every money field on a MXN CFDI carries. */
|
|
20
|
+
export declare function centsToDecimal(cents: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Reads a decimal back into cents. Accepts what the providers send: a string
|
|
23
|
+
* (`"24.50"`) or a JSON number.
|
|
24
|
+
*/
|
|
25
|
+
export declare function decimalToCents(value: string | number): number;
|
|
26
|
+
/**
|
|
27
|
+
* A unit price with more than two decimals, kept exactly as written.
|
|
28
|
+
*
|
|
29
|
+
* The SAT allows up to six on `ValorUnitario` and there are real prices that
|
|
30
|
+
* need them — anything sold by litre or by kilo. Parsing that into a float to
|
|
31
|
+
* get it back out again is how `12.345678` becomes `12.345677999999999`, so the
|
|
32
|
+
* string is validated and passed through untouched; only the amounts derived
|
|
33
|
+
* from it are computed.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertDecimalString(value: string, field: string): void;
|
|
36
|
+
/** Unit price as cents (the common case) or as an exact decimal string (per-litre pricing). */
|
|
37
|
+
export type UnitPrice = {
|
|
38
|
+
cents: number;
|
|
39
|
+
} | {
|
|
40
|
+
decimal: string;
|
|
41
|
+
};
|
|
42
|
+
export declare function unitPriceToDecimal(price: UnitPrice): string;
|
|
43
|
+
/**
|
|
44
|
+
* `importe` for a line: unit price times quantity, rounded to cents.
|
|
45
|
+
*
|
|
46
|
+
* Quantity can be fractional (1.5 kg), which is where the rounding actually
|
|
47
|
+
* happens. Done on a scaled integer rather than on the decimal, so a price of
|
|
48
|
+
* `0.1` and a quantity of `3` gives 30 cents and not 30.000000000000004.
|
|
49
|
+
*/
|
|
50
|
+
export declare function lineAmountCents(price: UnitPrice, quantity: number): number;
|
|
51
|
+
/** Tax over a base, rounded to cents. `rate` is the SAT's decimal rate: 0.16, 0.08, 0.106666. */
|
|
52
|
+
export declare function taxAmountCents(baseCents: number, rate: number): number;
|