@meistrari/tela-sdk-js 0.0.4 → 1.0.1

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.cjs CHANGED
@@ -1,10 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const web = require('node:stream/web');
4
3
  const changeCase = require('change-case');
5
4
  const micromatch = require('micromatch');
6
- const node_fs = require('node:fs');
7
- const node_stream = require('node:stream');
8
5
 
9
6
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
7
 
@@ -23,7 +20,7 @@ function _interopNamespaceCompat(e) {
23
20
  const changeCase__namespace = /*#__PURE__*/_interopNamespaceCompat(changeCase);
24
21
  const micromatch__default = /*#__PURE__*/_interopDefaultCompat(micromatch);
25
22
 
26
- const version = "0.0.4";
23
+ const version = "1.0.1";
27
24
 
28
25
  var __defProp$5 = Object.defineProperty;
29
26
  var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -460,7 +457,7 @@ class Stream {
460
457
  const self = this;
461
458
  let iter;
462
459
  const encoder = new TextEncoder();
463
- return new web.ReadableStream({
460
+ return new ReadableStream({
464
461
  async start() {
465
462
  iter = self[Symbol.asyncIterator]();
466
463
  },
@@ -1074,13 +1071,7 @@ class TelaFile {
1074
1071
  type: "application/octet-stream"
1075
1072
  });
1076
1073
  }
1077
- if (this._file instanceof node_fs.ReadStream) {
1078
- const webStream = node_stream.Readable.toWeb(this._file);
1079
- const [sizeStream, contentStream] = webStream.tee();
1080
- this._size = await getStreamSize(sizeStream);
1081
- return contentStream;
1082
- }
1083
- if (this._file instanceof web.ReadableStream) {
1074
+ if (this._file instanceof ReadableStream) {
1084
1075
  const [sizeStream, contentStream] = this._file.tee();
1085
1076
  this._size = await getStreamSize(sizeStream);
1086
1077
  return contentStream;
@@ -1199,7 +1190,7 @@ class ChatCompletions extends Resource {
1199
1190
  "Content-Type": contentType,
1200
1191
  ...file.size ? { "Content-Length": file.size.toString() } : {}
1201
1192
  },
1202
- // @ts-expect-error: duplex is not supported
1193
+ // duplex is not supported
1203
1194
  duplex: "half"
1204
1195
  });
1205
1196
  if (!uploadResponse.ok) {
package/dist/index.d.cts CHANGED
@@ -1,6 +1,3 @@
1
- import { ReadStream } from 'node:fs';
2
- import { ReadableStream } from 'node:stream/web';
3
-
4
1
  type HTTPMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5
2
  type RequestOptions<Req = unknown | Record<string, unknown>> = {
6
3
  method?: HTTPMethods;
@@ -141,7 +138,7 @@ type TelaFileOptions = {
141
138
  * Represents the possible types for a file input,
142
139
  * which can be a URL string, Uint8Array, ReadableStream, ReadStream, Blob, or File.
143
140
  */
144
- type TelaFileInput = string | Uint8Array | ReadableStream | ReadStream | Blob | File;
141
+ type TelaFileInput = string | Uint8Array | ReadableStream | Blob | File;
145
142
  /**
146
143
  * Represents a file with support for various types including URLs, binary data, streams, and Blobs.
147
144
  *
@@ -189,7 +186,7 @@ declare class TelaFile {
189
186
  * @throws {InvalidFileURL} If the provided URL is not valid.
190
187
  * @throws {EmptyFileError} If the provided file is empty.
191
188
  */
192
- constructor(file: string | Uint8Array | ReadableStream | ReadStream | Blob | File, options?: TelaFileOptions);
189
+ constructor(file: string | Uint8Array | ReadableStream | Blob | File, options?: TelaFileOptions);
193
190
  /**
194
191
  * Retrieves the options provided during instantiation.
195
192
  *
@@ -241,6 +238,14 @@ declare class TelaFile {
241
238
  */
242
239
  declare function createTelaFile(file: TelaFileInput, options?: TelaFileOptions): TelaFile;
243
240
 
241
+ /**
242
+ * Base class for all resources.
243
+ */
244
+ declare class Resource {
245
+ protected _client: BaseClient;
246
+ constructor(client: BaseClient);
247
+ }
248
+
244
249
  /**
245
250
  * Represents a stream of items that can be asynchronously iterated over.
246
251
  */
@@ -297,14 +302,6 @@ declare class Stream<Item> implements AsyncIterable<Item> {
297
302
  toReadableStream(): ReadableStream;
298
303
  }
299
304
 
300
- /**
301
- * Base class for all resources.
302
- */
303
- declare class Resource {
304
- protected _client: BaseClient;
305
- constructor(client: BaseClient);
306
- }
307
-
308
305
  /**
309
306
  * Manages chat completion operations.
310
307
  *
package/dist/index.d.mts CHANGED
@@ -1,6 +1,3 @@
1
- import { ReadStream } from 'node:fs';
2
- import { ReadableStream } from 'node:stream/web';
3
-
4
1
  type HTTPMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5
2
  type RequestOptions<Req = unknown | Record<string, unknown>> = {
6
3
  method?: HTTPMethods;
@@ -141,7 +138,7 @@ type TelaFileOptions = {
141
138
  * Represents the possible types for a file input,
142
139
  * which can be a URL string, Uint8Array, ReadableStream, ReadStream, Blob, or File.
143
140
  */
144
- type TelaFileInput = string | Uint8Array | ReadableStream | ReadStream | Blob | File;
141
+ type TelaFileInput = string | Uint8Array | ReadableStream | Blob | File;
145
142
  /**
146
143
  * Represents a file with support for various types including URLs, binary data, streams, and Blobs.
147
144
  *
@@ -189,7 +186,7 @@ declare class TelaFile {
189
186
  * @throws {InvalidFileURL} If the provided URL is not valid.
190
187
  * @throws {EmptyFileError} If the provided file is empty.
191
188
  */
192
- constructor(file: string | Uint8Array | ReadableStream | ReadStream | Blob | File, options?: TelaFileOptions);
189
+ constructor(file: string | Uint8Array | ReadableStream | Blob | File, options?: TelaFileOptions);
193
190
  /**
194
191
  * Retrieves the options provided during instantiation.
195
192
  *
@@ -241,6 +238,14 @@ declare class TelaFile {
241
238
  */
242
239
  declare function createTelaFile(file: TelaFileInput, options?: TelaFileOptions): TelaFile;
243
240
 
241
+ /**
242
+ * Base class for all resources.
243
+ */
244
+ declare class Resource {
245
+ protected _client: BaseClient;
246
+ constructor(client: BaseClient);
247
+ }
248
+
244
249
  /**
245
250
  * Represents a stream of items that can be asynchronously iterated over.
246
251
  */
@@ -297,14 +302,6 @@ declare class Stream<Item> implements AsyncIterable<Item> {
297
302
  toReadableStream(): ReadableStream;
298
303
  }
299
304
 
300
- /**
301
- * Base class for all resources.
302
- */
303
- declare class Resource {
304
- protected _client: BaseClient;
305
- constructor(client: BaseClient);
306
- }
307
-
308
305
  /**
309
306
  * Manages chat completion operations.
310
307
  *
package/dist/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { ReadStream } from 'node:fs';
2
- import { ReadableStream } from 'node:stream/web';
3
-
4
1
  type HTTPMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5
2
  type RequestOptions<Req = unknown | Record<string, unknown>> = {
6
3
  method?: HTTPMethods;
@@ -141,7 +138,7 @@ type TelaFileOptions = {
141
138
  * Represents the possible types for a file input,
142
139
  * which can be a URL string, Uint8Array, ReadableStream, ReadStream, Blob, or File.
143
140
  */
144
- type TelaFileInput = string | Uint8Array | ReadableStream | ReadStream | Blob | File;
141
+ type TelaFileInput = string | Uint8Array | ReadableStream | Blob | File;
145
142
  /**
146
143
  * Represents a file with support for various types including URLs, binary data, streams, and Blobs.
147
144
  *
@@ -189,7 +186,7 @@ declare class TelaFile {
189
186
  * @throws {InvalidFileURL} If the provided URL is not valid.
190
187
  * @throws {EmptyFileError} If the provided file is empty.
191
188
  */
192
- constructor(file: string | Uint8Array | ReadableStream | ReadStream | Blob | File, options?: TelaFileOptions);
189
+ constructor(file: string | Uint8Array | ReadableStream | Blob | File, options?: TelaFileOptions);
193
190
  /**
194
191
  * Retrieves the options provided during instantiation.
195
192
  *
@@ -241,6 +238,14 @@ declare class TelaFile {
241
238
  */
242
239
  declare function createTelaFile(file: TelaFileInput, options?: TelaFileOptions): TelaFile;
243
240
 
241
+ /**
242
+ * Base class for all resources.
243
+ */
244
+ declare class Resource {
245
+ protected _client: BaseClient;
246
+ constructor(client: BaseClient);
247
+ }
248
+
244
249
  /**
245
250
  * Represents a stream of items that can be asynchronously iterated over.
246
251
  */
@@ -297,14 +302,6 @@ declare class Stream<Item> implements AsyncIterable<Item> {
297
302
  toReadableStream(): ReadableStream;
298
303
  }
299
304
 
300
- /**
301
- * Base class for all resources.
302
- */
303
- declare class Resource {
304
- protected _client: BaseClient;
305
- constructor(client: BaseClient);
306
- }
307
-
308
305
  /**
309
306
  * Manages chat completion operations.
310
307
  *
package/dist/index.mjs CHANGED
@@ -1,10 +1,7 @@
1
- import { ReadableStream } from 'node:stream/web';
2
1
  import * as changeCase from 'change-case';
3
2
  import micromatch from 'micromatch';
4
- import { ReadStream } from 'node:fs';
5
- import { Readable } from 'node:stream';
6
3
 
7
- const version = "0.0.4";
4
+ const version = "1.0.1";
8
5
 
9
6
  var __defProp$5 = Object.defineProperty;
10
7
  var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -1055,12 +1052,6 @@ class TelaFile {
1055
1052
  type: "application/octet-stream"
1056
1053
  });
1057
1054
  }
1058
- if (this._file instanceof ReadStream) {
1059
- const webStream = Readable.toWeb(this._file);
1060
- const [sizeStream, contentStream] = webStream.tee();
1061
- this._size = await getStreamSize(sizeStream);
1062
- return contentStream;
1063
- }
1064
1055
  if (this._file instanceof ReadableStream) {
1065
1056
  const [sizeStream, contentStream] = this._file.tee();
1066
1057
  this._size = await getStreamSize(sizeStream);
@@ -1180,7 +1171,7 @@ class ChatCompletions extends Resource {
1180
1171
  "Content-Type": contentType,
1181
1172
  ...file.size ? { "Content-Length": file.size.toString() } : {}
1182
1173
  },
1183
- // @ts-expect-error: duplex is not supported
1174
+ // duplex is not supported
1184
1175
  duplex: "half"
1185
1176
  });
1186
1177
  if (!uploadResponse.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-sdk-js",
3
- "version": "0.0.4",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,10 @@
26
26
  "prepublishOnly": "bun run build",
27
27
  "release": "bunx bumpp & npm publish",
28
28
  "build": "bunx unbuild",
29
- "test": "bun test",
29
+ "test:default": "vitest run",
30
+ "test:browser": "vitest run --browser",
31
+ "test:bun": "bun test",
32
+ "test:all": "bun run test:default && bun run test:browser && bun run test:bun",
30
33
  "lint": "eslint . --fix",
31
34
  "lint:fix": "eslint . --fix",
32
35
  "check": "eslint . --quiet && tsc --noEmit",
@@ -38,15 +41,20 @@
38
41
  },
39
42
  "devDependencies": {
40
43
  "@antfu/eslint-config": "3.0.0",
44
+ "@rollup/plugin-inject": "5.0.5",
41
45
  "@types/bun": "latest",
42
46
  "@types/micromatch": "4.0.9",
43
47
  "@types/node": "22.5.5",
48
+ "@vitest/browser": "^3.0.8",
44
49
  "husky": "9.1.6",
45
50
  "lint-staged": "15.2.10",
46
- "unbuild": "^2.0.0"
51
+ "playwright": "1.51.0",
52
+ "unbuild": "2.0.0",
53
+ "unenv": "2.0.0-rc.14",
54
+ "vitest": "3.0.8"
47
55
  },
48
56
  "peerDependencies": {
49
- "typescript": "5.6.0"
57
+ "typescript": "5.8.2"
50
58
  },
51
59
  "lint-staged": {
52
60
  "*.{js,ts}": [