@centrali-io/centrali-sdk 9.0.2 → 9.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1246,6 +1246,8 @@ await centrali.webhookSubscriptions.deliveries.cancel(deliveryId);
1246
1246
  | `record_deleted` | A record is deleted (soft or hard) |
1247
1247
  | `records_bulk_created` | Multiple records are inserted in one batch |
1248
1248
 
1249
+ A subscription's `events` array also accepts **named business events** (`invoice.paid`, `payment.failed`, …) — any non-empty string — delivered via the `publish()` methods below. The `RecordEvents` enum values are kept for autocomplete; they are not a closed set.
1250
+
1249
1251
  #### Outbound Payload
1250
1252
 
1251
1253
  Centrali POSTs this JSON body to your URL:
@@ -1288,6 +1290,53 @@ function verifyCentraliSignature(rawBody: string, header: string, secret: string
1288
1290
  | `success` | Endpoint returned 2xx |
1289
1291
  | `retrying` | Awaiting next retry attempt |
1290
1292
  | `failed` | Exhausted all retries, or cancelled |
1293
+ | `filtered` | Matched the subscription's events but was skipped — payload predicate did not match, or a published business event did not cross the subscription's collection scope. Recorded as a terminal row so the skip is visible. |
1294
+
1295
+ ### Subscribers & Business Events
1296
+
1297
+ A **subscriber** is the customer or tenant a set of webhook subscriptions belongs to. `externalId` is your own id for that customer. Attach subscriptions to a subscriber with `subscriberId` on create/update, then publish named business events (`invoice.paid`) instead of relying on record lifecycle events.
1298
+
1299
+ ```typescript
1300
+ // Register a subscriber, then attach a prod + sandbox endpoint to it
1301
+ const { data: acme } = await centrali.subscribers.create({
1302
+ externalId: 'acme_123',
1303
+ name: 'Acme Corp',
1304
+ });
1305
+ await centrali.webhookSubscriptions.create({
1306
+ name: 'Acme production',
1307
+ url: 'https://acme.example.com/hooks/centrali',
1308
+ events: [RecordEvents.CREATED],
1309
+ subscriberId: acme.id,
1310
+ });
1311
+
1312
+ // List / get / update / delete — get/update/delete take the internal UUID
1313
+ const { data: all } = await centrali.subscribers.list();
1314
+ await centrali.subscribers.update(acme.id, { active: false });
1315
+
1316
+ // Everything this subscriber is subscribed to (keyed by your externalId).
1317
+ // Returns full subscription rows incl. the signing secret, so the caller
1318
+ // needs `webhook-subscriptions:retrieve` on top of `subscribers:retrieve`.
1319
+ const { data: subs } = await centrali.subscribers.subscriptions('acme_123');
1320
+ ```
1321
+
1322
+ ```typescript
1323
+ // Publish a business event to every subscription in the workspace that lists it.
1324
+ // Matches only subscriptions with no recordSlugs filter; a collection-scoped one
1325
+ // that also lists the event is recorded as a `filtered` delivery.
1326
+ const { data: fanout } = await centrali.webhookSubscriptions.publish({
1327
+ event: 'invoice.paid',
1328
+ data: { invoiceId: 'inv_1', amount: 4200 },
1329
+ });
1330
+ console.log(fanout.correlationId, '→', fanout.deliveries.length, 'deliveries');
1331
+
1332
+ // Publish scoped to one subscriber — reaches its collection-scoped subscriptions too
1333
+ await centrali.subscribers.publish('acme_123', {
1334
+ event: 'invoice.paid',
1335
+ data: { invoiceId: 'inv_1' },
1336
+ });
1337
+ ```
1338
+
1339
+ Both publish routes require the `publish` action on `webhook-subscriptions` (distinct from `create`). An empty `deliveries` array is a success — nothing subscribes to that event name.
1291
1340
 
1292
1341
  ## TypeScript Support
1293
1342
 
package/dist/index.d.ts CHANGED
@@ -311,6 +311,27 @@ declare function getWebhookDeliveryRetryApiPath(workspaceId: string, deliveryId:
311
311
  * Cancel is workspace-scoped — only the delivery ID is needed.
312
312
  */
313
313
  declare function getWebhookDeliveryCancelApiPath(workspaceId: string, deliveryId: string): string;
314
+ /**
315
+ * Generate the workspace-wide business-event publish API URL PATH.
316
+ * Fans a named event out to every subscription in the workspace listening for it.
317
+ */
318
+ declare function getWebhookPublishApiPath(workspaceId: string): string;
319
+ /**
320
+ * Generate Subscribers API URL PATH. `subscriberId` is the internal subscriber
321
+ * UUID — used for get/update/delete. The externalId-keyed routes have their own
322
+ * helpers below.
323
+ */
324
+ declare function getSubscribersApiPath(workspaceId: string, subscriberId?: string): string;
325
+ /**
326
+ * Generate the API URL PATH for a subscriber's attached webhook subscriptions,
327
+ * keyed by the builder's own `externalId`.
328
+ */
329
+ declare function getSubscriberSubscriptionsApiPath(workspaceId: string, externalId: string): string;
330
+ /**
331
+ * Generate the subscriber-scoped business-event publish API URL PATH, keyed by
332
+ * the builder's own `externalId`.
333
+ */
334
+ declare function getSubscriberPublishApiPath(workspaceId: string, externalId: string): string;
314
335
 
315
336
  /**
316
337
  * Retrieve an access token using the Client Credentials flow.
@@ -2867,12 +2888,20 @@ interface BulkOperationResult {
2867
2888
  message: string;
2868
2889
  }
2869
2890
 
2870
- type WebhookDeliveryStatus = 'success' | 'failed' | 'retrying';
2891
+ type WebhookDeliveryStatus = 'success' | 'failed' | 'retrying' | 'filtered';
2892
+ /**
2893
+ * An event name a subscription can listen for. The `RecordEventType` members
2894
+ * are the built-in record lifecycle events (kept for autocomplete); any other
2895
+ * string is a named business event published via
2896
+ * `centrali.webhookSubscriptions.publish()` / `centrali.subscribers.publish()`.
2897
+ * The backend validates this as a non-empty string, not an enum.
2898
+ */
2899
+ type WebhookEventName = RecordEventType | (string & {});
2871
2900
  interface WebhookSubscription {
2872
2901
  id: string;
2873
2902
  name: string;
2874
2903
  url: string;
2875
- events: RecordEventType[];
2904
+ events: WebhookEventName[];
2876
2905
  /**
2877
2906
  * Optional list of record slugs to scope the subscription to. When null or
2878
2907
  * empty, the subscription receives events for all collections.
@@ -2890,6 +2919,12 @@ interface WebhookSubscription {
2890
2919
  * describes. Frozen at creation; change it to upgrade to a newer shape.
2891
2920
  */
2892
2921
  payloadVersion: string;
2922
+ /**
2923
+ * CEN-1487: the owning subscriber's internal UUID, or null when the
2924
+ * subscription is unattached. Set it via `create`/`update` with a value
2925
+ * from `centrali.subscribers`.
2926
+ */
2927
+ subscriberId?: string | null;
2893
2928
  workspaceSlug: string;
2894
2929
  createdAt?: string;
2895
2930
  updatedAt?: string;
@@ -2927,7 +2962,8 @@ type WebhookDeliverySummary = Omit<WebhookDelivery, 'requestPayload' | 'response
2927
2962
  interface CreateWebhookSubscriptionInput {
2928
2963
  name: string;
2929
2964
  url: string;
2930
- events: RecordEventType[];
2965
+ /** Record lifecycle events and/or named business events. See `WebhookEventName`. */
2966
+ events: WebhookEventName[];
2931
2967
  /** Optional — restrict to a subset of collections. Omit for all collections. */
2932
2968
  recordSlugs?: string[];
2933
2969
  active?: boolean;
@@ -2937,11 +2973,18 @@ interface CreateWebhookSubscriptionInput {
2937
2973
  * by `getPayloadVersions()`.
2938
2974
  */
2939
2975
  payloadVersion?: string;
2976
+ /**
2977
+ * CEN-1487: attach the subscription to a subscriber. The internal
2978
+ * subscriber UUID (`centrali.subscribers` `id`), validated to exist in the
2979
+ * workspace. Omit or pass `null` to leave it unattached.
2980
+ */
2981
+ subscriberId?: string | null;
2940
2982
  }
2941
2983
  interface UpdateWebhookSubscriptionInput {
2942
2984
  name?: string;
2943
2985
  url?: string;
2944
- events?: RecordEventType[];
2986
+ /** Record lifecycle events and/or named business events. See `WebhookEventName`. */
2987
+ events?: WebhookEventName[];
2945
2988
  /**
2946
2989
  * Update the collection scope. Pass an empty array (`[]`) to clear the
2947
2990
  * restriction so the subscription receives events for all collections.
@@ -2954,6 +2997,11 @@ interface UpdateWebhookSubscriptionInput {
2954
2997
  * returned by `getPayloadVersions()`. Omit to leave the version unchanged.
2955
2998
  */
2956
2999
  payloadVersion?: string;
3000
+ /**
3001
+ * CEN-1487: re-attach (or detach, with `null`) the subscription's owning
3002
+ * subscriber. Omit to leave the attachment unchanged.
3003
+ */
3004
+ subscriberId?: string | null;
2957
3005
  }
2958
3006
  /**
2959
3007
  * Outbound payload versions a subscription can be pinned to. Returned by
@@ -2994,6 +3042,92 @@ interface WebhookCancelResponse {
2994
3042
  status: WebhookDeliveryStatus;
2995
3043
  lastError: string | null;
2996
3044
  }
3045
+ interface PublishWebhookEventInput {
3046
+ /**
3047
+ * Event name subscriptions match on (e.g. `invoice.paid`). Printable
3048
+ * characters only, no spaces, max 128 chars. Names beginning with `record.`
3049
+ * are reserved for platform record lifecycle events and are rejected.
3050
+ */
3051
+ event: string;
3052
+ /** Arbitrary JSON object delivered as the event's `data` body. Max 256 KB serialized. */
3053
+ data?: Record<string, unknown>;
3054
+ }
3055
+ /**
3056
+ * One delivery routed by a publish. `filtered` = the event matched the
3057
+ * subscription's events but was skipped (payload predicate, or a collection
3058
+ * scope the untargeted workspace-wide publish does not cross) and recorded as a
3059
+ * terminal row so the skip is visible in the delivery log.
3060
+ */
3061
+ interface WebhookPublishDelivery {
3062
+ id: string;
3063
+ subscriptionId: string;
3064
+ status: 'retrying' | 'filtered' | 'failed';
3065
+ }
3066
+ interface PublishWebhookEventResult {
3067
+ /** Chain ID stamped on every delivery this publish created. */
3068
+ correlationId: string;
3069
+ event: string;
3070
+ /**
3071
+ * One row per subscription the event was routed to. An empty array is a
3072
+ * success — nothing in the workspace subscribes to that event name.
3073
+ */
3074
+ deliveries: WebhookPublishDelivery[];
3075
+ }
3076
+
3077
+ interface Subscriber {
3078
+ id: string;
3079
+ workspaceSlug: string;
3080
+ /** The builder's own id for this customer. Unique within the workspace, not updatable. */
3081
+ externalId: string;
3082
+ name: string;
3083
+ metadata?: Record<string, unknown> | null;
3084
+ active: boolean;
3085
+ createdAt?: string;
3086
+ updatedAt?: string;
3087
+ }
3088
+ interface CreateSubscriberInput {
3089
+ externalId: string;
3090
+ name: string;
3091
+ metadata?: Record<string, unknown> | null;
3092
+ /** Defaults to `true` server-side when omitted. */
3093
+ active?: boolean;
3094
+ }
3095
+ /**
3096
+ * Editable fields on a subscriber. `externalId` is intentionally absent — it is
3097
+ * the stable lookup key and changing it would orphan `subscriptions`/`publish`
3098
+ * calls. At least one field must be provided.
3099
+ */
3100
+ interface UpdateSubscriberInput {
3101
+ name?: string;
3102
+ metadata?: Record<string, unknown> | null;
3103
+ active?: boolean;
3104
+ }
3105
+ interface PublishToSubscriberInput {
3106
+ /**
3107
+ * Event name subscriptions match on (e.g. `invoice.paid`). Printable
3108
+ * characters only, no spaces, max 128 chars. Names beginning with `record.`
3109
+ * are reserved for platform record lifecycle events and are rejected.
3110
+ */
3111
+ event: string;
3112
+ /** Arbitrary JSON object delivered as the event's `data` body. Max 256 KB serialized. */
3113
+ data?: Record<string, unknown>;
3114
+ }
3115
+ interface PublishToSubscriberResult {
3116
+ /** Chain ID stamped on every delivery this publish created. */
3117
+ correlationId: string;
3118
+ event: string;
3119
+ subscriber: {
3120
+ id: string;
3121
+ externalId: string;
3122
+ };
3123
+ /**
3124
+ * One row per subscription the event was routed to. An empty array is a
3125
+ * success — the subscriber has no subscription listening for that event.
3126
+ * Unlike the workspace-wide publish, this reaches the subscriber's
3127
+ * collection-scoped (`recordSlugs`) subscriptions too.
3128
+ */
3129
+ deliveries: WebhookPublishDelivery[];
3130
+ }
2997
3131
 
2998
3132
  /**
2999
3133
  * An allowed domain entry for compute function external calls.
@@ -5484,7 +5618,7 @@ declare class WebhookSubscriptionsManager {
5484
5618
  */
5485
5619
  cancel: (deliveryId: string) => Promise<ApiResponse<WebhookCancelResponse>>;
5486
5620
  };
5487
- constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
5621
+ constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>, config?: AxiosRequestConfig) => Promise<ApiResponse<T>>);
5488
5622
  /**
5489
5623
  * List all webhook subscriptions in the workspace.
5490
5624
  *
@@ -5542,6 +5676,128 @@ declare class WebhookSubscriptionsManager {
5542
5676
  * ```
5543
5677
  */
