@fias/create-fias-plugin 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fias/create-fias-plugin",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -2,7 +2,7 @@
2
2
 
3
3
  This project is a FIAS platform plugin — a React application that runs in a sandboxed iframe within the FIAS marketplace. This file provides the context AI coding assistants need to build, test, and submit plugins effectively.
4
4
 
5
- For other AI tool instruction files, see `CLAUDE.md` (identical content).
5
+ For other AI tool instruction files, see `AGENTS.md` (identical content).
6
6
 
7
7
  ## Project Structure
8
8
 
@@ -82,6 +82,8 @@ const user = useFiasUser();
82
82
  **Permission:** `storage:sandbox`
83
83
  **Returns:** `FiasStorageApi`
84
84
 
85
+ Storage is S3-backed and scoped per plugin + user. Data persists across sessions, browsers, and devices in live mode (staging/production). In mock mode, storage is in-memory and resets when the dev server restarts.
86
+
85
87
  ```tsx
86
88
  import { useFiasStorage } from '@fias/arche-sdk';
87
89
 
@@ -93,6 +95,73 @@ const files = await listFiles('data/'); // string[]
93
95
  await deleteFile('data/old.json');
94
96
  ```
95
97
 
98
+ **Error handling:** Storage calls can reject on infrastructure errors. Always use `.catch()` or `try/catch` -- an unhandled rejection will crash the plugin to a white screen.
99
+
100
+ ### `useFiasDataStore()` — Document database
101
+
102
+ **Permission:** `data:store`
103
+ **Returns:** `FiasDataStoreApi`
104
+
105
+ A document database with collections, queries, and filtering. Data persists across sessions in live mode. Each collection can be `user`-scoped (private to each user) or `shared` (visible to all users of the plugin).
106
+
107
+ ```tsx
108
+ import { useFiasDataStore } from '@fias/arche-sdk';
109
+
110
+ function MyComponent() {
111
+ const dataStore = useFiasDataStore();
112
+
113
+ // Collection management
114
+ await dataStore.createCollection('scores', { userScope: 'user' }); // or 'shared'
115
+ const collections = await dataStore.listCollections();
116
+ await dataStore.deleteCollection('scores');
117
+
118
+ // Document CRUD
119
+ await dataStore.put<MyType>('scores', 'doc-key', { score: 100, name: 'Alice' });
120
+ const doc = await dataStore.get<MyType>('scores', 'doc-key'); // MyType | null
121
+ await dataStore.delete('scores', 'doc-key');
122
+
123
+ // Query with filters, sorting, pagination
124
+ const results = await dataStore.query<MyType>('scores', {
125
+ filters: [
126
+ { field: 'score', op: 'gte', value: 50 },
127
+ { field: 'name', op: 'eq', value: 'Alice' },
128
+ ],
129
+ orderBy: { field: 'score', direction: 'desc' },
130
+ limit: 20,
131
+ cursor: nextCursor, // for pagination
132
+ });
133
+ // results = { documents: [{ key, data, updatedAt }], nextCursor: string | null }
134
+ }
135
+ ```
136
+
137
+ Also available as an imperative API outside React components:
138
+
139
+ ```tsx
140
+ import { fias } from '@fias/arche-sdk';
141
+
142
+ await fias.dataStore.put('scores', 'key', { score: 100 });
143
+ const doc = await fias.dataStore.get('scores', 'key');
144
+ ```
145
+
146
+ **Collection scopes:**
147
+
148
+ - `user` (default): Each user sees only their own documents
149
+ - `shared`: All users of the plugin see and share the same documents
150
+
151
+ **Filter operators:** `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains` (JSONB containment), `exists`
152
+
153
+ **Limits:**
154
+
155
+ - 50 collections per plugin
156
+ - 10,000 documents per collection
157
+ - 100 KB per document
158
+ - 100 MB total storage per plugin
159
+ - Max 100 results per query, max 10 filters, max field path depth 5
160
+
161
+ **Rate limits (per minute):** `put` 120, `get` 300, `query` 60, `delete` 60, `createCollection` 10
162
+
163
+ **Error handling:** Data store calls can reject on infrastructure errors or limit violations. Always use `try/catch`. Common error codes: `COLLECTION_NOT_FOUND`, `DOCUMENT_TOO_LARGE`, `STORAGE_LIMIT_REACHED`, `RATE_LIMIT`.
164
+
96
165
  ### `useEntityInvocation()` — Invoke AI models
