-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn about <2024.1 entities spec and update tests #1272
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,14 @@ const getDataset = (xml) => | |
else if (!semverSatisfies(version.get(), '2022.1.0 - 2024.1.x')) | ||
throw Problem.user.invalidEntityForm({ reason: `Entities specification version [${version.get()}] is not supported.` }); | ||
|
||
let warnings; | ||
if (semverSatisfies(version.get(), '<2024.1.x')) | ||
warnings = { | ||
Comment on lines
+85
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name |
||
type: 'oldEntityVersion', | ||
details: { version: version.get() }, | ||
reason: `Entities specification version [${version.get()}] is not compatible with Offline Entities. Please use version 2024.1.0 or later.` | ||
}; | ||
|
||
const strippedAttrs = Object.create(null); | ||
for (const [name, value] of Object.entries(entityAttrs.get())) | ||
strippedAttrs[stripNamespacesFromPath(name)] = value; | ||
|
@@ -101,7 +109,7 @@ const getDataset = (xml) => | |
if (actions.length === 0) | ||
throw Problem.user.invalidEntityForm({ reason: 'The form must specify at least one entity action, for example, create or update.' }); | ||
|
||
return Option.of({ name: datasetName, actions }); | ||
return Option.of({ name: datasetName, actions, warnings }); | ||
}); | ||
|
||
module.exports = { getDataset, validateDatasetName, validatePropertyName }; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -134,6 +134,7 @@ const createNew = (partial, project) => async ({ Actees, Datasets, FormAttachmen | |||||
|
||||||
// Check for xmlFormId collisions with previously deleted forms | ||||||
await Forms.checkDeletedForms(partial.xmlFormId, project.id); | ||||||
await Forms.checkDatasetWarnings(parsedDataset); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the lines above and below this one use |
||||||
await Forms.rejectIfWarnings(); | ||||||
|
||||||
// Provision Actee for form | ||||||
|
@@ -761,6 +762,16 @@ const checkDeletedForms = (xmlFormId, projectId) => ({ maybeOne, context }) => ( | |||||
} | ||||||
})); | ||||||
|
||||||
const checkDatasetWarnings = (dataset) => ({ context }) => { | ||||||
if (context.query.ignoreWarnings) return resolve(); | ||||||
|
||||||
if (dataset.isDefined() && dataset.get().warnings != null) { | ||||||
if (!context.transitoryData.has('workflowWarnings')) context.transitoryData.set('workflowWarnings', []); | ||||||
context.transitoryData.get('workflowWarnings').push(dataset.get().warnings); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you make
Suggested change
|
||||||
} | ||||||
return resolve(); | ||||||
}; | ||||||
|
||||||
const checkStructuralChange = (existingFields, fields) => ({ context }) => { | ||||||
if (context.query.ignoreWarnings) return resolve(); | ||||||
|
||||||
|
@@ -829,7 +840,7 @@ module.exports = { | |||||
getByProjectId, getByProjectAndXmlFormId, getByProjectAndNumericId, | ||||||
getAllByAuth, | ||||||
getFields, getBinaryFields, getStructuralFields, getMergedFields, | ||||||
rejectIfWarnings, checkMeta, checkDeletedForms, checkStructuralChange, checkFieldDowncast, | ||||||
rejectIfWarnings, checkMeta, checkDeletedForms, checkStructuralChange, checkFieldDowncast, checkDatasetWarnings, | ||||||
_newSchema, | ||||||
lockDefs, getAllSubmitters | ||||||
}; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's nice to avoid a
let
where possible. How aboutconst
+ a ternary?