appwrite-cli 13.0.0-rc.5 → 13.0.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 +14 -1
- package/README.md +3 -3
- package/dist/bundle.cjs +36319 -20470
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +3 -4
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/commands/config.d.ts +90 -1
- package/dist/lib/commands/config.d.ts.map +1 -1
- package/dist/lib/commands/config.js +14 -4
- package/dist/lib/commands/config.js.map +1 -1
- package/dist/lib/commands/pull.d.ts.map +1 -1
- package/dist/lib/commands/pull.js +68 -25
- package/dist/lib/commands/pull.js.map +1 -1
- package/dist/lib/commands/push.d.ts +1 -1
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/push.js +11 -5
- package/dist/lib/commands/push.js.map +1 -1
- package/dist/lib/commands/services/projects.js +7 -1
- package/dist/lib/commands/services/projects.js.map +1 -1
- package/dist/lib/commands/services/storage.js +2 -2
- package/dist/lib/commands/services/storage.js.map +1 -1
- package/dist/lib/commands/utils/attributes.d.ts +5 -2
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -1
- package/dist/lib/commands/utils/attributes.js +16 -7
- package/dist/lib/commands/utils/attributes.js.map +1 -1
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +48 -9
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +1 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/json.d.ts +8 -0
- package/dist/lib/json.d.ts.map +1 -0
- package/dist/lib/json.js +25 -0
- package/dist/lib/json.js.map +1 -0
- package/dist/lib/utils.d.ts +10 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +19 -177
- package/dist/lib/utils.js.map +1 -1
- package/dist/package.json +3 -2
- package/docs/examples/projects/update-labels.md +3 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +3 -5
- package/lib/commands/config.ts +50 -32
- package/lib/commands/pull.ts +111 -25
- package/lib/commands/push.ts +21 -7
- package/lib/commands/services/projects.ts +13 -1
- package/lib/commands/services/storage.ts +2 -2
- package/lib/commands/utils/attributes.ts +19 -8
- package/lib/config.ts +54 -10
- package/lib/constants.ts +1 -1
- package/lib/json.ts +28 -0
- package/lib/utils.ts +25 -232
- package/package.json +3 -2
- package/scoop/appwrite.config.json +3 -3
package/dist/lib/utils.js
CHANGED
|
@@ -2,9 +2,8 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import net from "net";
|
|
4
4
|
import childProcess from "child_process";
|
|
5
|
-
import chalk from "chalk";
|
|
6
5
|
import { fetch } from "undici";
|
|
7
|
-
import {
|
|
6
|
+
import { globalConfig } from "./config.js";
|
|
8
7
|
import { NPM_REGISTRY_URL, DEFAULT_ENDPOINT } from "./constants.js";
|
|
9
8
|
export const createSettingsObject = (project) => {
|
|
10
9
|
return {
|
|
@@ -141,184 +140,27 @@ export const checkDeployConditions = (localConfig) => {
|
|
|
141
140
|
throw new Error("No appwrite.config.json file found in the current directory. Please run this command again in the folder containing your appwrite.config.json file, or run 'appwrite init project' to link current directory to an Appwrite project.");
|
|
142
141
|
}
|
|
143
142
|
};
|
|
144
|
-
export function showConsoleLink(serviceName, action, ...ids) {
|
|
145
|
-
const projectId = localConfig.getProject().projectId;
|
|
146
|
-
const url = new URL(globalConfig.getEndpoint().replace("/v1", "/console"));
|
|
147
|
-
url.pathname += `/project-${projectId}`;
|
|
148
|
-
action = action.toLowerCase();
|
|
149
|
-
switch (serviceName) {
|
|
150
|
-
case "account":
|
|
151
|
-
url.pathname = url.pathname.replace(`/project-${projectId}`, "");
|
|
152
|
-
url.pathname += getAccountPath(action);
|
|
153
|
-
break;
|
|
154
|
-
case "databases":
|
|
155
|
-
url.pathname += getDatabasePath(action, ids);
|
|
156
|
-
break;
|
|
157
|
-
case "functions":
|
|
158
|
-
url.pathname += getFunctionsPath(action, ids);
|
|
159
|
-
break;
|
|
160
|
-
case "messaging":
|
|
161
|
-
url.pathname += getMessagingPath(action, ids);
|
|
162
|
-
break;
|
|
163
|
-
case "projects":
|
|
164
|
-
url.pathname = url.pathname.replace(`/project-${projectId}`, "");
|
|
165
|
-
url.pathname += getProjectsPath(action, ids);
|
|
166
|
-
break;
|
|
167
|
-
case "storage":
|
|
168
|
-
url.pathname += getBucketsPath(action, ids);
|
|
169
|
-
break;
|
|
170
|
-
case "teams":
|
|
171
|
-
url.pathname += getTeamsPath(action, ids);
|
|
172
|
-
break;
|
|
173
|
-
case "organizations":
|
|
174
|
-
url.pathname += getOrganizationsPath(action, ids);
|
|
175
|
-
break;
|
|
176
|
-
case "users":
|
|
177
|
-
url.pathname += getUsersPath(action, ids);
|
|
178
|
-
break;
|
|
179
|
-
default:
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(url.toString())}`);
|
|
183
|
-
}
|
|
184
|
-
function getAccountPath(action) {
|
|
185
|
-
let path = "/account";
|
|
186
|
-
if (action === "listsessions") {
|
|
187
|
-
path += "/sessions";
|
|
188
|
-
}
|
|
189
|
-
return path;
|
|
190
|
-
}
|
|
191
|
-
function getDatabasePath(action, ids) {
|
|
192
|
-
let path = "/databases";
|
|
193
|
-
if ([
|
|
194
|
-
"get",
|
|
195
|
-
"listcollections",
|
|
196
|
-
"getcollection",
|
|
197
|
-
"listattributes",
|
|
198
|
-
"listdocuments",
|
|
199
|
-
"getdocument",
|
|
200
|
-
"listindexes",
|
|
201
|
-
"getdatabaseusage",
|
|
202
|
-
].includes(action)) {
|
|
203
|
-
path += `/database-${ids[0]}`;
|
|
204
|
-
}
|
|
205
|
-
if (action === "getdatabaseusage") {
|
|
206
|
-
path += `/usage`;
|
|
207
|
-
}
|
|
208
|
-
if ([
|
|
209
|
-
"getcollection",
|
|
210
|
-
"listattributes",
|
|
211
|
-
"listdocuments",
|
|
212
|
-
"getdocument",
|
|
213
|
-
"listindexes",
|
|
214
|
-
].includes(action)) {
|
|
215
|
-
path += `/collection-${ids[1]}`;
|
|
216
|
-
}
|
|
217
|
-
if (action === "listattributes") {
|
|
218
|
-
path += "/attributes";
|
|
219
|
-
}
|
|
220
|
-
if (action === "listindexes") {
|
|
221
|
-
path += "/indexes";
|
|
222
|
-
}
|
|
223
|
-
if (action === "getdocument") {
|
|
224
|
-
path += `/document-${ids[2]}`;
|
|
225
|
-
}
|
|
226
|
-
return path;
|
|
227
|
-
}
|
|
228
|
-
function getFunctionsPath(action, ids) {
|
|
229
|
-
let path = "/functions";
|
|
230
|
-
if (action !== "list") {
|
|
231
|
-
path += `/function-${ids[0]}`;
|
|
232
|
-
}
|
|
233
|
-
if (action === "getdeployment") {
|
|
234
|
-
path += `/deployment-${ids[1]}`;
|
|
235
|
-
}
|
|
236
|
-
if (action === "getexecution" || action === "listexecution") {
|
|
237
|
-
path += `/executions`;
|
|
238
|
-
}
|
|
239
|
-
if (action === "getfunctionusage") {
|
|
240
|
-
path += `/usage`;
|
|
241
|
-
}
|
|
242
|
-
return path;
|
|
243
|
-
}
|
|
244
|
-
function getMessagingPath(action, ids) {
|
|
245
|
-
let path = "/messaging";
|
|
246
|
-
if (["getmessage", "listmessagelogs"].includes(action)) {
|
|
247
|
-
path += `/message-${ids[0]}`;
|
|
248
|
-
}
|
|
249
|
-
if (["listproviders", "getprovider"].includes(action)) {
|
|
250
|
-
path += `/providers`;
|
|
251
|
-
}
|
|
252
|
-
if (action === "getprovider") {
|
|
253
|
-
path += `/provider-${ids[0]}`;
|
|
254
|
-
}
|
|
255
|
-
if (["listtopics", "gettopic"].includes(action)) {
|
|
256
|
-
path += `/topics`;
|
|
257
|
-
}
|
|
258
|
-
if (action === "gettopic") {
|
|
259
|
-
path += `/topic-${ids[0]}`;
|
|
260
|
-
}
|
|
261
|
-
return path;
|
|
262
|
-
}
|
|
263
|
-
function getProjectsPath(action, ids) {
|
|
264
|
-
let path = "";
|
|
265
|
-
if (action !== "list") {
|
|
266
|
-
path += `/project-${ids[0]}`;
|
|
267
|
-
}
|
|
268
|
-
if (["listkeys", "getkey"].includes(action)) {
|
|
269
|
-
path += "/overview/keys";
|
|
270
|
-
}
|
|
271
|
-
if (["listplatforms", "getplatform"].includes(action)) {
|
|
272
|
-
path += "/overview/platforms";
|
|
273
|
-
}
|
|
274
|
-
if (["listwebhooks", "getwebhook"].includes(action)) {
|
|
275
|
-
path += "/settings/webhooks";
|
|
276
|
-
}
|
|
277
|
-
if (["getplatform", "getkey", "getwebhook"].includes(action)) {
|
|
278
|
-
path += `/${ids[1]}`;
|
|
279
|
-
}
|
|
280
|
-
return path;
|
|
281
|
-
}
|
|
282
|
-
function getBucketsPath(action, ids) {
|
|
283
|
-
let path = "/storage";
|
|
284
|
-
if (action !== "listbuckets") {
|
|
285
|
-
path += `/bucket-${ids[0]}`;
|
|
286
|
-
}
|
|
287
|
-
if (action === "getbucketusage") {
|
|
288
|
-
path += `/usage`;
|
|
289
|
-
}
|
|
290
|
-
if (action === "getfile") {
|
|
291
|
-
path += `/file-${ids[1]}`;
|
|
292
|
-
}
|
|
293
|
-
return path;
|
|
294
|
-
}
|
|
295
|
-
function getTeamsPath(action, ids) {
|
|
296
|
-
let path = "/auth/teams";
|
|
297
|
-
if (action !== "list") {
|
|
298
|
-
path += `/team-${ids[0]}`;
|
|
299
|
-
}
|
|
300
|
-
return path;
|
|
301
|
-
}
|
|
302
|
-
function getOrganizationsPath(action, ids) {
|
|
303
|
-
let path = `/organization-${ids[0]}`;
|
|
304
|
-
if (action === "list") {
|
|
305
|
-
path = "/account/organizations";
|
|
306
|
-
}
|
|
307
|
-
return path;
|
|
308
|
-
}
|
|
309
|
-
function getUsersPath(action, ids) {
|
|
310
|
-
let path = "/auth";
|
|
311
|
-
if (action !== "list") {
|
|
312
|
-
path += `/user-${ids[0]}`;
|
|
313
|
-
}
|
|
314
|
-
if (action === "listsessions") {
|
|
315
|
-
path += "sessions";
|
|
316
|
-
}
|
|
317
|
-
return path;
|
|
318
|
-
}
|
|
319
143
|
export function isCloud() {
|
|
320
144
|
const endpoint = globalConfig.getEndpoint() || DEFAULT_ENDPOINT;
|
|
321
145
|
const hostname = new URL(endpoint).hostname;
|
|
322
146
|
return hostname.endsWith("appwrite.io");
|
|
323
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Filters an object to only include fields defined in a Zod object schema.
|
|
150
|
+
* Uses the schema's shape to determine allowed keys.
|
|
151
|
+
*
|
|
152
|
+
* @param data - The data to filter
|
|
153
|
+
* @param schema - A Zod object schema with a shape property
|
|
154
|
+
* @returns The filtered data with only schema-defined fields
|
|
155
|
+
*/
|
|
156
|
+
export function filterBySchema(data, schema) {
|
|
157
|
+
const allowedKeys = Object.keys(schema.shape);
|
|
158
|
+
const result = {};
|
|
159
|
+
for (const key of allowedKeys) {
|
|
160
|
+
if (key in data) {
|
|
161
|
+
result[key] = data[key];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
324
166
|
//# sourceMappingURL=utils.js.map
|
package/dist/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,YAAY,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,YAAY,MAAM,eAAe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AQ,CAAC;IAC5C,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,IAA6B,EAC7B,MAAS;IAET,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,MAAoB,CAAC;AAC9B,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"homepage": "https://appwrite.io/support",
|
|
5
5
|
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
|
|
6
|
-
"version": "13.0.
|
|
6
|
+
"version": "13.0.1",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"windows-arm64": "bun run build && esbuild dist/cli.js --bundle --platform=node --format=cjs --outfile=dist/bundle.cjs --external:@appwrite.io/console --external:fsevents && pkg dist/bundle.cjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@appwrite.io/console": "^2.1.
|
|
31
|
+
"@appwrite.io/console": "^2.1.3",
|
|
32
|
+
"bignumber.js": "^9.0.0",
|
|
32
33
|
"chalk": "4.1.2",
|
|
33
34
|
"chokidar": "^3.6.0",
|
|
34
35
|
"cli-progress": "^3.12.0",
|
package/install.ps1
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
# You can use "View source" of this page to see the full script.
|
|
14
14
|
|
|
15
15
|
# REPO
|
|
16
|
-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.
|
|
16
|
+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.1/appwrite-cli-win-x64.exe"
|
|
17
|
+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.1/appwrite-cli-win-arm64.exe"
|
|
18
18
|
|
|
19
19
|
$APPWRITE_BINARY_NAME = "appwrite.exe"
|
|
20
20
|
|
package/install.sh
CHANGED
|
@@ -96,7 +96,7 @@ printSuccess() {
|
|
|
96
96
|
downloadBinary() {
|
|
97
97
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
98
98
|
|
|
99
|
-
GITHUB_LATEST_VERSION="13.0.
|
|
99
|
+
GITHUB_LATEST_VERSION="13.0.1"
|
|
100
100
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
101
101
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
102
102
|
|
package/lib/client.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import os from "os";
|
|
2
2
|
import { fetch, FormData, Agent } from "undici";
|
|
3
|
-
import JSONbig from "json-bigint";
|
|
4
3
|
import { AppwriteException } from "@appwrite.io/console";
|
|
5
4
|
import { globalConfig } from "./config.js";
|
|
5
|
+
import { JSONBig } from "./json.js";
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
import type {
|
|
8
8
|
Headers,
|
|
@@ -19,8 +19,6 @@ import {
|
|
|
19
19
|
SDK_TITLE,
|
|
20
20
|
} from "./constants.js";
|
|
21
21
|
|
|
22
|
-
const JSONBigInt = JSONbig({ useNativeBigInt: true });
|
|
23
|
-
|
|
24
22
|
class Client {
|
|
25
23
|
private endpoint: string;
|
|
26
24
|
private headers: Headers;
|
|
@@ -199,7 +197,7 @@ class Client {
|
|
|
199
197
|
|
|
200
198
|
body = formData;
|
|
201
199
|
} else {
|
|
202
|
-
body =
|
|
200
|
+
body = JSONBig.stringify(params);
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
let response: Awaited<ReturnType<typeof fetch>> | undefined = undefined;
|
|
@@ -266,7 +264,7 @@ class Client {
|
|
|
266
264
|
const text = await response.text();
|
|
267
265
|
let json: T | undefined = undefined;
|
|
268
266
|
try {
|
|
269
|
-
json =
|
|
267
|
+
json = JSONBig.parse(text);
|
|
270
268
|
} catch (error) {
|
|
271
269
|
return text as T;
|
|
272
270
|
}
|
package/lib/commands/config.ts
CHANGED
|
@@ -256,6 +256,20 @@ const AttributeSchema = AttributeSchemaBase.refine(
|
|
|
256
256
|
message: "When 'required' is true, 'default' must be null",
|
|
257
257
|
path: ["default"],
|
|
258
258
|
},
|
|
259
|
+
).refine(
|
|
260
|
+
(data) => {
|
|
261
|
+
if (
|
|
262
|
+
data.type === "string" &&
|
|
263
|
+
(data.size === undefined || data.size === null)
|
|
264
|
+
) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
message: "When 'type' is 'string', 'size' must be defined",
|
|
271
|
+
path: ["size"],
|
|
272
|
+
},
|
|
259
273
|
);
|
|
260
274
|
|
|
261
275
|
const IndexSchema = z
|
|
@@ -319,6 +333,7 @@ const CollectionSchema = z
|
|
|
319
333
|
// ============================================================================
|
|
320
334
|
|
|
321
335
|
const ColumnSchema = AttributeSchema;
|
|
336
|
+
const ColumnSchemaBase = AttributeSchemaBase;
|
|
322
337
|
|
|
323
338
|
const IndexTableSchema = z
|
|
324
339
|
.object({
|
|
@@ -330,7 +345,7 @@ const IndexTableSchema = z
|
|
|
330
345
|
})
|
|
331
346
|
.strict();
|
|
332
347
|
|
|
333
|
-
const
|
|
348
|
+
const TablesDBSchemaBase = z
|
|
334
349
|
.object({
|
|
335
350
|
$id: z.string(),
|
|
336
351
|
$permissions: z.array(z.string()).optional(),
|
|
@@ -341,40 +356,41 @@ const TablesDBSchema = z
|
|
|
341
356
|
columns: z.array(ColumnSchema).optional(),
|
|
342
357
|
indexes: z.array(IndexTableSchema).optional(),
|
|
343
358
|
})
|
|
344
|
-
.strict()
|
|
345
|
-
.superRefine((data, ctx) => {
|
|
346
|
-
if (data.columns && data.columns.length > 0) {
|
|
347
|
-
const seenKeys = new Set<string>();
|
|
359
|
+
.strict();
|
|
348
360
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
code: z.ZodIssueCode.custom,
|
|
353
|
-
message: `Column with the key '${col.key}' already exists. Column keys must be unique, try again with a different key.`,
|
|
354
|
-
path: ["columns", index, "key"],
|
|
355
|
-
});
|
|
356
|
-
} else {
|
|
357
|
-
seenKeys.add(col.key);
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
+
const TablesDBSchema = TablesDBSchemaBase.superRefine((data, ctx) => {
|
|
362
|
+
if (data.columns && data.columns.length > 0) {
|
|
363
|
+
const seenKeys = new Set<string>();
|
|
361
364
|
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
data.columns.forEach((col, index) => {
|
|
366
|
+
if (seenKeys.has(col.key)) {
|
|
367
|
+
ctx.addIssue({
|
|
368
|
+
code: z.ZodIssueCode.custom,
|
|
369
|
+
message: `Column with the key '${col.key}' already exists. Column keys must be unique, try again with a different key.`,
|
|
370
|
+
path: ["columns", index, "key"],
|
|
371
|
+
});
|
|
372
|
+
} else {
|
|
373
|
+
seenKeys.add(col.key);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
364
377
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
+
if (data.indexes && data.indexes.length > 0) {
|
|
379
|
+
const seenKeys = new Set<string>();
|
|
380
|
+
|
|
381
|
+
data.indexes.forEach((index, indexPos) => {
|
|
382
|
+
if (seenKeys.has(index.key)) {
|
|
383
|
+
ctx.addIssue({
|
|
384
|
+
code: z.ZodIssueCode.custom,
|
|
385
|
+
message: `Index with the key '${index.key}' already exists. Index keys must be unique, try again with a different key.`,
|
|
386
|
+
path: ["indexes", indexPos, "key"],
|
|
387
|
+
});
|
|
388
|
+
} else {
|
|
389
|
+
seenKeys.add(index.key);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
});
|
|
378
394
|
|
|
379
395
|
// ============================================================================
|
|
380
396
|
// Topics
|
|
@@ -477,7 +493,9 @@ export {
|
|
|
477
493
|
|
|
478
494
|
/** Tables */
|
|
479
495
|
TablesDBSchema,
|
|
496
|
+
TablesDBSchemaBase,
|
|
480
497
|
ColumnSchema,
|
|
498
|
+
ColumnSchemaBase,
|
|
481
499
|
IndexTableSchema,
|
|
482
500
|
|
|
483
501
|
/** Topics */
|
package/lib/commands/pull.ts
CHANGED
|
@@ -37,10 +37,18 @@ import {
|
|
|
37
37
|
commandDescriptions,
|
|
38
38
|
} from "../parser.js";
|
|
39
39
|
import type { ConfigType } from "./config.js";
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
DatabaseSchema,
|
|
42
|
+
TablesDBSchemaBase,
|
|
43
|
+
ColumnSchemaBase,
|
|
44
|
+
BucketSchema,
|
|
45
|
+
TopicSchema,
|
|
46
|
+
} from "./config.js";
|
|
47
|
+
import { createSettingsObject, filterBySchema } from "../utils.js";
|
|
41
48
|
import { ProjectNotInitializedError } from "./errors.js";
|
|
42
49
|
import type { SettingsType, FunctionType, SiteType } from "./config.js";
|
|
43
50
|
import { downloadDeploymentCode } from "./utils/deployment.js";
|
|
51
|
+
import { getConfirmation } from "./utils/change-approval.js";
|
|
44
52
|
|
|
45
53
|
export interface PullOptions {
|
|
46
54
|
all?: boolean;
|
|
@@ -522,7 +530,7 @@ export class Pull {
|
|
|
522
530
|
this.log(
|
|
523
531
|
`Pulling all tables from ${chalk.bold(database.name)} database ...`,
|
|
524
532
|
);
|
|
525
|
-
allDatabases.push(database);
|
|
533
|
+
allDatabases.push(filterBySchema(database, DatabaseSchema));
|
|
526
534
|
|
|
527
535
|
const { tables } = await paginate(
|
|
528
536
|
async () => new TablesDB(this.projectClient).listTables(database.$id),
|
|
@@ -532,10 +540,14 @@ export class Pull {
|
|
|
532
540
|
);
|
|
533
541
|
|
|
534
542
|
for (const table of tables) {
|
|
543
|
+
// Filter columns to only include schema-defined fields
|
|
544
|
+
const filteredColumns = table.columns?.map((col: any) =>
|
|
545
|
+
filterBySchema(col, ColumnSchemaBase),
|
|
546
|
+
);
|
|
547
|
+
|
|
535
548
|
allTables.push({
|
|
536
|
-
...table,
|
|
537
|
-
|
|
538
|
-
$updatedAt: undefined,
|
|
549
|
+
...filterBySchema(table, TablesDBSchemaBase),
|
|
550
|
+
columns: filteredColumns || [],
|
|
539
551
|
});
|
|
540
552
|
}
|
|
541
553
|
}
|
|
@@ -575,13 +587,18 @@ export class Pull {
|
|
|
575
587
|
"buckets",
|
|
576
588
|
);
|
|
577
589
|
|
|
590
|
+
const filteredBuckets: any[] = [];
|
|
591
|
+
|
|
578
592
|
for (const bucket of buckets) {
|
|
579
593
|
this.log(`Pulling bucket ${chalk.bold(bucket.name)} ...`);
|
|
594
|
+
filteredBuckets.push(filterBySchema(bucket, BucketSchema));
|
|
580
595
|
}
|
|
581
596
|
|
|
582
|
-
this.success(
|
|
597
|
+
this.success(
|
|
598
|
+
`Successfully pulled ${chalk.bold(filteredBuckets.length)} buckets.`,
|
|
599
|
+
);
|
|
583
600
|
|
|
584
|
-
return
|
|
601
|
+
return filteredBuckets;
|
|
585
602
|
}
|
|
586
603
|
|
|
587
604
|
/**
|
|
@@ -643,13 +660,18 @@ export class Pull {
|
|
|
643
660
|
"topics",
|
|
644
661
|
);
|
|
645
662
|
|
|
663
|
+
const filteredTopics: any[] = [];
|
|
664
|
+
|
|
646
665
|
for (const topic of topics) {
|
|
647
666
|
this.log(`Pulling topic ${chalk.bold(topic.name)} ...`);
|
|
667
|
+
filteredTopics.push(filterBySchema(topic, TopicSchema));
|
|
648
668
|
}
|
|
649
669
|
|
|
650
|
-
this.success(
|
|
670
|
+
this.success(
|
|
671
|
+
`Successfully pulled ${chalk.bold(filteredTopics.length)} topics.`,
|
|
672
|
+
);
|
|
651
673
|
|
|
652
|
-
return
|
|
674
|
+
return filteredTopics;
|
|
653
675
|
}
|
|
654
676
|
}
|
|
655
677
|
|
|
@@ -804,53 +826,117 @@ const pullCollection = async (): Promise<void> => {
|
|
|
804
826
|
const pullInstance = await createPullInstance();
|
|
805
827
|
const { databases, collections } = await pullInstance.pullCollections();
|
|
806
828
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
829
|
+
const localCollections = localConfig.getCollections();
|
|
830
|
+
const remoteCollectionIds = new Set(collections.map((c: any) => c.$id));
|
|
831
|
+
const collectionsToRemove = localCollections.filter(
|
|
832
|
+
(c: any) => !remoteCollectionIds.has(c.$id),
|
|
833
|
+
);
|
|
810
834
|
|
|
811
|
-
|
|
812
|
-
|
|
835
|
+
if (collectionsToRemove.length > 0) {
|
|
836
|
+
warn(
|
|
837
|
+
`The following collections exist locally but not remotely and will be removed: ${collectionsToRemove.map((c: any) => c.name || c.$id).join(", ")}`,
|
|
838
|
+
);
|
|
839
|
+
if ((await getConfirmation()) !== true) {
|
|
840
|
+
log("Pull cancelled.");
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
813
843
|
}
|
|
844
|
+
|
|
845
|
+
localConfig.set("databases", databases);
|
|
846
|
+
localConfig.set("collections", collections);
|
|
814
847
|
};
|
|
815
848
|
|
|
816
849
|
const pullTable = async (): Promise<void> => {
|
|
817
850
|
const pullInstance = await createPullInstance();
|
|
818
851
|
const { databases, tables } = await pullInstance.pullTables();
|
|
819
852
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
853
|
+
const localTables = localConfig.getTables();
|
|
854
|
+
const remoteTableIds = new Set(tables.map((t: any) => t.$id));
|
|
855
|
+
const tablesToRemove = localTables.filter(
|
|
856
|
+
(t: any) => !remoteTableIds.has(t.$id),
|
|
857
|
+
);
|
|
823
858
|
|
|
824
|
-
|
|
825
|
-
|
|
859
|
+
if (tablesToRemove.length > 0) {
|
|
860
|
+
warn(
|
|
861
|
+
`The following tables exist locally but not remotely and will be removed: ${tablesToRemove.map((t: any) => t.name || t.$id).join(", ")}`,
|
|
862
|
+
);
|
|
863
|
+
if ((await getConfirmation()) !== true) {
|
|
864
|
+
log("Pull cancelled.");
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
826
867
|
}
|
|
868
|
+
|
|
869
|
+
localConfig.set("tablesDB", databases);
|
|
870
|
+
localConfig.set("tables", tables);
|
|
827
871
|
};
|
|
828
872
|
|
|
829
873
|
const pullBucket = async (): Promise<void> => {
|
|
830
874
|
const pullInstance = await createPullInstance();
|
|
831
875
|
const buckets = await pullInstance.pullBuckets();
|
|
832
876
|
|
|
833
|
-
|
|
834
|
-
|
|
877
|
+
const localBuckets = localConfig.getBuckets();
|
|
878
|
+
const remoteBucketIds = new Set(buckets.map((b: any) => b.$id));
|
|
879
|
+
const bucketsToRemove = localBuckets.filter(
|
|
880
|
+
(b: any) => !remoteBucketIds.has(b.$id),
|
|
881
|
+
);
|
|
882
|
+
|
|
883
|
+
if (bucketsToRemove.length > 0) {
|
|
884
|
+
warn(
|
|
885
|
+
`The following buckets exist locally but not remotely and will be removed: ${bucketsToRemove.map((b: any) => b.name || b.$id).join(", ")}`,
|
|
886
|
+
);
|
|
887
|
+
if ((await getConfirmation()) !== true) {
|
|
888
|
+
log("Pull cancelled.");
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
835
891
|
}
|
|
892
|
+
|
|
893
|
+
localConfig.set("buckets", buckets);
|
|
836
894
|
};
|
|
837
895
|
|
|
838
896
|
const pullTeam = async (): Promise<void> => {
|
|
839
897
|
const pullInstance = await createPullInstance();
|
|
840
898
|
const teams = await pullInstance.pullTeams();
|
|
841
899
|
|
|
842
|
-
|
|
843
|
-
|
|
900
|
+
const localTeams = localConfig.getTeams();
|
|
901
|
+
const remoteTeamIds = new Set(teams.map((t: any) => t.$id));
|
|
902
|
+
const teamsToRemove = localTeams.filter(
|
|
903
|
+
(t: any) => !remoteTeamIds.has(t.$id),
|
|
904
|
+
);
|
|
905
|
+
|
|
906
|
+
if (teamsToRemove.length > 0) {
|
|
907
|
+
warn(
|
|
908
|
+
`The following teams exist locally but not remotely and will be removed: ${teamsToRemove.map((t: any) => t.name || t.$id).join(", ")}`,
|
|
909
|
+
);
|
|
910
|
+
if ((await getConfirmation()) !== true) {
|
|
911
|
+
log("Pull cancelled.");
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
844
914
|
}
|
|
915
|
+
|
|
916
|
+
localConfig.set("teams", teams);
|
|
845
917
|
};
|
|
846
918
|
|
|
847
919
|
const pullMessagingTopic = async (): Promise<void> => {
|
|
848
920
|
const pullInstance = await createPullInstance();
|
|
849
921
|
const topics = await pullInstance.pullMessagingTopics();
|
|
850
922
|
|
|
851
|
-
|
|
852
|
-
|
|
923
|
+
const localTopics = localConfig.getMessagingTopics();
|
|
924
|
+
const remoteTopicIds = new Set(topics.map((t: any) => t.$id));
|
|
925
|
+
const topicsToRemove = localTopics.filter(
|
|
926
|
+
(t: any) => !remoteTopicIds.has(t.$id),
|
|
927
|
+
);
|
|
928
|
+
|
|
929
|
+
if (topicsToRemove.length > 0) {
|
|
930
|
+
warn(
|
|
931
|
+
`The following topics exist locally but not remotely and will be removed: ${topicsToRemove.map((t: any) => t.name || t.$id).join(", ")}`,
|
|
932
|
+
);
|
|
933
|
+
if ((await getConfirmation()) !== true) {
|
|
934
|
+
log("Pull cancelled.");
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
853
937
|
}
|
|
938
|
+
|
|
939
|
+
localConfig.set("topics", topics);
|
|
854
940
|
};
|
|
855
941
|
|
|
856
942
|
/** Commander.js exports */
|