@grabjs/superapp-sdk 2.0.0-beta.12 → 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.
Files changed (166) hide show
  1. package/README.md +170 -55
  2. package/api-reference/json/api.json +27688 -0
  3. package/api-reference/markdown/README.md +194 -0
  4. package/api-reference/markdown/classes/BaseModule.md +123 -0
  5. package/api-reference/markdown/classes/CameraModule.md +177 -0
  6. package/api-reference/markdown/classes/CheckoutModule.md +181 -0
  7. package/api-reference/markdown/classes/ContainerModule.md +751 -0
  8. package/api-reference/markdown/classes/DeviceCapabilityModule.md +161 -0
  9. package/api-reference/markdown/classes/FileModule.md +178 -0
  10. package/api-reference/markdown/classes/IdentityModule.md +299 -0
  11. package/api-reference/markdown/classes/LocaleModule.md +161 -0
  12. package/api-reference/markdown/classes/LocationModule.md +239 -0
  13. package/api-reference/markdown/classes/MediaModule.md +219 -0
  14. package/api-reference/markdown/classes/PlatformModule.md +162 -0
  15. package/api-reference/markdown/classes/ProfileModule.md +224 -0
  16. package/api-reference/markdown/classes/ScopeModule.md +219 -0
  17. package/api-reference/markdown/classes/StorageModule.md +608 -0
  18. package/api-reference/markdown/classes/SystemWebViewKitModule.md +177 -0
  19. package/api-reference/markdown/classes/UserAttributesModule.md +164 -0
  20. package/api-reference/markdown/functions/isClientError.md +37 -0
  21. package/api-reference/markdown/functions/isErrorResponse.md +40 -0
  22. package/api-reference/markdown/functions/isRedirection.md +37 -0
  23. package/api-reference/markdown/functions/isServerError.md +37 -0
  24. package/api-reference/markdown/functions/isSuccess.md +39 -0
  25. package/api-reference/markdown/globals.md +176 -0
  26. package/api-reference/markdown/interfaces/GrabAppInfo.md +23 -0
  27. package/api-reference/markdown/interfaces/InvokeOptions.md +63 -0
  28. package/api-reference/markdown/interfaces/Version.md +23 -0
  29. package/api-reference/markdown/interfaces/WrappedModule.md +51 -0
  30. package/api-reference/markdown/type-aliases/AuthorizeRequest.md +79 -0
  31. package/api-reference/markdown/type-aliases/AuthorizeResponse.md +58 -0
  32. package/api-reference/markdown/type-aliases/AuthorizeResult.md +33 -0
  33. package/api-reference/markdown/type-aliases/BackResponse.md +37 -0
  34. package/api-reference/markdown/type-aliases/BackResult.md +8 -0
  35. package/api-reference/markdown/type-aliases/BridgeClientError.md +9 -0
  36. package/api-reference/markdown/type-aliases/BridgeError.md +8 -0
  37. package/api-reference/markdown/type-aliases/BridgeRedirection.md +8 -0
  38. package/api-reference/markdown/type-aliases/BridgeResponse.md +40 -0
  39. package/api-reference/markdown/type-aliases/BridgeServerError.md +8 -0
  40. package/api-reference/markdown/type-aliases/BridgeStatusCode.md +7 -0
  41. package/api-reference/markdown/type-aliases/BridgeStream.md +29 -0
  42. package/api-reference/markdown/type-aliases/BridgeStreamHandlers.md +25 -0
  43. package/api-reference/markdown/type-aliases/BridgeSuccessResponse.md +14 -0
  44. package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResponse.md +18 -0
  45. package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResult.md +8 -0
  46. package/api-reference/markdown/type-aliases/CloseResponse.md +37 -0
  47. package/api-reference/markdown/type-aliases/CloseResult.md +8 -0
  48. package/api-reference/markdown/type-aliases/DRMContentConfig.md +34 -0
  49. package/api-reference/markdown/type-aliases/DRMPlaybackEvent.md +43 -0
  50. package/api-reference/markdown/type-aliases/DownloadFileRequest.md +32 -0
  51. package/api-reference/markdown/type-aliases/DownloadFileResponse.md +48 -0
  52. package/api-reference/markdown/type-aliases/DownloadFileResult.md +11 -0
  53. package/api-reference/markdown/type-aliases/ErrorResponse.md +32 -0
  54. package/api-reference/markdown/type-aliases/FetchEmailResponse.md +58 -0
  55. package/api-reference/markdown/type-aliases/FetchEmailResult.md +21 -0
  56. package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResponse.md +42 -0
  57. package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResult.md +57 -0
  58. package/api-reference/markdown/type-aliases/GetBooleanRequest.md +21 -0
  59. package/api-reference/markdown/type-aliases/GetBooleanResponse.md +57 -0
  60. package/api-reference/markdown/type-aliases/GetBooleanResult.md +27 -0
  61. package/api-reference/markdown/type-aliases/GetCoordinateResponse.md +49 -0
  62. package/api-reference/markdown/type-aliases/GetCoordinateResult.md +29 -0
  63. package/api-reference/markdown/type-aliases/GetCountryCodeResponse.md +57 -0
  64. package/api-reference/markdown/type-aliases/GetCountryCodeResult.md +25 -0
  65. package/api-reference/markdown/type-aliases/GetDoubleRequest.md +21 -0
  66. package/api-reference/markdown/type-aliases/GetDoubleResponse.md +57 -0
  67. package/api-reference/markdown/type-aliases/GetDoubleResult.md +27 -0
  68. package/api-reference/markdown/type-aliases/GetIntRequest.md +21 -0
  69. package/api-reference/markdown/type-aliases/GetIntResponse.md +57 -0
  70. package/api-reference/markdown/type-aliases/GetIntResult.md +27 -0
  71. package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResponse.md +48 -0
  72. package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResult.md +31 -0
  73. package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResponse.md +48 -0
  74. package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResult.md +17 -0
  75. package/api-reference/markdown/type-aliases/GetSessionParamsResponse.md +40 -0
  76. package/api-reference/markdown/type-aliases/GetSessionParamsResult.md +27 -0
  77. package/api-reference/markdown/type-aliases/GetStringRequest.md +21 -0
  78. package/api-reference/markdown/type-aliases/GetStringResponse.md +57 -0
  79. package/api-reference/markdown/type-aliases/GetStringResult.md +27 -0
  80. package/api-reference/markdown/type-aliases/HasAccessToResponse.md +66 -0
  81. package/api-reference/markdown/type-aliases/HasAccessToResult.md +27 -0
  82. package/api-reference/markdown/type-aliases/HideBackButtonResponse.md +37 -0
  83. package/api-reference/markdown/type-aliases/HideBackButtonResult.md +8 -0
  84. package/api-reference/markdown/type-aliases/HideLoaderResponse.md +37 -0
  85. package/api-reference/markdown/type-aliases/HideLoaderResult.md +8 -0
  86. package/api-reference/markdown/type-aliases/HideRefreshButtonResponse.md +37 -0
  87. package/api-reference/markdown/type-aliases/HideRefreshButtonResult.md +8 -0
  88. package/api-reference/markdown/type-aliases/IsConnectedResponse.md +31 -0
  89. package/api-reference/markdown/type-aliases/IsConnectedResult.md +27 -0
  90. package/api-reference/markdown/type-aliases/IsEsimSupportedResponse.md +48 -0
  91. package/api-reference/markdown/type-aliases/IsEsimSupportedResult.md +17 -0
  92. package/api-reference/markdown/type-aliases/ObserveDRMPlaybackResponse.md +15 -0
  93. package/api-reference/markdown/type-aliases/ObserveLocationChangeResponse.md +15 -0
  94. package/api-reference/markdown/type-aliases/OnContentLoadedResponse.md +37 -0
  95. package/api-reference/markdown/type-aliases/OnContentLoadedResult.md +8 -0
  96. package/api-reference/markdown/type-aliases/OnCtaTapRequest.md +13 -0
  97. package/api-reference/markdown/type-aliases/OnCtaTapResponse.md +37 -0
  98. package/api-reference/markdown/type-aliases/OnCtaTapResult.md +8 -0
  99. package/api-reference/markdown/type-aliases/OpenExternalLinkRequest.md +13 -0
  100. package/api-reference/markdown/type-aliases/OpenExternalLinkResponse.md +46 -0
  101. package/api-reference/markdown/type-aliases/OpenExternalLinkResult.md +8 -0
  102. package/api-reference/markdown/type-aliases/Platform.md +7 -0
  103. package/api-reference/markdown/type-aliases/PlayDRMContentResponse.md +43 -0
  104. package/api-reference/markdown/type-aliases/PlayDRMContentResult.md +8 -0
  105. package/api-reference/markdown/type-aliases/RedirectToSystemWebViewRequest.md +23 -0
  106. package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResponse.md +55 -0
  107. package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResult.md +8 -0
  108. package/api-reference/markdown/type-aliases/ReloadScopesResponse.md +46 -0
  109. package/api-reference/markdown/type-aliases/ReloadScopesResult.md +8 -0
  110. package/api-reference/markdown/type-aliases/RemoveAllResponse.md +37 -0
  111. package/api-reference/markdown/type-aliases/RemoveAllResult.md +8 -0
  112. package/api-reference/markdown/type-aliases/RemoveResponse.md +46 -0
  113. package/api-reference/markdown/type-aliases/RemoveResult.md +8 -0
  114. package/api-reference/markdown/type-aliases/ResponseStatusCode200.md +34 -0
  115. package/api-reference/markdown/type-aliases/ResponseStatusCode204.md +20 -0
  116. package/api-reference/markdown/type-aliases/ResponseStatusCode302.md +20 -0
  117. package/api-reference/markdown/type-aliases/ResponseStatusCode400.md +7 -0
  118. package/api-reference/markdown/type-aliases/ResponseStatusCode401.md +7 -0
  119. package/api-reference/markdown/type-aliases/ResponseStatusCode403.md +7 -0
  120. package/api-reference/markdown/type-aliases/ResponseStatusCode404.md +7 -0
  121. package/api-reference/markdown/type-aliases/ResponseStatusCode424.md +7 -0
  122. package/api-reference/markdown/type-aliases/ResponseStatusCode426.md +12 -0
  123. package/api-reference/markdown/type-aliases/ResponseStatusCode500.md +7 -0
  124. package/api-reference/markdown/type-aliases/ResponseStatusCode501.md +12 -0
  125. package/api-reference/markdown/type-aliases/ScanQRCodeRequest.md +27 -0
  126. package/api-reference/markdown/type-aliases/ScanQRCodeResponse.md +64 -0
  127. package/api-reference/markdown/type-aliases/ScanQRCodeResult.md +21 -0
  128. package/api-reference/markdown/type-aliases/SendAnalyticsEventRequest.md +56 -0
  129. package/api-reference/markdown/type-aliases/SendAnalyticsEventResponse.md +46 -0
  130. package/api-reference/markdown/type-aliases/SendAnalyticsEventResult.md +8 -0
  131. package/api-reference/markdown/type-aliases/SetBackgroundColorRequest.md +13 -0
  132. package/api-reference/markdown/type-aliases/SetBackgroundColorResponse.md +46 -0
  133. package/api-reference/markdown/type-aliases/SetBackgroundColorResult.md +8 -0
  134. package/api-reference/markdown/type-aliases/SetBooleanResponse.md +46 -0
  135. package/api-reference/markdown/type-aliases/SetBooleanResult.md +8 -0
  136. package/api-reference/markdown/type-aliases/SetDoubleResponse.md +46 -0
  137. package/api-reference/markdown/type-aliases/SetDoubleResult.md +8 -0
  138. package/api-reference/markdown/type-aliases/SetIntResponse.md +46 -0
  139. package/api-reference/markdown/type-aliases/SetIntResult.md +8 -0
  140. package/api-reference/markdown/type-aliases/SetStringResponse.md +46 -0
  141. package/api-reference/markdown/type-aliases/SetStringResult.md +8 -0
  142. package/api-reference/markdown/type-aliases/SetTitleRequest.md +13 -0
  143. package/api-reference/markdown/type-aliases/SetTitleResponse.md +46 -0
  144. package/api-reference/markdown/type-aliases/SetTitleResult.md +8 -0
  145. package/api-reference/markdown/type-aliases/ShowBackButtonResponse.md +37 -0
  146. package/api-reference/markdown/type-aliases/ShowBackButtonResult.md +8 -0
  147. package/api-reference/markdown/type-aliases/ShowLoaderResponse.md +37 -0
  148. package/api-reference/markdown/type-aliases/ShowLoaderResult.md +8 -0
  149. package/api-reference/markdown/type-aliases/ShowRefreshButtonResponse.md +37 -0
  150. package/api-reference/markdown/type-aliases/ShowRefreshButtonResult.md +8 -0
  151. package/api-reference/markdown/type-aliases/StatusCodeMap.md +80 -0
  152. package/api-reference/markdown/type-aliases/Subscription.md +12 -0
  153. package/api-reference/markdown/type-aliases/TriggerCheckoutRequest.md +26 -0
  154. package/api-reference/markdown/type-aliases/TriggerCheckoutResponse.md +76 -0
  155. package/api-reference/markdown/type-aliases/TriggerCheckoutResult.md +75 -0
  156. package/api-reference/markdown/type-aliases/VerifyEmailRequest.md +32 -0
  157. package/api-reference/markdown/type-aliases/VerifyEmailResponse.md +55 -0
  158. package/api-reference/markdown/type-aliases/VerifyEmailResult.md +8 -0
  159. package/api-reference/markdown/variables/ContainerAnalyticsEventData.md +21 -0
  160. package/api-reference/markdown/variables/ContainerAnalyticsEventName.md +13 -0
  161. package/api-reference/markdown/variables/ContainerAnalyticsEventState.md +25 -0
  162. package/dist/index.d.ts +3377 -1139
  163. package/dist/index.esm.js +1 -1
  164. package/dist/index.js +1 -1
  165. package/package.json +24 -13
  166. package/dist/api.json +0 -16795
