🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@campfirelearning/sdk-lti

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@campfirelearning/sdk-lti - npm Package Compare versions

Comparing version

to
0.14.0

dist/esm/authoring/ExamEditor.js

7

CHANGELOG.md

@@ -6,2 +6,9 @@ # Change Log

# [0.14.0](https://github.com/examspark/campfire-sdk/compare/@campfirelearning/sdk-lti@0.13.0...@campfirelearning/sdk-lti@0.14.0) (2025-03-10)
### Features
- add support for updating m/c item content via js ([bac55cc](https://github.com/examspark/campfire-sdk/commit/bac55cce8595365dd826f86455d3894e7f226297))
- **sdk:** offer config flag to hide titlebar [ES-2004] ([53b2d37](https://github.com/examspark/campfire-sdk/commit/53b2d37b07969b6f12119ad6958a20822260f174))
# [0.13.0](https://github.com/examspark/campfire-sdk/compare/@campfirelearning/sdk-lti@0.12.1...@campfirelearning/sdk-lti@0.13.0) (2025-01-24)

@@ -8,0 +15,0 @@

18

dist/esm/authoring/ItemEditor.d.ts

@@ -122,5 +122,18 @@ import { z } from "zod";

readonly SET_ITEM_METADATA: "setItemMetadata";
readonly SET_ITEM_CONTENT: "setItemContent";
};
declare const itemEditorMessageSchema: z.ZodObject<{
declare const itemEditorMessageSchema: z.ZodUnion<[z.ZodObject<{
type: z.ZodLiteral<"message">;
name: z.ZodLiteral<"setItemContent">;
data: z.ZodAny;
}, "strip", z.ZodTypeAny, {
type: "message";
name: "setItemContent";
data?: any;
}, {
type: "message";
name: "setItemContent";
data?: any;
}>, z.ZodObject<{
type: z.ZodLiteral<"message">;
name: z.ZodLiteral<"setItemMetadata">;

@@ -230,3 +243,3 @@ data: z.ZodObject<{

name: "setItemMetadata";
}>;
}>]>;
type Message = z.infer<typeof itemEditorMessageSchema>;

@@ -238,4 +251,5 @@ export default class ItemEditor extends LTIToolConsumer<Event, Message> {

}>["data"]["fields"]) => void;
setItemContent: (data: any) => void;
}
export {};
//# sourceMappingURL=ItemEditor.d.ts.map

@@ -251,5 +251,19 @@ import { z } from "zod";

readonly SET_EXAM_FORM_DATA: "setExamFormData";
readonly SET_ITEM_EDITOR_DATA: "setItemEditorData";
};
export declare const messageSchema: z.ZodObject<{
export declare const setItemEditorDataMessage: z.ZodObject<{
type: z.ZodLiteral<"message">;
name: z.ZodLiteral<"setItemEditorData">;
data: z.ZodAny;
}, "strip", z.ZodTypeAny, {
type: "message";
name: "setItemEditorData";
data?: any;
}, {
type: "message";
name: "setItemEditorData";
data?: any;
}>;
export declare const messageSchema: z.ZodUnion<[z.ZodObject<{
type: z.ZodLiteral<"message">;
name: z.ZodLiteral<"setExamFormData">;

@@ -317,9 +331,24 @@ data: z.ZodObject<{

name: "setExamFormData";
}>;
}>, z.ZodObject<{
type: z.ZodLiteral<"message">;
name: z.ZodLiteral<"setItemEditorData">;
data: z.ZodAny;
}, "strip", z.ZodTypeAny, {
type: "message";
name: "setItemEditorData";
data?: any;
}, {
type: "message";
name: "setItemEditorData";
data?: any;
}>]>;
type Message = z.infer<typeof messageSchema>;
export type ExamBuilderOptions = CampfireLTIToolConsumerOptions & AuthoringOptions & {
launchOptions?: {
readOnly?: boolean;
userPrefs?: UserPrefs;
};
launchOptions?: Partial<{
readOnly: boolean;
userPrefs: UserPrefs;
titlebar: Partial<{
hidden: boolean;
}>;
}>;
};

@@ -331,4 +360,5 @@ export default class ExamBuilder extends LTIToolConsumer<Event, Message> {

}>["data"]["fields"]) => void;
setItemEditorData: (data: any) => void;
}
export {};
//# sourceMappingURL=ExamBuilder.d.ts.map

