@project-sunbird/sunbird-questionset-editor-web-component-react 0.1.20 → 0.1.21

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 (43) hide show
  1. package/dist/api/content.d.ts +4 -0
  2. package/dist/api/dynamicAssessApi.test.d.ts +1 -0
  3. package/dist/api/hierarchy.d.ts +2 -0
  4. package/dist/api/urls.d.ts +1 -0
  5. package/dist/components/SparkMetaForm/MinQuestionsPanel.d.ts +13 -0
  6. package/dist/components/SparkMetaForm/MinQuestionsPanel.test.d.ts +1 -0
  7. package/dist/components/SparkMetaForm/SparkMetaForm.d.ts +3 -1
  8. package/dist/components/SparkMetaForm/SparkMetaForm.test.d.ts +1 -0
  9. package/dist/components/shared/GeneratingOverlay.d.ts +6 -0
  10. package/dist/components/shared/GeneratingOverlay.test.d.ts +1 -0
  11. package/dist/components/shared/RegenerateButton.d.ts +4 -0
  12. package/dist/components/shared/StaleSettingsBanner.d.ts +8 -0
  13. package/dist/hooks/checkPool.test.d.ts +1 -0
  14. package/dist/hooks/useDynamicSkillField.d.ts +2 -0
  15. package/dist/hooks/useFramework.d.ts +13 -0
  16. package/dist/hooks/useFramework.test.d.ts +1 -0
  17. package/dist/hooks/useIsDynamicAssess.d.ts +2 -0
  18. package/dist/hooks/useRefreshQuestionSetBody.d.ts +62 -0
  19. package/dist/hooks/useRefreshQuestionSetBody.flow.test.d.ts +1 -0
  20. package/dist/hooks/useRefreshQuestionSetBody.test.d.ts +1 -0
  21. package/dist/hooks/useSaveHierarchy.d.ts +5 -0
  22. package/dist/hooks/useSaveHierarchy.test.d.ts +1 -0
  23. package/dist/hooks/useSaveQuestion.test.d.ts +1 -0
  24. package/dist/index.js +8339 -7728
  25. package/dist/locales/label.config.ar.json.d.ts +48 -3
  26. package/dist/locales/label.config.fr.json.d.ts +48 -3
  27. package/dist/locales/label.config.hi.json.d.ts +53 -0
  28. package/dist/locales/label.config.json.d.ts +48 -3
  29. package/dist/locales/label.config.pt.json.d.ts +48 -3
  30. package/dist/store/question.store.d.ts +2 -0
  31. package/dist/style.css +1 -1
  32. package/dist/types/editor.d.ts +3 -0
  33. package/dist/types/question.d.ts +2 -1
  34. package/dist/utils/context.d.ts +8 -0
  35. package/dist/utils/difficultyLevelField.d.ts +7 -0
  36. package/dist/utils/difficultyLevelField.test.d.ts +1 -0
  37. package/dist/utils/difficultyTarget.d.ts +8 -0
  38. package/dist/utils/dynamicAssessDraw.d.ts +19 -0
  39. package/dist/utils/dynamicAssessDraw.test.d.ts +1 -0
  40. package/dist/utils/dynamicAssessLabels.test.d.ts +1 -0
  41. package/dist/utils/poolPlan.d.ts +18 -0
  42. package/dist/utils/poolPlan.test.d.ts +1 -0
  43. package/package.json +1 -1
