@cipherstash/stack 0.2.0 → 0.4.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 (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -3
  3. package/dist/bin/stash.js +109 -186
  4. package/dist/bin/stash.js.map +1 -1
  5. package/dist/{chunk-SUYMGQBY.js → chunk-4RNBI3UH.js} +1 -7
  6. package/dist/chunk-4RNBI3UH.js.map +1 -0
  7. package/dist/{chunk-5G4F4JJG.js → chunk-KOU2MHXJ.js} +1 -1
  8. package/dist/chunk-KOU2MHXJ.js.map +1 -0
  9. package/dist/{chunk-5DCT6YU2.js → chunk-OAPLZLR5.js} +7 -3
  10. package/dist/{chunk-5DCT6YU2.js.map → chunk-OAPLZLR5.js.map} +1 -1
  11. package/dist/{chunk-LHZ6KZIG.js → chunk-WUZGKTMG.js} +84 -162
  12. package/dist/chunk-WUZGKTMG.js.map +1 -0
  13. package/dist/{chunk-7XRPN2KX.js → chunk-Y35W4WFN.js} +31 -28
  14. package/dist/chunk-Y35W4WFN.js.map +1 -0
  15. package/dist/{client-D-ZH8SB2.d.cts → client-CUGXheRq.d.cts} +33 -31
  16. package/dist/{client-BV9pXC-d.d.ts → client-CrGQnSlk.d.ts} +33 -31
  17. package/dist/client.cjs +30 -27
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.d.cts +2 -2
  20. package/dist/client.d.ts +2 -2
  21. package/dist/client.js +5 -5
  22. package/dist/drizzle/index.cjs +24 -21
  23. package/dist/drizzle/index.cjs.map +1 -1
  24. package/dist/drizzle/index.d.cts +5 -5
  25. package/dist/drizzle/index.d.ts +5 -5
  26. package/dist/drizzle/index.js +2 -2
  27. package/dist/drizzle/index.js.map +1 -1
  28. package/dist/dynamodb/index.cjs.map +1 -1
  29. package/dist/dynamodb/index.d.cts +10 -10
  30. package/dist/dynamodb/index.d.ts +10 -10
  31. package/dist/dynamodb/index.js.map +1 -1
  32. package/dist/identity/index.cjs +6 -2
  33. package/dist/identity/index.cjs.map +1 -1
  34. package/dist/identity/index.js +1 -1
  35. package/dist/index.cjs +113 -190
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +3 -3
  38. package/dist/index.d.ts +3 -3
  39. package/dist/index.js +8 -8
  40. package/dist/schema/index.cjs +36 -33
  41. package/dist/schema/index.cjs.map +1 -1
  42. package/dist/schema/index.d.cts +1 -1
  43. package/dist/schema/index.d.ts +1 -1
  44. package/dist/schema/index.js +11 -11
  45. package/dist/secrets/index.cjs +109 -186
  46. package/dist/secrets/index.cjs.map +1 -1
  47. package/dist/secrets/index.d.cts +1 -1
  48. package/dist/secrets/index.d.ts +1 -1
  49. package/dist/secrets/index.js +5 -5
  50. package/dist/secrets/index.js.map +1 -1
  51. package/dist/supabase/index.cjs +9 -9
  52. package/dist/supabase/index.cjs.map +1 -1
  53. package/dist/supabase/index.d.cts +3 -3
  54. package/dist/supabase/index.d.ts +3 -3
  55. package/dist/supabase/index.js +4 -4
  56. package/dist/supabase/index.js.map +1 -1
  57. package/dist/{types-public-Dfg-hkuQ.d.cts → types-public-Wj6tB_ux.d.cts} +115 -76
  58. package/dist/{types-public-Dfg-hkuQ.d.ts → types-public-Wj6tB_ux.d.ts} +115 -76
  59. package/dist/types-public.cjs.map +1 -1
  60. package/dist/types-public.d.cts +1 -1
  61. package/dist/types-public.d.ts +1 -1
  62. package/dist/types-public.js +1 -1
  63. package/package.json +2 -2
  64. package/dist/chunk-5G4F4JJG.js.map +0 -1
  65. package/dist/chunk-7XRPN2KX.js.map +0 -1
  66. package/dist/chunk-LHZ6KZIG.js.map +0 -1
  67. package/dist/chunk-SUYMGQBY.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { k as EncryptedQueryResult, l as Client, S as ScalarQueryTerm, B as BulkDecryptedData, m as BulkDecryptPayload, D as Decrypted, n as BulkEncryptedData, o as BulkEncryptPayload, p as EncryptOptions, P as ProtectColumn, g as ProtectValue, d as ProtectTable, f as ProtectTableColumn, i as Encrypted, q as EncryptQueryOptions, Q as QueryTypeName, r as EncryptedReturnType, s as EncryptConfig, K as KeysetIdentifier, h as EncryptedFromSchema } from './types-public-Dfg-hkuQ.cjs';
1
+ import { l as EncryptedQueryResult, m as Client, S as ScalarQueryTerm, B as BulkDecryptedData, n as BulkDecryptPayload, D as Decrypted, o as BulkEncryptedData, p as BulkEncryptPayload, q as EncryptOptions, d as EncryptedColumn, h as EncryptedField, f as EncryptedTable, g as EncryptedTableColumn, j as Encrypted, r as EncryptQueryOptions, Q as QueryTypeName, s as EncryptedReturnType, t as EncryptConfig, K as KeysetIdentifier, i as EncryptedFromSchema } from './types-public-Wj6tB_ux.cjs';
2
2
  import { a as EncryptionError, d as LockContext } from './index-9-Ya3fDK.cjs';
3
3
  import { Result } from '@byteslice/result';
4
4
  import { JsPlaintext } from '@cipherstash/protect-ffi';
@@ -99,8 +99,8 @@ declare class BulkEncryptOperation extends EncryptionOperation<BulkEncryptedData
99
99
  getOperation(): {
100
100
  client: Client;
101
101
  plaintexts: BulkEncryptPayload;
102
- column: ProtectColumn | ProtectValue;
103
- table: ProtectTable<ProtectTableColumn>;
102
+ column: EncryptedColumn | EncryptedField;
103
+ table: EncryptedTable<EncryptedTableColumn>;
104
104
  };
105
105
  }