@@ -170,4 +170,18 @@ import { z } from "zod";

type Event = z.infer<typeof eventSchema>;
export declare const Messages: {};
export declare const messageSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
export declare const Messages: {
readonly SET_ITEM_EDITOR_DATA: "setItemEditorData";
};
export declare const messageSchema: z.ZodObject<{
type: z.ZodLiteral<"message">;
name: z.ZodLiteral<"setItemEditorData">;
data: z.ZodAny;
}, "strip", z.ZodTypeAny, {
type: "message";
name: "setItemEditorData";
data?: any;
}, {
type: "message";
name: "setItemEditorData";
data?: any;
}>;
type Message = z.infer<typeof messageSchema>;

@@ -198,4 +212,5 @@ export type ExamPickerOptions = CampfireLTIToolConsumerOptions & {

constructor(options: ExamPickerOptions);
setItemEditorData: (data: any) => void;
}
export {};
//# sourceMappingURL=ExamPicker.d.ts.map

@@ -24,2 +24,3 @@ import { LTIParamsMap, LTIToolConsumer } from "./LTIToolConsumer";

};
export * from "./authoring/item-editor/utils";
//# sourceMappingURL=index.d.ts.map

238

docs/classes/LTIToolConsumer.md

@@ -1,153 +0,183 @@

