tila-sdk 0.1.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/LICENSE +21 -0
- package/README.md +318 -0
- package/dist/index.cjs +2168 -0
- package/dist/index.d.cts +464 -0
- package/dist/index.d.ts +464 -0
- package/dist/index.js +2142 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { TilaProjectConfig } from './config';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { EntityResponse, EntityDetailResponse, EntityListResponse, ArchiveSuccessResponse, CreateEntityRelationshipResponse, EntityArtifactReferenceListResponse, AcquireSuccessResponse, RenewSuccessResponse, ReleaseSuccessResponse, StateListResponse, StateResponse, ArtifactPutResponse, ArtifactListResponse, ArtifactSearchResponse, ArtifactGrepResponse, ArtifactRelationshipOkResponse, ArtifactRelationshipListResponse, TokenIssueResponse, TokenRevokeResponse, TokenListResponse, JournalResponse, PresenceHeartbeatSuccessResponse, PresenceListResponse, PresenceAllListResponse, RecordCreateRequest, RecordMutateResponse, RecordSetRequest, RecordGetResponse, RecordPatchRequest, RecordArchiveRequest, RecordUnarchiveRequest, RecordHistoryResponse, RecordListResponse, RecordTypesResponse, InstantiateTemplateRequest, InstantiateTemplateResponse, SummaryResponse, UnifiedSearchResponse } from './api';
|
|
4
|
+
export { AcquireSuccessResponse, ArtifactGrepResponse, ArtifactListResponse, ArtifactPutResponse, ArtifactSearchResponse, EntityDetailResponse, EntityListResponse, EntityResponse, InstantiateTemplateRequest, InstantiateTemplateResponse, JournalResponse, PresenceAllListResponse, PresenceListResponse, RecordArchiveRequest, RecordCreateRequest, RecordGetResponse, RecordHistoryItem, RecordHistoryResponse, RecordItem, RecordListItem, RecordListResponse, RecordMutateResponse, RecordPatchRequest, RecordSetRequest, RecordTypesResponse, RecordUnarchiveRequest, ReleaseSuccessResponse, RenewSuccessResponse, SummaryResponse, TokenIssueResponse, TokenListResponse, TokenRevokeResponse, UnifiedSearchQuery, UnifiedSearchResponse, UnifiedSearchResult } from './api';
|
|
5
|
+
import { ClaimMode } from './claim';
|
|
6
|
+
import { ArtifactPointer } from './artifact';
|
|
7
|
+
import { InboxResponse, SendSignalRequest, SendSignalResponse, AckSignalResponse } from './signal';
|
|
8
|
+
export { AckSignalResponse, InboxResponse, SendSignalRequest, SendSignalResponse } from './signal';
|
|
9
|
+
import { GateListResponse, CreateGateRequest, GateResponse, ResolveGateRequest } from './gate';
|
|
10
|
+
export { CreateGateRequest, GateListResponse, GateResponse, ResolveGateRequest } from './gate';
|
|
11
|
+
|
|
12
|
+
interface ClientOptions {
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
token: string;
|
|
15
|
+
validate?: boolean;
|
|
16
|
+
/** Request timeout in milliseconds. Default: 30000 (30s). */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
/** Extra headers to include on every request. Overrides the default X-Tila-Source header if provided. */
|
|
19
|
+
extraHeaders?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
declare class TilaClient {
|
|
22
|
+
private baseUrl;
|
|
23
|
+
private token;
|
|
24
|
+
private validate;
|
|
25
|
+
private timeoutMs;
|
|
26
|
+
private extraHeaders;
|
|
27
|
+
constructor(opts: ClientOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Creates an AbortSignal that fires after this.timeoutMs.
|
|
30
|
+
* Uses AbortSignal.timeout() when available (Node 18.8+, Bun 0.5+, browsers),
|
|
31
|
+
* falls back to manual setTimeout + AbortController for older runtimes.
|
|
32
|
+
*
|
|
33
|
+
* Note: Cloudflare Workers has supported AbortSignal.timeout() since 2023;
|
|
34
|
+
* the fallback branch will never execute there.
|
|
35
|
+
*/
|
|
36
|
+
private createAbortSignal;
|
|
37
|
+
static fromConfig(config: TilaProjectConfig, token: string): TilaClient;
|
|
38
|
+
request<T>(method: string, path: string, opts?: {
|
|
39
|
+
body?: unknown;
|
|
40
|
+
query?: Record<string, string | undefined>;
|
|
41
|
+
schema?: z.ZodType<T>;
|
|
42
|
+
validate?: boolean;
|
|
43
|
+
}): Promise<T>;
|
|
44
|
+
get<T>(path: string, opts?: {
|
|
45
|
+
schema?: z.ZodType<T>;
|
|
46
|
+
query?: Record<string, string | undefined>;
|
|
47
|
+
validate?: boolean;
|
|
48
|
+
}): Promise<T>;
|
|
49
|
+
post<T>(path: string, body: unknown, opts?: {
|
|
50
|
+
schema?: z.ZodType<T>;
|
|
51
|
+
validate?: boolean;
|
|
52
|
+
}): Promise<T>;
|
|
53
|
+
put<T>(path: string, body: unknown, opts?: {
|
|
54
|
+
schema?: z.ZodType<T>;
|
|
55
|
+
validate?: boolean;
|
|
56
|
+
}): Promise<T>;
|
|
57
|
+
patch<T>(path: string, body: unknown, opts?: {
|
|
58
|
+
schema?: z.ZodType<T>;
|
|
59
|
+
validate?: boolean;
|
|
60
|
+
}): Promise<T>;
|
|
61
|
+
delete<T>(path: string, opts?: {
|
|
62
|
+
schema?: z.ZodType<T>;
|
|
63
|
+
validate?: boolean;
|
|
64
|
+
}): Promise<T>;
|
|
65
|
+
requestRaw(method: string, path: string, opts?: {
|
|
66
|
+
query?: Record<string, string | undefined>;
|
|
67
|
+
}): Promise<Response>;
|
|
68
|
+
postFormData<T>(path: string, formData: FormData, opts?: {
|
|
69
|
+
schema?: z.ZodType<T>;
|
|
70
|
+
validate?: boolean;
|
|
71
|
+
}): Promise<T>;
|
|
72
|
+
private throwApiError;
|
|
73
|
+
}
|
|
74
|
+
declare class TilaApiError extends Error {
|
|
75
|
+
status: number;
|
|
76
|
+
code: string;
|
|
77
|
+
retryable: boolean;
|
|
78
|
+
constructor(status: number, code: string, message: string, retryable: boolean);
|
|
79
|
+
}
|
|
80
|
+
declare function isTilaApiError(err: unknown): err is TilaApiError;
|
|
81
|
+
declare function exchangeGitHubToken(baseUrl: string, projectId: string, githubToken: string): Promise<{
|
|
82
|
+
sessionToken: string;
|
|
83
|
+
expiresAt: number;
|
|
84
|
+
permission: string;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
interface RetryOptions {
|
|
88
|
+
/** Maximum number of retry attempts after the first failure. Default: 3. */
|
|
89
|
+
maxRetries?: number;
|
|
90
|
+
/** Base delay in milliseconds for exponential backoff. Default: 200. */
|
|
91
|
+
baseDelayMs?: number;
|
|
92
|
+
/** Maximum delay cap in milliseconds. Default: 30000. */
|
|
93
|
+
maxDelayMs?: number;
|
|
94
|
+
/** Whether to apply full jitter to the delay. Default: true. */
|
|
95
|
+
jitter?: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Retry wrapper with exponential backoff and full jitter.
|
|
99
|
+
*
|
|
100
|
+
* Follows the AWS "Full Jitter" pattern:
|
|
101
|
+
* sleep = random(0, min(cap, base * 2^attempt))
|
|
102
|
+
*
|
|
103
|
+
* Hard stop: if the thrown error is a TilaApiError with retryable === false,
|
|
104
|
+
* it is re-thrown immediately without waiting or counting against maxRetries.
|
|
105
|
+
* This is unconditional -- callers cannot override it.
|
|
106
|
+
*
|
|
107
|
+
* Non-TilaApiError errors (network errors, timeouts, TypeErrors) are always
|
|
108
|
+
* retried up to maxRetries.
|
|
109
|
+
*/
|
|
110
|
+
declare function withRetry<T>(fn: () => Promise<T>, opts?: RetryOptions): Promise<T>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Typed error code constants for all tila API error responses.
|
|
114
|
+
*
|
|
115
|
+
* Keys are normalized identifiers. Values are the exact wire-format strings
|
|
116
|
+
* returned by the worker and DO layers.
|
|
117
|
+
*
|
|
118
|
+
* NOTE: The codebase uses two conventions for error codes:
|
|
119
|
+
* - SCREAMING_SNAKE_CASE for worker/auth-layer codes ("UNAUTHORIZED", "SESSION_EXPIRED")
|
|
120
|
+
* - kebab-case for DO-layer codes ("stale-fence", "not-found")
|
|
121
|
+
* TILA_ERRORS preserves both conventions in its values. The _UPPER suffix on
|
|
122
|
+
* VALIDATION_ERROR_UPPER disambiguates the two distinct wire values for
|
|
123
|
+
* "validation error" used in different layers.
|
|
124
|
+
*/
|
|
125
|
+
declare const TILA_ERRORS: {
|
|
126
|
+
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
127
|
+
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
128
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
129
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
130
|
+
readonly PROJECT_MISMATCH: "PROJECT_MISMATCH";
|
|
131
|
+
readonly CSRF_MISSING_ORIGIN: "CSRF_MISSING_ORIGIN";
|
|
132
|
+
readonly CSRF_ORIGIN_MISMATCH: "CSRF_ORIGIN_MISMATCH";
|
|
133
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
134
|
+
readonly DO_UNREACHABLE: "do-unreachable";
|
|
135
|
+
readonly REPO_NOT_ALLOWED: "REPO_NOT_ALLOWED";
|
|
136
|
+
readonly GITHUB_AUTH_FAILED: "GITHUB_AUTH_FAILED";
|
|
137
|
+
readonly HMAC_NOT_CONFIGURED: "HMAC_NOT_CONFIGURED";
|
|
138
|
+
readonly TOKEN_NAME_CONFLICT: "TOKEN_NAME_CONFLICT";
|
|
139
|
+
readonly TOKEN_AUTHZ_DENIED: "TOKEN_AUTHZ_DENIED";
|
|
140
|
+
readonly TOKEN_NOT_FOUND: "TOKEN_NOT_FOUND";
|
|
141
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
142
|
+
readonly STALE_FENCE: "stale-fence";
|
|
143
|
+
readonly NOT_FOUND: "not-found";
|
|
144
|
+
readonly GATE_ALREADY_SETTLED: "gate-already-settled";
|
|
145
|
+
readonly NO_FENCE: "no-fence";
|
|
146
|
+
readonly INTERNAL: "internal";
|
|
147
|
+
readonly CONSTRAINT_VIOLATION: "constraint-violation";
|
|
148
|
+
readonly IDEMPOTENCY_KEY_CONFLICT: "idempotency-key-conflict";
|
|
149
|
+
readonly VALIDATION_ERROR_DO: "validation-error";
|
|
150
|
+
readonly ALREADY_HELD: "already-held";
|
|
151
|
+
readonly RENEW_FAILED: "renew-failed";
|
|
152
|
+
readonly BAD_REQUEST: "bad-request";
|
|
153
|
+
readonly MISSING_QUERY: "missing-query";
|
|
154
|
+
readonly INVALID_QUERY: "invalid-query";
|
|
155
|
+
readonly INVALID_SLOT: "invalid-slot";
|
|
156
|
+
readonly INVALID_RELATIONSHIP_TYPE: "invalid-relationship-type";
|
|
157
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
158
|
+
};
|
|
159
|
+
type TilaErrorCode = (typeof TILA_ERRORS)[keyof typeof TILA_ERRORS];
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Creates task API methods using the canonical /tasks public path.
|
|
163
|
+
*/
|
|
164
|
+
declare function createTaskMethods(client: TilaClient, projectId: string): {
|
|
165
|
+
create(id: string, type: string, data?: Record<string, unknown>): Promise<EntityResponse>;
|
|
166
|
+
get(id: string): Promise<EntityDetailResponse>;
|
|
167
|
+
list(query?: {
|
|
168
|
+
type?: string;
|
|
169
|
+
status?: string;
|
|
170
|
+
limit?: string;
|
|
171
|
+
cursor?: string;
|
|
172
|
+
}): Promise<EntityListResponse>;
|
|
173
|
+
update(id: string, data: Record<string, unknown>, fence: number): Promise<EntityResponse>;
|
|
174
|
+
archive(id: string, fence: number): Promise<ArchiveSuccessResponse>;
|
|
175
|
+
addRelationship(fromId: string, toId: string, type: string): Promise<CreateEntityRelationshipResponse>;
|
|
176
|
+
addArtifactRef(entityId: string, artifactKey: string, slot: string, metadata?: Record<string, unknown>): Promise<{
|
|
177
|
+
ok: true;
|
|
178
|
+
}>;
|
|
179
|
+
listArtifactRefs(entityId: string): Promise<EntityArtifactReferenceListResponse>;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated Use createTaskMethods instead.
|
|
183
|
+
*/
|
|
184
|
+
declare function createEntityMethods(client: TilaClient, projectId: string): {
|
|
185
|
+
create(id: string, type: string, data?: Record<string, unknown>): Promise<EntityResponse>;
|
|
186
|
+
get(id: string): Promise<EntityDetailResponse>;
|
|
187
|
+
list(query?: {
|
|
188
|
+
type?: string;
|
|
189
|
+
status?: string;
|
|
190
|
+
limit?: string;
|
|
191
|
+
cursor?: string;
|
|
192
|
+
}): Promise<EntityListResponse>;
|
|
193
|
+
update(id: string, data: Record<string, unknown>, fence: number): Promise<EntityResponse>;
|
|
194
|
+
archive(id: string, fence: number): Promise<ArchiveSuccessResponse>;
|
|
195
|
+
addRelationship(fromId: string, toId: string, type: string): Promise<CreateEntityRelationshipResponse>;
|
|
196
|
+
addArtifactRef(entityId: string, artifactKey: string, slot: string, metadata?: Record<string, unknown>): Promise<{
|
|
197
|
+
ok: true;
|
|
198
|
+
}>;
|
|
199
|
+
listArtifactRefs(entityId: string): Promise<EntityArtifactReferenceListResponse>;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated Use createTaskMethods instead.
|
|
203
|
+
*/
|
|
204
|
+
declare function createWorkUnitMethods(client: TilaClient, projectId: string): {
|
|
205
|
+
create(id: string, type: string, data?: Record<string, unknown>): Promise<EntityResponse>;
|
|
206
|
+
get(id: string): Promise<EntityDetailResponse>;
|
|
207
|
+
list(query?: {
|
|
208
|
+
type?: string;
|
|
209
|
+
status?: string;
|
|
210
|
+
limit?: string;
|
|
211
|
+
cursor?: string;
|
|
212
|
+
}): Promise<EntityListResponse>;
|
|
213
|
+
update(id: string, data: Record<string, unknown>, fence: number): Promise<EntityResponse>;
|
|
214
|
+
archive(id: string, fence: number): Promise<ArchiveSuccessResponse>;
|
|
215
|
+
addRelationship(fromId: string, toId: string, type: string): Promise<CreateEntityRelationshipResponse>;
|
|
216
|
+
addArtifactRef(entityId: string, artifactKey: string, slot: string, metadata?: Record<string, unknown>): Promise<{
|
|
217
|
+
ok: true;
|
|
218
|
+
}>;
|
|
219
|
+
listArtifactRefs(entityId: string): Promise<EntityArtifactReferenceListResponse>;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
declare function createClaimMethods(client: TilaClient, projectId: string): {
|
|
223
|
+
acquire(resource: string, mode: ClaimMode, ttlMs: number, opts?: {
|
|
224
|
+
metadata?: Record<string, unknown>;
|
|
225
|
+
idempotency_key?: string;
|
|
226
|
+
}): Promise<AcquireSuccessResponse>;
|
|
227
|
+
renew(resource: string, fence: number, ttlMs: number): Promise<RenewSuccessResponse>;
|
|
228
|
+
release(resource: string, fence: number): Promise<ReleaseSuccessResponse>;
|
|
229
|
+
list(): Promise<StateListResponse>;
|
|
230
|
+
get(resource: string): Promise<StateResponse>;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
interface ArtifactUploadOpts {
|
|
234
|
+
kind: string;
|
|
235
|
+
resource?: string;
|
|
236
|
+
fence?: number;
|
|
237
|
+
mimeType?: string;
|
|
238
|
+
flavor?: string;
|
|
239
|
+
}
|
|
240
|
+
declare function createArtifactMethods(client: TilaClient, projectId: string): {
|
|
241
|
+
upload: {
|
|
242
|
+
(file: File | Blob, opts: ArtifactUploadOpts): Promise<ArtifactPutResponse>;
|
|
243
|
+
(stream: ReadableStream, opts: ArtifactUploadOpts & {
|
|
244
|
+
mimeType: string;
|
|
245
|
+
}): Promise<ArtifactPutResponse>;
|
|
246
|
+
};
|
|
247
|
+
download(key: string): Promise<{
|
|
248
|
+
body: ReadableStream;
|
|
249
|
+
contentType: string;
|
|
250
|
+
contentLength: number | null;
|
|
251
|
+
}>;
|
|
252
|
+
list(query?: {
|
|
253
|
+
resource?: string;
|
|
254
|
+
kind?: string;
|
|
255
|
+
limit?: string;
|
|
256
|
+
}): Promise<ArtifactListResponse>;
|
|
257
|
+
search(q: string, opts?: {
|
|
258
|
+
kind?: string;
|
|
259
|
+
resource?: string;
|
|
260
|
+
limit?: string;
|
|
261
|
+
}): Promise<ArtifactSearchResponse>;
|
|
262
|
+
grep(pattern: string, opts?: {
|
|
263
|
+
kind?: string;
|
|
264
|
+
resource?: string;
|
|
265
|
+
regex?: boolean;
|
|
266
|
+
limit?: number;
|
|
267
|
+
}): Promise<ArtifactGrepResponse>;
|
|
268
|
+
addRelationship(fromKey: string, toKeyOrUri: string, type: string, metadata?: Record<string, unknown>): Promise<ArtifactRelationshipOkResponse>;
|
|
269
|
+
listRelationships(key: string): Promise<ArtifactRelationshipListResponse>;
|
|
270
|
+
getLatest(kind: string, resource: string): Promise<ArtifactPointer | null>;
|
|
271
|
+
writeText(content: string, opts: {
|
|
272
|
+
kind: string;
|
|
273
|
+
mimeType?: string;
|
|
274
|
+
resource?: string;
|
|
275
|
+
fence?: number;
|
|
276
|
+
}): Promise<ArtifactPutResponse>;
|
|
277
|
+
readText(key: string): Promise<{
|
|
278
|
+
content: string;
|
|
279
|
+
mimeType: string;
|
|
280
|
+
}>;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare function createTokenMethods(client: TilaClient): {
|
|
284
|
+
issue(name: string, note?: string): Promise<TokenIssueResponse>;
|
|
285
|
+
revoke(name: string): Promise<TokenRevokeResponse>;
|
|
286
|
+
list(): Promise<TokenListResponse>;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
declare function createJournalMethods(client: TilaClient, projectId: string): {
|
|
290
|
+
query(opts?: {
|
|
291
|
+
entity_id?: string;
|
|
292
|
+
event_kind?: string;
|
|
293
|
+
limit?: string;
|
|
294
|
+
cursor?: string;
|
|
295
|
+
}): Promise<JournalResponse>;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
declare function createPresenceMethods(client: TilaClient, projectId: string): {
|
|
299
|
+
heartbeat(machine: string, ttlMs?: number): Promise<PresenceHeartbeatSuccessResponse>;
|
|
300
|
+
list(): Promise<PresenceListResponse>;
|
|
301
|
+
/**
|
|
302
|
+
* List all presence records across all machines, including whether each is active.
|
|
303
|
+
* Hits GET /projects/:projectId/presence/all
|
|
304
|
+
*/
|
|
305
|
+
listAll(): Promise<PresenceAllListResponse>;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
declare function createRecordMethods(client: TilaClient, projectId: string): {
|
|
309
|
+
create(type: string, req: RecordCreateRequest): Promise<RecordMutateResponse>;
|
|
310
|
+
set(type: string, key: string, req: RecordSetRequest): Promise<RecordMutateResponse>;
|
|
311
|
+
get(type: string, key: string): Promise<RecordGetResponse>;
|
|
312
|
+
patch(type: string, key: string, req: RecordPatchRequest): Promise<RecordMutateResponse>;
|
|
313
|
+
archive(type: string, key: string, req: RecordArchiveRequest): Promise<RecordMutateResponse>;
|
|
314
|
+
unarchive(type: string, key: string, req: RecordUnarchiveRequest): Promise<RecordMutateResponse>;
|
|
315
|
+
history(type: string, key: string, opts?: {
|
|
316
|
+
limit?: number;
|
|
317
|
+
values?: boolean;
|
|
318
|
+
}): Promise<RecordHistoryResponse>;
|
|
319
|
+
list(type: string, query?: {
|
|
320
|
+
tag?: string;
|
|
321
|
+
filter?: string;
|
|
322
|
+
"include-archived"?: string;
|
|
323
|
+
limit?: string;
|
|
324
|
+
}): Promise<RecordListResponse>;
|
|
325
|
+
types(): Promise<RecordTypesResponse>;
|
|
326
|
+
typesInUse(): Promise<RecordTypesResponse>;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
declare function createSchemaMethods(client: TilaClient, projectId: string): {
|
|
330
|
+
get(): Promise<{
|
|
331
|
+
ok: true;
|
|
332
|
+
schema: unknown;
|
|
333
|
+
version: number;
|
|
334
|
+
}>;
|
|
335
|
+
apply(schema: unknown, strategy?: string): Promise<{
|
|
336
|
+
ok: true;
|
|
337
|
+
version: number;
|
|
338
|
+
diff: unknown;
|
|
339
|
+
}>;
|
|
340
|
+
history(opts?: {
|
|
341
|
+
limit?: string;
|
|
342
|
+
}): Promise<{
|
|
343
|
+
ok: true;
|
|
344
|
+
entries: unknown[];
|
|
345
|
+
}>;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
declare function createSignalMethods(client: TilaClient, projectId: string): {
|
|
349
|
+
/** Fetch the signal inbox for the current token. GET /projects/:id/signals */
|
|
350
|
+
inbox(): Promise<InboxResponse>;
|
|
351
|
+
/** Send a signal to a target. POST /projects/:id/signals/send */
|
|
352
|
+
send(req: SendSignalRequest): Promise<SendSignalResponse>;
|
|
353
|
+
/** Acknowledge a signal. POST /projects/:id/signals/:signalId/ack */
|
|
354
|
+
ack(signalId: string): Promise<AckSignalResponse>;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
declare function createGateMethods(client: TilaClient, projectId: string): {
|
|
358
|
+
/** List gates with optional filters. GET /projects/:id/gates */
|
|
359
|
+
list(query?: {
|
|
360
|
+
resource?: string;
|
|
361
|
+
status?: string;
|
|
362
|
+
limit?: string;
|
|
363
|
+
}): Promise<GateListResponse>;
|
|
364
|
+
/** Create a new gate. POST /projects/:id/gates */
|
|
365
|
+
create(req: CreateGateRequest): Promise<GateResponse>;
|
|
366
|
+
/** Resolve a gate. POST /projects/:id/gates/:gateId/resolve */
|
|
367
|
+
resolve(gateId: string, req?: ResolveGateRequest): Promise<GateResponse>;
|
|
368
|
+
/** Delete a gate. DELETE /projects/:id/gates/:gateId */
|
|
369
|
+
remove(gateId: string): Promise<{
|
|
370
|
+
ok: true;
|
|
371
|
+
}>;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
declare function createTemplateMethods(client: TilaClient, projectId: string): {
|
|
375
|
+
/** Instantiate an entity template. POST /projects/:id/templates/instantiate */
|
|
376
|
+
instantiate(req: InstantiateTemplateRequest): Promise<InstantiateTemplateResponse>;
|
|
377
|
+
/** List available templates from the project schema. GET /projects/:id/templates */
|
|
378
|
+
list(): Promise<{
|
|
379
|
+
ok: true;
|
|
380
|
+
templates: Array<{
|
|
381
|
+
name: string;
|
|
382
|
+
type: string;
|
|
383
|
+
description: string | null;
|
|
384
|
+
variables: string[];
|
|
385
|
+
}>;
|
|
386
|
+
}>;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
interface IndexCreateOpts {
|
|
390
|
+
kind?: string;
|
|
391
|
+
resource?: string;
|
|
392
|
+
mimeType?: string;
|
|
393
|
+
flavor?: string;
|
|
394
|
+
}
|
|
395
|
+
declare function createIndexMethods(client: TilaClient, projectId: string): {
|
|
396
|
+
/**
|
|
397
|
+
* Create an index artifact. Uploads file content with flavor=index.
|
|
398
|
+
* Returns the artifact key and byte count.
|
|
399
|
+
*/
|
|
400
|
+
create(input: File | Blob, opts?: IndexCreateOpts): Promise<ArtifactPutResponse>;
|
|
401
|
+
/**
|
|
402
|
+
* Add an entry artifact to an index. Records the relationship
|
|
403
|
+
* entry_key -> index_key with type "entry-of".
|
|
404
|
+
*/
|
|
405
|
+
addEntry(entryKey: string, indexKey: string): Promise<ArtifactRelationshipOkResponse>;
|
|
406
|
+
/**
|
|
407
|
+
* List relationships FROM the given index key. Note: this returns
|
|
408
|
+
* forward relationships (what the index points to), not a reverse
|
|
409
|
+
* lookup of entries pointing to this index. The HTTP API does not
|
|
410
|
+
* expose a reverse-lookup endpoint; for that, use the CLI's
|
|
411
|
+
* `tila index list-entries` which queries ops-sqlite directly.
|
|
412
|
+
*/
|
|
413
|
+
listEntries(indexKey: string): Promise<ArtifactRelationshipListResponse>;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
declare function createSummaryMethods(client: TilaClient, projectId: string): {
|
|
417
|
+
/** Get project summary. GET /projects/:id/summary */
|
|
418
|
+
get(): Promise<SummaryResponse>;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
declare function createSearchMethods(client: TilaClient, projectId: string): {
|
|
422
|
+
search(q: string, opts?: {
|
|
423
|
+
limit?: number;
|
|
424
|
+
}): Promise<UnifiedSearchResponse>;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
type ErrorListener = (err: TilaApiError | Error) => void;
|
|
428
|
+
interface ClaimHandleOptions {
|
|
429
|
+
client: TilaClient;
|
|
430
|
+
projectId: string;
|
|
431
|
+
resource: string;
|
|
432
|
+
fence: number;
|
|
433
|
+
expiresAt: number;
|
|
434
|
+
}
|
|
435
|
+
declare class ClaimHandle {
|
|
436
|
+
readonly resource: string;
|
|
437
|
+
readonly fence: number;
|
|
438
|
+
readonly expiresAt: number;
|
|
439
|
+
private client;
|
|
440
|
+
private projectId;
|
|
441
|
+
private errorListeners;
|
|
442
|
+
constructor(opts: ClaimHandleOptions);
|
|
443
|
+
on(event: "error", listener: ErrorListener): void;
|
|
444
|
+
private emitError;
|
|
445
|
+
updateEntity(id: string, data: Record<string, unknown>): Promise<EntityResponse>;
|
|
446
|
+
uploadArtifact(file: File | Blob, opts: Omit<ArtifactUploadOpts, "fence">): Promise<ArtifactPutResponse>;
|
|
447
|
+
uploadArtifact(stream: ReadableStream, opts: Omit<ArtifactUploadOpts, "fence"> & {
|
|
448
|
+
mimeType: string;
|
|
449
|
+
}): Promise<ArtifactPutResponse>;
|
|
450
|
+
addArtifactRef(entityId: string, artifactKey: string, slot: string): Promise<void>;
|
|
451
|
+
startHeartbeat(ttlMs: number, opts?: {
|
|
452
|
+
intervalMs?: number;
|
|
453
|
+
}): {
|
|
454
|
+
stop(): void;
|
|
455
|
+
};
|
|
456
|
+
onClaimExpiring(leadMs: number, callback: () => void): {
|
|
457
|
+
stop(): void;
|
|
458
|
+
};
|
|
459
|
+
/** @internal Release the claim. Errors are swallowed by withClaim's finally. */
|
|
460
|
+
_release(): Promise<void>;
|
|
461
|
+
}
|
|
462
|
+
declare function withClaim<T>(client: TilaClient, projectId: string, resource: string, mode: ClaimMode, ttlMs: number, callback: (handle: ClaimHandle) => Promise<T>): Promise<T>;
|
|
463
|
+
|
|
464
|
+
export { type ArtifactUploadOpts, ClaimHandle, type ClaimHandleOptions, type ClientOptions, type IndexCreateOpts, type RetryOptions, TILA_ERRORS, TilaApiError, TilaClient, type TilaErrorCode, createArtifactMethods, createClaimMethods, createEntityMethods, createGateMethods, createIndexMethods, createJournalMethods, createPresenceMethods, createRecordMethods, createSchemaMethods, createSearchMethods, createSignalMethods, createSummaryMethods, createTaskMethods, createTemplateMethods, createTokenMethods, createWorkUnitMethods, exchangeGitHubToken, isTilaApiError, withClaim, withRetry };
|