@runtypelabs/sdk 0.1.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/README.md +398 -0
- package/dist/batch-builder.d.ts +106 -0
- package/dist/batch-builder.d.ts.map +1 -0
- package/dist/batch-builder.js +124 -0
- package/dist/batch-builder.js.map +1 -0
- package/dist/batches-namespace.d.ts +132 -0
- package/dist/batches-namespace.d.ts.map +1 -0
- package/dist/batches-namespace.js +128 -0
- package/dist/batches-namespace.js.map +1 -0
- package/dist/client.d.ts +121 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +485 -0
- package/dist/client.js.map +1 -0
- package/dist/endpoints.d.ts +560 -0
- package/dist/endpoints.d.ts.map +1 -0
- package/dist/endpoints.js +725 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/eval-builder.d.ts +216 -0
- package/dist/eval-builder.d.ts.map +1 -0
- package/dist/eval-builder.js +225 -0
- package/dist/eval-builder.js.map +1 -0
- package/dist/evals-namespace.d.ts +205 -0
- package/dist/evals-namespace.d.ts.map +1 -0
- package/dist/evals-namespace.js +208 -0
- package/dist/evals-namespace.js.map +1 -0
- package/dist/flow-builder.d.ts +620 -0
- package/dist/flow-builder.d.ts.map +1 -0
- package/dist/flow-builder.js +565 -0
- package/dist/flow-builder.js.map +1 -0
- package/dist/flow-result.d.ts +117 -0
- package/dist/flow-result.d.ts.map +1 -0
- package/dist/flow-result.js +175 -0
- package/dist/flow-result.js.map +1 -0
- package/dist/flows-namespace.d.ts +430 -0
- package/dist/flows-namespace.d.ts.map +1 -0
- package/dist/flows-namespace.js +679 -0
- package/dist/flows-namespace.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts-namespace.d.ts +236 -0
- package/dist/prompts-namespace.d.ts.map +1 -0
- package/dist/prompts-namespace.js +222 -0
- package/dist/prompts-namespace.js.map +1 -0
- package/dist/runtype.d.ts +232 -0
- package/dist/runtype.d.ts.map +1 -0
- package/dist/runtype.js +367 -0
- package/dist/runtype.js.map +1 -0
- package/dist/stream-utils.d.ts +58 -0
- package/dist/stream-utils.d.ts.map +1 -0
- package/dist/stream-utils.js +348 -0
- package/dist/stream-utils.js.map +1 -0
- package/dist/transform.d.ts +21 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +170 -0
- package/dist/transform.js.map +1 -0
- package/dist/types.d.ts +626 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BatchesNamespace - Static namespace for batch operations
|
|
3
|
+
*
|
|
4
|
+
* Provides direct methods for scheduling and managing batch operations.
|
|
5
|
+
* Batches are always asynchronous - they don't return results immediately.
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntypeClient } from './runtype';
|
|
8
|
+
export interface BatchScheduleConfig {
|
|
9
|
+
/** Flow ID to execute for each record */
|
|
10
|
+
flowId: string;
|
|
11
|
+
/** Record type to batch process */
|
|
12
|
+
recordType: string;
|
|
13
|
+
/** When to execute (defaults to immediately) */
|
|
14
|
+
at?: Date;
|
|
15
|
+
/** Run batch asynchronously (default: true) */
|
|
16
|
+
async?: boolean;
|
|
17
|
+
/** Maximum concurrent executions */
|
|
18
|
+
concurrency?: number;
|
|
19
|
+
/** Continue on individual record failures */
|
|
20
|
+
continueOnError?: boolean;
|
|
21
|
+
/** Store results for each record */
|
|
22
|
+
storeResults?: boolean;
|
|
23
|
+
/** Model override for batch execution */
|
|
24
|
+
modelOverride?: string;
|
|
25
|
+
/** Optional filter for records */
|
|
26
|
+
filter?: Record<string, any>;
|
|
27
|
+
/** Optional limit on number of records */
|
|
28
|
+
limit?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface BatchStatus {
|
|
31
|
+
batchId: string;
|
|
32
|
+
status: 'queued' | 'scheduled' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
33
|
+
totalRecords: number;
|
|
34
|
+
processedRecords: number;
|
|
35
|
+
failedRecords: number;
|
|
36
|
+
scheduledAt?: string;
|
|
37
|
+
startedAt?: string;
|
|
38
|
+
completedAt?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BatchListParams {
|
|
41
|
+
/** Filter by status */
|
|
42
|
+
status?: 'queued' | 'scheduled' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
43
|
+
/** Filter by flow ID */
|
|
44
|
+
flowId?: string;
|
|
45
|
+
/** Filter by record type */
|
|
46
|
+
recordType?: string;
|
|
47
|
+
/** Pagination limit */
|
|
48
|
+
limit?: number;
|
|
49
|
+
/** Pagination offset */
|
|
50
|
+
offset?: number;
|
|
51
|
+
}
|
|
52
|
+
export declare class BatchesNamespace {
|
|
53
|
+
private getClient;
|
|
54
|
+
constructor(getClient: () => RuntypeClient);
|
|
55
|
+
/**
|
|
56
|
+
* Schedule a batch operation
|
|
57
|
+
*
|
|
58
|
+
* Creates and schedules a batch to run a flow on all records of a type.
|
|
59
|
+
* By default, runs immediately. Use `at` to schedule for a specific time.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Run immediately
|
|
64
|
+
* const batch = await Runtype.batches.schedule({
|
|
65
|
+
* flowId: 'flow_123',
|
|
66
|
+
* recordType: 'customers',
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* // Schedule for later
|
|
70
|
+
* const batch = await Runtype.batches.schedule({
|
|
71
|
+
* flowId: 'flow_123',
|
|
72
|
+
* recordType: 'customers',
|
|
73
|
+
* at: new Date('2024-01-15T09:00:00Z'),
|
|
74
|
+
* })
|
|
75
|
+
*
|
|
76
|
+
* // With options
|
|
77
|
+
* const batch = await Runtype.batches.schedule({
|
|
78
|
+
* flowId: 'flow_123',
|
|
79
|
+
* recordType: 'customers',
|
|
80
|
+
* concurrency: 5,
|
|
81
|
+
* continueOnError: true,
|
|
82
|
+
* filter: { status: 'active' },
|
|
83
|
+
* limit: 100,
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
schedule(config: BatchScheduleConfig): Promise<BatchStatus>;
|
|
88
|
+
/**
|
|
89
|
+
* Get batch status by ID
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const status = await Runtype.batches.get('batch_456')
|
|
94
|
+
* console.log(status.status, status.processedRecords, '/', status.totalRecords)
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
get(batchId: string): Promise<BatchStatus>;
|
|
98
|
+
/**
|
|
99
|
+
* Cancel a batch operation
|
|
100
|
+
*
|
|
101
|
+
* Cancels a queued or running batch. Records already processed are not rolled back.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* await Runtype.batches.cancel('batch_456')
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
cancel(batchId: string): Promise<{
|
|
109
|
+
success: boolean;
|
|
110
|
+
message: string;
|
|
111
|
+
}>;
|
|
112
|
+
/**
|
|
113
|
+
* List batch operations
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // List all batches
|
|
118
|
+
* const batches = await Runtype.batches.list()
|
|
119
|
+
*
|
|
120
|
+
* // Filter by status
|
|
121
|
+
* const running = await Runtype.batches.list({ status: 'running' })
|
|
122
|
+
*
|
|
123
|
+
* // Filter by flow
|
|
124
|
+
* const flowBatches = await Runtype.batches.list({ flowId: 'flow_123' })
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
list(params?: BatchListParams): Promise<{
|
|
128
|
+
data: BatchStatus[];
|
|
129
|
+
total: number;
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=batches-namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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,MAAM,CAAA;IACf,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAMD,qBAAa,gBAAgB;IACf,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM,aAAa;IAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAkCjE;;;;;;;;OAQG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhD;;;;;;;;;OASG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAK7E;;;;;;;;;;;;;;OAcG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAItF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* BatchesNamespace - Static namespace for batch operations
|
|
4
|
+
*
|
|
5
|
+
* Provides direct methods for scheduling and managing batch operations.
|
|
6
|
+
* Batches are always asynchronous - they don't return results immediately.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BatchesNamespace = void 0;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// BatchesNamespace
|
|
12
|
+
// ============================================================================
|
|
13
|
+
class BatchesNamespace {
|
|
14
|
+
constructor(getClient) {
|
|
15
|
+
this.getClient = getClient;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Schedule a batch operation
|
|
19
|
+
*
|
|
20
|
+
* Creates and schedules a batch to run a flow on all records of a type.
|
|
21
|
+
* By default, runs immediately. Use `at` to schedule for a specific time.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Run immediately
|
|
26
|
+
* const batch = await Runtype.batches.schedule({
|
|
27
|
+
* flowId: 'flow_123',
|
|
28
|
+
* recordType: 'customers',
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* // Schedule for later
|
|
32
|
+
* const batch = await Runtype.batches.schedule({
|
|
33
|
+
* flowId: 'flow_123',
|
|
34
|
+
* recordType: 'customers',
|
|
35
|
+
* at: new Date('2024-01-15T09:00:00Z'),
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* // With options
|
|
39
|
+
* const batch = await Runtype.batches.schedule({
|
|
40
|
+
* flowId: 'flow_123',
|
|
41
|
+
* recordType: 'customers',
|
|
42
|
+
* concurrency: 5,
|
|
43
|
+
* continueOnError: true,
|
|
44
|
+
* filter: { status: 'active' },
|
|
45
|
+
* limit: 100,
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async schedule(config) {
|
|
50
|
+
const client = this.getClient();
|
|
51
|
+
const payload = {
|
|
52
|
+
flowId: config.flowId,
|
|
53
|
+
recordType: config.recordType,
|
|
54
|
+
};
|
|
55
|
+
if (config.at) {
|
|
56
|
+
payload.scheduledAt = config.at.toISOString();
|
|
57
|
+
}
|
|
58
|
+
const options = {};
|
|
59
|
+
if (config.async !== undefined)
|
|
60
|
+
options.async = config.async;
|
|
61
|
+
if (config.concurrency !== undefined)
|
|
62
|
+
options.concurrency = config.concurrency;
|
|
63
|
+
if (config.continueOnError !== undefined)
|
|
64
|
+
options.continueOnError = config.continueOnError;
|
|
65
|
+
if (config.storeResults !== undefined)
|
|
66
|
+
options.storeResults = config.storeResults;
|
|
67
|
+
if (config.modelOverride !== undefined)
|
|
68
|
+
options.modelOverride = config.modelOverride;
|
|
69
|
+
if (Object.keys(options).length > 0) {
|
|
70
|
+
payload.options = options;
|
|
71
|
+
}
|
|
72
|
+
if (config.filter) {
|
|
73
|
+
payload.filter = config.filter;
|
|
74
|
+
}
|
|
75
|
+
if (config.limit !== undefined) {
|
|
76
|
+
payload.limit = config.limit;
|
|
77
|
+
}
|
|
78
|
+
return client.post('/batches', payload);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get batch status by ID
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const status = await Runtype.batches.get('batch_456')
|
|
86
|
+
* console.log(status.status, status.processedRecords, '/', status.totalRecords)
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
async get(batchId) {
|
|
90
|
+
const client = this.getClient();
|
|
91
|
+
return client.get(`/batches/${batchId}`);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Cancel a batch operation
|
|
95
|
+
*
|
|
96
|
+
* Cancels a queued or running batch. Records already processed are not rolled back.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* await Runtype.batches.cancel('batch_456')
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
async cancel(batchId) {
|
|
104
|
+
const client = this.getClient();
|
|
105
|
+
return client.post(`/batches/${batchId}/cancel`);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* List batch operations
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // List all batches
|
|
113
|
+
* const batches = await Runtype.batches.list()
|
|
114
|
+
*
|
|
115
|
+
* // Filter by status
|
|
116
|
+
* const running = await Runtype.batches.list({ status: 'running' })
|
|
117
|
+
*
|
|
118
|
+
* // Filter by flow
|
|
119
|
+
* const flowBatches = await Runtype.batches.list({ flowId: 'flow_123' })
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
async list(params) {
|
|
123
|
+
const client = this.getClient();
|
|
124
|
+
return client.get('/batches', params);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.BatchesNamespace = BatchesNamespace;
|
|
128
|
+
//# sourceMappingURL=batches-namespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batches-namespace.js","sourceRoot":"","sources":["../src/batches-namespace.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAuDH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAa,gBAAgB;IAC3B,YAAoB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,KAAK,CAAC,QAAQ,CAAC,MAA2B;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAE/B,MAAM,OAAO,GAAQ;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAA;QAED,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YACd,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,CAAA;QAC/C,CAAC;QAED,MAAM,OAAO,GAAQ,EAAE,CAAA;QACvB,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QAC5D,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;YAAE,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;QAC9E,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS;YAAE,OAAO,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAA;QAC1F,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS;YAAE,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC,YA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ype API Client with automatic camelCase/snake_case transformation
|
|
3
|
+
*/
|
|
4
|
+
import type { ClientConfig } from './types';
|
|
5
|
+
import { FlowsEndpoint, PromptsEndpoint, RecordsEndpoint, ApiKeysEndpoint, ModelConfigsEndpoint, DispatchEndpoint, ChatEndpoint, UsersEndpoint, AnalyticsEndpoint, FlowStepsEndpoint, ContextTemplatesEndpoint, ToolsEndpoint, EvalEndpoint, type ApiClient } from './endpoints';
|
|
6
|
+
import { ClientFlowBuilder, StreamCallbacks, FlowSummary } from './flow-builder';
|
|
7
|
+
import { FlowResult } from './flow-result';
|
|
8
|
+
/**
|
|
9
|
+
* RuntypeClient - The main entry point for interacting with the Runtype API
|
|
10
|
+
*
|
|
11
|
+
* Automatically transforms field names between camelCase (client) and snake_case (API)
|
|
12
|
+
* to provide an idiomatic JavaScript/TypeScript experience while maintaining API consistency.
|
|
13
|
+
*/
|
|
14
|
+
export declare class RuntypeClient implements ApiClient {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private apiVersion;
|
|
17
|
+
private timeout;
|
|
18
|
+
private headers;
|
|
19
|
+
flows: FlowsEndpoint;
|
|
20
|
+
prompts: PromptsEndpoint;
|
|
21
|
+
records: RecordsEndpoint;
|
|
22
|
+
apiKeys: ApiKeysEndpoint;
|
|
23
|
+
modelConfigs: ModelConfigsEndpoint;
|
|
24
|
+
dispatch: DispatchEndpoint;
|
|
25
|
+
chat: ChatEndpoint;
|
|
26
|
+
users: UsersEndpoint;
|
|
27
|
+
analytics: AnalyticsEndpoint;
|
|
28
|
+
flowSteps: FlowStepsEndpoint;
|
|
29
|
+
contextTemplates: ContextTemplatesEndpoint;
|
|
30
|
+
tools: ToolsEndpoint;
|
|
31
|
+
eval: EvalEndpoint;
|
|
32
|
+
constructor(config?: ClientConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Set the API key for authentication
|
|
35
|
+
*/
|
|
36
|
+
setApiKey(apiKey: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Start building a flow with fluent API
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const response = await runtype
|
|
43
|
+
* .flow('My Flow')
|
|
44
|
+
* .withRecord({ name: 'Test', type: 'data' })
|
|
45
|
+
* .fetchUrl({ name: 'Fetch', url: '...', outputVariable: 'data' })
|
|
46
|
+
* .prompt({ name: 'Process', model: 'gpt-4', userPrompt: '...' })
|
|
47
|
+
* .run()
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
flow(name: string): ClientFlowBuilder;
|
|
51
|
+
/**
|
|
52
|
+
* Remove the API key
|
|
53
|
+
*/
|
|
54
|
+
clearApiKey(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Run a flow with client-side tools (automatic pause/resume loop)
|
|
57
|
+
*
|
|
58
|
+
* @param request - The dispatch request configuration
|
|
59
|
+
* @param clientTools - Map of tool names to async functions that execute the tool logic
|
|
60
|
+
* @param callbacks - Optional callbacks for streaming events
|
|
61
|
+
* @returns The final result of the flow execution or summary if streaming
|
|
62
|
+
*/
|
|
63
|
+
runWithLocalTools(request: any, localTools: Record<string, (args: any) => Promise<any>>, callbacks?: StreamCallbacks): Promise<FlowResult | FlowSummary>;
|
|
64
|
+
/**
|
|
65
|
+
* Generic GET request
|
|
66
|
+
*/
|
|
67
|
+
get<T>(path: string, params?: Record<string, any>): Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Generic POST request
|
|
70
|
+
*/
|
|
71
|
+
post<T>(path: string, data?: any): Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* POST request with FormData support for file uploads
|
|
74
|
+
*/
|
|
75
|
+
postFormData<T>(path: string, formData: FormData): Promise<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Generic request that returns raw Response for streaming
|
|
78
|
+
*/
|
|
79
|
+
requestStream(path: string, options?: RequestInit): Promise<Response>;
|
|
80
|
+
/**
|
|
81
|
+
* Generic PUT request
|
|
82
|
+
*/
|
|
83
|
+
put<T>(path: string, data?: any): Promise<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Generic PATCH request
|
|
86
|
+
*/
|
|
87
|
+
patch<T>(path: string, data?: any): Promise<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Generic DELETE request
|
|
90
|
+
*/
|
|
91
|
+
delete<T>(path: string, data?: any): Promise<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Build full URL with query parameters
|
|
94
|
+
*/
|
|
95
|
+
private buildUrl;
|
|
96
|
+
/**
|
|
97
|
+
* Make HTTP request with timeout and error handling
|
|
98
|
+
*/
|
|
99
|
+
private makeRequest;
|
|
100
|
+
/**
|
|
101
|
+
* Make HTTP request that returns raw Response (for streaming)
|
|
102
|
+
*/
|
|
103
|
+
private makeRawRequest;
|
|
104
|
+
/**
|
|
105
|
+
* Handle error responses
|
|
106
|
+
*/
|
|
107
|
+
private handleErrorResponse;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Custom error class for Runtype API errors
|
|
111
|
+
*/
|
|
112
|
+
export declare class RuntypeApiError extends Error {
|
|
113
|
+
statusCode: number;
|
|
114
|
+
data?: any | undefined;
|
|
115
|
+
constructor(message: string, statusCode: number, data?: any | undefined);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Convenience function to create a new RuntypeClient instance
|
|
119
|
+
*/
|
|
120
|
+
export declare function createClient(config?: ClientConfig): RuntypeClient;
|
|
121
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,YAA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