[@campfirelearning/lti-tool-consumer - v0.0.1](../README.md) / [Exports](../modules.md) / LTIToolConsumer
[**@campfirelearning/sdk-lti v0.11.4**](../README.md)
# Class: LTIToolConsumer
---
## Table of contents
[@campfirelearning/sdk-lti](../globals.md) / LTIToolConsumer
### Constructors
# Class: LTIToolConsumer\<TEvent, TMessage\>
- [constructor](LTIToolConsumer.md#constructor)
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:95](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L95)
### Properties
## Extends
- [document](LTIToolConsumer.md#document)
- [isMounted](LTIToolConsumer.md#ismounted)
- [launchUrl](LTIToolConsumer.md#launchurl)
- [mountedNode](LTIToolConsumer.md#mountednode)
- [onMessageReceived](LTIToolConsumer.md#onmessagereceived)
- [params](LTIToolConsumer.md#params)
- [signingFunction](LTIToolConsumer.md#signingfunction)
- `EventTarget`
### Methods
## Extended by
- [launch](LTIToolConsumer.md#launch)
- [mount](LTIToolConsumer.md#mount)
- [sendMessage](LTIToolConsumer.md#sendmessage)
- [validateLTILaunchParams](LTIToolConsumer.md#validateltilaunchparams)
- [validateLTIParams](LTIToolConsumer.md#validateltiparams)
- [`ExamEditor`](ExamEditor.md)
- [`ItemEditor`](ItemEditor.md)
- [`Exam`](Exam.md)
- [`ExamBuilder`](ExamBuilder.md)
- [`ExamPicker`](ExamPicker.md)
- [`ExamResult`](ExamResult.md)
- [`GuidedExamBuilder`](GuidedExamBuilder.md)
- [`ItemViewer`](ItemViewer.md)
- [`CampfireAssessmentPlayer`](CampfireAssessmentPlayer.md)
## Type Parameters
• **TEvent** = `unknown`
• **TMessage** = `unknown`
## Constructors
### constructor
### new LTIToolConsumer()
• **new LTIToolConsumer**(`options`): [`LTIToolConsumer`](LTIToolConsumer.md)
> **new LTIToolConsumer**\<`TEvent`, `TMessage`\>(...`__namedParameters`): [`LTIToolConsumer`](LTIToolConsumer.md)\<`TEvent`, `TMessage`\>
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:121](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L121)
#### Parameters
| Name | Type |
| :-------- | :----------------------- |
| `options` | `LTIToolConsumerOptions` |
##### \_\_namedParameters
...`unknown` _extends_ `TEvent` ? \[`LTIToolConsumerOptions`\] : `unknown` _extends_ `TMessage` ? \[`LTIToolConsumerOptions`, `ZodType`\<`TEvent`, `TEvent`\>\] : \[`LTIToolConsumerOptions`, `ZodType`\<`TEvent`, `TEvent`\>, `ZodType`\<`TMessage`, `TMessage`\>\]
#### Returns
[`LTIToolConsumer`](LTIToolConsumer.md)
[`LTIToolConsumer`](LTIToolConsumer.md)\<`TEvent`, `TMessage`\>
#### Defined in
#### Overrides
[LTIToolConsumer.ts:50](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L50)
`EventTarget.constructor`
## Properties
### document
### addEventListener()
• `Private` **document**: `Document`
> **addEventListener**: \<`K`\>(`event`, `listener`) => `this`
#### Defined in
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:109](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L109)
[LTIToolConsumer.ts:42](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L42)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
---
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
### isMounted
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
• `Private` **isMounted**: `boolean` = `false`
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
#### Defined in
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
[LTIToolConsumer.ts:48](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L48)
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
---
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
### launchUrl
[MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
• `Private` **launchUrl**: `string`
#### Type Parameters
#### Defined in
• **K** _extends_ keyof `EventListeners`\<`TEvent`\>
[LTIToolConsumer.ts:45](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L45)
#### Parameters
---
##### event
### mountedNode
`K`
• `Private` `Optional` **mountedNode**: `HTMLIFrameElement`
##### listener
#### Defined in
`EventListeners`\<`TEvent`\>\[`K`\]
[LTIToolConsumer.ts:44](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L44)
#### Returns
`this`
#### Overrides
`EventTarget.addEventListener`
---
### onMessageReceived
### dispatchEvent()
• `Optional` **onMessageReceived**: `LTIMessageHandler`
> **dispatchEvent**: (`event`) => `boolean`
#### Defined in
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:117](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L117)
[LTIToolConsumer.ts:47](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L47)
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
---
[MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
### params
#### Parameters
• `Private` **params**: [`LTIParamsMap`](../modules.md#ltiparamsmap)
##### event
#### Defined in
`MessageEvent`\<`unknown`\>
[LTIToolConsumer.ts:43](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L43)
#### Returns
`boolean`
#### Overrides
`EventTarget.dispatchEvent`
---
### signingFunction
### removeEventListener()
• `Private` **signingFunction**: `LTISignRequest`
> **removeEventListener**: \<`K`\>(`event`, `listener`) => `this`
#### Defined in
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:113](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L113)
[LTIToolConsumer.ts:46](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L46)
Removes the event listener in target's event listener list with the same type, callback, and options.
## Methods
[MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
### launch
#### Type Parameters
▸ **launch**(`mountDOMID`, `launchUrl`, `params`): `Promise`\<`void`\>
• **K** _extends_ keyof `EventListeners`\<`TEvent`\>
#### Parameters
| Name | Type |
| :----------- | :------------------------------------------- |
| `mountDOMID` | `string` |
| `launchUrl` | `string` |
| `params` | [`LTIParamsMap`](../modules.md#ltiparamsmap) |
##### event
`K`
##### listener
`EventListeners`\<`TEvent`\>\[`K`\]
#### Returns
`Promise`\<`void`\>
`this`
#### Defined in
#### Overrides
[LTIToolConsumer.ts:72](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L72)
`EventTarget.removeEventListener`
---
## Methods
### mount
### launch()
▸ **mount**(`mountDOMID`): `Promise`\<`void`\>
> `protected` **launch**(`mountDOMID`, `launchUrl`, `params`): `Promise`\<`void`\>
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:162](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L162)
#### Parameters
| Name | Type |
| :----------- | :------- |
| `mountDOMID` | `string` |
##### mountDOMID
`string`
##### launchUrl
`string`
##### params
[`LTIParamsMap`](../type-aliases/LTIParamsMap.md)
#### Returns

@@ -157,64 +187,54 @@

#### Defined in
---
[LTIToolConsumer.ts:99](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L99)
### mount()
---
> **mount**(`mountDOMID`): `Promise`\<`void`\>
### sendMessage
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:196](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L196)
▸ **sendMessage**(`message`): `void`
#### Parameters
| Name | Type |
| :-------- | :------- |
| `message` | `string` |
##### mountDOMID
`string`
#### Returns
`void`
`Promise`\<`void`\>
#### Defined in
---
[LTIToolConsumer.ts:141](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L141)
### parse()
---
> `protected` **parse**(`e`): `e is MessageEvent<TEvent>`
### validateLTILaunchParams
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:188](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L188)
▸ **validateLTILaunchParams**(`params`): `void`
#### Parameters
| Name | Type |
| :------- | :------------------------------------------- |
| `params` | [`LTIParamsMap`](../modules.md#ltiparamsmap) |
##### e
`MessageEvent`\<`unknown`\>
#### Returns
`void`
`e is MessageEvent<TEvent>`
#### Defined in
---
[LTIToolConsumer.ts:156](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L156)
### sendMessage()
---
> **sendMessage**(`message`): `void`
### validateLTIParams
Defined in: [packages/sdk-lti/src/LTIToolConsumer.ts:242](https://github.com/examspark/campfire-sdk/blob/239837d1ea929d402ff9dcb6eb5d70f8a164d630/packages/sdk-lti/src/LTIToolConsumer.ts#L242)
▸ **validateLTIParams**(`params`): `void`
#### Parameters
| Name | Type |
| :------- | :------------------------------------------- |
| `params` | [`LTIParamsMap`](../modules.md#ltiparamsmap) |
##### message
`TMessage`
#### Returns
`void`
#### Defined in
[LTIToolConsumer.ts:171](https://github.com/examspark/campfire-sdk/blob/3496e21/packages/lti-tool-consumer/src/LTIToolConsumer.ts#L171)

@@ -1,3 +0,5 @@

@campfirelearning/lti-tool-consumer / [Exports](modules.md)
**@campfirelearning/sdk-lti v0.11.4**
---
# Campfire SDK

@@ -7,2 +9,6 @@

## Requirements
- `corepack enable` to respect Yarn 4 package manager dependency
## Packages

@@ -9,0 +15,0 @@

@@ -0,4 +1,3 @@

import { build } from "@campfirelearning/build-tools";
import { build } from "../../esbuild.shared";
build({

@@ -5,0 +4,0 @@ entryPoint: "./src/index.ts",

@@ -9,2 +9,3 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */

testEnvironment: "jsdom",
testPathIgnorePatterns: ["<rootDir>/dist"],
};
{
"name": "@campfirelearning/sdk-lti",
"version": "0.13.0",
"version": "0.14.0",
"main": "./src/index.ts",

@@ -10,9 +10,8 @@ "author": "ExamSpark, LLC",

"scripts": {
"build": "yarn build:types && yarn build:bundles",
"build": "pnpm build:types && pnpm build:bundles",
"build:bundles": "npx tsx esbuild.ts",
"build:types": "tsc",
"deploy:develop": "yarn build && aws s3 cp dist/index.js s3://examspark-app-files-develop/public/sdk/campfire-sdk-v0.1.js --profile examspark",
"deploy": "yarn build && aws s3 cp dist/index.js s3://examspark-app-files-master/public/sdk/campfire-sdk-v0.1.js --profile examspark",
"docs": "typedoc --plugin typedoc-plugin-markdown --out docs",
"prepublish": "yarn build:bundles",
"deploy:develop": "pnpm build && aws s3 cp dist/index.js s3://examspark-app-files-develop/public/sdk/campfire-sdk-v0.1.js --profile examspark",
"deploy": "pnpm build && aws s3 cp dist/index.js s3://examspark-app-files-master/public/sdk/campfire-sdk-v0.1.js --profile examspark",
"prepublish": "pnpm build:bundles",
"start": "node dev-server.mjs",

@@ -25,6 +24,6 @@ "tsc": "tsc --emitDeclarationOnly --outDir dist/esm",

"devDependencies": {
"@jest/globals": "^29.7.0",
"@testing-library/dom": "^9.3.4",
"@campfirelearning/build-tools": "^0.0.2",
"@testing-library/jest-dom": "^6.4.2",
"@types/jest": "^29.5.12",
"@types/jsdom": "^20",
"esbuild": "^0.20.1",

@@ -34,5 +33,4 @@ "esbuild-plugin-d.ts": "^1.2.3",

"jest-environment-jsdom": "^29.7.0",
"jsdom": "^20",
"ts-jest": "^29.1.2",
"typedoc": "^0.25.10",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.3.3"

@@ -44,5 +42,6 @@ },

"dependencies": {
"zod": "^3.23.8"
"nanoid": "^5.0.9",
"zod": "^3.24.1"
},
"gitHead": "7d6432a954c7c8c1012171790d152df53ebeb752"
"gitHead": "4ed3f22ae953d05491ffbf47b2f2738ee1bf33d0"
}

@@ -78,70 +78,78 @@ import { z } from "zod";

SET_ITEM_METADATA: "setItemMetadata",
SET_ITEM_CONTENT: "setItemContent",
} as const;
const itemEditorMessageSchema = z.object({
type: z.literal("message"),
name: z.literal(Messages.SET_ITEM_METADATA),
data: z.object({
fields: z.array(
z.union([
z.object({
field: z.literal("item:title"),
value: z.string(),
}),
z.object({
field: z.literal("item:bank"),
value: z.string(),
}),
z.object({
field: z.literal("item:maturity"),
// todo: decide if we want to do the rest of the maturity statuses
value: z.enum(["DRAFT", "IN_DEVELOPMENT", "OPERATIONAL"]),
}),
z.object({
field: z.literal("item:visibility"),
value: z.enum(["PRIVATE", "WORKSPACE", "WORKSPACE_SHAREABLE"]),
}),
// future fields
// z.object({
// field: z.literal("item:language"),
// value: z.string(),
// }),
// z.object({
// field: z.literal("item:subject"),
// value: z.enum(["MATH", "ELA", "SCI", "SS"]),
// }),
// z.object({
// field: z.literal("item:grades"),
// value: z.array(
// z.enum([
// "GRADE_PK",
// "GRADE_K",
// "GRADE_1",
// "GRADE_2",
// "GRADE_3",
// "GRADE_4",
// "GRADE_5",
// "GRADE_6",
// "GRADE_7",
// "GRADE_8",
// "GRADE_9",
// "GRADE_10",
// "GRADE_11",
// "GRADE_12",
// "GRADE_HS",
// ])
// ),
// }),
// z.object({
// field: z.literal("item:dok"),
// value: z.array(z.enum(["DOK1", "DOK2", "DOK3", "DOK4"])),
// }),
// z.object({
// field: z.literal("item:blooms"),
// value: z.array(z.enum(["BT1", "BT2", "BT3", "BT4", "BT5", "BT6"])),
// }),
]),
),
const itemEditorMessageSchema = z.union([
z.object({
type: z.literal("message"),
name: z.literal(Messages.SET_ITEM_CONTENT),
data: z.any(),
}),
});
z.object({
type: z.literal("message"),
name: z.literal(Messages.SET_ITEM_METADATA),
data: z.object({
fields: z.array(
z.union([
z.object({
field: z.literal("item:title"),
value: z.string(),
}),
z.object({
field: z.literal("item:bank"),
value: z.string(),
}),
z.object({
field: z.literal("item:maturity"),
// todo: decide if we want to do the rest of the maturity statuses
value: z.enum(["DRAFT", "IN_DEVELOPMENT", "OPERATIONAL"]),
}),
z.object({
field: z.literal("item:visibility"),
value: z.enum(["PRIVATE", "WORKSPACE", "WORKSPACE_SHAREABLE"]),
}),
// future fields
// z.object({
// field: z.literal("item:language"),
// value: z.string(),
// }),
// z.object({
// field: z.literal("item:subject"),
// value: z.enum(["MATH", "ELA", "SCI", "SS"]),
// }),
// z.object({
// field: z.literal("item:grades"),
// value: z.array(
// z.enum([
// "GRADE_PK",
// "GRADE_K",
// "GRADE_1",
// "GRADE_2",
// "GRADE_3",
// "GRADE_4",
// "GRADE_5",
// "GRADE_6",
// "GRADE_7",
// "GRADE_8",
// "GRADE_9",
// "GRADE_10",
// "GRADE_11",
// "GRADE_12",
// "GRADE_HS",
// ])
// ),
// }),
// z.object({
// field: z.literal("item:dok"),
// value: z.array(z.enum(["DOK1", "DOK2", "DOK3", "DOK4"])),
// }),
// z.object({
// field: z.literal("item:blooms"),
// value: z.array(z.enum(["BT1", "BT2", "BT3", "BT4", "BT5", "BT6"])),
// }),
]),
),
}),
}),
]);
type Message = z.infer<typeof itemEditorMessageSchema>;

@@ -183,2 +191,12 @@

};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setItemContent = (data: any) => {
// console.log("setItemEditorContent", data);
this.sendMessage({
type: "message",
name: Messages.SET_ITEM_CONTENT,
data,
});
};
}

@@ -63,22 +63,32 @@ import { z } from "zod";

SET_EXAM_FORM_DATA: "setExamFormData",
SET_ITEM_EDITOR_DATA: "setItemEditorData",
} as const;
export const messageSchema = z.object({
export const setItemEditorDataMessage = z.object({
type: z.literal("message"),
name: z.literal(Messages.SET_EXAM_FORM_DATA),
data: z.object({
fields: z.array(
z.union([
z.object({
field: z.literal("exam:title"),
value: z.string(),
}),
z.object({
field: z.literal("exam:description"),
value: z.string(),
}),
]),
),
name: z.literal(Messages.SET_ITEM_EDITOR_DATA),
data: z.any(),
});
export const messageSchema = z.union([
z.object({
type: z.literal("message"),
name: z.literal(Messages.SET_EXAM_FORM_DATA),
data: z.object({
fields: z.array(
z.union([
z.object({
field: z.literal("exam:title"),
value: z.string(),
}),
z.object({
field: z.literal("exam:description"),
value: z.string(),
}),
]),
),
}),
}),
});
setItemEditorDataMessage,
]);
type Message = z.infer<typeof messageSchema>;

@@ -88,6 +98,9 @@

AuthoringOptions & {
launchOptions?: {
readOnly?: boolean;
userPrefs?: UserPrefs;
};
launchOptions?: Partial<{
readOnly: boolean;
userPrefs: UserPrefs;
titlebar: Partial<{
hidden: boolean;
}>;
}>;
};

@@ -129,2 +142,11 @@

};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setItemEditorData = (data: any) => {
this.sendMessage({
type: "message",
name: Messages.SET_ITEM_EDITOR_DATA,
data,
});
};
}

@@ -10,3 +10,6 @@ import { z } from "zod";

import { SharedExamBuilerEvents } from "./ExamBuilder";
import {
setItemEditorDataMessage,
SharedExamBuilerEvents,
} from "./ExamBuilder";

@@ -67,5 +70,7 @@ export const Events = {

export const Messages = {} as const;
export const Messages = {
SET_ITEM_EDITOR_DATA: "setItemEditorData",
} as const;
export const messageSchema = z.object({});
export const messageSchema = setItemEditorDataMessage;
type Message = z.infer<typeof messageSchema>;

@@ -105,2 +110,11 @@

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setItemEditorData = (data: any) => {
this.sendMessage({
type: "message",
name: Messages.SET_ITEM_EDITOR_DATA,
data,
});
};
}

@@ -49,3 +49,3 @@ import { z } from "zod";

z.literal("exam:activityType"),
])
]),
),

@@ -103,3 +103,3 @@ }),

}),
])
]),
),

