@mexty/cli 1.3.0 → 1.4.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.
@@ -0,0 +1,491 @@
1
+ # MEXTY Blocks: Interactive Reusable Components
2
+
3
+ ## What are Blocks?
4
+
5
+ Blocks are **interactive, reusable, and customizable React components** that can be embedded anywhere. They are the core building blocks of the MEXTY platform, designed to create rich, engaging experiences that can be easily shared and integrated.
6
+
7
+ ## Key Characteristics
8
+
9
+ ### 1. **Interactive**
10
+
11
+ - Blocks are fully functional React components with state management
12
+ - Support user interactions like clicks, form inputs, animations, and real-time updates
13
+ - Can include complex UI elements like charts, games, quizzes, media players, etc.
14
+
15
+ ### 2. **Reusable**
16
+
17
+ - Once created, blocks can be used multiple times across different contexts
18
+ - Published blocks can be discovered and used by other users
19
+ - Blocks maintain their functionality regardless of where they're embedded
20
+
21
+ ### 3. **Customizable via Props**
22
+
23
+ - Blocks accept **props** (properties) that allow customization without code changes
24
+ - Props can be of various types: strings, numbers, booleans, colors, URLs, arrays, objects
25
+ - Users can modify block behavior and appearance through a visual props editor
26
+
27
+ ## Props System
28
+
29
+ The props system is the heart of block customization:
30
+
31
+ ### Supported Prop Types
32
+
33
+ - **String**: Text content, labels, descriptions
34
+ - **Number**: Quantities, dimensions, durations
35
+ - **Boolean**: Toggle features on/off
36
+ - **Color**: Theme colors, backgrounds, text colors
37
+ - **Image URL**: Pictures, icons, backgrounds
38
+ - **Video URL**: Video content, tutorials
39
+ - **Audio URL**: Sound effects, music, narration
40
+ - **3D Model URL**: GLB/GLTF files for 3D content
41
+ - **Array**: Lists of items, datasets
42
+ - **Object**: Complex nested configurations
43
+ - **Enum**: Predefined choices (dropdown selections)
44
+
45
+ ### Props Editor Features
46
+
47
+ - **Visual Interface**: No code required to customize blocks
48
+ - **Real-time Preview**: See changes instantly as you edit props
49
+ - **Media Integration**: Upload files, select from workspace, or use AI generation
50
+ - **Nested Objects**: Support for complex data structures
51
+ - **Array Management**: Add/remove items dynamically
52
+ - **Type Validation**: Ensures props match expected types
53
+
54
+ ## Block Structure
55
+
56
+ ### Core Files
57
+
58
+ ```
59
+ block-repository/
60
+ ├── src/
61
+ │ ├── block.tsx # Main component (receives props)
62
+ │ ├── App.tsx # Wrapper component
63
+ │ └── index.tsx # Entry point
64
+ ├── package.json # Dependencies and metadata
65
+ ├── webpack.config.js # Build configuration
66
+ └── index.html # Development preview
67
+ ```
68
+
69
+ ### Example Block Component
70
+
71
+ ```tsx
72
+ interface BlockProps {
73
+ title: string;
74
+ color: string;
75
+ items: Array<{
76
+ name: string;
77
+ value: number;
78
+ }>;
79
+ showAnimation: boolean;
80
+ }
81
+
82
+ export default function MyBlock(props: BlockProps) {
83
+ const { title, color, items, showAnimation } = props;
84
+
85
+ return (
86
+ <div style={{ backgroundColor: color }}>
87
+ <h1>{title}</h1>
88
+ {items.map((item, index) => (
89
+ <div key={index} className={showAnimation ? "animate" : ""}>
90
+ {item.name}: {item.value}
91
+ </div>
92
+ ))}
93
+ </div>
94
+ );
95
+ }
96
+ ```
97
+
98
+ ## Block Lifecycle
99
+
100
+ ### 1. **Creation**
101
+
102
+ - Use `mexty create block --name "Block Name" --description "Description" --category "category"`
103
+ - Automatically creates GitHub repository with template
104
+ - Sets up development environment
105
+
106
+ ### 2. **Development**
107
+
108
+ - Edit `src/block.tsx` to implement functionality
109
+ - Define TypeScript interfaces for props
110
+ - Test locally with `npm start`
111
+
112
+ ### 3. **Publishing**
113
+
114
+ - Use `mexty save` to commit changes and trigger build
115
+ - System automatically parses props schema from TypeScript interfaces
116
+ - Generates federation bundle for embedding
117
+
118
+ ### 4. **Distribution**
119
+
120
+ - Blocks can be shared privately or published to marketplace
121
+ - Published blocks become available as named components
122
+ - Can be made insertable by AI agents for automated content creation
123
+
124
+ ## Props Schema Auto-Detection
125
+
126
+ The system automatically analyzes your block's TypeScript interface to generate a props schema:
127
+
128
+ ```tsx
129
+ interface BlockProps {
130
+ title: string; // → String input
131
+ count: number; // → Number input
132
+ enabled: boolean; // → Toggle switch
133
+ color: string; // → Color picker (if name contains 'color')
134
+ imageUrl: string; // → Image selector (if name contains 'image')
135
+ options: string[]; // → Array of strings
136
+ config: {
137
+ // → Nested object
138
+ theme: "light" | "dark"; // → Enum dropdown
139
+ size: number;
140
+ };
141
+ }
142
+ ```
143
+
144
+ ## Use Cases
145
+
146
+ ### Educational Content
147
+
148
+ - Interactive quizzes and assessments
149
+ - Data visualizations and charts
150
+ - Simulations and experiments
151
+ - Progress trackers
152
+
153
+ ### Business Applications
154
+
155
+ - Product showcases
156
+ - Pricing calculators
157
+ - Contact forms
158
+ - Dashboard widgets
159
+
160
+ ### Entertainment
161
+
162
+ - Mini-games
163
+ - Interactive stories
164
+ - Media players
165
+ - Social widgets
166
+
167
+ ### Marketing
168
+
169
+ - Call-to-action buttons
170
+ - Lead generation forms
171
+ - Product demos
172
+ - Testimonial carousels
173
+
174
+ ## Integration Methods
175
+
176
+ ### 1. **Direct Embedding**
177
+
178
+ ```html
179
+ <iframe src="https://mexty.ai/preview.html?blockId=BLOCK_ID"></iframe>
180
+ ```
181
+
182
+ ### 2. **React Integration**
183
+
184
+ ```tsx
185
+ import { WeatherWidget } from "@mexty/block";
186
+
187
+ <WeatherWidget location="Paris" showForecast={true} theme="dark" />;
188
+ ```
189
+
190
+ ### 3. **Federation Module**
191
+
192
+ ```javascript
193
+ const RemoteComponent = React.lazy(() => import("FEDERATION_URL"));
194
+ ```
195
+
196
+ ## AI Agent Integration
197
+
198
+ Blocks can be marked as "insertable by agent" which allows AI systems to:
199
+
200
+ - Automatically select appropriate blocks for content
201
+ - Generate suitable props based on context
202
+ - Insert blocks into courses and pages
203
+ - Customize block behavior for specific use cases
204
+
205
+ ## Best Practices
206
+
207
+ ### Props Design
208
+
209
+ - Use descriptive prop names that indicate their purpose
210
+ - Provide sensible default values
211
+ - Group related props into objects
212
+ - Use enums for predefined choices
213
+
214
+ ### Component Structure
215
+
216
+ - Keep components focused and single-purpose
217
+ - Handle loading and error states gracefully
218
+ - Make components responsive and accessible
219
+ - Optimize for performance
220
+
221
+ ### Development Workflow
222
+
223
+ 1. Define props interface first
224
+ 2. Implement component logic
225
+ 3. Test with various prop combinations
226
+ 4. Commit and publish with `mexty save`
227
+ 5. Share or publish to marketplace
228
+
229
+ ## CLI Commands
230
+
231
+ The MEXTY CLI provides a complete toolkit for block development and publishing:
232
+
233
+ ### Installation
234
+
235
+ ```bash
236
+ npm install -g @mexty/cli
237
+ ```
238
+
239
+ ### Authentication
240
+
241
+ ```bash
242
+ mexty login
243
+ ```
244
+
245
+ Authenticate with your MEXTY account to access all CLI features.
246
+
247
+ ### Block Creation
248
+
249
+ ```bash
250
+ mexty create block --name "Block Name" --description "Description" --category "category"
251
+ ```
252
+
253
+ - Creates a new block via the API
254
+ - Automatically generates a GitHub repository
255
+ - Clones the repository locally
256
+ - Changes to the block directory
257
+ - Sets up the development environment
258
+
259
+ **Example:**
260
+
261
+ ```bash
262
+ mexty create block --name "Weather Widget" --description "A beautiful weather display component" --category "widget"
263
+ ```
264
+
265
+ ### Development & Saving
266
+
267
+ ```bash
268
+ mexty save
269
+ ```
270
+
271
+ - Stages all changes (`git add .`)
272
+ - Prompts for commit message
273
+ - Commits changes to git
274
+ - Pushes to GitHub
275
+ - Triggers the save-and-bundle process to build the block
276
+
277
+ ### Publishing to Marketplace
278
+
279
+ ```bash
280
+ mexty publish [--agent]
281
+ ```
282
+
283
+ - Builds and bundles the block
284
+ - Publishes to the marketplace (free only via CLI)
285
+ - Makes block discoverable by all users
286
+ - Optional `--agent` flag makes block insertable by AI agents (requires Mext staff permissions)
287
+
288
+ **Example:**
289
+
290
+ ```bash
291
+ mexty publish --agent
292
+ ```
293
+
294
+ ### Block Management
295
+
296
+ ```bash
297
+ mexty delete <blockId>
298
+ ```
299
+
300
+ Deletes a block (requires ownership).
301
+
302
+ ### Command Workflow
303
+
304
+ 1. **Create a new block:**
305
+
306
+ ```bash
307
+ mexty create block --name "My Widget" --description "An awesome widget" --category "utility"
308
+ ```
309
+
310
+ 2. **Develop your block:**
311
+
312
+ - Edit `src/block.tsx` to implement your component
313
+ - Define TypeScript interfaces for props
314
+ - Test locally with `npm start`
315
+
316
+ 3. **Save your progress:**
317
+
318
+ ```bash
319
+ mexty save
320
+ ```
321
+
322
+ 4. **Publish to marketplace:**
323
+ ```bash
324
+ mexty publish --agent
325
+ ```
326
+
327
+ ### CLI Features
328
+
329
+ - **Automatic GitHub Integration**: Creates and manages repositories
330
+ - **TypeScript Support**: Full TypeScript development environment
331
+ - **Props Schema Detection**: Automatically generates props schema from TypeScript interfaces
332
+ - **Federation Bundling**: Creates optimized bundles for embedding
333
+ - **Marketplace Publishing**: One-command publishing to the marketplace
334
+ - **AI Agent Integration**: Optional agent insertability for automated content creation
335
+
336
+ This system enables rapid creation of interactive content while maintaining consistency, reusability, and ease of customization for end users.
337
+
338
+ # @mexty/realtime
339
+
340
+ React hooks for real-time collaborative features using Yjs and Hocuspocus.
341
+
342
+ ## Installation
343
+
344
+ ```bash
345
+ npm install @mexty/realtime
346
+ ```
347
+
348
+ ## Usage
349
+
350
+ ```tsx
351
+ import { useCollabSpace } from "@mexty/realtime";
352
+
353
+ // 🧠 Example 1: Collaborative JSON document editor
354
+ export function DocumentEditor({ blockId }: { blockId: string }) {
355
+ const { state, update } = useCollabSpace(`block:${blockId}`, {
356
+ document: {
357
+ title: "Untitled",
358
+ content: "Write something...",
359
+ },
360
+ game: { weights: [] },
361
+ });
362
+
363
+ // ✅ Partial update usage
364
+ const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
365
+ update({ document: { ...state.document, title: e.target.value } });
366
+ };
367
+
368
+ // ✅ Functional update usage
369
+ const resetContent = () => {
370
+ update((prev) => ({
371
+ ...prev,
372
+ document: { ...prev.document, content: "" },
373
+ }));
374
+ };
375
+
376
+ return (
377
+ <div className="p-4 border rounded space-y-3">
378
+ <h2 className="text-lg font-bold">Collaborative Document</h2>
379
+ <input
380
+ type="text"
381
+ className="border p-2 w-full"
382
+ value={state.document.title}
383
+ onChange={handleTitleChange}
384
+ />
385
+ <textarea
386
+ className="border p-2 w-full h-32"
387
+ value={state.document.content}
388
+ onChange={(e) =>
389
+ update({ document: { ...state.document, content: e.target.value } })
390
+ }
391
+ />
392
+ <button
393
+ onClick={resetContent}
394
+ className="bg-blue-500 text-white px-3 py-1 rounded"
395
+ >
396
+ Reset Content
397
+ </button>
398
+ </div>
399
+ );
400
+ }
401
+
402
+ // 🧩 Example 2: Multiplayer tower game state
403
+ export function TowerGame({ blockId }: { blockId: string }) {
404
+ const { state, update } = useCollabSpace(`block:${blockId}`, {
405
+ document: {},
406
+ game: { weights: [] as { team: string; pos: number }[] },
407
+ });
408
+
409
+ // ✅ Append new weight (functional update)
410
+ const addWeight = (team: string) => {
411
+ update((prev) => ({
412
+ ...prev,
413
+ game: {
414
+ ...prev.game,
415
+ weights: [...prev.game.weights, { team, pos: Math.random() * 100 }],
416
+ },
417
+ }));
418
+ };
419
+
420
+ // ✅ Clear game state (partial update)
421
+ const resetGame = () => {
422
+ update({ game: { weights: [] } });
423
+ };
424
+
425
+ return (
426
+ <div className="p-4 border rounded space-y-3">
427
+ <h2 className="text-lg font-bold">Tower Game</h2>
428
+ <button
429
+ onClick={() => addWeight("blue")}
430
+ className="bg-blue-600 text-white px-3 py-1 rounded"
431
+ >
432
+ Add Blue Weight
433
+ </button>
434
+ <button
435
+ onClick={() => addWeight("red")}
436
+ className="bg-red-600 text-white px-3 py-1 rounded"
437
+ >
438
+ Add Red Weight
439
+ </button>
440
+ <button
441
+ onClick={resetGame}
442
+ className="bg-gray-600 text-white px-3 py-1 rounded"
443
+ >
444
+ Reset Game
445
+ </button>
446
+
447
+ <pre className="bg-gray-100 p-2 text-sm rounded overflow-auto">
448
+ {JSON.stringify(state.game, null, 2)}
449
+ </pre>
450
+ </div>
451
+ );
452
+ }
453
+ ```
454
+
455
+ ## API
456
+
457
+ ### `useCollabSpace(documentName, initialState, options?)`
458
+
459
+ #### Parameters
460
+
461
+ - `documentName: string` - Unique identifier for the collaborative document
462
+ - `initialState: T` - Initial state object for the collaborative space
463
+ - `options?: CollabSpaceOptions` - Optional configuration
464
+
465
+ #### Returns
466
+
467
+ - `state: T` - Current collaborative state
468
+ - `update: (updateFn: UpdateFunction<T>) => void` - Function to update state
469
+ - `isConnected: boolean` - WebSocket connection status
470
+ - `connectionStatus: 'connecting' | 'connected' | 'disconnected' | 'error'` - Detailed connection status
471
+ - `userId: string` - Anonymous user ID (persisted in localStorage)
472
+
473
+ #### Options
474
+
475
+ ```tsx
476
+ interface CollabSpaceOptions {
477
+ websocketUrl?: string;
478
+ onConnect?: () => void;
479
+ onDisconnect?: () => void;
480
+ onError?: (error: Error) => void;
481
+ }
482
+ ```
483
+
484
+ ## Features
485
+
486
+ - 🔄 Real-time collaborative state synchronization
487
+ - 🆔 Anonymous user authentication with persistent IDs
488
+ - 🔗 Automatic WebSocket connection management
489
+ - 📱 React hooks for easy integration
490
+ - 🎯 TypeScript support with full type safety
491
+ - 🏗️ Built on Yjs and Hocuspocus for reliability
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAOA,UAAU,aAAa;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAwBD,wBAAsB,aAAa,CACjC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA6Hf"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAOA,UAAU,aAAa;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAwBD,wBAAsB,aAAa,CACjC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiIf"}
@@ -74,17 +74,19 @@ async function createCommand(subcommand, options = {}) {
74
74
  // Create the block
75
75
  const block = await api_1.apiClient.createBlock(blockData);
76
76
  console.log(chalk_1.default.green(`✅ Block created successfully!`));
77
- console.log(chalk_1.default.gray(` Block ID: ${block._id}`));
78
- console.log(chalk_1.default.gray(` Block Type: ${block.blockType}`));
79
- if (block.gitUrl) {
80
- console.log(chalk_1.default.gray(` GitHub URL: ${block.gitUrl}`));
77
+ console.log(chalk_1.default.gray(` Block ID: ${block.id || block._id}`));
78
+ console.log(chalk_1.default.gray(` Block Type: ${block.blockType || block._doc?.blockType}`));
79
+ // Handle both plain objects and Mongoose documents
80
+ const gitUrl = block.gitUrl || block._doc?.gitUrl;
81
+ if (gitUrl) {
82
+ console.log(chalk_1.default.gray(` GitHub URL: ${gitUrl}`));
81
83
  // Clone the repository
82
- const repoName = git_1.GitManager.extractRepoName(block.gitUrl);
84
+ const repoName = git_1.GitManager.extractRepoName(gitUrl);
83
85
  const targetDir = path_1.default.join(process.cwd(), repoName);
84
86
  console.log(chalk_1.default.yellow(`📦 Cloning repository to ./${repoName}...`));
85
87
  try {
86
88
  const gitManager = new git_1.GitManager();
87
- await gitManager.cloneRepository(block.gitUrl, targetDir);
89
+ await gitManager.cloneRepository(gitUrl, targetDir);
88
90
  console.log(chalk_1.default.green(`🎉 Block created and repository cloned successfully!`));
89
91
  console.log(chalk_1.default.blue(`\nNext steps:`));
90
92
  console.log(chalk_1.default.gray(` 1. cd ${repoName}`));
@@ -103,7 +105,7 @@ async function createCommand(subcommand, options = {}) {
103
105
  catch (cloneError) {
104
106
  console.error(chalk_1.default.red(`❌ Failed to clone repository: ${cloneError.message}`));
105
107
  console.log(chalk_1.default.yellow(`You can manually clone it later:`));
106
- console.log(chalk_1.default.gray(` git clone ${block.gitUrl}`));
108
+ console.log(chalk_1.default.gray(` git clone ${gitUrl}`));
107
109
  }
108
110
  }
109
111
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":";;;;;AAoCA,sCAgIC;AApKD,kDAA0B;AAC1B,gDAAwB;AACxB,sCAA6D;AAC7D,sCAA0C;AAC1C,uCAA2C;AAC3C,wCAA4E;AAS5E,6CAA6C;AAC7C,KAAK,UAAU,MAAM,CACnB,QAAgB,EAChB,YAAqB;IAErB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC;YACzB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,YAAY;YAC7B,CAAC,CAAC,GAAG,QAAQ,KAAK,YAAY,KAAK;YACnC,CAAC,CAAC,GAAG,QAAQ,IAAI,CAAC;QAEpB,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;YACjC,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,YAAY,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CACjC,UAAmB,EACnB,UAAyB,EAAE;IAE3B,IAAI,CAAC;QACH,6BAA6B;QAC7B,IAAA,4BAAqB,GAAE,CAAC;QAExB,MAAM,IAAI,GAAG,IAAA,2BAAoB,GAAE,CAAC;QAEpC,iCAAiC;QACjC,IAAI,SAAiB,CAAC;QACtB,IAAI,gBAAwB,CAAC;QAC7B,IAAI,SAAiB,CAAC;QAEtB,IAAI,UAAU,KAAK,OAAO,EAAE,C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C;oBACzB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,4BAA4B,QAAQ,EAAE,CAAC,CAAC,CAAC;gBACnE,CAAC;gBAAC,OAAO,UAAe,EAAE,CAAC;oBACzB,OAAO,CAAC,IAAI,CACV,eAAK,CAAC,MAAM,CACV,sCAAsC,UAAU,CAAC,OAAO,EAAE,CAC3D,CACF,CAAC;oBACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CAAC,iCAAiC,UAAU,CAAC,OAAO,EAAE,CAAC,CACjE,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC;gBAC9D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,8DAA8D,CAC/D,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,2 +1,6 @@
1
- export declare function publishCommand(): Promise<void>;
1
+ interface PublishOptions {
2
+ agent?: boolean;
3
+ }
4
+ export declare function publishCommand(options?: PublishOptions): Promise<void>;
5
+ export {};
2
6
  //# sourceMappingURL=publish.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAmEA,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CA2FpD"}
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAmEA,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,cAAc,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HhF"}
@@ -10,7 +10,7 @@ const path_1 = __importDefault(require("path"));
10
10
  const api_1 = require("../utils/api");
11
11
  const git_1 = require("../utils/git");
12
12
  const readline_1 = require("readline");
13
- const sync_1 = require("./sync");
13
+ // Removed sync command import as it's been deleted
14
14
  const auth_1 = require("../utils/auth");
15
15
  // Simple confirmation function
16
16
  async function confirm(question) {
@@ -63,13 +63,14 @@ async function findBlockId() {
63
63
  }
64
64
  return null;
65
65
  }
66
- async function publishCommand() {
66
+ async function publishCommand(options = {}) {
67
67
  try {
68
68
  // Check authentication first
69
69
  (0, auth_1.requireAuthentication)();
70
70
  const user = (0, auth_1.getAuthenticatedUser)();
71
- console.log(chalk_1.default.blue('🚀 Publishing block...'));
71
+ console.log(chalk_1.default.blue('🚀 Publishing block to marketplace...'));
72
72
  console.log(chalk_1.default.gray(` User: ${user?.fullName || user?.email || 'Unknown'}`));
73
+ console.log(chalk_1.default.gray(` Agent insertable: ${options.agent ? 'Yes' : 'No'}`));
73
74
  // Check if we're in a git repository
74
75
  const gitManager = new git_1.GitManager();
75
76
  const isGitRepo = await gitManager.isGitRepository();
@@ -112,23 +113,51 @@ async function publishCommand() {
112
113
  console.log(chalk_1.default.yellow('📡 Triggering build and bundle process...'));
113
114
  try {
114
115
  const result = await api_1.apiClient.saveAndBundle({ blockId });
115
- console.log(chalk_1.default.green('✅ Block published successfully!'));
116
+ console.log(chalk_1.default.green('✅ Block bundled successfully!'));
116
117
  console.log(chalk_1.default.gray(` Bundle Path: ${result.bundlePath}`));
117
118
  console.log(chalk_1.default.gray(` Federation URL: ${result.federationUrl}`));
118
119
  if (result.message) {
119
120
  console.log(chalk_1.default.blue(` ${result.message}`));
120
121
  }
121
- // Automatically sync registry after successful publish
122
- console.log(chalk_1.default.blue('\n🔄 Auto-syncing registry...'));
122
+ // Update sharing scope to publish to marketplace (free only)
123
+ console.log(chalk_1.default.blue('\n🌐 Publishing to marketplace...'));
123
124
  try {
124
- await (0, sync_1.syncCommand)();
125
- console.log(chalk_1.default.green('✅ Registry synced! Your block is now available as a named component.'));
125
+ // Get current block to check existing scope
126
+ const block = await api_1.apiClient.getBlock(blockId);
127
+ const currentScope = block?.scope || ['user-store'];
128
+ // Add published-store to scope if not already present
129
+ const newScope = [...new Set([...currentScope, 'user-store', 'published-store'])];
130
+ await api_1.apiClient.updateBlockSharing(blockId, newScope);
131
+ console.log(chalk_1.default.green('✅ Block published to marketplace (free)'));
132
+ // Update agent insertability if requested
133
+ if (options.agent) {
134
+ console.log(chalk_1.default.blue('🤖 Making block insertable by AI agents...'));
135
+ try {
136
+ await api_1.apiClient.updateBlockAgentInsertable(blockId, true);
137
+ console.log(chalk_1.default.green('✅ Block is now insertable by AI agents'));
138
+ }
139
+ catch (agentError) {
140
+ // This might fail if user is not Mext staff, but that's okay
141
+ console.log(chalk_1.default.yellow('⚠️ Could not set agent insertability (requires Mext staff permissions)'));
142
+ console.log(chalk_1.default.gray(` Error: ${agentError.message || 'Permission denied'}`));
143
+ }
144
+ }
145
+ }
146
+ catch (sharingError) {
147
+ console.error(chalk_1.default.red('❌ Failed to publish to marketplace:'), sharingError.message);
148
+ console.log(chalk_1.default.yellow(' Block was built successfully but not published to marketplace.'));
149
+ console.log(chalk_1.default.gray(' You can try publishing again or contact support.'));
150
+ return;
126
151
  }
127
- catch (syncError) {
128
- console.warn(chalk_1.default.yellow(`⚠️ Registry sync failed: ${syncError.message}`));
129
- console.log(chalk_1.default.gray(' You can manually sync later with: mexty sync'));
130
- // Don't fail the publish if sync fails - it's not critical
152
+ // Success message
153
+ console.log(chalk_1.default.green('\n🎉 Block published to marketplace successfully!'));
154
+ console.log(chalk_1.default.blue('Your block is now:'));
155
+ console.log(chalk_1.default.gray(' Available for free download by anyone'));
156
+ console.log(chalk_1.default.gray(' ✓ Discoverable in the marketplace'));
157
+ if (options.agent) {
158
+ console.log(chalk_1.default.gray(' ✓ Insertable by AI agents (if you have permissions)'));
131
159
  }
160
+ console.log(chalk_1.default.gray(` ✓ Viewable at: https://mexty.ai/preview.html?blockId=${blockId}`));
132
161
  }
133
162
  catch (buildError) {
134
163
  console.error(chalk_1.default.red(`❌ Build failed: ${buildError.message}`));