@fintekkers/ledger-models 0.4.44 → 0.4.46
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/wrappers/util/object-type-coverage.test.d.ts +1 -0
- package/node/wrappers/util/object-type-coverage.test.js +159 -0
- package/node/wrappers/util/object-type-coverage.test.js.map +1 -0
- package/node/wrappers/util/object-type-coverage.test.ts +149 -0
- package/node/wrappers/util/object-types.d.ts +14 -4
- package/node/wrappers/util/object-types.js +135 -1
- package/node/wrappers/util/object-types.js.map +1 -1
- package/node/wrappers/util/object-types.ts +133 -4
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// Every message with object_type has an own-type stamp (LM-320). Walks the
|
|
27
|
+
// descriptor set for messages whose field 1 is
|
|
28
|
+
// fintekkers.models.util.ObjectTypeProto, and fails when `stampOwn` has no
|
|
29
|
+
// entry for one. Stamps each and checks its own type and version (0, 0, 1).
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const descriptor_pb_1 = require("google-protobuf/google/protobuf/descriptor_pb");
|
|
33
|
+
const object_type_pb_1 = require("../../fintekkers/models/util/object_type_pb");
|
|
34
|
+
const uuid_pb_1 = require("../../fintekkers/models/util/uuid_pb");
|
|
35
|
+
const objectTypes = __importStar(require("./object-types"));
|
|
36
|
+
// The descriptor set compile.sh writes for every language.
|
|
37
|
+
const DESCRIPTOR_SET = path.resolve(__dirname, '../../../../ledger-models-rust/ledger_models_file_descriptor_set_v_todo.bin');
|
|
38
|
+
const GENERATED = path.resolve(__dirname, '../..');
|
|
39
|
+
const OBJECT_TYPE_ENUM = '.fintekkers.models.util.ObjectTypeProto';
|
|
40
|
+
// The 13 types LM-320 names: every *ResponseProto and the index-composition
|
|
41
|
+
// requests and responses.
|
|
42
|
+
const NAMED = [
|
|
43
|
+
'fintekkers.requests.price.CreatePriceResponseProto',
|
|
44
|
+
'fintekkers.requests.price.QueryPriceResponseProto',
|
|
45
|
+
'fintekkers.requests.security.CreateSecurityResponseProto',
|
|
46
|
+
'fintekkers.requests.security.QuerySecurityResponseProto',
|
|
47
|
+
'fintekkers.requests.portfolio.CreatePortfolioResponseProto',
|
|
48
|
+
'fintekkers.requests.portfolio.QueryPortfolioResponseProto',
|
|
49
|
+
'fintekkers.requests.transaction.CreateTransactionResponseProto',
|
|
50
|
+
'fintekkers.requests.transaction.QueryTransactionResponseProto',
|
|
51
|
+
'fintekkers.requests.position.QueryPositionResponseProto',
|
|
52
|
+
'fintekkers.requests.index_composition.CreateIndexCompositionRequestProto',
|
|
53
|
+
'fintekkers.requests.index_composition.CreateIndexCompositionResponseProto',
|
|
54
|
+
'fintekkers.requests.index_composition.GetIndexCompositionRequestProto',
|
|
55
|
+
'fintekkers.requests.index_composition.GetIndexCompositionResponseProto',
|
|
56
|
+
];
|
|
57
|
+
/** Full name -> generated class of every message whose field 1 is ObjectTypeProto. */
|
|
58
|
+
function walk() {
|
|
59
|
+
if (!fs.existsSync(DESCRIPTOR_SET))
|
|
60
|
+
throw new Error(`descriptor set not found at ${DESCRIPTOR_SET}`);
|
|
61
|
+
const found = new Map();
|
|
62
|
+
const set = descriptor_pb_1.FileDescriptorSet.deserializeBinary(new Uint8Array(fs.readFileSync(DESCRIPTOR_SET)));
|
|
63
|
+
const isTyped = (message) => message.getFieldList().some((f) => f.getNumber() === 1 && f.getTypeName() === OBJECT_TYPE_ENUM);
|
|
64
|
+
for (const file of set.getFileList()) {
|
|
65
|
+
const fileName = file.getName();
|
|
66
|
+
// Loaded only for a typed message: google/protobuf/* has no module here.
|
|
67
|
+
const generated = () => require(path.join(GENERATED, fileName.replace(/\.proto$/, '_pb')));
|
|
68
|
+
const visit = (fullName, scope, message) => {
|
|
69
|
+
const messageClass = () => scope()[message.getName()];
|
|
70
|
+
if (isTyped(message)) {
|
|
71
|
+
if (typeof messageClass() !== 'function')
|
|
72
|
+
throw new Error(`${fullName}: no generated class in ${fileName}`);
|
|
73
|
+
found.set(fullName, messageClass());
|
|
74
|
+
}
|
|
75
|
+
for (const nested of message.getNestedTypeList()) {
|
|
76
|
+
visit(`${fullName}.${nested.getName()}`, messageClass, nested);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
for (const message of file.getMessageTypeList()) {
|
|
80
|
+
visit(`${file.getPackage()}.${message.getName()}`, generated, message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return found;
|
|
84
|
+
}
|
|
85
|
+
const WALKED = walk();
|
|
86
|
+
/** The walked names that `lookup` has no own type for. */
|
|
87
|
+
function missingTypes(walked, lookup) {
|
|
88
|
+
return Array.from(walked).filter((name) => lookup(name) === undefined);
|
|
89
|
+
}
|
|
90
|
+
function lookup(fullName) {
|
|
91
|
+
const messageClass = WALKED.get(fullName);
|
|
92
|
+
return objectTypes.ownType(new messageClass());
|
|
93
|
+
}
|
|
94
|
+
/** The value the naming rule gives: message name without Proto, in SCREAMING_SNAKE, prefixed OBJECT_TYPE_. */
|
|
95
|
+
function expectedType(fullName) {
|
|
96
|
+
const name = fullName.split('.').pop().replace(/Proto$/, '');
|
|
97
|
+
const enumName = 'OBJECT_TYPE_' + name.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
98
|
+
const value = object_type_pb_1.ObjectTypeProto[enumName];
|
|
99
|
+
if (value === undefined)
|
|
100
|
+
throw new Error(`${fullName}: no ${enumName} in ObjectTypeProto`);
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
test('the walk finds every typed message, including the named ones', () => {
|
|
104
|
+
expect(WALKED.size).toBeGreaterThanOrEqual(49);
|
|
105
|
+
for (const name of NAMED)
|
|
106
|
+
expect(WALKED.has(name)).toBe(true);
|
|
107
|
+
});
|
|
108
|
+
test('every typed message has an own type', () => {
|
|
109
|
+
expect(missingTypes(WALKED.keys(), lookup)).toEqual([]);
|
|
110
|
+
});
|
|
111
|
+
test('a missing entry is reported', () => {
|
|
112
|
+
const dropped = 'fintekkers.requests.price.QueryPriceResponseProto';
|
|
113
|
+
const without = (name) => (name === dropped ? undefined : lookup(name));
|
|
114
|
+
expect(missingTypes(WALKED.keys(), without)).toEqual([dropped]);
|
|
115
|
+
});
|
|
116
|
+
test.each(Array.from(WALKED.keys()).sort())('stamping %s sets its own type and version', (fullName) => {
|
|
117
|
+
const messageClass = WALKED.get(fullName);
|
|
118
|
+
const stamped = objectTypes.stampOwn(new messageClass());
|
|
119
|
+
const expected = expectedType(fullName);
|
|
120
|
+
expect(objectTypes.readType(stamped)).toBe(expected);
|
|
121
|
+
expect(objectTypes.readVersion(stamped)).toEqual([0, 0, 1]);
|
|
122
|
+
// The name table agrees with the class table.
|
|
123
|
+
expect(objectTypes.OWN_TYPE_NAMES.get(fullName)).toBe(expected);
|
|
124
|
+
});
|
|
125
|
+
test('own types are distinct and known', () => {
|
|
126
|
+
const types = Array.from(WALKED.keys()).map(lookup);
|
|
127
|
+
expect(types).not.toContain(object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_UNKNOWN);
|
|
128
|
+
expect(new Set(types).size).toBe(types.length);
|
|
129
|
+
});
|
|
130
|
+
test('the LM-318 entries keep their values', () => {
|
|
131
|
+
const lm318 = [
|
|
132
|
+
['fintekkers.models.portfolio.PortfolioProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_PORTFOLIO],
|
|
133
|
+
['fintekkers.models.position.PositionProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_POSITION],
|
|
134
|
+
['fintekkers.models.position.PositionFilterProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_POSITION_FILTER],
|
|
135
|
+
['fintekkers.models.price.PriceProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_PRICE],
|
|
136
|
+
['fintekkers.models.security.IdentifierProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_IDENTIFIER],
|
|
137
|
+
['fintekkers.models.security.SecurityProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_SECURITY],
|
|
138
|
+
['fintekkers.models.security.TenorProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_TENOR],
|
|
139
|
+
['fintekkers.models.strategy.StrategyProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_STRATEGY],
|
|
140
|
+
['fintekkers.models.strategy.StrategyAllocationProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_STRATEGY_ALLOCATION],
|
|
141
|
+
['fintekkers.models.transaction.TransactionProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_TRANSACTION],
|
|
142
|
+
['fintekkers.requests.portfolio.CreatePortfolioRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_PORTFOLIO_REQUEST],
|
|
143
|
+
['fintekkers.requests.portfolio.QueryPortfolioRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_PORTFOLIO_REQUEST],
|
|
144
|
+
['fintekkers.requests.price.CreatePriceRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_PRICE_REQUEST],
|
|
145
|
+
['fintekkers.requests.price.QueryPriceRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_PRICE_REQUEST],
|
|
146
|
+
['fintekkers.requests.security.CreateSecurityRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_SECURITY_REQUEST],
|
|
147
|
+
['fintekkers.requests.security.QuerySecurityRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_SECURITY_REQUEST],
|
|
148
|
+
['fintekkers.requests.transaction.CreateTransactionRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_TRANSACTION_REQUEST],
|
|
149
|
+
['fintekkers.requests.transaction.QueryTransactionRequestProto', object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_TRANSACTION_REQUEST],
|
|
150
|
+
];
|
|
151
|
+
for (const [name, objectType] of lm318)
|
|
152
|
+
expect([name, lookup(name)]).toEqual([name, objectType]);
|
|
153
|
+
});
|
|
154
|
+
test('stampOwn on a message without object_type throws', () => {
|
|
155
|
+
expect(objectTypes.ownType(new uuid_pb_1.UUIDProto())).toBeUndefined();
|
|
156
|
+
expect(objectTypes.ownType({})).toBeUndefined();
|
|
157
|
+
expect(() => objectTypes.stampOwn(new uuid_pb_1.UUIDProto())).toThrow('this message type has no own ObjectTypeProto');
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=object-type-coverage.test.js.map
|
|
@@ -0,0 +1 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+B,CAAC;QACrG,CAAC,yDAAyD,EAAE,gCAAe,CAAC,mCAAmC,CAAC;QAChH,CAAC,wDAAwD,EAAE,gCAAe,CAAC,kCAAkC,CAAC;QAC9G,CAAC,+DAA+D,EAAE,gCAAe,CAAC,sCAAsC,CAAC;QACzH,CAAC,8DAA8D,EAAE,gCAAe,CAAC,qCAAqC,CAAC;KACxH,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,KAAK;QAAE,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;AACnG,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC5D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,mBAAS,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAC7D,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAChD,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,mBAAS,EAA4B,CAAC,CAAC,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;AACxI,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Every message with object_type has an own-type stamp (LM-320). Walks the
|
|
2
|
+
// descriptor set for messages whose field 1 is
|
|
3
|
+
// fintekkers.models.util.ObjectTypeProto, and fails when `stampOwn` has no
|
|
4
|
+
// entry for one. Stamps each and checks its own type and version (0, 0, 1).
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { DescriptorProto, FileDescriptorSet } from 'google-protobuf/google/protobuf/descriptor_pb';
|
|
8
|
+
|
|
9
|
+
import { ObjectTypeProto } from '../../fintekkers/models/util/object_type_pb';
|
|
10
|
+
import { UUIDProto } from '../../fintekkers/models/util/uuid_pb';
|
|
11
|
+
|
|
12
|
+
import * as objectTypes from './object-types';
|
|
13
|
+
import { ObjectTyped } from './object-types';
|
|
14
|
+
|
|
15
|
+
// The descriptor set compile.sh writes for every language.
|
|
16
|
+
const DESCRIPTOR_SET = path.resolve(__dirname, '../../../../ledger-models-rust/ledger_models_file_descriptor_set_v_todo.bin');
|
|
17
|
+
const GENERATED = path.resolve(__dirname, '../..');
|
|
18
|
+
|
|
19
|
+
const OBJECT_TYPE_ENUM = '.fintekkers.models.util.ObjectTypeProto';
|
|
20
|
+
|
|
21
|
+
// The 13 types LM-320 names: every *ResponseProto and the index-composition
|
|
22
|
+
// requests and responses.
|
|
23
|
+
const NAMED = [
|
|
24
|
+
'fintekkers.requests.price.CreatePriceResponseProto',
|
|
25
|
+
'fintekkers.requests.price.QueryPriceResponseProto',
|
|
26
|
+
'fintekkers.requests.security.CreateSecurityResponseProto',
|
|
27
|
+
'fintekkers.requests.security.QuerySecurityResponseProto',
|
|
28
|
+
'fintekkers.requests.portfolio.CreatePortfolioResponseProto',
|
|
29
|
+
'fintekkers.requests.portfolio.QueryPortfolioResponseProto',
|
|
30
|
+
'fintekkers.requests.transaction.CreateTransactionResponseProto',
|
|
31
|
+
'fintekkers.requests.transaction.QueryTransactionResponseProto',
|
|
32
|
+
'fintekkers.requests.position.QueryPositionResponseProto',
|
|
33
|
+
'fintekkers.requests.index_composition.CreateIndexCompositionRequestProto',
|
|
34
|
+
'fintekkers.requests.index_composition.CreateIndexCompositionResponseProto',
|
|
35
|
+
'fintekkers.requests.index_composition.GetIndexCompositionRequestProto',
|
|
36
|
+
'fintekkers.requests.index_composition.GetIndexCompositionResponseProto',
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
type MessageClass = new () => ObjectTyped;
|
|
40
|
+
|
|
41
|
+
/** Full name -> generated class of every message whose field 1 is ObjectTypeProto. */
|
|
42
|
+
function walk(): Map<string, MessageClass> {
|
|
43
|
+
if (!fs.existsSync(DESCRIPTOR_SET)) throw new Error(`descriptor set not found at ${DESCRIPTOR_SET}`);
|
|
44
|
+
const found = new Map<string, MessageClass>();
|
|
45
|
+
const set = FileDescriptorSet.deserializeBinary(new Uint8Array(fs.readFileSync(DESCRIPTOR_SET)));
|
|
46
|
+
const isTyped = (message: DescriptorProto) =>
|
|
47
|
+
message.getFieldList().some((f) => f.getNumber() === 1 && f.getTypeName() === OBJECT_TYPE_ENUM);
|
|
48
|
+
for (const file of set.getFileList()) {
|
|
49
|
+
const fileName = file.getName() as string;
|
|
50
|
+
// Loaded only for a typed message: google/protobuf/* has no module here.
|
|
51
|
+
const generated = () => require(path.join(GENERATED, fileName.replace(/\.proto$/, '_pb')));
|
|
52
|
+
const visit = (fullName: string, scope: () => Record<string, unknown>, message: DescriptorProto) => {
|
|
53
|
+
const messageClass = () => scope()[message.getName() as string] as MessageClass & Record<string, unknown>;
|
|
54
|
+
if (isTyped(message)) {
|
|
55
|
+
if (typeof messageClass() !== 'function') throw new Error(`${fullName}: no generated class in ${fileName}`);
|
|
56
|
+
found.set(fullName, messageClass());
|
|
57
|
+
}
|
|
58
|
+
for (const nested of message.getNestedTypeList()) {
|
|
59
|
+
visit(`${fullName}.${nested.getName()}`, messageClass, nested);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
for (const message of file.getMessageTypeList()) {
|
|
63
|
+
visit(`${file.getPackage()}.${message.getName()}`, generated, message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return found;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const WALKED = walk();
|
|
70
|
+
|
|
71
|
+
/** The walked names that `lookup` has no own type for. */
|
|
72
|
+
function missingTypes(walked: Iterable<string>, lookup: (fullName: string) => ObjectTypeProto | undefined): string[] {
|
|
73
|
+
return Array.from(walked).filter((name) => lookup(name) === undefined);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function lookup(fullName: string): ObjectTypeProto | undefined {
|
|
77
|
+
const messageClass = WALKED.get(fullName) as MessageClass;
|
|
78
|
+
return objectTypes.ownType(new messageClass());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The value the naming rule gives: message name without Proto, in SCREAMING_SNAKE, prefixed OBJECT_TYPE_. */
|
|
82
|
+
function expectedType(fullName: string): ObjectTypeProto {
|
|
83
|
+
const name = (fullName.split('.').pop() as string).replace(/Proto$/, '');
|
|
84
|
+
const enumName = 'OBJECT_TYPE_' + name.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
85
|
+
const value = (ObjectTypeProto as unknown as Record<string, ObjectTypeProto>)[enumName];
|
|
86
|
+
if (value === undefined) throw new Error(`${fullName}: no ${enumName} in ObjectTypeProto`);
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
test('the walk finds every typed message, including the named ones', () => {
|
|
91
|
+
expect(WALKED.size).toBeGreaterThanOrEqual(49);
|
|
92
|
+
for (const name of NAMED) expect(WALKED.has(name)).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('every typed message has an own type', () => {
|
|
96
|
+
expect(missingTypes(WALKED.keys(), lookup)).toEqual([]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('a missing entry is reported', () => {
|
|
100
|
+
const dropped = 'fintekkers.requests.price.QueryPriceResponseProto';
|
|
101
|
+
const without = (name: string) => (name === dropped ? undefined : lookup(name));
|
|
102
|
+
expect(missingTypes(WALKED.keys(), without)).toEqual([dropped]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test.each(Array.from(WALKED.keys()).sort())('stamping %s sets its own type and version', (fullName) => {
|
|
106
|
+
const messageClass = WALKED.get(fullName) as MessageClass;
|
|
107
|
+
const stamped = objectTypes.stampOwn(new messageClass());
|
|
108
|
+
const expected = expectedType(fullName);
|
|
109
|
+
expect(objectTypes.readType(stamped)).toBe(expected);
|
|
110
|
+
expect(objectTypes.readVersion(stamped)).toEqual([0, 0, 1]);
|
|
111
|
+
// The name table agrees with the class table.
|
|
112
|
+
expect(objectTypes.OWN_TYPE_NAMES.get(fullName)).toBe(expected);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('own types are distinct and known', () => {
|
|
116
|
+
const types = Array.from(WALKED.keys()).map(lookup);
|
|
117
|
+
expect(types).not.toContain(ObjectTypeProto.OBJECT_TYPE_UNKNOWN);
|
|
118
|
+
expect(new Set(types).size).toBe(types.length);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('the LM-318 entries keep their values', () => {
|
|
122
|
+
const lm318: [string, ObjectTypeProto][] = [
|
|
123
|
+
['fintekkers.models.portfolio.PortfolioProto', ObjectTypeProto.OBJECT_TYPE_PORTFOLIO],
|
|
124
|
+
['fintekkers.models.position.PositionProto', ObjectTypeProto.OBJECT_TYPE_POSITION],
|
|
125
|
+
['fintekkers.models.position.PositionFilterProto', ObjectTypeProto.OBJECT_TYPE_POSITION_FILTER],
|
|
126
|
+
['fintekkers.models.price.PriceProto', ObjectTypeProto.OBJECT_TYPE_PRICE],
|
|
127
|
+
['fintekkers.models.security.IdentifierProto', ObjectTypeProto.OBJECT_TYPE_IDENTIFIER],
|
|
128
|
+
['fintekkers.models.security.SecurityProto', ObjectTypeProto.OBJECT_TYPE_SECURITY],
|
|
129
|
+
['fintekkers.models.security.TenorProto', ObjectTypeProto.OBJECT_TYPE_TENOR],
|
|
130
|
+
['fintekkers.models.strategy.StrategyProto', ObjectTypeProto.OBJECT_TYPE_STRATEGY],
|
|
131
|
+
['fintekkers.models.strategy.StrategyAllocationProto', ObjectTypeProto.OBJECT_TYPE_STRATEGY_ALLOCATION],
|
|
132
|
+
['fintekkers.models.transaction.TransactionProto', ObjectTypeProto.OBJECT_TYPE_TRANSACTION],
|
|
133
|
+
['fintekkers.requests.portfolio.CreatePortfolioRequestProto', ObjectTypeProto.OBJECT_TYPE_CREATE_PORTFOLIO_REQUEST],
|
|
134
|
+
['fintekkers.requests.portfolio.QueryPortfolioRequestProto', ObjectTypeProto.OBJECT_TYPE_QUERY_PORTFOLIO_REQUEST],
|
|
135
|
+
['fintekkers.requests.price.CreatePriceRequestProto', ObjectTypeProto.OBJECT_TYPE_CREATE_PRICE_REQUEST],
|
|
136
|
+
['fintekkers.requests.price.QueryPriceRequestProto', ObjectTypeProto.OBJECT_TYPE_QUERY_PRICE_REQUEST],
|
|
137
|
+
['fintekkers.requests.security.CreateSecurityRequestProto', ObjectTypeProto.OBJECT_TYPE_CREATE_SECURITY_REQUEST],
|
|
138
|
+
['fintekkers.requests.security.QuerySecurityRequestProto', ObjectTypeProto.OBJECT_TYPE_QUERY_SECURITY_REQUEST],
|
|
139
|
+
['fintekkers.requests.transaction.CreateTransactionRequestProto', ObjectTypeProto.OBJECT_TYPE_CREATE_TRANSACTION_REQUEST],
|
|
140
|
+
['fintekkers.requests.transaction.QueryTransactionRequestProto', ObjectTypeProto.OBJECT_TYPE_QUERY_TRANSACTION_REQUEST],
|
|
141
|
+
];
|
|
142
|
+
for (const [name, objectType] of lm318) expect([name, lookup(name)]).toEqual([name, objectType]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('stampOwn on a message without object_type throws', () => {
|
|
146
|
+
expect(objectTypes.ownType(new UUIDProto())).toBeUndefined();
|
|
147
|
+
expect(objectTypes.ownType({})).toBeUndefined();
|
|
148
|
+
expect(() => objectTypes.stampOwn(new UUIDProto() as unknown as ObjectTyped)).toThrow('this message type has no own ObjectTypeProto');
|
|
149
|
+
});
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Every message that names its type carries `ObjectTypeProto object_type = 1`
|
|
5
5
|
* and `VersionProto version = 2`. Writers call `stamp`, which sets the type and
|
|
6
|
-
* `SCHEMA_VERSION
|
|
7
|
-
* `
|
|
8
|
-
* written before it are not readable.
|
|
9
|
-
* docs/adr/compact_object_type_and_version.md.
|
|
6
|
+
* `SCHEMA_VERSION`; `stampOwn` passes the message's own type (LM-320). Readers
|
|
7
|
+
* call `readType` / `readVersion`. The old `object_class` / `version` strings
|
|
8
|
+
* were replaced in place by LM-318: bytes written before it are not readable.
|
|
9
|
+
* See docs/adr/compact_object_type_and_version.md.
|
|
10
10
|
*/
|
|
11
11
|
import { ObjectTypeProto } from '../../fintekkers/models/util/object_type_pb';
|
|
12
12
|
import { VersionProto } from '../../fintekkers/models/util/version_pb';
|
|
@@ -27,6 +27,16 @@ export declare const SCHEMA_VERSION: Version;
|
|
|
27
27
|
* `objectType` is the message's own ObjectTypeProto value.
|
|
28
28
|
*/
|
|
29
29
|
export declare function stamp<T extends ObjectTyped>(message: T, objectType: ObjectTypeProto): T;
|
|
30
|
+
/** Each message with object_type, by proto full name, to its own ObjectTypeProto value. */
|
|
31
|
+
export declare const OWN_TYPE_NAMES: ReadonlyMap<string, ObjectTypeProto>;
|
|
32
|
+
/** The message's own ObjectTypeProto value, or undefined when its class has none. */
|
|
33
|
+
export declare function ownType(message: object): ObjectTypeProto | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* `stamp` with the message's own ObjectTypeProto value (LM-320); returns it.
|
|
36
|
+
* Throws an Error when its class has no own value. Generated classes are
|
|
37
|
+
* anonymous at runtime, so the error names the class only when it has a name.
|
|
38
|
+
*/
|
|
39
|
+
export declare function stampOwn<T extends ObjectTyped>(message: T): T;
|
|
30
40
|
/**
|
|
31
41
|
* The message's ObjectTypeProto value; OBJECT_TYPE_UNKNOWN when unset. A value
|
|
32
42
|
* added after this build is returned as its number.
|
|
@@ -1,7 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readVersion = exports.readType = exports.stamp = exports.SCHEMA_VERSION = void 0;
|
|
3
|
+
exports.readVersion = exports.readType = exports.stampOwn = exports.ownType = exports.OWN_TYPE_NAMES = exports.stamp = exports.SCHEMA_VERSION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Object type and version (LM-297, LM-318).
|
|
6
|
+
*
|
|
7
|
+
* Every message that names its type carries `ObjectTypeProto object_type = 1`
|
|
8
|
+
* and `VersionProto version = 2`. Writers call `stamp`, which sets the type and
|
|
9
|
+
* `SCHEMA_VERSION`; `stampOwn` passes the message's own type (LM-320). Readers
|
|
10
|
+
* call `readType` / `readVersion`. The old `object_class` / `version` strings
|
|
11
|
+
* were replaced in place by LM-318: bytes written before it are not readable.
|
|
12
|
+
* See docs/adr/compact_object_type_and_version.md.
|
|
13
|
+
*/
|
|
14
|
+
const object_type_pb_1 = require("../../fintekkers/models/util/object_type_pb");
|
|
4
15
|
const version_pb_1 = require("../../fintekkers/models/util/version_pb");
|
|
16
|
+
const portfolio_pb_1 = require("../../fintekkers/models/portfolio/portfolio_pb");
|
|
17
|
+
const position_pb_1 = require("../../fintekkers/models/position/position_pb");
|
|
18
|
+
const position_filter_pb_1 = require("../../fintekkers/models/position/position_filter_pb");
|
|
19
|
+
const price_pb_1 = require("../../fintekkers/models/price/price_pb");
|
|
20
|
+
const issuance_pb_1 = require("../../fintekkers/models/security/bond/issuance_pb");
|
|
21
|
+
const identifier_pb_1 = require("../../fintekkers/models/security/identifier/identifier_pb");
|
|
22
|
+
const index_composition_pb_1 = require("../../fintekkers/models/security/index_composition_pb");
|
|
23
|
+
const security_pb_1 = require("../../fintekkers/models/security/security_pb");
|
|
24
|
+
const tenor_pb_1 = require("../../fintekkers/models/security/tenor_pb");
|
|
25
|
+
const strategy_pb_1 = require("../../fintekkers/models/strategy/strategy_pb");
|
|
26
|
+
const strategy_allocation_pb_1 = require("../../fintekkers/models/strategy/strategy_allocation_pb");
|
|
27
|
+
const transaction_pb_1 = require("../../fintekkers/models/transaction/transaction_pb");
|
|
28
|
+
const api_key_pb_1 = require("../../fintekkers/models/util/api/api_key_pb");
|
|
29
|
+
const date_range_pb_1 = require("../../fintekkers/models/util/date_range_pb");
|
|
30
|
+
const node_partition_pb_1 = require("../../fintekkers/models/util/lock/node_partition_pb");
|
|
31
|
+
const node_state_pb_1 = require("../../fintekkers/models/util/lock/node_state_pb");
|
|
32
|
+
const create_index_composition_request_pb_1 = require("../../fintekkers/requests/index_composition/create_index_composition_request_pb");
|
|
33
|
+
const get_index_composition_request_pb_1 = require("../../fintekkers/requests/index_composition/get_index_composition_request_pb");
|
|
34
|
+
const create_portfolio_request_pb_1 = require("../../fintekkers/requests/portfolio/create_portfolio_request_pb");
|
|
35
|
+
const create_portfolio_response_pb_1 = require("../../fintekkers/requests/portfolio/create_portfolio_response_pb");
|
|
36
|
+
const query_portfolio_request_pb_1 = require("../../fintekkers/requests/portfolio/query_portfolio_request_pb");
|
|
37
|
+
const query_portfolio_response_pb_1 = require("../../fintekkers/requests/portfolio/query_portfolio_response_pb");
|
|
38
|
+
const query_position_request_pb_1 = require("../../fintekkers/requests/position/query_position_request_pb");
|
|
39
|
+
const query_position_response_pb_1 = require("../../fintekkers/requests/position/query_position_response_pb");
|
|
40
|
+
const create_price_request_pb_1 = require("../../fintekkers/requests/price/create_price_request_pb");
|
|
41
|
+
const create_price_response_pb_1 = require("../../fintekkers/requests/price/create_price_response_pb");
|
|
42
|
+
const query_price_request_pb_1 = require("../../fintekkers/requests/price/query_price_request_pb");
|
|
43
|
+
const query_price_response_pb_1 = require("../../fintekkers/requests/price/query_price_response_pb");
|
|
44
|
+
const create_security_request_pb_1 = require("../../fintekkers/requests/security/create_security_request_pb");
|
|
45
|
+
const create_security_response_pb_1 = require("../../fintekkers/requests/security/create_security_response_pb");
|
|
46
|
+
const get_field_values_request_pb_1 = require("../../fintekkers/requests/security/get_field_values_request_pb");
|
|
47
|
+
const get_field_values_response_pb_1 = require("../../fintekkers/requests/security/get_field_values_response_pb");
|
|
48
|
+
const get_fields_response_pb_1 = require("../../fintekkers/requests/security/get_fields_response_pb");
|
|
49
|
+
const query_security_request_pb_1 = require("../../fintekkers/requests/security/query_security_request_pb");
|
|
50
|
+
const query_security_response_pb_1 = require("../../fintekkers/requests/security/query_security_response_pb");
|
|
51
|
+
const create_transaction_request_pb_1 = require("../../fintekkers/requests/transaction/create_transaction_request_pb");
|
|
52
|
+
const create_transaction_response_pb_1 = require("../../fintekkers/requests/transaction/create_transaction_response_pb");
|
|
53
|
+
const query_transaction_request_pb_1 = require("../../fintekkers/requests/transaction/query_transaction_request_pb");
|
|
54
|
+
const query_transaction_response_pb_1 = require("../../fintekkers/requests/transaction/query_transaction_response_pb");
|
|
55
|
+
const delete_request_pb_1 = require("../../fintekkers/requests/util/delete_request_pb");
|
|
56
|
+
const lock_request_pb_1 = require("../../fintekkers/requests/util/lock/lock_request_pb");
|
|
57
|
+
const lock_response_pb_1 = require("../../fintekkers/requests/util/lock/lock_response_pb");
|
|
58
|
+
const curve_request_pb_1 = require("../../fintekkers/requests/valuation/curve_request_pb");
|
|
59
|
+
const curve_response_pb_1 = require("../../fintekkers/requests/valuation/curve_response_pb");
|
|
60
|
+
const valuation_request_pb_1 = require("../../fintekkers/requests/valuation/valuation_request_pb");
|
|
61
|
+
const valuation_response_pb_1 = require("../../fintekkers/requests/valuation/valuation_response_pb");
|
|
5
62
|
/** The schema version `stamp` writes. Not the library release. */
|
|
6
63
|
exports.SCHEMA_VERSION = [0, 0, 1];
|
|
7
64
|
/**
|
|
@@ -15,6 +72,83 @@ function stamp(message, objectType) {
|
|
|
15
72
|
return message;
|
|
16
73
|
}
|
|
17
74
|
exports.stamp = stamp;
|
|
75
|
+
// Each message with object_type: proto full name, generated class, its own
|
|
76
|
+
// ObjectTypeProto value (LM-320). object-type-coverage.test.ts fails when a
|
|
77
|
+
// message in the descriptor set is missing.
|
|
78
|
+
const OWN_TYPE_ROWS = [
|
|
79
|
+
['fintekkers.models.portfolio.PortfolioProto', portfolio_pb_1.PortfolioProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_PORTFOLIO],
|
|
80
|
+
['fintekkers.models.position.PositionProto', position_pb_1.PositionProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_POSITION],
|
|
81
|
+
['fintekkers.models.position.PositionFilterProto', position_filter_pb_1.PositionFilterProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_POSITION_FILTER],
|
|
82
|
+
['fintekkers.models.price.PriceProto', price_pb_1.PriceProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_PRICE],
|
|
83
|
+
['fintekkers.models.security.IdentifierProto', identifier_pb_1.IdentifierProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_IDENTIFIER],
|
|
84
|
+
['fintekkers.models.security.SecurityProto', security_pb_1.SecurityProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_SECURITY],
|
|
85
|
+
['fintekkers.models.security.TenorProto', tenor_pb_1.TenorProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_TENOR],
|
|
86
|
+
['fintekkers.models.strategy.StrategyProto', strategy_pb_1.StrategyProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_STRATEGY],
|
|
87
|
+
['fintekkers.models.strategy.StrategyAllocationProto', strategy_allocation_pb_1.StrategyAllocationProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_STRATEGY_ALLOCATION],
|
|
88
|
+
['fintekkers.models.transaction.TransactionProto', transaction_pb_1.TransactionProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_TRANSACTION],
|
|
89
|
+
['fintekkers.requests.portfolio.CreatePortfolioRequestProto', create_portfolio_request_pb_1.CreatePortfolioRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_PORTFOLIO_REQUEST],
|
|
90
|
+
['fintekkers.requests.portfolio.QueryPortfolioRequestProto', query_portfolio_request_pb_1.QueryPortfolioRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_PORTFOLIO_REQUEST],
|
|
91
|
+
['fintekkers.requests.price.CreatePriceRequestProto', create_price_request_pb_1.CreatePriceRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_PRICE_REQUEST],
|
|
92
|
+
['fintekkers.requests.price.QueryPriceRequestProto', query_price_request_pb_1.QueryPriceRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_PRICE_REQUEST],
|
|
93
|
+
['fintekkers.requests.security.CreateSecurityRequestProto', create_security_request_pb_1.CreateSecurityRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_SECURITY_REQUEST],
|
|
94
|
+
['fintekkers.requests.security.QuerySecurityRequestProto', query_security_request_pb_1.QuerySecurityRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_SECURITY_REQUEST],
|
|
95
|
+
['fintekkers.requests.transaction.CreateTransactionRequestProto', create_transaction_request_pb_1.CreateTransactionRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_TRANSACTION_REQUEST],
|
|
96
|
+
['fintekkers.requests.transaction.QueryTransactionRequestProto', query_transaction_request_pb_1.QueryTransactionRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_TRANSACTION_REQUEST],
|
|
97
|
+
// LM-320: the rest of the messages with object_type.
|
|
98
|
+
['fintekkers.models.security.bond.IssuanceProto', issuance_pb_1.IssuanceProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_ISSUANCE],
|
|
99
|
+
['fintekkers.models.security.IndexCompositionProto', index_composition_pb_1.IndexCompositionProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_INDEX_COMPOSITION],
|
|
100
|
+
['fintekkers.models.util.DateRangeProto', date_range_pb_1.DateRangeProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_DATE_RANGE],
|
|
101
|
+
['fintekkers.models.util.api.API_Key', api_key_pb_1.API_Key, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_API_KEY],
|
|
102
|
+
['fintekkers.models.util.lock.NodeState', node_state_pb_1.NodeState, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_NODE_STATE],
|
|
103
|
+
['fintekkers.models.util.lock.NodePartition', node_partition_pb_1.NodePartition, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_NODE_PARTITION],
|
|
104
|
+
['fintekkers.requests.index_composition.CreateIndexCompositionRequestProto', create_index_composition_request_pb_1.CreateIndexCompositionRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_INDEX_COMPOSITION_REQUEST],
|
|
105
|
+
['fintekkers.requests.index_composition.CreateIndexCompositionResponseProto', create_index_composition_request_pb_1.CreateIndexCompositionResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_INDEX_COMPOSITION_RESPONSE],
|
|
106
|
+
['fintekkers.requests.index_composition.GetIndexCompositionRequestProto', get_index_composition_request_pb_1.GetIndexCompositionRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_GET_INDEX_COMPOSITION_REQUEST],
|
|
107
|
+
['fintekkers.requests.index_composition.GetIndexCompositionResponseProto', get_index_composition_request_pb_1.GetIndexCompositionResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_GET_INDEX_COMPOSITION_RESPONSE],
|
|
108
|
+
['fintekkers.requests.portfolio.CreatePortfolioResponseProto', create_portfolio_response_pb_1.CreatePortfolioResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_PORTFOLIO_RESPONSE],
|
|
109
|
+
['fintekkers.requests.portfolio.QueryPortfolioResponseProto', query_portfolio_response_pb_1.QueryPortfolioResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_PORTFOLIO_RESPONSE],
|
|
110
|
+
['fintekkers.requests.position.QueryPositionRequestProto', query_position_request_pb_1.QueryPositionRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_POSITION_REQUEST],
|
|
111
|
+
['fintekkers.requests.position.QueryPositionResponseProto', query_position_response_pb_1.QueryPositionResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_POSITION_RESPONSE],
|
|
112
|
+
['fintekkers.requests.price.CreatePriceResponseProto', create_price_response_pb_1.CreatePriceResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_PRICE_RESPONSE],
|
|
113
|
+
['fintekkers.requests.price.QueryPriceResponseProto', query_price_response_pb_1.QueryPriceResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_PRICE_RESPONSE],
|
|
114
|
+
['fintekkers.requests.security.CreateSecurityResponseProto', create_security_response_pb_1.CreateSecurityResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_SECURITY_RESPONSE],
|
|
115
|
+
['fintekkers.requests.security.QuerySecurityResponseProto', query_security_response_pb_1.QuerySecurityResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_SECURITY_RESPONSE],
|
|
116
|
+
['fintekkers.requests.security.GetFieldsResponseProto', get_fields_response_pb_1.GetFieldsResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_GET_FIELDS_RESPONSE],
|
|
117
|
+
['fintekkers.requests.security.GetFieldValuesRequestProto', get_field_values_request_pb_1.GetFieldValuesRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_GET_FIELD_VALUES_REQUEST],
|
|
118
|
+
['fintekkers.requests.security.GetFieldValuesResponseProto', get_field_values_response_pb_1.GetFieldValuesResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_GET_FIELD_VALUES_RESPONSE],
|
|
119
|
+
['fintekkers.requests.transaction.CreateTransactionResponseProto', create_transaction_response_pb_1.CreateTransactionResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CREATE_TRANSACTION_RESPONSE],
|
|
120
|
+
['fintekkers.requests.transaction.QueryTransactionResponseProto', query_transaction_response_pb_1.QueryTransactionResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_QUERY_TRANSACTION_RESPONSE],
|
|
121
|
+
['fintekkers.requests.util.DeleteRequestProto', delete_request_pb_1.DeleteRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_DELETE_REQUEST],
|
|
122
|
+
['fintekkers.requests.util.DeleteResponseProto', delete_request_pb_1.DeleteResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_DELETE_RESPONSE],
|
|
123
|
+
['fintekkers.requests.util.lock.LockRequestProto', lock_request_pb_1.LockRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_LOCK_REQUEST],
|
|
124
|
+
['fintekkers.requests.util.lock.LockResponseProto', lock_response_pb_1.LockResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_LOCK_RESPONSE],
|
|
125
|
+
['fintekkers.requests.valuation.ValuationRequestProto', valuation_request_pb_1.ValuationRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_VALUATION_REQUEST],
|
|
126
|
+
['fintekkers.requests.valuation.ValuationResponseProto', valuation_response_pb_1.ValuationResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_VALUATION_RESPONSE],
|
|
127
|
+
['fintekkers.requests.valuation.CurveRequestProto', curve_request_pb_1.CurveRequestProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CURVE_REQUEST],
|
|
128
|
+
['fintekkers.requests.valuation.CurveResponseProto', curve_response_pb_1.CurveResponseProto, object_type_pb_1.ObjectTypeProto.OBJECT_TYPE_CURVE_RESPONSE],
|
|
129
|
+
];
|
|
130
|
+
const OWN_TYPES = new Map(OWN_TYPE_ROWS.map(([, messageClass, objectType]) => [messageClass, objectType]));
|
|
131
|
+
/** Each message with object_type, by proto full name, to its own ObjectTypeProto value. */
|
|
132
|
+
exports.OWN_TYPE_NAMES = new Map(OWN_TYPE_ROWS.map(([fullName, , objectType]) => [fullName, objectType]));
|
|
133
|
+
/** The message's own ObjectTypeProto value, or undefined when its class has none. */
|
|
134
|
+
function ownType(message) {
|
|
135
|
+
return OWN_TYPES.get(message.constructor);
|
|
136
|
+
}
|
|
137
|
+
exports.ownType = ownType;
|
|
138
|
+
/**
|
|
139
|
+
* `stamp` with the message's own ObjectTypeProto value (LM-320); returns it.
|
|
140
|
+
* Throws an Error when its class has no own value. Generated classes are
|
|
141
|
+
* anonymous at runtime, so the error names the class only when it has a name.
|
|
142
|
+
*/
|
|
143
|
+
function stampOwn(message) {
|
|
144
|
+
var _a;
|
|
145
|
+
const objectType = ownType(message);
|
|
146
|
+
if (objectType === undefined) {
|
|
147
|
+
throw new Error(`${((_a = message.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'this message type'} has no own ObjectTypeProto`);
|
|
148
|
+
}
|
|
149
|
+
return stamp(message, objectType);
|
|
150
|
+
}
|
|
151
|
+
exports.stampOwn = stampOwn;
|
|
18
152
|
/**
|
|
19
153
|
* The message's ObjectTypeProto value; OBJECT_TYPE_UNKNOWN when unset. A value
|
|
20
154
|
* added after this build is returned as its number.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-types.js","sourceRoot":"","sources":["object-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"object-types.js","sourceRoot":"","sources":["object-types.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,gFAA8E;AAC9E,wEAAuE;AACvE,iFAAgF;AAChF,8EAA6E;AAC7E,4FAA0F;AAC1F,qEAAoE;AACpE,mFAAkF;AAClF,6FAA4F;AAC5F,gGAA8F;AAC9F,8EAA6E;AAC7E,wEAAuE;AACvE,8EAA6E;AAC7E,oGAAkG;AAClG,uFAAsF;AACtF,4EAAsE;AACtE,8EAA4E;AAC5E,2FAAoF;AACpF,mFAA4E;AAC5E,yIAA0K;AAC1K,mIAAiK;AACjK,iHAA8G;AAC9G,mHAAgH;AAChH,+GAA4G;AAC5G,iHAA8G;AAC9G,4GAAyG;AACzG,8GAA2G;AAC3G,qGAAkG;AAClG,uGAAoG;AACpG,mGAAgG;AAChG,qGAAkG;AAClG,8GAA2G;AAC3G,gHAA6G;AAC7G,gHAA4G;AAC5G,kHAA8G;AAC9G,sGAAmG;AACnG,4GAAyG;AACzG,8GAA2G;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CAAC;AACpC,CAAC;AAND,4BAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,OAAoB;IAC3C,OAAO,OAAO,CAAC,aAAa,EAAE,CAAC;AACjC,CAAC;AAFD,4BAEC;AAED,gFAAgF;AAChF,SAAgB,WAAW,CAAC,OAAoB;IAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACrE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;AACtE,CAAC;AAJD,kCAIC"}
|
|
@@ -3,13 +3,59 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Every message that names its type carries `ObjectTypeProto object_type = 1`
|
|
5
5
|
* and `VersionProto version = 2`. Writers call `stamp`, which sets the type and
|
|
6
|
-
* `SCHEMA_VERSION
|
|
7
|
-
* `
|
|
8
|
-
* written before it are not readable.
|
|
9
|
-
* docs/adr/compact_object_type_and_version.md.
|
|
6
|
+
* `SCHEMA_VERSION`; `stampOwn` passes the message's own type (LM-320). Readers
|
|
7
|
+
* call `readType` / `readVersion`. The old `object_class` / `version` strings
|
|
8
|
+
* were replaced in place by LM-318: bytes written before it are not readable.
|
|
9
|
+
* See docs/adr/compact_object_type_and_version.md.
|
|
10
10
|
*/
|
|
11
11
|
import { ObjectTypeProto } from '../../fintekkers/models/util/object_type_pb';
|
|
12
12
|
import { VersionProto } from '../../fintekkers/models/util/version_pb';
|
|
13
|
+
import { PortfolioProto } from '../../fintekkers/models/portfolio/portfolio_pb';
|
|
14
|
+
import { PositionProto } from '../../fintekkers/models/position/position_pb';
|
|
15
|
+
import { PositionFilterProto } from '../../fintekkers/models/position/position_filter_pb';
|
|
16
|
+
import { PriceProto } from '../../fintekkers/models/price/price_pb';
|
|
17
|
+
import { IssuanceProto } from '../../fintekkers/models/security/bond/issuance_pb';
|
|
18
|
+
import { IdentifierProto } from '../../fintekkers/models/security/identifier/identifier_pb';
|
|
19
|
+
import { IndexCompositionProto } from '../../fintekkers/models/security/index_composition_pb';
|
|
20
|
+
import { SecurityProto } from '../../fintekkers/models/security/security_pb';
|
|
21
|
+
import { TenorProto } from '../../fintekkers/models/security/tenor_pb';
|
|
22
|
+
import { StrategyProto } from '../../fintekkers/models/strategy/strategy_pb';
|
|
23
|
+
import { StrategyAllocationProto } from '../../fintekkers/models/strategy/strategy_allocation_pb';
|
|
24
|
+
import { TransactionProto } from '../../fintekkers/models/transaction/transaction_pb';
|
|
25
|
+
import { API_Key } from '../../fintekkers/models/util/api/api_key_pb';
|
|
26
|
+
import { DateRangeProto } from '../../fintekkers/models/util/date_range_pb';
|
|
27
|
+
import { NodePartition } from '../../fintekkers/models/util/lock/node_partition_pb';
|
|
28
|
+
import { NodeState } from '../../fintekkers/models/util/lock/node_state_pb';
|
|
29
|
+
import { CreateIndexCompositionRequestProto, CreateIndexCompositionResponseProto } from '../../fintekkers/requests/index_composition/create_index_composition_request_pb';
|
|
30
|
+
import { GetIndexCompositionRequestProto, GetIndexCompositionResponseProto } from '../../fintekkers/requests/index_composition/get_index_composition_request_pb';
|
|
31
|
+
import { CreatePortfolioRequestProto } from '../../fintekkers/requests/portfolio/create_portfolio_request_pb';
|
|
32
|
+
import { CreatePortfolioResponseProto } from '../../fintekkers/requests/portfolio/create_portfolio_response_pb';
|
|
33
|
+
import { QueryPortfolioRequestProto } from '../../fintekkers/requests/portfolio/query_portfolio_request_pb';
|
|
34
|
+
import { QueryPortfolioResponseProto } from '../../fintekkers/requests/portfolio/query_portfolio_response_pb';
|
|
35
|
+
import { QueryPositionRequestProto } from '../../fintekkers/requests/position/query_position_request_pb';
|
|
36
|
+
import { QueryPositionResponseProto } from '../../fintekkers/requests/position/query_position_response_pb';
|
|
37
|
+
import { CreatePriceRequestProto } from '../../fintekkers/requests/price/create_price_request_pb';
|
|
38
|
+
import { CreatePriceResponseProto } from '../../fintekkers/requests/price/create_price_response_pb';
|
|
39
|
+
import { QueryPriceRequestProto } from '../../fintekkers/requests/price/query_price_request_pb';
|
|
40
|
+
import { QueryPriceResponseProto } from '../../fintekkers/requests/price/query_price_response_pb';
|
|
41
|
+
import { CreateSecurityRequestProto } from '../../fintekkers/requests/security/create_security_request_pb';
|
|
42
|
+
import { CreateSecurityResponseProto } from '../../fintekkers/requests/security/create_security_response_pb';
|
|
43
|
+
import { GetFieldValuesRequestProto } from '../../fintekkers/requests/security/get_field_values_request_pb';
|
|
44
|
+
import { GetFieldValuesResponseProto } from '../../fintekkers/requests/security/get_field_values_response_pb';
|
|
45
|
+
import { GetFieldsResponseProto } from '../../fintekkers/requests/security/get_fields_response_pb';
|
|
46
|
+
import { QuerySecurityRequestProto } from '../../fintekkers/requests/security/query_security_request_pb';
|
|
47
|
+
import { QuerySecurityResponseProto } from '../../fintekkers/requests/security/query_security_response_pb';
|
|
48
|
+
import { CreateTransactionRequestProto } from '../../fintekkers/requests/transaction/create_transaction_request_pb';
|
|
49
|
+
import { CreateTransactionResponseProto } from '../../fintekkers/requests/transaction/create_transaction_response_pb';
|
|
50
|
+
import { QueryTransactionRequestProto } from '../../fintekkers/requests/transaction/query_transaction_request_pb';
|
|
51
|
+
import { QueryTransactionResponseProto } from '../../fintekkers/requests/transaction/query_transaction_response_pb';
|
|
52
|
+
import { DeleteRequestProto, DeleteResponseProto } from '../../fintekkers/requests/util/delete_request_pb';
|
|
53
|
+
import { LockRequestProto } from '../../fintekkers/requests/util/lock/lock_request_pb';
|
|
54
|
+
import { LockResponseProto } from '../../fintekkers/requests/util/lock/lock_response_pb';
|
|
55
|
+
import { CurveRequestProto } from '../../fintekkers/requests/valuation/curve_request_pb';
|
|
56
|
+
import { CurveResponseProto } from '../../fintekkers/requests/valuation/curve_response_pb';
|
|
57
|
+
import { ValuationRequestProto } from '../../fintekkers/requests/valuation/valuation_request_pb';
|
|
58
|
+
import { ValuationResponseProto } from '../../fintekkers/requests/valuation/valuation_response_pb';
|
|
13
59
|
|
|
14
60
|
/** Any generated message that carries object_type and version. */
|
|
15
61
|
export interface ObjectTyped {
|
|
@@ -37,6 +83,89 @@ export function stamp<T extends ObjectTyped>(message: T, objectType: ObjectTypeP
|
|
|
37
83
|
return message;
|
|
38
84
|
}
|
|
39
85
|
|
|
86
|
+
// Each message with object_type: proto full name, generated class, its own
|
|
87
|
+
// ObjectTypeProto value (LM-320). object-type-coverage.test.ts fails when a
|
|
88
|
+
// message in the descriptor set is missing.
|
|
89
|
+
const OWN_TYPE_ROWS: ReadonlyArray<[string, Function, ObjectTypeProto]> = [
|
|
90
|
+
['fintekkers.models.portfolio.PortfolioProto', PortfolioProto, ObjectTypeProto.OBJECT_TYPE_PORTFOLIO],
|
|
91
|
+
['fintekkers.models.position.PositionProto', PositionProto, ObjectTypeProto.OBJECT_TYPE_POSITION],
|
|
92
|
+
['fintekkers.models.position.PositionFilterProto', PositionFilterProto, ObjectTypeProto.OBJECT_TYPE_POSITION_FILTER],
|
|
93
|
+
['fintekkers.models.price.PriceProto', PriceProto, ObjectTypeProto.OBJECT_TYPE_PRICE],
|
|
94
|
+
['fintekkers.models.security.IdentifierProto', IdentifierProto, ObjectTypeProto.OBJECT_TYPE_IDENTIFIER],
|
|
95
|
+
['fintekkers.models.security.SecurityProto', SecurityProto, ObjectTypeProto.OBJECT_TYPE_SECURITY],
|
|
96
|
+
['fintekkers.models.security.TenorProto', TenorProto, ObjectTypeProto.OBJECT_TYPE_TENOR],
|
|
97
|
+
['fintekkers.models.strategy.StrategyProto', StrategyProto, ObjectTypeProto.OBJECT_TYPE_STRATEGY],
|
|
98
|
+
['fintekkers.models.strategy.StrategyAllocationProto', StrategyAllocationProto, ObjectTypeProto.OBJECT_TYPE_STRATEGY_ALLOCATION],
|
|
99
|
+
['fintekkers.models.transaction.TransactionProto', TransactionProto, ObjectTypeProto.OBJECT_TYPE_TRANSACTION],
|
|
100
|
+
['fintekkers.requests.portfolio.CreatePortfolioRequestProto', CreatePortfolioRequestProto, ObjectTypeProto.OBJECT_TYPE_CREATE_PORTFOLIO_REQUEST],
|
|
101
|
+
['fintekkers.requests.portfolio.QueryPortfolioRequestProto', QueryPortfolioRequestProto, ObjectTypeProto.OBJECT_TYPE_QUERY_PORTFOLIO_REQUEST],
|
|
102
|
+
['fintekkers.requests.price.CreatePriceRequestProto', CreatePriceRequestProto, ObjectTypeProto.OBJECT_TYPE_CREATE_PRICE_REQUEST],
|
|
103
|
+
['fintekkers.requests.price.QueryPriceRequestProto', QueryPriceRequestProto, ObjectTypeProto.OBJECT_TYPE_QUERY_PRICE_REQUEST],
|
|
104
|
+
['fintekkers.requests.security.CreateSecurityRequestProto', CreateSecurityRequestProto, ObjectTypeProto.OBJECT_TYPE_CREATE_SECURITY_REQUEST],
|
|
105
|
+
['fintekkers.requests.security.QuerySecurityRequestProto', QuerySecurityRequestProto, ObjectTypeProto.OBJECT_TYPE_QUERY_SECURITY_REQUEST],
|
|
106
|
+
['fintekkers.requests.transaction.CreateTransactionRequestProto', CreateTransactionRequestProto, ObjectTypeProto.OBJECT_TYPE_CREATE_TRANSACTION_REQUEST],
|
|
107
|
+
['fintekkers.requests.transaction.QueryTransactionRequestProto', QueryTransactionRequestProto, ObjectTypeProto.OBJECT_TYPE_QUERY_TRANSACTION_REQUEST],
|
|
108
|
+
// LM-320: the rest of the messages with object_type.
|
|
109
|
+
['fintekkers.models.security.bond.IssuanceProto', IssuanceProto, ObjectTypeProto.OBJECT_TYPE_ISSUANCE],
|
|
110
|
+
['fintekkers.models.security.IndexCompositionProto', IndexCompositionProto, ObjectTypeProto.OBJECT_TYPE_INDEX_COMPOSITION],
|
|
111
|
+
['fintekkers.models.util.DateRangeProto', DateRangeProto, ObjectTypeProto.OBJECT_TYPE_DATE_RANGE],
|
|
112
|
+
['fintekkers.models.util.api.API_Key', API_Key, ObjectTypeProto.OBJECT_TYPE_API_KEY],
|
|
113
|
+
['fintekkers.models.util.lock.NodeState', NodeState, ObjectTypeProto.OBJECT_TYPE_NODE_STATE],
|
|
114
|
+
['fintekkers.models.util.lock.NodePartition', NodePartition, ObjectTypeProto.OBJECT_TYPE_NODE_PARTITION],
|
|
115
|
+
['fintekkers.requests.index_composition.CreateIndexCompositionRequestProto', CreateIndexCompositionRequestProto, ObjectTypeProto.OBJECT_TYPE_CREATE_INDEX_COMPOSITION_REQUEST],
|
|
116
|
+
['fintekkers.requests.index_composition.CreateIndexCompositionResponseProto', CreateIndexCompositionResponseProto, ObjectTypeProto.OBJECT_TYPE_CREATE_INDEX_COMPOSITION_RESPONSE],
|
|
117
|
+
['fintekkers.requests.index_composition.GetIndexCompositionRequestProto', GetIndexCompositionRequestProto, ObjectTypeProto.OBJECT_TYPE_GET_INDEX_COMPOSITION_REQUEST],
|
|
118
|
+
['fintekkers.requests.index_composition.GetIndexCompositionResponseProto', GetIndexCompositionResponseProto, ObjectTypeProto.OBJECT_TYPE_GET_INDEX_COMPOSITION_RESPONSE],
|
|
119
|
+
['fintekkers.requests.portfolio.CreatePortfolioResponseProto', CreatePortfolioResponseProto, ObjectTypeProto.OBJECT_TYPE_CREATE_PORTFOLIO_RESPONSE],
|
|
120
|
+
['fintekkers.requests.portfolio.QueryPortfolioResponseProto', QueryPortfolioResponseProto, ObjectTypeProto.OBJECT_TYPE_QUERY_PORTFOLIO_RESPONSE],
|
|
121
|
+
['fintekkers.requests.position.QueryPositionRequestProto', QueryPositionRequestProto, ObjectTypeProto.OBJECT_TYPE_QUERY_POSITION_REQUEST],
|
|
122
|
+
['fintekkers.requests.position.QueryPositionResponseProto', QueryPositionResponseProto, ObjectTypeProto.OBJECT_TYPE_QUERY_POSITION_RESPONSE],
|
|
123
|
+
['fintekkers.requests.price.CreatePriceResponseProto', CreatePriceResponseProto, ObjectTypeProto.OBJECT_TYPE_CREATE_PRICE_RESPONSE],
|
|
124
|
+
['fintekkers.requests.price.QueryPriceResponseProto', QueryPriceResponseProto, ObjectTypeProto.OBJECT_TYPE_QUERY_PRICE_RESPONSE],
|
|
125
|
+
['fintekkers.requests.security.CreateSecurityResponseProto', CreateSecurityResponseProto, ObjectTypeProto.OBJECT_TYPE_CREATE_SECURITY_RESPONSE],
|
|
126
|
+
['fintekkers.requests.security.QuerySecurityResponseProto', QuerySecurityResponseProto, ObjectTypeProto.OBJECT_TYPE_QUERY_SECURITY_RESPONSE],
|
|
127
|
+
['fintekkers.requests.security.GetFieldsResponseProto', GetFieldsResponseProto, ObjectTypeProto.OBJECT_TYPE_GET_FIELDS_RESPONSE],
|
|
128
|
+
['fintekkers.requests.security.GetFieldValuesRequestProto', GetFieldValuesRequestProto, ObjectTypeProto.OBJECT_TYPE_GET_FIELD_VALUES_REQUEST],
|
|
129
|
+
['fintekkers.requests.security.GetFieldValuesResponseProto', GetFieldValuesResponseProto, ObjectTypeProto.OBJECT_TYPE_GET_FIELD_VALUES_RESPONSE],
|
|
130
|
+
['fintekkers.requests.transaction.CreateTransactionResponseProto', CreateTransactionResponseProto, ObjectTypeProto.OBJECT_TYPE_CREATE_TRANSACTION_RESPONSE],
|
|
131
|
+
['fintekkers.requests.transaction.QueryTransactionResponseProto', QueryTransactionResponseProto, ObjectTypeProto.OBJECT_TYPE_QUERY_TRANSACTION_RESPONSE],
|
|
132
|
+
['fintekkers.requests.util.DeleteRequestProto', DeleteRequestProto, ObjectTypeProto.OBJECT_TYPE_DELETE_REQUEST],
|
|
133
|
+
['fintekkers.requests.util.DeleteResponseProto', DeleteResponseProto, ObjectTypeProto.OBJECT_TYPE_DELETE_RESPONSE],
|
|
134
|
+
['fintekkers.requests.util.lock.LockRequestProto', LockRequestProto, ObjectTypeProto.OBJECT_TYPE_LOCK_REQUEST],
|
|
135
|
+
['fintekkers.requests.util.lock.LockResponseProto', LockResponseProto, ObjectTypeProto.OBJECT_TYPE_LOCK_RESPONSE],
|
|
136
|
+
['fintekkers.requests.valuation.ValuationRequestProto', ValuationRequestProto, ObjectTypeProto.OBJECT_TYPE_VALUATION_REQUEST],
|
|
137
|
+
['fintekkers.requests.valuation.ValuationResponseProto', ValuationResponseProto, ObjectTypeProto.OBJECT_TYPE_VALUATION_RESPONSE],
|
|
138
|
+
['fintekkers.requests.valuation.CurveRequestProto', CurveRequestProto, ObjectTypeProto.OBJECT_TYPE_CURVE_REQUEST],
|
|
139
|
+
['fintekkers.requests.valuation.CurveResponseProto', CurveResponseProto, ObjectTypeProto.OBJECT_TYPE_CURVE_RESPONSE],
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
const OWN_TYPES: ReadonlyMap<Function, ObjectTypeProto> = new Map(
|
|
143
|
+
OWN_TYPE_ROWS.map(([, messageClass, objectType]) => [messageClass, objectType]),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
/** Each message with object_type, by proto full name, to its own ObjectTypeProto value. */
|
|
147
|
+
export const OWN_TYPE_NAMES: ReadonlyMap<string, ObjectTypeProto> = new Map(
|
|
148
|
+
OWN_TYPE_ROWS.map(([fullName, , objectType]) => [fullName, objectType]),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
/** The message's own ObjectTypeProto value, or undefined when its class has none. */
|
|
152
|
+
export function ownType(message: object): ObjectTypeProto | undefined {
|
|
153
|
+
return OWN_TYPES.get(message.constructor);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* `stamp` with the message's own ObjectTypeProto value (LM-320); returns it.
|
|
158
|
+
* Throws an Error when its class has no own value. Generated classes are
|
|
159
|
+
* anonymous at runtime, so the error names the class only when it has a name.
|
|
160
|
+
*/
|
|
161
|
+
export function stampOwn<T extends ObjectTyped>(message: T): T {
|
|
162
|
+
const objectType = ownType(message);
|
|
163
|
+
if (objectType === undefined) {
|
|
164
|
+
throw new Error(`${message.constructor?.name || 'this message type'} has no own ObjectTypeProto`);
|
|
165
|
+
}
|
|
166
|
+
return stamp(message, objectType);
|
|
167
|
+
}
|
|
168
|
+
|
|
40
169
|
/**
|
|
41
170
|
* The message's ObjectTypeProto value; OBJECT_TYPE_UNKNOWN when unset. A value
|
|
42
171
|
* added after this build is returned as its number.
|