@@ -134,3 +134,3 @@ }),

{ name: typeof Messages.SET_GUIDED_EXAM_FORM_DATA }
>["data"]["fields"]
>["data"]["fields"],
) => {

@@ -146,3 +146,3 @@ this.addEventListener("message", (message) => {

fields: fields.filter((field) =>
requestedFields.includes(field.field)
requestedFields.includes(field.field),
),

@@ -149,0 +149,0 @@ },

@@ -39,1 +39,3 @@ import { LTIParamsMap, LTIToolConsumer } from "./LTIToolConsumer";

};
export * from "./authoring/item-editor/utils";

@@ -30,2 +30,3 @@ import "@testing-library/jest-dom";

const devNullSigningFunction =
// @ts-expect-error unused on purpose
// eslint-disable-next-line @typescript-eslint/no-unused-vars

@@ -35,2 +36,3 @@ (_url: string) => async (params: LTIParamsMap) => {

};
// @ts-expect-error unused on purpose
// eslint-disable-next-line @typescript-eslint/no-unused-vars

@@ -40,2 +42,3 @@ const testSigningFunction = async (params: LTIParamsMap) =>

// @ts-expect-error unused on purpose
// eslint-disable-next-line @typescript-eslint/no-unused-vars

@@ -55,3 +58,3 @@ const testLaunchFunction = async (params: LTIParamsMap) =>

<iframe id="aNamedIframe" name="aNamedIframe"></iframe>
</body></html>`
</body></html>`,
).window.document;

