@gokiteam/goki-dev 0.2.1 → 0.2.2

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.
@@ -1,13 +1,12 @@
1
1
  import { execa } from 'execa'
2
2
  import fs from 'fs'
3
+ import os from 'os'
3
4
  import path from 'path'
4
- import { fileURLToPath } from 'url'
5
5
  import { Logger } from './Logger.js'
6
6
 
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
7
  const DEV_TOOLS_API = 'http://localhost:9000'
9
8
  const NGROK_API = 'http://localhost:4040'
10
- const DATA_DIR = path.resolve(__dirname, '..', 'data')
9
+ const DATA_DIR = path.join(os.homedir(), '.goki-dev', 'data')
11
10
  const PID_FILE = path.join(DATA_DIR, 'ngrok.pid')
12
11
  const STATE_FILE = path.join(DATA_DIR, 'ngrok.json')
13
12
 
@@ -17,7 +17,6 @@ SHADOW_SUBSCRIPTION_CHECK_INTERVAL_MS=5000
17
17
  FIRESTORE_PROJECT_ID=goki-dev-local
18
18
 
19
19
  # Storage
20
- DATA_DIR=./data
21
20
  AUTO_FLUSH_INTERVAL_MS=5000
22
21
 
23
22
  # Redis (for app data)
@@ -44,7 +44,7 @@ services:
44
44
  volumes:
45
45
  - ./src:/app/src:ro
46
46
  - ./docs:/app/docs:ro
47
- - ./data:/app/data
47
+ - ~/.goki-dev/data:/app/data
48
48
  - ./logs:/app/logs
49
49
  - /var/run/docker.sock:/var/run/docker.sock:ro
50
50
  depends_on:
@@ -93,7 +93,7 @@ services:
93
93
  - APP_GATEWAY_SCAN_INTERVAL_SECONDS=30
94
94
  - APP_GATEWAY_AUTO_START=true
95
95
  volumes:
96
- - ./data:/app/data
96
+ - ~/.goki-dev/data:/app/data
97
97
  - ./logs:/app/logs
98
98
  - /var/run/docker.sock:/var/run/docker.sock
99
99
  depends_on:
package/package.json CHANGED
@@ -1,24 +1,8 @@
1
1
  {
2
2
  "name": "@gokiteam/goki-dev",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Unified local development platform for Goki services",
5
5
  "type": "module",
6
- "main": "./client/dist/index.js",
7
- "types": "./client/dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./client/dist/index.d.ts",
11
- "import": "./client/dist/index.js",
12
- "require": "./client/dist/index.js"
13
- }
14
- },
15
- "typesVersions": {
16
- "*": {
17
- ".": [
18
- "./client/dist/index.d.ts"
19
- ]
20
- }
21
- },
22
6
  "bin": {
23
7
  "goki-dev": "./bin/goki-dev.js",
24
8
  "goki-dev-mcp": "./bin/mcp-server.js",
@@ -28,7 +12,6 @@
28
12
  "bin/",
29
13
  "cli/",
30
14
  "src/",
31
- "client/dist/",
32
15
  "ui/build/",
33
16
  "docker-compose.yml",
34
17
  "docker-compose.services.yml",
@@ -48,12 +31,11 @@
48
31
  "dev:watch": "dotenv -e config.development node --watch src/Server.js",
49
32
  "dev:ui": "concurrently \"npm run dev\" \"cd ui && npm start\" --names \"backend,frontend\" --prefix-colors \"blue,green\"",
50
33
  "ui:start": "cd ui && npm start",
51
- "ui:build": "cd ui && npm run build",
52
- "build:client": "cd client && npx tsc && echo '{\"type\":\"commonjs\"}' > dist/package.json",
53
- "prepublishOnly": "npm run ui:build && npm run build:client",
54
- "release": "npm version patch && npm run build:client && npm publish",
55
- "release:minor": "npm version minor && npm run build:client && npm publish",
56
- "release:major": "npm version major && npm run build:client && npm publish",
34
+ "build": "cd ui && npm run build && cd ../client && npm run build",
35
+ "prepublishOnly": "npm run build",
36
+ "release": "standard-version && npm run build && npm publish && cd client && npm publish",
37
+ "release:minor": "standard-version --release-as minor && npm run build && npm publish && cd client && npm publish",
38
+ "release:major": "standard-version --release-as major && npm run build && npm publish && cd client && npm publish",
57
39
  "test": "dotenv -e config.test mocha 'tests/**/*.test.js'",
58
40
  "test:api": "dotenv -e config.test mocha 'tests/api/**/*.test.js'",
59
41
  "test:emulation": "dotenv -e config.test mocha 'tests/emulation/**/*.test.js'",
@@ -137,6 +119,7 @@
137
119
  "mqtt": "^5.15.0",
138
120
  "playwright": "^1.58.1",
139
121
  "standard": "^17.1.0",
122
+ "standard-version": "^9.5.0",
140
123
  "supertest": "^6.3.0",
141
124
  "typescript": "^5.9.3"
142
125
  },
