From 8d8331f3407a08b479ff890fdc025648e4b46e02 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Thu, 19 Nov 2026 20:51:20 +0530 Subject: [PATCH 01/12] [AGE-2886] Add list and get artifact APIs Co-authored-by: Cursor --- .changeset/artifact-apis.md | 5 ++ packages/trueforge/scripts/write-openapi.ts | 2 + packages/trueforge/src/apis/artifacts.ts | 60 +++++++++++++++++ packages/trueforge/src/app.ts | 7 ++ packages/trueforge/src/main.ts | 10 +++ .../trueforge/src/routes/artifactRoutes.ts | 64 +++++++++++++++++++ packages/trueforge/src/routes/openapiTags.ts | 2 + packages/trueforge/src/schemas/artifact.ts | 41 ++++++++++++ .../tests/unit/apis/artifacts.test.ts | 52 +++++++++++++++ 9 files changed, 243 insertions(+) create mode 100644 .changeset/artifact-apis.md create mode 100644 packages/trueforge/src/apis/artifacts.ts create mode 100644 packages/trueforge/src/routes/artifactRoutes.ts create mode 100644 packages/trueforge/src/schemas/artifact.ts create mode 100644 packages/trueforge/tests/unit/apis/artifacts.test.ts diff --git a/.changeset/artifact-apis.md b/.changeset/artifact-apis.md new file mode 100644 index 0000000000..6d90b5abce --- /dev/null +++ b/.changeset/artifact-apis.md @@ -0,0 +1,5 @@ +--- +"@truefoundry/trueforge": patch +--- + +Add `GET /api/v1/artifacts` and `GET /api/v1/artifacts/{slug}` to list and get artifacts. diff --git a/packages/trueforge/scripts/write-openapi.ts b/packages/trueforge/scripts/write-openapi.ts index a2deddf780..94749e6bd9 100644 --- a/packages/trueforge/scripts/write-openapi.ts +++ b/packages/trueforge/scripts/write-openapi.ts @@ -26,6 +26,7 @@ import configuration from '../src/config'; import { McpServerWithAuthStore } from '../src/db/McpServerWithAuthStore'; import { SqliteAccessControlStore } from '../src/db/sqlite/access-control-store/SqliteAccessControlStore'; import { SqliteAgentStore } from '../src/db/sqlite/agent-store/SqliteAgentStore'; +import { SqliteArtifactStore } from '../src/db/sqlite/artifact-store/SqliteArtifactStore'; import { createSqliteDb } from '../src/db/sqlite/client'; import { SqliteConfigurationStore } from '../src/db/sqlite/configuration-store/SqliteConfigurationStore'; import { SqliteMcpServerStore } from '../src/db/sqlite/mcp-server-store/SqliteMcpServerStore'; @@ -107,6 +108,7 @@ const app = createServerApp({ configurationStore, withTransaction: callback => db.transaction().execute(callback), scheduleStore: new SqliteScheduleStore(db), + artifactStore: new SqliteArtifactStore(db), tokenStore, sessionStore, accessControlStore: new SqliteAccessControlStore(db), diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts new file mode 100644 index 0000000000..d743175ed7 --- /dev/null +++ b/packages/trueforge/src/apis/artifacts.ts @@ -0,0 +1,60 @@ +import { OpenAPIHono, type RouteHandler } from '@hono/zod-openapi'; +import { InvalidPageTokenError } from '@truefoundry/trueforge-core/agent-session'; +import { HTTPException } from 'hono/http-exception'; +import type { ResolveRequestContext } from '../auth/identity'; +import type { ArtifactRecord, IArtifactStore } from '../db/artifactStore'; +import { getArtifactRoute, listArtifactsRoute } from '../routes/artifactRoutes'; +import type { Artifact } from '../schemas/artifact'; + +export interface ArtifactsRouterDeps { + artifactStore: IArtifactStore; + resolveRequestContext: ResolveRequestContext; +} + +function toWireArtifact(record: ArtifactRecord): Artifact { + return { + id: record.id, + slug: record.slug, + title: record.title, + latest_version: record.latest_version, + created_by_subject: record.created_by_subject, + created_by_session_id: record.created_by_session_id, + created_at: record.created_at, + updated_at: record.updated_at, + }; +} + +export function createArtifactsRouter(deps: ArtifactsRouterDeps) { + const listHandler: RouteHandler = async c => { + const { limit, page_token } = c.req.valid('query'); + const requestContext = deps.resolveRequestContext(c); + try { + const { data, pagination } = await deps.artifactStore.listArtifacts({ + tenant_id: requestContext.tenant_id, + limit, + page_token, + }); + return c.json({ data: data.map(toWireArtifact), pagination }, 200); + } catch (error) { + if (error instanceof InvalidPageTokenError) { + throw new HTTPException(400, { message: error.message, cause: error }); + } + throw error; + } + }; + + const getHandler: RouteHandler = async c => { + const { slug } = c.req.valid('param'); + const requestContext = deps.resolveRequestContext(c); + const artifact = await deps.artifactStore.getArtifact({ tenant_id: requestContext.tenant_id, slug }); + if (artifact === undefined) { + return c.json({ error: { message: `Artifact not found: ${slug}` } }, 404); + } + return c.json({ data: toWireArtifact(artifact) }, 200); + }; + + const router = new OpenAPIHono(); + router.openapi(listArtifactsRoute, listHandler); + router.openapi(getArtifactRoute, getHandler); + return router; +} diff --git a/packages/trueforge/src/app.ts b/packages/trueforge/src/app.ts index c61daf9849..c3bfa00bcf 100644 --- a/packages/trueforge/src/app.ts +++ b/packages/trueforge/src/app.ts @@ -11,6 +11,7 @@ import { randomUUID } from 'node:crypto'; import type { Configuration } from 'openid-client'; import type { Logger } from 'winston'; import { createAgentsRouter } from './apis/agents'; +import { createArtifactsRouter } from './apis/artifacts'; import { createAuthRouter } from './apis/auth'; import { createCapabilitiesRouter } from './apis/capabilities'; import { createCatalogRouter } from './apis/catalog'; @@ -52,6 +53,7 @@ import type { WebSearchCatalog } from './catalog/WebSearchCatalog'; import configuration, { getPublicUiBasePath, getTrueForgeAuthMode, TrueForgeAuthMode } from './config'; import type { IAccessControlStore } from './db/accessControlStore'; import type { AgentRecord, IAgentStore } from './db/agentStore'; +import type { IArtifactStore } from './db/artifactStore'; import type { IConfigurationStore } from './db/configurationStore'; import type { IMcpServerWithAuthStore } from './db/mcpServerStore'; import type { IMemoryProviderStore } from './db/memoryProviderStore'; @@ -341,6 +343,7 @@ export interface ServerDeps { /** DB singleton, or the env-backed shared store in TrueFoundry mode. */ sandboxProviderStore: ISandboxProviderStore; scheduleStore: IScheduleStore; + artifactStore: IArtifactStore; sessionMetricsStore: ISessionMetricsStore; sessions: Sessions; sessionStore: ISessionStore; @@ -555,6 +558,10 @@ export function createServerApp(deps: ServerDeps) { authMiddleware, ), ); + app.route( + '/api/v1/artifacts', + withAuth(createArtifactsRouter({ artifactStore: deps.artifactStore, resolveRequestContext }), authMiddleware), + ); // Registered before /api/v1/settings: tenant-wide switches are admin-gated in every mode, // while the catalog settings below stay closed in TrueFoundry mode. app.route( diff --git a/packages/trueforge/src/main.ts b/packages/trueforge/src/main.ts index 781474266c..6ed0144647 100644 --- a/packages/trueforge/src/main.ts +++ b/packages/trueforge/src/main.ts @@ -112,6 +112,7 @@ import { createController } from './controller'; import { memoryIngestFromConfig } from './controller/memoryIngest'; import type { IAccessControlStore } from './db/accessControlStore'; import type { IAgentStore } from './db/agentStore'; +import type { IArtifactStore } from './db/artifactStore'; import type { IConfigurationStore } from './db/configurationStore'; import type { IMcpServerWithAuthStore } from './db/mcpServerStore'; import { McpServerWithAuthStore } from './db/McpServerWithAuthStore'; @@ -165,6 +166,7 @@ interface ServerPersistence { accessControlStore: IAccessControlStore; /** extra pre-resolved stores for scheduled runs */ agentStore: IAgentStore; + artifactStore: IArtifactStore; destroyDb: () => Promise; mcpOAuthStore: IMcpServerWithAuthStore; /** Connected Redis (client + mode) for distributed peering; undefined in standalone. */ @@ -291,6 +293,7 @@ async function createStandalonePersistence(options: { import('./db/sqlite/schedule-store/SqliteScheduleStore'), import('./db/sqlite/sandbox-environment-store/SqliteSandboxEnvironmentStore'), import('./db/sqlite/access-control-store/SqliteAccessControlStore'), + import('./db/sqlite/artifact-store/SqliteArtifactStore'), ]), ]); const [ @@ -309,6 +312,7 @@ async function createStandalonePersistence(options: { { SqliteScheduleStore }, { SqliteSandboxEnvironmentStore }, { SqliteAccessControlStore }, + { SqliteArtifactStore }, ] = sqliteStores; const db = createSqliteDb(sqlitePath); @@ -342,6 +346,7 @@ async function createStandalonePersistence(options: { return { accessControlStore: new SqliteAccessControlStore(db), agentStore, + artifactStore: new SqliteArtifactStore(db), destroyDb: () => db.destroy(), mcpOAuthStore: mcpServerStore, redis: undefined, @@ -417,6 +422,7 @@ async function createDistributedPersistence(options: { import('./db/postgres/schedule-store/PostgresScheduleStore'), import('./db/postgres/sandbox-environment-store/PostgresSandboxEnvironmentStore'), import('./db/postgres/access-control-store/PostgresAccessControlStore'), + import('./db/postgres/artifact-store/PostgresArtifactStore'), ]), ]); const [ @@ -434,6 +440,7 @@ async function createDistributedPersistence(options: { { PostgresScheduleStore }, { PostgresSandboxEnvironmentStore }, { PostgresAccessControlStore }, + { PostgresArtifactStore }, ] = postgresStores; logger.info('Connecting to Postgres'); @@ -504,6 +511,7 @@ async function createDistributedPersistence(options: { return { accessControlStore: new PostgresAccessControlStore(db), agentStore, + artifactStore: new PostgresArtifactStore(db), destroyDb: () => db.destroy(), mcpOAuthStore: mcpServerWithAuthStore, redis: await connectRedis({ @@ -547,6 +555,7 @@ async function createServerRuntime(persistence: ServerPersistence< const { accessControlStore, agentStore, + artifactStore, destroyDb, mcpOAuthStore, redis, @@ -649,6 +658,7 @@ async function createServerRuntime(persistence: ServerPersistence< accessControlStore, activeTurns, agentStore, + artifactStore, authenticator, authorizer, eventSubscriptions, diff --git a/packages/trueforge/src/routes/artifactRoutes.ts b/packages/trueforge/src/routes/artifactRoutes.ts new file mode 100644 index 0000000000..110c8b18fe --- /dev/null +++ b/packages/trueforge/src/routes/artifactRoutes.ts @@ -0,0 +1,64 @@ +/** + * Artifact route definitions (mounted at /api/v1/artifacts). + * Handlers are registered in apis/artifacts.ts. + */ +import { createRoute, z } from '@hono/zod-openapi'; +import { + GetArtifactResponseSchema, + ListArtifactsRequestQuerySchema, + ListArtifactsResponseSchema, +} from '../schemas/artifact'; +import { RequestErrorResponseSchema } from '../schemas/errors'; +import { TOKEN_PAGINATION } from './fernExtensions'; +import { OpenApiTag } from './openapiTags'; + +const ArtifactSlugParamsSchema = z.object({ + slug: z.string().min(1).describe('Artifact slug.'), +}); + +export const listArtifactsRoute = createRoute({ + method: 'get', + path: '/', + tags: [OpenApiTag.ARTIFACTS], + summary: 'List artifacts', + description: 'List artifacts for the tenant, newest first.', + 'x-fern-sdk-group-name': ['artifacts'], + 'x-fern-sdk-method-name': 'list', + 'x-fern-pagination': TOKEN_PAGINATION, + request: { + query: ListArtifactsRequestQuerySchema, + }, + responses: { + 200: { + content: { 'application/json': { schema: ListArtifactsResponseSchema } }, + description: 'Paginated artifacts.', + }, + 400: { + content: { 'application/json': { schema: RequestErrorResponseSchema } }, + description: 'Invalid query parameters or page token.', + }, + }, +}); + +export const getArtifactRoute = createRoute({ + method: 'get', + path: '/{slug}', + tags: [OpenApiTag.ARTIFACTS], + summary: 'Get an artifact', + description: 'Get an artifact by slug.', + 'x-fern-sdk-group-name': ['artifacts'], + 'x-fern-sdk-method-name': 'get', + request: { + params: ArtifactSlugParamsSchema, + }, + responses: { + 200: { + content: { 'application/json': { schema: GetArtifactResponseSchema } }, + description: 'The artifact.', + }, + 404: { + content: { 'application/json': { schema: RequestErrorResponseSchema } }, + description: 'Not found.', + }, + }, +}); diff --git a/packages/trueforge/src/routes/openapiTags.ts b/packages/trueforge/src/routes/openapiTags.ts index dcf9790171..0c748d9a55 100644 --- a/packages/trueforge/src/routes/openapiTags.ts +++ b/packages/trueforge/src/routes/openapiTags.ts @@ -14,6 +14,7 @@ export enum OpenApiTag { AGENTS = 'Agents', SCHEDULES = 'Schedules', AGENT_SESSIONS = 'Agent Sessions', + ARTIFACTS = 'Artifacts', } /** Document-level tag order for `/api/v1/docs` and Mintlify. */ @@ -32,4 +33,5 @@ export const OPENAPI_DOCUMENT_TAGS: { name: OpenApiTag }[] = [ { name: OpenApiTag.AGENTS }, { name: OpenApiTag.SCHEDULES }, { name: OpenApiTag.AGENT_SESSIONS }, + { name: OpenApiTag.ARTIFACTS }, ]; diff --git a/packages/trueforge/src/schemas/artifact.ts b/packages/trueforge/src/schemas/artifact.ts new file mode 100644 index 0000000000..dcdd57d346 --- /dev/null +++ b/packages/trueforge/src/schemas/artifact.ts @@ -0,0 +1,41 @@ +import { z } from '@hono/zod-openapi'; +import { SubjectSchema, TokenPaginationSchema } from '@truefoundry/trueforge-core/agent-session'; +import { PAGE_LIMIT } from './common'; + +export const ArtifactSchema = z + .object({ + id: z.string(), + slug: z.string(), + title: z.string(), + latest_version: z.number().int().describe('Highest committed version; 0 before the first commit.'), + created_by_subject: SubjectSchema, + created_by_session_id: z.string(), + created_at: z.iso.datetime(), + updated_at: z.iso.datetime(), + }) + .strict() + .openapi('Artifact'); + +export type Artifact = z.infer; + +export const ListArtifactsRequestQuerySchema = z + .object({ + limit: z.coerce + .number() + .int() + .min(1) + .max(PAGE_LIMIT) + .optional() + .default(PAGE_LIMIT) + .describe(`Page size. Defaults to ${String(PAGE_LIMIT)}`), + page_token: z.string().optional().describe('Opaque token from a previous response `next_page_token`.'), + }) + .openapi('ListArtifactsRequestQuery'); + +export const GetArtifactResponseSchema = z.object({ data: ArtifactSchema }).openapi('GetArtifactResponse'); +export const ListArtifactsResponseSchema = z + .object({ + data: z.array(ArtifactSchema), + pagination: TokenPaginationSchema, + }) + .openapi('ListArtifactsResponse'); diff --git a/packages/trueforge/tests/unit/apis/artifacts.test.ts b/packages/trueforge/tests/unit/apis/artifacts.test.ts new file mode 100644 index 0000000000..5b028e2fe4 --- /dev/null +++ b/packages/trueforge/tests/unit/apis/artifacts.test.ts @@ -0,0 +1,52 @@ +import { createArtifactsRouter } from '../../../src/apis/artifacts'; +import { createdBySubjectFromRequestContext, STANDALONE_REQUEST_CONTEXT } from '../../../src/auth/identity'; +import { migrateSqliteToLatest } from '../../../src/db/migrateSqlite'; +import { SqliteArtifactStore } from '../../../src/db/sqlite/artifact-store/SqliteArtifactStore'; +import { createSqliteDb } from '../../../src/db/sqlite/client'; +import { GetArtifactResponseSchema, ListArtifactsResponseSchema } from '../../../src/schemas/artifact'; +import { mountWithErrorHandler } from '../mountWithErrorHandler'; + +describe('artifacts router', () => { + let app: ReturnType; + + beforeAll(async () => { + const db = createSqliteDb(':memory:'); + await migrateSqliteToLatest(db); + const artifactStore = new SqliteArtifactStore(db); + for (const slug of ['a', 'b']) { + await artifactStore.createArtifact({ + tenant_id: STANDALONE_REQUEST_CONTEXT.tenant_id, + slug, + title: slug, + created_by_subject: createdBySubjectFromRequestContext(STANDALONE_REQUEST_CONTEXT), + created_by_session_id: 'session-1', + }); + } + app = mountWithErrorHandler( + createArtifactsRouter({ artifactStore, resolveRequestContext: () => STANDALONE_REQUEST_CONTEXT }), + ); + }); + + it('lists artifacts with pagination', async () => { + const first = ListArtifactsResponseSchema.parse(await (await app.request('/?limit=1')).json()); + expect(first.data).toHaveLength(1); + const second = ListArtifactsResponseSchema.parse( + await (await app.request(`/?limit=1&page_token=${first.pagination.next_page_token ?? ''}`)).json(), + ); + expect([...first.data, ...second.data].map(a => a.slug).sort()).toEqual(['a', 'b']); + }); + + it('rejects an invalid page token', async () => { + expect((await app.request('/?page_token=not-a-token')).status).toBe(400); + }); + + it('gets an artifact by slug', async () => { + const response = await app.request('/a'); + expect(response.status).toBe(200); + expect(GetArtifactResponseSchema.parse(await response.json()).data.slug).toBe('a'); + }); + + it('returns 404 for an unknown slug', async () => { + expect((await app.request('/missing')).status).toBe(404); + }); +}); From 5045a1e585a39ff92e422d3cb667c7f50fdc25e6 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Thu, 19 Nov 2026 21:19:32 +0530 Subject: [PATCH 02/12] [AGE-2886] Restrict artifact APIs to the creator Co-authored-by: Cursor --- packages/trueforge/src/apis/artifacts.ts | 4 +++- packages/trueforge/src/routes/artifactRoutes.ts | 12 ++++++++++-- .../trueforge/tests/unit/apis/artifacts.test.ts | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index d743175ed7..9e53b72af8 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -31,6 +31,7 @@ export function createArtifactsRouter(deps: ArtifactsRouterDeps(deps: ArtifactsRouterDeps { created_by_session_id: 'session-1', }); } + await artifactStore.createArtifact({ + tenant_id: STANDALONE_REQUEST_CONTEXT.tenant_id, + slug: 'not-mine', + title: 'not mine', + created_by_subject: { + ...createdBySubjectFromRequestContext(STANDALONE_REQUEST_CONTEXT), + subject_id: 'someone-else', + }, + created_by_session_id: 'session-2', + }); app = mountWithErrorHandler( createArtifactsRouter({ artifactStore, resolveRequestContext: () => STANDALONE_REQUEST_CONTEXT }), ); }); - it('lists artifacts with pagination', async () => { + it("lists only the caller's artifacts with pagination", async () => { const first = ListArtifactsResponseSchema.parse(await (await app.request('/?limit=1')).json()); expect(first.data).toHaveLength(1); const second = ListArtifactsResponseSchema.parse( @@ -46,7 +56,7 @@ describe('artifacts router', () => { expect(GetArtifactResponseSchema.parse(await response.json()).data.slug).toBe('a'); }); - it('returns 404 for an unknown slug', async () => { - expect((await app.request('/missing')).status).toBe(404); + it.each(['missing', 'not-mine'])('returns 404 for %s', async slug => { + expect((await app.request(`/${slug}`)).status).toBe(404); }); }); From e11396fb7ea4f0db78438859130a3c9c5caec4ab Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:41:52 +0530 Subject: [PATCH 03/12] Regenerate OpenAPI document and SDKs Co-authored-by: Cursor --- .github/fern/openapi/openapi.json | 208 +++++++++++ docs/openapi.json | 208 +++++++++++ packages/trueforge-sdk/package.json | 11 + packages/trueforge-sdk/reference.md | 139 +++++++ packages/trueforge-sdk/src/Client.ts | 6 + .../api/resources/artifacts/client/Client.ts | 232 ++++++++++++ .../api/resources/artifacts/client/index.ts | 1 + .../client/requests/ListArtifactsRequest.ts | 12 + .../artifacts/client/requests/index.ts | 1 + .../src/api/resources/artifacts/exports.ts | 4 + .../src/api/resources/artifacts/index.ts | 1 + .../trueforge-sdk/src/api/resources/index.ts | 2 + .../trueforge-sdk/src/api/types/Artifact.ts | 15 + .../src/api/types/GetArtifactResponse.ts | 7 + .../src/api/types/ListArtifactsResponse.ts | 8 + packages/trueforge-sdk/src/api/types/index.ts | 3 + .../src/serialization/types/Artifact.ts | 31 ++ .../types/GetArtifactResponse.ts | 19 + .../types/ListArtifactsResponse.ts | 22 ++ .../src/serialization/types/index.ts | 3 + .../tests/wire/artifacts.test.ts | 182 ++++++++++ python/trueforge_sdk/reference.md | 151 ++++++++ .../src/trueforge_sdk/__init__.py | 12 + .../src/trueforge_sdk/artifacts/__init__.py | 4 + .../src/trueforge_sdk/artifacts/client.py | 210 +++++++++++ .../src/trueforge_sdk/artifacts/raw_client.py | 338 ++++++++++++++++++ .../src/trueforge_sdk/base_client.py | 19 + .../src/trueforge_sdk/types/__init__.py | 9 + .../src/trueforge_sdk/types/artifact.py | 32 ++ .../types/get_artifact_response.py | 20 ++ .../types/list_artifacts_response.py | 22 ++ 31 files changed, 1932 insertions(+) create mode 100644 packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts create mode 100644 packages/trueforge-sdk/src/api/resources/artifacts/client/index.ts create mode 100644 packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts create mode 100644 packages/trueforge-sdk/src/api/resources/artifacts/client/requests/index.ts create mode 100644 packages/trueforge-sdk/src/api/resources/artifacts/exports.ts create mode 100644 packages/trueforge-sdk/src/api/resources/artifacts/index.ts create mode 100644 packages/trueforge-sdk/src/api/types/Artifact.ts create mode 100644 packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts create mode 100644 packages/trueforge-sdk/src/api/types/ListArtifactsResponse.ts create mode 100644 packages/trueforge-sdk/src/serialization/types/Artifact.ts create mode 100644 packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts create mode 100644 packages/trueforge-sdk/src/serialization/types/ListArtifactsResponse.ts create mode 100644 packages/trueforge-sdk/tests/wire/artifacts.test.ts create mode 100644 python/trueforge_sdk/src/trueforge_sdk/artifacts/__init__.py create mode 100644 python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py create mode 100644 python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py create mode 100644 python/trueforge_sdk/src/trueforge_sdk/types/artifact.py create mode 100644 python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py create mode 100644 python/trueforge_sdk/src/trueforge_sdk/types/list_artifacts_response.py diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json index d325015bad..bb1623a62f 100644 --- a/.github/fern/openapi/openapi.json +++ b/.github/fern/openapi/openapi.json @@ -331,6 +331,49 @@ ], "type": "object" }, + "Artifact": { + "additionalProperties": false, + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "created_by_session_id": { + "type": "string" + }, + "created_by_subject": { + "$ref": "#/components/schemas/Subject" + }, + "id": { + "type": "string" + }, + "latest_version": { + "description": "Highest committed version; 0 before the first commit.", + "type": "integer" + }, + "slug": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "slug", + "title", + "latest_version", + "created_by_subject", + "created_by_session_id", + "created_at", + "updated_at" + ], + "type": "object" + }, "AskUserQuestionsConfig": { "default": { "enabled": true @@ -1606,6 +1649,17 @@ ], "type": "object" }, + "GetArtifactResponse": { + "properties": { + "data": { + "$ref": "#/components/schemas/Artifact" + } + }, + "required": [ + "data" + ], + "type": "object" + }, "GetAvailableMCPServerResponse": { "properties": { "data": { @@ -2145,6 +2199,24 @@ ], "type": "object" }, + "ListArtifactsResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/Artifact" + }, + "type": "array" + }, + "pagination": { + "$ref": "#/components/schemas/TokenPagination" + } + }, + "required": [ + "data", + "pagination" + ], + "type": "object" + }, "ListAvailableMCPServersResponse": { "properties": { "data": { @@ -7988,6 +8060,139 @@ "x-fern-sdk-method-name": "get_code_snippets" } }, + "/api/v1/artifacts": { + "get": { + "description": "List artifacts created by the caller, most recently updated first.", + "parameters": [ + { + "description": "Page size. Defaults to 25", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "default": 25, + "description": "Page size. Defaults to 25", + "maximum": 25, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Opaque token from a previous response `next_page_token`.", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "description": "Opaque token from a previous response `next_page_token`.", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListArtifactsResponse" + } + } + }, + "description": "Paginated artifacts." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Invalid query parameters or page token." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Unauthenticated." + } + }, + "summary": "List artifacts", + "tags": [ + "Artifacts" + ], + "x-fern-pagination": { + "cursor": "$request.page_token", + "next_cursor": "$response.pagination.next_page_token", + "results": "$response.data" + }, + "x-fern-sdk-group-name": [ + "artifacts" + ], + "x-fern-sdk-method-name": "list" + } + }, + "/api/v1/artifacts/{slug}": { + "get": { + "description": "Get an artifact created by the caller, by slug.", + "parameters": [ + { + "description": "Artifact slug.", + "in": "path", + "name": "slug", + "required": true, + "schema": { + "description": "Artifact slug.", + "minLength": 1, + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetArtifactResponse" + } + } + }, + "description": "The artifact." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Unauthenticated." + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Not found." + } + }, + "summary": "Get an artifact", + "tags": [ + "Artifacts" + ], + "x-fern-sdk-group-name": [ + "artifacts" + ], + "x-fern-sdk-method-name": "get" + } + }, "/api/v1/auth/callback": { "get": { "description": "Browser-redirect target hit by the identity provider after login, never called directly by SDK consumers. In local/single-binary mode, redirects straight back into the app.", @@ -12967,6 +13172,9 @@ }, { "name": "Agent Sessions" + }, + { + "name": "Artifacts" } ], "webhooks": {} diff --git a/docs/openapi.json b/docs/openapi.json index d325015bad..bb1623a62f 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -331,6 +331,49 @@ ], "type": "object" }, + "Artifact": { + "additionalProperties": false, + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "created_by_session_id": { + "type": "string" + }, + "created_by_subject": { + "$ref": "#/components/schemas/Subject" + }, + "id": { + "type": "string" + }, + "latest_version": { + "description": "Highest committed version; 0 before the first commit.", + "type": "integer" + }, + "slug": { + "type": "string" + }, + "title": { + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "slug", + "title", + "latest_version", + "created_by_subject", + "created_by_session_id", + "created_at", + "updated_at" + ], + "type": "object" + }, "AskUserQuestionsConfig": { "default": { "enabled": true @@ -1606,6 +1649,17 @@ ], "type": "object" }, + "GetArtifactResponse": { + "properties": { + "data": { + "$ref": "#/components/schemas/Artifact" + } + }, + "required": [ + "data" + ], + "type": "object" + }, "GetAvailableMCPServerResponse": { "properties": { "data": { @@ -2145,6 +2199,24 @@ ], "type": "object" }, + "ListArtifactsResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/Artifact" + }, + "type": "array" + }, + "pagination": { + "$ref": "#/components/schemas/TokenPagination" + } + }, + "required": [ + "data", + "pagination" + ], + "type": "object" + }, "ListAvailableMCPServersResponse": { "properties": { "data": { @@ -7988,6 +8060,139 @@ "x-fern-sdk-method-name": "get_code_snippets" } }, + "/api/v1/artifacts": { + "get": { + "description": "List artifacts created by the caller, most recently updated first.", + "parameters": [ + { + "description": "Page size. Defaults to 25", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "default": 25, + "description": "Page size. Defaults to 25", + "maximum": 25, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Opaque token from a previous response `next_page_token`.", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "description": "Opaque token from a previous response `next_page_token`.", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListArtifactsResponse" + } + } + }, + "description": "Paginated artifacts." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Invalid query parameters or page token." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Unauthenticated." + } + }, + "summary": "List artifacts", + "tags": [ + "Artifacts" + ], + "x-fern-pagination": { + "cursor": "$request.page_token", + "next_cursor": "$response.pagination.next_page_token", + "results": "$response.data" + }, + "x-fern-sdk-group-name": [ + "artifacts" + ], + "x-fern-sdk-method-name": "list" + } + }, + "/api/v1/artifacts/{slug}": { + "get": { + "description": "Get an artifact created by the caller, by slug.", + "parameters": [ + { + "description": "Artifact slug.", + "in": "path", + "name": "slug", + "required": true, + "schema": { + "description": "Artifact slug.", + "minLength": 1, + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetArtifactResponse" + } + } + }, + "description": "The artifact." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Unauthenticated." + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestErrorResponse" + } + } + }, + "description": "Not found." + } + }, + "summary": "Get an artifact", + "tags": [ + "Artifacts" + ], + "x-fern-sdk-group-name": [ + "artifacts" + ], + "x-fern-sdk-method-name": "get" + } + }, "/api/v1/auth/callback": { "get": { "description": "Browser-redirect target hit by the identity provider after login, never called directly by SDK consumers. In local/single-binary mode, redirects straight back into the app.", @@ -12967,6 +13172,9 @@ }, { "name": "Agent Sessions" + }, + { + "name": "Artifacts" } ], "webhooks": {} diff --git a/packages/trueforge-sdk/package.json b/packages/trueforge-sdk/package.json index 9c1d86994e..187e481838 100644 --- a/packages/trueforge-sdk/package.json +++ b/packages/trueforge-sdk/package.json @@ -55,6 +55,17 @@ }, "default": "./dist/esm/api/resources/agents/exports.mjs" }, + "./artifacts": { + "import": { + "types": "./dist/esm/api/resources/artifacts/exports.d.mts", + "default": "./dist/esm/api/resources/artifacts/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/artifacts/exports.d.ts", + "default": "./dist/cjs/api/resources/artifacts/exports.js" + }, + "default": "./dist/esm/api/resources/artifacts/exports.mjs" + }, "./auth": { "import": { "types": "./dist/esm/api/resources/auth/exports.d.mts", diff --git a/packages/trueforge-sdk/reference.md b/packages/trueforge-sdk/reference.md index 35b06f4f1e..45056873f6 100644 --- a/packages/trueforge-sdk/reference.md +++ b/packages/trueforge-sdk/reference.md @@ -412,6 +412,145 @@ await client.agents.delete("agent_id"); + + + + +## Artifacts +
client.artifacts.list({ ...params }) -> core.Page<TrueForge.Artifact, TrueForge.ListArtifactsResponse> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List artifacts created by the caller, most recently updated first. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +const pageableResponse = await client.artifacts.list(); +for await (const item of pageableResponse) { + console.log(item); +} + +// Or you can manually iterate page-by-page +let page = await client.artifacts.list(); +while (page.hasNextPage()) { + page = await page.getNextPage(); +} + +// You can also access the underlying response +const response = page.response; + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `TrueForge.ListArtifactsRequest` + +
+
+ +
+
+ +**requestOptions:** `ArtifactsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.artifacts.get(slug) -> TrueForge.GetArtifactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get an artifact created by the caller, by slug. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.artifacts.get("slug"); + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**slug:** `string` — Artifact slug. + +
+
+ +
+
+ +**requestOptions:** `ArtifactsClient.RequestOptions` + +
+
+
+
+ +
diff --git a/packages/trueforge-sdk/src/Client.ts b/packages/trueforge-sdk/src/Client.ts index 839dab1841..c3a05edef4 100644 --- a/packages/trueforge-sdk/src/Client.ts +++ b/packages/trueforge-sdk/src/Client.ts @@ -1,6 +1,7 @@ // This file was auto-generated by Fern from our API Definition. import { AgentsClient } from "./api/resources/agents/client/Client.js"; +import { ArtifactsClient } from "./api/resources/artifacts/client/Client.js"; import { AuthClient } from "./api/resources/auth/client/Client.js"; import { CatalogsClient } from "./api/resources/catalogs/client/Client.js"; import { InternalClient } from "./api/resources/internal/client/Client.js"; @@ -27,6 +28,7 @@ export class TrueForge { protected readonly _options: NormalizedClientOptionsWithAuth; protected _internal: InternalClient | undefined; protected _agents: AgentsClient | undefined; + protected _artifacts: ArtifactsClient | undefined; protected _auth: AuthClient | undefined; protected _server: ServerClient | undefined; protected _mcpServers: McpServersClient | undefined; @@ -51,6 +53,10 @@ export class TrueForge { return (this._agents ??= new AgentsClient(this._options)); } + public get artifacts(): ArtifactsClient { + return (this._artifacts ??= new ArtifactsClient(this._options)); + } + public get auth(): AuthClient { return (this._auth ??= new AuthClient(this._options)); } diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts new file mode 100644 index 0000000000..7b771be434 --- /dev/null +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts @@ -0,0 +1,232 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as serializers from "../../../../serialization/index.js"; +import * as TrueForge from "../../../index.js"; + +export declare namespace ArtifactsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class ArtifactsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ArtifactsClient.Options) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * List artifacts created by the caller, most recently updated first. + * + * @param {TrueForge.ListArtifactsRequest} request + * @param {ArtifactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link TrueForge.BadRequestError} + * @throws {@link TrueForge.UnauthorizedError} + * @throws {@link errors.TrueForgeError} + * @throws {@link errors.TrueForgeTimeoutError} + * + * @example + * await client.artifacts.list() + */ + public async list( + request: TrueForge.ListArtifactsRequest = {}, + requestOptions?: ArtifactsClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: TrueForge.ListArtifactsRequest, + ): Promise> => { + const { limit = 25, pageToken } = request; + const _queryParams: Record = { + limit, + page_token: pageToken, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)), + "api/v1/artifacts", + ), + method: "GET", + headers: _headers, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.ListArtifactsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new TrueForge.BadRequestError( + serializers.RequestErrorResponse.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + _response.rawResponse, + ); + case 401: + throw new TrueForge.UnauthorizedError( + serializers.RequestErrorResponse.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + _response.rawResponse, + ); + default: + throw new errors.TrueForgeError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/v1/artifacts"); + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => + response?.pagination.nextPageToken != null && + !(typeof response?.pagination.nextPageToken === "string" && response?.pagination.nextPageToken === ""), + getItems: (response) => response?.data ?? [], + loadPage: (response) => { + return list(core.setObjectProperty(request, "pageToken", response?.pagination.nextPageToken)); + }, + }); + } + + /** + * Get an artifact created by the caller, by slug. + * + * @param {string} slug - Artifact slug. + * @param {ArtifactsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link TrueForge.UnauthorizedError} + * @throws {@link TrueForge.NotFoundError} + * @throws {@link errors.TrueForgeError} + * @throws {@link errors.TrueForgeTimeoutError} + * + * @example + * await client.artifacts.get("slug") + */ + public get( + slug: string, + requestOptions?: ArtifactsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(slug, requestOptions)); + } + + private async __get( + slug: string, + requestOptions?: ArtifactsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)), + `api/v1/artifacts/${core.url.encodePathParam(slug, errors.TrueForgeError)}`, + ), + method: "GET", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.GetArtifactResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new TrueForge.UnauthorizedError( + serializers.RequestErrorResponse.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + _response.rawResponse, + ); + case 404: + throw new TrueForge.NotFoundError( + serializers.RequestErrorResponse.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + _response.rawResponse, + ); + default: + throw new errors.TrueForgeError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/v1/artifacts/{slug}"); + } +} diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/index.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/index.ts new file mode 100644 index 0000000000..195f9aa8a8 --- /dev/null +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts new file mode 100644 index 0000000000..edb251d5e7 --- /dev/null +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface ListArtifactsRequest { + /** Page size. Defaults to 25 */ + limit?: number; + /** Opaque token from a previous response `next_page_token`. */ + pageToken?: string; +} diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/index.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/index.ts new file mode 100644 index 0000000000..a83a129a26 --- /dev/null +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/index.ts @@ -0,0 +1 @@ +export type { ListArtifactsRequest } from "./ListArtifactsRequest.js"; diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/exports.ts b/packages/trueforge-sdk/src/api/resources/artifacts/exports.ts new file mode 100644 index 0000000000..8fe5f4af68 --- /dev/null +++ b/packages/trueforge-sdk/src/api/resources/artifacts/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { ArtifactsClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/index.ts b/packages/trueforge-sdk/src/api/resources/artifacts/index.ts new file mode 100644 index 0000000000..914b8c3c72 --- /dev/null +++ b/packages/trueforge-sdk/src/api/resources/artifacts/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/packages/trueforge-sdk/src/api/resources/index.ts b/packages/trueforge-sdk/src/api/resources/index.ts index 8d86eb8ec8..11fd9df2e1 100644 --- a/packages/trueforge-sdk/src/api/resources/index.ts +++ b/packages/trueforge-sdk/src/api/resources/index.ts @@ -1,5 +1,7 @@ export * from "./agents/client/requests/index.js"; export * as agents from "./agents/index.js"; +export * from "./artifacts/client/requests/index.js"; +export * as artifacts from "./artifacts/index.js"; export * as auth from "./auth/index.js"; export * as catalogs from "./catalogs/index.js"; export * from "./internal/client/requests/index.js"; diff --git a/packages/trueforge-sdk/src/api/types/Artifact.ts b/packages/trueforge-sdk/src/api/types/Artifact.ts new file mode 100644 index 0000000000..0cef10dd4d --- /dev/null +++ b/packages/trueforge-sdk/src/api/types/Artifact.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../index.js"; + +export interface Artifact { + createdAt: Date; + createdBySessionId: string; + createdBySubject: TrueForge.Subject; + id: string; + /** Highest committed version; 0 before the first commit. */ + latestVersion: number; + slug: string; + title: string; + updatedAt: Date; +} diff --git a/packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts b/packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts new file mode 100644 index 0000000000..8a2fd7c658 --- /dev/null +++ b/packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts @@ -0,0 +1,7 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../index.js"; + +export interface GetArtifactResponse { + data: TrueForge.Artifact; +} diff --git a/packages/trueforge-sdk/src/api/types/ListArtifactsResponse.ts b/packages/trueforge-sdk/src/api/types/ListArtifactsResponse.ts new file mode 100644 index 0000000000..f1a1d73d69 --- /dev/null +++ b/packages/trueforge-sdk/src/api/types/ListArtifactsResponse.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../index.js"; + +export interface ListArtifactsResponse { + data: TrueForge.Artifact[]; + pagination: TrueForge.TokenPagination; +} diff --git a/packages/trueforge-sdk/src/api/types/index.ts b/packages/trueforge-sdk/src/api/types/index.ts index 846a4b5f26..902a8cf1c8 100644 --- a/packages/trueforge-sdk/src/api/types/index.ts +++ b/packages/trueforge-sdk/src/api/types/index.ts @@ -11,6 +11,7 @@ export * from "./AnthropicModelProvider.js"; export * from "./ApprovalAllow.js"; export * from "./ApprovalDecision.js"; export * from "./ApprovalDeny.js"; +export * from "./Artifact.js"; export * from "./AskUserQuestionsConfig.js"; export * from "./AvailableMcpServer.js"; export * from "./AvailableModel.js"; @@ -72,6 +73,7 @@ export * from "./FireworksModelProvider.js"; export * from "./GenerativeUiConfig.js"; export * from "./GetAgentCodeSnippetsResponse.js"; export * from "./GetAgentResponse.js"; +export * from "./GetArtifactResponse.js"; export * from "./GetAvailableMcpServerResponse.js"; export * from "./GetCapabilitiesResponse.js"; export * from "./GetConfigurationResponse.js"; @@ -103,6 +105,7 @@ export * from "./InputTokensCompactionTrigger.js"; export * from "./LargeToolResponseConfig.js"; export * from "./LegacyTurnInputItem.js"; export * from "./ListAgentsResponse.js"; +export * from "./ListArtifactsResponse.js"; export * from "./ListAvailableMcpServersResponse.js"; export * from "./ListAvailableModelsResponse.js"; export * from "./ListAvailableSkillsResponse.js"; diff --git a/packages/trueforge-sdk/src/serialization/types/Artifact.ts b/packages/trueforge-sdk/src/serialization/types/Artifact.ts new file mode 100644 index 0000000000..bb83afe7ee --- /dev/null +++ b/packages/trueforge-sdk/src/serialization/types/Artifact.ts @@ -0,0 +1,31 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { Subject } from "./Subject.js"; + +export const Artifact: core.serialization.ObjectSchema = + core.serialization.object({ + createdAt: core.serialization.property("created_at", core.serialization.date()), + createdBySessionId: core.serialization.property("created_by_session_id", core.serialization.string()), + createdBySubject: core.serialization.property("created_by_subject", Subject), + id: core.serialization.string(), + latestVersion: core.serialization.property("latest_version", core.serialization.number()), + slug: core.serialization.string(), + title: core.serialization.string(), + updatedAt: core.serialization.property("updated_at", core.serialization.date()), + }); + +export declare namespace Artifact { + export interface Raw { + created_at: string; + created_by_session_id: string; + created_by_subject: Subject.Raw; + id: string; + latest_version: number; + slug: string; + title: string; + updated_at: string; + } +} diff --git a/packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts b/packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts new file mode 100644 index 0000000000..fd8f83823c --- /dev/null +++ b/packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts @@ -0,0 +1,19 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { Artifact } from "./Artifact.js"; + +export const GetArtifactResponse: core.serialization.ObjectSchema< + serializers.GetArtifactResponse.Raw, + TrueForge.GetArtifactResponse +> = core.serialization.object({ + data: Artifact, +}); + +export declare namespace GetArtifactResponse { + export interface Raw { + data: Artifact.Raw; + } +} diff --git a/packages/trueforge-sdk/src/serialization/types/ListArtifactsResponse.ts b/packages/trueforge-sdk/src/serialization/types/ListArtifactsResponse.ts new file mode 100644 index 0000000000..6f964c15e0 --- /dev/null +++ b/packages/trueforge-sdk/src/serialization/types/ListArtifactsResponse.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as TrueForge from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { Artifact } from "./Artifact.js"; +import { TokenPagination } from "./TokenPagination.js"; + +export const ListArtifactsResponse: core.serialization.ObjectSchema< + serializers.ListArtifactsResponse.Raw, + TrueForge.ListArtifactsResponse +> = core.serialization.object({ + data: core.serialization.list(Artifact), + pagination: TokenPagination, +}); + +export declare namespace ListArtifactsResponse { + export interface Raw { + data: Artifact.Raw[]; + pagination: TokenPagination.Raw; + } +} diff --git a/packages/trueforge-sdk/src/serialization/types/index.ts b/packages/trueforge-sdk/src/serialization/types/index.ts index 846a4b5f26..902a8cf1c8 100644 --- a/packages/trueforge-sdk/src/serialization/types/index.ts +++ b/packages/trueforge-sdk/src/serialization/types/index.ts @@ -11,6 +11,7 @@ export * from "./AnthropicModelProvider.js"; export * from "./ApprovalAllow.js"; export * from "./ApprovalDecision.js"; export * from "./ApprovalDeny.js"; +export * from "./Artifact.js"; export * from "./AskUserQuestionsConfig.js"; export * from "./AvailableMcpServer.js"; export * from "./AvailableModel.js"; @@ -72,6 +73,7 @@ export * from "./FireworksModelProvider.js"; export * from "./GenerativeUiConfig.js"; export * from "./GetAgentCodeSnippetsResponse.js"; export * from "./GetAgentResponse.js"; +export * from "./GetArtifactResponse.js"; export * from "./GetAvailableMcpServerResponse.js"; export * from "./GetCapabilitiesResponse.js"; export * from "./GetConfigurationResponse.js"; @@ -103,6 +105,7 @@ export * from "./InputTokensCompactionTrigger.js"; export * from "./LargeToolResponseConfig.js"; export * from "./LegacyTurnInputItem.js"; export * from "./ListAgentsResponse.js"; +export * from "./ListArtifactsResponse.js"; export * from "./ListAvailableMcpServersResponse.js"; export * from "./ListAvailableModelsResponse.js"; export * from "./ListAvailableSkillsResponse.js"; diff --git a/packages/trueforge-sdk/tests/wire/artifacts.test.ts b/packages/trueforge-sdk/tests/wire/artifacts.test.ts new file mode 100644 index 0000000000..99018d6db4 --- /dev/null +++ b/packages/trueforge-sdk/tests/wire/artifacts.test.ts @@ -0,0 +1,182 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as TrueForgeTypes from "../../src/api/index"; +import { TrueForge } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; + +describe("ArtifactsClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); + + const rawResponseBody = { + data: [ + { + created_at: "2024-01-15T09:30:00Z", + created_by_session_id: "created_by_session_id", + created_by_subject: { + subject_display_name: "subject_display_name", + subject_id: "subject_id", + subject_type: "subject_type", + }, + id: "id", + latest_version: 1, + slug: "slug", + title: "title", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + pagination: { limit: 1, next_page_token: "next_page_token", previous_page_token: "previous_page_token" }, + }; + + server + .mockEndpoint({ once: false }) + .get("/api/v1/artifacts") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = { + data: [ + { + createdAt: new Date("2024-01-15T09:30:00.000Z"), + createdBySessionId: "created_by_session_id", + createdBySubject: { + subjectDisplayName: "subject_display_name", + subjectId: "subject_id", + subjectType: "subject_type", + }, + id: "id", + latestVersion: 1, + slug: "slug", + title: "title", + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + pagination: { + limit: 1, + nextPageToken: "next_page_token", + previousPageToken: "previous_page_token", + }, + }; + const page = await client.artifacts.list(); + + expect(expected.data).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.data).toEqual(nextPage.data); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); + + const rawResponseBody = { error: { message: "message" } }; + + server.mockEndpoint().get("/api/v1/artifacts").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.artifacts.list(); + }).rejects.toThrow(TrueForgeTypes.BadRequestError); + }); + + test("list (3)", async () => { + const server = mockServerPool.createServer(); + const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); + + const rawResponseBody = { error: { message: "message" } }; + + server.mockEndpoint().get("/api/v1/artifacts").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.artifacts.list(); + }).rejects.toThrow(TrueForgeTypes.UnauthorizedError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); + + const rawResponseBody = { + data: { + created_at: "2024-01-15T09:30:00Z", + created_by_session_id: "created_by_session_id", + created_by_subject: { + subject_display_name: "subject_display_name", + subject_id: "subject_id", + subject_type: "subject_type", + }, + id: "id", + latest_version: 1, + slug: "slug", + title: "title", + updated_at: "2024-01-15T09:30:00Z", + }, + }; + + server + .mockEndpoint() + .get("/api/v1/artifacts/slug") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.artifacts.get("slug"); + expect(response).toEqual({ + data: { + createdAt: new Date("2024-01-15T09:30:00.000Z"), + createdBySessionId: "created_by_session_id", + createdBySubject: { + subjectDisplayName: "subject_display_name", + subjectId: "subject_id", + subjectType: "subject_type", + }, + id: "id", + latestVersion: 1, + slug: "slug", + title: "title", + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); + + const rawResponseBody = { error: { message: "message" } }; + + server + .mockEndpoint() + .get("/api/v1/artifacts/slug") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.artifacts.get("slug"); + }).rejects.toThrow(TrueForgeTypes.UnauthorizedError); + }); + + test("get (3)", async () => { + const server = mockServerPool.createServer(); + const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); + + const rawResponseBody = { error: { message: "message" } }; + + server + .mockEndpoint() + .get("/api/v1/artifacts/slug") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.artifacts.get("slug"); + }).rejects.toThrow(TrueForgeTypes.NotFoundError); + }); +}); diff --git a/python/trueforge_sdk/reference.md b/python/trueforge_sdk/reference.md index 20a21a712b..423b2cea25 100644 --- a/python/trueforge_sdk/reference.md +++ b/python/trueforge_sdk/reference.md @@ -497,6 +497,157 @@ client.agents.delete( + + + + +## Artifacts +
client.artifacts.list(...) -> ListArtifactsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List artifacts created by the caller, most recently updated first. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from trueforge_sdk import TrueForge + +client = TrueForge( + token="", + base_url="https://yourhost.com/path/to/api", +) + +client.artifacts.list() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page size. Defaults to 25 + +
+
+ +
+
+ +**page_token:** `typing.Optional[str]` — Opaque token from a previous response `next_page_token`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.artifacts.get(...) -> GetArtifactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get an artifact created by the caller, by slug. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from trueforge_sdk import TrueForge + +client = TrueForge( + token="", + base_url="https://yourhost.com/path/to/api", +) + +client.artifacts.get( + slug="slug", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**slug:** `str` — Artifact slug. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/python/trueforge_sdk/src/trueforge_sdk/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/__init__.py index 9366c3bfe4..1efdcc2dad 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/__init__.py +++ b/python/trueforge_sdk/src/trueforge_sdk/__init__.py @@ -20,6 +20,7 @@ ApprovalAllow, ApprovalDecision, ApprovalDeny, + Artifact, AskUserQuestionsConfig, AvailableMcpServer, AvailableModel, @@ -81,6 +82,7 @@ GenerativeUiConfig, GetAgentCodeSnippetsResponse, GetAgentResponse, + GetArtifactResponse, GetAvailableMcpServerResponse, GetCapabilitiesResponse, GetConfigurationResponse, @@ -112,6 +114,7 @@ LargeToolResponseConfig, LegacyTurnInputItem, ListAgentsResponse, + ListArtifactsResponse, ListAvailableMcpServersResponse, ListAvailableModelsResponse, ListAvailableSkillsResponse, @@ -322,6 +325,7 @@ ) from . import ( agents, + artifacts, auth, catalogs, internal, @@ -353,6 +357,7 @@ "ApprovalAllow": ".types", "ApprovalDecision": ".types", "ApprovalDeny": ".types", + "Artifact": ".types", "AskUserQuestionsConfig": ".types", "AsyncTrueForge": ".client", "AvailableMcpServer": ".types", @@ -425,6 +430,7 @@ "GenerativeUiConfig": ".types", "GetAgentCodeSnippetsResponse": ".types", "GetAgentResponse": ".types", + "GetArtifactResponse": ".types", "GetAvailableMcpServerResponse": ".types", "GetCapabilitiesResponse": ".types", "GetConfigurationResponse": ".types", @@ -458,6 +464,7 @@ "LargeToolResponseConfig": ".types", "LegacyTurnInputItem": ".types", "ListAgentsResponse": ".types", + "ListArtifactsResponse": ".types", "ListAvailableMcpServersResponse": ".types", "ListAvailableModelsResponse": ".types", "ListAvailableSkillsResponse": ".types", @@ -658,6 +665,7 @@ "ZepMemoryProviderAuth": ".types", "__version__": ".version", "agents": ".agents", + "artifacts": ".artifacts", "auth": ".auth", "catalogs": ".catalogs", "internal": ".internal", @@ -708,6 +716,7 @@ def __dir__(): "ApprovalAllow", "ApprovalDecision", "ApprovalDeny", + "Artifact", "AskUserQuestionsConfig", "AsyncTrueForge", "AvailableMcpServer", @@ -780,6 +789,7 @@ def __dir__(): "GenerativeUiConfig", "GetAgentCodeSnippetsResponse", "GetAgentResponse", + "GetArtifactResponse", "GetAvailableMcpServerResponse", "GetCapabilitiesResponse", "GetConfigurationResponse", @@ -813,6 +823,7 @@ def __dir__(): "LargeToolResponseConfig", "LegacyTurnInputItem", "ListAgentsResponse", + "ListArtifactsResponse", "ListAvailableMcpServersResponse", "ListAvailableModelsResponse", "ListAvailableSkillsResponse", @@ -1013,6 +1024,7 @@ def __dir__(): "ZepMemoryProviderAuth", "__version__", "agents", + "artifacts", "auth", "catalogs", "internal", diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/__init__.py new file mode 100644 index 0000000000..5cde0202dc --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py new file mode 100644 index 0000000000..a8058f41c5 --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py @@ -0,0 +1,210 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.pagination import AsyncPager, SyncPager +from ..core.request_options import RequestOptions +from ..types.artifact import Artifact +from ..types.get_artifact_response import GetArtifactResponse +from ..types.list_artifacts_response import ListArtifactsResponse +from .raw_client import AsyncRawArtifactsClient, RawArtifactsClient + + +class ArtifactsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawArtifactsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawArtifactsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawArtifactsClient + """ + return self._raw_client + + def list( + self, + *, + limit: typing.Optional[int] = 25, + page_token: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Artifact, ListArtifactsResponse]: + """ + List artifacts created by the caller, most recently updated first. + + Parameters + ---------- + limit : typing.Optional[int] + Page size. Defaults to 25 + + page_token : typing.Optional[str] + Opaque token from a previous response `next_page_token`. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Artifact, ListArtifactsResponse] + Paginated artifacts. + + Examples + -------- + from trueforge_sdk import TrueForge + + client = TrueForge( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + response = client.artifacts.list() + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list(limit=limit, page_token=page_token, request_options=request_options) + + def get(self, *, slug: str, request_options: typing.Optional[RequestOptions] = None) -> GetArtifactResponse: + """ + Get an artifact created by the caller, by slug. + + Parameters + ---------- + slug : str + Artifact slug. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetArtifactResponse + The artifact. + + Examples + -------- + from trueforge_sdk import TrueForge + + client = TrueForge( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.artifacts.get( + slug="slug", + ) + """ + _response = self._raw_client.get(slug=slug, request_options=request_options) + return _response.data + + +class AsyncArtifactsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawArtifactsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawArtifactsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawArtifactsClient + """ + return self._raw_client + + async def list( + self, + *, + limit: typing.Optional[int] = 25, + page_token: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Artifact, ListArtifactsResponse]: + """ + List artifacts created by the caller, most recently updated first. + + Parameters + ---------- + limit : typing.Optional[int] + Page size. Defaults to 25 + + page_token : typing.Optional[str] + Opaque token from a previous response `next_page_token`. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Artifact, ListArtifactsResponse] + Paginated artifacts. + + Examples + -------- + import asyncio + + from trueforge_sdk import AsyncTrueForge + + client = AsyncTrueForge( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + response = await client.artifacts.list() + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list(limit=limit, page_token=page_token, request_options=request_options) + + async def get(self, *, slug: str, request_options: typing.Optional[RequestOptions] = None) -> GetArtifactResponse: + """ + Get an artifact created by the caller, by slug. + + Parameters + ---------- + slug : str + Artifact slug. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetArtifactResponse + The artifact. + + Examples + -------- + import asyncio + + from trueforge_sdk import AsyncTrueForge + + client = AsyncTrueForge( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.artifacts.get( + slug="slug", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(slug=slug, request_options=request_options) + return _response.data diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py new file mode 100644 index 0000000000..d0d957b34f --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py @@ -0,0 +1,338 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import encode_path_param +from ..core.pagination import AsyncPager, SyncPager +from ..core.parse_error import ParsingError +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.bad_request_error import BadRequestError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.artifact import Artifact +from ..types.get_artifact_response import GetArtifactResponse +from ..types.list_artifacts_response import ListArtifactsResponse +from ..types.request_error_response import RequestErrorResponse +from pydantic import ValidationError + + +class RawArtifactsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + *, + limit: typing.Optional[int] = 25, + page_token: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Artifact, ListArtifactsResponse]: + """ + List artifacts created by the caller, most recently updated first. + + Parameters + ---------- + limit : typing.Optional[int] + Page size. Defaults to 25 + + page_token : typing.Optional[str] + Opaque token from a previous response `next_page_token`. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Artifact, ListArtifactsResponse] + Paginated artifacts. + """ + _response = self._client_wrapper.httpx_client.request( + "api/v1/artifacts", + method="GET", + params={ + "limit": limit, + "page_token": page_token, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListArtifactsResponse, + construct_type( + type_=ListArtifactsResponse, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.data + _has_next = False + _get_next = None + if _parsed_response.pagination is not None: + _parsed_next = _parsed_response.pagination.next_page_token + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + limit=limit, + page_token=_parsed_next, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, *, slug: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetArtifactResponse]: + """ + Get an artifact created by the caller, by slug. + + Parameters + ---------- + slug : str + Artifact slug. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetArtifactResponse] + The artifact. + """ + _response = self._client_wrapper.httpx_client.request( + f"api/v1/artifacts/{encode_path_param(slug)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetArtifactResponse, + construct_type( + type_=GetArtifactResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawArtifactsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + *, + limit: typing.Optional[int] = 25, + page_token: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Artifact, ListArtifactsResponse]: + """ + List artifacts created by the caller, most recently updated first. + + Parameters + ---------- + limit : typing.Optional[int] + Page size. Defaults to 25 + + page_token : typing.Optional[str] + Opaque token from a previous response `next_page_token`. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Artifact, ListArtifactsResponse] + Paginated artifacts. + """ + _response = await self._client_wrapper.httpx_client.request( + "api/v1/artifacts", + method="GET", + params={ + "limit": limit, + "page_token": page_token, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListArtifactsResponse, + construct_type( + type_=ListArtifactsResponse, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.data + _has_next = False + _get_next = None + if _parsed_response.pagination is not None: + _parsed_next = _parsed_response.pagination.next_page_token + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + limit=limit, + page_token=_parsed_next, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, *, slug: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetArtifactResponse]: + """ + Get an artifact created by the caller, by slug. + + Parameters + ---------- + slug : str + Artifact slug. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetArtifactResponse] + The artifact. + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/v1/artifacts/{encode_path_param(slug)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetArtifactResponse, + construct_type( + type_=GetArtifactResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + RequestErrorResponse, + construct_type( + type_=RequestErrorResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/python/trueforge_sdk/src/trueforge_sdk/base_client.py b/python/trueforge_sdk/src/trueforge_sdk/base_client.py index aa6c162f93..d85e543a6f 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/base_client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/base_client.py @@ -10,6 +10,7 @@ if typing.TYPE_CHECKING: from .agents.client import AgentsClient, AsyncAgentsClient + from .artifacts.client import ArtifactsClient, AsyncArtifactsClient from .auth.client import AsyncAuthClient, AuthClient from .catalogs.client import AsyncCatalogsClient, CatalogsClient from .internal.client import AsyncInternalClient, InternalClient @@ -101,6 +102,7 @@ def __init__( ) self._internal: typing.Optional[InternalClient] = None self._agents: typing.Optional[AgentsClient] = None + self._artifacts: typing.Optional[ArtifactsClient] = None self._auth: typing.Optional[AuthClient] = None self._server: typing.Optional[ServerClient] = None self._mcp_servers: typing.Optional[McpServersClient] = None @@ -129,6 +131,14 @@ def agents(self): self._agents = AgentsClient(client_wrapper=self._client_wrapper) return self._agents + @property + def artifacts(self): + if self._artifacts is None: + from .artifacts.client import ArtifactsClient # noqa: E402 + + self._artifacts = ArtifactsClient(client_wrapper=self._client_wrapper) + return self._artifacts + @property def auth(self): if self._auth is None: @@ -316,6 +326,7 @@ def __init__( ) self._internal: typing.Optional[AsyncInternalClient] = None self._agents: typing.Optional[AsyncAgentsClient] = None + self._artifacts: typing.Optional[AsyncArtifactsClient] = None self._auth: typing.Optional[AsyncAuthClient] = None self._server: typing.Optional[AsyncServerClient] = None self._mcp_servers: typing.Optional[AsyncMcpServersClient] = None @@ -344,6 +355,14 @@ def agents(self): self._agents = AsyncAgentsClient(client_wrapper=self._client_wrapper) return self._agents + @property + def artifacts(self): + if self._artifacts is None: + from .artifacts.client import AsyncArtifactsClient # noqa: E402 + + self._artifacts = AsyncArtifactsClient(client_wrapper=self._client_wrapper) + return self._artifacts + @property def auth(self): if self._auth is None: diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py index 2ce7a59229..039658f66a 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py +++ b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py @@ -19,6 +19,7 @@ from .approval_allow import ApprovalAllow from .approval_decision import ApprovalDecision from .approval_deny import ApprovalDeny + from .artifact import Artifact from .ask_user_questions_config import AskUserQuestionsConfig from .available_mcp_server import AvailableMcpServer from .available_model import AvailableModel @@ -80,6 +81,7 @@ from .generative_ui_config import GenerativeUiConfig from .get_agent_code_snippets_response import GetAgentCodeSnippetsResponse from .get_agent_response import GetAgentResponse + from .get_artifact_response import GetArtifactResponse from .get_available_mcp_server_response import GetAvailableMcpServerResponse from .get_capabilities_response import GetCapabilitiesResponse from .get_configuration_response import GetConfigurationResponse @@ -111,6 +113,7 @@ from .large_tool_response_config import LargeToolResponseConfig from .legacy_turn_input_item import LegacyTurnInputItem from .list_agents_response import ListAgentsResponse + from .list_artifacts_response import ListArtifactsResponse from .list_available_mcp_servers_response import ListAvailableMcpServersResponse from .list_available_models_response import ListAvailableModelsResponse from .list_available_skills_response import ListAvailableSkillsResponse @@ -318,6 +321,7 @@ "ApprovalAllow": ".approval_allow", "ApprovalDecision": ".approval_decision", "ApprovalDeny": ".approval_deny", + "Artifact": ".artifact", "AskUserQuestionsConfig": ".ask_user_questions_config", "AvailableMcpServer": ".available_mcp_server", "AvailableModel": ".available_model", @@ -379,6 +383,7 @@ "GenerativeUiConfig": ".generative_ui_config", "GetAgentCodeSnippetsResponse": ".get_agent_code_snippets_response", "GetAgentResponse": ".get_agent_response", + "GetArtifactResponse": ".get_artifact_response", "GetAvailableMcpServerResponse": ".get_available_mcp_server_response", "GetCapabilitiesResponse": ".get_capabilities_response", "GetConfigurationResponse": ".get_configuration_response", @@ -410,6 +415,7 @@ "LargeToolResponseConfig": ".large_tool_response_config", "LegacyTurnInputItem": ".legacy_turn_input_item", "ListAgentsResponse": ".list_agents_response", + "ListArtifactsResponse": ".list_artifacts_response", "ListAvailableMcpServersResponse": ".list_available_mcp_servers_response", "ListAvailableModelsResponse": ".list_available_models_response", "ListAvailableSkillsResponse": ".list_available_skills_response", @@ -641,6 +647,7 @@ def __dir__(): "ApprovalAllow", "ApprovalDecision", "ApprovalDeny", + "Artifact", "AskUserQuestionsConfig", "AvailableMcpServer", "AvailableModel", @@ -702,6 +709,7 @@ def __dir__(): "GenerativeUiConfig", "GetAgentCodeSnippetsResponse", "GetAgentResponse", + "GetArtifactResponse", "GetAvailableMcpServerResponse", "GetCapabilitiesResponse", "GetConfigurationResponse", @@ -733,6 +741,7 @@ def __dir__(): "LargeToolResponseConfig", "LegacyTurnInputItem", "ListAgentsResponse", + "ListArtifactsResponse", "ListAvailableMcpServersResponse", "ListAvailableModelsResponse", "ListAvailableSkillsResponse", diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py b/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py new file mode 100644 index 0000000000..092648c3de --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py @@ -0,0 +1,32 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .subject import Subject + + +class Artifact(UncheckedBaseModel): + created_at: dt.datetime + created_by_session_id: str + created_by_subject: Subject + id: str + latest_version: int = pydantic.Field() + """ + Highest committed version; 0 before the first commit. + """ + + slug: str + title: str + updated_at: dt.datetime + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py b/python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py new file mode 100644 index 0000000000..44400fb76f --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py @@ -0,0 +1,20 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .artifact import Artifact + + +class GetArtifactResponse(UncheckedBaseModel): + data: Artifact + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/list_artifacts_response.py b/python/trueforge_sdk/src/trueforge_sdk/types/list_artifacts_response.py new file mode 100644 index 0000000000..76433f054a --- /dev/null +++ b/python/trueforge_sdk/src/trueforge_sdk/types/list_artifacts_response.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .artifact import Artifact +from .token_pagination import TokenPagination + + +class ListArtifactsResponse(UncheckedBaseModel): + data: typing.List[Artifact] + pagination: TokenPagination + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow From 48e632bdb9fd555844ca3d58686654b884a46ccd Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:00:13 +0530 Subject: [PATCH 04/12] [AGE-2886] Remove get artifact API Co-authored-by: Cursor --- .changeset/artifact-apis.md | 2 +- packages/trueforge/src/apis/artifacts.ts | 14 +------ .../trueforge/src/routes/artifactRoutes.ts | 39 +------------------ packages/trueforge/src/schemas/artifact.ts | 1 - .../tests/unit/apis/artifacts.test.ts | 12 +----- 5 files changed, 5 insertions(+), 63 deletions(-) diff --git a/.changeset/artifact-apis.md b/.changeset/artifact-apis.md index 6d90b5abce..2e413f388c 100644 --- a/.changeset/artifact-apis.md +++ b/.changeset/artifact-apis.md @@ -2,4 +2,4 @@ "@truefoundry/trueforge": patch --- -Add `GET /api/v1/artifacts` and `GET /api/v1/artifacts/{slug}` to list and get artifacts. +Add `GET /api/v1/artifacts` to list the caller's artifacts. diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index 9e53b72af8..e277d89ab7 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -3,7 +3,7 @@ import { InvalidPageTokenError } from '@truefoundry/trueforge-core/agent-session import { HTTPException } from 'hono/http-exception'; import type { ResolveRequestContext } from '../auth/identity'; import type { ArtifactRecord, IArtifactStore } from '../db/artifactStore'; -import { getArtifactRoute, listArtifactsRoute } from '../routes/artifactRoutes'; +import { listArtifactsRoute } from '../routes/artifactRoutes'; import type { Artifact } from '../schemas/artifact'; export interface ArtifactsRouterDeps { @@ -44,19 +44,7 @@ export function createArtifactsRouter(deps: ArtifactsRouterDeps = async c => { - const { slug } = c.req.valid('param'); - const requestContext = deps.resolveRequestContext(c); - const artifact = await deps.artifactStore.getArtifact({ tenant_id: requestContext.tenant_id, slug }); - // Another user's artifact is reported as missing so its slug does not leak. - if (artifact?.created_by_subject.subject_id !== requestContext.subject.id) { - return c.json({ error: { message: `Artifact not found: ${slug}` } }, 404); - } - return c.json({ data: toWireArtifact(artifact) }, 200); - }; - const router = new OpenAPIHono(); router.openapi(listArtifactsRoute, listHandler); - router.openapi(getArtifactRoute, getHandler); return router; } diff --git a/packages/trueforge/src/routes/artifactRoutes.ts b/packages/trueforge/src/routes/artifactRoutes.ts index 965793f8c9..ce4d02460a 100644 --- a/packages/trueforge/src/routes/artifactRoutes.ts +++ b/packages/trueforge/src/routes/artifactRoutes.ts @@ -2,20 +2,12 @@ * Artifact route definitions (mounted at /api/v1/artifacts). * Handlers are registered in apis/artifacts.ts. */ -import { createRoute, z } from '@hono/zod-openapi'; -import { - GetArtifactResponseSchema, - ListArtifactsRequestQuerySchema, - ListArtifactsResponseSchema, -} from '../schemas/artifact'; +import { createRoute } from '@hono/zod-openapi'; +import { ListArtifactsRequestQuerySchema, ListArtifactsResponseSchema } from '../schemas/artifact'; import { RequestErrorResponseSchema } from '../schemas/errors'; import { TOKEN_PAGINATION } from './fernExtensions'; import { OpenApiTag } from './openapiTags'; -const ArtifactSlugParamsSchema = z.object({ - slug: z.string().min(1).describe('Artifact slug.'), -}); - export const listArtifactsRoute = createRoute({ method: 'get', path: '/', @@ -43,30 +35,3 @@ export const listArtifactsRoute = createRoute({ }, }, }); - -export const getArtifactRoute = createRoute({ - method: 'get', - path: '/{slug}', - tags: [OpenApiTag.ARTIFACTS], - summary: 'Get an artifact', - description: 'Get an artifact created by the caller, by slug.', - 'x-fern-sdk-group-name': ['artifacts'], - 'x-fern-sdk-method-name': 'get', - request: { - params: ArtifactSlugParamsSchema, - }, - responses: { - 200: { - content: { 'application/json': { schema: GetArtifactResponseSchema } }, - description: 'The artifact.', - }, - 401: { - content: { 'application/json': { schema: RequestErrorResponseSchema } }, - description: 'Unauthenticated.', - }, - 404: { - content: { 'application/json': { schema: RequestErrorResponseSchema } }, - description: 'Not found.', - }, - }, -}); diff --git a/packages/trueforge/src/schemas/artifact.ts b/packages/trueforge/src/schemas/artifact.ts index dcdd57d346..d5f15491f7 100644 --- a/packages/trueforge/src/schemas/artifact.ts +++ b/packages/trueforge/src/schemas/artifact.ts @@ -32,7 +32,6 @@ export const ListArtifactsRequestQuerySchema = z }) .openapi('ListArtifactsRequestQuery'); -export const GetArtifactResponseSchema = z.object({ data: ArtifactSchema }).openapi('GetArtifactResponse'); export const ListArtifactsResponseSchema = z .object({ data: z.array(ArtifactSchema), diff --git a/packages/trueforge/tests/unit/apis/artifacts.test.ts b/packages/trueforge/tests/unit/apis/artifacts.test.ts index e1f88b4d14..e0f27dba4f 100644 --- a/packages/trueforge/tests/unit/apis/artifacts.test.ts +++ b/packages/trueforge/tests/unit/apis/artifacts.test.ts @@ -3,7 +3,7 @@ import { createdBySubjectFromRequestContext, STANDALONE_REQUEST_CONTEXT } from ' import { migrateSqliteToLatest } from '../../../src/db/migrateSqlite'; import { SqliteArtifactStore } from '../../../src/db/sqlite/artifact-store/SqliteArtifactStore'; import { createSqliteDb } from '../../../src/db/sqlite/client'; -import { GetArtifactResponseSchema, ListArtifactsResponseSchema } from '../../../src/schemas/artifact'; +import { ListArtifactsResponseSchema } from '../../../src/schemas/artifact'; import { mountWithErrorHandler } from '../mountWithErrorHandler'; describe('artifacts router', () => { @@ -49,14 +49,4 @@ describe('artifacts router', () => { it('rejects an invalid page token', async () => { expect((await app.request('/?page_token=not-a-token')).status).toBe(400); }); - - it('gets an artifact by slug', async () => { - const response = await app.request('/a'); - expect(response.status).toBe(200); - expect(GetArtifactResponseSchema.parse(await response.json()).data.slug).toBe('a'); - }); - - it.each(['missing', 'not-mine'])('returns 404 for %s', async slug => { - expect((await app.request(`/${slug}`)).status).toBe(404); - }); }); From fe01b0da7a861fbc625eea078a9a235de19de651 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:01:35 +0530 Subject: [PATCH 05/12] Regenerate OpenAPI document and SDKs Co-authored-by: Cursor --- .github/fern/openapi/openapi.json | 69 --------- docs/openapi.json | 69 --------- packages/trueforge-sdk/reference.md | 63 -------- .../api/resources/artifacts/client/Client.ts | 95 ------------- .../src/api/types/GetArtifactResponse.ts | 7 - packages/trueforge-sdk/src/api/types/index.ts | 1 - .../types/GetArtifactResponse.ts | 19 --- .../src/serialization/types/index.ts | 1 - .../tests/wire/artifacts.test.ts | 86 ----------- python/trueforge_sdk/reference.md | 72 ---------- .../src/trueforge_sdk/__init__.py | 3 - .../src/trueforge_sdk/artifacts/client.py | 73 ---------- .../src/trueforge_sdk/artifacts/raw_client.py | 134 ------------------ .../src/trueforge_sdk/types/__init__.py | 3 - .../types/get_artifact_response.py | 20 --- 15 files changed, 715 deletions(-) delete mode 100644 packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts delete mode 100644 packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts delete mode 100644 python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json index bb1623a62f..640f332ba8 100644 --- a/.github/fern/openapi/openapi.json +++ b/.github/fern/openapi/openapi.json @@ -1649,17 +1649,6 @@ ], "type": "object" }, - "GetArtifactResponse": { - "properties": { - "data": { - "$ref": "#/components/schemas/Artifact" - } - }, - "required": [ - "data" - ], - "type": "object" - }, "GetAvailableMCPServerResponse": { "properties": { "data": { @@ -8135,64 +8124,6 @@ "x-fern-sdk-method-name": "list" } }, - "/api/v1/artifacts/{slug}": { - "get": { - "description": "Get an artifact created by the caller, by slug.", - "parameters": [ - { - "description": "Artifact slug.", - "in": "path", - "name": "slug", - "required": true, - "schema": { - "description": "Artifact slug.", - "minLength": 1, - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetArtifactResponse" - } - } - }, - "description": "The artifact." - }, - "401": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RequestErrorResponse" - } - } - }, - "description": "Unauthenticated." - }, - "404": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RequestErrorResponse" - } - } - }, - "description": "Not found." - } - }, - "summary": "Get an artifact", - "tags": [ - "Artifacts" - ], - "x-fern-sdk-group-name": [ - "artifacts" - ], - "x-fern-sdk-method-name": "get" - } - }, "/api/v1/auth/callback": { "get": { "description": "Browser-redirect target hit by the identity provider after login, never called directly by SDK consumers. In local/single-binary mode, redirects straight back into the app.", diff --git a/docs/openapi.json b/docs/openapi.json index bb1623a62f..640f332ba8 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1649,17 +1649,6 @@ ], "type": "object" }, - "GetArtifactResponse": { - "properties": { - "data": { - "$ref": "#/components/schemas/Artifact" - } - }, - "required": [ - "data" - ], - "type": "object" - }, "GetAvailableMCPServerResponse": { "properties": { "data": { @@ -8135,64 +8124,6 @@ "x-fern-sdk-method-name": "list" } }, - "/api/v1/artifacts/{slug}": { - "get": { - "description": "Get an artifact created by the caller, by slug.", - "parameters": [ - { - "description": "Artifact slug.", - "in": "path", - "name": "slug", - "required": true, - "schema": { - "description": "Artifact slug.", - "minLength": 1, - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetArtifactResponse" - } - } - }, - "description": "The artifact." - }, - "401": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RequestErrorResponse" - } - } - }, - "description": "Unauthenticated." - }, - "404": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RequestErrorResponse" - } - } - }, - "description": "Not found." - } - }, - "summary": "Get an artifact", - "tags": [ - "Artifacts" - ], - "x-fern-sdk-group-name": [ - "artifacts" - ], - "x-fern-sdk-method-name": "get" - } - }, "/api/v1/auth/callback": { "get": { "description": "Browser-redirect target hit by the identity provider after login, never called directly by SDK consumers. In local/single-binary mode, redirects straight back into the app.", diff --git a/packages/trueforge-sdk/reference.md b/packages/trueforge-sdk/reference.md index 45056873f6..30aa65afb6 100644 --- a/packages/trueforge-sdk/reference.md +++ b/packages/trueforge-sdk/reference.md @@ -488,69 +488,6 @@ const response = page.response; - - - - -
client.artifacts.get(slug) -> TrueForge.GetArtifactResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Get an artifact created by the caller, by slug. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.artifacts.get("slug"); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**slug:** `string` — Artifact slug. - -
-
- -
-
- -**requestOptions:** `ArtifactsClient.RequestOptions` - -
-
-
-
- -
diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts index 7b771be434..62946a225e 100644 --- a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts @@ -134,99 +134,4 @@ export class ArtifactsClient { }, }); } - - /** - * Get an artifact created by the caller, by slug. - * - * @param {string} slug - Artifact slug. - * @param {ArtifactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link TrueForge.UnauthorizedError} - * @throws {@link TrueForge.NotFoundError} - * @throws {@link errors.TrueForgeError} - * @throws {@link errors.TrueForgeTimeoutError} - * - * @example - * await client.artifacts.get("slug") - */ - public get( - slug: string, - requestOptions?: ArtifactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__get(slug, requestOptions)); - } - - private async __get( - slug: string, - requestOptions?: ArtifactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)), - `api/v1/artifacts/${core.url.encodePathParam(slug, errors.TrueForgeError)}`, - ), - method: "GET", - headers: _headers, - queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: serializers.GetArtifactResponse.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new TrueForge.UnauthorizedError( - serializers.RequestErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); - case 404: - throw new TrueForge.NotFoundError( - serializers.RequestErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); - default: - throw new errors.TrueForgeError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/v1/artifacts/{slug}"); - } } diff --git a/packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts b/packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts deleted file mode 100644 index 8a2fd7c658..0000000000 --- a/packages/trueforge-sdk/src/api/types/GetArtifactResponse.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as TrueForge from "../index.js"; - -export interface GetArtifactResponse { - data: TrueForge.Artifact; -} diff --git a/packages/trueforge-sdk/src/api/types/index.ts b/packages/trueforge-sdk/src/api/types/index.ts index 902a8cf1c8..ccf34864d0 100644 --- a/packages/trueforge-sdk/src/api/types/index.ts +++ b/packages/trueforge-sdk/src/api/types/index.ts @@ -73,7 +73,6 @@ export * from "./FireworksModelProvider.js"; export * from "./GenerativeUiConfig.js"; export * from "./GetAgentCodeSnippetsResponse.js"; export * from "./GetAgentResponse.js"; -export * from "./GetArtifactResponse.js"; export * from "./GetAvailableMcpServerResponse.js"; export * from "./GetCapabilitiesResponse.js"; export * from "./GetConfigurationResponse.js"; diff --git a/packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts b/packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts deleted file mode 100644 index fd8f83823c..0000000000 --- a/packages/trueforge-sdk/src/serialization/types/GetArtifactResponse.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as TrueForge from "../../api/index.js"; -import * as core from "../../core/index.js"; -import type * as serializers from "../index.js"; -import { Artifact } from "./Artifact.js"; - -export const GetArtifactResponse: core.serialization.ObjectSchema< - serializers.GetArtifactResponse.Raw, - TrueForge.GetArtifactResponse -> = core.serialization.object({ - data: Artifact, -}); - -export declare namespace GetArtifactResponse { - export interface Raw { - data: Artifact.Raw; - } -} diff --git a/packages/trueforge-sdk/src/serialization/types/index.ts b/packages/trueforge-sdk/src/serialization/types/index.ts index 902a8cf1c8..ccf34864d0 100644 --- a/packages/trueforge-sdk/src/serialization/types/index.ts +++ b/packages/trueforge-sdk/src/serialization/types/index.ts @@ -73,7 +73,6 @@ export * from "./FireworksModelProvider.js"; export * from "./GenerativeUiConfig.js"; export * from "./GetAgentCodeSnippetsResponse.js"; export * from "./GetAgentResponse.js"; -export * from "./GetArtifactResponse.js"; export * from "./GetAvailableMcpServerResponse.js"; export * from "./GetCapabilitiesResponse.js"; export * from "./GetConfigurationResponse.js"; diff --git a/packages/trueforge-sdk/tests/wire/artifacts.test.ts b/packages/trueforge-sdk/tests/wire/artifacts.test.ts index 99018d6db4..e361000d04 100644 --- a/packages/trueforge-sdk/tests/wire/artifacts.test.ts +++ b/packages/trueforge-sdk/tests/wire/artifacts.test.ts @@ -93,90 +93,4 @@ describe("ArtifactsClient", () => { return await client.artifacts.list(); }).rejects.toThrow(TrueForgeTypes.UnauthorizedError); }); - - test("get (1)", async () => { - const server = mockServerPool.createServer(); - const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); - - const rawResponseBody = { - data: { - created_at: "2024-01-15T09:30:00Z", - created_by_session_id: "created_by_session_id", - created_by_subject: { - subject_display_name: "subject_display_name", - subject_id: "subject_id", - subject_type: "subject_type", - }, - id: "id", - latest_version: 1, - slug: "slug", - title: "title", - updated_at: "2024-01-15T09:30:00Z", - }, - }; - - server - .mockEndpoint() - .get("/api/v1/artifacts/slug") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.artifacts.get("slug"); - expect(response).toEqual({ - data: { - createdAt: new Date("2024-01-15T09:30:00.000Z"), - createdBySessionId: "created_by_session_id", - createdBySubject: { - subjectDisplayName: "subject_display_name", - subjectId: "subject_id", - subjectType: "subject_type", - }, - id: "id", - latestVersion: 1, - slug: "slug", - title: "title", - updatedAt: new Date("2024-01-15T09:30:00.000Z"), - }, - }); - }); - - test("get (2)", async () => { - const server = mockServerPool.createServer(); - const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); - - const rawResponseBody = { error: { message: "message" } }; - - server - .mockEndpoint() - .get("/api/v1/artifacts/slug") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.artifacts.get("slug"); - }).rejects.toThrow(TrueForgeTypes.UnauthorizedError); - }); - - test("get (3)", async () => { - const server = mockServerPool.createServer(); - const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl }); - - const rawResponseBody = { error: { message: "message" } }; - - server - .mockEndpoint() - .get("/api/v1/artifacts/slug") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.artifacts.get("slug"); - }).rejects.toThrow(TrueForgeTypes.NotFoundError); - }); }); diff --git a/python/trueforge_sdk/reference.md b/python/trueforge_sdk/reference.md index 423b2cea25..4aee63017c 100644 --- a/python/trueforge_sdk/reference.md +++ b/python/trueforge_sdk/reference.md @@ -576,78 +576,6 @@ client.artifacts.list() - - - - -
client.artifacts.get(...) -> GetArtifactResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Get an artifact created by the caller, by slug. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from trueforge_sdk import TrueForge - -client = TrueForge( - token="", - base_url="https://yourhost.com/path/to/api", -) - -client.artifacts.get( - slug="slug", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**slug:** `str` — Artifact slug. - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- -
diff --git a/python/trueforge_sdk/src/trueforge_sdk/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/__init__.py index 1efdcc2dad..aeab071ebf 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/__init__.py +++ b/python/trueforge_sdk/src/trueforge_sdk/__init__.py @@ -82,7 +82,6 @@ GenerativeUiConfig, GetAgentCodeSnippetsResponse, GetAgentResponse, - GetArtifactResponse, GetAvailableMcpServerResponse, GetCapabilitiesResponse, GetConfigurationResponse, @@ -430,7 +429,6 @@ "GenerativeUiConfig": ".types", "GetAgentCodeSnippetsResponse": ".types", "GetAgentResponse": ".types", - "GetArtifactResponse": ".types", "GetAvailableMcpServerResponse": ".types", "GetCapabilitiesResponse": ".types", "GetConfigurationResponse": ".types", @@ -789,7 +787,6 @@ def __dir__(): "GenerativeUiConfig", "GetAgentCodeSnippetsResponse", "GetAgentResponse", - "GetArtifactResponse", "GetAvailableMcpServerResponse", "GetCapabilitiesResponse", "GetConfigurationResponse", diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py index a8058f41c5..1df50fa93d 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py @@ -6,7 +6,6 @@ from ..core.pagination import AsyncPager, SyncPager from ..core.request_options import RequestOptions from ..types.artifact import Artifact -from ..types.get_artifact_response import GetArtifactResponse from ..types.list_artifacts_response import ListArtifactsResponse from .raw_client import AsyncRawArtifactsClient, RawArtifactsClient @@ -69,38 +68,6 @@ def list( """ return self._raw_client.list(limit=limit, page_token=page_token, request_options=request_options) - def get(self, *, slug: str, request_options: typing.Optional[RequestOptions] = None) -> GetArtifactResponse: - """ - Get an artifact created by the caller, by slug. - - Parameters - ---------- - slug : str - Artifact slug. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetArtifactResponse - The artifact. - - Examples - -------- - from trueforge_sdk import TrueForge - - client = TrueForge( - token="YOUR_TOKEN", - base_url="https://yourhost.com/path/to/api", - ) - client.artifacts.get( - slug="slug", - ) - """ - _response = self._raw_client.get(slug=slug, request_options=request_options) - return _response.data - class AsyncArtifactsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -168,43 +135,3 @@ async def main() -> None: asyncio.run(main()) """ return await self._raw_client.list(limit=limit, page_token=page_token, request_options=request_options) - - async def get(self, *, slug: str, request_options: typing.Optional[RequestOptions] = None) -> GetArtifactResponse: - """ - Get an artifact created by the caller, by slug. - - Parameters - ---------- - slug : str - Artifact slug. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetArtifactResponse - The artifact. - - Examples - -------- - import asyncio - - from trueforge_sdk import AsyncTrueForge - - client = AsyncTrueForge( - token="YOUR_TOKEN", - base_url="https://yourhost.com/path/to/api", - ) - - - async def main() -> None: - await client.artifacts.get( - slug="slug", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.get(slug=slug, request_options=request_options) - return _response.data diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py index d0d957b34f..45266d40b9 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py @@ -5,17 +5,13 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.http_response import AsyncHttpResponse, HttpResponse -from ..core.jsonable_encoder import encode_path_param from ..core.pagination import AsyncPager, SyncPager from ..core.parse_error import ParsingError from ..core.request_options import RequestOptions from ..core.unchecked_base_model import construct_type from ..errors.bad_request_error import BadRequestError -from ..errors.not_found_error import NotFoundError from ..errors.unauthorized_error import UnauthorizedError from ..types.artifact import Artifact -from ..types.get_artifact_response import GetArtifactResponse from ..types.list_artifacts_response import ListArtifactsResponse from ..types.request_error_response import RequestErrorResponse from pydantic import ValidationError @@ -112,71 +108,6 @@ def list( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def get( - self, *, slug: str, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[GetArtifactResponse]: - """ - Get an artifact created by the caller, by slug. - - Parameters - ---------- - slug : str - Artifact slug. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetArtifactResponse] - The artifact. - """ - _response = self._client_wrapper.httpx_client.request( - f"api/v1/artifacts/{encode_path_param(slug)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetArtifactResponse, - construct_type( - type_=GetArtifactResponse, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 401: - raise UnauthorizedError( - headers=dict(_response.headers), - body=typing.cast( - RequestErrorResponse, - construct_type( - type_=RequestErrorResponse, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 404: - raise NotFoundError( - headers=dict(_response.headers), - body=typing.cast( - RequestErrorResponse, - construct_type( - type_=RequestErrorResponse, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - except ValidationError as e: - raise ParsingError( - status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e - ) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - class AsyncRawArtifactsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -271,68 +202,3 @@ async def _get_next(): status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def get( - self, *, slug: str, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[GetArtifactResponse]: - """ - Get an artifact created by the caller, by slug. - - Parameters - ---------- - slug : str - Artifact slug. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetArtifactResponse] - The artifact. - """ - _response = await self._client_wrapper.httpx_client.request( - f"api/v1/artifacts/{encode_path_param(slug)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetArtifactResponse, - construct_type( - type_=GetArtifactResponse, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 401: - raise UnauthorizedError( - headers=dict(_response.headers), - body=typing.cast( - RequestErrorResponse, - construct_type( - type_=RequestErrorResponse, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 404: - raise NotFoundError( - headers=dict(_response.headers), - body=typing.cast( - RequestErrorResponse, - construct_type( - type_=RequestErrorResponse, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - except ValidationError as e: - raise ParsingError( - status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e - ) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py index 039658f66a..0c672726a6 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py +++ b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py @@ -81,7 +81,6 @@ from .generative_ui_config import GenerativeUiConfig from .get_agent_code_snippets_response import GetAgentCodeSnippetsResponse from .get_agent_response import GetAgentResponse - from .get_artifact_response import GetArtifactResponse from .get_available_mcp_server_response import GetAvailableMcpServerResponse from .get_capabilities_response import GetCapabilitiesResponse from .get_configuration_response import GetConfigurationResponse @@ -383,7 +382,6 @@ "GenerativeUiConfig": ".generative_ui_config", "GetAgentCodeSnippetsResponse": ".get_agent_code_snippets_response", "GetAgentResponse": ".get_agent_response", - "GetArtifactResponse": ".get_artifact_response", "GetAvailableMcpServerResponse": ".get_available_mcp_server_response", "GetCapabilitiesResponse": ".get_capabilities_response", "GetConfigurationResponse": ".get_configuration_response", @@ -709,7 +707,6 @@ def __dir__(): "GenerativeUiConfig", "GetAgentCodeSnippetsResponse", "GetAgentResponse", - "GetArtifactResponse", "GetAvailableMcpServerResponse", "GetCapabilitiesResponse", "GetConfigurationResponse", diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py b/python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py deleted file mode 100644 index 44400fb76f..0000000000 --- a/python/trueforge_sdk/src/trueforge_sdk/types/get_artifact_response.py +++ /dev/null @@ -1,20 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.unchecked_base_model import UncheckedBaseModel -from .artifact import Artifact - - -class GetArtifactResponse(UncheckedBaseModel): - data: Artifact - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 - else: - - class Config: - smart_union = True - extra = pydantic.Extra.allow From 89edfd870f23211fd275e3786d3e49170b286423 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:05:32 +0530 Subject: [PATCH 06/12] [AGE-2886] Filter artifact list by session, title, and updated_at Co-authored-by: Cursor --- .changeset/artifact-apis.md | 2 +- packages/trueforge/src/apis/artifacts.ts | 10 +++- .../trueforge/src/routes/artifactRoutes.ts | 3 +- packages/trueforge/src/schemas/artifact.ts | 14 ++++- packages/trueforge/src/schemas/common.ts | 6 ++ packages/trueforge/src/schemas/session.ts | 8 +-- .../trueforge/src/schemas/sessionMetrics.ts | 7 +-- .../tests/unit/apis/artifacts.test.ts | 55 +++++++++++++------ 8 files changed, 68 insertions(+), 37 deletions(-) diff --git a/.changeset/artifact-apis.md b/.changeset/artifact-apis.md index 2e413f388c..2f554c6a8b 100644 --- a/.changeset/artifact-apis.md +++ b/.changeset/artifact-apis.md @@ -2,4 +2,4 @@ "@truefoundry/trueforge": patch --- -Add `GET /api/v1/artifacts` to list the caller's artifacts. +Add `GET /api/v1/artifacts` to list the caller's artifacts, filterable by session, title substring, and `updated_at` range. diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index e277d89ab7..db538b4fa4 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -26,14 +26,18 @@ function toWireArtifact(record: ArtifactRecord): Artifact { export function createArtifactsRouter(deps: ArtifactsRouterDeps) { const listHandler: RouteHandler = async c => { - const { limit, page_token } = c.req.valid('query'); + const query = c.req.valid('query'); const requestContext = deps.resolveRequestContext(c); try { const { data, pagination } = await deps.artifactStore.listArtifacts({ tenant_id: requestContext.tenant_id, created_by_subject_id: requestContext.subject.id, - limit, - page_token, + created_by_session_id: query.created_by_session_id, + title: query.title, + updated_since: query.updated_since, + updated_before: query.updated_before, + limit: query.limit, + page_token: query.page_token, }); return c.json({ data: data.map(toWireArtifact), pagination }, 200); } catch (error) { diff --git a/packages/trueforge/src/routes/artifactRoutes.ts b/packages/trueforge/src/routes/artifactRoutes.ts index ce4d02460a..7dbb2339fc 100644 --- a/packages/trueforge/src/routes/artifactRoutes.ts +++ b/packages/trueforge/src/routes/artifactRoutes.ts @@ -13,7 +13,8 @@ export const listArtifactsRoute = createRoute({ path: '/', tags: [OpenApiTag.ARTIFACTS], summary: 'List artifacts', - description: 'List artifacts created by the caller, most recently updated first.', + description: + 'List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range.', 'x-fern-sdk-group-name': ['artifacts'], 'x-fern-sdk-method-name': 'list', 'x-fern-pagination': TOKEN_PAGINATION, diff --git a/packages/trueforge/src/schemas/artifact.ts b/packages/trueforge/src/schemas/artifact.ts index d5f15491f7..e354036584 100644 --- a/packages/trueforge/src/schemas/artifact.ts +++ b/packages/trueforge/src/schemas/artifact.ts @@ -1,6 +1,6 @@ import { z } from '@hono/zod-openapi'; import { SubjectSchema, TokenPaginationSchema } from '@truefoundry/trueforge-core/agent-session'; -import { PAGE_LIMIT } from './common'; +import { IsoTimestampQueryParam, PAGE_LIMIT } from './common'; export const ArtifactSchema = z .object({ @@ -29,6 +29,18 @@ export const ListArtifactsRequestQuerySchema = z .default(PAGE_LIMIT) .describe(`Page size. Defaults to ${String(PAGE_LIMIT)}`), page_token: z.string().optional().describe('Opaque token from a previous response `next_page_token`.'), + created_by_session_id: z + .string() + .min(1) + .optional() + .describe('When set, only artifacts created in this session are returned.'), + title: z.string().trim().min(1).optional().describe('Case-insensitive substring match on artifact title.'), + updated_since: IsoTimestampQueryParam.optional().describe( + 'Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339).', + ), + updated_before: IsoTimestampQueryParam.optional().describe( + 'Exclusive upper bound on `updated_at` (ISO-8601 / RFC 3339).', + ), }) .openapi('ListArtifactsRequestQuery'); diff --git a/packages/trueforge/src/schemas/common.ts b/packages/trueforge/src/schemas/common.ts index a005191752..e5855c92b5 100644 --- a/packages/trueforge/src/schemas/common.ts +++ b/packages/trueforge/src/schemas/common.ts @@ -29,6 +29,12 @@ export type ResourceName = z.infer; /** Session and artifact titles; matches auto-derived titles from the first user message on turn 1. */ export const MAX_TITLE_LENGTH = 50; +/** Wire ISO-8601 (RFC 3339, offsets allowed) → Date for the store. */ +export const IsoTimestampQueryParam = z.iso + .datetime({ offset: true }) + .openapi({ type: 'string', format: 'date-time' }) + .transform(s => new Date(s)); + export const PAGE_LIMIT = 25; /** Session/turn event list page size; default and max are read from config per request, so not baked into OpenAPI. */ export const EventsPageLimitQuerySchema = z.coerce diff --git a/packages/trueforge/src/schemas/session.ts b/packages/trueforge/src/schemas/session.ts index 42b59c1675..da3f0e076e 100644 --- a/packages/trueforge/src/schemas/session.ts +++ b/packages/trueforge/src/schemas/session.ts @@ -8,7 +8,7 @@ import { SessionSourceTypeSchema, TokenPaginationSchema, } from '@truefoundry/trueforge-core/agent-session'; -import { MAX_TITLE_LENGTH, NameSchema, PAGE_LIMIT } from './common'; +import { IsoTimestampQueryParam, MAX_TITLE_LENGTH, NameSchema, PAGE_LIMIT } from './common'; import { foldDeepObjectQueryParam } from './deepObjectQuery'; /** Create arm: bind by unique registry agent name. */ @@ -70,12 +70,6 @@ export const UpdateSessionRequestSchema = z export type { Session } from '@truefoundry/trueforge-core/agent-session'; -/** Wire ISO-8601 (RFC 3339, offsets allowed) → Date for the store. */ -const IsoTimestampQueryParam = z.iso - .datetime({ offset: true }) - .openapi({ type: 'string', format: 'date-time' }) - .transform(s => new Date(s)); - /** Max metadata equality filters on list sessions (clause-budget style). */ export const LIST_SESSIONS_METADATA_FILTER_MAX_KEYS = 10; diff --git a/packages/trueforge/src/schemas/sessionMetrics.ts b/packages/trueforge/src/schemas/sessionMetrics.ts index af4e26f99a..d898fe4261 100644 --- a/packages/trueforge/src/schemas/sessionMetrics.ts +++ b/packages/trueforge/src/schemas/sessionMetrics.ts @@ -3,6 +3,7 @@ * Per-session counters (`SessionMetrics`) stay in trueforge-core. */ import { z } from '@hono/zod-openapi'; +import { IsoTimestampQueryParam } from './common'; /** Max inclusive created_at window for session metrics aggregation (30 days). */ export const MAX_SESSION_METRICS_WINDOW_MS = 30 * 24 * 60 * 60 * 1000; @@ -106,12 +107,6 @@ export const SessionMetricsChartDataResponseSchema = z .strict() .openapi('SessionMetricsChartDataResponse'); -/** Wire ISO-8601 (RFC 3339, offsets allowed) → Date for metrics window bounds. */ -const IsoTimestampQueryParam = z.iso - .datetime({ offset: true }) - .openapi({ type: 'string', format: 'date-time' }) - .transform(s => new Date(s)); - const GetSessionMetricsRequestQueryObjectSchema = z.object({ agent_id: z.string().min(1).max(64).describe('Named agent identifier.'), start_timestamp: IsoTimestampQueryParam.describe('Inclusive lower bound on session `created_at`.'), diff --git a/packages/trueforge/tests/unit/apis/artifacts.test.ts b/packages/trueforge/tests/unit/apis/artifacts.test.ts index e0f27dba4f..a3f9857067 100644 --- a/packages/trueforge/tests/unit/apis/artifacts.test.ts +++ b/packages/trueforge/tests/unit/apis/artifacts.test.ts @@ -1,5 +1,6 @@ import { createArtifactsRouter } from '../../../src/apis/artifacts'; import { createdBySubjectFromRequestContext, STANDALONE_REQUEST_CONTEXT } from '../../../src/auth/identity'; +import type { ArtifactRecord } from '../../../src/db/artifactStore'; import { migrateSqliteToLatest } from '../../../src/db/migrateSqlite'; import { SqliteArtifactStore } from '../../../src/db/sqlite/artifact-store/SqliteArtifactStore'; import { createSqliteDb } from '../../../src/db/sqlite/client'; @@ -8,29 +9,32 @@ import { mountWithErrorHandler } from '../mountWithErrorHandler'; describe('artifacts router', () => { let app: ReturnType; + let report: ArtifactRecord; + + async function listTitles(query: string): Promise { + const response = await app.request(`/?${query}`); + expect(response.status).toBe(200); + return ListArtifactsResponseSchema.parse(await response.json()) + .data.map(a => a.title) + .sort(); + } beforeAll(async () => { const db = createSqliteDb(':memory:'); await migrateSqliteToLatest(db); const artifactStore = new SqliteArtifactStore(db); - for (const slug of ['a', 'b']) { - await artifactStore.createArtifact({ - tenant_id: STANDALONE_REQUEST_CONTEXT.tenant_id, - slug, - title: slug, - created_by_subject: createdBySubjectFromRequestContext(STANDALONE_REQUEST_CONTEXT), - created_by_session_id: 'session-1', - }); - } - await artifactStore.createArtifact({ + const mine = { tenant_id: STANDALONE_REQUEST_CONTEXT.tenant_id, - slug: 'not-mine', + created_by_subject: createdBySubjectFromRequestContext(STANDALONE_REQUEST_CONTEXT), + }; + report = await artifactStore.createArtifact({ ...mine, title: 'Q3 Report', created_by_session_id: 'session-1' }); + await new Promise(resolve => setTimeout(resolve, 5)); + await artifactStore.createArtifact({ ...mine, title: 'Roadmap', created_by_session_id: 'session-2' }); + await artifactStore.createArtifact({ + ...mine, title: 'not mine', - created_by_subject: { - ...createdBySubjectFromRequestContext(STANDALONE_REQUEST_CONTEXT), - subject_id: 'someone-else', - }, - created_by_session_id: 'session-2', + created_by_subject: { ...mine.created_by_subject, subject_id: 'someone-else' }, + created_by_session_id: 'session-1', }); app = mountWithErrorHandler( createArtifactsRouter({ artifactStore, resolveRequestContext: () => STANDALONE_REQUEST_CONTEXT }), @@ -43,10 +47,25 @@ describe('artifacts router', () => { const second = ListArtifactsResponseSchema.parse( await (await app.request(`/?limit=1&page_token=${first.pagination.next_page_token ?? ''}`)).json(), ); - expect([...first.data, ...second.data].map(a => a.slug).sort()).toEqual(['a', 'b']); + expect([...first.data, ...second.data].map(a => a.title).sort()).toEqual(['Q3 Report', 'Roadmap']); + }); + + it('filters by created_by_session_id', async () => { + expect(await listTitles('created_by_session_id=session-2')).toEqual(['Roadmap']); + }); + + it('filters by title substring', async () => { + expect(await listTitles('title=report')).toEqual(['Q3 Report']); + }); + + it('filters by updated_at range', async () => { + const boundary = encodeURIComponent(new Date(Date.parse(report.updated_at) + 1).toISOString()); + expect(await listTitles(`updated_since=${boundary}`)).toEqual(['Roadmap']); + expect(await listTitles(`updated_before=${boundary}`)).toEqual(['Q3 Report']); }); - it('rejects an invalid page token', async () => { + it('rejects an invalid page token or timestamp', async () => { expect((await app.request('/?page_token=not-a-token')).status).toBe(400); + expect((await app.request('/?updated_since=yesterday')).status).toBe(400); }); }); From 28f9a92bcb60963785bc3e5faef2b486292b7428 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:24:13 +0530 Subject: [PATCH 07/12] [AGE-2886] Drop transaction generic from artifacts router deps Co-authored-by: Cursor --- packages/trueforge/src/apis/artifacts.ts | 6 +++--- packages/trueforge/src/app.ts | 2 +- packages/trueforge/src/main.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index db538b4fa4..7d8d989524 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -6,8 +6,8 @@ import type { ArtifactRecord, IArtifactStore } from '../db/artifactStore'; import { listArtifactsRoute } from '../routes/artifactRoutes'; import type { Artifact } from '../schemas/artifact'; -export interface ArtifactsRouterDeps { - artifactStore: IArtifactStore; +export interface ArtifactsRouterDeps { + artifactStore: IArtifactStore; resolveRequestContext: ResolveRequestContext; } @@ -24,7 +24,7 @@ function toWireArtifact(record: ArtifactRecord): Artifact { }; } -export function createArtifactsRouter(deps: ArtifactsRouterDeps) { +export function createArtifactsRouter(deps: ArtifactsRouterDeps) { const listHandler: RouteHandler = async c => { const query = c.req.valid('query'); const requestContext = deps.resolveRequestContext(c); diff --git a/packages/trueforge/src/app.ts b/packages/trueforge/src/app.ts index c3bfa00bcf..7cbe4b491f 100644 --- a/packages/trueforge/src/app.ts +++ b/packages/trueforge/src/app.ts @@ -343,7 +343,7 @@ export interface ServerDeps { /** DB singleton, or the env-backed shared store in TrueFoundry mode. */ sandboxProviderStore: ISandboxProviderStore; scheduleStore: IScheduleStore; - artifactStore: IArtifactStore; + artifactStore: IArtifactStore; sessionMetricsStore: ISessionMetricsStore; sessions: Sessions; sessionStore: ISessionStore; diff --git a/packages/trueforge/src/main.ts b/packages/trueforge/src/main.ts index 6ed0144647..37d99e68af 100644 --- a/packages/trueforge/src/main.ts +++ b/packages/trueforge/src/main.ts @@ -166,7 +166,7 @@ interface ServerPersistence { accessControlStore: IAccessControlStore; /** extra pre-resolved stores for scheduled runs */ agentStore: IAgentStore; - artifactStore: IArtifactStore; + artifactStore: IArtifactStore; destroyDb: () => Promise; mcpOAuthStore: IMcpServerWithAuthStore; /** Connected Redis (client + mode) for distributed peering; undefined in standalone. */ From 193b86555050dd91a4bd035d5cf05292d450b948 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:09:37 +0530 Subject: [PATCH 08/12] [AGE-2886] Replace updated_since/updated_before with last_updated and created ranges Co-authored-by: Cursor --- packages/trueforge/src/apis/artifacts.ts | 6 ++++-- packages/trueforge/src/schemas/artifact.ts | 20 +++++++++++++++---- .../tests/unit/apis/artifacts.test.ts | 14 ++++++++----- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index 7d8d989524..9aa400e5ec 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -34,8 +34,10 @@ export function createArtifactsRouter(deps: ArtifactsRouterDeps) { created_by_subject_id: requestContext.subject.id, created_by_session_id: query.created_by_session_id, title: query.title, - updated_since: query.updated_since, - updated_before: query.updated_before, + last_updated_from: query.last_updated_from, + last_updated_to: query.last_updated_to, + created_from: query.created_from, + created_to: query.created_to, limit: query.limit, page_token: query.page_token, }); diff --git a/packages/trueforge/src/schemas/artifact.ts b/packages/trueforge/src/schemas/artifact.ts index e354036584..98f4661916 100644 --- a/packages/trueforge/src/schemas/artifact.ts +++ b/packages/trueforge/src/schemas/artifact.ts @@ -35,13 +35,25 @@ export const ListArtifactsRequestQuerySchema = z .optional() .describe('When set, only artifacts created in this session are returned.'), title: z.string().trim().min(1).optional().describe('Case-insensitive substring match on artifact title.'), - updated_since: IsoTimestampQueryParam.optional().describe( - 'Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339).', + last_updated_from: IsoTimestampQueryParam.optional().describe( + 'Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.', ), - updated_before: IsoTimestampQueryParam.optional().describe( - 'Exclusive upper bound on `updated_at` (ISO-8601 / RFC 3339).', + last_updated_to: IsoTimestampQueryParam.optional().describe( + 'Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.', + ), + created_from: IsoTimestampQueryParam.optional().describe( + 'Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.', + ), + created_to: IsoTimestampQueryParam.optional().describe( + 'Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.', ), }) + .refine( + q => + (q.last_updated_from === undefined && q.last_updated_to === undefined) || + (q.created_from === undefined && q.created_to === undefined), + { message: 'Pass only one of the last_updated or created time ranges.' }, + ) .openapi('ListArtifactsRequestQuery'); export const ListArtifactsResponseSchema = z diff --git a/packages/trueforge/tests/unit/apis/artifacts.test.ts b/packages/trueforge/tests/unit/apis/artifacts.test.ts index a3f9857067..d143612205 100644 --- a/packages/trueforge/tests/unit/apis/artifacts.test.ts +++ b/packages/trueforge/tests/unit/apis/artifacts.test.ts @@ -58,14 +58,18 @@ describe('artifacts router', () => { expect(await listTitles('title=report')).toEqual(['Q3 Report']); }); - it('filters by updated_at range', async () => { + it('filters by last-updated or created range', async () => { const boundary = encodeURIComponent(new Date(Date.parse(report.updated_at) + 1).toISOString()); - expect(await listTitles(`updated_since=${boundary}`)).toEqual(['Roadmap']); - expect(await listTitles(`updated_before=${boundary}`)).toEqual(['Q3 Report']); + expect(await listTitles(`last_updated_from=${boundary}`)).toEqual(['Roadmap']); + expect(await listTitles(`last_updated_to=${boundary}`)).toEqual(['Q3 Report']); + expect(await listTitles(`created_from=${boundary}`)).toEqual(['Roadmap']); + expect(await listTitles(`created_to=${boundary}`)).toEqual(['Q3 Report']); }); - it('rejects an invalid page token or timestamp', async () => { + it('rejects an invalid page token, timestamp, or combined time ranges', async () => { expect((await app.request('/?page_token=not-a-token')).status).toBe(400); - expect((await app.request('/?updated_since=yesterday')).status).toBe(400); + expect((await app.request('/?last_updated_from=yesterday')).status).toBe(400); + const now = encodeURIComponent(new Date().toISOString()); + expect((await app.request(`/?last_updated_from=${now}&created_to=${now}`)).status).toBe(400); }); }); From 6e728b7345e799b021700f18c84652e85b56e6de Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:49:37 +0530 Subject: [PATCH 09/12] [AGE-2886] Drop id from artifact response and simplify latest_version description Co-authored-by: Cursor --- packages/trueforge/src/apis/artifacts.ts | 1 - packages/trueforge/src/schemas/artifact.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index 9aa400e5ec..98c541aa37 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -13,7 +13,6 @@ export interface ArtifactsRouterDeps { function toWireArtifact(record: ArtifactRecord): Artifact { return { - id: record.id, slug: record.slug, title: record.title, latest_version: record.latest_version, diff --git a/packages/trueforge/src/schemas/artifact.ts b/packages/trueforge/src/schemas/artifact.ts index 98f4661916..70c16249f5 100644 --- a/packages/trueforge/src/schemas/artifact.ts +++ b/packages/trueforge/src/schemas/artifact.ts @@ -4,10 +4,9 @@ import { IsoTimestampQueryParam, PAGE_LIMIT } from './common'; export const ArtifactSchema = z .object({ - id: z.string(), slug: z.string(), title: z.string(), - latest_version: z.number().int().describe('Highest committed version; 0 before the first commit.'), + latest_version: z.number().int().describe('Latest version.'), created_by_subject: SubjectSchema, created_by_session_id: z.string(), created_at: z.iso.datetime(), From 208cd304d1858df1fd575778057f277f7040afad Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Fri, 20 Nov 2026 21:02:29 +0530 Subject: [PATCH 10/12] Regenerate OpenAPI document and SDKs Co-authored-by: Cursor --- .github/fern/openapi/openapi.json | 74 ++++++++++++++++-- docs/openapi.json | 74 ++++++++++++++++-- packages/trueforge-sdk/reference.md | 2 +- .../api/resources/artifacts/client/Client.ts | 19 ++++- .../client/requests/ListArtifactsRequest.ts | 12 +++ .../trueforge-sdk/src/api/types/Artifact.ts | 3 +- .../src/serialization/types/Artifact.ts | 2 - .../tests/wire/artifacts.test.ts | 2 - python/trueforge_sdk/reference.md | 50 +++++++++++- .../src/trueforge_sdk/artifacts/client.py | 77 +++++++++++++++++- .../src/trueforge_sdk/artifacts/raw_client.py | 78 ++++++++++++++++++- .../src/trueforge_sdk/types/artifact.py | 3 +- 12 files changed, 366 insertions(+), 30 deletions(-) diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json index 640f332ba8..0a6685afa8 100644 --- a/.github/fern/openapi/openapi.json +++ b/.github/fern/openapi/openapi.json @@ -344,11 +344,8 @@ "created_by_subject": { "$ref": "#/components/schemas/Subject" }, - "id": { - "type": "string" - }, "latest_version": { - "description": "Highest committed version; 0 before the first commit.", + "description": "Latest version.", "type": "integer" }, "slug": { @@ -363,7 +360,6 @@ } }, "required": [ - "id", "slug", "title", "latest_version", @@ -8051,7 +8047,7 @@ }, "/api/v1/artifacts": { "get": { - "description": "List artifacts created by the caller, most recently updated first.", + "description": "List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range.", "parameters": [ { "description": "Page size. Defaults to 25", @@ -8075,6 +8071,72 @@ "description": "Opaque token from a previous response `next_page_token`.", "type": "string" } + }, + { + "description": "When set, only artifacts created in this session are returned.", + "in": "query", + "name": "created_by_session_id", + "required": false, + "schema": { + "description": "When set, only artifacts created in this session are returned.", + "minLength": 1, + "type": "string" + } + }, + { + "description": "Case-insensitive substring match on artifact title.", + "in": "query", + "name": "title", + "required": false, + "schema": { + "description": "Case-insensitive substring match on artifact title.", + "minLength": 1, + "type": "string" + } + }, + { + "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "in": "query", + "name": "last_updated_from", + "required": false, + "schema": { + "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "in": "query", + "name": "last_updated_to", + "required": false, + "schema": { + "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "in": "query", + "name": "created_from", + "required": false, + "schema": { + "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "in": "query", + "name": "created_to", + "required": false, + "schema": { + "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "format": "date-time", + "type": "string" + } } ], "responses": { diff --git a/docs/openapi.json b/docs/openapi.json index 640f332ba8..0a6685afa8 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -344,11 +344,8 @@ "created_by_subject": { "$ref": "#/components/schemas/Subject" }, - "id": { - "type": "string" - }, "latest_version": { - "description": "Highest committed version; 0 before the first commit.", + "description": "Latest version.", "type": "integer" }, "slug": { @@ -363,7 +360,6 @@ } }, "required": [ - "id", "slug", "title", "latest_version", @@ -8051,7 +8047,7 @@ }, "/api/v1/artifacts": { "get": { - "description": "List artifacts created by the caller, most recently updated first.", + "description": "List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range.", "parameters": [ { "description": "Page size. Defaults to 25", @@ -8075,6 +8071,72 @@ "description": "Opaque token from a previous response `next_page_token`.", "type": "string" } + }, + { + "description": "When set, only artifacts created in this session are returned.", + "in": "query", + "name": "created_by_session_id", + "required": false, + "schema": { + "description": "When set, only artifacts created in this session are returned.", + "minLength": 1, + "type": "string" + } + }, + { + "description": "Case-insensitive substring match on artifact title.", + "in": "query", + "name": "title", + "required": false, + "schema": { + "description": "Case-insensitive substring match on artifact title.", + "minLength": 1, + "type": "string" + } + }, + { + "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "in": "query", + "name": "last_updated_from", + "required": false, + "schema": { + "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "in": "query", + "name": "last_updated_to", + "required": false, + "schema": { + "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "in": "query", + "name": "created_from", + "required": false, + "schema": { + "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "in": "query", + "name": "created_to", + "required": false, + "schema": { + "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", + "format": "date-time", + "type": "string" + } } ], "responses": { diff --git a/packages/trueforge-sdk/reference.md b/packages/trueforge-sdk/reference.md index 30aa65afb6..4e4a1a2b24 100644 --- a/packages/trueforge-sdk/reference.md +++ b/packages/trueforge-sdk/reference.md @@ -429,7 +429,7 @@ await client.agents.delete("agent_id");
-List artifacts created by the caller, most recently updated first. +List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range.
diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts index 62946a225e..cb53f2df63 100644 --- a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts @@ -23,7 +23,7 @@ export class ArtifactsClient { } /** - * List artifacts created by the caller, most recently updated first. + * List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range. * * @param {TrueForge.ListArtifactsRequest} request * @param {ArtifactsClient.RequestOptions} requestOptions - Request-specific configuration. @@ -44,10 +44,25 @@ export class ArtifactsClient { async ( request: TrueForge.ListArtifactsRequest, ): Promise> => { - const { limit = 25, pageToken } = request; + const { + limit = 25, + pageToken, + createdBySessionId, + title, + lastUpdatedFrom, + lastUpdatedTo, + createdFrom, + createdTo, + } = request; const _queryParams: Record = { limit, page_token: pageToken, + created_by_session_id: createdBySessionId, + title, + last_updated_from: lastUpdatedFrom != null ? lastUpdatedFrom?.toISOString() : undefined, + last_updated_to: lastUpdatedTo != null ? lastUpdatedTo?.toISOString() : undefined, + created_from: createdFrom != null ? createdFrom?.toISOString() : undefined, + created_to: createdTo != null ? createdTo?.toISOString() : undefined, }; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts index edb251d5e7..a77858e4af 100644 --- a/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts @@ -9,4 +9,16 @@ export interface ListArtifactsRequest { limit?: number; /** Opaque token from a previous response `next_page_token`. */ pageToken?: string; + /** When set, only artifacts created in this session are returned. */ + createdBySessionId?: string; + /** Case-insensitive substring match on artifact title. */ + title?: string; + /** Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. */ + lastUpdatedFrom?: Date; + /** Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. */ + lastUpdatedTo?: Date; + /** Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. */ + createdFrom?: Date; + /** Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. */ + createdTo?: Date; } diff --git a/packages/trueforge-sdk/src/api/types/Artifact.ts b/packages/trueforge-sdk/src/api/types/Artifact.ts index 0cef10dd4d..965c19be67 100644 --- a/packages/trueforge-sdk/src/api/types/Artifact.ts +++ b/packages/trueforge-sdk/src/api/types/Artifact.ts @@ -6,8 +6,7 @@ export interface Artifact { createdAt: Date; createdBySessionId: string; createdBySubject: TrueForge.Subject; - id: string; - /** Highest committed version; 0 before the first commit. */ + /** Latest version. */ latestVersion: number; slug: string; title: string; diff --git a/packages/trueforge-sdk/src/serialization/types/Artifact.ts b/packages/trueforge-sdk/src/serialization/types/Artifact.ts index bb83afe7ee..43c811fc7f 100644 --- a/packages/trueforge-sdk/src/serialization/types/Artifact.ts +++ b/packages/trueforge-sdk/src/serialization/types/Artifact.ts @@ -10,7 +10,6 @@ export const Artifact: core.serialization.ObjectSchema { subject_id: "subject_id", subject_type: "subject_type", }, - id: "id", latest_version: 1, slug: "slug", title: "title", @@ -47,7 +46,6 @@ describe("ArtifactsClient", () => { subjectId: "subject_id", subjectType: "subject_type", }, - id: "id", latestVersion: 1, slug: "slug", title: "title", diff --git a/python/trueforge_sdk/reference.md b/python/trueforge_sdk/reference.md index 4aee63017c..b87c72bae0 100644 --- a/python/trueforge_sdk/reference.md +++ b/python/trueforge_sdk/reference.md @@ -514,7 +514,7 @@ client.agents.delete(
-List artifacts created by the caller, most recently updated first. +List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range.
@@ -568,6 +568,54 @@ client.artifacts.list()
+**created_by_session_id:** `typing.Optional[str]` — When set, only artifacts created in this session are returned. + +
+
+ +
+
+ +**title:** `typing.Optional[str]` — Case-insensitive substring match on artifact title. + +
+
+ +
+
+ +**last_updated_from:** `typing.Optional[datetime.datetime]` — Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + +
+
+ +
+
+ +**last_updated_to:** `typing.Optional[datetime.datetime]` — Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + +
+
+ +
+
+ +**created_from:** `typing.Optional[datetime.datetime]` — Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + +
+
+ +
+
+ +**created_to:** `typing.Optional[datetime.datetime]` — Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py index 1df50fa93d..530b7f28bf 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. +import datetime as dt import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -30,10 +31,16 @@ def list( *, limit: typing.Optional[int] = 25, page_token: typing.Optional[str] = None, + created_by_session_id: typing.Optional[str] = None, + title: typing.Optional[str] = None, + last_updated_from: typing.Optional[dt.datetime] = None, + last_updated_to: typing.Optional[dt.datetime] = None, + created_from: typing.Optional[dt.datetime] = None, + created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Artifact, ListArtifactsResponse]: """ - List artifacts created by the caller, most recently updated first. + List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range. Parameters ---------- @@ -43,6 +50,24 @@ def list( page_token : typing.Optional[str] Opaque token from a previous response `next_page_token`. + created_by_session_id : typing.Optional[str] + When set, only artifacts created in this session are returned. + + title : typing.Optional[str] + Case-insensitive substring match on artifact title. + + last_updated_from : typing.Optional[dt.datetime] + Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + last_updated_to : typing.Optional[dt.datetime] + Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + created_from : typing.Optional[dt.datetime] + Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + + created_to : typing.Optional[dt.datetime] + Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -66,7 +91,17 @@ def list( for page in response.iter_pages(): yield page """ - return self._raw_client.list(limit=limit, page_token=page_token, request_options=request_options) + return self._raw_client.list( + limit=limit, + page_token=page_token, + created_by_session_id=created_by_session_id, + title=title, + last_updated_from=last_updated_from, + last_updated_to=last_updated_to, + created_from=created_from, + created_to=created_to, + request_options=request_options, + ) class AsyncArtifactsClient: @@ -89,10 +124,16 @@ async def list( *, limit: typing.Optional[int] = 25, page_token: typing.Optional[str] = None, + created_by_session_id: typing.Optional[str] = None, + title: typing.Optional[str] = None, + last_updated_from: typing.Optional[dt.datetime] = None, + last_updated_to: typing.Optional[dt.datetime] = None, + created_from: typing.Optional[dt.datetime] = None, + created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Artifact, ListArtifactsResponse]: """ - List artifacts created by the caller, most recently updated first. + List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range. Parameters ---------- @@ -102,6 +143,24 @@ async def list( page_token : typing.Optional[str] Opaque token from a previous response `next_page_token`. + created_by_session_id : typing.Optional[str] + When set, only artifacts created in this session are returned. + + title : typing.Optional[str] + Case-insensitive substring match on artifact title. + + last_updated_from : typing.Optional[dt.datetime] + Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + last_updated_to : typing.Optional[dt.datetime] + Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + created_from : typing.Optional[dt.datetime] + Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + + created_to : typing.Optional[dt.datetime] + Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -134,4 +193,14 @@ async def main() -> None: asyncio.run(main()) """ - return await self._raw_client.list(limit=limit, page_token=page_token, request_options=request_options) + return await self._raw_client.list( + limit=limit, + page_token=page_token, + created_by_session_id=created_by_session_id, + title=title, + last_updated_from=last_updated_from, + last_updated_to=last_updated_to, + created_from=created_from, + created_to=created_to, + request_options=request_options, + ) diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py index 45266d40b9..869dae93dd 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py @@ -1,10 +1,12 @@ # This file was auto-generated by Fern from our API Definition. +import datetime as dt import typing from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.datetime_utils import serialize_datetime from ..core.pagination import AsyncPager, SyncPager from ..core.parse_error import ParsingError from ..core.request_options import RequestOptions @@ -26,10 +28,16 @@ def list( *, limit: typing.Optional[int] = 25, page_token: typing.Optional[str] = None, + created_by_session_id: typing.Optional[str] = None, + title: typing.Optional[str] = None, + last_updated_from: typing.Optional[dt.datetime] = None, + last_updated_to: typing.Optional[dt.datetime] = None, + created_from: typing.Optional[dt.datetime] = None, + created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Artifact, ListArtifactsResponse]: """ - List artifacts created by the caller, most recently updated first. + List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range. Parameters ---------- @@ -39,6 +47,24 @@ def list( page_token : typing.Optional[str] Opaque token from a previous response `next_page_token`. + created_by_session_id : typing.Optional[str] + When set, only artifacts created in this session are returned. + + title : typing.Optional[str] + Case-insensitive substring match on artifact title. + + last_updated_from : typing.Optional[dt.datetime] + Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + last_updated_to : typing.Optional[dt.datetime] + Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + created_from : typing.Optional[dt.datetime] + Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + + created_to : typing.Optional[dt.datetime] + Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -53,6 +79,12 @@ def list( params={ "limit": limit, "page_token": page_token, + "created_by_session_id": created_by_session_id, + "title": title, + "last_updated_from": serialize_datetime(last_updated_from) if last_updated_from is not None else None, + "last_updated_to": serialize_datetime(last_updated_to) if last_updated_to is not None else None, + "created_from": serialize_datetime(created_from) if created_from is not None else None, + "created_to": serialize_datetime(created_to) if created_to is not None else None, }, request_options=request_options, ) @@ -74,6 +106,12 @@ def list( _get_next = lambda: self.list( limit=limit, page_token=_parsed_next, + created_by_session_id=created_by_session_id, + title=title, + last_updated_from=last_updated_from, + last_updated_to=last_updated_to, + created_from=created_from, + created_to=created_to, request_options=request_options, ) return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) @@ -118,10 +156,16 @@ async def list( *, limit: typing.Optional[int] = 25, page_token: typing.Optional[str] = None, + created_by_session_id: typing.Optional[str] = None, + title: typing.Optional[str] = None, + last_updated_from: typing.Optional[dt.datetime] = None, + last_updated_to: typing.Optional[dt.datetime] = None, + created_from: typing.Optional[dt.datetime] = None, + created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Artifact, ListArtifactsResponse]: """ - List artifacts created by the caller, most recently updated first. + List artifacts created by the caller, most recently updated first. Optionally filter by session, title substring, or `updated_at` range. Parameters ---------- @@ -131,6 +175,24 @@ async def list( page_token : typing.Optional[str] Opaque token from a previous response `next_page_token`. + created_by_session_id : typing.Optional[str] + When set, only artifacts created in this session are returned. + + title : typing.Optional[str] + Case-insensitive substring match on artifact title. + + last_updated_from : typing.Optional[dt.datetime] + Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + last_updated_to : typing.Optional[dt.datetime] + Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. + + created_from : typing.Optional[dt.datetime] + Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + + created_to : typing.Optional[dt.datetime] + Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -145,6 +207,12 @@ async def list( params={ "limit": limit, "page_token": page_token, + "created_by_session_id": created_by_session_id, + "title": title, + "last_updated_from": serialize_datetime(last_updated_from) if last_updated_from is not None else None, + "last_updated_to": serialize_datetime(last_updated_to) if last_updated_to is not None else None, + "created_from": serialize_datetime(created_from) if created_from is not None else None, + "created_to": serialize_datetime(created_to) if created_to is not None else None, }, request_options=request_options, ) @@ -168,6 +236,12 @@ async def _get_next(): return await self.list( limit=limit, page_token=_parsed_next, + created_by_session_id=created_by_session_id, + title=title, + last_updated_from=last_updated_from, + last_updated_to=last_updated_to, + created_from=created_from, + created_to=created_to, request_options=request_options, ) diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py b/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py index 092648c3de..6b8b8ec40f 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py +++ b/python/trueforge_sdk/src/trueforge_sdk/types/artifact.py @@ -13,10 +13,9 @@ class Artifact(UncheckedBaseModel): created_at: dt.datetime created_by_session_id: str created_by_subject: Subject - id: str latest_version: int = pydantic.Field() """ - Highest committed version; 0 before the first commit. + Latest version. """ slug: str From 45d1a32a85741183283a0bd5f7dc1b48bed24043 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:17:00 +0530 Subject: [PATCH 11/12] [AGE-2886] Remove time-range filters from artifact list API Co-authored-by: Cursor --- packages/trueforge/src/apis/artifacts.ts | 4 ---- packages/trueforge/src/schemas/artifact.ts | 20 +------------------ packages/trueforge/src/schemas/common.ts | 6 ------ packages/trueforge/src/schemas/session.ts | 8 +++++++- .../trueforge/src/schemas/sessionMetrics.ts | 7 ++++++- .../tests/unit/apis/artifacts.test.ts | 18 ++--------------- 6 files changed, 16 insertions(+), 47 deletions(-) diff --git a/packages/trueforge/src/apis/artifacts.ts b/packages/trueforge/src/apis/artifacts.ts index 98c541aa37..86540d9100 100644 --- a/packages/trueforge/src/apis/artifacts.ts +++ b/packages/trueforge/src/apis/artifacts.ts @@ -33,10 +33,6 @@ export function createArtifactsRouter(deps: ArtifactsRouterDeps) { created_by_subject_id: requestContext.subject.id, created_by_session_id: query.created_by_session_id, title: query.title, - last_updated_from: query.last_updated_from, - last_updated_to: query.last_updated_to, - created_from: query.created_from, - created_to: query.created_to, limit: query.limit, page_token: query.page_token, }); diff --git a/packages/trueforge/src/schemas/artifact.ts b/packages/trueforge/src/schemas/artifact.ts index 70c16249f5..8c78c419b0 100644 --- a/packages/trueforge/src/schemas/artifact.ts +++ b/packages/trueforge/src/schemas/artifact.ts @@ -1,6 +1,6 @@ import { z } from '@hono/zod-openapi'; import { SubjectSchema, TokenPaginationSchema } from '@truefoundry/trueforge-core/agent-session'; -import { IsoTimestampQueryParam, PAGE_LIMIT } from './common'; +import { PAGE_LIMIT } from './common'; export const ArtifactSchema = z .object({ @@ -34,25 +34,7 @@ export const ListArtifactsRequestQuerySchema = z .optional() .describe('When set, only artifacts created in this session are returned.'), title: z.string().trim().min(1).optional().describe('Case-insensitive substring match on artifact title.'), - last_updated_from: IsoTimestampQueryParam.optional().describe( - 'Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.', - ), - last_updated_to: IsoTimestampQueryParam.optional().describe( - 'Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.', - ), - created_from: IsoTimestampQueryParam.optional().describe( - 'Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.', - ), - created_to: IsoTimestampQueryParam.optional().describe( - 'Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.', - ), }) - .refine( - q => - (q.last_updated_from === undefined && q.last_updated_to === undefined) || - (q.created_from === undefined && q.created_to === undefined), - { message: 'Pass only one of the last_updated or created time ranges.' }, - ) .openapi('ListArtifactsRequestQuery'); export const ListArtifactsResponseSchema = z diff --git a/packages/trueforge/src/schemas/common.ts b/packages/trueforge/src/schemas/common.ts index e5855c92b5..a005191752 100644 --- a/packages/trueforge/src/schemas/common.ts +++ b/packages/trueforge/src/schemas/common.ts @@ -29,12 +29,6 @@ export type ResourceName = z.infer; /** Session and artifact titles; matches auto-derived titles from the first user message on turn 1. */ export const MAX_TITLE_LENGTH = 50; -/** Wire ISO-8601 (RFC 3339, offsets allowed) → Date for the store. */ -export const IsoTimestampQueryParam = z.iso - .datetime({ offset: true }) - .openapi({ type: 'string', format: 'date-time' }) - .transform(s => new Date(s)); - export const PAGE_LIMIT = 25; /** Session/turn event list page size; default and max are read from config per request, so not baked into OpenAPI. */ export const EventsPageLimitQuerySchema = z.coerce diff --git a/packages/trueforge/src/schemas/session.ts b/packages/trueforge/src/schemas/session.ts index da3f0e076e..42b59c1675 100644 --- a/packages/trueforge/src/schemas/session.ts +++ b/packages/trueforge/src/schemas/session.ts @@ -8,7 +8,7 @@ import { SessionSourceTypeSchema, TokenPaginationSchema, } from '@truefoundry/trueforge-core/agent-session'; -import { IsoTimestampQueryParam, MAX_TITLE_LENGTH, NameSchema, PAGE_LIMIT } from './common'; +import { MAX_TITLE_LENGTH, NameSchema, PAGE_LIMIT } from './common'; import { foldDeepObjectQueryParam } from './deepObjectQuery'; /** Create arm: bind by unique registry agent name. */ @@ -70,6 +70,12 @@ export const UpdateSessionRequestSchema = z export type { Session } from '@truefoundry/trueforge-core/agent-session'; +/** Wire ISO-8601 (RFC 3339, offsets allowed) → Date for the store. */ +const IsoTimestampQueryParam = z.iso + .datetime({ offset: true }) + .openapi({ type: 'string', format: 'date-time' }) + .transform(s => new Date(s)); + /** Max metadata equality filters on list sessions (clause-budget style). */ export const LIST_SESSIONS_METADATA_FILTER_MAX_KEYS = 10; diff --git a/packages/trueforge/src/schemas/sessionMetrics.ts b/packages/trueforge/src/schemas/sessionMetrics.ts index d898fe4261..af4e26f99a 100644 --- a/packages/trueforge/src/schemas/sessionMetrics.ts +++ b/packages/trueforge/src/schemas/sessionMetrics.ts @@ -3,7 +3,6 @@ * Per-session counters (`SessionMetrics`) stay in trueforge-core. */ import { z } from '@hono/zod-openapi'; -import { IsoTimestampQueryParam } from './common'; /** Max inclusive created_at window for session metrics aggregation (30 days). */ export const MAX_SESSION_METRICS_WINDOW_MS = 30 * 24 * 60 * 60 * 1000; @@ -107,6 +106,12 @@ export const SessionMetricsChartDataResponseSchema = z .strict() .openapi('SessionMetricsChartDataResponse'); +/** Wire ISO-8601 (RFC 3339, offsets allowed) → Date for metrics window bounds. */ +const IsoTimestampQueryParam = z.iso + .datetime({ offset: true }) + .openapi({ type: 'string', format: 'date-time' }) + .transform(s => new Date(s)); + const GetSessionMetricsRequestQueryObjectSchema = z.object({ agent_id: z.string().min(1).max(64).describe('Named agent identifier.'), start_timestamp: IsoTimestampQueryParam.describe('Inclusive lower bound on session `created_at`.'), diff --git a/packages/trueforge/tests/unit/apis/artifacts.test.ts b/packages/trueforge/tests/unit/apis/artifacts.test.ts index d143612205..8f31b244e5 100644 --- a/packages/trueforge/tests/unit/apis/artifacts.test.ts +++ b/packages/trueforge/tests/unit/apis/artifacts.test.ts @@ -1,6 +1,5 @@ import { createArtifactsRouter } from '../../../src/apis/artifacts'; import { createdBySubjectFromRequestContext, STANDALONE_REQUEST_CONTEXT } from '../../../src/auth/identity'; -import type { ArtifactRecord } from '../../../src/db/artifactStore'; import { migrateSqliteToLatest } from '../../../src/db/migrateSqlite'; import { SqliteArtifactStore } from '../../../src/db/sqlite/artifact-store/SqliteArtifactStore'; import { createSqliteDb } from '../../../src/db/sqlite/client'; @@ -9,7 +8,6 @@ import { mountWithErrorHandler } from '../mountWithErrorHandler'; describe('artifacts router', () => { let app: ReturnType; - let report: ArtifactRecord; async function listTitles(query: string): Promise { const response = await app.request(`/?${query}`); @@ -27,8 +25,7 @@ describe('artifacts router', () => { tenant_id: STANDALONE_REQUEST_CONTEXT.tenant_id, created_by_subject: createdBySubjectFromRequestContext(STANDALONE_REQUEST_CONTEXT), }; - report = await artifactStore.createArtifact({ ...mine, title: 'Q3 Report', created_by_session_id: 'session-1' }); - await new Promise(resolve => setTimeout(resolve, 5)); + await artifactStore.createArtifact({ ...mine, title: 'Q3 Report', created_by_session_id: 'session-1' }); await artifactStore.createArtifact({ ...mine, title: 'Roadmap', created_by_session_id: 'session-2' }); await artifactStore.createArtifact({ ...mine, @@ -58,18 +55,7 @@ describe('artifacts router', () => { expect(await listTitles('title=report')).toEqual(['Q3 Report']); }); - it('filters by last-updated or created range', async () => { - const boundary = encodeURIComponent(new Date(Date.parse(report.updated_at) + 1).toISOString()); - expect(await listTitles(`last_updated_from=${boundary}`)).toEqual(['Roadmap']); - expect(await listTitles(`last_updated_to=${boundary}`)).toEqual(['Q3 Report']); - expect(await listTitles(`created_from=${boundary}`)).toEqual(['Roadmap']); - expect(await listTitles(`created_to=${boundary}`)).toEqual(['Q3 Report']); - }); - - it('rejects an invalid page token, timestamp, or combined time ranges', async () => { + it('rejects an invalid page token', async () => { expect((await app.request('/?page_token=not-a-token')).status).toBe(400); - expect((await app.request('/?last_updated_from=yesterday')).status).toBe(400); - const now = encodeURIComponent(new Date().toISOString()); - expect((await app.request(`/?last_updated_from=${now}&created_to=${now}`)).status).toBe(400); }); }); From 414c33dc3365e7d465ad0303fa583fd3c25d2097 Mon Sep 17 00:00:00 2001 From: Rutvij Menavlikar <174306281+rutvij-menavlikar@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:18:22 +0530 Subject: [PATCH 12/12] Regenerate OpenAPI document and SDKs Co-authored-by: Cursor --- .github/fern/openapi/openapi.json | 44 ---------------- docs/openapi.json | 44 ---------------- .../api/resources/artifacts/client/Client.ts | 15 +----- .../client/requests/ListArtifactsRequest.ts | 8 --- python/trueforge_sdk/reference.md | 32 ------------ .../src/trueforge_sdk/artifacts/client.py | 41 --------------- .../src/trueforge_sdk/artifacts/raw_client.py | 50 ------------------- 7 files changed, 1 insertion(+), 233 deletions(-) diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json index 0a6685afa8..c3fd5cf7c4 100644 --- a/.github/fern/openapi/openapi.json +++ b/.github/fern/openapi/openapi.json @@ -8093,50 +8093,6 @@ "minLength": 1, "type": "string" } - }, - { - "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "in": "query", - "name": "last_updated_from", - "required": false, - "schema": { - "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "format": "date-time", - "type": "string" - } - }, - { - "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "in": "query", - "name": "last_updated_to", - "required": false, - "schema": { - "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "format": "date-time", - "type": "string" - } - }, - { - "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "in": "query", - "name": "created_from", - "required": false, - "schema": { - "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "format": "date-time", - "type": "string" - } - }, - { - "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "in": "query", - "name": "created_to", - "required": false, - "schema": { - "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "format": "date-time", - "type": "string" - } } ], "responses": { diff --git a/docs/openapi.json b/docs/openapi.json index 0a6685afa8..c3fd5cf7c4 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -8093,50 +8093,6 @@ "minLength": 1, "type": "string" } - }, - { - "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "in": "query", - "name": "last_updated_from", - "required": false, - "schema": { - "description": "Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "format": "date-time", - "type": "string" - } - }, - { - "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "in": "query", - "name": "last_updated_to", - "required": false, - "schema": { - "description": "Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`.", - "format": "date-time", - "type": "string" - } - }, - { - "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "in": "query", - "name": "created_from", - "required": false, - "schema": { - "description": "Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "format": "date-time", - "type": "string" - } - }, - { - "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "in": "query", - "name": "created_to", - "required": false, - "schema": { - "description": "Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`.", - "format": "date-time", - "type": "string" - } } ], "responses": { diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts index cb53f2df63..9ef598894e 100644 --- a/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/Client.ts @@ -44,25 +44,12 @@ export class ArtifactsClient { async ( request: TrueForge.ListArtifactsRequest, ): Promise> => { - const { - limit = 25, - pageToken, - createdBySessionId, - title, - lastUpdatedFrom, - lastUpdatedTo, - createdFrom, - createdTo, - } = request; + const { limit = 25, pageToken, createdBySessionId, title } = request; const _queryParams: Record = { limit, page_token: pageToken, created_by_session_id: createdBySessionId, title, - last_updated_from: lastUpdatedFrom != null ? lastUpdatedFrom?.toISOString() : undefined, - last_updated_to: lastUpdatedTo != null ? lastUpdatedTo?.toISOString() : undefined, - created_from: createdFrom != null ? createdFrom?.toISOString() : undefined, - created_to: createdTo != null ? createdTo?.toISOString() : undefined, }; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( diff --git a/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts index a77858e4af..061303826d 100644 --- a/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts +++ b/packages/trueforge-sdk/src/api/resources/artifacts/client/requests/ListArtifactsRequest.ts @@ -13,12 +13,4 @@ export interface ListArtifactsRequest { createdBySessionId?: string; /** Case-insensitive substring match on artifact title. */ title?: string; - /** Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. */ - lastUpdatedFrom?: Date; - /** Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. */ - lastUpdatedTo?: Date; - /** Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. */ - createdFrom?: Date; - /** Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. */ - createdTo?: Date; } diff --git a/python/trueforge_sdk/reference.md b/python/trueforge_sdk/reference.md index b87c72bae0..bd915fa166 100644 --- a/python/trueforge_sdk/reference.md +++ b/python/trueforge_sdk/reference.md @@ -584,38 +584,6 @@ client.artifacts.list()
-**last_updated_from:** `typing.Optional[datetime.datetime]` — Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - -
-
- -
-
- -**last_updated_to:** `typing.Optional[datetime.datetime]` — Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - -
-
- -
-
- -**created_from:** `typing.Optional[datetime.datetime]` — Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - -
-
- -
-
- -**created_to:** `typing.Optional[datetime.datetime]` — Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - -
-
- -
-
- **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py index 530b7f28bf..1afadb1611 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/client.py @@ -1,6 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper @@ -33,10 +32,6 @@ def list( page_token: typing.Optional[str] = None, created_by_session_id: typing.Optional[str] = None, title: typing.Optional[str] = None, - last_updated_from: typing.Optional[dt.datetime] = None, - last_updated_to: typing.Optional[dt.datetime] = None, - created_from: typing.Optional[dt.datetime] = None, - created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Artifact, ListArtifactsResponse]: """ @@ -56,18 +51,6 @@ def list( title : typing.Optional[str] Case-insensitive substring match on artifact title. - last_updated_from : typing.Optional[dt.datetime] - Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - last_updated_to : typing.Optional[dt.datetime] - Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - created_from : typing.Optional[dt.datetime] - Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - - created_to : typing.Optional[dt.datetime] - Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -96,10 +79,6 @@ def list( page_token=page_token, created_by_session_id=created_by_session_id, title=title, - last_updated_from=last_updated_from, - last_updated_to=last_updated_to, - created_from=created_from, - created_to=created_to, request_options=request_options, ) @@ -126,10 +105,6 @@ async def list( page_token: typing.Optional[str] = None, created_by_session_id: typing.Optional[str] = None, title: typing.Optional[str] = None, - last_updated_from: typing.Optional[dt.datetime] = None, - last_updated_to: typing.Optional[dt.datetime] = None, - created_from: typing.Optional[dt.datetime] = None, - created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Artifact, ListArtifactsResponse]: """ @@ -149,18 +124,6 @@ async def list( title : typing.Optional[str] Case-insensitive substring match on artifact title. - last_updated_from : typing.Optional[dt.datetime] - Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - last_updated_to : typing.Optional[dt.datetime] - Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - created_from : typing.Optional[dt.datetime] - Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - - created_to : typing.Optional[dt.datetime] - Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -198,9 +161,5 @@ async def main() -> None: page_token=page_token, created_by_session_id=created_by_session_id, title=title, - last_updated_from=last_updated_from, - last_updated_to=last_updated_to, - created_from=created_from, - created_to=created_to, request_options=request_options, ) diff --git a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py index 869dae93dd..08874d00fd 100644 --- a/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py +++ b/python/trueforge_sdk/src/trueforge_sdk/artifacts/raw_client.py @@ -1,12 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt import typing from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.datetime_utils import serialize_datetime from ..core.pagination import AsyncPager, SyncPager from ..core.parse_error import ParsingError from ..core.request_options import RequestOptions @@ -30,10 +28,6 @@ def list( page_token: typing.Optional[str] = None, created_by_session_id: typing.Optional[str] = None, title: typing.Optional[str] = None, - last_updated_from: typing.Optional[dt.datetime] = None, - last_updated_to: typing.Optional[dt.datetime] = None, - created_from: typing.Optional[dt.datetime] = None, - created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Artifact, ListArtifactsResponse]: """ @@ -53,18 +47,6 @@ def list( title : typing.Optional[str] Case-insensitive substring match on artifact title. - last_updated_from : typing.Optional[dt.datetime] - Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - last_updated_to : typing.Optional[dt.datetime] - Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - created_from : typing.Optional[dt.datetime] - Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - - created_to : typing.Optional[dt.datetime] - Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -81,10 +63,6 @@ def list( "page_token": page_token, "created_by_session_id": created_by_session_id, "title": title, - "last_updated_from": serialize_datetime(last_updated_from) if last_updated_from is not None else None, - "last_updated_to": serialize_datetime(last_updated_to) if last_updated_to is not None else None, - "created_from": serialize_datetime(created_from) if created_from is not None else None, - "created_to": serialize_datetime(created_to) if created_to is not None else None, }, request_options=request_options, ) @@ -108,10 +86,6 @@ def list( page_token=_parsed_next, created_by_session_id=created_by_session_id, title=title, - last_updated_from=last_updated_from, - last_updated_to=last_updated_to, - created_from=created_from, - created_to=created_to, request_options=request_options, ) return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) @@ -158,10 +132,6 @@ async def list( page_token: typing.Optional[str] = None, created_by_session_id: typing.Optional[str] = None, title: typing.Optional[str] = None, - last_updated_from: typing.Optional[dt.datetime] = None, - last_updated_to: typing.Optional[dt.datetime] = None, - created_from: typing.Optional[dt.datetime] = None, - created_to: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Artifact, ListArtifactsResponse]: """ @@ -181,18 +151,6 @@ async def list( title : typing.Optional[str] Case-insensitive substring match on artifact title. - last_updated_from : typing.Optional[dt.datetime] - Inclusive lower bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - last_updated_to : typing.Optional[dt.datetime] - Inclusive upper bound on `updated_at` (ISO-8601 / RFC 3339). Cannot be combined with `created_from` or `created_to`. - - created_from : typing.Optional[dt.datetime] - Inclusive lower bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - - created_to : typing.Optional[dt.datetime] - Inclusive upper bound on `created_at` (ISO-8601 / RFC 3339). Cannot be combined with `last_updated_from` or `last_updated_to`. - request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -209,10 +167,6 @@ async def list( "page_token": page_token, "created_by_session_id": created_by_session_id, "title": title, - "last_updated_from": serialize_datetime(last_updated_from) if last_updated_from is not None else None, - "last_updated_to": serialize_datetime(last_updated_to) if last_updated_to is not None else None, - "created_from": serialize_datetime(created_from) if created_from is not None else None, - "created_to": serialize_datetime(created_to) if created_to is not None else None, }, request_options=request_options, ) @@ -238,10 +192,6 @@ async def _get_next(): page_token=_parsed_next, created_by_session_id=created_by_session_id, title=title, - last_updated_from=last_updated_from, - last_updated_to=last_updated_to, - created_from=created_from, - created_to=created_to, request_options=request_options, )