@tinycloud/sdk-services 3.8.0-beta.2 → 3.8.0-beta.22

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 (59) hide show
  1. package/dist/{BaseService-DO7vZ67k.d.ts → BaseService-Ma2MwJAd.d.ts} +1 -1
  2. package/dist/{BaseService-D-29xShG.d.cts → BaseService-O0iyuFLk.d.cts} +1 -1
  3. package/dist/IHooksService-4QNODVy6.d.cts +120 -0
  4. package/dist/IHooksService-CvTpJbQD.d.ts +120 -0
  5. package/dist/ISQLService-Aly1CBsW.d.ts +242 -0
  6. package/dist/ISQLService-BOgWzHLT.d.cts +242 -0
  7. package/dist/context.d.cts +1 -1
  8. package/dist/context.d.ts +1 -1
  9. package/dist/encryption/index.cjs +80 -7
  10. package/dist/encryption/index.cjs.map +1 -1
  11. package/dist/encryption/index.d.cts +23 -11
  12. package/dist/encryption/index.d.ts +23 -11
  13. package/dist/encryption/index.js +79 -7
  14. package/dist/encryption/index.js.map +1 -1
  15. package/dist/encryption/named-keys.cjs.map +1 -1
  16. package/dist/encryption/named-keys.d.cts +2 -2
  17. package/dist/encryption/named-keys.d.ts +2 -2
  18. package/dist/encryption/named-keys.js.map +1 -1
  19. package/dist/encryption/resource.cjs.map +1 -1
  20. package/dist/encryption/resource.js.map +1 -1
  21. package/dist/feed/index.cjs +1309 -0
  22. package/dist/feed/index.cjs.map +1 -0
  23. package/dist/feed/index.d.cts +238 -0
  24. package/dist/feed/index.d.ts +238 -0
  25. package/dist/feed/index.js +1258 -0
  26. package/dist/feed/index.js.map +1 -0
  27. package/dist/index.cjs +131 -15
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +16 -116
  30. package/dist/index.d.ts +16 -116
  31. package/dist/index.js +130 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
  34. package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
  35. package/dist/kv/index.cjs.map +1 -1
  36. package/dist/kv/index.d.cts +4 -4
  37. package/dist/kv/index.d.ts +4 -4
  38. package/dist/kv/index.js.map +1 -1
  39. package/dist/kv/replication/index.cjs +1 -0
  40. package/dist/kv/replication/index.cjs.map +1 -1
  41. package/dist/kv/replication/index.d.cts +3 -3
  42. package/dist/kv/replication/index.d.ts +3 -3
  43. package/dist/kv/replication/index.js +1 -0
  44. package/dist/kv/replication/index.js.map +1 -1
  45. package/dist/{scope-_HAUxOPl.d.ts → scope-BZr0QwxX.d.ts} +8 -1
  46. package/dist/{scope-D7bzmU6F.d.cts → scope-DEgc9f-W.d.cts} +8 -1
  47. package/dist/sql/index.cjs +21 -6
  48. package/dist/sql/index.cjs.map +1 -1
  49. package/dist/sql/index.d.cts +6 -236
  50. package/dist/sql/index.d.ts +6 -236
  51. package/dist/sql/index.js +21 -6
  52. package/dist/sql/index.js.map +1 -1
  53. package/dist/telemetry/requestLog.d.cts +1 -1
  54. package/dist/telemetry/requestLog.d.ts +1 -1
  55. package/dist/{types-BGRzS1ob.d.ts → types-Bf91gup6.d.ts} +7 -2
  56. package/dist/{types-DAOyIbXu.d.cts → types-CSd0RYir.d.cts} +1 -1
  57. package/dist/{types-DAOyIbXu.d.ts → types-CSd0RYir.d.ts} +1 -1
  58. package/dist/{types-B_rbS4XE.d.cts → types-D4XbIfFJ.d.cts} +7 -2
  59. package/package.json +6 -1
