@meistrari/tela-sdk-js 2.10.0 → 2.12.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/README.md CHANGED
@@ -636,11 +636,16 @@ const { data, meta } = await tela.tasks.list({
636
636
  status: ['validating', 'completed'],
637
637
  tags: 'product:my-app',
638
638
  createdAtSince: new Date('2024-01-01'),
639
+ excludeInputOutputColumns: true, // omit raw input/input content/original output
639
640
  orderBy: ['createdAt'],
640
641
  order: 'desc',
641
642
  limit: 50,
642
643
  })
643
644
 
645
+ // Lean list rows still include outputContent and flattened inputFiles.
646
+ // Fetch a single task when you need raw input or original output payloads.
647
+ const fullTask = await tela.tasks.get(data[0].id)
648
+
644
649
  // Mutations
645
650
  await tela.tasks.rename('task-id', 'New name')
646
651
  await tela.tasks.approve('task-id') // sets status: 'completed'
@@ -686,7 +691,7 @@ const uiStatus = normalizeTaskStatus(task.status)
686
691
  // 'failed' | 'cancelled' → 'failed'
687
692
  ```
688
693
 
689
- The full `Task`, `TaskInputFile`, `TaskListQuery`, `TaskUpdatePayload`, and `TaskStatus` types are exported from the package root, so you don't need to type any task-related responses by hand.
694
+ The full `Task`, `TaskListItem`, `TaskInputFile`, `TaskListQuery`, `TaskUpdatePayload`, and `TaskStatus` types are exported from the package root, so you don't need to type any task-related responses by hand.
690
695
 
691
696
  ### Vault API
692
697
 
@@ -1199,5 +1204,6 @@ When you execute a canvas using `applicationId`, it creates a task in the applic
1199
1204
 
1200
1205
  If you encounter issues during migration, please:
1201
1206
  - Check the [examples](./examples/) directory for updated usage patterns
1202
- - Review the [API documentation](./docs/)
1207
+ - Review the [API documentation](https://sdk-js.tela.tools/)
1208
+ - Generate the API reference locally with `bun run docs` when checking changes
1203
1209
  - Open an issue at [GitHub Issues](https://github.com/meistrari/tela-sdk-js/issues)
package/dist/index.cjs CHANGED
@@ -23,7 +23,7 @@ const changeCase__namespace = /*#__PURE__*/_interopNamespaceCompat(changeCase);
23
23
  const z__default = /*#__PURE__*/_interopDefaultCompat(z);
24
24
  const Emittery__default = /*#__PURE__*/_interopDefaultCompat(Emittery);
25
25
 
26
- const version = "2.10.0";
26
+ const version = "2.12.0";
27
27
 
28
28
  var __defProp$a = Object.defineProperty;
29
29
  var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -2574,6 +2574,40 @@ var __publicField$4 = (obj, key, value) => {
2574
2574
  __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
2575
2575
  return value;
2576
2576
  };
2577
+ function resolveBatchQueue(queue) {
2578
+ if (!queue) {
2579
+ return void 0;
2580
+ }
2581
+ const type = queue.type === void 0 ? "customer" : queue.type;
2582
+ if (type !== "internal" && type !== "customer") {
2583
+ throw new Error('Batch queue type must be either "internal" or "customer"');
2584
+ }
2585
+ if (typeof queue.application !== "string" || queue.application.trim().length === 0) {
2586
+ throw new Error("Batch queue application is required when queue is provided");
2587
+ }
2588
+ return {
2589
+ type,
2590
+ application: queue.application.trim()
2591
+ };
2592
+ }
2593
+ function createBatchRequestHeaders(params) {
2594
+ const headers = new Headers();
2595
+ let hasHeaders = false;
2596
+ const queue = resolveBatchQueue(params.queue);
2597
+ if (queue) {
2598
+ headers.set("x-batch-source", queue.type);
2599
+ headers.set("x-batch-source-application", queue.application);
2600
+ hasHeaders = true;
2601
+ }
2602
+ if (params.webhook?.headers) {
2603
+ for (const [key, value] of Object.entries(params.webhook.headers)) {
2604
+ const headerKey = key.toLowerCase().startsWith("x-tela-forward-") ? key : `x-tela-forward-${key}`;
2605
+ headers.set(headerKey, value);
2606
+ hasHeaders = true;
2607
+ }
2608
+ }
2609
+ return hasHeaders ? headers : void 0;
2610
+ }
2577
2611
  const BatchResultItem = z__default.looseObject({
2578
2612
  reference_id: z__default.string(),
2579
2613
  status: z__default.string(),
@@ -3304,6 +3338,7 @@ class Batch {
3304
3338
  const client = this._client;
3305
3339
  const params = this._params;
3306
3340
  async function execute() {
3341
+ const headers = createBatchRequestHeaders(params);
3307
3342
  const { fileUrl } = await uploadFile(file, client);
3308
3343
  const webhookUrl = params.webhook?.url ?? params.webhookUrl;
3309
3344
  const body = {
@@ -3311,31 +3346,22 @@ class Batch {
3311
3346
  inputFile: fileUrl,
3312
3347
  webhookUrl
3313
3348
  };
3314
- const forwardHeaders = {};
3315
- if (params.webhook?.headers) {
3316
- for (const [key, value] of Object.entries(params.webhook.headers)) {
3317
- const headerKey = key.toLowerCase().startsWith("x-tela-forward-") ? key : `x-tela-forward-${key}`;
3318
- forwardHeaders[headerKey] = value;
3319
- }
3320
- }
3321
- let headers;
3322
- if (Object.keys(forwardHeaders).length > 0) {
3323
- headers = new Headers();
3324
- for (const [key, value] of Object.entries(forwardHeaders)) {
3325
- headers.set(key, value);
3326
- }
3327
- }
3328
3349
  return client.post("/_services/batch/batches", {
3329
3350
  body,
3330
3351
  ...headers && { headers }
3331
3352
  }).then((response) => new BatchExecution(response.id, client, params, response));
3332
3353
  }
3354
+ let executionPromise;
3355
+ function getExecution() {
3356
+ executionPromise ?? (executionPromise = execute());
3357
+ return executionPromise;
3358
+ }
3333
3359
  return {
3334
3360
  then(onfulfilled, onrejected) {
3335
- return Promise.resolve(execute()).then((execution) => onfulfilled?.(execution) ?? execution).catch(onrejected);
3361
+ return getExecution().then((execution) => onfulfilled?.(execution) ?? execution).catch(onrejected);
3336
3362
  },
3337
3363
  get result() {
3338
- return Promise.resolve(execute()).then((execution) => execution.result);
3364
+ return getExecution().then((execution) => execution.result);
3339
3365
  }
3340
3366
  };
3341
3367
  }
@@ -3937,6 +3963,7 @@ const TaskListFilters = z__default.looseObject({
3937
3963
  const TaskListOptions = z__default.looseObject({
3938
3964
  limit: z__default.number().optional(),
3939
3965
  offset: z__default.number().optional(),
3966
+ excludeInputOutputColumns: z__default.boolean().optional(),
3940
3967
  order: z__default.object({
3941
3968
  by: z__default.enum(["createdAt", "updatedAt", "approvedAt", "status", "reference", "name"]),
3942
3969
  direction: z__default.enum(["asc", "desc"])
@@ -4239,6 +4266,7 @@ class Workstation {
4239
4266
  async *iterateTasks({ filters, options }) {
4240
4267
  let rawQuery;
4241
4268
  let hasMore = true;
4269
+ const validatedOptions = TaskListOptions.optional().parse(options);
4242
4270
  while (hasMore) {
4243
4271
  const { tasks, meta } = await this.listTasks({
4244
4272
  filters,
@@ -4251,7 +4279,8 @@ class Workstation {
4251
4279
  if (meta.links.next !== null) {
4252
4280
  rawQuery = {
4253
4281
  ...meta.links.next,
4254
- objectLinks: true
4282
+ objectLinks: true,
4283
+ ...validatedOptions?.excludeInputOutputColumns !== void 0 ? { excludeInputOutputColumns: validatedOptions.excludeInputOutputColumns } : {}
4255
4284
  };
4256
4285
  } else {
4257
4286
  hasMore = false;
@@ -4305,9 +4334,6 @@ class Tasks {
4305
4334
  ...NO_TRANSFORM
4306
4335
  });
4307
4336
  }
4308
- /**
4309
- * Lists tasks with optional filters and pagination.
4310
- */
4311
4337
  async list(query = {}) {
4312
4338
  const serialized = serializeTaskListQuery(query);
4313
4339
  return this.client.get("/task", {
package/dist/index.d.cts CHANGED
@@ -1947,6 +1947,27 @@ interface BatchWebhookConfig {
1947
1947
  */
1948
1948
  headers?: Record<string, string>;
1949
1949
  }
1950
+ /**
1951
+ * Source type for routing batch executions.
1952
+ *
1953
+ * @category Canvas
1954
+ */
1955
+ type BatchQueueType = 'internal' | 'customer';
1956
+ /**
1957
+ * Queue/source metadata sent as headers when creating a batch execution.
1958
+ *
1959
+ * @category Canvas
1960
+ */
1961
+ interface BatchQueueConfig {
1962
+ /**
1963
+ * Source type for the batch. Defaults to `customer` when omitted.
1964
+ */
1965
+ type?: BatchQueueType;
1966
+ /**
1967
+ * Name of the application creating the batch. Required when `queue` is provided.
1968
+ */
1969
+ application: string;
1970
+ }
1950
1971
  /**
1951
1972
  * Configuration options for batch execution.
1952
1973
  *
@@ -2007,6 +2028,14 @@ interface BatchParams extends Omit<BaseExecutionParams, ExcludedParams> {
2007
2028
  * ```