106
106
  declare class BulkEncryptOperationWithLockContext extends EncryptionOperation<BulkEncryptedData> {
@@ -114,13 +114,13 @@ declare class BulkEncryptModelsOperation<T extends Record<string, unknown>> exte
114
114
  private client;
115
115
  private models;
116
116
  private table;
117
- constructor(client: Client, models: Record<string, unknown>[], table: ProtectTable<ProtectTableColumn>);
117
+ constructor(client: Client, models: Record<string, unknown>[], table: EncryptedTable<EncryptedTableColumn>);
118
118
  withLockContext(lockContext: LockContext): BulkEncryptModelsOperationWithLockContext<T>;
119
119
  execute(): Promise<Result<T[], EncryptionError>>;
120
120
  getOperation(): {
121
121
  client: Client;
122
122
  models: Record<string, unknown>[];
123
- table: ProtectTable<ProtectTableColumn>;
123
+ table: EncryptedTable<EncryptedTableColumn>;
124
124
  };
125
125
  }
126
126
  declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T[]> {
@@ -134,23 +134,23 @@ declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string,
134
134
  * Decrypts an encrypted payload using the provided client.
135
135
  * This is the type returned by the {@link EncryptionClient.decrypt | decrypt} method of the {@link EncryptionClient}.
136
136
  */
137
- declare class DecryptOperation extends EncryptionOperation<JsPlaintext | null> {
137
+ declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
138
138
  private client;
139
139
  private encryptedData;
140
140
  constructor(client: Client, encryptedData: Encrypted);
141
141
  withLockContext(lockContext: LockContext): DecryptOperationWithLockContext;
142
- execute(): Promise<Result<JsPlaintext | null, EncryptionError>>;
142
+ execute(): Promise<Result<JsPlaintext, EncryptionError>>;
143
143
  getOperation(): {
144
144
  client: Client;
145
145
  encryptedData: Encrypted;
146
146
  auditData?: Record<string, unknown>;
147
147
  };
148
148
  }
149
- declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext | null> {
149
+ declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext> {
150
150
  private operation;
151
151
  private lockContext;
152
152
  constructor(operation: DecryptOperation, lockContext: LockContext);
153
- execute(): Promise<Result<JsPlaintext | null, EncryptionError>>;
153
+ execute(): Promise<Result<JsPlaintext, EncryptionError>>;
154
154
  }
155
155
 
156
156
  declare class DecryptModelOperation<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>> {
@@ -176,14 +176,14 @@ declare class EncryptOperation extends EncryptionOperation<Encrypted> {
176
176
  private plaintext;
177
177
  private column;
178
178
  private table;
179
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptOptions);
179
+ constructor(client: Client, plaintext: JsPlaintext, opts: EncryptOptions);
180
180
  withLockContext(lockContext: LockContext): EncryptOperationWithLockContext;
181
181
  execute(): Promise<Result<Encrypted, EncryptionError>>;
182
182
  getOperation(): {
183
183
  client: Client;
184
- plaintext: JsPlaintext | null;
185
- column: ProtectColumn | ProtectValue;
186
- table: ProtectTable<ProtectTableColumn>;
184
+ plaintext: JsPlaintext;
185
+ column: EncryptedColumn | EncryptedField;
186
+ table: EncryptedTable<EncryptedTableColumn>;
187
187
  };
188
188
  }
189
189
  declare class EncryptOperationWithLockContext extends EncryptionOperation<Encrypted> {
@@ -197,13 +197,13 @@ declare class EncryptModelOperation<T extends Record<string, unknown>> extends E
197
197
  private client;
198
198
  private model;
199
199
  private table;
200
- constructor(client: Client, model: Record<string, unknown>, table: ProtectTable<ProtectTableColumn>);
200
+ constructor(client: Client, model: Record<string, unknown>, table: EncryptedTable<EncryptedTableColumn>);
201
201
  withLockContext(lockContext: LockContext): EncryptModelOperationWithLockContext<T>;
202
202
  execute(): Promise<Result<T, EncryptionError>>;
203
203
  getOperation(): {
204
204
  client: Client;
205
205
  model: Record<string, unknown>;
206
- table: ProtectTable<ProtectTableColumn>;
206
+ table: EncryptedTable<EncryptedTableColumn>;
207
207
  };
208
208
  }
209
209
  declare class EncryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T> {
@@ -220,16 +220,16 @@ declare class EncryptQueryOperation extends EncryptionOperation<EncryptedQueryRe
220
220
  private client;
221
221
  private plaintext;
222
222
  private opts;
223
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptQueryOptions);
223
+ constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions);
224
224
  withLockContext(lockContext: LockContext): EncryptQueryOperationWithLockContext;
225
225
  execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
226
226
  getOperation(): {
227
- column: ProtectColumn;
228
- table: ProtectTable<ProtectTableColumn>;
227
+ column: EncryptedColumn;
228
+ table: EncryptedTable<EncryptedTableColumn>;
229
229
  queryType?: QueryTypeName;
230
230
  returnType?: EncryptedReturnType;
231
231
  client: Client;
232
- plaintext: JsPlaintext | null;
232
+ plaintext: JsPlaintext;
233
233
  };
234
234
  }
