openyida 2026.11.4-1 → 2026.11.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -278,6 +278,7 @@ openyida data query form APP_XXX FORM_XXX --dynamic-order '{"dateField_xxx":"-"}
278
278
  openyida data query process APP_XXX FORM_XXX --current-approver USER_ID --count
279
279
  openyida data create form APP_XXX FORM_XXX --expect-form-name 客户 --expect-form-type receipt --data-file .cache/openyida/data-import/record.json
280
280
  openyida data seed form APP_XXX FORM_XXX --expect-form-name 客户 --records-file .cache/openyida/data-import/customers.json --timezone +08:00 --json
281
+ openyida data mock form APP_XXX FORM_XXX --expect-form-name 客户 --records-file .cache/openyida/customers/data-import/records.json --json
281
282
  openyida get-permission APP_XXX FORM_XXX
282
283
  ```
283
284
 
@@ -291,6 +292,8 @@ The input file gets a sibling `.seed-receipt.json`. Rerunning the unchanged comm
291
292
 
292
293
  Keep the complete JSON result. After `success=true` and `readbackVerified=true`, match each verified `items[].formInstId` to the input by its zero-based `recordIndex`; `formInstIds` also preserves input order. Create referenced records first, then use those IDs in dependent association values. Avoid `tail/head/grep` on the JSON or list queries whose only purpose is rediscovering returned IDs. Keep the required business spot-check, using `data query form APP_XXX FORM_XXX --inst-id <verified-id> --json`. If output is truncated, read the current command's `receiptFile`; uncertain or cross-session recovery uses the unchanged seed command. Check-only output, pending entries and candidate IDs are not verified association targets. See the [receipt workflow](yida-skills/skills/yida-data-management/SKILL.md#直接消费回执与关联-id).
293
294
 
295
+ `data mock form` is an explicit beta command for environments with the `/query/aiTool/mockRecords.json` endpoint deployed. It submits 1–3 records for one ordinary form in a single write request, using `[{"clientRecordId":"seed-1","data":{"textField_name":"Customer A"}}]`. The default app-building flow continues to use `data seed form` with its date conversion, readback and resumable receipts. Mock request IDs are for tracing only; every invocation creates a new request, with no automatic retry or fallback to single-record writes. Inspect `COMPLETED/UNKNOWN/REJECTED`, per-row states and counts; `COMPLETED` does not imply every row succeeded. Verify each created instance ID and visible fields separately (`readbackVerified=false`), and inspect existing data before any further write after an uncertain result.
296
+
294
297
  Append and forward permissions are configured in the process definition through `nodes[].actions.normalActions/appendActions`. Both `create-process` and `configure-process` compile these settings into matching designer and runtime properties. See [approval action configuration](yida-skills/skills/yida-flow-node-config/references/actions.md) for the JSON example, defaults, and verification limits.
295
298
 
296
299
  `configure-process` 的流程 JSON 中,审批人可配置为发起人、指定成员、指定角色、部门主管或直属主管,例如:
@@ -558,7 +561,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
558
561
 
559
562
  | Command | Description |
560
563
  |---------|-------------|
561
- | `openyida data <query\|get\|create\|update\|transfer\|seed> <resource> ... \| delete form <appType> <formUuid> --inst-id <id> --expect-form-name <name> --expect-form-type receipt --confirm [--json]` | Unified data management (form/process/task/subform) |
564
+ | `openyida data <query\|get\|create\|update\|transfer\|seed\|mock> <resource> ... \| delete form <appType> <formUuid> --inst-id <id> --expect-form-name <name> --expect-form-type receipt --confirm [--json]` | Unified data management (form/process/task/subform) |
562
565
  | `openyida task-center <todo\|created\|done\|cc\|proxy\|capabilities\|link\|scaffold\|options\|inspect\|count> [--spec <file.json> --output <file.canvas.jsx>] [options]` | Global task center (todo/processed/cc etc.) |
563
566
  | `openyida basic-info <overview\|commodity\|grant\|capacity\|quota\|abs-path\|dataflow\|i18n\|domain>` | Query organization basic info, capacity, quotas, and domain settings |
564
567
  | `openyida read-dingtalk-doc <docUrl> [--output <file>] [--json]` | Fetch Markdown content from a DingTalk document |
@@ -644,7 +644,7 @@ const COMMAND_SIDE_EFFECTS = new Map([
644
644
  mutates_yida: true,
645
645
  mutates_local: true,
646
646
  read_actions: ['query', 'get'],
647
- mutating_actions: ['create', 'update', 'delete', 'transfer', 'seed'],
647
+ mutating_actions: ['create', 'update', 'delete', 'transfer', 'seed', 'mock'],
648
648
  })],
649
649
  ['db-seq-fix', sideEffect('mixed', {
650
650
  mutates_yida: true,
@@ -970,7 +970,7 @@ const COMMAND_PERMISSIONS = new Map([
970
970
  ...permissionEntries([
971
971
  'data',
972
972
  ], actionDependentPermission({
973
- preauthorized_actions: ['create', 'update', 'transfer', 'seed'],
973
+ preauthorized_actions: ['create', 'update', 'transfer', 'seed', 'mock'],
974
974
  ask_actions: ['delete'],
975
975
  })),
976
976
 
@@ -1821,7 +1821,7 @@ const COMMAND_GROUPS = [
1821
1821
  id: 'data',
1822
1822
  titleKey: 'help.group_data',
1823
1823
  commands: [
1824
- command('data', ['data'], 'data <query|get|create|update|transfer|seed> <resource> ... | delete form <appType> <formUuid> --inst-id <id> --expect-form-name <name> --expect-form-type receipt --confirm [--json]', 'help.cmd_data', {
1824
+ command('data', ['data'], 'data <query|get|create|update|transfer|seed|mock> <resource> ... | delete form <appType> <formUuid> --inst-id <id> --expect-form-name <name> --expect-form-type receipt --confirm [--json]', 'help.cmd_data', {
1825
1825
  managedRun: { scope: 'actions', actions: {
1826
1826
  query: { scope: 'actions', actions: {
1827
1827
  form: { scope: 'app', appPosition: 2 }, subform: { scope: 'app', appPosition: 2 },
@@ -1833,6 +1833,9 @@ const COMMAND_GROUPS = [
1833
1833
  form: { scope: 'app', appPosition: 2 }, subform: { scope: 'app', appPosition: 2 },
1834
1834
  process: { scope: 'app', appPosition: 2 },
1835
1835
  } },
1836
+ mock: { scope: 'actions', actions: {
1837
+ form: { scope: 'app', appPosition: 2, mutation: { operation: 'create_form_data', formUuidPosition: 3 } },
1838
+ } },
1836
1839
  create: { scope: 'actions', actions: {
1837
1840
  form: { scope: 'app', appPosition: 2, mutation: { operation: 'create_form_data', formUuidPosition: 3 } },
1838
1841
  process: { scope: 'app', appPosition: 2, mutation: { operation: 'create_form_data', formUuidPosition: 3 } },
@@ -1861,7 +1864,11 @@ const COMMAND_GROUPS = [
1861
1864
  { name: 'verifyWrite', type: 'boolean', source: 'option', builder_options: ['--verify-write'],
1862
1865
  description: 'Ordinary form create/update only: live-schema payload preflight and submitted-field readback after one write.' },
1863
1866
  { name: 'recordsFile', type: 'string', source: 'option', builder_options: ['--records-file'],
1864
- description: 'seed form only: JSON array of 1–30 business records using schema field formats; unadapted optional fields appear in skippedFields; receipt saved beside this file.' },
1867
+ description: 'seed form: JSON array of 1–30 business records with a reusable receipt. mock form: 1–3 {clientRecordId,data} entries, submitted once without a local receipt or automatic readback.' },
1868
+ { name: 'requestId', type: 'string', source: 'option', builder_options: ['--request-id'],
1869
+ description: 'mock form only: optional trace identifier; does not provide deduplication or make retries safe.' },
1870
+ { name: 'schemaVersion', type: 'number', source: 'option', builder_options: ['--schema-version'],
1871
+ description: 'mock form only: optional expected form version, checked by the server before writing.' },
1865
1872
  { name: 'timezone', type: 'string', source: 'option', builder_options: ['--timezone'],
1866
1873
  description: 'seed form only: fixed UTC offset for date strings without an offset, default +08:00.' },
1867
1874
  { name: 'check', type: 'boolean', source: 'option', builder_options: ['--check'],
@@ -1869,6 +1876,8 @@ const COMMAND_GROUPS = [
1869
1876
  ],
1870
1877
  notes: [
1871
1878
  '--verify-write is opt-in for ordinary form create/update. It validates supplied field IDs, optional configured aliases, scoped subform references and supported value formats before writing, then reads the same instance and compares submitted fields. Labels are suggestions only; ambiguous aliases and unsupported formats fail before writing. ID/count alone is not field verification. Readback failure or mismatch exits nonzero, preserves partial.formInstId/candidateIds and mutationAccepted, and never repeats the write. Existing identity/permission gates and managed-run scope remain unchanged. Verification covers submitted business values, not all application acceptance criteria or server-side business rules.',
1879
+ 'For mock NumberField values requiring decimal precision beyond JavaScript numbers, use a JSON string such as "1234567890.123456789". Unsafe integer numbers are rejected.',
1880
+ 'data mock form <appType> <formUuid> --records-file <file.json> --expect-form-name <name> [--request-id ID] [--schema-version N] [--resolve-aliases] [--json] submits 1-3 ordinary-form records in one JSON request. File format: [{clientRecordId,data:{fieldId:value}}]. requestId is only a trace identifier, not a deduplication key. Every invocation is a new write request; no automatic retry or fallback. success denotes protocol processing: count SUCCEEDED rows and inspect COMPLETED/UNKNOWN/REJECTED plus createdCount/failedCount/unknownCount/notStartedCount. After a lost response, verify existing data before considering any new write. Query created instance IDs separately to verify visible fields.',
1872
1881
  'Ordinary form updates read record edit permission and native edit-schema field behaviors before writing. Only verified NORMAL fields are accepted; readonly, hidden, disabled, unknown or dynamically unverifiable fields reject the entire update. Restricted subform replacements require the native editor. This CLI preflight does not replace server-side authorization.',
1873
1882
  'Application tasks: data query tasks <appType> --type todo|created|done|cc [--normalized] [--transport app-v1|app-query]. submitted remains an alias of created. --normalized returns items/total/page/pageSize with native detail targets; an unknown total is null. app-v1 is the compatible default; only cc adds --process-codes and --instance-status. Explicit app-query fixes appKeys to the target app and supports the per-kind filters in task-center capabilities: --originators, --process-codes, --instance-create-from/to, --task-create-from/to, --task-finish-from/to, --carbon-create-from/to. Date values are Unix milliseconds. Unsupported filters and caller scope/identity overrides are rejected; transports never silently fall back.',
1874
1883
  '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.',
@@ -1880,6 +1889,7 @@ const COMMAND_GROUPS = [
1880
1889
  'openyida data query process APP_XXX FORM_XXX --current-approver USER_ID --count',
1881
1890
  'openyida data query form APP_XXX FORM_XXX --page 1 --size 20 --search-json \'[{"key":"dateField_due","componentName":"DateField","type":"DOUBLE","operator":"is","value":""}]\'',
1882
1891
  'openyida data create form APP_XXX FORM_XXX --expect-form-name 客户 --expect-form-type receipt --data-json \'{"textField_name":"客户 A","dateField_followUp":1787932800000}\'',
1892
+ 'openyida data mock form APP_XXX FORM_XXX --expect-form-name 客户 --records-file .cache/openyida/customers/data-import/records.json --json',
1883
1893
  'openyida data delete form APP_XXX FORM_XXX --inst-id FINST_XXX --expect-form-name 客户 --expect-form-type receipt --confirm --json',
1884
1894
  'openyida data query process-tasks APP_XXX --process-inst-id PINST_XXX --json',
1885
1895
  'openyida data transfer task APP_XXX --process-inst-id PINST_XXX --form-uuid FORM_XXX --to-user-id USER_ID --expect-form-name "Approval form" --expect-form-type process --json',
@@ -13,6 +13,7 @@ module.exports = {
13
13
  learning_completed: 'Yida course completions',
14
14
  certified_developers: 'Certified Yida developers',
15
15
  },
16
+ mock_records: { stopped: 'Mock record operation stopped: {0}. Keep the operation receipt and follow the returned nextStep.' },
16
17
  qwenwork: {
17
18
  organization_switch_success: 'Switched organization through QwenWork login.',
18
19
  login_check_failed: 'Unable to verify the login session. Please retry.',
@@ -13,6 +13,7 @@ module.exports = {
13
13
  learning_completed: '宜搭学习完成人数',
14
14
  certified_developers: '宜搭开发者认证人数',
15
15
  },
16
+ mock_records: { stopped: '示例记录操作已停止:{0}。请保留操作回执,并按返回的 nextStep 继续。' },
16
17
  qwenwork: {
17
18
  organization_switch_success: '已通过千问办公登录切换组织。',
18
19
  login_check_failed: '登录状态暂时无法确认,请重试。',
@@ -0,0 +1,202 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const crypto = require('crypto');
5
+ const { CliError } = require('./cli-error');
6
+ const { t } = require('./i18n');
7
+ const { createYidaClient } = require('./yida-client');
8
+ const { redactSensitive } = require('./redact');
9
+ const { isPermissionGuidanceError } = require('./permission-guidance');
10
+
11
+ const MAX_BYTES = 64 * 1024;
12
+ const ROW_STATES = new Set(['NOT_STARTED', 'SUCCEEDED', 'FAILED', 'UNKNOWN']);
13
+
14
+ function fail(code, reason, details = {}) {
15
+ throw new CliError(t('mock_records.stopped', reason), { code, details });
16
+ }
17
+
18
+ function invalid(reason) {
19
+ fail('AI_INVALID_ARGUMENT', reason, { retryable: false, sideEffectState: 'none' });
20
+ }
21
+
22
+ function object(value) {
23
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
24
+ }
25
+
26
+ function text(value, max) {
27
+ return typeof value === 'string' && value.trim() === value && value.length > 0 && value.length <= max;
28
+ }
29
+
30
+ function validateJson(value, depth = 0) {
31
+ if (depth > 8) { invalid('json_depth'); }
32
+ if (typeof value === 'number' && (!Number.isFinite(value) || (Number.isInteger(value) && !Number.isSafeInteger(value)))) {
33
+ invalid('unsafe_number');
34
+ }
35
+ if (Array.isArray(value)) { value.forEach(item => validateJson(item, depth + 1)); }
36
+ else if (object(value)) { Object.values(value).forEach(item => validateJson(item, depth + 1)); }
37
+ }
38
+
39
+ function validateArguments(positionals, options) {
40
+ const allowed = ['records_file', 'request_id', 'expect_form_name', 'expect_form_type', 'schema_version', 'resolve_aliases', 'json'];
41
+ Object.keys(options).forEach(key => { if (!allowed.includes(key)) { invalid(`--${key.replace(/_/g, '-')}`); } });
42
+ if (positionals.length !== 2 || !/^APP_[A-Za-z0-9_-]+$/.test(positionals[0])
43
+ || !/^[A-Za-z0-9_-]{1,128}$/.test(positionals[1])) { invalid('appType/formUuid'); }
44
+ if (options.request_id !== undefined && (typeof options.request_id !== 'string'
45
+ || !/^[A-Za-z0-9_-]{8,64}$/.test(options.request_id))) { invalid('requestId'); }
46
+ ['json', 'resolve_aliases'].forEach(key => {
47
+ if (options[key] !== undefined && options[key] !== true) { invalid(`--${key}`); }
48
+ });
49
+ if (!text(options.records_file, 4096) || !text(options.expect_form_name, 256)) { invalid('records-file/expect-form-name'); }
50
+ if (options.expect_form_type !== undefined && options.expect_form_type !== 'receipt') { invalid('expect-form-type=receipt'); }
51
+ if (options.schema_version !== undefined && (!/^\d+$/.test(String(options.schema_version))
52
+ || !Number.isSafeInteger(Number(options.schema_version)))) { invalid('schema-version'); }
53
+ }
54
+
55
+ function readRecords(file) {
56
+ let value;
57
+ try {
58
+ if (fs.statSync(file).size > MAX_BYTES) { invalid('records-file_size'); }
59
+ value = JSON.parse(fs.readFileSync(file, 'utf8'));
60
+ } catch (error) {
61
+ if (error.isCliError) { throw error; }
62
+ invalid('records-file_json');
63
+ }
64
+ if (!Array.isArray(value) || value.length < 1 || value.length > 3) { invalid('records_count_1_3'); }
65
+ const ids = new Set();
66
+ value.forEach(row => {
67
+ if (!object(row) || Object.keys(row).some(key => !['clientRecordId', 'data'].includes(key))
68
+ || !text(row.clientRecordId, 64) || ids.has(row.clientRecordId) || !object(row.data)
69
+ || Object.keys(row.data).length === 0 || Object.keys(row.data).length > 100) { invalid('records_row'); }
70
+ ids.add(row.clientRecordId);
71
+ validateJson(row.data);
72
+ if (Buffer.byteLength(JSON.stringify(row.data)) > 16 * 1024) { invalid('record_size'); }
73
+ });
74
+ return value;
75
+ }
76
+
77
+ function sanitizeError(error, depth = 0) {
78
+ if (!object(error) || !text(error.code, 128) || typeof error.retryable !== 'boolean'
79
+ || !['NONE', 'UNKNOWN', 'PARTIAL', 'COMMITTED'].includes(error.sideEffectState)) { return null; }
80
+ const result = { code: error.code, retryable: error.retryable, sideEffectState: error.sideEffectState };
81
+ if (text(error.message, 256)) { result.message = redactSensitive(error.message); }
82
+ ['nextAction', 'fieldId', 'fieldPath'].forEach(key => { if (text(error[key], 256)) { result[key] = error[key]; } });
83
+ if (Number.isSafeInteger(error.rowIndex) && error.rowIndex >= 0 && error.rowIndex < 3) { result.rowIndex = error.rowIndex; }
84
+ if (depth < 2 && Array.isArray(error.fieldErrors)) {
85
+ result.fieldErrors = error.fieldErrors.slice(0, 100).map(detail => sanitizeError(detail, depth + 1)).filter(Boolean);
86
+ }
87
+ if (Number.isSafeInteger(error.retryAfterSeconds) && error.retryAfterSeconds >= 0) { result.retryAfterSeconds = error.retryAfterSeconds; }
88
+ return result;
89
+ }
90
+
91
+ function parseResponse(response, requestId, recordIds) {
92
+ const source = response && response.content;
93
+ // 参数绑定前的拒绝可能没有 requestId;Tianshu 将 null 字符串字段序列化为空串。
94
+ const rejectedWithoutRequestId = source?.status === 'REJECTED'
95
+ && [null, undefined, ''].includes(source.requestId);
96
+ if (!response || typeof response.success !== 'boolean' || !object(source)
97
+ || (source.requestId !== requestId && !rejectedWithoutRequestId)
98
+ || !['COMPLETED', 'UNKNOWN', 'REJECTED'].includes(source.status)) { return null; }
99
+ const result = { requestId, status: source.status, readbackVerified: false, results: [] };
100
+ const traceId = source.traceId || response.traceId;
101
+ if (text(traceId, 256)) { result.traceId = traceId; }
102
+ if (source.status === 'REJECTED') {
103
+ const error = sanitizeError(source.error);
104
+ if (response.success !== false || !error || error.sideEffectState !== 'NONE' || response.errorCode !== error.code) { return null; }
105
+ return { success: false, errorCode: error.code, content: { ...result, error,
106
+ createdCount: 0, failedCount: 0, unknownCount: 0, notStartedCount: recordIds.length,
107
+ results: recordIds.map(clientRecordId => ({ clientRecordId, status: 'NOT_STARTED' })),
108
+ } };
109
+ }
110
+ if (response.success !== true || !Array.isArray(source.results) || source.results.length !== recordIds.length) { return null; }
111
+ const counts = { SUCCEEDED: 0, FAILED: 0, UNKNOWN: 0, NOT_STARTED: 0 };
112
+ for (let index = 0; index < source.results.length; index++) {
113
+ const row = source.results[index];
114
+ if (!object(row) || row.clientRecordId !== recordIds[index] || !ROW_STATES.has(row.status)) { return null; }
115
+ counts[row.status]++;
116
+ const clean = { clientRecordId: row.clientRecordId, status: row.status };
117
+ if (row.status === 'SUCCEEDED') {
118
+ if (typeof row.formInstId !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(row.formInstId)) { return null; }
119
+ clean.formInstId = row.formInstId;
120
+ }
121
+ const error = sanitizeError(row.error);
122
+ if (error) { clean.error = error; }
123
+ result.results.push(clean);
124
+ }
125
+ const mapping = { createdCount: 'SUCCEEDED', failedCount: 'FAILED', unknownCount: 'UNKNOWN', notStartedCount: 'NOT_STARTED' };
126
+ for (const [key, state] of Object.entries(mapping)) {
127
+ if (source[key] !== counts[state]) { return null; }
128
+ result[key] = counts[state];
129
+ }
130
+ if ((source.status === 'COMPLETED' && counts.UNKNOWN) || (source.status === 'UNKNOWN' && !counts.UNKNOWN)) { return null; }
131
+ return { success: true, content: result };
132
+ }
133
+
134
+ function present(response, appType, formUuid) {
135
+ const content = response.content;
136
+ const created = content.results.find(row => row.status === 'SUCCEEDED');
137
+ const readbackCommand = created
138
+ ? `openyida data get form ${appType} --form-uuid ${formUuid} --inst-id ${created.formInstId} --json`
139
+ : `openyida data query form ${appType} ${formUuid} --json`;
140
+ const output = { ...response, content: { ...content, readbackCommand } };
141
+ if (!response.success || content.status !== 'COMPLETED' || content.createdCount !== content.results.length) {
142
+ fail(response.errorCode || (content.status === 'UNKNOWN' ? 'AI_MOCK_OUTCOME_UNKNOWN'
143
+ : content.createdCount ? 'AI_MOCK_PARTIAL' : 'AI_MOCK_FAILED'), content.error?.message || response.errorCode || content.status, {
144
+ ...output.content, target: { appType, formUuid },
145
+ partial: content.createdCount > 0, residual: content.createdCount > 0 ? { results: content.results } : undefined,
146
+ retryable: content.error?.retryable === true, retrySafe: false,
147
+ sideEffectState: content.status === 'UNKNOWN' ? 'unknown' : content.createdCount > 0 ? 'partial' : 'none',
148
+ nextAction: content.error?.nextAction || (content.status === 'UNKNOWN' ? 'VERIFY_DATA_DO_NOT_RESUBMIT' : 'INSPECT_RESULTS'),
149
+ });
150
+ }
151
+ console.log(JSON.stringify(output, null, 2));
152
+ }
153
+
154
+ async function mockRecords(positionals, options, session, prepareRecords) {
155
+ const [appType, formUuid] = positionals;
156
+ const records = readRecords(options.records_file);
157
+ const requestId = options.request_id || crypto.randomUUID();
158
+ const payload = { requestId, formUuid, expectedFormName: options.expect_form_name, expectedFormType: 'receipt',
159
+ records: prepareRecords ? await prepareRecords(records) : records,
160
+ ...(options.schema_version !== undefined ? { schemaVersion: Number(options.schema_version) } : {}) };
161
+ if (Buffer.byteLength(JSON.stringify(payload)) > MAX_BYTES) { invalid('payload_size'); }
162
+ let response;
163
+ try {
164
+ response = await createYidaClient({ authRef: session }).postJsonOnce(
165
+ `/dingtalk/web/${appType}/query/aiTool/mockRecords.json`, payload, { timeout: 100000, silentStatus: true });
166
+ } catch (error) {
167
+ if (isPermissionGuidanceError(error)) {
168
+ error.details = { ...error.details, requestId, batchStatus: 'REJECTED', sideEffectState: 'none', retrySafe: false,
169
+ createdCount: 0, failedCount: 0, unknownCount: 0, notStartedCount: records.length,
170
+ results: records.map(row => ({ clientRecordId: row.clientRecordId, status: 'NOT_STARTED' })),
171
+ };
172
+ throw error;
173
+ }
174
+ // A lost response cannot prove whether any row was saved.
175
+ }
176
+ // This endpoint converts downstream save failures into row-level UNKNOWN, so these HTTP
177
+ // authentication markers are confirmed entry rejections. Keep unknown/redirect responses uncertain.
178
+ if (response?.__csrfExpired || (response?.__needLogin && [401, 403].includes(response.__httpStatus))) {
179
+ const forbidden = response.__httpStatus === 403;
180
+ const code = forbidden ? 'AI_FORBIDDEN' : 'AI_UNAUTHORIZED';
181
+ response = { success: false, errorCode: code, content: { requestId, status: 'REJECTED',
182
+ error: { code, retryable: false, sideEffectState: 'NONE', nextAction: 'RESOLVE_PERMISSION',
183
+ message: t(forbidden ? 'permission_guidance.unknown' : 'create_process.login_required') },
184
+ } };
185
+ }
186
+ // The existing entry filter rejects before the controller and uses its legacy envelope.
187
+ if (response?.success === false && response.errorCode === 'TIANSHU_000071') {
188
+ response = { success: false, errorCode: 'AI_RATE_LIMITED', content: { requestId, status: 'REJECTED',
189
+ error: { code: 'AI_RATE_LIMITED', retryable: true, sideEffectState: 'NONE', nextAction: 'WAIT_OR_REDUCE_RATE' },
190
+ } };
191
+ }
192
+ const parsed = parseResponse(response, requestId, records.map(row => row.clientRecordId));
193
+ if (!parsed) {
194
+ return present({ success: true, content: { requestId, status: 'UNKNOWN', createdCount: 0, failedCount: 0,
195
+ unknownCount: records.length, notStartedCount: 0, readbackVerified: false,
196
+ results: records.map(row => ({ clientRecordId: row.clientRecordId, status: 'UNKNOWN' })),
197
+ } }, appType, formUuid);
198
+ }
199
+ present(parsed, appType, formUuid);
200
+ }
201
+
202
+ module.exports = { validateArguments, mockRecords };
@@ -26,6 +26,7 @@ const { fetchFormPageList } = require('../app/form-navigation');
26
26
  const processTasks = require('../process/process-tasks');
27
27
  const { assertFormUpdatePermissions, assertFormUpdatePermissionResponse } = require('./form-edit-permissions');
28
28
  const { buildWriteContract, prepareWriteData, compareWriteData, associationValueIssue } = require('../app/form-data-contract');
29
+ const mockRecordCommands = require('./mock-records');
29
30
 
30
31
  const USAGE = `openyida data - Unified Yida data CLI
