@12-apps/fiscal 1.0.0 → 1.1.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 +152 -7
- package/dist/chunk-27B4HNO6.js +574 -0
- package/dist/chunk-27B4HNO6.js.map +1 -0
- package/dist/chunk-3SDXLSG4.js +24 -0
- package/dist/chunk-3SDXLSG4.js.map +1 -0
- package/dist/chunk-ALABGVPO.js +247 -0
- package/dist/chunk-ALABGVPO.js.map +1 -0
- package/dist/chunk-FOFIN5M7.js +14 -0
- package/dist/chunk-FOFIN5M7.js.map +1 -0
- package/dist/chunk-HQ2NXSTX.js +85 -0
- package/dist/chunk-HQ2NXSTX.js.map +1 -0
- package/dist/chunk-PNTKG3DZ.js +47 -0
- package/dist/chunk-PNTKG3DZ.js.map +1 -0
- package/dist/chunk-RRFKYVLZ.js +192 -0
- package/dist/chunk-RRFKYVLZ.js.map +1 -0
- package/dist/chunk-V5ZQAAJT.js +210 -0
- package/dist/chunk-V5ZQAAJT.js.map +1 -0
- package/dist/chunk-X6MRDUYH.js +21 -0
- package/dist/chunk-X6MRDUYH.js.map +1 -0
- package/dist/chunk-XQGW5HUG.js +30 -0
- package/dist/chunk-XQGW5HUG.js.map +1 -0
- package/dist/context-ChnWR4Kb.d.ts +455 -0
- package/dist/danfe/en-US.d.ts +12 -0
- package/dist/danfe/en-US.js +51 -0
- package/dist/danfe/en-US.js.map +1 -0
- package/dist/danfe/index.d.ts +50 -0
- package/dist/danfe/index.js +18 -0
- package/dist/danfe/index.js.map +1 -0
- package/dist/danfe/pt-BR.d.ts +11 -0
- package/dist/danfe/pt-BR.js +51 -0
- package/dist/danfe/pt-BR.js.map +1 -0
- package/dist/documents/index.d.ts +169 -0
- package/dist/documents/index.js +1228 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/engine/index.d.ts +3 -246
- package/dist/http.d.ts +73 -0
- package/dist/http.js +16 -0
- package/dist/http.js.map +1 -0
- package/dist/issuer/index.d.ts +43 -0
- package/dist/issuer/index.js +131 -0
- package/dist/issuer/index.js.map +1 -0
- package/dist/jobs.d.ts +74 -0
- package/dist/jobs.js +22 -0
- package/dist/jobs.js.map +1 -0
- package/dist/labels-BNvflT0h.d.ts +44 -0
- package/dist/manifest/index.d.ts +30 -16
- package/dist/manifest/index.js +11 -17
- package/dist/manifest/index.js.map +1 -1
- package/dist/manifest/server.d.ts +57 -0
- package/dist/manifest/server.js +25 -0
- package/dist/manifest/server.js.map +1 -0
- package/dist/notifications.d.ts +93 -0
- package/dist/notifications.js +41 -0
- package/dist/notifications.js.map +1 -0
- package/dist/port-DpRFK56U.d.ts +238 -0
- package/dist/sale/index.d.ts +243 -0
- package/dist/sale/index.js +1 -0
- package/dist/sale/index.js.map +1 -0
- package/dist/service-KTjH7AxW.d.ts +139 -0
- package/dist/sidecar/index.d.ts +216 -0
- package/dist/sidecar/index.js +8 -0
- package/dist/sidecar/index.js.map +1 -0
- package/dist/types-B1b8LIWX.d.ts +247 -0
- package/package.json +63 -5
- package/prisma/fiscal.prisma +158 -0
- package/prisma/migrations/20261113220000_fiscal_documents/migration.sql +201 -0
- package/sidecar/.dockerignore +5 -0
- package/sidecar/Dockerfile +68 -0
- package/sidecar/README.md +149 -0
- package/sidecar/composer.json +30 -0
- package/sidecar/composer.lock +2224 -0
- package/sidecar/docker/apache.conf +14 -0
- package/sidecar/docker/icp-brasil.pem +8031 -0
- package/sidecar/docker/mpm.conf +17 -0
- package/sidecar/docker/openssl.cnf +16 -0
- package/sidecar/docker/php.ini +19 -0
- package/sidecar/public/index.php +15 -0
- package/sidecar/schema/sale-for-document.schema.json +401 -0
- package/sidecar/src/ErrorClass.php +31 -0
- package/sidecar/src/Http/Request.php +48 -0
- package/sidecar/src/Http/Response.php +32 -0
- package/sidecar/src/Http/Router.php +59 -0
- package/sidecar/src/Kernel.php +99 -0
- package/sidecar/src/Module.php +31 -0
- package/sidecar/src/Nfe/Classifier.php +89 -0
- package/sidecar/src/Nfe/Credentials.php +52 -0
- package/sidecar/src/Nfe/DocumentMapper.php +383 -0
- package/sidecar/src/Nfe/DocumentSchema.php +39 -0
- package/sidecar/src/Nfe/Input.php +125 -0
- package/sidecar/src/Nfe/Model.php +17 -0
- package/sidecar/src/Nfe/NfeModule.php +62 -0
- package/sidecar/src/Nfe/NfeService.php +504 -0
- package/sidecar/src/Nfe/Sefaz.php +49 -0
- package/sidecar/src/Nfe/SefazReply.php +81 -0
- package/sidecar/src/Nfe/Transport/CurlTransport.php +198 -0
- package/sidecar/src/Nfe/Transport/SoapAdapter.php +57 -0
- package/sidecar/src/Nfe/Transport/Transport.php +20 -0
- package/sidecar/src/Nfe/Transport/TransportFailure.php +42 -0
- package/sidecar/src/RequestLog.php +54 -0
- package/sidecar/src/ServiceError.php +69 -0
- package/src/danfe/en-US.ts +53 -0
- package/src/danfe/index.ts +11 -0
- package/src/danfe/labels.ts +49 -0
- package/src/danfe/pt-BR.ts +52 -0
- package/src/danfe/render.ts +265 -0
- package/src/danfe/xml.ts +45 -0
- package/src/documents/context.ts +260 -0
- package/src/documents/errors.ts +41 -0
- package/src/documents/helpers.ts +128 -0
- package/src/documents/index.ts +39 -0
- package/src/documents/lines.ts +63 -0
- package/src/documents/machine-steps.ts +260 -0
- package/src/documents/machine.ts +128 -0
- package/src/documents/memory.ts +138 -0
- package/src/documents/nfe-proc.ts +51 -0
- package/src/documents/ports.ts +130 -0
- package/src/documents/profile-input.ts +168 -0
- package/src/documents/profile.ts +98 -0
- package/src/documents/service-profile.ts +104 -0
- package/src/documents/service.ts +296 -0
- package/src/documents/settle.ts +121 -0
- package/src/documents/signing.ts +61 -0
- package/src/documents/sql-rows.ts +180 -0
- package/src/documents/sql-store.ts +242 -0
- package/src/documents/sql.ts +18 -0
- package/src/documents/steps.ts +173 -0
- package/src/documents/tests/integration/pglite.ts +73 -0
- package/src/documents/types.ts +193 -0
- package/src/http.ts +264 -0
- package/src/issuer/index.ts +9 -0
- package/src/issuer/port.ts +109 -0
- package/src/issuer/sidecar.ts +171 -0
- package/src/jobs.ts +115 -0
- package/src/manifest/index.ts +25 -16
- package/src/manifest/server.ts +20 -0
- package/src/notifications.ts +120 -0
- package/src/sale/index.ts +8 -0
- package/src/sale/types.ts +292 -0
- package/src/sidecar/index.ts +9 -0
- package/src/sidecar/types.ts +243 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { I as Issuer } from '../port-DpRFK56U.js';
|
|
2
|
+
export { C as CancelBySubstitutionCall, a as CancelCall, b as InutilizeCall, c as IssueCall, d as IssuerFailure, e as IssuerOutcome, L as LookupCall, S as SignContingencyCall, f as SigningMaterial, T as TransmitCall, m as modelPath } from '../port-DpRFK56U.js';
|
|
3
|
+
import '../sale/index.js';
|
|
4
|
+
import '../sidecar/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Issuer adapter over the fiscal service in this package's `sidecar/`
|
|
8
|
+
* folder, speaking exactly its wire contract (`../sidecar/types`). JSON in,
|
|
9
|
+
* JSON out; a non-2xx answer carries `{ error }` and is handed back
|
|
10
|
+
* classified, never thrown.
|
|
11
|
+
*
|
|
12
|
+
* What the service cannot classify because it never answered — the fetch
|
|
13
|
+
* failed, timed out or got something that is not the service's JSON — is
|
|
14
|
+
* `RETRYABLE` with `outcomeUnknown: true`: the call may have reached SEFAZ, so
|
|
15
|
+
* the next attempt is a retry of the SAME call, which the service settles by
|
|
16
|
+
* looking the key up first. The message names the path and the HTTP status,
|
|
17
|
+
* never the request: the request carries the certificate.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** The `fetch` the adapter calls: the global one fits. */
|
|
21
|
+
type SidecarFetch = (url: string, init: {
|
|
22
|
+
method: string;
|
|
23
|
+
headers: Record<string, string>;
|
|
24
|
+
body?: string;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
readonly status: number;
|
|
28
|
+
text(): Promise<string>;
|
|
29
|
+
}>;
|
|
30
|
+
interface SidecarIssuerConfig {
|
|
31
|
+
/** Where the service listens, `http://fiscal-sidecar:8080`. No default. */
|
|
32
|
+
readonly baseUrl: string;
|
|
33
|
+
readonly fetch: SidecarFetch;
|
|
34
|
+
/**
|
|
35
|
+
* How long one call may take, in ms. The service gives SEFAZ its connect
|
|
36
|
+
* timeout plus 20 s and may then look the key up, so this is longer than
|
|
37
|
+
* both; a shorter one turns answered calls into unknown outcomes.
|
|
38
|
+
*/
|
|
39
|
+
readonly timeoutMs: number;
|
|
40
|
+
}
|
|
41
|
+
declare function createSidecarIssuer(config: SidecarIssuerConfig): Issuer;
|
|
42
|
+
|
|
43
|
+
export { Issuer, type SidecarFetch, type SidecarIssuerConfig, createSidecarIssuer };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SIDECAR_ERROR_CLASSES
|
|
3
|
+
} from "../chunk-FOFIN5M7.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "../chunk-7QVYU63E.js";
|
|
7
|
+
|
|
8
|
+
// src/issuer/port.ts
|
|
9
|
+
function modelPath(model) {
|
|
10
|
+
return model === "NFE" ? "nfe" : "nfce";
|
|
11
|
+
}
|
|
12
|
+
__name(modelPath, "modelPath");
|
|
13
|
+
|
|
14
|
+
// src/issuer/sidecar.ts
|
|
15
|
+
function unanswered(message) {
|
|
16
|
+
return {
|
|
17
|
+
class: "RETRYABLE",
|
|
18
|
+
code: null,
|
|
19
|
+
message,
|
|
20
|
+
details: [],
|
|
21
|
+
accessKey: null,
|
|
22
|
+
signedXml: null,
|
|
23
|
+
sefazReply: null,
|
|
24
|
+
outcomeUnknown: true
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
__name(unanswered, "unanswered");
|
|
28
|
+
function isErrorBody(value) {
|
|
29
|
+
if (value === null || typeof value !== "object" || !("error" in value)) return false;
|
|
30
|
+
const error = value.error;
|
|
31
|
+
return error !== null && typeof error === "object" && SIDECAR_ERROR_CLASSES.includes(error.class);
|
|
32
|
+
}
|
|
33
|
+
__name(isErrorBody, "isErrorBody");
|
|
34
|
+
function parse(text) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(text);
|
|
37
|
+
} catch {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
__name(parse, "parse");
|
|
42
|
+
async function post(config, base, path, body) {
|
|
43
|
+
let status;
|
|
44
|
+
let text;
|
|
45
|
+
try {
|
|
46
|
+
const response = await config.fetch(`${base}${path}`, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
49
|
+
body: JSON.stringify(body),
|
|
50
|
+
signal: AbortSignal.timeout(config.timeoutMs)
|
|
51
|
+
});
|
|
52
|
+
status = response.status;
|
|
53
|
+
text = await response.text();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const why = error instanceof Error ? error.name : "unknown";
|
|
56
|
+
return { ok: false, error: unanswered(`POST ${path} got no answer from the fiscal service (${why}).`) };
|
|
57
|
+
}
|
|
58
|
+
const parsed = parse(text);
|
|
59
|
+
if (status >= 200 && status < 300 && parsed !== void 0 && !isErrorBody(parsed)) return { ok: true, answer: parsed };
|
|
60
|
+
if (isErrorBody(parsed)) return { ok: false, error: parsed.error };
|
|
61
|
+
return { ok: false, error: unanswered(`POST ${path} answered HTTP ${status} without the service's error body.`) };
|
|
62
|
+
}
|
|
63
|
+
__name(post, "post");
|
|
64
|
+
function createSidecarIssuer(config) {
|
|
65
|
+
if (typeof config?.baseUrl !== "string" || config.baseUrl === "") throw new TypeError("createSidecarIssuer needs baseUrl.");
|
|
66
|
+
if (typeof config.fetch !== "function") throw new TypeError("createSidecarIssuer needs fetch.");
|
|
67
|
+
if (!Number.isInteger(config.timeoutMs) || config.timeoutMs <= 0) throw new TypeError("createSidecarIssuer needs a positive timeoutMs.");
|
|
68
|
+
let baseEnd = config.baseUrl.length;
|
|
69
|
+
while (baseEnd > 0 && config.baseUrl[baseEnd - 1] === "/") baseEnd -= 1;
|
|
70
|
+
const base = config.baseUrl.slice(0, baseEnd);
|
|
71
|
+
const call = /* @__PURE__ */ __name((path, body) => post(config, base, path, body), "call");
|
|
72
|
+
return {
|
|
73
|
+
issue: /* @__PURE__ */ __name(({ model, environment, signing, document }) => call(`/${modelPath(model)}/issue`, {
|
|
74
|
+
environment,
|
|
75
|
+
certificate: signing.certificate,
|
|
76
|
+
csc: model === "NFCE" ? signing.csc : null,
|
|
77
|
+
document
|
|
78
|
+
}), "issue"),
|
|
79
|
+
signContingency: /* @__PURE__ */ __name(({ environment, signing, document, contingency }) => call("/nfce/sign-contingency", {
|
|
80
|
+
environment,
|
|
81
|
+
certificate: signing.certificate,
|
|
82
|
+
csc: signing.csc,
|
|
83
|
+
document,
|
|
84
|
+
contingency
|
|
85
|
+
}), "signContingency"),
|
|
86
|
+
transmit: /* @__PURE__ */ __name(({ model, environment, signing, signedXml }) => call(`/${modelPath(model)}/transmit`, { environment, certificate: signing.certificate, signedXml }), "transmit"),
|
|
87
|
+
cancel: /* @__PURE__ */ __name(({ model, environment, signing, accessKey, protocol, reason }) => call(`/${modelPath(model)}/cancel`, {
|
|
88
|
+
environment,
|
|
89
|
+
certificate: signing.certificate,
|
|
90
|
+
accessKey,
|
|
91
|
+
protocol,
|
|
92
|
+
reason
|
|
93
|
+
}), "cancel"),
|
|
94
|
+
cancelBySubstitution: /* @__PURE__ */ __name(({ environment, signing, accessKey, protocol, reason, substituteAccessKey }) => call("/nfce/cancel-substitution", {
|
|
95
|
+
environment,
|
|
96
|
+
certificate: signing.certificate,
|
|
97
|
+
accessKey,
|
|
98
|
+
protocol,
|
|
99
|
+
reason,
|
|
100
|
+
substituteAccessKey
|
|
101
|
+
}), "cancelBySubstitution"),
|
|
102
|
+
lookup: /* @__PURE__ */ __name(({ model, environment, signing, accessKey }) => call(`/${modelPath(model)}/lookup`, { environment, certificate: signing.certificate, accessKey }), "lookup"),
|
|
103
|
+
inutilize: /* @__PURE__ */ __name(({ model, environment, signing, uf, cnpj, year, series, from, to, reason }) => call("/inutilize", {
|
|
104
|
+
environment,
|
|
105
|
+
certificate: signing.certificate,
|
|
106
|
+
model: modelPath(model),
|
|
107
|
+
uf,
|
|
108
|
+
cnpj,
|
|
109
|
+
year,
|
|
110
|
+
series,
|
|
111
|
+
from,
|
|
112
|
+
to,
|
|
113
|
+
reason
|
|
114
|
+
}), "inutilize"),
|
|
115
|
+
async health() {
|
|
116
|
+
const response = await config.fetch(`${base}/health`, {
|
|
117
|
+
method: "GET",
|
|
118
|
+
headers: { accept: "application/json" },
|
|
119
|
+
signal: AbortSignal.timeout(config.timeoutMs)
|
|
120
|
+
});
|
|
121
|
+
if (response.status !== 200) throw new Error(`The fiscal service's /health answered HTTP ${response.status}.`);
|
|
122
|
+
return JSON.parse(await response.text());
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
__name(createSidecarIssuer, "createSidecarIssuer");
|
|
127
|
+
export {
|
|
128
|
+
createSidecarIssuer,
|
|
129
|
+
modelPath
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/issuer/port.ts","../../src/issuer/sidecar.ts"],"sourcesContent":["/**\n * The Issuer port: what the document service asks of whoever talks to SEFAZ.\n * The first (and today only) adapter is the fiscal service in this package's\n * `sidecar/` folder (`./sidecar`). A call never throws for a failure the\n * service classified: it answers `{ ok: false, error }` with the service's\n * class (`REJECTED`, `RETRYABLE`, `CONTINGENCY`, `AUTH`, `INVALID`,\n * `INTERNAL`), and the document service maps that onto the state machine.\n *\n * The certificate and the CSC travel with each call (the service is\n * stateless) inside {@link SigningMaterial}, built by the signing identity\n * for this one call and dropped with it.\n */\n\nimport type { FiscalDocumentModel } from \"../documents/types\";\nimport type { SaleForDocument } from \"../sale/types\";\nimport type {\n CancelledDocument,\n ContingencyEntry,\n ContingencySignedDocument,\n Csc,\n InutilizedRange,\n IssuedDocument,\n LookedUpDocument,\n SefazEnvironment,\n SidecarErrorBody,\n SidecarHealth,\n SigningCertificate,\n} from \"../sidecar/types\";\n\n/** What signs one call: the A1 and, for an NFC-e, the CSC. Never stored, never logged. */\nexport interface SigningMaterial {\n readonly certificate: SigningCertificate;\n readonly csc: Csc | null;\n}\n\n/** A failed call, classified. The service's error body, verbatim. */\nexport type IssuerFailure = SidecarErrorBody[\"error\"];\n\nexport type IssuerOutcome<T> = { readonly ok: true; readonly answer: T } | { readonly ok: false; readonly error: IssuerFailure };\n\ninterface Call {\n readonly environment: SefazEnvironment;\n readonly signing: SigningMaterial;\n}\n\nexport interface IssueCall extends Call {\n readonly model: FiscalDocumentModel;\n readonly document: SaleForDocument;\n}\n\nexport interface SignContingencyCall extends Call {\n readonly document: SaleForDocument;\n readonly contingency: ContingencyEntry;\n}\n\nexport interface TransmitCall extends Call {\n readonly model: FiscalDocumentModel;\n readonly signedXml: string;\n}\n\nexport interface CancelCall extends Call {\n readonly model: FiscalDocumentModel;\n readonly accessKey: string;\n readonly protocol: string;\n readonly reason: string;\n}\n\n/** NFC-e only: cancel an online document whose sale was issued again in contingency (event 110112). */\nexport interface CancelBySubstitutionCall extends Call {\n readonly accessKey: string;\n readonly protocol: string;\n readonly reason: string;\n readonly substituteAccessKey: string;\n}\n\nexport interface LookupCall extends Call {\n readonly model: FiscalDocumentModel;\n readonly accessKey: string;\n}\n\nexport interface InutilizeCall extends Call {\n readonly model: FiscalDocumentModel;\n readonly uf: string;\n readonly cnpj: string;\n readonly year: number;\n readonly series: number;\n readonly from: number;\n readonly to: number;\n readonly reason: string;\n}\n\nexport interface Issuer {\n /** Build, sign and transmit. `AUTHORIZED` or `DENIED`. */\n issue(call: IssueCall): Promise<IssuerOutcome<IssuedDocument>>;\n /** NFC-e only: build and sign offline (`tpEmis = 9`); nothing is sent. */\n signContingency(call: SignContingencyCall): Promise<IssuerOutcome<ContingencySignedDocument>>;\n /** Send an already signed XML (a contingency document). */\n transmit(call: TransmitCall): Promise<IssuerOutcome<IssuedDocument>>;\n cancel(call: CancelCall): Promise<IssuerOutcome<CancelledDocument>>;\n cancelBySubstitution(call: CancelBySubstitutionCall): Promise<IssuerOutcome<CancelledDocument>>;\n lookup(call: LookupCall): Promise<IssuerOutcome<LookedUpDocument>>;\n inutilize(call: InutilizeCall): Promise<IssuerOutcome<InutilizedRange>>;\n health(): Promise<SidecarHealth>;\n}\n\n/** The path segment of a model on the service's routes. */\nexport function modelPath(model: FiscalDocumentModel): \"nfe\" | \"nfce\" {\n return model === \"NFE\" ? \"nfe\" : \"nfce\";\n}\n","/**\n * The Issuer adapter over the fiscal service in this package's `sidecar/`\n * folder, speaking exactly its wire contract (`../sidecar/types`). JSON in,\n * JSON out; a non-2xx answer carries `{ error }` and is handed back\n * classified, never thrown.\n *\n * What the service cannot classify because it never answered — the fetch\n * failed, timed out or got something that is not the service's JSON — is\n * `RETRYABLE` with `outcomeUnknown: true`: the call may have reached SEFAZ, so\n * the next attempt is a retry of the SAME call, which the service settles by\n * looking the key up first. The message names the path and the HTTP status,\n * never the request: the request carries the certificate.\n */\n\nimport type {\n CancelBySubstitutionRequest,\n CancelRequest,\n InutilizeRequest,\n IssueRequest,\n LookupRequest,\n SidecarErrorBody,\n SidecarHealth,\n SignContingencyRequest,\n TransmitRequest,\n} from \"../sidecar/types\";\nimport { SIDECAR_ERROR_CLASSES } from \"../sidecar/types\";\nimport { type Issuer, type IssuerFailure, type IssuerOutcome, modelPath } from \"./port\";\n\n/** The `fetch` the adapter calls: the global one fits. */\nexport type SidecarFetch = (url: string, init: { method: string; headers: Record<string, string>; body?: string; signal?: AbortSignal }) => Promise<{\n readonly status: number;\n text(): Promise<string>;\n}>;\n\nexport interface SidecarIssuerConfig {\n /** Where the service listens, `http://fiscal-sidecar:8080`. No default. */\n readonly baseUrl: string;\n readonly fetch: SidecarFetch;\n /**\n * How long one call may take, in ms. The service gives SEFAZ its connect\n * timeout plus 20 s and may then look the key up, so this is longer than\n * both; a shorter one turns answered calls into unknown outcomes.\n */\n readonly timeoutMs: number;\n}\n\nfunction unanswered(message: string): IssuerFailure {\n return {\n class: \"RETRYABLE\",\n code: null,\n message,\n details: [],\n accessKey: null,\n signedXml: null,\n sefazReply: null,\n outcomeUnknown: true,\n };\n}\n\nfunction isErrorBody(value: unknown): value is SidecarErrorBody {\n if (value === null || typeof value !== \"object\" || !(\"error\" in value)) return false;\n const error = (value as { error: unknown }).error;\n return (\n error !== null &&\n typeof error === \"object\" &&\n SIDECAR_ERROR_CLASSES.includes((error as { class: IssuerFailure[\"class\"] }).class)\n );\n}\n\nfunction parse(text: string): unknown {\n try {\n return JSON.parse(text) as unknown;\n } catch {\n return undefined;\n }\n}\n\n/** One POST to the service, its answer classified; never throws. */\nasync function post<T>(config: SidecarIssuerConfig, base: string, path: string, body: unknown): Promise<IssuerOutcome<T>> {\n let status: number;\n let text: string;\n try {\n const response = await config.fetch(`${base}${path}`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\", accept: \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(config.timeoutMs),\n });\n status = response.status;\n text = await response.text();\n } catch (error) {\n const why = error instanceof Error ? error.name : \"unknown\";\n return { ok: false, error: unanswered(`POST ${path} got no answer from the fiscal service (${why}).`) };\n }\n const parsed = parse(text);\n if (status >= 200 && status < 300 && parsed !== undefined && !isErrorBody(parsed)) return { ok: true, answer: parsed as T };\n if (isErrorBody(parsed)) return { ok: false, error: parsed.error };\n return { ok: false, error: unanswered(`POST ${path} answered HTTP ${status} without the service's error body.`) };\n}\n\nexport function createSidecarIssuer(config: SidecarIssuerConfig): Issuer {\n if (typeof config?.baseUrl !== \"string\" || config.baseUrl === \"\") throw new TypeError(\"createSidecarIssuer needs baseUrl.\");\n if (typeof config.fetch !== \"function\") throw new TypeError(\"createSidecarIssuer needs fetch.\");\n if (!Number.isInteger(config.timeoutMs) || config.timeoutMs <= 0) throw new TypeError(\"createSidecarIssuer needs a positive timeoutMs.\");\n let baseEnd = config.baseUrl.length;\n while (baseEnd > 0 && config.baseUrl[baseEnd - 1] === \"/\") baseEnd -= 1;\n const base = config.baseUrl.slice(0, baseEnd);\n\n const call = <T>(path: string, body: unknown) => post<T>(config, base, path, body);\n\n return {\n issue: ({ model, environment, signing, document }) =>\n call(`/${modelPath(model)}/issue`, {\n environment,\n certificate: signing.certificate,\n csc: model === \"NFCE\" ? signing.csc : null,\n document,\n } satisfies IssueRequest),\n signContingency: ({ environment, signing, document, contingency }) =>\n call(\"/nfce/sign-contingency\", {\n environment,\n certificate: signing.certificate,\n csc: signing.csc,\n document,\n contingency,\n } satisfies SignContingencyRequest),\n transmit: ({ model, environment, signing, signedXml }) =>\n call(`/${modelPath(model)}/transmit`, { environment, certificate: signing.certificate, signedXml } satisfies TransmitRequest),\n cancel: ({ model, environment, signing, accessKey, protocol, reason }) =>\n call(`/${modelPath(model)}/cancel`, {\n environment,\n certificate: signing.certificate,\n accessKey,\n protocol,\n reason,\n } satisfies CancelRequest),\n cancelBySubstitution: ({ environment, signing, accessKey, protocol, reason, substituteAccessKey }) =>\n call(\"/nfce/cancel-substitution\", {\n environment,\n certificate: signing.certificate,\n accessKey,\n protocol,\n reason,\n substituteAccessKey,\n } satisfies CancelBySubstitutionRequest),\n lookup: ({ model, environment, signing, accessKey }) =>\n call(`/${modelPath(model)}/lookup`, { environment, certificate: signing.certificate, accessKey } satisfies LookupRequest),\n inutilize: ({ model, environment, signing, uf, cnpj, year, series, from, to, reason }) =>\n call(\"/inutilize\", {\n environment,\n certificate: signing.certificate,\n model: modelPath(model),\n uf,\n cnpj,\n year,\n series,\n from,\n to,\n reason,\n } satisfies InutilizeRequest),\n async health() {\n const response = await config.fetch(`${base}/health`, {\n method: \"GET\",\n headers: { accept: \"application/json\" },\n signal: AbortSignal.timeout(config.timeoutMs),\n });\n if (response.status !== 200) throw new Error(`The fiscal service's /health answered HTTP ${response.status}.`);\n return JSON.parse(await response.text()) as SidecarHealth;\n },\n };\n}\n"],"mappings":";;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
|
package/dist/jobs.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as _12_apps_wiring from '@12-apps/wiring';
|
|
2
|
+
import { F as FiscalStore, a as FiscalNotifyPort } from './context-ChnWR4Kb.js';
|
|
3
|
+
import { F as FiscalDocuments } from './service-KTjH7AxW.js';
|
|
4
|
+
import './port-DpRFK56U.js';
|
|
5
|
+
import './sale/index.js';
|
|
6
|
+
import './sidecar/index.js';
|
|
7
|
+
import './types-B1b8LIWX.js';
|
|
8
|
+
|
|
9
|
+
interface FiscalJobDeps {
|
|
10
|
+
readonly documents: Pick<FiscalDocuments, "sweep" | "transmitContingency">;
|
|
11
|
+
readonly store: Pick<FiscalStore, "listExpiringCertificates">;
|
|
12
|
+
readonly notify: FiscalNotifyPort;
|
|
13
|
+
readonly now: () => Date;
|
|
14
|
+
}
|
|
15
|
+
/** The single-flight lease a sweep or a transmission run holds. */
|
|
16
|
+
declare const FISCAL_JOB_LEASE_MS: number;
|
|
17
|
+
/**
|
|
18
|
+
* The worst one document can cost a run: an issue call and the offline
|
|
19
|
+
* signing after it, each bounded by the issuer's timeout (90 s recommended
|
|
20
|
+
* for the sidecar adapter, whose own SEFAZ call gets 50 s and a lookup).
|
|
21
|
+
*/
|
|
22
|
+
declare const FISCAL_WORST_STEP_MS: number;
|
|
23
|
+
/**
|
|
24
|
+
* At most this many documents per run, derived so that a run of the worst
|
|
25
|
+
* steps still ends inside its lease: a second run can never overlap the
|
|
26
|
+
* first. A backlog drains over several five-minute runs.
|
|
27
|
+
*/
|
|
28
|
+
declare const FISCAL_SWEEP_BATCH: number;
|
|
29
|
+
/** The days before expiry the owner is told; after expiry, every day. */
|
|
30
|
+
declare const CERTIFICATE_WARNING_DAYS: readonly number[];
|
|
31
|
+
/** Whole days from `now` to `expiresAt`, rounded up: 0 is "today", negative is "expired". */
|
|
32
|
+
declare function daysLeft(expiresAt: string, now: Date): number;
|
|
33
|
+
declare const FISCAL_JOBS: {
|
|
34
|
+
namespace: string;
|
|
35
|
+
blueprints: {
|
|
36
|
+
sweep: {
|
|
37
|
+
name: string;
|
|
38
|
+
schedule: {
|
|
39
|
+
pattern: string;
|
|
40
|
+
};
|
|
41
|
+
/** The batch is sized so a run of worst-case steps ends inside this lease. */
|
|
42
|
+
lease: {
|
|
43
|
+
ttlMs: number;
|
|
44
|
+
};
|
|
45
|
+
/** A missed run is caught up by the next tick. */
|
|
46
|
+
attempts: number;
|
|
47
|
+
handle(_payload: never, deps: FiscalJobDeps, context: _12_apps_wiring.WireJobContext): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
transmitContingency: {
|
|
50
|
+
name: string;
|
|
51
|
+
schedule: {
|
|
52
|
+
pattern: string;
|
|
53
|
+
};
|
|
54
|
+
lease: {
|
|
55
|
+
ttlMs: number;
|
|
56
|
+
};
|
|
57
|
+
attempts: number;
|
|
58
|
+
handle(_payload: never, deps: FiscalJobDeps, context: _12_apps_wiring.WireJobContext): Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
certificateExpiry: {
|
|
61
|
+
name: string;
|
|
62
|
+
schedule: {
|
|
63
|
+
pattern: string;
|
|
64
|
+
};
|
|
65
|
+
lease: {
|
|
66
|
+
ttlMs: number;
|
|
67
|
+
};
|
|
68
|
+
attempts: number;
|
|
69
|
+
handle(_payload: never, deps: FiscalJobDeps, context: _12_apps_wiring.WireJobContext): Promise<void>;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { CERTIFICATE_WARNING_DAYS, FISCAL_JOBS, FISCAL_JOB_LEASE_MS, FISCAL_SWEEP_BATCH, FISCAL_WORST_STEP_MS, type FiscalJobDeps, daysLeft };
|
package/dist/jobs.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CERTIFICATE_WARNING_DAYS,
|
|
3
|
+
FISCAL_JOBS,
|
|
4
|
+
FISCAL_JOB_LEASE_MS,
|
|
5
|
+
FISCAL_SWEEP_BATCH,
|
|
6
|
+
FISCAL_WORST_STEP_MS,
|
|
7
|
+
daysLeft
|
|
8
|
+
} from "./chunk-HQ2NXSTX.js";
|
|
9
|
+
import "./chunk-27B4HNO6.js";
|
|
10
|
+
import "./chunk-XQGW5HUG.js";
|
|
11
|
+
import "./chunk-3SDXLSG4.js";
|
|
12
|
+
import "./chunk-X6MRDUYH.js";
|
|
13
|
+
import "./chunk-7QVYU63E.js";
|
|
14
|
+
export {
|
|
15
|
+
CERTIFICATE_WARNING_DAYS,
|
|
16
|
+
FISCAL_JOBS,
|
|
17
|
+
FISCAL_JOB_LEASE_MS,
|
|
18
|
+
FISCAL_SWEEP_BATCH,
|
|
19
|
+
FISCAL_WORST_STEP_MS,
|
|
20
|
+
daysLeft
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=jobs.js.map
|
package/dist/jobs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words a DANFE NFC-e prints. The layout is the Manual do DANFE NFC-e's
|
|
3
|
+
* and the words are the host's language: a host passes them all, or the
|
|
4
|
+
* `./pt-BR` pack, which carries the Manual's own texts. Nothing here defaults.
|
|
5
|
+
*/
|
|
6
|
+
interface DanfeNfceLabels {
|
|
7
|
+
/** Division I. */
|
|
8
|
+
readonly cnpj: string;
|
|
9
|
+
readonly stateRegistration: string;
|
|
10
|
+
/** Division II: the document's own title. */
|
|
11
|
+
readonly title: string;
|
|
12
|
+
/** Division III: the item table's header. */
|
|
13
|
+
readonly itemsHeader: string;
|
|
14
|
+
/** Division IV. */
|
|
15
|
+
readonly itemCount: string;
|
|
16
|
+
readonly totalValue: string;
|
|
17
|
+
readonly discounts: string;
|
|
18
|
+
readonly amountDue: string;
|
|
19
|
+
readonly paymentHeader: string;
|
|
20
|
+
readonly change: string;
|
|
21
|
+
/** `tPag` code (`01`, `17`…) → the method's name; an unknown code prints itself. */
|
|
22
|
+
readonly paymentMethods: Readonly<Record<string, string>>;
|
|
23
|
+
/** Division V. */
|
|
24
|
+
readonly lookupByKey: string;
|
|
25
|
+
readonly homologation: string;
|
|
26
|
+
readonly contingency: string;
|
|
27
|
+
readonly pendingAuthorization: string;
|
|
28
|
+
/** Printed on a paper signed offline and not yet authorised: the one copy, the consumer's. */
|
|
29
|
+
readonly consumerCopy: string;
|
|
30
|
+
/** Division VI. */
|
|
31
|
+
readonly consumer: string;
|
|
32
|
+
readonly unidentifiedConsumer: string;
|
|
33
|
+
/** Division VII. */
|
|
34
|
+
readonly number: string;
|
|
35
|
+
readonly series: string;
|
|
36
|
+
readonly protocol: string;
|
|
37
|
+
readonly authorizedAt: string;
|
|
38
|
+
/** Division VIII and after: the QR code's caption and the approximate tax line (Lei 12.741/2012). */
|
|
39
|
+
readonly qrCaption: string;
|
|
40
|
+
readonly approximateTaxes: string;
|
|
41
|
+
}
|
|
42
|
+
declare const DANFE_LABEL_KEYS: readonly (keyof DanfeNfceLabels)[];
|
|
43
|
+
|
|
44
|
+
export { type DanfeNfceLabels as D, DANFE_LABEL_KEYS as a };
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -32,25 +32,31 @@ declare const FISCAL_PERMISSIONS: {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* `@12-apps/fiscal/manifest` — the SHARED wiring manifest
|
|
36
|
-
*
|
|
37
|
-
* What it declares today is what exists today:
|
|
35
|
+
* `@12-apps/fiscal/manifest` — the SHARED wiring manifest.
|
|
38
36
|
*
|
|
39
37
|
* - `permissions` — `fiscal:read`, `fiscal:manage`, `fiscal:issue`,
|
|
40
|
-
* `fiscal:cancel
|
|
41
|
-
*
|
|
38
|
+
* `fiscal:cancel`, declared here and nowhere else; every route in
|
|
39
|
+
* `../http` names the one it needs.
|
|
40
|
+
* - `db` — the Prisma partial (`prisma/fiscal.prisma`: the emitter profile,
|
|
41
|
+
* issuing points, one number counter per series, documents and their
|
|
42
|
+
* events) and its migrations.
|
|
43
|
+
* - `observability` — `fiscal`: the sweeps log under it.
|
|
44
|
+
* - `server: ["http", "jobs"]` — `./manifest/server`.
|
|
45
|
+
*
|
|
46
|
+
* Narrowings, each argued in `.wiring-conformance.json`:
|
|
42
47
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
48
|
+
* - **No static `notifications`.** The two alerts (certificate expiring,
|
|
49
|
+
* document rejected) are host words, so they ship as the factory
|
|
50
|
+
* `createFiscalNotificationBlueprints(copy)` (`@12-apps/fiscal/notifications`),
|
|
51
|
+
* which the host feeds to its own mount.
|
|
52
|
+
* - **No `web` surface yet.** The fiscal settings screen and the documents
|
|
53
|
+
* list are built with their screen tickets (FUT-2231, FUT-2238) from the
|
|
54
|
+
* owner's approved prototypes, over these routes.
|
|
55
|
+
* - **No NFS-e.** Only the platform's own NFS-e is planned (FUT-2242).
|
|
56
|
+
* - **No register blocks.** An offline register signing on a reserved block of
|
|
57
|
+
* the contingency series, and the voiding of a finished block's known rest,
|
|
58
|
+
* are FUT-4717's; the port is declared (`ContingencyBlockSource`) and not
|
|
59
|
+
* implemented.
|
|
54
60
|
*
|
|
55
61
|
* `@12-apps/wiring` is a TYPE-ONLY dependency: the manifest is a plain
|
|
56
62
|
* `satisfies`-checked value, and the producer's assertions run in this
|
|
@@ -78,6 +84,14 @@ declare const fiscalManifest: {
|
|
|
78
84
|
};
|
|
79
85
|
};
|
|
80
86
|
};
|
|
87
|
+
readonly db: {
|
|
88
|
+
readonly partial: "prisma/fiscal.prisma";
|
|
89
|
+
readonly migrations: "prisma/migrations";
|
|
90
|
+
};
|
|
91
|
+
readonly observability: {
|
|
92
|
+
readonly namespace: "fiscal";
|
|
93
|
+
};
|
|
94
|
+
readonly server: readonly ["http", "jobs"];
|
|
81
95
|
};
|
|
82
96
|
|
|
83
97
|
export { FISCAL_CANCEL, FISCAL_ISSUE, FISCAL_MANAGE, FISCAL_PERMISSIONS, FISCAL_READ, fiscalManifest };
|
package/dist/manifest/index.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FISCAL_CANCEL,
|
|
3
|
+
FISCAL_ISSUE,
|
|
4
|
+
FISCAL_MANAGE,
|
|
5
|
+
FISCAL_PERMISSIONS,
|
|
6
|
+
FISCAL_READ
|
|
7
|
+
} from "../chunk-3SDXLSG4.js";
|
|
1
8
|
import "../chunk-7QVYU63E.js";
|
|
2
9
|
|
|
3
|
-
// src/manifest/permissions.ts
|
|
4
|
-
var FISCAL_READ = "fiscal:read";
|
|
5
|
-
var FISCAL_MANAGE = "fiscal:manage";
|
|
6
|
-
var FISCAL_ISSUE = "fiscal:issue";
|
|
7
|
-
var FISCAL_CANCEL = "fiscal:cancel";
|
|
8
|
-
var FISCAL_PERMISSIONS = {
|
|
9
|
-
source: "@12-apps/fiscal",
|
|
10
|
-
ids: [FISCAL_READ, FISCAL_MANAGE, FISCAL_ISSUE, FISCAL_CANCEL],
|
|
11
|
-
permissions: {
|
|
12
|
-
[FISCAL_READ]: { kind: "class" },
|
|
13
|
-
[FISCAL_MANAGE]: { kind: "class" },
|
|
14
|
-
[FISCAL_ISSUE]: { kind: "class" },
|
|
15
|
-
[FISCAL_CANCEL]: { kind: "class" }
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
10
|
// src/manifest/index.ts
|
|
20
11
|
var fiscalManifest = {
|
|
21
12
|
name: "@12-apps/fiscal",
|
|
22
13
|
contract: 1,
|
|
23
|
-
permissions: FISCAL_PERMISSIONS
|
|
14
|
+
permissions: FISCAL_PERMISSIONS,
|
|
15
|
+
db: { partial: "prisma/fiscal.prisma", migrations: "prisma/migrations" },
|
|
16
|
+
observability: { namespace: "fiscal" },
|
|
17
|
+
server: ["http", "jobs"]
|
|
24
18
|
};
|
|
25
19
|
export {
|
|
26
20
|
FISCAL_CANCEL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/manifest/
|
|
1
|
+
{"version":3,"sources":["../../src/manifest/index.ts"],"sourcesContent":["/**\n * `@12-apps/fiscal/manifest` — the SHARED wiring manifest.\n *\n * - `permissions` — `fiscal:read`, `fiscal:manage`, `fiscal:issue`,\n * `fiscal:cancel`, declared here and nowhere else; every route in\n * `../http` names the one it needs.\n * - `db` — the Prisma partial (`prisma/fiscal.prisma`: the emitter profile,\n * issuing points, one number counter per series, documents and their\n * events) and its migrations.\n * - `observability` — `fiscal`: the sweeps log under it.\n * - `server: [\"http\", \"jobs\"]` — `./manifest/server`.\n *\n * Narrowings, each argued in `.wiring-conformance.json`:\n *\n * - **No static `notifications`.** The two alerts (certificate expiring,\n * document rejected) are host words, so they ship as the factory\n * `createFiscalNotificationBlueprints(copy)` (`@12-apps/fiscal/notifications`),\n * which the host feeds to its own mount.\n * - **No `web` surface yet.** The fiscal settings screen and the documents\n * list are built with their screen tickets (FUT-2231, FUT-2238) from the\n * owner's approved prototypes, over these routes.\n * - **No NFS-e.** Only the platform's own NFS-e is planned (FUT-2242).\n * - **No register blocks.** An offline register signing on a reserved block of\n * the contingency series, and the voiding of a finished block's known rest,\n * are FUT-4717's; the port is declared (`ContingencyBlockSource`) and not\n * implemented.\n *\n * `@12-apps/wiring` is a TYPE-ONLY dependency: the manifest is a plain\n * `satisfies`-checked value, and the producer's assertions run in this\n * package's own test suite.\n */\n\nimport type { PackageManifest } from \"@12-apps/wiring\";\n\nimport { FISCAL_PERMISSIONS } from \"./permissions\";\n\nexport { FISCAL_CANCEL, FISCAL_ISSUE, FISCAL_MANAGE, FISCAL_PERMISSIONS, FISCAL_READ } from \"./permissions\";\n\nexport const fiscalManifest = {\n name: \"@12-apps/fiscal\",\n contract: 1,\n permissions: FISCAL_PERMISSIONS,\n db: { partial: \"prisma/fiscal.prisma\", migrations: \"prisma/migrations\" },\n observability: { namespace: \"fiscal\" },\n server: [\"http\", \"jobs\"],\n} as const satisfies PackageManifest;\n"],"mappings":";;;;;;;;;;AAsCO,IAAM,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,EACb,IAAI,EAAE,SAAS,wBAAwB,YAAY,oBAAoB;AAAA,EACvE,eAAe,EAAE,WAAW,SAAS;AAAA,EACrC,QAAQ,CAAC,QAAQ,MAAM;AACzB;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as _12_apps_wiring from '@12-apps/wiring';
|
|
2
|
+
import { FiscalJobDeps } from '../jobs.js';
|
|
3
|
+
import { createApiFiscal } from '../http.js';
|
|
4
|
+
import '../context-ChnWR4Kb.js';
|
|
5
|
+
import '../port-DpRFK56U.js';
|
|
6
|
+
import '../sale/index.js';
|
|
7
|
+
import '../sidecar/index.js';
|
|
8
|
+
import '../types-B1b8LIWX.js';
|
|
9
|
+
import '../service-KTjH7AxW.js';
|
|
10
|
+
import '../labels-BNvflT0h.js';
|
|
11
|
+
|
|
12
|
+
declare const fiscalServerManifest: {
|
|
13
|
+
readonly name: "@12-apps/fiscal";
|
|
14
|
+
readonly http: {
|
|
15
|
+
readonly create: typeof createApiFiscal;
|
|
16
|
+
};
|
|
17
|
+
readonly jobs: {
|
|
18
|
+
namespace: string;
|
|
19
|
+
blueprints: {
|
|
20
|
+
sweep: {
|
|
21
|
+
name: string;
|
|
22
|
+
schedule: {
|
|
23
|
+
pattern: string;
|
|
24
|
+
};
|
|
25
|
+
lease: {
|
|
26
|
+
ttlMs: number;
|
|
27
|
+
};
|
|
28
|
+
attempts: number;
|
|
29
|
+
handle(_payload: never, deps: FiscalJobDeps, context: _12_apps_wiring.WireJobContext): Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
transmitContingency: {
|
|
32
|
+
name: string;
|
|
33
|
+
schedule: {
|
|
34
|
+
pattern: string;
|
|
35
|
+
};
|
|
36
|
+
lease: {
|
|
37
|
+
ttlMs: number;
|
|
38
|
+
};
|
|
39
|
+
attempts: number;
|
|
40
|
+
handle(_payload: never, deps: FiscalJobDeps, context: _12_apps_wiring.WireJobContext): Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
certificateExpiry: {
|
|
43
|
+
name: string;
|
|
44
|
+
schedule: {
|
|
45
|
+
pattern: string;
|
|
46
|
+
};
|
|
47
|
+
lease: {
|
|
48
|
+
ttlMs: number;
|
|
49
|
+
};
|
|
50
|
+
attempts: number;
|
|
51
|
+
handle(_payload: never, deps: FiscalJobDeps, context: _12_apps_wiring.WireJobContext): Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { fiscalServerManifest };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createApiFiscal
|
|
3
|
+
} from "../chunk-V5ZQAAJT.js";
|
|
4
|
+
import "../chunk-ALABGVPO.js";
|
|
5
|
+
import "../chunk-RRFKYVLZ.js";
|
|
6
|
+
import "../chunk-PNTKG3DZ.js";
|
|
7
|
+
import {
|
|
8
|
+
FISCAL_JOBS
|
|
9
|
+
} from "../chunk-HQ2NXSTX.js";
|
|
10
|
+
import "../chunk-27B4HNO6.js";
|
|
11
|
+
import "../chunk-XQGW5HUG.js";
|
|
12
|
+
import "../chunk-3SDXLSG4.js";
|
|
13
|
+
import "../chunk-X6MRDUYH.js";
|
|
14
|
+
import "../chunk-7QVYU63E.js";
|
|
15
|
+
|
|
16
|
+
// src/manifest/server.ts
|
|
17
|
+
var fiscalServerManifest = {
|
|
18
|
+
name: "@12-apps/fiscal",
|
|
19
|
+
http: { create: createApiFiscal },
|
|
20
|
+
jobs: FISCAL_JOBS
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
fiscalServerManifest
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/manifest/server.ts"],"sourcesContent":["/**\n * `@12-apps/fiscal/manifest/server` — the server capabilities.\n *\n * `http.create` IS `createApiFiscal` (`../http`): profile, certificate upload,\n * issuing points, issue, cancel, look up and the DANFE, each route declaring\n * the package permission it needs. `jobs` is `FISCAL_JOBS` (`../jobs`): the\n * retry sweep, the contingency transmission and the certificate-expiry\n * warning. A host binds both or declines each in writing.\n */\n\nimport type { AnyServerManifest } from \"@12-apps/wiring\";\n\nimport { createApiFiscal } from \"../http\";\nimport { FISCAL_JOBS } from \"../jobs\";\n\nexport const fiscalServerManifest = {\n name: \"@12-apps/fiscal\",\n http: { create: createApiFiscal },\n jobs: FISCAL_JOBS,\n} as const satisfies AnyServerManifest;\n"],"mappings":";;;;;;;;;;;;;;;;AAeO,IAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,MAAM,EAAE,QAAQ,gBAAgB;AAAA,EAChC,MAAM;AACR;","names":[]}
|