@guestyorg/tokenization-js 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +28 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guestyorg/tokenization-js",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Guesty Tokenization SDK loading utility and types",
5
5
  "main": "index.js",
6
6
  "module": "lib/esm/guesty-tokenization-js.js",
package/types/index.d.ts CHANGED
@@ -82,19 +82,29 @@ export interface GuestyTokenizationV2ApiV2SubmitPayload {
82
82
  apiVersion: 'v2';
83
83
  }
84
84
 
85
- export interface GuestyTokenizationV2ApiV3SubmitPayload {
85
+ type ReservationOrQuote =
86
+ | {
87
+ reservationId: string;
88
+ quoteId?: never;
89
+ guest?: never;
90
+ }
91
+ | {
92
+ quoteId: string;
93
+ guest: {
94
+ firstName: string;
95
+ lastName: string;
96
+ email?: string;
97
+ phone?: string;
98
+ };
99
+ reservationId?: never;
100
+ };
101
+
102
+ export type GuestyTokenizationV2ApiV3SubmitPayload = {
86
103
  listingId: string;
87
- quoteId: string;
88
104
  amount: number;
89
105
  currency: string;
90
- guest: {
91
- firstName: string;
92
- lastName: string;
93
- email?: string;
94
- phone?: string;
95
- };
96
106
  apiVersion?: 'v3';
97
- }
107
+ } & ReservationOrQuote;
98
108
 
99
109
  export type GuestyTokenizationV2SubmitPayload =
100
110
  | GuestyTokenizationV2ApiV2SubmitPayload
@@ -120,21 +130,21 @@ export interface GuestyTokenizationV2Namespace {
120
130
  validate: () => void;
121
131
  }
122
132
 
133
+ export interface LoadScriptOptions {
134
+ sandbox?: boolean;
135
+ version?: 'v1' | 'v2';
136
+ }
137
+
123
138
  type NamespaceBasedOnVersion<T extends LoadScriptOptions['version']> =
124
139
  T extends 'v1'
125
140
  ? GuestyTokenizationV1Namespace
126
141
  : T extends 'v2'
127
142
  ? GuestyTokenizationV2Namespace
128
- : GuestyTokenizationV1Namespace;
129
-
130
- export interface LoadScriptOptions {
131
- sandbox?: boolean;
132
- version?: 'v1' | 'v2';
133
- }
143
+ : never;
134
144
 
135
- export function loadScript(
136
- options?: LoadScriptOptions
137
- ): Promise<NamespaceBasedOnVersion<LoadScriptOptions['version']> | null>;
145
+ export function loadScript<T extends LoadScriptOptions['version']>(
146
+ options?: LoadScriptOptions & { version: T }
147
+ ): Promise<NamespaceBasedOnVersion<T> | null>;
138
148
 
139
149
  declare global {
140
150
  interface Window {