@fias/create-fias-plugin 1.0.3 → 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
|
@@ -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 `
|
|
5
|
+
For other AI tool instruction files, see `AGENTS.md` (identical content).
|
|
6
6
|
|
|
7
7
|
## Project Structure
|
|
8
8
|
|
|
@@ -95,6 +95,73 @@ const files = await listFiles('data/'); // string[]
|
|
|
95
95
|
await deleteFile('data/old.json');
|
|
96
96
|
```
|
|
97
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
|
+
|
|
98
165
|
### `useEntityInvocation()` — Invoke AI models
|
|
99
166
|
|
|
100
167
|
**Permission:** `entities:invoke`
|
|
@@ -242,7 +309,7 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' |
|
|
|
242
309
|
| `sdk` | Yes | SDK version range |
|
|
243
310
|
| `dependencies` | No | npm packages with **exact** versions (max 20) |
|
|
244
311
|
|
|
245
|
-
**Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `entities:invoke`, `entities:image_generate`
|
|
312
|
+
**Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `data:store`, `entities:invoke`, `entities:image_generate`
|
|
246
313
|
|
|
247
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`.
|
|
248
315
|
|
|
@@ -288,6 +355,19 @@ These are hard limits enforced by the platform. Code that violates these will fa
|
|
|
288
355
|
|
|
289
356
|
## Development Workflow
|
|
290
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
|
+
|
|
291
371
|
### Starting Development
|
|
292
372
|
|
|
293
373
|
```bash
|
|
@@ -95,6 +95,73 @@ const files = await listFiles('data/'); // string[]
|
|
|
95
95
|
await deleteFile('data/old.json');
|
|
96
96
|
```
|
|
97
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
|
+
|
|
98
165
|
### `useEntityInvocation()` — Invoke AI models
|
|
99
166
|
|
|
100
167
|
**Permission:** `entities:invoke`
|
|
@@ -242,7 +309,7 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' |
|
|
|
242
309
|
| `sdk` | Yes | SDK version range |
|
|
243
310
|
| `dependencies` | No | npm packages with **exact** versions (max 20) |
|
|
244
311
|
|
|
245
|
-
**Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `entities:invoke`, `entities:image_generate`
|
|
312
|
+
**Permissions:** `theme:read`, `user:profile:read`, `storage:sandbox`, `data:store`, `entities:invoke`, `entities:image_generate`
|
|
246
313
|
|
|
247
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`.
|
|
248
315
|
|
|
@@ -288,6 +355,19 @@ These are hard limits enforced by the platform. Code that violates these will fa
|
|
|
288
355
|
|
|
289
356
|
## Development Workflow
|
|
290
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
|
+
|
|
291
371
|
### Starting Development
|
|
292
372
|
|
|
293
373
|
```bash
|