2008
2029
  */
2009
2030
  webhook?: BatchWebhookConfig;
2031
+ /**
2032
+ * Optional queue/source metadata sent as headers when creating the batch.
2033
+ *
2034
+ * Sends:
2035
+ * - `x-batch-source`: `queue.type` or `customer` by default.
2036
+ * - `x-batch-source-application`: `queue.application`.
2037
+ */
2038
+ queue?: BatchQueueConfig;
2010
2039
  }
2011
2040
  /**
2012
2041
  * Promise-like wrapper for batch execution that provides direct result access.
@@ -3277,6 +3306,7 @@ type TaskListFilters = z.input<typeof TaskListFilters>;
3277
3306
  declare const TaskListOptions: z.ZodPipe<z.ZodObject<{
3278
3307
  limit: z.ZodOptional<z.ZodNumber>;
3279
3308
  offset: z.ZodOptional<z.ZodNumber>;
3309
+ excludeInputOutputColumns: z.ZodOptional<z.ZodBoolean>;
3280
3310
  order: z.ZodOptional<z.ZodObject<{
3281
3311
  by: z.ZodEnum<{
3282
3312
  name: "name";
@@ -3294,12 +3324,14 @@ declare const TaskListOptions: z.ZodPipe<z.ZodObject<{
3294
3324
  }, z.core.$loose>, z.ZodTransform<{
3295
3325
  limit?: number | undefined;
3296
3326
  offset?: number | undefined;
3327
+ excludeInputOutputColumns?: boolean | undefined;
3297
3328
  orderBy: "name" | "status" | "reference" | "approvedAt" | "createdAt" | "updatedAt" | undefined;
3298
3329
  orderDirection: "asc" | "desc" | undefined;
3299
3330
  }, {
3300
3331
  [x: string]: unknown;
3301
3332
  limit?: number | undefined;
3302
3333
  offset?: number | undefined;
3334
+ excludeInputOutputColumns?: boolean | undefined;
3303
3335
  order?: {
3304
3336
  by: "name" | "status" | "reference" | "approvedAt" | "createdAt" | "updatedAt";
3305
3337
  direction: "asc" | "desc";
@@ -3340,6 +3372,8 @@ type LinkParams = {
3340
3372
  limit: number;
3341
3373
  /** Starting offset for the page */
