async-matrix 3.0.0-aarch64-linux → 3.0.1-aarch64-linux

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.
@@ -5,7 +5,7 @@
5
5
 
6
6
  require_relative "../error"
7
7
 
8
- module Async
8
+ module Protocol
9
9
  module Matrix
10
10
  module Schema
11
11
  # Raised by Event#valid! when data fails schema validation.
@@ -17,7 +17,9 @@ module Async
17
17
  # - content.membership = "invalid" -- must be one of: ["invite", "join", "knock", "leave", "ban"]
18
18
  # - sender is required but missing
19
19
  #
20
- class ValidationError < Async::Matrix::Error
20
+ # Carries an errcode, which the base supports: M_BAD_JSON is what a
21
+ # homeserver answers for a payload that fails its schema.
22
+ class ValidationError < Protocol::Matrix::Error
21
23
  attr_reader :errors, :event_type, :event_id
22
24
 
23
25
  # @param errors [Array<Hash>] raw JSONSchemer error hashes
@@ -123,7 +125,7 @@ module Async
123
125
  end
124
126
 
125
127
  __END__
126
- describe "Async::Matrix::Schema::ValidationError" do
128
+ describe "Protocol::Matrix::Schema::ValidationError" do
127
129
  def error_hash(overrides = {})
128
130
  {
129
131
  "data" => nil,
@@ -137,7 +139,7 @@ __END__
137
139
  end
138
140
 
139
141
  it "includes event type in header" do
140
- err = Async::Matrix::Schema::ValidationError.new(
142
+ err = Protocol::Matrix::Schema::ValidationError.new(
141
143
  [error_hash],
142
144
  event_type: "m.room.message"
143
145
  )
@@ -145,7 +147,7 @@ __END__
145
147
  end
146
148
 
147
149
  it "includes event ID in header" do
148
- err = Async::Matrix::Schema::ValidationError.new(
150
+ err = Protocol::Matrix::Schema::ValidationError.new(
149
151
  [error_hash],
150
152
  event_type: "m.room.member",
151
153
  event_id: "$abc123"
@@ -154,7 +156,7 @@ __END__
154
156
  end
155
157
 
156
158
  it "formats type mismatch errors" do
157
- err = Async::Matrix::Schema::ValidationError.new([
159
+ err = Protocol::Matrix::Schema::ValidationError.new([
158
160
  error_hash(
159
161
  "data_pointer" => "/content/body",
160
162
  "type" => "string",
@@ -165,7 +167,7 @@ __END__
165
167
  end
166
168
 
167
169
  it "formats required errors with missing keys" do
168
- err = Async::Matrix::Schema::ValidationError.new([
170
+ err = Protocol::Matrix::Schema::ValidationError.new([
169
171
  error_hash(
170
172
  "data_pointer" => "/content",
171
173
  "type" => "required",
@@ -177,7 +179,7 @@ __END__
177
179
  end
178
180
 
179
181
  it "formats enum errors" do
180
- err = Async::Matrix::Schema::ValidationError.new([
182
+ err = Protocol::Matrix::Schema::ValidationError.new([
181
183
  error_hash(
182
184
  "data_pointer" => "/content/membership",
183
185
  "type" => "enum",
@@ -190,7 +192,7 @@ __END__
190
192
  end
191
193
 
192
194
  it "formats pattern errors" do
193
- err = Async::Matrix::Schema::ValidationError.new([
195
+ err = Protocol::Matrix::Schema::ValidationError.new([
194
196
  error_hash(
195
197
  "data_pointer" => "/state_key",
196
198
  "type" => "pattern",
@@ -202,7 +204,7 @@ __END__
202
204
  end
203
205
 
204
206
  it "formats format errors" do
205
- err = Async::Matrix::Schema::ValidationError.new([
207
+ err = Protocol::Matrix::Schema::ValidationError.new([
206
208
  error_hash(
207
209
  "data_pointer" => "/content/avatar_url",
208
210
  "type" => "format",
@@ -214,7 +216,7 @@ __END__
214
216
  end
215
217
 
216
218
  it "truncates long values" do
217
- err = Async::Matrix::Schema::ValidationError.new([
219
+ err = Protocol::Matrix::Schema::ValidationError.new([
218
220
  error_hash(
219
221
  "data_pointer" => "/content/body",
220
222
  "type" => "integer",
@@ -226,7 +228,7 @@ __END__
226
228
 
227
229
  it "exposes the raw errors array" do
228
230
  raw = [error_hash]
229
- err = Async::Matrix::Schema::ValidationError.new(raw)
231
+ err = Protocol::Matrix::Schema::ValidationError.new(raw)
230
232
  err.errors.should.equal raw
231
233
  end
232
234
  end
@@ -3,7 +3,7 @@
3
3
  # Released under the Apache License, Version 2.0.
4
4
  # Copyright, 2026, by General Intelligence Systems.
5
5
 
6
- module Async
6
+ module Protocol
7
7
  module Matrix
8
8
  # Schema-driven validation for Matrix events using the official matrix-org/matrix-spec
9
9
  # YAML schemas and the json_schemer gem.
@@ -13,14 +13,14 @@ module Async
13
13
  # spec -- just re-run `bin/fetch-matrix-schemas` to pull the latest.
14
14
  #
15
15
  # # Look up a schema by event type
16
- # Async::Matrix::Schema["m.room.message"] # => JSONSchemer::Schema
16
+ # Protocol::Matrix::Schema["m.room.message"] # => JSONSchemer::Schema
17
17
  #
18
18
  # # Validate an event hash
19
- # Async::Matrix::Schema.valid?(event_hash) # => true/false
20
- # Async::Matrix::Schema.validate(event_hash) # => [errors]
19
+ # Protocol::Matrix::Schema.valid?(event_hash) # => true/false
20
+ # Protocol::Matrix::Schema.validate(event_hash) # => [errors]
21
21
  #
22
22
  # # List all known event types
23
- # Async::Matrix::Schema.event_types # => ["m.accepted_terms", "m.call.answer", ...]
23
+ # Protocol::Matrix::Schema.event_types # => ["m.accepted_terms", "m.call.answer", ...]
24
24
  #
25
25
  module Schema
26
26
  class << self
@@ -89,15 +89,15 @@ module Async
89
89
  end
90
90
 
91
91
  __END__
92
- describe "Async::Matrix::Schema" do
92
+ describe "Protocol::Matrix::Schema" do
93
93
  it "looks up schemas by event type" do
94
- schema = Async::Matrix::Schema["m.room.message"]
94
+ schema = Protocol::Matrix::Schema["m.room.message"]
95
95
  schema.should.not.be.nil
96
96
  schema.should.be.kind_of JSONSchemer::Schema
97
97
  end
98
98
 
99
99
  it "returns nil for unknown event types" do
100
- Async::Matrix::Schema["m.fake.event"].should.be.nil
100
+ Protocol::Matrix::Schema["m.fake.event"].should.be.nil
101
101
  end
102
102
 
103
103
  it "validates event hashes" do
@@ -109,7 +109,7 @@ __END__
109
109
  "origin_server_ts" => 1234567890,
110
110
  "room_id" => "!room:example.org"
111
111
  }
112
- Async::Matrix::Schema.valid?(valid_event).should == true
112
+ Protocol::Matrix::Schema.valid?(valid_event).should == true
113
113
  end
114
114
 
115
115
  it "returns errors for invalid events" do
@@ -121,39 +121,39 @@ __END__
121
121
  "origin_server_ts" => 1234567890,
122
122
  "room_id" => "!room:example.org"
123
123
  }
124
- errors = Async::Matrix::Schema.validate(invalid_event)
124
+ errors = Protocol::Matrix::Schema.validate(invalid_event)
125
125
  errors.should.not.be.empty
126
126
  end
127
127
 
128
128
  it "lists event types" do
129
- types = Async::Matrix::Schema.event_types
129
+ types = Protocol::Matrix::Schema.event_types
130
130
  types.should.be.kind_of Array
131
131
  types.should.include "m.room.message"
132
132
  types.should.include "m.room.member"
133
133
  end
134
134
 
135
135
  it "lists variant types" do
136
- variants = Async::Matrix::Schema.variant_types
136
+ variants = Protocol::Matrix::Schema.variant_types
137
137
  variants.should.not.be.empty
138
138
  end
139
139
 
140
140
  it "looks up variant schemas" do
141
- schema = Async::Matrix::Schema.variant("m.room.message", "m.text")
141
+ schema = Protocol::Matrix::Schema.variant("m.room.message", "m.text")
142
142
  schema.should.not.be.nil
143
143
  end
144
144
 
145
145
  it "returns content properties" do
146
- props = Async::Matrix::Schema.content_properties("m.room.message")
146
+ props = Protocol::Matrix::Schema.content_properties("m.room.message")
147
147
  props.should.include "msgtype"
148
148
  props.should.include "body"
149
149
  end
150
150
 
151
151
  it "reports total schema count" do
152
- Async::Matrix::Schema.size.should.be > 50
152
+ Protocol::Matrix::Schema.size.should.be > 50
153
153
  end
154
154
 
155
155
  it "parses a raw hash into a schema-aware Event" do
156
- event = Async::Matrix::Schema.parse({
156
+ event = Protocol::Matrix::Schema.parse({
157
157
  "type" => "m.room.message",
158
158
  "content" => {"msgtype" => "m.text", "body" => "hello"},
159
159
  "event_id" => "$abc123",
@@ -161,7 +161,7 @@ __END__
161
161
  "origin_server_ts" => 1234567890,
162
162
  "room_id" => "!room:example.org"
163
163
  })
164
- event.should.be.kind_of Async::Matrix::Event
164
+ event.should.be.kind_of Protocol::Matrix::Event
165
165
  event.type.should == "m.room.message"
166
166
  event.content.body.should == "hello"
167
167
  event.valid?.should == true