@rglabs/butterfly 2.0.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/CLAUDE.md +201 -0
- package/README.md +371 -0
- package/dist/commands/add.d.ts +23 -0
- package/dist/commands/add.js +303 -0
- package/dist/commands/code.d.ts +11 -0
- package/dist/commands/code.js +72 -0
- package/dist/commands/create-object.d.ts +6 -0
- package/dist/commands/create-object.js +293 -0
- package/dist/commands/create-report.d.ts +6 -0
- package/dist/commands/create-report.js +154 -0
- package/dist/commands/diff.d.ts +4 -0
- package/dist/commands/diff.js +238 -0
- package/dist/commands/download.d.ts +4 -0
- package/dist/commands/download.js +374 -0
- package/dist/commands/layout.d.ts +12 -0
- package/dist/commands/layout.js +83 -0
- package/dist/commands/record.d.ts +21 -0
- package/dist/commands/record.js +483 -0
- package/dist/commands/run-poc.d.ts +3 -0
- package/dist/commands/run-poc.js +18 -0
- package/dist/commands/setup.d.ts +3 -0
- package/dist/commands/setup.js +66 -0
- package/dist/commands/start-poc.d.ts +3 -0
- package/dist/commands/start-poc.js +55 -0
- package/dist/commands/sync-docs.d.ts +3 -0
- package/dist/commands/sync-docs.js +27 -0
- package/dist/commands/translate.d.ts +13 -0
- package/dist/commands/translate.js +401 -0
- package/dist/commands/upload.d.ts +3 -0
- package/dist/commands/upload.js +150 -0
- package/dist/commands/workflow-info.d.ts +13 -0
- package/dist/commands/workflow-info.js +161 -0
- package/dist/components/ConflictResolver.d.ts +12 -0
- package/dist/components/ConflictResolver.js +77 -0
- package/dist/components/DiffView.d.ts +11 -0
- package/dist/components/DiffView.js +101 -0
- package/dist/components/DownloadProgress.d.ts +11 -0
- package/dist/components/DownloadProgress.js +29 -0
- package/dist/components/RecordPreview.d.ts +11 -0
- package/dist/components/RecordPreview.js +91 -0
- package/dist/components/SetupForm.d.ts +8 -0
- package/dist/components/SetupForm.js +56 -0
- package/dist/components/UploadProgress.d.ts +13 -0
- package/dist/components/UploadProgress.js +42 -0
- package/dist/diff/adapters/index.d.ts +8 -0
- package/dist/diff/adapters/index.js +18 -0
- package/dist/diff/adapters/objectsAdapter.d.ts +13 -0
- package/dist/diff/adapters/objectsAdapter.js +177 -0
- package/dist/diff/adapters/reportsAdapter.d.ts +14 -0
- package/dist/diff/adapters/reportsAdapter.js +212 -0
- package/dist/diff/adapters/types.d.ts +19 -0
- package/dist/diff/adapters/types.js +2 -0
- package/dist/diff/engine.d.ts +19 -0
- package/dist/diff/engine.js +57 -0
- package/dist/diff/types.d.ts +34 -0
- package/dist/diff/types.js +110 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +117 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/api.d.ts +85 -0
- package/dist/utils/api.js +1031 -0
- package/dist/utils/auth.d.ts +4 -0
- package/dist/utils/auth.js +22 -0
- package/dist/utils/bfySplitter.d.ts +12 -0
- package/dist/utils/bfySplitter.js +151 -0
- package/dist/utils/docs.d.ts +16 -0
- package/dist/utils/docs.js +186 -0
- package/dist/utils/errorLogger.d.ts +6 -0
- package/dist/utils/errorLogger.js +29 -0
- package/dist/utils/files.d.ts +14 -0
- package/dist/utils/files.js +772 -0
- package/dist/utils/lockManager.d.ts +15 -0
- package/dist/utils/lockManager.js +126 -0
- package/dist/utils/resourceHandlers.d.ts +50 -0
- package/dist/utils/resourceHandlers.js +684 -0
- package/dist/utils/resourceMapping.d.ts +32 -0
- package/dist/utils/resourceMapping.js +210 -0
- package/dist/utils/singleResourceDownload.d.ts +14 -0
- package/dist/utils/singleResourceDownload.js +261 -0
- package/dist/utils/summaryGenerator.d.ts +2 -0
- package/dist/utils/summaryGenerator.js +183 -0
- package/dist/utils/uploadHandler.d.ts +31 -0
- package/dist/utils/uploadHandler.js +263 -0
- package/docs/AI_API.md +93 -0
- package/docs/CLAUDE.md +216 -0
- package/docs/PROJECT_SPECIFIC.md +1 -0
- package/docs/RECORD_COMMAND.md +262 -0
- package/docs/WORKFLOW_API.md +480 -0
- package/docs/bfy-splitting.md +126 -0
- package/docs/cli-commands.md +333 -0
- package/docs/examples/README.md +95 -0
- package/docs/examples/order-system.md +147 -0
- package/docs/examples/product-catalog.md +195 -0
- package/docs/examples/reports.md +187 -0
- package/docs/excel-export.md +216 -0
- package/docs/field-types/README.md +29 -0
- package/docs/field-types/calculated.md +147 -0
- package/docs/field-types/code-mappings.md +84 -0
- package/docs/field-types/custom.md +340 -0
- package/docs/object-specs/README.md +136 -0
- package/docs/object-specs/code-parameters.md +151 -0
- package/docs/object-specs/creating.md +203 -0
- package/docs/object-specs/js-code-examples.md +208 -0
- package/docs/object-specs/js-field-updates.md +168 -0
- package/docs/objects/README.md +89 -0
- package/docs/objects/creating.md +127 -0
- package/docs/page-layout.md +361 -0
- package/docs/permissions.md +260 -0
- package/docs/reports.md +197 -0
- package/docs/state-machines.md +544 -0
- package/docs/tasks/create-object.md +81 -0
- package/docs/translations.md +346 -0
- package/docs/twig-helpers.md +283 -0
- package/docs/webservices.md +159 -0
- package/docs/workspaces.md +176 -0
- package/package.json +59 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
## Translations in Twig
|
|
4
|
+
|
|
5
|
+
```twig
|
|
6
|
+
{{ "text"|trans }}
|
|
7
|
+
{{ "Hello %name%"|trans({'name': value}) }}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Resource Information Lookup
|
|
11
|
+
|
|
12
|
+
1. **First, search in `butterfly-resources/` folder** - local resources are the source of truth
|
|
13
|
+
2. **If not found locally**, use `butterfly-cli record get <table> --column <col> --value <val>`
|
|
14
|
+
3. **For table/column info**, check `butterfly-resources/docs/` folder
|
|
15
|
+
|
|
16
|
+
## Record Command Quick Reference
|
|
17
|
+
|
|
18
|
+
| Operation | When to Use | Command |
|
|
19
|
+
|-----------|-------------|---------|
|
|
20
|
+
| **GET** | Not in `butterfly-resources/` | `butterfly-cli record get <table> --id <id>` |
|
|
21
|
+
| **ADD** | **Always** (never create files manually) | `butterfly-cli record add <table> --data '{...}'` |
|
|
22
|
+
| **EDIT** | Not in `butterfly-resources/` | `butterfly-cli record edit <table> --id <id> --data '{...}'` |
|
|
23
|
+
| **DELETE** | Always (ask user first!) | `butterfly-cli record delete <table> --id <id>` |
|
|
24
|
+
|
|
25
|
+
> **For EDIT operations only:** If the resource exists in `butterfly-resources/`, edit local files and use `butterfly-cli upload <path>` instead. **ADD operations must ALWAYS use `butterfly-cli record add`** - never create files manually in `butterfly-resources/`.
|
|
26
|
+
|
|
27
|
+
See [docs/RECORD_COMMAND.md](docs/RECORD_COMMAND.md) for full documentation.
|
|
28
|
+
|
|
29
|
+
## System Table Names
|
|
30
|
+
|
|
31
|
+
| Correct Name | Wrong Alternatives | Description |
|
|
32
|
+
|--------------|-------------------|-------------|
|
|
33
|
+
| `objects` | `cms_objects` | Object definitions |
|
|
34
|
+
| `object_specs` | `cms_object_specs` | Field specifications |
|
|
35
|
+
| `object_tabs` | `cms_object_tabs` | Page tabs |
|
|
36
|
+
| `bfy_sm_actions` | `bfy_state_machine_actions` | State machine actions |
|
|
37
|
+
| `bfy_sm_transition_actions` | `bfy_state_machine_transition_actions` | Transition-action mappings |
|
|
38
|
+
| `bfy_sm_action_specs` | `bfy_state_machine_action_specs` | Action form fields |
|
|
39
|
+
| `cms_reports` | `reports` | Report definitions |
|
|
40
|
+
| `cms_report_queries` | `report_queries` | Report queries |
|
|
41
|
+
| `cms_report_specs` | `report_specs` | Report field specs |
|
|
42
|
+
| `webservices` | - | Webservice endpoints |
|
|
43
|
+
|
|
44
|
+
## Directory Structure
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
butterfly-resources/
|
|
48
|
+
├── objects/[butterfly|app]/[table]/ # Objects and specs
|
|
49
|
+
├── bfy_state_machines/[name]/ # State machines
|
|
50
|
+
├── bfy_workflows/[name]/v[n]/ # Workflows
|
|
51
|
+
├── reports/[alias]/ # Reports
|
|
52
|
+
├── webservices/[custom_seo]/ # Webservices
|
|
53
|
+
├── pages/ # Pages
|
|
54
|
+
├── bfy_cronjobs/ # Cron jobs
|
|
55
|
+
└── docs/ # Database docs
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Field Type Code Mappings (Quick Reference)
|
|
59
|
+
|
|
60
|
+
| Field Type | Parameter | Export File |
|
|
61
|
+
|------------|-----------|-------------|
|
|
62
|
+
| `calculated` | `val_1` | `code.bfy` |
|
|
63
|
+
| `custom` | `val_1`, `val_2` | `template_code.bfy`, `processing_code.bfy` |
|
|
64
|
+
| `filter` | `val_3` | `filter_code.bfy` |
|
|
65
|
+
| `nested`/`nested_single` | `val_1` | `configuration.yaml` |
|
|
66
|
+
|
|
67
|
+
See [docs/field-types/code-mappings.md](docs/field-types/code-mappings.md) for full details.
|
|
68
|
+
|
|
69
|
+
## CLI Commands (Quick Reference)
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---------|-------------|
|
|
73
|
+
| `butterfly-cli setup` | Configure authentication |
|
|
74
|
+
| `butterfly-cli download [-t type]` | Download resources |
|
|
75
|
+
| `butterfly-cli upload <path>` | Upload files |
|
|
76
|
+
| `butterfly-cli add -t workflow` | Create workflow |
|
|
77
|
+
| `butterfly-cli code -c "..."` | Test Twig code |
|
|
78
|
+
| `butterfly-cli layout -f file.json` | Update page layout |
|
|
79
|
+
| `butterfly-cli translate <operation>` | Manage translations |
|
|
80
|
+
|
|
81
|
+
See [docs/cli-commands.md](docs/cli-commands.md) for full documentation.
|
|
82
|
+
|
|
83
|
+
## Translation Commands (Quick Reference)
|
|
84
|
+
|
|
85
|
+
| Command | Description |
|
|
86
|
+
|---------|-------------|
|
|
87
|
+
| `butterfly-cli translate languages` | List languages with stats |
|
|
88
|
+
| `butterfly-cli translate get-untranslated --lang tr` | Get untranslated texts |
|
|
89
|
+
| `butterfly-cli translate add --lang tr --source "text" --text "çeviri"` | Add/update single translation |
|
|
90
|
+
| `butterfly-cli translate bulk --lang tr --file translations.json` | Bulk import translations |
|
|
91
|
+
|
|
92
|
+
**Bulk CSV format (tab-delimited):**
|
|
93
|
+
```
|
|
94
|
+
source text
|
|
95
|
+
Welcome Hoş geldiniz
|
|
96
|
+
Save Kaydet
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
See [docs/translations.md](docs/translations.md) for full documentation.
|
|
100
|
+
|
|
101
|
+
## Query Helpers (Quick Reference)
|
|
102
|
+
|
|
103
|
+
```twig
|
|
104
|
+
{% set records = db().table('users').where('status', 'active').get() %}
|
|
105
|
+
{% set user = db().table('users').where('id', 5).first() %}
|
|
106
|
+
{% set ids = db().table('users').column('id') %}
|
|
107
|
+
{% set map = db().table('users').keyToValue('id', 'name') %}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
See [docs/twig-helpers.md](docs/twig-helpers.md) for full documentation.
|
|
111
|
+
|
|
112
|
+
## JavaScript Field Updates (Quick Reference)
|
|
113
|
+
|
|
114
|
+
| Field Types | Method |
|
|
115
|
+
|-------------|--------|
|
|
116
|
+
| `calculated`, `custom`, `date` | `bfyRefresh_COLUMN_NAME(value)` |
|
|
117
|
+
| All others | `$('[name="COLUMN"]').val(value).trigger('change')` |
|
|
118
|
+
|
|
119
|
+
See [docs/object-specs/js-field-updates.md](docs/object-specs/js-field-updates.md) for full documentation.
|
|
120
|
+
|
|
121
|
+
## Admin Page URL Format
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
/admin/SINGULAR_TABLE_NAME/list
|
|
125
|
+
/admin/SINGULAR_TABLE_NAME/add
|
|
126
|
+
/admin/SINGULAR_TABLE_NAME/edit/ID
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
For non-default database: `/admin/DATABASE_ALIAS/SINGULAR_TABLE_NAME/...`
|
|
130
|
+
|
|
131
|
+
## Object Menu Placement
|
|
132
|
+
|
|
133
|
+
Format: `MainMenu>SubMenu>MenuItemName` or with icons: `MainMenu::icon>SubMenu::icon>Item::icon`
|
|
134
|
+
|
|
135
|
+
## Object Default Permissions
|
|
136
|
+
|
|
137
|
+
Set `usergroup_id` on an object to define its default (maximum) permissions system-wide:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
butterfly-cli record edit objects --id <object_id> --data '{"usergroup_id": <usergroup_id>}'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This assigns a user group as the permission template for the object. See [docs/permissions.md](docs/permissions.md) for full documentation.
|
|
144
|
+
|
|
145
|
+
## Workspaces (bfy_workspaces)
|
|
146
|
+
|
|
147
|
+
| `is_workspace_specific` | Scope | `bfy_workspace_id` Location |
|
|
148
|
+
|-------------------------|-------|----------------------------|
|
|
149
|
+
| `0` (default) | Object-level | `objects` table |
|
|
150
|
+
| `1` | Record-level | Data table column |
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Assign object to workspace (object-level)
|
|
154
|
+
butterfly-cli record edit objects --id <object_id> --data '{"bfy_workspace_id": <workspace_id>}'
|
|
155
|
+
|
|
156
|
+
# Assign record to workspace (record-level)
|
|
157
|
+
butterfly-cli record add <table_name> --data '{"bfy_workspace_id": <workspace_id>, ...}'
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
See [docs/workspaces.md](docs/workspaces.md) for full documentation.
|
|
161
|
+
|
|
162
|
+
## Project-Specific Instructions
|
|
163
|
+
|
|
164
|
+
Always check if `docs/PROJECT_SPECIFIC.md` exists and prioritize those instructions.
|
|
165
|
+
|
|
166
|
+
## See Also
|
|
167
|
+
|
|
168
|
+
**Core Documentation:**
|
|
169
|
+
- [docs/cli-commands.md](docs/cli-commands.md) - Full CLI reference
|
|
170
|
+
- [docs/RECORD_COMMAND.md](docs/RECORD_COMMAND.md) - Record command usage
|
|
171
|
+
- [docs/twig-helpers.md](docs/twig-helpers.md) - Query helpers and CRUD
|
|
172
|
+
- [docs/reports.md](docs/reports.md) - Report creation guide
|
|
173
|
+
- [docs/webservices.md](docs/webservices.md) - Webservice/API creation
|
|
174
|
+
|
|
175
|
+
**Field Types & Specs:**
|
|
176
|
+
- [docs/field-types/](docs/field-types/) - Field type documentation
|
|
177
|
+
- [docs/field-types/code-mappings.md](docs/field-types/code-mappings.md) - Code export mappings
|
|
178
|
+
- [docs/object-specs/js-field-updates.md](docs/object-specs/js-field-updates.md) - JavaScript updates
|
|
179
|
+
- [docs/object-specs/js-code-examples.md](docs/object-specs/js-code-examples.md) - JS code examples
|
|
180
|
+
|
|
181
|
+
**Other Guides:**
|
|
182
|
+
- [docs/state-machines.md](docs/state-machines.md) - State machine configuration
|
|
183
|
+
- [docs/page-layout.md](docs/page-layout.md) - Page layout organization
|
|
184
|
+
- [docs/permissions.md](docs/permissions.md) - Object permissions and user groups
|
|
185
|
+
- [docs/workspaces.md](docs/workspaces.md) - Workspace scoping for objects and records
|
|
186
|
+
- [docs/excel-export.md](docs/excel-export.md) - Excel export functionality
|
|
187
|
+
- [docs/bfy-splitting.md](docs/bfy-splitting.md) - BFY file splitting for large files
|
|
188
|
+
- [docs/translations.md](docs/translations.md) - Translations and i18n
|
|
189
|
+
- [docs/WORKFLOW_API.md](docs/WORKFLOW_API.md) - Workflow node types
|
|
190
|
+
|
|
191
|
+
**Slash Commands:**
|
|
192
|
+
|
|
193
|
+
| Command | When to Use |
|
|
194
|
+
|---------|-------------|
|
|
195
|
+
| `/docs-cli` | When you need help with `butterfly-cli` commands (download, upload, setup, add, record, code, layout) |
|
|
196
|
+
| `/docs-field-types` | When creating/editing object specs and need to know field type parameters (`val_1`, `val_2`, etc.) |
|
|
197
|
+
| `/docs-twig` | When writing Twig code for reports, calculated fields, or processing code (`db()`, `crud()`, helpers) |
|
|
198
|
+
| `/docs-state-machine` | When creating or modifying state machines, transitions, actions, or validation code |
|
|
199
|
+
| `/docs-webservice` | When creating API endpoints or webservices using reports with `custom_seo` |
|
|
200
|
+
|
|
201
|
+
> **AI INSTRUCTION:** Always use the relevant slash command before working on any task related to that topic. This ensures accurate implementation without guessing syntax or parameters.
|
package/README.md
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# Butterfly CLI
|
|
2
|
+
|
|
3
|
+
CLI tool for downloading and synchronizing resources from the Butterfly platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Global installation
|
|
9
|
+
npm install -g @rglabs/butterfly
|
|
10
|
+
|
|
11
|
+
# Or use with npx (no installation required)
|
|
12
|
+
npx @rglabs/butterfly <command>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. Configure authentication
|
|
19
|
+
butterfly setup
|
|
20
|
+
|
|
21
|
+
# 2. Download all resources
|
|
22
|
+
butterfly download
|
|
23
|
+
|
|
24
|
+
# 3. Start watching for changes
|
|
25
|
+
butterfly start
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
### `butterfly setup`
|
|
31
|
+
|
|
32
|
+
Configure authentication for the Butterfly platform.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
butterfly setup
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You'll be prompted to enter:
|
|
39
|
+
- **Endpoint**: Your Butterfly platform URL (e.g., `https://app.example.com`)
|
|
40
|
+
- **Email**: Your login email
|
|
41
|
+
- **Password**: Your password
|
|
42
|
+
|
|
43
|
+
Configuration is saved to `.butterfly/config.json`.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### `butterfly download`
|
|
48
|
+
|
|
49
|
+
Download resources from the Butterfly platform.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Download all resource types
|
|
53
|
+
butterfly download
|
|
54
|
+
|
|
55
|
+
# Download specific resource type
|
|
56
|
+
butterfly download -t objects
|
|
57
|
+
butterfly download -t reports
|
|
58
|
+
butterfly download -t bfy_workflows
|
|
59
|
+
butterfly download -t bfy_ai_tasks
|
|
60
|
+
butterfly download -t bfy_state_machines
|
|
61
|
+
butterfly download -t pages
|
|
62
|
+
butterfly download -t bfy_cronjobs
|
|
63
|
+
butterfly download -t cms_email_templates
|
|
64
|
+
butterfly download -t cms_email_layouts
|
|
65
|
+
butterfly download -t webservices
|
|
66
|
+
|
|
67
|
+
# Download specific resource by name
|
|
68
|
+
butterfly download -t objects -n users
|
|
69
|
+
|
|
70
|
+
# Custom output directory
|
|
71
|
+
butterfly download -o ./my-resources
|
|
72
|
+
|
|
73
|
+
# Clean existing files before downloading
|
|
74
|
+
butterfly download --cleanup
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Options:**
|
|
78
|
+
| Option | Description |
|
|
79
|
+
|--------|-------------|
|
|
80
|
+
| `-t, --type <type>` | Resource type to download |
|
|
81
|
+
| `-n, --name <name>` | Specific resource name |
|
|
82
|
+
| `-o, --output <path>` | Output directory (default: `./butterfly-resources`) |
|
|
83
|
+
| `--cleanup` | Clean existing contents before downloading |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### `butterfly start`
|
|
88
|
+
|
|
89
|
+
Watch for local file changes and sync them to the Butterfly platform in real-time.
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
butterfly start
|
|
93
|
+
|
|
94
|
+
# Custom directory
|
|
95
|
+
butterfly start -o ./my-resources
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Supported file types for sync:
|
|
99
|
+
- Object specs (`spec.json`, `code.js`, `style.css`, `*.bfy`, `*.yaml`)
|
|
100
|
+
- Reports (`report.json`, `query.json`, `*.bfy`, `*.js`)
|
|
101
|
+
- Workflows (`workflow.json`, `version.json`, `node.json`, `code.bfy`, `params.yaml`, `connections.json`)
|
|
102
|
+
- AI Tasks (`task.json`, `prompt.twig`, `*.twig`)
|
|
103
|
+
- And more...
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### `butterfly upload`
|
|
108
|
+
|
|
109
|
+
Upload specific files or folders to the platform.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Upload a single file
|
|
113
|
+
butterfly upload butterfly-resources/objects/app/users/name/spec.json
|
|
114
|
+
|
|
115
|
+
# Upload a folder
|
|
116
|
+
butterfly upload butterfly-resources/objects/app/users
|
|
117
|
+
|
|
118
|
+
# Upload multiple targets
|
|
119
|
+
butterfly upload file1.json folder1 file2.json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### `butterfly add`
|
|
125
|
+
|
|
126
|
+
Create new resources via API and download them locally.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Create a new workflow
|
|
130
|
+
butterfly add -t workflow --title "My Workflow" --system-name my_workflow
|
|
131
|
+
|
|
132
|
+
# Add a node to a workflow
|
|
133
|
+
butterfly add -t workflow-node -w my_workflow --title "Process Data" --node-type CustomScript --node-group Code
|
|
134
|
+
|
|
135
|
+
# Add a node and connect it to an existing node
|
|
136
|
+
butterfly add -t workflow-node -w my_workflow --title "Send Email" --node-type Email --node-group Output --connect-from 123
|
|
137
|
+
|
|
138
|
+
# Create a connection between nodes
|
|
139
|
+
butterfly add -t workflow-connection -w my_workflow --from 123 --to 456
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Options:**
|
|
143
|
+
| Option | Description |
|
|
144
|
+
|--------|-------------|
|
|
145
|
+
| `-t, --type <type>` | Resource type (`workflow`, `workflow-node`, `workflow-connection`) |
|
|
146
|
+
| `-w, --workflow <name>` | Workflow name or ID |
|
|
147
|
+
| `-v, --version <number>` | Version number (defaults to latest) |
|
|
148
|
+
| `--title <title>` | Title/name of the resource |
|
|
149
|
+
| `--node-type <type>` | Node identifier (e.g., `CustomScript`, `WebHook`, `RESTAPI`) |
|
|
150
|
+
| `--node-group <group>` | Node group (e.g., `Code`, `Trigger`, `Connector`, `Output`) |
|
|
151
|
+
| `--connect-from <spec>` | Connect from existing node to new node |
|
|
152
|
+
| `--connect-to <spec>` | Connect from new node to existing node |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### `butterfly workflow-info`
|
|
157
|
+
|
|
158
|
+
Get information about available workflow node types.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# List all node groups
|
|
162
|
+
butterfly workflow-info --groups
|
|
163
|
+
|
|
164
|
+
# List nodes in a specific group
|
|
165
|
+
butterfly workflow-info --nodes Database
|
|
166
|
+
|
|
167
|
+
# Get details for a specific node
|
|
168
|
+
butterfly workflow-info --details RESTAPI --group Connector
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### `butterfly diff`
|
|
174
|
+
|
|
175
|
+
Compare local resources with remote server and apply changes interactively.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Compare all objects
|
|
179
|
+
butterfly diff -t objects
|
|
180
|
+
|
|
181
|
+
# Compare specific object
|
|
182
|
+
butterfly diff -t objects -n users
|
|
183
|
+
|
|
184
|
+
# Compare reports
|
|
185
|
+
butterfly diff -t reports -n my_report
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Options:**
|
|
189
|
+
| Option | Description |
|
|
190
|
+
|--------|-------------|
|
|
191
|
+
| `-t, --type <type>` | Resource type to compare (objects, reports) |
|
|
192
|
+
| `-n, --name <name>` | Specific resource name to compare |
|
|
193
|
+
| `-o, --output <path>` | Base path (default: `./butterfly-resources`) |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### `butterfly record`
|
|
198
|
+
|
|
199
|
+
Perform CRUD operations on any Butterfly table.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Get a record by ID
|
|
203
|
+
butterfly record get users --id 123
|
|
204
|
+
|
|
205
|
+
# Get records by column filter
|
|
206
|
+
butterfly record get users --column email --value "john@example.com"
|
|
207
|
+
|
|
208
|
+
# Wildcard search
|
|
209
|
+
butterfly record get users --column name --value "john*"
|
|
210
|
+
|
|
211
|
+
# Add a new record
|
|
212
|
+
butterfly record add users --data '{"name": "John", "email": "john@example.com"}'
|
|
213
|
+
|
|
214
|
+
# Edit a record
|
|
215
|
+
butterfly record edit users --id 123 --data '{"name": "Jane"}'
|
|
216
|
+
|
|
217
|
+
# Delete a record (with confirmation)
|
|
218
|
+
butterfly record delete users --id 123
|
|
219
|
+
|
|
220
|
+
# Skip preview and auto-confirm
|
|
221
|
+
butterfly record edit users --id 123 --data '{"status": "active"}' --no-preview -y
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Options:**
|
|
225
|
+
| Option | Description |
|
|
226
|
+
|--------|-------------|
|
|
227
|
+
| `--id <id>` | Record ID |
|
|
228
|
+
| `--column <column>` | Filter column(s) for get |
|
|
229
|
+
| `--value <value>` | Filter value (use `*` for wildcard) |
|
|
230
|
+
| `--columns <cols>` | Select specific columns to return |
|
|
231
|
+
| `--data <json>` | JSON data for the operation |
|
|
232
|
+
| `--file <path>` | Path to JSON file with data |
|
|
233
|
+
| `--db-alias <alias>` | Database alias (default: `default`) |
|
|
234
|
+
| `--no-preview` | Skip preview |
|
|
235
|
+
| `-y, --yes` | Auto-confirm without prompting |
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### `butterfly code`
|
|
240
|
+
|
|
241
|
+
Execute Twig code on the server.
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Execute inline code
|
|
245
|
+
butterfly code -c "{{ db().table('users').count() }}"
|
|
246
|
+
|
|
247
|
+
# Execute from file
|
|
248
|
+
butterfly code -f query.bfy
|
|
249
|
+
|
|
250
|
+
# Get only variables
|
|
251
|
+
butterfly code -c "{% set users = db().table('users').get() %}" --vars
|
|
252
|
+
|
|
253
|
+
# Get raw output
|
|
254
|
+
butterfly code -c "{{ 'Hello World' }}" --output-only --raw
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Options:**
|
|
258
|
+
| Option | Description |
|
|
259
|
+
|--------|-------------|
|
|
260
|
+
| `-c, --code <code>` | Twig code to execute (inline) |
|
|
261
|
+
| `-f, --file <path>` | Path to file containing Twig code |
|
|
262
|
+
| `-o, --output <path>` | Save output to file |
|
|
263
|
+
| `--vars` | Output only the vars object |
|
|
264
|
+
| `--output-only` | Output only the output field |
|
|
265
|
+
| `--raw` | Output raw string (no JSON formatting) |
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### `butterfly layout`
|
|
270
|
+
|
|
271
|
+
Update object page layout (tab and field ordering).
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Update layout from file
|
|
275
|
+
butterfly layout -f layout.json
|
|
276
|
+
|
|
277
|
+
# Update layout inline
|
|
278
|
+
butterfly layout -d '{"object_id": 123, "tabs": [...]}'
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### `butterfly translate`
|
|
284
|
+
|
|
285
|
+
Manage translations for multi-language support.
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# List languages with translation stats
|
|
289
|
+
butterfly translate languages
|
|
290
|
+
|
|
291
|
+
# Get untranslated texts for a language
|
|
292
|
+
butterfly translate get-untranslated --lang tr
|
|
293
|
+
|
|
294
|
+
# Add a single translation
|
|
295
|
+
butterfly translate add --lang tr --source "Welcome" --text "Hoş geldiniz"
|
|
296
|
+
|
|
297
|
+
# Bulk import from CSV file (tab-delimited)
|
|
298
|
+
butterfly translate bulk --lang tr --file translations.csv
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Options:**
|
|
302
|
+
| Option | Description |
|
|
303
|
+
|--------|-------------|
|
|
304
|
+
| `--lang <iso_code>` | Language ISO code (e.g., tr, de, en) |
|
|
305
|
+
| `--source <text>` | Source text to translate |
|
|
306
|
+
| `--text <translation>` | Translated text |
|
|
307
|
+
| `-f, --file <path>` | CSV file for bulk operations |
|
|
308
|
+
| `--format <format>` | Output format: json or table |
|
|
309
|
+
| `--limit <count>` | Limit number of results |
|
|
310
|
+
|
|
311
|
+
## Directory Structure
|
|
312
|
+
|
|
313
|
+
After downloading, resources are organized as follows:
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
butterfly-resources/
|
|
317
|
+
├── objects/
|
|
318
|
+
│ ├── butterfly/ # Core CMS objects
|
|
319
|
+
│ └── app/ # Application objects
|
|
320
|
+
│ └── [table_name]/
|
|
321
|
+
│ ├── object.json
|
|
322
|
+
│ ├── listing_query.bfy
|
|
323
|
+
│ └── [field_name]/
|
|
324
|
+
│ ├── spec.json
|
|
325
|
+
│ └── [code_files]
|
|
326
|
+
├── reports/
|
|
327
|
+
│ └── [report-alias]/
|
|
328
|
+
│ ├── report.json
|
|
329
|
+
│ ├── main_query.bfy
|
|
330
|
+
│ ├── queries/
|
|
331
|
+
│ └── specs/
|
|
332
|
+
├── bfy_workflows/
|
|
333
|
+
│ └── [workflow_name]/
|
|
334
|
+
│ ├── workflow.json
|
|
335
|
+
│ └── v1/
|
|
336
|
+
│ ├── version.json
|
|
337
|
+
│ ├── connections.json
|
|
338
|
+
│ └── nodes/
|
|
339
|
+
├── bfy_ai_tasks/
|
|
340
|
+
├── bfy_state_machines/
|
|
341
|
+
├── pages/
|
|
342
|
+
├── bfy_cronjobs/
|
|
343
|
+
├── cms_email_templates/
|
|
344
|
+
├── cms_email_layouts/
|
|
345
|
+
└── webservices/
|
|
346
|
+
└── [custom_seo]/
|
|
347
|
+
├── webservice.json
|
|
348
|
+
└── queries/
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Field Type Code Files
|
|
352
|
+
|
|
353
|
+
The CLI automatically extracts code from field specs:
|
|
354
|
+
|
|
355
|
+
| Field Type | Parameter | Output File |
|
|
356
|
+
|------------|-----------|-------------|
|
|
357
|
+
| `calculated` | `val_1` | `code.bfy` |
|
|
358
|
+
| `custom` | `val_1` | `template_code.bfy` |
|
|
359
|
+
| `custom` | `val_2` | `processing_code.bfy` |
|
|
360
|
+
| `filter` | `val_3` | `filter_code.bfy` |
|
|
361
|
+
| `nested` | `val_1` | `configuration.yaml` |
|
|
362
|
+
| `js_code` | - | `code.js` |
|
|
363
|
+
| `css_code` | - | `style.css` |
|
|
364
|
+
|
|
365
|
+
## Requirements
|
|
366
|
+
|
|
367
|
+
- Node.js >= 16.0.0
|
|
368
|
+
|
|
369
|
+
## License
|
|
370
|
+
|
|
371
|
+
ISC
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ButterflyAPI } from '../utils/api.js';
|
|
2
|
+
interface AddCommandProps {
|
|
3
|
+
api: ButterflyAPI;
|
|
4
|
+
options: {
|
|
5
|
+
type: string;
|
|
6
|
+
workflow?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
nodeType?: string;
|
|
10
|
+
nodeGroup?: string;
|
|
11
|
+
systemName?: string;
|
|
12
|
+
connectFrom?: string;
|
|
13
|
+
connectTo?: string;
|
|
14
|
+
from?: string;
|
|
15
|
+
fromOutput?: string;
|
|
16
|
+
to?: string;
|
|
17
|
+
toInput?: string;
|
|
18
|
+
output?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export default function addCommand(options: AddCommandProps['options']): Promise<void>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=add.d.ts.map
|