@shware/http 2.11.4 → 2.12.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 (236) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +13 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +13 -0
  3. package/dist/cache/index.cjs +5 -30
  4. package/dist/cache/index.cjs.map +1 -1
  5. package/dist/cache/index.d.cts +7 -5
  6. package/dist/cache/index.d.cts.map +1 -0
  7. package/dist/cache/index.d.mts +11 -0
  8. package/dist/cache/index.d.mts.map +1 -0
  9. package/dist/cache/index.mjs +5 -6
  10. package/dist/cache/index.mjs.map +1 -1
  11. package/dist/error/detail.cjs +100 -90
  12. package/dist/error/detail.cjs.map +1 -1
  13. package/dist/error/detail.d.cts +77 -78
  14. package/dist/error/detail.d.cts.map +1 -0
  15. package/dist/error/detail.d.mts +108 -0
  16. package/dist/error/detail.d.mts.map +1 -0
  17. package/dist/error/detail.mjs +99 -65
  18. package/dist/error/detail.mjs.map +1 -1
  19. package/dist/error/i18n/en-us.cjs +5 -29
  20. package/dist/error/i18n/en-us.cjs.map +1 -1
  21. package/dist/error/i18n/en-us.d.cts +3 -1
  22. package/dist/error/i18n/en-us.d.cts.map +1 -0
  23. package/dist/error/i18n/en-us.d.mts +5 -0
  24. package/dist/error/i18n/en-us.d.mts.map +1 -0
  25. package/dist/error/i18n/en-us.mjs +5 -5
  26. package/dist/error/i18n/en-us.mjs.map +1 -1
  27. package/dist/error/index.cjs +29 -56
  28. package/dist/error/index.cjs.map +1 -1
  29. package/dist/error/index.d.cts +12 -10
  30. package/dist/error/index.d.cts.map +1 -0
  31. package/dist/error/index.d.mts +21 -0
  32. package/dist/error/index.d.mts.map +1 -0
  33. package/dist/error/index.mjs +25 -28
  34. package/dist/error/index.mjs.map +1 -1
  35. package/dist/error/parse.cjs +63 -61
  36. package/dist/error/parse.cjs.map +1 -1
  37. package/dist/error/parse.d.cts +8 -7
  38. package/dist/error/parse.d.cts.map +1 -0
  39. package/dist/error/{parse.d.ts → parse.d.mts} +8 -7
  40. package/dist/error/parse.d.mts.map +1 -0
  41. package/dist/error/parse.mjs +59 -33
  42. package/dist/error/parse.mjs.map +1 -1
  43. package/dist/error/reason.cjs +0 -19
  44. package/dist/error/reason.d.cts +5 -4
  45. package/dist/error/reason.d.cts.map +1 -0
  46. package/dist/error/reason.d.mts +6 -0
  47. package/dist/error/reason.d.mts.map +1 -0
  48. package/dist/error/reason.mjs +1 -1
  49. package/dist/error/status.cjs +103 -256
  50. package/dist/error/status.cjs.map +1 -1
  51. package/dist/error/status.d.cts +58 -58
  52. package/dist/error/status.d.cts.map +1 -0
  53. package/dist/error/status.d.mts +69 -0
  54. package/dist/error/status.d.mts.map +1 -0
  55. package/dist/error/status.mjs +98 -227
  56. package/dist/error/status.mjs.map +1 -1
  57. package/dist/google-one-tap/index.cjs +135 -138
  58. package/dist/google-one-tap/index.cjs.map +1 -1
  59. package/dist/google-one-tap/index.d.cts +49 -48
  60. package/dist/google-one-tap/index.d.cts.map +1 -0
  61. package/dist/google-one-tap/index.d.mts +82 -0
  62. package/dist/google-one-tap/index.d.mts.map +1 -0
  63. package/dist/google-one-tap/index.mjs +133 -112
  64. package/dist/google-one-tap/index.mjs.map +1 -1
  65. package/dist/google-one-tap/types.cjs +0 -19
  66. package/dist/google-one-tap/types.d.cts +124 -122
  67. package/dist/google-one-tap/types.d.cts.map +1 -0
  68. package/dist/google-one-tap/types.d.mts +157 -0
  69. package/dist/google-one-tap/types.d.mts.map +1 -0
  70. package/dist/google-one-tap/types.mjs +1 -1
  71. package/dist/hono/authorizer.cjs +28 -65
  72. package/dist/hono/authorizer.cjs.map +1 -1
  73. package/dist/hono/authorizer.d.cts +12 -11
  74. package/dist/hono/authorizer.d.cts.map +1 -0
  75. package/dist/hono/authorizer.d.mts +19 -0
  76. package/dist/hono/authorizer.d.mts.map +1 -0
  77. package/dist/hono/authorizer.mjs +23 -36
  78. package/dist/hono/authorizer.mjs.map +1 -1
  79. package/dist/hono/csrf.cjs +81 -92
  80. package/dist/hono/csrf.cjs.map +1 -1
  81. package/dist/hono/csrf.d.cts +46 -45
  82. package/dist/hono/csrf.d.cts.map +1 -0
  83. package/dist/hono/csrf.d.mts +76 -0
  84. package/dist/hono/csrf.d.mts.map +1 -0
  85. package/dist/hono/csrf.mjs +76 -63
  86. package/dist/hono/csrf.mjs.map +1 -1
  87. package/dist/hono/geolocation.cjs +10 -34
  88. package/dist/hono/geolocation.cjs.map +1 -1
  89. package/dist/hono/geolocation.d.cts +5 -4
  90. package/dist/hono/geolocation.d.cts.map +1 -0
  91. package/dist/hono/geolocation.d.mts +7 -0
  92. package/dist/hono/geolocation.d.mts.map +1 -0
  93. package/dist/hono/geolocation.mjs +8 -12
  94. package/dist/hono/geolocation.mjs.map +1 -1
  95. package/dist/hono/handler.cjs +37 -61
  96. package/dist/hono/handler.cjs.map +1 -1
  97. package/dist/hono/handler.d.cts +26 -25
  98. package/dist/hono/handler.d.cts.map +1 -0
  99. package/dist/hono/handler.d.mts +32 -0
  100. package/dist/hono/handler.d.mts.map +1 -0
  101. package/dist/hono/handler.mjs +34 -34
  102. package/dist/hono/handler.mjs.map +1 -1
  103. package/dist/hono/index.cjs +14 -48
  104. package/dist/hono/index.d.cts +7 -15
  105. package/dist/hono/index.d.mts +7 -0
  106. package/dist/hono/index.mjs +4 -14
  107. package/dist/hono/rate-limit.cjs +65 -110
  108. package/dist/hono/rate-limit.cjs.map +1 -1
  109. package/dist/hono/rate-limit.d.cts +27 -26
  110. package/dist/hono/rate-limit.d.cts.map +1 -0
  111. package/dist/hono/rate-limit.d.mts +36 -0
  112. package/dist/hono/rate-limit.d.mts.map +1 -0
  113. package/dist/hono/rate-limit.mjs +60 -81
  114. package/dist/hono/rate-limit.mjs.map +1 -1
  115. package/dist/hono/validator.cjs +47 -66
  116. package/dist/hono/validator.cjs.map +1 -1
  117. package/dist/hono/validator.d.cts +25 -30
  118. package/dist/hono/validator.d.cts.map +1 -0
  119. package/dist/hono/validator.d.mts +26 -0
  120. package/dist/hono/validator.d.mts.map +1 -0
  121. package/dist/hono/validator.mjs +43 -43
  122. package/dist/hono/validator.mjs.map +1 -1
  123. package/dist/index.cjs +39 -95
  124. package/dist/index.d.cts +12 -14
  125. package/dist/index.d.mts +12 -0
  126. package/dist/index.mjs +5 -48
  127. package/dist/iso/iso_3601_1.cjs +1512 -290
  128. package/dist/iso/iso_3601_1.cjs.map +1 -1
  129. package/dist/iso/iso_3601_1.d.cts +8 -6
  130. package/dist/iso/iso_3601_1.d.cts.map +1 -0
  131. package/dist/iso/iso_3601_1.d.mts +11 -0
  132. package/dist/iso/iso_3601_1.d.mts.map +1 -0
  133. package/dist/iso/iso_3601_1.mjs +1511 -265
  134. package/dist/iso/iso_3601_1.mjs.map +1 -1
  135. package/dist/max-length/index.cjs +158 -91
  136. package/dist/max-length/index.cjs.map +1 -1
  137. package/dist/max-length/index.d.cts +110 -1
  138. package/dist/max-length/index.d.cts.map +1 -0
  139. package/dist/{index-BhgdyigB.d.ts → max-length/index.d.mts} +9 -28
  140. package/dist/max-length/index.d.mts.map +1 -0
  141. package/dist/max-length/index.mjs +133 -47
  142. package/dist/max-length/index.mjs.map +1 -1
  143. package/dist/message.cjs +5 -30
  144. package/dist/message.cjs.map +1 -1
  145. package/dist/message.d.cts +3 -1
  146. package/dist/message.d.cts.map +1 -0
  147. package/dist/{message.d.ts → message.d.mts} +3 -1
  148. package/dist/message.d.mts.map +1 -0
  149. package/dist/message.mjs +5 -6
  150. package/dist/message.mjs.map +1 -1
  151. package/dist/polyfills/index.cjs +4 -4
  152. package/dist/polyfills/index.cjs.map +1 -1
  153. package/dist/polyfills/index.d.cts +1 -2
  154. package/dist/polyfills/index.d.mts +1 -0
  155. package/dist/polyfills/index.mjs +5 -2
  156. package/dist/polyfills/index.mjs.map +1 -1
  157. package/dist/response.cjs +191 -208
  158. package/dist/response.cjs.map +1 -1
  159. package/dist/response.d.cts +53 -54
  160. package/dist/response.d.cts.map +1 -0
  161. package/dist/response.d.mts +82 -0
  162. package/dist/response.d.mts.map +1 -0
  163. package/dist/response.mjs +182 -175
  164. package/dist/response.mjs.map +1 -1
  165. package/dist/snowflake.cjs +48 -70
  166. package/dist/snowflake.cjs.map +1 -1
  167. package/dist/snowflake.d.cts +16 -14
  168. package/dist/snowflake.d.cts.map +1 -0
  169. package/dist/snowflake.d.mts +31 -0
  170. package/dist/snowflake.d.mts.map +1 -0
  171. package/dist/snowflake.mjs +46 -44
  172. package/dist/snowflake.mjs.map +1 -1
  173. package/dist/utils/geolocation.cjs +51 -75
  174. package/dist/utils/geolocation.cjs.map +1 -1
  175. package/dist/utils/geolocation.d.cts +14 -12
  176. package/dist/utils/geolocation.d.cts.map +1 -0
  177. package/dist/utils/{geolocation.d.ts → geolocation.d.mts} +14 -12
  178. package/dist/utils/geolocation.d.mts.map +1 -0
  179. package/dist/utils/geolocation.mjs +47 -47
  180. package/dist/utils/geolocation.mjs.map +1 -1
  181. package/dist/utils/google-tag-gateway.cjs +35 -56
  182. package/dist/utils/google-tag-gateway.cjs.map +1 -1
  183. package/dist/utils/google-tag-gateway.d.cts +3 -1
  184. package/dist/utils/google-tag-gateway.d.cts.map +1 -0
  185. package/dist/utils/{google-tag-gateway.d.ts → google-tag-gateway.d.mts} +3 -1
  186. package/dist/utils/google-tag-gateway.d.mts.map +1 -0
  187. package/dist/utils/google-tag-gateway.mjs +33 -30
  188. package/dist/utils/google-tag-gateway.mjs.map +1 -1
  189. package/dist/utils/timing.cjs +50 -71
  190. package/dist/utils/timing.cjs.map +1 -1
  191. package/dist/utils/timing.d.cts +11 -9
  192. package/dist/utils/timing.d.cts.map +1 -0
  193. package/dist/utils/timing.d.mts +15 -0
  194. package/dist/utils/timing.d.mts.map +1 -0
  195. package/dist/utils/timing.mjs +49 -46
  196. package/dist/utils/timing.mjs.map +1 -1
  197. package/dist/webhook/index.cjs +43 -72
  198. package/dist/webhook/index.cjs.map +1 -1
  199. package/dist/webhook/index.d.cts +3 -1
  200. package/dist/webhook/index.d.cts.map +1 -0
  201. package/dist/webhook/{index.d.ts → index.d.mts} +3 -1
  202. package/dist/webhook/index.d.mts.map +1 -0
  203. package/dist/webhook/index.mjs +41 -46
  204. package/dist/webhook/index.mjs.map +1 -1
  205. package/package.json +49 -24
  206. package/dist/cache/index.d.ts +0 -9
  207. package/dist/error/detail.d.ts +0 -109
  208. package/dist/error/i18n/en-us.d.ts +0 -3
  209. package/dist/error/index.d.ts +0 -19
  210. package/dist/error/reason.cjs.map +0 -1
  211. package/dist/error/reason.d.ts +0 -5
  212. package/dist/error/reason.mjs.map +0 -1
  213. package/dist/error/status.d.ts +0 -69
  214. package/dist/google-one-tap/index.d.ts +0 -81
  215. package/dist/google-one-tap/types.cjs.map +0 -1
  216. package/dist/google-one-tap/types.d.ts +0 -155
  217. package/dist/google-one-tap/types.mjs.map +0 -1
  218. package/dist/hono/authorizer.d.ts +0 -18
  219. package/dist/hono/csrf.d.ts +0 -75
  220. package/dist/hono/geolocation.d.ts +0 -6
  221. package/dist/hono/handler.d.ts +0 -31
  222. package/dist/hono/index.cjs.map +0 -1
  223. package/dist/hono/index.d.ts +0 -15
  224. package/dist/hono/index.mjs.map +0 -1
  225. package/dist/hono/rate-limit.d.ts +0 -35
  226. package/dist/hono/validator.d.ts +0 -31
  227. package/dist/index-BhgdyigB.d.cts +0 -129
  228. package/dist/index.cjs.map +0 -1
  229. package/dist/index.d.ts +0 -14
  230. package/dist/index.mjs.map +0 -1
  231. package/dist/iso/iso_3601_1.d.ts +0 -9
  232. package/dist/max-length/index.d.ts +0 -1
  233. package/dist/polyfills/index.d.ts +0 -2
  234. package/dist/response.d.ts +0 -83
  235. package/dist/snowflake.d.ts +0 -29
  236. package/dist/utils/timing.d.ts +0 -13
