morphir 0.0.1__py3-none-any.whl

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 (95) hide show
  1. morphir/__init__.py +14 -0
  2. morphir/ir/__init__.py +110 -0
  3. morphir/ir/access_controlled.py +15 -0
  4. morphir/ir/decorations.py +19 -0
  5. morphir/ir/diagnostics.py +105 -0
  6. morphir/ir/distribution.py +21 -0
  7. morphir/ir/document.py +37 -0
  8. morphir/ir/documented.py +11 -0
  9. morphir/ir/format_version.py +483 -0
  10. morphir/ir/fqname.py +9 -0
  11. morphir/ir/json.py +11 -0
  12. morphir/ir/literal.py +25 -0
  13. morphir/ir/meta.py +11 -0
  14. morphir/ir/migrate.py +1267 -0
  15. morphir/ir/module.py +17 -0
  16. morphir/ir/name.py +27 -0
  17. morphir/ir/package.py +15 -0
  18. morphir/ir/path.py +25 -0
  19. morphir/ir/qname.py +9 -0
  20. morphir/ir/ref.py +17 -0
  21. morphir/ir/type.py +37 -0
  22. morphir/ir/type_constraints.py +33 -0
  23. morphir/ir/type_def.py +19 -0
  24. morphir/ir/type_spec.py +25 -0
  25. morphir/ir/v3/__init__.py +64 -0
  26. morphir/ir/v3/_legacy_value.py +201 -0
  27. morphir/ir/v3/access_controlled.py +31 -0
  28. morphir/ir/v3/codec.py +1275 -0
  29. morphir/ir/v3/codec_v1.py +491 -0
  30. morphir/ir/v3/codec_v2.py +187 -0
  31. morphir/ir/v3/distribution.py +42 -0
  32. morphir/ir/v3/documented.py +13 -0
  33. morphir/ir/v3/fqname.py +30 -0
  34. morphir/ir/v3/literal.py +46 -0
  35. morphir/ir/v3/module.py +32 -0
  36. morphir/ir/v3/name.py +42 -0
  37. morphir/ir/v3/package.py +23 -0
  38. morphir/ir/v3/path.py +29 -0
  39. morphir/ir/v3/qname.py +16 -0
  40. morphir/ir/v3/type.py +126 -0
  41. morphir/ir/v3/value.py +235 -0
  42. morphir/ir/v4/__init__.py +160 -0
  43. morphir/ir/v4/access_controlled.py +17 -0
  44. morphir/ir/v4/annotation.py +75 -0
  45. morphir/ir/v4/codec.py +2161 -0
  46. morphir/ir/v4/decorations.py +88 -0
  47. morphir/ir/v4/distribution.py +56 -0
  48. morphir/ir/v4/document.py +69 -0
  49. morphir/ir/v4/documented.py +10 -0
  50. morphir/ir/v4/fqname.py +69 -0
  51. morphir/ir/v4/incompleteness.py +78 -0
  52. morphir/ir/v4/json.py +103 -0
  53. morphir/ir/v4/literal.py +51 -0
  54. morphir/ir/v4/meta.py +27 -0
  55. morphir/ir/v4/module.py +30 -0
  56. morphir/ir/v4/name.py +69 -0
  57. morphir/ir/v4/package.py +19 -0
  58. morphir/ir/v4/path.py +50 -0
  59. morphir/ir/v4/qname.py +34 -0
  60. morphir/ir/v4/ref.py +35 -0
  61. morphir/ir/v4/type.py +140 -0
  62. morphir/ir/v4/type_constraints.py +91 -0
  63. morphir/ir/v4/type_def.py +38 -0
  64. morphir/ir/v4/type_spec.py +64 -0
  65. morphir/ir/v4/value.py +480 -0
  66. morphir/ir/value.py +81 -0
  67. morphir/py.typed +0 -0
  68. morphir/sdk/__init__.py +110 -0
  69. morphir/sdk/_compare.py +187 -0
  70. morphir/sdk/aggregate.py +421 -0
  71. morphir/sdk/basics.py +504 -0
  72. morphir/sdk/char.py +110 -0
  73. morphir/sdk/decimal.py +311 -0
  74. morphir/sdk/dict.py +336 -0
  75. morphir/sdk/instant.py +118 -0
  76. morphir/sdk/int.py +86 -0
  77. morphir/sdk/key.py +522 -0
  78. morphir/sdk/list.py +356 -0
  79. morphir/sdk/local_date.py +436 -0
  80. morphir/sdk/local_time.py +267 -0
  81. morphir/sdk/maybe.py +135 -0
  82. morphir/sdk/number.py +237 -0
  83. morphir/sdk/regex.py +287 -0
  84. morphir/sdk/result.py +162 -0
  85. morphir/sdk/result_list.py +169 -0
  86. morphir/sdk/rule.py +103 -0
  87. morphir/sdk/set.py +214 -0
  88. morphir/sdk/stateful_app.py +49 -0
  89. morphir/sdk/string.py +427 -0
  90. morphir/sdk/tuple.py +43 -0
  91. morphir/sdk/uuid.py +209 -0
  92. morphir-0.0.1.dist-info/METADATA +411 -0
  93. morphir-0.0.1.dist-info/RECORD +95 -0
  94. morphir-0.0.1.dist-info/WHEEL +4 -0
  95. morphir-0.0.1.dist-info/licenses/LICENSE +201 -0
