@base44-preview/sdk 0.8.63-pr.384.b9e5aa9 → 0.8.63-pr.385.da33077

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.
@@ -370,6 +370,14 @@ export interface AuthModule {
370
370
  * {@linkcode verifyOtp | verifyOtp()} to complete verification, then log the user
371
371
  * in with {@linkcode loginViaEmailPassword | loginViaEmailPassword()}.
372
372
  *
373
+ * The response is the same whether or not the email already has an account.
374
+ * If the email belongs to an account that's still waiting for verification, the user gets a fresh code.
375
+ * If the account is already verified, no code is sent. Because your app can't
376
+ * tell which case applies, offer a new code with
377
+ * {@linkcode resendOtp | resendOtp()}, and tell users who already have an
378
+ * account to log in or reset their password with
379
+ * {@linkcode resetPasswordRequest | resetPasswordRequest()}.
380
+ *
373
381
  * @param params - Registration details including email, password, and optional fields.
374
382
  * @returns Promise resolving to the registration response.
375
383
  *
@@ -406,10 +414,22 @@ export interface AuthModule {
406
414
  * has expired or the user didn't receive it, send a fresh one with
407
415
  * {@linkcode resendOtp | resendOtp()}.
408
416
  *
417
+ * Each code allows five tries. Verification fails with the same error, "Invalid or
418
+ * expired verification code", in each of these cases:
419
+ *
420
+ * - The code is wrong.
421
+ * - The code has expired.
422
+ * - The code has used up its five tries.
423
+ * - The email has no account waiting for verification.
424
+ *
425
+ * The error doesn't say how many tries are left. When verification fails, offer
426
+ * the user a new code with {@linkcode resendOtp | resendOtp()}, which also
427
+ * resets the tries.
428
+ *
409
429
  * @param params - The email being verified and the OTP code the user entered.
410
430
  * @returns Promise resolving to the verification response, which includes an
411
431
  * access token for the now-verified user.
412
- * @throws Error if the OTP code is invalid or expired.
432
+ * @throws Error if verification fails for any reason.
413
433
  *
414
434
  * @example
415
435
  * ```typescript
@@ -421,7 +441,8 @@ export interface AuthModule {
421
441
  * });
422
442
  * console.log('Email verified successfully!');
423
443
  * } catch (error) {
424
- * console.error('Invalid or expired OTP code');
444
+ * // The same error covers a wrong, expired, or used-up code
445
+ * console.error('Invalid or expired code. Request a new one.');
425
446
  * }
426
447
  * ```
427
448
  *
@@ -452,13 +473,19 @@ export interface AuthModule {
452
473
  *
453
474
  * Call this when the user didn't receive the original code sent by
454
475
  * {@linkcode register | register()}, or when the previous code has expired.
455
- * The new code replaces the previous one. Pass it to
476
+ * Sending a new code resets the five tries. Pass it to
456
477
  * {@linkcode verifyOtp | verifyOtp()} to complete verification.
457
478
  *
479
+ * A code is sent only when the email belongs to an account that's still
480
+ * waiting for verification. For an email that's already verified or has no
481
+ * account, nothing is sent, but the response is the same. Tell users who still
482
+ * don't get a code to log in or reset their password with
483
+ * {@linkcode resetPasswordRequest | resetPasswordRequest()}.
484
+ *
458
485
  * @param email - Email address to send the new OTP to.
459
- * @returns Promise resolving once the new OTP has been sent, with a
460
- * confirmation message and the new code's expiration window.
461
- * @throws Error if the email is invalid or the request fails.
486
+ * @returns Promise resolving to a confirmation message and the code's
487
+ * expiration window. The same response is returned whether or not a code was sent.
488
+ * @throws Error if the request fails.
462
489
  *
463
490
  * @example
464
491
  * ```typescript
@@ -49,10 +49,6 @@ export interface AppUserConnectorConnectionResponse {
49
49
  * automatically retry non-idempotent requests based on them.
50
50
  */
51
51
  export type ConnectorApiResponsePhase = "not_sent" | "responded" | "timed_out" | "sent_unconfirmed";
52
- /**
53
- * A query parameter value: a string, number, boolean, or an array of strings and numbers.
54
- */
55
- export type ConnectorApiQueryValue = string | number | boolean | Array<string | number>;
56
52
  /**
57
53
  * A request to forward to a metered connector's API through the Base44 proxy.
58
54
  */
@@ -72,12 +68,8 @@ export interface ConnectorApiRequest {
72
68
  * separately in `query`. Either way, they're forwarded and priced the same.
73
69
  */
74
70
  path: string;
75
- /**
76
- * Query parameters. Merged into the request URL with any already in `path`.
77
- *
78
- * Each value can be a string, number, boolean, or an array of strings and numbers.
79
- */
80
- query?: Record<string, ConnectorApiQueryValue>;
71
+ /** Query parameters. Merged into the request URL with any already in `path`. */
72
+ query?: Record<string, string | number | boolean | Array<string | number>>;
81
73
  /** Extra request headers. Only headers the connector explicitly allows are forwarded, and the rest are dropped. */
82
74
  headers?: Record<string, string>;
83
75
  /** JSON request body. Ignored for `GET` and `HEAD`. */
@@ -156,15 +148,15 @@ export interface ConnectorProxyRawResponse {
156
148
  *
157
149
  * ## Metered connectors
158
150
  *
159
- * Some [platform connectors](#shared-connectors) use paid third-party APIs that charge Base44 per call. These connectors don't support an OAuth connection. As a result, {@linkcode getConnection | getConnection()} rejects with a permission error. Instead, call them with {@linkcode callApi | callApi()}. Base44 attaches the credential server-side, forwards the request, and charges the call to your workspace's credits.
151
+ * A few [platform connectors](#shared-connectors) are backed by paid third-party APIs that charge Base44 per call. For those, the OAuth token isn't available to your code, and {@linkcode getConnection | getConnection()} rejects with a permission error. Call them with {@linkcode callApi | callApi()} instead. Base44 attaches the credential server-side, forwards the request, and charges the call to your workspace's credits.
160
152
  *
161
- * This applies to platform connectors only. Workspace-registered and app user connectors aren't metered. They run on your own OAuth app, so the provider charges you directly.
153
+ * This applies to platform connectors only. A workspace-registered or app user connector runs on your own OAuth app, so the provider invoices you directly and there's nothing for Base44 to meter. Those connectors keep normal token access through {@linkcode getWorkspaceConnection | getWorkspaceConnection()} and {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()}.
162
154
  *
163
155
  * Keep these in mind when you call a metered connector:
164
156
  *
165
- * - **Cost varies by endpoint:** The same connector can charge differently depending on the endpoint you are calling. Avoid running expensive calls inside a loop, and batch requests when the provider supports it. Each response reports what it cost in the `creditsCharged` response field.
166
- * - **Response handling:** Provider errors and connection failures are returned in the response instead of being thrown. Read the `success` and `phase` fields to assess what happened. Errors on the Base44 side, such as authorization failures, quota failures, and invalid requests, reject the promise.
167
- * - **Retries:** After a timeout or a failure partway through, the provider may have already run it. You can confirm that a provider didn't run your request when `phase` is `'not_sent'`.
157
+ * - **Cost varies by endpoint, sometimes sharply.** The same connector can charge a hundred times more for one endpoint than for another, so avoid putting an expensive call inside a loop, and batch wherever the provider supports it. Each response reports what it cost in `creditsCharged`.
158
+ * - **Provider and transport outcomes are returned, not thrown.** A provider `4xx` or `5xx` response, or a connection failure, comes back as `success: false` with its `phase`. Authorization failures, quota failures, and invalid proxy requests reject the promise.
159
+ * - **Only `phase: 'not_sent'` proves the provider didn't execute the request.** A timeout or in-flight failure may have executed upstream, so don't automatically retry a non-idempotent call unless the provider supports an idempotency key.
168
160
  *
169
161
  * ## Available connectors
170
162
  *
@@ -426,11 +418,11 @@ export interface ConnectorsModule {
426
418
  /**
427
419
  * Calls a [metered connector's](#metered-connectors) API through the Base44 proxy.
428
420
  *
429
- * Use this for a shared platform connector identified by an integration type. Base44 adds the OAuth credential to the outgoing request, forwards it, and charges the call to the workspace's credits.
421
+ * Use this for a shared platform connector identified by an integration type. Base44 adds the OAuth credential to the outgoing request, forwards it, and charges the call to the workspace's credits, so you never handle the token yourself.
430
422
  *
431
423
  * @param integrationType - The integration type of a metered connector, such as `'x'`.
432
424
  * @param request - The upstream request to forward.
433
- * @returns Promise resolving to the upstream response.
425
+ * @returns Promise resolving to the upstream response. An upstream error is reported in `success` and `status` instead of thrown. Only Base44-side failures reject.
434
426
  *
435
427
  * @example
436
428
  * ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.63-pr.384.b9e5aa9",
3
+ "version": "0.8.63-pr.385.da33077",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",