mailschema 0.2.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE +21 -0
- data/README.md +114 -0
- data/contexts/map-0.2.jsonld +91 -0
- data/lib/mailschema/artifacts.rb +94 -0
- data/lib/mailschema/capability.rb +41 -0
- data/lib/mailschema/contract.rb +331 -0
- data/lib/mailschema/document.rb +79 -0
- data/lib/mailschema/documents.rb +127 -0
- data/lib/mailschema/forms.rb +41 -0
- data/lib/mailschema/http.rb +25 -0
- data/lib/mailschema/jcs.rb +87 -0
- data/lib/mailschema/limits.rb +56 -0
- data/lib/mailschema/message.rb +17 -0
- data/lib/mailschema/pointer.rb +46 -0
- data/lib/mailschema/references.rb +62 -0
- data/lib/mailschema/schema_walk.rb +29 -0
- data/lib/mailschema/version.rb +5 -0
- data/lib/mailschema.rb +41 -0
- data/schemas/contribution.schema.json +874 -0
- data/schemas/forms-0.1.schema.json +329 -0
- data/schemas/map-0.2.schema.json +1033 -0
- data/schemas/type-contract-0.2.schema.json +179 -0
- data/sig/mailschema.rbs +92 -0
- metadata +123 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://mailschema.org/schemas/type-contract-0.2.schema.json",
|
|
4
|
+
"title": "MailSchema type contract for MAP 0.2",
|
|
5
|
+
"description": "A versioned interaction contract: the details, inputs, results, authority, repeatability and consequences of each operation, with every schema it depends on pinned by digest.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"kind": {
|
|
10
|
+
"const": "MapTypeContract"
|
|
11
|
+
},
|
|
12
|
+
"id": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"pattern": "^https://mailschema\\.org/types/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
|
|
15
|
+
"maxLength": 2048
|
|
16
|
+
},
|
|
17
|
+
"version": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"pattern": "^[0-9]+\\.[0-9]+(?:\\.[0-9]+)?(?:-[a-zA-Z0-9.-]+)?$",
|
|
20
|
+
"maxLength": 80
|
|
21
|
+
},
|
|
22
|
+
"profile": {
|
|
23
|
+
"const": "https://mailschema.org/profiles/map/0.2"
|
|
24
|
+
},
|
|
25
|
+
"target": {
|
|
26
|
+
"$ref": "#/$defs/prose"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"minItems": 1,
|
|
31
|
+
"maxItems": 20,
|
|
32
|
+
"items": {
|
|
33
|
+
"$ref": "#/$defs/schemaReference"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"detailsSchema": {
|
|
37
|
+
"type": "object"
|
|
38
|
+
},
|
|
39
|
+
"requestSchema": {
|
|
40
|
+
"$ref": "#/$defs/schemaReference"
|
|
41
|
+
},
|
|
42
|
+
"operations": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"minItems": 1,
|
|
45
|
+
"maxItems": 100,
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"additionalProperties": false,
|
|
49
|
+
"properties": {
|
|
50
|
+
"id": {
|
|
51
|
+
"$ref": "#/$defs/token"
|
|
52
|
+
},
|
|
53
|
+
"effect": {
|
|
54
|
+
"$ref": "#/$defs/prose"
|
|
55
|
+
},
|
|
56
|
+
"authority": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"items": {
|
|
59
|
+
"enum": ["credential", "possession"]
|
|
60
|
+
},
|
|
61
|
+
"minItems": 1,
|
|
62
|
+
"maxItems": 2,
|
|
63
|
+
"uniqueItems": true
|
|
64
|
+
},
|
|
65
|
+
"consequences": {
|
|
66
|
+
"type": "array",
|
|
67
|
+
"items": {
|
|
68
|
+
"enum": [
|
|
69
|
+
"refusal",
|
|
70
|
+
"protection",
|
|
71
|
+
"record",
|
|
72
|
+
"disclosure",
|
|
73
|
+
"commitment",
|
|
74
|
+
"authorization",
|
|
75
|
+
"assertion"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"minItems": 1,
|
|
79
|
+
"maxItems": 7,
|
|
80
|
+
"uniqueItems": true
|
|
81
|
+
},
|
|
82
|
+
"repeatable": {
|
|
83
|
+
"type": "boolean"
|
|
84
|
+
},
|
|
85
|
+
"fieldBindings": {
|
|
86
|
+
"type": "array",
|
|
87
|
+
"minItems": 1,
|
|
88
|
+
"maxItems": 10,
|
|
89
|
+
"items": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"additionalProperties": false,
|
|
92
|
+
"properties": {
|
|
93
|
+
"input": {
|
|
94
|
+
"$ref": "#/$defs/pointer"
|
|
95
|
+
},
|
|
96
|
+
"fields": {
|
|
97
|
+
"$ref": "#/$defs/pointer"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"required": ["input", "fields"]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"results": {
|
|
104
|
+
"type": "array",
|
|
105
|
+
"minItems": 1,
|
|
106
|
+
"maxItems": 5,
|
|
107
|
+
"items": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": false,
|
|
110
|
+
"properties": {
|
|
111
|
+
"state": {
|
|
112
|
+
"enum": ["accepted", "completed", "failed", "pending", "approval-required"]
|
|
113
|
+
},
|
|
114
|
+
"reasons": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": {
|
|
117
|
+
"$ref": "#/$defs/token"
|
|
118
|
+
},
|
|
119
|
+
"minItems": 1,
|
|
120
|
+
"maxItems": 20,
|
|
121
|
+
"uniqueItems": true
|
|
122
|
+
},
|
|
123
|
+
"outputSchema": {
|
|
124
|
+
"type": "object"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"required": ["state", "outputSchema"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"required": ["id", "effect", "authority", "consequences", "results"]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"required": [
|
|
136
|
+
"kind",
|
|
137
|
+
"id",
|
|
138
|
+
"version",
|
|
139
|
+
"profile",
|
|
140
|
+
"target",
|
|
141
|
+
"dependencies",
|
|
142
|
+
"requestSchema",
|
|
143
|
+
"operations"
|
|
144
|
+
],
|
|
145
|
+
"$defs": {
|
|
146
|
+
"prose": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"minLength": 1,
|
|
149
|
+
"maxLength": 12000,
|
|
150
|
+
"pattern": "[^\\t\\n\\u000b\\f\\r \\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]"
|
|
151
|
+
},
|
|
152
|
+
"token": {
|
|
153
|
+
"type": "string",
|
|
154
|
+
"pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
|
|
155
|
+
"maxLength": 100
|
|
156
|
+
},
|
|
157
|
+
"pointer": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"pattern": "^(?:/(?:[^~/]|~[01])*)+$",
|
|
160
|
+
"maxLength": 1000
|
|
161
|
+
},
|
|
162
|
+
"schemaReference": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"additionalProperties": false,
|
|
165
|
+
"properties": {
|
|
166
|
+
"url": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"pattern": "^https://mailschema\\.org/schemas/[a-z0-9.-]+\\.json$",
|
|
169
|
+
"maxLength": 2048
|
|
170
|
+
},
|
|
171
|
+
"canonicalDigest": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"pattern": "^sha-256:[a-f0-9]{64}$"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"required": ["url", "canonicalDigest"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
data/sig/mailschema.rbs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Mail Action Protocol 0.2 tooling.
|
|
2
|
+
module Mailschema
|
|
3
|
+
type json = Hash[String, untyped] | Array[untyped] | String | Integer | Float | bool | nil
|
|
4
|
+
type document = Hash[String, untyped]
|
|
5
|
+
type input_error = Hash[String, String]
|
|
6
|
+
|
|
7
|
+
VERSION: String
|
|
8
|
+
|
|
9
|
+
PROFILE: String
|
|
10
|
+
CORE_SCHEMA: String
|
|
11
|
+
FORMS_SCHEMA: String
|
|
12
|
+
CONTRACT_FORMAT: String
|
|
13
|
+
CONTEXT: String
|
|
14
|
+
CONTRIBUTION_SCHEMA: String
|
|
15
|
+
ARTIFACTS: Hash[String, String]
|
|
16
|
+
APPROVAL_REASONS: Array[String]
|
|
17
|
+
PROBLEM_STATUS: Hash[String, Integer]
|
|
18
|
+
PROBLEM_TYPES: String
|
|
19
|
+
NON_TERMINAL_STATES: Array[String]
|
|
20
|
+
MAX_BYTES: Integer
|
|
21
|
+
MAX_DEPTH: Integer
|
|
22
|
+
EXACT_NUMBER: Integer
|
|
23
|
+
|
|
24
|
+
class Error < StandardError
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class InvalidDocument < Error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class InvalidContract < Error
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.parse: (String json) -> json
|
|
34
|
+
def self.canonicalize: (json value) -> String
|
|
35
|
+
def self.digest: (json value) -> String
|
|
36
|
+
def self.reached?: (Time now, untyped deadline, ?after: Numeric) -> bool
|
|
37
|
+
|
|
38
|
+
def self.artifact: (String url) -> String
|
|
39
|
+
def self.document: (String url) -> document
|
|
40
|
+
|
|
41
|
+
def self.map_errors: (untyped document) -> Array[String]
|
|
42
|
+
def self.description_errors: (untyped description) -> Array[String]
|
|
43
|
+
def self.request_errors: (untyped request) -> Array[String]
|
|
44
|
+
def self.result_errors: (untyped result) -> Array[String]
|
|
45
|
+
def self.problem_errors: (untyped problem) -> Array[String]
|
|
46
|
+
def self.request_id?: (untyped value) -> bool
|
|
47
|
+
|
|
48
|
+
def self.capability: (document description) -> String
|
|
49
|
+
def self.written_path: (String? url) -> String
|
|
50
|
+
|
|
51
|
+
def self.result: (document request, state: String, target: document, result_url: String, recorded_at: Time,
|
|
52
|
+
?output: document, ?reason: String?, ?approval_url: String?, ?actor: String?) -> document
|
|
53
|
+
def self.transition: (document result, state: String, recorded_at: Time, ?reason: String?, ?output: document) -> document
|
|
54
|
+
def self.problem: (String code, title: String, detail: String, ?request_id: String?, ?interaction_id: String?,
|
|
55
|
+
?result_url: String?, ?target: document?, ?errors: Array[input_error]?) -> document
|
|
56
|
+
def self.result_status: (document result) -> Integer
|
|
57
|
+
def self.json_request?: (String? content_type) -> bool
|
|
58
|
+
DESCRIPTION_MEDIA_TYPE: String
|
|
59
|
+
def self.description_part?: (String? media_type, String? profile_parameter) -> bool
|
|
60
|
+
def self.result_url: (document description, String request_id) -> String
|
|
61
|
+
def self.retain_until: (document description, Time recorded_at) -> Time
|
|
62
|
+
def self.settle: (document result, document description, Time now) -> document?
|
|
63
|
+
|
|
64
|
+
# A type contract an implementation vendors, verified by digest and compiled once.
|
|
65
|
+
class Contract
|
|
66
|
+
# A MAP problem a request earns before the service's own state is consulted.
|
|
67
|
+
class Problem < Data
|
|
68
|
+
attr_reader code: String
|
|
69
|
+
attr_reader title: String
|
|
70
|
+
attr_reader detail: String
|
|
71
|
+
|
|
72
|
+
def self.new: (String code, String title, String detail) -> instance
|
|
73
|
+
| (code: String, title: String, detail: String) -> instance
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
attr_reader document: document
|
|
77
|
+
attr_reader digest: String
|
|
78
|
+
attr_reader request_schema: document
|
|
79
|
+
|
|
80
|
+
def initialize: (document contract, document request_schema, digest: String,
|
|
81
|
+
?dependencies: Hash[String, document]) -> void
|
|
82
|
+
def id: () -> String
|
|
83
|
+
def version: () -> String
|
|
84
|
+
def type_reference: () -> Hash[String, String]
|
|
85
|
+
def operation: (String? id) -> document?
|
|
86
|
+
def decision?: (String id) -> bool
|
|
87
|
+
def description_errors: (document description) -> Array[String]
|
|
88
|
+
def request_problem: (document description, document request, now: Time) -> Problem?
|
|
89
|
+
def input_errors: (document description, document request) -> Array[input_error]
|
|
90
|
+
def result_errors: (document result) -> Array[String]
|
|
91
|
+
end
|
|
92
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mailschema
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- MailSchema contributors
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: bigdecimal
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '3.1'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '5'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '3.1'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '5'
|
|
32
|
+
- !ruby/object:Gem::Dependency
|
|
33
|
+
name: json
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '2.21'
|
|
39
|
+
- - "<"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '4'
|
|
42
|
+
type: :runtime
|
|
43
|
+
prerelease: false
|
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '2.21'
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '4'
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: json_schemer
|
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - "~>"
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '2.5'
|
|
59
|
+
type: :runtime
|
|
60
|
+
prerelease: false
|
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - "~>"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '2.5'
|
|
66
|
+
description: Parse, canonicalize, digest and validate Mail Action Protocol 0.2 documents,
|
|
67
|
+
verify the type contracts an implementation vendors, and build results and problems.
|
|
68
|
+
executables: []
|
|
69
|
+
extensions: []
|
|
70
|
+
extra_rdoc_files: []
|
|
71
|
+
files:
|
|
72
|
+
- CHANGELOG.md
|
|
73
|
+
- LICENSE
|
|
74
|
+
- README.md
|
|
75
|
+
- contexts/map-0.2.jsonld
|
|
76
|
+
- lib/mailschema.rb
|
|
77
|
+
- lib/mailschema/artifacts.rb
|
|
78
|
+
- lib/mailschema/capability.rb
|
|
79
|
+
- lib/mailschema/contract.rb
|
|
80
|
+
- lib/mailschema/document.rb
|
|
81
|
+
- lib/mailschema/documents.rb
|
|
82
|
+
- lib/mailschema/forms.rb
|
|
83
|
+
- lib/mailschema/http.rb
|
|
84
|
+
- lib/mailschema/jcs.rb
|
|
85
|
+
- lib/mailschema/limits.rb
|
|
86
|
+
- lib/mailschema/message.rb
|
|
87
|
+
- lib/mailschema/pointer.rb
|
|
88
|
+
- lib/mailschema/references.rb
|
|
89
|
+
- lib/mailschema/schema_walk.rb
|
|
90
|
+
- lib/mailschema/version.rb
|
|
91
|
+
- schemas/contribution.schema.json
|
|
92
|
+
- schemas/forms-0.1.schema.json
|
|
93
|
+
- schemas/map-0.2.schema.json
|
|
94
|
+
- schemas/type-contract-0.2.schema.json
|
|
95
|
+
- sig/mailschema.rbs
|
|
96
|
+
homepage: https://mailschema.org/tools
|
|
97
|
+
licenses:
|
|
98
|
+
- MIT
|
|
99
|
+
metadata:
|
|
100
|
+
allowed_push_host: https://rubygems.org
|
|
101
|
+
homepage_uri: https://mailschema.org/tools
|
|
102
|
+
source_code_uri: https://github.com/mailschema/ruby
|
|
103
|
+
changelog_uri: https://github.com/mailschema/ruby/blob/main/CHANGELOG.md
|
|
104
|
+
bug_tracker_uri: https://github.com/mailschema/ruby/issues
|
|
105
|
+
rubygems_mfa_required: 'true'
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: 3.3.0
|
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
requirements: []
|
|
120
|
+
rubygems_version: 4.0.20
|
|
121
|
+
specification_version: 4
|
|
122
|
+
summary: Mail Action Protocol 0.2 tooling
|
|
123
|
+
test_files: []
|