@payabli/component-contracts 0.4.0 → 0.6.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/dist/aliases.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  import type { ComponentEventMap } from './registry.js';
2
2
  export type PayInEvents = ComponentEventMap<'payin'>;
3
+ export type OnboardingEvents = ComponentEventMap<'onboarding'>;
4
+ export type PayoutEvents = ComponentEventMap<'payout'>;
@@ -1 +1,3 @@
1
+ export * from './onboarding/definition.js';
1
2
  export * from './payin/definition.js';
3
+ export * from './payout/definition.js';
package/dist/index.js CHANGED
@@ -1669,6 +1669,27 @@ function getComponentDescriptor(type) {
1669
1669
  return descriptors.get(type);
1670
1670
  }
1671
1671
 
1672
+ /**
1673
+ * Onboarding's wire contract. The boarding request owns all business data, so
1674
+ * the browser sends no options yet. The SDK sends this in CONFIG_SET.options
1675
+ * and payhub parses with this same object.
1676
+ */
1677
+ const onboardingOptionsSchema = object({});
1678
+ /** Onboarding's own inbound events, beyond the base set every component shares. */
1679
+ const onboardingEvents = {};
1680
+
1681
+ /** Wire type → emitter event. Onboarding emits only the base events for now. */
1682
+ const onboardingEventSchemas = {};
1683
+ const onboardingDescriptor = register({
1684
+ type: 'onboarding',
1685
+ displayName: 'Onboarding',
1686
+ frameLabel: 'Onboarding form',
1687
+ embedPath: '/embed/onboarding',
1688
+ endsOnSuccess: false,
1689
+ optionsSchema: onboardingOptionsSchema,
1690
+ eventSchemas: onboardingEventSchemas,
1691
+ });
1692
+
1672
1693
  /**
1673
1694
  * PayIn's wire contract: its event schemas, options schema, and vocabulary.
1674
1695
  * PayIn-specific on purpose — a payout component defines its own methods in
@@ -1771,7 +1792,6 @@ const payinEvents = {
1771
1792
  status: _enum(['verified', 'pending', 'failed', 'warning']),
1772
1793
  message: optional(string()),
1773
1794
  }),
1774
- VENDOR_CREATED: object({ vendorId: string() }),
1775
1795
  };
1776
1796
 
1777
1797
  /**
@@ -1796,20 +1816,79 @@ const payInEventSchemas = {
1796
1816
  event: 'validationStatus',
1797
1817
  schema: payinEvents.VALIDATION_STATUS,
1798
1818
  },
1799
- VENDOR_CREATED: {
1800
- event: 'vendorCreated',
1801
- schema: payinEvents.VENDOR_CREATED,
1802
- },
1803
1819
  };
1804
1820
  const payInDescriptor = register({
1805
1821
  type: 'payin',
1806
1822
  displayName: 'PayIn',
1823
+ frameLabel: 'Payment form',
1807
1824
  embedPath: '/embed/payin',
1808
1825
  endsOnSuccess: true,
1809
1826
  optionsSchema: payinOptionsSchema,
1810
1827
  eventSchemas: payInEventSchemas,
1811
1828
  });
1812
1829
 
1830
+ /**
1831
+ * Payout's wire contract: its event schemas, options schema, and vocabulary.
1832
+ * Payout has its own methods. They do not share names with PayIn's.
1833
+ */
1834
+ const PAYOUT_METHODS = [
1835
+ 'ach',
1836
+ 'check',
1837
+ 'vcard',
1838
+ 'wire',
1839
+ 'rtp',
1840
+ ];
1841
+ /** Payout text keys. The iframe drops other keys, trims values, and limits text to 120 characters. */
1842
+ const PAYOUT_LABEL_KEYS = [
1843
+ 'submit',
1844
+ 'method-ach',
1845
+ 'method-check',
1846
+ 'method-vcard',
1847
+ 'method-wire',
1848
+ 'method-rtp',
1849
+ 'label.ach.holderName',
1850
+ 'placeholder.ach.holderName',
1851
+ 'label.ach.holderType',
1852
+ 'label.ach.accountType',
1853
+ 'label.ach.routingNumber',
1854
+ 'placeholder.ach.routingNumber',
1855
+ 'label.ach.accountNumber',
1856
+ 'placeholder.ach.accountNumber',
1857
+ 'label.vcard.code',
1858
+ ];
1859
+ /**
1860
+ * Client-side UI behavior only. The partner server sets operation, methods,
1861
+ * vendorData, paymentDetails, invoiceData, and saveIfSuccess through
1862
+ * `Session/init`. The SDK sends this in CONFIG_SET.options and payhub parses
1863
+ * with this same object.
1864
+ */
1865
+ const payoutOptionsSchema = object({
1866
+ initialMethod: optional(_enum(PAYOUT_METHODS)
1867
+ .check(describe('Select this method first when session-allowed. Otherwise, use the first method in the effective order.'))),
1868
+ methodOrder: optional(array(_enum(PAYOUT_METHODS))
1869
+ .check(describe('Order session-allowed methods only. Ignore disallowed entries and duplicates after the first occurrence. Append unlisted allowed methods in the PAYOUT_METHODS order.'))),
1870
+ showSubmitButton: optional(boolean()
1871
+ .check(describe('Render the submit button inside the component. Set false when the host page owns the button and calls submit().'))),
1872
+ });
1873
+ /** Payout's own inbound events, beyond the base set every component shares. */
1874
+ const payoutEvents = {
1875
+ METHOD_CHANGE: object({ method: _enum(PAYOUT_METHODS) }),
1876
+ };
1877
+
1878
+ /** Wire type → emitter event, with the shared schema from `./schema.js` as the only validator. */
1879
+ const payoutEventSchemas = {
1880
+ METHOD_CHANGE: { event: 'methodChange', schema: payoutEvents.METHOD_CHANGE },
1881
+ };
1882
+ const payoutDescriptor = register({
1883
+ type: 'payout',
1884
+ displayName: 'Payout',
1885
+ frameLabel: 'Payout form',
1886
+ embedPath: '/embed/payout',
1887
+ endsOnSuccess: false,
1888
+ optionsSchema: payoutOptionsSchema,
1889
+ eventSchemas: payoutEventSchemas,
1890
+ });
1891
+
1813
1892
  const ErrorCodes = {
1814
1893
  LOAD_TIMEOUT: 'LOAD_TIMEOUT',
1815
1894
  PROTOCOL_ERROR: 'PROTOCOL_ERROR',
@@ -1851,4 +1930,4 @@ const BASE_COMPONENT_EVENT_NAMES = [
1851
1930
  'resize',
1852
1931
  ];
1853
1932
 
1854
- export { BASE_COMPONENT_EVENT_NAMES, CARD_BRANDS, ErrorCodes, FORM_METHODS, MESSAGE_SOURCE, MESSAGE_VERSION, PAYIN_LABEL_KEYS, PAYMENT_METHODS, appearanceSchema, baseInboundEvents, componentDescriptors, componentErrorSchema, componentTypes, eventEnvelopeSchema, getComponentDescriptor, outboundMessages, parseEnvelope, parseMessage, parsePayload, payInDescriptor, payInEventSchemas, payinEvents, payinOptionsSchema, register };
1933
+ export { BASE_COMPONENT_EVENT_NAMES, CARD_BRANDS, ErrorCodes, FORM_METHODS, MESSAGE_SOURCE, MESSAGE_VERSION, PAYIN_LABEL_KEYS, PAYMENT_METHODS, PAYOUT_LABEL_KEYS, PAYOUT_METHODS, appearanceSchema, baseInboundEvents, componentDescriptors, componentErrorSchema, componentTypes, eventEnvelopeSchema, getComponentDescriptor, onboardingDescriptor, onboardingEventSchemas, onboardingEvents, onboardingOptionsSchema, outboundMessages, parseEnvelope, parseMessage, parsePayload, payInDescriptor, payInEventSchemas, payinEvents, payinOptionsSchema, payoutDescriptor, payoutEventSchemas, payoutEvents, payoutOptionsSchema, register };
@@ -0,0 +1,13 @@
1
+ import type { Infer, InferEvents } from '../protocol/envelope.js';
2
+ import { onboardingEvents, onboardingOptionsSchema } from './schema.js';
3
+ export * from './schema.js';
4
+ /** The partner-facing options type is the wire schema's type. */
5
+ export type OnboardingOptions = Infer<typeof onboardingOptionsSchema>;
6
+ declare module '../registry.js' {
7
+ interface ComponentDefinitions {
8
+ onboarding: ComponentDefinition<OnboardingOptions, InferEvents<typeof onboardingEvents>>;
9
+ }
10
+ }
11
+ /** Wire type → emitter event. Onboarding emits only the base events for now. */
12
+ export declare const onboardingEventSchemas: {};
13
+ export declare const onboardingDescriptor: import("../registry.js").ComponentDescriptor<"onboarding">;
@@ -0,0 +1,9 @@
1
+ import * as z from 'zod/v4/mini';
2
+ /**
3
+ * Onboarding's wire contract. The boarding request owns all business data, so
4
+ * the browser sends no options yet. The SDK sends this in CONFIG_SET.options
5
+ * and payhub parses with this same object.
6
+ */
7
+ export declare const onboardingOptionsSchema: z.ZodMiniObject<{}, z.core.$strip>;
8
+ /** Onboarding's own inbound events, beyond the base set every component shares. */
9
+ export declare const onboardingEvents: {};
@@ -80,11 +80,5 @@ export declare const payInEventSchemas: {
80
80
  message: import("zod/v4/mini").ZodMiniOptional<import("zod/v4/mini").ZodMiniString<string>>;
81
81
  }, import("zod/v4/core").$strip>;
82
82
  };
