@contractspec/example.learning-journey-studio-onboarding 0.0.0-canary-20260113162409

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 (56) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +45 -0
  2. package/.turbo/turbo-build.log +46 -0
  3. package/CHANGELOG.md +330 -0
  4. package/LICENSE +21 -0
  5. package/README.md +41 -0
  6. package/dist/docs/index.d.ts +1 -0
  7. package/dist/docs/index.js +1 -0
  8. package/dist/docs/studio-onboarding.docblock.d.ts +1 -0
  9. package/dist/docs/studio-onboarding.docblock.js +40 -0
  10. package/dist/docs/studio-onboarding.docblock.js.map +1 -0
  11. package/dist/example.d.ts +7 -0
  12. package/dist/example.d.ts.map +1 -0
  13. package/dist/example.js +42 -0
  14. package/dist/example.js.map +1 -0
  15. package/dist/handlers/demo.handlers.d.ts +23 -0
  16. package/dist/handlers/demo.handlers.d.ts.map +1 -0
  17. package/dist/handlers/demo.handlers.js +24 -0
  18. package/dist/handlers/demo.handlers.js.map +1 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +9 -0
  21. package/dist/learning-journey-studio-onboarding.feature.d.ts +12 -0
  22. package/dist/learning-journey-studio-onboarding.feature.d.ts.map +1 -0
  23. package/dist/learning-journey-studio-onboarding.feature.js +75 -0
  24. package/dist/learning-journey-studio-onboarding.feature.js.map +1 -0
  25. package/dist/operations/index.d.ts +271 -0
  26. package/dist/operations/index.d.ts.map +1 -0
  27. package/dist/operations/index.js +176 -0
  28. package/dist/operations/index.js.map +1 -0
  29. package/dist/presentations/index.d.ts +9 -0
  30. package/dist/presentations/index.d.ts.map +1 -0
  31. package/dist/presentations/index.js +57 -0
  32. package/dist/presentations/index.js.map +1 -0
  33. package/dist/tests/operations.test-spec.d.ts +7 -0
  34. package/dist/tests/operations.test-spec.d.ts.map +1 -0
  35. package/dist/tests/operations.test-spec.js +36 -0
  36. package/dist/tests/operations.test-spec.js.map +1 -0
  37. package/dist/track.d.ts +8 -0
  38. package/dist/track.d.ts.map +1 -0
  39. package/dist/track.js +91 -0
  40. package/dist/track.js.map +1 -0
  41. package/example.ts +1 -0
  42. package/package.json +66 -0
  43. package/src/docs/index.ts +1 -0
  44. package/src/docs/studio-onboarding.docblock.ts +38 -0
  45. package/src/example.ts +31 -0
  46. package/src/handlers/demo.handlers.ts +48 -0
  47. package/src/index.ts +7 -0
  48. package/src/learning-journey-studio-onboarding.feature.ts +69 -0
  49. package/src/operations/index.test.ts +49 -0
  50. package/src/operations/index.ts +122 -0
  51. package/src/presentations/index.ts +57 -0
  52. package/src/tests/operations.test-spec.ts +31 -0
  53. package/src/track.ts +86 -0
  54. package/tsconfig.json +9 -0
  55. package/tsconfig.tsbuildinfo +1 -0
  56. package/tsdown.config.js +17 -0