@@ -67,3 +70,3 @@

await expect(async () => await consumer.mount("notAnIframe")).rejects.toThrow(
"Element with id notAnIframe is not an iframe"
"Element with id notAnIframe is not an iframe",
);

@@ -80,3 +83,3 @@ });

await expect(
async () => await consumer.mount("thisIsAnInvalidId")
async () => await consumer.mount("thisIsAnInvalidId"),
).rejects.toThrow("No element with id thisIsAnInvalidId");

@@ -93,3 +96,3 @@ });

await expect(async () => await consumer.mount("anIframe")).rejects.toThrow(
"The target iframe must also be named anIframe"
"The target iframe must also be named anIframe",
);

@@ -106,3 +109,3 @@ });

document: getTestDocument(),
})
}),
).toThrow("options.launchUrl must be provided");

@@ -118,3 +121,3 @@ });

document: getTestDocument(),
})
}),
).toThrow("Either signingUrl or signingFunction must be provided");

@@ -131,3 +134,3 @@ });

document: getTestDocument(),
})
}),
).toThrow("options.params must be provided");

@@ -144,3 +147,3 @@ });

await expect(
async () => await consumer.mount("aNamedIframe")
async () => await consumer.mount("aNamedIframe"),
).rejects.toThrow("Missing required LTI launch parameters: ");

