11/**
22 * Components API Client
3- *
3+ *
44 * Client for interacting with Components endpoints
55 */
66
7- import { LuminorkClient , ApiResponse } from ' ../client.ts' ;
7+ import { LuminorkClient , ApiResponse } from " ../client.ts" ;
88
99// Type definitions for Components API
1010export interface ComponentView {
@@ -50,7 +50,7 @@ export interface CreateComponentResponse {
5050 sockets ?: Array < unknown > ;
5151 domainProps ?: Array < unknown > ;
5252 resourceProps ?: Array < unknown > ;
53- }
53+ } ;
5454}
5555
5656export interface UpdateComponentResponse {
@@ -69,11 +69,17 @@ export interface UpdateComponentResponse {
6969 sockets ?: Array < unknown > ;
7070 domainProps ?: Array < unknown > ;
7171 resourceProps ?: Array < unknown > ;
72- }
72+ } ;
73+ }
74+
75+ export interface ComponentDetails {
76+ componentId : string ;
77+ name : string ;
78+ schemaName : string ;
7379}
7480
7581export interface ListComponentsResponse {
76- components : string [ ] ;
82+ componentDetails : ComponentDetails [ ] ;
7783 nextCursor : string | null ;
7884}
7985
@@ -95,7 +101,7 @@ export interface GetComponentResponse {
95101 resourceProps ?: Array < unknown > ;
96102 action_functions ?: Array < unknown > ;
97103 management_functions ?: Array < unknown > ;
98- }
104+ } ;
99105}
100106
101107export interface FindComponentParams {
@@ -128,136 +134,145 @@ export interface AddActionResponse {
128134 */
129135export class ComponentsApi {
130136 private client : LuminorkClient ;
131-
137+
132138 constructor ( client : LuminorkClient ) {
133139 this . client = client ;
134140 }
135-
141+
136142 /**
137143 * Build the full path with workspace and changeset IDs
138144 */
139- private buildPath ( workspaceId : string , changeSetId : string , path : string ) : string {
145+ private buildPath (
146+ workspaceId : string ,
147+ changeSetId : string ,
148+ path : string ,
149+ ) : string {
140150 return `/v1/w/${ workspaceId } /change-sets/${ changeSetId } /components${ path } ` ;
141151 }
142-
152+
143153 /**
144154 * Create a new component
145155 */
146156 async createComponent (
147157 workspaceId : string ,
148158 changeSetId : string ,
149- data : CreateComponentRequest
159+ data : CreateComponentRequest ,
150160 ) : Promise < ApiResponse < CreateComponentResponse > > {
151161 return this . client . post < CreateComponentResponse > (
152- this . buildPath ( workspaceId , changeSetId , '' ) ,
153- data
162+ this . buildPath ( workspaceId , changeSetId , "" ) ,
163+ data ,
154164 ) ;
155165 }
156-
166+
157167 /**
158168 * List all components in a change set
159169 */
160170 async listComponents (
161171 workspaceId : string ,
162- changeSetId : string
172+ changeSetId : string ,
163173 ) : Promise < ApiResponse < ListComponentsResponse > > {
164174 return this . client . get < ListComponentsResponse > (
165- this . buildPath ( workspaceId , changeSetId , '' )
175+ this . buildPath ( workspaceId , changeSetId , "" ) ,
166176 ) ;
167177 }
168-
178+
169179 /**
170180 * Find components by name or schema
171181 */
172182 async findComponent (
173183 workspaceId : string ,
174184 changeSetId : string ,
175- params : FindComponentParams
185+ params : FindComponentParams ,
176186 ) : Promise < ApiResponse < GetComponentResponse > > {
177- const url = new URL ( this . buildPath ( workspaceId , changeSetId , '/find' ) , this . client . getBaseUrl ( ) ) ;
178-
187+ const url = new URL (
188+ this . buildPath ( workspaceId , changeSetId , "/find" ) ,
189+ this . client . getBaseUrl ( ) ,
190+ ) ;
191+
179192 // Add search parameters
180193 if ( params . name ) {
181- url . searchParams . append ( ' component' , params . name ) ;
194+ url . searchParams . append ( " component" , params . name ) ;
182195 }
183-
196+
184197 if ( params . schema_id ) {
185- url . searchParams . append ( ' schema_id' , params . schema_id ) ;
198+ url . searchParams . append ( " schema_id" , params . schema_id ) ;
186199 }
187-
188- return this . client . get < GetComponentResponse > (
189- url . toString ( )
190- ) ;
200+
201+ return this . client . get < GetComponentResponse > ( url . toString ( ) ) ;
191202 }
192-
203+
193204 /**
194205 * Get a specific component
195206 */
196207 async getComponent (
197208 workspaceId : string ,
198209 changeSetId : string ,
199- componentId : string
210+ componentId : string ,
200211 ) : Promise < ApiResponse < GetComponentResponse > > {
201212 return this . client . get < GetComponentResponse > (
202- this . buildPath ( workspaceId , changeSetId , `/${ componentId } ` )
213+ this . buildPath ( workspaceId , changeSetId , `/${ componentId } ` ) ,
203214 ) ;
204215 }
205-
216+
206217 /**
207218 * Update a component
208219 */
209220 async updateComponent (
210221 workspaceId : string ,
211222 changeSetId : string ,
212223 componentId : string ,
213- data : UpdateComponentRequest
224+ data : UpdateComponentRequest ,
214225 ) : Promise < ApiResponse < UpdateComponentResponse > > {
215226 return this . client . put < UpdateComponentResponse > (
216227 this . buildPath ( workspaceId , changeSetId , `/${ componentId } ` ) ,
217- data
228+ data ,
218229 ) ;
219230 }
220-
231+
221232 /**
222233 * Delete a component
223234 */
224235 async deleteComponent (
225236 workspaceId : string ,
226237 changeSetId : string ,
227- componentId : string
238+ componentId : string ,
228239 ) : Promise < ApiResponse < { success : boolean } > > {
229240 return this . client . delete (
230- this . buildPath ( workspaceId , changeSetId , `/${ componentId } ` )
241+ this . buildPath ( workspaceId , changeSetId , `/${ componentId } ` ) ,
231242 ) ;
232243 }
233-
244+
234245 /**
235246 * Execute a management function on a component
236247 */
237248 async executeManagementFunction (
238249 workspaceId : string ,
239250 changeSetId : string ,
240251 componentId : string ,
241- data : ExecuteManagementFunctionRequest
252+ data : ExecuteManagementFunctionRequest ,
242253 ) : Promise < ApiResponse < ExecuteManagementFunctionResponse > > {
243254 return this . client . post < ExecuteManagementFunctionResponse > (
244- this . buildPath ( workspaceId , changeSetId , `/${ componentId } /execute-management-function` ) ,
245- data
255+ this . buildPath (
256+ workspaceId ,
257+ changeSetId ,
258+ `/${ componentId } /execute-management-function` ,
259+ ) ,
260+ data ,
246261 ) ;
247262 }
248-
263+
249264 /**
250265 * Add an action to a component
251266 */
252267 async addAction (
253268 workspaceId : string ,
254269 changeSetId : string ,
255270 componentId : string ,
256- data : AddActionRequest
271+ data : AddActionRequest ,
257272 ) : Promise < ApiResponse < AddActionResponse > > {
258273 return this . client . post < AddActionResponse > (
259274 this . buildPath ( workspaceId , changeSetId , `/${ componentId } /action` ) ,
260- data
275+ data ,
261276 ) ;
262277 }
263- }
278+ }
0 commit comments