@voyantjs/plugin-smartbill 0.77.12 → 0.78.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 CHANGED
@@ -75,6 +75,37 @@ deduplication elsewhere. Create failures are recorded as SmartBill external refs
75
75
  with `status: "error"` and `syncError`; `onError(event, error)` can be supplied
76
76
  for application-specific reporting.
77
77
 
78
+ Use `syncSmartbillInvoice({ db, invoiceId, pluginOptions })` to run the same
79
+ create-or-retry flow from an admin action. It loads the finance invoice,
80
+ booking, line items, and tax metadata, maps them through the configured
81
+ SmartBill options, reuses an existing non-error SmartBill ref when present, and
82
+ persists external refs/PDF artifacts through the configured artifact runtime.
83
+
84
+ Apps that use `@voyantjs/hono` can mount the packaged admin module:
85
+
86
+ ```typescript
87
+ import { createSmartbillAdminModule } from "@voyantjs/plugin-smartbill/hono"
88
+
89
+ const app = createApp({
90
+ plugins: [smartbillSync],
91
+ modules: [
92
+ createSmartbillAdminModule({
93
+ pluginOptions: {
94
+ username: env.SMARTBILL_USERNAME,
95
+ apiToken: env.SMARTBILL_API_TOKEN,
96
+ companyVatCode: "RO12345678",
97
+ seriesName: "A",
98
+ artifacts: { documentStorage },
99
+ },
100
+ }),
101
+ ],
102
+ })
103
+ ```
104
+
105
+ The admin module mounts `POST /v1/admin/smartbill/invoices/:id/sync`. The route
106
+ uses the request database for external-ref and artifact persistence unless
107
+ `pluginOptions.artifacts.db` supplies a custom database resolver.
108
+
78
109
  Use `retrySmartbillInvoiceArtifact({ runtime, client, externalRef, documentType
79
110
  })` to re-download and re-attach a SmartBill PDF from an existing external ref
80
111
  without issuing a new document.
