openyida 2026.7.13 → 2026.7.14-2
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 +15 -22
- package/bin/yida.js +72 -220
- package/lib/agent-center/api.js +2 -2
- package/lib/aggregate-table/aggregate-table.js +2 -2
- package/lib/ai/ai.js +7 -12
- package/lib/app/canvas-compile.js +2 -2
- package/lib/app/create-app.js +5 -19
- package/lib/app/create-form.js +54 -76
- package/lib/app/create-page.js +4 -19
- package/lib/app/er.js +11 -8
- package/lib/app/export-app.js +2 -2
- package/lib/app/externalize-form.js +12 -10
- package/lib/app/get-schema.js +12 -10
- package/lib/app/import-app.js +6 -22
- package/lib/app/list-forms.js +3 -19
- package/lib/app/nav-group.js +6 -19
- package/lib/app/publish.js +60 -198
- package/lib/app/update-app.js +4 -18
- package/lib/app/update-form-config.js +20 -113
- package/lib/app-permission/app-permission.js +2 -2
- package/lib/auth/oauth-loopback.js +156 -0
- package/lib/auth/org.js +169 -322
- package/lib/auth/token-auth.js +346 -0
- package/lib/auth/token-store.js +174 -0
- package/lib/basic-info/basic-info.js +11 -12
- package/lib/bridge/bridge.js +29 -27
- package/lib/connector/api.js +4 -4
- package/lib/core/agent-capabilities.js +92 -8
- package/lib/core/batch.js +8 -8
- package/lib/core/check-data.js +2 -2
- package/lib/core/command-manifest.js +3 -3
- package/lib/core/doctor.js +19 -22
- package/lib/core/env-cmd.js +1 -3
- package/lib/core/env-manager.js +8 -121
- package/lib/core/env.js +30 -72
- package/lib/core/locales/ar.js +5 -5
- package/lib/core/locales/de.js +5 -5
- package/lib/core/locales/en.js +26 -26
- package/lib/core/locales/es.js +5 -5
- package/lib/core/locales/fr.js +5 -5
- package/lib/core/locales/hi.js +5 -5
- package/lib/core/locales/ja.js +14 -14
- package/lib/core/locales/ko.js +5 -5
- package/lib/core/locales/pt.js +5 -5
- package/lib/core/locales/vi.js +5 -5
- package/lib/core/locales/zh-HK.js +15 -15
- package/lib/core/locales/zh.js +26 -26
- package/lib/core/query-data.js +2 -2
- package/lib/core/task-center.js +2 -2
- package/lib/core/utils.js +156 -400
- package/lib/core/yida-client.js +57 -22
- package/lib/corp-efficiency/corp-efficiency.js +3 -3
- package/lib/corp-manager/api.js +2 -2
- package/lib/db/db-seq-fix.js +20 -25
- package/lib/flash-note/flash-to-prd.js +2 -2
- package/lib/i18n-management/i18n-management.js +2 -2
- package/lib/integration/integration-check.js +10 -7
- package/lib/integration/integration-create.js +11 -8
- package/lib/integration/integration-list.js +11 -8
- package/lib/mcp/server.js +5 -54
- package/lib/page-config/get-page-config.js +2 -2
- package/lib/page-config/save-share-config.js +2 -2
- package/lib/page-config/verify-short-url.js +2 -2
- package/lib/permission/get-permission.js +2 -2
- package/lib/permission/save-permission.js +2 -2
- package/lib/process/ai-form-setting.js +2 -2
- package/lib/process/create-process.js +2 -2
- package/lib/process/preview-process.js +2 -2
- package/lib/report/append.js +3 -3
- package/lib/report/index.js +3 -3
- package/package.json +1 -1
- package/scripts/check-syntax.js +6 -0
- package/scripts/e2e-real/full-runner.js +2 -10
- package/scripts/e2e-real/runner.js +0 -31
- package/scripts/eval/screenshot.js +27 -69
- package/scripts/nightly-smoke.js +16 -34
- package/scripts/postinstall.js +6 -2
- package/yida-skills/SKILL.md +10 -6
- package/yida-skills/references/development-rules.md +2 -2
- package/yida-skills/references/setup-and-env.md +10 -9
- package/yida-skills/skills/sls-log-workbench/SKILL.md +2 -2
- package/yida-skills/skills/sls-log-workbench/sls-query.js +27 -54
- package/yida-skills/skills/yida-flash-note-to-prd/SKILL.md +1 -1
- package/yida-skills/skills/yida-integration/SKILL.md +3 -3
- package/yida-skills/skills/yida-login/SKILL.md +56 -74
- package/yida-skills/skills/yida-logout/SKILL.md +13 -12
- package/yida-skills/skills/yida-process-rule/SKILL.md +1 -1
- package/yida-skills/skills/yida-publish-page/SKILL.md +1 -1
- package/yida-skills/skills/yida-report/references/report-api-guide.md +4 -20
- package/yida-skills/skills-index.json +4 -4
- package/lib/auth/auth.js +0 -313
- package/lib/auth/cdp-browser-login.js +0 -390
- package/lib/auth/codex-login.js +0 -71
- package/lib/auth/login.js +0 -550
- package/lib/auth/qr-login.js +0 -1575
package/lib/app/create-form.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* AttachmentField, ImageField, TableField, AssociationFormField, SerialNumberField
|
|
47
47
|
*
|
|
48
48
|
* 前置条件:
|
|
49
|
-
*
|
|
49
|
+
* 项目根目录下需存在有效 token session(由 openyida login 生成)。
|
|
50
50
|
* 若接口返回 302(登录失效),脚本会自动调用 login.py 重新登录后重试。
|
|
51
51
|
*
|
|
52
52
|
* 示例:
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
const fs = require('fs');
|
|
60
60
|
const path = require('path');
|
|
61
61
|
const querystring = require('querystring');
|
|
62
|
-
const {
|
|
62
|
+
const { loadAuthData, triggerLogin, resolveBaseUrl, httpPost, httpGet, requestWithAutoLogin } = require('../core/utils');
|
|
63
63
|
const { CliError } = require('../core/cli-error');
|
|
64
64
|
const { t } = require('../core/i18n');
|
|
65
65
|
const { buildYidaI18n, normalizeYidaLocale, resolveContentLocale } = require('../core/yida-i18n');
|
|
@@ -2229,8 +2229,8 @@ function buildFormSchema(formTitle, fields, formUuid, corpId, appType, layout, t
|
|
|
2229
2229
|
|
|
2230
2230
|
// ── 发送 GET 请求(支持 302 自动重登录) ─────────────
|
|
2231
2231
|
|
|
2232
|
-
function sendGetRequest(baseUrl,
|
|
2233
|
-
return httpGet(baseUrl, requestPath, queryParams
|
|
2232
|
+
function sendGetRequest(baseUrl, requestPath, queryParams) {
|
|
2233
|
+
return httpGet(baseUrl, requestPath, queryParams);
|
|
2234
2234
|
}
|
|
2235
2235
|
|
|
2236
2236
|
// ── 空白表单 Schema 模板(update 模式) ─────────────
|
|
@@ -4325,19 +4325,19 @@ function applyChangesToSchema(schema, changes) {
|
|
|
4325
4325
|
|
|
4326
4326
|
// ── 发送 POST 请求(支持 302 自动重登录) ────────────
|
|
4327
4327
|
|
|
4328
|
-
function sendPostRequest(baseUrl, csrfToken,
|
|
4328
|
+
function sendPostRequest(baseUrl, csrfToken, requestPath, extraParams, formUuid) {
|
|
4329
4329
|
const postData = querystring.stringify(
|
|
4330
4330
|
Object.assign({ _csrf_token: csrfToken }, extraParams)
|
|
4331
4331
|
);
|
|
4332
4332
|
const referer = formUuid
|
|
4333
4333
|
? `${baseUrl}/alibaba/web/${extraParams.appType || ''}/design/pageDesigner?formUuid=${formUuid}`
|
|
4334
4334
|
: baseUrl + '/';
|
|
4335
|
-
return httpPost(baseUrl, requestPath, postData,
|
|
4335
|
+
return httpPost(baseUrl, requestPath, postData, { referer });
|
|
4336
4336
|
}
|
|
4337
4337
|
|
|
4338
4338
|
// ── 发送 updateFormConfig 请求 ───────────────────────
|
|
4339
4339
|
|
|
4340
|
-
function sendUpdateConfigRequest(baseUrl, csrfToken,
|
|
4340
|
+
function sendUpdateConfigRequest(baseUrl, csrfToken, appType, formUuid, version, value) {
|
|
4341
4341
|
const postData = querystring.stringify({
|
|
4342
4342
|
_csrf_token: csrfToken,
|
|
4343
4343
|
formUuid: formUuid,
|
|
@@ -4348,28 +4348,14 @@ function sendUpdateConfigRequest(baseUrl, csrfToken, cookies, appType, formUuid,
|
|
|
4348
4348
|
return httpPost(
|
|
4349
4349
|
baseUrl,
|
|
4350
4350
|
`/dingtalk/web/${appType}/query/formdesign/updateFormConfig.json`,
|
|
4351
|
-
postData
|
|
4352
|
-
cookies
|
|
4351
|
+
postData
|
|
4353
4352
|
);
|
|
4354
4353
|
}
|
|
4355
4354
|
|
|
4356
|
-
// ── 登录态辅助:从
|
|
4355
|
+
// ── 登录态辅助:从 authData 中提取 corpId ──────────
|
|
4357
4356
|
|
|
4358
|
-
function resolveCorpId(
|
|
4359
|
-
|
|
4360
|
-
if (cookieData.corp_id) {return cookieData.corp_id;}
|
|
4361
|
-
// 从 tianshu_corp_user Cookie 中提取(格式:"{corpId}_{userId}")
|
|
4362
|
-
if (cookieData.cookies) {
|
|
4363
|
-
const corpUserCookie = cookieData.cookies.find(function (c) {
|
|
4364
|
-
return c.name === 'tianshu_corp_user';
|
|
4365
|
-
});
|
|
4366
|
-
if (corpUserCookie && corpUserCookie.value) {
|
|
4367
|
-
const lastUnderscore = corpUserCookie.value.lastIndexOf('_');
|
|
4368
|
-
if (lastUnderscore > 0) {
|
|
4369
|
-
return corpUserCookie.value.slice(0, lastUnderscore);
|
|
4370
|
-
}
|
|
4371
|
-
}
|
|
4372
|
-
}
|
|
4357
|
+
function resolveCorpId(authData) {
|
|
4358
|
+
if (authData && authData.corp_id) {return authData.corp_id;}
|
|
4373
4359
|
return '';
|
|
4374
4360
|
}
|
|
4375
4361
|
|
|
@@ -4392,7 +4378,7 @@ async function saveSchemaAndUpdateConfig(authRef, appType, formUuid, schema, ver
|
|
|
4392
4378
|
|
|
4393
4379
|
const saveResult = await requestWithAutoLogin(function (auth) {
|
|
4394
4380
|
return sendPostRequest(
|
|
4395
|
-
auth.baseUrl, auth.csrfToken,
|
|
4381
|
+
auth.baseUrl, auth.csrfToken,
|
|
4396
4382
|
buildApiPath(appType, 'saveFormSchema', { prefix: '_view' }),
|
|
4397
4383
|
{ appType: appType, formUuid: formUuid, content: JSON.stringify(schema), schemaVersion: 'V5', prefix: '_view' },
|
|
4398
4384
|
formUuid
|
|
@@ -4422,7 +4408,7 @@ async function saveSchemaAndUpdateConfig(authRef, appType, formUuid, schema, ver
|
|
|
4422
4408
|
info(t('create_form.sending_config'));
|
|
4423
4409
|
|
|
4424
4410
|
const configResult = await requestWithAutoLogin(function (auth) {
|
|
4425
|
-
return sendUpdateConfigRequest(auth.baseUrl, auth.csrfToken,
|
|
4411
|
+
return sendUpdateConfigRequest(auth.baseUrl, auth.csrfToken, appType, formUuid, version || 1, 0);
|
|
4426
4412
|
}, authRef);
|
|
4427
4413
|
|
|
4428
4414
|
return { saveResult: saveResult, configResult: configResult };
|
|
@@ -4430,7 +4416,7 @@ async function saveSchemaAndUpdateConfig(authRef, appType, formUuid, schema, ver
|
|
|
4430
4416
|
|
|
4431
4417
|
// ── create 模式主流程 ─────────────────────────────────
|
|
4432
4418
|
|
|
4433
|
-
async function mainCreate(parsedArgs,
|
|
4419
|
+
async function mainCreate(parsedArgs, authRef) {
|
|
4434
4420
|
const { appType, formTitle, fieldsJsonOrFile, layout, theme, labelAlign } = parsedArgs;
|
|
4435
4421
|
|
|
4436
4422
|
banner(t('create_form.create_title'));
|
|
@@ -4438,9 +4424,6 @@ async function mainCreate(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
4438
4424
|
label('Title:', formTitle);
|
|
4439
4425
|
label('Fields:', fieldsJsonOrFile);
|
|
4440
4426
|
|
|
4441
|
-
// 登录态引用对象,供 requestWithAutoLogin 原地更新
|
|
4442
|
-
const authRef = { csrfToken: csrfToken, cookies: cookies, baseUrl: baseUrl, cookieData: cookieData };
|
|
4443
|
-
|
|
4444
4427
|
step(2, t('create_form.step_read_fields', 2));
|
|
4445
4428
|
const { fields, columns, validations } = readFieldsDefinition(fieldsJsonOrFile);
|
|
4446
4429
|
success(t('create_form.fields_loaded', fields.length));
|
|
@@ -4453,7 +4436,7 @@ async function mainCreate(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
4453
4436
|
info(t('create_form.sending_create'));
|
|
4454
4437
|
const createResult = await requestWithAutoLogin(function (auth) {
|
|
4455
4438
|
return sendPostRequest(
|
|
4456
|
-
auth.baseUrl, auth.csrfToken,
|
|
4439
|
+
auth.baseUrl, auth.csrfToken,
|
|
4457
4440
|
buildApiPath(appType, 'saveFormSchemaInfo'),
|
|
4458
4441
|
{ formType: 'receipt', title: JSON.stringify(i18n(formTitle)) }
|
|
4459
4442
|
);
|
|
@@ -4473,7 +4456,7 @@ async function mainCreate(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
4473
4456
|
success(t('create_form.blank_created', formUuid));
|
|
4474
4457
|
|
|
4475
4458
|
// Step 4 & 5: 生成 Schema 并保存,然后更新表单配置
|
|
4476
|
-
const corpId = resolveCorpId(authRef.
|
|
4459
|
+
const corpId = resolveCorpId(authRef.authData);
|
|
4477
4460
|
if (!corpId) {
|
|
4478
4461
|
warn(t('create_form.no_corp_id_warning'));
|
|
4479
4462
|
} else {
|
|
@@ -4561,7 +4544,7 @@ function fillSerialNumberFormulas(components, corpId, appType, formUuid) {
|
|
|
4561
4544
|
//
|
|
4562
4545
|
// 流程:getSchema → 定位目标字段 → 在 dataSource 末尾追加新选项 → saveSchema
|
|
4563
4546
|
|
|
4564
|
-
async function mainAddOption(parsedArgs,
|
|
4547
|
+
async function mainAddOption(parsedArgs, authRef) {
|
|
4565
4548
|
const { appType, formUuid, fieldLabel, newOptions } = parsedArgs;
|
|
4566
4549
|
|
|
4567
4550
|
banner(t('create_form.update_title'));
|
|
@@ -4570,14 +4553,12 @@ async function mainAddOption(parsedArgs, csrfToken, cookies, baseUrl, cookieData
|
|
|
4570
4553
|
label('Field:', fieldLabel);
|
|
4571
4554
|
label('New Options:', newOptions.join(', '));
|
|
4572
4555
|
|
|
4573
|
-
const authRef = { csrfToken, cookies, baseUrl, cookieData };
|
|
4574
|
-
|
|
4575
4556
|
// Step 2: 获取 Schema
|
|
4576
4557
|
step(2, t('create_form.step_get_schema', 2));
|
|
4577
4558
|
info(t('create_form.sending_get_schema'));
|
|
4578
4559
|
const schemaResult = await requestWithAutoLogin(function (auth) {
|
|
4579
4560
|
return sendGetRequest(
|
|
4580
|
-
auth.baseUrl,
|
|
4561
|
+
auth.baseUrl,
|
|
4581
4562
|
buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
|
|
4582
4563
|
{ formUuid, schemaVersion: 'V5' }
|
|
4583
4564
|
);
|
|
@@ -4731,7 +4712,7 @@ async function mainAddOption(parsedArgs, csrfToken, cookies, baseUrl, cookieData
|
|
|
4731
4712
|
|
|
4732
4713
|
// ── bind-datasource 模式:给选项类字段绑定远程搜索数据源 ──
|
|
4733
4714
|
|
|
4734
|
-
async function mainBindDataSource(parsedArgs,
|
|
4715
|
+
async function mainBindDataSource(parsedArgs, authRef) {
|
|
4735
4716
|
const { appType, formUuid, fieldLabel, dataSourceJsonOrFile } = parsedArgs;
|
|
4736
4717
|
|
|
4737
4718
|
banner(t('create_form.update_title'));
|
|
@@ -4740,13 +4721,11 @@ async function mainBindDataSource(parsedArgs, csrfToken, cookies, baseUrl, cooki
|
|
|
4740
4721
|
label('Field:', fieldLabel);
|
|
4741
4722
|
label('Data Source:', dataSourceJsonOrFile);
|
|
4742
4723
|
|
|
4743
|
-
const authRef = { csrfToken, cookies, baseUrl, cookieData };
|
|
4744
|
-
|
|
4745
4724
|
step(2, t('create_form.step_get_schema', 2));
|
|
4746
4725
|
info(t('create_form.sending_get_schema'));
|
|
4747
4726
|
const schemaResult = await requestWithAutoLogin(function (auth) {
|
|
4748
4727
|
return sendGetRequest(
|
|
4749
|
-
auth.baseUrl,
|
|
4728
|
+
auth.baseUrl,
|
|
4750
4729
|
buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
|
|
4751
4730
|
{ formUuid: formUuid, schemaVersion: 'V5' }
|
|
4752
4731
|
);
|
|
@@ -4834,7 +4813,7 @@ async function mainBindDataSource(parsedArgs, csrfToken, cookies, baseUrl, cooki
|
|
|
4834
4813
|
label('URL:', normalized.url || '(仅初始化选项)');
|
|
4835
4814
|
label('Options:', String(normalized.options.length));
|
|
4836
4815
|
|
|
4837
|
-
const corpId = resolveCorpId(authRef.
|
|
4816
|
+
const corpId = resolveCorpId(authRef.authData);
|
|
4838
4817
|
if (formContainer && formContainer.children) {
|
|
4839
4818
|
fillSerialNumberFormulas(formContainer.children, corpId, appType, formUuid);
|
|
4840
4819
|
}
|
|
@@ -4880,7 +4859,7 @@ async function mainBindDataSource(parsedArgs, csrfToken, cookies, baseUrl, cooki
|
|
|
4880
4859
|
|
|
4881
4860
|
// ── rule 模式主流程:声明式字段联动 / 自动赋值 ─────────
|
|
4882
4861
|
|
|
4883
|
-
async function mainRule(parsedArgs,
|
|
4862
|
+
async function mainRule(parsedArgs, authRef) {
|
|
4884
4863
|
const { appType, formUuid, rulesJsonOrFile } = parsedArgs;
|
|
4885
4864
|
|
|
4886
4865
|
banner(t('create_form.update_title'));
|
|
@@ -4888,13 +4867,11 @@ async function mainRule(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
4888
4867
|
label('Form UUID:', formUuid);
|
|
4889
4868
|
label('Rules:', rulesJsonOrFile);
|
|
4890
4869
|
|
|
4891
|
-
const authRef = { csrfToken, cookies, baseUrl, cookieData };
|
|
4892
|
-
|
|
4893
4870
|
step(2, t('create_form.step_get_schema', 2));
|
|
4894
4871
|
info(t('create_form.sending_get_schema'));
|
|
4895
4872
|
const schemaResult = await requestWithAutoLogin(function (auth) {
|
|
4896
4873
|
return sendGetRequest(
|
|
4897
|
-
auth.baseUrl,
|
|
4874
|
+
auth.baseUrl,
|
|
4898
4875
|
buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
|
|
4899
4876
|
{ formUuid: formUuid, schemaVersion: 'V5' }
|
|
4900
4877
|
);
|
|
@@ -4958,7 +4935,7 @@ async function mainRule(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
4958
4935
|
listItem((index + 1) + '. ' + rule.type + ' -> ' + (rule.targetFieldId || (rule.targetFieldIds || []).join(', ')));
|
|
4959
4936
|
});
|
|
4960
4937
|
|
|
4961
|
-
const corpId = resolveCorpId(authRef.
|
|
4938
|
+
const corpId = resolveCorpId(authRef.authData);
|
|
4962
4939
|
const formContainer = schema.pages && schema.pages[0] && schema.pages[0].componentsTree
|
|
4963
4940
|
? findFormContainer(schema.pages[0].componentsTree[0])
|
|
4964
4941
|
: null;
|
|
@@ -5009,7 +4986,7 @@ async function mainRule(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5009
4986
|
|
|
5010
4987
|
// ── patch 模式主流程 ──────────────────────────────────
|
|
5011
4988
|
|
|
5012
|
-
async function mainPatch(parsedArgs,
|
|
4989
|
+
async function mainPatch(parsedArgs, authRef) {
|
|
5013
4990
|
const { appType, formUuid, patchJsonOrFile } = parsedArgs;
|
|
5014
4991
|
|
|
5015
4992
|
banner(t('create_form.update_title'));
|
|
@@ -5017,13 +4994,11 @@ async function mainPatch(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5017
4994
|
label('Form UUID:', formUuid);
|
|
5018
4995
|
label('Patch:', patchJsonOrFile);
|
|
5019
4996
|
|
|
5020
|
-
const authRef = { csrfToken, cookies, baseUrl, cookieData };
|
|
5021
|
-
|
|
5022
4997
|
step(2, t('create_form.step_get_schema', 2));
|
|
5023
4998
|
info(t('create_form.sending_get_schema'));
|
|
5024
4999
|
const schemaResult = await requestWithAutoLogin(function (auth) {
|
|
5025
5000
|
return sendGetRequest(
|
|
5026
|
-
auth.baseUrl,
|
|
5001
|
+
auth.baseUrl,
|
|
5027
5002
|
buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
|
|
5028
5003
|
{ formUuid: formUuid, schemaVersion: 'V5' }
|
|
5029
5004
|
);
|
|
@@ -5086,7 +5061,7 @@ async function mainPatch(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5086
5061
|
listItem((index + 1) + '. ' + operation.action + (operation.field ? ' ' + operation.field : '') + (operation.path ? ' ' + operation.path : ''));
|
|
5087
5062
|
});
|
|
5088
5063
|
|
|
5089
|
-
const corpId = resolveCorpId(authRef.
|
|
5064
|
+
const corpId = resolveCorpId(authRef.authData);
|
|
5090
5065
|
const formContainer = schema.pages && schema.pages[0] && schema.pages[0].componentsTree
|
|
5091
5066
|
? findFormContainer(schema.pages[0].componentsTree[0])
|
|
5092
5067
|
: null;
|
|
@@ -5123,7 +5098,7 @@ async function mainPatch(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5123
5098
|
|
|
5124
5099
|
// ── validation 模式主流程:字段原生校验 ───────────────
|
|
5125
5100
|
|
|
5126
|
-
async function mainValidation(parsedArgs,
|
|
5101
|
+
async function mainValidation(parsedArgs, authRef) {
|
|
5127
5102
|
const { appType, formUuid, validationJsonOrFile, inlineValidationRule } = parsedArgs;
|
|
5128
5103
|
|
|
5129
5104
|
banner(t('create_form.update_title'));
|
|
@@ -5131,13 +5106,11 @@ async function mainValidation(parsedArgs, csrfToken, cookies, baseUrl, cookieDat
|
|
|
5131
5106
|
label('Form UUID:', formUuid);
|
|
5132
5107
|
label('Validation:', inlineValidationRule ? JSON.stringify(inlineValidationRule) : validationJsonOrFile);
|
|
5133
5108
|
|
|
5134
|
-
const authRef = { csrfToken, cookies, baseUrl, cookieData };
|
|
5135
|
-
|
|
5136
5109
|
step(2, t('create_form.step_get_schema', 2));
|
|
5137
5110
|
info(t('create_form.sending_get_schema'));
|
|
5138
5111
|
const schemaResult = await requestWithAutoLogin(function (auth) {
|
|
5139
5112
|
return sendGetRequest(
|
|
5140
|
-
auth.baseUrl,
|
|
5113
|
+
auth.baseUrl,
|
|
5141
5114
|
buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
|
|
5142
5115
|
{ formUuid: formUuid, schemaVersion: 'V5' }
|
|
5143
5116
|
);
|
|
@@ -5201,7 +5174,7 @@ async function mainValidation(parsedArgs, csrfToken, cookies, baseUrl, cookieDat
|
|
|
5201
5174
|
listItem((index + 1) + '. ' + rule.type + ' -> ' + (rule.fieldLabel || rule.fieldId));
|
|
5202
5175
|
});
|
|
5203
5176
|
|
|
5204
|
-
const corpId = resolveCorpId(authRef.
|
|
5177
|
+
const corpId = resolveCorpId(authRef.authData);
|
|
5205
5178
|
const formContainer = schema.pages && schema.pages[0] && schema.pages[0].componentsTree
|
|
5206
5179
|
? findFormContainer(schema.pages[0].componentsTree[0])
|
|
5207
5180
|
: null;
|
|
@@ -5253,7 +5226,7 @@ async function mainValidation(parsedArgs, csrfToken, cookies, baseUrl, cookieDat
|
|
|
5253
5226
|
|
|
5254
5227
|
// ── update 模式主流程 ─────────────────────────────────
|
|
5255
5228
|
|
|
5256
|
-
async function mainUpdate(parsedArgs,
|
|
5229
|
+
async function mainUpdate(parsedArgs, authRef) {
|
|
5257
5230
|
const { appType, formUuid, changesJsonOrFile } = parsedArgs;
|
|
5258
5231
|
|
|
5259
5232
|
banner(t('create_form.update_title'));
|
|
@@ -5261,14 +5234,11 @@ async function mainUpdate(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5261
5234
|
label('Form UUID:', formUuid);
|
|
5262
5235
|
label('Changes:', changesJsonOrFile);
|
|
5263
5236
|
|
|
5264
|
-
// 登录态引用对象,供 requestWithAutoLogin 原地更新
|
|
5265
|
-
const authRef = { csrfToken: csrfToken, cookies: cookies, baseUrl: baseUrl, cookieData: cookieData };
|
|
5266
|
-
|
|
5267
5237
|
step(2, t('create_form.step_get_schema', 2));
|
|
5268
5238
|
info(t('create_form.sending_get_schema'));
|
|
5269
5239
|
const schemaResult = await requestWithAutoLogin(function (auth) {
|
|
5270
5240
|
return sendGetRequest(
|
|
5271
|
-
auth.baseUrl,
|
|
5241
|
+
auth.baseUrl,
|
|
5272
5242
|
buildApiPath(appType, 'getFormSchema', { prefix: '_view', namespace: 'alibaba' }),
|
|
5273
5243
|
{ formUuid: formUuid, schemaVersion: 'V5' }
|
|
5274
5244
|
);
|
|
@@ -5329,7 +5299,7 @@ async function mainUpdate(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5329
5299
|
step(3, t('create_form.step_check_data', 3));
|
|
5330
5300
|
const dataCheckResult = await requestWithAutoLogin(function (auth) {
|
|
5331
5301
|
return sendGetRequest(
|
|
5332
|
-
auth.baseUrl,
|
|
5302
|
+
auth.baseUrl,
|
|
5333
5303
|
'/dingtalk/web/' + appType + '/v1/form/searchFormDatas.json',
|
|
5334
5304
|
{ formUuid: formUuid, appType: appType, currentPage: '1', pageSize: '1' }
|
|
5335
5305
|
);
|
|
@@ -5383,7 +5353,7 @@ async function mainUpdate(parsedArgs, csrfToken, cookies, baseUrl, cookieData) {
|
|
|
5383
5353
|
const appliedChanges = applyChangesToSchema(schema, changes);
|
|
5384
5354
|
|
|
5385
5355
|
// 为 SerialNumberField 补全 formula(若尚未设置)
|
|
5386
|
-
const corpId = resolveCorpId(authRef.
|
|
5356
|
+
const corpId = resolveCorpId(authRef.authData);
|
|
5387
5357
|
if (!corpId) {
|
|
5388
5358
|
warn(t('create_form.no_corp_id_warning'));
|
|
5389
5359
|
}
|
|
@@ -5433,30 +5403,38 @@ async function run(args) {
|
|
|
5433
5403
|
const parsedArgs = parseArgs(args);
|
|
5434
5404
|
|
|
5435
5405
|
step(1, t('common.step_login', 1));
|
|
5436
|
-
let
|
|
5437
|
-
if (!
|
|
5406
|
+
let authData = loadAuthData();
|
|
5407
|
+
if (!authData) {
|
|
5438
5408
|
warn(t('common.login_no_cache'));
|
|
5439
|
-
|
|
5409
|
+
authData = triggerLogin();
|
|
5440
5410
|
}
|
|
5441
|
-
const
|
|
5442
|
-
const
|
|
5411
|
+
const baseUrl = resolveBaseUrl(authData);
|
|
5412
|
+
const authRef = {
|
|
5413
|
+
csrfToken: authData.csrf_token,
|
|
5414
|
+
baseUrl,
|
|
5415
|
+
authData,
|
|
5416
|
+
authMode: authData.auth_mode || '',
|
|
5417
|
+
authSource: authData.auth_source || '',
|
|
5418
|
+
corpId: authData.corp_id || '',
|
|
5419
|
+
userId: authData.user_id || '',
|
|
5420
|
+
};
|
|
5443
5421
|
success(t('common.login_ready', baseUrl));
|
|
5444
5422
|
label('Locale:', resolveContentLocale({ locale: parsedArgs.contentLocale, baseUrl: baseUrl }));
|
|
5445
5423
|
|
|
5446
5424
|
if (parsedArgs.mode === 'update') {
|
|
5447
|
-
return mainUpdate(parsedArgs,
|
|
5425
|
+
return mainUpdate(parsedArgs, authRef);
|
|
5448
5426
|
} else if (parsedArgs.mode === 'patch') {
|
|
5449
|
-
return mainPatch(parsedArgs,
|
|
5427
|
+
return mainPatch(parsedArgs, authRef);
|
|
5450
5428
|
} else if (parsedArgs.mode === 'rule') {
|
|
5451
|
-
return mainRule(parsedArgs,
|
|
5429
|
+
return mainRule(parsedArgs, authRef);
|
|
5452
5430
|
} else if (parsedArgs.mode === 'validation') {
|
|
5453
|
-
return mainValidation(parsedArgs,
|
|
5431
|
+
return mainValidation(parsedArgs, authRef);
|
|
5454
5432
|
} else if (parsedArgs.mode === 'bind-datasource') {
|
|
5455
|
-
return mainBindDataSource(parsedArgs,
|
|
5433
|
+
return mainBindDataSource(parsedArgs, authRef);
|
|
5456
5434
|
} else if (parsedArgs.mode === 'add-option') {
|
|
5457
|
-
return mainAddOption(parsedArgs,
|
|
5435
|
+
return mainAddOption(parsedArgs, authRef);
|
|
5458
5436
|
} else {
|
|
5459
|
-
return mainCreate(parsedArgs,
|
|
5437
|
+
return mainCreate(parsedArgs, authRef);
|
|
5460
5438
|
}
|
|
5461
5439
|
}
|
|
5462
5440
|
|
package/lib/app/create-page.js
CHANGED
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
const querystring = require('querystring');
|
|
10
10
|
const {
|
|
11
|
-
loadCookieData,
|
|
12
|
-
triggerLogin,
|
|
13
|
-
resolveBaseUrl,
|
|
14
11
|
httpPost,
|
|
15
12
|
requestWithAutoLogin,
|
|
16
13
|
} = require('../core/utils');
|
|
14
|
+
const { createAuthRef } = require('../core/yida-client');
|
|
17
15
|
const { t } = require('../core/i18n');
|
|
18
16
|
const { buildYidaI18n, buildYidaTitleI18n, normalizeYidaLocale, resolveContentLocale } = require('../core/yida-i18n');
|
|
19
17
|
const { parseOpenOption, withBrowserHandoff } = require('../core/browser-handoff');
|
|
@@ -92,8 +90,7 @@ async function configureDashboardMode(authRef, appType, pageId, pageName) {
|
|
|
92
90
|
return httpPost(
|
|
93
91
|
auth.baseUrl,
|
|
94
92
|
`/dingtalk/web/${appType}/query/formdesign/updateFormSchemaInfo.json`,
|
|
95
|
-
buildPageInfoPostData(auth.csrfToken, pageId, pageName, false)
|
|
96
|
-
auth.cookies
|
|
93
|
+
buildPageInfoPostData(auth.csrfToken, pageId, pageName, false)
|
|
97
94
|
);
|
|
98
95
|
}, authRef);
|
|
99
96
|
}
|
|
@@ -129,18 +126,7 @@ async function run(args) {
|
|
|
129
126
|
|
|
130
127
|
// Step 1: 读取登录态
|
|
131
128
|
step(1, t('common.step_login', 1));
|
|
132
|
-
|
|
133
|
-
if (!cookieData) {
|
|
134
|
-
info(t('common.login_no_cache'));
|
|
135
|
-
cookieData = triggerLogin();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const authRef = {
|
|
139
|
-
csrfToken: cookieData.csrf_token,
|
|
140
|
-
cookies: cookieData.cookies,
|
|
141
|
-
baseUrl: resolveBaseUrl(cookieData),
|
|
142
|
-
cookieData,
|
|
143
|
-
};
|
|
129
|
+
const authRef = createAuthRef();
|
|
144
130
|
chalkSuccess(t('common.login_ready', authRef.baseUrl));
|
|
145
131
|
|
|
146
132
|
const contentLocale = resolveContentLocale({ locale: options.locale, baseUrl: authRef.baseUrl });
|
|
@@ -159,8 +145,7 @@ async function run(args) {
|
|
|
159
145
|
return httpPost(
|
|
160
146
|
auth.baseUrl,
|
|
161
147
|
`/dingtalk/web/${appType}/query/formdesign/saveFormSchemaInfo.json`,
|
|
162
|
-
postData
|
|
163
|
-
auth.cookies
|
|
148
|
+
postData
|
|
164
149
|
);
|
|
165
150
|
}, authRef);
|
|
166
151
|
|
package/lib/app/er.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const {
|
|
6
|
-
|
|
6
|
+
loadAuthData,
|
|
7
7
|
triggerLogin,
|
|
8
8
|
resolveBaseUrl,
|
|
9
9
|
} = require('../core/utils');
|
|
@@ -581,17 +581,20 @@ function createAuthRef() {
|
|
|
581
581
|
const { step, info, success: chalkSuccess } = require('../core/chalk');
|
|
582
582
|
|
|
583
583
|
step(1, t('common.step_login', 1));
|
|
584
|
-
let
|
|
585
|
-
if (!
|
|
584
|
+
let authData = loadAuthData();
|
|
585
|
+
if (!authData) {
|
|
586
586
|
info(t('common.login_no_cache'));
|
|
587
|
-
|
|
587
|
+
authData = triggerLogin();
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
const authRef = {
|
|
591
|
-
csrfToken:
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
csrfToken: authData.csrf_token,
|
|
592
|
+
baseUrl: resolveBaseUrl(authData),
|
|
593
|
+
authData,
|
|
594
|
+
authMode: authData.auth_mode || '',
|
|
595
|
+
authSource: authData.auth_source || '',
|
|
596
|
+
corpId: authData.corp_id || '',
|
|
597
|
+
userId: authData.user_id || '',
|
|
595
598
|
};
|
|
596
599
|
chalkSuccess(t('common.login_ready', authRef.baseUrl));
|
|
597
600
|
return authRef;
|
package/lib/app/export-app.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const { CliError } = require('../core/cli-error');
|
|
14
|
-
const { createAuthRef, createYidaClient } = require('../core/yida-client');
|
|
14
|
+
const { createAuthRef, createYidaClient, isAuthRefReady } = require('../core/yida-client');
|
|
15
15
|
const { t } = require('../core/i18n');
|
|
16
16
|
const { fetchFormPageList } = require('./form-navigation');
|
|
17
17
|
|
|
@@ -32,7 +32,7 @@ async function fetchFormSchema(appType, formUuid, authRef) {
|
|
|
32
32
|
|
|
33
33
|
function ensureSession() {
|
|
34
34
|
const authRef = createAuthRef();
|
|
35
|
-
if (!authRef
|
|
35
|
+
if (!isAuthRefReady(authRef)) {
|
|
36
36
|
throw new CliError(t('common.no_login_cache'), {
|
|
37
37
|
code: 'NEED_LOGIN',
|
|
38
38
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const {
|
|
6
|
-
|
|
6
|
+
loadAuthData,
|
|
7
7
|
triggerLogin,
|
|
8
8
|
resolveBaseUrl,
|
|
9
9
|
httpGet,
|
|
@@ -529,15 +529,18 @@ function loadSchemaFile(filePath) {
|
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
function createAuthRef() {
|
|
532
|
-
let
|
|
533
|
-
if (!
|
|
534
|
-
|
|
532
|
+
let authData = loadAuthData();
|
|
533
|
+
if (!authData) {
|
|
534
|
+
authData = triggerLogin();
|
|
535
535
|
}
|
|
536
536
|
return {
|
|
537
|
-
csrfToken:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
537
|
+
csrfToken: authData.csrf_token,
|
|
538
|
+
baseUrl: resolveBaseUrl(authData),
|
|
539
|
+
authData,
|
|
540
|
+
authMode: authData.auth_mode || '',
|
|
541
|
+
authSource: authData.auth_source || '',
|
|
542
|
+
corpId: authData.corp_id || '',
|
|
543
|
+
userId: authData.user_id || '',
|
|
541
544
|
};
|
|
542
545
|
}
|
|
543
546
|
|
|
@@ -546,8 +549,7 @@ async function fetchSchema(appType, formUuid, authRef) {
|
|
|
546
549
|
return httpGet(
|
|
547
550
|
auth.baseUrl,
|
|
548
551
|
`/alibaba/web/${appType}/_view/query/formdesign/getFormSchema.json`,
|
|
549
|
-
{ formUuid, schemaVersion: 'V5' }
|
|
550
|
-
auth.cookies
|
|
552
|
+
{ formUuid, schemaVersion: 'V5' }
|
|
551
553
|
);
|
|
552
554
|
}, authRef);
|
|
553
555
|
}
|
package/lib/app/get-schema.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const {
|
|
14
|
-
|
|
14
|
+
loadAuthData,
|
|
15
15
|
triggerLogin,
|
|
16
16
|
resolveBaseUrl,
|
|
17
17
|
httpGet,
|
|
@@ -322,17 +322,20 @@ function createAuthRef() {
|
|
|
322
322
|
|
|
323
323
|
// Step 1: 读取登录态
|
|
324
324
|
step(1, t('common.step_login', 1));
|
|
325
|
-
let
|
|
326
|
-
if (!
|
|
325
|
+
let authData = loadAuthData();
|
|
326
|
+
if (!authData) {
|
|
327
327
|
info(t('common.login_no_cache'));
|
|
328
|
-
|
|
328
|
+
authData = triggerLogin();
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
const authRef = {
|
|
332
|
-
csrfToken:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
332
|
+
csrfToken: authData.csrf_token,
|
|
333
|
+
baseUrl: resolveBaseUrl(authData),
|
|
334
|
+
authData,
|
|
335
|
+
authMode: authData.auth_mode || '',
|
|
336
|
+
authSource: authData.auth_source || '',
|
|
337
|
+
corpId: authData.corp_id || '',
|
|
338
|
+
userId: authData.user_id || '',
|
|
336
339
|
};
|
|
337
340
|
chalkSuccess(t('common.login_ready', authRef.baseUrl));
|
|
338
341
|
return authRef;
|
|
@@ -343,8 +346,7 @@ async function fetchSchema(appType, formUuid, authRef) {
|
|
|
343
346
|
return httpGet(
|
|
344
347
|
auth.baseUrl,
|
|
345
348
|
`/alibaba/web/${appType}/_view/query/formdesign/getFormSchema.json`,
|
|
346
|
-
{ formUuid, schemaVersion: 'V5' }
|
|
347
|
-
auth.cookies
|
|
349
|
+
{ formUuid, schemaVersion: 'V5' }
|
|
348
350
|
);
|
|
349
351
|
}, authRef);
|
|
350
352
|
}
|
package/lib/app/import-app.js
CHANGED
|
@@ -12,12 +12,10 @@ const fs = require('fs');
|
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const querystring = require('querystring');
|
|
14
14
|
const {
|
|
15
|
-
loadCookieData,
|
|
16
|
-
triggerLogin,
|
|
17
|
-
resolveBaseUrl,
|
|
18
15
|
httpPost,
|
|
19
16
|
requestWithAutoLogin,
|
|
20
17
|
} = require('../core/utils');
|
|
18
|
+
const { createAuthRef } = require('../core/yida-client');
|
|
21
19
|
const { t } = require('../core/i18n');
|
|
22
20
|
const { buildYidaI18n, resolveContentLocale } = require('../core/yida-i18n');
|
|
23
21
|
const { banner, step, label, success, fail, warn, info, error, result, usage, hint } = require('../core/chalk');
|
|
@@ -42,7 +40,7 @@ async function createApp(appName, authRef) {
|
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
const result = await requestWithAutoLogin((auth) => {
|
|
45
|
-
return httpPost(auth.baseUrl, '/query/app/registerApp.json', postData
|
|
43
|
+
return httpPost(auth.baseUrl, '/query/app/registerApp.json', postData);
|
|
46
44
|
}, authRef);
|
|
47
45
|
|
|
48
46
|
if (!result || !result.success || !result.content) {
|
|
@@ -76,8 +74,7 @@ async function createBlankForm(appType, formTitle, authRef, formType = 'receipt'
|
|
|
76
74
|
return httpPost(
|
|
77
75
|
auth.baseUrl,
|
|
78
76
|
`/dingtalk/web/${appType}/query/formdesign/saveFormSchemaInfo.json`,
|
|
79
|
-
postData
|
|
80
|
-
auth.cookies
|
|
77
|
+
postData
|
|
81
78
|
);
|
|
82
79
|
}, authRef);
|
|
83
80
|
|
|
@@ -108,8 +105,7 @@ async function saveFormSchema(appType, formUuid, schema, authRef, formType = 're
|
|
|
108
105
|
return httpPost(
|
|
109
106
|
auth.baseUrl,
|
|
110
107
|
`/alibaba/web/${appType}/_view/query/formdesign/saveFormSchema.json`,
|
|
111
|
-
postData
|
|
112
|
-
auth.cookies
|
|
108
|
+
postData
|
|
113
109
|
);
|
|
114
110
|
}, authRef);
|
|
115
111
|
|
|
@@ -131,8 +127,7 @@ async function updateFormConfig(appType, formUuid, authRef) {
|
|
|
131
127
|
return httpPost(
|
|
132
128
|
auth.baseUrl,
|
|
133
129
|
`/dingtalk/web/${appType}/query/formdesign/updateFormConfig.json`,
|
|
134
|
-
postData
|
|
135
|
-
auth.cookies
|
|
130
|
+
postData
|
|
136
131
|
);
|
|
137
132
|
}, authRef);
|
|
138
133
|
|
|
@@ -222,18 +217,7 @@ async function run(args) {
|
|
|
222
217
|
label('Target Name:', appName);
|
|
223
218
|
|
|
224
219
|
step(2, t('common.step_login_label'));
|
|
225
|
-
|
|
226
|
-
if (!cookieData) {
|
|
227
|
-
warn(t('common.no_login_cache'));
|
|
228
|
-
cookieData = triggerLogin();
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const authRef = {
|
|
232
|
-
csrfToken: cookieData.csrf_token,
|
|
233
|
-
cookies: cookieData.cookies,
|
|
234
|
-
baseUrl: resolveBaseUrl(cookieData),
|
|
235
|
-
cookieData,
|
|
236
|
-
};
|
|
220
|
+
const authRef = createAuthRef();
|
|
237
221
|
success(t('common.login_ready', authRef.baseUrl));
|
|
238
222
|
|
|
239
223
|
step(3, t('import.step_create_app'));
|