appwrite-cli 12.0.1 → 13.0.0-rc.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 +4 -0
- package/README.md +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +89 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +227 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/account.d.ts +379 -0
- package/dist/lib/commands/account.d.ts.map +1 -0
- package/dist/lib/commands/account.js +1228 -0
- package/dist/lib/commands/account.js.map +1 -0
- package/dist/lib/commands/console.d.ts +20 -0
- package/dist/lib/commands/console.d.ts.map +1 -0
- package/dist/lib/commands/console.js +78 -0
- package/dist/lib/commands/console.js.map +1 -0
- package/dist/lib/commands/databases.d.ts +732 -0
- package/dist/lib/commands/databases.d.ts.map +1 -0
- package/dist/lib/commands/databases.js +2196 -0
- package/dist/lib/commands/databases.js.map +1 -0
- package/dist/lib/commands/functions.d.ts +310 -0
- package/dist/lib/commands/functions.d.ts.map +1 -0
- package/dist/lib/commands/functions.js +1100 -0
- package/dist/lib/commands/functions.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +279 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/graphql.d.ts +19 -0
- package/dist/lib/commands/graphql.d.ts.map +1 -0
- package/dist/lib/commands/graphql.js +77 -0
- package/dist/lib/commands/graphql.js.map +1 -0
- package/dist/lib/commands/health.d.ts +153 -0
- package/dist/lib/commands/health.d.ts.map +1 -0
- package/dist/lib/commands/health.js +464 -0
- package/dist/lib/commands/health.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +518 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/locale.d.ts +53 -0
- package/dist/lib/commands/locale.d.ts.map +1 -0
- package/dist/lib/commands/locale.js +165 -0
- package/dist/lib/commands/locale.js.map +1 -0
- package/dist/lib/commands/messaging.d.ts +588 -0
- package/dist/lib/commands/messaging.d.ts.map +1 -0
- package/dist/lib/commands/messaging.js +2042 -0
- package/dist/lib/commands/messaging.js.map +1 -0
- package/dist/lib/commands/migrations.d.ts +150 -0
- package/dist/lib/commands/migrations.d.ts.map +1 -0
- package/dist/lib/commands/migrations.js +524 -0
- package/dist/lib/commands/migrations.js.map +1 -0
- package/dist/lib/commands/organizations.d.ts +11 -0
- package/dist/lib/commands/organizations.d.ts.map +1 -0
- package/dist/lib/commands/organizations.js +31 -0
- package/dist/lib/commands/organizations.js.map +1 -0
- package/dist/lib/commands/project.d.ts +53 -0
- package/dist/lib/commands/project.d.ts.map +1 -0
- package/dist/lib/commands/project.js +176 -0
- package/dist/lib/commands/project.js.map +1 -0
- package/dist/lib/commands/projects.d.ts +516 -0
- package/dist/lib/commands/projects.d.ts.map +1 -0
- package/dist/lib/commands/projects.js +1590 -0
- package/dist/lib/commands/projects.js.map +1 -0
- package/dist/lib/commands/proxy.d.ts +71 -0
- package/dist/lib/commands/proxy.d.ts.map +1 -0
- package/dist/lib/commands/proxy.js +240 -0
- package/dist/lib/commands/proxy.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +8 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +455 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +4 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +2154 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +287 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/sites.d.ts +296 -0
- package/dist/lib/commands/sites.d.ts.map +1 -0
- package/dist/lib/commands/sites.js +1046 -0
- package/dist/lib/commands/sites.js.map +1 -0
- package/dist/lib/commands/storage.d.ts +170 -0
- package/dist/lib/commands/storage.d.ts.map +1 -0
- package/dist/lib/commands/storage.js +651 -0
- package/dist/lib/commands/storage.js.map +1 -0
- package/dist/lib/commands/tables-db.d.ts +728 -0
- package/dist/lib/commands/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/tables-db.js +2198 -0
- package/dist/lib/commands/tables-db.js.map +1 -0
- package/dist/lib/commands/teams.d.ts +129 -0
- package/dist/lib/commands/teams.d.ts.map +1 -0
- package/dist/lib/commands/teams.js +403 -0
- package/dist/lib/commands/teams.js.map +1 -0
- package/dist/lib/commands/tokens.d.ts +48 -0
- package/dist/lib/commands/tokens.d.ts.map +1 -0
- package/dist/lib/commands/tokens.js +156 -0
- package/dist/lib/commands/tokens.js.map +1 -0
- package/dist/lib/commands/types.d.ts +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +155 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +202 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/users.d.ts +382 -0
- package/dist/lib/commands/users.d.ts.map +1 -0
- package/dist/lib/commands/users.js +1195 -0
- package/dist/lib/commands/users.js.map +1 -0
- package/dist/lib/commands/vcs.d.ts +92 -0
- package/dist/lib/commands/vcs.d.ts.map +1 -0
- package/dist/lib/commands/vcs.js +276 -0
- package/dist/lib/commands/vcs.js.map +1 -0
- package/dist/lib/config.d.ts +118 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/{lib → dist/lib}/config.js +204 -325
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +15 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +220 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +168 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/exception.d.ts +8 -0
- package/dist/lib/exception.d.ts.map +1 -0
- package/dist/lib/exception.js +16 -0
- package/dist/lib/exception.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +32 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +10 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/{lib → dist/lib}/paginate.js +9 -15
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +237 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +995 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +51 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/spinner.d.ts +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/{lib → dist/lib}/spinner.js +34 -45
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +19 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +108 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +82 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +112 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +133 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/{lib → dist/lib}/utils.js +74 -120
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +20 -0
- package/dist/lib/validations.js.map +1 -0
- package/docs/examples/databases/upsert-document.md +1 -2
- package/index.ts +152 -0
- package/install.ps1 +2 -5
- package/install.sh +1 -2
- package/lib/client.ts +259 -0
- package/lib/commands/{account.js → account.ts} +408 -662
- package/lib/commands/console.ts +112 -0
- package/lib/commands/{databases.js → databases.ts} +818 -1136
- package/lib/commands/{functions.js → functions.ts} +381 -526
- package/lib/commands/{generic.js → generic.ts} +47 -39
- package/lib/commands/graphql.ts +110 -0
- package/lib/commands/{health.js → health.ts} +168 -284
- package/lib/commands/{init.js → init.ts} +68 -66
- package/lib/commands/{locale.js → locale.ts} +75 -121
- package/lib/commands/{messaging.js → messaging.ts} +699 -937
- package/lib/commands/{migrations.js → migrations.ts} +182 -258
- package/lib/commands/organizations.ts +46 -0
- package/lib/commands/{project.js → project.ts} +75 -111
- package/lib/commands/{projects.js → projects.ts} +587 -843
- package/lib/commands/{proxy.js → proxy.ts} +94 -140
- package/lib/commands/{pull.js → pull.ts} +54 -44
- package/lib/commands/{push.js → push.ts} +235 -191
- package/lib/commands/{run.js → run.ts} +61 -55
- package/lib/commands/{sites.js → sites.ts} +364 -504
- package/lib/commands/{storage.js → storage.ts} +216 -292
- package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
- package/lib/commands/{teams.js → teams.ts} +162 -236
- package/lib/commands/{tokens.js → tokens.ts} +70 -99
- package/lib/commands/{types.js → types.ts} +37 -35
- package/lib/commands/{update.js → update.ts} +25 -27
- package/lib/commands/{users.js → users.ts} +426 -644
- package/lib/commands/{vcs.js → vcs.ts} +118 -174
- package/lib/config.ts +854 -0
- package/lib/emulation/{docker.js → docker.ts} +39 -38
- package/lib/emulation/utils.ts +193 -0
- package/lib/exception.ts +20 -0
- package/lib/{id.js → id.ts} +5 -5
- package/lib/paginate.ts +63 -0
- package/lib/parser.ts +238 -0
- package/lib/{questions.js → questions.ts} +148 -156
- package/lib/sdks.ts +55 -0
- package/lib/spinner.ts +118 -0
- package/lib/type-generation/attribute.ts +17 -0
- package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -57
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -89
- package/lib/type-generation/languages/{java.js → java.ts} +58 -56
- package/lib/type-generation/languages/javascript.ts +111 -0
- package/lib/type-generation/languages/kotlin.ts +96 -0
- package/lib/type-generation/languages/language.ts +119 -0
- package/lib/type-generation/languages/{php.js → php.ts} +55 -53
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -57
- package/lib/type-generation/languages/typescript.ts +116 -0
- package/lib/types.ts +150 -0
- package/lib/utils.ts +322 -0
- package/lib/validations.ts +17 -0
- package/package.json +21 -12
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +30 -0
- package/index.js +0 -147
- package/lib/client.js +0 -254
- package/lib/commands/console.js +0 -127
- package/lib/commands/graphql.js +0 -126
- package/lib/commands/organizations.js +0 -48
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/parser.js +0 -250
- package/lib/sdks.js +0 -60
- package/lib/type-generation/attribute.js +0 -19
- package/lib/type-generation/languages/javascript.js +0 -111
- package/lib/type-generation/languages/kotlin.js +0 -94
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -116
- package/lib/validations.js +0 -17
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dart = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const attribute_1 = require("../attribute");
|
|
7
|
+
const language_1 = require("./language");
|
|
8
|
+
class Dart extends language_1.LanguageMeta {
|
|
9
|
+
getPackageName() {
|
|
10
|
+
const pubspecPath = path.join(process.cwd(), 'pubspec.yaml');
|
|
11
|
+
if (fs.existsSync(pubspecPath)) {
|
|
12
|
+
const pubspecContent = fs.readFileSync(pubspecPath, 'utf8');
|
|
13
|
+
const lines = pubspecContent.split('\n');
|
|
14
|
+
const dependenciesIndex = lines.findIndex((line) => line.trim() === 'dependencies:');
|
|
15
|
+
if (dependenciesIndex !== -1) {
|
|
16
|
+
const indent = lines[dependenciesIndex].search(/\S|$/);
|
|
17
|
+
const dependencies = [];
|
|
18
|
+
for (let i = dependenciesIndex + 1; i < lines.length; i++) {
|
|
19
|
+
const line = lines[i];
|
|
20
|
+
if (line.trim() === '')
|
|
21
|
+
continue;
|
|
22
|
+
const lineIndent = line.search(/\S|$/);
|
|
23
|
+
if (lineIndent <= indent && line.trim() !== '') {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
dependencies.push(line.trim());
|
|
27
|
+
}
|
|
28
|
+
if (dependencies.some((dep) => dep.startsWith('dart_appwrite:'))) {
|
|
29
|
+
return 'dart_appwrite';
|
|
30
|
+
}
|
|
31
|
+
if (dependencies.some((dep) => dep.startsWith('appwrite:'))) {
|
|
32
|
+
return 'appwrite';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return 'appwrite';
|
|
37
|
+
}
|
|
38
|
+
getType(attribute, collections, collectionName) {
|
|
39
|
+
let type = '';
|
|
40
|
+
switch (attribute.type) {
|
|
41
|
+
case attribute_1.AttributeType.STRING:
|
|
42
|
+
case attribute_1.AttributeType.EMAIL:
|
|
43
|
+
case attribute_1.AttributeType.DATETIME:
|
|
44
|
+
type = 'String';
|
|
45
|
+
if (attribute.format === attribute_1.AttributeType.ENUM) {
|
|
46
|
+
type = language_1.LanguageMeta.toPascalCase(collectionName) + language_1.LanguageMeta.toPascalCase(attribute.key);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case attribute_1.AttributeType.INTEGER:
|
|
50
|
+
type = 'int';
|
|
51
|
+
break;
|
|
52
|
+
case attribute_1.AttributeType.FLOAT:
|
|
53
|
+
type = 'double';
|
|
54
|
+
break;
|
|
55
|
+
case attribute_1.AttributeType.BOOLEAN:
|
|
56
|
+
type = 'bool';
|
|
57
|
+
break;
|
|
58
|
+
case attribute_1.AttributeType.RELATIONSHIP:
|
|
59
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
60
|
+
if (!relatedCollection) {
|
|
61
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
62
|
+
}
|
|
63
|
+
type = language_1.LanguageMeta.toPascalCase(relatedCollection.name);
|
|
64
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
65
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
66
|
+
attribute.relationType === 'manyToMany') {
|
|
67
|
+
type = `List<${type}>`;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case attribute_1.AttributeType.POINT:
|
|
71
|
+
type = 'List<double>';
|
|
72
|
+
break;
|
|
73
|
+
case attribute_1.AttributeType.LINESTRING:
|
|
74
|
+
type = 'List<List<double>>';
|
|
75
|
+
break;
|
|
76
|
+
case attribute_1.AttributeType.POLYGON:
|
|
77
|
+
type = 'List<List<List<double>>>';
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
81
|
+
}
|
|
82
|
+
if (attribute.array) {
|
|
83
|
+
type = `List<${type}>`;
|
|
84
|
+
}
|
|
85
|
+
if (!attribute.required) {
|
|
86
|
+
type += '?';
|
|
87
|
+
}
|
|
88
|
+
return type;
|
|
89
|
+
}
|
|
90
|
+
getTemplate() {
|
|
91
|
+
return `// This file is auto-generated by the Appwrite CLI.
|
|
92
|
+
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
93
|
+
<% const __relatedImportsSeen = new Set();
|
|
94
|
+
const sortedAttributes = collection.attributes.slice().sort((a, b) => {
|
|
95
|
+
if (a.required === b.required) return 0;
|
|
96
|
+
return a.required ? -1 : 1;
|
|
97
|
+
}); -%>
|
|
98
|
+
<% const __attrs = sortedAttributes; -%>
|
|
99
|
+
<% for (const attribute of __attrs) { -%>
|
|
100
|
+
<% if (attribute.type === '${attribute_1.AttributeType.RELATIONSHIP}') { -%>
|
|
101
|
+
<% const related = collections.find(c => c.$id === attribute.relatedCollection); -%>
|
|
102
|
+
<% if (related && !__relatedImportsSeen.has(toSnakeCase(related.name))) { -%>
|
|
103
|
+
import '<%- toSnakeCase(related.name) %>.dart';
|
|
104
|
+
<% __relatedImportsSeen.add(toSnakeCase(related.name)); -%>
|
|
105
|
+
<% } -%>
|
|
106
|
+
<% } -%>
|
|
107
|
+
<% } -%>
|
|
108
|
+
|
|
109
|
+
<% for (const attribute of __attrs) { -%>
|
|
110
|
+
<% if (attribute.format === '${attribute_1.AttributeType.ENUM}') { -%>
|
|
111
|
+
enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> {
|
|
112
|
+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
|
|
113
|
+
<%- strict ? toCamelCase(element) : element %><% if (index < attribute.elements.length - 1) { -%>,<% } %>
|
|
114
|
+
<% } -%>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
<% } -%>
|
|
118
|
+
<% } -%>
|
|
119
|
+
class <%= toPascalCase(collection.name) %> {
|
|
120
|
+
<% for (const [index, attribute] of Object.entries(__attrs)) { -%>
|
|
121
|
+
<%- getType(attribute, collections, collection.name) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
122
|
+
<% } -%>
|
|
123
|
+
|
|
124
|
+
<%= toPascalCase(collection.name) %>({
|
|
125
|
+
<% for (const [index, attribute] of Object.entries(__attrs)) { -%>
|
|
126
|
+
<% if (attribute.required) { %>required <% } %>this.<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (index < __attrs.length - 1) { -%>,<% } %>
|
|
127
|
+
<% } -%>
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
factory <%= toPascalCase(collection.name) %>.fromMap(Map<String, dynamic> map) {
|
|
131
|
+
return <%= toPascalCase(collection.name) %>(
|
|
132
|
+
<% for (const [index, attribute] of Object.entries(__attrs)) { -%>
|
|
133
|
+
<%= strict ? toCamelCase(attribute.key) : attribute.key %>: <% if (attribute.type === '${attribute_1.AttributeType.STRING}' || attribute.type === '${attribute_1.AttributeType.EMAIL}' || attribute.type === '${attribute_1.AttributeType.DATETIME}') { -%>
|
|
134
|
+
<% if (attribute.format === '${attribute_1.AttributeType.ENUM}') { -%>
|
|
135
|
+
<% if (attribute.array) { -%>
|
|
136
|
+
(map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% } else { -%>
|
|
137
|
+
<% if (!attribute.required) { -%>
|
|
138
|
+
map['<%= attribute.key %>'] != null ? <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.where((e) => e.name == map['<%= attribute.key %>']).firstOrNull : null<% } else { -%>
|
|
139
|
+
<%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.firstWhere((e) => e.name == map['<%= attribute.key %>'])<% } -%>
|
|
140
|
+
<% } -%>
|
|
141
|
+
<% } else { -%>
|
|
142
|
+
<% if (attribute.array) { -%>
|
|
143
|
+
List<String>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
|
|
144
|
+
map['<%= attribute.key %>']<% if (!attribute.required) { %>?<% } %>.toString()<% } -%>
|
|
145
|
+
<% } -%>
|
|
146
|
+
<% } else if (attribute.type === '${attribute_1.AttributeType.INTEGER}') { -%>
|
|
147
|
+
<% if (attribute.array) { -%>
|
|
148
|
+
List<int>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
|
|
149
|
+
map['<%= attribute.key %>']<% } -%>
|
|
150
|
+
<% } else if (attribute.type === '${attribute_1.AttributeType.FLOAT}') { -%>
|
|
151
|
+
<% if (attribute.array) { -%>
|
|
152
|
+
List<double>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
|
|
153
|
+
map['<%= attribute.key %>']<% } -%>
|
|
154
|
+
<% } else if (attribute.type === '${attribute_1.AttributeType.BOOLEAN}') { -%>
|
|
155
|
+
<% if (attribute.array) { -%>
|
|
156
|
+
List<bool>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
|
|
157
|
+
map['<%= attribute.key %>']<% } -%>
|
|
158
|
+
<% } else if (attribute.type === '${attribute_1.AttributeType.RELATIONSHIP}') { -%>
|
|
159
|
+
<% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
|
|
160
|
+
(map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(e)).toList()
|
|
161
|
+
<% } else { -%>
|
|
162
|
+
<% if (!attribute.required) { -%>
|
|
163
|
+
map['<%= attribute.key %>'] != null ? <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(map['<%= attribute.key %>']) : null<% } else { -%>
|
|
164
|
+
<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(map['<%= attribute.key %>'])<% } -%>
|
|
165
|
+
<% } -%>
|
|
166
|
+
<% } -%><% if (index < __attrs.length - 1) { -%>,<% } %>
|
|
167
|
+
<% } -%>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Map<String, dynamic> toMap() {
|
|
172
|
+
return {
|
|
173
|
+
<% for (const [index, attribute] of Object.entries(__attrs)) { -%>
|
|
174
|
+
'<%= attribute.key %>': <% if (attribute.type === '${attribute_1.AttributeType.RELATIONSHIP}') { -%>
|
|
175
|
+
<% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
|
|
176
|
+
<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()
|
|
177
|
+
<% } else { -%>
|
|
178
|
+
<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.toMap()<% } -%>
|
|
179
|
+
<% } else if (attribute.format === '${attribute_1.AttributeType.ENUM}') { -%>
|
|
180
|
+
<% if (attribute.array) { -%>
|
|
181
|
+
<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% } else { -%>
|
|
182
|
+
<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.name<% } -%>
|
|
183
|
+
<% } else { -%>
|
|
184
|
+
<%= strict ? toCamelCase(attribute.key) : attribute.key -%>
|
|
185
|
+
<% } -%><% if (index < __attrs.length - 1) { -%>,<% } %>
|
|
186
|
+
<% } -%>
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
192
|
+
getFileName(collection) {
|
|
193
|
+
return language_1.LanguageMeta.toSnakeCase(collection.name) + '.dart';
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.Dart = Dart;
|
|
197
|
+
//# sourceMappingURL=dart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dart.js","sourceRoot":"","sources":["../../../../lib/type-generation/languages/dart.ts"],"names":[],"mappings":";;;AAAA,yBAA0B;AAC1B,6BAA8B;AAC9B,4CAA6C;AAC7C,yCAAiE;AAEjE,MAAa,IAAK,SAAQ,uBAAY;IAClC,cAAc;QACV,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QAC7D,IAAI,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;oCAInB,yBAAa,CAAC,OAAO;;;;oCAIrB,yBAAa,CAAC,YAAY;;;;;;;;;;;;;;;;uDAgBP,yBAAa,CAAC,YAAY;;;;;sCAK3C,yBAAa,CAAC,IAAI;;;;;;;;;;;CAWvD,CAAC;IACE,CAAC;IAED,WAAW,CAAC,UAAsB;QAC9B,OAAO,uBAAY,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAC/D,CAAC;CACJ;AArMD,oBAqMC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LanguageMeta, Attribute, Collection } from './language';
|
|
2
|
+
export declare class Java extends LanguageMeta {
|
|
3
|
+
getType(attribute: Attribute, collections?: Collection[], collectionName?: string): string;
|
|
4
|
+
getTemplate(): string;
|
|
5
|
+
getFileName(collection: Collection): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=java.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../../lib/type-generation/languages/java.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE,qBAAa,IAAK,SAAQ,YAAY;IAClC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM;IAoD1F,WAAW,IAAI,MAAM;IAgFrB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;CAG9C"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Java = void 0;
|
|
4
|
+
const attribute_1 = require("../attribute");
|
|
5
|
+
const language_1 = require("./language");
|
|
6
|
+
class Java extends language_1.LanguageMeta {
|
|
7
|
+
getType(attribute, collections, collectionName) {
|
|
8
|
+
let type = '';
|
|
9
|
+
switch (attribute.type) {
|
|
10
|
+
case attribute_1.AttributeType.STRING:
|
|
11
|
+
case attribute_1.AttributeType.EMAIL:
|
|
12
|
+
case attribute_1.AttributeType.DATETIME:
|
|
13
|
+
type = 'String';
|
|
14
|
+
if (attribute.format === attribute_1.AttributeType.ENUM) {
|
|
15
|
+
type = language_1.LanguageMeta.toPascalCase(collectionName) + language_1.LanguageMeta.toPascalCase(attribute.key);
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case attribute_1.AttributeType.INTEGER:
|
|
19
|
+
type = 'Integer';
|
|
20
|
+
break;
|
|
21
|
+
case attribute_1.AttributeType.FLOAT:
|
|
22
|
+
type = 'Double';
|
|
23
|
+
break;
|
|
24
|
+
case attribute_1.AttributeType.BOOLEAN:
|
|
25
|
+
type = 'Boolean';
|
|
26
|
+
break;
|
|
27
|
+
case attribute_1.AttributeType.RELATIONSHIP:
|
|
28
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
29
|
+
if (!relatedCollection) {
|
|
30
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
31
|
+
}
|
|
32
|
+
type = language_1.LanguageMeta.toPascalCase(relatedCollection.name);
|
|
33
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
34
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
35
|
+
attribute.relationType === 'manyToMany') {
|
|
36
|
+
type = 'List<' + type + '>';
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case attribute_1.AttributeType.POINT:
|
|
40
|
+
type = 'List<Double>';
|
|
41
|
+
break;
|
|
42
|
+
case attribute_1.AttributeType.LINESTRING:
|
|
43
|
+
type = 'List<List<Double>>';
|
|
44
|
+
break;
|
|
45
|
+
case attribute_1.AttributeType.POLYGON:
|
|
46
|
+
type = 'List<List<List<Double>>>';
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
50
|
+
}
|
|
51
|
+
if (attribute.array) {
|
|
52
|
+
type = 'List<' + type + '>';
|
|
53
|
+
}
|
|
54
|
+
return type;
|
|
55
|
+
}
|
|
56
|
+
getTemplate() {
|
|
57
|
+
return `package io.appwrite.models;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This file is auto-generated by the Appwrite CLI.
|
|
61
|
+
* You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
import java.util.Objects;
|
|
65
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
66
|
+
<% if (attribute.type === 'relationship') { -%>
|
|
67
|
+
import io.appwrite.models.<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>;
|
|
68
|
+
<% } -%>
|
|
69
|
+
<% } -%>
|
|
70
|
+
|
|
71
|
+
public class <%- toPascalCase(collection.name) %> {
|
|
72
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
73
|
+
<% if (attribute.format === 'enum') { -%>
|
|
74
|
+
|
|
75
|
+
public enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> {
|
|
76
|
+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
|
|
77
|
+
<%- strict ? toUpperSnakeCase(element) : element %><%- index < attribute.elements.length - 1 ? ',' : ';' %>
|
|
78
|
+
<% } -%>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
<% } -%>
|
|
82
|
+
<% } -%>
|
|
83
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
84
|
+
private <%- getType(attribute, collections, collection.name) %> <%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
85
|
+
<% } -%>
|
|
86
|
+
|
|
87
|
+
public <%- toPascalCase(collection.name) %>() {
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public <%- toPascalCase(collection.name) %>(
|
|
91
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
92
|
+
<%- getType(attribute, collections, collection.name) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %>
|
|
93
|
+
<% } -%>
|
|
94
|
+
) {
|
|
95
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
96
|
+
this.<%= strict ? toCamelCase(attribute.key) : attribute.key %> = <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
97
|
+
<% } -%>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
101
|
+
public <%- getType(attribute, collections, collection.name) %> get<%- toPascalCase(attribute.key) %>() {
|
|
102
|
+
return <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections, collection.name) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>) {
|
|
106
|
+
this.<%= strict ? toCamelCase(attribute.key) : attribute.key %> = <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
<% } -%>
|
|
110
|
+
@Override
|
|
111
|
+
public boolean equals(Object obj) {
|
|
112
|
+
if (this == obj) return true;
|
|
113
|
+
if (obj == null || getClass() != obj.getClass()) return false;
|
|
114
|
+
<%- toPascalCase(collection.name) %> that = (<%- toPascalCase(collection.name) %>) obj;
|
|
115
|
+
return <% collection.attributes.forEach((attr, index) => { %>Objects.equals(<%= toCamelCase(attr.key) %>, that.<%= toCamelCase(attr.key) %>)<% if (index < collection.attributes.length - 1) { %> &&
|
|
116
|
+
<% } }); %>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Override
|
|
120
|
+
public int hashCode() {
|
|
121
|
+
return Objects.hash(<%= collection.attributes.map(attr => toCamelCase(attr.key)).join(', ') %>);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@Override
|
|
125
|
+
public String toString() {
|
|
126
|
+
return "<%- toPascalCase(collection.name) %>{" +
|
|
127
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
128
|
+
"<%= strict ? toCamelCase(attribute.key) : attribute.key %>=" + <%= strict ? toCamelCase(attribute.key) : attribute.key %> +<% if (index < collection.attributes.length - 1) { %> ", " +<% } %>
|
|
129
|
+
<% } -%>
|
|
130
|
+
'}';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
getFileName(collection) {
|
|
136
|
+
return language_1.LanguageMeta.toPascalCase(collection.name) + '.java';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.Java = Java;
|
|
140
|
+
//# sourceMappingURL=java.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java.js","sourceRoot":"","sources":["../../../../lib/type-generation/languages/java.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,yCAAiE;AAEjE,MAAa,IAAK,SAAQ,uBAAY;IAClC,OAAO,CAAC,SAAoB,EAAE,WAA0B,EAAE,cAAuB;QAC7E,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,yBAAa,CAAC,MAAM,CAAC;YAC1B,KAAK,yBAAa,CAAC,KAAK,CAAC;YACzB,KAAK,yBAAa,CAAC,QAAQ;gBACvB,IAAI,GAAG,QAAQ,CAAC;gBAChB,IAAI,SAAS,CAAC,MAAM,KAAK,yBAAa,CAAC,IAAI,EAAE,CAAC;oBAC1C,IAAI,GAAG,uBAAY,CAAC,YAAY,CAAC,cAAe,CAAC,GAAG,uBAAY,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACjG,CAAC;gBACD,MAAM;YACV,KAAK,yBAAa,CAAC,OAAO;gBACtB,IAAI,GAAG,SAAS,CAAC;gBACjB,MAAM;YACV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AG,GAAG,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW;QACP,OAAO;;;;iDAIkC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwE/E,CAAC;IACE,CAAC;IAED,WAAW,CAAC,UAAsB;QAC9B,OAAO,uBAAY,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAChE,CAAC;CACJ;AAxID,oBAwIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LanguageMeta, Attribute, Collection } from './language';
|
|
2
|
+
export declare class JavaScript extends LanguageMeta {
|
|
3
|
+
getType(attribute: Attribute, collections?: Collection[]): string;
|
|
4
|
+
isSingleFile(): boolean;
|
|
5
|
+
private _getAppwriteDependency;
|
|
6
|
+
getTemplate(): string;
|
|
7
|
+
getFileName(_: Collection | undefined): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=javascript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../../../lib/type-generation/languages/javascript.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE,qBAAa,UAAW,SAAQ,YAAY;IACxC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,MAAM;IAyDjE,YAAY,IAAI,OAAO;IAIvB,OAAO,CAAC,sBAAsB;IAU9B,WAAW,IAAI,MAAM;IA8BrB,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM;CAGjD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JavaScript = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const attribute_1 = require("../attribute");
|
|
7
|
+
const language_1 = require("./language");
|
|
8
|
+
class JavaScript extends language_1.LanguageMeta {
|
|
9
|
+
getType(attribute, collections) {
|
|
10
|
+
let type = '';
|
|
11
|
+
switch (attribute.type) {
|
|
12
|
+
case attribute_1.AttributeType.STRING:
|
|
13
|
+
case attribute_1.AttributeType.EMAIL:
|
|
14
|
+
case attribute_1.AttributeType.DATETIME:
|
|
15
|
+
case attribute_1.AttributeType.IP:
|
|
16
|
+
case attribute_1.AttributeType.URL:
|
|
17
|
+
type = 'string';
|
|
18
|
+
if (attribute.format === attribute_1.AttributeType.ENUM) {
|
|
19
|
+
type = language_1.LanguageMeta.toPascalCase(attribute.key);
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
case attribute_1.AttributeType.INTEGER:
|
|
23
|
+
type = 'number';
|
|
24
|
+
break;
|
|
25
|
+
case attribute_1.AttributeType.FLOAT:
|
|
26
|
+
type = 'number';
|
|
27
|
+
break;
|
|
28
|
+
case attribute_1.AttributeType.BOOLEAN:
|
|
29
|
+
type = 'boolean';
|
|
30
|
+
break;
|
|
31
|
+
case attribute_1.AttributeType.RELATIONSHIP:
|
|
32
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
33
|
+
if (!relatedCollection) {
|
|
34
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
35
|
+
}
|
|
36
|
+
type = language_1.LanguageMeta.toPascalCase(relatedCollection.name);
|
|
37
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
38
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
39
|
+
attribute.relationType === 'manyToMany') {
|
|
40
|
+
type = `${type}[]`;
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case attribute_1.AttributeType.POINT:
|
|
44
|
+
type = 'number[]';
|
|
45
|
+
break;
|
|
46
|
+
case attribute_1.AttributeType.LINESTRING:
|
|
47
|
+
type = 'number[][]';
|
|
48
|
+
break;
|
|
49
|
+
case attribute_1.AttributeType.POLYGON:
|
|
50
|
+
type = 'number[][][]';
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
54
|
+
}
|
|
55
|
+
if (attribute.array) {
|
|
56
|
+
type += '[]';
|
|
57
|
+
}
|
|
58
|
+
if (!attribute.required && attribute.default === null) {
|
|
59
|
+
type += ' | null';
|
|
60
|
+
}
|
|
61
|
+
return type;
|
|
62
|
+
}
|
|
63
|
+
isSingleFile() {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
_getAppwriteDependency() {
|
|
67
|
+
if (fs.existsSync(path.resolve(process.cwd(), 'package.json'))) {
|
|
68
|
+
const packageJsonRaw = fs.readFileSync(path.resolve(process.cwd(), 'package.json'));
|
|
69
|
+
const packageJson = JSON.parse(packageJsonRaw.toString('utf-8'));
|
|
70
|
+
return packageJson.dependencies && packageJson.dependencies['node-appwrite'] ? 'node-appwrite' : 'appwrite';
|
|
71
|
+
}
|
|
72
|
+
return 'appwrite';
|
|
73
|
+
}
|
|
74
|
+
getTemplate() {
|
|
75
|
+
return `/**
|
|
76
|
+
* @typedef {import('${this._getAppwriteDependency()}').Models.Row} Row
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
// This file is auto-generated by the Appwrite CLI.
|
|
80
|
+
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
81
|
+
|
|
82
|
+
<% for (const collection of collections) { -%>
|
|
83
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
84
|
+
<% if (attribute.format === 'enum') { -%>
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {"<%- attribute.elements.join('"|"') %>"} <%- toPascalCase(attribute.key) %>
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
<% } -%>
|
|
90
|
+
<% } -%>
|
|
91
|
+
<% } -%>
|
|
92
|
+
<% for (const [index, collection] of Object.entries(collections)) { %>/**
|
|
93
|
+
* @typedef {Row & {
|
|
94
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
95
|
+
* <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
|
|
96
|
+
<% } -%>
|
|
97
|
+
* }} <%- toPascalCase(collection.name) %>
|
|
98
|
+
*/
|
|
99
|
+
<% if (index < collections.length - 1) { %>
|
|
100
|
+
<% } -%>
|
|
101
|
+
<% } %>`;
|
|
102
|
+
}
|
|
103
|
+
getFileName(_) {
|
|
104
|
+
return 'appwrite-types.js';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.JavaScript = JavaScript;
|
|
108
|
+
//# sourceMappingURL=javascript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../../lib/type-generation/languages/javascript.ts"],"names":[],"mappings":";;;AAAA,yBAA0B;AAC1B,6BAA8B;AAC9B,4CAA6C;AAC7C,yCAAiE;AAEjE,MAAa,UAAW,SAAQ,uBAAY;IACxC,OAAO,CAAC,SAAoB,EAAE,WAA0B;QACpD,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,yBAAa,CAAC,MAAM,CAAC;YAC1B,KAAK,yBAAa,CAAC,KAAK,CAAC;YACzB,KAAK,yBAAa,CAAC,QAAQ,CAAC;YAC5B,KAAK,yBAAa,CAAC,EAAE,CAAC;YACtB,KAAK,yBAAa,CAAC,GAAG;gBAClB,IAAI,GAAG,QAAQ,CAAC;gBAChB,IAAI,SAAS,CAAC,MAAM,KAAK,yBAAa,CAAC,IAAI,EAAE,CAAC;oBAC1C,IAAI,GAA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from './language';
|
|
2
|
+
export declare class Kotlin extends LanguageMeta {
|
|
3
|
+
getType(attribute: Attribute, collections?: Collection[], collectionName?: string): string;
|
|
4
|
+
getTemplate(): string;
|
|
5
|
+
getFileName(collection: Collection): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=kotlin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin.d.ts","sourceRoot":"","sources":["../../../../lib/type-generation/languages/kotlin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE,qBAAa,MAAO,SAAQ,YAAY;IACpC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM;IAuD1F,WAAW,IAAI,MAAM;IAgCrB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;CAG9C"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Kotlin = void 0;
|
|
4
|
+
const attribute_1 = require("../attribute");
|
|
5
|
+
const language_1 = require("./language");
|
|
6
|
+
class Kotlin extends language_1.LanguageMeta {
|
|
7
|
+
getType(attribute, collections, collectionName) {
|
|
8
|
+
let type = '';
|
|
9
|
+
switch (attribute.type) {
|
|
10
|
+
case attribute_1.AttributeType.STRING:
|
|
11
|
+
case attribute_1.AttributeType.EMAIL:
|
|
12
|
+
case attribute_1.AttributeType.DATETIME:
|
|
13
|
+
type = 'String';
|
|
14
|
+
if (attribute.format === attribute_1.AttributeType.ENUM) {
|
|
15
|
+
type = language_1.LanguageMeta.toPascalCase(collectionName) + language_1.LanguageMeta.toPascalCase(attribute.key);
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case attribute_1.AttributeType.INTEGER:
|
|
19
|
+
type = 'Int';
|
|
20
|
+
break;
|
|
21
|
+
case attribute_1.AttributeType.FLOAT:
|
|
22
|
+
type = 'Float';
|
|
23
|
+
break;
|
|
24
|
+
case attribute_1.AttributeType.BOOLEAN:
|
|
25
|
+
type = 'Boolean';
|
|
26
|
+
break;
|
|
27
|
+
case attribute_1.AttributeType.RELATIONSHIP:
|
|
28
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
29
|
+
if (!relatedCollection) {
|
|
30
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
31
|
+
}
|
|
32
|
+
type = language_1.LanguageMeta.toPascalCase(relatedCollection.name);
|
|
33
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
34
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
35
|
+
attribute.relationType === 'manyToMany') {
|
|
36
|
+
type = `List<${type}>`;
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case attribute_1.AttributeType.POINT:
|
|
40
|
+
type = 'List<Double>';
|
|
41
|
+
break;
|
|
42
|
+
case attribute_1.AttributeType.LINESTRING:
|
|
43
|
+
type = 'List<List<Double>>';
|
|
44
|
+
break;
|
|
45
|
+
case attribute_1.AttributeType.POLYGON:
|
|
46
|
+
type = 'List<List<List<Double>>>';
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
50
|
+
}
|
|
51
|
+
if (attribute.array) {
|
|
52
|
+
type = 'List<' + type + '>';
|
|
53
|
+
}
|
|
54
|
+
if (!attribute.required && attribute.default === null) {
|
|
55
|
+
type += '?';
|
|
56
|
+
}
|
|
57
|
+
return type;
|
|
58
|
+
}
|
|
59
|
+
getTemplate() {
|
|
60
|
+
return `package io.appwrite.models
|
|
61
|
+
|
|
62
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
63
|
+
<% if (attribute.type === 'relationship') { -%>
|
|
64
|
+
import <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>
|
|
65
|
+
|
|
66
|
+
<% } -%>
|
|
67
|
+
<% } -%>
|
|
68
|
+
/**
|
|
69
|
+
* This file is auto-generated by the Appwrite CLI.
|
|
70
|
+
* You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
74
|
+
<% if (attribute.format === 'enum') { -%>
|
|
75
|
+
enum class <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> {
|
|
76
|
+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
|
|
77
|
+
<%- strict ? toUpperSnakeCase(element) : element %><%- index < attribute.elements.length - 1 ? ',' : '' %>
|
|
78
|
+
<% } -%>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
<% } -%>
|
|
82
|
+
<% } -%>
|
|
83
|
+
data class <%- toPascalCase(collection.name) %>(
|
|
84
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
85
|
+
val <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections, collection.name) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
86
|
+
<% } -%>
|
|
87
|
+
)
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
getFileName(collection) {
|
|
91
|
+
return language_1.LanguageMeta.toPascalCase(collection.name) + '.kt';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.Kotlin = Kotlin;
|
|
95
|
+
//# sourceMappingURL=kotlin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin.js","sourceRoot":"","sources":["../../../../lib/type-generation/languages/kotlin.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,yCAAiE;AAEjE,MAAa,MAAO,SAAQ,uBAAY;IACpC,OAAO,CAAC,SAAoB,EAAE,WAA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E,SAAS,CAAC,YAAY,KAAK,YAAY,EACzC,CAAC;oBACC,IAAI,GAAG,QAAQ,IAAI,GAAG,CAAC;gBAC3B,CAAC;gBACD,MAAM;YACV,KAAK,yBAAa,CAAC,KAAK;gBACpB,IAAI,GAAG,cAAc,CAAC;gBACtB,MAAM;YACV,KAAK,yBAAa,CAAC,UAAU;gBACzB,IAAI,GAAG,oBAAoB,CAAC;gBAC5B,MAAM;YACV,KAAK,yBAAa,CAAC,OAAO;gBACtB,IAAI,GAAG,0BAA0B,CAAC;gBAClC,MAAM;YACV;gBACI,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACpD,IAAI,IAAI,GAAG,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW;QACP,OAAO;;;;;;;;;;iDAUkC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;CAkB/E,CAAC;IACE,CAAC;IAED,WAAW,CAAC,UAAsB;QAC9B,OAAO,uBAAY,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC9D,CAAC;CACJ;AA3FD,wBA2FC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface Attribute {
|
|
2
|
+
key: string;
|
|
3
|
+
type: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
array?: boolean;
|
|
6
|
+
default?: any;
|
|
7
|
+
format?: string;
|
|
8
|
+
elements?: string[];
|
|
9
|
+
relatedCollection?: string;
|
|
10
|
+
relationType?: string;
|
|
11
|
+
side?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Collection {
|
|
14
|
+
$id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
attributes: Attribute[];
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class LanguageMeta {
|
|
19
|
+
constructor();
|
|
20
|
+
static toKebabCase(string: string): string;
|
|
21
|
+
static toSnakeCase(string: string): string;
|
|
22
|
+
static toUpperSnakeCase(string: string): string;
|
|
23
|
+
static toCamelCase(string: string): string;
|
|
24
|
+
static toPascalCase(string: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Get the type literal of the given attribute.
|
|
27
|
+
*/
|
|
28
|
+
abstract getType(attribute: Attribute, collections?: Collection[], collectionName?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the language uses a single file for all types.
|
|
31
|
+
*/
|
|
32
|
+
isSingleFile(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Get the EJS template used to generate the types for this language.
|
|
35
|
+
*/
|
|
36
|
+
abstract getTemplate(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the file extension used by files of this language.
|
|
39
|
+
*/
|
|
40
|
+
abstract getFileName(collection?: Collection): string;
|
|
41
|
+
}
|
|
42
|
+
export declare function detectLanguage(): string;
|
|
43
|
+
//# sourceMappingURL=language.d.ts.map
|