@@ -1,238 +1,7 @@
1
- import { B as BaseService } from '../BaseService-D-29xShG.cjs';
2
- import { h as Result, c as IService } from '../types-DAOyIbXu.cjs';
3
-
4
- /**
5
- * SQL Service Types
6
- *
7
- * Type definitions for the SQL service operations.
8
- */
9
- /**
10
- * Configuration for SQLService.
11
- */
12
- interface SQLServiceConfig {
13
- /**
14
- * Default database name.
15
- * If not set, operations default to "default".
16
- */
17
- defaultDatabase?: string;
18
- /**
19
- * Timeout in milliseconds for each SQL request, including reading the
20
- * response body. When it elapses the request is aborted and the operation
21
- * returns an `ErrorCodes.TIMEOUT` error. Unset (the default), `0`, or
22
- * `Infinity` means no timeout.
23
- */
24
- timeout?: number;
25
- /** Allow additional config properties */
26
- [key: string]: unknown;
27
- }
28
- /**
29
- * Options for SQL query operations.
30
- */
31
- interface QueryOptions {
32
- /**
33
- * Custom abort signal for this operation.
34
- */
35
- signal?: AbortSignal;
36
- /** Maximum rows the node may return. Nodes without limit support ignore it. */
37
- maxRows?: number;
38
- /** Maximum serialized result bytes the node may return. */
39
- maxBytes?: number;
40
- }
41
- /**
42
- * Options for SQL execute operations.
43
- */
44
- interface ExecuteOptions {
45
- /**
46
- * Schema initialization statements (CREATE TABLE IF NOT EXISTS ...).
47
- * Executed before the main statement on first write.
48
- */
49
- schema?: string[];
50
- /**
51
- * Custom abort signal for this operation.
52
- */
53
- signal?: AbortSignal;
54
- }
55
- /**
56
- * Options for SQL batch operations.
57
- */
58
- interface BatchOptions {
59
- /**
60
- * Custom abort signal for this operation.
61
- */
62
- signal?: AbortSignal;
63
- }
64
- /**
65
- * A SQL value: null, number, string, or binary data.
66
- */
67
- type SqlValue = null | number | string | Uint8Array;
68
- /**
69
- * A SQL statement with optional parameters.
70
- */
71
- interface SqlStatement {
72
- sql: string;
73
- params?: SqlValue[];
74
- }
75
- /**
76
- * Response from SQL query operations.
77
- */
78
- interface QueryResponse<T = Record<string, unknown>> {
79
- columns: string[];
80
- rows: T[][];
81
- rowCount: number;
82
- }
83
- /**
84
- * Response from SQL execute operations.
85
- */
86
- interface ExecuteResponse {
87
- changes: number;
88
- lastInsertRowId: number | null;
89
- }
90
- /**
91
- * Response from SQL batch operations.
92
- */
93
- interface BatchResponse {
94
- results: ExecuteResponse[];
95
- }
96
- /**
97
- * A versioned SQL migration owned by an application or SDK subsystem.
98
- */
99
- interface SqlMigration {
100
- /**
101
- * Stable migration id within the namespace, e.g. "001_initial".
102
- */
103
- id: string;
104
- /**
105
- * SQL statements to apply when this migration has not been recorded.
106
- * Statements should be idempotent where SQLite supports it.
107
- */
108
- sql: Array<string | SqlStatement>;
109
- }
110
- /**
111
- * Options for applying SQL migrations.
112
- */
113
- interface SqlMigrationApplyOptions {
114
- /**
115
- * Namespace for this migration set, usually an app id or SDK subsystem.
116
- */
117
- namespace: string;
118
- /**
119
- * Ordered migration list.
120
- */
121
- migrations: SqlMigration[];
122
- /**
123
- * Custom abort signal for migration operations.
124
- */
125
- signal?: AbortSignal;
126
- }
127
- /**
128
- * Result from applying SQL migrations.
129
- */
130
- interface SqlMigrationApplyResponse {
131
- database: string;
132
- namespace: string;
133
- status: "already_current" | "applied";
134
- applied: string[];
135
- skipped: string[];
136
- }
137
- /**
138
- * SQL service action types.
139
- *
140
- * URNs derive from the canonical capability registry in `@tinycloud/bootstrap`
141
- * (TC-112 single source of truth, vendored from tinycloud-node). `insert`,
142
- * `update`, and `delete` were dropped — zero client refs and never accepted
143
- * node-side. `select` is a deprecated alias of `read`. `execute`/`export` are
144
- * request-kind artifacts, not grantable capabilities: the node routes them by
145
- * request-body kind, so they are absent from the registry but kept here as the
146
- * invocation ability the client sends today (wire alignment tracked in TC-114).
147
- */
148
- declare const SQLAction: {
149
- readonly READ: "tinycloud.sql/read";
150
- readonly WRITE: "tinycloud.sql/write";
151
- readonly SCHEMA: "tinycloud.sql/schema";
152
- readonly ADMIN: "tinycloud.sql/admin";
153
- readonly SELECT: "tinycloud.sql/select";
154
- readonly EXECUTE: "tinycloud.sql/execute";
155
- readonly EXPORT: "tinycloud.sql/export";
156
- readonly ALL: "tinycloud.sql/*";
157
- };
158
- type SQLActionType = (typeof SQLAction)[keyof typeof SQLAction];
159
-
160
- /**
161
- * ISQLService - Interface for SQL service.
162
- *
163
- * Platform-agnostic interface for SQL database operations.
164
- */
165
-
166
- /**
167
- * Migration helper bound to a specific database.
168
- */
169
- interface ISQLMigrations {
170
- /**
171
- * Apply ordered, app-owned migrations and record completed ids.
172
- */
173
- apply(options: SqlMigrationApplyOptions): Promise<Result<SqlMigrationApplyResponse>>;
174
- }
175
- /**
176
- * Database handle interface for operations on a specific named database.
177
- */
178
- interface IDatabaseHandle {
179
- /** The database name */
180
- readonly name: string;
181
- /** Versioned schema migration helper. */
182
- readonly migrations: ISQLMigrations;
183
- /**
184
- * Execute a SQL query and return rows.
185
- */
186
- query<T = Record<string, unknown>>(sql: string, params?: SqlValue[], options?: QueryOptions): Promise<Result<QueryResponse<T>>>;
187
- /**
188
- * Execute a SQL statement and return change count.
189
- */
190
- execute(sql: string, params?: SqlValue[], options?: ExecuteOptions): Promise<Result<ExecuteResponse>>;
191
- /**
192
- * Execute multiple statements in a transaction.
193
- */
194
- batch(statements: SqlStatement[], options?: BatchOptions): Promise<Result<BatchResponse>>;
195
- /**
196
- * Execute a named prepared statement from delegation caveats.
197
- */
198
- executeStatement(name: string, params?: SqlValue[], options?: QueryOptions): Promise<Result<QueryResponse | ExecuteResponse>>;
199
- /**
200
- * Export the raw SQLite database file.
201
- */
202
- export(options?: QueryOptions): Promise<Result<Blob>>;
203
- }
204
- /**
205
- * SQL service interface.
206
- *
207
- * Provides SQL database operations with:
208
- * - Result type pattern (no throwing)
209
- * - Named database handles
210
- * - Configurable timeouts
211
- * - Abort signal support
212
- */
213
- interface ISQLService extends IService {
214
- /**
215
- * Get a handle to a named database.
216
- * @param name - Database name (defaults to "default")
217
- */
218
- db(name?: string): IDatabaseHandle;
219
- /**
220
- * Shortcut: query the default database.
221
- */
222
- query<T = Record<string, unknown>>(sql: string, params?: SqlValue[], options?: QueryOptions): Promise<Result<QueryResponse<T>>>;
223
- /**
224
- * Shortcut: execute on the default database.
225
- */
226
- execute(sql: string, params?: SqlValue[], options?: ExecuteOptions): Promise<Result<ExecuteResponse>>;
227
- /**
228
- * Shortcut: batch on the default database.
229
- */
230
- batch(statements: SqlStatement[], options?: BatchOptions): Promise<Result<BatchResponse>>;
231
- /**
232
- * Service configuration.
233
- */
234
- readonly config: SQLServiceConfig;
235
- }
1
+ import { B as BaseService } from '../BaseService-O0iyuFLk.cjs';
2
+ import { f as Result } from '../types-CSd0RYir.cjs';
3
+ import { d as ISQLService, g as SQLServiceConfig, I as IDatabaseHandle, l as SqlValue, Q as QueryOptions, e as QueryResponse, E as ExecuteOptions, b as ExecuteResponse, k as SqlStatement, B as BatchOptions, a as BatchResponse, i as SqlMigrationApplyOptions, j as SqlMigrationApplyResponse, c as ISQLMigrations } from '../ISQLService-BOgWzHLT.cjs';
4
+ export { S as SQLAction, f as SQLActionType, h as SqlMigration } from '../ISQLService-BOgWzHLT.cjs';
236
5
 
