@acequants/aegis-contracts 0.1.55 → 0.1.57

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/package.json CHANGED
@@ -1,35 +1,35 @@
1
- {
2
- "name": "@acequants/aegis-contracts",
3
- "version": "0.1.55",
4
- "private": false,
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "files": [
10
- "dist/",
11
- "proto/"
12
- ],
13
- "scripts": {
14
- "clean": "rimraf dist src/gen",
15
- "gen": "mkdirp ./src/gen && node ./scripts/generate.cjs",
16
- "build": "tsc -p tsconfig.build.json",
17
- "prepublish": "npm run clean && npm run gen && npm run build"
18
- },
19
- "peerDependencies": {
20
- "@grpc/grpc-js": "^1.10.0",
21
- "protobufjs": "^7.2.0"
22
- },
23
- "devDependencies": {
24
- "@types/node": "^20.19.11",
25
- "mkdirp": "^3.0.1",
26
- "rimraf": "^6.0.0",
27
- "ts-node": "^10.9.2",
28
- "ts-proto": "^1.181.2",
29
- "typescript": "^5.5.0"
30
- },
31
- "dependencies": {
32
- "@nestjs/microservices": "^11.1.6",
33
- "rxjs": "^7.8.2"
34
- }
35
- }
1
+ {
2
+ "name": "@acequants/aegis-contracts",
3
+ "version": "0.1.57",
4
+ "private": false,
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist/",
11
+ "proto/"
12
+ ],
13
+ "scripts": {
14
+ "clean": "rimraf dist src/gen",
15
+ "gen": "mkdirp ./src/gen && node ./scripts/generate.cjs",
16
+ "build": "tsc -p tsconfig.build.json",
17
+ "prepublish": "npm run clean && npm run gen && npm run build"
18
+ },
19
+ "peerDependencies": {
20
+ "@grpc/grpc-js": "^1.10.0",
21
+ "protobufjs": "^7.2.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^20.19.11",
25
+ "mkdirp": "^3.0.1",
26
+ "rimraf": "^6.0.0",
27
+ "ts-node": "^10.9.2",
28
+ "ts-proto": "^1.181.2",
29
+ "typescript": "^5.5.0"
30
+ },
31
+ "dependencies": {
32
+ "@nestjs/microservices": "^11.1.6",
33
+ "rxjs": "^7.8.2"
34
+ }
35
+ }
@@ -7,6 +7,140 @@ option java_multiple_files = true;
7
7
  import "google/protobuf/timestamp.proto";
8
8
  // import "shared/v1/shared.proto";
9
9
 
