@aventara/core 1.0.0-rc.12 → 1.0.0-rc.14

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 (66) hide show
  1. package/CHANGELOG.md +152 -1
  2. package/ERRORS.md +7 -6
  3. package/README.md +3 -2
  4. package/dist/avz/avz-check.factory.d.ts +2 -0
  5. package/dist/avz/avz-check.factory.js +12 -0
  6. package/dist/avz/avz.d.ts +6 -0
  7. package/dist/avz/avz.js +1 -0
  8. package/dist/compiler/contract-compiler-diagnostic.d.ts +10 -0
  9. package/dist/compiler/contract-compiler-diagnostic.guidance.js +5 -0
  10. package/dist/compiler/contract.compiler.js +102 -12
  11. package/dist/compiler/create-requirements.projector.d.ts +45 -3
  12. package/dist/compiler/create-requirements.projector.js +239 -28
  13. package/dist/compiler/managed-elsewhere.projector.d.ts +3 -0
  14. package/dist/compiler/managed-elsewhere.projector.js +1 -1
  15. package/dist/config/computed-fields.d.ts +8 -0
  16. package/dist/config/computed-fields.js +1 -1
  17. package/dist/config/config-diagnostic.guidance.js +2 -2
  18. package/dist/config/config.resolver.d.ts +2 -2
  19. package/dist/config/config.validator.js +15 -6
  20. package/dist/config/exact-framework-config.d.ts +1 -0
  21. package/dist/config/field-pipeline-config.d.ts +2 -2
  22. package/dist/config/forced-operation.validator.js +3 -2
  23. package/dist/config/framework-config.d.ts +8 -3
  24. package/dist/config/framework-exemptions-config.d.ts +13 -8
  25. package/dist/config/framework-resources-config.d.ts +11 -3
  26. package/dist/contracts/client-contract-structure.validator.d.ts +4 -1
  27. package/dist/contracts/client-contract-structure.validator.js +3 -2
  28. package/dist/contracts/contract-limits.d.ts +8 -1
  29. package/dist/contracts/contract-limits.js +1 -0
  30. package/dist/contracts/contract.d.ts +7 -3
  31. package/dist/contracts/transaction-capability.d.ts +8 -0
  32. package/dist/contracts/transaction-capability.js +7 -0
  33. package/dist/framework/access-facade.js +14 -6
  34. package/dist/framework/contract-view.d.ts +91 -9
  35. package/dist/framework/operation-facade.d.ts +8 -3
  36. package/dist/internal.d.ts +1 -0
  37. package/dist/internal.js +1 -0
  38. package/dist/operations/validation-code.guidance.js +1 -1
  39. package/dist/policy/access-provider.interface.d.ts +7 -2
  40. package/dist/policy/access-question.runtime.js +2 -1
  41. package/dist/prebuilt/core-version.generated.d.ts +1 -1
  42. package/dist/prebuilt/core-version.generated.js +1 -1
  43. package/dist/protocol/absent-route.responder.d.ts +2 -2
  44. package/dist/protocol/absent-route.responder.js +2 -1
  45. package/dist/protocol/av-protocol.d.ts +1 -0
  46. package/dist/protocol/av-protocol.js +1 -0
  47. package/dist/protocol/protocol-surface.js +2 -1
  48. package/dist/protocol/protocol.handler.js +3 -1
  49. package/dist/runtime/context-executor.runtime.js +2 -1
  50. package/dist/runtime/create-requirement.d.ts +5 -1
  51. package/dist/runtime/create-requirement.js +10 -2
  52. package/dist/runtime/field-check.evaluator.js +39 -2
  53. package/dist/runtime/field-validator.runtime.d.ts +4 -3
  54. package/dist/runtime/field-validator.runtime.js +29 -0
  55. package/dist/runtime/mutation-planner.js +26 -9
  56. package/dist/runtime/operation-code.guidance.js +3 -3
  57. package/dist/runtime/operation-runtime.d.ts +10 -9
  58. package/dist/runtime/operation-runtime.js +20 -18
  59. package/dist/runtime/pipeline.d.ts +1 -15
  60. package/dist/runtime/state-refusal.mapper.d.ts +16 -0
  61. package/dist/runtime/state-refusal.mapper.js +40 -0
  62. package/dist/transactions/operation-fingerprint.d.ts +15 -2
  63. package/dist/transactions/transaction-plan-validator.js +31 -1
  64. package/dist/transactions/transaction-runtime.js +1 -1
  65. package/package.json +1 -1
  66. package/src/runtime/field-check.evaluator.ts +46 -2
@@ -579,10 +579,54 @@ function plural(count: number, one: string, many: string): string {
579
579
  return `${count} ${count === 1 ? one : many}`;
580
580
  }
581
581
 
582
+ /** The characters a pattern reads as syntax: `AvZ.oneOf` escapes each in a value. */
583
+ const PATTERN_SYNTAX = "\\^$.*+?()[]{}|/";
584
+
585
+ // Source: rc.13 (CORE-08). `AvZ.oneOf` writes its values as `^(?:a|b)$`, each
586
+ // syntax character escaped, no flags: read back exactly, that form lists them.
587
+ // Any other pattern (an unescaped syntax character, a flag) lists nothing.
588
+ /** The values an `AvZ.oneOf` pattern lists, or `undefined` for any other pattern. */
589
+ function listedValues(pattern: {
590
+ readonly source: string;
591
+ readonly flags: string;
592
+ }): readonly string[] | undefined {
593
+ const { source, flags } = pattern;
594
+ if (flags !== "" || !source.startsWith("^(?:") || !source.endsWith(")$")) {
595
+ return undefined;
596
+ }
597
+ const body = source.slice(4, -2);
598
+ const values: string[] = [];
599
+ let value = "";
600
+ for (let index = 0; index < body.length; index += 1) {
601
+ const character = body.charAt(index);
602
+ if (character === "\\") {
603
+ const escaped = body.charAt(index + 1);
604
+ if (escaped === "" || !PATTERN_SYNTAX.includes(escaped)) {
605
+ return undefined;
606
+ }
607
+ value += escaped;
608
+ index += 1;
609
+ } else if (character === "|") {
610
+ values.push(value);
611
+ value = "";
612
+ } else if (PATTERN_SYNTAX.includes(character)) {
613
+ return undefined;
614
+ } else {
615
+ value += character;
616
+ }
617
+ }
618
+ values.push(value);
619
+ return values;
620
+ }
621
+
582
622
  function formatMessage(check: AvFieldFormatCheck): string {
583
623
  switch (check.format) {
584
- case "regex":
585
- return `Value must match the pattern /${check.pattern.source}/${check.pattern.flags}.`;
624
+ case "regex": {
625
+ const listed = listedValues(check.pattern);
626
+ return listed === undefined
627
+ ? `Value must match the pattern /${check.pattern.source}/${check.pattern.flags}.`
628
+ : `Value must be one of ${listed.map((value) => JSON.stringify(value)).join(", ")}.`;
629
+ }
586
630
  case "includes":
587
631
  return `Value must include ${JSON.stringify(check.includes)}.`;
588
632
  case "starts_with":