@voyantjs/plugin-netopia 0.5.0 → 0.6.2

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
@@ -1,8 +1,19 @@
1
1
  # `@voyantjs/plugin-netopia`
2
2
 
3
- Netopia hosted-card payment support for Voyant finance.
3
+ Netopia hosted-card payment adapter bundle for Voyant finance.
4
4
 
5
- This package sits on top of `@voyantjs/finance` and its `payment_sessions` model. It does not replace finance state. It starts a hosted Netopia checkout, stores provider references on the session, and reconciles callback payloads back into Voyant payments, captures, authorizations, invoices, and booking payment schedules.
5
+ This package sits on top of `@voyantjs/finance` and its `payment_sessions`
6
+ model. It does not replace finance state.
7
+
8
+ Architecturally, this package is primarily:
9
+
10
+ - a Netopia payment adapter
11
+ - a finance extension
12
+ - an optional packaged Hono bundle when an app wants one installable entrypoint
13
+
14
+ It starts a hosted Netopia checkout, stores provider references on the session,
15
+ and reconciles callback payloads back into Voyant payments, captures,
16
+ authorizations, invoices, and booking payment schedules.
6
17
 
7
18
  ## Environment
8
19
 
@@ -29,23 +40,29 @@ Mounted as a finance extension, the package exposes:
29
40
 
30
41
  ## Checkout integration
31
42
 
32
- If you use `@voyantjs/checkout`, the plugin now also exports
43
+ If you use `@voyantjs/checkout`, the package also exports
33
44
  `createNetopiaCheckoutStarter()`. That lets checkout create the payment session
34
45
  and start the Netopia redirect flow in one request while keeping provider
35
46
  startup optional in core checkout.
36
47
 
37
- Because this is a finance extension, these routes mount under the finance module path in the app.
48
+ Because this is a finance extension, these routes mount under the finance module
49
+ path in the app.
38
50
 
39
51
  ## Usage
40
52
 
41
53
  ```ts
42
- import { createNetopiaFinanceExtension } from "@voyantjs/plugin-netopia"
54
+ import { createNetopiaFinanceAdapter } from "@voyantjs/plugin-netopia"
43
55
 
44
- const netopiaFinanceExtension = createNetopiaFinanceExtension()
56
+ const netopiaFinanceExtension = createNetopiaFinanceAdapter()
45
57
  ```
46
58
 
47
59
  Then include the returned extension in `createApp({ extensions: [...] })`.
48
60
 
61
+ If you want the packaged distribution helper instead, use
62
+ `createNetopiaAdapterBundle()` or `netopiaHonoPlugin()`. Those are optional
63
+ distribution helpers over the adapter/extension surfaces above; the adapter and
64
+ finance extension remain the main runtime seams.
65
+
49
66
  ## Flow
50
67
 
51
68
  1. Either create a finance `payment_session` yourself, or use one of the collect routes to create one from a booking schedule, guarantee, or invoice.
@@ -53,7 +70,7 @@ Then include the returned extension in `createApp({ extensions: [...] })`.
53
70
  3. Redirect the customer to the returned provider `paymentURL`.
54
71
  4. Optionally send a payment-link or invoice notification as part of the collect flow.
55
72
  5. Netopia calls the callback route.
56
- 6. The plugin completes, fails, or updates the session in finance.
73
+ 6. The adapter completes, fails, or updates the session in finance.
57
74
 
58
75
  ## Notes
