@meistrari/tela-sdk-js 2.0.0 → 2.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.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import * as changeCase from 'change-case';
2
2
  import { minimatch } from 'minimatch';
3
- import z, { z as z$1, ZodError, string, number, boolean, object, array, any, unknown } from 'zod';
3
+ import * as z from 'zod';
4
+ import z__default, { z as z$1, ZodError } from 'zod';
5
+ import Emittery from 'emittery';
4
6
 
5
- const version = "2.0.0";
7
+ const version = "2.2.0";
6
8
 
7
9
  var __defProp$7 = Object.defineProperty;
8
10
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -1023,17 +1025,9 @@ var __publicField$4 = (obj, key, value) => {
1023
1025
  return value;
1024
1026
  };
1025
1027
  function TelaFileSchema() {
1026
- return z.custom((value) => value instanceof TelaFile, { message: "Value must be an instance of TelaFile" }).meta({ isTelaFile: true });
1028
+ return z__default.custom((value) => value instanceof TelaFile, { message: "Value must be an instance of TelaFile" }).meta({ isTelaFile: true });
1027
1029
  }
1028
1030
  class TelaFile {
1029
- /**
1030
- * Creates an instance of `TelaFile`.
1031
- *
1032
- * @param file - The source of the file. Can be a URL string, Uint8Array, ReadableStream, ReadStream, Blob, or File.
1033
- * @param options - Optional configuration options such as byte range.
1034
- * @throws {InvalidFileURL} If the provided URL is not valid.
1035
- * @throws {EmptyFileError} If the provided file is empty.
1036
- */
1037
1031
  constructor(file, options = {}) {
1038
1032
  __publicField$4(this, "_file");
1039
1033
  __publicField$4(this, "_options");
@@ -1411,7 +1405,7 @@ class Poller {
1411
1405
  const resultPromise = async () => {
1412
1406
  try {
1413
1407
  while (!this._abortSignal.aborted) {
1414
- const result = await Promise.try(callback, this._abortSignal);
1408
+ const result = await callback(this._abortSignal);
1415
1409
  if (result.done) {
1416
1410
  return result.value;
1417
1411
  }
@@ -1473,7 +1467,38 @@ function isTelaFile(obj) {
1473
1467
  function isTelaFileArray(obj) {
1474
1468
  return Array.isArray(obj) && obj.length > 0 && obj.every(isTelaFile);
1475
1469
  }
1476
- class CanvasExecution {
1470
+ function isUUID(str) {
1471
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1472
+ return uuidRegex.test(str);
1473
+ }
1474
+ function isSyncWorkflowResult(obj) {
1475
+ return "output" in obj;
1476
+ }
1477
+ function isAsyncWorkflowResult(obj) {
1478
+ return "outputContent" in obj && "output" in obj.outputContent;
1479
+ }
1480
+ function isSyncCanvasResult(obj) {
1481
+ return "choices" in obj;
1482
+ }
1483
+ function isAsyncCanvasResult(obj) {
1484
+ return "outputContent" in obj && "content" in obj.outputContent;
1485
+ }
1486
+ function getResultFromPollingResponse(response) {
1487
+ if (isSyncWorkflowResult(response)) {
1488
+ return response.output.output;
1489
+ }
1490
+ if (isAsyncWorkflowResult(response)) {
1491
+ return response.outputContent.output.output;
1492
+ }
1493
+ if (isSyncCanvasResult(response)) {
1494
+ return response.choices?.[0]?.message?.content;
1495
+ }
1496
+ if (isAsyncCanvasResult(response)) {
1497
+ return response.outputContent.content;
1498
+ }
1499
+ throw new Error("Invalid response type");
1500
+ }
1501
+ class CanvasExecution extends Emittery {
1477
1502
  /**
1478
1503
  * Creates a new canvas execution instance.
1479
1504
  *
@@ -1483,16 +1508,18 @@ class CanvasExecution {
1483
1508
  * @param client - HTTP client instance for making API requests.
1484
1509
  */
1485
1510
  constructor(variables, params = { async: false }, outputSchema, client) {
1511
+ super();
1486
1512
  __publicField$2(this, "_id");
1513
+ __publicField$2(this, "_status");
1487
1514
  __publicField$2(this, "_variables");
1488
1515
  __publicField$2(this, "_params");
1489
1516
  __publicField$2(this, "_client");
1490
1517
  __publicField$2(this, "_outputSchema");
1491
1518
  __publicField$2(this, "_skipResultValidation");
1492
1519
  __publicField$2(this, "_abortController");
1493
- __publicField$2(this, "_startPropmise");
1494
1520
  __publicField$2(this, "_resultPromise");
1495
1521
  __publicField$2(this, "_stream");
1522
+ __publicField$2(this, "_rawResultValue");
1496
1523
  this._variables = variables;
1497
1524
  this._params = params;
1498
1525
  this._outputSchema = outputSchema;
@@ -1500,18 +1527,138 @@ class CanvasExecution {
1500
1527
  this._client = client;
1501
1528
  this._abortController = new AbortController();
1502
1529
  }
1530
+ /**
1531
+ * Fetches an existing asynchronous execution by its ID.
1532
+ *
1533
+ * This method retrieves the current state of an async execution and creates a new
1534
+ * CanvasExecution instance with the fetched data. Only async executions can be
1535
+ * fetched, as they are the only ones with persistent UUIDs on the server.
1536
+ *
1537
+ * @param id - The UUID of the async execution to fetch.
1538
+ * @param outputSchema - Zod schema or object schema for validating/parsing output.
1539
+ * @param client - HTTP client instance for making API requests.
1540
+ * @param options - Optional configuration for polling behavior.
1541
+ * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
1542
+ * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
1543
+ * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
1544
+ * @returns A promise resolving to a CanvasExecution instance with the fetched state.
1545
+ *
1546
+ * @example
1547
+ * ```typescript
1548
+ * const execution = await CanvasExecution.fetch(
1549
+ * 'execution-uuid',
1550
+ * z.object({ result: z.string() }),
1551
+ * client,
1552
+ * { pollingInterval: 2000, pollingTimeout: 120000 }
1553
+ * )
1554
+ * console.log(execution.status) // 'running' or 'succeeded' or 'failed'
1555
+ * ```
1556
+ */
1557
+ static async fetch(id, outputSchema, client, options) {
1558
+ if (!isUUID(id)) {
1559
+ throw new InvalidExecutionModeError(
1560
+ "Only async executions can be fetched by ID. The provided ID is not a valid UUID."
1561
+ );
1562
+ }
1563
+ const response = await client.get(
1564
+ `/v2/chat/completions/${id}`
1565
+ );
1566
+ const params = {
1567
+ async: true,
1568
+ pollingInterval: options?.pollingInterval,
1569
+ pollingTimeout: options?.pollingTimeout
1570
+ };
1571
+ const execution = new CanvasExecution(
1572
+ {},
1573
+ // No variables needed for fetched execution
1574
+ params,
1575
+ outputSchema,
1576
+ client
1577
+ );
1578
+ execution._id = response.id;
1579
+ execution.status = response.status;
1580
+ if (response.status === "succeeded") {
1581
+ execution._rawResultValue = response;
1582
+ const content = getResultFromPollingResponse(response);
1583
+ try {
1584
+ const validatedContent = execution._skipResultValidation || !(outputSchema instanceof z__default.ZodType) ? content : outputSchema.parse(content);
1585
+ execution._resultPromise = Promise.resolve(validatedContent);
1586
+ } catch (error) {
1587
+ execution._resultPromise = Promise.reject(error);
1588
+ execution._resultPromise.catch(() => {
1589
+ });
1590
+ }
1591
+ } else if (response.status === "failed") {
1592
+ execution._rawResultValue = response;
1593
+ const error = new ExecutionFailedError(response.rawOutput);
1594
+ execution._resultPromise = Promise.reject(error);
1595
+ execution._resultPromise.catch(() => {
1596
+ });
1597
+ }
1598
+ return execution;
1599
+ }
1503
1600
  /**
1504
1601
  * Gets the unique execution ID assigned by the server.
1505
1602
  *
1506
- * @throws {Error} If the execution has not been started yet.
1603
+ * Note: Streaming executions do not have an ID as they don't create a tracked execution on the server.
1604
+ *
1605
+ * @throws {ExecutionNotStartedError} If the execution has not been started yet.
1606
+ * @throws {InvalidExecutionModeError} If called on a streaming execution (streams don't have IDs).
1507
1607
  * @returns The execution ID.
1508
1608
  */
1509
1609
  get id() {
1610
+ if (this.isStream) {
1611
+ throw new InvalidExecutionModeError("Streaming executions do not have an execution ID");
1612
+ }
1510
1613
  if (!this._id) {
1511
1614
  throw new ExecutionNotStartedError();
1512
1615
  }
1513
1616
  return this._id;
1514
1617
  }
1618
+ /**
1619
+ * Gets the latest known status of the execution.
1620
+ *
1621
+ * Status values and transitions:
1622
+ * - **Sync**: `succeeded` (after validation) or `failed` (on any error)
1623
+ * - **Async**: `created` → `running` → `succeeded` or `failed`
1624
+ * - **Stream**: `streaming` (once started)
1625
+ *
1626
+ * **Important:** Status is set to `succeeded` only after successful validation.
1627
+ * If validation fails, status will be `failed` even if the API request succeeded.
1628
+ *
1629
+ * Use the `statusChange` event to track status transitions in real-time.
1630
+ *
1631
+ * @throws {ExecutionNotStartedError} If the execution has not been started yet.
1632
+ * @returns The current status of the execution.
1633
+ *
1634
+ * @example
1635
+ * ```typescript
1636
+ * const execution = await canvas.execute({ query: 'test' }, { async: true })
1637
+ * console.log(execution.status) // 'created'
1638
+ *
1639
+ * await execution.result
1640
+ * console.log(execution.status) // 'succeeded' or 'failed'
1641
+ * ```
1642
+ */
1643
+ get status() {
1644
+ if (!this._status) {
1645
+ throw new ExecutionNotStartedError();
1646
+ }
1647
+ return this._status;
1648
+ }
1649
+ /**
1650
+ * Sets the status of the execution.
1651
+ *
1652
+ * @param status - The new status of the execution.
1653
+ * @private
1654
+ */
1655
+ set status(status) {
1656
+ const changed = this._status !== status;
1657
+ this._status = status;
1658
+ if (changed) {
1659
+ this.emit("statusChange", status);
1660
+ }
1661
+ }
1515
1662
  /**
1516
1663
  * Gets the input variables provided to this execution.
1517
1664
  *
@@ -1552,6 +1699,31 @@ class CanvasExecution {
1552
1699
  get isStream() {
1553
1700
  return Boolean(this._params.stream);
1554
1701
  }
1702
+ /**
1703
+ * Gets the raw API response without any processing or validation.
1704
+ * Automatically starts execution and waits for completion (including polling for async executions).
1705
+ *
1706
+ * For sync executions, returns the complete API response.
1707
+ * For async executions, returns the polling response with status and output.
1708
+ *
1709
+ * @throws {InvalidExecutionModeError} If called on a streaming execution.
1710
+ * @returns A promise resolving to the raw API result.
1711
+ */
1712
+ get rawResult() {
1713
+ if (this.isStream) {
1714
+ throw new InvalidExecutionModeError("rawResult is not available for streaming executions");
1715
+ }
1716
+ if (this.isSync) {
1717
+ if (!this._resultPromise) {
1718
+ throw new ExecutionNotStartedError();
1719
+ }
1720
+ return this._resultPromise.then(() => this._rawResultValue);
1721
+ }
1722
+ if (!this._resultPromise) {
1723
+ this._resultPromise = this.startPolling();
1724
+ }
1725
+ return this._resultPromise.then(() => this._rawResultValue);
1726
+ }
1555
1727
  /**
1556
1728
  * Type guard to check if params indicate async execution.
1557
1729
  *
@@ -1610,25 +1782,95 @@ class CanvasExecution {
1610
1782
  cancel() {
1611
1783
  this._abortController.abort();
1612
1784
  }
1785
+ /**
1786
+ * Starts polling for the execution result without waiting for the promise to resolve.
1787
+ * This allows users to track execution progress via events rather than awaiting a promise.
1788
+ *
1789
+ * The following events will be emitted during polling:
1790
+ * - `statusChange`: Emitted when the execution status changes (e.g., 'created' → 'running' → 'succeeded')
1791
+ * - `poll`: Emitted on each polling attempt with the server response
1792
+ * - `success`: Emitted when the execution completes successfully with the final result
1793
+ * - `error`: Emitted if the execution fails
1794
+ *
1795
+ * **Important:** Events are only emitted while polling is active. You must either call `poll()` or
1796
+ * await `execution.result` to start polling. Simply setting up event listeners without starting
1797
+ * polling will not trigger any events.
1798
+ *
1799
+ * **Note:** If the execution has already completed (succeeded or failed) when fetched, the `success`
1800
+ * and `error` events will not fire since no polling is needed. Check the `status` property and
1801
+ * access the `result` directly for already-completed executions.
1802
+ *
1803
+ * @throws {InvalidExecutionModeError} If called on a non-async execution (sync or stream).
1804
+ * @throws {ExecutionNotStartedError} If the execution has not been started yet (no ID assigned).
1805
+ *
1806
+ * @example
1807
+ * ```typescript
1808
+ * const execution = await canvas.getExecution('execution-id')
1809
+ *
1810
+ * // Check if already completed
1811
+ * if (execution.status === 'succeeded' || execution.status === 'failed') {
1812
+ * // Access result directly - events won't fire
1813
+ * const result = await execution.result
1814
+ * console.log('Already completed:', result)
1815
+ * } else {
1816
+ * // Still running - set up events and start polling
1817
+ * execution.on('statusChange', (status) => {
1818
+ * console.log('Status:', status)
1819
+ * })
1820
+ *
1821
+ * execution.on('success', (result) => {
1822
+ * console.log('Completed:', result)
1823
+ * })
1824
+ *
1825
+ * execution.on('error', (error) => {
1826
+ * console.error('Failed:', error)
1827
+ * })
1828
+ *
1829
+ * // Start polling without waiting
1830
+ * execution.poll()
1831
+ * }
1832
+ * ```
1833
+ */
1834
+ poll() {
1835
+ if (!this.isAsync) {
1836
+ throw new InvalidExecutionModeError("Polling is only supported for async executions");
1837
+ }
1838
+ if (!this._id) {
1839
+ throw new ExecutionNotStartedError();
1840
+ }
1841
+ if (this._resultPromise) {
1842
+ return;
1843
+ }
1844
+ this._resultPromise = this.startPolling();
1845
+ this._resultPromise.catch(() => {
1846
+ });
1847
+ }
1613
1848
  /**
1614
1849
  * Builds the base request body shared across all execution types.
1615
- * Includes messages, overrides, and structured output configuration.
1850
+ * Includes messages, overrides, tags, label, and structured output configuration.
1616
1851
  *
1617
1852
  * @returns The base request body object.
1618
1853
  */
1619
1854
  get baseBody() {
1855
+ if (this._params.label && !this._params.applicationId) {
1856
+ console.warn(
1857
+ '[Tela SDK - WARNING] The "label" field is only applicable when using applicationId. It will be ignored since no applicationId is provided.'
1858
+ );
1859
+ }
1620
1860
  const body = {
1621
1861
  canvasId: this._params.canvasId,
1622
1862
  applicationId: this._params.applicationId,
1623
1863
  versionId: this._params.versionId,
1624
- messages: this._params.messages
1864
+ messages: this._params.messages,
1865
+ tags: this._params.tags,
1866
+ label: this._params.label
1625
1867
  };
1626
- if (this._params.override && this._outputSchema instanceof z.ZodType) {
1868
+ if (this._params.override && this._outputSchema instanceof z__default.ZodType) {
1627
1869
  return {
1628
1870
  ...body,
1629
1871
  override: {
1630
1872
  ...this._params.override,
1631
- structured_output: z.toJSONSchema(this._outputSchema)
1873
+ structured_output: z__default.toJSONSchema(this._outputSchema)
1632
1874
  }
1633
1875
  };
1634
1876
  }
@@ -1675,12 +1917,20 @@ class CanvasExecution {
1675
1917
  signal: this._abortController.signal
1676
1918
  }).then((response) => {
1677
1919
  this._id = response.id;
1678
- return response.choices?.[0]?.message?.content;
1920
+ this._rawResultValue = response;
1921
+ return getResultFromPollingResponse(response);
1679
1922
  }).then((content) => {
1680
- if (this._skipResultValidation || !(this._outputSchema instanceof z.ZodType)) {
1681
- return content;
1923
+ const validatedContent = this._skipResultValidation || !(this._outputSchema instanceof z__default.ZodType) ? content : this._outputSchema.parse(content);
1924
+ this.status = "succeeded";
1925
+ this.emit("success", validatedContent);
1926
+ return validatedContent;
1927
+ }).catch((error) => {
1928
+ this.status = "failed";
1929
+ if (this.listenerCount("error") > 0) {
1930
+ this.emit("error", error);
1931
+ return;
1682
1932
  }
1683
- return this._outputSchema.parse(content);
1933
+ throw error;
1684
1934
  });
1685
1935
  return this._resultPromise;
1686
1936
  }
@@ -1704,6 +1954,13 @@ class CanvasExecution {
1704
1954
  signal: this._abortController.signal
1705
1955
  }).then((response) => {
1706
1956
  this._id = response.id;
1957
+ this.status = response.status;
1958
+ this.emit("poll", {
1959
+ id: response.id,
1960
+ status: response.status,
1961
+ outputContent: response.output_content,
1962
+ rawOutput: response.raw_output
1963
+ });
1707
1964
  return response;
1708
1965
  });
1709
1966
  }
@@ -1724,6 +1981,7 @@ class CanvasExecution {
1724
1981
  stream: true,
1725
1982
  signal: this._abortController.signal
1726
1983
  });
1984
+ this.status = "streaming";
1727
1985
  return this._stream;
1728
1986
  }
1729
1987
  /**
@@ -1752,8 +2010,12 @@ class CanvasExecution {
1752
2010
  signal
1753
2011
  }
1754
2012
  );
2013
+ this.status = response.status;
2014
+ this.emit("poll", response);
1755
2015
  if (response.status === "failed") {
1756
- throw new ExecutionFailedError(response.rawOutput);
2016
+ const error = new ExecutionFailedError(response.rawOutput);
2017
+ this.emit("error", error);
2018
+ throw error;
1757
2019
  }
1758
2020
  if (response.status !== "succeeded") {
1759
2021
  return {
@@ -1761,15 +2023,28 @@ class CanvasExecution {
1761
2023
  value: void 0
1762
2024
  };
1763
2025
  }
2026
+ this._rawResultValue = response;
2027
+ this.emit("success", getResultFromPollingResponse(response));
1764
2028
  return {
1765
2029
  done: response.status === "succeeded",
1766
- value: response.outputContent.content
2030
+ value: getResultFromPollingResponse(response)
1767
2031
  };
1768
2032
  }).then((value) => {
1769
- if (this._skipResultValidation || !(this._outputSchema instanceof z.ZodType)) {
2033
+ if (this._skipResultValidation || !(this._outputSchema instanceof z__default.ZodType)) {
1770
2034
  return value;
1771
2035
  }
1772
2036
  return this._outputSchema.parse(value);
2037
+ }).catch((error) => {
2038
+ if (this._status !== "failed") {
2039
+ this.status = "failed";
2040
+ }
2041
+ if (this.listenerCount("error") > 0) {
2042
+ if (!(error instanceof ExecutionFailedError)) {
2043
+ this.emit("error", error);
2044
+ }
2045
+ return;
2046
+ }
2047
+ throw error;
1773
2048
  });
1774
2049
  }
1775
2050
  /**
@@ -1862,14 +2137,8 @@ var __publicField$1 = (obj, key, value) => {
1862
2137
  return value;
1863
2138
  };
1864
2139
  const zod = {
1865
- string,
1866
- number,
1867
- boolean,
1868
- object,
1869
- array,
1870
- file: TelaFileSchema,
1871
- any,
1872
- unknown
2140
+ ...z,
2141
+ file: TelaFileSchema
1873
2142
  };
1874
2143
  function fetchById(id, client) {
1875
2144
  return client.get(`/prompt/${id}/promoted-version`);
@@ -1949,7 +2218,7 @@ class Canvas {
1949
2218
  *
1950
2219
  * @private
1951
2220
  */
1952
- constructor({ id, applicationId, name, versionId, input, output, client, variables }) {
2221
+ constructor({ id, applicationId, name, versionId, input, output, client, variables, isWorkflow }) {
1953
2222
  __publicField$1(this, "_id");
1954
2223
  __publicField$1(this, "_versionId");
1955
2224
  __publicField$1(this, "_applicationId");
@@ -1958,6 +2227,7 @@ class Canvas {
1958
2227
  __publicField$1(this, "_output");
1959
2228
  __publicField$1(this, "_client");
1960
2229
  __publicField$1(this, "_variables");
2230
+ __publicField$1(this, "_isWorkflow");
1961
2231
  this._id = id;
1962
2232
  this._applicationId = applicationId;
1963
2233
  this._name = name;
@@ -1966,6 +2236,7 @@ class Canvas {
1966
2236
  this._output = output && output(zod);
1967
2237
  this._client = client;
1968
2238
  this._variables = variables;
2239
+ this._isWorkflow = isWorkflow;
1969
2240
  }
1970
2241
  /**
1971
2242
  * Gets a canvas by its ID.
@@ -1994,7 +2265,8 @@ class Canvas {
1994
2265
  input,
1995
2266
  output,
1996
2267
  client,
1997
- variables: promptVersion.variables
2268
+ variables: promptVersion.variables,
2269
+ isWorkflow: promptVersion.isWorkflow
1998
2270
  });
1999
2271
  }
2000
2272
  /**
@@ -2045,6 +2317,14 @@ class Canvas {
2045
2317
  get variables() {
2046
2318
  return this._variables;
2047
2319
  }
2320
+ /**
2321
+ * Gets whether this canvas is a workflow.
2322
+ *
2323
+ * @returns True if the canvas is a workflow.
2324
+ */
2325
+ get isWorkflow() {
2326
+ return this._isWorkflow;
2327
+ }
2048
2328
  /**
2049
2329
  * Validates and parses input variables using the canvas input schema.
2050
2330
  *
@@ -2083,6 +2363,43 @@ class Canvas {
2083
2363
  }
2084
2364
  };
2085
2365
  }
2366
+ /**
2367
+ * Fetches an existing async execution by its ID.
2368
+ *
2369
+ * This method retrieves the current state of an async execution that was previously
2370
+ * started on this canvas. Only async executions can be fetched, as they are the only
2371
+ * ones with persistent UUIDs on the server.
2372
+ *
2373
+ * @param id - The UUID of the async execution to fetch.
2374
+ * @param options - Optional configuration for polling behavior.
2375
+ * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
2376
+ * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
2377
+ * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
2378
+ * @returns A promise resolving to a CanvasExecution instance with the fetched state.
2379
+ *
2380
+ * @example
2381
+ * ```typescript
2382
+ * // Start an async execution
2383
+ * const execution = await canvas.execute({ query: 'test' }, { async: true })
2384
+ * const executionId = execution.id
2385
+ *
2386
+ * // Later, fetch the execution by ID
2387
+ * const fetched = await canvas.getExecution(executionId)
2388
+ * console.log(fetched.status) // 'running', 'succeeded', or 'failed'
2389
+ *
2390
+ * // Use poll() for event-driven progress tracking
2391
+ * fetched.on('statusChange', (status) => console.log('Status:', status))
2392
+ * fetched.poll()
2393
+ * ```
2394
+ */
2395
+ async getExecution(id, options) {
2396
+ return CanvasExecution.fetch(
2397
+ id,
2398
+ this._output,
2399
+ this._client,
2400
+ options
2401
+ );
2402
+ }
2086
2403
  }
2087
2404
 
2088
2405
  var __defProp = Object.defineProperty;
@@ -2110,20 +2427,22 @@ const _TelaSDK = class _TelaSDK extends BaseClient {
2110
2427
  __publicField(this, "createFile", TelaFile.create.bind(this));
2111
2428
  /**
2112
2429
  * Retrieves a canvas by its ID, version ID, or application ID.
2113
- * Validates input and output schemas if Zod schemas are provided.
2430
+ * Validates input and output schemas if provided via schema builder functions.
2114
2431
  *
2115
2432
  * @param options - Options for retrieving the canvas.
2116
2433
  * @returns A promise resolving to a Canvas instance.
2117
2434
  *
2118
2435
  * @example
2119
2436
  * ```typescript
2120
- * import { z } from 'zod';
2121
- *
2122
2437
  * // Get canvas by ID with schemas
2123
2438
  * const canvas = await tela.canvas.get({
2124
2439
  * id: 'canvas-id',
2125
- * input: z.object({ query: z.string() }),
2126
- * output: z.object({ response: z.string() })
2440
+ * input: schema => schema.object({
2441
+ * query: schema.string()
2442
+ * }),
2443
+ * output: schema => schema.object({
2444
+ * response: schema.string()
2445
+ * })
2127
2446
  * });
2128
2447
  *
2129
2448
  * // Get canvas by application ID
package/package.json CHANGED
@@ -1,14 +1,38 @@
1
1
  {
2
2
  "name": "@meistrari/tela-sdk-js",
3
- "version": "2.0.0",
4
- "type": "module",
3
+ "version": "2.2.0",
5
4
  "repository": {
6
5
  "type": "git",
7
6
  "url": "https://github.com/meistrari/tela-sdk-js.git"
8
7
  },
9
- "types": "dist/index.d.ts",
10
8
  "main": "dist/index.mjs",
11
9
  "module": "dist/index.mjs",
10
+ "dependencies": {
11
+ "change-case": "5.4.4",
12
+ "emittery": "^1.2.0",
13
+ "minimatch": "10.0.1",
14
+ "zod": "4.1.12"
15
+ },
16
+ "devDependencies": {
17
+ "@antfu/eslint-config": "3.0.0",
18
+ "@types/bun": "1.2.23",
19
+ "@types/node": "22.5.5",
20
+ "@typhonjs-typedoc/typedoc-theme-dmt": "0.4.0",
21
+ "@vitest/browser": "3.0.8",
22
+ "husky": "9.1.6",
23
+ "lint-staged": "15.2.10",
24
+ "playwright": "1.51.0",
25
+ "typedoc": "0.28.14",
26
+ "typedoc-plugin-merge-modules": "7.0.0",
27
+ "typedoc-unhoax-theme": "0.5.3",
28
+ "typescript": "5.6.3",
29
+ "unbuild": "2.0.0",
30
+ "unenv": "2.0.0-rc.14",
31
+ "vitest": "3.0.8"
32
+ },
33
+ "peerDependencies": {
34
+ "typescript": "5.6.3"
35
+ },
12
36
  "exports": {
13
37
  ".": {
14
38
  "types": "./dist/index.d.ts",
@@ -16,11 +40,16 @@
16
40
  "require": "./dist/index.cjs"
17
41
  }
18
42
  },
43
+ "engines": {
44
+ "node": "^20.15.1"
45
+ },
19
46
  "files": [
20
47
  "dist"
21
48
  ],
22
- "engines": {
23
- "node": "^20.15.1"
49
+ "lint-staged": {
50
+ "*.{js,ts}": [
51
+ "eslint --fix"
52
+ ]
24
53
  },
25
54
  "scripts": {
26
55
  "prepublishOnly": "bun run build",
@@ -39,34 +68,6 @@
39
68
  "docs": "typedoc",
40
69
  "docs:serve": "bunx http-server docs"
41
70
  },
42
- "dependencies": {
43
- "@meistrari/vault-http-client": "2.3.6",
44
- "change-case": "5.4.4",
45
- "minimatch": "10.0.1",
46
- "zod": "4.1.12"
47
- },
48
- "devDependencies": {
49
- "@antfu/eslint-config": "3.0.0",
50
- "@types/bun": "1.2.23",
51
- "@types/node": "22.5.5",
52
- "@typhonjs-typedoc/typedoc-theme-dmt": "0.4.0",
53
- "@vitest/browser": "3.0.8",
54
- "husky": "9.1.6",
55
- "lint-staged": "15.2.10",
56
- "playwright": "1.51.0",
57
- "typedoc": "0.28.14",
58
- "typedoc-plugin-merge-modules": "7.0.0",
59
- "typedoc-unhoax-theme": "0.5.3",
60
- "unbuild": "2.0.0",
61
- "unenv": "2.0.0-rc.14",
62
- "vitest": "3.0.8"
63
- },
64
- "peerDependencies": {
65
- "typescript": "5.8.2"
66
- },
67
- "lint-staged": {
68
- "*.{js,ts}": [
69
- "eslint --fix"
70
- ]
71
- }
71
+ "type": "module",
72
+ "types": "dist/index.d.ts"
72
73
  }