@airalogy/aimd-recorder 1.26.0 → 1.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/dist/{AimdDnaSequenceField-CKfd3-_9.js → AimdDnaSequenceField-CcH4iNkt.js} +1 -1
  4. package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-C1XlvrNT.js → AimdEditor.vue_vue_type_style_index_0_lang-CdfAwAUt.js} +2284 -2309
  5. package/dist/{AimdEntityRefField-CX67car3.js → AimdEntityRefField-D_oWNpqr.js} +1 -1
  6. package/dist/{AimdEntityRefField.vue_vue_type_script_setup_true_lang-JISqbfKY.js → AimdEntityRefField.vue_vue_type_script_setup_true_lang-Db_LDoBh.js} +1 -1
  7. package/dist/{AimdMarkdownField-BuRsjOB5.js → AimdMarkdownField-BKFxcFlr.js} +3 -3
  8. package/dist/{AimdMarkdownNoteField-NRA9ut3_.js → AimdMarkdownNoteField-BT9p-czP.js} +2 -2
  9. package/dist/{AimdResourceRefField-B71MVFFK.js → AimdResourceRefField-DTJrzEk0.js} +2 -2
  10. package/dist/{arc-2NNDEUZL.js → arc-C4wUYsPP.js} +1 -1
  11. package/dist/{architectureDiagram-3BPJPVTR-BGU_a_9z.js → architectureDiagram-3BPJPVTR-CsDNdq7Q.js} +2 -2
  12. package/dist/{blockDiagram-GPEHLZMM-ChLqLSJn.js → blockDiagram-GPEHLZMM-fKeT2D5b.js} +4 -4
  13. package/dist/{c4Diagram-AAUBKEIU-BXt823OA.js → c4Diagram-AAUBKEIU-DVwh7NRj.js} +2 -2
  14. package/dist/{channel-D1EuKFn5.js → channel-CH-usREe.js} +1 -1
  15. package/dist/{chunk-2J33WTMH-XJPmqQtr.js → chunk-2J33WTMH-wsLH41rI.js} +1 -1
  16. package/dist/{chunk-4BX2VUAB-CbV5jCeG.js → chunk-4BX2VUAB-DAJr3925.js} +1 -1
  17. package/dist/{chunk-55IACEB6-C8gv1Mc0.js → chunk-55IACEB6-Da4Ne6oY.js} +1 -1
  18. package/dist/{chunk-727SXJPM-Bs2EpCWN.js → chunk-727SXJPM-CP1g1Jx1.js} +5 -5
  19. package/dist/{chunk-AQP2D5EJ-CngahRo6.js → chunk-AQP2D5EJ-CrUHvBMG.js} +3 -3
  20. package/dist/{chunk-FMBD7UC4-DPBfEP1E.js → chunk-FMBD7UC4-2BS6vQ14.js} +1 -1
  21. package/dist/{chunk-ND2GUHAM-BlEzeiST.js → chunk-ND2GUHAM-DbptczhZ.js} +1 -1
  22. package/dist/{chunk-QZHKN3VN-DGOFj8Bc.js → chunk-QZHKN3VN-CmzoHGkh.js} +1 -1
  23. package/dist/{classDiagram-v2-Q7XG4LA2-BUQqoFF9.js → classDiagram-4FO5ZUOK-BhWOa0pe.js} +2 -2
  24. package/dist/{classDiagram-4FO5ZUOK-BUQqoFF9.js → classDiagram-v2-Q7XG4LA2-BhWOa0pe.js} +2 -2
  25. package/dist/components.js +7 -7
  26. package/dist/composables.js +2 -2
  27. package/dist/{cose-bilkent-S5V4N54A-Qxs9suxa.js → cose-bilkent-S5V4N54A-CVq2L78n.js} +1 -1
  28. package/dist/{dagre-BM42HDAG-CqV8IXIy.js → dagre-BM42HDAG-DgdlE5dv.js} +3 -3
  29. package/dist/{diagram-2AECGRRQ-D0mYOaE1.js → diagram-2AECGRRQ-Bp_4Kx4E.js} +2 -2
  30. package/dist/{diagram-5GNKFQAL-Dvjcs9SL.js → diagram-5GNKFQAL-CvhaI19W.js} +3 -3
  31. package/dist/{diagram-KO2AKTUF-rSovr72L.js → diagram-KO2AKTUF-zzkdurRu.js} +2 -2
  32. package/dist/{diagram-LMA3HP47-CirCeq88.js → diagram-LMA3HP47-LTnq6yjw.js} +2 -2
  33. package/dist/{diagram-OG6HWLK6-rk46c1hT.js → diagram-OG6HWLK6-Cuz0JAg_.js} +3 -3
  34. package/dist/{erDiagram-TEJ5UH35--_m5yDSV.js → erDiagram-TEJ5UH35-CIPjTfTT.js} +4 -4
  35. package/dist/example-record-BJC4OLXj.js +92 -0
  36. package/dist/{flowDiagram-I6XJVG4X-DU-TlDfY.js → flowDiagram-I6XJVG4X-CPaK4Xbu.js} +6 -6
  37. package/dist/{ganttDiagram-6RSMTGT7-CrMwQSQi.js → ganttDiagram-6RSMTGT7-DgW97z1_.js} +2 -2
  38. package/dist/{gitGraphDiagram-PVQCEYII-Q-bwtX2H.js → gitGraphDiagram-PVQCEYII-B5nDBDDz.js} +3 -3
  39. package/dist/{graph-CvyYQarK.js → graph-BPBu5cW4.js} +1 -1
  40. package/dist/index.js +117 -115
  41. package/dist/{infoDiagram-5YYISTIA-BejjAcMI.js → infoDiagram-5YYISTIA-BRL6QS3D.js} +1 -1
  42. package/dist/{ishikawaDiagram-YF4QCWOH-CbRBA5Ak.js → ishikawaDiagram-YF4QCWOH-Clx8yAcX.js} +1 -1
  43. package/dist/{journeyDiagram-JHISSGLW-D_6-qOB8.js → journeyDiagram-JHISSGLW-BgDIGN-f.js} +4 -4
  44. package/dist/{kanban-definition-UN3LZRKU-DyGjEqu5.js → kanban-definition-UN3LZRKU-CzITmCY8.js} +2 -2
  45. package/dist/{layout-Z5g42JDg.js → layout-CN9EF1w3.js} +2 -2
  46. package/dist/{linear-DSunMwcT.js → linear-8L3HEUrZ.js} +1 -1
  47. package/dist/{mermaid.core-B-O2uDZ3.js → mermaid.core-BKkg18RI.js} +34 -34
  48. package/dist/{mindmap-definition-RKZ34NQL-CC_NhwV9.js → mindmap-definition-RKZ34NQL-CmOIakhY.js} +3 -3
  49. package/dist/{pieDiagram-4H26LBE5-CHlBAazu.js → pieDiagram-4H26LBE5-Db3KkXWV.js} +3 -3
  50. package/dist/{quadrantDiagram-W4KKPZXB-BM6pMzVZ.js → quadrantDiagram-W4KKPZXB-B3vtZnG7.js} +2 -2
  51. package/dist/record.js +99 -97
  52. package/dist/{requirementDiagram-4Y6WPE33-CNkZDYpb.js → requirementDiagram-4Y6WPE33-Ck8oKzEP.js} +3 -3
  53. package/dist/{sankeyDiagram-5OEKKPKP-Cq6DjItn.js → sankeyDiagram-5OEKKPKP-CSeh32Zo.js} +1 -1
  54. package/dist/{sequenceDiagram-3UESZ5HK-BIzn9dmF.js → sequenceDiagram-3UESZ5HK-NbBPwpmy.js} +3 -3
  55. package/dist/{stateDiagram-AJRCARHV-DbSpH-v9.js → stateDiagram-AJRCARHV-4_Vpe-Zo.js} +4 -4
  56. package/dist/{stateDiagram-v2-BHNVJYJU-Cnv8BTgy.js → stateDiagram-v2-BHNVJYJU-7SjLjguc.js} +2 -2
  57. package/dist/{timeline-definition-PNZ67QCA-Bhs5_-8Z.js → timeline-definition-PNZ67QCA-BNHrT4au.js} +2 -2
  58. package/dist/{useFieldRendering-r1bAnHjk.js → useFieldRendering-DR71Yx2E.js} +28 -28
  59. package/dist/{useVarHelpers-xrbf4f60.js → useVarHelpers-DCu81vu6.js} +609 -609
  60. package/dist/{validation-ZmPcMCY0.js → validation-7k-val2c.js} +1 -1
  61. package/dist/validation-messages-DSKIAWbr.js +33 -0
  62. package/dist/{vennDiagram-CIIHVFJN-DJSLUotN.js → vennDiagram-CIIHVFJN-Dg6RsGJi.js} +1 -1
  63. package/dist/{wardleyDiagram-YWT4CUSO-Bk66hVLg.js → wardleyDiagram-YWT4CUSO-BKzJyt8_.js} +2 -2
  64. package/dist/{xychartDiagram-2RQKCTM6-Bss5MLVp.js → xychartDiagram-2RQKCTM6-DwYEckjZ.js} +2 -2
  65. package/package.json +7 -7
  66. package/src/__tests__/example-record.test.ts +56 -0
  67. package/src/index.ts +1 -0
  68. package/src/locales.ts +3 -28
  69. package/src/record/example-record.ts +66 -0
  70. package/src/record/index.ts +1 -0
  71. package/src/record/validation-messages.ts +32 -0
  72. package/src/styles/index.css +4 -0
