@syntrologie/adapt-gamification 2.3.0 → 2.4.0-canary.10

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/dist/schema.d.ts CHANGED
@@ -147,16 +147,259 @@ export declare const AwardBadgeSchema: z.ZodObject<{
147
147
  badgeId: z.ZodString;
148
148
  anchorId: z.ZodOptional<z.ZodString>;
149
149
  label: z.ZodOptional<z.ZodString>;
150
+ } & {
151
+ activation: z.ZodOptional<z.ZodObject<{
152
+ routes: z.ZodObject<{
153
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
154
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
155
+ }, "strip", z.ZodTypeAny, {
156
+ include?: string[] | undefined;
157
+ exclude?: string[] | undefined;
158
+ }, {
159
+ include?: string[] | undefined;
160
+ exclude?: string[] | undefined;
161
+ }>;
162
+ strategy: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
163
+ type: z.ZodLiteral<"rules">;
164
+ rules: z.ZodArray<z.ZodObject<{
165
+ conditions: z.ZodArray<z.ZodObject<{
166
+ type: z.ZodString;
167
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
168
+ type: z.ZodString;
169
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
170
+ type: z.ZodString;
171
+ }, z.ZodTypeAny, "passthrough">>, "many">;
172
+ value: z.ZodUnknown;
173
+ }, "strip", z.ZodTypeAny, {
174
+ conditions: z.objectOutputType<{
175
+ type: z.ZodString;
176
+ }, z.ZodTypeAny, "passthrough">[];
177
+ value?: unknown;
178
+ }, {
179
+ conditions: z.objectInputType<{
180
+ type: z.ZodString;
181
+ }, z.ZodTypeAny, "passthrough">[];
182
+ value?: unknown;
183
+ }>, "many">;
184
+ default: z.ZodUnknown;
185
+ }, "strip", z.ZodTypeAny, {
186
+ type: "rules";
187
+ rules: {
188
+ conditions: z.objectOutputType<{
189
+ type: z.ZodString;
190
+ }, z.ZodTypeAny, "passthrough">[];
191
+ value?: unknown;
192
+ }[];
193
+ default?: unknown;
194
+ }, {
195
+ type: "rules";
196
+ rules: {
197
+ conditions: z.objectInputType<{
198
+ type: z.ZodString;
199
+ }, z.ZodTypeAny, "passthrough">[];
200
+ value?: unknown;
201
+ }[];
202
+ default?: unknown;
203
+ }>, z.ZodObject<{
204
+ type: z.ZodLiteral<"score">;
205
+ field: z.ZodString;
206
+ threshold: z.ZodNumber;
207
+ above: z.ZodUnknown;
208
+ below: z.ZodUnknown;
209
+ }, "strip", z.ZodTypeAny, {
210
+ type: "score";
211
+ field: string;
212
+ threshold: number;
213
+ above?: unknown;
214
+ below?: unknown;
215
+ }, {
216
+ type: "score";
217
+ field: string;
218
+ threshold: number;
219
+ above?: unknown;
220
+ below?: unknown;
221
+ }>, z.ZodObject<{
222
+ type: z.ZodLiteral<"model">;
223
+ modelId: z.ZodString;
224
+ inputs: z.ZodArray<z.ZodString, "many">;
225
+ outputMapping: z.ZodRecord<z.ZodString, z.ZodUnknown>;
226
+ default: z.ZodUnknown;
227
+ }, "strip", z.ZodTypeAny, {
228
+ type: "model";
229
+ modelId: string;
230
+ inputs: string[];
231
+ outputMapping: Record<string, unknown>;
232
+ default?: unknown;
233
+ }, {
234
+ type: "model";
235
+ modelId: string;
236
+ inputs: string[];
237
+ outputMapping: Record<string, unknown>;
238
+ default?: unknown;
239
+ }>, z.ZodObject<{
240
+ type: z.ZodLiteral<"external">;
241
+ endpoint: z.ZodString;
242
+ method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>;
243
+ default: z.ZodUnknown;
244
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
245
+ }, "strip", z.ZodTypeAny, {
246
+ type: "external";
247
+ endpoint: string;
248
+ default?: unknown;
249
+ method?: "GET" | "POST" | undefined;
250
+ timeoutMs?: number | undefined;
251
+ }, {
252
+ type: "external";
253
+ endpoint: string;
254
+ default?: unknown;
255
+ method?: "GET" | "POST" | undefined;
256
+ timeoutMs?: number | undefined;
257
+ }>]>>;
258
+ }, "strip", z.ZodTypeAny, {
259
+ routes: {
260
+ include?: string[] | undefined;
261
+ exclude?: string[] | undefined;
262
+ };
263
+ strategy?: {
264
+ type: "rules";
265
+ rules: {
266
+ conditions: z.objectOutputType<{
267
+ type: z.ZodString;
268
+ }, z.ZodTypeAny, "passthrough">[];
269
+ value?: unknown;
270
+ }[];
271
+ default?: unknown;
272
+ } | {
273
+ type: "score";
274
+ field: string;
275
+ threshold: number;
276
+ above?: unknown;
277
+ below?: unknown;
278
+ } | {
279
+ type: "model";
280
+ modelId: string;
281
+ inputs: string[];
282
+ outputMapping: Record<string, unknown>;
283
+ default?: unknown;
284
+ } | {
285
+ type: "external";
286
+ endpoint: string;
287
+ default?: unknown;
288
+ method?: "GET" | "POST" | undefined;
289
+ timeoutMs?: number | undefined;
290
+ } | undefined;
291
+ }, {
292
+ routes: {
293
+ include?: string[] | undefined;
294
+ exclude?: string[] | undefined;
295
+ };
296
+ strategy?: {
297
+ type: "rules";
298
+ rules: {
299
+ conditions: z.objectInputType<{
300
+ type: z.ZodString;
301
+ }, z.ZodTypeAny, "passthrough">[];
302
+ value?: unknown;
303
+ }[];
304
+ default?: unknown;
305
+ } | {
306
+ type: "score";
307
+ field: string;
308
+ threshold: number;
309
+ above?: unknown;
310
+ below?: unknown;
311
+ } | {
312
+ type: "model";
313
+ modelId: string;
314
+ inputs: string[];
315
+ outputMapping: Record<string, unknown>;
316
+ default?: unknown;
317
+ } | {
318
+ type: "external";
319
+ endpoint: string;
320
+ default?: unknown;
321
+ method?: "GET" | "POST" | undefined;
322
+ timeoutMs?: number | undefined;
323
+ } | undefined;
324
+ }>>;
150
325
  }, "strip", z.ZodTypeAny, {
151
326
  badgeId: string;
152
327
  kind: "gamification:awardBadge";
153
328
  anchorId?: string | undefined;
154
329
  label?: string | undefined;
330
+ activation?: {
331
+ routes: {
332
+ include?: string[] | undefined;
333
+ exclude?: string[] | undefined;
334
+ };
335
+ strategy?: {
336
+ type: "rules";
337
+ rules: {
338
+ conditions: z.objectOutputType<{
339
+ type: z.ZodString;
340
+ }, z.ZodTypeAny, "passthrough">[];
341
+ value?: unknown;
342
+ }[];
343
+ default?: unknown;
344
+ } | {
345
+ type: "score";
346
+ field: string;
347
+ threshold: number;
348
+ above?: unknown;
349
+ below?: unknown;
350
+ } | {
351
+ type: "model";
352
+ modelId: string;
353
+ inputs: string[];
354
+ outputMapping: Record<string, unknown>;
355
+ default?: unknown;
356
+ } | {
357
+ type: "external";
358
+ endpoint: string;
359
+ default?: unknown;
360
+ method?: "GET" | "POST" | undefined;
361
+ timeoutMs?: number | undefined;
362
+ } | undefined;
363
+ } | undefined;
155
364
  }, {
156
365
  badgeId: string;
157
366
  kind: "gamification:awardBadge";
158
367
  anchorId?: string | undefined;
159
368
  label?: string | undefined;
369
+ activation?: {
370
+ routes: {
371
+ include?: string[] | undefined;
372
+ exclude?: string[] | undefined;
373
+ };
374
+ strategy?: {
375
+ type: "rules";
376
+ rules: {
377
+ conditions: z.objectInputType<{
378
+ type: z.ZodString;
379
+ }, z.ZodTypeAny, "passthrough">[];
380
+ value?: unknown;
381
+ }[];
382
+ default?: unknown;
383
+ } | {
384
+ type: "score";
385
+ field: string;
386
+ threshold: number;
387
+ above?: unknown;
388
+ below?: unknown;
389
+ } | {
390
+ type: "model";
391
+ modelId: string;
392
+ inputs: string[];
393
+ outputMapping: Record<string, unknown>;
394
+ default?: unknown;
395
+ } | {
396
+ type: "external";
397
+ endpoint: string;
398
+ default?: unknown;
399
+ method?: "GET" | "POST" | undefined;
400
+ timeoutMs?: number | undefined;
401
+ } | undefined;
402
+ } | undefined;
160
403
  }>;
