@getvision/core 0.0.0 → 0.0.1

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.
Files changed (101) hide show
  1. package/dist/__tests__/core.test.d.ts +2 -0
  2. package/dist/__tests__/core.test.d.ts.map +1 -0
  3. package/dist/__tests__/core.test.js +88 -0
  4. package/dist/__tests__/tracing.test.d.ts +2 -0
  5. package/dist/__tests__/tracing.test.d.ts.map +1 -0
  6. package/dist/__tests__/tracing.test.js +108 -0
  7. package/dist/core.d.ts +98 -0
  8. package/dist/core.d.ts.map +1 -0
  9. package/dist/core.js +266 -0
  10. package/dist/index.d.ts +8 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/logs/index.d.ts +3 -0
  13. package/dist/logs/index.d.ts.map +1 -0
  14. package/dist/logs/index.js +2 -0
  15. package/dist/logs/interceptor.d.ts +21 -0
  16. package/dist/logs/interceptor.d.ts.map +1 -0
  17. package/dist/logs/interceptor.js +72 -0
  18. package/dist/logs/store.d.ts +36 -0
  19. package/dist/logs/store.d.ts.map +1 -0
  20. package/dist/logs/store.js +72 -0
  21. package/dist/server/index.d.ts +3 -0
  22. package/dist/server/index.d.ts.map +1 -0
  23. package/dist/server/index.js +2 -0
  24. package/dist/server/jsonrpc.d.ts +21 -0
  25. package/dist/server/jsonrpc.d.ts.map +1 -0
  26. package/dist/server/jsonrpc.js +73 -0
  27. package/dist/server/static.d.ts +10 -0
  28. package/dist/server/static.d.ts.map +1 -0
  29. package/dist/server/static.js +54 -0
  30. package/dist/server/websocket.d.ts +42 -0
  31. package/dist/server/websocket.d.ts.map +1 -0
  32. package/dist/server/websocket.js +267 -0
  33. package/dist/tracing/index.d.ts +3 -0
  34. package/dist/tracing/index.d.ts.map +1 -0
  35. package/dist/tracing/index.js +2 -0
  36. package/dist/tracing/store.d.ts +52 -0
  37. package/dist/tracing/store.d.ts.map +1 -0
  38. package/dist/tracing/store.js +101 -0
  39. package/dist/tracing/tracer.d.ts +28 -0
  40. package/dist/tracing/tracer.d.ts.map +1 -0
  41. package/dist/tracing/tracer.js +64 -0
  42. package/dist/types/adapter-options.d.ts +69 -0
  43. package/dist/types/adapter-options.d.ts.map +1 -0
  44. package/dist/types/adapter-options.js +4 -0
  45. package/dist/types/index.d.ts +193 -0
  46. package/dist/types/index.d.ts.map +1 -0
  47. package/dist/types/index.js +5 -0
  48. package/dist/types/logs.d.ts +14 -0
  49. package/dist/types/logs.d.ts.map +1 -0
  50. package/dist/types/logs.js +1 -0
  51. package/dist/ui/assets/index-5t7c-m29.js +243 -0
  52. package/dist/ui/assets/index-9ueE5-_1.js +228 -0
  53. package/dist/ui/assets/index-B2zDhd4y.js +228 -0
  54. package/dist/ui/assets/index-B6PCTRWI.js +228 -0
  55. package/dist/ui/assets/index-BAqOyMpS.js +228 -0
  56. package/dist/ui/assets/index-BBPymjIY.css +1 -0
  57. package/dist/ui/assets/index-BFZ9LDLI.js +228 -0
  58. package/dist/ui/assets/index-BK3A49yO.js +243 -0
  59. package/dist/ui/assets/index-BVC9j-JL.css +1 -0
  60. package/dist/ui/assets/index-BWzGTXsJ.js +228 -0
  61. package/dist/ui/assets/index-BZaQlF2p.js +228 -0
  62. package/dist/ui/assets/index-BbYLBWtj.css +1 -0
  63. package/dist/ui/assets/index-Bgf_12ju.js +243 -0
  64. package/dist/ui/assets/index-Bhxve5KF.css +1 -0
  65. package/dist/ui/assets/index-Bj-CWu-L.js +228 -0
  66. package/dist/ui/assets/index-BlJwGFyg.js +243 -0
  67. package/dist/ui/assets/index-BnD39P39.js +228 -0
  68. package/dist/ui/assets/index-C9X3l8Qf.js +228 -0
  69. package/dist/ui/assets/index-C9wDB-pp.js +228 -0
  70. package/dist/ui/assets/index-CAONCZtM.js +243 -0
  71. package/dist/ui/assets/index-CCtH3nj-.js +243 -0
  72. package/dist/ui/assets/index-CKzeeZJS.js +228 -0
  73. package/dist/ui/assets/index-Cctg6X14.js +243 -0
  74. package/dist/ui/assets/index-Ch3Kvj5x.js +228 -0
  75. package/dist/ui/assets/index-CkV-qXIH.css +1 -0
  76. package/dist/ui/assets/index-Cl2VKig8.js +228 -0
  77. package/dist/ui/assets/index-CoKjAtkW.css +1 -0
  78. package/dist/ui/assets/index-D4C4VyHp.css +1 -0
  79. package/dist/ui/assets/index-DHQw82rB.js +228 -0
  80. package/dist/ui/assets/index-DIfw1ZVL.css +1 -0
  81. package/dist/ui/assets/index-DJJX2zqa.js +228 -0
  82. package/dist/ui/assets/index-D_D2XkaS.js +228 -0
  83. package/dist/ui/assets/index-De-GZ9-w.js +228 -0
  84. package/dist/ui/assets/index-DoWtvKFs.js +228 -0
  85. package/dist/ui/assets/index-Dyseuj-Z.js +223 -0
  86. package/dist/ui/assets/index-ErxJEkTC.js +243 -0
  87. package/dist/ui/assets/index-HIUv_thh.css +1 -0
  88. package/dist/ui/assets/index-HhqjfP8c.js +228 -0
  89. package/dist/ui/assets/index-eUFXMYOK.js +221 -0
  90. package/dist/ui/assets/index-jabSppNC.js +228 -0
  91. package/dist/ui/assets/index-t88G2D4Q.js +228 -0
  92. package/dist/ui/assets/index-tl7-KOr9.css +1 -0
  93. package/dist/ui/assets/index-uyOJY0cv.js +228 -0
  94. package/dist/ui/assets/index-wmKPAJzR.js +243 -0
  95. package/dist/utils/service-detection.d.ts +43 -0
  96. package/dist/utils/service-detection.d.ts.map +1 -0
  97. package/dist/utils/service-detection.js +103 -0
  98. package/dist/utils/zod-utils.d.ts +7 -0
  99. package/dist/utils/zod-utils.d.ts.map +1 -0
  100. package/dist/utils/zod-utils.js +145 -0
  101. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Package info detected from package.json