5544
5678
  getPayloadVersions(): Promise<ApiResponse<WebhookPayloadVersions>>;
5679
+ /**
5680
+ * Publish a named business event (e.g. `invoice.paid`) to every webhook
5681
+ * subscription in the workspace that listens for it. Delivery is
5682
+ * asynchronous. Requires the `publish` action on `webhook-subscriptions` —
5683
+ * distinct from `create` (which registers an endpoint).
5684
+ *
5685
+ * A published event carries no record context, so it matches only
5686
+ * subscriptions with **no** `recordSlugs` filter; a collection-scoped
5687
+ * subscription that also lists the event is recorded as a terminal
5688
+ * `filtered` delivery. To reach a collection-scoped subscription, publish
5689
+ * through `centrali.subscribers.publish()` instead.
5690
+ *
5691
+ * An empty `deliveries` array is a success — nothing subscribes to that
5692
+ * event name.
5693
+ *
5694
+ * Pass `options.idempotencyKey` (a stable UUID per logical publish) to make
5695
+ * a retry safe: the route's `withIdempotency` middleware returns the cached
5696
+ * result for a resend of the same event+payload instead of fanning it out
5697
+ * again. Retrying without one duplicates deliveries.
5698
+ *
5699
+ * @example
5700
+ * ```ts
5701
+ * const { data } = await centrali.webhookSubscriptions.publish(
5702
+ * { event: 'invoice.paid', data: { invoiceId: 'inv_1', amount: 4200 } },
5703
+ * { idempotencyKey: crypto.randomUUID() },
5704
+ * );
5705
+ * console.log('Correlation:', data.correlationId, 'fanned to', data.deliveries.length);
5706
+ * ```
5707
+ */
5708
+ publish(input: PublishWebhookEventInput, options?: {
5709
+ idempotencyKey?: string;
5710
+ }): Promise<ApiResponse<PublishWebhookEventResult>>;
5711
+ }
5712
+
5713
+ /**
5714
+ * SubscribersManager manages subscribers — the customer or tenant a set of
5715
+ * outbound webhook subscriptions belongs to (CEN-1487). Access via
5716
+ * `centrali.subscribers`.
5717
+ *
5718
+ * `externalId` is your own id for the customer; `get`/`update`/`delete` take
5719
+ * the internal subscriber UUID, while `subscriptions` and `publish` are keyed
5720
+ * by `externalId`.
5721
+ *
5722
+ * Usage:
5723
+ * ```ts
5724
+ * const sub = await centrali.subscribers.create({
5725
+ * externalId: 'acme_123',
5726
+ * name: 'Acme Corp',
5727
+ * });
5728
+ *
5729
+ * // Attach a webhook subscription to it
5730
+ * await centrali.webhookSubscriptions.create({
5731
+ * name: 'Acme production',
5732
+ * url: 'https://acme.example.com/hooks/centrali',
5733
+ * events: [RecordEvents.CREATED],
5734
+ * subscriberId: sub.data.id,
5735
+ * });
5736
+ *
5737
+ * // Everything Acme is subscribed to
5738
+ * const subs = await centrali.subscribers.subscriptions('acme_123');
5739
+ *
5740
+ * // Publish a business event to just Acme
5741
+ * await centrali.subscribers.publish('acme_123', {
5742
+ * event: 'invoice.paid',
5743
+ * data: { invoiceId: 'inv_1', amount: 4200 },
5744
+ * });
5745
+ * ```
5746
+ */
5747
+ declare class SubscribersManager {
5748
+ private requestFn;
5749
+ private workspaceId;
5750
+ constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
5751
+ /**
5752
+ * List every subscriber in the workspace.
5753
+ *
5754
+ * @example
5755
+ * ```ts
5756
+ * const result = await centrali.subscribers.list();
5757
+ * result.data.forEach(s => console.log(s.externalId, s.name));
5758
+ * ```
5759
+ */
5760
+ list(): Promise<ApiResponse<Subscriber[]>>;
5761
+ /**
5762
+ * Register a subscriber. `externalId` must be unique within the workspace —
5763
+ * a duplicate is rejected with a 400.
5764
+ */
5765
+ create(input: CreateSubscriberInput): Promise<ApiResponse<Subscriber>>;
5766
+ /**
5767
+ * Get a subscriber by its internal UUID.
5768
+ * @param subscriberId - The subscriber UUID (not the externalId).
5769
+ */
5770
+ get(subscriberId: string): Promise<ApiResponse<Subscriber>>;
5771
+ /**
5772
+ * Update editable fields on a subscriber. `externalId` is not updatable.
5773
+ * @param subscriberId - The subscriber UUID (not the externalId).
5774
+ */
5775
+ update(subscriberId: string, patch: UpdateSubscriberInput): Promise<ApiResponse<Subscriber>>;
5776
+ /**
5777
+ * Delete a subscriber. Subscriptions it owned are **not** deleted — the
5778
+ * `subscriberId` FK is `ON DELETE SET NULL`, so they revert to unattached.
5779
+ * @param subscriberId - The subscriber UUID (not the externalId).
5780
+ */
5781
+ delete(subscriberId: string): Promise<ApiResponse<void>>;
5782
+ /**
5783
+ * List the webhook subscriptions attached to a subscriber, keyed by your
5784
+ * own `externalId`. Returns full subscription rows — the signing `secret`
5785
+ * is included, so the caller needs `webhook-subscriptions:retrieve` on top
5786
+ * of `subscribers:retrieve`.
5787
+ *
5788
+ * @param externalId - The builder's own id for the subscriber.
5789
+ */
5790
+ subscriptions(externalId: string): Promise<ApiResponse<WebhookSubscription[]>>;
5791
+ /**
5792
+ * Publish a named business event to every webhook subscription this
5793
+ * subscriber owns that listens for it — the scoped counterpart to
5794
+ * `centrali.webhookSubscriptions.publish()`. Because the target is
5795
+ * explicit, the event reaches the subscriber's collection-scoped
5796
+ * (`recordSlugs`) subscriptions too. Requires `webhook-subscriptions:publish`.
5797
+ *
5798
+ * @param externalId - The builder's own id for the subscriber.
5799
+ */
5800
+ publish(externalId: string, input: PublishToSubscriberInput): Promise<ApiResponse<PublishToSubscriberResult>>;
5545
5801
  }
