@x12i/memorix-service 3.8.0 → 3.10.0

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.
Files changed (79) hide show
  1. package/dist/analytics/definition.d.ts +158 -0
  2. package/dist/analytics/definition.d.ts.map +1 -0
  3. package/dist/analytics/definition.js +439 -0
  4. package/dist/analytics/definition.js.map +1 -0
  5. package/dist/analytics/engine.d.ts +63 -0
  6. package/dist/analytics/engine.d.ts.map +1 -0
  7. package/dist/analytics/engine.js +181 -0
  8. package/dist/analytics/engine.js.map +1 -0
  9. package/dist/analytics/host.d.ts +15 -0
  10. package/dist/analytics/host.d.ts.map +1 -0
  11. package/dist/analytics/host.js +129 -0
  12. package/dist/analytics/host.js.map +1 -0
  13. package/dist/analytics/materializer.d.ts +88 -0
  14. package/dist/analytics/materializer.d.ts.map +1 -0
  15. package/dist/analytics/materializer.js +358 -0
  16. package/dist/analytics/materializer.js.map +1 -0
  17. package/dist/analytics/pipeline-port.d.ts +10 -0
  18. package/dist/analytics/pipeline-port.d.ts.map +1 -0
  19. package/dist/analytics/pipeline-port.js +42 -0
  20. package/dist/analytics/pipeline-port.js.map +1 -0
  21. package/dist/analytics/projector.d.ts +60 -0
  22. package/dist/analytics/projector.d.ts.map +1 -0
  23. package/dist/analytics/projector.js +262 -0
  24. package/dist/analytics/projector.js.map +1 -0
  25. package/dist/analytics/state.d.ts +83 -0
  26. package/dist/analytics/state.d.ts.map +1 -0
  27. package/dist/analytics/state.js +273 -0
  28. package/dist/analytics/state.js.map +1 -0
  29. package/dist/analytics/tracker.d.ts +182 -0
  30. package/dist/analytics/tracker.d.ts.map +1 -0
  31. package/dist/analytics/tracker.js +1302 -0
  32. package/dist/analytics/tracker.js.map +1 -0
  33. package/dist/app.d.ts.map +1 -1
  34. package/dist/app.js +8 -0
  35. package/dist/app.js.map +1 -1
  36. package/dist/caller-identity.d.ts.map +1 -1
  37. package/dist/caller-identity.js +2 -0
  38. package/dist/caller-identity.js.map +1 -1
  39. package/dist/content-census-countex.d.ts +15 -0
  40. package/dist/content-census-countex.d.ts.map +1 -0
  41. package/dist/content-census-countex.js +18 -0
  42. package/dist/content-census-countex.js.map +1 -0
  43. package/dist/datasource-backfill.d.ts +39 -0
  44. package/dist/datasource-backfill.d.ts.map +1 -0
  45. package/dist/datasource-backfill.js +206 -0
  46. package/dist/datasource-backfill.js.map +1 -0
  47. package/dist/errors.d.ts.map +1 -1
  48. package/dist/errors.js +5 -0
  49. package/dist/errors.js.map +1 -1
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +3 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/markdown-backfill.d.ts +23 -0
  55. package/dist/markdown-backfill.d.ts.map +1 -0
  56. package/dist/markdown-backfill.js +122 -0
  57. package/dist/markdown-backfill.js.map +1 -0
  58. package/dist/openapi/openapi.json +1151 -81
  59. package/dist/platform.d.ts +6 -0
  60. package/dist/platform.d.ts.map +1 -1
  61. package/dist/platform.js +55 -2
  62. package/dist/platform.js.map +1 -1
  63. package/dist/routes/analytics-counters.d.ts +8 -0
  64. package/dist/routes/analytics-counters.d.ts.map +1 -0
  65. package/dist/routes/analytics-counters.js +100 -0
  66. package/dist/routes/analytics-counters.js.map +1 -0
  67. package/dist/routes/data.d.ts.map +1 -1
  68. package/dist/routes/data.js +212 -3
  69. package/dist/routes/data.js.map +1 -1
  70. package/dist/routes/datasource-backfill.d.ts +4 -0
  71. package/dist/routes/datasource-backfill.d.ts.map +1 -0
  72. package/dist/routes/datasource-backfill.js +22 -0
  73. package/dist/routes/datasource-backfill.js.map +1 -0
  74. package/dist/routes/markdown-backfill.d.ts +4 -0
  75. package/dist/routes/markdown-backfill.d.ts.map +1 -0
  76. package/dist/routes/markdown-backfill.js +15 -0
  77. package/dist/routes/markdown-backfill.js.map +1 -0
  78. package/openapi/openapi.json +1151 -81
  79. package/package.json +5 -5
@@ -2218,6 +2218,260 @@
2218
2218
  }
2219
2219
  }
2220
2220
  },
