@pulsarinteractive/geniustasker 0.1.0-beta.12 → 0.1.0-beta.13

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.
@@ -329,6 +329,100 @@ export default {
329
329
  "module": "Memory/$",
330
330
  "permission": "memory:write"
331
331
  },
332
+ "metric.correct": {
333
+ "action": "correctMetric",
334
+ "fields": [
335
+ "observedAt",
336
+ "measurement",
337
+ "reason"
338
+ ],
339
+ "inputSchema": "GeniusTasker.Metrics.Correct",
340
+ "module": "Project/ProjectMetricObservation",
341
+ "permission": "metrics:write",
342
+ "personalModule": "LocalUser/LocalUserMetricObservation"
343
+ },
344
+ "metric.create": {
345
+ "action": "configureMetric",
346
+ "create": true,
347
+ "fields": [
348
+ "configuration"
349
+ ],
350
+ "inputSchema": "GeniusTasker.Metrics.Configure",
351
+ "module": "Project/ProjectMetricDefinition",
352
+ "permission": "metrics:write",
353
+ "personalModule": "LocalUser/LocalUserMetricDefinition"
354
+ },
355
+ "metric.delete": {
356
+ "delete": true,
357
+ "fields": [],
358
+ "module": "Project/ProjectMetricDefinition",
359
+ "permission": "metrics:write",
360
+ "personalModule": "LocalUser/LocalUserMetricDefinition"
361
+ },
362
+ "metric.goal.create": {
363
+ "action": "configureMetricGoal",
364
+ "create": true,
365
+ "fields": [
366
+ "configuration"
367
+ ],
368
+ "inputSchema": "GeniusTasker.MetricGoals.ConfigureGoal",
369
+ "module": "Project/ProjectMetricGoal",
370
+ "permission": "metrics:write",
371
+ "personalModule": "LocalUser/LocalUserMetricGoal"
372
+ },
373
+ "metric.goal.delete": {
374
+ "delete": true,
375
+ "fields": [],
376
+ "module": "Project/ProjectMetricGoal",
377
+ "permission": "metrics:write",
378
+ "personalModule": "LocalUser/LocalUserMetricGoal"
379
+ },
380
+ "metric.goal.update": {
381
+ "action": "configureMetricGoal",
382
+ "fields": [
383
+ "configuration"
384
+ ],
385
+ "inputSchema": "GeniusTasker.MetricGoals.ConfigureGoal",
386
+ "module": "Project/ProjectMetricGoal",
387
+ "permission": "metrics:write",
388
+ "personalModule": "LocalUser/LocalUserMetricGoal"
389
+ },
390
+ "metric.record": {
391
+ "action": "recordMetric",
392
+ "create": true,
393
+ "fields": [
394
+ "metricId",
395
+ "measurementVersion",
396
+ "sourceKey",
397
+ "sourceLabel",
398
+ "observedAt",
399
+ "measurement"
400
+ ],
401
+ "inputSchema": "GeniusTasker.Metrics.Record",
402
+ "module": "Project/ProjectMetricObservation",
403
+ "permission": "metrics:write",
404
+ "personalModule": "LocalUser/LocalUserMetricObservation"
405
+ },
406
+ "metric.update": {
407
+ "action": "configureMetric",
408
+ "fields": [
409
+ "configuration"
410
+ ],
411
+ "inputSchema": "GeniusTasker.Metrics.Configure",
412
+ "module": "Project/ProjectMetricDefinition",
413
+ "permission": "metrics:write",
414
+ "personalModule": "LocalUser/LocalUserMetricDefinition"
415
+ },
416
+ "metric.void": {
417
+ "action": "voidMetric",
418
+ "fields": [
419
+ "reason"
420
+ ],
421
+ "inputSchema": "GeniusTasker.Metrics.Void",
422
+ "module": "Project/ProjectMetricObservation",
423
+ "permission": "metrics:write",
424
+ "personalModule": "LocalUser/LocalUserMetricObservation"
425
+ },
332
426
  "project.create": {
333
427
  "create": true,
334
428
  "fields": [
@@ -749,6 +843,8 @@ export default {
749
843
  "approvals:write",
750
844
  "goals:read",
751
845
  "goals:write",
846
+ "metrics:read",
847
+ "metrics:write",
752
848
  "memory:read",
753
849
  "memory:write",
754
850
  "media:read",
@@ -1,5 +1,556 @@
1
1
  // Generated public command data schemas. Do not edit by hand.
2
2
  export default {
3
+ "metric.correct": {
4
+ "type": "object",
5
+ "required": [
6
+ "measurement",
7
+ "observedAt",
8
+ "reason"
9
+ ],
10
+ "properties": {
11
+ "observedAt": {
12
+ "type": "string"
13
+ },
14
+ "measurement": {
15
+ "type": "object",
16
+ "required": [
17
+ "denominator",
18
+ "numerator",
19
+ "value"
20
+ ],
21
+ "properties": {
22
+ "denominator": {
23
+ "anyOf": [
24
+ {
25
+ "type": "number",
26
+ "minimum": 0,
27
+ "maximum": 1000000000
28
+ },
29
+ {
30
+ "type": "null"
31
+ }
32
+ ]
33
+ },
34
+ "numerator": {
35
+ "anyOf": [
36
+ {
37
+ "type": "number",
38
+ "minimum": 0,
39
+ "maximum": 1000000000
40
+ },
41
+ {
42
+ "type": "null"
43
+ }
44
+ ]
45
+ },
46
+ "value": {
47
+ "anyOf": [
48
+ {
49
+ "type": "number",
50
+ "minimum": -1000000000,
51
+ "maximum": 1000000000
52
+ },
53
+ {
54
+ "type": "null"
55
+ }
56
+ ]
57
+ }
58
+ },
59
+ "additionalProperties": false
60
+ },
61
+ "reason": {
62
+ "type": "string",
63
+ "minLength": 1,
64
+ "maxLength": 500
65
+ }
66
+ },
67
+ "additionalProperties": false
68
+ },
69
+ "metric.create": {
70
+ "type": "object",
71
+ "required": [
72
+ "configuration"
73
+ ],
74
+ "properties": {
75
+ "configuration": {
76
+ "type": "object",
77
+ "required": [
78
+ "aggregation",
79
+ "archived",
80
+ "description",
81
+ "freshnessSeconds",
82
+ "key",
83
+ "kind",
84
+ "paused",
85
+ "precision",
86
+ "ratioScale",
87
+ "title",
88
+ "unit",
89
+ "writers"
90
+ ],
91
+ "properties": {
92
+ "aggregation": {
93
+ "type": "string",
94
+ "enum": [
95
+ "Latest",
96
+ "Sum",
97
+ "Mean",
98
+ "Ratio"
99
+ ]
100
+ },
101
+ "archived": {
102
+ "type": "boolean"
103
+ },
104
+ "description": {
105
+ "type": "string",
106
+ "maxLength": 1200
107
+ },
108
+ "freshnessSeconds": {
109
+ "anyOf": [
110
+ {
111
+ "type": "integer",
112
+ "minimum": 60,
113
+ "maximum": 31536000
114
+ },
115
+ {
116
+ "type": "null"
117
+ }
118
+ ]
119
+ },
120
+ "key": {
121
+ "type": "string",
122
+ "maxLength": 48,
123
+ "pattern": "^[a-z][a-z0-9_-]{0,47}$"
124
+ },
125
+ "kind": {
126
+ "type": "string",
127
+ "enum": [
128
+ "Gauge",
129
+ "Counter",
130
+ "Ratio"
131
+ ]
132
+ },
133
+ "paused": {
134
+ "type": "boolean"
135
+ },
136
+ "precision": {
137
+ "type": "integer",
138
+ "minimum": 0,
139
+ "maximum": 6
140
+ },
141
+ "ratioScale": {
142
+ "type": "integer",
143
+ "minimum": 1,
144
+ "maximum": 100
145
+ },
146
+ "title": {
147
+ "type": "string",
148
+ "minLength": 1,
149
+ "maxLength": 160
150
+ },
151
+ "unit": {
152
+ "type": "string",
153
+ "minLength": 1,
154
+ "maxLength": 24
155
+ },
156
+ "writers": {
157
+ "type": "array",
158
+ "maxItems": 64,
159
+ "uniqueItems": true,
160
+ "items": {
161
+ "type": "string"
162
+ }
163
+ }
164
+ },
165
+ "additionalProperties": false
166
+ }
167
+ },
168
+ "additionalProperties": false
169
+ },
170
+ "metric.goal.create": {
171
+ "type": "object",
172
+ "required": [
173
+ "configuration"
174
+ ],
175
+ "properties": {
176
+ "configuration": {
177
+ "type": "object",
178
+ "required": [
179
+ "archived",
180
+ "coachSignal",
181
+ "comparison",
182
+ "completion",
183
+ "description",
184
+ "metricId",
185
+ "notifyCompleted",
186
+ "paused",
187
+ "target",
188
+ "title",
189
+ "window"
190
+ ],
191
+ "properties": {
192
+ "archived": {
193
+ "type": "boolean"
194
+ },
195
+ "coachSignal": {
196
+ "type": "boolean"
197
+ },
198
+ "comparison": {
199
+ "type": "string",
200
+ "enum": [
201
+ "AtLeast",
202
+ "AtMost"
203
+ ]
204
+ },
205
+ "completion": {
206
+ "type": "string",
207
+ "enum": [
208
+ "OnReach",
209
+ "AtEnd"
210
+ ]
211
+ },
212
+ "description": {
213
+ "type": "string",
214
+ "maxLength": 1200
215
+ },
216
+ "metricId": {
217
+ "type": "string"
218
+ },
219
+ "notifyCompleted": {
220
+ "type": "boolean"
221
+ },
222
+ "paused": {
223
+ "type": "boolean"
224
+ },
225
+ "target": {
226
+ "type": "string",
227
+ "maxLength": 32,
228
+ "pattern": "^-?[0-9]{1,24}(\\.[0-9]{1,6})?$"
229
+ },
230
+ "title": {
231
+ "type": "string",
232
+ "minLength": 1,
233
+ "maxLength": 160
234
+ },
235
+ "window": {
236
+ "anyOf": [
237
+ {
238
+ "type": "object",
239
+ "required": [
240
+ "end",
241
+ "start"
242
+ ],
243
+ "properties": {
244
+ "end": {
245
+ "type": "string"
246
+ },
247
+ "start": {
248
+ "type": "string"
249
+ }
250
+ },
251
+ "additionalProperties": false
252
+ },
253
+ {
254
+ "type": "null"
255
+ }
256
+ ]
257
+ }
258
+ },
259
+ "additionalProperties": false
260
+ }
261
+ },
262
+ "additionalProperties": false
263
+ },
264
+ "metric.goal.update": {
265
+ "type": "object",
266
+ "required": [
267
+ "configuration"
268
+ ],
269
+ "properties": {
270
+ "configuration": {
271
+ "type": "object",
272
+ "required": [
273
+ "archived",
274
+ "coachSignal",
275
+ "comparison",
276
+ "completion",
277
+ "description",
278
+ "metricId",
279
+ "notifyCompleted",
280
+ "paused",
281
+ "target",
282
+ "title",
283
+ "window"
284
+ ],
285
+ "properties": {
286
+ "archived": {
287
+ "type": "boolean"
288
+ },
289
+ "coachSignal": {
290
+ "type": "boolean"
291
+ },
292
+ "comparison": {
293
+ "type": "string",
294
+ "enum": [
295
+ "AtLeast",
296
+ "AtMost"
297
+ ]
298
+ },
299
+ "completion": {
300
+ "type": "string",
301
+ "enum": [
302
+ "OnReach",
303
+ "AtEnd"
304
+ ]
305
+ },
306
+ "description": {
307
+ "type": "string",
308
+ "maxLength": 1200
309
+ },
310
+ "metricId": {
311
+ "type": "string"
312
+ },
313
+ "notifyCompleted": {
314
+ "type": "boolean"
315
+ },
316
+ "paused": {
317
+ "type": "boolean"
318
+ },
319
+ "target": {
320
+ "type": "string",
321
+ "maxLength": 32,
322
+ "pattern": "^-?[0-9]{1,24}(\\.[0-9]{1,6})?$"
323
+ },
324
+ "title": {
325
+ "type": "string",
326
+ "minLength": 1,
327
+ "maxLength": 160
328
+ },
329
+ "window": {
330
+ "anyOf": [
331
+ {
332
+ "type": "object",
333
+ "required": [
334
+ "end",
335
+ "start"
336
+ ],
337
+ "properties": {
338
+ "end": {
339
+ "type": "string"
340
+ },
341
+ "start": {
342
+ "type": "string"
343
+ }
344
+ },
345
+ "additionalProperties": false
346
+ },
347
+ {
348
+ "type": "null"
349
+ }
350
+ ]
351
+ }
352
+ },
353
+ "additionalProperties": false
354
+ }
355
+ },
356
+ "additionalProperties": false
357
+ },
358
+ "metric.record": {
359
+ "type": "object",
360
+ "required": [
361
+ "measurement",
362
+ "measurementVersion",
363
+ "metricId",
364
+ "observedAt",
365
+ "sourceKey",
366
+ "sourceLabel"
367
+ ],
368
+ "properties": {
369
+ "metricId": {
370
+ "type": "string"
371
+ },
372
+ "measurementVersion": {
373
+ "type": "integer",
374
+ "minimum": 1
375
+ },
376
+ "sourceKey": {
377
+ "type": "string",
378
+ "minLength": 1,
379
+ "maxLength": 160
380
+ },
381
+ "sourceLabel": {
382
+ "type": "string",
383
+ "minLength": 1,
384
+ "maxLength": 120
385
+ },
386
+ "observedAt": {
387
+ "type": "string"
388
+ },
389
+ "measurement": {
390
+ "type": "object",
391
+ "required": [
392
+ "denominator",
393
+ "numerator",
394
+ "value"
395
+ ],
396
+ "properties": {
397
+ "denominator": {
398
+ "anyOf": [
399
+ {
400
+ "type": "number",
401
+ "minimum": 0,
402
+ "maximum": 1000000000
403
+ },
404
+ {
405
+ "type": "null"
406
+ }
407
+ ]
408
+ },
409
+ "numerator": {
410
+ "anyOf": [
411
+ {
412
+ "type": "number",
413
+ "minimum": 0,
414
+ "maximum": 1000000000
415
+ },
416
+ {
417
+ "type": "null"
418
+ }
419
+ ]
420
+ },
421
+ "value": {
422
+ "anyOf": [
423
+ {
424
+ "type": "number",
425
+ "minimum": -1000000000,
426
+ "maximum": 1000000000
427
+ },
428
+ {
429
+ "type": "null"
430
+ }
431
+ ]
432
+ }
433
+ },
434
+ "additionalProperties": false
435
+ }
436
+ },
437
+ "additionalProperties": false
438
+ },
439
+ "metric.update": {
440
+ "type": "object",
441
+ "required": [
442
+ "configuration"
443
+ ],
444
+ "properties": {
445
+ "configuration": {
446
+ "type": "object",
447
+ "required": [
448
+ "aggregation",
449
+ "archived",
450
+ "description",
451
+ "freshnessSeconds",
452
+ "key",
453
+ "kind",
454
+ "paused",
455
+ "precision",
456
+ "ratioScale",
457
+ "title",
458
+ "unit",
459
+ "writers"
460
+ ],
461
+ "properties": {
462
+ "aggregation": {
463
+ "type": "string",
464
+ "enum": [
465
+ "Latest",
466
+ "Sum",
467
+ "Mean",
468
+ "Ratio"
469
+ ]
470
+ },
471
+ "archived": {
472
+ "type": "boolean"
473
+ },
474
+ "description": {
475
+ "type": "string",
476
+ "maxLength": 1200
477
+ },
478
+ "freshnessSeconds": {
479
+ "anyOf": [
480
+ {
481
+ "type": "integer",
482
+ "minimum": 60,
483
+ "maximum": 31536000
484
+ },
485
+ {
486
+ "type": "null"
487
+ }
488
+ ]
489
+ },
490
+ "key": {
491
+ "type": "string",
492
+ "maxLength": 48,
493
+ "pattern": "^[a-z][a-z0-9_-]{0,47}$"
494
+ },
495
+ "kind": {
496
+ "type": "string",
497
+ "enum": [
498
+ "Gauge",
499
+ "Counter",
500
+ "Ratio"
501
+ ]
502
+ },
503
+ "paused": {
504
+ "type": "boolean"
505
+ },
506
+ "precision": {
507
+ "type": "integer",
508
+ "minimum": 0,
509
+ "maximum": 6
510
+ },
511
+ "ratioScale": {
512
+ "type": "integer",
513
+ "minimum": 1,
514
+ "maximum": 100
515
+ },
516
+ "title": {
517
+ "type": "string",
518
+ "minLength": 1,
519
+ "maxLength": 160
520
+ },
521
+ "unit": {
522
+ "type": "string",
523
+ "minLength": 1,
524
+ "maxLength": 24
525
+ },
526
+ "writers": {
527
+ "type": "array",
528
+ "maxItems": 64,
529
+ "uniqueItems": true,
530
+ "items": {
531
+ "type": "string"
532
+ }
533
+ }
534
+ },
535
+ "additionalProperties": false
536
+ }
537
+ },
538
+ "additionalProperties": false
539
+ },
540
+ "metric.void": {
541
+ "type": "object",
542
+ "required": [
543
+ "reason"
544
+ ],
545
+ "properties": {
546
+ "reason": {
547
+ "type": "string",
548
+ "minLength": 1,
549
+ "maxLength": 500
550
+ }
551
+ },
552
+ "additionalProperties": false
553
+ },
3
554
  "protocol.apply": {
4
555
  "type": "object",
5
556
  "required": [
package/src/commands.mjs CHANGED
@@ -26,7 +26,7 @@ export const commandSchema = z
26
26
  .string()
27
27
  .max(256)
28
28
  // eslint-disable-next-line no-control-regex -- Reject control characters in untrusted input.
29
- .regex(/^(project|memory):[^\u0000-\u001f]+$/u),
29
+ .regex(/^(project|memory|personal):[^\u0000-\u001f]+$/u),
30
30
  epoch: identifier,
31
31
  id: identifier,
32
32
  expectedRevision: z
@@ -38,6 +38,15 @@ export const commandSchema = z
38
38
  })
39
39
  .strict();
40
40
  export const draftSchema = commandSchema.omit({ operationId: true, issuedAt: true });
41
+ export const metricCommandSchema = commandSchema
42
+ .extend({
43
+ kind: z.enum(
44
+ Object.entries(catalog.commands)
45
+ .filter(([, definition]) => definition.permission === 'metrics:write')
46
+ .map(([kind]) => kind),
47
+ ),
48
+ })
49
+ .strict();
41
50
  const canonical = (value) =>
42
51
  JSON.stringify(value, (_, item) =>
43
52
  item && typeof item === 'object' && !Array.isArray(item)
@@ -72,12 +81,20 @@ export function validateCommand(value) {
72
81
  'Use the declared command fields and size limit. Creation requires a null revision; other commands require the current record revision.',
73
82
  );
74
83
  }
75
- const prefix = definition.module.startsWith('Memory/') ? 'memory:' : 'project:';
84
+ const prefix =
85
+ command.scope.startsWith('personal:') && definition.personalModule
86
+ ? 'personal:'
87
+ : definition.module.startsWith('Memory/')
88
+ ? 'memory:'
89
+ : 'project:';
76
90
  if (
77
91
  !command.scope.startsWith(prefix) ||
78
92
  (definition.module.endsWith('/$') && command.id !== command.scope.slice(prefix.length))
79
93
  ) {
80
- fail('invalid_arguments', 'The command must target the matching project or memory scope.');
94
+ fail(
95
+ 'invalid_arguments',
96
+ 'Use the matching project or memory scope. Only declared personal metric commands may target personal:<connected-owner>.',
97
+ );
81
98
  }
82
99
  if (
83
100
  ['memory.create', 'project.create'].includes(command.kind) &&