appwrite-utils-cli 1.8.3 → 1.8.6

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 (53) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/README.md +42 -13
  3. package/dist/adapters/TablesDBAdapter.js +1 -1
  4. package/dist/cli/commands/functionCommands.js +30 -3
  5. package/dist/cli/commands/schemaCommands.js +39 -4
  6. package/dist/cli/commands/storageCommands.d.ts +5 -0
  7. package/dist/cli/commands/storageCommands.js +143 -0
  8. package/dist/collections/attributes.js +7 -7
  9. package/dist/collections/methods.js +122 -1
  10. package/dist/collections/tableOperations.js +2 -2
  11. package/dist/interactiveCLI.d.ts +1 -0
  12. package/dist/interactiveCLI.js +30 -0
  13. package/dist/main.js +17 -0
  14. package/dist/migrations/appwriteToX.js +1 -1
  15. package/dist/migrations/yaml/generateImportSchemas.js +2 -2
  16. package/dist/setupCommands.js +6 -0
  17. package/dist/shared/attributeMapper.js +2 -2
  18. package/dist/shared/jsonSchemaGenerator.js +3 -1
  19. package/dist/shared/pydanticModelGenerator.d.ts +17 -0
  20. package/dist/shared/pydanticModelGenerator.js +615 -0
  21. package/dist/shared/schemaGenerator.d.ts +3 -2
  22. package/dist/shared/schemaGenerator.js +22 -9
  23. package/dist/storage/methods.js +50 -7
  24. package/dist/utils/configDiscovery.js +2 -3
  25. package/dist/utils/constantsGenerator.d.ts +20 -8
  26. package/dist/utils/constantsGenerator.js +37 -25
  27. package/dist/utils/projectConfig.js +1 -1
  28. package/dist/utils/yamlConverter.d.ts +2 -2
  29. package/dist/utils/yamlConverter.js +2 -2
  30. package/dist/utilsController.js +11 -1
  31. package/package.json +1 -1
  32. package/src/adapters/TablesDBAdapter.ts +1 -1
  33. package/src/cli/commands/functionCommands.ts +28 -3
  34. package/src/cli/commands/schemaCommands.ts +59 -22
  35. package/src/cli/commands/storageCommands.ts +152 -0
  36. package/src/collections/attributes.ts +7 -7
  37. package/src/collections/methods.ts +125 -11
  38. package/src/collections/tableOperations.ts +2 -2
  39. package/src/interactiveCLI.ts +42 -12
  40. package/src/main.ts +32 -9
  41. package/src/migrations/appwriteToX.ts +1 -1
  42. package/src/migrations/yaml/generateImportSchemas.ts +7 -7
  43. package/src/setupCommands.ts +6 -0
  44. package/src/shared/attributeMapper.ts +2 -2
  45. package/src/shared/jsonSchemaGenerator.ts +4 -2
  46. package/src/shared/pydanticModelGenerator.ts +618 -0
  47. package/src/shared/schemaGenerator.ts +38 -25
  48. package/src/storage/methods.ts +67 -23
  49. package/src/utils/configDiscovery.ts +40 -41
  50. package/src/utils/constantsGenerator.ts +43 -26
  51. package/src/utils/projectConfig.ts +11 -11
  52. package/src/utils/yamlConverter.ts +40 -40
  53. package/src/utilsController.ts +30 -20
package/dist/main.js CHANGED
@@ -407,6 +407,23 @@ const argv = yargs(hideBin(process.argv))
407
407
  type: "string",
408
408
  description: "Output directory for generated constants files (default: config-folder/constants)",
409
409
  default: "auto",
410
+ })
411
+ .option("constantsInclude", {
412
+ type: "string",
413
+ description: "Comma-separated categories to include: databases,collections,buckets,functions",
414
+ })
415
+ .option("generateSchemas", {
416
+ type: "boolean",
417
+ description: "Generate schemas/models without interactive prompts",
418
+ })
419
+ .option("schemaFormat", {
420
+ type: "string",
421
+ choices: ["zod", "json", "pydantic", "both", "all"],
422
+ description: "Schema format: zod, json, pydantic, both (zod+json), or all",
423
+ })
424
+ .option("schemaOutDir", {
425
+ type: "string",
426
+ description: "Output directory for generated schemas (absolute path respected)",
410
427
  })