31
32
 
@@ -34,6 +35,7 @@ Usage:
34
35
  openyida data get form <appType> --inst-id <formInstId> [--form-uuid <formUuid>] [--no-hydrate-subforms]
35
36
  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
37
  openyida data seed form <appType> <formUuid> --expect-form-name <name> --records-file <JSON-array-file> [--timezone +08:00] [--resolve-aliases] [--check] [--json]
38
+ openyida data mock form <appType> <formUuid> --records-file .cache/openyida/records.json --expect-form-name <name> [--request-id ID] [--schema-version N] [--resolve-aliases] [--json]
37
39
  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]
38
40
  openyida data delete form <appType> <formUuid> --inst-id <formInstId> --expect-form-name <name> --expect-form-type receipt --confirm [--json]
39
41
  openyida data query subform <appType> <formUuid> --inst-id <formInstId> --table-field-id <fieldId|alias> [--page N] [--size N] [--resolve-aliases]
@@ -69,6 +71,7 @@ const SUPPORTED_DATA_COMMANDS = new Set([
69
71
  'get:form',
70
72
  'create:form',
71
73
  'seed:form',
74
+ 'mock:form',
72
75
  'update:form',
73
76
  'delete:form',
74
77
  'query:subform',
@@ -136,6 +139,10 @@ function validateDataCommandBeforeAuth(action, resource, positionals, options) {
136
139
  && (options.verify_write !== true || resource !== 'form' || !['create', 'update'].includes(action))) {
137
140
  dataError('DATA_VERIFY_WRITE_UNSUPPORTED', t('data_verify.invalid_usage'), { retrySafe: true, sideEffectState: 'none' });
138
141
  }
142
+ if (action === 'mock' && resource === 'form') {
143
+ mockRecordCommands.validateArguments(positionals, options);
144
+ return;
145
+ }
139
146
  if (options.current_approver !== undefined || options.count !== undefined) {
140
147
  if (action !== 'query' || resource !== 'process') {
141
148
  parseError('--current-approver / --count: data query process');
@@ -1638,7 +1645,7 @@ async function run(args) {
1638
1645
 
1639
1646
  const action = args[0];
1640
1647
  const resource = args[1];
1641
- const strict = action === 'transfer' || action === 'seed' || (action === 'query' && resource === 'process-tasks');
1648
+ const strict = ['transfer', 'seed', 'mock'].includes(action) || (action === 'query' && resource === 'process-tasks');
1642
1649
  const { positionals, options } = parseCliOptions(args.slice(2), strict,
1643
1650
  action === 'seed' ? t('data_seed.failed', 'DATA_SEED_INVALID_ARGUMENTS') : undefined);
1644
1651
 
@@ -1659,6 +1666,12 @@ async function run(args) {
1659
1666
 
1660
1667
  const session = ensureSession();
1661
1668
 
1669
+ if (action === 'mock' && resource === 'form') {
1670
+ return mockRecordCommands.mockRecords(positionals, options, session, async records => {
1671
+ const aliasContext = await resolveAliasContextIfNeeded(session, positionals[0], positionals[1], options, JSON.stringify(records));
1672
+ return records.map(row => ({ ...row, data: JSON.parse(prepareFormMutationJson(JSON.stringify(row.data), aliasContext)) }));
1673
+ });
1674
+ }
1662
1675
  if (action === 'query' && resource === 'form') {return queryForm(positionals, options, session);}
1663
1676
  if (action === 'get' && resource === 'form') {return getForm(positionals, options, session);}
1664
1677
  if (action === 'create' && resource === 'form') {return createForm(positionals, options, session);}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openyida",
3
- "version": "2026.11.4-1",
3
+ "version": "2026.11.5-beta.0",
4
4
  "description": "OpenYida CLI - AI 宜搭应用开发工具(安装即用,零配置)",
5
5
  "bin": {
6
6
  "openyida": "bin/yida.js",
@@ -139,6 +139,33 @@ openyida data query form <appType> <客户formUuid> --inst-id <回执中的formI
139
139
  - [ ] 已用 `openyida data query form|process ...` 抽查至少 1 条目标记录,核对实例 ID 和可见字段值;没有可见字段时已说明隐藏字段无法通过 CLI 回读
140
140
  - [ ] 已向用户报告创建/更新数量、验收命令与结果摘要;未完成项必须如实说明
141
141
 
142
+ ## 显式调用三条 Mock(beta)
143
+
144
+ 完整应用默认继续使用 `data seed form`,按上文完成日期转换、逐条回读与回执恢复。本节仅用于显式选择 `data mock form`,且目标环境已部署 `/query/aiTool/mockRecords.json` 接口的场景。
145
+
146
+ ```bash
147
+ openyida data mock form <appType> <formUuid> --expect-form-name <真实名称> --records-file <绝对路径>/records.json --json
148
+ ```
149
+
150
+ records.json 使用以下结构,包含同一普通表单的 1–3 条记录:
151
+
152
+ ```json
153
+ [
154
+ {
155
+ "clientRecordId": "seed-1",
156
+ "data": { "textField_name": "远山科技" }
157
+ }
158
+ ]
159
+ ```
160
+
161
+ - 使用真实 `fieldId`;显式加 `--resolve-aliases` 时按已配置别名解析。名称、UUID、普通表单类型或 Schema 不匹配时停止;流程表单使用独立流程命令。
162
+ - `clientRecordId` 同批唯一。可选 `--request-id` 仅用于追踪,不提供去重或幂等保证;本命令不持久化恢复回执,每次执行都会发送新的写请求。
163
+ - 保存将 1–3 条记录一次提交,由服务端先整批预检再顺序写入。命令不自动重试或回退旧单条接口;接口未开放、权限拒绝或限流时按实际回执处理,不改用其他写命令补写。
164
+ - 检查 `COMPLETED/UNKNOWN/REJECTED`、计数及每条结果,按 `clientRecordId` 对应输入。只有 `SUCCEEDED` 行计入已创建;`COMPLETED` 表示执行结束,并不保证全部成功。
165
+ - 成功回执的 `readbackVerified=false` 表示尚未独立核验。按成功行真实 `formInstId` 执行 `data get form` 或 `data query form --inst-id` 回读实例与可见字段,再用于页面数据或关联记录;隐藏字段按本技能规则说明验证边界。
166
+ - 断连或 `UNKNOWN` 先核对已有数据,保留成功与未知行的回执;结果未知不重发。失败或未开始行也先检查整批结果,不能把已成功或未知的行一并重提。
167
+ - 日期按字段保存契约提供毫秒值,本命令不提供 seed 的日期字符串转换。超出 JavaScript 安全整数范围的数值会拒绝;需要完整保留有效位的高精度 NumberField 值用字符串传入。
168
+
142
169
  ## 适用场景
143
170
 
144
171
  用户需要"查询数据"、"新增记录"、"更新数据"、"查看表单实例"、"发起流程"时使用。