@contractspec/example.learning-journey-studio-onboarding 1.44.0
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/.turbo/turbo-build$colon$bundle.log +41 -0
- package/.turbo/turbo-build.log +42 -0
- package/CHANGELOG.md +178 -0
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/studio-onboarding.docblock.d.ts +1 -0
- package/dist/docs/studio-onboarding.docblock.js +40 -0
- package/dist/docs/studio-onboarding.docblock.js.map +1 -0
- package/dist/example.d.ts +33 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +35 -0
- package/dist/example.js.map +1 -0
- package/dist/handlers/demo.handlers.d.ts +23 -0
- package/dist/handlers/demo.handlers.d.ts.map +1 -0
- package/dist/handlers/demo.handlers.js +24 -0
- package/dist/handlers/demo.handlers.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -0
- package/dist/learning-journey-studio-onboarding.feature.d.ts +12 -0
- package/dist/learning-journey-studio-onboarding.feature.d.ts.map +1 -0
- package/dist/learning-journey-studio-onboarding.feature.js +68 -0
- package/dist/learning-journey-studio-onboarding.feature.js.map +1 -0
- package/dist/operations/index.d.ts +271 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +176 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/presentations/index.d.ts +9 -0
- package/dist/presentations/index.d.ts.map +1 -0
- package/dist/presentations/index.js +57 -0
- package/dist/presentations/index.js.map +1 -0
- package/dist/track.d.ts +8 -0
- package/dist/track.d.ts.map +1 -0
- package/dist/track.js +91 -0
- package/dist/track.js.map +1 -0
- package/example.ts +1 -0
- package/package.json +67 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/studio-onboarding.docblock.ts +38 -0
- package/src/example.ts +24 -0
- package/src/handlers/demo.handlers.ts +48 -0
- package/src/index.ts +7 -0
- package/src/learning-journey-studio-onboarding.feature.ts +66 -0
- package/src/operations/index.test.ts +49 -0
- package/src/operations/index.ts +122 -0
- package/src/presentations/index.ts +57 -0
- package/src/track.ts +86 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +17 -0
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/example.learning-journey-studio-onboarding",
|
|
3
|
+
"version": "1.44.0",
|
|
4
|
+
"description": "Learning journey track for first 30 minutes in ContractSpec Studio.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./docs": "./dist/docs/index.js",
|
|
11
|
+
"./docs/studio-onboarding.docblock": "./dist/docs/studio-onboarding.docblock.js",
|
|
12
|
+
"./example": "./dist/example.js",
|
|
13
|
+
"./handlers/demo.handlers": "./dist/handlers/demo.handlers.js",
|
|
14
|
+
"./learning-journey-studio-onboarding.feature": "./dist/learning-journey-studio-onboarding.feature.js",
|
|
15
|
+
"./operations": "./dist/operations/index.js",
|
|
16
|
+
"./presentations": "./dist/presentations/index.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": "1.44.0",
|
|
34
|
+
"@contractspec/lib.schema": "1.44.0",
|
|
35
|
+
"@contractspec/module.learning-journey": "1.44.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@contractspec/tool.tsdown": "1.44.0",
|
|
39
|
+
"@contractspec/tool.typescript": "1.44.0",
|
|
40
|
+
"tsdown": "^0.18.3",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
},
|
|
43
|
+
"module": "./dist/index.js",
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"exports": {
|
|
46
|
+
".": "./dist/index.js",
|
|
47
|
+
"./contracts": "./dist/contracts/index.js",
|
|
48
|
+
"./docs": "./dist/docs/index.js",
|
|
49
|
+
"./docs/studio-onboarding.docblock": "./dist/docs/studio-onboarding.docblock.js",
|
|
50
|
+
"./example": "./dist/example.js",
|
|
51
|
+
"./handlers/demo.handlers": "./dist/handlers/demo.handlers.js",
|
|
52
|
+
"./learning-journey-studio-onboarding.feature": "./dist/learning-journey-studio-onboarding.feature.js",
|
|
53
|
+
"./presentations": "./dist/presentations/index.js",
|
|
54
|
+
"./track": "./dist/track.js",
|
|
55
|
+
"./*": "./*"
|
|
56
|
+
},
|
|
57
|
+
"registry": "https://registry.npmjs.org/",
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
64
|
+
"directory": "packages/examples/learning-journey-studio-onboarding"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://contractspec.io"
|
|
67
|
+
}
|
|
@@ -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,24 @@
|
|
|
1
|
+
const example = {
|
|
2
|
+
id: 'learning-journey-studio-onboarding',
|
|
3
|
+
title: 'Learning Journey — Studio Getting Started',
|
|
4
|
+
summary:
|
|
5
|
+
'Onboarding track guiding a new Studio user through template spawn, spec edit, regeneration, playground, and evolution.',
|
|
6
|
+
tags: ['learning', 'onboarding', 'studio'],
|
|
7
|
+
kind: 'template',
|
|
8
|
+
visibility: 'public',
|
|
9
|
+
docs: {
|
|
10
|
+
rootDocId: 'docs.learning-journey.studio-onboarding',
|
|
11
|
+
},
|
|
12
|
+
entrypoints: {
|
|
13
|
+
packageName: '@contractspec/example.learning-journey-studio-onboarding',
|
|
14
|
+
docs: './docs',
|
|
15
|
+
},
|
|
16
|
+
surfaces: {
|
|
17
|
+
templates: true,
|
|
18
|
+
sandbox: { enabled: true, modes: ['playground', 'markdown'] },
|
|
19
|
+
studio: { enabled: true, installable: true },
|
|
20
|
+
mcp: { enabled: true },
|
|
21
|
+
},
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
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,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learning Journey Studio Onboarding Feature Module Specification
|
|
3
|
+
*
|
|
4
|
+
* Defines the feature module for Studio onboarding journey.
|
|
5
|
+
*/
|
|
6
|
+
import type { FeatureModuleSpec } 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: FeatureModuleSpec = {
|
|
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,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// All contract operations included in this feature
|
|
26
|
+
operations: [
|
|
27
|
+
{ key: 'learningJourney.studioOnboarding.recordEvent', version: 1 },
|
|
28
|
+
{ key: 'learningJourney.studioOnboarding.getTrack', version: 1 },
|
|
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 },
|
|
37
|
+
{ key: 'learning.journey.studio.widget', version: 1 },
|
|
38
|
+
],
|
|
39
|
+
|
|
40
|
+
// Link operations to their primary presentations
|
|
41
|
+
opToPresentation: [
|
|
42
|
+
{
|
|
43
|
+
op: { key: 'learningJourney.studioOnboarding.getTrack', version: 1 },
|
|
44
|
+
pres: { key: 'learning.journey.studio.track', version: 1 },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
// Target requirements for multi-surface rendering
|
|
49
|
+
presentationsTargets: [
|
|
50
|
+
{
|
|
51
|
+
key: 'learning.journey.studio.track',
|
|
52
|
+
version: 1,
|
|
53
|
+
targets: ['react', 'markdown', 'application/json'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'learning.journey.studio.widget',
|
|
57
|
+
version: 1,
|
|
58
|
+
targets: ['react'],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
|
|
62
|
+
// Capability requirements
|
|
63
|
+
capabilities: {
|
|
64
|
+
requires: [{ key: 'identity', version: 1 }],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -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,
|
|
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,
|
|
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 type {
|
|
2
|
+
PresentationSpecMeta,
|
|
3
|
+
PresentationSpec,
|
|
4
|
+
} from '@contractspec/lib.contracts';
|
|
5
|
+
import { StabilityEnum } 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: PresentationSpec = {
|
|
20
|
+
meta: {
|
|
21
|
+
key: 'learning.journey.studio.track',
|
|
22
|
+
version: 1,
|
|
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: PresentationSpec = {
|
|
38
|
+
meta: {
|
|
39
|
+
key: 'learning.journey.studio.widget',
|
|
40
|
+
version: 1,
|
|
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
|
+
];
|
package/src/track.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { LearningJourneyTrackSpec } from '@contractspec/module.learning-journey/track-spec';
|
|
2
|
+
|
|
3
|
+
export const studioGettingStartedTrack: LearningJourneyTrackSpec = {
|
|
4
|
+
id: 'studio_getting_started',
|
|
5
|
+
productId: 'contractspec-studio',
|
|
6
|
+
name: 'Studio Getting Started',
|
|
7
|
+
description:
|
|
8
|
+
'First 30 minutes in Studio: create a project, edit the spec, deploy/regenerate, and try key modules.',
|
|
9
|
+
targetUserSegment: 'new_studio_user',
|
|
10
|
+
targetRole: 'developer',
|
|
11
|
+
totalXp: 110,
|
|
12
|
+
streakRule: { hoursWindow: 48, bonusXp: 25 },
|
|
13
|
+
completionRewards: { xpBonus: 25, badgeKey: 'studio_first_30m' },
|
|
14
|
+
steps: [
|
|
15
|
+
{
|
|
16
|
+
id: 'choose_template',
|
|
17
|
+
title: 'Choose a template',
|
|
18
|
+
description: 'Create your first Studio project (starter template).',
|
|
19
|
+
order: 1,
|
|
20
|
+
completion: {
|
|
21
|
+
eventName: 'studio.template.instantiated',
|
|
22
|
+
sourceModule: '@contractspec/bundle.studio',
|
|
23
|
+
},
|
|
24
|
+
xpReward: 20,
|
|
25
|
+
metadata: { surface: 'projects' },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'edit_spec',
|
|
29
|
+
title: 'Edit the spec',
|
|
30
|
+
description: 'Change the spec (not generated code) and save.',
|
|
31
|
+
instructions: 'Open spec editor, tweak a contract or presentation, save.',
|
|
32
|
+
order: 2,
|
|
33
|
+
completion: {
|
|
34
|
+
eventName: 'spec.changed',
|
|
35
|
+
sourceModule: '@contractspec/bundle.studio',
|
|
36
|
+
},
|
|
37
|
+
xpReward: 20,
|
|
38
|
+
metadata: { surface: 'spec-editor' },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'regenerate_app',
|
|
42
|
+
title: 'Regenerate the app',
|
|
43
|
+
description: 'Regenerate artifacts from the updated spec.',
|
|
44
|
+
order: 3,
|
|
45
|
+
completion: {
|
|
46
|
+
eventName: 'regeneration.completed',
|
|
47
|
+
sourceModule: '@contractspec/lib.contracts/regenerator',
|
|
48
|
+
},
|
|
49
|
+
xpReward: 20,
|
|
50
|
+
metadata: { surface: 'regenerator' },
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'open_canvas',
|
|
54
|
+
title: 'Open the canvas',
|
|
55
|
+
description: 'Visit the canvas module for your project.',
|
|
56
|
+
order: 4,
|
|
57
|
+
completion: {
|
|
58
|
+
eventName: 'module.navigated',
|
|
59
|
+
sourceModule: '@contractspec/bundle.studio',
|
|
60
|
+
payloadFilter: { moduleId: 'canvas' },
|
|
61
|
+
},
|
|
62
|
+
xpReward: 20,
|
|
63
|
+
metadata: { surface: 'canvas' },
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'try_evolution_mode',
|
|
67
|
+
title: 'Try evolution mode',
|
|
68
|
+
description: 'Request a change via Evolution, then regenerate.',
|
|
69
|
+
order: 5,
|
|
70
|
+
completion: {
|
|
71
|
+
eventName: 'studio.evolution.applied',
|
|
72
|
+
sourceModule: '@contractspec/lib.evolution',
|
|
73
|
+
},
|
|
74
|
+
xpReward: 30,
|
|
75
|
+
metadata: { surface: 'evolution' },
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
metadata: {
|
|
79
|
+
persona: 'first_run',
|
|
80
|
+
surfacedIn: ['studio/home', 'studio/sidebar/learning'],
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const studioLearningTracks: LearningJourneyTrackSpec[] = [
|
|
85
|
+
studioGettingStartedTrack,
|
|
86
|
+
];
|