@@ -1,4 +1,4 @@
1
- import { ba as Dt, bf as ba, b7 as wa, z as Sa, bl as Pa } from "./useVarHelpers-xrbf4f60.js";
1
+ import { bd as Dt, bi as ba, ba as wa, z as Sa, b3 as Pa } from "./useVarHelpers-DCu81vu6.js";
2
2
  import { g as Bn } from "./_commonjsHelpers-ByX85dGu.js";
3
3
  var Ve = { exports: {} }, Qt = {}, ge = {}, we = {}, Xt = {}, xt = {}, er = {}, pr;
4
4
  function zt() {
@@ -0,0 +1,33 @@
1
+ const $ = {
2
+ "en-US": {
3
+ required: (e) => `${e} is required.`,
4
+ pattern: (e) => `${e} has an invalid format.`,
5
+ enum: (e) => `${e} must use one of the allowed values.`,
6
+ numeric: (e, r) => `${e}: ${r}`,
7
+ type: (e, r) => `${e} must be ${r}.`,
8
+ format: (e, r) => `${e} must use ${r} format.`,
9
+ resource: (e, r) => `${e}: ${r}`,
10
+ resourceInvalid: "Select a valid resource.",
11
+ resourceContainerRequired: "A container must be selected.",
12
+ resourceBookingRequired: "An equipment booking must be selected.",
13
+ schema: (e, r) => `${e}: ${r}`,
14
+ tableCell: (e, r) => `Row ${e}, ${r}`
15
+ },
16
+ "zh-CN": {
17
+ required: (e) => `${e}为必填项。`,
18
+ pattern: (e) => `${e}格式不正确。`,
19
+ enum: (e) => `${e}必须使用允许的选项。`,
20
+ numeric: (e, r) => `${e}:${r}`,
21
+ type: (e, r) => `${e}必须是${r}类型。`,
22
+ format: (e, r) => `${e}必须使用 ${r} 格式。`,
23
+ resource: (e, r) => `${e}:${r}`,
24
+ resourceInvalid: "请选择有效资源。",
25
+ resourceContainerRequired: "必须选择容器。",
26
+ resourceBookingRequired: "必须选择设备预约时段。",
27
+ schema: (e, r) => `${e}:${r}`,
28
+ tableCell: (e, r) => `第 ${e} 行,${r}`
29
+ }
30
+ };
31
+ export {
32
+ $ as v
33
+ };
@@ -1,4 +1,4 @@
1
- import { aU as Gt, s as Wt, g as Kt, t as Ht, q as Yt, a as Xt, b as Zt, _ as w, F as wt, L as Jt, d as ot, al as Qt, ac as $t, ad as te, ae as ee, e as ne, A as se, H as ie, I as oe } from "./mermaid.core-B-O2uDZ3.js";
1
+ import { aU as Gt, s as Wt, g as Kt, t as Ht, q as Yt, a as Xt, b as Zt, _ as w, F as wt, L as Jt, d as ot, al as Qt, ac as $t, ad as te, ae as ee, e as ne, A as se, H as ie, I as oe } from "./mermaid.core-BKkg18RI.js";
2
2
  const kt = (t, n) => Gt(t, "a", -n), _t = 1e-10;
3
3
  function st(t, n) {
4
4
  const s = ae(t), e = s.filter((c) => re(c, t));
@@ -1,5 +1,5 @@
1
- import { s as Mt, g as Nt, t as Lt, q as zt, a as Tt, b as At, _ as u, a1 as Xt, F as Et, H as J, l as Q, L as Yt, e as It, A as Ft, c as V } from "./mermaid.core-B-O2uDZ3.js";
2
- import { p as Bt } from "./chunk-4BX2VUAB-CbV5jCeG.js";
1
+ import { s as Mt, g as Nt, t as Lt, q as zt, a as Tt, b as At, _ as u, a1 as Xt, F as Et, H as J, l as Q, L as Yt, e as It, A as Ft, c as V } from "./mermaid.core-BKkg18RI.js";
2
+ import { p as Bt } from "./chunk-4BX2VUAB-DAJr3925.js";
3
3
  import { p as Rt } from "./wardley-L42UT6IY-D7b2ujEZ.js";
4
4
  var G = /* @__PURE__ */ u((o, r) => {
5
5
  const e = o <= 1 ? o * 100 : o;
@@ -1,7 +1,7 @@
1
- import { s as gi, g as xi, t as Xt, q as di, a as fi, b as pi, _ as a, l as Yt, L as mi, e as yi, A as bi, F as _t, i as Ai, H as Nt, I as wi, a1 as Ci, am as Si, a9 as Wt } from "./mermaid.core-B-O2uDZ3.js";
1
+ import { s as gi, g as xi, t as Xt, q as di, a as fi, b as pi, _ as a, l as Yt, L as mi, e as yi, A as bi, F as _t, i as Ai, H as Nt, I as wi, a1 as Ci, am as Si, a9 as Wt } from "./mermaid.core-BKkg18RI.js";
2
2
  import { i as _i } from "./init-DjUOC4st.js";
3
3
  import { o as ki } from "./ordinal-B6-f3MAq.js";
4
- import { l as zt } from "./linear-DSunMwcT.js";
4
+ import { l as zt } from "./linear-8L3HEUrZ.js";
5
5
  function Ri(e, t, i) {
6
6
  e = +e, t = +t, i = (n = arguments.length) < 2 ? (t = e, e = 0, 1) : n < 3 ? 1 : +i;
7
7
  for (var s = -1, n = Math.max(0, Math.ceil((t - e) / i)) | 0, o = new Array(n); ++s < n; )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airalogy/aimd-recorder",
3
3
  "type": "module",
4
- "version": "1.26.0",
4
+ "version": "1.27.1",
5
5
  "description": "AIMD (Airalogy Markdown) recorder Vue components and UI",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "import": "./dist/record.js"
39
39
  },
40
40
  "./styles": {
41
- "import": "./src/styles/recorder.css",
42
- "default": "./src/styles/recorder.css"
41
+ "import": "./src/styles/index.css",
42
+ "default": "./src/styles/index.css"
43
43
  }
44
44
  },
45
45
  "main": "./dist/index.js",
@@ -67,9 +67,9 @@
67
67
  "react": "^19.2.4",
68
68
  "react-dom": "^19.2.4",
69
69
  "seqviz": "^3.10.18",
70
- "@airalogy/aimd-core": "^2.17.0",
71
- "@airalogy/aimd-editor": "^1.13.0",
72
- "@airalogy/aimd-renderer": "^2.14.0"
70
+ "@airalogy/aimd-core": "^2.18.0",
71
+ "@airalogy/aimd-renderer": "^2.14.0",
72
+ "@airalogy/aimd-editor": "^1.13.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/node": "^24.3.0",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "scripts": {
90
90
  "type-check": "vue-tsc --noEmit",
91
- "build": "vite build",
91
+ "build": "vite build && node --test tests/package-styles.test.mjs",
92
92
  "dev": "vite build --watch",
93
93
  "test": "vitest run --config vitest.config.ts"
94
94
  }
@@ -0,0 +1,56 @@
1
+ import { parseAndExtract } from '@airalogy/aimd-renderer'
2
+ import { describe, expect, it } from 'vitest'
3
+ import { createEmptyProtocolRecordData, createExampleRecord } from '../record'
4
+
5
+ describe('createExampleRecord', () => {
6
+ it('validates field examples before falling back, preserves false and zero and skips references', () => {
7
+ const fields = parseAndExtract('{{var|temp: float, ge=20, le=40, examples=[-1, 37]}} {{var|count: int}} {{var|enabled: bool}} {{var|seq: ATCG}} {{var|scan: FileIdPNG}} {{var|total: int}}')
8
+ fields.client_assigner = parseAndExtract(`
9
+ \`\`\`assigner runtime=client
10
+ assigner({ mode: "auto", dependent_fields: ["count"], assigned_fields: ["total"] }, function calculate({ count }) { return { total: count + 1 }; });
11
+ \`\`\``).client_assigner
12
+ expect(fields.client_assigner).toHaveLength(1)
13
+ const before = JSON.stringify(fields)
14
+ const result = createExampleRecord(fields)
15
+ expect(result.record.var).toEqual({ temp: 37, count: 0, enabled: false, seq: 'ATCG' })
16
+ expect(result.skipped).toEqual(['scan', 'total'])
17
+ result.record.var.temp = 99
18
+ expect(createExampleRecord(fields, { assignedFields: ['temp'] }).record.var.temp).toBeUndefined()
19
+ expect(createExampleRecord(fields).record.var.temp).toBe(37)
20
+ expect(JSON.stringify(fields)).toBe(before)
21
+ expect(createEmptyProtocolRecordData().var).toEqual({})
22
+ })
23
+
24
+ it('honors published schema, nullable enums, and impossible constraints', () => {
25
+ const fields = parseAndExtract('{{var|n: int}} {{var|group}} {{var|tag: str}} {{var|text: str}}')
26
+ const result = createExampleRecord(fields, { locale: 'zh-CN', schema: { research_variable: {
27
+ type: 'object',
28
+ properties: {
29
+ n: { type: 'integer', minimum: 9, maximum: 14, multipleOf: 4 },
30
+ group: { anyOf: [{ $ref: '#/$defs/Group' }, { type: 'null' }] },
31
+ tag: { type: 'string', pattern: '^S-[0-9]+$' },
32
+ },
33
+ $defs: { Group: { type: 'string', enum: ['A', 'B'] } },
34
+ } } })
35
+ expect(result.record.var).toEqual({ n: 12, group: 'A', text: '示例' })
36
+ expect(result.skipped).toEqual(['tag'])
37
+ })
38
+ it('rechecks earlier choices when another candidate changes a conditional requirement', () => {
39
+ const fields = parseAndExtract('{{var|n: int, examples=[1, 2]}} {{var|tag: str, examples=["A", "B"]}}')
40
+ const { record } = createExampleRecord(fields, { schema: { vars: {
41
+ type: 'object',
42
+ properties: { n: { type: 'integer', minimum: 2 }, tag: { type: 'string' } },
43
+ if: { properties: { n: { const: 2 } } },
44
+ then: { properties: { tag: { const: 'B' } } },
45
+ } } })
46
+ expect(record.var).toEqual({ n: 2, tag: 'B' })
47
+ })
48
+
49
+ it('does not return unchecked values when the supplied variables schema cannot compile', () => {
50
+ const fields = parseAndExtract('{{var|n: int}}')
51
+ expect(() => createExampleRecord(fields, { schema: { vars: {
52
+ type: 'object', properties: { n: { type: 'integer', minimum: 'invalid' } },
53
+ } } })).toThrow()
54
+ })
55
+
56
+ })
package/src/index.ts CHANGED
@@ -120,6 +120,7 @@ export {
120
120
  type ResolveAimdRequiredFieldOptions,
121
121
  type ValidateAimdRecordOptions,
122
122
  } from './record/validation'
123
+ export { createExampleRecord, type AimdExampleRecordOptions } from './record/example-record'
123
124
  export { createEmptyProtocolRecordData } from './types'
124
125
  export {
125
126
  BUILT_IN_AIMD_TYPE_PLUGINS,
package/src/locales.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { validationMessages } from "./record/validation-messages"
1
2
  import { getAimdRendererQuizTypeLabel as getSharedRendererQuizTypeLabel } from "@airalogy/aimd-renderer"
2
3
 
3
4
  export type AimdRecorderLocale = "en-US" | "zh-CN"
@@ -452,20 +453,7 @@ const EN_US_MESSAGES: AimdRecorderMessages = {
452
453
  noMatches: "No matches",
453
454
  matchCount: (current, total) => `${current} / ${total}`,
454
455
  },
455
- validation: {
456
- required: label => `${label} is required.`,
457
- pattern: label => `${label} has an invalid format.`,
458
- enum: label => `${label} must use one of the allowed values.`,
459
- numeric: (label, detail) => `${label}: ${detail}`,
460
- type: (label, expected) => `${label} must be ${expected}.`,
461
- format: (label, format) => `${label} must use ${format} format.`,
462
- resource: (label, detail) => `${label}: ${detail}`,
463
- resourceInvalid: "Select a valid resource.",
464
- resourceContainerRequired: "A container must be selected.",
465
- resourceBookingRequired: "An equipment booking must be selected.",
466
- schema: (label, detail) => `${label}: ${detail}`,
467
- tableCell: (row, column) => `Row ${row}, ${column}`,
468
- },
456
+ validation: validationMessages["en-US"],
469
457
  dna: {
470
458
  editMode: "Edit mode",
471
459
  interactiveMode: "Interactive",
@@ -708,20 +696,7 @@ const ZH_CN_MESSAGES: AimdRecorderMessages = {
708
696
  noMatches: "无匹配",
709
697
  matchCount: (current, total) => `${current} / ${total}`,
710
698
  },
711
- validation: {
712
- required: label => `${label}为必填项。`,
713
- pattern: label => `${label}格式不正确。`,
714
- enum: label => `${label}必须使用允许的选项。`,
715
- numeric: (label, detail) => `${label}:${detail}`,
716
- type: (label, expected) => `${label}必须是${expected}类型。`,
717
- format: (label, format) => `${label}必须使用 ${format} 格式。`,
718
- resource: (label, detail) => `${label}:${detail}`,
719
- resourceInvalid: "请选择有效资源。",
720
- resourceContainerRequired: "必须选择容器。",
721
- resourceBookingRequired: "必须选择设备预约时段。",
722
- schema: (label, detail) => `${label}:${detail}`,
723
- tableCell: (row, column) => `第 ${row} 行,${column}`,
724
- },
699
+ validation: validationMessages["zh-CN"],
725
700
  dna: {
726
701
  editMode: "编辑模式",
727
702
  interactiveMode: "交互式",
@@ -0,0 +1,66 @@
1
+ import type { ExtractedAimdFields } from '@airalogy/aimd-core/types'
2
+ import { getAimdFieldExampleCandidates } from '@airalogy/aimd-core/utils'
3
+ import type { AimdRecordValidationSchema } from '../types'
4
+ import { createEmptyProtocolRecordData } from '../types'
5
+ import { validationMessages } from './validation-messages'
6
+ import { validateAimdRecord } from './validation'
7
+
8
+ export interface AimdExampleRecordOptions {
9
+ schema?: AimdRecordValidationSchema
10
+ /** Outputs calculated by the host. Client assigner outputs are detected from AIMD. */
11
+ assignedFields?: readonly string[]
12
+ locale?: string
13
+ exampleText?: string
14
+ }
15
+
16
+ /** Build a new, in-memory test Record without executing assigners or contacting the host. */
17
+ export function createExampleRecord(fields: ExtractedAimdFields, options: AimdExampleRecordOptions = {}) {
18
+ const record = createEmptyProtocolRecordData()
19
+ const skipped: string[] = []
20
+ const outputs = new Set([...(options.assignedFields ?? []), ...fields.client_assigner.flatMap(item => item.assigned_fields)])
21
+ const definitions = new Map(fields.var_definitions?.map(field => [field.id, field]))
22
+ const section = options.schema?.vars ?? options.schema?.research_variable
23
+ const variablesSchema = section && typeof section === 'object' && !Array.isArray(section) ? section as Record<string, unknown> : undefined
24
+ const locale = options.locale?.toLowerCase().startsWith('zh') ? 'zh-CN' : 'en-US'
25
+ const exampleText = options.exampleText ?? (locale === 'zh-CN' ? '示例' : 'Example')
26
+ const remaining = new Map<string, (string | number | boolean)[]>()
27
+
28
+ for (const id of new Set(fields.var)) {
29
+ if (outputs.has(id) || Object.prototype.hasOwnProperty.call(Object.prototype, id) || id === 'prototype') {
30
+ skipped.push(id)
31
+ continue
32
+ }
33
+ const [first, ...alternatives] = getAimdFieldExampleCandidates(definitions.get(id) ?? { id }, { variablesSchema, exampleText })
34
+ if (first === undefined) {
35
+ skipped.push(id)
36
+ continue
37
+ }
38
+ record.var[id] = first
39
+ remaining.set(id, alternatives)
40
+ }
41
+ // Retry rejected values with the same validator that checks a manual Record.
42
+ const messages = validationMessages[locale]
43
+ while (remaining.size) {
44
+ const result = validateAimdRecord(fields, record, { schema: options.schema, messages })
45
+ const schemaIssue = result.issues.find(issue => issue.fieldKey === 'var:$schema')
46
+ if (schemaIssue?.keyword === 'compile') throw new Error(schemaIssue.message)
47
+ const invalid = new Set(result.issues.map(issue => issue.fieldKey))
48
+ if (!invalid.size) break
49
+ let changed = false
50
+ for (const [id, alternatives] of remaining) {
51
+ if (!invalid.has(`var:${id}`)) continue
52
+ changed = true
53
+ if (alternatives.length) record.var[id] = alternatives.shift()
54
+ else {
55
+ delete record.var[id]
56
+ remaining.delete(id)
57
+ skipped.push(id)
58
+ }
59
+ }
60
+ if (!changed) {
61
+ if (schemaIssue) throw new Error(schemaIssue.message)
62
+ break
63
+ }
64
+ }
65
+ return { record, skipped }
66
+ }
@@ -8,6 +8,7 @@ export type {
8
8
  AimdStepRecordItem,
9
9
  AimdStepOrCheckRecordItem,
10
10
  } from '../types'
11
+ export { createExampleRecord, type AimdExampleRecordOptions } from './example-record'
11
12
  export { createEmptyProtocolRecordData } from '../types'
12
13
  export type {
13
14
  AimdRecorderValidationCode,
@@ -0,0 +1,32 @@
1
+ import type { AimdRecorderLocale, AimdRecorderMessages } from "../locales"
2
+
3
+ export const validationMessages: Record<AimdRecorderLocale, AimdRecorderMessages["validation"]> = {
4
+ "en-US": {
5
+ required: label => `${label} is required.`,
6
+ pattern: label => `${label} has an invalid format.`,
7
+ enum: label => `${label} must use one of the allowed values.`,
8
+ numeric: (label, detail) => `${label}: ${detail}`,
9
+ type: (label, expected) => `${label} must be ${expected}.`,
10
+ format: (label, format) => `${label} must use ${format} format.`,
11
+ resource: (label, detail) => `${label}: ${detail}`,
12
+ resourceInvalid: "Select a valid resource.",
13
+ resourceContainerRequired: "A container must be selected.",
14
+ resourceBookingRequired: "An equipment booking must be selected.",
15
+ schema: (label, detail) => `${label}: ${detail}`,
16
+ tableCell: (row, column) => `Row ${row}, ${column}`,
17
+ },
18
+ "zh-CN": {
19
+ required: label => `${label}为必填项。`,
20
+ pattern: label => `${label}格式不正确。`,
21
+ enum: label => `${label}必须使用允许的选项。`,
22
+ numeric: (label, detail) => `${label}:${detail}`,
23
+ type: (label, expected) => `${label}必须是${expected}类型。`,
24
+ format: (label, format) => `${label}必须使用 ${format} 格式。`,
25
+ resource: (label, detail) => `${label}:${detail}`,
26
+ resourceInvalid: "请选择有效资源。",
27
+ resourceContainerRequired: "必须选择容器。",
28
+ resourceBookingRequired: "必须选择设备预约时段。",
29
+ schema: (label, detail) => `${label}:${detail}`,
30
+ tableCell: (row, column) => `第 ${row} 行,${column}`,
31
+ },
32
+ }
@@ -0,0 +1,4 @@
1
+ /* Keep the scoped styles emitted with the compiled Vue components together
2
+ * with the shared Recorder/Renderer rules behind the public styles entry. */
3
+ @import "../../dist/aimd-recorder.css";
4
+ @import "./recorder.css";