@cyberskill/shared 1.50.0 → 1.52.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 (147) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +100 -129
  2. package/dist/_tsup-dts-rollup.d.ts +100 -129
  3. package/dist/cli.cjs +1 -2146
  4. package/dist/cli.d.cts +1 -2
  5. package/dist/cli.d.ts +1 -2
  6. package/dist/cli.js +1 -2066
  7. package/dist/configs/commitlint/base.cjs +1 -64
  8. package/dist/configs/commitlint/base.js +1 -7
  9. package/dist/configs/eslint/base.cjs +1 -121
  10. package/dist/configs/eslint/base.js +1 -52
  11. package/dist/configs/eslint/nestjs.cjs +1 -155
  12. package/dist/configs/eslint/nestjs.js +1 -85
  13. package/dist/configs/eslint/nextjs.cjs +1 -155
  14. package/dist/configs/eslint/nextjs.js +1 -85
  15. package/dist/configs/eslint/nodejs.cjs +1 -156
  16. package/dist/configs/eslint/nodejs.js +1 -86
  17. package/dist/configs/eslint/vite-react.cjs +1 -159
  18. package/dist/configs/eslint/vite-react.js +1 -89
  19. package/dist/configs/graphql/graphql-codegen.cjs +1 -125
  20. package/dist/configs/graphql/graphql-codegen.js +1 -64
  21. package/dist/configs/graphql/index.cjs +1 -126
  22. package/dist/configs/graphql/index.js +1 -64
  23. package/dist/configs/i18n/react/i18next.cjs +1 -80
  24. package/dist/configs/i18n/react/i18next.js +1 -7
  25. package/dist/configs/i18n/react/index.cjs +1 -81
  26. package/dist/configs/i18n/react/index.js +1 -7
  27. package/dist/configs/index.cjs +1 -232
  28. package/dist/configs/index.js +1 -166
  29. package/dist/configs/lint-staged/base.cjs +1 -64
  30. package/dist/configs/lint-staged/base.js +1 -7
  31. package/dist/configs/vitest/react/e2e.cjs +1 -128
  32. package/dist/configs/vitest/react/e2e.js +1 -59
  33. package/dist/configs/vitest/react/unit.cjs +1 -305
  34. package/dist/configs/vitest/react/unit.js +1 -228
  35. package/dist/configs/vitest/react/unit.setup.cjs +1 -60
  36. package/dist/configs/vitest/react/unit.setup.js +1 -8
  37. package/dist/constants/index.cjs +1 -677
  38. package/dist/constants/index.d.cts +8 -3
  39. package/dist/constants/index.d.ts +8 -3
  40. package/dist/constants/index.js +1 -468
  41. package/dist/constants/path.cjs +1 -422
  42. package/dist/constants/path.d.cts +8 -3
  43. package/dist/constants/path.d.ts +8 -3
  44. package/dist/constants/path.js +1 -217
  45. package/dist/constants/response-status.cjs +1 -313
  46. package/dist/constants/response-status.js +1 -252
  47. package/dist/index.cjs +1 -4559
  48. package/dist/index.d.cts +13 -8
  49. package/dist/index.d.ts +13 -8
  50. package/dist/index.js +1 -4142
  51. package/dist/nodejs/index.cjs +1 -2138
  52. package/dist/nodejs/index.js +1 -2054
  53. package/dist/nodejs/mongo.cjs +1 -2137
  54. package/dist/nodejs/mongo.js +1 -2054
  55. package/dist/react/apollo-client.cjs +1 -177
  56. package/dist/react/apollo-client.js +1 -116
  57. package/dist/react/index.cjs +1 -990
  58. package/dist/react/index.js +1 -876
  59. package/dist/react/loading.cjs +1 -301
  60. package/dist/react/loading.js +1 -216
  61. package/dist/react/next-intl.cjs +1 -744
  62. package/dist/react/next-intl.js +1 -655
  63. package/dist/react/storage.cjs +1 -631
  64. package/dist/react/storage.js +1 -558
  65. package/dist/typescript/api-response.cjs +1 -48
  66. package/dist/typescript/apollo.cjs +1 -48
  67. package/dist/typescript/command.cjs +1 -68
  68. package/dist/typescript/command.d.cts +3 -0
  69. package/dist/typescript/command.d.ts +3 -0
  70. package/dist/typescript/command.js +1 -7
  71. package/dist/typescript/config.cjs +1 -48
  72. package/dist/typescript/fs.cjs +1 -48
  73. package/dist/typescript/graphql-codegen.cjs +1 -48
  74. package/dist/typescript/index.cjs +1 -175
  75. package/dist/typescript/index.d.cts +3 -0
  76. package/dist/typescript/index.d.ts +3 -0
  77. package/dist/typescript/index.js +1 -151
  78. package/dist/typescript/loading.cjs +1 -48
  79. package/dist/typescript/log.cjs +1 -48
  80. package/dist/typescript/mongo.cjs +1 -164
  81. package/dist/typescript/mongo.js +1 -145
  82. package/dist/typescript/next-intl.cjs +1 -48
  83. package/dist/typescript/react.cjs +1 -48
  84. package/dist/typescript/serializer.cjs +1 -48
  85. package/dist/typescript/string.cjs +1 -48
  86. package/dist/utils/command.cjs +1 -1387
  87. package/dist/utils/command.d.cts +2 -2
  88. package/dist/utils/command.d.ts +2 -2
  89. package/dist/utils/command.js +1 -1287
  90. package/dist/utils/common.cjs +1 -300
  91. package/dist/utils/common.js +1 -219
  92. package/dist/utils/config.cjs +1 -146
  93. package/dist/utils/config.js +1 -89
  94. package/dist/utils/fs.cjs +1 -132
  95. package/dist/utils/fs.js +1 -47
  96. package/dist/utils/index-nodejs.cjs +1 -1752
  97. package/dist/utils/index-nodejs.d.cts +2 -5
  98. package/dist/utils/index-nodejs.d.ts +2 -5
  99. package/dist/utils/index-nodejs.js +1 -1581
  100. package/dist/utils/index.cjs +1 -727
  101. package/dist/utils/index.js +1 -625
  102. package/dist/utils/log.cjs +1 -330
  103. package/dist/utils/log.js +1 -269
  104. package/dist/utils/package.cjs +1 -941
  105. package/dist/utils/package.js +1 -857
  106. package/dist/utils/path.cjs +1 -291
  107. package/dist/utils/path.d.cts +0 -3
  108. package/dist/utils/path.d.ts +0 -3
  109. package/dist/utils/path.js +1 -191
  110. package/dist/utils/serializer.cjs +1 -91
  111. package/dist/utils/serializer.js +1 -30
  112. package/dist/utils/storage-client.cjs +1 -349
  113. package/dist/utils/storage-client.js +1 -276
  114. package/dist/utils/storage-server.cjs +1 -636
  115. package/dist/utils/storage-server.js +1 -550
  116. package/dist/utils/string.cjs +1 -152
  117. package/dist/utils/string.js +1 -75
  118. package/dist/utils/validate.cjs +1 -90
  119. package/dist/utils/validate.js +1 -33
  120. package/package.json +15 -13
  121. /package/{src/public → public}/favicon/android-icon-144x144.png +0 -0
  122. /package/{src/public → public}/favicon/android-icon-192x192.png +0 -0
  123. /package/{src/public → public}/favicon/android-icon-36x36.png +0 -0
  124. /package/{src/public → public}/favicon/android-icon-48x48.png +0 -0
  125. /package/{src/public → public}/favicon/android-icon-72x72.png +0 -0
  126. /package/{src/public → public}/favicon/android-icon-96x96.png +0 -0
  127. /package/{src/public → public}/favicon/apple-icon-114x114.png +0 -0
  128. /package/{src/public → public}/favicon/apple-icon-120x120.png +0 -0
  129. /package/{src/public → public}/favicon/apple-icon-144x144.png +0 -0
  130. /package/{src/public → public}/favicon/apple-icon-152x152.png +0 -0
  131. /package/{src/public → public}/favicon/apple-icon-180x180.png +0 -0
  132. /package/{src/public → public}/favicon/apple-icon-57x57.png +0 -0
  133. /package/{src/public → public}/favicon/apple-icon-60x60.png +0 -0
  134. /package/{src/public → public}/favicon/apple-icon-72x72.png +0 -0
  135. /package/{src/public → public}/favicon/apple-icon-76x76.png +0 -0
  136. /package/{src/public → public}/favicon/apple-icon-precomposed.png +0 -0
  137. /package/{src/public → public}/favicon/apple-icon.png +0 -0
  138. /package/{src/public → public}/favicon/browserconfig.xml +0 -0
  139. /package/{src/public → public}/favicon/favicon-16x16.png +0 -0
  140. /package/{src/public → public}/favicon/favicon-32x32.png +0 -0
  141. /package/{src/public → public}/favicon/favicon-96x96.png +0 -0
  142. /package/{src/public → public}/favicon/favicon.ico +0 -0
  143. /package/{src/public → public}/favicon/manifest.json +0 -0
  144. /package/{src/public → public}/favicon/ms-icon-144x144.png +0 -0
  145. /package/{src/public → public}/favicon/ms-icon-150x150.png +0 -0
  146. /package/{src/public → public}/favicon/ms-icon-310x310.png +0 -0
  147. /package/{src/public → public}/favicon/ms-icon-70x70.png +0 -0
