@speechall/sdk 0.0.1 → 2.0.4

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.
Files changed (151) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +62 -0
  3. package/.beads/issues.jsonl +46 -0
  4. package/.beads/metadata.json +4 -0
  5. package/.env.example +5 -0
  6. package/.fernignore +45 -0
  7. package/.gitattributes +3 -0
  8. package/.github/copilot-instructions.md +78 -0
  9. package/.github/workflows/auto-release-simple.yml.deprecated +106 -0
  10. package/.github/workflows/auto-release.yml +67 -0
  11. package/.github/workflows/ci.yml +41 -0
  12. package/.github/workflows/release.yml +57 -0
  13. package/AGENTS.md +94 -0
  14. package/CHANGELOG.md +58 -0
  15. package/CLAUDE.md +75 -0
  16. package/README.md +294 -155
  17. package/examples/CLAUDE.md +136 -0
  18. package/examples/advanced-options.ts +213 -0
  19. package/examples/basic-transcription.ts +66 -0
  20. package/examples/error-handling.ts +251 -0
  21. package/examples/list-models.ts +112 -0
  22. package/examples/remote-transcription.ts +60 -0
  23. package/fern/fern.config.json +4 -0
  24. package/fern/generators.yml +43 -0
  25. package/jest.config.js +11 -0
  26. package/package.json +26 -44
  27. package/regenerate.sh +45 -0
  28. package/scripts/fix-generated-code.sh +25 -0
  29. package/src/BaseClient.ts +82 -0
  30. package/src/Client.ts +30 -0
  31. package/src/api/errors/BadRequestError.ts +22 -0
  32. package/src/api/errors/GatewayTimeoutError.ts +22 -0
  33. package/src/api/errors/InternalServerError.ts +22 -0
  34. package/src/api/errors/NotFoundError.ts +22 -0
  35. package/src/api/errors/PaymentRequiredError.ts +22 -0
  36. package/src/api/errors/ServiceUnavailableError.ts +22 -0
  37. package/src/api/errors/TooManyRequestsError.ts +22 -0
  38. package/src/api/errors/UnauthorizedError.ts +22 -0
  39. package/src/api/errors/index.ts +8 -0
  40. package/src/api/index.ts +3 -0
  41. package/src/api/resources/index.ts +5 -0
  42. package/src/api/resources/replacementRules/client/Client.ts +148 -0
  43. package/src/api/resources/replacementRules/client/index.ts +1 -0
  44. package/src/api/resources/replacementRules/client/requests/CreateReplacementRulesetRequest.ts +25 -0
  45. package/src/api/resources/replacementRules/client/requests/index.ts +1 -0
  46. package/src/api/resources/replacementRules/index.ts +2 -0
  47. package/src/api/resources/replacementRules/types/CreateReplacementRulesetResponse.ts +6 -0
  48. package/src/api/resources/replacementRules/types/index.ts +1 -0
  49. package/src/api/resources/speechToText/client/Client.ts +275 -0
  50. package/src/api/resources/speechToText/client/index.ts +1 -0
  51. package/src/api/resources/speechToText/client/requests/RemoteTranscriptionConfiguration.ts +20 -0
  52. package/src/api/resources/speechToText/client/requests/TranscribeRequest.ts +26 -0
  53. package/src/api/resources/speechToText/client/requests/index.ts +2 -0
  54. package/src/api/resources/speechToText/index.ts +1 -0
  55. package/src/api/types/BaseTranscriptionConfiguration.ts +29 -0
  56. package/src/api/types/ErrorResponse.ts +11 -0
  57. package/src/api/types/ExactRule.ts +13 -0
  58. package/src/api/types/RegexGroupRule.ts +28 -0
  59. package/src/api/types/RegexRule.ts +28 -0
  60. package/src/api/types/ReplacementRule.ts +25 -0
  61. package/src/api/types/SpeechToTextModel.ts +90 -0
  62. package/src/api/types/TranscriptLanguageCode.ts +114 -0
  63. package/src/api/types/TranscriptOutputFormat.ts +18 -0
  64. package/src/api/types/TranscriptionDetailed.ts +19 -0
  65. package/src/api/types/TranscriptionModelIdentifier.ts +80 -0
  66. package/src/api/types/TranscriptionOnlyText.ts +11 -0
  67. package/src/api/types/TranscriptionProvider.ts +23 -0
  68. package/src/api/types/TranscriptionResponse.ts +8 -0
  69. package/src/api/types/TranscriptionSegment.ts +17 -0
  70. package/src/api/types/TranscriptionWord.ts +17 -0
  71. package/src/api/types/index.ts +16 -0
  72. package/src/auth/BearerAuthProvider.ts +37 -0
  73. package/src/auth/index.ts +1 -0
  74. package/src/core/auth/AuthProvider.ts +6 -0
  75. package/src/core/auth/AuthRequest.ts +9 -0
  76. package/src/core/auth/BasicAuth.ts +32 -0
  77. package/src/core/auth/BearerToken.ts +20 -0
  78. package/src/core/auth/NoOpAuthProvider.ts +8 -0
  79. package/src/core/auth/index.ts +5 -0
  80. package/src/core/base64.ts +27 -0
  81. package/src/core/exports.ts +2 -0
  82. package/src/core/fetcher/APIResponse.ts +23 -0
  83. package/src/core/fetcher/BinaryResponse.ts +34 -0
  84. package/src/core/fetcher/EndpointMetadata.ts +13 -0
  85. package/src/core/fetcher/EndpointSupplier.ts +14 -0
  86. package/src/core/fetcher/Fetcher.ts +391 -0
  87. package/src/core/fetcher/Headers.ts +93 -0
  88. package/src/core/fetcher/HttpResponsePromise.ts +116 -0
  89. package/src/core/fetcher/RawResponse.ts +61 -0
  90. package/src/core/fetcher/Supplier.ts +11 -0
  91. package/src/core/fetcher/createRequestUrl.ts +6 -0
  92. package/src/core/fetcher/getErrorResponseBody.ts +33 -0
  93. package/src/core/fetcher/getFetchFn.ts +3 -0
  94. package/src/core/fetcher/getHeader.ts +8 -0
  95. package/src/core/fetcher/getRequestBody.ts +20 -0
  96. package/src/core/fetcher/getResponseBody.ts +58 -0
  97. package/src/core/fetcher/index.ts +11 -0
  98. package/src/core/fetcher/makeRequest.ts +42 -0
  99. package/src/core/fetcher/requestWithRetries.ts +64 -0
  100. package/src/core/fetcher/signals.ts +26 -0
  101. package/src/core/file/exports.ts +1 -0
  102. package/src/core/file/file.ts +217 -0
  103. package/src/core/file/index.ts +2 -0
  104. package/src/core/file/types.ts +81 -0
  105. package/src/core/headers.ts +35 -0
  106. package/src/core/index.ts +7 -0
  107. package/src/core/json.ts +27 -0
  108. package/src/core/logging/exports.ts +19 -0
  109. package/src/core/logging/index.ts +1 -0
  110. package/src/core/logging/logger.ts +203 -0
  111. package/src/core/runtime/index.ts +1 -0
  112. package/src/core/runtime/runtime.ts +134 -0
  113. package/src/core/url/encodePathParam.ts +18 -0
  114. package/src/core/url/index.ts +3 -0
  115. package/src/core/url/join.ts +79 -0
  116. package/src/core/url/qs.ts +74 -0
  117. package/src/environments.ts +7 -0
  118. package/src/errors/SpeechallError.ts +58 -0
  119. package/src/errors/SpeechallTimeoutError.ts +13 -0
  120. package/src/errors/handleNonStatusCodeError.ts +37 -0
  121. package/src/errors/index.ts +2 -0
  122. package/src/exports.ts +1 -0
  123. package/src/index.ts +6 -0
  124. package/test-import.ts +17 -0
  125. package/tests/integration/api.test.ts +93 -0
  126. package/tests/unit/client.test.ts +91 -0
  127. package/tsconfig.json +20 -0
  128. package/dist/api.d.ts +0 -467
  129. package/dist/api.d.ts.map +0 -1
  130. package/dist/api.js +0 -592
  131. package/dist/base.d.ts +0 -32
  132. package/dist/base.d.ts.map +0 -1
  133. package/dist/base.js +0 -35
  134. package/dist/common.d.ts +0 -14
  135. package/dist/common.d.ts.map +0 -1
  136. package/dist/common.js +0 -91
  137. package/dist/configuration.d.ts +0 -23
  138. package/dist/configuration.d.ts.map +0 -1
  139. package/dist/configuration.js +0 -25
  140. package/dist/esm/api.js +0 -574
  141. package/dist/esm/base.js +0 -27
  142. package/dist/esm/common.js +0 -79
  143. package/dist/esm/configuration.js +0 -21
  144. package/dist/esm/example.js +0 -131
  145. package/dist/esm/index.js +0 -2
  146. package/dist/example.d.ts +0 -3
  147. package/dist/example.d.ts.map +0 -1
  148. package/dist/example.js +0 -133
  149. package/dist/index.d.ts +0 -3
  150. package/dist/index.d.ts.map +0 -1
  151. package/dist/index.js +0 -18
