ord-schema 0.3.40

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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # JavaScript wrappers for the Open Reaction Database schema
2
+
3
+ See https://open-reaction-database.org for more information.
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2022 Open Reaction Database Project Authors
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
+ "use strict";
18
+ exports.dataset_pb = require('./proto/dataset_pb');
19
+ exports.reaction_pb = require('./proto/reaction_pb');
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "ord-schema",
3
+ "version": "0.3.40",
4
+ "description": "Schema for the Open Reaction Database",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "jest"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/open-reaction-database/ord-schema.git"
12
+ },
13
+ "author": "Open Reaction Database Project Authors",
14
+ "license": "Apache-2.0",
15
+ "bugs": {
16
+ "url": "https://github.com/open-reaction-database/ord-schema/issues"
17
+ },
18
+ "homepage": "https://open-reaction-database.org",
19
+ "dependencies": {
20
+ "google-protobuf": "<3.20",
21
+ "jest": "^29.3.1"
22
+ }
23
+ }
@@ -0,0 +1,626 @@
1
+ /**
2
+ * Copyright 2022 Open Reaction Database Project Authors
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
+ // source: ord-schema/proto/dataset.proto
18
+ /**
19
+ * @fileoverview
20
+ * @enhanceable
21
+ * @suppress {missingRequire} reports error on implicit type usages.
22
+ * @suppress {messageConventions} JS Compiler reports an error if a variable or
23
+ * field starts with 'MSG_' and isn't a translatable message.
24
+ * @public
25
+ */
26
+ // GENERATED CODE -- DO NOT EDIT!
27
+ /* eslint-disable */
28
+ // @ts-nocheck
29
+
30
+ var jspb = require('google-protobuf');
31
+ var goog = jspb;
32
+ var global = (function() {
33
+ if (this) { return this; }
34
+ if (typeof window !== 'undefined') { return window; }
35
+ if (typeof global !== 'undefined') { return global; }
36
+ if (typeof self !== 'undefined') { return self; }
37
+ return Function('return this')();
38
+ }.call(null));
39
+
40
+ var ord$schema_proto_reaction_pb = require('../../ord-schema/proto/reaction_pb.js');
41
+ goog.object.extend(proto, ord$schema_proto_reaction_pb);
42
+ goog.exportSymbol('proto.ord.Dataset', null, global);
43
+ goog.exportSymbol('proto.ord.DatasetExample', null, global);
44
+ /**
45
+ * Generated by JsPbCodeGenerator.
46
+ * @param {Array=} opt_data Optional initial data array, typically from a
47
+ * server response, or constructed directly in Javascript. The array is used
48
+ * in place and becomes part of the constructed object. It is not cloned.
49
+ * If no data is provided, the constructed object will be empty, but still
50
+ * valid.
51
+ * @extends {jspb.Message}
52
+ * @constructor
53
+ */
54
+ proto.ord.Dataset = function(opt_data) {
55
+ jspb.Message.initialize(this, opt_data, 0, -1, proto.ord.Dataset.repeatedFields_, null);
56
+ };
57
+ goog.inherits(proto.ord.Dataset, jspb.Message);
58
+ if (goog.DEBUG && !COMPILED) {
59
+ /**
60
+ * @public
61
+ * @override
62
+ */
63
+ proto.ord.Dataset.displayName = 'proto.ord.Dataset';
64
+ }
65
+ /**
66
+ * Generated by JsPbCodeGenerator.
67
+ * @param {Array=} opt_data Optional initial data array, typically from a
68
+ * server response, or constructed directly in Javascript. The array is used
69
+ * in place and becomes part of the constructed object. It is not cloned.
70
+ * If no data is provided, the constructed object will be empty, but still
71
+ * valid.
72
+ * @extends {jspb.Message}
73
+ * @constructor
74
+ */
75
+ proto.ord.DatasetExample = function(opt_data) {
76
+ jspb.Message.initialize(this, opt_data, 0, -1, null, null);
77
+ };
78
+ goog.inherits(proto.ord.DatasetExample, jspb.Message);
79
+ if (goog.DEBUG && !COMPILED) {
80
+ /**
81
+ * @public
82
+ * @override
83
+ */
84
+ proto.ord.DatasetExample.displayName = 'proto.ord.DatasetExample';
85
+ }
86
+
87
+ /**
88
+ * List of repeated fields within this message type.
89
+ * @private {!Array<number>}
90
+ * @const
91
+ */
92
+ proto.ord.Dataset.repeatedFields_ = [3,4];
93
+
94
+
95
+
96
+ if (jspb.Message.GENERATE_TO_OBJECT) {
97
+ /**
98
+ * Creates an object representation of this proto.
99
+ * Field names that are reserved in JavaScript and will be renamed to pb_name.
100
+ * Optional fields that are not set will be set to undefined.
101
+ * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
102
+ * For the list of reserved names please see:
103
+ * net/proto2/compiler/js/internal/generator.cc#kKeyword.
104
+ * @param {boolean=} opt_includeInstance Deprecated. whether to include the
105
+ * JSPB instance for transitional soy proto support:
106
+ * http://goto/soy-param-migration
107
+ * @return {!Object}
108
+ */
109
+ proto.ord.Dataset.prototype.toObject = function(opt_includeInstance) {
110
+ return proto.ord.Dataset.toObject(opt_includeInstance, this);
111
+ };
112
+
113
+
114
+ /**
115
+ * Static version of the {@see toObject} method.
116
+ * @param {boolean|undefined} includeInstance Deprecated. Whether to include
117
+ * the JSPB instance for transitional soy proto support:
118
+ * http://goto/soy-param-migration
119
+ * @param {!proto.ord.Dataset} msg The msg instance to transform.
120
+ * @return {!Object}
121
+ * @suppress {unusedLocalVariables} f is only used for nested messages
122
+ */
123
+ proto.ord.Dataset.toObject = function(includeInstance, msg) {
124
+ var f, obj = {
125
+ name: jspb.Message.getFieldWithDefault(msg, 1, ""),
126
+ description: jspb.Message.getFieldWithDefault(msg, 2, ""),
127
+ reactionsList: jspb.Message.toObjectList(msg.getReactionsList(),
128
+ ord$schema_proto_reaction_pb.Reaction.toObject, includeInstance),
129
+ reactionIdsList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f,
130
+ datasetId: jspb.Message.getFieldWithDefault(msg, 5, "")
131
+ };
132
+
133
+ if (includeInstance) {
134
+ obj.$jspbMessageInstance = msg;
135
+ }
136
+ return obj;
137
+ };
138
+ }
139
+
140
+
141
+ /**
142
+ * Deserializes binary data (in protobuf wire format).
143
+ * @param {jspb.ByteSource} bytes The bytes to deserialize.
144
+ * @return {!proto.ord.Dataset}
145
+ */
146
+ proto.ord.Dataset.deserializeBinary = function(bytes) {
147
+ var reader = new jspb.BinaryReader(bytes);
148
+ var msg = new proto.ord.Dataset;
149
+ return proto.ord.Dataset.deserializeBinaryFromReader(msg, reader);
150
+ };
151
+
152
+
153
+ /**
154
+ * Deserializes binary data (in protobuf wire format) from the
155
+ * given reader into the given message object.
156
+ * @param {!proto.ord.Dataset} msg The message object to deserialize into.
157
+ * @param {!jspb.BinaryReader} reader The BinaryReader to use.
158
+ * @return {!proto.ord.Dataset}
159
+ */
160
+ proto.ord.Dataset.deserializeBinaryFromReader = function(msg, reader) {
161
+ while (reader.nextField()) {
162
+ if (reader.isEndGroup()) {
163
+ break;
164
+ }
165
+ var field = reader.getFieldNumber();
166
+ switch (field) {
167
+ case 1:
168
+ var value = /** @type {string} */ (reader.readString());
169
+ msg.setName(value);
170
+ break;
171
+ case 2:
172
+ var value = /** @type {string} */ (reader.readString());
173
+ msg.setDescription(value);
174
+ break;
175
+ case 3:
176
+ var value = new ord$schema_proto_reaction_pb.Reaction;
177
+ reader.readMessage(value,ord$schema_proto_reaction_pb.Reaction.deserializeBinaryFromReader);
178
+ msg.addReactions(value);
179
+ break;
180
+ case 4:
181
+ var value = /** @type {string} */ (reader.readString());
182
+ msg.addReactionIds(value);
183
+ break;
184
+ case 5:
185
+ var value = /** @type {string} */ (reader.readString());
186
+ msg.setDatasetId(value);
187
+ break;
188
+ default:
189
+ reader.skipField();
190
+ break;
191
+ }
192
+ }
193
+ return msg;
194
+ };
195
+
196
+
197
+ /**
198
+ * Serializes the message to binary data (in protobuf wire format).
199
+ * @return {!Uint8Array}
200
+ */
201
+ proto.ord.Dataset.prototype.serializeBinary = function() {
202
+ var writer = new jspb.BinaryWriter();
203
+ proto.ord.Dataset.serializeBinaryToWriter(this, writer);
204
+ return writer.getResultBuffer();
205
+ };
206
+
207
+
208
+ /**
209
+ * Serializes the given message to binary data (in protobuf wire
210
+ * format), writing to the given BinaryWriter.
211
+ * @param {!proto.ord.Dataset} message
212
+ * @param {!jspb.BinaryWriter} writer
213
+ * @suppress {unusedLocalVariables} f is only used for nested messages
214
+ */
215
+ proto.ord.Dataset.serializeBinaryToWriter = function(message, writer) {
216
+ var f = undefined;
217
+ f = message.getName();
218
+ if (f.length > 0) {
219
+ writer.writeString(
220
+ 1,
221
+ f
222
+ );
223
+ }
224
+ f = message.getDescription();
225
+ if (f.length > 0) {
226
+ writer.writeString(
227
+ 2,
228
+ f
229
+ );
230
+ }
231
+ f = message.getReactionsList();
232
+ if (f.length > 0) {
233
+ writer.writeRepeatedMessage(
234
+ 3,
235
+ f,
236
+ ord$schema_proto_reaction_pb.Reaction.serializeBinaryToWriter
237
+ );
238
+ }
239
+ f = message.getReactionIdsList();
240
+ if (f.length > 0) {
241
+ writer.writeRepeatedString(
242
+ 4,
243
+ f
244
+ );
245
+ }
246
+ f = message.getDatasetId();
247
+ if (f.length > 0) {
248
+ writer.writeString(
249
+ 5,
250
+ f
251
+ );
252
+ }
253
+ };
254
+
255
+
256
+ /**
257
+ * optional string name = 1;
258
+ * @return {string}
259
+ */
260
+ proto.ord.Dataset.prototype.getName = function() {
261
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
262
+ };
263
+
264
+
265
+ /**
266
+ * @param {string} value
267
+ * @return {!proto.ord.Dataset} returns this
268
+ */
269
+ proto.ord.Dataset.prototype.setName = function(value) {
270
+ return jspb.Message.setProto3StringField(this, 1, value);
271
+ };
272
+
273
+
274
+ /**
275
+ * optional string description = 2;
276
+ * @return {string}
277
+ */
278
+ proto.ord.Dataset.prototype.getDescription = function() {
279
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
280
+ };
281
+
282
+
283
+ /**
284
+ * @param {string} value
285
+ * @return {!proto.ord.Dataset} returns this
286
+ */
287
+ proto.ord.Dataset.prototype.setDescription = function(value) {
288
+ return jspb.Message.setProto3StringField(this, 2, value);
289
+ };
290
+
291
+
292
+ /**
293
+ * repeated Reaction reactions = 3;
294
+ * @return {!Array<!proto.ord.Reaction>}
295
+ */
296
+ proto.ord.Dataset.prototype.getReactionsList = function() {
297
+ return /** @type{!Array<!proto.ord.Reaction>} */ (
298
+ jspb.Message.getRepeatedWrapperField(this, ord$schema_proto_reaction_pb.Reaction, 3));
299
+ };
300
+
301
+
302
+ /**
303
+ * @param {!Array<!proto.ord.Reaction>} value
304
+ * @return {!proto.ord.Dataset} returns this
305
+ */
306
+ proto.ord.Dataset.prototype.setReactionsList = function(value) {
307
+ return jspb.Message.setRepeatedWrapperField(this, 3, value);
308
+ };
309
+
310
+
311
+ /**
312
+ * @param {!proto.ord.Reaction=} opt_value
313
+ * @param {number=} opt_index
314
+ * @return {!proto.ord.Reaction}
315
+ */
316
+ proto.ord.Dataset.prototype.addReactions = function(opt_value, opt_index) {
317
+ return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.ord.Reaction, opt_index);
318
+ };
319
+
320
+
321
+ /**
322
+ * Clears the list making it empty but non-null.
323
+ * @return {!proto.ord.Dataset} returns this
324
+ */
325
+ proto.ord.Dataset.prototype.clearReactionsList = function() {
326
+ return this.setReactionsList([]);
327
+ };
328
+
329
+
330
+ /**
331
+ * repeated string reaction_ids = 4;
332
+ * @return {!Array<string>}
333
+ */
334
+ proto.ord.Dataset.prototype.getReactionIdsList = function() {
335
+ return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 4));
336
+ };
337
+
338
+
339
+ /**
340
+ * @param {!Array<string>} value
341
+ * @return {!proto.ord.Dataset} returns this
342
+ */
343
+ proto.ord.Dataset.prototype.setReactionIdsList = function(value) {
344
+ return jspb.Message.setField(this, 4, value || []);
345
+ };
346
+
347
+
348
+ /**
349
+ * @param {string} value
350
+ * @param {number=} opt_index
351
+ * @return {!proto.ord.Dataset} returns this
352
+ */
353
+ proto.ord.Dataset.prototype.addReactionIds = function(value, opt_index) {
354
+ return jspb.Message.addToRepeatedField(this, 4, value, opt_index);
355
+ };
356
+
357
+
358
+ /**
359
+ * Clears the list making it empty but non-null.
360
+ * @return {!proto.ord.Dataset} returns this
361
+ */
362
+ proto.ord.Dataset.prototype.clearReactionIdsList = function() {
363
+ return this.setReactionIdsList([]);
364
+ };
365
+
366
+
367
+ /**
368
+ * optional string dataset_id = 5;
369
+ * @return {string}
370
+ */
371
+ proto.ord.Dataset.prototype.getDatasetId = function() {
372
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
373
+ };
374
+
375
+
376
+ /**
377
+ * @param {string} value
378
+ * @return {!proto.ord.Dataset} returns this
379
+ */
380
+ proto.ord.Dataset.prototype.setDatasetId = function(value) {
381
+ return jspb.Message.setProto3StringField(this, 5, value);
382
+ };
383
+
384
+
385
+
386
+
387
+
388
+ if (jspb.Message.GENERATE_TO_OBJECT) {
389
+ /**
390
+ * Creates an object representation of this proto.
391
+ * Field names that are reserved in JavaScript and will be renamed to pb_name.
392
+ * Optional fields that are not set will be set to undefined.
393
+ * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
394
+ * For the list of reserved names please see:
395
+ * net/proto2/compiler/js/internal/generator.cc#kKeyword.
396
+ * @param {boolean=} opt_includeInstance Deprecated. whether to include the
397
+ * JSPB instance for transitional soy proto support:
398
+ * http://goto/soy-param-migration
399
+ * @return {!Object}
400
+ */
401
+ proto.ord.DatasetExample.prototype.toObject = function(opt_includeInstance) {
402
+ return proto.ord.DatasetExample.toObject(opt_includeInstance, this);
403
+ };
404
+
405
+
406
+ /**
407
+ * Static version of the {@see toObject} method.
408
+ * @param {boolean|undefined} includeInstance Deprecated. Whether to include
409
+ * the JSPB instance for transitional soy proto support:
410
+ * http://goto/soy-param-migration
411
+ * @param {!proto.ord.DatasetExample} msg The msg instance to transform.
412
+ * @return {!Object}
413
+ * @suppress {unusedLocalVariables} f is only used for nested messages
414
+ */
415
+ proto.ord.DatasetExample.toObject = function(includeInstance, msg) {
416
+ var f, obj = {
417
+ datasetId: jspb.Message.getFieldWithDefault(msg, 1, ""),
418
+ description: jspb.Message.getFieldWithDefault(msg, 2, ""),
419
+ url: jspb.Message.getFieldWithDefault(msg, 3, ""),
420
+ created: (f = msg.getCreated()) && ord$schema_proto_reaction_pb.RecordEvent.toObject(includeInstance, f)
421
+ };
422
+
423
+ if (includeInstance) {
424
+ obj.$jspbMessageInstance = msg;
425
+ }
426
+ return obj;
427
+ };
428
+ }
429
+
430
+
431
+ /**
432
+ * Deserializes binary data (in protobuf wire format).
433
+ * @param {jspb.ByteSource} bytes The bytes to deserialize.
434
+ * @return {!proto.ord.DatasetExample}
435
+ */
436
+ proto.ord.DatasetExample.deserializeBinary = function(bytes) {
437
+ var reader = new jspb.BinaryReader(bytes);
438
+ var msg = new proto.ord.DatasetExample;
439
+ return proto.ord.DatasetExample.deserializeBinaryFromReader(msg, reader);
440
+ };
441
+
442
+
443
+ /**
444
+ * Deserializes binary data (in protobuf wire format) from the
445
+ * given reader into the given message object.
446
+ * @param {!proto.ord.DatasetExample} msg The message object to deserialize into.
447
+ * @param {!jspb.BinaryReader} reader The BinaryReader to use.
448
+ * @return {!proto.ord.DatasetExample}
449
+ */
450
+ proto.ord.DatasetExample.deserializeBinaryFromReader = function(msg, reader) {
451
+ while (reader.nextField()) {
452
+ if (reader.isEndGroup()) {
453
+ break;
454
+ }
455
+ var field = reader.getFieldNumber();
456
+ switch (field) {
457
+ case 1:
458
+ var value = /** @type {string} */ (reader.readString());
459
+ msg.setDatasetId(value);
460
+ break;
461
+ case 2:
462
+ var value = /** @type {string} */ (reader.readString());
463
+ msg.setDescription(value);
464
+ break;
465
+ case 3:
466
+ var value = /** @type {string} */ (reader.readString());
467
+ msg.setUrl(value);
468
+ break;
469
+ case 4:
470
+ var value = new ord$schema_proto_reaction_pb.RecordEvent;
471
+ reader.readMessage(value,ord$schema_proto_reaction_pb.RecordEvent.deserializeBinaryFromReader);
472
+ msg.setCreated(value);
473
+ break;
474
+ default:
475
+ reader.skipField();
476
+ break;
477
+ }
478
+ }
479
+ return msg;
480
+ };
481
+
482
+
483
+ /**
484
+ * Serializes the message to binary data (in protobuf wire format).
485
+ * @return {!Uint8Array}
486
+ */
487
+ proto.ord.DatasetExample.prototype.serializeBinary = function() {
488
+ var writer = new jspb.BinaryWriter();
489
+ proto.ord.DatasetExample.serializeBinaryToWriter(this, writer);
490
+ return writer.getResultBuffer();
491
+ };
492
+
493
+
494
+ /**
495
+ * Serializes the given message to binary data (in protobuf wire
496
+ * format), writing to the given BinaryWriter.
497
+ * @param {!proto.ord.DatasetExample} message
498
+ * @param {!jspb.BinaryWriter} writer
499
+ * @suppress {unusedLocalVariables} f is only used for nested messages
500
+ */
501
+ proto.ord.DatasetExample.serializeBinaryToWriter = function(message, writer) {
502
+ var f = undefined;
503
+ f = message.getDatasetId();
504
+ if (f.length > 0) {
505
+ writer.writeString(
506
+ 1,
507
+ f
508
+ );
509
+ }
510
+ f = message.getDescription();
511
+ if (f.length > 0) {
512
+ writer.writeString(
513
+ 2,
514
+ f
515
+ );
516
+ }
517
+ f = message.getUrl();
518
+ if (f.length > 0) {
519
+ writer.writeString(
520
+ 3,
521
+ f
522
+ );
523
+ }
524
+ f = message.getCreated();
525
+ if (f != null) {
526
+ writer.writeMessage(
527
+ 4,
528
+ f,
529
+ ord$schema_proto_reaction_pb.RecordEvent.serializeBinaryToWriter
530
+ );
531
+ }
532
+ };
533
+
534
+
535
+ /**
536
+ * optional string dataset_id = 1;
537
+ * @return {string}
538
+ */
539
+ proto.ord.DatasetExample.prototype.getDatasetId = function() {
540
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
541
+ };
542
+
543
+
544
+ /**
545
+ * @param {string} value
546
+ * @return {!proto.ord.DatasetExample} returns this
547
+ */
548
+ proto.ord.DatasetExample.prototype.setDatasetId = function(value) {
549
+ return jspb.Message.setProto3StringField(this, 1, value);
550
+ };
551
+
552
+
553
+ /**
554
+ * optional string description = 2;
555
+ * @return {string}
556
+ */
557
+ proto.ord.DatasetExample.prototype.getDescription = function() {
558
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
559
+ };
560
+
561
+
562
+ /**
563
+ * @param {string} value
564
+ * @return {!proto.ord.DatasetExample} returns this
565
+ */
566
+ proto.ord.DatasetExample.prototype.setDescription = function(value) {
567
+ return jspb.Message.setProto3StringField(this, 2, value);
568
+ };
569
+
570
+
571
+ /**
572
+ * optional string url = 3;
573
+ * @return {string}
574
+ */
575
+ proto.ord.DatasetExample.prototype.getUrl = function() {
576
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
577
+ };
578
+
579
+
580
+ /**
581
+ * @param {string} value
582
+ * @return {!proto.ord.DatasetExample} returns this
583
+ */
584
+ proto.ord.DatasetExample.prototype.setUrl = function(value) {
585
+ return jspb.Message.setProto3StringField(this, 3, value);
586
+ };
587
+
588
+
589
+ /**
590
+ * optional RecordEvent created = 4;
591
+ * @return {?proto.ord.RecordEvent}
592
+ */
593
+ proto.ord.DatasetExample.prototype.getCreated = function() {
594
+ return /** @type{?proto.ord.RecordEvent} */ (
595
+ jspb.Message.getWrapperField(this, ord$schema_proto_reaction_pb.RecordEvent, 4));
596
+ };
597
+
598
+
599
+ /**
600
+ * @param {?proto.ord.RecordEvent|undefined} value
601
+ * @return {!proto.ord.DatasetExample} returns this
602
+ */
603
+ proto.ord.DatasetExample.prototype.setCreated = function(value) {
604
+ return jspb.Message.setWrapperField(this, 4, value);
605
+ };
606
+
607
+
608
+ /**
609
+ * Clears the message field making it undefined.
610
+ * @return {!proto.ord.DatasetExample} returns this
611
+ */
612
+ proto.ord.DatasetExample.prototype.clearCreated = function() {
613
+ return this.setCreated(undefined);
614
+ };
615
+
616
+
617
+ /**
618
+ * Returns whether this field is set.
619
+ * @return {boolean}
620
+ */
621
+ proto.ord.DatasetExample.prototype.hasCreated = function() {
622
+ return jspb.Message.getField(this, 4) != null;
623
+ };
624
+
625
+
626
+ goog.object.extend(exports, proto.ord);
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright 2022 Open Reaction Database Project Authors
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
+ const ord_schema = require('..');
18
+
19
+ test('round-trip', () => {
20
+ const dataset = new ord_schema.dataset_pb.Dataset();
21
+ dataset.setName('test');
22
+ dataset.setDescription('test dataset');
23
+ // Add a reaction directly to the dataset.
24
+ const reaction1 = dataset.addReactions();
25
+ const identifier1 = reaction1.addIdentifiers();
26
+ identifier1.setValue('C(C)Cl.Br>>C(C)Br.Cl');
27
+ identifier1.setType(ord_schema.reaction_pb.ReactionIdentifier.ReactionIdentifierType.REACTION_SMILES);
28
+ // Copy a reaction created elsewhere.
29
+ const reaction2 = new ord_schema.reaction_pb.Reaction();
30
+ const identifier2 = reaction2.addIdentifiers();
31
+ identifier2.setValue('amide coupling');
32
+ identifier2.setType(ord_schema.reaction_pb.ReactionIdentifier.ReactionIdentifierType.NAME);
33
+ dataset.addReactions(reaction2);
34
+ const serialized = dataset.serializeBinary();
35
+ const other = ord_schema.dataset_pb.Dataset.deserializeBinary(serialized);
36
+ expect(other.getName()).toBe('test');
37
+ expect(other.getDescription()).toBe('test dataset');
38
+ expect(other.getReactionsList()).toHaveLength(2);
39
+ expect(other.getReactionsList()[0].getIdentifiersList()[0].getType()).toBe(ord_schema.reaction_pb.ReactionIdentifier.ReactionIdentifierType.REACTION_SMILES);
40
+ expect(other.getReactionsList()[1].getIdentifiersList()[0].getType()).toBe(ord_schema.reaction_pb.ReactionIdentifier.ReactionIdentifierType.NAME);
41
+ });