Skip to content

Commit

Permalink
Minor: Add UI json spec (#19235)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshach authored Jan 6, 2025
1 parent 637e33f commit 029a086
Show file tree
Hide file tree
Showing 3 changed files with 474 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,360 @@
/*
* Copyright 2025 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* This schema defines the Metrics entity. `Metrics` are measurements computed from data
* such as `Monthly Active Users`. Some of the metrics that measures used to determine
* performance against an objective are called KPIs or Key Performance Indicators, such as
* `User Retention`.
*/
export interface Metrics {
/**
* Change that lead to this version of the entity.
*/
changeDescription?: ChangeDescription;
/**
* When `true` indicates the entity has been soft deleted.
*/
deleted?: boolean;
/**
* Description of metrics instance, what it is, and how to use it.
*/
description?: string;
/**
* Display Name that identifies this metric.
*/
displayName?: string;
/**
* Domain the Metrics belongs to.
*/
domain?: EntityReference;
/**
* A unique name that identifies a metric in the format 'ServiceName.MetricName'.
*/
fullyQualifiedName?: string;
/**
* Link to the resource corresponding to this entity.
*/
href?: string;
/**
* Unique identifier that identifies this metrics instance.
*/
id: string;
/**
* Name that identifies this metrics instance uniquely.
*/
name: string;
/**
* Owners of this metrics.
*/
owners?: EntityReference[];
/**
* Link to service where this metrics is hosted in.
*/
service: EntityReference;
/**
* Tags for this chart.
*/
tags?: TagLabel[];
/**
* Last update time corresponding to the new version of the entity in Unix epoch time
* milliseconds.
*/
updatedAt?: number;
/**
* User who made the update.
*/
updatedBy?: string;
/**
* Latest usage information for this database.
*/
usageSummary?: UsageDetails;
/**
* Metadata version of the entity.
*/
version?: number;
/**
* Votes on the entity.
*/
votes?: Votes;
}

/**
* Change that lead to this version of the entity.
*
* Description of the change.
*/
export interface ChangeDescription {
/**
* Names of fields added during the version changes.
*/
fieldsAdded?: FieldChange[];
/**
* Fields deleted during the version changes with old value before deleted.
*/
fieldsDeleted?: FieldChange[];
/**
* Fields modified during the version changes with old and new values.
*/
fieldsUpdated?: FieldChange[];
/**
* When a change did not result in change, this could be same as the current version.
*/
previousVersion?: number;
}

export interface FieldChange {
/**
* Name of the entity field that changed.
*/
name?: string;
/**
* New value of the field. Note that this is a JSON string and use the corresponding field
* type to deserialize it.
*/
newValue?: any;
/**
* Previous value of the field. Note that this is a JSON string and use the corresponding
* field type to deserialize it.
*/
oldValue?: any;
}

/**
* Domain the Metrics belongs to.
*
* This schema defines the EntityReference type used for referencing an entity.
* EntityReference is used for capturing relationships from one entity to another. For
* example, a table has an attribute called database of type EntityReference that captures
* the relationship of a table `belongs to a` database.
*
* Owners of this metrics.
*
* This schema defines the EntityReferenceList type used for referencing an entity.
* EntityReference is used for capturing relationships from one entity to another. For
* example, a table has an attribute called database of type EntityReference that captures
* the relationship of a table `belongs to a` database.
*
* Link to service where this metrics is hosted in.
*/
export interface EntityReference {
/**
* If true the entity referred to has been soft-deleted.
*/
deleted?: boolean;
/**
* Optional description of entity.
*/
description?: string;
/**
* Display Name that identifies this entity.
*/
displayName?: string;
/**
* Fully qualified name of the entity instance. For entities such as tables, databases
* fullyQualifiedName is returned in this field. For entities that don't have name hierarchy
* such as `user` and `team` this will be same as the `name` field.
*/
fullyQualifiedName?: string;
/**
* Link to the entity resource.
*/
href?: string;
/**
* Unique identifier that identifies an entity instance.
*/
id: string;
/**
* If true the relationship indicated by this entity reference is inherited from the parent
* entity.
*/
inherited?: boolean;
/**
* Name of the entity instance.
*/
name?: string;
/**
* Entity type/class name - Examples: `database`, `table`, `metrics`, `databaseService`,
* `dashboardService`...
*/
type: string;
}

/**
* This schema defines the type for labeling an entity with a Tag.
*/
export interface TagLabel {
/**
* Description for the tag label.
*/
description?: string;
/**
* Display Name that identifies this tag.
*/
displayName?: string;
/**
* Link to the tag resource.
*/
href?: string;
/**
* Label type describes how a tag label was applied. 'Manual' indicates the tag label was
* applied by a person. 'Derived' indicates a tag label was derived using the associated tag
* relationship (see Classification.json for more details). 'Propagated` indicates a tag
* label was propagated from upstream based on lineage. 'Automated' is used when a tool was
* used to determine the tag label.
*/
labelType: LabelType;
/**
* Name of the tag or glossary term.
*/
name?: string;
/**
* Label is from Tags or Glossary.
*/
source: TagSource;
/**
* 'Suggested' state is used when a tag label is suggested by users or tools. Owner of the
* entity must confirm the suggested labels before it is marked as 'Confirmed'.
*/
state: State;
style?: Style;
tagFQN: string;
}

/**
* Label type describes how a tag label was applied. 'Manual' indicates the tag label was
* applied by a person. 'Derived' indicates a tag label was derived using the associated tag
* relationship (see Classification.json for more details). 'Propagated` indicates a tag
* label was propagated from upstream based on lineage. 'Automated' is used when a tool was
* used to determine the tag label.
*/
export enum LabelType {
Automated = "Automated",
Derived = "Derived",
Manual = "Manual",
Propagated = "Propagated",
}

/**
* Label is from Tags or Glossary.
*/
export enum TagSource {
Classification = "Classification",
Glossary = "Glossary",
}

/**
* 'Suggested' state is used when a tag label is suggested by users or tools. Owner of the
* entity must confirm the suggested labels before it is marked as 'Confirmed'.
*/
export enum State {
Confirmed = "Confirmed",
Suggested = "Suggested",
}

/**
* UI Style is used to associate a color code and/or icon to entity to customize the look of
* that entity in UI.
*/
export interface Style {
/**
* Hex Color Code to mark an entity such as GlossaryTerm, Tag, Domain or Data Product.
*/
color?: string;
/**
* An icon to associate with GlossaryTerm, Tag, Domain or Data Product.
*/
iconURL?: string;
}

/**
* Latest usage information for this database.
*
* This schema defines the type for usage details. Daily, weekly, and monthly aggregation of
* usage is computed along with the percentile rank based on the usage for a given day.
*/
export interface UsageDetails {
/**
* Daily usage stats of a data asset on the start date.
*/
dailyStats: UsageStats;
/**
* Date in UTC.
*/
date: Date;
/**
* Monthly (last 30 days) rolling usage stats of a data asset on the start date.
*/
monthlyStats?: UsageStats;
/**
* Weekly (last 7 days) rolling usage stats of a data asset on the start date.
*/
weeklyStats?: UsageStats;
}

/**
* Daily usage stats of a data asset on the start date.
*
* Type used to return usage statistics.
*
* Monthly (last 30 days) rolling usage stats of a data asset on the start date.
*
* Weekly (last 7 days) rolling usage stats of a data asset on the start date.
*/
export interface UsageStats {
/**
* Usage count of a data asset on the start date.
*/
count: number;
/**
* Optional daily percentile rank data asset use when relevant.
*/
percentileRank?: number;
}

/**
* Votes on the entity.
*
* This schema defines the Votes for a Data Asset.
*/
export interface Votes {
/**
* List of all the Users who downVoted
*/
downVoters?: EntityReference[];
/**
* Total down-votes the entity has
*/
downVotes?: number;
/**
* List of all the Users who upVoted
*/
upVoters?: EntityReference[];
/**
* Total up-votes the entity has
*/
upVotes?: number;
}
Loading

0 comments on commit 029a086

Please sign in to comment.