appwrite-utils-cli 1.7.9 → 1.8.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/CHANGELOG.md +14 -199
- package/README.md +87 -30
- package/dist/adapters/AdapterFactory.js +5 -25
- package/dist/adapters/DatabaseAdapter.d.ts +17 -2
- package/dist/adapters/LegacyAdapter.d.ts +2 -1
- package/dist/adapters/LegacyAdapter.js +212 -16
- package/dist/adapters/TablesDBAdapter.d.ts +2 -12
- package/dist/adapters/TablesDBAdapter.js +261 -57
- package/dist/cli/commands/databaseCommands.js +4 -3
- package/dist/cli/commands/functionCommands.js +17 -8
- package/dist/collections/attributes.js +447 -125
- package/dist/collections/methods.js +197 -186
- package/dist/collections/tableOperations.d.ts +86 -0
- package/dist/collections/tableOperations.js +434 -0
- package/dist/collections/transferOperations.d.ts +3 -2
- package/dist/collections/transferOperations.js +93 -12
- package/dist/config/yamlConfig.d.ts +221 -88
- package/dist/examples/yamlTerminologyExample.d.ts +1 -1
- package/dist/examples/yamlTerminologyExample.js +6 -3
- package/dist/functions/fnConfigDiscovery.d.ts +3 -0
- package/dist/functions/fnConfigDiscovery.js +108 -0
- package/dist/interactiveCLI.js +18 -15
- package/dist/main.js +211 -73
- package/dist/migrations/appwriteToX.d.ts +88 -23
- package/dist/migrations/comprehensiveTransfer.d.ts +2 -0
- package/dist/migrations/comprehensiveTransfer.js +83 -6
- package/dist/migrations/dataLoader.d.ts +227 -69
- package/dist/migrations/dataLoader.js +3 -3
- package/dist/migrations/importController.js +3 -3
- package/dist/migrations/relationships.d.ts +8 -2
- package/dist/migrations/services/ImportOrchestrator.js +3 -3
- package/dist/migrations/transfer.js +159 -37
- package/dist/shared/attributeMapper.d.ts +20 -0
- package/dist/shared/attributeMapper.js +203 -0
- package/dist/shared/selectionDialogs.js +8 -4
- package/dist/storage/schemas.d.ts +354 -92
- package/dist/utils/configDiscovery.js +4 -3
- package/dist/utils/versionDetection.d.ts +0 -4
- package/dist/utils/versionDetection.js +41 -173
- package/dist/utils/yamlConverter.js +89 -16
- package/dist/utils/yamlLoader.d.ts +1 -1
- package/dist/utils/yamlLoader.js +6 -2
- package/dist/utilsController.js +56 -19
- package/package.json +4 -4
- package/src/adapters/AdapterFactory.ts +119 -143
- package/src/adapters/DatabaseAdapter.ts +18 -3
- package/src/adapters/LegacyAdapter.ts +236 -105
- package/src/adapters/TablesDBAdapter.ts +773 -643
- package/src/cli/commands/databaseCommands.ts +13 -12
- package/src/cli/commands/functionCommands.ts +23 -14
- package/src/collections/attributes.ts +2054 -1611
- package/src/collections/methods.ts +208 -293
- package/src/collections/tableOperations.ts +506 -0
- package/src/collections/transferOperations.ts +218 -144
- package/src/examples/yamlTerminologyExample.ts +10 -5
- package/src/functions/fnConfigDiscovery.ts +103 -0
- package/src/interactiveCLI.ts +25 -20
- package/src/main.ts +549 -194
- package/src/migrations/comprehensiveTransfer.ts +126 -50
- package/src/migrations/dataLoader.ts +3 -3
- package/src/migrations/importController.ts +3 -3
- package/src/migrations/services/ImportOrchestrator.ts +3 -3
- package/src/migrations/transfer.ts +148 -131
- package/src/shared/attributeMapper.ts +229 -0
- package/src/shared/selectionDialogs.ts +29 -25
- package/src/utils/configDiscovery.ts +9 -3
- package/src/utils/versionDetection.ts +74 -228
- package/src/utils/yamlConverter.ts +94 -17
- package/src/utils/yamlLoader.ts +11 -4
- package/src/utilsController.ts +80 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,199 +1,14 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Split interactive CLI into 5 focused command modules (1,595 lines total)
|
|
16
|
-
- Reduced large file sizes by 30-60% while maintaining all functionality
|
|
17
|
-
- **Logging Standardization**: Unified logging across entire codebase
|
|
18
|
-
- Replaced ~500 console.* calls with MessageFormatter
|
|
19
|
-
- Consistent prefixes and formatting for better debugging
|
|
20
|
-
- Integrated with Winston structured logging
|
|
21
|
-
- **New Utilities**: Added shared utility modules for better code reuse
|
|
22
|
-
- errorUtils.ts for centralized error handling
|
|
23
|
-
- directoryUtils.ts for file system operations
|
|
24
|
-
- typeGuards.ts for TypeScript type safety
|
|
25
|
-
- pathResolvers.ts for consistent path resolution
|
|
26
|
-
|
|
27
|
-
## [1.6.0] - 2025-01-27
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
- **Session Authentication Integration**: Complete integration with Appwrite CLI session authentication
|
|
31
|
-
- New CLI flags: `--use-session`, `--session`, `--sessionCookie` for flexible authentication
|
|
32
|
-
- Automatic detection and usage of sessions from `~/.appwrite/prefs.json`
|
|
33
|
-
- Priority authentication system: explicit session → session from prefs → API key → error
|
|
34
|
-
- Enhanced error messages with available session listing and login guidance
|
|
35
|
-
- Seamless integration maintaining backward compatibility with API key workflows
|
|
36
|
-
|
|
37
|
-
- **Native Project Configuration Support**: Full support for appwrite.json/appwrite.config.json files
|
|
38
|
-
- Automatic project configuration detection and loading from current directory tree
|
|
39
|
-
- Support for both Collections and TablesDB project formats from official Appwrite CLI
|
|
40
|
-
- Enhanced project context awareness for better tooling integration
|
|
41
|
-
- Conversion between project config and internal AppwriteConfig formats
|
|
42
|
-
- Priority system: CLI args → project config → YAML config → interactive prompt
|
|
43
|
-
|
|
44
|
-
- **Intelligent Version-Aware Setup**: Enhanced setup command with smart detection
|
|
45
|
-
- **Project-First Detection**: Automatically detects project type from existing appwrite.json
|
|
46
|
-
- **Session-Powered Version Detection**: Uses session auth for server version checking when available
|
|
47
|
-
- **Context-Aware Templates**: Generates tables/columns templates for TablesDB (1.8.0+)
|
|
48
|
-
- **Legacy Support**: Generates collections/attributes templates for older versions
|
|
49
|
-
- **Smart Schema Generation**: Creates appropriate JSON schemas (table.schema.json vs collection.schema.json)
|
|
50
|
-
- **Enhanced Examples**: TablesDB templates include unique constraints and row-level security features
|
|
51
|
-
|
|
52
|
-
- **Enhanced Client Creation**: Completely overhauled authentication flow
|
|
53
|
-
- New `getClientWithAuth()` function with intelligent fallback system
|
|
54
|
-
- Session validation and endpoint matching for security
|
|
55
|
-
- Enhanced `UtilsController` with session authentication support
|
|
56
|
-
- Automatic session discovery when no API key provided
|
|
57
|
-
- Clear authentication method logging and error reporting
|
|
58
|
-
|
|
59
|
-
- **Hono-TypeScript Function Template**: New web framework template for modern API development
|
|
60
|
-
- Complete Hono.dev integration with Appwrite functions
|
|
61
|
-
- Request/response adapters for seamless Appwrite-Hono bridge
|
|
62
|
-
- Built-in middleware for logging, error handling, and context injection
|
|
63
|
-
- Example API endpoints with database operations and authentication
|
|
64
|
-
- Comprehensive documentation and usage examples
|
|
65
|
-
|
|
66
|
-
- **Enhanced Function Templates**: Improved TypeScript and Python templates
|
|
67
|
-
- Complete Pydantic models for Python functions with proper type hints
|
|
68
|
-
- Enhanced Zod schemas for TypeScript functions with full validation
|
|
69
|
-
- Better error handling and context validation in templates
|
|
70
|
-
- Updated dependencies (Hono, Zod, Pydantic) in template configurations
|
|
71
|
-
|
|
72
|
-
- **Dual Collections/Tables Support**: Full support for both legacy and TablesDB APIs
|
|
73
|
-
- Enhanced YAML loading from both `collections/` and `tables/` directories simultaneously
|
|
74
|
-
- Automatic conflict detection and resolution between folder structures
|
|
75
|
-
- Version-aware folder selection based on Appwrite API detection
|
|
76
|
-
- Backward compatibility with existing projects
|
|
77
|
-
|
|
78
|
-
- **Interactive CLI Enhancements**: Improved user experience and database association
|
|
79
|
-
- Better collection/table selection with type indicators (🟢 Collection, 🔵 Table)
|
|
80
|
-
- Enhanced database filtering using optional `databaseId` for tables
|
|
81
|
-
- Improved prompts and contextual information display
|
|
82
|
-
- Better organization of mixed collection/table scenarios
|
|
83
|
-
|
|
84
|
-
- **Configuration Validation & Migration**: Comprehensive validation and migration tools
|
|
85
|
-
- New CLI flags: `--validate`, `--validate-strict`, `--migrate-collections-to-tables`
|
|
86
|
-
- Configuration validation with detailed error reporting and suggestions
|
|
87
|
-
- Multiple migration strategies for different project needs
|
|
88
|
-
- Integration with config loading for automatic validation
|
|
89
|
-
|
|
90
|
-
- **Enhanced Sync Operations**: Fixed and improved sync-from-Appwrite functionality
|
|
91
|
-
- **Fixed Database Syncing**: Remote databases now properly sync into `config.yaml`
|
|
92
|
-
- **Version-Aware YAML Generation**: Correct schema references and folder selection
|
|
93
|
-
- **Improved Error Handling**: Better user feedback and error recovery
|
|
94
|
-
- **Enhanced Logging**: Comprehensive operation tracking and debugging
|
|
95
|
-
|
|
96
|
-
### Changed
|
|
97
|
-
- **Authentication Priority**: Complete overhaul of authentication handling throughout CLI
|
|
98
|
-
- Session authentication now preferred over API key when available
|
|
99
|
-
- Enhanced error messages guide users to proper authentication setup
|
|
100
|
-
- Better integration with existing Appwrite CLI workflows
|
|
101
|
-
- Maintained full backward compatibility with existing projects
|
|
102
|
-
|
|
103
|
-
- **Setup Command Experience**: Major improvements to project initialization
|
|
104
|
-
- Intelligent detection provides better user feedback about project type
|
|
105
|
-
- Version-aware terminology throughout setup process
|
|
106
|
-
- Enhanced console output with detection source information
|
|
107
|
-
- Better guidance for TablesDB features and capabilities
|
|
108
|
-
|
|
109
|
-
- **Configuration Loading**: Enhanced to work with multiple configuration sources
|
|
110
|
-
- Project configuration loading from appwrite.json files
|
|
111
|
-
- Better conflict resolution between different config sources
|
|
112
|
-
- Enhanced validation and error handling for mixed scenarios
|
|
113
|
-
|
|
114
|
-
- **Enhanced Logging Infrastructure**: Comprehensive logging throughout the CLI
|
|
115
|
-
- Structured JSON logging with operation context and timing
|
|
116
|
-
- Version detection and adapter selection logging
|
|
117
|
-
- Attribute min/max value processing logs with before/after values
|
|
118
|
-
- Performance timing for bottleneck identification
|
|
119
|
-
|
|
120
|
-
- **Improved Template System**: Better function template organization and options
|
|
121
|
-
- Added "TypeScript with Hono Web Framework" option to CLI
|
|
122
|
-
- Enhanced template variable replacement system
|
|
123
|
-
- Better template defaults and configuration
|
|
124
|
-
- Improved template documentation and examples
|
|
125
|
-
|
|
126
|
-
### Fixed
|
|
127
|
-
- **Authentication Error Handling**: Resolved issues with missing authentication
|
|
128
|
-
- Better fallback logic when session authentication unavailable
|
|
129
|
-
- Clear error messages with actionable guidance
|
|
130
|
-
- Proper handling of invalid or expired session cookies
|
|
131
|
-
- Enhanced validation of authentication methods
|
|
132
|
-
|
|
133
|
-
- **Type Safety**: Resolved TypeScript compilation issues
|
|
134
|
-
- Fixed session authentication type definitions
|
|
135
|
-
- Proper null/undefined handling in project configuration
|
|
136
|
-
- Enhanced type inference throughout authentication flow
|
|
137
|
-
- Better error message types and interfaces
|
|
138
|
-
|
|
139
|
-
- **Version Detection**: Improved reliability of server version detection
|
|
140
|
-
- Better error handling when version detection fails
|
|
141
|
-
- Enhanced fallback mechanisms for offline scenarios
|
|
142
|
-
- Improved session-based version detection accuracy
|
|
143
|
-
|
|
144
|
-
- **Integer/Float Min/Max Handling**: Resolved issues with extreme values in attribute creation
|
|
145
|
-
- Implemented 10 billion threshold logic for min/max values
|
|
146
|
-
- Proper undefined value handling for Appwrite API compatibility
|
|
147
|
-
- Consistent normalization between create and update operations
|
|
148
|
-
- Better comparison logic for determining when updates are needed
|
|
149
|
-
|
|
150
|
-
- **Collection Re-pushing Prevention**: Eliminated unnecessary collection processing
|
|
151
|
-
- Intelligent state management prevents duplicate operations
|
|
152
|
-
- Surgical queue processing for relationship attributes only
|
|
153
|
-
- Better cache management and state tracking
|
|
154
|
-
- Performance improvements for large collection push operations
|
|
155
|
-
|
|
156
|
-
- **Version-Aware Attribute Creation**: Proper API mode detection and routing
|
|
157
|
-
- All attribute operations now route through adapter pattern
|
|
158
|
-
- TablesDB vs Legacy API terminology used correctly
|
|
159
|
-
- Fixed direct SDK calls that bypassed version detection
|
|
160
|
-
- Maintained backward compatibility with pre-1.8.0 Appwrite
|
|
161
|
-
|
|
162
|
-
- **Sync-from-Appwrite Issues**: Comprehensive fixes for YAML generation
|
|
163
|
-
- Database definitions now properly added to configuration
|
|
164
|
-
- Version-aware folder structure (tables/ vs collections/)
|
|
165
|
-
- Correct schema references in generated YAML files
|
|
166
|
-
- Enhanced error handling and user feedback
|
|
167
|
-
|
|
168
|
-
### Technical Improvements
|
|
169
|
-
- **New Utilities**: Added comprehensive session and project management utilities
|
|
170
|
-
- `sessionAuth.ts` - Complete session management and validation
|
|
171
|
-
- `projectConfig.ts` - Appwrite project configuration handling
|
|
172
|
-
- Enhanced `getClientFromConfig.ts` with session authentication support
|
|
173
|
-
- Improved `setupFiles.ts` with intelligent version detection
|
|
174
|
-
|
|
175
|
-
- **Enhanced Type Definitions**: Better TypeScript support throughout
|
|
176
|
-
- Comprehensive session authentication types
|
|
177
|
-
- Project configuration interfaces and validation
|
|
178
|
-
- Enhanced error handling and message formatting
|
|
179
|
-
- Better integration between authentication methods
|
|
180
|
-
|
|
181
|
-
- **Improved Error Handling**: More helpful and actionable error messages
|
|
182
|
-
- Authentication method reporting and guidance
|
|
183
|
-
- Session availability checking and listing
|
|
184
|
-
- Project configuration validation feedback
|
|
185
|
-
- Version detection status and fallback information
|
|
186
|
-
|
|
187
|
-
- **Full TypeScript Type Safety**: Enhanced type definitions throughout
|
|
188
|
-
- **Comprehensive Test Coverage**: Extensive testing for all new features
|
|
189
|
-
- **Performance Optimizations**: Reduced redundant operations and improved efficiency
|
|
190
|
-
- **Enhanced Debugging**: Better visibility into CLI operations and state changes
|
|
191
|
-
|
|
192
|
-
## [1.5.2] - 2024-XX-XX
|
|
193
|
-
|
|
194
|
-
### Previous
|
|
195
|
-
- Earlier version features and improvements
|
|
196
|
-
|
|
197
|
-
## Earlier Versions
|
|
198
|
-
|
|
199
|
-
Please refer to git history for changes prior to v1.6.0.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
- Push flow now uses explicit, manual selection for databases and tables/collections. No more auto-selecting all databases on `--push`.
|
|
8
|
+
- Adapter-first orchestration for schema updates. Attributes and indexes are compared and only created/updated when changed.
|
|
9
|
+
- Added clear summaries after attribute and index operations (create/update/skip counts).
|
|
10
|
+
- Improved index handling: existence check, tolerant duplicate handling, and availability polling.
|
|
11
|
+
- Multi-database targeting supported via `databaseIds` (alongside `databaseId`) on table/collection definitions.
|
|
12
|
+
- Per-function configuration discovery via `.fnconfig.yaml` anywhere in the repository. Relative `dirPath` resolves from the file’s directory; `~` expands to homedir.
|
|
13
|
+
- TablesDB/legacy detection is fetch-based; no additional SDK packages required.
|
|
14
|
+
|
package/README.md
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
`appwrite-utils-cli` is a powerful, YAML-first command-line interface tool designed for Appwrite developers who need to manage database migrations, schema generation, data import, and comprehensive project management. Built on a modular architecture with enhanced performance, this CLI tool facilitates complex tasks like setting up databases, running migrations, generating schemas, and managing backups efficiently.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Highlights:
|
|
8
|
+
- Adapter-first database orchestration (no legacy attribute fall-through)
|
|
9
|
+
- Safe diff-based updates for attributes and indexes (no duplicate creations)
|
|
10
|
+
- Manual push selections (no auto-push of all DBs)
|
|
11
|
+
- Multi-database targeting per table/collection via `databaseIds`
|
|
12
|
+
- Per-function configuration via `.fnconfig.yaml` (discovered anywhere in repo)
|
|
8
13
|
|
|
9
14
|
## Features
|
|
10
15
|
|
|
@@ -15,10 +20,10 @@
|
|
|
15
20
|
- **Enhanced Performance**: Configurable rate limiting and batch processing for optimal performance
|
|
16
21
|
- **Safety First**: Smart confirmation dialogs for destructive operations with explicit confirmations
|
|
17
22
|
|
|
18
|
-
### Dual API Support (Collections & TablesDB)
|
|
23
|
+
### Dual API Support (Collections & TablesDB)
|
|
19
24
|
- **Collections API**: Traditional Appwrite database operations with document-based terminology
|
|
20
25
|
- **TablesDB API**: New high-performance table API with column-based terminology
|
|
21
|
-
- **Automatic Detection**: Smart API mode detection based
|
|
26
|
+
- **Automatic Detection**: Smart API mode detection (fetch-based detection; no extra packages required)
|
|
22
27
|
- **Seamless Migration**: Zero-downtime migration between Collections and TablesDB APIs
|
|
23
28
|
- **Terminology Flexibility**: Support for both `collections/documents/attributes` and `tables/rows/columns`
|
|
24
29
|
|
|
@@ -53,32 +58,15 @@ npx --package=appwrite-utils-cli@latest appwrite-migrate [options]
|
|
|
53
58
|
|
|
54
59
|
**Note: Do not install this locally into your project. It is meant to be used as a command-line tool only.**
|
|
55
60
|
|
|
56
|
-
## TablesDB Support
|
|
61
|
+
## TablesDB Support
|
|
57
62
|
|
|
58
63
|
`appwrite-utils-cli` provides comprehensive support for both traditional Appwrite Collections API and the new TablesDB API, enabling high-performance database operations with modern terminology.
|
|
59
64
|
|
|
60
|
-
### API Mode Detection
|
|
65
|
+
### API Mode Detection
|
|
66
|
+
|
|
67
|
+
The CLI automatically selects Collections or TablesDB using fetch-based server detection (health/version and endpoint probes). No additional SDK packages are required.
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
1. **Package Detection**: Checks for `node-appwrite-tablesdb` package installation
|
|
65
|
-
2. **Configuration**: Detects `collections` vs `tables` in YAML configuration
|
|
66
|
-
3. **Environment**: Falls back to Collections API if TablesDB is not available
|
|
67
|
-
|
|
68
|
-
### Installing TablesDB Support
|
|
69
|
-
|
|
70
|
-
To enable TablesDB functionality, install the TablesDB package alongside the CLI:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# For global CLI usage
|
|
74
|
-
npm install -g node-appwrite-tablesdb
|
|
75
|
-
|
|
76
|
-
# For project-specific usage
|
|
77
|
-
npm install node-appwrite-tablesdb
|
|
78
|
-
npx --package=appwrite-utils-cli@latest --package=node-appwrite-tablesdb@latest appwrite-migrate --it
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Configuration Comparison
|
|
69
|
+
### Configuration Comparison
|
|
82
70
|
|
|
83
71
|
#### Collections API (Traditional)
|
|
84
72
|
```yaml
|
|
@@ -134,7 +122,7 @@ npx appwrite-utils-cli appwrite-migrate --sync --use-tablesdb
|
|
|
134
122
|
npx appwrite-utils-cli appwrite-migrate --generate --api-mode=tablesdb
|
|
135
123
|
```
|
|
136
124
|
|
|
137
|
-
## YAML-First Configuration
|
|
125
|
+
## YAML-First Configuration
|
|
138
126
|
|
|
139
127
|
Version 1.0.0 introduces a YAML-first approach for better cross-platform compatibility and enhanced developer experience.
|
|
140
128
|
|
|
@@ -145,7 +133,7 @@ The CLI automatically detects configuration files in this order:
|
|
|
145
133
|
2. `appwrite.yaml`
|
|
146
134
|
3. `appwriteConfig.ts` (legacy, still supported)
|
|
147
135
|
|
|
148
|
-
### YAML Configuration Examples
|
|
136
|
+
### YAML Configuration Examples
|
|
149
137
|
|
|
150
138
|
#### Collections API Configuration
|
|
151
139
|
```yaml
|
|
@@ -221,7 +209,7 @@ logging:
|
|
|
221
209
|
console: true
|
|
222
210
|
```
|
|
223
211
|
|
|
224
|
-
## Usage
|
|
212
|
+
## Usage
|
|
225
213
|
|
|
226
214
|
After installation, you can access the tool directly from your command line using the provided commands.
|
|
227
215
|
|
|
@@ -239,7 +227,34 @@ This provides a professional guided experience with:
|
|
|
239
227
|
- Operation summaries with detailed statistics
|
|
240
228
|
- Real-time progress bars with ETA calculations
|
|
241
229
|
|
|
242
|
-
###
|
|
230
|
+
### Push (manual selection)
|
|
231
|
+
|
|
232
|
+
Pushing local schema is now an explicit, manual selection flow to avoid unintended changes:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npx appwrite-utils-cli appwrite-migrate --push
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
- Select databases from the remote project (no default auto-selection)
|
|
239
|
+
- Select tables/collections to push per selected database
|
|
240
|
+
- Summary confirmation is shown before applying changes
|
|
241
|
+
|
|
242
|
+
Flags:
|
|
243
|
+
- `--dbIds=id1,id2` pre-selects databases by ID (skips DB prompt)
|
|
244
|
+
- `--collectionIds=c1,c2` pre-selects tables/collections by ID for the selected DB(s)
|
|
245
|
+
|
|
246
|
+
Eligibility per DB:
|
|
247
|
+
- A table/collection is considered eligible for a database if:
|
|
248
|
+
- `databaseIds` includes the database ID, or
|
|
249
|
+
- `databaseId` equals the database ID, or
|
|
250
|
+
- neither field is set (eligible everywhere)
|
|
251
|
+
|
|
252
|
+
Attribute/Index behavior:
|
|
253
|
+
- Attributes and indexes are compared and only created/updated when changed
|
|
254
|
+
- Unchanged definitions are skipped
|
|
255
|
+
- Status is monitored until available (with sensible timeouts)
|
|
256
|
+
|
|
257
|
+
### Non-Interactive Mode
|
|
243
258
|
|
|
244
259
|
You can also use specific flags to run tasks without the interactive prompt:
|
|
245
260
|
|
|
@@ -247,7 +262,7 @@ You can also use specific flags to run tasks without the interactive prompt:
|
|
|
247
262
|
npx --package=appwrite-utils-cli@latest appwrite-migrate [options]
|
|
248
263
|
```
|
|
249
264
|
|
|
250
|
-
## YAML Import Configuration System
|
|
265
|
+
## YAML Import Configuration System
|
|
251
266
|
|
|
252
267
|
Version 1.0.0 introduces a powerful YAML-based import system with sophisticated data handling capabilities.
|
|
253
268
|
|
|
@@ -1045,3 +1060,45 @@ npx appwrite-utils-cli appwrite-migrate --generateConstants --constantsLanguages
|
|
|
1045
1060
|
- 0.0.22: Converted all import processes except `postImportActions` and Relationship Resolution to the local data import, so it should be much faster.
|
|
1046
1061
|
- 0.0.6: Added `setTargetFieldFromOtherCollectionDocumentsByMatchingField` for the below, but setting a different field than the field you matched. The names are long, but at least you know what's going on lmao.
|
|
1047
1062
|
- 0.0.5: Added `setFieldFromOtherCollectionDocuments` to set an array of ID's for instance from another collection as a `postImportAction`
|
|
1063
|
+
## Multi-Database Targeting
|
|
1064
|
+
|
|
1065
|
+
You can target the same table/collection to multiple databases by adding `databaseIds` to the definition:
|
|
1066
|
+
|
|
1067
|
+
```ts
|
|
1068
|
+
// Example: table.ts
|
|
1069
|
+
export default {
|
|
1070
|
+
name: 'Analytics',
|
|
1071
|
+
databaseIds: ['dev', 'staging', 'main'],
|
|
1072
|
+
attributes: [
|
|
1073
|
+
{ key: 'timestamp', type: 'datetime', required: true },
|
|
1074
|
+
{ key: 'totalUsers', type: 'integer' }
|
|
1075
|
+
],
|
|
1076
|
+
indexes: [{ key: 'ts_idx', type: 'key', attributes: ['timestamp'] }]
|
|
1077
|
+
};
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
During push, this table will appear under each selected database whose ID matches `databaseIds`.
|
|
1081
|
+
|
|
1082
|
+
## Per-Function Configuration (.fnconfig.yaml)
|
|
1083
|
+
|
|
1084
|
+
You can define functions in per-directory YAML files named `.fnconfig.yaml` (or `.fnconfig.yml`), discovered anywhere under your git repository root:
|
|
1085
|
+
|
|
1086
|
+
```yaml
|
|
1087
|
+
# ./functions/reporting/.fnconfig.yaml
|
|
1088
|
+
id: reporting
|
|
1089
|
+
name: Reporting
|
|
1090
|
+
runtime: node-22.0
|
|
1091
|
+
execute: ["any"]
|
|
1092
|
+
events: []
|
|
1093
|
+
dirPath: ./ # defaults to the directory containing this file
|
|
1094
|
+
commands: npm install
|
|
1095
|
+
entrypoint: index.js
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
Rules:
|
|
1099
|
+
- If `dirPath` starts with `~`, it expands to your home directory
|
|
1100
|
+
- Relative `dirPath` resolves against the `.fnconfig.yaml` directory
|
|
1101
|
+
- Absolute `dirPath` is used as-is
|
|
1102
|
+
- `.fnconfig.yaml` definitions merge with central `.appwrite/config.yaml` functions; if the same `$id` exists in both, `.fnconfig.yaml` overrides
|
|
1103
|
+
|
|
1104
|
+
Deployment uses the merged function set and resolves paths according to these rules.
|
|
@@ -9,9 +9,9 @@ import { detectAppwriteVersionCached, isVersionAtLeast } from "../utils/versionD
|
|
|
9
9
|
import { TablesDBAdapter } from './TablesDBAdapter.js';
|
|
10
10
|
import { LegacyAdapter } from './LegacyAdapter.js';
|
|
11
11
|
import { logger } from '../shared/logging.js';
|
|
12
|
-
import { getClientWithAuth } from '../utils/getClientFromConfig.js';
|
|
13
12
|
import { isValidSessionCookie } from '../utils/sessionAuth.js';
|
|
14
13
|
import { MessageFormatter } from '../shared/messageFormatter.js';
|
|
14
|
+
import { Client } from 'node-appwrite';
|
|
15
15
|
/**
|
|
16
16
|
* AdapterFactory - Main factory class for creating database adapters
|
|
17
17
|
*/
|
|
@@ -157,18 +157,10 @@ export class AdapterFactory {
|
|
|
157
157
|
static async createTablesDBAdapter(config) {
|
|
158
158
|
const startTime = Date.now();
|
|
159
159
|
try {
|
|
160
|
-
logger.info('
|
|
160
|
+
logger.info('Creating TablesDB adapter (static SDK imports)', {
|
|
161
161
|
endpoint: config.appwriteEndpoint,
|
|
162
162
|
operation: 'createTablesDBAdapter'
|
|
163
163
|
});
|
|
164
|
-
// Dynamic import of TablesDB SDK
|
|
165
|
-
const importStartTime = Date.now();
|
|
166
|
-
const { Client, TablesDB } = await import('node-appwrite-tablesdb');
|
|
167
|
-
const importDuration = Date.now() - importStartTime;
|
|
168
|
-
logger.debug('TablesDB SDK import successful', {
|
|
169
|
-
importDuration,
|
|
170
|
-
operation: 'createTablesDBAdapter'
|
|
171
|
-
});
|
|
172
164
|
// Use pre-configured client or create session-aware client with TablesDB Client
|
|
173
165
|
let client;
|
|
174
166
|
if (config.preConfiguredClient) {
|
|
@@ -200,12 +192,10 @@ export class AdapterFactory {
|
|
|
200
192
|
throw new Error("No authentication available for adapter");
|
|
201
193
|
}
|
|
202
194
|
}
|
|
203
|
-
const
|
|
204
|
-
const adapter = new TablesDBAdapter(tablesDB);
|
|
195
|
+
const adapter = new TablesDBAdapter(client);
|
|
205
196
|
const totalDuration = Date.now() - startTime;
|
|
206
197
|
logger.info('TablesDB adapter created successfully', {
|
|
207
198
|
totalDuration,
|
|
208
|
-
importDuration,
|
|
209
199
|
endpoint: config.appwriteEndpoint,
|
|
210
200
|
operation: 'createTablesDBAdapter'
|
|
211
201
|
});
|
|
@@ -231,18 +221,10 @@ export class AdapterFactory {
|
|
|
231
221
|
static async createLegacyAdapter(config) {
|
|
232
222
|
const startTime = Date.now();
|
|
233
223
|
try {
|
|
234
|
-
logger.info('
|
|
224
|
+
logger.info('Creating legacy adapter (static SDK imports)', {
|
|
235
225
|
endpoint: config.appwriteEndpoint,
|
|
236
226
|
operation: 'createLegacyAdapter'
|
|
237
227
|
});
|
|
238
|
-
// Dynamic import of legacy SDK
|
|
239
|
-
const importStartTime = Date.now();
|
|
240
|
-
const { Client, Databases } = await import('node-appwrite');
|
|
241
|
-
const importDuration = Date.now() - importStartTime;
|
|
242
|
-
logger.debug('Legacy SDK import successful', {
|
|
243
|
-
importDuration,
|
|
244
|
-
operation: 'createLegacyAdapter'
|
|
245
|
-
});
|
|
246
228
|
// Use pre-configured client or create session-aware client with Legacy Client
|
|
247
229
|
let client;
|
|
248
230
|
if (config.preConfiguredClient) {
|
|
@@ -274,12 +256,10 @@ export class AdapterFactory {
|
|
|
274
256
|
throw new Error("No authentication available for adapter");
|
|
275
257
|
}
|
|
276
258
|
}
|
|
277
|
-
const
|
|
278
|
-
const adapter = new LegacyAdapter(databases);
|
|
259
|
+
const adapter = new LegacyAdapter(client);
|
|
279
260
|
const totalDuration = Date.now() - startTime;
|
|
280
261
|
logger.info('Legacy adapter created successfully', {
|
|
281
262
|
totalDuration,
|
|
282
|
-
importDuration,
|
|
283
263
|
endpoint: config.appwriteEndpoint,
|
|
284
264
|
operation: 'createLegacyAdapter'
|
|
285
265
|
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* (collections/documents) and new TablesDB (tables/rows) APIs. All internal
|
|
6
6
|
* code uses TablesDB-style method signatures for consistency.
|
|
7
7
|
*/
|
|
8
|
+
import type { Client } from "node-appwrite";
|
|
8
9
|
import type { ApiMode } from "../utils/versionDetection.js";
|
|
9
10
|
export interface CreateRowParams {
|
|
10
11
|
databaseId: string;
|
|
@@ -36,6 +37,7 @@ export interface CreateTableParams {
|
|
|
36
37
|
name: string;
|
|
37
38
|
permissions?: string[];
|
|
38
39
|
documentSecurity?: boolean;
|
|
40
|
+
rowSecurity?: boolean;
|
|
39
41
|
enabled?: boolean;
|
|
40
42
|
}
|
|
41
43
|
export interface UpdateTableParams {
|
|
@@ -44,6 +46,7 @@ export interface UpdateTableParams {
|
|
|
44
46
|
name: string;
|
|
45
47
|
permissions?: string[];
|
|
46
48
|
documentSecurity?: boolean;
|
|
49
|
+
rowSecurity?: boolean;
|
|
47
50
|
enabled?: boolean;
|
|
48
51
|
}
|
|
49
52
|
export interface ListTablesParams {
|
|
@@ -108,8 +111,20 @@ export interface UpdateAttributeParams {
|
|
|
108
111
|
databaseId: string;
|
|
109
112
|
tableId: string;
|
|
110
113
|
key: string;
|
|
114
|
+
type?: string;
|
|
111
115
|
required?: boolean;
|
|
112
116
|
default?: any;
|
|
117
|
+
size?: number;
|
|
118
|
+
min?: number;
|
|
119
|
+
max?: number;
|
|
120
|
+
array?: boolean;
|
|
121
|
+
encrypt?: boolean;
|
|
122
|
+
elements?: string[];
|
|
123
|
+
relatedCollection?: string;
|
|
124
|
+
relationType?: string;
|
|
125
|
+
twoWay?: boolean;
|
|
126
|
+
twoWayKey?: string;
|
|
127
|
+
onDelete?: string;
|
|
113
128
|
}
|
|
114
129
|
export interface DeleteAttributeParams {
|
|
115
130
|
databaseId: string;
|
|
@@ -176,9 +191,9 @@ export interface DatabaseAdapter {
|
|
|
176
191
|
* Base adapter class with common functionality
|
|
177
192
|
*/
|
|
178
193
|
export declare abstract class BaseAdapter implements DatabaseAdapter {
|
|
179
|
-
protected client:
|
|
194
|
+
protected client: Client;
|
|
180
195
|
protected apiMode: ApiMode;
|
|
181
|
-
constructor(client:
|
|
196
|
+
constructor(client: Client, apiMode: ApiMode);
|
|
182
197
|
abstract listRows(params: ListRowsParams): Promise<ApiResponse>;
|
|
183
198
|
abstract createRow(params: CreateRowParams): Promise<ApiResponse>;
|
|
184
199
|
abstract updateRow(params: UpdateRowParams): Promise<ApiResponse>;
|
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
* code can use modern TablesDB patterns while maintaining compatibility with
|
|
7
7
|
* older Appwrite instances.
|
|
8
8
|
*/
|
|
9
|
+
import { Client } from "node-appwrite";
|
|
9
10
|
import { BaseAdapter, type CreateRowParams, type UpdateRowParams, type ListRowsParams, type DeleteRowParams, type CreateTableParams, type UpdateTableParams, type ListTablesParams, type DeleteTableParams, type GetTableParams, type BulkCreateRowsParams, type BulkUpsertRowsParams, type BulkDeleteRowsParams, type CreateIndexParams, type ListIndexesParams, type DeleteIndexParams, type CreateAttributeParams, type UpdateAttributeParams, type DeleteAttributeParams, type ApiResponse, type AdapterMetadata } from './DatabaseAdapter.js';
|
|
10
11
|
/**
|
|
11
12
|
* LegacyAdapter - Translates TablesDB calls to legacy Databases API
|
|
12
13
|
*/
|
|
13
14
|
export declare class LegacyAdapter extends BaseAdapter {
|
|
14
15
|
private databases;
|
|
15
|
-
constructor(client:
|
|
16
|
+
constructor(client: Client);
|
|
16
17
|
listRows(params: ListRowsParams): Promise<ApiResponse>;
|
|
17
18
|
createRow(params: CreateRowParams): Promise<ApiResponse>;
|
|
18
19
|
updateRow(params: UpdateRowParams): Promise<ApiResponse>;
|