@openpolicy/vite 0.0.8 → 0.0.10

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.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # OpenPolicy Vite
1
+ # `@openpolicy/vite`
2
2
 
3
- This is the Vite package for the OpenPolicy project.
3
+ > Vite plugin for compiling [OpenPolicy](https://openpolicy.sh) policy documents at build time.
4
+
5
+ Compiles `definePrivacyPolicy()` and `defineTermsOfService()` configs to Markdown or HTML automatically — on every build and on save in dev mode.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ bun add -D @openpolicy/vite
11
+ bun add @openpolicy/sdk
12
+ # or: npm install --save-dev @openpolicy/vite @openpolicy/sdk
13
+ ```
14
+
15
+ ## Setup
16
+
17
+ ```ts
18
+ // vite.config.ts
19
+ import { defineConfig } from "vite";
20
+ import { openPolicy } from "@openpolicy/vite";
21
+
22
+ export default defineConfig({
23
+ plugins: [
24
+ openPolicy({
25
+ configs: ["privacy.config.ts", "terms.config.ts"],
26
+ formats: ["markdown"],
27
+ outDir: "public/policies",
28
+ }),
29
+ ],
30
+ });
31
+ ```
32
+
33
+ ## Options
34
+
35
+ | Option | Type | Default | Description |
36
+ |---|---|---|---|
37
+ | `configs` | `PolicyConfigEntry[]` | — | Policy configs to compile. Type is auto-detected from filename (`"terms"` → terms of service, otherwise privacy). Each entry is a path string or `{ config: string; type?: "privacy" \| "terms" }`. |
38
+ | `formats` | `OutputFormat[]` | `["markdown"]` | `"markdown"` or `"html"` |
39
+ | `outDir` | `string` | `"public/policies"` | Output directory, relative to the Vite root |
40
+
41
+ ## Scaffold
42
+
43
+ If a config file doesn't exist when Vite starts, the plugin creates a starter file with placeholder content — edit and save to generate your first policy.
44
+
45
+ ## Astro
46
+
47
+ For Astro projects, use [`@openpolicy/astro`](https://openpolicy.sh/docs/getting-started/astro) instead — it wraps this plugin and plugs into Astro's integration API.
48
+
49
+ ## Documentation
50
+
51
+ [openpolicy.sh/docs/getting-started/vite](https://openpolicy.sh/docs/getting-started/vite)
52
+
53
+ ## Links
54
+
55
+ - [GitHub](https://github.com/jamiedavenport/openpolicy)
56
+ - [openpolicy.sh](https://openpolicy.sh)
57
+ - [npm](https://www.npmjs.com/package/@openpolicy/vite)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { OutputFormat } from "@openpolicy/core";
2
1
  import { Plugin } from "vite";
3
2
 
3
+ //#region ../core/dist/index.d.ts
4
+ //#region src/types.d.ts
5
+ type OutputFormat = "markdown" | "html" | "pdf" | "jsx";
6
+ //#endregion
4
7
  //#region src/index.d.ts
5
8
  type PolicyConfigEntry = string | {
6
9
  config: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAcY,iBAAA;EAEP,MAAA;EAAgB,IAAA;AAAA;AAAA,UAEJ,iBAAA;EAChB,OAAA,GAAU,iBAAA;EACV,MAAA;EACA,OAAA,GAAU,YAAA;EACV,MAAA;EACA,IAAA;AAAA;AAAA,iBAyGqB,aAAA,CACrB,UAAA,UACA,IAAA,yBACE,OAAA;AAAA,iBAMmB,gBAAA,CACrB,UAAA,UACA,MAAA,UACA,OAAA,EAAS,YAAA,IACT,IAAA,yBACE,OAAA;AAAA,iBA+Ca,UAAA,CAAW,OAAA,GAAS,iBAAA,GAAyB,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["OutputFormat","CompileOptions","formats","PolicySection","id","title","body","Jurisdiction","PrivacyPolicyConfig","Record","effectiveDate","company","name","legalName","address","contact","dataCollected","legalBasis","retention","cookies","essential","analytics","marketing","thirdParties","purpose","userRights","jurisdictions","DisputeResolutionMethod","TermsOfServiceConfig","acceptance","methods","eligibility","minimumAge","jurisdictionRestrictions","accounts","registrationRequired","userResponsibleForCredentials","companyCanTerminate","prohibitedUses","userContent","usersOwnContent","licenseGrantedToCompany","licenseDescription","companyCanRemoveContent","intellectualProperty","companyOwnsService","usersMayNotCopy","payments","hasPaidFeatures","refundPolicy","priceChangesNotice","availability","noUptimeGuarantee","maintenanceWindows","termination","userCanTerminate","effectOfTermination","disclaimers","serviceProvidedAsIs","noWarranties","limitationOfLiability","excludesIndirectDamages","liabilityCap","indemnification","userIndemnifiesCompany","scope","thirdPartyServices","disputeResolution","method","venue","classActionWaiver","governingLaw","jurisdiction","changesPolicy","noticeMethod","noticePeriodDays","privacyPolicyUrl","PolicyInput","type","ValidationIssue","level","message","compilePrivacyPolicy","config","options","format","content","sections","compileTermsOfService","validatePrivacyPolicy","validateTermsOfService","compilePolicy","input"],"sources":["../../core/dist/index.d.ts","../src/index.ts"],"mappings":";;;;KACKA,YAAAA;;;KCaO,iBAAA;EAEP,MAAA;EAAgB,IAAA;AAAA;AAAA,UAEJ,iBAAA;EAChB,OAAA,GAAU,iBAAA;EACV,MAAA;EACA,OAAA,GAAU,YAAA;EACV,MAAA;EACA,IAAA;AAAA;AAAA,iBAyGqB,aAAA,CACrB,UAAA,UACA,IAAA,yBACE,OAAA;AAAA,iBAMmB,gBAAA,CACrB,UAAA,UACA,MAAA,UACA,OAAA,EAAS,YAAA,IACT,IAAA,yBACE,OAAA;AAAA,iBA+Ca,UAAA,CAAW,OAAA,GAAS,iBAAA,GAAyB,MAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,514 @@
1
1
  import { access, mkdir, writeFile } from "node:fs/promises";
2
2
  import { join, resolve } from "node:path";
3
- import { compilePolicy, validatePrivacyPolicy, validateTermsOfService } from "@openpolicy/core";
3
+ import { marked } from "marked";
4
+ //#region ../core/dist/index.js
5
+ function renderMarkdown(sections) {
6
+ return sections.map((section) => `## ${section.title}\n\n${section.body}`).join("\n\n---\n\n");
7
+ }
8
+ function renderHTML(sections) {
9
+ return marked(renderMarkdown(sections));
10
+ }
11
+ function buildCcpaSupplement(config) {
12
+ if (!config.jurisdictions.includes("ca")) return null;
13
+ return {
14
+ id: "ccpa-supplement",
15
+ title: "California Privacy Rights (CCPA)",
16
+ body: `This section applies to California residents under the California Consumer Privacy Act (CCPA) and the California Privacy Rights Act (CPRA).
17
+
18
+ **Categories of Personal Information Collected:** We collect the categories of personal information described in the "Information We Collect" section above.
19
+
20
+ **Your California Rights:**
21
+ - **Right to Know:** You may request information about the personal information we have collected about you, including the categories of sources, the business purpose for collection, and the categories of third parties with whom we share information.
22
+ - **Right to Delete:** You may request deletion of personal information we have collected from you, subject to certain exceptions.
23
+ - **Right to Opt-Out:** You may opt out of the sale or sharing of your personal information.
24
+ - **Right to Non-Discrimination:** We will not discriminate against you for exercising your California privacy rights.
25
+
26
+ To exercise your rights, contact us at ${config.company.contact}.`
27
+ };
28
+ }
29
+ function buildContact$1(config) {
30
+ return {
31
+ id: "contact",
32
+ title: "Contact Us",
33
+ body: `If you have questions or concerns about this Privacy Policy or our data practices, please contact us:
34
+
35
+ **${config.company.legalName}**
36
+ ${config.company.address}
37
+
38
+ Email: ${config.company.contact}`
39
+ };
40
+ }
41
+ function buildCookies(config) {
42
+ const enabled = [];
43
+ if (config.cookies.essential) enabled.push("**Essential cookies** — required for the service to function");
44
+ if (config.cookies.analytics) enabled.push("**Analytics cookies** — help us understand how visitors interact with our service");
45
+ if (config.cookies.marketing) enabled.push("**Marketing cookies** — used to deliver relevant advertisements");
46
+ return {
47
+ id: "cookies",
48
+ title: "Cookies and Tracking",
49
+ body: enabled.length > 0 ? `We use the following types of cookies and tracking technologies:\n\n${enabled.map((e) => `- ${e}`).join("\n")}` : "We do not use cookies or tracking technologies on our service."
50
+ };
51
+ }
52
+ function buildDataCollected(config) {
53
+ return {
54
+ id: "data-collected",
55
+ title: "Information We Collect",
56
+ body: `We collect the following categories of information:\n\n${Object.entries(config.dataCollected).map(([category, items]) => {
57
+ return `**${category}:**\n${items.map((item) => ` - ${item}`).join("\n")}`;
58
+ }).join("\n\n")}`
59
+ };
60
+ }
61
+ function buildDataRetention(config) {
62
+ return {
63
+ id: "data-retention",
64
+ title: "Data Retention",
65
+ body: `We retain your information for the following periods:\n\n${Object.entries(config.retention).map(([category, period]) => `- **${category}:** ${period}`).join("\n")}`
66
+ };
67
+ }
68
+ function buildGdprSupplement(config) {
69
+ if (!config.jurisdictions.includes("eu")) return null;
70
+ return {
71
+ id: "gdpr-supplement",
72
+ title: "GDPR Supplemental Disclosures",
73
+ body: `This section applies to individuals in the European Economic Area (EEA) under the General Data Protection Regulation (GDPR).
74
+
75
+ **Data Controller:** ${config.company.legalName}, ${config.company.address}
76
+
77
+ **Your GDPR Rights:** In addition to the rights listed above, you have the right to lodge a complaint with your local data protection authority if you believe we have not handled your data in accordance with applicable law.
78
+
79
+ **International Transfers:** If we transfer your personal data outside the EEA, we ensure adequate safeguards are in place in accordance with GDPR requirements.`
80
+ };
81
+ }
82
+ function buildIntroduction$1(config) {
83
+ return {
84
+ id: "introduction",
85
+ title: "Introduction",
86
+ body: `This Privacy Policy describes how ${config.company.name} ("we", "us", or "our") collects, uses, and shares information about you when you use our services.
87
+
88
+ **Effective Date:** ${config.effectiveDate}
89
+
90
+ If you have questions about this policy, please contact us at ${config.company.contact}.`
91
+ };
92
+ }
93
+ function buildLegalBasis(config) {
94
+ if (!config.jurisdictions.includes("eu")) return null;
95
+ return {
96
+ id: "legal-basis",
97
+ title: "Legal Basis for Processing",
98
+ body: `We process your personal data under the following legal basis:\n\n${config.legalBasis}`
99
+ };
100
+ }
101
+ function buildThirdParties(config) {
102
+ const lines = config.thirdParties.map((tp) => `- **${tp.name}** — ${tp.purpose}`);
103
+ return {
104
+ id: "third-parties",
105
+ title: "Third-Party Services",
106
+ body: lines.length > 0 ? `We share data with the following third-party services:\n\n${lines.join("\n")}` : "We do not share your data with third-party services."
107
+ };
108
+ }
109
+ const RIGHTS_LABELS = {
110
+ access: "Right to access your personal data",
111
+ rectification: "Right to correct inaccurate data",
112
+ erasure: "Right to request deletion of your data",
113
+ portability: "Right to receive your data in a portable format",
114
+ restriction: "Right to restrict how we process your data",
115
+ objection: "Right to object to processing",
116
+ opt_out_sale: "Right to opt out of the sale of your personal information",
117
+ non_discrimination: "Right to non-discriminatory treatment for exercising your rights"
118
+ };
119
+ function buildUserRights(config) {
120
+ return {
121
+ id: "user-rights",
122
+ title: "Your Rights",
123
+ body: `You have the following rights regarding your personal data:\n\n${config.userRights.map((right) => {
124
+ return `- ${RIGHTS_LABELS[right] ?? right}`;
125
+ }).join("\n")}`
126
+ };
127
+ }
128
+ const SECTION_BUILDERS$1 = [
129
+ buildIntroduction$1,
130
+ buildDataCollected,
131
+ buildLegalBasis,
132
+ buildDataRetention,
133
+ buildCookies,
134
+ buildThirdParties,
135
+ buildUserRights,
136
+ buildGdprSupplement,
137
+ buildCcpaSupplement,
138
+ buildContact$1
139
+ ];
140
+ function compilePrivacyPolicy(config, options = { formats: ["markdown"] }) {
141
+ const sections = SECTION_BUILDERS$1.map((builder) => builder(config)).filter((s) => s !== null);
142
+ return options.formats.map((format) => {
143
+ switch (format) {
144
+ case "markdown": return {
145
+ format,
146
+ content: renderMarkdown(sections),
147
+ sections
148
+ };
149
+ case "html": return {
150
+ format,
151
+ content: renderHTML(sections),
152
+ sections
153
+ };
154
+ case "pdf": throw new Error("pdf format is not yet implemented");
155
+ case "jsx": throw new Error("jsx format is not yet implemented");
156
+ default: throw new Error(`Unsupported format: ${format}`);
157
+ }
158
+ });
159
+ }
160
+ function buildAcceptance(config) {
161
+ return {
162
+ id: "tos-acceptance",
163
+ title: "Acceptance of Terms",
164
+ body: `By accessing or using our services, you agree to be bound by these Terms. You accept these Terms by:\n\n${config.acceptance.methods.map((m) => `- ${m}`).join("\n")}\n\nIf you do not agree to these Terms, you may not use our services.`
165
+ };
166
+ }
167
+ function buildAccounts(config) {
168
+ if (!config.accounts) return null;
169
+ const { registrationRequired, userResponsibleForCredentials, companyCanTerminate } = config.accounts;
170
+ const lines = [];
171
+ if (registrationRequired) lines.push("You must create an account to access certain features of our services. You agree to provide accurate, current, and complete information during registration.");
172
+ if (userResponsibleForCredentials) lines.push("You are responsible for maintaining the confidentiality of your account credentials and for all activities that occur under your account. You must notify us immediately of any unauthorized use of your account.");
173
+ if (companyCanTerminate) lines.push(`${config.company.name} reserves the right to suspend or terminate your account at any time, with or without notice, for any reason including violation of these Terms.`);
174
+ return {
175
+ id: "tos-accounts",
176
+ title: "Accounts",
177
+ body: lines.join("\n\n")
178
+ };
179
+ }
180
+ function buildAvailability(config) {
181
+ if (!config.availability) return null;
182
+ const lines = [];
183
+ if (config.availability.noUptimeGuarantee) lines.push("We do not guarantee that our services will be available at all times. Our services may be subject to interruptions, delays, or errors.");
184
+ if (config.availability.maintenanceWindows) lines.push(`**Maintenance:** ${config.availability.maintenanceWindows}`);
185
+ return {
186
+ id: "tos-availability",
187
+ title: "Service Availability",
188
+ body: lines.join("\n\n")
189
+ };
190
+ }
191
+ function buildChangesToTerms(config) {
192
+ if (!config.changesPolicy) return null;
193
+ const { noticeMethod, noticePeriodDays } = config.changesPolicy;
194
+ return {
195
+ id: "tos-changes",
196
+ title: "Changes to These Terms",
197
+ body: `We may update these Terms from time to time. We will notify you of material changes via ${noticeMethod}${noticePeriodDays ? ` at least **${noticePeriodDays} days** before they take effect` : " before they take effect"}. Your continued use of our services after changes become effective constitutes your acceptance of the revised Terms.`
198
+ };
199
+ }
200
+ function buildContact(config) {
201
+ return {
202
+ id: "tos-contact",
203
+ title: "Contact Us",
204
+ body: `If you have any questions about these Terms, please contact us at:
205
+
206
+ **${config.company.legalName}**
207
+ ${config.company.address}
208
+ ${config.company.contact}`
209
+ };
210
+ }
211
+ function buildDisclaimers(config) {
212
+ if (!config.disclaimers) return null;
213
+ const lines = [];
214
+ if (config.disclaimers.serviceProvidedAsIs) lines.push("OUR SERVICES ARE PROVIDED \"AS IS\" AND \"AS AVAILABLE\" WITHOUT WARRANTIES OF ANY KIND.");
215
+ if (config.disclaimers.noWarranties) lines.push(`${config.company.legalName} EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.`);
216
+ return {
217
+ id: "tos-disclaimers",
218
+ title: "Disclaimer of Warranties",
219
+ body: lines.join("\n\n")
220
+ };
221
+ }
222
+ function buildDisputeResolution(config) {
223
+ if (!config.disputeResolution) return null;
224
+ const { method, venue, classActionWaiver } = config.disputeResolution;
225
+ const lines = [{
226
+ arbitration: "Any disputes arising out of or relating to these Terms or our services shall be resolved by binding arbitration rather than in court.",
227
+ litigation: "Any disputes arising out of or relating to these Terms or our services shall be resolved through litigation in a court of competent jurisdiction.",
228
+ mediation: "Any disputes arising out of or relating to these Terms or our services shall first be submitted to non-binding mediation before pursuing other remedies."
229
+ }[method] ?? "Disputes arising out of or relating to these Terms shall be resolved as described below."];
230
+ if (venue) lines.push(`**Venue:** ${venue}`);
231
+ if (classActionWaiver) lines.push("**Class Action Waiver:** You agree that any dispute resolution proceedings will be conducted only on an individual basis and not in a class, consolidated, or representative action.");
232
+ return {
233
+ id: "tos-dispute-resolution",
234
+ title: "Dispute Resolution",
235
+ body: lines.join("\n\n")
236
+ };
237
+ }
238
+ function buildEligibility(config) {
239
+ if (!config.eligibility) return null;
240
+ const { minimumAge, jurisdictionRestrictions } = config.eligibility;
241
+ let body = `You must be at least **${minimumAge} years old** to use our services. By using our services, you represent and warrant that you meet this age requirement.`;
242
+ if (jurisdictionRestrictions && jurisdictionRestrictions.length > 0) {
243
+ const list = jurisdictionRestrictions.map((r) => `- ${r}`).join("\n");
244
+ body += `\n\nOur services are not available in the following jurisdictions:\n\n${list}`;
245
+ }
246
+ return {
247
+ id: "tos-eligibility",
248
+ title: "Eligibility",
249
+ body
250
+ };
251
+ }
252
+ function buildGoverningLaw(config) {
253
+ return {
254
+ id: "tos-governing-law",
255
+ title: "Governing Law",
256
+ body: `These Terms shall be governed by and construed in accordance with the laws of **${config.governingLaw.jurisdiction}**, without regard to its conflict of law provisions.`
257
+ };
258
+ }
259
+ function buildIndemnification(config) {
260
+ if (!config.indemnification) return null;
261
+ const lines = [];
262
+ if (config.indemnification.userIndemnifiesCompany) lines.push(`You agree to indemnify and hold harmless ${config.company.legalName} and its officers, directors, employees, and agents from and against any claims, liabilities, damages, losses, and expenses arising out of or in any way connected with your access to or use of our services.`);
263
+ if (config.indemnification.scope) lines.push(`**Scope:** ${config.indemnification.scope}`);
264
+ return {
265
+ id: "tos-indemnification",
266
+ title: "Indemnification",
267
+ body: lines.join("\n\n")
268
+ };
269
+ }
270
+ function buildIntellectualProperty(config) {
271
+ if (!config.intellectualProperty) return null;
272
+ const { companyOwnsService, usersMayNotCopy } = config.intellectualProperty;
273
+ const lines = [];
274
+ if (companyOwnsService) lines.push(`The services and all content, features, and functionality (including but not limited to text, graphics, logos, and software) are owned by ${config.company.legalName} and are protected by intellectual property laws.`);
275
+ if (usersMayNotCopy) lines.push("You may not copy, modify, distribute, sell, or lease any part of our services or included software, nor may you reverse engineer or attempt to extract the source code of that software.");
276
+ return {
277
+ id: "tos-intellectual-property",
278
+ title: "Intellectual Property",
279
+ body: lines.join("\n\n")
280
+ };
281
+ }
282
+ function buildIntroduction(config) {
283
+ const privacyLine = config.privacyPolicyUrl ? `\n\nFor information about how we collect and use your data, please review our [Privacy Policy](${config.privacyPolicyUrl}).` : "";
284
+ return {
285
+ id: "tos-introduction",
286
+ title: "Terms of Service",
287
+ body: `These Terms of Service ("Terms") govern your access to and use of the services provided by ${config.company.name} ("${config.company.name}", "we", "us", or "our"). By using our services, you agree to these Terms.
288
+
289
+ **Effective Date:** ${config.effectiveDate}${privacyLine}`
290
+ };
291
+ }
292
+ function buildLimitationOfLiability(config) {
293
+ if (!config.limitationOfLiability) return null;
294
+ const lines = [];
295
+ if (config.limitationOfLiability.excludesIndirectDamages) lines.push(`TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ${config.company.legalName.toUpperCase()} SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS OR REVENUES, WHETHER INCURRED DIRECTLY OR INDIRECTLY, OR ANY LOSS OF DATA, USE, GOODWILL, OR OTHER INTANGIBLE LOSSES.`);
296
+ if (config.limitationOfLiability.liabilityCap) lines.push(`**Liability Cap:** ${config.limitationOfLiability.liabilityCap}`);
297
+ return {
298
+ id: "tos-limitation-of-liability",
299
+ title: "Limitation of Liability",
300
+ body: lines.join("\n\n")
301
+ };
302
+ }
303
+ function buildPayments(config) {
304
+ if (!config.payments || !config.payments.hasPaidFeatures) return null;
305
+ const lines = ["Some features of our services require payment. By selecting a paid plan, you agree to pay all applicable fees."];
306
+ if (config.payments.refundPolicy) lines.push(`**Refunds:** ${config.payments.refundPolicy}`);
307
+ if (config.payments.priceChangesNotice) lines.push(`**Price Changes:** ${config.payments.priceChangesNotice}`);
308
+ return {
309
+ id: "tos-payments",
310
+ title: "Payments and Billing",
311
+ body: lines.join("\n\n")
312
+ };
313
+ }
314
+ function buildProhibitedUse(config) {
315
+ if (!config.prohibitedUses || config.prohibitedUses.length === 0) return null;
316
+ return {
317
+ id: "tos-prohibited-use",
318
+ title: "Prohibited Uses",
319
+ body: `You agree not to use our services for any of the following purposes:\n\n${config.prohibitedUses.map((u) => `- ${u}`).join("\n")}`
320
+ };
321
+ }
322
+ function buildTermination(config) {
323
+ if (!config.termination) return null;
324
+ const { companyCanTerminate, userCanTerminate, effectOfTermination } = config.termination;
325
+ const lines = [];
326
+ if (companyCanTerminate) lines.push(`${config.company.name} may suspend or terminate your access to the services at any time, with or without cause, and with or without notice.`);
327
+ if (userCanTerminate) lines.push("You may terminate your account at any time by discontinuing use of our services or by contacting us to close your account.");
328
+ if (effectOfTermination) lines.push(`**Effect of Termination:** ${effectOfTermination}`);
329
+ return {
330
+ id: "tos-termination",
331
+ title: "Termination",
332
+ body: lines.join("\n\n")
333
+ };
334
+ }
335
+ function buildThirdPartyServices(config) {
336
+ if (!config.thirdPartyServices || config.thirdPartyServices.length === 0) return null;
337
+ return {
338
+ id: "tos-third-party-services",
339
+ title: "Third-Party Services",
340
+ body: `Our services may integrate with or link to third-party services. Your use of those services is governed by their own terms and policies.\n\n${config.thirdPartyServices.map((s) => `- **${s.name}** — ${s.purpose}`).join("\n")}`
341
+ };
342
+ }
343
+ function buildUserContent(config) {
344
+ if (!config.userContent) return null;
345
+ const { usersOwnContent, licenseGrantedToCompany, licenseDescription, companyCanRemoveContent } = config.userContent;
346
+ const lines = [];
347
+ if (usersOwnContent) lines.push("You retain ownership of any content you submit, post, or display on or through our services (\"User Content\").");
348
+ if (licenseGrantedToCompany) {
349
+ const desc = licenseDescription ? licenseDescription : "a worldwide, royalty-free, non-exclusive license to use, reproduce, modify, and distribute your User Content in connection with operating and improving our services";
350
+ lines.push(`By submitting User Content, you grant ${config.company.name} ${desc}.`);
351
+ }
352
+ if (companyCanRemoveContent) lines.push(`${config.company.name} reserves the right to remove any User Content that violates these Terms or that we find objectionable, at our sole discretion.`);
353
+ return {
354
+ id: "tos-user-content",
355
+ title: "User Content",
356
+ body: lines.join("\n\n")
357
+ };
358
+ }
359
+ const SECTION_BUILDERS = [
360
+ buildIntroduction,
361
+ buildAcceptance,
362
+ buildEligibility,
363
+ buildAccounts,
364
+ buildProhibitedUse,
365
+ buildUserContent,
366
+ buildIntellectualProperty,
367
+ buildPayments,
368
+ buildAvailability,
369
+ buildTermination,
370
+ buildDisclaimers,
371
+ buildLimitationOfLiability,
372
+ buildIndemnification,
373
+ buildThirdPartyServices,
374
+ buildDisputeResolution,
375
+ buildGoverningLaw,
376
+ buildChangesToTerms,
377
+ buildContact
378
+ ];
379
+ function compileTermsOfService(config, options = { formats: ["markdown"] }) {
380
+ const sections = SECTION_BUILDERS.map((builder) => builder(config)).filter((s) => s !== null);
381
+ return options.formats.map((format) => {
382
+ switch (format) {
383
+ case "markdown": return {
384
+ format,
385
+ content: renderMarkdown(sections),
386
+ sections
387
+ };
388
+ case "html": return {
389
+ format,
390
+ content: renderHTML(sections),
391
+ sections
392
+ };
393
+ case "pdf": throw new Error("pdf format is not yet implemented");
394
+ case "jsx": throw new Error("jsx format is not yet implemented");
395
+ default: throw new Error(`Unsupported format: ${format}`);
396
+ }
397
+ });
398
+ }
399
+ function validatePrivacyPolicy(config) {
400
+ const issues = [];
401
+ if (!config.effectiveDate) issues.push({
402
+ level: "error",
403
+ message: "effectiveDate is required"
404
+ });
405
+ if (!config.company.name) issues.push({
406
+ level: "error",
407
+ message: "company.name is required"
408
+ });
409
+ if (!config.company.legalName) issues.push({
410
+ level: "error",
411
+ message: "company.legalName is required"
412
+ });
413
+ if (!config.company.address) issues.push({
414
+ level: "error",
415
+ message: "company.address is required"
416
+ });
417
+ if (!config.company.contact) issues.push({
418
+ level: "error",
419
+ message: "company.contact is required"
420
+ });
421
+ if (Object.keys(config.dataCollected).length === 0) issues.push({
422
+ level: "error",
423
+ message: "dataCollected must have at least one entry"
424
+ });
425
+ if (config.userRights.length === 0) issues.push({
426
+ level: "warning",
427
+ message: "userRights is empty — consider listing applicable rights"
428
+ });
429
+ if (config.jurisdictions.includes("eu")) {
430
+ if (!config.legalBasis) issues.push({
431
+ level: "error",
432
+ message: "GDPR requires a legalBasis"
433
+ });
434
+ for (const right of [
435
+ "access",
436
+ "rectification",
437
+ "erasure",
438
+ "portability",
439
+ "restriction",
440
+ "objection"
441
+ ]) if (!config.userRights.includes(right)) issues.push({
442
+ level: "warning",
443
+ message: `GDPR recommends including the "${right}" right`
444
+ });
445
+ }
446
+ if (config.jurisdictions.includes("ca")) {
447
+ for (const right of [
448
+ "access",
449
+ "erasure",
450
+ "opt_out_sale",
451
+ "non_discrimination"
452
+ ]) if (!config.userRights.includes(right)) issues.push({
453
+ level: "warning",
454
+ message: `CCPA recommends including the "${right}" right`
455
+ });
456
+ }
457
+ return issues;
458
+ }
459
+ function validateTermsOfService(config) {
460
+ const issues = [];
461
+ if (!config.effectiveDate) issues.push({
462
+ level: "error",
463
+ message: "effectiveDate is required"
464
+ });
465
+ if (!config.company.name) issues.push({
466
+ level: "error",
467
+ message: "company.name is required"
468
+ });
469
+ if (!config.company.legalName) issues.push({
470
+ level: "error",
471
+ message: "company.legalName is required"
472
+ });
473
+ if (!config.company.address) issues.push({
474
+ level: "error",
475
+ message: "company.address is required"
476
+ });
477
+ if (!config.company.contact) issues.push({
478
+ level: "error",
479
+ message: "company.contact is required"
480
+ });
481
+ if (!config.governingLaw.jurisdiction) issues.push({
482
+ level: "error",
483
+ message: "governingLaw.jurisdiction is required"
484
+ });
485
+ if (!config.disclaimers) issues.push({
486
+ level: "warning",
487
+ message: "disclaimers is missing — consider adding a disclaimer of warranties"
488
+ });
489
+ if (!config.limitationOfLiability) issues.push({
490
+ level: "warning",
491
+ message: "limitationOfLiability is missing — consider adding a limitation of liability clause"
492
+ });
493
+ if (config.acceptance.methods.length === 0) issues.push({
494
+ level: "warning",
495
+ message: "acceptance.methods is empty — consider listing how users accept these Terms"
496
+ });
497
+ return issues;
498
+ }
499
+ function compilePolicy(input, options) {
500
+ switch (input.type) {
501
+ case "privacy": {
502
+ const { type: _, ...config } = input;
503
+ return compilePrivacyPolicy(config, options);
504
+ }
505
+ case "terms": {
506
+ const { type: _, ...config } = input;
507
+ return compileTermsOfService(config, options);
508
+ }
509
+ }
510
+ }
511
+ //#endregion
4
512
  //#region src/index.ts
