@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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ButterflyAPI } from '../../utils/api.js';
|
|
2
|
+
import { ResourceDiff } from '../types.js';
|
|
3
|
+
export interface LocalResource {
|
|
4
|
+
main: Record<string, any>;
|
|
5
|
+
children: Record<string, any[]>;
|
|
6
|
+
path: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RemoteResource {
|
|
9
|
+
main: Record<string, any>;
|
|
10
|
+
children: Record<string, any[]>;
|
|
11
|
+
}
|
|
12
|
+
export interface ResourceAdapter {
|
|
13
|
+
readonly resourceType: string;
|
|
14
|
+
loadLocal(basePath: string): Promise<Map<number, LocalResource>>;
|
|
15
|
+
fetchRemote(api: ButterflyAPI): Promise<Map<number, RemoteResource>>;
|
|
16
|
+
compare(local: LocalResource | null, remote: RemoteResource | null, localPath?: string): ResourceDiff;
|
|
17
|
+
getDisplayName(data: Record<string, any>): string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ButterflyAPI } from '../utils/api.js';
|
|
2
|
+
import { ResourceDiff, DiffOptions, DiffSummary } from './types.js';
|
|
3
|
+
import { ResourceAdapter } from './adapters/index.js';
|
|
4
|
+
export interface DiffEngineCallbacks {
|
|
5
|
+
onProgress?: (message: string) => void;
|
|
6
|
+
onLoadingLocal?: (type: string) => void;
|
|
7
|
+
onFetchingRemote?: (type: string) => void;
|
|
8
|
+
onComparing?: (type: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class DiffEngine {
|
|
11
|
+
private adapters;
|
|
12
|
+
constructor();
|
|
13
|
+
getAdapters(): Map<string, ResourceAdapter>;
|
|
14
|
+
getSupportedTypes(): string[];
|
|
15
|
+
diff(api: ButterflyAPI, basePath: string, options?: DiffOptions, callbacks?: DiffEngineCallbacks): Promise<ResourceDiff[]>;
|
|
16
|
+
getSummary(diffs: ResourceDiff[]): DiffSummary;
|
|
17
|
+
groupByType(diffs: ResourceDiff[]): Map<string, ResourceDiff[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { calculateSummary } from './types.js';
|
|
2
|
+
import { getAdapters } from './adapters/index.js';
|
|
3
|
+
export class DiffEngine {
|
|
4
|
+
adapters;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.adapters = getAdapters();
|
|
7
|
+
}
|
|
8
|
+
getAdapters() {
|
|
9
|
+
return this.adapters;
|
|
10
|
+
}
|
|
11
|
+
getSupportedTypes() {
|
|
12
|
+
return Array.from(this.adapters.keys());
|
|
13
|
+
}
|
|
14
|
+
async diff(api, basePath, options = {}, callbacks = {}) {
|
|
15
|
+
const results = [];
|
|
16
|
+
const typesToDiff = options.type
|
|
17
|
+
? [options.type]
|
|
18
|
+
: Array.from(this.adapters.keys());
|
|
19
|
+
for (const type of typesToDiff) {
|
|
20
|
+
const adapter = this.adapters.get(type);
|
|
21
|
+
if (!adapter) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
callbacks.onLoadingLocal?.(type);
|
|
25
|
+
const local = await adapter.loadLocal(basePath);
|
|
26
|
+
callbacks.onFetchingRemote?.(type);
|
|
27
|
+
const remote = await adapter.fetchRemote(api);
|
|
28
|
+
callbacks.onComparing?.(type);
|
|
29
|
+
const allIds = new Set([...local.keys(), ...remote.keys()]);
|
|
30
|
+
for (const id of allIds) {
|
|
31
|
+
const localResource = local.get(id) || null;
|
|
32
|
+
const remoteResource = remote.get(id) || null;
|
|
33
|
+
const diff = adapter.compare(localResource, remoteResource);
|
|
34
|
+
if (options.name && diff.resourceName !== options.name) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (diff.status !== 'unchanged') {
|
|
38
|
+
results.push(diff);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
getSummary(diffs) {
|
|
45
|
+
return calculateSummary(diffs);
|
|
46
|
+
}
|
|
47
|
+
groupByType(diffs) {
|
|
48
|
+
const grouped = new Map();
|
|
49
|
+
for (const diff of diffs) {
|
|
50
|
+
const existing = grouped.get(diff.resourceType) || [];
|
|
51
|
+
existing.push(diff);
|
|
52
|
+
grouped.set(diff.resourceType, existing);
|
|
53
|
+
}
|
|
54
|
+
return grouped;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type DiffStatus = 'unchanged' | 'local_only' | 'remote_only' | 'modified';
|
|
2
|
+
export interface FieldDiff {
|
|
3
|
+
field: string;
|
|
4
|
+
localValue: any;
|
|
5
|
+
remoteValue: any;
|
|
6
|
+
status: DiffStatus;
|
|
7
|
+
}
|
|
8
|
+
export interface ResourceDiff {
|
|
9
|
+
resourceType: string;
|
|
10
|
+
resourceName: string;
|
|
11
|
+
resourceId: number;
|
|
12
|
+
localPath?: string;
|
|
13
|
+
status: DiffStatus;
|
|
14
|
+
fieldDiffs: FieldDiff[];
|
|
15
|
+
children?: ResourceDiff[];
|
|
16
|
+
}
|
|
17
|
+
export interface DiffSummary {
|
|
18
|
+
totalResources: number;
|
|
19
|
+
unchanged: number;
|
|
20
|
+
modified: number;
|
|
21
|
+
localOnly: number;
|
|
22
|
+
remoteOnly: number;
|
|
23
|
+
}
|
|
24
|
+
export interface DiffOptions {
|
|
25
|
+
type?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
output?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const IGNORE_FIELDS: string[];
|
|
30
|
+
export declare function valuesEqual(a: any, b: any): boolean;
|
|
31
|
+
export declare function compareFields(local: Record<string, any> | null, remote: Record<string, any> | null, ignoreFields?: string[]): FieldDiff[];
|
|
32
|
+
export declare function formatValue(value: any, maxLength?: number): string;
|
|
33
|
+
export declare function calculateSummary(diffs: ResourceDiff[]): DiffSummary;
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export const IGNORE_FIELDS = [
|
|
2
|
+
'updated_at',
|
|
3
|
+
'created_at',
|
|
4
|
+
'updated_by',
|
|
5
|
+
'created_by'
|
|
6
|
+
];
|
|
7
|
+
export function valuesEqual(a, b) {
|
|
8
|
+
if (a === null || a === undefined) {
|
|
9
|
+
return b === null || b === undefined;
|
|
10
|
+
}
|
|
11
|
+
if (b === null || b === undefined) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (typeof a !== 'object' && typeof b !== 'object') {
|
|
15
|
+
return String(a) === String(b);
|
|
16
|
+
}
|
|
17
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
18
|
+
}
|
|
19
|
+
function isDefaultValue(value) {
|
|
20
|
+
return value === null || value === '' || value === 0 || value === '0';
|
|
21
|
+
}
|
|
22
|
+
export function compareFields(local, remote, ignoreFields = IGNORE_FIELDS) {
|
|
23
|
+
const diffs = [];
|
|
24
|
+
if (!local && !remote) {
|
|
25
|
+
return diffs;
|
|
26
|
+
}
|
|
27
|
+
const allFields = new Set([
|
|
28
|
+
...Object.keys(local || {}),
|
|
29
|
+
...Object.keys(remote || {})
|
|
30
|
+
]);
|
|
31
|
+
for (const field of allFields) {
|
|
32
|
+
if (ignoreFields.includes(field))
|
|
33
|
+
continue;
|
|
34
|
+
const localVal = local?.[field];
|
|
35
|
+
const remoteVal = remote?.[field];
|
|
36
|
+
let status;
|
|
37
|
+
if (valuesEqual(localVal, remoteVal)) {
|
|
38
|
+
status = 'unchanged';
|
|
39
|
+
}
|
|
40
|
+
else if (localVal === undefined && isDefaultValue(remoteVal)) {
|
|
41
|
+
status = 'unchanged';
|
|
42
|
+
}
|
|
43
|
+
else if (remoteVal === undefined && isDefaultValue(localVal)) {
|
|
44
|
+
status = 'unchanged';
|
|
45
|
+
}
|
|
46
|
+
else if (localVal === undefined) {
|
|
47
|
+
status = 'remote_only';
|
|
48
|
+
}
|
|
49
|
+
else if (remoteVal === undefined) {
|
|
50
|
+
status = 'local_only';
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
status = 'modified';
|
|
54
|
+
}
|
|
55
|
+
if (status !== 'unchanged') {
|
|
56
|
+
diffs.push({
|
|
57
|
+
field,
|
|
58
|
+
localValue: localVal,
|
|
59
|
+
remoteValue: remoteVal,
|
|
60
|
+
status
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return diffs;
|
|
65
|
+
}
|
|
66
|
+
export function formatValue(value, maxLength = 60) {
|
|
67
|
+
if (value === null)
|
|
68
|
+
return '<null>';
|
|
69
|
+
if (value === undefined)
|
|
70
|
+
return '<undefined>';
|
|
71
|
+
if (typeof value === 'object') {
|
|
72
|
+
const json = JSON.stringify(value);
|
|
73
|
+
if (json.length > maxLength) {
|
|
74
|
+
return json.substring(0, maxLength) + '...';
|
|
75
|
+
}
|
|
76
|
+
return json;
|
|
77
|
+
}
|
|
78
|
+
const str = String(value);
|
|
79
|
+
if (str.length > maxLength) {
|
|
80
|
+
return str.substring(0, maxLength) + '...';
|
|
81
|
+
}
|
|
82
|
+
return str;
|
|
83
|
+
}
|
|
84
|
+
export function calculateSummary(diffs) {
|
|
85
|
+
const summary = {
|
|
86
|
+
totalResources: diffs.length,
|
|
87
|
+
unchanged: 0,
|
|
88
|
+
modified: 0,
|
|
89
|
+
localOnly: 0,
|
|
90
|
+
remoteOnly: 0
|
|
91
|
+
};
|
|
92
|
+
for (const diff of diffs) {
|
|
93
|
+
switch (diff.status) {
|
|
94
|
+
case 'unchanged':
|
|
95
|
+
summary.unchanged++;
|
|
96
|
+
break;
|
|
97
|
+
case 'modified':
|
|
98
|
+
summary.modified++;
|
|
99
|
+
break;
|
|
100
|
+
case 'local_only':
|
|
101
|
+
summary.localOnly++;
|
|
102
|
+
break;
|
|
103
|
+
case 'remote_only':
|
|
104
|
+
summary.remoteOnly++;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return summary;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=types.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import { config } from 'dotenv';
|
|
4
|
+
import setupCommand from './commands/setup.js';
|
|
5
|
+
import downloadCommand from './commands/download.js';
|
|
6
|
+
import uploadCommand from './commands/upload.js';
|
|
7
|
+
import diffCommand from './commands/diff.js';
|
|
8
|
+
import addCommand from './commands/add.js';
|
|
9
|
+
import workflowInfoCommand from './commands/workflow-info.js';
|
|
10
|
+
import recordCommand from './commands/record.js';
|
|
11
|
+
import codeCommand from './commands/code.js';
|
|
12
|
+
import layoutCommand from './commands/layout.js';
|
|
13
|
+
import syncDocsCommand from './commands/sync-docs.js';
|
|
14
|
+
import translateCommand from './commands/translate.js';
|
|
15
|
+
config();
|
|
16
|
+
program
|
|
17
|
+
.name('butterfly-cli')
|
|
18
|
+
.description('CLI tool to download resources from the Butterfly platform')
|
|
19
|
+
.version('2.0.1');
|
|
20
|
+
program
|
|
21
|
+
.command('setup')
|
|
22
|
+
.description('Configure authentication for the Butterfly platform')
|
|
23
|
+
.action(setupCommand);
|
|
24
|
+
program
|
|
25
|
+
.command('download')
|
|
26
|
+
.description('Download resources from the Butterfly platform')
|
|
27
|
+
.option('-t, --type <type>', 'Resource type to download (objects, reports, bfy_ai_tasks, bfy_state_machines, pages, bfy_cronjobs, cms_email_templates, cms_email_layouts, bfy_workflows, webservices, translations)')
|
|
28
|
+
.option('-n, --name <name>', 'Specific resource name to download')
|
|
29
|
+
.option('-o, --output <path>', 'Output directory path', './butterfly-resources')
|
|
30
|
+
.option('--cleanup', 'Clean existing contents before downloading')
|
|
31
|
+
.action(downloadCommand);
|
|
32
|
+
program
|
|
33
|
+
.command('diff')
|
|
34
|
+
.description('Compare local resources with remote server and apply changes interactively')
|
|
35
|
+
.option('-t, --type <type>', 'Resource type to compare (objects, reports)')
|
|
36
|
+
.option('-n, --name <name>', 'Specific resource name to compare')
|
|
37
|
+
.option('-o, --output <path>', 'Base path', './butterfly-resources')
|
|
38
|
+
.action(diffCommand);
|
|
39
|
+
program
|
|
40
|
+
.command('upload <targets...>')
|
|
41
|
+
.description('Upload files or folders to the Butterfly platform')
|
|
42
|
+
.action(uploadCommand);
|
|
43
|
+
program
|
|
44
|
+
.command('add')
|
|
45
|
+
.description('Create new resources via API and download them')
|
|
46
|
+
.option('-t, --type <type>', 'Resource type to create (workflow, workflow-node, workflow-connection)')
|
|
47
|
+
.option('-w, --workflow <name>', 'Workflow name or ID (for workflow-node, workflow-connection)')
|
|
48
|
+
.option('-v, --version <number>', 'Version number (defaults to latest)')
|
|
49
|
+
.option('--title <title>', 'Title/name of the resource')
|
|
50
|
+
.option('--node-type <type>', 'Node identifier key (e.g., CustomScript, WebHook, RESTAPI)')
|
|
51
|
+
.option('--node-group <group>', 'Node group class (e.g., Code, Trigger, Connector, Output)')
|
|
52
|
+
.option('--system-name <name>', 'System name for the resource')
|
|
53
|
+
.option('--connect-from <spec>', 'Connect FROM existing node TO new node (format: node_id[:output_key])')
|
|
54
|
+
.option('--connect-to <spec>', 'Connect FROM new node TO existing node (format: node_id[:input_key])')
|
|
55
|
+
.option('--from <id>', 'Source node ID (for workflow-connection)')
|
|
56
|
+
.option('--from-output <key>', 'Source node output key (default: output)')
|
|
57
|
+
.option('--to <id>', 'Target node ID (for workflow-connection)')
|
|
58
|
+
.option('--to-input <key>', 'Target node input key (default: input)')
|
|
59
|
+
.option('-o, --output <path>', 'Output directory path', './butterfly-resources')
|
|
60
|
+
.action(addCommand);
|
|
61
|
+
program
|
|
62
|
+
.command('workflow-info')
|
|
63
|
+
.description('Get information about workflow node groups and node types')
|
|
64
|
+
.option('--groups', 'List all available node groups')
|
|
65
|
+
.option('--nodes <group>', 'List nodes in a specific group (e.g., --nodes Database)')
|
|
66
|
+
.option('--details <node>', 'Get details for a specific node (requires --group)')
|
|
67
|
+
.option('--group <group>', 'Node group for --details option')
|
|
68
|
+
.action(workflowInfoCommand);
|
|
69
|
+
program
|
|
70
|
+
.command('record <operation> <table>')
|
|
71
|
+
.description('Perform CRUD operations (get/add/edit/delete) on any Butterfly table with preview')
|
|
72
|
+
.option('--id <id>', 'Record ID (required for edit/delete, optional for get)')
|
|
73
|
+
.option('--column <column>', 'Filter column(s) for get (comma-separated for OR search, e.g., "name,title")')
|
|
74
|
+
.option('--value <value>', 'Filter value (use * for wildcard, e.g., "test*" for LIKE)')
|
|
75
|
+
.option('--columns <columns>', 'Select specific columns to return (comma-separated, e.g., "id,name,status")')
|
|
76
|
+
.option('--data <json>', 'JSON data for the operation')
|
|
77
|
+
.option('--file <path>', 'Path to JSON file with data')
|
|
78
|
+
.option('--db-alias <alias>', 'Database alias', 'default')
|
|
79
|
+
.option('--preview', 'Show preview before executing (default: true)', true)
|
|
80
|
+
.option('--no-preview', 'Skip preview and execute directly')
|
|
81
|
+
.option('-y, --yes', 'Auto-confirm without prompting')
|
|
82
|
+
.option('--output <path>', 'For get: save record(s) to file instead of stdout')
|
|
83
|
+
.action(recordCommand);
|
|
84
|
+
program
|
|
85
|
+
.command('code')
|
|
86
|
+
.description('Execute Twig code on the server and retrieve variables/output')
|
|
87
|
+
.option('-c, --code <code>', 'Twig code to execute (inline)')
|
|
88
|
+
.option('-f, --file <path>', 'Path to file containing Twig code')
|
|
89
|
+
.option('-o, --output <path>', 'Save output to file instead of stdout')
|
|
90
|
+
.option('--vars', 'Output only the vars object')
|
|
91
|
+
.option('--output-only', 'Output only the output field')
|
|
92
|
+
.option('--raw', 'Output raw string (no JSON formatting) for --output-only')
|
|
93
|
+
.action(codeCommand);
|
|
94
|
+
program
|
|
95
|
+
.command('layout')
|
|
96
|
+
.description('Update object page layout (tab and field ordering)')
|
|
97
|
+
.option('-f, --file <path>', 'Path to JSON file with layout data')
|
|
98
|
+
.option('-d, --data <json>', 'Inline JSON layout data')
|
|
99
|
+
.action(layoutCommand);
|
|
100
|
+
program
|
|
101
|
+
.command('sync-docs')
|
|
102
|
+
.description('Sync documentation files from the CLI package to the project')
|
|
103
|
+
.action(syncDocsCommand);
|
|
104
|
+
program
|
|
105
|
+
.command('translate <operation>')
|
|
106
|
+
.description('Manage translations (get-untranslated, add, bulk, languages)')
|
|
107
|
+
.option('--lang <iso_code>', 'Language ISO code (e.g., tr, de, en)')
|
|
108
|
+
.option('--lang-id <id>', 'Language ID')
|
|
109
|
+
.option('--source <text>', 'Source text to translate')
|
|
110
|
+
.option('--source-id <id>', 'Source text ID')
|
|
111
|
+
.option('--text <translation>', 'Translated text')
|
|
112
|
+
.option('-f, --file <path>', 'CSV file (tab-delimited) for bulk operations')
|
|
113
|
+
.option('--format <format>', 'Output format: json or table (default: table)')
|
|
114
|
+
.option('--limit <count>', 'Limit number of results')
|
|
115
|
+
.action(translateCommand);
|
|
116
|
+
program.parse();
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AuthConfig {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
email: string;
|
|
4
|
+
password: string;
|
|
5
|
+
core?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface DownloadOptions {
|
|
8
|
+
type?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
output?: string;
|
|
11
|
+
cleanup?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ApiResponse<T> {
|
|
14
|
+
success: boolean;
|
|
15
|
+
data?: T;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AuthConfig } from '../types/index.js';
|
|
3
|
+
export declare class ButterflyAPI {
|
|
4
|
+
private config;
|
|
5
|
+
private client;
|
|
6
|
+
private cookieJar;
|
|
7
|
+
private csrfToken?;
|
|
8
|
+
private lastValidated?;
|
|
9
|
+
private debug;
|
|
10
|
+
private pending2FAData;
|
|
11
|
+
private static readonly VALIDATION_CACHE_TTL;
|
|
12
|
+
constructor(config: AuthConfig);
|
|
13
|
+
private getCookiesPath;
|
|
14
|
+
private getLogPath;
|
|
15
|
+
private logRequest;
|
|
16
|
+
private saveCookies;
|
|
17
|
+
private loadCookies;
|
|
18
|
+
private isRecentlyValidated;
|
|
19
|
+
private isSessionValid;
|
|
20
|
+
fetchCSRFToken(): Promise<string>;
|
|
21
|
+
private promptForInput;
|
|
22
|
+
private handle2FAVerification;
|
|
23
|
+
get needs2FA(): boolean;
|
|
24
|
+
complete2FA(): Promise<void>;
|
|
25
|
+
authenticate(): Promise<void>;
|
|
26
|
+
get httpClient(): AxiosInstance;
|
|
27
|
+
downloadResource(type: string, name?: string): Promise<any[]>;
|
|
28
|
+
fetchTable(tableName: string, column?: string, value?: string): Promise<any[]>;
|
|
29
|
+
fetchTableAdvanced(tableName: string, options?: {
|
|
30
|
+
column?: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
columns?: string;
|
|
33
|
+
dbAlias?: string;
|
|
34
|
+
}): Promise<any[]>;
|
|
35
|
+
fetchObjects(): Promise<any[]>;
|
|
36
|
+
fetchCMSObjects(): Promise<any[]>;
|
|
37
|
+
fetchObjectSpecs(objectId: number): Promise<any[]>;
|
|
38
|
+
fetchAllObjectSpecs(): Promise<any[]>;
|
|
39
|
+
fetchReports(): Promise<any[]>;
|
|
40
|
+
fetchReportCategories(): Promise<any[]>;
|
|
41
|
+
fetchReportSpecs(reportId: number): Promise<any[]>;
|
|
42
|
+
fetchReportQueries(reportId: number): Promise<any[]>;
|
|
43
|
+
fetchAllReportSpecs(): Promise<any[]>;
|
|
44
|
+
fetchAllReportQueries(): Promise<any[]>;
|
|
45
|
+
updateReport(reportId: number, updateData: Record<string, any>): Promise<any>;
|
|
46
|
+
createReport(reportData: Record<string, any>): Promise<any>;
|
|
47
|
+
updateReportSpec(specId: number, updateData: Record<string, any>): Promise<any>;
|
|
48
|
+
createReportSpec(specData: Record<string, any>): Promise<any>;
|
|
49
|
+
updateReportQuery(queryId: number, updateData: Record<string, any>): Promise<any>;
|
|
50
|
+
createReportQuery(queryData: Record<string, any>): Promise<any>;
|
|
51
|
+
uploadResource(filePath: string, data: any): Promise<any>;
|
|
52
|
+
private updateObject;
|
|
53
|
+
private updateObjectSpec;
|
|
54
|
+
private updateReportFromData;
|
|
55
|
+
private updateReportSpecFromData;
|
|
56
|
+
createWorkflowConnection(connectionData: Record<string, any>): Promise<any>;
|
|
57
|
+
updateWorkflowConnection(connectionId: number, updateData: Record<string, any>): Promise<any>;
|
|
58
|
+
deleteWorkflowConnection(connectionId: number): Promise<any>;
|
|
59
|
+
createWorkflowNode(nodeData: Record<string, any>): Promise<any>;
|
|
60
|
+
updateWorkflowNode(nodeId: number, updateData: Record<string, any>): Promise<any>;
|
|
61
|
+
deleteWorkflowNode(nodeId: number): Promise<any>;
|
|
62
|
+
createWorkflowVersion(versionData: Record<string, any>): Promise<any>;
|
|
63
|
+
updateWorkflowVersion(versionId: number, updateData: Record<string, any>): Promise<any>;
|
|
64
|
+
publishWorkflowVersion(versionId: number): Promise<any>;
|
|
65
|
+
archiveWorkflowVersion(versionId: number): Promise<any>;
|
|
66
|
+
executeCode(code: string): Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
vars?: Record<string, any>;
|
|
69
|
+
output?: string;
|
|
70
|
+
error?: string;
|
|
71
|
+
}>;
|
|
72
|
+
fetchRecordById(tableName: string, id: number, _dbAlias?: string): Promise<Record<string, any> | null>;
|
|
73
|
+
performOperation(tableName: string, operation: 'add' | 'edit' | 'delete', data: Record<string, any>, dbAlias?: string): Promise<{
|
|
74
|
+
success: boolean;
|
|
75
|
+
id?: number;
|
|
76
|
+
error?: string;
|
|
77
|
+
message?: string;
|
|
78
|
+
xtra?: {
|
|
79
|
+
type: string;
|
|
80
|
+
alias: string;
|
|
81
|
+
message: string;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=api.d.ts.map
|