@tasker-systems/tasker 0.1.1 → 0.1.2

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.js CHANGED
@@ -2103,6 +2103,151 @@ function healthCheck(runtime) {
2103
2103
  }
2104
2104
  }
2105
2105
 
2106
+ // src/client/index.ts
2107
+ var TaskerClientError = class extends Error {
2108
+ /** Whether the error is potentially recoverable */
2109
+ recoverable;
2110
+ constructor(message, recoverable = false) {
2111
+ super(message);
2112
+ this.name = "TaskerClientError";
2113
+ this.recoverable = recoverable;
2114
+ }
2115
+ };
2116
+ var TaskerClient = class {
2117
+ ffiLayer;
2118
+ constructor(ffiLayer) {
2119
+ this.ffiLayer = ffiLayer;
2120
+ }
2121
+ /**
2122
+ * Create a task via the orchestration API.
2123
+ *
2124
+ * @param options - Task creation options (only `name` is required)
2125
+ * @returns Typed task response
2126
+ * @throws TaskerClientError if the operation fails
2127
+ */
2128
+ createTask(options) {
2129
+ const request = {
2130
+ name: options.name,
2131
+ namespace: options.namespace ?? "default",
2132
+ version: options.version ?? "1.0.0",
2133
+ context: options.context ?? {},
2134
+ initiator: options.initiator ?? "tasker-core-typescript",
2135
+ source_system: options.sourceSystem ?? "tasker-core",
2136
+ reason: options.reason ?? "Task requested",
2137
+ tags: options.tags ?? [],
2138
+ requested_at: (/* @__PURE__ */ new Date()).toISOString(),
2139
+ options: null,
2140
+ priority: options.priority ?? null,
2141
+ correlation_id: options.correlationId ?? crypto.randomUUID(),
2142
+ parent_correlation_id: options.parentCorrelationId ?? null,
2143
+ idempotency_key: options.idempotencyKey ?? null
2144
+ };
2145
+ const result = this.getRuntime().clientCreateTask(JSON.stringify(request));
2146
+ return this.unwrap(result);
2147
+ }
2148
+ /**
2149
+ * Get a task by UUID.
2150
+ *
2151
+ * @param taskUuid - The task UUID
2152
+ * @returns Typed task response
2153
+ * @throws TaskerClientError if the operation fails
2154
+ */
2155
+ getTask(taskUuid) {
2156
+ const result = this.getRuntime().clientGetTask(taskUuid);
2157
+ return this.unwrap(result);
2158
+ }
2159
+ /**
2160
+ * List tasks with optional filtering and pagination.
2161
+ *
2162
+ * @param options - Filtering and pagination options
2163
+ * @returns Typed task list response with pagination
2164
+ * @throws TaskerClientError if the operation fails
2165
+ */
2166
+ listTasks(options = {}) {
2167
+ const params = {
2168
+ limit: options.limit ?? 50,
2169
+ offset: options.offset ?? 0,
2170
+ namespace: options.namespace ?? null,
2171
+ status: options.status ?? null
2172
+ };
2173
+ const result = this.getRuntime().clientListTasks(JSON.stringify(params));
2174
+ return this.unwrap(result);
2175
+ }
2176
+ /**
2177
+ * Cancel a task by UUID.
2178
+ *
2179
+ * @param taskUuid - The task UUID
2180
+ * @throws TaskerClientError if the operation fails
2181
+ */
2182
+ cancelTask(taskUuid) {
2183
+ const result = this.getRuntime().clientCancelTask(taskUuid);
2184
+ this.unwrap(result);
2185
+ }
2186
+ /**
2187
+ * List workflow steps for a task.
2188
+ *
2189
+ * @param taskUuid - The task UUID
2190
+ * @returns Array of typed step responses
2191
+ * @throws TaskerClientError if the operation fails
2192
+ */
2193
+ listTaskSteps(taskUuid) {
2194
+ const result = this.getRuntime().clientListTaskSteps(taskUuid);
2195
+ return this.unwrap(result);
2196
+ }
2197
+ /**
2198
+ * Get a specific workflow step.
2199
+ *
2200
+ * @param taskUuid - The task UUID
2201
+ * @param stepUuid - The step UUID
2202
+ * @returns Typed step response
2203
+ * @throws TaskerClientError if the operation fails
2204
+ */
2205
+ getStep(taskUuid, stepUuid) {
2206
+ const result = this.getRuntime().clientGetStep(taskUuid, stepUuid);
2207
+ return this.unwrap(result);
2208
+ }
2209
+ /**
2210
+ * Get audit history for a workflow step.
2211
+ *
2212
+ * @param taskUuid - The task UUID
2213
+ * @param stepUuid - The step UUID
2214
+ * @returns Array of typed audit history entries
2215
+ * @throws TaskerClientError if the operation fails
2216
+ */
2217
+ getStepAuditHistory(taskUuid, stepUuid) {
2218
+ const result = this.getRuntime().clientGetStepAuditHistory(taskUuid, stepUuid);
2219
+ return this.unwrap(result);
2220
+ }
2221
+ /**
2222
+ * Check orchestration API health.
2223
+ *
2224
+ * @returns Typed health response
2225
+ * @throws TaskerClientError if the operation fails
2226
+ */
2227
+ healthCheck() {
2228
+ const result = this.getRuntime().clientHealthCheck();
2229
+ return this.unwrap(result);
2230
+ }
2231
+ /**
2232
+ * Unwrap a ClientResult envelope, throwing on error.
2233
+ */
2234
+ unwrap(result) {
2235
+ if (!result.success) {
2236
+ throw new TaskerClientError(
2237
+ result.error ?? "Unknown client error",
2238
+ result.recoverable ?? false
2239
+ );
2240
+ }
2241
+ return result.data;
2242
+ }
2243
+ /**
2244
+ * Get the FFI runtime from the layer.
2245
+ */
2246
+ getRuntime() {
2247
+ return this.ffiLayer.getRuntime();
2248
+ }
2249
+ };
2250
+
2106
2251
  // src/events/event-names.ts
