appwrite-utils-cli 1.3.5 → 1.4.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.
Files changed (116) hide show
  1. package/dist/adapters/AdapterFactory.d.ts +87 -0
  2. package/dist/adapters/AdapterFactory.js +217 -0
  3. package/dist/adapters/DatabaseAdapter.d.ts +217 -0
  4. package/dist/adapters/DatabaseAdapter.js +50 -0
  5. package/dist/adapters/LegacyAdapter.d.ts +49 -0
  6. package/dist/adapters/LegacyAdapter.js +382 -0
  7. package/dist/adapters/TablesDBAdapter.d.ts +55 -0
  8. package/dist/adapters/TablesDBAdapter.js +302 -0
  9. package/dist/adapters/index.d.ts +11 -0
  10. package/dist/adapters/index.js +12 -0
  11. package/dist/collections/attributes.js +41 -22
  12. package/dist/collections/methods.d.ts +4 -3
  13. package/dist/collections/methods.js +34 -14
  14. package/dist/config/yamlConfig.d.ts +40 -437
  15. package/dist/config/yamlConfig.js +8 -2
  16. package/dist/databases/setup.js +2 -2
  17. package/dist/main.js +0 -0
  18. package/dist/migrations/appwriteToX.d.ts +26 -37
  19. package/dist/migrations/comprehensiveTransfer.js +4 -4
  20. package/dist/migrations/dataLoader.d.ts +124 -1484
  21. package/dist/migrations/dataLoader.js +2 -1
  22. package/dist/migrations/relationships.d.ts +2 -3
  23. package/dist/migrations/relationships.js +1 -1
  24. package/dist/migrations/services/UserMappingService.js +1 -1
  25. package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +24 -279
  26. package/dist/migrations/yaml/YamlImportConfigLoader.js +7 -2
  27. package/dist/schemas/authUser.d.ts +7 -47
  28. package/dist/schemas/authUser.js +1 -1
  29. package/dist/shared/jsonSchemaGenerator.d.ts +0 -2
  30. package/dist/shared/jsonSchemaGenerator.js +4 -17
  31. package/dist/shared/migrationHelpers.d.ts +17 -119
  32. package/dist/shared/operationQueue.js +16 -7
  33. package/dist/shared/schemaGenerator.js +2 -17
  34. package/dist/storage/schemas.d.ts +149 -296
  35. package/dist/users/methods.d.ts +2 -2
  36. package/dist/utils/configMigration.js +0 -1
  37. package/dist/utils/getClientFromConfig.d.ts +26 -0
  38. package/dist/utils/getClientFromConfig.js +37 -0
  39. package/dist/utils/loadConfigs.js +0 -2
  40. package/dist/utils/schemaStrings.js +2 -17
  41. package/dist/utils/setupFiles.js +2 -0
  42. package/dist/utils/versionDetection.d.ts +56 -0
  43. package/dist/utils/versionDetection.js +217 -0
  44. package/dist/utils/yamlConverter.d.ts +0 -1
  45. package/dist/utils/yamlConverter.js +0 -2
  46. package/dist/utilsController.js +2 -0
  47. package/package.json +3 -2
  48. package/src/adapters/AdapterFactory.ts +296 -0
  49. package/src/adapters/DatabaseAdapter.ts +290 -0
  50. package/src/adapters/LegacyAdapter.ts +667 -0
  51. package/src/adapters/TablesDBAdapter.ts +429 -0
  52. package/src/adapters/index.ts +37 -0
  53. package/src/collections/attributes.ts +347 -153
  54. package/src/collections/methods.ts +43 -28
  55. package/src/config/yamlConfig.ts +8 -2
  56. package/src/databases/setup.ts +2 -2
  57. package/src/migrations/afterImportActions.ts +2 -2
  58. package/src/migrations/comprehensiveTransfer.ts +4 -0
  59. package/src/migrations/dataLoader.ts +2 -1
  60. package/src/migrations/relationships.ts +1 -1
  61. package/src/migrations/services/UserMappingService.ts +1 -1
  62. package/src/migrations/yaml/YamlImportConfigLoader.ts +7 -2
  63. package/src/schemas/authUser.ts +1 -1
  64. package/src/shared/jsonSchemaGenerator.ts +4 -19
  65. package/src/shared/operationQueue.ts +20 -13
  66. package/src/shared/schemaGenerator.ts +2 -16
  67. package/src/types/node-appwrite-tablesdb.d.ts +44 -0
  68. package/src/users/methods.ts +2 -2
  69. package/src/utils/configMigration.ts +0 -1
  70. package/src/utils/getClientFromConfig.ts +56 -0
  71. package/src/utils/loadConfigs.ts +0 -2
  72. package/src/utils/schemaStrings.ts +2 -16
  73. package/src/utils/setupFiles.ts +2 -0
  74. package/src/utils/versionDetection.ts +265 -0
  75. package/src/utils/yamlConverter.ts +0 -2
  76. package/src/utilsController.ts +2 -0
  77. package/dist/functions/openapi.d.ts +0 -4
  78. package/dist/functions/openapi.js +0 -60
  79. package/dist/migrations/attributes.d.ts +0 -4
  80. package/dist/migrations/attributes.js +0 -301
  81. package/dist/migrations/backup.d.ts +0 -687
  82. package/dist/migrations/backup.js +0 -175
  83. package/dist/migrations/collections.d.ts +0 -22
  84. package/dist/migrations/collections.js +0 -347
  85. package/dist/migrations/converters.d.ts +0 -46
  86. package/dist/migrations/converters.js +0 -139
  87. package/dist/migrations/databases.d.ts +0 -2
  88. package/dist/migrations/databases.js +0 -28
  89. package/dist/migrations/dbHelpers.d.ts +0 -5
  90. package/dist/migrations/dbHelpers.js +0 -57
  91. package/dist/migrations/helper.d.ts +0 -3
  92. package/dist/migrations/helper.js +0 -21
  93. package/dist/migrations/indexes.d.ts +0 -4
  94. package/dist/migrations/indexes.js +0 -19
  95. package/dist/migrations/logging.d.ts +0 -10
  96. package/dist/migrations/logging.js +0 -46
  97. package/dist/migrations/migrationHelper.d.ts +0 -173
  98. package/dist/migrations/migrationHelper.js +0 -130
  99. package/dist/migrations/openapi.d.ts +0 -4
  100. package/dist/migrations/openapi.js +0 -60
  101. package/dist/migrations/queue.d.ts +0 -13
  102. package/dist/migrations/queue.js +0 -79
  103. package/dist/migrations/schemaStrings.d.ts +0 -14
  104. package/dist/migrations/schemaStrings.js +0 -478
  105. package/dist/migrations/setupDatabase.d.ts +0 -6
  106. package/dist/migrations/setupDatabase.js +0 -115
  107. package/dist/migrations/storage.d.ts +0 -10
  108. package/dist/migrations/storage.js +0 -340
  109. package/dist/migrations/users.d.ts +0 -16
  110. package/dist/migrations/users.js +0 -276
  111. package/dist/migrations/validationRules.d.ts +0 -43
  112. package/dist/migrations/validationRules.js +0 -42
  113. package/dist/shared/attributeManager.d.ts +0 -17
  114. package/dist/shared/attributeManager.js +0 -272
  115. package/src/functions/openapi.ts +0 -83
  116. package/src/shared/attributeManager.ts +0 -428
