@njdamstra/appwrite-utils-cli 1.8.9 → 1.10.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 +16 -0
- package/CONFIG_TODO.md +1189 -0
- package/SELECTION_DIALOGS.md +146 -0
- package/SERVICE_IMPLEMENTATION_REPORT.md +462 -0
- package/dist/adapters/index.d.ts +7 -8
- package/dist/adapters/index.js +7 -9
- package/dist/backups/operations/bucketBackup.js +2 -2
- package/dist/backups/operations/collectionBackup.d.ts +1 -1
- package/dist/backups/operations/collectionBackup.js +3 -3
- package/dist/backups/operations/comprehensiveBackup.d.ts +1 -1
- package/dist/backups/operations/comprehensiveBackup.js +2 -2
- package/dist/backups/tracking/centralizedTracking.d.ts +1 -1
- package/dist/backups/tracking/centralizedTracking.js +2 -2
- package/dist/cli/commands/configCommands.js +51 -7
- package/dist/cli/commands/databaseCommands.d.ts +1 -0
- package/dist/cli/commands/databaseCommands.js +119 -9
- package/dist/cli/commands/functionCommands.js +3 -3
- package/dist/cli/commands/importFileCommands.d.ts +7 -0
- package/dist/cli/commands/importFileCommands.js +674 -0
- package/dist/cli/commands/schemaCommands.js +3 -3
- package/dist/cli/commands/storageCommands.js +2 -3
- package/dist/cli/commands/transferCommands.js +3 -5
- package/dist/collections/attributes.d.ts +1 -1
- package/dist/collections/attributes.js +85 -35
- package/dist/collections/indexes.js +2 -4
- package/dist/collections/methods.d.ts +1 -1
- package/dist/collections/methods.js +111 -192
- package/dist/collections/tableOperations.d.ts +1 -0
- package/dist/collections/tableOperations.js +90 -23
- package/dist/collections/transferOperations.d.ts +1 -1
- package/dist/collections/transferOperations.js +3 -4
- package/dist/collections/wipeOperations.d.ts +4 -3
- package/dist/collections/wipeOperations.js +112 -39
- package/dist/databases/methods.js +2 -2
- package/dist/databases/setup.js +2 -2
- package/dist/examples/yamlTerminologyExample.js +2 -2
- package/dist/functions/deployments.d.ts +1 -1
- package/dist/functions/deployments.js +5 -5
- package/dist/functions/fnConfigDiscovery.js +2 -2
- package/dist/functions/methods.js +16 -4
- package/dist/init.js +1 -1
- package/dist/interactiveCLI.d.ts +6 -1
- package/dist/interactiveCLI.js +64 -10
- package/dist/main.js +130 -177
- package/dist/migrations/afterImportActions.js +2 -3
- package/dist/migrations/appwriteToX.d.ts +97 -1
- package/dist/migrations/appwriteToX.js +9 -7
- package/dist/migrations/comprehensiveTransfer.js +3 -5
- package/dist/migrations/dataLoader.d.ts +194 -2
- package/dist/migrations/dataLoader.js +2 -5
- package/dist/migrations/importController.js +3 -4
- package/dist/migrations/importDataActions.js +3 -3
- package/dist/migrations/relationships.js +1 -2
- package/dist/migrations/services/DataTransformationService.js +2 -2
- package/dist/migrations/services/FileHandlerService.js +1 -1
- package/dist/migrations/services/ImportOrchestrator.js +4 -4
- package/dist/migrations/services/RateLimitManager.js +1 -1
- package/dist/migrations/services/RelationshipResolver.js +1 -1
- package/dist/migrations/services/UserMappingService.js +1 -1
- package/dist/migrations/services/ValidationService.js +1 -1
- package/dist/migrations/transfer.d.ts +8 -4
- package/dist/migrations/transfer.js +106 -55
- package/dist/migrations/yaml/YamlImportConfigLoader.js +1 -1
- package/dist/migrations/yaml/YamlImportIntegration.js +2 -2
- package/dist/migrations/yaml/generateImportSchemas.js +1 -1
- package/dist/setupCommands.d.ts +1 -1
- package/dist/setupCommands.js +5 -6
- package/dist/setupController.js +1 -1
- package/dist/shared/backupTracking.d.ts +1 -1
- package/dist/shared/backupTracking.js +2 -2
- package/dist/shared/confirmationDialogs.js +1 -1
- package/dist/shared/migrationHelpers.d.ts +1 -1
- package/dist/shared/migrationHelpers.js +3 -3
- package/dist/shared/operationQueue.d.ts +1 -1
- package/dist/shared/operationQueue.js +2 -3
- package/dist/shared/operationsTable.d.ts +1 -1
- package/dist/shared/operationsTable.js +2 -2
- package/dist/shared/progressManager.js +1 -1
- package/dist/shared/selectionDialogs.js +9 -8
- package/dist/storage/methods.js +4 -4
- package/dist/storage/schemas.d.ts +386 -2
- package/dist/tables/indexManager.d.ts +65 -0
- package/dist/tables/indexManager.js +294 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/dist/users/methods.js +2 -3
- package/dist/utils/configMigration.js +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/loadConfigs.d.ts +2 -2
- package/dist/utils/loadConfigs.js +6 -7
- package/dist/utils/setupFiles.js +5 -7
- package/dist/utilsController.d.ts +15 -8
- package/dist/utilsController.js +57 -28
- package/package.json +8 -4
- package/src/adapters/index.ts +8 -34
- package/src/backups/operations/bucketBackup.ts +2 -2
- package/src/backups/operations/collectionBackup.ts +4 -4
- package/src/backups/operations/comprehensiveBackup.ts +3 -3
- package/src/backups/tracking/centralizedTracking.ts +3 -3
- package/src/cli/commands/configCommands.ts +72 -8
- package/src/cli/commands/databaseCommands.ts +161 -9
- package/src/cli/commands/functionCommands.ts +4 -3
- package/src/cli/commands/importFileCommands.ts +815 -0
- package/src/cli/commands/schemaCommands.ts +3 -3
- package/src/cli/commands/storageCommands.ts +2 -3
- package/src/cli/commands/transferCommands.ts +3 -6
- package/src/collections/attributes.ts +155 -39
- package/src/collections/indexes.ts +5 -7
- package/src/collections/methods.ts +115 -150
- package/src/collections/tableOperations.ts +92 -21
- package/src/collections/transferOperations.ts +4 -5
- package/src/collections/wipeOperations.ts +154 -51
- package/src/databases/methods.ts +2 -2
- package/src/databases/setup.ts +2 -2
- package/src/examples/yamlTerminologyExample.ts +2 -2
- package/src/functions/deployments.ts +6 -5
- package/src/functions/fnConfigDiscovery.ts +2 -2
- package/src/functions/methods.ts +19 -6
- package/src/init.ts +1 -1
- package/src/interactiveCLI.ts +78 -13
- package/src/main.ts +143 -287
- package/src/migrations/afterImportActions.ts +2 -3
- package/src/migrations/appwriteToX.ts +12 -8
- package/src/migrations/comprehensiveTransfer.ts +6 -6
- package/src/migrations/dataLoader.ts +2 -5
- package/src/migrations/importController.ts +3 -4
- package/src/migrations/importDataActions.ts +3 -3
- package/src/migrations/relationships.ts +1 -2
- package/src/migrations/services/DataTransformationService.ts +2 -2
- package/src/migrations/services/FileHandlerService.ts +1 -1
- package/src/migrations/services/ImportOrchestrator.ts +4 -4
- package/src/migrations/services/RateLimitManager.ts +1 -1
- package/src/migrations/services/RelationshipResolver.ts +1 -1
- package/src/migrations/services/UserMappingService.ts +1 -1
- package/src/migrations/services/ValidationService.ts +1 -1
- package/src/migrations/transfer.ts +126 -83
- package/src/migrations/yaml/YamlImportConfigLoader.ts +1 -1
- package/src/migrations/yaml/YamlImportIntegration.ts +2 -2
- package/src/migrations/yaml/generateImportSchemas.ts +1 -1
- package/src/setupCommands.ts +5 -6
- package/src/setupController.ts +1 -1
- package/src/shared/backupTracking.ts +3 -3
- package/src/shared/confirmationDialogs.ts +1 -1
- package/src/shared/migrationHelpers.ts +4 -4
- package/src/shared/operationQueue.ts +3 -4
- package/src/shared/operationsTable.ts +3 -3
- package/src/shared/progressManager.ts +1 -1
- package/src/shared/selectionDialogs.ts +9 -8
- package/src/storage/methods.ts +4 -4
- package/src/tables/indexManager.ts +409 -0
- package/src/types.ts +2 -2
- package/src/users/methods.ts +2 -3
- package/src/utils/configMigration.ts +1 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/loadConfigs.ts +15 -7
- package/src/utils/setupFiles.ts +5 -7
- package/src/utilsController.ts +86 -32
- package/dist/adapters/AdapterFactory.d.ts +0 -94
- package/dist/adapters/AdapterFactory.js +0 -405
- package/dist/adapters/DatabaseAdapter.d.ts +0 -233
- package/dist/adapters/DatabaseAdapter.js +0 -50
- package/dist/adapters/LegacyAdapter.d.ts +0 -50
- package/dist/adapters/LegacyAdapter.js +0 -612
- package/dist/adapters/TablesDBAdapter.d.ts +0 -45
- package/dist/adapters/TablesDBAdapter.js +0 -571
- package/dist/config/ConfigManager.d.ts +0 -445
- package/dist/config/ConfigManager.js +0 -625
- package/dist/config/configMigration.d.ts +0 -87
- package/dist/config/configMigration.js +0 -390
- package/dist/config/configValidation.d.ts +0 -66
- package/dist/config/configValidation.js +0 -358
- package/dist/config/index.d.ts +0 -8
- package/dist/config/index.js +0 -7
- package/dist/config/services/ConfigDiscoveryService.d.ts +0 -126
- package/dist/config/services/ConfigDiscoveryService.js +0 -374
- package/dist/config/services/ConfigLoaderService.d.ts +0 -129
- package/dist/config/services/ConfigLoaderService.js +0 -540
- package/dist/config/services/ConfigMergeService.d.ts +0 -208
- package/dist/config/services/ConfigMergeService.js +0 -308
- package/dist/config/services/ConfigValidationService.d.ts +0 -214
- package/dist/config/services/ConfigValidationService.js +0 -310
- package/dist/config/services/SessionAuthService.d.ts +0 -225
- package/dist/config/services/SessionAuthService.js +0 -456
- package/dist/config/services/__tests__/ConfigMergeService.test.d.ts +0 -1
- package/dist/config/services/__tests__/ConfigMergeService.test.js +0 -271
- package/dist/config/services/index.d.ts +0 -13
- package/dist/config/services/index.js +0 -10
- package/dist/config/yamlConfig.d.ts +0 -722
- package/dist/config/yamlConfig.js +0 -702
- package/dist/functions/pathResolution.d.ts +0 -37
- package/dist/functions/pathResolution.js +0 -185
- package/dist/shared/attributeMapper.d.ts +0 -20
- package/dist/shared/attributeMapper.js +0 -203
- package/dist/shared/errorUtils.d.ts +0 -54
- package/dist/shared/errorUtils.js +0 -95
- package/dist/shared/functionManager.d.ts +0 -48
- package/dist/shared/functionManager.js +0 -336
- package/dist/shared/indexManager.d.ts +0 -24
- package/dist/shared/indexManager.js +0 -151
- package/dist/shared/jsonSchemaGenerator.d.ts +0 -50
- package/dist/shared/jsonSchemaGenerator.js +0 -290
- package/dist/shared/logging.d.ts +0 -61
- package/dist/shared/logging.js +0 -116
- package/dist/shared/messageFormatter.d.ts +0 -39
- package/dist/shared/messageFormatter.js +0 -162
- package/dist/shared/pydanticModelGenerator.d.ts +0 -17
- package/dist/shared/pydanticModelGenerator.js +0 -615
- package/dist/shared/schemaGenerator.d.ts +0 -40
- package/dist/shared/schemaGenerator.js +0 -556
- package/dist/utils/ClientFactory.d.ts +0 -87
- package/dist/utils/ClientFactory.js +0 -212
- package/dist/utils/configDiscovery.d.ts +0 -78
- package/dist/utils/configDiscovery.js +0 -472
- package/dist/utils/constantsGenerator.d.ts +0 -31
- package/dist/utils/constantsGenerator.js +0 -321
- package/dist/utils/dataConverters.d.ts +0 -46
- package/dist/utils/dataConverters.js +0 -139
- package/dist/utils/directoryUtils.d.ts +0 -22
- package/dist/utils/directoryUtils.js +0 -59
- package/dist/utils/getClientFromConfig.d.ts +0 -39
- package/dist/utils/getClientFromConfig.js +0 -199
- package/dist/utils/helperFunctions.d.ts +0 -63
- package/dist/utils/helperFunctions.js +0 -156
- package/dist/utils/pathResolvers.d.ts +0 -53
- package/dist/utils/pathResolvers.js +0 -72
- package/dist/utils/projectConfig.d.ts +0 -119
- package/dist/utils/projectConfig.js +0 -171
- package/dist/utils/retryFailedPromises.d.ts +0 -2
- package/dist/utils/retryFailedPromises.js +0 -23
- package/dist/utils/sessionAuth.d.ts +0 -48
- package/dist/utils/sessionAuth.js +0 -164
- package/dist/utils/typeGuards.d.ts +0 -35
- package/dist/utils/typeGuards.js +0 -57
- package/dist/utils/validationRules.d.ts +0 -43
- package/dist/utils/validationRules.js +0 -42
- package/dist/utils/versionDetection.d.ts +0 -58
- package/dist/utils/versionDetection.js +0 -251
- package/dist/utils/yamlConverter.d.ts +0 -100
- package/dist/utils/yamlConverter.js +0 -428
- package/dist/utils/yamlLoader.d.ts +0 -70
- package/dist/utils/yamlLoader.js +0 -267
- package/src/adapters/AdapterFactory.ts +0 -510
- package/src/adapters/DatabaseAdapter.ts +0 -306
- package/src/adapters/LegacyAdapter.ts +0 -841
- package/src/adapters/TablesDBAdapter.ts +0 -773
- package/src/config/ConfigManager.ts +0 -808
- package/src/config/README.md +0 -274
- package/src/config/configMigration.ts +0 -575
- package/src/config/configValidation.ts +0 -445
- package/src/config/index.ts +0 -10
- package/src/config/services/ConfigDiscoveryService.ts +0 -463
- package/src/config/services/ConfigLoaderService.ts +0 -740
- package/src/config/services/ConfigMergeService.ts +0 -388
- package/src/config/services/ConfigValidationService.ts +0 -394
- package/src/config/services/SessionAuthService.ts +0 -565
- package/src/config/services/__tests__/ConfigMergeService.test.ts +0 -351
- package/src/config/services/index.ts +0 -29
- package/src/config/yamlConfig.ts +0 -761
- package/src/functions/pathResolution.ts +0 -227
- package/src/shared/attributeMapper.ts +0 -229
- package/src/shared/errorUtils.ts +0 -110
- package/src/shared/functionManager.ts +0 -525
- package/src/shared/indexManager.ts +0 -254
- package/src/shared/jsonSchemaGenerator.ts +0 -383
- package/src/shared/logging.ts +0 -149
- package/src/shared/messageFormatter.ts +0 -208
- package/src/shared/pydanticModelGenerator.ts +0 -618
- package/src/shared/schemaGenerator.ts +0 -644
- package/src/utils/ClientFactory.ts +0 -240
- package/src/utils/configDiscovery.ts +0 -557
- package/src/utils/constantsGenerator.ts +0 -369
- package/src/utils/dataConverters.ts +0 -159
- package/src/utils/directoryUtils.ts +0 -61
- package/src/utils/getClientFromConfig.ts +0 -257
- package/src/utils/helperFunctions.ts +0 -228
- package/src/utils/pathResolvers.ts +0 -81
- package/src/utils/projectConfig.ts +0 -299
- package/src/utils/retryFailedPromises.ts +0 -29
- package/src/utils/sessionAuth.ts +0 -230
- package/src/utils/typeGuards.ts +0 -65
- package/src/utils/validationRules.ts +0 -88
- package/src/utils/versionDetection.ts +0 -292
- package/src/utils/yamlConverter.ts +0 -542
- package/src/utils/yamlLoader.ts +0 -371
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { MessageFormatter } from
|
|
5
|
-
import { SchemaGenerator } from
|
|
4
|
+
import { MessageFormatter } from '@njdamstra/appwrite-utils-helpers';
|
|
5
|
+
import { SchemaGenerator } from '@njdamstra/appwrite-utils-helpers';
|
|
6
6
|
import { setupDirsFiles } from "../../utils/setupFiles.js";
|
|
7
7
|
import { fetchAllDatabases } from "../../databases/methods.js";
|
|
8
8
|
import type { InteractiveCLI } from "../../interactiveCLI.js";
|
|
@@ -126,7 +126,7 @@ export const schemaCommands = {
|
|
|
126
126
|
]);
|
|
127
127
|
|
|
128
128
|
try {
|
|
129
|
-
const { ConstantsGenerator } = await import("
|
|
129
|
+
const { ConstantsGenerator } = await import("@njdamstra/appwrite-utils-helpers");
|
|
130
130
|
const generator = new ConstantsGenerator((cli as any).controller.config);
|
|
131
131
|
|
|
132
132
|
const include = {
|
|
@@ -2,10 +2,9 @@ import inquirer from "inquirer";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { Storage, Permission, Role, Compression, type Models } from "node-appwrite";
|
|
4
4
|
import type { InteractiveCLI } from "../../interactiveCLI.js";
|
|
5
|
-
import { MessageFormatter } from
|
|
5
|
+
import { MessageFormatter } from '@njdamstra/appwrite-utils-helpers';
|
|
6
6
|
import { listBuckets, createBucket as createBucketApi, deleteBucket as deleteBucketApi } from "../../storage/methods.js";
|
|
7
|
-
import { writeYamlConfig } from "
|
|
8
|
-
import { ConfigManager } from "../../config/ConfigManager.js";
|
|
7
|
+
import { writeYamlConfig, ConfigManager } from "@njdamstra/appwrite-utils-helpers";
|
|
9
8
|
|
|
10
9
|
export const storageCommands = {
|
|
11
10
|
async createBucket(cli: InteractiveCLI): Promise<void> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import { Databases, Storage } from "node-appwrite";
|
|
3
|
-
import { MessageFormatter } from
|
|
3
|
+
import { MessageFormatter } from '@njdamstra/appwrite-utils-helpers';
|
|
4
4
|
import { fetchAllDatabases } from "../../databases/methods.js";
|
|
5
5
|
import { listBuckets } from "../../storage/methods.js";
|
|
6
|
-
import { getClient } from "
|
|
6
|
+
import { getClient } from "@njdamstra/appwrite-utils-helpers";
|
|
7
7
|
import { ComprehensiveTransfer, type ComprehensiveTransferOptions } from "../../migrations/comprehensiveTransfer.js";
|
|
8
8
|
import type { TransferOptions } from "../../migrations/transfer.js";
|
|
9
9
|
import type { InteractiveCLI } from "../../interactiveCLI.js";
|
|
@@ -145,10 +145,7 @@ export const transferCommands = {
|
|
|
145
145
|
fromDb,
|
|
146
146
|
targetDb,
|
|
147
147
|
isRemote,
|
|
148
|
-
collections:
|
|
149
|
-
selectedCollections.length > 0
|
|
150
|
-
? selectedCollections.map((c: any) => c.$id)
|
|
151
|
-
: undefined,
|
|
148
|
+
collections: selectedCollections.map((c: any) => c.$id),
|
|
152
149
|
sourceBucket,
|
|
153
150
|
targetBucket,
|
|
154
151
|
};
|
|
@@ -14,13 +14,11 @@ import {
|
|
|
14
14
|
delay,
|
|
15
15
|
tryAwaitWithRetry,
|
|
16
16
|
calculateExponentialBackoff,
|
|
17
|
-
} from "
|
|
17
|
+
} from "@njdamstra/appwrite-utils-helpers";
|
|
18
18
|
import chalk from "chalk";
|
|
19
19
|
import { Decimal } from "decimal.js";
|
|
20
|
-
import type { DatabaseAdapter, CreateAttributeParams, UpdateAttributeParams, DeleteAttributeParams } from "
|
|
21
|
-
import { logger } from "
|
|
22
|
-
import { MessageFormatter } from "../shared/messageFormatter.js";
|
|
23
|
-
import { isDatabaseAdapter } from "../utils/typeGuards.js";
|
|
20
|
+
import type { DatabaseAdapter, CreateAttributeParams, UpdateAttributeParams, DeleteAttributeParams } from "@njdamstra/appwrite-utils-helpers";
|
|
21
|
+
import { logger, MessageFormatter, isDatabaseAdapter } from "@njdamstra/appwrite-utils-helpers";
|
|
24
22
|
|
|
25
23
|
// Extreme values that Appwrite may return, which should be treated as undefined
|
|
26
24
|
const EXTREME_MIN_INTEGER = -9223372036854776000;
|
|
@@ -595,6 +593,74 @@ const createLegacyAttribute = async (
|
|
|
595
593
|
attribute.array || false
|
|
596
594
|
);
|
|
597
595
|
break;
|
|
596
|
+
case "varchar":
|
|
597
|
+
await db.createVarcharAttribute(
|
|
598
|
+
dbId,
|
|
599
|
+
collectionId,
|
|
600
|
+
attribute.key,
|
|
601
|
+
(attribute as any).size || 255,
|
|
602
|
+
attribute.required || false,
|
|
603
|
+
(attribute as any).xdefault !== undefined && !attribute.required
|
|
604
|
+
? (attribute as any).xdefault
|
|
605
|
+
: undefined,
|
|
606
|
+
attribute.array || false,
|
|
607
|
+
(attribute as any).encrypt
|
|
608
|
+
);
|
|
609
|
+
break;
|
|
610
|
+
case "text":
|
|
611
|
+
case "mediumtext":
|
|
612
|
+
case "longtext": {
|
|
613
|
+
const createFn = attribute.type === "text"
|
|
614
|
+
? db.createTextAttribute.bind(db)
|
|
615
|
+
: attribute.type === "mediumtext"
|
|
616
|
+
? db.createMediumtextAttribute.bind(db)
|
|
617
|
+
: db.createLongtextAttribute.bind(db);
|
|
618
|
+
await createFn(
|
|
619
|
+
dbId,
|
|
620
|
+
collectionId,
|
|
621
|
+
attribute.key,
|
|
622
|
+
attribute.required || false,
|
|
623
|
+
(attribute as any).xdefault !== undefined && !attribute.required
|
|
624
|
+
? (attribute as any).xdefault
|
|
625
|
+
: undefined,
|
|
626
|
+
attribute.array || false,
|
|
627
|
+
(attribute as any).encrypt
|
|
628
|
+
);
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
case "point":
|
|
632
|
+
await db.createPointAttribute(
|
|
633
|
+
dbId,
|
|
634
|
+
collectionId,
|
|
635
|
+
attribute.key,
|
|
636
|
+
attribute.required || false,
|
|
637
|
+
(attribute as any).xdefault !== undefined && !attribute.required
|
|
638
|
+
? (attribute as any).xdefault
|
|
639
|
+
: undefined
|
|
640
|
+
);
|
|
641
|
+
break;
|
|
642
|
+
case "line":
|
|
643
|
+
await db.createLineAttribute(
|
|
644
|
+
dbId,
|
|
645
|
+
collectionId,
|
|
646
|
+
attribute.key,
|
|
647
|
+
attribute.required || false,
|
|
648
|
+
(attribute as any).xdefault !== undefined && !attribute.required
|
|
649
|
+
? (attribute as any).xdefault
|
|
650
|
+
: undefined
|
|
651
|
+
);
|
|
652
|
+
break;
|
|
653
|
+
case "polygon":
|
|
654
|
+
await db.createPolygonAttribute(
|
|
655
|
+
dbId,
|
|
656
|
+
collectionId,
|
|
657
|
+
attribute.key,
|
|
658
|
+
attribute.required || false,
|
|
659
|
+
(attribute as any).xdefault !== undefined && !attribute.required
|
|
660
|
+
? (attribute as any).xdefault
|
|
661
|
+
: undefined
|
|
662
|
+
);
|
|
663
|
+
break;
|
|
598
664
|
case "relationship":
|
|
599
665
|
await db.createRelationshipAttribute(
|
|
600
666
|
dbId,
|
|
@@ -617,6 +683,10 @@ const createLegacyAttribute = async (
|
|
|
617
683
|
type: (attribute as any).type,
|
|
618
684
|
supportedTypes: [
|
|
619
685
|
"string",
|
|
686
|
+
"varchar",
|
|
687
|
+
"text",
|
|
688
|
+
"mediumtext",
|
|
689
|
+
"longtext",
|
|
620
690
|
"integer",
|
|
621
691
|
"double",
|
|
622
692
|
"float",
|
|
@@ -626,6 +696,9 @@ const createLegacyAttribute = async (
|
|
|
626
696
|
"ip",
|
|
627
697
|
"url",
|
|
628
698
|
"enum",
|
|
699
|
+
"point",
|
|
700
|
+
"line",
|
|
701
|
+
"polygon",
|
|
629
702
|
"relationship",
|
|
630
703
|
],
|
|
631
704
|
operation: "createLegacyAttribute",
|
|
@@ -651,13 +724,6 @@ const updateLegacyAttribute = async (
|
|
|
651
724
|
collectionId: string,
|
|
652
725
|
attribute: Attribute
|
|
653
726
|
): Promise<void> => {
|
|
654
|
-
console.log(`DEBUG updateLegacyAttribute before normalizeMinMaxValues:`, {
|
|
655
|
-
key: attribute.key,
|
|
656
|
-
type: attribute.type,
|
|
657
|
-
min: (attribute as any).min,
|
|
658
|
-
max: (attribute as any).max
|
|
659
|
-
});
|
|
660
|
-
|
|
661
727
|
const { min: normalizedMin, max: normalizedMax } =
|
|
662
728
|
normalizeMinMaxValues(attribute);
|
|
663
729
|
|
|
@@ -779,6 +845,70 @@ const updateLegacyAttribute = async (
|
|
|
779
845
|
: null
|
|
780
846
|
);
|
|
781
847
|
break;
|
|
848
|
+
case "varchar":
|
|
849
|
+
await db.updateVarcharAttribute(
|
|
850
|
+
dbId,
|
|
851
|
+
collectionId,
|
|
852
|
+
attribute.key,
|
|
853
|
+
attribute.required || false,
|
|
854
|
+
!attribute.required && (attribute as any).xdefault !== undefined
|
|
855
|
+
? (attribute as any).xdefault
|
|
856
|
+
: null,
|
|
857
|
+
(attribute as any).size
|
|
858
|
+
);
|
|
859
|
+
break;
|
|
860
|
+
case "text":
|
|
861
|
+
case "mediumtext":
|
|
862
|
+
case "longtext": {
|
|
863
|
+
const updateFn = attribute.type === "text"
|
|
864
|
+
? db.updateTextAttribute.bind(db)
|
|
865
|
+
: attribute.type === "mediumtext"
|
|
866
|
+
? db.updateMediumtextAttribute.bind(db)
|
|
867
|
+
: db.updateLongtextAttribute.bind(db);
|
|
868
|
+
await updateFn(
|
|
869
|
+
dbId,
|
|
870
|
+
collectionId,
|
|
871
|
+
attribute.key,
|
|
872
|
+
attribute.required || false,
|
|
873
|
+
!attribute.required && (attribute as any).xdefault !== undefined
|
|
874
|
+
? (attribute as any).xdefault
|
|
875
|
+
: null
|
|
876
|
+
);
|
|
877
|
+
break;
|
|
878
|
+
}
|
|
879
|
+
case "point":
|
|
880
|
+
await db.updatePointAttribute(
|
|
881
|
+
dbId,
|
|
882
|
+
collectionId,
|
|
883
|
+
attribute.key,
|
|
884
|
+
attribute.required || false,
|
|
885
|
+
!attribute.required && (attribute as any).xdefault !== undefined
|
|
886
|
+
? (attribute as any).xdefault
|
|
887
|
+
: null
|
|
888
|
+
);
|
|
889
|
+
break;
|
|
890
|
+
case "line":
|
|
891
|
+
await db.updateLineAttribute(
|
|
892
|
+
dbId,
|
|
893
|
+
collectionId,
|
|
894
|
+
attribute.key,
|
|
895
|
+
attribute.required || false,
|
|
896
|
+
!attribute.required && (attribute as any).xdefault !== undefined
|
|
897
|
+
? (attribute as any).xdefault
|
|
898
|
+
: null
|
|
899
|
+
);
|
|
900
|
+
break;
|
|
901
|
+
case "polygon":
|
|
902
|
+
await db.updatePolygonAttribute(
|
|
903
|
+
dbId,
|
|
904
|
+
collectionId,
|
|
905
|
+
attribute.key,
|
|
906
|
+
attribute.required || false,
|
|
907
|
+
!attribute.required && (attribute as any).xdefault !== undefined
|
|
908
|
+
? (attribute as any).xdefault
|
|
909
|
+
: null
|
|
910
|
+
);
|
|
911
|
+
break;
|
|
782
912
|
case "relationship":
|
|
783
913
|
await db.updateRelationshipAttribute(
|
|
784
914
|
dbId,
|
|
@@ -1057,6 +1187,14 @@ const getComparableFields = (type: string): string[] => {
|
|
|
1057
1187
|
case "string":
|
|
1058
1188
|
return [...baseFields, "size", "encrypt"];
|
|
1059
1189
|
|
|
1190
|
+
case "varchar":
|
|
1191
|
+
return [...baseFields, "size", "encrypt"];
|
|
1192
|
+
|
|
1193
|
+
case "text":
|
|
1194
|
+
case "mediumtext":
|
|
1195
|
+
case "longtext":
|
|
1196
|
+
return [...baseFields, "encrypt"];
|
|
1197
|
+
|
|
1060
1198
|
case "integer":
|
|
1061
1199
|
case "double":
|
|
1062
1200
|
case "float":
|
|
@@ -1065,6 +1203,11 @@ const getComparableFields = (type: string): string[] => {
|
|
|
1065
1203
|
case "enum":
|
|
1066
1204
|
return [...baseFields, "elements"];
|
|
1067
1205
|
|
|
1206
|
+
case "point":
|
|
1207
|
+
case "line":
|
|
1208
|
+
case "polygon":
|
|
1209
|
+
return baseFields;
|
|
1210
|
+
|
|
1068
1211
|
case "relationship":
|
|
1069
1212
|
return [
|
|
1070
1213
|
...baseFields,
|
|
@@ -1515,37 +1658,10 @@ export const createOrUpdateAttribute = async (
|
|
|
1515
1658
|
// `Updating attribute with same key ${attribute.key} but different values`
|
|
1516
1659
|
// );
|
|
1517
1660
|
|
|
1518
|
-
// DEBUG: Log before object merge to detect corruption
|
|
1519
|
-
if ((attribute.key === 'conversationType' || attribute.key === 'messageStreakCount')) {
|
|
1520
|
-
console.log(`[DEBUG] MERGE - key="${attribute.key}"`, {
|
|
1521
|
-
found: {
|
|
1522
|
-
elements: (foundAttribute as any)?.elements,
|
|
1523
|
-
min: (foundAttribute as any)?.min,
|
|
1524
|
-
max: (foundAttribute as any)?.max
|
|
1525
|
-
},
|
|
1526
|
-
desired: {
|
|
1527
|
-
elements: (attribute as any)?.elements,
|
|
1528
|
-
min: (attribute as any)?.min,
|
|
1529
|
-
max: (attribute as any)?.max
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
1661
|
finalAttribute = {
|
|
1535
1662
|
...foundAttribute,
|
|
1536
1663
|
...attribute,
|
|
1537
1664
|
};
|
|
1538
|
-
|
|
1539
|
-
// DEBUG: Log after object merge to detect corruption
|
|
1540
|
-
if ((finalAttribute.key === 'conversationType' || finalAttribute.key === 'messageStreakCount')) {
|
|
1541
|
-
console.log(`[DEBUG] AFTER_MERGE - key="${finalAttribute.key}"`, {
|
|
1542
|
-
merged: {
|
|
1543
|
-
elements: finalAttribute?.elements,
|
|
1544
|
-
min: (finalAttribute as any)?.min,
|
|
1545
|
-
max: (finalAttribute as any)?.max
|
|
1546
|
-
}
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
1665
|
action = "update";
|
|
1550
1666
|
} else if (
|
|
1551
1667
|
!updateEnabled &&
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { indexSchema, type Index } from "@njdamstra/appwrite-utils";
|
|
2
|
-
import { Databases, IndexType, Query, type Models } from "node-appwrite";
|
|
3
|
-
import type { DatabaseAdapter } from "
|
|
4
|
-
import { delay, tryAwaitWithRetry, calculateExponentialBackoff } from "
|
|
5
|
-
import { isLegacyDatabases } from "../utils/typeGuards.js";
|
|
6
|
-
import { MessageFormatter } from "../shared/messageFormatter.js";
|
|
2
|
+
import { Databases, IndexType, OrderBy, Query, type Models } from "node-appwrite";
|
|
3
|
+
import type { DatabaseAdapter } from "@njdamstra/appwrite-utils-helpers";
|
|
4
|
+
import { delay, tryAwaitWithRetry, calculateExponentialBackoff, isLegacyDatabases, MessageFormatter } from "@njdamstra/appwrite-utils-helpers";
|
|
7
5
|
|
|
8
6
|
// System attributes that are always available for indexing in Appwrite
|
|
9
7
|
const SYSTEM_ATTRIBUTES = ['$id', '$createdAt', '$updatedAt', '$permissions'];
|
|
@@ -329,10 +327,10 @@ export const createOrUpdateIndex = async (
|
|
|
329
327
|
index.key,
|
|
330
328
|
index.type as IndexType,
|
|
331
329
|
index.attributes,
|
|
332
|
-
orders
|
|
330
|
+
orders as OrderBy[]
|
|
333
331
|
);
|
|
334
332
|
}
|
|
335
|
-
|
|
333
|
+
|
|
336
334
|
return newIndex;
|
|
337
335
|
};
|
|
338
336
|
|