Skip to content

Commit

Permalink
Reduce number of circular dependencies (#616)
Browse files Browse the repository at this point in the history
We have a bunch of them, which can be fairly easily avoid, mostly by
intruducing the top level logger file and moving some objects around.
  • Loading branch information
therve authored Apr 5, 2022
1 parent 7c26f94 commit 6ed1588
Show file tree
Hide file tree
Showing 889 changed files with 939 additions and 940 deletions.
2 changes: 1 addition & 1 deletion .generator/templates/api/api.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BaseAPIRequestFactory, RequiredError } from './baseapi{{extensionForDeno}}';
import {Configuration, getServer, applySecurityAuthentication} from '../configuration{{extensionForDeno}}';
import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http{{extensionForDeno}}';
import { logger } from "../../../index";
import { logger } from "../../../logger";
{{#platforms}}
{{#node}}
import FormData from "form-data";
Expand Down
3 changes: 0 additions & 3 deletions .generator/templates/http/http.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import URLParse from "url-parse";
{{#platforms}}
{{^deno}}
{{#frameworks}}
{{#fetch-api}}
export * from './isomorphic-fetch';
{{/fetch-api}}
{{#jquery}}
export * from './jquery';
{{/jquery}}
Expand Down
1 change: 1 addition & 0 deletions .generator/templates/index.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./http/http{{extensionForDeno}}";
export * from './http/isomorphic-fetch';
export * from "./auth/auth{{extensionForDeno}}";
export { createConfiguration } from "./configuration{{extensionForDeno}}"
export { setServerVariables } from "./configuration{{extensionForDeno}}"
Expand Down
19 changes: 2 additions & 17 deletions .generator/templates/model/ObjectSerializer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import { {{classname}}{{#hasEnums}}{{#vars}}{{#isEnum}}, {{classname}}{{enumName}} {{/isEnum}} {{/vars}}{{/hasEnums}} } from './{{{ classFilename }}}{{extensionForDeno}}';
{{/model}}
{{/models}}
import { logger } from "../../../index";
import { UnparsedObject } from "../util";
import { logger } from "../../../logger";

const primitives = [
"string",
Expand Down Expand Up @@ -287,19 +288,3 @@ export class ObjectSerializer {
}
}
}

export class UnparsedObject {
unparsedObject:any;
constructor(data:any) {
this.unparsedObject = data;
}
}

export type AttributeTypeMap = {
[key: string]: {
baseName: string;
type: string;
required?: boolean;
format?: string;
};
}
2 changes: 1 addition & 1 deletion .generator/templates/model/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { {{classname}} } from './{{filename}}{{extensionForDeno}}';
{{/tsImports}}
import { HttpFile } from '../http/http{{extensionForDeno}}';
import { AttributeTypeMap, UnparsedObject } from './ObjectSerializer';
import { AttributeTypeMap, UnparsedObject } from '../util';

{{#description}}
/**
Expand Down
16 changes: 16 additions & 0 deletions .generator/templates/util.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,19 @@ export function isCodeInRange(codeRange: string, code: number): boolean {
return true;
}
}

export class UnparsedObject {
unparsedObject:any;
constructor(data:any) {
this.unparsedObject = data;
}
}

export type AttributeTypeMap = {
[key: string]: {
baseName: string;
type: string;
required?: boolean;
format?: string;
};
}
8 changes: 1 addition & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
export * as v1 from "./packages/datadog-api-client-v1";
export * as v2 from "./packages/datadog-api-client-v2";

import log from "loglevel";

const logger = log.noConflict();
logger.setLevel((process !== undefined && process.env.DEBUG) ? logger.levels.DEBUG : logger.levels.INFO);

export { logger };
export * from "./logger";
6 changes: 6 additions & 0 deletions logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import log from "loglevel";

const logger = log.noConflict();
logger.setLevel((process !== undefined && process.env.DEBUG) ? logger.levels.DEBUG : logger.levels.INFO);

export { logger };
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
applySecurityAuthentication,
} from "../configuration";
import { RequestContext, HttpMethod, ResponseContext } from "../http/http";
import { logger } from "../../../index";
import { logger } from "../../../logger";
import { ObjectSerializer } from "../models/ObjectSerializer";
import { ApiException } from "./exception";
import { isCodeInRange } from "../util";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
applySecurityAuthentication,
} from "../configuration";
import { RequestContext, HttpMethod, ResponseContext } from "../http/http";
import { logger } from "../../../index";
import { logger } from "../../../logger";
import { ObjectSerializer } from "../models/ObjectSerializer";
import { ApiException } from "./exception";
import { isCodeInRange } from "../util";
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/apis/UsageMeteringApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
applySecurityAuthentication,
} from "../configuration";
import { RequestContext, HttpMethod, ResponseContext } from "../http/http";
import { logger } from "../../../index";
import { logger } from "../../../logger";
import { ObjectSerializer } from "../models/ObjectSerializer";
import { ApiException } from "./exception";
import { isCodeInRange } from "../util";
Expand Down
2 changes: 0 additions & 2 deletions packages/datadog-api-client-v1/http/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { userAgent } from "../../../userAgent";
import FormData from "form-data";
import URLParse from "url-parse";

export * from "./isomorphic-fetch";

/**
* Interface for aborting fetch requests.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-api-client-v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./http/http";
export * from "./http/isomorphic-fetch";
export * from "./auth/auth";
export { createConfiguration } from "./configuration";
export { setServerVariables } from "./configuration";
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/APIErrorResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Error response object.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/AWSAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Returns the AWS account associated with this integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* AWS account ID and Lambda ARN.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* The Response returned by the AWS Create Account call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* List of AWS accounts to delete.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSAccount } from "./AWSAccount";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* List of enabled AWS accounts.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/AWSLogsAsyncError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Description of errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSLogsAsyncError } from "./AWSLogsAsyncError";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* A list of all Datadog-AWS logs integrations available in your Datadog organization.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/AWSLogsLambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Description of the Lambdas.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSLogsLambda } from "./AWSLogsLambda";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* A list of all Datadog-AWS logs integrations available in your Datadog organization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* The list of current AWS services for which Datadog offers automatic log collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* A list of current AWS services for which Datadog offers automatic log collection.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/AWSTagFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSNamespace } from "./AWSNamespace";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* A tag filter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSNamespace } from "./AWSNamespace";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* The objects used to set an AWS tag filter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSNamespace } from "./AWSNamespace";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* The objects used to delete an AWS tag filter entry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { AWSTagFilter } from "./AWSTagFilter";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* An array of tag filter rules by `namespace` and tag filter string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AlertGraphWidgetDefinitionType } from "./AlertGraphWidgetDefinitionType
import { WidgetTextAlign } from "./WidgetTextAlign";
import { WidgetTime } from "./WidgetTime";
import { WidgetVizType } from "./WidgetVizType";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Alert graphs are timeseries graphs showing the current status of any monitor defined on your system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { AlertValueWidgetDefinitionType } from "./AlertValueWidgetDefinitionType";
import { WidgetTextAlign } from "./WidgetTextAlign";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Alert values are query values showing the current value of the metric in any monitor defined on your system.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/ApiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Datadog API key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { ApiKey } from "./ApiKey";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* List of API and application keys available for a given organization.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/ApiKeyResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { ApiKey } from "./ApiKey";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* An API key with its associated metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { TableWidgetCellDisplayMode } from "./TableWidgetCellDisplayMode";
import { WidgetSort } from "./WidgetSort";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Column properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { ApmStatsQueryColumnType } from "./ApmStatsQueryColumnType";
import { ApmStatsQueryRowType } from "./ApmStatsQueryRowType";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* The APM stats query for table and distributions widgets.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/ApplicationKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* An application key with its associated metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { ApplicationKey } from "./ApplicationKey";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* An application key response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { ApplicationKey } from "./ApplicationKey";
import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* An application key response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Represent validation endpoint responses.
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-api-client-v1/models/AzureAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Do not edit the class manually.
*/

import { AttributeTypeMap } from "./ObjectSerializer";
import { AttributeTypeMap } from "../util";

/**
* Datadog-Azure integrations configured for your organization.
Expand Down
Loading

0 comments on commit 6ed1588

Please sign in to comment.