bitsnap-automations 0.0.0-stage → 0.1.1
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/CHANGELOG.md +45 -0
- package/LICENSE +37 -0
- package/README.md +157 -2
- package/THIRD_PARTY_NOTICES.md +1725 -0
- package/chunks/logic-DYkm-4Pc.js +1158 -0
- package/index.js +20265 -0
- package/logic.js +1 -0
- package/messages/en.json +819 -0
- package/messages/pl.json +831 -0
- package/messages.js +1675 -0
- package/package.json +50 -4
- package/styles.css +1 -0
- package/types/_bitsnap-ui/components/portal-container.d.ts +60 -0
- package/types/_bitsnap-ui/lib/translate.d.ts +42 -0
- package/types/components/AiLearning.d.ts +26 -0
- package/types/components/RunHistory.d.ts +50 -0
- package/types/components/SaveScenarioTemplateDialog.d.ts +34 -0
- package/types/components/ScenarioEditor.d.ts +69 -0
- package/types/components/ScenarioList.d.ts +42 -0
- package/types/components/ScenarioTemplateList.d.ts +39 -0
- package/types/components/shared.d.ts +84 -0
- package/types/create-labels.d.ts +71 -0
- package/types/index.d.ts +22 -0
- package/types/labels.d.ts +529 -0
- package/types/logic/ai-decision.d.ts +38 -0
- package/types/logic/catalog.d.ts +48 -0
- package/types/logic/filters.d.ts +3 -0
- package/types/logic/index.d.ts +7 -0
- package/types/logic/scenario.d.ts +240 -0
- package/types/logic/templates.d.ts +27 -0
- package/types/messages-entry.d.ts +4 -0
- package/types/types.d.ts +314 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog: bitsnap-automations
|
|
2
|
+
|
|
3
|
+
Published to npm as `bitsnap-automations`. SemVer: while the version is `0.x.y`, a change that
|
|
4
|
+
breaks the contract (a removed or renamed export, prop or label, a prop that becomes required, a
|
|
5
|
+
changed meaning) bumps `x`; everything else bumps `y`.
|
|
6
|
+
|
|
7
|
+
## 0.1.1
|
|
8
|
+
|
|
9
|
+
- Additive: scenario filters beyond products (customer personas). `ScenarioDraft` gains the optional
|
|
10
|
+
`formIds`, `personaIds` and `skipNegativePersona`; `emptyScenarioDraft()` starts with no filter and
|
|
11
|
+
`skipNegativePersona: true` (an explicit choice for a new scenario, not a server default).
|
|
12
|
+
- Additive: `ScenarioEditor` props `filters` (`ScenarioFilterSources`: forms, personas, `personasHref`) for the
|
|
13
|
+
"Formularz" filter on events that carry a form, the "Persona" filter and "Pomiń personę negatywną", and
|
|
14
|
+
`onDraftChange`. A host without `filters` sees no change.
|
|
15
|
+
- Additive: `placeholders` and `checkEmailText` get the picked forms as a last argument
|
|
16
|
+
(`PlaceholderFilterContext`); `EmailPlaceholder.group` (`"persona" | "answers"`) shows those chips under their
|
|
17
|
+
own heading in "Wyślij e-mail".
|
|
18
|
+
- Additive logic: `eventHasForm`, `withTriggerEvent` (a new event without a form drops the picked forms).
|
|
19
|
+
- Additive: picking the negative persona in the persona filter turns "Pomiń personę negatywną" off, locks it with a
|
|
20
|
+
one-line note, and saves `false` (`withNegativePersonaRule`, `picksNegativePersona`).
|
|
21
|
+
- Additive: a picked form or persona the host's list no longer names shows as a removable "Usunięty formularz" /
|
|
22
|
+
"Usunięta persona" chip. `ScenarioFilterSources.answersFailed` (optional) says that a picked form's questions did
|
|
23
|
+
not load; "Wyślij e-mail" keeps the answer chips of the forms that did load and says so.
|
|
24
|
+
- New labels, all **optional**: `sheet.forms*`, `sheet.formDeleted`, `sheet.persona*`, `sheet.personaDeleted`,
|
|
25
|
+
`sheet.skipNegative*` (with `skipNegativePicked`), `actions.sendEmail.insertPersona*`, `insertAnswers*` (with
|
|
26
|
+
`insertAnswersFailed`, `insertAnswersHint`), and the error labels `formsNotApplicable`, `formsInvalid`,
|
|
27
|
+
`formUnknown`, `personasInvalid`, `personaUnknown` (`FilterErrorCode`). `createAutomationsLabels` fills them
|
|
28
|
+
from the host's translations; a host that builds `labels` by hand needs no change and gets the Polish defaults.
|
|
29
|
+
|
|
30
|
+
## 0.1.0
|
|
31
|
+
|
|
32
|
+
First release: `npm install bitsnap-automations`.
|
|
33
|
+
|
|
34
|
+
- Automation screens as props-only client components: `ScenarioList`, `ScenarioEditor` with the
|
|
35
|
+
action cards, `ScenarioTemplateList`, `RunHistory` and `AiLearningPanel`.
|
|
36
|
+
- `AutomationsRoot` at the top: the `.bitsnap-ui` root and a body-level portal host for dialogs,
|
|
37
|
+
sheets and popovers; `theme="light" | "dark"` sets the theme whatever the host page's `.dark`
|
|
38
|
+
says.
|
|
39
|
+
- `createAutomationsLabels(t, { locale, timeZone })` builds every view's `labels`;
|
|
40
|
+
`bitsnap-automations/messages` ships the `pl` and `en` catalogs and `createTranslate`.
|
|
41
|
+
- `bitsnap-automations/logic`: the pure catalog, filters and rules, safe in server components.
|
|
42
|
+
- No toasts of its own: pass `notify` to the views.
|
|
43
|
+
- `bitsnap-automations/styles.css`: one global stylesheet, every rule scoped to `.bitsnap-ui`.
|
|
44
|
+
- Peer dependencies: `react` and `react-dom` `^19.2.3`. Server rendering (Next.js App Router)
|
|
45
|
+
supported; the root entry is a client module.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Bitsnap packages licence
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Piotr Michalik (Bitsnap). All rights reserved.
|
|
4
|
+
|
|
5
|
+
This package is published so that you can install it from the npm registry. It is not open source.
|
|
6
|
+
|
|
7
|
+
1. Use. You may install this package in an application that you own or build for a client, and
|
|
8
|
+
run it in that application, and develop and test that application, for as long as that
|
|
9
|
+
application connects to the Bitsnap service (https://bitsnap.pl) or to a Bitsnap API on your
|
|
10
|
+
behalf, or is being built to do so. The use may be commercial.
|
|
11
|
+
|
|
12
|
+
2. Your application. You may include this package in that application as the application's own
|
|
13
|
+
build does: copy it into your repository or build, transpile, bundle, minify and tree-shake it,
|
|
14
|
+
deploy it to your hosting, and deliver it to the application's users (browsers included) as part
|
|
15
|
+
of the application. You may configure it through its props, host interface and stylesheet.
|
|
16
|
+
|
|
17
|
+
3. Not allowed. Without written permission from Bitsnap you may not: publish, redistribute, sell,
|
|
18
|
+
lease or sublicense this package, or any part of it, as a package, a library, a template or a
|
|
19
|
+
starter kit, alone or inside another one, even when it has been bundled or minified (delivering
|
|
20
|
+
it to the users of your application, as in clause 2, is not redistribution); remove this
|
|
21
|
+
licence or its notices from the package as distributed to you (a build output of your
|
|
22
|
+
application that drops comments and files is fine); decompile or reverse engineer it, except where the law
|
|
23
|
+
allows this despite this clause; or use it to build a product that competes with Bitsnap.
|
|
24
|
+
|
|
25
|
+
4. Third-party code. This package contains code of other projects, each under its own licence.
|
|
26
|
+
THIRD_PARTY_NOTICES.md lists them with their licence texts. Those licences apply to that code
|
|
27
|
+
and are not changed by this one.
|
|
28
|
+
|
|
29
|
+
5. No warranty. The package is provided "as is", without warranty of any kind, express or
|
|
30
|
+
implied, including fitness for a particular purpose and non-infringement. Bitsnap is not liable
|
|
31
|
+
for any claim, damages or other liability arising from its use, except where the law does not
|
|
32
|
+
allow this limit.
|
|
33
|
+
|
|
34
|
+
6. Changes. Bitsnap may release later versions under other terms. The terms of a version you
|
|
35
|
+
installed stay as published with it.
|
|
36
|
+
|
|
37
|
+
Questions or a request for permission: https://bitsnap.pl
|
package/README.md
CHANGED
|
@@ -1,3 +1,158 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bitsnap-automations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The automation screens of [Bitsnap](https://bitsnap.pl) as React components you can embed in your own
|
|
4
|
+
app: the scenario list, the scenario editor with its action cards, the template list, the run
|
|
5
|
+
history and the AI learning panel.
|
|
6
|
+
|
|
7
|
+
The components are **props-only**. The package calls no API and stores nothing: your app passes the
|
|
8
|
+
data, the permissions and the callbacks, plus the `labels` built from one translate function.
|
|
9
|
+
|
|
10
|
+
Built for React 19 and the Next.js App Router. Server rendering is supported.
|
|
11
|
+
|
|
12
|
+
> Polish documentation: <https://docs.bitsnap.pl/guides/marketing-ui-packages/>
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install bitsnap-automations
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Peer dependencies: `react` and `react-dom` `^19.2.3`. Everything else is bundled.
|
|
21
|
+
|
|
22
|
+
If the same app also uses [`bitsnap-notifications`](https://www.npmjs.com/package/bitsnap-notifications),
|
|
23
|
+
install both at **the same version**. They ship the same stylesheet, so importing one or both gives
|
|
24
|
+
the same result; two different versions on one page are not supported.
|
|
25
|
+
|
|
26
|
+
## Quick start (Next.js App Router)
|
|
27
|
+
|
|
28
|
+
**1. Import the stylesheet once**, in the root layout. It is a plain global CSS file and needs no
|
|
29
|
+
extra setup. Every rule is scoped to `.bitsnap-ui`, so it does not touch the rest of your page.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// app/layout.tsx
|
|
33
|
+
import "bitsnap-automations/styles.css";
|
|
34
|
+
|
|
35
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
36
|
+
return (
|
|
37
|
+
<html lang="en">
|
|
38
|
+
<body>{children}</body>
|
|
39
|
+
</html>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**2. Render the views in a client component.** The labels hold functions (`labels.list.runs(count)`),
|
|
45
|
+
so they cannot be passed from a server component to a client one: build them next to the views.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
// components/scenarios.tsx
|
|
49
|
+
"use client";
|
|
50
|
+
|
|
51
|
+
import {
|
|
52
|
+
AutomationsRoot,
|
|
53
|
+
ScenarioList,
|
|
54
|
+
createAutomationsLabels,
|
|
55
|
+
type ScenarioFilters,
|
|
56
|
+
type ScenarioSummary,
|
|
57
|
+
} from "bitsnap-automations";
|
|
58
|
+
import { DEFAULT_SCENARIO_FILTERS } from "bitsnap-automations/logic";
|
|
59
|
+
import { createTranslate, en } from "bitsnap-automations/messages";
|
|
60
|
+
import { useState } from "react";
|
|
61
|
+
|
|
62
|
+
// `timeZone` keeps the dates of the server render and of the browser identical.
|
|
63
|
+
const labels = createAutomationsLabels(createTranslate(en), { locale: "en-GB", timeZone: "Europe/Warsaw" });
|
|
64
|
+
|
|
65
|
+
const noop = () => {};
|
|
66
|
+
|
|
67
|
+
export function Scenarios({ scenarios }: { scenarios: ScenarioSummary[] }) {
|
|
68
|
+
const [filters, setFilters] = useState<ScenarioFilters>(DEFAULT_SCENARIO_FILTERS);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<AutomationsRoot theme="light">
|
|
72
|
+
<ScenarioList
|
|
73
|
+
scenarios={{ status: "ready", value: { scenarios, total: scenarios.length, projectTotal: scenarios.length } }}
|
|
74
|
+
filters={filters}
|
|
75
|
+
onFiltersChange={setFilters}
|
|
76
|
+
events={[]} // the trigger events your app offers
|
|
77
|
+
products={{ search: async () => [], variants: async () => [] }}
|
|
78
|
+
labels={labels.list}
|
|
79
|
+
canEdit
|
|
80
|
+
onNew={noop}
|
|
81
|
+
onTemplate={noop}
|
|
82
|
+
onOpen={noop}
|
|
83
|
+
onShowRuns={noop}
|
|
84
|
+
onShowApps={noop}
|
|
85
|
+
onToggleActive={async () => ({ status: "success" })}
|
|
86
|
+
onDelete={async () => ({ status: "success" })}
|
|
87
|
+
notify={{ success: noop, error: noop }}
|
|
88
|
+
/>
|
|
89
|
+
</AutomationsRoot>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**3. Use it in a page.**
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// app/automations/page.tsx
|
|
98
|
+
import { Scenarios } from "@/components/scenarios";
|
|
99
|
+
|
|
100
|
+
export default function Page() {
|
|
101
|
+
return <Scenarios scenarios={[]} />; // your scenarios, loaded by your app
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`ScenarioEditor`, `ScenarioTemplateList`, `RunHistory` and `AiLearningPanel` are used the same way,
|
|
106
|
+
inside the same `AutomationsRoot`.
|
|
107
|
+
|
|
108
|
+
## Theme
|
|
109
|
+
|
|
110
|
+
`AutomationsRoot` renders the `.bitsnap-ui` root, and a second root at the end of `<body>` where
|
|
111
|
+
dialogs, sheets and popovers open. `theme="light" | "dark"` sets the theme of both, whatever your
|
|
112
|
+
page's own `.dark` class says. The portal root is created in an effect, so nothing touches `window`
|
|
113
|
+
or `document` while rendering and the first server render matches the first client render.
|
|
114
|
+
|
|
115
|
+
## Labels and translations
|
|
116
|
+
|
|
117
|
+
`createAutomationsLabels(translate, { locale, timeZone })` builds the `labels` prop of every view
|
|
118
|
+
from one translate function. `bitsnap-automations/messages` ships the `pl` and `en` catalogs and
|
|
119
|
+
`createTranslate` (i18next-compatible: `{{placeholders}}`, `count` plurals, `defaultValue`); the
|
|
120
|
+
catalogs are also JSON files (`bitsnap-automations/messages/pl.json`, `.../en.json`). `timeZone` is
|
|
121
|
+
required unless you pass your own `format`.
|
|
122
|
+
|
|
123
|
+
## Feedback
|
|
124
|
+
|
|
125
|
+
The package has no toasts of its own. Pass `notify` (`{ success, error }`) to the views, for example
|
|
126
|
+
the `toast` of your own toast library. Without `notify` it warns once in the console and shows
|
|
127
|
+
nothing.
|
|
128
|
+
|
|
129
|
+
## Entry points
|
|
130
|
+
|
|
131
|
+
| Import | What it is |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `bitsnap-automations` | The components and `createAutomationsLabels`. A client module (`"use client"`). |
|
|
134
|
+
| `bitsnap-automations/styles.css` | The stylesheet. Import it once, globally. |
|
|
135
|
+
| `bitsnap-automations/messages` | The `pl` and `en` catalogs and `createTranslate`. |
|
|
136
|
+
| `bitsnap-automations/logic` | The pure catalog of actions, filters and rules. Safe in server components. |
|
|
137
|
+
|
|
138
|
+
The root entry is a client module, so in a server component its exports are client references, not
|
|
139
|
+
functions you can call. Server code that needs only the pure helpers imports them from `/logic`.
|
|
140
|
+
|
|
141
|
+
## Good to know
|
|
142
|
+
|
|
143
|
+
- **Render the views at page level**, not inside your own Radix `Dialog` or `Sheet`. The package
|
|
144
|
+
bundles its own Radix, and two copies do not know each other's layers: focus traps fight, Escape
|
|
145
|
+
closes both, and a modal's `pointer-events: none` on `<body>` can make the package's popovers
|
|
146
|
+
unclickable. Give a view its own route, or show it in place of the page content.
|
|
147
|
+
- **Your Tailwind is safe.** The reset sits in `@layer base`, the layer of your own Tailwind
|
|
148
|
+
preflight, so a utility on your element inside a `.bitsnap-ui` root keeps its padding and border.
|
|
149
|
+
Your page outside the root is untouched.
|
|
150
|
+
- **Versions.** The package follows SemVer. While it is `0.x`, a change that breaks the contract (a
|
|
151
|
+
removed or renamed export, prop or label, a prop that becomes required) bumps the minor number, so
|
|
152
|
+
pin it (`"bitsnap-automations": "~0.1.0"`) or use a lockfile. See [CHANGELOG.md](./CHANGELOG.md).
|
|
153
|
+
|
|
154
|
+
## Licence
|
|
155
|
+
|
|
156
|
+
Proprietary, free to use in an application that connects to Bitsnap, and free to bundle and serve as
|
|
157
|
+
part of that application: see [LICENSE](./LICENSE). The licences of the bundled open source packages are in
|
|
158
|
+
[THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
|