@openpolicy/core 0.0.3 → 0.0.4

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 (38) hide show
  1. package/dist/index.d.ts +10 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +8 -0
  4. package/dist/index.test.d.ts +2 -0
  5. package/dist/index.test.d.ts.map +1 -0
  6. package/dist/privacy.d.ts +7 -0
  7. package/dist/privacy.d.ts.map +1 -0
  8. package/dist/privacy.test.d.ts +2 -0
  9. package/dist/privacy.test.d.ts.map +1 -0
  10. package/dist/renderers/html.d.ts +3 -0
  11. package/dist/renderers/html.d.ts.map +1 -0
  12. package/dist/renderers/markdown.d.ts +3 -0
  13. package/dist/renderers/markdown.d.ts.map +1 -0
  14. package/dist/templates/privacy/ccpa-supplement.d.ts +3 -0
  15. package/dist/templates/privacy/ccpa-supplement.d.ts.map +1 -0
  16. package/dist/templates/privacy/contact.d.ts +3 -0
  17. package/dist/templates/privacy/contact.d.ts.map +1 -0
  18. package/dist/templates/privacy/cookies.d.ts +3 -0
  19. package/dist/templates/privacy/cookies.d.ts.map +1 -0
  20. package/dist/templates/privacy/data-collected.d.ts +3 -0
  21. package/dist/templates/privacy/data-collected.d.ts.map +1 -0
  22. package/dist/templates/privacy/data-retention.d.ts +3 -0
  23. package/dist/templates/privacy/data-retention.d.ts.map +1 -0
  24. package/dist/templates/privacy/gdpr-supplement.d.ts +3 -0
  25. package/dist/templates/privacy/gdpr-supplement.d.ts.map +1 -0
  26. package/dist/templates/privacy/introduction.d.ts +3 -0
  27. package/dist/templates/privacy/introduction.d.ts.map +1 -0
  28. package/dist/templates/privacy/legal-basis.d.ts +3 -0
  29. package/dist/templates/privacy/legal-basis.d.ts.map +1 -0
  30. package/dist/templates/privacy/third-parties.d.ts +3 -0
  31. package/dist/templates/privacy/third-parties.d.ts.map +1 -0
  32. package/dist/templates/privacy/user-rights.d.ts +3 -0
  33. package/dist/templates/privacy/user-rights.d.ts.map +1 -0
  34. package/dist/types.d.ts +41 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/validate.d.ts +3 -0
  37. package/dist/validate.d.ts.map +1 -0
  38. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ export { compilePrivacyPolicy } from "./privacy";
2
+ export type { CompileOptions, Jurisdiction, OutputFormat, PolicyInput, PolicySection, PrivacyPolicyConfig, ValidationIssue, } from "./types";
3
+ export { validatePrivacyPolicy } from "./validate";
4
+ import type { CompileOptions, PolicyInput } from "./types";
5
+ export declare function compilePolicy(input: PolicyInput, options?: CompileOptions): {
6
+ format: import("./types").OutputFormat;
7
+ content: string;
8
+ sections: import("./types").PolicySection[];
9
+ }[];
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,eAAe,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3D,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc;;;;IAOzE"}
package/dist/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ // src/renderers/html.ts
2
+ function renderHTML(sections) {
3
+ return sections.map((section) => `<h2>${section.title}</h2><p>${section.body}</p>`).join(`
4
+ `);
5
+ }
6
+
1
7
  // src/renderers/markdown.ts
