Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/core/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ export class HttpClient {
return this.request<T>("GET", path, options);
}

async post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T> {
async post<T>(path: string, body?: unknown, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<T> {
return this.request<T>("POST", path, { ...options, body });
}

async put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T> {
async put<T>(path: string, body?: unknown, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<T> {
return this.request<T>("PUT", path, { ...options, body });
}

async patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T> {
async patch<T>(path: string, body?: unknown, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<T> {
return this.request<T>("PATCH", path, { ...options, body });
}

async delete<T>(path: string, options?: RequestOptions): Promise<T> {
async delete<T>(path: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<T> {
return this.request<T>("DELETE", path, options);
}

Expand Down
15 changes: 14 additions & 1 deletion src/core/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@ interface RawPaginatedResponse<T> {
}

function extractItems<T>(raw: RawPaginatedResponse<T>): T[] {
return raw.data ?? raw.metadata ?? raw.records ?? [];
// Check well-known keys first
if (raw.data) return raw.data;
if (raw.metadata) return raw.metadata;
if (raw.records) return raw.records;

// Fall back to the first array-valued property (handles collection responses
// like { dataStreams: [...] }, { connections: [...] }, etc.)
for (const value of Object.values(raw)) {
if (Array.isArray(value)) {
return value as T[];
}
}

return [];
}

export interface PaginateOptions<T> extends PaginationParams {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/activations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ActivationsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(id: string, options?: RequestOptions): Promise<void> {
async delete(id: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(
`${this.basePath}/${encodeURIComponent(id)}`,
options,
Expand Down
2 changes: 1 addition & 1 deletion src/resources/calculated-insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class CalculatedInsightsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(apiName: string, options?: RequestOptions): Promise<void> {
async delete(apiName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(apiName)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class ConnectionsService extends BaseResource {
return this.httpClient.put(`${this.basePath}/${encodeURIComponent(connectionId)}`, body, options);
}

async delete(connectionId: string, options?: RequestOptions): Promise<void> {
async delete(connectionId: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(connectionId)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/data-action-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class DataActionTargetsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(apiName: string, options?: RequestOptions): Promise<void> {
async delete(apiName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(apiName)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/data-graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DataGraphsService extends BaseResource {
return this.httpClient.get(`${this.basePath}/data/${encodeURIComponent(dataGraphEntityName)}/${encodeURIComponent(id)}`, options);
}

async delete(dataGraphName: string, options?: RequestOptions): Promise<void> {
async delete(dataGraphName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(dataGraphName)}`, options);
}
}
2 changes: 1 addition & 1 deletion src/resources/data-lake-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class DataLakeObjectsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(recordIdOrDeveloperName: string, options?: RequestOptions): Promise<void> {
async delete(recordIdOrDeveloperName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(recordIdOrDeveloperName)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/data-model-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class DataModelObjectsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(dataModelObjectName: string, options?: RequestOptions): Promise<void> {
async delete(dataModelObjectName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(dataModelObjectName)}`, options);
}

Expand Down
5 changes: 4 additions & 1 deletion src/resources/data-streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class DataStreamsService extends BaseResource {
);
}

async delete(recordIdOrDeveloperName: string, options?: RequestOptions): Promise<void> {
async delete(
recordIdOrDeveloperName: string,
options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> },
): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(recordIdOrDeveloperName)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/data-transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class DataTransformsService extends BaseResource {
return this.httpClient.put(`${this.basePath}/${encodeURIComponent(dataTransformNameOrId)}`, body, options);
}

async delete(dataTransformNameOrId: string, options?: RequestOptions): Promise<void> {
async delete(dataTransformNameOrId: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(dataTransformNameOrId)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/identity-resolutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class IdentityResolutionsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(identityResolution: string, options?: RequestOptions): Promise<void> {
async delete(identityResolution: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(identityResolution)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/private-network-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class PrivateNetworkRoutesService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(routeIdOrName: string, options?: RequestOptions): Promise<void> {
async delete(routeIdOrName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(routeIdOrName)}`, options);
}
}
2 changes: 1 addition & 1 deletion src/resources/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class QueryService extends BaseResource {
);
}

async delete(queryId: string, options?: RequestOptions): Promise<void> {
async delete(queryId: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(queryId)}`, options);
}
}
2 changes: 1 addition & 1 deletion src/resources/search-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class SearchIndexService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(searchIndexApiNameOrId: string, options?: RequestOptions): Promise<void> {
async delete(searchIndexApiNameOrId: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(searchIndexApiNameOrId)}`, options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/segments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SegmentsService extends BaseResource {
return this.httpClient.post(this.basePath, body, options);
}

async delete(segmentApiName: string, options?: RequestOptions): Promise<void> {
async delete(segmentApiName: string, options?: RequestOptions & { query?: Record<string, string | number | boolean | undefined> }): Promise<void> {
return this.httpClient.delete(`${this.basePath}/${encodeURIComponent(segmentApiName)}`, options);
}

Expand Down
Loading