@concord-consortium/lara-interactive-api 1.12.0 → 1.13.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, IReportItemHandlerMetadata, ICustomMessage } 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, ICustomMessage, IJobInfo } from "./types";
2
2
  import { PubSubChannel } from "./pubsub";
3
3
  export { PubSubChannel };
4
4
  export declare const getInitInteractiveMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => Promise<IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null>;
@@ -121,3 +121,10 @@ export declare const setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined)
121
121
  export declare const sendCustomMessage: (customMessage: ICustomMessage) => void;
122
122
  export declare const createPubSubChannel: (channelId: string, channelInfo?: any) => PubSubChannel;
123
123
  export declare const setDirtyState: (isDirty: boolean) => void;
124
+ export declare const createJob: (request: {
125
+ task: string;
126
+ } & Record<string, any>) => Promise<IJobInfo>;
127
+ export declare const cancelJob: (jobId: string) => void;
128
+ export declare const getJobs: () => IJobInfo[];
129
+ export declare const addJobUpdateListener: (listener: (job: IJobInfo) => void) => void;
130
+ export declare const removeJobUpdateListener: (listener: (job: IJobInfo) => void) => void;
package/hooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICustomMessageHandler, ICustomMessagesHandledMap, IInitInteractive, ITextDecorationHandler, IReportItemHandlerMetadata, IGetReportItemAnswerHandler, IAccessibilitySettings } from "./types";
1
+ import { ICustomMessageHandler, ICustomMessagesHandledMap, IInitInteractive, ITextDecorationHandler, IReportItemHandlerMetadata, IGetReportItemAnswerHandler, IAccessibilitySettings, IJobInfo } from "./types";
2
2
  declare type UpdateFunc<S> = (prevState: S | null) => S;
3
3
  export declare const useInteractiveState: <InteractiveState>() => {
4
4
  interactiveState: InteractiveState | null;
@@ -14,6 +14,14 @@ export declare const useGlobalInteractiveState: <GlobalInteractiveState>() => {
14
14
  };
15
15
  export declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null;
16
16
  export declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
17
+ export declare const useJobs: () => {
18
+ createJob: (request: {
19
+ task: string;
20
+ } & Record<string, any>) => Promise<IJobInfo>;
21
+ cancelJob: (jobId: string) => void;
22
+ jobs: IJobInfo[];
23
+ latestJob: IJobInfo | undefined;
24
+ };
17
25
  export declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
18
26
  export declare const useAutoSetHeight: () => void;
19
27
  export interface IUseReportItemOptions<InteractiveState, AuthoredState> {
package/index-bundle.d.ts CHANGED
@@ -168,8 +168,8 @@ interface ICustomReportFieldsInteractiveState {
168
168
  };
169
169
  };
170
170
  }
171
- declare type IRuntimeClientMessage = "interactiveState" | "height" | "hint" | "getAttachmentUrl" | "getAuthInfo" | "supportedFeatures" | "navigation" | "getFirebaseJWT" | "authoredState" | "authoringCustomReportFields" | "runtimeCustomReportValues" | "showModal" | "closeModal" | "getLibraryInteractiveList" | "getInteractiveSnapshot" | "addLinkedInteractiveStateListener" | "removeLinkedInteractiveStateListener" | "decoratedContentEvent" | "setDirtyState" | "customMessage" | "createChannel" | "publish" | "subscribe" | "unsubscribe";
172
- declare type IRuntimeServerMessage = "attachmentUrl" | "authInfo" | "getInteractiveState" | "initInteractive" | "firebaseJWT" | "closedModal" | "customMessage" | "libraryInteractiveList" | "interactiveSnapshot" | "contextMembership" | "linkedInteractiveState" | "decorateContent" | "pubSubMessage" | "pubSubChannelInfo";
171
+ declare type IRuntimeClientMessage = "interactiveState" | "height" | "hint" | "getAttachmentUrl" | "getAuthInfo" | "supportedFeatures" | "navigation" | "getFirebaseJWT" | "authoredState" | "authoringCustomReportFields" | "runtimeCustomReportValues" | "showModal" | "closeModal" | "getLibraryInteractiveList" | "getInteractiveSnapshot" | "addLinkedInteractiveStateListener" | "removeLinkedInteractiveStateListener" | "decoratedContentEvent" | "setDirtyState" | "customMessage" | "createChannel" | "publish" | "subscribe" | "unsubscribe" | "createJob" | "cancelJob";
172
+ declare type IRuntimeServerMessage = "attachmentUrl" | "authInfo" | "getInteractiveState" | "initInteractive" | "firebaseJWT" | "closedModal" | "customMessage" | "libraryInteractiveList" | "interactiveSnapshot" | "contextMembership" | "linkedInteractiveState" | "decorateContent" | "pubSubMessage" | "pubSubChannelInfo" | "jobCreated" | "jobInfo";
173
173
  declare type IAuthoringClientMessage = "getInteractiveList" | "setLinkedInteractives" | "getFirebaseJWT";
