@supatype/client 0.3.6 → 0.7.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 (205) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +58 -31
  3. package/.turbo/turbo-typecheck.log +2 -2
  4. package/LICENSE +1 -1
  5. package/dist/auth-redirect.d.ts +48 -0
  6. package/dist/auth-redirect.d.ts.map +1 -0
  7. package/dist/auth-redirect.js +70 -0
  8. package/dist/auth-redirect.js.map +1 -0
  9. package/dist/auth.d.ts +78 -4
  10. package/dist/auth.d.ts.map +1 -1
  11. package/dist/auth.js +373 -274
  12. package/dist/auth.js.map +1 -1
  13. package/dist/bindings.d.ts +16 -0
  14. package/dist/bindings.d.ts.map +1 -0
  15. package/dist/bindings.js +13 -0
  16. package/dist/bindings.js.map +1 -0
  17. package/dist/caller-types.d.ts +18 -0
  18. package/dist/caller-types.d.ts.map +1 -0
  19. package/dist/caller-types.js +22 -0
  20. package/dist/caller-types.js.map +1 -0
  21. package/dist/draft-create.d.ts +12 -0
  22. package/dist/draft-create.d.ts.map +1 -0
  23. package/dist/draft-create.js +47 -0
  24. package/dist/draft-create.js.map +1 -0
  25. package/dist/draft-models-registry.d.ts +27 -0
  26. package/dist/draft-models-registry.d.ts.map +1 -0
  27. package/dist/draft-models-registry.js +61 -0
  28. package/dist/draft-models-registry.js.map +1 -0
  29. package/dist/error-codes-doc.d.ts +1 -1
  30. package/dist/error-codes-doc.d.ts.map +1 -1
  31. package/dist/error-codes-doc.js +42 -34
  32. package/dist/error-codes-doc.js.map +1 -1
  33. package/dist/errors.d.ts +102 -60
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +69 -28
  36. package/dist/errors.js.map +1 -1
  37. package/dist/exact-response.d.ts.map +1 -1
  38. package/dist/exact-response.js +2 -1
  39. package/dist/exact-response.js.map +1 -1
  40. package/dist/exact-values.d.ts +2 -0
  41. package/dist/exact-values.d.ts.map +1 -1
  42. package/dist/exact-values.js +12 -10
  43. package/dist/exact-values.js.map +1 -1
  44. package/dist/fetch-with-retry.d.ts +21 -6
  45. package/dist/fetch-with-retry.d.ts.map +1 -1
  46. package/dist/fetch-with-retry.js +67 -53
  47. package/dist/fetch-with-retry.js.map +1 -1
  48. package/dist/field-kinds-registry.d.ts +11 -3
  49. package/dist/field-kinds-registry.d.ts.map +1 -1
  50. package/dist/field-kinds-registry.js +10 -6
  51. package/dist/field-kinds-registry.js.map +1 -1
  52. package/dist/filters.d.ts +51 -0
  53. package/dist/filters.d.ts.map +1 -0
  54. package/dist/filters.js +117 -0
  55. package/dist/filters.js.map +1 -0
  56. package/dist/generated-client.d.ts +7 -0
  57. package/dist/generated-client.d.ts.map +1 -0
  58. package/dist/generated-client.js +7 -0
  59. package/dist/generated-client.js.map +1 -0
  60. package/dist/graphql-document.d.ts +39 -0
  61. package/dist/graphql-document.d.ts.map +1 -0
  62. package/dist/graphql-document.js +228 -0
  63. package/dist/graphql-document.js.map +1 -0
  64. package/dist/graphql-json.d.ts +56 -0
  65. package/dist/graphql-json.d.ts.map +1 -0
  66. package/dist/graphql-json.js +220 -0
  67. package/dist/graphql-json.js.map +1 -0
  68. package/dist/graphql-transport.d.ts +28 -0
  69. package/dist/graphql-transport.d.ts.map +1 -0
  70. package/dist/graphql-transport.js +77 -0
  71. package/dist/graphql-transport.js.map +1 -0
  72. package/dist/index.d.ts +103 -40
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +153 -157
  75. package/dist/index.js.map +1 -1
  76. package/dist/json.d.ts +61 -0
  77. package/dist/json.d.ts.map +1 -0
  78. package/dist/json.js +83 -0
  79. package/dist/json.js.map +1 -0
  80. package/dist/jwt.d.ts +16 -0
  81. package/dist/jwt.d.ts.map +1 -0
  82. package/dist/jwt.js +37 -0
  83. package/dist/jwt.js.map +1 -0
  84. package/dist/live-preview.d.ts +23 -0
  85. package/dist/live-preview.d.ts.map +1 -0
  86. package/dist/live-preview.js +28 -0
  87. package/dist/live-preview.js.map +1 -0
  88. package/dist/mutation-request.d.ts +17 -0
  89. package/dist/mutation-request.d.ts.map +1 -0
  90. package/dist/mutation-request.js +41 -0
  91. package/dist/mutation-request.js.map +1 -0
  92. package/dist/preview.d.ts.map +1 -1
  93. package/dist/preview.js +8 -6
  94. package/dist/preview.js.map +1 -1
  95. package/dist/query-cache.d.ts.map +1 -1
  96. package/dist/query-cache.js +19 -13
  97. package/dist/query-cache.js.map +1 -1
  98. package/dist/query.d.ts +108 -29
  99. package/dist/query.d.ts.map +1 -1
  100. package/dist/query.js +294 -224
  101. package/dist/query.js.map +1 -1
  102. package/dist/realtime.d.ts +20 -2
  103. package/dist/realtime.d.ts.map +1 -1
  104. package/dist/realtime.js +105 -12
  105. package/dist/realtime.js.map +1 -1
  106. package/dist/select-types.d.ts +99 -0
  107. package/dist/select-types.d.ts.map +1 -0
  108. package/dist/select-types.js +2 -0
  109. package/dist/select-types.js.map +1 -0
  110. package/dist/storage.d.ts +81 -11
  111. package/dist/storage.d.ts.map +1 -1
  112. package/dist/storage.js +129 -37
  113. package/dist/storage.js.map +1 -1
  114. package/dist/table-subscription.d.ts +69 -0
  115. package/dist/table-subscription.d.ts.map +1 -0
  116. package/dist/table-subscription.js +93 -0
  117. package/dist/table-subscription.js.map +1 -0
  118. package/dist/types.d.ts +84 -5
  119. package/dist/types.d.ts.map +1 -1
  120. package/dist/types.js +6 -1
  121. package/dist/types.js.map +1 -1
  122. package/package.json +6 -2
  123. package/src/auth-redirect.ts +90 -0
  124. package/src/auth.ts +421 -280
  125. package/src/bindings.ts +22 -0
  126. package/src/caller-types.ts +27 -0
  127. package/src/draft-create.ts +51 -0
  128. package/src/draft-models-registry.ts +81 -0
  129. package/src/error-codes-doc.ts +44 -35
  130. package/src/errors.ts +72 -28
  131. package/src/exact-response.ts +2 -1
  132. package/src/exact-values.ts +16 -9
  133. package/src/fetch-with-retry.ts +80 -70
  134. package/src/field-kinds-registry.ts +22 -9
  135. package/src/filters.ts +133 -0
  136. package/src/generated-client.ts +6 -0
  137. package/src/graphql-document.ts +234 -0
  138. package/src/graphql-json.ts +243 -0
  139. package/src/graphql-transport.ts +97 -0
  140. package/src/index.ts +272 -201
  141. package/src/json.ts +117 -0
  142. package/src/jwt.ts +37 -0
  143. package/src/live-preview.ts +37 -0
  144. package/src/mutation-request.ts +66 -0
  145. package/src/preview.ts +9 -11
  146. package/src/query-cache.ts +19 -16
  147. package/src/query.ts +389 -270
  148. package/src/realtime.ts +116 -13
  149. package/src/select-types.ts +184 -0
  150. package/src/storage.ts +214 -43
  151. package/src/table-subscription.ts +160 -0
  152. package/src/types.ts +90 -5
  153. package/tests/auth-error-codes.test.ts +53 -0
  154. package/tests/auth-errors.test.ts +84 -0
  155. package/tests/auth-events.test.ts +136 -0
  156. package/tests/auth-url-session.test.ts +204 -0
  157. package/tests/auth.test.ts +122 -26
  158. package/tests/count.test.ts +60 -0
  159. package/tests/data-plane-auth.test.ts +21 -46
  160. package/tests/draft-insert.integration.test.ts +118 -0
  161. package/tests/draft-insert.test.ts +225 -0
  162. package/tests/draft-profile.test.ts +55 -84
  163. package/tests/draft-update.integration.test.ts +122 -0
  164. package/tests/draft-update.test.ts +174 -0
  165. package/tests/dynamic-headers.test.ts +45 -0
  166. package/tests/entry-points.test.ts +42 -0
  167. package/tests/exact-response.test.ts +4 -4
  168. package/tests/exact-values.test.ts +14 -25
  169. package/tests/field-kinds-registry.test.ts +3 -3
  170. package/tests/filters.test.ts +146 -0
  171. package/tests/graphql-json.test.ts +199 -0
  172. package/tests/helpers/mock-websocket.ts +44 -11
  173. package/tests/helpers/oauth-binding.ts +92 -0
  174. package/tests/helpers/signup-binding.ts +73 -0
  175. package/tests/helpers/socket-swap.ts +139 -0
  176. package/tests/mfa-totp-integration.test.ts +13 -20
  177. package/tests/postgrest-error-codes.test.ts +85 -0
  178. package/tests/query-cache.test.ts +116 -117
  179. package/tests/query.test.ts +29 -31
  180. package/tests/rate-limit-integration.test.ts +4 -12
  181. package/tests/realtime-exact-values.test.ts +2 -4
  182. package/tests/realtime-presence.test.ts +75 -0
  183. package/tests/realtime-session-auth.test.ts +2 -4
  184. package/tests/realtime-swap-status.test.ts +62 -0
  185. package/tests/retry-integration.test.ts +3 -8
  186. package/tests/retry-policy.test.ts +166 -0
  187. package/tests/rpc-resend.test.ts +24 -0
  188. package/tests/server-bodies.test.ts +139 -0
  189. package/tests/serverless.test.ts +2 -2
  190. package/tests/signed-url-absolute.test.ts +2 -5
  191. package/tests/storage-object-shape.test.ts +101 -0
  192. package/tests/storage-quota-integration.test.ts +3 -2
  193. package/tests/storage-reference-url.test.ts +51 -0
  194. package/tests/storage-upload-browser.test.ts +71 -0
  195. package/tests/storage-upload-limit-integration.test.ts +12 -22
  196. package/tests/subscribe-frame.test.ts +5 -11
  197. package/tests/support/fetch-mock.ts +64 -0
  198. package/tests/support/storage-object.ts +37 -0
  199. package/tests/table-subscribe.test.ts +13 -13
  200. package/tests/table-subscription.test.ts +105 -0
  201. package/tests/table-transport.test.ts +94 -0
  202. package/tests/tsconfig.json +1 -1
  203. package/tests/types.test.ts +153 -1
  204. package/tsconfig.json +1 -1
  205. package/tsconfig.tsbuildinfo +1 -1
