@sap/cds-dk 9.8.4 → 9.9.0

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +18 -2
  2. package/bin/add.js +3 -3
  3. package/bin/cds.js +16 -2
  4. package/bin/import.js +6 -2
  5. package/bin/logout.js +9 -12
  6. package/lib/bind/shared.js +2 -2
  7. package/lib/build/constants.js +0 -1
  8. package/lib/build/index.js +420 -463
  9. package/lib/build/plugins/hana/index.js +121 -2
  10. package/lib/build/plugins/helm/files/subcharts/content-deployment/Chart.yaml +1 -1
  11. package/lib/build/plugins/helm/files/subcharts/content-deployment/templates/job.yaml +1 -1
  12. package/lib/build/plugins/helm/files/subcharts/content-deployment/values.schema.json +4 -0
  13. package/lib/build/plugins/helm/files/subcharts/content-deployment/values.yaml +5 -2
  14. package/lib/build/plugins/internal.js +1 -1
  15. package/lib/build/plugins/mtx-extension/index.js +0 -2
  16. package/lib/deploy/index.js +23 -3
  17. package/lib/deploy/to-hana/hana.js +24 -15
  18. package/lib/import/common.js +6 -3
  19. package/lib/init/constants.js +3 -1
  20. package/lib/init/indent.js +0 -1
  21. package/lib/init/merge.js +0 -1
  22. package/lib/init/mvn.js +4 -2
  23. package/lib/init/projectReader.js +0 -1
  24. package/lib/init/registries/mta.js +4 -2
  25. package/lib/init/template/app-frontend/index.js +39 -4
  26. package/lib/init/template/data/as-csv.js +2 -0
  27. package/lib/init/template/esm/index.js +5 -0
  28. package/lib/init/template/extensibility/index.js +1 -1
  29. package/lib/init/template/hana/index.js +1 -1
  30. package/lib/init/template/html5-repo/files/mta.yaml.hbs +9 -20
  31. package/lib/init/template/http/index.js +34 -6
  32. package/lib/init/template/kyma/index.js +1 -0
  33. package/lib/init/template/postgres/files/values.yaml.hbs +1 -1
  34. package/lib/init/template/postgres/index.js +1 -1
  35. package/lib/init/template/react/files/index.html +13 -0
  36. package/lib/init/template/react/files/package.json.hbs +22 -0
  37. package/lib/init/template/react/files/public/favicon.svg +1 -0
  38. package/lib/init/template/react/files/src/App.jsx.hbs +29 -0
  39. package/lib/init/template/react/files/src/index.css +28 -0
  40. package/lib/init/template/react/files/src/main.jsx +10 -0
  41. package/lib/init/template/react/files/vite.config.js +19 -0
  42. package/lib/init/template/react/index.js +29 -0
  43. package/lib/init/template/sample/index.js +1 -4
  44. package/lib/init/template/typer/index.js +1 -1
  45. package/lib/init/template/typescript/files/package.json +1 -1
  46. package/lib/init/template/typescript/index.js +1 -1
  47. package/lib/init/template/ui5/index.js +2 -1
  48. package/lib/init/template/vue/files/index.html +13 -0
  49. package/lib/init/template/vue/files/package.json.hbs +19 -0
  50. package/lib/init/template/vue/files/public/favicon.svg +1 -0
  51. package/lib/init/template/vue/files/src/App.vue.hbs +34 -0
  52. package/lib/init/template/vue/files/src/main.js +5 -0
  53. package/lib/init/template/vue/files/src/style.css +20 -0
  54. package/lib/init/template/vue/files/vite.config.js +19 -0
  55. package/lib/init/template/vue/index.js +29 -0
  56. package/lib/init/template/workzone-standard/files/mta.yaml.hbs +2 -13
  57. package/lib/init/xml.js +0 -2
  58. package/lib/mtx/auth_manager.js +21 -11
  59. package/lib/mtx/download_legacy.js +9 -8
  60. package/lib/mtx/pull.js +9 -8
  61. package/lib/mtx/push.js +42 -28
  62. package/lib/mtx/settings_manager.js +17 -10
  63. package/lib/mtx/tenant_action.js +9 -9
  64. package/lib/mtx/util/request.js +158 -0
  65. package/lib/util/cf.js +30 -29
  66. package/lib/watch/node-watch.js +1 -1
  67. package/lib/watch/vite-watch.js +76 -0
  68. package/lib/watch/watched.js +5 -4
  69. package/npm-shrinkwrap.json +14 -154
  70. package/package.json +1 -2
  71. package/lib/init/template/sample/files/db/hana/index.cds +0 -10
  72. package/lib/init/template/sample/files/db/sqlite/index.cds +0 -10
  73. package/lib/init/template/sample/files/package.json.hbs +0 -14
  74. package/lib/util/axios.js +0 -118
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "9.8.4",
3
+ "version": "9.9.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "9.8.4",
9
+ "version": "9.9.0",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@cap-js/asyncapi": "^1.0.0",
@@ -14,7 +14,6 @@
14
14
  "@sap/cds": ">=8.3",