174
174
  declare type IAuthoringServerMessage = "interactiveList" | "firebaseJWT";
175
175
  declare type IReportItemClientMessage = "reportItemAnswer" | "reportItemClientReady";
@@ -514,6 +514,44 @@ interface IPubSubChannelInfo {
514
514
  }
515
515
  declare type PubSubMessageHandler = (message: any, publisherId: string) => void;
516
516
  declare type PubSubChannelInfoHandler = (channelInfo: any) => void;
517
+ interface IJobInfo {
518
+ version: 1;
519
+ id: string;
520
+ status: "queued" | "running" | "success" | "failure" | "cancelled";
521
+ request: {
522
+ task: string;
523
+ } & Record<string, any>;
524
+ result?: {
525
+ message: string;
526
+ processingMessage?: string;
527
+ } & Record<string, any>;
528
+ createdAt: number;
529
+ updatedAt?: number;
530
+ startedAt?: number;
531
+ completedAt?: number;
532
+ }
533
+ interface ICreateJobRequest extends IBaseRequestResponse {
534
+ request: {
535
+ task: string;
536
+ } & Record<string, any>;
537
+ }
538
+ interface ICreateJobResponse extends IBaseRequestResponse {
539
+ job: IJobInfo;
540
+ }
541
+ interface ICancelJobRequest {
542
+ jobId: string;
543
+ }
544
+ interface IJobInfoMessage {
545
+ job: IJobInfo;
546
+ }
547
+ interface IJobExecutor {
548
+ createJob(request: {
549
+ task: string;
550
+ } & Record<string, any>, context?: Record<string, any>): Promise<IJobInfo>;
551
+ cancelJob(jobId: string): Promise<void>;
552
+ getJobs(context?: Record<string, any>): Promise<IJobInfo[]>;
553
+ onJobUpdate(callback: (job: IJobInfo) => void): void;
554
+ }
517
555
 
518
556
  declare type ChoiceId = string;