@@ -11,3 +11,7 @@ export declare function compositeSearch(params: {
11
11
  content: IContent[];
12
12
  count: number;
13
13
  }>;
14
+ /** Live Question counts per skill x difficultyLevel, the availability the job allocates from (same channel + category filters, no visibility filter). */
15
+ export declare function questionBucketCounts(categoryField: string, skills: string[], channel?: string): Promise<Record<string, Record<'E' | 'M' | 'D', number>>>;
16
+ /** Live Question counts per skill, with the same filters knowlg-service uses to reject a refresh (no channel, any level). */
17
+ export declare function questionSkillCounts(categoryField: string, skills: string[]): Promise<Record<string, number>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -30,5 +30,7 @@ export declare function addQuestionsToSet(rootId: string, collectionId: string |
30
30
  */
31
31
  export declare function removeQuestionsFromSet(rootId: string, collectionId: string | null, children: string[]): Promise<void>;
32
32
  export declare function publishContent(contentId: string, lastPublishedBy?: string): Promise<void>;
33
+ /** POST questionset/v5/refresh/body/:id: queues pool-based question selection; a pool rejection throws like any other call. */
34
+ export declare function refreshQuestionSetBody(contentId: string): Promise<void>;
33
35
  export declare function sendForReview(contentId: string): Promise<void>;
34
36
  export declare function rejectContent(contentId: string, comment: string): Promise<void>;
@@ -19,6 +19,7 @@ export declare const URLS: {
19
19
  readonly reject: "questionset/v2/reject";
20
20
  readonly publish: "questionset/v2/publish";
21
21
  readonly systemUpdate: "questionset/v5/system/update";
22
+ readonly refreshBody: "questionset/v5/refresh/body";
22
23
  readonly commentRead: "questionset/v2/comment/read";
23
24
  readonly commentUpdate: "questionset/v2/comment/update";
24
25
  /** Extra read fields absent from the hierarchy response. */
@@ -0,0 +1,13 @@
1
+ import { DifficultyTarget } from '../../utils/difficultyTarget';
2
+ type Label = (key: string, fallback: string) => string;
3
+ /** The fixed example under "See an example": 2 skills and the set's own minCriteria per level, independent of what the creator entered. */
4
+ export declare function exampleLines(minCriteria: number, L: Label): {
5
+ intro: string;
6
+ points: string[];
7
+ };
8
+ /** Dynamic Assess: the set's own per-skill minimum against the live Difficulty Target, once a skill is selected; Save is still blocked by the pool check. */
9
+ export declare function MinQuestionsPanel({ values, target }: {
10
+ values: Record<string, unknown>;
11
+ target: DifficultyTarget;
12
+ }): import("react").JSX.Element | null;
13
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { ICategoryField } from '../../api/categoryDefinition';
3
+ import { toDifficultyTarget, DifficultyTarget } from '../../utils/difficultyTarget';
3
4
  /** Shape of a single framework term entry. */
4
5
  export interface FrameworkTerm {
5
6
  name: string;
@@ -58,6 +59,7 @@ export interface SparkMetaFormProps {
58
59
  */
59
60
  isRoot?: boolean;
60
61
  }
62
+ export { toDifficultyTarget, type DifficultyTarget };
61
63
  /** Exported so callers (e.g. ContextualEditor's tab bar) can check whether a
62
64
  * given tab's section has any required field, using the exact same
63
65
  * matching rule the tab's own <SparkMetaForm section="..."/> render uses.
@@ -71,7 +73,7 @@ export interface SelectOption {
71
73
  value: string;
72
74
  label: string;
73
75
  }
74
- export declare function adaptFieldsForFramework(fields: ICategoryField[], frameworkTerms: Map<string, FrameworkTerm[]> | undefined, categoryOrder: string[] | undefined, isRoot: boolean): ICategoryField[];
76
+ export declare function adaptFieldsForFramework(fields: ICategoryField[], frameworkTerms: Map<string, FrameworkTerm[]> | undefined, categoryOrder: string[] | undefined, isRoot: boolean, isDynamicAssess: boolean): ICategoryField[];
75
77
  export interface SingleSelectDropdownProps {
76
78
  fieldId: string;
77
79
  value: string;
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ /** Blocking loader shown while Dynamic Assess questions generate, so a stale tree can't be edited and saved over the job's result. */
3
+ export declare function GeneratingOverlay({ open }: {
4
+ open: boolean;
5
+ }): React.JSX.Element | null;
6
+ export default GeneratingOverlay;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ /** Re-rolls a Dynamic set's pool with unchanged settings. */
3
+ export declare function RegenerateButton(): React.JSX.Element;
4
+ export default RegenerateButton;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ /** Explains why review is blocked when the saved Skill/Difficulty Target don't match the questions (e.g. a failed or older generation); Save & Generate is the fix. */
3
+ export declare function StaleSettingsBanner({ open, canRegenerate, pending }: {
4
+ open: boolean;
5
+ canRegenerate: boolean;
6
+ pending?: boolean;
7
+ }): React.JSX.Element | null;
8
+ export default StaleSettingsBanner;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ /** The field Dynamic pool questions carry their skill in: the framework's deepest category (e.g. "topic" on BMGS), else "skill". */
2
+ export declare function useDynamicSkillField(): string;
@@ -1,4 +1,17 @@
1
1
  import { IFramework, ITerm } from '../types/framework';
2
+ import { IEditorConfig } from '../types/editor';
3
+ /** The backend's skill category rule (knowlg-service and the knowlg-publish job): highest `index`, a missing index counts as 0, the first wins on ties. */
4
+ export declare function highestIndexCategoryCode(categories: Array<{
5
+ code: string;
6
+ index?: number;
7
+ }>): string | undefined;
8
+ /** Category codes by ascending `index`, missing last; for Dynamic Assess the backend's skill category is moved last, since Skill binds to the last entry. */
9
+ export declare function orderCategoryCodes(categories: Array<{
10
+ code: string;
11
+ index?: number;
12
+ }>, isDynamicAssess: boolean): string[];
13
+ /** The set's framework id with useFramework's precedence: a live pick, then the set's own, then the host's context/config; shared so Dynamic Assess reads the same framework the form shows. */
14
+ export declare function resolveFrameworkId(config: IEditorConfig | null | undefined, rootFramework: unknown, liveFramework?: string | null): string;
2
15
  /**
3
16
  * @param overrideFrameworkId - Resolves categories against this framework
4
17
  * instead of the root/live one, fully locally to the caller — e.g. a
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Whether the open set is a Dynamic QuestionSet, from the host config or, when the host omits it, the loaded root. */
2
+ export declare function useIsDynamicAssess(): boolean;
@@ -0,0 +1,62 @@
1
+ import { SaveOutcome } from './useSaveHierarchy';
2
+ import { DifficultyTarget } from '../utils/difficultyTarget';
3
+ import { DynamicAssessSettings } from '../utils/dynamicAssessDraw';
4
+ import { INode } from '../types/editor';
5
+ import { IFramework } from '../types/framework';
6
+ type Buckets = Record<string, Record<'E' | 'M' | 'D', number>>;
7
+ /** Why the job couldn't generate these settings (it mirrors the job's own allocation, with the set's own minCriteria/multiplier), plus knowlg-service's per-skill floor; empty when generation can go ahead. */
8
+ export declare function poolProblems(skills: string[], target: DifficultyTarget, buckets: Buckets, skillTotals: Record<string, number>, settings?: DynamicAssessSettings): string[];
9
+ /** The minimum-questions panel's rule (each selected skill gets at least minCriteria), checked without a search; the message when the target is below it, else null. */
10
+ export declare function belowSkillMinimum(skillCount: number, target: DifficultyTarget, settings: DynamicAssessSettings): string | null;
11
+ /** Skills below the minCriteria x multiplier Live questions knowlg-service requires before it accepts a refresh. */
12
+ export declare function skillShortfalls(skills: string[], counts: Record<string, number>, settings?: DynamicAssessSettings): string[];
13
+ /** Translates knowlg-service's per-skill rejection, whose message is English-only ("Fewer than 6 Live questions found for skill(s): A, B"). */
14
+ export declare function skillPoolErrorMessage(err: unknown): string | null;
15
+ /** The field the job's pool query filters on: the framework's highest-index category, else "skill". */
16
+ export declare function deepestCategoryCode(framework: IFramework | undefined): string;
17
+ export declare const GENERATE_POLL_MS = 3000;
18
+ export declare const GENERATE_POLL_MAX_ATTEMPTS = 40;
19
+ export type GenerateResult = 'generated' | 'pending' | 'failed' | 'cancelled';
20
+ export interface GenerateDeps {
21
+ contentId: string;
22
+ save: () => Promise<SaveOutcome>;
23
+ refresh: (contentId: string) => Promise<void>;
24
+ read: (contentId: string) => Promise<{
25
+ rootNode: INode;
26
+ }>;
27
+ sleep?: (ms: number) => Promise<void>;
28
+ pollMs?: number;
29
+ maxAttempts?: number;
30
+ /** True once the editor that started this generation has closed or reloaded; the wait then stops without touching the shared stores. */
31
+ isCancelled?: () => boolean;
32
+ }
33
+ /** Bumped whenever an editor opens or closes; the stores are shared, so a generation from an earlier session must not write into the current one. */
34
+ export declare function startEditorSession(): void;
35
+ /** Cancellation check for a generation started now: true once another session has begun. */
36
+ export declare function sessionCancelledCheck(): () => boolean;
37
+ export declare function generationPendingMessage(): string;
38
+ /** Whether a timed-out generation must pause saving, given the tree the editor would save: only children it could write back over the job's result need it. */
39
+ export declare function shouldPauseAfterPending(editorRoot: INode | undefined): boolean;
40
+ /** The framework through the shared query cache (same key and staleTime as useFramework), fetched if not loaded yet; undefined without an id. */
41
+ export declare function fetchFramework(frameworkId: string): Promise<IFramework | undefined>;
42
+ /** The job's allocation check plus knowlg-service's per-skill floor, against live counts and the set's own settings; throws if the searches fail. */
43
+ export declare function checkPool(skills: string[], target: DifficultyTarget, framework: IFramework | undefined, channel: string | undefined, settings: DynamicAssessSettings): Promise<string[]>;
44
+ /** Live counts the pool checks read: per skill x level (job allocation) and per skill (knowlg-service floor); throws if the searches fail. */
45
+ export declare function poolCounts(categoryField: string, skills: string[], channel?: string): Promise<[Record<string, Record<"E" | "M" | "D", number>>, Record<string, number>]>;
46
+ /** Refresh-body, then poll until the job has finished both its /add and /remove; stopping at the first change could keep the old children and a later save would re-attach them. */
47
+ export declare function generateAndWait(deps: Omit<GenerateDeps, 'save'>, baselineRoot: INode | undefined): Promise<{
48
+ result: GenerateResult;
49
+ rootNode?: INode;
50
+ }>;
51
+ /** Save, then generate: inputs only exist in treeCache until saved. */
52
+ export declare function saveThenGenerate(deps: GenerateDeps): Promise<{
53
+ result: GenerateResult;
54
+ rootNode?: INode;
55
+ }>;
56
+ /** Dynamic Assess generation (Save & Generate, Regenerate): failures toast and return false; a failed save has already toasted and reverted. */
57
+ export declare function useRefreshQuestionSetBody(): {
58
+ refresh: (opts?: {
59
+ saveIfBlocked?: boolean;
60
+ }) => Promise<boolean>;
61
+ };
62
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,8 @@
1
+ import { INode } from '../types/editor';
2
+ export declare function buildSavePayload(nodes: INode[], treeCache: Record<string, Record<string, unknown>>, channel: string, rootPrimaryCategory: string): {
3
+ nodesModified: Record<string, unknown>;
4
+ hierarchy: Record<string, unknown>;
5
+ };
1
6
  /**
2
7
  * Outcome of a hierarchy save, for callers that need to tell the three cases
3
8
  * apart rather than collapsing them into a boolean:
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};