@concord-consortium/lara-interactive-api 1.13.0-pre.0 → 1.13.0-pre.2

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
@@ -110,24 +110,9 @@ interface IThemeInfo {
110
110
  };
111
111
  }
112
112
  declare type InteractiveItemId = string;
113
- /**
114
- * Represents a linked interactive element within the LARA system.
115
- *
116
- * @remarks
117
- * This interface defines the structure for referencing an interactive component
118
- * that is linked to another interactive or question. The questionId field is
119
- * intentionally transient and should not be persisted in interactive state
120
- * as it may change over time. The questionId field is also only set in the
121
- * initInteractive message and is ignored in the setLinkedInteractives message.
122
- *
123
- * @property id - Unique identifier for the interactive item
124
- * @property label - Human-readable label for the interactive
125
- * @property questionId - Optional question identifier that should not be saved in state
126
- */
127
113
  interface ILinkedInteractive {
128
114
  id: InteractiveItemId;
129
115
  label: string;
130
- questionId?: string;
131
116
  }
132
117
  interface IAuthoringInitInteractive<AuthoredState = {}> {
133
118
  version: 1;
@@ -183,8 +168,8 @@ interface ICustomReportFieldsInteractiveState {
183
168
  };
184
169
  };
185
170
  }
186
- 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";
187
- 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";
188
173
  declare type IAuthoringClientMessage = "getInteractiveList" | "setLinkedInteractives" | "getFirebaseJWT";
189
174
  declare type IAuthoringServerMessage = "interactiveList" | "firebaseJWT";
190
175
  declare type IReportItemClientMessage = "reportItemAnswer" | "reportItemClientReady";
@@ -529,6 +514,44 @@ interface IPubSubChannelInfo {
529
514
  }
530
515
  declare type PubSubMessageHandler = (message: any, publisherId: string) => void;
531
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
+ }
532
555
 
533
556
  declare type ChoiceId = string;
534
557
  interface IAuthoringMetadataBase {
@@ -595,9 +618,10 @@ declare type IRuntimeMetadata = IRuntimeInteractiveMetadata | IRuntimeOpenRespon
595
618
 
596
619
  declare const inIframe: () => boolean;
597
620
 
598
- declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive";
621
+ declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive" | "jobInfoReceived";
599
622
  declare class ManagedState {
600
623
  interactiveStateDirty: boolean;
624
+ jobs: ReadonlyArray<IJobInfo>;
601
625
  private _initMessage;
602
626
  private _interactiveState;
603
627
  private _authoredState;
@@ -615,6 +639,7 @@ declare class ManagedState {
615
639
  on(event: ManagedStateEvent, handler: any): void;
616
640
  off(event: ManagedStateEvent, handler: any): void;
617
641
  once(event: ManagedStateEvent, handler: any): void;
642
+ upsertJob(job: IJobInfo): void;
618
643
  }
619
644
 
620
645
  declare const getClient: () => Client;
@@ -779,6 +804,13 @@ declare const setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void
779
804
  declare const sendCustomMessage: (customMessage: ICustomMessage) => void;
780
805
  declare const createPubSubChannel: (channelId: string, channelInfo?: any) => PubSubChannel;
781
806
  declare const setDirtyState: (isDirty: boolean) => void;
807
+ declare const createJob: (request: {
808
+ task: string;
809
+ } & Record<string, any>) => Promise<IJobInfo>;
810
+ declare const cancelJob: (jobId: string) => void;
811
+ declare const getJobs: () => IJobInfo[];
812
+ declare const addJobUpdateListener: (listener: (job: IJobInfo) => void) => void;
813
+ declare const removeJobUpdateListener: (listener: (job: IJobInfo) => void) => void;
782
814
 
783
815
  declare type UpdateFunc<S> = (prevState: S | null) => S;
784
816
  declare const useInteractiveState: <InteractiveState>() => {
@@ -795,6 +827,14 @@ declare const useGlobalInteractiveState: <GlobalInteractiveState>() => {
795
827
  };
796
828
  declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null;
797
829
  declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
830
+ declare const useJobs: () => {
831
+ createJob: (request: {
832
+ task: string;
833
+ } & Record<string, any>) => Promise<IJobInfo>;
834
+ cancelJob: (jobId: string) => void;
835
+ jobs: IJobInfo[];
836
+ latestJob: IJobInfo | undefined;
837
+ };
798
838
  declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
799
839
  declare const useAutoSetHeight: () => void;
800
840
  interface IUseReportItemOptions<InteractiveState, AuthoredState> {
@@ -810,4 +850,4 @@ interface IUseAccessibilityProps {
810
850
  }
811
851
  declare const useAccessibility: (props?: IUseAccessibilityProps | undefined) => IAccessibilitySettings;
812
852
 
813
- 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 };
853
+ 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 };