15
15
  "@sap/cds-mtxs": ">=2",
16
16
  "@sap/hdi-deploy": "^5",
17
- "axios": "^1",
18
17
  "express": "^4.22.1 || ^5",
19
18
  "hdb": "^2.0.0",
20
19
  "livereload-js": "^4.0.1",
@@ -103,14 +102,14 @@
103
102
  }
104
103
  },
105
104
  "node_modules/@sap/cds": {
106
- "version": "9.8.5",
107
- "integrity": "sha512-AU7HzrdEf8u13W2Aff8GyqKpJh6w9yXK/68xvXD+6cuU21JcGOLQ+dInbNV8vRKaCMn2cVVrsx7OoR+j7z5QKA==",
105
+ "version": "9.9.0",
106
+ "integrity": "sha512-09qkye9erBr71GNt6vdu9HmvZCKSTECYdxppQyAYJjeOeLJW4eL1eyZThawRkvqqLOEdmsEZdfG6eZ3X+w0YYA==",
108
107
  "license": "SEE LICENSE IN LICENSE",
109
108
  "dependencies": {
110
109
  "@sap/cds-compiler": "^6.4",
111
110
  "@sap/cds-fiori": "^2",
112
111
  "express": "^4.22.1 || ^5",
113
- "js-yaml": "^4.1.1"
112
+ "yaml": "^2"
114
113
  },
115
114
  "bin": {
116
115
  "cds-deploy": "bin/deploy.js",
@@ -130,8 +129,8 @@
130
129
  }
131
130
  },
132
131
  "node_modules/@sap/cds-compiler": {
133
- "version": "6.8.0",
134
- "integrity": "sha512-yRoTZcH8DFiP4PcEuIHe42YAaNt51V736+6RRr+U4nbO91sz36L8be2djcE8n760t8IbqLxzZ/UkATiL0fjRmA==",
132
+ "version": "6.9.0",
133
+ "integrity": "sha512-UXQ5pomb+Fw48Ch1mJoN1JkDy0loZX8nZKXjy4qxY2s9FMwNOwKJP9wPomAVlYcuzq6u8Viqh5j70ty8ciGWGg==",
135
134
  "license": "SEE LICENSE IN LICENSE",
136
135
  "bin": {
137
136
  "cdsc": "bin/cdsc.js",
@@ -151,8 +150,8 @@
151
150
  }
152
151
  },
153
152
  "node_modules/@sap/cds-mtxs": {
154
- "version": "3.8.1",
155
- "integrity": "sha512-FUm1of08WsZ1O3eur7OGj7ZYp9Gy3RuYEGBZK+zosSPyJ3QrBhBzKwYvbh2DJdbv3P/xuk46NGg5yz914qZxrw==",
153
+ "version": "3.9.0",
154
+ "integrity": "sha512-U9H9NXQxlxSNwSD/6U59+Egn9LIE2SRdu8i5bZqEG2GB4xEU6csduy0kY4EWvi8XXD8onbFSgw4AA9SB4pN0Yg==",
156
155
  "license": "SEE LICENSE IN LICENSE",
157
156
  "dependencies": {
158
157
  "@sap/hdi-deploy": "^5"
@@ -162,7 +161,7 @@
162
161
  "cds-mtx-migrate": "bin/cds-mtx-migrate.js"
163
162
  },
164
163
  "peerDependencies": {
165
- "@sap/cds": "^9"
164
+ "@sap/cds": ">=9"
166
165
  }
167
166
  },
168
167
  "node_modules/@sap/hdi": {
@@ -241,11 +240,6 @@
241
240
  "node": ">= 0.6"
242
241
  }
243
242
  },
