@ikxvxn/databi-sharedtypes 0.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ import { Document } from 'mongoose';
2
+ export declare enum DataSourceStatusEnum {
3
+ inactive = 0,
4
+ active = 1,
5
+ syncing = 2,
6
+ error = 3,
7
+ incomplete = 4,
8
+ unknown = 5
9
+ }
10
+ export type DataSourceStatus = keyof typeof DataSourceStatusEnum;
11
+ export declare enum SyncModeEnum {
12
+ inactive = 0,
13
+ manual = 1,
14
+ automatic = 2
15
+ }
16
+ export type SyncMode = keyof typeof SyncModeEnum;
17
+ export declare enum AutomaticSyncModeEnum {
18
+ daily = 0,
19
+ weekly = 1,
20
+ monthly = 2
21
+ }
22
+ export type AutomaticSyncMode = keyof typeof AutomaticSyncModeEnum;
23
+ export declare enum TypeOfOriginEnum {
24
+ quickbooks_desktop = 0
25
+ }
26
+ export type TypeOfOrigin = keyof typeof TypeOfOriginEnum;
27
+ export interface ExternalDbShared {
28
+ name: string;
29
+ typeOfOrigin: TypeOfOrigin;
30
+ endpointUrl: string;
31
+ auth: any;
32
+ tables: ITable[];
33
+ status?: DataSourceStatus;
34
+ syncMode?: SyncMode;
35
+ automaticSyncMode?: AutomaticSyncMode;
36
+ createdAt?: Date | string;
37
+ }
38
+ export interface IParam {
39
+ name: string;
40
+ alias?: string;
41
+ type: string;
42
+ sourceRef?: string;
43
+ isKey?: boolean;
44
+ }
45
+ export interface ITable {
46
+ name: string;
47
+ alias?: string;
48
+ params?: IParam[];
49
+ lastSync?: Date | string;
50
+ initiallySynced: boolean;
51
+ progressiveSyncField?: string;
52
+ }
53
+ export interface IExternalDb extends ExternalDbShared, Document {
54
+ }
55
+ export interface IExternalDbClient extends ExternalDbShared {
56
+ id: string;
57
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeOfOriginEnum = exports.AutomaticSyncModeEnum = exports.SyncModeEnum = exports.DataSourceStatusEnum = void 0;
4
+ var DataSourceStatusEnum;
5
+ (function (DataSourceStatusEnum) {
6
+ DataSourceStatusEnum[DataSourceStatusEnum["inactive"] = 0] = "inactive";
7
+ DataSourceStatusEnum[DataSourceStatusEnum["active"] = 1] = "active";
8
+ DataSourceStatusEnum[DataSourceStatusEnum["syncing"] = 2] = "syncing";
9
+ DataSourceStatusEnum[DataSourceStatusEnum["error"] = 3] = "error";
10
+ DataSourceStatusEnum[DataSourceStatusEnum["incomplete"] = 4] = "incomplete";
11
+ DataSourceStatusEnum[DataSourceStatusEnum["unknown"] = 5] = "unknown";
12
+ })(DataSourceStatusEnum || (exports.DataSourceStatusEnum = DataSourceStatusEnum = {}));
13
+ var SyncModeEnum;
14
+ (function (SyncModeEnum) {
15
+ SyncModeEnum[SyncModeEnum["inactive"] = 0] = "inactive";
16
+ SyncModeEnum[SyncModeEnum["manual"] = 1] = "manual";
17
+ SyncModeEnum[SyncModeEnum["automatic"] = 2] = "automatic";
18
+ })(SyncModeEnum || (exports.SyncModeEnum = SyncModeEnum = {}));
19
+ var AutomaticSyncModeEnum;
20
+ (function (AutomaticSyncModeEnum) {
21
+ AutomaticSyncModeEnum[AutomaticSyncModeEnum["daily"] = 0] = "daily";
22
+ AutomaticSyncModeEnum[AutomaticSyncModeEnum["weekly"] = 1] = "weekly";
23
+ AutomaticSyncModeEnum[AutomaticSyncModeEnum["monthly"] = 2] = "monthly";
24
+ })(AutomaticSyncModeEnum || (exports.AutomaticSyncModeEnum = AutomaticSyncModeEnum = {}));
25
+ // Enum para origen de datos
26
+ var TypeOfOriginEnum;
27
+ (function (TypeOfOriginEnum) {
28
+ TypeOfOriginEnum[TypeOfOriginEnum["quickbooks_desktop"] = 0] = "quickbooks_desktop";
29
+ })(TypeOfOriginEnum || (exports.TypeOfOriginEnum = TypeOfOriginEnum = {}));
@@ -0,0 +1,14 @@
1
+ export interface IDistrito {
2
+ idDistrito: number;
3
+ idCanton: number;
4
+ nombre: string;
5
+ }
6
+ export interface ICanton {
7
+ idCanton: number;
8
+ idProvincia: number;
9
+ nombre: string;
10
+ }
11
+ export interface IProvincia {
12
+ idProvincia: number;
13
+ nombre: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export * from './company';
2
+ export * from './externalDb';
3
+ export * from './queryResult';
4
+ export * from './pagination';
5
+ export * from './defaultTablesByExternalDb';
6
+ export * from './auth';
7
+ export * from './geographic';
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./company"), exports);
18
+ __exportStar(require("./externalDb"), exports);
19
+ __exportStar(require("./queryResult"), exports);
20
+ __exportStar(require("./pagination"), exports);
21
+ __exportStar(require("./defaultTablesByExternalDb"), exports);
22
+ __exportStar(require("./auth"), exports);
23
+ __exportStar(require("./geographic"), exports);
@@ -0,0 +1,53 @@
1
+ import type { IPaginationInfo } from './pagination';
2
+ /** Tipos de visualización disponibles en Metabase */
3
+ export type MetabaseDisplayType = 'table' | 'bar' | 'line' | 'pie' | 'scalar' | 'row' | 'area' | 'combo' | 'pivot' | 'funnel' | 'scatter' | 'waterfall' | 'map';
4
+ /** Referencia a una pregunta/chart de Metabase */
5
+ export interface IMetabaseQuestion {
6
+ id: number;
7
+ name: string;
8
+ description?: string;
9
+ display: MetabaseDisplayType;
10
+ databaseId: number;
11
+ tableId?: number;
12
+ }
13
+ /** Configuración de embed firmado */
14
+ export interface IMetabaseEmbedPayload {
15
+ embedUrl: string;
16
+ expiresAt: number;
17
+ }
18
+ /** Resumen de base de datos en Metabase */
19
+ export interface IMetabaseDatabaseRef {
20
+ id: number;
21
+ name: string;
22
+ engine: string;
23
+ }
24
+ /** Respuesta al listar visualizaciones disponibles para una BD */
25
+ export interface IVisualizationListResponse {
26
+ questions: IMetabaseQuestion[];
27
+ metabaseDatabaseId: number | null;
28
+ }
29
+ /** URL de exploración para abrir Metabase query builder */
30
+ export interface IMetabaseExploreResponse {
31
+ url: string;
32
+ metabaseDatabaseId: number | null;
33
+ }
34
+ /** Categorías de análisis para agrupar visualizaciones */
35
+ export type AnalysisCategory = 'all' | 'counts' | 'charts' | 'distribution' | 'trends';
36
+ /** Tipos de display que representan datos crudos (excluidos de análisis) */
37
+ export declare const NON_ANALYSIS_DISPLAY_TYPES: MetabaseDisplayType[];
38
+ /** Mapeo de categoría de análisis → tipos de display de Metabase */
39
+ export declare const ANALYSIS_CATEGORY_DISPLAY_MAP: Record<Exclude<AnalysisCategory, 'all'>, MetabaseDisplayType[]>;
40
+ /** Tamaño de página por defecto para visualizaciones de análisis (2×2 grid) */
41
+ export declare const DEFAULT_ANALYSIS_PAGE_SIZE = 4;
42
+ /** Opciones de consulta para listar visualizaciones */
43
+ export interface IVisualizationQueryOptions {
44
+ page?: number;
45
+ limit?: number;
46
+ category?: AnalysisCategory;
47
+ }
48
+ /** Respuesta paginada de visualizaciones/análisis */
49
+ export interface IPaginatedVisualizationResponse {
50
+ questions: IMetabaseQuestion[];
51
+ pagination: IPaginationInfo;
52
+ metabaseDatabaseId: number | null;
53
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ANALYSIS_PAGE_SIZE = exports.ANALYSIS_CATEGORY_DISPLAY_MAP = exports.NON_ANALYSIS_DISPLAY_TYPES = void 0;
4
+ /** Tipos de display que representan datos crudos (excluidos de análisis) */
5
+ exports.NON_ANALYSIS_DISPLAY_TYPES = ['table'];
6
+ /** Mapeo de categoría de análisis → tipos de display de Metabase */
7
+ exports.ANALYSIS_CATEGORY_DISPLAY_MAP = {
8
+ counts: ['scalar', 'row'],
9
+ charts: ['bar', 'combo', 'waterfall'],
10
+ distribution: ['pie', 'funnel'],
11
+ trends: ['line', 'area', 'scatter'],
12
+ };
13
+ /** Tamaño de página por defecto para visualizaciones de análisis (2×2 grid) */
14
+ exports.DEFAULT_ANALYSIS_PAGE_SIZE = 4;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Interfaces para paginación de consultas de datos
3
+ */
4
+ /** Máximo de documentos por página permitido */
5
+ export declare const MAX_PAGE_SIZE = 100;
6
+ /** Tamaño de página por defecto */
7
+ export declare const DEFAULT_PAGE_SIZE = 20;
8
+ export interface IPaginatedRequest {
9
+ page?: number;
10
+ limit?: number;
11
+ sortBy?: string;
12
+ sortOrder?: 'asc' | 'desc';
13
+ search?: string;
14
+ }
15
+ export interface IPaginationInfo {
16
+ page: number;
17
+ limit: number;
18
+ totalItems: number;
19
+ totalPages: number;
20
+ hasNextPage: boolean;
21
+ hasPrevPage: boolean;
22
+ }
23
+ export interface IPaginatedResponse<T> {
24
+ data: T[];
25
+ pagination: IPaginationInfo;
26
+ }
27
+ /**
28
+ * Parámetros para solicitar datos paginados de una tabla.
29
+ * Usado tanto por el cliente (al enviar la request) como por el servidor (al recibirla).
30
+ */
31
+ export interface ITableDataRequest extends IPaginatedRequest {
32
+ externalDbId: string;
33
+ tableName: string;
34
+ searchColumns?: string[];
35
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Interfaces para paginación de consultas de datos
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_PAGE_SIZE = exports.MAX_PAGE_SIZE = void 0;
7
+ /** Máximo de documentos por página permitido */
8
+ exports.MAX_PAGE_SIZE = 100;
9
+ /** Tamaño de página por defecto */
10
+ exports.DEFAULT_PAGE_SIZE = 20;
@@ -0,0 +1,7 @@
1
+ import type { IExternalDb } from './externalDb.js';
2
+ export interface IQueryResult {
3
+ data: Record<string, unknown>[];
4
+ db: IExternalDb;
5
+ sql: string;
6
+ nextPageToken: string | undefined;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@ikxvxn/databi-sharedtypes",
3
+ "version": "0.0.42",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "build": "tsc -p tsconfig.json",
11
+ "release": "npm install && npm run build && npm version patch && npm publish"
12
+ },
13
+ "devDependencies": {
14
+ "@types/mongoose": "^5.11.96",
15
+ "@types/node": "^24.10.2",
16
+ "mongoose": "^9.0.1",
17
+ "typescript": "^5.9.3"
18
+ }
19
+ }