5
513
  function detectType(filename) {
6
514
  return filename.includes("terms") ? "terms" : "privacy";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type {\n\tOutputFormat,\n\tPrivacyPolicyConfig,\n\tTermsOfServiceConfig,\n} from \"@openpolicy/core\";\nimport {\n\tcompilePolicy,\n\tvalidatePrivacyPolicy,\n\tvalidateTermsOfService,\n} from \"@openpolicy/core\";\nimport type { Plugin } from \"vite\";\n\nexport type PolicyConfigEntry =\n\t| string\n\t| { config: string; type?: \"privacy\" | \"terms\" };\n\nexport interface OpenPolicyOptions {\n\tconfigs?: PolicyConfigEntry[];\n\tconfig?: string;\n\tformats?: OutputFormat[];\n\toutDir?: string;\n\ttype?: \"privacy\" | \"terms\";\n}\n\nfunction detectType(filename: string): \"privacy\" | \"terms\" {\n\treturn filename.includes(\"terms\") ? \"terms\" : \"privacy\";\n}\n\nfunction normalizeEntries(\n\toptions: OpenPolicyOptions,\n): Array<{ configFile: string; type: \"privacy\" | \"terms\" }> {\n\tif (options.configs) {\n\t\treturn options.configs.map((entry) => {\n\t\t\tif (typeof entry === \"string\") {\n\t\t\t\treturn { configFile: entry, type: detectType(entry) };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tconfigFile: entry.config,\n\t\t\t\ttype: entry.type ?? detectType(entry.config),\n\t\t\t};\n\t\t});\n\t}\n\tconst configFile =\n\t\toptions.type === \"terms\" ? \"terms.config.ts\" : \"privacy.config.ts\";\n\treturn [\n\t\t{\n\t\t\tconfigFile: options.config ?? configFile,\n\t\t\ttype: options.type ?? \"privacy\",\n\t\t},\n\t];\n}\n\nconst PRIVACY_SCAFFOLD_TEMPLATE = `import { definePrivacyPolicy } from \"@openpolicy/sdk\";\n\nexport default definePrivacyPolicy({\n effectiveDate: \"${new Date().toISOString().slice(0, 10)}\",\n company: {\n name: \"Your Company\",\n legalName: \"Your Company, Inc.\",\n address: \"123 Main St, City, State, ZIP\",\n contact: \"privacy@yourcompany.com\",\n },\n dataCollected: {\n \"Personal Information\": [\"Full name\", \"Email address\"],\n },\n legalBasis: \"Legitimate interests and consent\",\n retention: {\n \"All personal data\": \"As long as necessary for the purposes described in this policy\",\n },\n cookies: { essential: true, analytics: false, marketing: false },\n thirdParties: [],\n userRights: [\"access\", \"erasure\"],\n jurisdictions: [\"us\"],\n});\n`;\n\nconst TERMS_SCAFFOLD_TEMPLATE = `import { defineTermsOfService } from \"@openpolicy/sdk\";\n\nexport default defineTermsOfService({\n effectiveDate: \"${new Date().toISOString().slice(0, 10)}\",\n company: {\n name: \"Your Company\",\n legalName: \"Your Company, Inc.\",\n address: \"123 Main St, City, State, ZIP\",\n contact: \"legal@yourcompany.com\",\n },\n acceptance: {\n methods: [\"using the service\", \"creating an account\"],\n },\n eligibility: {\n minimumAge: 13,\n },\n accounts: {\n registrationRequired: false,\n userResponsibleForCredentials: true,\n companyCanTerminate: true,\n },\n prohibitedUses: [\n \"Violating any applicable laws or regulations\",\n \"Infringing on intellectual property rights\",\n ],\n intellectualProperty: {\n companyOwnsService: true,\n usersMayNotCopy: true,\n },\n termination: {\n companyCanTerminate: true,\n userCanTerminate: true,\n },\n disclaimers: {\n serviceProvidedAsIs: true,\n noWarranties: true,\n },\n limitationOfLiability: {\n excludesIndirectDamages: true,\n },\n governingLaw: {\n jurisdiction: \"Delaware, USA\",\n },\n changesPolicy: {\n noticeMethod: \"email or prominent notice on our website\",\n noticePeriodDays: 30,\n },\n});\n`;\n\nexport async function writeScaffold(\n\tconfigPath: string,\n\ttype: \"privacy\" | \"terms\" = \"privacy\",\n): Promise<void> {\n\tconst template =\n\t\ttype === \"terms\" ? TERMS_SCAFFOLD_TEMPLATE : PRIVACY_SCAFFOLD_TEMPLATE;\n\tawait writeFile(configPath, template, \"utf8\");\n}\n\nexport async function generatePolicies(\n\tconfigPath: string,\n\toutDir: string,\n\tformats: OutputFormat[],\n\ttype: \"privacy\" | \"terms\" = \"privacy\",\n): Promise<void> {\n\tconst mod = await import(`${configPath}?t=${Date.now()}`);\n\tconst config =\n\t\t(mod as Record<string, unknown>)[\"default\"] ??\n\t\t(mod as Record<string, unknown>)[\"module.exports\"] ??\n\t\tmod;\n\n\tif (config === null || config === undefined || typeof config !== \"object\") {\n\t\tthrow new Error(\n\t\t\t`[openpolicy] Config must export a non-null object: ${configPath}`,\n\t\t);\n\t}\n\n\tconst issues =\n\t\ttype === \"terms\"\n\t\t\t? validateTermsOfService(config as TermsOfServiceConfig)\n\t\t\t: validatePrivacyPolicy(config as PrivacyPolicyConfig);\n\n\tfor (const issue of issues) {\n\t\tif (issue.level === \"error\") {\n\t\t\tthrow new Error(`[openpolicy] Validation error: ${issue.message}`);\n\t\t}\n\t\tconsole.warn(`[openpolicy] Warning: ${issue.message}`);\n\t}\n\n\tconst results = compilePolicy(\n\t\ttype === \"terms\"\n\t\t\t? { type: \"terms\", ...(config as TermsOfServiceConfig) }\n\t\t\t: { type: \"privacy\", ...(config as PrivacyPolicyConfig) },\n\t\t{ formats },\n\t);\n\n\tconst outputFilename =\n\t\ttype === \"terms\" ? \"terms-of-service\" : \"privacy-policy\";\n\n\tawait mkdir(outDir, { recursive: true });\n\n\tfor (const result of results) {\n\t\tconst ext = result.format === \"markdown\" ? \"md\" : result.format;\n\t\tawait writeFile(\n\t\t\tjoin(outDir, `${outputFilename}.${ext}`),\n\t\t\tresult.content,\n\t\t\t\"utf8\",\n\t\t);\n\t}\n}\n\nexport function openPolicy(options: OpenPolicyOptions = {}): Plugin {\n\tconst formats: OutputFormat[] = options.formats ?? [\"markdown\"];\n\tlet resolvedOutDir: string;\n\tlet resolvedEntries: Array<{ configPath: string; type: \"privacy\" | \"terms\" }>;\n\n\treturn {\n\t\tname: \"openpolicy\",\n\n\t\tconfigResolved(config) {\n\t\t\tresolvedOutDir = resolve(\n\t\t\t\tconfig.root,\n\t\t\t\toptions.outDir ?? \"public/policies\",\n\t\t\t);\n\t\t\tresolvedEntries = normalizeEntries(options).map((e) => ({\n\t\t\t\tconfigPath: resolve(config.root, e.configFile),\n\t\t\t\ttype: e.type,\n\t\t\t}));\n\t\t},\n\n\t\tasync buildStart() {\n\t\t\tfor (const entry of resolvedEntries) {\n\t\t\t\tconst configExists = await access(entry.configPath).then(\n\t\t\t\t\t() => true,\n\t\t\t\t\t() => false,\n\t\t\t\t);\n\t\t\t\tif (!configExists) {\n\t\t\t\t\tawait writeScaffold(entry.configPath, entry.type);\n\t\t\t\t\tconsole.log(`[openpolicy] Scaffolded config at ${entry.configPath}`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait generatePolicies(\n\t\t\t\t\tentry.configPath,\n\t\t\t\t\tresolvedOutDir,\n\t\t\t\t\tformats,\n\t\t\t\t\tentry.type,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tfor (const entry of resolvedEntries) {\n\t\t\t\tserver.watcher.add(entry.configPath);\n\t\t\t}\n\t\t\tserver.watcher.on(\"change\", async (path) => {\n\t\t\t\tconst entry = resolvedEntries.find((e) => e.configPath === path);\n\t\t\t\tif (!entry) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait generatePolicies(\n\t\t\t\t\t\tentry.configPath,\n\t\t\t\t\t\tresolvedOutDir,\n\t\t\t\t\t\tformats,\n\t\t\t\t\t\tentry.type,\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(\"[openpolicy] Policies regenerated\");\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(\"[openpolicy]\", err);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;AA0BA,SAAS,WAAW,UAAuC;AAC1D,QAAO,SAAS,SAAS,QAAQ,GAAG,UAAU;;AAG/C,SAAS,iBACR,SAC2D;AAC3D,KAAI,QAAQ,QACX,QAAO,QAAQ,QAAQ,KAAK,UAAU;AACrC,MAAI,OAAO,UAAU,SACpB,QAAO;GAAE,YAAY;GAAO,MAAM,WAAW,MAAM;GAAE;AAEtD,SAAO;GACN,YAAY,MAAM;GAClB,MAAM,MAAM,QAAQ,WAAW,MAAM,OAAO;GAC5C;GACA;CAEH,MAAM,aACL,QAAQ,SAAS,UAAU,oBAAoB;AAChD,QAAO,CACN;EACC,YAAY,QAAQ,UAAU;EAC9B,MAAM,QAAQ,QAAQ;EACtB,CACD;;AAGF,MAAM,4BAA4B;;;qCAGd,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;AAqB1D,MAAM,0BAA0B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BAAkB,iBAAiB,QAAQ,CAAC,KAAK,OAAO;IACvD,YAAY,QAAQ,OAAO,MAAM,EAAE,WAAW;IAC9C,MAAM,EAAE;IACR,EAAE;;EAGJ,MAAM,aAAa;AAClB,QAAK,MAAM,SAAS,iBAAiB;AAKpC,QAAI,CAJiB,MAAM,OAAO,MAAM,WAAW,CAAC,WAC7C,YACA,MACN,EACkB;AAClB,WAAM,cAAc,MAAM,YAAY,MAAM,KAAK;AACjD,aAAQ,IAAI,qCAAqC,MAAM,aAAa;AACpE;;AAED,UAAM,iBACL,MAAM,YACN,gBACA,SACA,MAAM,KACN;;;EAIH,gBAAgB,QAAQ;AACvB,QAAK,MAAM,SAAS,gBACnB,QAAO,QAAQ,IAAI,MAAM,WAAW;AAErC,UAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;IAC3C,MAAM,QAAQ,gBAAgB,MAAM,MAAM,EAAE,eAAe,KAAK;AAChE,QAAI,CAAC,MAAO;AACZ,QAAI;AACH,WAAM,iBACL,MAAM,YACN,gBACA,SACA,MAAM,KACN;AACD,aAAQ,IAAI,oCAAoC;aACxC,KAAK;AACb,aAAQ,MAAM,gBAAgB,IAAI;;KAElC;;EAEH"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../core/dist/index.js","../src/index.ts"],"sourcesContent":["import { marked } from \"marked\";\n//#region src/renderers/markdown.ts\nfunction renderMarkdown(sections) {\n\treturn sections.map((section) => `## ${section.title}\\n\\n${section.body}`).join(\"\\n\\n---\\n\\n\");\n}\n//#endregion\n//#region src/renderers/html.ts\nfunction renderHTML(sections) {\n\treturn marked(renderMarkdown(sections));\n}\n//#endregion\n//#region src/templates/privacy/ccpa-supplement.ts\nfunction buildCcpaSupplement(config) {\n\tif (!config.jurisdictions.includes(\"ca\")) return null;\n\treturn {\n\t\tid: \"ccpa-supplement\",\n\t\ttitle: \"California Privacy Rights (CCPA)\",\n\t\tbody: `This section applies to California residents under the California Consumer Privacy Act (CCPA) and the California Privacy Rights Act (CPRA).\n\n**Categories of Personal Information Collected:** We collect the categories of personal information described in the \"Information We Collect\" section above.\n\n**Your California Rights:**\n- **Right to Know:** You may request information about the personal information we have collected about you, including the categories of sources, the business purpose for collection, and the categories of third parties with whom we share information.\n- **Right to Delete:** You may request deletion of personal information we have collected from you, subject to certain exceptions.\n- **Right to Opt-Out:** You may opt out of the sale or sharing of your personal information.\n- **Right to Non-Discrimination:** We will not discriminate against you for exercising your California privacy rights.\n\nTo exercise your rights, contact us at ${config.company.contact}.`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/contact.ts\nfunction buildContact$1(config) {\n\treturn {\n\t\tid: \"contact\",\n\t\ttitle: \"Contact Us\",\n\t\tbody: `If you have questions or concerns about this Privacy Policy or our data practices, please contact us:\n\n**${config.company.legalName}**\n${config.company.address}\n\nEmail: ${config.company.contact}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/cookies.ts\nfunction buildCookies(config) {\n\tconst enabled = [];\n\tif (config.cookies.essential) enabled.push(\"**Essential cookies** — required for the service to function\");\n\tif (config.cookies.analytics) enabled.push(\"**Analytics cookies** — help us understand how visitors interact with our service\");\n\tif (config.cookies.marketing) enabled.push(\"**Marketing cookies** — used to deliver relevant advertisements\");\n\treturn {\n\t\tid: \"cookies\",\n\t\ttitle: \"Cookies and Tracking\",\n\t\tbody: enabled.length > 0 ? `We use the following types of cookies and tracking technologies:\\n\\n${enabled.map((e) => `- ${e}`).join(\"\\n\")}` : \"We do not use cookies or tracking technologies on our service.\"\n\t};\n}\n//#endregion\n//#region src/templates/privacy/data-collected.ts\nfunction buildDataCollected(config) {\n\treturn {\n\t\tid: \"data-collected\",\n\t\ttitle: \"Information We Collect\",\n\t\tbody: `We collect the following categories of information:\\n\\n${Object.entries(config.dataCollected).map(([category, items]) => {\n\t\t\treturn `**${category}:**\\n${items.map((item) => ` - ${item}`).join(\"\\n\")}`;\n\t\t}).join(\"\\n\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/data-retention.ts\nfunction buildDataRetention(config) {\n\treturn {\n\t\tid: \"data-retention\",\n\t\ttitle: \"Data Retention\",\n\t\tbody: `We retain your information for the following periods:\\n\\n${Object.entries(config.retention).map(([category, period]) => `- **${category}:** ${period}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/gdpr-supplement.ts\nfunction buildGdprSupplement(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn {\n\t\tid: \"gdpr-supplement\",\n\t\ttitle: \"GDPR Supplemental Disclosures\",\n\t\tbody: `This section applies to individuals in the European Economic Area (EEA) under the General Data Protection Regulation (GDPR).\n\n**Data Controller:** ${config.company.legalName}, ${config.company.address}\n\n**Your GDPR Rights:** In addition to the rights listed above, you have the right to lodge a complaint with your local data protection authority if you believe we have not handled your data in accordance with applicable law.\n\n**International Transfers:** If we transfer your personal data outside the EEA, we ensure adequate safeguards are in place in accordance with GDPR requirements.`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/introduction.ts\nfunction buildIntroduction$1(config) {\n\treturn {\n\t\tid: \"introduction\",\n\t\ttitle: \"Introduction\",\n\t\tbody: `This Privacy Policy describes how ${config.company.name} (\"we\", \"us\", or \"our\") collects, uses, and shares information about you when you use our services.\n\n**Effective Date:** ${config.effectiveDate}\n\nIf you have questions about this policy, please contact us at ${config.company.contact}.`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/legal-basis.ts\nfunction buildLegalBasis(config) {\n\tif (!config.jurisdictions.includes(\"eu\")) return null;\n\treturn {\n\t\tid: \"legal-basis\",\n\t\ttitle: \"Legal Basis for Processing\",\n\t\tbody: `We process your personal data under the following legal basis:\\n\\n${config.legalBasis}`\n\t};\n}\n//#endregion\n//#region src/templates/privacy/third-parties.ts\nfunction buildThirdParties(config) {\n\tconst lines = config.thirdParties.map((tp) => `- **${tp.name}** — ${tp.purpose}`);\n\treturn {\n\t\tid: \"third-parties\",\n\t\ttitle: \"Third-Party Services\",\n\t\tbody: lines.length > 0 ? `We share data with the following third-party services:\\n\\n${lines.join(\"\\n\")}` : \"We do not share your data with third-party services.\"\n\t};\n}\n//#endregion\n//#region src/templates/privacy/user-rights.ts\nconst RIGHTS_LABELS = {\n\taccess: \"Right to access your personal data\",\n\trectification: \"Right to correct inaccurate data\",\n\terasure: \"Right to request deletion of your data\",\n\tportability: \"Right to receive your data in a portable format\",\n\trestriction: \"Right to restrict how we process your data\",\n\tobjection: \"Right to object to processing\",\n\topt_out_sale: \"Right to opt out of the sale of your personal information\",\n\tnon_discrimination: \"Right to non-discriminatory treatment for exercising your rights\"\n};\nfunction buildUserRights(config) {\n\treturn {\n\t\tid: \"user-rights\",\n\t\ttitle: \"Your Rights\",\n\t\tbody: `You have the following rights regarding your personal data:\\n\\n${config.userRights.map((right) => {\n\t\t\treturn `- ${RIGHTS_LABELS[right] ?? right}`;\n\t\t}).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/privacy.ts\nconst SECTION_BUILDERS$1 = [\n\tbuildIntroduction$1,\n\tbuildDataCollected,\n\tbuildLegalBasis,\n\tbuildDataRetention,\n\tbuildCookies,\n\tbuildThirdParties,\n\tbuildUserRights,\n\tbuildGdprSupplement,\n\tbuildCcpaSupplement,\n\tbuildContact$1\n];\nfunction compilePrivacyPolicy(config, options = { formats: [\"markdown\"] }) {\n\tconst sections = SECTION_BUILDERS$1.map((builder) => builder(config)).filter((s) => s !== null);\n\treturn options.formats.map((format) => {\n\t\tswitch (format) {\n\t\t\tcase \"markdown\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderMarkdown(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"html\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderHTML(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"pdf\": throw new Error(\"pdf format is not yet implemented\");\n\t\t\tcase \"jsx\": throw new Error(\"jsx format is not yet implemented\");\n\t\t\tdefault: throw new Error(`Unsupported format: ${format}`);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/templates/terms/acceptance.ts\nfunction buildAcceptance(config) {\n\treturn {\n\t\tid: \"tos-acceptance\",\n\t\ttitle: \"Acceptance of Terms\",\n\t\tbody: `By accessing or using our services, you agree to be bound by these Terms. You accept these Terms by:\\n\\n${config.acceptance.methods.map((m) => `- ${m}`).join(\"\\n\")}\\n\\nIf you do not agree to these Terms, you may not use our services.`\n\t};\n}\n//#endregion\n//#region src/templates/terms/accounts.ts\nfunction buildAccounts(config) {\n\tif (!config.accounts) return null;\n\tconst { registrationRequired, userResponsibleForCredentials, companyCanTerminate } = config.accounts;\n\tconst lines = [];\n\tif (registrationRequired) lines.push(\"You must create an account to access certain features of our services. You agree to provide accurate, current, and complete information during registration.\");\n\tif (userResponsibleForCredentials) lines.push(\"You are responsible for maintaining the confidentiality of your account credentials and for all activities that occur under your account. You must notify us immediately of any unauthorized use of your account.\");\n\tif (companyCanTerminate) lines.push(`${config.company.name} reserves the right to suspend or terminate your account at any time, with or without notice, for any reason including violation of these Terms.`);\n\treturn {\n\t\tid: \"tos-accounts\",\n\t\ttitle: \"Accounts\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/availability.ts\nfunction buildAvailability(config) {\n\tif (!config.availability) return null;\n\tconst lines = [];\n\tif (config.availability.noUptimeGuarantee) lines.push(\"We do not guarantee that our services will be available at all times. Our services may be subject to interruptions, delays, or errors.\");\n\tif (config.availability.maintenanceWindows) lines.push(`**Maintenance:** ${config.availability.maintenanceWindows}`);\n\treturn {\n\t\tid: \"tos-availability\",\n\t\ttitle: \"Service Availability\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/changes-to-terms.ts\nfunction buildChangesToTerms(config) {\n\tif (!config.changesPolicy) return null;\n\tconst { noticeMethod, noticePeriodDays } = config.changesPolicy;\n\treturn {\n\t\tid: \"tos-changes\",\n\t\ttitle: \"Changes to These Terms\",\n\t\tbody: `We may update these Terms from time to time. We will notify you of material changes via ${noticeMethod}${noticePeriodDays ? ` at least **${noticePeriodDays} days** before they take effect` : \" before they take effect\"}. Your continued use of our services after changes become effective constitutes your acceptance of the revised Terms.`\n\t};\n}\n//#endregion\n//#region src/templates/terms/contact.ts\nfunction buildContact(config) {\n\treturn {\n\t\tid: \"tos-contact\",\n\t\ttitle: \"Contact Us\",\n\t\tbody: `If you have any questions about these Terms, please contact us at:\n\n**${config.company.legalName}**\n${config.company.address}\n${config.company.contact}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/disclaimers.ts\nfunction buildDisclaimers(config) {\n\tif (!config.disclaimers) return null;\n\tconst lines = [];\n\tif (config.disclaimers.serviceProvidedAsIs) lines.push(\"OUR SERVICES ARE PROVIDED \\\"AS IS\\\" AND \\\"AS AVAILABLE\\\" WITHOUT WARRANTIES OF ANY KIND.\");\n\tif (config.disclaimers.noWarranties) lines.push(`${config.company.legalName} EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.`);\n\treturn {\n\t\tid: \"tos-disclaimers\",\n\t\ttitle: \"Disclaimer of Warranties\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/dispute-resolution.ts\nfunction buildDisputeResolution(config) {\n\tif (!config.disputeResolution) return null;\n\tconst { method, venue, classActionWaiver } = config.disputeResolution;\n\tconst lines = [{\n\t\tarbitration: \"Any disputes arising out of or relating to these Terms or our services shall be resolved by binding arbitration rather than in court.\",\n\t\tlitigation: \"Any disputes arising out of or relating to these Terms or our services shall be resolved through litigation in a court of competent jurisdiction.\",\n\t\tmediation: \"Any disputes arising out of or relating to these Terms or our services shall first be submitted to non-binding mediation before pursuing other remedies.\"\n\t}[method] ?? \"Disputes arising out of or relating to these Terms shall be resolved as described below.\"];\n\tif (venue) lines.push(`**Venue:** ${venue}`);\n\tif (classActionWaiver) lines.push(\"**Class Action Waiver:** You agree that any dispute resolution proceedings will be conducted only on an individual basis and not in a class, consolidated, or representative action.\");\n\treturn {\n\t\tid: \"tos-dispute-resolution\",\n\t\ttitle: \"Dispute Resolution\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/eligibility.ts\nfunction buildEligibility(config) {\n\tif (!config.eligibility) return null;\n\tconst { minimumAge, jurisdictionRestrictions } = config.eligibility;\n\tlet body = `You must be at least **${minimumAge} years old** to use our services. By using our services, you represent and warrant that you meet this age requirement.`;\n\tif (jurisdictionRestrictions && jurisdictionRestrictions.length > 0) {\n\t\tconst list = jurisdictionRestrictions.map((r) => `- ${r}`).join(\"\\n\");\n\t\tbody += `\\n\\nOur services are not available in the following jurisdictions:\\n\\n${list}`;\n\t}\n\treturn {\n\t\tid: \"tos-eligibility\",\n\t\ttitle: \"Eligibility\",\n\t\tbody\n\t};\n}\n//#endregion\n//#region src/templates/terms/governing-law.ts\nfunction buildGoverningLaw(config) {\n\treturn {\n\t\tid: \"tos-governing-law\",\n\t\ttitle: \"Governing Law\",\n\t\tbody: `These Terms shall be governed by and construed in accordance with the laws of **${config.governingLaw.jurisdiction}**, without regard to its conflict of law provisions.`\n\t};\n}\n//#endregion\n//#region src/templates/terms/indemnification.ts\nfunction buildIndemnification(config) {\n\tif (!config.indemnification) return null;\n\tconst lines = [];\n\tif (config.indemnification.userIndemnifiesCompany) lines.push(`You agree to indemnify and hold harmless ${config.company.legalName} and its officers, directors, employees, and agents from and against any claims, liabilities, damages, losses, and expenses arising out of or in any way connected with your access to or use of our services.`);\n\tif (config.indemnification.scope) lines.push(`**Scope:** ${config.indemnification.scope}`);\n\treturn {\n\t\tid: \"tos-indemnification\",\n\t\ttitle: \"Indemnification\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/intellectual-property.ts\nfunction buildIntellectualProperty(config) {\n\tif (!config.intellectualProperty) return null;\n\tconst { companyOwnsService, usersMayNotCopy } = config.intellectualProperty;\n\tconst lines = [];\n\tif (companyOwnsService) lines.push(`The services and all content, features, and functionality (including but not limited to text, graphics, logos, and software) are owned by ${config.company.legalName} and are protected by intellectual property laws.`);\n\tif (usersMayNotCopy) lines.push(\"You may not copy, modify, distribute, sell, or lease any part of our services or included software, nor may you reverse engineer or attempt to extract the source code of that software.\");\n\treturn {\n\t\tid: \"tos-intellectual-property\",\n\t\ttitle: \"Intellectual Property\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/introduction.ts\nfunction buildIntroduction(config) {\n\tconst privacyLine = config.privacyPolicyUrl ? `\\n\\nFor information about how we collect and use your data, please review our [Privacy Policy](${config.privacyPolicyUrl}).` : \"\";\n\treturn {\n\t\tid: \"tos-introduction\",\n\t\ttitle: \"Terms of Service\",\n\t\tbody: `These Terms of Service (\"Terms\") govern your access to and use of the services provided by ${config.company.name} (\"${config.company.name}\", \"we\", \"us\", or \"our\"). By using our services, you agree to these Terms.\n\n**Effective Date:** ${config.effectiveDate}${privacyLine}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/limitation-of-liability.ts\nfunction buildLimitationOfLiability(config) {\n\tif (!config.limitationOfLiability) return null;\n\tconst lines = [];\n\tif (config.limitationOfLiability.excludesIndirectDamages) lines.push(`TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ${config.company.legalName.toUpperCase()} SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS OR REVENUES, WHETHER INCURRED DIRECTLY OR INDIRECTLY, OR ANY LOSS OF DATA, USE, GOODWILL, OR OTHER INTANGIBLE LOSSES.`);\n\tif (config.limitationOfLiability.liabilityCap) lines.push(`**Liability Cap:** ${config.limitationOfLiability.liabilityCap}`);\n\treturn {\n\t\tid: \"tos-limitation-of-liability\",\n\t\ttitle: \"Limitation of Liability\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/payments.ts\nfunction buildPayments(config) {\n\tif (!config.payments || !config.payments.hasPaidFeatures) return null;\n\tconst lines = [\"Some features of our services require payment. By selecting a paid plan, you agree to pay all applicable fees.\"];\n\tif (config.payments.refundPolicy) lines.push(`**Refunds:** ${config.payments.refundPolicy}`);\n\tif (config.payments.priceChangesNotice) lines.push(`**Price Changes:** ${config.payments.priceChangesNotice}`);\n\treturn {\n\t\tid: \"tos-payments\",\n\t\ttitle: \"Payments and Billing\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/prohibited-use.ts\nfunction buildProhibitedUse(config) {\n\tif (!config.prohibitedUses || config.prohibitedUses.length === 0) return null;\n\treturn {\n\t\tid: \"tos-prohibited-use\",\n\t\ttitle: \"Prohibited Uses\",\n\t\tbody: `You agree not to use our services for any of the following purposes:\\n\\n${config.prohibitedUses.map((u) => `- ${u}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/termination.ts\nfunction buildTermination(config) {\n\tif (!config.termination) return null;\n\tconst { companyCanTerminate, userCanTerminate, effectOfTermination } = config.termination;\n\tconst lines = [];\n\tif (companyCanTerminate) lines.push(`${config.company.name} may suspend or terminate your access to the services at any time, with or without cause, and with or without notice.`);\n\tif (userCanTerminate) lines.push(\"You may terminate your account at any time by discontinuing use of our services or by contacting us to close your account.\");\n\tif (effectOfTermination) lines.push(`**Effect of Termination:** ${effectOfTermination}`);\n\treturn {\n\t\tid: \"tos-termination\",\n\t\ttitle: \"Termination\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/templates/terms/third-party-services.ts\nfunction buildThirdPartyServices(config) {\n\tif (!config.thirdPartyServices || config.thirdPartyServices.length === 0) return null;\n\treturn {\n\t\tid: \"tos-third-party-services\",\n\t\ttitle: \"Third-Party Services\",\n\t\tbody: `Our services may integrate with or link to third-party services. Your use of those services is governed by their own terms and policies.\\n\\n${config.thirdPartyServices.map((s) => `- **${s.name}** — ${s.purpose}`).join(\"\\n\")}`\n\t};\n}\n//#endregion\n//#region src/templates/terms/user-content.ts\nfunction buildUserContent(config) {\n\tif (!config.userContent) return null;\n\tconst { usersOwnContent, licenseGrantedToCompany, licenseDescription, companyCanRemoveContent } = config.userContent;\n\tconst lines = [];\n\tif (usersOwnContent) lines.push(\"You retain ownership of any content you submit, post, or display on or through our services (\\\"User Content\\\").\");\n\tif (licenseGrantedToCompany) {\n\t\tconst desc = licenseDescription ? licenseDescription : \"a worldwide, royalty-free, non-exclusive license to use, reproduce, modify, and distribute your User Content in connection with operating and improving our services\";\n\t\tlines.push(`By submitting User Content, you grant ${config.company.name} ${desc}.`);\n\t}\n\tif (companyCanRemoveContent) lines.push(`${config.company.name} reserves the right to remove any User Content that violates these Terms or that we find objectionable, at our sole discretion.`);\n\treturn {\n\t\tid: \"tos-user-content\",\n\t\ttitle: \"User Content\",\n\t\tbody: lines.join(\"\\n\\n\")\n\t};\n}\n//#endregion\n//#region src/terms.ts\nconst SECTION_BUILDERS = [\n\tbuildIntroduction,\n\tbuildAcceptance,\n\tbuildEligibility,\n\tbuildAccounts,\n\tbuildProhibitedUse,\n\tbuildUserContent,\n\tbuildIntellectualProperty,\n\tbuildPayments,\n\tbuildAvailability,\n\tbuildTermination,\n\tbuildDisclaimers,\n\tbuildLimitationOfLiability,\n\tbuildIndemnification,\n\tbuildThirdPartyServices,\n\tbuildDisputeResolution,\n\tbuildGoverningLaw,\n\tbuildChangesToTerms,\n\tbuildContact\n];\nfunction compileTermsOfService(config, options = { formats: [\"markdown\"] }) {\n\tconst sections = SECTION_BUILDERS.map((builder) => builder(config)).filter((s) => s !== null);\n\treturn options.formats.map((format) => {\n\t\tswitch (format) {\n\t\t\tcase \"markdown\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderMarkdown(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"html\": return {\n\t\t\t\tformat,\n\t\t\t\tcontent: renderHTML(sections),\n\t\t\t\tsections\n\t\t\t};\n\t\t\tcase \"pdf\": throw new Error(\"pdf format is not yet implemented\");\n\t\t\tcase \"jsx\": throw new Error(\"jsx format is not yet implemented\");\n\t\t\tdefault: throw new Error(`Unsupported format: ${format}`);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/validate.ts\nfunction validatePrivacyPolicy(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tif (Object.keys(config.dataCollected).length === 0) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"dataCollected must have at least one entry\"\n\t});\n\tif (config.userRights.length === 0) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"userRights is empty — consider listing applicable rights\"\n\t});\n\tif (config.jurisdictions.includes(\"eu\")) {\n\t\tif (!config.legalBasis) issues.push({\n\t\t\tlevel: \"error\",\n\t\t\tmessage: \"GDPR requires a legalBasis\"\n\t\t});\n\t\tfor (const right of [\n\t\t\t\"access\",\n\t\t\t\"rectification\",\n\t\t\t\"erasure\",\n\t\t\t\"portability\",\n\t\t\t\"restriction\",\n\t\t\t\"objection\"\n\t\t]) if (!config.userRights.includes(right)) issues.push({\n\t\t\tlevel: \"warning\",\n\t\t\tmessage: `GDPR recommends including the \"${right}\" right`\n\t\t});\n\t}\n\tif (config.jurisdictions.includes(\"ca\")) {\n\t\tfor (const right of [\n\t\t\t\"access\",\n\t\t\t\"erasure\",\n\t\t\t\"opt_out_sale\",\n\t\t\t\"non_discrimination\"\n\t\t]) if (!config.userRights.includes(right)) issues.push({\n\t\t\tlevel: \"warning\",\n\t\t\tmessage: `CCPA recommends including the \"${right}\" right`\n\t\t});\n\t}\n\treturn issues;\n}\n//#endregion\n//#region src/validate-terms.ts\nfunction validateTermsOfService(config) {\n\tconst issues = [];\n\tif (!config.effectiveDate) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"effectiveDate is required\"\n\t});\n\tif (!config.company.name) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.name is required\"\n\t});\n\tif (!config.company.legalName) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.legalName is required\"\n\t});\n\tif (!config.company.address) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.address is required\"\n\t});\n\tif (!config.company.contact) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"company.contact is required\"\n\t});\n\tif (!config.governingLaw.jurisdiction) issues.push({\n\t\tlevel: \"error\",\n\t\tmessage: \"governingLaw.jurisdiction is required\"\n\t});\n\tif (!config.disclaimers) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"disclaimers is missing — consider adding a disclaimer of warranties\"\n\t});\n\tif (!config.limitationOfLiability) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"limitationOfLiability is missing — consider adding a limitation of liability clause\"\n\t});\n\tif (config.acceptance.methods.length === 0) issues.push({\n\t\tlevel: \"warning\",\n\t\tmessage: \"acceptance.methods is empty — consider listing how users accept these Terms\"\n\t});\n\treturn issues;\n}\n//#endregion\n//#region src/index.ts\nfunction compilePolicy(input, options) {\n\tswitch (input.type) {\n\t\tcase \"privacy\": {\n\t\t\tconst { type: _, ...config } = input;\n\t\t\treturn compilePrivacyPolicy(config, options);\n\t\t}\n\t\tcase \"terms\": {\n\t\t\tconst { type: _, ...config } = input;\n\t\t\treturn compileTermsOfService(config, options);\n\t\t}\n\t}\n}\n//#endregion\nexport { compilePolicy, compilePrivacyPolicy, compileTermsOfService, validatePrivacyPolicy, validateTermsOfService };\n\n//# sourceMappingURL=index.js.map","import { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type {\n\tOutputFormat,\n\tPrivacyPolicyConfig,\n\tTermsOfServiceConfig,\n} from \"@openpolicy/core\";\nimport {\n\tcompilePolicy,\n\tvalidatePrivacyPolicy,\n\tvalidateTermsOfService,\n} from \"@openpolicy/core\";\nimport type { Plugin } from \"vite\";\n\nexport type PolicyConfigEntry =\n\t| string\n\t| { config: string; type?: \"privacy\" | \"terms\" };\n\nexport interface OpenPolicyOptions {\n\tconfigs?: PolicyConfigEntry[];\n\tconfig?: string;\n\tformats?: OutputFormat[];\n\toutDir?: string;\n\ttype?: \"privacy\" | \"terms\";\n}\n\nfunction detectType(filename: string): \"privacy\" | \"terms\" {\n\treturn filename.includes(\"terms\") ? \"terms\" : \"privacy\";\n}\n\nfunction normalizeEntries(\n\toptions: OpenPolicyOptions,\n): Array<{ configFile: string; type: \"privacy\" | \"terms\" }> {\n\tif (options.configs) {\n\t\treturn options.configs.map((entry) => {\n\t\t\tif (typeof entry === \"string\") {\n\t\t\t\treturn { configFile: entry, type: detectType(entry) };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tconfigFile: entry.config,\n\t\t\t\ttype: entry.type ?? detectType(entry.config),\n\t\t\t};\n\t\t});\n\t}\n\tconst configFile =\n\t\toptions.type === \"terms\" ? \"terms.config.ts\" : \"privacy.config.ts\";\n\treturn [\n\t\t{\n\t\t\tconfigFile: options.config ?? configFile,\n\t\t\ttype: options.type ?? \"privacy\",\n\t\t},\n\t];\n}\n\nconst PRIVACY_SCAFFOLD_TEMPLATE = `import { definePrivacyPolicy } from \"@openpolicy/sdk\";\n\nexport default definePrivacyPolicy({\n effectiveDate: \"${new Date().toISOString().slice(0, 10)}\",\n company: {\n name: \"Your Company\",\n legalName: \"Your Company, Inc.\",\n address: \"123 Main St, City, State, ZIP\",\n contact: \"privacy@yourcompany.com\",\n },\n dataCollected: {\n \"Personal Information\": [\"Full name\", \"Email address\"],\n },\n legalBasis: \"Legitimate interests and consent\",\n retention: {\n \"All personal data\": \"As long as necessary for the purposes described in this policy\",\n },\n cookies: { essential: true, analytics: false, marketing: false },\n thirdParties: [],\n userRights: [\"access\", \"erasure\"],\n jurisdictions: [\"us\"],\n});\n`;\n\nconst TERMS_SCAFFOLD_TEMPLATE = `import { defineTermsOfService } from \"@openpolicy/sdk\";\n\nexport default defineTermsOfService({\n effectiveDate: \"${new Date().toISOString().slice(0, 10)}\",\n company: {\n name: \"Your Company\",\n legalName: \"Your Company, Inc.\",\n address: \"123 Main St, City, State, ZIP\",\n contact: \"legal@yourcompany.com\",\n },\n acceptance: {\n methods: [\"using the service\", \"creating an account\"],\n },\n eligibility: {\n minimumAge: 13,\n },\n accounts: {\n registrationRequired: false,\n userResponsibleForCredentials: true,\n companyCanTerminate: true,\n },\n prohibitedUses: [\n \"Violating any applicable laws or regulations\",\n \"Infringing on intellectual property rights\",\n ],\n intellectualProperty: {\n companyOwnsService: true,\n usersMayNotCopy: true,\n },\n termination: {\n companyCanTerminate: true,\n userCanTerminate: true,\n },\n disclaimers: {\n serviceProvidedAsIs: true,\n noWarranties: true,\n },\n limitationOfLiability: {\n excludesIndirectDamages: true,\n },\n governingLaw: {\n jurisdiction: \"Delaware, USA\",\n },\n changesPolicy: {\n noticeMethod: \"email or prominent notice on our website\",\n noticePeriodDays: 30,\n },\n});\n`;\n\nexport async function writeScaffold(\n\tconfigPath: string,\n\ttype: \"privacy\" | \"terms\" = \"privacy\",\n): Promise<void> {\n\tconst template =\n\t\ttype === \"terms\" ? TERMS_SCAFFOLD_TEMPLATE : PRIVACY_SCAFFOLD_TEMPLATE;\n\tawait writeFile(configPath, template, \"utf8\");\n}\n\nexport async function generatePolicies(\n\tconfigPath: string,\n\toutDir: string,\n\tformats: OutputFormat[],\n\ttype: \"privacy\" | \"terms\" = \"privacy\",\n): Promise<void> {\n\tconst mod = await import(`${configPath}?t=${Date.now()}`);\n\tconst config =\n\t\t(mod as Record<string, unknown>)[\"default\"] ??\n\t\t(mod as Record<string, unknown>)[\"module.exports\"] ??\n\t\tmod;\n\n\tif (config === null || config === undefined || typeof config !== \"object\") {\n\t\tthrow new Error(\n\t\t\t`[openpolicy] Config must export a non-null object: ${configPath}`,\n\t\t);\n\t}\n\n\tconst issues =\n\t\ttype === \"terms\"\n\t\t\t? validateTermsOfService(config as TermsOfServiceConfig)\n\t\t\t: validatePrivacyPolicy(config as PrivacyPolicyConfig);\n\n\tfor (const issue of issues) {\n\t\tif (issue.level === \"error\") {\n\t\t\tthrow new Error(`[openpolicy] Validation error: ${issue.message}`);\n\t\t}\n\t\tconsole.warn(`[openpolicy] Warning: ${issue.message}`);\n\t}\n\n\tconst results = compilePolicy(\n\t\ttype === \"terms\"\n\t\t\t? { type: \"terms\", ...(config as TermsOfServiceConfig) }\n\t\t\t: { type: \"privacy\", ...(config as PrivacyPolicyConfig) },\n\t\t{ formats },\n\t);\n\n\tconst outputFilename =\n\t\ttype === \"terms\" ? \"terms-of-service\" : \"privacy-policy\";\n\n\tawait mkdir(outDir, { recursive: true });\n\n\tfor (const result of results) {\n\t\tconst ext = result.format === \"markdown\" ? \"md\" : result.format;\n\t\tawait writeFile(\n\t\t\tjoin(outDir, `${outputFilename}.${ext}`),\n\t\t\tresult.content,\n\t\t\t\"utf8\",\n\t\t);\n\t}\n}\n\nexport function openPolicy(options: OpenPolicyOptions = {}): Plugin {\n\tconst formats: OutputFormat[] = options.formats ?? [\"markdown\"];\n\tlet resolvedOutDir: string;\n\tlet resolvedEntries: Array<{ configPath: string; type: \"privacy\" | \"terms\" }>;\n\n\treturn {\n\t\tname: \"openpolicy\",\n\n\t\tconfigResolved(config) {\n\t\t\tresolvedOutDir = resolve(\n\t\t\t\tconfig.root,\n\t\t\t\toptions.outDir ?? \"public/policies\",\n\t\t\t);\n\t\t\tresolvedEntries = normalizeEntries(options).map((e) => ({\n\t\t\t\tconfigPath: resolve(config.root, e.configFile),\n\t\t\t\ttype: e.type,\n\t\t\t}));\n\t\t},\n\n\t\tasync buildStart() {\n\t\t\tfor (const entry of resolvedEntries) {\n\t\t\t\tconst configExists = await access(entry.configPath).then(\n\t\t\t\t\t() => true,\n\t\t\t\t\t() => false,\n\t\t\t\t);\n\t\t\t\tif (!configExists) {\n\t\t\t\t\tawait writeScaffold(entry.configPath, entry.type);\n\t\t\t\t\tconsole.log(`[openpolicy] Scaffolded config at ${entry.configPath}`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait generatePolicies(\n\t\t\t\t\tentry.configPath,\n\t\t\t\t\tresolvedOutDir,\n\t\t\t\t\tformats,\n\t\t\t\t\tentry.type,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tfor (const entry of resolvedEntries) {\n\t\t\t\tserver.watcher.add(entry.configPath);\n\t\t\t}\n\t\t\tserver.watcher.on(\"change\", async (path) => {\n\t\t\t\tconst entry = resolvedEntries.find((e) => e.configPath === path);\n\t\t\t\tif (!entry) return;\n\t\t\t\ttry {\n\t\t\t\t\tawait generatePolicies(\n\t\t\t\t\t\tentry.configPath,\n\t\t\t\t\t\tresolvedOutDir,\n\t\t\t\t\t\tformats,\n\t\t\t\t\t\tentry.type,\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(\"[openpolicy] Policies regenerated\");\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(\"[openpolicy]\", err);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;AAEA,SAAS,eAAe,UAAU;AACjC,QAAO,SAAS,KAAK,YAAY,MAAM,QAAQ,MAAM,MAAM,QAAQ,OAAO,CAAC,KAAK,cAAc;;AAI/F,SAAS,WAAW,UAAU;AAC7B,QAAO,OAAO,eAAe,SAAS,C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;IACvD,YAAY,QAAQ,OAAO,MAAM,EAAE,WAAW;IAC9C,MAAM,EAAE;IACR,EAAE;;EAGJ,MAAM,aAAa;AAClB,QAAK,MAAM,SAAS,iBAAiB;AAKpC,QAAI,CAJiB,MAAM,OAAO,MAAM,WAAW,CAAC,WAC7C,YACA,MACN,EACkB;AAClB,WAAM,cAAc,MAAM,YAAY,MAAM,KAAK;AACjD,aAAQ,IAAI,qCAAqC,MAAM,aAAa;AACpE;;AAED,UAAM,iBACL,MAAM,YACN,gBACA,SACA,MAAM,KACN;;;EAIH,gBAAgB,QAAQ;AACvB,QAAK,MAAM,SAAS,gBACnB,QAAO,QAAQ,IAAI,MAAM,WAAW;AAErC,UAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;IAC3C,MAAM,QAAQ,gBAAgB,MAAM,MAAM,EAAE,eAAe,KAAK;AAChE,QAAI,CAAC,MAAO;AACZ,QAAI;AACH,WAAM,iBACL,MAAM,YACN,gBACA,SACA,MAAM,KACN;AACD,aAAQ,IAAI,oCAAoC;aACxC,KAAK;AACb,aAAQ,MAAM,gBAAgB,IAAI;;KAElC;;EAEH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpolicy/vite",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "description": "Vite plugin for compiling OpenPolicy privacy policy documents at build time",
6
6
  "license": "MIT",