@kadoa/node-sdk 0.22.0 → 0.23.0

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/dist/index.d.mts CHANGED
@@ -10367,13 +10367,31 @@ declare class ApiRegistry {
10367
10367
  get notifications(): NotificationsApi;
10368
10368
  }
10369
10369
 
10370
+ interface TeamInfo {
10371
+ id: string;
10372
+ name: string;
10373
+ role: string;
10374
+ memberRole: string;
10375
+ }
10376
+ interface BearerAuthOptions {
10377
+ bearerToken: string;
10378
+ }
10370
10379
  interface KadoaClientStatus {
10371
10380
  baseUrl: string;
10372
10381
  user: KadoaUser;
10373
10382
  realtimeConnected: boolean;
10374
10383
  }
10375
10384
  interface KadoaClientConfig {
10376
- apiKey: string;
10385
+ /**
10386
+ * Team API key (`tk-...`). Required unless `bearerToken` is provided.
10387
+ */
10388
+ apiKey?: string;
10389
+ /**
10390
+ * = JWT for Bearer auth. When set, requests send
10391
+ * `Authorization: Bearer <token>` instead of `x-api-key`.
10392
+ * Use {@link KadoaClient.setBearerToken} to update after refresh.
10393
+ */
10394
+ bearerToken?: string;
10377
10395
  /**
10378
10396
  * Override the base URL for the public API.
10379
10397
  *
@@ -10422,6 +10440,7 @@ declare class KadoaClient {
10422
10440
  private readonly _axiosInstance;
10423
10441
  private readonly _baseUrl;
10424
10442
  private readonly _apiKey;
10443
+ private _bearerToken;
10425
10444
  private _realtime?;
10426
10445
  private readonly _extractionBuilderService;
10427
10446
  readonly apis: ApiRegistry;
@@ -10448,9 +10467,15 @@ declare class KadoaClient {
10448
10467
  /**
10449
10468
  * Get the API key
10450
10469
  *
10451
- * @returns The API key
10470
+ * @returns The API key (empty string when using Bearer auth)
10452
10471
  */
10453
10472
  get apiKey(): string;
10473
+ /**
10474
+ * Update the Bearer token used for authentication.
10475
+ * Call this after a Supabase JWT refresh so that subsequent requests
10476
+ * use the new token.
10477
+ */
10478
+ setBearerToken(token: string): void;
10454
10479
  /**
10455
10480
  * Get the realtime connection (if enabled)
10456
10481
  */
@@ -10486,6 +10511,24 @@ declare class KadoaClient {
10486
10511
  * @returns The status of the client
10487
10512
  */
10488
10513
  status(): Promise<KadoaClientStatus>;
10514
+ /**
10515
+ * List all teams accessible to the authenticated user.
10516
+ *
10517
+ * When called with a Bearer token (Supabase JWT), returns all teams the
10518
+ * human user belongs to. Without it, falls back to x-api-key auth which
10519
+ * only returns teams the service account (API key) belongs to.
10520
+ */
10521
+ listTeams(opts?: BearerAuthOptions): Promise<TeamInfo[]>;
10522
+ /**
10523
+ * Switch the active team for this session.
10524
+ *
10525
+ * Calls `POST /v5/auth/active-team` which updates the server-side
10526
+ * session→team mapping. Subsequent requests with the same JWT are
10527
+ * automatically scoped to the new team — no token refresh needed.
10528
+ *
10529
+ * @param teamId - The team ID to switch to (must be a team the user belongs to)
10530
+ */
10531
+ setActiveTeam(teamId: string): Promise<void>;
10489
10532
  /**
10490
10533
  * Dispose of the client and clean up resources
10491
10534
  */
@@ -10653,4 +10696,4 @@ declare class KadoaHttpException extends KadoaSdkException {
10653
10696
  static mapStatusToCode(errorOrStatus: AxiosError | number): KadoaErrorCode;
10654
10697
  }
10655
10698
 
10656
- export { type ArtifactOptions, type BlueprintItem, type BulkApproveRulesRequest, type BulkApproveRulesResponseData, type BulkDeleteRulesRequest, type BulkDeleteRulesResponseData, type Category, type ChannelConfig, type ChannelSetupRequestConfig, type CrawlMethod, type CrawlerConfig, CrawlerConfigService, type CrawlerDomain, type CrawlerExtractionOptions, type CrawlerSession, CrawlerSessionService, type CreateChannelRequest, type CreateConfigRequest, type CreateSchemaRequest, type CreateSettingsRequest, type CreateWorkflowInput, type CreateWorkflowRequest, type CreateWorkflowWithCustomSchemaRequest, type CreatedExtraction, DataFetcherService, type DataFieldFor, type DataPagination, DataSortOrder, type DataType, type DataTypeNotRequiringExample, type DataTypeRequiringExample, type DeleteAllRulesRequest, type DeleteAllRulesResponseData, type DeleteConfigRequest, type DeleteConfigResult, type DisableRuleRequest, ERROR_MESSAGES, type EmailChannelConfig, EntityResolverService, type ExtractOptions, ExtractionBuilderService, type ExtractionOptions, type ExtractionResult, ExtractionService, FetchDataOptions, type FetchDataResult, type FieldExample, type FieldOptions, type FieldOptionsWithExample, type FieldOptionsWithoutExample, type FieldType, type FinishedExtraction, type GenerateRuleRequest, type GenerateRulesRequest, type GetAllDataOptions, type GetAnomaliesByRuleResponse, type GetAnomalyRulePageResponse, type GetBucketFileOptions, type GetJobResponse, type GetPageOptions, type GetPagesOptions, type GetValidationResponse, type GetWorkflowResponse, type JobId, JobStateEnum, type JobWaitOptions, KadoaClient, type KadoaClientConfig, type KadoaClientStatus, KadoaErrorCode, KadoaHttpException, KadoaSdkException, type KadoaUser, ListChannelsRequest, ListRulesRequest, type ListRulesResponse, type ListSessionsOptions, type ListSessionsResult, ListSettingsRequest, type ListValidationsResponse, ListWorkflowValidationsRequest, ListWorkflowsRequest, type LocationConfig, type MetadataKey, type MonitoringConfig, type MonitoringField, type MonitoringOperator, MonitoringStatus, type NavigationMode, type NavigationOptions, type NotificationChannel, type NotificationChannelConfig, NotificationChannelType, NotificationChannelsService, type NotificationDomain, type NotificationOptions, type NotificationSettings, type NotificationSettingsEventType, V5NotificationsSettingsGetEventTypeEnum as NotificationSettingsEventTypeEnum, NotificationSettingsService, type NotificationSetupRequestChannels, NotificationSetupService, type PageContent, PageStatus, type PaginationInfo, type PollingOptions, type PreparedExtraction, type RawFormat, Realtime, type RealtimeConfig, type RealtimeEvent, ResponseFormat, type Rule, RuleStatus, RuleType, type RunWorkflowRequest, type RunWorkflowResponse, type ScheduleValidationResponse, SchemaBuilder, type SchemaField as SchemaDefinitionField, type SchemaField$1 as SchemaField, SchemaFieldDataType, type SchemaResponse, SchemasService, type SessionDataItem, type SessionDataList, type SessionOperationResult, type SessionPage, type SessionPagesResult, type SessionStatus, type SetupWorkflowNotificationSettingsRequest, type SetupWorkspaceNotificationSettingsRequest, type SlackChannelConfig, type StartCrawlRequest, type StartSessionResult, type StartWithConfigRequest, type SubmitExtractionResult, type SubmittedExtraction, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, type TestNotificationRequest, type TestNotificationResult, type ToggleValidationResponse, UpdateInterval, type UpdateSchemaRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, UserService, ValidationCoreService, type ValidationDomain, ValidationRulesService, ValidationStrategy, type WaitForReadyOptions, type WaitOptions, type WebhookChannelConfig, type WebhookChannelConfigAuth, type WebhookHttpMethod, type WebsocketChannelConfig, type WorkflowDataResponse, type WorkflowDetailsResponse, WorkflowDisplayStateEnum, type WorkflowId, type WorkflowInterval, type WorkflowMonitoringConfig, type WorkflowResponse, WorkflowState, WorkflowStateEnum, type WorkflowsApiInterface, WorkflowsCoreService, createCrawlerDomain, pollUntil, validateAdditionalData };
10699
+ export { type ArtifactOptions, type BearerAuthOptions, type BlueprintItem, type BulkApproveRulesRequest, type BulkApproveRulesResponseData, type BulkDeleteRulesRequest, type BulkDeleteRulesResponseData, type Category, type ChannelConfig, type ChannelSetupRequestConfig, type CrawlMethod, type CrawlerConfig, CrawlerConfigService, type CrawlerDomain, type CrawlerExtractionOptions, type CrawlerSession, CrawlerSessionService, type CreateChannelRequest, type CreateConfigRequest, type CreateSchemaRequest, type CreateSettingsRequest, type CreateWorkflowInput, type CreateWorkflowRequest, type CreateWorkflowWithCustomSchemaRequest, type CreatedExtraction, DataFetcherService, type DataFieldFor, type DataPagination, DataSortOrder, type DataType, type DataTypeNotRequiringExample, type DataTypeRequiringExample, type DeleteAllRulesRequest, type DeleteAllRulesResponseData, type DeleteConfigRequest, type DeleteConfigResult, type DisableRuleRequest, ERROR_MESSAGES, type EmailChannelConfig, EntityResolverService, type ExtractOptions, ExtractionBuilderService, type ExtractionOptions, type ExtractionResult, ExtractionService, FetchDataOptions, type FetchDataResult, type FieldExample, type FieldOptions, type FieldOptionsWithExample, type FieldOptionsWithoutExample, type FieldType, type FinishedExtraction, type GenerateRuleRequest, type GenerateRulesRequest, type GetAllDataOptions, type GetAnomaliesByRuleResponse, type GetAnomalyRulePageResponse, type GetBucketFileOptions, type GetJobResponse, type GetPageOptions, type GetPagesOptions, type GetValidationResponse, type GetWorkflowResponse, type JobId, JobStateEnum, type JobWaitOptions, KadoaClient, type KadoaClientConfig, type KadoaClientStatus, KadoaErrorCode, KadoaHttpException, KadoaSdkException, type KadoaUser, ListChannelsRequest, ListRulesRequest, type ListRulesResponse, type ListSessionsOptions, type ListSessionsResult, ListSettingsRequest, type ListValidationsResponse, ListWorkflowValidationsRequest, ListWorkflowsRequest, type LocationConfig, type MetadataKey, type MonitoringConfig, type MonitoringField, type MonitoringOperator, MonitoringStatus, type NavigationMode, type NavigationOptions, type NotificationChannel, type NotificationChannelConfig, NotificationChannelType, NotificationChannelsService, type NotificationDomain, type NotificationOptions, type NotificationSettings, type NotificationSettingsEventType, V5NotificationsSettingsGetEventTypeEnum as NotificationSettingsEventTypeEnum, NotificationSettingsService, type NotificationSetupRequestChannels, NotificationSetupService, type PageContent, PageStatus, type PaginationInfo, type PollingOptions, type PreparedExtraction, type RawFormat, Realtime, type RealtimeConfig, type RealtimeEvent, ResponseFormat, type Rule, RuleStatus, RuleType, type RunWorkflowRequest, type RunWorkflowResponse, type ScheduleValidationResponse, SchemaBuilder, type SchemaField as SchemaDefinitionField, type SchemaField$1 as SchemaField, SchemaFieldDataType, type SchemaResponse, SchemasService, type SessionDataItem, type SessionDataList, type SessionOperationResult, type SessionPage, type SessionPagesResult, type SessionStatus, type SetupWorkflowNotificationSettingsRequest, type SetupWorkspaceNotificationSettingsRequest, type SlackChannelConfig, type StartCrawlRequest, type StartSessionResult, type StartWithConfigRequest, type SubmitExtractionResult, type SubmittedExtraction, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, type TeamInfo, type TestNotificationRequest, type TestNotificationResult, type ToggleValidationResponse, UpdateInterval, type UpdateSchemaRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, UserService, ValidationCoreService, type ValidationDomain, ValidationRulesService, ValidationStrategy, type WaitForReadyOptions, type WaitOptions, type WebhookChannelConfig, type WebhookChannelConfigAuth, type WebhookHttpMethod, type WebsocketChannelConfig, type WorkflowDataResponse, type WorkflowDetailsResponse, WorkflowDisplayStateEnum, type WorkflowId, type WorkflowInterval, type WorkflowMonitoringConfig, type WorkflowResponse, WorkflowState, WorkflowStateEnum, type WorkflowsApiInterface, WorkflowsCoreService, createCrawlerDomain, pollUntil, validateAdditionalData };
package/dist/index.d.ts CHANGED
@@ -10367,13 +10367,31 @@ declare class ApiRegistry {
10367
10367
  get notifications(): NotificationsApi;
10368
10368
  }
10369
10369
 
10370
+ interface TeamInfo {
10371
+ id: string;
10372
+ name: string;
10373
+ role: string;
10374
+ memberRole: string;
10375
+ }
10376
+ interface BearerAuthOptions {
10377
+ bearerToken: string;
10378
+ }
10370
10379
  interface KadoaClientStatus {
10371
10380
  baseUrl: string;
10372
10381
  user: KadoaUser;
10373
10382
  realtimeConnected: boolean;
10374
10383
  }
10375
10384
  interface KadoaClientConfig {
10376
- apiKey: string;
10385
+ /**
10386
+ * Team API key (`tk-...`). Required unless `bearerToken` is provided.
10387
+ */
10388
+ apiKey?: string;
10389
+ /**
10390
+ * = JWT for Bearer auth. When set, requests send
10391
+ * `Authorization: Bearer <token>` instead of `x-api-key`.
10392
+ * Use {@link KadoaClient.setBearerToken} to update after refresh.
10393
+ */
10394
+ bearerToken?: string;
10377
10395
  /**
10378
10396
  * Override the base URL for the public API.
10379
10397
  *
@@ -10422,6 +10440,7 @@ declare class KadoaClient {
10422
10440
  private readonly _axiosInstance;
10423
10441
  private readonly _baseUrl;
10424
10442
  private readonly _apiKey;
10443
+ private _bearerToken;
10425
10444
  private _realtime?;
10426
10445
  private readonly _extractionBuilderService;
10427
10446
  readonly apis: ApiRegistry;
@@ -10448,9 +10467,15 @@ declare class KadoaClient {
10448
10467
  /**
10449
10468
  * Get the API key
10450
10469
  *
10451
- * @returns The API key
10470
+ * @returns The API key (empty string when using Bearer auth)
10452
10471
  */
10453
10472
  get apiKey(): string;
10473
+ /**
10474
+ * Update the Bearer token used for authentication.
10475
+ * Call this after a Supabase JWT refresh so that subsequent requests
10476
+ * use the new token.
10477
+ */
10478
+ setBearerToken(token: string): void;
10454
10479
  /**
10455
10480
  * Get the realtime connection (if enabled)
10456
10481
  */
@@ -10486,6 +10511,24 @@ declare class KadoaClient {
10486
10511
  * @returns The status of the client
10487
10512
  */
10488
10513
  status(): Promise<KadoaClientStatus>;
10514
+ /**
10515
+ * List all teams accessible to the authenticated user.
10516
+ *
10517
+ * When called with a Bearer token (Supabase JWT), returns all teams the
10518
+ * human user belongs to. Without it, falls back to x-api-key auth which
10519
+ * only returns teams the service account (API key) belongs to.
10520
+ */
10521
+ listTeams(opts?: BearerAuthOptions): Promise<TeamInfo[]>;
10522
+ /**
10523
+ * Switch the active team for this session.
10524
+ *
10525
+ * Calls `POST /v5/auth/active-team` which updates the server-side
10526
+ * session→team mapping. Subsequent requests with the same JWT are
10527
+ * automatically scoped to the new team — no token refresh needed.
10528
+ *
10529
+ * @param teamId - The team ID to switch to (must be a team the user belongs to)
10530
+ */
10531
+ setActiveTeam(teamId: string): Promise<void>;
10489
10532
  /**
10490
10533
  * Dispose of the client and clean up resources
10491
10534
  */
@@ -10653,4 +10696,4 @@ declare class KadoaHttpException extends KadoaSdkException {
10653
10696
  static mapStatusToCode(errorOrStatus: AxiosError | number): KadoaErrorCode;
10654
10697
  }
10655
10698
 
10656
- export { type ArtifactOptions, type BlueprintItem, type BulkApproveRulesRequest, type BulkApproveRulesResponseData, type BulkDeleteRulesRequest, type BulkDeleteRulesResponseData, type Category, type ChannelConfig, type ChannelSetupRequestConfig, type CrawlMethod, type CrawlerConfig, CrawlerConfigService, type CrawlerDomain, type CrawlerExtractionOptions, type CrawlerSession, CrawlerSessionService, type CreateChannelRequest, type CreateConfigRequest, type CreateSchemaRequest, type CreateSettingsRequest, type CreateWorkflowInput, type CreateWorkflowRequest, type CreateWorkflowWithCustomSchemaRequest, type CreatedExtraction, DataFetcherService, type DataFieldFor, type DataPagination, DataSortOrder, type DataType, type DataTypeNotRequiringExample, type DataTypeRequiringExample, type DeleteAllRulesRequest, type DeleteAllRulesResponseData, type DeleteConfigRequest, type DeleteConfigResult, type DisableRuleRequest, ERROR_MESSAGES, type EmailChannelConfig, EntityResolverService, type ExtractOptions, ExtractionBuilderService, type ExtractionOptions, type ExtractionResult, ExtractionService, FetchDataOptions, type FetchDataResult, type FieldExample, type FieldOptions, type FieldOptionsWithExample, type FieldOptionsWithoutExample, type FieldType, type FinishedExtraction, type GenerateRuleRequest, type GenerateRulesRequest, type GetAllDataOptions, type GetAnomaliesByRuleResponse, type GetAnomalyRulePageResponse, type GetBucketFileOptions, type GetJobResponse, type GetPageOptions, type GetPagesOptions, type GetValidationResponse, type GetWorkflowResponse, type JobId, JobStateEnum, type JobWaitOptions, KadoaClient, type KadoaClientConfig, type KadoaClientStatus, KadoaErrorCode, KadoaHttpException, KadoaSdkException, type KadoaUser, ListChannelsRequest, ListRulesRequest, type ListRulesResponse, type ListSessionsOptions, type ListSessionsResult, ListSettingsRequest, type ListValidationsResponse, ListWorkflowValidationsRequest, ListWorkflowsRequest, type LocationConfig, type MetadataKey, type MonitoringConfig, type MonitoringField, type MonitoringOperator, MonitoringStatus, type NavigationMode, type NavigationOptions, type NotificationChannel, type NotificationChannelConfig, NotificationChannelType, NotificationChannelsService, type NotificationDomain, type NotificationOptions, type NotificationSettings, type NotificationSettingsEventType, V5NotificationsSettingsGetEventTypeEnum as NotificationSettingsEventTypeEnum, NotificationSettingsService, type NotificationSetupRequestChannels, NotificationSetupService, type PageContent, PageStatus, type PaginationInfo, type PollingOptions, type PreparedExtraction, type RawFormat, Realtime, type RealtimeConfig, type RealtimeEvent, ResponseFormat, type Rule, RuleStatus, RuleType, type RunWorkflowRequest, type RunWorkflowResponse, type ScheduleValidationResponse, SchemaBuilder, type SchemaField as SchemaDefinitionField, type SchemaField$1 as SchemaField, SchemaFieldDataType, type SchemaResponse, SchemasService, type SessionDataItem, type SessionDataList, type SessionOperationResult, type SessionPage, type SessionPagesResult, type SessionStatus, type SetupWorkflowNotificationSettingsRequest, type SetupWorkspaceNotificationSettingsRequest, type SlackChannelConfig, type StartCrawlRequest, type StartSessionResult, type StartWithConfigRequest, type SubmitExtractionResult, type SubmittedExtraction, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, type TestNotificationRequest, type TestNotificationResult, type ToggleValidationResponse, UpdateInterval, type UpdateSchemaRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, UserService, ValidationCoreService, type ValidationDomain, ValidationRulesService, ValidationStrategy, type WaitForReadyOptions, type WaitOptions, type WebhookChannelConfig, type WebhookChannelConfigAuth, type WebhookHttpMethod, type WebsocketChannelConfig, type WorkflowDataResponse, type WorkflowDetailsResponse, WorkflowDisplayStateEnum, type WorkflowId, type WorkflowInterval, type WorkflowMonitoringConfig, type WorkflowResponse, WorkflowState, WorkflowStateEnum, type WorkflowsApiInterface, WorkflowsCoreService, createCrawlerDomain, pollUntil, validateAdditionalData };
10699
+ export { type ArtifactOptions, type BearerAuthOptions, type BlueprintItem, type BulkApproveRulesRequest, type BulkApproveRulesResponseData, type BulkDeleteRulesRequest, type BulkDeleteRulesResponseData, type Category, type ChannelConfig, type ChannelSetupRequestConfig, type CrawlMethod, type CrawlerConfig, CrawlerConfigService, type CrawlerDomain, type CrawlerExtractionOptions, type CrawlerSession, CrawlerSessionService, type CreateChannelRequest, type CreateConfigRequest, type CreateSchemaRequest, type CreateSettingsRequest, type CreateWorkflowInput, type CreateWorkflowRequest, type CreateWorkflowWithCustomSchemaRequest, type CreatedExtraction, DataFetcherService, type DataFieldFor, type DataPagination, DataSortOrder, type DataType, type DataTypeNotRequiringExample, type DataTypeRequiringExample, type DeleteAllRulesRequest, type DeleteAllRulesResponseData, type DeleteConfigRequest, type DeleteConfigResult, type DisableRuleRequest, ERROR_MESSAGES, type EmailChannelConfig, EntityResolverService, type ExtractOptions, ExtractionBuilderService, type ExtractionOptions, type ExtractionResult, ExtractionService, FetchDataOptions, type FetchDataResult, type FieldExample, type FieldOptions, type FieldOptionsWithExample, type FieldOptionsWithoutExample, type FieldType, type FinishedExtraction, type GenerateRuleRequest, type GenerateRulesRequest, type GetAllDataOptions, type GetAnomaliesByRuleResponse, type GetAnomalyRulePageResponse, type GetBucketFileOptions, type GetJobResponse, type GetPageOptions, type GetPagesOptions, type GetValidationResponse, type GetWorkflowResponse, type JobId, JobStateEnum, type JobWaitOptions, KadoaClient, type KadoaClientConfig, type KadoaClientStatus, KadoaErrorCode, KadoaHttpException, KadoaSdkException, type KadoaUser, ListChannelsRequest, ListRulesRequest, type ListRulesResponse, type ListSessionsOptions, type ListSessionsResult, ListSettingsRequest, type ListValidationsResponse, ListWorkflowValidationsRequest, ListWorkflowsRequest, type LocationConfig, type MetadataKey, type MonitoringConfig, type MonitoringField, type MonitoringOperator, MonitoringStatus, type NavigationMode, type NavigationOptions, type NotificationChannel, type NotificationChannelConfig, NotificationChannelType, NotificationChannelsService, type NotificationDomain, type NotificationOptions, type NotificationSettings, type NotificationSettingsEventType, V5NotificationsSettingsGetEventTypeEnum as NotificationSettingsEventTypeEnum, NotificationSettingsService, type NotificationSetupRequestChannels, NotificationSetupService, type PageContent, PageStatus, type PaginationInfo, type PollingOptions, type PreparedExtraction, type RawFormat, Realtime, type RealtimeConfig, type RealtimeEvent, ResponseFormat, type Rule, RuleStatus, RuleType, type RunWorkflowRequest, type RunWorkflowResponse, type ScheduleValidationResponse, SchemaBuilder, type SchemaField as SchemaDefinitionField, type SchemaField$1 as SchemaField, SchemaFieldDataType, type SchemaResponse, SchemasService, type SessionDataItem, type SessionDataList, type SessionOperationResult, type SessionPage, type SessionPagesResult, type SessionStatus, type SetupWorkflowNotificationSettingsRequest, type SetupWorkspaceNotificationSettingsRequest, type SlackChannelConfig, type StartCrawlRequest, type StartSessionResult, type StartWithConfigRequest, type SubmitExtractionResult, type SubmittedExtraction, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, type TeamInfo, type TestNotificationRequest, type TestNotificationResult, type ToggleValidationResponse, UpdateInterval, type UpdateSchemaRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, UserService, ValidationCoreService, type ValidationDomain, ValidationRulesService, ValidationStrategy, type WaitForReadyOptions, type WaitOptions, type WebhookChannelConfig, type WebhookChannelConfigAuth, type WebhookHttpMethod, type WebsocketChannelConfig, type WorkflowDataResponse, type WorkflowDetailsResponse, WorkflowDisplayStateEnum, type WorkflowId, type WorkflowInterval, type WorkflowMonitoringConfig, type WorkflowResponse, WorkflowState, WorkflowStateEnum, type WorkflowsApiInterface, WorkflowsCoreService, createCrawlerDomain, pollUntil, validateAdditionalData };
package/dist/index.js CHANGED
@@ -6209,7 +6209,7 @@ process.env.KADOA_WSS_NEO_API_URI ?? "wss://events.kadoa.com/events/ws";
6209
6209
  var REALTIME_API_URI = process.env.KADOA_REALTIME_API_URI ?? "https://realtime.kadoa.com";
6210
6210
 
6211
6211
  // src/version.ts
6212
- var SDK_VERSION = "0.22.0";
6212
+ var SDK_VERSION = "0.23.0";
6213
6213
  var SDK_NAME = "kadoa-node-sdk";
6214
6214
  var SDK_LANGUAGE = "node";
6215
6215
 
@@ -7184,11 +7184,27 @@ function createNotificationDomain(params) {
7184
7184
  // src/client/kadoa-client.ts
7185
7185
  var KadoaClient = class {
7186
7186
  constructor(config) {
7187
+ if (!config.apiKey && !config.bearerToken) {
7188
+ throw new KadoaSdkException(
7189
+ "Either apiKey or bearerToken must be provided",
7190
+ { code: "VALIDATION_ERROR" }
7191
+ );
7192
+ }
7187
7193
  this._baseUrl = config.baseUrl ?? PUBLIC_API_URI;
7188
- this._apiKey = config.apiKey;
7194
+ this._apiKey = config.apiKey ?? "";
7195
+ this._bearerToken = config.bearerToken;
7189
7196
  const timeout = config.timeout ?? 3e4;
7190
7197
  const headers = createSdkHeaders();
7191
7198
  this._axiosInstance = createAxiosInstance({ timeout, headers });
7199
+ this._axiosInstance.interceptors.request.use((reqConfig) => {
7200
+ if (this._bearerToken) {
7201
+ if (!reqConfig.headers["Authorization"]) {
7202
+ reqConfig.headers["Authorization"] = `Bearer ${this._bearerToken}`;
7203
+ }
7204
+ delete reqConfig.headers["x-api-key"];
7205
+ }
7206
+ return reqConfig;
7207
+ });
7192
7208
  this.apis = new ApiRegistry(
7193
7209
  this._apiKey,
7194
7210
  this._baseUrl,
@@ -7226,11 +7242,19 @@ var KadoaClient = class {
7226
7242
  /**
7227
7243
  * Get the API key
7228
7244
  *
7229
- * @returns The API key
7245
+ * @returns The API key (empty string when using Bearer auth)
7230
7246
  */
7231
7247
  get apiKey() {
7232
7248
  return this._apiKey;
7233
7249
  }
7250
+ /**
7251
+ * Update the Bearer token used for authentication.
7252
+ * Call this after a Supabase JWT refresh so that subsequent requests
7253
+ * use the new token.
7254
+ */
7255
+ setBearerToken(token) {
7256
+ this._bearerToken = token;
7257
+ }
7234
7258
  /**
7235
7259
  * Get the realtime connection (if enabled)
7236
7260
  */
@@ -7254,6 +7278,12 @@ var KadoaClient = class {
7254
7278
  * @returns The Realtime instance
7255
7279
  */
7256
7280
  async connectRealtime(options) {
7281
+ if (!this._apiKey) {
7282
+ throw new KadoaSdkException(
7283
+ "Realtime requires an API key. Bearer-only auth is not supported for WebSocket connections.",
7284
+ { code: "VALIDATION_ERROR" }
7285
+ );
7286
+ }
7257
7287
  if (!this._realtime) {
7258
7288
  this._realtime = new Realtime({ apiKey: this._apiKey, ...options });
7259
7289
  await this._realtime.connect();
@@ -7289,6 +7319,42 @@ var KadoaClient = class {
7289
7319
  realtimeConnected: this.isRealtimeConnected()
7290
7320
  };
7291
7321
  }
7322
+ /**
7323
+ * List all teams accessible to the authenticated user.
7324
+ *
7325
+ * When called with a Bearer token (Supabase JWT), returns all teams the
7326
+ * human user belongs to. Without it, falls back to x-api-key auth which
7327
+ * only returns teams the service account (API key) belongs to.
7328
+ */
7329
+ async listTeams(opts) {
7330
+ const headers = opts?.bearerToken ? { Authorization: `Bearer ${opts.bearerToken}` } : void 0;
7331
+ const response = await this._axiosInstance.get("/v5/user", {
7332
+ baseURL: this._baseUrl,
7333
+ ...headers && { headers }
7334
+ });
7335
+ return response.data?.teams ?? [];
7336
+ }
7337
+ /**
7338
+ * Switch the active team for this session.
7339
+ *
7340
+ * Calls `POST /v5/auth/active-team` which updates the server-side
7341
+ * session→team mapping. Subsequent requests with the same JWT are
7342
+ * automatically scoped to the new team — no token refresh needed.
7343
+ *
7344
+ * @param teamId - The team ID to switch to (must be a team the user belongs to)
7345
+ */
7346
+ async setActiveTeam(teamId) {
7347
+ if (!teamId?.trim()) {
7348
+ throw new KadoaSdkException("teamId is required", {
7349
+ code: "VALIDATION_ERROR"
7350
+ });
7351
+ }
7352
+ await this._axiosInstance.post(
7353
+ "/v5/auth/active-team",
7354
+ { teamId },
7355
+ { baseURL: this._baseUrl }
7356
+ );
7357
+ }
7292
7358
  /**
7293
7359
  * Dispose of the client and clean up resources
7294
7360
  */