2107
2252
  var StepEventNames = {
2108
2253
  /** Emitted when a step execution event is received from the FFI layer */
@@ -7865,6 +8010,6 @@ var WorkerServer = class {
7865
8010
  }
7866
8011
  };
7867
8012
 
7868
- export { APIMixin, ApiHandler, ApiResponse, BasePublisher, BaseSubscriber, BaseTaskerRuntime, BatchableMixin, BunRuntime, ClassLookupResolver, DecisionHandler, DecisionMixin, DecisionType, DefaultPublisher, DenoRuntime, DuplicatePublisherError, ErrorType, EventNames, EventPoller, EventSystem, ExplicitMappingResolver, FfiLayer, HandlerRegistry, HandlerSystem, InProcessDomainEventPoller, MethodDispatchError, MethodDispatchWrapper, MetricsEventNames, NoResolverMatchError, NodeRuntime, PollerEventNames, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, ResolutionError, ResolverChain, ResolverNotFoundError, ShutdownController, StepContext, StepEventNames, StepExecutionSubscriber, StepHandler, StepHandlerResult, SubscriberRegistry, TaskerEventEmitter, WorkerEventNames, WorkerServer, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createEventPoller, createFfiPollAdapter, createLogger, createStepEventContext, detectRuntime, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getLibraryPath, getRuntimeInfo, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isBun, isCreateBatches, isDeno, isNoBatches, isNode, isStandardErrorType, isTypicallyRetryable, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
8013
+ export { APIMixin, ApiHandler, ApiResponse, BasePublisher, BaseSubscriber, BaseTaskerRuntime, BatchableMixin, BunRuntime, ClassLookupResolver, DecisionHandler, DecisionMixin, DecisionType, DefaultPublisher, DenoRuntime, DuplicatePublisherError, ErrorType, EventNames, EventPoller, EventSystem, ExplicitMappingResolver, FfiLayer, HandlerRegistry, HandlerSystem, InProcessDomainEventPoller, MethodDispatchError, MethodDispatchWrapper, MetricsEventNames, NoResolverMatchError, NodeRuntime, PollerEventNames, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, ResolutionError, ResolverChain, ResolverNotFoundError, ShutdownController, StepContext, StepEventNames, StepExecutionSubscriber, StepHandler, StepHandlerResult, SubscriberRegistry, TaskerClient, TaskerClientError, TaskerEventEmitter, WorkerEventNames, WorkerServer, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createEventPoller, createFfiPollAdapter, createLogger, createStepEventContext, detectRuntime, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getLibraryPath, getRuntimeInfo, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isBun, isCreateBatches, isDeno, isNoBatches, isNode, isStandardErrorType, isTypicallyRetryable, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
7869
8014
  //# sourceMappingURL=index.js.map
7870
8015
  //# sourceMappingURL=index.js.map