onlyoffice-docs_integration_sdk 0.1.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 (31) hide show
  1. checksums.yaml +7 -0
  2. data/lib/onlyoffice/docs_integration_sdk/document_editor/config.rb +1479 -0
  3. data/lib/onlyoffice/docs_integration_sdk/document_editor/config_test.rb +1713 -0
  4. data/lib/onlyoffice/docs_integration_sdk/document_editor.rb +29 -0
  5. data/lib/onlyoffice/docs_integration_sdk/document_server/client/command.rb +417 -0
  6. data/lib/onlyoffice/docs_integration_sdk/document_server/client/command_test.rb +672 -0
  7. data/lib/onlyoffice/docs_integration_sdk/document_server/client/conversion.rb +477 -0
  8. data/lib/onlyoffice/docs_integration_sdk/document_server/client/conversion_test.rb +682 -0
  9. data/lib/onlyoffice/docs_integration_sdk/document_server/client/healthcheck.rb +101 -0
  10. data/lib/onlyoffice/docs_integration_sdk/document_server/client/healthcheck_test.rb +209 -0
  11. data/lib/onlyoffice/docs_integration_sdk/document_server/client/jwt.rb +116 -0
  12. data/lib/onlyoffice/docs_integration_sdk/document_server/client/jwt_test.rb +70 -0
  13. data/lib/onlyoffice/docs_integration_sdk/document_server/client/response.rb +73 -0
  14. data/lib/onlyoffice/docs_integration_sdk/document_server/client/response_test.rb +49 -0
  15. data/lib/onlyoffice/docs_integration_sdk/document_server/client/service.rb +44 -0
  16. data/lib/onlyoffice/docs_integration_sdk/document_server/client/ua.rb +31 -0
  17. data/lib/onlyoffice/docs_integration_sdk/document_server/client/ua_test.rb +35 -0
  18. data/lib/onlyoffice/docs_integration_sdk/document_server/client.rb +321 -0
  19. data/lib/onlyoffice/docs_integration_sdk/document_server/client_test.rb +1259 -0
  20. data/lib/onlyoffice/docs_integration_sdk/document_server.rb +29 -0
  21. data/lib/onlyoffice/docs_integration_sdk/document_storage/callback.rb +276 -0
  22. data/lib/onlyoffice/docs_integration_sdk/document_storage/callback_test.rb +291 -0
  23. data/lib/onlyoffice/docs_integration_sdk/document_storage.rb +29 -0
  24. data/lib/onlyoffice/docs_integration_sdk/jwt.rb +448 -0
  25. data/lib/onlyoffice/docs_integration_sdk/jwt_test.rb +598 -0
  26. data/lib/onlyoffice/docs_integration_sdk/test_test.rb +113 -0
  27. data/lib/onlyoffice/docs_integration_sdk/version.rb +26 -0
  28. data/lib/onlyoffice/docs_integration_sdk/version_test.rb +33 -0
  29. data/lib/onlyoffice/docs_integration_sdk.rb +31 -0
  30. data/lib/onlyoffice.rb +21 -0
  31. metadata +283 -0
