@fintekkers/ledger-models 0.2.4 → 0.3.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.
- package/node/fintekkers/models/security/identifier/identifier_type_pb.d.ts +1 -0
- package/node/fintekkers/models/security/identifier/identifier_type_pb.js +1 -0
- package/node/fintekkers/models/security/security_pb.d.ts +42 -123
- package/node/fintekkers/models/security/security_pb.js +279 -974
- package/node/fintekkers/requests/security/query_security_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/security/query_security_request_pb.js +31 -1
- package/node/wrappers/models/security/identifier.test.js +2 -0
- package/node/wrappers/models/security/identifier.test.js.map +1 -1
- package/node/wrappers/models/security/identifier.test.ts +2 -0
- package/node/wrappers/models/security/security-roundtrip.test.js +96 -12
- package/node/wrappers/models/security/security-roundtrip.test.js.map +1 -1
- package/node/wrappers/models/security/security-roundtrip.test.ts +97 -0
- package/node/wrappers/models/security/security.d.ts +29 -5
- package/node/wrappers/models/security/security.js +66 -10
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +70 -11
- package/package.json +1 -1
- package/node/fintekkers/models/security/security_id_pb.d.ts +0 -31
- package/node/fintekkers/models/security/security_id_pb.js +0 -199
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
4
|
+
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
4
5
|
const datetime_1 = require("../utils/datetime");
|
|
5
6
|
const uuid_1 = require("../utils/uuid");
|
|
6
7
|
const date_1 = require("../utils/date");
|
|
@@ -9,6 +10,58 @@ class Security {
|
|
|
9
10
|
constructor(proto) {
|
|
10
11
|
this.proto = proto;
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Build a SecurityProto link reference (is_link=true) with uuid and as_of
|
|
15
|
+
* populated. Use this whenever you embed a Security inside another message
|
|
16
|
+
* that itself carries an as_of (Position, Transaction, Price, etc.) — the
|
|
17
|
+
* link MUST carry the same as_of as the parent so the resolver hydrates
|
|
18
|
+
* the correct point-in-time vintage. See docs/adr/is_link_pattern.md.
|
|
19
|
+
*
|
|
20
|
+
* @param uuid The Security UUID to reference.
|
|
21
|
+
* @param asOf The as-of timestamp; required. For "always latest" semantics
|
|
22
|
+
* use linkOfLatest(uuid) instead.
|
|
23
|
+
*/
|
|
24
|
+
static linkOf(uuid, asOf) {
|
|
25
|
+
if (!uuid)
|
|
26
|
+
throw new Error("uuid is required for linkOf");
|
|
27
|
+
if (!asOf)
|
|
28
|
+
throw new Error("asOf is required for linkOf; use linkOfLatest(uuid) for latest-version semantics");
|
|
29
|
+
const proto = new security_pb_1.SecurityProto();
|
|
30
|
+
proto.setIsLink(true);
|
|
31
|
+
proto.setUuid(Security._uuidToProto(uuid));
|
|
32
|
+
proto.setAsOf(Security._zonedDateTimeToProto(asOf));
|
|
33
|
+
return proto;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a SecurityProto link reference (is_link=true) with only uuid set.
|
|
37
|
+
* Resolution returns the latest version. Explicit escape hatch — most
|
|
38
|
+
* callers should prefer linkOf(uuid, asOf).
|
|
39
|
+
*/
|
|
40
|
+
static linkOfLatest(uuid) {
|
|
41
|
+
if (!uuid)
|
|
42
|
+
throw new Error("uuid is required for linkOfLatest");
|
|
43
|
+
const proto = new security_pb_1.SecurityProto();
|
|
44
|
+
proto.setIsLink(true);
|
|
45
|
+
proto.setUuid(Security._uuidToProto(uuid));
|
|
46
|
+
return proto;
|
|
47
|
+
}
|
|
48
|
+
static _uuidToProto(uuid) {
|
|
49
|
+
return uuid.toUUIDProto();
|
|
50
|
+
}
|
|
51
|
+
static _zonedDateTimeToProto(asOf) {
|
|
52
|
+
return asOf.toProto();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Throws if this Security is in link mode. Use to guard accessors that
|
|
56
|
+
* would otherwise return proto3 default values on a link reference.
|
|
57
|
+
*/
|
|
58
|
+
assertNotLink(accessor) {
|
|
59
|
+
if (this.proto.getIsLink()) {
|
|
60
|
+
throw new Error(`Cannot read ${accessor} on a link-mode Security (is_link=true). `
|
|
61
|
+
+ `Resolve via SecurityService.GetByIds first. `
|
|
62
|
+
+ `See docs/adr/is_link_pattern.md.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
12
65
|
/**
|
|
13
66
|
* Factory method to create the appropriate Security subclass based on security type
|
|
14
67
|
*/
|
|
@@ -98,17 +151,21 @@ class Security {
|
|
|
98
151
|
return new datetime_1.ZonedDateTime(asOf);
|
|
99
152
|
}
|
|
100
153
|
getAssetClass() {
|
|
154
|
+
this.assertNotLink('assetClass');
|
|
101
155
|
return this.proto.getAssetClass();
|
|
102
156
|
}
|
|
103
157
|
getProductClass() {
|
|
158
|
+
this.assertNotLink('productClass');
|
|
104
159
|
throw new Error('Not implemented yet. See Java implementation for reference');
|
|
105
160
|
}
|
|
106
161
|
getProductType() {
|
|
162
|
+
this.assertNotLink('productType');
|
|
107
163
|
const securityType = this.proto.getProductType();
|
|
108
164
|
const securityTypeString = Object.keys(product_type_pb_1.ProductTypeProto).find(key => product_type_pb_1.ProductTypeProto[key] === securityType);
|
|
109
165
|
return securityTypeString || 'UNKNOWN_SECURITY_TYPE';
|
|
110
166
|
}
|
|
111
167
|
getSecurityID() {
|
|
168
|
+
this.assertNotLink('securityId');
|
|
112
169
|
const identifier = this.proto.getIdentifier();
|
|
113
170
|
if (!identifier)
|
|
114
171
|
throw new Error("Identifier is required");
|
|
@@ -127,6 +184,7 @@ class Security {
|
|
|
127
184
|
* calling BondSecurity.getIssueDate() (which returns LocalDate, not null).
|
|
128
185
|
*/
|
|
129
186
|
getIssueDate() {
|
|
187
|
+
this.assertNotLink('issueDate');
|
|
130
188
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
131
189
|
const bond = this.getBondLikeDetails();
|
|
132
190
|
const date = bond ? bond.getIssueDate() : this.proto.getIssueDate();
|
|
@@ -145,6 +203,7 @@ class Security {
|
|
|
145
203
|
* and TS will catch the misuse at compile time.
|
|
146
204
|
*/
|
|
147
205
|
getMaturityDate() {
|
|
206
|
+
this.assertNotLink('maturityDate');
|
|
148
207
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
149
208
|
const bond = this.getBondLikeDetails();
|
|
150
209
|
const date = bond ? bond.getMaturityDate() : this.proto.getMaturityDate();
|
|
@@ -153,22 +212,19 @@ class Security {
|
|
|
153
212
|
return new date_1.LocalDate(date);
|
|
154
213
|
}
|
|
155
214
|
/**
|
|
156
|
-
* Returns the
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* (e.g. when JS codegen hasn't been updated).
|
|
215
|
+
* Returns the canonical bond_details sub-message if set, else undefined.
|
|
216
|
+
* v0.3.0 collapsed the prior 3-arm bond/tips/frn oneof into a single
|
|
217
|
+
* top-level bond_details — TIPS and FRN extras now live in their own
|
|
218
|
+
* tips_extension / frn_extension fields.
|
|
161
219
|
*/
|
|
162
220
|
getBondLikeDetails() {
|
|
163
|
-
|
|
221
|
+
var _a;
|
|
164
222
|
if (typeof this.proto.getBondDetails !== 'function')
|
|
165
223
|
return undefined;
|
|
166
|
-
return this.proto.getBondDetails()
|
|
167
|
-
this.proto.getTipsDetails() ||
|
|
168
|
-
this.proto.getFrnDetails() ||
|
|
169
|
-
undefined;
|
|
224
|
+
return (_a = this.proto.getBondDetails()) !== null && _a !== void 0 ? _a : undefined;
|
|
170
225
|
}
|
|
171
226
|
getIssuerName() {
|
|
227
|
+
this.assertNotLink('issuerName');
|
|
172
228
|
return this.proto.getIssuerName();
|
|
173
229
|
}
|
|
174
230
|
equals(other) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sourceRoot":"","sources":["security.ts"],"names":[],"mappings":";;AAAA,2EAA0E;
|
|
1
|
+
{"version":3,"file":"security.js","sourceR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C;CACF;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FieldProto } from "../../../fintekkers/models/position/field_pb";
|
|
2
2
|
import { IdentifierProto } from "../../../fintekkers/models/security/identifier/identifier_pb";
|
|
3
3
|
import { SecurityProto } from "../../../fintekkers/models/security/security_pb";
|
|
4
|
+
import { UUIDProto } from "../../../fintekkers/models/util/uuid_pb";
|
|
5
|
+
import { LocalTimestampProto } from "../../../fintekkers/models/util/local_timestamp_pb";
|
|
4
6
|
import { ZonedDateTime } from "../utils/datetime";
|
|
5
7
|
import { UUID } from "../utils/uuid";
|
|
6
8
|
import { LocalDate } from "../utils/date";
|
|
@@ -13,6 +15,62 @@ class Security {
|
|
|
13
15
|
this.proto = proto;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Build a SecurityProto link reference (is_link=true) with uuid and as_of
|
|
20
|
+
* populated. Use this whenever you embed a Security inside another message
|
|
21
|
+
* that itself carries an as_of (Position, Transaction, Price, etc.) — the
|
|
22
|
+
* link MUST carry the same as_of as the parent so the resolver hydrates
|
|
23
|
+
* the correct point-in-time vintage. See docs/adr/is_link_pattern.md.
|
|
24
|
+
*
|
|
25
|
+
* @param uuid The Security UUID to reference.
|
|
26
|
+
* @param asOf The as-of timestamp; required. For "always latest" semantics
|
|
27
|
+
* use linkOfLatest(uuid) instead.
|
|
28
|
+
*/
|
|
29
|
+
static linkOf(uuid: UUID, asOf: ZonedDateTime): SecurityProto {
|
|
30
|
+
if (!uuid) throw new Error("uuid is required for linkOf");
|
|
31
|
+
if (!asOf) throw new Error("asOf is required for linkOf; use linkOfLatest(uuid) for latest-version semantics");
|
|
32
|
+
const proto = new SecurityProto();
|
|
33
|
+
proto.setIsLink(true);
|
|
34
|
+
proto.setUuid(Security._uuidToProto(uuid));
|
|
35
|
+
proto.setAsOf(Security._zonedDateTimeToProto(asOf));
|
|
36
|
+
return proto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Build a SecurityProto link reference (is_link=true) with only uuid set.
|
|
41
|
+
* Resolution returns the latest version. Explicit escape hatch — most
|
|
42
|
+
* callers should prefer linkOf(uuid, asOf).
|
|
43
|
+
*/
|
|
44
|
+
static linkOfLatest(uuid: UUID): SecurityProto {
|
|
45
|
+
if (!uuid) throw new Error("uuid is required for linkOfLatest");
|
|
46
|
+
const proto = new SecurityProto();
|
|
47
|
+
proto.setIsLink(true);
|
|
48
|
+
proto.setUuid(Security._uuidToProto(uuid));
|
|
49
|
+
return proto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private static _uuidToProto(uuid: UUID): UUIDProto {
|
|
53
|
+
return uuid.toUUIDProto();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private static _zonedDateTimeToProto(asOf: ZonedDateTime): LocalTimestampProto {
|
|
57
|
+
return asOf.toProto();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Throws if this Security is in link mode. Use to guard accessors that
|
|
62
|
+
* would otherwise return proto3 default values on a link reference.
|
|
63
|
+
*/
|
|
64
|
+
private assertNotLink(accessor: string): void {
|
|
65
|
+
if (this.proto.getIsLink()) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Cannot read ${accessor} on a link-mode Security (is_link=true). `
|
|
68
|
+
+ `Resolve via SecurityService.GetByIds first. `
|
|
69
|
+
+ `See docs/adr/is_link_pattern.md.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
16
74
|
/**
|
|
17
75
|
* Factory method to create the appropriate Security subclass based on security type
|
|
18
76
|
*/
|
|
@@ -109,14 +167,17 @@ class Security {
|
|
|
109
167
|
}
|
|
110
168
|
|
|
111
169
|
getAssetClass(): string {
|
|
170
|
+
this.assertNotLink('assetClass');
|
|
112
171
|
return this.proto.getAssetClass();
|
|
113
172
|
}
|
|
114
173
|
|
|
115
174
|
getProductClass(): string {
|
|
175
|
+
this.assertNotLink('productClass');
|
|
116
176
|
throw new Error('Not implemented yet. See Java implementation for reference');
|
|
117
177
|
}
|
|
118
178
|
|
|
119
179
|
getProductType(): string {
|
|
180
|
+
this.assertNotLink('productType');
|
|
120
181
|
const securityType = this.proto.getProductType();
|
|
121
182
|
const securityTypeString = (Object.keys(ProductTypeProto) as Array<keyof typeof ProductTypeProto>).find(
|
|
122
183
|
key => ProductTypeProto[key] === securityType
|
|
@@ -126,6 +187,7 @@ class Security {
|
|
|
126
187
|
}
|
|
127
188
|
|
|
128
189
|
getSecurityID(): IdentifierProto {
|
|
190
|
+
this.assertNotLink('securityId');
|
|
129
191
|
const identifier = this.proto.getIdentifier();
|
|
130
192
|
if (!identifier) throw new Error("Identifier is required");
|
|
131
193
|
return identifier;
|
|
@@ -144,6 +206,7 @@ class Security {
|
|
|
144
206
|
* calling BondSecurity.getIssueDate() (which returns LocalDate, not null).
|
|
145
207
|
*/
|
|
146
208
|
getIssueDate(): LocalDate | null {
|
|
209
|
+
this.assertNotLink('issueDate');
|
|
147
210
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
148
211
|
const bond = this.getBondLikeDetails();
|
|
149
212
|
const date = bond ? bond.getIssueDate() : this.proto.getIssueDate();
|
|
@@ -162,6 +225,7 @@ class Security {
|
|
|
162
225
|
* and TS will catch the misuse at compile time.
|
|
163
226
|
*/
|
|
164
227
|
getMaturityDate(): LocalDate {
|
|
228
|
+
this.assertNotLink('maturityDate');
|
|
165
229
|
// Prefer oneof bond sub-message if available, fall back to flat fields
|
|
166
230
|
const bond = this.getBondLikeDetails();
|
|
167
231
|
const date = bond ? bond.getMaturityDate() : this.proto.getMaturityDate();
|
|
@@ -170,23 +234,18 @@ class Security {
|
|
|
170
234
|
}
|
|
171
235
|
|
|
172
236
|
/**
|
|
173
|
-
* Returns the
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* (e.g. when JS codegen hasn't been updated).
|
|
237
|
+
* Returns the canonical bond_details sub-message if set, else undefined.
|
|
238
|
+
* v0.3.0 collapsed the prior 3-arm bond/tips/frn oneof into a single
|
|
239
|
+
* top-level bond_details — TIPS and FRN extras now live in their own
|
|
240
|
+
* tips_extension / frn_extension fields.
|
|
178
241
|
*/
|
|
179
242
|
protected getBondLikeDetails(): any | undefined {
|
|
180
|
-
// Guard: check if the oneof accessor exists (JS codegen may be stale)
|
|
181
243
|
if (typeof this.proto.getBondDetails !== 'function') return undefined;
|
|
182
|
-
|
|
183
|
-
return this.proto.getBondDetails() ||
|
|
184
|
-
this.proto.getTipsDetails() ||
|
|
185
|
-
this.proto.getFrnDetails() ||
|
|
186
|
-
undefined;
|
|
244
|
+
return this.proto.getBondDetails() ?? undefined;
|
|
187
245
|
}
|
|
188
246
|
|
|
189
247
|
getIssuerName(): string {
|
|
248
|
+
this.assertNotLink('issuerName');
|
|
190
249
|
return this.proto.getIssuerName();
|
|
191
250
|
}
|
|
192
251
|
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// package: fintekkers.models.security
|
|
2
|
-
// file: fintekkers/models/security/security_id.proto
|
|
3
|
-
|
|
4
|
-
/* tslint:disable */
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
|
|
7
|
-
import * as jspb from "google-protobuf";
|
|
8
|
-
import * as fintekkers_models_util_uuid_pb from "../../../fintekkers/models/util/uuid_pb";
|
|
9
|
-
|
|
10
|
-
export class SecurityIdProto extends jspb.Message {
|
|
11
|
-
|
|
12
|
-
hasUuid(): boolean;
|
|
13
|
-
clearUuid(): void;
|
|
14
|
-
getUuid(): fintekkers_models_util_uuid_pb.UUIDProto | undefined;
|
|
15
|
-
setUuid(value?: fintekkers_models_util_uuid_pb.UUIDProto): SecurityIdProto;
|
|
16
|
-
|
|
17
|
-
serializeBinary(): Uint8Array;
|
|
18
|
-
toObject(includeInstance?: boolean): SecurityIdProto.AsObject;
|
|
19
|
-
static toObject(includeInstance: boolean, msg: SecurityIdProto): SecurityIdProto.AsObject;
|
|
20
|
-
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
|
21
|
-
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
|
22
|
-
static serializeBinaryToWriter(message: SecurityIdProto, writer: jspb.BinaryWriter): void;
|
|
23
|
-
static deserializeBinary(bytes: Uint8Array): SecurityIdProto;
|
|
24
|
-
static deserializeBinaryFromReader(message: SecurityIdProto, reader: jspb.BinaryReader): SecurityIdProto;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export namespace SecurityIdProto {
|
|
28
|
-
export type AsObject = {
|
|
29
|
-
uuid?: fintekkers_models_util_uuid_pb.UUIDProto.AsObject,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// source: fintekkers/models/security/security_id.proto
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview
|
|
4
|
-
* @enhanceable
|
|
5
|
-
* @suppress {missingRequire} reports error on implicit type usages.
|
|
6
|
-
* @suppress {messageConventions} JS Compiler reports an error if a variable or
|
|
7
|
-
* field starts with 'MSG_' and isn't a translatable message.
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
// GENERATED CODE -- DO NOT EDIT!
|
|
11
|
-
/* eslint-disable */
|
|
12
|
-
// @ts-nocheck
|
|
13
|
-
|
|
14
|
-
var jspb = require('google-protobuf');
|
|
15
|
-
var goog = jspb;
|
|
16
|
-
var global = (function() {
|
|
17
|
-
if (this) { return this; }
|
|
18
|
-
if (typeof window !== 'undefined') { return window; }
|
|
19
|
-
if (typeof global !== 'undefined') { return global; }
|
|
20
|
-
if (typeof self !== 'undefined') { return self; }
|
|
21
|
-
return Function('return this')();
|
|
22
|
-
}.call(null));
|
|
23
|
-
|
|
24
|
-
var fintekkers_models_util_uuid_pb = require('../../../fintekkers/models/util/uuid_pb.js');
|
|
25
|
-
goog.object.extend(proto, fintekkers_models_util_uuid_pb);
|
|
26
|
-
goog.exportSymbol('proto.fintekkers.models.security.SecurityIdProto', null, global);
|
|
27
|
-
/**
|
|
28
|
-
* Generated by JsPbCodeGenerator.
|
|
29
|
-
* @param {Array=} opt_data Optional initial data array, typically from a
|
|
30
|
-
* server response, or constructed directly in Javascript. The array is used
|
|
31
|
-
* in place and becomes part of the constructed object. It is not cloned.
|
|
32
|
-
* If no data is provided, the constructed object will be empty, but still
|
|
33
|
-
* valid.
|
|
34
|
-
* @extends {jspb.Message}
|
|
35
|
-
* @constructor
|
|
36
|
-
*/
|
|
37
|
-
proto.fintekkers.models.security.SecurityIdProto = function(opt_data) {
|
|
38
|
-
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
|
39
|
-
};
|
|
40
|
-
goog.inherits(proto.fintekkers.models.security.SecurityIdProto, jspb.Message);
|
|
41
|
-
if (goog.DEBUG && !COMPILED) {
|
|
42
|
-
/**
|
|
43
|
-
* @public
|
|
44
|
-
* @override
|
|
45
|
-
*/
|
|
46
|
-
proto.fintekkers.models.security.SecurityIdProto.displayName = 'proto.fintekkers.models.security.SecurityIdProto';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (jspb.Message.GENERATE_TO_OBJECT) {
|
|
52
|
-
/**
|
|
53
|
-
* Creates an object representation of this proto.
|
|
54
|
-
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
|
55
|
-
* Optional fields that are not set will be set to undefined.
|
|
56
|
-
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
|
57
|
-
* For the list of reserved names please see:
|
|
58
|
-
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
|
59
|
-
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
|
60
|
-
* JSPB instance for transitional soy proto support:
|
|
61
|
-
* http://goto/soy-param-migration
|
|
62
|
-
* @return {!Object}
|
|
63
|
-
*/
|
|
64
|
-
proto.fintekkers.models.security.SecurityIdProto.prototype.toObject = function(opt_includeInstance) {
|
|
65
|
-
return proto.fintekkers.models.security.SecurityIdProto.toObject(opt_includeInstance, this);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Static version of the {@see toObject} method.
|
|
71
|
-
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
|
72
|
-
* the JSPB instance for transitional soy proto support:
|
|
73
|
-
* http://goto/soy-param-migration
|
|
74
|
-
* @param {!proto.fintekkers.models.security.SecurityIdProto} msg The msg instance to transform.
|
|
75
|
-
* @return {!Object}
|
|
76
|
-
* @suppress {unusedLocalVariables} f is only used for nested messages
|
|
77
|
-
*/
|
|
78
|
-
proto.fintekkers.models.security.SecurityIdProto.toObject = function(includeInstance, msg) {
|
|
79
|
-
var f, obj = {
|
|
80
|
-
uuid: (f = msg.getUuid()) && fintekkers_models_util_uuid_pb.UUIDProto.toObject(includeInstance, f)
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
if (includeInstance) {
|
|
84
|
-
obj.$jspbMessageInstance = msg;
|
|
85
|
-
}
|
|
86
|
-
return obj;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Deserializes binary data (in protobuf wire format).
|
|
93
|
-
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
|
94
|
-
* @return {!proto.fintekkers.models.security.SecurityIdProto}
|
|
95
|
-
*/
|
|
96
|
-
proto.fintekkers.models.security.SecurityIdProto.deserializeBinary = function(bytes) {
|
|
97
|
-
var reader = new jspb.BinaryReader(bytes);
|
|
98
|
-
var msg = new proto.fintekkers.models.security.SecurityIdProto;
|
|
99
|
-
return proto.fintekkers.models.security.SecurityIdProto.deserializeBinaryFromReader(msg, reader);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Deserializes binary data (in protobuf wire format) from the
|
|
105
|
-
* given reader into the given message object.
|
|
106
|
-
* @param {!proto.fintekkers.models.security.SecurityIdProto} msg The message object to deserialize into.
|
|
107
|
-
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
|
108
|
-
* @return {!proto.fintekkers.models.security.SecurityIdProto}
|
|
109
|
-
*/
|
|
110
|
-
proto.fintekkers.models.security.SecurityIdProto.deserializeBinaryFromReader = function(msg, reader) {
|
|
111
|
-
while (reader.nextField()) {
|
|
112
|
-
if (reader.isEndGroup()) {
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
var field = reader.getFieldNumber();
|
|
116
|
-
switch (field) {
|
|
117
|
-
case 1:
|
|
118
|
-
var value = new fintekkers_models_util_uuid_pb.UUIDProto;
|
|
119
|
-
reader.readMessage(value,fintekkers_models_util_uuid_pb.UUIDProto.deserializeBinaryFromReader);
|
|
120
|
-
msg.setUuid(value);
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
reader.skipField();
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return msg;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Serializes the message to binary data (in protobuf wire format).
|
|
133
|
-
* @return {!Uint8Array}
|
|
134
|
-
*/
|
|
135
|
-
proto.fintekkers.models.security.SecurityIdProto.prototype.serializeBinary = function() {
|
|
136
|
-
var writer = new jspb.BinaryWriter();
|
|
137
|
-
proto.fintekkers.models.security.SecurityIdProto.serializeBinaryToWriter(this, writer);
|
|
138
|
-
return writer.getResultBuffer();
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Serializes the given message to binary data (in protobuf wire
|
|
144
|
-
* format), writing to the given BinaryWriter.
|
|
145
|
-
* @param {!proto.fintekkers.models.security.SecurityIdProto} message
|
|
146
|
-
* @param {!jspb.BinaryWriter} writer
|
|
147
|
-
* @suppress {unusedLocalVariables} f is only used for nested messages
|
|
148
|
-
*/
|
|
149
|
-
proto.fintekkers.models.security.SecurityIdProto.serializeBinaryToWriter = function(message, writer) {
|
|
150
|
-
var f = undefined;
|
|
151
|
-
f = message.getUuid();
|
|
152
|
-
if (f != null) {
|
|
153
|
-
writer.writeMessage(
|
|
154
|
-
1,
|
|
155
|
-
f,
|
|
156
|
-
fintekkers_models_util_uuid_pb.UUIDProto.serializeBinaryToWriter
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* optional fintekkers.models.util.UUIDProto uuid = 1;
|
|
164
|
-
* @return {?proto.fintekkers.models.util.UUIDProto}
|
|
165
|
-
*/
|
|
166
|
-
proto.fintekkers.models.security.SecurityIdProto.prototype.getUuid = function() {
|
|
167
|
-
return /** @type{?proto.fintekkers.models.util.UUIDProto} */ (
|
|
168
|
-
jspb.Message.getWrapperField(this, fintekkers_models_util_uuid_pb.UUIDProto, 1));
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @param {?proto.fintekkers.models.util.UUIDProto|undefined} value
|
|
174
|
-
* @return {!proto.fintekkers.models.security.SecurityIdProto} returns this
|
|
175
|
-
*/
|
|
176
|
-
proto.fintekkers.models.security.SecurityIdProto.prototype.setUuid = function(value) {
|
|
177
|
-
return jspb.Message.setWrapperField(this, 1, value);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Clears the message field making it undefined.
|
|
183
|
-
* @return {!proto.fintekkers.models.security.SecurityIdProto} returns this
|
|
184
|
-
*/
|
|
185
|
-
proto.fintekkers.models.security.SecurityIdProto.prototype.clearUuid = function() {
|
|
186
|
-
return this.setUuid(undefined);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Returns whether this field is set.
|
|
192
|
-
* @return {boolean}
|
|
193
|
-
*/
|
|
194
|
-
proto.fintekkers.models.security.SecurityIdProto.prototype.hasUuid = function() {
|
|
195
|
-
return jspb.Message.getField(this, 1) != null;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
goog.object.extend(exports, proto.fintekkers.models.security);
|