237
6
  /**
238
7
  * SQLService - SQL database service implementation.
@@ -279,6 +48,7 @@ declare class SQLService extends BaseService implements ISQLService {
279
48
  private actionsForSqlBatch;
280
49
  private dedupeActions;
281
50
  private invokeSQLAny;
51
+ private redactFailure;
282
52
  private handleErrorResponse;
283
53
  private mapHttpStatusToErrorCode;
284
54
  }
@@ -308,4 +78,4 @@ declare class SQLMigrations implements ISQLMigrations {
308
78
  apply(options: SqlMigrationApplyOptions): Promise<Result<SqlMigrationApplyResponse>>;
309
79
  }
310
80
 
311
- export { type BatchOptions, type BatchResponse, DatabaseHandle, type ExecuteOptions, type ExecuteResponse, type IDatabaseHandle, type ISQLMigrations, type ISQLService, type QueryOptions, type QueryResponse, SQLAction, type SQLActionType, SQLMigrations, SQLService, type SQLServiceConfig, type SqlMigration, type SqlMigrationApplyOptions, type SqlMigrationApplyResponse, type SqlStatement, type SqlValue };
81
+ export { BatchOptions, BatchResponse, DatabaseHandle, ExecuteOptions, ExecuteResponse, IDatabaseHandle, ISQLMigrations, ISQLService, QueryOptions, QueryResponse, SQLMigrations, SQLService, SQLServiceConfig, SqlMigrationApplyOptions, SqlMigrationApplyResponse, SqlStatement, SqlValue };
@@ -1,238 +1,7 @@
1
- import { B as BaseService } from '../BaseService-DO7vZ67k.js';
2
- import { h as Result, c as IService } from '../types-DAOyIbXu.js';
3
-
4
- /**
5
- * SQL Service Types
6
- *
7
- * Type definitions for the SQL service operations.
8
- */
9
- /**
10
- * Configuration for SQLService.
11
- */
12
- interface SQLServiceConfig {
13
- /**
14
- * Default database name.
15
- * If not set, operations default to "default".
16
- */
17
- defaultDatabase?: string;
18
- /**
19
- * Timeout in milliseconds for each SQL request, including reading the
20
- * response body. When it elapses the request is aborted and the operation
21
- * returns an `ErrorCodes.TIMEOUT` error. Unset (the default), `0`, or
22
- * `Infinity` means no timeout.
23
- */
24
- timeout?: number;
25
- /** Allow additional config properties */
26
- [key: string]: unknown;
27
- }
28
- /**
29
- * Options for SQL query operations.
30
- */
31
- interface QueryOptions {
32
- /**
33
- * Custom abort signal for this operation.
34
- */
35
- signal?: AbortSignal;
36
- /** Maximum rows the node may return. Nodes without limit support ignore it. */
37
- maxRows?: number;
38
- /** Maximum serialized result bytes the node may return. */
39
- maxBytes?: number;
40
- }
41
- /**
42
- * Options for SQL execute operations.
43
- */
44
- interface ExecuteOptions {
45
- /**
46
- * Schema initialization statements (CREATE TABLE IF NOT EXISTS ...).
47
- * Executed before the main statement on first write.
48
- */
49
- schema?: string[];
50
- /**
51
- * Custom abort signal for this operation.
52
- */
53
- signal?: AbortSignal;
54
- }
55
- /**
56
- * Options for SQL batch operations.
57
- */
58
- interface BatchOptions {
59
- /**
60
- * Custom abort signal for this operation.
61
- */
62
- signal?: AbortSignal;
63
- }
64
- /**
65
- * A SQL value: null, number, string, or binary data.
66
- */
67
- type SqlValue = null | number | string | Uint8Array;
68
- /**
69
- * A SQL statement with optional parameters.
70
- */
71
- interface SqlStatement {
72
- sql: string;
73
- params?: SqlValue[];
74
- }
75
- /**
76
- * Response from SQL query operations.
77
- */
78
- interface QueryResponse<T = Record<string, unknown>> {
79
- columns: string[];
80
- rows: T[][];
81
- rowCount: number;
82
- }
83
- /**
84
- * Response from SQL execute operations.
85
- */
86
- interface ExecuteResponse {
87
- changes: number;
88
- lastInsertRowId: number | null;
89
- }
90
- /**
91
- * Response from SQL batch operations.
92
- */
93
- interface BatchResponse {
94
- results: ExecuteResponse[];
95
- }
96
- /**
97
- * A versioned SQL migration owned by an application or SDK subsystem.
98
- */
99
- interface SqlMigration {
100
- /**
101
- * Stable migration id within the namespace, e.g. "001_initial".
102
- */
103
- id: string;
104
- /**
105
- * SQL statements to apply when this migration has not been recorded.
106
- * Statements should be idempotent where SQLite supports it.
107
- */
108
- sql: Array<string | SqlStatement>;
109
- }
110
- /**
111
- * Options for applying SQL migrations.
112
- */
113
- interface SqlMigrationApplyOptions {
114
- /**
115
- * Namespace for this migration set, usually an app id or SDK subsystem.
116
- */
117
- namespace: string;
118
- /**
119
- * Ordered migration list.
120
- */
121
- migrations: SqlMigration[];
122
- /**
123
- * Custom abort signal for migration operations.
124
- */
125
- signal?: AbortSignal;
126
- }
127
- /**
128
- * Result from applying SQL migrations.
129
- */
130
- interface SqlMigrationApplyResponse {
131
- database: string;
132
- namespace: string;
133
- status: "already_current" | "applied";
134
- applied: string[];
135
- skipped: string[];
136
- }
137
- /**
138
- * SQL service action types.
139
- *
140
- * URNs derive from the canonical capability registry in `@tinycloud/bootstrap`
141
- * (TC-112 single source of truth, vendored from tinycloud-node). `insert`,
142
- * `update`, and `delete` were dropped — zero client refs and never accepted
143
- * node-side. `select` is a deprecated alias of `read`. `execute`/`export` are
144
- * request-kind artifacts, not grantable capabilities: the node routes them by
145
- * request-body kind, so they are absent from the registry but kept here as the
146
- * invocation ability the client sends today (wire alignment tracked in TC-114).
147
- */
148
- declare const SQLAction: {
149
- readonly READ: "tinycloud.sql/read";
150
- readonly WRITE: "tinycloud.sql/write";
151
- readonly SCHEMA: "tinycloud.sql/schema";
152
- readonly ADMIN: "tinycloud.sql/admin";
153
- readonly SELECT: "tinycloud.sql/select";
154
- readonly EXECUTE: "tinycloud.sql/execute";
155
- readonly EXPORT: "tinycloud.sql/export";
156
- readonly ALL: "tinycloud.sql/*";
157
- };
158
- type SQLActionType = (typeof SQLAction)[keyof typeof SQLAction];
159
-
160
- /**
161
- * ISQLService - Interface for SQL service.
162
- *
163
- * Platform-agnostic interface for SQL database operations.
164
- */
165
-
166
- /**
167
- * Migration helper bound to a specific database.
168
- */
169
- interface ISQLMigrations {
170
- /**
171
- * Apply ordered, app-owned migrations and record completed ids.
172
- */
173
- apply(options: SqlMigrationApplyOptions): Promise<Result<SqlMigrationApplyResponse>>;
174
- }
175
- /**
176
- * Database handle interface for operations on a specific named database.
177
- */
178
- interface IDatabaseHandle {
179
- /** The database name */
180
- readonly name: string;
181
- /** Versioned schema migration helper. */
182
- readonly migrations: ISQLMigrations;
183
- /**
184
- * Execute a SQL query and return rows.
185
- */
186
- query<T = Record<string, unknown>>(sql: string, params?: SqlValue[], options?: QueryOptions): Promise<Result<QueryResponse<T>>>;
187
- /**
188
- * Execute a SQL statement and return change count.
189
- */
190
- execute(sql: string, params?: SqlValue[], options?: ExecuteOptions): Promise<Result<ExecuteResponse>>;
191
- /**
192
- * Execute multiple statements in a transaction.
193
- */
194
- batch(statements: SqlStatement[], options?: BatchOptions): Promise<Result<BatchResponse>>;
195
- /**
196
- * Execute a named prepared statement from delegation caveats.
197
- */
198
- executeStatement(name: string, params?: SqlValue[], options?: QueryOptions): Promise<Result<QueryResponse | ExecuteResponse>>;
199
- /**
200
- * Export the raw SQLite database file.
201
- */
202
- export(options?: QueryOptions): Promise<Result<Blob>>;
203
- }
204
- /**
205
- * SQL service interface.
206
- *
207
- * Provides SQL database operations with:
208
- * - Result type pattern (no throwing)
209
- * - Named database handles
210
- * - Configurable timeouts
211
- * - Abort signal support
212
- */
213
- interface ISQLService extends IService {
214
- /**
215
- * Get a handle to a named database.
216
- * @param name - Database name (defaults to "default")
217
- */
218
- db(name?: string): IDatabaseHandle;
219
- /**
220
- * Shortcut: query the default database.
221
- */
222
- query<T = Record<string, unknown>>(sql: string, params?: SqlValue[], options?: QueryOptions): Promise<Result<QueryResponse<T>>>;
223
- /**
224
- * Shortcut: execute on the default database.
225
- */
226
- execute(sql: string, params?: SqlValue[], options?: ExecuteOptions): Promise<Result<ExecuteResponse>>;
227
- /**
228
- * Shortcut: batch on the default database.
229
- */
230
- batch(statements: SqlStatement[], options?: BatchOptions): Promise<Result<BatchResponse>>;
231
- /**
232
- * Service configuration.
233
- */
234
- readonly config: SQLServiceConfig;
235
- }
1
+ import { B as BaseService } from '../BaseService-Ma2MwJAd.js';
2
+ import { f as Result } from '../types-CSd0RYir.js';
3
+ import { d as ISQLService, g as SQLServiceConfig, I as IDatabaseHandle, l as SqlValue, Q as QueryOptions, e as QueryResponse, E as ExecuteOptions, b as ExecuteResponse, k as SqlStatement, B as BatchOptions, a as BatchResponse, i as SqlMigrationApplyOptions, j as SqlMigrationApplyResponse, c as ISQLMigrations } from '../ISQLService-Aly1CBsW.js';
4
+ export { S as SQLAction, f as SQLActionType, h as SqlMigration } from '../ISQLService-Aly1CBsW.js';
236
5
 
