openyida 2026.11.2 → 2026.11.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/README.md +11 -9
- package/bin/yida.js +2 -1
- package/lib/app/application-entry-urls.js +35 -1
- package/lib/app/check-prd-completeness.js +27 -6
- package/lib/app/create-app.js +17 -9
- package/lib/app/fast-build.js +151 -0
- package/lib/app/fast-theme.js +83 -0
- package/lib/app/form-data-contract.js +162 -0
- package/lib/app/services/canvas-page-schema-builder.js +10 -0
- package/lib/asset/ai-image.js +8 -5
- package/lib/asset/asset-cmd.js +24 -4
- package/lib/asset/asset-execution.js +25 -4
- package/lib/asset/asset-plan.js +4 -2
- package/lib/asset/asset-resolve.js +21 -7
- package/lib/auth/oauth-loopback.js +1 -1
- package/lib/auth/org.js +2 -0
- package/lib/auth/token-auth.js +1 -0
- package/lib/core/agent-capabilities.js +30 -9
- package/lib/core/batch.js +71 -122
- package/lib/core/command-manifest.js +71 -38
- package/lib/core/locales/en.js +20 -4
- package/lib/core/locales/zh.js +19 -3
- package/lib/core/permission-guidance.js +10 -10
- package/lib/core/query-data.js +67 -10
- package/lib/core/sample.js +73 -0
- package/lib/core/task-concurrency.js +96 -0
- package/lib/corp-efficiency/corp-efficiency.js +15 -8
- package/lib/design/fast-document.js +118 -0
- package/lib/design-plan/design-plan.js +3 -3
- package/lib/design-plan/init.js +90 -5
- package/lib/design-plan/materialize.js +2 -2
- package/lib/design-plan/validate.js +64 -9
- package/lib/flash-note/build-flash-note-prompt.js +1 -1
- package/lib/samples/openyida-scaffold/canvas-data-source.jsx +135 -0
- package/lib/samples/openyida-scaffold/canvas-file-upload.jsx +106 -0
- package/lib/samples/openyida-scaffold/file-upload-client.jsx +160 -0
- package/lib/samples/yida-app/fast-app.json +64 -0
- package/lib/samples/yida-design/fast-design.json +38 -0
- package/package.json +3 -3
- package/scripts/postinstall.js +6 -6
- package/yida-skills/SKILL.md +10 -9
- package/yida-skills/references/official-example-schema-patterns.md +3 -3
- package/yida-skills/references/qwenwork-link-presentation.md +11 -16
- package/yida-skills/references/user-facing-summary.md +1 -1
- package/yida-skills/skills/yida-app/SKILL.md +23 -12
- package/yida-skills/skills/yida-app/references/fast-context.md +7 -0
- package/yida-skills/skills/yida-app/workflow/fast-build.md +65 -0
- package/yida-skills/skills/yida-app/workflow/parallel-work.md +15 -5
- package/yida-skills/skills/yida-app/workflow/plan/workflow.md +5 -1
- package/yida-skills/skills/yida-app/workflow/step-2-design.md +13 -6
- package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +7 -2
- package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +4 -1
- package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -1
- package/yida-skills/skills/yida-app/workflow/step-6-main-page.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +5 -2
- package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +7 -2
- package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +14 -4
- package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +2 -0
- package/yida-skills/skills/yida-canvas-custom-page/references/file-upload.md +75 -0
- package/yida-skills/skills/yida-canvas-custom-page/references/native-components-bridge.md +4 -3
- package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +1 -1
- package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +23 -82
- package/yida-skills/skills/yida-corp-efficiency/SKILL.md +3 -3
- package/yida-skills/skills/yida-create-app/SKILL.md +9 -5
- package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -1
- package/yida-skills/skills/yida-create-form-page/references/field-definition-guide.md +1 -1
- package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +13 -17
- package/yida-skills/skills/yida-custom-page/SKILL.md +2 -0
- package/yida-skills/skills/yida-custom-page/references/attachment-upload-guide.md +4 -0
- package/yida-skills/skills/yida-data-management/SKILL.md +2 -0
- package/yida-skills/skills/yida-data-management/references/data-format-guide.md +9 -0
- package/yida-skills/skills/yida-design/SKILL.md +7 -2
- package/yida-skills/skills/yida-design/references/application-theme-consistency.md +4 -4
- package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +2 -2
- package/yida-skills/skills/yida-design/references/design-mode.md +4 -2
- package/yida-skills/skills/yida-design/references/fast-design-spec.md +32 -0
- package/yida-skills/skills/yida-design/references/native-form-styles.md +2 -2
- package/yida-skills/skills/yida-design/templates/design-themes/app-teal/design.md +4 -4
- package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/design.md +4 -4
- package/yida-skills/skills/yida-design/workflow/output-design.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-4-wireframe-interaction.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +1 -1
- package/yida-skills/skills/yida-dingtalk-openapi/references/api-contract.md +1 -1
- package/yida-skills/skills/yida-flash-note-to-prd/references/flash-note-prompt.md +1 -1
- package/yida-skills/skills/yida-image-assets/SKILL.md +11 -5
- package/yida-skills/skills/yida-login/SKILL.md +6 -0
- package/yida-skills/skills/yida-ppt-slider/references/examples.md +3 -3
- package/yida-skills/skills/yida-prd/SKILL.md +5 -1
- package/yida-skills/skills/yida-publish-page/SKILL.md +3 -0
- package/yida-skills/skills/yida-requirement-analysis/SKILL.md +4 -1
- package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +4 -1
- package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -0
- package/yida-skills/skills-index.json +2 -2
|
@@ -41,7 +41,6 @@ function resolvePermissionPage(location, baseUrl) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function createPermissionError(response, options = {}) {
|
|
44
|
-
if (options.tool !== 'qwenwork') { return null; }
|
|
45
44
|
let payload = response;
|
|
46
45
|
if (typeof payload === 'string') {
|
|
47
46
|
try { payload = JSON.parse(payload); } catch { payload = {}; }
|
|
@@ -60,17 +59,18 @@ function createPermissionError(response, options = {}) {
|
|
|
60
59
|
if (!failed) { return null; }
|
|
61
60
|
let page = resolvePermissionPage(options.location || payload.__location, options.baseUrl);
|
|
62
61
|
const legacyDenied = /^(?:TIANSHU_)?000006$/.test(code);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
const normalized = normalizeMessage(message);
|
|
63
|
+
const creationDenied = /^\/query\/app\/registerApp(?:\.json)?(?:\?|$)/.test(options.requestPath || '')
|
|
64
|
+
&& (legacyDenied || !code || code === '403')
|
|
65
|
+
&& ['没有权限', '无权限', '暂无权限', '管理员暂未为您分配权限请联系管理员授权'].includes(normalized);
|
|
66
|
+
if (!page && creationDenied) {
|
|
67
|
+
page = resolvePermissionPage('/defaultPage.html?type=noAppCreationAuth', options.baseUrl);
|
|
68
|
+
}
|
|
69
|
+
if (!page && legacyDenied && normalized === '已升级宜搭你未在授权范围内因此无法使用如要使用请联系管理员授权') {
|
|
70
|
+
page = resolvePermissionPage('/defaultPage.html?type=unauth', options.baseUrl);
|
|
72
71
|
}
|
|
73
72
|
if (!page && !legacyDenied && httpStatus !== 403 && code !== '403' && status !== '403') { return null; }
|
|
73
|
+
if (!page && options.tool !== 'qwenwork') { return null; }
|
|
74
74
|
const permissionType = page ? page.permissionType : 'unknown';
|
|
75
75
|
const label = page ? t(`permission_guidance.${permissionType}_link`) : '';
|
|
76
76
|
const details = {
|
package/lib/core/query-data.js
CHANGED
|
@@ -25,14 +25,15 @@ const { readFormMode } = require('../app/services/form-mode-service');
|
|
|
25
25
|
const { fetchFormPageList } = require('../app/form-navigation');
|
|
26
26
|
const processTasks = require('../process/process-tasks');
|
|
27
27
|
const { assertFormUpdatePermissions, assertFormUpdatePermissionResponse } = require('./form-edit-permissions');
|
|
28
|
+
const { buildWriteContract, prepareWriteData, compareWriteData } = require('../app/form-data-contract');
|
|
28
29
|
|
|
29
30
|
const USAGE = `openyida data - Unified Yida data CLI
|
|
30
31
|
|
|
31
32
|
Usage:
|
|
32
33
|
openyida data query form <appType> <formUuid> [--page N] [--size N] [--all] [--max-pages N] [--search-json JSON|--search-file .cache/openyida/search.json] [--dynamic-order '{"fieldId":"+"}'] [--resolve-aliases] [--inst-id ID] [--no-hydrate-subforms]
|
|
33
34
|
openyida data get form <appType> --inst-id <formInstId> [--form-uuid <formUuid>] [--no-hydrate-subforms]
|
|
34
|
-
openyida data create form <appType> <formUuid> (--data-json <JSON>|--data-file .cache/openyida/data.json) --expect-form-name <name> --expect-form-type receipt [--dept-id ID] [--resolve-aliases]
|
|
35
|
-
openyida data update form <appType> --inst-id <formInstId> --form-uuid <formUuid> (--data-json <JSON>|--data-file .cache/openyida/data.json) --expect-form-name <name> --expect-form-type receipt [--use-latest-version y] [--resolve-aliases]
|
|
35
|
+
openyida data create form <appType> <formUuid> (--data-json <JSON>|--data-file .cache/openyida/data.json) --expect-form-name <name> --expect-form-type receipt [--dept-id ID] [--resolve-aliases] [--verify-write]
|
|
36
|
+
openyida data update form <appType> --inst-id <formInstId> --form-uuid <formUuid> (--data-json <JSON>|--data-file .cache/openyida/data.json) --expect-form-name <name> --expect-form-type receipt [--use-latest-version y] [--resolve-aliases] [--verify-write]
|
|
36
37
|
openyida data delete form <appType> <formUuid> --inst-id <formInstId> --expect-form-name <name> --expect-form-type receipt --confirm [--json]
|
|
37
38
|
openyida data query subform <appType> <formUuid> --inst-id <formInstId> --table-field-id <fieldId|alias> [--page N] [--size N] [--resolve-aliases]
|
|
38
39
|
|
|
@@ -50,6 +51,7 @@ Usage:
|
|
|
50
51
|
openyida data query tasks <appType> --type todo --transport app-query [--originators JSON] [--instance-create-from MS] [--instance-create-to MS] [--task-create-from MS] [--task-create-to MS]
|
|
51
52
|
|
|
52
53
|
Add --resolve-aliases when JSON keys use Yida component aliases instead of field IDs.
|
|
54
|
+
--verify-write preflights ordinary form create/update against the live schema and reads back submitted fields after one write. Unknown fields/types fail before writing; accepted writes with failed verification retain instance IDs and must not be repeated automatically.
|
|
53
55
|
Ordinary form updates verify record edit permission and native edit-schema field behaviors before writing. Readonly, hidden, disabled, unknown or dynamically unverifiable fields reject the entire update. Restricted subform replacements require the native editor.
|
|
54
56
|
Each condition uses key (field ID), componentName, type, operator and value. Query types: TextField/TextareaField/TableField TEXT; NumberField/RateField/DateField/CascadeDateField DOUBLE; RadioField/SelectField/CheckboxField/MultiSelectField/DepartmentSelectField ARRAY; EmployeeField/CascadeSelectField/CitySelectField STRING; ImageField/AttachmentField TEXT.
|
|
55
57
|
For ordinary form queries, DateField emptiness uses operator is/is_not and value "" (type DOUBLE).
|
|
@@ -125,6 +127,10 @@ function buildDeleteReadbackStep(target) {
|
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
function validateDataCommandBeforeAuth(action, resource, positionals, options) {
|
|
130
|
+
if (options.verify_write !== undefined
|
|
131
|
+
&& (options.verify_write !== true || resource !== 'form' || !['create', 'update'].includes(action))) {
|
|
132
|
+
dataError('DATA_VERIFY_WRITE_UNSUPPORTED', t('data_verify.invalid_usage'), { retrySafe: true, sideEffectState: 'none' });
|
|
133
|
+
}
|
|
128
134
|
if (options.current_approver !== undefined || options.count !== undefined) {
|
|
129
135
|
if (action !== 'query' || resource !== 'process') {
|
|
130
136
|
parseError('--current-approver / --count: data query process');
|
|
@@ -487,6 +493,7 @@ async function fetchFormAliasContext(session, appType, formUuid) {
|
|
|
487
493
|
}
|
|
488
494
|
return {
|
|
489
495
|
...buildComponentAliasMaps(result),
|
|
496
|
+
schemaResult: result,
|
|
490
497
|
fieldInfoById: buildFieldInfoById(result),
|
|
491
498
|
appType,
|
|
492
499
|
formUuid,
|
|
@@ -494,7 +501,7 @@ async function fetchFormAliasContext(session, appType, formUuid) {
|
|
|
494
501
|
}
|
|
495
502
|
|
|
496
503
|
async function resolveAliasContextIfNeeded(session, appType, formUuid, options, jsonValue) {
|
|
497
|
-
if (!shouldResolveAliases(options) || !jsonValue) {
|
|
504
|
+
if ((!shouldResolveAliases(options) && !options.verify_write) || !jsonValue) {
|
|
498
505
|
return null;
|
|
499
506
|
}
|
|
500
507
|
if (!formUuid) {
|
|
@@ -636,6 +643,45 @@ function prepareFormMutationJson(jsonValue, aliasContext) {
|
|
|
636
643
|
return JSON.stringify(normalizeAssociationFormFields(translated, aliasContext));
|
|
637
644
|
}
|
|
638
645
|
|
|
646
|
+
function prepareVerifiedMutation(json, context, options) {
|
|
647
|
+
if (!options.verify_write) {return { json: prepareFormMutationJson(json, context) };}
|
|
648
|
+
let data;
|
|
649
|
+
try {data = JSON.parse(json);} catch {parseError('--data-json / --data-file: JSON');}
|
|
650
|
+
const contract = buildWriteContract(context.schemaResult);
|
|
651
|
+
const compiled = prepareWriteData(data, contract, shouldResolveAliases(options));
|
|
652
|
+
// The contract compiler already resolved scoped aliases. Do not translate canonical IDs again.
|
|
653
|
+
return { json: JSON.stringify(normalizeAssociationFormFields(compiled, context)), contract };
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
async function verifyFormWrite(session, target, formInstId, payload, contract, candidateIds = []) {
|
|
657
|
+
const failure = (code, issues = []) => dataError(code, t(code === 'DATA_WRITE_READBACK_MISMATCH'
|
|
658
|
+
? 'data_verify.mismatch' : 'data_verify.readback_failed'), {
|
|
659
|
+
target: { appType: target.appType, formUuid: target.formUuid, formInstId: formInstId || null },
|
|
660
|
+
partial: { formInstId: formInstId || null, candidateIds: [...new Set(candidateIds)] }, issues, schemaHash: contract.schemaHash,
|
|
661
|
+
mutationAccepted: true, readbackVerified: false, readbackAllowed: !!formInstId,
|
|
662
|
+
retryable: false, retrySafe: false, sideEffectState: formInstId ? 'committed' : 'unknown',
|
|
663
|
+
nextStep: 'readback_existing_instance_do_not_repeat_write',
|
|
664
|
+
});
|
|
665
|
+
if (!formInstId) {failure('DATA_WRITE_READBACK_UNVERIFIED');}
|
|
666
|
+
let response;
|
|
667
|
+
try {
|
|
668
|
+
response = await sendGet(session, target.appType, `/dingtalk/web/${target.appType}/v1/form/getFormDataById.json`, { formInstId });
|
|
669
|
+
} catch {failure('DATA_WRITE_READBACK_UNVERIFIED');}
|
|
670
|
+
const record = isSuccessfulDataResponse(response) ? getFormRecordFromResult(response) : null;
|
|
671
|
+
const formIds = [record?.formUuid, record?.modelUuid].filter(value => value !== undefined && value !== null && value !== '');
|
|
672
|
+
if (!isPlainObject(record) || !formIds.length || formIds.some(id => id !== target.formUuid)
|
|
673
|
+
|| String(record.formInstId || record.id || '') !== String(formInstId)
|
|
674
|
+
|| record.appType !== undefined && record.appType !== target.appType) {
|
|
675
|
+
failure('DATA_WRITE_READBACK_UNVERIFIED', [{ path: '$', code: 'READBACK_TARGET_UNVERIFIED' }]);
|
|
676
|
+
}
|
|
677
|
+
let data = record.formData;
|
|
678
|
+
if (typeof data === 'string') {try {data = JSON.parse(data);} catch {data = null;}}
|
|
679
|
+
const issues = compareWriteData(JSON.parse(payload), data, contract);
|
|
680
|
+
if (issues.length) {failure('DATA_WRITE_READBACK_MISMATCH', issues);}
|
|
681
|
+
return { readbackVerified: true, verification: { schemaHash: contract.schemaHash,
|
|
682
|
+
formInstId, verifiedFields: Object.keys(JSON.parse(payload)) } };
|
|
683
|
+
}
|
|
684
|
+
|
|
639
685
|
/**
|
|
640
686
|
* 归一化 searchFormDatas / searchFormDataIds 的返回结构。
|
|
641
687
|
* 宜搭 API 在不同场景下会返回两种结构:
|
|
@@ -1105,10 +1151,11 @@ async function createForm(positionals, options, session) {
|
|
|
1105
1151
|
const [appType, formUuid] = positionals;
|
|
1106
1152
|
const target = await requireExpectedFormTarget(session, appType, formUuid, options);
|
|
1107
1153
|
const aliasContext = await resolveAliasContextIfNeeded(session, appType, formUuid, options, dataJson);
|
|
1154
|
+
const prepared = prepareVerifiedMutation(dataJson, aliasContext, options);
|
|
1108
1155
|
const params = {
|
|
1109
1156
|
appType,
|
|
1110
1157
|
formUuid,
|
|
1111
|
-
formDataJson:
|
|
1158
|
+
formDataJson: prepared.json,
|
|
1112
1159
|
};
|
|
1113
1160
|
if (options.dept_id) {params.deptId = options.dept_id;}
|
|
1114
1161
|
|
|
@@ -1128,11 +1175,13 @@ async function createForm(positionals, options, session) {
|
|
|
1128
1175
|
);
|
|
1129
1176
|
}
|
|
1130
1177
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1178
|
+
const response = await sendPostOnce(session, appType, `/dingtalk/web/${appType}/v1/form/saveFormData.json`, params);
|
|
1179
|
+
if (!options.verify_write || !isSuccessfulDataResponse(response)) {return printCreateResult(response, 'formInstance', 'formInstId');}
|
|
1180
|
+
const result = normalizeCreateResult(response, 'formInstance', 'formInstId');
|
|
1181
|
+
const candidates = [normalizeResourceId(response.formInstId), normalizeResourceId(isPlainObject(response.content)
|
|
1182
|
+
? response.content.formInstId : response.content)].filter(Boolean);
|
|
1183
|
+
const verified = await verifyFormWrite(session, target, result.idVerified ? result.formInstId : null, prepared.json, prepared.contract, candidates);
|
|
1184
|
+
printResult({ ...result, ...verified });
|
|
1136
1185
|
}
|
|
1137
1186
|
|
|
1138
1187
|
async function updateForm(positionals, options, session) {
|
|
@@ -1149,9 +1198,10 @@ async function updateForm(positionals, options, session) {
|
|
|
1149
1198
|
const record = getFormRecordFromResult(preflight);
|
|
1150
1199
|
requireInstanceTarget(record, target, options.inst_id, ['formInstId']);
|
|
1151
1200
|
const aliasContext = await resolveAliasContextIfNeeded(session, appType, options.form_uuid, options, dataJson);
|
|
1201
|
+
const prepared = prepareVerifiedMutation(dataJson, aliasContext, options);
|
|
1152
1202
|
const params = {
|
|
1153
1203
|
formInstId: options.inst_id,
|
|
1154
|
-
updateFormDataJson:
|
|
1204
|
+
updateFormDataJson: prepared.json,
|
|
1155
1205
|
};
|
|
1156
1206
|
await assertFormUpdatePermissions({
|
|
1157
1207
|
get: (requestPath, query) => sendGet(session, appType, requestPath, query),
|
|
@@ -1161,6 +1211,10 @@ async function updateForm(positionals, options, session) {
|
|
|
1161
1211
|
if (options.use_latest_version) {params.useLatestVersion = options.use_latest_version;}
|
|
1162
1212
|
const result = await sendPostOnce(session, appType, `/dingtalk/web/${appType}/v1/form/updateFormData.json`, params);
|
|
1163
1213
|
assertFormUpdatePermissionResponse(result, updateTarget, 'write');
|
|
1214
|
+
if (options.verify_write && isSuccessfulDataResponse(result)) {
|
|
1215
|
+
const verified = await verifyFormWrite(session, target, options.inst_id, prepared.json, prepared.contract);
|
|
1216
|
+
return printResult({ ...result, formInstId: options.inst_id, ...verified });
|
|
1217
|
+
}
|
|
1164
1218
|
printResult(result);
|
|
1165
1219
|
}
|
|
1166
1220
|
|
|
@@ -1556,6 +1610,9 @@ async function transferProcessTask(positionals, options, session) {
|
|
|
1556
1610
|
}
|
|
1557
1611
|
|
|
1558
1612
|
async function run(args) {
|
|
1613
|
+
if (args.some(arg => arg.startsWith('--verify-write='))) {
|
|
1614
|
+
dataError('DATA_VERIFY_WRITE_UNSUPPORTED', t('data_verify.invalid_usage'), { retrySafe: true, sideEffectState: 'none' });
|
|
1615
|
+
}
|
|
1559
1616
|
if (args.length < 2) {
|
|
1560
1617
|
parseError('缺少必填参数 action 或 resource');
|
|
1561
1618
|
}
|
package/lib/core/sample.js
CHANGED
|
@@ -23,6 +23,7 @@ const { t } = require('./i18n');
|
|
|
23
23
|
// ── Sample 索引表 ─────────────────────────────────────────────────────
|
|
24
24
|
|
|
25
25
|
const SAMPLES = {
|
|
26
|
+
'yida-app': { 'fast-spec': 'fast-app.json' },
|
|
26
27
|
'yida-print-template': Object.fromEntries(require('../print-template/scenes').names.map(name => [name, `${name}.json`])),
|
|
27
28
|
'yida-chart': {
|
|
28
29
|
'line-trend': 'line-trend.js',
|
|
@@ -60,8 +61,11 @@ const SAMPLES = {
|
|
|
60
61
|
'canvas-theme': 'canvas-theme-provider.template.jsx',
|
|
61
62
|
'canvas-navigation': 'canvas-navigation.jsx',
|
|
62
63
|
'canvas-view-state': 'canvas-view-state.jsx',
|
|
64
|
+
'canvas-data-source': 'canvas-data-source.jsx',
|
|
63
65
|
'canvas-responsive-layout': 'canvas-responsive-layout.jsx',
|
|
64
66
|
'canvas-admin-entry': 'canvas-admin-entry.jsx',
|
|
67
|
+
'file-upload-client': 'file-upload-client.jsx',
|
|
68
|
+
'canvas-file-upload': 'canvas-file-upload.jsx',
|
|
65
69
|
'canvas-nav-side': 'canvas-nav/side.jsx',
|
|
66
70
|
'canvas-nav-top': 'canvas-nav/top.jsx',
|
|
67
71
|
'canvas-nav-mixed': 'canvas-nav/mixed.jsx',
|
|
@@ -71,6 +75,7 @@ const SAMPLES = {
|
|
|
71
75
|
'canvas-nav-content': 'canvas-nav/content.jsx',
|
|
72
76
|
},
|
|
73
77
|
'yida-design': {
|
|
78
|
+
'fast-spec': 'fast-design.json',
|
|
74
79
|
'app-theme': 'app-custom-theme-template.css',
|
|
75
80
|
'theme-selector': 'theme-selector.html',
|
|
76
81
|
'theme-preview': 'theme-selector.html',
|
|
@@ -160,6 +165,9 @@ function printSampleList() {
|
|
|
160
165
|
console.log('');
|
|
161
166
|
console.log(' 应用主题:openyida sample yida-design app-theme --output <app-theme.css> --design-file <design.md>');
|
|
162
167
|
console.log(' Application style: openyida sample yida-design application-style --style-id <themeId|free-creative> --output <directory>');
|
|
168
|
+
console.log(' openyida sample yida-app fast-theme --style-id <themeId> --primary-color <color> --output <app_theme.css>');
|
|
169
|
+
console.log(' openyida sample yida-app fast-build --spec-file <fast-app.json> --output <directory> [--check]');
|
|
170
|
+
console.log(' openyida sample yida-design document --spec-file <fast-design.json> --output <design.md>');
|
|
163
171
|
console.log(` ${t('sample_options.theme_help')}`);
|
|
164
172
|
console.log(` ${t('sample_options.style_help')}`);
|
|
165
173
|
}
|
|
@@ -243,6 +251,20 @@ function applyTemplateVariables(content, variables) {
|
|
|
243
251
|
* @param {string[]} args
|
|
244
252
|
*/
|
|
245
253
|
async function run(args) {
|
|
254
|
+
const fastAction = args[0] === 'yida-app' && ['fast-theme', 'fast-build'].includes(args[1]);
|
|
255
|
+
if (fastAction && (args.includes('--help') || args.includes('-h'))) {
|
|
256
|
+
console.log(JSON.stringify(args[1] === 'fast-theme' ? {
|
|
257
|
+
usage: 'sample yida-app fast-theme --style-id <themeId> --primary-color <color> [--output <app_theme.css>] [--tokens-file <theme.json>] [--nav-theme light|dark] [--pop-art-context explicit-request|showcase] [--check] [--json]',
|
|
258
|
+
required: ['--style-id', '--primary-color'], output: 'app_theme.css only',
|
|
259
|
+
scope: 'Theme generation only; no app, business JSON or Plan required. Create/reuse the application independently.',
|
|
260
|
+
} : {
|
|
261
|
+
usage: 'sample yida-app fast-build --spec-file <fast-app.json> [--output <directory>] [--check] [--json]',
|
|
262
|
+
scope: 'Optional legacy context generator; never required before application creation.',
|
|
263
|
+
resourceTypes: ['normal-form', 'process-form', 'report', 'integration'],
|
|
264
|
+
resources: 'Use [] for a display-only website. Display pages belong in pages.',
|
|
265
|
+
}, null, 2));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
246
268
|
// --list 模式
|
|
247
269
|
if (args.includes('--list') || args.includes('--help') || args.includes('-h') || args.length === 0) {
|
|
248
270
|
printSampleList();
|
|
@@ -250,6 +272,57 @@ async function run(args) {
|
|
|
250
272
|
}
|
|
251
273
|
|
|
252
274
|
const [skill, name, ...rest] = args;
|
|
275
|
+
if (skill === 'yida-app' && name === 'fast-theme') {
|
|
276
|
+
const options = {}, flags = { '--style-id': 'styleId', '--primary-color': 'primaryColor',
|
|
277
|
+
'--output': 'output', '--tokens-file': 'tokensFile', '--nav-theme': 'navTheme', '--pop-art-context': 'popArtContext' };
|
|
278
|
+
const seen = new Set();
|
|
279
|
+
for (let index = 0; index < rest.length; index++) {
|
|
280
|
+
const key = rest[index];
|
|
281
|
+
if (seen.has(key)) {throw new CliError(t('cli_argument.invalid', key), { code: 'SAMPLE_ARGUMENT_INVALID' });}
|
|
282
|
+
seen.add(key);
|
|
283
|
+
if (key === '--json') {continue;}
|
|
284
|
+
if (key === '--check') {options.check = true; continue;}
|
|
285
|
+
if (!flags[key] || !rest[index + 1] || rest[index + 1].startsWith('--')) {
|
|
286
|
+
throw new CliError(t('cli_argument.invalid', key), { code: 'SAMPLE_ARGUMENT_INVALID' });
|
|
287
|
+
}
|
|
288
|
+
options[flags[key]] = rest[++index];
|
|
289
|
+
}
|
|
290
|
+
const result = require('../app/fast-theme').prepareFastTheme(options);
|
|
291
|
+
console.log(JSON.stringify(result, null, 2));
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
if (skill === 'yida-app' && name === 'fast-build') {
|
|
295
|
+
const options = {};
|
|
296
|
+
for (let index = 0; index < rest.length; index++) {
|
|
297
|
+
const key = rest[index];
|
|
298
|
+
if (key === '--json' && !options[key]) {options[key] = true; continue;}
|
|
299
|
+
if (key === '--check' && !options[key]) {options[key] = true; continue;}
|
|
300
|
+
if (!['--spec-file', '--output'].includes(key) || options[key] || !rest[index + 1] || rest[index + 1].startsWith('--')) {
|
|
301
|
+
throw new CliError(t('cli_argument.invalid', key), { code: 'SAMPLE_ARGUMENT_INVALID' });
|
|
302
|
+
}
|
|
303
|
+
options[key] = rest[++index];
|
|
304
|
+
}
|
|
305
|
+
if (!options['--spec-file']) {throw new CliError(t('cli_argument.invalid', '--spec-file'), { code: 'SAMPLE_ARGUMENT_INVALID' });}
|
|
306
|
+
const result = require('../app/fast-build').prepareFastBuild(options['--spec-file'],
|
|
307
|
+
options['--output'] || path.join(process.cwd(), '.cache/openyida/fast-app'), { check: options['--check'] });
|
|
308
|
+
console.log(JSON.stringify(result, null, 2));
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
if (skill === 'yida-design' && name === 'document') {
|
|
312
|
+
const options = {};
|
|
313
|
+
for (let index = 0; index < rest.length; index += 2) {
|
|
314
|
+
const key = rest[index], value = rest[index + 1];
|
|
315
|
+
if (!['--spec-file', '--output'].includes(key) || !value || value.startsWith('--') || options[key]) {
|
|
316
|
+
throw new CliError(t('cli_argument.invalid', key), { code: 'SAMPLE_ARGUMENT_INVALID' });
|
|
317
|
+
}
|
|
318
|
+
options[key] = value;
|
|
319
|
+
}
|
|
320
|
+
if (!options['--spec-file']) {throw new CliError(t('cli_argument.invalid', '--spec-file'), { code: 'SAMPLE_ARGUMENT_INVALID' });}
|
|
321
|
+
const result = require('../design/fast-document').generateFastDocument(options['--spec-file'],
|
|
322
|
+
options['--output'] || path.join(process.cwd(), '.cache/samples/design.md'));
|
|
323
|
+
console.log(JSON.stringify(result, null, 2));
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
253
326
|
if (skill === 'yida-design' && name === 'theme-preview') {
|
|
254
327
|
const result = require('./theme-widget').createThemePreview(rest);
|
|
255
328
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { flattenCommandManifest } = require('./command-manifest');
|
|
6
|
+
|
|
7
|
+
function describeTask(tokens, entries = flattenCommandManifest()) {
|
|
8
|
+
const match = entries.flatMap(entry => [entry.path, ...(entry.aliases || []).map(alias => alias.split(' '))]
|
|
9
|
+
.map(parts => ({ entry, parts })))
|
|
10
|
+
.filter(({ parts }) => parts.every((part, i) => tokens[i] === part))
|
|
11
|
+
.sort((a, b) => b.parts.length - a.parts.length)[0];
|
|
12
|
+
const entry = match?.entry;
|
|
13
|
+
const policy = entry?.taskConcurrency;
|
|
14
|
+
const args = tokens.slice(match?.parts.length || 1);
|
|
15
|
+
const barrier = { barrier: true, locks: [], requiresLogin: entry?.requiresLogin !== false };
|
|
16
|
+
if (!policy || policy.forbiddenFlags?.some(flag => args.some(arg => arg.split('=')[0] === flag))) { return barrier; }
|
|
17
|
+
if (policy.kind === 'read') { return { ...barrier, barrier: false }; }
|
|
18
|
+
if (policy.kind !== 'page' || !args[policy.sourcePosition] || args[policy.sourcePosition].startsWith('-')) { return barrier; }
|
|
19
|
+
let source, stat;
|
|
20
|
+
try { source = fs.realpathSync(args[policy.sourcePosition]); stat = fs.statSync(source); } catch { return barrier; }
|
|
21
|
+
if (!stat.isFile()) { return barrier; }
|
|
22
|
+
const stems = [source, args[policy.sourcePosition]].map(file =>
|
|
23
|
+
path.parse(file).name.replace(/(?:\.(?:oyd|openyida|yida))+$/i, '').toLowerCase());
|
|
24
|
+
// Both compilers write to the shared pages/build and pages/dist directories.
|
|
25
|
+
// Inode identity also protects different symlinks/hard links to the same source.
|
|
26
|
+
const locks = [`source:${stat.dev}:${stat.ino}`, ...new Set(stems.map(stem => `page-output:${stem}`))];
|
|
27
|
+
if (policy.appPosition !== undefined) {
|
|
28
|
+
const app = args[policy.appPosition], form = args[policy.formPosition];
|
|
29
|
+
if (!/^APP_[A-Z0-9]+$/i.test(app || '') || !/^FORM-[A-Z0-9]+$/i.test(form || '')) { return barrier; }
|
|
30
|
+
locks.push(`page:${app.toLowerCase()}:${form.toLowerCase()}`);
|
|
31
|
+
}
|
|
32
|
+
return { ...barrier, barrier: false, locks };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function runTaskWave(tasks, options, execute) {
|
|
36
|
+
if (!Number.isInteger(options.concurrency) || options.concurrency < 1 || options.concurrency > 4) {
|
|
37
|
+
throw new RangeError('Task concurrency must be an integer from 1 to 4.');
|
|
38
|
+
}
|
|
39
|
+
const pending = tasks.map((task, index) => ({ task, index }));
|
|
40
|
+
const active = new Map(), results = new Array(tasks.length);
|
|
41
|
+
let peakConcurrency = 0, stopped = false;
|
|
42
|
+
const started = Date.now();
|
|
43
|
+
const launch = ({ task, index }) => {
|
|
44
|
+
const promise = Promise.resolve().then(() => execute(task, index)).catch(error => ({
|
|
45
|
+
command: task.tokens.join(' '), success: false, exitCode: 1, error: error.message,
|
|
46
|
+
})).then(result => {
|
|
47
|
+
results[index] = result;
|
|
48
|
+
if (!result.success && options.stopOnError) { stopped = true; }
|
|
49
|
+
}).finally(() => active.delete(index));
|
|
50
|
+
active.set(index, { policy: task.policy, promise });
|
|
51
|
+
peakConcurrency = Math.max(peakConcurrency, active.size);
|
|
52
|
+
};
|
|
53
|
+
while ((!stopped && pending.length) || active.size) {
|
|
54
|
+
for (let i = 0; !stopped && i < pending.length && active.size < options.concurrency;) {
|
|
55
|
+
const next = pending[i];
|
|
56
|
+
if (next.task.policy.barrier) {
|
|
57
|
+
if (!active.size) { launch(pending.splice(i, 1)[0]); }
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if ([...active.values()].some(item => item.policy.barrier)) { break; }
|
|
61
|
+
if ([...active.values()].some(item => item.policy.locks.some(lock => next.task.policy.locks.includes(lock)))) { i++; continue; }
|
|
62
|
+
launch(pending.splice(i, 1)[0]);
|
|
63
|
+
}
|
|
64
|
+
if (active.size) { await Promise.race([...active.values()].map(item => item.promise)); }
|
|
65
|
+
}
|
|
66
|
+
return { results: results.filter(Boolean), stopped, skipped: pending.length,
|
|
67
|
+
concurrency: options.concurrency, peakConcurrency, elapsed: Date.now() - started };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function buildTaskExecutionPolicy(env = process.env) {
|
|
71
|
+
const allowed = env.OPENYIDA_MANAGED_RUN !== '1';
|
|
72
|
+
return {
|
|
73
|
+
scope: 'single_orchestrator_independent_ready_tasks',
|
|
74
|
+
cli_batch: { available: allowed, command: 'openyida batch <file> --concurrency 3 --json',
|
|
75
|
+
default_concurrency: 1, max_concurrency: 4,
|
|
76
|
+
...(allowed ? {} : { reason: 'generic_batch_not_admitted_in_managed_run' }) },
|
|
77
|
+
delegation: { status: 'host_tool_inventory_required', optional: true,
|
|
78
|
+
use_for: ['independent analysis', 'page authoring', 'visual design', 'verification'],
|
|
79
|
+
required_checks: ['actual tool name and input schema', 'allowed agent types and tools',
|
|
80
|
+
'parallel tool-call support OR nonblocking dispatch with retrievable task results'],
|
|
81
|
+
handoff: ['confirmed requirements and theme', 'input files and dependencies', 'exclusive output files',
|
|
82
|
+
'actual app/page identities', 'required skill instructions or accessible references', 'completion and verification criteria'],
|
|
83
|
+
rules: ['Use available subagents for independent reasoning/authoring branches; ready CLI work can run directly.',
|
|
84
|
+
'A delegation tool alone does not prove concurrent dispatch. Blocking delegation needs verified parallel tool calls; nonblocking delegation needs real handles and result retrieval.',
|
|
85
|
+
'The orchestrator joins results only at dependencies, owns shared settings and verifies outputs. Do not assume inherited skills or credentials.'],
|
|
86
|
+
},
|
|
87
|
+
forms: 'openyida create-form batch <appType> <plan.json> --concurrency 3 --json',
|
|
88
|
+
rules: ['Only batch tasks whose inputs and resource IDs are ready. Put dependent work in a later batch.',
|
|
89
|
+
'Audited reads and independent page compile/publish tasks may overlap. Same page/source/output conflicts wait; other commands are serial barriers.',
|
|
90
|
+
'Stop-on-error stops queued work and waits for already running tasks. Inspect each result before retrying any remote write.',
|
|
91
|
+
'When generic batch is not admitted, use audited command-family batches or actual host parallel tool calls if available. Never bypass managed scope.',
|
|
92
|
+
'CLI task concurrency does not require background Agent or parallel sessions. Background shell is a separate optional host capability.'],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = { describeTask, runTaskWave, buildTaskExecutionPolicy };
|
|
@@ -17,6 +17,7 @@ const { createAuthRef: createCoreAuthRef, createYidaClient, isAuthRefReady } = r
|
|
|
17
17
|
const { c, success, listItem } = require('../core/chalk');
|
|
18
18
|
const { parseOpenOption, withBrowserHandoff } = require('../core/browser-handoff');
|
|
19
19
|
const { throwCommandError } = require('../core/command-errors');
|
|
20
|
+
const { loadLocaleForLanguage } = require('../core/i18n');
|
|
20
21
|
|
|
21
22
|
const API = {
|
|
22
23
|
corpInfoManageCard: '/query/corpadmin/getCorpInfoManageCard.json',
|
|
@@ -32,7 +33,7 @@ const DETAIL_CONSULT_URL = 'https://www.aliwork.com/hybrid_home';
|
|
|
32
33
|
const API_MESSAGES = {
|
|
33
34
|
loginMessage: '登录态已失效,请重新登录',
|
|
34
35
|
};
|
|
35
|
-
const
|
|
36
|
+
const CERTIFICATION_REPORT = {
|
|
36
37
|
appType: 'APP_VTT6NHGPQHR6HW9UUF60',
|
|
37
38
|
reportId: 'REPORT-QQ866JB164A81S0X764WJ97ATDKI33SCLP5EL3',
|
|
38
39
|
topicId: '2558050',
|
|
@@ -133,7 +134,7 @@ function buildCertificationDetailReportUrl(completeAuthNumber) {
|
|
|
133
134
|
const data = completeAuthNumber === null || completeAuthNumber === undefined
|
|
134
135
|
? ''
|
|
135
136
|
: encodeURIComponent(String(completeAuthNumber));
|
|
136
|
-
const { appType, reportId, topicId } =
|
|
137
|
+
const { appType, reportId, topicId } = CERTIFICATION_REPORT;
|
|
137
138
|
return `/${appType}/preview/${reportId}?isPreview=true&topicId=${topicId}&formUuid=${reportId}&data=${data}&navConfig.type=none&navConfig.layout=auto`;
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -294,12 +295,12 @@ function buildPerformanceMetrics(efficacyData = {}, baseUrl) {
|
|
|
294
295
|
}));
|
|
295
296
|
}
|
|
296
297
|
|
|
297
|
-
function buildLearningDetailTargets(efficacyData = {},
|
|
298
|
+
function buildLearningDetailTargets(efficacyData = {}, labels, baseUrl) {
|
|
298
299
|
return [
|
|
299
300
|
createDetailTarget({
|
|
300
301
|
key: 'lowcodeCertification',
|
|
301
302
|
type: 'learning',
|
|
302
|
-
title:
|
|
303
|
+
title: labels.certified_developers,
|
|
303
304
|
data: efficacyData.completeAuthNumber,
|
|
304
305
|
detailReportUrl: buildCertificationDetailReportUrl(efficacyData.completeAuthNumber),
|
|
305
306
|
baseUrl,
|
|
@@ -392,9 +393,14 @@ function sanitizeCommodityInfo(commodityInfo = {}) {
|
|
|
392
393
|
};
|
|
393
394
|
}
|
|
394
395
|
|
|
395
|
-
function formatOverview({ efficacyData = {}, workbenchData = {}, commodityInfo = {}, authRef, raw = false }) {
|
|
396
|
+
function formatOverview({ efficacyData = {}, workbenchData = {}, commodityInfo = {}, authRef, raw = false, locale = 'zh_CN' }) {
|
|
397
|
+
const language = locale.replace(/_/g, '-');
|
|
398
|
+
const dictionary = loadLocaleForLanguage(language)
|
|
399
|
+
|| loadLocaleForLanguage(language.split('-')[0])
|
|
400
|
+
|| {};
|
|
401
|
+
const labels = { ...loadLocaleForLanguage('en').corp_efficiency, ...dictionary.corp_efficiency };
|
|
396
402
|
const performanceMetrics = buildPerformanceMetrics(efficacyData, authRef.baseUrl);
|
|
397
|
-
const learningDetails = buildLearningDetailTargets(efficacyData,
|
|
403
|
+
const learningDetails = buildLearningDetailTargets(efficacyData, labels, authRef.baseUrl);
|
|
398
404
|
|
|
399
405
|
const output = {
|
|
400
406
|
sourcePage: `${authRef.baseUrl}/platformManage/corpEfficiency`,
|
|
@@ -412,8 +418,8 @@ function formatOverview({ efficacyData = {}, workbenchData = {}, commodityInfo =
|
|
|
412
418
|
: (workbenchData.saveMoneyDefaultTip || ''),
|
|
413
419
|
},
|
|
414
420
|
learning: {
|
|
415
|
-
lowcodeStandard:
|
|
416
|
-
lowcodeCertification:
|
|
421
|
+
lowcodeStandard: labels.learning_completed,
|
|
422
|
+
lowcodeCertification: labels.certified_developers,
|
|
417
423
|
completeLessonNumber: efficacyData.completeLessonNumber,
|
|
418
424
|
completeAuthNumber: efficacyData.completeAuthNumber,
|
|
419
425
|
completeStudy: !!efficacyData.completeStudy,
|
|
@@ -457,6 +463,7 @@ async function fetchOverview(flags) {
|
|
|
457
463
|
commodityInfo,
|
|
458
464
|
authRef,
|
|
459
465
|
raw: !!flags.raw,
|
|
466
|
+
locale,
|
|
460
467
|
});
|
|
461
468
|
}
|
|
462
469
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { CliError } = require('../core/cli-error');
|
|
6
|
+
const { t } = require('../core/i18n');
|
|
7
|
+
const { loadThemeIndex } = require('../design-plan/themes');
|
|
8
|
+
const { normalizeCssColorToHex } = require('../app/custom-theme');
|
|
9
|
+
const { parseDesignDocument, serializeDesignDocument, validateDesignDocument } = require('./document');
|
|
10
|
+
|
|
11
|
+
const PAGE_TEXT = ['pageId', 'name', 'sceneKey', 'primaryTask', 'firstScreenFocus', 'layout', 'surface', 'primaryAction', 'states', 'responsive'];
|
|
12
|
+
const filled = value => typeof value === 'string' && value.trim().length > 0;
|
|
13
|
+
const object = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
14
|
+
|
|
15
|
+
// Fast supplies project decisions; the shared renderer owns tokens, YAML,
|
|
16
|
+
// anchors and ordered chapters. No plan, approval or business resource is created.
|
|
17
|
+
function renderFastDocument(spec, options = {}) {
|
|
18
|
+
const issues = [];
|
|
19
|
+
const issue = (field, expected) => issues.push({ path: field, expected });
|
|
20
|
+
if (!object(spec)) {issue('spec', 'object');}
|
|
21
|
+
else {
|
|
22
|
+
for (const field of ['name', 'themeId', 'primaryColor']) {if (!filled(spec[field])) {issue(field, 'nonempty string');}}
|
|
23
|
+
if (!object(spec.direction) || !filled(spec.direction.label) || !filled(spec.direction.description)) {
|
|
24
|
+
issue('direction', { label: '<project direction>', description: '<business-specific visual rationale>' });
|
|
25
|
+
}
|
|
26
|
+
if (!['top', 'side'].includes(spec.navigation?.structure)) {issue('navigation.structure', 'top | side');}
|
|
27
|
+
for (const field of ['tokens', 'appConfig', 'iconSystem', 'creativeDirection']) {
|
|
28
|
+
if (spec[field] !== undefined && !object(spec[field])) {issue(field, 'object');}
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(spec.pages)) {issue('pages', 'array');}
|
|
31
|
+
const ids = new Set();
|
|
32
|
+
for (const [index, page] of (Array.isArray(spec.pages) ? spec.pages : []).entries()) {
|
|
33
|
+
const prefix = `pages[${index}]`;
|
|
34
|
+
if (!object(page)) {issue(prefix, 'object'); continue;}
|
|
35
|
+
for (const field of PAGE_TEXT) {if (!filled(page[field])) {issue(`${prefix}.${field}`, 'nonempty project-specific string');}}
|
|
36
|
+
for (const field of ['blocks', 'acceptanceChecks']) {
|
|
37
|
+
if (!Array.isArray(page[field]) || !page[field].length || !page[field].every(filled)) {issue(`${prefix}.${field}`, 'nonempty string array');}
|
|
38
|
+
}
|
|
39
|
+
if (ids.has(page.pageId)) {issue(`${prefix}.pageId`, 'unique pageId');}
|
|
40
|
+
ids.add(page.pageId);
|
|
41
|
+
if (filled(page.sceneKey) && !/^[\p{L}\p{N}_-]+$/u.test(page.sceneKey)) {issue(`${prefix}.sceneKey`, 'letters, numbers, underscore or hyphen');}
|
|
42
|
+
}
|
|
43
|
+
if (!object(spec.assetStrategy) || !Array.isArray(spec.assetStrategy.pages)) {issue('assetStrategy', { pages: [] });}
|
|
44
|
+
}
|
|
45
|
+
if (issues.length) {
|
|
46
|
+
throw new CliError(t('design_document.invalid', issues[0].path, 'FAST_DESIGN_SPEC_INVALID'), {
|
|
47
|
+
code: 'FAST_DESIGN_SPEC_INVALID', details: { issues },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const theme = loadThemeIndex().themes.find(item => item.themeId === spec.themeId);
|
|
51
|
+
if (!theme) {
|
|
52
|
+
throw new CliError(t('design_document.invalid', 'themeId', 'UNKNOWN_THEME'), {
|
|
53
|
+
code: 'FAST_DESIGN_SPEC_INVALID', details: { themeId: spec.themeId, nextArgv: ['design-plan', 'catalog', '--compact'] },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (theme.themeId === 'app-pop' && !['explicit-request', 'showcase'].includes(spec.popArtContext)) {
|
|
57
|
+
throw new CliError(t('design_document.invalid', 'popArtContext', 'EXPLICIT_CONTEXT_REQUIRED'), {
|
|
58
|
+
code: 'FAST_DESIGN_SPEC_INVALID', details: { allowed: ['explicit-request', 'showcase'] },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (theme.supportedNavigationLayouts && !theme.supportedNavigationLayouts.includes(spec.navigation.structure)) {
|
|
62
|
+
throw new CliError(t('design_document.invalid', 'navigation.structure', 'UNSUPPORTED_NAVIGATION_LAYOUT'), {
|
|
63
|
+
code: 'FAST_DESIGN_SPEC_INVALID', details: { themeId: theme.themeId, supported: theme.supportedNavigationLayouts },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const primaryColor = normalizeCssColorToHex(spec.primaryColor);
|
|
67
|
+
if (!primaryColor) {
|
|
68
|
+
throw new CliError(t('design_document.invalid', 'primaryColor', 'HEX_REQUIRED'), { code: 'FAST_DESIGN_SPEC_INVALID' });
|
|
69
|
+
}
|
|
70
|
+
const plan = {
|
|
71
|
+
schemaVersion: '1.0', meta: { projectName: spec.name, appName: spec.name },
|
|
72
|
+
overview: { summary: spec.summary || spec.direction.description },
|
|
73
|
+
pages: { customPageDetails: spec.pages.map(page => ({ ...page,
|
|
74
|
+
density: page.density || 'comfortable', layoutPattern: { id: page.sceneKey },
|
|
75
|
+
pageSpecHandoff: { scene: page.sceneKey, ...(page.entryMode ? { entryMode: page.entryMode } : {}),
|
|
76
|
+
...(page.navigation ? { navigation: page.navigation } : {}) },
|
|
77
|
+
})) },
|
|
78
|
+
execution: { appConfig: spec.appConfig || {} },
|
|
79
|
+
visualStyle: { tokens: { '--color-brand1-6': primaryColor, ...spec.tokens }, creativeDirection: spec.creativeDirection, forUser: {
|
|
80
|
+
selectedTheme: theme, visualDirection: spec.direction,
|
|
81
|
+
navigationStyle: spec.navigation,
|
|
82
|
+
colorStrategy: { primaryColor, source: spec.colorSource || 'business-inferred' },
|
|
83
|
+
pageApplications: spec.pages, assetStrategy: spec.assetStrategy,
|
|
84
|
+
...(spec.iconSystem ? { iconSystem: spec.iconSystem } : {}),
|
|
85
|
+
} },
|
|
86
|
+
};
|
|
87
|
+
const outputDir = options.outputDir || '.';
|
|
88
|
+
const rendered = require('../design-plan/materialize').renderDesign(plan, { outputDir, draft: true });
|
|
89
|
+
const parsed = parseDesignDocument(rendered);
|
|
90
|
+
delete parsed.metadata.buildPlanRevision;
|
|
91
|
+
const markdown = serializeDesignDocument(parsed);
|
|
92
|
+
const validation = validateDesignDocument(markdown);
|
|
93
|
+
return { markdown, metadata: parsed.metadata, validation };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function generateFastDocument(inputFile, outputFile) {
|
|
97
|
+
const input = path.resolve(inputFile), output = path.resolve(outputFile);
|
|
98
|
+
if (input === output || fs.existsSync(output)) {
|
|
99
|
+
throw new CliError(t('design_document.invalid', output, 'OUTPUT_EXISTS'), { code: 'SAMPLE_OUTPUT_EXISTS' });
|
|
100
|
+
}
|
|
101
|
+
let spec;
|
|
102
|
+
try {spec = JSON.parse(fs.readFileSync(input, 'utf8'));} catch (error) {
|
|
103
|
+
throw new CliError(t('design_document.read_error', input), {
|
|
104
|
+
code: 'FAST_DESIGN_SPEC_INVALID', details: { sourcePath: input, reason: error.code || 'INVALID_JSON' },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const { markdown, metadata, validation } = renderFastDocument(spec, { outputDir: path.dirname(output) });
|
|
108
|
+
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
109
|
+
fs.writeFileSync(output, markdown, { flag: 'wx' });
|
|
110
|
+
return { success: true, mode: 'fast', designFile: output, themeId: spec.themeId, pages: validation.pages,
|
|
111
|
+
tokenCount: validation.tokenCount, sceneRecipes: metadata.sceneRecipes,
|
|
112
|
+
references: { components: Object.keys(metadata.components), states: Object.keys(metadata.states) },
|
|
113
|
+
nextCheckArgv: ['check-design', output, '--json'],
|
|
114
|
+
nextThemeArgv: ['sample', 'yida-design', 'app-theme', '--output', metadata.themeProfile.themeFile, '--design-file', output],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = { renderFastDocument, generateFastDocument };
|
|
@@ -10,7 +10,7 @@ const { preview } = require('./preview');
|
|
|
10
10
|
function usage() {
|
|
11
11
|
return [
|
|
12
12
|
'用法:',
|
|
13
|
-
' openyida design-plan catalog [--json]',
|
|
13
|
+
' openyida design-plan catalog [--compact] [--json]',
|
|
14
14
|
' openyida design-plan init <requirement-brief.json> [--theme-id <id>] [--output-dir <dir>] [--json]',
|
|
15
15
|
' openyida design-plan preview <build-plan.json> --part-file <module.json> [--json]',
|
|
16
16
|
' openyida design-plan materialize <build-plan.json> [--from-preview | --business-file <json> --visual-file <json>] [--output-dir <dir>] [--rebase-parts] [--check] [--json]',
|
|
@@ -52,7 +52,7 @@ function setValues(args) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const OPTION_SCHEMA = Object.freeze({
|
|
55
|
-
catalog: { flags: ['--json'], values: [] },
|
|
55
|
+
catalog: { flags: ['--json', '--compact'], values: [] },
|
|
56
56
|
init: { flags: ['--json'], values: ['--theme-id', '--output-dir'] },
|
|
57
57
|
preview: { flags: ['--json'], values: ['--part-file'] },
|
|
58
58
|
materialize: { flags: ['--from-preview', '--rebase-parts', '--check', '--json'], values: ['--business-file', '--visual-file', '--output-dir'] },
|
|
@@ -105,7 +105,7 @@ async function run(args) {
|
|
|
105
105
|
}
|
|
106
106
|
if (subcommand === 'catalog') {
|
|
107
107
|
assertKnownOptions(subcommand, args.slice(1));
|
|
108
|
-
console.log(JSON.stringify(catalog(), null, 2));
|
|
108
|
+
console.log(JSON.stringify(catalog({ compact: args.includes('--compact') }), null, 2));
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
const input = args[1];
|