@gokiteam/goki-dev 0.2.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 +478 -0
- package/bin/goki-dev.js +452 -0
- package/bin/mcp-server.js +16 -0
- package/bin/secrets-cli.js +302 -0
- package/cli/ComposeOverrideGenerator.js +226 -0
- package/cli/ComposeParser.js +73 -0
- package/cli/ConfigGenerator.js +304 -0
- package/cli/ConfigManager.js +46 -0
- package/cli/DatabaseManager.js +94 -0
- package/cli/DevToolsChecker.js +21 -0
- package/cli/DevToolsDir.js +66 -0
- package/cli/DevToolsManager.js +451 -0
- package/cli/DockerManager.js +138 -0
- package/cli/FunctionManager.js +95 -0
- package/cli/HttpProxyRewriter.js +91 -0
- package/cli/Logger.js +10 -0
- package/cli/McpConfigManager.js +123 -0
- package/cli/NgrokManager.js +431 -0
- package/cli/ProjectCLI.js +2322 -0
- package/cli/PubSubManager.js +129 -0
- package/cli/SnapshotManager.js +88 -0
- package/cli/UiFormatter.js +292 -0
- package/cli/WebhookUrlRewriter.js +32 -0
- package/cli/secrets/BiometricAuth.js +125 -0
- package/cli/secrets/SecretInjector.js +47 -0
- package/cli/secrets/SecretsConfig.js +141 -0
- package/cli/secrets/SecretsDoctor.js +384 -0
- package/cli/secrets/SecretsManager.js +255 -0
- package/client/dist/client.d.ts +332 -0
- package/client/dist/client.js +507 -0
- package/client/dist/helpers.d.ts +62 -0
- package/client/dist/helpers.js +122 -0
- package/client/dist/index.d.ts +59 -0
- package/client/dist/index.js +78 -0
- package/client/dist/package.json +1 -0
- package/client/dist/types.d.ts +280 -0
- package/client/dist/types.js +7 -0
- package/config.development +46 -0
- package/config.test +18 -0
- package/guidelines/CodingStyleGuideline.md +148 -0
- package/guidelines/CommentingGuideline.md +10 -0
- package/guidelines/HttpApiImplementationGuideline.md +137 -0
- package/guidelines/NamingGuideline.md +182 -0
- package/package.json +138 -0
- package/patterns/api/[collectionName]/Controllers.md +62 -0
- package/patterns/api/[collectionName]/Logic.md +154 -0
- package/patterns/api/[collectionName]/Permissions.md +81 -0
- package/patterns/api/[collectionName]/Router.md +83 -0
- package/patterns/api/[collectionName]/Schemas.md +197 -0
- package/patterns/configs/Patterns.md +7 -0
- package/patterns/enums/Patterns.md +24 -0
- package/patterns/errorHandling/Patterns.md +185 -0
- package/patterns/testing/Patterns.md +232 -0
- package/src/Server.js +238 -0
- package/src/api/dashboard/Controllers.js +9 -0
- package/src/api/dashboard/Logic.js +76 -0
- package/src/api/dashboard/Router.js +11 -0
- package/src/api/dashboard/Schemas.js +47 -0
- package/src/api/data/Controllers.js +26 -0
- package/src/api/data/Logic.js +188 -0
- package/src/api/data/Router.js +16 -0
- package/src/api/docker/Controllers.js +33 -0
- package/src/api/docker/Logic.js +268 -0
- package/src/api/docker/Router.js +15 -0
- package/src/api/docker/Schemas.js +80 -0
- package/src/api/docs/Controllers.js +15 -0
- package/src/api/docs/Logic.js +85 -0
- package/src/api/docs/Router.js +12 -0
- package/src/api/export/Controllers.js +30 -0
- package/src/api/export/Logic.js +143 -0
- package/src/api/export/Router.js +18 -0
- package/src/api/export/Schemas.js +104 -0
- package/src/api/firestore/Controllers.js +152 -0
- package/src/api/firestore/Logic.js +474 -0
- package/src/api/firestore/Router.js +23 -0
- package/src/api/functions/Controllers.js +261 -0
- package/src/api/functions/Logic.js +710 -0
- package/src/api/functions/Router.js +50 -0
- package/src/api/functions/Schemas.js +193 -0
- package/src/api/gateway/Controllers.js +72 -0
- package/src/api/gateway/Logic.js +74 -0
- package/src/api/gateway/Router.js +10 -0
- package/src/api/gateway/Schemas.js +19 -0
- package/src/api/health/Controllers.js +14 -0
- package/src/api/health/Logic.js +24 -0
- package/src/api/health/Router.js +12 -0
- package/src/api/httpTraffic/Controllers.js +29 -0
- package/src/api/httpTraffic/Logic.js +33 -0
- package/src/api/httpTraffic/Router.js +9 -0
- package/src/api/httpTraffic/Schemas.js +23 -0
- package/src/api/logging/Controllers.js +80 -0
- package/src/api/logging/Logic.js +461 -0
- package/src/api/logging/Router.js +24 -0
- package/src/api/logging/Schemas.js +43 -0
- package/src/api/mqtt/Controllers.js +17 -0
- package/src/api/mqtt/Logic.js +66 -0
- package/src/api/mqtt/Router.js +12 -0
- package/src/api/postgres/Controllers.js +97 -0
- package/src/api/postgres/Logic.js +221 -0
- package/src/api/postgres/Router.js +21 -0
- package/src/api/pubsub/Controllers.js +236 -0
- package/src/api/pubsub/Logic.js +732 -0
- package/src/api/pubsub/Router.js +41 -0
- package/src/api/pubsub/Schemas.js +355 -0
- package/src/api/redis/Controllers.js +63 -0
- package/src/api/redis/Logic.js +239 -0
- package/src/api/redis/Router.js +21 -0
- package/src/api/scheduler/Controllers.js +27 -0
- package/src/api/scheduler/Logic.js +49 -0
- package/src/api/scheduler/Router.js +16 -0
- package/src/api/services/Controllers.js +26 -0
- package/src/api/services/Logic.js +205 -0
- package/src/api/services/Router.js +14 -0
- package/src/api/services/Schemas.js +66 -0
- package/src/api/snapshots/Controllers.js +37 -0
- package/src/api/snapshots/Logic.js +797 -0
- package/src/api/snapshots/Router.js +15 -0
- package/src/api/snapshots/Schemas.js +23 -0
- package/src/api/webhooks/Controllers.js +49 -0
- package/src/api/webhooks/Logic.js +137 -0
- package/src/api/webhooks/Router.js +12 -0
- package/src/api/webhooks/Schemas.js +31 -0
- package/src/configs/Application.js +147 -0
- package/src/configs/Default.js +13 -0
- package/src/consumers/BlackboxLogsConsumer.js +235 -0
- package/src/consumers/DockerLogsConsumer.js +687 -0
- package/src/db/Tables.js +66 -0
- package/src/db/schemas/firestore.js +18 -0
- package/src/db/schemas/functions.js +65 -0
- package/src/db/schemas/httpTraffic.js +43 -0
- package/src/db/schemas/logging.js +74 -0
- package/src/db/schemas/migrations.js +64 -0
- package/src/db/schemas/mqtt.js +56 -0
- package/src/db/schemas/pubsub.js +90 -0
- package/src/db/schemas/pubsubRegistry.js +22 -0
- package/src/db/schemas/webhooks.js +28 -0
- package/src/emulation/awsiot/Controllers.js +91 -0
- package/src/emulation/awsiot/Logic.js +70 -0
- package/src/emulation/awsiot/Router.js +19 -0
- package/src/emulation/awsiot/Server.js +100 -0
- package/src/emulation/firestore/Server.js +136 -0
- package/src/emulation/logging/Controllers.js +212 -0
- package/src/emulation/logging/Logic.js +416 -0
- package/src/emulation/logging/Router.js +36 -0
- package/src/emulation/logging/Schemas.js +82 -0
- package/src/emulation/logging/Server.js +108 -0
- package/src/emulation/pubsub/Controllers.js +279 -0
- package/src/emulation/pubsub/DefaultTopics.js +162 -0
- package/src/emulation/pubsub/Logic.js +427 -0
- package/src/emulation/pubsub/README.md +309 -0
- package/src/emulation/pubsub/Router.js +33 -0
- package/src/emulation/pubsub/Server.js +104 -0
- package/src/emulation/pubsub/ShadowPoller.js +276 -0
- package/src/emulation/pubsub/ShadowSubscriptionManager.js +199 -0
- package/src/enums/ContainerNames.js +106 -0
- package/src/enums/ErrorReason.js +28 -0
- package/src/enums/FunctionStatuses.js +15 -0
- package/src/enums/FunctionTriggerTypes.js +15 -0
- package/src/enums/GatewayState.js +7 -0
- package/src/enums/ServiceNames.js +68 -0
- package/src/jobs/DatabaseMaintenance.js +184 -0
- package/src/jobs/MessageHistoryCleanup.js +152 -0
- package/src/mcp/ApiClient.js +25 -0
- package/src/mcp/Server.js +52 -0
- package/src/mcp/prompts/debugging.js +104 -0
- package/src/mcp/resources/platform.js +118 -0
- package/src/mcp/tools/data.js +84 -0
- package/src/mcp/tools/docker.js +166 -0
- package/src/mcp/tools/firestore.js +162 -0
- package/src/mcp/tools/functions.js +380 -0
- package/src/mcp/tools/httpTraffic.js +69 -0
- package/src/mcp/tools/logging.js +174 -0
- package/src/mcp/tools/mqtt.js +37 -0
- package/src/mcp/tools/postgres.js +130 -0
- package/src/mcp/tools/pubsub.js +316 -0
- package/src/mcp/tools/redis.js +146 -0
- package/src/mcp/tools/services.js +169 -0
- package/src/mcp/tools/snapshots.js +88 -0
- package/src/mcp/tools/webhooks.js +115 -0
- package/src/middleware/DevProxy.js +67 -0
- package/src/middleware/ErrorCatcher.js +35 -0
- package/src/middleware/HttpProxy.js +215 -0
- package/src/middleware/Reply.js +24 -0
- package/src/middleware/TraceId.js +9 -0
- package/src/middleware/WebhookProxy.js +234 -0
- package/src/protocols/mqtt/Broker.js +92 -0
- package/src/protocols/mqtt/Handlers.js +175 -0
- package/src/protocols/mqtt/PubSubBridge.js +162 -0
- package/src/protocols/mqtt/Server.js +116 -0
- package/src/runtime/FunctionRunner.js +179 -0
- package/src/services/AppGatewayService.js +582 -0
- package/src/singletons/FirestoreBroadcaster.js +367 -0
- package/src/singletons/FunctionTriggerDispatcher.js +456 -0
- package/src/singletons/FunctionsService.js +418 -0
- package/src/singletons/HttpProxy.js +224 -0
- package/src/singletons/LogBroadcaster.js +159 -0
- package/src/singletons/Logger.js +49 -0
- package/src/singletons/MemoryJsonStore.js +175 -0
- package/src/singletons/MessageBroadcaster.js +190 -0
- package/src/singletons/PostgresBroadcaster.js +367 -0
- package/src/singletons/PostgresClient.js +180 -0
- package/src/singletons/RedisClient.js +184 -0
- package/src/singletons/SqliteStore.js +480 -0
- package/src/singletons/TickService.js +151 -0
- package/src/singletons/WebhookProxy.js +223 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import os from 'os'
|
|
4
|
+
import { keyring } from '@zowe/secrets-for-zowe-sdk'
|
|
5
|
+
import { BiometricAuth } from './BiometricAuth.js'
|
|
6
|
+
|
|
7
|
+
const SERVICE_NAME = 'goki-secrets'
|
|
8
|
+
const CONFIG_DIR = path.join(os.homedir(), '.goki-dev')
|
|
9
|
+
const INDEX_FILE = 'secrets-index.json'
|
|
10
|
+
const INDEX_PATH = path.join(CONFIG_DIR, INDEX_FILE)
|
|
11
|
+
|
|
12
|
+
export class SecretsManager {
|
|
13
|
+
constructor ({ projectDir, projectName, configDir }) {
|
|
14
|
+
this._projectDir = projectDir || null
|
|
15
|
+
this._projectName = projectName || null
|
|
16
|
+
this._configDir = configDir || CONFIG_DIR
|
|
17
|
+
this._cache = new Map()
|
|
18
|
+
this._unlocked = false
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static async create (options = {}) {
|
|
22
|
+
const startDir = options.projectDir || process.cwd()
|
|
23
|
+
const detected = SecretsManager.detectProject(startDir)
|
|
24
|
+
return new SecretsManager({
|
|
25
|
+
projectDir: detected?.dir || null,
|
|
26
|
+
projectName: detected?.name || null,
|
|
27
|
+
configDir: CONFIG_DIR
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async unlock () {
|
|
32
|
+
const prefs = BiometricAuth.loadPreferences()
|
|
33
|
+
const auth = new BiometricAuth(prefs)
|
|
34
|
+
await auth.authenticate()
|
|
35
|
+
const index = this._readIndex()
|
|
36
|
+
for (const entry of index.secrets) {
|
|
37
|
+
// Only load global secrets and secrets for the current project
|
|
38
|
+
if (entry.scope === 'project' && entry.project !== this._projectName) continue
|
|
39
|
+
const accountKey = this._buildAccountKey(entry.key, entry.scope, entry.project)
|
|
40
|
+
try {
|
|
41
|
+
const value = await keyring.getPassword(SERVICE_NAME, accountKey)
|
|
42
|
+
if (value !== null && value !== undefined) {
|
|
43
|
+
this._cache.set(accountKey, value)
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
// Secret may have been removed from keychain outside this tool
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
this._unlocked = true
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get projectName () {
|
|
53
|
+
return this._projectName
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get projectDir () {
|
|
57
|
+
return this._projectDir
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async set (key, value, options = {}) {
|
|
61
|
+
const scope = this._resolveScope(options.scope)
|
|
62
|
+
const project = scope === 'project' ? this._projectName : null
|
|
63
|
+
if (scope === 'project' && !project) {
|
|
64
|
+
throw new Error('Cannot set project-scoped secret: no project detected')
|
|
65
|
+
}
|
|
66
|
+
const accountKey = this._buildAccountKey(key, scope, project)
|
|
67
|
+
await keyring.setPassword(SERVICE_NAME, accountKey, value)
|
|
68
|
+
this._cache.set(accountKey, value)
|
|
69
|
+
this._updateIndexEntry(key, scope, project, options.description)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get (key) {
|
|
73
|
+
if (this._projectName) {
|
|
74
|
+
const projectKey = this._buildAccountKey(key, 'project', this._projectName)
|
|
75
|
+
if (this._cache.has(projectKey)) {
|
|
76
|
+
return this._cache.get(projectKey)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const globalKey = this._buildAccountKey(key, 'global', null)
|
|
80
|
+
if (this._cache.has(globalKey)) {
|
|
81
|
+
return this._cache.get(globalKey)
|
|
82
|
+
}
|
|
83
|
+
return undefined
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async delete (key, options = {}) {
|
|
87
|
+
const scope = this._resolveScope(options.scope)
|
|
88
|
+
const project = scope === 'project' ? this._projectName : null
|
|
89
|
+
if (scope === 'project' && !project) {
|
|
90
|
+
throw new Error('Cannot delete project-scoped secret: no project detected')
|
|
91
|
+
}
|
|
92
|
+
const accountKey = this._buildAccountKey(key, scope, project)
|
|
93
|
+
try {
|
|
94
|
+
await keyring.deletePassword(SERVICE_NAME, accountKey)
|
|
95
|
+
} catch {
|
|
96
|
+
// Already deleted or never existed
|
|
97
|
+
}
|
|
98
|
+
this._cache.delete(accountKey)
|
|
99
|
+
this._removeIndexEntry(key, scope, project)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
list (options = {}) {
|
|
103
|
+
const index = this._readIndex()
|
|
104
|
+
if (options.scope) {
|
|
105
|
+
return index.secrets.filter(entry => {
|
|
106
|
+
if (entry.scope !== options.scope) return false
|
|
107
|
+
if (entry.scope === 'project' && entry.project !== this._projectName) return false
|
|
108
|
+
return true
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
return index.secrets.filter(entry => {
|
|
112
|
+
if (entry.scope === 'global') return true
|
|
113
|
+
if (entry.scope === 'project' && entry.project === this._projectName) return true
|
|
114
|
+
return false
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getEnvMap () {
|
|
119
|
+
const env = {}
|
|
120
|
+
const index = this._readIndex()
|
|
121
|
+
for (const entry of index.secrets) {
|
|
122
|
+
if (entry.scope !== 'global') continue
|
|
123
|
+
const accountKey = this._buildAccountKey(entry.key, 'global', null)
|
|
124
|
+
if (this._cache.has(accountKey)) {
|
|
125
|
+
env[entry.key] = this._cache.get(accountKey)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (this._projectName) {
|
|
129
|
+
for (const entry of index.secrets) {
|
|
130
|
+
if (entry.scope !== 'project' || entry.project !== this._projectName) continue
|
|
131
|
+
const accountKey = this._buildAccountKey(entry.key, 'project', entry.project)
|
|
132
|
+
if (this._cache.has(accountKey)) {
|
|
133
|
+
env[entry.key] = this._cache.get(accountKey)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return env
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
getGlobalSecrets () {
|
|
141
|
+
const env = {}
|
|
142
|
+
const index = this._readIndex()
|
|
143
|
+
for (const entry of index.secrets) {
|
|
144
|
+
if (entry.scope !== 'global') continue
|
|
145
|
+
const accountKey = this._buildAccountKey(entry.key, 'global', null)
|
|
146
|
+
if (this._cache.has(accountKey)) {
|
|
147
|
+
env[entry.key] = this._cache.get(accountKey)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return env
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static detectProject (startDir) {
|
|
154
|
+
let dir = path.resolve(startDir)
|
|
155
|
+
const root = path.parse(dir).root
|
|
156
|
+
while (dir !== root) {
|
|
157
|
+
const pkgPath = path.join(dir, 'package.json')
|
|
158
|
+
if (fs.existsSync(pkgPath)) {
|
|
159
|
+
try {
|
|
160
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
161
|
+
if (pkg.name) {
|
|
162
|
+
const name = pkg.name.replace(/^@[^/]+\//, '')
|
|
163
|
+
return { name, dir, source: 'package.json' }
|
|
164
|
+
}
|
|
165
|
+
} catch {
|
|
166
|
+
// Malformed package.json, skip
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const configPath = path.join(dir, '.dev-tools', 'config.js')
|
|
170
|
+
if (fs.existsSync(configPath)) {
|
|
171
|
+
try {
|
|
172
|
+
const content = fs.readFileSync(configPath, 'utf-8')
|
|
173
|
+
const nameMatch = content.match(/name\s*:\s*['"]([^'"]+)['"]/)
|
|
174
|
+
if (nameMatch) {
|
|
175
|
+
return { name: nameMatch[1], dir, source: '.dev-tools/config.js' }
|
|
176
|
+
}
|
|
177
|
+
} catch {
|
|
178
|
+
// Skip
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
dir = path.dirname(dir)
|
|
182
|
+
}
|
|
183
|
+
return null
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
loadSecretsConfig (configDir) {
|
|
187
|
+
const configPath = path.join(configDir || this._projectDir, '.dev-tools', 'config.js')
|
|
188
|
+
if (!fs.existsSync(configPath)) return null
|
|
189
|
+
try {
|
|
190
|
+
// Note: dynamic import must be awaited by caller
|
|
191
|
+
return import(configPath).then(m => m.default?.secrets || null)
|
|
192
|
+
} catch {
|
|
193
|
+
return null
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_resolveScope (explicitScope) {
|
|
198
|
+
if (explicitScope) return explicitScope
|
|
199
|
+
return this._projectName ? 'project' : 'global'
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
_buildAccountKey (key, scope, project) {
|
|
203
|
+
if (scope === 'project') {
|
|
204
|
+
return `project:${project}:${key}`
|
|
205
|
+
}
|
|
206
|
+
return `global:${key}`
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_readIndex () {
|
|
210
|
+
if (!fs.existsSync(INDEX_PATH)) {
|
|
211
|
+
return { version: 1, secrets: [] }
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const content = fs.readFileSync(INDEX_PATH, 'utf-8')
|
|
215
|
+
return JSON.parse(content)
|
|
216
|
+
} catch {
|
|
217
|
+
return { version: 1, secrets: [] }
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
_writeIndex (index) {
|
|
222
|
+
fs.mkdirSync(this._configDir, { recursive: true })
|
|
223
|
+
fs.writeFileSync(INDEX_PATH, JSON.stringify(index, null, 2) + '\n')
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
_updateIndexEntry (key, scope, project, description) {
|
|
227
|
+
const index = this._readIndex()
|
|
228
|
+
const now = new Date().toISOString()
|
|
229
|
+
const existing = index.secrets.find(
|
|
230
|
+
e => e.key === key && e.scope === scope && e.project === (project || null)
|
|
231
|
+
)
|
|
232
|
+
if (existing) {
|
|
233
|
+
existing.updatedAt = now
|
|
234
|
+
if (description !== undefined) existing.description = description
|
|
235
|
+
} else {
|
|
236
|
+
index.secrets.push({
|
|
237
|
+
key,
|
|
238
|
+
scope,
|
|
239
|
+
project: project || null,
|
|
240
|
+
description: description || null,
|
|
241
|
+
createdAt: now,
|
|
242
|
+
updatedAt: now
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
this._writeIndex(index)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_removeIndexEntry (key, scope, project) {
|
|
249
|
+
const index = this._readIndex()
|
|
250
|
+
index.secrets = index.secrets.filter(
|
|
251
|
+
e => !(e.key === key && e.scope === scope && e.project === (project || null))
|
|
252
|
+
)
|
|
253
|
+
this._writeIndex(index)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,332 @@
|
|
|
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 DevToolsClient {
|
|
318
|
+
private client;
|
|
319
|
+
private baseUrl;
|
|
320
|
+
pubsub: PubSubClient;
|
|
321
|
+
logging: LoggingClient;
|
|
322
|
+
postgres: PostgresClient;
|
|
323
|
+
redis: RedisClient;
|
|
324
|
+
firestore: FirestoreClient;
|
|
325
|
+
mqtt: MqttClient;
|
|
326
|
+
docker: DockerClient;
|
|
327
|
+
platform: PlatformClient;
|
|
328
|
+
scheduler: SchedulerClient;
|
|
329
|
+
constructor(config?: DevToolsClientConfig);
|
|
330
|
+
generateTraceId(prefix?: string): string;
|
|
331
|
+
}
|
|
332
|
+
export * from './types';
|