Skip to content

Commit

Permalink
pc/consent: Restructure consent src dir to make modle/browser distinc…
Browse files Browse the repository at this point in the history
…tion clearer (#1904)
  • Loading branch information
ssangervasi authored Nov 30, 2022
1 parent 71157ff commit 754c93f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
3 changes: 3 additions & 0 deletions clients/privacy-center/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ typings/
# The consent script is a build artifact.
public/fides-consent.js

# Fix conflict with root .gitignore Python rule.
!lib

# Nuxt.js build / generate output
.nuxt
dist
Expand Down
2 changes: 1 addition & 1 deletion clients/privacy-center/packages/fides-consent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ In this example, `data_sharing` is a cookie key that has been [configured in the

## fides-consent.mjs & fides-consent.d.ts

This package also exports its cookie utilities (`cookie.ts`) as a module the Privacy Center can import. This ensures the Privacy Center uses the exact same logic for reading & writing cookie data. This module is only used locally for convenience and is not published.
This package also exports its library (`src/lib`) as a module the Privacy Center can import. This ensures the Privacy Center uses the exact same logic for reading & writing cookie data. This module is only used locally for convenience and is not published.

Note that this module does _not_ define the `Fides.consent` global, as that is unnecessary when using modules.

Expand Down
2 changes: 1 addition & 1 deletion clients/privacy-center/packages/fides-consent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fides-consent",
"version": "0.0.1",
"description": "Fides consent script",
"source": "src/index.ts",
"source": "src/lib/index.ts",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const name = require("./package.json").name;

export default [
{
input: `src/index.ts`,
input: `src/${name}.ts`,
plugins: [
nodeResolve(),
esbuild({
minify: process.env.NODE_ENV === "development",
minify: process.env.NODE_ENV !== "development",
}),
copy({
// Automatically add the built script to the privacy center's static files for testing:
Expand All @@ -31,7 +31,7 @@ export default [
],
},
{
input: `src/cookie.ts`,
input: `src/lib/index.ts`,
plugins: [nodeResolve(), esbuild()],
output: [
{
Expand All @@ -43,7 +43,7 @@ export default [
],
},
{
input: `src/cookie.ts`,
input: `src/lib/index.ts`,
plugins: [dts()],
output: [
{
Expand Down
12 changes: 12 additions & 0 deletions clients/privacy-center/packages/fides-consent/src/fides-consent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* This script defines the browser script entrypoint for Fides consent logic. It is distributed
* as `fides-consent.js` and is accessed from the `Fides` global variable.
*/

import { getConsentCookie } from "./lib/cookie";

const Fides = {
consent: getConsentCookie(),
};

export default Fides;
7 changes: 0 additions & 7 deletions clients/privacy-center/packages/fides-consent/src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import config from "config/config.json";
import { getCookie, setCookie, Types } from "typescript-cookie";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This module defines the library of features are exported as a module. This library
* is then bundled into `fides-consent.js` and imported by Privacy Center app, so that
* both can share the same consent logic.
*/
export * from "./cookie";

0 comments on commit 754c93f

Please sign in to comment.