🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat: add new /api/public/organizations/projects route to list projects (#6997)
Steffen Schmitz720ed7a36f3e
diff --git a/fern/apis/server/definition/observations.yml b/fern/apis/server/definition/observations.ymlindex 7d9297852a..d0c4423440 100644--- a/fern/apis/server/definition/observations.yml+++ b/fern/apis/server/definition/observations.yml@@ -39,7 +39,7 @@ service:docs: Optional filter for observations where the environment is one of the provided values.fromStartTime:type: optional<datetime>- docs: Retrieve only observations with a start_time or or after this datetime (ISO 8601).+ docs: Retrieve only observations with a start_time on or after this datetime (ISO 8601).toStartTime:type: optional<datetime>docs: Retrieve only observations with a start_time before this datetime (ISO 8601).diff --git a/fern/apis/server/definition/memberships.yml b/fern/apis/server/definition/organizations.ymlsimilarity index 75%rename from fern/apis/server/definition/memberships.ymlrename to fern/apis/server/definition/organizations.ymlindex 3c40016ee0..1a3fd3ccab 100644--- a/fern/apis/server/definition/memberships.yml+++ b/fern/apis/server/definition/organizations.yml@@ -37,6 +37,12 @@ service:request: MembershipRequestresponse: MembershipResponse+ getOrganizationProjects:+ docs: Get all projects for the organization associated with the API key (requires organization-scoped API key)+ method: GET+ path: /organizations/projects+ response: OrganizationProjectsResponse+types:MembershipRole:enum:@@ -59,4 +65,16 @@ types:MembershipsResponse:properties:- memberships: list<MembershipResponse>\ No newline at end of file+ memberships: list<MembershipResponse>++ OrganizationProject:+ properties:+ id: string+ name: string+ metadata: optional<map<string, unknown>>+ createdAt: datetime+ updatedAt: datetime++ OrganizationProjectsResponse:+ properties:+ projects: list<OrganizationProject>\ No newline at end of filediff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.ymlindex 067d7ea0b2..f3de64642d 100644--- a/web/public/generated/api/openapi.yml+++ b/web/public/generated/api/openapi.yml@@ -1564,22 +1564,67 @@ paths:application/json:schema:$ref: '#/components/schemas/GetMediaUploadUrlRequest'- /api/public/organizations/memberships:+ /api/public/metrics:get:- description: >-- Get all memberships for the organization associated with the API key- (requires organization-scoped API key)- operationId: memberships_getOrganizationMemberships+ description: Get metrics from the Langfuse project using a query object+ operationId: metrics_metricstags:- - Memberships- parameters: []+ - Metrics+ parameters:+ - name: query+ in: query+ description: >-+ JSON string containing the query parameters with the following+ structure:++ ```json++ {+ "view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"+ "dimensions": [ // Optional. Default: []+ {+ "field": string // Field to group by, e.g. "name", "userId", "sessionId"+ }+ ],+ "metrics": [ // Required. At least one metric must be provided+ {+ "measure": string, // What to measure, e.g. "count", "latency", "value"+ "aggregation": string // How to aggregate, e.g. "count", "sum", "avg", "p95"+ }+ ],+ "filters": [ // Optional. Default: []+ {+ "column": string, // Column to filter on+ "operator": string, // Operator, e.g. "=", ">", "<", "contains"+ "value": any, // Value to compare against+ "type": string, // Data type, e.g. "string", "number", "stringObject"+ "key": string // Required only when filtering on metadata+ }+ ],+ "timeDimension": { // Optional. Default: null. If provided, results will be grouped by time+ "granularity": string // One of "minute", "hour", "day", "week", "month", "auto"+ },+ "fromTimestamp": string, // Required. ISO datetime string for start of time range+ "toTimestamp": string, // Required. ISO datetime string for end of time range+ "orderBy": [ // Optional. Default: null+ {+ "field": string, // Field to order by+ "direction": string // "asc" or "desc"+ }+ ]+ }++ ```+ required: true+ schema:+ type: stringresponses:'200':description: ''content:application/json:schema:- $ref: '#/components/schemas/MembershipsResponse'+ $ref: '#/components/schemas/MetricsResponse''400':description: ''content:@@ -1607,13 +1652,12 @@ paths:schema: {}security:- BasicAuth: []- put:- description: >-- Create or update a membership for the organization associated with the- API key (requires organization-scoped API key)- operationId: memberships_updateOrganizationMembership+ /api/public/models:+ post:+ description: Create a model+ operationId: models_createtags:- - Memberships+ - Modelsparameters: []responses:'200':@@ -1621,7 +1665,7 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/MembershipResponse'+ $ref: '#/components/schemas/Model''400':description: ''content:@@ -1654,28 +1698,34 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/MembershipRequest'- /api/public/projects/{projectId}/memberships:+ $ref: '#/components/schemas/CreateModelRequest'get:- description: >-- Get all memberships for a specific project (requires organization-scoped- API key)- operationId: memberships_getProjectMemberships+ description: Get all models+ operationId: models_listtags:- - Memberships+ - Modelsparameters:- - name: projectId- in: path- required: true+ - name: page+ in: query+ description: page number, starts at 1+ required: falseschema:- type: string+ type: integer+ nullable: true+ - name: limit+ in: query+ description: limit of items per page+ required: false+ schema:+ type: integer+ nullable: trueresponses:'200':description: ''content:application/json:schema:- $ref: '#/components/schemas/MembershipsResponse'+ $ref: '#/components/schemas/PaginatedModels''400':description: ''content:@@ -1703,16 +1753,14 @@ paths:schema: {}security:- BasicAuth: []- put:- description: >-- Create or update a membership for a specific project (requires- organization-scoped API key). The user must already be a member of the- organization.- operationId: memberships_updateProjectMembership+ /api/public/models/{id}:+ get:+ description: Get a model+ operationId: models_gettags:- - Memberships+ - Modelsparameters:- - name: projectId+ - name: idin: pathrequired: trueschema:@@ -1723,7 +1771,7 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/MembershipResponse'+ $ref: '#/components/schemas/Model''400':description: ''content:@@ -1751,73 +1799,23 @@ paths:schema: {}security:- BasicAuth: []- requestBody:- required: true- content:- application/json:- schema:- $ref: '#/components/schemas/MembershipRequest'- /api/public/metrics:- get:- description: Get metrics from the Langfuse project using a query object- operationId: metrics_metrics+ delete:+ description: >-+ Delete a model. Cannot delete models managed by Langfuse. You can create+ your own definition with the same modelName to override the definition+ though.+ operationId: models_deletetags:- - Metrics+ - Modelsparameters:- - name: query- in: query- description: >-- JSON string containing the query parameters with the following- structure:-- ```json-- {- "view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"- "dimensions": [ // Optional. Default: []- {- "field": string // Field to group by, e.g. "name", "userId", "sessionId"- }- ],- "metrics": [ // Required. At least one metric must be provided- {- "measure": string, // What to measure, e.g. "count", "latency", "value"- "aggregation": string // How to aggregate, e.g. "count", "sum", "avg", "p95"- }- ],- "filters": [ // Optional. Default: []- {- "column": string, // Column to filter on- "operator": string, // Operator, e.g. "=", ">", "<", "contains"- "value": any, // Value to compare against- "type": string, // Data type, e.g. "string", "number", "stringObject"- "key": string // Required only when filtering on metadata- }- ],- "timeDimension": { // Optional. Default: null. If provided, results will be grouped by time- "granularity": string // One of "minute", "hour", "day", "week", "month", "auto"- },- "fromTimestamp": string, // Required. ISO datetime string for start of time range- "toTimestamp": string, // Required. ISO datetime string for end of time range- "orderBy": [ // Optional. Default: null- {- "field": string, // Field to order by- "direction": string // "asc" or "desc"- }- ]- }-- ```+ - name: id+ in: pathrequired: trueschema:type: stringresponses:- '200':+ '204':description: ''- content:- application/json:- schema:- $ref: '#/components/schemas/MetricsResponse''400':description: ''content:@@ -1845,20 +1843,28 @@ paths:schema: {}security:- BasicAuth: []- /api/public/models:- post:- description: Create a model- operationId: models_create+ /api/public/observations/{observationId}:+ get:+ description: Get a observation+ operationId: observations_gettags:- - Models- parameters: []+ - Observations+ parameters:+ - name: observationId+ in: path+ description: >-+ The unique langfuse identifier of an observation, can be an event,+ span or generation+ required: true+ schema:+ type: stringresponses:'200':description: ''content:application/json:schema:- $ref: '#/components/schemas/Model'+ $ref: '#/components/schemas/ObservationsView''400':description: ''content:@@ -1886,39 +1892,104 @@ paths:schema: {}security:- BasicAuth: []- requestBody:- required: true- content:- application/json:- schema:- $ref: '#/components/schemas/CreateModelRequest'+ /api/public/observations:get:- description: Get all models- operationId: models_list+ description: Get a list of observations+ operationId: observations_getManytags:- - Models+ - Observationsparameters:- name: pagein: query- description: page number, starts at 1+ description: Page number, starts at 1.required: falseschema:type: integernullable: true- name: limitin: query- description: limit of items per page+ description: >-+ Limit of items per page. If you encounter api issues due to too+ large page sizes, try to reduce the limit.required: falseschema:type: integernullable: true+ - name: name+ in: query+ required: false+ schema:+ type: string+ nullable: true+ - name: userId+ in: query+ required: false+ schema:+ type: string+ nullable: true+ - name: type+ in: query+ required: false+ schema:+ type: string+ nullable: true+ - name: traceId+ in: query+ required: false+ schema:+ type: string+ nullable: true+ - name: parentObservationId+ in: query+ required: false+ schema:+ type: string+ nullable: true+ - name: environment+ in: query+ description: >-+ Optional filter for observations where the environment is one of the+ provided values.+ required: false+ schema:+ type: array+ items:+ type: string+ nullable: true+ - name: fromStartTime+ in: query+ description: >-+ Retrieve only observations with a start_time on or after this+ datetime (ISO 8601).+ required: false+ schema:+ type: string+ format: date-time+ nullable: true+ - name: toStartTime+ in: query+ description: >-+ Retrieve only observations with a start_time before this datetime+ (ISO 8601).+ required: false+ schema:+ type: string+ format: date-time+ nullable: true+ - name: version+ in: query+ description: Optional filter to only include observations with a certain version.+ required: false+ schema:+ type: string+ nullable: trueresponses:'200':description: ''content:application/json:schema:- $ref: '#/components/schemas/PaginatedModels'+ $ref: '#/components/schemas/ObservationsViews''400':description: ''content:@@ -1946,25 +2017,22 @@ paths:schema: {}security:- BasicAuth: []- /api/public/models/{id}:+ /api/public/organizations/memberships:get:- description: Get a model- operationId: models_get+ description: >-+ Get all memberships for the organization associated with the API key+ (requires organization-scoped API key)+ operationId: organizations_getOrganizationMembershipstags:- - Models- parameters:- - name: id- in: path- required: true- schema:- type: string+ - Organizations+ parameters: []responses:'200':description: ''content:application/json:schema:- $ref: '#/components/schemas/Model'+ $ref: '#/components/schemas/MembershipsResponse''400':description: ''content:@@ -1992,23 +2060,75 @@ paths:schema: {}security:- BasicAuth: []- delete:+ put:+ description: >-+ Create or update a membership for the organization associated with the+ API key (requires organization-scoped API key)+ operationId: organizations_updateOrganizationMembership+ tags:+ - Organizations+ parameters: []+ responses:+ '200':+ description: ''+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/MembershipResponse'+ '400':+ description: ''+ content:+ application/json:+ schema: {}+ '401':+ description: ''+ content:+ application/json:+ schema: {}+ '403':+ description: ''+ content:+ application/json:+ schema: {}+ '404':+ description: ''+ content:+ application/json:+ schema: {}+ '405':+ description: ''+ content:+ application/json:+ schema: {}+ security:+ - BasicAuth: []+ requestBody:+ required: true+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/MembershipRequest'+ /api/public/projects/{projectId}/memberships:+ get:description: >-- Delete a model. Cannot delete models managed by Langfuse. You can create- your own definition with the same modelName to override the definition- though.- operationId: models_delete+ Get all memberships for a specific project (requires organization-scoped+ API key)+ operationId: organizations_getProjectMembershipstags:- - Models+ - Organizationsparameters:- - name: id+ - name: projectIdin: pathrequired: trueschema:type: stringresponses:- '204':+ '200':description: ''+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/MembershipsResponse''400':description: ''content:@@ -2036,18 +2156,17 @@ paths:schema: {}security:- BasicAuth: []- /api/public/observations/{observationId}:- get:- description: Get a observation- operationId: observations_get+ put:+ description: >-+ Create or update a membership for a specific project (requires+ organization-scoped API key). The user must already be a member of the+ organization.+ operationId: organizations_updateProjectMembershiptags:- - Observations+ - Organizationsparameters:- - name: observationId+ - name: projectIdin: path- description: >-- The unique langfuse identifier of an observation, can be an event,- span or generationrequired: trueschema:type: string@@ -2057,7 +2176,7 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/ObservationsView'+ $ref: '#/components/schemas/MembershipResponse''400':description: ''content:@@ -2085,104 +2204,28 @@ paths:schema: {}security:- BasicAuth: []- /api/public/observations:+ requestBody:+ required: true+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/MembershipRequest'+ /api/public/organizations/projects:get:- description: Get a list of observations- operationId: observations_getMany+ description: >-+ Get all projects for the organization associated with the API key+ (requires organization-scoped API key)+ operationId: organizations_getOrganizationProjectstags:- - Observations- parameters:- - name: page- in: query- description: Page number, starts at 1.- required: false- schema:- type: integer- nullable: true- - name: limit- in: query- description: >-- Limit of items per page. If you encounter api issues due to too- large page sizes, try to reduce the limit.- required: false- schema:- type: integer- nullable: true- - name: name- in: query- required: false- schema:- type: string- nullable: true- - name: userId- in: query- required: false- schema:- type: string- nullable: true- - name: type- in: query- required: false- schema:- type: string- nullable: true- - name: traceId- in: query- required: false- schema:- type: string- nullable: true- - name: parentObservationId- in: query- required: false- schema:- type: string- nullable: true- - name: environment- in: query- description: >-- Optional filter for observations where the environment is one of the- provided values.- required: false- schema:- type: array- items:- type: string- nullable: true- - name: fromStartTime- in: query- description: >-- Retrieve only observations with a start_time or or after this- datetime (ISO 8601).- required: false- schema:- type: string- format: date-time- nullable: true- - name: toStartTime- in: query- description: >-- Retrieve only observations with a start_time before this datetime- (ISO 8601).- required: false- schema:- type: string- format: date-time- nullable: true- - name: version- in: query- description: Optional filter to only include observations with a certain version.- required: false- schema:- type: string- nullable: true+ - Organizations+ parameters: []responses:'200':description: ''content:application/json:schema:- $ref: '#/components/schemas/ObservationsViews'+ $ref: '#/components/schemas/OrganizationProjectsResponse''400':description: ''content:@@ -6277,52 +6320,6 @@ components:- application/xml- application/octet-streamdescription: The MIME type of the media record- MembershipRole:- title: MembershipRole- type: string- enum:- - OWNER- - ADMIN- - MEMBER- - VIEWER- MembershipRequest:- title: MembershipRequest- type: object- properties:- userId:- type: string- role:- $ref: '#/components/schemas/MembershipRole'- required:- - userId- - role- MembershipResponse:- title: MembershipResponse- type: object- properties:- userId:- type: string- role:- $ref: '#/components/schemas/MembershipRole'- email:- type: string- name:- type: string- required:- - userId- - role- - name- MembershipsResponse:- title: MembershipsResponse- type: object- properties:- memberships:- type: array- items:- $ref: '#/components/schemas/MembershipResponse'- required:- - membershipsMetricsResponse:title: MetricsResponsetype: object@@ -6435,6 +6432,85 @@ components:required:- data- meta+ MembershipRole:+ title: MembershipRole+ type: string+ enum:+ - OWNER+ - ADMIN+ - MEMBER+ - VIEWER+ MembershipRequest:+ title: MembershipRequest+ type: object+ properties:+ userId:+ type: string+ role:+ $ref: '#/components/schemas/MembershipRole'+ required:+ - userId+ - role+ MembershipResponse:+ title: MembershipResponse+ type: object+ properties:+ userId:+ type: string+ role:+ $ref: '#/components/schemas/MembershipRole'+ email:+ type: string+ name:+ type: string+ required:+ - userId+ - role+ - name+ MembershipsResponse:+ title: MembershipsResponse+ type: object+ properties:+ memberships:+ type: array+ items:+ $ref: '#/components/schemas/MembershipResponse'+ required:+ - memberships+ OrganizationProject:+ title: OrganizationProject+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ metadata:+ type: object+ additionalProperties: true+ nullable: true+ createdAt:+ type: string+ format: date-time+ updatedAt:+ type: string+ format: date-time+ required:+ - id+ - name+ - createdAt+ - updatedAt+ OrganizationProjectsResponse:+ title: OrganizationProjectsResponse+ type: object+ properties:+ projects:+ type: array+ items:+ $ref: '#/components/schemas/OrganizationProject'+ required:+ - projectsProjects:title: Projectstype: objectdiff --git a/web/public/generated/postman/collection.json b/web/public/generated/postman/collection.jsonindex 153dc20841..6777c6a0c5 100644--- a/web/public/generated/postman/collection.json+++ b/web/public/generated/postman/collection.json@@ -1246,147 +1246,6 @@}]},- {- "_type": "container",- "description": null,- "name": "Memberships",- "item": [- {- "_type": "endpoint",- "name": "Get Organization Memberships",- "request": {- "description": "Get all memberships for the organization associated with the API key (requires organization-scoped API key)",- "url": {- "raw": "{{baseUrl}}/api/public/organizations/memberships",- "host": [- "{{baseUrl}}"- ],- "path": [- "api",- "public",- "organizations",- "memberships"- ],- "query": [],- "variable": []- },- "header": [],- "method": "GET",- "auth": null,- "body": null- },- "response": []- },- {- "_type": "endpoint",- "name": "Update Organization Membership",- "request": {- "description": "Create or update a membership for the organization associated with the API key (requires organization-scoped API key)",- "url": {- "raw": "{{baseUrl}}/api/public/organizations/memberships",- "host": [- "{{baseUrl}}"- ],- "path": [- "api",- "public",- "organizations",- "memberships"- ],- "query": [],- "variable": []- },- "header": [],- "method": "PUT",- "auth": null,- "body": {- "mode": "raw",- "raw": "{\n \"userId\": \"example\",\n \"role\": \"OWNER\"\n}",- "options": {- "raw": {- "language": "json"- }- }- }- },- "response": []- },- {- "_type": "endpoint",- "name": "Get Project Memberships",- "request": {- "description": "Get all memberships for a specific project (requires organization-scoped API key)",- "url": {- "raw": "{{baseUrl}}/api/public/projects/:projectId/memberships",- "host": [- "{{baseUrl}}"- ],- "path": [- "api",- "public",- "projects",- ":projectId",- "memberships"- ],- "query": [],- "variable": [- {- "key": "projectId",- "value": "",- "description": null- }- ]- },- "header": [],- "method": "GET",- "auth": null,- "body": null- },- "response": []- },- {- "_type": "endpoint",- "name": "Update Project Membership",- "request": {- "description": "Create or update a membership for a specific project (requires organization-scoped API key). The user must already be a member of the organization.",- "url": {- "raw": "{{baseUrl}}/api/public/projects/:projectId/memberships",- "host": [- "{{baseUrl}}"- ],- "path": [- "api",- "public",- "projects",- ":projectId",- "memberships"- ],- "query": [],- "variable": [- {- "key": "projectId",- "value": "",- "description": null- }- ]- },- "header": [],- "method": "PUT",- "auth": null,- "body": {- "mode": "raw",- "raw": "{\n \"userId\": \"example\",\n \"role\": \"OWNER\"\n}",- "options": {- "raw": {- "language": "json"- }- }- }- },- "response": []- }- ]- },{"_type": "container","description": null,@@ -1661,7 +1520,7 @@{"key": "fromStartTime","value": "",- "description": "Retrieve only observations with a start_time or or after this datetime (ISO 8601)."+ "description": "Retrieve only observations with a start_time on or after this datetime (ISO 8601)."},{"key": "toStartTime",@@ -1685,6 +1544,173 @@}]},+ {+ "_type": "container",+ "description": null,+ "name": "Organizations",+ "item": [+ {+ "_type": "endpoint",+ "name": "Get Organization Memberships",+ "request": {+ "description": "Get all memberships for the organization associated with the API key (requires organization-scoped API key)",+ "url": {+ "raw": "{{baseUrl}}/api/public/organizations/memberships",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "api",+ "public",+ "organizations",+ "memberships"+ ],+ "query": [],+ "variable": []+ },+ "header": [],+ "method": "GET",+ "auth": null,+ "body": null+ },+ "response": []+ },+ {+ "_type": "endpoint",+ "name": "Update Organization Membership",+ "request": {+ "description": "Create or update a membership for the organization associated with the API key (requires organization-scoped API key)",+ "url": {+ "raw": "{{baseUrl}}/api/public/organizations/memberships",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "api",+ "public",+ "organizations",+ "memberships"+ ],+ "query": [],+ "variable": []+ },+ "header": [],+ "method": "PUT",+ "auth": null,+ "body": {+ "mode": "raw",+ "raw": "{\n \"userId\": \"example\",\n \"role\": \"OWNER\"\n}",+ "options": {+ "raw": {+ "language": "json"+ }+ }+ }+ },+ "response": []+ },+ {+ "_type": "endpoint",+ "name": "Get Project Memberships",+ "request": {+ "description": "Get all memberships for a specific project (requires organization-scoped API key)",+ "url": {+ "raw": "{{baseUrl}}/api/public/projects/:projectId/memberships",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "api",+ "public",+ "projects",+ ":projectId",+ "memberships"+ ],+ "query": [],+ "variable": [+ {+ "key": "projectId",+ "value": "",+ "description": null+ }+ ]+ },+ "header": [],+ "method": "GET",+ "auth": null,+ "body": null+ },+ "response": []+ },+ {+ "_type": "endpoint",+ "name": "Update Project Membership",+ "request": {+ "description": "Create or update a membership for a specific project (requires organization-scoped API key). The user must already be a member of the organization.",+ "url": {+ "raw": "{{baseUrl}}/api/public/projects/:projectId/memberships",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "api",+ "public",+ "projects",+ ":projectId",+ "memberships"+ ],+ "query": [],+ "variable": [+ {+ "key": "projectId",+ "value": "",+ "description": null+ }+ ]+ },+ "header": [],+ "method": "PUT",+ "auth": null,+ "body": {+ "mode": "raw",+ "raw": "{\n \"userId\": \"example\",\n \"role\": \"OWNER\"\n}",+ "options": {+ "raw": {+ "language": "json"+ }+ }+ }+ },+ "response": []+ },+ {+ "_type": "endpoint",+ "name": "Get Organization Projects",+ "request": {+ "description": "Get all projects for the organization associated with the API key (requires organization-scoped API key)",+ "url": {+ "raw": "{{baseUrl}}/api/public/organizations/projects",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "api",+ "public",+ "organizations",+ "projects"+ ],+ "query": [],+ "variable": []+ },+ "header": [],+ "method": "GET",+ "auth": null,+ "body": null+ },+ "response": []+ }+ ]+ },{"_type": "container","description": null,diff --git a/web/src/__tests__/async/organizations-api.servertest.ts b/web/src/__tests__/async/organizations-api.servertest.tsindex e13f3440d7..c69aa919ed 100644--- a/web/src/__tests__/async/organizations-api.servertest.ts+++ b/web/src/__tests__/async/organizations-api.servertest.ts@@ -7,6 +7,10 @@ import {import { prisma } from "@langfuse/shared/src/db";import { z } from "zod";import { randomUUID } from "crypto";+import {+ createAndAddApiKeysToDb,+ createBasicAuthHeader,+} from "@langfuse/shared/src/server";// Schema for organization responseconst OrganizationResponseSchema = z.object({@@ -740,3 +744,292 @@ describe("Admin Organizations API", () => {expect(result.body.error).toContain("Method Not Allowed");});});++// Schema for organization project response+const OrganizationProjectSchema = z.object({+ id: z.string(),+ name: z.string(),+ metadata: z.record(z.unknown()).nullable(),+ createdAt: z.string().datetime(),+ updatedAt: z.string().datetime(),+});++// Schema for organization projects list response+const OrganizationProjectsListSchema = z.object({+ projects: z.array(OrganizationProjectSchema),+});++describe("Public Organizations API", () => {+ // Create test data+ let testOrgId: string;+ let testProject1Id: string;+ let testProject2Id: string;+ let testApiKey: string;+ let testApiSecretKey: string;++ beforeAll(async () => {+ // Create a test organization+ const uniqueOrgName = `Test Org ${randomUUID().substring(0, 8)}`;+ const org = await prisma.organization.create({+ data: { name: uniqueOrgName, cloudConfig: { plan: "Team" } },+ });+ testOrgId = org.id;++ // Create test projects+ const uniqueProject1Name = `Test Project 1 ${randomUUID().substring(0, 8)}`;+ const project1 = await prisma.project.create({+ data: {+ name: uniqueProject1Name,+ orgId: testOrgId,+ metadata: { type: "test", environment: "development" },+ },+ });+ testProject1Id = project1.id;++ const uniqueProject2Name = `Test Project 2 ${randomUUID().substring(0, 8)}`;+ const project2 = await prisma.project.create({+ data: {+ name: uniqueProject2Name,+ orgId: testOrgId,+ metadata: { type: "test", environment: "production" },+ },+ });+ testProject2Id = project2.id;++ // Create an organization API key+ const apiKey = await createAndAddApiKeysToDb({+ prisma,+ entityId: testOrgId,+ scope: "ORGANIZATION",+ note: "Test API Key for Organizations API",+ predefinedKeys: {+ publicKey: `pk-lf-org-${randomUUID().substring(0, 8)}`,+ secretKey: `sk-lf-org-${randomUUID().substring(0, 8)}`,+ },+ });+ testApiKey = apiKey.publicKey;+ testApiSecretKey = apiKey.secretKey;+ });++ afterAll(async () => {+ // Clean up test data+ await prisma.organization.delete({+ where: {+ id: testOrgId,+ },+ });+ });++ describe("Organization Projects", () => {+ describe("GET /api/public/organizations/projects", () => {+ it("should get all organization projects with valid API key", async () => {+ const response = await makeZodVerifiedAPICall(+ OrganizationProjectsListSchema,+ "GET",+ `/api/public/organizations/projects`,+ undefined,+ createBasicAuthHeader(testApiKey, testApiSecretKey),+ 200,+ );++ expect(response.status).toBe(200);+ expect(Array.isArray(response.body.projects)).toBe(true);+ expect(response.body.projects.length).toBeGreaterThanOrEqual(2);++ // Verify our test projects are in the response+ const projectIds = response.body.projects.map((p) => p.id);+ expect(projectIds).toContain(testProject1Id);+ expect(projectIds).toContain(testProject2Id);++ // Verify project structure+ const project1 = response.body.projects.find(+ (p) => p.id === testProject1Id,+ );+ expect(project1).toBeDefined();+ expect(project1?.name).toBeTruthy();+ expect(project1?.metadata).toEqual({+ type: "test",+ environment: "development",+ });+ expect(project1?.createdAt).toBeTruthy();+ expect(project1?.updatedAt).toBeTruthy();++ const project2 = response.body.projects.find(+ (p) => p.id === testProject2Id,+ );+ expect(project2).toBeDefined();+ expect(project2?.metadata).toEqual({+ type: "test",+ environment: "production",+ });+ });++ it("should return 403 when using a project-scoped API key", async () => {+ // Create a project API key+ const projectApiKey = await createAndAddApiKeysToDb({+ prisma,+ entityId: testProject1Id,+ scope: "PROJECT",+ note: "Test Project API Key",+ predefinedKeys: {+ publicKey: `pk-lf-project-${randomUUID().substring(0, 8)}`,+ secretKey: `sk-lf-project-${randomUUID().substring(0, 8)}`,+ },+ });++ const result = await makeAPICall(+ "GET",+ `/api/public/organizations/projects`,+ undefined,+ createBasicAuthHeader(+ projectApiKey.publicKey,+ projectApiKey.secretKey,+ ),+ );+ expect(result.status).toBe(403);+ expect(result.body.error).toContain(+ "Organization-scoped API key required",+ );++ // Clean up+ await prisma.apiKey.delete({+ where: {+ id: projectApiKey.id,+ },+ });+ });++ it("should return 401 when using invalid API key", async () => {+ const result = await makeAPICall(+ "GET",+ `/api/public/organizations/projects`,+ undefined,+ createBasicAuthHeader("invalid-key", "invalid-secret"),+ );+ expect(result.status).toBe(401);+ });++ it("should return 405 for non-GET methods", async () => {+ const result = await makeAPICall(+ "POST",+ `/api/public/organizations/projects`,+ { some: "data" },+ createBasicAuthHeader(testApiKey, testApiSecretKey),+ );+ expect(result.status).toBe(405);+ expect(result.body.error).toBe("Method not allowed");+ });++ it("should only return projects belonging to the organization", async () => {+ // Create another organization with projects+ const otherOrg = await prisma.organization.create({+ data: {+ name: `Other Org ${randomUUID().substring(0, 8)}`,+ cloudConfig: { plan: "Team" },+ },+ });++ const otherProject = await prisma.project.create({+ data: {+ name: `Other Project ${randomUUID().substring(0, 8)}`,+ orgId: otherOrg.id,+ },+ });++ // Get projects for our test organization+ const response = await makeZodVerifiedAPICall(+ OrganizationProjectsListSchema,+ "GET",+ `/api/public/organizations/projects`,+ undefined,+ createBasicAuthHeader(testApiKey, testApiSecretKey),+ 200,+ );++ // Verify only our organization's projects are returned+ const projectIds = response.body.projects.map((p) => p.id);+ expect(projectIds).toContain(testProject1Id);+ expect(projectIds).toContain(testProject2Id);+ expect(projectIds).not.toContain(otherProject.id);++ // Clean up+ await prisma.organization.delete({+ where: {+ id: otherOrg.id,+ },+ });+ });++ it("should handle organization with no projects", async () => {+ // Create an empty organization+ const emptyOrg = await prisma.organization.create({+ data: {+ name: `Empty Org ${randomUUID().substring(0, 8)}`,+ cloudConfig: { plan: "Team" },+ },+ });++ // Create API key for empty organization+ const emptyOrgApiKey = await createAndAddApiKeysToDb({+ prisma,+ entityId: emptyOrg.id,+ scope: "ORGANIZATION",+ note: "Test API Key for Empty Org",+ predefinedKeys: {+ publicKey: `pk-lf-empty-${randomUUID().substring(0, 8)}`,+ secretKey: `sk-lf-empty-${randomUUID().substring(0, 8)}`,+ },+ });++ const response = await makeZodVerifiedAPICall(+ OrganizationProjectsListSchema,+ "GET",+ `/api/public/organizations/projects`,+ undefined,+ createBasicAuthHeader(+ emptyOrgApiKey.publicKey,+ emptyOrgApiKey.secretKey,+ ),+ 200,+ );++ expect(response.status).toBe(200);+ expect(response.body.projects).toEqual([]);++ // Clean up+ await prisma.organization.delete({+ where: {+ id: emptyOrg.id,+ },+ });+ });++ it("should handle projects with null metadata", async () => {+ // Create a project with null metadata+ const projectWithNullMetadata = await prisma.project.create({+ data: {+ name: `Null Metadata Project ${randomUUID().substring(0, 8)}`,+ orgId: testOrgId,+ metadata: null,+ },+ });++ const response = await makeZodVerifiedAPICall(+ OrganizationProjectsListSchema,+ "GET",+ `/api/public/organizations/projects`,+ undefined,+ createBasicAuthHeader(testApiKey, testApiSecretKey),+ 200,+ );++ expect(response.status).toBe(200);+ const nullMetadataProject = response.body.projects.find(+ (p) => p.id === projectWithNullMetadata.id,+ );+ expect(nullMetadataProject).toBeDefined();+ expect(nullMetadataProject?.metadata).toBeNull();+ });+ });+ });+});diff --git a/web/src/ee/features/admin-api/public/organizations/projects.ts b/web/src/ee/features/admin-api/public/organizations/projects.tsnew file mode 100644index 0000000000..103b8b4370--- /dev/null+++ b/web/src/ee/features/admin-api/public/organizations/projects.ts@@ -0,0 +1,32 @@+import { type NextApiRequest, type NextApiResponse } from "next";+import { prisma } from "@langfuse/shared/src/db";++// GET - Retrieve all projects in an organization+export async function handleGetProjects(+ req: NextApiRequest,+ res: NextApiResponse,+ orgId: string,+) {+ const projects = await prisma.project.findMany({+ where: {+ orgId,+ },+ select: {+ id: true,+ name: true,+ metadata: true,+ createdAt: true,+ updatedAt: true,+ },+ });++ return res.status(200).json({+ projects: projects.map((project) => ({+ id: project.id,+ name: project.name,+ metadata: project.metadata,+ createdAt: project.createdAt,+ updatedAt: project.updatedAt,+ })),+ });+}diff --git a/web/src/pages/api/public/organizations/projects/index.ts b/web/src/pages/api/public/organizations/projects/index.tsnew file mode 100644index 0000000000..91b5a686e7--- /dev/null+++ b/web/src/pages/api/public/organizations/projects/index.ts@@ -0,0 +1,71 @@+import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";+import { cors, runMiddleware } from "@/src/features/public-api/server/cors";+import { prisma } from "@langfuse/shared/src/db";+import { logger, redis } from "@langfuse/shared/src/server";+import { handleGetProjects } from "@/src/ee/features/admin-api/public/organizations/projects";++import { type NextApiRequest, type NextApiResponse } from "next";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";++export default async function handler(+ req: NextApiRequest,+ res: NextApiResponse,+) {+ await runMiddleware(req, res, cors);++ if (req.method !== "GET") {+ logger.error(+ `Method not allowed for ${req.method} on /api/public/organizations/projects`,+ );+ return res.status(405).json({+ error: "Method not allowed",+ });+ }++ // CHECK AUTH+ const authCheck = await new ApiAuthService(+ prisma,+ redis,+ ).verifyAuthHeaderAndReturnScope(req.headers.authorization);+ if (!authCheck.validKey) {+ return res.status(401).json({+ error: authCheck.error,+ });+ }+ // END CHECK AUTH++ // Check if using an organization API key+ if (+ authCheck.scope.accessLevel !== "organization" ||+ !authCheck.scope.orgId+ ) {+ return res.status(403).json({+ error:+ "Invalid API key. Organization-scoped API key required for this operation.",+ });+ }++ if (+ !hasEntitlementBasedOnPlan({+ plan: authCheck.scope.plan,+ entitlement: "admin-api",+ })+ ) {+ return res.status(403).json({+ error: "This feature is not available on your current plan.",+ });+ }++ // Route to the appropriate handler based on HTTP method+ try {+ return handleGetProjects(req, res, authCheck.scope.orgId);+ } catch (error) {+ logger.error(+ `Error handling organization projects for ${req.method}`,+ error,+ );+ return res.status(500).json({+ error: "Internal server error",+ });+ }+}\ No newline at end of file