@fugood/bricks-project 2.23.0 → 2.23.3
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/compile/action-name-map.ts +26 -0
- package/compile/index.ts +353 -130
- package/package.json +6 -4
- package/skills/bricks-project/rules/automations.md +74 -28
- package/tools/deploy.ts +39 -10
- package/tools/mcp-server.ts +21 -13
- package/tools/postinstall.ts +53 -6
- package/tools/preview-main.mjs +8 -7
- package/tools/preview.ts +1 -1
- package/tsconfig.json +16 -0
- package/types/bricks/Camera.ts +1 -1
- package/types/bricks/Chart.ts +1 -1
- package/types/bricks/GenerativeMedia.ts +1 -1
- package/types/bricks/Icon.ts +1 -1
- package/types/bricks/Image.ts +1 -1
- package/types/bricks/Items.ts +1 -1
- package/types/bricks/Lottie.ts +1 -1
- package/types/bricks/Maps.ts +1 -1
- package/types/bricks/QrCode.ts +1 -1
- package/types/bricks/Rect.ts +1 -1
- package/types/bricks/RichText.ts +1 -1
- package/types/bricks/Rive.ts +1 -1
- package/types/bricks/Slideshow.ts +1 -1
- package/types/bricks/Svg.ts +1 -1
- package/types/bricks/Text.ts +1 -1
- package/types/bricks/TextInput.ts +1 -1
- package/types/bricks/Video.ts +1 -1
- package/types/bricks/VideoStreaming.ts +1 -1
- package/types/bricks/WebRtcStream.ts +1 -1
- package/types/bricks/WebView.ts +1 -1
- package/types/canvas.ts +2 -2
- package/types/common.ts +4 -4
- package/types/generators/AlarmClock.ts +1 -1
- package/types/generators/Assistant.ts +1 -1
- package/types/generators/BleCentral.ts +1 -1
- package/types/generators/BlePeripheral.ts +1 -1
- package/types/generators/CanvasMap.ts +1 -1
- package/types/generators/CastlesPay.ts +1 -1
- package/types/generators/DataBank.ts +1 -1
- package/types/generators/File.ts +1 -1
- package/types/generators/GraphQl.ts +1 -1
- package/types/generators/Http.ts +1 -1
- package/types/generators/HttpServer.ts +1 -1
- package/types/generators/Information.ts +1 -1
- package/types/generators/Intent.ts +1 -1
- package/types/generators/Iterator.ts +1 -1
- package/types/generators/Keyboard.ts +1 -1
- package/types/generators/LlmAnthropicCompat.ts +1 -1
- package/types/generators/LlmAppleBuiltin.ts +1 -1
- package/types/generators/LlmGgml.ts +1 -1
- package/types/generators/LlmOnnx.ts +1 -1
- package/types/generators/LlmOpenAiCompat.ts +1 -1
- package/types/generators/LlmQualcommAiEngine.ts +1 -1
- package/types/generators/Mcp.ts +1 -1
- package/types/generators/McpServer.ts +1 -1
- package/types/generators/MediaFlow.ts +1 -1
- package/types/generators/MqttBroker.ts +1 -1
- package/types/generators/MqttClient.ts +1 -1
- package/types/generators/Question.ts +1 -1
- package/types/generators/RealtimeTranscription.ts +15 -7
- package/types/generators/RerankerGgml.ts +1 -1
- package/types/generators/SerialPort.ts +1 -1
- package/types/generators/SoundPlayer.ts +1 -1
- package/types/generators/SoundRecorder.ts +1 -1
- package/types/generators/SpeechToTextGgml.ts +6 -1
- package/types/generators/SpeechToTextOnnx.ts +1 -1
- package/types/generators/SpeechToTextPlatform.ts +1 -1
- package/types/generators/SqLite.ts +1 -1
- package/types/generators/Step.ts +1 -1
- package/types/generators/SttAppleBuiltin.ts +1 -1
- package/types/generators/Tcp.ts +1 -1
- package/types/generators/TcpServer.ts +1 -1
- package/types/generators/TextToSpeechAppleBuiltin.ts +1 -1
- package/types/generators/TextToSpeechGgml.ts +1 -1
- package/types/generators/TextToSpeechOnnx.ts +1 -1
- package/types/generators/TextToSpeechOpenAiLike.ts +1 -1
- package/types/generators/ThermalPrinter.ts +1 -1
- package/types/generators/Tick.ts +1 -1
- package/types/generators/Udp.ts +1 -1
- package/types/generators/VadGgml.ts +1 -1
- package/types/generators/VadOnnx.ts +201 -0
- package/types/generators/VadTraditional.ts +123 -0
- package/types/generators/VectorStore.ts +1 -1
- package/types/generators/Watchdog.ts +1 -1
- package/types/generators/WebCrawler.ts +1 -1
- package/types/generators/WebRtc.ts +1 -1
- package/types/generators/WebSocket.ts +1 -1
- package/types/generators/index.ts +2 -0
- package/utils/calc.ts +16 -8
- package/utils/event-props.ts +27 -0
- package/utils/id.ts +4 -0
- package/api/index.ts +0 -1
- package/api/instance.ts +0 -213
package/api/instance.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
const apiUrlMap = {
|
|
2
|
-
production: 'https://display.bricks.tools/api/graphql-workspace',
|
|
3
|
-
beta: 'https://display-beta.bricks.tools/api/graphql-workspace',
|
|
4
|
-
development: 'http://localhost:3001/api/graphql-workspace',
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const workspaceToken = process.env.BRICKS_WORKSPACE_TOKEN
|
|
8
|
-
|
|
9
|
-
type Stage = 'production' | 'beta' | 'development'
|
|
10
|
-
|
|
11
|
-
const doGQL = async (stage: Stage, query: string, variables: Record<string, any>) => {
|
|
12
|
-
if (!workspaceToken) throw new Error('env BRICKS_WORKSPACE_TOKEN is not set')
|
|
13
|
-
|
|
14
|
-
const apiURL = apiUrlMap[stage]
|
|
15
|
-
if (!apiURL) throw new Error(`Invalid stage: ${stage}`)
|
|
16
|
-
|
|
17
|
-
const data = await fetch(apiURL, {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
headers: {
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
Authorization: `Bearer ${workspaceToken}`,
|
|
22
|
-
},
|
|
23
|
-
body: JSON.stringify({ query, variables }),
|
|
24
|
-
}).then((res) => res.json())
|
|
25
|
-
|
|
26
|
-
if (data.error && data.error.message) throw new Error(data.error.message)
|
|
27
|
-
return data
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const pullApp = async (stage: Stage, appId: string) => {
|
|
31
|
-
const { data, errors } = await doGQL(
|
|
32
|
-
stage,
|
|
33
|
-
`query BRICKS_PROJECT_application($id: ID!) {
|
|
34
|
-
application(id: $id) {
|
|
35
|
-
_id
|
|
36
|
-
name
|
|
37
|
-
description
|
|
38
|
-
config
|
|
39
|
-
lock {
|
|
40
|
-
enabled
|
|
41
|
-
}
|
|
42
|
-
dev_ref {
|
|
43
|
-
is_dev
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}`,
|
|
47
|
-
{ id: appId },
|
|
48
|
-
)
|
|
49
|
-
if (errors) throw new Error(errors[0].message)
|
|
50
|
-
|
|
51
|
-
const app = data.application
|
|
52
|
-
if (!app) throw new Error('App not found')
|
|
53
|
-
if (app.lock.enabled) throw new Error('App is locked')
|
|
54
|
-
// TODO: Uncomment it on leaving experimental
|
|
55
|
-
// if (!app.dev_ref.is_dev)
|
|
56
|
-
// throw new Error(
|
|
57
|
-
// 'Currently BRICKS Project is experimental, please use the fork version of the app',
|
|
58
|
-
// )
|
|
59
|
-
return app
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type Config = { title?: string }
|
|
63
|
-
|
|
64
|
-
export const deployApp = async (
|
|
65
|
-
stage: Stage,
|
|
66
|
-
appId: string,
|
|
67
|
-
config: Config,
|
|
68
|
-
lastCommitId?: string,
|
|
69
|
-
changelogs?: string,
|
|
70
|
-
version?: string,
|
|
71
|
-
) => {
|
|
72
|
-
const app = await pullApp(stage, appId)
|
|
73
|
-
if (app.config?.bricks_project_last_commit_id === lastCommitId)
|
|
74
|
-
throw new Error('No changes to deploy')
|
|
75
|
-
|
|
76
|
-
const versionName = version || app.name || 'Untitled'
|
|
77
|
-
const releaseNote = changelogs
|
|
78
|
-
? `${changelogs}\n\nRelease by BRICKS Project`
|
|
79
|
-
: 'Release by BRICKS Project'
|
|
80
|
-
|
|
81
|
-
const { errors } = await doGQL(
|
|
82
|
-
stage,
|
|
83
|
-
`mutation BRICKS_PROJECT_releaseApplication(
|
|
84
|
-
$id: ID!,
|
|
85
|
-
$config: String,
|
|
86
|
-
$releaseCurrentVersion: String,
|
|
87
|
-
$releaseCurrentVersionNote: String
|
|
88
|
-
) {
|
|
89
|
-
updateApplication(
|
|
90
|
-
id: $id,
|
|
91
|
-
config: $config,
|
|
92
|
-
releaseCurrentVersion: $releaseCurrentVersion,
|
|
93
|
-
releaseCurrentVersionNote: $releaseCurrentVersionNote
|
|
94
|
-
) {
|
|
95
|
-
_id
|
|
96
|
-
name
|
|
97
|
-
}
|
|
98
|
-
}`,
|
|
99
|
-
{
|
|
100
|
-
id: appId,
|
|
101
|
-
config: JSON.stringify({
|
|
102
|
-
...config,
|
|
103
|
-
title: versionName,
|
|
104
|
-
bricks_project_last_commit_id: lastCommitId,
|
|
105
|
-
}),
|
|
106
|
-
releaseCurrentVersion: versionName,
|
|
107
|
-
releaseCurrentVersionNote: releaseNote,
|
|
108
|
-
},
|
|
109
|
-
)
|
|
110
|
-
if (errors) throw new Error(errors[0].message)
|
|
111
|
-
return true
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const pullApplicationProject = async (stage: Stage, appId: string) => {
|
|
115
|
-
const { data, errors } = await doGQL(
|
|
116
|
-
stage,
|
|
117
|
-
`query BRICKS_PROJECT_applicationProject($id: ID!) {
|
|
118
|
-
UNSTABLE_applicationProject(id: $id, buildApplicationOnly: true)
|
|
119
|
-
}`,
|
|
120
|
-
{ id: appId },
|
|
121
|
-
)
|
|
122
|
-
if (errors) throw new Error(errors[0].message)
|
|
123
|
-
if (!data.UNSTABLE_applicationProject) throw new Error('Application not found')
|
|
124
|
-
return data.UNSTABLE_applicationProject
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export const pullModule = async (stage: Stage, modId: string) => {
|
|
128
|
-
const { data, errors } = await doGQL(
|
|
129
|
-
stage,
|
|
130
|
-
`query BRICKS_PROJECT_module($id: ID!) {
|
|
131
|
-
module(id: $id) {
|
|
132
|
-
_id
|
|
133
|
-
name
|
|
134
|
-
description
|
|
135
|
-
is_public
|
|
136
|
-
config
|
|
137
|
-
}
|
|
138
|
-
}`,
|
|
139
|
-
{ id: modId },
|
|
140
|
-
)
|
|
141
|
-
if (errors) throw new Error(errors[0].message)
|
|
142
|
-
const mod = data.module
|
|
143
|
-
if (!mod) throw new Error('Module not found')
|
|
144
|
-
if (mod.is_public)
|
|
145
|
-
throw new Error(
|
|
146
|
-
'Currently BRICKS Project is experimental, public module deployment is temporary not recommended',
|
|
147
|
-
)
|
|
148
|
-
return mod
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export const deployModule = async (
|
|
152
|
-
stage: Stage,
|
|
153
|
-
modId: string,
|
|
154
|
-
config: Config,
|
|
155
|
-
lastCommitId?: string,
|
|
156
|
-
changelogs?: string,
|
|
157
|
-
version?: string,
|
|
158
|
-
) => {
|
|
159
|
-
const mod = await pullModule(stage, modId)
|
|
160
|
-
if (mod.config?.bricks_project_last_commit_id === lastCommitId)
|
|
161
|
-
throw new Error('No changes to deploy')
|
|
162
|
-
|
|
163
|
-
const versionName = version || mod.name || 'Untitled'
|
|
164
|
-
const releaseNote = changelogs
|
|
165
|
-
? `${changelogs}\n\nRelease by BRICKS Project`
|
|
166
|
-
: 'Release by BRICKS Project'
|
|
167
|
-
|
|
168
|
-
const { errors } = await doGQL(
|
|
169
|
-
stage,
|
|
170
|
-
`mutation BRICKS_PROJECT_releaseModule(
|
|
171
|
-
$id: ID!,
|
|
172
|
-
$config: String,
|
|
173
|
-
$releaseCurrentVersion: String,
|
|
174
|
-
$releaseCurrentVersionNote: String
|
|
175
|
-
) {
|
|
176
|
-
updateModule(
|
|
177
|
-
id: $id
|
|
178
|
-
config: $config
|
|
179
|
-
validateConfig: true
|
|
180
|
-
releaseCurrentVersion: $releaseCurrentVersion
|
|
181
|
-
releaseCurrentVersionNote: $releaseCurrentVersionNote
|
|
182
|
-
) {
|
|
183
|
-
_id
|
|
184
|
-
name
|
|
185
|
-
}
|
|
186
|
-
}`,
|
|
187
|
-
{
|
|
188
|
-
id: modId,
|
|
189
|
-
config: JSON.stringify({
|
|
190
|
-
...config,
|
|
191
|
-
title: versionName,
|
|
192
|
-
bricks_project_last_commit_id: lastCommitId,
|
|
193
|
-
}),
|
|
194
|
-
releaseCurrentVersion: versionName,
|
|
195
|
-
releaseCurrentVersionNote: releaseNote,
|
|
196
|
-
},
|
|
197
|
-
)
|
|
198
|
-
if (errors) throw new Error(errors[0].message)
|
|
199
|
-
return true
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export const pullModuleProject = async (stage: Stage, modId: string) => {
|
|
203
|
-
const { data, errors } = await doGQL(
|
|
204
|
-
stage,
|
|
205
|
-
`query BRICKS_PROJECT_moduleProject($id: ID!) {
|
|
206
|
-
UNSTABLE_moduleProject(id: $id, buildApplicationOnly: true)
|
|
207
|
-
}`,
|
|
208
|
-
{ id: modId },
|
|
209
|
-
)
|
|
210
|
-
if (errors) throw new Error(errors[0].message)
|
|
211
|
-
if (!data.UNSTABLE_moduleProject) throw new Error('Module not found')
|
|
212
|
-
return data.UNSTABLE_moduleProject
|
|
213
|
-
}
|