@@ -7,94 +7,95 @@
7
7
  * Each SDK error includes a `helpUrl` field linking to the relevant section
8
8
  * on the documentation page.
9
9
  */
10
+ import { AuthErrorCodes } from "./errors.js";
10
11
  export const ERROR_CODES_DOCUMENTATION = [
11
12
  // ── Auth errors ──────────────────────────────────────────────────────────
12
13
  {
13
- code: "AUTH_INVALID_CREDENTIALS",
14
+ code: AuthErrorCodes.INVALID_CREDENTIALS,
14
15
  description: "The email/password combination is incorrect.",
15
16
  suggestion: "Check the email and password. If forgotten, use resetPasswordForEmail().",
16
17
  httpStatus: 400,
17
18
  category: "auth",
18
19
  },
19
20
  {
20
- code: "AUTH_USER_NOT_FOUND",
21
+ code: AuthErrorCodes.USER_NOT_FOUND,
21
22
  description: "No user exists with the provided identifier.",
22
23
  suggestion: "Verify the email address. The user may need to sign up first.",
23
24
  httpStatus: 404,
24
25
  category: "auth",
25
26
  },
26
27
  {
27
- code: "AUTH_EMAIL_NOT_CONFIRMED",
28
+ code: AuthErrorCodes.EMAIL_NOT_CONFIRMED,
28
29
  description: "The user's email has not been confirmed yet.",
29
30
  suggestion: "Check inbox for the confirmation email. Use auth.resend({ type: 'signup' }) to re-send.",
30
31
  httpStatus: 403,
31
32
  category: "auth",
32
33
  },
33
34
  {
34
- code: "AUTH_PHONE_NOT_CONFIRMED",
35
+ code: AuthErrorCodes.PHONE_NOT_CONFIRMED,
35
36
  description: "The user's phone number has not been verified.",
36
37
  suggestion: "Complete the phone OTP verification flow.",
37
38
  httpStatus: 403,
38
39
  category: "auth",
39
40
  },
40
41
  {
41
- code: "AUTH_SESSION_EXPIRED",
42
+ code: AuthErrorCodes.SESSION_EXPIRED,
42
43
  description: "The session has expired and the refresh token is no longer valid.",
43
44
  suggestion: "Sign the user in again. Implement automatic token refresh with onAuthStateChange.",
44
45
  httpStatus: 401,
45
46
  category: "auth",
46
47
  },
47
48
  {
48
- code: "AUTH_INVALID_TOKEN",
49
+ code: AuthErrorCodes.INVALID_TOKEN,
49
50
  description: "The provided JWT is malformed, expired, or signed with a different secret.",
50
51
  suggestion: "Ensure the token is from the correct project. Check expiry. Re-authenticate.",
51
52
  httpStatus: 401,
52
53
  category: "auth",
53
54
  },
54
55
  {
55
- code: "AUTH_MFA_REQUIRED",
56
+ code: AuthErrorCodes.MFA_REQUIRED,
56
57
  description: "Multi-factor authentication is required to complete this action.",
57
58
  suggestion: "Call mfa.challenge() and mfa.verify() with the user's TOTP code.",
58
59
  httpStatus: 403,
59
60
  category: "auth",
60
61
  },
61
62
  {
62
- code: "AUTH_MFA_CHALLENGE_EXPIRED",
63
+ code: AuthErrorCodes.MFA_CHALLENGE_EXPIRED,
63
64
  description: "The MFA challenge has expired.",
64
65
  suggestion: "Create a new challenge with mfa.challenge() and try again.",
65
66
  httpStatus: 400,
66
67
  category: "auth",
67
68
  },
68
69
  {
69
- code: "AUTH_MFA_VERIFICATION_FAILED",
70
+ code: AuthErrorCodes.MFA_VERIFICATION_FAILED,
70
71
  description: "The MFA verification code is incorrect.",
71
72
  suggestion: "Ensure the TOTP code is current (codes rotate every 30 seconds).",
72
73
  httpStatus: 400,
73
74
  category: "auth",
74
75
  },
75
76
  {
76
- code: "AUTH_WEAK_PASSWORD",
77
+ code: AuthErrorCodes.WEAK_PASSWORD,
77
78
  description: "The password does not meet the minimum strength requirements.",
78
79
  suggestion: "Use a password with at least 8 characters including mixed case and numbers.",
79
80
  httpStatus: 422,
80
81
  category: "auth",
81
82
  },
82
83
  {
83
- code: "AUTH_USER_ALREADY_EXISTS",
84
+ code: AuthErrorCodes.USER_ALREADY_EXISTS,
84
85
  description: "A user with this email or phone already exists.",
85
86
  suggestion: "Use signInWithPassword() instead, or try a different email.",
86
87
  httpStatus: 409,
87
88
  category: "auth",
88
89
  },
89
90
  {
90
- code: "AUTH_OAUTH_CALLBACK_ERROR",
91
+ code: AuthErrorCodes.OAUTH_CALLBACK_ERROR,
91
92
  description: "The OAuth provider returned an error during the callback.",
92
93
  suggestion: "Check the provider configuration (client ID, secret, redirect URL).",
93
94
  httpStatus: 400,
94
95
  category: "auth",
95
96
  },
96
97
  {
97
- code: "AUTH_MAGIC_LINK_EXPIRED",
98
+ code: AuthErrorCodes.MAGIC_LINK_EXPIRED,
98
99
  description: "The magic link has expired (default: 10 minutes).",
99
100
  suggestion: "Request a new magic link with signInWithOtp({ email }).",
100
101
  httpStatus: 400,
@@ -103,15 +104,22 @@ export const ERROR_CODES_DOCUMENTATION = [
103
104
  // ── PostgREST errors ─────────────────────────────────────────────────────
104
105
  {
105
106
  code: "PGRST301",
106
- description: "JWT expired or missing. PostgREST could not authenticate the request.",
107
- suggestion: "Refresh the user's session or re-authenticate. Check that the apikey header is set.",
107
+ description: "The JWT could not be decoded or verified: a bad signature, a malformed token, or an empty one.",
108
+ suggestion: "Check that the apikey and Authorization headers carry a token signed with this project's JWT secret.",
108
109
  httpStatus: 401,
109
110
  category: "postgrest",
110
111
  },
111
112
  {
112
- code: "PGRST302",
113
- description: "Permission denied. RLS policy blocked access to the requested resource.",
114
- suggestion: "Review your access rules in the schema. Ensure the user has the required role.",
113
+ code: "PGRST303",
114
+ description: "The JWT's claims were rejected. An expired token is the usual cause.",
115
+ suggestion: "Refresh the user's session or sign in again.",
116
+ httpStatus: 401,
117
+ category: "postgrest",
118
+ },
119
+ {
120
+ code: "42501",
121
+ description: "Permission denied. A row-level security policy or a missing grant blocked the operation.",
122
+ suggestion: "Review your access rules in the schema. A request without a signed-in user is answered with 401.",
115
123
  httpStatus: 403,
116
124
  category: "postgrest",
117
125
  },
@@ -124,55 +132,55 @@ export const ERROR_CODES_DOCUMENTATION = [
124
132
  },
125
133
  {
126
134
  code: "PGRST204",
127
- description: "PostgREST schema cache is stale. The table or function may have changed.",
128
- suggestion: "PostgREST will reload its cache automatically. Retry the request.",
129
- httpStatus: 503,
135
+ description: "The request named a column that is not in PostgREST's schema cache.",
136
+ suggestion: "Check the column names you write against the current schema, and push the schema if it changed.",
137
+ httpStatus: 400,
130
138
  category: "postgrest",
131
139
  },
132
140
  {
133
- code: "PGRST23503",
141
+ code: "PGRST205",
142
+ description: "Table does not exist. The schema may need to be pushed.",
143
+ suggestion: "Run `npx supatype push` to apply your schema to the database.",
144
+ httpStatus: 404,
145
+ category: "postgrest",
146
+ },
147
+ {
148
+ code: "23503",
134
149
  description: "Foreign key constraint violation. The referenced record does not exist.",
135
150
  suggestion: "Ensure the related record exists before creating/updating. Check relation fields.",
136
151
  httpStatus: 409,
137
152
  category: "postgrest",
138
153
  },
139
154
  {
140
- code: "PGRST23505",
155
+ code: "23505",
141
156
  description: "Unique constraint violation. A record with this value already exists.",
142
157
  suggestion: "Use .upsert() for insert-or-update, or check for existing records first.",
143
158
  httpStatus: 409,
144
159
  category: "postgrest",
145
160
  },
146
161
  {
147
- code: "PGRST23502",
162
+ code: "23502",
148
163
  description: "Not-null constraint violation. A required field is missing.",
149
164
  suggestion: "Include all required fields in the insert/update payload.",
150
165
  httpStatus: 400,
151
166
  category: "postgrest",
152
167
  },
153
168
  {
154
- code: "PGRST23514",
169
+ code: "23514",
155
170
  description: "Check constraint violation. A field value does not satisfy the constraint.",
156
171
  suggestion: "Ensure enum values match declared options. Check field validation rules.",
157
172
  httpStatus: 400,
158
173
  category: "postgrest",
159
174
  },
160
175
  {
161
- code: "PGRST22P02",
176
+ code: "22P02",
162
177
  description: "Invalid input syntax. The value cannot be cast to the expected type.",
163
178
  suggestion: "Check that field values match the expected types (e.g., UUID format, number format).",
164
179
  httpStatus: 400,
165
180
  category: "postgrest",
166
181
  },
167
182
  {
168
- code: "PGRST42P01",
169
- description: "Table does not exist. The schema may need to be pushed.",
170
- suggestion: "Run `npx supatype push` to apply your schema to the database.",
171
- httpStatus: 404,
172
- category: "postgrest",
173
- },
174
- {
175
- code: "PGRST42703",
183
+ code: "42703",
176
184
  description: "Column does not exist. The field may have been renamed or removed.",
177
185
  suggestion: "Check your query column names against the current schema.",
178
186
  httpStatus: 400,
@@ -1 +1 @@
1
- {"version":3,"file":"error-codes-doc.js","sourceRoot":"","sources":["../src/error-codes-doc.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAeH,MAAM,CAAC,MAAM,yBAAyB,GAA8B;IAClE,4EAA4E;IAC5E;QACE,IAAI,EAAE,0BAA0B;QAChC,WAAW,EAAE,8CAA8C;QAC3D,UAAU,EAAE,0EAA0E;QACtF,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,MAAM;KACjB;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,8CAA8C;QAC3D,UAAU,EAAE,+DAA+D;QAC3E,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE,MAAM;KACjB;IACD;QACE,IAAI,EAAE,0BAA0B;QAChC,WAAW,EAAE,8CAA8C;QAC3D,UAAU,EAAE,yFAAyF;QACrG,UAAU,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C,IAAI,KAAK,IAAI,CAAC,CAAA;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAoC;IAEpC,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAA;AACjF,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- /**
2
- * Typed error hierarchy for the Supatype SDK.
3
- * Every error has a machine-readable `code` field and optional `helpUrl`.
4
- */
1
+ import type { SupatypeError as SupatypeErrorShape } from "./types.js";
5
2
  /**
6
3
  * Base error class for all Supatype SDK errors.
7
4
  */
@@ -59,20 +56,37 @@ export declare class RateLimitError extends SupatypeError {
59
56
  readonly retryAfterSeconds: number;
60
57
  constructor(retryAfterSeconds: number);
61
58
  }
59
+ /**
60
+ * The `code` an auth error carries, as the auth server sends it in `error_code`.
61
+ *
62
+ * These were `AUTH_INVALID_CREDENTIALS` and the like, which the server never sends, so comparing
63
+ * an error's code with them never matched. The names are unchanged; the values are the server's.
64
+ */
62
65
  export declare const AuthErrorCodes: {
63
- readonly INVALID_CREDENTIALS: "AUTH_INVALID_CREDENTIALS";
64
- readonly USER_NOT_FOUND: "AUTH_USER_NOT_FOUND";
65
- readonly EMAIL_NOT_CONFIRMED: "AUTH_EMAIL_NOT_CONFIRMED";
66
- readonly PHONE_NOT_CONFIRMED: "AUTH_PHONE_NOT_CONFIRMED";
67
- readonly SESSION_EXPIRED: "AUTH_SESSION_EXPIRED";
68
- readonly INVALID_TOKEN: "AUTH_INVALID_TOKEN";
69
- readonly MFA_REQUIRED: "AUTH_MFA_REQUIRED";
70
- readonly MFA_CHALLENGE_EXPIRED: "AUTH_MFA_CHALLENGE_EXPIRED";
71
- readonly MFA_VERIFICATION_FAILED: "AUTH_MFA_VERIFICATION_FAILED";
72
- readonly WEAK_PASSWORD: "AUTH_WEAK_PASSWORD";
73
- readonly USER_ALREADY_EXISTS: "AUTH_USER_ALREADY_EXISTS";
74
- readonly OAUTH_CALLBACK_ERROR: "AUTH_OAUTH_CALLBACK_ERROR";
75
- readonly MAGIC_LINK_EXPIRED: "AUTH_MAGIC_LINK_EXPIRED";
66
+ /** Wrong email or password */
67
+ readonly INVALID_CREDENTIALS: "invalid_credentials";
68
+ readonly USER_NOT_FOUND: "user_not_found";
69
+ readonly EMAIL_NOT_CONFIRMED: "email_not_confirmed";
70
+ readonly PHONE_NOT_CONFIRMED: "phone_not_confirmed";
71
+ readonly SESSION_EXPIRED: "session_expired";
72
+ /** The access token could not be verified */
73
+ readonly INVALID_TOKEN: "bad_jwt";
74
+ /** The request needs a session at a higher assurance level: complete an MFA challenge first */
75
+ readonly MFA_REQUIRED: "insufficient_aal";
76
+ readonly MFA_CHALLENGE_EXPIRED: "mfa_challenge_expired";
77
+ readonly MFA_VERIFICATION_FAILED: "mfa_verification_failed";
78
+ readonly WEAK_PASSWORD: "weak_password";
79
+ /** Sign-up with an email that is already registered sends EMAIL_EXISTS */
80
+ readonly USER_ALREADY_EXISTS: "user_already_exists";
81
+ readonly EMAIL_EXISTS: "email_exists";
82
+ readonly OAUTH_CALLBACK_ERROR: "bad_oauth_callback";
83
+ /** An emailed link or one-time code that has expired or was already used */
84
+ readonly MAGIC_LINK_EXPIRED: "otp_expired";
85
+ readonly OTP_EXPIRED: "otp_expired";
86
+ readonly SIGNUP_DISABLED: "signup_disabled";
87
+ readonly SAME_PASSWORD: "same_password";
88
+ readonly OVER_EMAIL_SEND_RATE_LIMIT: "over_email_send_rate_limit";
89
+ readonly OVER_REQUEST_RATE_LIMIT: "over_request_rate_limit";
76
90
  };
77
91
  export declare const StorageErrorCodes: {
78
92
  readonly OBJECT_NOT_FOUND: "STORAGE_OBJECT_NOT_FOUND";
@@ -82,31 +96,39 @@ export declare const StorageErrorCodes: {
82
96
  readonly QUOTA_EXCEEDED: "STORAGE_QUOTA_EXCEEDED";
83
97
  readonly PRESIGNED_URL_EXPIRED: "STORAGE_PRESIGNED_URL_EXPIRED";
84
98
  };
99
+ /**
100
+ * The `code` a REST error carries, as PostgREST 14 sends it.
101
+ *
102
+ * PostgREST's own errors are `PGRST` codes. A database error is passed through under its Postgres
103
+ * SQLSTATE, with no prefix: a unique violation is `23505`, never `PGRST23505`.
104
+ */
85
105
  export declare const PostgrestErrorCodes: {
86
- /** JWT expired or missing */
87
- readonly JWT_EXPIRED: "PGRST301";
88
- /** No permission: RLS policy denied access */
89
- readonly PERMISSION_DENIED: "PGRST302";
90
- /** Requested resource not found */
106
+ /** The token could not be decoded or verified: a bad signature, a malformed or empty token */
107
+ readonly JWT_INVALID: "PGRST301";
108
+ /** The token's claims were rejected, an expired token among them (`PGRST301` before PostgREST 13) */
109
+ readonly JWT_EXPIRED: "PGRST303";
110
+ /** Row-level security or a missing grant refused the operation */
111
+ readonly PERMISSION_DENIED: "42501";
112
+ /** `.single()` found no row */
91
113
  readonly NOT_FOUND: "PGRST116";
92
- /** Multiple rows returned when single expected */
114
+ /** `.single()` found more than one row */
93
115
  readonly MULTIPLE_ROWS: "PGRST116";
94
- /** Schema cache miss: PostgREST needs reload */
116
+ /** The request named a column the schema cache does not have */
95
117
  readonly SCHEMA_CACHE_MISS: "PGRST204";
96
118
  /** Foreign key violation */
97
- readonly FK_VIOLATION: "PGRST23503";
119
+ readonly FK_VIOLATION: "23503";
98
120
  /** Unique constraint violation */
99
- readonly UNIQUE_VIOLATION: "PGRST23505";
121
+ readonly UNIQUE_VIOLATION: "23505";
100
122
  /** Not-null constraint violation */
101
- readonly NOT_NULL_VIOLATION: "PGRST23502";
123
+ readonly NOT_NULL_VIOLATION: "23502";
102
124
  /** Check constraint violation */
103
- readonly CHECK_VIOLATION: "PGRST23514";
125
+ readonly CHECK_VIOLATION: "23514";
104
126
  /** Invalid input syntax */
105
- readonly INVALID_INPUT: "PGRST22P02";
106
- /** Undefined table */
107
- readonly UNDEFINED_TABLE: "PGRST42P01";
127
+ readonly INVALID_INPUT: "22P02";
128
+ /** The table is not in the schema cache (the SQLSTATE `42P01` before PostgREST 13) */
129
+ readonly UNDEFINED_TABLE: "PGRST205";
108
130
  /** Undefined column */
109
- readonly UNDEFINED_COLUMN: "PGRST42703";
131
+ readonly UNDEFINED_COLUMN: "42703";
110
132
  };
111
133
  export declare const RealtimeErrorCodes: {
112
134
  /** WebSocket connection failed */
@@ -128,45 +150,58 @@ export declare const NetworkErrorCodes: {
128
150
  /** Union of all error code constant objects for programmatic access. */
129
151
  export declare const ErrorCodes: {
130
152
  readonly Auth: {
131
- readonly INVALID_CREDENTIALS: "AUTH_INVALID_CREDENTIALS";
132
- readonly USER_NOT_FOUND: "AUTH_USER_NOT_FOUND";
133
- readonly EMAIL_NOT_CONFIRMED: "AUTH_EMAIL_NOT_CONFIRMED";
134
- readonly PHONE_NOT_CONFIRMED: "AUTH_PHONE_NOT_CONFIRMED";
135
- readonly SESSION_EXPIRED: "AUTH_SESSION_EXPIRED";
136
- readonly INVALID_TOKEN: "AUTH_INVALID_TOKEN";
137
- readonly MFA_REQUIRED: "AUTH_MFA_REQUIRED";
138
- readonly MFA_CHALLENGE_EXPIRED: "AUTH_MFA_CHALLENGE_EXPIRED";
139
- readonly MFA_VERIFICATION_FAILED: "AUTH_MFA_VERIFICATION_FAILED";
140
- readonly WEAK_PASSWORD: "AUTH_WEAK_PASSWORD";
141
- readonly USER_ALREADY_EXISTS: "AUTH_USER_ALREADY_EXISTS";
142
- readonly OAUTH_CALLBACK_ERROR: "AUTH_OAUTH_CALLBACK_ERROR";
143
- readonly MAGIC_LINK_EXPIRED: "AUTH_MAGIC_LINK_EXPIRED";
153
+ /** Wrong email or password */
154
+ readonly INVALID_CREDENTIALS: "invalid_credentials";
155
+ readonly USER_NOT_FOUND: "user_not_found";
156
+ readonly EMAIL_NOT_CONFIRMED: "email_not_confirmed";
157
+ readonly PHONE_NOT_CONFIRMED: "phone_not_confirmed";
158
+ readonly SESSION_EXPIRED: "session_expired";
159
+ /** The access token could not be verified */
160
+ readonly INVALID_TOKEN: "bad_jwt";
161
+ /** The request needs a session at a higher assurance level: complete an MFA challenge first */
162
+ readonly MFA_REQUIRED: "insufficient_aal";
163
+ readonly MFA_CHALLENGE_EXPIRED: "mfa_challenge_expired";
164
+ readonly MFA_VERIFICATION_FAILED: "mfa_verification_failed";
165
+ readonly WEAK_PASSWORD: "weak_password";
166
+ /** Sign-up with an email that is already registered sends EMAIL_EXISTS */
167
+ readonly USER_ALREADY_EXISTS: "user_already_exists";
168
+ readonly EMAIL_EXISTS: "email_exists";
169
+ readonly OAUTH_CALLBACK_ERROR: "bad_oauth_callback";
170
+ /** An emailed link or one-time code that has expired or was already used */
171
+ readonly MAGIC_LINK_EXPIRED: "otp_expired";
172
+ readonly OTP_EXPIRED: "otp_expired";
173
+ readonly SIGNUP_DISABLED: "signup_disabled";
174
+ readonly SAME_PASSWORD: "same_password";
175
+ readonly OVER_EMAIL_SEND_RATE_LIMIT: "over_email_send_rate_limit";
176
+ readonly OVER_REQUEST_RATE_LIMIT: "over_request_rate_limit";
144
177
  };
145
178
  readonly Postgrest: {
146
- /** JWT expired or missing */
147
- readonly JWT_EXPIRED: "PGRST301";
148
- /** No permission: RLS policy denied access */
149
- readonly PERMISSION_DENIED: "PGRST302";
150
- /** Requested resource not found */
179
+ /** The token could not be decoded or verified: a bad signature, a malformed or empty token */
180
+ readonly JWT_INVALID: "PGRST301";
181
+ /** The token's claims were rejected, an expired token among them (`PGRST301` before PostgREST 13) */
182
+ readonly JWT_EXPIRED: "PGRST303";
183
+ /** Row-level security or a missing grant refused the operation */
184
+ readonly PERMISSION_DENIED: "42501";
185
+ /** `.single()` found no row */
151
186
  readonly NOT_FOUND: "PGRST116";
152
- /** Multiple rows returned when single expected */
187
+ /** `.single()` found more than one row */
153
188
  readonly MULTIPLE_ROWS: "PGRST116";
154
- /** Schema cache miss: PostgREST needs reload */
189
+ /** The request named a column the schema cache does not have */
155
190
  readonly SCHEMA_CACHE_MISS: "PGRST204";
156
191
  /** Foreign key violation */
157
- readonly FK_VIOLATION: "PGRST23503";
192
+ readonly FK_VIOLATION: "23503";
158
193
  /** Unique constraint violation */
159
- readonly UNIQUE_VIOLATION: "PGRST23505";
194
+ readonly UNIQUE_VIOLATION: "23505";
160
195
  /** Not-null constraint violation */
161
- readonly NOT_NULL_VIOLATION: "PGRST23502";
196
+ readonly NOT_NULL_VIOLATION: "23502";
162
197
  /** Check constraint violation */
163
- readonly CHECK_VIOLATION: "PGRST23514";
198
+ readonly CHECK_VIOLATION: "23514";
164
199
  /** Invalid input syntax */
165
- readonly INVALID_INPUT: "PGRST22P02";
166
- /** Undefined table */
167
- readonly UNDEFINED_TABLE: "PGRST42P01";
200
+ readonly INVALID_INPUT: "22P02";
201
+ /** The table is not in the schema cache (the SQLSTATE `42P01` before PostgREST 13) */
202
+ readonly UNDEFINED_TABLE: "PGRST205";
168
203
  /** Undefined column */
169
- readonly UNDEFINED_COLUMN: "PGRST42703";
204
+ readonly UNDEFINED_COLUMN: "42703";
170
205
  };
171
206
  readonly Storage: {
172
207
  readonly OBJECT_NOT_FOUND: "STORAGE_OBJECT_NOT_FOUND";
@@ -194,4 +229,11 @@ export declare const ErrorCodes: {
194
229
  readonly DNS_FAILURE: "NETWORK_DNS_FAILURE";
195
230
  };
196
231
  };
232
+ /**
233
+ * A request that never got an answer, as a result rather than a throw.
234
+ *
235
+ * The client's fetch throws typed errors (a timeout, a rate limit after the last retry), and their
236
+ * code and status are what lets a caller tell "try again later" from "the server is gone".
237
+ */
238
+ export declare function transportFailure(e: unknown): SupatypeErrorShape;
197
239
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,C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6CAA6C;;;;;;;;CAiBrC,CAAA;AAEV;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAS/D"}
package/dist/errors.js CHANGED
@@ -85,20 +85,37 @@ export class RateLimitError extends SupatypeError {
85
85
  }
86
86
  }
87
87
  // ── Common error codes ────────────────────────────────────────────
88
+ /**
89
+ * The `code` an auth error carries, as the auth server sends it in `error_code`.
90
+ *
91
+ * These were `AUTH_INVALID_CREDENTIALS` and the like, which the server never sends, so comparing
92
+ * an error's code with them never matched. The names are unchanged; the values are the server's.
93
+ */
88
94
  export const AuthErrorCodes = {
89
- INVALID_CREDENTIALS: "AUTH_INVALID_CREDENTIALS",
90
- USER_NOT_FOUND: "AUTH_USER_NOT_FOUND",
91
- EMAIL_NOT_CONFIRMED: "AUTH_EMAIL_NOT_CONFIRMED",
92
- PHONE_NOT_CONFIRMED: "AUTH_PHONE_NOT_CONFIRMED",
93
- SESSION_EXPIRED: "AUTH_SESSION_EXPIRED",
94
- INVALID_TOKEN: "AUTH_INVALID_TOKEN",
95
- MFA_REQUIRED: "AUTH_MFA_REQUIRED",
96
- MFA_CHALLENGE_EXPIRED: "AUTH_MFA_CHALLENGE_EXPIRED",
97
- MFA_VERIFICATION_FAILED: "AUTH_MFA_VERIFICATION_FAILED",
98
- WEAK_PASSWORD: "AUTH_WEAK_PASSWORD",
99
- USER_ALREADY_EXISTS: "AUTH_USER_ALREADY_EXISTS",
100
- OAUTH_CALLBACK_ERROR: "AUTH_OAUTH_CALLBACK_ERROR",
101
- MAGIC_LINK_EXPIRED: "AUTH_MAGIC_LINK_EXPIRED",
95
+ /** Wrong email or password */
96
+ INVALID_CREDENTIALS: "invalid_credentials",
97
+ USER_NOT_FOUND: "user_not_found",
98
+ EMAIL_NOT_CONFIRMED: "email_not_confirmed",
99
+ PHONE_NOT_CONFIRMED: "phone_not_confirmed",
100
+ SESSION_EXPIRED: "session_expired",
101
+ /** The access token could not be verified */
102
+ INVALID_TOKEN: "bad_jwt",
103
+ /** The request needs a session at a higher assurance level: complete an MFA challenge first */
104
+ MFA_REQUIRED: "insufficient_aal",
105
+ MFA_CHALLENGE_EXPIRED: "mfa_challenge_expired",
106
+ MFA_VERIFICATION_FAILED: "mfa_verification_failed",
107
+ WEAK_PASSWORD: "weak_password",
108
+ /** Sign-up with an email that is already registered sends EMAIL_EXISTS */
109
+ USER_ALREADY_EXISTS: "user_already_exists",
110
+ EMAIL_EXISTS: "email_exists",
111
+ OAUTH_CALLBACK_ERROR: "bad_oauth_callback",
112
+ /** An emailed link or one-time code that has expired or was already used */
113
+ MAGIC_LINK_EXPIRED: "otp_expired",
114
+ OTP_EXPIRED: "otp_expired",
115
+ SIGNUP_DISABLED: "signup_disabled",
116
+ SAME_PASSWORD: "same_password",
117
+ OVER_EMAIL_SEND_RATE_LIMIT: "over_email_send_rate_limit",
118
+ OVER_REQUEST_RATE_LIMIT: "over_request_rate_limit",
102
119
  };
103
120
  export const StorageErrorCodes = {
104
121
  OBJECT_NOT_FOUND: "STORAGE_OBJECT_NOT_FOUND",
@@ -108,31 +125,39 @@ export const StorageErrorCodes = {
108
125
  QUOTA_EXCEEDED: "STORAGE_QUOTA_EXCEEDED",
109
126
  PRESIGNED_URL_EXPIRED: "STORAGE_PRESIGNED_URL_EXPIRED",
110
127
  };
128
+ /**
129
+ * The `code` a REST error carries, as PostgREST 14 sends it.
130
+ *
131
+ * PostgREST's own errors are `PGRST` codes. A database error is passed through under its Postgres
132
+ * SQLSTATE, with no prefix: a unique violation is `23505`, never `PGRST23505`.
133
+ */
111
134
  export const PostgrestErrorCodes = {
112
- /** JWT expired or missing */
113
- JWT_EXPIRED: "PGRST301",
114
- /** No permission: RLS policy denied access */
115
- PERMISSION_DENIED: "PGRST302",
116
- /** Requested resource not found */
135
+ /** The token could not be decoded or verified: a bad signature, a malformed or empty token */
136
+ JWT_INVALID: "PGRST301",
137
+ /** The token's claims were rejected, an expired token among them (`PGRST301` before PostgREST 13) */
138
+ JWT_EXPIRED: "PGRST303",
139
+ /** Row-level security or a missing grant refused the operation */
140
+ PERMISSION_DENIED: "42501",
141
+ /** `.single()` found no row */
117
142
  NOT_FOUND: "PGRST116",
118
- /** Multiple rows returned when single expected */
143
+ /** `.single()` found more than one row */
119
144
  MULTIPLE_ROWS: "PGRST116",
120
- /** Schema cache miss: PostgREST needs reload */
145
+ /** The request named a column the schema cache does not have */
121
146
  SCHEMA_CACHE_MISS: "PGRST204",
122
147
  /** Foreign key violation */
123
- FK_VIOLATION: "PGRST23503",
148
+ FK_VIOLATION: "23503",
124
149
  /** Unique constraint violation */
125
- UNIQUE_VIOLATION: "PGRST23505",
150
+ UNIQUE_VIOLATION: "23505",
126
151
  /** Not-null constraint violation */
127
- NOT_NULL_VIOLATION: "PGRST23502",
152
+ NOT_NULL_VIOLATION: "23502",
128
153
  /** Check constraint violation */
129
- CHECK_VIOLATION: "PGRST23514",
154
+ CHECK_VIOLATION: "23514",
130
155
  /** Invalid input syntax */
131
- INVALID_INPUT: "PGRST22P02",
132
- /** Undefined table */
133
- UNDEFINED_TABLE: "PGRST42P01",
156
+ INVALID_INPUT: "22P02",
157
+ /** The table is not in the schema cache (the SQLSTATE `42P01` before PostgREST 13) */
158
+ UNDEFINED_TABLE: "PGRST205",
134
159
  /** Undefined column */
135
- UNDEFINED_COLUMN: "PGRST42703",
160
+ UNDEFINED_COLUMN: "42703",
136
161
  };
137
162
  export const RealtimeErrorCodes = {
138
163
  /** WebSocket connection failed */
@@ -159,4 +184,20 @@ export const ErrorCodes = {
159
184
  Realtime: RealtimeErrorCodes,
160
185
  Network: NetworkErrorCodes,
161
186
  };
187
+ /**
188
+ * A request that never got an answer, as a result rather than a throw.
189
+ *
190
+ * The client's fetch throws typed errors (a timeout, a rate limit after the last retry), and their
191
+ * code and status are what lets a caller tell "try again later" from "the server is gone".
192
+ */
193
+ export function transportFailure(e) {
194
+ if (e instanceof SupatypeError) {
195
+ return {
196
+ message: e.message,
197
+ code: e.code,
198
+ ...(e.statusCode !== undefined && { status: e.statusCode }),
199
+ };
200
+ }
201
+ return { message: e instanceof Error ? e.message : "Network error" };
202
+ }
162
203
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,SAAS,GAAG,kCAAkC,CAAA;AAEpD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAQ;IACZ,OAAO,CAAQ;IACf,UAAU,CAAqB;IAExC,YAAY,OAAe,EAAE,IAAY,EAAE,UAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,GAAG,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAA;IACrD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,YAAY,OAAe,EAAE,OAAe,YAAY,EAAE,UAAmB;QAC3E,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAa;IACtC,OAAO,CAAe;IACtB,IAAI,CAAe;IAE5B,YACE,OAAe,EACf,OAAe,UAAU,EACzB,UAAmB,EACnB,OAAuB,EACvB,IAAoB;QAEpB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,CAAA;QAC9B,IAAI,CAAC,IAAI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MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,IAAI,CAAC,YAAY,aAAa,EAAE,CAAC;QAC/B,OAAO;YACL,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,GAAG,CAAC,CAAC,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;SAC5D,CAAA;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAA;AACtE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"exact-response.d.ts","sourceRoot":"","sources":["../src/exact-response.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAEzF,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAWxE"}
1
+ {"version":3,"file":"exact-response.d.ts","sourceRoot":"","sources":["../src/exact-response.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAEzF,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAWxE"}