@@ -0,0 +1,37 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type * as core from "../core/index.js";
4
+ import * as errors from "./index.js";
5
+
6
+ export function handleNonStatusCodeError(
7
+ error: core.Fetcher.Error,
8
+ rawResponse: core.RawResponse,
9
+ method: string,
10
+ path: string,
11
+ ): never {
12
+ switch (error.reason) {
13
+ case "non-json":
14
+ throw new errors.SpeechallError({
15
+ statusCode: error.statusCode,
16
+ body: error.rawBody,
17
+ rawResponse: rawResponse,
18
+ });
19
+ case "body-is-null":
20
+ throw new errors.SpeechallError({
21
+ statusCode: error.statusCode,
22
+ rawResponse: rawResponse,
23
+ });
24
+ case "timeout":
25
+ throw new errors.SpeechallTimeoutError(`Timeout exceeded when calling ${method} ${path}.`);
26
+ case "unknown":
27
+ throw new errors.SpeechallError({
28
+ message: error.errorMessage,
29
+ rawResponse: rawResponse,
30
+ });
31
+ default:
32
+ throw new errors.SpeechallError({
33
+ message: "Unknown error",
34
+ rawResponse: rawResponse,
35
+ });
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ export { SpeechallError } from "./SpeechallError.js";
2
+ export { SpeechallTimeoutError } from "./SpeechallTimeoutError.js";
package/src/exports.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./core/exports.js";
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * as Speechall from "./api/index.js";
2
+ export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
3
+ export { SpeechallClient } from "./Client.js";
4
+ export { SpeechallEnvironment } from "./environments.js";
5
+ export { SpeechallError, SpeechallTimeoutError } from "./errors/index.js";
6
+ export * from "./exports.js";
package/test-import.ts ADDED
@@ -0,0 +1,17 @@
1
+ // Quick test to verify SDK imports work
2
+ import { SpeechallClient } from './dist';
3
+
4
+ console.log('SDK imported successfully');
5
+ console.log('SpeechallClient:', typeof SpeechallClient);
6
+
7
+ // Test basic client initialization
8
+ try {
9
+ const client = new SpeechallClient({
10
+ token: 'test-api-token',
11
+ });
12
+ console.log('Client initialized successfully');
13
+ console.log('Client type:', client.constructor.name);
14
+ console.log('Available methods:', Object.keys(Object.getPrototypeOf(client)));
15
+ } catch (error) {
16
+ console.error('Failed to initialize client:', error);
17
+ }
@@ -0,0 +1,93 @@
1
+ import { SpeechallClient } from '../../src';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+
5
+ // Skip integration tests if no API token is provided
6
+ const runIntegration = process.env.SPEECHALL_API_TOKEN !== undefined;
7
+ const describeIntegration = runIntegration ? describe : describe.skip;
8
+
9
+ describeIntegration('API Integration Tests', () => {
10
+ let client: SpeechallClient;
11
+
12
+ beforeAll(() => {
13
+ client = new SpeechallClient({
14
+ token: process.env.SPEECHALL_API_TOKEN!,
15
+ });
16
+ });
17
+
18
+ describe('SpeechToText API', () => {
19
+ it('should transcribe audio file', async () => {
20
+ // This test requires an actual audio file and API token
21
+ // Skip if no audio fixture is available
22
+ const audioPath = path.join(__dirname, '../fixtures/audio-sample.wav');
23
+
24
+ if (!fs.existsSync(audioPath)) {
25
+ console.log('Skipping: No audio fixture available');
26
+ return;
27
+ }
28
+
29
+ const audioBuffer = fs.readFileSync(audioPath);
30
+ const audioFile = new File([audioBuffer], 'audio-sample.wav', {
31
+ type: 'audio/wav',
32
+ });
33
+
34
+ const response = await client.speechToText.transcribe(
35
+ audioFile,
36
+ {
37
+ model: 'openai.whisper-1',
38
+ }
39
+ );
40
+
41
+ expect(response).toBeDefined();
42
+ // Add more specific assertions based on your API response structure
43
+ }, 30000); // 30 second timeout for API calls
44
+
45
+ it('should list available speech-to-text models', async () => {
46
+ const models = await client.speechToText.listSpeechToTextModels();
47
+
48
+ expect(models).toBeDefined();
49
+ expect(Array.isArray(models)).toBe(true);
50
+ }, 30000);
51
+ });
52
+
53
+ describe('Replacement Rules API', () => {
54
+ it('should create replacement ruleset', async () => {
55
+ const ruleset = await client.replacementRules.createReplacementRuleset({
56
+ name: 'Test Ruleset',
57
+ rules: [
58
+ {
59
+ kind: 'exact',
60
+ search: 'test',
61
+ replacement: 'TEST',
62
+ },
63
+ ],
64
+ });
65
+
66
+ expect(ruleset).toBeDefined();
67
+ expect(ruleset.id).toBeDefined();
68
+ });
69
+ });
70
+ });
71
+
72
+ // Mock integration tests that always run
73
+ describe('API Integration Tests (Mocked)', () => {
74
+ let client: SpeechallClient;
75
+
76
+ beforeEach(() => {
77
+ client = new SpeechallClient({
78
+ token: 'mock-api-token',
79
+ });
80
+ });
81
+
82
+ it('should have speechToText client available', () => {
83
+ expect(client.speechToText).toBeDefined();
84
+ expect(typeof client.speechToText.transcribe).toBe('function');
85
+ expect(typeof client.speechToText.transcribeRemote).toBe('function');
86
+ expect(typeof client.speechToText.listSpeechToTextModels).toBe('function');
87
+ });
88
+
89
+ it('should have replacementRules client available', () => {
90
+ expect(client.replacementRules).toBeDefined();
91
+ expect(typeof client.replacementRules.createReplacementRuleset).toBe('function');
92
+ });
93
+ });
@@ -0,0 +1,91 @@
1
+ import { SpeechallClient, SpeechallError } from '../../src';
2
+
3
+ describe('SpeechallClient', () => {
4
+ describe('initialization', () => {
5
+ it('should initialize with token', () => {
6
+ const client = new SpeechallClient({
7
+ token: 'test-api-token',
8
+ });
9
+ expect(client).toBeDefined();
10
+ expect(client).toBeInstanceOf(SpeechallClient);
11
+ });
12
+
13
+ it('should initialize with token as a function', () => {
14
+ const client = new SpeechallClient({
15
+ token: () => 'test-api-token',
16
+ });
17
+ expect(client).toBeDefined();
18
+ expect(client).toBeInstanceOf(SpeechallClient);
19
+ });
20
+
21
+ it('should expose speechToText client', () => {
22
+ const client = new SpeechallClient({
23
+ token: 'test-api-token',
24
+ });
25
+ expect(client.speechToText).toBeDefined();
26
+ });
27
+
28
+ it('should expose replacementRules client', () => {
29
+ const client = new SpeechallClient({
30
+ token: 'test-api-token',
31
+ });
32
+ expect(client.replacementRules).toBeDefined();
33
+ });
34
+ });
35
+
36
+ describe('configuration', () => {
37
+ it('should accept custom baseUrl', () => {
38
+ const client = new SpeechallClient({
39
+ token: 'test-api-token',
40
+ baseUrl: 'https://custom-api.example.com',
41
+ });
42
+ expect(client).toBeDefined();
43
+ });
44
+
45
+ it('should accept custom headers', () => {
46
+ const client = new SpeechallClient({
47
+ token: 'test-api-token',
48
+ headers: {
49
+ 'X-Custom-Header': 'custom-value',
50
+ },
51
+ });
52
+ expect(client).toBeDefined();
53
+ });
54
+
55
+ it('should accept timeout configuration', () => {
56
+ const client = new SpeechallClient({
57
+ token: 'test-api-token',
58
+ timeoutInSeconds: 30,
59
+ });
60
+ expect(client).toBeDefined();
61
+ });
62
+
63
+ it('should accept maxRetries configuration', () => {
64
+ const client = new SpeechallClient({
65
+ token: 'test-api-token',
66
+ maxRetries: 5,
67
+ });
68
+ expect(client).toBeDefined();
69
+ });
70
+ });
71
+
72
+ describe('lazy initialization', () => {
73
+ it('should lazily initialize speechToText client', () => {
74
+ const client = new SpeechallClient({
75
+ token: 'test-api-token',
76
+ });
77
+ const firstAccess = client.speechToText;
78
+ const secondAccess = client.speechToText;
79
+ expect(firstAccess).toBe(secondAccess);
80
+ });
81
+
82
+ it('should lazily initialize replacementRules client', () => {
83
+ const client = new SpeechallClient({
84
+ token: 'test-api-token',
85
+ });
86
+ const firstAccess = client.replacementRules;
87
+ const secondAccess = client.replacementRules;
88
+ expect(firstAccess).toBe(secondAccess);
89
+ });
90
+ });
91
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "moduleResolution": "node"
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist", "tests", "examples"]
20
+ }