@stacksjs/types 0.75.40 → 0.75.42

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.
@@ -53,7 +53,7 @@ export declare interface DatabaseBackupOptions {
53
53
  destination?: string
54
54
  }
55
55
  export declare interface DatabaseOptions {
56
- default: SupportedDialect
56
+ default: SupportedDialect | 'turso' | 'libsql'
57
57
  logging?: boolean
58
58
  backups?: DatabaseBackupOptions
59
59
  connections: {
@@ -93,6 +93,11 @@ export declare interface DatabaseOptions {
93
93
  database?: string
94
94
  prefix?: string
95
95
  }
96
+ turso?: {
97
+ url?: string
98
+ authToken?: string
99
+ prefix?: string
100
+ }
96
101
  dynamodb?: {
97
102
  key?: string
98
103
  secret?: string
package/dist/model.d.ts CHANGED
@@ -211,6 +211,7 @@ export declare interface ModelOptions extends Base {
211
211
  billable?: boolean
212
212
  useActivityLog?: boolean | ActivityLogOption
213
213
  likeable?: boolean | LikeableOptions
214
+ gdpr?: GdprTraitOptions
214
215
  sharding?: ShardingOptions
215
216
  }
216
217
  attributes?: AttributesElements
@@ -235,6 +236,22 @@ export declare interface ModelOptions extends Base {
235
236
  [key: string]: (value: any) => any
236
237
  }
237
238
  }
239
+ export declare interface GdprRetentionPolicy {
240
+ readonly days: number
241
+ readonly column?: string
242
+ readonly action?: GdprRetentionAction
243
+ }
244
+ export declare interface GdprTraitOptions {
245
+ readonly subject?: GdprSubject
246
+ readonly erasure?: GdprErasureAction
247
+ readonly retention?: GdprRetentionPolicy
248
+ readonly purpose?: string
249
+ readonly basis?: GdprLawfulBasis
250
+ }
251
+ export declare interface PersonalAttributeOptions {
252
+ readonly anonymize?: string | number | boolean | null
253
+ readonly export?: boolean
254
+ }
238
255
  export declare interface Attribute {
239
256
  required?: boolean
240
257
  nullable?: boolean
@@ -245,6 +262,7 @@ export declare interface Attribute {
245
262
  hidden?: boolean
246
263
  fillable?: boolean
247
264
  guarded?: boolean
265
+ personal?: PersonalAttribute
248
266
  foreignKey?: boolean | ForeignKeyConfig
249
267
  factory?: (faker: Faker, attributes: Readonly<Record<string, unknown>>) => any
250
268
  validation: {
@@ -326,6 +344,49 @@ export type ApiMiddleware = | string
326
344
  | string[]
327
345
  | { read?: string | string[], write?: string | string[] }
328
346
  declare type ApiOptions = DeepPartial<ApiSettings>;
347
+ /*
348
+ * GDPR declarations (stacksjs/stacks#365): `personal` on an attribute and
349
+ * `traits.gdpr` on a model. Declared here, beside the rest of the model
350
+ * vocabulary; `@stacksjs/orm` reads them (`exportSubjectData`, `eraseSubject`,
351
+ * `pruneRetainedData`, `buddy gdpr:register`).
352
+ */
353
+ /** What erasure does to a data subject's rows. */
354
+ export type GdprErasureAction = 'anonymize' | 'delete' | 'keep';
355
+ /** What retention does to rows older than the policy allows. */
356
+ export type GdprRetentionAction = 'anonymize' | 'delete';
357
+ /** The Article 6 lawful bases, spelled as the register prints them. */
358
+ export type GdprLawfulBasis = | 'consent'
359
+ | 'contract'
360
+ | 'legal_obligation'
361
+ | 'vital_interests'
362
+ | 'public_task'
363
+ | 'legitimate_interests';
364
+ /**
365
+ * Whose data a row is.
366
+ *
367
+ * - a column name: the column holds the subject's user id (`'user_id'`; `'id'`
368
+ * on the User model itself). Several columns match when ANY of them does.
369
+ * - `{ column, where }`: the same, narrowed by fixed values - for a polymorphic
370
+ * owner such as `{ column: 'tokenable_id', where: { tokenable_type: 'users' } }`,
371
+ * which would otherwise match another model's row with the same id.
372
+ * - `{ via }`: the row belongs to a `belongsTo` parent that is itself a
373
+ * subject's (`{ via: 'Customer' }` on Order). Chains, so OrderItem can go via
374
+ * Order via Customer.
375
+ * - `{ email }`: the column holds the subject's email address, for ledgers keyed
376
+ * by address rather than account (consent, suppression, form submissions).
377
+ *
378
+ * Left out, it is derived: `id` on the `User` model, and the foreign key of a
379
+ * `belongsTo: ['User']` everywhere else. A model with neither has no subject -
380
+ * retention still applies to it, access and erasure cannot reach it, and the
381
+ * register says so.
382
+ */
383
+ export type GdprSubject = | string
384
+ | readonly string[]
385
+ | { readonly column: string | readonly string[], readonly where?: Readonly<Record<string, string | number | boolean>> }
386
+ | { readonly via: string }
387
+ | { readonly email: string }
388
+ /** `personal: true`, or the options form. */
389
+ export type PersonalAttribute = boolean | PersonalAttributeOptions;
329
390
  /**
330
391
  * The attribute VALUES of one model row, as handed to a computed getter or
331
392
  * setter: `salutationName: (attributes: Attributes) => …`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/types",
3
3
  "type": "module",
4
- "version": "0.75.40",
4
+ "version": "0.75.42",
5
5
  "description": "The Stacks framework types.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -58,11 +58,11 @@
58
58
  "dependencies": {
59
59
  "@stacksjs/bunpress": "^0.2.8",
60
60
  "@stacksjs/clapp": "^0.2.12",
61
- "@stacksjs/events": "0.75.40",
62
- "@stacksjs/strings": "0.75.40",
63
- "@stacksjs/stx": "^0.2.348",
61
+ "@stacksjs/events": "0.75.42",
62
+ "@stacksjs/strings": "0.75.42",
63
+ "@stacksjs/stx": "^0.2.350",
64
64
  "@stacksjs/ts-validation": "^0.5.6",
65
- "bun-query-builder": "^0.3.4"
65
+ "bun-query-builder": "^0.3.5"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "meilisearch": "^0.62.0"
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "devDependencies": {
76
- "@stacksjs/validation": "0.75.40",
76
+ "@stacksjs/validation": "0.75.42",
77
77
  "better-dx": "^0.2.24",
78
78
  "meilisearch": "^0.62.0"
79
79
  },