import type { JSONSupport, JSONSupportMixinProperties } from "../../core/JSONSupport.js";

export interface TableDataSourceProperties extends JSONSupportMixinProperties, Partial<Pick<TableDataSource, "dataSourceName" | "gdbVersion" | "workspaceId">> {}

/**
 * A table or feature class that resides in a registered workspace (either a folder or geodatabase).
 * In the case of a geodatabase, if versioned, use `version` to
 * switch to an alternate geodatabase version.
 *
 * @see [Sample - MapImageLayer: toggle sublayer visibility](https://developers.arcgis.com/javascript/latest/sample-code/layers-mapimagelayer-sublayers/)
 * @see [Sample - MapImageLayer: dynamic data layer with table join](https://developers.arcgis.com/javascript/latest/sample-code/layers-dynamicdatalayer-table-join/)
 * @see [ArcGIS REST API - Table data source](https://developers.arcgis.com/rest/services-reference/enterprise/data-source-object/#table-data-source)
 * @example
 * let layer = new MapImageLayer({
 *    url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
 *    sublayers: [{
 *      renderer: renderer,
 *      source: {
 *        type: "data-layer",
 *        dataSource: {
 *          type: "table",
 *          workspaceId: "MyDatabaseWorkspaceIDSSR2",
 *          dataSourceName: "ss6.gdb.Railroads"
 *        }
 *      }
 *    }]
 *  });
 */
export default abstract class TableDataSource extends JSONSupport {
  /** The name of the table in the registered workspace. */
  accessor dataSourceName: string;
  /** References the geodatabase version if multiple versions exist in the geodatabase. */
  accessor gdbVersion: string;
  /** This value is always `table`. */
  get type(): "table";
  /** The workspace where the table resides as defined in the ArcGIS Server Manager. */
  accessor workspaceId: string;
}