morphir/__init__.py ADDED
@@ -0,0 +1,14 @@
1
+ """Morphir - Functional domain modeling for Python.
2
+
3
+ Morphir enables you to write business logic once and use it across multiple
4
+ platforms, languages, and runtimes. It provides a strongly-typed intermediate
5
+ representation (IR) that captures the semantics of your domain model.
6
+
7
+ Example:
8
+ >>> import morphir
9
+ >>> morphir.__version__
10
+ '0.0.1'
11
+ """
12
+
13
+ __version__ = "0.0.1"
14
+ __all__ = ["__version__"]
morphir/ir/__init__.py ADDED
@@ -0,0 +1,110 @@
1
+ """Morphir IR.
2
+
3
+ The default model is IR v4 (`morphir.ir.v4`); every name here is the same object
4
+ as its `morphir.ir.v4` counterpart. Format 3.0.0 lives in `morphir.ir.v3`.
5
+ """
6
+
7
+ from . import module, package
8
+ from .v4.access_controlled import AccessControlled
9
+ from .v4.decorations import (
10
+ DecorationFormat,
11
+ DecorationValuesFile,
12
+ LayerManifest,
13
+ SchemaRef,
14
+ )
15
+ from .v4.distribution import (
16
+ ApplicationDistribution,
17
+ Distribution,
18
+ EntryPoint,
19
+ EntryPointKind,
20
+ LibraryDistribution,
21
+ PackageInfo,
22
+ SpecsDistribution,
23
+ )
24
+ from .v4.document import (
25
+ DocArray,
26
+ DocBool,
27
+ DocFloat,
28
+ DocInt,
29
+ DocNull,
30
+ DocObject,
31
+ DocString,
32
+ Document,
33
+ )
34
+ from .v4.documented import Documented
35
+ from .v4.fqname import FQName
36
+ from .v4.literal import (
37
+ BoolLiteral,
38
+ CharLiteral,
39
+ DecimalLiteral,
40
+ FloatLiteral,
41
+ IntegerLiteral,
42
+ Literal,
43
+ StringLiteral,
44
+ )
45
+ from .v4.meta import FileMeta, SourceRange
46
+ from .v4.name import Name
47
+ from .v4.path import Path
48
+ from .v4.qname import QName
49
+ from .v4.ref import DefRef, FileWithDefs, PointerRef, Ref
50
+ from .v4.type import Field, Type, TypeAttributes
51
+ from .v4.type_constraints import TypeConstraints
52
+ from .v4.type_def import Definition as TypeDefinition
53
+ from .v4.type_spec import Specification as TypeSpecification
54
+ from .v4.value import Definition as ValueDefinition
55
+ from .v4.value import Pattern, Value, ValueAttributes
56
+ from .v4.value import Specification as ValueSpecification
57
+
58
+ __all__ = [
59
+ "AccessControlled",
60
+ "ApplicationDistribution",
61
+ "BoolLiteral",
62
+ "CharLiteral",
63
+ "DecimalLiteral",
64
+ "DecorationFormat",
65
+ "DecorationValuesFile",
66
+ "DefRef",
67
+ "Distribution",
68
+ "DocArray",
69
+ "DocBool",
70
+ "DocFloat",
71
+ "DocInt",
72
+ "DocNull",
73
+ "DocObject",
74
+ "DocString",
75
+ "Document",
76
+ "Documented",
77
+ "EntryPoint",
78
+ "EntryPointKind",
79
+ "FQName",
80
+ "Field",
81
+ "FileMeta",
82
+ "FileWithDefs",
83
+ "FloatLiteral",
84
+ "IntegerLiteral",
85
+ "LayerManifest",
86
+ "LibraryDistribution",
87
+ "Literal",
88
+ "Name",
89
+ "PackageInfo",
90
+ "Path",
91
+ "Pattern",
92
+ "PointerRef",
93
+ "QName",
94
+ "Ref",
95
+ "SchemaRef",
96
+ "SourceRange",
97
+ "SpecsDistribution",
98
+ "StringLiteral",
99
+ "Type",
100
+ "TypeAttributes",
101
+ "TypeConstraints",
102
+ "TypeDefinition",
103
+ "TypeSpecification",
104
+ "Value",
105
+ "ValueAttributes",
106
+ "ValueDefinition",
107
+ "ValueSpecification",
108
+ "module",
109
+ "package",
110
+ ]
@@ -0,0 +1,15 @@
1
+ """Compatibility shim: re-exports `morphir.ir.v4.access_controlled`."""
2
+
3
+ from morphir.ir.v4.access_controlled import (
4
+ AccessControlled,
5
+ Private,
6
+ Public,
7
+ T,
8
+ )
9
+
10
+ __all__ = [
11
+ "AccessControlled",
12
+ "Private",
13
+ "Public",
14
+ "T",
15
+ ]
@@ -0,0 +1,19 @@
1
+ """Compatibility shim: re-exports `morphir.ir.v4.decorations`."""
2
+
3
+ from morphir.ir.v4.decorations import (
4
+ DecorationFormat,
5
+ DecorationValuesFile,
6
+ LayerManifest,
7
+ SchemaRef,
8
+ deep_merge,
9
+ merge_decoration_values,
10
+ )
11
+
12
+ __all__ = [
13
+ "DecorationFormat",
14
+ "DecorationValuesFile",
15
+ "LayerManifest",
16
+ "SchemaRef",
17
+ "deep_merge",
18
+ "merge_decoration_values",
19
+ ]
@@ -0,0 +1,105 @@
1
+ """Structured diagnostics shared by the IR readers, codecs, and migrations.
2
+
3
+ Every diagnostic code lives in this module so that an upstream rename is a single
4
+ edit. Codes reuse upstream vocabulary where it exists:
5
+
6
+ - format-version codes come from the finos/morphir format-version contract
7
+ (``docs/spec/ir/format-version.md``);
8
+ - ``specs_before_3_1`` comes from the finos/morphir v3 specification
9
+ (``docs/spec/ir/schemas/v3/whats-new.md``, decision record 0018);
10
+ - decoding codes come from the Morphir Compatibility Kit (morphir-rust
11
+ ``ir/diagnostic.rs``);
12
+ - downgrade codes come from the finos CLI and morphir-moonbit
13
+ ``migration/v3/migration.mbt``, and may be renamed when finos bead
14
+ ``morphir-diwy`` settles;
15
+ - ``package_version_dropped``, ``source_location_dropped``,
16
+ ``input_attributes_dropped``, and ``no_v4_spelling`` are local to
17
+ morphir-python.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from dataclasses import dataclass
23
+
24
+ # Format version (finos/morphir format-version contract).
25
+ MISSING_FORMAT_VERSION = "missing_format_version"
26
+ DUPLICATE_FORMAT_VERSION = "duplicate_format_version"
27
+ INVALID_FORMAT_VERSION_TYPE = "invalid_format_version_type"
28
+ INVALID_FORMAT_VERSION_SYNTAX = "invalid_format_version_syntax"
29
+ FORMAT_VERSION_OUT_OF_RANGE = "format_version_out_of_range"
30
+ UNSUPPORTED_FORMAT_VERSION_MAJOR = "unsupported_format_version_major"
31
+ UNSUPPORTED_FORMAT_VERSION_MINOR = "unsupported_format_version_minor"
32
+
33
+ # A v3 Specs distribution declared below 3.1.0 (finos/morphir decision record 0018).
34
+ SPECS_BEFORE_3_1 = "specs_before_3_1"
35
+
36
+ # Decoding (Morphir Compatibility Kit).
37
+ UNKNOWN_NODE = "unknown_node"
38
+ UNKNOWN_MEMBER = "unknown_member"
39
+ MISSING_MEMBER = "missing_member"
40
+ DUPLICATE_MEMBER = "duplicate_member"
41
+ INVALID_NAME = "invalid_name"
42
+ INVALID_LITERAL = "invalid_literal"
43
+ INVALID_JSON = "invalid_json"
44
+
45
+ # Encoding a v4 construct that has no spelling in the pinned draft profile.
46
+ NO_V4_SPELLING = "no_v4_spelling"
47
+
48
+ # Reverse migration (finos CLI, morphir-moonbit).
49
+ UNSUPPORTED_V4_DOWNGRADE = "unsupported_v4_downgrade"
50
+ UNSUPPORTED_ATTRIBUTES_DOWNGRADE = "unsupported_attributes_downgrade"
51
+ MISSING_INFERRED_TYPE = "missing_inferred_type"
52
+ UNSUPPORTED_DOCUMENTATION_DOWNGRADE = "unsupported_documentation_downgrade"
53
+
54
+ # Warnings (morphir-python).
55
+ PACKAGE_VERSION_DROPPED = "package_version_dropped"
56
+ SOURCE_LOCATION_DROPPED = "source_location_dropped"
57
+ INPUT_ATTRIBUTES_DROPPED = "input_attributes_dropped"
58
+
59
+ Location = tuple[str | int, ...]
60
+
61
+
62
+ @dataclass(frozen=True)
63
+ class Diagnostic:
64
+ """A machine-readable problem found while reading, writing, or migrating IR.
65
+
66
+ Attributes:
67
+ code: Stable diagnostic code, one of the constants in this module.
68
+ construct: Name of the IR construct involved, such as ``"Hole"``.
69
+ location: Path from the document root to the construct.
70
+ message: Human-readable explanation. Callers must not parse it.
71
+ """
72
+
73
+ code: str
74
+ construct: str
75
+ location: Location
76
+ message: str
77
+
78
+ def render(self) -> str:
79
+ """Render as ``code at location: message`` for terminal output."""
80
+ where = "/".join(str(part) for part in self.location) or "<root>"
81
+ return f"{self.code} at {where}: {self.message}"
82
+
83
+
84
+ class DiagnosticError(Exception):
85
+ """Raised by readers and codecs when input cannot be processed.
86
+
87
+ Attributes:
88
+ diagnostics: One or more diagnostics describing the failure.
89
+ """
90
+
91
+ def __init__(self, *diagnostics: Diagnostic) -> None:
92
+ self.diagnostics: tuple[Diagnostic, ...] = diagnostics
93
+ super().__init__("; ".join(d.render() for d in diagnostics))
94
+
95
+ @property
96
+ def codes(self) -> tuple[str, ...]:
97
+ """The diagnostic codes, in order."""
98
+ return tuple(d.code for d in self.diagnostics)
99
+
100
+
101
+ def fail(
102
+ code: str, construct: str, location: Location, message: str
103
+ ) -> DiagnosticError:
104
+ """Build a `DiagnosticError` holding a single diagnostic."""
105
+ return DiagnosticError(Diagnostic(code, construct, location, message))
@@ -0,0 +1,21 @@
1
+ """Compatibility shim: re-exports `morphir.ir.v4.distribution`."""
2
+
3
+ from morphir.ir.v4.distribution import (
4
+ ApplicationDistribution,
5
+ Distribution,
6
+ EntryPoint,
7
+ EntryPointKind,
8
+ LibraryDistribution,
9
+ PackageInfo,
10
+ SpecsDistribution,
11
+ )
12
+
13
+ __all__ = [
14
+ "ApplicationDistribution",
15
+ "Distribution",
16
+ "EntryPoint",
17
+ "EntryPointKind",
18
+ "LibraryDistribution",
19
+ "PackageInfo",
20
+ "SpecsDistribution",
21
+ ]
morphir/ir/document.py ADDED
@@ -0,0 +1,37 @@
1
+ """Compatibility shim: re-exports `morphir.ir.v4.document`."""
2
+
3
+ from morphir.ir.v4.document import (
4
+ DocArray,
5
+ DocBool,
6
+ DocFloat,
7
+ DocInt,
8
+ DocNull,
9
+ DocObject,
10
+ DocString,
11
+ Document,
12
+ array,
13
+ bool_,
14
+ float_,
15
+ int_,
16
+ null,
17
+ object_,
18
+ string,
19
+ )
20
+
21
+ __all__ = [
22
+ "DocArray",
23
+ "DocBool",
24
+ "DocFloat",
25
+ "DocInt",
26
+ "DocNull",
27
+ "DocObject",
28
+ "DocString",
29
+ "Document",
30
+ "array",
31
+ "bool_",
32
+ "float_",
33
+ "int_",
34
+ "null",
35
+ "object_",
36
+ "string",
37
+ ]
@@ -0,0 +1,11 @@
1
+ """Compatibility shim: re-exports `morphir.ir.v4.documented`."""
2
+
3
+ from morphir.ir.v4.documented import (
4
+ Documented,
5
+ T,
6
+ )
7
+
8
+ __all__ = [
9
+ "Documented",
10
+ "T",
11
+ ]