Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/add-configure-preference-upload-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@transcend-io/cli': minor
---

Add configure-preference-upload CLI command

- New `transcend consent configure-preference-upload` command that interactively configures column mappings for preference CSV uploads
- Scans CSV files to discover headers and unique values, then walks through a 6-step wizard (identifiers, identifier names, timestamp, purpose columns, value mappings, metadata)
- Saves a reusable config JSON for fully non-interactive uploads via `upload-preferences`
- Deprecate old parsing functions that use FileMetadataState in favor of new FileFormatState versions
11 changes: 11 additions & 0 deletions .changeset/sdk-preference-format-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@transcend-io/sdk': minor
---

Add preference upload types and helpers to SDK

- Add FileFormatState codec (schema-only CSV column mapping without upload receipts)
- Add RequestUploadReceipts codec (tracks upload progress and results)
- Add loadReferenceData helper (fetches purposes, topics, identifiers in parallel)
- Add getPreferenceIdentifiersFromRow helper (extracts identifiers from a CSV row)
- Add getUniquePreferenceIdentifierNamesFromRow helper (extracts unique identifiers from a CSV row)
18 changes: 18 additions & 0 deletions .cursor/rules/test-colocation.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
description: Tests must live next to the code they test
globs: "**/*.test.ts"
alwaysApply: false
---

# Test Colocation

Tests always live in a `tests/` folder next to the source file they cover.

```
packages/sdk/src/preference-management/
getPreferenceIdentifiersFromRow.ts
tests/
getPreferenceIdentifiersFromRow.test.ts
```

When moving a function between packages, move its test file too.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { buildCommand } from '@stricli/core';
import { ScopeName } from '@transcend-io/privacy-types';

import {
createAuthParameter,
createTranscendUrlParameter,
} from '../../../lib/cli/common-parameters.js';

export const configurePreferenceUploadCommand = buildCommand({
loader: async () => {
const { configurePreferenceUpload } = await import('./impl.js');
return configurePreferenceUpload;
},
parameters: {
flags: {
auth: createAuthParameter({
scopes: [ScopeName.ViewPreferenceStoreSettings, ScopeName.ViewRequestIdentitySettings],
}),
transcendUrl: createTranscendUrlParameter(),
directory: {
kind: 'parsed',
parse: String,
brief: 'Path to the directory of CSV files to scan for column headers and unique values',
},
schemaFilePath: {
kind: 'parsed',
parse: String,
brief:
'Path to the config JSON file. Defaults to <directory>/../preference-upload-schema.json',
optional: true,
},
},
},
docs: {
brief: 'Interactively configure the column mapping for preference CSV uploads',
fullDescription: `Interactively configure the column mapping for preference CSV uploads.

Scans ALL CSV files in the given directory to discover every column header
and every unique value per column, then walks through an interactive editor
to build the full mapping config (identifiers, ignored columns, timestamp,
purposes/preferences and their value mappings).

The resulting config JSON is reused by 'upload-preferences' so subsequent
uploads run fully non-interactively.`,
},
});
Loading
Loading