@concord-consortium/lara-interactive-api 1.6.1 → 1.7.0-pre.1

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/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IInitInteractive, INavigationOptions, IAuthInfo, ISupportedFeatures, IShowModal, ICloseModal, IGetInteractiveListOptions, IGetInteractiveListResponse, ISetLinkedInteractives, IGetLibraryInteractiveListRequest, IJwtResponse, ICustomMessageHandler, ICustomMessagesHandledMap, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotResponse, IAddLinkedInteractiveStateListenerOptions, IDecoratedContentEvent, ITextDecorationHandler, WriteAttachmentParams, ReadAttachmentParams, GetAttachmentUrlParams, IGetReportItemAnswerHandler, IReportItemAnswer, OnUnloadFunction } from "./types";
1
+ import { IInitInteractive, INavigationOptions, IAuthInfo, ISupportedFeatures, IShowModal, ICloseModal, IGetInteractiveListOptions, IGetInteractiveListResponse, ISetLinkedInteractives, IGetLibraryInteractiveListRequest, IJwtResponse, ICustomMessageHandler, ICustomMessagesHandledMap, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotResponse, IAddLinkedInteractiveStateListenerOptions, IDecoratedContentEvent, ITextDecorationHandler, WriteAttachmentParams, ReadAttachmentParams, GetAttachmentUrlParams, IGetReportItemAnswerHandler, IReportItemAnswer, OnUnloadFunction, IReportItemHandlerMetadata } from "./types";
2
2
  export declare const getInitInteractiveMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => Promise<IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null>;
3
3
  export declare const getMode: () => Promise<"runtime" | "authoring" | "report" | "reportItem" | undefined>;
4
4
  export declare const getInteractiveState: <InteractiveState>() => InteractiveState | null;
@@ -66,11 +66,12 @@ export declare const getGlobalInteractiveState: <GlobalInteractiveState>() => Gl
66
66
  */
67
67
  export declare const setGlobalInteractiveState: <GlobalInteractiveState>(newGlobalState: GlobalInteractiveState | null) => void;
68
68
  export declare const addCustomMessageListener: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
69
- export declare const removeCustomMessageListener: () => void;
69
+ export declare const removeCustomMessageListener: () => boolean;
70
70
  export declare const addDecorateContentListener: (callback: ITextDecorationHandler) => void;
71
71
  export declare const removeDecorateContentListener: () => void;
72
72
  export declare const addGetReportItemAnswerListener: <InteractiveState, AuthoredState>(callback: IGetReportItemAnswerHandler<InteractiveState, AuthoredState>) => void;
73
73
  export declare const removeGetReportItemAnswerListener: () => void;
74
+ export declare const notifyReportItemClientReady: (metadata?: IReportItemHandlerMetadata | undefined) => void;
74
75
  export declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
75
76
  export declare const setHeight: (height: number | string) => void;
76
77
  export declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
package/client.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  import * as iframePhone from "iframe-phone";
2
- import { ClientMessage, ICustomMessageHandler, ICustomMessagesHandledMap, ISupportedFeaturesRequest, ServerMessage, ITextDecorationHandler, IGetReportItemAnswerHandler, OnUnloadFunction } from "./types";
2
+ import { ClientMessage, ICustomMessagesHandledMap, ISupportedFeaturesRequest, ServerMessage, OnUnloadFunction } from "./types";
3
3
  import { ManagedState } from "./managed-state";
4
4
  export declare const getClient: () => Client;
