Skip to content

Commit 768cf20

Browse files
committed
chore(stack): disable logging by default
1 parent 4d1aacb commit 768cf20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+127
-87
lines changed

docs/reference/configuration.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ Each keyset provides an isolated set of encryption keys, so data encrypted under
142142

143143
### Logging configuration
144144

145-
You can configure structured logging for the Encryption client:
145+
Logging is disabled by default. You can enable it by setting the `STASH_LOG_LEVEL` environment variable or by configuring it programmatically:
146+
147+
```bash
148+
STASH_LOG_LEVEL=debug # debug | info | warn | error
149+
```
146150

147151
```ts
148152
const client = await Encryption({
@@ -160,7 +164,7 @@ const client = await Encryption({
160164

161165
| Option | Type | Default | Description |
162166
|--------|------|---------|-------------|
163-
| `enabled` | `boolean` | `true` | Toggle logging on or off. |
167+
| `enabled` | `boolean` | `false` | Toggle logging on or off. Automatically enabled when `STASH_LOG_LEVEL` is set. |
164168
| `pretty` | `boolean` | Auto-detected | Enable pretty-printed log format. |
165169
| `drain` | `(ctx) => void` | `undefined` | Callback for forwarding log events to an external platform. |
166170

docs/reference/dynamodb.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,17 @@ const decryptedUsers = decryptedResult.data
171171

172172
## Using nested objects
173173

174-
The DynamoDB helper supports nested object encryption using `encryptedValue`:
174+
The DynamoDB helper supports nested object encryption using `encryptedField`:
175175

176176
```typescript
177-
import { encryptedTable, encryptedColumn, encryptedValue } from '@cipherstash/stack/schema'
177+
import { encryptedTable, encryptedColumn, encryptedField } from '@cipherstash/stack/schema'
178178

179179
const users = encryptedTable('users', {
180180
email: encryptedColumn('email'),
181181
profile: {
182-
name: encryptedValue('profile.name'),
182+
name: encryptedField('profile.name'),
183183
address: {
184-
street: encryptedValue('profile.address.street'),
184+
street: encryptedField('profile.address.street'),
185185
},
186186
},
187187
})

