@syntrologie/adapt-gamification 2.4.0-canary.2 → 2.4.0-canary.20

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.
@@ -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,k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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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/dist/types.d.ts CHANGED
@@ -4,16 +4,6 @@
4
4
  * Minimal type definitions for building this app independently.
5
5
  * These match the types exported from @syntrologie/runtime-sdk/types.
6
6
  */
7
- export interface EditorPanelProps {
8
- config: Record<string, unknown>;
9
- onChange: (config: Record<string, unknown>) => void;
10
- editor: {
11
- setDirty: (dirty: boolean) => void;
12
- navigateHome: () => Promise<boolean>;
13
- save: () => Promise<void>;
14
- publish: (captureScreenshot?: boolean) => Promise<void>;
15
- };
16
- platformClient?: unknown;
17
- }
7
+ export type { EditorPanelProps } from '@syntrologie/sdk-contracts';
18
8
  export type { ActionExecutor, ExecutorCleanup, ExecutorContext, ExecutorResult, ExecutorUpdate, } from '@syntrologie/sdk-contracts';
19
9
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QACnC,YAAY,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,OAAO,EAAE,CAAC,iBAAiB,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACzD,CAAC;IACF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAMD,YAAY,EACV,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAMnE,YAAY,EACV,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntrologie/adapt-gamification",
3
- "version": "2.4.0-canary.2",
3
+ "version": "2.4.0-canary.20",
4
4
  "description": "Adaptive Gamification app - Badges, rewards, points, and engagement mechanics",
5
5
  "license": "Proprietary",
6
6
  "private": false,
@@ -31,9 +31,7 @@
31
31
  "files": [
32
32
  "dist"
33
33
  ],
34
- "bundledDependencies": [
35
- "@syntrologie/sdk-contracts"
36
- ],
34
+ "bundledDependencies": [],
37
35
  "scripts": {
38
36
  "prepack": "node ../../../scripts/prepare-bundled-deps.mjs",
39
37
  "build": "tsc",
@@ -47,10 +45,9 @@
47
45
  "react-dom": ">=18.0.0",
48
46
  "zod": "^3.0.0"
49
47
  },
50
- "dependencies": {
51
- "@syntrologie/sdk-contracts": "*"
52
- },
48
+ "dependencies": {},
53
49
  "devDependencies": {
50
+ "@syntrologie/sdk-contracts": "*",
54
51
  "@testing-library/react": "^16.3.2",
55
52
  "@types/react": "^19.2.0",
56
53
  "jsdom": "^26.1.0",
@@ -1,26 +0,0 @@
1
- /**
2
- * @syntrologie/sdk-contracts
3
- *
4
- * Shared TypeScript contracts between runtime-sdk and adaptive packages.
5
- * Executor types + shared Zod schemas for decision strategies and conditions.
6
- */
7
- export { AnchorVisibleConditionZ, type ConditionSchema, ConditionZ, CooldownActiveConditionZ, type DecisionStrategySchema, DecisionStrategyZ, DismissedConditionZ, EventCountConditionZ, EventOccurredConditionZ, type EventScopeSchema, EventScopeZ, ExternalStrategyZ, FrequencyLimitConditionZ, ModelStrategyZ, NotifyZ, PageUrlConditionZ, RouteConditionZ, type RuleSchema, RuleStrategyZ, RuleZ, ScoreStrategyZ, SessionMetricConditionZ, StateEqualsConditionZ, ViewportConditionZ, } from './schemas.js';
8
- /** Cleanup function returned by executors */
9
- export type ExecutorCleanup = () => void | Promise<void>;
10
- /** Update function for actions that support in-place updates */
11
- export type ExecutorUpdate = (changes: Record<string, unknown>) => void | Promise<void>;
12
- /** Result returned by action executors */
13
- export interface ExecutorResult {
14
- cleanup: ExecutorCleanup;
15
- updateFn?: ExecutorUpdate;
16
- }
17
- /** Context passed to action executors by the runtime */
18
- export interface ExecutorContext {
19
- overlayRoot: HTMLElement;
20
- resolveAnchor: (anchorId: string) => HTMLElement | null;
21
- generateId: () => string;
22
- publishEvent: (name: string, props?: Record<string, unknown>) => void;
23
- adaptiveId?: string;
24
- }
25
- /** Executor function signature */
26
- export type ActionExecutor<T = unknown> = (action: T, context: ExecutorContext) => Promise<ExecutorResult>;
@@ -1,13 +0,0 @@
1
- /**
2
- * @syntrologie/sdk-contracts
3
- *
4
- * Shared TypeScript contracts between runtime-sdk and adaptive packages.
5
- * Executor types + shared Zod schemas for decision strategies and conditions.
6
- */
7
- export { AnchorVisibleConditionZ, ConditionZ, CooldownActiveConditionZ, DecisionStrategyZ, DismissedConditionZ, EventCountConditionZ, EventOccurredConditionZ,
8
- // Shared schemas
9
- EventScopeZ, ExternalStrategyZ, FrequencyLimitConditionZ, ModelStrategyZ, NotifyZ,
10
- // Condition schemas
11
- PageUrlConditionZ, RouteConditionZ, RuleStrategyZ,
12
- // Strategy schemas
13
- RuleZ, ScoreStrategyZ, SessionMetricConditionZ, StateEqualsConditionZ, ViewportConditionZ, } from './schemas.js';