3
+ */
4
+ export interface PackageInfo {
5
+ name: string;
6
+ version: string;
7
+ }
8
+ /**
9
+ * Integration configuration
10
+ */
11
+ export interface IntegrationConfig {
12
+ database?: string;
13
+ redis?: string;
14
+ [key: string]: string | undefined;
15
+ }
16
+ /**
17
+ * Drizzle detection result
18
+ */
19
+ export interface DrizzleInfo {
20
+ detected: boolean;
21
+ configPath?: string;
22
+ }
23
+ /**
24
+ * Auto-detect package.json for service name and version
25
+ */
26
+ export declare function autoDetectPackageInfo(): PackageInfo;
27
+ /**
28
+ * Auto-detect integrations from environment variables
29
+ */
30
+ export declare function autoDetectIntegrations(): IntegrationConfig;
31
+ /**
32
+ * Detect Drizzle configuration
33
+ */
34
+ export declare function detectDrizzle(): DrizzleInfo;
35
+ /**
36
+ * Start Drizzle Studio
37
+ */
38
+ export declare function startDrizzleStudio(port?: number): boolean;
39
+ /**
40
+ * Stop Drizzle Studio
41
+ */
42
+ export declare function stopDrizzleStudio(): void;
43
+ //# sourceMappingURL=service-detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-detection.d.ts","sourceRoot":"","sources":["../../src/utils/service-detection.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAcnD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,iBAAiB,CAsB1D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,WAAW,CAc3C;AAID;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,MAAa,GAAG,OAAO,CAgC/D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAMxC"}
@@ -0,0 +1,103 @@
1
+ import { readFileSync, existsSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { spawn } from 'child_process';
4
+ /**
5
+ * Auto-detect package.json for service name and version
6
+ */
7
+ export function autoDetectPackageInfo() {
8
+ try {
9
+ const pkgPath = join(process.cwd(), 'package.json');
10
+ if (existsSync(pkgPath)) {
11
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
12
+ return {
13
+ name: pkg.name || 'unknown',
14
+ version: pkg.version || '0.0.0',
15
+ };
16
+ }
17
+ }
18
+ catch (error) {
19
+ // Ignore errors
20
+ }
21
+ return { name: 'unknown', version: '0.0.0' };
22
+ }
23
+ /**
24
+ * Auto-detect integrations from environment variables
25
+ */
26
+ export function autoDetectIntegrations() {
27
+ const integrations = {};
28
+ // Common database env vars
29
+ const dbKeys = ['DATABASE_URL', 'DB_URL', 'POSTGRES_URL', 'MYSQL_URL', 'MONGODB_URL'];
30
+ for (const key of dbKeys) {
31
+ if (process.env[key]) {
32
+ integrations.database = process.env[key];
33
+ break;
34
+ }
35
+ }
36
+ // Common redis env vars
37
+ const redisKeys = ['REDIS_URL', 'CACHE_URL', 'UPSTASH_REDIS_URL'];
38
+ for (const key of redisKeys) {
39
+ if (process.env[key]) {
40
+ integrations.redis = process.env[key];
41
+ break;
42
+ }
43
+ }
44
+ return integrations;
45
+ }
46
+ /**
47
+ * Detect Drizzle configuration
48
+ */
49
+ export function detectDrizzle() {
50
+ const possiblePaths = [
51
+ 'drizzle.config.ts',
52
+ 'drizzle.config.js',
53
+ 'drizzle.config.mjs',
54
+ ];
55
+ for (const path of possiblePaths) {
56
+ if (existsSync(path)) {
57
+ return { detected: true, configPath: path };
58
+ }
59
+ }
60
+ return { detected: false };
61
+ }
62
+ let drizzleStudioProcess = null;
63
+ /**
64
+ * Start Drizzle Studio
65
+ */
66
+ export function startDrizzleStudio(port = 4983) {
67
+ const drizzleInfo = detectDrizzle();
68
+ if (!drizzleInfo.detected) {
69
+ console.warn('⚠️ Drizzle config not found. Skipping Drizzle Studio auto-start.');
70
+ return false;
71
+ }
72
+ console.log(`🗄️ Starting Drizzle Studio on port ${port}...`);
73
+ try {
74
+ drizzleStudioProcess = spawn('npx', ['drizzle-kit', 'studio', '--port', String(port), '--host', '0.0.0.0'], {
75
+ stdio: 'inherit',
76
+ detached: false,
77
+ });
78
+ drizzleStudioProcess.on('error', (error) => {
79
+ console.error('❌ Failed to start Drizzle Studio:', error.message);
80
+ });
81
+ drizzleStudioProcess.on('exit', (code) => {
82
+ if (code !== 0 && code !== null) {
83
+ console.error(`❌ Drizzle Studio exited with code ${code}`);
84
+ }
85
+ });
86
+ console.log(`✅ Drizzle Studio started`);
87
+ return true;
88
+ }
89
+ catch (error) {
90
+ console.error('❌ Failed to start Drizzle Studio:', error);
91
+ return false;
92
+ }
93
+ }
94
+ /**
95
+ * Stop Drizzle Studio
96
+ */
97
+ export function stopDrizzleStudio() {
98
+ if (drizzleStudioProcess) {
99
+ drizzleStudioProcess.kill();
100
+ drizzleStudioProcess = null;
101
+ console.log('🛑 Drizzle Studio stopped');
102
+ }
103
+ }
@@ -0,0 +1,7 @@
1
+ import type { ZodType } from 'zod';
2
+ import type { RequestBodySchema } from '../types/index';
3
+ /**
4
+ * Generate JSON template with comments from Zod schema
5
+ */
6
+ export declare function generateZodTemplate(schema: ZodType): RequestBodySchema | undefined;
7
+ //# sourceMappingURL=zod-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-utils.d.ts","sourceRoot":"","sources":["../../src/utils/zod-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,KAAK,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,gBAAgB,CAAA;AAEpE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,CAalF"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Generate JSON template with comments from Zod schema
3
+ */
4
+ export function generateZodTemplate(schema) {
5
+ try {
6
+ const fields = extractZodFields(schema);
7
+ const template = generateJsonTemplate(fields);
8
+ return {
9
+ template,
10
+ fields,
11
+ };
12
+ }
13
+ catch (error) {
14
+ console.warn('Failed to generate template from Zod schema:', error);
15
+ return undefined;
16
+ }
17
+ }
18
+ /**
19
+ * Extract fields from Zod schema (supports v3 and v4)
20
+ */
21
+ function extractZodFields(schema, path = []) {
22
+ const fields = [];
23
+ // Support both v3 (_def) and v4 (def)
24
+ const def = schema.def || schema._def;
25
+ if (!def)
26
+ return fields;
27
+ // Unwrap ZodOptional, ZodNullable, ZodDefault - not needed for top level object
28
+ let unwrapped = schema;
29
+ const currentDef = unwrapped.def || unwrapped._def;
30
+ const typeName = currentDef?.type || currentDef?.typeName;
31
+ if (typeName === 'object' || typeName === 'ZodObject') {
32
+ // Get shape - it can be a function (getter) or direct object
33
+ const shapeValue = currentDef?.shape;
34
+ const shape = typeof shapeValue === 'function' ? shapeValue() : shapeValue;
35
+ for (const [key, value] of Object.entries(shape || {})) {
36
+ const fieldSchema = value;
37
+ const fieldDef = fieldSchema.def || fieldSchema._def;
38
+ const isOptional = fieldSchema.type === 'optional' ||
39
+ fieldDef?.type === 'optional' ||
40
+ fieldDef?.typeName === 'ZodOptional' ||
41
+ fieldDef?.typeName === 'ZodDefault';
42
+ // Get description - might be in wrapped schema for optional fields
43
+ let description = fieldDef?.description || fieldSchema.description;
44
+ if (!description && fieldDef?.wrapped) {
45
+ const wrappedDef = fieldDef.wrapped.def || fieldDef.wrapped._def;
46
+ description = wrappedDef?.description || fieldDef.wrapped.description;
47
+ }
48
+ // Determine type
49
+ let fieldType = getZodType(fieldSchema);
50
+ // Check for nested objects/arrays
51
+ const nested = extractZodFields(fieldSchema, [...path, key]);
52
+ fields.push({
53
+ name: key,
54
+ type: fieldType,
55
+ description,
56
+ required: !isOptional,
57
+ nested: nested.length > 0 ? nested : undefined,
58
+ example: getZodExample(fieldSchema, fieldType),
59
+ });
60
+ }
61
+ }
62
+ return fields;
63
+ }
64
+ /**
65
+ * Get Zod type as string (supports v3 and v4)
66
+ */
67
+ function getZodType(schema) {
68
+ let unwrapped = schema;
69
+ let def = unwrapped.def || unwrapped._def;
70
+ // Unwrap optional/nullable/default
71
+ while (def?.type === 'optional' ||
72
+ def?.type === 'nullable' ||
73
+ def?.type === 'default' ||
74
+ def?.typeName === 'ZodOptional' ||
75
+ def?.typeName === 'ZodNullable' ||
76
+ def?.typeName === 'ZodDefault') {
77
+ unwrapped = def?.innerType || def?.wrapped || unwrapped;
78
+ def = unwrapped.def || unwrapped._def;
79
+ }
80
+ // Support both v4 (type) and v3 (typeName)
81
+ const typeName = def?.type || def?.typeName || unwrapped.type;
82
+ switch (typeName) {
83
+ case 'string':
84
+ case 'ZodString':
85
+ return 'string';
86
+ case 'number':
87
+ case 'ZodNumber':
88
+ return 'number';
89
+ case 'boolean':
90
+ case 'ZodBoolean':
91
+ return 'boolean';
92
+ case 'array':
93
+ case 'ZodArray':
94
+ return 'array';
95
+ case 'object':
96
+ case 'ZodObject':
97
+ return 'object';
98
+ case 'enum':
99
+ case 'ZodEnum':
100
+ return 'enum';
101
+ case 'date':
102
+ case 'ZodDate':
103
+ return 'date';
104
+ default:
105
+ return 'any';
106
+ }
107
+ }
108
+ /**
109
+ * Get example value for Zod type
110
+ */
111
+ function getZodExample(_schema, type) {
112
+ switch (type) {
113
+ case 'string': return '';
114
+ case 'number': return 0;
115
+ case 'boolean': return false;
116
+ case 'array': return [];
117
+ case 'object': return {};
118
+ default: return null;
119
+ }
120
+ }
121
+ /**
122
+ * Generate JSONC template with comments
123
+ */
124
+ function generateJsonTemplate(fields, indent = 0) {
125
+ const lines = [];
126
+ const spacing = ' '.repeat(indent);
127
+ lines.push('{');
128
+ fields.forEach((field, index) => {
129
+ const isLast = index === fields.length - 1;
130
+ const description = field.description || field.name;
131
+ // Add comment
132
+ lines.push(`${spacing} // ${description}`);
133
+ // Add field
134
+ let value;
135
+ if (field.nested && field.nested.length > 0) {
136
+ value = generateJsonTemplate(field.nested, indent + 1);
137
+ }
138
+ else {
139
+ value = JSON.stringify(field.example);
140
+ }
141
+ lines.push(`${spacing} "${field.name}": ${value}${isLast ? '' : ','}`);
142
+ });
143
+ lines.push(`${spacing}}`);
144
+ return lines.join('\n');
145
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getvision/core",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",