adapt-authoring-adaptframework 0.0.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/lib/apidefs.js ADDED
@@ -0,0 +1,152 @@
1
+ const responseDataMeta = {
2
+ 200: {
3
+ description: 'The Adapt build data',
4
+ content: {
5
+ 'application/json': {
6
+ schema: { $ref: '#components/schemas/adaptbuild' }
7
+ }
8
+ }
9
+ }
10
+ }
11
+
12
+ const responseZipMeta = {
13
+ 200: {
14
+ description: 'Course build zip file',
15
+ content: { 'application/zip': {} }
16
+ }
17
+ }
18
+
19
+ const statusReportItemSchema = {
20
+ type: 'array',
21
+ items: {
22
+ type: 'object',
23
+ properties: {
24
+ code: { type: 'string' },
25
+ data: { type: 'string' }
26
+ }
27
+ }
28
+ }
29
+
30
+ export default {
31
+ preview: {
32
+ post: {
33
+ summary: 'Build a preview of an Adapt course',
34
+ responses: responseDataMeta
35
+ }
36
+ },
37
+ publish: {
38
+ post: {
39
+ summary: 'Create a publish zip of an Adapt course',
40
+ responses: responseDataMeta
41
+ },
42
+ get: {
43
+ summary: 'Retrieve an Adapt course publish zip',
44
+ responses: responseZipMeta
45
+ }
46
+ },
47
+ import: {
48
+ post: {
49
+ summary: 'Import an Adapt course',
50
+ requestBody: {
51
+ content: {
52
+ 'application/json': {
53
+ schema: {
54
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
55
+ type: 'object',
56
+ properties: {
57
+ isDryRun: { type: 'Boolean', default: false },
58
+ importContent: { type: 'Boolean', default: true },
59
+ importPlugins: { type: 'Boolean', default: true },
60
+ updatePlugins: { type: 'Boolean', default: false }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ },
66
+ responses: {
67
+ 200: {
68
+ description: '',
69
+ content: {
70
+ 'application/json': {
71
+ schema: {
72
+ properties: {
73
+ title: { type: 'string' },
74
+ courseId: { type: 'string' },
75
+ versions: { type: 'object' },
76
+ content: {
77
+ type: 'object',
78
+ properties: {
79
+ course: { type: 'number' },
80
+ config: { type: 'number' },
81
+ menu: { type: 'number' },
82
+ page: { type: 'number' },
83
+ article: { type: 'number' },
84
+ block: { type: 'number' },
85
+ component: { type: 'number' }
86
+ }
87
+ },
88
+ statusReport: {
89
+ type: 'object',
90
+ properties: {
91
+ error: statusReportItemSchema,
92
+ warn: statusReportItemSchema,
93
+ info: statusReportItemSchema
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ },
104
+ export: {
105
+ post: {
106
+ summary: 'Create an export zip of an Adapt course',
107
+ responses: responseDataMeta
108
+ },
109
+ get: {
110
+ summary: 'Retrieve an Adapt course export zip',
111
+ responses: responseZipMeta
112
+ }
113
+ },
114
+ update: {
115
+ post: {
116
+ summary: 'Updates the installed framework',
117
+ responses: {
118
+ 200: {
119
+ description: 'Describes the upgraded elements',
120
+ content: {
121
+ 'application/json': {
122
+ schema: {
123
+ properties: {
124
+ from: { type: 'string' },
125
+ to: { type: 'string' }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ },
133
+ get: {
134
+ summary: 'Retrieve framework update data',
135
+ responses: {
136
+ 200: {
137
+ content: {
138
+ 'application/json': {
139
+ schema: {
140
+ properties: {
141
+ canBeUpdated: { type: 'boolean' },
142
+ currentVersion: { type: 'string' },
143
+ latestCompatibleVersion: { type: 'string' }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,12 @@
1
+ async function ComponentTransform (data, importer) {
2
+ if (data._type !== 'component') {
3
+ return
4
+ }
5
+ data._component = importer.componentNameMap[data._component]
6
+
7
+ if (data._playerOptions === '') {
8
+ delete data._playerOptions
9
+ }
10
+ }
11
+
12
+ export default ComponentTransform
@@ -0,0 +1,11 @@
1
+ async function ConfigTransform (data) {
2
+ if (data._type !== 'config' || !data._accessibility._ariaLevels) {
3
+ return
4
+ }
5
+ ['_menu', '_menuItem', '_page', '_article', '_block', '_component', '_componentItem', '_notify'].forEach(k => {
6
+ const val = data._accessibility._ariaLevels[k]
7
+ if (val) data._accessibility._ariaLevels[k] = String(val)
8
+ })
9
+ }
10
+
11
+ export default ConfigTransform
@@ -0,0 +1,10 @@
1
+ async function GraphicSrcTransform (data) {
2
+ if (data._component !== 'adapt-contrib-graphic' && data._component !== 'adapt-contrib-hotgraphic') {
3
+ return
4
+ }
5
+ ([data].concat(data._items ?? [])).forEach(i => {
6
+ if (i._graphic.src) i._graphic.large = i._graphic.small = i._graphic.src
7
+ })
8
+ }
9
+
10
+ export default GraphicSrcTransform
@@ -0,0 +1,12 @@
1
+ async function ConfigTransform (data) {
2
+ if (data._type !== 'course') {
3
+ return
4
+ }
5
+ const exts = data._globals._extensions
6
+ Object.keys(exts).forEach(k => {
7
+ if(exts[k]._navOrder !== undefined)
8
+ exts[k]._navOrder = Number(exts[k]._navOrder)
9
+ })
10
+ }
11
+
12
+ export default ConfigTransform
@@ -0,0 +1,7 @@
1
+ async function ParentIdTransform (data, importer) {
2
+ if (data._parentId) {
3
+ data._parentId = importer.idMap[data._parentId]
4
+ }
5
+ }
6
+
7
+ export default ParentIdTransform
@@ -0,0 +1,13 @@
1
+ async function RemoveUndef (data) {
2
+ Object.entries(data).forEach(([k, v]) => {
3
+ if (v === null) {
4
+ delete data[k]
5
+ return
6
+ }
7
+ if (typeof v === 'object' && !Array.isArray(v)) {
8
+ RemoveUndef(v)
9
+ }
10
+ })
11
+ }
12
+
13
+ export default RemoveUndef
@@ -0,0 +1,17 @@
1
+ async function StartPage (data, importer) {
2
+ if (data._type !== 'course' || data._start === undefined) {
3
+ return
4
+ }
5
+ let pageIndex = 1
6
+ data._start._startIds.forEach((d, i) => {
7
+ const _id = data._start._startIds[i]._id
8
+ const co = importer.contentJson.contentObjects[_id]
9
+ if(!co) {
10
+ return importer.framework.log('warn', `StartPage transform: unable to find content with _id '${_id}'`)
11
+ }
12
+ co._friendlyId = data._start._startIds[i]._id = co._friendlyId ?? `start_page_${pageIndex++}`
13
+ })
14
+ }
15
+
16
+ export default StartPage
17
+
@@ -0,0 +1,9 @@
1
+ async function ThemeUndef (data, importer) {
2
+ if (data._type !== 'config' || data._theme !== undefined) {
3
+ return
4
+ }
5
+ data._theme = Object.values(importer.usedContentPlugins).find(p => p.type === 'theme')?.name
6
+ }
7
+
8
+ export default ThemeUndef
9
+
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "adapt-authoring-adaptframework",
3
+ "version": "0.0.1",
4
+ "description": "Adapt framework integration for the Adapt authoring tool",
5
+ "homepage": "https://github.com/adapt-security/adapt-authoring-adaptframework",
6
+ "license": "GPL-3.0",
7
+ "type": "module",
8
+ "main": "index.js",
9
+ "repository": "github:adapt-security/adapt-authoring-adaptframework",
10
+ "dependencies": {
11
+ "adapt-authoring-browserslist": "github:adapt-security/adapt-authoring-browserslist",
12
+ "adapt-authoring-content": "github:adapt-security/adapt-authoring-content",
13
+ "adapt-authoring-contentplugin": "github:adapt-security/adapt-authoring-contentplugin",
14
+ "adapt-authoring-courseassets": "github:adapt-security/adapt-authoring-courseassets",
15
+ "adapt-authoring-coursetheme": "github:adapt-security/adapt-authoring-coursetheme",
16
+ "adapt-authoring-spoortracking": "github:adapt-security/adapt-authoring-spoortracking",
17
+ "adapt-cli": "github:adaptlearning/adapt-cli#v3.3.1",
18
+ "adapt-octopus": "github:cgkineo/adapt-octopus#v0.1.1",
19
+ "bytes": "^3.1.2",
20
+ "fs-extra": "11.3.0",
21
+ "glob": "^11.0.0",
22
+ "lodash": "^4.17.21",
23
+ "semver": "^7.6.0",
24
+ "upath": "^2.0.1",
25
+ "zipper": "github:adapt-security/zipper#v1.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "eslint": "^9.11.0",
29
+ "standard": "^17.1.0"
30
+ }
31
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$anchor": "adaptbuild",
4
+ "description": "An Adapt course build instance",
5
+ "type": "object",
6
+ "properties": {
7
+ "action": {
8
+ "description": "The course _id",
9
+ "type": "string"
10
+ },
11
+ "courseId": {
12
+ "description": "The course _id",
13
+ "type": "string"
14
+ },
15
+ "location": {
16
+ "description": "Location of the course preview",
17
+ "type": "string"
18
+ },
19
+ "expiresAt": {
20
+ "description": "When the preview should be purged from the server",
21
+ "type": "string",
22
+ "format": "date-time",
23
+ "isDate": true
24
+ },
25
+ "createdBy": {
26
+ "description": "User which initiated the build",
27
+ "type": "string",
28
+ "isObjectId": true
29
+ },
30
+ "versions": {
31
+ "description": "Versions of framework and plugins used in the build",
32
+ "type": "object"
33
+ }
34
+ },
35
+ "required": ["action", "courseId", "location", "expiresAt", "createdBy"]
36
+ }