@@ -157,5 +160,5 @@ });

await expect(
async () => await consumer.mount("aNamedIframe")
async () => await consumer.mount("aNamedIframe"),
).rejects.toThrow(
"Error mounting LTI tool consumer: Missing required LTI parameters:"
"Error mounting LTI tool consumer: Missing required LTI parameters:",
);

@@ -172,6 +175,6 @@ });

await expect(
async () => await consumer.mount("aNamedIframe")
async () => await consumer.mount("aNamedIframe"),
).rejects.toThrow(
"Error mounting LTI tool consumer: Missing required LTI parameters:"
"Error mounting LTI tool consumer: Missing required LTI parameters:",
);
});

@@ -97,3 +97,3 @@ import { z } from "zod";

TEvent = unknown,
TMessage = unknown
TMessage = unknown,
> extends EventTarget {

@@ -112,7 +112,7 @@ private document: Document;

event: K,
listener: EventListeners<TEvent>[K]
listener: EventListeners<TEvent>[K],
) => this;
declare removeEventListener: <K extends keyof EventListeners<TEvent>>(
event: K,
listener: EventListeners<TEvent>[K]
listener: EventListeners<TEvent>[K],
) => this;

@@ -167,3 +167,3 @@ declare dispatchEvent: (event: MessageEvent<unknown>) => boolean;

