appwrite-utils-cli 1.7.8 → 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 +10 -10
- 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/services/ConfigLoaderService.d.ts +7 -0
- package/dist/config/services/ConfigLoaderService.js +47 -1
- 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/deployments.js +5 -23
- package/dist/functions/fnConfigDiscovery.d.ts +3 -0
- package/dist/functions/fnConfigDiscovery.js +108 -0
- package/dist/functions/methods.js +4 -2
- package/dist/functions/pathResolution.d.ts +37 -0
- package/dist/functions/pathResolution.js +185 -0
- package/dist/functions/templates/count-docs-in-collection/README.md +54 -0
- package/dist/functions/templates/count-docs-in-collection/package.json +25 -0
- package/dist/functions/templates/count-docs-in-collection/src/main.ts +159 -0
- package/dist/functions/templates/count-docs-in-collection/src/request.ts +9 -0
- package/dist/functions/templates/count-docs-in-collection/tsconfig.json +28 -0
- package/dist/functions/templates/hono-typescript/README.md +286 -0
- package/dist/functions/templates/hono-typescript/package.json +26 -0
- package/dist/functions/templates/hono-typescript/src/adapters/request.ts +74 -0
- package/dist/functions/templates/hono-typescript/src/adapters/response.ts +106 -0
- package/dist/functions/templates/hono-typescript/src/app.ts +180 -0
- package/dist/functions/templates/hono-typescript/src/context.ts +103 -0
- package/dist/functions/templates/hono-typescript/src/index.ts +54 -0
- package/dist/functions/templates/hono-typescript/src/middleware/appwrite.ts +119 -0
- package/dist/functions/templates/hono-typescript/tsconfig.json +20 -0
- package/dist/functions/templates/typescript-node/README.md +32 -0
- package/dist/functions/templates/typescript-node/package.json +25 -0
- package/dist/functions/templates/typescript-node/src/context.ts +103 -0
- package/dist/functions/templates/typescript-node/src/index.ts +29 -0
- package/dist/functions/templates/typescript-node/tsconfig.json +28 -0
- package/dist/functions/templates/uv/README.md +31 -0
- package/dist/functions/templates/uv/pyproject.toml +30 -0
- package/dist/functions/templates/uv/src/__init__.py +0 -0
- package/dist/functions/templates/uv/src/context.py +125 -0
- package/dist/functions/templates/uv/src/index.py +46 -0
- package/dist/interactiveCLI.js +18 -15
- package/dist/main.js +219 -81
- 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.d.ts +1 -1
- package/dist/shared/selectionDialogs.js +39 -11
- 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.d.ts +2 -1
- package/dist/utilsController.js +151 -22
- package/package.json +7 -5
- package/scripts/copy-templates.ts +23 -0
- 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 +19 -19
- 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/config/services/ConfigLoaderService.ts +62 -1
- package/src/examples/yamlTerminologyExample.ts +10 -5
- package/src/functions/deployments.ts +10 -35
- package/src/functions/fnConfigDiscovery.ts +103 -0
- package/src/functions/methods.ts +4 -2
- package/src/functions/pathResolution.ts +227 -0
- package/src/interactiveCLI.ts +25 -20
- package/src/main.ts +557 -202
- 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 +65 -32
- 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 +202 -36
- package/dist/utils/schemaStrings.d.ts +0 -14
- package/dist/utils/schemaStrings.js +0 -428
- package/dist/utils/sessionPreservationExample.d.ts +0 -1666
- package/dist/utils/sessionPreservationExample.js +0 -101
|
@@ -26,15 +26,14 @@ export const databaseCommands = {
|
|
|
26
26
|
// Get local collections for selection
|
|
27
27
|
const localCollections = (cli as any).getLocalCollections();
|
|
28
28
|
|
|
29
|
-
//
|
|
30
|
-
const { syncExisting, modifyConfiguration } = await SelectionDialogs.promptForExistingConfig(configuredDatabases);
|
|
29
|
+
// Push operations always use local configuration as source of truth
|
|
31
30
|
|
|
32
31
|
// Select databases
|
|
33
|
-
const selectedDatabaseIds = await SelectionDialogs.selectDatabases(
|
|
34
|
-
availableDatabases,
|
|
35
|
-
configuredDatabases,
|
|
36
|
-
{ showSelectAll:
|
|
37
|
-
);
|
|
32
|
+
const selectedDatabaseIds = await SelectionDialogs.selectDatabases(
|
|
33
|
+
availableDatabases,
|
|
34
|
+
configuredDatabases,
|
|
35
|
+
{ showSelectAll: false, allowNewOnly: false, defaultSelected: [] }
|
|
36
|
+
);
|
|
38
37
|
|
|
39
38
|
if (selectedDatabaseIds.length === 0) {
|
|
40
39
|
MessageFormatter.warning("No databases selected. Skipping database sync.", { prefix: "Database" });
|
|
@@ -54,7 +53,8 @@ export const databaseCommands = {
|
|
|
54
53
|
(cli as any).controller!.database!,
|
|
55
54
|
chalk.blue(`Select collections/tables to push to "${database.name}":`),
|
|
56
55
|
true, // multiSelect
|
|
57
|
-
true
|
|
56
|
+
true, // prefer local
|
|
57
|
+
true // shouldFilterByDatabase
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
// Map selected collections to table IDs
|
|
@@ -93,12 +93,12 @@ export const databaseCommands = {
|
|
|
93
93
|
MessageFormatter.warning("No storage buckets available in remote instance.", { prefix: "Database" });
|
|
94
94
|
} else {
|
|
95
95
|
// Select buckets using SelectionDialogs
|
|
96
|
-
const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases(
|
|
97
|
-
selectedDatabaseIds,
|
|
98
|
-
availableBuckets,
|
|
99
|
-
configuredBuckets,
|
|
100
|
-
{ showSelectAll:
|
|
101
|
-
);
|
|
96
|
+
const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases(
|
|
97
|
+
selectedDatabaseIds,
|
|
98
|
+
availableBuckets,
|
|
99
|
+
configuredBuckets,
|
|
100
|
+
{ showSelectAll: false, groupByDatabase: true, defaultSelected: [] }
|
|
101
|
+
);
|
|
102
102
|
|
|
103
103
|
if (selectedBucketIds.length > 0) {
|
|
104
104
|
// Create BucketSelection objects
|
|
@@ -133,16 +133,16 @@ export const databaseCommands = {
|
|
|
133
133
|
bucketSelections
|
|
134
134
|
);
|
|
135
135
|
|
|
136
|
-
const confirmed = await SelectionDialogs.confirmSyncSelection(selectionSummary);
|
|
136
|
+
const confirmed = await SelectionDialogs.confirmSyncSelection(selectionSummary, 'push');
|
|
137
137
|
|
|
138
138
|
if (!confirmed) {
|
|
139
|
-
MessageFormatter.info("
|
|
139
|
+
MessageFormatter.info("Push operation cancelled by user", { prefix: "Database" });
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
// Perform selective
|
|
144
|
-
MessageFormatter.progress("Starting selective
|
|
145
|
-
await (cli as any).controller!.
|
|
143
|
+
// Perform selective push using the controller
|
|
144
|
+
MessageFormatter.progress("Starting selective push...", { prefix: "Database" });
|
|
145
|
+
await (cli as any).controller!.selectivePush(databaseSelections, bucketSelections);
|
|
146
146
|
|
|
147
147
|
MessageFormatter.success("\n✅ All database configurations pushed successfully!", { prefix: "Database" });
|
|
148
148
|
|
|
@@ -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()!,
|