@fintekkers/ledger-models 0.1.133 → 0.1.134

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.
@@ -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,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,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,C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+ 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,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;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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
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fintekkers/ledger-models",
3
3
  "todo": "Replace the version with build script version number",
4
- "version": "0.1.133",
4
+ "version": "0.1.134",
5
5
  "description": "ledger model protos ",
6
6
  "authors": [
7
7
  "David Doherty",