appwrite-cli 9.0.2 → 10.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/CHANGELOG.md +9 -0
- package/README.md +2 -2
- package/docs/examples/databases/create-line-attribute.md +5 -0
- package/docs/examples/databases/create-point-attribute.md +5 -0
- package/docs/examples/databases/create-polygon-attribute.md +5 -0
- package/docs/examples/databases/update-line-attribute.md +5 -0
- package/docs/examples/databases/update-point-attribute.md +5 -0
- package/docs/examples/databases/update-polygon-attribute.md +5 -0
- package/docs/examples/tablesdb/create-line-column.md +5 -0
- package/docs/examples/tablesdb/create-point-column.md +5 -0
- package/docs/examples/tablesdb/create-polygon-column.md +5 -0
- package/docs/examples/tablesdb/update-line-column.md +5 -0
- package/docs/examples/tablesdb/update-point-column.md +5 -0
- package/docs/examples/tablesdb/update-polygon-column.md +5 -0
- package/index.js +0 -2
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/databases.js +336 -0
- package/lib/commands/functions.js +2 -2
- package/lib/commands/generic.js +5 -5
- package/lib/commands/init.js +3 -1
- package/lib/commands/pull.js +24 -12
- package/lib/commands/push.js +27 -9
- package/lib/commands/tables-db.js +338 -2
- package/lib/commands/types.js +54 -15
- package/lib/config.js +57 -33
- package/lib/parser.js +5 -2
- package/lib/questions.js +6 -6
- package/lib/type-generation/languages/csharp.js +170 -0
- package/lib/type-generation/languages/javascript.js +2 -2
- package/lib/type-generation/languages/typescript.js +4 -2
- package/package.json +1 -1
- package/scoop/appwrite.config.json +3 -3
- package/docs/examples/avatars/get-browser.md +0 -2
- package/docs/examples/avatars/get-credit-card.md +0 -2
- package/docs/examples/avatars/get-favicon.md +0 -2
- package/docs/examples/avatars/get-flag.md +0 -2
- package/docs/examples/avatars/get-image.md +0 -2
- package/docs/examples/avatars/get-initials.md +0 -1
- package/docs/examples/avatars/get-qr.md +0 -2
- package/lib/commands/avatars.js +0 -484
package/lib/commands/pull.js
CHANGED
|
@@ -16,7 +16,9 @@ const { paginate } = require("../paginate");
|
|
|
16
16
|
const { questionsPullCollection, questionsPullFunctions, questionsPullFunctionsCode, questionsPullSites, questionsPullSitesCode, questionsPullResources } = require("../questions");
|
|
17
17
|
const { cliConfig, success, log, warn, actionRunner, commandDescriptions } = require("../parser");
|
|
18
18
|
|
|
19
|
-
const pullResources = async (
|
|
19
|
+
const pullResources = async ({
|
|
20
|
+
skipDeprecated = false
|
|
21
|
+
} = {}) => {
|
|
20
22
|
const actions = {
|
|
21
23
|
settings: pullSettings,
|
|
22
24
|
functions: pullFunctions,
|
|
@@ -28,6 +30,10 @@ const pullResources = async () => {
|
|
|
28
30
|
messages: pullMessagingTopic
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
if (skipDeprecated) {
|
|
34
|
+
delete actions.collections;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
if (cliConfig.all) {
|
|
32
38
|
for (let action of Object.values(actions)) {
|
|
33
39
|
cliConfig.all = true;
|
|
@@ -289,7 +295,8 @@ const pullSites = async ({ code, withVariables }) => {
|
|
|
289
295
|
const pullCollection = async () => {
|
|
290
296
|
warn("appwrite pull collection has been deprecated. Please consider using 'appwrite pull tables' instead");
|
|
291
297
|
log("Fetching collections ...");
|
|
292
|
-
let
|
|
298
|
+
let totalDatabases = 0;
|
|
299
|
+
let totalCollections = 0;
|
|
293
300
|
|
|
294
301
|
const fetchResponse = await databasesList({
|
|
295
302
|
queries: [JSON.stringify({ method: 'limit', values: [1] })],
|
|
@@ -297,7 +304,7 @@ const pullCollection = async () => {
|
|
|
297
304
|
});
|
|
298
305
|
if (fetchResponse["databases"].length <= 0) {
|
|
299
306
|
log("No collections found.");
|
|
300
|
-
success(`Successfully pulled ${chalk.bold(
|
|
307
|
+
success(`Successfully pulled ${chalk.bold(totalCollections)} collections from ${chalk.bold(totalDatabases)} databases.`);
|
|
301
308
|
return;
|
|
302
309
|
}
|
|
303
310
|
|
|
@@ -317,7 +324,7 @@ const pullCollection = async () => {
|
|
|
317
324
|
parseOutput: false
|
|
318
325
|
});
|
|
319
326
|
|
|
320
|
-
|
|
327
|
+
totalDatabases++;
|
|
321
328
|
log(`Pulling all collections from ${chalk.bold(database['name'])} database ...`);
|
|
322
329
|
|
|
323
330
|
localConfig.addDatabase(database);
|
|
@@ -328,6 +335,7 @@ const pullCollection = async () => {
|
|
|
328
335
|
}, 100, 'collections');
|
|
329
336
|
|
|
330
337
|
for (const collection of collections) {
|
|
338
|
+
totalCollections++;
|
|
331
339
|
localConfig.addCollection({
|
|
332
340
|
...collection,
|
|
333
341
|
'$createdAt': undefined,
|
|
@@ -336,12 +344,13 @@ const pullCollection = async () => {
|
|
|
336
344
|
}
|
|
337
345
|
}
|
|
338
346
|
|
|
339
|
-
success(`Successfully pulled ${chalk.bold(
|
|
347
|
+
success(`Successfully pulled ${chalk.bold(totalCollections)} collections from ${chalk.bold(totalDatabases)} databases.`);
|
|
340
348
|
}
|
|
341
349
|
|
|
342
350
|
const pullTable = async () => {
|
|
343
351
|
log("Fetching tables ...");
|
|
344
|
-
let
|
|
352
|
+
let totalTablesDBs = 0;
|
|
353
|
+
let totalTables = 0;
|
|
345
354
|
|
|
346
355
|
const fetchResponse = await tablesDBList({
|
|
347
356
|
queries: [JSON.stringify({ method: 'limit', values: [1] })],
|
|
@@ -349,7 +358,7 @@ const pullTable = async () => {
|
|
|
349
358
|
});
|
|
350
359
|
if (fetchResponse["databases"].length <= 0) {
|
|
351
360
|
log("No tables found.");
|
|
352
|
-
success(`Successfully pulled ${chalk.bold(
|
|
361
|
+
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tables databases.`);
|
|
353
362
|
return;
|
|
354
363
|
}
|
|
355
364
|
|
|
@@ -369,10 +378,10 @@ const pullTable = async () => {
|
|
|
369
378
|
parseOutput: false
|
|
370
379
|
});
|
|
371
380
|
|
|
372
|
-
|
|
381
|
+
totalTablesDBs++;
|
|
373
382
|
log(`Pulling all tables from ${chalk.bold(database['name'])} database ...`);
|
|
374
383
|
|
|
375
|
-
localConfig.
|
|
384
|
+
localConfig.addTablesDB(database);
|
|
376
385
|
|
|
377
386
|
const { tables } = await paginate(tablesDBListTables, {
|
|
378
387
|
databaseId,
|
|
@@ -380,6 +389,7 @@ const pullTable = async () => {
|
|
|
380
389
|
}, 100, 'tables');
|
|
381
390
|
|
|
382
391
|
for (const table of tables) {
|
|
392
|
+
totalTables++;
|
|
383
393
|
localConfig.addTable({
|
|
384
394
|
...table,
|
|
385
395
|
'$createdAt': undefined,
|
|
@@ -388,7 +398,7 @@ const pullTable = async () => {
|
|
|
388
398
|
}
|
|
389
399
|
}
|
|
390
400
|
|
|
391
|
-
success(`Successfully pulled ${chalk.bold(
|
|
401
|
+
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tables databases.`);
|
|
392
402
|
}
|
|
393
403
|
|
|
394
404
|
const pullBucket = async () => {
|
|
@@ -468,14 +478,16 @@ const pullMessagingTopic = async () => {
|
|
|
468
478
|
|
|
469
479
|
const pull = new Command("pull")
|
|
470
480
|
.description(commandDescriptions['pull'])
|
|
471
|
-
.action(actionRunner(pullResources));
|
|
481
|
+
.action(actionRunner(() => pullResources({ skipDeprecated: true })));
|
|
472
482
|
|
|
473
483
|
pull
|
|
474
484
|
.command("all")
|
|
475
485
|
.description("Pull all resource.")
|
|
476
486
|
.action(actionRunner(() => {
|
|
477
487
|
cliConfig.all = true;
|
|
478
|
-
return pullResources(
|
|
488
|
+
return pullResources({
|
|
489
|
+
skipDeprecated: true
|
|
490
|
+
});
|
|
479
491
|
}));
|
|
480
492
|
|
|
481
493
|
pull
|
package/lib/commands/push.js
CHANGED
|
@@ -51,7 +51,9 @@ const {
|
|
|
51
51
|
} = require("./databases");
|
|
52
52
|
const {
|
|
53
53
|
tablesDBGet,
|
|
54
|
-
tablesDBGetTable
|
|
54
|
+
tablesDBGetTable,
|
|
55
|
+
tablesDBUpdateTable,
|
|
56
|
+
tablesDBCreateTable
|
|
55
57
|
} = require("./tables-db");
|
|
56
58
|
const {
|
|
57
59
|
storageGetBucket, storageUpdateBucket, storageCreateBucket
|
|
@@ -892,7 +894,7 @@ const createIndexes = async (indexes, collection) => {
|
|
|
892
894
|
);
|
|
893
895
|
|
|
894
896
|
if (!result) {
|
|
895
|
-
throw new Error(
|
|
897
|
+
throw new Error('Index creation timed out.');
|
|
896
898
|
}
|
|
897
899
|
|
|
898
900
|
success(`Created ${indexes.length} indexes`);
|
|
@@ -916,6 +918,25 @@ const createAttributes = async (attributes, collection) => {
|
|
|
916
918
|
|
|
917
919
|
success(`Created ${attributes.length} attributes`);
|
|
918
920
|
}
|
|
921
|
+
const createColumns = async (columns, table) => {
|
|
922
|
+
for (let column of columns) {
|
|
923
|
+
if (column.side !== 'child') {
|
|
924
|
+
await createAttribute(table['databaseId'], table['$id'], column);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
const result = await awaitPools.expectAttributes(
|
|
929
|
+
table['databaseId'],
|
|
930
|
+
table['$id'],
|
|
931
|
+
table.columns.filter(column => column.side !== 'child').map(column => column.key)
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
if (!result) {
|
|
935
|
+
throw new Error(`Column creation timed out.`);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
success(`Created ${columns.length} columns`);
|
|
939
|
+
}
|
|
919
940
|
|
|
920
941
|
const pushResources = async () => {
|
|
921
942
|
const actions = {
|
|
@@ -1711,7 +1732,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1711
1732
|
|
|
1712
1733
|
// Parallel db actions
|
|
1713
1734
|
await Promise.all(databases.map(async (databaseId) => {
|
|
1714
|
-
const localDatabase = localConfig.
|
|
1735
|
+
const localDatabase = localConfig.getTablesDB(databaseId);
|
|
1715
1736
|
|
|
1716
1737
|
try {
|
|
1717
1738
|
const database = await tablesDBGet({
|
|
@@ -1753,11 +1774,10 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1753
1774
|
});
|
|
1754
1775
|
|
|
1755
1776
|
if (remoteTable.name !== table.name) {
|
|
1756
|
-
await
|
|
1777
|
+
await tablesDBUpdateTable({
|
|
1757
1778
|
databaseId: table['databaseId'],
|
|
1758
1779
|
tableId: table['$id'],
|
|
1759
1780
|
name: table.name,
|
|
1760
|
-
name: table.name,
|
|
1761
1781
|
parseOutput: false
|
|
1762
1782
|
})
|
|
1763
1783
|
|
|
@@ -1770,7 +1790,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1770
1790
|
(e) {
|
|
1771
1791
|
if (Number(e.code) === 404) {
|
|
1772
1792
|
log(`Table ${table.name} does not exist in the project. Creating ... `);
|
|
1773
|
-
await
|
|
1793
|
+
await tablesDBCreateTable({
|
|
1774
1794
|
databaseId: table['databaseId'],
|
|
1775
1795
|
tableId: table['$id'],
|
|
1776
1796
|
name: table.name,
|
|
@@ -1796,13 +1816,12 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
|
|
|
1796
1816
|
if ((Array.isArray(columns) && columns.length <= 0) && (Array.isArray(indexes) && indexes.length <= 0)) {
|
|
1797
1817
|
continue;
|
|
1798
1818
|
}
|
|
1799
|
-
|
|
1800
1819
|
}
|
|
1801
1820
|
|
|
1802
1821
|
log(`Pushing table ${table.name} ( ${table['databaseId']} - ${table['$id']} ) attributes`)
|
|
1803
1822
|
|
|
1804
1823
|
try {
|
|
1805
|
-
await
|
|
1824
|
+
await createColumns(columns, table)
|
|
1806
1825
|
} catch (e) {
|
|
1807
1826
|
throw e;
|
|
1808
1827
|
}
|
|
@@ -1900,7 +1919,6 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
|
|
|
1900
1919
|
databaseId: collection['databaseId'],
|
|
1901
1920
|
collectionId: collection['$id'],
|
|
1902
1921
|
name: collection.name,
|
|
1903
|
-
name: collection.name,
|
|
1904
1922
|
parseOutput: false
|
|
1905
1923
|
})
|
|
1906
1924
|
|
|
@@ -1178,6 +1178,273 @@ const tablesDBUpdateIpColumn = async ({databaseId,tableId,key,required,xdefault,
|
|
|
1178
1178
|
|
|
1179
1179
|
return response;
|
|
1180
1180
|
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* @typedef {Object} TablesDBCreateLineColumnRequestParams
|
|
1184
|
+
* @property {string} databaseId Database ID.
|
|
1185
|
+
* @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
1186
|
+
* @property {string} key Column Key.
|
|
1187
|
+
* @property {boolean} required Is column required?
|
|
1188
|
+
* @property {any[]} xdefault Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.
|
|
1189
|
+
* @property {boolean} overrideForCli
|
|
1190
|
+
* @property {boolean} parseOutput
|
|
1191
|
+
* @property {libClient | undefined} sdk
|
|
1192
|
+
*/
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* @param {TablesDBCreateLineColumnRequestParams} params
|
|
1196
|
+
*/
|
|
1197
|
+
const tablesDBCreateLineColumn = async ({databaseId,tableId,key,required,xdefault,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
1198
|
+
let client = !sdk ? await sdkForProject() :
|
|
1199
|
+
sdk;
|
|
1200
|
+
let apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
|
|
1201
|
+
let payload = {};
|
|
1202
|
+
if (typeof key !== 'undefined') {
|
|
1203
|
+
payload['key'] = key;
|
|
1204
|
+
}
|
|
1205
|
+
if (typeof required !== 'undefined') {
|
|
1206
|
+
payload['required'] = required;
|
|
1207
|
+
}
|
|
1208
|
+
xdefault = xdefault === true ? [] : xdefault;
|
|
1209
|
+
if (typeof xdefault !== 'undefined') {
|
|
1210
|
+
payload['default'] = xdefault;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
let response = undefined;
|
|
1214
|
+
|
|
1215
|
+
response = await client.call('post', apiPath, {
|
|
1216
|
+
'content-type': 'application/json',
|
|
1217
|
+
}, payload);
|
|
1218
|
+
|
|
1219
|
+
if (parseOutput) {
|
|
1220
|
+
parse(response)
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
return response;
|
|
1224
|
+
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* @typedef {Object} TablesDBUpdateLineColumnRequestParams
|
|
1228
|
+
* @property {string} databaseId Database ID.
|
|
1229
|
+
* @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
1230
|
+
* @property {string} key Column Key.
|
|
1231
|
+
* @property {boolean} required Is column required?
|
|
1232
|
+
* @property {any[]} xdefault Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.
|
|
1233
|
+
* @property {string} newKey New Column Key.
|
|
1234
|
+
* @property {boolean} overrideForCli
|
|
1235
|
+
* @property {boolean} parseOutput
|
|
1236
|
+
* @property {libClient | undefined} sdk
|
|
1237
|
+
*/
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* @param {TablesDBUpdateLineColumnRequestParams} params
|
|
1241
|
+
*/
|
|
1242
|
+
const tablesDBUpdateLineColumn = async ({databaseId,tableId,key,required,xdefault,newKey,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
1243
|
+
let client = !sdk ? await sdkForProject() :
|
|
1244
|
+
sdk;
|
|
1245
|
+
let apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key);
|
|
1246
|
+
let payload = {};
|
|
1247
|
+
if (typeof required !== 'undefined') {
|
|
1248
|
+
payload['required'] = required;
|
|
1249
|
+
}
|
|
1250
|
+
xdefault = xdefault === true ? [] : xdefault;
|
|
1251
|
+
if (typeof xdefault !== 'undefined') {
|
|
1252
|
+
payload['default'] = xdefault;
|
|
1253
|
+
}
|
|
1254
|
+
if (typeof newKey !== 'undefined') {
|
|
1255
|
+
payload['newKey'] = newKey;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
let response = undefined;
|
|
1259
|
+
|
|
1260
|
+
response = await client.call('patch', apiPath, {
|
|
1261
|
+
'content-type': 'application/json',
|
|
1262
|
+
}, payload);
|
|
1263
|
+
|
|
1264
|
+
if (parseOutput) {
|
|
1265
|
+
parse(response)
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
return response;
|
|
1269
|
+
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* @typedef {Object} TablesDBCreatePointColumnRequestParams
|
|
1273
|
+
* @property {string} databaseId Database ID.
|
|
1274
|
+
* @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
1275
|
+
* @property {string} key Column Key.
|
|
1276
|
+
* @property {boolean} required Is column required?
|
|
1277
|
+
* @property {any[]} xdefault Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.
|
|
1278
|
+
* @property {boolean} overrideForCli
|
|
1279
|
+
* @property {boolean} parseOutput
|
|
1280
|
+
* @property {libClient | undefined} sdk
|
|
1281
|
+
*/
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* @param {TablesDBCreatePointColumnRequestParams} params
|
|
1285
|
+
*/
|
|
1286
|
+
const tablesDBCreatePointColumn = async ({databaseId,tableId,key,required,xdefault,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
1287
|
+
let client = !sdk ? await sdkForProject() :
|
|
1288
|
+
sdk;
|
|
1289
|
+
let apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
|
|
1290
|
+
let payload = {};
|
|
1291
|
+
if (typeof key !== 'undefined') {
|
|
1292
|
+
payload['key'] = key;
|
|
1293
|
+
}
|
|
1294
|
+
if (typeof required !== 'undefined') {
|
|
1295
|
+
payload['required'] = required;
|
|
1296
|
+
}
|
|
1297
|
+
xdefault = xdefault === true ? [] : xdefault;
|
|
1298
|
+
if (typeof xdefault !== 'undefined') {
|
|
1299
|
+
payload['default'] = xdefault;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
let response = undefined;
|
|
1303
|
+
|
|
1304
|
+
response = await client.call('post', apiPath, {
|
|
1305
|
+
'content-type': 'application/json',
|
|
1306
|
+
}, payload);
|
|
1307
|
+
|
|
1308
|
+
if (parseOutput) {
|
|
1309
|
+
parse(response)
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
return response;
|
|
1313
|
+
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* @typedef {Object} TablesDBUpdatePointColumnRequestParams
|
|
1317
|
+
* @property {string} databaseId Database ID.
|
|
1318
|
+
* @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
1319
|
+
* @property {string} key Column Key.
|
|
1320
|
+
* @property {boolean} required Is column required?
|
|
1321
|
+
* @property {any[]} xdefault Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.
|
|
1322
|
+
* @property {string} newKey New Column Key.
|
|
1323
|
+
* @property {boolean} overrideForCli
|
|
1324
|
+
* @property {boolean} parseOutput
|
|
1325
|
+
* @property {libClient | undefined} sdk
|
|
1326
|
+
*/
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* @param {TablesDBUpdatePointColumnRequestParams} params
|
|
1330
|
+
*/
|
|
1331
|
+
const tablesDBUpdatePointColumn = async ({databaseId,tableId,key,required,xdefault,newKey,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
1332
|
+
let client = !sdk ? await sdkForProject() :
|
|
1333
|
+
sdk;
|
|
1334
|
+
let apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key);
|
|
1335
|
+
let payload = {};
|
|
1336
|
+
if (typeof required !== 'undefined') {
|
|
1337
|
+
payload['required'] = required;
|
|
1338
|
+
}
|
|
1339
|
+
xdefault = xdefault === true ? [] : xdefault;
|
|
1340
|
+
if (typeof xdefault !== 'undefined') {
|
|
1341
|
+
payload['default'] = xdefault;
|
|
1342
|
+
}
|
|
1343
|
+
if (typeof newKey !== 'undefined') {
|
|
1344
|
+
payload['newKey'] = newKey;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
let response = undefined;
|
|
1348
|
+
|
|
1349
|
+
response = await client.call('patch', apiPath, {
|
|
1350
|
+
'content-type': 'application/json',
|
|
1351
|
+
}, payload);
|
|
1352
|
+
|
|
1353
|
+
if (parseOutput) {
|
|
1354
|
+
parse(response)
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
return response;
|
|
1358
|
+
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* @typedef {Object} TablesDBCreatePolygonColumnRequestParams
|
|
1362
|
+
* @property {string} databaseId Database ID.
|
|
1363
|
+
* @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
1364
|
+
* @property {string} key Column Key.
|
|
1365
|
+
* @property {boolean} required Is column required?
|
|
1366
|
+
* @property {any[]} xdefault Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.
|
|
1367
|
+
* @property {boolean} overrideForCli
|
|
1368
|
+
* @property {boolean} parseOutput
|
|
1369
|
+
* @property {libClient | undefined} sdk
|
|
1370
|
+
*/
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* @param {TablesDBCreatePolygonColumnRequestParams} params
|
|
1374
|
+
*/
|
|
1375
|
+
const tablesDBCreatePolygonColumn = async ({databaseId,tableId,key,required,xdefault,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
1376
|
+
let client = !sdk ? await sdkForProject() :
|
|
1377
|
+
sdk;
|
|
1378
|
+
let apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon'.replace('{databaseId}', databaseId).replace('{tableId}', tableId);
|
|
1379
|
+
let payload = {};
|
|
1380
|
+
if (typeof key !== 'undefined') {
|
|
1381
|
+
payload['key'] = key;
|
|
1382
|
+
}
|
|
1383
|
+
if (typeof required !== 'undefined') {
|
|
1384
|
+
payload['required'] = required;
|
|
1385
|
+
}
|
|
1386
|
+
xdefault = xdefault === true ? [] : xdefault;
|
|
1387
|
+
if (typeof xdefault !== 'undefined') {
|
|
1388
|
+
payload['default'] = xdefault;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
let response = undefined;
|
|
1392
|
+
|
|
1393
|
+
response = await client.call('post', apiPath, {
|
|
1394
|
+
'content-type': 'application/json',
|
|
1395
|
+
}, payload);
|
|
1396
|
+
|
|
1397
|
+
if (parseOutput) {
|
|
1398
|
+
parse(response)
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
return response;
|
|
1402
|
+
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* @typedef {Object} TablesDBUpdatePolygonColumnRequestParams
|
|
1406
|
+
* @property {string} databaseId Database ID.
|
|
1407
|
+
* @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
|
|
1408
|
+
* @property {string} key Column Key.
|
|
1409
|
+
* @property {boolean} required Is column required?
|
|
1410
|
+
* @property {any[]} xdefault Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.
|
|
1411
|
+
* @property {string} newKey New Column Key.
|
|
1412
|
+
* @property {boolean} overrideForCli
|
|
1413
|
+
* @property {boolean} parseOutput
|
|
1414
|
+
* @property {libClient | undefined} sdk
|
|
1415
|
+
*/
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* @param {TablesDBUpdatePolygonColumnRequestParams} params
|
|
1419
|
+
*/
|
|
1420
|
+
const tablesDBUpdatePolygonColumn = async ({databaseId,tableId,key,required,xdefault,newKey,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
1421
|
+
let client = !sdk ? await sdkForProject() :
|
|
1422
|
+
sdk;
|
|
1423
|
+
let apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key);
|
|
1424
|
+
let payload = {};
|
|
1425
|
+
if (typeof required !== 'undefined') {
|
|
1426
|
+
payload['required'] = required;
|
|
1427
|
+
}
|
|
1428
|
+
xdefault = xdefault === true ? [] : xdefault;
|
|
1429
|
+
if (typeof xdefault !== 'undefined') {
|
|
1430
|
+
payload['default'] = xdefault;
|
|
1431
|
+
}
|
|
1432
|
+
if (typeof newKey !== 'undefined') {
|
|
1433
|
+
payload['newKey'] = newKey;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
let response = undefined;
|
|
1437
|
+
|
|
1438
|
+
response = await client.call('patch', apiPath, {
|
|
1439
|
+
'content-type': 'application/json',
|
|
1440
|
+
}, payload);
|
|
1441
|
+
|
|
1442
|
+
if (parseOutput) {
|
|
1443
|
+
parse(response)
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
return response;
|
|
1447
|
+
|
|
1181
1448
|
}
|
|
1182
1449
|
/**
|
|
1183
1450
|
* @typedef {Object} TablesDBCreateRelationshipColumnRequestParams
|
|
@@ -1814,7 +2081,7 @@ const tablesDBCreateRow = async ({databaseId,tableId,rowId,data,permissions,pars
|
|
|
1814
2081
|
* @typedef {Object} TablesDBCreateRowsRequestParams
|
|
1815
2082
|
* @property {string} databaseId Database ID.
|
|
1816
2083
|
* @property {string} tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
|
|
1817
|
-
* @property {object[]} rows Array of
|
|
2084
|
+
* @property {object[]} rows Array of rows data as JSON objects.
|
|
1818
2085
|
* @property {boolean} overrideForCli
|
|
1819
2086
|
* @property {boolean} parseOutput
|
|
1820
2087
|
* @property {libClient | undefined} sdk
|
|
@@ -2566,6 +2833,69 @@ tablesDB
|
|
|
2566
2833
|
.option(`--new-key <new-key>`, `New Column Key.`)
|
|
2567
2834
|
.action(actionRunner(tablesDBUpdateIpColumn))
|
|
2568
2835
|
|
|
2836
|
+
tablesDB
|
|
2837
|
+
.command(`create-line-column`)
|
|
2838
|
+
.description(`Create a geometric line column.`)
|
|
2839
|
+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2840
|
+
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
|
|
2841
|
+
.requiredOption(`--key <key>`, `Column Key.`)
|
|
2842
|
+
.requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
|
|
2843
|
+
.option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.`)
|
|
2844
|
+
.action(actionRunner(tablesDBCreateLineColumn))
|
|
2845
|
+
|
|
2846
|
+
tablesDB
|
|
2847
|
+
.command(`update-line-column`)
|
|
2848
|
+
.description(`Update a line column. Changing the 'default' value will not update already existing rows.`)
|
|
2849
|
+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2850
|
+
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
|
|
2851
|
+
.requiredOption(`--key <key>`, `Column Key.`)
|
|
2852
|
+
.requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
|
|
2853
|
+
.option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.`)
|
|
2854
|
+
.option(`--new-key <new-key>`, `New Column Key.`)
|
|
2855
|
+
.action(actionRunner(tablesDBUpdateLineColumn))
|
|
2856
|
+
|
|
2857
|
+
tablesDB
|
|
2858
|
+
.command(`create-point-column`)
|
|
2859
|
+
.description(`Create a geometric point column.`)
|
|
2860
|
+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2861
|
+
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
|
|
2862
|
+
.requiredOption(`--key <key>`, `Column Key.`)
|
|
2863
|
+
.requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
|
|
2864
|
+
.option(`--xdefault <xdefault>`, `Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.`)
|
|
2865
|
+
.action(actionRunner(tablesDBCreatePointColumn))
|
|
2866
|
+
|
|
2867
|
+
tablesDB
|
|
2868
|
+
.command(`update-point-column`)
|
|
2869
|
+
.description(`Update a point column. Changing the 'default' value will not update already existing rows.`)
|
|
2870
|
+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2871
|
+
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
|
|
2872
|
+
.requiredOption(`--key <key>`, `Column Key.`)
|
|
2873
|
+
.requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
|
|
2874
|
+
.option(`--xdefault <xdefault>`, `Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.`)
|
|
2875
|
+
.option(`--new-key <new-key>`, `New Column Key.`)
|
|
2876
|
+
.action(actionRunner(tablesDBUpdatePointColumn))
|
|
2877
|
+
|
|
2878
|
+
tablesDB
|
|
2879
|
+
.command(`create-polygon-column`)
|
|
2880
|
+
.description(`Create a geometric polygon column.`)
|
|
2881
|
+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2882
|
+
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
|
|
2883
|
+
.requiredOption(`--key <key>`, `Column Key.`)
|
|
2884
|
+
.requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
|
|
2885
|
+
.option(`--xdefault <xdefault>`, `Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.`)
|
|
2886
|
+
.action(actionRunner(tablesDBCreatePolygonColumn))
|
|
2887
|
+
|
|
2888
|
+
tablesDB
|
|
2889
|
+
.command(`update-polygon-column`)
|
|
2890
|
+
.description(`Update a polygon column. Changing the 'default' value will not update already existing rows.`)
|
|
2891
|
+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2892
|
+
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
|
|
2893
|
+
.requiredOption(`--key <key>`, `Column Key.`)
|
|
2894
|
+
.requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
|
|
2895
|
+
.option(`--xdefault <xdefault>`, `Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.`)
|
|
2896
|
+
.option(`--new-key <new-key>`, `New Column Key.`)
|
|
2897
|
+
.action(actionRunner(tablesDBUpdatePolygonColumn))
|
|
2898
|
+
|
|
2569
2899
|
tablesDB
|
|
2570
2900
|
.command(`create-relationship-column`)
|
|
2571
2901
|
.description(`Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). `)
|
|
@@ -2723,7 +3053,7 @@ tablesDB
|
|
|
2723
3053
|
.description(`Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.`)
|
|
2724
3054
|
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2725
3055
|
.requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.`)
|
|
2726
|
-
.requiredOption(`--rows [rows...]`, `Array of
|
|
3056
|
+
.requiredOption(`--rows [rows...]`, `Array of rows data as JSON objects.`)
|
|
2727
3057
|
.action(actionRunner(tablesDBCreateRows))
|
|
2728
3058
|
|
|
2729
3059
|
tablesDB
|
|
@@ -2865,6 +3195,12 @@ module.exports = {
|
|
|
2865
3195
|
tablesDBUpdateIntegerColumn,
|
|
2866
3196
|
tablesDBCreateIpColumn,
|
|
2867
3197
|
tablesDBUpdateIpColumn,
|
|
3198
|
+
tablesDBCreateLineColumn,
|
|
3199
|
+
tablesDBUpdateLineColumn,
|
|
3200
|
+
tablesDBCreatePointColumn,
|
|
3201
|
+
tablesDBUpdatePointColumn,
|
|
3202
|
+
tablesDBCreatePolygonColumn,
|
|
3203
|
+
tablesDBUpdatePolygonColumn,
|
|
2868
3204
|
tablesDBCreateRelationshipColumn,
|
|
2869
3205
|
tablesDBCreateStringColumn,
|
|
2870
3206
|
tablesDBUpdateStringColumn,
|