@fintekkers/ledger-models 0.1.133 → 0.1.135
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/asset_class_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/asset_class_pb.d.ts +15 -0
- package/node/fintekkers/models/security/asset_class_pb.js +36 -0
- package/node/wrappers/models/position/position_filter_operator.d.ts +28 -0
- package/node/wrappers/models/position/position_filter_operator.js +53 -0
- package/node/wrappers/models/position/position_filter_operator.js.map +1 -0
- package/node/wrappers/models/position/position_filter_operator.test.d.ts +1 -0
- package/node/wrappers/models/position/position_filter_operator.test.js +61 -0
- package/node/wrappers/models/position/position_filter_operator.test.js.map +1 -0
- package/node/wrappers/models/position/position_filter_operator.test.ts +68 -0
- package/node/wrappers/models/position/position_filter_operator.ts +55 -0
- package/node/wrappers/models/security/asset_class.d.ts +37 -0
- package/node/wrappers/models/security/asset_class.js +51 -0
- package/node/wrappers/models/security/asset_class.js.map +1 -0
- package/node/wrappers/models/security/asset_class.test.d.ts +1 -0
- package/node/wrappers/models/security/asset_class.test.js +52 -0
- package/node/wrappers/models/security/asset_class.test.js.map +1 -0
- package/node/wrappers/models/security/asset_class.test.ts +58 -0
- package/node/wrappers/models/security/asset_class.ts +53 -0
- package/node/wrappers/models/security/security_type.d.ts +31 -0
- package/node/wrappers/models/security/security_type.js +45 -0
- package/node/wrappers/models/security/security_type.js.map +1 -0
- package/node/wrappers/models/security/security_type.test.d.ts +1 -0
- package/node/wrappers/models/security/security_type.test.js +64 -0
- package/node/wrappers/models/security/security_type.test.js.map +1 -0
- package/node/wrappers/models/security/security_type.test.ts +70 -0
- package/node/wrappers/models/security/security_type.ts +47 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// GENERATED CODE -- NO SERVICES IN PROTO
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// package: fintekkers.models.security
|
|
2
|
+
// file: fintekkers/models/security/asset_class.proto
|
|
3
|
+
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
|
|
7
|
+
import * as jspb from "google-protobuf";
|
|
8
|
+
|
|
9
|
+
export enum AssetClassProto {
|
|
10
|
+
UNKNOWN_ASSET_CLASS = 0,
|
|
11
|
+
FIXED_INCOME = 1,
|
|
12
|
+
EQUITY = 2,
|
|
13
|
+
CASH_ASSET_CLASS = 3,
|
|
14
|
+
INDEX = 4,
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// source: fintekkers/models/security/asset_class.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
|
+
goog.exportSymbol('proto.fintekkers.models.security.AssetClassProto', null, global);
|
|
25
|
+
/**
|
|
26
|
+
* @enum {number}
|
|
27
|
+
*/
|
|
28
|
+
proto.fintekkers.models.security.AssetClassProto = {
|
|
29
|
+
UNKNOWN_ASSET_CLASS: 0,
|
|
30
|
+
FIXED_INCOME: 1,
|
|
31
|
+
EQUITY: 2,
|
|
32
|
+
CASH_ASSET_CLASS: 3,
|
|
33
|
+
INDEX: 4
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
goog.object.extend(exports, proto.fintekkers.models.security);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PositionFilterOperator as PositionFilterOperatorEnum } from '../../../fintekkers/models/position/position_util_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Static helpers around the PositionFilterOperator proto enum, mirroring
|
|
4
|
+
* the Identifier / SecurityType / AssetClass wrapper pattern shipped in
|
|
5
|
+
* v0.1.133–v0.1.134 (PRs #188, #189).
|
|
6
|
+
*
|
|
7
|
+
* Strict: takes / returns proto enum NAMES ("MORE_THAN", "LESS_THAN_OR_EQUALS",
|
|
8
|
+
* ...). Consumers (including UI URL conventions) should standardize on
|
|
9
|
+
* proto names — ledger-models is the source-of-truth vocabulary and
|
|
10
|
+
* should not absorb consumer-side naming conventions. See
|
|
11
|
+
* FinTekkers/second-brain#229 for the ui-service migration path.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PositionFilterOperator {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the names of all known PositionFilterOperator values, EXCLUDING
|
|
16
|
+
* the sentinel `UNKNOWN_OPERATOR`. Drives UI dropdowns / pickers so
|
|
17
|
+
* adding a new proto enum variant auto-propagates to consumers.
|
|
18
|
+
*
|
|
19
|
+
* Order matches proto declaration order.
|
|
20
|
+
*/
|
|
21
|
+
static getAllTypeNames(): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a proto enum NAME (e.g., "MORE_THAN", "EQUALS") to its numeric
|
|
24
|
+
* PositionFilterOperator value. Throws on unknown name; the error lists
|
|
25
|
+
* the valid names so typos are fixable without grepping the proto.
|
|
26
|
+
*/
|
|
27
|
+
static fromName(name: string): PositionFilterOperatorEnum;
|
|
28
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PositionFilterOperator = void 0;
|
|
4
|
+
// The proto module exports the enum as `PositionFilterOperator` (no `Proto`
|
|
5
|
+
// suffix, unlike SecurityTypeProto / AssetClassProto / IdentifierTypeProto).
|
|
6
|
+
// Renamed on import to free the natural class name for the wrapper. Consumers
|
|
7
|
+
// who want the enum type for their own annotations can import directly from
|
|
8
|
+
// the proto module:
|
|
9
|
+
//
|
|
10
|
+
// import { PositionFilterOperator } from '@fintekkers/.../position_util_pb';
|
|
11
|
+
//
|
|
12
|
+
// vs. importing the wrapper helpers from this file:
|
|
13
|
+
//
|
|
14
|
+
// import { PositionFilterOperator } from '@fintekkers/.../position_filter_operator';
|
|
15
|
+
const position_util_pb_1 = require("../../../fintekkers/models/position/position_util_pb");
|
|
16
|
+
/**
|
|
17
|
+
* Static helpers around the PositionFilterOperator proto enum, mirroring
|
|
18
|
+
* the Identifier / SecurityType / AssetClass wrapper pattern shipped in
|
|
19
|
+
* v0.1.133–v0.1.134 (PRs #188, #189).
|
|
20
|
+
*
|
|
21
|
+
* Strict: takes / returns proto enum NAMES ("MORE_THAN", "LESS_THAN_OR_EQUALS",
|
|
22
|
+
* ...). Consumers (including UI URL conventions) should standardize on
|
|
23
|
+
* proto names — ledger-models is the source-of-truth vocabulary and
|
|
24
|
+
* should not absorb consumer-side naming conventions. See
|
|
25
|
+
* FinTekkers/second-brain#229 for the ui-service migration path.
|
|
26
|
+
*/
|
|
27
|
+
class PositionFilterOperator {
|
|
28
|
+
/**
|
|
29
|
+
* Returns the names of all known PositionFilterOperator values, EXCLUDING
|
|
30
|
+
* the sentinel `UNKNOWN_OPERATOR`. Drives UI dropdowns / pickers so
|
|
31
|
+
* adding a new proto enum variant auto-propagates to consumers.
|
|
32
|
+
*
|
|
33
|
+
* Order matches proto declaration order.
|
|
34
|
+
*/
|
|
35
|
+
static getAllTypeNames() {
|
|
36
|
+
return Object.keys(position_util_pb_1.PositionFilterOperator).filter(k => k !== 'UNKNOWN_OPERATOR');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a proto enum NAME (e.g., "MORE_THAN", "EQUALS") to its numeric
|
|
40
|
+
* PositionFilterOperator value. Throws on unknown name; the error lists
|
|
41
|
+
* the valid names so typos are fixable without grepping the proto.
|
|
42
|
+
*/
|
|
43
|
+
static fromName(name) {
|
|
44
|
+
const enumObj = position_util_pb_1.PositionFilterOperator;
|
|
45
|
+
const enumValue = enumObj[name];
|
|
46
|
+
if (enumValue === undefined) {
|
|
47
|
+
throw new Error(`Unknown PositionFilterOperator name: '${name}'. Valid names: ${PositionFilterOperator.getAllTypeNames().join(', ')}`);
|
|
48
|
+
}
|
|
49
|
+
return enumValue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.PositionFilterOperator = PositionFilterOperator;
|
|
53
|
+
//# sourceMappingURL=position_filter_operator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position_filter_operator.js","sourceRoot":"","sources":["position_filter_operator.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,oBAAoB;AACpB,EAAE;AACF,+EAA+E;AAC/E,EAAE;AACF,oDAAoD;AACpD,EAAE;AACF,uFAAuF;AACvF,2FAA4H;AAE5H;;;;;;;;;;GAUG;AACH,MAAa,sBAAsB;IAE/B;;;;;;OAMG;IACH,MAAM,CAAC,eAAe;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,yCAA0B,CAAC,CAAC,MAAM,CACjD,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,kBAAkB,CAChC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY;QACxB,MAAM,OAAO,GAAG,yCAA+D,CAAC;QAChF,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACX,yCAAyC,IAAI,mBAAmB,sBAAsB,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxH,CAAC;SACL;QACD,OAAO,SAAuC,CAAC;IACnD,CAAC;CACJ;AA9BD,wDA8BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const position_filter_operator_1 = require("./position_filter_operator");
|
|
4
|
+
const position_util_pb_1 = require("../../../fintekkers/models/position/position_util_pb");
|
|
5
|
+
describe('PositionFilterOperator.fromName', () => {
|
|
6
|
+
test.each(position_filter_operator_1.PositionFilterOperator.getAllTypeNames())('fromName("%s") returns the matching numeric enum value', (name) => {
|
|
7
|
+
const value = position_filter_operator_1.PositionFilterOperator.fromName(name);
|
|
8
|
+
const expected = position_util_pb_1.PositionFilterOperator[name];
|
|
9
|
+
expect(value).toBe(expected);
|
|
10
|
+
});
|
|
11
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
12
|
+
let err;
|
|
13
|
+
try {
|
|
14
|
+
position_filter_operator_1.PositionFilterOperator.fromName('NOT_A_REAL_OPERATOR');
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
err = e;
|
|
18
|
+
}
|
|
19
|
+
expect(err).toBeDefined();
|
|
20
|
+
expect(err.message).toContain('NOT_A_REAL_OPERATOR');
|
|
21
|
+
expect(err.message).toContain('EQUALS');
|
|
22
|
+
expect(err.message).toContain('MORE_THAN');
|
|
23
|
+
});
|
|
24
|
+
test('throws on lowercase URL-style input (fromName takes proto enum names)', () => {
|
|
25
|
+
// ledger-models is the source-of-truth vocabulary; consumers
|
|
26
|
+
// (including URL conventions in UI) standardize on proto names.
|
|
27
|
+
// Pin the strict behavior so this contract is loudly tested.
|
|
28
|
+
expect(() => position_filter_operator_1.PositionFilterOperator.fromName('greater_than')).toThrow();
|
|
29
|
+
expect(() => position_filter_operator_1.PositionFilterOperator.fromName('more_than')).toThrow();
|
|
30
|
+
});
|
|
31
|
+
test('accepts UNKNOWN_OPERATOR — sentinel is a valid enum key', () => {
|
|
32
|
+
// Excluded from getAllTypeNames (no dropdown surface) but still a
|
|
33
|
+
// valid proto enum value. Mirrors Identifier / SecurityType /
|
|
34
|
+
// AssetClass behavior.
|
|
35
|
+
expect(position_filter_operator_1.PositionFilterOperator.fromName('UNKNOWN_OPERATOR')).toBe(position_util_pb_1.PositionFilterOperator.UNKNOWN_OPERATOR);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('PositionFilterOperator.getAllTypeNames', () => {
|
|
39
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN_OPERATOR', () => {
|
|
40
|
+
// Proto-declared order in position_util.proto:
|
|
41
|
+
// UNKNOWN_OPERATOR = 0; (excluded)
|
|
42
|
+
// EQUALS = 1;
|
|
43
|
+
// NOT_EQUALS = 2;
|
|
44
|
+
// LESS_THAN = 3;
|
|
45
|
+
// LESS_THAN_OR_EQUALS = 4;
|
|
46
|
+
// MORE_THAN = 5;
|
|
47
|
+
// MORE_THAN_OR_EQUALS = 6;
|
|
48
|
+
expect(position_filter_operator_1.PositionFilterOperator.getAllTypeNames()).toEqual([
|
|
49
|
+
'EQUALS',
|
|
50
|
+
'NOT_EQUALS',
|
|
51
|
+
'LESS_THAN',
|
|
52
|
+
'LESS_THAN_OR_EQUALS',
|
|
53
|
+
'MORE_THAN',
|
|
54
|
+
'MORE_THAN_OR_EQUALS',
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
test('excludes the UNKNOWN_OPERATOR sentinel', () => {
|
|
58
|
+
expect(position_filter_operator_1.PositionFilterOperator.getAllTypeNames()).not.toContain('UNKNOWN_OPERATOR');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=position_filter_operator.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position_filter_operator.test.js","sourceRoot":"","sources":["position_filter_operator.test.ts"],"names":[],"mappings":";;AAAA,yEAAoE;AACpE,2FAA4H;AAE5H,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC7C,IAAI,CAAC,IAAI,CAAC,iDAAsB,CAAC,eAAe,EAAE,CAAC,CAC/C,wDAAwD,EACxD,CAAC,IAAY,EAAE,EAAE;QACb,MAAM,KAAK,GAAG,iDAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAI,yCAAgE,CAAC,IAAI,CAAC,CAAC;QACzF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CACJ,CAAC;IAEF,IAAI,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,IAAI,GAAsB,CAAC;QAC3B,IAAI;YACA,iDAAsB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;SAC1D;QAAC,OAAO,CAAC,EAAE;YACR,GAAG,GAAG,CAAU,CAAC;SACpB;QACD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACtD,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,6DAA6D;QAC7D,gEAAgE;QAChE,6DAA6D;QAC7D,MAAM,CAAC,GAAG,EAAE,CAAC,iDAAsB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACxE,MAAM,CAAC,GAAG,EAAE,CAAC,iDAAsB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,kEAAkE;QAClE,8DAA8D;QAC9D,uBAAuB;QACvB,MAAM,CAAC,iDAAsB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAC5D,yCAA0B,CAAC,gBAAgB,CAC9C,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACpD,IAAI,CAAC,iFAAiF,EAAE,GAAG,EAAE;QACzF,+CAA+C;QAC/C,4CAA4C;QAC5C,gBAAgB;QAChB,oBAAoB;QACpB,mBAAmB;QACnB,6BAA6B;QAC7B,mBAAmB;QACnB,6BAA6B;QAC7B,MAAM,CAAC,iDAAsB,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC;YACrD,QAAQ;YACR,YAAY;YACZ,WAAW;YACX,qBAAqB;YACrB,WAAW;YACX,qBAAqB;SACxB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,iDAAsB,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { PositionFilterOperator } from './position_filter_operator';
|
|
2
|
+
import { PositionFilterOperator as PositionFilterOperatorEnum } from '../../../fintekkers/models/position/position_util_pb';
|
|
3
|
+
|
|
4
|
+
describe('PositionFilterOperator.fromName', () => {
|
|
5
|
+
test.each(PositionFilterOperator.getAllTypeNames())(
|
|
6
|
+
'fromName("%s") returns the matching numeric enum value',
|
|
7
|
+
(name: string) => {
|
|
8
|
+
const value = PositionFilterOperator.fromName(name);
|
|
9
|
+
const expected = (PositionFilterOperatorEnum as unknown as Record<string, number>)[name];
|
|
10
|
+
expect(value).toBe(expected);
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
15
|
+
let err: Error | undefined;
|
|
16
|
+
try {
|
|
17
|
+
PositionFilterOperator.fromName('NOT_A_REAL_OPERATOR');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
err = e as Error;
|
|
20
|
+
}
|
|
21
|
+
expect(err).toBeDefined();
|
|
22
|
+
expect(err!.message).toContain('NOT_A_REAL_OPERATOR');
|
|
23
|
+
expect(err!.message).toContain('EQUALS');
|
|
24
|
+
expect(err!.message).toContain('MORE_THAN');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('throws on lowercase URL-style input (fromName takes proto enum names)', () => {
|
|
28
|
+
// ledger-models is the source-of-truth vocabulary; consumers
|
|
29
|
+
// (including URL conventions in UI) standardize on proto names.
|
|
30
|
+
// Pin the strict behavior so this contract is loudly tested.
|
|
31
|
+
expect(() => PositionFilterOperator.fromName('greater_than')).toThrow();
|
|
32
|
+
expect(() => PositionFilterOperator.fromName('more_than')).toThrow();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('accepts UNKNOWN_OPERATOR — sentinel is a valid enum key', () => {
|
|
36
|
+
// Excluded from getAllTypeNames (no dropdown surface) but still a
|
|
37
|
+
// valid proto enum value. Mirrors Identifier / SecurityType /
|
|
38
|
+
// AssetClass behavior.
|
|
39
|
+
expect(PositionFilterOperator.fromName('UNKNOWN_OPERATOR')).toBe(
|
|
40
|
+
PositionFilterOperatorEnum.UNKNOWN_OPERATOR
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('PositionFilterOperator.getAllTypeNames', () => {
|
|
46
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN_OPERATOR', () => {
|
|
47
|
+
// Proto-declared order in position_util.proto:
|
|
48
|
+
// UNKNOWN_OPERATOR = 0; (excluded)
|
|
49
|
+
// EQUALS = 1;
|
|
50
|
+
// NOT_EQUALS = 2;
|
|
51
|
+
// LESS_THAN = 3;
|
|
52
|
+
// LESS_THAN_OR_EQUALS = 4;
|
|
53
|
+
// MORE_THAN = 5;
|
|
54
|
+
// MORE_THAN_OR_EQUALS = 6;
|
|
55
|
+
expect(PositionFilterOperator.getAllTypeNames()).toEqual([
|
|
56
|
+
'EQUALS',
|
|
57
|
+
'NOT_EQUALS',
|
|
58
|
+
'LESS_THAN',
|
|
59
|
+
'LESS_THAN_OR_EQUALS',
|
|
60
|
+
'MORE_THAN',
|
|
61
|
+
'MORE_THAN_OR_EQUALS',
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('excludes the UNKNOWN_OPERATOR sentinel', () => {
|
|
66
|
+
expect(PositionFilterOperator.getAllTypeNames()).not.toContain('UNKNOWN_OPERATOR');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// The proto module exports the enum as `PositionFilterOperator` (no `Proto`
|
|
2
|
+
// suffix, unlike SecurityTypeProto / AssetClassProto / IdentifierTypeProto).
|
|
3
|
+
// Renamed on import to free the natural class name for the wrapper. Consumers
|
|
4
|
+
// who want the enum type for their own annotations can import directly from
|
|
5
|
+
// the proto module:
|
|
6
|
+
//
|
|
7
|
+
// import { PositionFilterOperator } from '@fintekkers/.../position_util_pb';
|
|
8
|
+
//
|
|
9
|
+
// vs. importing the wrapper helpers from this file:
|
|
10
|
+
//
|
|
11
|
+
// import { PositionFilterOperator } from '@fintekkers/.../position_filter_operator';
|
|
12
|
+
import { PositionFilterOperator as PositionFilterOperatorEnum } from '../../../fintekkers/models/position/position_util_pb';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Static helpers around the PositionFilterOperator proto enum, mirroring
|
|
16
|
+
* the Identifier / SecurityType / AssetClass wrapper pattern shipped in
|
|
17
|
+
* v0.1.133–v0.1.134 (PRs #188, #189).
|
|
18
|
+
*
|
|
19
|
+
* Strict: takes / returns proto enum NAMES ("MORE_THAN", "LESS_THAN_OR_EQUALS",
|
|
20
|
+
* ...). Consumers (including UI URL conventions) should standardize on
|
|
21
|
+
* proto names — ledger-models is the source-of-truth vocabulary and
|
|
22
|
+
* should not absorb consumer-side naming conventions. See
|
|
23
|
+
* FinTekkers/second-brain#229 for the ui-service migration path.
|
|
24
|
+
*/
|
|
25
|
+
export class PositionFilterOperator {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the names of all known PositionFilterOperator values, EXCLUDING
|
|
29
|
+
* the sentinel `UNKNOWN_OPERATOR`. Drives UI dropdowns / pickers so
|
|
30
|
+
* adding a new proto enum variant auto-propagates to consumers.
|
|
31
|
+
*
|
|
32
|
+
* Order matches proto declaration order.
|
|
33
|
+
*/
|
|
34
|
+
static getAllTypeNames(): string[] {
|
|
35
|
+
return Object.keys(PositionFilterOperatorEnum).filter(
|
|
36
|
+
k => k !== 'UNKNOWN_OPERATOR'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a proto enum NAME (e.g., "MORE_THAN", "EQUALS") to its numeric
|
|
42
|
+
* PositionFilterOperator value. Throws on unknown name; the error lists
|
|
43
|
+
* the valid names so typos are fixable without grepping the proto.
|
|
44
|
+
*/
|
|
45
|
+
static fromName(name: string): PositionFilterOperatorEnum {
|
|
46
|
+
const enumObj = PositionFilterOperatorEnum as unknown as Record<string, number>;
|
|
47
|
+
const enumValue = enumObj[name];
|
|
48
|
+
if (enumValue === undefined) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Unknown PositionFilterOperator name: '${name}'. Valid names: ${PositionFilterOperator.getAllTypeNames().join(', ')}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return enumValue as PositionFilterOperatorEnum;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AssetClassProto } from '../../../fintekkers/models/security/asset_class_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Static helpers around the AssetClass proto enum, mirroring the
|
|
4
|
+
* Identifier wrapper pattern shipped in v0.1.133 (PR #188) and the
|
|
5
|
+
* SecurityType wrapper alongside this file.
|
|
6
|
+
*
|
|
7
|
+
* Note: SecurityProto.asset_class is currently a `string` field
|
|
8
|
+
* (security.proto field 11). This enum defines the canonical vocabulary;
|
|
9
|
+
* the field type stays string in this release to avoid coordinating a
|
|
10
|
+
* breaking change with downstream services. A follow-up will flip the
|
|
11
|
+
* field type after a data-normalization audit.
|
|
12
|
+
*
|
|
13
|
+
* Until then: producers SHOULD use `AssetClass.getAllTypeNames()` as
|
|
14
|
+
* the source of truth for the legal string values; consumers SHOULD
|
|
15
|
+
* use `AssetClass.fromName(name)` to validate a string against the
|
|
16
|
+
* canonical vocabulary.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AssetClass {
|
|
19
|
+
/**
|
|
20
|
+
* Returns the names of all known AssetClassProto values, EXCLUDING
|
|
21
|
+
* the sentinel `UNKNOWN_ASSET_CLASS`. Drives UI dropdowns / pickers
|
|
22
|
+
* so adding a new proto enum variant auto-propagates to consumers.
|
|
23
|
+
*
|
|
24
|
+
* Order matches proto declaration order.
|
|
25
|
+
*/
|
|
26
|
+
static getAllTypeNames(): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a proto enum NAME (e.g., "FIXED_INCOME", "EQUITY") to its
|
|
29
|
+
* numeric AssetClassProto value. Throws on unknown name; the error
|
|
30
|
+
* lists the valid names so typos are fixable without grepping the
|
|
31
|
+
* proto.
|
|
32
|
+
*
|
|
33
|
+
* @param name proto enum key (e.g., "FIXED_INCOME")
|
|
34
|
+
* @returns the numeric AssetClassProto value
|
|
35
|
+
*/
|
|
36
|
+
static fromName(name: string): AssetClassProto;
|
|
37
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetClass = void 0;
|
|
4
|
+
const asset_class_pb_1 = require("../../../fintekkers/models/security/asset_class_pb");
|
|
5
|
+
/**
|
|
6
|
+
* Static helpers around the AssetClass proto enum, mirroring the
|
|
7
|
+
* Identifier wrapper pattern shipped in v0.1.133 (PR #188) and the
|
|
8
|
+
* SecurityType wrapper alongside this file.
|
|
9
|
+
*
|
|
10
|
+
* Note: SecurityProto.asset_class is currently a `string` field
|
|
11
|
+
* (security.proto field 11). This enum defines the canonical vocabulary;
|
|
12
|
+
* the field type stays string in this release to avoid coordinating a
|
|
13
|
+
* breaking change with downstream services. A follow-up will flip the
|
|
14
|
+
* field type after a data-normalization audit.
|
|
15
|
+
*
|
|
16
|
+
* Until then: producers SHOULD use `AssetClass.getAllTypeNames()` as
|
|
17
|
+
* the source of truth for the legal string values; consumers SHOULD
|
|
18
|
+
* use `AssetClass.fromName(name)` to validate a string against the
|
|
19
|
+
* canonical vocabulary.
|
|
20
|
+
*/
|
|
21
|
+
class AssetClass {
|
|
22
|
+
/**
|
|
23
|
+
* Returns the names of all known AssetClassProto values, EXCLUDING
|
|
24
|
+
* the sentinel `UNKNOWN_ASSET_CLASS`. Drives UI dropdowns / pickers
|
|
25
|
+
* so adding a new proto enum variant auto-propagates to consumers.
|
|
26
|
+
*
|
|
27
|
+
* Order matches proto declaration order.
|
|
28
|
+
*/
|
|
29
|
+
static getAllTypeNames() {
|
|
30
|
+
return Object.keys(asset_class_pb_1.AssetClassProto).filter(k => k !== 'UNKNOWN_ASSET_CLASS');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a proto enum NAME (e.g., "FIXED_INCOME", "EQUITY") to its
|
|
34
|
+
* numeric AssetClassProto value. Throws on unknown name; the error
|
|
35
|
+
* lists the valid names so typos are fixable without grepping the
|
|
36
|
+
* proto.
|
|
37
|
+
*
|
|
38
|
+
* @param name proto enum key (e.g., "FIXED_INCOME")
|
|
39
|
+
* @returns the numeric AssetClassProto value
|
|
40
|
+
*/
|
|
41
|
+
static fromName(name) {
|
|
42
|
+
const enumObj = asset_class_pb_1.AssetClassProto;
|
|
43
|
+
const enumValue = enumObj[name];
|
|
44
|
+
if (enumValue === undefined) {
|
|
45
|
+
throw new Error(`Unknown AssetClass name: '${name}'. Valid names: ${AssetClass.getAllTypeNames().join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
return enumValue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.AssetClass = AssetClass;
|
|
51
|
+
//# sourceMappingURL=asset_class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_class.js","sourceRoot":"","sources":["asset_class.ts"],"names":[],"mappings":";;;AAAA,uFAAqF;AAErF;;;;;;;;;;;;;;;GAeG;AACH,MAAa,UAAU;IAEnB;;;;;;OAMG;IACH,MAAM,CAAC,eAAe;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,gCAAe,CAAC,CAAC,MAAM,CACtC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,qBAAqB,CACnC,CAAC;IACN,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY;QACxB,MAAM,OAAO,GAAG,gCAAoD,CAAC;QACrE,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACX,6BAA6B,IAAI,mBAAmB,UAAU,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChG,CAAC;SACL;QACD,OAAO,SAA4B,CAAC;IACxC,CAAC;CACJ;AAlCD,gCAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const asset_class_1 = require("./asset_class");
|
|
4
|
+
const asset_class_pb_1 = require("../../../fintekkers/models/security/asset_class_pb");
|
|
5
|
+
describe('AssetClass.fromName', () => {
|
|
6
|
+
test.each(asset_class_1.AssetClass.getAllTypeNames())('fromName("%s") returns the matching numeric enum value', (name) => {
|
|
7
|
+
const value = asset_class_1.AssetClass.fromName(name);
|
|
8
|
+
const expected = asset_class_pb_1.AssetClassProto[name];
|
|
9
|
+
expect(value).toBe(expected);
|
|
10
|
+
});
|
|
11
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
12
|
+
let err;
|
|
13
|
+
try {
|
|
14
|
+
asset_class_1.AssetClass.fromName('COMMODITY');
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
err = e;
|
|
18
|
+
}
|
|
19
|
+
expect(err).toBeDefined();
|
|
20
|
+
expect(err.message).toContain('COMMODITY');
|
|
21
|
+
// Hint with valid entries
|
|
22
|
+
expect(err.message).toContain('FIXED_INCOME');
|
|
23
|
+
expect(err.message).toContain('EQUITY');
|
|
24
|
+
});
|
|
25
|
+
test('accepts UNKNOWN_ASSET_CLASS — sentinel is a valid enum key', () => {
|
|
26
|
+
// Same pin as SecurityType / Identifier: excluded from getAllTypeNames
|
|
27
|
+
// (no dropdown surface), but valid via fromName.
|
|
28
|
+
expect(asset_class_1.AssetClass.fromName('UNKNOWN_ASSET_CLASS')).toBe(asset_class_pb_1.AssetClassProto.UNKNOWN_ASSET_CLASS);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('AssetClass.getAllTypeNames', () => {
|
|
32
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN', () => {
|
|
33
|
+
// Proto-declared order in asset_class.proto:
|
|
34
|
+
// UNKNOWN_ASSET_CLASS = 0; (excluded)
|
|
35
|
+
// FIXED_INCOME = 1;
|
|
36
|
+
// EQUITY = 2;
|
|
37
|
+
// CASH_ASSET_CLASS = 3; (suffixed to avoid name collision
|
|
38
|
+
// with IdentifierTypeProto.CASH per
|
|
39
|
+
// proto3 package-wide uniqueness)
|
|
40
|
+
// INDEX = 4;
|
|
41
|
+
expect(asset_class_1.AssetClass.getAllTypeNames()).toEqual([
|
|
42
|
+
'FIXED_INCOME',
|
|
43
|
+
'EQUITY',
|
|
44
|
+
'CASH_ASSET_CLASS',
|
|
45
|
+
'INDEX',
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
test('excludes the UNKNOWN_ASSET_CLASS sentinel', () => {
|
|
49
|
+
expect(asset_class_1.AssetClass.getAllTypeNames()).not.toContain('UNKNOWN_ASSET_CLASS');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=asset_class.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_class.test.js","sourceRoot":"","sources":["asset_class.test.ts"],"names":[],"mappings":";;AAAA,+CAA2C;AAC3C,uFAAqF;AAErF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,IAAI,CAAC,IAAI,CAAC,wBAAU,CAAC,eAAe,EAAE,CAAC,CACnC,wDAAwD,EACxD,CAAC,IAAY,EAAE,EAAE;QACb,MAAM,KAAK,GAAG,wBAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAI,gCAAqD,CAAC,IAAI,CAAC,CAAC;QAC9E,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CACJ,CAAC;IAEF,IAAI,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,IAAI,GAAsB,CAAC;QAC3B,IAAI;YACA,wBAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;SACpC;QAAC,OAAO,CAAC,EAAE;YACR,GAAG,GAAG,CAAU,CAAC;SACpB;QACD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC5C,0BAA0B;QAC1B,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC/C,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,uEAAuE;QACvE,iDAAiD;QACjD,MAAM,CAAC,wBAAU,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CACnD,gCAAe,CAAC,mBAAmB,CACtC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,IAAI,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,6CAA6C;QAC7C,4CAA4C;QAC5C,sBAAsB;QACtB,gBAAgB;QAChB,mEAAmE;QACnE,oEAAoE;QACpE,kEAAkE;QAClE,eAAe;QACf,MAAM,CAAC,wBAAU,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC;YACzC,cAAc;YACd,QAAQ;YACR,kBAAkB;YAClB,OAAO;SACV,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,CAAC,wBAAU,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AssetClass } from './asset_class';
|
|
2
|
+
import { AssetClassProto } from '../../../fintekkers/models/security/asset_class_pb';
|
|
3
|
+
|
|
4
|
+
describe('AssetClass.fromName', () => {
|
|
5
|
+
test.each(AssetClass.getAllTypeNames())(
|
|
6
|
+
'fromName("%s") returns the matching numeric enum value',
|
|
7
|
+
(name: string) => {
|
|
8
|
+
const value = AssetClass.fromName(name);
|
|
9
|
+
const expected = (AssetClassProto as unknown as Record<string, number>)[name];
|
|
10
|
+
expect(value).toBe(expected);
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
15
|
+
let err: Error | undefined;
|
|
16
|
+
try {
|
|
17
|
+
AssetClass.fromName('COMMODITY');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
err = e as Error;
|
|
20
|
+
}
|
|
21
|
+
expect(err).toBeDefined();
|
|
22
|
+
expect(err!.message).toContain('COMMODITY');
|
|
23
|
+
// Hint with valid entries
|
|
24
|
+
expect(err!.message).toContain('FIXED_INCOME');
|
|
25
|
+
expect(err!.message).toContain('EQUITY');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('accepts UNKNOWN_ASSET_CLASS — sentinel is a valid enum key', () => {
|
|
29
|
+
// Same pin as SecurityType / Identifier: excluded from getAllTypeNames
|
|
30
|
+
// (no dropdown surface), but valid via fromName.
|
|
31
|
+
expect(AssetClass.fromName('UNKNOWN_ASSET_CLASS')).toBe(
|
|
32
|
+
AssetClassProto.UNKNOWN_ASSET_CLASS
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('AssetClass.getAllTypeNames', () => {
|
|
38
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN', () => {
|
|
39
|
+
// Proto-declared order in asset_class.proto:
|
|
40
|
+
// UNKNOWN_ASSET_CLASS = 0; (excluded)
|
|
41
|
+
// FIXED_INCOME = 1;
|
|
42
|
+
// EQUITY = 2;
|
|
43
|
+
// CASH_ASSET_CLASS = 3; (suffixed to avoid name collision
|
|
44
|
+
// with IdentifierTypeProto.CASH per
|
|
45
|
+
// proto3 package-wide uniqueness)
|
|
46
|
+
// INDEX = 4;
|
|
47
|
+
expect(AssetClass.getAllTypeNames()).toEqual([
|
|
48
|
+
'FIXED_INCOME',
|
|
49
|
+
'EQUITY',
|
|
50
|
+
'CASH_ASSET_CLASS',
|
|
51
|
+
'INDEX',
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('excludes the UNKNOWN_ASSET_CLASS sentinel', () => {
|
|
56
|
+
expect(AssetClass.getAllTypeNames()).not.toContain('UNKNOWN_ASSET_CLASS');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AssetClassProto } from '../../../fintekkers/models/security/asset_class_pb';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Static helpers around the AssetClass proto enum, mirroring the
|
|
5
|
+
* Identifier wrapper pattern shipped in v0.1.133 (PR #188) and the
|
|
6
|
+
* SecurityType wrapper alongside this file.
|
|
7
|
+
*
|
|
8
|
+
* Note: SecurityProto.asset_class is currently a `string` field
|
|
9
|
+
* (security.proto field 11). This enum defines the canonical vocabulary;
|
|
10
|
+
* the field type stays string in this release to avoid coordinating a
|
|
11
|
+
* breaking change with downstream services. A follow-up will flip the
|
|
12
|
+
* field type after a data-normalization audit.
|
|
13
|
+
*
|
|
14
|
+
* Until then: producers SHOULD use `AssetClass.getAllTypeNames()` as
|
|
15
|
+
* the source of truth for the legal string values; consumers SHOULD
|
|
16
|
+
* use `AssetClass.fromName(name)` to validate a string against the
|
|
17
|
+
* canonical vocabulary.
|
|
18
|
+
*/
|
|
19
|
+
export class AssetClass {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the names of all known AssetClassProto values, EXCLUDING
|
|
23
|
+
* the sentinel `UNKNOWN_ASSET_CLASS`. Drives UI dropdowns / pickers
|
|
24
|
+
* so adding a new proto enum variant auto-propagates to consumers.
|
|
25
|
+
*
|
|
26
|
+
* Order matches proto declaration order.
|
|
27
|
+
*/
|
|
28
|
+
static getAllTypeNames(): string[] {
|
|
29
|
+
return Object.keys(AssetClassProto).filter(
|
|
30
|
+
k => k !== 'UNKNOWN_ASSET_CLASS'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a proto enum NAME (e.g., "FIXED_INCOME", "EQUITY") to its
|
|
36
|
+
* numeric AssetClassProto value. Throws on unknown name; the error
|
|
37
|
+
* lists the valid names so typos are fixable without grepping the
|
|
38
|
+
* proto.
|
|
39
|
+
*
|
|
40
|
+
* @param name proto enum key (e.g., "FIXED_INCOME")
|
|
41
|
+
* @returns the numeric AssetClassProto value
|
|
42
|
+
*/
|
|
43
|
+
static fromName(name: string): AssetClassProto {
|
|
44
|
+
const enumObj = AssetClassProto as unknown as Record<string, number>;
|
|
45
|
+
const enumValue = enumObj[name];
|
|
46
|
+
if (enumValue === undefined) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Unknown AssetClass name: '${name}'. Valid names: ${AssetClass.getAllTypeNames().join(', ')}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return enumValue as AssetClassProto;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Static helpers around the SecurityType proto enum, mirroring the
|
|
4
|
+
* Identifier wrapper pattern shipped in v0.1.133 (PR #188).
|
|
5
|
+
*
|
|
6
|
+
* Lets TS/JS consumers stop hand-typing literal unions and switch
|
|
7
|
+
* statements over `'BOND_SECURITY' | 'TIPS' | 'FRN' | ...` — adding a
|
|
8
|
+
* new variant on the proto side propagates automatically.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SecurityType {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the names of all known SecurityTypeProto values, EXCLUDING
|
|
13
|
+
* the sentinel `UNKNOWN_SECURITY_TYPE`. Drives UI dropdowns / pickers
|
|
14
|
+
* so a new proto enum variant auto-propagates to consumers without
|
|
15
|
+
* any UI-side code change.
|
|
16
|
+
*
|
|
17
|
+
* Order matches proto declaration order (Object.keys preserves
|
|
18
|
+
* insertion order on the generated JS enum object).
|
|
19
|
+
*/
|
|
20
|
+
static getAllTypeNames(): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a proto enum NAME (e.g., "BOND_SECURITY", "EQUITY_SECURITY")
|
|
23
|
+
* to its numeric SecurityTypeProto value. Throws on unknown name; the
|
|
24
|
+
* error lists the valid names so typos are fixable without grepping
|
|
25
|
+
* the proto.
|
|
26
|
+
*
|
|
27
|
+
* @param name proto enum key (e.g., "BOND_SECURITY")
|
|
28
|
+
* @returns the numeric SecurityTypeProto value
|
|
29
|
+
*/
|
|
30
|
+
static fromName(name: string): SecurityTypeProto;
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecurityType = void 0;
|
|
4
|
+
const security_type_pb_1 = require("../../../fintekkers/models/security/security_type_pb");
|
|
5
|
+
/**
|
|
6
|
+
* Static helpers around the SecurityType proto enum, mirroring the
|
|
7
|
+
* Identifier wrapper pattern shipped in v0.1.133 (PR #188).
|
|
8
|
+
*
|
|
9
|
+
* Lets TS/JS consumers stop hand-typing literal unions and switch
|
|
10
|
+
* statements over `'BOND_SECURITY' | 'TIPS' | 'FRN' | ...` — adding a
|
|
11
|
+
* new variant on the proto side propagates automatically.
|
|
12
|
+
*/
|
|
13
|
+
class SecurityType {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the names of all known SecurityTypeProto values, EXCLUDING
|
|
16
|
+
* the sentinel `UNKNOWN_SECURITY_TYPE`. Drives UI dropdowns / pickers
|
|
17
|
+
* so a new proto enum variant auto-propagates to consumers without
|
|
18
|
+
* any UI-side code change.
|
|
19
|
+
*
|
|
20
|
+
* Order matches proto declaration order (Object.keys preserves
|
|
21
|
+
* insertion order on the generated JS enum object).
|
|
22
|
+
*/
|
|
23
|
+
static getAllTypeNames() {
|
|
24
|
+
return Object.keys(security_type_pb_1.SecurityTypeProto).filter(k => k !== 'UNKNOWN_SECURITY_TYPE');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a proto enum NAME (e.g., "BOND_SECURITY", "EQUITY_SECURITY")
|
|
28
|
+
* to its numeric SecurityTypeProto value. Throws on unknown name; the
|
|
29
|
+
* error lists the valid names so typos are fixable without grepping
|
|
30
|
+
* the proto.
|
|
31
|
+
*
|
|
32
|
+
* @param name proto enum key (e.g., "BOND_SECURITY")
|
|
33
|
+
* @returns the numeric SecurityTypeProto value
|
|
34
|
+
*/
|
|
35
|
+
static fromName(name) {
|
|
36
|
+
const enumObj = security_type_pb_1.SecurityTypeProto;
|
|
37
|
+
const enumValue = enumObj[name];
|
|
38
|
+
if (enumValue === undefined) {
|
|
39
|
+
throw new Error(`Unknown SecurityType name: '${name}'. Valid names: ${SecurityType.getAllTypeNames().join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
return enumValue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.SecurityType = SecurityType;
|
|
45
|
+
//# sourceMappingURL=security_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security_type.js","sourceRoot":"","sources":["security_type.ts"],"names":[],"mappings":";;;AAAA,2FAAyF;AAEzF;;;;;;;GAOG;AACH,MAAa,YAAY;IAErB;;;;;;;;OAQG;IACH,MAAM,CAAC,eAAe;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,oCAAiB,CAAC,CAAC,MAAM,CACxC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,uBAAuB,CACrC,CAAC;IACN,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY;QACxB,MAAM,OAAO,GAAG,oCAAsD,CAAC;QACvE,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACX,+BAA+B,IAAI,mBAAmB,YAAY,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpG,CAAC;SACL;QACD,OAAO,SAA8B,CAAC;IAC1C,CAAC;CACJ;AApCD,oCAoCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const security_type_1 = require("./security_type");
|
|
4
|
+
const security_type_pb_1 = require("../../../fintekkers/models/security/security_type_pb");
|
|
5
|
+
describe('SecurityType.fromName', () => {
|
|
6
|
+
// Round-trip: every name returned by getAllTypeNames must resolve to
|
|
7
|
+
// a numeric enum value that maps back to the same name.
|
|
8
|
+
test.each(security_type_1.SecurityType.getAllTypeNames())('fromName("%s") returns the matching numeric enum value', (name) => {
|
|
9
|
+
const value = security_type_1.SecurityType.fromName(name);
|
|
10
|
+
// The proto-generated enum is bidirectionally indexable
|
|
11
|
+
// (Object.keys / numeric-key lookups both work in google-protobuf JS).
|
|
12
|
+
const expected = security_type_pb_1.SecurityTypeProto[name];
|
|
13
|
+
expect(value).toBe(expected);
|
|
14
|
+
});
|
|
15
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
16
|
+
let err;
|
|
17
|
+
try {
|
|
18
|
+
security_type_1.SecurityType.fromName('NOT_A_REAL_TYPE');
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
err = e;
|
|
22
|
+
}
|
|
23
|
+
expect(err).toBeDefined();
|
|
24
|
+
expect(err.message).toContain('NOT_A_REAL_TYPE');
|
|
25
|
+
// Error message should hint with known valid entries.
|
|
26
|
+
expect(err.message).toContain('BOND_SECURITY');
|
|
27
|
+
expect(err.message).toContain('EQUITY_SECURITY');
|
|
28
|
+
});
|
|
29
|
+
test('accepts UNKNOWN_SECURITY_TYPE — sentinel is a valid enum key', () => {
|
|
30
|
+
// It's excluded from getAllTypeNames (so it doesn't appear in
|
|
31
|
+
// dropdowns), but it IS a valid proto enum value, so fromName
|
|
32
|
+
// accepts it. Pinning the existing behavior — flip if policy
|
|
33
|
+
// ever tightens.
|
|
34
|
+
expect(security_type_1.SecurityType.fromName('UNKNOWN_SECURITY_TYPE')).toBe(security_type_pb_1.SecurityTypeProto.UNKNOWN_SECURITY_TYPE);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('SecurityType.getAllTypeNames', () => {
|
|
38
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN', () => {
|
|
39
|
+
// Proto-declared order in security_type.proto:
|
|
40
|
+
// UNKNOWN_SECURITY_TYPE = 0; (excluded)
|
|
41
|
+
// CASH_SECURITY = 1;
|
|
42
|
+
// EQUITY_SECURITY = 2;
|
|
43
|
+
// BOND_SECURITY = 3;
|
|
44
|
+
// TIPS = 4;
|
|
45
|
+
// FRN = 5;
|
|
46
|
+
// INDEX_SECURITY = 6;
|
|
47
|
+
// FX_SPOT = 7;
|
|
48
|
+
// EQUITY_INDEX_SECURITY = 8;
|
|
49
|
+
expect(security_type_1.SecurityType.getAllTypeNames()).toEqual([
|
|
50
|
+
'CASH_SECURITY',
|
|
51
|
+
'EQUITY_SECURITY',
|
|
52
|
+
'BOND_SECURITY',
|
|
53
|
+
'TIPS',
|
|
54
|
+
'FRN',
|
|
55
|
+
'INDEX_SECURITY',
|
|
56
|
+
'FX_SPOT',
|
|
57
|
+
'EQUITY_INDEX_SECURITY',
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
test('excludes the UNKNOWN_SECURITY_TYPE sentinel', () => {
|
|
61
|
+
expect(security_type_1.SecurityType.getAllTypeNames()).not.toContain('UNKNOWN_SECURITY_TYPE');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=security_type.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security_type.test.js","sourceRoot":"","sources":["security_type.test.ts"],"names":[],"mappings":";;AAAA,mDAA+C;AAC/C,2FAAyF;AAEzF,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACnC,qEAAqE;IACrE,wDAAwD;IACxD,IAAI,CAAC,IAAI,CAAC,4BAAY,CAAC,eAAe,EAAE,CAAC,CACrC,wDAAwD,EACxD,CAAC,IAAY,EAAE,EAAE;QACb,MAAM,KAAK,GAAG,4BAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,wDAAwD;QACxD,uEAAuE;QACvE,MAAM,QAAQ,GAAI,oCAAuD,CAAC,IAAI,CAAC,CAAC;QAChF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CACJ,CAAC;IAEF,IAAI,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,IAAI,GAAsB,CAAC;QAC3B,IAAI;YACA,4BAAY,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;SAC5C;QAAC,OAAO,CAAC,EAAE;YACR,GAAG,GAAG,CAAU,CAAC;SACpB;QACD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAClD,sDAAsD;QACtD,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAChD,MAAM,CAAC,GAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,8DAA8D;QAC9D,8DAA8D;QAC9D,6DAA6D;QAC7D,iBAAiB;QACjB,MAAM,CAAC,4BAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CACvD,oCAAiB,CAAC,qBAAqB,CAC1C,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,IAAI,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,+CAA+C;QAC/C,2CAA2C;QAC3C,uBAAuB;QACvB,yBAAyB;QACzB,uBAAuB;QACvB,cAAc;QACd,aAAa;QACb,wBAAwB;QACxB,iBAAiB;QACjB,+BAA+B;QAC/B,MAAM,CAAC,4BAAY,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC;YAC3C,eAAe;YACf,iBAAiB;YACjB,eAAe;YACf,MAAM;YACN,KAAK;YACL,gBAAgB;YAChB,SAAS;YACT,uBAAuB;SAC1B,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,4BAAY,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SecurityType } from './security_type';
|
|
2
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
3
|
+
|
|
4
|
+
describe('SecurityType.fromName', () => {
|
|
5
|
+
// Round-trip: every name returned by getAllTypeNames must resolve to
|
|
6
|
+
// a numeric enum value that maps back to the same name.
|
|
7
|
+
test.each(SecurityType.getAllTypeNames())(
|
|
8
|
+
'fromName("%s") returns the matching numeric enum value',
|
|
9
|
+
(name: string) => {
|
|
10
|
+
const value = SecurityType.fromName(name);
|
|
11
|
+
// The proto-generated enum is bidirectionally indexable
|
|
12
|
+
// (Object.keys / numeric-key lookups both work in google-protobuf JS).
|
|
13
|
+
const expected = (SecurityTypeProto as unknown as Record<string, number>)[name];
|
|
14
|
+
expect(value).toBe(expected);
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
test('throws on unknown name and lists valid names in the error', () => {
|
|
19
|
+
let err: Error | undefined;
|
|
20
|
+
try {
|
|
21
|
+
SecurityType.fromName('NOT_A_REAL_TYPE');
|
|
22
|
+
} catch (e) {
|
|
23
|
+
err = e as Error;
|
|
24
|
+
}
|
|
25
|
+
expect(err).toBeDefined();
|
|
26
|
+
expect(err!.message).toContain('NOT_A_REAL_TYPE');
|
|
27
|
+
// Error message should hint with known valid entries.
|
|
28
|
+
expect(err!.message).toContain('BOND_SECURITY');
|
|
29
|
+
expect(err!.message).toContain('EQUITY_SECURITY');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('accepts UNKNOWN_SECURITY_TYPE — sentinel is a valid enum key', () => {
|
|
33
|
+
// It's excluded from getAllTypeNames (so it doesn't appear in
|
|
34
|
+
// dropdowns), but it IS a valid proto enum value, so fromName
|
|
35
|
+
// accepts it. Pinning the existing behavior — flip if policy
|
|
36
|
+
// ever tightens.
|
|
37
|
+
expect(SecurityType.fromName('UNKNOWN_SECURITY_TYPE')).toBe(
|
|
38
|
+
SecurityTypeProto.UNKNOWN_SECURITY_TYPE
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('SecurityType.getAllTypeNames', () => {
|
|
44
|
+
test('returns the expected set in proto-declaration order, excluding UNKNOWN', () => {
|
|
45
|
+
// Proto-declared order in security_type.proto:
|
|
46
|
+
// UNKNOWN_SECURITY_TYPE = 0; (excluded)
|
|
47
|
+
// CASH_SECURITY = 1;
|
|
48
|
+
// EQUITY_SECURITY = 2;
|
|
49
|
+
// BOND_SECURITY = 3;
|
|
50
|
+
// TIPS = 4;
|
|
51
|
+
// FRN = 5;
|
|
52
|
+
// INDEX_SECURITY = 6;
|
|
53
|
+
// FX_SPOT = 7;
|
|
54
|
+
// EQUITY_INDEX_SECURITY = 8;
|
|
55
|
+
expect(SecurityType.getAllTypeNames()).toEqual([
|
|
56
|
+
'CASH_SECURITY',
|
|
57
|
+
'EQUITY_SECURITY',
|
|
58
|
+
'BOND_SECURITY',
|
|
59
|
+
'TIPS',
|
|
60
|
+
'FRN',
|
|
61
|
+
'INDEX_SECURITY',
|
|
62
|
+
'FX_SPOT',
|
|
63
|
+
'EQUITY_INDEX_SECURITY',
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('excludes the UNKNOWN_SECURITY_TYPE sentinel', () => {
|
|
68
|
+
expect(SecurityType.getAllTypeNames()).not.toContain('UNKNOWN_SECURITY_TYPE');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Static helpers around the SecurityType proto enum, mirroring the
|
|
5
|
+
* Identifier wrapper pattern shipped in v0.1.133 (PR #188).
|
|
6
|
+
*
|
|
7
|
+
* Lets TS/JS consumers stop hand-typing literal unions and switch
|
|
8
|
+
* statements over `'BOND_SECURITY' | 'TIPS' | 'FRN' | ...` — adding a
|
|
9
|
+
* new variant on the proto side propagates automatically.
|
|
10
|
+
*/
|
|
11
|
+
export class SecurityType {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the names of all known SecurityTypeProto values, EXCLUDING
|
|
15
|
+
* the sentinel `UNKNOWN_SECURITY_TYPE`. Drives UI dropdowns / pickers
|
|
16
|
+
* so a new proto enum variant auto-propagates to consumers without
|
|
17
|
+
* any UI-side code change.
|
|
18
|
+
*
|
|
19
|
+
* Order matches proto declaration order (Object.keys preserves
|
|
20
|
+
* insertion order on the generated JS enum object).
|
|
21
|
+
*/
|
|
22
|
+
static getAllTypeNames(): string[] {
|
|
23
|
+
return Object.keys(SecurityTypeProto).filter(
|
|
24
|
+
k => k !== 'UNKNOWN_SECURITY_TYPE'
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a proto enum NAME (e.g., "BOND_SECURITY", "EQUITY_SECURITY")
|
|
30
|
+
* to its numeric SecurityTypeProto value. Throws on unknown name; the
|
|
31
|
+
* error lists the valid names so typos are fixable without grepping
|
|
32
|
+
* the proto.
|
|
33
|
+
*
|
|
34
|
+
* @param name proto enum key (e.g., "BOND_SECURITY")
|
|
35
|
+
* @returns the numeric SecurityTypeProto value
|
|
36
|
+
*/
|
|
37
|
+
static fromName(name: string): SecurityTypeProto {
|
|
38
|
+
const enumObj = SecurityTypeProto as unknown as Record<string, number>;
|
|
39
|
+
const enumValue = enumObj[name];
|
|
40
|
+
if (enumValue === undefined) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Unknown SecurityType name: '${name}'. Valid names: ${SecurityType.getAllTypeNames().join(', ')}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return enumValue as SecurityTypeProto;
|
|
46
|
+
}
|
|
47
|
+
}
|