3342
3374
  offset: number;
3375
+ /** Whether heavy input/output columns are omitted from task rows */
3376
+ excludeInputOutputColumns?: boolean;
3343
3377
  };
3344
3378
  /**
3345
3379
  * Navigation links for paginated task lists.
@@ -3663,6 +3697,16 @@ interface Task<TOutput = unknown> {
3663
3697
  updatedAt: string;
3664
3698
  deletedAt: string | null;
3665
3699
  }
3700
+ /**
3701
+ * A lean task row returned when `excludeInputOutputColumns` is enabled.
3702
+ *
3703
+ * The API omits `rawInput`, `inputContent`, and `originalOutputContent` from
3704
+ * each row, while still returning the current `outputContent` and flattened
3705
+ * `inputFiles`. Fetch the task by id to retrieve the full task payload.
3706
+ */
3707
+ type TaskListItem<TOutput = unknown> = Omit<Task<TOutput>, 'inputContent' | 'originalOutputContent' | 'rawInput'> & {
3708
+ inputFiles: Array<TaskInputFile>;
3709
+ };
3666
3710
  /**
3667
3711
  * Payload accepted by `tasks.update()`.
3668
3712
  *
@@ -3705,14 +3749,22 @@ interface TaskListQuery {
3705
3749
  order?: 'asc' | 'desc';
3706
3750
  limit?: number;
3707
3751
  offset?: number;
3752
+ /**
3753
+ * Omits raw input, normalized input content, and original output columns
3754
+ * from each listed task. The list rows still include the current
3755
+ * `outputContent` and flattened `inputFiles`.
3756
+ *
3757
+ * Use `tasks.get(id)` when you need the full task detail, including raw
3758
+ * input and original output payloads.
3759
+ */
3708
3760
  excludeInputOutputColumns?: boolean;