161
404
  /**
162
405
  * Schema for adding points to a user's score.
@@ -166,16 +409,259 @@ export declare const AddPointsSchema: z.ZodObject<{
166
409
  points: z.ZodNumber;
167
410
  reason: z.ZodOptional<z.ZodString>;
168
411
  label: z.ZodOptional<z.ZodString>;
412
+ } & {
413
+ activation: z.ZodOptional<z.ZodObject<{
414
+ routes: z.ZodObject<{
415
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
416
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
417
+ }, "strip", z.ZodTypeAny, {
418
+ include?: string[] | undefined;
419
+ exclude?: string[] | undefined;
420
+ }, {
421
+ include?: string[] | undefined;
422
+ exclude?: string[] | undefined;
423
+ }>;
424
+ strategy: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
425
+ type: z.ZodLiteral<"rules">;
426
+ rules: z.ZodArray<z.ZodObject<{
427
+ conditions: z.ZodArray<z.ZodObject<{
428
+ type: z.ZodString;
429
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
430
+ type: z.ZodString;
431
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
432
+ type: z.ZodString;
433
+ }, z.ZodTypeAny, "passthrough">>, "many">;
434
+ value: z.ZodUnknown;
435
+ }, "strip", z.ZodTypeAny, {
436
+ conditions: z.objectOutputType<{
437
+ type: z.ZodString;
438
+ }, z.ZodTypeAny, "passthrough">[];
439
+ value?: unknown;
440
+ }, {
441
+ conditions: z.objectInputType<{
442
+ type: z.ZodString;
443
+ }, z.ZodTypeAny, "passthrough">[];
444
+ value?: unknown;
445
+ }>, "many">;
446
+ default: z.ZodUnknown;
447
+ }, "strip", z.ZodTypeAny, {
448
+ type: "rules";
449
+ rules: {
450
+ conditions: z.objectOutputType<{
451
+ type: z.ZodString;
452
+ }, z.ZodTypeAny, "passthrough">[];
453
+ value?: unknown;
454
+ }[];
455
+ default?: unknown;
456
+ }, {
457
+ type: "rules";
458
+ rules: {
459
+ conditions: z.objectInputType<{
460
+ type: z.ZodString;
461
+ }, z.ZodTypeAny, "passthrough">[];
462
+ value?: unknown;
463
+ }[];
464
+ default?: unknown;
465
+ }>, z.ZodObject<{
466
+ type: z.ZodLiteral<"score">;
467
+ field: z.ZodString;
468
+ threshold: z.ZodNumber;
469
+ above: z.ZodUnknown;
470
+ below: z.ZodUnknown;
471
+ }, "strip", z.ZodTypeAny, {
472
+ type: "score";
473
+ field: string;
474
+ threshold: number;
475
+ above?: unknown;
476
+ below?: unknown;
477
+ }, {
478
+ type: "score";
479
+ field: string;
480
+ threshold: number;
481
+ above?: unknown;
482
+ below?: unknown;
483
+ }>, z.ZodObject<{
484
+ type: z.ZodLiteral<"model">;
485
+ modelId: z.ZodString;
486
+ inputs: z.ZodArray<z.ZodString, "many">;
487
+ outputMapping: z.ZodRecord<z.ZodString, z.ZodUnknown>;
488
+ default: z.ZodUnknown;
489
+ }, "strip", z.ZodTypeAny, {
490
+ type: "model";
491
+ modelId: string;
492
+ inputs: string[];
493
+ outputMapping: Record<string, unknown>;
494
+ default?: unknown;
495
+ }, {
496
+ type: "model";
497
+ modelId: string;
498
+ inputs: string[];
499
+ outputMapping: Record<string, unknown>;
500
+ default?: unknown;
501
+ }>, z.ZodObject<{
502
+ type: z.ZodLiteral<"external">;
503
+ endpoint: z.ZodString;
504
+ method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>;
505
+ default: z.ZodUnknown;
506
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
507
+ }, "strip", z.ZodTypeAny, {
508
+ type: "external";
509
+ endpoint: string;
510
+ default?: unknown;
511
+ method?: "GET" | "POST" | undefined;
512
+ timeoutMs?: number | undefined;
513
+ }, {
514
+ type: "external";
515
+ endpoint: string;
516
+ default?: unknown;
517
+ method?: "GET" | "POST" | undefined;
518
+ timeoutMs?: number | undefined;
519
+ }>]>>;
520
+ }, "strip", z.ZodTypeAny, {
521
+ routes: {
522
+ include?: string[] | undefined;
523
+ exclude?: string[] | undefined;
524
+ };
525
+ strategy?: {
526
+ type: "rules";
527
+ rules: {
528
+ conditions: z.objectOutputType<{
529
+ type: z.ZodString;
530
+ }, z.ZodTypeAny, "passthrough">[];
531
+ value?: unknown;
532
+ }[];
533
+ default?: unknown;
534
+ } | {
535
+ type: "score";
536
+ field: string;
537
+ threshold: number;
538
+ above?: unknown;
539
+ below?: unknown;
540
+ } | {
541
+ type: "model";
542
+ modelId: string;
543
+ inputs: string[];
544
+ outputMapping: Record<string, unknown>;
545
+ default?: unknown;
546
+ } | {
547
+ type: "external";
548
+ endpoint: string;
549
+ default?: unknown;
550
+ method?: "GET" | "POST" | undefined;
551
+ timeoutMs?: number | undefined;
552
+ } | undefined;
553
+ }, {
554
+ routes: {
555
+ include?: string[] | undefined;
556
+ exclude?: string[] | undefined;
557
+ };
558
+ strategy?: {
559
+ type: "rules";
560
+ rules: {
561
+ conditions: z.objectInputType<{
562
+ type: z.ZodString;
563
+ }, z.ZodTypeAny, "passthrough">[];
564
+ value?: unknown;
565
+ }[];
566
+ default?: unknown;
567
+ } | {
568
+ type: "score";
569
+ field: string;
570
+ threshold: number;
571
+ above?: unknown;
572
+ below?: unknown;
573
+ } | {
574
+ type: "model";
575
+ modelId: string;
576
+ inputs: string[];
577
+ outputMapping: Record<string, unknown>;
578
+ default?: unknown;
579
+ } | {
580
+ type: "external";
581
+ endpoint: string;
582
+ default?: unknown;
583
+ method?: "GET" | "POST" | undefined;
584
+ timeoutMs?: number | undefined;
585
+ } | undefined;
586
+ }>>;
169
587
  }, "strip", z.ZodTypeAny, {
170
588
  points: number;
171
589
  kind: "gamification:addPoints";
172
590
  reason?: string | undefined;
173
591
  label?: string | undefined;
592
+ activation?: {
593
+ routes: {
594
+ include?: string[] | undefined;
595
+ exclude?: string[] | undefined;
596
+ };
597
+ strategy?: {
598
+ type: "rules";
599
+ rules: {
600
+ conditions: z.objectOutputType<{
601
+ type: z.ZodString;
602
+ }, z.ZodTypeAny, "passthrough">[];
603
+ value?: unknown;
604
+ }[];
605
+ default?: unknown;
606
+ } | {
607
+ type: "score";
608
+ field: string;
609
+ threshold: number;
610
+ above?: unknown;
611
+ below?: unknown;
612
+ } | {
613
+ type: "model";
614
+ modelId: string;
615
+ inputs: string[];
616
+ outputMapping: Record<string, unknown>;
617
+ default?: unknown;
618
+ } | {
619
+ type: "external";
620
+ endpoint: string;
621
+ default?: unknown;
622
+ method?: "GET" | "POST" | undefined;
623
+ timeoutMs?: number | undefined;
624
+ } | undefined;
625
+ } | undefined;
174
626
  }, {
175
627
  points: number;
176
628
  kind: "gamification:addPoints";
177
629
  reason?: string | undefined;
178
630
  label?: string | undefined;
631
+ activation?: {
632
+ routes: {
633
+ include?: string[] | undefined;
634
+ exclude?: string[] | undefined;
635
+ };
636
+ strategy?: {
637
+ type: "rules";
638
+ rules: {
639
+ conditions: z.objectInputType<{
640
+ type: z.ZodString;
641
+ }, z.ZodTypeAny, "passthrough">[];
642
+ value?: unknown;
643
+ }[];
644
+ default?: unknown;
645
+ } | {
646
+ type: "score";
647
+ field: string;
648
+ threshold: number;
649
+ above?: unknown;
650
+ below?: unknown;
651
+ } | {
652
+ type: "model";
653
+ modelId: string;
654
+ inputs: string[];
655
+ outputMapping: Record<string, unknown>;
656
+ default?: unknown;
657
+ } | {
658
+ type: "external";
659
+ endpoint: string;
660
+ default?: unknown;
661
+ method?: "GET" | "POST" | undefined;
662
+ timeoutMs?: number | undefined;
663
+ } | undefined;
664
+ } | undefined;
179
665
  }>;
180
666
  /**
181
667
  * Action step schemas for unified JSON Schema generation.
@@ -189,16 +675,259 @@ export declare const actionStepSchemas: ({
189
675
  badgeId: z.ZodString;
190
676
  anchorId: z.ZodOptional<z.ZodString>;
191
677
  label: z.ZodOptional<z.ZodString>;
678
+ } & {
679
+ activation: z.ZodOptional<z.ZodObject<{
680
+ routes: z.ZodObject<{
681
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
682
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
683
+ }, "strip", z.ZodTypeAny, {
684
+ include?: string[] | undefined;
685
+ exclude?: string[] | undefined;
686
+ }, {
687
+ include?: string[] | undefined;
688
+ exclude?: string[] | undefined;
689
+ }>;
690
+ strategy: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
691
+ type: z.ZodLiteral<"rules">;
692
+ rules: z.ZodArray<z.ZodObject<{
693
+ conditions: z.ZodArray<z.ZodObject<{
694
+ type: z.ZodString;
695
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
696
+ type: z.ZodString;
697
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
698
+ type: z.ZodString;
699
+ }, z.ZodTypeAny, "passthrough">>, "many">;
700
+ value: z.ZodUnknown;
701
+ }, "strip", z.ZodTypeAny, {
702
+ conditions: z.objectOutputType<{
703
+ type: z.ZodString;
704
+ }, z.ZodTypeAny, "passthrough">[];
705
+ value?: unknown;
706
+ }, {
707
+ conditions: z.objectInputType<{
708
+ type: z.ZodString;
709
+ }, z.ZodTypeAny, "passthrough">[];
710
+ value?: unknown;
711
+ }>, "many">;
712
+ default: z.ZodUnknown;
713
+ }, "strip", z.ZodTypeAny, {
714
+ type: "rules";
715
+ rules: {
716
+ conditions: z.objectOutputType<{
717
+ type: z.ZodString;
718
+ }, z.ZodTypeAny, "passthrough">[];
719
+ value?: unknown;
720
+ }[];
721
+ default?: unknown;
722
+ }, {
723
+ type: "rules";
724
+ rules: {
725
+ conditions: z.objectInputType<{
726
+ type: z.ZodString;
727
+ }, z.ZodTypeAny, "passthrough">[];
728
+ value?: unknown;
729
+ }[];
730
+ default?: unknown;
731
+ }>, z.ZodObject<{
732
+ type: z.ZodLiteral<"score">;
733
+ field: z.ZodString;
734
+ threshold: z.ZodNumber;
735
+ above: z.ZodUnknown;
736
+ below: z.ZodUnknown;
737
+ }, "strip", z.ZodTypeAny, {
738
+ type: "score";
739
+ field: string;
740
+ threshold: number;
741
+ above?: unknown;
742
+ below?: unknown;
743
+ }, {
744
+ type: "score";
745
+ field: string;
746
+ threshold: number;
747
+ above?: unknown;
748
+ below?: unknown;
749
+ }>, z.ZodObject<{
750
+ type: z.ZodLiteral<"model">;
751
+ modelId: z.ZodString;
752
+ inputs: z.ZodArray<z.ZodString, "many">;
753
+ outputMapping: z.ZodRecord<z.ZodString, z.ZodUnknown>;
754
+ default: z.ZodUnknown;
755
+ }, "strip", z.ZodTypeAny, {
756
+ type: "model";
757
+ modelId: string;
758
+ inputs: string[];
759
+ outputMapping: Record<string, unknown>;
760
+ default?: unknown;
761
+ }, {
762
+ type: "model";
763
+ modelId: string;
764
+ inputs: string[];
765
+ outputMapping: Record<string, unknown>;
766
+ default?: unknown;
767
+ }>, z.ZodObject<{
768
+ type: z.ZodLiteral<"external">;
769
+ endpoint: z.ZodString;
770
+ method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>;
771
+ default: z.ZodUnknown;
772
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
773
+ }, "strip", z.ZodTypeAny, {
774
+ type: "external";
775
+ endpoint: string;
776
+ default?: unknown;
777
+ method?: "GET" | "POST" | undefined;
778
+ timeoutMs?: number | undefined;
779
+ }, {
780
+ type: "external";
781
+ endpoint: string;
782
+ default?: unknown;
783
+ method?: "GET" | "POST" | undefined;
784
+ timeoutMs?: number | undefined;
785
+ }>]>>;
786
+ }, "strip", z.ZodTypeAny, {
787
+ routes: {
788
+ include?: string[] | undefined;
789
+ exclude?: string[] | undefined;
790
+ };
791
+ strategy?: {
792
+ type: "rules";
793
+ rules: {
794
+ conditions: z.objectOutputType<{
795
+ type: z.ZodString;
796
+ }, z.ZodTypeAny, "passthrough">[];
797
+ value?: unknown;
798
+ }[];
799
+ default?: unknown;
800
+ } | {
801
+ type: "score";
802
+ field: string;
803
+ threshold: number;
804
+ above?: unknown;
805
+ below?: unknown;
806
+ } | {
807
+ type: "model";
808
+ modelId: string;
809
+ inputs: string[];
810
+ outputMapping: Record<string, unknown>;
811
+ default?: unknown;
812
+ } | {
813
+ type: "external";
814
+ endpoint: string;
815
+ default?: unknown;
816
+ method?: "GET" | "POST" | undefined;
817
+ timeoutMs?: number | undefined;
818
+ } | undefined;
819
+ }, {
820
+ routes: {
821
+ include?: string[] | undefined;
822
+ exclude?: string[] | undefined;
823
+ };
824
+ strategy?: {
825
+ type: "rules";
826
+ rules: {
827
+ conditions: z.objectInputType<{
828
+ type: z.ZodString;
829
+ }, z.ZodTypeAny, "passthrough">[];
830
+ value?: unknown;
831
+ }[];
832
+ default?: unknown;
833
+ } | {
834
+ type: "score";
835
+ field: string;
836
+ threshold: number;
837
+ above?: unknown;
838
+ below?: unknown;
839
+ } | {
840
+ type: "model";
841
+ modelId: string;
842
+ inputs: string[];
843
+ outputMapping: Record<string, unknown>;
844
+ default?: unknown;
845
+ } | {
846
+ type: "external";
847
+ endpoint: string;
848
+ default?: unknown;
849
+ method?: "GET" | "POST" | undefined;
850
+ timeoutMs?: number | undefined;
851
+ } | undefined;
852
+ }>>;
192
853
  }, "strip", z.ZodTypeAny, {
193
854
  badgeId: string;
194
855
  kind: "gamification:awardBadge";
195
856
  anchorId?: string | undefined;
196
857
  label?: string | undefined;
858
+ activation?: {
859
+ routes: {
860
+ include?: string[] | undefined;
861
+ exclude?: string[] | undefined;
862
+ };
863
+ strategy?: {
864
+ type: "rules";
865
+ rules: {
866
+ conditions: z.objectOutputType<{
867
+ type: z.ZodString;
868
+ }, z.ZodTypeAny, "passthrough">[];
869
+ value?: unknown;
870
+ }[];
871
+ default?: unknown;
872
+ } | {
873
+ type: "score";
874
+ field: string;
875
+ threshold: number;
876
+ above?: unknown;
877
+ below?: unknown;
878
+ } | {
879
+ type: "model";
880
+ modelId: string;
881
+ inputs: string[];
882
+ outputMapping: Record<string, unknown>;
883
+ default?: unknown;
884
+ } | {
885
+ type: "external";
886
+ endpoint: string;
887
+ default?: unknown;
888
+ method?: "GET" | "POST" | undefined;
889
+ timeoutMs?: number | undefined;
890
+ } | undefined;
891
+ } | undefined;
197
892
  }, {
198
893
  badgeId: string;
199
894
  kind: "gamification:awardBadge";
200
895
  anchorId?: string | undefined;
201
896
  label?: string | undefined;
897
+ activation?: {
898
+ routes: {
899
+ include?: string[] | undefined;
900
+ exclude?: string[] | undefined;
901
+ };
902
+ strategy?: {
903
+ type: "rules";
904
+ rules: {
905
+ conditions: z.objectInputType<{
906
+ type: z.ZodString;
907
+ }, z.ZodTypeAny, "passthrough">[];
908
+ value?: unknown;
909
+ }[];
910
+ default?: unknown;
911
+ } | {
912
+ type: "score";
913
+ field: string;
914
+ threshold: number;
915
+ above?: unknown;
916
+ below?: unknown;
917
+ } | {
918
+ type: "model";
919
+ modelId: string;
920
+ inputs: string[];
921
+ outputMapping: Record<string, unknown>;
922
+ default?: unknown;
923
+ } | {
924
+ type: "external";
925
+ endpoint: string;
926
+ default?: unknown;
927
+ method?: "GET" | "POST" | undefined;
928
+ timeoutMs?: number | undefined;
929
+ } | undefined;
930
+ } | undefined;
202
931
  }>;
203
932
  } | {
204
933
  defName: string;
@@ -207,16 +936,259 @@ export declare const actionStepSchemas: ({
207
936
  points: z.ZodNumber;
208
937
  reason: z.ZodOptional<z.ZodString>;
209
938
  label: z.ZodOptional<z.ZodString>;
939
+ } & {
940
+ activation: z.ZodOptional<z.ZodObject<{
941
+ routes: z.ZodObject<{
942
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
943
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
944
+ }, "strip", z.ZodTypeAny, {
945
+ include?: string[] | undefined;
946
+ exclude?: string[] | undefined;
947
+ }, {
948
+ include?: string[] | undefined;
949
+ exclude?: string[] | undefined;
950
+ }>;
951
+ strategy: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
952
+ type: z.ZodLiteral<"rules">;
953
+ rules: z.ZodArray<z.ZodObject<{
954
+ conditions: z.ZodArray<z.ZodObject<{
955
+ type: z.ZodString;
956
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
957
+ type: z.ZodString;
958
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
959
+ type: z.ZodString;
960
+ }, z.ZodTypeAny, "passthrough">>, "many">;
961
+ value: z.ZodUnknown;
962
+ }, "strip", z.ZodTypeAny, {
963
+ conditions: z.objectOutputType<{
964
+ type: z.ZodString;
965
+ }, z.ZodTypeAny, "passthrough">[];
966
+ value?: unknown;
967
+ }, {
968
+ conditions: z.objectInputType<{
969
+ type: z.ZodString;
970
+ }, z.ZodTypeAny, "passthrough">[];
971
+ value?: unknown;
972
+ }>, "many">;
973
+ default: z.ZodUnknown;
974
+ }, "strip", z.ZodTypeAny, {
975
+ type: "rules";
976
+ rules: {
977
+ conditions: z.objectOutputType<{
978
+ type: z.ZodString;
979
+ }, z.ZodTypeAny, "passthrough">[];
980
+ value?: unknown;
981
+ }[];
982
+ default?: unknown;
983
+ }, {
984
+ type: "rules";
985
+ rules: {
986
+ conditions: z.objectInputType<{
987
+ type: z.ZodString;
988
+ }, z.ZodTypeAny, "passthrough">[];
989
+ value?: unknown;
990
+ }[];
991
+ default?: unknown;
992
+ }>, z.ZodObject<{
993
+ type: z.ZodLiteral<"score">;
994
+ field: z.ZodString;
995
+ threshold: z.ZodNumber;
996
+ above: z.ZodUnknown;
997
+ below: z.ZodUnknown;
998
+ }, "strip", z.ZodTypeAny, {
999
+ type: "score";
1000
+ field: string;
1001
+ threshold: number;
1002
+ above?: unknown;
1003
+ below?: unknown;
1004
+ }, {
1005
+ type: "score";
1006
+ field: string;
1007
+ threshold: number;
1008
+ above?: unknown;
1009
+ below?: unknown;
1010
+ }>, z.ZodObject<{
1011
+ type: z.ZodLiteral<"model">;
1012
+ modelId: z.ZodString;
1013
+ inputs: z.ZodArray<z.ZodString, "many">;
1014
+ outputMapping: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1015
+ default: z.ZodUnknown;
1016
+ }, "strip", z.ZodTypeAny, {
1017
+ type: "model";
1018
+ modelId: string;
1019
+ inputs: string[];
1020
+ outputMapping: Record<string, unknown>;
1021
+ default?: unknown;
1022
+ }, {
1023
+ type: "model";
1024
+ modelId: string;
1025
+ inputs: string[];
1026
+ outputMapping: Record<string, unknown>;
1027
+ default?: unknown;
1028
+ }>, z.ZodObject<{
1029
+ type: z.ZodLiteral<"external">;
1030
+ endpoint: z.ZodString;
1031
+ method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>;
1032
+ default: z.ZodUnknown;
1033
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
1034
+ }, "strip", z.ZodTypeAny, {
1035
+ type: "external";
1036
+ endpoint: string;
1037
+ default?: unknown;
1038
+ method?: "GET" | "POST" | undefined;
1039
+ timeoutMs?: number | undefined;
1040
+ }, {
1041
+ type: "external";
1042
+ endpoint: string;
1043
+ default?: unknown;
1044
+ method?: "GET" | "POST" | undefined;
1045
+ timeoutMs?: number | undefined;
1046
+ }>]>>;
1047
+ }, "strip", z.ZodTypeAny, {
1048
+ routes: {
1049
+ include?: string[] | undefined;
1050
+ exclude?: string[] | undefined;
1051
+ };
1052
+ strategy?: {
1053
+ type: "rules";
1054
+ rules: {
1055
+ conditions: z.objectOutputType<{
1056
+ type: z.ZodString;
1057
+ }, z.ZodTypeAny, "passthrough">[];
1058
+ value?: unknown;
1059
+ }[];
1060
+ default?: unknown;
1061
+ } | {
1062
+ type: "score";
1063
+ field: string;
1064
+ threshold: number;
1065
+ above?: unknown;
1066
+ below?: unknown;
1067
+ } | {
1068
+ type: "model";
1069
+ modelId: string;
1070
+ inputs: string[];
1071
+ outputMapping: Record<string, unknown>;
1072
+ default?: unknown;
1073
+ } | {
1074
+ type: "external";
1075
+ endpoint: string;
1076
+ default?: unknown;
1077
+ method?: "GET" | "POST" | undefined;
1078
+ timeoutMs?: number | undefined;
1079
+ } | undefined;
1080
+ }, {
1081
+ routes: {
1082
+ include?: string[] | undefined;
1083
+ exclude?: string[] | undefined;
1084
+ };
1085
+ strategy?: {
1086
+ type: "rules";
1087
+ rules: {
1088
+ conditions: z.objectInputType<{
1089
+ type: z.ZodString;
1090
+ }, z.ZodTypeAny, "passthrough">[];
1091
+ value?: unknown;
1092
+ }[];
1093
+ default?: unknown;
1094
+ } | {
1095
+ type: "score";
1096
+ field: string;
1097
+ threshold: number;
1098
+ above?: unknown;
1099
+ below?: unknown;
1100
+ } | {
1101
+ type: "model";
1102
+ modelId: string;
1103
+ inputs: string[];
1104
+ outputMapping: Record<string, unknown>;
1105
+ default?: unknown;
1106
+ } | {
1107
+ type: "external";
1108
+ endpoint: string;
1109
+ default?: unknown;
1110
+ method?: "GET" | "POST" | undefined;
1111
+ timeoutMs?: number | undefined;
1112
+ } | undefined;
1113
+ }>>;
210
1114
  }, "strip", z.ZodTypeAny, {
211
1115
  points: number;
212
1116
  kind: "gamification:addPoints";
213
1117
  reason?: string | undefined;
214
1118
  label?: string | undefined;
1119
+ activation?: {
1120
+ routes: {
1121
+ include?: string[] | undefined;
1122
+ exclude?: string[] | undefined;
1123
+ };
1124
+ strategy?: {
1125
+ type: "rules";
1126
+ rules: {
1127
+ conditions: z.objectOutputType<{
1128
+ type: z.ZodString;
1129
+ }, z.ZodTypeAny, "passthrough">[];
1130
+ value?: unknown;
1131
+ }[];
1132
+ default?: unknown;
1133
+ } | {
1134
+ type: "score";
1135
+ field: string;
1136
+ threshold: number;
1137
+ above?: unknown;
1138
+ below?: unknown;
1139
+ } | {
1140
+ type: "model";
1141
+ modelId: string;
1142
+ inputs: string[];
1143
+ outputMapping: Record<string, unknown>;
1144
+ default?: unknown;
1145
+ } | {
1146
+ type: "external";
1147
+ endpoint: string;
1148
+ default?: unknown;
1149
+ method?: "GET" | "POST" | undefined;
1150
+ timeoutMs?: number | undefined;
1151
+ } | undefined;
1152
+ } | undefined;
215
1153
  }, {
216
1154
  points: number;
217
1155
  kind: "gamification:addPoints";
218
1156
  reason?: string | undefined;
219
1157
  label?: string | undefined;
1158
+ activation?: {
1159
+ routes: {
1160
+ include?: string[] | undefined;
1161
+ exclude?: string[] | undefined;
1162
+ };
1163
+ strategy?: {
1164
+ type: "rules";
1165
+ rules: {
1166
+ conditions: z.objectInputType<{
1167
+ type: z.ZodString;
1168
+ }, z.ZodTypeAny, "passthrough">[];
1169
+ value?: unknown;
1170
+ }[];
1171
+ default?: unknown;
1172
+ } | {
1173
+ type: "score";
1174
+ field: string;
1175
+ threshold: number;
1176
+ above?: unknown;
1177
+ below?: unknown;
1178
+ } | {
1179
+ type: "model";
1180
+ modelId: string;
1181
+ inputs: string[];
1182
+ outputMapping: Record<string, unknown>;
1183
+ default?: unknown;
1184
+ } | {
1185
+ type: "external";
1186
+ endpoint: string;
1187
+ default?: unknown;
1188
+ method?: "GET" | "POST" | undefined;
1189
+ timeoutMs?: number | undefined;
1190
+ } | undefined;
1191
+ } | undefined;
220
1192
  }>;
221
1193
  })[];
222
1194
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAStB,CAAC;AAUH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASvB,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAM9D;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAK1B,CAAC;AAMH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAG7B,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuExB;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAStB,CAAC;AAUH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASvB,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAM9D;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOD,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAC;AAM7B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAG7B,CAAC"}
package/dist/schema.js CHANGED
@@ -4,6 +4,63 @@
4
4
  * Zod schema for validating gamification app configuration.
5
5
  */