5546
5802
 
5547
5803
  /**
@@ -5751,6 +6007,7 @@ declare class CentraliSDK {
5751
6007
  private _orchestrationRuns;
5752
6008
  private _files;
5753
6009
  private _webhookSubscriptions;
6010
+ private _subscribers;
5754
6011
  private _query;
5755
6012
  private _embed;
5756
6013
  private isRefreshingToken;
@@ -6212,6 +6469,27 @@ declare class CentraliSDK {
6212
6469
  * ```
6213
6470
  */
6214
6471
  get webhookSubscriptions(): WebhookSubscriptionsManager;
6472
+ /**
6473
+ * Subscribers namespace (CEN-1487) — the customer or tenant a set of
6474
+ * outbound webhook subscriptions belongs to. Create a subscriber, attach
6475
+ * subscriptions to it via `webhookSubscriptions.create({ subscriberId })`,
6476
+ * list everything it is subscribed to, and publish business events scoped
6477
+ * to just that subscriber.
6478
+ *
6479
+ * Usage:
6480
+ * ```ts
6481
+ * const acme = await centrali.subscribers.create({
6482
+ * externalId: 'acme_123',
6483
+ * name: 'Acme Corp',
6484
+ * });
6485
+ * const subs = await centrali.subscribers.subscriptions('acme_123');
6486
+ * await centrali.subscribers.publish('acme_123', {
6487
+ * event: 'invoice.paid',
6488
+ * data: { invoiceId: 'inv_1' },
6489
+ * });
6490
+ * ```
6491
+ */
6492
+ get subscribers(): SubscribersManager;
6215
6493
  /**
6216
6494
  * Server-side helpers for the white-label Event Log embed
6217
6495
  * (CEN-1301 — see `embed.centrali.io/v1/event-log`). Use to mint
@@ -6582,4 +6860,4 @@ declare class CentraliSDK {
6582
6860
  checkAuthorization(options: CheckAuthorizationOptions): Promise<ApiResponse<AuthorizationResult>>;
6583
6861
  }
6584
6862
 
6585
- export { type AcceptSuggestionResult, type AddAllowedDomainOptions, type AlertComparisonOp, type AlertCondition, type AlertDefinition, AlertDefinitionsManager, type AlertRecipient, type AllowedDomain, type AllowedDomainsListResponse, AllowedDomainsManager, type AnomalyAnalysisResult, type AnomalyDetectionData, type AnomalyEventType, type AnomalyInsight, type AnomalyInsightData, AnomalyInsightsManager, type ApiResponse, type ArrayPropertyDefinition, AuditLogManager, type AuthorizationResult, type BasePropertyDefinition, type BatchScanResult, type BatchScanStatus, type BooleanPropertyDefinition, type BulkOperationResult, CANONICAL_OPERATORS, type CanonicalOperator, CentraliError, CentraliSDK, type CentraliSDKOptions, type CheckAuthorizationOptions, CollectionsManager, type ComputeEventType, type ComputeFunction, ComputeFunctionsManager, type ComputeJobStatus, type ComputeJobStatusResponse, type ConditionOperator, type CreateAlertDefinitionInput, type CreateComputeFunctionInput, type CreateOrchestrationInput, type CreateSmartQueryInput, type CreateStructureInput, type CreateTriggerInput, type CreateWebhookSubscriptionInput, type DateTimePropertyDefinition, type DateWindowOption, type DeleteRecordOptions, type EmbedCapability, EmbedManager, type EndpointResponse, EventLogEmbed, type EventLogSourceTable, type EventLogSubscribeOptions, type ExecuteSavedQueryValues, type ExecuteSmartQueryOptions, type ExpandOptions, type FieldCondition, type FieldConditionMap, type FileMetadata, FilesManager, type FilterOperators, type FilterValue, type FunctionMemoryUsage, type FunctionRun, type FunctionRunError, type FunctionRunExecutionSource, type FunctionRunStatus, FunctionRunsManager, type FunctionTrigger, type GetRecordOptions, type IncludeClause, type InsightSeverity, type InsightStatus, type InsightType, type InsightsSummary, type InvokeEndpointOptions, type InvokeTriggerOptions, type IssueEmbedTokenInput, type IssueEmbedTokenResult, JOINS_MAX_LENGTH, type JoinClause, type JoinType, type LegacyTranslateOptions, type LegacyTranslateResult, type LegacyTranslateWarning, type ListAlertDefinitionsOptions, type ListAllTriggersOptions, type ListCollectionsOptions, type ListComputeFunctionsOptions, type ListFunctionRunsOptions, type ListInsightsOptions, type ListOrchestrationRunsOptions, type ListOrchestrationsOptions, type ListSmartQueryOptions, type ListStructuresOptions, type ListValidationSuggestionsOptions, type ListWebhookDeliveriesOptions, type NumberPropertyDefinition, OPERATOR_METADATA, type ObjectPropertyDefinition, type OperatorMeta, type OperatorTypeApplicability, type OperatorValueShape, type Orchestration, type OrchestrationCaseEvaluation, type OrchestrationCondition, type OrchestrationConditionEvaluation, type OrchestrationDecisionCase, type OrchestrationDecisionResult, type OrchestrationDelayConfig, type OrchestrationEventType, type OrchestrationFailureReason, type OrchestrationOnFailure, type OrchestrationOnSuccess, type OrchestrationRetryConfig, type OrchestrationRun, type OrchestrationRunStatus, type OrchestrationRunStep, OrchestrationRunsManager, type OrchestrationScheduleType, type OrchestrationStatus, type OrchestrationStep, type OrchestrationStepError, type OrchestrationStepStatus, type OrchestrationStepType, type OrchestrationTrigger, type OrchestrationTriggerMetadata, type OrchestrationTriggerType, OrchestrationsManager, type PageClause, type PaginatedResponse, type ParsedUrlQuery, type PropertyDefinition, type PropertyType, type QueryDefinition, type QueryError, type QueryErrorCode, type QueryExecutionMode, type QueryHttpError, type QueryHttpErrorCode, QueryManager, type QueryRecordOptions, type QueryResult, type QueryResultMeta, type QueryValidateOptions, type QueryVariableDefinition, RECORDS_PAGE_DEFAULT_LIMIT, RECORDS_PAGE_MAX_LIMIT, type RealtimeAnomalyDetectionEvent, type RealtimeAnomalyInsightEvent, type RealtimeCloseEvent, type RealtimeError, type RealtimeEvent, type RealtimeEventLogEntry, type RealtimeEventType, type RealtimeFunctionRunEvent, RealtimeManager, type RealtimeOrchestrationRunEvent, type RealtimeRecordEvent, type RealtimeSubscribeOptions, type RealtimeSubscription, type RealtimeValidationBatchEvent, type RealtimeValidationSuggestionEvent, type RecordEventType, RecordEvents, type RecordTtlOptions, RecordsManager, type ReferencePropertyDefinition, type ResourceCategory, type RevokeEmbedSessionInput, type RevokeEmbedSessionResult, type SavedQueryDefinition, type SavedQueryScalarBinding, type ScalarValue, type SchemaDiscoveryMode, type SelectClause, SmartQueriesManager, type SmartQuery, type SmartQueryDefinition, type SmartQueryExecuteResult, type SmartQueryFieldCondition, type SmartQueryJoin, type SmartQuerySort, type SmartQueryWhereClause, type SortClause, type StepEncryptedParam, type StringPropertyDefinition, type Structure, StructuresManager, type TestComputeFunctionInput, type TestComputeFunctionResult, type TestSmartQueryInput, type TextSearchClause, type TriggerExecutionType, type TriggerHealthMetrics, type TriggerHealthStatus, type TriggerInvokeResponse, type TriggerOrchestrationRunOptions, type TriggerScanOptions, type TriggerWithHealth, TriggersManager, type UpdateAlertDefinitionInput, type UpdateComputeFunctionInput, type UpdateOrchestrationInput, type UpdateSmartQueryInput, type UpdateStructureInput, type UpdateTriggerInput, type UpdateWebhookSubscriptionInput, type UrlParserOptions, type ValidateStructureInput, type ValidationBatchData, type ValidationEventType, type ValidationIssueType, ValidationManager, type ValidationResult, type ValidationSuggestion, type ValidationSuggestionData, type ValidationSuggestionStatus, type ValidationSummary, type VariableType, type WaitForScanOptions, type WebhookCancelResponse, type WebhookDeliveriesListMeta, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookDeliverySummary, type WebhookPayloadVersions, type WebhookReplayResponse, type WebhookSubscription, WebhookSubscriptionsManager, type WhereExpression, fetchClientToken, getAlertDefinitionByIdApiPath, getAlertDefinitionsApiPath, getAllowedDomainsApiPath, getAnomalyAnalysisTriggerApiPath, getAnomalyInsightAcknowledgeApiPath, getAnomalyInsightDismissApiPath, getAnomalyInsightsApiPath, getAnomalyInsightsBulkAcknowledgeApiPath, getAnomalyInsightsSummaryApiPath, getApiUrl, getAuthUrl, getCollectionBySlugApiPath, getCollectionInsightsApiPath, getCollectionValidateApiPath, getCollectionsApiPath, getComputeFunctionTestApiPath, getComputeFunctionsApiPath, getComputeJobStatusApiPath, getEndpointApiPath, getFileUploadApiPath, getFilesCanonicalApiPath, getFunctionRunsApiPath, getFunctionRunsByFunctionApiPath, getFunctionRunsByTriggerApiPath, getFunctionTriggerExecuteApiPath, getFunctionTriggerPauseApiPath, getFunctionTriggerResumeApiPath, getFunctionTriggersApiPath, getOrchestrationRunStepsApiPath, getOrchestrationRunsApiPath, getOrchestrationRunsCanonicalApiPath, getOrchestrationsApiPath, getRealtimeUrl, getRecordApiPath, getSavedQueryCanonicalByIdPath, getSavedQueryCanonicalCollectionPath, getSavedQueryCanonicalExecutePath, getSavedQueryCanonicalTestPath, getSmartQueriesApiPath, getSmartQueriesStructureApiPath, getSmartQueryByNameApiPath, getSmartQueryExecuteApiPath, getSmartQueryTestApiPath, getStructureBySlugApiPath, getStructureInsightsApiPath, getStructureValidateApiPath, getStructuresApiPath, getValidationBulkAcceptApiPath, getValidationBulkRejectApiPath, getValidationPendingCountApiPath, getValidationRecordSuggestionsApiPath, getValidationScanApiPath, getValidationSuggestionAcceptApiPath, getValidationSuggestionRejectApiPath, getValidationSuggestionsApiPath, getValidationSummaryApiPath, getWebhookDeliveryCancelApiPath, getWebhookDeliveryRetryApiPath, getWebhookPayloadVersionsApiPath, getWebhookSubscriptionDeliveriesApiPath, getWebhookSubscriptionRotateSecretApiPath, getWebhookSubscriptionsApiPath, isCentraliError, operatorsForFieldType };
6863
+ export { type AcceptSuggestionResult, type AddAllowedDomainOptions, type AlertComparisonOp, type AlertCondition, type AlertDefinition, AlertDefinitionsManager, type AlertRecipient, type AllowedDomain, type AllowedDomainsListResponse, AllowedDomainsManager, type AnomalyAnalysisResult, type AnomalyDetectionData, type AnomalyEventType, type AnomalyInsight, type AnomalyInsightData, AnomalyInsightsManager, type ApiResponse, type ArrayPropertyDefinition, AuditLogManager, type AuthorizationResult, type BasePropertyDefinition, type BatchScanResult, type BatchScanStatus, type BooleanPropertyDefinition, type BulkOperationResult, CANONICAL_OPERATORS, type CanonicalOperator, CentraliError, CentraliSDK, type CentraliSDKOptions, type CheckAuthorizationOptions, CollectionsManager, type ComputeEventType, type ComputeFunction, ComputeFunctionsManager, type ComputeJobStatus, type ComputeJobStatusResponse, type ConditionOperator, type CreateAlertDefinitionInput, type CreateComputeFunctionInput, type CreateOrchestrationInput, type CreateSmartQueryInput, type CreateStructureInput, type CreateSubscriberInput, type CreateTriggerInput, type CreateWebhookSubscriptionInput, type DateTimePropertyDefinition, type DateWindowOption, type DeleteRecordOptions, type EmbedCapability, EmbedManager, type EndpointResponse, EventLogEmbed, type EventLogSourceTable, type EventLogSubscribeOptions, type ExecuteSavedQueryValues, type ExecuteSmartQueryOptions, type ExpandOptions, type FieldCondition, type FieldConditionMap, type FileMetadata, FilesManager, type FilterOperators, type FilterValue, type FunctionMemoryUsage, type FunctionRun, type FunctionRunError, type FunctionRunExecutionSource, type FunctionRunStatus, FunctionRunsManager, type FunctionTrigger, type GetRecordOptions, type IncludeClause, type InsightSeverity, type InsightStatus, type InsightType, type InsightsSummary, type InvokeEndpointOptions, type InvokeTriggerOptions, type IssueEmbedTokenInput, type IssueEmbedTokenResult, JOINS_MAX_LENGTH, type JoinClause, type JoinType, type LegacyTranslateOptions, type LegacyTranslateResult, type LegacyTranslateWarning, type ListAlertDefinitionsOptions, type ListAllTriggersOptions, type ListCollectionsOptions, type ListComputeFunctionsOptions, type ListFunctionRunsOptions, type ListInsightsOptions, type ListOrchestrationRunsOptions, type ListOrchestrationsOptions, type ListSmartQueryOptions, type ListStructuresOptions, type ListValidationSuggestionsOptions, type ListWebhookDeliveriesOptions, type NumberPropertyDefinition, OPERATOR_METADATA, type ObjectPropertyDefinition, type OperatorMeta, type OperatorTypeApplicability, type OperatorValueShape, type Orchestration, type OrchestrationCaseEvaluation, type OrchestrationCondition, type OrchestrationConditionEvaluation, type OrchestrationDecisionCase, type OrchestrationDecisionResult, type OrchestrationDelayConfig, type OrchestrationEventType, type OrchestrationFailureReason, type OrchestrationOnFailure, type OrchestrationOnSuccess, type OrchestrationRetryConfig, type OrchestrationRun, type OrchestrationRunStatus, type OrchestrationRunStep, OrchestrationRunsManager, type OrchestrationScheduleType, type OrchestrationStatus, type OrchestrationStep, type OrchestrationStepError, type OrchestrationStepStatus, type OrchestrationStepType, type OrchestrationTrigger, type OrchestrationTriggerMetadata, type OrchestrationTriggerType, OrchestrationsManager, type PageClause, type PaginatedResponse, type ParsedUrlQuery, type PropertyDefinition, type PropertyType, type PublishToSubscriberInput, type PublishToSubscriberResult, type PublishWebhookEventInput, type PublishWebhookEventResult, type QueryDefinition, type QueryError, type QueryErrorCode, type QueryExecutionMode, type QueryHttpError, type QueryHttpErrorCode, QueryManager, type QueryRecordOptions, type QueryResult, type QueryResultMeta, type QueryValidateOptions, type QueryVariableDefinition, RECORDS_PAGE_DEFAULT_LIMIT, RECORDS_PAGE_MAX_LIMIT, type RealtimeAnomalyDetectionEvent, type RealtimeAnomalyInsightEvent, type RealtimeCloseEvent, type RealtimeError, type RealtimeEvent, type RealtimeEventLogEntry, type RealtimeEventType, type RealtimeFunctionRunEvent, RealtimeManager, type RealtimeOrchestrationRunEvent, type RealtimeRecordEvent, type RealtimeSubscribeOptions, type RealtimeSubscription, type RealtimeValidationBatchEvent, type RealtimeValidationSuggestionEvent, type RecordEventType, RecordEvents, type RecordTtlOptions, RecordsManager, type ReferencePropertyDefinition, type ResourceCategory, type RevokeEmbedSessionInput, type RevokeEmbedSessionResult, type SavedQueryDefinition, type SavedQueryScalarBinding, type ScalarValue, type SchemaDiscoveryMode, type SelectClause, SmartQueriesManager, type SmartQuery, type SmartQueryDefinition, type SmartQueryExecuteResult, type SmartQueryFieldCondition, type SmartQueryJoin, type SmartQuerySort, type SmartQueryWhereClause, type SortClause, type StepEncryptedParam, type StringPropertyDefinition, type Structure, StructuresManager, type Subscriber, SubscribersManager, type TestComputeFunctionInput, type TestComputeFunctionResult, type TestSmartQueryInput, type TextSearchClause, type TriggerExecutionType, type TriggerHealthMetrics, type TriggerHealthStatus, type TriggerInvokeResponse, type TriggerOrchestrationRunOptions, type TriggerScanOptions, type TriggerWithHealth, TriggersManager, type UpdateAlertDefinitionInput, type UpdateComputeFunctionInput, type UpdateOrchestrationInput, type UpdateSmartQueryInput, type UpdateStructureInput, type UpdateSubscriberInput, type UpdateTriggerInput, type UpdateWebhookSubscriptionInput, type UrlParserOptions, type ValidateStructureInput, type ValidationBatchData, type ValidationEventType, type ValidationIssueType, ValidationManager, type ValidationResult, type ValidationSuggestion, type ValidationSuggestionData, type ValidationSuggestionStatus, type ValidationSummary, type VariableType, type WaitForScanOptions, type WebhookCancelResponse, type WebhookDeliveriesListMeta, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookDeliverySummary, type WebhookEventName, type WebhookPayloadVersions, type WebhookPublishDelivery, type WebhookReplayResponse, type WebhookSubscription, WebhookSubscriptionsManager, type WhereExpression, fetchClientToken, getAlertDefinitionByIdApiPath, getAlertDefinitionsApiPath, getAllowedDomainsApiPath, getAnomalyAnalysisTriggerApiPath, getAnomalyInsightAcknowledgeApiPath, getAnomalyInsightDismissApiPath, getAnomalyInsightsApiPath, getAnomalyInsightsBulkAcknowledgeApiPath, getAnomalyInsightsSummaryApiPath, getApiUrl, getAuthUrl, getCollectionBySlugApiPath, getCollectionInsightsApiPath, getCollectionValidateApiPath, getCollectionsApiPath, getComputeFunctionTestApiPath, getComputeFunctionsApiPath, getComputeJobStatusApiPath, getEndpointApiPath, getFileUploadApiPath, getFilesCanonicalApiPath, getFunctionRunsApiPath, getFunctionRunsByFunctionApiPath, getFunctionRunsByTriggerApiPath, getFunctionTriggerExecuteApiPath, getFunctionTriggerPauseApiPath, getFunctionTriggerResumeApiPath, getFunctionTriggersApiPath, getOrchestrationRunStepsApiPath, getOrchestrationRunsApiPath, getOrchestrationRunsCanonicalApiPath, getOrchestrationsApiPath, getRealtimeUrl, getRecordApiPath, getSavedQueryCanonicalByIdPath, getSavedQueryCanonicalCollectionPath, getSavedQueryCanonicalExecutePath, getSavedQueryCanonicalTestPath, getSmartQueriesApiPath, getSmartQueriesStructureApiPath, getSmartQueryByNameApiPath, getSmartQueryExecuteApiPath, getSmartQueryTestApiPath, getStructureBySlugApiPath, getStructureInsightsApiPath, getStructureValidateApiPath, getStructuresApiPath, getSubscriberPublishApiPath, getSubscriberSubscriptionsApiPath, getSubscribersApiPath, getValidationBulkAcceptApiPath, getValidationBulkRejectApiPath, getValidationPendingCountApiPath, getValidationRecordSuggestionsApiPath, getValidationScanApiPath, getValidationSuggestionAcceptApiPath, getValidationSuggestionRejectApiPath, getValidationSuggestionsApiPath, getValidationSummaryApiPath, getWebhookDeliveryCancelApiPath, getWebhookDeliveryRetryApiPath, getWebhookPayloadVersionsApiPath, getWebhookPublishApiPath, getWebhookSubscriptionDeliveriesApiPath, getWebhookSubscriptionRotateSecretApiPath, getWebhookSubscriptionsApiPath, isCentraliError, operatorsForFieldType };
package/dist/index.js CHANGED
@@ -92,6 +92,7 @@ __export(index_exports, {
92
92
  RecordsManager: () => RecordsManager,
93
93
  SmartQueriesManager: () => SmartQueriesManager,
94
94
  StructuresManager: () => StructuresManager,
95
+ SubscribersManager: () => SubscribersManager,
95
96
  TriggersManager: () => TriggersManager,
96
97
  ValidationManager: () => ValidationManager,
97
98
  WebhookSubscriptionsManager: () => WebhookSubscriptionsManager,
@@ -143,6 +144,9 @@ __export(index_exports, {
143
144
  getStructureInsightsApiPath: () => getStructureInsightsApiPath,
144
145
  getStructureValidateApiPath: () => getStructureValidateApiPath,
145
146
  getStructuresApiPath: () => getStructuresApiPath,
147
+ getSubscriberPublishApiPath: () => getSubscriberPublishApiPath,
148
+ getSubscriberSubscriptionsApiPath: () => getSubscriberSubscriptionsApiPath,
149
+ getSubscribersApiPath: () => getSubscribersApiPath,
146
150
  getValidationBulkAcceptApiPath: () => getValidationBulkAcceptApiPath,
147
151
  getValidationBulkRejectApiPath: () => getValidationBulkRejectApiPath,
148
152
  getValidationPendingCountApiPath: () => getValidationPendingCountApiPath,
@@ -155,6 +159,7 @@ __export(index_exports, {
155
159
  getWebhookDeliveryCancelApiPath: () => getWebhookDeliveryCancelApiPath,
156
160
  getWebhookDeliveryRetryApiPath: () => getWebhookDeliveryRetryApiPath,
157
161
  getWebhookPayloadVersionsApiPath: () => getWebhookPayloadVersionsApiPath,
162
+ getWebhookPublishApiPath: () => getWebhookPublishApiPath,
158
163
  getWebhookSubscriptionDeliveriesApiPath: () => getWebhookSubscriptionDeliveriesApiPath,
159
164
  getWebhookSubscriptionRotateSecretApiPath: () => getWebhookSubscriptionRotateSecretApiPath,
160
165
  getWebhookSubscriptionsApiPath: () => getWebhookSubscriptionsApiPath,
@@ -409,6 +414,19 @@ function getWebhookDeliveryRetryApiPath(workspaceId, deliveryId) {
409
414
  function getWebhookDeliveryCancelApiPath(workspaceId, deliveryId) {
410
415
  return `data/workspace/${workspaceId}/api/v1/webhook-subscriptions/deliveries/${deliveryId}/cancel`;
411
416
  }
417
+ function getWebhookPublishApiPath(workspaceId) {
418
+ return `data/workspace/${workspaceId}/api/v1/webhook-subscriptions/publish`;
419
+ }
420
+ function getSubscribersApiPath(workspaceId, subscriberId) {
421
+ const basePath = `data/workspace/${workspaceId}/api/v1/subscribers`;
422
+ return subscriberId ? `${basePath}/${subscriberId}` : basePath;
423
+ }
424
+ function getSubscriberSubscriptionsApiPath(workspaceId, externalId) {
425
+ return `data/workspace/${workspaceId}/api/v1/subscribers/${encodeURIComponent(externalId)}/subscriptions`;
426
+ }
427
+ function getSubscriberPublishApiPath(workspaceId, externalId) {
428
+ return `data/workspace/${workspaceId}/api/v1/subscribers/${encodeURIComponent(externalId)}/publish`;
429
+ }
412
430
 
413
431
  // src/internal/auth.ts
414
432
  var import_axios2 = __toESM(require("axios"));
@@ -8192,6 +8210,123 @@ var WebhookSubscriptionsManager = class {
8192
8210
  const path = getWebhookPayloadVersionsApiPath(this.workspaceId);
8193
8211
  return this.requestFn("GET", path);
8194
8212
  }
8213
+ /**
8214
+ * Publish a named business event (e.g. `invoice.paid`) to every webhook
8215
+ * subscription in the workspace that listens for it. Delivery is
8216
+ * asynchronous. Requires the `publish` action on `webhook-subscriptions` —
8217
+ * distinct from `create` (which registers an endpoint).
8218
+ *
8219
+ * A published event carries no record context, so it matches only
8220
+ * subscriptions with **no** `recordSlugs` filter; a collection-scoped
8221
+ * subscription that also lists the event is recorded as a terminal
8222
+ * `filtered` delivery. To reach a collection-scoped subscription, publish
8223
+ * through `centrali.subscribers.publish()` instead.
8224
+ *
8225
+ * An empty `deliveries` array is a success — nothing subscribes to that
8226
+ * event name.
8227
+ *
8228
+ * Pass `options.idempotencyKey` (a stable UUID per logical publish) to make
8229
+ * a retry safe: the route's `withIdempotency` middleware returns the cached
8230
+ * result for a resend of the same event+payload instead of fanning it out
8231
+ * again. Retrying without one duplicates deliveries.
8232
+ *
8233
+ * @example
8234
+ * ```ts
8235
+ * const { data } = await centrali.webhookSubscriptions.publish(
8236
+ * { event: 'invoice.paid', data: { invoiceId: 'inv_1', amount: 4200 } },
8237
+ * { idempotencyKey: crypto.randomUUID() },
8238
+ * );
8239
+ * console.log('Correlation:', data.correlationId, 'fanned to', data.deliveries.length);
8240
+ * ```
8241
+ */
8242
+ publish(input, options) {
8243
+ const path = getWebhookPublishApiPath(this.workspaceId);
8244
+ if (options == null ? void 0 : options.idempotencyKey) {
8245
+ return this.requestFn("POST", path, input, void 0, {
8246
+ headers: { "Idempotency-Key": options.idempotencyKey }
8247
+ });
8248
+ }
8249
+ return this.requestFn("POST", path, input);
8250
+ }
8251
+ };
8252
+
8253
+ // src/managers/subscribers.ts
8254
+ var SubscribersManager = class {
8255
+ constructor(workspaceId, requestFn) {
8256
+ this.workspaceId = workspaceId;
8257
+ this.requestFn = requestFn;
8258
+ }
8259
+ /**
8260
+ * List every subscriber in the workspace.
8261
+ *
8262
+ * @example
8263
+ * ```ts
8264
+ * const result = await centrali.subscribers.list();
8265
+ * result.data.forEach(s => console.log(s.externalId, s.name));
8266
+ * ```
8267
+ */
8268
+ list() {
8269
+ const path = getSubscribersApiPath(this.workspaceId);
8270
+ return this.requestFn("GET", path);
8271
+ }
8272
+ /**
8273
+ * Register a subscriber. `externalId` must be unique within the workspace —
8274
+ * a duplicate is rejected with a 400.
8275
+ */
8276
+ create(input) {
8277
+ const path = getSubscribersApiPath(this.workspaceId);
8278
+ return this.requestFn("POST", path, input);
8279
+ }
8280
+ /**
8281
+ * Get a subscriber by its internal UUID.
8282
+ * @param subscriberId - The subscriber UUID (not the externalId).
8283
+ */
8284
+ get(subscriberId) {
8285
+ const path = getSubscribersApiPath(this.workspaceId, subscriberId);
8286
+ return this.requestFn("GET", path);
8287
+ }
8288
+ /**
8289
+ * Update editable fields on a subscriber. `externalId` is not updatable.
8290
+ * @param subscriberId - The subscriber UUID (not the externalId).
8291
+ */
8292
+ update(subscriberId, patch) {
8293
+ const path = getSubscribersApiPath(this.workspaceId, subscriberId);
8294
+ return this.requestFn("PATCH", path, patch);
8295
+ }
8296
+ /**
8297
+ * Delete a subscriber. Subscriptions it owned are **not** deleted — the
8298
+ * `subscriberId` FK is `ON DELETE SET NULL`, so they revert to unattached.
8299
+ * @param subscriberId - The subscriber UUID (not the externalId).
8300
+ */
8301
+ delete(subscriberId) {
8302
+ const path = getSubscribersApiPath(this.workspaceId, subscriberId);
8303
+ return this.requestFn("DELETE", path);
8304
+ }
8305
+ /**
8306
+ * List the webhook subscriptions attached to a subscriber, keyed by your
8307
+ * own `externalId`. Returns full subscription rows — the signing `secret`
8308
+ * is included, so the caller needs `webhook-subscriptions:retrieve` on top
8309
+ * of `subscribers:retrieve`.
8310
+ *
8311
+ * @param externalId - The builder's own id for the subscriber.
8312
+ */
8313
+ subscriptions(externalId) {
8314
+ const path = getSubscriberSubscriptionsApiPath(this.workspaceId, externalId);
8315
+ return this.requestFn("GET", path);
8316
+ }
8317
+ /**
8318
+ * Publish a named business event to every webhook subscription this
8319
+ * subscriber owns that listens for it — the scoped counterpart to
8320
+ * `centrali.webhookSubscriptions.publish()`. Because the target is
8321
+ * explicit, the event reaches the subscriber's collection-scoped
8322
+ * (`recordSlugs`) subscriptions too. Requires `webhook-subscriptions:publish`.
8323
+ *
8324
+ * @param externalId - The builder's own id for the subscriber.
8325
+ */
8326
+ publish(externalId, input) {
8327
+ const path = getSubscriberPublishApiPath(this.workspaceId, externalId);
8328
+ return this.requestFn("POST", path, input);
8329
+ }
8195
8330
  };
