openyida 2026.7.14-2 → 2026.7.17-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/bin/yida.js +0 -12
- package/lib/agent-center/api.js +2 -3
- package/lib/aggregate-table/aggregate-table.js +6 -8
- package/lib/ai/ai.js +10 -15
- package/lib/app/app-list.js +4 -6
- package/lib/app/create-app.js +1 -2
- package/lib/app/create-form.js +6 -10
- package/lib/app/create-page.js +2 -4
- package/lib/app/er.js +0 -1
- package/lib/app/externalize-form.js +1 -2
- package/lib/app/get-schema.js +1 -2
- package/lib/app/import-app.js +2 -6
- package/lib/app/list-forms.js +2 -2
- package/lib/app/nav-group.js +3 -4
- package/lib/app/publish.js +5 -15
- package/lib/app/update-app.js +0 -1
- package/lib/app/update-form-config.js +3 -5
- package/lib/app-permission/app-permission.js +1 -2
- package/lib/auth/token-auth.js +134 -20
- package/lib/auth/token-store.js +43 -1
- package/lib/basic-info/basic-info.js +1 -8
- package/lib/bridge/bridge.js +1 -1
- package/lib/connector/api.js +1 -4
- package/lib/core/check-data.js +1 -2
- package/lib/core/env.js +0 -2
- package/lib/core/query-data.js +2 -3
- package/lib/core/task-center.js +4 -5
- package/lib/core/utils.js +75 -116
- package/lib/core/yida-client.js +3 -5
- package/lib/corp-efficiency/corp-efficiency.js +2 -3
- package/lib/corp-manager/api.js +1 -2
- package/lib/db/db-seq-fix.js +15 -22
- package/lib/flash-note/flash-to-prd.js +2 -3
- package/lib/i18n-management/i18n-management.js +1 -2
- package/lib/integration/integration-api.js +9 -15
- package/lib/integration/integration-check.js +0 -1
- package/lib/integration/integration-create.js +0 -1
- package/lib/integration/integration-list.js +0 -1
- package/lib/mcp/server.js +0 -1
- package/lib/page-config/get-page-config.js +3 -4
- package/lib/page-config/save-share-config.js +3 -4
- package/lib/page-config/verify-short-url.js +2 -3
- package/lib/permission/get-permission.js +2 -3
- package/lib/permission/save-permission.js +3 -5
- package/lib/process/ai-form-setting.js +7 -8
- package/lib/process/configure-process.js +11 -17
- package/lib/process/create-process.js +4 -6
- package/lib/report/append.js +2 -3
- package/lib/report/http.js +4 -6
- package/package.json +1 -1
package/bin/yida.js
CHANGED
|
@@ -216,12 +216,6 @@ const TOKEN_OUTPUT_SECRET_KEYS = new Set([
|
|
|
216
216
|
'accessToken',
|
|
217
217
|
'refresh_token',
|
|
218
218
|
'refreshToken',
|
|
219
|
-
'ai_app_user_auth_token',
|
|
220
|
-
'aiAppUserAuthToken',
|
|
221
|
-
'tianshu_csrf_token',
|
|
222
|
-
'tianshuCsrfToken',
|
|
223
|
-
'csrf_token',
|
|
224
|
-
'csrfToken',
|
|
225
219
|
]);
|
|
226
220
|
|
|
227
221
|
function maskSensitiveAuthOutput(value) {
|
|
@@ -451,12 +445,6 @@ function throwCliUsage(...lines) {
|
|
|
451
445
|
});
|
|
452
446
|
}
|
|
453
447
|
|
|
454
|
-
function throwNeedLogin(message) {
|
|
455
|
-
throw new CliError(message, {
|
|
456
|
-
code: 'NEED_LOGIN',
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
|
|
460
448
|
async function main() {
|
|
461
449
|
applyQuietFlag();
|
|
462
450
|
applyGlobalEnvironmentFlags();
|
package/lib/agent-center/api.js
CHANGED
|
@@ -71,7 +71,7 @@ const AGENT_RANGE_ALIASES = {
|
|
|
71
71
|
function getAuthRef() {
|
|
72
72
|
const authRef = createAuthRef();
|
|
73
73
|
if (!isAuthRefReady(authRef)) {
|
|
74
|
-
throw new Error('
|
|
74
|
+
throw new Error('无法获取有效 token 登录态');
|
|
75
75
|
}
|
|
76
76
|
return authRef;
|
|
77
77
|
}
|
|
@@ -128,7 +128,6 @@ function normalizeYesNo(value, defaultValue = 'n') {
|
|
|
128
128
|
function buildCommonParams(authRef, apiName, params = {}) {
|
|
129
129
|
const base = {
|
|
130
130
|
_mock: 'false',
|
|
131
|
-
_csrf_token: authRef.csrfToken,
|
|
132
131
|
_locale_time_zone_offset: '28800000',
|
|
133
132
|
_stamp: String(Date.now()),
|
|
134
133
|
};
|
|
@@ -150,7 +149,7 @@ async function agentPost(path, apiName, params = {}, authRef = getAuthRef()) {
|
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
function assertSuccess(result, action) {
|
|
153
|
-
if (result && result.success !== false && !result.__needLogin
|
|
152
|
+
if (result && result.success !== false && !result.__needLogin) {
|
|
154
153
|
return result;
|
|
155
154
|
}
|
|
156
155
|
const message = result && (result.errorMsg || result.message || result.errorCode);
|
|
@@ -86,7 +86,7 @@ function unwrapContent(result) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function assertSuccess(result, action) {
|
|
89
|
-
if (!result || result.success === false || result.__needLogin
|
|
89
|
+
if (!result || result.success === false || result.__needLogin) {
|
|
90
90
|
const message = result
|
|
91
91
|
? result.errorMsg || result.error || result.message || t('common.unknown_error')
|
|
92
92
|
: t('common.request_failed');
|
|
@@ -103,9 +103,8 @@ async function createAuthRef() {
|
|
|
103
103
|
return authRef;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
function buildCreateEmptyPostData(
|
|
106
|
+
function buildCreateEmptyPostData(title) {
|
|
107
107
|
return querystring.stringify({
|
|
108
|
-
_csrf_token: csrfToken,
|
|
109
108
|
formType: 'receipt',
|
|
110
109
|
isVirtualView: 'y',
|
|
111
110
|
title: JSON.stringify(buildYidaTitleI18n(title, {
|
|
@@ -115,9 +114,8 @@ function buildCreateEmptyPostData(csrfToken, title) {
|
|
|
115
114
|
});
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
function buildDesignPostData(
|
|
117
|
+
function buildDesignPostData(formUuid, designInfo, gmtModified) {
|
|
119
118
|
const payload = {
|
|
120
|
-
_csrf_token: csrfToken,
|
|
121
119
|
formUuid,
|
|
122
120
|
designInfo: JSON.stringify(designInfo),
|
|
123
121
|
};
|
|
@@ -130,14 +128,14 @@ function buildDesignPostData(csrfToken, formUuid, designInfo, gmtModified) {
|
|
|
130
128
|
async function checkVirtualViewFeature(authRef, appType) {
|
|
131
129
|
return createYidaClient({ authRef }).postForm(
|
|
132
130
|
`/dingtalk/web/${appType}/query/virtualview/show.json`,
|
|
133
|
-
|
|
131
|
+
{}
|
|
134
132
|
);
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
async function createEmptyVirtualView(authRef, appType, title) {
|
|
138
136
|
return createYidaClient({ authRef }).postForm(
|
|
139
137
|
`/dingtalk/web/${appType}/query/formdesign/saveFormSchemaInfo.json`,
|
|
140
|
-
|
|
138
|
+
buildCreateEmptyPostData(title)
|
|
141
139
|
);
|
|
142
140
|
}
|
|
143
141
|
|
|
@@ -161,7 +159,7 @@ async function postVirtualViewDesign(authRef, appType, formUuid, designInfo, act
|
|
|
161
159
|
|
|
162
160
|
return createYidaClient({ authRef }).postForm(
|
|
163
161
|
`/alibaba/web/${appType}/query/virtualview/${endpoint}`,
|
|
164
|
-
|
|
162
|
+
buildDesignPostData(formUuid, designInfo, gmtModified)
|
|
165
163
|
);
|
|
166
164
|
}
|
|
167
165
|
|
package/lib/ai/ai.js
CHANGED
|
@@ -188,12 +188,11 @@ function getSuccessContent(response, fallbackMessage, code = 'AI_REQUEST_FAILED'
|
|
|
188
188
|
async function callTextFromAI(prompt, options, authRef) {
|
|
189
189
|
const response = await createYidaClient({ authRef }).postForm(
|
|
190
190
|
'/query/intelligent/txtFromAI.json',
|
|
191
|
-
|
|
192
|
-
_csrf_token: auth.csrfToken,
|
|
191
|
+
{
|
|
193
192
|
prompt,
|
|
194
193
|
maxTokens: String(options.maxTokens || DEFAULT_MAX_TOKENS),
|
|
195
194
|
skill: 'ToText',
|
|
196
|
-
}
|
|
195
|
+
}
|
|
197
196
|
);
|
|
198
197
|
|
|
199
198
|
const content = getSuccessContent(response, 'AI 接口调用失败', 'AI_TEXT_REQUEST_FAILED');
|
|
@@ -226,11 +225,10 @@ async function getOssSign(filePath, appType, authRef) {
|
|
|
226
225
|
|
|
227
226
|
return createYidaClient({ authRef }).get(
|
|
228
227
|
'/ossSign',
|
|
229
|
-
|
|
228
|
+
{
|
|
230
229
|
scene: 'ImageField',
|
|
231
230
|
_api: 'nattyFetch',
|
|
232
231
|
_mock: 'false',
|
|
233
|
-
_csrf_token: auth.csrfToken,
|
|
234
232
|
appType,
|
|
235
233
|
fileName,
|
|
236
234
|
fileSize: String(stat.size),
|
|
@@ -242,7 +240,7 @@ async function getOssSign(filePath, appType, authRef) {
|
|
|
242
240
|
businessType: '',
|
|
243
241
|
accelerate: 'y',
|
|
244
242
|
_stamp: String(Date.now()),
|
|
245
|
-
}
|
|
243
|
+
}
|
|
246
244
|
);
|
|
247
245
|
}
|
|
248
246
|
|
|
@@ -283,10 +281,9 @@ async function postToOss(filePath, signContent) {
|
|
|
283
281
|
async function convertToPublicImageUrl(downloadUrl, authRef) {
|
|
284
282
|
const response = await createYidaClient({ authRef }).get(
|
|
285
283
|
'/aliyun/sdk/upload2Oss.json',
|
|
286
|
-
|
|
284
|
+
{
|
|
287
285
|
imageUrl: downloadUrl,
|
|
288
|
-
|
|
289
|
-
})
|
|
286
|
+
}
|
|
290
287
|
);
|
|
291
288
|
|
|
292
289
|
if (!response || !response.success) {
|
|
@@ -306,8 +303,7 @@ async function uploadCallback(filePath, appType, formUuid, signContent, ossResul
|
|
|
306
303
|
const stat = fs.statSync(filePath);
|
|
307
304
|
return createYidaClient({ authRef }).postForm(
|
|
308
305
|
'/query/attach/uploadCallBack.json',
|
|
309
|
-
|
|
310
|
-
_csrf_token: auth.csrfToken,
|
|
306
|
+
{
|
|
311
307
|
appType,
|
|
312
308
|
fileName: path.basename(filePath),
|
|
313
309
|
fileSize: String(stat.size),
|
|
@@ -316,7 +312,7 @@ async function uploadCallback(filePath, appType, formUuid, signContent, ossResul
|
|
|
316
312
|
procInstId: '',
|
|
317
313
|
ossRequestId: ossResult.requestId || '',
|
|
318
314
|
businessType: 'inst',
|
|
319
|
-
}
|
|
315
|
+
}
|
|
320
316
|
);
|
|
321
317
|
}
|
|
322
318
|
|
|
@@ -388,11 +384,10 @@ async function invokeImageRecognition(imageUrl, options, authRef) {
|
|
|
388
384
|
|
|
389
385
|
const response = await createYidaClient({ authRef }).postForm(
|
|
390
386
|
'/query/publicService/invokeService.json',
|
|
391
|
-
|
|
387
|
+
{
|
|
392
388
|
inputs: JSON.stringify(inputs),
|
|
393
389
|
serviceInfo: JSON.stringify(serviceInfo),
|
|
394
|
-
|
|
395
|
-
})
|
|
390
|
+
}
|
|
396
391
|
);
|
|
397
392
|
|
|
398
393
|
if (!response || !response.success) {
|
package/lib/app/app-list.js
CHANGED
|
@@ -25,7 +25,6 @@ function fetchAppListPage(auth, pageIndex, pageSize) {
|
|
|
25
25
|
pageIndex,
|
|
26
26
|
pageSize,
|
|
27
27
|
creator: ref.userId,
|
|
28
|
-
_csrf_token: ref.csrfToken,
|
|
29
28
|
_stamp: Date.now(),
|
|
30
29
|
}));
|
|
31
30
|
}
|
|
@@ -36,9 +35,8 @@ function fetchAppListPage(auth, pageIndex, pageSize) {
|
|
|
36
35
|
async function fetchAllApps(auth, pageSize) {
|
|
37
36
|
const firstResult = await fetchAppListPage(auth, 1, pageSize);
|
|
38
37
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
if (firstResult.__needLogin || firstResult.__csrfExpired) {
|
|
38
|
+
// 如果首次请求就提示需要登录,直接返回原始结果让外层自动刷新 token 后重试。
|
|
39
|
+
if (firstResult.__needLogin) {
|
|
42
40
|
return firstResult;
|
|
43
41
|
}
|
|
44
42
|
|
|
@@ -59,7 +57,7 @@ async function fetchAllApps(auth, pageSize) {
|
|
|
59
57
|
const remainingResults = await Promise.all(remainingFetches);
|
|
60
58
|
for (const result of remainingResults) {
|
|
61
59
|
// 如果后续翻页也出现登录态问题,同样返回标记对象
|
|
62
|
-
if (result.__needLogin
|
|
60
|
+
if (result.__needLogin) {
|
|
63
61
|
return result;
|
|
64
62
|
}
|
|
65
63
|
if (result.success && result.content && result.content.data) {
|
|
@@ -122,7 +120,7 @@ async function run(args) {
|
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
// 如果重试后仍然返回登录失效标记,说明登录态确实不可用
|
|
125
|
-
if (apps &&
|
|
123
|
+
if (apps && apps.__needLogin) {
|
|
126
124
|
console.error('登录态已失效,请重新登录');
|
|
127
125
|
process.exit(1);
|
|
128
126
|
}
|
package/lib/app/create-app.js
CHANGED
|
@@ -246,7 +246,7 @@ async function run(args) {
|
|
|
246
246
|
try {
|
|
247
247
|
const corpConfig = await httpPost(
|
|
248
248
|
authRef.baseUrl,
|
|
249
|
-
`/query/exclusive/queryCorpAppConfig.json?_api=Global.queryCorpAppConfig&_mock=false&
|
|
249
|
+
`/query/exclusive/queryCorpAppConfig.json?_api=Global.queryCorpAppConfig&_mock=false&_locale_time_zone_offset=28800000&_stamp=${Date.now()}`,
|
|
250
250
|
''
|
|
251
251
|
);
|
|
252
252
|
if (corpConfig && corpConfig.content) {
|
|
@@ -260,7 +260,6 @@ async function run(args) {
|
|
|
260
260
|
const iconValue = `${icon}%%${iconColor}`;
|
|
261
261
|
const response = await requestWithAutoLogin((auth) => {
|
|
262
262
|
const postData = querystring.stringify({
|
|
263
|
-
_csrf_token: auth.csrfToken,
|
|
264
263
|
appName: JSON.stringify(buildYidaI18n(appName, { en_US: appName, ja_JP: appName })),
|
|
265
264
|
description: JSON.stringify(buildYidaI18n(description, { en_US: description, ja_JP: description })),
|
|
266
265
|
icon: iconValue,
|
package/lib/app/create-form.js
CHANGED
|
@@ -4325,10 +4325,8 @@ function applyChangesToSchema(schema, changes) {
|
|
|
4325
4325
|
|
|
4326
4326
|
// ── 发送 POST 请求(支持 302 自动重登录) ────────────
|
|
4327
4327
|
|
|
4328
|
-
function sendPostRequest(baseUrl,
|
|
4329
|
-
const postData = querystring.stringify(
|
|
4330
|
-
Object.assign({ _csrf_token: csrfToken }, extraParams)
|
|
4331
|
-
);
|
|
4328
|
+
function sendPostRequest(baseUrl, requestPath, extraParams, formUuid) {
|
|
4329
|
+
const postData = querystring.stringify(extraParams);
|
|
4332
4330
|
const referer = formUuid
|
|
4333
4331
|
? `${baseUrl}/alibaba/web/${extraParams.appType || ''}/design/pageDesigner?formUuid=${formUuid}`
|
|
4334
4332
|
: baseUrl + '/';
|
|
@@ -4337,9 +4335,8 @@ function sendPostRequest(baseUrl, csrfToken, requestPath, extraParams, formUuid)
|
|
|
4337
4335
|
|
|
4338
4336
|
// ── 发送 updateFormConfig 请求 ───────────────────────
|
|
4339
4337
|
|
|
4340
|
-
function sendUpdateConfigRequest(baseUrl,
|
|
4338
|
+
function sendUpdateConfigRequest(baseUrl, appType, formUuid, version, value) {
|
|
4341
4339
|
const postData = querystring.stringify({
|
|
4342
|
-
_csrf_token: csrfToken,
|
|
4343
4340
|
formUuid: formUuid,
|
|
4344
4341
|
version: version,
|
|
4345
4342
|
configType: 'MINI_RESOURCE',
|
|
@@ -4378,7 +4375,7 @@ async function saveSchemaAndUpdateConfig(authRef, appType, formUuid, schema, ver
|
|
|
4378
4375
|
|
|
4379
4376
|
const saveResult = await requestWithAutoLogin(function (auth) {
|
|
4380
4377
|
return sendPostRequest(
|
|
4381
|
-
auth.baseUrl,
|
|
4378
|
+
auth.baseUrl,
|
|
4382
4379
|
buildApiPath(appType, 'saveFormSchema', { prefix: '_view' }),
|
|
4383
4380
|
{ appType: appType, formUuid: formUuid, content: JSON.stringify(schema), schemaVersion: 'V5', prefix: '_view' },
|
|
4384
4381
|
formUuid
|
|
@@ -4408,7 +4405,7 @@ async function saveSchemaAndUpdateConfig(authRef, appType, formUuid, schema, ver
|
|
|
4408
4405
|
info(t('create_form.sending_config'));
|
|
4409
4406
|
|
|
4410
4407
|
const configResult = await requestWithAutoLogin(function (auth) {
|
|
4411
|
-
return sendUpdateConfigRequest(auth.baseUrl,
|
|
4408
|
+
return sendUpdateConfigRequest(auth.baseUrl, appType, formUuid, version || 1, 0);
|
|
4412
4409
|
}, authRef);
|
|
4413
4410
|
|
|
4414
4411
|
return { saveResult: saveResult, configResult: configResult };
|
|
@@ -4436,7 +4433,7 @@ async function mainCreate(parsedArgs, authRef) {
|
|
|
4436
4433
|
info(t('create_form.sending_create'));
|
|
4437
4434
|
const createResult = await requestWithAutoLogin(function (auth) {
|
|
4438
4435
|
return sendPostRequest(
|
|
4439
|
-
auth.baseUrl,
|
|
4436
|
+
auth.baseUrl,
|
|
4440
4437
|
buildApiPath(appType, 'saveFormSchemaInfo'),
|
|
4441
4438
|
{ formType: 'receipt', title: JSON.stringify(i18n(formTitle)) }
|
|
4442
4439
|
);
|
|
@@ -5410,7 +5407,6 @@ async function run(args) {
|
|
|
5410
5407
|
}
|
|
5411
5408
|
const baseUrl = resolveBaseUrl(authData);
|
|
5412
5409
|
const authRef = {
|
|
5413
|
-
csrfToken: authData.csrf_token,
|
|
5414
5410
|
baseUrl,
|
|
5415
5411
|
authData,
|
|
5416
5412
|
authMode: authData.auth_mode || '',
|
package/lib/app/create-page.js
CHANGED
|
@@ -48,7 +48,7 @@ function parseArgs(args) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function buildPageInfoPostData(
|
|
51
|
+
function buildPageInfoPostData(formUuid, pageName, isRenderNav) {
|
|
52
52
|
const titleJson = JSON.stringify(buildYidaTitleI18n(pageName, {
|
|
53
53
|
en_US: pageName,
|
|
54
54
|
ja_JP: pageName,
|
|
@@ -56,7 +56,6 @@ function buildPageInfoPostData(csrfToken, formUuid, pageName, isRenderNav) {
|
|
|
56
56
|
|
|
57
57
|
return querystring.stringify({
|
|
58
58
|
_api: 'Form.updateFormSchemaInfo',
|
|
59
|
-
_csrf_token: csrfToken,
|
|
60
59
|
_locale_time_zone_offset: '28800000',
|
|
61
60
|
formUuid,
|
|
62
61
|
serialSwitch: 'n',
|
|
@@ -90,7 +89,7 @@ async function configureDashboardMode(authRef, appType, pageId, pageName) {
|
|
|
90
89
|
return httpPost(
|
|
91
90
|
auth.baseUrl,
|
|
92
91
|
`/dingtalk/web/${appType}/query/formdesign/updateFormSchemaInfo.json`,
|
|
93
|
-
buildPageInfoPostData(
|
|
92
|
+
buildPageInfoPostData(pageId, pageName, false)
|
|
94
93
|
);
|
|
95
94
|
}, authRef);
|
|
96
95
|
}
|
|
@@ -138,7 +137,6 @@ async function run(args) {
|
|
|
138
137
|
|
|
139
138
|
const response = await requestWithAutoLogin((auth) => {
|
|
140
139
|
const postData = querystring.stringify({
|
|
141
|
-
_csrf_token: auth.csrfToken,
|
|
142
140
|
formType: 'display',
|
|
143
141
|
title: JSON.stringify(buildYidaI18n(pageName, { en_US: pageName, ja_JP: pageName })),
|
|
144
142
|
});
|
package/lib/app/er.js
CHANGED
|
@@ -534,7 +534,6 @@ function createAuthRef() {
|
|
|
534
534
|
authData = triggerLogin();
|
|
535
535
|
}
|
|
536
536
|
return {
|
|
537
|
-
csrfToken: authData.csrf_token,
|
|
538
537
|
baseUrl: resolveBaseUrl(authData),
|
|
539
538
|
authData,
|
|
540
539
|
authMode: authData.auth_mode || '',
|
|
@@ -555,7 +554,7 @@ async function fetchSchema(appType, formUuid, authRef) {
|
|
|
555
554
|
}
|
|
556
555
|
|
|
557
556
|
function ensureSuccessfulSchema(result) {
|
|
558
|
-
if (!result || result.success === false || result.__needLogin
|
|
557
|
+
if (!result || result.success === false || result.__needLogin) {
|
|
559
558
|
const message = result && (result.errorMsg || result.message)
|
|
560
559
|
? result.errorMsg || result.message
|
|
561
560
|
: 'Failed to fetch form schema';
|
package/lib/app/get-schema.js
CHANGED
|
@@ -329,7 +329,6 @@ function createAuthRef() {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
const authRef = {
|
|
332
|
-
csrfToken: authData.csrf_token,
|
|
333
332
|
baseUrl: resolveBaseUrl(authData),
|
|
334
333
|
authData,
|
|
335
334
|
authMode: authData.auth_mode || '',
|
|
@@ -352,7 +351,7 @@ async function fetchSchema(appType, formUuid, authRef) {
|
|
|
352
351
|
}
|
|
353
352
|
|
|
354
353
|
function isSuccessfulSchemaResult(result) {
|
|
355
|
-
return !!(result && result.success !== false && !result.__needLogin
|
|
354
|
+
return !!(result && result.success !== false && !result.__needLogin);
|
|
356
355
|
}
|
|
357
356
|
|
|
358
357
|
function printFieldSummary(result) {
|
package/lib/app/import-app.js
CHANGED
|
@@ -25,7 +25,6 @@ const { banner, step, label, success, fail, warn, info, error, result, usage, hi
|
|
|
25
25
|
async function createApp(appName, authRef) {
|
|
26
26
|
const contentLocale = resolveContentLocale({ baseUrl: authRef.baseUrl });
|
|
27
27
|
const postData = querystring.stringify({
|
|
28
|
-
_csrf_token: authRef.csrfToken,
|
|
29
28
|
appName: JSON.stringify(buildYidaI18n(appName, { en_US: appName, ja_JP: appName })),
|
|
30
29
|
description: JSON.stringify(buildYidaI18n(appName, { en_US: appName, ja_JP: appName })),
|
|
31
30
|
icon: 'xian-yingyong%%#0089FF',
|
|
@@ -58,9 +57,8 @@ function normalizeImportFormType(formType) {
|
|
|
58
57
|
return normalized;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
function buildCreateFormPostData(
|
|
60
|
+
function buildCreateFormPostData(formTitle, formType = 'receipt') {
|
|
62
61
|
return querystring.stringify({
|
|
63
|
-
_csrf_token: csrfToken,
|
|
64
62
|
formType: normalizeImportFormType(formType),
|
|
65
63
|
title: JSON.stringify(buildYidaI18n(formTitle, { en_US: formTitle, ja_JP: formTitle })),
|
|
66
64
|
});
|
|
@@ -69,7 +67,7 @@ function buildCreateFormPostData(csrfToken, formTitle, formType = 'receipt') {
|
|
|
69
67
|
// ── 创建空白表单/页面/报表 ──────────────────────────────
|
|
70
68
|
|
|
71
69
|
async function createBlankForm(appType, formTitle, authRef, formType = 'receipt') {
|
|
72
|
-
const postData = buildCreateFormPostData(
|
|
70
|
+
const postData = buildCreateFormPostData(formTitle, formType);
|
|
73
71
|
const result = await requestWithAutoLogin((auth) => {
|
|
74
72
|
return httpPost(
|
|
75
73
|
auth.baseUrl,
|
|
@@ -90,7 +88,6 @@ async function createBlankForm(appType, formTitle, authRef, formType = 'receipt'
|
|
|
90
88
|
|
|
91
89
|
async function saveFormSchema(appType, formUuid, schema, authRef, formType = 'receipt') {
|
|
92
90
|
const payload = {
|
|
93
|
-
_csrf_token: authRef.csrfToken,
|
|
94
91
|
appType,
|
|
95
92
|
formUuid,
|
|
96
93
|
content: JSON.stringify(schema),
|
|
@@ -116,7 +113,6 @@ async function saveFormSchema(appType, formUuid, schema, authRef, formType = 're
|
|
|
116
113
|
|
|
117
114
|
async function updateFormConfig(appType, formUuid, authRef) {
|
|
118
115
|
const postData = querystring.stringify({
|
|
119
|
-
_csrf_token: authRef.csrfToken,
|
|
120
116
|
appType,
|
|
121
117
|
formUuid,
|
|
122
118
|
setting: JSON.stringify({ MINI_RESOURCE: 0 }),
|
package/lib/app/list-forms.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { createAuthRef } = require('../core/yida-client');
|
|
3
|
+
const { createAuthRef, isAuthRefReady } = require('../core/yida-client');
|
|
4
4
|
const { t } = require('../core/i18n');
|
|
5
5
|
const { fetchFormPageList } = require('./form-navigation');
|
|
6
6
|
|
|
@@ -57,7 +57,7 @@ async function run(args) {
|
|
|
57
57
|
|
|
58
58
|
console.error(t('common.step_login', 1));
|
|
59
59
|
const authRef = createAuthRef();
|
|
60
|
-
if (!authRef
|
|
60
|
+
if (!isAuthRefReady(authRef)) {
|
|
61
61
|
console.error(t('list_forms.no_login'));
|
|
62
62
|
process.exit(1);
|
|
63
63
|
}
|
package/lib/app/nav-group.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
httpPost,
|
|
7
7
|
requestWithAutoLogin,
|
|
8
8
|
} = require('../core/utils');
|
|
9
|
-
const { createAuthRef } = require('../core/yida-client');
|
|
9
|
+
const { createAuthRef, isAuthRefReady } = require('../core/yida-client');
|
|
10
10
|
|
|
11
11
|
const ROOT_NAV_UUID = 'NAV-SYSTEM-PARENT-UUID';
|
|
12
12
|
const FORM_UUID_FALLBACK = 'NAV-SYSTEM-FROM-ME-UUID';
|
|
@@ -364,7 +364,7 @@ function countChildren(list, navUuid) {
|
|
|
364
364
|
|
|
365
365
|
function loadAuthRef() {
|
|
366
366
|
const authRef = createAuthRef();
|
|
367
|
-
if (!authRef
|
|
367
|
+
if (!isAuthRefReady(authRef)) {
|
|
368
368
|
throw new Error('No valid Yida login cache found. Run openyida login first.');
|
|
369
369
|
}
|
|
370
370
|
return authRef;
|
|
@@ -378,7 +378,6 @@ async function fetchNavigationList(appType, authRef) {
|
|
|
378
378
|
{
|
|
379
379
|
_api: 'Nav.queryList',
|
|
380
380
|
_mock: false,
|
|
381
|
-
_csrf_token: auth.csrfToken,
|
|
382
381
|
_locale_time_zone_offset: 28800000,
|
|
383
382
|
_stamp: Date.now(),
|
|
384
383
|
}
|
|
@@ -415,7 +414,7 @@ async function postNavAction(appType, action, payload, authRef) {
|
|
|
415
414
|
const result = await requestWithAutoLogin((auth) => {
|
|
416
415
|
const path = `/dingtalk/web/${appType}/query/formnav/${endpoint}` +
|
|
417
416
|
`?_api=${encodeURIComponent(apiNames[action])}` +
|
|
418
|
-
|
|
417
|
+
'&_mock=false' +
|
|
419
418
|
`&_stamp=${Date.now()}`;
|
|
420
419
|
return httpPost(auth.baseUrl, path, querystring.stringify(payload));
|
|
421
420
|
}, authRef);
|
package/lib/app/publish.js
CHANGED
|
@@ -322,7 +322,7 @@ async function fetchExistingSchemaContent(appType, formUuid, authRef) {
|
|
|
322
322
|
);
|
|
323
323
|
}, authRef);
|
|
324
324
|
|
|
325
|
-
if (!result || result.success === false || result.__needLogin
|
|
325
|
+
if (!result || result.success === false || result.__needLogin) {
|
|
326
326
|
const errorMsg = result ? result.errorMsg || t('common.unknown_error') : t('common.request_failed');
|
|
327
327
|
throw new Error(errorMsg);
|
|
328
328
|
}
|
|
@@ -655,10 +655,9 @@ function buildCanvasSchemaContent(sourceCode, runtimeCode, importedModules, form
|
|
|
655
655
|
|
|
656
656
|
// ── 4. 发送 saveFormSchema 请求 ──────────────────────
|
|
657
657
|
|
|
658
|
-
function sendSaveRequest(
|
|
658
|
+
function sendSaveRequest(schemaContent, baseUrl, appType, formUuid) {
|
|
659
659
|
const saveSchemaPath = `/alibaba/web/${appType}/${PREFIX}/query/formdesign/saveFormSchema.json?_stamp=${Date.now()}`;
|
|
660
660
|
const postData = querystring.stringify({
|
|
661
|
-
_csrf_token: csrfToken,
|
|
662
661
|
prefix: PREFIX,
|
|
663
662
|
content: schemaContent,
|
|
664
663
|
formUuid: formUuid,
|
|
@@ -671,10 +670,9 @@ function sendSaveRequest(csrfToken, schemaContent, baseUrl, appType, formUuid) {
|
|
|
671
670
|
|
|
672
671
|
// ── 5. 发送 updateFormConfig 请求 ────────────────────
|
|
673
672
|
|
|
674
|
-
function sendUpdateConfigRequest(
|
|
673
|
+
function sendUpdateConfigRequest(baseUrl, appType, formUuid, version, value) {
|
|
675
674
|
const updateConfigPath = `/dingtalk/web/${appType}/query/formdesign/updateFormConfig.json`;
|
|
676
675
|
const postData = querystring.stringify({
|
|
677
|
-
_csrf_token: csrfToken,
|
|
678
676
|
formUuid: formUuid,
|
|
679
677
|
version: version,
|
|
680
678
|
configType: 'MINI_RESOURCE',
|
|
@@ -942,14 +940,12 @@ async function main(argv) {
|
|
|
942
940
|
|
|
943
941
|
step(2, t('common.step_login', 2));
|
|
944
942
|
let authData = loadAuthData();
|
|
945
|
-
if (!authData
|
|
943
|
+
if (!authData) {
|
|
946
944
|
warn(t('common.login_no_cache'));
|
|
947
945
|
authData = triggerLogin();
|
|
948
946
|
}
|
|
949
|
-
let csrfToken = authData.csrf_token;
|
|
950
947
|
let baseUrl = resolveBaseUrl(authData);
|
|
951
948
|
const authRef = {
|
|
952
|
-
csrfToken,
|
|
953
949
|
baseUrl,
|
|
954
950
|
authData,
|
|
955
951
|
authMode: authData.auth_mode || '',
|
|
@@ -958,7 +954,6 @@ async function main(argv) {
|
|
|
958
954
|
userId: authData.user_id || '',
|
|
959
955
|
};
|
|
960
956
|
await ensurePublishTargetOrExit(appType, formUuid, authRef, { force });
|
|
961
|
-
csrfToken = authRef.csrfToken;
|
|
962
957
|
baseUrl = authRef.baseUrl;
|
|
963
958
|
|
|
964
959
|
let schemaContent;
|
|
@@ -973,7 +968,6 @@ async function main(argv) {
|
|
|
973
968
|
fail(t('publish.data_source_fetch_failed', dataSourceError.message));
|
|
974
969
|
process.exit(1);
|
|
975
970
|
}
|
|
976
|
-
csrfToken = authRef.csrfToken;
|
|
977
971
|
baseUrl = authRef.baseUrl;
|
|
978
972
|
schemaContent = buildSchemaContent(sourceCode, compiledCode, formUuid, { existingDataSource });
|
|
979
973
|
}
|
|
@@ -987,19 +981,17 @@ async function main(argv) {
|
|
|
987
981
|
label('Compiled:', compiledPath);
|
|
988
982
|
step(3, t('publish.step_publish'));
|
|
989
983
|
const response = await requestWithAutoLogin((ref) => sendSaveRequest(
|
|
990
|
-
ref.csrfToken,
|
|
991
984
|
schemaContent,
|
|
992
985
|
ref.baseUrl,
|
|
993
986
|
appType,
|
|
994
987
|
formUuid
|
|
995
988
|
), authRef);
|
|
996
|
-
csrfToken = authRef.csrfToken;
|
|
997
989
|
baseUrl = authRef.baseUrl;
|
|
998
990
|
|
|
999
991
|
if (!response || !response.success) {
|
|
1000
992
|
const errorMsg = response ? response.errorMsg || t('common.unknown_error') : t('common.request_failed');
|
|
1001
993
|
fail(t('publish.publish_failed', errorMsg));
|
|
1002
|
-
if (response && !response.__needLogin
|
|
994
|
+
if (response && !response.__needLogin) {
|
|
1003
995
|
hint(t('common.response_detail', JSON.stringify(response, null, 2)));
|
|
1004
996
|
}
|
|
1005
997
|
process.exit(1);
|
|
@@ -1015,14 +1007,12 @@ async function main(argv) {
|
|
|
1015
1007
|
step(4, t('publish.step_config'));
|
|
1016
1008
|
info(t('publish.sending_config'));
|
|
1017
1009
|
const configResponse = await requestWithAutoLogin((ref) => sendUpdateConfigRequest(
|
|
1018
|
-
ref.csrfToken,
|
|
1019
1010
|
ref.baseUrl,
|
|
1020
1011
|
appType,
|
|
1021
1012
|
savedFormUuid,
|
|
1022
1013
|
version,
|
|
1023
1014
|
8
|
|
1024
1015
|
), authRef);
|
|
1025
|
-
csrfToken = authRef.csrfToken;
|
|
1026
1016
|
baseUrl = authRef.baseUrl;
|
|
1027
1017
|
|
|
1028
1018
|
const pageUrl = `${baseUrl}/${appType}/workbench/${savedFormUuid}`;
|
package/lib/app/update-app.js
CHANGED
|
@@ -35,7 +35,7 @@ function parseArgs() {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function buildPostData(
|
|
38
|
+
function buildPostData(formUuid, isRenderNav, title) {
|
|
39
39
|
const titleJson = JSON.stringify(buildYidaTitleI18n(title, {
|
|
40
40
|
en_US: title,
|
|
41
41
|
ja_JP: title,
|
|
@@ -43,7 +43,6 @@ function buildPostData(csrfToken, formUuid, isRenderNav, title) {
|
|
|
43
43
|
|
|
44
44
|
return querystring.stringify({
|
|
45
45
|
_api: 'Form.updateFormSchemaInfo',
|
|
46
|
-
_csrf_token: csrfToken,
|
|
47
46
|
_locale_time_zone_offset: '28800000',
|
|
48
47
|
formUuid: formUuid,
|
|
49
48
|
serialSwitch: 'n',
|
|
@@ -93,7 +92,6 @@ async function main() {
|
|
|
93
92
|
authData = triggerLogin();
|
|
94
93
|
}
|
|
95
94
|
const authRef = {
|
|
96
|
-
csrfToken: authData.csrf_token,
|
|
97
95
|
baseUrl: resolveBaseUrl(authData),
|
|
98
96
|
authData,
|
|
99
97
|
authMode: authData.auth_mode || '',
|
|
@@ -110,10 +108,10 @@ async function main() {
|
|
|
110
108
|
const apiResult = await requestWithAutoLogin((ref) => sendPostRequest(
|
|
111
109
|
ref.baseUrl,
|
|
112
110
|
`/dingtalk/web/${appType}/query/formdesign/updateFormSchemaInfo.json`,
|
|
113
|
-
buildPostData(
|
|
111
|
+
buildPostData(formUuid, isRenderNav, title)
|
|
114
112
|
), authRef);
|
|
115
113
|
|
|
116
|
-
if (apiResult && !apiResult.__needLogin
|
|
114
|
+
if (apiResult && !apiResult.__needLogin) {
|
|
117
115
|
if (apiResult.success) {
|
|
118
116
|
result(true, t('update_form_config.update_ok'), [
|
|
119
117
|
['Render Nav', isRenderNav === 'true' ? t('update_form_config.nav_shown') : t('update_form_config.nav_hidden')],
|
|
@@ -82,7 +82,7 @@ function printJson(payload) {
|
|
|
82
82
|
function getAuthRef() {
|
|
83
83
|
const authRef = createAuthRef();
|
|
84
84
|
if (!isAuthRefReady(authRef)) {
|
|
85
|
-
throw new Error('
|
|
85
|
+
throw new Error('无法获取有效 token 登录态');
|
|
86
86
|
}
|
|
87
87
|
return authRef;
|
|
88
88
|
}
|
|
@@ -173,7 +173,6 @@ function parseCliOptions(tokens) {
|
|
|
173
173
|
|
|
174
174
|
function buildCommonParams(authRef, params = {}) {
|
|
175
175
|
return {
|
|
176
|
-
_csrf_token: authRef.csrfToken,
|
|
177
176
|
_locale_time_zone_offset: '28800000',
|
|
178
177
|
_stamp: String(Date.now()),
|
|
179
178
|
...params,
|