@hatchet-dev/typescript-sdk 1.37.0 → 1.39.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.
Files changed (34) hide show
  1. package/clients/rest/generated/Api.d.ts +62 -1
  2. package/clients/rest/generated/Api.js +50 -0
  3. package/clients/rest/generated/data-contracts.d.ts +146 -15
  4. package/clients/rest/generated/data-contracts.js +8 -1
  5. package/clients/streams/rpc.d.ts +8 -0
  6. package/clients/streams/rpc.js +14 -0
  7. package/clients/transport/fetch-transport.js +18 -1
  8. package/core/client.d.ts +2 -1
  9. package/core/client.js +3 -1
  10. package/core/features/streams.d.ts +68 -3
  11. package/core/features/streams.js +206 -5
  12. package/core/index.d.ts +9 -5
  13. package/core/index.js +13 -7
  14. package/core/types.d.ts +20 -0
  15. package/dist/check-core-esm-exports.mjs +19 -0
  16. package/package.json +2 -2
  17. package/protoc/v1/streams.d.ts +18 -0
  18. package/protoc/v1/streams.js +115 -1
  19. package/protoc-es/v1/streams_pb.d.ts +35 -0
  20. package/protoc-es/v1/streams_pb.js +12 -2
  21. package/scripts/check-core-esm-exports.mjs +19 -0
  22. package/v1/client/features/streams.d.ts +12 -18
  23. package/v1/client/features/streams.js +15 -1
  24. package/v1/examples/durable-streams/run.d.ts +6 -0
  25. package/v1/examples/durable-streams/run.js +192 -0
  26. package/v1/examples/durable-streams/worker.d.ts +1 -0
  27. package/v1/examples/durable-streams/worker.js +24 -0
  28. package/v1/examples/durable-streams/workflow.d.ts +9 -0
  29. package/v1/examples/durable-streams/workflow.js +47 -0
  30. package/v1/examples/durable_eviction/graceful-worker.d.ts +1 -0
  31. package/v1/examples/durable_eviction/graceful-worker.js +49 -0
  32. package/v1/examples/e2e-worker.js +59 -56
  33. package/version.d.ts +1 -1
  34. package/version.js +1 -1