@@ -145,5 +128,17 @@
145
128
  "mocha"
146
129
  ]
147
130
  },
131
+ "standard-version": {
132
+ "bumpFiles": [
133
+ {
134
+ "filename": "package.json",
135
+ "type": "json"
136
+ },
137
+ {
138
+ "filename": "client/package.json",
139
+ "type": "json"
140
+ }
141
+ ]
142
+ },
148
143
  "packageManager": "yarn@3.8.7+sha512.bbe7e310ff7fd20dc63b111110f96fe18192234bb0d4f10441fa6b85d2b644c8923db8fbe6d7886257ace948440ab1f83325ad02af457a1806cdc97f03d2508e"
149
144
  }
@@ -1,7 +1,7 @@
1
1
  import { execa } from 'execa'
2
2
  import fs from 'fs/promises'
3
+ import os from 'os'
3
4
  import path from 'path'
4
- import { fileURLToPath } from 'url'
5
5
  import { Logic as FirestoreLogic } from '../firestore/Logic.js'
6
6
  import { Logic as DockerLogic } from '../docker/Logic.js'
7
7
  import { Logic as PubSubLogic } from '../pubsub/Logic.js'
@@ -23,10 +23,7 @@ import {
23
23
  PUBSUB_MESSAGE_HISTORY
24
24
  } from '../../db/Tables.js'
25
25
 
26
- const __filename = fileURLToPath(import.meta.url)
27
- const __dirname = path.dirname(__filename)
28
- const PROJECT_ROOT = path.join(__dirname, '../../..')
29
- const SNAPSHOTS_DIR = path.join(PROJECT_ROOT, '.goki-dev/snapshots')
26
+ const SNAPSHOTS_DIR = path.join(os.homedir(), '.goki-dev', 'snapshots')
30
27
 
31
28
  // Ensure snapshot directories exist
