@lowdefy/build 5.2.0 → 5.4.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/dist/build/buildAgents.js +249 -0
- package/dist/build/buildApi/buildRoutine/countStepTypes.js +1 -1
- package/dist/build/buildApi/buildRoutine/setStepId.js +6 -2
- package/dist/build/buildApi/buildRoutine/validateStep.js +18 -0
- package/dist/build/buildApp.js +18 -5
- package/dist/build/buildImports/buildImportsDev.js +5 -0
- package/dist/build/buildImports/buildImportsProd.js +1 -0
- package/dist/build/buildJs/writeJs.js +2 -2
- package/dist/build/buildMenu.js +5 -0
- package/dist/build/buildModuleDefs.js +52 -1
- package/dist/build/buildModules.js +1 -1
- package/dist/build/buildPages/validateCallApiRefs.js +9 -0
- package/dist/build/buildRefs/getUserJavascriptFunction.js +6 -9
- package/dist/build/buildRefs/runTransformer.js +3 -2
- package/dist/build/buildRefs/walker.js +22 -39
- package/dist/build/buildTypes.js +7 -0
- package/dist/build/codegenI18nLocales.js +53 -0
- package/dist/build/copyAgentFileSystems.js +45 -0
- package/dist/build/full/updateServerPackageJson.js +1 -0
- package/dist/build/jit/shallowBuild.js +31 -0
- package/dist/build/registerModules.js +11 -33
- package/dist/build/writeAgents.js +26 -0
- package/dist/build/writeAppMeta.js +19 -0
- package/dist/build/writeI18n.js +117 -0
- package/dist/build/writePluginImports/writeAgentImports.js +22 -0
- package/dist/build/writePluginImports/writePluginImports.js +10 -0
- package/dist/build/writePluginImports/writeServerExternalPackages.js +121 -0
- package/dist/createContext.js +8 -1
- package/dist/defaultMessagesMap.js +3 -0
- package/dist/defaultPackages.js +7 -0
- package/dist/defaultTypesMap.js +590 -377
- package/dist/index.js +30 -0
- package/dist/lowdefySchema.js +414 -0
- package/dist/scripts/generateDefaultMessages.js +37 -0
- package/dist/scripts/generateDefaultTypes.js +1 -0
- package/dist/test-utils/testContext.js +2 -0
- package/dist/utils/createPluginTypesMap.js +7 -0
- package/package.json +51 -44
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { createRequire } from 'node:module';
|
|
18
|
+
import { ConfigError } from '@lowdefy/errors';
|
|
19
|
+
// Collect every unique plugin package across all import categories.
|
|
20
|
+
// Mirrors the dependency walk in updateServerPackageJson.js so externalisation
|
|
21
|
+
// covers connections/operators/actions etc., not just blocks.
|
|
22
|
+
function collectPluginPackages(imports) {
|
|
23
|
+
const categories = [
|
|
24
|
+
imports.actions,
|
|
25
|
+
imports.agents,
|
|
26
|
+
imports.auth?.adapters,
|
|
27
|
+
imports.auth?.callbacks,
|
|
28
|
+
imports.auth?.events,
|
|
29
|
+
imports.auth?.providers,
|
|
30
|
+
imports.blocks,
|
|
31
|
+
imports.connections,
|
|
32
|
+
imports.icons,
|
|
33
|
+
imports.requests,
|
|
34
|
+
imports.operators?.client,
|
|
35
|
+
imports.operators?.server
|
|
36
|
+
];
|
|
37
|
+
const packages = new Set();
|
|
38
|
+
for (const list of categories){
|
|
39
|
+
if (!Array.isArray(list)) continue;
|
|
40
|
+
for (const item of list){
|
|
41
|
+
if (item?.package) packages.add(item.package);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return packages;
|
|
45
|
+
}
|
|
46
|
+
// Direct resolve of `${pkg}/package.json` fails for plugins whose exports map
|
|
47
|
+
// uses a catch-all like `"./*": "./dist/*"` (e.g. blocks-tiptap, plugin-aws),
|
|
48
|
+
// because it routes the request into `./dist/package.json`. Fall back to
|
|
49
|
+
// resolving a known subpath and walking up to the real package root.
|
|
50
|
+
function findPluginPackageJson({ requireFromServer, pkg }) {
|
|
51
|
+
try {
|
|
52
|
+
const direct = requireFromServer.resolve(`${pkg}/package.json`);
|
|
53
|
+
const json = JSON.parse(fs.readFileSync(direct, 'utf8'));
|
|
54
|
+
if (json.name === pkg) return json;
|
|
55
|
+
} catch {
|
|
56
|
+
// Fall through to walk-up resolution.
|
|
57
|
+
}
|
|
58
|
+
const subpaths = [
|
|
59
|
+
'types',
|
|
60
|
+
'metas',
|
|
61
|
+
'blocks',
|
|
62
|
+
'connections'
|
|
63
|
+
];
|
|
64
|
+
for (const sub of subpaths){
|
|
65
|
+
let entry;
|
|
66
|
+
try {
|
|
67
|
+
entry = requireFromServer.resolve(`${pkg}/${sub}`);
|
|
68
|
+
} catch {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
let dir = path.dirname(entry);
|
|
72
|
+
const root = path.parse(dir).root;
|
|
73
|
+
while(dir !== root){
|
|
74
|
+
const candidate = path.join(dir, 'package.json');
|
|
75
|
+
if (fs.existsSync(candidate)) {
|
|
76
|
+
try {
|
|
77
|
+
const json = JSON.parse(fs.readFileSync(candidate, 'utf8'));
|
|
78
|
+
if (json.name === pkg) return json;
|
|
79
|
+
} catch {
|
|
80
|
+
// Malformed package.json — try the next ancestor.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
dir = path.dirname(dir);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
async function writeServerExternalPackages({ components, context }) {
|
|
89
|
+
const requireFromServer = createRequire(path.join(context.directories.server, 'package.json'));
|
|
90
|
+
const pluginPackages = collectPluginPackages(components.imports ?? {});
|
|
91
|
+
// Track which plugin contributed each external so error messages can name them.
|
|
92
|
+
const externalToPlugins = new Map();
|
|
93
|
+
for (const pkg of pluginPackages){
|
|
94
|
+
const pluginPkgJson = findPluginPackageJson({
|
|
95
|
+
requireFromServer,
|
|
96
|
+
pkg
|
|
97
|
+
});
|
|
98
|
+
const list = pluginPkgJson?.lowdefy?.serverExternalPackages;
|
|
99
|
+
if (!Array.isArray(list)) continue;
|
|
100
|
+
for (const external of list){
|
|
101
|
+
if (!externalToPlugins.has(external)) {
|
|
102
|
+
externalToPlugins.set(external, []);
|
|
103
|
+
}
|
|
104
|
+
externalToPlugins.get(external).push(pkg);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Next.js rejects entries that are also in transpilePackages. Block packages
|
|
108
|
+
// are always transpiled, so a plugin externalising one would silently break
|
|
109
|
+
// the build at next start — fail early with a pointer to the offender.
|
|
110
|
+
const transpiledBlockPackages = new Set((components.imports?.blocks ?? []).map((b)=>b.package));
|
|
111
|
+
for (const [external, plugins] of externalToPlugins){
|
|
112
|
+
if (transpiledBlockPackages.has(external)) {
|
|
113
|
+
throw new ConfigError(`Plugin "${plugins.join('", "')}" declared serverExternalPackages entry "${external}", which is also a transpiled block package. A package cannot be both transpiled and externalised.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const sorted = [
|
|
117
|
+
...externalToPlugins.keys()
|
|
118
|
+
].sort();
|
|
119
|
+
await context.writeBuildArtifact('serverExternalPackages.json', JSON.stringify(sorted));
|
|
120
|
+
}
|
|
121
|
+
export default writeServerExternalPackages;
|
package/dist/createContext.js
CHANGED
|
@@ -18,11 +18,13 @@ import createCounter from './utils/createCounter.js';
|
|
|
18
18
|
import createHandleWarning from './utils/createHandleWarning.js';
|
|
19
19
|
import createReadConfigFile from './utils/readConfigFile.js';
|
|
20
20
|
import createWriteBuildArtifact from './utils/writeBuildArtifact.js';
|
|
21
|
+
import defaultMessagesMap from './defaultMessagesMap.js';
|
|
21
22
|
import defaultPackages from './defaultPackages.js';
|
|
22
23
|
import defaultTypesMap from './defaultTypesMap.js';
|
|
23
|
-
function createContext({ customTypesMap, directories, logger, refResolver, stage = 'prod' }) {
|
|
24
|
+
function createContext({ customMessagesMap, customTypesMap, directories, logger, refResolver, stage = 'prod' }) {
|
|
24
25
|
const context = {
|
|
25
26
|
defaultPackageNames: new Set(defaultPackages),
|
|
27
|
+
agentIds: new Set(),
|
|
26
28
|
connectionIds: new Set(),
|
|
27
29
|
directories,
|
|
28
30
|
errors: [],
|
|
@@ -42,6 +44,7 @@ function createContext({ customTypesMap, directories, logger, refResolver, stage
|
|
|
42
44
|
stage,
|
|
43
45
|
typeCounters: {
|
|
44
46
|
actions: createCounter(),
|
|
47
|
+
agents: createCounter(),
|
|
45
48
|
auth: {
|
|
46
49
|
adapters: createCounter(),
|
|
47
50
|
callbacks: createCounter(),
|
|
@@ -61,6 +64,10 @@ function createContext({ customTypesMap, directories, logger, refResolver, stage
|
|
|
61
64
|
defaultTypesMap,
|
|
62
65
|
customTypesMap
|
|
63
66
|
]),
|
|
67
|
+
messagesMap: mergeObjects([
|
|
68
|
+
defaultMessagesMap,
|
|
69
|
+
customMessagesMap
|
|
70
|
+
]),
|
|
64
71
|
writeBuildArtifact: createWriteBuildArtifact({
|
|
65
72
|
directories
|
|
66
73
|
})
|
package/dist/defaultPackages.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
'@lowdefy/actions-pdf-make',
|
|
18
18
|
'@lowdefy/blocks-aggrid',
|
|
19
19
|
'@lowdefy/blocks-antd',
|
|
20
|
+
'@lowdefy/blocks-antd-x',
|
|
20
21
|
'@lowdefy/blocks-basic',
|
|
21
22
|
'@lowdefy/blocks-diff',
|
|
22
23
|
'@lowdefy/blocks-echarts',
|
|
@@ -25,7 +26,13 @@
|
|
|
25
26
|
'@lowdefy/blocks-markdown',
|
|
26
27
|
'@lowdefy/blocks-qr',
|
|
27
28
|
'@lowdefy/blocks-tiptap',
|
|
29
|
+
'@lowdefy/ai-utils',
|
|
30
|
+
'@lowdefy/connection-ai-gateway',
|
|
31
|
+
'@lowdefy/connection-anthropic',
|
|
28
32
|
'@lowdefy/connection-axios-http',
|
|
33
|
+
'@lowdefy/connection-google',
|
|
34
|
+
'@lowdefy/connection-mcp',
|
|
35
|
+
'@lowdefy/connection-openai',
|
|
29
36
|
'@lowdefy/connection-elasticsearch',
|
|
30
37
|
'@lowdefy/connection-test',
|
|
31
38
|
'@lowdefy/connection-google-sheets',
|