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.
- checksums.yaml +7 -0
- data/lib/onlyoffice/docs_integration_sdk/document_editor/config.rb +1479 -0
- data/lib/onlyoffice/docs_integration_sdk/document_editor/config_test.rb +1713 -0
- data/lib/onlyoffice/docs_integration_sdk/document_editor.rb +29 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/command.rb +417 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/command_test.rb +672 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/conversion.rb +477 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/conversion_test.rb +682 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/healthcheck.rb +101 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/healthcheck_test.rb +209 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/jwt.rb +116 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/jwt_test.rb +70 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/response.rb +73 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/response_test.rb +49 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/service.rb +44 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/ua.rb +31 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client/ua_test.rb +35 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client.rb +321 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server/client_test.rb +1259 -0
- data/lib/onlyoffice/docs_integration_sdk/document_server.rb +29 -0
- data/lib/onlyoffice/docs_integration_sdk/document_storage/callback.rb +276 -0
- data/lib/onlyoffice/docs_integration_sdk/document_storage/callback_test.rb +291 -0
- data/lib/onlyoffice/docs_integration_sdk/document_storage.rb +29 -0
- data/lib/onlyoffice/docs_integration_sdk/jwt.rb +448 -0
- data/lib/onlyoffice/docs_integration_sdk/jwt_test.rb +598 -0
- data/lib/onlyoffice/docs_integration_sdk/test_test.rb +113 -0
- data/lib/onlyoffice/docs_integration_sdk/version.rb +26 -0
- data/lib/onlyoffice/docs_integration_sdk/version_test.rb +33 -0
- data/lib/onlyoffice/docs_integration_sdk.rb +31 -0
- data/lib/onlyoffice.rb +21 -0
- 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 DocumentEditor; end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require_relative "document_editor/config"
|
@@ -0,0 +1,417 @@
|
|
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
|
+
require_relative "response"
|
22
|
+
require_relative "service"
|
23
|
+
|
24
|
+
module Onlyoffice
|
25
|
+
module DocsIntegrationSdk
|
26
|
+
module DocumentServer
|
27
|
+
class Client
|
28
|
+
# CommandServing is an interface that describes the methods that must be
|
29
|
+
# implemented to be considered a command service.
|
30
|
+
#
|
31
|
+
# @since 0.1.0
|
32
|
+
module CommandServing
|
33
|
+
extend T::Sig
|
34
|
+
extend T::Helpers
|
35
|
+
interface!
|
36
|
+
|
37
|
+
# @param r The request options.
|
38
|
+
# @return A tuple containing the result and the response.
|
39
|
+
# @since 0.1.0
|
40
|
+
sig {abstract.params(r: CommandService::Request).returns([CommandService::Result, Response])}
|
41
|
+
def do(r); end
|
42
|
+
end
|
43
|
+
|
44
|
+
# CommandService is an implementation of the {CommandServing} interface.
|
45
|
+
#
|
46
|
+
# @since 0.1.0
|
47
|
+
class CommandService < Service
|
48
|
+
include CommandServing
|
49
|
+
|
50
|
+
# Error is an enum that represents the possible errors that can occur
|
51
|
+
# when using the command service.
|
52
|
+
#
|
53
|
+
# @since 0.1.0
|
54
|
+
class Error < T::Enum
|
55
|
+
extend T::Sig
|
56
|
+
|
57
|
+
enums do
|
58
|
+
# @since 0.1.0
|
59
|
+
None = new(0)
|
60
|
+
|
61
|
+
# @since 0.1.0
|
62
|
+
MissingDocumentKey = new(1)
|
63
|
+
|
64
|
+
# @since 0.1.0
|
65
|
+
IncorrectCallbackUrl = new(2)
|
66
|
+
|
67
|
+
# @since 0.1.0
|
68
|
+
InternalError = new(3)
|
69
|
+
|
70
|
+
# @since 0.1.0
|
71
|
+
NoChanges = new(4)
|
72
|
+
|
73
|
+
# @since 0.1.0
|
74
|
+
IncorrectCommand = new(5)
|
75
|
+
|
76
|
+
# @since 0.1.0
|
77
|
+
InvalidToken = new(6)
|
78
|
+
end
|
79
|
+
|
80
|
+
# description returns the human-readable description of the error.
|
81
|
+
#
|
82
|
+
# @since 0.1.0
|
83
|
+
sig {returns(String)}
|
84
|
+
def description
|
85
|
+
case self
|
86
|
+
when None
|
87
|
+
"No errors"
|
88
|
+
when MissingDocumentKey
|
89
|
+
"Document key is missing or no document with such key could be found"
|
90
|
+
when IncorrectCallbackUrl
|
91
|
+
"Callback url not correct"
|
92
|
+
when InternalError
|
93
|
+
"Internal server error"
|
94
|
+
when NoChanges
|
95
|
+
"No changes were applied to the document before the forcesave command was received"
|
96
|
+
when IncorrectCommand
|
97
|
+
"Command not correct"
|
98
|
+
when InvalidToken
|
99
|
+
"Invalid token"
|
100
|
+
else
|
101
|
+
# :nocov:
|
102
|
+
# unreachable
|
103
|
+
# :nocov:
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Request is a class that represents the request options for the
|
109
|
+
# command service.
|
110
|
+
#
|
111
|
+
# @since 0.1.0
|
112
|
+
class Request < T::Struct
|
113
|
+
extend T::Sig
|
114
|
+
|
115
|
+
# @since 0.1.0
|
116
|
+
class C < T::Enum
|
117
|
+
enums do
|
118
|
+
# @since 0.1.0
|
119
|
+
DeleteForgotten = new("deleteForgotten")
|
120
|
+
|
121
|
+
# @since 0.1.0
|
122
|
+
Drop = new("drop")
|
123
|
+
|
124
|
+
# @since 0.1.0
|
125
|
+
Forcesave = new("forcesave")
|
126
|
+
|
127
|
+
# @since 0.1.0
|
128
|
+
GetForgotten = new("getForgotten")
|
129
|
+
|
130
|
+
# @since 0.1.0
|
131
|
+
GetForgottenList = new("getForgottenList")
|
132
|
+
|
133
|
+
# @since 0.1.0
|
134
|
+
Info = new("info")
|
135
|
+
|
136
|
+
# @since 0.1.0
|
137
|
+
License = new("license")
|
138
|
+
|
139
|
+
# @since 0.1.0
|
140
|
+
Meta = new("meta")
|
141
|
+
|
142
|
+
# @since 0.1.0
|
143
|
+
Version = new("version")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# @since 0.1.0
|
148
|
+
class License < T::Struct
|
149
|
+
extend T::Sig
|
150
|
+
|
151
|
+
# @since 0.1.0
|
152
|
+
prop :end_date, T.nilable(String), name: "end_date"
|
153
|
+
|
154
|
+
# @since 0.1.0
|
155
|
+
prop :trial, T.nilable(T::Boolean), name: "trial"
|
156
|
+
|
157
|
+
# @since 0.1.0
|
158
|
+
prop :customization, T.nilable(T::Boolean), name: "customization"
|
159
|
+
|
160
|
+
# @since 0.1.0
|
161
|
+
prop :connections, T.nilable(Integer), name: "connections"
|
162
|
+
|
163
|
+
# @since 0.1.0
|
164
|
+
prop :connections_view, T.nilable(Integer), name: "connections_view"
|
165
|
+
|
166
|
+
# @since 0.1.0
|
167
|
+
prop :users_count, T.nilable(Integer), name: "users_count"
|
168
|
+
|
169
|
+
# @since 0.1.0
|
170
|
+
prop :users_view_count, T.nilable(Integer), name: "users_view_count"
|
171
|
+
|
172
|
+
# @since 0.1.0
|
173
|
+
prop :users_expire, T.nilable(Integer), name: "users_expire"
|
174
|
+
|
175
|
+
# @since 0.1.0
|
176
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(License)}
|
177
|
+
def self.from_hash(hash, strict = nil)
|
178
|
+
super(hash, strict)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# @since 0.1.0
|
183
|
+
class Server < T::Struct
|
184
|
+
extend T::Sig
|
185
|
+
|
186
|
+
# @since 0.1.0
|
187
|
+
class ResultType < T::Enum
|
188
|
+
extend T::Sig
|
189
|
+
|
190
|
+
enums do
|
191
|
+
# @since 0.1.0
|
192
|
+
Error = new(1)
|
193
|
+
|
194
|
+
# @since 0.1.0
|
195
|
+
LicenseExpired = new(2)
|
196
|
+
|
197
|
+
# @since 0.1.0
|
198
|
+
LicenseAvailable = new(3)
|
199
|
+
|
200
|
+
# @since 0.1.0
|
201
|
+
TrialLicenseExpired = new(6)
|
202
|
+
end
|
203
|
+
|
204
|
+
# description returns the human-readable description of the
|
205
|
+
# result type.
|
206
|
+
#
|
207
|
+
# @since 0.1.0
|
208
|
+
sig {returns(String)}
|
209
|
+
def description
|
210
|
+
case self
|
211
|
+
when Error
|
212
|
+
"An error occurred"
|
213
|
+
when LicenseExpired
|
214
|
+
"The license expired"
|
215
|
+
when LicenseAvailable
|
216
|
+
"The license is still available"
|
217
|
+
when TrialLicenseExpired
|
218
|
+
"The trial license expired"
|
219
|
+
else
|
220
|
+
# :nocov:
|
221
|
+
# unreachable
|
222
|
+
# :nocov:
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# @since 0.1.0
|
228
|
+
class PackageType < T::Enum
|
229
|
+
enums do
|
230
|
+
# @since 0.1.0
|
231
|
+
OpenSource = new(0)
|
232
|
+
|
233
|
+
# @since 0.1.0
|
234
|
+
Enterprise = new(1)
|
235
|
+
|
236
|
+
# @since 0.1.0
|
237
|
+
Developer = new(2)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# @since 0.1.0
|
242
|
+
prop :result_type, T.nilable(ResultType), name: "resultType"
|
243
|
+
|
244
|
+
# @since 0.1.0
|
245
|
+
prop :package_type, T.nilable(PackageType), name: "packageType"
|
246
|
+
|
247
|
+
# @since 0.1.0
|
248
|
+
prop :build_date, T.nilable(String), name: "buildDate"
|
249
|
+
|
250
|
+
# @since 0.1.0
|
251
|
+
prop :build_version, T.nilable(String), name: "buildVersion"
|
252
|
+
|
253
|
+
# @since 0.1.0
|
254
|
+
prop :build_number, T.nilable(Integer), name: "buildNumber"
|
255
|
+
|
256
|
+
# @since 0.1.0
|
257
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(Server)}
|
258
|
+
def self.from_hash(hash, strict = nil)
|
259
|
+
super(hash, strict)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# @since 0.1.0
|
264
|
+
class Quota < T::Struct
|
265
|
+
extend T::Sig
|
266
|
+
|
267
|
+
# @since 0.1.0
|
268
|
+
class User < T::Struct
|
269
|
+
extend T::Sig
|
270
|
+
|
271
|
+
# @since 0.1.0
|
272
|
+
prop :userid, T.nilable(String), name: "userid"
|
273
|
+
|
274
|
+
# @since 0.1.0
|
275
|
+
prop :expire, T.nilable(String), name: "expire"
|
276
|
+
|
277
|
+
# @since 0.1.0
|
278
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(User)}
|
279
|
+
def self.from_hash(hash, strict = nil)
|
280
|
+
super(hash, strict)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
# @since 0.1.0
|
285
|
+
prop :users, T.nilable(T::Array[User]), name: "users"
|
286
|
+
|
287
|
+
# @since 0.1.0
|
288
|
+
prop :users_view, T.nilable(T::Array[User]), name: "users_view"
|
289
|
+
|
290
|
+
# @since 0.1.0
|
291
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(Quota)}
|
292
|
+
def self.from_hash(hash, strict = nil)
|
293
|
+
super(hash, strict)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# @since 0.1.0
|
298
|
+
class Meta < T::Struct
|
299
|
+
extend T::Sig
|
300
|
+
|
301
|
+
# @since 0.1.0
|
302
|
+
prop :title, T.nilable(String), name: "title"
|
303
|
+
|
304
|
+
# @since 0.1.0
|
305
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(Meta)}
|
306
|
+
def self.from_hash(hash, strict = nil)
|
307
|
+
super(hash, strict)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# @since 0.1.0
|
312
|
+
prop :c, T.nilable(C), name: "c"
|
313
|
+
|
314
|
+
# @since 0.1.0
|
315
|
+
prop :key, T.nilable(String), name: "key"
|
316
|
+
|
317
|
+
# @since 0.1.0
|
318
|
+
prop :users, T.nilable(T::Array[String]), name: "users"
|
319
|
+
|
320
|
+
# @since 0.1.0
|
321
|
+
prop :userdata, T.nilable(String), name: "userdata"
|
322
|
+
|
323
|
+
# @since 0.1.0
|
324
|
+
prop :license, T.nilable(License), name: "license"
|
325
|
+
|
326
|
+
# @since 0.1.0
|
327
|
+
prop :server, T.nilable(Server), name: "server"
|
328
|
+
|
329
|
+
# @since 0.1.0
|
330
|
+
prop :quota, T.nilable(Quota), name: "quota"
|
331
|
+
|
332
|
+
# @since 0.1.0
|
333
|
+
prop :meta, T.nilable(Meta), name: "meta"
|
334
|
+
|
335
|
+
# @since 0.1.0
|
336
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(Request)}
|
337
|
+
def self.from_hash(hash, strict = nil)
|
338
|
+
super(hash, strict)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
# Result is a class that represents the result of the command service
|
343
|
+
# call.
|
344
|
+
#
|
345
|
+
# @since 0.1.0
|
346
|
+
class Result < T::Struct
|
347
|
+
extend T::Sig
|
348
|
+
|
349
|
+
# @since 0.1.0
|
350
|
+
prop :key, T.nilable(String), name: "key"
|
351
|
+
|
352
|
+
# @since 0.1.0
|
353
|
+
prop :url, T.nilable(String), name: "url"
|
354
|
+
|
355
|
+
# @since 0.1.0
|
356
|
+
prop :keys, T.nilable(T::Array[String]), name: "keys"
|
357
|
+
|
358
|
+
# @since 0.1.0
|
359
|
+
prop :users, T.nilable(T::Array[String]), name: "users"
|
360
|
+
|
361
|
+
# @since 0.1.0
|
362
|
+
prop :version, T.nilable(String), name: "version"
|
363
|
+
|
364
|
+
# @since 0.1.0
|
365
|
+
sig {params(hash: T.untyped, strict: T.untyped).returns(Result)}
|
366
|
+
def self.from_hash(hash, strict = nil)
|
367
|
+
super(hash, strict)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
# do makes a request to the command service. It returns an empty
|
372
|
+
# result if an error occurs.
|
373
|
+
#
|
374
|
+
# @param r The request options.
|
375
|
+
# @return A tuple containing the result and the response.
|
376
|
+
# @since 0.1.0
|
377
|
+
sig {override.params(r: Request).returns([Result, Response])}
|
378
|
+
def do(r)
|
379
|
+
com, res = @client.post("coauthoring/CommandService.ashx", r.serialize)
|
380
|
+
if res.error
|
381
|
+
return [Result.new, res]
|
382
|
+
end
|
383
|
+
|
384
|
+
err = T.let(nil, T.untyped)
|
385
|
+
|
386
|
+
begin
|
387
|
+
if com && com.is_a?(Hash) && com.key?("error")
|
388
|
+
err = Error.from_serialized(com["error"])
|
389
|
+
if err == Error::None
|
390
|
+
err = nil
|
391
|
+
ret = Result.from_hash(com)
|
392
|
+
end
|
393
|
+
elsif com
|
394
|
+
ret = Result.from_hash(com)
|
395
|
+
else
|
396
|
+
ret = Result.new
|
397
|
+
end
|
398
|
+
rescue StandardError => e
|
399
|
+
err = e
|
400
|
+
end
|
401
|
+
|
402
|
+
if err
|
403
|
+
ret = Result.new
|
404
|
+
res = Response.new(
|
405
|
+
request: res.request,
|
406
|
+
response: res.response,
|
407
|
+
error: err,
|
408
|
+
)
|
409
|
+
end
|
410
|
+
|
411
|
+
[ret, res]
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|