5
+ /**
6
+ * This class is intended to provide basic helpers (like `post()` or `add/removeListener`), maintain client-specific
7
+ * state, and generally be as minimal as possible. Most of the client-specific helpers and logic can be implemented
8
+ * in api.ts or hooks.ts (or both so the client app has choice).
9
+ */
5
10
  export declare class Client {
6
11
  phone: iframePhone.IFrameEndpoint;
7
12
  managedState: ManagedState;
8
- private customMessagesHandled;
13
+ customMessagesHandled: ICustomMessagesHandledMap;
9
14
  private listeners;
10
15
  private requestId;
11
16
  private onUnload;
@@ -14,12 +19,6 @@ export declare class Client {
14
19
  post(message: ClientMessage, content?: any): void;
15
20
  addListener(message: ServerMessage, callback: iframePhone.ListenerCallback, requestId?: number): boolean;
16
21
  removeListener(message: ServerMessage, requestId?: number, callback?: iframePhone.ListenerCallback): boolean;
17
- addCustomMessageListener(callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap): void;
18
- removeCustomMessageListener(): boolean;
19
- addDecorateContentListener(callback: ITextDecorationHandler): void;
20
- removeDecorateContentListener(): boolean;
21
- addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
22
- removeGetReportItemAnswerListener(): boolean;
23
22
  setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
24
23
  setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
25
24
  private connect;
package/hooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICustomMessageHandler, ICustomMessagesHandledMap, IInitInteractive, ITextDecorationHandler } from "./types";
1
+ import { ICustomMessageHandler, ICustomMessagesHandledMap, IInitInteractive, ITextDecorationHandler, IReportItemHandlerMetadata, IGetReportItemAnswerHandler } from "./types";
2
2
  declare type UpdateFunc<S> = (prevState: S | null) => S;
3
3
  export declare const useInteractiveState: <InteractiveState>() => {
4
4
  interactiveState: InteractiveState | null;
@@ -16,4 +16,9 @@ export declare const useInitMessage: <InteractiveState = {}, AuthoredState = {},
16
16
  export declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
17
17
  export declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
18
18
  export declare const useAutoSetHeight: () => void;
19
+ export interface IUseReportItemOptions<InteractiveState, AuthoredState> {
20
+ metadata: IReportItemHandlerMetadata;
21
+ handler: IGetReportItemAnswerHandler<InteractiveState, AuthoredState>;
22
+ }
23
+ export declare const useReportItem: <InteractiveState, AuthoredState>({ metadata, handler }: IUseReportItemOptions<InteractiveState, AuthoredState>) => void;
19
24
  export {};
package/index-bundle.d.ts CHANGED
@@ -130,7 +130,7 @@ interface IReportItemInitInteractive<InteractiveState = {}, AuthoredState = {}>
130
130
  mode: "reportItem";
131
131
  hostFeatures: IHostFeatures;
132
132
  interactiveItemId: string;
133
- view: "singleAnswer" | "multipleAnswer";
133
+ view: "singleAnswer" | "multipleAnswer" | "hidden";
134
134
  users: Record<string, {
135
135
  hasAnswer: boolean;
136
136
  }>;
@@ -361,11 +361,17 @@ interface ILinkedInteractiveStateResponse<LinkedInteractiveState> {
361
361
  listenerId: string;
362
362
  interactiveState: LinkedInteractiveState | undefined;
363
363
  }
364
+ declare type ReportItemsType = "fullAnswer" | "compactAnswer";
364
365
  interface IGetReportItemAnswer<InteractiveState = {}, AuthoredState = {}> extends IBaseRequestResponse {
365
- version: "2.0.0";
366
+ version: "2.1.0";
366
367
  platformUserId: string;
367
368
  interactiveState: InteractiveState;
368
369
  authoredState: AuthoredState;
370
+ /**
371
+ * When not provided, host should assume that itemsType is equal to "fullAnswer" (to maintain backward compatibility
372
+ * with version 2.0.0).
373
+ */
374
+ itemsType?: ReportItemsType;
369
375
  }
370
376
  interface IReportItemAnswerItemAttachment {
371
377
  type: "attachment";
@@ -384,13 +390,31 @@ interface IReportItemAnswerItemLinks {
384
390
  hideViewInline?: boolean;
385
391
  hideViewInNewTab?: boolean;
386
392
  }
387
- declare type IReportItemAnswerItem = IReportItemAnswerItemAttachment | IReportItemAnswerItemAnswerText | IReportItemAnswerItemHtml | IReportItemAnswerItemLinks;
393
+ interface IReportItemAnswerItemScore {
394
+ type: "score";
395
+ score: number;
396
+ maxScore: number;
397
+ }
398
+ declare type IReportItemAnswerItem = IReportItemAnswerItemAttachment | IReportItemAnswerItemAnswerText | IReportItemAnswerItemHtml | IReportItemAnswerItemLinks | IReportItemAnswerItemScore;
388
399
  interface IReportItemAnswer extends IBaseRequestResponse {
389
- version: "2.0.0";
400
+ version: "2.1.0";
390
401
  platformUserId: string;
391
402
  items: IReportItemAnswerItem[];
403
+ /**
404
+ * When not provided, host should assume that itemsType is equal to "fullAnswer" (to maintain backward compatibility
405
+ * with version 2.0.0).
406
+ */
407
+ itemsType: ReportItemsType;
392
408
  }
393
409
  declare type IGetReportItemAnswerHandler<InteractiveState = {}, AuthoredState = {}> = (message: IGetReportItemAnswer<InteractiveState, AuthoredState>) => void;
410
+ interface IReportItemHandlerMetadata {
411
+ /**
412
+ * When compactAnswerReportItems is present and equal to true, report will try to get report items related to compact
413
+ * answer (small icons visible in the dashboard grid view). An example of compact answer report item is "score"
414
+ * used by ScoreBOT question.
415
+ */
416
+ compactAnswerReportItemsAvailable?: boolean;
417
+ }
394
418
  /**
395
419
  * Interface that can be used by interactives to export and consume datasets. For example:
396
420
  * - Vortex interactive is exporting its dataset in the interactive state
@@ -549,11 +573,12 @@ declare const getGlobalInteractiveState: <GlobalInteractiveState>() => GlobalInt
549
573
  */
550
574
  declare const setGlobalInteractiveState: <GlobalInteractiveState>(newGlobalState: GlobalInteractiveState | null) => void;
551
575
  declare const addCustomMessageListener: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
552
- declare const removeCustomMessageListener: () => void;
576
+ declare const removeCustomMessageListener: () => boolean;
553
577
  declare const addDecorateContentListener: (callback: ITextDecorationHandler) => void;
554
578
  declare const removeDecorateContentListener: () => void;
555
579
  declare const addGetReportItemAnswerListener: <InteractiveState, AuthoredState>(callback: IGetReportItemAnswerHandler<InteractiveState, AuthoredState>) => void;
556
580
  declare const removeGetReportItemAnswerListener: () => void;
581
+ declare const notifyReportItemClientReady: (metadata?: IReportItemHandlerMetadata | undefined) => void;
557
582
  declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
558
583
  declare const setHeight: (height: number | string) => void;
559
584
  declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
@@ -616,6 +641,11 @@ declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, Global
616
641
  declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
617
642
  declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
618
643
  declare const useAutoSetHeight: () => void;
644
+ interface IUseReportItemOptions<InteractiveState, AuthoredState> {
645
+ metadata: IReportItemHandlerMetadata;
646
+ handler: IGetReportItemAnswerHandler<InteractiveState, AuthoredState>;
647
+ }
648
+ declare const useReportItem: <InteractiveState, AuthoredState>({ metadata, handler }: IUseReportItemOptions<InteractiveState, AuthoredState>) => void;
619
649
 
620
650
  declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive";
621
651
  declare class ManagedState {
@@ -640,10 +670,15 @@ declare class ManagedState {
640
670
  }
641
671
 
642
672
  declare const getClient: () => Client;
673
+ /**
674
+ * This class is intended to provide basic helpers (like `post()` or `add/removeListener`), maintain client-specific
675
+ * state, and generally be as minimal as possible. Most of the client-specific helpers and logic can be implemented
676
+ * in api.ts or hooks.ts (or both so the client app has choice).
677
+ */
643
678
  declare class Client {
644
679
  phone: iframePhone.IFrameEndpoint;
645
680
  managedState: ManagedState;
646
- private customMessagesHandled;
681
+ customMessagesHandled: ICustomMessagesHandledMap;
647
682
  private listeners;
648
683
  private requestId;
649
684
  private onUnload;
@@ -652,15 +687,9 @@ declare class Client {
652
687
  post(message: ClientMessage, content?: any): void;
653
688
  addListener(message: ServerMessage, callback: iframePhone.ListenerCallback, requestId?: number): boolean;
654
689
  removeListener(message: ServerMessage, requestId?: number, callback?: iframePhone.ListenerCallback): boolean;
655
- addCustomMessageListener(callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap): void;
656
- removeCustomMessageListener(): boolean;
657
- addDecorateContentListener(callback: ITextDecorationHandler): void;
658
- removeDecorateContentListener(): boolean;
659
- addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
660
- removeGetReportItemAnswerListener(): boolean;
661
690
  setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
662
691
  setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
663
692
  private connect;
664
693
  }
665
694
 
666
- export { AttachmentInfoMap, ChoiceId, Client, ClientMessage, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GetAttachmentUrlParams, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAddLinkedInteractiveStateListenerOptions, IAddLinkedInteractiveStateListenerRequest, IAttachmentInfo, IAttachmentUrlRequest, IAttachmentUrlResponse, IAuthInfo, IAuthoringClientMessage, IAuthoringCustomReportField, IAuthoringCustomReportFields, IAuthoringImageQuestionMetadata, IAuthoringInitInteractive, IAuthoringInteractiveMetadata, IAuthoringMetadata, IAuthoringMetadataBase, IAuthoringMultipleChoiceChoiceMetadata, IAuthoringMultipleChoiceMetadata, IAuthoringOpenResponseMetadata, IAuthoringServerMessage, IBaseShowModal, ICloseModal, IContextMember, IContextMembership, ICustomMessage, ICustomMessageHandler, ICustomMessageOptions, ICustomMessagesHandledMap, ICustomReportFieldsAuthoredState, ICustomReportFieldsAuthoredStateField, ICustomReportFieldsInteractiveState, IDataset, IDecoratedContentEvent, IGetAuthInfoRequest, IGetAuthInfoResponse, IGetFirebaseJwtRequest, IGetFirebaseJwtResponse, IGetInteractiveListOptions, IGetInteractiveListRequest, IGetInteractiveListResponse, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotRequest, IGetInteractiveSnapshotResponse, IGetInteractiveState, IGetLibraryInteractiveListOptions, IGetLibraryInteractiveListRequest, IGetLibraryInteractiveListResponse, IGetReportItemAnswer, IGetReportItemAnswerHandler, IHintRequest, IHostFeatureSupport, IHostFeatures, IHostModalSupport, IInitInteractive, IInteractiveListResponseItem, IInteractiveStateProps, IInteractiveStateWithDataset, IJwtClaims, IJwtResponse, ILibraryInteractiveListResponseItem, ILinkedInteractive, ILinkedInteractiveStateResponse, INavigationOptions, IPortalClaims, IRemoveLinkedInteractiveStateListenerRequest, IReportInitInteractive, IReportItemAnswer, IReportItemAnswerItem, IReportItemAnswerItemAnswerText, IReportItemAnswerItemAttachment, IReportItemAnswerItemHtml, IReportItemAnswerItemLinks, IReportItemClientMessage, IReportItemInitInteractive, IReportItemServerMessage, IRuntimeClientMessage, IRuntimeCustomReportValues, IRuntimeImageQuestionMetadata, IRuntimeInitInteractive, IRuntimeInteractiveMetadata, IRuntimeMetadata, IRuntimeMetadataBase, IRuntimeMultipleChoiceMetadata, IRuntimeOpenResponseMetadata, IRuntimeServerMessage, ISetLinkedInteractives, IShowAlert, IShowDialog, IShowLightbox, IShowModal, ISupportedFeatures, ISupportedFeaturesRequest, ITextDecorationHandler, ITextDecorationHandlerInfo, ITextDecorationInfo, IThemeInfo, IWriteAttachmentRequest, IframePhoneServerMessage, InitInteractiveMode, InteractiveItemId, LoggerClientMessage, ModalType, OnUnloadFunction, ReadAttachmentParams, ServerMessage, WriteAttachmentParams, addAuthoredStateListener, addCustomMessageListener, addDecorateContentListener, addGetReportItemAnswerListener, addGlobalInteractiveStateListener, addInteractiveStateListener, addLinkedInteractiveStateListener, closeModal, flushStateUpdates, getAttachmentUrl, getAuthInfo, getAuthoredState, getClient, getFirebaseJwt, getGlobalInteractiveState, getInitInteractiveMessage, getInteractiveList, getInteractiveSnapshot, getInteractiveState, getLibraryInteractiveList, getMode, inIframe, log, postDecoratedContentEvent, readAttachment, removeAuthoredStateListener, removeCustomMessageListener, removeDecorateContentListener, removeGetReportItemAnswerListener, removeGlobalInteractiveStateListener, removeInteractiveStateListener, removeLinkedInteractiveStateListener, sendReportItemAnswer, setAuthoredState, setGlobalInteractiveState, setHeight, setHint, setInteractiveState, setInteractiveStateTimeout, setLinkedInteractives, setNavigation, setOnUnload, setSupportedFeatures, showModal, useAuthoredState, useAutoSetHeight, useCustomMessages, useDecorateContent, useGlobalInteractiveState, useInitMessage, useInteractiveState, writeAttachment };
695
+ export { AttachmentInfoMap, ChoiceId, Client, ClientMessage, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GetAttachmentUrlParams, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAddLinkedInteractiveStateListenerOptions, IAddLinkedInteractiveStateListenerRequest, IAttachmentInfo, IAttachmentUrlRequest, IAttachmentUrlResponse, IAuthInfo, IAuthoringClientMessage, IAuthoringCustomReportField, IAuthoringCustomReportFields, IAuthoringImageQuestionMetadata, IAuthoringInitInteractive, IAuthoringInteractiveMetadata, IAuthoringMetadata, IAuthoringMetadataBase, IAuthoringMultipleChoiceChoiceMetadata, IAuthoringMultipleChoiceMetadata, IAuthoringOpenResponseMetadata, IAuthoringServerMessage, IBaseShowModal, ICloseModal, IContextMember, IContextMembership, ICustomMessage, ICustomMessageHandler, ICustomMessageOptions, ICustomMessagesHandledMap, ICustomReportFieldsAuthoredState, ICustomReportFieldsAuthoredStateField, ICustomReportFieldsInteractiveState, IDataset, IDecoratedContentEvent, IGetAuthInfoRequest, IGetAuthInfoResponse, IGetFirebaseJwtRequest, IGetFirebaseJwtResponse, IGetInteractiveListOptions, IGetInteractiveListRequest, IGetInteractiveListResponse, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotRequest, IGetInteractiveSnapshotResponse, IGetInteractiveState, IGetLibraryInteractiveListOptions, IGetLibraryInteractiveListRequest, IGetLibraryInteractiveListResponse, IGetReportItemAnswer, IGetReportItemAnswerHandler, IHintRequest, IHostFeatureSupport, IHostFeatures, IHostModalSupport, IInitInteractive, IInteractiveListResponseItem, IInteractiveStateProps, IInteractiveStateWithDataset, IJwtClaims, IJwtResponse, ILibraryInteractiveListResponseItem, ILinkedInteractive, ILinkedInteractiveStateResponse, INavigationOptions, IPortalClaims, IRemoveLinkedInteractiveStateListenerRequest, IReportInitInteractive, IReportItemAnswer, IReportItemAnswerItem, IReportItemAnswerItemAnswerText, IReportItemAnswerItemAttachment, IReportItemAnswerItemHtml, IReportItemAnswerItemLinks, IReportItemAnswerItemScore, IReportItemClientMessage, IReportItemHandlerMetadata, IReportItemInitInteractive, IReportItemServerMessage, IRuntimeClientMessage, IRuntimeCustomReportValues, IRuntimeImageQuestionMetadata, IRuntimeInitInteractive, IRuntimeInteractiveMetadata, IRuntimeMetadata, IRuntimeMetadataBase, IRuntimeMultipleChoiceMetadata, IRuntimeOpenResponseMetadata, IRuntimeServerMessage, ISetLinkedInteractives, IShowAlert, IShowDialog, IShowLightbox, IShowModal, ISupportedFeatures, ISupportedFeaturesRequest, ITextDecorationHandler, ITextDecorationHandlerInfo, ITextDecorationInfo, IThemeInfo, IUseReportItemOptions, IWriteAttachmentRequest, IframePhoneServerMessage, InitInteractiveMode, InteractiveItemId, LoggerClientMessage, ModalType, OnUnloadFunction, ReadAttachmentParams, ReportItemsType, ServerMessage, WriteAttachmentParams, addAuthoredStateListener, addCustomMessageListener, addDecorateContentListener, addGetReportItemAnswerListener, addGlobalInteractiveStateListener, addInteractiveStateListener, addLinkedInteractiveStateListener, closeModal, flushStateUpdates, getAttachmentUrl, getAuthInfo, getAuthoredState, getClient, getFirebaseJwt, getGlobalInteractiveState, getInitInteractiveMessage, getInteractiveList, getInteractiveSnapshot, getInteractiveState, getLibraryInteractiveList, getMode, inIframe, log, notifyReportItemClientReady, postDecoratedContentEvent, readAttachment, removeAuthoredStateListener, removeCustomMessageListener, removeDecorateContentListener, removeGetReportItemAnswerListener, removeGlobalInteractiveStateListener, removeInteractiveStateListener, removeLinkedInteractiveStateListener, sendReportItemAnswer, setAuthoredState, setGlobalInteractiveState, setHeight, setHint, setInteractiveState, setInteractiveStateTimeout, setLinkedInteractives, setNavigation, setOnUnload, setSupportedFeatures, showModal, useAuthoredState, useAutoSetHeight, useCustomMessages, useDecorateContent, useGlobalInteractiveState, useInitMessage, useInteractiveState, useReportItem, writeAttachment };