@aivue/tabular-intelligence 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,244 @@
1
+ # @aivue/tabular-intelligence
2
+
3
+ > Tabular Foundation Model (TFM) integration for structured data analysis in Vue.js
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@aivue/tabular-intelligence.svg)](https://www.npmjs.com/package/@aivue/tabular-intelligence)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## 🎯 Features
9
+
10
+ - 🔌 **Generic TFM Client** - Connect to any HTTP-based Tabular Foundation Model API
11
+ - 📊 **Descriptive Statistics** - Mean, median, mode, std dev, percentiles, distributions
12
+ - 🚨 **Anomaly Detection** - Statistical and ML-based outlier detection
13
+ - 🎯 **Segmentation & Clustering** - K-means, DBSCAN, hierarchical clustering
14
+ - 🔮 **Predictions** - Time series forecasting and predictive modeling
15
+ - 📈 **Correlation Analysis** - Pearson correlation matrices and significance testing
16
+ - 🔄 **Local Fallback** - Built-in statistical analysis when API is unavailable
17
+ - 🎨 **Vue Integration** - Reactive composables for seamless Vue.js integration
18
+ - 📦 **Smart DataTable Ready** - Designed to work with @aivue/smart-datatable
19
+
20
+ ## 📦 Installation
21
+
22
+ ```bash
23
+ npm install @aivue/tabular-intelligence
24
+ ```
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ ### Basic Usage
29
+
30
+ ```typescript
31
+ import { useTabularIntelligence } from '@aivue/tabular-intelligence';
32
+
33
+ const { analyze, getDescriptiveStats, detectAnomalies } = useTabularIntelligence({
34
+ config: {
35
+ provider: 'custom',
36
+ baseUrl: 'https://your-tfm-api.com/analyze',
37
+ apiKey: 'your-api-key',
38
+ },
39
+ data: ref(yourData),
40
+ useLocalFallback: true, // Use local analysis if API fails
41
+ });
42
+
43
+ // Get descriptive statistics
44
+ const stats = await getDescriptiveStats();
45
+
46
+ // Detect anomalies
47
+ const anomalies = await detectAnomalies(['price', 'quantity'], 0.7);
48
+
49
+ // Perform clustering
50
+ const clusters = await performClustering(['feature1', 'feature2'], 3);
51
+ ```
52
+
53
+ ### With Smart DataTable
54
+
55
+ ```vue
56
+ <template>
57
+ <div>
58
+ <SmartDataTable :data="tableData" :columns="columns" />
59
+
60
+ <button @click="analyzeData">Analyze Data</button>
61
+
62
+ <div v-if="anomalies.length">
63
+ <h3>Anomalies Detected: {{ anomalies.length }}</h3>
64
+ <div v-for="anomaly in anomalies" :key="anomaly.rowIndex">
65
+ Row {{ anomaly.rowIndex }}: {{ anomaly.reasons.join(', ') }}
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </template>
70
+
71
+ <script setup>
72
+ import { ref } from 'vue';
73
+ import { SmartDataTable } from '@aivue/smart-datatable';
74
+ import { useTabularIntelligence } from '@aivue/tabular-intelligence';
75
+
76
+ const tableData = ref([
77
+ { id: 1, name: 'Product A', price: 100, quantity: 50 },
78
+ { id: 2, name: 'Product B', price: 200, quantity: 30 },
79
+ { id: 3, name: 'Product C', price: 9999, quantity: 1 }, // Anomaly!
80
+ ]);
81
+
82
+ const { detectAnomalies } = useTabularIntelligence({
83
+ config: {
84
+ provider: 'custom',
85
+ baseUrl: 'https://api.example.com/tfm',
86
+ },
87
+ data: tableData,
88
+ useLocalFallback: true,
89
+ });
90
+
91
+ const anomalies = ref([]);
92
+
93
+ async function analyzeData() {
94
+ anomalies.value = await detectAnomalies(['price', 'quantity']);
95
+ }
96
+ </script>
97
+ ```
98
+
99
+ ## 📖 API Reference
100
+
101
+ ### `useTabularIntelligence(options)`
102
+
103
+ Main composable for tabular intelligence.
104
+
105
+ **Options:**
106
+ - `config: TFMConfig` - TFM API configuration
107
+ - `data?: Ref<any[]>` - Reactive data array
108
+ - `schema?: Ref<TableSchema>` - Optional table schema
109
+ - `useLocalFallback?: boolean` - Enable local analysis fallback (default: true)
110
+
111
+ **Returns:**
112
+ - `client: TabularIntelligence` - Core TFM client instance
113
+ - `loading: Ref<boolean>` - Loading state
114
+ - `error: Ref<Error | null>` - Error state
115
+ - `lastResult: Ref<AnalysisResult | null>` - Last analysis result
116
+ - `data: Ref<any[]>` - Data array
117
+ - `schema: Ref<TableSchema | null>` - Inferred or provided schema
118
+ - `analyze(type, options)` - Generic analysis method
119
+ - `getDescriptiveStats()` - Get descriptive statistics
120
+ - `detectAnomalies(columns?, sensitivity?)` - Detect anomalies
121
+ - `performClustering(features, numClusters?)` - Perform clustering
122
+ - `predict(targetColumn, options?)` - Make predictions
123
+ - `updateConfig(config)` - Update TFM configuration
124
+ - `setData(data, autoInferSchema?)` - Set new data
125
+ - `reset()` - Reset state
126
+
127
+ ### Analysis Types
128
+
129
+ ```typescript
130
+ type AnalysisType =
131
+ | 'descriptive_stats' // Mean, median, std dev, percentiles
132
+ | 'anomaly_detection' // Outlier detection
133
+ | 'segmentation' // Data segmentation
134
+ | 'clustering' // K-means, DBSCAN, etc.
135
+ | 'prediction' // Forecasting
136
+ | 'correlation' // Correlation analysis
137
+ | 'trend_analysis' // Trend detection
138
+ | 'outlier_detection'; // Statistical outliers
139
+ ```
140
+
141
+ ### TFM Configuration
142
+
143
+ ```typescript
144
+ interface TFMConfig {
145
+ provider: 'custom' | 'openai' | 'anthropic' | 'huggingface' | 'local';
146
+ baseUrl: string; // API endpoint
147
+ apiKey?: string; // API key
148
+ model?: string; // Model name
149
+ headers?: Record<string, string>; // Custom headers
150
+ timeout?: number; // Request timeout (ms)
151
+ }
152
+ ```
153
+
154
+ ## 🔧 Advanced Usage
155
+
156
+ ### Custom TFM API Integration
157
+
158
+ ```typescript
159
+ const { analyze } = useTabularIntelligence({
160
+ config: {
161
+ provider: 'custom',
162
+ baseUrl: 'https://your-tfm.com/api/v1/analyze',
163
+ apiKey: process.env.TFM_API_KEY,
164
+ headers: {
165
+ 'X-Custom-Header': 'value',
166
+ },
167
+ timeout: 60000,
168
+ },
169
+ });
170
+
171
+ // Custom analysis
172
+ const result = await analyze('clustering', {
173
+ features: ['age', 'income', 'spending'],
174
+ numClusters: 5,
175
+ algorithm: 'kmeans',
176
+ });
177
+ ```
178
+
179
+ ### Local Analysis (No API Required)
180
+
181
+ ```typescript
182
+ const { getDescriptiveStats, detectAnomalies } = useTabularIntelligence({
183
+ config: {
184
+ provider: 'local',
185
+ baseUrl: '', // Not used for local
186
+ },
187
+ data: ref(myData),
188
+ useLocalFallback: true,
189
+ });
190
+
191
+ // These will use built-in statistical methods
192
+ const stats = await getDescriptiveStats();
193
+ const anomalies = await detectAnomalies();
194
+ ```
195
+
196
+ ## 🎨 Integration with @aivue/smart-datatable
197
+
198
+ Perfect companion for SmartDataTable:
199
+
200
+ ```typescript
201
+ import { useSmartDataTable } from '@aivue/smart-datatable';
202
+ import { useTabularIntelligence } from '@aivue/tabular-intelligence';
203
+
204
+ const { data, filteredData } = useSmartDataTable({ data: ref(orders) });
205
+
206
+ const { analyze } = useTabularIntelligence({
207
+ config: tfmConfig,
208
+ data: filteredData, // Analyze filtered data
209
+ });
210
+ ```
211
+
212
+ ## 📊 Example: Complete Analysis Pipeline
213
+
214
+ ```typescript
215
+ const pipeline = async () => {
216
+ // 1. Get descriptive statistics
217
+ const stats = await getDescriptiveStats();
218
+ console.log('Statistics:', stats);
219
+
220
+ // 2. Detect anomalies
221
+ const anomalies = await detectAnomalies(['price', 'quantity'], 0.8);
222
+ console.log('Anomalies:', anomalies);
223
+
224
+ // 3. Perform clustering
225
+ const clusters = await performClustering(['price', 'quantity'], 3);
226
+ console.log('Clusters:', clusters);
227
+
228
+ // 4. Make predictions
229
+ const predictions = await predict('sales', {
230
+ predictionHorizon: 30,
231
+ confidenceLevel: 0.95,
232
+ });
233
+ console.log('Predictions:', predictions);
234
+ };
235
+ ```
236
+
237
+ ## 🤝 Contributing
238
+
239
+ Contributions are welcome! Please see [CONTRIBUTING.md](../../CONTRIBUTING.md).
240
+
241
+ ## 📄 License
242
+
243
+ MIT © [reachbrt](https://github.com/reachbrt)
244
+
@@ -0,0 +1,27 @@
1
+ import { Ref } from 'vue';
2
+ import { TabularIntelligence } from '../core/TabularIntelligence';
3
+ import { TFMConfig, AnalysisResult, AnalysisType, TableSchema, DescriptiveStats, Anomaly } from '../types';
4
+ export interface UseTabularIntelligenceOptions {
5
+ config: TFMConfig;
6
+ data?: Ref<any[]>;
7
+ schema?: Ref<TableSchema>;
8
+ useLocalFallback?: boolean;
9
+ }
10
+ export interface UseTabularIntelligenceReturn {
11
+ client: TabularIntelligence;
12
+ loading: Ref<boolean>;
13
+ error: Ref<Error | null>;
14
+ lastResult: Ref<AnalysisResult | null>;
15
+ data: Ref<any[]>;
16
+ schema: Ref<TableSchema | null>;
17
+ analyze: (type: AnalysisType, options?: any) => Promise<AnalysisResult>;
18
+ getDescriptiveStats: () => Promise<DescriptiveStats[]>;
19
+ detectAnomalies: (columns?: string[], sensitivity?: number) => Promise<Anomaly[]>;
20
+ performClustering: (features: string[], numClusters?: number) => Promise<AnalysisResult>;
21
+ predict: (targetColumn: string, options?: any) => Promise<AnalysisResult>;
22
+ updateConfig: (config: Partial<TFMConfig>) => void;
23
+ setData: (newData: any[], autoInferSchema?: boolean) => void;
24
+ reset: () => void;
25
+ }
26
+ export declare function useTabularIntelligence(options: UseTabularIntelligenceOptions): UseTabularIntelligenceReturn;
27
+ //# sourceMappingURL=useTabularIntelligence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTabularIntelligence.d.ts","sourceRoot":"","sources":["../../src/composables/useTabularIntelligence.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAiB,GAAG,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EACV,SAAS,EAET,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,OAAO,EACR,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,SAAS,CAA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AM,IAAI,CAAC;CACnB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,4BAA4B,CAiK9B"}
@@ -0,0 +1,26 @@
1
+ import { TFMConfig, AnalysisRequest, AnalysisResult } from '../types';
2
+ export declare class TabularIntelligence {
3
+ private config;
4
+ constructor(config: TFMConfig);
5
+ /**
6
+ * Generic API call to TFM endpoint
7
+ */
8
+ private callTFM;
9
+ /**
10
+ * Perform analysis on tabular data
11
+ */
12
+ analyze(request: AnalysisRequest): Promise<AnalysisResult>;
13
+ /**
14
+ * Parse TFM response into structured AnalysisResult
15
+ */
16
+ private parseAnalysisResult;
17
+ /**
18
+ * Update configuration
19
+ */
20
+ updateConfig(config: Partial<TFMConfig>): void;
21
+ /**
22
+ * Get current configuration (without sensitive data)
23
+ */
24
+ getConfig(): Omit<TFMConfig, 'apiKey'>;
25
+ }
26
+ //# sourceMappingURL=TabularIntelligence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabularIntelligence.d.ts","sourceRoot":"","sources":["../../src/core/TabularIntelligence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,SAAS,EAGT,eAAe,EACf,cAAc,EAQf,MAAM,UAAU,CAAC;AAElB,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAY;gBAEd,MAAM,EAAE,SAAS;IAO7B;;OAEG;YACW,OAAO;IA+CrB;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAkBhE;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAoD3B;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;IAI9C;;OAEG;IACH,SAAS,IAAI,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;CAIvC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @aivue/tabular-intelligence
3
+ * Tabular Foundation Model (TFM) integration for Vue.js
4
+ */
5
+ export { TabularIntelligence } from './core/TabularIntelligence';
6
+ export { useTabularIntelligence } from './composables/useTabularIntelligence';
7
+ export type { UseTabularIntelligenceOptions, UseTabularIntelligenceReturn } from './composables/useTabularIntelligence';
8
+ export { inferSchema, inferColumnType, calculateStats, detectAnomalies } from './utils/helpers';
9
+ export type { TFMProvider, TFMConfig, TableColumn, TableSchema, AnalysisType, AnalysisRequest, AnalysisOptions, AnalysisResult, DescriptiveStats, Anomaly, Cluster, Prediction, CorrelationMatrix, TFMRequest, TFMResponse, } from './types';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,YAAY,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAGxH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhG,YAAY,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,GACZ,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("vue");class A{constructor(s){this.config={timeout:3e4,...s}}async callTFM(s){const e=Date.now();try{const n=await fetch(this.config.baseUrl,{method:"POST",headers:{"Content-Type":"application/json",...this.config.apiKey&&{Authorization:`Bearer ${this.config.apiKey}`},...this.config.headers},body:JSON.stringify({...s,model:this.config.model}),signal:AbortSignal.timeout(this.config.timeout||3e4)});if(!n.ok){const o=await n.text();throw new Error(`TFM API error: ${n.status} - ${o}`)}const t=await n.json(),i=Date.now()-e;return{success:!0,result:t.result||t,metadata:{processingTime:i,model:this.config.model||"unknown",version:t.version}}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error",metadata:{processingTime:Date.now()-e,model:this.config.model||"unknown"}}}}async analyze(s){const e={operation:s.type,data:s.data,schema:s.schema,parameters:s.options},n=await this.callTFM(e);if(!n.success)throw new Error(n.error||"Analysis failed");return this.parseAnalysisResult(s.type,n.result,n.metadata)}parseAnalysisResult(s,e,n){const t={type:s,timestamp:new Date,summary:e.summary||"",insights:e.insights||[],recommendations:e.recommendations,confidence:e.confidence||.8,processingTime:n==null?void 0:n.processingTime};switch(s){case"descriptive_stats":return{...t,descriptiveStats:e.stats||e.descriptiveStats};case"anomaly_detection":return{...t,anomalies:e.anomalies||[]};case"segmentation":case"clustering":return{...t,clusters:e.clusters||[]};case"prediction":return{...t,predictions:e.predictions||e};case"correlation":return{...t,correlations:e.correlations||e};default:return t}}updateConfig(s){this.config={...this.config,...s}}getConfig(){const{apiKey:s,...e}=this.config;return e}}function M(c,s){if(c.length===0)return{columns:[],rowCount:0,name:s};const e=c[0];return{columns:Object.keys(e).map(t=>{const i=N(c,t);return{name:t,type:i,nullable:c.some(o=>o[t]==null)}}),rowCount:c.length,name:s}}function N(c,s){const e=c.map(t=>t[s]).filter(t=>t!=null);if(e.length===0)return"string";if(e.every(t=>typeof t=="number"||!isNaN(Number(t))))return"number";if(e.every(t=>typeof t=="boolean"||t==="true"||t==="false"))return"boolean";if(e.every(t=>!isNaN(Date.parse(t))))return"date";const n=new Set(e);return n.size<e.length*.5&&n.size<20?"categorical":"string"}function $(c,s,e){const n=c.map(l=>l[s]).filter(l=>l!=null),t=n.length,i=c.length-t,o={column:s,count:t,nullCount:i};if(e==="number"){const l=n.map(Number).filter(r=>!isNaN(r));if(l.length>0){const r=[...l].sort((u,d)=>u-d),p=l.reduce((u,d)=>u+d,0);o.mean=p/l.length,o.median=r[Math.floor(r.length/2)],o.min=r[0],o.max=r[r.length-1];const h=l.reduce((u,d)=>u+Math.pow(d-o.mean,2),0)/l.length;o.std=Math.sqrt(h),o.percentiles={25:r[Math.floor(r.length*.25)],50:o.median,75:r[Math.floor(r.length*.75)],90:r[Math.floor(r.length*.9)]}}}else{const l=new Set(n);o.uniqueValues=l.size;const r={};n.forEach(h=>{const u=String(h);r[u]=(r[u]||0)+1});const p=Math.max(...Object.values(r));o.mode=Object.keys(r).find(h=>r[h]===p)}return o}function F(c,s,e=.5){const n=[],t=1.5+(1-e)*1.5;return s.forEach(i=>{const o=c.map((m,g)=>({value:Number(m[i]),idx:g})).filter(m=>!isNaN(m.value));if(o.length===0)return;const l=[...o].sort((m,g)=>m.value-g.value),r=l[Math.floor(l.length*.25)].value,p=l[Math.floor(l.length*.75)].value,h=p-r,u=r-t*h,d=p+t*h;o.forEach(({value:m,idx:g})=>{if(m<u||m>d){const v=n.find(a=>a.rowIndex===g),C=m<u?`${i}: ${m.toFixed(2)} < ${u.toFixed(2)}`:`${i}: ${m.toFixed(2)} > ${d.toFixed(2)}`;v?(v.reasons.push(C),v.affectedColumns.push(i),v.score=Math.min(1,v.score+.2)):n.push({rowIndex:g,row:c[g],score:.7,reasons:[C],affectedColumns:[i]})}})}),n.sort((i,o)=>o.score-i.score)}function x(c){const s=new A(c.config),e=T.ref(!1),n=T.ref(null),t=T.ref(null),i=c.data||T.ref([]),o=c.schema||T.ref(null),l=c.useLocalFallback!==!1;async function r(a,f){e.value=!0,n.value=null;try{const y={type:a,data:i.value,schema:o.value||void 0,options:f},w=await s.analyze(y);return t.value=w,w}catch(y){if(n.value=y instanceof Error?y:new Error("Analysis failed"),l)return p(a,f);throw n.value}finally{e.value=!1}}function p(a,f){const y=o.value||M(i.value);switch(a){case"descriptive_stats":{const w=y.columns.map(b=>$(i.value,b.name,b.type));return{type:a,timestamp:new Date,descriptiveStats:w,summary:`Calculated statistics for ${w.length} columns`,insights:[],confidence:.9}}case"anomaly_detection":{const w=y.columns.filter(S=>S.type==="number").map(S=>S.name),b=F(i.value,w,f==null?void 0:f.sensitivity);return{type:a,timestamp:new Date,anomalies:b,summary:`Found ${b.length} anomalies`,insights:b.slice(0,3).map(S=>S.reasons[0]),confidence:.8}}default:throw new Error(`Local analysis not supported for type: ${a}`)}}async function h(){return(await r("descriptive_stats")).descriptiveStats||[]}async function u(a,f){return(await r("anomaly_detection",{sensitivity:f,features:a})).anomalies||[]}async function d(a,f=3){return r("clustering",{features:a,numClusters:f})}async function m(a,f){return r("prediction",{targetColumn:a,...f})}function g(a){s.updateConfig(a)}function v(a,f=!0){i.value=a,f&&(o.value=M(a))}function C(){e.value=!1,n.value=null,t.value=null}return{client:s,loading:e,error:n,lastResult:t,data:i,schema:o,analyze:r,getDescriptiveStats:h,detectAnomalies:u,performClustering:d,predict:m,updateConfig:g,setData:v,reset:C}}exports.TabularIntelligence=A;exports.calculateStats=$;exports.detectAnomalies=F;exports.inferColumnType=N;exports.inferSchema=M;exports.useTabularIntelligence=x;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/core/TabularIntelligence.ts","../src/utils/helpers.ts","../src/composables/useTabularIntelligence.ts"],"sourcesContent":["/**\n * TabularIntelligence - Core TFM Client\n * Generic client for Tabular Foundation Model APIs\n */\n\nimport type {\n TFMConfig,\n TFMRequest,\n TFMResponse,\n AnalysisRequest,\n AnalysisResult,\n AnalysisType,\n TableSchema,\n DescriptiveStats,\n Anomaly,\n Cluster,\n Prediction,\n CorrelationMatrix,\n} from '../types';\n\nexport class TabularIntelligence {\n private config: TFMConfig;\n\n constructor(config: TFMConfig) {\n this.config = {\n timeout: 30000,\n ...config,\n };\n }\n\n /**\n * Generic API call to TFM endpoint\n */\n private async callTFM(request: TFMRequest): Promise<TFMResponse> {\n const startTime = Date.now();\n\n try {\n const response = await fetch(this.config.baseUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }),\n ...this.config.headers,\n },\n body: JSON.stringify({\n ...request,\n model: this.config.model,\n }),\n signal: AbortSignal.timeout(this.config.timeout || 30000),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`TFM API error: ${response.status} - ${error}`);\n }\n\n const result = await response.json();\n const processingTime = Date.now() - startTime;\n\n return {\n success: true,\n result: result.result || result,\n metadata: {\n processingTime,\n model: this.config.model || 'unknown',\n version: result.version,\n },\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n metadata: {\n processingTime: Date.now() - startTime,\n model: this.config.model || 'unknown',\n },\n };\n }\n }\n\n /**\n * Perform analysis on tabular data\n */\n async analyze(request: AnalysisRequest): Promise<AnalysisResult> {\n const tfmRequest: TFMRequest = {\n operation: request.type,\n data: request.data,\n schema: request.schema,\n parameters: request.options,\n };\n\n const response = await this.callTFM(tfmRequest);\n\n if (!response.success) {\n throw new Error(response.error || 'Analysis failed');\n }\n\n // Parse response based on analysis type\n return this.parseAnalysisResult(request.type, response.result, response.metadata);\n }\n\n /**\n * Parse TFM response into structured AnalysisResult\n */\n private parseAnalysisResult(\n type: AnalysisType,\n result: any,\n metadata?: any\n ): AnalysisResult {\n const baseResult: AnalysisResult = {\n type,\n timestamp: new Date(),\n summary: result.summary || '',\n insights: result.insights || [],\n recommendations: result.recommendations,\n confidence: result.confidence || 0.8,\n processingTime: metadata?.processingTime,\n };\n\n switch (type) {\n case 'descriptive_stats':\n return {\n ...baseResult,\n descriptiveStats: result.stats || result.descriptiveStats,\n };\n\n case 'anomaly_detection':\n return {\n ...baseResult,\n anomalies: result.anomalies || [],\n };\n\n case 'segmentation':\n case 'clustering':\n return {\n ...baseResult,\n clusters: result.clusters || [],\n };\n\n case 'prediction':\n return {\n ...baseResult,\n predictions: result.predictions || result,\n };\n\n case 'correlation':\n return {\n ...baseResult,\n correlations: result.correlations || result,\n };\n\n default:\n return baseResult;\n }\n }\n\n /**\n * Update configuration\n */\n updateConfig(config: Partial<TFMConfig>): void {\n this.config = { ...this.config, ...config };\n }\n\n /**\n * Get current configuration (without sensitive data)\n */\n getConfig(): Omit<TFMConfig, 'apiKey'> {\n const { apiKey, ...safeConfig } = this.config;\n return safeConfig;\n }\n}\n\n","/**\n * Helper utilities for tabular intelligence\n */\n\nimport type { TableSchema, TableColumn, DescriptiveStats, Anomaly, Cluster } from '../types';\n\n/**\n * Infer table schema from data\n */\nexport function inferSchema(data: any[], name?: string): TableSchema {\n if (data.length === 0) {\n return { columns: [], rowCount: 0, name };\n }\n\n const firstRow = data[0];\n const columns: TableColumn[] = Object.keys(firstRow).map((key) => {\n const type = inferColumnType(data, key);\n return {\n name: key,\n type,\n nullable: data.some((row) => row[key] == null),\n };\n });\n\n return {\n columns,\n rowCount: data.length,\n name,\n };\n}\n\n/**\n * Infer column type from data\n */\nexport function inferColumnType(data: any[], column: string): TableColumn['type'] {\n const values = data.map((row) => row[column]).filter((v) => v != null);\n \n if (values.length === 0) return 'string';\n\n // Check if all values are numbers\n if (values.every((v) => typeof v === 'number' || !isNaN(Number(v)))) {\n return 'number';\n }\n\n // Check if all values are booleans\n if (values.every((v) => typeof v === 'boolean' || v === 'true' || v === 'false')) {\n return 'boolean';\n }\n\n // Check if values look like dates\n if (values.every((v) => !isNaN(Date.parse(v)))) {\n return 'date';\n }\n\n // Check if categorical (limited unique values)\n const uniqueValues = new Set(values);\n if (uniqueValues.size < values.length * 0.5 && uniqueValues.size < 20) {\n return 'categorical';\n }\n\n return 'string';\n}\n\n/**\n * Calculate basic descriptive statistics\n */\nexport function calculateStats(data: any[], column: string, type: TableColumn['type']): DescriptiveStats {\n const values = data.map((row) => row[column]).filter((v) => v != null);\n const count = values.length;\n const nullCount = data.length - count;\n\n const stats: DescriptiveStats = {\n column,\n count,\n nullCount,\n };\n\n if (type === 'number') {\n const numbers = values.map(Number).filter((n) => !isNaN(n));\n \n if (numbers.length > 0) {\n const sorted = [...numbers].sort((a, b) => a - b);\n const sum = numbers.reduce((a, b) => a + b, 0);\n \n stats.mean = sum / numbers.length;\n stats.median = sorted[Math.floor(sorted.length / 2)];\n stats.min = sorted[0];\n stats.max = sorted[sorted.length - 1];\n \n const variance = numbers.reduce((acc, val) => acc + Math.pow(val - stats.mean!, 2), 0) / numbers.length;\n stats.std = Math.sqrt(variance);\n \n stats.percentiles = {\n '25': sorted[Math.floor(sorted.length * 0.25)],\n '50': stats.median,\n '75': sorted[Math.floor(sorted.length * 0.75)],\n '90': sorted[Math.floor(sorted.length * 0.90)],\n };\n }\n } else {\n const uniqueValues = new Set(values);\n stats.uniqueValues = uniqueValues.size;\n \n const frequency: Record<string, number> = {};\n values.forEach((v) => {\n const key = String(v);\n frequency[key] = (frequency[key] || 0) + 1;\n });\n \n const maxFreq = Math.max(...Object.values(frequency));\n stats.mode = Object.keys(frequency).find((k) => frequency[k] === maxFreq);\n }\n\n return stats;\n}\n\n/**\n * Detect anomalies using IQR method\n */\nexport function detectAnomalies(data: any[], columns: string[], sensitivity: number = 0.5): Anomaly[] {\n const anomalies: Anomaly[] = [];\n const multiplier = 1.5 + (1 - sensitivity) * 1.5;\n\n columns.forEach((column) => {\n const values = data.map((row, idx) => ({ value: Number(row[column]), idx }))\n .filter((v) => !isNaN(v.value));\n\n if (values.length === 0) return;\n\n const sorted = [...values].sort((a, b) => a.value - b.value);\n const q1 = sorted[Math.floor(sorted.length * 0.25)].value;\n const q3 = sorted[Math.floor(sorted.length * 0.75)].value;\n const iqr = q3 - q1;\n const lowerBound = q1 - multiplier * iqr;\n const upperBound = q3 + multiplier * iqr;\n\n values.forEach(({ value, idx }) => {\n if (value < lowerBound || value > upperBound) {\n const existing = anomalies.find((a) => a.rowIndex === idx);\n const reason = value < lowerBound\n ? `${column}: ${value.toFixed(2)} < ${lowerBound.toFixed(2)}`\n : `${column}: ${value.toFixed(2)} > ${upperBound.toFixed(2)}`;\n\n if (existing) {\n existing.reasons.push(reason);\n existing.affectedColumns.push(column);\n existing.score = Math.min(1, existing.score + 0.2);\n } else {\n anomalies.push({\n rowIndex: idx,\n row: data[idx],\n score: 0.7,\n reasons: [reason],\n affectedColumns: [column],\n });\n }\n }\n });\n });\n\n return anomalies.sort((a, b) => b.score - a.score);\n}\n\n","/**\n * Vue Composable for Tabular Intelligence\n */\n\nimport { ref, computed, Ref } from 'vue';\nimport { TabularIntelligence } from '../core/TabularIntelligence';\nimport type {\n TFMConfig,\n AnalysisRequest,\n AnalysisResult,\n AnalysisType,\n TableSchema,\n DescriptiveStats,\n Anomaly,\n} from '../types';\nimport { inferSchema, calculateStats, detectAnomalies } from '../utils/helpers';\n\nexport interface UseTabularIntelligenceOptions {\n config: TFMConfig;\n data?: Ref<any[]>;\n schema?: Ref<TableSchema>;\n useLocalFallback?: boolean;\n}\n\nexport interface UseTabularIntelligenceReturn {\n // Core client\n client: TabularIntelligence;\n \n // State\n loading: Ref<boolean>;\n error: Ref<Error | null>;\n lastResult: Ref<AnalysisResult | null>;\n \n // Data\n data: Ref<any[]>;\n schema: Ref<TableSchema | null>;\n \n // Methods\n analyze: (type: AnalysisType, options?: any) => Promise<AnalysisResult>;\n getDescriptiveStats: () => Promise<DescriptiveStats[]>;\n detectAnomalies: (columns?: string[], sensitivity?: number) => Promise<Anomaly[]>;\n performClustering: (features: string[], numClusters?: number) => Promise<AnalysisResult>;\n predict: (targetColumn: string, options?: any) => Promise<AnalysisResult>;\n updateConfig: (config: Partial<TFMConfig>) => void;\n setData: (newData: any[], autoInferSchema?: boolean) => void;\n reset: () => void;\n}\n\nexport function useTabularIntelligence(\n options: UseTabularIntelligenceOptions\n): UseTabularIntelligenceReturn {\n const client = new TabularIntelligence(options.config);\n \n const loading = ref(false);\n const error = ref<Error | null>(null);\n const lastResult = ref<AnalysisResult | null>(null);\n \n const data = options.data || ref<any[]>([]);\n const schema = options.schema || ref<TableSchema | null>(null);\n \n const useLocalFallback = options.useLocalFallback !== false;\n\n /**\n * Generic analyze method\n */\n async function analyze(type: AnalysisType, analysisOptions?: any): Promise<AnalysisResult> {\n loading.value = true;\n error.value = null;\n\n try {\n const request: AnalysisRequest = {\n type,\n data: data.value,\n schema: schema.value || undefined,\n options: analysisOptions,\n };\n\n const result = await client.analyze(request);\n lastResult.value = result;\n return result;\n } catch (err) {\n error.value = err instanceof Error ? err : new Error('Analysis failed');\n \n // Try local fallback if enabled\n if (useLocalFallback) {\n return performLocalAnalysis(type, analysisOptions);\n }\n \n throw error.value;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Local fallback analysis\n */\n function performLocalAnalysis(type: AnalysisType, analysisOptions?: any): AnalysisResult {\n const currentSchema = schema.value || inferSchema(data.value);\n \n switch (type) {\n case 'descriptive_stats': {\n const stats = currentSchema.columns.map((col) =>\n calculateStats(data.value, col.name, col.type)\n );\n return {\n type,\n timestamp: new Date(),\n descriptiveStats: stats,\n summary: `Calculated statistics for ${stats.length} columns`,\n insights: [],\n confidence: 0.9,\n };\n }\n\n case 'anomaly_detection': {\n const numericColumns = currentSchema.columns\n .filter((col) => col.type === 'number')\n .map((col) => col.name);\n const anomalies = detectAnomalies(\n data.value,\n numericColumns,\n analysisOptions?.sensitivity\n );\n return {\n type,\n timestamp: new Date(),\n anomalies,\n summary: `Found ${anomalies.length} anomalies`,\n insights: anomalies.slice(0, 3).map((a) => a.reasons[0]),\n confidence: 0.8,\n };\n }\n\n default:\n throw new Error(`Local analysis not supported for type: ${type}`);\n }\n }\n\n /**\n * Get descriptive statistics\n */\n async function getDescriptiveStats(): Promise<DescriptiveStats[]> {\n const result = await analyze('descriptive_stats');\n return result.descriptiveStats || [];\n }\n\n /**\n * Detect anomalies\n */\n async function detectAnomaliesMethod(columns?: string[], sensitivity?: number): Promise<Anomaly[]> {\n const result = await analyze('anomaly_detection', { sensitivity, features: columns });\n return result.anomalies || [];\n }\n\n /**\n * Perform clustering\n */\n async function performClustering(features: string[], numClusters: number = 3): Promise<AnalysisResult> {\n return analyze('clustering', { features, numClusters });\n }\n\n /**\n * Make predictions\n */\n async function predict(targetColumn: string, predictionOptions?: any): Promise<AnalysisResult> {\n return analyze('prediction', { targetColumn, ...predictionOptions });\n }\n\n /**\n * Update TFM configuration\n */\n function updateConfig(newConfig: Partial<TFMConfig>): void {\n client.updateConfig(newConfig);\n }\n\n /**\n * Set new data\n */\n function setData(newData: any[], autoInferSchema: boolean = true): void {\n data.value = newData;\n if (autoInferSchema) {\n schema.value = inferSchema(newData);\n }\n }\n\n /**\n * Reset state\n */\n function reset(): void {\n loading.value = false;\n error.value = null;\n lastResult.value = null;\n }\n\n return {\n client,\n loading,\n error,\n lastResult,\n data,\n schema,\n analyze,\n getDescriptiveStats,\n detectAnomalies: detectAnomaliesMethod,\n performClustering,\n predict,\n updateConfig,\n setData,\n reset,\n };\n}\n\n"],"names":["TabularIntelligence","config","request","startTime","response","error","result","processingTime","tfmRequest","type","metadata","baseResult","apiKey","safeConfig","inferSchema","data","name","firstRow","key","inferColumnType","row","column","values","v","uniqueValues","calculateStats","count","nullCount","stats","numbers","n","sorted","a","b","sum","variance","acc","val","frequency","maxFreq","k","detectAnomalies","columns","sensitivity","anomalies","multiplier","idx","q1","q3","iqr","lowerBound","upperBound","value","existing","reason","useTabularIntelligence","options","client","loading","ref","lastResult","schema","useLocalFallback","analyze","analysisOptions","err","performLocalAnalysis","currentSchema","col","numericColumns","getDescriptiveStats","detectAnomaliesMethod","performClustering","features","numClusters","predict","targetColumn","predictionOptions","updateConfig","newConfig","setData","newData","autoInferSchema","reset"],"mappings":"uGAoBO,MAAMA,CAAoB,CAG/B,YAAYC,EAAmB,CAC7B,KAAK,OAAS,CACZ,QAAS,IACT,GAAGA,CACL,CAAA,CAMF,MAAc,QAAQC,EAA2C,CACzD,MAAAC,EAAY,KAAK,IAAI,EAEvB,GAAA,CACF,MAAMC,EAAW,MAAM,MAAM,KAAK,OAAO,QAAS,CAChD,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,G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mBAAmB,GAClC,kBAAoB,CAAC,CAAA,CAMtB,eAAAQ,EAAsB7B,EAAoBC,EAA0C,CAE1F,OADQ,MAAMoB,EAAQ,oBAAqB,CAAE,YAAApB,EAAa,SAAUD,EAAS,GACtE,WAAa,CAAC,CAAA,CAMf,eAAA8B,EAAkBC,EAAoBC,EAAsB,EAA4B,CACrG,OAAOX,EAAQ,aAAc,CAAE,SAAAU,EAAU,YAAAC,EAAa,CAAA,CAMzC,eAAAC,EAAQC,EAAsBC,EAAkD,CAC7F,OAAOd,EAAQ,aAAc,CAAE,aAAAa,EAAc,GAAGC,EAAmB,CAAA,CAMrE,SAASC,EAAaC,EAAqC,CACzDtB,EAAO,aAAasB,CAAS,CAAA,CAMtB,SAAAC,EAAQC,EAAgBC,EAA2B,GAAY,CACtEnE,EAAK,MAAQkE,EACTC,IACKrB,EAAA,MAAQ/C,EAAYmE,CAAO,EACpC,CAMF,SAASE,GAAc,CACrBzB,EAAQ,MAAQ,GAChBrD,EAAM,MAAQ,KACduD,EAAW,MAAQ,IAAA,CAGd,MAAA,CACL,OAAAH,EACA,QAAAC,EACA,MAAArD,EACA,WAAAuD,EACA,KAAA7C,EACA,OAAA8C,EACA,QAAAE,EACA,oBAAAO,EACA,gBAAiBC,EACjB,kBAAAC,EACA,QAAAG,EACA,aAAAG,EACA,QAAAE,EACA,MAAAG,CACF,CACF"}
package/dist/index.mjs ADDED
@@ -0,0 +1,307 @@
1
+ import { ref as M } from "vue";
2
+ class N {
3
+ constructor(s) {
4
+ this.config = {
5
+ timeout: 3e4,
6
+ ...s
7
+ };
8
+ }
9
+ /**
10
+ * Generic API call to TFM endpoint
11
+ */
12
+ async callTFM(s) {
13
+ const e = Date.now();
14
+ try {
15
+ const n = await fetch(this.config.baseUrl, {
16
+ method: "POST",
17
+ headers: {
18
+ "Content-Type": "application/json",
19
+ ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` },
20
+ ...this.config.headers
21
+ },
22
+ body: JSON.stringify({
23
+ ...s,
24
+ model: this.config.model
25
+ }),
26
+ signal: AbortSignal.timeout(this.config.timeout || 3e4)
27
+ });
28
+ if (!n.ok) {
29
+ const r = await n.text();
30
+ throw new Error(`TFM API error: ${n.status} - ${r}`);
31
+ }
32
+ const t = await n.json(), i = Date.now() - e;
33
+ return {
34
+ success: !0,
35
+ result: t.result || t,
36
+ metadata: {
37
+ processingTime: i,
38
+ model: this.config.model || "unknown",
39
+ version: t.version
40
+ }
41
+ };
42
+ } catch (n) {
43
+ return {
44
+ success: !1,
45
+ error: n instanceof Error ? n.message : "Unknown error",
46
+ metadata: {
47
+ processingTime: Date.now() - e,
48
+ model: this.config.model || "unknown"
49
+ }
50
+ };
51
+ }
52
+ }
53
+ /**
54
+ * Perform analysis on tabular data
55
+ */
56
+ async analyze(s) {
57
+ const e = {
58
+ operation: s.type,
59
+ data: s.data,
60
+ schema: s.schema,
61
+ parameters: s.options
62
+ }, n = await this.callTFM(e);
63
+ if (!n.success)
64
+ throw new Error(n.error || "Analysis failed");
65
+ return this.parseAnalysisResult(s.type, n.result, n.metadata);
66
+ }
67
+ /**
68
+ * Parse TFM response into structured AnalysisResult
69
+ */
70
+ parseAnalysisResult(s, e, n) {
71
+ const t = {
72
+ type: s,
73
+ timestamp: /* @__PURE__ */ new Date(),
74
+ summary: e.summary || "",
75
+ insights: e.insights || [],
76
+ recommendations: e.recommendations,
77
+ confidence: e.confidence || 0.8,
78
+ processingTime: n == null ? void 0 : n.processingTime
79
+ };
80
+ switch (s) {
81
+ case "descriptive_stats":
82
+ return {
83
+ ...t,
84
+ descriptiveStats: e.stats || e.descriptiveStats
85
+ };
86
+ case "anomaly_detection":
87
+ return {
88
+ ...t,
89
+ anomalies: e.anomalies || []
90
+ };
91
+ case "segmentation":
92
+ case "clustering":
93
+ return {
94
+ ...t,
95
+ clusters: e.clusters || []
96
+ };
97
+ case "prediction":
98
+ return {
99
+ ...t,
100
+ predictions: e.predictions || e
101
+ };
102
+ case "correlation":
103
+ return {
104
+ ...t,
105
+ correlations: e.correlations || e
106
+ };
107
+ default:
108
+ return t;
109
+ }
110
+ }
111
+ /**
112
+ * Update configuration
113
+ */
114
+ updateConfig(s) {
115
+ this.config = { ...this.config, ...s };
116
+ }
117
+ /**
118
+ * Get current configuration (without sensitive data)
119
+ */
120
+ getConfig() {
121
+ const { apiKey: s, ...e } = this.config;
122
+ return e;
123
+ }
124
+ }
125
+ function T(c, s) {
126
+ if (c.length === 0)
127
+ return { columns: [], rowCount: 0, name: s };
128
+ const e = c[0];
129
+ return {
130
+ columns: Object.keys(e).map((t) => {
131
+ const i = $(c, t);
132
+ return {
133
+ name: t,
134
+ type: i,
135
+ nullable: c.some((r) => r[t] == null)
136
+ };
137
+ }),
138
+ rowCount: c.length,
139
+ name: s
140
+ };
141
+ }
142
+ function $(c, s) {
143
+ const e = c.map((t) => t[s]).filter((t) => t != null);
144
+ if (e.length === 0) return "string";
145
+ if (e.every((t) => typeof t == "number" || !isNaN(Number(t))))
146
+ return "number";
147
+ if (e.every((t) => typeof t == "boolean" || t === "true" || t === "false"))
148
+ return "boolean";
149
+ if (e.every((t) => !isNaN(Date.parse(t))))
150
+ return "date";
151
+ const n = new Set(e);
152
+ return n.size < e.length * 0.5 && n.size < 20 ? "categorical" : "string";
153
+ }
154
+ function A(c, s, e) {
155
+ const n = c.map((l) => l[s]).filter((l) => l != null), t = n.length, i = c.length - t, r = {
156
+ column: s,
157
+ count: t,
158
+ nullCount: i
159
+ };
160
+ if (e === "number") {
161
+ const l = n.map(Number).filter((o) => !isNaN(o));
162
+ if (l.length > 0) {
163
+ const o = [...l].sort((u, d) => u - d), p = l.reduce((u, d) => u + d, 0);
164
+ r.mean = p / l.length, r.median = o[Math.floor(o.length / 2)], r.min = o[0], r.max = o[o.length - 1];
165
+ const h = l.reduce((u, d) => u + Math.pow(d - r.mean, 2), 0) / l.length;
166
+ r.std = Math.sqrt(h), r.percentiles = {
167
+ 25: o[Math.floor(o.length * 0.25)],
168
+ 50: r.median,
169
+ 75: o[Math.floor(o.length * 0.75)],
170
+ 90: o[Math.floor(o.length * 0.9)]
171
+ };
172
+ }
173
+ } else {
174
+ const l = new Set(n);
175
+ r.uniqueValues = l.size;
176
+ const o = {};
177
+ n.forEach((h) => {
178
+ const u = String(h);
179
+ o[u] = (o[u] || 0) + 1;
180
+ });
181
+ const p = Math.max(...Object.values(o));
182
+ r.mode = Object.keys(o).find((h) => o[h] === p);
183
+ }
184
+ return r;
185
+ }
186
+ function F(c, s, e = 0.5) {
187
+ const n = [], t = 1.5 + (1 - e) * 1.5;
188
+ return s.forEach((i) => {
189
+ const r = c.map((m, g) => ({ value: Number(m[i]), idx: g })).filter((m) => !isNaN(m.value));
190
+ if (r.length === 0) return;
191
+ const l = [...r].sort((m, g) => m.value - g.value), o = l[Math.floor(l.length * 0.25)].value, p = l[Math.floor(l.length * 0.75)].value, h = p - o, u = o - t * h, d = p + t * h;
192
+ r.forEach(({ value: m, idx: g }) => {
193
+ if (m < u || m > d) {
194
+ const v = n.find((a) => a.rowIndex === g), S = m < u ? `${i}: ${m.toFixed(2)} < ${u.toFixed(2)}` : `${i}: ${m.toFixed(2)} > ${d.toFixed(2)}`;
195
+ v ? (v.reasons.push(S), v.affectedColumns.push(i), v.score = Math.min(1, v.score + 0.2)) : n.push({
196
+ rowIndex: g,
197
+ row: c[g],
198
+ score: 0.7,
199
+ reasons: [S],
200
+ affectedColumns: [i]
201
+ });
202
+ }
203
+ });
204
+ }), n.sort((i, r) => r.score - i.score);
205
+ }
206
+ function E(c) {
207
+ const s = new N(c.config), e = M(!1), n = M(null), t = M(null), i = c.data || M([]), r = c.schema || M(null), l = c.useLocalFallback !== !1;
208
+ async function o(a, f) {
209
+ e.value = !0, n.value = null;
210
+ try {
211
+ const y = {
212
+ type: a,
213
+ data: i.value,
214
+ schema: r.value || void 0,
215
+ options: f
216
+ }, w = await s.analyze(y);
217
+ return t.value = w, w;
218
+ } catch (y) {
219
+ if (n.value = y instanceof Error ? y : new Error("Analysis failed"), l)
220
+ return p(a, f);
221
+ throw n.value;
222
+ } finally {
223
+ e.value = !1;
224
+ }
225
+ }
226
+ function p(a, f) {
227
+ const y = r.value || T(i.value);
228
+ switch (a) {
229
+ case "descriptive_stats": {
230
+ const w = y.columns.map(
231
+ (b) => A(i.value, b.name, b.type)
232
+ );
233
+ return {
234
+ type: a,
235
+ timestamp: /* @__PURE__ */ new Date(),
236
+ descriptiveStats: w,
237
+ summary: `Calculated statistics for ${w.length} columns`,
238
+ insights: [],
239
+ confidence: 0.9
240
+ };
241
+ }
242
+ case "anomaly_detection": {
243
+ const w = y.columns.filter((C) => C.type === "number").map((C) => C.name), b = F(
244
+ i.value,
245
+ w,
246
+ f == null ? void 0 : f.sensitivity
247
+ );
248
+ return {
249
+ type: a,
250
+ timestamp: /* @__PURE__ */ new Date(),
251
+ anomalies: b,
252
+ summary: `Found ${b.length} anomalies`,
253
+ insights: b.slice(0, 3).map((C) => C.reasons[0]),
254
+ confidence: 0.8
255
+ };
256
+ }
257
+ default:
258
+ throw new Error(`Local analysis not supported for type: ${a}`);
259
+ }
260
+ }
261
+ async function h() {
262
+ return (await o("descriptive_stats")).descriptiveStats || [];
263
+ }
264
+ async function u(a, f) {
265
+ return (await o("anomaly_detection", { sensitivity: f, features: a })).anomalies || [];
266
+ }
267
+ async function d(a, f = 3) {
268
+ return o("clustering", { features: a, numClusters: f });
269
+ }
270
+ async function m(a, f) {
271
+ return o("prediction", { targetColumn: a, ...f });
272
+ }
273
+ function g(a) {
274
+ s.updateConfig(a);
275
+ }
276
+ function v(a, f = !0) {
277
+ i.value = a, f && (r.value = T(a));
278
+ }
279
+ function S() {
280
+ e.value = !1, n.value = null, t.value = null;
281
+ }
282
+ return {
283
+ client: s,
284
+ loading: e,
285
+ error: n,
286
+ lastResult: t,
287
+ data: i,
288
+ schema: r,
289
+ analyze: o,
290
+ getDescriptiveStats: h,
291
+ detectAnomalies: u,
292
+ performClustering: d,
293
+ predict: m,
294
+ updateConfig: g,
295
+ setData: v,
296
+ reset: S
297
+ };
298
+ }
299
+ export {
300
+ N as TabularIntelligence,
301
+ A as calculateStats,
302
+ F as detectAnomalies,
303
+ $ as inferColumnType,
304
+ T as inferSchema,
305
+ E as useTabularIntelligence
306
+ };
307
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/core/TabularIntelligence.ts","../src/utils/helpers.ts","../src/composables/useTabularIntelligence.ts"],"sourcesContent":["/**\n * TabularIntelligence - Core TFM Client\n * Generic client for Tabular Foundation Model APIs\n */\n\nimport type {\n TFMConfig,\n TFMRequest,\n TFMResponse,\n AnalysisRequest,\n AnalysisResult,\n AnalysisType,\n TableSchema,\n DescriptiveStats,\n Anomaly,\n Cluster,\n Prediction,\n CorrelationMatrix,\n} from '../types';\n\nexport class TabularIntelligence {\n private config: TFMConfig;\n\n constructor(config: TFMConfig) {\n this.config = {\n timeout: 30000,\n ...config,\n };\n }\n\n /**\n * Generic API call to TFM endpoint\n */\n private async callTFM(request: TFMRequest): Promise<TFMResponse> {\n const startTime = Date.now();\n\n try {\n const response = await fetch(this.config.baseUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` }),\n ...this.config.headers,\n },\n body: JSON.stringify({\n ...request,\n model: this.config.model,\n }),\n signal: AbortSignal.timeout(this.config.timeout || 30000),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`TFM API error: ${response.status} - ${error}`);\n }\n\n const result = await response.json();\n const processingTime = Date.now() - startTime;\n\n return {\n success: true,\n result: result.result || result,\n metadata: {\n processingTime,\n model: this.config.model || 'unknown',\n version: result.version,\n },\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n metadata: {\n processingTime: Date.now() - startTime,\n model: this.config.model || 'unknown',\n },\n };\n }\n }\n\n /**\n * Perform analysis on tabular data\n */\n async analyze(request: AnalysisRequest): Promise<AnalysisResult> {\n const tfmRequest: TFMRequest = {\n operation: request.type,\n data: request.data,\n schema: request.schema,\n parameters: request.options,\n };\n\n const response = await this.callTFM(tfmRequest);\n\n if (!response.success) {\n throw new Error(response.error || 'Analysis failed');\n }\n\n // Parse response based on analysis type\n return this.parseAnalysisResult(request.type, response.result, response.metadata);\n }\n\n /**\n * Parse TFM response into structured AnalysisResult\n */\n private parseAnalysisResult(\n type: AnalysisType,\n result: any,\n metadata?: any\n ): AnalysisResult {\n const baseResult: AnalysisResult = {\n type,\n timestamp: new Date(),\n summary: result.summary || '',\n insights: result.insights || [],\n recommendations: result.recommendations,\n confidence: result.confidence || 0.8,\n processingTime: metadata?.processingTime,\n };\n\n switch (type) {\n case 'descriptive_stats':\n return {\n ...baseResult,\n descriptiveStats: result.stats || result.descriptiveStats,\n };\n\n case 'anomaly_detection':\n return {\n ...baseResult,\n anomalies: result.anomalies || [],\n };\n\n case 'segmentation':\n case 'clustering':\n return {\n ...baseResult,\n clusters: result.clusters || [],\n };\n\n case 'prediction':\n return {\n ...baseResult,\n predictions: result.predictions || result,\n };\n\n case 'correlation':\n return {\n ...baseResult,\n correlations: result.correlations || result,\n };\n\n default:\n return baseResult;\n }\n }\n\n /**\n * Update configuration\n */\n updateConfig(config: Partial<TFMConfig>): void {\n this.config = { ...this.config, ...config };\n }\n\n /**\n * Get current configuration (without sensitive data)\n */\n getConfig(): Omit<TFMConfig, 'apiKey'> {\n const { apiKey, ...safeConfig } = this.config;\n return safeConfig;\n }\n}\n\n","/**\n * Helper utilities for tabular intelligence\n */\n\nimport type { TableSchema, TableColumn, DescriptiveStats, Anomaly, Cluster } from '../types';\n\n/**\n * Infer table schema from data\n */\nexport function inferSchema(data: any[], name?: string): TableSchema {\n if (data.length === 0) {\n return { columns: [], rowCount: 0, name };\n }\n\n const firstRow = data[0];\n const columns: TableColumn[] = Object.keys(firstRow).map((key) => {\n const type = inferColumnType(data, key);\n return {\n name: key,\n type,\n nullable: data.some((row) => row[key] == null),\n };\n });\n\n return {\n columns,\n rowCount: data.length,\n name,\n };\n}\n\n/**\n * Infer column type from data\n */\nexport function inferColumnType(data: any[], column: string): TableColumn['type'] {\n const values = data.map((row) => row[column]).filter((v) => v != null);\n \n if (values.length === 0) return 'string';\n\n // Check if all values are numbers\n if (values.every((v) => typeof v === 'number' || !isNaN(Number(v)))) {\n return 'number';\n }\n\n // Check if all values are booleans\n if (values.every((v) => typeof v === 'boolean' || v === 'true' || v === 'false')) {\n return 'boolean';\n }\n\n // Check if values look like dates\n if (values.every((v) => !isNaN(Date.parse(v)))) {\n return 'date';\n }\n\n // Check if categorical (limited unique values)\n const uniqueValues = new Set(values);\n if (uniqueValues.size < values.length * 0.5 && uniqueValues.size < 20) {\n return 'categorical';\n }\n\n return 'string';\n}\n\n/**\n * Calculate basic descriptive statistics\n */\nexport function calculateStats(data: any[], column: string, type: TableColumn['type']): DescriptiveStats {\n const values = data.map((row) => row[column]).filter((v) => v != null);\n const count = values.length;\n const nullCount = data.length - count;\n\n const stats: DescriptiveStats = {\n column,\n count,\n nullCount,\n };\n\n if (type === 'number') {\n const numbers = values.map(Number).filter((n) => !isNaN(n));\n \n if (numbers.length > 0) {\n const sorted = [...numbers].sort((a, b) => a - b);\n const sum = numbers.reduce((a, b) => a + b, 0);\n \n stats.mean = sum / numbers.length;\n stats.median = sorted[Math.floor(sorted.length / 2)];\n stats.min = sorted[0];\n stats.max = sorted[sorted.length - 1];\n \n const variance = numbers.reduce((acc, val) => acc + Math.pow(val - stats.mean!, 2), 0) / numbers.length;\n stats.std = Math.sqrt(variance);\n \n stats.percentiles = {\n '25': sorted[Math.floor(sorted.length * 0.25)],\n '50': stats.median,\n '75': sorted[Math.floor(sorted.length * 0.75)],\n '90': sorted[Math.floor(sorted.length * 0.90)],\n };\n }\n } else {\n const uniqueValues = new Set(values);\n stats.uniqueValues = uniqueValues.size;\n \n const frequency: Record<string, number> = {};\n values.forEach((v) => {\n const key = String(v);\n frequency[key] = (frequency[key] || 0) + 1;\n });\n \n const maxFreq = Math.max(...Object.values(frequency));\n stats.mode = Object.keys(frequency).find((k) => frequency[k] === maxFreq);\n }\n\n return stats;\n}\n\n/**\n * Detect anomalies using IQR method\n */\nexport function detectAnomalies(data: any[], columns: string[], sensitivity: number = 0.5): Anomaly[] {\n const anomalies: Anomaly[] = [];\n const multiplier = 1.5 + (1 - sensitivity) * 1.5;\n\n columns.forEach((column) => {\n const values = data.map((row, idx) => ({ value: Number(row[column]), idx }))\n .filter((v) => !isNaN(v.value));\n\n if (values.length === 0) return;\n\n const sorted = [...values].sort((a, b) => a.value - b.value);\n const q1 = sorted[Math.floor(sorted.length * 0.25)].value;\n const q3 = sorted[Math.floor(sorted.length * 0.75)].value;\n const iqr = q3 - q1;\n const lowerBound = q1 - multiplier * iqr;\n const upperBound = q3 + multiplier * iqr;\n\n values.forEach(({ value, idx }) => {\n if (value < lowerBound || value > upperBound) {\n const existing = anomalies.find((a) => a.rowIndex === idx);\n const reason = value < lowerBound\n ? `${column}: ${value.toFixed(2)} < ${lowerBound.toFixed(2)}`\n : `${column}: ${value.toFixed(2)} > ${upperBound.toFixed(2)}`;\n\n if (existing) {\n existing.reasons.push(reason);\n existing.affectedColumns.push(column);\n existing.score = Math.min(1, existing.score + 0.2);\n } else {\n anomalies.push({\n rowIndex: idx,\n row: data[idx],\n score: 0.7,\n reasons: [reason],\n affectedColumns: [column],\n });\n }\n }\n });\n });\n\n return anomalies.sort((a, b) => b.score - a.score);\n}\n\n","/**\n * Vue Composable for Tabular Intelligence\n */\n\nimport { ref, computed, Ref } from 'vue';\nimport { TabularIntelligence } from '../core/TabularIntelligence';\nimport type {\n TFMConfig,\n AnalysisRequest,\n AnalysisResult,\n AnalysisType,\n TableSchema,\n DescriptiveStats,\n Anomaly,\n} from '../types';\nimport { inferSchema, calculateStats, detectAnomalies } from '../utils/helpers';\n\nexport interface UseTabularIntelligenceOptions {\n config: TFMConfig;\n data?: Ref<any[]>;\n schema?: Ref<TableSchema>;\n useLocalFallback?: boolean;\n}\n\nexport interface UseTabularIntelligenceReturn {\n // Core client\n client: TabularIntelligence;\n \n // State\n loading: Ref<boolean>;\n error: Ref<Error | null>;\n lastResult: Ref<AnalysisResult | null>;\n \n // Data\n data: Ref<any[]>;\n schema: Ref<TableSchema | null>;\n \n // Methods\n analyze: (type: AnalysisType, options?: any) => Promise<AnalysisResult>;\n getDescriptiveStats: () => Promise<DescriptiveStats[]>;\n detectAnomalies: (columns?: string[], sensitivity?: number) => Promise<Anomaly[]>;\n performClustering: (features: string[], numClusters?: number) => Promise<AnalysisResult>;\n predict: (targetColumn: string, options?: any) => Promise<AnalysisResult>;\n updateConfig: (config: Partial<TFMConfig>) => void;\n setData: (newData: any[], autoInferSchema?: boolean) => void;\n reset: () => void;\n}\n\nexport function useTabularIntelligence(\n options: UseTabularIntelligenceOptions\n): UseTabularIntelligenceReturn {\n const client = new TabularIntelligence(options.config);\n \n const loading = ref(false);\n const error = ref<Error | null>(null);\n const lastResult = ref<AnalysisResult | null>(null);\n \n const data = options.data || ref<any[]>([]);\n const schema = options.schema || ref<TableSchema | null>(null);\n \n const useLocalFallback = options.useLocalFallback !== false;\n\n /**\n * Generic analyze method\n */\n async function analyze(type: AnalysisType, analysisOptions?: any): Promise<AnalysisResult> {\n loading.value = true;\n error.value = null;\n\n try {\n const request: AnalysisRequest = {\n type,\n data: data.value,\n schema: schema.value || undefined,\n options: analysisOptions,\n };\n\n const result = await client.analyze(request);\n lastResult.value = result;\n return result;\n } catch (err) {\n error.value = err instanceof Error ? err : new Error('Analysis failed');\n \n // Try local fallback if enabled\n if (useLocalFallback) {\n return performLocalAnalysis(type, analysisOptions);\n }\n \n throw error.value;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Local fallback analysis\n */\n function performLocalAnalysis(type: AnalysisType, analysisOptions?: any): AnalysisResult {\n const currentSchema = schema.value || inferSchema(data.value);\n \n switch (type) {\n case 'descriptive_stats': {\n const stats = currentSchema.columns.map((col) =>\n calculateStats(data.value, col.name, col.type)\n );\n return {\n type,\n timestamp: new Date(),\n descriptiveStats: stats,\n summary: `Calculated statistics for ${stats.length} columns`,\n insights: [],\n confidence: 0.9,\n };\n }\n\n case 'anomaly_detection': {\n const numericColumns = currentSchema.columns\n .filter((col) => col.type === 'number')\n .map((col) => col.name);\n const anomalies = detectAnomalies(\n data.value,\n numericColumns,\n analysisOptions?.sensitivity\n );\n return {\n type,\n timestamp: new Date(),\n anomalies,\n summary: `Found ${anomalies.length} anomalies`,\n insights: anomalies.slice(0, 3).map((a) => a.reasons[0]),\n confidence: 0.8,\n };\n }\n\n default:\n throw new Error(`Local analysis not supported for type: ${type}`);\n }\n }\n\n /**\n * Get descriptive statistics\n */\n async function getDescriptiveStats(): Promise<DescriptiveStats[]> {\n const result = await analyze('descriptive_stats');\n return result.descriptiveStats || [];\n }\n\n /**\n * Detect anomalies\n */\n async function detectAnomaliesMethod(columns?: string[], sensitivity?: number): Promise<Anomaly[]> {\n const result = await analyze('anomaly_detection', { sensitivity, features: columns });\n return result.anomalies || [];\n }\n\n /**\n * Perform clustering\n */\n async function performClustering(features: string[], numClusters: number = 3): Promise<AnalysisResult> {\n return analyze('clustering', { features, numClusters });\n }\n\n /**\n * Make predictions\n */\n async function predict(targetColumn: string, predictionOptions?: any): Promise<AnalysisResult> {\n return analyze('prediction', { targetColumn, ...predictionOptions });\n }\n\n /**\n * Update TFM configuration\n */\n function updateConfig(newConfig: Partial<TFMConfig>): void {\n client.updateConfig(newConfig);\n }\n\n /**\n * Set new data\n */\n function setData(newData: any[], autoInferSchema: boolean = true): void {\n data.value = newData;\n if (autoInferSchema) {\n schema.value = inferSchema(newData);\n }\n }\n\n /**\n * Reset state\n */\n function reset(): void {\n loading.value = false;\n error.value = null;\n lastResult.value = null;\n }\n\n return {\n client,\n loading,\n error,\n lastResult,\n data,\n schema,\n analyze,\n getDescriptiveStats,\n detectAnomalies: detectAnomaliesMethod,\n performClustering,\n predict,\n updateConfig,\n setData,\n reset,\n };\n}\n\n"],"names":["TabularIntelligence","config","request","startTime","response","error","result","processingTime","tfmRequest","type","metadata","baseResult","apiKey","safeConfig","inferSchema","data","name","firstRow","key","inferColumnType","row","column","values","v","uniqueValues","calculateStats","count","nullCount","stats","numbers","n","sorted","a","b","sum","variance","acc","val","frequency","maxFreq","k","detectAnomalies","columns","sensitivity","anomalies","multiplier","idx","q1","q3","iqr","lowerBound","upperBound","value","existing","reason","useTabularIntelligence","options","client","loading","ref","lastResult","schema","useLocalFallback","analyze","analysisOptions","err","performLocalAnalysis","currentSchema","col","numericColumns","getDescriptiveStats","detectAnomaliesMethod","performClustering","features","numClusters","predict","targetColumn","predictionOptions","updateConfig","newConfig","setData","newData","autoInferSchema","reset"],"mappings":";AAoBO,MAAMA,EAAoB;AAAA,EAG/B,YAAYC,GAAmB;AAC7B,SAAK,SAAS;AAAA,MACZ,SAAS;AAAA,MACT,GAAGA;AAAA,IACL;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMF,MAAc,QAAQC,GAA2C;AACzD,UAAAC,IAAY,KAAK,IAAI;AAEvB,QAAA;AACF,YAAMC,IAAW,MAAM,MAAM,KAAK,OAAO,SAAS;AAAA,QAChD,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,GAAI,KAAK,OAAO,UAAU,EAAE,eAAe,UAAU,KAAK,OAAO,MAAM,GAAG;AAAA,UAC1E,GAAG,KAAK,OAAO;AAAA,QACjB;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,GAAGF;AAAA,UACH,OAAO,KAAK,OAAO;AAAA,QAAA,CACpB;AAAA,QACD,QAAQ,YAAY,QAAQ,KAAK,OAAO,WAAW,GAAK;AAAA,MAAA,CACzD;AAEG,UAAA,CAACE,EAAS,IAAI;AACV,cAAAC,IAAQ,MAAMD,EAAS,KAAK;AAClC,cAAM,IAAI,MAAM,kBAAkBA,EAAS,MAAM,MAAMC,CAAK,EAAE;AAAA,MAAA;AAG1D,YAAAC,IAAS,MAAMF,E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A,EACpC;AAMF,WAASE,IAAc;AACrB,IAAAzB,EAAQ,QAAQ,IAChBrD,EAAM,QAAQ,MACduD,EAAW,QAAQ;AAAA,EAAA;AAGd,SAAA;AAAA,IACL,QAAAH;AAAA,IACA,SAAAC;AAAA,IACA,OAAArD;AAAA,IACA,YAAAuD;AAAA,IACA,MAAA7C;AAAA,IACA,QAAA8C;AAAA,IACA,SAAAE;AAAA,IACA,qBAAAO;AAAA,IACA,iBAAiBC;AAAA,IACjB,mBAAAC;AAAA,IACA,SAAAG;AAAA,IACA,cAAAG;AAAA,IACA,SAAAE;AAAA,IACA,OAAAG;AAAA,EACF;AACF;"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Tabular Intelligence Types
3
+ * Type definitions for Tabular Foundation Model (TFM) integration
4
+ */
5
+ export type TFMProvider = 'custom' | 'openai' | 'anthropic' | 'huggingface' | 'local';
6
+ export interface TFMConfig {
7
+ provider: TFMProvider;
8
+ apiKey?: string;
9
+ baseUrl: string;
10
+ model?: string;
11
+ headers?: Record<string, string>;
12
+ timeout?: number;
13
+ }
14
+ export interface TableColumn {
15
+ name: string;
16
+ type: 'string' | 'number' | 'boolean' | 'date' | 'categorical';
17
+ nullable?: boolean;
18
+ unique?: boolean;
19
+ description?: string;
20
+ }
21
+ export interface TableSchema {
22
+ columns: TableColumn[];
23
+ rowCount: number;
24
+ name?: string;
25
+ description?: string;
26
+ }
27
+ export type AnalysisType = 'descriptive_stats' | 'anomaly_detection' | 'segmentation' | 'clustering' | 'prediction' | 'correlation' | 'trend_analysis' | 'outlier_detection';
28
+ export interface AnalysisRequest {
29
+ type: AnalysisType;
30
+ data: any[];
31
+ schema?: TableSchema;
32
+ options?: AnalysisOptions;
33
+ }
34
+ export interface AnalysisOptions {
35
+ includeDistribution?: boolean;
36
+ percentiles?: number[];
37
+ sensitivity?: number;
38
+ method?: 'statistical' | 'ml' | 'isolation_forest';
39
+ numClusters?: number;
40
+ features?: string[];
41
+ algorithm?: 'kmeans' | 'dbscan' | 'hierarchical';
42
+ targetColumn?: string;
43
+ predictionHorizon?: number;
44
+ confidenceLevel?: number;
45
+ maxRows?: number;
46
+ sampleSize?: number;
47
+ }
48
+ export interface DescriptiveStats {
49
+ column: string;
50
+ count: number;
51
+ mean?: number;
52
+ median?: number;
53
+ mode?: any;
54
+ std?: number;
55
+ min?: any;
56
+ max?: any;
57
+ percentiles?: Record<string, number>;
58
+ distribution?: {
59
+ bins: number[];
60
+ counts: number[];
61
+ };
62
+ uniqueValues?: number;
63
+ nullCount?: number;
64
+ }
65
+ export interface Anomaly {
66
+ rowIndex: number;
67
+ row: any;
68
+ score: number;
69
+ reasons: string[];
70
+ affectedColumns: string[];
71
+ }
72
+ export interface Cluster {
73
+ id: number;
74
+ label: string;
75
+ size: number;
76
+ centroid?: Record<string, any>;
77
+ characteristics: string[];
78
+ members?: number[];
79
+ }
80
+ export interface Prediction {
81
+ targetColumn: string;
82
+ predictions: any[];
83
+ confidence: number[];
84
+ model?: string;
85
+ accuracy?: number;
86
+ featureImportance?: Record<string, number>;
87
+ }
88
+ export interface CorrelationMatrix {
89
+ columns: string[];
90
+ matrix: number[][];
91
+ significant?: Array<{
92
+ col1: string;
93
+ col2: string;
94
+ correlation: number;
95
+ pValue?: number;
96
+ }>;
97
+ }
98
+ export interface AnalysisResult {
99
+ type: AnalysisType;
100
+ timestamp: Date;
101
+ descriptiveStats?: DescriptiveStats[];
102
+ anomalies?: Anomaly[];
103
+ clusters?: Cluster[];
104
+ predictions?: Prediction;
105
+ correlations?: CorrelationMatrix;
106
+ summary: string;
107
+ insights: string[];
108
+ recommendations?: string[];
109
+ confidence: number;
110
+ processingTime?: number;
111
+ }
112
+ export interface TFMRequest {
113
+ operation: string;
114
+ data: any[];
115
+ schema?: TableSchema;
116
+ parameters?: Record<string, any>;
117
+ }
118
+ export interface TFMResponse {
119
+ success: boolean;
120
+ result?: any;
121
+ error?: string;
122
+ metadata?: {
123
+ processingTime: number;
124
+ model: string;
125
+ version?: string;
126
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e,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAMD,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH"}
@@ -0,0 +1,18 @@
1
+ import { TableSchema, TableColumn, DescriptiveStats, Anomaly } from '../types';
2
+ /**
3
+ * Infer table schema from data
4
+ */
5
+ export declare function inferSchema(data: any[], name?: string): TableSchema;
6
+ /**
7
+ * Infer column type from data
8
+ */
9
+ export declare function inferColumnType(data: any[], column: string): TableColumn['type'];
10
+ /**
11
+ * Calculate basic descriptive statistics
12
+ */
13
+ export declare function calculateStats(data: any[], column: string, type: TableColumn['type']): DescriptiveStats;
14
+ /**
15
+ * Detect anomalies using IQR method
16
+ */
17
+ export declare function detectAnomalies(data: any[], columns: string[], sensitivity?: number): Anomaly[];
18
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAW,MAAM,UAAU,CAAC;AAE7F;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAoBnE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CA2BhF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAgDvG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,GAAE,MAAY,GAAG,OAAO,EAAE,CA0CpG"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@aivue/tabular-intelligence",
3
+ "version": "1.0.0",
4
+ "description": "Tabular Foundation Model (TFM) integration for structured data analysis in Vue.js",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "npm run clean && vite build",
21
+ "dev": "vite build --watch",
22
+ "clean": "rm -rf dist",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "keywords": [
26
+ "vue",
27
+ "ai",
28
+ "tabular",
29
+ "foundation-model",
30
+ "tfm",
31
+ "data-analysis",
32
+ "machine-learning",
33
+ "statistics",
34
+ "anomaly-detection",
35
+ "clustering",
36
+ "prediction",
37
+ "datatable"
38
+ ],
39
+ "author": "reachbrt",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/reachbrt/vueai.git",
44
+ "directory": "packages/tabular-intelligence"
45
+ },
46
+ "homepage": "https://github.com/reachbrt/vueai#readme",
47
+ "bugs": {
48
+ "url": "https://github.com/reachbrt/vueai/issues"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "peerDependencies": {
54
+ "vue": "^2.6.0 || ^3.0.0"
55
+ },
56
+ "dependencies": {
57
+ "@aivue/core": "file:../core"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^20.16.0",
61
+ "@vitejs/plugin-vue": "^5.0.0",
62
+ "typescript": "^5.3.0",
63
+ "vite": "^6.3.5",
64
+ "vite-plugin-dts": "^4.5.3",
65
+ "vue": "^3.5.0"
66
+ }
67
+ }
68
+