UNPKG

@gftdcojp/gftd-cli

Version:

GFTD Schema Management CLI - Drizzle-like schema management for Kafka and ksqlDB

71 lines 2.35 kB
"use strict"; /** * GFTD CLI Types - Category-theoretic Schema Management */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SchemaParser = exports.NamingConvention = exports.CategoricalNaming = void 0; // Category-theoretic Naming Convention class CategoricalNaming { constructor(templates) { this.templates = templates; } generateTopicName(orgId, topicName) { return this.templates.topic .replace('{name}', topicName) .replace('{org}', orgId) .replace('{ORG}', orgId.toUpperCase()); } generateStreamName(orgId, streamName) { return this.templates.stream .replace('{name}', streamName) .replace('{NAME}', streamName.toUpperCase()) .replace('{org}', orgId) .replace('{ORG}', orgId.toUpperCase()); } generateTableName(orgId, tableName) { return this.templates.table .replace('{name}', tableName) .replace('{NAME}', tableName.toUpperCase()) .replace('{org}', orgId) .replace('{ORG}', orgId.toUpperCase()); } } exports.CategoricalNaming = CategoricalNaming; // Legacy Naming Convention class NamingConvention { generateTopicName(orgId, topicName) { return topicName; } generateStreamName(orgId, streamName) { return `${orgId.toUpperCase()}_${streamName.toUpperCase()}`; } generateTableName(orgId, tableName) { return `${orgId.toUpperCase()}_${tableName.toUpperCase()}`; } } exports.NamingConvention = NamingConvention; // Parser utilities for compact schema syntax class SchemaParser { static parseColumnType(definition) { const [type, ...modifiers] = definition.split('('); const isPrimaryKey = modifiers.some(m => m.includes('PK')); const isKey = modifiers.some(m => m.includes('KEY')) || isPrimaryKey; return { name: '', type: type, key: isKey, primaryKey: isPrimaryKey }; } static parseFormat(format) { if (Array.isArray(format)) { return { valueFormat: format[0], keyFormat: format[1] }; } return { valueFormat: format }; } } exports.SchemaParser = SchemaParser; //# sourceMappingURL=index.js.map