6
6
  import { z } from 'zod';
7
+ // ============================================================================
8
+ // Decision Strategy Schema (simplified for this package)
9
+ // ============================================================================
10
+ const ConditionZ = z
11
+ .object({
12
+ type: z.string(),
13
+ })
14
+ .passthrough();
15
+ const RuleZ = z.object({
16
+ conditions: z.array(ConditionZ),
17
+ value: z.unknown(),
18
+ });
19
+ const RuleStrategyZ = z.object({
20
+ type: z.literal('rules'),
21
+ rules: z.array(RuleZ),
22
+ default: z.unknown(),
23
+ });
24
+ const ScoreStrategyZ = z.object({
25
+ type: z.literal('score'),
26
+ field: z.string(),
27
+ threshold: z.number(),
28
+ above: z.unknown(),
29
+ below: z.unknown(),
30
+ });
31
+ const ModelStrategyZ = z.object({
32
+ type: z.literal('model'),
33
+ modelId: z.string(),
34
+ inputs: z.array(z.string()),
35
+ outputMapping: z.record(z.unknown()),
36
+ default: z.unknown(),
37
+ });
38
+ const ExternalStrategyZ = z.object({
39
+ type: z.literal('external'),
40
+ endpoint: z.string(),
41
+ method: z.enum(['GET', 'POST']).optional(),
42
+ default: z.unknown(),
43
+ timeoutMs: z.number().optional(),
44
+ });
45
+ const DecisionStrategyZ = z.discriminatedUnion('type', [
46
+ RuleStrategyZ,
47
+ ScoreStrategyZ,
48
+ ModelStrategyZ,
49
+ ExternalStrategyZ,
50
+ ]);
51
+ // ============================================================================
52
+ // Activation Config Schema
53
+ // ============================================================================
54
+ const RouteFilterZ = z.object({
55
+ include: z.array(z.string()).optional(),
56
+ exclude: z.array(z.string()).optional(),
57
+ });
58
+ const ActivationConfigZ = z.object({
59
+ routes: RouteFilterZ,
60
+ strategy: DecisionStrategyZ.optional(),
61
+ });
62
+ /** Optional activation config — every action can declare its own route scoping */
63
+ const ActionActivationZ = { activation: ActivationConfigZ.optional() };
7
64
  /**
8
65
  * Badge definition schema.
9
66
  */
