@grabjs/superapp-sdk 2.0.0-beta.14 → 2.0.0-beta.23
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 +170 -55
- package/{dist → api-reference/json}/api.json +17192 -7721
- package/api-reference/markdown/README.md +194 -0
- package/api-reference/markdown/classes/BaseModule.md +123 -0
- package/api-reference/markdown/classes/CameraModule.md +177 -0
- package/api-reference/markdown/classes/CheckoutModule.md +181 -0
- package/api-reference/markdown/classes/ContainerModule.md +751 -0
- package/api-reference/markdown/classes/DeviceCapabilityModule.md +161 -0
- package/api-reference/markdown/classes/FileModule.md +178 -0
- package/api-reference/markdown/classes/IdentityModule.md +299 -0
- package/api-reference/markdown/classes/LocaleModule.md +161 -0
- package/api-reference/markdown/classes/LocationModule.md +239 -0
- package/api-reference/markdown/classes/MediaModule.md +219 -0
- package/api-reference/markdown/classes/PlatformModule.md +162 -0
- package/api-reference/markdown/classes/ProfileModule.md +224 -0
- package/api-reference/markdown/classes/ScopeModule.md +219 -0
- package/api-reference/markdown/classes/StorageModule.md +608 -0
- package/api-reference/markdown/classes/SystemWebViewKitModule.md +177 -0
- package/api-reference/markdown/classes/UserAttributesModule.md +164 -0
- package/api-reference/markdown/functions/isClientError.md +37 -0
- package/api-reference/markdown/functions/isErrorResponse.md +40 -0
- package/api-reference/markdown/functions/isRedirection.md +37 -0
- package/api-reference/markdown/functions/isServerError.md +37 -0
- package/api-reference/markdown/functions/isSuccess.md +39 -0
- package/api-reference/markdown/globals.md +176 -0
- package/api-reference/markdown/interfaces/GrabAppInfo.md +23 -0
- package/api-reference/markdown/interfaces/InvokeOptions.md +63 -0
- package/api-reference/markdown/interfaces/Version.md +23 -0
- package/api-reference/markdown/interfaces/WrappedModule.md +51 -0
- package/api-reference/markdown/type-aliases/AuthorizeRequest.md +79 -0
- package/api-reference/markdown/type-aliases/AuthorizeResponse.md +58 -0
- package/api-reference/markdown/type-aliases/AuthorizeResult.md +33 -0
- package/api-reference/markdown/type-aliases/BackResponse.md +37 -0
- package/api-reference/markdown/type-aliases/BackResult.md +8 -0
- package/api-reference/markdown/type-aliases/BridgeClientError.md +9 -0
- package/api-reference/markdown/type-aliases/BridgeError.md +8 -0
- package/api-reference/markdown/type-aliases/BridgeRedirection.md +8 -0
- package/api-reference/markdown/type-aliases/BridgeResponse.md +40 -0
- package/api-reference/markdown/type-aliases/BridgeServerError.md +8 -0
- package/api-reference/markdown/type-aliases/BridgeStatusCode.md +7 -0
- package/api-reference/markdown/type-aliases/BridgeStream.md +29 -0
- package/api-reference/markdown/type-aliases/BridgeStreamHandlers.md +25 -0
- package/api-reference/markdown/type-aliases/BridgeSuccessResponse.md +14 -0
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResponse.md +18 -0
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResult.md +8 -0
- package/api-reference/markdown/type-aliases/CloseResponse.md +37 -0
- package/api-reference/markdown/type-aliases/CloseResult.md +8 -0
- package/api-reference/markdown/type-aliases/DRMContentConfig.md +34 -0
- package/api-reference/markdown/type-aliases/DRMPlaybackEvent.md +43 -0
- package/api-reference/markdown/type-aliases/DownloadFileRequest.md +32 -0
- package/api-reference/markdown/type-aliases/DownloadFileResponse.md +48 -0
- package/api-reference/markdown/type-aliases/DownloadFileResult.md +11 -0
- package/api-reference/markdown/type-aliases/ErrorResponse.md +32 -0
- package/api-reference/markdown/type-aliases/FetchEmailResponse.md +58 -0
- package/api-reference/markdown/type-aliases/FetchEmailResult.md +21 -0
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResponse.md +42 -0
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResult.md +57 -0
- package/api-reference/markdown/type-aliases/GetBooleanRequest.md +21 -0
- package/api-reference/markdown/type-aliases/GetBooleanResponse.md +57 -0
- package/api-reference/markdown/type-aliases/GetBooleanResult.md +27 -0
- package/api-reference/markdown/type-aliases/GetCoordinateResponse.md +49 -0
- package/api-reference/markdown/type-aliases/GetCoordinateResult.md +29 -0
- package/api-reference/markdown/type-aliases/GetCountryCodeResponse.md +57 -0
- package/api-reference/markdown/type-aliases/GetCountryCodeResult.md +25 -0
- package/api-reference/markdown/type-aliases/GetDoubleRequest.md +21 -0
- package/api-reference/markdown/type-aliases/GetDoubleResponse.md +57 -0
- package/api-reference/markdown/type-aliases/GetDoubleResult.md +27 -0
- package/api-reference/markdown/type-aliases/GetIntRequest.md +21 -0
- package/api-reference/markdown/type-aliases/GetIntResponse.md +57 -0
- package/api-reference/markdown/type-aliases/GetIntResult.md +27 -0
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResponse.md +48 -0
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResult.md +31 -0
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResponse.md +48 -0
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResult.md +17 -0
- package/api-reference/markdown/type-aliases/GetSessionParamsResponse.md +40 -0
- package/api-reference/markdown/type-aliases/GetSessionParamsResult.md +27 -0
- package/api-reference/markdown/type-aliases/GetStringRequest.md +21 -0
- package/api-reference/markdown/type-aliases/GetStringResponse.md +57 -0
- package/api-reference/markdown/type-aliases/GetStringResult.md +27 -0
- package/api-reference/markdown/type-aliases/HasAccessToResponse.md +66 -0
- package/api-reference/markdown/type-aliases/HasAccessToResult.md +27 -0
- package/api-reference/markdown/type-aliases/HideBackButtonResponse.md +37 -0
- package/api-reference/markdown/type-aliases/HideBackButtonResult.md +8 -0
- package/api-reference/markdown/type-aliases/HideLoaderResponse.md +37 -0
- package/api-reference/markdown/type-aliases/HideLoaderResult.md +8 -0
- package/api-reference/markdown/type-aliases/HideRefreshButtonResponse.md +37 -0
- package/api-reference/markdown/type-aliases/HideRefreshButtonResult.md +8 -0
- package/api-reference/markdown/type-aliases/IsConnectedResponse.md +31 -0
- package/api-reference/markdown/type-aliases/IsConnectedResult.md +27 -0
- package/api-reference/markdown/type-aliases/IsEsimSupportedResponse.md +48 -0
- package/api-reference/markdown/type-aliases/IsEsimSupportedResult.md +17 -0
- package/api-reference/markdown/type-aliases/ObserveDRMPlaybackResponse.md +15 -0
- package/api-reference/markdown/type-aliases/ObserveLocationChangeResponse.md +15 -0
- package/api-reference/markdown/type-aliases/OnContentLoadedResponse.md +37 -0
- package/api-reference/markdown/type-aliases/OnContentLoadedResult.md +8 -0
- package/api-reference/markdown/type-aliases/OnCtaTapRequest.md +13 -0
- package/api-reference/markdown/type-aliases/OnCtaTapResponse.md +37 -0
- package/api-reference/markdown/type-aliases/OnCtaTapResult.md +8 -0
- package/api-reference/markdown/type-aliases/OpenExternalLinkRequest.md +13 -0
- package/api-reference/markdown/type-aliases/OpenExternalLinkResponse.md +46 -0
- package/api-reference/markdown/type-aliases/OpenExternalLinkResult.md +8 -0
- package/api-reference/markdown/type-aliases/Platform.md +7 -0
- package/api-reference/markdown/type-aliases/PlayDRMContentResponse.md +43 -0
- package/api-reference/markdown/type-aliases/PlayDRMContentResult.md +8 -0
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewRequest.md +23 -0
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResponse.md +55 -0
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResult.md +8 -0
- package/api-reference/markdown/type-aliases/ReloadScopesResponse.md +46 -0
- package/api-reference/markdown/type-aliases/ReloadScopesResult.md +8 -0
- package/api-reference/markdown/type-aliases/RemoveAllResponse.md +37 -0
- package/api-reference/markdown/type-aliases/RemoveAllResult.md +8 -0
- package/api-reference/markdown/type-aliases/RemoveResponse.md +46 -0
- package/api-reference/markdown/type-aliases/RemoveResult.md +8 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode200.md +34 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode204.md +20 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode302.md +20 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode400.md +7 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode401.md +7 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode403.md +7 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode404.md +7 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode424.md +7 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode426.md +12 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode500.md +7 -0
- package/api-reference/markdown/type-aliases/ResponseStatusCode501.md +12 -0
- package/api-reference/markdown/type-aliases/ScanQRCodeRequest.md +27 -0
- package/api-reference/markdown/type-aliases/ScanQRCodeResponse.md +64 -0
- package/api-reference/markdown/type-aliases/ScanQRCodeResult.md +21 -0
- package/api-reference/markdown/type-aliases/SendAnalyticsEventRequest.md +56 -0
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResult.md +8 -0
- package/api-reference/markdown/type-aliases/SetBackgroundColorRequest.md +13 -0
- package/api-reference/markdown/type-aliases/SetBackgroundColorResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SetBackgroundColorResult.md +8 -0
- package/api-reference/markdown/type-aliases/SetBooleanResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SetBooleanResult.md +8 -0
- package/api-reference/markdown/type-aliases/SetDoubleResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SetDoubleResult.md +8 -0
- package/api-reference/markdown/type-aliases/SetIntResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SetIntResult.md +8 -0
- package/api-reference/markdown/type-aliases/SetStringResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SetStringResult.md +8 -0
- package/api-reference/markdown/type-aliases/SetTitleRequest.md +13 -0
- package/api-reference/markdown/type-aliases/SetTitleResponse.md +46 -0
- package/api-reference/markdown/type-aliases/SetTitleResult.md +8 -0
- package/api-reference/markdown/type-aliases/ShowBackButtonResponse.md +37 -0
- package/api-reference/markdown/type-aliases/ShowBackButtonResult.md +8 -0
- package/api-reference/markdown/type-aliases/ShowLoaderResponse.md +37 -0
- package/api-reference/markdown/type-aliases/ShowLoaderResult.md +8 -0
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResponse.md +37 -0
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResult.md +8 -0
- package/api-reference/markdown/type-aliases/StatusCodeMap.md +80 -0
- package/api-reference/markdown/type-aliases/Subscription.md +12 -0
- package/api-reference/markdown/type-aliases/TriggerCheckoutRequest.md +26 -0
- package/api-reference/markdown/type-aliases/TriggerCheckoutResponse.md +76 -0
- package/api-reference/markdown/type-aliases/TriggerCheckoutResult.md +75 -0
- package/api-reference/markdown/type-aliases/VerifyEmailRequest.md +32 -0
- package/api-reference/markdown/type-aliases/VerifyEmailResponse.md +55 -0
- package/api-reference/markdown/type-aliases/VerifyEmailResult.md +8 -0
- package/api-reference/markdown/variables/ContainerAnalyticsEventData.md +21 -0
- package/api-reference/markdown/variables/ContainerAnalyticsEventName.md +13 -0
- package/api-reference/markdown/variables/ContainerAnalyticsEventState.md +25 -0
- package/dist/index.d.ts +1825 -1298
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +22 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { DataStream as DataStream_2 } from '@grabjs/mobile-kit-bridge-sdk';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Request parameters for initiating an OAuth2 authorization flow with PKCE.
|
|
5
3
|
*
|
|
@@ -57,6 +55,10 @@ export declare type AuthorizeRequest = {
|
|
|
57
55
|
* - `302`: Redirect in progress (web redirect flow). The page will navigate away.
|
|
58
56
|
* - `204`: No content - user cancelled or flow completed without result data.
|
|
59
57
|
* - `400`: Bad request - missing required OAuth parameters or invalid configuration.
|
|
58
|
+
* - `401`: Unauthorized - user not authenticated or session expired.
|
|
59
|
+
* - `403`: Forbidden - client not authorized for the requested scope.
|
|
60
|
+
* - `500`: Internal server error - unexpected error during native authorization.
|
|
61
|
+
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
60
62
|
*
|
|
61
63
|
* @example
|
|
62
64
|
* **Success response (200) - native in_place flow:**
|
|
@@ -91,9 +93,18 @@ export declare type AuthorizeRequest = {
|
|
|
91
93
|
* }
|
|
92
94
|
* ```
|
|
93
95
|
*
|
|
96
|
+
* @example
|
|
97
|
+
* **Not implemented response (501) - outside Grab app:**
|
|
98
|
+
* ```typescript
|
|
99
|
+
* {
|
|
100
|
+
* status_code: 501,
|
|
101
|
+
* error: 'Not implemented: This method requires the Grab app environment'
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
94
105
|
* @public
|
|
95
106
|
*/
|
|
96
|
-
export declare type AuthorizeResponse =
|
|
107
|
+
export declare type AuthorizeResponse = BridgeResponse<200 | 302 | 204 | 400 | 401 | 403 | 500 | 501, AuthorizeResult>;
|
|
97
108
|
|
|
98
109
|
/**
|
|
99
110
|
* Result object for the authorization flow.
|
|
@@ -122,6 +133,7 @@ export declare type AuthorizeResult = {
|
|
|
122
133
|
* @remarks
|
|
123
134
|
* This response can have the following status codes:
|
|
124
135
|
* - `204`: Back navigation triggered successfully.
|
|
136
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
125
137
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
126
138
|
*
|
|
127
139
|
* @example
|
|
@@ -139,9 +151,18 @@ export declare type AuthorizeResult = {
|
|
|
139
151
|
* }
|
|
140
152
|
* ```
|
|
141
153
|
*
|
|
154
|
+
* @example
|
|
155
|
+
* **Internal server error response (500):**
|
|
156
|
+
* ```typescript
|
|
157
|
+
* {
|
|
158
|
+
* status_code: 500,
|
|
159
|
+
* error: 'Internal server error'
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
142
163
|
* @public
|
|
143
164
|
*/
|
|
144
|
-
export declare type BackResponse =
|
|
165
|
+
export declare type BackResponse = BridgeResponse<204 | 500 | 501, BackResult>;
|
|
145
166
|
|
|
146
167
|
/**
|
|
147
168
|
* Result when triggering platform back navigation.
|
|
@@ -170,7 +191,7 @@ export declare class BaseModule {
|
|
|
170
191
|
*
|
|
171
192
|
* @returns The wrapped module instance with native method bindings.
|
|
172
193
|
*
|
|
173
|
-
* @
|
|
194
|
+
* @public
|
|
174
195
|
*/
|
|
175
196
|
protected get wrappedModule(): WrappedModule;
|
|
176
197
|
/**
|
|
@@ -181,29 +202,53 @@ export declare class BaseModule {
|
|
|
181
202
|
*/
|
|
182
203
|
constructor(moduleName: string);
|
|
183
204
|
/**
|
|
184
|
-
* Invokes a JSBridge method with
|
|
205
|
+
* Invokes a JSBridge method with optional app validation and response transformation.
|
|
185
206
|
*
|
|
186
207
|
* @remarks
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
208
|
+
* - Always checks if running in Grab app (returns 501 if not).
|
|
209
|
+
* - When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
210
|
+
* - When `transformResponse` is provided, applies it to successful responses.
|
|
211
|
+
* - All errors are reported via the `status_code` field; this method never rejects.
|
|
212
|
+
* - For streaming methods, use `invokeStream` instead.
|
|
190
213
|
*
|
|
191
|
-
* @param
|
|
192
|
-
* @
|
|
193
|
-
* @returns A promise resolving to the JSBridge response, or a 501 error if not in Grab app.
|
|
214
|
+
* @param options - The invoke options including method name, params, validation, and transformation.
|
|
215
|
+
* @returns A promise resolving to the JSBridge response.
|
|
194
216
|
*
|
|
195
|
-
* @
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
invoke<T>(options: InvokeOptions<T>): Promise<BridgeResponse<BridgeStatusCode, T>>;
|
|
220
|
+
/**
|
|
221
|
+
* Creates a BridgeStream that immediately emits an error response.
|
|
222
|
+
* Used for 501, 426, and 500 error scenarios in invokeStream.
|
|
223
|
+
*
|
|
224
|
+
* @returns A BridgeStream that emits the error and immediately completes.
|
|
196
225
|
*/
|
|
197
|
-
|
|
226
|
+
private createErrorStream;
|
|
227
|
+
/**
|
|
228
|
+
* Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* - Always checks if running in Grab app (returns 501 error response if not).
|
|
232
|
+
* - When `isSupported` returns false, returns 426 error response.
|
|
233
|
+
* - Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
234
|
+
* - All errors are reported via error responses in the stream; this method never rejects.
|
|
235
|
+
*
|
|
236
|
+
* @param options - The invoke options including method name, params, and validation.
|
|
237
|
+
* @returns A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
protected invokeStream<T>(options: InvokeOptions<T>): BridgeStream<BridgeStatusCode, T>;
|
|
198
242
|
}
|
|
199
243
|
|
|
200
244
|
/**
|
|
201
245
|
* Union type representing all client error JSBridge responses (4xx status codes).
|
|
202
|
-
* Includes: 400 (Bad Request), 403 (Forbidden), 404 (Not Found),
|
|
246
|
+
* Includes: 400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found),
|
|
247
|
+
* 424 (Failed Dependency), and 426 (Upgrade Required).
|
|
203
248
|
*
|
|
204
249
|
* @public
|
|
205
250
|
*/
|
|
206
|
-
export declare type
|
|
251
|
+
export declare type BridgeClientError = ResponseStatusCode400 | ResponseStatusCode401 | ResponseStatusCode403 | ResponseStatusCode404 | ResponseStatusCode424 | ResponseStatusCode426;
|
|
207
252
|
|
|
208
253
|
/**
|
|
209
254
|
* Union type representing all error JSBridge responses (4xx and 5xx status codes).
|
|
@@ -211,7 +256,7 @@ export declare type BridgeClientErrorResponse = BridgeStatusCode400Response | Br
|
|
|
211
256
|
*
|
|
212
257
|
* @public
|
|
213
258
|
*/
|
|
214
|
-
export declare type
|
|
259
|
+
export declare type BridgeError = BridgeClientError | BridgeServerError;
|
|
215
260
|
|
|
216
261
|
/**
|
|
217
262
|
* Union type representing redirect JSBridge responses.
|
|
@@ -219,158 +264,93 @@ export declare type BridgeErrorResponse = BridgeClientErrorResponse | BridgeServ
|
|
|
219
264
|
*
|
|
220
265
|
* @public
|
|
221
266
|
*/
|
|
222
|
-
export declare type
|
|
267
|
+
export declare type BridgeRedirection = ResponseStatusCode302;
|
|
223
268
|
|
|
224
269
|
/**
|
|
225
|
-
* Universal response
|
|
270
|
+
* Universal response type for JSBridge method callbacks.
|
|
226
271
|
*
|
|
227
272
|
* @remarks
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* @public
|
|
232
|
-
*/
|
|
233
|
-
export declare type BridgeResponse<T> = BridgeSuccessResponse<T> | BridgeRedirectResponse | BridgeClientErrorResponse | BridgeServerErrorResponse;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Union type representing server error JSBridge responses (5xx status codes).
|
|
237
|
-
* Includes status codes 500 (Internal Server Error) and 501 (Not Implemented).
|
|
238
|
-
*
|
|
239
|
-
* @public
|
|
240
|
-
*/
|
|
241
|
-
export declare type BridgeServerErrorResponse = BridgeStatusCode500Response | BridgeStatusCode501Response;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Success response from the bridge SDK.
|
|
273
|
+
* Represents the response shape from a JSBridge method call. Use with specific status codes
|
|
274
|
+
* to constrain which responses are possible, or use `BridgeStatusCode` for the full union.
|
|
245
275
|
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* The `result` field contains the JSBridge method's data.
|
|
276
|
+
* This type works for both single (non-streaming) responses and as the item type
|
|
277
|
+
* emitted by {@link BridgeStream}.
|
|
249
278
|
*
|
|
250
|
-
*
|
|
251
|
-
*/
|
|
252
|
-
export declare type BridgeStatusCode200Response<T> = {
|
|
253
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
254
|
-
status_code: 200;
|
|
255
|
-
/** The result data from the JSBridge method, or undefined if no result was returned */
|
|
256
|
-
result: T;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* No result response with status code 204.
|
|
279
|
+
* Status codes come first in the type parameters for better readability at module call sites.
|
|
261
280
|
*
|
|
262
|
-
* @
|
|
263
|
-
*
|
|
264
|
-
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* // Constrained to specific status codes (common case)
|
|
284
|
+
* type SuccessOrError = BridgeResponse<200 | 500, string>;
|
|
265
285
|
*
|
|
266
|
-
*
|
|
267
|
-
|
|
268
|
-
export declare type BridgeStatusCode204Response = {
|
|
269
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
270
|
-
status_code: 204;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Redirect response with status code 302.
|
|
286
|
+
* // Only success
|
|
287
|
+
* type OnlySuccess = BridgeResponse<200, string>;
|
|
275
288
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
289
|
+
* // Unconstrained - all status codes possible (internal use)
|
|
290
|
+
* type AnyResponse = BridgeResponse<BridgeStatusCode, string>;
|
|
291
|
+
* ```
|
|
279
292
|
*
|
|
280
293
|
* @public
|
|
281
294
|
*/
|
|
282
|
-
export declare type
|
|
283
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
284
|
-
status_code: 302;
|
|
285
|
-
};
|
|
295
|
+
export declare type BridgeResponse<Codes extends BridgeStatusCode = BridgeStatusCode, T = void> = StatusCodeMap<T>[Codes];
|
|
286
296
|
|
|
287
297
|
/**
|
|
288
|
-
*
|
|
298
|
+
* Union type representing server error JSBridge responses (5xx status codes).
|
|
299
|
+
* Includes status codes 500 (Internal Server Error) and 501 (Not Implemented).
|
|
289
300
|
*
|
|
290
301
|
* @public
|
|
291
302
|
*/
|
|
292
|
-
export declare type
|
|
293
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
294
|
-
status_code: 400;
|
|
295
|
-
/** Error message if the call failed */
|
|
296
|
-
error: string;
|
|
297
|
-
};
|
|
303
|
+
export declare type BridgeServerError = ResponseStatusCode500 | ResponseStatusCode501;
|
|
298
304
|
|
|
299
305
|
/**
|
|
300
|
-
*
|
|
306
|
+
* Helper type representing all possible JSBridge status codes.
|
|
301
307
|
*
|
|
302
308
|
* @public
|
|
303
309
|
*/
|
|
304
|
-
export declare type
|
|
305
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
306
|
-
status_code: 401;
|
|
307
|
-
/** Error message if the call failed */
|
|
308
|
-
error: string;
|
|
309
|
-
};
|
|
310
|
+
export declare type BridgeStatusCode = keyof StatusCodeMap<unknown>;
|
|
310
311
|
|
|
311
312
|
/**
|
|
312
|
-
*
|
|
313
|
+
* A stream for receiving continuous data from JSBridge methods (e.g., location updates).
|
|
313
314
|
*
|
|
314
|
-
* @
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
status_code: 403;
|
|
319
|
-
/** Error message if the call failed */
|
|
320
|
-
error: string;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Error response with status code 404
|
|
315
|
+
* @remarks
|
|
316
|
+
* Provides both Observable-like and Promise-like interfaces:
|
|
317
|
+
* - Use `subscribe()` to receive all values over time
|
|
318
|
+
* - Use `then()` or `await` to receive only the first value
|
|
325
319
|
*
|
|
326
|
-
*
|
|
327
|
-
*/
|
|
328
|
-
export declare type BridgeStatusCode404Response = {
|
|
329
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
330
|
-
status_code: 404;
|
|
331
|
-
/** Error message if the call failed */
|
|
332
|
-
error: string;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Error response with status code 424
|
|
320
|
+
* Note: Each `subscribe()` call creates a fresh subscription, allowing multiple independent listeners.
|
|
337
321
|
*
|
|
338
|
-
* @
|
|
339
|
-
|
|
340
|
-
export declare type BridgeStatusCode424Response = {
|
|
341
|
-
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
342
|
-
status_code: 424;
|
|
343
|
-
/** Error message if the call failed */
|
|
344
|
-
error: string;
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Error response with status code 500
|
|
322
|
+
* @typeParam Codes - The status codes that can be emitted by the stream.
|
|
323
|
+
* @typeParam T - The type of data emitted by the stream.
|
|
349
324
|
*
|
|
350
325
|
* @public
|
|
351
326
|
*/
|
|
352
|
-
export declare type
|
|
353
|
-
/**
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
327
|
+
export declare type BridgeStream<Codes extends BridgeStatusCode = BridgeStatusCode, T = void> = Readonly<{
|
|
328
|
+
/**
|
|
329
|
+
* Subscribe to receive stream data.
|
|
330
|
+
*
|
|
331
|
+
* @param handlers - Optional callbacks for data (`next`) and completion (`complete`).
|
|
332
|
+
* @returns A `Subscription` to terminate the stream when needed.
|
|
333
|
+
*/
|
|
334
|
+
subscribe: (handlers?: BridgeStreamHandlers<Codes, T>) => Subscription;
|
|
335
|
+
}> & PromiseLike<BridgeResponse<Codes, T>>;
|
|
358
336
|
|
|
359
337
|
/**
|
|
360
|
-
*
|
|
338
|
+
* Callbacks for handling stream events.
|
|
361
339
|
*
|
|
362
340
|
* @remarks
|
|
363
|
-
*
|
|
364
|
-
*
|
|
341
|
+
* Pass these to `subscribe()` to receive data via `next` and completion via `complete`.
|
|
342
|
+
*
|
|
343
|
+
* @typeParam Codes - The status codes that can be emitted by the stream.
|
|
344
|
+
* @typeParam T - The type of data emitted by the stream.
|
|
365
345
|
*
|
|
366
346
|
* @public
|
|
367
347
|
*/
|
|
368
|
-
export declare type
|
|
369
|
-
/**
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
|
|
373
|
-
}
|
|
348
|
+
export declare type BridgeStreamHandlers<Codes extends BridgeStatusCode = BridgeStatusCode, T = void> = Readonly<{
|
|
349
|
+
/** Called with each new value from the stream. */
|
|
350
|
+
next?: (data: BridgeResponse<Codes, T>) => unknown;
|
|
351
|
+
/** Called when the stream ends and no more data will arrive. */
|
|
352
|
+
complete?: () => unknown;
|
|
353
|
+
}>;
|
|
374
354
|
|
|
375
355
|
/**
|
|
376
356
|
* Union type representing all successful JSBridge responses.
|
|
@@ -378,7 +358,7 @@ export declare type BridgeStatusCode501Response = {
|
|
|
378
358
|
*
|
|
379
359
|
* @public
|
|
380
360
|
*/
|
|
381
|
-
export declare type BridgeSuccessResponse<T> =
|
|
361
|
+
export declare type BridgeSuccessResponse<T> = ResponseStatusCode200<T> | ResponseStatusCode204;
|
|
382
362
|
|
|
383
363
|
/**
|
|
384
364
|
* JSBridge module for accessing the device camera.
|
|
@@ -406,6 +386,7 @@ export declare type BridgeSuccessResponse<T> = BridgeStatusCode200Response<T> |
|
|
|
406
386
|
* ```
|
|
407
387
|
*
|
|
408
388
|
* @public
|
|
389
|
+
* @noInheritDoc
|
|
409
390
|
*/
|
|
410
391
|
export declare class CameraModule extends BaseModule {
|
|
411
392
|
constructor();
|
|
@@ -416,48 +397,37 @@ export declare class CameraModule extends BaseModule {
|
|
|
416
397
|
*
|
|
417
398
|
* @returns The QR code scanning result, containing the scanned code on success or status information.
|
|
418
399
|
*
|
|
419
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
420
|
-
*
|
|
421
400
|
* @example
|
|
422
401
|
* **Simple usage**
|
|
423
402
|
* ```typescript
|
|
424
|
-
* // Imports using ES Module built
|
|
425
|
-
* import { CameraModule } from '@grabjs/superapp-sdk';
|
|
426
|
-
* // Imports using UMD built (via CDN)
|
|
427
|
-
* const { CameraModule } = window.SuperAppSDK;
|
|
428
|
-
*
|
|
429
403
|
* // Initialize the camera module
|
|
430
404
|
* const cameraModule = new CameraModule();
|
|
431
405
|
*
|
|
432
406
|
* // Scan the QR code
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
* console.log('Unexpected status code:', response);
|
|
453
|
-
* }
|
|
454
|
-
* } catch (error) {
|
|
455
|
-
* console.log('Unexpected error:', error);
|
|
407
|
+
* const response = await cameraModule.scanQRCode({ title: 'Scan Payment QR' });
|
|
408
|
+
* switch (response.status_code) {
|
|
409
|
+
* case 200:
|
|
410
|
+
* console.log('QR Code scanned:', response.result.qrCode);
|
|
411
|
+
* break;
|
|
412
|
+
* case 204:
|
|
413
|
+
* console.log('User cancelled QR code scanning');
|
|
414
|
+
* break;
|
|
415
|
+
* case 400:
|
|
416
|
+
* console.log('Bad request:', response.error);
|
|
417
|
+
* break;
|
|
418
|
+
* case 403:
|
|
419
|
+
* console.log('Camera permission is not enabled for the Grab app');
|
|
420
|
+
* break;
|
|
421
|
+
* case 501:
|
|
422
|
+
* console.log('Not in Grab app:', response.error);
|
|
423
|
+
* break;
|
|
424
|
+
* default:
|
|
425
|
+
* console.log('Unexpected status code:', response);
|
|
456
426
|
* }
|
|
457
427
|
* ```
|
|
458
428
|
* @public
|
|
459
429
|
*/
|
|
460
|
-
scanQRCode(request: ScanQRCodeRequest): ScanQRCodeResponse
|
|
430
|
+
scanQRCode(request: ScanQRCodeRequest): Promise<ScanQRCodeResponse>;
|
|
461
431
|
}
|
|
462
432
|
|
|
463
433
|
/**
|
|
@@ -486,6 +456,7 @@ export declare class CameraModule extends BaseModule {
|
|
|
486
456
|
* ```
|
|
487
457
|
*
|
|
488
458
|
* @public
|
|
459
|
+
* @noInheritDoc
|
|
489
460
|
*/
|
|
490
461
|
export declare class CheckoutModule extends BaseModule {
|
|
491
462
|
constructor();
|
|
@@ -496,53 +467,42 @@ export declare class CheckoutModule extends BaseModule {
|
|
|
496
467
|
*
|
|
497
468
|
* @returns The checkout result, containing transaction status (success, failure, or pending) and transaction details.
|
|
498
469
|
*
|
|
499
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
500
|
-
*
|
|
501
470
|
* @example
|
|
502
471
|
* **Simple usage**
|
|
503
472
|
* ```typescript
|
|
504
|
-
* // Imports using ES Module built
|
|
505
|
-
* import { CheckoutModule } from '@grabjs/superapp-sdk';
|
|
506
|
-
* // Imports using UMD built (via CDN)
|
|
507
|
-
* const { CheckoutModule } = window.SuperAppSDK;
|
|
508
|
-
*
|
|
509
473
|
* // Initialize the checkout module
|
|
510
474
|
* const checkoutModule = new CheckoutModule();
|
|
511
475
|
*
|
|
512
476
|
* // Trigger checkout with response params
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* console.log('Unexpected status code:', response);
|
|
537
|
-
* }
|
|
538
|
-
* } catch (error) {
|
|
539
|
-
* console.log('Could not trigger checkout:', error);
|
|
477
|
+
* const transactionResponse = await createTransaction(); // Call POST /grabpay/partner/v4/charge/init from Grab API to create a transaction
|
|
478
|
+
* const response = await checkoutModule.triggerCheckout(transactionResponse);
|
|
479
|
+
*
|
|
480
|
+
* switch (response.status_code) {
|
|
481
|
+
* case 200:
|
|
482
|
+
* if (response.result.status === 'success') {
|
|
483
|
+
* console.log('Transaction successful:', response.result.transactionID);
|
|
484
|
+
* } else if (response.result.status === 'failure') {
|
|
485
|
+
* console.log('Transaction failed:', response.result.errorMessage, response.result.errorCode);
|
|
486
|
+
* } else if (response.result.status === 'pending') {
|
|
487
|
+
* console.log('Transaction pending:', response.result.transactionID);
|
|
488
|
+
* } else if (response.result.status === 'userInitiatedCancel') {
|
|
489
|
+
* console.log('User cancelled the checkout');
|
|
490
|
+
* }
|
|
491
|
+
* break;
|
|
492
|
+
* case 400:
|
|
493
|
+
* console.log('Transaction failed:', response.error);
|
|
494
|
+
* break;
|
|
495
|
+
* case 501:
|
|
496
|
+
* console.log('Not in Grab app:', response.error);
|
|
497
|
+
* break;
|
|
498
|
+
* default:
|
|
499
|
+
* console.log('Unexpected status code:', response);
|
|
540
500
|
* }
|
|
541
501
|
* ```
|
|
542
502
|
*
|
|
543
503
|
* @public
|
|
544
504
|
*/
|
|
545
|
-
triggerCheckout(request: TriggerCheckoutRequest): TriggerCheckoutResponse
|
|
505
|
+
triggerCheckout(request: TriggerCheckoutRequest): Promise<TriggerCheckoutResponse>;
|
|
546
506
|
}
|
|
547
507
|
|
|
548
508
|
/**
|
|
@@ -559,7 +519,7 @@ export declare class CheckoutModule extends BaseModule {
|
|
|
559
519
|
*
|
|
560
520
|
* @public
|
|
561
521
|
*/
|
|
562
|
-
export declare type ClearAuthorizationArtifactsResponse =
|
|
522
|
+
export declare type ClearAuthorizationArtifactsResponse = BridgeResponse<204, ClearAuthorizationArtifactsResult>;
|
|
563
523
|
|
|
564
524
|
/**
|
|
565
525
|
* Result object for clearing authorization artifacts.
|
|
@@ -575,6 +535,7 @@ export declare type ClearAuthorizationArtifactsResult = void;
|
|
|
575
535
|
* @remarks
|
|
576
536
|
* This response can have the following status codes:
|
|
577
537
|
* - `200`: Container closed successfully.
|
|
538
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
578
539
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
579
540
|
*
|
|
580
541
|
* @example
|
|
@@ -592,9 +553,18 @@ export declare type ClearAuthorizationArtifactsResult = void;
|
|
|
592
553
|
* }
|
|
593
554
|
* ```
|
|
594
555
|
*
|
|
556
|
+
* @example
|
|
557
|
+
* **Internal server error response (500):**
|
|
558
|
+
* ```typescript
|
|
559
|
+
* {
|
|
560
|
+
* status_code: 500,
|
|
561
|
+
* error: 'Internal server error'
|
|
562
|
+
* }
|
|
563
|
+
* ```
|
|
564
|
+
*
|
|
595
565
|
* @public
|
|
596
566
|
*/
|
|
597
|
-
export declare type CloseResponse =
|
|
567
|
+
export declare type CloseResponse = BridgeResponse<200 | 500 | 501, CloseResult>;
|
|
598
568
|
|
|
599
569
|
/**
|
|
600
570
|
* Result when closing the container.
|
|
@@ -604,25 +574,6 @@ export declare type CloseResponse = Promise<ConstrainedBridgeResponse<CloseResul
|
|
|
604
574
|
*/
|
|
605
575
|
export declare type CloseResult = void;
|
|
606
576
|
|
|
607
|
-
/**
|
|
608
|
-
* Create a constrained JSBridge response type with only specific status codes.
|
|
609
|
-
*
|
|
610
|
-
* @example
|
|
611
|
-
* ```typescript
|
|
612
|
-
* // Only status code 200
|
|
613
|
-
* type OnlySuccess = ConstrainedBridgeResponse<string, 200>;
|
|
614
|
-
*
|
|
615
|
-
* // Only status codes 200 and 500
|
|
616
|
-
* type SuccessOrServerError = ConstrainedBridgeResponse<string, 200 | 500>;
|
|
617
|
-
*
|
|
618
|
-
* // Only error status codes
|
|
619
|
-
* type OnlyErrors = ConstrainedBridgeResponse<string, 400 | 403 | 424 | 500>;
|
|
620
|
-
* ```
|
|
621
|
-
*
|
|
622
|
-
* @public
|
|
623
|
-
*/
|
|
624
|
-
export declare type ConstrainedBridgeResponse<T, Codes extends keyof StatusCodeMap<T>> = StatusCodeMap<T>[Codes];
|
|
625
|
-
|
|
626
577
|
/**
|
|
627
578
|
* Constants for container analytics event data.
|
|
628
579
|
*
|
|
@@ -681,6 +632,7 @@ export declare const ContainerAnalyticsEventState: {
|
|
|
681
632
|
* ```
|
|
682
633
|
*
|
|
683
634
|
* @public
|
|
635
|
+
* @noInheritDoc
|
|
684
636
|
*/
|
|
685
637
|
export declare class ContainerModule extends BaseModule {
|
|
686
638
|
constructor();
|
|
@@ -691,44 +643,33 @@ export declare class ContainerModule extends BaseModule {
|
|
|
691
643
|
*
|
|
692
644
|
* @returns Confirmation that the background color was set.
|
|
693
645
|
*
|
|
694
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
695
|
-
*
|
|
696
646
|
* @example
|
|
697
647
|
* **Simple usage**
|
|
698
648
|
* ```typescript
|
|
699
|
-
* // Imports using ES Module built
|
|
700
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
701
|
-
* // Imports using UMD built (via CDN)
|
|
702
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
703
|
-
*
|
|
704
649
|
* // Initialize the container module
|
|
705
650
|
* const containerModule = new ContainerModule();
|
|
706
651
|
*
|
|
707
652
|
* // Set background color
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
* console.log('Unexpected status code:', response);
|
|
723
|
-
* }
|
|
724
|
-
* } catch (error) {
|
|
725
|
-
* console.log('Unexpected error:', error);
|
|
653
|
+
* const response = await containerModule.setBackgroundColor('#ffffff');
|
|
654
|
+
*
|
|
655
|
+
* switch (response.status_code) {
|
|
656
|
+
* case 200:
|
|
657
|
+
* console.log('Background color set successfully');
|
|
658
|
+
* break;
|
|
659
|
+
* case 400:
|
|
660
|
+
* console.log('Could not set background color:', response.error);
|
|
661
|
+
* break;
|
|
662
|
+
* case 501:
|
|
663
|
+
* console.log('Not in Grab app:', response.error);
|
|
664
|
+
* break;
|
|
665
|
+
* default:
|
|
666
|
+
* console.log('Unexpected status code:', response);
|
|
726
667
|
* }
|
|
727
668
|
* ```
|
|
728
669
|
*
|
|
729
670
|
* @public
|
|
730
671
|
*/
|
|
731
|
-
setBackgroundColor(request: SetBackgroundColorRequest): SetBackgroundColorResponse
|
|
672
|
+
setBackgroundColor(request: SetBackgroundColorRequest): Promise<SetBackgroundColorResponse>;
|
|
732
673
|
/**
|
|
733
674
|
* Set the title of the container header.
|
|
734
675
|
*
|
|
@@ -736,272 +677,195 @@ export declare class ContainerModule extends BaseModule {
|
|
|
736
677
|
*
|
|
737
678
|
* @returns Confirmation that the title was set.
|
|
738
679
|
*
|
|
739
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
740
|
-
*
|
|
741
680
|
* @example
|
|
742
681
|
* **Simple usage**
|
|
743
682
|
* ```typescript
|
|
744
|
-
* // Imports using ES Module built
|
|
745
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
746
|
-
* // Imports using UMD built (via CDN)
|
|
747
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
748
|
-
*
|
|
749
683
|
* // Initialize the container module
|
|
750
684
|
* const containerModule = new ContainerModule();
|
|
751
685
|
*
|
|
752
686
|
* // Set title
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
* console.log('Unexpected status code:', response);
|
|
768
|
-
* }
|
|
769
|
-
* } catch (error) {
|
|
770
|
-
* console.log('Unexpected error:', error);
|
|
687
|
+
* const response = await containerModule.setTitle('Home');
|
|
688
|
+
*
|
|
689
|
+
* switch (response.status_code) {
|
|
690
|
+
* case 200:
|
|
691
|
+
* console.log('Title set successfully');
|
|
692
|
+
* break;
|
|
693
|
+
* case 400:
|
|
694
|
+
* console.log('Could not set title:', response.error);
|
|
695
|
+
* break;
|
|
696
|
+
* case 501:
|
|
697
|
+
* console.log('Not in Grab app:', response.error);
|
|
698
|
+
* break;
|
|
699
|
+
* default:
|
|
700
|
+
* console.log('Unexpected status code:', response);
|
|
771
701
|
* }
|
|
772
702
|
* ```
|
|
773
703
|
*
|
|
774
704
|
* @public
|
|
775
705
|
*/
|
|
776
|
-
setTitle(request: SetTitleRequest): SetTitleResponse
|
|
706
|
+
setTitle(request: SetTitleRequest): Promise<SetTitleResponse>;
|
|
777
707
|
/**
|
|
778
708
|
* Hide the back button on the container header.
|
|
779
709
|
*
|
|
780
710
|
* @returns Confirmation that the back button is now hidden.
|
|
781
711
|
*
|
|
782
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
783
|
-
*
|
|
784
712
|
* @example
|
|
785
713
|
* **Simple usage**
|
|
786
714
|
* ```typescript
|
|
787
|
-
* // Imports using ES Module built
|
|
788
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
789
|
-
* // Imports using UMD built (via CDN)
|
|
790
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
791
|
-
*
|
|
792
715
|
* // Initialize the container module
|
|
793
716
|
* const containerModule = new ContainerModule();
|
|
794
717
|
*
|
|
795
718
|
* // Hide back button
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
* break;
|
|
806
|
-
* }
|
|
807
|
-
* } catch (error) {
|
|
808
|
-
* console.log('Unexpected error:', error);
|
|
719
|
+
* const response = await containerModule.hideBackButton();
|
|
720
|
+
*
|
|
721
|
+
* switch (response.status_code) {
|
|
722
|
+
* case 200:
|
|
723
|
+
* console.log('Back button hidden successfully');
|
|
724
|
+
* break;
|
|
725
|
+
* case 501:
|
|
726
|
+
* console.log('Not in Grab app:', response.error);
|
|
727
|
+
* break;
|
|
809
728
|
* }
|
|
810
729
|
* ```
|
|
811
730
|
*
|
|
812
731
|
* @public
|
|
813
732
|
*/
|
|
814
|
-
hideBackButton(): HideBackButtonResponse
|
|
733
|
+
hideBackButton(): Promise<HideBackButtonResponse>;
|
|
815
734
|
/**
|
|
816
735
|
* Show the back button on the container header.
|
|
817
736
|
*
|
|
818
737
|
* @returns Confirmation that the back button is now visible.
|
|
819
738
|
*
|
|
820
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
821
|
-
*
|
|
822
739
|
* @example
|
|
823
740
|
* **Simple usage**
|
|
824
741
|
* ```typescript
|
|
825
|
-
* // Imports using ES Module built
|
|
826
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
827
|
-
* // Imports using UMD built (via CDN)
|
|
828
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
829
|
-
*
|
|
830
742
|
* // Initialize the container module
|
|
831
743
|
* const containerModule = new ContainerModule();
|
|
832
744
|
*
|
|
833
745
|
* // Show back button
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
842
|
-
*
|
|
843
|
-
* break;
|
|
844
|
-
* }
|
|
845
|
-
* } catch (error) {
|
|
846
|
-
* console.log('Unexpected error:', error);
|
|
746
|
+
* const response = await containerModule.showBackButton();
|
|
747
|
+
*
|
|
748
|
+
* switch (response.status_code) {
|
|
749
|
+
* case 200:
|
|
750
|
+
* console.log('Back button shown successfully');
|
|
751
|
+
* break;
|
|
752
|
+
* case 501:
|
|
753
|
+
* console.log('Not in Grab app:', response.error);
|
|
754
|
+
* break;
|
|
847
755
|
* }
|
|
848
756
|
* ```
|
|
849
757
|
*
|
|
850
758
|
* @public
|
|
851
759
|
*/
|
|
852
|
-
showBackButton(): ShowBackButtonResponse
|
|
760
|
+
showBackButton(): Promise<ShowBackButtonResponse>;
|
|
853
761
|
/**
|
|
854
762
|
* Hide the refresh button on the container header.
|
|
855
763
|
*
|
|
856
764
|
* @returns Confirmation that the refresh button is now hidden.
|
|
857
765
|
*
|
|
858
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
859
|
-
*
|
|
860
766
|
* @example
|
|
861
767
|
* **Simple usage**
|
|
862
768
|
* ```typescript
|
|
863
|
-
* // Imports using ES Module built
|
|
864
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
865
|
-
* // Imports using UMD built (via CDN)
|
|
866
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
867
|
-
*
|
|
868
769
|
* // Initialize the container module
|
|
869
770
|
* const containerModule = new ContainerModule();
|
|
870
771
|
*
|
|
871
772
|
* // Hide refresh button
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
*
|
|
877
|
-
*
|
|
878
|
-
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
* break;
|
|
882
|
-
* }
|
|
883
|
-
* } catch (error) {
|
|
884
|
-
* console.log('Unexpected error:', error);
|
|
773
|
+
* const response = await containerModule.hideRefreshButton();
|
|
774
|
+
*
|
|
775
|
+
* switch (response.status_code) {
|
|
776
|
+
* case 200:
|
|
777
|
+
* console.log('Refresh button hidden successfully');
|
|
778
|
+
* break;
|
|
779
|
+
* case 501:
|
|
780
|
+
* console.log('Not in Grab app:', response.error);
|
|
781
|
+
* break;
|
|
885
782
|
* }
|
|
886
783
|
* ```
|
|
887
784
|
*
|
|
888
785
|
* @public
|
|
889
786
|
*/
|
|
890
|
-
hideRefreshButton(): HideRefreshButtonResponse
|
|
787
|
+
hideRefreshButton(): Promise<HideRefreshButtonResponse>;
|
|
891
788
|
/**
|
|
892
789
|
* Show the refresh button on the container header.
|
|
893
790
|
*
|
|
894
791
|
* @returns Confirmation that the refresh button is now visible.
|
|
895
792
|
*
|
|
896
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
897
|
-
*
|
|
898
793
|
* @example
|
|
899
794
|
* **Simple usage**
|
|
900
795
|
* ```typescript
|
|
901
|
-
* // Imports using ES Module built
|
|
902
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
903
|
-
* // Imports using UMD built (via CDN)
|
|
904
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
905
|
-
*
|
|
906
796
|
* // Initialize the container module
|
|
907
797
|
* const containerModule = new ContainerModule();
|
|
908
798
|
*
|
|
909
799
|
* // Show refresh button
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
*
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
919
|
-
* break;
|
|
920
|
-
* }
|
|
921
|
-
* } catch (error) {
|
|
922
|
-
* console.log('Unexpected error:', error);
|
|
800
|
+
* const response = await containerModule.showRefreshButton();
|
|
801
|
+
*
|
|
802
|
+
* switch (response.status_code) {
|
|
803
|
+
* case 200:
|
|
804
|
+
* console.log('Refresh button shown successfully');
|
|
805
|
+
* break;
|
|
806
|
+
* case 501:
|
|
807
|
+
* console.log('Not in Grab app:', response.error);
|
|
808
|
+
* break;
|
|
923
809
|
* }
|
|
924
810
|
* ```
|
|
925
811
|
*
|
|
926
812
|
* @public
|
|
927
813
|
*/
|
|
928
|
-
showRefreshButton(): ShowRefreshButtonResponse
|
|
814
|
+
showRefreshButton(): Promise<ShowRefreshButtonResponse>;
|
|
929
815
|
/**
|
|
930
816
|
* Close the container and return to the previous screen.
|
|
931
817
|
*
|
|
932
818
|
* @returns Confirmation that the container is closing.
|
|
933
819
|
*
|
|
934
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
935
|
-
*
|
|
936
820
|
* @example
|
|
937
821
|
* **Simple usage**
|
|
938
822
|
* ```typescript
|
|
939
|
-
* // Imports using ES Module built
|
|
940
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
941
|
-
* // Imports using UMD built (via CDN)
|
|
942
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
943
|
-
*
|
|
944
823
|
* // Initialize the container module
|
|
945
824
|
* const containerModule = new ContainerModule();
|
|
946
825
|
*
|
|
947
826
|
* // Close the container
|
|
948
|
-
*
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
* break;
|
|
958
|
-
* }
|
|
959
|
-
* } catch (error) {
|
|
960
|
-
* console.log('Unexpected error:', error);
|
|
827
|
+
* const response = await containerModule.close();
|
|
828
|
+
*
|
|
829
|
+
* switch (response.status_code) {
|
|
830
|
+
* case 200:
|
|
831
|
+
* console.log('Container closed successfully');
|
|
832
|
+
* break;
|
|
833
|
+
* case 501:
|
|
834
|
+
* console.log('Not in Grab app:', response.error);
|
|
835
|
+
* break;
|
|
961
836
|
* }
|
|
962
837
|
* ```
|
|
963
838
|
*
|
|
964
839
|
* @public
|
|
965
840
|
*/
|
|
966
|
-
close(): CloseResponse
|
|
841
|
+
close(): Promise<CloseResponse>;
|
|
967
842
|
/**
|
|
968
843
|
* Notify the Grab SuperApp that the page content has loaded.
|
|
969
844
|
*
|
|
970
845
|
* @returns Confirmation that the content loaded notification was sent.
|
|
971
846
|
*
|
|
972
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
973
|
-
*
|
|
974
847
|
* @example
|
|
975
848
|
* **Simple usage**
|
|
976
849
|
* ```typescript
|
|
977
|
-
* // Imports using ES Module built
|
|
978
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
979
|
-
* // Imports using UMD built (via CDN)
|
|
980
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
981
|
-
*
|
|
982
850
|
* // Initialize the container module
|
|
983
851
|
* const containerModule = new ContainerModule();
|
|
984
852
|
*
|
|
985
853
|
* // Notify content loaded
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
* break;
|
|
996
|
-
* }
|
|
997
|
-
* } catch (error) {
|
|
998
|
-
* console.log('Unexpected error:', error);
|
|
854
|
+
* const response = await containerModule.onContentLoaded();
|
|
855
|
+
*
|
|
856
|
+
* switch (response.status_code) {
|
|
857
|
+
* case 200:
|
|
858
|
+
* console.log('Content loaded notification sent successfully');
|
|
859
|
+
* break;
|
|
860
|
+
* case 501:
|
|
861
|
+
* console.log('Not in Grab app:', response.error);
|
|
862
|
+
* break;
|
|
999
863
|
* }
|
|
1000
864
|
* ```
|
|
1001
865
|
*
|
|
1002
866
|
* @public
|
|
1003
867
|
*/
|
|
1004
|
-
onContentLoaded(): OnContentLoadedResponse
|
|
868
|
+
onContentLoaded(): Promise<OnContentLoadedResponse>;
|
|
1005
869
|
/**
|
|
1006
870
|
* Show the full-screen loading indicator.
|
|
1007
871
|
*
|
|
@@ -1010,39 +874,28 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1010
874
|
*
|
|
1011
875
|
* @returns Confirmation that the loader is now visible.
|
|
1012
876
|
*
|
|
1013
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1014
|
-
*
|
|
1015
877
|
* @example
|
|
1016
878
|
* **Simple usage**
|
|
1017
879
|
* ```typescript
|
|
1018
|
-
* // Imports using ES Module built
|
|
1019
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
1020
|
-
* // Imports using UMD built (via CDN)
|
|
1021
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
1022
|
-
*
|
|
1023
880
|
* // Initialize the container module
|
|
1024
881
|
* const containerModule = new ContainerModule();
|
|
1025
882
|
*
|
|
1026
883
|
* // Show loader
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
* break;
|
|
1037
|
-
* }
|
|
1038
|
-
* } catch (error) {
|
|
1039
|
-
* console.log('Unexpected error:', error);
|
|
884
|
+
* const response = await containerModule.showLoader();
|
|
885
|
+
*
|
|
886
|
+
* switch (response.status_code) {
|
|
887
|
+
* case 200:
|
|
888
|
+
* console.log('Loader shown successfully');
|
|
889
|
+
* break;
|
|
890
|
+
* case 501:
|
|
891
|
+
* console.log('Not in Grab app:', response.error);
|
|
892
|
+
* break;
|
|
1040
893
|
* }
|
|
1041
894
|
* ```
|
|
1042
895
|
*
|
|
1043
896
|
* @public
|
|
1044
897
|
*/
|
|
1045
|
-
showLoader(): ShowLoaderResponse
|
|
898
|
+
showLoader(): Promise<ShowLoaderResponse>;
|
|
1046
899
|
/**
|
|
1047
900
|
* Hide the full-screen loading indicator.
|
|
1048
901
|
*
|
|
@@ -1051,39 +904,28 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1051
904
|
*
|
|
1052
905
|
* @returns Confirmation that the loader is now hidden.
|
|
1053
906
|
*
|
|
1054
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1055
|
-
*
|
|
1056
907
|
* @example
|
|
1057
908
|
* **Simple usage**
|
|
1058
909
|
* ```typescript
|
|
1059
|
-
* // Imports using ES Module built
|
|
1060
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
1061
|
-
* // Imports using UMD built (via CDN)
|
|
1062
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
1063
|
-
*
|
|
1064
910
|
* // Initialize the container module
|
|
1065
911
|
* const containerModule = new ContainerModule();
|
|
1066
912
|
*
|
|
1067
913
|
* // Hide loader
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1077
|
-
* break;
|
|
1078
|
-
* }
|
|
1079
|
-
* } catch (error) {
|
|
1080
|
-
* console.log('Unexpected error:', error);
|
|
914
|
+
* const response = await containerModule.hideLoader();
|
|
915
|
+
*
|
|
916
|
+
* switch (response.status_code) {
|
|
917
|
+
* case 200:
|
|
918
|
+
* console.log('Loader hidden successfully');
|
|
919
|
+
* break;
|
|
920
|
+
* case 501:
|
|
921
|
+
* console.log('Not in Grab app:', response.error);
|
|
922
|
+
* break;
|
|
1081
923
|
* }
|
|
1082
924
|
* ```
|
|
1083
925
|
*
|
|
1084
926
|
* @public
|
|
1085
927
|
*/
|
|
1086
|
-
hideLoader(): HideLoaderResponse
|
|
928
|
+
hideLoader(): Promise<HideLoaderResponse>;
|
|
1087
929
|
/**
|
|
1088
930
|
* Open a link in the external browser.
|
|
1089
931
|
*
|
|
@@ -1094,44 +936,33 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1094
936
|
*
|
|
1095
937
|
* @returns Confirmation of whether the external link was opened successfully.
|
|
1096
938
|
*
|
|
1097
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1098
|
-
*
|
|
1099
939
|
* @example
|
|
1100
940
|
* **Simple usage**
|
|
1101
941
|
* ```typescript
|
|
1102
|
-
* // Imports using ES Module built
|
|
1103
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
1104
|
-
* // Imports using UMD built (via CDN)
|
|
1105
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
1106
|
-
*
|
|
1107
942
|
* // Initialize the container module
|
|
1108
943
|
* const containerModule = new ContainerModule();
|
|
1109
944
|
*
|
|
1110
945
|
* // Open external link
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
*
|
|
1125
|
-
* console.log('Unexpected status code:', response);
|
|
1126
|
-
* }
|
|
1127
|
-
* } catch (error) {
|
|
1128
|
-
* console.log('Unexpected error:', error);
|
|
946
|
+
* const response = await containerModule.openExternalLink('https://grab.com');
|
|
947
|
+
*
|
|
948
|
+
* switch (response.status_code) {
|
|
949
|
+
* case 200:
|
|
950
|
+
* console.log('External link opened successfully');
|
|
951
|
+
* break;
|
|
952
|
+
* case 400:
|
|
953
|
+
* console.log('Could not open external link:', response.error);
|
|
954
|
+
* break;
|
|
955
|
+
* case 501:
|
|
956
|
+
* console.log('Not in Grab app:', response.error);
|
|
957
|
+
* break;
|
|
958
|
+
* default:
|
|
959
|
+
* console.log('Unexpected status code:', response);
|
|
1129
960
|
* }
|
|
1130
961
|
* ```
|
|
1131
962
|
*
|
|
1132
963
|
* @public
|
|
1133
964
|
*/
|
|
1134
|
-
openExternalLink(request: OpenExternalLinkRequest): OpenExternalLinkResponse
|
|
965
|
+
openExternalLink(request: OpenExternalLinkRequest): Promise<OpenExternalLinkResponse>;
|
|
1135
966
|
/**
|
|
1136
967
|
* Notify the client that the user has tapped a call-to-action (CTA).
|
|
1137
968
|
*
|
|
@@ -1139,39 +970,28 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1139
970
|
*
|
|
1140
971
|
* @returns Confirmation that the CTA tap was notified.
|
|
1141
972
|
*
|
|
1142
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1143
|
-
*
|
|
1144
973
|
* @example
|
|
1145
974
|
* **Simple usage**
|
|
1146
975
|
* ```typescript
|
|
1147
|
-
* // Imports using ES Module built
|
|
1148
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
1149
|
-
* // Imports using UMD built (via CDN)
|
|
1150
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
1151
|
-
*
|
|
1152
976
|
* // Initialize the container module
|
|
1153
977
|
* const containerModule = new ContainerModule();
|
|
1154
978
|
*
|
|
1155
979
|
* // Notify CTA tap
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
*
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* break;
|
|
1166
|
-
* }
|
|
1167
|
-
* } catch (error) {
|
|
1168
|
-
* console.log('Unexpected error:', error);
|
|
980
|
+
* const response = await containerModule.onCtaTap('AV_LANDING_PAGE_CONTINUE');
|
|
981
|
+
*
|
|
982
|
+
* switch (response.status_code) {
|
|
983
|
+
* case 200:
|
|
984
|
+
* console.log('CTA tap notified successfully');
|
|
985
|
+
* break;
|
|
986
|
+
* case 501:
|
|
987
|
+
* console.log('Not in Grab app:', response.error);
|
|
988
|
+
* break;
|
|
1169
989
|
* }
|
|
1170
990
|
* ```
|
|
1171
991
|
*
|
|
1172
992
|
* @public
|
|
1173
993
|
*/
|
|
1174
|
-
onCtaTap(request: OnCtaTapRequest): OnCtaTapResponse
|
|
994
|
+
onCtaTap(request: OnCtaTapRequest): Promise<OnCtaTapResponse>;
|
|
1175
995
|
/**
|
|
1176
996
|
* Use this method to track user interactions and page transitions.
|
|
1177
997
|
*
|
|
@@ -1195,13 +1015,11 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1195
1015
|
* ```typescript
|
|
1196
1016
|
* // Imports using ES Module built
|
|
1197
1017
|
* import {
|
|
1198
|
-
* ContainerModule,
|
|
1199
1018
|
* ContainerAnalyticsEventState,
|
|
1200
1019
|
* ContainerAnalyticsEventName,
|
|
1201
1020
|
* } from '@grabjs/superapp-sdk';
|
|
1202
1021
|
* // Imports using UMD built (via CDN)
|
|
1203
1022
|
* const {
|
|
1204
|
-
* ContainerModule,
|
|
1205
1023
|
* ContainerAnalyticsEventState,
|
|
1206
1024
|
* ContainerAnalyticsEventName,
|
|
1207
1025
|
* } = window.SuperAppSDK;
|
|
@@ -1210,33 +1028,29 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1210
1028
|
* const containerModule = new ContainerModule();
|
|
1211
1029
|
*
|
|
1212
1030
|
* // Send analytics event
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1217
|
-
* });
|
|
1031
|
+
* const response = await containerModule.sendAnalyticsEvent({
|
|
1032
|
+
* state: ContainerAnalyticsEventState.HOMEPAGE,
|
|
1033
|
+
* name: ContainerAnalyticsEventName.DEFAULT,
|
|
1034
|
+
* });
|
|
1218
1035
|
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
*
|
|
1231
|
-
* }
|
|
1232
|
-
* } catch (error) {
|
|
1233
|
-
* console.log('Unexpected error:', error);
|
|
1036
|
+
* switch (response.status_code) {
|
|
1037
|
+
* case 200:
|
|
1038
|
+
* console.log('Analytics event sent successfully');
|
|
1039
|
+
* break;
|
|
1040
|
+
* case 400:
|
|
1041
|
+
* console.log('Invalid analytics event parameters:', response.error);
|
|
1042
|
+
* break;
|
|
1043
|
+
* case 501:
|
|
1044
|
+
* console.log('Not in Grab app:', response.error);
|
|
1045
|
+
* break;
|
|
1046
|
+
* default:
|
|
1047
|
+
* console.log('Unexpected status code:', response);
|
|
1234
1048
|
* }
|
|
1235
1049
|
* ```
|
|
1236
1050
|
*
|
|
1237
1051
|
* @public
|
|
1238
1052
|
*/
|
|
1239
|
-
sendAnalyticsEvent(request: SendAnalyticsEventRequest): SendAnalyticsEventResponse
|
|
1053
|
+
sendAnalyticsEvent(request: SendAnalyticsEventRequest): Promise<SendAnalyticsEventResponse>;
|
|
1240
1054
|
/**
|
|
1241
1055
|
* Check if the web app is connected to the Grab SuperApp via JSBridge.
|
|
1242
1056
|
*
|
|
@@ -1245,41 +1059,30 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1245
1059
|
*
|
|
1246
1060
|
* @returns The connection status, indicating whether the MiniApp is running inside the Grab SuperApp.
|
|
1247
1061
|
*
|
|
1248
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1249
|
-
*
|
|
1250
1062
|
* @example
|
|
1251
1063
|
* **Simple usage**
|
|
1252
1064
|
* ```typescript
|
|
1253
|
-
* // Imports using ES Module built
|
|
1254
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
1255
|
-
* // Imports using UMD built (via CDN)
|
|
1256
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
1257
|
-
*
|
|
1258
1065
|
* // Initialize the container module
|
|
1259
1066
|
* const containerModule = new ContainerModule();
|
|
1260
1067
|
*
|
|
1261
1068
|
* // Check connection status
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
1266
|
-
*
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1269
|
-
*
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
* console.log('Unexpected status code:', response);
|
|
1274
|
-
* }
|
|
1275
|
-
* } catch (error) {
|
|
1276
|
-
* console.log('Unexpected error:', error);
|
|
1069
|
+
* const response = await containerModule.isConnected();
|
|
1070
|
+
*
|
|
1071
|
+
* switch (response.status_code) {
|
|
1072
|
+
* case 200:
|
|
1073
|
+
* console.log('Connected to Grab SuperApp');
|
|
1074
|
+
* break;
|
|
1075
|
+
* case 404:
|
|
1076
|
+
* console.log('Not connected to Grab SuperApp');
|
|
1077
|
+
* break;
|
|
1078
|
+
* default:
|
|
1079
|
+
* console.log('Unexpected status code:', response);
|
|
1277
1080
|
* }
|
|
1278
1081
|
* ```
|
|
1279
1082
|
*
|
|
1280
1083
|
* @public
|
|
1281
1084
|
*/
|
|
1282
|
-
isConnected(): IsConnectedResponse
|
|
1085
|
+
isConnected(): Promise<IsConnectedResponse>;
|
|
1283
1086
|
/**
|
|
1284
1087
|
* Get the session parameters from the container.
|
|
1285
1088
|
*
|
|
@@ -1290,41 +1093,30 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1290
1093
|
*
|
|
1291
1094
|
* @returns The session parameters as a JSON string that can be parsed into an object.
|
|
1292
1095
|
*
|
|
1293
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1294
|
-
*
|
|
1295
1096
|
* @example
|
|
1296
1097
|
* **Simple usage**
|
|
1297
1098
|
* ```typescript
|
|
1298
|
-
* // Imports using ES Module built
|
|
1299
|
-
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
1300
|
-
* // Imports using UMD built (via CDN)
|
|
1301
|
-
* const { ContainerModule } = window.SuperAppSDK;
|
|
1302
|
-
*
|
|
1303
1099
|
* // Initialize the container module
|
|
1304
1100
|
* const containerModule = new ContainerModule();
|
|
1305
1101
|
*
|
|
1306
1102
|
* // Get session parameters
|
|
1307
|
-
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
* break;
|
|
1315
|
-
* }
|
|
1316
|
-
* case 501:
|
|
1317
|
-
* console.log('Not in Grab app:', response.error);
|
|
1318
|
-
* break;
|
|
1103
|
+
* const response = await containerModule.getSessionParams();
|
|
1104
|
+
*
|
|
1105
|
+
* switch (response.status_code) {
|
|
1106
|
+
* case 200: {
|
|
1107
|
+
* const sessionParams = JSON.parse(response.result?.result || '{}');
|
|
1108
|
+
* console.log('Session params retrieved:', sessionParams);
|
|
1109
|
+
* break;
|
|
1319
1110
|
* }
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1111
|
+
* case 501:
|
|
1112
|
+
* console.log('Not in Grab app:', response.error);
|
|
1113
|
+
* break;
|
|
1322
1114
|
* }
|
|
1323
1115
|
* ```
|
|
1324
1116
|
*
|
|
1325
1117
|
* @public
|
|
1326
1118
|
*/
|
|
1327
|
-
getSessionParams(): GetSessionParamsResponse
|
|
1119
|
+
getSessionParams(): Promise<GetSessionParamsResponse>;
|
|
1328
1120
|
/**
|
|
1329
1121
|
* Validate the analytics event details.
|
|
1330
1122
|
*
|
|
@@ -1336,45 +1128,144 @@ export declare class ContainerModule extends BaseModule {
|
|
|
1336
1128
|
}
|
|
1337
1129
|
|
|
1338
1130
|
/**
|
|
1339
|
-
*
|
|
1131
|
+
* JSBridge module for querying native device capability information.
|
|
1132
|
+
*
|
|
1133
|
+
* @group Modules
|
|
1340
1134
|
*
|
|
1341
1135
|
* @remarks
|
|
1342
|
-
* Provides
|
|
1343
|
-
*
|
|
1344
|
-
* - Use `then()` or `await` to receive only the first value
|
|
1136
|
+
* Provides access to device capability checks exposed by the native Grab app bridge.
|
|
1137
|
+
* This code must run on the Grab SuperApp's webview to function correctly.
|
|
1345
1138
|
*
|
|
1346
|
-
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* **ES Module:**
|
|
1141
|
+
* ```typescript
|
|
1142
|
+
* import { DeviceCapabilityModule } from '@grabjs/superapp-sdk';
|
|
1143
|
+
* const deviceCapabilityModule = new DeviceCapabilityModule();
|
|
1144
|
+
* ```
|
|
1347
1145
|
*
|
|
1348
|
-
* @
|
|
1146
|
+
* @example
|
|
1147
|
+
* **CDN (UMD):**
|
|
1148
|
+
* ```html
|
|
1149
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1150
|
+
* <script>
|
|
1151
|
+
* const deviceCapabilityModule = new SuperAppSDK.DeviceCapabilityModule();
|
|
1152
|
+
* </script>
|
|
1153
|
+
* ```
|
|
1349
1154
|
*
|
|
1350
1155
|
* @public
|
|
1156
|
+
* @noInheritDoc
|
|
1351
1157
|
*/
|
|
1352
|
-
export declare
|
|
1158
|
+
export declare class DeviceCapabilityModule extends BaseModule {
|
|
1159
|
+
constructor();
|
|
1353
1160
|
/**
|
|
1354
|
-
*
|
|
1161
|
+
* Checks whether the current device supports eSIM.
|
|
1355
1162
|
*
|
|
1356
|
-
* @
|
|
1357
|
-
*
|
|
1163
|
+
* @returns Whether eSIM is supported on the current device.
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* **Simple usage**
|
|
1167
|
+
* ```typescript
|
|
1168
|
+
* // Initialize the device capability module
|
|
1169
|
+
* const deviceCapabilityModule = new DeviceCapabilityModule();
|
|
1170
|
+
*
|
|
1171
|
+
* // Check eSIM support
|
|
1172
|
+
* const response = await deviceCapabilityModule.isEsimSupported();
|
|
1173
|
+
*
|
|
1174
|
+
* switch (response.status_code) {
|
|
1175
|
+
* case 200:
|
|
1176
|
+
* console.log('eSIM supported:', response.result);
|
|
1177
|
+
* break;
|
|
1178
|
+
* case 501:
|
|
1179
|
+
* console.log('Not in Grab app:', response.error);
|
|
1180
|
+
* break;
|
|
1181
|
+
* default:
|
|
1182
|
+
* console.log('Unexpected status code:', response);
|
|
1183
|
+
* }
|
|
1184
|
+
* ```
|
|
1185
|
+
*
|
|
1186
|
+
* @public
|
|
1358
1187
|
*/
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1188
|
+
isEsimSupported(): Promise<IsEsimSupportedResponse>;
|
|
1189
|
+
}
|
|
1361
1190
|
|
|
1362
1191
|
/**
|
|
1363
|
-
*
|
|
1192
|
+
* Request parameters for downloading a file via native bridge.
|
|
1193
|
+
*
|
|
1194
|
+
* @example
|
|
1195
|
+
* ```typescript
|
|
1196
|
+
* {
|
|
1197
|
+
* fileUrl: 'https://example.com/report.pdf',
|
|
1198
|
+
* fileName: 'report.pdf'
|
|
1199
|
+
* }
|
|
1200
|
+
* ```
|
|
1201
|
+
*
|
|
1202
|
+
* @public
|
|
1203
|
+
*/
|
|
1204
|
+
export declare type DownloadFileRequest = {
|
|
1205
|
+
/** The URL of the file to download. */
|
|
1206
|
+
fileUrl: string;
|
|
1207
|
+
/** The desired name for the downloaded file. */
|
|
1208
|
+
fileName: string;
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* Response when requesting a native file download.
|
|
1364
1213
|
*
|
|
1365
1214
|
* @remarks
|
|
1366
|
-
*
|
|
1215
|
+
* This response can have the following status codes:
|
|
1216
|
+
* - `204`: File downloaded successfully.
|
|
1217
|
+
* - `400`: Invalid request parameters such as invalid file URL, invalid domain, or missing file name.
|
|
1218
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1219
|
+
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1367
1220
|
*
|
|
1368
|
-
* @
|
|
1221
|
+
* @example
|
|
1222
|
+
* **Success response (204):**
|
|
1223
|
+
* ```typescript
|
|
1224
|
+
* {
|
|
1225
|
+
* status_code: 204
|
|
1226
|
+
* }
|
|
1227
|
+
* ```
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* **Bad request response (400):**
|
|
1231
|
+
* ```typescript
|
|
1232
|
+
* {
|
|
1233
|
+
* status_code: 400,
|
|
1234
|
+
* error: 'Invalid request'
|
|
1235
|
+
* }
|
|
1236
|
+
* ```
|
|
1237
|
+
*
|
|
1238
|
+
* @example
|
|
1239
|
+
* **Not implemented response (501) - outside Grab app:**
|
|
1240
|
+
* ```typescript
|
|
1241
|
+
* {
|
|
1242
|
+
* status_code: 501,
|
|
1243
|
+
* error: 'Not implemented: This method requires the Grab app environment'
|
|
1244
|
+
* }
|
|
1245
|
+
* ```
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* **Internal server error response (500):**
|
|
1249
|
+
* ```typescript
|
|
1250
|
+
* {
|
|
1251
|
+
* status_code: 500,
|
|
1252
|
+
* error: 'Internal server error'
|
|
1253
|
+
* }
|
|
1254
|
+
* ```
|
|
1369
1255
|
*
|
|
1370
1256
|
* @public
|
|
1371
1257
|
*/
|
|
1372
|
-
export declare type
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1258
|
+
export declare type DownloadFileResponse = BridgeResponse<204 | 400 | 500 | 501, DownloadFileResult>;
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* Result data structure for file download operations.
|
|
1262
|
+
*
|
|
1263
|
+
* @remarks
|
|
1264
|
+
* This is a void result type as successful downloads return status code 204 with no content.
|
|
1265
|
+
*
|
|
1266
|
+
* @public
|
|
1267
|
+
*/
|
|
1268
|
+
export declare type DownloadFileResult = void;
|
|
1378
1269
|
|
|
1379
1270
|
/**
|
|
1380
1271
|
* DRM content configuration for playback.
|
|
@@ -1436,12 +1327,27 @@ export declare type DRMContentConfig = Record<string, unknown>;
|
|
|
1436
1327
|
* @public
|
|
1437
1328
|
*/
|
|
1438
1329
|
export declare type DRMPlaybackEvent = {
|
|
1439
|
-
/** The type of playback event
|
|
1440
|
-
eventType:
|
|
1330
|
+
/** The type of playback event. */
|
|
1331
|
+
eventType: 'started' | 'paused' | 'ended' | 'error';
|
|
1441
1332
|
/** Additional event data as key-value pairs. */
|
|
1442
1333
|
data?: Record<string, unknown>;
|
|
1443
1334
|
};
|
|
1444
1335
|
|
|
1336
|
+
/**
|
|
1337
|
+
* Generic error response shape with a specific status code.
|
|
1338
|
+
* Used as the base for all error response types (4xx and 5xx).
|
|
1339
|
+
*
|
|
1340
|
+
* @typeParam Code - The HTTP status code (e.g., 400, 401, 500)
|
|
1341
|
+
*
|
|
1342
|
+
* @public
|
|
1343
|
+
*/
|
|
1344
|
+
export declare type ErrorResponse<Code extends number> = {
|
|
1345
|
+
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
1346
|
+
status_code: Code;
|
|
1347
|
+
/** Error message if the call failed */
|
|
1348
|
+
error: string;
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1445
1351
|
/**
|
|
1446
1352
|
* Response when fetching the user's email.
|
|
1447
1353
|
*
|
|
@@ -1449,7 +1355,8 @@ export declare type DRMPlaybackEvent = {
|
|
|
1449
1355
|
* This response can have the following status codes:
|
|
1450
1356
|
* - `200`: Email fetched successfully. The `result` contains the email address.
|
|
1451
1357
|
* - `400`: Invalid request - the request was malformed.
|
|
1452
|
-
* - `
|
|
1358
|
+
* - `426`: Upgrade Required - feature requires Grab app version 5.399 or above.
|
|
1359
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1453
1360
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1454
1361
|
*
|
|
1455
1362
|
* @example
|
|
@@ -1471,11 +1378,11 @@ export declare type DRMPlaybackEvent = {
|
|
|
1471
1378
|
* ```
|
|
1472
1379
|
*
|
|
1473
1380
|
* @example
|
|
1474
|
-
* **
|
|
1381
|
+
* **Upgrade Required response (426):**
|
|
1475
1382
|
* ```typescript
|
|
1476
1383
|
* {
|
|
1477
|
-
* status_code:
|
|
1478
|
-
* error: 'This
|
|
1384
|
+
* status_code: 426,
|
|
1385
|
+
* error: 'Upgrade Required: This method requires Grab app version 5.399.0 or above on iOS'
|
|
1479
1386
|
* }
|
|
1480
1387
|
* ```
|
|
1481
1388
|
*
|
|
@@ -1488,9 +1395,18 @@ export declare type DRMPlaybackEvent = {
|
|
|
1488
1395
|
* }
|
|
1489
1396
|
* ```
|
|
1490
1397
|
*
|
|
1398
|
+
* @example
|
|
1399
|
+
* **Internal server error response (500):**
|
|
1400
|
+
* ```typescript
|
|
1401
|
+
* {
|
|
1402
|
+
* status_code: 500,
|
|
1403
|
+
* error: 'Internal server error'
|
|
1404
|
+
* }
|
|
1405
|
+
* ```
|
|
1406
|
+
*
|
|
1491
1407
|
* @public
|
|
1492
1408
|
*/
|
|
1493
|
-
export declare type FetchEmailResponse =
|
|
1409
|
+
export declare type FetchEmailResponse = BridgeResponse<200 | 400 | 426 | 500 | 501, FetchEmailResult>;
|
|
1494
1410
|
|
|
1495
1411
|
/**
|
|
1496
1412
|
* Result object containing the user's email address.
|
|
@@ -1507,6 +1423,78 @@ export declare type FetchEmailResult = {
|
|
|
1507
1423
|
email: string;
|
|
1508
1424
|
};
|
|
1509
1425
|
|
|
1426
|
+
/**
|
|
1427
|
+
* JSBridge module for downloading files to the user's device.
|
|
1428
|
+
*
|
|
1429
|
+
* @group Modules
|
|
1430
|
+
*
|
|
1431
|
+
* @remarks
|
|
1432
|
+
* Initiates native file download handling in the Grab app using a file URL and file name.
|
|
1433
|
+
* This code must run on the Grab SuperApp's webview to function correctly.
|
|
1434
|
+
*
|
|
1435
|
+
* @example
|
|
1436
|
+
* **ES Module:**
|
|
1437
|
+
* ```typescript
|
|
1438
|
+
* import { FileModule } from '@grabjs/superapp-sdk';
|
|
1439
|
+
* const fileModule = new FileModule();
|
|
1440
|
+
* ```
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* **CDN (UMD):**
|
|
1444
|
+
* ```html
|
|
1445
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1446
|
+
* <script>
|
|
1447
|
+
* const fileModule = new SuperAppSDK.FileModule();
|
|
1448
|
+
* </script>
|
|
1449
|
+
* ```
|
|
1450
|
+
*
|
|
1451
|
+
* @public
|
|
1452
|
+
* @noInheritDoc
|
|
1453
|
+
*/
|
|
1454
|
+
export declare class FileModule extends BaseModule {
|
|
1455
|
+
constructor();
|
|
1456
|
+
/**
|
|
1457
|
+
* Downloads a file via the native bridge.
|
|
1458
|
+
*
|
|
1459
|
+
* @param request - File information, including URL and target file name.
|
|
1460
|
+
*
|
|
1461
|
+
* @returns Download operation result.
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* **Simple usage**
|
|
1465
|
+
* ```typescript
|
|
1466
|
+
* // Initialize the file module
|
|
1467
|
+
* const fileModule = new FileModule();
|
|
1468
|
+
*
|
|
1469
|
+
* // Download the file
|
|
1470
|
+
* const response = await fileModule.downloadFile({
|
|
1471
|
+
* fileUrl: 'https://example.com/report.pdf',
|
|
1472
|
+
* fileName: 'report.pdf',
|
|
1473
|
+
* });
|
|
1474
|
+
*
|
|
1475
|
+
* switch (response.status_code) {
|
|
1476
|
+
* case 204:
|
|
1477
|
+
* console.log('File downloaded successfully');
|
|
1478
|
+
* break;
|
|
1479
|
+
* case 400:
|
|
1480
|
+
* console.log('Bad request:', response.error);
|
|
1481
|
+
* break;
|
|
1482
|
+
* case 500:
|
|
1483
|
+
* console.log('Internal server error:', response.error);
|
|
1484
|
+
* break;
|
|
1485
|
+
* case 501:
|
|
1486
|
+
* console.log('Not in Grab app:', response.error);
|
|
1487
|
+
* break;
|
|
1488
|
+
* default:
|
|
1489
|
+
* console.log('Unexpected status code:', response);
|
|
1490
|
+
* }
|
|
1491
|
+
* ```
|
|
1492
|
+
*
|
|
1493
|
+
* @public
|
|
1494
|
+
*/
|
|
1495
|
+
downloadFile(request: DownloadFileRequest): Promise<DownloadFileResponse>;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1510
1498
|
/**
|
|
1511
1499
|
* Response when retrieving stored authorization artifacts.
|
|
1512
1500
|
*
|
|
@@ -1547,7 +1535,7 @@ export declare type FetchEmailResult = {
|
|
|
1547
1535
|
*
|
|
1548
1536
|
* @public
|
|
1549
1537
|
*/
|
|
1550
|
-
export declare type GetAuthorizationArtifactsResponse =
|
|
1538
|
+
export declare type GetAuthorizationArtifactsResponse = BridgeResponse<200 | 204 | 400, GetAuthorizationArtifactsResult>;
|
|
1551
1539
|
|
|
1552
1540
|
/**
|
|
1553
1541
|
* Result object containing the stored PKCE authorization artifacts.
|
|
@@ -1581,7 +1569,7 @@ export declare type GetAuthorizationArtifactsResult = {
|
|
|
1581
1569
|
nonce: string;
|
|
1582
1570
|
/** The redirect URI used in the authorization request. */
|
|
1583
1571
|
redirectUri: string;
|
|
1584
|
-
}
|
|
1572
|
+
};
|
|
1585
1573
|
|
|
1586
1574
|
/**
|
|
1587
1575
|
* Request parameters for getting a boolean value from storage.
|
|
@@ -1605,6 +1593,7 @@ export declare type GetBooleanRequest = {
|
|
|
1605
1593
|
* This response can have the following status codes:
|
|
1606
1594
|
* - `200`: Value retrieved successfully. The `result` contains the boolean value or null if not found.
|
|
1607
1595
|
* - `400`: Missing required parameters - key not provided.
|
|
1596
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1608
1597
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1609
1598
|
*
|
|
1610
1599
|
* @example
|
|
@@ -1643,9 +1632,18 @@ export declare type GetBooleanRequest = {
|
|
|
1643
1632
|
* }
|
|
1644
1633
|
* ```
|
|
1645
1634
|
*
|
|
1635
|
+
* @example
|
|
1636
|
+
* **Internal server error response (500):**
|
|
1637
|
+
* ```typescript
|
|
1638
|
+
* {
|
|
1639
|
+
* status_code: 500,
|
|
1640
|
+
* error: 'Internal server error'
|
|
1641
|
+
* }
|
|
1642
|
+
* ```
|
|
1643
|
+
*
|
|
1646
1644
|
* @public
|
|
1647
1645
|
*/
|
|
1648
|
-
export declare type GetBooleanResponse =
|
|
1646
|
+
export declare type GetBooleanResponse = BridgeResponse<200 | 400 | 500 | 501, GetBooleanResult>;
|
|
1649
1647
|
|
|
1650
1648
|
/**
|
|
1651
1649
|
* Result object containing the boolean value.
|
|
@@ -1676,6 +1674,7 @@ export declare type GetBooleanResult = {
|
|
|
1676
1674
|
* This response can have the following status codes:
|
|
1677
1675
|
* - `200`: Coordinates retrieved successfully. The `result` contains latitude and longitude.
|
|
1678
1676
|
* - `424`: GeoKit error - location services unavailable or permission denied.
|
|
1677
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1679
1678
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1680
1679
|
*
|
|
1681
1680
|
* @example
|
|
@@ -1705,9 +1704,18 @@ export declare type GetBooleanResult = {
|
|
|
1705
1704
|
* }
|
|
1706
1705
|
* ```
|
|
1707
1706
|
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* **Internal server error response (500):**
|
|
1709
|
+
* ```typescript
|
|
1710
|
+
* {
|
|
1711
|
+
* status_code: 500,
|
|
1712
|
+
* error: 'Internal server error'
|
|
1713
|
+
* }
|
|
1714
|
+
* ```
|
|
1715
|
+
*
|
|
1708
1716
|
* @public
|
|
1709
1717
|
*/
|
|
1710
|
-
export declare type GetCoordinateResponse =
|
|
1718
|
+
export declare type GetCoordinateResponse = BridgeResponse<200 | 424 | 500 | 501, GetCoordinateResult>;
|
|
1711
1719
|
|
|
1712
1720
|
/**
|
|
1713
1721
|
* Result object containing the geographic coordinates.
|
|
@@ -1733,6 +1741,7 @@ export declare type GetCoordinateResult = {
|
|
|
1733
1741
|
* This response can have the following status codes:
|
|
1734
1742
|
* - `200`: Country code retrieved successfully. The `result` contains the ISO country code.
|
|
1735
1743
|
* - `424`: GeoKit/Resolver error - location services unavailable.
|
|
1744
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1736
1745
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1737
1746
|
*
|
|
1738
1747
|
* @example
|
|
@@ -1771,9 +1780,18 @@ export declare type GetCoordinateResult = {
|
|
|
1771
1780
|
* }
|
|
1772
1781
|
* ```
|
|
1773
1782
|
*
|
|
1783
|
+
* @example
|
|
1784
|
+
* **Internal server error response (500):**
|
|
1785
|
+
* ```typescript
|
|
1786
|
+
* {
|
|
1787
|
+
* status_code: 500,
|
|
1788
|
+
* error: 'Internal server error'
|
|
1789
|
+
* }
|
|
1790
|
+
* ```
|
|
1791
|
+
*
|
|
1774
1792
|
* @public
|
|
1775
1793
|
*/
|
|
1776
|
-
export declare type GetCountryCodeResponse =
|
|
1794
|
+
export declare type GetCountryCodeResponse = BridgeResponse<200 | 424 | 500 | 501, GetCountryCodeResult>;
|
|
1777
1795
|
|
|
1778
1796
|
/**
|
|
1779
1797
|
* Result object containing the country code.
|
|
@@ -1817,6 +1835,7 @@ export declare type GetDoubleRequest = {
|
|
|
1817
1835
|
* This response can have the following status codes:
|
|
1818
1836
|
* - `200`: Value retrieved successfully. The `result` contains the double value or null if not found.
|
|
1819
1837
|
* - `400`: Missing required parameters - key not provided.
|
|
1838
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1820
1839
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1821
1840
|
*
|
|
1822
1841
|
* @example
|
|
@@ -1855,9 +1874,18 @@ export declare type GetDoubleRequest = {
|
|
|
1855
1874
|
* }
|
|
1856
1875
|
* ```
|
|
1857
1876
|
*
|
|
1877
|
+
* @example
|
|
1878
|
+
* **Internal server error response (500):**
|
|
1879
|
+
* ```typescript
|
|
1880
|
+
* {
|
|
1881
|
+
* status_code: 500,
|
|
1882
|
+
* error: 'Internal server error'
|
|
1883
|
+
* }
|
|
1884
|
+
* ```
|
|
1885
|
+
*
|
|
1858
1886
|
* @public
|
|
1859
1887
|
*/
|
|
1860
|
-
export declare type GetDoubleResponse =
|
|
1888
|
+
export declare type GetDoubleResponse = BridgeResponse<200 | 400 | 500 | 501, GetDoubleResult>;
|
|
1861
1889
|
|
|
1862
1890
|
/**
|
|
1863
1891
|
* Result object containing the double value.
|
|
@@ -1903,6 +1931,7 @@ export declare type GetIntRequest = {
|
|
|
1903
1931
|
* This response can have the following status codes:
|
|
1904
1932
|
* - `200`: Value retrieved successfully. The `result` contains the integer value or null if not found.
|
|
1905
1933
|
* - `400`: Missing required parameters - key not provided.
|
|
1934
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1906
1935
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1907
1936
|
*
|
|
1908
1937
|
* @example
|
|
@@ -1941,9 +1970,18 @@ export declare type GetIntRequest = {
|
|
|
1941
1970
|
* }
|
|
1942
1971
|
* ```
|
|
1943
1972
|
*
|
|
1973
|
+
* @example
|
|
1974
|
+
* **Internal server error response (500):**
|
|
1975
|
+
* ```typescript
|
|
1976
|
+
* {
|
|
1977
|
+
* status_code: 500,
|
|
1978
|
+
* error: 'Internal server error'
|
|
1979
|
+
* }
|
|
1980
|
+
* ```
|
|
1981
|
+
*
|
|
1944
1982
|
* @public
|
|
1945
1983
|
*/
|
|
1946
|
-
export declare type GetIntResponse =
|
|
1984
|
+
export declare type GetIntResponse = BridgeResponse<200 | 400 | 500 | 501, GetIntResult>;
|
|
1947
1985
|
|
|
1948
1986
|
/**
|
|
1949
1987
|
* Result object containing the integer value.
|
|
@@ -1973,6 +2011,7 @@ export declare type GetIntResult = {
|
|
|
1973
2011
|
* @remarks
|
|
1974
2012
|
* This response can have the following status codes:
|
|
1975
2013
|
* - `200`: Locale identifier retrieved successfully.
|
|
2014
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
1976
2015
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
1977
2016
|
*
|
|
1978
2017
|
* @example
|
|
@@ -2002,9 +2041,18 @@ export declare type GetIntResult = {
|
|
|
2002
2041
|
* }
|
|
2003
2042
|
* ```
|
|
2004
2043
|
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* **Internal server error response (500):**
|
|
2046
|
+
* ```typescript
|
|
2047
|
+
* {
|
|
2048
|
+
* status_code: 500,
|
|
2049
|
+
* error: 'Internal server error'
|
|
2050
|
+
* }
|
|
2051
|
+
* ```
|
|
2052
|
+
*
|
|
2005
2053
|
* @public
|
|
2006
2054
|
*/
|
|
2007
|
-
export declare type GetLanguageLocaleIdentifierResponse =
|
|
2055
|
+
export declare type GetLanguageLocaleIdentifierResponse = BridgeResponse<200 | 500 | 501, GetLanguageLocaleIdentifierResult>;
|
|
2008
2056
|
|
|
2009
2057
|
/**
|
|
2010
2058
|
* Result object containing the language locale identifier.
|
|
@@ -2036,12 +2084,79 @@ export declare type GetLanguageLocaleIdentifierResponse = Promise<ConstrainedBri
|
|
|
2036
2084
|
*/
|
|
2037
2085
|
export declare type GetLanguageLocaleIdentifierResult = string;
|
|
2038
2086
|
|
|
2087
|
+
/**
|
|
2088
|
+
* Response when reading the selected travel destination lowercase ISO 3166-1 alpha-2 country code.
|
|
2089
|
+
*
|
|
2090
|
+
* @remarks
|
|
2091
|
+
* This response can have the following status codes:
|
|
2092
|
+
* - `200`: The selected travel destination lowercase ISO 3166-1 alpha-2 country code was returned successfully.
|
|
2093
|
+
* - `204`: No selected travel destination is currently available.
|
|
2094
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2095
|
+
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2096
|
+
*
|
|
2097
|
+
* @example
|
|
2098
|
+
* **Success response (200):**
|
|
2099
|
+
* ```typescript
|
|
2100
|
+
* {
|
|
2101
|
+
* status_code: 200,
|
|
2102
|
+
* result: 'id'
|
|
2103
|
+
* }
|
|
2104
|
+
* ```
|
|
2105
|
+
*
|
|
2106
|
+
* @example
|
|
2107
|
+
* **No content response (204):**
|
|
2108
|
+
* ```typescript
|
|
2109
|
+
* {
|
|
2110
|
+
* status_code: 204
|
|
2111
|
+
* }
|
|
2112
|
+
* ```
|
|
2113
|
+
*
|
|
2114
|
+
* @example
|
|
2115
|
+
* **Not implemented response (501) - outside Grab app:**
|
|
2116
|
+
* ```typescript
|
|
2117
|
+
* {
|
|
2118
|
+
* status_code: 501,
|
|
2119
|
+
* error: 'Not implemented: This method requires the Grab app environment'
|
|
2120
|
+
* }
|
|
2121
|
+
* ```
|
|
2122
|
+
*
|
|
2123
|
+
* @example
|
|
2124
|
+
* **Internal server error response (500):**
|
|
2125
|
+
* ```typescript
|
|
2126
|
+
* {
|
|
2127
|
+
* status_code: 500,
|
|
2128
|
+
* error: 'Internal server error'
|
|
2129
|
+
* }
|
|
2130
|
+
* ```
|
|
2131
|
+
*
|
|
2132
|
+
* @public
|
|
2133
|
+
*/
|
|
2134
|
+
export declare type GetSelectedTravelDestinationResponse = BridgeResponse<200 | 204 | 500 | 501, GetSelectedTravelDestinationResult>;
|
|
2135
|
+
|
|
2136
|
+
/**
|
|
2137
|
+
* Result containing the selected travel destination lowercase ISO 3166-1 alpha-2 country code.
|
|
2138
|
+
*
|
|
2139
|
+
* @example
|
|
2140
|
+
* ```typescript
|
|
2141
|
+
* 'id'
|
|
2142
|
+
* ```
|
|
2143
|
+
*
|
|
2144
|
+
* @example
|
|
2145
|
+
* ```typescript
|
|
2146
|
+
* 'sg'
|
|
2147
|
+
* ```
|
|
2148
|
+
*
|
|
2149
|
+
* @public
|
|
2150
|
+
*/
|
|
2151
|
+
export declare type GetSelectedTravelDestinationResult = string;
|
|
2152
|
+
|
|
2039
2153
|
/**
|
|
2040
2154
|
* Response when getting session parameters.
|
|
2041
2155
|
*
|
|
2042
2156
|
* @remarks
|
|
2043
2157
|
* This response can have the following status codes:
|
|
2044
2158
|
* - `200`: Session parameters retrieved successfully.
|
|
2159
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2045
2160
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2046
2161
|
*
|
|
2047
2162
|
* @example
|
|
@@ -2062,9 +2177,18 @@ export declare type GetLanguageLocaleIdentifierResult = string;
|
|
|
2062
2177
|
* }
|
|
2063
2178
|
* ```
|
|
2064
2179
|
*
|
|
2180
|
+
* @example
|
|
2181
|
+
* **Internal server error response (500):**
|
|
2182
|
+
* ```typescript
|
|
2183
|
+
* {
|
|
2184
|
+
* status_code: 500,
|
|
2185
|
+
* error: 'Internal server error'
|
|
2186
|
+
* }
|
|
2187
|
+
* ```
|
|
2188
|
+
*
|
|
2065
2189
|
* @public
|
|
2066
2190
|
*/
|
|
2067
|
-
export declare type GetSessionParamsResponse =
|
|
2191
|
+
export declare type GetSessionParamsResponse = BridgeResponse<200 | 500 | 501, GetSessionParamsResult>;
|
|
2068
2192
|
|
|
2069
2193
|
/**
|
|
2070
2194
|
* Result object containing session parameters as a JSON string.
|
|
@@ -2108,6 +2232,7 @@ export declare type GetStringRequest = {
|
|
|
2108
2232
|
* This response can have the following status codes:
|
|
2109
2233
|
* - `200`: Value retrieved successfully. The `result` contains the string value or null if not found.
|
|
2110
2234
|
* - `400`: Missing required parameters - key not provided.
|
|
2235
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2111
2236
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2112
2237
|
*
|
|
2113
2238
|
* @example
|
|
@@ -2146,9 +2271,18 @@ export declare type GetStringRequest = {
|
|
|
2146
2271
|
* }
|
|
2147
2272
|
* ```
|
|
2148
2273
|
*
|
|
2149
|
-
* @
|
|
2150
|
-
|
|
2151
|
-
|
|
2274
|
+
* @example
|
|
2275
|
+
* **Internal server error response (500):**
|
|
2276
|
+
* ```typescript
|
|
2277
|
+
* {
|
|
2278
|
+
* status_code: 500,
|
|
2279
|
+
* error: 'Internal server error'
|
|
2280
|
+
* }
|
|
2281
|
+
* ```
|
|
2282
|
+
*
|
|
2283
|
+
* @public
|
|
2284
|
+
*/
|
|
2285
|
+
export declare type GetStringResponse = BridgeResponse<200 | 400 | 500 | 501, GetStringResult>;
|
|
2152
2286
|
|
|
2153
2287
|
/**
|
|
2154
2288
|
* Result object containing the string value.
|
|
@@ -2172,6 +2306,17 @@ export declare type GetStringResult = {
|
|
|
2172
2306
|
value: string | null;
|
|
2173
2307
|
};
|
|
2174
2308
|
|
|
2309
|
+
/**
|
|
2310
|
+
* Represents parsed information from a Grab app user agent string.
|
|
2311
|
+
*
|
|
2312
|
+
* @public
|
|
2313
|
+
*/
|
|
2314
|
+
export declare interface GrabAppInfo {
|
|
2315
|
+
appName: string;
|
|
2316
|
+
version: Version;
|
|
2317
|
+
platform: Platform;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2175
2320
|
/**
|
|
2176
2321
|
* Response when checking API access permissions.
|
|
2177
2322
|
*
|
|
@@ -2180,6 +2325,7 @@ export declare type GetStringResult = {
|
|
|
2180
2325
|
* - `200`: Access check completed successfully. The `result` contains the access status.
|
|
2181
2326
|
* - `400`: Missing required parameters - module or method not provided.
|
|
2182
2327
|
* - `424`: ScopeKit error - unable to check access due to a dependency error.
|
|
2328
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2183
2329
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2184
2330
|
*
|
|
2185
2331
|
* @example
|
|
@@ -2227,9 +2373,18 @@ export declare type GetStringResult = {
|
|
|
2227
2373
|
* }
|
|
2228
2374
|
* ```
|
|
2229
2375
|
*
|
|
2376
|
+
* @example
|
|
2377
|
+
* **Internal server error response (500):**
|
|
2378
|
+
* ```typescript
|
|
2379
|
+
* {
|
|
2380
|
+
* status_code: 500,
|
|
2381
|
+
* error: 'Internal server error'
|
|
2382
|
+
* }
|
|
2383
|
+
* ```
|
|
2384
|
+
*
|
|
2230
2385
|
* @public
|
|
2231
2386
|
*/
|
|
2232
|
-
export declare type HasAccessToResponse =
|
|
2387
|
+
export declare type HasAccessToResponse = BridgeResponse<200 | 400 | 424 | 500 | 501, HasAccessToResult>;
|
|
2233
2388
|
|
|
2234
2389
|
/**
|
|
2235
2390
|
* Result object containing the access check result.
|
|
@@ -2259,6 +2414,7 @@ export declare type HasAccessToResult = {
|
|
|
2259
2414
|
* @remarks
|
|
2260
2415
|
* This response can have the following status codes:
|
|
2261
2416
|
* - `200`: Back button hidden successfully.
|
|
2417
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2262
2418
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2263
2419
|
*
|
|
2264
2420
|
* @example
|
|
@@ -2276,9 +2432,18 @@ export declare type HasAccessToResult = {
|
|
|
2276
2432
|
* }
|
|
2277
2433
|
* ```
|
|
2278
2434
|
*
|
|
2435
|
+
* @example
|
|
2436
|
+
* **Internal server error response (500):**
|
|
2437
|
+
* ```typescript
|
|
2438
|
+
* {
|
|
2439
|
+
* status_code: 500,
|
|
2440
|
+
* error: 'Internal server error'
|
|
2441
|
+
* }
|
|
2442
|
+
* ```
|
|
2443
|
+
*
|
|
2279
2444
|
* @public
|
|
2280
2445
|
*/
|
|
2281
|
-
export declare type HideBackButtonResponse =
|
|
2446
|
+
export declare type HideBackButtonResponse = BridgeResponse<200 | 500 | 501, HideBackButtonResult>;
|
|
2282
2447
|
|
|
2283
2448
|
/**
|
|
2284
2449
|
* Result when hiding the back button.
|
|
@@ -2294,6 +2459,7 @@ export declare type HideBackButtonResult = void;
|
|
|
2294
2459
|
* @remarks
|
|
2295
2460
|
* This response can have the following status codes:
|
|
2296
2461
|
* - `200`: Loader hidden successfully.
|
|
2462
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2297
2463
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2298
2464
|
*
|
|
2299
2465
|
* @example
|
|
@@ -2311,9 +2477,18 @@ export declare type HideBackButtonResult = void;
|
|
|
2311
2477
|
* }
|
|
2312
2478
|
* ```
|
|
2313
2479
|
*
|
|
2480
|
+
* @example
|
|
2481
|
+
* **Internal server error response (500):**
|
|
2482
|
+
* ```typescript
|
|
2483
|
+
* {
|
|
2484
|
+
* status_code: 500,
|
|
2485
|
+
* error: 'Internal server error'
|
|
2486
|
+
* }
|
|
2487
|
+
* ```
|
|
2488
|
+
*
|
|
2314
2489
|
* @public
|
|
2315
2490
|
*/
|
|
2316
|
-
export declare type HideLoaderResponse =
|
|
2491
|
+
export declare type HideLoaderResponse = BridgeResponse<200 | 500 | 501, HideLoaderResult>;
|
|
2317
2492
|
|
|
2318
2493
|
/**
|
|
2319
2494
|
* Result when hiding the loader.
|
|
@@ -2329,6 +2504,7 @@ export declare type HideLoaderResult = void;
|
|
|
2329
2504
|
* @remarks
|
|
2330
2505
|
* This response can have the following status codes:
|
|
2331
2506
|
* - `200`: Refresh button hidden successfully.
|
|
2507
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2332
2508
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2333
2509
|
*
|
|
2334
2510
|
* @example
|
|
@@ -2346,9 +2522,18 @@ export declare type HideLoaderResult = void;
|
|
|
2346
2522
|
* }
|
|
2347
2523
|
* ```
|
|
2348
2524
|
*
|
|
2525
|
+
* @example
|
|
2526
|
+
* **Internal server error response (500):**
|
|
2527
|
+
* ```typescript
|
|
2528
|
+
* {
|
|
2529
|
+
* status_code: 500,
|
|
2530
|
+
* error: 'Internal server error'
|
|
2531
|
+
* }
|
|
2532
|
+
* ```
|
|
2533
|
+
*
|
|
2349
2534
|
* @public
|
|
2350
2535
|
*/
|
|
2351
|
-
export declare type HideRefreshButtonResponse =
|
|
2536
|
+
export declare type HideRefreshButtonResponse = BridgeResponse<200 | 500 | 501, HideRefreshButtonResult>;
|
|
2352
2537
|
|
|
2353
2538
|
/**
|
|
2354
2539
|
* Result when hiding the refresh button.
|
|
@@ -2385,6 +2570,7 @@ export declare type HideRefreshButtonResult = void;
|
|
|
2385
2570
|
* ```
|
|
2386
2571
|
*
|
|
2387
2572
|
* @public
|
|
2573
|
+
* @noInheritDoc
|
|
2388
2574
|
*/
|
|
2389
2575
|
export declare class IdentityModule extends BaseModule {
|
|
2390
2576
|
constructor();
|
|
@@ -2394,7 +2580,6 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2394
2580
|
* @param environment - The environment to fetch configuration for ('staging' or 'production').
|
|
2395
2581
|
* @returns The authorization endpoint URL.
|
|
2396
2582
|
* @throws Error when the environment is invalid or the configuration cannot be fetched.
|
|
2397
|
-
*
|
|
2398
2583
|
* @internal
|
|
2399
2584
|
*/
|
|
2400
2585
|
private fetchAuthorizationEndpoint;
|
|
@@ -2429,46 +2614,37 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2429
2614
|
* @example
|
|
2430
2615
|
* **Simple usage**
|
|
2431
2616
|
* ```typescript
|
|
2432
|
-
* // Imports using ES Module built
|
|
2433
|
-
* import { IdentityModule } from '@grabjs/superapp-sdk';
|
|
2434
|
-
* // Imports using UMD built (via CDN)
|
|
2435
|
-
* const { IdentityModule } = window.SuperAppSDK;
|
|
2436
|
-
*
|
|
2437
2617
|
* // Initialize the identity module
|
|
2438
2618
|
* const identityModule = new IdentityModule();
|
|
2439
2619
|
*
|
|
2440
2620
|
* // Retrieve stored authorization artifacts after authorization redirect
|
|
2441
|
-
*
|
|
2442
|
-
*
|
|
2443
|
-
*
|
|
2444
|
-
*
|
|
2445
|
-
*
|
|
2446
|
-
*
|
|
2447
|
-
*
|
|
2448
|
-
*
|
|
2449
|
-
*
|
|
2450
|
-
*
|
|
2451
|
-
*
|
|
2452
|
-
*
|
|
2453
|
-
*
|
|
2454
|
-
*
|
|
2455
|
-
*
|
|
2456
|
-
*
|
|
2457
|
-
*
|
|
2458
|
-
*
|
|
2459
|
-
*
|
|
2460
|
-
*
|
|
2461
|
-
*
|
|
2462
|
-
* console.log('Unexpected status code:', response);
|
|
2463
|
-
* }
|
|
2464
|
-
* } catch (error) {
|
|
2465
|
-
* console.log('Unexpected error:', error);
|
|
2621
|
+
* const response = await identityModule.getAuthorizationArtifacts();
|
|
2622
|
+
*
|
|
2623
|
+
* switch (response.status_code) {
|
|
2624
|
+
* case 200:
|
|
2625
|
+
* // All artifacts present - proceed with token exchange
|
|
2626
|
+
* const { state, codeVerifier, nonce, redirectUri } = response.result;
|
|
2627
|
+
* console.log('State:', state);
|
|
2628
|
+
* console.log('Code Verifier:', codeVerifier);
|
|
2629
|
+
* console.log('Nonce:', nonce);
|
|
2630
|
+
* console.log('Redirect URI:', redirectUri);
|
|
2631
|
+
* break;
|
|
2632
|
+
* case 204:
|
|
2633
|
+
* // No artifacts yet - user hasn't authorized
|
|
2634
|
+
* console.log('No authorization artifacts found. Authorization has not been initiated.');
|
|
2635
|
+
* break;
|
|
2636
|
+
* case 400:
|
|
2637
|
+
* // Inconsistent state - possible data corruption
|
|
2638
|
+
* console.error('Authorization artifacts error:', response.error);
|
|
2639
|
+
* break;
|
|
2640
|
+
* default:
|
|
2641
|
+
* console.log('Unexpected status code:', response);
|
|
2466
2642
|
* }
|
|
2467
2643
|
* ```
|
|
2468
2644
|
*
|
|
2469
2645
|
* @public
|
|
2470
2646
|
*/
|
|
2471
|
-
getAuthorizationArtifacts(): GetAuthorizationArtifactsResponse
|
|
2647
|
+
getAuthorizationArtifacts(): Promise<GetAuthorizationArtifactsResponse>;
|
|
2472
2648
|
/**
|
|
2473
2649
|
* Clears all stored PKCE authorization artifacts from local storage.
|
|
2474
2650
|
* This should be called after a successful token exchange or when you need to
|
|
@@ -2479,29 +2655,20 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2479
2655
|
* @example
|
|
2480
2656
|
* **Simple usage**
|
|
2481
2657
|
* ```typescript
|
|
2482
|
-
* // Imports using ES Module built
|
|
2483
|
-
* import { IdentityModule } from '@grabjs/superapp-sdk';
|
|
2484
|
-
* // Imports using UMD built (via CDN)
|
|
2485
|
-
* const { IdentityModule } = window.SuperAppSDK;
|
|
2486
|
-
*
|
|
2487
2658
|
* // Initialize the identity module
|
|
2488
2659
|
* const identityModule = new IdentityModule();
|
|
2489
2660
|
*
|
|
2490
2661
|
* // Clear stored authorization artifacts after successful token exchange
|
|
2491
|
-
*
|
|
2492
|
-
* const response = await identityModule.clearAuthorizationArtifacts();
|
|
2662
|
+
* const response = await identityModule.clearAuthorizationArtifacts();
|
|
2493
2663
|
*
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
* }
|
|
2497
|
-
* } catch (error) {
|
|
2498
|
-
* console.log('Unexpected error:', error);
|
|
2664
|
+
* if (response.status_code === 204) {
|
|
2665
|
+
* console.log('Authorization artifacts cleared');
|
|
2499
2666
|
* }
|
|
2500
2667
|
* ```
|
|
2501
2668
|
*
|
|
2502
2669
|
* @public
|
|
2503
2670
|
*/
|
|
2504
|
-
clearAuthorizationArtifacts(): ClearAuthorizationArtifactsResponse
|
|
2671
|
+
clearAuthorizationArtifacts(): Promise<ClearAuthorizationArtifactsResponse>;
|
|
2505
2672
|
/**
|
|
2506
2673
|
* Stores a value in local storage with the GrabID namespace prefix.
|
|
2507
2674
|
*
|
|
@@ -2576,8 +2743,6 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2576
2743
|
*
|
|
2577
2744
|
* @returns The authorization result, containing the authorization code on success or redirect status.
|
|
2578
2745
|
*
|
|
2579
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
2580
|
-
*
|
|
2581
2746
|
* @remarks
|
|
2582
2747
|
* **Important Note on redirectUri and responseMode:**
|
|
2583
2748
|
*
|
|
@@ -2605,54 +2770,45 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2605
2770
|
* @example
|
|
2606
2771
|
* **Simple usage**
|
|
2607
2772
|
* ```typescript
|
|
2608
|
-
* // Imports using ES Module built
|
|
2609
|
-
* import { IdentityModule } from '@grabjs/superapp-sdk';
|
|
2610
|
-
* // Imports using UMD built (via CDN)
|
|
2611
|
-
* const { IdentityModule } = window.SuperAppSDK;
|
|
2612
|
-
*
|
|
2613
2773
|
* // Initialize the identity module
|
|
2614
2774
|
* const identityModule = new IdentityModule();
|
|
2615
2775
|
*
|
|
2616
2776
|
* // Initiate authorization with redirect mode
|
|
2617
|
-
*
|
|
2618
|
-
*
|
|
2619
|
-
*
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2622
|
-
*
|
|
2623
|
-
* responseMode: 'redirect'
|
|
2777
|
+
* const response = await identityModule.authorize({
|
|
2778
|
+
* clientId: 'your-client-id',
|
|
2779
|
+
* redirectUri: 'https://your-app.com/callback',
|
|
2780
|
+
* scope: 'openid profile',
|
|
2781
|
+
* environment: 'production',
|
|
2782
|
+
* responseMode: 'redirect'
|
|
2624
2783
|
* });
|
|
2625
2784
|
*
|
|
2626
|
-
*
|
|
2627
|
-
*
|
|
2628
|
-
*
|
|
2629
|
-
*
|
|
2630
|
-
*
|
|
2631
|
-
*
|
|
2632
|
-
*
|
|
2633
|
-
*
|
|
2634
|
-
*
|
|
2635
|
-
*
|
|
2636
|
-
*
|
|
2637
|
-
*
|
|
2638
|
-
*
|
|
2639
|
-
*
|
|
2640
|
-
*
|
|
2641
|
-
*
|
|
2642
|
-
*
|
|
2643
|
-
*
|
|
2644
|
-
*
|
|
2645
|
-
*
|
|
2646
|
-
*
|
|
2647
|
-
* }
|
|
2648
|
-
* } catch (error) {
|
|
2649
|
-
* console.log('Unexpected error:', error);
|
|
2785
|
+
* switch (response.status_code) {
|
|
2786
|
+
* case 200:
|
|
2787
|
+
* // Authorization successful (in_place mode with native flow)
|
|
2788
|
+
* console.log('Auth Code:', response.result.code);
|
|
2789
|
+
* console.log('State:', response.result.state);
|
|
2790
|
+
* break;
|
|
2791
|
+
* case 302:
|
|
2792
|
+
* // Redirect in progress (web flow with responseMode: 'redirect')
|
|
2793
|
+
* // The page will be redirected to the authorization URL
|
|
2794
|
+
* console.log('Redirecting to authorization...');
|
|
2795
|
+
* break;
|
|
2796
|
+
* case 204:
|
|
2797
|
+
* // User cancelled or flow completed without result data
|
|
2798
|
+
* console.log('Authorization cancelled or no content');
|
|
2799
|
+
* break;
|
|
2800
|
+
* case 400:
|
|
2801
|
+
* // Authorization failed
|
|
2802
|
+
* console.error('Auth error:', response.error);
|
|
2803
|
+
* break;
|
|
2804
|
+
* default:
|
|
2805
|
+
* console.log('Unexpected status code:', response);
|
|
2650
2806
|
* }
|
|
2651
2807
|
* ```
|
|
2652
2808
|
*
|
|
2653
2809
|
* @public
|
|
2654
2810
|
*/
|
|
2655
|
-
authorize(request: AuthorizeRequest): AuthorizeResponse
|
|
2811
|
+
authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;
|
|
2656
2812
|
/**
|
|
2657
2813
|
* Validates that a required string field is present and non-empty.
|
|
2658
2814
|
*
|
|
@@ -2674,6 +2830,41 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2674
2830
|
private static validateAuthorizeRequest;
|
|
2675
2831
|
}
|
|
2676
2832
|
|
|
2833
|
+
/**
|
|
2834
|
+
* Options for invoking a JSBridge method.
|
|
2835
|
+
*
|
|
2836
|
+
* @public
|
|
2837
|
+
*/
|
|
2838
|
+
export declare interface InvokeOptions<T> {
|
|
2839
|
+
/** The name of the JSBridge method to invoke */
|
|
2840
|
+
method: string;
|
|
2841
|
+
/** The parameters to pass to the method */
|
|
2842
|
+
params?: unknown;
|
|
2843
|
+
/** Validator function - returns false = 426 with default error */
|
|
2844
|
+
isSupported?: (appInfo: GrabAppInfo) => boolean;
|
|
2845
|
+
/** Optional response transformation function */
|
|
2846
|
+
transformResponse?: (response: BridgeResponse<BridgeStatusCode, T>) => BridgeResponse<BridgeStatusCode, T>;
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
/**
|
|
2850
|
+
* Type guard to check if a JSBridge response is a client error (4xx status codes).
|
|
2851
|
+
*
|
|
2852
|
+
* @param response - The JSBridge response to check
|
|
2853
|
+
* @returns True if the response is a client error (400, 401, 403, 404, 424, 426), false otherwise
|
|
2854
|
+
*
|
|
2855
|
+
* @example
|
|
2856
|
+
* ```typescript
|
|
2857
|
+
* const response = await someBridgeMethod();
|
|
2858
|
+
* if (isClientError(response)) {
|
|
2859
|
+
* // response is narrowed to BridgeClientError
|
|
2860
|
+
* console.error('Client error:', response.error);
|
|
2861
|
+
* }
|
|
2862
|
+
* ```
|
|
2863
|
+
*
|
|
2864
|
+
* @public
|
|
2865
|
+
*/
|
|
2866
|
+
export declare function isClientError<T>(response: BridgeResponse<BridgeStatusCode, T>): response is BridgeClientError;
|
|
2867
|
+
|
|
2677
2868
|
/**
|
|
2678
2869
|
* Response when checking connection status.
|
|
2679
2870
|
*
|
|
@@ -2702,7 +2893,7 @@ export declare class IdentityModule extends BaseModule {
|
|
|
2702
2893
|
*
|
|
2703
2894
|
* @public
|
|
2704
2895
|
*/
|
|
2705
|
-
export declare type IsConnectedResponse =
|
|
2896
|
+
export declare type IsConnectedResponse = BridgeResponse<200 | 404, IsConnectedResult>;
|
|
2706
2897
|
|
|
2707
2898
|
/**
|
|
2708
2899
|
* Result object containing the connection status.
|
|
@@ -2726,6 +2917,153 @@ export declare type IsConnectedResult = {
|
|
|
2726
2917
|
connected: boolean;
|
|
2727
2918
|
};
|
|
2728
2919
|
|
|
2920
|
+
/**
|
|
2921
|
+
* Type guard to check if a JSBridge response is an error (4xx or 5xx status codes).
|
|
2922
|
+
*
|
|
2923
|
+
* @param response - The JSBridge response to check
|
|
2924
|
+
* @returns True if the response is any error (4xx or 5xx), false otherwise
|
|
2925
|
+
*
|
|
2926
|
+
* @example
|
|
2927
|
+
* ```typescript
|
|
2928
|
+
* const response = await someBridgeMethod();
|
|
2929
|
+
* if (isErrorResponse(response)) {
|
|
2930
|
+
* // response is narrowed to BridgeError
|
|
2931
|
+
* console.error('Error:', response.error);
|
|
2932
|
+
* } else {
|
|
2933
|
+
* // response is successful or redirect
|
|
2934
|
+
* console.log('Success!');
|
|
2935
|
+
* }
|
|
2936
|
+
* ```
|
|
2937
|
+
*
|
|
2938
|
+
* @public
|
|
2939
|
+
*/
|
|
2940
|
+
export declare function isErrorResponse<T>(response: BridgeResponse<BridgeStatusCode, T>): response is BridgeError;
|
|
2941
|
+
|
|
2942
|
+
/**
|
|
2943
|
+
* Response when checking whether the current device supports eSIM.
|
|
2944
|
+
*
|
|
2945
|
+
* @remarks
|
|
2946
|
+
* This response can have the following status codes:
|
|
2947
|
+
* - `200`: eSIM capability was checked successfully. The `result` contains `true` or `false`.
|
|
2948
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
2949
|
+
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
2950
|
+
*
|
|
2951
|
+
* @example
|
|
2952
|
+
* **Success response (200) - eSIM supported:**
|
|
2953
|
+
* ```typescript
|
|
2954
|
+
* {
|
|
2955
|
+
* status_code: 200,
|
|
2956
|
+
* result: true
|
|
2957
|
+
* }
|
|
2958
|
+
* ```
|
|
2959
|
+
*
|
|
2960
|
+
* @example
|
|
2961
|
+
* **Success response (200) - eSIM not supported:**
|
|
2962
|
+
* ```typescript
|
|
2963
|
+
* {
|
|
2964
|
+
* status_code: 200,
|
|
2965
|
+
* result: false
|
|
2966
|
+
* }
|
|
2967
|
+
* ```
|
|
2968
|
+
*
|
|
2969
|
+
* @example
|
|
2970
|
+
* **Not implemented response (501) - outside Grab app:**
|
|
2971
|
+
* ```typescript
|
|
2972
|
+
* {
|
|
2973
|
+
* status_code: 501,
|
|
2974
|
+
* error: 'Not implemented: This method requires the Grab app environment'
|
|
2975
|
+
* }
|
|
2976
|
+
* ```
|
|
2977
|
+
*
|
|
2978
|
+
* @example
|
|
2979
|
+
* **Internal server error response (500):**
|
|
2980
|
+
* ```typescript
|
|
2981
|
+
* {
|
|
2982
|
+
* status_code: 500,
|
|
2983
|
+
* error: 'Internal server error'
|
|
2984
|
+
* }
|
|
2985
|
+
* ```
|
|
2986
|
+
*
|
|
2987
|
+
* @public
|
|
2988
|
+
*/
|
|
2989
|
+
export declare type IsEsimSupportedResponse = BridgeResponse<200 | 500 | 501, IsEsimSupportedResult>;
|
|
2990
|
+
|
|
2991
|
+
/**
|
|
2992
|
+
* Result indicating whether the current device supports eSIM.
|
|
2993
|
+
*
|
|
2994
|
+
* @example
|
|
2995
|
+
* ```typescript
|
|
2996
|
+
* true
|
|
2997
|
+
* ```
|
|
2998
|
+
*
|
|
2999
|
+
* @example
|
|
3000
|
+
* ```typescript
|
|
3001
|
+
* false
|
|
3002
|
+
* ```
|
|
3003
|
+
*
|
|
3004
|
+
* @public
|
|
3005
|
+
*/
|
|
3006
|
+
export declare type IsEsimSupportedResult = boolean;
|
|
3007
|
+
|
|
3008
|
+
/**
|
|
3009
|
+
* Type guard to check if a JSBridge response is a redirect (status code 302).
|
|
3010
|
+
*
|
|
3011
|
+
* @param response - The JSBridge response to check
|
|
3012
|
+
* @returns True if the response is a redirect (302), false otherwise
|
|
3013
|
+
*
|
|
3014
|
+
* @example
|
|
3015
|
+
* ```typescript
|
|
3016
|
+
* const response = await someBridgeMethod();
|
|
3017
|
+
* if (isRedirection(response)) {
|
|
3018
|
+
* // response is narrowed to BridgeRedirection
|
|
3019
|
+
* console.log('Redirecting...');
|
|
3020
|
+
* }
|
|
3021
|
+
* ```
|
|
3022
|
+
*
|
|
3023
|
+
* @public
|
|
3024
|
+
*/
|
|
3025
|
+
export declare function isRedirection<T>(response: BridgeResponse<BridgeStatusCode, T>): response is BridgeRedirection;
|
|
3026
|
+
|
|
3027
|
+
/**
|
|
3028
|
+
* Type guard to check if a JSBridge response is a server error (5xx status codes).
|
|
3029
|
+
*
|
|
3030
|
+
* @param response - The JSBridge response to check
|
|
3031
|
+
* @returns True if the response is a server error (500, 501), false otherwise
|
|
3032
|
+
*
|
|
3033
|
+
* @example
|
|
3034
|
+
* ```typescript
|
|
3035
|
+
* const response = await someBridgeMethod();
|
|
3036
|
+
* if (isServerError(response)) {
|
|
3037
|
+
* // response is narrowed to BridgeServerError
|
|
3038
|
+
* console.error('Server error:', response.error);
|
|
3039
|
+
* }
|
|
3040
|
+
* ```
|
|
3041
|
+
*
|
|
3042
|
+
* @public
|
|
3043
|
+
*/
|
|
3044
|
+
export declare function isServerError<T>(response: BridgeResponse<BridgeStatusCode, T>): response is BridgeServerError;
|
|
3045
|
+
|
|
3046
|
+
/**
|
|
3047
|
+
* Type guard to check if a JSBridge response is successful (status codes 200 or 204).
|
|
3048
|
+
*
|
|
3049
|
+
* @param response - The JSBridge response to check
|
|
3050
|
+
* @returns True if the response is successful (200 or 204), false otherwise
|
|
3051
|
+
*
|
|
3052
|
+
* @example
|
|
3053
|
+
* ```typescript
|
|
3054
|
+
* const response = await someBridgeMethod();
|
|
3055
|
+
* if (isSuccess(response)) {
|
|
3056
|
+
* // response is narrowed to BridgeSuccessResponse<T>
|
|
3057
|
+
* if (response.status_code === 200) {
|
|
3058
|
+
* console.log(response.result);
|
|
3059
|
+
* }
|
|
3060
|
+
* }
|
|
3061
|
+
* ```
|
|
3062
|
+
*
|
|
3063
|
+
* @public
|
|
3064
|
+
*/
|
|
3065
|
+
export declare function isSuccess<T>(response: BridgeResponse<BridgeStatusCode, T>): response is BridgeSuccessResponse<T>;
|
|
3066
|
+
|
|
2729
3067
|
/**
|
|
2730
3068
|
* JSBridge module for accessing device locale settings.
|
|
2731
3069
|
*
|
|
@@ -2752,6 +3090,7 @@ export declare type IsConnectedResult = {
|
|
|
2752
3090
|
* ```
|
|
2753
3091
|
*
|
|
2754
3092
|
* @public
|
|
3093
|
+
* @noInheritDoc
|
|
2755
3094
|
*/
|
|
2756
3095
|
export declare class LocaleModule extends BaseModule {
|
|
2757
3096
|
constructor();
|
|
@@ -2760,41 +3099,30 @@ export declare class LocaleModule extends BaseModule {
|
|
|
2760
3099
|
*
|
|
2761
3100
|
* @returns The user's preferred language locale string (e.g., 'en-SG', 'id-ID').
|
|
2762
3101
|
*
|
|
2763
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
2764
|
-
*
|
|
2765
3102
|
* @example
|
|
2766
3103
|
* **Simple usage**
|
|
2767
3104
|
* ```typescript
|
|
2768
|
-
* // Imports using ES Module built
|
|
2769
|
-
* import { LocaleModule } from '@grabjs/superapp-sdk';
|
|
2770
|
-
* // Imports using UMD built (via CDN)
|
|
2771
|
-
* const { LocaleModule } = window.SuperAppSDK;
|
|
2772
|
-
*
|
|
2773
3105
|
* // Initialize the locale module
|
|
2774
3106
|
* const localeModule = new LocaleModule();
|
|
2775
3107
|
*
|
|
2776
3108
|
* // Get the current locale
|
|
2777
|
-
*
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
2780
|
-
*
|
|
2781
|
-
*
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
2784
|
-
*
|
|
2785
|
-
*
|
|
2786
|
-
*
|
|
2787
|
-
*
|
|
2788
|
-
* console.log('Unexpected status code:', response);
|
|
2789
|
-
* }
|
|
2790
|
-
* } catch (error) {
|
|
2791
|
-
* console.log('Unexpected error:', error);
|
|
3109
|
+
* const response = await localeModule.getLanguageLocaleIdentifier();
|
|
3110
|
+
*
|
|
3111
|
+
* switch (response.status_code) {
|
|
3112
|
+
* case 200:
|
|
3113
|
+
* console.log('Current locale:', response.result);
|
|
3114
|
+
* break;
|
|
3115
|
+
* case 501:
|
|
3116
|
+
* console.log('Not in Grab app:', response.error);
|
|
3117
|
+
* break;
|
|
3118
|
+
* default:
|
|
3119
|
+
* console.log('Unexpected status code:', response);
|
|
2792
3120
|
* }
|
|
2793
3121
|
* ```
|
|
2794
3122
|
*
|
|
2795
3123
|
* @public
|
|
2796
3124
|
*/
|
|
2797
|
-
getLanguageLocaleIdentifier(): GetLanguageLocaleIdentifierResponse
|
|
3125
|
+
getLanguageLocaleIdentifier(): Promise<GetLanguageLocaleIdentifierResponse>;
|
|
2798
3126
|
}
|
|
2799
3127
|
|
|
2800
3128
|
/**
|
|
@@ -2823,6 +3151,7 @@ export declare class LocaleModule extends BaseModule {
|
|
|
2823
3151
|
* ```
|
|
2824
3152
|
*
|
|
2825
3153
|
* @public
|
|
3154
|
+
* @noInheritDoc
|
|
2826
3155
|
*/
|
|
2827
3156
|
export declare class LocationModule extends BaseModule {
|
|
2828
3157
|
constructor();
|
|
@@ -2831,60 +3160,42 @@ export declare class LocationModule extends BaseModule {
|
|
|
2831
3160
|
*
|
|
2832
3161
|
* @returns The device's current latitude and longitude coordinates.
|
|
2833
3162
|
*
|
|
2834
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
2835
|
-
*
|
|
2836
3163
|
* @example
|
|
2837
3164
|
* **Simple usage**
|
|
2838
3165
|
* ```typescript
|
|
2839
|
-
* // Imports using ES Module built
|
|
2840
|
-
* import { LocationModule } from '@grabjs/superapp-sdk';
|
|
2841
|
-
* // Imports using UMD built (via CDN)
|
|
2842
|
-
* const { LocationModule } = window.SuperAppSDK;
|
|
2843
|
-
*
|
|
2844
3166
|
* // Initialize the location module
|
|
2845
3167
|
* const locationModule = new LocationModule();
|
|
2846
3168
|
*
|
|
2847
3169
|
* // Get current coordinates
|
|
2848
|
-
*
|
|
2849
|
-
*
|
|
2850
|
-
*
|
|
2851
|
-
*
|
|
2852
|
-
*
|
|
2853
|
-
*
|
|
2854
|
-
*
|
|
2855
|
-
*
|
|
2856
|
-
*
|
|
2857
|
-
*
|
|
2858
|
-
*
|
|
2859
|
-
*
|
|
2860
|
-
*
|
|
2861
|
-
*
|
|
2862
|
-
* console.log('Unexpected status code:', response);
|
|
2863
|
-
* }
|
|
2864
|
-
* } catch (error) {
|
|
2865
|
-
* console.log('Unexpected error:', error);
|
|
3170
|
+
* const response = await locationModule.getCoordinate();
|
|
3171
|
+
*
|
|
3172
|
+
* switch (response.status_code) {
|
|
3173
|
+
* case 200:
|
|
3174
|
+
* console.log('Coordinates:', response.result.lat, response.result.lng);
|
|
3175
|
+
* break;
|
|
3176
|
+
* case 424:
|
|
3177
|
+
* console.log('Could not get coordinates:', response.error);
|
|
3178
|
+
* break;
|
|
3179
|
+
* case 501:
|
|
3180
|
+
* console.log('Not in Grab app:', response.error);
|
|
3181
|
+
* break;
|
|
3182
|
+
* default:
|
|
3183
|
+
* console.log('Unexpected status code:', response);
|
|
2866
3184
|
* }
|
|
2867
3185
|
* ```
|
|
2868
3186
|
*
|
|
2869
3187
|
* @public
|
|
2870
3188
|
*/
|
|
2871
|
-
getCoordinate(): GetCoordinateResponse
|
|
3189
|
+
getCoordinate(): Promise<GetCoordinateResponse>;
|
|
2872
3190
|
/**
|
|
2873
3191
|
* Subscribe to location change updates from the device.
|
|
2874
3192
|
*
|
|
2875
|
-
* @returns A `
|
|
3193
|
+
* @returns A `BridgeStream` that emits location updates as the device location changes.
|
|
2876
3194
|
* Use `subscribe()` to listen for updates, or `await` to get the first value only.
|
|
2877
3195
|
*
|
|
2878
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
2879
|
-
*
|
|
2880
3196
|
* @example
|
|
2881
3197
|
* **Simple usage**
|
|
2882
3198
|
* ```typescript
|
|
2883
|
-
* // Imports using ES Module built
|
|
2884
|
-
* import { LocationModule } from '@grabjs/superapp-sdk';
|
|
2885
|
-
* // Imports using UMD built (via CDN)
|
|
2886
|
-
* const { LocationModule } = window.SuperAppSDK;
|
|
2887
|
-
*
|
|
2888
3199
|
* // Initialize the location module
|
|
2889
3200
|
* const locationModule = new LocationModule();
|
|
2890
3201
|
*
|
|
@@ -2910,44 +3221,33 @@ export declare class LocationModule extends BaseModule {
|
|
|
2910
3221
|
*
|
|
2911
3222
|
* @returns The ISO country code (e.g., 'SG', 'ID') based on the device's location.
|
|
2912
3223
|
*
|
|
2913
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
2914
|
-
*
|
|
2915
3224
|
* @example
|
|
2916
3225
|
* **Simple usage**
|
|
2917
3226
|
* ```typescript
|
|
2918
|
-
* // Imports using ES Module built
|
|
2919
|
-
* import { LocationModule } from '@grabjs/superapp-sdk';
|
|
2920
|
-
* // Imports using UMD built (via CDN)
|
|
2921
|
-
* const { LocationModule } = window.SuperAppSDK;
|
|
2922
|
-
*
|
|
2923
3227
|
* // Initialize the location module
|
|
2924
3228
|
* const locationModule = new LocationModule();
|
|
2925
3229
|
*
|
|
2926
3230
|
* // Get country code
|
|
2927
|
-
*
|
|
2928
|
-
*
|
|
2929
|
-
*
|
|
2930
|
-
*
|
|
2931
|
-
*
|
|
2932
|
-
*
|
|
2933
|
-
*
|
|
2934
|
-
*
|
|
2935
|
-
*
|
|
2936
|
-
*
|
|
2937
|
-
*
|
|
2938
|
-
*
|
|
2939
|
-
*
|
|
2940
|
-
*
|
|
2941
|
-
* console.log('Unexpected status code:', response);
|
|
2942
|
-
* }
|
|
2943
|
-
* } catch (error) {
|
|
2944
|
-
* console.log('Unexpected error:', error);
|
|
3231
|
+
* const response = await locationModule.getCountryCode();
|
|
3232
|
+
*
|
|
3233
|
+
* switch (response.status_code) {
|
|
3234
|
+
* case 200:
|
|
3235
|
+
* console.log('Country code:', response.result.countryCode);
|
|
3236
|
+
* break;
|
|
3237
|
+
* case 424:
|
|
3238
|
+
* console.log('Could not get country code:', response.error);
|
|
3239
|
+
* break;
|
|
3240
|
+
* case 501:
|
|
3241
|
+
* console.log('Not in Grab app:', response.error);
|
|
3242
|
+
* break;
|
|
3243
|
+
* default:
|
|
3244
|
+
* console.log('Unexpected status code:', response);
|
|
2945
3245
|
* }
|
|
2946
3246
|
* ```
|
|
2947
3247
|
*
|
|
2948
3248
|
* @public
|
|
2949
3249
|
*/
|
|
2950
|
-
getCountryCode(): GetCountryCodeResponse
|
|
3250
|
+
getCountryCode(): Promise<GetCountryCodeResponse>;
|
|
2951
3251
|
}
|
|
2952
3252
|
|
|
2953
3253
|
/**
|
|
@@ -2976,6 +3276,7 @@ export declare class LocationModule extends BaseModule {
|
|
|
2976
3276
|
* ```
|
|
2977
3277
|
*
|
|
2978
3278
|
* @public
|
|
3279
|
+
* @noInheritDoc
|
|
2979
3280
|
*/
|
|
2980
3281
|
export declare class MediaModule extends BaseModule {
|
|
2981
3282
|
constructor();
|
|
@@ -2986,46 +3287,35 @@ export declare class MediaModule extends BaseModule {
|
|
|
2986
3287
|
*
|
|
2987
3288
|
* @returns The playback initiation result, indicating if the DRM content started playing.
|
|
2988
3289
|
*
|
|
2989
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
2990
|
-
*
|
|
2991
3290
|
* @example
|
|
2992
3291
|
* **Simple usage**
|
|
2993
3292
|
* ```typescript
|
|
2994
|
-
* // Imports using ES Module built
|
|
2995
|
-
* import { MediaModule } from '@grabjs/superapp-sdk';
|
|
2996
|
-
* // Imports using UMD built (via CDN)
|
|
2997
|
-
* const { MediaModule } = window.SuperAppSDK;
|
|
2998
|
-
*
|
|
2999
3293
|
* // Initialize the media module
|
|
3000
3294
|
* const mediaModule = new MediaModule();
|
|
3001
3295
|
*
|
|
3002
3296
|
* // Play DRM content
|
|
3003
|
-
*
|
|
3004
|
-
*
|
|
3005
|
-
*
|
|
3006
|
-
* });
|
|
3297
|
+
* const response = await mediaModule.playDRMContent({
|
|
3298
|
+
* // DRM content configuration
|
|
3299
|
+
* });
|
|
3007
3300
|
*
|
|
3008
|
-
*
|
|
3009
|
-
*
|
|
3010
|
-
*
|
|
3011
|
-
*
|
|
3012
|
-
*
|
|
3013
|
-
*
|
|
3014
|
-
*
|
|
3015
|
-
*
|
|
3016
|
-
*
|
|
3017
|
-
*
|
|
3018
|
-
*
|
|
3019
|
-
*
|
|
3020
|
-
* }
|
|
3021
|
-
* } catch (error) {
|
|
3022
|
-
* console.log('Unexpected error:', error);
|
|
3301
|
+
* switch (response.status_code) {
|
|
3302
|
+
* case 200:
|
|
3303
|
+
* console.log('Playback initiated');
|
|
3304
|
+
* break;
|
|
3305
|
+
* case 204:
|
|
3306
|
+
* console.log('Invalid parameters');
|
|
3307
|
+
* break;
|
|
3308
|
+
* case 501:
|
|
3309
|
+
* console.log('Not in Grab app:', response.error);
|
|
3310
|
+
* break;
|
|
3311
|
+
* default:
|
|
3312
|
+
* console.log('Unexpected status code:', response);
|
|
3023
3313
|
* }
|
|
3024
3314
|
* ```
|
|
3025
3315
|
*
|
|
3026
3316
|
* @public
|
|
3027
3317
|
*/
|
|
3028
|
-
playDRMContent(data: DRMContentConfig): PlayDRMContentResponse
|
|
3318
|
+
playDRMContent(data: DRMContentConfig): Promise<PlayDRMContentResponse>;
|
|
3029
3319
|
/**
|
|
3030
3320
|
* Observes DRM-protected media content playback events.
|
|
3031
3321
|
*
|
|
@@ -3033,16 +3323,9 @@ export declare class MediaModule extends BaseModule {
|
|
|
3033
3323
|
*
|
|
3034
3324
|
* @returns A stream that emits playback events as the media plays.
|
|
3035
3325
|
*
|
|
3036
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
3037
|
-
*
|
|
3038
3326
|
* @example
|
|
3039
3327
|
* **Simple usage**
|
|
3040
3328
|
* ```typescript
|
|
3041
|
-
* // Imports using ES Module built
|
|
3042
|
-
* import { MediaModule } from '@grabjs/superapp-sdk';
|
|
3043
|
-
* // Imports using UMD built (via CDN)
|
|
3044
|
-
* const { MediaModule } = window.SuperAppSDK;
|
|
3045
|
-
*
|
|
3046
3329
|
* // Initialize the media module
|
|
3047
3330
|
* const mediaModule = new MediaModule();
|
|
3048
3331
|
*
|
|
@@ -3070,16 +3353,30 @@ export declare class MediaModule extends BaseModule {
|
|
|
3070
3353
|
/**
|
|
3071
3354
|
* Response stream for observing DRM playback events.
|
|
3072
3355
|
*
|
|
3356
|
+
* @remarks
|
|
3357
|
+
* This is a `BridgeStream` that can be:
|
|
3358
|
+
* - Subscribed to via `.subscribe()` for continuous updates
|
|
3359
|
+
* - Awaited via `await` to get the first value only
|
|
3360
|
+
*
|
|
3361
|
+
* The stream can emit status codes 200 (event data), 500 (server error), or 501 (not implemented).
|
|
3362
|
+
*
|
|
3073
3363
|
* @public
|
|
3074
3364
|
*/
|
|
3075
|
-
export declare type ObserveDRMPlaybackResponse =
|
|
3365
|
+
export declare type ObserveDRMPlaybackResponse = BridgeStream<200 | 500 | 501, DRMPlaybackEvent>;
|
|
3076
3366
|
|
|
3077
3367
|
/**
|
|
3078
3368
|
* Response when observing the device coordinates.
|
|
3079
3369
|
*
|
|
3370
|
+
* @remarks
|
|
3371
|
+
* This is a `BridgeStream` that can be:
|
|
3372
|
+
* - Subscribed to via `.subscribe()` for continuous updates
|
|
3373
|
+
* - Awaited via `await` to get the first value only
|
|
3374
|
+
*
|
|
3375
|
+
* The stream can emit the same status codes as {@link GetCoordinateResponse}.
|
|
3376
|
+
*
|
|
3080
3377
|
* @public
|
|
3081
3378
|
*/
|
|
3082
|
-
export declare type ObserveLocationChangeResponse =
|
|
3379
|
+
export declare type ObserveLocationChangeResponse = BridgeStream<200 | 424 | 500 | 501, GetCoordinateResult>;
|
|
3083
3380
|
|
|
3084
3381
|
/**
|
|
3085
3382
|
* Response when notifying content loaded.
|
|
@@ -3087,6 +3384,7 @@ export declare type ObserveLocationChangeResponse = DataStream_2<GetCoordinateRe
|
|
|
3087
3384
|
* @remarks
|
|
3088
3385
|
* This response can have the following status codes:
|
|
3089
3386
|
* - `200`: Notification sent successfully.
|
|
3387
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3090
3388
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3091
3389
|
*
|
|
3092
3390
|
* @example
|
|
@@ -3104,9 +3402,18 @@ export declare type ObserveLocationChangeResponse = DataStream_2<GetCoordinateRe
|
|
|
3104
3402
|
* }
|
|
3105
3403
|
* ```
|
|
3106
3404
|
*
|
|
3405
|
+
* @example
|
|
3406
|
+
* **Internal server error response (500):**
|
|
3407
|
+
* ```typescript
|
|
3408
|
+
* {
|
|
3409
|
+
* status_code: 500,
|
|
3410
|
+
* error: 'Internal server error'
|
|
3411
|
+
* }
|
|
3412
|
+
* ```
|
|
3413
|
+
*
|
|
3107
3414
|
* @public
|
|
3108
3415
|
*/
|
|
3109
|
-
export declare type OnContentLoadedResponse =
|
|
3416
|
+
export declare type OnContentLoadedResponse = BridgeResponse<200 | 500 | 501, OnContentLoadedResult>;
|
|
3110
3417
|
|
|
3111
3418
|
/**
|
|
3112
3419
|
* Result when notifying content loaded.
|
|
@@ -3134,6 +3441,7 @@ export declare type OnCtaTapRequest = string;
|
|
|
3134
3441
|
* @remarks
|
|
3135
3442
|
* This response can have the following status codes:
|
|
3136
3443
|
* - `200`: CTA tap notification sent successfully.
|
|
3444
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3137
3445
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3138
3446
|
*
|
|
3139
3447
|
* @example
|
|
@@ -3151,9 +3459,18 @@ export declare type OnCtaTapRequest = string;
|
|
|
3151
3459
|
* }
|
|
3152
3460
|
* ```
|
|
3153
3461
|
*
|
|
3462
|
+
* @example
|
|
3463
|
+
* **Internal server error response (500):**
|
|
3464
|
+
* ```typescript
|
|
3465
|
+
* {
|
|
3466
|
+
* status_code: 500,
|
|
3467
|
+
* error: 'Internal server error'
|
|
3468
|
+
* }
|
|
3469
|
+
* ```
|
|
3470
|
+
*
|
|
3154
3471
|
* @public
|
|
3155
3472
|
*/
|
|
3156
|
-
export declare type OnCtaTapResponse =
|
|
3473
|
+
export declare type OnCtaTapResponse = BridgeResponse<200 | 500 | 501, OnCtaTapResult>;
|
|
3157
3474
|
|
|
3158
3475
|
/**
|
|
3159
3476
|
* Result when notifying CTA tap.
|
|
@@ -3182,6 +3499,7 @@ export declare type OpenExternalLinkRequest = string;
|
|
|
3182
3499
|
* This response can have the following status codes:
|
|
3183
3500
|
* - `200`: External link opened successfully.
|
|
3184
3501
|
* - `400`: Invalid URL parameter.
|
|
3502
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3185
3503
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3186
3504
|
*
|
|
3187
3505
|
* @example
|
|
@@ -3208,9 +3526,18 @@ export declare type OpenExternalLinkRequest = string;
|
|
|
3208
3526
|
* }
|
|
3209
3527
|
* ```
|
|
3210
3528
|
*
|
|
3529
|
+
* @example
|
|
3530
|
+
* **Internal server error response (500):**
|
|
3531
|
+
* ```typescript
|
|
3532
|
+
* {
|
|
3533
|
+
* status_code: 500,
|
|
3534
|
+
* error: 'Internal server error'
|
|
3535
|
+
* }
|
|
3536
|
+
* ```
|
|
3537
|
+
*
|
|
3211
3538
|
* @public
|
|
3212
3539
|
*/
|
|
3213
|
-
export declare type OpenExternalLinkResponse =
|
|
3540
|
+
export declare type OpenExternalLinkResponse = BridgeResponse<200 | 400 | 500 | 501, OpenExternalLinkResult>;
|
|
3214
3541
|
|
|
3215
3542
|
/**
|
|
3216
3543
|
* Result when opening an external link.
|
|
@@ -3220,6 +3547,13 @@ export declare type OpenExternalLinkResponse = Promise<ConstrainedBridgeResponse
|
|
|
3220
3547
|
*/
|
|
3221
3548
|
export declare type OpenExternalLinkResult = void;
|
|
3222
3549
|
|
|
3550
|
+
/**
|
|
3551
|
+
* Represents the mobile operating system platform.
|
|
3552
|
+
*
|
|
3553
|
+
* @public
|
|
3554
|
+
*/
|
|
3555
|
+
export declare type Platform = 'Android' | 'iOS';
|
|
3556
|
+
|
|
3223
3557
|
/**
|
|
3224
3558
|
* JSBridge module for controlling platform navigation.
|
|
3225
3559
|
*
|
|
@@ -3246,6 +3580,7 @@ export declare type OpenExternalLinkResult = void;
|
|
|
3246
3580
|
* ```
|
|
3247
3581
|
*
|
|
3248
3582
|
* @public
|
|
3583
|
+
* @noInheritDoc
|
|
3249
3584
|
*/
|
|
3250
3585
|
export declare class PlatformModule extends BaseModule {
|
|
3251
3586
|
constructor();
|
|
@@ -3255,41 +3590,30 @@ export declare class PlatformModule extends BaseModule {
|
|
|
3255
3590
|
*
|
|
3256
3591
|
* @returns Confirmation that the back navigation was triggered.
|
|
3257
3592
|
*
|
|
3258
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
3259
|
-
*
|
|
3260
3593
|
* @example
|
|
3261
3594
|
* **Simple usage**
|
|
3262
3595
|
* ```typescript
|
|
3263
|
-
* // Imports using ES Module built
|
|
3264
|
-
* import { PlatformModule } from '@grabjs/superapp-sdk';
|
|
3265
|
-
* // Imports using UMD built (via CDN)
|
|
3266
|
-
* const { PlatformModule } = window.SuperAppSDK;
|
|
3267
|
-
*
|
|
3268
3596
|
* // Initialize the platform module
|
|
3269
3597
|
* const platformModule = new PlatformModule();
|
|
3270
3598
|
*
|
|
3271
3599
|
* // Trigger back navigation
|
|
3272
|
-
*
|
|
3273
|
-
*
|
|
3274
|
-
*
|
|
3275
|
-
*
|
|
3276
|
-
*
|
|
3277
|
-
*
|
|
3278
|
-
*
|
|
3279
|
-
*
|
|
3280
|
-
*
|
|
3281
|
-
*
|
|
3282
|
-
*
|
|
3283
|
-
* console.log('Unexpected status code:', response);
|
|
3284
|
-
* }
|
|
3285
|
-
* } catch (error) {
|
|
3286
|
-
* console.log('Unexpected error:', error);
|
|
3600
|
+
* const response = await platformModule.back();
|
|
3601
|
+
*
|
|
3602
|
+
* switch (response.status_code) {
|
|
3603
|
+
* case 204:
|
|
3604
|
+
* console.log('Back navigation triggered');
|
|
3605
|
+
* break;
|
|
3606
|
+
* case 501:
|
|
3607
|
+
* console.log('Not in Grab app:', response.error);
|
|
3608
|
+
* break;
|
|
3609
|
+
* default:
|
|
3610
|
+
* console.log('Unexpected status code:', response);
|
|
3287
3611
|
* }
|
|
3288
3612
|
* ```
|
|
3289
3613
|
*
|
|
3290
3614
|
* @public
|
|
3291
3615
|
*/
|
|
3292
|
-
back(): BackResponse
|
|
3616
|
+
back(): Promise<BackResponse>;
|
|
3293
3617
|
}
|
|
3294
3618
|
|
|
3295
3619
|
/**
|
|
@@ -3299,6 +3623,7 @@ export declare class PlatformModule extends BaseModule {
|
|
|
3299
3623
|
* This response can have the following status codes:
|
|
3300
3624
|
* - `200`: Playback initiated successfully (streaming content).
|
|
3301
3625
|
* - `204`: Invalid parameters - the DRM configuration is malformed or missing required fields.
|
|
3626
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3302
3627
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3303
3628
|
*
|
|
3304
3629
|
* @example
|
|
@@ -3322,9 +3647,18 @@ export declare class PlatformModule extends BaseModule {
|
|
|
3322
3647
|
* }
|
|
3323
3648
|
* ```
|
|
3324
3649
|
*
|
|
3650
|
+
* @example
|
|
3651
|
+
* **Internal server error response (500):**
|
|
3652
|
+
* ```typescript
|
|
3653
|
+
* {
|
|
3654
|
+
* status_code: 500,
|
|
3655
|
+
* error: 'Internal server error'
|
|
3656
|
+
* }
|
|
3657
|
+
* ```
|
|
3658
|
+
*
|
|
3325
3659
|
* @public
|
|
3326
3660
|
*/
|
|
3327
|
-
export declare type PlayDRMContentResponse =
|
|
3661
|
+
export declare type PlayDRMContentResponse = BridgeResponse<200 | 204 | 500 | 501, PlayDRMContentResult>;
|
|
3328
3662
|
|
|
3329
3663
|
/**
|
|
3330
3664
|
* Result object for DRM content playback initiation.
|
|
@@ -3360,55 +3694,45 @@ export declare type PlayDRMContentResult = void;
|
|
|
3360
3694
|
* ```
|
|
3361
3695
|
*
|
|
3362
3696
|
* @public
|
|
3697
|
+
* @noInheritDoc
|
|
3363
3698
|
*/
|
|
3364
3699
|
export declare class ProfileModule extends BaseModule {
|
|
3365
3700
|
constructor();
|
|
3366
|
-
static
|
|
3701
|
+
static readonly MINIMUM_VERSION: Version;
|
|
3367
3702
|
/**
|
|
3368
3703
|
* Fetches the user's email address from their Grab profile.
|
|
3369
3704
|
*
|
|
3370
3705
|
* @returns The user's email address if available.
|
|
3371
3706
|
*
|
|
3372
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
3373
|
-
*
|
|
3374
3707
|
* @example
|
|
3375
3708
|
* **Simple usage**
|
|
3376
3709
|
* ```typescript
|
|
3377
|
-
* // Imports using ES Module built
|
|
3378
|
-
* import { ProfileModule } from '@grabjs/superapp-sdk';
|
|
3379
|
-
* // Imports using UMD built (via CDN)
|
|
3380
|
-
* const { ProfileModule } = window.SuperAppSDK;
|
|
3381
|
-
*
|
|
3382
3710
|
* // Initialize the profile module
|
|
3383
3711
|
* const profileModule = new ProfileModule();
|
|
3384
3712
|
*
|
|
3385
3713
|
* // Fetch the user's email
|
|
3386
|
-
*
|
|
3387
|
-
*
|
|
3388
|
-
*
|
|
3389
|
-
*
|
|
3390
|
-
*
|
|
3391
|
-
*
|
|
3392
|
-
*
|
|
3393
|
-
*
|
|
3394
|
-
*
|
|
3395
|
-
*
|
|
3396
|
-
*
|
|
3397
|
-
*
|
|
3398
|
-
*
|
|
3399
|
-
*
|
|
3400
|
-
*
|
|
3401
|
-
*
|
|
3402
|
-
* console.log('Unexpected status code:', response);
|
|
3403
|
-
* }
|
|
3404
|
-
* } catch (err) {
|
|
3405
|
-
* console.log(`Could not fetch email${err ? `: ${err}` : ''}`);
|
|
3714
|
+
* const response = await profileModule.fetchEmail();
|
|
3715
|
+
*
|
|
3716
|
+
* switch (response.status_code) {
|
|
3717
|
+
* case 200:
|
|
3718
|
+
* console.log('User email:', response.result.email);
|
|
3719
|
+
* break;
|
|
3720
|
+
* case 400:
|
|
3721
|
+
* case 403:
|
|
3722
|
+
* // Feature not available or other error
|
|
3723
|
+
* console.log('Could not fetch email:', response.error);
|
|
3724
|
+
* break;
|
|
3725
|
+
* case 501:
|
|
3726
|
+
* console.log('Not in Grab app:', response.error);
|
|
3727
|
+
* break;
|
|
3728
|
+
* default:
|
|
3729
|
+
* console.log('Unexpected status code:', response);
|
|
3406
3730
|
* }
|
|
3407
3731
|
* ```
|
|
3408
3732
|
*
|
|
3409
3733
|
* @public
|
|
3410
3734
|
*/
|
|
3411
|
-
fetchEmail(): FetchEmailResponse
|
|
3735
|
+
fetchEmail(): Promise<FetchEmailResponse>;
|
|
3412
3736
|
/**
|
|
3413
3737
|
* Verifies the user's email address using a one-time password (OTP).
|
|
3414
3738
|
*
|
|
@@ -3416,49 +3740,38 @@ export declare class ProfileModule extends BaseModule {
|
|
|
3416
3740
|
*
|
|
3417
3741
|
* @returns Confirmation of whether the email verification was successful.
|
|
3418
3742
|
*
|
|
3419
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
3420
|
-
*
|
|
3421
3743
|
* @example
|
|
3422
3744
|
* **Simple usage**
|
|
3423
3745
|
* ```typescript
|
|
3424
|
-
* // Imports using ES Module built
|
|
3425
|
-
* import { ProfileModule } from '@grabjs/superapp-sdk';
|
|
3426
|
-
* // Imports using UMD built (via CDN)
|
|
3427
|
-
* const { ProfileModule } = window.SuperAppSDK;
|
|
3428
|
-
*
|
|
3429
3746
|
* // Initialize the profile module
|
|
3430
3747
|
* const profileModule = new ProfileModule();
|
|
3431
3748
|
*
|
|
3432
3749
|
* // Verify email with OTP
|
|
3433
|
-
*
|
|
3434
|
-
*
|
|
3435
|
-
*
|
|
3436
|
-
*
|
|
3437
|
-
* });
|
|
3750
|
+
* const response = await profileModule.verifyEmail({
|
|
3751
|
+
* email: 'user@example.com',
|
|
3752
|
+
* otp: '123456'
|
|
3753
|
+
* });
|
|
3438
3754
|
*
|
|
3439
|
-
*
|
|
3440
|
-
*
|
|
3441
|
-
*
|
|
3442
|
-
*
|
|
3443
|
-
*
|
|
3444
|
-
*
|
|
3445
|
-
*
|
|
3446
|
-
*
|
|
3447
|
-
*
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3452
|
-
*
|
|
3453
|
-
* }
|
|
3454
|
-
* } catch (err) {
|
|
3455
|
-
* console.log(`Could not verify email${err ? `: ${err}` : ''}`);
|
|
3755
|
+
* switch (response.status_code) {
|
|
3756
|
+
* case 200:
|
|
3757
|
+
* console.log('Email verified successfully');
|
|
3758
|
+
* break;
|
|
3759
|
+
* case 400:
|
|
3760
|
+
* case 403:
|
|
3761
|
+
* // Feature not available or other error
|
|
3762
|
+
* console.log('Could not verify email:', response.error);
|
|
3763
|
+
* break;
|
|
3764
|
+
* case 501:
|
|
3765
|
+
* console.log('Not in Grab app:', response.error);
|
|
3766
|
+
* break;
|
|
3767
|
+
* default:
|
|
3768
|
+
* console.log('Unexpected status code:', response);
|
|
3456
3769
|
* }
|
|
3457
3770
|
* ```
|
|
3458
3771
|
*
|
|
3459
3772
|
* @public
|
|
3460
3773
|
*/
|
|
3461
|
-
verifyEmail(request: VerifyEmailRequest): VerifyEmailResponse
|
|
3774
|
+
verifyEmail(request: VerifyEmailRequest): Promise<VerifyEmailResponse>;
|
|
3462
3775
|
}
|
|
3463
3776
|
|
|
3464
3777
|
/**
|
|
@@ -3486,6 +3799,7 @@ export declare type RedirectToSystemWebViewRequest = {
|
|
|
3486
3799
|
* - `200`: Redirect initiated successfully.
|
|
3487
3800
|
* - `400`: Invalid URL, domain not whitelisted, or missing callback URL.
|
|
3488
3801
|
* - `424`: ASWebAuthenticationSession error - dependency error on iOS.
|
|
3802
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3489
3803
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3490
3804
|
*
|
|
3491
3805
|
* @example
|
|
@@ -3521,9 +3835,18 @@ export declare type RedirectToSystemWebViewRequest = {
|
|
|
3521
3835
|
* }
|
|
3522
3836
|
* ```
|
|
3523
3837
|
*
|
|
3838
|
+
* @example
|
|
3839
|
+
* **Internal server error response (500):**
|
|
3840
|
+
* ```typescript
|
|
3841
|
+
* {
|
|
3842
|
+
* status_code: 500,
|
|
3843
|
+
* error: 'Internal server error'
|
|
3844
|
+
* }
|
|
3845
|
+
* ```
|
|
3846
|
+
*
|
|
3524
3847
|
* @public
|
|
3525
3848
|
*/
|
|
3526
|
-
export declare type RedirectToSystemWebViewResponse =
|
|
3849
|
+
export declare type RedirectToSystemWebViewResponse = BridgeResponse<200 | 400 | 424 | 500 | 501, RedirectToSystemWebViewResult>;
|
|
3527
3850
|
|
|
3528
3851
|
/**
|
|
3529
3852
|
* Result object for redirecting to the system web view.
|
|
@@ -3540,6 +3863,7 @@ export declare type RedirectToSystemWebViewResult = void;
|
|
|
3540
3863
|
* This response can have the following status codes:
|
|
3541
3864
|
* - `200`: Scopes reloaded successfully.
|
|
3542
3865
|
* - `424`: ScopeKit error - unable to reload scopes due to a dependency error.
|
|
3866
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3543
3867
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3544
3868
|
*
|
|
3545
3869
|
* @example
|
|
@@ -3566,9 +3890,18 @@ export declare type RedirectToSystemWebViewResult = void;
|
|
|
3566
3890
|
* }
|
|
3567
3891
|
* ```
|
|
3568
3892
|
*
|
|
3893
|
+
* @example
|
|
3894
|
+
* **Internal server error response (500):**
|
|
3895
|
+
* ```typescript
|
|
3896
|
+
* {
|
|
3897
|
+
* status_code: 500,
|
|
3898
|
+
* error: 'Internal server error'
|
|
3899
|
+
* }
|
|
3900
|
+
* ```
|
|
3901
|
+
*
|
|
3569
3902
|
* @public
|
|
3570
3903
|
*/
|
|
3571
|
-
export declare type ReloadScopesResponse =
|
|
3904
|
+
export declare type ReloadScopesResponse = BridgeResponse<200 | 424 | 500 | 501, ReloadScopesResult>;
|
|
3572
3905
|
|
|
3573
3906
|
/**
|
|
3574
3907
|
* Result object for reloading scopes.
|
|
@@ -3584,6 +3917,7 @@ export declare type ReloadScopesResult = void;
|
|
|
3584
3917
|
* @remarks
|
|
3585
3918
|
* This response can have the following status codes:
|
|
3586
3919
|
* - `204`: All values removed successfully.
|
|
3920
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3587
3921
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3588
3922
|
*
|
|
3589
3923
|
* @example
|
|
@@ -3601,62 +3935,189 @@ export declare type ReloadScopesResult = void;
|
|
|
3601
3935
|
* }
|
|
3602
3936
|
* ```
|
|
3603
3937
|
*
|
|
3938
|
+
* @example
|
|
3939
|
+
* **Internal server error response (500):**
|
|
3940
|
+
* ```typescript
|
|
3941
|
+
* {
|
|
3942
|
+
* status_code: 500,
|
|
3943
|
+
* error: 'Internal server error'
|
|
3944
|
+
* }
|
|
3945
|
+
* ```
|
|
3946
|
+
*
|
|
3947
|
+
* @public
|
|
3948
|
+
*/
|
|
3949
|
+
export declare type RemoveAllResponse = BridgeResponse<204 | 500 | 501, RemoveAllResult>;
|
|
3950
|
+
|
|
3951
|
+
/**
|
|
3952
|
+
* Result object for removing all values.
|
|
3953
|
+
* This operation returns no data on success.
|
|
3954
|
+
*
|
|
3955
|
+
* @public
|
|
3956
|
+
*/
|
|
3957
|
+
export declare type RemoveAllResult = void;
|
|
3958
|
+
|
|
3959
|
+
/**
|
|
3960
|
+
* Response when removing a value.
|
|
3961
|
+
*
|
|
3962
|
+
* @remarks
|
|
3963
|
+
* This response can have the following status codes:
|
|
3964
|
+
* - `204`: Value removed successfully.
|
|
3965
|
+
* - `400`: Missing required parameters - key not provided.
|
|
3966
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3967
|
+
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3968
|
+
*
|
|
3969
|
+
* @example
|
|
3970
|
+
* **Success response (204):**
|
|
3971
|
+
* ```typescript
|
|
3972
|
+
* { status_code: 204 }
|
|
3973
|
+
* ```
|
|
3974
|
+
*
|
|
3975
|
+
* @example
|
|
3976
|
+
* **Bad request response (400):**
|
|
3977
|
+
* ```typescript
|
|
3978
|
+
* {
|
|
3979
|
+
* status_code: 400,
|
|
3980
|
+
* error: 'Missing required parameters'
|
|
3981
|
+
* }
|
|
3982
|
+
* ```
|
|
3983
|
+
*
|
|
3984
|
+
* @example
|
|
3985
|
+
* **Not implemented response (501) - outside Grab app:**
|
|
3986
|
+
* ```typescript
|
|
3987
|
+
* {
|
|
3988
|
+
* status_code: 501,
|
|
3989
|
+
* error: 'Not implemented: This method requires the Grab app environment'
|
|
3990
|
+
* }
|
|
3991
|
+
* ```
|
|
3992
|
+
*
|
|
3993
|
+
* @example
|
|
3994
|
+
* **Internal server error response (500):**
|
|
3995
|
+
* ```typescript
|
|
3996
|
+
* {
|
|
3997
|
+
* status_code: 500,
|
|
3998
|
+
* error: 'Internal server error'
|
|
3999
|
+
* }
|
|
4000
|
+
* ```
|
|
4001
|
+
*
|
|
4002
|
+
* @public
|
|
4003
|
+
*/
|
|
4004
|
+
export declare type RemoveResponse = BridgeResponse<204 | 400 | 500 | 501, RemoveResult>;
|
|
4005
|
+
|
|
4006
|
+
/**
|
|
4007
|
+
* Result object for removing a value.
|
|
4008
|
+
* This operation returns no data on success.
|
|
4009
|
+
*
|
|
4010
|
+
* @public
|
|
4011
|
+
*/
|
|
4012
|
+
export declare type RemoveResult = void;
|
|
4013
|
+
|
|
4014
|
+
/**
|
|
4015
|
+
* Success response from the bridge SDK.
|
|
4016
|
+
*
|
|
4017
|
+
* @remarks
|
|
4018
|
+
* Returned when a JSBridge method completes successfully.
|
|
4019
|
+
* The `result` field contains the JSBridge method's data.
|
|
4020
|
+
*
|
|
4021
|
+
* @public
|
|
4022
|
+
*/
|
|
4023
|
+
export declare type ResponseStatusCode200<T> = {
|
|
4024
|
+
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
4025
|
+
status_code: 200;
|
|
4026
|
+
/** The result data from the JSBridge method, or undefined if no result was returned */
|
|
4027
|
+
result: T;
|
|
4028
|
+
};
|
|
4029
|
+
|
|
4030
|
+
/**
|
|
4031
|
+
* No result response with status code 204.
|
|
4032
|
+
*
|
|
4033
|
+
* @remarks
|
|
4034
|
+
* Returned when a JSBridge method completes with no content (e.g., user cancelled a dialog).
|
|
4035
|
+
* No `result` or `error` data is returned.
|
|
4036
|
+
*
|
|
4037
|
+
* @public
|
|
4038
|
+
*/
|
|
4039
|
+
export declare type ResponseStatusCode204 = {
|
|
4040
|
+
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
4041
|
+
status_code: 204;
|
|
4042
|
+
};
|
|
4043
|
+
|
|
4044
|
+
/**
|
|
4045
|
+
* Redirect response with status code 302.
|
|
4046
|
+
*
|
|
4047
|
+
* @remarks
|
|
4048
|
+
* Returned when a JSBridge method initiates a redirect (e.g., OAuth2 redirect flow).
|
|
4049
|
+
* No `result` or `error` data is returned as the page will navigate away.
|
|
4050
|
+
*
|
|
4051
|
+
* @public
|
|
4052
|
+
*/
|
|
4053
|
+
export declare type ResponseStatusCode302 = {
|
|
4054
|
+
/** HTTP-style status code indicating the outcome of the JSBridge method call */
|
|
4055
|
+
status_code: 302;
|
|
4056
|
+
};
|
|
4057
|
+
|
|
4058
|
+
/**
|
|
4059
|
+
* Error response with status code 400
|
|
4060
|
+
*
|
|
4061
|
+
* @public
|
|
4062
|
+
*/
|
|
4063
|
+
export declare type ResponseStatusCode400 = ErrorResponse<400>;
|
|
4064
|
+
|
|
4065
|
+
/**
|
|
4066
|
+
* Error response with status code 401
|
|
4067
|
+
*
|
|
3604
4068
|
* @public
|
|
3605
4069
|
*/
|
|
3606
|
-
export declare type
|
|
4070
|
+
export declare type ResponseStatusCode401 = ErrorResponse<401>;
|
|
3607
4071
|
|
|
3608
4072
|
/**
|
|
3609
|
-
*
|
|
3610
|
-
* This operation returns no data on success.
|
|
4073
|
+
* Error response with status code 403
|
|
3611
4074
|
*
|
|
3612
4075
|
* @public
|
|
3613
4076
|
*/
|
|
3614
|
-
export declare type
|
|
4077
|
+
export declare type ResponseStatusCode403 = ErrorResponse<403>;
|
|
3615
4078
|
|
|
3616
4079
|
/**
|
|
3617
|
-
*
|
|
4080
|
+
* Error response with status code 404
|
|
3618
4081
|
*
|
|
3619
|
-
* @
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
4082
|
+
* @public
|
|
4083
|
+
*/
|
|
4084
|
+
export declare type ResponseStatusCode404 = ErrorResponse<404>;
|
|
4085
|
+
|
|
4086
|
+
/**
|
|
4087
|
+
* Error response with status code 424
|
|
3624
4088
|
*
|
|
3625
|
-
* @
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
4089
|
+
* @public
|
|
4090
|
+
*/
|
|
4091
|
+
export declare type ResponseStatusCode424 = ErrorResponse<424>;
|
|
4092
|
+
|
|
4093
|
+
/**
|
|
4094
|
+
* Error response with status code 426
|
|
3630
4095
|
*
|
|
3631
|
-
* @
|
|
3632
|
-
*
|
|
3633
|
-
*
|
|
3634
|
-
* {
|
|
3635
|
-
* status_code: 400,
|
|
3636
|
-
* error: 'Missing required parameters'
|
|
3637
|
-
* }
|
|
3638
|
-
* ```
|
|
4096
|
+
* @remarks
|
|
4097
|
+
* Returned when the JSBridge method requires a newer version of the Grab app.
|
|
4098
|
+
* This indicates the method is not supported in the current app version.
|
|
3639
4099
|
*
|
|
3640
|
-
* @
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
*
|
|
3646
|
-
* }
|
|
3647
|
-
* ```
|
|
4100
|
+
* @public
|
|
4101
|
+
*/
|
|
4102
|
+
export declare type ResponseStatusCode426 = ErrorResponse<426>;
|
|
4103
|
+
|
|
4104
|
+
/**
|
|
4105
|
+
* Error response with status code 500
|
|
3648
4106
|
*
|
|
3649
4107
|
* @public
|
|
3650
4108
|
*/
|
|
3651
|
-
export declare type
|
|
4109
|
+
export declare type ResponseStatusCode500 = ErrorResponse<500>;
|
|
3652
4110
|
|
|
3653
4111
|
/**
|
|
3654
|
-
*
|
|
3655
|
-
*
|
|
4112
|
+
* Error response with status code 501
|
|
4113
|
+
*
|
|
4114
|
+
* @remarks
|
|
4115
|
+
* Returned when a JSBridge method is called outside the Grab app environment.
|
|
4116
|
+
* This indicates the method is not implemented in the current environment.
|
|
3656
4117
|
*
|
|
3657
4118
|
* @public
|
|
3658
4119
|
*/
|
|
3659
|
-
export declare type
|
|
4120
|
+
export declare type ResponseStatusCode501 = ErrorResponse<501>;
|
|
3660
4121
|
|
|
3661
4122
|
/**
|
|
3662
4123
|
* Request parameters for scanning QR codes.
|
|
@@ -3689,6 +4150,7 @@ export declare type ScanQRCodeRequest = {
|
|
|
3689
4150
|
* - `204`: User cancelled the QR code scanning. No result data is returned.
|
|
3690
4151
|
* - `400`: Bad request - invalid request parameters.
|
|
3691
4152
|
* - `403`: Camera permission is not enabled for the Grab app.
|
|
4153
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3692
4154
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3693
4155
|
*
|
|
3694
4156
|
* @example
|
|
@@ -3733,9 +4195,18 @@ export declare type ScanQRCodeRequest = {
|
|
|
3733
4195
|
* }
|
|
3734
4196
|
* ```
|
|
3735
4197
|
*
|
|
4198
|
+
* @example
|
|
4199
|
+
* **Internal server error response (500):**
|
|
4200
|
+
* ```typescript
|
|
4201
|
+
* {
|
|
4202
|
+
* status_code: 500,
|
|
4203
|
+
* error: 'Internal server error'
|
|
4204
|
+
* }
|
|
4205
|
+
* ```
|
|
4206
|
+
*
|
|
3736
4207
|
* @public
|
|
3737
4208
|
*/
|
|
3738
|
-
export declare type ScanQRCodeResponse =
|
|
4209
|
+
export declare type ScanQRCodeResponse = BridgeResponse<200 | 204 | 400 | 403 | 500 | 501, ScanQRCodeResult>;
|
|
3739
4210
|
|
|
3740
4211
|
/**
|
|
3741
4212
|
* Result object containing the scanned QR code data.
|
|
@@ -3778,6 +4249,7 @@ export declare type ScanQRCodeResult = {
|
|
|
3778
4249
|
* ```
|
|
3779
4250
|
*
|
|
3780
4251
|
* @public
|
|
4252
|
+
* @noInheritDoc
|
|
3781
4253
|
*/
|
|
3782
4254
|
export declare class ScopeModule extends BaseModule {
|
|
3783
4255
|
constructor();
|
|
@@ -3789,89 +4261,67 @@ export declare class ScopeModule extends BaseModule {
|
|
|
3789
4261
|
*
|
|
3790
4262
|
* @returns Whether the MiniApp has permission to access the specified method.
|
|
3791
4263
|
*
|
|
3792
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
3793
|
-
*
|
|
3794
4264
|
* @example
|
|
3795
4265
|
* **Simple usage**
|
|
3796
4266
|
* ```typescript
|
|
3797
|
-
* // Imports using ES Module built
|
|
3798
|
-
* import { ScopeModule } from '@grabjs/superapp-sdk';
|
|
3799
|
-
* // Imports using UMD built (via CDN)
|
|
3800
|
-
* const { ScopeModule } = window.SuperAppSDK;
|
|
3801
|
-
*
|
|
3802
4267
|
* // Initialize the scope module
|
|
3803
4268
|
* const scopeModule = new ScopeModule();
|
|
3804
4269
|
*
|
|
3805
4270
|
* // Check access to CameraModule.scanQRCode
|
|
3806
|
-
*
|
|
3807
|
-
*
|
|
3808
|
-
*
|
|
3809
|
-
*
|
|
3810
|
-
*
|
|
3811
|
-
*
|
|
3812
|
-
*
|
|
3813
|
-
*
|
|
3814
|
-
*
|
|
3815
|
-
*
|
|
3816
|
-
*
|
|
3817
|
-
*
|
|
3818
|
-
*
|
|
3819
|
-
*
|
|
3820
|
-
*
|
|
3821
|
-
* console.log('Unexpected status code:', response);
|
|
3822
|
-
* }
|
|
3823
|
-
* } catch (error) {
|
|
3824
|
-
* console.log('Unexpected error:', error);
|
|
4271
|
+
* const response = await scopeModule.hasAccessTo('CameraModule', 'scanQRCode');
|
|
4272
|
+
*
|
|
4273
|
+
* switch (response.status_code) {
|
|
4274
|
+
* case 200:
|
|
4275
|
+
* console.log('Has access:', response.result.hasAccess);
|
|
4276
|
+
* break;
|
|
4277
|
+
* case 400:
|
|
4278
|
+
* case 424:
|
|
4279
|
+
* console.log('Could not check access:', response.error);
|
|
4280
|
+
* break;
|
|
4281
|
+
* case 501:
|
|
4282
|
+
* console.log('Not in Grab app:', response.error);
|
|
4283
|
+
* break;
|
|
4284
|
+
* default:
|
|
4285
|
+
* console.log('Unexpected status code:', response);
|
|
3825
4286
|
* }
|
|
3826
4287
|
* ```
|
|
3827
4288
|
*
|
|
3828
4289
|
* @public
|
|
3829
4290
|
*/
|
|
3830
|
-
hasAccessTo(module: string, method: string): HasAccessToResponse
|
|
4291
|
+
hasAccessTo(module: string, method: string): Promise<HasAccessToResponse>;
|
|
3831
4292
|
/**
|
|
3832
4293
|
* Requests to reload the consented OAuth scopes for the current client.
|
|
3833
4294
|
* This refreshes the permissions from the server.
|
|
3834
4295
|
*
|
|
3835
4296
|
* @returns Confirmation that the scopes have been reloaded from the server.
|
|
3836
4297
|
*
|
|
3837
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
3838
|
-
*
|
|
3839
4298
|
* @example
|
|
3840
4299
|
* **Simple usage**
|
|
3841
4300
|
* ```typescript
|
|
3842
|
-
* // Imports using ES Module built
|
|
3843
|
-
* import { ScopeModule } from '@grabjs/superapp-sdk';
|
|
3844
|
-
* // Imports using UMD built (via CDN)
|
|
3845
|
-
* const { ScopeModule } = window.SuperAppSDK;
|
|
3846
|
-
*
|
|
3847
4301
|
* // Initialize the scope module
|
|
3848
4302
|
* const scopeModule = new ScopeModule();
|
|
3849
4303
|
*
|
|
3850
4304
|
* // Reload scopes
|
|
3851
|
-
*
|
|
3852
|
-
*
|
|
3853
|
-
*
|
|
3854
|
-
*
|
|
3855
|
-
*
|
|
3856
|
-
*
|
|
3857
|
-
*
|
|
3858
|
-
*
|
|
3859
|
-
*
|
|
3860
|
-
*
|
|
3861
|
-
*
|
|
3862
|
-
*
|
|
3863
|
-
*
|
|
3864
|
-
*
|
|
3865
|
-
* console.log('Unexpected status code:', response);
|
|
3866
|
-
* }
|
|
3867
|
-
* } catch (error) {
|
|
3868
|
-
* console.log('Unexpected error:', error);
|
|
4305
|
+
* const response = await scopeModule.reloadScopes();
|
|
4306
|
+
*
|
|
4307
|
+
* switch (response.status_code) {
|
|
4308
|
+
* case 200:
|
|
4309
|
+
* console.log('Scopes reloaded successfully');
|
|
4310
|
+
* break;
|
|
4311
|
+
* case 424:
|
|
4312
|
+
* console.log('Could not reload scopes:', response.error);
|
|
4313
|
+
* break;
|
|
4314
|
+
* case 501:
|
|
4315
|
+
* console.log('Not in Grab app:', response.error);
|
|
4316
|
+
* break;
|
|
4317
|
+
* default:
|
|
4318
|
+
* console.log('Unexpected status code:', response);
|
|
3869
4319
|
* }
|
|
3870
4320
|
* ```
|
|
3871
4321
|
*
|
|
3872
4322
|
* @public
|
|
3873
4323
|
*/
|
|
3874
|
-
reloadScopes(): ReloadScopesResponse
|
|
4324
|
+
reloadScopes(): Promise<ReloadScopesResponse>;
|
|
3875
4325
|
}
|
|
3876
4326
|
|
|
3877
4327
|
/**
|
|
@@ -3919,6 +4369,7 @@ export declare type SendAnalyticsEventRequest = {
|
|
|
3919
4369
|
* This response can have the following status codes:
|
|
3920
4370
|
* - `200`: Analytics event sent successfully.
|
|
3921
4371
|
* - `400`: Invalid analytics event parameters.
|
|
4372
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3922
4373
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3923
4374
|
*
|
|
3924
4375
|
* @example
|
|
@@ -3945,9 +4396,18 @@ export declare type SendAnalyticsEventRequest = {
|
|
|
3945
4396
|
* }
|
|
3946
4397
|
* ```
|
|
3947
4398
|
*
|
|
4399
|
+
* @example
|
|
4400
|
+
* **Internal server error response (500):**
|
|
4401
|
+
* ```typescript
|
|
4402
|
+
* {
|
|
4403
|
+
* status_code: 500,
|
|
4404
|
+
* error: 'Internal server error'
|
|
4405
|
+
* }
|
|
4406
|
+
* ```
|
|
4407
|
+
*
|
|
3948
4408
|
* @public
|
|
3949
4409
|
*/
|
|
3950
|
-
export declare type SendAnalyticsEventResponse =
|
|
4410
|
+
export declare type SendAnalyticsEventResponse = BridgeResponse<200 | 400 | 500 | 501, SendAnalyticsEventResult>;
|
|
3951
4411
|
|
|
3952
4412
|
/**
|
|
3953
4413
|
* Result when sending analytics events.
|
|
@@ -3976,6 +4436,7 @@ export declare type SetBackgroundColorRequest = string;
|
|
|
3976
4436
|
* This response can have the following status codes:
|
|
3977
4437
|
* - `200`: Background color set successfully.
|
|
3978
4438
|
* - `400`: Invalid background color format.
|
|
4439
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
3979
4440
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
3980
4441
|
*
|
|
3981
4442
|
* @example
|
|
@@ -4002,9 +4463,18 @@ export declare type SetBackgroundColorRequest = string;
|
|
|
4002
4463
|
* }
|
|
4003
4464
|
* ```
|
|
4004
4465
|
*
|
|
4466
|
+
* @example
|
|
4467
|
+
* **Internal server error response (500):**
|
|
4468
|
+
* ```typescript
|
|
4469
|
+
* {
|
|
4470
|
+
* status_code: 500,
|
|
4471
|
+
* error: 'Internal server error'
|
|
4472
|
+
* }
|
|
4473
|
+
* ```
|
|
4474
|
+
*
|
|
4005
4475
|
* @public
|
|
4006
4476
|
*/
|
|
4007
|
-
export declare type SetBackgroundColorResponse =
|
|
4477
|
+
export declare type SetBackgroundColorResponse = BridgeResponse<204 | 400 | 500 | 501, SetBackgroundColorResult>;
|
|
4008
4478
|
|
|
4009
4479
|
/**
|
|
4010
4480
|
* Result when setting the background color.
|
|
@@ -4021,6 +4491,7 @@ export declare type SetBackgroundColorResult = void;
|
|
|
4021
4491
|
* This response can have the following status codes:
|
|
4022
4492
|
* - `204`: Value stored successfully.
|
|
4023
4493
|
* - `400`: Missing required parameters - key or value not provided.
|
|
4494
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4024
4495
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4025
4496
|
*
|
|
4026
4497
|
* @example
|
|
@@ -4047,9 +4518,18 @@ export declare type SetBackgroundColorResult = void;
|
|
|
4047
4518
|
* }
|
|
4048
4519
|
* ```
|
|
4049
4520
|
*
|
|
4521
|
+
* @example
|
|
4522
|
+
* **Internal server error response (500):**
|
|
4523
|
+
* ```typescript
|
|
4524
|
+
* {
|
|
4525
|
+
* status_code: 500,
|
|
4526
|
+
* error: 'Internal server error'
|
|
4527
|
+
* }
|
|
4528
|
+
* ```
|
|
4529
|
+
*
|
|
4050
4530
|
* @public
|
|
4051
4531
|
*/
|
|
4052
|
-
export declare type SetBooleanResponse =
|
|
4532
|
+
export declare type SetBooleanResponse = BridgeResponse<204 | 400 | 500 | 501, SetBooleanResult>;
|
|
4053
4533
|
|
|
4054
4534
|
/**
|
|
4055
4535
|
* Result object for setting a boolean value.
|
|
@@ -4066,6 +4546,7 @@ export declare type SetBooleanResult = void;
|
|
|
4066
4546
|
* This response can have the following status codes:
|
|
4067
4547
|
* - `204`: Value stored successfully.
|
|
4068
4548
|
* - `400`: Missing required parameters - key or value not provided.
|
|
4549
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4069
4550
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4070
4551
|
*
|
|
4071
4552
|
* @example
|
|
@@ -4092,9 +4573,18 @@ export declare type SetBooleanResult = void;
|
|
|
4092
4573
|
* }
|
|
4093
4574
|
* ```
|
|
4094
4575
|
*
|
|
4576
|
+
* @example
|
|
4577
|
+
* **Internal server error response (500):**
|
|
4578
|
+
* ```typescript
|
|
4579
|
+
* {
|
|
4580
|
+
* status_code: 500,
|
|
4581
|
+
* error: 'Internal server error'
|
|
4582
|
+
* }
|
|
4583
|
+
* ```
|
|
4584
|
+
*
|
|
4095
4585
|
* @public
|
|
4096
4586
|
*/
|
|
4097
|
-
export declare type SetDoubleResponse =
|
|
4587
|
+
export declare type SetDoubleResponse = BridgeResponse<204 | 400 | 500 | 501, SetDoubleResult>;
|
|
4098
4588
|
|
|
4099
4589
|
/**
|
|
4100
4590
|
* Result object for setting a double value.
|
|
@@ -4111,6 +4601,7 @@ export declare type SetDoubleResult = void;
|
|
|
4111
4601
|
* This response can have the following status codes:
|
|
4112
4602
|
* - `204`: Value stored successfully.
|
|
4113
4603
|
* - `400`: Missing required parameters - key or value not provided.
|
|
4604
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4114
4605
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4115
4606
|
*
|
|
4116
4607
|
* @example
|
|
@@ -4137,9 +4628,18 @@ export declare type SetDoubleResult = void;
|
|
|
4137
4628
|
* }
|
|
4138
4629
|
* ```
|
|
4139
4630
|
*
|
|
4631
|
+
* @example
|
|
4632
|
+
* **Internal server error response (500):**
|
|
4633
|
+
* ```typescript
|
|
4634
|
+
* {
|
|
4635
|
+
* status_code: 500,
|
|
4636
|
+
* error: 'Internal server error'
|
|
4637
|
+
* }
|
|
4638
|
+
* ```
|
|
4639
|
+
*
|
|
4140
4640
|
* @public
|
|
4141
4641
|
*/
|
|
4142
|
-
export declare type SetIntResponse =
|
|
4642
|
+
export declare type SetIntResponse = BridgeResponse<204 | 400 | 500 | 501, SetIntResult>;
|
|
4143
4643
|
|
|
4144
4644
|
/**
|
|
4145
4645
|
* Result object for setting an integer value.
|
|
@@ -4156,6 +4656,7 @@ export declare type SetIntResult = void;
|
|
|
4156
4656
|
* This response can have the following status codes:
|
|
4157
4657
|
* - `204`: Value stored successfully.
|
|
4158
4658
|
* - `400`: Missing required parameters - key or value not provided.
|
|
4659
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4159
4660
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4160
4661
|
*
|
|
4161
4662
|
* @example
|
|
@@ -4182,9 +4683,18 @@ export declare type SetIntResult = void;
|
|
|
4182
4683
|
* }
|
|
4183
4684
|
* ```
|
|
4184
4685
|
*
|
|
4686
|
+
* @example
|
|
4687
|
+
* **Internal server error response (500):**
|
|
4688
|
+
* ```typescript
|
|
4689
|
+
* {
|
|
4690
|
+
* status_code: 500,
|
|
4691
|
+
* error: 'Internal server error'
|
|
4692
|
+
* }
|
|
4693
|
+
* ```
|
|
4694
|
+
*
|
|
4185
4695
|
* @public
|
|
4186
4696
|
*/
|
|
4187
|
-
export declare type SetStringResponse =
|
|
4697
|
+
export declare type SetStringResponse = BridgeResponse<204 | 400 | 500 | 501, SetStringResult>;
|
|
4188
4698
|
|
|
4189
4699
|
/**
|
|
4190
4700
|
* Result object for setting a string value.
|
|
@@ -4213,6 +4723,7 @@ export declare type SetTitleRequest = string;
|
|
|
4213
4723
|
* This response can have the following status codes:
|
|
4214
4724
|
* - `200`: Title set successfully.
|
|
4215
4725
|
* - `400`: Invalid title parameter.
|
|
4726
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4216
4727
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4217
4728
|
*
|
|
4218
4729
|
* @example
|
|
@@ -4239,9 +4750,18 @@ export declare type SetTitleRequest = string;
|
|
|
4239
4750
|
* }
|
|
4240
4751
|
* ```
|
|
4241
4752
|
*
|
|
4753
|
+
* @example
|
|
4754
|
+
* **Internal server error response (500):**
|
|
4755
|
+
* ```typescript
|
|
4756
|
+
* {
|
|
4757
|
+
* status_code: 500,
|
|
4758
|
+
* error: 'Internal server error'
|
|
4759
|
+
* }
|
|
4760
|
+
* ```
|
|
4761
|
+
*
|
|
4242
4762
|
* @public
|
|
4243
4763
|
*/
|
|
4244
|
-
export declare type SetTitleResponse =
|
|
4764
|
+
export declare type SetTitleResponse = BridgeResponse<200 | 400 | 500 | 501, SetTitleResult>;
|
|
4245
4765
|
|
|
4246
4766
|
/**
|
|
4247
4767
|
* Result when setting the title.
|
|
@@ -4257,6 +4777,7 @@ export declare type SetTitleResult = void;
|
|
|
4257
4777
|
* @remarks
|
|
4258
4778
|
* This response can have the following status codes:
|
|
4259
4779
|
* - `200`: Back button shown successfully.
|
|
4780
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4260
4781
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4261
4782
|
*
|
|
4262
4783
|
* @example
|
|
@@ -4274,9 +4795,18 @@ export declare type SetTitleResult = void;
|
|
|
4274
4795
|
* }
|
|
4275
4796
|
* ```
|
|
4276
4797
|
*
|
|
4798
|
+
* @example
|
|
4799
|
+
* **Internal server error response (500):**
|
|
4800
|
+
* ```typescript
|
|
4801
|
+
* {
|
|
4802
|
+
* status_code: 500,
|
|
4803
|
+
* error: 'Internal server error'
|
|
4804
|
+
* }
|
|
4805
|
+
* ```
|
|
4806
|
+
*
|
|
4277
4807
|
* @public
|
|
4278
4808
|
*/
|
|
4279
|
-
export declare type ShowBackButtonResponse =
|
|
4809
|
+
export declare type ShowBackButtonResponse = BridgeResponse<200 | 500 | 501, ShowBackButtonResult>;
|
|
4280
4810
|
|
|
4281
4811
|
/**
|
|
4282
4812
|
* Result when showing the back button.
|
|
@@ -4292,6 +4822,7 @@ export declare type ShowBackButtonResult = void;
|
|
|
4292
4822
|
* @remarks
|
|
4293
4823
|
* This response can have the following status codes:
|
|
4294
4824
|
* - `200`: Loader shown successfully.
|
|
4825
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4295
4826
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4296
4827
|
*
|
|
4297
4828
|
* @example
|
|
@@ -4309,9 +4840,18 @@ export declare type ShowBackButtonResult = void;
|
|
|
4309
4840
|
* }
|
|
4310
4841
|
* ```
|
|
4311
4842
|
*
|
|
4843
|
+
* @example
|
|
4844
|
+
* **Internal server error response (500):**
|
|
4845
|
+
* ```typescript
|
|
4846
|
+
* {
|
|
4847
|
+
* status_code: 500,
|
|
4848
|
+
* error: 'Internal server error'
|
|
4849
|
+
* }
|
|
4850
|
+
* ```
|
|
4851
|
+
*
|
|
4312
4852
|
* @public
|
|
4313
4853
|
*/
|
|
4314
|
-
export declare type ShowLoaderResponse =
|
|
4854
|
+
export declare type ShowLoaderResponse = BridgeResponse<200 | 500 | 501, ShowLoaderResult>;
|
|
4315
4855
|
|
|
4316
4856
|
/**
|
|
4317
4857
|
* Result when showing the loader.
|
|
@@ -4327,6 +4867,7 @@ export declare type ShowLoaderResult = void;
|
|
|
4327
4867
|
* @remarks
|
|
4328
4868
|
* This response can have the following status codes:
|
|
4329
4869
|
* - `200`: Refresh button shown successfully.
|
|
4870
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4330
4871
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4331
4872
|
*
|
|
4332
4873
|
* @example
|
|
@@ -4344,9 +4885,18 @@ export declare type ShowLoaderResult = void;
|
|
|
4344
4885
|
* }
|
|
4345
4886
|
* ```
|
|
4346
4887
|
*
|
|
4888
|
+
* @example
|
|
4889
|
+
* **Internal server error response (500):**
|
|
4890
|
+
* ```typescript
|
|
4891
|
+
* {
|
|
4892
|
+
* status_code: 500,
|
|
4893
|
+
* error: 'Internal server error'
|
|
4894
|
+
* }
|
|
4895
|
+
* ```
|
|
4896
|
+
*
|
|
4347
4897
|
* @public
|
|
4348
4898
|
*/
|
|
4349
|
-
export declare type ShowRefreshButtonResponse =
|
|
4899
|
+
export declare type ShowRefreshButtonResponse = BridgeResponse<200 | 500 | 501, ShowRefreshButtonResult>;
|
|
4350
4900
|
|
|
4351
4901
|
/**
|
|
4352
4902
|
* Result when showing the refresh button.
|
|
@@ -4358,21 +4908,22 @@ export declare type ShowRefreshButtonResult = void;
|
|
|
4358
4908
|
|
|
4359
4909
|
/**
|
|
4360
4910
|
* Map of individual status codes to their JSBridge response types.
|
|
4361
|
-
* Used internally by
|
|
4911
|
+
* Used internally by BridgeResponse to select specific response types.
|
|
4362
4912
|
*
|
|
4363
4913
|
* @public
|
|
4364
4914
|
*/
|
|
4365
4915
|
export declare type StatusCodeMap<T> = {
|
|
4366
|
-
200:
|
|
4367
|
-
204:
|
|
4368
|
-
302:
|
|
4369
|
-
400:
|
|
4370
|
-
401:
|
|
4371
|
-
403:
|
|
4372
|
-
404:
|
|
4373
|
-
424:
|
|
4374
|
-
|
|
4375
|
-
|
|
4916
|
+
200: ResponseStatusCode200<T>;
|
|
4917
|
+
204: ResponseStatusCode204;
|
|
4918
|
+
302: ResponseStatusCode302;
|
|
4919
|
+
400: ResponseStatusCode400;
|
|
4920
|
+
401: ResponseStatusCode401;
|
|
4921
|
+
403: ResponseStatusCode403;
|
|
4922
|
+
404: ResponseStatusCode404;
|
|
4923
|
+
424: ResponseStatusCode424;
|
|
4924
|
+
426: ResponseStatusCode426;
|
|
4925
|
+
500: ResponseStatusCode500;
|
|
4926
|
+
501: ResponseStatusCode501;
|
|
4376
4927
|
};
|
|
4377
4928
|
|
|
4378
4929
|
/**
|
|
@@ -4401,6 +4952,7 @@ export declare type StatusCodeMap<T> = {
|
|
|
4401
4952
|
* ```
|
|
4402
4953
|
*
|
|
4403
4954
|
* @public
|
|
4955
|
+
* @noInheritDoc
|
|
4404
4956
|
*/
|
|
4405
4957
|
export declare class StorageModule extends BaseModule {
|
|
4406
4958
|
constructor();
|
|
@@ -4412,44 +4964,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4412
4964
|
*
|
|
4413
4965
|
* @returns Confirmation that the boolean value was stored.
|
|
4414
4966
|
*
|
|
4415
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4416
|
-
*
|
|
4417
4967
|
* @example
|
|
4418
4968
|
* **Simple usage**
|
|
4419
4969
|
* ```typescript
|
|
4420
|
-
* // Imports using ES Module built
|
|
4421
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4422
|
-
* // Imports using UMD built (via CDN)
|
|
4423
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4424
|
-
*
|
|
4425
4970
|
* // Initialize the storage module
|
|
4426
4971
|
* const storageModule = new StorageModule();
|
|
4427
4972
|
*
|
|
4428
4973
|
* // Set a boolean value
|
|
4429
|
-
*
|
|
4430
|
-
*
|
|
4431
|
-
*
|
|
4432
|
-
*
|
|
4433
|
-
*
|
|
4434
|
-
*
|
|
4435
|
-
*
|
|
4436
|
-
*
|
|
4437
|
-
*
|
|
4438
|
-
*
|
|
4439
|
-
*
|
|
4440
|
-
*
|
|
4441
|
-
*
|
|
4442
|
-
*
|
|
4443
|
-
* console.log('Unexpected status code:', response);
|
|
4444
|
-
* }
|
|
4445
|
-
* } catch (error) {
|
|
4446
|
-
* console.log('Unexpected error:', error);
|
|
4974
|
+
* const response = await storageModule.setBoolean('isDarkMode', true);
|
|
4975
|
+
*
|
|
4976
|
+
* switch (response.status_code) {
|
|
4977
|
+
* case 204:
|
|
4978
|
+
* console.log('Value stored successfully');
|
|
4979
|
+
* break;
|
|
4980
|
+
* case 400:
|
|
4981
|
+
* console.log('Could not store value:', response.error);
|
|
4982
|
+
* break;
|
|
4983
|
+
* case 501:
|
|
4984
|
+
* console.log('Not in Grab app:', response.error);
|
|
4985
|
+
* break;
|
|
4986
|
+
* default:
|
|
4987
|
+
* console.log('Unexpected status code:', response);
|
|
4447
4988
|
* }
|
|
4448
4989
|
* ```
|
|
4449
4990
|
*
|
|
4450
4991
|
* @public
|
|
4451
4992
|
*/
|
|
4452
|
-
setBoolean(key: string, value: boolean): SetBooleanResponse
|
|
4993
|
+
setBoolean(key: string, value: boolean): Promise<SetBooleanResponse>;
|
|
4453
4994
|
/**
|
|
4454
4995
|
* Retrieves a boolean value from the native storage.
|
|
4455
4996
|
*
|
|
@@ -4457,44 +4998,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4457
4998
|
*
|
|
4458
4999
|
* @returns The stored boolean value.
|
|
4459
5000
|
*
|
|
4460
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4461
|
-
*
|
|
4462
5001
|
* @example
|
|
4463
5002
|
* **Simple usage**
|
|
4464
5003
|
* ```typescript
|
|
4465
|
-
* // Imports using ES Module built
|
|
4466
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4467
|
-
* // Imports using UMD built (via CDN)
|
|
4468
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4469
|
-
*
|
|
4470
5004
|
* // Initialize the storage module
|
|
4471
5005
|
* const storageModule = new StorageModule();
|
|
4472
5006
|
*
|
|
4473
5007
|
* // Get a boolean value
|
|
4474
|
-
*
|
|
4475
|
-
*
|
|
4476
|
-
*
|
|
4477
|
-
*
|
|
4478
|
-
*
|
|
4479
|
-
*
|
|
4480
|
-
*
|
|
4481
|
-
*
|
|
4482
|
-
*
|
|
4483
|
-
*
|
|
4484
|
-
*
|
|
4485
|
-
*
|
|
4486
|
-
*
|
|
4487
|
-
*
|
|
4488
|
-
* console.log('Unexpected status code:', response);
|
|
4489
|
-
* }
|
|
4490
|
-
* } catch (error) {
|
|
4491
|
-
* console.log('Unexpected error:', error);
|
|
5008
|
+
* const response = await storageModule.getBoolean('isDarkMode');
|
|
5009
|
+
*
|
|
5010
|
+
* switch (response.status_code) {
|
|
5011
|
+
* case 200:
|
|
5012
|
+
* console.log('Stored value:', response.result.value);
|
|
5013
|
+
* break;
|
|
5014
|
+
* case 400:
|
|
5015
|
+
* console.log('Could not retrieve value:', response.error);
|
|
5016
|
+
* break;
|
|
5017
|
+
* case 501:
|
|
5018
|
+
* console.log('Not in Grab app:', response.error);
|
|
5019
|
+
* break;
|
|
5020
|
+
* default:
|
|
5021
|
+
* console.log('Unexpected status code:', response);
|
|
4492
5022
|
* }
|
|
4493
5023
|
* ```
|
|
4494
5024
|
*
|
|
4495
5025
|
* @public
|
|
4496
5026
|
*/
|
|
4497
|
-
getBoolean(key: string): GetBooleanResponse
|
|
5027
|
+
getBoolean(key: string): Promise<GetBooleanResponse>;
|
|
4498
5028
|
/**
|
|
4499
5029
|
* Stores an integer value in the native storage.
|
|
4500
5030
|
*
|
|
@@ -4503,44 +5033,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4503
5033
|
*
|
|
4504
5034
|
* @returns Confirmation that the integer value was stored.
|
|
4505
5035
|
*
|
|
4506
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4507
|
-
*
|
|
4508
5036
|
* @example
|
|
4509
5037
|
* **Simple usage**
|
|
4510
5038
|
* ```typescript
|
|
4511
|
-
* // Imports using ES Module built
|
|
4512
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4513
|
-
* // Imports using UMD built (via CDN)
|
|
4514
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4515
|
-
*
|
|
4516
5039
|
* // Initialize the storage module
|
|
4517
5040
|
* const storageModule = new StorageModule();
|
|
4518
5041
|
*
|
|
4519
5042
|
* // Set an integer value
|
|
4520
|
-
*
|
|
4521
|
-
*
|
|
4522
|
-
*
|
|
4523
|
-
*
|
|
4524
|
-
*
|
|
4525
|
-
*
|
|
4526
|
-
*
|
|
4527
|
-
*
|
|
4528
|
-
*
|
|
4529
|
-
*
|
|
4530
|
-
*
|
|
4531
|
-
*
|
|
4532
|
-
*
|
|
4533
|
-
*
|
|
4534
|
-
* console.log('Unexpected status code:', response);
|
|
4535
|
-
* }
|
|
4536
|
-
* } catch (error) {
|
|
4537
|
-
* console.log('Unexpected error:', error);
|
|
5043
|
+
* const response = await storageModule.setInt('userCount', 42);
|
|
5044
|
+
*
|
|
5045
|
+
* switch (response.status_code) {
|
|
5046
|
+
* case 204:
|
|
5047
|
+
* console.log('Value stored successfully');
|
|
5048
|
+
* break;
|
|
5049
|
+
* case 400:
|
|
5050
|
+
* console.log('Could not store value:', response.error);
|
|
5051
|
+
* break;
|
|
5052
|
+
* case 501:
|
|
5053
|
+
* console.log('Not in Grab app:', response.error);
|
|
5054
|
+
* break;
|
|
5055
|
+
* default:
|
|
5056
|
+
* console.log('Unexpected status code:', response);
|
|
4538
5057
|
* }
|
|
4539
5058
|
* ```
|
|
4540
5059
|
*
|
|
4541
5060
|
* @public
|
|
4542
5061
|
*/
|
|
4543
|
-
setInt(key: string, value: number): SetIntResponse
|
|
5062
|
+
setInt(key: string, value: number): Promise<SetIntResponse>;
|
|
4544
5063
|
/**
|
|
4545
5064
|
* Retrieves an integer value from the native storage.
|
|
4546
5065
|
*
|
|
@@ -4548,44 +5067,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4548
5067
|
*
|
|
4549
5068
|
* @returns The stored integer value.
|
|
4550
5069
|
*
|
|
4551
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4552
|
-
*
|
|
4553
5070
|
* @example
|
|
4554
5071
|
* **Simple usage**
|
|
4555
5072
|
* ```typescript
|
|
4556
|
-
* // Imports using ES Module built
|
|
4557
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4558
|
-
* // Imports using UMD built (via CDN)
|
|
4559
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4560
|
-
*
|
|
4561
5073
|
* // Initialize the storage module
|
|
4562
5074
|
* const storageModule = new StorageModule();
|
|
4563
5075
|
*
|
|
4564
5076
|
* // Get an integer value
|
|
4565
|
-
*
|
|
4566
|
-
*
|
|
4567
|
-
*
|
|
4568
|
-
*
|
|
4569
|
-
*
|
|
4570
|
-
*
|
|
4571
|
-
*
|
|
4572
|
-
*
|
|
4573
|
-
*
|
|
4574
|
-
*
|
|
4575
|
-
*
|
|
4576
|
-
*
|
|
4577
|
-
*
|
|
4578
|
-
*
|
|
4579
|
-
* console.log('Unexpected status code:', response);
|
|
4580
|
-
* }
|
|
4581
|
-
* } catch (error) {
|
|
4582
|
-
* console.log('Unexpected error:', error);
|
|
5077
|
+
* const response = await storageModule.getInt('userCount');
|
|
5078
|
+
*
|
|
5079
|
+
* switch (response.status_code) {
|
|
5080
|
+
* case 200:
|
|
5081
|
+
* console.log('Stored value:', response.result.value);
|
|
5082
|
+
* break;
|
|
5083
|
+
* case 400:
|
|
5084
|
+
* console.log('Could not retrieve value:', response.error);
|
|
5085
|
+
* break;
|
|
5086
|
+
* case 501:
|
|
5087
|
+
* console.log('Not in Grab app:', response.error);
|
|
5088
|
+
* break;
|
|
5089
|
+
* default:
|
|
5090
|
+
* console.log('Unexpected status code:', response);
|
|
4583
5091
|
* }
|
|
4584
5092
|
* ```
|
|
4585
5093
|
*
|
|
4586
5094
|
* @public
|
|
4587
5095
|
*/
|
|
4588
|
-
getInt(key: string): GetIntResponse
|
|
5096
|
+
getInt(key: string): Promise<GetIntResponse>;
|
|
4589
5097
|
/**
|
|
4590
5098
|
* Stores a string value in the native storage.
|
|
4591
5099
|
*
|
|
@@ -4594,44 +5102,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4594
5102
|
*
|
|
4595
5103
|
* @returns Confirmation that the string value was stored.
|
|
4596
5104
|
*
|
|
4597
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4598
|
-
*
|
|
4599
5105
|
* @example
|
|
4600
5106
|
* **Simple usage**
|
|
4601
5107
|
* ```typescript
|
|
4602
|
-
* // Imports using ES Module built
|
|
4603
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4604
|
-
* // Imports using UMD built (via CDN)
|
|
4605
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4606
|
-
*
|
|
4607
5108
|
* // Initialize the storage module
|
|
4608
5109
|
* const storageModule = new StorageModule();
|
|
4609
5110
|
*
|
|
4610
5111
|
* // Set a string value
|
|
4611
|
-
*
|
|
4612
|
-
*
|
|
4613
|
-
*
|
|
4614
|
-
*
|
|
4615
|
-
*
|
|
4616
|
-
*
|
|
4617
|
-
*
|
|
4618
|
-
*
|
|
4619
|
-
*
|
|
4620
|
-
*
|
|
4621
|
-
*
|
|
4622
|
-
*
|
|
4623
|
-
*
|
|
4624
|
-
*
|
|
4625
|
-
* console.log('Unexpected status code:', response);
|
|
4626
|
-
* }
|
|
4627
|
-
* } catch (error) {
|
|
4628
|
-
* console.log('Unexpected error:', error);
|
|
5112
|
+
* const response = await storageModule.setString('username', 'john_doe');
|
|
5113
|
+
*
|
|
5114
|
+
* switch (response.status_code) {
|
|
5115
|
+
* case 204:
|
|
5116
|
+
* console.log('Value stored successfully');
|
|
5117
|
+
* break;
|
|
5118
|
+
* case 400:
|
|
5119
|
+
* console.log('Could not store value:', response.error);
|
|
5120
|
+
* break;
|
|
5121
|
+
* case 501:
|
|
5122
|
+
* console.log('Not in Grab app:', response.error);
|
|
5123
|
+
* break;
|
|
5124
|
+
* default:
|
|
5125
|
+
* console.log('Unexpected status code:', response);
|
|
4629
5126
|
* }
|
|
4630
5127
|
* ```
|
|
4631
5128
|
*
|
|
4632
5129
|
* @public
|
|
4633
5130
|
*/
|
|
4634
|
-
setString(key: string, value: string): SetStringResponse
|
|
5131
|
+
setString(key: string, value: string): Promise<SetStringResponse>;
|
|
4635
5132
|
/**
|
|
4636
5133
|
* Retrieves a string value from the native storage.
|
|
4637
5134
|
*
|
|
@@ -4639,44 +5136,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4639
5136
|
*
|
|
4640
5137
|
* @returns The stored string value.
|
|
4641
5138
|
*
|
|
4642
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4643
|
-
*
|
|
4644
5139
|
* @example
|
|
4645
5140
|
* **Simple usage**
|
|
4646
5141
|
* ```typescript
|
|
4647
|
-
* // Imports using ES Module built
|
|
4648
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4649
|
-
* // Imports using UMD built (via CDN)
|
|
4650
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4651
|
-
*
|
|
4652
5142
|
* // Initialize the storage module
|
|
4653
5143
|
* const storageModule = new StorageModule();
|
|
4654
5144
|
*
|
|
4655
5145
|
* // Get a string value
|
|
4656
|
-
*
|
|
4657
|
-
*
|
|
4658
|
-
*
|
|
4659
|
-
*
|
|
4660
|
-
*
|
|
4661
|
-
*
|
|
4662
|
-
*
|
|
4663
|
-
*
|
|
4664
|
-
*
|
|
4665
|
-
*
|
|
4666
|
-
*
|
|
4667
|
-
*
|
|
4668
|
-
*
|
|
4669
|
-
*
|
|
4670
|
-
* console.log('Unexpected status code:', response);
|
|
4671
|
-
* }
|
|
4672
|
-
* } catch (error) {
|
|
4673
|
-
* console.log('Unexpected error:', error);
|
|
5146
|
+
* const response = await storageModule.getString('username');
|
|
5147
|
+
*
|
|
5148
|
+
* switch (response.status_code) {
|
|
5149
|
+
* case 200:
|
|
5150
|
+
* console.log('Stored value:', response.result.value);
|
|
5151
|
+
* break;
|
|
5152
|
+
* case 400:
|
|
5153
|
+
* console.log('Could not retrieve value:', response.error);
|
|
5154
|
+
* break;
|
|
5155
|
+
* case 501:
|
|
5156
|
+
* console.log('Not in Grab app:', response.error);
|
|
5157
|
+
* break;
|
|
5158
|
+
* default:
|
|
5159
|
+
* console.log('Unexpected status code:', response);
|
|
4674
5160
|
* }
|
|
4675
5161
|
* ```
|
|
4676
5162
|
*
|
|
4677
5163
|
* @public
|
|
4678
5164
|
*/
|
|
4679
|
-
getString(key: string): GetStringResponse
|
|
5165
|
+
getString(key: string): Promise<GetStringResponse>;
|
|
4680
5166
|
/**
|
|
4681
5167
|
* Stores a double (floating point) value in the native storage.
|
|
4682
5168
|
*
|
|
@@ -4685,44 +5171,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4685
5171
|
*
|
|
4686
5172
|
* @returns Confirmation that the double value was stored.
|
|
4687
5173
|
*
|
|
4688
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4689
|
-
*
|
|
4690
5174
|
* @example
|
|
4691
5175
|
* **Simple usage**
|
|
4692
5176
|
* ```typescript
|
|
4693
|
-
* // Imports using ES Module built
|
|
4694
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4695
|
-
* // Imports using UMD built (via CDN)
|
|
4696
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4697
|
-
*
|
|
4698
5177
|
* // Initialize the storage module
|
|
4699
5178
|
* const storageModule = new StorageModule();
|
|
4700
5179
|
*
|
|
4701
5180
|
* // Set a double value
|
|
4702
|
-
*
|
|
4703
|
-
*
|
|
4704
|
-
*
|
|
4705
|
-
*
|
|
4706
|
-
*
|
|
4707
|
-
*
|
|
4708
|
-
*
|
|
4709
|
-
*
|
|
4710
|
-
*
|
|
4711
|
-
*
|
|
4712
|
-
*
|
|
4713
|
-
*
|
|
4714
|
-
*
|
|
4715
|
-
*
|
|
4716
|
-
* console.log('Unexpected status code:', response);
|
|
4717
|
-
* }
|
|
4718
|
-
* } catch (error) {
|
|
4719
|
-
* console.log('Unexpected error:', error);
|
|
5181
|
+
* const response = await storageModule.setDouble('price', 19.99);
|
|
5182
|
+
*
|
|
5183
|
+
* switch (response.status_code) {
|
|
5184
|
+
* case 204:
|
|
5185
|
+
* console.log('Value stored successfully');
|
|
5186
|
+
* break;
|
|
5187
|
+
* case 400:
|
|
5188
|
+
* console.log('Could not store value:', response.error);
|
|
5189
|
+
* break;
|
|
5190
|
+
* case 501:
|
|
5191
|
+
* console.log('Not in Grab app:', response.error);
|
|
5192
|
+
* break;
|
|
5193
|
+
* default:
|
|
5194
|
+
* console.log('Unexpected status code:', response);
|
|
4720
5195
|
* }
|
|
4721
5196
|
* ```
|
|
4722
5197
|
*
|
|
4723
5198
|
* @public
|
|
4724
5199
|
*/
|
|
4725
|
-
setDouble(key: string, value: number): SetDoubleResponse
|
|
5200
|
+
setDouble(key: string, value: number): Promise<SetDoubleResponse>;
|
|
4726
5201
|
/**
|
|
4727
5202
|
* Retrieves a double (floating point) value from the native storage.
|
|
4728
5203
|
*
|
|
@@ -4730,44 +5205,33 @@ export declare class StorageModule extends BaseModule {
|
|
|
4730
5205
|
*
|
|
4731
5206
|
* @returns The stored double value.
|
|
4732
5207
|
*
|
|
4733
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4734
|
-
*
|
|
4735
5208
|
* @example
|
|
4736
5209
|
* **Simple usage**
|
|
4737
5210
|
* ```typescript
|
|
4738
|
-
* // Imports using ES Module built
|
|
4739
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4740
|
-
* // Imports using UMD built (via CDN)
|
|
4741
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4742
|
-
*
|
|
4743
5211
|
* // Initialize the storage module
|
|
4744
5212
|
* const storageModule = new StorageModule();
|
|
4745
5213
|
*
|
|
4746
5214
|
* // Get a double value
|
|
4747
|
-
*
|
|
4748
|
-
*
|
|
4749
|
-
*
|
|
4750
|
-
*
|
|
4751
|
-
*
|
|
4752
|
-
*
|
|
4753
|
-
*
|
|
4754
|
-
*
|
|
4755
|
-
*
|
|
4756
|
-
*
|
|
4757
|
-
*
|
|
4758
|
-
*
|
|
4759
|
-
*
|
|
4760
|
-
*
|
|
4761
|
-
* console.log('Unexpected status code:', response);
|
|
4762
|
-
* }
|
|
4763
|
-
* } catch (error) {
|
|
4764
|
-
* console.log('Unexpected error:', error);
|
|
5215
|
+
* const response = await storageModule.getDouble('price');
|
|
5216
|
+
*
|
|
5217
|
+
* switch (response.status_code) {
|
|
5218
|
+
* case 200:
|
|
5219
|
+
* console.log('Stored value:', response.result.value);
|
|
5220
|
+
* break;
|
|
5221
|
+
* case 400:
|
|
5222
|
+
* console.log('Could not retrieve value:', response.error);
|
|
5223
|
+
* break;
|
|
5224
|
+
* case 501:
|
|
5225
|
+
* console.log('Not in Grab app:', response.error);
|
|
5226
|
+
* break;
|
|
5227
|
+
* default:
|
|
5228
|
+
* console.log('Unexpected status code:', response);
|
|
4765
5229
|
* }
|
|
4766
5230
|
* ```
|
|
4767
5231
|
*
|
|
4768
5232
|
* @public
|
|
4769
5233
|
*/
|
|
4770
|
-
getDouble(key: string): GetDoubleResponse
|
|
5234
|
+
getDouble(key: string): Promise<GetDoubleResponse>;
|
|
4771
5235
|
/**
|
|
4772
5236
|
* Removes a single value from the native storage by key.
|
|
4773
5237
|
*
|
|
@@ -4775,84 +5239,62 @@ export declare class StorageModule extends BaseModule {
|
|
|
4775
5239
|
*
|
|
4776
5240
|
* @returns Confirmation that the value was removed.
|
|
4777
5241
|
*
|
|
4778
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4779
|
-
*
|
|
4780
5242
|
* @example
|
|
4781
5243
|
* **Simple usage**
|
|
4782
5244
|
* ```typescript
|
|
4783
|
-
* // Imports using ES Module built
|
|
4784
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4785
|
-
* // Imports using UMD built (via CDN)
|
|
4786
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4787
|
-
*
|
|
4788
5245
|
* // Initialize the storage module
|
|
4789
5246
|
* const storageModule = new StorageModule();
|
|
4790
5247
|
*
|
|
4791
5248
|
* // Remove a value
|
|
4792
|
-
*
|
|
4793
|
-
*
|
|
4794
|
-
*
|
|
4795
|
-
*
|
|
4796
|
-
*
|
|
4797
|
-
*
|
|
4798
|
-
*
|
|
4799
|
-
*
|
|
4800
|
-
*
|
|
4801
|
-
*
|
|
4802
|
-
*
|
|
4803
|
-
*
|
|
4804
|
-
*
|
|
4805
|
-
*
|
|
4806
|
-
* console.log('Unexpected status code:', response);
|
|
4807
|
-
* }
|
|
4808
|
-
* } catch (error) {
|
|
4809
|
-
* console.log('Unexpected error:', error);
|
|
5249
|
+
* const response = await storageModule.remove('username');
|
|
5250
|
+
*
|
|
5251
|
+
* switch (response.status_code) {
|
|
5252
|
+
* case 204:
|
|
5253
|
+
* console.log('Value removed successfully');
|
|
5254
|
+
* break;
|
|
5255
|
+
* case 400:
|
|
5256
|
+
* console.log('Could not remove value:', response.error);
|
|
5257
|
+
* break;
|
|
5258
|
+
* case 501:
|
|
5259
|
+
* console.log('Not in Grab app:', response.error);
|
|
5260
|
+
* break;
|
|
5261
|
+
* default:
|
|
5262
|
+
* console.log('Unexpected status code:', response);
|
|
4810
5263
|
* }
|
|
4811
5264
|
* ```
|
|
4812
5265
|
*
|
|
4813
5266
|
* @public
|
|
4814
5267
|
*/
|
|
4815
|
-
remove(key: string): RemoveResponse
|
|
5268
|
+
remove(key: string): Promise<RemoveResponse>;
|
|
4816
5269
|
/**
|
|
4817
5270
|
* Removes all values from the native storage.
|
|
4818
5271
|
*
|
|
4819
5272
|
* @returns Confirmation that all values were removed.
|
|
4820
5273
|
*
|
|
4821
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4822
|
-
*
|
|
4823
5274
|
* @example
|
|
4824
5275
|
* **Simple usage**
|
|
4825
5276
|
* ```typescript
|
|
4826
|
-
* // Imports using ES Module built
|
|
4827
|
-
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
4828
|
-
* // Imports using UMD built (via CDN)
|
|
4829
|
-
* const { StorageModule } = window.SuperAppSDK;
|
|
4830
|
-
*
|
|
4831
5277
|
* // Initialize the storage module
|
|
4832
5278
|
* const storageModule = new StorageModule();
|
|
4833
5279
|
*
|
|
4834
5280
|
* // Remove all values
|
|
4835
|
-
*
|
|
4836
|
-
*
|
|
4837
|
-
*
|
|
4838
|
-
*
|
|
4839
|
-
*
|
|
4840
|
-
*
|
|
4841
|
-
*
|
|
4842
|
-
*
|
|
4843
|
-
*
|
|
4844
|
-
*
|
|
4845
|
-
*
|
|
4846
|
-
* console.log('Unexpected status code:', response);
|
|
4847
|
-
* }
|
|
4848
|
-
* } catch (error) {
|
|
4849
|
-
* console.log('Unexpected error:', error);
|
|
5281
|
+
* const response = await storageModule.removeAll();
|
|
5282
|
+
*
|
|
5283
|
+
* switch (response.status_code) {
|
|
5284
|
+
* case 204:
|
|
5285
|
+
* console.log('All values removed successfully');
|
|
5286
|
+
* break;
|
|
5287
|
+
* case 501:
|
|
5288
|
+
* console.log('Not in Grab app:', response.error);
|
|
5289
|
+
* break;
|
|
5290
|
+
* default:
|
|
5291
|
+
* console.log('Unexpected status code:', response);
|
|
4850
5292
|
* }
|
|
4851
5293
|
* ```
|
|
4852
5294
|
*
|
|
4853
5295
|
* @public
|
|
4854
5296
|
*/
|
|
4855
|
-
removeAll(): RemoveAllResponse
|
|
5297
|
+
removeAll(): Promise<RemoveAllResponse>;
|
|
4856
5298
|
}
|
|
4857
5299
|
|
|
4858
5300
|
/**
|
|
@@ -4897,6 +5339,7 @@ export declare type Subscription = Readonly<{
|
|
|
4897
5339
|
* ```
|
|
4898
5340
|
*
|
|
4899
5341
|
* @public
|
|
5342
|
+
* @noInheritDoc
|
|
4900
5343
|
*/
|
|
4901
5344
|
export declare class SystemWebViewKitModule extends BaseModule {
|
|
4902
5345
|
constructor();
|
|
@@ -4907,49 +5350,38 @@ export declare class SystemWebViewKitModule extends BaseModule {
|
|
|
4907
5350
|
*
|
|
4908
5351
|
* @returns Confirmation of whether the redirect to system web view was successful.
|
|
4909
5352
|
*
|
|
4910
|
-
* @throws Error when the JSBridge method fails unexpectedly.
|
|
4911
|
-
*
|
|
4912
5353
|
* @example
|
|
4913
5354
|
* **Simple usage**
|
|
4914
5355
|
* ```typescript
|
|
4915
|
-
* // Imports using ES Module built
|
|
4916
|
-
* import { SystemWebViewKitModule } from '@grabjs/superapp-sdk';
|
|
4917
|
-
* // Imports using UMD built (via CDN)
|
|
4918
|
-
* const { SystemWebViewKitModule } = window.SuperAppSDK;
|
|
4919
|
-
*
|
|
4920
5356
|
* // Initialize the system web view kit module
|
|
4921
5357
|
* const systemWebViewKitModule = new SystemWebViewKitModule();
|
|
4922
5358
|
*
|
|
4923
5359
|
* // Open a URL in system web view
|
|
4924
|
-
*
|
|
4925
|
-
*
|
|
4926
|
-
*
|
|
4927
|
-
* });
|
|
5360
|
+
* const response = await systemWebViewKitModule.redirectToSystemWebView({
|
|
5361
|
+
* url: 'https://www.example.com'
|
|
5362
|
+
* });
|
|
4928
5363
|
*
|
|
4929
|
-
*
|
|
4930
|
-
*
|
|
4931
|
-
*
|
|
4932
|
-
*
|
|
4933
|
-
*
|
|
4934
|
-
*
|
|
4935
|
-
*
|
|
4936
|
-
*
|
|
4937
|
-
*
|
|
4938
|
-
*
|
|
4939
|
-
*
|
|
4940
|
-
*
|
|
4941
|
-
*
|
|
4942
|
-
*
|
|
4943
|
-
*
|
|
4944
|
-
* }
|
|
4945
|
-
* } catch (err) {
|
|
4946
|
-
* console.log('Unexpected error:', err);
|
|
5364
|
+
* switch (response.status_code) {
|
|
5365
|
+
* case 200:
|
|
5366
|
+
* console.log('Redirect initiated successfully');
|
|
5367
|
+
* break;
|
|
5368
|
+
* case 400:
|
|
5369
|
+
* console.log('Could not redirect:', response.error);
|
|
5370
|
+
* break;
|
|
5371
|
+
* case 424:
|
|
5372
|
+
* console.log('Dependency error:', response.error);
|
|
5373
|
+
* break;
|
|
5374
|
+
* case 501:
|
|
5375
|
+
* console.log('Not in Grab app:', response.error);
|
|
5376
|
+
* break;
|
|
5377
|
+
* default:
|
|
5378
|
+
* console.log('Unexpected status code:', response);
|
|
4947
5379
|
* }
|
|
4948
5380
|
* ```
|
|
4949
5381
|
*
|
|
4950
5382
|
* @public
|
|
4951
5383
|
*/
|
|
4952
|
-
redirectToSystemWebView(request: RedirectToSystemWebViewRequest): RedirectToSystemWebViewResponse
|
|
5384
|
+
redirectToSystemWebView(request: RedirectToSystemWebViewRequest): Promise<RedirectToSystemWebViewResponse>;
|
|
4953
5385
|
}
|
|
4954
5386
|
|
|
4955
5387
|
/**
|
|
@@ -4983,6 +5415,7 @@ export declare type TriggerCheckoutRequest = Record<string, unknown>;
|
|
|
4983
5415
|
* This response can have the following status codes:
|
|
4984
5416
|
* - `200`: Checkout completed successfully. The `result` contains transaction details.
|
|
4985
5417
|
* - `400`: Bad request - invalid checkout parameters.
|
|
5418
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
4986
5419
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
4987
5420
|
*
|
|
4988
5421
|
* @example
|
|
@@ -5041,9 +5474,18 @@ export declare type TriggerCheckoutRequest = Record<string, unknown>;
|
|
|
5041
5474
|
* }
|
|
5042
5475
|
* ```
|
|
5043
5476
|
*
|
|
5477
|
+
* @example
|
|
5478
|
+
* **Internal server error response (500):**
|
|
5479
|
+
* ```typescript
|
|
5480
|
+
* {
|
|
5481
|
+
* status_code: 500,
|
|
5482
|
+
* error: 'Internal server error'
|
|
5483
|
+
* }
|
|
5484
|
+
* ```
|
|
5485
|
+
*
|
|
5044
5486
|
* @public
|
|
5045
5487
|
*/
|
|
5046
|
-
export declare type TriggerCheckoutResponse =
|
|
5488
|
+
export declare type TriggerCheckoutResponse = BridgeResponse<200 | 400 | 500 | 501, TriggerCheckoutResult>;
|
|
5047
5489
|
|
|
5048
5490
|
/**
|
|
5049
5491
|
* Result object containing the checkout transaction details.
|
|
@@ -5091,14 +5533,78 @@ export declare type TriggerCheckoutResponse = Promise<ConstrainedBridgeResponse<
|
|
|
5091
5533
|
export declare type TriggerCheckoutResult = {
|
|
5092
5534
|
/** Unique identifier for the transaction at Grab side. */
|
|
5093
5535
|
transactionID: string;
|
|
5094
|
-
/** Status of the transaction
|
|
5095
|
-
status:
|
|
5536
|
+
/** Status of the transaction. */
|
|
5537
|
+
status: 'success' | 'failure' | 'pending' | 'userInitiatedCancel';
|
|
5096
5538
|
/** Error message if the transaction failed. */
|
|
5097
5539
|
errorMessage?: string;
|
|
5098
5540
|
/** Error code associated with the failed transaction. */
|
|
5099
5541
|
errorCode?: string;
|
|
5100
5542
|
};
|
|
5101
5543
|
|
|
5544
|
+
/**
|
|
5545
|
+
* JSBridge module for reading user-related attributes from native code.
|
|
5546
|
+
*
|
|
5547
|
+
* @group Modules
|
|
5548
|
+
*
|
|
5549
|
+
* @remarks
|
|
5550
|
+
* Provides access to user and traveller attributes exposed by the native Grab app bridge.
|
|
5551
|
+
* This code must run on the Grab SuperApp's webview to function correctly.
|
|
5552
|
+
*
|
|
5553
|
+
* @example
|
|
5554
|
+
* **ES Module:**
|
|
5555
|
+
* ```typescript
|
|
5556
|
+
* import { UserAttributesModule } from '@grabjs/superapp-sdk';
|
|
5557
|
+
* const userAttributesModule = new UserAttributesModule();
|
|
5558
|
+
* ```
|
|
5559
|
+
*
|
|
5560
|
+
* @example
|
|
5561
|
+
* **CDN (UMD):**
|
|
5562
|
+
* ```html
|
|
5563
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
5564
|
+
* <script>
|
|
5565
|
+
* const userAttributesModule = new SuperAppSDK.UserAttributesModule();
|
|
5566
|
+
* </script>
|
|
5567
|
+
* ```
|
|
5568
|
+
*
|
|
5569
|
+
* @public
|
|
5570
|
+
* @noInheritDoc
|
|
5571
|
+
*/
|
|
5572
|
+
export declare class UserAttributesModule extends BaseModule {
|
|
5573
|
+
constructor();
|
|
5574
|
+
/**
|
|
5575
|
+
* Returns the currently selected travel destination as a lowercase ISO 3166-1 alpha-2 country code.
|
|
5576
|
+
*
|
|
5577
|
+
* @returns The selected travel destination lowercase ISO 3166-1 alpha-2 country code when available.
|
|
5578
|
+
*
|
|
5579
|
+
* @example
|
|
5580
|
+
* **Simple usage**
|
|
5581
|
+
* ```typescript
|
|
5582
|
+
* // Initialize the user attributes module
|
|
5583
|
+
* const userAttributesModule = new UserAttributesModule();
|
|
5584
|
+
*
|
|
5585
|
+
* // Read the selected travel destination
|
|
5586
|
+
* const response = await userAttributesModule.getSelectedTravelDestination();
|
|
5587
|
+
*
|
|
5588
|
+
* switch (response.status_code) {
|
|
5589
|
+
* case 200:
|
|
5590
|
+
* console.log('Selected travel destination code:', response.result);
|
|
5591
|
+
* break;
|
|
5592
|
+
* case 204:
|
|
5593
|
+
* console.log('Selected travel destination is not available');
|
|
5594
|
+
* break;
|
|
5595
|
+
* case 501:
|
|
5596
|
+
* console.log('Not in Grab app:', response.error);
|
|
5597
|
+
* break;
|
|
5598
|
+
* default:
|
|
5599
|
+
* console.log('Unexpected status code:', response);
|
|
5600
|
+
* }
|
|
5601
|
+
* ```
|
|
5602
|
+
*
|
|
5603
|
+
* @public
|
|
5604
|
+
*/
|
|
5605
|
+
getSelectedTravelDestination(): Promise<GetSelectedTravelDestinationResponse>;
|
|
5606
|
+
}
|
|
5607
|
+
|
|
5102
5608
|
/**
|
|
5103
5609
|
* Request parameters for verifying the user's email with an OTP.
|
|
5104
5610
|
*
|
|
@@ -5126,7 +5632,8 @@ export declare type VerifyEmailRequest = {
|
|
|
5126
5632
|
* This response can have the following status codes:
|
|
5127
5633
|
* - `200`: Email verified successfully.
|
|
5128
5634
|
* - `400`: Invalid request - OTP is incorrect or expired.
|
|
5129
|
-
* - `
|
|
5635
|
+
* - `426`: Upgrade Required - feature requires Grab app version 5.399 or above.
|
|
5636
|
+
* - `500`: Internal server error - an unexpected error occurred on the native side.
|
|
5130
5637
|
* - `501`: Not implemented - this method requires the Grab app environment.
|
|
5131
5638
|
*
|
|
5132
5639
|
* @example
|
|
@@ -5145,11 +5652,11 @@ export declare type VerifyEmailRequest = {
|
|
|
5145
5652
|
* ```
|
|
5146
5653
|
*
|
|
5147
5654
|
* @example
|
|
5148
|
-
* **
|
|
5655
|
+
* **Upgrade Required response (426):**
|
|
5149
5656
|
* ```typescript
|
|
5150
5657
|
* {
|
|
5151
|
-
* status_code:
|
|
5152
|
-
* error: 'This
|
|
5658
|
+
* status_code: 426,
|
|
5659
|
+
* error: 'Upgrade Required: This method requires Grab app version 5.399.0 or above on iOS'
|
|
5153
5660
|
* }
|
|
5154
5661
|
* ```
|
|
5155
5662
|
*
|
|
@@ -5162,9 +5669,18 @@ export declare type VerifyEmailRequest = {
|
|
|
5162
5669
|
* }
|
|
5163
5670
|
* ```
|
|
5164
5671
|
*
|
|
5672
|
+
* @example
|
|
5673
|
+
* **Internal server error response (500):**
|
|
5674
|
+
* ```typescript
|
|
5675
|
+
* {
|
|
5676
|
+
* status_code: 500,
|
|
5677
|
+
* error: 'Internal server error'
|
|
5678
|
+
* }
|
|
5679
|
+
* ```
|
|
5680
|
+
*
|
|
5165
5681
|
* @public
|
|
5166
5682
|
*/
|
|
5167
|
-
export declare type VerifyEmailResponse =
|
|
5683
|
+
export declare type VerifyEmailResponse = BridgeResponse<200 | 400 | 426 | 500 | 501, VerifyEmailResult>;
|
|
5168
5684
|
|
|
5169
5685
|
/**
|
|
5170
5686
|
* Result object for verifying the user's email.
|
|
@@ -5174,6 +5690,17 @@ export declare type VerifyEmailResponse = Promise<ConstrainedBridgeResponse<Veri
|
|
|
5174
5690
|
*/
|
|
5175
5691
|
export declare type VerifyEmailResult = void;
|
|
5176
5692
|
|
|
5693
|
+
/**
|
|
5694
|
+
* Represents a semantic version with major, minor, and patch components.
|
|
5695
|
+
*
|
|
5696
|
+
* @public
|
|
5697
|
+
*/
|
|
5698
|
+
export declare interface Version {
|
|
5699
|
+
major: number;
|
|
5700
|
+
minor: number;
|
|
5701
|
+
patch: number;
|
|
5702
|
+
}
|
|
5703
|
+
|
|
5177
5704
|
/**
|
|
5178
5705
|
* Generic interface for all native JSBridge module wrappers.
|
|
5179
5706
|
*
|
|
@@ -5192,14 +5719,14 @@ export declare type VerifyEmailResult = void;
|
|
|
5192
5719
|
* Extending with method overloads (ProfileModule, LocationModule):
|
|
5193
5720
|
* ```typescript
|
|
5194
5721
|
* export interface WrappedProfileModule extends WrappedModule {
|
|
5195
|
-
* invoke(method: 'fetchEmail', params?: any): Promise<BridgeResponse<string>>;
|
|
5722
|
+
* invoke(method: 'fetchEmail', params?: any): Promise<BridgeResponse<BridgeStatusCode, string>>;
|
|
5196
5723
|
* }
|
|
5197
5724
|
* ```
|
|
5198
5725
|
*
|
|
5199
5726
|
* @public
|
|
5200
5727
|
*/
|
|
5201
5728
|
export declare interface WrappedModule {
|
|
5202
|
-
invoke<T
|
|
5729
|
+
invoke<T>(method: string, params?: unknown): BridgeStream<BridgeStatusCode, T> | Promise<BridgeResponse<BridgeStatusCode, T>>;
|
|
5203
5730
|
}
|
|
5204
5731
|
|
|
5205
5732
|
export { }
|