97
166
 
98
167
  **Permission:** `entities:invoke`
@@ -129,6 +198,41 @@ function AISummarizer() {
129
198
 
130
199
  The `entityId` references a published model entity. Browse available models with `npx fias-dev entities`. The `systemPrompt` tells the AI how to behave — this is where your plugin's intelligence lives.
131
200
 
201
+ ### `useImageGeneration()` — Generate images via AI models
202
+
203
+ **Permission:** `entities:image_generate`
204
+ **Returns:** `ImageGenerationApi`
205
+
206
+ Generate images using platform image models. Images are saved to the user's Fias file system and a display URL is returned. Use `npx fias-dev entities --detail <entityId>` to check supported sizes, qualities, and styles for each model.
207
+
208
+ ```tsx
209
+ import { useImageGeneration } from '@fias/arche-sdk';
210
+
211
+ function ImageMaker() {
212
+ const { generate, isLoading, result, error } = useImageGeneration();
213
+
214
+ return (
215
+ <div>
216
+ <button
217
+ onClick={() =>
218
+ generate({
219
+ entityId: 'ent_modeldef_dalle3',
220
+ prompt: 'A serene mountain landscape at sunset',
221
+ size: '1024x1024',
222
+ quality: 'hd',
223
+ })
224
+ }
225
+ disabled={isLoading}
226
+ >
227
+ {isLoading ? 'Generating...' : 'Generate Image'}
228
+ </button>
229
+ {result && <img src={result.imageUrl} alt="Generated" />}
230
+ {error && <p>Error: {error.message}</p>}
231
+ </div>
232
+ );
233
+ }
234
+ ```
235
+
132
236
  ### `useFiasNavigation()` — In-plugin routing
133
237
 
134
238
  **Permission:** None required
@@ -155,6 +259,8 @@ const { currentStep, setCurrentStep } = useStepNavigation('step-1');
155
259
 
156
260
  **Permission:** `storage:sandbox`
157
261
 
262
+ Uses `useFiasStorage` under the hood — same persistence rules apply (durable in live mode, in-memory in mock mode).
263
+
158
264
  ```tsx
159
265
  import { usePersistentState } from '@fias/arche-sdk';
160
266
 
@@ -203,7 +309,7 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' |
203
309
  | `sdk` | Yes | SDK version range |
204
310
  | `dependencies` | No | npm packages with **exact** versions (max 20) |
205
311
 
206
- **Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `entities:invoke`
312
+ **Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `data:store`, `entities:invoke`, `entities:image_generate`
207
313
 
208
314
  **Using AI:** Add `"entities:invoke"` to permissions, then use `useEntityInvocation()` with a model entity ID and your own `systemPrompt`. Browse available models with `npx fias-dev entities`.
209
315
 
@@ -249,6 +355,19 @@ These are hard limits enforced by the platform. Code that violates these will fa
249
355
 
250
356
  ## Development Workflow
251
357
 
358
+ ### Check for Updates (DO THIS FIRST)
359
+
360
+ **At the start of every new session**, check if the FIAS packages and tooling are up to date:
361
+
362
+ ```bash
363
+ npm outdated @fias/arche-sdk @fias/plugin-dev-harness
364
+ npx fias-dev sync --dry-run
365
+ ```
366
+
367
+ If newer package versions are available, tell the user and ask if they want to update before proceeding. Stale packages can cause subtle bugs (e.g., mismatched API return types) that are hard to diagnose.
368
+
369
+ If `sync --dry-run` shows pending changes, tell the user and offer to run `npx fias-dev sync` to update AI instruction files and config from the latest SDK templates. This never touches source code or project-specific files (`package.json`, `fias-plugin.json`, `src/`).
370
+
252
371
  ### Starting Development
253
372
 
254
373
  ```bash
@@ -279,9 +398,10 @@ npx fias-dev login --env production # Authenticate with production
279
398
  ### Browsing Available Entities
280
399
 
281
400
  ```bash
282
- npx fias-dev entities # List all
283
- npx fias-dev entities --search "text" # Search by keyword
284
- npx fias-dev entities --type "prompt" # Filter by type
401
+ npx fias-dev entities # List all
402
+ npx fias-dev entities --search "image" # Search by keyword
403
+ npx fias-dev entities --type "model-definition" # Filter by type
404
+ npx fias-dev entities --detail ent_modeldef_dalle3 # Full entity details (capabilities, sizes, pricing)
285
405
  ```
286
406
 
287
407
  ### Validating the Manifest
@@ -82,6 +82,8 @@ const user = useFiasUser();
82
82
  **Permission:** `storage:sandbox`
83
83
  **Returns:** `FiasStorageApi`
84
84
 
85
+ Storage is S3-backed and scoped per plugin + user. Data persists across sessions, browsers, and devices in live mode (staging/production). In mock mode, storage is in-memory and resets when the dev server restarts.
86
+
85
87
  ```tsx
86
88
  import { useFiasStorage } from '@fias/arche-sdk';
87
89
 
@@ -93,6 +95,73 @@ const files = await listFiles('data/'); // string[]
93
95
  await deleteFile('data/old.json');
94
96
  ```
95
97
 
98
+ **Error handling:** Storage calls can reject on infrastructure errors. Always use `.catch()` or `try/catch` -- an unhandled rejection will crash the plugin to a white screen.
99
+
100
+ ### `useFiasDataStore()` — Document database
101
+
102
+ **Permission:** `data:store`
103
+ **Returns:** `FiasDataStoreApi`
104
+
105
+ A document database with collections, queries, and filtering. Data persists across sessions in live mode. Each collection can be `user`-scoped (private to each user) or `shared` (visible to all users of the plugin).
106
+
107
+ ```tsx
108
+ import { useFiasDataStore } from '@fias/arche-sdk';
109
+
110
+ function MyComponent() {
111
+ const dataStore = useFiasDataStore();
112
+
113
+ // Collection management
114
+ await dataStore.createCollection('scores', { userScope: 'user' }); // or 'shared'
115
+ const collections = await dataStore.listCollections();
116
+ await dataStore.deleteCollection('scores');
117
+
118
+ // Document CRUD
119
+ await dataStore.put<MyType>('scores', 'doc-key', { score: 100, name: 'Alice' });
120
+ const doc = await dataStore.get<MyType>('scores', 'doc-key'); // MyType | null
121
+ await dataStore.delete('scores', 'doc-key');
122
+
123
+ // Query with filters, sorting, pagination
124
+ const results = await dataStore.query<MyType>('scores', {
125
+ filters: [
126
+ { field: 'score', op: 'gte', value: 50 },
127
+ { field: 'name', op: 'eq', value: 'Alice' },
128
+ ],
129
+ orderBy: { field: 'score', direction: 'desc' },
130
+ limit: 20,
131
+ cursor: nextCursor, // for pagination
132
+ });
133
+ // results = { documents: [{ key, data, updatedAt }], nextCursor: string | null }
134
+ }
135
+ ```
136
+
137
+ Also available as an imperative API outside React components:
138
+
139
+ ```tsx
140
+ import { fias } from '@fias/arche-sdk';
141
+
142
+ await fias.dataStore.put('scores', 'key', { score: 100 });
143
+ const doc = await fias.dataStore.get('scores', 'key');
144
+ ```
145
+
146
+ **Collection scopes:**
147
+
148
+ - `user` (default): Each user sees only their own documents
149
+ - `shared`: All users of the plugin see and share the same documents
150
+
151
+ **Filter operators:** `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains` (JSONB containment), `exists`
152
+
153
+ **Limits:**
154
+
155
+ - 50 collections per plugin
156
+ - 10,000 documents per collection
157
+ - 100 KB per document
158
+ - 100 MB total storage per plugin
159
+ - Max 100 results per query, max 10 filters, max field path depth 5
160
+
161
+ **Rate limits (per minute):** `put` 120, `get` 300, `query` 60, `delete` 60, `createCollection` 10
162
+
163
+ **Error handling:** Data store calls can reject on infrastructure errors or limit violations. Always use `try/catch`. Common error codes: `COLLECTION_NOT_FOUND`, `DOCUMENT_TOO_LARGE`, `STORAGE_LIMIT_REACHED`, `RATE_LIMIT`.
164
+
96
165
  ### `useEntityInvocation()` — Invoke AI models
97
166
 
98
167
  **Permission:** `entities:invoke`
@@ -129,6 +198,41 @@ function AISummarizer() {
129
198
 
130
199
  The `entityId` references a published model entity. Browse available models with `npx fias-dev entities`. The `systemPrompt` tells the AI how to behave — this is where your plugin's intelligence lives.
131
200
 
201
+ ### `useImageGeneration()` — Generate images via AI models
202
+
203
+ **Permission:** `entities:image_generate`
204
+ **Returns:** `ImageGenerationApi`
205
+
206
+ Generate images using platform image models. Images are saved to the user's Fias file system and a display URL is returned. Use `npx fias-dev entities --detail <entityId>` to check supported sizes, qualities, and styles for each model.
207
+
208
+ ```tsx
209
+ import { useImageGeneration } from '@fias/arche-sdk';
210
+
211
+ function ImageMaker() {
212
+ const { generate, isLoading, result, error } = useImageGeneration();
213
+
214
+ return (
215
+ <div>
216
+ <button
217
+ onClick={() =>
218
+ generate({
219
+ entityId: 'ent_modeldef_dalle3',
220
+ prompt: 'A serene mountain landscape at sunset',
221
+ size: '1024x1024',
222
+ quality: 'hd',
223
+ })
224
+ }
225
+ disabled={isLoading}
226
+ >
227
+ {isLoading ? 'Generating...' : 'Generate Image'}
228
+ </button>
229
+ {result && <img src={result.imageUrl} alt="Generated" />}
230
+ {error && <p>Error: {error.message}</p>}
231
+ </div>
232
+ );
233
+ }
234
+ ```
235
+
132
236
  ### `useFiasNavigation()` — In-plugin routing
133
237
 
134
238
  **Permission:** None required
@@ -155,6 +259,8 @@ const { currentStep, setCurrentStep } = useStepNavigation('step-1');
155
259
 
156
260
  **Permission:** `storage:sandbox`
157
261
 
262
+ Uses `useFiasStorage` under the hood — same persistence rules apply (durable in live mode, in-memory in mock mode).
263
+
158
264
  ```tsx
159
265
  import { usePersistentState } from '@fias/arche-sdk';
160
266
 
@@ -203,7 +309,7 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' |
203
309
  | `sdk` | Yes | SDK version range |
204
310
  | `dependencies` | No | npm packages with **exact** versions (max 20) |
205
311
 
206
- **Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `entities:invoke`
312
+ **Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `data:store`, `entities:invoke`, `entities:image_generate`
207
313
 
208
314
  **Using AI:** Add `"entities:invoke"` to permissions, then use `useEntityInvocation()` with a model entity ID and your own `systemPrompt`. Browse available models with `npx fias-dev entities`.
209
315
 
@@ -249,6 +355,19 @@ These are hard limits enforced by the platform. Code that violates these will fa
249
355
 
250
356
  ## Development Workflow
251
357
 
358
+ ### Check for Updates (DO THIS FIRST)
359
+
360
+ **At the start of every new session**, check if the FIAS packages and tooling are up to date:
361
+
362
+ ```bash
363
+ npm outdated @fias/arche-sdk @fias/plugin-dev-harness
364
+ npx fias-dev sync --dry-run
365
+ ```
366
+
367
+ If newer package versions are available, tell the user and ask if they want to update before proceeding. Stale packages can cause subtle bugs (e.g., mismatched API return types) that are hard to diagnose.
368
+
369
+ If `sync --dry-run` shows pending changes, tell the user and offer to run `npx fias-dev sync` to update AI instruction files and config from the latest SDK templates. This never touches source code or project-specific files (`package.json`, `fias-plugin.json`, `src/`).
370
+
252
371
  ### Starting Development
253
372
 
254
373
  ```bash
@@ -279,9 +398,10 @@ npx fias-dev login --env production # Authenticate with production
279
398
  ### Browsing Available Entities
280
399
 
281
400
  ```bash
282
- npx fias-dev entities # List all
283
- npx fias-dev entities --search "text" # Search by keyword
284
- npx fias-dev entities --type "prompt" # Filter by type
401
+ npx fias-dev entities # List all
402
+ npx fias-dev entities --search "image" # Search by keyword
403
+ npx fias-dev entities --type "model-definition" # Filter by type
404
+ npx fias-dev entities --detail ent_modeldef_dalle3 # Full entity details (capabilities, sizes, pricing)
285
405
  ```
286
406
 
287
407
  ### Validating the Manifest