519
557
  interface IAuthoringMetadataBase {
@@ -580,9 +618,10 @@ declare type IRuntimeMetadata = IRuntimeInteractiveMetadata | IRuntimeOpenRespon
580
618
 
581
619
  declare const inIframe: () => boolean;
582
620
 
583
- declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive";
621
+ declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive" | "jobInfoReceived";
584
622
  declare class ManagedState {
585
623
  interactiveStateDirty: boolean;
624
+ jobs: ReadonlyArray<any>;
586
625
  private _initMessage;
587
626
  private _interactiveState;
588
627
  private _authoredState;
@@ -764,6 +803,13 @@ declare const setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void
764
803
  declare const sendCustomMessage: (customMessage: ICustomMessage) => void;
765
804
  declare const createPubSubChannel: (channelId: string, channelInfo?: any) => PubSubChannel;
766
805
  declare const setDirtyState: (isDirty: boolean) => void;
806
+ declare const createJob: (request: {
807
+ task: string;
808
+ } & Record<string, any>) => Promise<IJobInfo>;
809
+ declare const cancelJob: (jobId: string) => void;
810
+ declare const getJobs: () => IJobInfo[];
811
+ declare const addJobUpdateListener: (listener: (job: IJobInfo) => void) => void;
812
+ declare const removeJobUpdateListener: (listener: (job: IJobInfo) => void) => void;
767
813
 
768
814
  declare type UpdateFunc<S> = (prevState: S | null) => S;
769
815
  declare const useInteractiveState: <InteractiveState>() => {
@@ -780,6 +826,14 @@ declare const useGlobalInteractiveState: <GlobalInteractiveState>() => {
780
826
  };
781
827
  declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null;
782
828
  declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
829
+ declare const useJobs: () => {
830
+ createJob: (request: {
831
+ task: string;
832
+ } & Record<string, any>) => Promise<IJobInfo>;
833
+ cancelJob: (jobId: string) => void;
834
+ jobs: IJobInfo[];
835
+ latestJob: IJobInfo | undefined;
836
+ };
783
837
  declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
784
838
  declare const useAutoSetHeight: () => void;
785
839
  interface IUseReportItemOptions<InteractiveState, AuthoredState> {
@@ -795,4 +849,4 @@ interface IUseAccessibilityProps {
795
849
  }
796
850
  declare const useAccessibility: (props?: IUseAccessibilityProps | undefined) => IAccessibilitySettings;
797
851
 
798
- export { AttachmentInfoMap, ChoiceId, Client, ClientMessage, DefaultAccessibilitySettings, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GetAttachmentUrlParams, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAccessibilitySettings, 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, IMediaLibrary, IMediaLibraryItem, IMediaLibraryItemType, INavigationOptions, IOpaqueObjectStorageConfig, IPortalClaims, IPubSubChannelInfo, IPubSubCreateChannel, IPubSubMessage, IPubSubPublish, IPubSubSubscribe, IPubSubUnsubscribe, IRemoveLinkedInteractiveStateListenerRequest, IReportInitInteractive, IReportItemAnswer, IReportItemAnswerItem, IReportItemAnswerItemAnswerText, IReportItemAnswerItemAttachment, IReportItemAnswerItemHtml, IReportItemAnswerItemLinks, IReportItemAnswerItemScore, IReportItemClientMessage, IReportItemHandlerMetadata, IReportItemInitInteractive, IReportItemServerMessage, IRuntimeClientMessage, IRuntimeCustomReportValues, IRuntimeImageQuestionMetadata, IRuntimeInitInteractive, IRuntimeInteractiveMetadata, IRuntimeMetadata, IRuntimeMetadataBase, IRuntimeMultipleChoiceMetadata, IRuntimeOpenResponseMetadata, IRuntimeServerMessage, ISetDirtyStateRequest, ISetLinkedInteractives, IShowAlert, IShowDialog, IShowLightbox, IShowModal, ISupportedFeatures, ISupportedFeaturesRequest, ITextDecorationHandler, ITextDecorationHandlerInfo, ITextDecorationInfo, IThemeInfo, IUseAccessibilityProps, IUseReportItemOptions, IWriteAttachmentRequest, IframePhoneServerMessage, InitInteractiveMode, InteractiveItemId, LoggerClientMessage, ModalType, OnUnloadFunction, PubSubChannel, PubSubChannelInfoHandler, PubSubMessageHandler, ReadAttachmentParams, ReportItemsType, ServerMessage, WriteAttachmentParams, addAuthoredStateListener, addCustomMessageListener, addDecorateContentListener, addGetReportItemAnswerListener, addGlobalInteractiveStateListener, addInteractiveStateListener, addLinkedInteractiveStateListener, closeModal, createPubSubChannel, 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, sendCustomMessage, sendReportItemAnswer, setAuthoredState, setDirtyState, setGlobalInteractiveState, setHeight, setHint, setInteractiveState, setInteractiveStateTimeout, setLinkedInteractives, setNavigation, setOnUnload, setSupportedFeatures, showModal, useAccessibility, useAuthoredState, useAutoSetHeight, useCustomMessages, useDecorateContent, useGlobalInteractiveState, useInitMessage, useInteractiveState, useReportItem, writeAttachment };
852
+ export { AttachmentInfoMap, ChoiceId, Client, ClientMessage, DefaultAccessibilitySettings, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GetAttachmentUrlParams, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAccessibilitySettings, IAddLinkedInteractiveStateListenerOptions, IAddLinkedInteractiveStateListenerRequest, IAttachmentInfo, IAttachmentUrlRequest, IAttachmentUrlResponse, IAuthInfo, IAuthoringClientMessage, IAuthoringCustomReportField, IAuthoringCustomReportFields, IAuthoringImageQuestionMetadata, IAuthoringInitInteractive, IAuthoringInteractiveMetadata, IAuthoringMetadata, IAuthoringMetadataBase, IAuthoringMultipleChoiceChoiceMetadata, IAuthoringMultipleChoiceMetadata, IAuthoringOpenResponseMetadata, IAuthoringServerMessage, IBaseShowModal, ICancelJobRequest, ICloseModal, IContextMember, IContextMembership, ICreateJobRequest, ICreateJobResponse, 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, IJobExecutor, IJobInfo, IJobInfoMessage, IJwtClaims, IJwtResponse, ILibraryInteractiveListResponseItem, ILinkedInteractive, ILinkedInteractiveStateResponse, IMediaLibrary, IMediaLibraryItem, IMediaLibraryItemType, INavigationOptions, IOpaqueObjectStorageConfig, IPortalClaims, IPubSubChannelInfo, IPubSubCreateChannel, IPubSubMessage, IPubSubPublish, IPubSubSubscribe, IPubSubUnsubscribe, IRemoveLinkedInteractiveStateListenerRequest, IReportInitInteractive, IReportItemAnswer, IReportItemAnswerItem, IReportItemAnswerItemAnswerText, IReportItemAnswerItemAttachment, IReportItemAnswerItemHtml, IReportItemAnswerItemLinks, IReportItemAnswerItemScore, IReportItemClientMessage, IReportItemHandlerMetadata, IReportItemInitInteractive, IReportItemServerMessage, IRuntimeClientMessage, IRuntimeCustomReportValues, IRuntimeImageQuestionMetadata, IRuntimeInitInteractive, IRuntimeInteractiveMetadata, IRuntimeMetadata, IRuntimeMetadataBase, IRuntimeMultipleChoiceMetadata, IRuntimeOpenResponseMetadata, IRuntimeServerMessage, ISetDirtyStateRequest, ISetLinkedInteractives, IShowAlert, IShowDialog, IShowLightbox, IShowModal, ISupportedFeatures, ISupportedFeaturesRequest, ITextDecorationHandler, ITextDecorationHandlerInfo, ITextDecorationInfo, IThemeInfo, IUseAccessibilityProps, IUseReportItemOptions, IWriteAttachmentRequest, IframePhoneServerMessage, InitInteractiveMode, InteractiveItemId, LoggerClientMessage, ModalType, OnUnloadFunction, PubSubChannel, PubSubChannelInfoHandler, PubSubMessageHandler, ReadAttachmentParams, ReportItemsType, ServerMessage, WriteAttachmentParams, addAuthoredStateListener, addCustomMessageListener, addDecorateContentListener, addGetReportItemAnswerListener, addGlobalInteractiveStateListener, addInteractiveStateListener, addJobUpdateListener, addLinkedInteractiveStateListener, cancelJob, closeModal, createJob, createPubSubChannel, flushStateUpdates, getAttachmentUrl, getAuthInfo, getAuthoredState, getClient, getFirebaseJwt, getGlobalInteractiveState, getInitInteractiveMessage, getInteractiveList, getInteractiveSnapshot, getInteractiveState, getJobs, getLibraryInteractiveList, getMode, inIframe, log, notifyReportItemClientReady, postDecoratedContentEvent, readAttachment, removeAuthoredStateListener, removeCustomMessageListener, removeDecorateContentListener, removeGetReportItemAnswerListener, removeGlobalInteractiveStateListener, removeInteractiveStateListener, removeJobUpdateListener, removeLinkedInteractiveStateListener, sendCustomMessage, sendReportItemAnswer, setAuthoredState, setDirtyState, setGlobalInteractiveState, setHeight, setHint, setInteractiveState, setInteractiveStateTimeout, setLinkedInteractives, setNavigation, setOnUnload, setSupportedFeatures, showModal, useAccessibility, useAuthoredState, useAutoSetHeight, useCustomMessages, useDecorateContent, useGlobalInteractiveState, useInitMessage, useInteractiveState, useJobs, useReportItem, writeAttachment };