{"_id":"@creaditor/cdtr-series-newsletter","_rev":"2-f7f1b427a2b64d6a2ffa7b25d2198033","name":"@creaditor/cdtr-series-newsletter","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@creaditor/cdtr-series-newsletter","version":"0.1.0","keywords":["web-components","creaditor","series","newsletter","email","embed","drop-in","hebrew","rtl"],"author":{"name":"Creaditor"},"license":"MIT","_id":"@creaditor/cdtr-series-newsletter@0.1.0","maintainers":[{"name":"creaditor","email":"creaditor.system@gmail.com"}],"dist":{"shasum":"f28aa1c3fbe3a731838f8ee648e900dea9e7cdb0","tarball":"https://registry.npmjs.org/@creaditor/cdtr-series-newsletter/-/cdtr-series-newsletter-0.1.0.tgz","fileCount":3,"integrity":"sha512-+c2qCZpZbU+HzwBBjPr5gV5lPuQuwFT662lArFk+To9L5bkpHO3x1NGLUaXDSPl0bzaKApU7yB5aQuNHCxSthQ==","signatures":[{"sig":"MEYCIQCkaAkkx0ExCekO4UbGUSiCxldRKPTigdUm+4PI291i3gIhAN1exghJBV4uX+8yQ0f/9Xw8yOTjSClr8hoRxWxw7Ics","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":192262},"main":"./dist/cdtr-series-newsletter.umd.js","type":"module","types":"./dist/index.d.ts","unpkg":"./dist/cdtr-series-newsletter.umd.js","module":"./dist/cdtr-series-newsletter.es.js","browser":"./dist/cdtr-series-newsletter.umd.js","gitHead":"b0935cf2fe8729a3f78668b14a5960cb23765def","private":false,"scripts":{"dev":"vite","build":"tsc -p tsconfig.build.json && vite build","preview":"vite preview"},"_npmUser":{"name":"creaditor","email":"creaditor.system@gmail.com"},"jsdelivr":"./dist/cdtr-series-newsletter.umd.js","_npmVersion":"11.3.0","description":"Embeddable <cdtr-series-newsletter> web component. AI chat-driven email series builder with outline review, newsletter generation, and preview. Hebrew + English.","directories":{},"_nodeVersion":"24.1.0","dependencies":{"lit":"^3.2.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.2.0","typescript":"~5.7.2"},"_npmOperationalInternal":{"tmp":"tmp/cdtr-series-newsletter_0.1.0_1783288065141_0.657829643489914","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@creaditor/cdtr-series-newsletter","private":false,"version":"0.1.2","type":"module","publishConfig":{"access":"public"},"description":"Embeddable <cdtr-series-newsletter> web component. AI chat-driven email series builder with outline review, newsletter generation, and preview. Hebrew + English.","main":"./dist/cdtr-series-newsletter.umd.js","module":"./dist/cdtr-series-newsletter.es.js","types":"./dist/index.d.ts","unpkg":"./dist/cdtr-series-newsletter.umd.js","jsdelivr":"./dist/cdtr-series-newsletter.umd.js","browser":"./dist/cdtr-series-newsletter.umd.js","scripts":{"dev":"vite","build":"vite build && tsc -p tsconfig.build.json","preview":"vite preview"},"keywords":["web-components","creaditor","series","newsletter","email","embed","drop-in","hebrew","rtl"],"author":{"name":"Creaditor"},"license":"MIT","dependencies":{"lit":"^3.2.1"},"devDependencies":{"typescript":"~5.7.2","vite":"^6.2.0"},"_id":"@creaditor/cdtr-series-newsletter@0.1.2","gitHead":"b0935cf2fe8729a3f78668b14a5960cb23765def","_nodeVersion":"24.1.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-6aZZgU79xnkteroTW9rGWWXKk3xQ0LZTTl1MDe6OoR5MB7q9NZmZ5w8Bte2yx9QV0ZbHTaCRNLJjOxi13EiFSA==","shasum":"d12081fc276feb9ca269e60ad44ff62a2b355e70","tarball":"https://registry.npmjs.org/@creaditor/cdtr-series-newsletter/-/cdtr-series-newsletter-0.1.2.tgz","fileCount":7,"unpackedSize":208680,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCKpODyWd0GoE6Vug05uhodn+EiKs+X6ephlG7OmSJHBgIgejhViStExqfs9/W60+c3/JQIaGCli49y5zSAVBjpcBQ="}]},"_npmUser":{"name":"creaditor","email":"creaditor.system@gmail.com"},"directories":{},"maintainers":[{"name":"creaditor","email":"creaditor.system@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cdtr-series-newsletter_0.1.2_1783288644136_0.0554678099578676"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-05T21:47:44.981Z","modified":"2026-07-05T21:57:24.383Z","0.1.0":"2026-07-05T21:47:45.279Z","0.1.2":"2026-07-05T21:57:24.272Z"},"author":{"name":"Creaditor"},"license":"MIT","keywords":["web-components","creaditor","series","newsletter","email","embed","drop-in","hebrew","rtl"],"description":"Embeddable <cdtr-series-newsletter> web component. AI chat-driven email series builder with outline review, newsletter generation, and preview. Hebrew + English.","maintainers":[{"name":"creaditor","email":"creaditor.system@gmail.com"}],"readme":"# @creaditor/cdtr-series-newsletter\n\nEmbeddable `<cdtr-series-newsletter>` web component. An AI chat-driven **email series builder**: the user describes what they want in a conversation, the component generates a series outline they can review and edit, renders each newsletter, and previews the result. Hebrew + English out of the box, with full RTL layout.\n\nBuilt with [Lit](https://lit.dev). The component owns the whole UI flow (chat → outline → generation → preview); the **host page owns the backend** — you point it at an API base URL and Creaditor drives the rest.\n\n## How it works\n\nThe component walks the user through four phases:\n\n1. **Chat** — the user talks to an assistant (rendered via `<cdtr-chat>`) that extracts the series goal, email count, title, and audience. When enough is known, it offers to build the outline.\n2. **Outline** — the AI proposes a card per email (subject, summary, send-offset in days). The user can edit, reorder timing, delete, or ask the AI to rewrite any card.\n3. **Generating** — each approved card is turned into a full newsletter, one at a time, with per-email retry on failure.\n4. **Preview** — the rendered newsletters are shown. On approval the component emits a single event with the final prompts and generated newsletter JSON.\n\n## Install\n\n```bash\nnpm install @creaditor/cdtr-series-newsletter\n```\n\n## Use\n\n> **Dependency:** the component renders `<cdtr-chat>` inside its shadow DOM but does **not** bundle it. You must load [`@creaditor/cdtr-chat`](../cdtr-chat) **before** this component, or the chat phase renders blank.\n\n### As an ES module\n\n```html\n<cdtr-series-newsletter\n  lang=\"en\"\n  user-name=\"Alex\"\n  api-url=\"https://your-backend.example.com/api/series\"\n  studio-token=\"<JWT>\"\n  style=\"display:block; height: 80vh; max-width: 720px;\"\n></cdtr-series-newsletter>\n\n<script type=\"module\">\n  import '@creaditor/cdtr-chat';            // must come first\n  import '@creaditor/cdtr-series-newsletter';\n\n  const el = document.querySelector('cdtr-series-newsletter');\n\n  // Fired once, when the user approves the previewed series.\n  el.addEventListener('cdtr-series-newsletter:approved', (e) => {\n    const { prompts, newsletters } = e.detail;\n    // prompts     → one { type, prompt, sendOffsetDays } per email\n    // newsletters → the generated Creaditor newsletter JSON per email\n    myApp.scheduleSeries(prompts, newsletters);\n  });\n</script>\n```\n\n### Via CDN (UMD)\n\n```html\n<script src=\"https://unpkg.com/@creaditor/cdtr-chat\"></script>\n<script src=\"https://unpkg.com/@creaditor/cdtr-series-newsletter\"></script>\n\n<cdtr-series-newsletter\n  api-url=\"https://your-backend.example.com/api/series\"\n></cdtr-series-newsletter>\n```\n\n### Sizing\n\nThe component fills its host. Give the element (or a wrapper) an explicit height, e.g. `style=\"display:block; height: 80vh;\"`, otherwise the chat area collapses.\n\n## Attributes\n\n| Attribute         | Type   | Default | Description                                                                                       |\n| ----------------- | ------ | ------- | ------------------------------------------------------------------------------------------------- |\n| `lang`            | string | `\"en\"`  | `\"he\"` or `\"en\"`. Auto-sets `dir=\"rtl\"` for Hebrew.                                               |\n| `user-name`       | string | `\"\"`    | Personalizes the assistant's greeting and is sent to the `/chat` endpoint.                        |\n| `api-url`         | string | `\"\"`    | **Required.** Base URL for the backend. The component appends `/chat`, `/generate-cards`, etc.    |\n| `studio-token`    | string | `\"\"`    | Bearer JWT sent as `Authorization: Bearer <token>` on every API call. Omit for open/dev backends. |\n| `token-balance`   | number | `null`  | If set, renders a token-balance chip. Below ~40k shows a \"buy\" link; below ~1k reads as empty.    |\n| `payment-url`     | string | `\"\"`    | Link target for the \"buy tokens\" chip (used with `token-balance`).                                |\n| `error-token-img` | string | `\"\"`    | Optional image shown on the \"out of tokens\" error screen.                                         |\n\nAll attributes can also be set as properties (e.g. `el.tokenBalance = 25000`).\n\n## Events\n\nBubbles and composed. Prefixed with `cdtr-series-newsletter:`.\n\n| Event                          | `detail`                    | When                                                       |\n| ------------------------------ | --------------------------- | ---------------------------------------------------------- |\n| `cdtr-series-newsletter:approved` | `{ prompts, newsletters }` | User approved the previewed series (the terminal action).  |\n\n```ts\n// detail shape\n{\n  prompts: Array<{\n    type: 'authentic';\n    prompt: string;          // \"Subject: …\\n\\n<summary>\"\n    sendOffsetDays: number;  // 0 = same day, 1 = next day, …\n  }>;\n  newsletters: unknown[];    // generated Creaditor newsletter JSON, one per prompt (null if that email failed)\n}\n```\n\n## Backend contract\n\nSet `api-url` to a base path; the component calls these routes beneath it. Each request carries `Authorization: Bearer <studio-token>` when the token attribute is set, and `language` reflects the `lang` attribute.\n\n| Route                  | Request body                                             | Expected response                                                        |\n| ---------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------ |\n| `POST /chat`           | `{ messages, language, userName }`                      | `{ reply, extracted?: {goal,count,title,audience}, ready?: boolean }`    |\n| `POST /generate-cards` | `{ goal, count, title, audience, language }`            | `{ cards: [{ subject, summary, sendOffsetDays }] }`                       |\n| `POST /assist-card`    | `{ instruction, card, seriesContext, language }`        | `{ subject?, summary? }` (the rewritten card)                            |\n| `POST /generate-newsletter` | `{ prompt, language }`                             | Creaditor newsletter JSON for one email                                  |\n\n- `messages` is the running `[{ role, content }]` history.\n- `ready: true` on `/chat` unlocks the \"build outline\" step.\n- Return HTTP `429` with `{ error: \"token_balance_exceeded\", paymentUrl? }` to trigger the built-in out-of-tokens screen.\n- On `/chat` errors, an `{ reason }` field is surfaced to the user; other routes fall back to a generic error.\n\n## Types\n\n```ts\nimport type { OutlineCard } from '@creaditor/cdtr-series-newsletter';\n\ntype OutlineCard = {\n  id: string;\n  subject: string;\n  summary: string;\n  sendOffsetDays: number;   // days after the first email\n};\n```\n\nThe `i18n` helpers are also exported: `STRINGS`, `isRtl`, `t`, and the `Lang` type.\n\n## Styling\n\nThe component exposes CSS custom properties for theming (set them on the element or a parent):\n\n```css\ncdtr-series-newsletter {\n  --cdtr-sn-bg: #ffffff;\n  --cdtr-sn-surface: #faf9fc;\n  --cdtr-sn-fg: #17161d;\n  --cdtr-sn-fg-secondary: #6c6b78;\n  --cdtr-sn-accent: #6328A7;\n  --cdtr-sn-accent-gradient: linear-gradient(135deg, #A8107E, #6328A7);\n  --cdtr-sn-border: #ececef;\n  --cdtr-sn-danger: #e11d48;\n  --cdtr-sn-radius: 16px;\n  --cdtr-sn-font: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n}\n```\n\nThe component uses the **Rubik** font; load it on the host page for the intended look:\n\n```html\n<link href=\"https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap\" rel=\"stylesheet\" />\n```\n\n## Local development\n\n```bash\nnpm install\nnpm run dev      # Vite dev server on http://localhost:5173\nnpm run build    # emits ES + UMD bundles and types to dist/\n```\n\n`index.html` is a working harness that loads `<cdtr-chat>`, mints a dev studio token, points at a local backend (`http://localhost:8000/api/series`), and logs emitted events.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}