@ja-platform/parser-schema 0.0.0-dev-20261019214152 → 0.0.0-dev-20261021195551

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 (63) hide show
  1. package/dist/@types/day/Day.d.ts +48 -4
  2. package/dist/@types/expressions/parseParameterValueProvider.d.ts +5 -0
  3. package/dist/@types/index.d.ts +6 -6
  4. package/dist/@types/schema/Schema.d.ts +6 -22
  5. package/dist/@types/schema/TypeFactory.d.ts +3 -4
  6. package/dist/@types/schema/fieldMetadata.d.ts +5 -0
  7. package/dist/@types/types/EnumOption.d.ts +0 -2
  8. package/dist/@types/types/Field.d.ts +24 -0
  9. package/dist/@types/types/Param.d.ts +4 -4
  10. package/dist/@types/types/SchemaModelType.d.ts +9 -25
  11. package/dist/@types/types/primitives/Date.d.ts +2 -1
  12. package/dist/day/Day.js +89 -97
  13. package/dist/day/Day.js.map +1 -1
  14. package/dist/expressions/parseParameterValueProvider.js +13 -0
  15. package/dist/expressions/parseParameterValueProvider.js.map +1 -0
  16. package/dist/index.js +6 -6
  17. package/dist/index.js.map +1 -1
  18. package/dist/schema/Schema.js +7 -69
  19. package/dist/schema/Schema.js.map +1 -1
  20. package/dist/schema/TypeFactory.js.map +1 -1
  21. package/dist/schema/fieldMetadata.js +35 -0
  22. package/dist/schema/fieldMetadata.js.map +1 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/types/EnumOption.js.map +1 -1
  25. package/dist/types/Field.js +28 -0
  26. package/dist/types/Field.js.map +1 -0
  27. package/dist/types/Param.js +2 -12
  28. package/dist/types/Param.js.map +1 -1
  29. package/dist/types/SchemaModelType.js +4 -28
  30. package/dist/types/SchemaModelType.js.map +1 -1
  31. package/dist/types/primitives/Date.js +8 -7
  32. package/dist/types/primitives/Date.js.map +1 -1
  33. package/package.json +5 -8
  34. package/dist/@types/Version.d.ts +0 -19
  35. package/dist/@types/day/DayConstructorInterface.d.ts +0 -50
  36. package/dist/@types/day/DayInterface.d.ts +0 -34
  37. package/dist/@types/day/index.d.ts +0 -2
  38. package/dist/@types/schema/SchemaParserErrors.d.ts +0 -10
  39. package/dist/@types/schema/reservedNames.d.ts +0 -7
  40. package/dist/@types/schema/schemaParser.d.ts +0 -43
  41. package/dist/@types/schema/schemaSerializer.d.ts +0 -11
  42. package/dist/@types/types/FunctionType.d.ts +0 -15
  43. package/dist/@types/types/Variable.d.ts +0 -32
  44. package/dist/Version.js +0 -76
  45. package/dist/Version.js.map +0 -1
  46. package/dist/day/DayConstructorInterface.js +0 -3
  47. package/dist/day/DayConstructorInterface.js.map +0 -1
  48. package/dist/day/DayInterface.js +0 -3
  49. package/dist/day/DayInterface.js.map +0 -1
  50. package/dist/day/index.js +0 -19
  51. package/dist/day/index.js.map +0 -1
  52. package/dist/schema/SchemaParserErrors.js +0 -26
  53. package/dist/schema/SchemaParserErrors.js.map +0 -1
  54. package/dist/schema/reservedNames.js +0 -101
  55. package/dist/schema/reservedNames.js.map +0 -1
  56. package/dist/schema/schemaParser.js +0 -1135
  57. package/dist/schema/schemaParser.js.map +0 -1
  58. package/dist/schema/schemaSerializer.js +0 -181
  59. package/dist/schema/schemaSerializer.js.map +0 -1
  60. package/dist/types/FunctionType.js +0 -30
  61. package/dist/types/FunctionType.js.map +0 -1
  62. package/dist/types/Variable.js +0 -49
  63. package/dist/types/Variable.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemaParser.js","sourceRoot":"","sources":["../../src/schema/schemaParser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gGAA6F;AAC7F,wEAA4D;AAC5D,kDAA+C;AAC/C,kBAAkB;AAClB,0CAA0C;AAC1C,wEAAsF;AACtF,MAAY,GAAG,oDAAgC;AAC/C,wDAAqD;AAIrD,wEAAmE;AACnE,oDAAoG;AAEpG,6DAA0D;AAE1D,mDAAuE;AACvE,6CAAwF;AAExF;;GAEG;AACH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,CAAC,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEpC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAU,OAAO;gBACzD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;oBAC9B,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,MAAM;oBACN,WAAW,EAAE,OAAO,CAAC,WAAW;iBACjC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { SchemaObjectDisplayExpression } from '../expressions/SchemaObjectDisplayExpression';\nimport { ArrayType } from '@ja-platform/parser-type-system';\nimport { QueryType } from '../types/QueryType';\n// # schema module\n// Parser for v2 and v3 of the schema XML.\nimport { FunctionExpression, FUNCTION_PREFIX } from '@ja-platform/parser-expressions';\nimport * as xml from '@journeyapps/common-xml';\nimport { FunctionType } from '../types/FunctionType';\nimport { Param } from '../types/Param';\nimport { Schema } from './Schema';\nimport { SchemaModelType } from '../types/SchemaModelType';\nimport { Type, ObjectType } from '@ja-platform/parser-type-system';\nimport { ChoiceType, PrimitiveType, TextType, DateType, AttachmentType } from '../types/primitives';\nimport { Variable } from '../types/Variable';\nimport { SchemaParserErrors } from './SchemaParserErrors';\nimport { XMLDocument, XMLElement } from '@journeyapps/domparser/types';\nimport { validateFieldName, validateModelName } from './reservedNames';\nimport { IndexDatabase, IndexDirection, ModelIndex, ModelIndexKey } from './ModelIndex';\n\n/**\n * Normalize serialized parameter providers once at the schema boundary.\n */\nexport function parseParameterValueProvider(source: string): FunctionExpression {\n const code = source.trim().replace(/^\\$:/, '');\n const call = /^[\\w$]+(?:\\.[\\w$]+)*$/.test(code) ? `${code}()` : code;\n return FunctionExpression.parse(`${FUNCTION_PREFIX}${call}`);\n}\n\nfunction parseElement(element: XMLElement, definitions: any, errorHandler: SchemaParserErrors) {\n const result = xml.parseElement(element, definitions);\n if (result.errors.length > 0) {\n errorHandler.pushErrors(result.errors);\n }\n return result;\n}\n\nconst specs = xml.attribute.optionList(\n [\n 'text',\n 'text.email',\n 'text.address',\n 'text.name',\n 'text.url',\n 'text.paragraph',\n 'number',\n 'number.za_id',\n 'phone',\n 'phone.za_cell',\n 'decimal',\n 'password'\n ],\n 'Invalid spec'\n);\n\nexport const ATTACHMENT_MEDIA_TYPES = [\n 'image/png',\n 'image/jpeg',\n 'image/svg+xml',\n 'application/pdf',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.ms-excel',\n 'application/msword',\n 'application/vnd.anritsu',\n 'application/vnd.valvelink',\n 'application/xml',\n 'text/plain',\n 'text/csv',\n 'any'\n];\n\nconst v2AttributeDef = {\n name: xml.attribute.name,\n type: xml.attribute.notBlank,\n spec: specs,\n media: xml.attribute.optionList(\n ATTACHMENT_MEDIA_TYPES,\n \"media must be 'any', or one of the specific allowed mime types.\"\n ),\n minValue: xml.attribute.notBlank,\n maxValue: xml.attribute.notBlank,\n label: xml.attribute.label,\n _required: ['name', 'type', 'label']\n};\n\nconst deprecationWarning = {\n warning: 'Attribute is deprecated. Please remove or replace it.'\n};\n\nconst v3AttributeDef = {\n name: xml.attribute.name,\n type: xml.attribute.notBlank,\n media: xml.attribute.optionList(\n ATTACHMENT_MEDIA_TYPES,\n \"media must be 'any', or one of the specific allowed mime types.\"\n ),\n 'auto-download': xml.attribute.optionList('true', 'false'),\n label: xml.attribute.label,\n _required: ['name', 'type', 'label'],\n 'deprecated-spec': deprecationWarning,\n minValue: deprecationWarning,\n maxValue: deprecationWarning,\n spec: { warning: \"'spec' is deprecated. Please remove or replace it.\" }\n};\n\nconst v2VariableDef = {\n name: xml.attribute.name,\n type: xml.attribute.notBlank,\n spec: specs,\n media: xml.attribute.optionList(\n ATTACHMENT_MEDIA_TYPES,\n \"media must be 'any', or one of the specific allowed mime types.\"\n ),\n minValue: xml.attribute.notBlank,\n maxValue: xml.attribute.notBlank,\n array: xml.attribute.optionList(['true', 'false']),\n _required: ['name', 'type']\n};\n\nconst v3VariableDef = {\n name: xml.attribute.name,\n type: xml.attribute.notBlank,\n media: xml.attribute.optionList(\n ATTACHMENT_MEDIA_TYPES,\n \"media must be 'any', or one of the specific allowed mime types.\"\n ),\n minValue: deprecationWarning,\n maxValue: deprecationWarning,\n _required: ['name', 'type']\n};\n\nconst v5ParamArgDef = {\n name: xml.attribute.name,\n type: xml.attribute.notBlank\n};\n\nconst v3ParameterDef = {\n name: xml.attribute.name,\n type: xml.attribute.notBlank,\n media: xml.attribute.optionList(\n ATTACHMENT_MEDIA_TYPES,\n \"media must be 'any', or one of the specific allowed mime types.\"\n ),\n required: xml.attribute.optionList(['true', 'false']),\n 'transform-value': xml.attribute.optionListWithFunctions([], FUNCTION_PREFIX),\n _required: ['name', 'type']\n};\n\nconst v2PrimitiveMapping: { [index: string]: string } = {\n enum_set: PrimitiveType.MULTIPLE_CHOICE_INTEGER,\n enum: PrimitiveType.SINGLE_CHOICE_INTEGER,\n int: PrimitiveType.INTEGER,\n string: PrimitiveType.TEXT,\n attachment: PrimitiveType.ATTACHMENT,\n location: PrimitiveType.LOCATION,\n decimal: PrimitiveType.NUMBER,\n date: PrimitiveType.DATE,\n datetime: PrimitiveType.DATETIME\n};\n\nconst v3SpecMapping: { [index: string]: string } = {\n email: 'text.email',\n address: 'text.address',\n name: 'text.name',\n url: 'text.url',\n paragraph: 'text.paragraph',\n 'signed-number': 'number',\n number: 'number', // TODO: fix\n 'south-african-id': 'number.za_id',\n 'phone-number': 'phone',\n 'decimal-number': 'decimal',\n password: 'password'\n};\n\nexport const TEXT_SUBTYPES = Object.keys(v3SpecMapping);\n\nconst getAttribute = xml.getAttribute;\n\nexport interface ParseVersion {\n v3?: boolean;\n v3_1?: boolean;\n}\n\nexport interface SchemaParser {\n parse: (rawxml: string) => void;\n parseField: (element: XMLElement, isVariable?: boolean) => Variable;\n validateVariableAttributes: (element: XMLElement, options?: { validateType?: boolean }) => void;\n parseObjectType: (element: XMLElement) => SchemaModelType;\n parseBelongsTo: (object: SchemaModelType, element: XMLElement) => void;\n parseDisplay: (object: SchemaModelType, element: XMLElement) => SchemaModelType;\n reset: () => void;\n getErrors: () => any[];\n}\n\nexport function parser(schema: Schema, options?: { version?: ParseVersion; recordSource?: boolean }): SchemaParser {\n const errorHandler = new SchemaParserErrors();\n options = options || {};\n\n let tag: {\n root: string;\n model: string;\n relatedModel: string;\n inverseOf: string;\n belongsTo: string;\n hasMany: string;\n field: string;\n optionKey: string;\n };\n\n let description: {\n field: string;\n };\n const version: ParseVersion = options.version || { v3: false, v3_1: false };\n\n const v3 = version.v3 === true;\n const v3p1 = version.v3_1 === true;\n const variableDef = v3 ? v3VariableDef : v2VariableDef;\n const parameterDef = v3ParameterDef;\n const attributeDef = v3 ? v3AttributeDef : v2AttributeDef;\n\n let optionDef: {\n option: any;\n };\n\n if (!v3) {\n tag = {\n root: 'schema',\n model: 'object',\n relatedModel: 'type',\n inverseOf: 'inverse_of',\n belongsTo: 'belongs_to',\n hasMany: 'has_many',\n field: 'attribute',\n optionKey: 'value'\n };\n description = {\n field: 'Attribute'\n };\n optionDef = { option: {} };\n } else {\n tag = {\n root: 'data-model',\n model: 'model',\n relatedModel: 'model',\n inverseOf: 'inverse-of',\n belongsTo: 'belongs-to',\n hasMany: 'has-many',\n field: 'field',\n optionKey: 'key'\n };\n description = {\n field: 'Field'\n };\n optionDef = { option: { key: xml.attribute.notBlank } };\n if (!v3p1) {\n tag.model = 'object';\n tag.relatedModel = 'type';\n optionDef = { option: { value: xml.attribute.notBlank } };\n }\n }\n\n function recordSource(on: { sourceElement: XMLElement | null } | null, source: XMLElement) {\n if (options.recordSource && on != null) {\n on.sourceElement = source;\n }\n }\n\n function parse(rawxml: string): XMLDocument {\n const xmlDoc = xml.parse(rawxml);\n schema.errors = xmlDoc.errors || [];\n errorHandler.pushErrors(schema.errors);\n if (schema.errors.length > 0) {\n // Stop parsing right here, and keep the previous version we parsed (if any).\n return;\n }\n\n const root = xmlDoc.documentElement;\n recordSource(schema, root);\n\n if (root == null) {\n errorHandler.pushError({ element: null, message: 'Not a valid XML document' });\n return; // fatal error\n }\n\n if (root.tagName != tag.root) {\n errorHandler.pushError({ element: root, message: `<${tag.root}> root tag expected` });\n return; // fatal error\n }\n\n // Validate that the only children are <object>\n let rootChildren = {\n [tag.model]: 1\n };\n errorHandler.pushErrors(xml.validateChildren(root, rootChildren));\n\n const objects = xml.children(root, tag.model);\n if (objects.length === 0) {\n errorHandler.pushError({ element: root, message: 'At least one model is required' });\n }\n\n schema.objects = {};\n\n // First pass - load the objects with attributes and display names\n objects.forEach(function (element) {\n const object = parseObjectType(element);\n if (object.name != null) {\n if (object.name in schema.objects) {\n const errorElement = xml.attributeNode(element, 'name') || element;\n errorHandler.pushError({ element: errorElement, message: \"Model '\" + object.name + \"' is already defined\" });\n errorHandler.pushErrors(object.errors);\n } else {\n schema.objects[object.name] = object;\n }\n } else {\n errorHandler.pushErrors(object.errors);\n }\n });\n\n // Second pass - load the belongs_to relationships\n objects.forEach(function (element) {\n const name = getAttribute(element, 'name');\n const object = schema.objects[name];\n if (object) {\n parseBelongsTo(object, element);\n }\n });\n\n // Third pass - load the has_many relationships and indexes\n objects.forEach(function (element) {\n const name = getAttribute(element, 'name');\n const object = schema.objects[name];\n if (object) {\n parseHasMany(object, element);\n parseIndexes(object, element);\n }\n });\n\n // Fourth pass - display and webhooks\n objects.forEach(function (element) {\n const name = getAttribute(element, 'name');\n const object = schema.objects[name];\n if (object) {\n parseDisplay(object, element);\n parseWebhooks(object, element);\n parseNotifications(object, element);\n }\n });\n }\n\n function parseObjectType(element: XMLElement) {\n const object = schema.newObjectType();\n recordSource(object, element);\n\n const modelDef = {\n [tag.model]: {\n name: xml.attribute.name,\n label: xml.attribute.label,\n classification: xml.attribute.optionList(['standard', 'sensitive']),\n _required: ['name', 'label']\n }\n };\n\n parseElement(element, modelDef, errorHandler);\n\n object.name = getAttribute(element, 'name');\n object.label = getAttribute(element, 'label');\n const validation = validateModelName(object.name);\n // Special case here: if name === null, we don't want to tell the user it's\n // a reserved name, since it's not specified at all.\n if (validation && object.name !== null) {\n errorHandler.pushError({\n element: xml.attributeNode(element, 'name'),\n message:\n validation == 'error'\n ? `Reserved model name '${object.name}'`\n : `'${object.name}' is reserved in some contexts and may cause issues.`,\n type: validation\n });\n }\n\n // the ordering of the elements (elements can share a number and be interchangeable)\n const allowedChildren = {\n [tag.field]: 1,\n [tag.belongsTo]: 2,\n [tag.hasMany]: 2,\n index: 3,\n display: 3,\n 'notify-user': 3,\n webhook: 3\n };\n\n const orderMessage =\n 'Elements must be in this order: ' + tag.field + 's, relationships, display, notify-user, indices, webhooks';\n\n const errors = xml.validateChildren(element, allowedChildren, orderMessage);\n errorHandler.pushErrors(errors);\n\n // Processes model attributes\n const attributes = xml.children(element, tag.field);\n attributes.forEach(function (attributeElement) {\n const variable = parseField(attributeElement, false);\n if (object.attributes.hasOwnProperty(variable.name)) {\n const errorElement = xml.attributeNode(attributeElement, 'name') || attributeElement;\n errorHandler.pushError({\n element: errorElement,\n message: description.field + \" '\" + variable.name + \"' is already defined\"\n });\n } else {\n object.addAttribute(variable);\n }\n });\n\n return object;\n }\n\n function parseDisplay(object: SchemaModelType, element: XMLElement) {\n const displayElements = xml.children(element, 'display');\n if (displayElements.length == 1) {\n const displayElement = displayElements[0];\n parseElement(\n displayElement,\n {\n display: {\n format: xml.attribute.label\n }\n },\n errorHandler\n );\n let attribute = true;\n let fmtString = getAttribute(displayElement, 'format');\n if (fmtString == null) {\n fmtString = displayElement.textContent;\n attribute = false;\n }\n object.displayFormat = SchemaObjectDisplayExpression.parse(fmtString);\n if (options.recordSource) {\n object.displaySource = displayElement;\n }\n const displayErrors = object.displayFormat.validate({\n getReference(path) {\n let type: Type = object;\n for (const field of path) {\n type = ObjectType.isInstanceOf(type) ? type.getField(String(field)) : null;\n }\n return type;\n }\n });\n displayErrors.forEach(function (error) {\n if (attribute) {\n errorHandler.pushError({\n element: xml.attributeValuePosition(displayElement, 'format', error.token.start, error.token.end),\n message: error.message\n });\n } else {\n errorHandler.pushError({\n element: xml.elementTextPosition(displayElement, error.token.start, error.token.end),\n message: error.message\n });\n }\n });\n } else if (displayElements.length === 0) {\n errorHandler.pushError({ element, message: '<display> is required' });\n object.displayFormat = SchemaObjectDisplayExpression.parse('');\n } else {\n errorHandler.pushError({\n element: displayElements[1],\n message: 'Only one <display> element is allowed',\n type: 'warning'\n });\n }\n\n return object;\n }\n\n function parseBelongsTo(object: SchemaModelType, element: XMLElement) {\n const syntax = {\n [tag.belongsTo]: {\n name: xml.attribute.name,\n [tag.relatedModel]: xml.attribute.notBlank,\n _required: [tag.relatedModel]\n }\n };\n\n xml.children(element, tag.belongsTo).forEach(function (e) {\n parseElement(e, syntax, errorHandler);\n\n try {\n const typeName = getAttribute(e, tag.relatedModel);\n let name = getAttribute(e, 'name');\n if (name == null || name === '') {\n name = typeName;\n }\n object.addBelongsTo({ name, type: typeName, schema });\n recordSource(object.belongsToVars[name], e);\n } catch (err) {\n const node = xml.attributeNode(e, err.attribute) || e;\n errorHandler.pushError({ element: node, message: err.message });\n }\n });\n }\n\n function parseHasMany(object: SchemaModelType, element: XMLElement) {\n const syntax = {\n [tag.hasMany]: {\n name: xml.attribute.name,\n [tag.inverseOf]: xml.attribute.notBlank,\n [tag.relatedModel]: xml.attribute.notBlank,\n _required: ['name', tag.relatedModel]\n }\n };\n\n xml.children(element, tag.hasMany).forEach(function (e) {\n parseElement(e, syntax, errorHandler);\n\n const typeName = getAttribute(e, tag.relatedModel);\n const name = getAttribute(e, 'name');\n\n const inverseOf = getAttribute(e, tag.inverseOf);\n\n if (typeName != null) {\n const objectType = schema.objects[typeName];\n if (objectType == null) {\n errorHandler.pushError({\n element: xml.attributeNode(e, tag.relatedModel) || e,\n message: \"Object '\" + typeName + \"' is not defined\"\n });\n } else {\n let rel = null;\n if (inverseOf != null) {\n rel = objectType.belongsTo[inverseOf];\n if (rel == null) {\n errorHandler.pushError({\n element: xml.attributeNode(e, tag.inverseOf),\n message: \"'\" + inverseOf + \"' is not defined on '\" + objectType.name + \"'\"\n });\n }\n } else {\n const candidates = [];\n for (let key in objectType.belongsTo) {\n if (objectType.belongsTo.hasOwnProperty(key)) {\n const r = objectType.belongsTo[key];\n if (r.foreignType === object) {\n candidates.push(r);\n }\n }\n }\n if (candidates.length == 1) {\n rel = candidates[0];\n } else if (candidates.length === 0) {\n errorHandler.pushError({\n element: e,\n message:\n 'Need <' +\n tag.belongsTo +\n ' ' +\n tag.relatedModel +\n '=\"' +\n object.name +\n '\"> in object \\'' +\n objectType.name +\n \"'\"\n });\n } else {\n const names = [];\n for (let i = 0; i < candidates.length; i++) {\n names.push(candidates[i].name);\n }\n errorHandler.pushError({\n element: e,\n message: 'Ambiguous ' + e.tagName + ' - set ' + tag.inverseOf + ' to one of ' + names.join(', ')\n });\n }\n }\n\n if (rel != null) {\n if (object.hasMany.hasOwnProperty(name)) {\n errorHandler.pushError({\n element: xml.attributeNode(e, 'name') || e,\n message: \"Relationship '\" + name + \"' is already defined\"\n });\n } else if (rel.foreignName != null) {\n errorHandler.pushError({\n element: e,\n message: \"Relationship '\" + rel.name + \"' already has a \" + e.tagName + \" '\" + rel.foreignName + \"'\"\n });\n } else {\n rel.foreignName = name;\n\n object.hasMany[name] = rel;\n object.hasManyVars[name] = schema.variable(name, new QueryType(objectType));\n recordSource(object.hasManyVars[name], e);\n }\n }\n }\n }\n });\n }\n\n function parseWebhooks(object: SchemaModelType, element: XMLElement) {\n const syntax = {\n webhook: {\n name: xml.attribute.name,\n type: xml.attribute.notBlank,\n receiver: xml.attribute.any, // pdfmailer|cloudcode|<none>\n action: xml.attribute.any, // template |task |<n/a>\n // Fixme: this looks wrong.\n field: {\n name: xml.attribute.name,\n required: xml.attribute.notBlank,\n embed: xml.attribute.notBlank,\n state: xml.attribute.notBlank,\n _required: ['name']\n },\n _required: ['type']\n }\n };\n\n xml.children(element, 'webhook').forEach(function (webhookElement) {\n parseElement(webhookElement, syntax, errorHandler);\n\n let webhook = {\n name: getAttribute(webhookElement, 'name'),\n type: getAttribute(webhookElement, 'type'),\n receiver: getAttribute(webhookElement, 'receiver'),\n action: getAttribute(webhookElement, 'action'),\n fields: [] as any[],\n sourceElement: null as XMLElement\n };\n recordSource(webhook, webhookElement);\n\n if (webhook.type != 'ready' && webhook.type != 'update') {\n errorHandler.pushError({\n element: xml.attributeNode(webhookElement, 'type') || webhookElement,\n message: 'webhook type must be \"ready\" or \"update\"'\n });\n }\n\n if (webhook.receiver == null) {\n if (webhook.name == null) {\n webhook.name = object.name + '_' + webhook.type;\n }\n\n if (webhook.action != null) {\n errorHandler.pushError({\n element: xml.attributeNode(webhookElement, 'action') || webhookElement,\n message: 'webhook action is not allowed unless receiver is specified'\n });\n }\n } else {\n if (webhook.receiver != 'pdfmailer' && webhook.receiver != 'cloudcode') {\n errorHandler.pushError({\n element: xml.attributeNode(webhookElement, 'receiver') || webhookElement,\n message: 'webhook receiver must be \"cloudcode\" or \"pdfmailer\" when specified'\n });\n }\n\n if (webhook.action == null || webhook.action == '') {\n errorHandler.pushError({\n element: webhookElement,\n message: 'webhook action required when receiver is specified'\n });\n }\n\n if (webhook.name == null) {\n // pdfmailer: pdfmailer_notification_ready_delivery_note\n\n webhook.name = webhook.receiver + '_' + object.name + '_' + webhook.type + '_' + webhook.action;\n }\n }\n\n const booleanMapping: { [index: string]: boolean | undefined } = {\n true: true,\n false: false,\n null: true,\n '': true\n };\n\n // iterate through all fields in webhook\n xml.children(webhookElement, 'field').forEach(function (fieldElement) {\n const fieldName = getAttribute(fieldElement, 'name');\n // TODO: validate 'name'\n\n const fieldRequiredText = getAttribute(fieldElement, 'required');\n // 'required' defaults to true if not provided\n const fieldRequired = booleanMapping[fieldRequiredText];\n if (fieldRequired == null) {\n errorHandler.pushError({\n element: xml.attributeNode(fieldElement, 'required') || fieldElement,\n message: 'required must be \"true\" or \"false\"'\n });\n }\n\n const fieldEmbedText = getAttribute(fieldElement, 'embed');\n // 'embed' defaults to true if not provided\n const fieldEmbed = booleanMapping[fieldEmbedText];\n if (fieldEmbed == null) {\n errorHandler.pushError({\n element: xml.attributeNode(fieldElement, 'embed') || fieldElement,\n message: 'embed must be \"true\" or \"false\"'\n });\n }\n\n let fieldState = getAttribute(fieldElement, 'state');\n // 'state' defaults to 'present' if not provided\n if (fieldState == null) {\n fieldState = 'present';\n }\n if (fieldState != 'present' && fieldState != 'uploaded') {\n errorHandler.pushError({\n element: xml.attributeNode(fieldElement, 'state') || fieldElement,\n message: 'state must be \"present\" or \"uploaded\"'\n });\n }\n\n const field = {\n name: fieldName,\n required: fieldRequired,\n embed: fieldEmbed,\n state: fieldState\n };\n webhook.fields.push(field);\n });\n\n object.webhooks.push(webhook);\n });\n }\n\n function parseNotifications(object: SchemaModelType, element: XMLElement) {\n const syntax = {\n 'notify-user': {\n message: xml.attribute.notBlank,\n 'received-field': xml.attribute.notBlank,\n 'recipient-field': xml.attribute.notBlank,\n 'badge-count-field': xml.attribute.notBlank\n },\n _required: ['message', 'received-field', 'recipient-field']\n };\n\n xml.children(element, 'notify-user').forEach(function (notificationElement) {\n parseElement(notificationElement, syntax, errorHandler);\n\n const notifyUserObject = {\n message: SchemaObjectDisplayExpression.parse(getAttribute(notificationElement, 'message')),\n recipient: getAttribute(notificationElement, 'recipient-field'),\n received: getAttribute(notificationElement, 'received-field'),\n badgeCount: getAttribute(notificationElement, 'badge-count-field')\n };\n\n object.notifyUsers.push(notifyUserObject);\n });\n }\n\n function parseIndexes(object: SchemaModelType, element: XMLElement) {\n const indexDef = {\n index: {\n name: xml.attribute.name,\n on: xml.attribute.notBlank,\n database: xml.attribute.notBlank,\n _required: ['on']\n }\n };\n\n xml.children(element, 'index').forEach(function (e) {\n parseElement(e, indexDef, errorHandler);\n\n const onAttribute = getAttribute(e, 'on');\n let name = getAttribute(e, 'name');\n const on = onAttribute.split(',');\n let keys: ModelIndexKey[] = [];\n for (let key of on) {\n let dir: IndexDirection;\n if (key.startsWith('-')) {\n key = key.substring(1);\n dir = IndexDirection.DESCENDING;\n } else {\n dir = IndexDirection.ASCENDING;\n }\n const fieldType = object.attributes[key] || object.belongsToVars[key];\n if (!fieldType) {\n errorHandler.pushError({\n element: xml.attributeNode(e, 'on') || e,\n message: \"Undefined field or model in index: '\" + key + \"'\"\n });\n } else if (['attachment', 'multiple-choice', 'multiple-choice-integer'].indexOf(fieldType.type.name) >= 0) {\n errorHandler.pushError({\n element: xml.attributeNode(e, 'on') || e,\n message: \"Field is not indexable: '\" + key + \"'\"\n });\n }\n keys.push({\n dir,\n field: key\n });\n }\n if (name == null) {\n name = keys.map((key) => key.field).join('_');\n }\n const databaseAttribute = getAttribute(e, 'database');\n let databases: IndexDatabase[] = [IndexDatabase.APP, IndexDatabase.CLOUD];\n if (databaseAttribute) {\n databases = databaseAttribute.split(',') as IndexDatabase[];\n for (let db of databases) {\n if ([IndexDatabase.APP, IndexDatabase.CLOUD].indexOf(db) == -1) {\n errorHandler.pushError({ element: xml.attributeNode(e, 'database'), message: `Invalid database: ${db}` });\n }\n }\n }\n const index: ModelIndex = {\n on, // Deprecated, since this doesn't support IndexDirection.\n keys,\n name,\n databases\n };\n object.allIndexes.push(index);\n if (index.databases.indexOf(IndexDatabase.APP) >= 0) {\n object.indexes.push(index);\n }\n });\n }\n\n function parseIntegerOptions(type: Type, element: XMLElement) {\n if (!ChoiceType.isInstanceOf(type)) {\n throw new Error('Integer options can only be used with choice types');\n }\n let index = 0;\n let largest = -1;\n xml.children(element, 'option').forEach(function (e) {\n parseElement(e, optionDef, errorHandler);\n const valueText = getAttribute(e, tag.optionKey);\n const value = valueText == null ? largest + 1 : parseInt(valueText, 10);\n const label = e.textContent;\n try {\n let enumOption = type.addOption(value, label, index);\n recordSource(enumOption, e);\n } catch (err) {\n errorHandler.pushError({ element: xml.attributeNode(e, tag.optionKey) || e, message: err.message });\n }\n index++;\n largest = Math.max(largest, value);\n });\n }\n\n function parseStringOptions(type: Type, element: XMLElement) {\n if (!ChoiceType.isInstanceOf(type)) {\n throw new Error('String options can only be used with choice types');\n }\n let index = 0;\n xml.children(element, 'option').forEach(function (e) {\n parseElement(e, optionDef, errorHandler);\n const value = getAttribute(e, tag.optionKey);\n const label = e.textContent;\n try {\n let enumOption = type.addOption(value, label, index);\n recordSource(enumOption, e);\n index++;\n } catch (err) {\n errorHandler.pushError({ element: xml.attributeNode(e, tag.optionKey) || e, message: err.message });\n }\n });\n }\n\n function parseBooleanOptions(type: Type, element: XMLElement) {\n if (!ChoiceType.isInstanceOf(type)) {\n throw new Error('Boolean options can only be used with choice types');\n }\n let index = 0;\n xml.children(element, 'option').forEach(function (e) {\n parseElement(e, optionDef, errorHandler);\n const valueText = getAttribute(e, tag.optionKey);\n const value = ({ true: true, false: false } as any)[valueText];\n const label = e.textContent;\n if (value != null) {\n try {\n let enumOption = type.addOption(value, label, index);\n recordSource(enumOption, e);\n index++;\n } catch (err) {\n errorHandler.pushError({ element: xml.attributeNode(e, tag.optionKey) || e, message: err.message });\n }\n } else {\n errorHandler.pushError({\n element: xml.attributeNode(e, tag.optionKey) || e,\n message: 'key must be \"true\" or \"false\"'\n });\n }\n });\n if (Object.keys(type.options).length === 0) {\n type.addOption(false, 'No', 0);\n type.addOption(true, 'Yes', 1);\n }\n if (Object.keys(type.options).length != 2) {\n errorHandler.pushError({ element, message: 'A boolean must contain exactly two options.' });\n }\n }\n\n /**\n * Validate declaration attributes independently of resolving their type.\n * A caller validating type expressions separately can omit the type attribute checks.\n */\n function validateVariableAttributes(element: XMLElement, options: { validateType?: boolean } = {}) {\n const definition = element.tagName === 'param' ? parameterDef : variableDef;\n parseElement(\n element,\n {\n [element.tagName]:\n options.validateType === false\n ? {\n ...definition,\n type: xml.attribute.any,\n _required: definition._required.filter((name) => name !== 'type')\n }\n : definition\n },\n errorHandler\n );\n }\n\n function parseField(element: XMLElement, isVariable: boolean) {\n const isParam = element.tagName == 'param';\n\n const variable: Variable | Param = isParam ? schema.param() : schema.variable();\n\n recordSource(variable, element);\n\n if (isVariable) {\n validateVariableAttributes(element);\n } else {\n parseElement(\n element,\n {\n attribute: attributeDef,\n field: attributeDef\n },\n errorHandler\n );\n }\n\n variable.name = getAttribute(element, 'name');\n variable.label = getAttribute(element, 'label');\n\n if (isParam) {\n const requiredAttr = getAttribute(element, 'required');\n (variable as Param).required = requiredAttr != null ? requiredAttr !== 'false' : true;\n const provider = getAttribute(element, 'transform-value');\n if (provider != null) {\n (variable as Param).provideValue = parseParameterValueProvider(provider);\n }\n }\n\n const originalTypeName = getAttribute(element, 'type');\n variable.sourceTypeName = originalTypeName; // Useful for debugging info\n\n let typeName = originalTypeName;\n let subType = null;\n\n if (originalTypeName != null) {\n const colon = originalTypeName.indexOf(':');\n if (colon >= 0 && v3) {\n typeName = originalTypeName.substring(0, colon);\n subType = originalTypeName.substring(colon + 1);\n }\n }\n\n if (!isVariable) {\n const validation = validateFieldName(variable.name);\n if (validation) {\n errorHandler.pushError({\n element: xml.attributeNode(element, 'name'),\n message: `Reserved field name '${variable.name}'`,\n type: validation\n });\n } else if (variable.name != null && variable.name.slice(-3) === '_id') {\n errorHandler.pushError({\n element: xml.attributeNode(element, 'name'),\n message: \"Field name should not end with '_id'\",\n type: 'warning'\n });\n }\n }\n\n let query = false;\n let array = false;\n\n if (isVariable) {\n if (v3 && typeName == 'query') {\n query = true;\n typeName = subType;\n } else if (v3 && typeName == 'array') {\n array = true;\n typeName = subType;\n } else if (!v3 && getAttribute(element, 'array') == 'true') {\n query = true;\n }\n }\n\n let primitiveType = null;\n\n if (v3) {\n if (!v3p1 && typeName == 'decimal') {\n typeName = PrimitiveType.NUMBER;\n }\n primitiveType = schema.primitive(typeName);\n } else {\n if (typeName in v2PrimitiveMapping) {\n typeName = v2PrimitiveMapping[typeName];\n primitiveType = schema.primitive(typeName);\n } else {\n primitiveType = null;\n }\n }\n\n if (\n typeName == PrimitiveType.SINGLE_CHOICE_INTEGER ||\n typeName == PrimitiveType.MULTIPLE_CHOICE_INTEGER ||\n typeName == PrimitiveType.SINGLE_CHOICE ||\n typeName == PrimitiveType.MULTIPLE_CHOICE ||\n typeName == PrimitiveType.BOOLEAN\n ) {\n errorHandler.pushErrors(xml.validateChildren(element, { option: 1 }));\n } else {\n errorHandler.pushErrors(xml.validateChildren(element, { arg: 1 }));\n }\n\n if (primitiveType == null && isVariable) {\n const objectType = schema.getType(typeName);\n if (objectType != null) {\n if (query) {\n variable.type = new QueryType(objectType);\n } else if (array) {\n variable.type = new ArrayType(objectType);\n } else {\n variable.type = objectType;\n }\n } else if (isParam && typeName == FunctionType.TYPE) {\n const functionType = schema.functionType();\n xml.children(element, FunctionType.ARG_TAG).forEach((child) => {\n const result = parseElement(child, { arg: v5ParamArgDef }, errorHandler);\n if (result.errors.length == 0) {\n functionType.addArgument(\n schema.variable(getAttribute(child, 'name'), schema.getType(getAttribute(child, 'type')))\n );\n }\n });\n variable.type = functionType;\n }\n } else if (primitiveType != null) {\n variable.type = primitiveType;\n if (TextType.isInstanceOf(variable.type)) {\n variable.type.spec = getAttribute(element, 'spec');\n\n if (v3 && subType) {\n variable.type.subType = subType;\n\n // For backwards compatibility\n variable.type.spec = v3SpecMapping[subType];\n\n if (variable.type.spec == null) {\n errorHandler.pushError({\n element: xml.attributeNode(element, 'type'),\n message: \"'\" + subType + \"' is not a valid string format\"\n });\n }\n }\n } else if (DateType.isInstanceOf(variable.type)) {\n variable.type.isDay = v3p1 ? true : false;\n } else if (typeName == 'single-choice-integer' || typeName == 'multiple-choice-integer') {\n parseIntegerOptions(variable.type, element);\n } else if (typeName == 'single-choice' || typeName == 'multiple-choice') {\n parseStringOptions(variable.type, element);\n } else if (typeName == 'boolean') {\n parseBooleanOptions(variable.type, element);\n } else if (originalTypeName == 'attachment' && AttachmentType.isInstanceOf(variable.type)) {\n variable.type.media = getAttribute(element, 'media');\n if (variable.type.media == null) {\n if (v3) {\n errorHandler.pushError({\n element,\n message: 'Include media=\"\" with a specific mime type, or media=\"any\" for any of the allowed types.'\n });\n } else {\n errorHandler.pushError({\n element,\n message: 'Include media=\"image/svg+xml\" (signature) or \"image/jpeg\" (picture)'\n });\n }\n }\n // parseElement validates the allowed values when the element is present\n }\n }\n\n if (variable.type != null && AttachmentType.isInstanceOf(variable.type)) {\n variable.type.autoDownload = getAttribute(element, 'auto-download') == 'true';\n }\n\n if (variable.type == null) {\n if (xml.attributeNode(element, 'type') != null && typeName !== '') {\n errorHandler.pushError({\n element: xml.attributeNode(element, 'type'),\n message: \"Invalid type '\" + originalTypeName + \"'\"\n });\n } else {\n // This case is covered by parseElement().\n }\n }\n\n return variable;\n }\n\n function reset() {\n errorHandler.reset();\n }\n\n function getErrors() {\n return errorHandler.getErrors();\n }\n\n return {\n parse,\n parseField,\n validateVariableAttributes,\n parseObjectType,\n parseBelongsTo,\n parseDisplay,\n reset,\n getErrors\n };\n}\n\n/**\n * Apply serialized field metadata to a variable whose type is already resolved.\n */\nexport function applyVariableMetadata(variable: Variable, attributeData: any) {\n variable.label = attributeData.label;\n\n if (attributeData.spec && TextType.isInstanceOf(variable.type)) {\n variable.type.spec = attributeData.spec;\n }\n\n if (attributeData.subType && TextType.isInstanceOf(variable.type)) {\n variable.type.subType = attributeData.subType;\n }\n\n if (DateType.isInstanceOf(variable.type)) {\n variable.type.isDay = !!attributeData.isDay;\n }\n\n if (attributeData.options && ChoiceType.isInstanceOf(variable.type)) {\n for (let optionData of attributeData.options) {\n variable.type.addOption(optionData.value, optionData.label, optionData.index);\n }\n }\n return variable;\n}\n\nexport function parseJsonVariable(schema: Schema, attributeName: string, attributeData: any) {\n if (attributeData.type == 'query') {\n return schema.variable(attributeName, new QueryType(schema.getType(attributeData.object)));\n } else if (attributeData.type == 'array') {\n return schema.variable(attributeName, new ArrayType(schema.getType(attributeData.object)));\n } else {\n const variable = schema.variable(attributeName, attributeData.type);\n if (attributeData.required != null) {\n (variable as Param).required = attributeData.required;\n }\n if (attributeData.provideValue != null) {\n (variable as Param).provideValue = parseParameterValueProvider(attributeData.provideValue);\n }\n return applyVariableMetadata(variable, attributeData);\n }\n}\n\n// Schema-free variable parsing\n// Used for indexes\nexport function parseJsonField(schema: Schema, attributeData: any) {\n const type = schema.primitive(attributeData.type);\n let variable = schema.variable(attributeData.name, type);\n if (attributeData.relationship) {\n variable.relationship = attributeData.relationship;\n variable.isRelationshipId = attributeData.isRelationshipId;\n }\n return applyVariableMetadata(variable, attributeData);\n}\n\nexport function jsonParser(schema: Schema) {\n // Structure:\n // {\n // objects: {\n // \"asset\": {\n // attributes: {\n // \"serial_number\": {\n // type: \"string\",\n // spec: \"number\",\n // },\n // ...,\n // },\n // belongsTo: {\n // \"owner\": {\n // type: \"person\",\n // foreignName: \"assets\"\n // },\n // ...\n // },\n // display: \"A {serial_number}\",\n // },\n // ...\n // }\n // }\n function parse(data: any) {\n schema.objects = {};\n\n // First pass - load the objects with attributes and display names\n Object.keys(data.objects).forEach(function (name) {\n const objectData = data.objects[name];\n const object = schema.newObjectType();\n object.name = name;\n object.label = objectData.label;\n object.displayFormat = SchemaObjectDisplayExpression.parse(objectData.display);\n\n Object.keys(objectData.attributes).forEach(function (attributeName) {\n const attributeData = objectData.attributes[attributeName];\n const variable = parseJsonVariable(schema, attributeName, attributeData);\n object.addAttribute(variable);\n });\n\n schema.objects[object.name] = object;\n });\n\n Object.keys(data.objects).forEach(function (name) {\n const objectData = data.objects[name];\n const object = schema.objects[name];\n\n Object.keys(objectData.belongsTo).forEach(function (relName) {\n const relData = objectData.belongsTo[relName];\n const rel = object.addBelongsTo({\n name: relName,\n type: relData.type,\n schema,\n foreignName: relData.foreignName\n });\n });\n });\n }\n\n return {\n parse\n };\n}\n"]}