32
29
  async function ensureSnapshotDirs () {
@@ -1,4 +1,6 @@
1
1
  import Moment from 'moment'
2
+ import os from 'os'
3
+ import path from 'path'
2
4
 
3
5
  const {
4
6
  NODE_ENV = 'development',
@@ -77,7 +79,7 @@ export const Application = {
77
79
  shadowSubscriptionCheckIntervalMs: parseInt(SHADOW_SUBSCRIPTION_CHECK_INTERVAL_MS) || 5000
78
80
  },
79
81
  storage: {
80
- dataDir: DATA_DIR
82
+ dataDir: DATA_DIR || path.join(os.homedir(), '.goki-dev', 'data')
81
83
  },
82
84
  redis: {
83
85
  host: REDIS_HOST || 'localhost',
@@ -21,10 +21,15 @@ class SqliteStoreClass {
21
21
  initialize (dbPath = null) {
22
22
  if (this.isInitialized) return
23
23
 
24
- const dataDir = Application.storage.dataDir || './data'
24
+ const dataDir = Application.storage.dataDir
25
25
  if (!fs.existsSync(dataDir)) {
26
26
  fs.mkdirSync(dataDir, { recursive: true })
27
27
  }
28
+ if (dataDir.includes('.goki-dev') && fs.existsSync('./data/dev-tools.db')) {
29
+ console.warn('[MIGRATION] Found legacy database at ./data/dev-tools.db')
30
+ console.warn(`[MIGRATION] Database now lives at ${path.join(dataDir, 'dev-tools.db')}`)
31
+ console.warn(`[MIGRATION] Copy manually: cp ./data/dev-tools.db ${path.join(dataDir, 'dev-tools.db')}`)
32
+ }
28
33
 
29
34
  const finalDbPath = dbPath || path.join(dataDir, 'dev-tools.db')
30
35
  this.db = new Database(finalDbPath)
@@ -1,380 +0,0 @@
1
- /**
2
- * @gokiteam/goki-dev - Main Client
3
- *
4
- * HTTP client for Goki Developer Tools
5
- */
6
- import { AxiosInstance } from 'axios';
7
- import type * as Types from './types';
8
- export interface DevToolsClientConfig {
9
- baseUrl?: string;
10
- timeout?: number;
11
- }
12
- export declare class PubSubClient {
13
- private client;
14
- constructor(client: AxiosInstance);
15
- private call;
16
- /**
17
- * Extract short topic name from a full path like 'projects/X/topics/Y' -> 'Y'
18
- */
19
- private extractTopicName;
20
- publish(params: {
21
- topic: string;
22
- message: any;
23
- attributes?: Record<string, string>;
24
- traceId?: string;
25
- }): Promise<{
26
- messageIds: string[];
27
- } & {
28
- traceId: string;
29
- }>;
30
- waitForMessage(params: Types.WaitForMessageRequest): Promise<Types.WaitForMessageResponse>;
31
- assertMessagePublished(params: Types.AssertMessagePublishedRequest): Promise<Types.AssertMessagePublishedResponse>;
32
- getMessages(params?: {
33
- filter?: Types.PubSubHistoryFilter;
34
- page?: Types.PageOptions;
35
- traceId?: string;
36
- }): Promise<{
37
- messages: Types.PubSubMessage[];
38
- total: number;
39
- } & {
40
- traceId: string;
41
- }>;
42
- searchMessages(params: {
43
- query: string;
44
- filter?: Partial<Types.PubSubHistoryFilter>;
45
- traceId?: string;
46
- }): Promise<{
47
- messages: Types.PubSubMessage[];
48
- total: number;
49
- } & {
50
- traceId: string;
51
- }>;
52
- listTopics(params?: {
53
- traceId?: string;
54
- }): Promise<{
55
- topics: Types.PubSubTopic[];
56
- total: number;
57
- } & {
58
- traceId: string;
59
- }>;
60
- createTopic(params: {
61
- topic: string;
62
- traceId?: string;
63
- }): Promise<{
64
- topic: Types.PubSubTopic;
65
- } & {
66
- traceId: string;
67
- }>;
68
- deleteTopic(params: {
69
- topic: string;
70
- traceId?: string;
71
- }): Promise<void>;
72
- }
73
- export declare class LoggingClient {
74
- private client;
75
- constructor(client: AxiosInstance);
76
- private call;
77
- getByTrace(params: {
78
- traceId: string;
79
- queryTraceId?: string;
80
- }): Promise<{
81
- traceId: string;
82
- entries: Types.LogEntry[];
83
- count: number;
84
- }>;
85
- list(params?: {
86
- filter?: Types.LogFilter;
87
- page?: Types.PageOptions;
88
- traceId?: string;
89
- }): Promise<{
90
- entries: Types.LogEntry[];
91
- total: number;
92
- } & {
93
- traceId: string;
94
- }>;
95
- clear(params?: {
96
- service?: string;
97
- traceId?: string;
98
- }): Promise<{
99
- deletedCount: number;
100
- } & {
101
- traceId: string;
102
- }>;
103
- waitForLog(params: Types.WaitForLogRequest): Promise<Types.WaitForLogResponse>;
104
- assertNoErrors(params: Types.AssertNoErrorsRequest): Promise<Types.AssertNoErrorsResponse>;
105
- }
106
- export declare class PostgresClient {
107
- private client;
108
- constructor(client: AxiosInstance);
109
- private call;
110
- query(params: Types.PostgresQueryRequest): Promise<Types.PostgresQueryResponse>;
111
- listTables(params: {
112
- database: string;
113
- schema?: string;
114
- traceId?: string;
115
- }): Promise<{
116
- tables: {
117
- name: string;
118
- rowCount: number;
119
- }[];
120
- } & {
121
- traceId: string;
122
- }>;
123
- listRows(params: {
124
- database: string;
125
- schema: string;
126
- table: string;
127
- page?: Types.PageOptions;
128
- traceId?: string;
129
- }): Promise<{
130
- rows: any[];
131
- total: number;
132
- } & {
133
- traceId: string;
134
- }>;
135
- waitForCondition(params: Types.WaitForConditionRequest & {
136
- type: 'postgres';
137
- }): Promise<Types.WaitForConditionResponse>;
138
- }
139
- export declare class RedisClient {
140
- private client;
141
- constructor(client: AxiosInstance);
142
- private call;
143
- get(params: {
144
- key: string;
145
- traceId?: string;
146
- }): Promise<Types.RedisValue>;
147
- scan(params: {
148
- pattern: string;
149
- count?: number;
150
- traceId?: string;
151
- }): Promise<{
152
- keys: Types.RedisKey[];
153
- total: number;
154
- } & {
155
- traceId: string;
156
- }>;
157
- delete(params: {
158
- key: string;
159
- traceId?: string;
160
- }): Promise<{
161
- deleted: boolean;
162
- } & {
163
- traceId: string;
164
- }>;
165
- deletePattern(params: {
166
- pattern: string;
167
- traceId?: string;
168
- }): Promise<{
169
- deletedCount: number;
170
- } & {
171
- traceId: string;
172
- }>;
173
- waitForCondition(params: Types.WaitForConditionRequest & {
174
- type: 'redis';
175
- }): Promise<Types.WaitForConditionResponse>;
176
- }
177
- export declare class FirestoreClient {
178
- private client;
179
- constructor(client: AxiosInstance);
180
- private call;
181
- /**
182
- * Parses a Firestore REST API typed value into a plain JS value.
183
- */
184
- private parseFirestoreValue;
185
- /**
186
- * Parses Firestore REST API fields object into a plain JS object.
187
- */
188
- private parseFirestoreFields;
189
- /**
190
- * Converts a raw Firestore REST API document to a clean FirestoreDocument.
191
- * Raw format: { name: "projects/.../documents/collection/id", fields: { key: { stringValue: "..." } }, ... }
192
- * Clean format: { id: "docId", data: { key: "..." } }
193
- */
194
- private parseRawDocument;
195
- getDocument(params: {
196
- collection: string;
197
- documentId: string;
198
- traceId?: string;
199
- }): Promise<{
200
- document: Types.FirestoreDocument;
201
- }>;
202
- query(params: {
203
- collection: string;
204
- where: Types.FirestoreQuery;
205
- traceId?: string;
206
- }): Promise<{
207
- documents: Types.FirestoreDocument[];
208
- }>;
209
- listDocuments(params: {
210
- collection: string;
211
- page?: Types.PageOptions;
212
- traceId?: string;
213
- }): Promise<{
214
- documents: Types.FirestoreDocument[];
215
- total: number;
216
- }>;
217
- deleteByQuery(params: Types.DeleteByQueryRequest): Promise<Types.DeleteByQueryResponse>;
218
- deleteByPrefix(params: Types.DeleteByPrefixRequest): Promise<Types.DeleteByPrefixResponse>;
219
- deleteBatch(params: Types.DeleteBatchRequest): Promise<Types.DeleteBatchResponse>;
220
- waitForCondition(params: Types.WaitForConditionRequest & {
221
- type: 'firestore';
222
- }): Promise<Types.WaitForConditionResponse>;
223
- }
224
- export declare class MqttClient {
225
- private client;
226
- constructor(client: AxiosInstance);
227
- private call;
228
- listClients(params?: {
229
- traceId?: string;
230
- }): Promise<{
231
- clients: Types.MqttClientInfo[];
232
- } & {
233
- traceId: string;
234
- }>;
235
- getMessages(params?: {
236
- filter?: {
237
- clientId?: string;
238
- topic?: string;
239
- };
240
- page?: Types.PageOptions;
241
- traceId?: string;
242
- }): Promise<{
243
- messages: Types.MqttMessage[];
244
- total: number;
245
- } & {
246
- traceId: string;
247
- }>;
248
- }
249
- export declare class DockerClient {
250
- private client;
251
- constructor(client: AxiosInstance);
252
- private call;
253
- list(params?: {
254
- traceId?: string;
255
- }): Promise<{
256
- data: Types.DockerContainer[];
257
- } & {
258
- traceId: string;
259
- }>;
260
- start(params: {
261
- containerName: string;
262
- traceId?: string;
263
- }): Promise<void>;
264
- stop(params: {
265
- containerName: string;
266
- traceId?: string;
267
- }): Promise<void>;
268
- restart(params: {
269
- containerName: string;
270
- traceId?: string;
271
- }): Promise<void>;
272
- logs(params: {
273
- containerName: string;
274
- lines?: number;
275
- traceId?: string;
276
- }): Promise<{
277
- data: string;
278
- } & {
279
- traceId: string;
280
- }>;
281
- }
282
- export declare class PlatformClient {
283
- private client;
284
- constructor(client: AxiosInstance);
285
- private call;
286
- getStats(params?: {
287
- traceId?: string;
288
- }): Promise<{
289
- stats: Types.PlatformStats;
290
- } & {
291
- traceId: string;
292
- }>;
293
- clearAll(params?: {
294
- traceId?: string;
295
- }): Promise<{
296
- cleared: Record<string, number>;
297
- } & {
298
- traceId: string;
299
- }>;
300
- clearServices(params: Types.ClearServiceDataRequest): Promise<Types.ClearServiceDataResponse>;
301
- export(params?: {
302
- traceId?: string;
303
- }): Promise<{
304
- export: Types.ExportData;
305
- } & {
306
- traceId: string;
307
- }>;
308
- }
309
- export declare class SchedulerClient {
310
- private client;
311
- constructor(client: AxiosInstance);
312
- private call;
313
- triggerTick(params?: {
314
- traceId?: string;
315
- }): Promise<Types.SchedulerTickResponse>;
316
- }
317
- export declare class HttpTrafficClient {
318
- private client;
319
- constructor(client: AxiosInstance);
320
- private call;
321
- list(params?: {
322
- filter?: Types.HttpTrafficFilter;
323
- limit?: number;
324
- offset?: number;
325
- traceId?: string;
326
- }): Promise<{
327
- entries: Types.HttpTrafficEntry[];
328
- total: number;
329
- limit: number;
330
- offset: number;
331
- } & {
332
- traceId: string;
333
- }>;
334
- getDetails(params: {
335
- id: string;
336
- traceId?: string;
337
- }): Promise<{
338
- entry: Types.HttpTrafficEntry;
339
- } & {
340
- traceId: string;
341
- }>;
342
- clear(params?: {
343
- traceId?: string;
344
- }): Promise<{
345
- message: string;
346
- } & {
347
- traceId: string;
348
- }>;
349
- waitFor(params: {
350
- filter: Types.HttpTrafficWaitFilter;
351
- timeout?: number;
352
- traceId?: string;
353
- }): Promise<{
354
- entry: Types.HttpTrafficEntry;
355
- foundAt: number;
356
- traceId: string;
357
- }>;
358
- stats(params?: {
359
- traceId?: string;
360
- }): Promise<Types.HttpTrafficStats & {
361
- traceId: string;
362
- }>;
363
- }
364
- export declare class DevToolsClient {
365
- private client;
366
- private baseUrl;
367
- pubsub: PubSubClient;
368
- logging: LoggingClient;
369
- postgres: PostgresClient;
370
- redis: RedisClient;
371
- firestore: FirestoreClient;
372
- mqtt: MqttClient;
373
- docker: DockerClient;
374
- platform: PlatformClient;
375
- scheduler: SchedulerClient;
376
- httpTraffic: HttpTrafficClient;
377
- constructor(config?: DevToolsClientConfig);
378
- generateTraceId(prefix?: string): string;
379
- }
380
- export * from './types';