8196
8331
 
8197
8332
  // src/managers/embed.ts
@@ -8328,6 +8463,7 @@ var CentraliSDK = class {
8328
8463
  this._orchestrationRuns = null;
8329
8464
  this._files = null;
8330
8465
  this._webhookSubscriptions = null;
8466
+ this._subscribers = null;
8331
8467
  this._query = null;
8332
8468
  this._embed = null;
8333
8469
  this.isRefreshingToken = false;
@@ -9059,6 +9195,35 @@ var CentraliSDK = class {
9059
9195
  }
9060
9196
  return this._webhookSubscriptions;
9061
9197
  }
9198
+ /**
9199
+ * Subscribers namespace (CEN-1487) — the customer or tenant a set of
9200
+ * outbound webhook subscriptions belongs to. Create a subscriber, attach
9201
+ * subscriptions to it via `webhookSubscriptions.create({ subscriberId })`,
9202
+ * list everything it is subscribed to, and publish business events scoped
9203
+ * to just that subscriber.
9204
+ *
9205
+ * Usage:
9206
+ * ```ts
9207
+ * const acme = await centrali.subscribers.create({
9208
+ * externalId: 'acme_123',
9209
+ * name: 'Acme Corp',
9210
+ * });
9211
+ * const subs = await centrali.subscribers.subscriptions('acme_123');
9212
+ * await centrali.subscribers.publish('acme_123', {
9213
+ * event: 'invoice.paid',
9214
+ * data: { invoiceId: 'inv_1' },
9215
+ * });
9216
+ * ```
9217
+ */
9218
+ get subscribers() {
9219
+ if (!this._subscribers) {
9220
+ this._subscribers = new SubscribersManager(
9221
+ this.options.workspaceId,
9222
+ this.request.bind(this)
9223
+ );
9224
+ }
9225
+ return this._subscribers;
9226
+ }
9062
9227
  /**
9063
9228
  * Server-side helpers for the white-label Event Log embed
9064
9229
  * (CEN-1301 — see `embed.centrali.io/v1/event-log`). Use to mint
@@ -9564,6 +9729,7 @@ var CentraliSDK = class {
9564
9729
  RecordsManager,
9565
9730
  SmartQueriesManager,
9566
9731
  StructuresManager,
9732
+ SubscribersManager,
9567
9733
  TriggersManager,
9568
9734
  ValidationManager,
9569
9735
  WebhookSubscriptionsManager,
@@ -9615,6 +9781,9 @@ var CentraliSDK = class {
9615
9781
  getStructureInsightsApiPath,
9616
9782
  getStructureValidateApiPath,
9617
9783
  getStructuresApiPath,
9784
+ getSubscriberPublishApiPath,
9785
+ getSubscriberSubscriptionsApiPath,
9786
+ getSubscribersApiPath,
9618
9787
  getValidationBulkAcceptApiPath,
9619
9788
  getValidationBulkRejectApiPath,
9620
9789
  getValidationPendingCountApiPath,
@@ -9627,6 +9796,7 @@ var CentraliSDK = class {
9627
9796
  getWebhookDeliveryCancelApiPath,
9628
9797
  getWebhookDeliveryRetryApiPath,
9629
9798
  getWebhookPayloadVersionsApiPath,
9799
+ getWebhookPublishApiPath,
9630
9800
  getWebhookSubscriptionDeliveriesApiPath,
9631
9801
  getWebhookSubscriptionRotateSecretApiPath,
9632
9802
  getWebhookSubscriptionsApiPath,
package/index.ts CHANGED
@@ -31,6 +31,7 @@ export * from './src/types/insights';
31
31
  export * from './src/types/alertDefinitions';
32
32
  export * from './src/types/validation';
33
33
  export * from './src/types/webhooks';
34
+ export * from './src/types/subscribers';
34
35
  export * from './src/types/allowedDomains';
35
36
  export * from './src/types/embed';
36
37
 
@@ -54,6 +55,7 @@ export { FunctionRunsManager } from './src/managers/functionRuns';
54
55
  export { OrchestrationRunsManager } from './src/managers/orchestrationRuns';
55
56
  export { FilesManager, FileMetadata } from './src/managers/files';
56
57
  export { WebhookSubscriptionsManager } from './src/managers/webhookSubscriptions';
58
+ export { SubscribersManager } from './src/managers/subscribers';
57
59
  export { EmbedManager, EventLogEmbed } from './src/managers/embed';
58
60
  export {
59
61
  QueryManager,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-sdk",
3
- "version": "9.0.2",
3
+ "version": "9.1.1",
4
4
  "description": "Centrali Node SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/client.ts CHANGED
@@ -34,6 +34,7 @@ import { FunctionRunsManager } from './managers/functionRuns';
34
34
  import { OrchestrationRunsManager } from './managers/orchestrationRuns';
35
35
  import { FilesManager } from './managers/files';
36
36
  import { WebhookSubscriptionsManager } from './managers/webhookSubscriptions';
37
+ import { SubscribersManager } from './managers/subscribers';
37
38
  import { QueryManager } from './managers/query';
38
39
  import { EmbedManager } from './managers/embed';
39
40
 
@@ -59,6 +60,7 @@ export class CentraliSDK {
59
60
  private _orchestrationRuns: OrchestrationRunsManager | null = null;
60
61
  private _files: FilesManager | null = null;
61
62
  private _webhookSubscriptions: WebhookSubscriptionsManager | null = null;
63
+ private _subscribers: SubscribersManager | null = null;
62
64
  private _query: QueryManager | null = null;
63
65
  private _embed: EmbedManager | null = null;
64
66
  private isRefreshingToken: boolean = false;
@@ -847,6 +849,36 @@ export class CentraliSDK {
847
849
  return this._webhookSubscriptions;
848
850
  }
849
851
 
852
+ /**
853
+ * Subscribers namespace (CEN-1487) — the customer or tenant a set of
854
+ * outbound webhook subscriptions belongs to. Create a subscriber, attach
855
+ * subscriptions to it via `webhookSubscriptions.create({ subscriberId })`,
856
+ * list everything it is subscribed to, and publish business events scoped
857
+ * to just that subscriber.
858
+ *
859
+ * Usage:
860
+ * ```ts
861
+ * const acme = await centrali.subscribers.create({
862
+ * externalId: 'acme_123',
863
+ * name: 'Acme Corp',
864
+ * });
865
+ * const subs = await centrali.subscribers.subscriptions('acme_123');
866
+ * await centrali.subscribers.publish('acme_123', {
867
+ * event: 'invoice.paid',
868
+ * data: { invoiceId: 'inv_1' },
869
+ * });
870
+ * ```
871
+ */
872
+ public get subscribers(): SubscribersManager {
873
+ if (!this._subscribers) {
874
+ this._subscribers = new SubscribersManager(
875
+ this.options.workspaceId,
876
+ this.request.bind(this)
877
+ );
878
+ }
879
+ return this._subscribers;
880
+ }
881
+
850
882
  /**
851
883
  * Server-side helpers for the white-label Event Log embed
852
884
  * (CEN-1301 — see `embed.centrali.io/v1/event-log`). Use to mint
@@ -467,3 +467,41 @@ export function getWebhookDeliveryRetryApiPath(workspaceId: string, deliveryId:
467
467
  export function getWebhookDeliveryCancelApiPath(workspaceId: string, deliveryId: string): string {
468
468
  return `data/workspace/${workspaceId}/api/v1/webhook-subscriptions/deliveries/${deliveryId}/cancel`;
469
469
  }
470
+
471
+ /**
472
+ * Generate the workspace-wide business-event publish API URL PATH.
473
+ * Fans a named event out to every subscription in the workspace listening for it.
474
+ */
475
+ export function getWebhookPublishApiPath(workspaceId: string): string {
476
+ return `data/workspace/${workspaceId}/api/v1/webhook-subscriptions/publish`;
477
+ }
478
+
479
+ // =====================================================
480
+ // Subscriber API Paths
481
+ // =====================================================
482
+
483
+ /**
484
+ * Generate Subscribers API URL PATH. `subscriberId` is the internal subscriber
485
+ * UUID — used for get/update/delete. The externalId-keyed routes have their own
486
+ * helpers below.
487
+ */
488
+ export function getSubscribersApiPath(workspaceId: string, subscriberId?: string): string {
489
+ const basePath = `data/workspace/${workspaceId}/api/v1/subscribers`;
490
+ return subscriberId ? `${basePath}/${subscriberId}` : basePath;
491
+ }
492
+
493
+ /**
494
+ * Generate the API URL PATH for a subscriber's attached webhook subscriptions,
495
+ * keyed by the builder's own `externalId`.
496
+ */
497
+ export function getSubscriberSubscriptionsApiPath(workspaceId: string, externalId: string): string {
498
+ return `data/workspace/${workspaceId}/api/v1/subscribers/${encodeURIComponent(externalId)}/subscriptions`;
499
+ }
500
+
501
+ /**
502
+ * Generate the subscriber-scoped business-event publish API URL PATH, keyed by
503
+ * the builder's own `externalId`.
504
+ */
505
+ export function getSubscriberPublishApiPath(workspaceId: string, externalId: string): string {
506
+ return `data/workspace/${workspaceId}/api/v1/subscribers/${encodeURIComponent(externalId)}/publish`;
507
+ }
@@ -0,0 +1,148 @@
1
+ // =====================================================
2
+ // Subscribers Manager
3
+ // =====================================================
4
+
5
+ import type { Method } from 'axios';
6
+ import type { ApiResponse } from '../types/common';
7
+ import type {
8
+ Subscriber,
9
+ CreateSubscriberInput,
10
+ UpdateSubscriberInput,
11
+ PublishToSubscriberInput,
12
+ PublishToSubscriberResult,
13
+ } from '../types/subscribers';
14
+ import type { WebhookSubscription } from '../types/webhooks';
15
+ import {
16
+ getSubscribersApiPath,
17
+ getSubscriberSubscriptionsApiPath,
18
+ getSubscriberPublishApiPath,
19
+ } from '../internal/paths';
20
+
21
+ // =====================================================
22
+ // Subscribers Manager
23
+ // =====================================================
24
+
25
+ /**
26
+ * SubscribersManager manages subscribers — the customer or tenant a set of
27
+ * outbound webhook subscriptions belongs to (CEN-1487). Access via
28
+ * `centrali.subscribers`.
29
+ *
30
+ * `externalId` is your own id for the customer; `get`/`update`/`delete` take
31
+ * the internal subscriber UUID, while `subscriptions` and `publish` are keyed
32
+ * by `externalId`.
33
+ *
34
+ * Usage:
35
+ * ```ts
36
+ * const sub = await centrali.subscribers.create({
37
+ * externalId: 'acme_123',
38
+ * name: 'Acme Corp',
39
+ * });
40
+ *
41
+ * // Attach a webhook subscription to it
42
+ * await centrali.webhookSubscriptions.create({
43
+ * name: 'Acme production',
44
+ * url: 'https://acme.example.com/hooks/centrali',
45
+ * events: [RecordEvents.CREATED],
46
+ * subscriberId: sub.data.id,
47
+ * });
48
+ *
49
+ * // Everything Acme is subscribed to
50
+ * const subs = await centrali.subscribers.subscriptions('acme_123');
51
+ *
52
+ * // Publish a business event to just Acme
53
+ * await centrali.subscribers.publish('acme_123', {
54
+ * event: 'invoice.paid',
55
+ * data: { invoiceId: 'inv_1', amount: 4200 },
56
+ * });
57
+ * ```
58
+ */
59
+ export class SubscribersManager {
60
+ private requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>;
61
+ private workspaceId: string;
62
+
63
+ constructor(
64
+ workspaceId: string,
65
+ requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>
66
+ ) {
67
+ this.workspaceId = workspaceId;
68
+ this.requestFn = requestFn;
69
+ }
70
+
71
+ /**
72
+ * List every subscriber in the workspace.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const result = await centrali.subscribers.list();
77
+ * result.data.forEach(s => console.log(s.externalId, s.name));
78
+ * ```
79
+ */
80
+ public list(): Promise<ApiResponse<Subscriber[]>> {
81
+ const path = getSubscribersApiPath(this.workspaceId);
82
+ return this.requestFn<Subscriber[]>('GET', path);
83
+ }
84
+
85
+ /**
86
+ * Register a subscriber. `externalId` must be unique within the workspace —
87
+ * a duplicate is rejected with a 400.
88
+ */
89
+ public create(input: CreateSubscriberInput): Promise<ApiResponse<Subscriber>> {
90
+ const path = getSubscribersApiPath(this.workspaceId);
91
+ return this.requestFn<Subscriber>('POST', path, input);
92
+ }
93
+
94
+ /**
95
+ * Get a subscriber by its internal UUID.
96
+ * @param subscriberId - The subscriber UUID (not the externalId).
97
+ */
98
+ public get(subscriberId: string): Promise<ApiResponse<Subscriber>> {
99
+ const path = getSubscribersApiPath(this.workspaceId, subscriberId);
100
+ return this.requestFn<Subscriber>('GET', path);
101
+ }
102
+
103
+ /**
104
+ * Update editable fields on a subscriber. `externalId` is not updatable.
105
+ * @param subscriberId - The subscriber UUID (not the externalId).
106
+ */
107
+ public update(subscriberId: string, patch: UpdateSubscriberInput): Promise<ApiResponse<Subscriber>> {
108
+ const path = getSubscribersApiPath(this.workspaceId, subscriberId);
109
+ return this.requestFn<Subscriber>('PATCH', path, patch);
110
+ }
111
+
112
+ /**
113
+ * Delete a subscriber. Subscriptions it owned are **not** deleted — the
114
+ * `subscriberId` FK is `ON DELETE SET NULL`, so they revert to unattached.
115
+ * @param subscriberId - The subscriber UUID (not the externalId).
116
+ */
117
+ public delete(subscriberId: string): Promise<ApiResponse<void>> {
118
+ const path = getSubscribersApiPath(this.workspaceId, subscriberId);
119
+ return this.requestFn<void>('DELETE', path);
120
+ }
121
+
122
+ /**
123
+ * List the webhook subscriptions attached to a subscriber, keyed by your
124
+ * own `externalId`. Returns full subscription rows — the signing `secret`
125
+ * is included, so the caller needs `webhook-subscriptions:retrieve` on top
126
+ * of `subscribers:retrieve`.
127
+ *
128
+ * @param externalId - The builder's own id for the subscriber.
129
+ */
130
+ public subscriptions(externalId: string): Promise<ApiResponse<WebhookSubscription[]>> {
131
+ const path = getSubscriberSubscriptionsApiPath(this.workspaceId, externalId);
132
+ return this.requestFn<WebhookSubscription[]>('GET', path);
133
+ }
134
+
135
+ /**
136
+ * Publish a named business event to every webhook subscription this
137
+ * subscriber owns that listens for it — the scoped counterpart to
138
+ * `centrali.webhookSubscriptions.publish()`. Because the target is
139
+ * explicit, the event reaches the subscriber's collection-scoped
140
+ * (`recordSlugs`) subscriptions too. Requires `webhook-subscriptions:publish`.
141
+ *
142
+ * @param externalId - The builder's own id for the subscriber.
143
+ */
144
+ public publish(externalId: string, input: PublishToSubscriberInput): Promise<ApiResponse<PublishToSubscriberResult>> {
145
+ const path = getSubscriberPublishApiPath(this.workspaceId, externalId);
146
+ return this.requestFn<PublishToSubscriberResult>('POST', path, input);
147
+ }
148
+ }
@@ -2,7 +2,7 @@
2
2
  // Webhook Subscriptions Manager