package/README.md CHANGED
@@ -1,79 +1,194 @@
1
- # JavaScript to Native bridge communication
2
-
3
1
  ## Overview
4
2
 
5
- Communication between web-app and native Grab app happens via web bridge. Each request and
6
- response object must have a structure defined in this document.
3
+ The SuperApp SDK enables web developers to build MiniApps that run within the Grab SuperApp WebView. It provides a type-safe bridge for communication between web applications and native Android/iOS capabilities.
7
4
 
8
- ## Currently available modules
5
+ Each module encapsulates a specific domain of functionality, offering strongly-typed APIs with consistent response patterns.
9
6
 
10
- - [Camera Module](https://github.com/grab/superapp-sdk/blob/master/docs/CameraModule.md)
11
- - [Checkout Module](https://github.com/grab/superapp-sdk/blob/master/docs/CheckoutModule.md).
12
- - [Container Module](https://github.com/grab/superapp-sdk/blob/master/docs/ContainerModule.md).
13
- - [Identity Module](https://github.com/grab/superapp-sdk/blob/master/docs/IdentityModule.md).
14
- - [Location Module](https://github.com/grab/superapp-sdk/blob/master/docs/LocationModule.md).
15
- - [Media Module](https://github.com/grab/superapp-sdk/blob/master/docs/MediaModule.md).
16
- - [Scope Module](https://github.com/grab/superapp-sdk/blob/master/docs/ScopeModule.md).
17
- - [Locale Module](https://github.com/grab/superapp-sdk/blob/master/docs/LocaleModule.md).
18
- - [Storage Module](https://github.com/grab/superapp-sdk/blob/master/docs/StorageModule.md)
19
- - [Platform Module](https://github.com/grab/superapp-sdk/blob/master/docs/PlatformModule.md)
20
- - [SystemWebViewKit Module](https://github.com/grab/superapp-sdk/blob/master/docs/SystemWebViewKitModule.md)
7
+ ### Key Features
21
8
 
22
- One point to note is that partner engineers need to call `ScopeModule.reloadScopes` after redirection to partner website to load permissions from `GrabID`:
9
+ - **Type-Safe APIs** Full TypeScript support with comprehensive type definitions
10
+ - **Modular Architecture** — Import only the modules you need
11
+ - **Consistent Response Pattern** — All methods return standardized bridge responses with HTTP-style status codes
12
+ - **Streaming Support** — Real-time data streams for location updates and media events
13
+ - **Automatic Fallbacks** — Graceful degradation when native features are unavailable
23
14
 
24
- ```javascript
25
- const scopeModule = new ScopeModule();
26
- await scopeModule.reloadScopes();
27
- ```
15
+ ## Installation
28
16
 
29
- Afterwards, calls to module methods will reflect actual permissions.
17
+ ### NPM (ES Modules)
30
18
 
31
- ## Request
19
+ ```bash
20
+ npm install @grabjs/superapp-sdk
21
+ ```
32
22
 
33
- Each request to native API should be done through JavaScript bridge provided by Grab. Please refer to specific Module API documentation for more details
23
+ ```typescript
24
+ import { ContainerModule, LocationModule } from '@grabjs/superapp-sdk';
25
+ ```
34
26
 
35
- ## Response
27
+ ### CDN (UMD Bundle)
36
28
 
37
- Each response from the native bridge follows the same structure described bellow.
29
+ ```html
30
+ <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
31
+ <script>
32
+ const { ContainerModule, LocationModule } = window.SuperAppSDK;
33
+ </script>
34
+ ```
38
35
 
39
- | Key | Type | Description |
40
- | ----------- | ------------------------ | ---------------------------------------------------------------------------------- |
41
- | status_code | Integer | Response status code (see list of codes below) |
42
- | result | Object or primitive type | Result object according to method specification (required for **200** status code) |
43
- | error | String | Error message (required for **non-200** status codes) |
36
+ ## Usage
44
37
 
45
- ### Response status codes
38
+ ### Basic Module Initialization
46
39
 
47
- | Code | Type | Description |
48
- | ---- | ----------------- | ------------------------------------------------------------------------------- |
49
- | 200 | OK | Request successful, **result** value contains response data |
50
- | 204 | No Content | Request successful, **result** value doesn't contain data |
51
- | 400 | Bad Request | The request is malformed (e.g. missing **parameters**, missing **method** name) |
52
- | 403 | Forbidden | The client doesn't have permission to access this method |
53
- | 424 | Failed Dependency | Underlying request returned an error |
54
- | 500 | Internal Error | Unexpected internal error (e.g. failed to serialize response object) |
40
+ All modules are instantiated with a simple constructor call:
55
41
 
56
- ### Success response example
42
+ ```typescript
43
+ import { ContainerModule, LocationModule, IdentityModule } from '@grabjs/superapp-sdk';
57
44
 
58
- ```json
59
- {
60
- "status_code": 200,
61
- "result": {
62
- "latitude": 1.234567,
63
- "longitude": -1.234567
64
- }
45
+ // Initialize modules
46
+ const container = new ContainerModule();
47
+ const location = new LocationModule();
48
+ const identity = new IdentityModule();
49
+ ```
50
+
51
+ ### Handling Responses
52
+
53
+ All SDK methods return a standardized response with HTTP-style status codes:
54
+
55
+ ```typescript
56
+ import { CameraModule } from '@grabjs/superapp-sdk';
57
+
58
+ const camera = new CameraModule();
59
+ const response = await camera.scanQRCode({ title: 'Scan Payment QR' });
60
+
61
+ switch (response.status_code) {
62
+ case 200:
63
+ // Successfully scanned - result contains the QR code data
64
+ console.log('QR Code scanned:', response.result.qrCode);
65
+ break;
66
+ case 204:
67
+ // User cancelled the scanning operation
68
+ console.log('Scanning cancelled');
69
+ break;
70
+ case 400:
71
+ // Bad request - invalid request parameters
72
+ console.error('Invalid request:', response.error);
73
+ break;
74
+ case 403:
75
+ // Camera permission not granted to the Grab app
76
+ console.error('Camera permission denied:', response.error);
77
+ break;
78
+ case 501:
79
+ // Not implemented - not running in Grab app
80
+ console.error('Requires Grab SuperApp environment');
81
+ break;
82
+ default:
83
+ console.error('Unexpected error:', response);
65
84
  }
66
85
  ```
67
86
 
68
- ### Failure response example
87
+ ### Working with Streams
88
+
89
+ Some modules provide streaming methods for real-time data:
90
+
91
+ ```typescript
92
+ import { LocationModule } from '@grabjs/superapp-sdk';
93
+
94
+ const location = new LocationModule();
95
+
96
+ // Subscribe to location updates
97
+ const stream = location.observeLocationChange();
98
+
99
+ const subscription = stream.subscribe({
100
+ next: (response) => {
101
+ if (response.status_code === 200) {
102
+ console.log('Location:', response.result);
103
+ }
104
+ },
105
+ complete: () => {
106
+ console.log('Stream ended');
107
+ },
108
+ });
109
+
110
+ // Unsubscribe when done
111
+ subscription.unsubscribe();
112
+ ```
113
+
114
+ ## Available Modules
115
+
116
+ - **[ContainerModule](https://grab.github.io/superapp-sdk/classes/ContainerModule.html)** — Control the WebView container UI and lifecycle (header, loading indicators, analytics, connection verification)
117
+
118
+ - **[IdentityModule](https://grab.github.io/superapp-sdk/classes/IdentityModule.html)** — Authenticate users via GrabID OAuth2/OIDC with PKCE support
119
+
120
+ - **[LocationModule](https://grab.github.io/superapp-sdk/classes/LocationModule.html)** — Access device location services and subscribe to location updates
121
+
122
+ - **[StorageModule](https://grab.github.io/superapp-sdk/classes/StorageModule.html)** — Persist key-value data locally with type-safe storage
123
+
124
+ - **[CameraModule](https://grab.github.io/superapp-sdk/classes/CameraModule.html)** — Access device camera capabilities for QR code scanning
125
+
126
+ - **[CheckoutModule](https://grab.github.io/superapp-sdk/classes/CheckoutModule.html)** — Trigger native checkout flows for payment processing
127
+
128
+ - **[DeviceCapabilityModule](https://grab.github.io/superapp-sdk/classes/DeviceCapabilityModule.html)** — Query device hardware capabilities
69
129
 
70
- ```json
71
- {
72
- "status_code": 403,
73
- "error": "Client doesn't have access to method \"getLocation\" in module \"LocationModule\""
130
+ - **[FileModule](https://grab.github.io/superapp-sdk/classes/FileModule.html)** — Handle file operations including downloading from remote URLs
131
+
132
+ - **[LocaleModule](https://grab.github.io/superapp-sdk/classes/LocaleModule.html)** — Access device locale and localization settings
133
+
134
+ - **[MediaModule](https://grab.github.io/superapp-sdk/classes/MediaModule.html)** — Handle media playback including DRM-protected content
135
+
136
+ - **[PlatformModule](https://grab.github.io/superapp-sdk/classes/PlatformModule.html)** — Access platform information and navigation controls
137
+
138
+ - **[ProfileModule](https://grab.github.io/superapp-sdk/classes/ProfileModule.html)** — Access user profile information including email
139
+
140
+ - **[ScopeModule](https://grab.github.io/superapp-sdk/classes/ScopeModule.html)** — Manage permission scopes from GrabID
141
+
142
+ - **[SystemWebViewKitModule](https://grab.github.io/superapp-sdk/classes/SystemWebViewKitModule.html)** — Handle system WebView operations and external browser redirections
143
+
144
+ - **[UserAttributesModule](https://grab.github.io/superapp-sdk/classes/UserAttributesModule.html)** — Access user attribute data
145
+
146
+ > **Important:** Always call `ScopeModule.reloadScopes()` after an OAuth redirect to load the latest permissions from GrabID. Without this, module methods may return 403 errors even when permissions have been granted.
147
+
148
+ ## Response Status Codes
149
+
150
+ The SDK uses HTTP-style status codes for all responses:
151
+
152
+ | Code | Type | Description |
153
+ | ----- | ----------------- | --------------------------------------------------- |
154
+ | `200` | OK | Request successful, `result` contains response data |
155
+ | `204` | No Content | Request successful, no data returned |
156
+ | `302` | Redirect | OAuth redirect in progress |
157
+ | `400` | Bad Request | Invalid request parameters |
158
+ | `401` | Unauthorized | Authentication required |
159
+ | `403` | Forbidden | Insufficient permissions for this operation |
160
+ | `404` | Not Found | Resource not found |
161
+ | `424` | Failed Dependency | Underlying native request failed |
162
+ | `426` | Upgrade Required | Requires newer Grab app version |
163
+ | `500` | Internal Error | Unexpected SDK error |
164
+ | `501` | Not Implemented | Method requires Grab SuperApp environment |
165
+
166
+ ## Type Guards
167
+
168
+ The SDK provides type guards for response validation:
169
+
170
+ ```typescript
171
+ import { isSuccess, isErrorResponse, isClientError, isServerError } from '@grabjs/superapp-sdk';
172
+
173
+ const response = await someModule.someMethod();
174
+
175
+ if (isSuccess(response)) {
176
+ // TypeScript knows response.result is available
177
+ console.log(response.result);
178
+ }
179
+
180
+ if (isErrorResponse(response)) {
181
+ // TypeScript knows response.error is available
182
+ console.error(response.error);
74
183
  }
75
184
  ```
76
185
 
77
- ---
186
+ ## Best Practices
187
+
188
+ 2. **Handle all status codes** in your switch statements, including unexpected ones.
189
+
190
+ 3. **Use type guards** for cleaner response handling and better type inference.
191
+
192
+ 4. **Call `reloadScopes()` when your MiniApp launches and after OAuth** before accessing protected resources.
78
193
 
79
- - **GDMCOMMENT:** Latitudes and longitudes used in this file are either sourced from GrabPlaces, GrabMaps, OSM or randomly created by the developer and are not obtained from other external sources.
194
+ 5. **Unsubscribe from streams** when your component unmounts or you no longer need updates.