2221
+ "/api/admin/markdown/backfill": {
2222
+ "post": {
2223
+ "operationId": "adminMarkdownBackfill",
2224
+ "summary": "Fill missing _markdown from data on current heads",
2225
+ "description": "Admin repair. Dry-run is the default. Sets source json with generatedFrom data. Skips rows that already have _markdown. Does not change revision, data, or _system.modifiedAt. confirm must be true. includeHistory must stay false.",
2226
+ "tags": ["Admin"],
2227
+ "parameters": [
2228
+ { "$ref": "#/components/parameters/XMemorixCaller" },
2229
+ { "$ref": "#/components/parameters/XMemorixOrgId" },
2230
+ { "$ref": "#/components/parameters/XMemorixAgentIds" }
2231
+ ],
2232
+ "requestBody": {
2233
+ "required": true,
2234
+ "content": {
2235
+ "application/json": {
2236
+ "schema": {
2237
+ "type": "object",
2238
+ "required": ["confirm"],
2239
+ "properties": {
2240
+ "confirm": { "type": "boolean" },
2241
+ "dryRun": { "type": "boolean", "default": true },
2242
+ "includeHistory": { "type": "boolean", "enum": [false] }
2243
+ },
2244
+ "additionalProperties": false
2245
+ }
2246
+ }
2247
+ }
2248
+ },
2249
+ "responses": {
2250
+ "200": {
2251
+ "description": "Backfill counts",
2252
+ "content": {
2253
+ "application/json": {
2254
+ "schema": {
2255
+ "type": "object",
2256
+ "required": ["dryRun", "scanned", "wouldFill", "alreadyPresent", "skippedTooLarge", "skippedInvalid"],
2257
+ "properties": {
2258
+ "dryRun": { "type": "boolean" },
2259
+ "scanned": { "type": "integer" },
2260
+ "wouldFill": { "type": "integer" },
2261
+ "alreadyPresent": { "type": "integer" },
2262
+ "skippedTooLarge": { "type": "integer" },
2263
+ "skippedInvalid": { "type": "integer" }
2264
+ }
2265
+ }
2266
+ }
2267
+ }
2268
+ },
2269
+ "400": {
2270
+ "description": "confirm was not true, or includeHistory was requested",
2271
+ "content": {
2272
+ "application/json": {
2273
+ "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
2274
+ }
2275
+ }
2276
+ },
2277
+ "503": {
2278
+ "description": "Mongo is not connected",
2279
+ "content": {
2280
+ "application/json": {
2281
+ "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
2282
+ }
2283
+ }
2284
+ }
2285
+ }
2286
+ }
2287
+ },
2288
+ "/api/admin/datasource/backfill": {
2289
+ "post": {
2290
+ "operationId": "adminDatasourceBackfill",
2291
+ "summary": "Stamp _system._datasource on current heads without a content write",
2292
+ "description": "Admin repair. Dry-run is the default. Does not change revision, data, or _system.modifiedAt. confirm must be true. includeHistory must stay false.",
2293
+ "tags": ["Admin"],
2294
+ "parameters": [
2295
+ { "$ref": "#/components/parameters/XMemorixCaller" },
2296
+ { "$ref": "#/components/parameters/XMemorixOrgId" },
2297
+ { "$ref": "#/components/parameters/XMemorixAgentIds" }
2298
+ ],
2299
+ "requestBody": {
2300
+ "required": true,
2301
+ "content": {
2302
+ "application/json": {
2303
+ "schema": {
2304
+ "type": "object",
2305
+ "required": ["confirm", "rules", "unmatched"],
2306
+ "properties": {
2307
+ "confirm": { "type": "boolean" },
2308
+ "dryRun": { "type": "boolean", "default": true },
2309
+ "overwriteBackfill": { "type": "boolean", "default": true },
2310
+ "includeHistory": { "type": "boolean", "default": false },
2311
+ "rules": {
2312
+ "type": "array",
2313
+ "items": {
2314
+ "type": "object",
2315
+ "required": ["id", "match", "datasource"],
2316
+ "properties": {
2317
+ "id": { "type": "string" },
2318
+ "match": {
2319
+ "type": "object",
2320
+ "properties": {
2321
+ "orgId": { "type": "string" },
2322
+ "agentIds": { "type": "array", "items": { "type": "string" } },
2323
+ "objectType": { "type": "string" },
2324
+ "contentType": { "type": "string" }
2325
+ }
2326
+ },
2327
+ "datasource": {
2328
+ "type": "object",
2329
+ "description": "Do not send basis or recordedAt. Memorix adds basis backfill and recordedAt.",
2330
+ "required": ["service", "ingress"],
2331
+ "properties": {
2332
+ "service": { "type": "string" },
2333
+ "origin": { "type": "string" },
2334
+ "channel": { "type": "string" },
2335
+ "ingress": { "type": "string" }
2336
+ }
2337
+ }
2338
+ }
2339
+ }
2340
+ },
2341
+ "unmatched": {
2342
+ "type": "object",
2343
+ "description": "Required. Applied when no rule matches. Do not send basis or recordedAt.",
2344
+ "required": ["service", "ingress"],
2345
+ "properties": {
2346
+ "service": { "type": "string" },
2347
+ "ingress": { "type": "string" }
2348
+ }
2349
+ }
2350
+ }
2351
+ }
2352
+ }
2353
+ }
2354
+ },
2355
+ "responses": {
2356
+ "200": {
2357
+ "description": "Backfill counts. dryRun true changes nothing.",
2358
+ "content": {
2359
+ "application/json": {
2360
+ "schema": {
2361
+ "type": "object",
2362
+ "required": ["dryRun", "scanned", "wouldStamp", "alreadyStamped", "unattributed", "byRule"],
2363
+ "properties": {
2364
+ "dryRun": { "type": "boolean" },
2365
+ "scanned": { "type": "integer" },
2366
+ "wouldStamp": { "type": "integer" },
2367
+ "alreadyStamped": { "type": "integer" },
2368
+ "unattributed": { "type": "integer" },
2369
+ "byRule": { "type": "object", "additionalProperties": { "type": "integer" } }
2370
+ }
2371
+ }
2372
+ }
2373
+ }
2374
+ },
2375
+ "400": {
2376
+ "description": "confirm is not true, includeHistory is true, or the body is invalid",
2377
+ "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
2378
+ }
2379
+ }
2380
+ }
2381
+ },
2382
+ "/api/data/datasource": {
2383
+ "post": {
2384
+ "operationId": "dataSetDatasource",
2385
+ "summary": "Set _system._datasource on existing content",
2386
+ "description": "MX-SYS-02. service is x-memorix-caller. Send recordId plus expectedRevision, or filter plus confirm true for one page. datasource may declare origin, channel, originRecordId, originAt, and ingress. Do not send service, basis, or recordedAt.",
2387
+ "tags": ["Data"],
2388
+ "parameters": [
2389
+ { "$ref": "#/components/parameters/XMemorixCaller" },
2390
+ { "$ref": "#/components/parameters/XMemorixOrgId" },
2391
+ { "$ref": "#/components/parameters/XMemorixAgentIds" }
2392
+ ],
2393
+ "requestBody": {
2394
+ "required": true,
2395
+ "content": {
2396
+ "application/json": {
2397
+ "schema": {
2398
+ "type": "object",
2399
+ "required": ["objectType", "contentType"],
2400
+ "properties": {
2401
+ "objectType": { "type": "string" },
2402
+ "contentType": { "type": "string" },
2403
+ "recordId": { "type": "string" },
2404
+ "expectedRevision": { "type": "integer", "minimum": 1 },
2405
+ "discriminatorValue": { "type": "string" },
2406
+ "filter": {},
2407
+ "confirm": { "type": "boolean" },
2408
+ "limit": { "type": "integer", "minimum": 1, "maximum": 200 },
2409
+ "cursor": { "type": "string" },
2410
+ "datasource": {
2411
+ "type": "object",
2412
+ "properties": {
2413
+ "origin": { "type": "string", "nullable": true },
2414
+ "channel": { "type": "string", "nullable": true },
2415
+ "originRecordId": { "type": "string", "nullable": true },
2416
+ "originAt": { "type": "string", "format": "date-time", "nullable": true },
2417
+ "ingress": {
2418
+ "type": "string",
2419
+ "enum": ["push", "import", "sync", "derive", "migrate", "manual", "replicate"]
2420
+ },
2421
+ "sources": { "$ref": "#/components/schemas/DatasourceSourcesDeclaration" }
2422
+ }
2423
+ }
2424
+ }
2425
+ }
2426
+ }
2427
+ }
2428
+ },
2429
+ "responses": {
2430
+ "200": { "description": "Datasource stamped. Revision increments." },
2431
+ "400": { "description": "Missing target, invalid declaration, or filter without confirm" },
2432
+ "404": { "description": "Record not found" },
2433
+ "409": { "description": "Stale revision" }
2434
+ }
2435
+ }
2436
+ },
2437
+ "/api/data/content/move-fields": {
2438
+ "post": {
2439
+ "operationId": "dataMoveContentFields",
2440
+ "summary": "Move top-level keys between data and _metadata",
2441
+ "description": "data is content. _metadata is producer context and is not rendered into JSON markdown. toMetadata moves keys out of data. toData moves keys back into data. One record, exact revision.",
2442
+ "tags": ["Data"],
2443
+ "parameters": [
2444
+ { "$ref": "#/components/parameters/XMemorixCaller" },
2445
+ { "$ref": "#/components/parameters/XMemorixOrgId" },
2446
+ { "$ref": "#/components/parameters/XMemorixAgentIds" }
2447
+ ],
2448
+ "requestBody": {
2449
+ "required": true,
2450
+ "content": {
2451
+ "application/json": {
2452
+ "schema": {
2453
+ "type": "object",
2454
+ "required": ["objectType", "contentType", "recordId", "expectedRevision"],
2455
+ "properties": {
2456
+ "objectType": { "type": "string" },
2457
+ "contentType": { "type": "string" },
2458
+ "recordId": { "type": "string" },
2459
+ "expectedRevision": { "type": "integer", "minimum": 1 },
2460
+ "discriminatorValue": { "type": "string" },
2461
+ "toMetadata": { "type": "array", "items": { "type": "string" } },
2462
+ "toData": { "type": "array", "items": { "type": "string" } }
2463
+ }
2464
+ }
2465
+ }
2466
+ }
2467
+ },
2468
+ "responses": {
2469
+ "200": { "description": "Keys moved and revision bumped" },
2470
+ "400": { "description": "Invalid keys, missing source key, or data/metadata conflict" },
2471
+ "409": { "description": "Stale revision" }
2472
+ }
2473
+ }
2474
+ },
2221
2475
  "/api/data/content": {
2222
2476
  "get": {
2223
2477
  "operationId": "dataGetContent",
@@ -2274,6 +2528,14 @@
2274
2528
  "type": "string"
2275
2529
  }
2276
2530
  },