3
3
  // =====================================================
4
4
 
5
- import type { Method } from 'axios';
5
+ import type { AxiosRequestConfig, Method } from 'axios';
6
6
  import type { ApiResponse } from '../types/common';
7
7
  import type {
8
8
  WebhookSubscription,
@@ -15,6 +15,8 @@ import type {
15
15
  CreateWebhookSubscriptionInput,
16
16
  UpdateWebhookSubscriptionInput,
17
17
  ListWebhookDeliveriesOptions,
18
+ PublishWebhookEventInput,
19
+ PublishWebhookEventResult,
18
20
  } from '../types/webhooks';
19
21
  import {
20
22
  getWebhookSubscriptionsApiPath,
@@ -23,6 +25,7 @@ import {
23
25
  getWebhookSubscriptionDeliveriesApiPath,
24
26
  getWebhookDeliveryRetryApiPath,
25
27
  getWebhookDeliveryCancelApiPath,
28
+ getWebhookPublishApiPath,
26
29
  } from '../internal/paths';
27
30
 
28
31
  // =====================================================
@@ -63,7 +66,7 @@ import {
63
66
  * ```
64
67
  */
65
68
  export class WebhookSubscriptionsManager {
66
- private requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>;
69
+ private requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>, config?: AxiosRequestConfig) => Promise<ApiResponse<T>>;
67
70
  private workspaceId: string;
68
71
 
69
72
  /**
@@ -96,7 +99,7 @@ export class WebhookSubscriptionsManager {
96
99
 
97
100
  constructor(
98
101
  workspaceId: string,
99
- requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>
102
+ requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>, config?: AxiosRequestConfig) => Promise<ApiResponse<T>>
100
103
  ) {
101
104
  this.workspaceId = workspaceId;
102
105
  this.requestFn = requestFn;
@@ -221,4 +224,46 @@ export class WebhookSubscriptionsManager {
221
224
  const path = getWebhookPayloadVersionsApiPath(this.workspaceId);
222
225
  return this.requestFn<WebhookPayloadVersions>('GET', path);
223
226
  }
227
+
228
+ /**
229
+ * Publish a named business event (e.g. `invoice.paid`) to every webhook
230
+ * subscription in the workspace that listens for it. Delivery is
231
+ * asynchronous. Requires the `publish` action on `webhook-subscriptions` —
232
+ * distinct from `create` (which registers an endpoint).
233
+ *
234
+ * A published event carries no record context, so it matches only
235
+ * subscriptions with **no** `recordSlugs` filter; a collection-scoped
236
+ * subscription that also lists the event is recorded as a terminal
237
+ * `filtered` delivery. To reach a collection-scoped subscription, publish
238
+ * through `centrali.subscribers.publish()` instead.
239
+ *
240
+ * An empty `deliveries` array is a success — nothing subscribes to that
241
+ * event name.
242
+ *
243
+ * Pass `options.idempotencyKey` (a stable UUID per logical publish) to make
244
+ * a retry safe: the route's `withIdempotency` middleware returns the cached
245
+ * result for a resend of the same event+payload instead of fanning it out
246
+ * again. Retrying without one duplicates deliveries.
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * const { data } = await centrali.webhookSubscriptions.publish(
251
+ * { event: 'invoice.paid', data: { invoiceId: 'inv_1', amount: 4200 } },
252
+ * { idempotencyKey: crypto.randomUUID() },
253
+ * );
254
+ * console.log('Correlation:', data.correlationId, 'fanned to', data.deliveries.length);
255
+ * ```
256
+ */
257
+ public publish(
258
+ input: PublishWebhookEventInput,
259
+ options?: { idempotencyKey?: string },
260
+ ): Promise<ApiResponse<PublishWebhookEventResult>> {
261
+ const path = getWebhookPublishApiPath(this.workspaceId);
262
+ if (options?.idempotencyKey) {
263
+ return this.requestFn<PublishWebhookEventResult>('POST', path, input, undefined, {
264
+ headers: { 'Idempotency-Key': options.idempotencyKey },
265
+ });
266
+ }
267
+ return this.requestFn<PublishWebhookEventResult>('POST', path, input);
268
+ }
224
269
  }
@@ -0,0 +1,65 @@
1
+ // =====================================================
2
+ // Subscriber Types
3
+ // =====================================================
4
+ //
5
+ // CEN-1487: a Subscriber is the customer/tenant a set of webhook subscriptions
6
+ // belongs to. `externalId` is the builder's own id for that customer and is the
7
+ // stable key the externalId-scoped routes (subscriptions, publish) look up by.
8
+
9
+ import type { WebhookPublishDelivery } from './webhooks';
10
+
11
+ export interface Subscriber {
12
+ id: string;
13
+ workspaceSlug: string;
14
+ /** The builder's own id for this customer. Unique within the workspace, not updatable. */
15
+ externalId: string;
16
+ name: string;
17
+ metadata?: Record<string, unknown> | null;
18
+ active: boolean;
19
+ createdAt?: string;
20
+ updatedAt?: string;
21
+ }
22
+
23
+ export interface CreateSubscriberInput {
24
+ externalId: string;
25
+ name: string;
26
+ metadata?: Record<string, unknown> | null;
27
+ /** Defaults to `true` server-side when omitted. */
28
+ active?: boolean;
29
+ }
30
+
31
+ /**
32
+ * Editable fields on a subscriber. `externalId` is intentionally absent — it is
33
+ * the stable lookup key and changing it would orphan `subscriptions`/`publish`
34
+ * calls. At least one field must be provided.
35
+ */
36
+ export interface UpdateSubscriberInput {
37
+ name?: string;
38
+ metadata?: Record<string, unknown> | null;
39
+ active?: boolean;
40
+ }
41
+
42
+ export interface PublishToSubscriberInput {
43
+ /**
44
+ * Event name subscriptions match on (e.g. `invoice.paid`). Printable
45
+ * characters only, no spaces, max 128 chars. Names beginning with `record.`
46
+ * are reserved for platform record lifecycle events and are rejected.
47
+ */
48
+ event: string;
49
+ /** Arbitrary JSON object delivered as the event's `data` body. Max 256 KB serialized. */
50
+ data?: Record<string, unknown>;
51
+ }
52
+
53
+ export interface PublishToSubscriberResult {
54
+ /** Chain ID stamped on every delivery this publish created. */
55
+ correlationId: string;
56
+ event: string;
57
+ subscriber: { id: string; externalId: string };
58
+ /**
59
+ * One row per subscription the event was routed to. An empty array is a
60
+ * success — the subscriber has no subscription listening for that event.
61
+ * Unlike the workspace-wide publish, this reaches the subscriber's
62
+ * collection-scoped (`recordSlugs`) subscriptions too.
63
+ */
64
+ deliveries: WebhookPublishDelivery[];
65
+ }
@@ -4,13 +4,22 @@
4
4
 
5
5
  import type { RecordEventType } from './realtime';
6
6
 
7
- export type WebhookDeliveryStatus = 'success' | 'failed' | 'retrying';
7
+ export type WebhookDeliveryStatus = 'success' | 'failed' | 'retrying' | 'filtered';
8
+
9
+ /**
10
+ * An event name a subscription can listen for. The `RecordEventType` members
11
+ * are the built-in record lifecycle events (kept for autocomplete); any other
12
+ * string is a named business event published via
13
+ * `centrali.webhookSubscriptions.publish()` / `centrali.subscribers.publish()`.
14
+ * The backend validates this as a non-empty string, not an enum.
15
+ */
16
+ export type WebhookEventName = RecordEventType | (string & {});
8
17
 
9
18
  export interface WebhookSubscription {
10
19
  id: string;
11
20
  name: string;
12
21
  url: string;
13
- events: RecordEventType[];
22
+ events: WebhookEventName[];
14
23
  /**
15
24
  * Optional list of record slugs to scope the subscription to. When null or
16
25
  * empty, the subscription receives events for all collections.
@@ -28,6 +37,12 @@ export interface WebhookSubscription {
28
37
  * describes. Frozen at creation; change it to upgrade to a newer shape.
29
38
  */
30
39
  payloadVersion: string;
40
+ /**
41
+ * CEN-1487: the owning subscriber's internal UUID, or null when the
42
+ * subscription is unattached. Set it via `create`/`update` with a value
43
+ * from `centrali.subscribers`.
44
+ */
45
+ subscriberId?: string | null;
31
46
  workspaceSlug: string;
32
47
  createdAt?: string;
33
48
  updatedAt?: string;
@@ -68,7 +83,8 @@ export type WebhookDeliverySummary = Omit<WebhookDelivery, 'requestPayload' | 'r
68
83
  export interface CreateWebhookSubscriptionInput {
69
84
  name: string;
70
85
  url: string;
71
- events: RecordEventType[];
86
+ /** Record lifecycle events and/or named business events. See `WebhookEventName`. */
87
+ events: WebhookEventName[];
72
88
  /** Optional — restrict to a subset of collections. Omit for all collections. */
73
89
  recordSlugs?: string[];
74
90
  active?: boolean;
@@ -78,12 +94,19 @@ export interface CreateWebhookSubscriptionInput {
78
94
  * by `getPayloadVersions()`.
79
95
  */
80
96
  payloadVersion?: string;
97
+ /**
98
+ * CEN-1487: attach the subscription to a subscriber. The internal
99
+ * subscriber UUID (`centrali.subscribers` `id`), validated to exist in the
100
+ * workspace. Omit or pass `null` to leave it unattached.
101
+ */
102
+ subscriberId?: string | null;
81
103
  }
82
104
 
83
105
  export interface UpdateWebhookSubscriptionInput {
84
106
  name?: string;
85
107
  url?: string;
86
- events?: RecordEventType[];
108
+ /** Record lifecycle events and/or named business events. See `WebhookEventName`. */
109
+ events?: WebhookEventName[];
87
110
  /**
88
111
  * Update the collection scope. Pass an empty array (`[]`) to clear the
89
112
  * restriction so the subscription receives events for all collections.
@@ -96,6 +119,11 @@ export interface UpdateWebhookSubscriptionInput {
96
119
  * returned by `getPayloadVersions()`. Omit to leave the version unchanged.
97
120
  */
98
121
  payloadVersion?: string;
122
+ /**
123
+ * CEN-1487: re-attach (or detach, with `null`) the subscription's owning
124
+ * subscriber. Omit to leave the attachment unchanged.
125
+ */
126
+ subscriberId?: string | null;
99
127
  }
100
128
 
101
129
  /**
@@ -141,3 +169,41 @@ export interface WebhookCancelResponse {
141
169
  status: WebhookDeliveryStatus;
142
170
  lastError: string | null;
143
171
  }
172
+
173
+ // =====================================================
174
+ // Business-event publish (CEN-1413 / CEN-1487)
175
+ // =====================================================
176
+
177
+ export interface PublishWebhookEventInput {
178
+ /**
179
+ * Event name subscriptions match on (e.g. `invoice.paid`). Printable
180
+ * characters only, no spaces, max 128 chars. Names beginning with `record.`
181
+ * are reserved for platform record lifecycle events and are rejected.
182
+ */
183
+ event: string;
184
+ /** Arbitrary JSON object delivered as the event's `data` body. Max 256 KB serialized. */
185
+ data?: Record<string, unknown>;
186
+ }
187
+
188
+ /**
189
+ * One delivery routed by a publish. `filtered` = the event matched the
190
+ * subscription's events but was skipped (payload predicate, or a collection
191
+ * scope the untargeted workspace-wide publish does not cross) and recorded as a
192
+ * terminal row so the skip is visible in the delivery log.
193
+ */
194
+ export interface WebhookPublishDelivery {
195
+ id: string;
196
+ subscriptionId: string;
197
+ status: 'retrying' | 'filtered' | 'failed';
198
+ }
199
+
200
+ export interface PublishWebhookEventResult {
201
+ /** Chain ID stamped on every delivery this publish created. */
202
+ correlationId: string;
203
+ event: string;
204
+ /**
205
+ * One row per subscription the event was routed to. An empty array is a
206
+ * success — nothing in the workspace subscribes to that event name.
207
+ */
208
+ deliveries: WebhookPublishDelivery[];
209
+ }