This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git
The following commit(s) were added to refs/heads/master by this push:
new 558d9e1 Fix overly concrete Snapshot properties, expose those
property typings
558d9e1 is described below
commit 558d9e1b3f6b2d4d508dc1d7e755257deb13f488
Author: ocket8888 <[email protected]>
AuthorDate: Thu Oct 13 15:07:17 2022 -0600
Fix overly concrete Snapshot properties, expose those property typings
---
package-lock.json | 4 +-
package.json | 5 +-
src/snap.and.queue.ts | 274 +++++++++++++++++++++++++++++---------------------
3 files changed, 162 insertions(+), 121 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index db5e289..21e0e0a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "trafficops-types",
- "version": "3.1.1",
+ "version": "3.1.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "trafficops-types",
- "version": "3.1.1",
+ "version": "3.1.2",
"license": "Apache-2.0",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.0.0",
diff --git a/package.json b/package.json
index 911daa4..8fbfd33 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,14 @@
{
"name": "trafficops-types",
- "version": "3.1.1",
+ "version": "3.1.2",
"description": "A library for dealing with Apache Traffic Control
objects",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"lint": "eslint --ext .ts .",
"clean": "rm -rf dist",
- "doc": "typedoc --includeVersion --readme ./README.md
src/index.ts"
+ "doc": "typedoc --includeVersion --readme ./README.md
src/index.ts",
+ "prepare": "npm run lint && npm run build"
},
"keywords": [
"Traffic Ops",
diff --git a/src/snap.and.queue.ts b/src/snap.and.queue.ts
index dffc1af..42c125a 100644
--- a/src/snap.and.queue.ts
+++ b/src/snap.and.queue.ts
@@ -133,6 +133,148 @@ interface MidContentServer extends ContentServerBase {
type: "MID";
}
+/**
+ * Represents a Snapshot "contentServer" of arbitrary tier.
+ */
+export type SnapshotContentServer = EdgeContentServer | MidContentServer;
+
+/**
+ * Represents a Traffic Router in a CDN Snapshot.
+ */
+export interface SnapshotContentRouter {
+ // These property names are defined by the API and are therefore
+ // beyond my control.
+ // eslint-disable-next-line @typescript-eslint/naming-convention
+ "api.port": string;
+ // eslint-disable-next-line @typescript-eslint/naming-convention
+ "secure.api.port": string;
+ fqdn: string;
+ httpsPort: number | null;
+ ip: string;
+ ip6: string;
+ location: string;
+ port: number;
+ profile: string;
+ status: string;
+}
+
+/**
+ * Represents a Delivery Service in a CDN Snapshot.
+ */
+export interface SnapshotDeliveryService {
+ anonymousBlockingEnabled: "true" | "false";
+ consistentHashQueryParameters: Array<string>;
+ consistentHashRegex?: string;
+ coverageZoneOnly: "true" | "false";
+ deepCachingType: "ALWAYS" | "NEVER";
+ dispersion: {
+ limit: number;
+ shuffled: "true" | "false";
+ };
+ domains: Array<string>;
+ ecsEnabled: "true" | "false";
+ geolocationProvider: string;
+ ip6RoutingEnabled: "true" | "false";
+ matchsets: Array<{
+ matchList: Array<{
+ // This is beyond my control.
+ // eslint-disable-next-line
@typescript-eslint/naming-convention
+ "match-type": string;
+ regex: string;
+ }>;
+ protocol: string;
+ }>;
+ missLocation: {
+ lat: number;
+ long: number;
+ };
+ protocol: {
+ acceptHttps: "true" | "false";
+ redirectToHttps: "true" | "false";
+ };
+ regionalGeoBlocking: "true" | "false";
+ requiredCapabilities: Array<string>;
+ routingName: string;
+ soa: {
+ admin: string;
+ expire: string;
+ minimum: string;
+ refresh: string;
+ retry: string;
+ };
+ sslEnabled: "true" | "false";
+ topology?: string;
+ ttls: {
+ /* eslint-disable @typescript-eslint/naming-convention */
+ A: string;
+ AAAA: string;
+ NS: string;
+ SOA: string;
+ /* eslint-enable @typescript-eslint/naming-convention */
+ };
+}
+
+/**
+ * Represents an Edge-tier Cache Group in a CDN Snapshot.
+ */
+export interface SnapshotEdgeLocation {
+ backupLocations: {
+ fallbackToClosest: "true" | "false";
+ list?: Array<string>;
+ };
+ latitude: number;
+ longitude: number;
+ localizationMethods: Array<LocalizationMethod>;
+}
+
+/**
+ * Represents a Traffic Monitor in the context of a CDN Snapshot.
+ */
+export interface SnapshotMonitor {
+ fqdn: string;
+ httpsPort: number | null;
+ ip: string;
+ ip6: string;
+ location: string;
+ port: number;
+ profile: string;
+ status: string;
+}
+
+/**
+ * Represents the "stats" section of a CDN Snapshot.
+ */
+export interface SnapshotStatsSection {
+ /* eslint-disable @typescript-eslint/naming-convention */
+ CDN_name?: string;
+ date?: Date;
+ tm_host?: string;
+ tm_path?: string;
+ tm_user?: string;
+ tm_version?: string;
+ /* eslint-enable @typescript-eslint/naming-convention */
+}
+
+/**
+ * Represents a Traffic Router Cache Group in a CDN Snapshot.
+ */
+export interface SnapshotTrafficRouterLocation {
+ backupLocations: {
+ fallbackToClosest: "true" | "false";
+ list?: Array<string>;
+ };
+ latitude: number;
+ localizationMethods: Array<LocalizationMethod>;
+ longitude: number;
+}
+
+/**
+ * Represents a Topology in a CDN Snapshot.
+ */
+export interface SnapshotTopology {
+ nodes: Array<string>;
+}
+
/**
* Represents a CDN Snapshot.
*
@@ -140,130 +282,28 @@ interface MidContentServer extends ContentServerBase {
* the normal rules of API versioning.
*/
export interface Snapshot {
- config: Record<string, unknown>;
- contentRouters: {
- [routerHostName: string]: {
- // These property names are defined by the API and are
therefore
- // beyond my control.
- // eslint-disable-next-line
@typescript-eslint/naming-convention
- "api.port": string;
- // eslint-disable-next-line
@typescript-eslint/naming-convention
- "secure.api.port": string;
- fqdn: string;
- httpsPort: number | null;
- ip: string;
- ip6: string;
- location: string;
- port: number;
- profile: string;
- status: string;
- };
+ config?: Record<string, string>;
+ contentRouters?: {
+ [routerHostName: string]: SnapshotContentRouter;
};
- contentServers: {
- [cacheServerHostName: string]: EdgeContentServer |
MidContentServer;
+ contentServers?: {
+ [cacheServerHostName: string]: SnapshotContentServer;
};
- deliveryServices: {
- [xmlID: string]: {
- anonymousBlockingEnabled: "true" | "false";
- consistentHashQueryParameters: Array<string>;
- consistentHashRegex?: string;
- coverageZoneOnly: "true" | "false";
- deepCachingType: "ALWAYS" | "NEVER";
- dispersion: {
- limit: number;
- shuffled: "true" | "false";
- };
- domains: Array<string>;
- ecsEnabled: "true" | "false";
- geolocationProvider: string;
- ip6RoutingEnabled: "true" | "false";
- matchsets: Array<{
- matchList: Array<{
- // This is beyond my control.
- // eslint-disable-next-line
@typescript-eslint/naming-convention
- "match-type": string;
- regex: string;
- }>;
- protocol: string;
- }>;
- missLocation: {
- lat: number;
- long: number;
- };
- protocol: {
- acceptHttps: "true" | "false";
- redirectToHttps: "true" | "false";
- };
- regionalGeoBlocking: "true" | "false";
- requiredCapabilities: Array<string>;
- routingName: string;
- soa: {
- admin: string;
- expire: string;
- minimum: string;
- refresh: string;
- retry: string;
- };
- sslEnabled: "true" | "false";
- topology?: string;
- ttls: {
- /* eslint-disable
@typescript-eslint/naming-convention */
- A: string;
- AAAA: string;
- NS: string;
- SOA: string;
- /* eslint-enable
@typescript-eslint/naming-convention */
- };
- };
+ deliveryServices?: {
+ [xmlID: string]: SnapshotDeliveryService;
};
- edgeLocations: {
- [name: string]: {
- backupLocations: {
- fallbackToClosest: "true" | "false";
- list?: Array<string>;
- };
- latitude: number;
- longitude: number;
- localizationMethods: Array<LocalizationMethod>;
- };
+ edgeLocations?: {
+ [name: string]: SnapshotEdgeLocation;
};
- monitors: {
- [monitorHostName: string]: {
- fqdn: string;
- httpsPort: number | null;
- ip: string;
- ip6: string;
- location: string;
- port: number;
- profile: string;
- status: string;
- };
- };
- stats: {
- /* eslint-disable @typescript-eslint/naming-convention */
- CDN_name: string;
- date: Date;
- tm_host: string;
- tm_path: string;
- tm_user: string;
- tm_version: string;
- /* eslint-enable @typescript-eslint/naming-convention */
+ monitors?: {
+ [monitorHostName: string]: SnapshotMonitor;
};
+ stats?: SnapshotStatsSection;
topologies?: {
- [name: string]: {
- nodes: Array<string>;
- };
+ [name: string]: SnapshotTopology;
};
- trafficRouterLocations: {
- [name: string]: {
- backupLocations: {
- fallbackToClosest: "true" | "false";
- list?: Array<string>;
- };
- latitude: number;
- localizationMethods: Array<LocalizationMethod>;
- longitude: number;
- };
+ trafficRouterLocations?: {
+ [name: string]: SnapshotTrafficRouterLocation;
};
}