@@ -0,0 +1,36 @@
1
+ import { defineTestSpec } from "@contractspec/lib.contracts";
2
+
3
+ //#region src/tests/operations.test-spec.ts
4
+ const GetTrackTest = defineTestSpec({
5
+ meta: {
6
+ key: "learningJourney.studioOnboarding.getTrack.test",
7
+ version: "1.0.0",
8
+ stability: "experimental",
9
+ owners: ["@example.learning-journey-studio-onboarding"],
10
+ description: "Test for getting studio onboarding track",
11
+ tags: ["test"]
12
+ },
13
+ target: {
14
+ type: "operation",
15
+ operation: {
16
+ key: "learningJourney.studioOnboarding.getTrack",
17
+ version: "1.0.0"
18
+ }
19
+ },
20
+ scenarios: [{
21
+ key: "success",
22
+ when: { operation: { key: "learningJourney.studioOnboarding.getTrack" } },
23
+ then: [{
24
+ type: "expectOutput",
25
+ match: {}
26
+ }]
27
+ }, {
28
+ key: "error",
29
+ when: { operation: { key: "learningJourney.studioOnboarding.getTrack" } },
30
+ then: [{ type: "expectError" }]
31
+ }]
32
+ });
33
+
34
+ //#endregion
35
+ export { GetTrackTest };
36
+ //# sourceMappingURL=operations.test-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.test-spec.js","names":[],"sources":["../../src/tests/operations.test-spec.ts"],"sourcesContent":["import { defineTestSpec } from '@contractspec/lib.contracts';\n\nexport const GetTrackTest = defineTestSpec({\n meta: {\n key: 'learningJourney.studioOnboarding.getTrack.test',\n version: '1.0.0',\n stability: 'experimental',\n owners: ['@example.learning-journey-studio-onboarding'],\n description: 'Test for getting studio onboarding track',\n tags: ['test'],\n },\n target: {\n type: 'operation',\n operation: {\n key: 'learningJourney.studioOnboarding.getTrack',\n version: '1.0.0',\n },\n },\n scenarios: [\n {\n key: 'success',\n when: { operation: { key: 'learningJourney.studioOnboarding.getTrack' } },\n then: [{ type: 'expectOutput', match: {} }],\n },\n {\n key: 'error',\n when: { operation: { key: 'learningJourney.studioOnboarding.getTrack' } },\n then: [{ type: 'expectError' }],\n },\n ],\n});\n"],"mappings":";;;AAEA,MAAa,eAAe,eAAe;CACzC,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,8CAA8C;EACvD,aAAa;EACb,MAAM,CAAC,OAAO;EACf;CACD,QAAQ;EACN,MAAM;EACN,WAAW;GACT,KAAK;GACL,SAAS;GACV;EACF;CACD,WAAW,CACT;EACE,KAAK;EACL,MAAM,EAAE,WAAW,EAAE,KAAK,6CAA6C,EAAE;EACzE,MAAM,CAAC;GAAE,MAAM;GAAgB,OAAO,EAAE;GAAE,CAAC;EAC5C,EACD;EACE,KAAK;EACL,MAAM,EAAE,WAAW,EAAE,KAAK,6CAA6C,EAAE;EACzE,MAAM,CAAC,EAAE,MAAM,eAAe,CAAC;EAChC,CACF;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { LearningJourneyTrackSpec } from "@contractspec/module.learning-journey/track-spec";
2
+
3
+ //#region src/track.d.ts
4
+ declare const studioGettingStartedTrack: LearningJourneyTrackSpec;
5
+ declare const studioLearningTracks: LearningJourneyTrackSpec[];
6
+ //#endregion
7
+ export { studioGettingStartedTrack, studioLearningTracks };
8
+ //# sourceMappingURL=track.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"track.d.ts","names":[],"sources":["../src/track.ts"],"sourcesContent":[],"mappings":";;;cAEa,2BAA2B;cAiF3B,sBAAsB"}
package/dist/track.js ADDED
@@ -0,0 +1,91 @@
1
+ //#region src/track.ts
2
+ const studioGettingStartedTrack = {
3
+ id: "studio_getting_started",
4
+ productId: "contractspec-studio",
5
+ name: "Studio Getting Started",
6
+ description: "First 30 minutes in Studio: create a project, edit the spec, deploy/regenerate, and try key modules.",
7
+ targetUserSegment: "new_studio_user",
8
+ targetRole: "developer",
9
+ totalXp: 110,
10
+ streakRule: {
11
+ hoursWindow: 48,
12
+ bonusXp: 25
13
+ },
14
+ completionRewards: {
15
+ xpBonus: 25,
16
+ badgeKey: "studio_first_30m"
17
+ },
18
+ steps: [
19
+ {
20
+ id: "choose_template",
21
+ title: "Choose a template",
22
+ description: "Create your first Studio project (starter template).",
23
+ order: 1,
24
+ completion: {
25
+ eventName: "studio.template.instantiated",
26
+ sourceModule: "@contractspec/bundle.studio"
27
+ },
28
+ xpReward: 20,
29
+ metadata: { surface: "projects" }
30
+ },
31
+ {
32
+ id: "edit_spec",
33
+ title: "Edit the spec",
34
+ description: "Change the spec (not generated code) and save.",
35
+ instructions: "Open spec editor, tweak a contract or presentation, save.",
36
+ order: 2,
37
+ completion: {
38
+ eventName: "spec.changed",
39
+ sourceModule: "@contractspec/bundle.studio"
40
+ },
41
+ xpReward: 20,
42
+ metadata: { surface: "spec-editor" }
43
+ },
44
+ {
45
+ id: "regenerate_app",
46
+ title: "Regenerate the app",
47
+ description: "Regenerate artifacts from the updated spec.",
48
+ order: 3,
49
+ completion: {
50
+ eventName: "regeneration.completed",
51
+ sourceModule: "@contractspec/lib.contracts/regenerator"
52
+ },
53
+ xpReward: 20,
54
+ metadata: { surface: "regenerator" }
55
+ },
56
+ {
57
+ id: "open_canvas",
58
+ title: "Open the canvas",
59
+ description: "Visit the canvas module for your project.",
60
+ order: 4,
61
+ completion: {
62
+ eventName: "module.navigated",
63
+ sourceModule: "@contractspec/bundle.studio",
64
+ payloadFilter: { moduleId: "canvas" }
65
+ },
66
+ xpReward: 20,
67
+ metadata: { surface: "canvas" }
68
+ },
69
+ {
70
+ id: "try_evolution_mode",
71
+ title: "Try evolution mode",
72
+ description: "Request a change via Evolution, then regenerate.",
73
+ order: 5,
74
+ completion: {
75
+ eventName: "studio.evolution.applied",
76
+ sourceModule: "@contractspec/lib.evolution"
77
+ },
78
+ xpReward: 30,
79
+ metadata: { surface: "evolution" }
80
+ }
81
+ ],
82
+ metadata: {
83
+ persona: "first_run",
84
+ surfacedIn: ["studio/home", "studio/sidebar/learning"]
85
+ }
86
+ };
87
+ const studioLearningTracks = [studioGettingStartedTrack];
88
+
89
+ //#endregion
90
+ export { studioGettingStartedTrack, studioLearningTracks };
91
+ //# sourceMappingURL=track.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"track.js","names":[],"sources":["../src/track.ts"],"sourcesContent":["import type { LearningJourneyTrackSpec } from '@contractspec/module.learning-journey/track-spec';\n\nexport const studioGettingStartedTrack: LearningJourneyTrackSpec = {\n id: 'studio_getting_started',\n productId: 'contractspec-studio',\n name: 'Studio Getting Started',\n description:\n 'First 30 minutes in Studio: create a project, edit the spec, deploy/regenerate, and try key modules.',\n targetUserSegment: 'new_studio_user',\n targetRole: 'developer',\n totalXp: 110,\n streakRule: { hoursWindow: 48, bonusXp: 25 },\n completionRewards: { xpBonus: 25, badgeKey: 'studio_first_30m' },\n steps: [\n {\n id: 'choose_template',\n title: 'Choose a template',\n description: 'Create your first Studio project (starter template).',\n order: 1,\n completion: {\n eventName: 'studio.template.instantiated',\n sourceModule: '@contractspec/bundle.studio',\n },\n xpReward: 20,\n metadata: { surface: 'projects' },\n },\n {\n id: 'edit_spec',\n title: 'Edit the spec',\n description: 'Change the spec (not generated code) and save.',\n instructions: 'Open spec editor, tweak a contract or presentation, save.',\n order: 2,\n completion: {\n eventName: 'spec.changed',\n sourceModule: '@contractspec/bundle.studio',\n },\n xpReward: 20,\n metadata: { surface: 'spec-editor' },\n },\n {\n id: 'regenerate_app',\n title: 'Regenerate the app',\n description: 'Regenerate artifacts from the updated spec.',\n order: 3,\n completion: {\n eventName: 'regeneration.completed',\n sourceModule: '@contractspec/lib.contracts/regenerator',\n },\n xpReward: 20,\n metadata: { surface: 'regenerator' },\n },\n {\n id: 'open_canvas',\n title: 'Open the canvas',\n description: 'Visit the canvas module for your project.',\n order: 4,\n completion: {\n eventName: 'module.navigated',\n sourceModule: '@contractspec/bundle.studio',\n payloadFilter: { moduleId: 'canvas' },\n },\n xpReward: 20,\n metadata: { surface: 'canvas' },\n },\n {\n id: 'try_evolution_mode',\n title: 'Try evolution mode',\n description: 'Request a change via Evolution, then regenerate.',\n order: 5,\n completion: {\n eventName: 'studio.evolution.applied',\n sourceModule: '@contractspec/lib.evolution',\n },\n xpReward: 30,\n metadata: { surface: 'evolution' },\n },\n ],\n metadata: {\n persona: 'first_run',\n surfacedIn: ['studio/home', 'studio/sidebar/learning'],\n },\n};\n\nexport const studioLearningTracks: LearningJourneyTrackSpec[] = [\n studioGettingStartedTrack,\n];\n"],"mappings":";AAEA,MAAa,4BAAsD;CACjE,IAAI;CACJ,WAAW;CACX,MAAM;CACN,aACE;CACF,mBAAmB;CACnB,YAAY;CACZ,SAAS;CACT,YAAY;EAAE,aAAa;EAAI,SAAS;EAAI;CAC5C,mBAAmB;EAAE,SAAS;EAAI,UAAU;EAAoB;CAChE,OAAO;EACL;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,OAAO;GACP,YAAY;IACV,WAAW;IACX,cAAc;IACf;GACD,UAAU;GACV,UAAU,EAAE,SAAS,YAAY;GAClC;EACD;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,cAAc;GACd,OAAO;GACP,YAAY;IACV,WAAW;IACX,cAAc;IACf;GACD,UAAU;GACV,UAAU,EAAE,SAAS,eAAe;GACrC;EACD;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,OAAO;GACP,YAAY;IACV,WAAW;IACX,cAAc;IACf;GACD,UAAU;GACV,UAAU,EAAE,SAAS,eAAe;GACrC;EACD;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,OAAO;GACP,YAAY;IACV,WAAW;IACX,cAAc;IACd,eAAe,EAAE,UAAU,UAAU;IACtC;GACD,UAAU;GACV,UAAU,EAAE,SAAS,UAAU;GAChC;EACD;GACE,IAAI;GACJ,OAAO;GACP,aAAa;GACb,OAAO;GACP,YAAY;IACV,WAAW;IACX,cAAc;IACf;GACD,UAAU;GACV,UAAU,EAAE,SAAS,aAAa;GACnC;EACF;CACD,UAAU;EACR,SAAS;EACT,YAAY,CAAC,eAAe,0BAA0B;EACvD;CACF;AAED,MAAa,uBAAmD,CAC9D,0BACD"}
package/example.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './src/example';
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@contractspec/example.learning-journey-studio-onboarding",
3
+ "version": "0.0.0-canary-20260113162409",
4
+ "description": "Learning journey track for first 30 minutes in ContractSpec Studio.",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.js",
9
+ "./docs": "./dist/docs/index.js",
10
+ "./docs/studio-onboarding.docblock": "./dist/docs/studio-onboarding.docblock.js",
11
+ "./example": "./dist/example.js",
12
+ "./handlers/demo.handlers": "./dist/handlers/demo.handlers.js",
13
+ "./learning-journey-studio-onboarding.feature": "./dist/learning-journey-studio-onboarding.feature.js",
14
+ "./operations": "./dist/operations/index.js",
15
+ "./presentations": "./dist/presentations/index.js",
16
+ "./tests/operations.test-spec": "./dist/tests/operations.test-spec.js",
17
+ "./track": "./dist/track.js",
18
+ "./*": "./*"
19
+ },
20
+ "scripts": {
21
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
22
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
23
+ "build": "bun build:types && bun build:bundle",
24
+ "build:bundle": "tsdown",
25
+ "build:types": "tsc --noEmit",
26
+ "dev": "bun build:bundle --watch",
27
+ "clean": "rimraf dist .turbo",
28
+ "lint": "bun lint:fix",
29
+ "lint:fix": "eslint src --fix",
30
+ "lint:check": "eslint src"
31
+ },
32
+ "dependencies": {
33
+ "@contractspec/lib.contracts": "0.0.0-canary-20260113162409",
34
+ "@contractspec/lib.schema": "0.0.0-canary-20260113162409",
35
+ "@contractspec/module.learning-journey": "0.0.0-canary-20260113162409"
36
+ },
37
+ "devDependencies": {
38
+ "@contractspec/tool.tsdown": "0.0.0-canary-20260113162409",
39
+ "@contractspec/tool.typescript": "0.0.0-canary-20260113162409",
40
+ "tsdown": "^0.19.0",
41
+ "typescript": "^5.9.3"
42
+ },
43
+ "publishConfig": {
44
+ "exports": {
45
+ ".": "./dist/index.js",
46
+ "./contracts": "./dist/contracts/index.js",
47
+ "./docs": "./dist/docs/index.js",
48
+ "./docs/studio-onboarding.docblock": "./dist/docs/studio-onboarding.docblock.js",
49
+ "./example": "./dist/example.js",
50
+ "./handlers/demo.handlers": "./dist/handlers/demo.handlers.js",
51
+ "./learning-journey-studio-onboarding.feature": "./dist/learning-journey-studio-onboarding.feature.js",
52
+ "./presentations": "./dist/presentations/index.js",
53
+ "./track": "./dist/track.js",
54
+ "./*": "./*"
55
+ },
56
+ "registry": "https://registry.npmjs.org/",
57
+ "access": "public"
58
+ },
59
+ "license": "MIT",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "https://github.com/lssm-tech/contractspec.git",
63
+ "directory": "packages/examples/learning-journey-studio-onboarding"
64
+ },
65
+ "homepage": "https://contractspec.io"
66
+ }
@@ -0,0 +1 @@
1
+ import './studio-onboarding.docblock';
@@ -0,0 +1,38 @@
1
+ import type { DocBlock } from '@contractspec/lib.contracts';
2
+ import { registerDocBlocks } from '@contractspec/lib.contracts';
3
+
4
+ const studioOnboardingDocBlocks: DocBlock[] = [
5
+ {
6
+ id: 'docs.learning-journey.studio-onboarding',
7
+ title: 'Learning Journey — Studio Getting Started',
8
+ summary:
9
+ 'Track that guides a new Studio user through template spawn, spec edit, regeneration, playground, and evolution.',
10
+ kind: 'reference',
11
+ visibility: 'public',
12
+ route: '/docs/learning-journey/studio-onboarding',
13
+ tags: ['learning', 'onboarding', 'studio'],
14
+ body: `## Track
15
+ - **Key**: \`studio_getting_started\`
16
+ - **Persona**: new Studio developer, first 30 minutes
17
+ - **Goal**: instantiate template → edit spec → regenerate → play → run evolution
18
+
19
+ ## Steps & Events
20
+ 1) \`choose_template\` → event \`studio.template.instantiated\`
21
+ 2) \`edit_spec\` → event \`spec.changed\` (scope: sandbox)
22
+ 3) \`regenerate_app\` → event \`regeneration.completed\`
23
+ 4) \`play_in_playground\` → event \`playground.session.started\`
24
+ 5) \`try_evolution_mode\` → event \`studio.evolution.applied\`
25
+
26
+ XP: 20/20/20/20/30 with bonus 25 XP if completed within 48h (streak rule). Badge: \`studio_first_30m\`.
27
+
28
+ ## Wiring
29
+ - Tracks export from \`@contractspec/example.learning-journey-studio-onboarding/track\`.
30
+ - Use onboarding API:
31
+ - \`learning.onboarding.listTracks\` to surface catalog
32
+ - \`learning.onboarding.getProgress\` to render progress
33
+ - \`learning.onboarding.recordEvent\` to advance from bus events
34
+ - Events should be emitted by Studio surfaces (template creation, spec save, regeneration, playground session start, evolution apply).`,
35
+ },
36
+ ];
37
+
38
+ registerDocBlocks(studioOnboardingDocBlocks);
package/src/example.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { defineExample } from '@contractspec/lib.contracts';
2
+
3
+ const example = defineExample({
4
+ meta: {
5
+ key: 'learning-journey-studio-onboarding',
6
+ version: '1.0.0',
7
+ title: 'Learning Journey — Studio Getting Started',
8
+ description:
9
+ 'Onboarding track guiding a new Studio user through template spawn, spec edit, regeneration, playground, and evolution.',
10
+ kind: 'template',
11
+ visibility: 'public',
12
+ stability: 'experimental',
13
+ owners: ['@platform.core'],
14
+ tags: ['learning', 'onboarding', 'studio'],
15
+ },
16
+ docs: {
17
+ rootDocId: 'docs.learning-journey.studio-onboarding',
18
+ },
19
+ entrypoints: {
20
+ packageName: '@contractspec/example.learning-journey-studio-onboarding',
21
+ docs: './docs',
22
+ },
23
+ surfaces: {
24
+ templates: true,
25
+ sandbox: { enabled: true, modes: ['playground', 'markdown'] },
26
+ studio: { enabled: true, installable: true },
27
+ mcp: { enabled: true },
28
+ },
29
+ });
30
+
31
+ export default example;
@@ -0,0 +1,48 @@
1
+ import { studioGettingStartedTrack } from '../track';
2
+
3
+ interface EmitParams {
4
+ learnerId: string;
5
+ occurredAt?: Date;
6
+ }
7
+
8
+ interface LearningJourneyEvent {
9
+ learnerId: string;
10
+ name: string;
11
+ occurredAt: Date;
12
+ trackId: string;
13
+ payload?: Record<string, unknown>;
14
+ }
15
+
16
+ type RecordEvent = (event: LearningJourneyEvent) => unknown;
17
+
18
+ export const studioOnboardingEvents = [
19
+ 'studio.template.instantiated',
20
+ 'spec.changed',
21
+ 'regeneration.completed',
22
+ 'playground.session.started',
23
+ 'studio.evolution.applied',
24
+ ] as const;
25
+
26
+ export type StudioEvent = (typeof studioOnboardingEvents)[number];
27
+
28
+ export const emitStudioOnboardingEvent = (
29
+ eventName: StudioEvent,
30
+ { learnerId, occurredAt = new Date() }: EmitParams,
31
+ record?: RecordEvent
32
+ ) => {
33
+ const event: LearningJourneyEvent = {
34
+ learnerId,
35
+ name: eventName,
36
+ occurredAt,
37
+ trackId: studioGettingStartedTrack.id,
38
+ };
39
+ return record ? record(event) : event;
40
+ };
41
+
42
+ export const emitAllStudioOnboardingEvents = (
43
+ params: EmitParams,
44
+ record?: RecordEvent
45
+ ) =>
46
+ studioOnboardingEvents.map((name) =>
47
+ emitStudioOnboardingEvent(name, params, record)
48
+ );
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './track';
2
+ export * from './docs';
3
+ export * from './operations';
4
+ export * from './handlers/demo.handlers';
5
+ export * from './presentations';
6
+ export * from './learning-journey-studio-onboarding.feature';
7
+ export { default as example } from './example';
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Learning Journey Studio Onboarding Feature Module Specification
3
+ *
4
+ * Defines the feature module for Studio onboarding journey.
5
+ */
6
+ import { defineFeature } from '@contractspec/lib.contracts';
7
+
8
+ /**
9
+ * Learning Journey Studio Onboarding feature module that bundles
10
+ * Studio-specific onboarding track operations and presentations.
11
+ */
12
+ export const LearningJourneyStudioOnboardingFeature = defineFeature({
13
+ meta: {
14
+ key: 'learning-journey-studio-onboarding',
15
+ title: 'Learning Journey: Studio Onboarding',
16
+ description:
17
+ 'Studio onboarding journey for getting started with ContractSpec Studio',
18
+ domain: 'learning-journey',
19
+ owners: ['@examples.learning-journey.studio-onboarding'],
20
+ tags: ['learning', 'onboarding', 'studio', 'journey'],
21
+ stability: 'experimental',
22
+ version: '1.0.0',
23
+ },
24
+
25
+ // All contract operations included in this feature
26
+ operations: [
27
+ { key: 'learningJourney.studioOnboarding.recordEvent', version: '1.0.0' },
28
+ { key: 'learningJourney.studioOnboarding.getTrack', version: '1.0.0' },
29
+ ],
30
+
31
+ // Events emitted by this feature
32
+ events: [],
33
+
34
+ // Presentations associated with this feature
35
+ presentations: [
36
+ { key: 'learning.journey.studio.track', version: '1.0.0' },
37
+ { key: 'learning.journey.studio.widget', version: '1.0.0' },
38
+ ],
39
+
40
+ // Link operations to their primary presentations
41
+ opToPresentation: [
42
+ {
43
+ op: {
44
+ key: 'learningJourney.studioOnboarding.getTrack',
45
+ version: '1.0.0',
46
+ },
47
+ pres: { key: 'learning.journey.studio.track', version: '1.0.0' },
48
+ },
49
+ ],
50
+
51
+ // Target requirements for multi-surface rendering
52
+ presentationsTargets: [
53
+ {
54
+ key: 'learning.journey.studio.track',
55
+ version: '1.0.0',
56
+ targets: ['react', 'markdown', 'application/json'],
57
+ },
58
+ {
59
+ key: 'learning.journey.studio.widget',
60
+ version: '1.0.0',
61
+ targets: ['react'],
62
+ },
63
+ ],
64
+
65
+ // Capability requirements
66
+ capabilities: {
67
+ requires: [{ key: 'identity', version: '1.0.0' }],
68
+ },
69
+ });
@@ -0,0 +1,49 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+
3
+ import {
4
+ GetStudioOnboardingTrack,
5
+ RecordStudioOnboardingEvent,
6
+ studioOnboardingContracts,
7
+ } from './index';
8
+ import { studioGettingStartedTrack } from '../track';
9
+ import {
10
+ emitStudioOnboardingEvent,
11
+ studioOnboardingEvents,
12
+ } from '../handlers/demo.handlers';
13
+ import type { StudioEvent } from '../handlers/demo.handlers';
14
+
15
+ describe('studio onboarding contracts', () => {
16
+ it('exposes track metadata', () => {
17
+ expect(studioOnboardingContracts.track.id).toBe('studio_getting_started');
18
+ expect(studioOnboardingContracts.track.steps.length).toBeGreaterThan(0);
19
+ expect(GetStudioOnboardingTrack.meta.key).toBe(
20
+ 'learningJourney.studioOnboarding.getTrack'
21
+ );
22
+ });
23
+
24
+ it('allows recording events via demo handler', async () => {
25
+ const step = studioGettingStartedTrack.steps[0];
26
+ expect(step).toBeDefined();
27
+ if (!step) throw new Error('Expected at least one onboarding step');
28
+
29
+ const eventName = step.completion.eventName;
30
+ const isStudioEvent = (value: string): value is StudioEvent =>
31
+ studioOnboardingEvents.includes(value as StudioEvent);
32
+
33
+ expect(isStudioEvent(eventName)).toBe(true);
34
+ if (!isStudioEvent(eventName)) {
35
+ throw new Error(`Unexpected event name: ${eventName}`);
36
+ }
37
+
38
+ const result = await emitStudioOnboardingEvent(eventName, {
39
+ learnerId: 'demo-learner',
40
+ });
41
+ expect(result).toBeDefined();
42
+ });
43
+
44
+ it('exposes record event contract', () => {
45
+ expect(RecordStudioOnboardingEvent.meta.key).toBe(
46
+ 'learningJourney.studioOnboarding.recordEvent'
47
+ );
48
+ });
49
+ });
@@ -0,0 +1,122 @@
1
+ import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';
2
+ import { defineCommand, defineQuery } from '@contractspec/lib.contracts';
3
+
4
+ import { studioGettingStartedTrack } from '../track';
5
+
6
+ const OWNERS = ['examples.learning-journey.studio-onboarding'] as const;
7
+
8
+ const StepModel = defineSchemaModel({
9
+ name: 'StudioOnboardingStep',
10
+ description: 'Step metadata for Studio onboarding journey',
11
+ fields: {
12
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
14
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
15
+ completionEvent: {
16
+ type: ScalarTypeEnum.String_unsecure(),
17
+ isOptional: false,
18
+ },
19
+ sourceModule: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
20
+ xpReward: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
21
+ order: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
22
+ },
23
+ });
24
+
25
+ export const StudioOnboardingTrackModel = defineSchemaModel({
26
+ name: 'StudioOnboardingTrack',
27
+ description: 'Studio onboarding track definition',
28
+ fields: {
29
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
30
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
32
+ totalXp: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
33
+ completionXpBonus: {
34
+ type: ScalarTypeEnum.Int_unsecure(),
35
+ isOptional: true,
36
+ },
37
+ completionBadgeKey: {
38
+ type: ScalarTypeEnum.String_unsecure(),
39
+ isOptional: true,
40
+ },
41
+ streakHoursWindow: {
42
+ type: ScalarTypeEnum.Int_unsecure(),
43
+ isOptional: true,
44
+ },
45
+ streakBonusXp: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
46
+ steps: { type: StepModel, isArray: true, isOptional: false },
47
+ },
48
+ });
49
+
50
+ const TrackResponseModel = defineSchemaModel({
51
+ name: 'StudioOnboardingTrackResponse',
52
+ description: 'Response wrapper for studio onboarding track',
53
+ fields: {
54
+ track: { type: StudioOnboardingTrackModel, isOptional: false },
55
+ },
56
+ });
57
+
58
+ const RecordDemoEventInput = defineSchemaModel({
59
+ name: 'StudioOnboardingRecordEventInput',
60
+ description: 'Emit a demo event to advance Studio onboarding steps',
61
+ fields: {
62
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
63
+ eventName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
+ payload: { type: ScalarTypeEnum.JSON(), isOptional: true },
65
+ occurredAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
66
+ },
67
+ });
68
+
69
+ const SuccessModel = defineSchemaModel({
70
+ name: 'StudioOnboardingSuccess',
71
+ description: 'Generic success response',
72
+ fields: {
73
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
74
+ },
75
+ });
76
+
77
+ export const GetStudioOnboardingTrack = defineQuery({
78
+ meta: {
79
+ key: 'learningJourney.studioOnboarding.getTrack',
80
+ version: '1.0.0',
81
+ stability: 'experimental',
82
+ owners: [...OWNERS],
83
+ tags: ['learning', 'onboarding', 'studio'],
84
+ description: 'Fetch the Studio onboarding track definition.',
85
+ goal: 'Expose track metadata to UIs and templates.',
86
+ context: 'Called by Studio/Playground to render journey steps.',
87
+ },
88
+ io: {
89
+ input: defineSchemaModel({
90
+ name: 'StudioOnboardingTrackInput',
91
+ description: 'Track input',
92
+ fields: {},
93
+ }),
94
+ output: TrackResponseModel,
95
+ },
96
+ policy: { auth: 'user' },
97
+ });
98
+
99
+ export const RecordStudioOnboardingEvent = defineCommand({
100
+ meta: {
101
+ key: 'learningJourney.studioOnboarding.recordEvent',
102
+ version: '1.0.0',
103
+ stability: 'experimental',
104
+ owners: [...OWNERS],
105
+ tags: ['learning', 'onboarding', 'studio'],
106
+ description: 'Record an event to advance Studio onboarding progress.',
107
+ goal: 'Advance steps via domain events in demo/sandbox contexts.',
108
+ context:
109
+ 'Called by handlers or demo scripts to emit step completion events.',
110
+ },
111
+ io: {
112
+ input: RecordDemoEventInput,
113
+ output: SuccessModel,
114
+ },
115
+ policy: { auth: 'user' },
116
+ });
117
+
118
+ export const studioOnboardingContracts = {
119
+ GetStudioOnboardingTrack,
120
+ RecordStudioOnboardingEvent,
121
+ track: studioGettingStartedTrack,
122
+ };
@@ -0,0 +1,57 @@
1
+ import {
2
+ definePresentation,
3
+ StabilityEnum,
4
+ type PresentationSpecMeta,
5
+ } from '@contractspec/lib.contracts';
6
+ import { StudioOnboardingTrackModel } from '../operations';
7
+
8
+ const baseMeta: Pick<
9
+ PresentationSpecMeta,
10
+ 'domain' | 'owners' | 'tags' | 'title' | 'stability'
11
+ > = {
12
+ domain: 'learning-journey',
13
+ title: 'Studio Onboarding',
14
+ owners: ['@examples.learning-journey.studio-onboarding'] as string[],
15
+ tags: ['learning', 'onboarding', 'studio'] as string[],
16
+ stability: StabilityEnum.Experimental,
17
+ };
18
+
19
+ export const StudioOnboardingTrackPresentation = definePresentation({
20
+ meta: {
21
+ key: 'learning.journey.studio.track',
22
+ version: '1.0.0',
23
+ description: 'Studio onboarding track detail',
24
+ goal: 'Visualize the onboarding track for the user.',
25
+ context: 'Displayed in the Studio dashboard.',
26
+ ...baseMeta,
27
+ },
28
+ source: {
29
+ type: 'component',
30
+ framework: 'react',
31
+ componentKey: 'LearningTrackDetail',
32
+ props: StudioOnboardingTrackModel,
33
+ },
34
+ targets: ['react', 'markdown', 'application/json'],
35
+ });
36
+
37
+ export const StudioOnboardingWidgetPresentation = definePresentation({
38
+ meta: {
39
+ key: 'learning.journey.studio.widget',
40
+ version: '1.0.0',
41
+ description: 'Compact widget for Studio onboarding progress',
42
+ goal: 'Show quick progress summary.',
43
+ context: 'Displayed in the Studio sidebar or header.',
44
+ ...baseMeta,
45
+ },
46
+ source: {
47
+ type: 'component',
48
+ framework: 'react',
49
+ componentKey: 'LearningTrackProgressWidget',
50
+ },
51
+ targets: ['react'],
52
+ });
53
+
54
+ export const studioOnboardingPresentations = [
55
+ StudioOnboardingTrackPresentation,
56
+ StudioOnboardingWidgetPresentation,
57
+ ];