@koolbase/core 11.2.0 → 11.3.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.
@@ -217,6 +217,29 @@ export declare class LastCredentialError extends KoolbaseAuthError {
217
217
  export declare class HideRequiresVerificationError extends KoolbaseAuthError {
218
218
  constructor(message?: string);
219
219
  }
220
+ /**
221
+ * The API key's scope is below what the operation requires.
222
+ *
223
+ * Scopes rank read < write < admin. Not a credential problem — the key is
224
+ * valid, and a different key or a dashboard session is needed. Worth its own
225
+ * type so an app does not tell someone to sign in again when signing in will
226
+ * not help.
227
+ */
228
+ export declare class InsufficientScopeError extends KoolbaseAuthError {
229
+ constructor(message?: string);
230
+ }
231
+ /** The provider is not connected to this account. */
232
+ export declare class IdentityNotFoundError extends KoolbaseAuthError {
233
+ constructor(message?: string);
234
+ }
235
+ /**
236
+ * Connecting a Google or Apple identity that another account already holds.
237
+ * Distinct from AccountExistsError, which is about the email; this is about
238
+ * the provider identity itself.
239
+ */
240
+ export declare class ProviderIdentityAlreadyLinkedError extends KoolbaseAuthError {
241
+ constructor(message?: string);
242
+ }
220
243
  export declare class MalformedSessionResponseError extends KoolbaseAuthError {
221
244
  constructor(missing: string);
222
245
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleEmailRequiredError = exports.InvalidGoogleTokenError = exports.MalformedSessionResponseError = exports.HideRequiresVerificationError = exports.LastCredentialError = exports.InsufficientAuthorityError = exports.SessionRequiredError = exports.UnsupportedOAuthProviderError = exports.OAuthOnlyAccountError = exports.AccountExistsError = exports.CurrentPasswordIncorrectError = exports.TokenAlreadyUsedError = exports.TokenExpiredError = exports.SignupsDisabledError = exports.ContactNotVerifiedError = exports.GoogleSignInNotConfiguredError = exports.OAuthEmailConflictError = exports.AppleEmailRequiredError = exports.InvalidAppleTokenError = exports.AppleSignInNotConfiguredError = exports.SmsConfigMissingError = exports.PhoneAlreadyLinkedError = exports.OtpRateLimitError = exports.OtpMaxAttemptsError = exports.OtpInvalidError = exports.OtpExpiredError = exports.InvalidPhoneNumberError = exports.NetworkError = exports.VerificationResendDailyCapError = exports.VerificationResendCooldownError = exports.RateLimitError = exports.UnlockTokenInvalidError = exports.AccountLockedError = exports.TokenRevokedError = exports.SessionExpiredError = exports.WeakPasswordError = exports.UserDisabledError = exports.EmailAlreadyInUseError = exports.InvalidCredentialsError = exports.KoolbaseAuthError = void 0;
3
+ exports.GoogleEmailRequiredError = exports.InvalidGoogleTokenError = exports.MalformedSessionResponseError = exports.ProviderIdentityAlreadyLinkedError = exports.IdentityNotFoundError = exports.InsufficientScopeError = exports.HideRequiresVerificationError = exports.LastCredentialError = exports.InsufficientAuthorityError = exports.SessionRequiredError = exports.UnsupportedOAuthProviderError = exports.OAuthOnlyAccountError = exports.AccountExistsError = exports.CurrentPasswordIncorrectError = exports.TokenAlreadyUsedError = exports.TokenExpiredError = exports.SignupsDisabledError = exports.ContactNotVerifiedError = exports.GoogleSignInNotConfiguredError = exports.OAuthEmailConflictError = exports.AppleEmailRequiredError = exports.InvalidAppleTokenError = exports.AppleSignInNotConfiguredError = exports.SmsConfigMissingError = exports.PhoneAlreadyLinkedError = exports.OtpRateLimitError = exports.OtpMaxAttemptsError = exports.OtpInvalidError = exports.OtpExpiredError = exports.InvalidPhoneNumberError = exports.NetworkError = exports.VerificationResendDailyCapError = exports.VerificationResendCooldownError = exports.RateLimitError = exports.UnlockTokenInvalidError = exports.AccountLockedError = exports.TokenRevokedError = exports.SessionExpiredError = exports.WeakPasswordError = exports.UserDisabledError = exports.EmailAlreadyInUseError = exports.InvalidCredentialsError = exports.KoolbaseAuthError = void 0;
4
4
  const errors_js_1 = require("./errors.js");
5
5
  /**
6
6
  * Base error type for all Koolbase auth errors. Catchable via
@@ -410,6 +410,44 @@ class HideRequiresVerificationError extends KoolbaseAuthError {
410
410
  }
411
411
  }
412
412
  exports.HideRequiresVerificationError = HideRequiresVerificationError;
413
+ /**
414
+ * The API key's scope is below what the operation requires.
415
+ *
416
+ * Scopes rank read < write < admin. Not a credential problem — the key is
417
+ * valid, and a different key or a dashboard session is needed. Worth its own
418
+ * type so an app does not tell someone to sign in again when signing in will
419
+ * not help.
420
+ */
421
+ class InsufficientScopeError extends KoolbaseAuthError {
422
+ constructor(message) {
423
+ super(message ?? "This key's scope does not permit this operation", 'insufficient_scope');
424
+ this.name = 'InsufficientScopeError';
425
+ Object.setPrototypeOf(this, InsufficientScopeError.prototype);
426
+ }
427
+ }
428
+ exports.InsufficientScopeError = InsufficientScopeError;
429
+ /** The provider is not connected to this account. */
430
+ class IdentityNotFoundError extends KoolbaseAuthError {
431
+ constructor(message) {
432
+ super(message ?? 'That provider is not connected to your account', 'identity_not_found');
433
+ this.name = 'IdentityNotFoundError';
434
+ Object.setPrototypeOf(this, IdentityNotFoundError.prototype);
435
+ }
436
+ }
437
+ exports.IdentityNotFoundError = IdentityNotFoundError;
438
+ /**
439
+ * Connecting a Google or Apple identity that another account already holds.
440
+ * Distinct from AccountExistsError, which is about the email; this is about
441
+ * the provider identity itself.
442
+ */
443
+ class ProviderIdentityAlreadyLinkedError extends KoolbaseAuthError {
444
+ constructor(message) {
445
+ super(message ?? 'That provider identity is already linked to another account', 'provider_identity_already_linked');
446
+ this.name = 'ProviderIdentityAlreadyLinkedError';
447
+ Object.setPrototypeOf(this, ProviderIdentityAlreadyLinkedError.prototype);
448
+ }
449
+ }
450
+ exports.ProviderIdentityAlreadyLinkedError = ProviderIdentityAlreadyLinkedError;
413
451
  class MalformedSessionResponseError extends KoolbaseAuthError {
414
452
  constructor(missing) {
415
453
  super(`The server returned a session without ${missing}. This is a protocol error, not a credential problem.`, 'malformed_session_response');
package/dist/cjs/auth.js CHANGED
@@ -198,9 +198,16 @@ class KoolbaseAuth {
198
198
  return types_js_1.RestoreResult.Restored;
199
199
  }
200
200
  catch (e) {
201
- if (e instanceof auth_errors_js_1.SessionExpiredError ||
202
- e instanceof auth_errors_js_1.TokenRevokedError ||
203
- e instanceof auth_errors_js_1.InvalidCredentialsError) {
201
+ // Only a refresh the server refused clears the stored session, and
202
+ // only because the refresh token is the last credential there is — once
203
+ // it is rejected there is nothing left to try.
204
+ //
205
+ // InvalidCredentialsError used to be in this list. It means "these
206
+ // credentials are wrong", which during a restore points at the project
207
+ // key or the request rather than the user's session — and deleting the
208
+ // refresh token on that reading signs someone out with no way back.
209
+ // Nothing reaches here with it today; it stays out so nothing does.
210
+ if (e instanceof auth_errors_js_1.SessionExpiredError) {
204
211
  await this.clearSessionInternal();
205
212
  return types_js_1.RestoreResult.Expired;
206
213
  }
@@ -791,8 +798,6 @@ class KoolbaseAuth {
791
798
  case 'invalid_refresh_token':
792
799
  // Refresh token rejected — the session is unrecoverable; re-login.
793
800
  throw new auth_errors_js_1.SessionExpiredError();
794
- case 'token_revoked':
795
- throw new auth_errors_js_1.TokenRevokedError();
796
801
  case 'invalid_unlock_token':
797
802
  throw new auth_errors_js_1.UnlockTokenInvalidError();
798
803
  case 'rate_limit':
@@ -831,6 +836,12 @@ class KoolbaseAuth {
831
836
  throw new auth_errors_js_1.OAuthOnlyAccountError(msg || undefined);
832
837
  case 'unsupported_oauth_provider':
833
838
  throw new auth_errors_js_1.UnsupportedOAuthProviderError(msg || undefined);
839
+ case 'identity_not_found':
840
+ throw new auth_errors_js_1.IdentityNotFoundError(msg || undefined);
841
+ case 'provider_identity_already_linked':
842
+ throw new auth_errors_js_1.ProviderIdentityAlreadyLinkedError(msg || undefined);
843
+ case 'insufficient_scope':
844
+ throw new auth_errors_js_1.InsufficientScopeError(msg || undefined);
834
845
  // Authority
835
846
  case 'session_required':
836
847
  throw new auth_errors_js_1.SessionRequiredError(msg || undefined);
@@ -863,11 +874,6 @@ class KoolbaseAuth {
863
874
  if (msg.includes('invalid or expired unlock token')) {
864
875
  throw new auth_errors_js_1.UnlockTokenInvalidError();
865
876
  }
866
- if (msg.includes('session revoked') ||
867
- msg.includes('token revoked') ||
868
- msg.includes('session has been revoked')) {
869
- throw new auth_errors_js_1.TokenRevokedError();
870
- }
871
877
  throw new auth_errors_js_1.KoolbaseAuthError(msg || `Request failed: ${res.status}`, code || `http_${res.status}`);
872
878
  }
873
879
  /**
@@ -49,6 +49,137 @@ export declare class KoolbaseDataError extends KoolbaseError {
49
49
  * nobody asked to change. Narrow the filter, or add a unique constraint over
50
50
  * the fields you are matching on so the ambiguity cannot arise.
51
51
  */
52
+ /**
53
+ * The record changed between reading it and writing it.
54
+ *
55
+ * Optimistic concurrency: a write carrying a revision is refused when the
56
+ * server has moved on, rather than overwriting whatever happened in between.
57
+ * The refusal carries the server's current record and both revisions, so
58
+ * resolving needs no second fetch — and cannot race one.
59
+ *
60
+ * Distinct from KoolbaseConflict, which models a queued OFFLINE write and
61
+ * carries a baseline as well, because a change composed hours ago needs its
62
+ * original context to be resolvable. Here the caller still has their data in
63
+ * hand.
64
+ *
65
+ * Until 11.3.0 this arrived as a generic data error and the details had to be
66
+ * dug out of an untyped bag — the information the server went to the trouble
67
+ * of attaching, unreachable in practice.
68
+ */
69
+ /** A vector field with that name already exists on the collection. */
70
+ /**
71
+ * A seed or import operation was refused. The code says which stage:
72
+ * invalid_seed_file (the file itself, with a "problems" list in details),
73
+ * seed_key_not_unique (the key does not identify rows uniquely),
74
+ * seed_needs_decision (conflicts need a choice before proceeding), or
75
+ * seed_conflicts_require_force (overwriting would discard the target's
76
+ * version of rows that changed on both sides — details carry the rows).
77
+ *
78
+ * One class with the code distinguishing them, rather than four: these are
79
+ * dashboard and CLI operations, and a caller handling one handles them the
80
+ * same way — show the reason and let a human decide.
81
+ */
82
+ export declare class KoolbaseSeedError extends KoolbaseDataError {
83
+ constructor(message: string, code: string);
84
+ }
85
+ /** A project slug that another project already holds. */
86
+ export declare class KoolbaseSlugTakenError extends KoolbaseDataError {
87
+ constructor(message?: string);
88
+ }
89
+ /** An invitation that has been revoked or has expired. */
90
+ export declare class KoolbaseInvitationInvalidError extends KoolbaseDataError {
91
+ constructor(message?: string);
92
+ }
93
+ /** The project id in the request is not valid. */
94
+ export declare class KoolbaseProjectInvalidError extends KoolbaseDataError {
95
+ constructor(message?: string);
96
+ }
97
+ /** The request body could not be decoded. */
98
+ export declare class KoolbaseInvalidBodyError extends KoolbaseDataError {
99
+ constructor(message?: string);
100
+ }
101
+ /**
102
+ * The request asked for no change — an update with nothing to update.
103
+ */
104
+ export declare class KoolbaseNoChangesError extends KoolbaseDataError {
105
+ constructor(message?: string);
106
+ }
107
+ /**
108
+ * Something already exists, or something is in the wrong state, where the
109
+ * server did not say more than that.
110
+ *
111
+ * Carries whichever generic code arrived — conflict, duplicate,
112
+ * state_conflict — rather than four classes for codes that differ only in
113
+ * spelling. A caller who needs to branch finely is being underserved by the
114
+ * server, not by this.
115
+ */
116
+ export declare class KoolbaseStateConflictError extends KoolbaseDataError {
117
+ constructor(message: string, code: string);
118
+ }
119
+ export declare class KoolbaseVectorFieldExistsError extends KoolbaseDataError {
120
+ constructor(message?: string);
121
+ }
122
+ /**
123
+ * A backfill was asked for on a field that embeds nothing automatically.
124
+ * Set provider, model and source_field on the field first.
125
+ */
126
+ export declare class KoolbaseFieldNotAutoEmbedError extends KoolbaseDataError {
127
+ constructor(message?: string);
128
+ }
129
+ /**
130
+ * Embedding config is partial. Provider, model and source_field are set
131
+ * together or cleared together — half a configuration is refused rather than
132
+ * half-applied, which would embed against a model nobody chose.
133
+ */
134
+ export declare class KoolbaseInvalidEmbeddingConfigError extends KoolbaseDataError {
135
+ constructor(message?: string);
136
+ }
137
+ /**
138
+ * The project has no embedding provider configured. Embedding runs on the
139
+ * project's own Gemini or OpenAI key.
140
+ */
141
+ export declare class KoolbaseProviderNotConfiguredError extends KoolbaseDataError {
142
+ constructor(message?: string);
143
+ }
144
+ /** The configured provider's credentials were rejected by the provider. */
145
+ export declare class KoolbaseProviderInvalidError extends KoolbaseDataError {
146
+ constructor(message?: string);
147
+ }
148
+ export declare class KoolbaseRevisionMismatchError extends KoolbaseDataError {
149
+ readonly expectedRevision?: number | undefined;
150
+ readonly currentRevision?: number | undefined;
151
+ /** The record as the server holds it now. */
152
+ readonly current?: Record<string, unknown> | undefined;
153
+ constructor(message?: string, expectedRevision?: number | undefined, currentRevision?: number | undefined,
154
+ /** The record as the server holds it now. */
155
+ current?: Record<string, unknown> | undefined);
156
+ }
157
+ /**
158
+ * The same idempotency key sent with different data.
159
+ *
160
+ * Refused rather than replayed: the two requests do not agree, so neither
161
+ * answer is safe. Usually a key reused by accident across two operations.
162
+ */
163
+ export declare class KoolbaseIdempotencyKeyReusedError extends KoolbaseDataError {
164
+ /**
165
+ * Carries its code: the database package calls this idempotency_key_reused
166
+ * and fiscal calls it idempotency_conflict, and an error reporting a code
167
+ * the server did not send is a small lie that apps branching on e.code act
168
+ * on.
169
+ */
170
+ constructor(message?: string, code?: string);
171
+ }
172
+ /** A batch write failed for a reason the server did not classify further. */
173
+ export declare class KoolbaseBatchFailedError extends KoolbaseDataError {
174
+ constructor(message?: string);
175
+ }
176
+ /**
177
+ * Creating a unique constraint over data that already breaks it. details
178
+ * carry the offending values, so they can be shown rather than hunted for.
179
+ */
180
+ export declare class KoolbaseDuplicateValuesError extends KoolbaseDataError {
181
+ constructor(message?: string);
182
+ }
52
183
  export declare class KoolbaseAmbiguousMatchError extends KoolbaseDataError {
53
184
  constructor(message?: string);
54
185
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KoolbaseVectorDimensionMismatchError = exports.KoolbaseRateLimitError = exports.KoolbasePermissionError = exports.KoolbaseInsufficientAuthorityError = exports.KoolbaseValidationError = exports.KoolbaseNotFoundError = exports.KoolbaseConflictError = exports.KoolbaseConstraintNotFoundError = exports.KoolbaseConstraintExistsError = exports.KoolbaseAmbiguousMatchError = exports.KoolbaseDataError = void 0;
3
+ exports.KoolbaseVectorDimensionMismatchError = exports.KoolbaseRateLimitError = exports.KoolbasePermissionError = exports.KoolbaseInsufficientAuthorityError = exports.KoolbaseValidationError = exports.KoolbaseNotFoundError = exports.KoolbaseConflictError = exports.KoolbaseConstraintNotFoundError = exports.KoolbaseConstraintExistsError = exports.KoolbaseAmbiguousMatchError = exports.KoolbaseDuplicateValuesError = exports.KoolbaseBatchFailedError = exports.KoolbaseIdempotencyKeyReusedError = exports.KoolbaseRevisionMismatchError = exports.KoolbaseProviderInvalidError = exports.KoolbaseProviderNotConfiguredError = exports.KoolbaseInvalidEmbeddingConfigError = exports.KoolbaseFieldNotAutoEmbedError = exports.KoolbaseVectorFieldExistsError = exports.KoolbaseStateConflictError = exports.KoolbaseNoChangesError = exports.KoolbaseInvalidBodyError = exports.KoolbaseProjectInvalidError = exports.KoolbaseInvitationInvalidError = exports.KoolbaseSlugTakenError = exports.KoolbaseSeedError = exports.KoolbaseDataError = void 0;
4
4
  exports.koolbaseDataError = koolbaseDataError;
5
5
  const errors_js_1 = require("./errors.js");
6
6
  /**
@@ -52,6 +52,216 @@ exports.KoolbaseDataError = KoolbaseDataError;
52
52
  * nobody asked to change. Narrow the filter, or add a unique constraint over
53
53
  * the fields you are matching on so the ambiguity cannot arise.
54
54
  */
55
+ /**
56
+ * The record changed between reading it and writing it.
57
+ *
58
+ * Optimistic concurrency: a write carrying a revision is refused when the
59
+ * server has moved on, rather than overwriting whatever happened in between.
60
+ * The refusal carries the server's current record and both revisions, so
61
+ * resolving needs no second fetch — and cannot race one.
62
+ *
63
+ * Distinct from KoolbaseConflict, which models a queued OFFLINE write and
64
+ * carries a baseline as well, because a change composed hours ago needs its
65
+ * original context to be resolvable. Here the caller still has their data in
66
+ * hand.
67
+ *
68
+ * Until 11.3.0 this arrived as a generic data error and the details had to be
69
+ * dug out of an untyped bag — the information the server went to the trouble
70
+ * of attaching, unreachable in practice.
71
+ */
72
+ /** A vector field with that name already exists on the collection. */
73
+ /**
74
+ * A seed or import operation was refused. The code says which stage:
75
+ * invalid_seed_file (the file itself, with a "problems" list in details),
76
+ * seed_key_not_unique (the key does not identify rows uniquely),
77
+ * seed_needs_decision (conflicts need a choice before proceeding), or
78
+ * seed_conflicts_require_force (overwriting would discard the target's
79
+ * version of rows that changed on both sides — details carry the rows).
80
+ *
81
+ * One class with the code distinguishing them, rather than four: these are
82
+ * dashboard and CLI operations, and a caller handling one handles them the
83
+ * same way — show the reason and let a human decide.
84
+ */
85
+ class KoolbaseSeedError extends KoolbaseDataError {
86
+ constructor(message, code) {
87
+ super(message, code);
88
+ this.name = 'KoolbaseSeedError';
89
+ Object.setPrototypeOf(this, KoolbaseSeedError.prototype);
90
+ }
91
+ }
92
+ exports.KoolbaseSeedError = KoolbaseSeedError;
93
+ /** A project slug that another project already holds. */
94
+ class KoolbaseSlugTakenError extends KoolbaseDataError {
95
+ constructor(message) {
96
+ super(message ?? 'A project with this slug already exists', 'slug_taken');
97
+ this.name = 'KoolbaseSlugTakenError';
98
+ Object.setPrototypeOf(this, KoolbaseSlugTakenError.prototype);
99
+ }
100
+ }
101
+ exports.KoolbaseSlugTakenError = KoolbaseSlugTakenError;
102
+ /** An invitation that has been revoked or has expired. */
103
+ class KoolbaseInvitationInvalidError extends KoolbaseDataError {
104
+ constructor(message) {
105
+ super(message ?? 'This invitation has been revoked or expired', 'invitation_invalid');
106
+ this.name = 'KoolbaseInvitationInvalidError';
107
+ Object.setPrototypeOf(this, KoolbaseInvitationInvalidError.prototype);
108
+ }
109
+ }
110
+ exports.KoolbaseInvitationInvalidError = KoolbaseInvitationInvalidError;
111
+ /** The project id in the request is not valid. */
112
+ class KoolbaseProjectInvalidError extends KoolbaseDataError {
113
+ constructor(message) {
114
+ super(message ?? 'Invalid project id', 'project_invalid');
115
+ this.name = 'KoolbaseProjectInvalidError';
116
+ Object.setPrototypeOf(this, KoolbaseProjectInvalidError.prototype);
117
+ }
118
+ }
119
+ exports.KoolbaseProjectInvalidError = KoolbaseProjectInvalidError;
120
+ /** The request body could not be decoded. */
121
+ class KoolbaseInvalidBodyError extends KoolbaseDataError {
122
+ constructor(message) {
123
+ super(message ?? 'Could not decode the request body', 'invalid_body');
124
+ this.name = 'KoolbaseInvalidBodyError';
125
+ Object.setPrototypeOf(this, KoolbaseInvalidBodyError.prototype);
126
+ }
127
+ }
128
+ exports.KoolbaseInvalidBodyError = KoolbaseInvalidBodyError;
129
+ /**
130
+ * The request asked for no change — an update with nothing to update.
131
+ */
132
+ class KoolbaseNoChangesError extends KoolbaseDataError {
133
+ constructor(message) {
134
+ super(message ?? 'The request contains no changes', 'no_changes');
135
+ this.name = 'KoolbaseNoChangesError';
136
+ Object.setPrototypeOf(this, KoolbaseNoChangesError.prototype);
137
+ }
138
+ }
139
+ exports.KoolbaseNoChangesError = KoolbaseNoChangesError;
140
+ /**
141
+ * Something already exists, or something is in the wrong state, where the
142
+ * server did not say more than that.
143
+ *
144
+ * Carries whichever generic code arrived — conflict, duplicate,
145
+ * state_conflict — rather than four classes for codes that differ only in
146
+ * spelling. A caller who needs to branch finely is being underserved by the
147
+ * server, not by this.
148
+ */
149
+ class KoolbaseStateConflictError extends KoolbaseDataError {
150
+ constructor(message, code) {
151
+ super(message, code);
152
+ this.name = 'KoolbaseStateConflictError';
153
+ Object.setPrototypeOf(this, KoolbaseStateConflictError.prototype);
154
+ }
155
+ }
156
+ exports.KoolbaseStateConflictError = KoolbaseStateConflictError;
157
+ class KoolbaseVectorFieldExistsError extends KoolbaseDataError {
158
+ constructor(message) {
159
+ super(message ?? 'A vector field with that name already exists on this collection', 'vector_field_exists');
160
+ this.name = 'KoolbaseVectorFieldExistsError';
161
+ Object.setPrototypeOf(this, KoolbaseVectorFieldExistsError.prototype);
162
+ }
163
+ }
164
+ exports.KoolbaseVectorFieldExistsError = KoolbaseVectorFieldExistsError;
165
+ /**
166
+ * A backfill was asked for on a field that embeds nothing automatically.
167
+ * Set provider, model and source_field on the field first.
168
+ */
169
+ class KoolbaseFieldNotAutoEmbedError extends KoolbaseDataError {
170
+ constructor(message) {
171
+ super(message ?? 'This vector field has no auto-embedding config; set provider, model and source_field first', 'field_not_auto_embed');
172
+ this.name = 'KoolbaseFieldNotAutoEmbedError';
173
+ Object.setPrototypeOf(this, KoolbaseFieldNotAutoEmbedError.prototype);
174
+ }
175
+ }
176
+ exports.KoolbaseFieldNotAutoEmbedError = KoolbaseFieldNotAutoEmbedError;
177
+ /**
178
+ * Embedding config is partial. Provider, model and source_field are set
179
+ * together or cleared together — half a configuration is refused rather than
180
+ * half-applied, which would embed against a model nobody chose.
181
+ */
182
+ class KoolbaseInvalidEmbeddingConfigError extends KoolbaseDataError {
183
+ constructor(message) {
184
+ super(message ?? 'Embedding config requires provider, model and source_field together, or all cleared', 'invalid_embedding_config');
185
+ this.name = 'KoolbaseInvalidEmbeddingConfigError';
186
+ Object.setPrototypeOf(this, KoolbaseInvalidEmbeddingConfigError.prototype);
187
+ }
188
+ }
189
+ exports.KoolbaseInvalidEmbeddingConfigError = KoolbaseInvalidEmbeddingConfigError;
190
+ /**
191
+ * The project has no embedding provider configured. Embedding runs on the
192
+ * project's own Gemini or OpenAI key.
193
+ */
194
+ class KoolbaseProviderNotConfiguredError extends KoolbaseDataError {
195
+ constructor(message) {
196
+ super(message ?? 'No embedding provider is configured for this project', 'provider_not_configured');
197
+ this.name = 'KoolbaseProviderNotConfiguredError';
198
+ Object.setPrototypeOf(this, KoolbaseProviderNotConfiguredError.prototype);
199
+ }
200
+ }
201
+ exports.KoolbaseProviderNotConfiguredError = KoolbaseProviderNotConfiguredError;
202
+ /** The configured provider's credentials were rejected by the provider. */
203
+ class KoolbaseProviderInvalidError extends KoolbaseDataError {
204
+ constructor(message) {
205
+ super(message ?? 'The embedding provider credentials are not valid', 'provider_invalid');
206
+ this.name = 'KoolbaseProviderInvalidError';
207
+ Object.setPrototypeOf(this, KoolbaseProviderInvalidError.prototype);
208
+ }
209
+ }
210
+ exports.KoolbaseProviderInvalidError = KoolbaseProviderInvalidError;
211
+ class KoolbaseRevisionMismatchError extends KoolbaseDataError {
212
+ constructor(message, expectedRevision, currentRevision,
213
+ /** The record as the server holds it now. */
214
+ current) {
215
+ super(message ?? 'The record has changed since you read it', 'revision_mismatch');
216
+ this.expectedRevision = expectedRevision;
217
+ this.currentRevision = currentRevision;
218
+ this.current = current;
219
+ this.name = 'KoolbaseRevisionMismatchError';
220
+ Object.setPrototypeOf(this, KoolbaseRevisionMismatchError.prototype);
221
+ }
222
+ }
223
+ exports.KoolbaseRevisionMismatchError = KoolbaseRevisionMismatchError;
224
+ /**
225
+ * The same idempotency key sent with different data.
226
+ *
227
+ * Refused rather than replayed: the two requests do not agree, so neither
228
+ * answer is safe. Usually a key reused by accident across two operations.
229
+ */
230
+ class KoolbaseIdempotencyKeyReusedError extends KoolbaseDataError {
231
+ /**
232
+ * Carries its code: the database package calls this idempotency_key_reused
233
+ * and fiscal calls it idempotency_conflict, and an error reporting a code
234
+ * the server did not send is a small lie that apps branching on e.code act
235
+ * on.
236
+ */
237
+ constructor(message, code = 'idempotency_key_reused') {
238
+ super(message ?? 'Idempotency key reused with different data', code);
239
+ this.name = 'KoolbaseIdempotencyKeyReusedError';
240
+ Object.setPrototypeOf(this, KoolbaseIdempotencyKeyReusedError.prototype);
241
+ }
242
+ }
243
+ exports.KoolbaseIdempotencyKeyReusedError = KoolbaseIdempotencyKeyReusedError;
244
+ /** A batch write failed for a reason the server did not classify further. */
245
+ class KoolbaseBatchFailedError extends KoolbaseDataError {
246
+ constructor(message) {
247
+ super(message ?? 'The batch write failed', 'batch_failed');
248
+ this.name = 'KoolbaseBatchFailedError';
249
+ Object.setPrototypeOf(this, KoolbaseBatchFailedError.prototype);
250
+ }
251
+ }
252
+ exports.KoolbaseBatchFailedError = KoolbaseBatchFailedError;
253
+ /**
254
+ * Creating a unique constraint over data that already breaks it. details
255
+ * carry the offending values, so they can be shown rather than hunted for.
256
+ */
257
+ class KoolbaseDuplicateValuesError extends KoolbaseDataError {
258
+ constructor(message) {
259
+ super(message ?? 'The collection has duplicate values for these fields', 'duplicate_values');
260
+ this.name = 'KoolbaseDuplicateValuesError';
261
+ Object.setPrototypeOf(this, KoolbaseDuplicateValuesError.prototype);
262
+ }
263
+ }
264
+ exports.KoolbaseDuplicateValuesError = KoolbaseDuplicateValuesError;
55
265
  class KoolbaseAmbiguousMatchError extends KoolbaseDataError {
56
266
  constructor(message) {
57
267
  super(message ?? 'Upsert match resolved to more than one record', 'ambiguous_match');
@@ -217,6 +427,55 @@ function koolbaseDataError(status, body, fallbackMessage = 'Request failed') {
217
427
  switch (code) {
218
428
  case 'unique_violation':
219
429
  return attach(new KoolbaseConflictError(message, field));
430
+ case 'plan_limit_reached': {
431
+ const d = (body?.details ?? {});
432
+ return new errors_js_1.KoolbasePlanLimitError(message, d.resource, d.limit, d.plan);
433
+ }
434
+ case 'invalid_seed_file':
435
+ case 'seed_key_not_unique':
436
+ case 'seed_needs_decision':
437
+ case 'seed_conflicts_require_force':
438
+ return attach(new KoolbaseSeedError(message, code));
439
+ case 'slug_taken':
440
+ return attach(new KoolbaseSlugTakenError(message));
441
+ case 'invitation_invalid':
442
+ return attach(new KoolbaseInvitationInvalidError(message));
443
+ case 'project_invalid':
444
+ return attach(new KoolbaseProjectInvalidError(message));
445
+ case 'invalid_body':
446
+ return attach(new KoolbaseInvalidBodyError(message));
447
+ case 'no_changes':
448
+ return attach(new KoolbaseNoChangesError(message));
449
+ case 'conflict':
450
+ case 'duplicate':
451
+ case 'state_conflict':
452
+ return attach(new KoolbaseStateConflictError(message, code));
453
+ case 'vector_field_exists':
454
+ return attach(new KoolbaseVectorFieldExistsError(message));
455
+ case 'field_not_auto_embed':
456
+ return attach(new KoolbaseFieldNotAutoEmbedError(message));
457
+ case 'invalid_embedding_config':
458
+ return attach(new KoolbaseInvalidEmbeddingConfigError(message));
459
+ case 'provider_not_configured':
460
+ return attach(new KoolbaseProviderNotConfiguredError(message));
461
+ case 'provider_invalid':
462
+ return attach(new KoolbaseProviderInvalidError(message));
463
+ case 'revision_mismatch': {
464
+ // The typed fields come off details, which the server attaches for
465
+ // exactly this. attach() still puts the whole bag on the error, so
466
+ // nothing is lost for a caller reading it directly.
467
+ const d = (body?.details ?? {});
468
+ return attach(new KoolbaseRevisionMismatchError(message, d.expected_revision, d.current_revision, d.record));
469
+ }
470
+ // Two codes, one situation — the database and fiscal packages name it
471
+ // differently and a caller should not have to know which spoke.
472
+ case 'idempotency_key_reused':
473
+ case 'idempotency_conflict':
474
+ return attach(new KoolbaseIdempotencyKeyReusedError(message, code));
475
+ case 'batch_failed':
476
+ return attach(new KoolbaseBatchFailedError(message));
477
+ case 'duplicate_values':
478
+ return attach(new KoolbaseDuplicateValuesError(message));
220
479
  case 'ambiguous_match':
221
480
  return attach(new KoolbaseAmbiguousMatchError(message));
222
481
  case 'constraint_exists':
@@ -232,7 +491,6 @@ function koolbaseDataError(status, body, fallbackMessage = 'Request failed') {
232
491
  case 'vector_field_not_found':
233
492
  return attach(new KoolbaseNotFoundError(message, code));
234
493
  case 'unauthenticated':
235
- case 'session_expired':
236
494
  case 'invalid_token':
237
495
  return attach(new errors_js_1.KoolbaseUnauthenticatedError(message));
238
496
  case 'permission_denied':
@@ -59,6 +59,20 @@ export declare class KoolbaseUnauthenticatedError extends KoolbaseError {
59
59
  * updates are conflict-safe and some quietly are not, which is a worse guarantee
60
60
  * than a clear refusal.
61
61
  */
62
+ /**
63
+ * The project's plan does not allow this — a 402 carrying which resource, the
64
+ * limit, and the plan.
65
+ *
66
+ * Shared rather than per-domain: creating a collection, uploading an object
67
+ * and deploying a function can all hit it, and an app showing an upgrade
68
+ * prompt wants one type to catch.
69
+ */
70
+ export declare class KoolbasePlanLimitError extends KoolbaseError {
71
+ readonly resource?: string | undefined;
72
+ readonly limit?: number | undefined;
73
+ readonly plan?: string | undefined;
74
+ constructor(message?: string, resource?: string | undefined, limit?: number | undefined, plan?: string | undefined);
75
+ }
62
76
  export declare class KoolbaseOfflineBaselineUnavailableError extends KoolbaseError {
63
77
  constructor(message: string);
64
78
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KoolbaseOfflineBaselineUnavailableError = exports.KoolbaseUnauthenticatedError = exports.KoolbaseError = void 0;
3
+ exports.KoolbaseOfflineBaselineUnavailableError = exports.KoolbasePlanLimitError = exports.KoolbaseUnauthenticatedError = exports.KoolbaseError = void 0;
4
4
  /**
5
5
  * The root of every error the SDK raises.
6
6
  *
@@ -75,6 +75,25 @@ exports.KoolbaseUnauthenticatedError = KoolbaseUnauthenticatedError;
75
75
  * updates are conflict-safe and some quietly are not, which is a worse guarantee
76
76
  * than a clear refusal.
77
77
  */
78
+ /**
79
+ * The project's plan does not allow this — a 402 carrying which resource, the
80
+ * limit, and the plan.
81
+ *
82
+ * Shared rather than per-domain: creating a collection, uploading an object
83
+ * and deploying a function can all hit it, and an app showing an upgrade
84
+ * prompt wants one type to catch.
85
+ */
86
+ class KoolbasePlanLimitError extends KoolbaseError {
87
+ constructor(message, resource, limit, plan) {
88
+ super(message ?? 'This exceeds your plan limit', 'plan_limit_reached');
89
+ this.resource = resource;
90
+ this.limit = limit;
91
+ this.plan = plan;
92
+ this.name = 'KoolbasePlanLimitError';
93
+ Object.setPrototypeOf(this, KoolbasePlanLimitError.prototype);
94
+ }
95
+ }
96
+ exports.KoolbasePlanLimitError = KoolbasePlanLimitError;
78
97
  class KoolbaseOfflineBaselineUnavailableError extends KoolbaseError {
79
98
  constructor(message) {
80
99
  super(message, 'offline_baseline_unavailable');
@@ -84,6 +84,16 @@ export declare class KoolbaseStoragePermissionError extends KoolbaseStorageError
84
84
  * failure: presign again and send the same bytes. Worth catching rather than
85
85
  * showing "upload failed" to someone whose file was fine.
86
86
  */
87
+ /**
88
+ * Minting a presigned upload URL failed. The message carries the underlying
89
+ * reason — a misconfigured bucket, or the object store refusing.
90
+ *
91
+ * Not the user's doing, and not a retry they can fix: distinct from
92
+ * KoolbaseUploadExpiredError, which is a retry that will work.
93
+ */
94
+ export declare class KoolbaseUploadURLFailedError extends KoolbaseStorageError {
95
+ constructor(message?: string);
96
+ }
87
97
  export declare class KoolbaseUploadExpiredError extends KoolbaseStorageError {
88
98
  constructor(message?: string);
89
99
  }