411
428
  .option("migrateCollectionsToTables", {
412
429
  alias: ["migrate-collections"],
@@ -468,7 +468,7 @@ export class AppwriteToX {
468
468
  await generator.updateConfig(configWithApiContext, false);
469
469
  }
470
470
  MessageFormatter.info("Generating Zod schemas from synced collections...", { prefix: "Migration" });
471
- generator.generateSchemas();
471
+ await generator.generateSchemas();
472
472
  MessageFormatter.success("Sync-from-Appwrite process completed successfully", { prefix: "Migration" });
473
473
  }
474
474
  catch (error) {
@@ -551,8 +551,8 @@ export function generateTableSchema() {
551
551
  }
552
552
  // Add column definition (similar to attribute but with table terminology)
553
553
  tableSchema.$defs.column = JSON.parse(JSON.stringify(tableSchema.$defs.attribute));
554
- // Add encrypted property (table-specific feature)
555
- tableSchema.$defs.column.properties.encrypted = {
554
+ // Add encrypt property (table-specific feature)
555
+ tableSchema.$defs.column.properties.encrypt = {
556
556
  "type": "boolean",
557
557
  "description": "Whether the column should be encrypted",
558
558
  "default": false
@@ -259,6 +259,12 @@ export function createYamlValidationSchema(yamlSchemaFolder, useTables) {
259
259
  "default": false,
260
260
  "description": `Whether the ${useTables ? 'column' : 'attribute'} is an array`
261
261
  },
262
+ // Encryption flag for string types
263
+ "encrypt": {
264
+ "type": "boolean",
265
+ "default": false,
266
+ "description": `Enable encryption for string ${useTables ? 'columns' : 'attributes'}`
267
+ },
262
268
  ...(useTables ? {
263
269
  "unique": {
264
270
  "type": "boolean",
@@ -14,7 +14,7 @@ export function mapToCreateAttributeParams(attr, base) {
14
14
  const required = !!attr.required;
15
15
  const array = !!attr.array;
16
16
  const xdefault = attr.xdefault;
17
- const encrypt = attr.encrypted ?? attr.encrypt;
17
+ const encrypt = attr.encrypt;
18
18
  // Numeric helpers
19
19
  const rawMin = ensureNumber(attr.min);
20
20
  const rawMax = ensureNumber(attr.max);
@@ -160,7 +160,7 @@ export function mapToUpdateAttributeParams(attr, base) {
160
160
  setIfDefined("array", attr.array);
161
161
  // encrypt only applies to string types
162
162
  if (type === "string")
163
- setIfDefined("encrypt", attr.encrypted ?? attr.encrypt);
163
+ setIfDefined("encrypt", attr.encrypt);
164
164
  // Numeric normalization
165
165
  const toNum = (n) => (n === null || n === undefined ? undefined : (Number(n)));
166
166
  let min = toNum(attr.min);
@@ -177,7 +177,9 @@ export class JsonSchemaGenerator {
177
177
  return;
178
178
  }
179
179
  // Create JSON schemas directory using provided outputDirectory
180
- const jsonSchemasPath = path.join(this.appwriteFolderPath, outputDirectory);
180
+ const jsonSchemasPath = path.isAbsolute(outputDirectory)
181
+ ? outputDirectory
182
+ : path.join(this.appwriteFolderPath, outputDirectory);
181
183
  if (!fs.existsSync(jsonSchemasPath)) {
182
184
  fs.mkdirSync(jsonSchemasPath, { recursive: true });
183
185
  }
@@ -0,0 +1,17 @@
1
+ import type { AppwriteConfig } from 'appwrite-utils';
2
+ export declare class PydanticModelGenerator {
3
+ private config;
4
+ private appwriteFolderPath;
5
+ constructor(config: AppwriteConfig, appwriteFolderPath: string);
6
+ generatePydanticModels(options: {
7
+ baseOutputDirectory: string;
8
+ verbose?: boolean;
9
+ }): void;
10
+ private writeBase;
11
+ private generateModel;
12
+ private composeHeader;
13
+ private defaultInitializer;
14
+ private mapAttributeToPythonType;
15
+ private toSnake;
16
+ private toPascal;
17
+ }