@bitflow/core 0.6.0 → 0.7.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/bits.d.ts DELETED
@@ -1,128 +0,0 @@
1
- import { ForwardRefExoticComponent, ReactElement, RefAttributes } from "react";
2
- import { ZodSchema } from "zod";
3
- import { DoResult } from "./do";
4
- export interface Action {
5
- type: string;
6
- payload?: any;
7
- }
8
- export interface FeedbackMessage {
9
- message: string;
10
- severity: "error" | "warning" | "info" | "success";
11
- }
12
- export interface TitleProps<T extends Bitflow.Title> {
13
- title: Pick<T, "view" | "subtype">;
14
- }
15
- export interface TitleViewFormProps {
16
- name: string;
17
- }
18
- export interface TitleBit<T extends Bitflow.Title = any> {
19
- ViewForm: (props: TitleViewFormProps) => ReactElement | null;
20
- Title: (props: TitleProps<T>) => ReactElement | null;
21
- TitleSchema: ZodSchema<T>;
22
- useInformation: () => {
23
- name: string;
24
- description: string;
25
- example: T;
26
- };
27
- }
28
- export interface InputProps<I extends Bitflow.Input> {
29
- input: Pick<I, "view" | "subtype">;
30
- }
31
- export interface InputViewFormProps {
32
- name: string;
33
- }
34
- export interface InputBit<I extends Bitflow.Input = any> {
35
- ViewForm: (props: InputViewFormProps) => ReactElement | null;
36
- Input: (props: InputProps<I>) => ReactElement | null;
37
- useInformation: () => {
38
- name: string;
39
- description: string;
40
- example: I;
41
- };
42
- InputSchema: ZodSchema<I>;
43
- }
44
- export interface StartProps<S extends Bitflow.Start> {
45
- start: Pick<S, "view" | "subtype">;
46
- }
47
- export interface StartViewFormProps {
48
- name: string;
49
- }
50
- export interface StartBit<S extends Bitflow.Start = any> {
51
- ViewForm: (props: StartViewFormProps) => ReactElement | null;
52
- Start: (props: StartProps<S>) => ReactElement | null;
53
- StartSchema: ZodSchema<S>;
54
- useInformation: () => {
55
- name: string;
56
- description: string;
57
- example: S;
58
- };
59
- }
60
- export interface EndProps<E extends Bitflow.End> {
61
- end: Pick<E, "view" | "subtype">;
62
- getResult: () => Promise<DoResult>;
63
- }
64
- export interface EndViewFormProps {
65
- name: string;
66
- }
67
- export interface EndBit<E extends Bitflow.End = any> {
68
- ViewForm: (props: EndViewFormProps) => ReactElement | null;
69
- End: (props: EndProps<E>) => ReactElement | null;
70
- useInformation: () => {
71
- name: string;
72
- description: string;
73
- example: E;
74
- };
75
- EndSchema: ZodSchema<E>;
76
- }
77
- export interface TaskProps<T extends Bitflow.Task, R extends Bitflow.TaskResult, A extends Bitflow.TaskAnswer, Act extends Action> {
78
- mode: "default" | "recording" | "result";
79
- task: Pick<T, "view" | "subtype">;
80
- result?: R;
81
- answer?: A;
82
- onChange?: (value: A) => void;
83
- onAction?: (action: Act) => void;
84
- }
85
- export interface TaskRef<Act> {
86
- dispatch: (action: Act) => void;
87
- }
88
- export interface TaskEvaluationFormProps {
89
- name: string;
90
- }
91
- export interface TaskViewFormProps {
92
- name: string;
93
- }
94
- export interface TaskFeedbackFormProps {
95
- name: string;
96
- }
97
- export interface TaskStatisticProps<S extends Bitflow.TaskStatistic, T extends Bitflow.Task> {
98
- statistic: S;
99
- task: T;
100
- }
101
- export interface TaskEvaluateParams<A extends Bitflow.TaskAnswer, T extends Bitflow.Task> {
102
- answer?: A;
103
- task: T;
104
- }
105
- export declare type Evaluate<A extends Bitflow.TaskAnswer = Bitflow.TaskAnswer, T extends Bitflow.Task = Bitflow.Task, R extends Bitflow.TaskResult = Bitflow.TaskResult> = ({ answer, task }: TaskEvaluateParams<A, T>) => Promise<R>;
106
- export interface UpdateTaskStatisticParams<S extends Bitflow.TaskStatistic, A extends Bitflow.TaskAnswer, T extends Bitflow.Task, R extends Bitflow.TaskResult> {
107
- statistic?: S;
108
- answer: A;
109
- task: T;
110
- result?: R;
111
- }
112
- export declare type UpdateTaskStatistic<S extends Bitflow.TaskStatistic, A extends Bitflow.TaskAnswer, T extends Bitflow.Task, R extends Bitflow.TaskResult> = ({ statistic, answer, task, result, }: UpdateTaskStatisticParams<S, A, T, R>) => Promise<S>;
113
- export interface TaskBit<T extends Bitflow.Task = any, A extends Bitflow.TaskAnswer = any, R extends Bitflow.TaskResult = any, S extends Bitflow.TaskStatistic = any, Act extends Action = any> {
114
- ViewForm: (props: TaskViewFormProps) => ReactElement | null;
115
- EvaluationForm: (props: TaskEvaluationFormProps) => ReactElement | null;
116
- FeedbackForm: (props: TaskFeedbackFormProps) => ReactElement | null;
117
- Task: ForwardRefExoticComponent<TaskProps<T, R, A, Act> & RefAttributes<TaskRef<Act>>>;
118
- Statistic: (props: TaskStatisticProps<S, T>) => ReactElement | null;
119
- updateStatistic: UpdateTaskStatistic<S, A, T, R>;
120
- TaskSchema: ZodSchema<T>;
121
- useInformation: () => {
122
- name: string;
123
- description: string;
124
- example: T;
125
- };
126
- evaluate: Evaluate<A, T, R>;
127
- }
128
- export declare const makeEvaluate: (evaluateMap: Record<string, Evaluate>) => Evaluate;
@@ -1,150 +0,0 @@
1
- import * as z from "zod";
2
- export declare const FeedbackMessageSchema: z.ZodObject<{
3
- message: z.ZodString;
4
- severity: z.ZodEnum<["error", "warning", "info", "success"]>;
5
- }, "strip", z.ZodTypeAny, {
6
- message: string;
7
- severity: "error" | "warning" | "info" | "success";
8
- }, {
9
- message: string;
10
- severity: "error" | "warning" | "info" | "success";
11
- }>;
12
- export declare const TaskSchema: z.ZodObject<{
13
- name: z.ZodString;
14
- description: z.ZodOptional<z.ZodString>;
15
- subtype: z.ZodString;
16
- view: z.ZodRecord<z.ZodString, z.ZodAny>;
17
- evaluation: z.ZodObject<{
18
- mode: z.ZodEnum<["auto", "skip", "manual"]>;
19
- enableRetry: z.ZodBoolean;
20
- showFeedback: z.ZodBoolean;
21
- }, "strip", z.ZodTypeAny, {
22
- mode: "auto" | "manual" | "skip";
23
- enableRetry: boolean;
24
- showFeedback: boolean;
25
- }, {
26
- mode: "auto" | "manual" | "skip";
27
- enableRetry: boolean;
28
- showFeedback: boolean;
29
- }>;
30
- feedback: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
31
- }, "strip", z.ZodTypeAny, {
32
- description?: string | undefined;
33
- feedback?: Record<string, any> | undefined;
34
- view: Record<string, any>;
35
- subtype: string;
36
- name: string;
37
- evaluation: {
38
- mode: "auto" | "manual" | "skip";
39
- enableRetry: boolean;
40
- showFeedback: boolean;
41
- };
42
- }, {
43
- description?: string | undefined;
44
- feedback?: Record<string, any> | undefined;
45
- view: Record<string, any>;
46
- subtype: string;
47
- name: string;
48
- evaluation: {
49
- mode: "auto" | "manual" | "skip";
50
- enableRetry: boolean;
51
- showFeedback: boolean;
52
- };
53
- }>;
54
- export declare const TaskStatisticSchema: z.ZodObject<{
55
- subtype: z.ZodString;
56
- count: z.ZodNumber;
57
- }, "strip", z.ZodTypeAny, {
58
- subtype: string;
59
- count: number;
60
- }, {
61
- subtype: string;
62
- count: number;
63
- }>;
64
- export declare const TaskAnswerSchema: z.ZodObject<{
65
- subtype: z.ZodString;
66
- }, "strip", z.ZodTypeAny, {
67
- subtype: string;
68
- }, {
69
- subtype: string;
70
- }>;
71
- export declare const TaskResultSchema: z.ZodObject<{
72
- subtype: z.ZodString;
73
- state: z.ZodEnum<["unknown", "manual", "correct", "wrong"]>;
74
- allowRetry: z.ZodOptional<z.ZodBoolean>;
75
- feedback: z.ZodAny;
76
- }, "strip", z.ZodTypeAny, {
77
- feedback?: any;
78
- allowRetry?: boolean | undefined;
79
- subtype: string;
80
- state: "manual" | "unknown" | "correct" | "wrong";
81
- }, {
82
- feedback?: any;
83
- allowRetry?: boolean | undefined;
84
- subtype: string;
85
- state: "manual" | "unknown" | "correct" | "wrong";
86
- }>;
87
- export declare const InputSchema: z.ZodObject<{
88
- name: z.ZodString;
89
- description: z.ZodString;
90
- subtype: z.ZodString;
91
- view: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
92
- }, "strip", z.ZodTypeAny, {
93
- view: {};
94
- subtype: string;
95
- name: string;
96
- description: string;
97
- }, {
98
- view: {};
99
- subtype: string;
100
- name: string;
101
- description: string;
102
- }>;
103
- export declare const TitleSchema: z.ZodObject<{
104
- name: z.ZodString;
105
- description: z.ZodString;
106
- subtype: z.ZodString;
107
- view: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
108
- }, "strip", z.ZodTypeAny, {
109
- view: {};
110
- subtype: string;
111
- name: string;
112
- description: string;
113
- }, {
114
- view: {};
115
- subtype: string;
116
- name: string;
117
- description: string;
118
- }>;
119
- export declare const StartSchema: z.ZodObject<{
120
- name: z.ZodString;
121
- description: z.ZodString;
122
- subtype: z.ZodString;
123
- view: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
124
- }, "strip", z.ZodTypeAny, {
125
- view: {};
126
- subtype: string;
127
- name: string;
128
- description: string;
129
- }, {
130
- view: {};
131
- subtype: string;
132
- name: string;
133
- description: string;
134
- }>;
135
- export declare const EndSchema: z.ZodObject<{
136
- name: z.ZodString;
137
- description: z.ZodString;
138
- subtype: z.ZodString;
139
- view: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
140
- }, "strip", z.ZodTypeAny, {
141
- view: {};
142
- subtype: string;
143
- name: string;
144
- description: string;
145
- }, {
146
- view: {};
147
- subtype: string;
148
- name: string;
149
- description: string;
150
- }>;
package/dist/do.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { InteractiveFlowPublicNode } from "./flow";
2
- export interface DoBaseTry {
3
- node: InteractiveFlowPublicNode;
4
- startDate: Date;
5
- try: number;
6
- status: string;
7
- }
8
- export interface DoStartedTry extends DoBaseTry {
9
- status: "started";
10
- }
11
- export declare const isDoStartedTry: (d: DoTry) => d is DoStartedTry;
12
- export interface DoFinishedTry extends DoBaseTry {
13
- status: "finished";
14
- endDate: Date;
15
- answer?: Bitflow.TaskAnswer;
16
- result?: Bitflow.TaskResult;
17
- }
18
- export declare const isDoFinishedTry: (d: DoTry) => d is DoFinishedTry;
19
- export interface DoSkippedTry extends DoBaseTry {
20
- status: "skipped";
21
- evaluation: {
22
- mode: "auto" | "manual" | "skip";
23
- };
24
- endDate: Date;
25
- }
26
- export declare const isDoSkippedTry: (d: DoTry) => d is DoSkippedTry;
27
- export declare type DoTry = DoStartedTry | DoSkippedTry | DoFinishedTry;
28
- export declare const skipDoTry: (doResult: DoResult, evaluation?: DoSkippedTry["evaluation"]) => DoResult;
29
- export interface DoResult {
30
- points: number;
31
- maxPoints: number;
32
- startDate: Date;
33
- endDate: Date;
34
- tries: DoTry[];
35
- }
36
- export declare const finishDoTry: (doResult: DoResult, answer?: Bitflow.TaskAnswer | undefined, result?: Bitflow.TaskResult | undefined) => DoResult;
37
- export declare const retryDoTry: (doResult: DoResult) => DoResult;