File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @zenstackhq/proxy" ,
3- "version" : " 0.2.1 " ,
3+ "version" : " 0.2.2 " ,
44 "description" : " A CLI tool to run an Express server that proxies CRUD requests to a ZenStack backend" ,
55 "main" : " index.js" ,
66 "publishConfig" : {
3333 "express" : " ^4.19.2" ,
3434 "mixpanel" : " ^0.19.1" ,
3535 "semver" : " ^7.7.3" ,
36- "tsx" : " ^4.20.6"
36+ "tsx" : " ^4.20.6" ,
37+ "uuid" : " ^13.0.0"
3738 },
3839 "devDependencies" : {
3940 "@types/cors" : " ^2.8.17" ,
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import 'dotenv/config'
1010import { getVersion } from './utils/version-utils'
1111import { telemetry } from './telemetry'
1212import { CliError } from './cli-error'
13-
1413export function createProgram ( ) {
1514 const program = new Command ( )
1615
@@ -32,7 +31,7 @@ export function createProgram() {
3231 : path . join ( process . cwd ( ) , options . schema )
3332
3433 if ( ! fs . existsSync ( zmodelPath ) ) {
35- console . error ( `Error: ZModel schema file not found: ${ zmodelPath } ` )
34+ console . error ( `ZModel schema file not found: ${ zmodelPath } ` )
3635 console . error ( 'Please provide a valid path using the -s option.' )
3736 process . exit ( 1 )
3837 }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import isDocker from './utils/is-docker'
88import { isWsl } from './utils/is-wsl'
99import { getMachineId } from './utils/machine-id-utils'
1010import { getPrismaVersion , getVersion } from './utils/version-utils'
11+ import { v5 as uuidv5 } from 'uuid'
1112
1213/**
1314 * Telemetry events
@@ -18,7 +19,7 @@ export type TelemetryEvents = 'proxy:start' | 'proxy:complete' | 'proxy:error'
1819 */
1920export class Telemetry {
2021 private readonly mixpanel : Mixpanel | undefined
21- private readonly hostId = getMachineId ( )
22+ private readonly hostId = this . getDeviceId ( )
2223 private readonly sessionid = randomUUID ( )
2324 private readonly _os_type = os . type ( )
2425 private readonly _os_release = os . release ( )
@@ -40,6 +41,12 @@ export class Telemetry {
4041 }
4142 }
4243
44+ private getDeviceId ( ) {
45+ const hostId = getMachineId ( )
46+ // namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'
47+ return uuidv5 ( hostId , '133cac15-3efb-50fa-b5fc-4b90e441e563' )
48+ }
49+
4350 get isTracking ( ) {
4451 return ! ! this . mixpanel
4552 }
Original file line number Diff line number Diff line change 11// modified from https://github.com/automation-stack/node-machine-id
22
33import { execSync } from 'child_process'
4- import { createHash , randomUUID } from 'node:crypto'
4+ import { createHash } from 'node:crypto'
5+ import { v4 as uuid } from 'uuid'
56
67const { platform } = process
78const win32RegBinPath = {
@@ -31,7 +32,7 @@ function hash(guid: string): string {
3132 return createHash ( 'sha256' ) . update ( guid ) . digest ( 'hex' )
3233}
3334
34- function expose ( result : string ) : string | undefined {
35+ function expose ( result : string ) : string {
3536 switch ( platform ) {
3637 case 'darwin' :
3738 return result
@@ -62,16 +63,13 @@ function expose(result: string): string | undefined {
6263
6364export function getMachineId ( ) {
6465 if ( ! ( platform in guid ) ) {
65- return randomUUID ( )
66+ return uuid ( )
6667 }
6768 try {
6869 const value = execSync ( guid [ platform as keyof typeof guid ] )
6970 const id = expose ( value . toString ( ) )
70- if ( ! id ) {
71- return randomUUID ( )
72- }
7371 return hash ( id )
7472 } catch {
75- return randomUUID ( )
73+ return uuid ( )
7674 }
7775}
Original file line number Diff line number Diff line change @@ -157,7 +157,9 @@ function parseGenerator(content: string): GeneratorConfig {
157157 // Match generator block for prisma client
158158 const generatorMatch = content . match ( / g e n e r a t o r \s + \w + \s * \{ ( [ ^ } ] + ) \} / s)
159159 if ( ! generatorMatch ) {
160- throw new CliError ( 'No generator block found in zmodel schema' )
160+ throw new CliError (
161+ 'No generator block found in zmodel schema.\nZenStack V3 is not supported, V3 will have built-in proxy support soon.'
162+ )
161163 }
162164
163165 const generatorBlock = generatorMatch [ 1 ]
You can’t perform that action at this time.
0 commit comments