@@ -43,21 +100,25 @@ export const configSchema = z.object({
43
100
  /**
44
101
  * Schema for awarding a badge to a user.
45
102
  */
46
- export const AwardBadgeSchema = z.object({
103
+ export const AwardBadgeSchema = z
104
+ .object({
47
105
  kind: z.literal('gamification:awardBadge'),
48
106
  badgeId: z.string(),
49
107
  anchorId: z.string().optional(),
50
108
  label: z.string().optional(),
51
- });
109
+ })
110
+ .extend(ActionActivationZ);
52
111
  /**
53
112
  * Schema for adding points to a user's score.
54
113
  */
55
- export const AddPointsSchema = z.object({
114
+ export const AddPointsSchema = z
115
+ .object({
56
116
  kind: z.literal('gamification:addPoints'),
57
117
  points: z.number(),
58
118
  reason: z.string().optional(),
59
119
  label: z.string().optional(),
60
- });
120
+ })
121
+ .extend(ActionActivationZ);
61
122
  // ============================================================================
62
123
  // Unified Schema Export
63
124
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntrologie/adapt-gamification",
3
- "version": "2.3.0",
3
+ "version": "2.4.0-canary.10",
4
4
  "description": "Adaptive Gamification app - Badges, rewards, points, and engagement mechanics",
5
5
  "license": "Proprietary",
6
6
  "private": false,
@@ -31,7 +31,9 @@
31
31
  "files": [
32
32
  "dist"
33
33
  ],
34
+ "bundledDependencies": [],
34
35
  "scripts": {
36
+ "prepack": "node ../../../scripts/prepare-bundled-deps.mjs",
35
37
  "build": "tsc",
36
38
  "typecheck": "tsc --noEmit",
37
39
  "clean": "rm -rf dist",
@@ -43,7 +45,9 @@
43
45
  "react-dom": ">=18.0.0",
44
46
  "zod": "^3.0.0"
45
47
  },
48
+ "dependencies": {},
46
49
  "devDependencies": {
50
+ "@syntrologie/sdk-contracts": "*",
47
51
  "@testing-library/react": "^16.3.2",
48
52
  "@types/react": "^19.2.0",
49
53
  "jsdom": "^26.1.0",
@@ -52,8 +56,5 @@
52
56
  "typescript": "^5.9.3",
53
57
  "vitest": "^4.0.18",
54
58
  "zod": "^3.25.76"
55
- },
56
- "dependencies": {
57
- "@syntrologie/sdk-contracts": "*"
58
59
  }
59
60
  }