@base44-preview/platform 0.6.0-pr.378.dce07b1 → 0.6.0-pr.382.458dc61

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.
@@ -233,3 +233,5 @@ export interface WebhookEventMap {
233
233
  }
234
234
  /** Every event type in {@link WebhookEventMap}, so events from a newer Base44 can be told apart at runtime. @internal */
235
235
  export declare const WEBHOOK_EVENT_TYPES: readonly ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "chat.turn_started.v1", "chat.turn_ended.v1"];
236
+ /** The deprecation notice of each deprecated event type, for verifyEvent()'s warning. @internal */
237
+ export declare const WEBHOOK_DEPRECATIONS: Partial<Record<string, string>>;
@@ -2,3 +2,5 @@
2
2
  // published at https://base44.com/webhooks/schemas. Do not edit by hand; run `npm run generate:webhooks`.
3
3
  /** Every event type in {@link WebhookEventMap}, so events from a newer Base44 can be told apart at runtime. @internal */
4
4
  export const WEBHOOK_EVENT_TYPES = ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "chat.turn_started.v1", "chat.turn_ended.v1"];
5
+ /** The deprecation notice of each deprecated event type, for verifyEvent()'s warning. @internal */
6
+ export const WEBHOOK_DEPRECATIONS = {};
@@ -1,8 +1,17 @@
1
1
  import { WebhookConfigurationError, WebhookVerificationError } from "../errors.js";
2
2
  import { anySignatureVerifies, importPublicKey, parsePublicKeys, parseSignatures, readHeader, signedPayload } from "./webhooks-signature.js";
3
- import { WEBHOOK_EVENT_TYPES } from "./webhooks.events.generated.js";
3
+ import { WEBHOOK_DEPRECATIONS, WEBHOOK_EVENT_TYPES } from "./webhooks.events.generated.js";
4
4
  const knownTypes = new Set(WEBHOOK_EVENT_TYPES);
5
5
  const DEFAULT_TOLERANCE_SECONDS = 300;
6
+ // Types can't flag a deprecated event in a `switch` or a handler key, so the first delivery of each says so.
7
+ const warnedDeprecated = new Set();
8
+ function warnIfDeprecated(type) {
9
+ const notice = WEBHOOK_DEPRECATIONS[type];
10
+ if (!notice || warnedDeprecated.has(type))
11
+ return;
12
+ warnedDeprecated.add(type);
13
+ console.warn(`Base44 webhook event ${type}: ${notice}`);
14
+ }
6
15
  /** Webhook receiving utilities. Verification is local: no network calls, no timers. */
7
16
  export function createWebhooks() {
8
17
  // Imported keys are cached by their wire form so a pinned key is imported once.
@@ -49,6 +58,7 @@ export function createWebhooks() {
49
58
  if (typeof type !== "string" || typeof eventId !== "string" || typeof data !== "object" || data === null) {
50
59
  throw new WebhookVerificationError("invalid_payload");
51
60
  }
61
+ warnIfDeprecated(type);
52
62
  // A type from a newer Base44 gets the client's unknown-event shape, so known types keep narrowing.
53
63
  return (knownTypes.has(type) ? event : { ...event, type: "unknown", name: type });
54
64
  };
@@ -121,9 +121,15 @@ export interface CreateHandlerOptions extends VerifyEventOptions {
121
121
  /**
122
122
  * Webhooks module for receiving and verifying Base44's webhooks.
123
123
  *
124
- * Base44 sends a signed event to your endpoint:
125
- * - When an app is created, published, unpublished, moved to trash, or restored.
126
- * - When you add the endpoint, to test it.
124
+ * Base44 sends your endpoint a signed event for each event type it selected, and a `webhook.test.v1`
125
+ * event when you add the endpoint, to test it. `WebhookEventMap` lists every event type this version
126
+ * knows, with the shape of its `data`. See the
127
+ * [event types](https://docs.base44.com/developers/references/outbound-webhooks/get-started/event-types)
128
+ * for what each one means.
129
+ *
130
+ * A deprecated event type's `data` interface and its `WebhookEventMap` entry are marked `@deprecated`.
131
+ * Editors don't flag a `case` label or a handler key, so `verifyEvent()` also logs a warning the
132
+ * first time each deprecated type arrives, saying what replaces it.
127
133
  *
128
134
  * The module verifies each delivery's signature with your workspace's public keys and returns the
129
135
  * event with a typed payload. It runs on Node.js 20 and later and on edge runtimes, and makes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/platform",
3
- "version": "0.6.0-pr.378.dce07b1",
3
+ "version": "0.6.0-pr.382.458dc61",
4
4
  "description": "Base44 Platform SDK for white-label platforms: a browser client for following the AI chat and a server entrypoint for webhooks",
5
5
  "main": "dist/client/index.js",
6
6
  "types": "dist/client/index.d.ts",