10
+ //----------------------
11
+ // --- GEOSYCN START ---
12
+ //----------------------
13
+ //
14
+ // Geo* delta-sync surface.
15
+ //
16
+ // aegis owns every Geo* table; gtms holds a read-only mirror refreshed
17
+ // hourly via the RPCs below. Each request carries a server-defined
18
+ // cursor (last seen `updated_at` for watermark-friendly tables; last
19
+ // seen `id` for the 3 bridge tables that have no `updated_at`/
20
+ // `deleted_at` column). Responses are stable-ordered pages with
21
+ // `next_cursor` + `has_more` so the consumer can stream until idle.
22
+ //
23
+ // All timestamp fields carry the source-of-truth (aegis) value; the
24
+ // consumer is free to store its own local audit dates separately.
25
+
26
+ message GrpcInputGeoSync {
27
+ // Opaque cursor — for delta tables this is an ISO8601 string of
28
+ // the last seen `updated_at`; for bridge tables it is the last
29
+ // seen integer `id` rendered as decimal. Empty string = from start.
30
+ string cursor = 1;
31
+ // Server clamps to [100, 2000]; 0 / unset → 500.
32
+ int32 page_size = 2;
33
+ }
34
+
35
+ // ---- Geo DTOs (1:1 with aegis schema scalars + FK publicIds) ----
36
+
37
+ message GrpcDtoGeoTimezone {
38
+ string public_id = 1;
39
+ string iana = 2;
40
+ google.protobuf.Timestamp updated_at = 3;
41
+ google.protobuf.Timestamp deleted_at = 4; // nullable
42
+ }
43
+
44
+ message GrpcDtoGeoCurrency {
45
+ string public_id = 1;
46
+ string code = 2;
47
+ string name = 3;
48
+ string symbol = 4; // nullable, empty = unset
49
+ bool is_base = 5;
50
+ bool is_active = 6;
51
+ string exchange_rate = 7; // Decimal serialised as string
52
+ google.protobuf.Timestamp updated_at = 8;
53
+ google.protobuf.Timestamp deleted_at = 9; // nullable
54
+ }
55
+
56
+ message GrpcDtoGeoLanguage {
57
+ string public_id = 1;
58
+ string iso639_1 = 2; // LANGUAGE enum as string
59
+ string iso639_2 = 3; // nullable
60
+ string name = 4;
61
+ bool is_active = 5;
62
+ google.protobuf.Timestamp updated_at = 6;
63
+ google.protobuf.Timestamp deleted_at = 7; // nullable
64
+ }
65
+
66
+ message GrpcDtoGeoLocale {
67
+ string public_id = 1;
68
+ string language_public_id = 2;
69
+ string code = 3;
70
+ string name = 4;
71
+ google.protobuf.Timestamp updated_at = 5;
72
+ // GeoLocale has no deletedAt in aegis schema.
73
+ }
74
+
75
+ message GrpcDtoGeoDivision {
76
+ string public_id = 1;
77
+ string timezone_public_id = 2; // nullable
78
+ string currency_public_id = 3; // nullable
79
+ string parent_public_id = 4; // nullable
80
+ string type = 5; // GEO_DIVISION enum as string
81
+ int32 level = 6;
82
+ string code = 7; // nullable
83
+ string path = 8;
84
+ string iso2 = 9; // nullable
85
+ string iso3 = 10; // nullable
86
+ string name = 11;
87
+ string phone_code = 12; // nullable
88
+ bool is_capital = 13;
89
+ bool is_active = 14;
90
+ double lat = 15; // nullable -> 0 when unset
91
+ double lng = 16; // nullable -> 0 when unset
92
+ bool has_lat = 17;
93
+ bool has_lng = 18;
94
+ string geo_json = 19; // JSON.stringify(geoJson) or empty
95
+ google.protobuf.Timestamp updated_at = 20;
96
+ google.protobuf.Timestamp deleted_at = 21;// nullable
97
+ }
98
+
99
+ message GrpcDtoGeoCountryMeta {
100
+ string public_id = 1;
101
+ string division_public_id = 2;
102
+ google.protobuf.Timestamp updated_at = 3;
103
+ // GeoCountryMeta has no deletedAt in aegis schema.
104
+ }
105
+
106
+ message GrpcDtoGeoCountryTimezone {
107
+ string public_id = 1;
108
+ string country_meta_public_id = 2;
109
+ string timezone_public_id = 3;
110
+ bool is_primary = 4;
111
+ }
112
+
113
+ message GrpcDtoGeoCountryCurrency {
114
+ string public_id = 1;
115
+ string country_meta_public_id = 2;
116
+ string currency_public_id = 3;
117
+ bool is_primary = 4;
118
+ }
119
+
120
+ message GrpcDtoGeoCountryLanguage {
121
+ string public_id = 1;
122
+ string country_meta_public_id = 2;
123
+ string language_public_id = 3;
124
+ bool is_official = 4;
125
+ bool is_national = 5;
126
+ }
127
+
128
+ // ---- Per-table sync responses ----
129
+
130
+ message GrpcDtoGeoTimezonesSync { repeated GrpcDtoGeoTimezone items = 1; string next_cursor = 2; bool has_more = 3; }
131
+ message GrpcDtoGeoCurrenciesSync { repeated GrpcDtoGeoCurrency items = 1; string next_cursor = 2; bool has_more = 3; }
132
+ message GrpcDtoGeoLanguagesSync { repeated GrpcDtoGeoLanguage items = 1; string next_cursor = 2; bool has_more = 3; }
133
+ message GrpcDtoGeoLocalesSync { repeated GrpcDtoGeoLocale items = 1; string next_cursor = 2; bool has_more = 3; }
134
+ message GrpcDtoGeoDivisionsSync { repeated GrpcDtoGeoDivision items = 1; string next_cursor = 2; bool has_more = 3; }
135
+ message GrpcDtoGeoCountryMetasSync { repeated GrpcDtoGeoCountryMeta items = 1; string next_cursor = 2; bool has_more = 3; }
136
+ message GrpcDtoGeoCountryTimezonesSync{ repeated GrpcDtoGeoCountryTimezone items = 1; string next_cursor = 2; bool has_more = 3; }
137
+ message GrpcDtoGeoCountryCurrenciesSync{repeated GrpcDtoGeoCountryCurrency items = 1; string next_cursor = 2; bool has_more = 3; }
138
+ message GrpcDtoGeoCountryLanguagesSync{ repeated GrpcDtoGeoCountryLanguage items = 1; string next_cursor = 2; bool has_more = 3; }
139
+
140
+ //----------------------
141
+ // --- GEOSYCN END -----
142
+ //----------------------
143
+
10
144
  message GrpcDtoPagination {
11
145
  int32 total_items = 1;
12
146
  int32 total_pages = 2;
@@ -31,6 +165,44 @@ message GrpcDtoPermissionsAdd {
31
165
  repeated GrpcDtoPermission permissions = 1;
32
166
  }
33
167
 
168
+ // ---- CLIENT TYPE ----
169
+ message GrpcInputClientTypeSeed {
170
+ string name = 1;
171
+ }
172
+
173
+ message GrpcInputClientTypesSeed {
174
+ repeated GrpcInputClientTypeSeed client_types = 1;
175
+ }
176
+
177
+ message GrpcInputClientType {
178
+ string publicId = 1;
179
+ }
180
+
181
+ message GrpcInputClientTypes {
182
+ optional string search = 1;
183
+ optional int32 page = 2;
184
+ optional int32 page_size = 3;
185
+ optional string sort_by = 4;
186
+ optional string sort_order = 5;
187
+ }
188
+
189
+ message GrpcDtoClientType {
190
+ string public_id = 1;
191
+ string name = 2;
192
+ google.protobuf.Timestamp created_at = 3;
193
+ google.protobuf.Timestamp updated_at = 4;
194
+ google.protobuf.Timestamp deleted_at = 5;
195
+ }
196
+
197
+ message GrpcDtoClientTypesSeed {
198
+ repeated GrpcDtoClientType client_types = 1;
199
+ }
200
+
201
+ message GrpcDtoClientTypes {
202
+ repeated GrpcDtoClientType items = 1;
203
+ GrpcDtoPagination meta = 2;
204
+ }
205
+
34
206
  // ---- FEATURES ----
35
207
  message GrpcInputFeatureSeed {
36
208
  string name = 1;
@@ -96,122 +268,109 @@ message GrpcDtoFeaturePermissions {
96
268
  repeated GrpcDtoFeaturePermission featurePermissions = 1;
97
269
  }
98
270
 
99
- service SystemService {
100
- // --- Features ---
101
- rpc FeaturesSeed (GrpcInputFeaturesSeed) returns (GrpcDtoFeaturesSeed);
102
- rpc Features (GrpcInputFeatures) returns (GrpcDtoFeatures);
103
- rpc Feature (GrpcInputFeature) returns (GrpcDtoFeature);
104
- rpc FeaturePermissions (GrpcInputFeaturePermissions) returns (GrpcDtoFeaturePermissions);
105
- rpc FeaturePermissionsAdd (GrpcInputFeaturePermissionsAdd) returns (GrpcDtoPermissionsAdd);
106
- rpc FeaturePermissionsRemove (GrpcInputFeaturePermissionsRemove) returns (GrpcDtoMessage);
271
+ // ---- CLIENT ----
272
+ message GrpcInputClientCreate {
273
+ string clientTypePublicId=1;
274
+ string name = 2;
275
+ optional string managerPublicId=3;
276
+ optional string description = 4;
107
277
  }
108
278
 
109
- // ============================================================================
110
- // GEO REPLICATION CONTRACT
111
- // ============================================================================
112
- //
113
- // Used by aegis (authoritative) to ship GeoDivision rows to subscriber
114
- // services (today: gtms) so they can maintain a local read-only mirror.
115
- //
116
- // RULES
117
- // - Keyed by public_id only. NEVER add internal numeric ids.
118
- // - Soft-deleted rows ARE returned so subscribers can mark them deleted.
119
- // - Ordering is part of the contract: level ASC, public_id ASC. Parents
120
- // arrive before children so the subscriber can satisfy its self-FK.
121
- //
122
- // DO
123
- // - Add new fields at the END of a message with a new field number.
124
- // - Bump to a v2 file for removals/renames or breaking semantics.
125
- //
126
- // DON'T
127
- // - Don't reuse field numbers. Ever.
128
- // - Don't add user/auth context to these payloads — geo is public data.
129
- // ============================================================================
130
-
131
- // ---- GEO MESSAGES ----
132
- message GrpcDtoGeoDivision {
133
- string public_id = 1;
134
- // Parent's public_id; empty string when this is a root division (level 0).
135
- string parent_public_id = 2;
136
-
137
- // Enum name as string (e.g. "COUNTRY", "REGION") — matches Prisma enum
138
- // GEO_DIVISION. Kept as string so adding new levels doesn't require a
139
- // proto bump on the subscriber.
140
- string type = 3;
141
- int32 level = 4;
142
- string code = 5;
143
- // Immutable hierarchy path (e.g. "KE", "KE.47", "KE.47.001").
144
- string path = 6;
145
-
146
- string name = 7;
147
- string iso2 = 8;
148
- string iso3 = 9;
149
- string phone_code = 10;
150
-
151
- bool is_capital = 11;
152
- bool is_active = 12;
279
+ message GrpcInputClientUpdate {
280
+ string publicId = 1;
281
+ optional string name = 2;
282
+ optional string description = 3;
283
+ optional string clientTypePublicId=4;
284
+ optional string managerPublicId=5;
285
+ }
153
286
 
154
- // Optional centroid. Sent as wrapped/optional so 0,0 stays distinguishable
155
- // from "no value". Using `optional` keyword (proto3 field presence).
156
- optional double lat = 13;
157
- optional double lng = 14;
287
+ message GrpcInputClientFeaturesAdd {
288
+ string publicId=1;
289
+ repeated string featureIds=2;
290
+ }
158
291
 
159
- // JSON-encoded geometry (GeoJSON). Empty string when not set.
160
- // Kept as string to avoid pulling in google.protobuf.Struct here and to
161
- // stay lossless for arbitrary GeoJSON shapes.
162
- string geo_json = 15;
292
+ message GrpcInputClientFeaturesRemove {
293
+ repeated string publicClientFeatureIds=1;
294
+ }
163
295
 
164
- // Relation references by public_id. Mirrors the structure of aegis
165
- // `GeoDivision.timezone` / `.currency` — subscribers can hold either
166
- // an opaque string ref or layer their own mirror table on top. We
167
- // ship public_ids (not internal ids) so the contract stays portable.
168
- string timezone_public_id = 16;
169
- string currency_public_id = 17;
296
+ message GrpcInputClient {
297
+ string publicId = 1;
298
+ }
170
299
 
171
- google.protobuf.Timestamp created_at = 18;
172
- google.protobuf.Timestamp updated_at = 19;
173
- google.protobuf.Timestamp deleted_at = 20;
300
+ message GrpcInputClientFeatures {
301
+ string clientPublicId = 1;
174
302
  }
175
303
 
176
- message GrpcDtoGeoDivisionsPage {
177
- repeated GrpcDtoGeoDivision items = 1;
178
- // Empty string when there is no next page.
179
- string next_cursor = 2;
304
+ message GrpcInputClients {
305
+ optional string clientTypePublicId=1;
306
+ optional string managerPublicId=2;
307
+ optional string search = 3;
308
+ optional int32 page = 4;
309
+ optional int32 pageSize = 5;
310
+ optional string sortBy = 6;
311
+ optional string sortOrder = 7;
180
312
  }
181
313
 
182
- message GrpcDtoGeoDivisions {
183
- repeated GrpcDtoGeoDivision items = 1;
314
+ message GrpcDtoClient {
315
+ string publicId = 1;
316
+ string name = 2;
317
+ optional string description = 3;
318
+ optional GrpcDtoClientType clientType = 4;
319
+ google.protobuf.Timestamp createdAt = 5;
320
+ google.protobuf.Timestamp updatedAt = 6;
321
+ google.protobuf.Timestamp deletedAt = 7;
184
322
  }
185
323
 
186
- // ---- GEO INPUTS ----
187
- message GrpcInputGeoDivisionsListAll {
188
- // Empty string means "from the beginning".
189
- string cursor = 1;
190
- // 0 means "use server default". Server clamps to its max.
191
- int32 limit = 2;
324
+ message GrpcDtoClients {
325
+ repeated GrpcDtoClient items = 1;
326
+ GrpcDtoPagination meta = 2;
192
327
  }
193
328
 
194
- message GrpcInputGeoDivisionsGetByPublicIds {
195
- repeated string public_ids = 1;
329
+ message GrpcDtoFeaturesAdd {
330
+ repeated GrpcDtoFeature features = 1;
196
331
  }
197
332
 
198
- message GrpcInputGeoDivisionsListChangedSince {
199
- // Strict `>` comparison server-side. Subscriber should record its
200
- // "last seen updated_at" and pass it back here unchanged.
201
- google.protobuf.Timestamp since = 1;
202
- string cursor = 2;
203
- int32 limit = 3;
333
+ message GrpcDtoClientFeature {
334
+ string public_id = 1;
335
+ GrpcDtoFeature feature = 2;
336
+ optional GrpcDtoClient client = 3;
204
337
  }
205
338
 
206
- // ---- GEO SERVICE ----
207
- service GeoService {
208
- // Full sync (used on first mirror boot). Paged by public_id cursor.
209
- rpc GeoDivisionsListAll (GrpcInputGeoDivisionsListAll) returns (GrpcDtoGeoDivisionsPage);
339
+ message GrpcDtoClientFeatures {
340
+ repeated GrpcDtoClientFeature clientFeatures = 1;
341
+ }
210
342
 
211
- // Batch fetch by public_id (used by live Redis event consumers).
212
- rpc GeoDivisionsGetByPublicIds (GrpcInputGeoDivisionsGetByPublicIds) returns (GrpcDtoGeoDivisions);
343
+ service SystemService {
344
+ // --- Client Types ---
345
+ rpc ClientTypesSeed (GrpcInputClientTypesSeed) returns (GrpcDtoClientTypesSeed);
346
+ rpc ClientTypes (GrpcInputClientTypes) returns (GrpcDtoClientTypes);
347
+ rpc ClientType (GrpcInputClientType) returns (GrpcDtoClientType);
348
+
349
+ // --- Features ---
350
+ rpc FeaturesSeed (GrpcInputFeaturesSeed) returns (GrpcDtoFeaturesSeed);
351
+ rpc Features (GrpcInputFeatures) returns (GrpcDtoFeatures);
352
+ rpc Feature (GrpcInputFeature) returns (GrpcDtoFeature);
353
+ rpc FeaturePermissions (GrpcInputFeaturePermissions) returns (GrpcDtoFeaturePermissions);
354
+ rpc FeaturePermissionsAdd (GrpcInputFeaturePermissionsAdd) returns (GrpcDtoPermissionsAdd);
355
+ rpc FeaturePermissionsRemove (GrpcInputFeaturePermissionsRemove) returns (GrpcDtoMessage);
213
356
 
214
- // Hourly safety-net reconciler. Catches anything the Redis publisher
215
- // dropped due to restart races.
216
- rpc GeoDivisionsListChangedSince (GrpcInputGeoDivisionsListChangedSince) returns (GrpcDtoGeoDivisionsPage);
357
+ // --- Clients ---
358
+ rpc ClientCreate (GrpcInputClientCreate) returns (GrpcDtoClient);
359
+ rpc ClientUpdate (GrpcInputClientUpdate) returns (GrpcDtoClient);
360
+ rpc Clients (GrpcInputClients) returns (GrpcDtoClients);
361
+ rpc Client (GrpcInputClient) returns (GrpcDtoClient);
362
+ rpc ClientFeaturesAdd (GrpcInputClientFeaturesAdd) returns (GrpcDtoFeaturesAdd);
363
+ rpc ClientFeaturesRemove (GrpcInputClientFeaturesRemove) returns (GrpcDtoMessage);
364
+ rpc ClientFeatures (GrpcInputClientFeatures) returns (GrpcDtoClientFeatures);
365
+
366
+ // --- Geo delta sync (hourly pull from gtms mirror) ---
367
+ rpc GeoTimezonesSync (GrpcInputGeoSync) returns (GrpcDtoGeoTimezonesSync);
368
+ rpc GeoCurrenciesSync (GrpcInputGeoSync) returns (GrpcDtoGeoCurrenciesSync);
369
+ rpc GeoLanguagesSync (GrpcInputGeoSync) returns (GrpcDtoGeoLanguagesSync);
370
+ rpc GeoLocalesSync (GrpcInputGeoSync) returns (GrpcDtoGeoLocalesSync);
371
+ rpc GeoDivisionsSync (GrpcInputGeoSync) returns (GrpcDtoGeoDivisionsSync);
372
+ rpc GeoCountryMetasSync (GrpcInputGeoSync) returns (GrpcDtoGeoCountryMetasSync);
373
+ rpc GeoCountryTimezonesSync (GrpcInputGeoSync) returns (GrpcDtoGeoCountryTimezonesSync);
374
+ rpc GeoCountryCurrenciesSync(GrpcInputGeoSync) returns (GrpcDtoGeoCountryCurrenciesSync);
375
+ rpc GeoCountryLanguagesSync (GrpcInputGeoSync) returns (GrpcDtoGeoCountryLanguagesSync);
217
376
  }