appwrite-utils-cli 1.7.9 → 1.8.2
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
|
@@ -29,11 +29,11 @@ export const databaseCommands = {
|
|
|
29
29
|
// Push operations always use local configuration as source of truth
|
|
30
30
|
|
|
31
31
|
// Select databases
|
|
32
|
-
const selectedDatabaseIds = await SelectionDialogs.selectDatabases(
|
|
33
|
-
availableDatabases,
|
|
34
|
-
configuredDatabases,
|
|
35
|
-
{ showSelectAll:
|
|
36
|
-
);
|
|
32
|
+
const selectedDatabaseIds = await SelectionDialogs.selectDatabases(
|
|
33
|
+
availableDatabases,
|
|
34
|
+
configuredDatabases,
|
|
35
|
+
{ showSelectAll: false, allowNewOnly: false, defaultSelected: [] }
|
|
36
|
+
);
|
|
37
37
|
|
|
38
38
|
if (selectedDatabaseIds.length === 0) {
|
|
39
39
|
MessageFormatter.warning("No databases selected. Skipping database sync.", { prefix: "Database" });
|
|
@@ -53,7 +53,8 @@ export const databaseCommands = {
|
|
|
53
53
|
(cli as any).controller!.database!,
|
|
54
54
|
chalk.blue(`Select collections/tables to push to "${database.name}":`),
|
|
55
55
|
true, // multiSelect
|
|
56
|
-
true
|
|
56
|
+
true, // prefer local
|
|
57
|
+
true // shouldFilterByDatabase
|
|
57
58
|
);
|
|
58
59
|
|
|
59
60
|
// Map selected collections to table IDs
|
|
@@ -92,12 +93,12 @@ export const databaseCommands = {
|
|
|
92
93
|
MessageFormatter.warning("No storage buckets available in remote instance.", { prefix: "Database" });
|
|
93
94
|
} else {
|
|
94
95
|
// Select buckets using SelectionDialogs
|
|
95
|
-
const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases(
|
|
96
|
-
selectedDatabaseIds,
|
|
97
|
-
availableBuckets,
|
|
98
|
-
configuredBuckets,
|
|
99
|
-
{ showSelectAll:
|
|
100
|
-
);
|
|
96
|
+
const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases(
|
|
97
|
+
selectedDatabaseIds,
|
|
98
|
+
availableBuckets,
|
|
99
|
+
configuredBuckets,
|
|
100
|
+
{ showSelectAll: false, groupByDatabase: true, defaultSelected: [] }
|
|
101
|
+
);
|
|
101
102
|
|
|
102
103
|
if (selectedBucketIds.length > 0) {
|
|
103
104
|
// Create BucketSelection objects
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
listFunctions,
|
|
14
14
|
listSpecifications,
|
|
15
15
|
} from "../../functions/methods.js";
|
|
16
|
-
import { deployLocalFunction } from "../../functions/deployments.js";
|
|
16
|
+
import { deployLocalFunction } from "../../functions/deployments.js";
|
|
17
|
+
import { discoverFnConfigs, mergeDiscoveredFunctions } from "../../functions/fnConfigDiscovery.js";
|
|
17
18
|
import { addFunctionToYamlConfig, findYamlConfig } from "../../config/yamlConfig.js";
|
|
18
19
|
import { RuntimeSchema, type AppwriteFunction, type Runtime, type Specification } from "appwrite-utils";
|
|
19
20
|
import type { InteractiveCLI } from "../../interactiveCLI.js";
|
|
@@ -137,11 +138,18 @@ export const functionCommands = {
|
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
// Discover local .fnconfig.yaml functions and merge into controller config
|
|
142
|
+
try {
|
|
143
|
+
const discovered = discoverFnConfigs((cli as any).currentDir);
|
|
144
|
+
const merged = mergeDiscoveredFunctions((cli as any).controller!.config!.functions || [], discovered);
|
|
145
|
+
(cli as any).controller!.config!.functions = merged as any;
|
|
146
|
+
} catch {}
|
|
147
|
+
|
|
148
|
+
const functions = await (cli as any).selectFunctions(
|
|
149
|
+
"Select function(s) to deploy:",
|
|
150
|
+
true,
|
|
151
|
+
true
|
|
152
|
+
);
|
|
145
153
|
|
|
146
154
|
if (!functions?.length) {
|
|
147
155
|
MessageFormatter.error("No function selected", undefined, { prefix: "Functions" });
|
|
@@ -177,18 +185,19 @@ export const functionCommands = {
|
|
|
177
185
|
MessageFormatter.info(` Appwrite folder: ${(cli as any).controller.getAppwriteFolderPath()}`, { prefix: "Functions" });
|
|
178
186
|
MessageFormatter.info(` Current working dir: ${process.cwd()}`, { prefix: "Functions" });
|
|
179
187
|
|
|
180
|
-
//
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
return path;
|
|
186
|
-
};
|
|
188
|
+
// Resolve config dirPath relative to central YAML if it's relative
|
|
189
|
+
const yamlConfigPath = findYamlConfig((cli as any).currentDir);
|
|
190
|
+
const yamlBaseDir = yamlConfigPath ? require('node:path').dirname(yamlConfigPath) : process.cwd();
|
|
191
|
+
const expandTildePath = (p: string): string => (p?.startsWith('~/') ? p.replace('~', os.homedir()) : p);
|
|
187
192
|
|
|
188
193
|
// Check locations in priority order:
|
|
189
194
|
const priorityLocations = [
|
|
190
195
|
// 1. Config dirPath if specified (with tilde expansion)
|
|
191
|
-
functionConfig.dirPath
|
|
196
|
+
functionConfig.dirPath
|
|
197
|
+
? (require('node:path').isAbsolute(expandTildePath(functionConfig.dirPath))
|
|
198
|
+
? expandTildePath(functionConfig.dirPath)
|
|
199
|
+
: require('node:path').resolve(yamlBaseDir, expandTildePath(functionConfig.dirPath)))
|
|
200
|
+
: undefined,
|
|
192
201
|
// 2. Appwrite config folder/functions/name
|
|
193
202
|
join(
|
|
194
203
|
(cli as any).controller.getAppwriteFolderPath()!,
|