@tantainnovative/ndpr-toolkit 4.1.0 → 5.0.1

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 (83) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +76 -12
  3. package/dist/chunk-4FXRJH37.js +1 -0
  4. package/dist/{chunk-UJGNW6CH.js → chunk-ASEUTU45.js} +1 -1
  5. package/dist/chunk-BRJKIF7E.mjs +1 -0
  6. package/dist/chunk-CSE36REY.js +6 -0
  7. package/dist/chunk-DKLJ5DYN.js +1 -0
  8. package/dist/chunk-FRMVSG4N.mjs +1 -0
  9. package/dist/chunk-MAD7QYRK.js +1 -0
  10. package/dist/chunk-NBOJ2KGN.mjs +1 -0
  11. package/dist/chunk-PQ5IPUJN.mjs +1 -0
  12. package/dist/chunk-QKXGVT2Q.js +1 -0
  13. package/dist/chunk-R2ZZMATR.js +1 -0
  14. package/dist/chunk-R3ZKV2J7.mjs +1 -0
  15. package/dist/chunk-RRVML7CU.mjs +1 -0
  16. package/dist/{chunk-6H6IXTHA.mjs → chunk-SBSYHCPK.mjs} +1 -1
  17. package/dist/chunk-TLIHFGIJ.js +1 -0
  18. package/dist/{chunk-O4ATGGVK.js → chunk-TVA6D6S4.js} +1 -1
  19. package/dist/chunk-WPH6CJDL.mjs +6 -0
  20. package/dist/{chunk-6OPGI27L.mjs → chunk-ZSRO4L3C.mjs} +1 -1
  21. package/dist/consent.d.mts +59 -21
  22. package/dist/consent.d.ts +59 -21
  23. package/dist/consent.js +1 -1
  24. package/dist/consent.mjs +1 -1
  25. package/dist/core.d.mts +116 -74
  26. package/dist/core.d.ts +116 -74
  27. package/dist/core.js +1 -1
  28. package/dist/core.mjs +1 -1
  29. package/dist/cross-border.d.mts +4 -27
  30. package/dist/cross-border.d.ts +4 -27
  31. package/dist/cross-border.js +1 -1
  32. package/dist/cross-border.mjs +1 -1
  33. package/dist/dsr.d.mts +86 -57
  34. package/dist/dsr.d.ts +86 -57
  35. package/dist/dsr.js +1 -1
  36. package/dist/dsr.mjs +1 -1
  37. package/dist/headless.d.mts +20 -27
  38. package/dist/headless.d.ts +20 -27
  39. package/dist/headless.js +1 -1
  40. package/dist/headless.mjs +1 -1
  41. package/dist/hooks.d.mts +20 -27
  42. package/dist/hooks.d.ts +20 -27
  43. package/dist/hooks.js +1 -1
  44. package/dist/hooks.mjs +1 -1
  45. package/dist/index.d.mts +37 -202
  46. package/dist/index.d.ts +37 -202
  47. package/dist/index.js +1 -1
  48. package/dist/index.mjs +1 -1
  49. package/dist/lawful-basis.d.mts +3 -24
  50. package/dist/lawful-basis.d.ts +3 -24
  51. package/dist/lawful-basis.js +1 -1
  52. package/dist/lawful-basis.mjs +1 -1
  53. package/dist/presets.d.mts +1 -9
  54. package/dist/presets.d.ts +1 -9
  55. package/dist/presets.js +1 -1
  56. package/dist/presets.mjs +1 -1
  57. package/dist/ropa-lite.d.mts +2 -11
  58. package/dist/ropa-lite.d.ts +2 -11
  59. package/dist/ropa-lite.js +1 -1
  60. package/dist/ropa-lite.mjs +1 -1
  61. package/dist/ropa.d.mts +10 -52
  62. package/dist/ropa.d.ts +10 -52
  63. package/dist/ropa.js +1 -1
  64. package/dist/ropa.mjs +1 -1
  65. package/dist/server.d.mts +20 -100
  66. package/dist/server.d.ts +20 -100
  67. package/dist/server.js +1 -1
  68. package/dist/server.mjs +1 -1
  69. package/package.json +1 -1
  70. package/dist/chunk-3APT25XO.mjs +0 -1
  71. package/dist/chunk-45D7AMB3.js +0 -1
  72. package/dist/chunk-65J4P5ID.js +0 -1
  73. package/dist/chunk-7Z7NURIA.mjs +0 -1
  74. package/dist/chunk-D3HHDWBR.js +0 -1
  75. package/dist/chunk-DSIIEUAD.mjs +0 -1
  76. package/dist/chunk-H2FDWK4F.js +0 -6
  77. package/dist/chunk-HLFS3NXG.js +0 -1
  78. package/dist/chunk-JGY65SHX.mjs +0 -1
  79. package/dist/chunk-NI54X543.mjs +0 -1
  80. package/dist/chunk-P5MPUC5F.js +0 -1
  81. package/dist/chunk-ROOUYQD4.js +0 -1
  82. package/dist/chunk-UTXDZDYF.mjs +0 -6
  83. package/dist/chunk-W6VVLHRQ.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -1329,39 +1329,16 @@ export declare interface CrossBorderTransferManagerProps {
1329
1329
  */
1330
1330
  transfers: CrossBorderTransfer[];
1331
1331
  /**
1332
- * Callback when a new transfer is added
1333
- * @deprecated Renamed to `onAdd` in 4.1. The legacy name still fires
1334
- * for backward compatibility and will be removed in 5.0.
1335
- */
1336
- onAddTransfer?: (transfer: Omit<CrossBorderTransfer, 'id' | 'createdAt' | 'updatedAt'>) => void;
1337
- /**
1338
- * Callback when a transfer is updated
1339
- * @deprecated Renamed to `onUpdate` in 4.1. The legacy name still fires
1340
- * for backward compatibility and will be removed in 5.0.
1341
- */
1342
- onUpdateTransfer?: (id: string, updates: Partial<CrossBorderTransfer>) => void;
1343
- /**
1344
- * Callback when a transfer is removed
1345
- * @deprecated Renamed to `onArchive` in 4.1 (NDPA prefers soft-delete
1346
- * over hard delete). The legacy name still fires for backward
1347
- * compatibility and will be removed in 5.0.
1348
- */
1349
- onRemoveTransfer?: (id: string) => void;
1350
- /**
1351
- * Callback when a new transfer is added (uniform 4.1+ name).
1352
- * Takes precedence over `onAddTransfer` when both are provided.
1332
+ * Callback when a new transfer is added.
1353
1333
  */
1354
1334
  onAdd?: (transfer: Omit<CrossBorderTransfer, 'id' | 'createdAt' | 'updatedAt'>) => void;
1355
1335
  /**
1356
- * Callback when a transfer is updated (uniform 4.1+ name).
1357
- * Takes precedence over `onUpdateTransfer` when both are provided.
1336
+ * Callback when a transfer is updated.
1358
1337
  */
1359
1338
  onUpdate?: (id: string, updates: Partial<CrossBorderTransfer>) => void;
1360
1339
  /**
1361
- * Callback when a transfer is archived (uniform 4.1+ name). NDPA
1362
- * preference is soft-delete over hard-delete; consumers should treat
1363
- * this as an archive signal. Takes precedence over `onRemoveTransfer`
1364
- * when both are provided.
1340
+ * Callback when a transfer is archived. NDPA preference is soft-delete
1341
+ * over hard-delete; consumers should treat this as an archive signal.
1365
1342
  */
1366
1343
  onArchive?: (id: string) => void;
1367
1344
  /**
@@ -2101,7 +2078,7 @@ export declare type DSRStatus = 'pending' | 'awaitingVerification' | 'inProgress
2101
2078
  /**
2102
2079
  * Validated DSR submission shape — matches what `<DSRRequestForm onSubmit>`
2103
2080
  * emits client-side. Use this as the typed parameter for your server-side
2104
- * handler after `validateDsrSubmission` returns `valid: true`.
2081
+ * handler after `validateDsrSubmissionStructured` returns `valid: true`.
2105
2082
  */
2106
2083
  export declare interface DsrSubmissionPayload {
2107
2084
  requestType: string;
@@ -2116,16 +2093,6 @@ export declare interface DsrSubmissionPayload {
2116
2093
  submittedAt: number;
2117
2094
  }
2118
2095
 
2119
- /** Result of validating a raw DSR submission payload. */
2120
- export declare interface DsrSubmissionValidationResult {
2121
- /** True when the payload conforms to the DSR submission contract. */
2122
- valid: boolean;
2123
- /** Field-keyed error messages. Empty when `valid` is true. */
2124
- errors: Record<string, string>;
2125
- /** The narrowed, typed payload — only populated when `valid` is true. */
2126
- data?: DsrSubmissionPayload;
2127
- }
2128
-
2129
2096
  /**
2130
2097
  * DSR tracking and analytics component. Supports compliance with NDPA Part IV,
2131
2098
  * providing summary statistics, deadline tracking, and compliance metrics for data subject requests.
@@ -2240,21 +2207,9 @@ export declare type EffortLevel = 'low' | 'medium' | 'high';
2240
2207
  export declare function exportROPAToCSV(ropa: RecordOfProcessingActivities): string;
2241
2208
 
2242
2209
  /**
2243
- * Formats a DSR request for display or submission
2244
- * @param request The DSR request to format
2245
- * @returns Formatted request data
2246
- * @deprecated Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
2247
- */
2248
- export declare function formatDSRRequest(request: DSRRequest): {
2249
- formattedRequest: Record<string, unknown>;
2250
- isValid: boolean;
2251
- validationErrors: string[];
2252
- };
2253
-
2254
- /**
2255
- * Structured-result variant of {@link formatDSRRequest}. Same formatting
2256
- * output, but `validationErrors` is replaced with a typed `errors` array
2257
- * of `{ field, code, message }`.
2210
+ * Format a DSR request for display or submission. Returns the formatted
2211
+ * payload plus a typed `errors` array of `{ field, code, message }` for any
2212
+ * required fields missing from the source request.
2258
2213
  *
2259
2214
  * Codes emitted:
2260
2215
  * - `request_id_required`
@@ -2467,36 +2422,15 @@ export declare interface LawfulBasisTrackerProps {
2467
2422
  */
2468
2423
  activities: ProcessingActivity[];
2469
2424
  /**
2470
- * Callback when a new activity is created
2471
- * @deprecated Renamed to `onAdd` in 4.1. The legacy name still fires
2472
- * for backward compatibility and will be removed in 5.0.
2473
- */
2474
- onAddActivity?: (activity: Omit<ProcessingActivity, 'id' | 'createdAt' | 'updatedAt'>) => void;
2475
- /**
2476
- * Callback when an activity is updated
2477
- * @deprecated Renamed to `onUpdate` in 4.1. The legacy name still fires
2478
- * for backward compatibility and will be removed in 5.0.
2479
- */
2480
- onUpdateActivity?: (id: string, updates: Partial<ProcessingActivity>) => void;
2481
- /**
2482
- * Callback when an activity is archived
2483
- * @deprecated Renamed to `onArchive` in 4.1. The legacy name still fires
2484
- * for backward compatibility and will be removed in 5.0.
2485
- */
2486
- onArchiveActivity?: (id: string) => void;
2487
- /**
2488
- * Callback when a new activity is created (uniform 4.1+ name).
2489
- * Takes precedence over `onAddActivity` when both are provided.
2425
+ * Callback when a new activity is created.
2490
2426
  */
2491
2427
  onAdd?: (activity: Omit<ProcessingActivity, 'id' | 'createdAt' | 'updatedAt'>) => void;
2492
2428
  /**
2493
- * Callback when an activity is updated (uniform 4.1+ name).
2494
- * Takes precedence over `onUpdateActivity` when both are provided.
2429
+ * Callback when an activity is updated.
2495
2430
  */
2496
2431
  onUpdate?: (id: string, updates: Partial<ProcessingActivity>) => void;
2497
2432
  /**
2498
- * Callback when an activity is archived (uniform 4.1+ name).
2499
- * Takes precedence over `onArchiveActivity` when both are provided.
2433
+ * Callback when an activity is archived.
2500
2434
  */
2501
2435
  onArchive?: (id: string) => void;
2502
2436
  /**
@@ -3995,36 +3929,15 @@ export declare interface ROPAManagerProps {
3995
3929
  */
3996
3930
  ropa: RecordOfProcessingActivities;
3997
3931
  /**
3998
- * Callback when a new record is added
3999
- * @deprecated Renamed to `onAdd` in 4.1. The legacy name still fires
4000
- * for backward compatibility and will be removed in 5.0.
4001
- */
4002
- onAddRecord?: (record: ProcessingRecord) => void;
4003
- /**
4004
- * Callback when a record is updated
4005
- * @deprecated Renamed to `onUpdate` in 4.1. The legacy name still fires
4006
- * for backward compatibility and will be removed in 5.0.
4007
- */
4008
- onUpdateRecord?: (id: string, updates: Partial<ProcessingRecord>) => void;
4009
- /**
4010
- * Callback when a record is archived
4011
- * @deprecated Renamed to `onArchive` in 4.1. The legacy name still fires
4012
- * for backward compatibility and will be removed in 5.0.
4013
- */
4014
- onArchiveRecord?: (id: string) => void;
4015
- /**
4016
- * Callback when a new record is added (uniform 4.1+ name).
4017
- * Takes precedence over `onAddRecord` when both are provided.
3932
+ * Callback when a new record is added.
4018
3933
  */
4019
3934
  onAdd?: (record: ProcessingRecord) => void;
4020
3935
  /**
4021
- * Callback when a record is updated (uniform 4.1+ name).
4022
- * Takes precedence over `onUpdateRecord` when both are provided.
3936
+ * Callback when a record is updated.
4023
3937
  */
4024
3938
  onUpdate?: (id: string, updates: Partial<ProcessingRecord>) => void;
4025
3939
  /**
4026
- * Callback when a record is archived (uniform 4.1+ name).
4027
- * Takes precedence over `onArchiveRecord` when both are provided.
3940
+ * Callback when a record is archived.
4028
3941
  */
4029
3942
  onArchive?: (id: string) => void;
4030
3943
  /**
@@ -4660,9 +4573,10 @@ declare interface UseConsentReturn {
4660
4573
  */
4661
4574
  isValid: boolean;
4662
4575
  /**
4663
- * Validation errors (if any)
4576
+ * Validation errors (if any). Each entry is a structured `{ field, code,
4577
+ * message }` so consumers can switch on `code` across locales.
4664
4578
  */
4665
- validationErrors: string[];
4579
+ validationErrors: StructuredValidationError[];
4666
4580
  /**
4667
4581
  * Reset consent settings (clear from storage)
4668
4582
  */
@@ -5337,7 +5251,7 @@ declare interface UsePrivacyPolicyReturn {
5337
5251
  * }
5338
5252
  * ```
5339
5253
  */
5340
- export declare function useROPA({ initialData, adapter, onRecordAdd, onRecordUpdate, onRecordArchive, onAdd, onUpdate, onArchive, }: UseROPAOptions): UseROPAReturn;
5254
+ export declare function useROPA({ initialData, adapter, onAdd, onUpdate, onArchive, }: UseROPAOptions): UseROPAReturn;
5341
5255
 
5342
5256
  export declare interface UseROPAOptions {
5343
5257
  /**
@@ -5351,36 +5265,15 @@ export declare interface UseROPAOptions {
5351
5265
  */
5352
5266
  adapter?: StorageAdapter<RecordOfProcessingActivities>;
5353
5267
  /**
5354
- * Callback when a record is added
5355
- * @deprecated Renamed to `onAdd` in 4.1. The legacy name still fires
5356
- * for backward compatibility and will be removed in 5.0.
5357
- */
5358
- onRecordAdd?: (record: ProcessingRecord) => void;
5359
- /**
5360
- * Callback when a record is updated
5361
- * @deprecated Renamed to `onUpdate` in 4.1. The legacy name still fires
5362
- * for backward compatibility and will be removed in 5.0.
5363
- */
5364
- onRecordUpdate?: (id: string, updates: Partial<ProcessingRecord>) => void;
5365
- /**
5366
- * Callback when a record is archived
5367
- * @deprecated Renamed to `onArchive` in 4.1. The legacy name still fires
5368
- * for backward compatibility and will be removed in 5.0.
5369
- */
5370
- onRecordArchive?: (id: string) => void;
5371
- /**
5372
- * Callback when a record is added (uniform 4.1+ name).
5373
- * Takes precedence over `onRecordAdd` when both are provided.
5268
+ * Callback when a record is added.
5374
5269
  */
5375
5270
  onAdd?: (record: ProcessingRecord) => void;
5376
5271
  /**
5377
- * Callback when a record is updated (uniform 4.1+ name).
5378
- * Takes precedence over `onRecordUpdate` when both are provided.
5272
+ * Callback when a record is updated.
5379
5273
  */
5380
5274
  onUpdate?: (id: string, updates: Partial<ProcessingRecord>) => void;
5381
5275
  /**
5382
- * Callback when a record is archived (uniform 4.1+ name).
5383
- * Takes precedence over `onRecordArchive` when both are provided.
5276
+ * Callback when a record is archived.
5384
5277
  */
5385
5278
  onArchive?: (id: string) => void;
5386
5279
  }
@@ -5446,34 +5339,10 @@ export declare interface UseROPAReturn {
5446
5339
  }
5447
5340
 
5448
5341
  /**
5449
- * Validates consent settings to ensure they meet NDPA requirements
5450
- * @param settings The consent settings to validate
5451
- * @returns An object containing validation result and any error messages
5452
- * @deprecated Use `validateConsentStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
5453
- */
5454
- export declare function validateConsent(settings: ConsentSettings): {
5455
- valid: boolean;
5456
- errors: string[];
5457
- };
5458
-
5459
- /**
5460
- * Validates that consent options meet NDPA Section 26 requirements.
5461
- * Each consent option must specify a purpose for which data will be processed,
5462
- * as consent must be specific and informed per the Nigeria Data Protection Act.
5463
- * @param options The consent options to validate
5464
- * @returns An object containing validation result and any error messages
5465
- * @deprecated Use `validateConsentOptionsStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
5466
- */
5467
- export declare function validateConsentOptions(options: ConsentOption[]): {
5468
- valid: boolean;
5469
- errors: string[];
5470
- };
5471
-
5472
- /**
5473
- * Structured-result variant of {@link validateConsentOptions}. Each option
5474
- * is checked for a non-empty `purpose` (NDPA Section 26). Failing options
5475
- * are reported with `field: 'options[i].purpose'` so consumers can map
5476
- * errors back to the originating option index.
5342
+ * Validates consent options against NDPA Section 26 requirements. Each option
5343
+ * is checked for a non-empty `purpose`. Failing options are reported with
5344
+ * `field: 'options[i].purpose'` so consumers can map errors back to the
5345
+ * originating option index.
5477
5346
  *
5478
5347
  * Codes emitted:
5479
5348
  * - `options_required` — empty / missing options array
@@ -5482,8 +5351,8 @@ export declare function validateConsentOptions(options: ConsentOption[]): {
5482
5351
  export declare function validateConsentOptionsStructured(options: ConsentOption[]): StructuredValidationResult<ConsentOption[]>;
5483
5352
 
5484
5353
  /**
5485
- * Structured-result variant of {@link validateConsent}. Returns the same
5486
- * checks as `{ field, code, message }[]` so consumers can switch on `code`
5354
+ * Validates consent settings against NDPA requirements. Returns structured
5355
+ * `{ field, code, message }[]` errors so consumers can switch on `code`
5487
5356
  * across locales without regex-matching English strings.
5488
5357
  *
5489
5358
  * Codes emitted:
@@ -5506,47 +5375,7 @@ export declare function validateConsentOptionsStructured(options: ConsentOption[
5506
5375
  */
5507
5376
  export declare function validateConsentStructured(settings: ConsentSettings): StructuredValidationResult<ConsentSettings>;
5508
5377
 
5509
- /**
5510
- * Validate a raw DSR submission payload against the same rules
5511
- * `<DSRRequestForm />` enforces client-side. Designed to be called from a
5512
- * server-side handler (Next.js Route Handler, NestJS controller, Express
5513
- * middleware, Cloudflare Worker) so client and server stay in sync without
5514
- * the consumer hand-rolling zod / class-validator schemas.
5515
- *
5516
- * Defensive — accepts `unknown` and narrows. Safe to call directly on
5517
- * `await request.json()`.
5518
- *
5519
- * @example **Next.js Route Handler**
5520
- * ```ts
5521
- * // app/api/dsr/route.ts
5522
- * import { validateDsrSubmission } from '@tantainnovative/ndpr-toolkit/server';
5523
- *
5524
- * export async function POST(req: Request) {
5525
- * const { valid, errors, data } = validateDsrSubmission(await req.json());
5526
- * if (!valid) return Response.json({ errors }, { status: 422 });
5527
- * // `data` is the typed DsrSubmissionPayload
5528
- * await dsrStore.create(data);
5529
- * return Response.json({ ok: true }, { status: 201 });
5530
- * }
5531
- * ```
5532
- *
5533
- * @example **Lock to specific request types**
5534
- * ```ts
5535
- * validateDsrSubmission(payload, {
5536
- * allowedRequestTypes: ['access', 'erasure', 'rectification'],
5537
- * });
5538
- * ```
5539
- *
5540
- * @example **Skip identity verification (e.g. authenticated session)**
5541
- * ```ts
5542
- * validateDsrSubmission(payload, { requireIdentityVerification: false });
5543
- * ```
5544
- *
5545
- * @deprecated Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
5546
- */
5547
- export declare function validateDsrSubmission(payload: unknown, options?: ValidateDsrSubmissionOptions): DsrSubmissionValidationResult;
5548
-
5549
- /** Options for {@link validateDsrSubmission}. */
5378
+ /** Options for {@link validateDsrSubmissionStructured}. */
5550
5379
  export declare interface ValidateDsrSubmissionOptions {
5551
5380
  /**
5552
5381
  * Whether the data subject is required to provide an identifier
@@ -5564,9 +5393,15 @@ export declare interface ValidateDsrSubmissionOptions {
5564
5393
  }
5565
5394
 
5566
5395
  /**
5567
- * Structured-result variant of {@link validateDsrSubmission}. Same rules,
5568
- * but returns an array of `{ field, code, message }` so callers can switch
5569
- * on `code` programmatically across locales.
5396
+ * Validate a raw DSR submission payload against the same rules
5397
+ * `<DSRRequestForm />` enforces client-side. Designed to be called from a
5398
+ * server-side handler (Next.js Route Handler, NestJS controller, Express
5399
+ * middleware, Cloudflare Worker) so client and server stay in sync without
5400
+ * the consumer hand-rolling zod / class-validator schemas.
5401
+ *
5402
+ * Defensive — accepts `unknown` and narrows. Safe to call directly on
5403
+ * `await request.json()`. Returns `{ field, code, message }[]` errors so
5404
+ * callers can switch on `code` programmatically across locales.
5570
5405
  *
5571
5406
  * Codes emitted:
5572
5407
  * - `payload_not_object`