appwrite-utils-cli 0.9.83 → 0.9.85
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/dist/interactiveCLI.js
CHANGED
@@ -104,17 +104,17 @@ export class InteractiveCLI {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
async selectDatabases(databases, message, multiSelect = true) {
|
107
|
-
const choices = databases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
|
108
107
|
const configDatabases = this.getLocalDatabases();
|
109
108
|
const dbNames = databases.map((db) => db.name).concat(configDatabases.map((db) => db.name));
|
110
109
|
const allDbNamesUnique = Array.from(new Set(dbNames));
|
111
110
|
const allDatabases = allDbNamesUnique.map((name) => configDatabases.find((db) => db.name === name) ?? databases.find((db) => db.name === name)).filter((v) => v !== undefined).sort((a, b) => a.name.localeCompare(b.name));
|
111
|
+
const choices = allDatabases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
|
112
112
|
const { selectedDatabases } = await inquirer.prompt([
|
113
113
|
{
|
114
114
|
type: multiSelect ? "checkbox" : "list",
|
115
115
|
name: "selectedDatabases",
|
116
116
|
message: chalk.blue(message),
|
117
|
-
choices
|
117
|
+
choices,
|
118
118
|
loop: false,
|
119
119
|
pageSize: 10,
|
120
120
|
},
|
@@ -592,7 +592,7 @@ export class InteractiveCLI {
|
|
592
592
|
console.log(chalk.green("Data transfer completed."));
|
593
593
|
}
|
594
594
|
getLocalCollections() {
|
595
|
-
const configCollections = this.controller.config
|
595
|
+
const configCollections = this.controller.config?.collections || [];
|
596
596
|
// @ts-expect-error - appwrite invalid types
|
597
597
|
return configCollections.map(c => ({
|
598
598
|
$id: c.$id || ulid(),
|
@@ -608,7 +608,7 @@ export class InteractiveCLI {
|
|
608
608
|
}));
|
609
609
|
}
|
610
610
|
getLocalDatabases() {
|
611
|
-
const configDatabases = this.controller.config
|
611
|
+
const configDatabases = this.controller.config?.databases || [];
|
612
612
|
return configDatabases.map(db => ({
|
613
613
|
$id: db.$id || ulid(),
|
614
614
|
$createdAt: DateTime.now().toISO(),
|
@@ -111,6 +111,9 @@ export class SchemaGenerator {
|
|
111
111
|
return;
|
112
112
|
}
|
113
113
|
this.config.collections.forEach((collection) => {
|
114
|
+
if (!collection.attributes) {
|
115
|
+
return;
|
116
|
+
}
|
114
117
|
collection.attributes.forEach((attr) => {
|
115
118
|
if (attr.type === "relationship" && attr.twoWay && attr.twoWayKey) {
|
116
119
|
const relationshipAttr = attr;
|
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": "0.9.
|
4
|
+
"version": "0.9.85",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/interactiveCLI.ts
CHANGED
@@ -121,19 +121,18 @@ export class InteractiveCLI {
|
|
121
121
|
message: string,
|
122
122
|
multiSelect = true
|
123
123
|
): Promise<Models.Database[]> {
|
124
|
-
const choices = databases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
|
125
124
|
const configDatabases = this.getLocalDatabases();
|
126
125
|
const dbNames = databases.map((db) => db.name).concat(configDatabases.map((db) => db.name));
|
127
126
|
const allDbNamesUnique = Array.from(new Set(dbNames));
|
128
127
|
const allDatabases = allDbNamesUnique.map((name) => configDatabases.find((db) => db.name === name) ?? databases.find((db) => db.name === name)).filter((v) => v !== undefined).sort((a, b) => a.name.localeCompare(b.name));
|
129
|
-
|
128
|
+
const choices = allDatabases.map((db) => ({ name: db.name, value: db })).filter((db) => db.name.toLowerCase() !== "migrations");
|
130
129
|
|
131
130
|
const { selectedDatabases } = await inquirer.prompt([
|
132
131
|
{
|
133
132
|
type: multiSelect ? "checkbox" : "list",
|
134
133
|
name: "selectedDatabases",
|
135
134
|
message: chalk.blue(message),
|
136
|
-
choices
|
135
|
+
choices,
|
137
136
|
loop: false,
|
138
137
|
pageSize: 10,
|
139
138
|
},
|
@@ -816,7 +815,7 @@ export class InteractiveCLI {
|
|
816
815
|
|
817
816
|
|
818
817
|
private getLocalCollections(): Models.Collection[] {
|
819
|
-
const configCollections = this.controller!.config
|
818
|
+
const configCollections = this.controller!.config?.collections || [];
|
820
819
|
// @ts-expect-error - appwrite invalid types
|
821
820
|
return configCollections.map(c => ({
|
822
821
|
$id: c.$id || ulid(),
|
@@ -833,7 +832,7 @@ export class InteractiveCLI {
|
|
833
832
|
}
|
834
833
|
|
835
834
|
private getLocalDatabases(): Models.Database[] {
|
836
|
-
const configDatabases = this.controller!.config
|
835
|
+
const configDatabases = this.controller!.config?.databases || [];
|
837
836
|
return configDatabases.map(db => ({
|
838
837
|
$id: db.$id || ulid(),
|
839
838
|
$createdAt: DateTime.now().toISO(),
|
@@ -145,6 +145,9 @@ export class SchemaGenerator {
|
|
145
145
|
return;
|
146
146
|
}
|
147
147
|
this.config.collections.forEach((collection) => {
|
148
|
+
if (!collection.attributes) {
|
149
|
+
return;
|
150
|
+
}
|
148
151
|
collection.attributes.forEach((attr) => {
|
149
152
|
if (attr.type === "relationship" && attr.twoWay && attr.twoWayKey) {
|
150
153
|
const relationshipAttr = attr as RelationshipAttribute;
|