repzo 1.0.291 → 1.0.293

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 (34) hide show
  1. package/changelog.md +28 -0
  2. package/lib/index.d.ts +244 -2
  3. package/lib/index.js +541 -0
  4. package/lib/types/index.d.ts +4533 -1
  5. package/package.json +1 -1
  6. package/src/index.ts +1270 -0
  7. package/src/oas/activity-ai-object-detection-session-frame.yaml +600 -0
  8. package/src/oas/ai-object-detection-assigned-missions.yaml +283 -0
  9. package/src/oas/ai-object-detection-assignment-rule.yaml +357 -0
  10. package/src/oas/ai-object-detection-category.yaml +338 -0
  11. package/src/oas/ai-object-detection-dataset.yaml +342 -0
  12. package/src/oas/ai-object-detection-detection-settings.yaml +410 -0
  13. package/src/oas/ai-object-detection-inference.yaml +818 -0
  14. package/src/oas/ai-object-detection-label-group.yaml +265 -0
  15. package/src/oas/ai-object-detection-label-report.yaml +366 -0
  16. package/src/oas/ai-object-detection-label.yaml +395 -0
  17. package/src/oas/ai-object-detection-metric-result.yaml +734 -0
  18. package/src/oas/ai-object-detection-metric.yaml +559 -0
  19. package/src/oas/ai-object-detection-mission-results.yaml +370 -0
  20. package/src/oas/ai-object-detection-mission-set.yaml +250 -0
  21. package/src/oas/ai-object-detection-mission.yaml +349 -0
  22. package/src/oas/ai-object-detection-model-version-epoch.yaml +214 -0
  23. package/src/oas/ai-object-detection-model-version-train-agent.yaml +88 -0
  24. package/src/oas/ai-object-detection-model-version.yaml +567 -0
  25. package/src/oas/ai-object-detection-model.yaml +369 -0
  26. package/src/oas/ai-object-detection-segment.yaml +301 -0
  27. package/src/oas/ai-object-detection-session-analysis.yaml +1306 -0
  28. package/src/oas/ai-object-detection-session-election.yaml +193 -0
  29. package/src/oas/ai-object-detection-session-insight.yaml +418 -0
  30. package/src/oas/ai-object-detection-session.yaml +840 -0
  31. package/src/oas/ai-object-detection-settings.yaml +249 -0
  32. package/src/oas/ai-object-detection-task.yaml +1007 -0
  33. package/src/oas/object-detection-analytics-report.yaml +674 -0
  34. package/src/types/index.ts +5159 -1