244
- "node_modules/argparse": {
245
- "version": "2.0.1",
246
- "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
247
- "license": "Python-2.0"
248
- },
249
243
  "node_modules/assert-plus": {
250
244
  "version": "1.0.0",
251
245
  "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==",
@@ -259,21 +253,6 @@
259
253
  "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
260
254
  "license": "MIT"
261
255
  },
262
- "node_modules/asynckit": {
263
- "version": "0.4.0",
264
- "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
265
- "license": "MIT"
266
- },
267
- "node_modules/axios": {
268
- "version": "1.15.0",
269
- "integrity": "sha512-wWyJDlAatxk30ZJer+GeCWS209sA42X+N5jU2jy6oHTp7ufw8uzUTVFBX9+wTfAlhiJXGS0Bq7X6efruWjuK9Q==",
270
- "license": "MIT",
271
- "dependencies": {
272
- "follow-redirects": "^1.15.11",
273
- "form-data": "^4.0.5",
274
- "proxy-from-env": "^2.1.0"
275
- }
276
- },
277
256
  "node_modules/base64-js": {
278
257
  "version": "1.5.1",
279
258
  "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
@@ -295,8 +274,8 @@
295
274
  "optional": true
296
275
  },
297
276
  "node_modules/better-sqlite3": {
298
- "version": "12.8.0",
299
- "integrity": "sha512-RxD2Vd96sQDjQr20kdP+F+dK/1OUNiVOl200vKBZY8u0vTwysfolF6Hq+3ZK2+h8My9YvZhHsF+RSGZW2VYrPQ==",
277
+ "version": "12.9.0",
278
+ "integrity": "sha512-wqUv4Gm3toFpHDQmaKD4QhZm3g1DjUBI0yzS4UBl6lElUmXFYdTQmmEDpAFa5o8FiFiymURypEnfVHzILKaxqQ==",
300
279
  "hasInstallScript": true,
301
280
  "license": "MIT",
302
281
  "optional": true,
@@ -435,17 +414,6 @@
435
414
  "node": ">=0.8"
436
415
  }
437
416
  },
438
- "node_modules/combined-stream": {
439
- "version": "1.0.8",
440
- "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
441
- "license": "MIT",
442
- "dependencies": {
443
- "delayed-stream": "~1.0.0"
444
- },
445
- "engines": {
446
- "node": ">= 0.8"
447
- }
448
- },
449
417
  "node_modules/content-disposition": {
450
418
  "version": "1.1.0",
451
419
  "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==",
@@ -527,14 +495,6 @@
527
495
  "node": ">=4.0.0"
528
496
  }
529
497
  },
530
- "node_modules/delayed-stream": {
531
- "version": "1.0.0",
532
- "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
533
- "license": "MIT",
534
- "engines": {
535
- "node": ">=0.4.0"
536
- }
537
- },
538
498
  "node_modules/depd": {
539
499
  "version": "2.0.0",
540
500
  "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
@@ -625,20 +585,6 @@
625
585
  "node": ">= 0.4"
626
586
  }
627
587
  },
628
- "node_modules/es-set-tostringtag": {
629
- "version": "2.1.0",
630
- "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
631
- "license": "MIT",
632
- "dependencies": {
633
- "es-errors": "^1.3.0",
634
- "get-intrinsic": "^1.2.6",
635
- "has-tostringtag": "^1.0.2",
636
- "hasown": "^2.0.2"
637
- },
638
- "engines": {
639
- "node": ">= 0.4"
640
- }
641
- },
642
588
  "node_modules/escape-html": {
643
589
  "version": "1.0.3",
644
590
  "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
@@ -748,59 +694,6 @@
748
694
  "url": "https://opencollective.com/express"
749
695
  }
750
696
  },
