@concord-consortium/lara-interactive-api 1.6.0 → 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
@@ -123,13 +123,14 @@ interface IReportInitInteractive<InteractiveState = {}, AuthoredState = {}> {
123
123
  interactiveState: InteractiveState;
124
124
  themeInfo: IThemeInfo;
125
125
  attachments?: AttachmentInfoMap;
126
+ linkedInteractives: ILinkedInteractive[];
126
127
  }
127
128
  interface IReportItemInitInteractive<InteractiveState = {}, AuthoredState = {}> {
128
129
  version: 1;
129
130
  mode: "reportItem";
130
131
  hostFeatures: IHostFeatures;
131
132
  interactiveItemId: string;
132
- view: "singleAnswer" | "multipleAnswer";
133
+ view: "singleAnswer" | "multipleAnswer" | "hidden";
133
134
  users: Record<string, {
134
135
  hasAnswer: boolean;
135
136
  }>;
@@ -360,11 +361,17 @@ interface ILinkedInteractiveStateResponse<LinkedInteractiveState> {
360
361
  listenerId: string;
361
362
  interactiveState: LinkedInteractiveState | undefined;
362
363
  }
364
+ declare type ReportItemsType = "fullAnswer" | "compactAnswer";
363
365
  interface IGetReportItemAnswer<InteractiveState = {}, AuthoredState = {}> extends IBaseRequestResponse {
364
- version: "2.0.0";
366
+ version: "2.1.0";
365
367
  platformUserId: string;
366
368
  interactiveState: InteractiveState;
367
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;
368
375
  }
369
376
  interface IReportItemAnswerItemAttachment {
370
377
  type: "attachment";
@@ -383,13 +390,31 @@ interface IReportItemAnswerItemLinks {
383
390
  hideViewInline?: boolean;
384
391
  hideViewInNewTab?: boolean;
385
392
  }
386
- 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;
387
399
  interface IReportItemAnswer extends IBaseRequestResponse {
388
- version: "2.0.0";
400
+ version: "2.1.0";
389
401
  platformUserId: string;
390
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;
391
408
  }
392
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
+ }
393
418
  /**
394
419
  * Interface that can be used by interactives to export and consume datasets. For example:
395
420
  * - Vortex interactive is exporting its dataset in the interactive state
@@ -548,11 +573,12 @@ declare const getGlobalInteractiveState: <GlobalInteractiveState>() => GlobalInt
548
573
  */
549
574
  declare const setGlobalInteractiveState: <GlobalInteractiveState>(newGlobalState: GlobalInteractiveState | null) => void;
550
575
  declare const addCustomMessageListener: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
551
- declare const removeCustomMessageListener: () => void;
576
+ declare const removeCustomMessageListener: () => boolean;
552
577
  declare const addDecorateContentListener: (callback: ITextDecorationHandler) => void;
553
578
  declare const removeDecorateContentListener: () => void;
554
579
  declare const addGetReportItemAnswerListener: <InteractiveState, AuthoredState>(callback: IGetReportItemAnswerHandler<InteractiveState, AuthoredState>) => void;
555
580
  declare const removeGetReportItemAnswerListener: () => void;
581
+ declare const notifyReportItemClientReady: (metadata?: IReportItemHandlerMetadata | undefined) => void;
556
582
  declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
557
583
  declare const setHeight: (height: number | string) => void;
558
584
  declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
@@ -615,6 +641,11 @@ declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, Global
615
641
  declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
616
642
  declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
617
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;
618
649
 
619
650
  declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive";
620
651
  declare class ManagedState {
@@ -639,10 +670,15 @@ declare class ManagedState {
639
670
  }
640
671
 
641
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
+ */
642
678
  declare class Client {
643
679
  phone: iframePhone.IFrameEndpoint;
644
680
  managedState: ManagedState;
645
- private customMessagesHandled;
681
+ customMessagesHandled: ICustomMessagesHandledMap;
646
682
  private listeners;
647
683
  private requestId;
648
684
  private onUnload;
@@ -651,15 +687,9 @@ declare class Client {
651
687
  post(message: ClientMessage, content?: any): void;
652
688
  addListener(message: ServerMessage, callback: iframePhone.ListenerCallback, requestId?: number): boolean;
653
689
  removeListener(message: ServerMessage, requestId?: number, callback?: iframePhone.ListenerCallback): boolean;
654
- addCustomMessageListener(callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap): void;
655
- removeCustomMessageListener(): boolean;
656
- addDecorateContentListener(callback: ITextDecorationHandler): void;
657
- removeDecorateContentListener(): boolean;
658
- addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
659
- removeGetReportItemAnswerListener(): boolean;
660
690
  setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
661
691
  setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
662
692
  private connect;
663
693
  }
664
694
 
665
- 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 };