2
8
  function renderMarkdown(sections) {
3
9
  return sections.map((section) => `## ${section.title}
@@ -200,6 +206,8 @@ function compilePrivacyPolicy(config, options = { formats: ["markdown"] }) {
200
206
  switch (format) {
201
207
  case "markdown":
202
208
  return { format, content: renderMarkdown(sections), sections };
209
+ case "html":
210
+ return { format, content: renderHTML(sections), sections };
203
211
  case "pdf":
204
212
  throw new Error("pdf format is not yet implemented");
205
213
  case "jsx":
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { CompileOptions, OutputFormat, PolicySection, PrivacyPolicyConfig } from "./types";
2
+ export declare function compilePrivacyPolicy(config: PrivacyPolicyConfig, options?: CompileOptions): {
3
+ format: OutputFormat;
4
+ content: string;
5
+ sections: PolicySection[];
6
+ }[];
7
+ //# sourceMappingURL=privacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../src/privacy.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACX,cAAc,EACd,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,GAAE,cAA0C,GACjD;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,EAAE,CAAA;CAAE,EAAE,CAmBxE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=privacy.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.test.d.ts","sourceRoot":"","sources":["../src/privacy.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection } from "../types";
2
+ export declare function renderHTML(sections: PolicySection[]): string;
3
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/renderers/html.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAI5D"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection } from "../types";
2
+ export declare function renderMarkdown(sections: PolicySection[]): string;
3
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/renderers/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAIhE"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildCcpaSupplement(config: PrivacyPolicyConfig): PolicySection | null;
3
+ //# sourceMappingURL=ccpa-supplement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ccpa-supplement.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/ccpa-supplement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,GACzB,aAAa,GAAG,IAAI,CAkBtB"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildContact(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=contact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/contact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAWvE"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildCookies(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=cookies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/cookies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAyBvE"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildDataCollected(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=data-collected.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-collected.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/data-collected.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAY7E"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildDataRetention(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=data-retention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-retention.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/data-retention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAW7E"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildGdprSupplement(config: PrivacyPolicyConfig): PolicySection | null;
3
+ //# sourceMappingURL=gdpr-supplement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gdpr-supplement.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/gdpr-supplement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,GACzB,aAAa,GAAG,IAAI,CActB"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildIntroduction(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=introduction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introduction.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/introduction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAU5E"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildLegalBasis(config: PrivacyPolicyConfig): PolicySection | null;
3
+ //# sourceMappingURL=legal-basis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legal-basis.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/legal-basis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,eAAe,CAC9B,MAAM,EAAE,mBAAmB,GACzB,aAAa,GAAG,IAAI,CAQtB"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildThirdParties(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=third-parties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"third-parties.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/third-parties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAe5E"}
@@ -0,0 +1,3 @@
1
+ import type { PolicySection, PrivacyPolicyConfig } from "../../types";
2
+ export declare function buildUserRights(config: PrivacyPolicyConfig): PolicySection;
3
+ //# sourceMappingURL=user-rights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-rights.d.ts","sourceRoot":"","sources":["../../../src/templates/privacy/user-rights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AActE,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAW1E"}
@@ -0,0 +1,41 @@
1
+ export type OutputFormat = "markdown" | "html" | "pdf" | "jsx";
2
+ export type CompileOptions = {
3
+ formats: OutputFormat[];
4
+ };
5
+ export type PolicySection = {
6
+ id: string;
7
+ title: string;
8
+ body: string;
9
+ };
10
+ export type Jurisdiction = "us" | "eu" | "ca" | "au" | "nz" | "other";
11
+ export type PrivacyPolicyConfig = {
12
+ effectiveDate: string;
13
+ company: {
14
+ name: string;
15
+ legalName: string;
16
+ address: string;
17
+ contact: string;
18
+ };
19
+ dataCollected: Record<string, string[]>;
20
+ legalBasis: string;
21
+ retention: Record<string, string>;
22
+ cookies: {
23
+ essential: boolean;
24
+ analytics: boolean;
25
+ marketing: boolean;
26
+ };
27
+ thirdParties: {
28
+ name: string;
29
+ purpose: string;
30
+ }[];
31
+ userRights: string[];
32
+ jurisdictions: Jurisdiction[];
33
+ };
34
+ export type PolicyInput = {
35
+ type: "privacy";
36
+ } & PrivacyPolicyConfig;
37
+ export type ValidationIssue = {
38
+ level: "error" | "warning";
39
+ message: string;
40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AAA;CAAE,GAAG,mBAAmB,CAAC;AAEpE,MAAM,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { PrivacyPolicyConfig, ValidationIssue } from "./types";
2
+ export declare function validatePrivacyPolicy(config: PrivacyPolicyConfig): ValidationIssue[];
3
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpE,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,mBAAmB,GACzB,eAAe,EAAE,CA8DnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpolicy/core",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "Core package for OpenPolicy",
6
6
  "license": "MIT",