I have been trying to add an ID-field (called "itemId") to replace the database generated "_id" as the "_id" for Articles, Blocks and Components in the framework json-files.
The main reason for this is, that when you have made translation CSV-files for a course, it is a pain that the IDs change, every time you copy or import a course.
But it also makes it possible to use IDs from a course manuscript, which makes it easier to connect items in the course code to the manuscript.
In "plugins/content/[article|block|component]/model.schema" I have inserted this in the "properties" section:
And also in the "plugins/content/component/componentType.schema" file.
In "ContentPlugin.prototype.create" I insert a default ID, that could be changed by the user in the AT.
I have also added the field to "BlockModel.whitelistAttributes" and "ComponentModel.whitelistAttributes" to allow it to be saved.
The "OutputPlugin.prototype.writeCourseJSON" is of course also modified, to use the "itemId" instead of the database "_id" field for JSON "_id" field.
This works quite a long way, but when I try to install a new AT server, using the modified code (from a fork of the AT repo), the standard components will not install (extensions installs ok).
I get this error, when I try to upload a component in the AT (it is the same error during AT install - but without the stack trace):
ValidationError: itemId: Path `itemId` is required.
ValidationError: componenttype validation failed: itemId: Path `itemId` is required.
at new ValidationError (/root/adapt_authoring/node_modules/mongoose/lib/error/validation.js:30:11)
at model.Document.invalidate (/root/adapt_authoring/node_modules/mongoose/lib/document.js:2080:32)
at p.doValidate.skipSchemaValidators (/root/adapt_authoring/node_modules/mongoose/lib/document.js:1943:17)
at process._tickCallback (internal/process/next_tick.js:61:11)
I can see that it is connected to my "itemId" field - but how?