59
76
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;CAC5F;AAED,MAAM,WAAW,oBACf,SAAQ,IAAI,CAAC,6BAA6B,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAChE,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,OAAO,GAAE,qBAA0B,GAClC,6BAA6B,CA0B/B;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CA+CnF"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,YAAY,CAAA;AAGnB,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;CAC5F;AAED,MAAM,WAAW,oBACf,SAAQ,IAAI,CAAC,6BAA6B,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAChE,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,OAAO,GAAE,qBAA0B,GAClC,6BAA6B,CAuC/B;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CA+CnF"}
package/dist/client.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { ZodError } from "zod";
2
+ import { resolvedNetopiaRuntimeOptionsSchema } from "./validation.js";
1
3
  export function resolveNetopiaRuntimeOptions(bindings, options = {}) {
2
4
  const env = bindings ?? {};
3
5
  const apiUrl = options.apiUrl ?? coerceString(env.NETOPIA_URL);
@@ -15,18 +17,32 @@ export function resolveNetopiaRuntimeOptions(bindings, options = {}) {
15
17
  throw new Error("Missing Netopia config: NETOPIA_NOTIFY_URL");
16
18
  if (!redirectUrl)
17
19
  throw new Error("Missing Netopia config: NETOPIA_REDIRECT_URL");
18
- return {
19
- apiUrl,
20
- apiKey,
21
- posSignature,
22
- notifyUrl,
23
- redirectUrl,
24
- emailTemplate: options.emailTemplate ?? "confirm",
25
- language: options.language ?? "ro",
26
- successStatuses: options.successStatuses ?? [3, 5],
27
- processingStatuses: options.processingStatuses ?? [1, 15],
28
- fetch: options.fetch,
29
- };
20
+ try {
21
+ return resolvedNetopiaRuntimeOptionsSchema.parse({
22
+ apiUrl,
23
+ apiKey,
24
+ posSignature,
25
+ notifyUrl,
26
+ redirectUrl,
27
+ emailTemplate: options.emailTemplate,
28
+ language: options.language,
29
+ successStatuses: options.successStatuses,
30
+ processingStatuses: options.processingStatuses,
31
+ fetch: options.fetch,
32
+ });
33
+ }
34
+ catch (error) {
35
+ if (error instanceof ZodError) {
36
+ const detail = error.issues
37
+ .map((issue) => {
38
+ const path = issue.path.join(".") || "runtimeOptions";
39
+ return `${path}: ${issue.message}`;
40
+ })
41
+ .join("; ");
42
+ throw new Error(`Invalid Netopia runtime options: ${detail}`);
43
+ }
44
+ throw error;
45
+ }
30
46
  }
31
47
  function coerceString(value) {
32
48
  return typeof value === "string" && value.length > 0 ? value : undefined;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export { createNetopiaCheckoutStarter } from "./checkout.js";
2
2
  export { createNetopiaClient, type NetopiaClientApi, type NetopiaClientOptions, resolveNetopiaRuntimeOptions, } from "./client.js";
3
- export { createNetopiaFinanceExtension, createNetopiaFinanceRoutes, netopiaFinanceExtension, netopiaHonoPlugin, } from "./plugin.js";
3
+ export type { NetopiaNotificationRuntime, NetopiaNotificationRuntimeOptions, } from "./notification-runtime.js";
4
+ export { buildNetopiaNotificationRuntime } from "./notification-runtime.js";
5
+ export { createNetopiaFinanceExtension, createNetopiaFinanceExtension as createNetopiaFinanceAdapter, createNetopiaFinanceRoutes, NETOPIA_RUNTIME_CONTAINER_KEY, netopiaFinanceExtension, netopiaHonoPlugin as createNetopiaAdapterBundle, netopiaHonoPlugin, } from "./plugin.js";
4
6
  export { deriveNetopiaOrderId, mapNetopiaPaymentStatus, type NetopiaCallbackResult, type NetopiaCollectPaymentResult, type NetopiaStartPaymentResult, netopiaService, } from "./service.js";
5
7
  export type { NetopiaBillingAddress, NetopiaBrowserData, NetopiaFetch, NetopiaInstallments, NetopiaPaymentInstrument, NetopiaPaymentOptions, NetopiaProductLine, NetopiaRuntimeOptions, NetopiaStartPaymentInput, NetopiaStartPaymentRequest, NetopiaStartPaymentResponse, NetopiaWebhookPayload, ResolvedNetopiaRuntimeOptions, } from "./types.js";
6
- export { netopiaBillingAddressSchema, netopiaBrowserDataSchema, netopiaCollectBookingGuaranteeSchema, netopiaCollectBookingScheduleSchema, netopiaCollectInvoiceSchema, netopiaInstallmentsSchema, netopiaPaymentInstrumentSchema, netopiaPaymentOptionsSchema, netopiaProductLineSchema, netopiaStartPaymentSessionSchema, netopiaWebhookPayloadSchema, } from "./validation.js";
8
+ export { netopiaBillingAddressSchema, netopiaBrowserDataSchema, netopiaCollectBookingGuaranteeSchema, netopiaCollectBookingScheduleSchema, netopiaCollectInvoiceSchema, netopiaInstallmentsSchema, netopiaPaymentInstrumentSchema, netopiaPaymentOptionsSchema, netopiaProductLineSchema, netopiaRuntimeOptionsSchema, netopiaStartPaymentSessionSchema, netopiaWebhookPayloadSchema, resolvedNetopiaRuntimeOptionsSchema, } from "./validation.js";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EACL,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,4BAA4B,GAC7B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,cAAc,GACf,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,6BAA6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BAA2B,EAC3B,wBAAwB,EACxB,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,mCAAmC,GACpC,MAAM,iBAAiB,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { createNetopiaCheckoutStarter } from "./checkout.js";
2
2
  export { createNetopiaClient, resolveNetopiaRuntimeOptions, } from "./client.js";
3
- export { createNetopiaFinanceExtension, createNetopiaFinanceRoutes, netopiaFinanceExtension, netopiaHonoPlugin, } from "./plugin.js";
3
+ export { buildNetopiaNotificationRuntime } from "./notification-runtime.js";
4
+ export { createNetopiaFinanceExtension, createNetopiaFinanceExtension as createNetopiaFinanceAdapter, createNetopiaFinanceRoutes, NETOPIA_RUNTIME_CONTAINER_KEY, netopiaFinanceExtension, netopiaHonoPlugin as createNetopiaAdapterBundle, netopiaHonoPlugin, } from "./plugin.js";
4
5
  export { deriveNetopiaOrderId, mapNetopiaPaymentStatus, netopiaService, } from "./service.js";
5
- export { netopiaBillingAddressSchema, netopiaBrowserDataSchema, netopiaCollectBookingGuaranteeSchema, netopiaCollectBookingScheduleSchema, netopiaCollectInvoiceSchema, netopiaInstallmentsSchema, netopiaPaymentInstrumentSchema, netopiaPaymentOptionsSchema, netopiaProductLineSchema, netopiaStartPaymentSessionSchema, netopiaWebhookPayloadSchema, } from "./validation.js";
6
+ export { netopiaBillingAddressSchema, netopiaBrowserDataSchema, netopiaCollectBookingGuaranteeSchema, netopiaCollectBookingScheduleSchema, netopiaCollectInvoiceSchema, netopiaInstallmentsSchema, netopiaPaymentInstrumentSchema, netopiaPaymentOptionsSchema, netopiaProductLineSchema, netopiaRuntimeOptionsSchema, netopiaStartPaymentSessionSchema, netopiaWebhookPayloadSchema, resolvedNetopiaRuntimeOptionsSchema, } from "./validation.js";
@@ -0,0 +1,10 @@
1
+ import { type NotificationProvider, type NotificationService } from "@voyantjs/notifications";
2
+ import type { NetopiaRuntimeOptions } from "./types.js";
3
+ export type NetopiaNotificationRuntime = {
4
+ dispatcher: NotificationService;
5
+ };
6
+ export type NetopiaNotificationRuntimeOptions = Pick<NetopiaRuntimeOptions, "resolveNotificationProviders"> & {
7
+ notificationProviders?: ReadonlyArray<NotificationProvider>;
8
+ };
9
+ export declare function buildNetopiaNotificationRuntime(bindings: Record<string, unknown> | undefined, runtimeOptions?: NetopiaNotificationRuntimeOptions, dispatcherOverride?: NotificationService): NetopiaNotificationRuntime;
10
+ //# sourceMappingURL=notification-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-runtime.d.ts","sourceRoot":"","sources":["../src/notification-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,mBAAmB,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAClD,qBAAqB,EACrB,8BAA8B,CAC/B,GAAG;IACF,qBAAqB,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAA;CAC5D,CAAA;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,cAAc,GAAE,iCAAsC,EACtD,kBAAkB,CAAC,EAAE,mBAAmB,GACvC,0BAA0B,CAe5B"}
@@ -0,0 +1,14 @@
1
+ import { createDefaultNotificationProviders, createNotificationService, } from "@voyantjs/notifications";
2
+ export function buildNetopiaNotificationRuntime(bindings, runtimeOptions = {}, dispatcherOverride) {
3
+ if (dispatcherOverride) {
4
+ return {
5
+ dispatcher: dispatcherOverride,
6
+ };
7
+ }
8
+ const providers = runtimeOptions.resolveNotificationProviders?.(bindings ?? {}) ??
9
+ runtimeOptions.notificationProviders ??
10
+ createDefaultNotificationProviders(bindings ?? {});
11
+ return {
12
+ dispatcher: createNotificationService(providers),
13
+ };
14
+ }
package/dist/plugin.d.ts CHANGED
@@ -1,14 +1,17 @@
1
- import { type HonoPlugin } from "@voyantjs/hono";
1
+ import type { ModuleContainer } from "@voyantjs/core";
2
+ import { type HonoBundle } from "@voyantjs/hono";
2
3
  import type { HonoExtension } from "@voyantjs/hono/module";
3
4
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
4
5
  import type { NetopiaRuntimeOptions } from "./types.js";
5
6
  type Env = {
6
7
  Bindings: Record<string, unknown>;
7
8
  Variables: {
9
+ container: ModuleContainer;
8
10
  db: PostgresJsDatabase;
9
11
  userId?: string;
10
12
  };
11
13
  };
14
+ export declare const NETOPIA_RUNTIME_CONTAINER_KEY = "providers.netopia.runtime";
12
15
  export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptions): import("hono/hono-base").HonoBase<Env, {
13
16
  "/providers/netopia/payment-sessions/:sessionId/start": {
14
17
  $post: {
@@ -20,24 +23,24 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
20
23
  output: {
21
24
  data: {
22
25
  session: {
26
+ metadata: {
27
+ [x: string]: import("hono/utils/types").JSONValue;
28
+ } | null;
23
29
  id: string;
24
- status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ expiresAt: string | null;
33
+ status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
34
+ currency: string;
35
+ notes: string | null;
25
36
  expiredAt: string | null;
26
37
  cancelledAt: string | null;
27
38
  completedAt: string | null;
28
- createdAt: string;
29
- updatedAt: string;
30
39
  bookingId: string | null;
31
- notes: string | null;
32
- metadata: {
33
- [x: string]: import("hono/utils/types").JSONValue;
34
- } | null;
35
- expiresAt: string | null;
36
40
  provider: string | null;
37
41
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
38
42
  targetId: string | null;
39
43
  orderId: string | null;
40
- currency: string;
41
44
  invoiceId: string | null;
42
45
  amountCents: number;
43
46
  bookingPaymentScheduleId: string | null;
@@ -146,19 +149,19 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
146
149
  output: {
147
150
  data: {
148
151
  paymentSessionNotification: {
152
+ metadata: {
153
+ [x: string]: import("hono/utils/types").JSONValue;
154
+ } | null;
149
155
  id: string;
150
- status: "cancelled" | "pending" | "failed" | "sent";
151
- personId: string | null;
152
- organizationId: string | null;
153
156
  createdAt: string;
154
157
  updatedAt: string;
158
+ organizationId: string | null;
159
+ status: "pending" | "cancelled" | "failed" | "sent";
160
+ personId: string | null;
155
161
  bookingId: string | null;
156
- metadata: {
157
- [x: string]: import("hono/utils/types").JSONValue;
158
- } | null;
159
162
  channel: "email" | "sms";
160
163
  provider: string;
161
- targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
164
+ targetType: "organization" | "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "payment_session";
162
165
  targetId: string | null;
163
166
  templateId: string | null;
164
167
  invoiceId: string | null;
@@ -179,19 +182,19 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
179
182
  scheduledFor: string | null;
180
183
  } | null;
181
184
  invoiceNotification: {
185
+ metadata: {
186
+ [x: string]: import("hono/utils/types").JSONValue;
187
+ } | null;
182
188
  id: string;
183
- status: "cancelled" | "pending" | "failed" | "sent";
184
- personId: string | null;
185
- organizationId: string | null;
186
189
  createdAt: string;
187
190
  updatedAt: string;
191
+ organizationId: string | null;
192
+ status: "pending" | "cancelled" | "failed" | "sent";
193
+ personId: string | null;
188
194
  bookingId: string | null;
189
- metadata: {
190
- [x: string]: import("hono/utils/types").JSONValue;
191
- } | null;
192
195
  channel: "email" | "sms";
193
196
  provider: string;
194
- targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
197
+ targetType: "organization" | "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "payment_session";
195
198
  targetId: string | null;
196
199
  templateId: string | null;
197
200
  invoiceId: string | null;
@@ -212,24 +215,24 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
212
215
  scheduledFor: string | null;
213
216
  } | null;
214
217
  session: {
218
+ metadata: {
219
+ [x: string]: import("hono/utils/types").JSONValue;
220
+ } | null;
215
221
  id: string;
216
- status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
222
+ createdAt: string;
223
+ updatedAt: string;
224
+ expiresAt: string | null;
225
+ status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
226
+ currency: string;
227
+ notes: string | null;
217
228
  expiredAt: string | null;
218
229
  cancelledAt: string | null;
219
230
  completedAt: string | null;
220
- createdAt: string;
221
- updatedAt: string;
222
231
  bookingId: string | null;
223
- notes: string | null;
224
- metadata: {
225
- [x: string]: import("hono/utils/types").JSONValue;
226
- } | null;
227
- expiresAt: string | null;
228
232
  provider: string | null;
229
233
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
230
234
  targetId: string | null;
231
235
  orderId: string | null;
232
- currency: string;
233
236
  invoiceId: string | null;
234
237
  amountCents: number;
235
238
  bookingPaymentScheduleId: string | null;
@@ -291,7 +294,7 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
291
294
  error: string;
292
295
  };
293
296
  outputFormat: "json";
294
- status: 500 | 404 | 409 | 502;
297
+ status: 404 | 409 | 500 | 502;
295
298
  };
296
299
  };
297
300
  } & {
@@ -307,19 +310,19 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
307
310
  output: {
308
311
  data: {
309
312
  paymentSessionNotification: {
313
+ metadata: {
314
+ [x: string]: import("hono/utils/types").JSONValue;
315
+ } | null;
310
316
  id: string;
311
- status: "cancelled" | "pending" | "failed" | "sent";
312
- personId: string | null;
313
- organizationId: string | null;
314
317
  createdAt: string;
315
318
  updatedAt: string;
319
+ organizationId: string | null;
320
+ status: "pending" | "cancelled" | "failed" | "sent";
321
+ personId: string | null;
316
322
  bookingId: string | null;
317
- metadata: {
318
- [x: string]: import("hono/utils/types").JSONValue;
319
- } | null;
320
323
  channel: "email" | "sms";
321
324
  provider: string;
322
- targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
325
+ targetType: "organization" | "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "payment_session";
323
326
  targetId: string | null;
324
327
  templateId: string | null;
325
328
  invoiceId: string | null;
@@ -340,19 +343,19 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
340
343
  scheduledFor: string | null;
341
344
  } | null;
342
345
  invoiceNotification: {
346
+ metadata: {
347
+ [x: string]: import("hono/utils/types").JSONValue;
348
+ } | null;
343
349
  id: string;
344
- status: "cancelled" | "pending" | "failed" | "sent";
345
- personId: string | null;
346
- organizationId: string | null;
347
350
  createdAt: string;
348
351
  updatedAt: string;
352
+ organizationId: string | null;
353
+ status: "pending" | "cancelled" | "failed" | "sent";
354
+ personId: string | null;
349
355
  bookingId: string | null;
350
- metadata: {
351
- [x: string]: import("hono/utils/types").JSONValue;
352
- } | null;
353
356
  channel: "email" | "sms";
354
357
  provider: string;
355
- targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
358
+ targetType: "organization" | "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "payment_session";
356
359
  targetId: string | null;
357
360
  templateId: string | null;
358
361
  invoiceId: string | null;
@@ -373,24 +376,24 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
373
376
  scheduledFor: string | null;
374
377
  } | null;
375
378
  session: {
379
+ metadata: {
380
+ [x: string]: import("hono/utils/types").JSONValue;
381
+ } | null;
376
382
  id: string;
377
- status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
383
+ createdAt: string;
384
+ updatedAt: string;
385
+ expiresAt: string | null;
386
+ status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
387
+ currency: string;
388
+ notes: string | null;
378
389
  expiredAt: string | null;
379
390
  cancelledAt: string | null;
380
391
  completedAt: string | null;
381
- createdAt: string;
382
- updatedAt: string;
383
392
  bookingId: string | null;
384
- notes: string | null;
385
- metadata: {
386
- [x: string]: import("hono/utils/types").JSONValue;
387
- } | null;
388
- expiresAt: string | null;
389
393
  provider: string | null;
390
394
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
391
395
  targetId: string | null;
392
396
  orderId: string | null;
393
- currency: string;
394
397
  invoiceId: string | null;
395
398
  amountCents: number;
396
399
  bookingPaymentScheduleId: string | null;
@@ -452,7 +455,7 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
452
455
  error: string;
453
456
  };
454
457
  outputFormat: "json";
455
- status: 500 | 404 | 409 | 502;
458
+ status: 404 | 409 | 500 | 502;
456
459
  };
457
460
  };
458
461
  } & {
@@ -466,19 +469,19 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
466
469
  output: {
467
470
  data: {
468
471
  paymentSessionNotification: {
472
+ metadata: {
473
+ [x: string]: import("hono/utils/types").JSONValue;
474
+ } | null;
469
475
  id: string;
470
- status: "cancelled" | "pending" | "failed" | "sent";
471
- personId: string | null;
472
- organizationId: string | null;
473
476
  createdAt: string;
474
477
  updatedAt: string;
478
+ organizationId: string | null;
479
+ status: "pending" | "cancelled" | "failed" | "sent";
480
+ personId: string | null;
475
481
  bookingId: string | null;
476
- metadata: {
477
- [x: string]: import("hono/utils/types").JSONValue;
478
- } | null;
479
482
  channel: "email" | "sms";
480
483
  provider: string;
481
- targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
484
+ targetType: "organization" | "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "payment_session";
482
485
  targetId: string | null;
483
486
  templateId: string | null;
484
487
  invoiceId: string | null;
@@ -499,19 +502,19 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
499
502
  scheduledFor: string | null;
500
503
  } | null;
501
504
  invoiceNotification: {
505
+ metadata: {
506
+ [x: string]: import("hono/utils/types").JSONValue;
507
+ } | null;
502
508
  id: string;
503
- status: "cancelled" | "pending" | "failed" | "sent";
504
- personId: string | null;
505
- organizationId: string | null;
506
509
  createdAt: string;
507
510
  updatedAt: string;
511
+ organizationId: string | null;
512
+ status: "pending" | "cancelled" | "failed" | "sent";
513
+ personId: string | null;
508
514
  bookingId: string | null;
509
- metadata: {
510
- [x: string]: import("hono/utils/types").JSONValue;
511
- } | null;
512
515
  channel: "email" | "sms";
513
516
  provider: string;
514
- targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
517
+ targetType: "organization" | "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "person" | "payment_session";
515
518
  targetId: string | null;
516
519
  templateId: string | null;
517
520
  invoiceId: string | null;
@@ -532,24 +535,24 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
532
535
  scheduledFor: string | null;
533
536
  } | null;
534
537
  session: {
538
+ metadata: {
539
+ [x: string]: import("hono/utils/types").JSONValue;
540
+ } | null;
535
541
  id: string;
536
- status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
542
+ createdAt: string;
543
+ updatedAt: string;
544
+ expiresAt: string | null;
545
+ status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
546
+ currency: string;
547
+ notes: string | null;
537
548
  expiredAt: string | null;
538
549
  cancelledAt: string | null;
539
550
  completedAt: string | null;
540
- createdAt: string;
541
- updatedAt: string;
542
551
  bookingId: string | null;
543
- notes: string | null;
544
- metadata: {
545
- [x: string]: import("hono/utils/types").JSONValue;
546
- } | null;
547
- expiresAt: string | null;
548
552
  provider: string | null;
549
553
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
550
554
  targetId: string | null;
551
555
  orderId: string | null;
552
- currency: string;
553
556
  invoiceId: string | null;
554
557
  amountCents: number;
555
558
  bookingPaymentScheduleId: string | null;
@@ -609,7 +612,7 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
609
612
  error: string;
610
613
  };
611
614
  outputFormat: "json";
612
- status: 500 | 404 | 409 | 502;
615
+ status: 404 | 409 | 500 | 502;
613
616
  };
614
617
  };
615
618
  } & {
@@ -621,24 +624,24 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
621
624
  action: "processing" | "completed" | "failed" | "ignored";
622
625
  reason?: string | undefined;
623
626
  session: {
627
+ metadata: {
628
+ [x: string]: import("hono/utils/types").JSONValue;
629
+ } | null;
624
630
  id: string;
625
- status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
631
+ createdAt: string;
632
+ updatedAt: string;
633
+ expiresAt: string | null;
634
+ status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
635
+ currency: string;
636
+ notes: string | null;
626
637
  expiredAt: string | null;
627
638
  cancelledAt: string | null;
628
639
  completedAt: string | null;
629
- createdAt: string;
630
- updatedAt: string;
631
640
  bookingId: string | null;
632
- notes: string | null;
633
- metadata: {
634
- [x: string]: import("hono/utils/types").JSONValue;
635
- } | null;
636
- expiresAt: string | null;
637
641
  provider: string | null;
638
642
  targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
639
643
  targetId: string | null;
640
644
  orderId: string | null;
641
- currency: string;
642
645
  invoiceId: string | null;
643
646
  amountCents: number;
644
647
  bookingPaymentScheduleId: string | null;
@@ -703,7 +706,9 @@ export declare function createNetopiaFinanceRoutes(options?: NetopiaRuntimeOptio
703
706
  };
704
707
  }, "/", "/providers/netopia/config">;
705
708
  export declare function createNetopiaFinanceExtension(options?: NetopiaRuntimeOptions): HonoExtension;
706
- export declare function netopiaHonoPlugin(options?: NetopiaRuntimeOptions): HonoPlugin;
709
+ export declare function netopiaHonoBundle(options?: NetopiaRuntimeOptions): HonoBundle;
710
+ /** @deprecated Prefer {@link netopiaHonoBundle}. */
711
+ export declare const netopiaHonoPlugin: typeof netopiaHonoBundle;
707
712
  export declare const netopiaFinanceExtension: HonoExtension;
708
713
  export {};
709
714
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AASvD,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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GAAG,UAAU,CAYjF;AAED,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,0BAAoB,CAAA;AAElD,eAAO,MAAM,uBAAuB,eAAkC,CAAA"}
package/dist/plugin.js CHANGED
@@ -1,8 +1,20 @@
1
- import { defineHonoPlugin } from "@voyantjs/hono";
1
+ import { defineHonoBundle, parseJsonBody } from "@voyantjs/hono";
2
2
  import { Hono } from "hono";
3
3
  import { resolveNetopiaRuntimeOptions } from "./client.js";
4
4
  import { netopiaService } from "./service.js";
5
5
  import { netopiaCollectBookingGuaranteeSchema, netopiaCollectBookingScheduleSchema, netopiaCollectInvoiceSchema, netopiaStartPaymentSessionSchema, netopiaWebhookPayloadSchema, } from "./validation.js";
6
+ export const NETOPIA_RUNTIME_CONTAINER_KEY = "providers.netopia.runtime";
7
+ function getNetopiaRuntime(bindings, options, resolveFromContainer) {
8
+ if (resolveFromContainer) {
9
+ try {
10
+ return resolveFromContainer(NETOPIA_RUNTIME_CONTAINER_KEY);
11
+ }
12
+ catch {
13
+ // Fall through to per-request resolution when bootstrap has not run.
14
+ }
15
+ }
16
+ return resolveNetopiaRuntimeOptions(bindings, options);
17
+ }
6
18
  export function createNetopiaFinanceRoutes(options = {}) {
7
19
  const handleNetopiaError = (message) => {
8
20
  if (message.includes("not found") ||
@@ -24,11 +36,13 @@ export function createNetopiaFinanceRoutes(options = {}) {
24
36
  }
25
37
  return { status: 502, message };
26
38
  };
39
+ const resolveRuntime = (c) => getNetopiaRuntime(c.env, options, (key) => c.var.container.resolve(key));
27
40
  return new Hono()
28
41
  .post("/providers/netopia/payment-sessions/:sessionId/start", async (c) => {
29
42
  try {
30
- const data = netopiaStartPaymentSessionSchema.parse(await c.req.json());
31
- const result = await netopiaService.startPaymentSession(c.get("db"), c.req.param("sessionId"), data, options, undefined, c.env);
43
+ const data = await parseJsonBody(c, netopiaStartPaymentSessionSchema);
44
+ const runtime = resolveRuntime(c);
45
+ const result = await netopiaService.startPaymentSession(c.get("db"), c.req.param("sessionId"), data, runtime, undefined);
32
46
  return c.json({ data: result }, 201);
33
47
  }
34
48
  catch (error) {
@@ -47,8 +61,9 @@ export function createNetopiaFinanceRoutes(options = {}) {
47
61
  })
48
62
  .post("/providers/netopia/bookings/:bookingId/payment-schedules/:scheduleId/collect", async (c) => {
49
63
  try {
50
- const data = netopiaCollectBookingScheduleSchema.parse(await c.req.json());
51
- const result = await netopiaService.collectBookingSchedule(c.get("db"), c.req.param("scheduleId"), data, options, undefined, undefined, c.env);
64
+ const data = await parseJsonBody(c, netopiaCollectBookingScheduleSchema);
65
+ const runtime = resolveRuntime(c);
66
+ const result = await netopiaService.collectBookingSchedule(c.get("db"), c.req.param("scheduleId"), data, runtime, undefined, undefined, c.env);
52
67
  return c.json({ data: result }, 201);
53
68
  }
54
69
  catch (error) {
@@ -59,8 +74,9 @@ export function createNetopiaFinanceRoutes(options = {}) {
59
74
  })
60
75
  .post("/providers/netopia/bookings/:bookingId/guarantees/:guaranteeId/collect", async (c) => {
61
76
  try {
62
- const data = netopiaCollectBookingGuaranteeSchema.parse(await c.req.json());
63
- const result = await netopiaService.collectBookingGuarantee(c.get("db"), c.req.param("guaranteeId"), data, options, undefined, undefined, c.env);
77
+ const data = await parseJsonBody(c, netopiaCollectBookingGuaranteeSchema);
78
+ const runtime = resolveRuntime(c);
79
+ const result = await netopiaService.collectBookingGuarantee(c.get("db"), c.req.param("guaranteeId"), data, runtime, undefined, undefined, c.env);
64
80
  return c.json({ data: result }, 201);
65
81
  }
66
82
  catch (error) {
@@ -71,8 +87,9 @@ export function createNetopiaFinanceRoutes(options = {}) {
71
87
  })
72
88
  .post("/providers/netopia/invoices/:invoiceId/collect", async (c) => {
73
89
  try {
74
- const data = netopiaCollectInvoiceSchema.parse(await c.req.json());
75
- const result = await netopiaService.collectInvoice(c.get("db"), c.req.param("invoiceId"), data, options, undefined, undefined, c.env);
90
+ const data = await parseJsonBody(c, netopiaCollectInvoiceSchema);
91
+ const runtime = resolveRuntime(c);
92
+ const result = await netopiaService.collectInvoice(c.get("db"), c.req.param("invoiceId"), data, runtime, undefined, undefined, c.env);
76
93
  return c.json({ data: result }, 201);
77
94
  }
78
95
  catch (error) {
@@ -82,13 +99,14 @@ export function createNetopiaFinanceRoutes(options = {}) {
82
99
  }
83
100
  })
84
101
  .post("/providers/netopia/callback", async (c) => {
85
- const payload = netopiaWebhookPayloadSchema.parse(await c.req.json());
86
- const result = await netopiaService.handleCallback(c.get("db"), payload, options, c.env);
102
+ const payload = await parseJsonBody(c, netopiaWebhookPayloadSchema);
103
+ const runtime = resolveRuntime(c);
104
+ const result = await netopiaService.handleCallback(c.get("db"), payload, runtime);
87
105
  return c.json({ data: result });
88
106
  })
89
107
  .get("/providers/netopia/config", async (c) => {
90
108
  try {
91
- const runtime = resolveNetopiaRuntimeOptions(c.env, options);
109
+ const runtime = resolveRuntime(c);
92
110
  return c.json({
93
111
  data: {
94
112
  apiUrl: runtime.apiUrl,
@@ -117,11 +135,16 @@ export function createNetopiaFinanceExtension(options = {}) {
117
135
  routes: createNetopiaFinanceRoutes(options),
118
136
  };
119
137
  }
120
- export function netopiaHonoPlugin(options = {}) {
121
- return defineHonoPlugin({
138
+ export function netopiaHonoBundle(options = {}) {
139
+ return defineHonoBundle({
122
140
  name: "netopia",
123
141
  version: "0.1.0",
142
+ bootstrap: ({ bindings, container }) => {
143
+ container.register(NETOPIA_RUNTIME_CONTAINER_KEY, resolveNetopiaRuntimeOptions(bindings, options));
144
+ },
124
145
  extensions: [createNetopiaFinanceExtension(options)],
125
146
  });
126
147
  }
148
+ /** @deprecated Prefer {@link netopiaHonoBundle}. */
149
+ export const netopiaHonoPlugin = netopiaHonoBundle;
127
150
  export const netopiaFinanceExtension = createNetopiaFinanceExtension();
@@ -1,5 +1,5 @@
1
1
  import { financeService, type PaymentSession } from "@voyantjs/finance";
2
- import { type NotificationDelivery, type NotificationService } from "@voyantjs/notifications";
2
+ import type { NotificationDelivery, NotificationService } from "@voyantjs/notifications";
3
3
  import type { z } from "zod";
4
4
  import type { NetopiaProductLine, NetopiaRuntimeOptions, NetopiaStartPaymentResponse, ResolvedNetopiaRuntimeOptions } from "./types.js";
5
5
  import type { netopiaCollectBookingGuaranteeSchema, netopiaCollectBookingScheduleSchema, netopiaCollectInvoiceSchema } from "./validation.js";
@@ -1 +1 @@
1
- {"version":3,"file":"service-shared.d.ts","sourceRoot":"","sources":["../src/service-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,oCAAoC,EACpC,mCAAmC,EACnC,2BAA2B,EAC5B,MAAM,iBAAiB,CAAA;AAExB,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,2BAA2B,CAAA;IAC7C,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;IACzD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,GAAG,IAAI,CAAA;IAC9B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,2BAA4B,SAAQ,yBAAyB;IAC5E,0BAA0B,EAAE,oBAAoB,GAAG,IAAI,CAAA;IACvD,mBAAmB,EAAE,oBAAoB,GAAG,IAAI,CAAA;CACjD;AAED,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;AACpG,MAAM,MAAM,mC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AK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,MAAM,GAClB,kBAAkB,EAAE,CAQtB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,UAE3D;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,6BAA6B,EAAE,iBAAiB,GAAG,oBAAoB,CAAC,GACrF,WAAW,GAAG,YAAY,GAAG,QAAQ,CAIvC;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,cAAc,EAAE,qBAAqB,EACrC,kBAAkB,CAAC,EAAE,mBAAmB,uBAGzC;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { financeService } from "@voyantjs/finance";
2
- import { createDefaultNotificationProviders, createNotificationService, } from "@voyantjs/notifications";
2
+ import { buildNetopiaNotificationRuntime } from "./notification-runtime.js";
3
3
  export function centsToAmount(cents) {
4
4
  return Number((cents / 100).toFixed(2));
5
5
  }
@@ -35,10 +35,6 @@ export function mapNetopiaPaymentStatus(status, options) {
35
35
  return "failed";
36
36
  }
37
37
  export function resolveNotificationDispatcher(bindings, runtimeOptions, dispatcherOverride) {
38
- if (dispatcherOverride) {
39
- return dispatcherOverride;
40
- }
41
- return createNotificationService(runtimeOptions.resolveNotificationProviders?.(bindings ?? {}) ??
42
- createDefaultNotificationProviders(bindings ?? {}));
38
+ return buildNetopiaNotificationRuntime(bindings, runtimeOptions, dispatcherOverride).dispatcher;
43
39
  }
44
40
  export { financeService };
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { NetopiaFetch } from "./types.js";
2
3
  export declare const netopiaBillingAddressSchema: z.ZodObject<{
3
4
  email: z.ZodString;
4
5
  phone: z.ZodString;
@@ -34,6 +35,31 @@ export declare const netopiaPaymentInstrumentSchema: z.ZodObject<{
34
35
  token: z.ZodOptional<z.ZodString>;
35
36
  }, z.core.$strip>;
36
37
  export declare const netopiaBrowserDataSchema: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>;
38
+ export declare const netopiaRuntimeOptionsSchema: z.ZodObject<{
39
+ apiUrl: z.ZodOptional<z.ZodString>;
40
+ apiKey: z.ZodOptional<z.ZodString>;
41
+ posSignature: z.ZodOptional<z.ZodString>;
42
+ notifyUrl: z.ZodOptional<z.ZodString>;
43
+ redirectUrl: z.ZodOptional<z.ZodString>;
44
+ emailTemplate: z.ZodOptional<z.ZodString>;
45
+ language: z.ZodOptional<z.ZodString>;
46
+ successStatuses: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
47
+ processingStatuses: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
48
+ fetch: z.ZodOptional<z.ZodCustom<NetopiaFetch | undefined, NetopiaFetch | undefined>>;
49
+ resolveNotificationProviders: z.ZodOptional<z.ZodCustom<((bindings: Record<string, unknown>) => ReadonlyArray<import("@voyantjs/notifications").NotificationProvider>) | undefined, ((bindings: Record<string, unknown>) => ReadonlyArray<import("@voyantjs/notifications").NotificationProvider>) | undefined>>;
50
+ }, z.core.$strip>;
51
+ export declare const resolvedNetopiaRuntimeOptionsSchema: z.ZodObject<{
52
+ apiUrl: z.ZodString;
53
+ apiKey: z.ZodString;
54
+ posSignature: z.ZodString;
55
+ notifyUrl: z.ZodString;
56
+ redirectUrl: z.ZodString;
57
+ emailTemplate: z.ZodDefault<z.ZodString>;
58
+ language: z.ZodDefault<z.ZodString>;
59
+ successStatuses: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
60
+ processingStatuses: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
61
+ fetch: z.ZodOptional<z.ZodCustom<NetopiaFetch | undefined, NetopiaFetch | undefined>>;
62
+ }, z.core.$strip>;
37
63
  export declare const netopiaStartPaymentSessionSchema: z.ZodObject<{
38
64
  description: z.ZodOptional<z.ZodString>;
39
65
  notifyUrl: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,2BAA2B;;;;;;;;;;iBAUtC,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;;;;iBAMnC,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;iBAGpC,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAA;AAEF,eAAO,MAAM,8BAA8B;;;;;;;iBAOzC,CAAA;AAEF,eAAO,MAAM,wBAAwB,sDAA8C,CAAA;AAEnF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkB3C,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;iBA4BtC,CAAA;AAEF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI9C,CAAA;AAEF,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI/C,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKtC,CAAA"}
@@ -36,6 +36,36 @@ export const netopiaPaymentInstrumentSchema = z.object({
36
36
  token: z.string().optional(),
37
37
  });
38
38
  export const netopiaBrowserDataSchema = z.record(z.string(), z.string().optional());
39
+ const optionalRuntimeUrl = z.string().trim().url().optional();
40
+ const optionalRuntimeString = z.string().trim().min(1).optional();
41
+ const optionalIntegerArray = z.array(z.number().int()).min(1).optional();
42
+ const optionalFetch = z.custom((value) => value === undefined || typeof value === "function", "Expected a fetch implementation function");
43
+ const optionalProviderResolver = z.custom((value) => value === undefined || typeof value === "function", "Expected a notification provider resolver function");
44
+ export const netopiaRuntimeOptionsSchema = z.object({
45
+ apiUrl: optionalRuntimeUrl,
46
+ apiKey: optionalRuntimeString,
47
+ posSignature: optionalRuntimeString,
48
+ notifyUrl: optionalRuntimeUrl,
49
+ redirectUrl: optionalRuntimeUrl,
50
+ emailTemplate: optionalRuntimeString,
51
+ language: optionalRuntimeString,
52
+ successStatuses: optionalIntegerArray,
53
+ processingStatuses: optionalIntegerArray,
54
+ fetch: optionalFetch.optional(),
55
+ resolveNotificationProviders: optionalProviderResolver.optional(),
56
+ });
57
+ export const resolvedNetopiaRuntimeOptionsSchema = z.object({
58
+ apiUrl: z.string().trim().url(),
59
+ apiKey: z.string().trim().min(1),
60
+ posSignature: z.string().trim().min(1),
61
+ notifyUrl: z.string().trim().url(),
62
+ redirectUrl: z.string().trim().url(),
63
+ emailTemplate: z.string().trim().min(1).default("confirm"),
64
+ language: z.string().trim().min(1).default("ro"),
65
+ successStatuses: z.array(z.number().int()).min(1).default([3, 5]),
66
+ processingStatuses: z.array(z.number().int()).min(1).default([1, 15]),
67
+ fetch: optionalFetch.optional(),
68
+ });
39
69
  export const netopiaStartPaymentSessionSchema = z.object({
40
70
  description: z.string().optional(),
41
71
  notifyUrl: z.string().url().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/plugin-netopia",
3
- "version": "0.5.0",
3
+ "version": "0.6.2",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -33,11 +33,11 @@
33
33
  "drizzle-orm": "^0.45.2",
34
34
  "hono": "^4.12.10",
35
35
  "zod": "^4.3.6",
36
- "@voyantjs/checkout": "0.5.0",
37
- "@voyantjs/core": "0.5.0",
38
- "@voyantjs/finance": "0.5.0",
39
- "@voyantjs/hono": "0.5.0",
40
- "@voyantjs/notifications": "0.5.0"
36
+ "@voyantjs/checkout": "0.6.2",
37
+ "@voyantjs/core": "0.6.2",
38
+ "@voyantjs/finance": "0.6.2",
39
+ "@voyantjs/hono": "0.6.2",
40
+ "@voyantjs/notifications": "0.6.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "typescript": "^6.0.2",