2531
+ {
2532
+ "name": "include",
2533
+ "in": "query",
2534
+ "schema": {
2535
+ "type": "string"
2536
+ },
2537
+ "description": "JSON object. {\"markdown\":true} returns root _markdown on get and list. Omitted by default. _audit is returned whenever stored and is not part of this flag."
2538
+ },
2277
2539
  {
2278
2540
  "name": "cursor",
2279
2541
  "in": "query",
@@ -2558,6 +2820,22 @@
2558
2820
  "record": {
2559
2821
  "$ref": "#/components/schemas/MemorixRecordV2"
2560
2822
  },
2823
+ "datasource": {
2824
+ "description": "Optional document source declaration. Memorix sets service from x-memorix-caller. Do not send service, basis, or recordedAt. record._system._datasource is ignored.",
2825
+ "type": "object",
2826
+ "properties": {
2827
+ "origin": { "type": "string", "nullable": true },
2828
+ "channel": { "type": "string", "nullable": true },
2829
+ "originRecordId": { "type": "string", "nullable": true },
2830
+ "originAt": { "type": "string", "format": "date-time", "nullable": true },
2831
+ "ingress": {
2832
+ "type": "string",
2833
+ "enum": ["push", "import", "sync", "derive", "migrate", "manual", "replicate"]
2834
+ },
2835
+ "sources": { "$ref": "#/components/schemas/DatasourceSourcesDeclaration" }
2836
+ },
2837
+ "additionalProperties": true
2838
+ },
2561
2839
  "precondition": {
2562
2840
  "$ref": "#/components/schemas/WritePrecondition"
2563
2841
  },
@@ -13659,91 +13937,684 @@
13659
13937
  }
13660
13938
  }
13661
13939
  }