751
- "node_modules/follow-redirects": {
752
- "version": "1.15.11",
753
- "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
754
- "funding": [
755
- {
756
- "type": "individual",
757
- "url": "https://github.com/sponsors/RubenVerborgh"
758
- }
759
- ],
760
- "license": "MIT",
761
- "engines": {
762
- "node": ">=4.0"
763
- },
764
- "peerDependenciesMeta": {
765
- "debug": {
766
- "optional": true
767
- }
768
- }
769
- },
770
- "node_modules/form-data": {
771
- "version": "4.0.5",
772
- "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
773
- "license": "MIT",
774
- "dependencies": {
775
- "asynckit": "^0.4.0",
776
- "combined-stream": "^1.0.8",
777
- "es-set-tostringtag": "^2.1.0",
778
- "hasown": "^2.0.2",
779
- "mime-types": "^2.1.12"
780
- },
781
- "engines": {
782
- "node": ">= 6"
783
- }
784
- },
785
- "node_modules/form-data/node_modules/mime-db": {
786
- "version": "1.52.0",
787
- "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
788
- "license": "MIT",
789
- "engines": {
790
- "node": ">= 0.6"
791
- }
792
- },
793
- "node_modules/form-data/node_modules/mime-types": {
794
- "version": "2.1.35",
795
- "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
796
- "license": "MIT",
797
- "dependencies": {
798
- "mime-db": "1.52.0"
799
- },
800
- "engines": {
801
- "node": ">= 0.6"
802
- }
803
- },
804
697
  "node_modules/forwarded": {
805
698
  "version": "0.2.0",
806
699
  "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
@@ -923,23 +816,9 @@
923
816
  "url": "https://github.com/sponsors/ljharb"
924
817
  }
925
818
  },
926
- "node_modules/has-tostringtag": {
927
- "version": "1.0.2",
928
- "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
929
- "license": "MIT",
930
- "dependencies": {
931
- "has-symbols": "^1.0.3"
932
- },
933
- "engines": {
934
- "node": ">= 0.4"
935
- },
936
- "funding": {
937
- "url": "https://github.com/sponsors/ljharb"
938
- }
939
- },
940
819
  "node_modules/hasown": {
941
- "version": "2.0.2",
942
- "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
820
+ "version": "2.0.3",
821
+ "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==",
943
822
  "license": "MIT",
944
823
  "dependencies": {
945
824
  "function-bind": "^1.1.2"
@@ -1063,17 +942,6 @@
1063
942
  "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
1064
943
  "license": "MIT"
1065
944
  },
1066
- "node_modules/js-yaml": {
1067
- "version": "4.1.1",
1068
- "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
1069
- "license": "MIT",
1070
- "dependencies": {
1071
- "argparse": "^2.0.1"
1072
- },
1073
- "bin": {
1074
- "js-yaml": "bin/js-yaml.js"
1075
- }
1076
- },
1077
945
  "node_modules/livereload-js": {
1078
946
  "version": "4.0.2",
1079
947
  "integrity": "sha512-Fy7VwgQNiOkynYyNBTo3v9hQUhcW5pFAheJN148+DTgpShjsy/22pLHKKwDK5v0kOsZsJBK+6q1PMgLvRmrwFQ==",
@@ -1333,14 +1201,6 @@
1333
1201
  "node": ">= 0.10"
1334
1202
  }
1335
1203
  },