launchUrl: string,
params: LTIParamsMap
params: LTIParamsMap,
) {

@@ -179,3 +179,3 @@ const launchForm = this.document.createElement("form");

input.setAttribute("name", key);
input.setAttribute("value", this.params[key]);
input.setAttribute("value", this.params[key]!);
launchForm.appendChild(input);

@@ -232,7 +232,7 @@ }

this.dispatchEvent(
new MessageEvent("message", { data: event.data })
new MessageEvent("message", { data: event.data }),
);
} else {
this.dispatchEvent(
new MessageEvent("message:unhandled", { data: event.data })
new MessageEvent("message:unhandled", { data: event.data }),
);

@@ -273,3 +273,3 @@ }

throw new Error(
`Missing required LTI launch parameters: ${missingKeys.join(", ")}`
`Missing required LTI launch parameters: ${missingKeys.join(", ")}`,
);

@@ -289,3 +289,3 @@ }

throw new Error(
`Missing required LTI parameters: ${missingKeys.join(", ")}`
`Missing required LTI parameters: ${missingKeys.join(", ")}`,
);

@@ -292,0 +292,0 @@ }

import { CampfireLTIToolConsumerOptions } from "../LTIToolConsumer";
export const getCampfireApiDomain = (
options: CampfireLTIToolConsumerOptions
options: CampfireLTIToolConsumerOptions,
): `${"https" | "http"}://${string}` => {

@@ -6,0 +6,0 @@ let domain = options.domain;

{
"extends": "../../tsconfig.settings.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist/esm",
"rootDir": "src",
"esModuleInterop": true,
"emitDeclarationOnly": true
"esModuleInterop": true
},
"include": ["src/**/*.ts"]
}
{
"extends": ["../../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet