appwrite-cli 6.2.3 → 8.0.0
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/README.md +4 -4
- package/docs/examples/console/get-resource.md +3 -0
- package/docs/examples/databases/create-documents.md +4 -0
- package/docs/examples/databases/create-index.md +1 -0
- package/docs/examples/databases/delete-documents.md +4 -0
- package/docs/examples/databases/update-documents.md +5 -0
- package/docs/examples/databases/upsert-document.md +6 -0
- package/docs/examples/databases/upsert-documents.md +4 -0
- package/docs/examples/functions/{create-build.md → create-duplicate-deployment.md} +1 -1
- package/docs/examples/functions/create-template-deployment.md +7 -0
- package/docs/examples/functions/create-variable.md +2 -1
- package/docs/examples/functions/create-vcs-deployment.md +5 -0
- package/docs/examples/functions/create.md +0 -4
- package/docs/examples/functions/get-deployment-download.md +2 -1
- package/docs/examples/functions/get-usage.md +1 -0
- package/docs/examples/functions/list-executions.md +0 -1
- package/docs/examples/functions/list-usage.md +2 -0
- package/docs/examples/functions/{update-deployment.md → update-deployment-status.md} +1 -1
- package/docs/examples/functions/{update-deployment-build.md → update-function-deployment.md} +1 -1
- package/docs/examples/functions/update-variable.md +1 -0
- package/docs/examples/migrations/create-csv-migration.md +4 -0
- package/docs/examples/project/create-variable.md +2 -1
- package/docs/examples/project/update-variable.md +1 -0
- package/docs/examples/projects/create-dev-key.md +4 -0
- package/docs/examples/projects/delete-dev-key.md +3 -0
- package/docs/examples/projects/get-dev-key.md +3 -0
- package/docs/examples/projects/list-dev-keys.md +3 -0
- package/docs/examples/projects/update-dev-key.md +5 -0
- package/docs/examples/proxy/create-a-p-i-rule.md +2 -0
- package/docs/examples/proxy/create-function-rule.md +4 -0
- package/docs/examples/proxy/create-redirect-rule.md +4 -0
- package/docs/examples/proxy/create-site-rule.md +4 -0
- package/docs/examples/sites/create-deployment.md +7 -0
- package/docs/examples/sites/create-duplicate-deployment.md +3 -0
- package/docs/examples/sites/create-template-deployment.md +7 -0
- package/docs/examples/sites/create-variable.md +5 -0
- package/docs/examples/sites/create-vcs-deployment.md +5 -0
- package/docs/examples/sites/create.md +19 -0
- package/docs/examples/sites/delete-deployment.md +3 -0
- package/docs/examples/sites/delete-log.md +3 -0
- package/docs/examples/sites/delete-variable.md +3 -0
- package/docs/examples/sites/delete.md +2 -0
- package/docs/examples/sites/get-deployment-download.md +4 -0
- package/docs/examples/sites/get-deployment.md +3 -0
- package/docs/examples/sites/get-log.md +3 -0
- package/docs/examples/sites/get-template.md +2 -0
- package/docs/examples/sites/get-usage.md +3 -0
- package/docs/examples/sites/get-variable.md +3 -0
- package/docs/examples/sites/get.md +2 -0
- package/docs/examples/sites/list-deployments.md +4 -0
- package/docs/examples/sites/list-frameworks.md +1 -0
- package/docs/examples/sites/list-logs.md +3 -0
- package/docs/examples/sites/list-specifications.md +1 -0
- package/docs/examples/sites/list-templates.md +5 -0
- package/docs/examples/sites/list-usage.md +2 -0
- package/docs/examples/sites/list-variables.md +2 -0
- package/docs/examples/sites/list.md +3 -0
- package/docs/examples/sites/update-deployment-status.md +3 -0
- package/docs/examples/sites/update-site-deployment.md +3 -0
- package/docs/examples/sites/update-variable.md +6 -0
- package/docs/examples/sites/update.md +19 -0
- package/docs/examples/storage/get-file-download.md +2 -1
- package/docs/examples/storage/get-file-preview.md +1 -0
- package/docs/examples/storage/get-file-view.md +2 -1
- package/docs/examples/tokens/create-file-token.md +4 -0
- package/docs/examples/tokens/delete.md +2 -0
- package/docs/examples/tokens/get.md +2 -0
- package/docs/examples/tokens/list.md +4 -0
- package/docs/examples/tokens/update.md +3 -0
- package/docs/examples/users/list-memberships.md +3 -1
- package/docs/examples/vcs/create-repository-detection.md +1 -0
- package/docs/examples/vcs/list-repositories.md +1 -0
- package/index.js +6 -2
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +8 -4
- package/lib/commands/account.js +7 -17
- package/lib/commands/avatars.js +7 -14
- package/lib/commands/console.js +50 -1
- package/lib/commands/databases.js +287 -55
- package/lib/commands/functions.js +244 -146
- package/lib/commands/generic.js +1 -1
- package/lib/commands/health.js +0 -63
- package/lib/commands/init.js +191 -0
- package/lib/commands/locale.js +0 -8
- package/lib/commands/messaging.js +38 -51
- package/lib/commands/migrations.js +50 -5
- package/lib/commands/project.js +12 -5
- package/lib/commands/projects.js +246 -27
- package/lib/commands/proxy.js +160 -19
- package/lib/commands/pull.js +124 -1
- package/lib/commands/push.js +338 -5
- package/lib/commands/sites.js +1663 -0
- package/lib/commands/storage.js +28 -22
- package/lib/commands/teams.js +2 -8
- package/lib/commands/tokens.js +261 -0
- package/lib/commands/types.js +126 -0
- package/lib/commands/users.js +15 -17
- package/lib/commands/vcs.js +60 -53
- package/lib/config.js +50 -0
- package/lib/parser.js +2 -2
- package/lib/questions.js +110 -1
- package/lib/type-generation/attribute.js +16 -0
- package/lib/type-generation/languages/dart.js +152 -0
- package/lib/type-generation/languages/java.js +121 -0
- package/lib/type-generation/languages/javascript.js +84 -0
- package/lib/type-generation/languages/kotlin.js +75 -0
- package/lib/type-generation/languages/language.js +125 -0
- package/lib/type-generation/languages/php.js +100 -0
- package/lib/type-generation/languages/swift.js +156 -0
- package/lib/type-generation/languages/typescript.js +95 -0
- package/package.json +2 -1
- package/scoop/appwrite.json +3 -3
- package/docs/examples/assistant/chat.md +0 -2
- package/docs/examples/functions/get-function-usage.md +0 -3
- package/docs/examples/health/get-queue-stats-usage-dump.md +0 -2
- package/docs/examples/proxy/create-rule.md +0 -4
- package/lib/commands/assistant.js +0 -85
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/** @typedef {import('../attribute').Attribute} Attribute */
|
|
2
|
+
const { AttributeType } = require('../attribute');
|
|
3
|
+
const { LanguageMeta } = require("./language");
|
|
4
|
+
|
|
5
|
+
class Swift extends LanguageMeta {
|
|
6
|
+
getType(attribute) {
|
|
7
|
+
let type = "";
|
|
8
|
+
switch (attribute.type) {
|
|
9
|
+
case AttributeType.STRING:
|
|
10
|
+
case AttributeType.EMAIL:
|
|
11
|
+
case AttributeType.DATETIME:
|
|
12
|
+
type = "String";
|
|
13
|
+
if (attribute.format === AttributeType.ENUM) {
|
|
14
|
+
type = LanguageMeta.toPascalCase(attribute.key);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
case AttributeType.INTEGER:
|
|
18
|
+
type = "Int";
|
|
19
|
+
break;
|
|
20
|
+
case AttributeType.FLOAT:
|
|
21
|
+
type = "Double";
|
|
22
|
+
break;
|
|
23
|
+
case AttributeType.BOOLEAN:
|
|
24
|
+
type = "Bool";
|
|
25
|
+
break;
|
|
26
|
+
case AttributeType.RELATIONSHIP:
|
|
27
|
+
type = LanguageMeta.toPascalCase(attribute.relatedCollection);
|
|
28
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
29
|
+
type = `[${type}]`;
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
34
|
+
}
|
|
35
|
+
if (attribute.array) {
|
|
36
|
+
type = "[" + type + "]";
|
|
37
|
+
}
|
|
38
|
+
if (!attribute.required) {
|
|
39
|
+
type += "?";
|
|
40
|
+
}
|
|
41
|
+
return type;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getTemplate() {
|
|
45
|
+
return `import Foundation
|
|
46
|
+
|
|
47
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
48
|
+
<% if (attribute.format === 'enum') { -%>
|
|
49
|
+
public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
|
|
50
|
+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
|
|
51
|
+
case <%- element %> = "<%- element %>"
|
|
52
|
+
<% } -%>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
<% } -%>
|
|
56
|
+
<% } -%>
|
|
57
|
+
public class <%- toPascalCase(collection.name) %>: Codable {
|
|
58
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
59
|
+
public let <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>
|
|
60
|
+
<% } %>
|
|
61
|
+
enum CodingKeys: String, CodingKey {
|
|
62
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
63
|
+
case <%- toCamelCase(attribute.key) %> = "<%- attribute.key %>"
|
|
64
|
+
<% } -%>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
init(
|
|
68
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
69
|
+
<%- toCamelCase(attribute.key) %>: <%- getType(attribute) %><% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
70
|
+
<% } -%>
|
|
71
|
+
) {
|
|
72
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
73
|
+
self.<%- toCamelCase(attribute.key) %> = <%- toCamelCase(attribute.key) %>
|
|
74
|
+
<% } -%>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public required init(from decoder: Decoder) throws {
|
|
78
|
+
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
79
|
+
|
|
80
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
81
|
+
<% if (attribute.required) { -%>
|
|
82
|
+
self.<%- toCamelCase(attribute.key) %> = try container.decode(<%- getType(attribute).replace('?', '') %>.self, forKey: .<%- toCamelCase(attribute.key) %>)
|
|
83
|
+
<% } else { -%>
|
|
84
|
+
self.<%- toCamelCase(attribute.key) %> = try container.decodeIfPresent(<%- getType(attribute).replace('?', '') %>.self, forKey: .<%- toCamelCase(attribute.key) %>)
|
|
85
|
+
<% } -%>
|
|
86
|
+
<% } -%>
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public func encode(to encoder: Encoder) throws {
|
|
90
|
+
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
91
|
+
|
|
92
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
93
|
+
<% if (attribute.required) { -%>
|
|
94
|
+
try container.encode(<%- toCamelCase(attribute.key) %>, forKey: .<%- toCamelCase(attribute.key) %>)
|
|
95
|
+
<% } else { -%>
|
|
96
|
+
try container.encodeIfPresent(<%- toCamelCase(attribute.key) %>, forKey: .<%- toCamelCase(attribute.key) %>)
|
|
97
|
+
<% } -%>
|
|
98
|
+
<% } -%>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public func toMap() -> [String: Any] {
|
|
102
|
+
return [
|
|
103
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
104
|
+
<% if (attribute.type === 'relationship') { -%>
|
|
105
|
+
"<%- attribute.key %>": <%- toCamelCase(attribute.key) %> as Any<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
106
|
+
<% } else if (attribute.array && attribute.type !== 'string' && attribute.type !== 'integer' && attribute.type !== 'float' && attribute.type !== 'boolean') { -%>
|
|
107
|
+
"<%- attribute.key %>": <%- toCamelCase(attribute.key) %>?.map { $0.toMap() } as Any<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
108
|
+
<% } else { -%>
|
|
109
|
+
"<%- attribute.key %>": <%- toCamelCase(attribute.key) %> as Any<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
110
|
+
<% } -%>
|
|
111
|
+
<% } -%>
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public static func from(map: [String: Any]) -> <%- toPascalCase(collection.name) %> {
|
|
116
|
+
return <%- toPascalCase(collection.name) %>(
|
|
117
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
118
|
+
<% if (attribute.type === 'relationship') { -%>
|
|
119
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- toPascalCase(attribute.relatedCollection) %><% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
120
|
+
<% } else if (attribute.array) { -%>
|
|
121
|
+
<% if (attribute.type === 'string') { -%>
|
|
122
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [String]<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
123
|
+
<% } else if (attribute.type === 'integer') { -%>
|
|
124
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [Int]<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
125
|
+
<% } else if (attribute.type === 'float') { -%>
|
|
126
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [Double]<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
127
|
+
<% } else if (attribute.type === 'boolean') { -%>
|
|
128
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [Bool]<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
129
|
+
<% } else { -%>
|
|
130
|
+
<%- toCamelCase(attribute.key) %>: (map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [[String: Any]])<% if (!attribute.required) { %>?<% } %>.map { <%- toPascalCase(attribute.type) %>.from(map: $0) }<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
131
|
+
<% } -%>
|
|
132
|
+
<% } else { -%>
|
|
133
|
+
<% if (attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime' || attribute.type === 'enum') { -%>
|
|
134
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> String<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
135
|
+
<% } else if (attribute.type === 'integer') { -%>
|
|
136
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> Int<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
137
|
+
<% } else if (attribute.type === 'float') { -%>
|
|
138
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> Double<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
139
|
+
<% } else if (attribute.type === 'boolean') { -%>
|
|
140
|
+
<%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> Bool<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
141
|
+
<% } else { -%>
|
|
142
|
+
<%- toCamelCase(attribute.key) %>: <%- toPascalCase(attribute.type) %>.from(map: map["<%- attribute.key %>"] as! [String: Any])<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
|
|
143
|
+
<% } -%>
|
|
144
|
+
<% } -%>
|
|
145
|
+
<% } -%>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
getFileName(collection) {
|
|
152
|
+
return LanguageMeta.toPascalCase(collection.name) + ".swift";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = { Swift };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** @typedef {import('../attribute').Attribute} Attribute */
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const { AttributeType } = require('../attribute');
|
|
6
|
+
const { LanguageMeta } = require("./language");
|
|
7
|
+
|
|
8
|
+
class TypeScript extends LanguageMeta {
|
|
9
|
+
getType(attribute) {
|
|
10
|
+
let type = ""
|
|
11
|
+
switch (attribute.type) {
|
|
12
|
+
case AttributeType.STRING:
|
|
13
|
+
case AttributeType.EMAIL:
|
|
14
|
+
case AttributeType.DATETIME:
|
|
15
|
+
case AttributeType.IP:
|
|
16
|
+
case AttributeType.URL:
|
|
17
|
+
type = "string";
|
|
18
|
+
if (attribute.format === AttributeType.ENUM) {
|
|
19
|
+
type = LanguageMeta.toPascalCase(attribute.key);
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
case AttributeType.INTEGER:
|
|
23
|
+
type = "number";
|
|
24
|
+
break;
|
|
25
|
+
case AttributeType.FLOAT:
|
|
26
|
+
type = "number";
|
|
27
|
+
break;
|
|
28
|
+
case AttributeType.BOOLEAN:
|
|
29
|
+
type = "boolean";
|
|
30
|
+
break;
|
|
31
|
+
case AttributeType.RELATIONSHIP:
|
|
32
|
+
type = LanguageMeta.toPascalCase(attribute.relatedCollection);
|
|
33
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
34
|
+
type = `${type}[]`;
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
39
|
+
}
|
|
40
|
+
if (attribute.array) {
|
|
41
|
+
type += "[]";
|
|
42
|
+
}
|
|
43
|
+
if (!attribute.required) {
|
|
44
|
+
type += " | null";
|
|
45
|
+
}
|
|
46
|
+
return type;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
isSingleFile() {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_getAppwriteDependency() {
|
|
54
|
+
if (fs.existsSync(path.resolve(process.cwd(), 'package.json'))) {
|
|
55
|
+
const packageJsonRaw = fs.readFileSync(path.resolve(process.cwd(), 'package.json'));
|
|
56
|
+
const packageJson = JSON.parse(packageJsonRaw.toString('utf-8'));
|
|
57
|
+
return packageJson.dependencies['node-appwrite'] ? 'node-appwrite' : 'appwrite';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (fs.existsSync(path.resolve(process.cwd(), 'deno.json'))) {
|
|
61
|
+
return "https://deno.land/x/appwrite/mod.ts";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return "appwrite";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getTemplate() {
|
|
68
|
+
return `import { Models } from '${this._getAppwriteDependency()}';
|
|
69
|
+
|
|
70
|
+
<% for (const collection of collections) { -%>
|
|
71
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
72
|
+
<% if (attribute.format === 'enum') { -%>
|
|
73
|
+
export enum <%- toPascalCase(attribute.key) %> {
|
|
74
|
+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
|
|
75
|
+
<%- element.toUpperCase() %> = "<%- element %>",
|
|
76
|
+
<% } -%>
|
|
77
|
+
}
|
|
78
|
+
<% } -%>
|
|
79
|
+
<% } -%>
|
|
80
|
+
<% } -%>
|
|
81
|
+
<% for (const collection of collections) { %>
|
|
82
|
+
export type <%- toPascalCase(collection.name) %> = Models.Document & {
|
|
83
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
84
|
+
<%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>;
|
|
85
|
+
<% } -%>
|
|
86
|
+
}
|
|
87
|
+
<% } %>`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getFileName(_) {
|
|
91
|
+
return "appwrite.d.ts";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = { TypeScript };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "appwrite-cli",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "8.0.0",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"undici": "^5.28.2",
|
|
26
|
+
"ejs": "^3.1.9",
|
|
26
27
|
"chalk": "4.1.2",
|
|
27
28
|
"cli-progress": "^3.12.0",
|
|
28
29
|
"cli-table3": "^0.6.2",
|
package/scoop/appwrite.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.0.0/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.0.0/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const pathLib = require('path');
|
|
3
|
-
const tar = require("tar");
|
|
4
|
-
const ignore = require("ignore");
|
|
5
|
-
const { promisify } = require('util');
|
|
6
|
-
const libClient = require('../client.js');
|
|
7
|
-
const { getAllFiles, showConsoleLink } = require('../utils.js');
|
|
8
|
-
const { Command } = require('commander');
|
|
9
|
-
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
|
-
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
|
-
const { localConfig, globalConfig } = require("../config");
|
|
12
|
-
const { File } = require('undici');
|
|
13
|
-
const { ReadableStream } = require('stream/web');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {fs.ReadStream} readStream
|
|
17
|
-
* @returns {ReadableStream}
|
|
18
|
-
*/
|
|
19
|
-
function convertReadStreamToReadableStream(readStream) {
|
|
20
|
-
return new ReadableStream({
|
|
21
|
-
start(controller) {
|
|
22
|
-
readStream.on("data", (chunk) => {
|
|
23
|
-
controller.enqueue(chunk);
|
|
24
|
-
});
|
|
25
|
-
readStream.on("end", () => {
|
|
26
|
-
controller.close();
|
|
27
|
-
});
|
|
28
|
-
readStream.on("error", (err) => {
|
|
29
|
-
controller.error(err);
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
cancel() {
|
|
33
|
-
readStream.destroy();
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const assistant = new Command("assistant").description(commandDescriptions['assistant'] ?? '').configureHelp({
|
|
39
|
-
helpWidth: process.stdout.columns || 80
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @typedef {Object} AssistantChatRequestParams
|
|
44
|
-
* @property {string} prompt Prompt. A string containing questions asked to the AI assistant.
|
|
45
|
-
* @property {boolean} overrideForCli
|
|
46
|
-
* @property {boolean} parseOutput
|
|
47
|
-
* @property {libClient | undefined} sdk
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @param {AssistantChatRequestParams} params
|
|
52
|
-
*/
|
|
53
|
-
const assistantChat = async ({prompt,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
54
|
-
let client = !sdk ? await sdkForProject() :
|
|
55
|
-
sdk;
|
|
56
|
-
let apiPath = '/console/assistant';
|
|
57
|
-
let payload = {};
|
|
58
|
-
if (typeof prompt !== 'undefined') {
|
|
59
|
-
payload['prompt'] = prompt;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let response = undefined;
|
|
63
|
-
|
|
64
|
-
response = await client.call('post', apiPath, {
|
|
65
|
-
'content-type': 'application/json',
|
|
66
|
-
}, payload);
|
|
67
|
-
|
|
68
|
-
if (parseOutput) {
|
|
69
|
-
parse(response)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return response;
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
assistant
|
|
77
|
-
.command(`chat`)
|
|
78
|
-
.description(`Send a prompt to the AI assistant and receive a response. This endpoint allows you to interact with Appwrite's AI assistant by sending questions or prompts and receiving helpful responses in real-time through a server-sent events stream. `)
|
|
79
|
-
.requiredOption(`--prompt <prompt>`, `Prompt. A string containing questions asked to the AI assistant.`)
|
|
80
|
-
.action(actionRunner(assistantChat))
|
|
81
|
-
|
|
82
|
-
module.exports = {
|
|
83
|
-
assistant,
|
|
84
|
-
assistantChat
|
|
85
|
-
};
|