1336
- "node_modules/proxy-from-env": {
1337
- "version": "2.1.0",
1338
- "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==",
1339
- "license": "MIT",
1340
- "engines": {
1341
- "node": ">=10"
1342
- }
1343
- },
1344
1204
  "node_modules/pump": {
1345
1205
  "version": "3.0.4",
1346
1206
  "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "9.8.4",
3
+ "version": "9.9.0",
4
4
  "description": "Command line client and development toolkit for the SAP Cloud Application Programming Model",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
@@ -22,7 +22,6 @@
22
22
  "@sap/cds": ">=8.3",
23
23
  "@sap/cds-mtxs": ">=2",
24
24
  "@sap/hdi-deploy": "^5",
25
- "axios": "^1",
26
25
  "express": "^4.22.1 || ^5",
27
26
  "hdb": "^2.0.0",
28
27
  "livereload-js": "^4.0.1",
@@ -1,10 +0,0 @@
1
- //
2
- // Add Author.age and .lifetime with a DB-specific function
3
- //
4
-
5
- using { AdminService } from '../../srv/admin-service';
6
-
7
- extend projection AdminService.Authors with {
8
- YEARS_BETWEEN(dateOfBirth, dateOfDeath) as age: Integer,
9
- YEAR(dateOfBirth) || ' – ' || YEAR(dateOfDeath) as lifetime : String
10
- }
@@ -1,10 +0,0 @@
1
- //
2
- // Add Author.age and .lifetime with a DB-specific function
3
- //
4
-
5
- using { AdminService } from '../../srv/admin-service';
6
-
7
- extend projection AdminService.Authors with {
8
- strftime('%Y',dateOfDeath)-strftime('%Y',dateOfBirth) as age: Integer,
9
- strftime('%Y',dateOfBirth) || ' – ' || strftime('%Y',dateOfDeath) as lifetime : String
10
- }
@@ -1,14 +0,0 @@
1
- {
2
- "cds": {
3
- "requires": {
4
- "db-ext": {
5
- "[development]": {
6
- "model": "db/sqlite"
7
- },
8
- "[production]": {
9
- "model": "db/hana"
10
- }
11
- }
12
- }
13
- }
14
- }
package/lib/util/axios.js DELETED
@@ -1,118 +0,0 @@
1
- module.exports = {
2
- pruneErrors
3
- };
4
-
5
- let interceptor
6
-
7
- function pruneErrors() {
8
-
9
- if (interceptor) {
10
- // Already set up.
11
- return;
12
- }
13
- interceptor = true;
14
-
15
- function stacklessError(message) {
16
- const { stackTraceLimit } = Error;
17
- Error.stackTraceLimit = 0;
18
- const error = new Error(message);
19
- Error.stackTraceLimit = stackTraceLimit;
20
- return error;
21
- }
22
-
23
- require('axios').interceptors.response.use(
24
- response => response,
25
- axError => {
26
- const { inspect } = require('util');
27
-
28
- let { url, method } = axError.config ?? {};
29
- url = url?.replace(/(passcode|refreshToken|clientsecret|key)=[^&]+/g, '$1=...');
30
-
31
- const { errno, code, response = {}, message: axMessage } = axError;
32
- const prefix = (url && method ? `${method.toUpperCase()} ${url}` : 'Request') + ' failed';
33
-
34
- function fixData(data) {
35
- if (Buffer.isBuffer(data)) {
36
- let str = data.toString();
37
- try {
38
- data = JSON.parse(str);
39
- } catch {
40
- data = str;
41
- }
42
- }
43
- return data;
44
- }
45
-
46
- function extractErrorDetails(data) {
47
- if (!data) return undefined;
48
-
49
- if (typeof data === "string") {
50
- if (/<html/i.test(data)) {
51
- return '(HTML response received. If applicable, ensure the route to MTX is configured correctly in App Router.)';
52
- }
53
- if (data.length >= 1000) return undefined;
54
- return data.trim();
55
- }
56
-
57
- if (typeof data === "object") {
58
- if (data.error_description) return data.error_description; // OAuth RFC
59
- if (data.error && typeof data.error === "object" && data.error.message) return data.error.message;
60
- if (data.error && typeof data.error === "string") return data.error;
61
- if (typeof data.message === "string") return data.message;
62
- return inspect(data); // fallback
63
- }
64
-
65
- return undefined;
66
- }
67
-
68
- let error;
69
- const debug = require('../').log('req')._debug;
70
-
71
- if (errno) {
72
- // System/network errors
73
- const message = prefix +
74
- `: ${errno} ${code}` +
75
- (/\b(ENOTFOUND|EAI_AGAIN)\b/.test(code)
76
- ? `. Make sure the URL is correct and the server is running.`
77
- : '');
78
- error = stacklessError(message);
79
- } else {
80
- // HTTP errors
81
- const { status, statusText } = response;
82
- let { data } = response;
83
- data = fixData(data);
84
- const details = extractErrorDetails(data);
85
- const reason = typeof data?.error === "string"
86
- ? data.error
87
- : undefined;
88
- const errObj = debug && typeof data.error === 'object'
89
- ? inspect(data.error)
90
- : undefined;
91
-
92
- const message = prefix +
93
- (status || statusText || reason || details
94
- ? (status || statusText ? ':' : '') +
95
- (status ? ` ${status}` : '') +
96
- (statusText ? ` ${statusText}` : '') +
97
- (reason ? `. ${reason}` : '') +
98
- (details ? `. Details: ${details}` : '') +
99
- (errObj ? `. Error object: ${errObj}` : '')
100
- : (axMessage ? `: ${axMessage}` : '')
101
- );
102
-
103
- error = stacklessError(message);
104
- if (status) error.status = status;
105
- if (data?.passcode_url) {
106
- error.auth = { passcode_url: data.passcode_url };
107
- }
108
- }
109
-
110
- if (debug) {
111
- error.cause = axError;
112
- }
113
-
114
- return Promise.reject(error);
115
- }
116
- );
117
- return module.exports;
118
- }