@ja-platform/parser-schema-xml 0.0.0-stage → 1.0.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.
Files changed (99) hide show
  1. package/dist/@types/SchemaNode.d.ts +13 -0
  2. package/dist/@types/XmlField.d.ts +10 -0
  3. package/dist/@types/XmlModel.d.ts +16 -0
  4. package/dist/@types/XmlParam.d.ts +7 -0
  5. package/dist/@types/XmlSchema.d.ts +20 -0
  6. package/dist/@types/attributes/SchemaDatabaseAttribute.d.ts +11 -0
  7. package/dist/@types/attributes/SchemaEnumAttribute.d.ts +6 -0
  8. package/dist/@types/attributes/SchemaFieldTypeAttribute.d.ts +9 -0
  9. package/dist/@types/attributes/SchemaIndexAttribute.d.ts +9 -0
  10. package/dist/@types/attributes/SchemaNameAttribute.d.ts +4 -0
  11. package/dist/@types/attributes/SchemaOptionKeyAttribute.d.ts +16 -0
  12. package/dist/@types/expressions/SchemaDatabasesExpression.d.ts +10 -0
  13. package/dist/@types/expressions/SchemaFieldTypeExpression.d.ts +14 -0
  14. package/dist/@types/expressions/SchemaIndexExpression.d.ts +14 -0
  15. package/dist/@types/index.d.ts +10 -0
  16. package/dist/@types/loadSchemaXml.d.ts +8 -0
  17. package/dist/@types/nodes/SchemaBelongsToNode.d.ts +9 -0
  18. package/dist/@types/nodes/SchemaDisplayNode.d.ts +8 -0
  19. package/dist/@types/nodes/SchemaFieldNode.d.ts +21 -0
  20. package/dist/@types/nodes/SchemaHasManyNode.d.ts +10 -0
  21. package/dist/@types/nodes/SchemaIndexNode.d.ts +12 -0
  22. package/dist/@types/nodes/SchemaModelNode.d.ts +26 -0
  23. package/dist/@types/nodes/SchemaNotificationNode.d.ts +12 -0
  24. package/dist/@types/nodes/SchemaOptionNode.d.ts +10 -0
  25. package/dist/@types/nodes/SchemaWebhookFieldNode.d.ts +12 -0
  26. package/dist/@types/nodes/SchemaWebhookNode.d.ts +14 -0
  27. package/dist/@types/parsed/ParsedSchemaFieldNode.d.ts +7 -0
  28. package/dist/@types/parsed/ParsedSchemaModelNode.d.ts +15 -0
  29. package/dist/@types/parsed/ParsedSchemaNode.d.ts +10 -0
  30. package/dist/@types/parsed/sourceElement.d.ts +4 -0
  31. package/dist/@types/schemaSerializer.d.ts +11 -0
  32. package/dist/@types/tokens/SchemaIndexKeyToken.d.ts +14 -0
  33. package/dist/SchemaNode.js +20 -0
  34. package/dist/SchemaNode.js.map +1 -0
  35. package/dist/XmlField.js +12 -0
  36. package/dist/XmlField.js.map +1 -0
  37. package/dist/XmlModel.js +8 -0
  38. package/dist/XmlModel.js.map +1 -0
  39. package/dist/XmlParam.js +12 -0
  40. package/dist/XmlParam.js.map +1 -0
  41. package/dist/XmlSchema.js +29 -0
  42. package/dist/XmlSchema.js.map +1 -0
  43. package/dist/attributes/SchemaDatabaseAttribute.js +12 -0
  44. package/dist/attributes/SchemaDatabaseAttribute.js.map +1 -0
  45. package/dist/attributes/SchemaEnumAttribute.js +27 -0
  46. package/dist/attributes/SchemaEnumAttribute.js.map +1 -0
  47. package/dist/attributes/SchemaFieldTypeAttribute.js +12 -0
  48. package/dist/attributes/SchemaFieldTypeAttribute.js.map +1 -0
  49. package/dist/attributes/SchemaIndexAttribute.js +12 -0
  50. package/dist/attributes/SchemaIndexAttribute.js.map +1 -0
  51. package/dist/attributes/SchemaNameAttribute.js +23 -0
  52. package/dist/attributes/SchemaNameAttribute.js.map +1 -0
  53. package/dist/attributes/SchemaOptionKeyAttribute.js +30 -0
  54. package/dist/attributes/SchemaOptionKeyAttribute.js.map +1 -0
  55. package/dist/expressions/SchemaDatabasesExpression.js +28 -0
  56. package/dist/expressions/SchemaDatabasesExpression.js.map +1 -0
  57. package/dist/expressions/SchemaFieldTypeExpression.js +50 -0
  58. package/dist/expressions/SchemaFieldTypeExpression.js.map +1 -0
  59. package/dist/expressions/SchemaIndexExpression.js +30 -0
  60. package/dist/expressions/SchemaIndexExpression.js.map +1 -0
  61. package/dist/index.js +27 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/loadSchemaXml.js +46 -0
  64. package/dist/loadSchemaXml.js.map +1 -0
  65. package/dist/nodes/SchemaBelongsToNode.js +14 -0
  66. package/dist/nodes/SchemaBelongsToNode.js.map +1 -0
  67. package/dist/nodes/SchemaDisplayNode.js +17 -0
  68. package/dist/nodes/SchemaDisplayNode.js.map +1 -0
  69. package/dist/nodes/SchemaFieldNode.js +30 -0
  70. package/dist/nodes/SchemaFieldNode.js.map +1 -0
  71. package/dist/nodes/SchemaHasManyNode.js +15 -0
  72. package/dist/nodes/SchemaHasManyNode.js.map +1 -0
  73. package/dist/nodes/SchemaIndexNode.js +22 -0
  74. package/dist/nodes/SchemaIndexNode.js.map +1 -0
  75. package/dist/nodes/SchemaModelNode.js +34 -0
  76. package/dist/nodes/SchemaModelNode.js.map +1 -0
  77. package/dist/nodes/SchemaNotificationNode.js +21 -0
  78. package/dist/nodes/SchemaNotificationNode.js.map +1 -0
  79. package/dist/nodes/SchemaOptionNode.js +20 -0
  80. package/dist/nodes/SchemaOptionNode.js.map +1 -0
  81. package/dist/nodes/SchemaWebhookFieldNode.js +22 -0
  82. package/dist/nodes/SchemaWebhookFieldNode.js.map +1 -0
  83. package/dist/nodes/SchemaWebhookNode.js +20 -0
  84. package/dist/nodes/SchemaWebhookNode.js.map +1 -0
  85. package/dist/parsed/ParsedSchemaFieldNode.js +56 -0
  86. package/dist/parsed/ParsedSchemaFieldNode.js.map +1 -0
  87. package/dist/parsed/ParsedSchemaModelNode.js +113 -0
  88. package/dist/parsed/ParsedSchemaModelNode.js.map +1 -0
  89. package/dist/parsed/ParsedSchemaNode.js +29 -0
  90. package/dist/parsed/ParsedSchemaNode.js.map +1 -0
  91. package/dist/parsed/sourceElement.js +12 -0
  92. package/dist/parsed/sourceElement.js.map +1 -0
  93. package/dist/schemaSerializer.js +181 -0
  94. package/dist/schemaSerializer.js.map +1 -0
  95. package/dist/tokens/SchemaIndexKeyToken.js +39 -0
  96. package/dist/tokens/SchemaIndexKeyToken.js.map +1 -0
  97. package/dist/tsconfig.tsbuildinfo +1 -0
  98. package/package.json +41 -3
  99. package/README.md +0 -3
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaIndexAttribute = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const SchemaIndexExpression_1 = require("../expressions/SchemaIndexExpression");
6
+ class SchemaIndexAttribute extends parser_core_1.Attribute {
7
+ constructor(options) {
8
+ super('schema-index', Object.assign(Object.assign({}, options), { syntax: new SchemaIndexExpression_1.SchemaIndexExpressionParser() }));
9
+ }
10
+ }
11
+ exports.SchemaIndexAttribute = SchemaIndexAttribute;
12
+ //# sourceMappingURL=SchemaIndexAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaIndexAttribute.js","sourceRoot":"","sources":["../../src/attributes/SchemaIndexAttribute.ts"],"names":[],"mappings":";;;AAAA,0DAA0F;AAC1F,gFAA0G;AAM1G,0BAAkC,SAAQ,uBAAuC;IAC/E,YAAY,OAAyB;QACnC,KAAK,CAAC,cAAc,kCAAO,OAAO,KAAE,MAAM,EAAE,IAAI,mDAA2B,EAAE,IAAG,CAAC;IACnF,CAAC;CACF","sourcesContent":["import { Attribute, AttributeGenerics, AttributeOptions } from '@ja-platform/parser-core';\nimport { SchemaIndexExpression, SchemaIndexExpressionParser } from '../expressions/SchemaIndexExpression';\n\ninterface SchemaIndexAttributeGenerics extends AttributeGenerics {\n Value: SchemaIndexExpression;\n}\n\nexport class SchemaIndexAttribute extends Attribute<SchemaIndexAttributeGenerics> {\n constructor(options: AttributeOptions) {\n super('schema-index', { ...options, syntax: new SchemaIndexExpressionParser() });\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaNameAttribute = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
6
+ const common_xml_1 = require("@journeyapps/common-xml");
7
+ class SchemaNameType extends parser_type_system_1.TextType {
8
+ parse(value) {
9
+ try {
10
+ return common_xml_1.attribute.name(super.parse(value));
11
+ }
12
+ catch (error) {
13
+ throw new SyntaxError(error.message);
14
+ }
15
+ }
16
+ }
17
+ class SchemaNameAttribute extends parser_core_1.ConstantTextAttribute {
18
+ constructor(options) {
19
+ super(Object.assign(Object.assign({}, options), { valueType: new SchemaNameType() }));
20
+ }
21
+ }
22
+ exports.SchemaNameAttribute = SchemaNameAttribute;
23
+ //# sourceMappingURL=SchemaNameAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaNameAttribute.js","sourceRoot":"","sources":["../../src/attributes/SchemaNameAttribute.ts"],"names":[],"mappings":";;;AAAA,0DAAmF;AACnF,wEAA2D;AAC3D,wDAAoD;AAEpD,MAAM,cAAe,SAAQ,6BAAQ;IACnC,KAAK,CAAC,KAAc;QAClB,IAAI,CAAC;YACH,OAAO,sBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;CACF;AAED,yBAAiC,SAAQ,mCAAqB;IAC5D,YAAY,OAAyC;QACnD,KAAK,iCAAM,OAAO,KAAE,SAAS,EAAE,IAAI,cAAc,EAAE,IAAG,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { ConstantTextAttribute, AttributeOptions } from '@ja-platform/parser-core';\nimport { TextType } from '@ja-platform/parser-type-system';\nimport { attribute } from '@journeyapps/common-xml';\n\nclass SchemaNameType extends TextType {\n parse(value: unknown): string {\n try {\n return attribute.name(super.parse(value));\n } catch (error) {\n throw new SyntaxError(error.message);\n }\n }\n}\n\nexport class SchemaNameAttribute extends ConstantTextAttribute {\n constructor(options: AttributeOptions<string, string>) {\n super({ ...options, valueType: new SchemaNameType() });\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaOptionKeyAttribute = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
6
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
7
+ const parser_schema_1 = require("@ja-platform/parser-schema");
8
+ /**
9
+ * Choice keys use the enclosing field's declared literal type.
10
+ */
11
+ class SchemaOptionKeyAttribute extends parser_core_1.Attribute {
12
+ constructor() {
13
+ super('schema-option-key', { name: 'key' });
14
+ }
15
+ getParsedValue(event) {
16
+ var _a, _b;
17
+ const field = (_b = (_a = event.context) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.attrExpression('type');
18
+ return new parser_expressions_1.ConstantExpressionParser(this.keyType(field === null || field === void 0 ? void 0 : field.primitive)).parse(event.input.value);
19
+ }
20
+ keyType(primitive) {
21
+ if (primitive === parser_schema_1.PrimitiveType.BOOLEAN)
22
+ return parser_type_system_1.booleanType;
23
+ if (primitive === parser_schema_1.PrimitiveType.SINGLE_CHOICE_INTEGER || primitive === parser_schema_1.PrimitiveType.MULTIPLE_CHOICE_INTEGER) {
24
+ return parser_type_system_1.integerType;
25
+ }
26
+ return parser_type_system_1.textType;
27
+ }
28
+ }
29
+ exports.SchemaOptionKeyAttribute = SchemaOptionKeyAttribute;
30
+ //# sourceMappingURL=SchemaOptionKeyAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaOptionKeyAttribute.js","sourceRoot":"","sources":["../../src/attributes/SchemaOptionKeyAttribute.ts"],"names":[],"mappings":";;;AAAA,0DAA6F;AAC7F,wEAA+F;AAC/F,wEAA2F;AAC3F,8DAA2D;AAU3D;;GAEG;AACH,8BAAsC,SAAQ,uBAAkC;IAC9E;QACE,KAAK,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;IAES,cAAc,CAAC,KAA0B;;QACjD,MAAM,KAAK,GAAG,MAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,UAAU,0CAAE,cAAc,CAAC,MAAM,CAA0C,CAAC;QACzG,OAAO,IAAI,6CAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/F,CAAC;IAEO,OAAO,CAAC,SAAkD;QAChE,IAAI,SAAS,KAAK,6BAAa,CAAC,OAAO;YAAE,OAAO,gCAAW,CAAC;QAC5D,IAAI,SAAS,KAAK,6BAAa,CAAC,qBAAqB,IAAI,SAAS,KAAK,6BAAa,CAAC,uBAAuB,EAAE,CAAC;YAC7G,OAAO,gCAAW,CAAC;QACrB,CAAC;QACD,OAAO,6BAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { Attribute, AttributeGenerics, AttributeParseEvent } from '@ja-platform/parser-core';\nimport { ConstantExpression, ConstantExpressionParser } from '@ja-platform/parser-expressions';\nimport { booleanType, integerType, textType, Type } from '@ja-platform/parser-type-system';\nimport { PrimitiveType } from '@ja-platform/parser-schema';\nimport { SchemaFieldTypeExpression } from '../expressions/SchemaFieldTypeExpression';\n\nexport type SchemaOptionKey = string | number | boolean;\n\ninterface SchemaOptionKeyGenerics extends AttributeGenerics {\n Value: ConstantExpression<SchemaOptionKey>;\n NormalizedValue: SchemaOptionKey;\n}\n\n/**\n * Choice keys use the enclosing field's declared literal type.\n */\nexport class SchemaOptionKeyAttribute extends Attribute<SchemaOptionKeyGenerics> {\n constructor() {\n super('schema-option-key', { name: 'key' });\n }\n\n protected getParsedValue(event: AttributeParseEvent): ConstantExpression<SchemaOptionKey> {\n const field = event.context?.parentNode?.attrExpression('type') as SchemaFieldTypeExpression | undefined;\n return new ConstantExpressionParser(this.keyType(field?.primitive)).parse(event.input.value);\n }\n\n private keyType(primitive?: SchemaFieldTypeExpression['primitive']): Type<SchemaOptionKey> {\n if (primitive === PrimitiveType.BOOLEAN) return booleanType;\n if (primitive === PrimitiveType.SINGLE_CHOICE_INTEGER || primitive === PrimitiveType.MULTIPLE_CHOICE_INTEGER) {\n return integerType;\n }\n return textType;\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaDatabasesExpressionParser = exports.SchemaDatabasesExpression = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const parser_schema_1 = require("@ja-platform/parser-schema");
6
+ class SchemaDatabasesExpression extends parser_expressions_1.ListExpression {
7
+ constructor(options) {
8
+ super(options, 'schema-databases');
9
+ }
10
+ isValid() {
11
+ return (super.isValid() &&
12
+ this.items.every((token) => token instanceof parser_expressions_1.IdentifierToken && Object.values(parser_schema_1.IndexDatabase).includes(token.raw())));
13
+ }
14
+ get databases() {
15
+ return this.items.map((token) => token.raw());
16
+ }
17
+ }
18
+ exports.SchemaDatabasesExpression = SchemaDatabasesExpression;
19
+ class SchemaDatabasesExpressionParser extends parser_expressions_1.ListExpressionParser {
20
+ constructor() {
21
+ super({
22
+ parseItem: ({ source, start }) => new parser_expressions_1.IdentifierToken(source, start),
23
+ createExpression: (options) => new SchemaDatabasesExpression(options)
24
+ });
25
+ }
26
+ }
27
+ exports.SchemaDatabasesExpressionParser = SchemaDatabasesExpressionParser;
28
+ //# sourceMappingURL=SchemaDatabasesExpression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaDatabasesExpression.js","sourceRoot":"","sources":["../../src/expressions/SchemaDatabasesExpression.ts"],"names":[],"mappings":";;;AAAA,wEAKyC;AACzC,8DAA2D;AAE3D,+BAAuC,SAAQ,mCAA+B;IAC5E,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACL,OAAO,CACL,KAAK,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,KAAK,CAAC,KAAK,CACd,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,YAAY,oCAAe,IAAI,MAAM,CAAC,MAAM,CAAC,6BAAa,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAmB,CAAC,CAC1G,CACF,CAAC;IACJ,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAmB,CAAC,CAAC;IACjE,CAAC;CACF;;AAED,qCAA6C,SAAQ,yCAA+C;IAClG;QACE,KAAK,CAAC;YACJ,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,oCAAe,CAAC,MAAM,EAAE,KAAK,CAAC;YACpE,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,yBAAyB,CAAC,OAAO,CAAC;SACtE,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import {\n AbstractExpressionOptions,\n ListExpression,\n ListExpressionParser,\n IdentifierToken\n} from '@ja-platform/parser-expressions';\nimport { IndexDatabase } from '@ja-platform/parser-schema';\n\nexport class SchemaDatabasesExpression extends ListExpression<IdentifierToken> {\n constructor(options: AbstractExpressionOptions) {\n super(options, 'schema-databases');\n }\n\n isValid(): boolean {\n return (\n super.isValid() &&\n this.items.every(\n (token) =>\n token instanceof IdentifierToken && Object.values(IndexDatabase).includes(token.raw() as IndexDatabase)\n )\n );\n }\n\n get databases(): readonly IndexDatabase[] {\n return this.items.map((token) => token.raw() as IndexDatabase);\n }\n}\n\nexport class SchemaDatabasesExpressionParser extends ListExpressionParser<SchemaDatabasesExpression> {\n constructor() {\n super({\n parseItem: ({ source, start }) => new IdentifierToken(source, start),\n createExpression: (options) => new SchemaDatabasesExpression(options)\n });\n }\n}\n"]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaFieldTypeExpressionParser = exports.SchemaFieldTypeExpression = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const parser_schema_1 = require("@ja-platform/parser-schema");
6
+ const parser_schema_2 = require("@ja-platform/parser-schema");
7
+ /**
8
+ * A primitive declaration, with an optional prefix introducing its subtype.
9
+ */
10
+ class SchemaFieldTypeExpression extends parser_expressions_1.AbstractExpression {
11
+ constructor(options) {
12
+ super('schema-field-type', options);
13
+ }
14
+ get primitive() {
15
+ const first = this.tokens[0];
16
+ return (first instanceof parser_expressions_1.PrefixToken ? first.raw().slice(0, -1) : first === null || first === void 0 ? void 0 : first.raw());
17
+ }
18
+ get subtype() {
19
+ var _a;
20
+ return this.tokens[0] instanceof parser_expressions_1.PrefixToken ? (_a = this.tokens[1]) === null || _a === void 0 ? void 0 : _a.raw() : undefined;
21
+ }
22
+ isValid() {
23
+ const [first, second] = this.tokens;
24
+ if (first instanceof parser_expressions_1.PrefixToken) {
25
+ return (this.tokens.length === 2 &&
26
+ first.isValid() &&
27
+ first.raw() === 'text:' &&
28
+ second instanceof parser_expressions_1.TextToken &&
29
+ parser_schema_2.TEXT_SUBTYPES.includes(second.raw()));
30
+ }
31
+ return this.tokens.length === 1 && first instanceof parser_expressions_1.TextToken && Object.hasOwn(parser_schema_1.PrimitiveTypeMap, first.raw());
32
+ }
33
+ }
34
+ exports.SchemaFieldTypeExpression = SchemaFieldTypeExpression;
35
+ class SchemaFieldTypeExpressionParser extends parser_expressions_1.ExpressionParser {
36
+ tryParse(source, start = 0) {
37
+ if (typeof source !== 'string')
38
+ return new SchemaFieldTypeExpression({ tokens: source });
39
+ const colon = source.indexOf(':');
40
+ const tokens = colon === -1
41
+ ? [new parser_expressions_1.TextToken(source, start)]
42
+ : [
43
+ new parser_expressions_1.PrefixToken(start, source.slice(0, colon + 1)),
44
+ new parser_expressions_1.TextToken(source.slice(colon + 1), start + colon + 1)
45
+ ];
46
+ return new SchemaFieldTypeExpression({ tokens });
47
+ }
48
+ }
49
+ exports.SchemaFieldTypeExpressionParser = SchemaFieldTypeExpressionParser;
50
+ //# sourceMappingURL=SchemaFieldTypeExpression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaFieldTypeExpression.js","sourceRoot":"","sources":["../../src/expressions/SchemaFieldTypeExpression.ts"],"names":[],"mappings":";;;AAAA,wEAOyC;AACzC,8DAA8D;AAC9D,8DAA2D;AAE3D;;GAEG;AACH,+BAAuC,SAAQ,uCAAkB;IAC/D,YAAY,OAAkC;QAC5C,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,SAAS;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO,CAAC,KAAK,YAAY,gCAAW,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,EAAE,CAAkC,CAAC;IACnH,CAAC;IAED,IAAI,OAAO;;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,gCAAW,CAAC,CAAC,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,0CAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACnF,CAAC;IAED,OAAO;QACL,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,KAAK,YAAY,gCAAW,EAAE,CAAC;YACjC,OAAO,CACL,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;gBACxB,KAAK,CAAC,OAAO,EAAE;gBACf,KAAK,CAAC,GAAG,EAAE,KAAK,OAAO;gBACvB,MAAM,YAAY,8BAAS;gBAC3B,6BAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CACrC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,YAAY,8BAAS,IAAI,MAAM,CAAC,MAAM,CAAC,gCAAgB,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAChH,CAAC;CACF;;AAED,qCAA6C,SAAQ,qCAA2C;IAC9F,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,IAAI,yBAAyB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,MAAM,GACV,KAAK,KAAK,CAAC,CAAC;YACV,CAAC,CAAC,CAAC,IAAI,8BAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC,CAAC;gBACE,IAAI,gCAAW,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBAClD,IAAI,8BAAS,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;aAC1D,CAAC;QACR,OAAO,IAAI,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["import {\n AbstractExpression,\n AbstractExpressionOptions,\n ExpressionParser,\n ExpressionSource,\n PrefixToken,\n TextToken\n} from '@ja-platform/parser-expressions';\nimport { PrimitiveTypeMap } from '@ja-platform/parser-schema';\nimport { TEXT_SUBTYPES } from '@ja-platform/parser-schema';\n\n/**\n * A primitive declaration, with an optional prefix introducing its subtype.\n */\nexport class SchemaFieldTypeExpression extends AbstractExpression {\n constructor(options: AbstractExpressionOptions) {\n super('schema-field-type', options);\n }\n\n get primitive(): keyof typeof PrimitiveTypeMap {\n const first = this.tokens[0];\n return (first instanceof PrefixToken ? first.raw().slice(0, -1) : first?.raw()) as keyof typeof PrimitiveTypeMap;\n }\n\n get subtype(): string | undefined {\n return this.tokens[0] instanceof PrefixToken ? this.tokens[1]?.raw() : undefined;\n }\n\n isValid(): boolean {\n const [first, second] = this.tokens;\n if (first instanceof PrefixToken) {\n return (\n this.tokens.length === 2 &&\n first.isValid() &&\n first.raw() === 'text:' &&\n second instanceof TextToken &&\n TEXT_SUBTYPES.includes(second.raw())\n );\n }\n return this.tokens.length === 1 && first instanceof TextToken && Object.hasOwn(PrimitiveTypeMap, first.raw());\n }\n}\n\nexport class SchemaFieldTypeExpressionParser extends ExpressionParser<SchemaFieldTypeExpression> {\n tryParse(source: ExpressionSource, start = 0): SchemaFieldTypeExpression {\n if (typeof source !== 'string') return new SchemaFieldTypeExpression({ tokens: source });\n const colon = source.indexOf(':');\n const tokens =\n colon === -1\n ? [new TextToken(source, start)]\n : [\n new PrefixToken(start, source.slice(0, colon + 1)),\n new TextToken(source.slice(colon + 1), start + colon + 1)\n ];\n return new SchemaFieldTypeExpression({ tokens });\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaIndexExpressionParser = exports.SchemaIndexExpression = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const SchemaIndexKeyToken_1 = require("../tokens/SchemaIndexKeyToken");
6
+ /**
7
+ * Index field references and their sort directions, derived from the source tokens.
8
+ */
9
+ class SchemaIndexExpression extends parser_expressions_1.ListExpression {
10
+ constructor(options) {
11
+ super(options, 'schema-index');
12
+ }
13
+ isValid() {
14
+ return super.isValid() && this.items.every((token) => token instanceof SchemaIndexKeyToken_1.SchemaIndexKeyToken && token.isValid());
15
+ }
16
+ get keys() {
17
+ return this.items.map((token) => ({ field: token.field, dir: token.direction }));
18
+ }
19
+ }
20
+ exports.SchemaIndexExpression = SchemaIndexExpression;
21
+ class SchemaIndexExpressionParser extends parser_expressions_1.ListExpressionParser {
22
+ constructor() {
23
+ super({
24
+ parseItem: ({ source, start }) => new SchemaIndexKeyToken_1.SchemaIndexKeyToken(source, start),
25
+ createExpression: (options) => new SchemaIndexExpression(options)
26
+ });
27
+ }
28
+ }
29
+ exports.SchemaIndexExpressionParser = SchemaIndexExpressionParser;
30
+ //# sourceMappingURL=SchemaIndexExpression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaIndexExpression.js","sourceRoot":"","sources":["../../src/expressions/SchemaIndexExpression.ts"],"names":[],"mappings":";;;AAAA,wEAAkH;AAElH,uEAAoE;AAEpE;;GAEG;AACH,2BAAmC,SAAQ,mCAAmC;IAC5E,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACjC,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,yCAAmB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACjH,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;CACF;;AAED,iCAAyC,SAAQ,yCAA2C;IAC1F;QACE,KAAK,CAAC;YACJ,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,yCAAmB,CAAC,MAAM,EAAE,KAAK,CAAC;YACxE,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,OAAO,CAAC;SAClE,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { AbstractExpressionOptions, ListExpression, ListExpressionParser } from '@ja-platform/parser-expressions';\nimport { ModelIndexKey } from '@ja-platform/parser-schema';\nimport { SchemaIndexKeyToken } from '../tokens/SchemaIndexKeyToken';\n\n/**\n * Index field references and their sort directions, derived from the source tokens.\n */\nexport class SchemaIndexExpression extends ListExpression<SchemaIndexKeyToken> {\n constructor(options: AbstractExpressionOptions) {\n super(options, 'schema-index');\n }\n\n isValid(): boolean {\n return super.isValid() && this.items.every((token) => token instanceof SchemaIndexKeyToken && token.isValid());\n }\n\n get keys(): readonly ModelIndexKey[] {\n return this.items.map((token) => ({ field: token.field, dir: token.direction }));\n }\n}\n\nexport class SchemaIndexExpressionParser extends ListExpressionParser<SchemaIndexExpression> {\n constructor() {\n super({\n parseItem: ({ source, start }) => new SchemaIndexKeyToken(source, start),\n createExpression: (options) => new SchemaIndexExpression(options)\n });\n }\n}\n"]}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./schemaSerializer"), exports);
18
+ __exportStar(require("./loadSchemaXml"), exports);
19
+ __exportStar(require("./SchemaNode"), exports);
20
+ __exportStar(require("./parsed/ParsedSchemaNode"), exports);
21
+ __exportStar(require("./parsed/ParsedSchemaModelNode"), exports);
22
+ __exportStar(require("./parsed/ParsedSchemaFieldNode"), exports);
23
+ __exportStar(require("./XmlSchema"), exports);
24
+ __exportStar(require("./XmlField"), exports);
25
+ __exportStar(require("./XmlModel"), exports);
26
+ __exportStar(require("./XmlParam"), exports);
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,kDAAgC;AAChC,+CAA6B;AAC7B,4DAA0C;AAC1C,iEAA+C;AAC/C,iEAA+C;AAC/C,8CAA4B;AAC5B,6CAA2B;AAC3B,6CAA2B;AAC3B,6CAA2B","sourcesContent":["export * from './schemaSerializer';\nexport * from './loadSchemaXml';\nexport * from './SchemaNode';\nexport * from './parsed/ParsedSchemaNode';\nexport * from './parsed/ParsedSchemaModelNode';\nexport * from './parsed/ParsedSchemaFieldNode';\nexport * from './XmlSchema';\nexport * from './XmlField';\nexport * from './XmlModel';\nexport * from './XmlParam';\n"]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadSchemaXml = loadSchemaXml;
4
+ const XmlSchema_1 = require("./XmlSchema");
5
+ const domparser_1 = require("@journeyapps/domparser");
6
+ const SchemaNode_1 = require("./SchemaNode");
7
+ const parser_document_xml_1 = require("@ja-platform/parser-document-xml");
8
+ /**
9
+ * Parse schema XML using the node definitions and convert the resulting tree to a schema.
10
+ */
11
+ function loadSchemaXml({ source }) {
12
+ var _a;
13
+ const document = new domparser_1.DOMParser().parseFromString(source, 'text/xml');
14
+ let schema = new XmlSchema_1.XmlSchema();
15
+ schema.errors = ((_a = document.errors) !== null && _a !== void 0 ? _a : []).map((error) => { var _a; return ({
16
+ message: error.message,
17
+ type: 'error',
18
+ source: { range: { start: error.startOffset, end: (_a = error.endOffset) !== null && _a !== void 0 ? _a : error.startOffset } }
19
+ }); });
20
+ if (schema.errors.length)
21
+ return schema;
22
+ const element = document.documentElement;
23
+ const definition = new SchemaNode_1.SchemaNode();
24
+ if ((element === null || element === void 0 ? void 0 : element.tagName) !== definition.name) {
25
+ const diagnostic = {
26
+ message: `<${definition.name}> root tag expected`,
27
+ type: 'error'
28
+ };
29
+ if (element)
30
+ diagnostic.source = new parser_document_xml_1.XMLSourceReference(element, source);
31
+ schema.errors.push(diagnostic);
32
+ return schema;
33
+ }
34
+ const parsed = definition.parseTree({
35
+ input: new parser_document_xml_1.XMLNodeInput(element, source),
36
+ report: (diagnostic) => schema.errors.push(diagnostic)
37
+ });
38
+ schema.parsedNode = parsed;
39
+ if (!schema.errors.some((diagnostic) => diagnostic.type !== 'warning')) {
40
+ const errors = schema.errors;
41
+ schema = parsed.toSchema();
42
+ schema.errors = errors;
43
+ }
44
+ return schema;
45
+ }
46
+ //# sourceMappingURL=loadSchemaXml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadSchemaXml.js","sourceRoot":"","sources":["../src/loadSchemaXml.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,sDAAmD;AACnD,6CAA0C;AAC1C,0EAAoF;AAOpF;;GAEG;AACH,uBAA8B,EAAE,MAAM,EAAwB;;IAC5D,MAAM,QAAQ,GAAG,IAAI,qBAAS,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrE,IAAI,MAAM,GAAG,IAAI,qBAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,MAAM,GAAG,OAAC,QAAQ,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,kBAAC,CAAC;QACtD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,GAAG,QAAE,KAAK,CAAC,SAAS,mCAAI,KAAK,CAAC,WAAW,EAAE,EAAE;KAC3F,CAAC,GAAA,CAAC,CAAC;IACJ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IAExC,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC;IACzC,MAAM,UAAU,GAAG,IAAI,uBAAU,EAAE,CAAC;IACpC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,MAAK,UAAU,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,UAAU,GAAqB;YACnC,OAAO,EAAE,IAAI,UAAU,CAAC,IAAI,qBAAqB;YACjD,IAAI,EAAE,OAAO;SACd,CAAC;QACF,IAAI,OAAO;YAAE,UAAU,CAAC,MAAM,GAAG,IAAI,wCAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC;QAClC,KAAK,EAAE,IAAI,kCAAY,CAAC,OAAO,EAAE,MAAM,CAAC;QACxC,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;KACvD,CAAC,CAAC;IACH,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;IAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,EAAE,CAAC;QACvE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC7B,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { XmlSchema as Schema } from './XmlSchema';\nimport { DOMParser } from '@journeyapps/domparser';\nimport { SchemaNode } from './SchemaNode';\nimport { XMLNodeInput, XMLSourceReference } from '@ja-platform/parser-document-xml';\nimport type { ParsedDiagnostic } from '@ja-platform/parser-core';\n\nexport interface LoadSchemaXmlOptions {\n source: string;\n}\n\n/**\n * Parse schema XML using the node definitions and convert the resulting tree to a schema.\n */\nexport function loadSchemaXml({ source }: LoadSchemaXmlOptions): Schema {\n const document = new DOMParser().parseFromString(source, 'text/xml');\n let schema = new Schema();\n schema.errors = (document.errors ?? []).map((error) => ({\n message: error.message,\n type: 'error',\n source: { range: { start: error.startOffset, end: error.endOffset ?? error.startOffset } }\n }));\n if (schema.errors.length) return schema;\n\n const element = document.documentElement;\n const definition = new SchemaNode();\n if (element?.tagName !== definition.name) {\n const diagnostic: ParsedDiagnostic = {\n message: `<${definition.name}> root tag expected`,\n type: 'error'\n };\n if (element) diagnostic.source = new XMLSourceReference(element, source);\n schema.errors.push(diagnostic);\n return schema;\n }\n\n const parsed = definition.parseTree({\n input: new XMLNodeInput(element, source),\n report: (diagnostic) => schema.errors.push(diagnostic)\n });\n schema.parsedNode = parsed;\n if (!schema.errors.some((diagnostic) => diagnostic.type !== 'warning')) {\n const errors = schema.errors;\n schema = parsed.toSchema();\n schema.errors = errors;\n }\n return schema;\n}\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaBelongsToNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
6
+ class SchemaBelongsToNode extends parser_core_1.Node {
7
+ constructor() {
8
+ super({ name: 'belongs-to', key: 'belongsTo', isMultiple: true });
9
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'name' }));
10
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'model', required: true }));
11
+ }
12
+ }
13
+ exports.SchemaBelongsToNode = SchemaBelongsToNode;
14
+ //# sourceMappingURL=SchemaBelongsToNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaBelongsToNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaBelongsToNode.ts"],"names":[],"mappings":";;;AAAA,0DAA+E;AAE/E,2EAAwE;AAOxE,yBAAiC,SAAQ,kBAAwC;IAC/E;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChF,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\n\nexport interface SchemaBelongsToShape extends ParsedNodeShape {\n name?: ConstantExpression<string>;\n model: ConstantExpression<string>;\n}\n\nexport class SchemaBelongsToNode extends Node<NodeGenerics<SchemaBelongsToShape>> {\n constructor() {\n super({ name: 'belongs-to', key: 'belongsTo', isMultiple: true });\n this.addAttribute(new SchemaNameAttribute({ name: 'name' }));\n this.addAttribute(new SchemaNameAttribute({ name: 'model', required: true }));\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaDisplayNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_schema_1 = require("@ja-platform/parser-schema");
6
+ class SchemaDisplayNode extends parser_core_1.Node {
7
+ constructor() {
8
+ super({ name: 'display', isRequired: true });
9
+ this.addAttribute(new parser_core_1.TextAttribute({
10
+ allowContentFromNode: true,
11
+ name: 'format',
12
+ syntax: new parser_schema_1.SchemaObjectDisplayExpressionParser()
13
+ }));
14
+ }
15
+ }
16
+ exports.SchemaDisplayNode = SchemaDisplayNode;
17
+ //# sourceMappingURL=SchemaDisplayNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaDisplayNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaDisplayNode.ts"],"names":[],"mappings":";;;AAAA,0DAA8F;AAC9F,8DAAgH;AAMhH,uBAA+B,SAAQ,kBAAsC;IAC3E;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,YAAY,CACf,IAAI,2BAAa,CAAC;YAChB,oBAAoB,EAAE,IAAI;YAC1B,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,IAAI,mDAAmC,EAAE;SAClD,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape, TextAttribute } from '@ja-platform/parser-core';\nimport { SchemaObjectDisplayExpression, SchemaObjectDisplayExpressionParser } from '@ja-platform/parser-schema';\n\nexport interface SchemaDisplayShape extends ParsedNodeShape {\n format: SchemaObjectDisplayExpression;\n}\n\nexport class SchemaDisplayNode extends Node<NodeGenerics<SchemaDisplayShape>> {\n constructor() {\n super({ name: 'display', isRequired: true });\n this.addAttribute(\n new TextAttribute({\n allowContentFromNode: true,\n name: 'format',\n syntax: new SchemaObjectDisplayExpressionParser()\n })\n );\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaFieldNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const SchemaFieldTypeAttribute_1 = require("../attributes/SchemaFieldTypeAttribute");
6
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
7
+ const SchemaEnumAttribute_1 = require("../attributes/SchemaEnumAttribute");
8
+ const parser_schema_1 = require("@ja-platform/parser-schema");
9
+ const SchemaOptionNode_1 = require("./SchemaOptionNode");
10
+ const ParsedSchemaFieldNode_1 = require("../parsed/ParsedSchemaFieldNode");
11
+ class SchemaFieldNode extends parser_core_1.Node {
12
+ constructor() {
13
+ super({ name: 'field', key: 'fields', isMultiple: true });
14
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'name', required: true }));
15
+ this.addAttribute(new parser_core_1.ConstantTextAttribute({ name: 'label', required: true }));
16
+ this.addAttribute(new SchemaFieldTypeAttribute_1.SchemaFieldTypeAttribute({ name: 'type', required: true }));
17
+ this.addAttribute(new SchemaEnumAttribute_1.SchemaEnumAttribute({ name: 'media', values: parser_schema_1.ATTACHMENT_MEDIA_TYPES }));
18
+ this.addAttribute(new parser_core_1.ConstantBooleanAttribute({ name: 'auto-download', key: 'autoDownload', defaultValue: false }));
19
+ this.addAttribute(new parser_core_1.ConstantTextAttribute({ name: 'spec', deprecated: true }));
20
+ this.addAttribute(new parser_core_1.ConstantTextAttribute({ name: 'deprecated-spec', key: 'deprecatedSpec', deprecated: true }));
21
+ this.addAttribute(new parser_core_1.ConstantTextAttribute({ name: 'minValue', deprecated: true }));
22
+ this.addAttribute(new parser_core_1.ConstantTextAttribute({ name: 'maxValue', deprecated: true }));
23
+ this.addNode(new SchemaOptionNode_1.SchemaOptionNode());
24
+ }
25
+ createParsedNode(options) {
26
+ return new ParsedSchemaFieldNode_1.ParsedSchemaFieldNode(Object.assign({ definition: this }, options));
27
+ }
28
+ }
29
+ exports.SchemaFieldNode = SchemaFieldNode;
30
+ //# sourceMappingURL=SchemaFieldNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaFieldNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaFieldNode.ts"],"names":[],"mappings":";;;AAAA,0DASkC;AAElC,qFAAkF;AAElF,2EAAwE;AACxE,2EAAwE;AACxE,8DAAoE;AACpE,yDAAyE;AACzE,2EAAwE;AAexE,qBAA6B,SAAQ,kBAA2D;IAC9F;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,mCAAqB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,YAAY,CAAC,IAAI,mDAAwB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,sCAAsB,EAAE,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,YAAY,CACf,IAAI,sCAAwB,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAClG,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,IAAI,mCAAqB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACjF,IAAI,CAAC,YAAY,CAAC,IAAI,mCAAqB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnH,IAAI,CAAC,YAAY,CAAC,IAAI,mCAAqB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACrF,IAAI,CAAC,YAAY,CAAC,IAAI,mCAAqB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACrF,IAAI,CAAC,OAAO,CAAC,IAAI,mCAAgB,EAAE,CAAC,CAAC;IACvC,CAAC;IAES,gBAAgB,CAAC,OAAyB;QAClD,OAAO,IAAI,6CAAqB,iBAAG,UAAU,EAAE,IAAI,IAAK,OAAO,EAAG,CAAC;IACrE,CAAC;CACF","sourcesContent":["import {\n Node,\n NodeGenerics,\n ParsedNodeShape,\n ParsedNode,\n ParsedArrayNode,\n ConstantTextAttribute,\n ConstantBooleanAttribute,\n ParseTreeOptions\n} from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { SchemaFieldTypeAttribute } from '../attributes/SchemaFieldTypeAttribute';\nimport { SchemaFieldTypeExpression } from '../expressions/SchemaFieldTypeExpression';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\nimport { SchemaEnumAttribute } from '../attributes/SchemaEnumAttribute';\nimport { ATTACHMENT_MEDIA_TYPES } from '@ja-platform/parser-schema';\nimport { SchemaOptionNode, SchemaOptionShape } from './SchemaOptionNode';\nimport { ParsedSchemaFieldNode } from '../parsed/ParsedSchemaFieldNode';\n\nexport interface SchemaFieldShape extends ParsedNodeShape {\n name: ConstantExpression<string>;\n label: ConstantExpression<string>;\n type: SchemaFieldTypeExpression;\n media?: ConstantExpression<string>;\n autoDownload?: ConstantExpression<boolean>;\n spec?: ConstantExpression<string>;\n deprecatedSpec?: ConstantExpression<string>;\n minValue?: ConstantExpression<string>;\n maxValue?: ConstantExpression<string>;\n options: ParsedArrayNode<ParsedNode<SchemaOptionShape>>;\n}\n\nexport class SchemaFieldNode extends Node<NodeGenerics<SchemaFieldShape, ParsedSchemaFieldNode>> {\n constructor() {\n super({ name: 'field', key: 'fields', isMultiple: true });\n this.addAttribute(new SchemaNameAttribute({ name: 'name', required: true }));\n this.addAttribute(new ConstantTextAttribute({ name: 'label', required: true }));\n this.addAttribute(new SchemaFieldTypeAttribute({ name: 'type', required: true }));\n this.addAttribute(new SchemaEnumAttribute({ name: 'media', values: ATTACHMENT_MEDIA_TYPES }));\n this.addAttribute(\n new ConstantBooleanAttribute({ name: 'auto-download', key: 'autoDownload', defaultValue: false })\n );\n this.addAttribute(new ConstantTextAttribute({ name: 'spec', deprecated: true }));\n this.addAttribute(new ConstantTextAttribute({ name: 'deprecated-spec', key: 'deprecatedSpec', deprecated: true }));\n this.addAttribute(new ConstantTextAttribute({ name: 'minValue', deprecated: true }));\n this.addAttribute(new ConstantTextAttribute({ name: 'maxValue', deprecated: true }));\n this.addNode(new SchemaOptionNode());\n }\n\n protected createParsedNode(options: ParseTreeOptions): ParsedSchemaFieldNode {\n return new ParsedSchemaFieldNode({ definition: this, ...options });\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaHasManyNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
6
+ class SchemaHasManyNode extends parser_core_1.Node {
7
+ constructor() {
8
+ super({ name: 'has-many', key: 'hasMany', isMultiple: true });
9
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'name', required: true }));
10
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'model', required: true }));
11
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'inverse-of', key: 'inverseOf' }));
12
+ }
13
+ }
14
+ exports.SchemaHasManyNode = SchemaHasManyNode;
15
+ //# sourceMappingURL=SchemaHasManyNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaHasManyNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaHasManyNode.ts"],"names":[],"mappings":";;;AAAA,0DAA+E;AAE/E,2EAAwE;AAQxE,uBAA+B,SAAQ,kBAAsC;IAC3E;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9E,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IACvF,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\n\nexport interface SchemaHasManyShape extends ParsedNodeShape {\n name: ConstantExpression<string>;\n model: ConstantExpression<string>;\n inverseOf?: ConstantExpression<string>;\n}\n\nexport class SchemaHasManyNode extends Node<NodeGenerics<SchemaHasManyShape>> {\n constructor() {\n super({ name: 'has-many', key: 'hasMany', isMultiple: true });\n this.addAttribute(new SchemaNameAttribute({ name: 'name', required: true }));\n this.addAttribute(new SchemaNameAttribute({ name: 'model', required: true }));\n this.addAttribute(new SchemaNameAttribute({ name: 'inverse-of', key: 'inverseOf' }));\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaIndexNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_schema_1 = require("@ja-platform/parser-schema");
6
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
7
+ const SchemaIndexAttribute_1 = require("../attributes/SchemaIndexAttribute");
8
+ const SchemaDatabaseAttribute_1 = require("../attributes/SchemaDatabaseAttribute");
9
+ class SchemaIndexNode extends parser_core_1.Node {
10
+ constructor() {
11
+ super({ name: 'index', key: 'indexes', isMultiple: true });
12
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'name' }));
13
+ this.addAttribute(new SchemaIndexAttribute_1.SchemaIndexAttribute({ name: 'on', key: 'keys', required: true }));
14
+ this.addAttribute(new SchemaDatabaseAttribute_1.SchemaDatabaseAttribute({
15
+ name: 'database',
16
+ key: 'databases',
17
+ defaultValue: [parser_schema_1.IndexDatabase.APP, parser_schema_1.IndexDatabase.CLOUD]
18
+ }));
19
+ }
20
+ }
21
+ exports.SchemaIndexNode = SchemaIndexNode;
22
+ //# sourceMappingURL=SchemaIndexNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaIndexNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaIndexNode.ts"],"names":[],"mappings":";;;AAAA,0DAA+E;AAE/E,8DAA2D;AAG3D,2EAAwE;AACxE,6EAA0E;AAC1E,mFAAgF;AAQhF,qBAA6B,SAAQ,kBAAoC;IACvE;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,CAAC,IAAI,2CAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACzF,IAAI,CAAC,YAAY,CACf,IAAI,iDAAuB,CAAC;YAC1B,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,WAAW;YAChB,YAAY,EAAE,CAAC,6BAAa,CAAC,GAAG,EAAE,6BAAa,CAAC,KAAK,CAAC;SACvD,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { IndexDatabase } from '@ja-platform/parser-schema';\nimport { SchemaIndexExpression } from '../expressions/SchemaIndexExpression';\nimport { SchemaDatabasesExpression } from '../expressions/SchemaDatabasesExpression';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\nimport { SchemaIndexAttribute } from '../attributes/SchemaIndexAttribute';\nimport { SchemaDatabaseAttribute } from '../attributes/SchemaDatabaseAttribute';\n\nexport interface SchemaIndexShape extends ParsedNodeShape {\n name?: ConstantExpression<string>;\n keys: SchemaIndexExpression;\n databases?: SchemaDatabasesExpression;\n}\n\nexport class SchemaIndexNode extends Node<NodeGenerics<SchemaIndexShape>> {\n constructor() {\n super({ name: 'index', key: 'indexes', isMultiple: true });\n this.addAttribute(new SchemaNameAttribute({ name: 'name' }));\n this.addAttribute(new SchemaIndexAttribute({ name: 'on', key: 'keys', required: true }));\n this.addAttribute(\n new SchemaDatabaseAttribute({\n name: 'database',\n key: 'databases',\n defaultValue: [IndexDatabase.APP, IndexDatabase.CLOUD]\n })\n );\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaModelNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
6
+ const SchemaEnumAttribute_1 = require("../attributes/SchemaEnumAttribute");
7
+ const SchemaFieldNode_1 = require("./SchemaFieldNode");
8
+ const ParsedSchemaModelNode_1 = require("../parsed/ParsedSchemaModelNode");
9
+ const SchemaBelongsToNode_1 = require("./SchemaBelongsToNode");
10
+ const SchemaHasManyNode_1 = require("./SchemaHasManyNode");
11
+ const SchemaIndexNode_1 = require("./SchemaIndexNode");
12
+ const SchemaDisplayNode_1 = require("./SchemaDisplayNode");
13
+ const SchemaNotificationNode_1 = require("./SchemaNotificationNode");
14
+ const SchemaWebhookNode_1 = require("./SchemaWebhookNode");
15
+ class SchemaModelNode extends parser_core_1.Node {
16
+ constructor() {
17
+ super({ name: 'model', key: 'models', isMultiple: true });
18
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'name', required: true }));
19
+ this.addAttribute(new parser_core_1.ConstantTextAttribute({ name: 'label', required: true }));
20
+ this.addAttribute(new SchemaEnumAttribute_1.SchemaEnumAttribute({ name: 'classification', values: ['standard', 'sensitive'] }));
21
+ this.addNode(new SchemaFieldNode_1.SchemaFieldNode());
22
+ this.addNode(new SchemaBelongsToNode_1.SchemaBelongsToNode());
23
+ this.addNode(new SchemaHasManyNode_1.SchemaHasManyNode());
24
+ this.addNode(new SchemaIndexNode_1.SchemaIndexNode());
25
+ this.addNode(new SchemaDisplayNode_1.SchemaDisplayNode());
26
+ this.addNode(new SchemaNotificationNode_1.SchemaNotificationNode());
27
+ this.addNode(new SchemaWebhookNode_1.SchemaWebhookNode());
28
+ }
29
+ createParsedNode(options) {
30
+ return new ParsedSchemaModelNode_1.ParsedSchemaModelNode(Object.assign({ definition: this }, options));
31
+ }
32
+ }
33
+ exports.SchemaModelNode = SchemaModelNode;
34
+ //# sourceMappingURL=SchemaModelNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaModelNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaModelNode.ts"],"names":[],"mappings":";;;AAAA,0DAQkC;AAElC,2EAAwE;AACxE,2EAAwE;AACxE,uDAAoD;AAEpD,2EAAwE;AACxE,+DAAkF;AAClF,2DAA4E;AAC5E,uDAAsE;AACtE,2DAA4E;AAC5E,qEAA2F;AAC3F,2DAA4E;AAe5E,qBAA6B,SAAQ,kBAA2D;IAC9F;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,mCAAqB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1G,IAAI,CAAC,OAAO,CAAC,IAAI,iCAAe,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,CAAC,IAAI,yCAAmB,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,IAAI,qCAAiB,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,iCAAe,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,CAAC,IAAI,qCAAiB,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,+CAAsB,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,qCAAiB,EAAE,CAAC,CAAC;IACxC,CAAC;IAES,gBAAgB,CAAC,OAAyB;QAClD,OAAO,IAAI,6CAAqB,iBAAG,UAAU,EAAE,IAAI,IAAK,OAAO,EAAG,CAAC;IACrE,CAAC;CACF","sourcesContent":["import {\n Node,\n NodeGenerics,\n ParsedNodeShape,\n ParsedNode,\n ParsedArrayNode,\n ConstantTextAttribute,\n ParseTreeOptions\n} from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\nimport { SchemaEnumAttribute } from '../attributes/SchemaEnumAttribute';\nimport { SchemaFieldNode } from './SchemaFieldNode';\nimport { ParsedSchemaFieldNode } from '../parsed/ParsedSchemaFieldNode';\nimport { ParsedSchemaModelNode } from '../parsed/ParsedSchemaModelNode';\nimport { SchemaBelongsToNode, SchemaBelongsToShape } from './SchemaBelongsToNode';\nimport { SchemaHasManyNode, SchemaHasManyShape } from './SchemaHasManyNode';\nimport { SchemaIndexNode, SchemaIndexShape } from './SchemaIndexNode';\nimport { SchemaDisplayNode, SchemaDisplayShape } from './SchemaDisplayNode';\nimport { SchemaNotificationNode, SchemaNotificationShape } from './SchemaNotificationNode';\nimport { SchemaWebhookNode, SchemaWebhookShape } from './SchemaWebhookNode';\n\nexport interface SchemaModelShape extends ParsedNodeShape {\n name: ConstantExpression<string>;\n label: ConstantExpression<string>;\n classification?: ConstantExpression<string>;\n fields: ParsedArrayNode<ParsedSchemaFieldNode>;\n belongsTo: ParsedArrayNode<ParsedNode<SchemaBelongsToShape>>;\n hasMany: ParsedArrayNode<ParsedNode<SchemaHasManyShape>>;\n indexes: ParsedArrayNode<ParsedNode<SchemaIndexShape>>;\n display?: ParsedNode<SchemaDisplayShape>;\n notifications: ParsedArrayNode<ParsedNode<SchemaNotificationShape>>;\n webhooks: ParsedArrayNode<ParsedNode<SchemaWebhookShape>>;\n}\n\nexport class SchemaModelNode extends Node<NodeGenerics<SchemaModelShape, ParsedSchemaModelNode>> {\n constructor() {\n super({ name: 'model', key: 'models', isMultiple: true });\n this.addAttribute(new SchemaNameAttribute({ name: 'name', required: true }));\n this.addAttribute(new ConstantTextAttribute({ name: 'label', required: true }));\n this.addAttribute(new SchemaEnumAttribute({ name: 'classification', values: ['standard', 'sensitive'] }));\n this.addNode(new SchemaFieldNode());\n this.addNode(new SchemaBelongsToNode());\n this.addNode(new SchemaHasManyNode());\n this.addNode(new SchemaIndexNode());\n this.addNode(new SchemaDisplayNode());\n this.addNode(new SchemaNotificationNode());\n this.addNode(new SchemaWebhookNode());\n }\n\n protected createParsedNode(options: ParseTreeOptions): ParsedSchemaModelNode {\n return new ParsedSchemaModelNode({ definition: this, ...options });\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaNotificationNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_schema_1 = require("@ja-platform/parser-schema");
6
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
7
+ class SchemaNotificationNode extends parser_core_1.Node {
8
+ constructor() {
9
+ super({ name: 'notify-user', key: 'notifications', isMultiple: true });
10
+ this.addAttribute(new parser_core_1.Attribute('schema-notification-message', {
11
+ name: 'message',
12
+ required: true,
13
+ syntax: new parser_schema_1.SchemaObjectDisplayExpressionParser()
14
+ }));
15
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'received-field', key: 'received', required: true }));
16
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'recipient-field', key: 'recipient', required: true }));
17
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'badge-count-field', key: 'badgeCount' }));
18
+ }
19
+ }
20
+ exports.SchemaNotificationNode = SchemaNotificationNode;
21
+ //# sourceMappingURL=SchemaNotificationNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaNotificationNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaNotificationNode.ts"],"names":[],"mappings":";;;AAAA,0DAA0F;AAE1F,8DAAgH;AAChH,2EAAwE;AASxE,4BAAoC,SAAQ,kBAA2C;IACrF;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,YAAY,CACf,IAAI,uBAAS,CAAC,6BAA6B,EAAE;YAC3C,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI,mDAAmC,EAAE;SAClD,CAAC,CACH,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACxG,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1G,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape, Attribute } from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { SchemaObjectDisplayExpression, SchemaObjectDisplayExpressionParser } from '@ja-platform/parser-schema';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\n\nexport interface SchemaNotificationShape extends ParsedNodeShape {\n message: SchemaObjectDisplayExpression;\n received: ConstantExpression<string>;\n recipient: ConstantExpression<string>;\n badgeCount?: ConstantExpression<string>;\n}\n\nexport class SchemaNotificationNode extends Node<NodeGenerics<SchemaNotificationShape>> {\n constructor() {\n super({ name: 'notify-user', key: 'notifications', isMultiple: true });\n this.addAttribute(\n new Attribute('schema-notification-message', {\n name: 'message',\n required: true,\n syntax: new SchemaObjectDisplayExpressionParser()\n })\n );\n this.addAttribute(new SchemaNameAttribute({ name: 'received-field', key: 'received', required: true }));\n this.addAttribute(new SchemaNameAttribute({ name: 'recipient-field', key: 'recipient', required: true }));\n this.addAttribute(new SchemaNameAttribute({ name: 'badge-count-field', key: 'badgeCount' }));\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaOptionNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
6
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
7
+ const SchemaOptionKeyAttribute_1 = require("../attributes/SchemaOptionKeyAttribute");
8
+ class SchemaOptionNode extends parser_core_1.Node {
9
+ constructor() {
10
+ super({ name: 'option', key: 'options', isMultiple: true });
11
+ this.addAttribute(new SchemaOptionKeyAttribute_1.SchemaOptionKeyAttribute());
12
+ this.addAttribute(new parser_core_1.ContentValueAttribute('schema-option-label', {
13
+ name: 'label',
14
+ valueType: parser_type_system_1.textType,
15
+ syntax: new parser_expressions_1.ConstantExpressionParser(parser_type_system_1.textType)
16
+ }));
17
+ }
18
+ }
19
+ exports.SchemaOptionNode = SchemaOptionNode;
20
+ //# sourceMappingURL=SchemaOptionNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaOptionNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaOptionNode.ts"],"names":[],"mappings":";;;AAAA,0DAAsG;AACtG,wEAA+F;AAC/F,wEAA2D;AAC3D,qFAAmG;AAOnG,sBAA8B,SAAQ,kBAAqC;IACzE;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,CAAC,IAAI,mDAAwB,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,CACf,IAAI,mCAAqB,CAAC,qBAAqB,EAAE;YAC/C,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,6BAAQ;YACnB,MAAM,EAAE,IAAI,6CAAwB,CAAC,6BAAQ,CAAC;SAC/C,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape, ContentValueAttribute } from '@ja-platform/parser-core';\nimport { ConstantExpression, ConstantExpressionParser } from '@ja-platform/parser-expressions';\nimport { textType } from '@ja-platform/parser-type-system';\nimport { SchemaOptionKey, SchemaOptionKeyAttribute } from '../attributes/SchemaOptionKeyAttribute';\n\nexport interface SchemaOptionShape extends ParsedNodeShape {\n key?: ConstantExpression<SchemaOptionKey>;\n label: ConstantExpression<string>;\n}\n\nexport class SchemaOptionNode extends Node<NodeGenerics<SchemaOptionShape>> {\n constructor() {\n super({ name: 'option', key: 'options', isMultiple: true });\n this.addAttribute(new SchemaOptionKeyAttribute());\n this.addAttribute(\n new ContentValueAttribute('schema-option-label', {\n name: 'label',\n valueType: textType,\n syntax: new ConstantExpressionParser(textType)\n })\n );\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaWebhookFieldNode = void 0;
4
+ const parser_core_1 = require("@ja-platform/parser-core");
5
+ const parser_schema_1 = require("@ja-platform/parser-schema");
6
+ const SchemaNameAttribute_1 = require("../attributes/SchemaNameAttribute");
7
+ const SchemaEnumAttribute_1 = require("../attributes/SchemaEnumAttribute");
8
+ class SchemaWebhookFieldNode extends parser_core_1.Node {
9
+ constructor() {
10
+ super({ name: 'field', key: 'fields', isMultiple: true });
11
+ this.addAttribute(new SchemaNameAttribute_1.SchemaNameAttribute({ name: 'name', required: true }));
12
+ this.addAttribute(new parser_core_1.ConstantBooleanAttribute({ name: 'required', defaultValue: true }));
13
+ this.addAttribute(new parser_core_1.ConstantBooleanAttribute({ name: 'embed', defaultValue: true }));
14
+ this.addAttribute(new SchemaEnumAttribute_1.SchemaEnumAttribute({
15
+ name: 'state',
16
+ values: Object.values(parser_schema_1.WebhookFieldState),
17
+ defaultValue: parser_schema_1.WebhookFieldState.PRESENT
18
+ }));
19
+ }
20
+ }
21
+ exports.SchemaWebhookFieldNode = SchemaWebhookFieldNode;
22
+ //# sourceMappingURL=SchemaWebhookFieldNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaWebhookFieldNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaWebhookFieldNode.ts"],"names":[],"mappings":";;;AAAA,0DAAyG;AAEzG,8DAA+D;AAC/D,2EAAwE;AACxE,2EAAwE;AASxE,4BAAoC,SAAQ,kBAA2C;IACrF;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,CAAC,IAAI,yCAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,sCAAwB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,YAAY,CAAC,IAAI,sCAAwB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACvF,IAAI,CAAC,YAAY,CACf,IAAI,yCAAmB,CAAC;YACtB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,iCAAiB,CAAC;YACxC,YAAY,EAAE,iCAAiB,CAAC,OAAO;SACxC,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape, ConstantBooleanAttribute } from '@ja-platform/parser-core';\nimport { ConstantExpression } from '@ja-platform/parser-expressions';\nimport { WebhookFieldState } from '@ja-platform/parser-schema';\nimport { SchemaNameAttribute } from '../attributes/SchemaNameAttribute';\nimport { SchemaEnumAttribute } from '../attributes/SchemaEnumAttribute';\n\nexport interface SchemaWebhookFieldShape extends ParsedNodeShape {\n name: ConstantExpression<string>;\n required?: ConstantExpression<boolean>;\n embed?: ConstantExpression<boolean>;\n state?: ConstantExpression<WebhookFieldState>;\n}\n\nexport class SchemaWebhookFieldNode extends Node<NodeGenerics<SchemaWebhookFieldShape>> {\n constructor() {\n super({ name: 'field', key: 'fields', isMultiple: true });\n this.addAttribute(new SchemaNameAttribute({ name: 'name', required: true }));\n this.addAttribute(new ConstantBooleanAttribute({ name: 'required', defaultValue: true }));\n this.addAttribute(new ConstantBooleanAttribute({ name: 'embed', defaultValue: true }));\n this.addAttribute(\n new SchemaEnumAttribute({\n name: 'state',\n values: Object.values(WebhookFieldState),\n defaultValue: WebhookFieldState.PRESENT\n })\n );\n }\n}\n"]}