feat: prepare FreeCAD private naming worker linkage
This commit is contained in:
@@ -259,8 +259,8 @@ test('viewport box selection distinguishes enclosed window objects from crossing
|
||||
})
|
||||
|
||||
test('project schema is versioned and covers the FreeCAD document graph', () => {
|
||||
assert.equal(PROJECT_SCHEMA_VERSION, 6)
|
||||
assert.deepEqual(PROJECT_SCHEMA_MIGRATIONS.map((migration) => migration.version), [1, 2, 3, 4, 5, 6])
|
||||
assert.equal(PROJECT_SCHEMA_VERSION, 7)
|
||||
assert.deepEqual(PROJECT_SCHEMA_MIGRATIONS.map((migration) => migration.version), [1, 2, 3, 4, 5, 6, 7])
|
||||
for (const table of ['projects', 'documents', 'objects', 'object_properties', 'dependencies', 'transactions', 'resources', 'document_checkpoints']) assert.match(PROJECT_SCHEMA_SQL, new RegExp(`CREATE TABLE IF NOT EXISTS ${table}`))
|
||||
assert.match(PROJECT_SCHEMA_SQL, /CREATE INDEX IF NOT EXISTS objects_document_ordinal/)
|
||||
})
|
||||
@@ -719,7 +719,7 @@ test('versioned FreeCAD private naming ABI is capability-gated and attaches vali
|
||||
freecadNamingCapabilitiesJson: () => JSON.stringify({ schemaVersion: 1, freecadVersion: '1.1.1', sourceCommit: '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d', mappedNameRef: true, stringHasher: true, elementMap2: true, operations: ['cut'] }),
|
||||
freecadNamingEvidenceJson: (requestJson: string) => {
|
||||
capturedRequest = JSON.parse(requestJson) as Record<string, unknown>
|
||||
return JSON.stringify({ schemaVersion: 1, stageId: 'cut-native:stage:0', resultObjectId: 'cut-native', status: 'native-evidence', mappedNames: [{ kind: 'edge', resultIndex: 0, resultPersistentId: 'edge-native-0', relation: 'modified', reference: { name: 'Edge1', stringIds: [0x36] }, sourceRefs: [{ objectId: 'object', persistentId: 'Edge1' }] }], stringHasher, elementMap2 })
|
||||
return JSON.stringify({ schemaVersion: 1, stageId: capturedRequest.stageId, resultObjectId: capturedRequest.resultObjectId, status: 'native-evidence', mappedNames: [{ kind: 'edge', resultIndex: 0, resultPersistentId: 'edge-native-0', relation: 'modified', reference: { name: 'Edge1', stringIds: [0x36] }, sourceRefs: [{ objectId: 'object', persistentId: 'Edge1' }] }], stringHasher, elementMap2 })
|
||||
},
|
||||
}
|
||||
assert.deepEqual(probeFreeCadPrivateNamingAbi(module).availability, 'available')
|
||||
@@ -731,6 +731,16 @@ test('versioned FreeCAD private naming ABI is capability-gated and attaches vali
|
||||
assert.equal(capturedRequest?.operation, 'cut')
|
||||
assert.equal((capturedRequest?.history as { records: unknown[] }).records.length, 1)
|
||||
|
||||
const inputEvidence = createFinalShapeOnlyNamingEvidence('source:stage:0', 'source')
|
||||
await provider.capture({ protocolVersion: 1, requestId: 'naming-tags', documentId: 'doc', documentVersion: 2, operationId: 'cut-native', resultObjectId: 'cut-result', operation: 'cut', objectStep: 'ISO-10303-21; object', toolStep: 'ISO-10303-21; tool', resultObjectTag: 23, inputs: [{ inputId: 'object', objectId: 'base', role: 'object', step: 'ISO-10303-21; object', objectTag: 17, namingEvidence: inputEvidence }, { inputId: 'tool', objectId: 'tool', role: 'tool', step: 'ISO-10303-21; tool', objectTag: 19 }] }, new AbortController().signal)
|
||||
assert.equal(capturedRequest?.resultObjectId, 'cut-result')
|
||||
assert.equal(capturedRequest?.resultObjectTag, 23)
|
||||
assert.equal((capturedRequest?.inputs as Array<{ objectTag?: number; namingEvidence?: { stageId: string } }>)[0].objectTag, 17)
|
||||
assert.equal((capturedRequest?.inputs as Array<{ objectId?: string }>)[0].objectId, 'base')
|
||||
assert.equal((capturedRequest?.inputs as Array<{ namingEvidence?: { stageId: string } }>)[0].namingEvidence?.stageId, 'source:stage:0')
|
||||
assert.notEqual((capturedRequest?.inputs as Array<{ namingEvidence?: unknown }>)[0].namingEvidence, inputEvidence)
|
||||
await assert.rejects(() => provider.capture({ protocolVersion: 1, requestId: 'naming-invalid-tag', documentId: 'doc', documentVersion: 2, operationId: 'cut-native', operation: 'cut', objectStep: 'ISO-10303-21; object', toolStep: 'ISO-10303-21; tool', resultObjectTag: 0 }, new AbortController().signal), /positive safe integer/)
|
||||
|
||||
const invalid = { ...module, freecadNamingCapabilitiesJson: () => JSON.stringify({ schemaVersion: 1, freecadVersion: '1.1.1', sourceCommit: 'wrong', mappedNameRef: true, stringHasher: true, elementMap2: true, operations: ['cut'] }) }
|
||||
assert.equal(probeFreeCadPrivateNamingAbi(invalid).availability, 'unavailable')
|
||||
})
|
||||
@@ -4367,6 +4377,9 @@ test('FCStd metadata writer rejects ambiguous object identity', () => {
|
||||
const document = createMockFacade().app.document.getActive()
|
||||
assert.throws(() => serializeFcstdMetadataArchive({ ...document, objects: [...document.objects, { ...document.objects[0] }] }), /unique object ids/)
|
||||
assert.throws(() => serializeFcstdMetadataArchive({ ...document, objects: [{ ...document.objects[0], id: ' ' }] }), /non-empty object ids/)
|
||||
assert.throws(() => serializeFcstdMetadataArchive({ ...document, objects: document.objects.slice(0, 2).map((object) => ({ ...object, nativeObjectTag: 9 })) }), /assigned to more than one object/)
|
||||
const duplicateNativeTag = zipSync({ 'Document.xml': strToU8('<Document><Objects><Object name="A" type="Part::Feature" id="4"/><Object name="B" type="Part::Feature" id="4"/></Objects></Document>') })
|
||||
assert.throws(() => inspectFcstdArchive(duplicateNativeTag), /native id 4 is duplicated/)
|
||||
})
|
||||
|
||||
test('FCStd inspection inventories object extensions without instantiating them', () => {
|
||||
@@ -4379,7 +4392,7 @@ test('FCStd metadata writer round-trips Document and GuiDocument while preservin
|
||||
const document = {
|
||||
id: 'fcstd-writer-doc', label: 'Writer fixture', version: 1, dirty: false, readOnly: false, units: 'mm',
|
||||
tree: [{ id: 'body', label: 'Body', type: 'body' as const, state: 'active' as const }],
|
||||
objects: [{ id: 'body', typeId: 'PartDesign::Body', properties: [
|
||||
objects: [{ id: 'body', typeId: 'PartDesign::Body', nativeObjectTag: 37, properties: [
|
||||
{ name: 'Label', label: 'Label', type: 'App::PropertyString', value: 'Body', expression: 'Spreadsheet.Width * 2', recompute: false },
|
||||
{ name: 'Length', label: 'Length', type: 'App::PropertyLength', value: 12.5 },
|
||||
{ name: 'Visible', label: 'Visible', type: 'App::PropertyBool', value: true },
|
||||
@@ -4391,6 +4404,8 @@ test('FCStd metadata writer round-trips Document and GuiDocument while preservin
|
||||
const inspection = inspectFcstdArchive(archive)
|
||||
assert.equal(inspection.label, 'Writer fixture')
|
||||
assert.equal(inspection.objects[0].typeId, 'PartDesign::Body')
|
||||
assert.equal(inspection.objects[0].nativeObjectTag, 37)
|
||||
assert.equal(inspection.proxyDocument.objects[0].nativeObjectTag, 37)
|
||||
assert.equal(inspection.objects[0].properties[0].value, 'Body')
|
||||
assert.equal(inspection.objects[0].properties[0].expression, 'Spreadsheet.Width * 2')
|
||||
assert.equal(inspection.objects[0].properties.find((property) => property.name === 'Length')?.element, 'Float')
|
||||
|
||||
Reference in New Issue
Block a user