@@ -1,263 +1,110 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/error/status.ts
3
+ const Code = {
4
+ OK: 200,
5
+ CANCELLED: 499,
6
+ UNKNOWN: 500,
7
+ INVALID_ARGUMENT: 400,
8
+ DEADLINE_EXCEEDED: 504,
9
+ NOT_FOUND: 404,
10
+ ALREADY_EXISTS: 409,
11
+ PERMISSION_DENIED: 403,
12
+ RESOURCE_EXHAUSTED: 429,
13
+ FAILED_PRECONDITION: 400,
14
+ ABORTED: 409,
15
+ OUT_OF_RANGE: 400,
16
+ UNIMPLEMENTED: 501,
17
+ INTERNAL: 500,
18
+ UNAVAILABLE: 503,
19
+ DATA_LOSS: 500,
20
+ UNAUTHENTICATED: 401,
21
+ METHOD_NOT_ALLOWED: 405
9
22
  };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
23
+ const DEFAULT_MESSAGES = {
24
+ OK: "OK",
25
+ CANCELLED: "The operation was cancelled",
26
+ UNKNOWN: "Unknown error",
27
+ INVALID_ARGUMENT: "The client specified an invalid argument",
28
+ DEADLINE_EXCEEDED: "The deadline expired before the operation could complete",
29
+ NOT_FOUND: "Some requested entity was not found",
30
+ ALREADY_EXISTS: "The entity that a client attempted to create already exists",
31
+ PERMISSION_DENIED: "The caller does not have permission to execute the specified operation",
32
+ RESOURCE_EXHAUSTED: "Some resource has been exhausted",
33
+ FAILED_PRECONDITION: "The operation was rejected because the system is not in a state required for the operation's execution",
34
+ ABORTED: "The operation was aborted",
35
+ OUT_OF_RANGE: "The operation was attempted past the valid range",
36
+ UNIMPLEMENTED: "The operation is not implemented or is not supported/enabled in this service",
37
+ INTERNAL: "Internal errors",
38
+ UNAVAILABLE: "The service is currently unavailable",
39
+ DATA_LOSS: "Unrecoverable data loss or corruption",
40
+ UNAUTHENTICATED: "The request does not have valid authentication credentials for the operation",
41
+ METHOD_NOT_ALLOWED: "The request method is not supported by the server and cannot be handled"
17
42
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/error/status.ts
21
- var status_exports = {};
22
- __export(status_exports, {
23
- Code: () => Code,
24
- DEFAULT_MESSAGES: () => DEFAULT_MESSAGES,
25
- Status: () => Status,
26
- StatusCode: () => StatusCode,
27
- StatusError: () => StatusError
28
- });
29
- module.exports = __toCommonJS(status_exports);
30
- var Code = {
31
- // Not an error; returned on success
32
- //
33
- // HTTP Mapping: 200 OK
34
- OK: 200,
35
- // The operation was cancelled, typically by the caller.
36
- //
37
- // HTTP Mapping: 499 Client Closed Request
38
- CANCELLED: 499,
39
- // Unknown error. For example, this error may be returned when
40
- // a `Status` value received from another address space belongs to
41
- // an error space that is not known in this address space. Also,
42
- // errors raised by APIs that do not return enough error information
43
- // may be converted to this error.
44
- //
45
- // HTTP Mapping: 500 Internal Server Error
46
- UNKNOWN: 500,
47
- // The client specified an invalid argument. Note that this differs
48
- // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
49
- // that are problematic regardless of the state of the system
50
- // (e.g., a malformed file name).
51
- //
52
- // HTTP Mapping: 400 Bad Request
53
- INVALID_ARGUMENT: 400,
54
- // The deadline expired before the operation could complete. For operations
55
- // that change the state of the system, this error may be returned
56
- // even if the operation has completed successfully. For example, a
57
- // successful response from a server could have been delayed long
58
- // enough for the deadline to expire.
59
- //
60
- // HTTP Mapping: 504 Gateway Timeout
61
- DEADLINE_EXCEEDED: 504,
62
- // Some requested entity (e.g., file or directory) was not found.
63
- //
64
- // Note to server developers: if a request is denied for an entire class
65
- // of users, such as gradual feature rollout or undocumented whitelist,
66
- // `NOT_FOUND` may be used. If a request is denied for some users within
67
- // a class of users, such as user-based access control, `PERMISSION_DENIED`
68
- // must be used.
69
- //
70
- // HTTP Mapping: 404 Not Found
71
- NOT_FOUND: 404,
72
- // The entity that a client attempted to create (e.g., file or directory)
73
- // already exists.
74
- //
75
- // HTTP Mapping: 409 Conflict
76
- ALREADY_EXISTS: 409,
77
- // The caller does not have permission to execute the specified
78
- // operation. `PERMISSION_DENIED` must not be used for rejections
79
- // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
80
- // instead for those errors). `PERMISSION_DENIED` must not be
81
- // used if the caller can not be identified (use `UNAUTHENTICATED`
82
- // instead for those errors). This error code does not imply the
83
- // request is valid or the requested entity exists or satisfies
84
- // other pre-conditions.
85
- //
86
- // HTTP Mapping: 403 Forbidden
87
- PERMISSION_DENIED: 403,
88
- // Some resource has been exhausted, perhaps a per-user quota, or
89
- // perhaps the entire file system is out of space.
90
- //
91
- // HTTP Mapping: 429 Too Many Requests
92
- RESOURCE_EXHAUSTED: 429,
93
- // The operation was rejected because the system is not in a state
94
- // required for the operation's execution. For example, the directory
95
- // to be deleted is non-empty, a rmdir operation is applied to
96
- // a non-directory, etc.
97
- //
98
- // Service implementors can use the following guidelines to decide
99
- // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
100
- // (a) Use `UNAVAILABLE` if the client can retry just the failing call.
101
- // (b) Use `ABORTED` if the client should retry at a higher level
102
- // (e.g., when a client-specified test-and-set fails, indicating the
103
- // client should restart a read-modify-write sequence).
104
- // (c) Use `FAILED_PRECONDITION` if the client should not retry until
105
- // the system state has been explicitly fixed. E.g., if a "rmdir"
106
- // fails because the directory is non-empty, `FAILED_PRECONDITION`
107
- // should be returned since the client should not retry unless
108
- // the files are deleted from the directory.
109
- //
110
- // HTTP Mapping: 400 Bad Request
111
- FAILED_PRECONDITION: 400,
112
- // The operation was aborted, typically due to a concurrency issue such as
113
- // a sequencer check failure or transaction abort.
114
- //
115
- // See the guidelines above for deciding between `FAILED_PRECONDITION`,
116
- // `ABORTED`, and `UNAVAILABLE`.
117
- //
118
- // HTTP Mapping: 409 Conflict
119
- ABORTED: 409,
120
- // The operation was attempted past the valid range. E.g., seeking or
121
- // reading past end-of-file.
122
- //
123
- // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
124
- // be fixed if the system state changes. For example, a 32-bit file
125
- // system will generate `INVALID_ARGUMENT` if asked to read at an
126
- // offset that is not in the range [0,2^32-1], but it will generate
127
- // `OUT_OF_RANGE` if asked to read from an offset past the current
128
- // file size.
129
- //
130
- // There is a fair bit of overlap between `FAILED_PRECONDITION` and
131
- // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
132
- // error) when it applies so that callers who are iterating through
133
- // a space can easily look for an `OUT_OF_RANGE` error to detect when
134
- // they are done.
135
- //
136
- // HTTP Mapping: 400 Bad Request
137
- OUT_OF_RANGE: 400,
138
- // The operation is not implemented or is not supported/enabled in this
139
- // service.
140
- //
141
- // HTTP Mapping: 501 Not Implemented
142
- UNIMPLEMENTED: 501,
143
- // Internal errors. This means that some invariants expected by the
144
- // underlying system have been broken. This error code is reserved
145
- // for serious errors.
146
- //
147
- // HTTP Mapping: 500 Internal Server Error
148
- INTERNAL: 500,
149
- // The service is currently unavailable. This is most likely a
150
- // transient condition, which can be corrected by retrying with
151
- // a backoff. Note that it is not always safe to retry
152
- // non-idempotent operations.
153
- //
154
- // See the guidelines above for deciding between `FAILED_PRECONDITION`,
155
- // `ABORTED`, and `UNAVAILABLE`.
156
- //
157
- // HTTP Mapping: 503 Service Unavailable
158
- UNAVAILABLE: 503,
159
- // Unrecoverable data loss or corruption.
160
- //
161
- // HTTP Mapping: 500 Internal Server Error
162
- DATA_LOSS: 500,
163
- // The request does not have valid authentication credentials for the
164
- // operation.
165
- //
166
- // HTTP Mapping: 401 Unauthorized
167
- UNAUTHENTICATED: 401,
168
- // The request method is not supported by the server and cannot be handled.
169
- //
170
- // HTTP Mapping: 405 Method Not Allowed
171
- METHOD_NOT_ALLOWED: 405
172
- };
173
- var DEFAULT_MESSAGES = {
174
- OK: "OK",
175
- CANCELLED: "The operation was cancelled",
176
- UNKNOWN: "Unknown error",
177
- INVALID_ARGUMENT: "The client specified an invalid argument",
178
- DEADLINE_EXCEEDED: "The deadline expired before the operation could complete",
179
- NOT_FOUND: "Some requested entity was not found",
180
- ALREADY_EXISTS: "The entity that a client attempted to create already exists",
181
- PERMISSION_DENIED: "The caller does not have permission to execute the specified operation",
182
- RESOURCE_EXHAUSTED: "Some resource has been exhausted",
183
- FAILED_PRECONDITION: "The operation was rejected because the system is not in a state required for the operation's execution",
184
- ABORTED: "The operation was aborted",
185
- OUT_OF_RANGE: "The operation was attempted past the valid range",
186
- UNIMPLEMENTED: "The operation is not implemented or is not supported/enabled in this service",
187
- INTERNAL: "Internal errors",
188
- UNAVAILABLE: "The service is currently unavailable",
189
- DATA_LOSS: "Unrecoverable data loss or corruption",
190
- UNAUTHENTICATED: "The request does not have valid authentication credentials for the operation",
191
- METHOD_NOT_ALLOWED: "The request method is not supported by the server and cannot be handled"
43
+ var StatusError = class StatusError extends Error {
44
+ status;
45
+ body;
46
+ constructor(status, body) {
47
+ super(body?.error?.message ?? `Status Error: ${status}`);
48
+ this.name = "StatusError";
49
+ this.status = status;
50
+ this.body = body;
51
+ Object.setPrototypeOf(this, StatusError.prototype);
52
+ }
192
53
  };
193
- var StatusError = class _StatusError extends Error {
194
- status;
195
- body;
196
- constructor(status, body) {
197
- super(body?.error?.message ?? `Status Error: ${status}`);
198
- this.name = "StatusError";
199
- this.status = status;
200
- this.body = body;
201
- Object.setPrototypeOf(this, _StatusError.prototype);
202
- }
203
- };
204
- var StatusCode = class _StatusCode {
205
- code;
206
- message;
207
- constructor(code, message) {
208
- this.code = code;
209
- this.message = message;
210
- }
211
- static of(code, message) {
212
- return new _StatusCode(code, message ?? DEFAULT_MESSAGES[code]);
213
- }
214
- body(details) {
215
- return {
216
- error: {
217
- code: Code[this.code],
218
- status: this.code,
219
- message: this.message ?? "",
220
- details: details?.list ?? []
221
- }
222
- };
223
- }
224
- error(details) {
225
- const body = this.body(details);
226
- if (Status.adapter) return Status.adapter(Code[this.code], body);
227
- return new StatusError(Code[this.code], body);
228
- }
229
- response(details) {
230
- const body = this.body(details);
231
- return Response.json(body, { status: body.error.code });
232
- }
54
+ var StatusCode = class StatusCode {
55
+ code;
56
+ message;
57
+ constructor(code, message) {
58
+ this.code = code;
59
+ this.message = message;
60
+ }
61
+ static of(code, message) {
62
+ return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);
63
+ }
64
+ body(details) {
65
+ return { error: {
66
+ code: Code[this.code],
67
+ status: this.code,
68
+ message: this.message ?? "",
69
+ details: details?.list ?? []
70
+ } };
71
+ }
72
+ error(details) {
73
+ const body = this.body(details);
74
+ if (Status.adapter) return Status.adapter(Code[this.code], body);
75
+ return new StatusError(Code[this.code], body);
76
+ }
77
+ response(details) {
78
+ const body = this.body(details);
79
+ return Response.json(body, { status: body.error.code });
80
+ }
233
81
  };
234
82
  var Status = class {
235
- static adapter;
236
- static ok = (message) => StatusCode.of("OK", message);
237
- static cancelled = (message) => StatusCode.of("CANCELLED", message);
238
- static unknown = (message) => StatusCode.of("UNKNOWN", message);
239
- static invalidArgument = (message) => StatusCode.of("INVALID_ARGUMENT", message);
240
- static deadlineExceeded = (message) => StatusCode.of("DEADLINE_EXCEEDED", message);
241
- static notFound = (message) => StatusCode.of("NOT_FOUND", message);
242
- static alreadyExists = (message) => StatusCode.of("ALREADY_EXISTS", message);
243
- static permissionDenied = (message) => StatusCode.of("PERMISSION_DENIED", message);
244
- static unauthorized = (message) => StatusCode.of("UNAUTHENTICATED", message);
245
- static resourceExhausted = (message) => StatusCode.of("RESOURCE_EXHAUSTED", message);
246
- static failedPrecondition = (message) => StatusCode.of("FAILED_PRECONDITION", message);
247
- static aborted = (message) => StatusCode.of("ABORTED", message);
248
- static outOfRange = (message) => StatusCode.of("OUT_OF_RANGE", message);
249
- static unimplemented = (message) => StatusCode.of("UNIMPLEMENTED", message);
250
- static internal = (message) => StatusCode.of("INTERNAL", message);
251
- static unavailable = (message) => StatusCode.of("UNAVAILABLE", message);
252
- static dataLoss = (message) => StatusCode.of("DATA_LOSS", message);
253
- static methodNotAllowed = (message) => StatusCode.of("METHOD_NOT_ALLOWED", message);
83
+ static adapter;
84
+ static ok = (message) => StatusCode.of("OK", message);
85
+ static cancelled = (message) => StatusCode.of("CANCELLED", message);
86
+ static unknown = (message) => StatusCode.of("UNKNOWN", message);
87
+ static invalidArgument = (message) => StatusCode.of("INVALID_ARGUMENT", message);
88
+ static deadlineExceeded = (message) => StatusCode.of("DEADLINE_EXCEEDED", message);
89
+ static notFound = (message) => StatusCode.of("NOT_FOUND", message);
90
+ static alreadyExists = (message) => StatusCode.of("ALREADY_EXISTS", message);
91
+ static permissionDenied = (message) => StatusCode.of("PERMISSION_DENIED", message);
92
+ static unauthorized = (message) => StatusCode.of("UNAUTHENTICATED", message);
93
+ static resourceExhausted = (message) => StatusCode.of("RESOURCE_EXHAUSTED", message);
94
+ static failedPrecondition = (message) => StatusCode.of("FAILED_PRECONDITION", message);
95
+ static aborted = (message) => StatusCode.of("ABORTED", message);
96
+ static outOfRange = (message) => StatusCode.of("OUT_OF_RANGE", message);
97
+ static unimplemented = (message) => StatusCode.of("UNIMPLEMENTED", message);
98
+ static internal = (message) => StatusCode.of("INTERNAL", message);
99
+ static unavailable = (message) => StatusCode.of("UNAVAILABLE", message);
100
+ static dataLoss = (message) => StatusCode.of("DATA_LOSS", message);
101
+ static methodNotAllowed = (message) => StatusCode.of("METHOD_NOT_ALLOWED", message);
254
102
  };
255
- // Annotate the CommonJS export names for ESM import in node:
256
- 0 && (module.exports = {
257
- Code,
258
- DEFAULT_MESSAGES,
259
- Status,
260
- StatusCode,
261
- StatusError
262
- });
103
+ //#endregion
104
+ exports.Code = Code;
105
+ exports.DEFAULT_MESSAGES = DEFAULT_MESSAGES;
106
+ exports.Status = Status;
107
+ exports.StatusCode = StatusCode;
108
+ exports.StatusError = StatusError;
109
+
263
110
  //# sourceMappingURL=status.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was cancelled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error?.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":"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","names":[]}
1
+ {"version":3,"file":"status.cjs","names":[],"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was cancelled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error?.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":";;AAEA,MAAa,OAAO;CAIlB,IAAI;CAKJ,WAAW;CASX,SAAS;CAQT,kBAAkB;CASlB,mBAAmB;CAWnB,WAAW;CAMX,gBAAgB;CAYhB,mBAAmB;CAMnB,oBAAoB;CAoBpB,qBAAqB;CASrB,SAAS;CAmBT,cAAc;CAMd,eAAe;CAOf,UAAU;CAWV,aAAa;CAKb,WAAW;CAMX,iBAAiB;CAKjB,oBAAoB;AACtB;AAEA,MAAa,mBAAsD;CACjE,IAAI;CACJ,WAAW;CACX,SAAS;CACT,kBAAkB;CAClB,mBAAmB;CACnB,WAAW;CACX,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACpB,qBACE;CACF,SAAS;CACT,cAAc;CACd,eAAe;CACf,UAAU;CACV,aAAa;CACb,WAAW;CACX,iBAAiB;CACjB,oBAAoB;AACtB;AAWA,IAAa,cAAb,MAAa,oBAAoB,MAAM;CACrC;CACA;CAEA,YAAY,QAAgB,MAAkB;EAC5C,MAAM,MAAM,OAAO,WAAW,iBAAiB,QAAQ;EACvD,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,OAAO,eAAe,MAAM,YAAY,SAAS;CACnD;AACF;AAEA,IAAa,aAAb,MAAa,WAAW;CACtB;CACA;CACA,YAAoB,MAAyB,SAAkB;EAC7D,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;CAEA,OAAO,GAAG,MAAyB,SAAkB;EACnD,OAAO,IAAI,WAAW,MAAM,WAAW,iBAAiB,KAAK;CAC/D;CAEA,KAAK,SAA8B;EACjC,OAAO,EACL,OAAO;GACL,MAAM,KAAK,KAAK;GAChB,QAAQ,KAAK;GACb,SAAS,KAAK,WAAW;GACzB,SAAS,SAAS,QAAQ,CAAC;EAC7B,EACF;CACF;CAEA,MAAM,SAA0B;EAC9B,MAAM,OAAO,KAAK,KAAK,OAAO;EAC9B,IAAI,OAAO,SAAS,OAAO,OAAO,QAAQ,KAAK,KAAK,OAAO,IAAI;EAC/D,OAAO,IAAI,YAAY,KAAK,KAAK,OAAO,IAAI;CAC9C;CAEA,SAAS,SAA6B;EACpC,MAAM,OAAO,KAAK,KAAK,OAAO;EAC9B,OAAO,SAAS,KAAK,MAAM,EAAE,QAAQ,KAAK,MAAM,KAAK,CAAC;CACxD;AACF;AAEA,IAAa,SAAb,MAAoB;CAClB,OAAO;CAEP,OAAO,MAAM,YAAqB,WAAW,GAAG,MAAM,OAAO;CAC7D,OAAO,aAAa,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC3E,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,mBAAmB,YAAqB,WAAW,GAAG,oBAAoB,OAAO;CACxF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,kBAAkB,OAAO;CACpF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,gBAAgB,YAAqB,WAAW,GAAG,mBAAmB,OAAO;CACpF,OAAO,qBAAqB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;CAC5F,OAAO,sBAAsB,YAAqB,WAAW,GAAG,uBAAuB,OAAO;CAC9F,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,cAAc,YAAqB,WAAW,GAAG,gBAAgB,OAAO;CAC/E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,iBAAiB,OAAO;CACnF,OAAO,YAAY,YAAqB,WAAW,GAAG,YAAY,OAAO;CACzE,OAAO,eAAe,YAAqB,WAAW,GAAG,eAAe,OAAO;CAC/E,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,oBAAoB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F"}
@@ -1,69 +1,69 @@
1
- import { Detail, Details } from './detail.cjs';
2
- import './reason.cjs';
3
-
1
+ import { Detail, Details } from "./detail.cjs";
2
+ //#region src/error/status.d.ts
4
3
  declare const Code: {
5
- readonly OK: 200;
6
- readonly CANCELLED: 499;
7
- readonly UNKNOWN: 500;
8
- readonly INVALID_ARGUMENT: 400;
9
- readonly DEADLINE_EXCEEDED: 504;
10
- readonly NOT_FOUND: 404;
11
- readonly ALREADY_EXISTS: 409;
12
- readonly PERMISSION_DENIED: 403;
13
- readonly RESOURCE_EXHAUSTED: 429;
14
- readonly FAILED_PRECONDITION: 400;
15
- readonly ABORTED: 409;
16
- readonly OUT_OF_RANGE: 400;
17
- readonly UNIMPLEMENTED: 501;
18
- readonly INTERNAL: 500;
19
- readonly UNAVAILABLE: 503;
20
- readonly DATA_LOSS: 500;
21
- readonly UNAUTHENTICATED: 401;
22
- readonly METHOD_NOT_ALLOWED: 405;
4
+ readonly OK: 200;
5
+ readonly CANCELLED: 499;
6
+ readonly UNKNOWN: 500;
7
+ readonly INVALID_ARGUMENT: 400;
8
+ readonly DEADLINE_EXCEEDED: 504;
9
+ readonly NOT_FOUND: 404;
10
+ readonly ALREADY_EXISTS: 409;
11
+ readonly PERMISSION_DENIED: 403;
12
+ readonly RESOURCE_EXHAUSTED: 429;
13
+ readonly FAILED_PRECONDITION: 400;
14
+ readonly ABORTED: 409;
15
+ readonly OUT_OF_RANGE: 400;
16
+ readonly UNIMPLEMENTED: 501;
17
+ readonly INTERNAL: 500;
18
+ readonly UNAVAILABLE: 503;
19
+ readonly DATA_LOSS: 500;
20
+ readonly UNAUTHENTICATED: 401;
21
+ readonly METHOD_NOT_ALLOWED: 405;
23
22
  };
24
23
  declare const DEFAULT_MESSAGES: Record<keyof typeof Code, string>;
25
24
  interface ErrorBody {
26
- error: {
27
- code: number;
28
- status: keyof typeof Code;
29
- message: string;
30
- details: Detail[];
31
- };
25
+ error: {
26
+ code: number;
27
+ status: keyof typeof Code;
28
+ message: string;
29
+ details: Detail[];
30
+ };
32
31
  }
33
32
  declare class StatusError extends Error {
34
- readonly status: number;
35
- readonly body?: ErrorBody;
36
- constructor(status: number, body?: ErrorBody);
33
+ readonly status: number;
34
+ readonly body?: ErrorBody;
35
+ constructor(status: number, body?: ErrorBody);
37
36
  }
38
37
  declare class StatusCode {
39
- code: keyof typeof Code;
40
- message?: string;
41
- private constructor();
42
- static of(code: keyof typeof Code, message?: string): StatusCode;
43
- body(details?: Details): ErrorBody;
44
- error(details?: Details): Error;
45
- response(details?: Details): Response;
38
+ code: keyof typeof Code;
39
+ message?: string;
40
+ private constructor();
41
+ static of(code: keyof typeof Code, message?: string): StatusCode;
42
+ body(details?: Details): ErrorBody;
43
+ error(details?: Details): Error;
44
+ response(details?: Details): Response;
46
45
  }
47
46
  declare class Status {
48
- static adapter?: (status: number, response: ErrorBody) => Error;
49
- static ok: (message?: string) => StatusCode;
50
- static cancelled: (message?: string) => StatusCode;
51
- static unknown: (message?: string) => StatusCode;
52
- static invalidArgument: (message?: string) => StatusCode;
53
- static deadlineExceeded: (message?: string) => StatusCode;
54
- static notFound: (message?: string) => StatusCode;
55
- static alreadyExists: (message?: string) => StatusCode;
56
- static permissionDenied: (message?: string) => StatusCode;
57
- static unauthorized: (message?: string) => StatusCode;
58
- static resourceExhausted: (message?: string) => StatusCode;
59
- static failedPrecondition: (message?: string) => StatusCode;
60
- static aborted: (message?: string) => StatusCode;
61
- static outOfRange: (message?: string) => StatusCode;
62
- static unimplemented: (message?: string) => StatusCode;
63
- static internal: (message?: string) => StatusCode;
64
- static unavailable: (message?: string) => StatusCode;
65
- static dataLoss: (message?: string) => StatusCode;
66
- static methodNotAllowed: (message?: string) => StatusCode;
47
+ static adapter?: (status: number, response: ErrorBody) => Error;
48
+ static ok: (message?: string) => StatusCode;
49
+ static cancelled: (message?: string) => StatusCode;
50
+ static unknown: (message?: string) => StatusCode;
51
+ static invalidArgument: (message?: string) => StatusCode;
52
+ static deadlineExceeded: (message?: string) => StatusCode;
53
+ static notFound: (message?: string) => StatusCode;
54
+ static alreadyExists: (message?: string) => StatusCode;
55
+ static permissionDenied: (message?: string) => StatusCode;
56
+ static unauthorized: (message?: string) => StatusCode;
57
+ static resourceExhausted: (message?: string) => StatusCode;
58
+ static failedPrecondition: (message?: string) => StatusCode;
59
+ static aborted: (message?: string) => StatusCode;
60
+ static outOfRange: (message?: string) => StatusCode;
61
+ static unimplemented: (message?: string) => StatusCode;
62
+ static internal: (message?: string) => StatusCode;
63
+ static unavailable: (message?: string) => StatusCode;
64
+ static dataLoss: (message?: string) => StatusCode;
65
+ static methodNotAllowed: (message?: string) => StatusCode;
67
66
  }
68
-
69
- export { Code, DEFAULT_MESSAGES, type ErrorBody, Status, StatusCode, StatusError };
67
+ //#endregion
68
+ export { Code, DEFAULT_MESSAGES, ErrorBody, Status, StatusCode, StatusError };
69
+ //# sourceMappingURL=status.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.cts","names":[],"sources":["../../src/error/status.ts"],"mappings":";;cAEa;WAIX;WAKA;WASA;WAQA;WASA;WAWA;WAMA;WAYA;WAMA;WAoBA;WASA;WAmBA;WAMA;WAOA;WAWA;WAKA;WAMA;WAKA;;cAGW,kBAAkB,oBAAoB;UAsBlC;EACf;IACE;IACA,qBAAqB;IACrB;IACA,SAAS;;;cAIA,oBAAoB;WACtB;WACA,OAAO;EAEhB,YAAY,gBAAgB,OAAO;;cASxB;EACX,mBAAmB;EACnB;UACO;SAKA,GAAG,mBAAmB,MAAM,mBAAgB;EAInD,KAAK,UAAU,UAAU;EAWzB,MAAM,UAAU,UAAU;EAM1B,SAAS,UAAU,UAAU;;cAMlB;SACJ,WAAW,gBAAgB,UAAU,cAAc;SAEnD,KAAE,qBAAoB;SACtB,YAAS,qBAAoB;SAC7B,UAAO,qBAAoB;SAC3B,kBAAe,qBAAoB;SACnC,mBAAgB,qBAAoB;SACpC,WAAQ,qBAAoB;SAC5B,gBAAa,qBAAoB;SACjC,mBAAgB,qBAAoB;SACpC,eAAY,qBAAoB;SAChC,oBAAiB,qBAAoB;SACrC,qBAAkB,qBAAoB;SACtC,UAAO,qBAAoB;SAC3B,aAAU,qBAAoB;SAC9B,gBAAa,qBAAoB;SACjC,WAAQ,qBAAoB;SAC5B,cAAW,qBAAoB;SAC/B,WAAQ,qBAAoB;SAC5B,mBAAgB,qBAAoB"}
@@ -0,0 +1,69 @@
1
+ import { Detail, Details } from "./detail.mjs";
2
+ //#region src/error/status.d.ts
3
+ declare const Code: {
4
+ readonly OK: 200;
5
+ readonly CANCELLED: 499;
6
+ readonly UNKNOWN: 500;
7
+ readonly INVALID_ARGUMENT: 400;
8
+ readonly DEADLINE_EXCEEDED: 504;
9
+ readonly NOT_FOUND: 404;
10
+ readonly ALREADY_EXISTS: 409;
11
+ readonly PERMISSION_DENIED: 403;
12
+ readonly RESOURCE_EXHAUSTED: 429;
13
+ readonly FAILED_PRECONDITION: 400;
14
+ readonly ABORTED: 409;
15
+ readonly OUT_OF_RANGE: 400;
16
+ readonly UNIMPLEMENTED: 501;
17
+ readonly INTERNAL: 500;
18
+ readonly UNAVAILABLE: 503;
19
+ readonly DATA_LOSS: 500;
20
+ readonly UNAUTHENTICATED: 401;
21
+ readonly METHOD_NOT_ALLOWED: 405;
22
+ };
23
+ declare const DEFAULT_MESSAGES: Record<keyof typeof Code, string>;
24
+ interface ErrorBody {
25
+ error: {
26
+ code: number;
27
+ status: keyof typeof Code;
28
+ message: string;
29
+ details: Detail[];
30
+ };
31
+ }
32
+ declare class StatusError extends Error {
33
+ readonly status: number;
34
+ readonly body?: ErrorBody;
35
+ constructor(status: number, body?: ErrorBody);
36
+ }
37
+ declare class StatusCode {
38
+ code: keyof typeof Code;
39
+ message?: string;
40
+ private constructor();
41
+ static of(code: keyof typeof Code, message?: string): StatusCode;
42
+ body(details?: Details): ErrorBody;
43
+ error(details?: Details): Error;
44
+ response(details?: Details): Response;
45
+ }
46
+ declare class Status {
47
+ static adapter?: (status: number, response: ErrorBody) => Error;
48
+ static ok: (message?: string) => StatusCode;
49
+ static cancelled: (message?: string) => StatusCode;
50
+ static unknown: (message?: string) => StatusCode;
51
+ static invalidArgument: (message?: string) => StatusCode;
52
+ static deadlineExceeded: (message?: string) => StatusCode;
53
+ static notFound: (message?: string) => StatusCode;
54
+ static alreadyExists: (message?: string) => StatusCode;
55
+ static permissionDenied: (message?: string) => StatusCode;
56
+ static unauthorized: (message?: string) => StatusCode;
57
+ static resourceExhausted: (message?: string) => StatusCode;
58
+ static failedPrecondition: (message?: string) => StatusCode;
59
+ static aborted: (message?: string) => StatusCode;
60
+ static outOfRange: (message?: string) => StatusCode;
61
+ static unimplemented: (message?: string) => StatusCode;
62
+ static internal: (message?: string) => StatusCode;
63
+ static unavailable: (message?: string) => StatusCode;
64
+ static dataLoss: (message?: string) => StatusCode;
65
+ static methodNotAllowed: (message?: string) => StatusCode;
66
+ }
67
+ //#endregion
68
+ export { Code, DEFAULT_MESSAGES, ErrorBody, Status, StatusCode, StatusError };
69
+ //# sourceMappingURL=status.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.mts","names":[],"sources":["../../src/error/status.ts"],"mappings":";;cAEa;WAIX;WAKA;WASA;WAQA;WASA;WAWA;WAMA;WAYA;WAMA;WAoBA;WASA;WAmBA;WAMA;WAOA;WAWA;WAKA;WAMA;WAKA;;cAGW,kBAAkB,oBAAoB;UAsBlC;EACf;IACE;IACA,qBAAqB;IACrB;IACA,SAAS;;;cAIA,oBAAoB;WACtB;WACA,OAAO;EAEhB,YAAY,gBAAgB,OAAO;;cASxB;EACX,mBAAmB;EACnB;UACO;SAKA,GAAG,mBAAmB,MAAM,mBAAgB;EAInD,KAAK,UAAU,UAAU;EAWzB,MAAM,UAAU,UAAU;EAM1B,SAAS,UAAU,UAAU;;cAMlB;SACJ,WAAW,gBAAgB,UAAU,cAAc;SAEnD,KAAE,qBAAoB;SACtB,YAAS,qBAAoB;SAC7B,UAAO,qBAAoB;SAC3B,kBAAe,qBAAoB;SACnC,mBAAgB,qBAAoB;SACpC,WAAQ,qBAAoB;SAC5B,gBAAa,qBAAoB;SACjC,mBAAgB,qBAAoB;SACpC,eAAY,qBAAoB;SAChC,oBAAiB,qBAAoB;SACrC,qBAAkB,qBAAoB;SACtC,UAAO,qBAAoB;SAC3B,aAAU,qBAAoB;SAC9B,gBAAa,qBAAoB;SACjC,WAAQ,qBAAoB;SAC5B,cAAW,qBAAoB;SAC/B,WAAQ,qBAAoB;SAC5B,mBAAgB,qBAAoB"}