Skip to content
Open
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
161 changes: 0 additions & 161 deletions lib/metadata/data-collection.js

This file was deleted.

78 changes: 39 additions & 39 deletions lib/metadata/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ export interface ColumnInfo {
type: DataTypeInfo;
}

export enum ColumnKind {
Regular = 0,
Static,
Clustering,
PartitionKey,
}

export interface ColumnMetadata {
type: string;
kind: ColumnKind;
}

export enum IndexKind {
custom = 0,
keys,
Expand All @@ -58,48 +70,15 @@ export interface Index {
isKeysKind(): boolean;
}

export interface DataCollection {
bloomFilterFalsePositiveChance: number;
caching: string;
clusteringKeys: ColumnInfo[];
clusteringOrder: string[];
columns: ColumnInfo[];
columnsByName: { [key: string]: ColumnInfo };
comment: string;
compactionClass: string;
compactionOptions: { [option: string]: any };
compression: {
class?: string;
[option: string]: any;
};
crcCheckChange?: number;
defaultTtl: number;
extensions: { [option: string]: any };
gcGraceSeconds: number;
localReadRepairChance: number;
maxIndexInterval?: number;
minIndexInterval?: number;
name: string;
partitionKeys: ColumnInfo[];
populateCacheOnFlush: boolean;
readRepairChance: number;
speculativeRetry: string;
}

export interface MaterializedView extends DataCollection {
export interface MaterializedView extends TableMetadata {
tableName: string;
whereClause: string;
includeAllColumns: boolean;
}

export interface TableMetadata extends DataCollection {
indexes: Index[];
indexInterval?: number;
isCompact: boolean;
memtableFlushPeriod: number;
replicateOnWrite: boolean;
cdc?: boolean;
virtual: boolean;
export interface TableMetadata {
columns: { [name: string]: ColumnMetadata };
partitionKey: string[];
clusteringKey: string[];
partitioner: string | null;
}

export interface QueryTrace {
Expand Down Expand Up @@ -135,6 +114,27 @@ export interface Udt {
fields: ColumnInfo[];
}

export enum StrategyKind {
SimpleStrategy = 0,
NetworkTopologyStrategy,
LocalStrategy,
Other,
}

export type Strategy =
| { kind: StrategyKind.SimpleStrategy; replicationFactor: number }
| { kind: StrategyKind.NetworkTopologyStrategy; datacenterRepfactors: { [datacenter: string]: number } }
| { kind: StrategyKind.LocalStrategy }
| { kind: StrategyKind.Other; name: string; data: { [key: string]: string } };

export interface KeyspaceMetadata {
strategy: Strategy;
durableWrites: boolean;
tables: { [name: string]: TableMetadata };
views: { [name: string]: MaterializedView };
userDefinedTypes: { [name: string]: Udt };
}

export interface Metadata {
keyspaces: { [name: string]: { name: string; strategy: string } };

Expand Down
121 changes: 121 additions & 0 deletions lib/metadata/keyspace-metadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
"use strict";

const { _TableMetadata } = require("./table-metadata");
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This imports _TableMetadata from ./table-metadata, but table-metadata.js exports { TableMetadata, ColumnMetadata, ColumnKind } (no _TableMetadata). The destructured value will be undefined, which is confusing and makes the JSDoc below incorrect. Import TableMetadata (or remove the import entirely and reference the exported alias directly in JSDoc).

Copilot uses AI. Check for mistakes.

/**
* Identifies the replication strategy variant.
* @readonly
* @enum {number}
* @alias module:metadata~StrategyKind
*/
const StrategyKind = {
/**
* Deprecated in ScyllaDB.
*
* **Use only for a single datacenter and one rack.**
*
* Places the first replica on a node determined by the partitioner.
* Additional replicas are placed on the next nodes clockwise in the ring
* without considering topology (rack or datacenter location).
*/
SimpleStrategy: 0,
/**
* Use this strategy when you have (or plan to have) your cluster deployed across
* multiple datacenters. This strategy specifies how many replicas you want in each
* datacenter.
*
* `NetworkTopologyStrategy` places replicas in the same datacenter by walking the ring
* clockwise until reaching the first node in another rack. It attempts to place replicas
* on distinct racks because nodes in the same rack (or similar physical grouping) often
* fail at the same time due to power, cooling, or network issues.
*/
NetworkTopologyStrategy: 1,
/**
* Used for internal purposes, e.g. for system tables.
*/
LocalStrategy: 2,
/**
* Unknown other strategy, which is not supported by the driver.
*/
Other: 3,
};

StrategyKind.S;

Comment on lines +43 to +44
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StrategyKind.S; is a no-op statement and looks like an accidental leftover. It should be removed to avoid confusing readers (and to prevent accidental reliance on side effects that don’t exist).

Suggested change
StrategyKind.S;

Copilot uses AI. Check for mistakes.
/**
* Describes the replication strategy used by a keyspace.
* @alias module:metadata~Strategy
*/
class Strategy {
/**
* Identifies which strategy variant this is.
* @type {StrategyKind}
*/
kind;

/**
* Replication factor, i.e. how many replicas of each piece of data there are.
* (only set when {@link kind} is {@link StrategyKind.SimpleStrategy}).
* @type {number?}
*/
replicationFactor;

/**
* Replication factors of datacenters with given names, i.e. how many replicas of each piece
* of data there are in each datacenter.
* (only set when {@link kind} is {@link StrategyKind.NetworkTopologyStrategy}).
* @type {Object.<String, number>?}
*/
datacenterRepfactors;

/**
* Name of the strategy (only set when {@link kind} is {@link StrategyKind.Other}).
* @type {String?}
*/
name;

/**
* Additional parameters of the strategy, which the driver does not understand.
* (only set when {@link kind} is {@link StrategyKind.Other}).
* @type {Object.<String, String>?}
*/
data;
}

/**
* Describes a keyspace in the cluster.
* @alias module:metadata~KeyspaceMetadata
*/
class KeyspaceMetadata {
/**
* Replication strategy used by the keyspace.
* @type {Strategy}
*/
strategy;

/**
* Whether the keyspace has durable writes enabled.
* @type {Boolean}
*/
durableWrites;

/**
* Tables in the keyspace, keyed by table name.
* @type {Object.<String, _TableMetadata>}
*/
tables;

/**
* Materialized views in the keyspace, keyed by view name.
* @type {Object.<String, Object>}
*/
views;
Comment on lines +102 to +112
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc type for tables references _TableMetadata, but that symbol doesn’t exist/export (and the new TS types model tables as TableMetadata). This will produce broken docs and incorrect editor hints; update it to reference TableMetadata (and similarly consider tightening views/userDefinedTypes away from Object to match the public types).

Copilot uses AI. Check for mistakes.

/**
* User-defined types in the keyspace, keyed by type name.
* @type {Object.<String, Object>}
*/
userDefinedTypes;
}

module.exports = { KeyspaceMetadata, Strategy, StrategyKind };
Loading
Loading