@@ -96,15 +127,7 @@ export function InvoicePage({ invoiceId }: { invoiceId: string }) {
96
127
  id={invoiceId}
97
128
  slots={{
98
129
  integrationsContent: ({ invoice }) => (
99
- <SmartbillInvoicePanel
100
- invoiceId={invoice.id}
101
- sendAction={{
102
- onClick: () => requestSmartbillSend(invoice.id),
103
- }}
104
- retryAction={{
105
- onClick: () => requestSmartbillRetry(invoice.id),
106
- }}
107
- />
130
+ <SmartbillInvoicePanel invoiceId={invoice.id} />
108
131
  ),
109
132
  }}
110
133
  />
@@ -114,9 +137,11 @@ export function InvoicePage({ invoiceId }: { invoiceId: string }) {
114
137
 
115
138
  `SmartbillInvoicePanel` displays the SmartBill series, number, document type,
116
139
  sync status, sync errors, and document/PDF links when the external ref contains
117
- them. Hosts provide action callbacks such as send, retry, or proforma
118
- conversion because route shape and permissions remain app-owned. For custom
119
- layouts, use `useSmartbillInvoiceRef(invoiceId)` together with
140
+ them. By default, send and retry actions call
141
+ `POST /v1/admin/smartbill/invoices/:id/sync`, and proforma conversion calls the
142
+ finance `POST /v1/finance/invoices/:id/convert-to-invoice` endpoint. Pass
143
+ `sendAction`, `retryAction`, or `convertProformaAction` to override those
144
+ defaults. For custom layouts, use `useSmartbillInvoiceRef(invoiceId)` together with
120
145
  `resolveSmartbillInvoiceReferenceParts(ref)` and
121
146
  `getSmartbillInvoiceDocumentLinks(ref)`.
122
147
 
@@ -167,6 +192,8 @@ finance records.
167
192
  | `.` | Barrel re-exports |
168
193
  | `./plugin` | `smartbillPlugin(options)` — packaged adapter/subscriber bundle |
169
194
  | `./client` | `createSmartbillClient` — `createInvoice`, `cancelInvoice`, `viewPdf`, `getPaymentStatus`, etc. |
195
+ | `./hono` | `createSmartbillAdminModule(options)` and admin sync routes |
196
+ | `./sync` | `syncSmartbillInvoice(...)` and event-level sync helpers |
170
197
  | `./invoice-ui` | Optional React hooks, display helpers, and `SmartbillInvoicePanel` for invoice detail integrations |
171
198
  | `./mock` | `createSmartbillMockServer` — stateful local SmartBill-compatible mock for tests |
172
199
  | `./workflows` | Proforma conversion polling and drift reconciliation factories |
package/dist/hono.d.ts ADDED
@@ -0,0 +1,199 @@
1
+ import type { ModuleContainer } from "@voyantjs/core";
2
+ import type { HonoModule } from "@voyantjs/hono/module";
3
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
4
+ import type { SmartbillPluginOptions } from "./plugin.js";
5
+ type Env = {
6
+ Bindings: Record<string, unknown>;
7
+ Variables: {
8
+ container?: ModuleContainer;
9
+ db: PostgresJsDatabase;
10
+ userId?: string;
11
+ };
12
+ };
13
+ export interface SmartbillAdminModuleOptions {
14
+ pluginOptions: SmartbillPluginOptions | SmartbillPluginOptionsResolver;
15
+ }
16
+ export type SmartbillPluginOptionsResolver = (bindings: Record<string, unknown>) => SmartbillPluginOptions;
17
+ export interface SmartbillAdminRouteRuntime {
18
+ pluginOptions: SmartbillPluginOptions;
19
+ }
20
+ export declare const SMARTBILL_ADMIN_RUNTIME_CONTAINER_KEY = "providers.smartbill.adminRuntime";
21
+ export declare function createSmartbillAdminRoutes(options: SmartbillAdminModuleOptions): import("hono/hono-base").HonoBase<Env, {
22
+ "/invoices/:id/sync": {
23
+ $post: {
24
+ input: {
25
+ param: {
26
+ id: string;
27
+ };
28
+ };
29
+ output: {
30
+ error: string;
31
+ };
32
+ outputFormat: "json";
33
+ status: 404;
34
+ } | {
35
+ input: {
36
+ param: {
37
+ id: string;
38
+ };
39
+ };
40
+ output: {
41
+ error: string;
42
+ };
43
+ outputFormat: "json";
44
+ status: 409;
45
+ } | {
46
+ input: {
47
+ param: {
48
+ id: string;
49
+ };
50
+ };
51
+ output: {
52
+ data: {
53
+ status: "existing_ref";
54
+ invoiceId: string;
55
+ documentType: import("./artifacts.js").SmartbillDocumentType;
56
+ externalRef: {
57
+ metadata: import("hono/utils/types").JSONValue;
58
+ id: string;
59
+ invoiceId: string;
60
+ externalId: string | null;
61
+ externalNumber: string | null;
62
+ externalUrl: string | null;
63
+ };
64
+ artifact: {
65
+ status: "skipped";
66
+ reason: "missing_db" | "missing_invoice" | "missing_document_storage" | "missing_smartbill_reference";
67
+ } | {
68
+ status: "registered_ref";
69
+ reason?: "missing_number" | undefined;
70
+ } | {
71
+ status: "already_exists";
72
+ attachment: {
73
+ metadata: import("hono/utils/types").JSONValue;
74
+ name: string;
75
+ id: string;
76
+ createdAt: string;
77
+ kind: string;
78
+ invoiceId: string;
79
+ storageKey: string | null;
80
+ fileSize: number | null;
81
+ checksum: string | null;
82
+ mimeType: string | null;
83
+ } | null;
84
+ } | {
85
+ status: "persisted";
86
+ rendition: {
87
+ metadata: import("hono/utils/types").JSONValue;
88
+ id: string;
89
+ createdAt: string;
90
+ updatedAt: string;
91
+ status: "pending" | "failed" | "ready" | "stale";
92
+ format: "json" | "pdf" | "html" | "xml";
93
+ errorMessage: string | null;
94
+ templateId: string | null;
95
+ language: string | null;
96
+ invoiceId: string;
97
+ storageKey: string | null;
98
+ fileSize: number | null;
99
+ checksum: string | null;
100
+ generatedAt: string | null;
101
+ } | null;
102
+ attachment: {
103
+ metadata: import("hono/utils/types").JSONValue;
104
+ name: string;
105
+ id: string;
106
+ createdAt: string;
107
+ kind: string;
108
+ invoiceId: string;
109
+ storageKey: string | null;
110
+ fileSize: number | null;
111
+ checksum: string | null;
112
+ mimeType: string | null;
113
+ } | null;
114
+ } | null;
115
+ } | {
116
+ status: "created";
117
+ invoiceId: string;
118
+ documentType: import("./artifacts.js").SmartbillDocumentType;
119
+ result: {
120
+ number?: string | undefined;
121
+ series?: string | undefined;
122
+ url?: string | undefined;
123
+ status?: string | undefined;
124
+ message?: string | undefined;
125
+ errorText?: string | undefined;
126
+ };
127
+ artifact: {
128
+ status: "skipped";
129
+ reason: "missing_db" | "missing_invoice" | "missing_document_storage" | "missing_smartbill_reference";
130
+ } | {
131
+ status: "registered_ref";
132
+ reason?: "missing_number" | undefined;
133
+ } | {
134
+ status: "already_exists";
135
+ attachment: {
136
+ metadata: import("hono/utils/types").JSONValue;
137
+ name: string;
138
+ id: string;
139
+ createdAt: string;
140
+ kind: string;
141
+ invoiceId: string;
142
+ storageKey: string | null;
143
+ fileSize: number | null;
144
+ checksum: string | null;
145
+ mimeType: string | null;
146
+ } | null;
147
+ } | {
148
+ status: "persisted";
149
+ rendition: {
150
+ metadata: import("hono/utils/types").JSONValue;
151
+ id: string;
152
+ createdAt: string;
153
+ updatedAt: string;
154
+ status: "pending" | "failed" | "ready" | "stale";
155
+ format: "json" | "pdf" | "html" | "xml";
156
+ errorMessage: string | null;
157
+ templateId: string | null;
158
+ language: string | null;
159
+ invoiceId: string;
160
+ storageKey: string | null;
161
+ fileSize: number | null;
162
+ checksum: string | null;
163
+ generatedAt: string | null;
164
+ } | null;
165
+ attachment: {
166
+ metadata: import("hono/utils/types").JSONValue;
167
+ name: string;
168
+ id: string;
169
+ createdAt: string;
170
+ kind: string;
171
+ invoiceId: string;
172
+ storageKey: string | null;
173
+ fileSize: number | null;
174
+ checksum: string | null;
175
+ mimeType: string | null;
176
+ } | null;
177
+ } | null;
178
+ };
179
+ };
180
+ outputFormat: "json";
181
+ status: 200 | 201;
182
+ } | {
183
+ input: {
184
+ param: {
185
+ id: string;
186
+ };
187
+ };
188
+ output: {
189
+ error: string;
190
+ };
191
+ outputFormat: "json";
192
+ status: 502;
193
+ };
194
+ };
195
+ }, "/", "/invoices/:id/sync">;
196
+ export declare function createSmartbillAdminModule(options: SmartbillAdminModuleOptions): HonoModule;
197
+ export declare function buildSmartbillAdminRouteRuntime(bindings: Record<string, unknown>, options: SmartbillAdminModuleOptions): SmartbillAdminRouteRuntime;
198
+ export {};
199
+ //# sourceMappingURL=hono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAGzD,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,SAAS,CAAC,EAAE,eAAe,CAAA;QAC3B,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,MAAM,WAAW,2BAA2B;IAC1C,aAAa,EAAE,sBAAsB,GAAG,8BAA8B,CAAA;CACvE;AAED,MAAM,MAAM,8BAA8B,GAAG,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,sBAAsB,CAAA;AAE3B,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,sBAAsB,CAAA;CACtC;AAED,eAAO,MAAM,qCAAqC,qCAAqC,CAAA;AAEvF,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAyB9E;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,UAAU,CAe3F;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,2BAA2B,GACnC,0BAA0B,CAO5B"}
package/dist/hono.js ADDED
@@ -0,0 +1,77 @@
1
+ import { FINANCE_ROUTE_RUNTIME_CONTAINER_KEY } from "@voyantjs/finance";
2
+ import { Hono } from "hono";
3
+ import { syncSmartbillInvoice } from "./sync.js";
4
+ export const SMARTBILL_ADMIN_RUNTIME_CONTAINER_KEY = "providers.smartbill.adminRuntime";
5
+ export function createSmartbillAdminRoutes(options) {
6
+ return new Hono().post("/invoices/:id/sync", async (c) => {
7
+ try {
8
+ const runtime = resolveSmartbillAdminRouteRuntime(c, options);
9
+ const financeRuntime = resolveFinanceRouteRuntime(c.var.container);
10
+ const result = await syncSmartbillInvoice({
11
+ db: c.get("db"),
12
+ invoiceId: c.req.param("id"),
13
+ pluginOptions: runtime.pluginOptions,
14
+ issueRuntime: financeRuntime,
15
+ });
16
+ if (result.status === "not_found") {
17
+ return c.json({ error: "Invoice not found" }, 404);
18
+ }
19
+ if (result.status === "unsupported_document_type") {
20
+ return c.json({ error: `SmartBill sync does not support ${result.invoiceType}` }, 409);
21
+ }
22
+ return c.json({ data: result }, result.status === "created" ? 201 : 200);
23
+ }
24
+ catch (error) {
25
+ const message = error instanceof Error ? error.message : "SmartBill sync failed";
26
+ return c.json({ error: message }, 502);
27
+ }
28
+ });
29
+ }
30
+ export function createSmartbillAdminModule(options) {
31
+ const module = {
32
+ name: "smartbill",
33
+ bootstrap: ({ bindings, container }) => {
34
+ container.register(SMARTBILL_ADMIN_RUNTIME_CONTAINER_KEY, buildSmartbillAdminRouteRuntime(bindings, options));
35
+ },
36
+ };
37
+ return {
38
+ module,
39
+ adminRoutes: createSmartbillAdminRoutes(options),
40
+ };
41
+ }
42
+ export function buildSmartbillAdminRouteRuntime(bindings, options) {
43
+ return {
44
+ pluginOptions: typeof options.pluginOptions === "function"
45
+ ? options.pluginOptions(bindings)
46
+ : options.pluginOptions,
47
+ };
48
+ }
49
+ function resolveSmartbillAdminRouteRuntime(c, options) {
50
+ if (c.var.container) {
51
+ try {
52
+ return c.var.container.resolve(SMARTBILL_ADMIN_RUNTIME_CONTAINER_KEY);
53
+ }
54
+ catch {
55
+ // Fall through for tests and minimal apps that mount routes without bootstrap.
56
+ }
57
+ }
58
+ return buildSmartbillAdminRouteRuntime(c.env, options);
59
+ }
60
+ function resolveFinanceRouteRuntime(container) {
61
+ if (!container)
62
+ return undefined;
63
+ try {
64
+ const runtime = container.resolve(FINANCE_ROUTE_RUNTIME_CONTAINER_KEY);
65
+ return {
66
+ invoiceFxSettings: runtime.invoiceFxSettings,
67
+ resolveInvoiceFxSettings: runtime.resolveInvoiceFxSettings,
68
+ updateInvoiceFxSettings: runtime.updateInvoiceFxSettings,
69
+ resolveInvoiceExchangeRate: runtime.resolveInvoiceExchangeRate,
70
+ resolveInvoiceExchangeRateResolver: runtime.resolveInvoiceExchangeRateResolver,
71
+ onInvoiceFxResolutionError: runtime.onInvoiceFxResolutionError,
72
+ };
73
+ }
74
+ catch {
75
+ return undefined;
76
+ }
77
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export type { RetrySmartbillInvoiceArtifactInput, SmartbillArtifactPersistenceOp
2
2
  export { retrySmartbillInvoiceArtifact } from "./artifacts.js";
3
3
  export type { SmartbillClientApi, SmartbillClientOptions } from "./client.js";
4
4
  export { createSmartbillClient } from "./client.js";
5
+ export type { SmartbillAdminModuleOptions, SmartbillAdminRouteRuntime, SmartbillPluginOptionsResolver, } from "./hono.js";
6
+ export { buildSmartbillAdminRouteRuntime, createSmartbillAdminModule, createSmartbillAdminRoutes, SMARTBILL_ADMIN_RUNTIME_CONTAINER_KEY, } from "./hono.js";
5
7
  export type { SmartbillEventValue, SmartbillMappingOptions, SmartbillMaybePromise, } from "./mapping.js";
6
8
  export { mapClient, mapLineItems, mapVoyantInvoiceToSmartbill, mapVoyantInvoiceToSmartbillAsync, } from "./mapping.js";
7
9
  export type { SmartbillMockDocument, SmartbillMockDocumentKind, SmartbillMockDocumentStatus, SmartbillMockListenOptions, SmartbillMockRequest, SmartbillMockResponse, SmartbillMockSeries, SmartbillMockServer, SmartbillMockServerHandle, SmartbillMockServerOptions, SmartbillMockTax, } from "./mock.js";
@@ -12,6 +14,8 @@ export type { ResolvedSmartbillSyncEventNames, SmartbillSyncRuntime } from "./ru
12
14
  export { createSmartbillSyncRuntime } from "./runtime.js";
13
15
  export type { SmartbillInvoiceSettlementPoller, SmartbillInvoiceSettlementPollerOptions, SmartbillSettlementExternalRef, SmartbillSettlementInvoice, SmartbillSettlementPollerContext, SmartbillSettlementPollerResult, SmartbillSettlementSeriesContext, } from "./settlement.js";
14
16
  export { createSmartbillInvoiceSettlementPoller } from "./settlement.js";
17
+ export type { SyncSmartbillInvoiceEventInput, SyncSmartbillInvoiceEventResult, SyncSmartbillInvoiceInput, SyncSmartbillInvoiceResult, } from "./sync.js";
18
+ export { syncSmartbillInvoice, syncSmartbillInvoiceEvent } from "./sync.js";
15
19
  export type { SmartbillClient, SmartbillEnvelope, SmartbillEstimateInvoicesResponse, SmartbillFetch, SmartbillInvoiceBody, SmartbillInvoiceResponse, SmartbillPaymentEntry, SmartbillPdfResponse, SmartbillProduct, SmartbillSeriesResponse, SmartbillStatusResponse, SmartbillTaxesResponse, VoyantInvoiceEvent, } from "./types.js";
16
20
  export type { SmartbillDriftFinding, SmartbillDriftFindingType, SmartbillDriftReconciler, SmartbillDriftReconcilerOptions, SmartbillDriftReconcilerResult, SmartbillProformaConversion, SmartbillProformaConversionPoller, SmartbillProformaConversionPollerOptions, SmartbillProformaConversionPollerResult, SmartbillReferenceParts, SmartbillRemoteDocument, SmartbillRemoteDocumentStatus, SmartbillWorkflowDocumentType, SmartbillWorkflowError, SmartbillWorkflowExternalRef, SmartbillWorkflowInvoice, SmartbillWorkflowLogger, } from "./workflows.js";
17
21
  export { createSmartbillDriftReconciler, createSmartbillProformaConversionPoller, } from "./workflows.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kCAAkC,EAClC,mCAAmC,EACnC,kCAAkC,EAClC,mCAAmC,EACnC,+BAA+B,EAC/B,mBAAmB,EACnB,gCAAgC,EAChC,qBAAqB,EACrB,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,YAAY,EACV,mBAAm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dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export { retrySmartbillInvoiceArtifact } from "./artifacts.js";
2
2
  export { createSmartbillClient } from "./client.js";
3
+ export { buildSmartbillAdminRouteRuntime, createSmartbillAdminModule, createSmartbillAdminRoutes, SMARTBILL_ADMIN_RUNTIME_CONTAINER_KEY, } from "./hono.js";
3
4
  export { mapClient, mapLineItems, mapVoyantInvoiceToSmartbill, mapVoyantInvoiceToSmartbillAsync, } from "./mapping.js";
4
5
  export { createSmartbillMockServer } from "./mock.js";
5
6
  export { smartbillPlugin } from "./plugin.js";
6
7
  export { createSmartbillSyncRuntime } from "./runtime.js";
7
8
  export { createSmartbillInvoiceSettlementPoller } from "./settlement.js";
9
+ export { syncSmartbillInvoice, syncSmartbillInvoiceEvent } from "./sync.js";
8
10
  export { createSmartbillDriftReconciler, createSmartbillProformaConversionPoller, } from "./workflows.js";
@@ -433,4 +433,6 @@ export declare function useSmartbillInvoiceRef(invoiceId: string | null | undefi
433
433
  }[]>;
434
434
  };
435
435
  export declare function SmartbillInvoicePanel({ invoiceId, externalRef, title, className, hideWhenEmpty, sendAction, retryAction, convertProformaAction, extraActions, }: SmartbillInvoicePanelProps): import("react/jsx-runtime").JSX.Element | null;
436
+ export declare function useSmartbillInvoiceSyncAction(invoiceId: string): SmartbillInvoiceAction;
437
+ export declare function useSmartbillConvertProformaAction(invoiceId: string): SmartbillInvoiceAction;
436
438
  //# sourceMappingURL=invoice-ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invoice-ui.d.ts","sourceRoot":"","sources":["../src/invoice-ui.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAGL,KAAK,2BAA2B,EAGjC,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,gCAAgC,EAChC,qCAAqC,EACrC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,yBAA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AqB,CAAC,EAAE,sBAAsB,CAAA;IAC9C,YAAY,CAAC,EAAE,SAAS,CAAA;CACzB;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,8BAAmC;;;;;;;;;;;;;YAiB7C;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,8BAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO7C;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,WAAW,EACX,KAAmB,EACnB,SAAS,EACT,aAAqB,EACrB,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,YAAY,GACb,EAAE,0BAA0B,kDAuG5B;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,sBAAsB,CAuBvF;AAED,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,GAAG,sBAAsB,CAuB3F"}
@@ -1,11 +1,13 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useQuery } from "@tanstack/react-query";
3
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
4
4
  import { fetchWithValidation, useVoyantFinanceContext } from "@voyantjs/finance-react";
5
5
  import { Badge, Button, buttonVariants, Card, CardAction, CardContent, CardHeader, CardTitle, } from "@voyantjs/ui/components";
6
6
  import { cn } from "@voyantjs/ui/lib/utils";
7
- import { ExternalLink, FileText, Loader2, RefreshCw, Send } from "lucide-react";
7
+ import { ArrowRightLeft, ExternalLink, FileText, Loader2, RefreshCw, Send } from "lucide-react";
8
+ import { z } from "zod";
8
9
  import { getSmartbillInvoiceDocumentLinks, resolveSmartbillInvoiceReferenceParts, selectSmartbillInvoiceRef, smartbillInvoiceExternalRefsResponseSchema, } from "./invoice-ui-data.js";
10
+ const actionResponseSchema = z.object({ data: z.unknown().optional() });
9
11
  export { getSmartbillInvoiceDocumentLinks, resolveSmartbillInvoiceReferenceParts, selectSmartbillInvoiceRef, } from "./invoice-ui-data.js";
10
12
  export function useSmartbillInvoiceRefs(invoiceId, options = {}) {
11
13
  const { baseUrl, fetcher } = useVoyantFinanceContext();
@@ -28,6 +30,8 @@ export function useSmartbillInvoiceRef(invoiceId, options = {}) {
28
30
  }
29
31
  export function SmartbillInvoicePanel({ invoiceId, externalRef, title = "SmartBill", className, hideWhenEmpty = false, sendAction, retryAction, convertProformaAction, extraActions, }) {
30
32
  const query = useSmartbillInvoiceRef(invoiceId, { enabled: externalRef === undefined });
33
+ const defaultSyncAction = useSmartbillInvoiceSyncAction(invoiceId);
34
+ const defaultConvertProformaAction = useSmartbillConvertProformaAction(invoiceId);
31
35
  const ref = externalRef === undefined ? query.data : externalRef;
32
36
  const isLoading = externalRef === undefined && query.isPending;
33
37
  const isError = externalRef === undefined && query.isError;
@@ -37,8 +41,45 @@ export function SmartbillInvoicePanel({ invoiceId, externalRef, title = "SmartBi
37
41
  const reference = resolveSmartbillInvoiceReferenceParts(ref);
38
42
  const documentLinks = getSmartbillInvoiceDocumentLinks(ref);
39
43
  const status = ref?.syncError ? "error" : (ref?.status ?? null);
40
- const canConvertProforma = reference.documentType === "proforma" && convertProformaAction;
41
- return (_jsxs(Card, { "data-slot": "smartbill-invoice-panel", size: "sm", className: className, children: [_jsxs(CardHeader, { children: [_jsxs(CardTitle, { className: "flex min-w-0 items-center gap-2", children: [_jsx(FileText, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }), _jsx("span", { className: "truncate", children: title })] }), _jsx(CardAction, { children: status ? (_jsx(Badge, { variant: status === "error" ? "destructive" : "outline", children: status })) : null })] }), _jsxs(CardContent, { className: "grid gap-4", children: [isLoading ? (_jsxs("div", { className: "flex items-center gap-2 text-muted-foreground text-sm", children: [_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), "Loading SmartBill state"] })) : isError ? (_jsx("p", { className: "text-destructive text-sm", children: "SmartBill state could not be loaded." })) : ref ? (_jsxs("div", { className: "grid gap-3 text-sm", children: [_jsxs("dl", { className: "grid gap-2 sm:grid-cols-2", children: [_jsx(SmartbillField, { label: "Series", children: reference.seriesName ?? "-" }), _jsx(SmartbillField, { label: "Number", children: reference.number ?? "-" }), _jsx(SmartbillField, { label: "Type", children: reference.documentType ?? "-" }), _jsx(SmartbillField, { label: "Synced", children: formatDateTime(ref.syncedAt) ?? "-" })] }), ref.syncError ? (_jsx("p", { className: "rounded-md border border-destructive/20 bg-destructive/5 p-2 text-destructive", children: ref.syncError })) : null, documentLinks.length > 0 ? (_jsx("div", { className: "flex flex-wrap gap-2", children: documentLinks.map((link) => (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", className: buttonVariants({ variant: "outline", size: "sm" }), children: [_jsx(ExternalLink, { className: "size-4", "aria-hidden": "true" }), link.label] }, link.href))) })) : null] })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: "No SmartBill reference is linked yet." })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [!ref && sendAction ? (_jsx(SmartbillActionButton, { action: sendAction, icon: _jsx(Send, { className: "size-4" }), children: sendAction.label ?? "Send to SmartBill" })) : null, retryAction ? (_jsx(SmartbillActionButton, { action: retryAction, icon: _jsx(RefreshCw, { className: "size-4" }), children: retryAction.label ?? "Retry sync" })) : null, canConvertProforma ? (_jsx(SmartbillActionButton, { action: convertProformaAction, icon: _jsx(RefreshCw, { className: "size-4" }), children: convertProformaAction.label ?? "Convert proforma" })) : null, extraActions] })] })] }));
44
+ const effectiveSendAction = sendAction ?? defaultSyncAction;
45
+ const effectiveRetryAction = retryAction ?? (ref ? defaultSyncAction : undefined);
46
+ const effectiveConvertProformaAction = convertProformaAction ?? defaultConvertProformaAction;
47
+ const canConvertProforma = reference.documentType === "proforma" && Boolean(effectiveConvertProformaAction);
48
+ return (_jsxs(Card, { "data-slot": "smartbill-invoice-panel", size: "sm", className: className, children: [_jsxs(CardHeader, { children: [_jsxs(CardTitle, { className: "flex min-w-0 items-center gap-2", children: [_jsx(FileText, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }), _jsx("span", { className: "truncate", children: title })] }), _jsx(CardAction, { children: status ? (_jsx(Badge, { variant: status === "error" ? "destructive" : "outline", children: status })) : null })] }), _jsxs(CardContent, { className: "grid gap-4", children: [isLoading ? (_jsxs("div", { className: "flex items-center gap-2 text-muted-foreground text-sm", children: [_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), "Loading SmartBill state"] })) : isError ? (_jsx("p", { className: "text-destructive text-sm", children: "SmartBill state could not be loaded." })) : ref ? (_jsxs("div", { className: "grid gap-3 text-sm", children: [_jsxs("dl", { className: "grid gap-2 sm:grid-cols-2", children: [_jsx(SmartbillField, { label: "Series", children: reference.seriesName ?? "-" }), _jsx(SmartbillField, { label: "Number", children: reference.number ?? "-" }), _jsx(SmartbillField, { label: "Type", children: reference.documentType ?? "-" }), _jsx(SmartbillField, { label: "Synced", children: formatDateTime(ref.syncedAt) ?? "-" })] }), ref.syncError ? (_jsx("p", { className: "rounded-md border border-destructive/20 bg-destructive/5 p-2 text-destructive", children: ref.syncError })) : null, documentLinks.length > 0 ? (_jsx("div", { className: "flex flex-wrap gap-2", children: documentLinks.map((link) => (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", className: buttonVariants({ variant: "outline", size: "sm" }), children: [_jsx(ExternalLink, { className: "size-4", "aria-hidden": "true" }), link.label] }, link.href))) })) : null] })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: "No SmartBill reference is linked yet." })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [!ref && !isLoading && !isError ? (_jsx(SmartbillActionButton, { action: effectiveSendAction, icon: _jsx(Send, { className: "size-4" }), children: effectiveSendAction.label ?? "Send to SmartBill" })) : null, effectiveRetryAction ? (_jsx(SmartbillActionButton, { action: effectiveRetryAction, icon: _jsx(RefreshCw, { className: "size-4" }), children: effectiveRetryAction.label ?? "Retry sync" })) : null, canConvertProforma && effectiveConvertProformaAction ? (_jsx(SmartbillActionButton, { action: effectiveConvertProformaAction, icon: _jsx(ArrowRightLeft, { className: "size-4" }), children: effectiveConvertProformaAction.label ?? "Convert proforma" })) : null, extraActions] })] })] }));
49
+ }
50
+ export function useSmartbillInvoiceSyncAction(invoiceId) {
51
+ const { baseUrl, fetcher } = useVoyantFinanceContext();
52
+ const queryClient = useQueryClient();
53
+ const mutation = useMutation({
54
+ mutationFn: async () => fetchWithValidation(`/v1/admin/smartbill/invoices/${encodeURIComponent(invoiceId)}/sync`, actionResponseSchema, { baseUrl, fetcher }, { method: "POST" }),
55
+ onSuccess: async () => {
56
+ await queryClient.invalidateQueries({ queryKey: ["voyant"] });
57
+ },
58
+ });
59
+ return {
60
+ pending: mutation.isPending,
61
+ disabled: !invoiceId,
62
+ onClick: async () => {
63
+ await mutation.mutateAsync();
64
+ },
65
+ };
66
+ }
67
+ export function useSmartbillConvertProformaAction(invoiceId) {
68
+ const { baseUrl, fetcher } = useVoyantFinanceContext();
69
+ const queryClient = useQueryClient();
70
+ const mutation = useMutation({
71
+ mutationFn: async () => fetchWithValidation(`/v1/finance/invoices/${encodeURIComponent(invoiceId)}/convert-to-invoice`, actionResponseSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({}) }),
72
+ onSuccess: async () => {
73
+ await queryClient.invalidateQueries({ queryKey: ["voyant"] });
74
+ },
75
+ });
76
+ return {
77
+ pending: mutation.isPending,
78
+ disabled: !invoiceId,
79
+ onClick: async () => {
80
+ await mutation.mutateAsync();
81
+ },
82
+ };
42
83
  }
43
84
  function SmartbillField({ label, children }) {
44
85
  return (_jsxs("div", { className: "grid gap-1", children: [_jsx("dt", { className: "text-muted-foreground text-xs uppercase", children: label }), _jsx("dd", { className: "break-words font-medium", children: children })] }));
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from "@voyantjs/core";
2
- import { type SmartbillArtifactPersistenceOptions } from "./artifacts.js";
2
+ import type { SmartbillArtifactPersistenceOptions } from "./artifacts.js";
3
3
  import type { SmartbillClientOptions } from "./client.js";
4
4
  import type { SmartbillMappingOptions } from "./mapping.js";
5
5
  import type { SmartbillInvoiceBody, SmartbillInvoiceResponse, VoyantInvoiceEvent } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,gBAAgB,CAAA;AAIxD,OAAO,EAKL,KAAK,mCAAmC,EAIzC,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGpG,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,eAAe;IAC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