docs/reference/schema.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,23 @@ export const protectedUsers = encryptedTable("users", {
8181
CipherStash Encryption supports nested objects in your schema, allowing you to encrypt **but not search on** nested properties. You can define nested objects up to 3 levels deep.
8282
This is useful for data stores that have less structured data, like NoSQL databases.
8383

84-
You can define nested objects by using the `encryptedValue` function to define a value in a nested object. The value naming convention of the `encryptedValue` function is a dot-separated string of the nested object path, e.g. `profile.name` or `profile.address.street`.
84+
You can define nested objects by using the `encryptedField` function to define a value in a nested object. The value naming convention of the `encryptedField` function is a dot-separated string of the nested object path, e.g. `profile.name` or `profile.address.street`.
8585

8686
> [!NOTE]
8787
> Using nested objects is not recommended for SQL databases, as it will not be searchable.
8888
> You should either use a JSON data type and encrypt the entire object, or use a separate column for each nested property.
8989
9090
```ts
91-
import { encryptedTable, encryptedColumn, encryptedValue } from "@cipherstash/stack/schema";
91+
import { encryptedTable, encryptedColumn, encryptedField } from "@cipherstash/stack/schema";
9292

9393
export const protectedUsers = encryptedTable("users", {
9494
email: encryptedColumn("email").freeTextSearch().equality().orderAndRange(),
9595
profile: {
96-
name: encryptedValue("profile.name"),
96+
name: encryptedField("profile.name"),
9797
address: {
98-
street: encryptedValue("profile.address.street"),
98+
street: encryptedField("profile.address.street"),
9999
location: {
100-
coordinates: encryptedValue("profile.address.location.coordinates"),
100+
coordinates: encryptedField("profile.address.location.coordinates"),
101101
},
102102
},
103103
},
@@ -112,8 +112,8 @@ When working with nested objects:
112112
- Optional nested objects are supported
113113

114114
> [!WARNING]
115-
> TODO: The schema builder does not validate the values you supply to the `encryptedValue` or `encryptedColumn` functions.
116-
> These values are meant to be unique, and and cause unexpected behavior if they are not defined correctly.
115+
> TODO: The schema builder does not validate the values you supply to the `encryptedField` or `encryptedColumn` functions.
116+
> These values are meant to be unique, and cause unexpected behavior if they are not defined correctly.
117117
118118
## Data types
119119

packages/stack/__tests__/drizzle-operators-jsonb.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EncryptionClient } from '@/encryption/ffi'
1+
import type { EncryptionClient } from '@/encryption'
22
import { pgTable } from 'drizzle-orm/pg-core'
33
import { PgDialect } from 'drizzle-orm/pg-core'
44
import { describe, expect, it, vi } from 'vitest'

packages/stack/__tests__/encrypt-query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dotenv/config'
2-
import type { EncryptionClient } from '@/encryption/ffi'
2+
import type { EncryptionClient } from '@/encryption'
33
import { EncryptionErrorTypes } from '@/errors'
44
import { Encryption } from '@/index'
55
import { beforeAll, describe, expect, it } from 'vitest'

packages/stack/__tests__/error-codes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dotenv/config'
2-
import type { EncryptionClient } from '@/encryption/ffi'
2+
import type { EncryptionClient } from '@/encryption'
33
import { Encryption, EncryptionErrorTypes } from '@/index'
44
import { encryptedColumn, encryptedTable } from '@/schema'
55
import { ProtectError as FfiProtectError } from '@cipherstash/protect-ffi'

packages/stack/__tests__/infer-index-type.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
inferIndexType,
33
inferQueryOpFromPlaintext,
44
validateIndexType,
5-
} from '@/encryption/ffi/helpers/infer-index-type'
5+
} from '@/encryption/helpers/infer-index-type'
66
import { encryptedColumn, encryptedTable } from '@/schema'
77
import { describe, expect, it } from 'vitest'
88

packages/stack/__tests__/types.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type {
1919
OtherFields,
2020
QueryTypeName,
2121
} from '../src/types.js'
22-
import type { EncryptionClient } from '../src/encryption/ffi/index.js'
22+
import type { EncryptionClient } from '../src/encryption/index.js'
2323

2424
describe('Type inference', () => {
2525
it('encryptedTable returns ProtectTable with column access', () => {

packages/stack/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ export type {
2020
InferPlaintext,
2121
InferEncrypted,
2222
} from '@/schema'
23-
export type { EncryptionClient } from '@/encryption/ffi'
23+
export type { EncryptionClient } from '@/encryption'

packages/stack/src/drizzle/operators.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import type { EncryptionClient } from '@/encryption/ffi'
2-
import type { EncryptedColumn, EncryptedTable, EncryptedTableColumn } from '@/schema'
1+
import type { EncryptionClient } from '@/encryption/index.js'
2+
import type {
3+
EncryptedColumn,
4+
EncryptedTable,
5+
EncryptedTableColumn,
6+
} from '@/schema'
37
import { type QueryTypeName, queryTypes } from '@/types'
48
import {
59
type SQL,
@@ -1170,7 +1174,8 @@ export function createEncryptionOperators(encryptionClient: EncryptionClient): {
11701174
} {
11711175
// Create a cache for encrypted tables keyed by table name
11721176
const tableCache = new Map<string, EncryptedTable<EncryptedTableColumn>>()
1173-
const defaultTable: EncryptedTable<EncryptedTableColumn> | undefined = undefined
1177+
const defaultTable: EncryptedTable<EncryptedTableColumn> | undefined =
1178+
undefined
11741179

11751180
/**
11761181
* Equality operator - encrypts value and uses regular Drizzle operator

0 commit comments

Comments
 (0)