@fintekkers/ledger-models 0.1.134 → 0.1.136

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,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,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
+ }
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.134",
4
+ "version": "0.1.136",
5
5
  "description": "ledger model protos ",
6
6
  "authors": [
7
7
  "David Doherty",