@@ -0,0 +1,370 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Repzo API - AI Object Detection Mission Results
4
+ version: 2.0.0
5
+ description: |
6
+ **Mission results** — the STORED outcome of mission executions: exactly
7
+ ONE document per (session, mission), written by the metric evaluator and
8
+ kept in step by every metric-result flag/override/confirm. Re-analyzing
9
+ a session RE-POINTS its documents at the new analysis instead of adding
10
+ rows — a session can never appear twice for the same mission, and the
11
+ review state survives re-analysis.
12
+
13
+ Each document carries: the `analysis` it currently reflects, the
14
+ denormalized scan context (`user`/`user_name` = the scanning rep,
15
+ `client`/`client_name`, `teams`, the scan's visit context `visit_id` /
16
+ `route` / `business_day`), `time` (analysis time ≈ the visit),
17
+ `scanned` (the session was STARTED FROM this mission), the outcome
18
+ (`score` = the weighted EFFECTIVE metric scores with confirmed human
19
+ overrides folded in, `min_score`, `completed` — a zero score never
20
+ completes), `via_sets` (assignment snapshot at evaluation time), and the
21
+ REVIEW WORKFLOW: `flagged` (DERIVED — any of the mission's metric
22
+ results carries a flag; a fresh flag REOPENS a resolved document) and
23
+ `resolved` (the admin's verdict, the only writable field here; resolving
24
+ stamps `resolver` + `resolved_at`).
25
+
26
+ Assignment is snapshotted AT EVALUATION TIME — assignment-rule edits
27
+ affect future evaluations, not recorded history. The per-client "what's
28
+ due now" read lives in `/ai-object-detection-assigned-missions` (it
29
+ counts completions from these documents, so a re-analyzed visit can
30
+ never double-count).
31
+
32
+ **Reads.** The list defaults to a 30-day window on `time` (`from_time` /
33
+ `to_time`, Unix ms) sorted newest first (`time` desc, `_id` desc — the
34
+ `sort` param is ignored). There is NO create (documents are written by
35
+ the evaluator only — 400) and no `PATCH` (400).
36
+
37
+ **Roles.** Admins see everything and may narrow with `?rep=` (list and
38
+ single reads); a REP token is FORCED to its own results (`user` = the
39
+ rep) and is read-only (`PUT`/`DELETE` → 403). Scoped by
40
+ `company_namespace`; soft-deleted via `disabled`.
41
+ servers:
42
+ - url: https://sv.api.repzo.me
43
+ security:
44
+ - ApiKeyAuth: []
45
+ - JwtAuth: []
46
+ paths:
47
+ /ai-object-detection-mission-results:
48
+ get:
49
+ summary: The mission-results listing
50
+ operationId: findAiObjectDetectionMissionResults
51
+ parameters:
52
+ - in: query
53
+ name: from_time
54
+ description: Window start on `time` (ms). Default = 30 days before to_time.
55
+ schema: { type: number }
56
+ - in: query
57
+ name: to_time
58
+ description: Window end (ms). Default = now.
59
+ schema: { type: number }
60
+ - in: query
61
+ name: _id
62
+ schema:
63
+ oneOf:
64
+ - type: string
65
+ - type: array
66
+ items: { type: string }
67
+ - in: query
68
+ name: client
69
+ description: Restrict to one (or more) client.
70
+ schema:
71
+ oneOf:
72
+ - type: string
73
+ - type: array
74
+ items: { type: string }
75
+ - in: query
76
+ name: session
77
+ description: Restrict to one (or more) session.
78
+ schema:
79
+ oneOf:
80
+ - type: string
81
+ - type: array
82
+ items: { type: string }
83
+ - in: query
84
+ name: mission
85
+ description: Restrict to one (or more) mission.
86
+ schema:
87
+ oneOf:
88
+ - type: string
89
+ - type: array
90
+ items: { type: string }
91
+ - in: query
92
+ name: analysis
93
+ description: Restrict to documents currently pointing at this analysis.
94
+ schema:
95
+ oneOf:
96
+ - type: string
97
+ - type: array
98
+ items: { type: string }
99
+ - in: query
100
+ name: user
101
+ description: "The scanning rep's id. Overridden by `rep`; a rep token is always forced to itself."
102
+ schema:
103
+ oneOf:
104
+ - type: string
105
+ - type: array
106
+ items: { type: string }
107
+ - in: query
108
+ name: rep
109
+ description: "Restrict to one rep's results (admin only — a rep token is always forced to itself). Ignored unless a valid ObjectId; maps onto `user`."
110
+ schema: { type: string }
111
+ - in: query
112
+ name: teams
113
+ description: "The scanning rep's team id(s) at evaluation time — pass once or as `?teams[]=`."
114
+ schema:
115
+ oneOf:
116
+ - type: string
117
+ - type: array
118
+ items: { type: string }
119
+ - in: query
120
+ name: visit_id
121
+ description: Restrict to scans made in one visit (device `visits.visit_id`).
122
+ schema:
123
+ oneOf:
124
+ - type: string
125
+ - type: array
126
+ items: { type: string }
127
+ - in: query
128
+ name: route
129
+ description: Restrict to scans made on one route (`sv.routes` `_id`).
130
+ schema:
131
+ oneOf:
132
+ - type: string
133
+ - type: array
134
+ items: { type: string }
135
+ - in: query
136
+ name: flagged
137
+ description: Only results whose mission metrics carry a flag (or none).
138
+ schema: { type: boolean }
139
+ - in: query
140
+ name: resolved
141
+ description: Filter by the admin review verdict.
142
+ schema: { type: boolean }
143
+ - in: query
144
+ name: completed
145
+ description: Only completed (or only missed) missions.
146
+ schema: { type: boolean }
147
+ - in: query
148
+ name: scanned
149
+ description: 'Only sessions started FROM their mission ("SCAN THIS MISSION").'
150
+ schema: { type: boolean }
151
+ - in: query
152
+ name: disabled
153
+ description: "Include soft-deleted documents (`true`) or only live ones (`false`). Omitted = no filter."
154
+ schema: { type: boolean }
155
+ - in: query
156
+ name: from_createdAt
157
+ schema: { type: number }
158
+ - in: query
159
+ name: to_createdAt
160
+ schema: { type: number }
161
+ - in: query
162
+ name: per_page
163
+ schema: { type: integer, minimum: 1 }
164
+ - in: query
165
+ name: page
166
+ schema: { type: integer, minimum: 1 }
167
+ responses:
168
+ "200":
169
+ description: Paginated mission-result documents, newest first.
170
+ content:
171
+ application/json:
172
+ schema:
173
+ $ref: "#/components/schemas/MissionResultFindResult"
174
+ post:
175
+ summary: Not supported
176
+ description: "Always 400 — mission results are written by the metric evaluator (`POST /ai-object-detection-metric-result` recalculates them)."
177
+ operationId: createAiObjectDetectionMissionResult
178
+ x-scalar-ignore: true
179
+ responses:
180
+ "400":
181
+ description: "`Object Detection Mission Results: written by the metric evaluator — create is not allowed`."
182
+ /ai-object-detection-mission-results/{id}:
183
+ get:
184
+ summary: Get one mission result
185
+ operationId: getAiObjectDetectionMissionResult
186
+ parameters:
187
+ - in: path
188
+ name: id
189
+ required: true
190
+ schema: { type: string }
191
+ - in: query
192
+ name: rep
193
+ description: "Admin only — the document must belong to this rep (`user`). A rep token is forced to itself."
194
+ schema: { type: string }
195
+ responses:
196
+ "200":
197
+ description: The mission-result document.
198
+ content:
199
+ application/json:
200
+ schema:
201
+ $ref: "#/components/schemas/MissionResult"
202
+ "400":
203
+ description: Not found (or not owned by the rep).
204
+ put:
205
+ summary: Review verdict — resolved only
206
+ description: |
207
+ ADMIN ONLY. The single writable field is `resolved` — everything
208
+ else (score, completed, flagged, context) is derived from the metric
209
+ results and the evaluator. Resolving stamps `resolver` +
210
+ `resolved_at`; un-resolving clears both; a FRESH metric-result flag
211
+ automatically reopens the document (resolved flips back to false).
212
+ operationId: updateAiObjectDetectionMissionResult
213
+ parameters:
214
+ - in: path
215
+ name: id
216
+ required: true
217
+ schema: { type: string }
218
+ requestBody:
219
+ required: true
220
+ content:
221
+ application/json:
222
+ schema:
223
+ type: object
224
+ required: [resolved]
225
+ properties:
226
+ resolved: { type: boolean }
227
+ responses:
228
+ "200":
229
+ description: The updated document.
230
+ content:
231
+ application/json:
232
+ schema:
233
+ $ref: "#/components/schemas/MissionResult"
234
+ "400":
235
+ description: "`resolved` missing / not a boolean, or not found."
236
+ "403":
237
+ description: Rep tokens may not resolve.
238
+ delete:
239
+ summary: Soft-delete a mission result (admin)
240
+ operationId: removeAiObjectDetectionMissionResult
241
+ parameters:
242
+ - in: path
243
+ name: id
244
+ required: true
245
+ schema: { type: string }
246
+ responses:
247
+ "200":
248
+ description: The soft-deleted document.
249
+ content:
250
+ application/json:
251
+ schema:
252
+ $ref: "#/components/schemas/MissionResult"
253
+ "400":
254
+ description: Not found.
255
+ "403":
256
+ description: Rep tokens may not remove.
257
+ components:
258
+ securitySchemes:
259
+ ApiKeyAuth:
260
+ type: apiKey
261
+ in: header
262
+ name: api-key
263
+ JwtAuth:
264
+ type: apiKey
265
+ in: header
266
+ name: Authorization
267
+ schemas:
268
+ UserStamp:
269
+ type: object
270
+ description: "A user stamp from the token (`resolver`, `creator`, `editor`)."
271
+ properties:
272
+ _id: { type: string }
273
+ name: { type: string }
274
+ type:
275
+ type: string
276
+ enum: [admin, rep, client, tenant]
277
+ admin: { type: string }
278
+ rep: { type: string }
279
+ client: { type: string }
280
+ tenant: { type: string }
281
+ MissionResult:
282
+ type: object
283
+ properties:
284
+ _id: { type: string }
285
+ session: { type: string }
286
+ mission: { type: string }
287
+ analysis:
288
+ type: string
289
+ description: The analysis this result CURRENTLY reflects (the latest evaluated one — re-analysis re-points it).
290
+ user:
291
+ type: string
292
+ nullable: true
293
+ description: The SCANNING rep (unset for admin-scanned sessions).
294
+ user_name: { type: string, nullable: true }
295
+ client: { type: string, nullable: true }
296
+ client_name: { type: string, nullable: true }
297
+ teams:
298
+ type: array
299
+ items: { type: string }
300
+ visit_id:
301
+ type: string
302
+ description: Device visit id of the visit the scan happened in (copied from the session; absent on scans made without a visit).
303
+ route:
304
+ type: string
305
+ description: "`sv.routes` `_id` of the visit's route."
306
+ business_day:
307
+ type: string
308
+ description: "Business day of the scan, `YYYY-MM-DD` (copied from the session)."
309
+ time:
310
+ type: number
311
+ description: Analysis time (ms) ≈ the visit.
312
+ scanned:
313
+ type: boolean
314
+ description: 'The session was started FROM this mission ("SCAN THIS MISSION").'
315
+ mission_name: { type: string }
316
+ score:
317
+ type: number
318
+ description: Weighted EFFECTIVE metric scores 0..1 (confirmed human overrides folded in; a demanded metric without a result counts 0).
319
+ min_score:
320
+ type: number
321
+ description: Mission threshold snapshot (default 0).
322
+ completed:
323
+ type: boolean
324
+ description: score reached min_score (a ZERO score never completes).
325
+ via_sets:
326
+ type: array
327
+ items: { type: string }
328
+ description: Mission-set names that assigned it (snapshot at evaluation time).
329
+ flagged:
330
+ type: boolean
331
+ description: DERIVED — any of the mission's metric results on `analysis` carries a flag.
332
+ resolved:
333
+ type: boolean
334
+ description: Admin review verdict; auto-reopens (false) when a fresh flag arrives.
335
+ resolver:
336
+ nullable: true
337
+ allOf:
338
+ - $ref: "#/components/schemas/UserStamp"
339
+ resolved_at:
340
+ type: number
341
+ nullable: true
342
+ description: Unix ms; null when un-resolved.
343
+ creator:
344
+ $ref: "#/components/schemas/UserStamp"
345
+ editor:
346
+ $ref: "#/components/schemas/UserStamp"
347
+ disabled: { type: boolean }
348
+ company_namespace:
349
+ type: array
350
+ items: { type: string }
351
+ createdAt: { type: string, format: date-time }
352
+ updatedAt: { type: string, format: date-time }
353
+ MissionResultFindResult:
354
+ type: object
355
+ description: Standard paginated result envelope.
356
+ properties:
357
+ data:
358
+ type: array
359
+ items:
360
+ $ref: "#/components/schemas/MissionResult"
361
+ total_result: { type: number }
362
+ current_count: { type: number }
363
+ total_pages: { type: number }
364
+ current_page: { type: number }
365
+ per_page: { type: number }
366
+ first_page_url: { type: string }
367
+ last_page_url: { type: string }
368
+ next_page_url: { type: string, nullable: true }
369
+ prev_page_url: { type: string, nullable: true }
370
+ path: { type: string }
@@ -0,0 +1,250 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Repzo API - AI Object Detection Mission Set
4
+ version: 1.0.0
5
+ description: |
6
+ **Mission sets** group missions (`/ai-object-detection-mission`) into
7
+ the unit assignment rules (`/ai-object-detection-assignment-rule`)
8
+ target: "assign set X to clients with tag Y", each rule line carrying a
9
+ requirement mode for the set's missions. Resolution happens at read /
10
+ evaluation time (the mission `scores_for` read, the assigned-missions
11
+ read and the metric evaluator) — nothing is ever persisted on the
12
+ client, so editing a set's `missions` is reflected on the next read.
13
+
14
+ **Validation.** Create AND update require `missions` with at least one
15
+ valid mission id (every violation listed in one 400). `enabled: false`
16
+ makes the set invisible to assignment resolution without deleting it.
17
+
18
+ **Multi-tenancy & lifecycle.** Scoped by `company_namespace` (injected
19
+ from the caller's token; SDK callers may pass an explicit value on
20
+ create), soft-deleted via `disabled`. `PATCH` is not supported (400 —
21
+ use `PUT`). Admin-facing.
22
+ servers:
23
+ - url: https://sv.api.repzo.me
24
+ security:
25
+ - ApiKeyAuth: []
26
+ - JwtAuth: []
27
+ paths:
28
+ /ai-object-detection-mission-set:
29
+ get:
30
+ summary: List mission sets
31
+ operationId: findMissionSet
32
+ parameters:
33
+ - in: query
34
+ name: _id
35
+ schema:
36
+ oneOf:
37
+ - type: string
38
+ - type: array
39
+ items: { type: string }
40
+ - in: query
41
+ name: name
42
+ description: Exact name match.
43
+ schema:
44
+ oneOf:
45
+ - type: string
46
+ - type: array
47
+ items: { type: string }
48
+ - in: query
49
+ name: search
50
+ description: Case-insensitive substring search on `name`.
51
+ schema: { type: string }
52
+ - in: query
53
+ name: enabled
54
+ schema: { type: boolean }
55
+ - in: query
56
+ name: disabled
57
+ description: "Include soft-deleted sets (`true`) or only live ones (`false`). Omitted = no filter."
58
+ schema: { type: boolean }
59
+ - in: query
60
+ name: from_updatedAt
61
+ schema: { type: number }
62
+ - in: query
63
+ name: to_updatedAt
64
+ schema: { type: number }
65
+ - in: query
66
+ name: from_createdAt
67
+ schema: { type: number }
68
+ - in: query
69
+ name: to_createdAt
70
+ schema: { type: number }
71
+ - in: query
72
+ name: per_page
73
+ schema: { type: integer, minimum: 1 }
74
+ - in: query
75
+ name: page
76
+ schema: { type: integer, minimum: 1 }
77
+ responses:
78
+ "200":
79
+ description: "Paginated documents (newest `_id` first)."
80
+ content:
81
+ application/json:
82
+ schema:
83
+ $ref: "#/components/schemas/MissionSetFindResult"
84
+ post:
85
+ summary: Create a mission set
86
+ operationId: createMissionSet
87
+ requestBody:
88
+ required: true
89
+ content:
90
+ application/json:
91
+ schema:
92
+ $ref: "#/components/schemas/MissionSetCreateBody"
93
+ responses:
94
+ "201":
95
+ description: The created document.
96
+ content:
97
+ application/json:
98
+ schema:
99
+ $ref: "#/components/schemas/MissionSet"
100
+ "400":
101
+ description: Validation failed — the message lists every violation.
102
+ /ai-object-detection-mission-set/{id}:
103
+ get:
104
+ summary: Get a mission set
105
+ operationId: getMissionSet
106
+ parameters:
107
+ - in: path
108
+ name: id
109
+ required: true
110
+ schema: { type: string }
111
+ responses:
112
+ "200":
113
+ description: The document.
114
+ content:
115
+ application/json:
116
+ schema:
117
+ $ref: "#/components/schemas/MissionSet"
118
+ "400":
119
+ description: Not found.
120
+ put:
121
+ summary: Update a mission set (re-validated)
122
+ description: "Same validation as create — `missions` (≥ 1 id) is required again. Set `disabled: true` to soft-delete."
123
+ operationId: updateMissionSet
124
+ parameters:
125
+ - in: path
126
+ name: id
127
+ required: true
128
+ schema: { type: string }
129
+ requestBody:
130
+ required: true
131
+ content:
132
+ application/json:
133
+ schema:
134
+ $ref: "#/components/schemas/MissionSetUpdateBody"
135
+ responses:
136
+ "200":
137
+ description: The updated document.
138
+ content:
139
+ application/json:
140
+ schema:
141
+ $ref: "#/components/schemas/MissionSet"
142
+ "400":
143
+ description: Validation failed.
144
+ "404":
145
+ description: Not found.
146
+ delete:
147
+ summary: Soft-delete a mission set
148
+ operationId: removeMissionSet
149
+ parameters:
150
+ - in: path
151
+ name: id
152
+ required: true
153
+ schema: { type: string }
154
+ responses:
155
+ "200":
156
+ description: The disabled document.
157
+ content:
158
+ application/json:
159
+ schema:
160
+ $ref: "#/components/schemas/MissionSet"
161
+ "404":
162
+ description: Not found.
163
+ components:
164
+ securitySchemes:
165
+ ApiKeyAuth:
166
+ type: apiKey
167
+ in: header
168
+ name: api-key
169
+ JwtAuth:
170
+ type: apiKey
171
+ in: header
172
+ name: Authorization
173
+ schemas:
174
+ UserStamp:
175
+ type: object
176
+ description: "Who created / last edited the document (server-stamped from the token)."
177
+ properties:
178
+ _id: { type: string }
179
+ name: { type: string }
180
+ type:
181
+ type: string
182
+ enum: [admin, rep, client, tenant]
183
+ admin: { type: string }
184
+ rep: { type: string }
185
+ client: { type: string }
186
+ tenant: { type: string }
187
+ MissionSetFields:
188
+ type: object
189
+ properties:
190
+ name: { type: string }
191
+ description: { type: string }
192
+ missions:
193
+ type: array
194
+ minItems: 1
195
+ items: { type: string }
196
+ description: "Mission ids in this set (required, ≥ 1 valid id)."
197
+ enabled: { type: boolean, default: true }
198
+ MissionSetCreateBody:
199
+ allOf:
200
+ - $ref: "#/components/schemas/MissionSetFields"
201
+ - type: object
202
+ required: [name, missions]
203
+ properties:
204
+ company_namespace:
205
+ type: array
206
+ items: { type: string }
207
+ description: Optional tenant namespace override for SDK callers.
208
+ MissionSetUpdateBody:
209
+ allOf:
210
+ - $ref: "#/components/schemas/MissionSetFields"
211
+ - type: object
212
+ required: [missions]
213
+ properties:
214
+ disabled:
215
+ type: boolean
216
+ description: Soft-delete flag.
217
+ MissionSet:
218
+ allOf:
219
+ - $ref: "#/components/schemas/MissionSetFields"
220
+ - type: object
221
+ properties:
222
+ _id: { type: string }
223
+ disabled: { type: boolean }
224
+ creator:
225
+ $ref: "#/components/schemas/UserStamp"
226
+ editor:
227
+ $ref: "#/components/schemas/UserStamp"
228
+ company_namespace:
229
+ type: array
230
+ items: { type: string }
231
+ createdAt: { type: string, format: date-time }
232
+ updatedAt: { type: string, format: date-time }
233
+ MissionSetFindResult:
234
+ type: object
235
+ description: Standard paginated result envelope.
236
+ properties:
237
+ data:
238
+ type: array
239
+ items:
240
+ $ref: "#/components/schemas/MissionSet"
241
+ total_result: { type: number }
242
+ current_count: { type: number }
243
+ total_pages: { type: number }
244
+ current_page: { type: number }
245
+ per_page: { type: number }
246
+ first_page_url: { type: string }
247
+ last_page_url: { type: string }
248
+ next_page_url: { type: string, nullable: true }
249
+ prev_page_url: { type: string, nullable: true }
250
+ path: { type: string }