@@ -8,8 +8,8 @@ export declare class UsersController {
8
8
  constructor(config: AppwriteConfig, db: Databases);
9
9
  wipeUsers(): Promise<void>;
10
10
  getAllUsers(): Promise<Models.User<Models.Preferences>[]>;
11
- createUsersAndReturn(items: AuthUserCreate[]): Promise<(Models.User<Models.Preferences> | undefined)[]>;
12
- createUserAndReturn(item: AuthUserCreate): Promise<Models.User<Models.Preferences> | undefined>;
11
+ createUsersAndReturn(items: AuthUserCreate[]): Promise<any[]>;
12
+ createUserAndReturn(item: AuthUserCreate): Promise<any>;
13
13
  createAndCheckForUserAndReturn(item: AuthUserCreate): Promise<Models.User<Models.Preferences> | undefined>;
14
14
  getUserIdByEmailOrPhone(email?: string, phone?: string): Promise<string | undefined>;
15
15
  transferUsersBetweenDbsLocalToRemote: (endpoint: string, projectId: string, apiKey: string) => Promise<void>;
@@ -220,7 +220,6 @@ async function convertCollectionToYaml(tsFilePath, targetDir) {
220
220
  required: attr.required ?? false,
221
221
  array: attr.array,
222
222
  default: attr.xdefault || attr.default,
223
- description: attr.description,
224
223
  min: attr.min,
225
224
  max: attr.max,
226
225
  elements: attr.elements,
@@ -1,4 +1,30 @@
1
1
  import { type AppwriteConfig } from "appwrite-utils";
2
2
  import { Client } from "node-appwrite";
3
+ import type { DatabaseAdapter } from "../adapters/DatabaseAdapter.js";
4
+ /**
5
+ * Legacy function - returns basic Client for backwards compatibility
6
+ * @deprecated Use getAdapterFromConfig for dual API support
7
+ */
3
8
  export declare const getClientFromConfig: (config: AppwriteConfig) => Client | undefined;
9
+ /**
10
+ * Legacy function - returns basic Client
11
+ * @deprecated Use createDatabaseAdapter for dual API support
12
+ */
4
13
  export declare const getClient: (endpoint: string, project: string, key: string) => Client;
14
+ /**
15
+ * Modern adapter-based client creation with dual API support
16
+ * Returns both adapter and legacy client for compatibility
17
+ */
18
+ export declare const getAdapterFromConfig: (config: AppwriteConfig, forceRefresh?: boolean) => Promise<{
19
+ adapter: DatabaseAdapter;
20
+ client: Client;
21
+ apiMode: "legacy" | "tablesdb";
22
+ }>;
23
+ /**
24
+ * Create adapter from individual parameters
25
+ */
26
+ export declare const getAdapter: (endpoint: string, project: string, key: string, apiMode?: "auto" | "legacy" | "tablesdb") => Promise<{
27
+ adapter: DatabaseAdapter;
28
+ client: Client;
29
+ apiMode: "legacy" | "tablesdb";
30
+ }>;
@@ -1,5 +1,10 @@
1
1
  import {} from "appwrite-utils";
2
2
  import { Client } from "node-appwrite";
3
+ import { AdapterFactory } from "../adapters/AdapterFactory.js";
4
+ /**
5
+ * Legacy function - returns basic Client for backwards compatibility
6
+ * @deprecated Use getAdapterFromConfig for dual API support
7
+ */
3
8
  export const getClientFromConfig = (config) => {
4
9
  let appwriteClient;
5
10
  if (!config.appwriteClient) {
@@ -11,6 +16,38 @@ export const getClientFromConfig = (config) => {
11
16
  }
12
17
  return appwriteClient;
13
18
  };
19
+ /**
20
+ * Legacy function - returns basic Client
21
+ * @deprecated Use createDatabaseAdapter for dual API support
22
+ */
14
23
  export const getClient = (endpoint, project, key) => {
15
24
  return new Client().setEndpoint(endpoint).setProject(project).setKey(key);
16
25
  };
26
+ /**
27
+ * Modern adapter-based client creation with dual API support
28
+ * Returns both adapter and legacy client for compatibility
29
+ */
30
+ export const getAdapterFromConfig = async (config, forceRefresh) => {
31
+ const result = await AdapterFactory.createFromConfig(config, forceRefresh);
32
+ return {
33
+ adapter: result.adapter,
34
+ client: result.client,
35
+ apiMode: result.apiMode
36
+ };
37
+ };
38
+ /**
39
+ * Create adapter from individual parameters
40
+ */
41
+ export const getAdapter = async (endpoint, project, key, apiMode = 'auto') => {
42
+ const result = await AdapterFactory.create({
43
+ appwriteEndpoint: endpoint,
44
+ appwriteProject: project,
45
+ appwriteKey: key,
46
+ apiMode
47
+ });
48
+ return {
49
+ adapter: result.adapter,
50
+ client: result.client,
51
+ apiMode: result.apiMode
52
+ };
53
+ };
@@ -346,7 +346,6 @@ const YamlCollectionSchema = z.object({
346
346
  required: z.boolean().default(false),
347
347
  array: z.boolean().optional(),
348
348
  default: z.any().optional(),
349
- description: z.string().optional(),
350
349
  min: z.number().optional(),
351
350
  max: z.number().optional(),
352
351
  elements: z.array(z.string()).optional(),
@@ -387,7 +386,6 @@ const loadYamlCollection = (filePath) => {
387
386
  required: attr.required,
388
387
  array: attr.array,
389
388
  xdefault: attr.default,
390
- description: attr.description,
391
389
  min: attr.min,
392
390
  max: attr.max,
393
391
  elements: attr.elements,
@@ -211,11 +211,6 @@ export class SchemaGenerator {
211
211
  createSchemaString = (name, attributes) => {
212
212
  const pascalName = toPascalCase(name);
213
213
  let imports = `import { z } from "zod";\n`;
214
- const hasDescription = attributes.some((attr) => attr.description);
215
- if (hasDescription) {
216
- imports += `import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";\n`;
217
- imports += `extendZodWithOpenApi(z);\n`;
218
- }
219
214
  // Use the relationshipMap to find related collections
220
215
  const relationshipDetails = this.relationshipMap.get(name) || [];
221
216
  const relatedCollections = relationshipDetails
@@ -340,7 +335,7 @@ export class SchemaGenerator {
340
335
  baseSchemaCode = "z.number().int()";
341
336
  if (finalAttribute.min !== undefined) {
342
337
  if (BigInt(finalAttribute.min) === BigInt(-9223372036854776000)) {
343
- delete finalAttribute.min;
338
+ finalAttribute.min = undefined;
344
339
  }
345
340
  else {
346
341
  baseSchemaCode += `.min(${finalAttribute.min}, "Minimum value of ${finalAttribute.min} not met")`;
@@ -348,7 +343,7 @@ export class SchemaGenerator {
348
343
  }
349
344
  if (finalAttribute.max !== undefined) {
350
345
  if (BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
351
- delete finalAttribute.max;
346
+ finalAttribute.max = undefined;
352
347
  }
353
348
  else {
354
349
  baseSchemaCode += `.max(${finalAttribute.max}, "Maximum value of ${finalAttribute.max} exceeded")`;
@@ -445,16 +440,6 @@ export class SchemaGenerator {
445
440
  if (attribute.array && !attribute.required) {
446
441
  baseSchemaCode += ".nullish()";
447
442
  }
448
- if (attribute.description) {
449
- if (typeof attribute.description === "string") {
450
- baseSchemaCode += `.openapi({ description: "${attribute.description}" })`;
451
- }
452
- else {
453
- baseSchemaCode += `.openapi(${Object.entries(attribute.description)
454
- .map(([key, value]) => `"${key}": ${value}`)
455
- .join(", ")})`;
456
- }
457
- }
458
443
  return baseSchemaCode;
459
444
  };
460
445
  }
@@ -10,6 +10,8 @@ const baseConfig = {
10
10
  appwriteEndpoint: "https://cloud.appwrite.io/v1",
11
11
  appwriteProject: "YOUR_PROJECT_ID",
12
12
  appwriteKey: "YOUR_API_KEY",
13
+ appwriteClient: null,
14
+ apiMode: "auto", // Enable dual API support - auto-detect TablesDB vs legacy
13
15
  logging: {
14
16
  enabled: false,
15
17
  level: "info",
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Version Detection Utility for Appwrite API Compatibility
3
+ *
4
+ * This module provides functions to detect whether an Appwrite instance
5
+ * supports the new TablesDB API or uses the legacy Databases API.
6
+ *
7
+ * Detection Strategy:
8
+ * 1. Primary: Test TablesDB-specific endpoint availability
9
+ * 2. Secondary: Health endpoint version check
10
+ * 3. Fallback: Default to legacy mode for safety
11
+ */
12
+ export type ApiMode = 'legacy' | 'tablesdb';
13
+ export interface VersionDetectionResult {
14
+ apiMode: ApiMode;
15
+ detectionMethod: 'endpoint_probe' | 'health_check' | 'fallback';
16
+ serverVersion?: string;
17
+ confidence: 'high' | 'medium' | 'low';
18
+ }
19
+ /**
20
+ * Detects Appwrite API version and TablesDB support
21
+ *
22
+ * @param endpoint - Appwrite server endpoint URL
23
+ * @param project - Project ID
24
+ * @param apiKey - API key for authentication
25
+ * @returns Promise resolving to version detection result
26
+ */
27
+ export declare function detectAppwriteVersion(endpoint: string, project: string, apiKey: string): Promise<VersionDetectionResult>;
28
+ /**
29
+ * Cached version detection with automatic cache management
30
+ *
31
+ * @param endpoint - Appwrite server endpoint URL
32
+ * @param project - Project ID
33
+ * @param apiKey - API key for authentication
34
+ * @param forceRefresh - Skip cache and force fresh detection
35
+ * @returns Promise resolving to version detection result
36
+ */
37
+ export declare function detectAppwriteVersionCached(endpoint: string, project: string, apiKey: string, forceRefresh?: boolean): Promise<VersionDetectionResult>;
38
+ /**
39
+ * Quick check for cloud.appwrite.io instances (likely have TablesDB)
40
+ *
41
+ * @param endpoint - Appwrite server endpoint URL
42
+ * @returns boolean indicating if endpoint is likely cloud-hosted
43
+ */
44
+ export declare function isCloudAppwriteEndpoint(endpoint: string): boolean;
45
+ /**
46
+ * SDK feature detection as a fallback method
47
+ * Attempts to dynamically import TablesDB to check availability
48
+ */
49
+ export declare function detectSdkSupport(): Promise<{
50
+ tablesDbAvailable: boolean;
51
+ legacyAvailable: boolean;
52
+ }>;
53
+ /**
54
+ * Clear version detection cache (useful for testing)
55
+ */
56
+ export declare function clearVersionDetectionCache(): void;
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Version Detection Utility for Appwrite API Compatibility
3
+ *
4
+ * This module provides functions to detect whether an Appwrite instance
5
+ * supports the new TablesDB API or uses the legacy Databases API.
6
+ *
7
+ * Detection Strategy:
8
+ * 1. Primary: Test TablesDB-specific endpoint availability
9
+ * 2. Secondary: Health endpoint version check
10
+ * 3. Fallback: Default to legacy mode for safety
11
+ */
12
+ /**
13
+ * Detects Appwrite API version and TablesDB support
14
+ *
15
+ * @param endpoint - Appwrite server endpoint URL
16
+ * @param project - Project ID
17
+ * @param apiKey - API key for authentication
18
+ * @returns Promise resolving to version detection result
19
+ */
20
+ export async function detectAppwriteVersion(endpoint, project, apiKey) {
21
+ // Clean endpoint URL
22
+ const cleanEndpoint = endpoint.replace(/\/$/, '');
23
+ // Try primary detection method: TablesDB endpoint probe
24
+ try {
25
+ const tablesDbResult = await probeTablesDbEndpoint(cleanEndpoint, project, apiKey);
26
+ if (tablesDbResult.apiMode === 'tablesdb') {
27
+ return tablesDbResult;
28
+ }
29
+ }
30
+ catch (error) {
31
+ console.warn('TablesDB endpoint probe failed:', error instanceof Error ? error.message : 'Unknown error');
32
+ }
33
+ // Try secondary detection method: SDK feature detection
34
+ try {
35
+ const sdkResult = await probeSdkCapabilities();
36
+ if (sdkResult.apiMode === 'tablesdb') {
37
+ return sdkResult;
38
+ }
39
+ }
40
+ catch (error) {
41
+ console.warn('SDK capability probe failed:', error instanceof Error ? error.message : 'Unknown error');
42
+ }
43
+ // Fallback to legacy mode
44
+ return {
45
+ apiMode: 'legacy',
46
+ detectionMethod: 'fallback',
47
+ confidence: 'low'
48
+ };
49
+ }
50
+ /**
51
+ * Test TablesDB endpoint availability - most reliable detection method
52
+ */
53
+ async function probeTablesDbEndpoint(endpoint, project, apiKey) {
54
+ const response = await fetch(`${endpoint}/tablesdb/`, {
55
+ method: 'GET',
56
+ headers: {
57
+ 'Content-Type': 'application/json',
58
+ 'X-Appwrite-Project': project,
59
+ 'X-Appwrite-Key': apiKey
60
+ },
61
+ // Short timeout for faster detection
62
+ signal: AbortSignal.timeout(5000)
63
+ });
64
+ if (response.ok || response.status === 404) {
65
+ // 200 = TablesDB available, 404 = endpoint exists but no tables
66
+ // Both indicate TablesDB support
67
+ return {
68
+ apiMode: 'tablesdb',
69
+ detectionMethod: 'endpoint_probe',
70
+ confidence: 'high'
71
+ };
72
+ }
73
+ // 501 Not Implemented or other errors = no TablesDB support
74
+ throw new Error(`TablesDB endpoint returned ${response.status}: ${response.statusText}`);
75
+ }
76
+ /**
77
+ * SDK capability detection as secondary method
78
+ */
79
+ async function probeSdkCapabilities() {
80
+ try {
81
+ // Try to import TablesDB SDK
82
+ let TablesDBModule;
83
+ try {
84
+ TablesDBModule = await import('node-appwrite-tablesdb');
85
+ }
86
+ catch (importError) {
87
+ // TablesDB SDK not available, will fall back to legacy
88
+ }
89
+ if (TablesDBModule?.TablesDB) {
90
+ return {
91
+ apiMode: 'tablesdb',
92
+ detectionMethod: 'endpoint_probe',
93
+ confidence: 'medium'
94
+ };
95
+ }
96
+ }
97
+ catch (error) {
98
+ // TablesDB SDK not available, assume legacy
99
+ }
100
+ // Check for legacy SDK availability
101
+ try {
102
+ const { Databases } = await import('node-appwrite');
103
+ if (Databases) {
104
+ return {
105
+ apiMode: 'legacy',
106
+ detectionMethod: 'endpoint_probe',
107
+ confidence: 'medium'
108
+ };
109
+ }
110
+ }
111
+ catch (error) {
112
+ throw new Error('No Appwrite SDK available');
113
+ }
114
+ throw new Error('Unable to determine SDK capabilities');
115
+ }
116
+ /**
117
+ * Cached version detection to avoid repeated API calls
118
+ */
119
+ class VersionDetectionCache {
120
+ cache = new Map();
121
+ CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
122
+ getCacheKey(endpoint, project) {
123
+ return `${endpoint}:${project}`;
124
+ }
125
+ get(endpoint, project) {
126
+ const key = this.getCacheKey(endpoint, project);
127
+ const cached = this.cache.get(key);
128
+ if (!cached) {
129
+ return null;
130
+ }
131
+ // Check if cache is expired
132
+ if (Date.now() - cached.timestamp > this.CACHE_DURATION) {
133
+ this.cache.delete(key);
134
+ return null;
135
+ }
136
+ return cached.result;
137
+ }
138
+ set(endpoint, project, result) {
139
+ const key = this.getCacheKey(endpoint, project);
140
+ this.cache.set(key, {
141
+ result,
142
+ timestamp: Date.now()
143
+ });
144
+ }
145
+ clear() {
146
+ this.cache.clear();
147
+ }
148
+ }
149
+ // Global cache instance
150
+ const detectionCache = new VersionDetectionCache();
151
+ /**
152
+ * Cached version detection with automatic cache management
153
+ *
154
+ * @param endpoint - Appwrite server endpoint URL
155
+ * @param project - Project ID
156
+ * @param apiKey - API key for authentication
157
+ * @param forceRefresh - Skip cache and force fresh detection
158
+ * @returns Promise resolving to version detection result
159
+ */
160
+ export async function detectAppwriteVersionCached(endpoint, project, apiKey, forceRefresh = false) {
161
+ // Check cache first (unless force refresh)
162
+ if (!forceRefresh) {
163
+ const cached = detectionCache.get(endpoint, project);
164
+ if (cached) {
165
+ return cached;
166
+ }
167
+ }
168
+ // Perform fresh detection
169
+ const result = await detectAppwriteVersion(endpoint, project, apiKey);
170
+ // Cache the result
171
+ detectionCache.set(endpoint, project, result);
172
+ return result;
173
+ }
174
+ /**
175
+ * Quick check for cloud.appwrite.io instances (likely have TablesDB)
176
+ *
177
+ * @param endpoint - Appwrite server endpoint URL
178
+ * @returns boolean indicating if endpoint is likely cloud-hosted
179
+ */
180
+ export function isCloudAppwriteEndpoint(endpoint) {
181
+ return endpoint.includes('cloud.appwrite.io');
182
+ }
183
+ /**
184
+ * SDK feature detection as a fallback method
185
+ * Attempts to dynamically import TablesDB to check availability
186
+ */
187
+ export async function detectSdkSupport() {
188
+ const result = {
189
+ tablesDbAvailable: false,
190
+ legacyAvailable: false
191
+ };
192
+ // Test TablesDB SDK availability
193
+ try {
194
+ const tablesModule = await import('node-appwrite-tablesdb');
195
+ if (tablesModule) {
196
+ result.tablesDbAvailable = true;
197
+ }
198
+ }
199
+ catch (error) {
200
+ // TablesDB SDK not available
201
+ }
202
+ // Test legacy SDK availability
203
+ try {
204
+ await import('node-appwrite');
205
+ result.legacyAvailable = true;
206
+ }
207
+ catch (error) {
208
+ // Legacy SDK not available
209
+ }
210
+ return result;
211
+ }
212
+ /**
213
+ * Clear version detection cache (useful for testing)
214
+ */
215
+ export function clearVersionDetectionCache() {
216
+ detectionCache.clear();
217
+ }
@@ -15,7 +15,6 @@ export interface YamlCollectionData {
15
15
  required?: boolean;
16
16
  array?: boolean;
17
17
  default?: any;
18
- description?: string;
19
18
  min?: number;
20
19
  max?: number;
21
20
  elements?: string[];
@@ -33,8 +33,6 @@ export function collectionToYaml(collection, schemaPath = "../.yaml_schemas/coll
33
33
  yamlAttr.array = attr.array;
34
34
  if ('xdefault' in attr && attr.xdefault !== undefined)
35
35
  yamlAttr.default = attr.xdefault;
36
- if (attr.description !== undefined)
37
- yamlAttr.description = attr.description;
38
36
  if ('min' in attr && attr.min !== undefined)
39
37
  yamlAttr.min = attr.min;
40
38
  if ('max' in attr && attr.max !== undefined)
@@ -55,6 +55,8 @@ export class UtilsController {
55
55
  appwriteEndpoint: directConfig.appwriteEndpoint,
56
56
  appwriteProject: directConfig.appwriteProject,
57
57
  appwriteKey: directConfig.appwriteKey,
58
+ appwriteClient: null,
59
+ apiMode: "auto", // Default to auto-detect for dual API support
58
60
  enableBackups: false,
59
61
  backupInterval: 0,
60
62
  backupRetention: 0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrite-utils-cli",
3
3
  "description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
4
- "version": "1.3.5",
4
+ "version": "1.4.1",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "@types/inquirer": "^9.0.8",
34
34
  "@types/json-schema": "^7.0.15",
35
35
  "@types/yargs": "^17.0.33",
36
- "appwrite-utils": "^1.3.2",
36
+ "appwrite-utils": "^1.4.1",
37
37
  "chalk": "^5.4.1",
38
38
  "cli-progress": "^3.12.0",
39
39
  "commander": "^12.1.0",
@@ -44,6 +44,7 @@
44
44
  "luxon": "^3.6.1",
45
45
  "nanostores": "^0.10.3",
46
46
  "node-appwrite": "^17",
47
+ "node-appwrite-tablesdb": "npm:node-appwrite@^18.0.0",
47
48
  "p-limit": "^6.2.0",
48
49
  "tar": "^7.4.3",
49
50
  "tsx": "^4.20.3",