@@ -1,4 +1,4 @@
1
- import { APIErrors, APIMeta, AcceptInviteRequest, BulkCreateEventRequest, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, Events, FeatureFlagEvaluationResult, FeatureFlagId, ListAPIMetaIntegration, ListAPITokensResponse, ListSNSIntegrations, ListSlackWebhooks, OtelSpanList, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, ScheduleWorkflowRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerRunResult, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1AdditionalMetadataOperator, V1BranchDurableTaskRequest, V1BranchDurableTaskResponse, V1CELDebugRequest, V1CELDebugResponse, V1CancelTaskRequest, V1CancelledTasks, V1CreateFilterRequest, V1CreateWebhookRequest, V1DagChildren, V1DurableEventLogList, V1Event, V1EventList, V1Filter, V1FilterList, V1LogLineLevel, V1LogLineList, V1LogLineOrderByDirection, V1LogsPointMetrics, V1ReplayTaskRequest, V1ReplayedTasks, V1RestoreTaskResponse, V1RunningFilter, V1StreamPayloadRef, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookResponse, V1WebhookSourceName, V1WorkflowRunCount, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, WebhookWorkerCreateRequest, WebhookWorkerCreated, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, WorkerStatus, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunShape, WorkflowRunStatus, WorkflowRunStatusList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
1
+ import { APIErrors, APIMeta, AcceptInviteRequest, BulkCreateEventRequest, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, Events, FeatureFlagEvaluationResult, FeatureFlagId, ListAPIMetaIntegration, ListAPITokensResponse, ListSNSIntegrations, ListSlackWebhooks, OtelSpanList, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, ScheduleWorkflowRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerRunResult, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1AdditionalMetadataOperator, V1BranchDurableTaskRequest, V1BranchDurableTaskResponse, V1CELDebugRequest, V1CELDebugResponse, V1CancelTaskRequest, V1CancelledTasks, V1CreateFilterRequest, V1CreateServerlessEndpointRequest, V1CreateWebhookRequest, V1DagChildren, V1DurableEventLogList, V1Event, V1EventList, V1Filter, V1FilterList, V1LogLineLevel, V1LogLineList, V1LogLineOrderByDirection, V1LogsPointMetrics, V1ReplayTaskRequest, V1ReplayedTasks, V1RestoreTaskResponse, V1RunningFilter, V1ServerlessEndpoint, V1ServerlessEndpointList, V1StreamPayloadRef, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1UpdateServerlessEndpointRequest, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookResponse, V1WebhookSourceName, V1WorkflowRunCount, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, WebhookWorkerCreateRequest, WebhookWorkerCreated, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, WorkerStatus, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunShape, WorkflowRunStatus, WorkflowRunStatusList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
2
2
  import { HttpClient, RequestParams } from './http-client';
3
3
  export declare class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
4
4
  /**
@@ -777,6 +777,67 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
777
777
  * @secure
778
778
  */
779
779
  v1WebhookUpdate: (tenant: string, v1Webhook: string, data: V1UpdateWebhookRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1Webhook, any, {}>>;
780
+ /**
781
+ * @description Lists the serverless endpoints of a tenant.
782
+ *
783
+ * @tags Serverless
784
+ * @name V1ServerlessEndpointList
785
+ * @summary List serverless endpoints
786
+ * @request GET:/api/v1/stable/tenants/{tenant}/serverless/endpoints
787
+ * @secure
788
+ */
789
+ v1ServerlessEndpointList: (tenant: string, query?: {
790
+ /**
791
+ * The number to skip
792
+ * @format int64
793
+ */
794
+ offset?: number;
795
+ /**
796
+ * The number to limit by
797
+ * @format int64
798
+ */
799
+ limit?: number;
800
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1ServerlessEndpointList, any, {}>>;
801
+ /**
802
+ * @description Create a serverless endpoint
803
+ *
804
+ * @tags Serverless
805
+ * @name V1ServerlessEndpointCreate
806
+ * @summary Create a serverless endpoint
807
+ * @request POST:/api/v1/stable/tenants/{tenant}/serverless/endpoints
808
+ * @secure
809
+ */
810
+ v1ServerlessEndpointCreate: (tenant: string, data: V1CreateServerlessEndpointRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1ServerlessEndpoint, any, {}>>;
811
+ /**
812
+ * @description Get a serverless endpoint by its id
813
+ *
814
+ * @tags Serverless
815
+ * @name V1ServerlessEndpointGet
816
+ * @summary Get a serverless endpoint
817
+ * @request GET:/api/v1/stable/serverless/endpoints/{v1-serverless-endpoint}
818
+ * @secure
819
+ */
820
+ v1ServerlessEndpointGet: (v1ServerlessEndpoint: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1ServerlessEndpoint, any, {}>>;
821
+ /**
822
+ * @description Update a serverless endpoint
823
+ *
824
+ * @tags Serverless
825
+ * @name V1ServerlessEndpointUpdate
826
+ * @summary Update a serverless endpoint
827
+ * @request PATCH:/api/v1/stable/serverless/endpoints/{v1-serverless-endpoint}
828
+ * @secure
829
+ */
830
+ v1ServerlessEndpointUpdate: (v1ServerlessEndpoint: string, data: V1UpdateServerlessEndpointRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1ServerlessEndpoint, any, {}>>;
831
+ /**
832
+ * @description Delete a serverless endpoint
833
+ *
834
+ * @tags Serverless
835
+ * @name V1ServerlessEndpointDelete
836
+ * @summary Delete a serverless endpoint
837
+ * @request DELETE:/api/v1/stable/serverless/endpoints/{v1-serverless-endpoint}
838
+ * @secure
839
+ */
840
+ v1ServerlessEndpointDelete: (v1ServerlessEndpoint: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1ServerlessEndpoint, any, {}>>;
780
841
  /**
781
842
  * @description Evaluate a CEL expression against provided input data.
782
843
  *
@@ -405,6 +405,56 @@ class Api extends http_client_1.HttpClient {
405
405
  * @secure
406
406
  */
407
407
  this.v1WebhookUpdate = (tenant, v1Webhook, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/webhooks/${v1Webhook}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
408
+ /**
409
+ * @description Lists the serverless endpoints of a tenant.
410
+ *
411
+ * @tags Serverless
412
+ * @name V1ServerlessEndpointList
413
+ * @summary List serverless endpoints
414
+ * @request GET:/api/v1/stable/tenants/{tenant}/serverless/endpoints
415
+ * @secure
416
+ */
417
+ this.v1ServerlessEndpointList = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/serverless/endpoints`, method: 'GET', query: query, secure: true, format: 'json' }, params));
418
+ /**
419
+ * @description Create a serverless endpoint
420
+ *
421
+ * @tags Serverless
422
+ * @name V1ServerlessEndpointCreate
423
+ * @summary Create a serverless endpoint
424
+ * @request POST:/api/v1/stable/tenants/{tenant}/serverless/endpoints
425
+ * @secure
426
+ */
427
+ this.v1ServerlessEndpointCreate = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/serverless/endpoints`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
428
+ /**
429
+ * @description Get a serverless endpoint by its id
430
+ *
431
+ * @tags Serverless
432
+ * @name V1ServerlessEndpointGet
433
+ * @summary Get a serverless endpoint
434
+ * @request GET:/api/v1/stable/serverless/endpoints/{v1-serverless-endpoint}
435
+ * @secure
436
+ */
437
+ this.v1ServerlessEndpointGet = (v1ServerlessEndpoint, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/serverless/endpoints/${v1ServerlessEndpoint}`, method: 'GET', secure: true, format: 'json' }, params));
438
+ /**
439
+ * @description Update a serverless endpoint
440
+ *
441
+ * @tags Serverless
442
+ * @name V1ServerlessEndpointUpdate
443
+ * @summary Update a serverless endpoint
444
+ * @request PATCH:/api/v1/stable/serverless/endpoints/{v1-serverless-endpoint}
445
+ * @secure
446
+ */
447
+ this.v1ServerlessEndpointUpdate = (v1ServerlessEndpoint, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/serverless/endpoints/${v1ServerlessEndpoint}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
448
+ /**
449
+ * @description Delete a serverless endpoint
450
+ *
451
+ * @tags Serverless
452
+ * @name V1ServerlessEndpointDelete
453
+ * @summary Delete a serverless endpoint
454
+ * @request DELETE:/api/v1/stable/serverless/endpoints/{v1-serverless-endpoint}
455
+ * @secure
456
+ */
457
+ this.v1ServerlessEndpointDelete = (v1ServerlessEndpoint, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/serverless/endpoints/${v1ServerlessEndpoint}`, method: 'DELETE', secure: true, format: 'json' }, params));
408
458
  /**
409
459
  * @description Evaluate a CEL expression against provided input data.
410
460
  *
@@ -191,6 +191,11 @@ export declare enum V1CELDebugResponseStatus {
191
191
  SUCCESS = "SUCCESS",
192
192
  ERROR = "ERROR"
193
193
  }
194
+ /** The kind of serverless endpoint. GENERIC_HTTP is any HTTPS endpoint that implements the serverless endpoint contract; CLOUDFLARE_WORKERS applies the Cloudflare Workers runtime constraints on top of it. */
195
+ export declare enum V1ServerlessEndpointKind {
196
+ GENERIC_HTTP = "GENERIC_HTTP",
197
+ CLOUDFLARE_WORKERS = "CLOUDFLARE_WORKERS"
198
+ }
194
199
  export declare enum V1WebhookHMACEncoding {
195
200
  HEX = "HEX",
196
201
  BASE64 = "BASE64",
@@ -1129,6 +1134,130 @@ export interface V1UpdateWebhookRequest {
1129
1134
  /** Whether to return the triggered event as the response payload when this webhook is triggered */
1130
1135
  returnEventAsResponsePayload?: boolean;
1131
1136
  }
1137
+ /** The health of the endpoint as last observed by the serverless operator. Written on state transitions only, so changedAt is the time the endpoint last flipped between healthy and unhealthy. */
1138
+ export interface V1ServerlessEndpointStatus {
1139
+ /** Whether the last healthcheck succeeded. Absent until the operator has polled the endpoint at least once. */
1140
+ healthy?: boolean;
1141
+ /** The error from the last failed healthcheck, if the endpoint is unhealthy. */
1142
+ error?: string;
1143
+ /**
1144
+ * When the healthy flag last changed.
1145
+ * @format date-time
1146
+ */
1147
+ changedAt?: string;
1148
+ /** The action ids the operator registered for this endpoint from its last healthcheck, as the endpoint declared them. Several endpoints of a tenant may register the same action; each then serves it. */
1149
+ registeredActions: string[];
1150
+ }
1151
+ export interface V1ServerlessEndpoint {
1152
+ metadata: APIResourceMeta;
1153
+ /**
1154
+ * The ID of the tenant that owns this endpoint.
1155
+ * @format uuid
1156
+ */
1157
+ tenantId: string;
1158
+ /** The name of the endpoint. Unique within the tenant. */
1159
+ name: string;
1160
+ /** The kind of serverless endpoint. GENERIC_HTTP is any HTTPS endpoint that implements the serverless endpoint contract; CLOUDFLARE_WORKERS applies the Cloudflare Workers runtime constraints on top of it. */
1161
+ kind: V1ServerlessEndpointKind;
1162
+ /** The HTTPS URL (port 443) polled periodically to discover the workflows this endpoint serves. */
1163
+ healthcheckUrl: string;
1164
+ /** The HTTPS URL (port 443) that assigned tasks are delivered to. */
1165
+ triggerUrl: string;
1166
+ /**
1167
+ * The per-request timeout backstop for trigger requests, in seconds.
1168
+ * @format int32
1169
+ */
1170
+ requestTimeoutSeconds: number;
1171
+ /**
1172
+ * How often the healthcheck URL is polled, in seconds.
1173
+ * @format int32
1174
+ */
1175
+ pollIntervalSeconds: number;
1176
+ /**
1177
+ * How long a trigger request may block waiting for a durable result before the operator falls back to the websocket durable protocol, in milliseconds.
1178
+ * @format int32
1179
+ */
1180
+ inlineWaitBudgetMs: number;
1181
+ /** Worker labels applied to the connection-backed worker the operator creates for this endpoint. */
1182
+ labels: Record<string, any>;
1183
+ /** Whether the operator polls and dispatches to this endpoint. */
1184
+ enabled: boolean;
1185
+ /** The health of the endpoint as last observed by the serverless operator. Written on state transitions only, so changedAt is the time the endpoint last flipped between healthy and unhealthy. */
1186
+ status: V1ServerlessEndpointStatus;
1187
+ }
1188
+ export interface V1ServerlessEndpointList {
1189
+ pagination?: PaginationResponse;
1190
+ rows?: V1ServerlessEndpoint[];
1191
+ }
1192
+ export interface V1CreateServerlessEndpointRequest {
1193
+ /** The name of the endpoint. Unique within the tenant. */
1194
+ name: string;
1195
+ /** The kind of serverless endpoint. GENERIC_HTTP is any HTTPS endpoint that implements the serverless endpoint contract; CLOUDFLARE_WORKERS applies the Cloudflare Workers runtime constraints on top of it. */
1196
+ kind?: V1ServerlessEndpointKind;
1197
+ /** The HTTPS URL (port 443) polled periodically to discover the workflows this endpoint serves. */
1198
+ healthcheckUrl: string;
1199
+ /** The HTTPS URL (port 443) that assigned tasks are delivered to. */
1200
+ triggerUrl: string;
1201
+ /**
1202
+ * The secret used to HMAC-sign requests delivered to the endpoint. At least 32 characters. Write-only: it is stored encrypted and never returned in responses.
1203
+ * @minLength 32
1204
+ */
1205
+ signingSecret: string;
1206
+ /**
1207
+ * The per-request timeout backstop for trigger requests, in seconds. Defaults to 60.
1208
+ * @format int32
1209
+ */
1210
+ requestTimeoutSeconds?: number;
1211
+ /**
1212
+ * How often the healthcheck URL is polled, in seconds. Defaults to 30.
1213
+ * @format int32
1214
+ */
1215
+ pollIntervalSeconds?: number;
1216
+ /**
1217
+ * The inline wait budget for durable results, in milliseconds. Defaults to 5000.
1218
+ * @format int32
1219
+ */
1220
+ inlineWaitBudgetMs?: number;
1221
+ /** Worker labels applied to the worker the operator creates for this endpoint. */
1222
+ labels?: Record<string, any>;
1223
+ /** Whether the operator polls and dispatches to this endpoint. Defaults to true. */
1224
+ enabled?: boolean;
1225
+ }
1226
+ /** Fields to update on a serverless endpoint. Omitted fields are left unchanged. */
1227
+ export interface V1UpdateServerlessEndpointRequest {
1228
+ /** The name of the endpoint. Unique within the tenant. */
1229
+ name?: string;
1230
+ /** The kind of serverless endpoint. GENERIC_HTTP is any HTTPS endpoint that implements the serverless endpoint contract; CLOUDFLARE_WORKERS applies the Cloudflare Workers runtime constraints on top of it. */
1231
+ kind?: V1ServerlessEndpointKind;
1232
+ /** The HTTPS URL (port 443) polled periodically to discover the workflows this endpoint serves. */
1233
+ healthcheckUrl?: string;
1234
+ /** The HTTPS URL (port 443) that assigned tasks are delivered to. */
1235
+ triggerUrl?: string;
1236
+ /**
1237
+ * A new secret used to HMAC-sign requests delivered to the endpoint. At least 32 characters. Provide a value to rotate the secret; it is never returned in responses.
1238
+ * @minLength 32
1239
+ */
1240
+ signingSecret?: string;
1241
+ /**
1242
+ * The per-request timeout backstop for trigger requests, in seconds.
1243
+ * @format int32
1244
+ */
1245
+ requestTimeoutSeconds?: number;
1246
+ /**
1247
+ * How often the healthcheck URL is polled, in seconds.
1248
+ * @format int32
1249
+ */
1250
+ pollIntervalSeconds?: number;
1251
+ /**
1252
+ * The inline wait budget for durable results, in milliseconds.
1253
+ * @format int32
1254
+ */
1255
+ inlineWaitBudgetMs?: number;
1256
+ /** Worker labels applied to the worker the operator creates for this endpoint. Replaces the existing labels. */
1257
+ labels?: Record<string, any>;
1258
+ /** Whether the operator polls and dispatches to this endpoint. */
1259
+ enabled?: boolean;
1260
+ }
1132
1261
  export interface V1CELDebugRequest {
1133
1262
  /** The CEL expression to evaluate */
1134
1263
  expression: string;
@@ -1661,6 +1790,8 @@ export interface Workflow {
1661
1790
  jobs?: Job[];
1662
1791
  /** The tenant id of the workflow. */
1663
1792
  tenantId: string;
1793
+ /** The event and cron triggers declared on the latest workflow version. */
1794
+ triggers?: WorkflowTriggers;
1664
1795
  }
1665
1796
  export interface WorkflowVersionMeta {
1666
1797
  metadata: APIResourceMeta;
@@ -1704,6 +1835,21 @@ export interface Job {
1704
1835
  /** The timeout of the job. */
1705
1836
  timeout?: string;
1706
1837
  }
1838
+ export interface WorkflowTriggerEventRef {
1839
+ parent_id?: string;
1840
+ event_key?: string;
1841
+ }
1842
+ export interface WorkflowTriggerCronRef {
1843
+ parent_id?: string;
1844
+ cron?: string;
1845
+ }
1846
+ export interface WorkflowTriggers {
1847
+ metadata?: APIResourceMeta;
1848
+ workflow_version_id?: string;
1849
+ tenant_id?: string;
1850
+ events?: WorkflowTriggerEventRef[];
1851
+ crons?: WorkflowTriggerCronRef[];
1852
+ }
1707
1853
  export interface WorkflowList {
1708
1854
  metadata?: APIResourceMeta;
1709
1855
  rows?: Workflow[];
@@ -1904,21 +2050,6 @@ export interface WorkflowConcurrency {
1904
2050
  /** An action which gets the concurrency group for the WorkflowRun. */
1905
2051
  getConcurrencyGroup: string;
1906
2052
  }
1907
- export interface WorkflowTriggerEventRef {
1908
- parent_id?: string;
1909
- event_key?: string;
1910
- }
1911
- export interface WorkflowTriggerCronRef {
1912
- parent_id?: string;
1913
- cron?: string;
1914
- }
1915
- export interface WorkflowTriggers {
1916
- metadata?: APIResourceMeta;
1917
- workflow_version_id?: string;
1918
- tenant_id?: string;
1919
- events?: WorkflowTriggerEventRef[];
1920
- crons?: WorkflowTriggerCronRef[];
1921
- }
1922
2053
  export interface ConcurrencySetting {
1923
2054
  /**
1924
2055
  * The maximum number of concurrent workflow runs.
@@ -11,7 +11,8 @@
11
11
  * ---------------------------------------------------------------
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.V1TaskStatus = exports.V1WorkflowType = exports.V1TaskEventType = exports.V1LogLineLevel = exports.V1LogLineOrderByDirection = exports.V1AdditionalMetadataOperator = exports.V1RunningFilter = exports.V1DurableEventLogKind = exports.V1DurableWaitConditionKind = exports.OtelSpanKind = exports.OtelStatusCode = exports.TenantVersion = exports.TenantEnvironment = exports.V1WebhookSourceName = exports.V1WebhookAuthType = exports.V1WebhookHMACAlgorithm = exports.V1WebhookHMACEncoding = exports.V1CELDebugResponseStatus = exports.TenantResource = exports.TenantMemberRole = exports.WorkflowRunStatus = exports.EventOrderByField = exports.EventOrderByDirection = exports.RateLimitOrderByField = exports.RateLimitOrderByDirection = exports.WorkflowPauseScheduledCronRunQueueBehavior = exports.ScheduledWorkflowsMethod = exports.ScheduledWorkflowsOrderByField = exports.WorkflowRunOrderByDirection = exports.ScheduledRunStatus = exports.CronWorkflowsMethod = exports.CronWorkflowsOrderByField = exports.ConcurrencyLimitStrategy = exports.ConcurrencyScope = exports.StepRunStatus = exports.JobRunStatus = exports.StepRunEventReason = exports.StepRunEventSeverity = exports.WorkflowKind = exports.WorkflowRunOrderByField = exports.WorkerStatus = exports.WorkerType = exports.WorkerRuntimeSDKs = exports.WebhookWorkerRequestMethod = exports.FeatureFlagId = exports.PullRequestState = exports.LogLineLevel = exports.LogLineOrderByField = exports.LogLineOrderByDirection = exports.V1TaskRunStatus = void 0;
14
+ exports.V1WorkflowType = exports.V1TaskEventType = exports.V1LogLineLevel = exports.V1LogLineOrderByDirection = exports.V1AdditionalMetadataOperator = exports.V1RunningFilter = exports.V1DurableEventLogKind = exports.V1DurableWaitConditionKind = exports.OtelSpanKind = exports.OtelStatusCode = exports.TenantVersion = exports.TenantEnvironment = exports.V1WebhookSourceName = exports.V1WebhookAuthType = exports.V1WebhookHMACAlgorithm = exports.V1WebhookHMACEncoding = exports.V1ServerlessEndpointKind = exports.V1CELDebugResponseStatus = exports.TenantResource = exports.TenantMemberRole = exports.WorkflowRunStatus = exports.EventOrderByField = exports.EventOrderByDirection = exports.RateLimitOrderByField = exports.RateLimitOrderByDirection = exports.WorkflowPauseScheduledCronRunQueueBehavior = exports.ScheduledWorkflowsMethod = exports.ScheduledWorkflowsOrderByField = exports.WorkflowRunOrderByDirection = exports.ScheduledRunStatus = exports.CronWorkflowsMethod = exports.CronWorkflowsOrderByField = exports.ConcurrencyLimitStrategy = exports.ConcurrencyScope = exports.StepRunStatus = exports.JobRunStatus = exports.StepRunEventReason = exports.StepRunEventSeverity = exports.WorkflowKind = exports.WorkflowRunOrderByField = exports.WorkerStatus = exports.WorkerType = exports.WorkerRuntimeSDKs = exports.WebhookWorkerRequestMethod = exports.FeatureFlagId = exports.PullRequestState = exports.LogLineLevel = exports.LogLineOrderByField = exports.LogLineOrderByDirection = exports.V1TaskRunStatus = void 0;
15
+ exports.V1TaskStatus = void 0;
15
16
  var V1TaskRunStatus;
16
17
  (function (V1TaskRunStatus) {
17
18
  V1TaskRunStatus["PENDING"] = "PENDING";
@@ -238,6 +239,12 @@ var V1CELDebugResponseStatus;
238
239
  V1CELDebugResponseStatus["SUCCESS"] = "SUCCESS";
239
240
  V1CELDebugResponseStatus["ERROR"] = "ERROR";
240
241
  })(V1CELDebugResponseStatus || (exports.V1CELDebugResponseStatus = V1CELDebugResponseStatus = {}));
242
+ /** The kind of serverless endpoint. GENERIC_HTTP is any HTTPS endpoint that implements the serverless endpoint contract; CLOUDFLARE_WORKERS applies the Cloudflare Workers runtime constraints on top of it. */
243
+ var V1ServerlessEndpointKind;
244
+ (function (V1ServerlessEndpointKind) {
245
+ V1ServerlessEndpointKind["GENERIC_HTTP"] = "GENERIC_HTTP";
246
+ V1ServerlessEndpointKind["CLOUDFLARE_WORKERS"] = "CLOUDFLARE_WORKERS";
247
+ })(V1ServerlessEndpointKind || (exports.V1ServerlessEndpointKind = V1ServerlessEndpointKind = {}));
241
248
  var V1WebhookHMACEncoding;
242
249
  (function (V1WebhookHMACEncoding) {
243
250
  V1WebhookHMACEncoding["HEX"] = "HEX";
@@ -0,0 +1,8 @@
1
+ import { V1StreamsClient } from '../../protoc/v1/streams';
2
+ import type { Transport } from '../transport/transport';
3
+ /**
4
+ * The v1 `V1Streams` client, every RPC of the generated `V1StreamsClient` interface, served
5
+ * by a Connect client on the given transport. `Subscribe` is a server stream, which the unary
6
+ * transport does not serve: calling it throws.
7
+ */
8
+ export declare function createV1StreamsRpc(transport: Transport): V1StreamsClient;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createV1StreamsRpc = createV1StreamsRpc;
4
+ const streams_1 = require("../../protoc/v1/streams");
5
+ const streams_pb_1 = require("../../protoc-es/v1/streams_pb");
6
+ const ts_proto_client_1 = require("../transport/ts-proto-client");
7
+ /**
8
+ * The v1 `V1Streams` client, every RPC of the generated `V1StreamsClient` interface, served
9
+ * by a Connect client on the given transport. `Subscribe` is a server stream, which the unary
10
+ * transport does not serve: calling it throws.
11
+ */
12
+ function createV1StreamsRpc(transport) {
13
+ return (0, ts_proto_client_1.createTsProtoClient)(streams_1.V1StreamsDefinition, streams_pb_1.V1Streams, transport);
14
+ }
@@ -82,7 +82,24 @@ function createFetchTransport(options) {
82
82
  baseUrl: resolveServerUrl(options),
83
83
  useBinaryFormat: true,
84
84
  interceptors: [(0, transport_1.createAuthInterceptor)(options.token)],
85
- fetch: limitMessageSizes(send, limits),
85
+ fetch: limitMessageSizes(withoutRedirects(send), limits),
86
+ });
87
+ }
88
+ /**
89
+ * Wraps a `fetch` so a redirect fails the call instead of being followed. connect-web asks
90
+ * for this with `redirect: 'error'`, which Cloudflare Workers reject outright ("Invalid
91
+ * redirect value"), so the request goes out with `redirect: 'manual'` and a redirect
92
+ * response (a 3xx status, or the opaque redirect a browser hands back) is turned into the
93
+ * error connect-web would have raised. The engine never redirects; one means `serverUrl`
94
+ * points at something in front of it.
95
+ */
96
+ function withoutRedirects(send) {
97
+ return (input, init) => __awaiter(this, void 0, void 0, function* () {
98
+ const response = yield send(input, Object.assign(Object.assign({}, init), { redirect: 'manual' }));
99
+ if (response.type === 'opaqueredirect' || (response.status >= 300 && response.status < 400)) {
100
+ throw new connect_1.ConnectError(`the server answered with a redirect (${response.status || 'opaque'}); serverUrl must point at the engine itself`, connect_1.Code.Unavailable);
101
+ }
102
+ return response;
86
103
  });
87
104
  }
88
105
  /**
package/core/client.d.ts CHANGED
@@ -55,11 +55,12 @@ export declare class HatchetCore {
55
55
  readonly rateLimits: RateLimitsClient;
56
56
  /** Writes task run log lines. */
57
57
  readonly logs: LogsClient;
58
- /** Publishes task run stream chunks. */
58
+ /** Publishes task run stream chunks and durable stream topics. */
59
59
  readonly streams: StreamsClient;
60
60
  private readonly workflowsRpc;
61
61
  private readonly adminRpc;
62
62
  private readonly eventsRpc;
63
+ private readonly streamsRpc;
63
64
  constructor(config: CoreClientConfig);
64
65
  /** The same as `new HatchetCore(config)`, mirroring the Node client's `init`. */
65
66
  static init(config: CoreClientConfig): HatchetCore;
package/core/client.js CHANGED
@@ -20,6 +20,7 @@ const fetch_transport_1 = require("../clients/transport/fetch-transport");
20
20
  const rpc_1 = require("../clients/admin/rpc");
21
21
  const trigger_request_1 = require("../clients/admin/trigger-request");
22
22
  const rpc_2 = require("../clients/event/rpc");
23
+ const rpc_3 = require("../clients/streams/rpc");
23
24
  const workflows_1 = require("../protoc/workflows");
24
25
  const token_1 = require("../util/config-loader/token");
25
26
  const batch_1 = require("../util/batch");
@@ -81,13 +82,14 @@ class HatchetCore {
81
82
  this.workflowsRpc = (0, rpc_1.createWorkflowsRpc)(this.transport);
82
83
  this.adminRpc = (0, rpc_1.createV1AdminRpc)(this.transport);
83
84
  this.eventsRpc = (0, rpc_2.createEventsRpc)(this.transport);
85
+ this.streamsRpc = (0, rpc_3.createV1StreamsRpc)(this.transport);
84
86
  const shared = { logger: this.logger, namespace, retrier: config.retrier };
85
87
  this.events = new events_1.EventsClient(Object.assign({ rpc: this.eventsRpc }, shared));
86
88
  this.runs = new runs_1.RunsClient(this.adminRpc);
87
89
  this.workflows = new workflows_2.WorkflowsClient(Object.assign({ rpc: this.adminRpc }, shared));
88
90
  this.rateLimits = new rate_limits_1.RateLimitsClient(Object.assign({ rpc: this.workflowsRpc }, shared));
89
91
  this.logs = new logs_1.LogsClient(this.eventsRpc);
90
- this.streams = new streams_1.StreamsClient(this.eventsRpc);
92
+ this.streams = new streams_1.StreamsClient({ events: this.eventsRpc, streams: this.streamsRpc });
91
93
  }
92
94
  /** The same as `new HatchetCore(config)`, mirroring the Node client's `init`. */
93
95
  static init(config) {
@@ -1,11 +1,76 @@
1
1
  import type { EventsServiceClient, PutStreamEventResponse } from '../../protoc/events/events';
2
- /** Publishes stream chunks from a task run, the way `ctx.putStream` does from a worker. */
2
+ import type { V1StreamsClient } from '../../protoc/v1/streams';
3
+ import type { StreamCallOptions, StreamTopicMetadata } from '../types';
4
+ /**
5
+ * The largest payload one `publish` carries: the engine's limit for a payload sent inline
6
+ * (`MaxStreamMessagePayloadBytes`). The Node client uploads larger payloads over its REST
7
+ * client first; this client has none, so it rejects them.
8
+ */
9
+ export declare const MAX_STREAM_MESSAGE_BYTES: number;
10
+ export interface StreamsClientDeps {
11
+ events: EventsServiceClient;
12
+ streams: V1StreamsClient;
13
+ }
14
+ /**
15
+ * How many (namespace, topic) producers the client remembers. A topic past the cap starts
16
+ * over with a new producer id, which the engine orders after the old one, so correctness
17
+ * does not depend on the cap; it only bounds memory for clients that publish to many
18
+ * short-lived topics.
19
+ */
20
+ export declare const MAX_TRACKED_TOPICS = 1024;
21
+ /**
22
+ * Task run streams and durable stream topics.
23
+ *
24
+ * `put` publishes a chunk on a task run's stream, the way `ctx.putStream` does from a worker.
25
+ * `publish`, `reset` and `topicMetadata` are the Node client's durable topic calls
26
+ * (`hatchet.streams`), with the same names and options. `events()` is not here: it is a
27
+ * server stream, which the unary transport does not carry. Read a topic with the Node client
28
+ * (`hatchet.streams.events(topic)`), or from a serverless task over the operator socket once
29
+ * the operator relays the subscription.
30
+ */
3
31
  export declare class StreamsClient {
4
- private readonly rpc;
5
- constructor(rpc: EventsServiceClient);
32
+ /** Per (namespace, topic); the sequence number only advances after a publish succeeds. */
33
+ private readonly producers;
34
+ /**
35
+ * Serializes publishes per (namespace, topic) so two never share a sequence number. The
36
+ * stored promise always resolves, so one failure does not block later calls.
37
+ */
38
+ private readonly publishChains;
39
+ private readonly events;
40
+ private readonly streams;
41
+ /**
42
+ * Takes the events and durable streams services, or only the events service, which
43
+ * serves `put` and leaves the durable stream calls unavailable.
44
+ */
45
+ constructor(deps: StreamsClientDeps | EventsServiceClient);
46
+ private durable;
6
47
  /**
7
48
  * Publishes one chunk on a task run's stream. `index` orders chunks that are published
8
49
  * concurrently. Resolves once the engine has the chunk.
9
50
  */
10
51
  put(taskRunExternalId: string, data: string | Uint8Array, index?: number): Promise<PutStreamEventResponse>;
52
+ /**
53
+ * Publishes a message to a durable topic and resolves once it is stored. A client's
54
+ * messages to a topic are delivered in the order `publish` was called. A payload over
55
+ * `MAX_STREAM_MESSAGE_BYTES` rejects with a `HatchetError` before anything is sent.
56
+ * @param topic - the topic to publish to
57
+ * @param message - the message payload
58
+ * @param options - optional namespace override and abort signal
59
+ */
60
+ publish(topic: string, message: Uint8Array | string, options?: StreamCallOptions): Promise<void>;
61
+ /**
62
+ * Describes a topic's retained messages. Rejects with a `ConnectError` of code `NotFound`
63
+ * for a topic nothing was published to.
64
+ * @param topic - the topic to describe
65
+ * @param options - optional namespace override and abort signal
66
+ */
67
+ topicMetadata(topic: string, options?: Pick<StreamCallOptions, 'namespace' | 'signal'>): Promise<StreamTopicMetadata>;
68
+ /**
69
+ * Makes `events()` calls without a cursor start after the topic's latest message. Readers
70
+ * already iterating, and any call with a cursor, are unaffected.
71
+ * @param topic - the topic to reset
72
+ * @param options - optional namespace override and abort signal
73
+ */
74
+ reset(topic: string, options?: Pick<StreamCallOptions, 'namespace' | 'signal'>): Promise<void>;
75
+ private publishOrdered;
11
76
  }