@to11ai/sdk 3.0.0-rc.8 → 3.0.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/README.md +31 -4
- package/dist/client.cjs +29 -21
- package/dist/client.d.ts +6 -0
- package/dist/client.js +27 -19
- package/dist/errors.cjs +15 -16
- package/dist/errors.js +15 -15
- package/dist/gateway.cjs +11 -11
- package/dist/gateway.js +11 -11
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +9495 -4795
- package/dist/generated/zod.gen.d.ts +8260 -4911
- package/dist/pagination.d.ts +32 -0
- package/dist/projectEnvironments/resource.cjs +20 -2
- package/dist/projectEnvironments/resource.d.ts +21 -5
- package/dist/projectEnvironments/resource.js +20 -2
- package/dist/projectEnvironments/types.d.ts +14 -1
- package/dist/prompts/resource.cjs +49 -3
- package/dist/prompts/resource.d.ts +41 -2
- package/dist/prompts/resource.js +61 -5
- package/dist/prompts/types.d.ts +40 -15
- package/dist/routingRules/resource.d.ts +44 -2
- package/dist/routingRules/types.d.ts +33 -3
- package/dist/transport.d.ts +5 -1
- package/dist/usage/resource.cjs +113 -0
- package/dist/usage/resource.d.ts +29 -0
- package/dist/usage/resource.js +78 -0
- package/dist/usage/types.d.ts +81 -0
- package/package.json +14 -6
- package/src/client.ts +12 -0
- package/src/generated/index.ts +1 -1
- package/src/generated/types.gen.ts +9670 -4790
- package/src/generated/zod.gen.ts +6112 -3115
- package/src/pagination.ts +64 -0
- package/src/projectEnvironments/resource.ts +44 -9
- package/src/projectEnvironments/types.ts +19 -1
- package/src/prompts/resource.ts +149 -4
- package/src/prompts/types.ts +56 -15
- package/src/routingRules/resource.ts +77 -5
- package/src/routingRules/types.ts +35 -3
- package/src/transport.ts +14 -2
- package/src/usage/resource.ts +183 -0
- package/src/usage/types.ts +121 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyset paging, as every cursor list in the API answers it. `nextCursor` is
|
|
3
|
+
* the opaque cursor of the next page and `null` on the last one; `limit` is
|
|
4
|
+
* the page size the server applied (its default when the call passed none,
|
|
5
|
+
* clamped to its max).
|
|
6
|
+
*/
|
|
7
|
+
export interface CursorPaginationInfo {
|
|
8
|
+
nextCursor: string | null;
|
|
9
|
+
limit: number;
|
|
10
|
+
}
|
|
11
|
+
/** One page of a cursor list: `{ items, pagination: { nextCursor, limit } }`. */
|
|
12
|
+
export interface CursorPaginatedResult<T> {
|
|
13
|
+
items: T[];
|
|
14
|
+
pagination: CursorPaginationInfo;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetches one page. `cursor` is `undefined` for the first page and the
|
|
18
|
+
* previous page's `pagination.nextCursor` after that.
|
|
19
|
+
*/
|
|
20
|
+
export type FetchCursorPage<T> = (cursor: string | undefined) => Promise<CursorPaginatedResult<T>>;
|
|
21
|
+
/**
|
|
22
|
+
* Walks a cursor list page by page, yielding each page as the server returned
|
|
23
|
+
* it. Stops after the page whose `nextCursor` is `null` or empty. Throws a
|
|
24
|
+
* `To11aiError` when the server hands back a cursor it already returned, so a
|
|
25
|
+
* misbehaving endpoint cannot loop the caller forever.
|
|
26
|
+
*/
|
|
27
|
+
export declare function iterateCursorPages<T>(fetchPage: FetchCursorPage<T>): AsyncGenerator<CursorPaginatedResult<T>, void, undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Walks a cursor list and yields its items one by one, across every page.
|
|
30
|
+
* Same stop rules as `iterateCursorPages`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function iterateCursorItems<T>(fetchPage: FetchCursorPage<T>): AsyncGenerator<T, void, undefined>;
|
|
@@ -44,6 +44,14 @@ __export(exports_resource, {
|
|
|
44
44
|
module.exports = __toCommonJS(exports_resource);
|
|
45
45
|
var import_zod = require("zod");
|
|
46
46
|
var import_zod2 = require("../generated/zod.gen");
|
|
47
|
+
var import_pagination = require("../pagination");
|
|
48
|
+
var zProjectEnvironmentPage = import_zod.z.object({
|
|
49
|
+
items: import_zod.z.array(import_zod2.zProjectEnvironment),
|
|
50
|
+
pagination: import_zod.z.object({
|
|
51
|
+
nextCursor: import_zod.z.string().nullable(),
|
|
52
|
+
limit: import_zod.z.number().int()
|
|
53
|
+
})
|
|
54
|
+
});
|
|
47
55
|
function unwrap(envelope) {
|
|
48
56
|
if (envelope.data === null || envelope.data === undefined) {
|
|
49
57
|
throw new Error("API returned success but data is null");
|
|
@@ -63,12 +71,22 @@ class ProjectEnvironmentResource {
|
|
|
63
71
|
this.transport = transport;
|
|
64
72
|
}
|
|
65
73
|
async list(input) {
|
|
74
|
+
const query = {};
|
|
75
|
+
if (input.includeArchived)
|
|
76
|
+
query.includeArchived = "true";
|
|
77
|
+
if (input.cursor !== undefined)
|
|
78
|
+
query.cursor = input.cursor;
|
|
79
|
+
if (input.limit !== undefined)
|
|
80
|
+
query.limit = input.limit;
|
|
66
81
|
const envelope = await this.transport.request("GET", projectEnvironmentsPath(input.projectId), {
|
|
67
|
-
query
|
|
68
|
-
decode: (data) =>
|
|
82
|
+
query,
|
|
83
|
+
decode: (data) => zProjectEnvironmentPage.parse(data)
|
|
69
84
|
});
|
|
70
85
|
return unwrap(envelope);
|
|
71
86
|
}
|
|
87
|
+
iterate(input) {
|
|
88
|
+
return import_pagination.iterateCursorItems((cursor) => this.list({ ...input, cursor }));
|
|
89
|
+
}
|
|
72
90
|
async get(input) {
|
|
73
91
|
const envelope = await this.transport.request("GET", projectEnvironmentPath(input.projectId, input.slug), {
|
|
74
92
|
decode: (data) => import_zod2.zProjectEnvironment.parse(data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Transport } from "../transport";
|
|
2
|
-
import type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult } from "./types";
|
|
3
|
-
export type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, ProjectEnvironment, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult, } from "./types";
|
|
2
|
+
import type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, IterateProjectEnvironmentsInput, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, ProjectEnvironment, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult } from "./types";
|
|
3
|
+
export type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, IterateProjectEnvironmentsInput, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, ProjectEnvironment, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult, } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* SDK resource for `/v1/projects/:projectId/environments`. Constructed by
|
|
6
6
|
* `createClient` and exposed as `client.projectEnvironments`.
|
|
@@ -9,11 +9,27 @@ export declare class ProjectEnvironmentResource {
|
|
|
9
9
|
private readonly transport;
|
|
10
10
|
constructor(transport: Transport);
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
12
|
+
* One page of the project's environments, in settings order (`sortOrder`,
|
|
13
|
+
* then `slug`). Excludes archived rows by default — pass
|
|
14
|
+
* `includeArchived: true` to include rows with a non-null `archivedAt`
|
|
15
|
+
* (used by the admin / restore UI). The result mirrors the wire shape,
|
|
16
|
+
* `{ items, pagination: { nextCursor, limit } }`; pass
|
|
17
|
+
* `pagination.nextCursor` back as `cursor` until it is `null`, or use
|
|
18
|
+
* `iterate()`.
|
|
15
19
|
*/
|
|
16
20
|
list(input: ListProjectEnvironmentsInput): Promise<ListProjectEnvironmentsResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Every environment of the project: walks `list()` page by page until
|
|
23
|
+
* `pagination.nextCursor` is `null` and yields one environment at a time.
|
|
24
|
+
* Throws a `To11aiError` if the server repeats a cursor.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* for await (const env of to11.projectEnvironments.iterate({ projectId })) {
|
|
28
|
+
* console.log(env.slug);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
iterate(input: IterateProjectEnvironmentsInput): AsyncGenerator<ProjectEnvironment, void, undefined>;
|
|
17
33
|
get(input: GetProjectEnvironmentInput): Promise<GetProjectEnvironmentResult>;
|
|
18
34
|
/**
|
|
19
35
|
* Create a new environment.
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// src/projectEnvironments/resource.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { zProjectEnvironment } from "../generated/zod.gen";
|
|
4
|
+
import { iterateCursorItems } from "../pagination";
|
|
5
|
+
var zProjectEnvironmentPage = z.object({
|
|
6
|
+
items: z.array(zProjectEnvironment),
|
|
7
|
+
pagination: z.object({
|
|
8
|
+
nextCursor: z.string().nullable(),
|
|
9
|
+
limit: z.number().int()
|
|
10
|
+
})
|
|
11
|
+
});
|
|
4
12
|
function unwrap(envelope) {
|
|
5
13
|
if (envelope.data === null || envelope.data === undefined) {
|
|
6
14
|
throw new Error("API returned success but data is null");
|
|
@@ -20,12 +28,22 @@ class ProjectEnvironmentResource {
|
|
|
20
28
|
this.transport = transport;
|
|
21
29
|
}
|
|
22
30
|
async list(input) {
|
|
31
|
+
const query = {};
|
|
32
|
+
if (input.includeArchived)
|
|
33
|
+
query.includeArchived = "true";
|
|
34
|
+
if (input.cursor !== undefined)
|
|
35
|
+
query.cursor = input.cursor;
|
|
36
|
+
if (input.limit !== undefined)
|
|
37
|
+
query.limit = input.limit;
|
|
23
38
|
const envelope = await this.transport.request("GET", projectEnvironmentsPath(input.projectId), {
|
|
24
|
-
query
|
|
25
|
-
decode: (data) =>
|
|
39
|
+
query,
|
|
40
|
+
decode: (data) => zProjectEnvironmentPage.parse(data)
|
|
26
41
|
});
|
|
27
42
|
return unwrap(envelope);
|
|
28
43
|
}
|
|
44
|
+
iterate(input) {
|
|
45
|
+
return iterateCursorItems((cursor) => this.list({ ...input, cursor }));
|
|
46
|
+
}
|
|
29
47
|
async get(input) {
|
|
30
48
|
const envelope = await this.transport.request("GET", projectEnvironmentPath(input.projectId, input.slug), {
|
|
31
49
|
decode: (data) => zProjectEnvironment.parse(data)
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import type { ArchiveProjectEnvironmentResult as GenArchiveProjectEnvironmentResult, ProjectEnvironment as GenProjectEnvironment } from "../generated/types.gen";
|
|
2
|
+
import type { CursorPaginatedResult } from "../pagination";
|
|
2
3
|
export type ProjectEnvironment = GenProjectEnvironment;
|
|
3
4
|
export type ArchiveProjectEnvironmentResult = GenArchiveProjectEnvironmentResult;
|
|
4
5
|
export interface ListProjectEnvironmentsInput {
|
|
5
6
|
projectId: string;
|
|
6
7
|
includeArchived?: boolean;
|
|
8
|
+
/** `pagination.nextCursor` of the previous page. Omit for the first page. */
|
|
9
|
+
cursor?: string;
|
|
10
|
+
/** Page size. The server defaults to 100 and clamps to [1, 100]. */
|
|
11
|
+
limit?: number;
|
|
7
12
|
}
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Input of `iterate()`: `list()` without `cursor`, which the walk supplies.
|
|
15
|
+
*/
|
|
16
|
+
export type IterateProjectEnvironmentsInput = Omit<ListProjectEnvironmentsInput, "cursor">;
|
|
17
|
+
/**
|
|
18
|
+
* One page of a project's environments, in settings order (`sortOrder`,
|
|
19
|
+
* then `slug`).
|
|
20
|
+
*/
|
|
21
|
+
export type ListProjectEnvironmentsResult = CursorPaginatedResult<ProjectEnvironment>;
|
|
9
22
|
export interface GetProjectEnvironmentInput {
|
|
10
23
|
projectId: string;
|
|
11
24
|
slug: string;
|
|
@@ -44,9 +44,14 @@ __export(exports_resource, {
|
|
|
44
44
|
module.exports = __toCommonJS(exports_resource);
|
|
45
45
|
var import_errors = require("../errors");
|
|
46
46
|
var import_zod = require("../generated/zod.gen");
|
|
47
|
+
var import_pagination = require("../pagination");
|
|
47
48
|
var import_shape = require("./shape");
|
|
48
49
|
var import_types = require("./types");
|
|
49
50
|
var LATEST_PROMPT_LABEL = "latest";
|
|
51
|
+
var versionsPage = import_zod.zPromptsListPromptVersionsResponse.shape.data.unwrap();
|
|
52
|
+
var labelsPage = import_zod.zPromptsListPromptLabelsResponse.shape.data.unwrap();
|
|
53
|
+
var orgPromptsData = import_zod.zOrgPromptsListOrgPromptsResponse.shape.data.unwrap();
|
|
54
|
+
var skillVersionData = import_zod.zPromptsRenderSkillVersionResponse.shape.data.unwrap();
|
|
50
55
|
function unwrap(envelope) {
|
|
51
56
|
if (envelope.data === null || envelope.data === undefined) {
|
|
52
57
|
throw new Error("API returned success but data is null");
|
|
@@ -89,6 +94,13 @@ function liftFallbackToRendered(fallback, slug) {
|
|
|
89
94
|
}
|
|
90
95
|
return { ...structuredClone(fallback), slug: fallback.slug || slug };
|
|
91
96
|
}
|
|
97
|
+
function rejectDotSegments(params) {
|
|
98
|
+
for (const [name, value] of Object.entries(params)) {
|
|
99
|
+
if (value === "." || value === "..") {
|
|
100
|
+
throw new import_errors.To11aiValidationError(`[to11ai/sdk] \`${name}\` cannot be "${value}": a path segment of only dots`, "invalid_path_param", { param: name });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
92
104
|
function getProjectPromptPath(projectId, promptId) {
|
|
93
105
|
return `${getProjectPromptsPath(projectId)}/${encodeURIComponent(promptId)}`;
|
|
94
106
|
}
|
|
@@ -167,9 +179,15 @@ class PromptResource {
|
|
|
167
179
|
query.cursor = cursor;
|
|
168
180
|
if (limit !== undefined)
|
|
169
181
|
query.limit = limit;
|
|
170
|
-
const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions`, {
|
|
182
|
+
const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions`, {
|
|
183
|
+
query,
|
|
184
|
+
decode: (data) => versionsPage.parse(data)
|
|
185
|
+
});
|
|
171
186
|
return unwrap(envelope);
|
|
172
187
|
}
|
|
188
|
+
iterateVersions(input) {
|
|
189
|
+
return import_pagination.iterateCursorItems((cursor) => this.listVersions({ ...input, cursor }));
|
|
190
|
+
}
|
|
173
191
|
async getVersion(input) {
|
|
174
192
|
const { projectId: perCallProjectId, promptId, versionNumber } = input;
|
|
175
193
|
const projectId = this.resolveProjectId(perCallProjectId);
|
|
@@ -177,9 +195,37 @@ class PromptResource {
|
|
|
177
195
|
return unwrap(envelope);
|
|
178
196
|
}
|
|
179
197
|
async listLabels(input) {
|
|
180
|
-
const { projectId: perCallProjectId, promptId } = input;
|
|
198
|
+
const { projectId: perCallProjectId, promptId, cursor, limit } = input;
|
|
181
199
|
const projectId = this.resolveProjectId(perCallProjectId);
|
|
182
|
-
const
|
|
200
|
+
const query = {};
|
|
201
|
+
if (cursor !== undefined)
|
|
202
|
+
query.cursor = cursor;
|
|
203
|
+
if (limit !== undefined)
|
|
204
|
+
query.limit = limit;
|
|
205
|
+
const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/labels`, {
|
|
206
|
+
query,
|
|
207
|
+
decode: (data) => labelsPage.parse(data)
|
|
208
|
+
});
|
|
209
|
+
return unwrap(envelope);
|
|
210
|
+
}
|
|
211
|
+
iterateLabels(input) {
|
|
212
|
+
return import_pagination.iterateCursorItems((cursor) => this.listLabels({ ...input, cursor }));
|
|
213
|
+
}
|
|
214
|
+
async listOrgPrompts(input) {
|
|
215
|
+
const { orgId, kind, query, limit } = input;
|
|
216
|
+
const envelope = await this.transport.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/prompts`, {
|
|
217
|
+
query: { kind, query, limit },
|
|
218
|
+
decode: (data) => orgPromptsData.parse(data)
|
|
219
|
+
});
|
|
220
|
+
return unwrap(envelope);
|
|
221
|
+
}
|
|
222
|
+
async renderSkillVersion(input) {
|
|
223
|
+
const projectId = this.resolveProjectId(input.projectId);
|
|
224
|
+
rejectDotSegments({ projectId, slug: input.slug });
|
|
225
|
+
const envelope = await this.transport.request("POST", `${getProjectPromptsPath(projectId)}/by-slug/${encodeURIComponent(input.slug)}/versions/${encodeURIComponent(String(input.version))}/render`, {
|
|
226
|
+
body: {},
|
|
227
|
+
decode: (data) => skillVersionData.parse(data)
|
|
228
|
+
});
|
|
183
229
|
return unwrap(envelope);
|
|
184
230
|
}
|
|
185
231
|
async render(slug, options = {}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Transport } from "../transport";
|
|
2
2
|
import type { AnthropicRenderedPrompt, OpenAiRenderedPrompt, RenderResult } from "./shape";
|
|
3
|
-
import type { ArchivePromptInput, ArchivePromptResult, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, PaginatedResult, RenderFormat, RenderOptions, UnknownRoleMode, UpdatePromptInput, UpdatePromptResult } from "./types";
|
|
4
|
-
export type { ArchivePromptInput, ArchivePromptResult, BlockRenderRecord, ChatMessage, ChatRole, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, CursorPaginatedResult, CursorPaginationInfo, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, PaginatedResult, PaginationInfo, Prompt, PromptFormat, PromptLabelPointer, PromptStatus, PromptVersion, PromptVersionSummary, RenderedChatMessage, RenderedPrompt, RenderFormat, RenderOptions, ResolvedPrompt, ResolvedPromptEnvelope, ResolvedToolCall, ResolvedToolDefinition, RowError, UnknownRoleMode, UpdatePromptInput, UpdatePromptResult, } from "./types";
|
|
3
|
+
import type { ArchivePromptInput, ArchivePromptResult, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, IterateLabelsInput, IterateVersionsInput, ListOrgPromptsInput, ListOrgPromptsResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, PaginatedResult, PromptLabelPointer, PromptVersionSummary, RenderedSkillVersion, RenderFormat, RenderOptions, RenderSkillVersionInput, UnknownRoleMode, UpdatePromptInput, UpdatePromptResult } from "./types";
|
|
4
|
+
export type { ArchivePromptInput, ArchivePromptResult, BlockRenderRecord, ChatMessage, ChatRole, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, CursorPaginatedResult, CursorPaginationInfo, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, IterateLabelsInput, IterateVersionsInput, ListOrgPromptsInput, ListOrgPromptsResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, OrgPromptRow, PaginatedResult, PaginationInfo, Prompt, PromptFormat, PromptLabelPointer, PromptStatus, PromptVersion, PromptVersionSummary, RenderedChatMessage, RenderedPrompt, RenderedSkillFile, RenderedSkillVersion, RenderFormat, RenderOptions, RenderSkillVersionInput, ResolvedPrompt, ResolvedPromptEnvelope, ResolvedToolCall, ResolvedToolDefinition, RowError, UnknownRoleMode, UpdatePromptInput, UpdatePromptResult, } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* Init-time config for the `render()` surface (TO11-980 / S9).
|
|
7
7
|
*
|
|
@@ -48,8 +48,47 @@ export declare class PromptResource<F extends RenderFormat | undefined = undefin
|
|
|
48
48
|
* version's content with `getVersion()`.
|
|
49
49
|
*/
|
|
50
50
|
listVersions(input: ListPromptVersionsInput): Promise<ListPromptVersionsResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Every version of a prompt, newest first, as summaries: walks
|
|
53
|
+
* `listVersions()` page by page until `pagination.nextCursor` is `null` and
|
|
54
|
+
* yields one `PromptVersionSummary` at a time. `limit` sets the page size of
|
|
55
|
+
* each request. Throws a `To11aiError` if the server repeats a cursor.
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* for await (const version of to11.prompts.iterateVersions({ promptId })) {
|
|
59
|
+
* console.log(version.version);
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
iterateVersions(input: IterateVersionsInput): AsyncGenerator<PromptVersionSummary, void, undefined>;
|
|
51
64
|
getVersion(input: GetPromptVersionInput): Promise<GetPromptVersionResult>;
|
|
65
|
+
/**
|
|
66
|
+
* One page of a prompt's labels, by label name (today only `latest`). The
|
|
67
|
+
* result mirrors the wire shape, `{ items, pagination: { nextCursor,
|
|
68
|
+
* limit } }`; pass `pagination.nextCursor` back as `cursor` until it is
|
|
69
|
+
* `null`, or use `iterateLabels()`.
|
|
70
|
+
*/
|
|
52
71
|
listLabels(input: ListPromptLabelsInput): Promise<ListPromptLabelsResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Every label of a prompt: walks `listLabels()` page by page until
|
|
74
|
+
* `pagination.nextCursor` is `null`. Throws a `To11aiError` if the server
|
|
75
|
+
* repeats a cursor.
|
|
76
|
+
*/
|
|
77
|
+
iterateLabels(input: IterateLabelsInput): AsyncGenerator<PromptLabelPointer, void, undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Skills across every project of `orgId` the caller may read prompts in,
|
|
80
|
+
* each with the version its `latest` label serves at listing time. At most
|
|
81
|
+
* `limit` rows (default 20, max 50): a picker, not a list to page. Projects
|
|
82
|
+
* the read left out are listed in `excludedProjects`.
|
|
83
|
+
*/
|
|
84
|
+
listOrgPrompts(input: ListOrgPromptsInput): Promise<ListOrgPromptsResult>;
|
|
85
|
+
/**
|
|
86
|
+
* One exact version of a skill, by slug, with its files. Pass the
|
|
87
|
+
* `version` `listOrgPrompts()` returned so the caller runs exactly the
|
|
88
|
+
* version it listed, whatever `latest` serves by then. A chat prompt at
|
|
89
|
+
* this address is a 409.
|
|
90
|
+
*/
|
|
91
|
+
renderSkillVersion(input: RenderSkillVersionInput): Promise<RenderedSkillVersion>;
|
|
53
92
|
/**
|
|
54
93
|
* Resolve and (optionally) shape a prompt for the client's configured
|
|
55
94
|
* `projectId`, in one control-plane request. With a `format` (per call or
|
package/dist/prompts/resource.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
// src/prompts/resource.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
To11aiApiError,
|
|
4
|
+
To11aiNetworkError,
|
|
5
|
+
To11aiValidationError
|
|
6
|
+
} from "../errors";
|
|
7
|
+
import {
|
|
8
|
+
zOrgPromptsListOrgPromptsResponse,
|
|
9
|
+
zPromptsListPromptLabelsResponse,
|
|
10
|
+
zPromptsListPromptVersionsResponse,
|
|
11
|
+
zPromptsRenderSkillVersionResponse,
|
|
12
|
+
zResolvedPrompt
|
|
13
|
+
} from "../generated/zod.gen";
|
|
14
|
+
import { iterateCursorItems } from "../pagination";
|
|
4
15
|
import { shapePrompt } from "./shape";
|
|
5
16
|
import { ENV_SLUG_REGEX } from "./types";
|
|
6
17
|
var LATEST_PROMPT_LABEL = "latest";
|
|
18
|
+
var versionsPage = zPromptsListPromptVersionsResponse.shape.data.unwrap();
|
|
19
|
+
var labelsPage = zPromptsListPromptLabelsResponse.shape.data.unwrap();
|
|
20
|
+
var orgPromptsData = zOrgPromptsListOrgPromptsResponse.shape.data.unwrap();
|
|
21
|
+
var skillVersionData = zPromptsRenderSkillVersionResponse.shape.data.unwrap();
|
|
7
22
|
function unwrap(envelope) {
|
|
8
23
|
if (envelope.data === null || envelope.data === undefined) {
|
|
9
24
|
throw new Error("API returned success but data is null");
|
|
@@ -46,6 +61,13 @@ function liftFallbackToRendered(fallback, slug) {
|
|
|
46
61
|
}
|
|
47
62
|
return { ...structuredClone(fallback), slug: fallback.slug || slug };
|
|
48
63
|
}
|
|
64
|
+
function rejectDotSegments(params) {
|
|
65
|
+
for (const [name, value] of Object.entries(params)) {
|
|
66
|
+
if (value === "." || value === "..") {
|
|
67
|
+
throw new To11aiValidationError(`[to11ai/sdk] \`${name}\` cannot be "${value}": a path segment of only dots`, "invalid_path_param", { param: name });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
49
71
|
function getProjectPromptPath(projectId, promptId) {
|
|
50
72
|
return `${getProjectPromptsPath(projectId)}/${encodeURIComponent(promptId)}`;
|
|
51
73
|
}
|
|
@@ -124,9 +146,15 @@ class PromptResource {
|
|
|
124
146
|
query.cursor = cursor;
|
|
125
147
|
if (limit !== undefined)
|
|
126
148
|
query.limit = limit;
|
|
127
|
-
const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions`, {
|
|
149
|
+
const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions`, {
|
|
150
|
+
query,
|
|
151
|
+
decode: (data) => versionsPage.parse(data)
|
|
152
|
+
});
|
|
128
153
|
return unwrap(envelope);
|
|
129
154
|
}
|
|
155
|
+
iterateVersions(input) {
|
|
156
|
+
return iterateCursorItems((cursor) => this.listVersions({ ...input, cursor }));
|
|
157
|
+
}
|
|
130
158
|
async getVersion(input) {
|
|
131
159
|
const { projectId: perCallProjectId, promptId, versionNumber } = input;
|
|
132
160
|
const projectId = this.resolveProjectId(perCallProjectId);
|
|
@@ -134,9 +162,37 @@ class PromptResource {
|
|
|
134
162
|
return unwrap(envelope);
|
|
135
163
|
}
|
|
136
164
|
async listLabels(input) {
|
|
137
|
-
const { projectId: perCallProjectId, promptId } = input;
|
|
165
|
+
const { projectId: perCallProjectId, promptId, cursor, limit } = input;
|
|
138
166
|
const projectId = this.resolveProjectId(perCallProjectId);
|
|
139
|
-
const
|
|
167
|
+
const query = {};
|
|
168
|
+
if (cursor !== undefined)
|
|
169
|
+
query.cursor = cursor;
|
|
170
|
+
if (limit !== undefined)
|
|
171
|
+
query.limit = limit;
|
|
172
|
+
const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/labels`, {
|
|
173
|
+
query,
|
|
174
|
+
decode: (data) => labelsPage.parse(data)
|
|
175
|
+
});
|
|
176
|
+
return unwrap(envelope);
|
|
177
|
+
}
|
|
178
|
+
iterateLabels(input) {
|
|
179
|
+
return iterateCursorItems((cursor) => this.listLabels({ ...input, cursor }));
|
|
180
|
+
}
|
|
181
|
+
async listOrgPrompts(input) {
|
|
182
|
+
const { orgId, kind, query, limit } = input;
|
|
183
|
+
const envelope = await this.transport.request("GET", `/v1/orgs/${encodeURIComponent(orgId)}/prompts`, {
|
|
184
|
+
query: { kind, query, limit },
|
|
185
|
+
decode: (data) => orgPromptsData.parse(data)
|
|
186
|
+
});
|
|
187
|
+
return unwrap(envelope);
|
|
188
|
+
}
|
|
189
|
+
async renderSkillVersion(input) {
|
|
190
|
+
const projectId = this.resolveProjectId(input.projectId);
|
|
191
|
+
rejectDotSegments({ projectId, slug: input.slug });
|
|
192
|
+
const envelope = await this.transport.request("POST", `${getProjectPromptsPath(projectId)}/by-slug/${encodeURIComponent(input.slug)}/versions/${encodeURIComponent(String(input.version))}/render`, {
|
|
193
|
+
body: {},
|
|
194
|
+
decode: (data) => skillVersionData.parse(data)
|
|
195
|
+
});
|
|
140
196
|
return unwrap(envelope);
|
|
141
197
|
}
|
|
142
198
|
async render(slug, options = {}) {
|
package/dist/prompts/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Prompt as GenPrompt, PromptLabelPointer as GenPromptLabelPointer, PromptVersion as GenPromptVersion, PromptVersionSummary as GenPromptVersionSummary, RenderedChatPrompt as GenRenderedChatPrompt, ResolvedPrompt as GenResolvedPrompt, ResolvedToolCall as GenResolvedToolCall, ResolvedToolDefinition as GenResolvedToolDefinition } from "../generated/types.gen";
|
|
1
|
+
import type { OrgPromptRow as GenOrgPromptRow, OrgPromptsResponse as GenOrgPromptsResponse, Prompt as GenPrompt, PromptLabelPointer as GenPromptLabelPointer, PromptVersion as GenPromptVersion, PromptVersionSummary as GenPromptVersionSummary, RenderedChatPrompt as GenRenderedChatPrompt, RenderedSkillFile as GenRenderedSkillFile, RenderedSkillVersion as GenRenderedSkillVersion, ResolvedPrompt as GenResolvedPrompt, ResolvedToolCall as GenResolvedToolCall, ResolvedToolDefinition as GenResolvedToolDefinition } from "../generated/types.gen";
|
|
2
|
+
import type { CursorPaginatedResult } from "../pagination";
|
|
2
3
|
export interface RowError {
|
|
3
4
|
path: ReadonlyArray<string | number>;
|
|
4
5
|
code: string;
|
|
@@ -55,19 +56,7 @@ export interface PaginatedResult<T> {
|
|
|
55
56
|
items: T[];
|
|
56
57
|
pagination: PaginationInfo;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
* Keyset paging, as the audit feeds use it. `nextCursor` is the opaque cursor
|
|
60
|
-
* of the next page and `null` on the last one; `limit` is the page size the
|
|
61
|
-
* server applied (its default when the call passed none, clamped to its max).
|
|
62
|
-
*/
|
|
63
|
-
export interface CursorPaginationInfo {
|
|
64
|
-
nextCursor: string | null;
|
|
65
|
-
limit: number;
|
|
66
|
-
}
|
|
67
|
-
export interface CursorPaginatedResult<T> {
|
|
68
|
-
items: T[];
|
|
69
|
-
pagination: CursorPaginationInfo;
|
|
70
|
-
}
|
|
59
|
+
export type { CursorPaginatedResult, CursorPaginationInfo, } from "../pagination";
|
|
71
60
|
export interface CreatePromptInput {
|
|
72
61
|
projectId?: string;
|
|
73
62
|
name: string;
|
|
@@ -121,6 +110,11 @@ export interface ListPromptVersionsInput {
|
|
|
121
110
|
/** Page size. The server defaults to 50 and clamps to 100. */
|
|
122
111
|
limit?: number;
|
|
123
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Input of `iterateVersions()`: `listVersions()` without `cursor`, which the
|
|
115
|
+
* iterator manages. `limit` is the page size of each request.
|
|
116
|
+
*/
|
|
117
|
+
export type IterateVersionsInput = Omit<ListPromptVersionsInput, "cursor">;
|
|
124
118
|
/**
|
|
125
119
|
* One page of a prompt's versions, newest first, as summaries. Read a
|
|
126
120
|
* version's content with `getVersion()`.
|
|
@@ -135,8 +129,18 @@ export type GetPromptVersionResult = PromptVersion;
|
|
|
135
129
|
export interface ListPromptLabelsInput {
|
|
136
130
|
projectId?: string;
|
|
137
131
|
promptId: string;
|
|
132
|
+
/** `pagination.nextCursor` of the previous page. Omit for the first page. */
|
|
133
|
+
cursor?: string;
|
|
134
|
+
/** Page size. The server defaults to 100 and clamps to [1, 100]. */
|
|
135
|
+
limit?: number;
|
|
138
136
|
}
|
|
139
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Input of `iterateLabels()`: `listLabels()` without `cursor`, which the walk
|
|
139
|
+
* supplies.
|
|
140
|
+
*/
|
|
141
|
+
export type IterateLabelsInput = Omit<ListPromptLabelsInput, "cursor">;
|
|
142
|
+
/** One page of a prompt's labels, by label name. Today only `latest`. */
|
|
143
|
+
export type ListPromptLabelsResult = CursorPaginatedResult<PromptLabelPointer>;
|
|
140
144
|
/**
|
|
141
145
|
* Slug rule shared by the client `env` (the gateway's `x-to11-env` routing key)
|
|
142
146
|
* and a `render()` label — lowercase-kebab, 1-63 chars. Both are routing keys,
|
|
@@ -208,3 +212,24 @@ export interface RenderOptions {
|
|
|
208
212
|
*/
|
|
209
213
|
onUnknownRole?: UnknownRoleMode;
|
|
210
214
|
}
|
|
215
|
+
/** `GET /v1/orgs/:orgId/prompts`: skills across the projects the caller reads. */
|
|
216
|
+
export interface ListOrgPromptsInput {
|
|
217
|
+
readonly orgId: string;
|
|
218
|
+
/** Only `skill` today; the server's default. */
|
|
219
|
+
readonly kind?: "skill";
|
|
220
|
+
/** Case-insensitive substring of the skill's name or slug; 1–100 chars. */
|
|
221
|
+
readonly query?: string;
|
|
222
|
+
/** Default 20, max 50: a picker, not a list to page. */
|
|
223
|
+
readonly limit?: number;
|
|
224
|
+
}
|
|
225
|
+
/** One skill and the version its `latest` label serves at listing time. */
|
|
226
|
+
export type OrgPromptRow = GenOrgPromptRow;
|
|
227
|
+
export type ListOrgPromptsResult = GenOrgPromptsResponse;
|
|
228
|
+
/** Render one exact skill version (`OrgPromptRow.version`) by slug. */
|
|
229
|
+
export interface RenderSkillVersionInput {
|
|
230
|
+
readonly projectId: string;
|
|
231
|
+
readonly slug: string;
|
|
232
|
+
readonly version: number;
|
|
233
|
+
}
|
|
234
|
+
export type RenderedSkillVersion = GenRenderedSkillVersion;
|
|
235
|
+
export type RenderedSkillFile = GenRenderedSkillFile;
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import type { Transport } from "../transport";
|
|
2
|
-
import type { CreateRuleVersionInput, CreateRuleVersionResult, GetRuleVersionInput, GetRuleVersionResult, ListRuleReleasesInput, ListRuleReleasesResult, ListRuleVersionsInput, ListRuleVersionsResult, RollbackRuleReleaseInput, RollbackRuleReleaseResult, SetRuleReleaseInput, SetRuleReleaseResult } from "./types";
|
|
3
|
-
export type { CreateRuleVersionInput, CreateRuleVersionResult, GetRuleVersionInput, GetRuleVersionResult, ListRuleReleasesInput, ListRuleReleasesResult, ListRuleVersionsInput, ListRuleVersionsResult, RollbackRuleReleaseInput, RollbackRuleReleaseResult, RuleModelBinding, RuleProviderRef, RuleRelease, RuleReleaseActorType, RuleReleaseApprovalStatus, RuleReleaseChangeKind, RuleReleaseStrategy, RuleReleaseWeight, RuleSnapshot, RuleStrategy, RuleVersion, SetRuleReleaseInput, SetRuleReleaseResult, } from "./types";
|
|
2
|
+
import type { CreateRuleVersionInput, CreateRuleVersionResult, GetRuleVersionInput, GetRuleVersionResult, IterateRuleReleasesInput, IterateRuleVersionsInput, ListRuleReleasesInput, ListRuleReleasesResult, ListRuleVersionsInput, ListRuleVersionsResult, RollbackRuleReleaseInput, RollbackRuleReleaseResult, RuleRelease, RuleVersion, SetRuleReleaseInput, SetRuleReleaseResult } from "./types";
|
|
3
|
+
export type { CreateRuleVersionInput, CreateRuleVersionResult, GetRuleVersionInput, GetRuleVersionResult, IterateRuleReleasesInput, IterateRuleVersionsInput, ListRuleReleasesInput, ListRuleReleasesResult, ListRuleVersionsInput, ListRuleVersionsResult, RollbackRuleReleaseInput, RollbackRuleReleaseResult, RuleModelBinding, RuleProviderRef, RuleRelease, RuleReleaseActorType, RuleReleaseApprovalStatus, RuleReleaseChangeKind, RuleReleaseStrategy, RuleReleaseWeight, RuleSnapshot, RuleStrategy, RuleVersion, SetRuleReleaseInput, SetRuleReleaseResult, } from "./types";
|
|
4
4
|
export declare class RoutingRuleVersionResource {
|
|
5
5
|
private readonly transport;
|
|
6
6
|
constructor(transport: Transport);
|
|
7
7
|
create(input: CreateRuleVersionInput): Promise<CreateRuleVersionResult>;
|
|
8
|
+
/**
|
|
9
|
+
* One page of a rule's versions, newest first. The result mirrors the wire
|
|
10
|
+
* shape, `{ items, pagination: { nextCursor, limit } }`; pass
|
|
11
|
+
* `pagination.nextCursor` back as `cursor` until it is `null`. Pass only a
|
|
12
|
+
* cursor this list returned: a malformed or unreadable one answers 400
|
|
13
|
+
* `invalid_cursor`.
|
|
14
|
+
*/
|
|
8
15
|
list(input: ListRuleVersionsInput): Promise<ListRuleVersionsResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Every version of a rule, newest first: walks `list()` page by page until
|
|
18
|
+
* `pagination.nextCursor` is `null` and yields one `RuleVersion` at a time.
|
|
19
|
+
* `limit` sets the page size of each request. Throws a `To11aiError` if the
|
|
20
|
+
* server repeats a cursor.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* for await (const version of rules.versions.iterate({ projectId, ruleId })) {
|
|
24
|
+
* console.log(version.version);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
iterate(input: IterateRuleVersionsInput): AsyncGenerator<RuleVersion, void, undefined>;
|
|
9
29
|
get(input: GetRuleVersionInput): Promise<GetRuleVersionResult>;
|
|
10
30
|
}
|
|
11
31
|
export declare class RoutingRuleReleaseResource {
|
|
@@ -13,7 +33,29 @@ export declare class RoutingRuleReleaseResource {
|
|
|
13
33
|
constructor(transport: Transport);
|
|
14
34
|
set(input: SetRuleReleaseInput): Promise<SetRuleReleaseResult>;
|
|
15
35
|
rollback(input: RollbackRuleReleaseInput): Promise<RollbackRuleReleaseResult>;
|
|
36
|
+
/**
|
|
37
|
+
* One page of a rule's releases, newest first. Without `envSlug` it lists
|
|
38
|
+
* every environment's releases; with it, one environment's. The result
|
|
39
|
+
* mirrors the wire shape, `{ items, pagination: { nextCursor, limit } }`;
|
|
40
|
+
* pass `pagination.nextCursor` back as `cursor` until it is `null`. Pass
|
|
41
|
+
* only a cursor this list returned: a malformed or unreadable one answers
|
|
42
|
+
* 400 `invalid_cursor`, while a well-formed cursor from another list is
|
|
43
|
+
* accepted and continues from its position, which can skip releases.
|
|
44
|
+
*/
|
|
16
45
|
list(input: ListRuleReleasesInput): Promise<ListRuleReleasesResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Every release of a rule, newest first: walks `list()` page by page until
|
|
48
|
+
* `pagination.nextCursor` is `null` and yields one `RuleRelease` at a time.
|
|
49
|
+
* `limit` sets the page size of each request. Throws a `To11aiError` if the
|
|
50
|
+
* server repeats a cursor.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* for await (const release of rules.releases.iterate({ projectId, ruleId })) {
|
|
54
|
+
* console.log(release.envSlug, release.changeKind);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
iterate(input: IterateRuleReleasesInput): AsyncGenerator<RuleRelease, void, undefined>;
|
|
17
59
|
}
|
|
18
60
|
export declare class RoutingRulesResource {
|
|
19
61
|
readonly versions: RoutingRuleVersionResource;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RuleModelBinding as GenRuleModelBinding, RuleProviderRef as GenRuleProviderRef, RuleRelease as GenRuleRelease, RuleReleaseWeight as GenRuleReleaseWeight, RuleSnapshot as GenRuleSnapshot, RuleVersion as GenRuleVersion } from "../generated/types.gen";
|
|
2
|
+
import type { CursorPaginatedResult } from "../pagination";
|
|
2
3
|
export type RuleProviderRef = GenRuleProviderRef;
|
|
3
4
|
export type RuleModelBinding = GenRuleModelBinding;
|
|
4
5
|
export type RuleStrategy = GenRuleSnapshot["strategy"];
|
|
@@ -11,13 +12,27 @@ export interface CreateRuleVersionInput {
|
|
|
11
12
|
description?: string;
|
|
12
13
|
}
|
|
13
14
|
export type CreateRuleVersionResult = RuleVersion;
|
|
15
|
+
/**
|
|
16
|
+
* Input of `versions.list()`. `cursor` is the previous page's
|
|
17
|
+
* `pagination.nextCursor`; `limit` is the page size (the server clamps it
|
|
18
|
+
* into 1..100 and defaults to 50).
|
|
19
|
+
*/
|
|
14
20
|
export interface ListRuleVersionsInput {
|
|
15
21
|
projectId: string;
|
|
16
22
|
ruleId: string;
|
|
17
|
-
cursor?:
|
|
23
|
+
cursor?: string;
|
|
18
24
|
limit?: number;
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Input of `versions.iterate()`: `versions.list()` without `cursor`, which the
|
|
28
|
+
* iterator manages. `limit` is the page size of each request.
|
|
29
|
+
*/
|
|
30
|
+
export type IterateRuleVersionsInput = Omit<ListRuleVersionsInput, "cursor">;
|
|
31
|
+
/**
|
|
32
|
+
* One page of a rule's versions, newest first (`version` descending):
|
|
33
|
+
* `{ items, pagination: { nextCursor, limit } }`.
|
|
34
|
+
*/
|
|
35
|
+
export type ListRuleVersionsResult = CursorPaginatedResult<RuleVersion>;
|
|
21
36
|
export interface GetRuleVersionInput {
|
|
22
37
|
projectId: string;
|
|
23
38
|
ruleId: string;
|
|
@@ -48,6 +63,12 @@ export interface RollbackRuleReleaseInput {
|
|
|
48
63
|
targetReleaseId?: string;
|
|
49
64
|
}
|
|
50
65
|
export type RollbackRuleReleaseResult = RuleRelease;
|
|
66
|
+
/**
|
|
67
|
+
* Input of `releases.list()`. Without `envSlug` the call lists the rule's
|
|
68
|
+
* releases across every environment; with it, one environment's. `cursor` is
|
|
69
|
+
* the previous page's `pagination.nextCursor`; `limit` is the page size (the
|
|
70
|
+
* server clamps it into 1..100 and defaults to 50).
|
|
71
|
+
*/
|
|
51
72
|
export interface ListRuleReleasesInput {
|
|
52
73
|
projectId: string;
|
|
53
74
|
ruleId: string;
|
|
@@ -55,4 +76,13 @@ export interface ListRuleReleasesInput {
|
|
|
55
76
|
cursor?: string;
|
|
56
77
|
limit?: number;
|
|
57
78
|
}
|
|
58
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Input of `releases.iterate()`: `releases.list()` without `cursor`, which the
|
|
81
|
+
* iterator manages. `limit` is the page size of each request.
|
|
82
|
+
*/
|
|
83
|
+
export type IterateRuleReleasesInput = Omit<ListRuleReleasesInput, "cursor">;
|
|
84
|
+
/**
|
|
85
|
+
* One page of a rule's releases, newest first:
|
|
86
|
+
* `{ items, pagination: { nextCursor, limit } }`.
|
|
87
|
+
*/
|
|
88
|
+
export type ListRuleReleasesResult = CursorPaginatedResult<RuleRelease>;
|
package/dist/transport.d.ts
CHANGED
|
@@ -56,7 +56,11 @@ export declare class Transport {
|
|
|
56
56
|
constructor(config: TransportConfig);
|
|
57
57
|
private buildHeaders;
|
|
58
58
|
request<T>(method: string, path: string, options?: {
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Query params. An array value repeats the param once per element
|
|
61
|
+
* (`?groupBy=model&groupBy=project`); `undefined` or `null` omits it.
|
|
62
|
+
*/
|
|
63
|
+
query?: Record<string, string | number | boolean | ReadonlyArray<string> | null | undefined>;
|
|
60
64
|
body?: unknown;
|
|
61
65
|
/**
|
|
62
66
|
* Runtime validator for the envelope `data` on a 2xx response. When
|