83
- VENDOR_CREATED: {
84
- event: "vendorCreated";
85
- schema: import("zod/v4/mini").ZodMiniObject<{
86
- vendorId: import("zod/v4/mini").ZodMiniString<string>;
87
- }, import("zod/v4/core").$strip>;
88
- };
89
83
  };
90
84
  export declare const payInDescriptor: import("../registry.js").ComponentDescriptor<"payin">;
@@ -88,9 +88,6 @@ export declare const payinEvents: {
88
88
  }>;
89
89
  message: z.ZodMiniOptional<z.ZodMiniString<string>>;
90
90
  }, z.core.$strip>;
91
- readonly VENDOR_CREATED: z.ZodMiniObject<{
92
- vendorId: z.ZodMiniString<string>;
93
- }, z.core.$strip>;
94
91
  };
95
92
  /** The session operation the payload reports on. */
96
93
  export type PayInOperation = 'pay' | 'auth' | 'tokenize';
@@ -0,0 +1,29 @@
1
+ import type { Infer, InferEvents } from '../protocol/envelope.js';
2
+ import { payoutEvents, payoutOptionsSchema } from './schema.js';
3
+ import type { PayoutSuccessPayload } from './schema.js';
4
+ export * from './schema.js';
5
+ /** The partner-facing options type is the wire schema's type. */
6
+ export type PayoutOptions = Infer<typeof payoutOptionsSchema>;
7
+ declare module '../registry.js' {
8
+ interface ComponentDefinitions {
9
+ payout: ComponentDefinition<PayoutOptions, InferEvents<typeof payoutEvents> & {
10
+ success: PayoutSuccessPayload;
11
+ }>;
12
+ }
13
+ }
14
+ /** Wire type → emitter event, with the shared schema from `./schema.js` as the only validator. */
15
+ export declare const payoutEventSchemas: {
16
+ METHOD_CHANGE: {
17
+ event: "methodChange";
18
+ schema: import("zod/v4/mini").ZodMiniObject<{
19
+ method: import("zod/v4/mini").ZodMiniEnum<{
20
+ ach: "ach";
21
+ check: "check";
22
+ vcard: "vcard";
23
+ wire: "wire";
24
+ rtp: "rtp";
25
+ }>;
26
+ }, import("zod/v4/core").$strip>;
27
+ };
28
+ };
29
+ export declare const payoutDescriptor: import("../registry.js").ComponentDescriptor<"payout">;
@@ -0,0 +1,79 @@
1
+ import * as z from 'zod/v4/mini';
2
+ /**
3
+ * Payout's wire contract: its event schemas, options schema, and vocabulary.
4
+ * Payout has its own methods. They do not share names with PayIn's.
5
+ */
6
+ export declare const PAYOUT_METHODS: readonly ["ach", "check", "vcard", "wire", "rtp"];
7
+ export type PayoutMethodName = (typeof PAYOUT_METHODS)[number];
8
+ /** Payout text keys. The iframe drops other keys, trims values, and limits text to 120 characters. */
9
+ export declare const PAYOUT_LABEL_KEYS: readonly ["submit", "method-ach", "method-check", "method-vcard", "method-wire", "method-rtp", "label.ach.holderName", "placeholder.ach.holderName", "label.ach.holderType", "label.ach.accountType", "label.ach.routingNumber", "placeholder.ach.routingNumber", "label.ach.accountNumber", "placeholder.ach.accountNumber", "label.vcard.code"];
10
+ export type PayoutLabelKey = (typeof PAYOUT_LABEL_KEYS)[number];
11
+ /**
12
+ * Client-side UI behavior only. The partner server sets operation, methods,
13
+ * vendorData, paymentDetails, invoiceData, and saveIfSuccess through
14
+ * `Session/init`. The SDK sends this in CONFIG_SET.options and payhub parses
15
+ * with this same object.
16
+ */
17
+ export declare const payoutOptionsSchema: z.ZodMiniObject<{
18
+ initialMethod: z.ZodMiniOptional<z.ZodMiniEnum<{
19
+ ach: "ach";
20
+ check: "check";
21
+ vcard: "vcard";
22
+ wire: "wire";
23
+ rtp: "rtp";
24
+ }>>;
25
+ methodOrder: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
26
+ ach: "ach";
27
+ check: "check";
28
+ vcard: "vcard";
29
+ wire: "wire";
30
+ rtp: "rtp";
31
+ }>>>;
32
+ showSubmitButton: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
33
+ }, z.core.$strip>;
34
+ /** Payout's own inbound events, beyond the base set every component shares. */
35
+ export declare const payoutEvents: {
36
+ readonly METHOD_CHANGE: z.ZodMiniObject<{
37
+ method: z.ZodMiniEnum<{
38
+ ach: "ach";
39
+ check: "check";
40
+ vcard: "vcard";
41
+ wire: "wire";
42
+ rtp: "rtp";
43
+ }>;
44
+ }, z.core.$strip>;
45
+ };
46
+ /** The session operation the payload reports on. Same names as PayIn. */
47
+ export type PayoutOperation = 'pay' | 'auth' | 'tokenize';
48
+ /**
49
+ * SUBMIT_RESULT.data for Payout: the `success` event payload and the
50
+ * `submit()` result. One closed shape for every operation, like PayIn. payhub
51
+ * builds it from the API result. Card data, account numbers, and addresses
52
+ * never go in it.
53
+ */
54
+ export type PayoutSuccessPayload = {
55
+ operation: PayoutOperation;
56
+ /** The method the vendor used. */
57
+ method: PayoutMethodName;
58
+ /** The vendor from the session config. */
59
+ vendorId: number;
60
+ /** The MoneyOut transaction id. Present for `pay` and `auth`. */
61
+ transactionId?: string;
62
+ /**
63
+ * The saved vendor payment method id. Present for `tokenize`, and for `pay`
64
+ * or `auth` when the session saved the method.
65
+ */
66
+ storedMethodId?: string;
67
+ paymentMethod?: {
68
+ /** The account with every digit but the last four hidden. */
69
+ maskedAccount?: string;
70
+ accountType?: 'checking' | 'savings';
71
+ holderName?: string;
72
+ };
73
+ /** The paid or authorized amount. Present for `pay` and `auth`. */
74
+ amount?: {
75
+ total: number;
76
+ serviceFee?: number;
77
+ currency?: string;
78
+ };
79
+ };
@@ -26,6 +26,8 @@ export type EventSchemaDescriptor<EventName extends string = string> = {
26
26
  export type ComponentDescriptor<T extends ComponentType = ComponentType> = {
27
27
  type: T;
28
28
  displayName: string;
29
+ /** Accessible name of the component frame, such as "Payment form". */
30
+ frameLabel: string;
29
31
  embedPath: `/embed/${string}`;
30
32
  /** A successful submit ends this component, so the SDK destroys it after `success`. */
31
33
  endsOnSuccess: boolean;
package/dist/sdk.d.ts CHANGED
@@ -41,7 +41,8 @@ export interface CreateOptions<T extends ComponentType = ComponentType> {
41
41
  key?: string;
42
42
  appearance?: AppearanceOptions;
43
43
  options?: ComponentOptions<T>;
44
- prefill?: T extends 'payin' ? never : Record<string, string>;
44
+ /** Not supported by PayIn, Onboarding, or Payout: the server session owns their data. */
45
+ prefill?: T extends 'payin' | 'onboarding' | 'payout' ? never : Record<string, string>;
45
46
  locale?: string;
46
47
  timeout?: number;
47
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payabli/component-contracts",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Wire schemas, component registry, and partner-facing types shared by the Payabli embedded components SDK and payhub.",
5
5
  "private": false,
6
6
  "license": "MIT",