adapt-authoring-ui 1.7.3 → 1.7.5

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.
@@ -99,49 +99,65 @@ define(function(require){
99
99
 
100
100
  formatErrorString: function (errorString) {
101
101
  const normalise = (s, delim) => s.split(delim).map(s => s.trim()).filter(Boolean)
102
- const nl = count => '<br/>'.repeat(count ?? 1)
103
-
104
- // Extract prefix messages (anything before the first component error)
105
- const firstComponentIndex = errorString.search(/\S+-component\s+\S+/);
106
- const prefixMessages = firstComponentIndex > 0
107
- ? normalise(errorString.substring(0, firstComponentIndex), ',')
108
- : [];
109
- const componentString = firstComponentIndex > 0
110
- ? errorString.substring(firstComponentIndex)
111
- : errorString;
112
-
113
- const components = normalise(componentString, ';')
114
- const groups = {};
115
-
116
- components.forEach(component => {
117
- const [, type, id, errorsStr] = component.match(/^(\S+-component)\s+(\S+)\s+(.+)$/) ?? [];
118
102
 
119
- if(!type || !id || !errorsStr) {
120
- return
103
+ // Match content type + id + errors: e.g. "contentobject abc123 /path must be..."
104
+ // Covers: contentobject, block, article, course, *-component, etc.
105
+ const contentErrorPattern = /\b(\S+)\s+([a-f0-9]{24})\s+(\/\S+.*?)(?=,\s*;\s*|,\s*$|$)/g;
106
+
107
+ const prefixMessages = [];
108
+ const groups = {};
109
+ let hasContentErrors = false;
110
+
111
+ // Extract semicolon-delimited segments
112
+ const segments = normalise(errorString, ';');
113
+
114
+ segments.forEach(segment => {
115
+ const matches = [...segment.matchAll(contentErrorPattern)];
116
+ if (!matches.length) {
117
+ // No content errors found in this segment — treat as prefix message
118
+ normalise(segment, ',').forEach(msg => {
119
+ if (msg.trim()) prefixMessages.push(msg.trim());
120
+ });
121
+ return;
122
+ }
123
+ hasContentErrors = true;
124
+
125
+ // Extract any text before the first content error as prefix
126
+ const firstMatchStart = segment.indexOf(matches[0][0]);
127
+ if (firstMatchStart > 0) {
128
+ normalise(segment.substring(0, firstMatchStart), ',').forEach(msg => {
129
+ if (msg.trim()) prefixMessages.push(msg.trim());
130
+ });
121
131
  }
122
- // Split only on ", /" to avoid breaking apart value lists like "false,soft,hard"
123
- const errors = errorsStr
124
- .split(/,\s*(?=\/)/)
125
- .map(s => s.trim())
126
- .filter(Boolean)
127
- .sort();
128
- const signature = `${type}|${errors.join('|')}`;
129
-
130
- if (!groups[signature]) groups[signature] = { type, errors, ids: [] };
131
- groups[signature].ids.push(id);
132
- });
133
- // Group by component type
132
+
133
+ matches.forEach(match => {
134
+ const [, type, id, errorsStr] = match;
135
+ // Split only on ", /" to avoid breaking apart value lists like "false,soft,hard"
136
+ const errors = errorsStr
137
+ .split(/,\s*(?=\/)/)
138
+ .map(s => s.trim())
139
+ .filter(Boolean)
140
+ .sort();
141
+ const signature = `${type}|${errors.join('|')}`;
142
+
143
+ if (!groups[signature]) groups[signature] = { type, errors, ids: [] };
144
+ groups[signature].ids.push(id);
145
+ });
146
+ });
147
+
148
+ if (!hasContentErrors) return '';
149
+
150
+ // Group by content type
134
151
  const byType = {};
135
152
  Object.values(groups).forEach(group => {
136
153
  if (!byType[group.type]) byType[group.type] = [];
137
154
  byType[group.type].push(group);
138
155
  });
139
-
156
+
140
157
  // Format output
141
158
  const output = [];
142
- // Add prefix messages if any
143
159
  if (prefixMessages.length) output.push(prefixMessages.join(', '));
144
- // Add component errors
160
+
145
161
  const formatted = Object.entries(byType).map(([type, typeGroups]) => {
146
162
  const totalCount = typeGroups.reduce((sum, g) => sum + g.ids.length, 0);
147
163
  const subGroups = typeGroups.map(group => {
@@ -156,12 +172,11 @@ define(function(require){
156
172
  },
157
173
 
158
174
  onError: function(e) {
159
- let text
175
+ let text = e.message
160
176
  try {
161
- text = this.formatErrorString(e.message)
162
- } catch (e) {
163
- text = e.message
164
- }
177
+ const formatted = this.formatErrorString(e.message)
178
+ if (formatted) text = formatted
179
+ } catch {}
165
180
  Origin.Notify.alert({ type: 'error', text });
166
181
  Origin.trigger('sidebar:resetButtons');
167
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "Front-end application for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
6
  "license": "GPL-3.0",
@@ -20,7 +20,7 @@
20
20
  "@rollup/plugin-commonjs": "^29.0.0",
21
21
  "@rollup/plugin-node-resolve": "^16.0.3",
22
22
  "@rollup/plugin-terser": "^0.4.0",
23
- "adapt-authoring-core": "github:adapt-security/adapt-authoring-core",
23
+ "adapt-authoring-core": "^1.7.0",
24
24
  "babel-plugin-transform-amd-to-es6": "^0.6.1",
25
25
  "cpy": "^13.0.0",
26
26
  "fs-extra": "^11.2.0",
@@ -35,6 +35,18 @@
35
35
  "rollup-plugin-inject-process-env": "*",
36
36
  "upath": "^2.0.1"
37
37
  },
38
+ "peerDependencies": {
39
+ "adapt-authoring-adaptframework": "^1.9.4",
40
+ "adapt-authoring-server": "^1.2.1"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "adapt-authoring-adaptframework": {
44
+ "optional": true
45
+ },
46
+ "adapt-authoring-server": {
47
+ "optional": true
48
+ }
49
+ },
38
50
  "devDependencies": {
39
51
  "@semantic-release/git": "^10.0.1",
40
52
  "conventional-changelog-eslint": "^6.0.0",
@@ -57,7 +69,15 @@
57
69
  ],
58
70
  "@semantic-release/npm",
59
71
  "@semantic-release/github",
60
- "@semantic-release/git"
72
+ [
73
+ "@semantic-release/git",
74
+ {
75
+ "assets": [
76
+ "package.json"
77
+ ],
78
+ "message": "Chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
79
+ }
80
+ ]
61
81
  ]
62
82
  },
63
83
  "standard": {