3709
3761
  }
3710
3762
  type TaskOrderBy = 'name' | 'reference' | 'approvedAt' | 'createdAt' | 'updatedAt' | 'id' | 'status' | 'approvedBy' | 'createdBy';
3711
3763
  /**
3712
3764
  * Paginated response wrapper.
3713
3765
  */
3714
- interface TaskListResult<TOutput = unknown> {
3715
- data: Array<Task<TOutput>>;
3766
+ interface TaskListResult<TOutput = unknown, TItem extends Task<TOutput> | TaskListItem<TOutput> = Task<TOutput>> {
3767
+ data: Array<TItem>;
3716
3768
  meta: {
3717
3769
  totalCount?: number;
3718
3770
  limit?: number;
@@ -3836,6 +3888,9 @@ declare class Tasks {
3836
3888
  /**
3837
3889
  * Lists tasks with optional filters and pagination.
3838
3890
  */
3891
+ list<TOutput = unknown>(query: TaskListQuery & {
3892
+ excludeInputOutputColumns: true;
3893
+ }): Promise<TaskListResult<TOutput, TaskListItem<TOutput>>>;
3839
3894
  list<TOutput = unknown>(query?: TaskListQuery): Promise<TaskListResult<TOutput>>;
3840
3895
  /**
3841
3896
  * Updates one or more fields of a task.
@@ -4254,4 +4309,4 @@ declare class TelaSDK extends BaseClient {
4254
4309
  */
4255
4310
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4256
4311
 
4257
- export { APIError, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
4312
+ export { APIError, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
package/dist/index.d.mts CHANGED
@@ -1947,6 +1947,27 @@ interface BatchWebhookConfig {
1947
1947
  */
1948
1948
  headers?: Record<string, string>;
1949
1949
  }
1950
+ /**
1951
+ * Source type for routing batch executions.
1952
+ *
1953
+ * @category Canvas
1954
+ */
1955
+ type BatchQueueType = 'internal' | 'customer';
1956
+ /**
1957
+ * Queue/source metadata sent as headers when creating a batch execution.
1958
+ *
1959
+ * @category Canvas
1960
+ */
1961
+ interface BatchQueueConfig {
1962
+ /**
1963
+ * Source type for the batch. Defaults to `customer` when omitted.
1964
+ */
1965
+ type?: BatchQueueType;
1966
+ /**
1967
+ * Name of the application creating the batch. Required when `queue` is provided.
1968
+ */
1969
+ application: string;
1970
+ }
1950
1971
  /**
1951
1972
  * Configuration options for batch execution.
1952
1973
  *
@@ -2007,6 +2028,14 @@ interface BatchParams extends Omit<BaseExecutionParams, ExcludedParams> {
2007
2028
  * ```
2008
2029
  */
2009
2030
  webhook?: BatchWebhookConfig;
2031
+ /**
2032
+ * Optional queue/source metadata sent as headers when creating the batch.
2033
+ *
2034
+ * Sends:
2035
+ * - `x-batch-source`: `queue.type` or `customer` by default.
2036
+ * - `x-batch-source-application`: `queue.application`.
2037
+ */
2038
+ queue?: BatchQueueConfig;
2010
2039
  }
2011
2040
  /**
2012
2041
  * Promise-like wrapper for batch execution that provides direct result access.
@@ -3277,6 +3306,7 @@ type TaskListFilters = z.input<typeof TaskListFilters>;
3277
3306
  declare const TaskListOptions: z.ZodPipe<z.ZodObject<{
3278
3307
  limit: z.ZodOptional<z.ZodNumber>;
3279
3308
  offset: z.ZodOptional<z.ZodNumber>;
3309
+ excludeInputOutputColumns: z.ZodOptional<z.ZodBoolean>;
3280
3310
  order: z.ZodOptional<z.ZodObject<{
3281
3311
  by: z.ZodEnum<{
3282
3312
  name: "name";
@@ -3294,12 +3324,14 @@ declare const TaskListOptions: z.ZodPipe<z.ZodObject<{
3294
3324
  }, z.core.$loose>, z.ZodTransform<{
3295
3325
  limit?: number | undefined;
3296
3326
  offset?: number | undefined;
3327
+ excludeInputOutputColumns?: boolean | undefined;
3297
3328
  orderBy: "name" | "status" | "reference" | "approvedAt" | "createdAt" | "updatedAt" | undefined;
3298
3329
  orderDirection: "asc" | "desc" | undefined;
3299
3330
  }, {
3300
3331
  [x: string]: unknown;
3301
3332
  limit?: number | undefined;
3302
3333
  offset?: number | undefined;
3334
+ excludeInputOutputColumns?: boolean | undefined;
3303
3335
  order?: {
3304
3336
  by: "name" | "status" | "reference" | "approvedAt" | "createdAt" | "updatedAt";
3305
3337
  direction: "asc" | "desc";
@@ -3340,6 +3372,8 @@ type LinkParams = {
3340
3372
  limit: number;
3341
3373
  /** Starting offset for the page */
3342
3374
  offset: number;
3375
+ /** Whether heavy input/output columns are omitted from task rows */
3376
+ excludeInputOutputColumns?: boolean;
3343
3377
  };
3344
3378
  /**
3345
3379
  * Navigation links for paginated task lists.
@@ -3663,6 +3697,16 @@ interface Task<TOutput = unknown> {
3663
3697
  updatedAt: string;
3664
3698
  deletedAt: string | null;
3665
3699
  }
3700
+ /**
3701
+ * A lean task row returned when `excludeInputOutputColumns` is enabled.
3702
+ *
3703
+ * The API omits `rawInput`, `inputContent`, and `originalOutputContent` from
3704
+ * each row, while still returning the current `outputContent` and flattened
3705
+ * `inputFiles`. Fetch the task by id to retrieve the full task payload.
3706
+ */
3707
+ type TaskListItem<TOutput = unknown> = Omit<Task<TOutput>, 'inputContent' | 'originalOutputContent' | 'rawInput'> & {
3708
+ inputFiles: Array<TaskInputFile>;
3709
+ };
3666
3710
  /**
3667
3711
  * Payload accepted by `tasks.update()`.
3668
3712
  *
@@ -3705,14 +3749,22 @@ interface TaskListQuery {
3705
3749
  order?: 'asc' | 'desc';
3706
3750
  limit?: number;
3707
3751
  offset?: number;
3752
+ /**
3753
+ * Omits raw input, normalized input content, and original output columns
3754
+ * from each listed task. The list rows still include the current
3755
+ * `outputContent` and flattened `inputFiles`.
3756
+ *
3757
+ * Use `tasks.get(id)` when you need the full task detail, including raw
3758
+ * input and original output payloads.
3759
+ */
3708
3760
  excludeInputOutputColumns?: boolean;
3709
3761
  }
3710
3762
  type TaskOrderBy = 'name' | 'reference' | 'approvedAt' | 'createdAt' | 'updatedAt' | 'id' | 'status' | 'approvedBy' | 'createdBy';
3711
3763
  /**
3712
3764
  * Paginated response wrapper.
3713
3765
  */
3714
- interface TaskListResult<TOutput = unknown> {
3715
- data: Array<Task<TOutput>>;
3766
+ interface TaskListResult<TOutput = unknown, TItem extends Task<TOutput> | TaskListItem<TOutput> = Task<TOutput>> {
3767
+ data: Array<TItem>;
3716
3768
  meta: {
3717
3769
  totalCount?: number;
3718
3770
  limit?: number;
@@ -3836,6 +3888,9 @@ declare class Tasks {
3836
3888
  /**
3837
3889
  * Lists tasks with optional filters and pagination.
3838
3890
  */
3891
+ list<TOutput = unknown>(query: TaskListQuery & {
3892
+ excludeInputOutputColumns: true;
3893
+ }): Promise<TaskListResult<TOutput, TaskListItem<TOutput>>>;
3839
3894
  list<TOutput = unknown>(query?: TaskListQuery): Promise<TaskListResult<TOutput>>;
3840
3895
  /**
3841
3896
  * Updates one or more fields of a task.
@@ -4254,4 +4309,4 @@ declare class TelaSDK extends BaseClient {
4254
4309
  */
4255
4310
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4256
4311
 
4257
- export { APIError, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
4312
+ export { APIError, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
package/dist/index.d.ts CHANGED
@@ -1947,6 +1947,27 @@ interface BatchWebhookConfig {
1947
1947
  */
1948
1948
  headers?: Record<string, string>;
1949
1949
  }
1950
+ /**
1951
+ * Source type for routing batch executions.
1952
+ *
1953
+ * @category Canvas
1954
+ */
1955
+ type BatchQueueType = 'internal' | 'customer';
1956
+ /**
1957
+ * Queue/source metadata sent as headers when creating a batch execution.
1958
+ *
1959
+ * @category Canvas
1960
+ */
1961
+ interface BatchQueueConfig {
1962
+ /**
1963
+ * Source type for the batch. Defaults to `customer` when omitted.
1964
+ */
1965
+ type?: BatchQueueType;
1966
+ /**
1967
+ * Name of the application creating the batch. Required when `queue` is provided.
1968
+ */
1969
+ application: string;
1970
+ }
1950
1971
  /**
1951
1972
  * Configuration options for batch execution.
1952
1973
  *
@@ -2007,6 +2028,14 @@ interface BatchParams extends Omit<BaseExecutionParams, ExcludedParams> {
2007
2028
  * ```
2008
2029
  */
2009
2030
  webhook?: BatchWebhookConfig;
2031
+ /**
2032
+ * Optional queue/source metadata sent as headers when creating the batch.
2033
+ *
2034
+ * Sends:
2035
+ * - `x-batch-source`: `queue.type` or `customer` by default.
2036
+ * - `x-batch-source-application`: `queue.application`.
2037
+ */
2038
+ queue?: BatchQueueConfig;
2010
2039
  }
2011
2040
  /**
2012
2041
  * Promise-like wrapper for batch execution that provides direct result access.
@@ -3277,6 +3306,7 @@ type TaskListFilters = z.input<typeof TaskListFilters>;
3277
3306
  declare const TaskListOptions: z.ZodPipe<z.ZodObject<{
3278
3307
  limit: z.ZodOptional<z.ZodNumber>;
3279
3308
  offset: z.ZodOptional<z.ZodNumber>;
3309
+ excludeInputOutputColumns: z.ZodOptional<z.ZodBoolean>;
3280
3310
  order: z.ZodOptional<z.ZodObject<{
3281
3311
  by: z.ZodEnum<{
3282
3312
  name: "name";
@@ -3294,12 +3324,14 @@ declare const TaskListOptions: z.ZodPipe<z.ZodObject<{
3294
3324
  }, z.core.$loose>, z.ZodTransform<{
3295
3325
  limit?: number | undefined;
3296
3326
  offset?: number | undefined;
3327
+ excludeInputOutputColumns?: boolean | undefined;
3297
3328
  orderBy: "name" | "status" | "reference" | "approvedAt" | "createdAt" | "updatedAt" | undefined;
3298
3329
  orderDirection: "asc" | "desc" | undefined;
3299
3330
  }, {
3300
3331
  [x: string]: unknown;
3301
3332
  limit?: number | undefined;
3302
3333
  offset?: number | undefined;
3334
+ excludeInputOutputColumns?: boolean | undefined;
3303
3335
  order?: {
3304
3336
  by: "name" | "status" | "reference" | "approvedAt" | "createdAt" | "updatedAt";
3305
3337
  direction: "asc" | "desc";
@@ -3340,6 +3372,8 @@ type LinkParams = {
3340
3372
  limit: number;
3341
3373
  /** Starting offset for the page */
3342
3374
  offset: number;
3375
+ /** Whether heavy input/output columns are omitted from task rows */
3376
+ excludeInputOutputColumns?: boolean;
3343
3377
  };
3344
3378
  /**
3345
3379
  * Navigation links for paginated task lists.
@@ -3663,6 +3697,16 @@ interface Task<TOutput = unknown> {
3663
3697
  updatedAt: string;
3664
3698
  deletedAt: string | null;
3665
3699
  }
3700
+ /**
3701
+ * A lean task row returned when `excludeInputOutputColumns` is enabled.
3702
+ *
3703
+ * The API omits `rawInput`, `inputContent`, and `originalOutputContent` from
3704
+ * each row, while still returning the current `outputContent` and flattened
3705
+ * `inputFiles`. Fetch the task by id to retrieve the full task payload.
3706
+ */
3707
+ type TaskListItem<TOutput = unknown> = Omit<Task<TOutput>, 'inputContent' | 'originalOutputContent' | 'rawInput'> & {
3708
+ inputFiles: Array<TaskInputFile>;
3709
+ };
3666
3710
  /**
3667
3711
  * Payload accepted by `tasks.update()`.
3668
3712
  *
@@ -3705,14 +3749,22 @@ interface TaskListQuery {
3705
3749
  order?: 'asc' | 'desc';
3706
3750
  limit?: number;
3707
3751
  offset?: number;
3752
+ /**
3753
+ * Omits raw input, normalized input content, and original output columns
3754
+ * from each listed task. The list rows still include the current
3755
+ * `outputContent` and flattened `inputFiles`.
3756
+ *
3757
+ * Use `tasks.get(id)` when you need the full task detail, including raw
3758
+ * input and original output payloads.
3759
+ */
3708
3760
  excludeInputOutputColumns?: boolean;
3709
3761
  }
3710
3762
  type TaskOrderBy = 'name' | 'reference' | 'approvedAt' | 'createdAt' | 'updatedAt' | 'id' | 'status' | 'approvedBy' | 'createdBy';
3711
3763
  /**
3712
3764
  * Paginated response wrapper.
3713
3765
  */
3714
- interface TaskListResult<TOutput = unknown> {
3715
- data: Array<Task<TOutput>>;
3766
+ interface TaskListResult<TOutput = unknown, TItem extends Task<TOutput> | TaskListItem<TOutput> = Task<TOutput>> {
3767
+ data: Array<TItem>;
3716
3768
  meta: {
3717
3769
  totalCount?: number;
3718
3770
  limit?: number;
@@ -3836,6 +3888,9 @@ declare class Tasks {
3836
3888
  /**
3837
3889
  * Lists tasks with optional filters and pagination.
3838
3890
  */
3891
+ list<TOutput = unknown>(query: TaskListQuery & {
3892
+ excludeInputOutputColumns: true;
3893
+ }): Promise<TaskListResult<TOutput, TaskListItem<TOutput>>>;
3839
3894
  list<TOutput = unknown>(query?: TaskListQuery): Promise<TaskListResult<TOutput>>;
3840
3895
  /**
3841
3896
  * Updates one or more fields of a task.
@@ -4254,4 +4309,4 @@ declare class TelaSDK extends BaseClient {
4254
4309
  */
4255
4310
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4256
4311
 
4257
- export { APIError, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
4312
+ export { APIError, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { Minimatch } from 'minimatch';
3
3
  import z, { z as z$1, ZodError } from 'zod';
4
4
  import Emittery from 'emittery';
5
5
 
6
- const version = "2.10.0";
6
+ const version = "2.12.0";
7
7
 
8
8
  var __defProp$a = Object.defineProperty;
9
9
  var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -2554,6 +2554,40 @@ var __publicField$4 = (obj, key, value) => {
2554
2554
  __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
2555
2555
  return value;
2556
2556
  };
2557
+ function resolveBatchQueue(queue) {
2558
+ if (!queue) {
2559
+ return void 0;
2560
+ }
2561
+ const type = queue.type === void 0 ? "customer" : queue.type;
2562
+ if (type !== "internal" && type !== "customer") {
2563
+ throw new Error('Batch queue type must be either "internal" or "customer"');
2564
+ }
2565
+ if (typeof queue.application !== "string" || queue.application.trim().length === 0) {
2566
+ throw new Error("Batch queue application is required when queue is provided");
2567
+ }
2568
+ return {
2569
+ type,
2570
+ application: queue.application.trim()
2571
+ };
2572
+ }
2573
+ function createBatchRequestHeaders(params) {
2574
+ const headers = new Headers();
2575
+ let hasHeaders = false;
2576
+ const queue = resolveBatchQueue(params.queue);
2577
+ if (queue) {
2578
+ headers.set("x-batch-source", queue.type);
2579
+ headers.set("x-batch-source-application", queue.application);
2580
+ hasHeaders = true;
2581
+ }
2582
+ if (params.webhook?.headers) {
2583
+ for (const [key, value] of Object.entries(params.webhook.headers)) {
2584
+ const headerKey = key.toLowerCase().startsWith("x-tela-forward-") ? key : `x-tela-forward-${key}`;
2585
+ headers.set(headerKey, value);
2586
+ hasHeaders = true;
2587
+ }
2588
+ }
2589
+ return hasHeaders ? headers : void 0;
2590
+ }
2557
2591
  const BatchResultItem = z.looseObject({
2558
2592
  reference_id: z.string(),
2559
2593
  status: z.string(),
@@ -3284,6 +3318,7 @@ class Batch {
3284
3318
  const client = this._client;
3285
3319
  const params = this._params;
3286
3320
  async function execute() {
3321
+ const headers = createBatchRequestHeaders(params);
3287
3322
  const { fileUrl } = await uploadFile(file, client);
3288
3323
  const webhookUrl = params.webhook?.url ?? params.webhookUrl;
3289
3324
  const body = {
@@ -3291,31 +3326,22 @@ class Batch {
3291
3326
  inputFile: fileUrl,
3292
3327
  webhookUrl
3293
3328
  };
3294
- const forwardHeaders = {};
3295
- if (params.webhook?.headers) {
3296
- for (const [key, value] of Object.entries(params.webhook.headers)) {
3297
- const headerKey = key.toLowerCase().startsWith("x-tela-forward-") ? key : `x-tela-forward-${key}`;
3298
- forwardHeaders[headerKey] = value;
3299
- }
3300
- }
3301
- let headers;
3302
- if (Object.keys(forwardHeaders).length > 0) {
3303
- headers = new Headers();
3304
- for (const [key, value] of Object.entries(forwardHeaders)) {
3305
- headers.set(key, value);
3306
- }
3307
- }
3308
3329
  return client.post("/_services/batch/batches", {
3309
3330
  body,
3310
3331
  ...headers && { headers }
3311
3332
  }).then((response) => new BatchExecution(response.id, client, params, response));
3312
3333
  }
3334
+ let executionPromise;
3335
+ function getExecution() {
3336
+ executionPromise ?? (executionPromise = execute());
3337
+ return executionPromise;
3338
+ }
3313
3339
  return {
3314
3340
  then(onfulfilled, onrejected) {
3315
- return Promise.resolve(execute()).then((execution) => onfulfilled?.(execution) ?? execution).catch(onrejected);
3341
+ return getExecution().then((execution) => onfulfilled?.(execution) ?? execution).catch(onrejected);
3316
3342
  },
3317
3343
  get result() {
3318
- return Promise.resolve(execute()).then((execution) => execution.result);
3344
+ return getExecution().then((execution) => execution.result);
3319
3345
  }
3320
3346
  };
3321
3347
  }
@@ -3917,6 +3943,7 @@ const TaskListFilters = z.looseObject({
3917
3943
  const TaskListOptions = z.looseObject({
3918
3944
  limit: z.number().optional(),
3919
3945
  offset: z.number().optional(),
3946
+ excludeInputOutputColumns: z.boolean().optional(),
3920
3947
  order: z.object({
3921
3948
  by: z.enum(["createdAt", "updatedAt", "approvedAt", "status", "reference", "name"]),
3922
3949
  direction: z.enum(["asc", "desc"])
@@ -4219,6 +4246,7 @@ class Workstation {
4219
4246
  async *iterateTasks({ filters, options }) {
4220
4247
  let rawQuery;
4221
4248
  let hasMore = true;
4249
+ const validatedOptions = TaskListOptions.optional().parse(options);
4222
4250
  while (hasMore) {
4223
4251
  const { tasks, meta } = await this.listTasks({
4224
4252
  filters,
@@ -4231,7 +4259,8 @@ class Workstation {
4231
4259
  if (meta.links.next !== null) {
4232
4260
  rawQuery = {
4233
4261
  ...meta.links.next,
4234
- objectLinks: true
4262
+ objectLinks: true,
4263
+ ...validatedOptions?.excludeInputOutputColumns !== void 0 ? { excludeInputOutputColumns: validatedOptions.excludeInputOutputColumns } : {}
4235
4264
  };
4236
4265
  } else {
4237
4266
  hasMore = false;
@@ -4285,9 +4314,6 @@ class Tasks {
4285
4314
  ...NO_TRANSFORM
4286
4315
  });
4287
4316
  }
4288
- /**
4289
- * Lists tasks with optional filters and pagination.
4290
- */
4291
4317
  async list(query = {}) {
4292
4318
  const serialized = serializeTaskListQuery(query);
4293
4319
  return this.client.get("/task", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-sdk-js",
3
- "version": "2.10.0",
3
+ "version": "2.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/meistrari/tela-sdk-js.git"