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
17 changes: 9 additions & 8 deletions .github/workflows/api-client-drift.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: API client drift

# Regenerates the OpenAPI spec and the generated product clients
# (apps/libs/api-client, apps/api-client-go) and fails if the committed
# clients differ — the committed clients must always match apps/api source.
# (apps/libs/api-client, apps/api-client-go, apps/libs/analytics-api-client)
# and fails if the committed clients differ — the committed clients must
# always match their specs (apps/api source for the product clients,
# apps/libs/analytics-api-client/swagger.json for the analytics client).
# Ported from daytonaio/daytona's `format-lint-api-clients` PR check.
# analytics-api-client is excluded: its input swagger comes from the external
# analytics service, not this repo.

on:
pull_request:
Expand Down Expand Up @@ -68,12 +68,13 @@ jobs:
run: |
yarn nx run api-client:generate:api-client
yarn nx run api-client-go:generate:api-client
yarn nx run analytics-api-client:generate:api-client

- name: Fail on drift
run: |
if [ -n "$(git status --porcelain -- libs/api-client api-client-go)" ]; then
git status --porcelain -- libs/api-client api-client-go
git diff -- libs/api-client api-client-go | head -200
echo "::error::Generated API clients are stale. Run 'yarn nx run api-client:generate:api-client && yarn nx run api-client-go:generate:api-client' in apps/ and commit the result."
if [ -n "$(git status --porcelain -- libs/api-client api-client-go libs/analytics-api-client)" ]; then
git status --porcelain -- libs/api-client api-client-go libs/analytics-api-client
git diff -- libs/api-client api-client-go libs/analytics-api-client | head -200
echo "::error::Generated API clients are stale. Run 'yarn nx run api-client:generate:api-client && yarn nx run api-client-go:generate:api-client && yarn nx run analytics-api-client:generate:api-client' in apps/ and commit the result."
exit 1
fi
1 change: 1 addition & 0 deletions apps/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default [
ignores: [
'**/dist',
'**/node_modules/**',
'**/.nx/**',
'**/vite.config.*.timestamp*',
'**/vitest.config.*.timestamp*',
'docs/**',
Expand Down
4 changes: 2 additions & 2 deletions apps/libs/analytics-api-client/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"generate:api-client": {
"executor": "nx:run-commands",
"inputs": ["apiClient"],
"inputs": ["{projectRoot}/swagger.json", { "env": "DEFAULT_PACKAGE_VERSION" }],
"outputs": ["{projectRoot}/src"],
"options": {
"commands": [
"rm -rf {projectRoot}/src",
"yarn run openapi-generator-cli generate --git-repo-id=boxlite --git-user-id=boxlite-ai -i tmp/swagger.json -g typescript-axios --additional-properties=supportsES6=true,typescriptThreePlus=true,withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models,useTags=true,enumPropertyNaming=UPPERCASE --type-mappings=DateTime=Date -o libs/analytics-api-client/src"
"yarn run openapi-generator-cli generate --git-repo-id=boxlite --git-user-id=boxlite-ai -i libs/analytics-api-client/swagger.json -g typescript-axios --additional-properties=supportsES6=true,typescriptThreePlus=true,withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models,useTags=true,enumPropertyNaming=UPPERCASE --type-mappings=DateTime=Date -o libs/analytics-api-client/src"
],
"parallel": false
}
Expand Down
12 changes: 11 additions & 1 deletion apps/libs/analytics-api-client/src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@ api/usage-api.ts
base.ts
common.ts
configuration.ts
docs/ModelsAggregatedUsage.md
docs/ModelsBoxUsage.md
docs/ModelsLogEntry.md
docs/ModelsMetricPoint.md
docs/ModelsSpan.md
docs/ModelsTraceSummary.md
docs/ModelsUsageChartPoint.md
docs/ModelsUsagePeriod.md
docs/TelemetryApi.md
docs/UsageApi.md
git_push.sh
index.ts
models/index.ts
models/models-aggregated-usage.ts
models/models-box-usage.ts
models/models-log-entry.ts
models/models-metric-point.ts
models/models-sandbox-usage.ts
models/models-span.ts
models/models-trace-summary.ts
models/models-usage-chart-point.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.12.0
7.23.0
Comment thread
DorianZheng marked this conversation as resolved.
3 changes: 2 additions & 1 deletion apps/libs/analytics-api-client/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* BoxLite Analytics API - Read-only telemetry and usage data. Authenticated via BoxLite API keys or JWT tokens.
*
* The version of the OpenAPI document: v0.0.0-dev
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand All @@ -16,3 +16,4 @@

export * from './api/telemetry-api';
export * from './api/usage-api';

279 changes: 135 additions & 144 deletions apps/libs/analytics-api-client/src/api/telemetry-api.ts

Large diffs are not rendered by default.

189 changes: 90 additions & 99 deletions apps/libs/analytics-api-client/src/api/usage-api.ts

Large diffs are not rendered by default.

26 changes: 1 addition & 25 deletions apps/libs/analytics-api-client/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* BoxLite Analytics API - Read-only telemetry and usage data. Authenticated via BoxLite API keys or JWT tokens.
*
* The version of the OpenAPI document: v0.0.0-dev
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand All @@ -21,32 +21,18 @@ import globalAxios from 'axios';

export const BASE_PATH = "http://localhost:8080".replace(/\/+$/, "");

/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};

/**
*
* @export
* @interface RequestArgs
*/
export interface RequestArgs {
url: string;
options: RawAxiosRequestConfig;
}

/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
protected configuration: Configuration | undefined;

Expand All @@ -58,12 +44,6 @@ export class BaseAPI {
}
};

/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(public field: string, msg?: string) {
super(msg);
Expand All @@ -78,9 +58,5 @@ interface ServerMap {
}[];
}

/**
*
* @export
*/
export const operationServerMap: ServerMap = {
}
55 changes: 16 additions & 39 deletions apps/libs/analytics-api-client/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,30 @@
* BoxLite Analytics API - Read-only telemetry and usage data. Authenticated via BoxLite API keys or JWT tokens.
*
* The version of the OpenAPI document: v0.0.0-dev
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";

/**
*
* @export
*/
export const DUMMY_BASE_URL = 'https://example.com'

/**
*
* @throws {RequiredError}
* @export
*/
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
}

/**
*
* @export
*/
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
Expand All @@ -48,20 +38,12 @@ export const setApiKeyToObject = async function (object: any, keyParamName: stri
}
}

/**
*
* @export
*/
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { username: configuration.username, password: configuration.password };
}
}

/**
*
* @export
*/
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
Expand All @@ -71,10 +53,6 @@ export const setBearerAuthToObject = async function (object: any, configuration?
}
}

/**
*
* @export
*/
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
Expand All @@ -84,10 +62,11 @@ export const setOAuthToObject = async function (object: any, name: string, scope
}
}


function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter)) {
if (Array.isArray(parameter) || parameter instanceof Set) {
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
}
else {
Expand All @@ -106,42 +85,40 @@ function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: an
}
}

/**
*
* @export
*/
export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
}

/**
*
* @export
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
*/
// @ts-ignore
export const replaceWithSerializableTypeIfNeeded = function(key: string, value: any) {
if (value instanceof Set) {
return Array.from(value);
} else {
return value;
}
}

export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {})
? JSON.stringify(value !== undefined ? value : {}, replaceWithSerializableTypeIfNeeded)
: (value || "");
}

/**
*
* @export
*/
export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash
}

/**
*
* @export
*/
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
Expand Down
Loading
Loading