13662
- }
13663
- },
13664
- "components": {
13665
- "parameters": {
13666
- "XMemorixOrgId": {
13667
- "name": "x-memorix-org-id",
13668
- "in": "header",
13669
- "required": true,
13670
- "schema": {
13671
- "type": "string",
13672
- "minLength": 1
13673
- },
13674
- "description": "Organization / data-universe id"
13675
- },
13676
- "XMemorixAgentIds": {
13677
- "name": "x-memorix-agent-ids",
13678
- "in": "header",
13679
- "required": true,
13680
- "schema": {
13681
- "type": "string",
13682
- "minLength": 1
13683
- },
13684
- "description": "Comma-separated agentIds for effective metadata",
13685
- "example": "ops,fieldstone"
13686
- },
13687
- "XMemorixCaller": {
13688
- "name": "x-memorix-caller",
13689
- "in": "header",
13690
- "required": true,
13691
- "schema": {
13692
- "type": "string",
13693
- "minLength": 1,
13694
- "maxLength": 128,
13695
- "pattern": "^[a-zA-Z0-9@][a-zA-Z0-9._@/-]*$"
13696
- },
13697
- "description": "MX-CALLER-01: calling application id (e.g. synapix-lander, map-store, memorix-studio, @x12i/memorix-client)",
13698
- "example": "memorix-studio"
13699
- }
13700
13940
  },
13701
- "schemas": {
13702
- "MemorixScope": {
13703
- "type": "object",
13704
- "required": [
13705
- "orgId",
13706
- "agentIds"
13941
+ "/api/analytics/counters": {
13942
+ "get": {
13943
+ "operationId": "analyticsCountersList",
13944
+ "summary": "List registered counters (pack analytics[], API registrations, built-ins)",
13945
+ "tags": [
13946
+ "Analytics"
13707
13947
  ],
13708
- "additionalProperties": false,
13709
- "properties": {
13710
- "orgId": {
13711
- "type": "string",
13712
- "minLength": 1,
13713
- "description": "Data universe / org isolation key"
13948
+ "parameters": [
13949
+ {
13950
+ "$ref": "#/components/parameters/XMemorixCaller"
13714
13951
  },
13715
- "agentIds": {
13716
- "type": "array",
13717
- "items": {
13718
- "type": "string",
13719
- "minLength": 1
13720
- },
13721
- "minItems": 1,
13722
- "uniqueItems": true,
13723
- "description": "Effective metadata agent chain (canonicalized/sorted)"
13952
+ {
13953
+ "$ref": "#/components/parameters/XMemorixOrgId"
13954
+ },
13955
+ {
13956
+ "$ref": "#/components/parameters/XMemorixAgentIds"
13724
13957
  }
13725
- },
13726
- "example": {
13727
- "orgId": "acme",
13728
- "agentIds": [
13729
- "opx",
13730
- "fieldstone"
13731
- ]
13732
- }
13733
- },
13734
- "ConnectorCatalogEntry": {
13735
- "type": "object",
13736
- "required": [
13737
- "id",
13738
- "version",
13739
- "protocol",
13740
- "enabled",
13741
- "framework",
13742
- "displayName",
13743
- "capabilities",
13744
- "isSource",
13745
- "isTarget",
13746
- "origin"
13958
+ ],
13959
+ "responses": {
13960
+ "200": {
13961
+ "description": "Counters for the organization",
13962
+ "content": {
13963
+ "application/json": {
13964
+ "schema": {
13965
+ "type": "object",
13966
+ "required": [
13967
+ "items"
13968
+ ],
13969
+ "properties": {
13970
+ "items": {
13971
+ "type": "array",
13972
+ "items": {
13973
+ "$ref": "#/components/schemas/AnalyticsCounter"
13974
+ }
13975
+ }
13976
+ }
13977
+ }
13978
+ }
13979
+ }
13980
+ },
13981
+ "503": {
13982
+ "description": "Analytics counters unavailable (no Mongo, or MEMORIX_ANALYTICS=0)",
13983
+ "content": {
13984
+ "application/json": {
13985
+ "schema": {
13986
+ "$ref": "#/components/schemas/ErrorEnvelope"
13987
+ }
13988
+ }
13989
+ }
13990
+ }
13991
+ }
13992
+ },
13993
+ "post": {
13994
+ "operationId": "analyticsCountersRegister",
13995
+ "summary": "Register a counter; results are read from its target record with GET /api/data/content",
13996
+ "tags": [
13997
+ "Analytics"
13998
+ ],
13999
+ "parameters": [
14000
+ {
14001
+ "$ref": "#/components/parameters/XMemorixCaller"
14002
+ },
14003
+ {
14004
+ "$ref": "#/components/parameters/XMemorixOrgId"
14005
+ },
14006
+ {
14007
+ "$ref": "#/components/parameters/XMemorixAgentIds"
14008
+ }
14009
+ ],
14010
+ "requestBody": {
14011
+ "required": true,
14012
+ "content": {
14013
+ "application/json": {
14014
+ "schema": {
14015
+ "type": "object",
14016
+ "required": [
14017
+ "definition"
14018
+ ],
14019
+ "properties": {
14020
+ "definition": {
14021
+ "type": "object",
14022
+ "additionalProperties": true,
14023
+ "description": "An analytics definition (same shape as a pack analytics[] item)"
14024
+ },
14025
+ "replace": {
14026
+ "type": "boolean",
14027
+ "description": "Rebuild when a counter with this id exists with a different definition"
14028
+ }
14029
+ }
14030
+ }
14031
+ }
14032
+ }
14033
+ },
14034
+ "responses": {
14035
+ "202": {
14036
+ "description": "Accepted; the counter backfills once, then stays current from writes",
14037
+ "content": {
14038
+ "application/json": {
14039
+ "schema": {
14040
+ "type": "object",
14041
+ "required": [
14042
+ "id",
14043
+ "status",
14044
+ "counter"
14045
+ ],
14046
+ "properties": {
14047
+ "id": {
14048
+ "type": "string"
14049
+ },
14050
+ "status": {
14051
+ "type": "string"
14052
+ },
14053
+ "counter": {
14054
+ "$ref": "#/components/schemas/AnalyticsCounter"
14055
+ }
14056
+ }
14057
+ }
14058
+ }
14059
+ }
14060
+ },
14061
+ "400": {
14062
+ "description": "Definition invalid (error.details.issues)",
14063
+ "content": {
14064
+ "application/json": {
14065
+ "schema": {
14066
+ "$ref": "#/components/schemas/ErrorEnvelope"
14067
+ }
14068
+ }
14069
+ }
14070
+ },
14071
+ "409": {
14072
+ "description": "Id taken by a pack or built-in counter, definition differs without replace, or target already used",
14073
+ "content": {
14074
+ "application/json": {
14075
+ "schema": {
14076
+ "$ref": "#/components/schemas/ErrorEnvelope"
14077
+ }
14078
+ }
14079
+ }
14080
+ },
14081
+ "503": {
14082
+ "description": "Analytics counters unavailable",
14083
+ "content": {
14084
+ "application/json": {
14085
+ "schema": {
14086
+ "$ref": "#/components/schemas/ErrorEnvelope"
14087
+ }
14088
+ }
14089
+ }
14090
+ }
14091
+ }
14092
+ }
14093
+ },
14094
+ "/api/analytics/counters/validate": {
14095
+ "post": {
14096
+ "operationId": "analyticsCountersValidate",
14097
+ "summary": "Validate a counter definition without registering it",
14098
+ "tags": [
14099
+ "Analytics"
14100
+ ],
14101
+ "parameters": [
14102
+ {
14103
+ "$ref": "#/components/parameters/XMemorixCaller"
14104
+ },
14105
+ {
14106
+ "$ref": "#/components/parameters/XMemorixOrgId"
14107
+ },
14108
+ {
14109
+ "$ref": "#/components/parameters/XMemorixAgentIds"
14110
+ }
14111
+ ],
14112
+ "requestBody": {
14113
+ "required": true,
14114
+ "content": {
14115
+ "application/json": {
14116
+ "schema": {
14117
+ "type": "object",
14118
+ "properties": {
14119
+ "definition": {
14120
+ "type": "object",
14121
+ "additionalProperties": true
14122
+ }
14123
+ }
14124
+ }
14125
+ }
14126
+ }
14127
+ },
14128
+ "responses": {
14129
+ "200": {
14130
+ "description": "Validation result",
14131
+ "content": {
14132
+ "application/json": {
14133
+ "schema": {
14134
+ "type": "object",
14135
+ "required": [
14136
+ "ok",
14137
+ "issues"
14138
+ ],
14139
+ "properties": {
14140
+ "ok": {
14141
+ "type": "boolean"
14142
+ },
14143
+ "issues": {
14144
+ "type": "array",
14145
+ "items": {
14146
+ "type": "object",
14147
+ "additionalProperties": true
14148
+ }
14149
+ }
14150
+ }
14151
+ }
14152
+ }
14153
+ }
14154
+ },
14155
+ "503": {
14156
+ "description": "Analytics counters unavailable",
14157
+ "content": {
14158
+ "application/json": {
14159
+ "schema": {
14160
+ "$ref": "#/components/schemas/ErrorEnvelope"
14161
+ }
14162
+ }
14163
+ }
14164
+ }
14165
+ }
14166
+ }
14167
+ },
14168
+ "/api/analytics/counters/{id}": {
14169
+ "get": {
14170
+ "operationId": "analyticsCounterGet",
14171
+ "summary": "Counter status, backfill progress, target address and lastMaterializedAt",
14172
+ "tags": [
14173
+ "Analytics"
14174
+ ],
14175
+ "parameters": [
14176
+ {
14177
+ "$ref": "#/components/parameters/XMemorixCaller"
14178
+ },
14179
+ {
14180
+ "$ref": "#/components/parameters/XMemorixOrgId"
14181
+ },
14182
+ {
14183
+ "$ref": "#/components/parameters/XMemorixAgentIds"
14184
+ },
14185
+ {
14186
+ "name": "id",
14187
+ "in": "path",
14188
+ "required": true,
14189
+ "schema": {
14190
+ "type": "string"
14191
+ }
14192
+ }
14193
+ ],
14194
+ "responses": {
14195
+ "200": {
14196
+ "description": "Counter",
14197
+ "content": {
14198
+ "application/json": {
14199
+ "schema": {
14200
+ "$ref": "#/components/schemas/AnalyticsCounter"
14201
+ }
14202
+ }
14203
+ }
14204
+ },
14205
+ "404": {
14206
+ "description": "Counter not found",
14207
+ "content": {
14208
+ "application/json": {
14209
+ "schema": {
14210
+ "$ref": "#/components/schemas/ErrorEnvelope"
14211
+ }
14212
+ }
14213
+ }
14214
+ },
14215
+ "503": {
14216
+ "description": "Analytics counters unavailable",
14217
+ "content": {
14218
+ "application/json": {
14219
+ "schema": {
14220
+ "$ref": "#/components/schemas/ErrorEnvelope"
14221
+ }
14222
+ }
14223
+ }
14224
+ }
14225
+ }
14226
+ },
14227
+ "delete": {
14228
+ "operationId": "analyticsCounterDelete",
14229
+ "summary": "Unregister an API-registered counter (pack counters are removed from the pack)",
14230
+ "tags": [
14231
+ "Analytics"
14232
+ ],
14233
+ "parameters": [
14234
+ {
14235
+ "$ref": "#/components/parameters/XMemorixCaller"
14236
+ },
14237
+ {
14238
+ "$ref": "#/components/parameters/XMemorixOrgId"
14239
+ },
14240
+ {
14241
+ "$ref": "#/components/parameters/XMemorixAgentIds"
14242
+ },
14243
+ {
14244
+ "name": "id",
14245
+ "in": "path",
14246
+ "required": true,
14247
+ "schema": {
14248
+ "type": "string"
14249
+ }
14250
+ }
14251
+ ],
14252
+ "responses": {
14253
+ "200": {
14254
+ "description": "Removed",
14255
+ "content": {
14256
+ "application/json": {
14257
+ "schema": {
14258
+ "type": "object",
14259
+ "properties": {
14260
+ "id": {
14261
+ "type": "string"
14262
+ },
14263
+ "removed": {
14264
+ "type": "boolean"
14265
+ }
14266
+ }
14267
+ }
14268
+ }
14269
+ }
14270
+ },
14271
+ "404": {
14272
+ "description": "Counter not found",
14273
+ "content": {
14274
+ "application/json": {
14275
+ "schema": {
14276
+ "$ref": "#/components/schemas/ErrorEnvelope"
14277
+ }
14278
+ }
14279
+ }
14280
+ },
14281
+ "409": {
14282
+ "description": "Pack or built-in counter",
14283
+ "content": {
14284
+ "application/json": {
14285
+ "schema": {
14286
+ "$ref": "#/components/schemas/ErrorEnvelope"
14287
+ }
14288
+ }
14289
+ }
14290
+ },
14291
+ "503": {
14292
+ "description": "Analytics counters unavailable",
14293
+ "content": {
14294
+ "application/json": {
14295
+ "schema": {
14296
+ "$ref": "#/components/schemas/ErrorEnvelope"
14297
+ }
14298
+ }
14299
+ }
14300
+ }
14301
+ }
14302
+ }
14303
+ },
14304
+ "/api/analytics/counters/{id}/rebuild": {
14305
+ "post": {
14306
+ "operationId": "analyticsCounterRebuild",
14307
+ "summary": "Drop the counter's cells and ledger, then backfill again",
14308
+ "tags": [
14309
+ "Analytics"
14310
+ ],
14311
+ "parameters": [
14312
+ {
14313
+ "$ref": "#/components/parameters/XMemorixCaller"
14314
+ },
14315
+ {
14316
+ "$ref": "#/components/parameters/XMemorixOrgId"
14317
+ },
14318
+ {
14319
+ "$ref": "#/components/parameters/XMemorixAgentIds"
14320
+ },
14321
+ {
14322
+ "name": "id",
14323
+ "in": "path",
14324
+ "required": true,
14325
+ "schema": {
14326
+ "type": "string"
14327
+ }
14328
+ }
14329
+ ],
14330
+ "responses": {
14331
+ "202": {
14332
+ "description": "Accepted; the counter backfills once, then stays current from writes",
14333
+ "content": {
14334
+ "application/json": {
14335
+ "schema": {
14336
+ "type": "object",
14337
+ "required": [
14338
+ "id",
14339
+ "status",
14340
+ "counter"
14341
+ ],
14342
+ "properties": {
14343
+ "id": {
14344
+ "type": "string"
14345
+ },
14346
+ "status": {
14347
+ "type": "string"
14348
+ },
14349
+ "counter": {
14350
+ "$ref": "#/components/schemas/AnalyticsCounter"
14351
+ }
14352
+ }
14353
+ }
14354
+ }
14355
+ }
14356
+ },
14357
+ "404": {
14358
+ "description": "Counter not found",
14359
+ "content": {
14360
+ "application/json": {
14361
+ "schema": {
14362
+ "$ref": "#/components/schemas/ErrorEnvelope"
14363
+ }
14364
+ }
14365
+ }
14366
+ },
14367
+ "503": {
14368
+ "description": "Analytics counters unavailable",
14369
+ "content": {
14370
+ "application/json": {
14371
+ "schema": {
14372
+ "$ref": "#/components/schemas/ErrorEnvelope"
14373
+ }
14374
+ }
14375
+ }
14376
+ }
14377
+ }
14378
+ }
14379
+ },
14380
+ "/api/analytics/source-census": {
14381
+ "get": {
14382
+ "operationId": "analyticsSourceCensus",
14383
+ "summary": "Current records by data source (built-in @datasources counter)",
14384
+ "tags": [
14385
+ "Analytics"
14386
+ ],
14387
+ "parameters": [
14388
+ {
14389
+ "$ref": "#/components/parameters/XMemorixCaller"
14390
+ },
14391
+ {
14392
+ "$ref": "#/components/parameters/XMemorixOrgId"
14393
+ },
14394
+ {
14395
+ "$ref": "#/components/parameters/XMemorixAgentIds"
14396
+ }
14397
+ ],
14398
+ "responses": {
14399
+ "200": {
14400
+ "description": "Census",
14401
+ "content": {
14402
+ "application/json": {
14403
+ "schema": {
14404
+ "type": "object",
14405
+ "required": [
14406
+ "ok",
14407
+ "censusId",
14408
+ "timestamp",
14409
+ "status",
14410
+ "subjects",
14411
+ "heads"
14412
+ ],
14413
+ "properties": {
14414
+ "ok": {
14415
+ "type": "boolean"
14416
+ },
14417
+ "censusId": {
14418
+ "type": [
14419
+ "string",
14420
+ "null"
14421
+ ]
14422
+ },
14423
+ "timestamp": {
14424
+ "type": "string",
14425
+ "format": "date-time"
14426
+ },
14427
+ "status": {
14428
+ "type": "string",
14429
+ "enum": [
14430
+ "live",
14431
+ "backfilling",
14432
+ "error",
14433
+ "disabled"
14434
+ ]
14435
+ },
14436
+ "subjects": {
14437
+ "type": "array",
14438
+ "items": {
14439
+ "type": "object",
14440
+ "required": [
14441
+ "system",
14442
+ "name",
14443
+ "total",
14444
+ "kinds"
14445
+ ],
14446
+ "properties": {
14447
+ "system": {
14448
+ "type": "string"
14449
+ },
14450
+ "name": {
14451
+ "type": "string"
14452
+ },
14453
+ "total": {
14454
+ "type": "integer"
14455
+ },
14456
+ "kinds": {
14457
+ "type": "array",
14458
+ "items": {
14459
+ "type": "object",
14460
+ "required": [
14461
+ "kind",
14462
+ "label",
14463
+ "count"
14464
+ ],
14465
+ "properties": {
14466
+ "kind": {
14467
+ "type": "string"
14468
+ },
14469
+ "label": {
14470
+ "type": "string"
14471
+ },
14472
+ "count": {
14473
+ "type": "integer"
14474
+ }
14475
+ }
14476
+ }
14477
+ }
14478
+ }
14479
+ }
14480
+ },
14481
+ "heads": {
14482
+ "type": "array",
14483
+ "items": {
14484
+ "type": "object",
14485
+ "required": [
14486
+ "system",
14487
+ "name",
14488
+ "total",
14489
+ "kinds"
14490
+ ],
14491
+ "properties": {
14492
+ "system": {
14493
+ "type": "string"
14494
+ },
14495
+ "name": {
14496
+ "type": "string"
14497
+ },
14498
+ "total": {
14499
+ "type": "integer"
14500
+ },
14501
+ "kinds": {
14502
+ "type": "array",
14503
+ "items": {
14504
+ "type": "object",
14505
+ "required": [
14506
+ "kind",
14507
+ "label",
14508
+ "count"
14509
+ ],
14510
+ "properties": {
14511
+ "kind": {
14512
+ "type": "string"
14513
+ },
14514
+ "label": {
14515
+ "type": "string"
14516
+ },
14517
+ "count": {
14518
+ "type": "integer"
14519
+ }
14520
+ }
14521
+ }
14522
+ }
14523
+ }
14524
+ }
14525
+ }
14526
+ }
14527
+ }
14528
+ }
14529
+ }
14530
+ }
14531
+ }
14532
+ }
14533
+ }
14534
+ },
14535
+ "components": {
14536
+ "parameters": {
14537
+ "XMemorixOrgId": {
14538
+ "name": "x-memorix-org-id",
14539
+ "in": "header",
14540
+ "required": true,
14541
+ "schema": {
14542
+ "type": "string",
14543
+ "minLength": 1
14544
+ },
14545
+ "description": "Organization / data-universe id"
14546
+ },
14547
+ "XMemorixAgentIds": {
14548
+ "name": "x-memorix-agent-ids",
14549
+ "in": "header",
14550
+ "required": true,
14551
+ "schema": {
14552
+ "type": "string",
14553
+ "minLength": 1
14554
+ },
14555
+ "description": "Comma-separated agentIds for effective metadata",
14556
+ "example": "ops,fieldstone"
14557
+ },
14558
+ "XMemorixCaller": {
14559
+ "name": "x-memorix-caller",
14560
+ "in": "header",
14561
+ "required": true,
14562
+ "schema": {
14563
+ "type": "string",
14564
+ "minLength": 1,
14565
+ "maxLength": 128,
14566
+ "pattern": "^[a-zA-Z0-9@][a-zA-Z0-9._@/-]*$"
14567
+ },
14568
+ "description": "MX-CALLER-01: calling application id (e.g. synapix-lander, map-store, memorix-studio, @x12i/memorix-client)",
14569
+ "example": "memorix-studio"
14570
+ }
14571
+ },
14572
+ "schemas": {
14573
+ "MemorixScope": {
14574
+ "type": "object",
14575
+ "required": [
14576
+ "orgId",
14577
+ "agentIds"
14578
+ ],
14579
+ "additionalProperties": false,
14580
+ "properties": {
14581
+ "orgId": {
14582
+ "type": "string",
14583
+ "minLength": 1,
14584
+ "description": "Data universe / org isolation key"
14585
+ },
14586
+ "agentIds": {
14587
+ "type": "array",
14588
+ "items": {
14589
+ "type": "string",
14590
+ "minLength": 1
14591
+ },
14592
+ "minItems": 1,
14593
+ "uniqueItems": true,
14594
+ "description": "Effective metadata agent chain (canonicalized/sorted)"
14595
+ }
14596
+ },
14597
+ "example": {
14598
+ "orgId": "acme",
14599
+ "agentIds": [
14600
+ "opx",
14601
+ "fieldstone"
14602
+ ]
14603
+ }
14604
+ },
14605
+ "ConnectorCatalogEntry": {
14606
+ "type": "object",
14607
+ "required": [
14608
+ "id",
14609
+ "version",
14610
+ "protocol",
14611
+ "enabled",
14612
+ "framework",
14613
+ "displayName",
14614
+ "capabilities",
14615
+ "isSource",
14616
+ "isTarget",
14617
+ "origin"
13747
14618
  ],
13748
14619
  "properties": {
13749
14620
  "id": {
@@ -13992,8 +14863,79 @@
13992
14863
  "provenance": {
13993
14864
  "type": "object",
13994
14865
  "additionalProperties": true
14866
+ },
14867
+ "_datasource": {
14868
+ "$ref": "#/components/schemas/DatasourceStamp"
13995
14869
  }
13996
14870
  }
14871
+ },
14872
+ "_markdown": {
14873
+ "$ref": "#/components/schemas/RecordMarkdown"
14874
+ },
14875
+ "_audit": {
14876
+ "type": "object",
14877
+ "description": "Optional audit of this record, not of its content and not _markdown.metadata. Returned on get, list, and query whenever stored. Not an include flag. Not rendered into JSON markdown. provider, model, and reasoningEffort are required when the object is present. Other keys stay open, including verdict.",
14878
+ "required": ["provider", "model", "reasoningEffort"],
14879
+ "properties": {
14880
+ "provider": { "type": "string", "minLength": 1 },
14881
+ "model": { "type": "string", "minLength": 1 },
14882
+ "reasoningEffort": { "type": "string", "minLength": 1 }
14883
+ },
14884
+ "additionalProperties": true
14885
+ }
14886
+ }
14887
+ },
14888
+ "RecordMarkdown": {
14889
+ "type": "object",
14890
+ "description": "Original text beside data. Omitted from get and list unless the include query asks for markdown. Clients may send source ai or content. source json is filled by Memorix from data.",
14891
+ "required": ["content", "source"],
14892
+ "properties": {
14893
+ "content": { "type": "string" },
14894
+ "source": { "type": "string", "enum": ["ai", "json", "content"] },
14895
+ "metadata": { "type": "object", "additionalProperties": true }
14896
+ },
14897
+ "additionalProperties": true
14898
+ },
14899
+ "DatasourceStamp": {
14900
+ "type": "object",
14901
+ "description": "Memorix-owned document source. Not part of data. Absent on records written before MX-SYS-02.",
14902
+ "required": ["service", "ingress", "basis", "recordedAt"],
14903
+ "properties": {
14904
+ "service": { "type": "string" },
14905
+ "ingress": {
14906
+ "type": "string",
14907
+ "enum": ["push", "import", "sync", "derive", "migrate", "manual", "replicate", "unknown"]
14908
+ },
14909
+ "basis": {
14910
+ "type": "string",
14911
+ "enum": ["declared", "caller", "preserved", "backfill"]
14912
+ },
14913
+ "recordedAt": { "type": "string", "format": "date-time" },
14914
+ "origin": { "type": "string" },
14915
+ "channel": { "type": "string" },
14916
+ "originRecordId": { "type": "string" },
14917
+ "originAt": { "type": "string", "format": "date-time" },
14918
+ "sources": {
14919
+ "type": "array",
14920
+ "items": {
14921
+ "type": "object",
14922
+ "required": ["system", "name"],
14923
+ "properties": { "system": { "type": "string" }, "name": { "type": "string" } }
14924
+ }
14925
+ }
14926
+ }
14927
+ },
14928
+ "DatasourceSourcesDeclaration": {
14929
+ "description": "Connector the record came from; the census and @datasource groups file it under sources[0]. Replaces stored sources; null or [] clears them; omit to keep them.",
14930
+ "type": "array",
14931
+ "nullable": true,
14932
+ "maxItems": 8,
14933
+ "items": {
14934
+ "type": "object",
14935
+ "required": ["system", "name"],
14936
+ "properties": {
14937
+ "system": { "type": "string", "pattern": "^[a-zA-Z0-9@][a-zA-Z0-9._@/-]*$", "maxLength": 128 },
14938
+ "name": { "type": "string", "minLength": 1, "maxLength": 128 }
13997
14939
  }
13998
14940
  }
13999
14941
  },
@@ -15931,6 +16873,134 @@
15931
16873
  }
15932
16874
  }
15933
16875
  }
16876
+ },
16877
+ "AnalyticsCounter": {
16878
+ "type": "object",
16879
+ "required": [
16880
+ "id",
16881
+ "origin",
16882
+ "status",
16883
+ "generation",
16884
+ "target",
16885
+ "backfill"
16886
+ ],
16887
+ "properties": {
16888
+ "id": {
16889
+ "type": "string"
16890
+ },
16891
+ "name": {
16892
+ "type": [
16893
+ "string",
16894
+ "null"
16895
+ ]
16896
+ },
16897
+ "origin": {
16898
+ "type": "string",
16899
+ "enum": [
16900
+ "pack",
16901
+ "api",
16902
+ "builtin"
16903
+ ]
16904
+ },
16905
+ "status": {
16906
+ "type": "string",
16907
+ "enum": [
16908
+ "backfilling",
16909
+ "live",
16910
+ "error"
16911
+ ]
16912
+ },
16913
+ "generation": {
16914
+ "type": "integer"
16915
+ },
16916
+ "hash": {
16917
+ "type": "string"
16918
+ },
16919
+ "agentIds": {
16920
+ "type": "array",
16921
+ "items": {
16922
+ "type": "string"
16923
+ }
16924
+ },
16925
+ "target": {
16926
+ "type": [
16927
+ "object",
16928
+ "null"
16929
+ ],
16930
+ "properties": {
16931
+ "objectType": {
16932
+ "type": "string"
16933
+ },
16934
+ "contentType": {
16935
+ "type": "string"
16936
+ },
16937
+ "recordId": {
16938
+ "type": "string"
16939
+ }
16940
+ }
16941
+ },
16942
+ "history": {
16943
+ "type": [
16944
+ "object",
16945
+ "null"
16946
+ ],
16947
+ "additionalProperties": true
16948
+ },
16949
+ "backfill": {
16950
+ "type": "object",
16951
+ "additionalProperties": {
16952
+ "type": "object",
16953
+ "properties": {
16954
+ "cursor": {
16955
+ "type": [
16956
+ "string",
16957
+ "null"
16958
+ ]
16959
+ },
16960
+ "done": {
16961
+ "type": "boolean"
16962
+ },
16963
+ "seen": {
16964
+ "type": "integer"
16965
+ }
16966
+ }
16967
+ }
16968
+ },
16969
+ "registeredAt": {
16970
+ "type": "string",
16971
+ "format": "date-time"
16972
+ },
16973
+ "registeredBy": {
16974
+ "type": [
16975
+ "string",
16976
+ "null"
16977
+ ]
16978
+ },
16979
+ "updatedAt": {
16980
+ "type": "string",
16981
+ "format": "date-time"
16982
+ },
16983
+ "liveAt": {
16984
+ "type": [
16985
+ "string",
16986
+ "null"
16987
+ ],
16988
+ "format": "date-time"
16989
+ },
16990
+ "lastMaterializedAt": {
16991
+ "type": [
16992
+ "string",
16993
+ "null"
16994
+ ],
16995
+ "format": "date-time"
16996
+ },
16997
+ "error": {
16998
+ "type": [
16999
+ "string",
17000
+ "null"
17001
+ ]
17002
+ }
17003
+ }
15934
17004
  }
15935
17005
  }
15936
17006
  }