-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: shows v3 not supported message #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import isDocker from './utils/is-docker' | |
| import { isWsl } from './utils/is-wsl' | ||
| import { getMachineId } from './utils/machine-id-utils' | ||
| import { getPrismaVersion, getVersion } from './utils/version-utils' | ||
| import { v5 as uuidv5 } from 'uuid' | ||
|
|
||
| /** | ||
| * Telemetry events | ||
|
|
@@ -18,7 +19,7 @@ export type TelemetryEvents = 'proxy:start' | 'proxy:complete' | 'proxy:error' | |
| */ | ||
| export class Telemetry { | ||
| private readonly mixpanel: Mixpanel | undefined | ||
| private readonly hostId = getMachineId() | ||
| private readonly hostId = this.getDeviceId() | ||
| private readonly sessionid = randomUUID() | ||
| private readonly _os_type = os.type() | ||
| private readonly _os_release = os.release() | ||
|
|
@@ -40,6 +41,12 @@ export class Telemetry { | |
| } | ||
| } | ||
|
|
||
| private getDeviceId() { | ||
| const hostId = getMachineId() | ||
| // namespace UUID for generating UUIDv5 from DNS 'zenstack.dev' | ||
| return uuidv5(hostId, '133cac15-3efb-50fa-b5fc-4b90e441e563') | ||
| } | ||
|
Comment on lines
+44
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Short answer:
Sources: 🏁 Script executed: # Search for any documentation or comments about the custom namespace UUID
rg "133cac15-3efb-50fa-b5fc-4b90e441e563" --type ts --type js
# Also check for any comments or documentation about zenstack namespace
rg -i "zenstack.*namespace\|namespace.*zenstack" --type ts --type js -A 2 -B 2Repository: zenstackhq/proxy Length of output: 142 Clarify the namespace UUID usage. The namespace UUID 🤖 Prompt for AI Agents |
||
|
|
||
| get isTracking() { | ||
| return !!this.mixpanel | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| // modified from https://github.com/automation-stack/node-machine-id | ||
|
|
||
| import { execSync } from 'child_process' | ||
| import { createHash, randomUUID } from 'node:crypto' | ||
| import { createHash } from 'node:crypto' | ||
| import { v4 as uuid } from 'uuid' | ||
|
|
||
| const { platform } = process | ||
| const win32RegBinPath = { | ||
|
|
@@ -31,7 +32,7 @@ function hash(guid: string): string { | |
| return createHash('sha256').update(guid).digest('hex') | ||
| } | ||
|
|
||
| function expose(result: string): string | undefined { | ||
| function expose(result: string): string { | ||
|
||
| switch (platform) { | ||
| case 'darwin': | ||
| return result | ||
|
|
@@ -62,16 +63,13 @@ function expose(result: string): string | undefined { | |
|
|
||
| export function getMachineId() { | ||
| if (!(platform in guid)) { | ||
| return randomUUID() | ||
| return uuid() | ||
| } | ||
| try { | ||
| const value = execSync(guid[platform as keyof typeof guid]) | ||
| const id = expose(value.toString()) | ||
| if (!id) { | ||
| return randomUUID() | ||
| } | ||
| return hash(id) | ||
| } catch { | ||
| return randomUUID() | ||
| return uuid() | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,15 +71,9 @@ function loadPrismaConfig(schemaDir: string): string | null { | |||||
|
|
||||||
| // Use Function constructor to safely evaluate the object literal | ||||||
| // This is safer than eval as it doesn't have access to the local scope | ||||||
| try { | ||||||
| const configFn = new Function('env', `return ${configObjectStr}`) | ||||||
| const config = configFn(env) | ||||||
|
|
||||||
| return config?.datasource?.url || null | ||||||
| } catch (evalError) { | ||||||
| console.warn(`Warning: Could not evaluate config object: ${evalError}`) | ||||||
| return null | ||||||
| } | ||||||
| const configFn = new Function('env', `return ${configObjectStr}`) | ||||||
| const config = configFn(env) | ||||||
| return config?.datasource?.url | ||||||
| } catch (error) { | ||||||
| if (error instanceof Error && error.message.includes('Environment variable')) { | ||||||
| throw error | ||||||
|
|
@@ -117,34 +111,43 @@ function parseDatasource( | |||||
| return { provider, url: datasourceUrlOverride } | ||||||
| } | ||||||
|
|
||||||
| // Extract url from schema | ||||||
| let urlMatch = datasourceBlock.match(/url\s*=\s*['"]([^'"]+)['"]/) | ||||||
| // Extract url value using single regex (could be string literal, env() call, or expression) | ||||||
| const urlMatch = datasourceBlock.match(/url\s*=\s*([^\n]+)/) | ||||||
| let url: string | null = null | ||||||
|
|
||||||
| if (urlMatch) { | ||||||
| url = urlMatch[1] | ||||||
| } else { | ||||||
| // Try to match env("xxx") | ||||||
| const envMatch = datasourceBlock.match(/url\s*=\s*env\(\s*['"]([^'"]+)['"]\s*\)/) | ||||||
| if (envMatch) { | ||||||
| const envVar = envMatch[1] | ||||||
| const envValue = process.env[envVar] | ||||||
| if (envValue) { | ||||||
| url = envValue | ||||||
| const urlValueStr = urlMatch[1].trim() | ||||||
|
|
||||||
| // Create env helper function | ||||||
| const env = (varName: string) => { | ||||||
| const value = process.env[varName] | ||||||
| if (!value) { | ||||||
| throw new CliError(`Environment variable ${varName} is not set`) | ||||||
| } | ||||||
| return value | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // If no URL found in schema, try prisma.config.ts (Prisma 7) | ||||||
| if (!url) { | ||||||
| try { | ||||||
| // Use Function constructor to evaluate the url value | ||||||
| const urlFn = new Function('env', `return ${urlValueStr}`) | ||||||
| url = urlFn(env) | ||||||
| } catch (evalError) { | ||||||
| throw new CliError( | ||||||
| 'Could not evaluate datasource url from schema, you could provide it via -d option.' | ||||||
| ) | ||||||
| } | ||||||
| } else { | ||||||
| url = loadPrismaConfig(schemaDir) | ||||||
| // If still no URL found, throw error | ||||||
| if (url == null) { | ||||||
| throw new CliError( | ||||||
| 'No datasource URL found. For Prisma 7, ensure prisma.config.ts exists with datasource configuration, or provide the URL via -d option.' | ||||||
| ) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // If still no URL found, throw error | ||||||
| if (!url) { | ||||||
| throw new CliError( | ||||||
| 'No datasource URL found. For Prisma 7, ensure prisma.config.ts exists with datasource configuration, or provide the URL via --datasource-url option.' | ||||||
| ) | ||||||
| throw new CliError('datasource url has no value, you could provide it via -d option.') | ||||||
| } | ||||||
|
|
||||||
| return { provider, url } | ||||||
|
|
@@ -157,7 +160,9 @@ function parseGenerator(content: string): GeneratorConfig { | |||||
| // Match generator block for prisma client | ||||||
| const generatorMatch = content.match(/generator\s+\w+\s*\{([^}]+)\}/s) | ||||||
| if (!generatorMatch) { | ||||||
| throw new CliError('No generator block found in zmodel schema') | ||||||
| throw new CliError( | ||||||
| 'No generator block found in zmodel schema.\nZenStack V3 is not supported, V3 will have built-in proxy support soon.' | ||||||
|
||||||
| 'No generator block found in zmodel schema.\nZenStack V3 is not supported, V3 will have built-in proxy support soon.' | |
| 'No generator block found in zmodel schema.\nZenStack V3 schemas are not supported by this CLI yet. Built-in proxy support for V3 is planned but not currently available.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states this is a "namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'", but the hardcoded UUID should be verified. The standard DNS namespace UUID is '6ba7b810-9dad-11d1-80b4-00c04fd430c8'. If '133cac15-3efb-50fa-b5fc-4b90e441e563' is a custom namespace derived from 'zenstack.dev', the comment should clarify this to avoid confusion.