@airalogy/aimd-recorder 1.24.4 → 1.25.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 +13 -1
- package/README.zh-CN.md +13 -1
- package/dist/{AimdDnaSequenceField-Opgy07Gt.js → AimdDnaSequenceField-BHV1_c2o.js} +1 -1
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-DHckC0bq.js → AimdEditor.vue_vue_type_style_index_0_lang-phvUVTHV.js} +643 -605
- package/dist/AimdEntityRefField-COzwbHwr.js +4 -0
- package/dist/{AimdEntityRefField-GA6-mhGU.js → AimdEntityRefField.vue_vue_type_script_setup_true_lang-BIvUuZFV.js} +2 -2
- package/dist/{AimdMarkdownField-jagZIbKc.js → AimdMarkdownField-t8hqazDv.js} +3 -3
- package/dist/{AimdMarkdownNoteField-BUq4fRcZ.js → AimdMarkdownNoteField-BGjkSXEY.js} +2 -2
- package/dist/AimdResourceRefField-BBaRSLcL.js +264 -0
- package/dist/aimd-recorder.css +1 -1
- package/dist/{arc-CR1cpc2k.js → arc-CsBMJYPv.js} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-B8OoiHF6.js → architectureDiagram-3BPJPVTR-BeKUSqHO.js} +2 -2
- package/dist/{blockDiagram-GPEHLZMM-Ddq40SrW.js → blockDiagram-GPEHLZMM-CJeAC_1p.js} +4 -4
- package/dist/{c4Diagram-AAUBKEIU-Cf3cjJMq.js → c4Diagram-AAUBKEIU-LoQMp4kW.js} +2 -2
- package/dist/{channel-C8Vd7nOK.js → channel-BoLQO6Dk.js} +1 -1
- package/dist/{chunk-2J33WTMH-Ck31ftjD.js → chunk-2J33WTMH-D1vw38h5.js} +1 -1
- package/dist/{chunk-4BX2VUAB-BJOkbq4i.js → chunk-4BX2VUAB-BFSVnsyi.js} +1 -1
- package/dist/{chunk-55IACEB6-lNZxrJyO.js → chunk-55IACEB6-D13UaCP1.js} +1 -1
- package/dist/{chunk-727SXJPM-mEDRtdd4.js → chunk-727SXJPM-BCcz4POX.js} +5 -5
- package/dist/{chunk-AQP2D5EJ-C1MU-m_K.js → chunk-AQP2D5EJ-DTOfpg2m.js} +3 -3
- package/dist/{chunk-FMBD7UC4-Pmfg_1nq.js → chunk-FMBD7UC4-XGRN-sFg.js} +1 -1
- package/dist/{chunk-ND2GUHAM-CipPchY0.js → chunk-ND2GUHAM-DSgp1I9F.js} +1 -1
- package/dist/{chunk-QZHKN3VN-BvE9EC7r.js → chunk-QZHKN3VN-DQl3-kKo.js} +1 -1
- package/dist/{classDiagram-v2-Q7XG4LA2-BM5OaktU.js → classDiagram-4FO5ZUOK-CI-4bhme.js} +2 -2
- package/dist/{classDiagram-4FO5ZUOK-BM5OaktU.js → classDiagram-v2-Q7XG4LA2-CI-4bhme.js} +2 -2
- package/dist/components.js +2222 -2110
- package/dist/composables.js +2 -2
- package/dist/{cose-bilkent-S5V4N54A-nmO7LFhz.js → cose-bilkent-S5V4N54A-CU1K-fx3.js} +1 -1
- package/dist/{dagre-BM42HDAG-D3xhjRxX.js → dagre-BM42HDAG-HIHsvvPF.js} +3 -3
- package/dist/{diagram-2AECGRRQ-kCJcuZOT.js → diagram-2AECGRRQ-XlYRVMia.js} +2 -2
- package/dist/{diagram-5GNKFQAL-Bdr1oGkv.js → diagram-5GNKFQAL-BeA9dVE2.js} +3 -3
- package/dist/{diagram-KO2AKTUF-CeBpcrbw.js → diagram-KO2AKTUF-D501LuyG.js} +2 -2
- package/dist/{diagram-LMA3HP47-C5oYYzCp.js → diagram-LMA3HP47-ClkmdOf_.js} +2 -2
- package/dist/{diagram-OG6HWLK6-CNzZuxZL.js → diagram-OG6HWLK6-30O5epks.js} +3 -3
- package/dist/{erDiagram-TEJ5UH35-MWNh4yWB.js → erDiagram-TEJ5UH35-Dk5azNFu.js} +4 -4
- package/dist/{flowDiagram-I6XJVG4X-DcREbXha.js → flowDiagram-I6XJVG4X-C4K9bB2d.js} +6 -6
- package/dist/{ganttDiagram-6RSMTGT7-DGZUsfa4.js → ganttDiagram-6RSMTGT7-sFuSkRH3.js} +2 -2
- package/dist/{gitGraphDiagram-PVQCEYII-DhpcTOAS.js → gitGraphDiagram-PVQCEYII-CC4Kf_0S.js} +3 -3
- package/dist/{graph-CXU7Rv38.js → graph-BBr12s4M.js} +1 -1
- package/dist/index.js +124 -122
- package/dist/{infoDiagram-5YYISTIA-CVZBlZ8R.js → infoDiagram-5YYISTIA-PObcwLKW.js} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-Bjyc47Lv.js → ishikawaDiagram-YF4QCWOH-B93dpm60.js} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-e2G_PVGF.js → journeyDiagram-JHISSGLW-Z0_jIQ5z.js} +4 -4
- package/dist/{kanban-definition-UN3LZRKU-CKOBjcK9.js → kanban-definition-UN3LZRKU-BicW7pfZ.js} +2 -2
- package/dist/{layout-CBS27QDo.js → layout-jm5q2dTB.js} +2 -2
- package/dist/{linear-UyXZcrYY.js → linear-Bv4EbUf4.js} +1 -1
- package/dist/{mermaid.core-BeKK51C9.js → mermaid.core-BN0BM26i.js} +34 -34
- package/dist/{mindmap-definition-RKZ34NQL-T6_bnhal.js → mindmap-definition-RKZ34NQL-Ba85mo62.js} +3 -3
- package/dist/{pieDiagram-4H26LBE5-GGANuPvf.js → pieDiagram-4H26LBE5-CfU3ahlI.js} +3 -3
- package/dist/{quadrantDiagram-W4KKPZXB-BAtVKEgW.js → quadrantDiagram-W4KKPZXB-BPTjR1PA.js} +2 -2
- package/dist/record.js +2 -2
- package/dist/{requirementDiagram-4Y6WPE33-C2oozBsJ.js → requirementDiagram-4Y6WPE33-DVfyUAUL.js} +3 -3
- package/dist/{sankeyDiagram-5OEKKPKP-Bfc4Y-JM.js → sankeyDiagram-5OEKKPKP-B_9c0VJt.js} +1 -1
- package/dist/{sequenceDiagram-3UESZ5HK-e9yMBU3K.js → sequenceDiagram-3UESZ5HK-BFSDCMig.js} +3 -3
- package/dist/{stateDiagram-AJRCARHV-D1vciiPs.js → stateDiagram-AJRCARHV-DNCya3UT.js} +4 -4
- package/dist/{stateDiagram-v2-BHNVJYJU-DMXm3rUm.js → stateDiagram-v2-BHNVJYJU-BlmsFnk2.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-Cg7TL_0Q.js → timeline-definition-PNZ67QCA-B297WQKg.js} +2 -2
- package/dist/{useFieldRendering-JFnqNEWH.js → useFieldRendering-DQN_MbSg.js} +1 -1
- package/dist/{useVarHelpers-CQQ-zhL0.js → useVarHelpers-D00Za8e6.js} +978 -932
- package/dist/validation-Dn_j1py1.js +5712 -0
- package/dist/{vennDiagram-CIIHVFJN-BEJdgPK5.js → vennDiagram-CIIHVFJN-gDmDgx6K.js} +1 -1
- package/dist/{wardleyDiagram-YWT4CUSO-DLxpx6Lm.js → wardleyDiagram-YWT4CUSO-ek5B-FUl.js} +2 -2
- package/dist/{xychartDiagram-2RQKCTM6-CG-K6knD.js → xychartDiagram-2RQKCTM6-DRtlxacH.js} +2 -2
- package/package.json +4 -4
- package/src/__tests__/record-validation.test.ts +121 -0
- package/src/__tests__/required-marker.test.ts +14 -0
- package/src/__tests__/resource-form.test.ts +20 -0
- package/src/__tests__/resource-ref-field.test.ts +125 -0
- package/src/__tests__/var-field-render.test.ts +87 -1
- package/src/components/AimdRecorder.vue +11 -1
- package/src/components/AimdRecorderEditor.vue +5 -0
- package/src/components/AimdRecorderWysiwygFieldHost.vue +1 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +5 -0
- package/src/components/AimdResourceForm.vue +129 -0
- package/src/components/AimdResourceRefField.vue +393 -0
- package/src/components/AimdVarField.vue +41 -3
- package/src/components/index.ts +4 -0
- package/src/components/recorderMilkdownPlugin.ts +2 -0
- package/src/composables/__tests__/useVarHelpers.test.ts +96 -0
- package/src/composables/useVarHelpers.ts +91 -4
- package/src/index.ts +12 -1
- package/src/locales.ts +57 -0
- package/src/record/validation.ts +145 -11
- package/src/styles/recorder.css +8 -0
- package/src/types.ts +30 -1
- package/dist/validation-DSn_Ttx_.js +0 -5629
|
@@ -7,8 +7,11 @@ import {
|
|
|
7
7
|
getScalarListInputItems,
|
|
8
8
|
getScalarListItemType,
|
|
9
9
|
getEntityRefTypeConfig,
|
|
10
|
+
getResourceRefTypeConfig,
|
|
11
|
+
isIntegerVarType,
|
|
10
12
|
isNullableVarType,
|
|
11
13
|
isEntityRefVarType,
|
|
14
|
+
isResourceRefVarType,
|
|
12
15
|
isScalarListVarType,
|
|
13
16
|
isStructuredVarType,
|
|
14
17
|
normalizeScalarListInputItems,
|
|
@@ -145,6 +148,12 @@ describe('getVarInputKind', () => {
|
|
|
145
148
|
expect(getVarInputKind('list[EntityRef["plasmid"]]')).toBe('entity-ref')
|
|
146
149
|
})
|
|
147
150
|
|
|
151
|
+
it('returns "resource-ref" for ResourceRef types before structured fallbacks', () => {
|
|
152
|
+
expect(getVarInputKind('ResourceRef')).toBe('resource-ref')
|
|
153
|
+
expect(getVarInputKind('ResourceRef["plasmid"] | None')).toBe('resource-ref')
|
|
154
|
+
expect(getVarInputKind('list[ResourceRef["sample"]]')).toBe('resource-ref')
|
|
155
|
+
})
|
|
156
|
+
|
|
148
157
|
it('returns "textarea" for structured non-scalar list and object types', () => {
|
|
149
158
|
expect(getVarInputKind('list')).toBe('textarea')
|
|
150
159
|
expect(getVarInputKind('list[bool]')).toBe('textarea')
|
|
@@ -202,6 +211,48 @@ describe('EntityRef helpers', () => {
|
|
|
202
211
|
})
|
|
203
212
|
})
|
|
204
213
|
|
|
214
|
+
describe('ResourceRef helpers', () => {
|
|
215
|
+
it('detects ResourceRef annotations and normalizes inventory metadata', () => {
|
|
216
|
+
expect(isResourceRefVarType('ResourceRef["plasmid"] | None')).toBe(true)
|
|
217
|
+
expect(isResourceRefVarType('EntityRef["plasmid"]')).toBe(false)
|
|
218
|
+
expect(getResourceRefTypeConfig(
|
|
219
|
+
'ResourceRef["plasmid"]',
|
|
220
|
+
{
|
|
221
|
+
resource_role: 'input',
|
|
222
|
+
quantity_field: 'amount',
|
|
223
|
+
container_required: true,
|
|
224
|
+
},
|
|
225
|
+
)).toEqual({
|
|
226
|
+
multiple: false,
|
|
227
|
+
entity: 'plasmid',
|
|
228
|
+
source: undefined,
|
|
229
|
+
role: 'input',
|
|
230
|
+
quantityField: 'amount',
|
|
231
|
+
containerRequired: true,
|
|
232
|
+
bookingRequired: false,
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('supports equipment and list ResourceRef metadata', () => {
|
|
237
|
+
expect(getResourceRefTypeConfig(
|
|
238
|
+
'list[ResourceRef["equipment"]] | None',
|
|
239
|
+
{
|
|
240
|
+
resource_role: 'equipment',
|
|
241
|
+
booking_required: true,
|
|
242
|
+
source: 'lab-equipment',
|
|
243
|
+
},
|
|
244
|
+
)).toEqual({
|
|
245
|
+
multiple: true,
|
|
246
|
+
entity: 'equipment',
|
|
247
|
+
source: 'lab-equipment',
|
|
248
|
+
role: 'equipment',
|
|
249
|
+
quantityField: undefined,
|
|
250
|
+
containerRequired: false,
|
|
251
|
+
bookingRequired: true,
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
|
|
205
256
|
// ---------------------------------------------------------------------------
|
|
206
257
|
// File-like vars
|
|
207
258
|
// ---------------------------------------------------------------------------
|
|
@@ -275,6 +326,15 @@ describe('file-like var helpers', () => {
|
|
|
275
326
|
// ---------------------------------------------------------------------------
|
|
276
327
|
|
|
277
328
|
describe('numeric field constraints', () => {
|
|
329
|
+
it('recognizes nullable integer annotations as integer types', () => {
|
|
330
|
+
expect(isIntegerVarType('int')).toBe(true)
|
|
331
|
+
expect(isIntegerVarType('int | None')).toBe(true)
|
|
332
|
+
expect(isIntegerVarType('None | integer')).toBe(true)
|
|
333
|
+
expect(isIntegerVarType('Optional[int]')).toBe(true)
|
|
334
|
+
expect(isIntegerVarType('typing.Optional[integer]')).toBe(true)
|
|
335
|
+
expect(isIntegerVarType('float | None')).toBe(false)
|
|
336
|
+
})
|
|
337
|
+
|
|
278
338
|
it('reads Pydantic-style numeric constraints only for numeric var types', () => {
|
|
279
339
|
expect(getNumericFieldConstraints('float', { gt: 0, le: 100, multiple_of: 0.5 })).toEqual({
|
|
280
340
|
gt: 0,
|
|
@@ -867,6 +927,42 @@ describe('measureVarLabelWidth', () => {
|
|
|
867
927
|
|
|
868
928
|
expect(measureVarLabelWidth(wrapper)).toBeGreaterThan(220)
|
|
869
929
|
})
|
|
930
|
+
|
|
931
|
+
it('reserves label width for required markers', () => {
|
|
932
|
+
vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockImplementation(() => ({
|
|
933
|
+
measureText: (text: string) => ({ width: text.length * 8 }),
|
|
934
|
+
} as unknown as CanvasRenderingContext2D))
|
|
935
|
+
vi.spyOn(window, 'getComputedStyle').mockImplementation((element: Element) => {
|
|
936
|
+
const classList = (element as HTMLElement).classList
|
|
937
|
+
return {
|
|
938
|
+
fontSize: '14px',
|
|
939
|
+
fontFamily: 'sans-serif',
|
|
940
|
+
fontWeight: '500',
|
|
941
|
+
fontStyle: 'normal',
|
|
942
|
+
paddingLeft: classList.contains('aimd-field__name') ? '16px' : '0px',
|
|
943
|
+
paddingRight: classList.contains('aimd-field__scope--var') ? '14px' : '0px',
|
|
944
|
+
borderLeftWidth: '0px',
|
|
945
|
+
borderRightWidth: '0px',
|
|
946
|
+
marginLeft: classList.contains('aimd-field__required-marker') ? '4px' : '0px',
|
|
947
|
+
marginRight: classList.contains('aimd-field__required-marker') ? '5px' : '0px',
|
|
948
|
+
} as CSSStyleDeclaration
|
|
949
|
+
})
|
|
950
|
+
|
|
951
|
+
const optionalWrapper = document.createElement('span')
|
|
952
|
+
optionalWrapper.innerHTML = `
|
|
953
|
+
<span class="aimd-field__label">
|
|
954
|
+
<span class="aimd-field__scope aimd-field__scope--var">var</span>
|
|
955
|
+
<span class="aimd-field__name"><span class="aimd-field__title">age</span></span>
|
|
956
|
+
</span>
|
|
957
|
+
`
|
|
958
|
+
const requiredWrapper = optionalWrapper.cloneNode(true) as HTMLElement
|
|
959
|
+
const requiredTitle = requiredWrapper.querySelector('.aimd-field__title')
|
|
960
|
+
requiredTitle?.insertAdjacentHTML('afterend', '<span class="aimd-field__required-marker">*</span>')
|
|
961
|
+
requiredTitle?.parentElement?.classList.add('aimd-field__title-row')
|
|
962
|
+
document.body.append(optionalWrapper, requiredWrapper)
|
|
963
|
+
|
|
964
|
+
expect(measureVarLabelWidth(requiredWrapper)).toBeGreaterThan(measureVarLabelWidth(optionalWrapper))
|
|
965
|
+
})
|
|
870
966
|
})
|
|
871
967
|
|
|
872
968
|
// ---------------------------------------------------------------------------
|
|
@@ -76,6 +76,13 @@ export interface EntityRefTypeConfig {
|
|
|
76
76
|
source?: string
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
export interface ResourceRefTypeConfig extends EntityRefTypeConfig {
|
|
80
|
+
role: "input" | "output" | "reference" | "equipment"
|
|
81
|
+
quantityField?: string
|
|
82
|
+
containerRequired: boolean
|
|
83
|
+
bookingRequired: boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
export function getFileInputConfig(
|
|
80
87
|
type: string | undefined,
|
|
81
88
|
kwargs?: Record<string, unknown>,
|
|
@@ -199,6 +206,10 @@ function resolveOverrideInputKind(inputType: string | undefined, codeLanguage: s
|
|
|
199
206
|
return 'entity-ref'
|
|
200
207
|
}
|
|
201
208
|
|
|
209
|
+
if (normalized === 'resourceref' || normalized === 'resource-ref') {
|
|
210
|
+
return 'resource-ref'
|
|
211
|
+
}
|
|
212
|
+
|
|
202
213
|
if (normalized === 'dna') {
|
|
203
214
|
return 'dna'
|
|
204
215
|
}
|
|
@@ -330,6 +341,11 @@ export function isNumericVarType(type: string | undefined): boolean {
|
|
|
330
341
|
return normalized === "float" || normalized === "int" || normalized === "integer" || normalized === "number"
|
|
331
342
|
}
|
|
332
343
|
|
|
344
|
+
export function isIntegerVarType(type: string | undefined): boolean {
|
|
345
|
+
const normalized = normalizeVarTypeName(unwrapOptionalTypeAnnotation(type))
|
|
346
|
+
return normalized === "int" || normalized === "integer"
|
|
347
|
+
}
|
|
348
|
+
|
|
333
349
|
function getScalarListItemTypeFromExpression(type: string | undefined): ScalarListItemType | undefined {
|
|
334
350
|
const normalized = canonicalizeTypeExpression(type).replace(/^typing\./, "")
|
|
335
351
|
if (normalized === "str" || normalized === "string" || normalized === "builtins.str") {
|
|
@@ -369,11 +385,73 @@ function getEntityFromEntityRefExpression(type: string | undefined): string | un
|
|
|
369
385
|
return match ? stripTypeArgumentQuotes(match[1]) : undefined
|
|
370
386
|
}
|
|
371
387
|
|
|
388
|
+
function getEntityFromResourceRefExpression(type: string | undefined): string | undefined {
|
|
389
|
+
const normalized = canonicalizeTypeExpression(type).replace(/^typing\./, "")
|
|
390
|
+
const match = normalized.match(/^(?:airalogy\.types\.)?resourceref(?:\[(.*)\])?$/)
|
|
391
|
+
return match ? stripTypeArgumentQuotes(match[1]) : undefined
|
|
392
|
+
}
|
|
393
|
+
|
|
372
394
|
function isEntityRefExpression(type: string | undefined): boolean {
|
|
373
395
|
const normalized = canonicalizeTypeExpression(type).replace(/^typing\./, "")
|
|
374
396
|
return /^(?:airalogy\.types\.)?entityref(?:\[.*\])?$/.test(normalized)
|
|
375
397
|
}
|
|
376
398
|
|
|
399
|
+
function isResourceRefExpression(type: string | undefined): boolean {
|
|
400
|
+
const normalized = canonicalizeTypeExpression(type).replace(/^typing\./, "")
|
|
401
|
+
return /^(?:airalogy\.types\.)?resourceref(?:\[.*\])?$/.test(normalized)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export function getResourceRefTypeConfig(
|
|
405
|
+
type: string | undefined,
|
|
406
|
+
kwargs?: Record<string, unknown>,
|
|
407
|
+
fieldMeta?: AimdFieldMeta,
|
|
408
|
+
): ResourceRefTypeConfig | undefined {
|
|
409
|
+
const unwrapped = unwrapOptionalTypeAnnotation(type)
|
|
410
|
+
const compact = canonicalizeTypeExpression(unwrapped).replace(/^typing\./, "")
|
|
411
|
+
let multiple = false
|
|
412
|
+
let expressionEntity = getEntityFromResourceRefExpression(unwrapped)
|
|
413
|
+
let resourceRef = isResourceRefExpression(unwrapped)
|
|
414
|
+
const listMatch = compact.match(/^(?:list|array)\[(.*)\]$/)
|
|
415
|
+
if (listMatch) {
|
|
416
|
+
multiple = true
|
|
417
|
+
expressionEntity = getEntityFromResourceRefExpression(listMatch[1])
|
|
418
|
+
resourceRef = isResourceRefExpression(listMatch[1])
|
|
419
|
+
}
|
|
420
|
+
else if (compact.endsWith("[]")) {
|
|
421
|
+
multiple = true
|
|
422
|
+
const itemType = compact.slice(0, -2)
|
|
423
|
+
expressionEntity = getEntityFromResourceRefExpression(itemType)
|
|
424
|
+
resourceRef = isResourceRefExpression(itemType)
|
|
425
|
+
}
|
|
426
|
+
if (!resourceRef) return undefined
|
|
427
|
+
|
|
428
|
+
const roleValue = fieldMeta?.resource_role ?? kwargs?.resource_role
|
|
429
|
+
const role = ["input", "output", "reference", "equipment"].includes(String(roleValue))
|
|
430
|
+
? roleValue as ResourceRefTypeConfig["role"]
|
|
431
|
+
: "reference"
|
|
432
|
+
return {
|
|
433
|
+
multiple,
|
|
434
|
+
entity: normalizeEntityRefMetadataString(fieldMeta?.entity)
|
|
435
|
+
?? normalizeEntityRefMetadataString(kwargs?.entity)
|
|
436
|
+
?? expressionEntity,
|
|
437
|
+
source: normalizeEntityRefMetadataString(fieldMeta?.source)
|
|
438
|
+
?? normalizeEntityRefMetadataString(kwargs?.source),
|
|
439
|
+
role,
|
|
440
|
+
quantityField: normalizeEntityRefMetadataString(fieldMeta?.quantity_field)
|
|
441
|
+
?? normalizeEntityRefMetadataString(kwargs?.quantity_field),
|
|
442
|
+
containerRequired: fieldMeta?.container_required === true || kwargs?.container_required === true,
|
|
443
|
+
bookingRequired: fieldMeta?.booking_required === true || kwargs?.booking_required === true,
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export function isResourceRefVarType(
|
|
448
|
+
type: string | undefined,
|
|
449
|
+
kwargs?: Record<string, unknown>,
|
|
450
|
+
fieldMeta?: AimdFieldMeta,
|
|
451
|
+
): boolean {
|
|
452
|
+
return getResourceRefTypeConfig(type, kwargs, fieldMeta) !== undefined
|
|
453
|
+
}
|
|
454
|
+
|
|
377
455
|
export function getEntityRefTypeConfig(
|
|
378
456
|
type: string | undefined,
|
|
379
457
|
kwargs?: Record<string, unknown>,
|
|
@@ -464,6 +542,10 @@ export function getVarInputKind(type: string | undefined, options: VarInputKindO
|
|
|
464
542
|
return typePlugin.inputKind
|
|
465
543
|
}
|
|
466
544
|
|
|
545
|
+
if (isResourceRefVarType(type, options.kwargs, options.fieldMeta)) {
|
|
546
|
+
return "resource-ref"
|
|
547
|
+
}
|
|
548
|
+
|
|
467
549
|
if (isEntityRefVarType(type, options.kwargs, options.fieldMeta)) {
|
|
468
550
|
return "entity-ref"
|
|
469
551
|
}
|
|
@@ -904,7 +986,7 @@ export function getVarInputDisplayValue(
|
|
|
904
986
|
))
|
|
905
987
|
}
|
|
906
988
|
|
|
907
|
-
if (kind === "entity-ref") {
|
|
989
|
+
if (kind === "entity-ref" || kind === "resource-ref") {
|
|
908
990
|
return getEntityRefDisplayValue(normalized)
|
|
909
991
|
}
|
|
910
992
|
|
|
@@ -1017,7 +1099,8 @@ function getVarControlMinWidth(inputKind: VarInputKind): number {
|
|
|
1017
1099
|
case "file":
|
|
1018
1100
|
case "scalar-list":
|
|
1019
1101
|
case "entity-ref":
|
|
1020
|
-
|
|
1102
|
+
case "resource-ref":
|
|
1103
|
+
return inputKind === "scalar-list" || inputKind === "entity-ref" || inputKind === "resource-ref" ? 220 : 160
|
|
1021
1104
|
default:
|
|
1022
1105
|
return 0
|
|
1023
1106
|
}
|
|
@@ -1035,6 +1118,7 @@ function getVarControlExtraWidth(inputKind: VarInputKind): number {
|
|
|
1035
1118
|
return 24
|
|
1036
1119
|
case "scalar-list":
|
|
1037
1120
|
case "entity-ref":
|
|
1121
|
+
case "resource-ref":
|
|
1038
1122
|
return 16
|
|
1039
1123
|
default:
|
|
1040
1124
|
return 4
|
|
@@ -1137,8 +1221,11 @@ function getElementHorizontalSpace(element: HTMLElement): number {
|
|
|
1137
1221
|
function measureFieldNameWidth(name: HTMLElement): number {
|
|
1138
1222
|
const title = name.querySelector(".aimd-field__title") as HTMLElement | null
|
|
1139
1223
|
const key = name.querySelector(".aimd-field__key") as HTMLElement | null
|
|
1224
|
+
const requiredMarker = name.querySelector(".aimd-field__required-marker") as HTMLElement | null
|
|
1225
|
+
const titleRowWidth = (title ? measureLabelTokenWidth(title) : 0)
|
|
1226
|
+
+ (requiredMarker ? measureLabelTokenWidth(requiredMarker) : 0)
|
|
1140
1227
|
const visibleTokenWidth = Math.max(
|
|
1141
|
-
|
|
1228
|
+
titleRowWidth,
|
|
1142
1229
|
key ? measureLabelTokenWidth(key) : 0,
|
|
1143
1230
|
)
|
|
1144
1231
|
|
|
@@ -1230,7 +1317,7 @@ export function applyVarStackWidth(target: HTMLElement, inputKind: VarInputKind)
|
|
|
1230
1317
|
return
|
|
1231
1318
|
}
|
|
1232
1319
|
|
|
1233
|
-
if (inputKind === "scalar-list" || inputKind === "entity-ref") {
|
|
1320
|
+
if (inputKind === "scalar-list" || inputKind === "entity-ref" || inputKind === "resource-ref") {
|
|
1234
1321
|
wrapper.style.width = "100%"
|
|
1235
1322
|
wrapper.style.maxWidth = "100%"
|
|
1236
1323
|
return
|
package/src/index.ts
CHANGED
|
@@ -17,8 +17,9 @@ export {
|
|
|
17
17
|
AimdRecorderEditor,
|
|
18
18
|
AimdQuizRecorder,
|
|
19
19
|
AimdRequiredMarker,
|
|
20
|
+
AimdResourceForm,
|
|
20
21
|
} from './components'
|
|
21
|
-
export { AimdDnaSequenceField, AimdEntityRefField, AimdMarkdownField } from './components'
|
|
22
|
+
export { AimdDnaSequenceField, AimdEntityRefField, AimdMarkdownField, AimdResourceRefField } from './components'
|
|
22
23
|
/**
|
|
23
24
|
* @deprecated Use `AimdRecorder` instead.
|
|
24
25
|
*/
|
|
@@ -65,6 +66,16 @@ export type {
|
|
|
65
66
|
AimdEntityRefOption,
|
|
66
67
|
AimdEntityRefValue,
|
|
67
68
|
AimdEntitySearchHandler,
|
|
69
|
+
AimdEquipmentSlotOption,
|
|
70
|
+
AimdPreparedResourceOutput,
|
|
71
|
+
AimdResourceAvailability,
|
|
72
|
+
AimdResourceContainerOption,
|
|
73
|
+
AimdResourceLotOption,
|
|
74
|
+
AimdResourceRefOption,
|
|
75
|
+
AimdResourceRefValue,
|
|
76
|
+
AimdResourceResolveContext,
|
|
77
|
+
AimdResourceResolver,
|
|
78
|
+
AimdResourceResolverMap,
|
|
68
79
|
AimdResolvedFileInfo,
|
|
69
80
|
AimdSelectedFileValue,
|
|
70
81
|
AimdTypePlugin,
|
package/src/locales.ts
CHANGED
|
@@ -118,6 +118,21 @@ export interface AimdRecorderMessages {
|
|
|
118
118
|
noMatches: string
|
|
119
119
|
searchFailed: string
|
|
120
120
|
}
|
|
121
|
+
resourceRef: {
|
|
122
|
+
availability: string
|
|
123
|
+
available: string
|
|
124
|
+
lot: string
|
|
125
|
+
container: string
|
|
126
|
+
quantity: string
|
|
127
|
+
unit: string
|
|
128
|
+
booking: string
|
|
129
|
+
selectLot: string
|
|
130
|
+
selectContainer: string
|
|
131
|
+
selectBooking: string
|
|
132
|
+
availabilityFailed: string
|
|
133
|
+
prepareOutputFailed: string
|
|
134
|
+
quantityFrom: (field: string) => string
|
|
135
|
+
}
|
|
121
136
|
collector: {
|
|
122
137
|
snapshot: string
|
|
123
138
|
start: string
|
|
@@ -161,6 +176,10 @@ export interface AimdRecorderMessages {
|
|
|
161
176
|
numeric: (label: string, detail: string) => string
|
|
162
177
|
type: (label: string, expected: string) => string
|
|
163
178
|
format: (label: string, format: string) => string
|
|
179
|
+
resource: (label: string, detail: string) => string
|
|
180
|
+
resourceInvalid: string
|
|
181
|
+
resourceContainerRequired: string
|
|
182
|
+
resourceBookingRequired: string
|
|
164
183
|
schema: (label: string, detail: string) => string
|
|
165
184
|
tableCell: (row: number, column: string) => string
|
|
166
185
|
}
|
|
@@ -373,6 +392,21 @@ const EN_US_MESSAGES: AimdRecorderMessages = {
|
|
|
373
392
|
noMatches: "No matching entities",
|
|
374
393
|
searchFailed: "Entity search failed.",
|
|
375
394
|
},
|
|
395
|
+
resourceRef: {
|
|
396
|
+
availability: "Availability",
|
|
397
|
+
available: "Available",
|
|
398
|
+
lot: "Lot",
|
|
399
|
+
container: "Container",
|
|
400
|
+
quantity: "Quantity",
|
|
401
|
+
unit: "Unit",
|
|
402
|
+
booking: "Booking",
|
|
403
|
+
selectLot: "Select a lot",
|
|
404
|
+
selectContainer: "Select a container",
|
|
405
|
+
selectBooking: "Select a time slot",
|
|
406
|
+
availabilityFailed: "Resource availability could not be loaded.",
|
|
407
|
+
prepareOutputFailed: "The output resource could not be prepared.",
|
|
408
|
+
quantityFrom: field => `Quantity is read from ${field}.`,
|
|
409
|
+
},
|
|
376
410
|
collector: {
|
|
377
411
|
snapshot: "Read now",
|
|
378
412
|
start: "Start collecting",
|
|
@@ -425,6 +459,10 @@ const EN_US_MESSAGES: AimdRecorderMessages = {
|
|
|
425
459
|
numeric: (label, detail) => `${label}: ${detail}`,
|
|
426
460
|
type: (label, expected) => `${label} must be ${expected}.`,
|
|
427
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.",
|
|
428
466
|
schema: (label, detail) => `${label}: ${detail}`,
|
|
429
467
|
tableCell: (row, column) => `Row ${row}, ${column}`,
|
|
430
468
|
},
|
|
@@ -610,6 +648,21 @@ const ZH_CN_MESSAGES: AimdRecorderMessages = {
|
|
|
610
648
|
noMatches: "没有匹配的实体",
|
|
611
649
|
searchFailed: "实体搜索失败。",
|
|
612
650
|
},
|
|
651
|
+
resourceRef: {
|
|
652
|
+
availability: "可用情况",
|
|
653
|
+
available: "可用量",
|
|
654
|
+
lot: "批次",
|
|
655
|
+
container: "容器",
|
|
656
|
+
quantity: "数量",
|
|
657
|
+
unit: "单位",
|
|
658
|
+
booking: "设备预约",
|
|
659
|
+
selectLot: "选择批次",
|
|
660
|
+
selectContainer: "选择容器",
|
|
661
|
+
selectBooking: "选择可用时段",
|
|
662
|
+
availabilityFailed: "无法读取资源可用情况。",
|
|
663
|
+
prepareOutputFailed: "无法准备产出资源。",
|
|
664
|
+
quantityFrom: field => `数量读取自 ${field}。`,
|
|
665
|
+
},
|
|
613
666
|
collector: {
|
|
614
667
|
snapshot: "立即采集",
|
|
615
668
|
start: "开始采集",
|
|
@@ -662,6 +715,10 @@ const ZH_CN_MESSAGES: AimdRecorderMessages = {
|
|
|
662
715
|
numeric: (label, detail) => `${label}:${detail}`,
|
|
663
716
|
type: (label, expected) => `${label}必须是${expected}类型。`,
|
|
664
717
|
format: (label, format) => `${label}必须使用 ${format} 格式。`,
|
|
718
|
+
resource: (label, detail) => `${label}:${detail}`,
|
|
719
|
+
resourceInvalid: "请选择有效资源。",
|
|
720
|
+
resourceContainerRequired: "必须选择容器。",
|
|
721
|
+
resourceBookingRequired: "必须选择设备预约时段。",
|
|
665
722
|
schema: (label, detail) => `${label}:${detail}`,
|
|
666
723
|
tableCell: (row, column) => `第 ${row} 行,${column}`,
|
|
667
724
|
},
|
package/src/record/validation.ts
CHANGED
|
@@ -14,7 +14,11 @@ import type {
|
|
|
14
14
|
AimdRecorderValidationIssue,
|
|
15
15
|
AimdRecorderValidationResult,
|
|
16
16
|
} from "../types"
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
getNumericConstraintViolation,
|
|
19
|
+
getResourceRefTypeConfig,
|
|
20
|
+
isNullableVarType,
|
|
21
|
+
} from "../composables/useVarHelpers"
|
|
18
22
|
|
|
19
23
|
export interface ValidateAimdRecordOptions {
|
|
20
24
|
fieldMeta?: Record<string, AimdFieldMeta>
|
|
@@ -225,6 +229,53 @@ function findArraySchema(
|
|
|
225
229
|
return undefined
|
|
226
230
|
}
|
|
227
231
|
|
|
232
|
+
function schemaAllowsNull(
|
|
233
|
+
root: Record<string, unknown>,
|
|
234
|
+
candidate: unknown,
|
|
235
|
+
visited = new Set<object>(),
|
|
236
|
+
): boolean {
|
|
237
|
+
if (!isRecord(candidate) || visited.has(candidate)) return false
|
|
238
|
+
visited.add(candidate)
|
|
239
|
+
|
|
240
|
+
const schema = resolveLocalSchemaReference(root, candidate)
|
|
241
|
+
if (schema !== candidate && schemaAllowsNull(root, schema, visited)) return true
|
|
242
|
+
if (schema.nullable === true) return true
|
|
243
|
+
if (schema.type === "null") return true
|
|
244
|
+
if (Array.isArray(schema.type) && schema.type.includes("null")) return true
|
|
245
|
+
|
|
246
|
+
for (const branchKey of ["anyOf", "oneOf"] as const) {
|
|
247
|
+
const branches = schema[branchKey]
|
|
248
|
+
if (Array.isArray(branches) && branches.some(branch => schemaAllowsNull(root, branch, visited))) {
|
|
249
|
+
return true
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return false
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function getSchemaNullableFieldKeys(schemaSections: ResolvedSchemaSection[]): Set<string> {
|
|
256
|
+
const keys = new Set<string>()
|
|
257
|
+
for (const { section, schema } of schemaSections) {
|
|
258
|
+
const properties = isRecord(schema.properties) ? schema.properties : {}
|
|
259
|
+
for (const [id, propertySchema] of Object.entries(properties)) {
|
|
260
|
+
if (schemaAllowsNull(schema, propertySchema)) {
|
|
261
|
+
keys.add(`${section}:${id}`)
|
|
262
|
+
if (section === "var") keys.add(`var_table:${id}`)
|
|
263
|
+
}
|
|
264
|
+
if (section !== "var") continue
|
|
265
|
+
|
|
266
|
+
const arraySchema = findArraySchema(schema, propertySchema)
|
|
267
|
+
const itemSchema = isRecord(arraySchema?.items)
|
|
268
|
+
? resolveLocalSchemaReference(schema, arraySchema.items)
|
|
269
|
+
: undefined
|
|
270
|
+
const itemProperties = itemSchema && isRecord(itemSchema.properties) ? itemSchema.properties : {}
|
|
271
|
+
for (const [column, columnSchema] of Object.entries(itemProperties)) {
|
|
272
|
+
if (schemaAllowsNull(schema, columnSchema)) keys.add(`var_table:${id}:${column}`)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return keys
|
|
277
|
+
}
|
|
278
|
+
|
|
228
279
|
function getSchemaRequiredFieldKeys(schemaSections: ResolvedSchemaSection[]): Set<string> {
|
|
229
280
|
const keys = new Set<string>()
|
|
230
281
|
for (const { section, schema } of schemaSections) {
|
|
@@ -264,31 +315,39 @@ export function getAimdRequiredFieldKeys(
|
|
|
264
315
|
const schemaSections = resolveSchemaSections(options.schema)
|
|
265
316
|
const schemaCoveredKeys = getSchemaCoveredFieldKeys(schemaSections)
|
|
266
317
|
const schemaRequiredKeys = getSchemaRequiredFieldKeys(schemaSections)
|
|
318
|
+
const schemaNullableKeys = getSchemaNullableFieldKeys(schemaSections)
|
|
267
319
|
|
|
268
320
|
const addWhenRequired = (
|
|
269
321
|
fieldKey: string,
|
|
270
322
|
kwargs: Record<string, unknown> | undefined,
|
|
271
323
|
inferredRequired: boolean,
|
|
324
|
+
type?: string,
|
|
272
325
|
) => {
|
|
273
326
|
const required = schemaCoveredKeys.has(fieldKey)
|
|
274
|
-
?
|
|
275
|
-
|
|
327
|
+
? fieldMeta[fieldKey]?.required === true
|
|
328
|
+
|| (schemaRequiredKeys.has(fieldKey) && !schemaNullableKeys.has(fieldKey))
|
|
329
|
+
: resolveRequired(fieldMeta[fieldKey], kwargs, inferredRequired && !isNullableVarType(type))
|
|
276
330
|
if (required) keys.add(fieldKey)
|
|
277
331
|
}
|
|
278
332
|
|
|
279
333
|
for (const field of fields.var_definitions ?? []) {
|
|
280
|
-
addWhenRequired(`var:${field.id}`, field.kwargs, !hasOwn(field, "default"))
|
|
334
|
+
addWhenRequired(`var:${field.id}`, field.kwargs, !hasOwn(field, "default"), field.type)
|
|
281
335
|
}
|
|
282
336
|
|
|
283
337
|
for (const table of fields.var_table ?? []) {
|
|
284
338
|
const tableKey = `var_table:${table.id}`
|
|
285
|
-
addWhenRequired(tableKey, table.kwargs, !hasOwn(table, "default"))
|
|
339
|
+
addWhenRequired(tableKey, table.kwargs, !hasOwn(table, "default"), table.type_annotation)
|
|
286
340
|
const schemaCovered = schemaCoveredKeys.has(tableKey)
|
|
287
341
|
for (const column of table.subvars ?? []) {
|
|
288
342
|
const columnKey = `${tableKey}:${column.id}`
|
|
289
343
|
const required = schemaCovered
|
|
290
|
-
?
|
|
291
|
-
|
|
344
|
+
? fieldMeta[columnKey]?.required === true
|
|
345
|
+
|| (schemaRequiredKeys.has(columnKey) && !schemaNullableKeys.has(columnKey))
|
|
346
|
+
: resolveRequired(
|
|
347
|
+
fieldMeta[columnKey],
|
|
348
|
+
column.kwargs,
|
|
349
|
+
!hasOwn(column, "default") && !isNullableVarType(column.type),
|
|
350
|
+
)
|
|
292
351
|
if (required) keys.add(columnKey)
|
|
293
352
|
}
|
|
294
353
|
}
|
|
@@ -587,6 +646,7 @@ function validateValue(
|
|
|
587
646
|
inferredRequired?: boolean
|
|
588
647
|
schemaCovered?: boolean
|
|
589
648
|
schemaRequired?: boolean
|
|
649
|
+
schemaNullable?: boolean
|
|
590
650
|
},
|
|
591
651
|
) {
|
|
592
652
|
const {
|
|
@@ -603,15 +663,19 @@ function validateValue(
|
|
|
603
663
|
inferredRequired = false,
|
|
604
664
|
schemaCovered = false,
|
|
605
665
|
schemaRequired = false,
|
|
666
|
+
schemaNullable = false,
|
|
606
667
|
} = input
|
|
607
668
|
const details = { rowIndex, column }
|
|
608
669
|
const fallbackKwargs = schemaCovered ? undefined : kwargs
|
|
609
670
|
const fallbackEnumValues = schemaCovered ? undefined : enumValues
|
|
671
|
+
const explicitlyRequired = meta?.required === true || (!schemaCovered && kwargs?.required === true)
|
|
672
|
+
const nullable = schemaCovered ? schemaNullable : isNullableVarType(type)
|
|
610
673
|
const required = schemaCovered
|
|
611
674
|
? schemaRequired || meta?.required === true
|
|
612
|
-
: resolveRequired(meta, kwargs, inferredRequired)
|
|
675
|
+
: resolveRequired(meta, kwargs, inferredRequired && !nullable)
|
|
676
|
+
const allowedNullableEmpty = value === null && nullable && !explicitlyRequired
|
|
613
677
|
|
|
614
|
-
if (required && isEmptyValue(value)) {
|
|
678
|
+
if (required && isEmptyValue(value) && !allowedNullableEmpty) {
|
|
615
679
|
addIssue(issues, fieldKey, section, "required", options.messages.required(label), value, details)
|
|
616
680
|
return
|
|
617
681
|
}
|
|
@@ -652,6 +716,60 @@ function validateValue(
|
|
|
652
716
|
}
|
|
653
717
|
}
|
|
654
718
|
|
|
719
|
+
function validateResourceRefValue(
|
|
720
|
+
issues: AimdRecorderValidationIssue[],
|
|
721
|
+
options: ValidateAimdRecordOptions,
|
|
722
|
+
input: {
|
|
723
|
+
fieldKey: string
|
|
724
|
+
label: string
|
|
725
|
+
value: unknown
|
|
726
|
+
type?: string
|
|
727
|
+
kwargs?: Record<string, unknown>
|
|
728
|
+
meta?: AimdFieldMeta
|
|
729
|
+
},
|
|
730
|
+
): void {
|
|
731
|
+
const config = getResourceRefTypeConfig(input.type, input.kwargs, input.meta)
|
|
732
|
+
if (!config || isEmptyValue(input.value)) return
|
|
733
|
+
const values = config.multiple
|
|
734
|
+
? Array.isArray(input.value) ? input.value : [input.value]
|
|
735
|
+
: [input.value]
|
|
736
|
+
for (const value of values) {
|
|
737
|
+
if (!isRecord(value) || typeof value.id !== "string" || !value.id.trim()) {
|
|
738
|
+
addIssue(
|
|
739
|
+
issues,
|
|
740
|
+
input.fieldKey,
|
|
741
|
+
"var",
|
|
742
|
+
"resource",
|
|
743
|
+
options.messages.resource(input.label, options.messages.resourceInvalid),
|
|
744
|
+
input.value,
|
|
745
|
+
)
|
|
746
|
+
return
|
|
747
|
+
}
|
|
748
|
+
if (config.containerRequired && (typeof value.container_id !== "string" || !value.container_id.trim())) {
|
|
749
|
+
addIssue(
|
|
750
|
+
issues,
|
|
751
|
+
input.fieldKey,
|
|
752
|
+
"var",
|
|
753
|
+
"resource",
|
|
754
|
+
options.messages.resource(input.label, options.messages.resourceContainerRequired),
|
|
755
|
+
input.value,
|
|
756
|
+
)
|
|
757
|
+
return
|
|
758
|
+
}
|
|
759
|
+
if (config.bookingRequired && (typeof value.booking_id !== "string" || !value.booking_id.trim())) {
|
|
760
|
+
addIssue(
|
|
761
|
+
issues,
|
|
762
|
+
input.fieldKey,
|
|
763
|
+
"var",
|
|
764
|
+
"resource",
|
|
765
|
+
options.messages.resource(input.label, options.messages.resourceBookingRequired),
|
|
766
|
+
input.value,
|
|
767
|
+
)
|
|
768
|
+
return
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
655
773
|
function matchesFieldSelector(fieldKey: string, selector: string): boolean {
|
|
656
774
|
if (fieldKey === selector) return true
|
|
657
775
|
const selectorParts = selector.split(":")
|
|
@@ -715,6 +833,7 @@ export function validateAimdRecord(
|
|
|
715
833
|
const schemaSections = resolveSchemaSections(options.schema)
|
|
716
834
|
const schemaCoveredKeys = getSchemaCoveredFieldKeys(schemaSections)
|
|
717
835
|
const schemaRequiredKeys = getSchemaRequiredFieldKeys(schemaSections)
|
|
836
|
+
const schemaNullableKeys = getSchemaNullableFieldKeys(schemaSections)
|
|
718
837
|
|
|
719
838
|
validateSchema(issues, fields, record, schemaSections, options.messages)
|
|
720
839
|
|
|
@@ -732,6 +851,15 @@ export function validateAimdRecord(
|
|
|
732
851
|
inferredRequired: !hasOwn(field, "default"),
|
|
733
852
|
schemaCovered: schemaCoveredKeys.has(fieldKey),
|
|
734
853
|
schemaRequired: schemaRequiredKeys.has(fieldKey),
|
|
854
|
+
schemaNullable: schemaNullableKeys.has(fieldKey),
|
|
855
|
+
})
|
|
856
|
+
validateResourceRefValue(issues, options, {
|
|
857
|
+
fieldKey,
|
|
858
|
+
label: field.title || field.id,
|
|
859
|
+
value: record.var[field.id],
|
|
860
|
+
type: field.type,
|
|
861
|
+
kwargs: field.kwargs,
|
|
862
|
+
meta: fieldMeta[fieldKey],
|
|
735
863
|
})
|
|
736
864
|
}
|
|
737
865
|
|
|
@@ -740,8 +868,13 @@ export function validateAimdRecord(
|
|
|
740
868
|
const rows = Array.isArray(record.var[table.id]) ? record.var[table.id] as Record<string, unknown>[] : []
|
|
741
869
|
const schemaCovered = schemaCoveredKeys.has(tableKey)
|
|
742
870
|
const required = schemaCovered
|
|
743
|
-
?
|
|
744
|
-
|
|
871
|
+
? fieldMeta[tableKey]?.required === true
|
|
872
|
+
|| (schemaRequiredKeys.has(tableKey) && !schemaNullableKeys.has(tableKey))
|
|
873
|
+
: resolveRequired(
|
|
874
|
+
fieldMeta[tableKey],
|
|
875
|
+
table.kwargs,
|
|
876
|
+
!hasOwn(table, "default") && !isNullableVarType(table.type_annotation),
|
|
877
|
+
)
|
|
745
878
|
if (required && rows.length === 0) {
|
|
746
879
|
addIssue(issues, tableKey, "var_table", "required", options.messages.required(table.title || table.id), rows)
|
|
747
880
|
continue
|
|
@@ -764,6 +897,7 @@ export function validateAimdRecord(
|
|
|
764
897
|
inferredRequired: !hasOwn(column, "default"),
|
|
765
898
|
schemaCovered,
|
|
766
899
|
schemaRequired: schemaRequiredKeys.has(columnMetaKey),
|
|
900
|
+
schemaNullable: schemaNullableKeys.has(columnMetaKey),
|
|
767
901
|
})
|
|
768
902
|
}
|
|
769
903
|
})
|