@spooled/sdk 1.1.0 → 1.2.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_MpLQYY.d.cts → index-BzfyWvfc.d.cts} +105 -72
- package/dist/{index-D_MpLQYY.d.ts → index-BzfyWvfc.d.ts} +105 -72
- package/dist/index.cjs +179 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +179 -31
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-
|
|
2
|
-
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-BzfyWvfc.cjs';
|
|
2
|
+
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as CheckEmailResponse, G as CheckSlugResponse, H as CircuitBreaker, I as CircuitBreakerConfig, J as CircuitState, K as ClaimJobsParams, L as ClaimJobsResult, M as ClaimedJob, N as CompleteJobParams, O as CreateApiKeyParams, P as CreateApiKeyResponse, Q as CreateBillingPortalParams, T as CreateBillingPortalResponse, U as CreateJobParams, V as CreateJobResult, W as CreateOrganizationParams, X as CreateOrganizationResponse, Y as CreateOutgoingWebhookParams, Z as CreateScheduleParams, _ as CreateScheduleResponse, $ as CreateWorkflowParams, a0 as CreateWorkflowResponse, a1 as CurrentUserResponse, a2 as DEFAULT_CONFIG, a3 as DashboardData, a4 as DashboardResource, a5 as DashboardWorkerSummary, a6 as DebugFn, a7 as DependencyInfo, a8 as DependencyMode, a9 as FailJobParams, aa as GrpcClientOptions, ab as GrpcCompleteJobParams, ac as GrpcCompleteJobResponse, ad as GrpcCompleteRequest, ae as GrpcCompleteResponse, af as GrpcDequeueJobParams, ag as GrpcDequeueJobResponse, ah as GrpcDequeueRequest, ai as GrpcDequeueResponse, aj as GrpcDeregisterRequest, ak as GrpcDeregisterResponse, al as GrpcEnqueueJobParams, am as GrpcEnqueueJobResponse, an as GrpcEnqueueRequest, ao as GrpcEnqueueResponse, ap as GrpcErrorResponse, aq as GrpcFailJobParams, ar as GrpcFailJobResponse, as as GrpcFailRequest, at as GrpcFailResponse, au as GrpcGetJobRequest, av as GrpcGetJobResponse, aw as GrpcGetQueueStatsRequest, ax as GrpcGetQueueStatsResponse, ay as GrpcGetQueueStatsResponse_Legacy, az as GrpcHeartbeatParams, aA as GrpcHeartbeatRequest, aB as GrpcHeartbeatResponse, aC as GrpcHeartbeatResponse_Legacy, aD as GrpcJob, aE as GrpcJobStatus, aF as GrpcJobStatusNumber, aG as GrpcProcessRequest, aH as GrpcProcessResponse, aI as GrpcQueueOperations, aJ as GrpcRegisterWorkerParams, aK as GrpcRegisterWorkerRequest, aL as GrpcRegisterWorkerResponse, aM as GrpcRegisterWorkerResponse_Legacy, aN as GrpcRenewLeaseParams, aO as GrpcRenewLeaseRequest, aP as GrpcRenewLeaseResponse, aQ as GrpcRenewLeaseResponse_Legacy, aR as GrpcStreamJobsRequest, aS as GrpcTimestamp, aT as GrpcWorkerOperations, aU as HealthResource, aV as HealthResponse, aW as HeartbeatEvent, aX as HeartbeatJobParams, aY as HttpClient, aZ as IngestCustomWebhookParams, a_ as IngestCustomWebhookResponse, a$ as IngestGitHubWebhookOptions, b0 as IngestStripeWebhookOptions, b1 as InitialApiKey, b2 as Job, b3 as JobCompletedEvent, b4 as JobContext, b5 as JobCreatedEvent, b6 as JobFailedEvent, b7 as JobHandler, b8 as JobProgressEvent, b9 as JobResult, ba as JobStartedEvent, bb as JobStats, bc as JobStatus, bd as JobStatusChangedEvent, be as JobStream, bf as JobSummary, bg as JobSummaryStats, bh as JobWithDependencies, bi as JobsResource, bj as JsonArray, bk as JsonObject, bl as JsonPrimitive, bm as JsonValue, bn as ListDlqParams, bo as ListJobsParams, bp as ListParams, bq as ListSchedulesParams, br as ListWorkflowsParams, bs as LoginParams, bt as LoginResponse, bu as MetricsResource, bv as Organization, bw as OrganizationMember, bx as OrganizationSummary, by as OrganizationUsage, bz as OrganizationsResource, bA as OutgoingWebhook, bB as OutgoingWebhookDelivery, bC as PaginatedResponse, bD as PaginationParams, bE as PauseQueueResponse, bF as PlanCount, bG as PlanLimits, bH as PlanTier, bI as ProcessJobsStream, bJ as PurgeDlqParams, bK as PurgeDlqResponse, bL as QueueConfig, bM as QueueConfigSummary, bN as QueuePausedEvent, bO as QueueResumedEvent, bP as QueueStats, bQ as QueueSummary, bR as QueuesResource, bS as RealtimeEventData, bT as RecentActivity, bU as RefreshTokenParams, bV as RefreshTokenResponse, bW as RegisterWorkerParams, bX as RegisterWorkerResponse, bY as ResolvedConfig, bZ as ResourceUsage, b_ as ResumeQueueResponse, b$ as RetryDlqParams, c0 as RetryDlqResponse, c1 as SDK_VERSION, c2 as Schedule, c3 as ScheduleRun, c4 as ScheduleRunStatus, c5 as ScheduleTriggeredEvent, c6 as SchedulesResource, c7 as SpooledClient, c8 as SpooledClientConfig, c9 as SpooledGrpcClient, ca as SpooledRealtime, cb as SpooledRealtimeOptions, cc as SpooledWorker, cd as SpooledWorkerOptions, ce as StartEmailLoginResponse, cf as StreamOptions, cg as SystemInfo, ch as TestWebhookResponse, ci as TokenClaims, cj as TriggerScheduleResponse, ck as UpdateApiKeyParams, cl as UpdateOrganizationParams, cm as UpdateOutgoingWebhookParams, cn as UpdateQueueConfigParams, co as UpdateScheduleParams, cp as UsageItem, cq as UsageWarning, cr as ValidateTokenParams, cs as ValidateTokenResponse, ct as WebhookDeliveryStatus, cu as WebhookEventType, cv as WebhookIngestionResource, cw as WebhookTokenResponse, cx as WebhooksResource, cy as Worker, cz as WorkerDeregisteredEvent, cA as WorkerEvent, cB as WorkerEventData, cC as WorkerHeartbeatParams, cD as WorkerRegisteredEvent, cE as WorkerState, cF as WorkerStatus, cG as WorkerSummary, cH as WorkersResource, cI as Workflow, cJ as WorkflowJob, cK as WorkflowJobDefinition, cL as WorkflowJobStatus, cM as WorkflowResponse, cN as WorkflowStatus, cO as WorkflowsResource, cP as asyncIterableFromStream, cQ as createCircuitBreaker, cR as createClient, cS as createHttpClient, cT as createJobStream, cU as createPaginatedResponse, cV as createProcessJobsStream, cW as dateToTimestamp, cX as resolveConfig, cY as timestampToDate, cZ as validateConfig } from './index-BzfyWvfc.cjs';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-
|
|
2
|
-
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-BzfyWvfc.js';
|
|
2
|
+
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as CheckEmailResponse, G as CheckSlugResponse, H as CircuitBreaker, I as CircuitBreakerConfig, J as CircuitState, K as ClaimJobsParams, L as ClaimJobsResult, M as ClaimedJob, N as CompleteJobParams, O as CreateApiKeyParams, P as CreateApiKeyResponse, Q as CreateBillingPortalParams, T as CreateBillingPortalResponse, U as CreateJobParams, V as CreateJobResult, W as CreateOrganizationParams, X as CreateOrganizationResponse, Y as CreateOutgoingWebhookParams, Z as CreateScheduleParams, _ as CreateScheduleResponse, $ as CreateWorkflowParams, a0 as CreateWorkflowResponse, a1 as CurrentUserResponse, a2 as DEFAULT_CONFIG, a3 as DashboardData, a4 as DashboardResource, a5 as DashboardWorkerSummary, a6 as DebugFn, a7 as DependencyInfo, a8 as DependencyMode, a9 as FailJobParams, aa as GrpcClientOptions, ab as GrpcCompleteJobParams, ac as GrpcCompleteJobResponse, ad as GrpcCompleteRequest, ae as GrpcCompleteResponse, af as GrpcDequeueJobParams, ag as GrpcDequeueJobResponse, ah as GrpcDequeueRequest, ai as GrpcDequeueResponse, aj as GrpcDeregisterRequest, ak as GrpcDeregisterResponse, al as GrpcEnqueueJobParams, am as GrpcEnqueueJobResponse, an as GrpcEnqueueRequest, ao as GrpcEnqueueResponse, ap as GrpcErrorResponse, aq as GrpcFailJobParams, ar as GrpcFailJobResponse, as as GrpcFailRequest, at as GrpcFailResponse, au as GrpcGetJobRequest, av as GrpcGetJobResponse, aw as GrpcGetQueueStatsRequest, ax as GrpcGetQueueStatsResponse, ay as GrpcGetQueueStatsResponse_Legacy, az as GrpcHeartbeatParams, aA as GrpcHeartbeatRequest, aB as GrpcHeartbeatResponse, aC as GrpcHeartbeatResponse_Legacy, aD as GrpcJob, aE as GrpcJobStatus, aF as GrpcJobStatusNumber, aG as GrpcProcessRequest, aH as GrpcProcessResponse, aI as GrpcQueueOperations, aJ as GrpcRegisterWorkerParams, aK as GrpcRegisterWorkerRequest, aL as GrpcRegisterWorkerResponse, aM as GrpcRegisterWorkerResponse_Legacy, aN as GrpcRenewLeaseParams, aO as GrpcRenewLeaseRequest, aP as GrpcRenewLeaseResponse, aQ as GrpcRenewLeaseResponse_Legacy, aR as GrpcStreamJobsRequest, aS as GrpcTimestamp, aT as GrpcWorkerOperations, aU as HealthResource, aV as HealthResponse, aW as HeartbeatEvent, aX as HeartbeatJobParams, aY as HttpClient, aZ as IngestCustomWebhookParams, a_ as IngestCustomWebhookResponse, a$ as IngestGitHubWebhookOptions, b0 as IngestStripeWebhookOptions, b1 as InitialApiKey, b2 as Job, b3 as JobCompletedEvent, b4 as JobContext, b5 as JobCreatedEvent, b6 as JobFailedEvent, b7 as JobHandler, b8 as JobProgressEvent, b9 as JobResult, ba as JobStartedEvent, bb as JobStats, bc as JobStatus, bd as JobStatusChangedEvent, be as JobStream, bf as JobSummary, bg as JobSummaryStats, bh as JobWithDependencies, bi as JobsResource, bj as JsonArray, bk as JsonObject, bl as JsonPrimitive, bm as JsonValue, bn as ListDlqParams, bo as ListJobsParams, bp as ListParams, bq as ListSchedulesParams, br as ListWorkflowsParams, bs as LoginParams, bt as LoginResponse, bu as MetricsResource, bv as Organization, bw as OrganizationMember, bx as OrganizationSummary, by as OrganizationUsage, bz as OrganizationsResource, bA as OutgoingWebhook, bB as OutgoingWebhookDelivery, bC as PaginatedResponse, bD as PaginationParams, bE as PauseQueueResponse, bF as PlanCount, bG as PlanLimits, bH as PlanTier, bI as ProcessJobsStream, bJ as PurgeDlqParams, bK as PurgeDlqResponse, bL as QueueConfig, bM as QueueConfigSummary, bN as QueuePausedEvent, bO as QueueResumedEvent, bP as QueueStats, bQ as QueueSummary, bR as QueuesResource, bS as RealtimeEventData, bT as RecentActivity, bU as RefreshTokenParams, bV as RefreshTokenResponse, bW as RegisterWorkerParams, bX as RegisterWorkerResponse, bY as ResolvedConfig, bZ as ResourceUsage, b_ as ResumeQueueResponse, b$ as RetryDlqParams, c0 as RetryDlqResponse, c1 as SDK_VERSION, c2 as Schedule, c3 as ScheduleRun, c4 as ScheduleRunStatus, c5 as ScheduleTriggeredEvent, c6 as SchedulesResource, c7 as SpooledClient, c8 as SpooledClientConfig, c9 as SpooledGrpcClient, ca as SpooledRealtime, cb as SpooledRealtimeOptions, cc as SpooledWorker, cd as SpooledWorkerOptions, ce as StartEmailLoginResponse, cf as StreamOptions, cg as SystemInfo, ch as TestWebhookResponse, ci as TokenClaims, cj as TriggerScheduleResponse, ck as UpdateApiKeyParams, cl as UpdateOrganizationParams, cm as UpdateOutgoingWebhookParams, cn as UpdateQueueConfigParams, co as UpdateScheduleParams, cp as UsageItem, cq as UsageWarning, cr as ValidateTokenParams, cs as ValidateTokenResponse, ct as WebhookDeliveryStatus, cu as WebhookEventType, cv as WebhookIngestionResource, cw as WebhookTokenResponse, cx as WebhooksResource, cy as Worker, cz as WorkerDeregisteredEvent, cA as WorkerEvent, cB as WorkerEventData, cC as WorkerHeartbeatParams, cD as WorkerRegisteredEvent, cE as WorkerState, cF as WorkerStatus, cG as WorkerSummary, cH as WorkersResource, cI as Workflow, cJ as WorkflowJob, cK as WorkflowJobDefinition, cL as WorkflowJobStatus, cM as WorkflowResponse, cN as WorkflowStatus, cO as WorkflowsResource, cP as asyncIterableFromStream, cQ as createCircuitBreaker, cR as createClient, cS as createHttpClient, cT as createJobStream, cU as createPaginatedResponse, cV as createProcessJobsStream, cW as dateToTimestamp, cX as resolveConfig, cY as timestampToDate, cZ as validateConfig } from './index-BzfyWvfc.js';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -26,10 +26,10 @@ var DEFAULT_CONFIG = {
|
|
|
26
26
|
successThreshold: 3,
|
|
27
27
|
timeout: 3e4
|
|
28
28
|
},
|
|
29
|
-
userAgent: "@spooled/sdk-nodejs/1.
|
|
29
|
+
userAgent: "@spooled/sdk-nodejs/1.2.0",
|
|
30
30
|
autoRefreshToken: true
|
|
31
31
|
};
|
|
32
|
-
var SDK_VERSION = "1.
|
|
32
|
+
var SDK_VERSION = "1.2.0";
|
|
33
33
|
var API_VERSION = "v1";
|
|
34
34
|
var API_BASE_PATH = `/api/${API_VERSION}`;
|
|
35
35
|
function normalizeCredential(value) {
|
|
@@ -1055,21 +1055,28 @@ var AuthResource = class {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
/**
|
|
1057
1057
|
* Validate a token
|
|
1058
|
+
*
|
|
1059
|
+
* POST /auth/validate is `{ valid, error?, claims? }`. Claims use `org_id`
|
|
1060
|
+
* (camelCased `orgId`), not `organizationId`. Invalid tokens send `error`,
|
|
1061
|
+
* not `message`.
|
|
1058
1062
|
*/
|
|
1059
1063
|
async validate(params) {
|
|
1060
|
-
|
|
1064
|
+
const raw = await this.http.post(
|
|
1065
|
+
"/auth/validate",
|
|
1066
|
+
params
|
|
1067
|
+
);
|
|
1068
|
+
return mapValidate(raw);
|
|
1061
1069
|
}
|
|
1062
1070
|
/**
|
|
1063
|
-
* Start email-based login flow (sends
|
|
1071
|
+
* Start email-based login flow (sends a 6-digit code)
|
|
1064
1072
|
*/
|
|
1065
1073
|
async startEmailLogin(email) {
|
|
1066
|
-
return this.http.post(
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
);
|
|
1074
|
+
return this.http.post("/auth/email/start", {
|
|
1075
|
+
email
|
|
1076
|
+
});
|
|
1070
1077
|
}
|
|
1071
1078
|
/**
|
|
1072
|
-
* Check
|
|
1079
|
+
* Check whether an email is registered (GET /auth/check-email)
|
|
1073
1080
|
*/
|
|
1074
1081
|
async checkEmail(email) {
|
|
1075
1082
|
return this.http.get("/auth/check-email", {
|
|
@@ -1077,6 +1084,23 @@ var AuthResource = class {
|
|
|
1077
1084
|
});
|
|
1078
1085
|
}
|
|
1079
1086
|
};
|
|
1087
|
+
function mapValidate(raw) {
|
|
1088
|
+
const claims = raw.claims;
|
|
1089
|
+
const organizationId = claims?.organizationId ?? claims?.orgId;
|
|
1090
|
+
return {
|
|
1091
|
+
valid: raw.valid,
|
|
1092
|
+
message: raw.message ?? raw.error,
|
|
1093
|
+
error: raw.error ?? raw.message,
|
|
1094
|
+
claims: claims ? {
|
|
1095
|
+
organizationId: organizationId ?? "",
|
|
1096
|
+
orgId: claims.orgId ?? organizationId,
|
|
1097
|
+
apiKeyId: claims.apiKeyId ?? "",
|
|
1098
|
+
queues: claims.queues ?? [],
|
|
1099
|
+
exp: claims.exp ?? 0,
|
|
1100
|
+
iat: claims.iat ?? 0
|
|
1101
|
+
} : void 0
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1080
1104
|
|
|
1081
1105
|
// src/resources/jobs.ts
|
|
1082
1106
|
var JobsResource = class {
|
|
@@ -1107,15 +1131,20 @@ var JobsResource = class {
|
|
|
1107
1131
|
* List jobs with optional filtering
|
|
1108
1132
|
*/
|
|
1109
1133
|
async list(params) {
|
|
1110
|
-
|
|
1134
|
+
const rows = await this.http.get("/jobs", {
|
|
1111
1135
|
params
|
|
1112
1136
|
});
|
|
1137
|
+
return rows.map((row) => ({
|
|
1138
|
+
...row,
|
|
1139
|
+
jobType: row.jobType ?? jobTypeFromPayload(row)
|
|
1140
|
+
}));
|
|
1113
1141
|
}
|
|
1114
1142
|
/**
|
|
1115
1143
|
* Get a job by ID
|
|
1116
1144
|
*/
|
|
1117
1145
|
async get(id) {
|
|
1118
|
-
|
|
1146
|
+
const job = await this.http.get(`/jobs/${id}`);
|
|
1147
|
+
return withJobType(job);
|
|
1119
1148
|
}
|
|
1120
1149
|
/**
|
|
1121
1150
|
* Cancel a pending or scheduled job
|
|
@@ -1127,7 +1156,8 @@ var JobsResource = class {
|
|
|
1127
1156
|
* Retry a failed or dead-lettered job
|
|
1128
1157
|
*/
|
|
1129
1158
|
async retry(id) {
|
|
1130
|
-
|
|
1159
|
+
const job = await this.http.post(`/jobs/${id}/retry`);
|
|
1160
|
+
return withJobType(job);
|
|
1131
1161
|
}
|
|
1132
1162
|
/**
|
|
1133
1163
|
* Boost job priority
|
|
@@ -1196,9 +1226,13 @@ var JobsResource = class {
|
|
|
1196
1226
|
}
|
|
1197
1227
|
// DLQ operations (private implementations)
|
|
1198
1228
|
async listDlq(params) {
|
|
1199
|
-
|
|
1229
|
+
const rows = await this.http.get("/jobs/dlq", {
|
|
1200
1230
|
params
|
|
1201
1231
|
});
|
|
1232
|
+
return rows.map((row) => ({
|
|
1233
|
+
...row,
|
|
1234
|
+
jobType: row.jobType ?? jobTypeFromPayload(row)
|
|
1235
|
+
}));
|
|
1202
1236
|
}
|
|
1203
1237
|
async retryDlq(params) {
|
|
1204
1238
|
return this.http.post("/jobs/dlq/retry", params);
|
|
@@ -1207,6 +1241,28 @@ var JobsResource = class {
|
|
|
1207
1241
|
return this.http.post("/jobs/dlq/purge", params);
|
|
1208
1242
|
}
|
|
1209
1243
|
};
|
|
1244
|
+
function withJobType(job) {
|
|
1245
|
+
return {
|
|
1246
|
+
...job,
|
|
1247
|
+
jobType: job.jobType ?? jobTypeFromPayload(job) ?? void 0
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
function jobTypeFromPayload(row) {
|
|
1251
|
+
if (typeof row.jobType === "string" && row.jobType !== "") {
|
|
1252
|
+
return row.jobType;
|
|
1253
|
+
}
|
|
1254
|
+
const payload = row.payload;
|
|
1255
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
1256
|
+
return void 0;
|
|
1257
|
+
}
|
|
1258
|
+
const rec = payload;
|
|
1259
|
+
for (const value of [rec.jobType, rec.job_type]) {
|
|
1260
|
+
if (typeof value === "string" && value !== "") {
|
|
1261
|
+
return value;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
return void 0;
|
|
1265
|
+
}
|
|
1210
1266
|
|
|
1211
1267
|
// src/resources/queues.ts
|
|
1212
1268
|
var QueuesResource = class {
|
|
@@ -1401,7 +1457,8 @@ var WorkflowsResource = class {
|
|
|
1401
1457
|
* Get a workflow by ID
|
|
1402
1458
|
*/
|
|
1403
1459
|
async get(id) {
|
|
1404
|
-
|
|
1460
|
+
const raw = await this.http.get(`/workflows/${id}`);
|
|
1461
|
+
return mapWorkflowGetResponse(raw);
|
|
1405
1462
|
}
|
|
1406
1463
|
/**
|
|
1407
1464
|
* Cancel a workflow
|
|
@@ -1419,27 +1476,104 @@ var WorkflowsResource = class {
|
|
|
1419
1476
|
return this.http.post(`/workflows/${id}/retry`);
|
|
1420
1477
|
}
|
|
1421
1478
|
// Workflow job operations (private implementations)
|
|
1479
|
+
//
|
|
1480
|
+
// The backend has no /workflows/{id}/jobs routes. Job rows and dependency
|
|
1481
|
+
// edges are on GET /workflows/{id} (WorkflowDetailResponse).
|
|
1422
1482
|
async listWorkflowJobs(workflowId) {
|
|
1423
|
-
|
|
1483
|
+
const detail = await this.http.get(
|
|
1484
|
+
`/workflows/${workflowId}`
|
|
1485
|
+
);
|
|
1486
|
+
return mapWorkflowDetailJobs(detail);
|
|
1424
1487
|
}
|
|
1425
1488
|
async getWorkflowJob(workflowId, jobId) {
|
|
1426
|
-
|
|
1489
|
+
const jobs = await this.listWorkflowJobs(workflowId);
|
|
1490
|
+
const job = jobs.find((item) => item.id === jobId);
|
|
1491
|
+
if (!job) {
|
|
1492
|
+
throw new NotFoundError(
|
|
1493
|
+
`Job ${jobId} not found in workflow ${workflowId}`
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
return job;
|
|
1427
1497
|
}
|
|
1428
1498
|
async getWorkflowJobsStatus(workflowId) {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1499
|
+
const jobs = await this.listWorkflowJobs(workflowId);
|
|
1500
|
+
return jobs.map((job) => ({
|
|
1501
|
+
jobId: job.id,
|
|
1502
|
+
key: job.key,
|
|
1503
|
+
status: job.status
|
|
1504
|
+
}));
|
|
1432
1505
|
}
|
|
1433
1506
|
async getJobDependencies(jobId) {
|
|
1434
1507
|
return this.http.get(`/jobs/${jobId}/dependencies`);
|
|
1435
1508
|
}
|
|
1436
1509
|
async addJobDependencies(jobId, params) {
|
|
1437
|
-
|
|
1510
|
+
const dependsOn = params.dependsOn ?? params.dependsOnJobIds ?? [];
|
|
1511
|
+
const mode = params.dependencyMode ?? (params.dependencyType === "any" || params.dependencyType === "all" ? params.dependencyType : void 0);
|
|
1512
|
+
const raw = await this.http.post(
|
|
1438
1513
|
`/jobs/${jobId}/dependencies`,
|
|
1439
|
-
|
|
1514
|
+
{
|
|
1515
|
+
depends_on: dependsOn,
|
|
1516
|
+
...mode ? { dependency_mode: mode } : {}
|
|
1517
|
+
},
|
|
1518
|
+
{ skipRequestConversion: true }
|
|
1440
1519
|
);
|
|
1520
|
+
return {
|
|
1521
|
+
added: raw.dependenciesAdded ?? 0,
|
|
1522
|
+
dependenciesMet: raw.dependenciesMet ?? false,
|
|
1523
|
+
dependencies: []
|
|
1524
|
+
};
|
|
1441
1525
|
}
|
|
1442
1526
|
};
|
|
1527
|
+
function mapWorkflowGetResponse(raw) {
|
|
1528
|
+
const totalJobs = raw.totalJobs ?? raw.progress?.total ?? 0;
|
|
1529
|
+
const completedJobs = raw.completedJobs ?? raw.progress?.completed ?? 0;
|
|
1530
|
+
const failedJobs = raw.failedJobs ?? raw.progress?.failed ?? 0;
|
|
1531
|
+
const progressPercent = raw.progressPercent ?? (totalJobs > 0 ? completedJobs / totalJobs * 100 : 0);
|
|
1532
|
+
return {
|
|
1533
|
+
id: String(raw.id ?? ""),
|
|
1534
|
+
name: String(raw.name ?? ""),
|
|
1535
|
+
status: raw.status ?? "pending",
|
|
1536
|
+
totalJobs,
|
|
1537
|
+
completedJobs,
|
|
1538
|
+
failedJobs,
|
|
1539
|
+
progressPercent,
|
|
1540
|
+
createdAt: String(raw.createdAt ?? ""),
|
|
1541
|
+
completedAt: raw.completedAt
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
function mapWorkflowDetailJobs(detail) {
|
|
1545
|
+
const workflowId = String(detail.id ?? "");
|
|
1546
|
+
const deps = detail.dependencies ?? [];
|
|
1547
|
+
return (detail.jobs ?? []).map((job) => {
|
|
1548
|
+
const id = String(job.id ?? "");
|
|
1549
|
+
const timeoutMs = typeof job.timeoutMs === "number" ? job.timeoutMs : void 0;
|
|
1550
|
+
const errorObj = job.error;
|
|
1551
|
+
let error;
|
|
1552
|
+
if (typeof errorObj === "string") {
|
|
1553
|
+
error = errorObj;
|
|
1554
|
+
} else if (errorObj && typeof errorObj === "object" && "message" in errorObj) {
|
|
1555
|
+
error = String(errorObj.message);
|
|
1556
|
+
}
|
|
1557
|
+
return {
|
|
1558
|
+
id,
|
|
1559
|
+
workflowId: String(job.workflowId ?? workflowId),
|
|
1560
|
+
key: String(job.key ?? ""),
|
|
1561
|
+
queueName: String(job.queueName ?? job.queue ?? ""),
|
|
1562
|
+
status: job.status,
|
|
1563
|
+
payload: job.payload ?? {},
|
|
1564
|
+
result: job.result ?? void 0,
|
|
1565
|
+
error,
|
|
1566
|
+
dependsOn: deps.filter((dep) => dep.childJobId === id).map((dep) => String(dep.parentJobId ?? "")),
|
|
1567
|
+
priority: Number(job.priority ?? 0),
|
|
1568
|
+
maxRetries: Number(job.maxRetries ?? 0),
|
|
1569
|
+
attempt: Number(job.attempt ?? 0),
|
|
1570
|
+
timeoutSeconds: timeoutMs != null ? Math.max(1, Math.floor(timeoutMs / 1e3)) : void 0,
|
|
1571
|
+
createdAt: String(job.createdAt ?? ""),
|
|
1572
|
+
startedAt: job.startedAt ?? void 0,
|
|
1573
|
+
completedAt: job.completedAt ?? void 0
|
|
1574
|
+
};
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1443
1577
|
|
|
1444
1578
|
// src/resources/webhooks.ts
|
|
1445
1579
|
var WebhooksResource = class {
|
|
@@ -1608,8 +1742,8 @@ var OrganizationsResource = class {
|
|
|
1608
1742
|
*
|
|
1609
1743
|
* @example
|
|
1610
1744
|
* ```typescript
|
|
1611
|
-
* const {
|
|
1612
|
-
* console.log('Webhook token:',
|
|
1745
|
+
* const { webhookToken, webhookUrl } = await client.organizations.getWebhookToken();
|
|
1746
|
+
* console.log('Webhook token:', webhookToken);
|
|
1613
1747
|
* ```
|
|
1614
1748
|
*/
|
|
1615
1749
|
async getWebhookToken() {
|
|
@@ -1623,7 +1757,7 @@ var OrganizationsResource = class {
|
|
|
1623
1757
|
*
|
|
1624
1758
|
* @example
|
|
1625
1759
|
* ```typescript
|
|
1626
|
-
* const {
|
|
1760
|
+
* const { webhookToken: newToken } = await client.organizations.regenerateWebhookToken();
|
|
1627
1761
|
* console.log('New webhook token:', newToken);
|
|
1628
1762
|
* ```
|
|
1629
1763
|
*/
|
|
@@ -1635,8 +1769,9 @@ var OrganizationsResource = class {
|
|
|
1635
1769
|
/**
|
|
1636
1770
|
* Clear/delete the webhook token for the current organization.
|
|
1637
1771
|
*
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1772
|
+
* POST /organizations/webhook-token/clear requires `{ confirm: true }`.
|
|
1773
|
+
* An empty body 422s. The API currently rejects the operation and tells
|
|
1774
|
+
* callers to use regenerateWebhookToken() instead.
|
|
1640
1775
|
*
|
|
1641
1776
|
* @example
|
|
1642
1777
|
* ```typescript
|
|
@@ -1644,7 +1779,9 @@ var OrganizationsResource = class {
|
|
|
1644
1779
|
* ```
|
|
1645
1780
|
*/
|
|
1646
1781
|
async clearWebhookToken() {
|
|
1647
|
-
await this.http.post("/organizations/webhook-token/clear"
|
|
1782
|
+
await this.http.post("/organizations/webhook-token/clear", {
|
|
1783
|
+
confirm: true
|
|
1784
|
+
});
|
|
1648
1785
|
}
|
|
1649
1786
|
};
|
|
1650
1787
|
|
|
@@ -1941,16 +2078,27 @@ var WebhookIngestionResource = class {
|
|
|
1941
2078
|
/**
|
|
1942
2079
|
* Ingest a custom webhook.
|
|
1943
2080
|
*
|
|
1944
|
-
* POST /api/v1/webhooks/{org_id}/custom
|
|
2081
|
+
* POST /api/v1/webhooks/{org_id}/custom returns `{ jobId, queueName, status }`.
|
|
2082
|
+
* An older empty 200 maps to an empty object rather than throwing.
|
|
1945
2083
|
*/
|
|
1946
2084
|
async custom(orgId, params, opts) {
|
|
1947
2085
|
const headers = {
|
|
1948
2086
|
...opts?.webhookToken ? { "X-Webhook-Token": opts.webhookToken } : {},
|
|
1949
2087
|
...opts?.forwardedProto ? { "X-Forwarded-Proto": opts.forwardedProto } : {}
|
|
1950
2088
|
};
|
|
1951
|
-
await this.http.post(
|
|
1952
|
-
|
|
1953
|
-
|
|
2089
|
+
const raw = await this.http.post(
|
|
2090
|
+
`/webhooks/${orgId}/custom`,
|
|
2091
|
+
params,
|
|
2092
|
+
{ headers }
|
|
2093
|
+
);
|
|
2094
|
+
if (!raw || typeof raw === "string") {
|
|
2095
|
+
return {};
|
|
2096
|
+
}
|
|
2097
|
+
return {
|
|
2098
|
+
jobId: raw.jobId,
|
|
2099
|
+
queueName: raw.queueName,
|
|
2100
|
+
status: raw.status
|
|
2101
|
+
};
|
|
1954
2102
|
}
|
|
1955
2103
|
};
|
|
1956
2104
|
|