235
235
  /**
@@ -240,11 +240,11 @@ declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<E
240
240
  private plaintext;
241
241
  private opts;
242
242
  private lockContext;
243
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
243
+ constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
244
244
  execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
245
245
  }
246
246
 
247
- /** The EncryptionClient is the main entry point for interacting with the CipherStash Protect.js library.
247
+ /** The EncryptionClient is the main entry point for interacting with the CipherStash Encryption library.
248
248
  * It provides methods for encrypting and decrypting individual values, as well as models (objects) and bulk operations.
249
249
  *
250
250
  * The client must be initialized using the {@link Encryption} function before it can be used.
@@ -271,8 +271,8 @@ declare class EncryptionClient {
271
271
  /**
272
272
  * Encrypt a value - returns a promise which resolves to an encrypted value.
273
273
  *
274
- * @param plaintext - The plaintext value to be encrypted. Can be null.
275
- * @param opts - Options specifying the column and table for encryption.
274
+ * @param plaintext - The plaintext value to be encrypted.
275
+ * @param opts - Options specifying the column (or nested field) and table for encryption. See {@link EncryptOptions}.
276
276
  * @returns An EncryptOperation that can be awaited or chained with additional methods.
277
277
  *
278
278
  * @example
@@ -335,16 +335,19 @@ declare class EncryptionClient {
335
335
  * .withLockContext(lockContext)
336
336
  * ```
337
337
  *
338
+ * @see {@link EncryptOptions}
338
339
  * @see {@link Result}
339
340
  * @see {@link encryptedTable}
341
+ * @see {@link encryptedColumn}
342
+ * @see {@link encryptedField}
340
343
  * @see {@link LockContext}
341
344
  * @see {@link EncryptOperation}
342
345
  */
343
- encrypt(plaintext: JsPlaintext | null, opts: EncryptOptions): EncryptOperation;
346
+ encrypt(plaintext: JsPlaintext, opts: EncryptOptions): EncryptOperation;
344
347
  /**
345
348
  * Encrypt a query value - returns a promise which resolves to an encrypted query value.
346
349
  *
347
- * @param plaintext - The plaintext value to be encrypted for querying. Can be null.
350
+ * @param plaintext - The plaintext value to be encrypted for querying.
348
351
  * @param opts - Options specifying the column, table, and optional queryType for encryption.
349
352
  * @returns An EncryptQueryOperation that can be awaited or chained with additional methods.
350
353
  *
@@ -394,7 +397,7 @@ declare class EncryptionClient {
394
397
  * - String plaintext → `steVecSelector` (JSONPath queries like `'$.user.email'`)
395
398
  * - Object/Array plaintext → `steVecTerm` (containment queries like `{ role: 'admin' }`)
396
399
  */