@@ -1,181 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.toDOM = toDOM;
37
- exports.updateOptions = updateOptions;
38
- const common_xml_1 = require("@journeyapps/common-xml");
39
- const xml = __importStar(require("@journeyapps/common-xml"));
40
- const primitives_1 = require("../types/primitives");
41
- function toDOM(schema) {
42
- let doc = xml.createDocument('data-model');
43
- let root = doc.documentElement;
44
- doc.insertBefore(doc.createProcessingInstruction('xml', 'version="1.0" encoding="UTF-8"'), root);
45
- const documentDiff = new common_xml_1.OrderedIncrementalUpdater(schema.sourceElement, ['model']);
46
- for (let type in schema.objects) {
47
- let model = schema.objects[type];
48
- const updateModel = (modelElement) => {
49
- (0, common_xml_1.setAttributes)(modelElement, {
50
- name: model.name,
51
- label: model.label
52
- });
53
- const diff = new common_xml_1.OrderedIncrementalUpdater(model.sourceElement, ['field', 'belongs-to', 'has-many', 'display']);
54
- for (let attributeName in model.attributes) {
55
- const attribute = model.attributes[attributeName];
56
- diff.append(attribute.sourceElement, {
57
- tagName: 'field',
58
- update(fieldElement) {
59
- (0, common_xml_1.setAttributes)(fieldElement, {
60
- name: attribute.name,
61
- label: attribute.label,
62
- type: attribute.sourceTypeName || attribute.type.stringify(),
63
- 'auto-download': primitives_1.AttachmentType.isInstanceOf(attribute.type) && attribute.type.autoDownload ? 'true' : null
64
- });
65
- // single-choice, single-choice-integer and boolean fields all may contain <option> children.
66
- // For other elements, we just keep the children as is.
67
- const fieldDiff = new common_xml_1.OrderedIncrementalUpdater(attribute.sourceElement, ['option']);
68
- updateOptions(fieldDiff, attribute);
69
- fieldDiff.update(fieldElement);
70
- },
71
- cloneDeep: false
72
- });
73
- }
74
- for (let fieldName in model.belongsTo) {
75
- const field = model.belongsToVars[fieldName];
76
- const rel = model.belongsTo[fieldName];
77
- diff.append(field.sourceElement, {
78
- tagName: 'belongs-to',
79
- update(fieldElement) {
80
- (0, common_xml_1.setAttributes)(fieldElement, {
81
- model: rel.foreignType.name,
82
- name: rel.name
83
- }, { name: rel.foreignType.name });
84
- },
85
- cloneDeep: true
86
- });
87
- }
88
- for (let fieldName in model.hasMany) {
89
- const rel = model.hasMany[fieldName];
90
- const field = model.hasManyVars[fieldName];
91
- diff.append(field.sourceElement, {
92
- tagName: 'has-many',
93
- update(fieldElement) {
94
- (0, common_xml_1.setAttributes)(fieldElement, {
95
- model: rel.objectType.name,
96
- name: rel.foreignName
97
- });
98
- },
99
- cloneDeep: true
100
- });
101
- }
102
- diff.append(model.displaySource, {
103
- tagName: 'display',
104
- update(displayElement) {
105
- var _a;
106
- var _b;
107
- displayElement.textContent = (_b = (_a = model.displayFormat) === null || _a === void 0 ? void 0 : _a.raw()) !== null && _b !== void 0 ? _b : '';
108
- },
109
- cloneDeep: true
110
- });
111
- diff.update(modelElement);
112
- };
113
- documentDiff.append(model.sourceElement, {
114
- tagName: 'model',
115
- update: updateModel,
116
- cloneDeep: false
117
- });
118
- }
119
- documentDiff.update(root);
120
- return doc;
121
- }
122
- /**
123
- * Update the options for single-choice, single-choice-integer and boolean fields.
124
- *
125
- * No-op for other fields.
126
- */
127
- function updateOptions(fieldDiff, attribute) {
128
- if (!primitives_1.ChoiceType.isInstanceOf(attribute.type)) {
129
- return;
130
- }
131
- const options = attribute.type.options;
132
- const keys = Object.keys(options);
133
- // Special case for default boolean options, which doesn't have to be specified explicitly.
134
- // <option key="false">No</option>
135
- // <option key="true">Yes</option>
136
- let explicitOptions = true;
137
- if (attribute.type.name == 'boolean' &&
138
- keys.length == 2 &&
139
- keys[0] == 'false' &&
140
- keys[1] == 'true' &&
141
- options['false'].label == 'No' &&
142
- options['true'].label == 'Yes') {
143
- // Options match the default options. Use implicit ones.
144
- if (attribute.sourceElement && attribute.sourceElement.childNodes.length > 0) {
145
- // Source contained elements inside the tags. Could have been comments on the options.
146
- // Keep explicit options in this case.
147
- explicitOptions = true;
148
- }
149
- else {
150
- explicitOptions = false;
151
- }
152
- }
153
- if (!explicitOptions) {
154
- // No options needed.
155
- return;
156
- }
157
- // For single-choice-integer, keep track of the last key.
158
- let lastKey = -1;
159
- for (let key of keys) {
160
- const option = options[key];
161
- // If the key is equal to the previous one + 1, we don't have to specify it.
162
- // However, if the source had an explicit key, we keep it.
163
- const defaultValue = '' + (lastKey + 1);
164
- if (typeof option.value == 'number') {
165
- lastKey = option.value;
166
- }
167
- fieldDiff.append(option.sourceElement, {
168
- tagName: 'option',
169
- update(element) {
170
- (0, common_xml_1.setAttributes)(element, {
171
- key: '' + option.value
172
- }, {
173
- key: defaultValue
174
- });
175
- element.textContent = option.label;
176
- },
177
- cloneDeep: true
178
- });
179
- }
180
- }
181
- //# sourceMappingURL=schemaSerializer.js.map
@@ -1 +0,0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EAAE;YACrC,OAAO,EAAE,QAAQ;YACjB,MAAM,CAAC,OAAO;gBACZ,IAAA,0BAAa,EACX,OAAO,EACP;oBACE,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK;iBACvB,EACD;oBACE,GAAG,EAAE,YAAY;iBAClB,CACF,CAAC;gBACF,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;YACrC,CAAC;YACD,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { Schema } from './Schema';\nimport { setAttributes, OrderedIncrementalUpdater } from '@journeyapps/common-xml';\nimport { XMLElement, XMLDocument } from '@journeyapps/domparser/types';\nimport * as xml from '@journeyapps/common-xml';\nimport { Variable } from '../types/Variable';\nimport { AttachmentType, ChoiceType } from '../types/primitives';\n\nexport function toDOM(schema: Schema): XMLDocument {\n let doc = xml.createDocument('data-model');\n let root = doc.documentElement;\n doc.insertBefore(doc.createProcessingInstruction('xml', 'version=\"1.0\" encoding=\"UTF-8\"'), root);\n\n const documentDiff = new OrderedIncrementalUpdater(schema.sourceElement, ['model']);\n\n for (let type in schema.objects) {\n let model = schema.objects[type];\n\n const updateModel = (modelElement: XMLElement) => {\n setAttributes(modelElement, {\n name: model.name,\n label: model.label\n });\n\n const diff = new OrderedIncrementalUpdater(model.sourceElement, ['field', 'belongs-to', 'has-many', 'display']);\n\n for (let attributeName in model.attributes) {\n const attribute = model.attributes[attributeName];\n diff.append(attribute.sourceElement, {\n tagName: 'field',\n update(fieldElement) {\n setAttributes(fieldElement, {\n name: attribute.name,\n label: attribute.label,\n type: attribute.sourceTypeName || attribute.type.stringify(),\n 'auto-download':\n AttachmentType.isInstanceOf(attribute.type) && attribute.type.autoDownload ? 'true' : null\n });\n\n // single-choice, single-choice-integer and boolean fields all may contain <option> children.\n // For other elements, we just keep the children as is.\n const fieldDiff = new OrderedIncrementalUpdater(attribute.sourceElement, ['option']);\n updateOptions(fieldDiff, attribute);\n fieldDiff.update(fieldElement);\n },\n cloneDeep: false\n });\n }\n\n for (let fieldName in model.belongsTo) {\n const field = model.belongsToVars[fieldName];\n const rel = model.belongsTo[fieldName];\n diff.append(field.sourceElement, {\n tagName: 'belongs-to',\n update(fieldElement) {\n setAttributes(\n fieldElement,\n {\n model: rel.foreignType.name,\n name: rel.name\n },\n { name: rel.foreignType.name }\n );\n },\n cloneDeep: true\n });\n }\n\n for (let fieldName in model.hasMany) {\n const rel = model.hasMany[fieldName];\n const field = model.hasManyVars[fieldName];\n diff.append(field.sourceElement, {\n tagName: 'has-many',\n update(fieldElement) {\n setAttributes(fieldElement, {\n model: rel.objectType.name,\n name: rel.foreignName\n });\n },\n cloneDeep: true\n });\n }\n\n diff.append(model.displaySource, {\n tagName: 'display',\n update(displayElement) {\n displayElement.textContent = model.displayFormat?.raw() ?? '';\n },\n cloneDeep: true\n });\n\n diff.update(modelElement);\n };\n\n documentDiff.append(model.sourceElement, {\n tagName: 'model',\n update: updateModel,\n cloneDeep: false\n });\n }\n\n documentDiff.update(root);\n return doc;\n}\n\n/**\n * Update the options for single-choice, single-choice-integer and boolean fields.\n *\n * No-op for other fields.\n */\nexport function updateOptions(fieldDiff: OrderedIncrementalUpdater, attribute: Variable) {\n if (!ChoiceType.isInstanceOf(attribute.type)) {\n return;\n }\n const options = attribute.type.options;\n const keys = Object.keys(options);\n\n // Special case for default boolean options, which doesn't have to be specified explicitly.\n // <option key=\"false\">No</option>\n // <option key=\"true\">Yes</option>\n let explicitOptions = true;\n if (\n attribute.type.name == 'boolean' &&\n keys.length == 2 &&\n keys[0] == 'false' &&\n keys[1] == 'true' &&\n options['false'].label == 'No' &&\n options['true'].label == 'Yes'\n ) {\n // Options match the default options. Use implicit ones.\n if (attribute.sourceElement && attribute.sourceElement.childNodes.length > 0) {\n // Source contained elements inside the tags. Could have been comments on the options.\n // Keep explicit options in this case.\n explicitOptions = true;\n } else {\n explicitOptions = false;\n }\n }\n\n if (!explicitOptions) {\n // No options needed.\n return;\n }\n\n // For single-choice-integer, keep track of the last key.\n let lastKey = -1;\n for (let key of keys) {\n const option = options[key];\n // If the key is equal to the previous one + 1, we don't have to specify it.\n // However, if the source had an explicit key, we keep it.\n const defaultValue = '' + (lastKey + 1);\n if (typeof option.value == 'number') {\n lastKey = option.value;\n }\n fieldDiff.append(option.sourceElement, {\n tagName: 'option',\n update(element) {\n setAttributes(\n element,\n {\n key: '' + option.value\n },\n {\n key: defaultValue\n }\n );\n element.textContent = option.label;\n },\n cloneDeep: true\n });\n }\n}\n"]}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FunctionTypeFactory = exports.FunctionType = void 0;
4
- const TypeFactory_1 = require("../schema/TypeFactory");
5
- const parser_type_system_1 = require("@ja-platform/parser-type-system");
6
- class FunctionType extends parser_type_system_1.Type {
7
- static isInstanceOf(type) {
8
- return type.name === FunctionType.TYPE;
9
- }
10
- constructor() {
11
- super(FunctionType.TYPE);
12
- this.arguments = [];
13
- }
14
- addArgument(argument) {
15
- this.arguments.push(argument);
16
- }
17
- }
18
- exports.FunctionType = FunctionType;
19
- FunctionType.TYPE = 'function';
20
- FunctionType.ARG_TAG = 'arg';
21
- class FunctionTypeFactory extends TypeFactory_1.AbstractObjectTypeFactory {
22
- constructor() {
23
- super(FunctionType.TYPE);
24
- }
25
- generate() {
26
- return new FunctionType();
27
- }
28
- }
29
- exports.FunctionTypeFactory = FunctionTypeFactory;
30
- //# sourceMappingURL=FunctionType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FunctionType.js","sourceRoot":"","sources":["../../src/types/FunctionType.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAClE,wEAAuD;AAGvD,kBAA0B,SAAQ,yBAAI;IAIpC,MAAM,CAAC,YAAY,CAAC,IAAU;QAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC;IACzC,CAAC;IAGD;QACE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,WAAW,CAAC,QAAkB;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CACF;;AAhBiB,iBAAI,GAAG,UAAU,CAAC;AAClB,oBAAO,GAAG,KAAK,CAAC;AAiBlC,yBAAiC,SAAQ,uCAAuC;IAC9E;QACE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,YAAY,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { AbstractObjectTypeFactory } from '../schema/TypeFactory';\nimport { Type } from '@ja-platform/parser-type-system';\nimport { Variable } from './Variable';\n\nexport class FunctionType extends Type {\n static readonly TYPE = 'function';\n static readonly ARG_TAG = 'arg';\n\n static isInstanceOf(type: Type): type is FunctionType {\n return type.name === FunctionType.TYPE;\n }\n arguments: Variable[];\n\n constructor() {\n super(FunctionType.TYPE);\n this.arguments = [];\n }\n\n addArgument(argument: Variable) {\n this.arguments.push(argument);\n }\n}\n\nexport class FunctionTypeFactory extends AbstractObjectTypeFactory<FunctionType> {\n constructor() {\n super(FunctionType.TYPE);\n }\n\n generate(): FunctionType {\n return new FunctionType();\n }\n}\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VariableFactory = exports.Variable = void 0;
4
- const TypeFactory_1 = require("../schema/TypeFactory");
5
- const SchemaModelType_1 = require("./SchemaModelType");
6
- // Variable constructor. A variable is simply a name and a type (can be null).
7
- class Variable {
8
- static isInstanceOf(obj) {
9
- return obj instanceof Variable || 'name' in obj;
10
- }
11
- constructor(name, type) {
12
- this.name = name;
13
- this.type = type;
14
- this.errors = [];
15
- }
16
- toJSON() {
17
- const result = {
18
- name: this.name,
19
- type: undefined
20
- };
21
- if (this.type != null) {
22
- result.type = this.type.name;
23
- }
24
- if (typeof this.label != 'undefined') {
25
- result.label = this.label;
26
- }
27
- if (this.type != null && !(this.type instanceof SchemaModelType_1.SchemaModelType)) {
28
- const typeJson = this.type.toJSON();
29
- Object.assign(result, typeJson);
30
- }
31
- if (this.relationship != null) {
32
- result.relationship = this.relationship;
33
- result.isRelationshipId = this.isRelationshipId;
34
- }
35
- return result;
36
- }
37
- }
38
- exports.Variable = Variable;
39
- Variable.TYPE = 'variable';
40
- class VariableFactory extends TypeFactory_1.AbstractObjectTypeFactory {
41
- constructor() {
42
- super(Variable.TYPE);
43
- }
44
- generate(event) {
45
- return new Variable(event.name, event.type);
46
- }
47
- }
48
- exports.VariableFactory = VariableFactory;
49
- //# sourceMappingURL=Variable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Variable.js","sourceRoot":"","sources":["../../src/types/Variable.ts"],"names":[],"mappings":";;;AAAA,uDAAqF;AAErF,uDAAoD;AAUpD,8EAA8E;AAC9E;IAGE,MAAM,CAAC,YAAY,CAAC,GAAQ;QAC1B,OAAO,GAAG,YAAY,QAAQ,IAAI,MAAM,IAAI,GAAG,CAAC;IAClD,CAAC;IAYD,YAAY,IAAY,EAAE,IAAc;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAqB;YAC/B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,SAAS;SAChB,CAAC;QACF,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAC/B,CAAC;QAED,IAAI,OAAO,IAAI,CAAC,KAAK,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,YAAY,iCAAe,CAAC,EAAE,CAAC;YACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;YAC9B,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;YACxC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAClD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;;AA9CQ,aAAI,GAAG,UAAU,CAAC;AAqD3B,qBAAoD,SAAQ,uCAG3D;IACC;QACE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IACD,QAAQ,CAAwB,KAA+B;QAC7D,OAAO,IAAI,QAAQ,CAAI,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF","sourcesContent":["import { AbstractObjectTypeFactory, GenerateTypeEvent } from '../schema/TypeFactory';\nimport { Type } from '@ja-platform/parser-type-system';\nimport { SchemaModelType } from './SchemaModelType';\nimport { XMLElement } from '@journeyapps/domparser/types';\n\nexport interface VariableJsonType {\n name: string;\n type: string;\n label?: string;\n [key: string]: any;\n}\n\n// Variable constructor. A variable is simply a name and a type (can be null).\nexport class Variable<T extends Type = Type> {\n static TYPE = 'variable';\n\n static isInstanceOf(obj: any): obj is Variable {\n return obj instanceof Variable || 'name' in obj;\n }\n\n name: string;\n type: T | null;\n errors: any[];\n label?: string;\n relationship?: string;\n isRelationshipId?: boolean;\n isBelongsToId?: boolean;\n sourceTypeName?: string;\n sourceElement: XMLElement;\n\n constructor(name: string, type: T | null) {\n this.name = name;\n this.type = type;\n this.errors = [];\n }\n\n toJSON() {\n const result: VariableJsonType = {\n name: this.name,\n type: undefined\n };\n if (this.type != null) {\n result.type = this.type.name;\n }\n\n if (typeof this.label != 'undefined') {\n result.label = this.label;\n }\n if (this.type != null && !(this.type instanceof SchemaModelType)) {\n const typeJson = this.type.toJSON();\n Object.assign(result, typeJson);\n }\n\n if (this.relationship != null) {\n result.relationship = this.relationship;\n result.isRelationshipId = this.isRelationshipId;\n }\n\n return result;\n }\n}\n\nexport interface GenerateVariableEvent<T extends Type> extends GenerateTypeEvent {\n name: string;\n type: T;\n}\n\nexport class VariableFactory<T extends Type = Type> extends AbstractObjectTypeFactory<\n Variable<T>,\n GenerateVariableEvent<T>\n> {\n constructor() {\n super(Variable.TYPE);\n }\n generate<T extends Type = Type>(event: GenerateVariableEvent<T>): Variable<T> {\n return new Variable<T>(event.name, event.type);\n }\n}\n"]}