237
6
  /**
238
7
  * SQLService - SQL database service implementation.
@@ -279,6 +48,7 @@ declare class SQLService extends BaseService implements ISQLService {
279
48
  private actionsForSqlBatch;
280
49
  private dedupeActions;
281
50
  private invokeSQLAny;
51
+ private redactFailure;
282
52
  private handleErrorResponse;
283
53
  private mapHttpStatusToErrorCode;
284
54
  }
@@ -308,4 +78,4 @@ declare class SQLMigrations implements ISQLMigrations {
308
78
  apply(options: SqlMigrationApplyOptions): Promise<Result<SqlMigrationApplyResponse>>;
309
79
  }
310
80
 
311
- export { type BatchOptions, type BatchResponse, DatabaseHandle, type ExecuteOptions, type ExecuteResponse, type IDatabaseHandle, type ISQLMigrations, type ISQLService, type QueryOptions, type QueryResponse, SQLAction, type SQLActionType, SQLMigrations, SQLService, type SQLServiceConfig, type SqlMigration, type SqlMigrationApplyOptions, type SqlMigrationApplyResponse, type SqlStatement, type SqlValue };
81
+ export { BatchOptions, BatchResponse, DatabaseHandle, ExecuteOptions, ExecuteResponse, IDatabaseHandle, ISQLMigrations, ISQLService, QueryOptions, QueryResponse, SQLMigrations, SQLService, SQLServiceConfig, SqlMigrationApplyOptions, SqlMigrationApplyResponse, SqlStatement, SqlValue };
package/dist/sql/index.js CHANGED
@@ -741,12 +741,13 @@ var SQLService = class extends BaseService {
741
741
  request.signal
742
742
  );
743
743
  if (!response.ok) {
744
- return await this.handleErrorResponse(response, "query", dbName, [action]);
744
+ const failure = await this.handleErrorResponse(response, "query", dbName, [action]);
745
+ return this.redactFailure(failure, options?.redactErrors, response.status);
745
746
  }
746
747
  const data = await response.json();
747
748
  return ok(data);
748
749
  } catch (error) {
749
- return err(wrapError("sql", error));
750
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
750
751
  } finally {
751
752
  request.dispose();
752
753
  }
@@ -781,12 +782,13 @@ var SQLService = class extends BaseService {
781
782
  request.signal
782
783
  );
783
784
  if (!response.ok) {
784
- return await this.handleErrorResponse(response, "execute", dbName, requestedActions);
785
+ const failure = await this.handleErrorResponse(response, "execute", dbName, requestedActions);
786
+ return this.redactFailure(failure, options?.redactErrors, response.status);
785
787
  }
786
788
  const data = await response.json();
787
789
  return ok(data);
788
790
  } catch (error) {
789
- return err(wrapError("sql", error));
791
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
790
792
  } finally {
791
793
  request.dispose();
792
794
  }
@@ -807,12 +809,13 @@ var SQLService = class extends BaseService {
807
809
  request.signal
808
810
  );
809
811
  if (!response.ok) {
810
- return await this.handleErrorResponse(response, "batch", dbName, requestedActions);
812
+ const failure = await this.handleErrorResponse(response, "batch", dbName, requestedActions);
813
+ return this.redactFailure(failure, options?.redactErrors, response.status);
811
814
  }
812
815
  const data = await response.json();
813
816
  return ok(data);
814
817
  } catch (error) {
815
- return err(wrapError("sql", error));
818
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
816
819
  } finally {
817
820
  request.dispose();
818
821
  }
@@ -1008,6 +1011,18 @@ var SQLService = class extends BaseService {
1008
1011
  }))
1009
1012
  );
1010
1013
  }
1014
+ redactFailure(result, redactErrors, status) {
1015
+ if (!redactErrors || result.ok) return result;
1016
+ const candidate = result.error.code;
1017
+ const code = typeof candidate === "string" && Object.prototype.hasOwnProperty.call(ErrorCodes, candidate) ? candidate : ErrorCodes.SQL_ERROR;
1018
+ const safeStatus = typeof status === "number" && Number.isInteger(status) && status >= 400 && status <= 599 ? status : void 0;
1019
+ return err(serviceError(
1020
+ code,
1021
+ "SQL operation failed",
1022
+ "sql",
1023
+ safeStatus === void 0 ? void 0 : { meta: { status: safeStatus } }
1024
+ ));
1025
+ }
1011
1026
  async handleErrorResponse(response, operation, dbName, requestedActions) {
1012
1027
  const errorText = await response.text();
1013
1028
  const meta = responseErrorMeta(response.status, response.statusText, errorText);