@soulcraft/sdk 1.0.0 → 1.1.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/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/billing/firestore-provider.d.ts +60 -0
- package/dist/modules/billing/firestore-provider.d.ts.map +1 -0
- package/dist/modules/billing/firestore-provider.js +314 -0
- package/dist/modules/billing/firestore-provider.js.map +1 -0
- package/dist/modules/billing/index.d.ts +46 -0
- package/dist/modules/billing/index.d.ts.map +1 -0
- package/dist/modules/billing/index.js +149 -0
- package/dist/modules/billing/index.js.map +1 -0
- package/dist/modules/billing/local-provider.d.ts +38 -0
- package/dist/modules/billing/local-provider.d.ts.map +1 -0
- package/dist/modules/billing/local-provider.js +242 -0
- package/dist/modules/billing/local-provider.js.map +1 -0
- package/dist/modules/billing/types.d.ts +322 -3
- package/dist/modules/billing/types.d.ts.map +1 -1
- package/dist/modules/billing/types.js +21 -2
- package/dist/modules/billing/types.js.map +1 -1
- package/dist/modules/billing/usage-buffer.d.ts +72 -0
- package/dist/modules/billing/usage-buffer.d.ts.map +1 -0
- package/dist/modules/billing/usage-buffer.js +141 -0
- package/dist/modules/billing/usage-buffer.js.map +1 -0
- package/dist/modules/formats/types.d.ts +65 -3
- package/dist/modules/formats/types.d.ts.map +1 -1
- package/dist/modules/formats/types.js +40 -3
- package/dist/modules/formats/types.js.map +1 -1
- package/dist/modules/formats/wdoc.d.ts +263 -0
- package/dist/modules/formats/wdoc.d.ts.map +1 -0
- package/dist/modules/formats/wdoc.js +21 -0
- package/dist/modules/formats/wdoc.js.map +1 -0
- package/dist/modules/formats/wquiz.d.ts +122 -0
- package/dist/modules/formats/wquiz.d.ts.map +1 -0
- package/dist/modules/formats/wquiz.js +23 -0
- package/dist/modules/formats/wquiz.js.map +1 -0
- package/dist/modules/formats/wslide.d.ts +130 -0
- package/dist/modules/formats/wslide.d.ts.map +1 -0
- package/dist/modules/formats/wslide.js +23 -0
- package/dist/modules/formats/wslide.js.map +1 -0
- package/dist/modules/formats/wviz.d.ts +114 -0
- package/dist/modules/formats/wviz.d.ts.map +1 -0
- package/dist/modules/formats/wviz.js +21 -0
- package/dist/modules/formats/wviz.js.map +1 -0
- package/dist/modules/kits/index.d.ts +41 -0
- package/dist/modules/kits/index.d.ts.map +1 -0
- package/dist/modules/kits/index.js +85 -0
- package/dist/modules/kits/index.js.map +1 -0
- package/dist/modules/kits/types.d.ts +107 -3
- package/dist/modules/kits/types.d.ts.map +1 -1
- package/dist/modules/kits/types.js +15 -2
- package/dist/modules/kits/types.js.map +1 -1
- package/dist/modules/license/index.d.ts +53 -0
- package/dist/modules/license/index.d.ts.map +1 -0
- package/dist/modules/license/index.js +233 -0
- package/dist/modules/license/index.js.map +1 -0
- package/dist/modules/license/types.d.ts +222 -3
- package/dist/modules/license/types.d.ts.map +1 -1
- package/dist/modules/license/types.js +21 -2
- package/dist/modules/license/types.js.map +1 -1
- package/dist/modules/notifications/index.d.ts +40 -0
- package/dist/modules/notifications/index.d.ts.map +1 -0
- package/dist/modules/notifications/index.js +280 -0
- package/dist/modules/notifications/index.js.map +1 -0
- package/dist/modules/notifications/types.d.ts +152 -3
- package/dist/modules/notifications/types.d.ts.map +1 -1
- package/dist/modules/notifications/types.js +21 -2
- package/dist/modules/notifications/types.js.map +1 -1
- package/dist/server/create-sdk.d.ts +4 -0
- package/dist/server/create-sdk.d.ts.map +1 -1
- package/dist/server/create-sdk.js +19 -26
- package/dist/server/create-sdk.js.map +1 -1
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -1
- package/dist/types.d.ts +13 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formats/wdoc
|
|
3
|
+
* @description Type definitions for the WDOC (Workshop Document) format.
|
|
4
|
+
*
|
|
5
|
+
* WDOC is a block-based JSON document format compatible with the TipTap/ProseMirror
|
|
6
|
+
* document schema. It extends plain Markdown with rich content blocks (video, icon,
|
|
7
|
+
* table, callout, embed) and is the native format for Workshop's document editor.
|
|
8
|
+
*
|
|
9
|
+
* WDOC files are stored in the VFS with the `.wdoc` extension. The format is a
|
|
10
|
+
* strict superset of Markdown — all Markdown content can be represented as WDOC,
|
|
11
|
+
* but not vice versa.
|
|
12
|
+
*
|
|
13
|
+
* @example Reading a WDOC from the VFS
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const buf = await sdk.vfs.readFile('/projects/my-project/README.wdoc')
|
|
16
|
+
* const doc: WdocDocument = JSON.parse(buf.toString('utf-8'))
|
|
17
|
+
* console.log(doc.meta.title)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=wdoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wdoc.js","sourceRoot":"","sources":["../../../src/modules/formats/wdoc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formats/wquiz
|
|
3
|
+
* @description Type definitions for the WQUIZ (Workshop Quiz) document format.
|
|
4
|
+
*
|
|
5
|
+
* WQUIZ documents are portable assessment and quiz definitions. They support
|
|
6
|
+
* multiple-choice, true/false, short-answer, and essay question types, with
|
|
7
|
+
* per-question point values, optional explanations, and configurable scoring.
|
|
8
|
+
*
|
|
9
|
+
* WQUIZ files are stored in the VFS with the `.wquiz.json` extension. Academy
|
|
10
|
+
* uses them for module assessments; Workshop can render them for self-check quizzes.
|
|
11
|
+
*
|
|
12
|
+
* Question content supports rich formatting via WDOC blocks, enabling code
|
|
13
|
+
* snippets, images, and callouts inside questions and answer choices.
|
|
14
|
+
*
|
|
15
|
+
* @example Reading a WQUIZ from the VFS
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const buf = await sdk.vfs.readFile('/assessments/module-1.wquiz.json')
|
|
18
|
+
* const quiz: WquizDocument = JSON.parse(buf.toString('utf-8'))
|
|
19
|
+
* console.log(`${quiz.questions.length} questions, ${quiz.scoring.totalPoints} points`)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { WdocBlock } from './wdoc.js';
|
|
23
|
+
/**
|
|
24
|
+
* A WQUIZ assessment document.
|
|
25
|
+
*/
|
|
26
|
+
export interface WquizDocument {
|
|
27
|
+
/** Format discriminator. Always `'wquiz'`. */
|
|
28
|
+
format: 'wquiz';
|
|
29
|
+
/** Schema version. Currently `'1.0'`. */
|
|
30
|
+
version: '1.0';
|
|
31
|
+
/** Quiz title. */
|
|
32
|
+
title: string;
|
|
33
|
+
/** Optional description shown to the learner before starting. */
|
|
34
|
+
description?: string;
|
|
35
|
+
/** ISO 8601 creation timestamp. */
|
|
36
|
+
createdAt?: string;
|
|
37
|
+
/** ISO 8601 last-modified timestamp. */
|
|
38
|
+
updatedAt?: string;
|
|
39
|
+
/** Ordered list of questions. */
|
|
40
|
+
questions: WquizQuestion[];
|
|
41
|
+
/** Scoring configuration. */
|
|
42
|
+
scoring: WquizScoringRules;
|
|
43
|
+
/** Optional metadata for product-specific use (e.g. Academy module ID). */
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Question type discriminant.
|
|
48
|
+
*
|
|
49
|
+
* - `multiple-choice` — One or more correct answers from a fixed list
|
|
50
|
+
* - `true-false` — Binary correct/incorrect assertion
|
|
51
|
+
* - `short-answer` — Free-text response, graded by exact match or AI review
|
|
52
|
+
* - `essay` — Long-form free-text response, graded by human or AI review
|
|
53
|
+
*/
|
|
54
|
+
export type WquizQuestionType = 'multiple-choice' | 'true-false' | 'short-answer' | 'essay';
|
|
55
|
+
/**
|
|
56
|
+
* A single quiz question.
|
|
57
|
+
*/
|
|
58
|
+
export interface WquizQuestion {
|
|
59
|
+
/** Stable unique identifier for this question. */
|
|
60
|
+
id: string;
|
|
61
|
+
/** Question type. */
|
|
62
|
+
type: WquizQuestionType;
|
|
63
|
+
/** Plain-text question stem (used as fallback when `content` is absent). */
|
|
64
|
+
text: string;
|
|
65
|
+
/** Rich-text question content (WDOC blocks). When present, rendered instead of `text`. */
|
|
66
|
+
content?: WdocBlock[];
|
|
67
|
+
/** Available answer choices (for `multiple-choice` and `true-false` types). */
|
|
68
|
+
answers: WquizAnswer[];
|
|
69
|
+
/**
|
|
70
|
+
* IDs of correct answer choices.
|
|
71
|
+
* - For `multiple-choice`: one or more answer IDs.
|
|
72
|
+
* - For `true-false`: one of the two generated answer IDs.
|
|
73
|
+
* - For `short-answer`: the accepted text strings (exact match).
|
|
74
|
+
* - For `essay`: omit; graded externally.
|
|
75
|
+
*/
|
|
76
|
+
correct?: string[];
|
|
77
|
+
/** Explanation shown after the learner answers (Markdown or plain text). */
|
|
78
|
+
explanation?: string;
|
|
79
|
+
/** Point value for this question. Defaults to `1`. */
|
|
80
|
+
points?: number;
|
|
81
|
+
/** Whether to randomize the order of `answers` when presenting. Defaults to `false`. */
|
|
82
|
+
shuffleAnswers?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A single answer choice within a question.
|
|
86
|
+
*/
|
|
87
|
+
export interface WquizAnswer {
|
|
88
|
+
/** Stable unique identifier for this answer choice. */
|
|
89
|
+
id: string;
|
|
90
|
+
/** Plain-text answer label (used as fallback when `content` is absent). */
|
|
91
|
+
text: string;
|
|
92
|
+
/** Rich-text answer content (WDOC blocks). When present, rendered instead of `text`. */
|
|
93
|
+
content?: WdocBlock[];
|
|
94
|
+
/** Per-choice feedback shown after the learner answers. */
|
|
95
|
+
feedback?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Partial-credit weight (0–1) for this answer choice.
|
|
98
|
+
* Only used when `WquizScoringRules.allowPartialCredit` is `true`.
|
|
99
|
+
* A weight of `1.0` means full credit; `0.5` means half credit.
|
|
100
|
+
*/
|
|
101
|
+
weight?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Scoring rules for the entire quiz.
|
|
105
|
+
*/
|
|
106
|
+
export interface WquizScoringRules {
|
|
107
|
+
/** Minimum score (as a percentage 0–100) required to pass. */
|
|
108
|
+
passingScore: number;
|
|
109
|
+
/** Total possible points across all questions. */
|
|
110
|
+
totalPoints: number;
|
|
111
|
+
/** Whether partial credit is allowed on multi-select questions. Defaults to `false`. */
|
|
112
|
+
allowPartialCredit?: boolean;
|
|
113
|
+
/** Whether to penalize wrong answers (negative marking). Defaults to `false`. */
|
|
114
|
+
negativeMark?: boolean;
|
|
115
|
+
/** Maximum number of attempts allowed. `0` = unlimited. Defaults to `0`. */
|
|
116
|
+
maxAttempts?: number;
|
|
117
|
+
/** Time limit in seconds. `0` = no limit. Defaults to `0`. */
|
|
118
|
+
timeLimitSeconds?: number;
|
|
119
|
+
/** Whether to randomize question order when presenting. Defaults to `false`. */
|
|
120
|
+
shuffleQuestions?: boolean;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=wquiz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wquiz.d.ts","sourceRoot":"","sources":["../../../src/modules/formats/wquiz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAM1C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,MAAM,EAAE,OAAO,CAAA;IACf,yCAAyC;IACzC,OAAO,EAAE,KAAK,CAAA;IACd,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAw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EAAE,MAAM,CAAA;IACnB,wFAAwF;IACxF,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,iFAAiF;IACjF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formats/wquiz
|
|
3
|
+
* @description Type definitions for the WQUIZ (Workshop Quiz) document format.
|
|
4
|
+
*
|
|
5
|
+
* WQUIZ documents are portable assessment and quiz definitions. They support
|
|
6
|
+
* multiple-choice, true/false, short-answer, and essay question types, with
|
|
7
|
+
* per-question point values, optional explanations, and configurable scoring.
|
|
8
|
+
*
|
|
9
|
+
* WQUIZ files are stored in the VFS with the `.wquiz.json` extension. Academy
|
|
10
|
+
* uses them for module assessments; Workshop can render them for self-check quizzes.
|
|
11
|
+
*
|
|
12
|
+
* Question content supports rich formatting via WDOC blocks, enabling code
|
|
13
|
+
* snippets, images, and callouts inside questions and answer choices.
|
|
14
|
+
*
|
|
15
|
+
* @example Reading a WQUIZ from the VFS
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const buf = await sdk.vfs.readFile('/assessments/module-1.wquiz.json')
|
|
18
|
+
* const quiz: WquizDocument = JSON.parse(buf.toString('utf-8'))
|
|
19
|
+
* console.log(`${quiz.questions.length} questions, ${quiz.scoring.totalPoints} points`)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=wquiz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wquiz.js","sourceRoot":"","sources":["../../../src/modules/formats/wquiz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formats/wslide
|
|
3
|
+
* @description Type definitions for the WSLIDE (Workshop Slide Deck) document format.
|
|
4
|
+
*
|
|
5
|
+
* WSLIDE documents are portable slide presentations. Each slide contains rich
|
|
6
|
+
* content blocks (in WDOC format), a layout preset, optional background, and
|
|
7
|
+
* transition configuration.
|
|
8
|
+
*
|
|
9
|
+
* WSLIDE files are stored in the VFS with the `.wslide.json` extension and can
|
|
10
|
+
* be rendered by any Soulcraft product that embeds the Workshop slideshow viewer.
|
|
11
|
+
*
|
|
12
|
+
* Content blocks within each slide reuse the WDOC block types — the same block
|
|
13
|
+
* system that powers the Workshop document editor applies inside slides.
|
|
14
|
+
*
|
|
15
|
+
* @example Reading a WSLIDE document from the VFS
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const buf = await sdk.vfs.readFile('/presentations/onboarding.wslide.json')
|
|
18
|
+
* const deck: WslideDocument = JSON.parse(buf.toString('utf-8'))
|
|
19
|
+
* console.log(`${deck.slides.length} slides`)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { WdocBlock } from './wdoc.js';
|
|
23
|
+
/**
|
|
24
|
+
* Predefined layout preset for a slide.
|
|
25
|
+
*
|
|
26
|
+
* - `title` — Centered title + subtitle
|
|
27
|
+
* - `content` — Title bar + full content area below
|
|
28
|
+
* - `two-column` — Title bar + two equal-width content columns
|
|
29
|
+
* - `image-left` — Image panel on the left, content on the right
|
|
30
|
+
* - `image-right` — Content on the left, image panel on the right
|
|
31
|
+
* - `image-full` — Full-bleed background image with overlaid text
|
|
32
|
+
* - `blank` — No preset layout; positions are fully custom
|
|
33
|
+
*/
|
|
34
|
+
export type WslideLayout = 'title' | 'content' | 'two-column' | 'image-left' | 'image-right' | 'image-full' | 'blank';
|
|
35
|
+
/**
|
|
36
|
+
* Slide-to-slide transition animation.
|
|
37
|
+
*
|
|
38
|
+
* - `none` — Instant cut
|
|
39
|
+
* - `fade` — Cross-fade dissolve
|
|
40
|
+
* - `slide` / `slide-left` — Slide the new content in from the right
|
|
41
|
+
* - `slide-right` — Slide the new content in from the left
|
|
42
|
+
* - `slide-up` / `slide-down` — Vertical slide
|
|
43
|
+
* - `zoom` / `zoom-in` — Zoom in from center
|
|
44
|
+
* - `zoom-out` — Zoom out to reveal next slide
|
|
45
|
+
*/
|
|
46
|
+
export type WslideTransition = 'none' | 'fade' | 'slide' | 'slide-left' | 'slide-right' | 'slide-up' | 'slide-down' | 'zoom' | 'zoom-in' | 'zoom-out';
|
|
47
|
+
/**
|
|
48
|
+
* A WSLIDE presentation document.
|
|
49
|
+
*/
|
|
50
|
+
export interface WslideDocument {
|
|
51
|
+
/** Format discriminator. Always `'wslide'`. */
|
|
52
|
+
format: 'wslide';
|
|
53
|
+
/** Schema version. Currently `'1.0'`. */
|
|
54
|
+
version: '1.0';
|
|
55
|
+
/** Presentation title. */
|
|
56
|
+
title?: string;
|
|
57
|
+
/** Author name or user ID. */
|
|
58
|
+
author?: string;
|
|
59
|
+
/** ISO 8601 creation timestamp. */
|
|
60
|
+
createdAt?: string;
|
|
61
|
+
/** ISO 8601 last-modified timestamp. */
|
|
62
|
+
updatedAt?: string;
|
|
63
|
+
/** Ordered list of slides. */
|
|
64
|
+
slides: WslideSlide[];
|
|
65
|
+
/** Presentation-level display settings. */
|
|
66
|
+
config?: WslideConfig;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A single slide in a WSLIDE presentation.
|
|
70
|
+
*/
|
|
71
|
+
export interface WslideSlide {
|
|
72
|
+
/** Unique slide identifier (stable across reorders). */
|
|
73
|
+
id: string;
|
|
74
|
+
/** Slide title shown in the navigation/outline panel. */
|
|
75
|
+
title: string;
|
|
76
|
+
/** Rich content blocks (WDOC format). */
|
|
77
|
+
content: WdocBlock[];
|
|
78
|
+
/** Speaker notes (plain text or Markdown). Not shown to the audience. */
|
|
79
|
+
notes?: string;
|
|
80
|
+
/** Background override for this slide (overrides the presentation default). */
|
|
81
|
+
background?: WslideBackground;
|
|
82
|
+
/** Layout preset for this slide. */
|
|
83
|
+
layout?: WslideLayout;
|
|
84
|
+
/** Transition to use when advancing TO this slide. */
|
|
85
|
+
transition?: WslideTransition;
|
|
86
|
+
/** Arbitrary per-slide metadata for product-specific use. */
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Slide background configuration.
|
|
91
|
+
*/
|
|
92
|
+
export interface WslideBackground {
|
|
93
|
+
/** Background type. */
|
|
94
|
+
type: 'color' | 'gradient' | 'image';
|
|
95
|
+
/**
|
|
96
|
+
* Background value:
|
|
97
|
+
* - `color`: CSS hex or named color, e.g. `'#1a1a2e'`
|
|
98
|
+
* - `gradient`: CSS gradient string, e.g. `'linear-gradient(135deg, #1a1a2e, #16213e)'`
|
|
99
|
+
* - `image`: URL or VFS path to an image file
|
|
100
|
+
*/
|
|
101
|
+
value: string;
|
|
102
|
+
/** Opacity for image backgrounds (0–1). Defaults to 1. */
|
|
103
|
+
opacity?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Presentation-level display configuration.
|
|
107
|
+
*/
|
|
108
|
+
export interface WslideConfig {
|
|
109
|
+
/** Auto-advance interval in seconds. `0` = manual navigation. Defaults to `0`. */
|
|
110
|
+
autoAdvance?: number;
|
|
111
|
+
/** Show slide numbers in the viewer. Defaults to `true`. */
|
|
112
|
+
showSlideNumbers?: boolean;
|
|
113
|
+
/** Show a progress bar across the bottom. Defaults to `true`. */
|
|
114
|
+
showProgress?: boolean;
|
|
115
|
+
/** Show previous/next navigation arrows. Defaults to `true`. */
|
|
116
|
+
showNavigation?: boolean;
|
|
117
|
+
/** Show the speaker notes panel. Defaults to `false`. */
|
|
118
|
+
showNotes?: boolean;
|
|
119
|
+
/** Enable keyboard navigation (arrow keys, space). Defaults to `true`. */
|
|
120
|
+
keyboardNavigation?: boolean;
|
|
121
|
+
/** Loop back to the first slide after the last. Defaults to `false`. */
|
|
122
|
+
loop?: boolean;
|
|
123
|
+
/** Default transition for all slides (overridden per-slide by `WslideSlide.transition`). */
|
|
124
|
+
defaultTransition?: WslideTransition;
|
|
125
|
+
/** Slide aspect ratio. Defaults to `'16:9'`. */
|
|
126
|
+
aspectRatio?: '16:9' | '4:3' | '16:10' | 'auto';
|
|
127
|
+
/** Color theme. Defaults to `'auto'` (follows system preference). */
|
|
128
|
+
theme?: 'dark' | 'light' | 'auto';
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=wslide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wslide.d.ts","sourceRoot":"","sources":["../../../src/modules/formats/wslide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAM1C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,OAAO,CAAA;AAEX;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,MAAM,GACN,OAAO,GACP,YAAY,GACZ,aAAa,GACb,UAAU,GACV,YAAY,GACZ,MAAM,GACN,SAAS,GACT,UAAU,CAAA;AAMd;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,MAAM,EAAE,QAAQ,CAAA;IAChB,yCAAyC;IACzC,OAAO,EAAE,KAAK,CAAA;IACd,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,2CAA2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KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;CAClC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formats/wslide
|
|
3
|
+
* @description Type definitions for the WSLIDE (Workshop Slide Deck) document format.
|
|
4
|
+
*
|
|
5
|
+
* WSLIDE documents are portable slide presentations. Each slide contains rich
|
|
6
|
+
* content blocks (in WDOC format), a layout preset, optional background, and
|
|
7
|
+
* transition configuration.
|
|
8
|
+
*
|
|
9
|
+
* WSLIDE files are stored in the VFS with the `.wslide.json` extension and can
|
|
10
|
+
* be rendered by any Soulcraft product that embeds the Workshop slideshow viewer.
|
|
11
|
+
*
|
|
12
|
+
* Content blocks within each slide reuse the WDOC block types — the same block
|
|
13
|
+
* system that powers the Workshop document editor applies inside slides.
|
|
14
|
+
*
|
|
15
|
+
* @example Reading a WSLIDE document from the VFS
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const buf = await sdk.vfs.readFile('/presentations/onboarding.wslide.json')
|
|
18
|
+
* const deck: WslideDocument = JSON.parse(buf.toString('utf-8'))
|
|
19
|
+
* console.log(`${deck.slides.length} slides`)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=wslide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wslide.js","sourceRoot":"","sources":["../../../src/modules/formats/wslide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formats/wviz
|
|
3
|
+
* @description Type definitions for the WVIZ (Soulcraft Visualization) document format.
|
|
4
|
+
*
|
|
5
|
+
* WVIZ documents are portable, self-contained graph snapshots. They capture a
|
|
6
|
+
* filtered view of a Brainy knowledge graph — entities and edges — along with
|
|
7
|
+
* enough metadata to render them in any Soulcraft view (graph, mindmap, tree, etc.)
|
|
8
|
+
* without requiring a live Brainy connection.
|
|
9
|
+
*
|
|
10
|
+
* WVIZ files are stored in the VFS with the `.wviz.json` extension and can be
|
|
11
|
+
* exported from Workshop's Explore panel or generated programmatically.
|
|
12
|
+
*
|
|
13
|
+
* @example Reading a WVIZ document from the VFS
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const buf = await sdk.vfs.readFile('/visualizations/product-graph.wviz.json')
|
|
16
|
+
* const viz: WvizDocument = JSON.parse(buf.toString('utf-8'))
|
|
17
|
+
* console.log(viz.entities.length) // number of nodes
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The rendering mode to use when displaying a WVIZ document.
|
|
22
|
+
*
|
|
23
|
+
* - `graph` — Force-directed node-link diagram (default)
|
|
24
|
+
* - `mindmap` — Radial tree rooted at a central concept
|
|
25
|
+
* - `tree` — Hierarchical top-down tree layout
|
|
26
|
+
* - `tapestry` — Narrative woven-thread visualization (Soulcraft-specific)
|
|
27
|
+
* - `workflow` — Left-to-right directed flow
|
|
28
|
+
* - `board` — Kanban-style column layout
|
|
29
|
+
* - `list` — Flat list view with metadata columns
|
|
30
|
+
* - `table` — Sortable tabular grid
|
|
31
|
+
* - `gallery` — Card grid with thumbnails
|
|
32
|
+
* - `calendar` — Date-based calendar view
|
|
33
|
+
* - `timeline` — Chronological timeline
|
|
34
|
+
*/
|
|
35
|
+
export type WvizViewType = 'graph' | 'mindmap' | 'tree' | 'tapestry' | 'workflow' | 'board' | 'list' | 'table' | 'gallery' | 'calendar' | 'timeline';
|
|
36
|
+
/**
|
|
37
|
+
* A self-contained visualization document.
|
|
38
|
+
*
|
|
39
|
+
* Entities and edges are snapshotted at export time. They are NOT live references
|
|
40
|
+
* to a Brainy graph — rendering does not require a Brainy connection.
|
|
41
|
+
*/
|
|
42
|
+
export interface WvizDocument {
|
|
43
|
+
/** Format discriminator. Always `'wviz'`. */
|
|
44
|
+
format: 'wviz';
|
|
45
|
+
/** Schema version. Currently `'1.0'`. */
|
|
46
|
+
version: '1.0';
|
|
47
|
+
/** Human-readable document title. */
|
|
48
|
+
title?: string;
|
|
49
|
+
/** Which view type to render this document with. */
|
|
50
|
+
viewType: WvizViewType;
|
|
51
|
+
/**
|
|
52
|
+
* View-specific configuration (layout algorithm, color scheme, label settings, etc.).
|
|
53
|
+
* Shape is view-type-specific and interpreted by the rendering component.
|
|
54
|
+
*/
|
|
55
|
+
viewConfig: Record<string, unknown>;
|
|
56
|
+
/** Snapshotted entity list. These are not live Brainy entity references. */
|
|
57
|
+
entities: WvizEntity[];
|
|
58
|
+
/** Edges connecting entities. */
|
|
59
|
+
edges: WvizEdge[];
|
|
60
|
+
/**
|
|
61
|
+
* Saved node positions for force-directed layouts.
|
|
62
|
+
* Key is entity ID; value is `{ x, y }` in canvas coordinates.
|
|
63
|
+
* When present, the layout is pinned rather than recalculated on each render.
|
|
64
|
+
*/
|
|
65
|
+
positions?: Record<string, {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Provenance metadata describing where this snapshot came from.
|
|
71
|
+
* Recorded at export time; not updated when entities change in Brainy.
|
|
72
|
+
*/
|
|
73
|
+
snapshot?: WvizSnapshot;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A single entity (node) in a WVIZ document.
|
|
77
|
+
*/
|
|
78
|
+
export interface WvizEntity {
|
|
79
|
+
/** Unique identifier within this document (matches the Brainy entity ID at export time). */
|
|
80
|
+
id: string;
|
|
81
|
+
/** Brainy NounType string (e.g. `'concept'`, `'person'`, `'task'`). */
|
|
82
|
+
type: string;
|
|
83
|
+
/** Human-readable name shown as the node label. */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Additional metadata fields captured at export time. */
|
|
86
|
+
metadata?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A directed edge (relationship) between two entities in a WVIZ document.
|
|
90
|
+
*/
|
|
91
|
+
export interface WvizEdge {
|
|
92
|
+
/** Source entity ID. Must match a `WvizEntity.id` in the same document. */
|
|
93
|
+
from: string;
|
|
94
|
+
/** Target entity ID. Must match a `WvizEntity.id` in the same document. */
|
|
95
|
+
to: string;
|
|
96
|
+
/** Brainy VerbType string describing the relationship (e.g. `'relatesTo'`, `'blocks'`). */
|
|
97
|
+
verb: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Provenance metadata for a WVIZ snapshot.
|
|
101
|
+
*/
|
|
102
|
+
export interface WvizSnapshot {
|
|
103
|
+
/** ISO 8601 timestamp when this snapshot was taken. */
|
|
104
|
+
createdAt: string;
|
|
105
|
+
/** Workspace ID the entities were exported from. */
|
|
106
|
+
sourceWorkspace?: string;
|
|
107
|
+
/** Collection or workbench name at time of export. */
|
|
108
|
+
sourceWorkbench?: string;
|
|
109
|
+
/** Total entity count in the source (may differ from `entities.length` after filtering). */
|
|
110
|
+
entityCount: number;
|
|
111
|
+
/** Total edge count in the source. */
|
|
112
|
+
edgeCount: number;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=wviz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wviz.d.ts","sourceRoot":"","sources":["../../../src/modules/formats/wviz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,SAAS,GACT,MAAM,GACN,UAAU,GACV,UAAU,GACV,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,UAAU,GACV,UAAU,CAAA;AAMd;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,OAAO,EAAE,KAAK,CAAA;IACd,qCAAqC;IACrC,KAAK,CAA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
* @description Type definitions for the WVIZ (Soulcraft Visualization) document format.
|
|
4
|
+
*
|
|
5
|
+
* WVIZ documents are portable, self-contained graph snapshots. They capture a
|
|
6
|
+
* filtered view of a Brainy knowledge graph — entities and edges — along with
|
|
7
|
+
* enough metadata to render them in any Soulcraft view (graph, mindmap, tree, etc.)
|
|
8
|
+
* without requiring a live Brainy connection.
|
|
9
|
+
*
|
|
10
|
+
* WVIZ files are stored in the VFS with the `.wviz.json` extension and can be
|
|
11
|
+
* exported from Workshop's Explore panel or generated programmatically.
|
|
12
|
+
*
|
|
13
|
+
* @example Reading a WVIZ document from the VFS
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const buf = await sdk.vfs.readFile('/visualizations/product-graph.wviz.json')
|
|
16
|
+
* const viz: WvizDocument = JSON.parse(buf.toString('utf-8'))
|
|
17
|
+
* console.log(viz.entities.length) // number of nodes
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=wviz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wviz.js","sourceRoot":"","sources":["../../../src/modules/formats/wviz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module kits
|
|
3
|
+
* @description Factory for sdk.kits.* — the Soulcraft kit registry module.
|
|
4
|
+
*
|
|
5
|
+
* Provides read-only access to kit configurations from the `@soulcraft/kits`
|
|
6
|
+
* package. The package is an optional peer dependency loaded lazily via
|
|
7
|
+
* `createRequire` so that the SDK compiles and runs without it installed;
|
|
8
|
+
* calls gracefully return `null` / empty array when it is absent.
|
|
9
|
+
*
|
|
10
|
+
* The factory accepts an optional `bundledRegistry` override (used in tests)
|
|
11
|
+
* to inject a mock registry without needing the real package.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createKitsModule } from '@soulcraft/sdk/server'
|
|
16
|
+
*
|
|
17
|
+
* const kits = createKitsModule()
|
|
18
|
+
* const kit = await kits.load('wicks-and-whiskers')
|
|
19
|
+
* console.log(kit?.name) // "Wicks & Whiskers"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { KitsModule, CreateKitsModuleOptions } from './types.js';
|
|
23
|
+
/**
|
|
24
|
+
* Create the `sdk.kits.*` module.
|
|
25
|
+
*
|
|
26
|
+
* @param options - Optional overrides, primarily for testing.
|
|
27
|
+
* @returns A `KitsModule` backed by the `@soulcraft/kits` registry.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // In production:
|
|
32
|
+
* const kits = createKitsModule()
|
|
33
|
+
*
|
|
34
|
+
* // In tests — inject a mock registry to avoid the peer dep:
|
|
35
|
+
* const kits = createKitsModule({
|
|
36
|
+
* bundledRegistry: { 'test-kit': { id: 'test-kit', name: 'Test Kit', ... } }
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createKitsModule(options?: CreateKitsModuleOptions): KitsModule;
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/kits/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAsB,UAAU,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AA8BzF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAkBlF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module kits
|
|
3
|
+
* @description Factory for sdk.kits.* — the Soulcraft kit registry module.
|
|
4
|
+
*
|
|
5
|
+
* Provides read-only access to kit configurations from the `@soulcraft/kits`
|
|
6
|
+
* package. The package is an optional peer dependency loaded lazily via
|
|
7
|
+
* `createRequire` so that the SDK compiles and runs without it installed;
|
|
8
|
+
* calls gracefully return `null` / empty array when it is absent.
|
|
9
|
+
*
|
|
10
|
+
* The factory accepts an optional `bundledRegistry` override (used in tests)
|
|
11
|
+
* to inject a mock registry without needing the real package.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createKitsModule } from '@soulcraft/sdk/server'
|
|
16
|
+
*
|
|
17
|
+
* const kits = createKitsModule()
|
|
18
|
+
* const kit = await kits.load('wicks-and-whiskers')
|
|
19
|
+
* console.log(kit?.name) // "Wicks & Whiskers"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { createRequire } from 'node:module';
|
|
23
|
+
// createRequire enables CJS-style require() inside an ESM module — the only
|
|
24
|
+
// reliable way to conditionally load optional peer dependencies in Node/Bun ESM.
|
|
25
|
+
const _require = createRequire(import.meta.url);
|
|
26
|
+
// Module-level cache — loaded once per process, not per SDK instance.
|
|
27
|
+
let _registryCache = undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Load the kit registry from the installed `@soulcraft/kits` package.
|
|
30
|
+
* Returns `null` when the package is not installed, allowing callers to
|
|
31
|
+
* degrade gracefully rather than throwing.
|
|
32
|
+
*/
|
|
33
|
+
function _getBundledRegistry() {
|
|
34
|
+
if (_registryCache !== undefined)
|
|
35
|
+
return _registryCache;
|
|
36
|
+
try {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
const kits = _require('@soulcraft/kits');
|
|
39
|
+
_registryCache = kits.kitRegistry ?? null;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
_registryCache = null;
|
|
43
|
+
}
|
|
44
|
+
return _registryCache;
|
|
45
|
+
}
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
// Factory
|
|
48
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
49
|
+
/**
|
|
50
|
+
* Create the `sdk.kits.*` module.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Optional overrides, primarily for testing.
|
|
53
|
+
* @returns A `KitsModule` backed by the `@soulcraft/kits` registry.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // In production:
|
|
58
|
+
* const kits = createKitsModule()
|
|
59
|
+
*
|
|
60
|
+
* // In tests — inject a mock registry to avoid the peer dep:
|
|
61
|
+
* const kits = createKitsModule({
|
|
62
|
+
* bundledRegistry: { 'test-kit': { id: 'test-kit', name: 'Test Kit', ... } }
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function createKitsModule(options = {}) {
|
|
67
|
+
const getRegistry = options.bundledRegistry !== undefined
|
|
68
|
+
? () => options.bundledRegistry ?? null
|
|
69
|
+
: _getBundledRegistry;
|
|
70
|
+
return {
|
|
71
|
+
async load(kitId) {
|
|
72
|
+
const registry = getRegistry();
|
|
73
|
+
if (!registry)
|
|
74
|
+
return null;
|
|
75
|
+
return registry[kitId] ?? null;
|
|
76
|
+
},
|
|
77
|
+
async list() {
|
|
78
|
+
const registry = getRegistry();
|
|
79
|
+
if (!registry)
|
|
80
|
+
return [];
|
|
81
|
+
return Object.values(registry);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/kits/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,4EAA4E;AAC5E,iFAAiF;AACjF,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE/C,sEAAsE;AACtE,IAAI,cAAc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