397
- encryptQuery(plaintext: JsPlaintext | null, opts: EncryptQueryOptions): EncryptQueryOperation;
400
+ encryptQuery(plaintext: JsPlaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
398
401
  /**
399
402
  * Encrypt multiple values for use in queries (batch operation).
400
403
  * @param terms - Array of query terms to encrypt
@@ -479,7 +482,7 @@ declare class EncryptionClient {
479
482
  * }
480
483
  * ```
481
484
  */
482
- encryptModel<T extends Record<string, unknown>, S extends ProtectTableColumn = ProtectTableColumn>(input: T, table: ProtectTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
485
+ encryptModel<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: T, table: EncryptedTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
483
486
  /**
484
487
  * Decrypt a model (object) whose fields contain encrypted values.
485
488
  *
@@ -554,7 +557,7 @@ declare class EncryptionClient {
554
557
  * }
555
558
  * ```
556
559
  */
557
- bulkEncryptModels<T extends Record<string, unknown>, S extends ProtectTableColumn = ProtectTableColumn>(input: Array<T>, table: ProtectTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
560
+ bulkEncryptModels<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: Array<T>, table: EncryptedTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
558
561
  /**
559
562
  * Decrypt multiple models (objects) in a single bulk operation.
560
563
  *
@@ -589,10 +592,10 @@ declare class EncryptionClient {
589
592
  *
590
593
  * Each value is encrypted with its own unique key via a single call to ZeroKMS.
591
594
  * Values can include optional `id` fields for correlating results back to
592
- * your application data. Null plaintext values are preserved as null.
595
+ * your application data.
593
596
  *
594
597
  * @param plaintexts - An array of objects with `plaintext` (and optional `id`) fields.
595
- * @param opts - Options specifying the target column and table for encryption.
598
+ * @param opts - Options specifying the target column (or nested {@link encryptedField}) and table. See {@link EncryptOptions}.
596
599
  * @returns A `BulkEncryptOperation` that can be awaited to get a `Result`
597
600
  * containing an array of `{ id?, data: Encrypted }` objects, or an `EncryptionError`.
598
601
  *
@@ -610,7 +613,6 @@ declare class EncryptionClient {
610
613
  * [
611
614
  * { id: "u1", plaintext: "alice@example.com" },
612
615
  * { id: "u2", plaintext: "bob@example.com" },
613
- * { id: "u3", plaintext: null },
614
616
  * ],
615
617
  * { column: users.email, table: users },
616
618
  * )
@@ -1,4 +1,4 @@
1
- import { k as EncryptedQueryResult, l as Client, S as ScalarQueryTerm, B as BulkDecryptedData, m as BulkDecryptPayload, D as Decrypted, n as BulkEncryptedData, o as BulkEncryptPayload, p as EncryptOptions, P as ProtectColumn, g as ProtectValue, d as ProtectTable, f as ProtectTableColumn, i as Encrypted, q as EncryptQueryOptions, Q as QueryTypeName, r as EncryptedReturnType, s as EncryptConfig, K as KeysetIdentifier, h as EncryptedFromSchema } from './types-public-Dfg-hkuQ.js';
1
+ import { l as EncryptedQueryResult, m as Client, S as ScalarQueryTerm, B as BulkDecryptedData, n as BulkDecryptPayload, D as Decrypted, o as BulkEncryptedData, p as BulkEncryptPayload, q as EncryptOptions, d as EncryptedColumn, h as EncryptedField, f as EncryptedTable, g as EncryptedTableColumn, j as Encrypted, r as EncryptQueryOptions, Q as QueryTypeName, s as EncryptedReturnType, t as EncryptConfig, K as KeysetIdentifier, i as EncryptedFromSchema } from './types-public-Wj6tB_ux.js';
2
2
  import { a as EncryptionError, d as LockContext } from './index-9-Ya3fDK.js';
3
3
  import { Result } from '@byteslice/result';
4
4
  import { JsPlaintext } from '@cipherstash/protect-ffi';
@@ -99,8 +99,8 @@ declare class BulkEncryptOperation extends EncryptionOperation<BulkEncryptedData
99
99
  getOperation(): {
100
100
  client: Client;
101
101
  plaintexts: BulkEncryptPayload;
102
- column: ProtectColumn | ProtectValue;
103
- table: ProtectTable<ProtectTableColumn>;
102
+ column: EncryptedColumn | EncryptedField;
103
+ table: EncryptedTable<EncryptedTableColumn>;
104
104
  };
105
105
  }
106
106
  declare class BulkEncryptOperationWithLockContext extends EncryptionOperation<BulkEncryptedData> {
@@ -114,13 +114,13 @@ declare class BulkEncryptModelsOperation<T extends Record<string, unknown>> exte
114
114
  private client;
115
115
  private models;
116
116
  private table;
117
- constructor(client: Client, models: Record<string, unknown>[], table: ProtectTable<ProtectTableColumn>);
117
+ constructor(client: Client, models: Record<string, unknown>[], table: EncryptedTable<EncryptedTableColumn>);
118
118
  withLockContext(lockContext: LockContext): BulkEncryptModelsOperationWithLockContext<T>;
119
119
  execute(): Promise<Result<T[], EncryptionError>>;
120
120
  getOperation(): {
121
121
  client: Client;
122
122
  models: Record<string, unknown>[];
123
- table: ProtectTable<ProtectTableColumn>;
123
+ table: EncryptedTable<EncryptedTableColumn>;
124
124
  };
125
125
  }
126
126
  declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T[]> {
@@ -134,23 +134,23 @@ declare class BulkEncryptModelsOperationWithLockContext<T extends Record<string,
134
134
  * Decrypts an encrypted payload using the provided client.
135
135
  * This is the type returned by the {@link EncryptionClient.decrypt | decrypt} method of the {@link EncryptionClient}.
136
136
  */
137
- declare class DecryptOperation extends EncryptionOperation<JsPlaintext | null> {
137
+ declare class DecryptOperation extends EncryptionOperation<JsPlaintext> {
138
138
  private client;
139
139
  private encryptedData;
140
140
  constructor(client: Client, encryptedData: Encrypted);
141
141
  withLockContext(lockContext: LockContext): DecryptOperationWithLockContext;
142
- execute(): Promise<Result<JsPlaintext | null, EncryptionError>>;
142
+ execute(): Promise<Result<JsPlaintext, EncryptionError>>;
143
143
  getOperation(): {
144
144
  client: Client;
145
145
  encryptedData: Encrypted;
146
146
  auditData?: Record<string, unknown>;
147
147
  };
148
148
  }
149
- declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext | null> {
149
+ declare class DecryptOperationWithLockContext extends EncryptionOperation<JsPlaintext> {
150
150
  private operation;
151
151
  private lockContext;
152
152
  constructor(operation: DecryptOperation, lockContext: LockContext);
153
- execute(): Promise<Result<JsPlaintext | null, EncryptionError>>;
153
+ execute(): Promise<Result<JsPlaintext, EncryptionError>>;
154
154
  }
155
155
 
156
156
  declare class DecryptModelOperation<T extends Record<string, unknown>> extends EncryptionOperation<Decrypted<T>> {
@@ -176,14 +176,14 @@ declare class EncryptOperation extends EncryptionOperation<Encrypted> {
176
176
  private plaintext;
177
177
  private column;
178
178
  private table;
179
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptOptions);
179
+ constructor(client: Client, plaintext: JsPlaintext, opts: EncryptOptions);
180
180
  withLockContext(lockContext: LockContext): EncryptOperationWithLockContext;
181
181
  execute(): Promise<Result<Encrypted, EncryptionError>>;
182
182
  getOperation(): {
183
183
  client: Client;
184
- plaintext: JsPlaintext | null;
185
- column: ProtectColumn | ProtectValue;
186
- table: ProtectTable<ProtectTableColumn>;
184
+ plaintext: JsPlaintext;
185
+ column: EncryptedColumn | EncryptedField;
186
+ table: EncryptedTable<EncryptedTableColumn>;
187
187
  };
188
188
  }
189
189
  declare class EncryptOperationWithLockContext extends EncryptionOperation<Encrypted> {
@@ -197,13 +197,13 @@ declare class EncryptModelOperation<T extends Record<string, unknown>> extends E
197
197
  private client;
198
198
  private model;
199
199
  private table;
200
- constructor(client: Client, model: Record<string, unknown>, table: ProtectTable<ProtectTableColumn>);
200
+ constructor(client: Client, model: Record<string, unknown>, table: EncryptedTable<EncryptedTableColumn>);
201
201
  withLockContext(lockContext: LockContext): EncryptModelOperationWithLockContext<T>;
202
202
  execute(): Promise<Result<T, EncryptionError>>;
203
203
  getOperation(): {
204
204
  client: Client;
205
205
  model: Record<string, unknown>;
206
- table: ProtectTable<ProtectTableColumn>;
206
+ table: EncryptedTable<EncryptedTableColumn>;
207
207
  };
208
208
  }
209
209
  declare class EncryptModelOperationWithLockContext<T extends Record<string, unknown>> extends EncryptionOperation<T> {
@@ -220,16 +220,16 @@ declare class EncryptQueryOperation extends EncryptionOperation<EncryptedQueryRe
220
220
  private client;
221
221
  private plaintext;
222
222
  private opts;
223
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptQueryOptions);
223
+ constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions);
224
224
  withLockContext(lockContext: LockContext): EncryptQueryOperationWithLockContext;
225
225
  execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
226
226
  getOperation(): {
227
- column: ProtectColumn;
228
- table: ProtectTable<ProtectTableColumn>;
227
+ column: EncryptedColumn;
228
+ table: EncryptedTable<EncryptedTableColumn>;
229
229
  queryType?: QueryTypeName;
230
230
  returnType?: EncryptedReturnType;
231
231
  client: Client;
232
- plaintext: JsPlaintext | null;
232
+ plaintext: JsPlaintext;
233
233
  };
234
234
  }
235
235
  /**
@@ -240,11 +240,11 @@ declare class EncryptQueryOperationWithLockContext extends EncryptionOperation<E
240
240
  private plaintext;
241
241
  private opts;
242
242
  private lockContext;
243
- constructor(client: Client, plaintext: JsPlaintext | null, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
243
+ constructor(client: Client, plaintext: JsPlaintext, opts: EncryptQueryOptions, lockContext: LockContext, auditMetadata?: Record<string, unknown>);
244
244
  execute(): Promise<Result<EncryptedQueryResult, EncryptionError>>;
245
245
  }
246
246
 
247
- /** The EncryptionClient is the main entry point for interacting with the CipherStash Protect.js library.
247
+ /** The EncryptionClient is the main entry point for interacting with the CipherStash Encryption library.
248
248
  * It provides methods for encrypting and decrypting individual values, as well as models (objects) and bulk operations.
249
249
  *
250
250
  * The client must be initialized using the {@link Encryption} function before it can be used.
@@ -271,8 +271,8 @@ declare class EncryptionClient {
271
271
  /**
272
272
  * Encrypt a value - returns a promise which resolves to an encrypted value.
273
273
  *
274
- * @param plaintext - The plaintext value to be encrypted. Can be null.
275
- * @param opts - Options specifying the column and table for encryption.
274
+ * @param plaintext - The plaintext value to be encrypted.
275
+ * @param opts - Options specifying the column (or nested field) and table for encryption. See {@link EncryptOptions}.
276
276
  * @returns An EncryptOperation that can be awaited or chained with additional methods.
277
277
  *
278
278
  * @example
@@ -335,16 +335,19 @@ declare class EncryptionClient {
335
335
  * .withLockContext(lockContext)
336
336
  * ```
337
337
  *
338
+ * @see {@link EncryptOptions}
338
339
  * @see {@link Result}
339
340
  * @see {@link encryptedTable}
341
+ * @see {@link encryptedColumn}
342
+ * @see {@link encryptedField}
340
343
  * @see {@link LockContext}
341
344
  * @see {@link EncryptOperation}
342
345
  */
343
- encrypt(plaintext: JsPlaintext | null, opts: EncryptOptions): EncryptOperation;
346
+ encrypt(plaintext: JsPlaintext, opts: EncryptOptions): EncryptOperation;
344
347
  /**
345
348
  * Encrypt a query value - returns a promise which resolves to an encrypted query value.
346
349
  *
347
- * @param plaintext - The plaintext value to be encrypted for querying. Can be null.
350
+ * @param plaintext - The plaintext value to be encrypted for querying.
348
351
  * @param opts - Options specifying the column, table, and optional queryType for encryption.
349
352
  * @returns An EncryptQueryOperation that can be awaited or chained with additional methods.
350
353
  *
@@ -394,7 +397,7 @@ declare class EncryptionClient {
394
397
  * - String plaintext → `steVecSelector` (JSONPath queries like `'$.user.email'`)
395
398
  * - Object/Array plaintext → `steVecTerm` (containment queries like `{ role: 'admin' }`)
396
399
  */
397
- encryptQuery(plaintext: JsPlaintext | null, opts: EncryptQueryOptions): EncryptQueryOperation;
400
+ encryptQuery(plaintext: JsPlaintext, opts: EncryptQueryOptions): EncryptQueryOperation;
398
401
  /**
399
402
  * Encrypt multiple values for use in queries (batch operation).
400
403
  * @param terms - Array of query terms to encrypt
@@ -479,7 +482,7 @@ declare class EncryptionClient {
479
482
  * }
480
483
  * ```
481
484
  */
482
- encryptModel<T extends Record<string, unknown>, S extends ProtectTableColumn = ProtectTableColumn>(input: T, table: ProtectTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
485
+ encryptModel<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: T, table: EncryptedTable<S>): EncryptModelOperation<EncryptedFromSchema<T, S>>;
483
486
  /**
484
487
  * Decrypt a model (object) whose fields contain encrypted values.
485
488
  *
@@ -554,7 +557,7 @@ declare class EncryptionClient {
554
557
  * }
555
558
  * ```
556
559
  */
557
- bulkEncryptModels<T extends Record<string, unknown>, S extends ProtectTableColumn = ProtectTableColumn>(input: Array<T>, table: ProtectTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
560
+ bulkEncryptModels<T extends Record<string, unknown>, S extends EncryptedTableColumn = EncryptedTableColumn>(input: Array<T>, table: EncryptedTable<S>): BulkEncryptModelsOperation<EncryptedFromSchema<T, S>>;
558
561
  /**
559
562
  * Decrypt multiple models (objects) in a single bulk operation.
560
563
  *
@@ -589,10 +592,10 @@ declare class EncryptionClient {
589
592
  *
590
593
  * Each value is encrypted with its own unique key via a single call to ZeroKMS.
591
594
  * Values can include optional `id` fields for correlating results back to
592
- * your application data. Null plaintext values are preserved as null.
595
+ * your application data.
593
596
  *
594
597
  * @param plaintexts - An array of objects with `plaintext` (and optional `id`) fields.
595
- * @param opts - Options specifying the target column and table for encryption.
598
+ * @param opts - Options specifying the target column (or nested {@link encryptedField}) and table. See {@link EncryptOptions}.
596
599
  * @returns A `BulkEncryptOperation` that can be awaited to get a `Result`
597
600
  * containing an array of `{ id?, data: Encrypted }` objects, or an `EncryptionError`.
598
601
  *
@@ -610,7 +613,6 @@ declare class EncryptionClient {
610
613
  * [
611
614
  * { id: "u1", plaintext: "alice@example.com" },
612
615
  * { id: "u2", plaintext: "bob@example.com" },
613
- * { id: "u3", plaintext: null },
614
616
  * ],
615
617
  * { column: users.email, table: users },
616
618
  * )
package/dist/client.cjs CHANGED
@@ -21,14 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var client_exports = {};
22
22
  __export(client_exports, {
23
23
  encryptedColumn: () => encryptedColumn,
24
- encryptedTable: () => encryptedTable,
25
- encryptedValue: () => encryptedValue
24
+ encryptedField: () => encryptedField,
25
+ encryptedTable: () => encryptedTable
26
26
  });
27
27
  module.exports = __toCommonJS(client_exports);
28
28
 
29
29
  // src/schema/index.ts
30
30
  var import_zod = require("zod");
31
- var castAsEnum = import_zod.z.enum(["bigint", "boolean", "date", "number", "string", "json"]).default("string");
31
+ var castAsEnum = import_zod.z.enum(["bigint", "boolean", "date", "number", "string", "json", "text"]).default("text");
32
32
  var tokenFilterSchema = import_zod.z.object({
33
33
  kind: import_zod.z.literal("downcase")
34
34
  });
@@ -71,28 +71,28 @@ var encryptConfigSchema = import_zod.z.object({
71
71
  v: import_zod.z.number(),
72
72
  tables: tablesSchema
73
73
  });
74
- var ProtectValue = class {
74
+ var EncryptedField = class {
75
75
  valueName;
76
76
  castAsValue;
77
77
  constructor(valueName) {
78
78
  this.valueName = valueName;
79
- this.castAsValue = "string";
79
+ this.castAsValue = "text";
80
80
  }
81
81
  /**
82
- * Set or override the plaintext data type for this value.
82
+ * Set or override the plaintext data type for this field.
83
83
  *
84
84
  * By default all values are treated as `'string'`. Use this method to specify
85
85
  * a different type so the encryption layer knows how to encode the plaintext
86
86
  * before encrypting.
87
87
  *
88
- * @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
89
- * @returns This `ProtectValue` instance for method chaining.
88
+ * @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'text'`, `'bigint'`, or `'json'`.
89
+ * @returns This `EncryptedField` instance for method chaining.
90
90
  *
91
91
  * @example
92
92
  * ```typescript
93
- * import { encryptedValue } from "@cipherstash/stack/schema"
93
+ * import { encryptedField } from "@cipherstash/stack/schema"
94
94
  *
95
- * const age = encryptedValue("age").dataType("number")
95
+ * const age = encryptedField("age").dataType("number")
96
96
  * ```
97
97
  */
98
98
  dataType(castAs) {
@@ -101,7 +101,7 @@ var ProtectValue = class {
101
101
  }
102
102
  build() {
103
103
  return {
104
- cast_as: this.castAsValue,
104
+ cast_as: this.castAsValue === "string" ? "text" : this.castAsValue,
105
105
  indexes: {}
106
106
  };
107
107
  }
@@ -109,7 +109,7 @@ var ProtectValue = class {
109
109
  return this.valueName;
110
110
  }
111
111
  };
112
- var ProtectColumn = class {
112
+ var EncryptedColumn = class {
113
113
  columnName;
114
114
  castAsValue;
115
115
  indexesValue = {};
@@ -125,7 +125,7 @@ var ProtectColumn = class {
125
125
  * before encrypting.
126
126
  *
127
127
  * @param castAs - The plaintext data type: `'string'`, `'number'`, `'boolean'`, `'date'`, `'bigint'`, or `'json'`.
128
- * @returns This `ProtectColumn` instance for method chaining.
128
+ * @returns This `EncryptedColumn` instance for method chaining.
129
129
  *
130
130
  * @example
131
131
  * ```typescript
@@ -144,7 +144,7 @@ var ProtectColumn = class {
144
144
  * ORE allows sorting, comparison, and range queries on encrypted data.
145
145
  * Use with `encryptQuery` and `queryType: 'orderAndRange'`.
146
146
  *
147
- * @returns This `ProtectColumn` instance for method chaining.
147
+ * @returns This `EncryptedColumn` instance for method chaining.
148
148
  *
149
149
  * @example
150
150
  * ```typescript
@@ -167,7 +167,7 @@ var ProtectColumn = class {
167
167
  *
168
168
  * @param tokenFilters - Optional array of token filters (e.g. `[{ kind: 'downcase' }]`).
169
169
  * When omitted, no token filters are applied.
170
- * @returns This `ProtectColumn` instance for method chaining.
170
+ * @returns This `EncryptedColumn` instance for method chaining.
171
171
  *
172
172
  * @example
173
173
  * ```typescript
@@ -192,7 +192,7 @@ var ProtectColumn = class {
192
192
  *
193
193
  * @param opts - Optional match index configuration. Defaults to 3-character ngram
194
194
  * tokenization with a downcase filter, `k=6`, `m=2048`, and `include_original=true`.
195
- * @returns This `ProtectColumn` instance for method chaining.
195
+ * @returns This `EncryptedColumn` instance for method chaining.
196
196
  *
197
197
  * @example
198
198
  * ```typescript
@@ -237,7 +237,7 @@ var ProtectColumn = class {
237
237
  * the plaintext type: strings become selector queries, objects/arrays become
238
238
  * containment queries.
239
239
  *
240
- * @returns This `ProtectColumn` instance for method chaining.
240
+ * @returns This `EncryptedColumn` instance for method chaining.
241
241
  *
242
242
  * @example
243
243
  * ```typescript
@@ -255,7 +255,7 @@ var ProtectColumn = class {
255
255
  }
256
256
  build() {
257
257
  return {
258
- cast_as: this.castAsValue,
258
+ cast_as: this.castAsValue === "string" ? "text" : this.castAsValue,
259
259
  indexes: this.indexesValue
260
260
  };
261
261
  }
@@ -263,7 +263,7 @@ var ProtectColumn = class {
263
263
  return this.columnName;
264
264
  }
265
265
  };
266
- var ProtectTable = class {
266
+ var EncryptedTable = class {
267
267
  constructor(tableName, columnBuilders) {
268
268
  this.tableName = tableName;
269
269
  this.columnBuilders = columnBuilders;
@@ -290,7 +290,7 @@ var ProtectTable = class {
290
290
  build() {
291
291
  const builtColumns = {};
292
292
  const processColumn = (builder, colName) => {
293
- if (builder instanceof ProtectColumn) {
293
+ if (builder instanceof EncryptedColumn) {
294
294
  const builtColumn = builder.build();
295
295
  if (builtColumn.cast_as === "json" && builtColumn.indexes.ste_vec?.prefix === "enabled") {
296
296
  builtColumns[colName] = {
@@ -307,7 +307,7 @@ var ProtectTable = class {
307
307
  }
308
308
  } else {
309
309
  for (const [key, value] of Object.entries(builder)) {
310
- if (value instanceof ProtectValue) {
310
+ if (value instanceof EncryptedField) {
311
311
  builtColumns[value.getName()] = value.build();
312
312
  } else {
313
313
  processColumn(value, key);
@@ -325,7 +325,10 @@ var ProtectTable = class {
325
325
  }
326
326
  };
327
327
  function encryptedTable(tableName, columns) {
328
- const tableBuilder = new ProtectTable(tableName, columns);
328
+ const tableBuilder = new EncryptedTable(
329
+ tableName,
330
+ columns
331
+ );
329
332
  for (const [colName, colBuilder] of Object.entries(columns)) {
330
333
  ;
331
334
  tableBuilder[colName] = colBuilder;
@@ -333,15 +336,15 @@ function encryptedTable(tableName, columns) {
333
336
  return tableBuilder;
334
337
  }
335
338
  function encryptedColumn(columnName) {
336
- return new ProtectColumn(columnName);
339
+ return new EncryptedColumn(columnName);
337
340
  }
338
- function encryptedValue(valueName) {
339
- return new ProtectValue(valueName);
341
+ function encryptedField(valueName) {
342
+ return new EncryptedField(valueName);
340
343
  }
341
344
  // Annotate the CommonJS export names for ESM import in node:
342
345
  0 && (module.exports = {
343
346
  encryptedColumn,
344
- encryptedTable,
345
- encryptedValue
347
+ encryptedField,
348
+ encryptedTable
346
349
  });
347
350
  //# sourceMappingURL=client.cjs.map