@@ -1,330 +1 @@
1
- "use strict";
2
- function _type_of(obj) {
3
- "@swc/helpers - typeof";
4
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5
- }
6
- var __defProp = Object.defineProperty;
7
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __export = function(target, all) {
11
- for(var name in all)__defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- };
16
- var __copyProps = function(to, from, except, desc) {
17
- if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
18
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19
- try {
20
- var _loop = function() {
21
- var key = _step.value;
22
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
- get: function() {
24
- return from[key];
25
- },
26
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
- });
28
- };
29
- for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
30
- } catch (err) {
31
- _didIteratorError = true;
32
- _iteratorError = err;
33
- } finally{
34
- try {
35
- if (!_iteratorNormalCompletion && _iterator.return != null) {
36
- _iterator.return();
37
- }
38
- } finally{
39
- if (_didIteratorError) {
40
- throw _iteratorError;
41
- }
42
- }
43
- }
44
- }
45
- return to;
46
- };
47
- var __toCommonJS = function(mod) {
48
- return __copyProps(__defProp({}, "__esModule", {
49
- value: true
50
- }), mod);
51
- };
52
- // src/utils/log.ts
53
- var log_exports = {};
54
- __export(log_exports, {
55
- throwResponse: function() {
56
- return throwResponse;
57
- }
58
- });
59
- module.exports = __toCommonJS(log_exports);
60
- var import_graphql = require("graphql");
61
- // src/constants/response-status.ts
62
- var RESPONSE_STATUS = {
63
- GRAPHQL_PARSE_FAILED: {
64
- CODE: "GRAPHQL_PARSE_FAILED",
65
- MESSAGE: "The GraphQL operation string contains a syntax error."
66
- },
67
- GRAPHQL_VALIDATION_FAILED: {
68
- CODE: "GRAPHQL_VALIDATION_FAILED",
69
- MESSAGE: "The GraphQL operation is not valid against the server's schema."
70
- },
71
- BAD_USER_INPUT: {
72
- CODE: "BAD_USER_INPUT",
73
- MESSAGE: "The GraphQL operation includes an invalid value for a field argument."
74
- },
75
- PERSISTED_QUERY_NOT_FOUND: {
76
- CODE: "PERSISTED_QUERY_NOT_FOUND",
77
- MESSAGE: "A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."
78
- },
79
- PERSISTED_QUERY_NOT_SUPPORTED: {
80
- CODE: "PERSISTED_QUERY_NOT_SUPPORTED",
81
- MESSAGE: "A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."
82
- },
83
- OPERATION_RESOLUTION_FAILURE: {
84
- CODE: "OPERATION_RESOLUTION_FAILURE",
85
- MESSAGE: "The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."
86
- },
87
- CONTINUE: {
88
- CODE: 100,
89
- MESSAGE: "Continue"
90
- },
91
- SWITCHING_PROTOCOLS: {
92
- CODE: 101,
93
- MESSAGE: "Switching Protocols"
94
- },
95
- PROCESSING: {
96
- CODE: 102,
97
- MESSAGE: "Processing"
98
- },
99
- OK: {
100
- CODE: 200,
101
- MESSAGE: "OK"
102
- },
103
- CREATED: {
104
- CODE: 201,
105
- MESSAGE: "Created"
106
- },
107
- ACCEPTED: {
108
- CODE: 202,
109
- MESSAGE: "Accepted"
110
- },
111
- NON_AUTHORITATIVE_INFORMATION: {
112
- CODE: 203,
113
- MESSAGE: "Non Authoritative Information"
114
- },
115
- NO_CONTENT: {
116
- CODE: 204,
117
- MESSAGE: "No Content"
118
- },
119
- RESET_CONTENT: {
120
- CODE: 205,
121
- MESSAGE: "Reset Content"
122
- },
123
- PARTIAL_CONTENT: {
124
- CODE: 206,
125
- MESSAGE: "Partial Content"
126
- },
127
- MULTI_STATUS: {
128
- CODE: 207,
129
- MESSAGE: "Multi-Status"
130
- },
131
- MULTIPLE_CHOICES: {
132
- CODE: 300,
133
- MESSAGE: "Multiple Choices"
134
- },
135
- MOVED_PERMANENTLY: {
136
- CODE: 301,
137
- MESSAGE: "Moved Permanently"
138
- },
139
- MOVED_TEMPORARILY: {
140
- CODE: 302,
141
- MESSAGE: "Moved Temporarily"
142
- },
143
- SEE_OTHER: {
144
- CODE: 303,
145
- MESSAGE: "See Other"
146
- },
147
- NOT_MODIFIED: {
148
- CODE: 304,
149
- MESSAGE: "Not Modified"
150
- },
151
- USE_PROXY: {
152
- CODE: 305,
153
- MESSAGE: "Use Proxy"
154
- },
155
- TEMPORARY_REDIRECT: {
156
- CODE: 307,
157
- MESSAGE: "Temporary Redirect"
158
- },
159
- PERMANENT_REDIRECT: {
160
- CODE: 308,
161
- MESSAGE: "Permanent Redirect"
162
- },
163
- BAD_REQUEST: {
164
- CODE: 400,
165
- MESSAGE: "Bad Request"
166
- },
167
- UNAUTHORIZED: {
168
- CODE: 401,
169
- MESSAGE: "Unauthorized"
170
- },
171
- PAYMENT_REQUIRED: {
172
- CODE: 402,
173
- MESSAGE: "Payment Required"
174
- },
175
- FORBIDDEN: {
176
- CODE: 403,
177
- MESSAGE: "Forbidden"
178
- },
179
- NOT_FOUND: {
180
- CODE: 404,
181
- MESSAGE: "Not Found"
182
- },
183
- METHOD_NOT_ALLOWED: {
184
- CODE: 405,
185
- MESSAGE: "Method Not Allowed"
186
- },
187
- NOT_ACCEPTABLE: {
188
- CODE: 406,
189
- MESSAGE: "Not Acceptable"
190
- },
191
- PROXY_AUTHENTICATION_REQUIRED: {
192
- CODE: 407,
193
- MESSAGE: "Proxy Authentication Required"
194
- },
195
- REQUEST_TIMEOUT: {
196
- CODE: 408,
197
- MESSAGE: "Request Timeout"
198
- },
199
- CONFLICT: {
200
- CODE: 409,
201
- MESSAGE: "Conflict"
202
- },
203
- GONE: {
204
- CODE: 410,
205
- MESSAGE: "Gone"
206
- },
207
- LENGTH_REQUIRED: {
208
- CODE: 411,
209
- MESSAGE: "Length Required"
210
- },
211
- PRECONDITION_FAILED: {
212
- CODE: 412,
213
- MESSAGE: "Precondition Failed"
214
- },
215
- REQUEST_TOO_LONG: {
216
- CODE: 413,
217
- MESSAGE: "Request Entity Too Large"
218
- },
219
- REQUEST_URI_TOO_LONG: {
220
- CODE: 414,
221
- MESSAGE: "Request-URI Too Long"
222
- },
223
- UNSUPPORTED_MEDIA_TYPE: {
224
- CODE: 415,
225
- MESSAGE: "Unsupported Media Type"
226
- },
227
- REQUESTED_RANGE_NOT_SATISFIABLE: {
228
- CODE: 416,
229
- MESSAGE: "Requested Range Not Satisfiable"
230
- },
231
- EXPECTATION_FAILED: {
232
- CODE: 417,
233
- MESSAGE: "Expectation Failed"
234
- },
235
- IM_A_TEAPOT: {
236
- CODE: 418,
237
- MESSAGE: "I'm a teapot"
238
- },
239
- INSUFFICIENT_SPACE_ON_RESOURCE: {
240
- CODE: 419,
241
- MESSAGE: "Insufficient Space on Resource"
242
- },
243
- METHOD_FAILURE: {
244
- CODE: 420,
245
- MESSAGE: "Method Failure"
246
- },
247
- MISDIRECTED_REQUEST: {
248
- CODE: 421,
249
- MESSAGE: "Misdirected Request"
250
- },
251
- UNPROCESSABLE_ENTITY: {
252
- CODE: 422,
253
- MESSAGE: "Unprocessable Entity"
254
- },
255
- LOCKED: {
256
- CODE: 423,
257
- MESSAGE: "Locked"
258
- },
259
- FAILED_DEPENDENCY: {
260
- CODE: 424,
261
- MESSAGE: "Failed Dependency"
262
- },
263
- PRECONDITION_REQUIRED: {
264
- CODE: 428,
265
- MESSAGE: "Precondition Required"
266
- },
267
- TOO_MANY_REQUESTS: {
268
- CODE: 429,
269
- MESSAGE: "Too Many Requests"
270
- },
271
- REQUEST_HEADER_FIELDS_TOO_LARGE: {
272
- CODE: 431,
273
- MESSAGE: "Request Header Fields Too Large"
274
- },
275
- UNAVAILABLE_FOR_LEGAL_REASONS: {
276
- CODE: 451,
277
- MESSAGE: "Unavailable For Legal Reasons"
278
- },
279
- INTERNAL_SERVER_ERROR: {
280
- CODE: 500,
281
- MESSAGE: "Internal Server Error"
282
- },
283
- NOT_IMPLEMENTED: {
284
- CODE: 501,
285
- MESSAGE: "Not Implemented"
286
- },
287
- BAD_GATEWAY: {
288
- CODE: 502,
289
- MESSAGE: "Bad Gateway"
290
- },
291
- SERVICE_UNAVAILABLE: {
292
- CODE: 503,
293
- MESSAGE: "Service Unavailable"
294
- },
295
- GATEWAY_TIMEOUT: {
296
- CODE: 504,
297
- MESSAGE: "Gateway Timeout"
298
- },
299
- HTTP_VERSION_NOT_SUPPORTED: {
300
- CODE: 505,
301
- MESSAGE: "HTTP Version Not Supported"
302
- },
303
- INSUFFICIENT_STORAGE: {
304
- CODE: 507,
305
- MESSAGE: "Insufficient Storage"
306
- },
307
- NETWORK_AUTHENTICATION_REQUIRED: {
308
- CODE: 511,
309
- MESSAGE: "Network Authentication Required"
310
- }
311
- };
312
- // src/utils/log.ts
313
- function throwResponse(param) {
314
- var message = param.message, _param_status = param.status, status = _param_status === void 0 ? RESPONSE_STATUS.INTERNAL_SERVER_ERROR : _param_status, _param_type = param.type, type = _param_type === void 0 ? "graphql" : _param_type;
315
- var _ref;
316
- var responseMessage = (_ref = message !== null && message !== void 0 ? message : status.MESSAGE) !== null && _ref !== void 0 ? _ref : "Internal server error";
317
- if (type === "graphql") {
318
- throw new import_graphql.GraphQLError(responseMessage, {
319
- extensions: {
320
- code: status.CODE
321
- }
322
- });
323
- } else {
324
- throw new Error(responseMessage);
325
- }
326
- }
327
- // Annotate the CommonJS export names for ESM import in node:
328
- 0 && (module.exports = {
329
- throwResponse: throwResponse
330
- });
1
+ "use strict";function E(E){"@swc/helpers - typeof";return E&&typeof Symbol!=="undefined"&&E.constructor===Symbol?"symbol":typeof E}var e=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var O=function(E,t){for(var S in t)e(E,S,{get:t[S],enumerable:!0})},o=function(O,o,n,A){var a=true,i=false,T=undefined;if(o&&(typeof o==="undefined"?"undefined":E(o))=="object"||typeof o=="function")try{var D=function(){var E=C.value;!r.call(O,E)&&E!==n&&e(O,E,{get:function(){return o[E]},enumerable:!(A=t(o,E))||A.enumerable})};for(var R=S(o)[Symbol.iterator](),C;!(a=(C=R.next()).done);a=true)D()}catch(E){i=true;T=E}finally{try{if(!a&&R.return!=null){R.return()}}finally{if(i){throw T}}}return O};var n=function(E){return o(e({},"__esModule",{value:!0}),E)};var A={};O(A,{throwResponse:function(){return T}});module.exports=n(A);var a=require("graphql");var i={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function T(E){var e=E.message,t=E.status,S=t===void 0?i.INTERNAL_SERVER_ERROR:t,r=E.type,O=r===void 0?"graphql":r;var o;var n=(o=e!==null&&e!==void 0?e:S.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw O==="graphql"?new a.GraphQLError(n,{extensions:{code:S.CODE}}):new Error(n)}0&&(module.exports={throwResponse:throwResponse});
package/dist/utils/log.js CHANGED
@@ -1,269 +1 @@
1
- // src/utils/log.ts
2
- import { GraphQLError } from "graphql";
3
- // src/constants/response-status.ts
4
- var RESPONSE_STATUS = {
5
- GRAPHQL_PARSE_FAILED: {
6
- CODE: "GRAPHQL_PARSE_FAILED",
7
- MESSAGE: "The GraphQL operation string contains a syntax error."
8
- },
9
- GRAPHQL_VALIDATION_FAILED: {
10
- CODE: "GRAPHQL_VALIDATION_FAILED",
11
- MESSAGE: "The GraphQL operation is not valid against the server's schema."
12
- },
13
- BAD_USER_INPUT: {
14
- CODE: "BAD_USER_INPUT",
15
- MESSAGE: "The GraphQL operation includes an invalid value for a field argument."
16
- },
17
- PERSISTED_QUERY_NOT_FOUND: {
18
- CODE: "PERSISTED_QUERY_NOT_FOUND",
19
- MESSAGE: "A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."
20
- },
21
- PERSISTED_QUERY_NOT_SUPPORTED: {
22
- CODE: "PERSISTED_QUERY_NOT_SUPPORTED",
23
- MESSAGE: "A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."
24
- },
25
- OPERATION_RESOLUTION_FAILURE: {
26
- CODE: "OPERATION_RESOLUTION_FAILURE",
27
- MESSAGE: "The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."
28
- },
29
- CONTINUE: {
30
- CODE: 100,
31
- MESSAGE: "Continue"
32
- },
33
- SWITCHING_PROTOCOLS: {
34
- CODE: 101,
35
- MESSAGE: "Switching Protocols"
36
- },
37
- PROCESSING: {
38
- CODE: 102,
39
- MESSAGE: "Processing"
40
- },
41
- OK: {
42
- CODE: 200,
43
- MESSAGE: "OK"
44
- },
45
- CREATED: {
46
- CODE: 201,
47
- MESSAGE: "Created"
48
- },
49
- ACCEPTED: {
50
- CODE: 202,
51
- MESSAGE: "Accepted"
52
- },
53
- NON_AUTHORITATIVE_INFORMATION: {
54
- CODE: 203,
55
- MESSAGE: "Non Authoritative Information"
56
- },
57
- NO_CONTENT: {
58
- CODE: 204,
59
- MESSAGE: "No Content"
60
- },
61
- RESET_CONTENT: {
62
- CODE: 205,
63
- MESSAGE: "Reset Content"
64
- },
65
- PARTIAL_CONTENT: {
66
- CODE: 206,
67
- MESSAGE: "Partial Content"
68
- },
69
- MULTI_STATUS: {
70
- CODE: 207,
71
- MESSAGE: "Multi-Status"
72
- },
73
- MULTIPLE_CHOICES: {
74
- CODE: 300,
75
- MESSAGE: "Multiple Choices"
76
- },
77
- MOVED_PERMANENTLY: {
78
- CODE: 301,
79
- MESSAGE: "Moved Permanently"
80
- },
81
- MOVED_TEMPORARILY: {
82
- CODE: 302,
83
- MESSAGE: "Moved Temporarily"
84
- },
85
- SEE_OTHER: {
86
- CODE: 303,
87
- MESSAGE: "See Other"
88
- },
89
- NOT_MODIFIED: {
90
- CODE: 304,
91
- MESSAGE: "Not Modified"
92
- },
93
- USE_PROXY: {
94
- CODE: 305,
95
- MESSAGE: "Use Proxy"
96
- },
97
- TEMPORARY_REDIRECT: {
98
- CODE: 307,
99
- MESSAGE: "Temporary Redirect"
100
- },
101
- PERMANENT_REDIRECT: {
102
- CODE: 308,
103
- MESSAGE: "Permanent Redirect"
104
- },
105
- BAD_REQUEST: {
106
- CODE: 400,
107
- MESSAGE: "Bad Request"
108
- },
109
- UNAUTHORIZED: {
110
- CODE: 401,
111
- MESSAGE: "Unauthorized"
112
- },
113
- PAYMENT_REQUIRED: {
114
- CODE: 402,
115
- MESSAGE: "Payment Required"
116
- },
117
- FORBIDDEN: {
118
- CODE: 403,
119
- MESSAGE: "Forbidden"
120
- },
121
- NOT_FOUND: {
122
- CODE: 404,
123
- MESSAGE: "Not Found"
124
- },
125
- METHOD_NOT_ALLOWED: {
126
- CODE: 405,
127
- MESSAGE: "Method Not Allowed"
128
- },
129
- NOT_ACCEPTABLE: {
130
- CODE: 406,
131
- MESSAGE: "Not Acceptable"
132
- },
133
- PROXY_AUTHENTICATION_REQUIRED: {
134
- CODE: 407,
135
- MESSAGE: "Proxy Authentication Required"
136
- },
137
- REQUEST_TIMEOUT: {
138
- CODE: 408,
139
- MESSAGE: "Request Timeout"
140
- },
141
- CONFLICT: {
142
- CODE: 409,
143
- MESSAGE: "Conflict"
144
- },
145
- GONE: {
146
- CODE: 410,
147
- MESSAGE: "Gone"
148
- },
149
- LENGTH_REQUIRED: {
150
- CODE: 411,
151
- MESSAGE: "Length Required"
152
- },
153
- PRECONDITION_FAILED: {
154
- CODE: 412,
155
- MESSAGE: "Precondition Failed"
156
- },
157
- REQUEST_TOO_LONG: {
158
- CODE: 413,
159
- MESSAGE: "Request Entity Too Large"
160
- },
161
- REQUEST_URI_TOO_LONG: {
162
- CODE: 414,
163
- MESSAGE: "Request-URI Too Long"
164
- },
165
- UNSUPPORTED_MEDIA_TYPE: {
166
- CODE: 415,
167
- MESSAGE: "Unsupported Media Type"
168
- },
169
- REQUESTED_RANGE_NOT_SATISFIABLE: {
170
- CODE: 416,
171
- MESSAGE: "Requested Range Not Satisfiable"
172
- },
173
- EXPECTATION_FAILED: {
174
- CODE: 417,
175
- MESSAGE: "Expectation Failed"
176
- },
177
- IM_A_TEAPOT: {
178
- CODE: 418,
179
- MESSAGE: "I'm a teapot"
180
- },
181
- INSUFFICIENT_SPACE_ON_RESOURCE: {
182
- CODE: 419,
183
- MESSAGE: "Insufficient Space on Resource"
184
- },
185
- METHOD_FAILURE: {
186
- CODE: 420,
187
- MESSAGE: "Method Failure"
188
- },
189
- MISDIRECTED_REQUEST: {
190
- CODE: 421,
191
- MESSAGE: "Misdirected Request"
192
- },
193
- UNPROCESSABLE_ENTITY: {
194
- CODE: 422,
195
- MESSAGE: "Unprocessable Entity"
196
- },
197
- LOCKED: {
198
- CODE: 423,
199
- MESSAGE: "Locked"
200
- },
201
- FAILED_DEPENDENCY: {
202
- CODE: 424,
203
- MESSAGE: "Failed Dependency"
204
- },
205
- PRECONDITION_REQUIRED: {
206
- CODE: 428,
207
- MESSAGE: "Precondition Required"
208
- },
209
- TOO_MANY_REQUESTS: {
210
- CODE: 429,
211
- MESSAGE: "Too Many Requests"
212
- },
213
- REQUEST_HEADER_FIELDS_TOO_LARGE: {
214
- CODE: 431,
215
- MESSAGE: "Request Header Fields Too Large"
216
- },
217
- UNAVAILABLE_FOR_LEGAL_REASONS: {
218
- CODE: 451,
219
- MESSAGE: "Unavailable For Legal Reasons"
220
- },
221
- INTERNAL_SERVER_ERROR: {
222
- CODE: 500,
223
- MESSAGE: "Internal Server Error"
224
- },
225
- NOT_IMPLEMENTED: {
226
- CODE: 501,
227
- MESSAGE: "Not Implemented"
228
- },
229
- BAD_GATEWAY: {
230
- CODE: 502,
231
- MESSAGE: "Bad Gateway"
232
- },
233
- SERVICE_UNAVAILABLE: {
234
- CODE: 503,
235
- MESSAGE: "Service Unavailable"
236
- },
237
- GATEWAY_TIMEOUT: {
238
- CODE: 504,
239
- MESSAGE: "Gateway Timeout"
240
- },
241
- HTTP_VERSION_NOT_SUPPORTED: {
242
- CODE: 505,
243
- MESSAGE: "HTTP Version Not Supported"
244
- },
245
- INSUFFICIENT_STORAGE: {
246
- CODE: 507,
247
- MESSAGE: "Insufficient Storage"
248
- },
249
- NETWORK_AUTHENTICATION_REQUIRED: {
250
- CODE: 511,
251
- MESSAGE: "Network Authentication Required"
252
- }
253
- };
254
- // src/utils/log.ts
255
- function throwResponse(param) {
256
- var message = param.message, _param_status = param.status, status = _param_status === void 0 ? RESPONSE_STATUS.INTERNAL_SERVER_ERROR : _param_status, _param_type = param.type, type = _param_type === void 0 ? "graphql" : _param_type;
257
- var _ref;
258
- var responseMessage = (_ref = message !== null && message !== void 0 ? message : status.MESSAGE) !== null && _ref !== void 0 ? _ref : "Internal server error";
259
- if (type === "graphql") {
260
- throw new GraphQLError(responseMessage, {
261
- extensions: {
262
- code: status.CODE
263
- }
264
- });
265
- } else {
266
- throw new Error(responseMessage);
267
- }
268
- }
269
- export { throwResponse };
1
+ import{GraphQLError as E}from"graphql";var e={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};function S(S){var O=S.message,A=S.status,t=A===void 0?e.INTERNAL_SERVER_ERROR:A,T=S.type,D=T===void 0?"graphql":T;var o;var R=(o=O!==null&&O!==void 0?O:t.MESSAGE)!==null&&o!==void 0?o:"Internal server error";throw D==="graphql"?new E(R,{extensions:{code:t.CODE}}):new Error(R)}export{S as throwResponse};