openyida 2026.11.16 → 2026.11.18-1
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 +17 -2
- package/bin/yida.js +23 -2
- package/lib/app/app-list.js +2 -1
- package/lib/app/check-prd-completeness.js +99 -14
- package/lib/app/create-page.js +62 -13
- package/lib/app/datav-designer.js +179 -0
- package/lib/app/datav.js +228 -0
- package/lib/app/fast-build.js +2 -2
- package/lib/app/portal-schema.js +431 -0
- package/lib/app/portal.js +165 -0
- package/lib/app/update-app.js +212 -41
- package/lib/connector/action-generator.js +8 -14
- package/lib/connector/api.js +3 -1
- package/lib/connector/connector-action-update.js +12 -3
- package/lib/connector/connector-add-action.js +2 -0
- package/lib/connector/connector-create-connection.js +152 -2
- package/lib/connector/connector-create.js +1 -0
- package/lib/connector/connector-delete-action.js +1 -1
- package/lib/connector/connector-delete.js +2 -1
- package/lib/connector/contract.js +26 -6
- package/lib/connector/doc-parser.js +3 -53
- package/lib/connector/operation-normalizer.js +16 -6
- package/lib/connector/response-parser.js +35 -0
- package/lib/core/agent-capabilities.js +4 -0
- package/lib/core/command-manifest.js +172 -5
- package/lib/core/form-edit-permissions.js +3 -1
- package/lib/core/locales/en.js +51 -6
- package/lib/core/locales/zh.js +51 -6
- package/lib/core/query-data.js +140 -9
- package/lib/core/redact.js +31 -2
- package/lib/design-plan/entry-navigation.js +14 -5
- package/lib/design-plan/init.js +1 -1
- package/lib/design-plan/materialize.js +8 -5
- package/lib/design-plan/render-html.js +1 -1
- package/lib/integration/connector-presets.js +36 -12
- package/lib/integration/integration-create.js +1 -0
- package/lib/integration/integration-process-builder.js +132 -4
- package/lib/integration/integration-readback.js +22 -0
- package/lib/integration/integration-spec-builder.js +2 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +3 -1
- package/yida-skills/SKILL.md +6 -3
- package/yida-skills/skills/yida-app/SKILL.md +4 -1
- package/yida-skills/skills/yida-app/references/entry-navigation.md +1 -1
- package/yida-skills/skills/yida-app/workflow/fast-build.md +15 -5
- package/yida-skills/skills/yida-app/workflow/plan/workflow.md +1 -1
- package/yida-skills/skills/yida-app/workflow/step-6-main-page.md +4 -0
- package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +2 -0
- package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +8 -12
- package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +12 -4
- package/yida-skills/skills/yida-canvas-custom-page/references/navigation-and-entry-guide.md +3 -0
- package/yida-skills/skills/yida-connector/SKILL.md +15 -5
- package/yida-skills/skills/yida-connector/references/connector-action-format.md +11 -3
- package/yida-skills/skills/yida-create-app/SKILL.md +8 -0
- package/yida-skills/skills/yida-create-page/SKILL.md +8 -7
- package/yida-skills/skills/yida-create-portal/SKILL.md +20 -0
- package/yida-skills/skills/yida-create-portal/references/native-portal.md +67 -0
- package/yida-skills/skills/yida-dashboard/SKILL.md +9 -2
- package/yida-skills/skills/yida-dashboard/references/structure-and-layout.md +6 -0
- package/yida-skills/skills/yida-dashboard/references/theme-presets.md +8 -0
- package/yida-skills/skills/yida-data-management/SKILL.md +7 -3
- package/yida-skills/skills/yida-datav/SKILL.md +81 -0
- package/yida-skills/skills/yida-datav/references/components-and-configuration.md +187 -0
- package/yida-skills/skills/yida-design/references/theme-selection.md +12 -0
- package/yida-skills/skills/yida-flow-node-config/references/extensions.md +23 -0
- package/yida-skills/skills/yida-integration/SKILL.md +13 -2
- package/yida-skills/skills/yida-integration/references/operations.md +4 -1
- package/yida-skills/skills/yida-integration/references/spec-authoring.md +2 -0
- package/yida-skills/skills/yida-nav-shell/SKILL.md +2 -0
- package/yida-skills/skills/yida-rechart/SKILL.md +19 -11
- package/yida-skills/skills/yida-requirement-analysis/references/experience-groups.md +2 -2
- package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +1 -1
- package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -2
- package/yida-skills/skills-index.json +68 -3
package/README.md
CHANGED
|
@@ -269,6 +269,8 @@ For the current custom page native-component support matrix, see [Yida native co
|
|
|
269
269
|
|
|
270
270
|
### Workflow, Data, and Permissions
|
|
271
271
|
|
|
272
|
+
Historical ordinary-form updates do not request an upgrade by default. Explicitly pass `--use-latest-version y` to request an upgrade; submitted fields and the instance version are then always verified. An ineffective upgrade fails without replaying the write. See [historical record updates](docs/guides/form-version-update.md).
|
|
273
|
+
|
|
272
274
|
```bash
|
|
273
275
|
openyida create-process APP_XXX "Purchase Request" .cache/openyida/process/fields.json .cache/openyida/process/process.json
|
|
274
276
|
openyida configure-process APP_XXX FORM_XXX .cache/openyida/process/process.json
|
|
@@ -547,10 +549,22 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
547
549
|
| `openyida custom-button <list\|inspect\|options\|create\|update\|delete> <appType> <formUuid> [buttonUuid] [--config <file>] [--expected-hash <hash>] [--backup <file>] [--yes] [--json]` | Native custom buttons: inspect and configure form edits, automation flows and page links |
|
|
548
550
|
| `openyida form-message <list\|inspect\|options\|create\|update\|delete> <appType> <formUuid> [messageId] [--config <file>] [--expected-hash <hash>] [--backup <file>] [--yes] [--json]` | Native form notifications: inspect triggers, recipients and templates, then safely maintain bindings |
|
|
549
551
|
| `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json]` | Get one form Schema or all form Schemas |
|
|
550
|
-
| `openyida check-prd-completeness (<prd.md> [--build-manifest <file>] \| --build-spec <build-context.json> [--build-manifest <file>] \| --manifest-only --build-manifest <file>) --app-type <appType> [--json]` | Check resources,
|
|
552
|
+
| `openyida check-prd-completeness (<prd.md> [--build-manifest <file>] \| --build-spec <build-context.json> [--build-manifest <file>] \| --manifest-only --build-manifest <file>) --app-type <appType> [--json]` | Check resources, navigation visibility and application theme |
|
|
551
553
|
| `openyida check-design <design.md> [--prd <prd.md>] [--base-dir <dir>] [--json]` | Validate design documents, theme tokens and PRD handoff |
|
|
552
554
|
| `openyida er <appType> [--format mermaid\|json] [--output file] [--include-system] [--include-pages]` | Export app entity relationship diagram |
|
|
553
|
-
| `openyida create-page <appType> "<name>" [--mode dashboard] [--hide-nav] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a custom
|
|
555
|
+
| `openyida create-page <appType> "<name>" [--mode dashboard] [--hide-nav] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a custom page |
|
|
556
|
+
| `openyida create-portal <appType> "<name>" [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a native YiDA portal |
|
|
557
|
+
| `openyida datav templates <appType> [--page <value>] [--page-size <value>] [--json]` | List native DataV screen templates |
|
|
558
|
+
| `openyida datav create <appType> <name> [--template <value>] [--locale <value>] [--wait-seconds <value>] [--json]` | Create a native YiDA DataV screen |
|
|
559
|
+
| `openyida datav inspect <appType> <formUuid> [--json]` | Inspect native DataV status and URLs |
|
|
560
|
+
| `openyida datav components <appType> <formUuid> [--component <value>] [--category <value>] [--search <value>] [--json]` | List DataV components and parameter definitions |
|
|
561
|
+
| `openyida datav config <appType> <formUuid> [--component <value>] [--json]` | Read DataV canvas and layer configuration |
|
|
562
|
+
| `openyida datav copy <appType> <formUuid> <name> [--locale <value>] [--wait-seconds <value>] [--json]` | Copy a native DataV screen |
|
|
563
|
+
| `openyida datav rename <appType> <formUuid> <name> [--locale <value>] [--json]` | Rename a native DataV screen |
|
|
564
|
+
| `openyida datav publish <appType> <formUuid> --confirm [--json]` | Publish and enable a native DataV screen |
|
|
565
|
+
| `openyida portal catalog [componentName] [--json]` | List configurable native portal components and theme options |
|
|
566
|
+
| `openyida portal inspect <appType> <formUuid> [--editable] [--json]` | Inspect native portal tiles and revision |
|
|
567
|
+
| `openyida portal configure <appType> <formUuid> <file> [--expected-revision <revision>] [--dry-run] [--json]` | Configure native portal tiles and layout |
|
|
554
568
|
| `openyida build-page <sourceFile> [--output file\|--write]` | Build Yida-compatible page source |
|
|
555
569
|
| `openyida check-page <src> [--compat] [--json]` | Check custom page standards |
|
|
556
570
|
| `openyida compile <src> [--canvas] [--compat] [--skip-lint] [--strict-theme\|--allow-fixed-brand] [--json]` | Compile custom page locally |
|
|
@@ -616,6 +630,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
|
|
|
616
630
|
| `openyida connector delete-action <id> <operation-id>` | Delete an action |
|
|
617
631
|
| `openyida connector test --connector-id <id> --action <actionId> [--path-json JSON] [--query-json JSON] [--header-json JSON] [--body-json JSON] [--account-id <id>] [--system-token-app <appType>] [--ignore-defaults]` | Test an action |
|
|
618
632
|
| `openyida connector list-connections <id>` | List auth connections |
|
|
633
|
+
| `openyida connector connection <detail\|update> <connector-id> <connection-id> [--name <name>] [--confirm --interactive] [--json]` | Read account metadata or replace complete credentials using hidden terminal input. |
|
|
619
634
|
| `openyida connector create-connection <id> <name> [--interactive] [--repair-api-key-scheme]` | Create an auth connection |
|
|
620
635
|
| `openyida connector smart-create --curl "..."` | Generate a redacted action draft from cURL (no remote create) |
|
|
621
636
|
| `openyida connector parse-api [options]` | Parse API information |
|
package/bin/yida.js
CHANGED
|
@@ -854,6 +854,24 @@ async function dispatchCommand() {
|
|
|
854
854
|
break;
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
+
case 'create-portal': {
|
|
858
|
+
const { runPortal } = require('../lib/app/create-page');
|
|
859
|
+
await runPortal(args);
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
case 'datav': {
|
|
864
|
+
const { run } = require('../lib/app/datav');
|
|
865
|
+
await run(args);
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
case 'portal': {
|
|
870
|
+
const { run } = require('../lib/app/portal');
|
|
871
|
+
await run(args);
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
|
|
857
875
|
case 'create-form': {
|
|
858
876
|
const { run } = require('../lib/app/create-form');
|
|
859
877
|
await run(args);
|
|
@@ -1238,6 +1256,7 @@ async function dispatchCommand() {
|
|
|
1238
1256
|
'test': '../lib/connector/connector-test',
|
|
1239
1257
|
'list-connections': '../lib/connector/connector-list-connections',
|
|
1240
1258
|
'create-connection': '../lib/connector/connector-create-connection',
|
|
1259
|
+
'connection': '../lib/connector/connector-create-connection',
|
|
1241
1260
|
'smart-create': '../lib/connector/connector-smart-create',
|
|
1242
1261
|
'parse-api': '../lib/connector/connector-parse-api',
|
|
1243
1262
|
'gen-template': '../lib/connector/connector-gen-template',
|
|
@@ -1251,13 +1270,14 @@ async function dispatchCommand() {
|
|
|
1251
1270
|
list 列出 HTTP 连接器
|
|
1252
1271
|
create "名称" "域名" --operations <file> 创建连接器
|
|
1253
1272
|
detail <connector-id> 查看连接器详情
|
|
1254
|
-
delete <connector-id> [--force]
|
|
1273
|
+
delete <connector-id> [--force] ${t('help.cmd_connector_delete')}
|
|
1255
1274
|
add-action --operations <file> --connector-id <id> 添加执行动作
|
|
1256
1275
|
update-action --connector-id <id> --action <id> --query-json <JSON> --confirm 安全更新动作 Query 默认值
|
|
1257
1276
|
list-actions <connector-id> 列出执行动作
|
|
1258
1277
|
delete-action <connector-id> <operation-id> 删除执行动作
|
|
1259
1278
|
test --connector-id <id> --action <actionId> [结构化 JSON 参数] 测试执行动作
|
|
1260
1279
|
list-connections <connector-id> 列出鉴权账号
|
|
1280
|
+
connection <detail|update> <connector-id> <account-id> [--confirm --interactive] 鉴权账号维护
|
|
1261
1281
|
create-connection <connector-id> <name> [--interactive] 创建鉴权账号;钉钉凭据可在本机隐藏输入
|
|
1262
1282
|
smart-create --curl "curl命令" 生成脱敏连接器动作草稿(不创建远端资源)
|
|
1263
1283
|
parse-api [选项] 解析接口信息
|
|
@@ -1273,7 +1293,8 @@ async function dispatchCommand() {
|
|
|
1273
1293
|
throwCliUsage(`未知的 connector 子命令: ${subCommand}`, '使用 openyida connector --help 查看可用子命令');
|
|
1274
1294
|
}
|
|
1275
1295
|
|
|
1276
|
-
const
|
|
1296
|
+
const connectorCommand = require(modulePath);
|
|
1297
|
+
const runConnector = subCommand === 'connection' ? connectorCommand.runConnection : connectorCommand.run;
|
|
1277
1298
|
await runConnector(subArgs);
|
|
1278
1299
|
break;
|
|
1279
1300
|
}
|
package/lib/app/app-list.js
CHANGED
|
@@ -36,8 +36,9 @@ function fetchAppListPage(auth, pageIndex, pageSize, isAdmin) {
|
|
|
36
36
|
_mock: 'false',
|
|
37
37
|
pageIndex,
|
|
38
38
|
pageSize,
|
|
39
|
-
creator: ref.userId,
|
|
40
39
|
isAdmin,
|
|
40
|
+
// 管理权限与创建人是独立条件;仅“我创建的”附加创建人筛选。
|
|
41
|
+
...(isAdmin ? {} : { creator: ref.userId }),
|
|
41
42
|
_stamp: Date.now(),
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const { createAuthRef, isAuthRefReady } = require('../core/yida-client');
|
|
5
|
+
const { createAuthRef, isAuthRefReady, unwrapYidaResponse } = require('../core/yida-client');
|
|
6
6
|
const { t } = require('../core/i18n');
|
|
7
7
|
const { throwCommandError, throwUsage } = require('../core/command-errors');
|
|
8
8
|
const { auditAssetExecution } = require('../asset/asset-execution');
|
|
9
9
|
const { fetchFormPageList } = require('./form-navigation');
|
|
10
|
+
const { fetchFormSchemaInfo } = require('./get-form-config');
|
|
11
|
+
const { buildDisplayPageEntryUrls } = require('./application-entry-urls');
|
|
10
12
|
|
|
11
|
-
const CHECKABLE_RESOURCE_KINDS = new Set(['display-page', 'normal-form', 'process-form']);
|
|
13
|
+
const CHECKABLE_RESOURCE_KINDS = new Set(['display-page', 'normal-form', 'process-form', 'native-portal']);
|
|
12
14
|
const APP_TYPE_OPTIONS = Object.freeze(['--app-type', '--appType', '--app_type']);
|
|
13
15
|
|
|
14
16
|
function parseArgs(args = [], options = {}) {
|
|
@@ -207,6 +209,9 @@ function classifyResourceType(typeValue) {
|
|
|
207
209
|
if (!value) {
|
|
208
210
|
return 'unknown';
|
|
209
211
|
}
|
|
212
|
+
if (value === 'portal' || /原生门户|nativeportal/.test(value)) {
|
|
213
|
+
return 'native-portal';
|
|
214
|
+
}
|
|
210
215
|
if (/process|流程|审批/.test(value)) {
|
|
211
216
|
return 'process-form';
|
|
212
217
|
}
|
|
@@ -221,6 +226,9 @@ function classifyResourceType(typeValue) {
|
|
|
221
226
|
|
|
222
227
|
function classifyActualFormType(formType) {
|
|
223
228
|
const value = normalizeComparable(formType);
|
|
229
|
+
if (value === 'portal') {
|
|
230
|
+
return 'native-portal';
|
|
231
|
+
}
|
|
224
232
|
if (/display|custom|自定义|展示/.test(value)) {
|
|
225
233
|
return 'display-page';
|
|
226
234
|
}
|
|
@@ -273,17 +281,23 @@ function extractResources(markdown) {
|
|
|
273
281
|
|
|
274
282
|
function parsePrdMarkdown(markdown) {
|
|
275
283
|
const navigationVisibility = [];
|
|
284
|
+
const pageNavigation = [];
|
|
276
285
|
let applicationTheme;
|
|
286
|
+
let hideAppNav;
|
|
277
287
|
for (const match of String(markdown || '').matchAll(/```json\s*\n([\s\S]*?)\n```/g)) {
|
|
278
288
|
try {
|
|
279
289
|
const handoff = JSON.parse(match[1]);
|
|
280
290
|
if (Array.isArray(handoff.navigationVisibility)) {navigationVisibility.push(...handoff.navigationVisibility);}
|
|
291
|
+
if (Array.isArray(handoff.pageNavigation)) {pageNavigation.push(...handoff.pageNavigation);}
|
|
292
|
+
if (['y', 'n'].includes(handoff.appConfig?.hideAppNav)) {hideAppNav = handoff.appConfig.hideAppNav;}
|
|
281
293
|
if (Object.prototype.hasOwnProperty.call(handoff, 'applicationTheme')) {applicationTheme = handoff.applicationTheme;}
|
|
282
294
|
} catch { /* Other fenced examples are not the structured execution handoff. */ }
|
|
283
295
|
}
|
|
284
296
|
return {
|
|
285
297
|
resources: extractResources(markdown),
|
|
286
298
|
navigationVisibility,
|
|
299
|
+
pageNavigation,
|
|
300
|
+
...(hideAppNav !== undefined ? { hideAppNav } : {}),
|
|
287
301
|
...(applicationTheme !== undefined ? { applicationTheme } : {}),
|
|
288
302
|
};
|
|
289
303
|
}
|
|
@@ -467,14 +481,22 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
|
|
|
467
481
|
resources: [...fast.resources, ...fast.pages.map(page => ({ ...page, type: 'display-page' }))]
|
|
468
482
|
.map(resource => ({ name: resource.name, type: resource.type, kind: resource.type, source: 'fast.resources' }))
|
|
469
483
|
.filter(resource => CHECKABLE_RESOURCE_KINDS.has(resource.kind)),
|
|
470
|
-
navigationVisibility: fast.navigationVisibility || [],
|
|
484
|
+
navigationVisibility: fast.navigationVisibility?.length ? fast.navigationVisibility : options.buildManifest?.navigationVisibility || [],
|
|
471
485
|
...(fast.applicationTheme ? { applicationTheme: fast.applicationTheme } : {}),
|
|
472
486
|
} : options.manifestOnly ? { resources: [], navigationVisibility: options.buildManifest?.navigationVisibility || [],
|
|
473
487
|
...(options.buildManifest?.applicationTheme ? { applicationTheme: options.buildManifest.applicationTheme } : {}) } : parsePrdMarkdown(markdown);
|
|
474
488
|
const parsedManifest = parseBuildManifest(options.buildManifest);
|
|
489
|
+
const expectedAppNavigation = parsedPrd.hideAppNav ?? (fast || options.manifestOnly
|
|
490
|
+
? options.buildManifest?.appConfig?.hideAppNav : undefined);
|
|
491
|
+
const pageNavigation = [
|
|
492
|
+
...(parsedPrd.pageNavigation || []),
|
|
493
|
+
...asArray(options.buildManifest?.pageNavigation),
|
|
494
|
+
].filter(page => page?.type === 'display-page' && page.isRenderNav === false);
|
|
495
|
+
const pageNavigationVerification = [];
|
|
475
496
|
const items = [];
|
|
476
497
|
const assetExecution = auditAssetExecution(options.buildManifest?.assetExecution, options.buildManifest?.assetTasks);
|
|
477
498
|
let themeVerification;
|
|
499
|
+
let applicationNavigationVerification;
|
|
478
500
|
|
|
479
501
|
function addItem(id, source, status, severity, message, details = {}) {
|
|
480
502
|
items.push(makeRiskItem(id, source, status, severity, message, details));
|
|
@@ -489,7 +511,9 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
|
|
|
489
511
|
verdict,
|
|
490
512
|
mode: 'delivery_risk_radar',
|
|
491
513
|
assetExecution,
|
|
514
|
+
...(pageNavigationVerification.length ? { pageNavigationVerification } : {}),
|
|
492
515
|
...(themeVerification ? { themeVerification } : {}),
|
|
516
|
+
...(applicationNavigationVerification ? { applicationNavigationVerification } : {}),
|
|
493
517
|
appType,
|
|
494
518
|
prdPath: options.prdPath || '',
|
|
495
519
|
buildManifestPath: options.buildManifestPath || '',
|
|
@@ -548,6 +572,29 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
|
|
|
548
572
|
const actualResources = forms.map(makeActualResource);
|
|
549
573
|
const manifestResources = parsedManifest.resources.filter(resource => resource.required);
|
|
550
574
|
|
|
575
|
+
const checkAppNavigation = ['y', 'n'].includes(expectedAppNavigation);
|
|
576
|
+
let appSettings;
|
|
577
|
+
if (checkAppNavigation || parsedPrd.applicationTheme !== undefined) {
|
|
578
|
+
const { fetchCurrentApp } = require('./update-app');
|
|
579
|
+
try {
|
|
580
|
+
const app = await (deps.fetchApp || fetchCurrentApp)(appType, authRef);
|
|
581
|
+
if (app && typeof app === 'object' && !Array.isArray(app) && Object.keys(app).length) {appSettings = app;}
|
|
582
|
+
} catch { /* The individual checks report missing readback. */ }
|
|
583
|
+
}
|
|
584
|
+
if (checkAppNavigation) {
|
|
585
|
+
const { getNavigationSettings } = require('./update-app');
|
|
586
|
+
const stored = appSettings ? getNavigationSettings(appSettings, ['hideAppNav']).hideAppNav : null;
|
|
587
|
+
// The workbench uses the visible default when the application has no override.
|
|
588
|
+
const actual = appSettings && stored === null ? 'n' : stored;
|
|
589
|
+
const verified = actual === expectedAppNavigation;
|
|
590
|
+
applicationNavigationVerification = { expected: expectedAppNavigation, actual, verified };
|
|
591
|
+
if (!verified) {
|
|
592
|
+
addItem('application_navigation_unverified', 'remote.application_navigation', 'fail', 'blocker',
|
|
593
|
+
'应用设置里的平台导航显隐未通过校验。请按已确认的应用导航方案检查设置并重新回读。',
|
|
594
|
+
{ expected: { hideAppNav: expectedAppNavigation }, actual: { hideAppNav: actual } });
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
551
598
|
if (parsedPrd.applicationTheme !== undefined) {
|
|
552
599
|
const expected = parsedPrd.applicationTheme;
|
|
553
600
|
const { normalizeCssColorToHex } = require('./custom-theme');
|
|
@@ -555,11 +602,10 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
|
|
|
555
602
|
themeVerification = { configurationReadback: false, verified: false, runtimeVerified: false };
|
|
556
603
|
try {
|
|
557
604
|
if (!expectedColor || !['light', 'dark'].includes(expected?.navTheme)) {throw new Error('INVALID_THEME_EXPECTATION');}
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
const rawNav = getNavigationSettings(app, ['navTheme']).navTheme;
|
|
605
|
+
if (!appSettings) {throw new Error('APP_SETTINGS_UNAVAILABLE');}
|
|
606
|
+
const { getThemeSettings, getNavigationSettings } = require('./update-app');
|
|
607
|
+
const settings = getThemeSettings(appSettings);
|
|
608
|
+
const rawNav = getNavigationSettings(appSettings, ['navTheme']).navTheme;
|
|
563
609
|
const actual = {
|
|
564
610
|
colour: settings.colour,
|
|
565
611
|
themeColor: normalizeCssColorToHex(settings.themeColor),
|
|
@@ -580,12 +626,12 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
|
|
|
580
626
|
}
|
|
581
627
|
}
|
|
582
628
|
|
|
583
|
-
//
|
|
584
|
-
// independent; a successful publication cannot prove the latter.
|
|
629
|
+
// Workbench menu visibility is independent of the standalone page setting.
|
|
585
630
|
for (const expected of parsedPrd.navigationVisibility) {
|
|
586
631
|
const matches = parsedManifest.resources.filter(resource => resource.name === expected?.name && resource.kind === 'display-page');
|
|
587
|
-
const ids = [...new Set(matches.map(resource => resource.formUuid).filter(Boolean))];
|
|
588
|
-
const actual = ids.length === 1 ?
|
|
632
|
+
const ids = expected?.formUuid ? [expected.formUuid] : [...new Set(matches.map(resource => resource.formUuid).filter(Boolean))];
|
|
633
|
+
const actual = ids.length === 1 ? actualResources.find(resource => resource.formUuid === ids[0]
|
|
634
|
+
&& resource.kind === 'display-page')?.raw : undefined;
|
|
589
635
|
const known = value => typeof value === 'boolean';
|
|
590
636
|
const valid = expected?.hidden === true && expected?.mobileHidden === true;
|
|
591
637
|
if (valid && actual && (actual.hidden === false || actual.mobileHidden === false)) {
|
|
@@ -597,14 +643,53 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
|
|
|
597
643
|
}
|
|
598
644
|
}
|
|
599
645
|
|
|
646
|
+
const checkedStandalonePages = new Set();
|
|
647
|
+
for (const page of pageNavigation) {
|
|
648
|
+
const recorded = parsedManifest.resources
|
|
649
|
+
.filter(resource => resource.kind === 'display-page' && resource.name === page.name)
|
|
650
|
+
.map(resource => resource.formUuid).filter(Boolean);
|
|
651
|
+
const ids = page.formUuid ? [page.formUuid] : [...new Set(recorded.length ? recorded : actualResources
|
|
652
|
+
.filter(resource => resource.kind === 'display-page' && resource.name === page.name)
|
|
653
|
+
.map(resource => resource.formUuid).filter(Boolean))];
|
|
654
|
+
const resource = ids.length === 1 && actualResources.find(item => item.formUuid === ids[0] && item.kind === 'display-page');
|
|
655
|
+
const key = resource?.formUuid || page.formUuid || page.name;
|
|
656
|
+
if (checkedStandalonePages.has(key)) {continue;}
|
|
657
|
+
checkedStandalonePages.add(key);
|
|
658
|
+
const actual = { name: page.name, formUuid: resource?.formUuid || null, renderNav: null, standaloneUrl: null };
|
|
659
|
+
if (resource) {
|
|
660
|
+
const menuIds = parsedPrd.navigationVisibility
|
|
661
|
+
.filter(item => item?.name === page.name && item.hidden === true && item.mobileHidden === true)
|
|
662
|
+
.flatMap(item => item.formUuid ? [item.formUuid] : recorded);
|
|
663
|
+
if (menuIds.some(id => id !== resource.formUuid)) {
|
|
664
|
+
addItem('frontend_navigation_page_mismatch', 'remote.navigation', 'fail', 'blocker',
|
|
665
|
+
`「${page.name}」的独立入口和后台菜单隐藏指向不同页面。请按同一页面 ID 核对发布与菜单显隐。`,
|
|
666
|
+
{ expected: { formUuid: resource.formUuid }, actual: { formUuids: menuIds } });
|
|
667
|
+
}
|
|
668
|
+
try {
|
|
669
|
+
const response = await (deps.fetchPageConfig || fetchFormSchemaInfo)(authRef, appType, resource.formUuid);
|
|
670
|
+
const payload = unwrapYidaResponse(response, { action: 'Read standalone page configuration' });
|
|
671
|
+
const config = payload === response ? response.result ?? response.data ?? payload : payload;
|
|
672
|
+
const entry = buildDisplayPageEntryUrls({ appType, formUuid: resource.formUuid, baseUrl: authRef.baseUrl, config, formType: 'display' });
|
|
673
|
+
actual.renderNav = entry.navigationVerification?.renderNav ?? null;
|
|
674
|
+
actual.standaloneUrl = entry.standaloneUrl || null;
|
|
675
|
+
} catch { /* Report missing readback as an unverified standalone entry. */ }
|
|
676
|
+
}
|
|
677
|
+
pageNavigationVerification.push({ ...actual, verified: !!actual.standaloneUrl });
|
|
678
|
+
if (!actual.standaloneUrl) {
|
|
679
|
+
addItem('standalone_page_navigation_unverified', 'remote.page_navigation', 'fail', 'blocker',
|
|
680
|
+
`独立入口「${page.name || key}」未确认隐藏本页平台导航。请核对页面 ID,更新并回读 renderNav=false,再使用 standaloneUrl。`,
|
|
681
|
+
{ expected: { renderNav: false, route: 'custom' }, actual });
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
600
685
|
if (!options.buildManifest) {
|
|
601
686
|
addItem('build_manifest_missing', 'build_manifest', 'not_checked', 'info', '未提供 build-manifest.json,只能基于 PRD 资源 hints 做风险提示', {
|
|
602
687
|
expected: '--build-manifest <file>',
|
|
603
688
|
actual: null,
|
|
604
689
|
});
|
|
605
690
|
} else if (parsedManifest.resources.length === 0) {
|
|
606
|
-
addItem('build_manifest_empty', 'build_manifest', 'not_checked', 'warning', 'build-manifest.json
|
|
607
|
-
expected: [
|
|
691
|
+
addItem('build_manifest_empty', 'build_manifest', 'not_checked', 'warning', 'build-manifest.json 未记录可核验的页面或表单资源,无法确认数量完整性', {
|
|
692
|
+
expected: [...CHECKABLE_RESOURCE_KINDS],
|
|
608
693
|
actual: [],
|
|
609
694
|
});
|
|
610
695
|
}
|
package/lib/app/create-page.js
CHANGED
|
@@ -44,8 +44,11 @@ function parseArgs(args) {
|
|
|
44
44
|
|
|
45
45
|
for (let i = 0; i < openOption.args.length; i++) {
|
|
46
46
|
const arg = openOption.args[i];
|
|
47
|
-
if (arg === '--mode'
|
|
48
|
-
mode = openOption.args[++i];
|
|
47
|
+
if (arg === '--mode' || arg.startsWith('--mode=')) {
|
|
48
|
+
mode = arg === '--mode' ? openOption.args[++i] : arg.slice('--mode='.length);
|
|
49
|
+
if (!mode || mode.startsWith('--')) {
|
|
50
|
+
throw new Error('--mode requires a value.');
|
|
51
|
+
}
|
|
49
52
|
continue;
|
|
50
53
|
}
|
|
51
54
|
if ((arg === '--locale' || arg === '--content-locale' || arg === '--lang') && openOption.args[i + 1]) {
|
|
@@ -179,34 +182,51 @@ async function configureNavigationVisibility(authRef, appType, pageId, pageName,
|
|
|
179
182
|
return verification;
|
|
180
183
|
}
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
const PORTAL_USAGE = 'openyida create-portal <appType> "<pageName>" [--locale zh_CN|en_US|ja_JP] [--open|--no-open]';
|
|
186
|
+
|
|
187
|
+
async function createPage(args, formType) {
|
|
188
|
+
const nativePortal = formType === 'portal';
|
|
183
189
|
let options;
|
|
184
190
|
try {
|
|
185
191
|
options = parseArgs(args || []);
|
|
186
192
|
} catch (err) {
|
|
187
193
|
const { error: chalkError } = require('../core/chalk');
|
|
188
|
-
chalkError(err.message, { hint: t('create_page.usage') });
|
|
194
|
+
chalkError(err.message, { hint: nativePortal ? PORTAL_USAGE : t('create_page.usage') });
|
|
189
195
|
}
|
|
190
196
|
|
|
191
197
|
if (options.help) {
|
|
192
198
|
const { usage, hint } = require('../core/chalk');
|
|
193
|
-
|
|
194
|
-
|
|
199
|
+
if (nativePortal) {
|
|
200
|
+
usage(PORTAL_USAGE, 'openyida create-portal APP_XXX "运营门户"');
|
|
201
|
+
} else {
|
|
202
|
+
usage(t('create_page.usage'), t('create_page.example'));
|
|
203
|
+
hint(t('create_page.mode_hint'));
|
|
204
|
+
}
|
|
195
205
|
return options;
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
if (options.args.length < 2) {
|
|
199
209
|
const { error: chalkError } = require('../core/chalk');
|
|
200
|
-
chalkError(t('create_page.usage'), { hint: t('create_page.example') });
|
|
210
|
+
chalkError(nativePortal ? PORTAL_USAGE : t('create_page.usage'), { hint: nativePortal ? undefined : t('create_page.example') });
|
|
201
211
|
}
|
|
202
212
|
|
|
203
213
|
const appType = options.appType;
|
|
204
214
|
const pageName = options.pageName;
|
|
205
|
-
|
|
206
|
-
|
|
215
|
+
if (!nativePortal && options.mode === 'portal') {
|
|
216
|
+
throwCommandError(PORTAL_USAGE + ' (only for an explicitly requested native portal)', {
|
|
217
|
+
code: 'CREATE_PAGE_USE_PORTAL_COMMAND',
|
|
218
|
+
details: { recovery: { command: 'create-portal', args: [appType, pageName] } },
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (nativePortal && ((args || []).some(arg => /^--(?:mode|hide-nav(?:igation)?|no-nav|render-nav|is-render-nav|isRenderNav)(?:=|$)/.test(arg)) ||
|
|
222
|
+
options.args.length !== 2)) {
|
|
223
|
+
throwCommandError(PORTAL_USAGE, { code: 'CREATE_PORTAL_USAGE' });
|
|
224
|
+
}
|
|
225
|
+
if (!nativePortal && !['default', 'dashboard'].includes(options.mode)) {
|
|
207
226
|
const { error: chalkError } = require('../core/chalk');
|
|
208
|
-
chalkError(t('create_page.err_mode_invalid', mode), { hint: t('create_page.mode_hint') });
|
|
227
|
+
chalkError(t('create_page.err_mode_invalid', options.mode), { hint: t('create_page.mode_hint') });
|
|
209
228
|
}
|
|
229
|
+
const mode = nativePortal ? 'portal' : options.mode;
|
|
210
230
|
|
|
211
231
|
const { c, banner, step, label, info, warn, success: chalkSuccess, result: chalkResult } = require('../core/chalk');
|
|
212
232
|
|
|
@@ -231,7 +251,7 @@ async function run(args) {
|
|
|
231
251
|
(auth) => {
|
|
232
252
|
const postData = querystring.stringify({
|
|
233
253
|
_csrf_token: auth.csrfToken,
|
|
234
|
-
formType
|
|
254
|
+
formType,
|
|
235
255
|
title: JSON.stringify(buildYidaI18n(pageName, { en_US: pageName, ja_JP: pageName })),
|
|
236
256
|
});
|
|
237
257
|
return httpPost(
|
|
@@ -252,6 +272,31 @@ async function run(args) {
|
|
|
252
272
|
if (response && response.success && response.content) {
|
|
253
273
|
const pageId = response.content.formUuid || response.content;
|
|
254
274
|
const workbenchUrl = `${authRef.baseUrl}/${appType}/workbench/${pageId}`;
|
|
275
|
+
let portalResult = {};
|
|
276
|
+
if (formType === 'portal') {
|
|
277
|
+
const designerUrl = `${authRef.baseUrl}/alibaba/web/${encodeURIComponent(appType)}/design/portalDesigner?formUuid=${encodeURIComponent(pageId)}`;
|
|
278
|
+
let actualType = null;
|
|
279
|
+
try {
|
|
280
|
+
const readback = await fetchFormSchemaInfo(authRef, appType, pageId);
|
|
281
|
+
if (readback && readback.success !== false && !readback.__needLogin && !readback.__csrfExpired) {
|
|
282
|
+
const config = readback.content || readback.result || readback.data;
|
|
283
|
+
actualType = config?.formType ?? null;
|
|
284
|
+
}
|
|
285
|
+
} catch {
|
|
286
|
+
// Creation already succeeded. Report the resource for read-only recovery.
|
|
287
|
+
}
|
|
288
|
+
if (actualType !== 'portal') {
|
|
289
|
+
throwCommandError(t('create_page.portal_unverified'), {
|
|
290
|
+
code: 'CREATE_PAGE_PORTAL_NOT_VERIFIED',
|
|
291
|
+
details: {
|
|
292
|
+
pageCreated: true, appType, pageId, actualType, designerUrl, workbenchUrl,
|
|
293
|
+
retrySafe: false, sideEffectState: 'applied',
|
|
294
|
+
recovery: { command: 'get-form-config', args: [appType, pageId, '--json'] },
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
portalResult = { formType, designerUrl, readbackVerified: true };
|
|
299
|
+
}
|
|
255
300
|
let pageUrl = workbenchUrl;
|
|
256
301
|
let dashboardConfigWarning = null;
|
|
257
302
|
let navigationVerification = null;
|
|
@@ -278,6 +323,7 @@ async function run(args) {
|
|
|
278
323
|
hideNav: options.hideNav ? (navigationVerification.renderNav === null ? null : !navigationVerification.renderNav) : false,
|
|
279
324
|
chromeless: options.hideNav && navigationVerification.verified,
|
|
280
325
|
navigationVerification, url: pageUrl, workbenchUrl, dashboardConfigWarning,
|
|
326
|
+
...portalResult,
|
|
281
327
|
};
|
|
282
328
|
if (!complete) {
|
|
283
329
|
result.errorCode = 'CREATE_PAGE_NAVIGATION_NOT_VERIFIED';
|
|
@@ -293,7 +339,7 @@ async function run(args) {
|
|
|
293
339
|
|
|
294
340
|
console.log(JSON.stringify(complete ? withBrowserHandoff(
|
|
295
341
|
result,
|
|
296
|
-
pageUrl,
|
|
342
|
+
portalResult.designerUrl || pageUrl,
|
|
297
343
|
{ stage: 'create_page_success', title: pageName },
|
|
298
344
|
options.openMode
|
|
299
345
|
) : result));
|
|
@@ -309,4 +355,7 @@ async function run(args) {
|
|
|
309
355
|
}
|
|
310
356
|
}
|
|
311
357
|
|
|
312
|
-
|
|
358
|
+
const run = args => createPage(args, 'display');
|
|
359
|
+
const runPortal = args => createPage(args, 'portal');
|
|
360
|
+
|
|
361
|
+
module.exports = { run, runPortal, parseArgs, buildPageInfoPostData };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const https = require('node:https');
|
|
4
|
+
const { CliError } = require('../core/cli-error');
|
|
5
|
+
|
|
6
|
+
const ORIGIN = 'https://datav.aliyun.com';
|
|
7
|
+
|
|
8
|
+
function failure(code = 'DATAV_DESIGNER_UNAVAILABLE') {
|
|
9
|
+
const messages = {
|
|
10
|
+
DATAV_CONFIG_INVALID: 'The saved DataV configuration format is not supported.',
|
|
11
|
+
DATAV_CATALOGUE_INVALID: 'The DataV component catalogue returned an unsupported response.',
|
|
12
|
+
DATAV_COMPONENT_NOT_FOUND: 'No component matches the requested catalogue name or layer ID.',
|
|
13
|
+
};
|
|
14
|
+
return new CliError(messages[code] || 'DataV designer access could not be verified. Open the YiDA designer and check access before retrying.', { code });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Only the observed YiDA DataV integration origin may receive its temporary ticket. */
|
|
18
|
+
function allowedUrl(value) {
|
|
19
|
+
let url;
|
|
20
|
+
try {url = new URL(value, ORIGIN);} catch {throw failure();}
|
|
21
|
+
if (url.origin !== ORIGIN || url.username || url.password || url.hash) {throw failure();}
|
|
22
|
+
return url;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A short-lived, memory-only DataV session. YiDA OAuth headers never cross origins. */
|
|
26
|
+
function session(request = https.request) {
|
|
27
|
+
const cookies = new Map();
|
|
28
|
+
async function get(value, redirects = 0) {
|
|
29
|
+
const url = allowedUrl(value);
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const req = request(url, { method: 'GET', headers: {
|
|
32
|
+
Accept: '*/*', 'Accept-Encoding': 'identity', 'from-app': 'yida',
|
|
33
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
34
|
+
...(cookies.size ? { Cookie: [...cookies].map(([key, val]) => key + '=' + val).join('; ') } : {}),
|
|
35
|
+
} }, response => {
|
|
36
|
+
for (const entry of response.headers['set-cookie'] || []) {
|
|
37
|
+
const domain = /;\s*domain=([^;]+)/i.exec(entry);
|
|
38
|
+
if (domain && !['datav.aliyun.com', '.datav.aliyun.com'].includes(domain[1].toLowerCase())) {continue;}
|
|
39
|
+
const pair = /^([^=;\s]+)=([^;]*)/.exec(entry);
|
|
40
|
+
if (pair) {cookies.set(pair[1], pair[2]);}
|
|
41
|
+
}
|
|
42
|
+
if ([301, 302, 303, 307, 308].includes(response.statusCode)) {
|
|
43
|
+
response.resume();
|
|
44
|
+
try {
|
|
45
|
+
if (redirects >= 3 || !response.headers.location) {throw failure();}
|
|
46
|
+
resolve(get(allowedUrl(new URL(response.headers.location, url).href).href, redirects + 1));
|
|
47
|
+
} catch {reject(failure());}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (response.statusCode !== 200) {response.resume(); reject(failure()); return;}
|
|
51
|
+
let bytes = 0;
|
|
52
|
+
const chunks = [];
|
|
53
|
+
response.on('data', chunk => {
|
|
54
|
+
bytes += chunk.length;
|
|
55
|
+
if (bytes > 8 * 1024 * 1024) {req.destroy(); reject(failure()); return;}
|
|
56
|
+
chunks.push(chunk);
|
|
57
|
+
});
|
|
58
|
+
response.on('error', () => reject(failure()));
|
|
59
|
+
response.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
60
|
+
});
|
|
61
|
+
req.setTimeout(30000, () => {req.destroy(); reject(failure());});
|
|
62
|
+
req.on('error', () => reject(failure()));
|
|
63
|
+
req.end();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return { get };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Parse the JSON payload in Cube's known config envelope without evaluating script. */
|
|
70
|
+
function parseConfig(text, id) {
|
|
71
|
+
const prefix = `Cube("main:/admin/v3/screen/${id}/config.js", [], function (module, exports, require, load, __dirname, __filename) {module.exports = `;
|
|
72
|
+
const suffix = ';\nreturn module.exports;});';
|
|
73
|
+
if (!text.startsWith(prefix) || !text.trimEnd().endsWith(suffix)) {throw failure('DATAV_CONFIG_INVALID');}
|
|
74
|
+
let result;
|
|
75
|
+
try {result = JSON.parse(text.trimEnd().slice(prefix.length, -suffix.length));} catch {throw failure('DATAV_CONFIG_INVALID');}
|
|
76
|
+
if (!result || !Array.isArray(result.scenes) || !result.config || typeof result.config !== 'object') {throw failure('DATAV_CONFIG_INVALID');}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function connect(client, metadata) {
|
|
81
|
+
const html = await client.get('/alibaba/web/' + metadata.appType + '/datav/vigoDesigner.html',
|
|
82
|
+
{ formUuid: metadata.formUuid }, { responseType: 'text', silentStatus: true });
|
|
83
|
+
const match = typeof html === 'string' && /datavScreenEdit:\s*"([^"\r\n]+)"/.exec(html);
|
|
84
|
+
if (!match) {throw failure();}
|
|
85
|
+
const url = allowedUrl(match[1].replace(/&/g, '&'));
|
|
86
|
+
if (url.pathname !== '/admin/screen/' + metadata.datavId || !url.searchParams.has('x-datav-login-ticket')) {throw failure();}
|
|
87
|
+
const remote = session();
|
|
88
|
+
const editor = await remote.get(url.href);
|
|
89
|
+
if (!editor.includes('configJSPath')) {throw failure();}
|
|
90
|
+
return remote;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Redact credentials in saved style URLs and bindings; never return share settings. */
|
|
94
|
+
function redact(value) {
|
|
95
|
+
if (Array.isArray(value)) {return value.map(redact);}
|
|
96
|
+
if (value && typeof value === 'object') {
|
|
97
|
+
return Object.fromEntries(Object.entries(value).map(([key, val]) =>
|
|
98
|
+
[key, /token|password|secret|cookie|authorization|credential|ticket|signature|access.?key|api.?key/i.test(key) ? '[redacted]' : redact(val)]));
|
|
99
|
+
}
|
|
100
|
+
if (typeof value === 'string') {
|
|
101
|
+
return value.replace(/([?&](?:[^=&\s]*(?:token|secret|password|ticket|signature|credential|authorization|access.?key|api.?key)[^=&\s]*)=)[^&#\s]*/gi, '$1[redacted]')
|
|
102
|
+
.replace(/(https?:\/\/)[^/\s:@]+:[^/\s@]+@/gi, '$1[redacted]@');
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function screenView(config, component) {
|
|
108
|
+
const scenes = config.scenes.map((scene, index) => ({ index, name: scene.name,
|
|
109
|
+
layers: Object.entries(scene.layers || {}).filter(([id]) => !component || component === id).map(([id, layer]) => ({
|
|
110
|
+
id, comName: layer.comName, version: layer.version, type: layer.type, comType: layer.comType,
|
|
111
|
+
parent: layer.parent, children: layer.children, attr: layer.attr, config: layer.config,
|
|
112
|
+
// Values and remote data-source credentials stay in the native designer.
|
|
113
|
+
dataInterfaces: Object.keys(layer.data || {}),
|
|
114
|
+
})),
|
|
115
|
+
}));
|
|
116
|
+
if (component && !scenes.some(scene => scene.layers.length)) {throw failure('DATAV_COMPONENT_NOT_FOUND');}
|
|
117
|
+
const { width, height, grid, display, backgroundColor, backgroundImage } = config.config;
|
|
118
|
+
return redact({ page: { width, height, grid, display, backgroundColor, backgroundImage }, scenes,
|
|
119
|
+
dataValuesIncluded: false, shareSettingsIncluded: false, writable: false });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function categories(entry) {
|
|
123
|
+
const types = [entry.type, entry.config?.type || []].flat().join(',');
|
|
124
|
+
const values = [];
|
|
125
|
+
if (/map|geo|datavgl|guston/.test(types) || /map2d|datavmap|xiongan_blockdata/.test(entry.name || '')) {values.push('map');}
|
|
126
|
+
if (/regular/.test(types)) {values.push('chart');}
|
|
127
|
+
if (/interact|control/.test(types)) {values.push('control');}
|
|
128
|
+
if (/figure|text|:info/.test(types)) {values.push('info');}
|
|
129
|
+
if (/table|list|:table/.test(types)) {values.push('table');}
|
|
130
|
+
if (/media|decorate/.test(types)) {values.push('media');}
|
|
131
|
+
if (/:analysis/.test(types)) {values.push('analysis');}
|
|
132
|
+
return values.length ? values : ['other'];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function parameters(fields, prefix = '') {
|
|
136
|
+
return Object.entries(fields || {}).flatMap(([key, field]) => {
|
|
137
|
+
if (!field || typeof field !== 'object') {return [];}
|
|
138
|
+
const path = prefix ? prefix + '.' + key : key;
|
|
139
|
+
const { name, type, description, default: initial, min, max, range, options, show, showInPanel, step, suffix } = field;
|
|
140
|
+
return [{ path, name, type, description, default: initial, min, max, range, options, show, showInPanel, step, suffix },
|
|
141
|
+
...parameters(field.children, path), ...parameters(field.template?.children, path + '[]')];
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function catalogueView(entries, args) {
|
|
146
|
+
if (!Array.isArray(entries)) {throw failure('DATAV_CATALOGUE_INVALID');}
|
|
147
|
+
const normalized = entries.map(entry => {
|
|
148
|
+
if (!entry || typeof entry !== 'object') {return {};}
|
|
149
|
+
let config = entry.config;
|
|
150
|
+
if (typeof config === 'string') {
|
|
151
|
+
try {config = JSON.parse(config);} catch {throw failure('DATAV_CATALOGUE_INVALID');}
|
|
152
|
+
}
|
|
153
|
+
return { ...entry, config };
|
|
154
|
+
});
|
|
155
|
+
const selected = normalized.filter(entry => typeof entry.name === 'string' &&
|
|
156
|
+
(!args.category || categories(entry).includes(args.category)) &&
|
|
157
|
+
(!args.component || entry.name === args.component) &&
|
|
158
|
+
(!args.search || (entry.name + ' ' + entry.cn_name).toLowerCase().includes(args.search.toLowerCase())));
|
|
159
|
+
if (args.component && !selected.length) {throw failure('DATAV_COMPONENT_NOT_FOUND');}
|
|
160
|
+
return { source: 'datav_component_catalogue', entitlementVerified: false, installedPackagesIncluded: false,
|
|
161
|
+
total: selected.length, components: selected.map(entry => ({ name: entry.name, title: entry.cn_name || entry.config?.cn_name || entry.name,
|
|
162
|
+
version: entry.version, categories: categories(entry), type: entry.type, level: entry.level,
|
|
163
|
+
dataInterfaces: Object.keys(entry.config?.apis || {}),
|
|
164
|
+
...(args.component ? { parameterDefinitions: parameters(entry.config?.config), definition: entry.config } : {}),
|
|
165
|
+
})) };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function read(client, metadata, args) {
|
|
169
|
+
const remote = await connect(client, metadata);
|
|
170
|
+
if (args.action === 'config') {
|
|
171
|
+
return screenView(parseConfig(await remote.get('/api/admin/v3/screen/' + metadata.datavId + '/config.js?x-datav-from-app=yida&m=1'), metadata.datavId), args.component);
|
|
172
|
+
}
|
|
173
|
+
let entries;
|
|
174
|
+
const detail = args.component ? '' : '&withoutConfig=true';
|
|
175
|
+
try {entries = JSON.parse(await remote.get('/cube/modules?i18n=zh_CN&x-datav-from-app=yida' + detail));} catch {throw failure('DATAV_CATALOGUE_INVALID');}
|
|
176
|
+
return redact(catalogueView(entries, args));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
module.exports = { read, allowedUrl, session, parseConfig, screenView, catalogueView };
|