@@ -0,0 +1,29 @@
1
+ #
2
+ # (c) Copyright Ascensio System SIA 2025
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ # typed: strict
18
+ # frozen_string_literal: true
19
+
20
+ require "sorbet-runtime"
21
+
22
+ module Onlyoffice
23
+ module DocsIntegrationSdk
24
+ # @since 0.1.0
25
+ module DocumentServer; end
26
+ end
27
+ end
28
+
29
+ require_relative "document_server/client"
@@ -0,0 +1,276 @@
1
+ #
2
+ # (c) Copyright Ascensio System SIA 2025
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ # typed: strict
18
+ # frozen_string_literal: true
19
+
20
+ require "sorbet-runtime"
21
+
22
+ module Onlyoffice
23
+ module DocsIntegrationSdk
24
+ module DocumentStorage
25
+ # @since 0.1.0
26
+ module Callback
27
+ # @since 0.1.0
28
+ class Request < T::Struct
29
+ extend T::Sig
30
+
31
+ # @since 0.1.0
32
+ class Action < T::Struct
33
+ extend T::Sig
34
+
35
+ # @since 0.1.0
36
+ class Type < T::Enum
37
+ extend T::Sig
38
+
39
+ enums do
40
+ # @since 0.1.0
41
+ Disconnect = new(0)
42
+
43
+ # @since 0.1.0
44
+ Connect = new(1)
45
+
46
+ # @since 0.1.0
47
+ ForceSave = new(2)
48
+ end
49
+
50
+ # description returns the human-readable description of the type.
51
+ #
52
+ # @since 0.1.0
53
+ sig {returns(String)}
54
+ def description
55
+ case self
56
+ when Disconnect
57
+ "The user disconnects from the document co-editing"
58
+ when Connect
59
+ "The new user connects to the document co-editing"
60
+ when ForceSave
61
+ "The user clicks the forcesave button"
62
+ else
63
+ # :nocov:
64
+ # unreachable
65
+ # :nocov:
66
+ end
67
+ end
68
+ end
69
+
70
+ # @since 0.1.0
71
+ prop :type, T.nilable(Type), name: "type"
72
+
73
+ # @since 0.1.0
74
+ prop :user_id, T.nilable(String), name: "userid"
75
+
76
+ # @since 0.1.0
77
+ sig {params(hash: T.untyped, strict: T.untyped).returns(Action)}
78
+ def self.from_hash(hash, strict = nil)
79
+ super(hash, strict)
80
+ end
81
+ end
82
+
83
+ # @since 0.1.0
84
+ class ForceSaveType < T::Enum
85
+ enums do
86
+ # @since 0.1.0
87
+ Command = new(0)
88
+
89
+ # @since 0.1.0
90
+ Save = new(1)
91
+
92
+ # @since 0.1.0
93
+ Time = new(2)
94
+
95
+ # @since 0.1.0
96
+ Submit = new(3)
97
+ end
98
+ end
99
+
100
+ # @since 0.1.0
101
+ class FormData < T::Struct
102
+ extend T::Sig
103
+
104
+ # @since 0.1.0
105
+ class Type < T::Enum
106
+ enums do
107
+ # @since 0.1.0
108
+ Text = new("text")
109
+
110
+ # @since 0.1.0
111
+ CheckBox = new("checkBox")
112
+
113
+ # @since 0.1.0
114
+ Picture = new("picture")
115
+
116
+ # @since 0.1.0
117
+ ComboBox = new("comboBox")
118
+
119
+ # @since 0.1.0
120
+ DropDownList = new("dropDownList")
121
+
122
+ # @since 0.1.0
123
+ DateTime = new("dateTime")
124
+
125
+ # @since 0.1.0
126
+ Radio = new("radio")
127
+ end
128
+ end
129
+
130
+ # @since 0.1.0
131
+ prop :key, T.nilable(String), name: "key"
132
+
133
+ # @since 0.1.0
134
+ prop :tag, T.nilable(String), name: "tag"
135
+
136
+ # @since 0.1.0
137
+ prop :value, T.nilable(String), name: "value"
138
+
139
+ # @since 0.1.0
140
+ prop :type, T.nilable(Type), name: "type"
141
+
142
+ # @since 0.1.0
143
+ sig {params(hash: T.untyped, strict: T.untyped).returns(FormData)}
144
+ def self.from_hash(hash, strict = nil)
145
+ super(hash, strict)
146
+ end
147
+ end
148
+
149
+ # @since 0.1.0
150
+ class History < T::Struct
151
+ extend T::Sig
152
+
153
+ # @since 0.1.0
154
+ prop :changes, T.nilable(T::Hash[T.untyped, T.untyped]), name: "changes"
155
+
156
+ # @since 0.1.0
157
+ prop :server_version, T.nilable(String), name: "serverVersion"
158
+
159
+ # @since 0.1.0
160
+ sig {params(hash: T.untyped, strict: T.untyped).returns(History)}
161
+ def self.from_hash(hash, strict = nil)
162
+ super(hash, strict)
163
+ end
164
+ end
165
+
166
+ # @since 0.1.0
167
+ class Status < T::Enum
168
+ extend T::Sig
169
+
170
+ enums do
171
+ # @since 0.1.0
172
+ Editing = new(1)
173
+
174
+ # @since 0.1.0
175
+ Save = new(2)
176
+
177
+ # @since 0.1.0
178
+ SaveError = new(3)
179
+
180
+ # @since 0.1.0
181
+ Closed = new(4)
182
+
183
+ # @since 0.1.0
184
+ ForceSave = new(6)
185
+
186
+ # @since 0.1.0
187
+ ForceSaveError = new(7)
188
+ end
189
+
190
+ # description returns the human-readable description of the status.
191
+ #
192
+ # @since 0.1.0
193
+ sig {returns(String)}
194
+ def description
195
+ case self
196
+ when Editing
197
+ "The document is being edited"
198
+ when Save
199
+ "The document is ready to be saved"
200
+ when SaveError
201
+ "An error occurred while saving the document"
202
+ when Closed
203
+ "The document was closed without changes"
204
+ when ForceSave
205
+ "Editing of the document continues, but the current state of the document is saved"
206
+ when ForceSaveError
207
+ "An error occurred while forcing the document to be saved"
208
+ else
209
+ # :nocov:
210
+ # unreachable
211
+ # :nocov:
212
+ end
213
+ end
214
+ end
215
+
216
+ # @since 0.1.0
217
+ prop :actions, T.nilable(T::Array[Action]), name: "actions"
218
+
219
+ # @deprecated Use {history} instead. This property is deprecated since Document Server version 4.2.
220
+ # @since 0.1.0
221
+ prop :changeshistory, T.nilable(T::Array[T.untyped]), name: "changeshistory"
222
+
223
+ # @since 0.1.0
224
+ prop :changesurl, T.nilable(String), name: "changesurl"
225
+
226
+ # @since 0.1.0
227
+ prop :filetype, T.nilable(String), name: "filetype"
228
+
229
+ # @since 0.1.0
230
+ prop :forcesavetype, T.nilable(ForceSaveType), name: "forcesavetype"
231
+
232
+ # @since 0.1.0
233
+ prop :formsdataurl, T.nilable(String), name: "formsdataurl"
234
+
235
+ # @since 0.1.0
236
+ prop :history, T.nilable(History), name: "history"
237
+
238
+ # @since 0.1.0
239
+ prop :key, T.nilable(String), name: "key"
240
+
241
+ # @since 0.1.0
242
+ prop :status, T.nilable(Status), name: "status"
243
+
244
+ # @since 0.1.0
245
+ prop :url, T.nilable(String), name: "url"
246
+
247
+ # @since 0.1.0
248
+ prop :userdata, T.nilable(String), name: "userdata"
249
+
250
+ # @since 0.1.0
251
+ prop :users, T.nilable(T::Array[String]), name: "users"
252
+
253
+ # @since 0.1.0
254
+ sig {params(hash: T.untyped, strict: T.untyped).returns(Request)}
255
+ def self.from_hash(hash, strict = nil)
256
+ super(hash, strict)
257
+ end
258
+ end
259
+
260
+ # @since 0.1.0
261
+ class Response < T::Struct
262
+ extend T::Sig
263
+
264
+ # @since 0.1.0
265
+ prop :error, Integer, name: "error"
266
+
267
+ # @since 0.1.0
268
+ sig {params(hash: T.untyped, strict: T.untyped).returns(Response)}
269
+ def self.from_hash(hash, strict = nil)
270
+ super(hash, strict)
271
+ end
272
+ end
273
+ end
274
+ end
275
+ end
276
+ end
@@ -0,0 +1,291 @@
1
+ #
2
+ # (c) Copyright Ascensio System SIA 2025
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ # typed: true
18
+ # frozen_string_literal: true
19
+
20
+ require "test/unit"
21
+ require_relative "../test_test"
22
+ require_relative "callback"
23
+
24
+ module Onlyoffice
25
+ module DocsIntegrationSdk
26
+ module DocumentStorage
27
+ module Callback
28
+ class Request
29
+ class Action
30
+ class TypeTest < ::Test::Unit::TestCase
31
+ extend T::Sig
32
+ include Test::DescriptiveEnumMarshalling
33
+
34
+ sig {override.returns(T::Array[[Integer, String, Type]])}
35
+ def cases
36
+ [
37
+ [
38
+ 0,
39
+ "The user disconnects from the document co-editing",
40
+ Type::Disconnect,
41
+ ],
42
+ [
43
+ 1,
44
+ "The new user connects to the document co-editing",
45
+ Type::Connect,
46
+ ],
47
+ [
48
+ 2,
49
+ "The user clicks the forcesave button",
50
+ Type::ForceSave,
51
+ ],
52
+ ]
53
+ end
54
+ end
55
+ end
56
+
57
+ class ActionTest < ::Test::Unit::TestCase
58
+ extend T::Sig
59
+ include Test::StructMarshalling
60
+
61
+ sig {override.returns(T::Array[[T.untyped, Action]])}
62
+ def cases
63
+ [
64
+ [
65
+ {},
66
+ Action.new,
67
+ ],
68
+ [
69
+ {
70
+ "type" => 0,
71
+ "userid" => "user",
72
+ },
73
+ Action.new(
74
+ type: Action::Type::Disconnect,
75
+ user_id: "user",
76
+ ),
77
+ ],
78
+ ]
79
+ end
80
+ end
81
+
82
+ class ForceSaveTypeTest < ::Test::Unit::TestCase
83
+ extend T::Sig
84
+ include Test::BasicEnumMarshalling
85
+
86
+ sig {override.returns(T::Array[[Integer, ForceSaveType]])}
87
+ def cases
88
+ [
89
+ [0, ForceSaveType::Command],
90
+ [1, ForceSaveType::Save],
91
+ [2, ForceSaveType::Time],
92
+ [3, ForceSaveType::Submit],
93
+ ]
94
+ end
95
+ end
96
+
97
+ class FormData
98
+ class TypeTest < ::Test::Unit::TestCase
99
+ extend T::Sig
100
+ include Test::BasicEnumMarshalling
101
+
102
+ sig {override.returns(T::Array[[String, Type]])}
103
+ def cases
104
+ [
105
+ ["text", Type::Text],
106
+ ["checkBox", Type::CheckBox],
107
+ ["picture", Type::Picture],
108
+ ["comboBox", Type::ComboBox],
109
+ ["dropDownList", Type::DropDownList],
110
+ ["dateTime", Type::DateTime],
111
+ ["radio", Type::Radio],
112
+ ]
113
+ end
114
+ end
115
+ end
116
+
117
+ class FormDataTest < ::Test::Unit::TestCase
118
+ extend T::Sig
119
+ include Test::StructMarshalling
120
+
121
+ sig {override.returns(T::Array[[T.untyped, FormData]])}
122
+ def cases
123
+ [
124
+ [
125
+ {},
126
+ FormData.new,
127
+ ],
128
+ [
129
+ {
130
+ "key" => "text_1",
131
+ "tag" => "label",
132
+ "value" => "hello",
133
+ "type" => "text",
134
+ },
135
+ FormData.new(
136
+ key: "text_1",
137
+ tag: "label",
138
+ value: "hello",
139
+ type: FormData::Type::Text,
140
+ ),
141
+ ],
142
+ ]
143
+ end
144
+ end
145
+
146
+ class HistoryTest < ::Test::Unit::TestCase
147
+ extend T::Sig
148
+ include Test::StructMarshalling
149
+
150
+ sig {override.returns(T::Array[[T.untyped, History]])}
151
+ def cases
152
+ [
153
+ [
154
+ {},
155
+ History.new,
156
+ ],
157
+ [
158
+ {
159
+ "changes" => {},
160
+ "serverVersion" => "1.0",
161
+ },
162
+ History.new(
163
+ changes: {},
164
+ server_version: "1.0",
165
+ ),
166
+ ],
167
+ ]
168
+ end
169
+ end
170
+
171
+ class StatusTest < ::Test::Unit::TestCase
172
+ extend T::Sig
173
+ include Test::DescriptiveEnumMarshalling
174
+
175
+ sig {override.returns(T::Array[[Integer, String, Status]])}
176
+ def cases
177
+ [
178
+ [
179
+ 1,
180
+ "The document is being edited",
181
+ Status::Editing,
182
+ ],
183
+ [
184
+ 2,
185
+ "The document is ready to be saved",
186
+ Status::Save,
187
+ ],
188
+ [
189
+ 3,
190
+ "An error occurred while saving the document",
191
+ Status::SaveError,
192
+ ],
193
+ [
194
+ 4,
195
+ "The document was closed without changes",
196
+ Status::Closed,
197
+ ],
198
+ [
199
+ 6,
200
+ "Editing of the document continues, but the current state of the document is saved",
201
+ Status::ForceSave,
202
+ ],
203
+ [
204
+ 7,
205
+ "An error occurred while forcing the document to be saved",
206
+ Status::ForceSaveError,
207
+ ],
208
+ ]
209
+ end
210
+ end
211
+ end
212
+
213
+ class RequestTest < ::Test::Unit::TestCase
214
+ extend T::Sig
215
+ include Test::StructMarshalling
216
+
217
+ sig {override.returns(T::Array[[T.untyped, Request]])}
218
+ def cases
219
+ [
220
+ [
221
+ {},
222
+ Request.new,
223
+ ],
224
+ [
225
+ {
226
+ "actions" => [
227
+ {
228
+ "type" => 0,
229
+ },
230
+ ],
231
+ "changeshistory" => [],
232
+ "changesurl" => "http://localhost:8080/",
233
+ "filetype" => "pdf",
234
+ "forcesavetype" => 0,
235
+ "formsdataurl" => "http://localhost:8080/",
236
+ "history" => {
237
+ "changes" => {},
238
+ },
239
+ "key" => "***",
240
+ "status" => 1,
241
+ "url" => "http://localhost:8080/",
242
+ "userdata" => "data",
243
+ "users" => ["user_1"],
244
+ },
245
+ Request.new(
246
+ actions: [
247
+ Request::Action.new(
248
+ type: Request::Action::Type::Disconnect,
249
+ ),
250
+ ],
251
+ changeshistory: [],
252
+ changesurl: "http://localhost:8080/",
253
+ filetype: "pdf",
254
+ forcesavetype: Request::ForceSaveType::Command,
255
+ formsdataurl: "http://localhost:8080/",
256
+ history: Request::History.new(
257
+ changes: {},
258
+ ),
259
+ key: "***",
260
+ status: Request::Status::Editing,
261
+ url: "http://localhost:8080/",
262
+ userdata: "data",
263
+ users: ["user_1"],
264
+ ),
265
+ ],
266
+ ]
267
+ end
268
+ end
269
+
270
+ class ResponseTest < ::Test::Unit::TestCase
271
+ extend T::Sig
272
+ include Test::StructMarshalling
273
+
274
+ sig {override.returns(T::Array[[T.untyped, Response]])}
275
+ def cases
276
+ [
277
+ [
278
+ {
279
+ "error" => 0,
280
+ },
281
+ Response.new(
282
+ error: 0,
283
+ ),
284
+ ],
285
+ ]
286
+ end
287
+ end
288
+ end
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # (c) Copyright Ascensio System SIA 2025
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ # typed: strict
18
+ # frozen_string_literal: true
19
+
20
+ require "sorbet-runtime"
21
+
22
+ module Onlyoffice
23
+ module DocsIntegrationSdk
24
+ # @since 0.1.0
25
+ module DocumentStorage; end
26
+ end
27
+ end
28
+
29
+ require_relative "document_storage/callback"