@itentialopensource/adapter-gitlab 0.19.0 → 0.19.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/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ## 0.19.1 [02-06-2026]
3
+
4
+ * Fix repository file content encoding handling
5
+
6
+ See merge request itentialopensource/adapters/adapter-gitlab!56
7
+
8
+ ---
9
+
2
10
  ## 0.15.4 [10-15-2024]
3
11
 
4
12
  * Changes made at 2024.10.14_21:29PM
package/adapter.js CHANGED
@@ -15,6 +15,39 @@ const path = require('path');
15
15
  /* Fetch in the other needed components for the this Adaptor */
16
16
  const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
17
17
 
18
+ /**
19
+ * Prevents GitLab API encoding mismatch issues by ensuring the encoding field
20
+ * accurately reflects content format (base64 vs text).
21
+ *
22
+ * @param {object} payload - The request payload
23
+ * @return {object} A new object with content encoded if necessary
24
+ */
25
+ function handleRepositoryFileEncoding(payload) {
26
+ const result = { ...payload };
27
+
28
+ const isContentEncoded = result.isEncoded === true;
29
+ delete result.isEncoded;
30
+
31
+ if (isContentEncoded) {
32
+ return result;
33
+ }
34
+
35
+ if (result.content === undefined || result.content === null) {
36
+ return result;
37
+ }
38
+
39
+ if (result.encoding === 'text') {
40
+ return result;
41
+ }
42
+
43
+ if ((result.encoding === 'base64' || !result.encoding) && typeof result.content === 'string') {
44
+ result.content = Buffer.from(result.content).toString('base64');
45
+ result.encoding = 'base64';
46
+ }
47
+
48
+ return result;
49
+ }
50
+
18
51
  /**
19
52
  * This is the adapter/interface into Gitlab
20
53
  */
@@ -28717,7 +28750,7 @@ class Gitlab extends AdapterBaseCl {
28717
28750
  const queryParamsAvailable = {};
28718
28751
  const queryParams = {};
28719
28752
  const pathVars = [id, filePath];
28720
- const bodyVars = body;
28753
+ const bodyVars = handleRepositoryFileEncoding(body);
28721
28754
 
28722
28755
  // loop in template. long callback arg name to avoid identifier conflicts
28723
28756
  Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
@@ -28803,7 +28836,7 @@ class Gitlab extends AdapterBaseCl {
28803
28836
  const queryParamsAvailable = {};
28804
28837
  const queryParams = {};
28805
28838
  const pathVars = [id, filePath];
28806
- const bodyVars = body;
28839
+ const bodyVars = handleRepositoryFileEncoding(body);
28807
28840
 
28808
28841
  // loop in template. long callback arg name to avoid identifier conflicts
28809
28842
  Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
@@ -895,9 +895,9 @@
895
895
  },
896
896
  "content": {
897
897
  "type": "string",
898
- "description": "Include file content - encoded",
898
+ "description": "Include file content",
899
899
  "parse": true,
900
- "encode": true,
900
+ "encode": false,
901
901
  "encrypt": {
902
902
  "type": "AES",
903
903
  "key": ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-gitlab",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "This adapter integrates with system described as: gitlab.",
5
5
  "main": "adapter.js",
6
6
  "systemName": "Gitlab",
@@ -1,10 +1,10 @@
1
1
  {
2
- "version": "0.16.4",
3
- "configLines": 42806,
2
+ "version": "0.19.0",
3
+ "configLines": 42850,
4
4
  "scriptLines": 2498,
5
- "codeLines": 45166,
6
- "testLines": 43103,
5
+ "codeLines": 45252,
6
+ "testLines": 43109,
7
7
  "testCases": 2271,
8
- "totalCodeLines": 90767,
8
+ "totalCodeLines": 90859,
9
9
  "wfTasks": 571
10
10
  }
@@ -37396,12 +37396,12 @@
37396
37396
  }
37397
37397
  ],
37398
37398
  "requestBody": {
37399
- "description": "indeterminate body object",
37400
37399
  "content": {
37401
37400
  "application/json": {
37402
37401
  "schema": {
37403
- "type": "object"
37404
- }
37402
+ "type": "string"
37403
+ },
37404
+ "example": "handleRepositoryFileEncoding()"
37405
37405
  }
37406
37406
  }
37407
37407
  }
@@ -37457,12 +37457,12 @@
37457
37457
  }
37458
37458
  ],
37459
37459
  "requestBody": {
37460
- "description": "indeterminate body object",
37461
37460
  "content": {
37462
37461
  "application/json": {
37463
37462
  "schema": {
37464
- "type": "object"
37465
- }
37463
+ "type": "string"
37464
+ },
37465
+ "example": "handleRepositoryFileEncoding()"
37466
37466
  }
37467
37467
  }
37468
37468
  }