appwrite-cli 22.2.2 → 22.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.cjs +339 -122
- package/dist/index.cjs +323 -115
- package/dist/index.js +323 -115
- package/dist/lib/auth/login.d.ts.map +1 -1
- package/dist/lib/commands/config.d.ts +6 -6
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/push.d.ts +3 -0
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/parser.d.ts +1 -0
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/sdks.d.ts +3 -1
- package/dist/lib/sdks.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -86539,7 +86539,7 @@ var package_default = {
|
|
|
86539
86539
|
type: "module",
|
|
86540
86540
|
homepage: "https://appwrite.io/support",
|
|
86541
86541
|
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",
|
|
86542
|
-
version: "22.
|
|
86542
|
+
version: "22.3.0",
|
|
86543
86543
|
license: "BSD-3-Clause",
|
|
86544
86544
|
main: "dist/index.cjs",
|
|
86545
86545
|
module: "dist/index.js",
|
|
@@ -101271,7 +101271,7 @@ var validateCrossDatabase = (data, ctx) => {
|
|
|
101271
101271
|
// lib/constants.ts
|
|
101272
101272
|
var SDK_TITLE = "Appwrite";
|
|
101273
101273
|
var SDK_TITLE_LOWER = "appwrite";
|
|
101274
|
-
var SDK_VERSION = "22.
|
|
101274
|
+
var SDK_VERSION = "22.3.0";
|
|
101275
101275
|
var SDK_NAME = "Command Line";
|
|
101276
101276
|
var SDK_PLATFORM = "console";
|
|
101277
101277
|
var SDK_LANGUAGE = "cli";
|
|
@@ -101383,9 +101383,9 @@ var SettingsSchema = external_exports.object({
|
|
|
101383
101383
|
}).strict().optional(),
|
|
101384
101384
|
security: external_exports.object({
|
|
101385
101385
|
duration: external_exports.union([external_exports.number(), external_exports.bigint()]).optional(),
|
|
101386
|
-
limit: external_exports.union([external_exports.number(), external_exports.bigint()]).optional(),
|
|
101387
|
-
sessionsLimit: external_exports.union([external_exports.number(), external_exports.bigint()]).optional(),
|
|
101388
|
-
passwordHistory: external_exports.union([external_exports.number(), external_exports.bigint()]).optional(),
|
|
101386
|
+
limit: external_exports.union([external_exports.number(), external_exports.bigint()]).nullable().optional(),
|
|
101387
|
+
sessionsLimit: external_exports.union([external_exports.number(), external_exports.bigint()]).nullable().optional(),
|
|
101388
|
+
passwordHistory: external_exports.union([external_exports.number(), external_exports.bigint()]).nullable().optional(),
|
|
101389
101389
|
passwordDictionary: external_exports.boolean().optional(),
|
|
101390
101390
|
personalDataCheck: external_exports.boolean().optional(),
|
|
101391
101391
|
sessionAlerts: external_exports.boolean().optional(),
|
|
@@ -131622,7 +131622,10 @@ var createSettingsObject = (project2, policies, mockNumbers) => {
|
|
|
131622
131622
|
}
|
|
131623
131623
|
const policyTotal = (id) => {
|
|
131624
131624
|
const policy = policyById.get(id);
|
|
131625
|
-
|
|
131625
|
+
if (!policy || !("total" in policy)) {
|
|
131626
|
+
return void 0;
|
|
131627
|
+
}
|
|
131628
|
+
return policy.total === 0 ? null : policy.total;
|
|
131626
131629
|
};
|
|
131627
131630
|
const policyEnabled = (id) => {
|
|
131628
131631
|
const policy = policyById.get(id);
|
|
@@ -131857,8 +131860,40 @@ var isRegionalCloudEndpoint = (endpoint) => {
|
|
|
131857
131860
|
return false;
|
|
131858
131861
|
}
|
|
131859
131862
|
};
|
|
131863
|
+
var getCloudEndpointRegion = (endpoint) => {
|
|
131864
|
+
try {
|
|
131865
|
+
const hostname3 = new URL(endpoint).hostname;
|
|
131866
|
+
if (!isCloudHostname(hostname3) || hostname3 === "cloud.appwrite.io") {
|
|
131867
|
+
return null;
|
|
131868
|
+
}
|
|
131869
|
+
const region = hostname3.split(".")[0];
|
|
131870
|
+
return CLOUD_REGION_CODES.has(region) ? region : null;
|
|
131871
|
+
} catch (_error) {
|
|
131872
|
+
return null;
|
|
131873
|
+
}
|
|
131874
|
+
};
|
|
131860
131875
|
var isLocalhostHostname = (hostname3) => hostname3 === "localhost" || hostname3 === "127.0.0.1" || hostname3 === "[::1]";
|
|
131861
131876
|
var isCloudEnvironmentHostname = (hostname3) => hostname3.endsWith(".cloud.appwrite.io") && CLOUD_LOGIN_ENVIRONMENTS.has(hostname3.split(".")[0]);
|
|
131877
|
+
var getCloudConsoleHostname = (hostname3) => {
|
|
131878
|
+
if (hostname3 === "cloud.appwrite.io") {
|
|
131879
|
+
return hostname3;
|
|
131880
|
+
}
|
|
131881
|
+
const labels = hostname3.split(".");
|
|
131882
|
+
if (labels.length < 4 || labels.slice(-3).join(".") !== "cloud.appwrite.io") {
|
|
131883
|
+
return null;
|
|
131884
|
+
}
|
|
131885
|
+
if (CLOUD_REGION_CODES.has(labels[0])) {
|
|
131886
|
+
const environment = labels[1];
|
|
131887
|
+
if (environment && CLOUD_LOGIN_ENVIRONMENTS.has(environment)) {
|
|
131888
|
+
return `${environment}.cloud.appwrite.io`;
|
|
131889
|
+
}
|
|
131890
|
+
return "cloud.appwrite.io";
|
|
131891
|
+
}
|
|
131892
|
+
if (CLOUD_LOGIN_ENVIRONMENTS.has(labels[0])) {
|
|
131893
|
+
return hostname3;
|
|
131894
|
+
}
|
|
131895
|
+
return null;
|
|
131896
|
+
};
|
|
131862
131897
|
var isCloudLoginEndpoint = (endpoint) => {
|
|
131863
131898
|
try {
|
|
131864
131899
|
const hostname3 = new URL(endpoint).hostname;
|
|
@@ -131870,8 +131905,9 @@ var isCloudLoginEndpoint = (endpoint) => {
|
|
|
131870
131905
|
var getConsoleBaseUrl = (endpoint) => {
|
|
131871
131906
|
try {
|
|
131872
131907
|
const url2 = new URL(endpoint);
|
|
131873
|
-
|
|
131874
|
-
|
|
131908
|
+
const consoleHostname = getCloudConsoleHostname(url2.hostname);
|
|
131909
|
+
if (consoleHostname) {
|
|
131910
|
+
url2.hostname = consoleHostname;
|
|
131875
131911
|
}
|
|
131876
131912
|
url2.pathname = url2.pathname.replace(/\/v1\/?$/, "");
|
|
131877
131913
|
url2.search = "";
|
|
@@ -132745,10 +132781,7 @@ var Config = class {
|
|
|
132745
132781
|
}
|
|
132746
132782
|
_addDBEntity(entityType, props, keysSet, nestedKeys = {}) {
|
|
132747
132783
|
props = whitelistKeys(props, keysSet, nestedKeys);
|
|
132748
|
-
|
|
132749
|
-
this.set(entityType, []);
|
|
132750
|
-
}
|
|
132751
|
-
const entities = this.get(entityType);
|
|
132784
|
+
const entities = this.has(entityType) ? [...this.get(entityType) ?? []] : [];
|
|
132752
132785
|
for (let i = 0; i < entities.length; i++) {
|
|
132753
132786
|
if (entities[i]["$id"] == props["$id"]) {
|
|
132754
132787
|
entities[i] = props;
|
|
@@ -134476,6 +134509,28 @@ var printQueryErrorHint = (err) => {
|
|
|
134476
134509
|
`For common list filters, use flags like --limit 25, --sort-desc '$createdAt', or --filter 'status=active'. Raw --queries values must be Appwrite JSON query strings, for example: ${EXECUTABLE_NAME} tables-db list-rows --queries '{"method":"limit","values":[25]}'`
|
|
134477
134510
|
);
|
|
134478
134511
|
};
|
|
134512
|
+
var ERROR_DETAIL_KEYS = ["code", "type", "response"];
|
|
134513
|
+
var formatErrorForLog = (err) => {
|
|
134514
|
+
const stack = err.stack || `${err.name}: ${err.message}`;
|
|
134515
|
+
const detailLines = ERROR_DETAIL_KEYS.flatMap((key) => {
|
|
134516
|
+
if (!Object.prototype.hasOwnProperty.call(err, key)) {
|
|
134517
|
+
return [];
|
|
134518
|
+
}
|
|
134519
|
+
const value = err[key];
|
|
134520
|
+
let detail = "undefined";
|
|
134521
|
+
try {
|
|
134522
|
+
detail = typeof value === "string" ? JSON.stringify(value) : JSON.stringify(value) ?? String(value);
|
|
134523
|
+
} catch {
|
|
134524
|
+
detail = String(value);
|
|
134525
|
+
}
|
|
134526
|
+
return [`${key}: ${detail}`];
|
|
134527
|
+
});
|
|
134528
|
+
if (detailLines.length === 0) {
|
|
134529
|
+
return stack;
|
|
134530
|
+
}
|
|
134531
|
+
const [summary, ...frames] = stack.split("\n");
|
|
134532
|
+
return [summary, ...detailLines, ...frames].join("\n");
|
|
134533
|
+
};
|
|
134479
134534
|
var parseError = (err) => {
|
|
134480
134535
|
if (cliConfig.report) {
|
|
134481
134536
|
void (async () => {
|
|
@@ -134526,12 +134581,12 @@ ${stack}`
|
|
|
134526
134581
|
);
|
|
134527
134582
|
printQueryErrorHint(err);
|
|
134528
134583
|
error51("\n Stack Trace: \n");
|
|
134529
|
-
console.error(err);
|
|
134584
|
+
console.error(formatErrorForLog(err));
|
|
134530
134585
|
process.exit(1);
|
|
134531
134586
|
})();
|
|
134532
134587
|
} else {
|
|
134533
134588
|
if (cliConfig.verbose) {
|
|
134534
|
-
console.error(err);
|
|
134589
|
+
console.error(formatErrorForLog(err));
|
|
134535
134590
|
printQueryErrorHint(err);
|
|
134536
134591
|
} else {
|
|
134537
134592
|
log("For detailed error pass the --verbose or --report flag");
|
|
@@ -135164,12 +135219,12 @@ var deleteStoredRefreshToken = (sessionId) => {
|
|
|
135164
135219
|
};
|
|
135165
135220
|
|
|
135166
135221
|
// lib/sdks.ts
|
|
135167
|
-
var getValidAccessToken = async (endpoint) => {
|
|
135222
|
+
var getValidAccessToken = async (endpoint, options = {}) => {
|
|
135168
135223
|
const accessToken = globalConfig2.getAccessToken();
|
|
135169
135224
|
const tokenExpiry = globalConfig2.getTokenExpiry();
|
|
135170
135225
|
const clientId = globalConfig2.getClientId() || OAUTH2_CLIENT_ID;
|
|
135171
135226
|
const currentSession = globalConfig2.getCurrentSession();
|
|
135172
|
-
if (accessToken && tokenExpiry > Date.now() + 6e4) {
|
|
135227
|
+
if (!options.forceRefresh && accessToken && tokenExpiry > Date.now() + 6e4) {
|
|
135173
135228
|
return accessToken;
|
|
135174
135229
|
}
|
|
135175
135230
|
const refreshToken = currentSession ? getStoredRefreshToken(currentSession) : "";
|
|
@@ -137097,6 +137152,16 @@ var getCurrentAccount = async () => {
|
|
|
137097
137152
|
return account2;
|
|
137098
137153
|
} catch (err) {
|
|
137099
137154
|
if (isGuestUnauthorizedError(err)) {
|
|
137155
|
+
try {
|
|
137156
|
+
await getValidAccessToken(globalConfig2.getEndpoint(), {
|
|
137157
|
+
forceRefresh: true
|
|
137158
|
+
});
|
|
137159
|
+
const refreshedClient = await sdkForConsole();
|
|
137160
|
+
const refreshedAccount = await new Account(refreshedClient).get();
|
|
137161
|
+
globalConfig2.setEmail(refreshedAccount.email);
|
|
137162
|
+
return refreshedAccount;
|
|
137163
|
+
} catch (_refreshError) {
|
|
137164
|
+
}
|
|
137100
137165
|
removeCurrentSession();
|
|
137101
137166
|
}
|
|
137102
137167
|
return null;
|
|
@@ -142185,6 +142250,11 @@ var getExistingProjectSummary = async (organizationId, projectId) => {
|
|
|
142185
142250
|
region: project2.region || ""
|
|
142186
142251
|
};
|
|
142187
142252
|
};
|
|
142253
|
+
var getRegionalCloudEndpoint = (region) => {
|
|
142254
|
+
const url2 = new URL(globalConfig2.getEndpoint() || DEFAULT_ENDPOINT);
|
|
142255
|
+
url2.hostname = `${region}.${url2.hostname}`;
|
|
142256
|
+
return url2.toString().replace(/\/$/, "");
|
|
142257
|
+
};
|
|
142188
142258
|
var printInitProjectSuccess = (message) => {
|
|
142189
142259
|
console.log(`${import_chalk9.default.green.bold("\u2713")} ${import_chalk9.default.green(message)}`);
|
|
142190
142260
|
};
|
|
@@ -142371,7 +142441,6 @@ var initProject = async ({
|
|
|
142371
142441
|
);
|
|
142372
142442
|
}
|
|
142373
142443
|
localConfig.clear();
|
|
142374
|
-
const url2 = new URL(DEFAULT_ENDPOINT);
|
|
142375
142444
|
if (answers.start === "new") {
|
|
142376
142445
|
let projectIdToCreate;
|
|
142377
142446
|
let projectNameToCreate;
|
|
@@ -142402,9 +142471,7 @@ var initProject = async ({
|
|
|
142402
142471
|
localConfig.setProject(response["$id"], response.name ?? "");
|
|
142403
142472
|
localConfig.setOrganizationId(answers.organization);
|
|
142404
142473
|
if (answers.region) {
|
|
142405
|
-
localConfig.setEndpoint(
|
|
142406
|
-
`https://${answers.region}.${url2.host}${url2.pathname}`
|
|
142407
|
-
);
|
|
142474
|
+
localConfig.setEndpoint(getRegionalCloudEndpoint(answers.region));
|
|
142408
142475
|
}
|
|
142409
142476
|
} else {
|
|
142410
142477
|
let selectedProject;
|
|
@@ -142422,9 +142489,7 @@ var initProject = async ({
|
|
|
142422
142489
|
localConfig.setProject(selectedProject.$id, selectedProject.name ?? "");
|
|
142423
142490
|
localConfig.setOrganizationId(answers.organization);
|
|
142424
142491
|
if (isCloud() && selectedProject.region) {
|
|
142425
|
-
localConfig.setEndpoint(
|
|
142426
|
-
`https://${selectedProject.region}.${url2.host}${url2.pathname}`
|
|
142427
|
-
);
|
|
142492
|
+
localConfig.setEndpoint(getRegionalCloudEndpoint(selectedProject.region));
|
|
142428
142493
|
}
|
|
142429
142494
|
}
|
|
142430
142495
|
let autoPulled = false;
|
|
@@ -147045,6 +147110,44 @@ function createDeploymentLogsController(enabled) {
|
|
|
147045
147110
|
close: cleanup
|
|
147046
147111
|
};
|
|
147047
147112
|
}
|
|
147113
|
+
var getPushErrorMessage = (error52) => {
|
|
147114
|
+
if (error52 instanceof Error) {
|
|
147115
|
+
return error52.message;
|
|
147116
|
+
}
|
|
147117
|
+
if (typeof error52 === "object" && error52 !== null && "message" in error52 && typeof error52.message === "string") {
|
|
147118
|
+
return error52.message;
|
|
147119
|
+
}
|
|
147120
|
+
return String(error52);
|
|
147121
|
+
};
|
|
147122
|
+
var getPushResultErrors = (result) => {
|
|
147123
|
+
if (typeof result !== "object" || result === null) {
|
|
147124
|
+
return [];
|
|
147125
|
+
}
|
|
147126
|
+
if ("errors" in result && Array.isArray(result.errors) && result.errors.length > 0) {
|
|
147127
|
+
return result.errors.map(getPushErrorMessage).filter((message) => message.trim() !== "");
|
|
147128
|
+
}
|
|
147129
|
+
if ("error" in result && typeof result.error === "string" && result.error.trim() !== "") {
|
|
147130
|
+
return [result.error];
|
|
147131
|
+
}
|
|
147132
|
+
return [];
|
|
147133
|
+
};
|
|
147134
|
+
var formatPushResourceErrors = (results) => {
|
|
147135
|
+
const failed = Object.entries(results).map(([resourceGroup, result]) => ({
|
|
147136
|
+
resourceGroup,
|
|
147137
|
+
messages: getPushResultErrors(result)
|
|
147138
|
+
})).filter(({ messages }) => messages.length > 0);
|
|
147139
|
+
if (failed.length === 0) {
|
|
147140
|
+
return "Failed to push resource groups.";
|
|
147141
|
+
}
|
|
147142
|
+
return [
|
|
147143
|
+
`Failed to push ${failed.length} resource group${failed.length === 1 ? "" : "s"}:`,
|
|
147144
|
+
...failed.flatMap(({ resourceGroup, messages }) => [
|
|
147145
|
+
`- ${resourceGroup}:`,
|
|
147146
|
+
...messages.map((message) => ` - ${message}`)
|
|
147147
|
+
])
|
|
147148
|
+
].join("\n");
|
|
147149
|
+
};
|
|
147150
|
+
var nullablePolicyTotal = (value) => value === null || Number(value) === 0 ? null : Number(value);
|
|
147048
147151
|
var normalizeIgnoreRules = (value) => {
|
|
147049
147152
|
if (Array.isArray(value)) {
|
|
147050
147153
|
return value.filter(
|
|
@@ -147090,6 +147193,53 @@ var Push = class {
|
|
|
147090
147193
|
warn(message);
|
|
147091
147194
|
}
|
|
147092
147195
|
}
|
|
147196
|
+
getFunctionRuleDomain(domain2) {
|
|
147197
|
+
const region = getCloudEndpointRegion(this.projectClient.config.endpoint);
|
|
147198
|
+
if (!region) {
|
|
147199
|
+
return domain2;
|
|
147200
|
+
}
|
|
147201
|
+
const parts = domain2.split(".");
|
|
147202
|
+
if (parts.length < 3) {
|
|
147203
|
+
return domain2;
|
|
147204
|
+
}
|
|
147205
|
+
parts[0] = region;
|
|
147206
|
+
return parts.join(".");
|
|
147207
|
+
}
|
|
147208
|
+
async createDefaultFunctionRule(functionId) {
|
|
147209
|
+
let domain2 = "";
|
|
147210
|
+
try {
|
|
147211
|
+
const consoleService = await getConsoleService(this.consoleClient);
|
|
147212
|
+
const variables = await consoleService.variables();
|
|
147213
|
+
const domains = variables["_APP_DOMAIN_FUNCTIONS"].split(",").map((value) => value.trim()).filter((value) => value.length > 0);
|
|
147214
|
+
if (domains.length === 0) {
|
|
147215
|
+
throw new Error("_APP_DOMAIN_FUNCTIONS is not configured.");
|
|
147216
|
+
}
|
|
147217
|
+
domain2 = id_default2.unique() + "." + this.getFunctionRuleDomain(domains[0]);
|
|
147218
|
+
} catch (err) {
|
|
147219
|
+
this.error("Error fetching console variables.");
|
|
147220
|
+
throw err;
|
|
147221
|
+
}
|
|
147222
|
+
try {
|
|
147223
|
+
const proxyService = await getProxyService(this.projectClient);
|
|
147224
|
+
this.log(`Creating function proxy rule for ${domain2} ...`);
|
|
147225
|
+
await proxyService.createFunctionRule(domain2, functionId);
|
|
147226
|
+
} catch (err) {
|
|
147227
|
+
this.error("Error creating function rule.");
|
|
147228
|
+
throw err;
|
|
147229
|
+
}
|
|
147230
|
+
}
|
|
147231
|
+
async hasDefaultFunctionRule(functionId) {
|
|
147232
|
+
const proxyService = await getProxyService(this.projectClient);
|
|
147233
|
+
const { rules } = await proxyService.listRules({
|
|
147234
|
+
queries: [
|
|
147235
|
+
Query.limit(1),
|
|
147236
|
+
Query.equal("deploymentResourceType", "function"),
|
|
147237
|
+
Query.equal("deploymentResourceId", functionId),
|
|
147238
|
+
Query.equal("trigger", "manual")
|
|
147239
|
+
]
|
|
147240
|
+
});
|
|
147241
|
+
return rules.length > 0;
|
|
147242
|
+
}
|
|
147093
147243
|
/**
|
|
147094
147244
|
* Log an error message (respects silent mode)
|
|
147095
147245
|
*/
|
|
@@ -147153,7 +147303,11 @@ var Push = class {
|
|
|
147153
147303
|
results.settings = { success: true };
|
|
147154
147304
|
} catch (e) {
|
|
147155
147305
|
allErrors.push(e);
|
|
147156
|
-
results.settings = {
|
|
147306
|
+
results.settings = {
|
|
147307
|
+
success: false,
|
|
147308
|
+
error: getPushErrorMessage(e),
|
|
147309
|
+
errors: [e]
|
|
147310
|
+
};
|
|
147157
147311
|
}
|
|
147158
147312
|
}
|
|
147159
147313
|
if ((shouldPushAll || options.buckets) && config2.buckets && config2.buckets.length > 0) {
|
|
@@ -147236,10 +147390,28 @@ var Push = class {
|
|
|
147236
147390
|
}
|
|
147237
147391
|
if ((shouldPushAll || options.sites) && config2.sites && config2.sites.length > 0) {
|
|
147238
147392
|
try {
|
|
147393
|
+
let siteOptions = options.siteOptions;
|
|
147394
|
+
if (siteOptions?.code === void 0) {
|
|
147395
|
+
let allowSitesCodePush = cliConfig.force === true ? true : null;
|
|
147396
|
+
if (allowSitesCodePush === null) {
|
|
147397
|
+
const codeAnswer = await import_inquirer8.default.prompt(questionsPushSitesCode);
|
|
147398
|
+
allowSitesCodePush = codeAnswer.override;
|
|
147399
|
+
}
|
|
147400
|
+
siteOptions = {
|
|
147401
|
+
...siteOptions,
|
|
147402
|
+
code: allowSitesCodePush === true
|
|
147403
|
+
};
|
|
147404
|
+
}
|
|
147405
|
+
if (siteOptions.code === true && siteOptions.activate === void 0) {
|
|
147406
|
+
siteOptions = {
|
|
147407
|
+
...siteOptions,
|
|
147408
|
+
activate: cliConfig.force === true ? true : (await import_inquirer8.default.prompt(questionsPushSitesActivate)).activate
|
|
147409
|
+
};
|
|
147410
|
+
}
|
|
147239
147411
|
this.log("Pushing sites ...");
|
|
147240
147412
|
const result = await this.pushSites(
|
|
147241
147413
|
config2.sites,
|
|
147242
|
-
|
|
147414
|
+
siteOptions
|
|
147243
147415
|
);
|
|
147244
147416
|
this.success(
|
|
147245
147417
|
`Successfully pushed ${import_chalk14.default.bold(result.successfullyPushed)} sites.`
|
|
@@ -147258,6 +147430,12 @@ var Push = class {
|
|
|
147258
147430
|
}
|
|
147259
147431
|
if ((shouldPushAll || options.tables) && config2.tables && config2.tables.length > 0) {
|
|
147260
147432
|
try {
|
|
147433
|
+
const { resyncNeeded } = await checkAndApplyTablesDBChanges();
|
|
147434
|
+
if (resyncNeeded) {
|
|
147435
|
+
throw new Error(
|
|
147436
|
+
"Configuration changed after applying tablesDB deletions. Re-run the push command to continue."
|
|
147437
|
+
);
|
|
147438
|
+
}
|
|
147261
147439
|
this.log("Pushing tables ...");
|
|
147262
147440
|
const result = await this.pushTables(config2.tables, {
|
|
147263
147441
|
attempts: options.tableOptions?.attempts,
|
|
@@ -147329,46 +147507,80 @@ var Push = class {
|
|
|
147329
147507
|
}
|
|
147330
147508
|
if (settings.services) {
|
|
147331
147509
|
this.log("Applying service statuses ...");
|
|
147332
|
-
|
|
147333
|
-
|
|
147334
|
-
|
|
147335
|
-
|
|
147336
|
-
|
|
147337
|
-
|
|
147510
|
+
await Promise.all(
|
|
147511
|
+
Object.entries(settings.services).map(
|
|
147512
|
+
([service, status]) => projectService.updateService({
|
|
147513
|
+
serviceId: service,
|
|
147514
|
+
enabled: status
|
|
147515
|
+
})
|
|
147516
|
+
)
|
|
147517
|
+
);
|
|
147338
147518
|
}
|
|
147339
147519
|
if (settings.protocols) {
|
|
147340
147520
|
this.log("Applying protocol statuses ...");
|
|
147341
|
-
|
|
147342
|
-
|
|
147343
|
-
|
|
147344
|
-
|
|
147345
|
-
|
|
147346
|
-
|
|
147521
|
+
await Promise.all(
|
|
147522
|
+
Object.entries(settings.protocols).map(
|
|
147523
|
+
([protocol, status]) => projectService.updateProtocol({
|
|
147524
|
+
protocolId: protocol,
|
|
147525
|
+
enabled: status
|
|
147526
|
+
})
|
|
147527
|
+
)
|
|
147528
|
+
);
|
|
147347
147529
|
}
|
|
147348
147530
|
if (settings.auth) {
|
|
147349
147531
|
if (settings.auth.security) {
|
|
147350
147532
|
this.log("Applying auth security settings ...");
|
|
147351
|
-
|
|
147352
|
-
|
|
147353
|
-
|
|
147354
|
-
|
|
147355
|
-
|
|
147356
|
-
|
|
147357
|
-
|
|
147358
|
-
|
|
147359
|
-
|
|
147360
|
-
|
|
147361
|
-
|
|
147362
|
-
|
|
147363
|
-
|
|
147364
|
-
|
|
147365
|
-
}
|
|
147366
|
-
|
|
147367
|
-
|
|
147368
|
-
|
|
147369
|
-
|
|
147370
|
-
|
|
147371
|
-
|
|
147533
|
+
const securityUpdates = [];
|
|
147534
|
+
if (settings.auth.security.duration !== void 0) {
|
|
147535
|
+
securityUpdates.push(
|
|
147536
|
+
projectService.updateSessionDurationPolicy({
|
|
147537
|
+
duration: Number(settings.auth.security.duration)
|
|
147538
|
+
})
|
|
147539
|
+
);
|
|
147540
|
+
}
|
|
147541
|
+
if (settings.auth.security.limit !== void 0) {
|
|
147542
|
+
securityUpdates.push(
|
|
147543
|
+
projectService.updateUserLimitPolicy({
|
|
147544
|
+
total: nullablePolicyTotal(settings.auth.security.limit)
|
|
147545
|
+
})
|
|
147546
|
+
);
|
|
147547
|
+
}
|
|
147548
|
+
if (settings.auth.security.sessionsLimit !== void 0) {
|
|
147549
|
+
securityUpdates.push(
|
|
147550
|
+
projectService.updateSessionLimitPolicy({
|
|
147551
|
+
total: nullablePolicyTotal(settings.auth.security.sessionsLimit)
|
|
147552
|
+
})
|
|
147553
|
+
);
|
|
147554
|
+
}
|
|
147555
|
+
if (settings.auth.security.passwordDictionary !== void 0) {
|
|
147556
|
+
securityUpdates.push(
|
|
147557
|
+
projectService.updatePasswordDictionaryPolicy({
|
|
147558
|
+
enabled: settings.auth.security.passwordDictionary
|
|
147559
|
+
})
|
|
147560
|
+
);
|
|
147561
|
+
}
|
|
147562
|
+
if (settings.auth.security.passwordHistory !== void 0) {
|
|
147563
|
+
securityUpdates.push(
|
|
147564
|
+
projectService.updatePasswordHistoryPolicy({
|
|
147565
|
+
total: nullablePolicyTotal(settings.auth.security.passwordHistory)
|
|
147566
|
+
})
|
|
147567
|
+
);
|
|
147568
|
+
}
|
|
147569
|
+
if (settings.auth.security.personalDataCheck !== void 0) {
|
|
147570
|
+
securityUpdates.push(
|
|
147571
|
+
projectService.updatePasswordPersonalDataPolicy({
|
|
147572
|
+
enabled: settings.auth.security.personalDataCheck
|
|
147573
|
+
})
|
|
147574
|
+
);
|
|
147575
|
+
}
|
|
147576
|
+
if (settings.auth.security.sessionAlerts !== void 0) {
|
|
147577
|
+
securityUpdates.push(
|
|
147578
|
+
projectService.updateSessionAlertPolicy({
|
|
147579
|
+
enabled: settings.auth.security.sessionAlerts
|
|
147580
|
+
})
|
|
147581
|
+
);
|
|
147582
|
+
}
|
|
147583
|
+
await Promise.all(securityUpdates);
|
|
147372
147584
|
if (settings.auth.security.mockNumbers !== void 0) {
|
|
147373
147585
|
const remoteMockNumbers = [];
|
|
147374
147586
|
const limit = 100;
|
|
@@ -147391,40 +147603,50 @@ var Push = class {
|
|
|
147391
147603
|
mockNumber.otp
|
|
147392
147604
|
])
|
|
147393
147605
|
);
|
|
147606
|
+
const mockNumberUpdates = [];
|
|
147394
147607
|
for (const remoteMockNumber of remoteMockNumbers) {
|
|
147395
147608
|
const desiredOtp = desiredMockNumbersByPhone.get(
|
|
147396
147609
|
remoteMockNumber.number
|
|
147397
147610
|
);
|
|
147398
147611
|
if (desiredOtp === void 0) {
|
|
147399
|
-
|
|
147400
|
-
|
|
147401
|
-
|
|
147612
|
+
mockNumberUpdates.push(
|
|
147613
|
+
projectService.deleteMockPhone({
|
|
147614
|
+
number: remoteMockNumber.number
|
|
147615
|
+
})
|
|
147616
|
+
);
|
|
147402
147617
|
continue;
|
|
147403
147618
|
}
|
|
147404
147619
|
if (remoteMockNumber.otp !== desiredOtp) {
|
|
147405
|
-
|
|
147406
|
-
|
|
147407
|
-
|
|
147408
|
-
|
|
147620
|
+
mockNumberUpdates.push(
|
|
147621
|
+
projectService.updateMockPhone({
|
|
147622
|
+
number: remoteMockNumber.number,
|
|
147623
|
+
otp: desiredOtp
|
|
147624
|
+
})
|
|
147625
|
+
);
|
|
147409
147626
|
}
|
|
147410
147627
|
desiredMockNumbersByPhone.delete(remoteMockNumber.number);
|
|
147411
147628
|
}
|
|
147412
147629
|
for (const [phone, otp] of desiredMockNumbersByPhone) {
|
|
147413
|
-
|
|
147414
|
-
|
|
147415
|
-
|
|
147416
|
-
|
|
147630
|
+
mockNumberUpdates.push(
|
|
147631
|
+
projectService.createMockPhone({
|
|
147632
|
+
number: phone,
|
|
147633
|
+
otp
|
|
147634
|
+
})
|
|
147635
|
+
);
|
|
147417
147636
|
}
|
|
147637
|
+
await Promise.all(mockNumberUpdates);
|
|
147418
147638
|
}
|
|
147419
147639
|
}
|
|
147420
147640
|
if (settings.auth.methods) {
|
|
147421
147641
|
this.log("Applying auth methods statuses ...");
|
|
147422
|
-
|
|
147423
|
-
|
|
147424
|
-
|
|
147425
|
-
|
|
147426
|
-
|
|
147427
|
-
|
|
147642
|
+
await Promise.all(
|
|
147643
|
+
Object.entries(settings.auth.methods).map(
|
|
147644
|
+
([method, status]) => projectService.updateAuthMethod({
|
|
147645
|
+
methodId: method,
|
|
147646
|
+
enabled: status
|
|
147647
|
+
})
|
|
147648
|
+
)
|
|
147649
|
+
);
|
|
147428
147650
|
}
|
|
147429
147651
|
}
|
|
147430
147652
|
}
|
|
@@ -147715,24 +147937,7 @@ var Push = class {
|
|
|
147715
147937
|
runtimeSpecification: func.runtimeSpecification,
|
|
147716
147938
|
deploymentRetention: func.deploymentRetention
|
|
147717
147939
|
});
|
|
147718
|
-
|
|
147719
|
-
try {
|
|
147720
|
-
const consoleService = await getConsoleService(
|
|
147721
|
-
this.consoleClient
|
|
147722
|
-
);
|
|
147723
|
-
const variables = await consoleService.variables();
|
|
147724
|
-
domain2 = id_default2.unique() + "." + variables["_APP_DOMAIN_FUNCTIONS"];
|
|
147725
|
-
} catch (err) {
|
|
147726
|
-
this.error("Error fetching console variables.");
|
|
147727
|
-
throw err;
|
|
147728
|
-
}
|
|
147729
|
-
try {
|
|
147730
|
-
const proxyService = await getProxyService(this.projectClient);
|
|
147731
|
-
await proxyService.createFunctionRule(domain2, func.$id);
|
|
147732
|
-
} catch (err) {
|
|
147733
|
-
this.error("Error creating function rule.");
|
|
147734
|
-
throw err;
|
|
147735
|
-
}
|
|
147940
|
+
await this.createDefaultFunctionRule(func.$id);
|
|
147736
147941
|
updaterRow.update({ status: "Created" });
|
|
147737
147942
|
} catch (e) {
|
|
147738
147943
|
errors.push(e);
|
|
@@ -147741,6 +147946,18 @@ var Push = class {
|
|
|
147741
147946
|
});
|
|
147742
147947
|
return;
|
|
147743
147948
|
}
|
|
147949
|
+
} else {
|
|
147950
|
+
try {
|
|
147951
|
+
if (!await this.hasDefaultFunctionRule(func.$id)) {
|
|
147952
|
+
await this.createDefaultFunctionRule(func.$id);
|
|
147953
|
+
}
|
|
147954
|
+
} catch (e) {
|
|
147955
|
+
errors.push(e);
|
|
147956
|
+
updaterRow.fail({
|
|
147957
|
+
errorMessage: e.message ?? "General error occurs please try again"
|
|
147958
|
+
});
|
|
147959
|
+
return;
|
|
147960
|
+
}
|
|
147744
147961
|
}
|
|
147745
147962
|
if (withVariables) {
|
|
147746
147963
|
updaterRow.update({ status: "Updating variables" }).replaceSpinner(SPINNER_DOTS);
|
|
@@ -148842,10 +149059,11 @@ async function createPushInstance(options = {
|
|
|
148842
149059
|
silent: false,
|
|
148843
149060
|
requiresConsoleAuth: false
|
|
148844
149061
|
}) {
|
|
148845
|
-
const { silent, requiresConsoleAuth } = options;
|
|
149062
|
+
const { silent, requiresConsoleAuth, organizationId } = options;
|
|
148846
149063
|
const projectClient2 = await sdkForProject();
|
|
148847
149064
|
const consoleClient = await sdkForConsole({
|
|
148848
|
-
requiresAuth: requiresConsoleAuth
|
|
149065
|
+
requiresAuth: requiresConsoleAuth,
|
|
149066
|
+
organizationId
|
|
148849
149067
|
});
|
|
148850
149068
|
return new Push(projectClient2, consoleClient, silent);
|
|
148851
149069
|
}
|
|
@@ -148876,20 +149094,11 @@ var pushResources = async ({
|
|
|
148876
149094
|
activateFunctionsDeployment = activateAnswer.activate;
|
|
148877
149095
|
}
|
|
148878
149096
|
const sites2 = localConfig.getSites();
|
|
148879
|
-
|
|
148880
|
-
let activateSitesDeployment = cliConfig.force === true ? true : void 0;
|
|
148881
|
-
if (sites2.length > 0 && allowSitesCodePush === null) {
|
|
148882
|
-
const codeAnswer = await import_inquirer8.default.prompt(questionsPushSitesCode);
|
|
148883
|
-
allowSitesCodePush = codeAnswer.override;
|
|
148884
|
-
}
|
|
148885
|
-
if (sites2.length > 0 && allowSitesCodePush === true && activateSitesDeployment === void 0) {
|
|
148886
|
-
const activateAnswer = await import_inquirer8.default.prompt(questionsPushSitesActivate);
|
|
148887
|
-
activateSitesDeployment = activateAnswer.activate;
|
|
148888
|
-
}
|
|
149097
|
+
const project2 = localConfig.getProject();
|
|
148889
149098
|
const pushInstance = await createPushInstance({
|
|
148890
|
-
requiresConsoleAuth: true
|
|
149099
|
+
requiresConsoleAuth: true,
|
|
149100
|
+
organizationId: project2.organizationId
|
|
148891
149101
|
});
|
|
148892
|
-
const project2 = localConfig.getProject();
|
|
148893
149102
|
const config2 = {
|
|
148894
149103
|
organizationId: project2.organizationId,
|
|
148895
149104
|
projectId: project2.projectId ?? "",
|
|
@@ -148912,7 +149121,7 @@ var pushResources = async ({
|
|
|
148912
149121
|
"Configuration validation failed",
|
|
148913
149122
|
config2
|
|
148914
149123
|
);
|
|
148915
|
-
await pushInstance.pushResources(config2, {
|
|
149124
|
+
const result = await pushInstance.pushResources(config2, {
|
|
148916
149125
|
all: cliConfig.all,
|
|
148917
149126
|
skipDeprecated,
|
|
148918
149127
|
functionOptions: {
|
|
@@ -148922,12 +149131,13 @@ var pushResources = async ({
|
|
|
148922
149131
|
logs: functionOptions?.logs
|
|
148923
149132
|
},
|
|
148924
149133
|
siteOptions: {
|
|
148925
|
-
code: allowSitesCodePush === true,
|
|
148926
|
-
activate: activateSitesDeployment ?? true,
|
|
148927
149134
|
withVariables: false,
|
|
148928
149135
|
logs: siteOptions?.logs
|
|
148929
149136
|
}
|
|
148930
149137
|
});
|
|
149138
|
+
if (result.errors.length > 0) {
|
|
149139
|
+
throw new Error(formatPushResourceErrors(result.results));
|
|
149140
|
+
}
|
|
148931
149141
|
} else {
|
|
148932
149142
|
const actions = {
|
|
148933
149143
|
settings: pushSettings,
|
|
@@ -149006,10 +149216,11 @@ var pushSettings = async () => {
|
|
|
149006
149216
|
}
|
|
149007
149217
|
try {
|
|
149008
149218
|
log("Pushing project settings ...");
|
|
149219
|
+
const config2 = localConfig.getProject();
|
|
149009
149220
|
const pushInstance = await createPushInstance({
|
|
149010
|
-
requiresConsoleAuth: true
|
|
149221
|
+
requiresConsoleAuth: true,
|
|
149222
|
+
organizationId: config2.organizationId ?? resolvedOrganizationId
|
|
149011
149223
|
});
|
|
149012
|
-
const config2 = localConfig.getProject();
|
|
149013
149224
|
await pushInstance.pushSettings({
|
|
149014
149225
|
projectId: config2.projectId,
|
|
149015
149226
|
organizationId: config2.organizationId ?? resolvedOrganizationId,
|
|
@@ -149098,7 +149309,10 @@ var pushSite = async ({
|
|
|
149098
149309
|
}
|
|
149099
149310
|
log("Pushing sites ...");
|
|
149100
149311
|
const pushStartTime = Date.now();
|
|
149101
|
-
const pushInstance = await createPushInstance(
|
|
149312
|
+
const pushInstance = await createPushInstance({
|
|
149313
|
+
requiresConsoleAuth: true,
|
|
149314
|
+
organizationId: localConfig.getProject().organizationId
|
|
149315
|
+
});
|
|
149102
149316
|
const result = await pushInstance.pushSites(
|
|
149103
149317
|
withResolvedResourcePaths("sites", sites2),
|
|
149104
149318
|
{
|
|
@@ -149153,7 +149367,7 @@ var pushSite = async ({
|
|
|
149153
149367
|
}
|
|
149154
149368
|
if (cliConfig.verbose) {
|
|
149155
149369
|
errors.forEach((e) => {
|
|
149156
|
-
console.error(e);
|
|
149370
|
+
console.error(formatErrorForLog(e));
|
|
149157
149371
|
});
|
|
149158
149372
|
}
|
|
149159
149373
|
};
|
|
@@ -149236,7 +149450,10 @@ var pushFunction = async ({
|
|
|
149236
149450
|
}
|
|
149237
149451
|
log("Pushing functions ...");
|
|
149238
149452
|
const pushStartTime = Date.now();
|
|
149239
|
-
const pushInstance = await createPushInstance(
|
|
149453
|
+
const pushInstance = await createPushInstance({
|
|
149454
|
+
requiresConsoleAuth: true,
|
|
149455
|
+
organizationId: localConfig.getProject().organizationId
|
|
149456
|
+
});
|
|
149240
149457
|
const result = await pushInstance.pushFunctions(
|
|
149241
149458
|
withResolvedResourcePaths("functions", functions2),
|
|
149242
149459
|
{
|
|
@@ -149291,7 +149508,7 @@ var pushFunction = async ({
|
|
|
149291
149508
|
}
|
|
149292
149509
|
if (cliConfig.verbose) {
|
|
149293
149510
|
errors.forEach((e) => {
|
|
149294
|
-
console.error(e);
|
|
149511
|
+
console.error(formatErrorForLog(e));
|
|
149295
149512
|
});
|
|
149296
149513
|
}
|
|
149297
149514
|
};
|
|
@@ -149436,7 +149653,7 @@ var pushTable = async ({
|
|
|
149436
149653
|
success2(`Successfully pushed ${successfullyPushed} tables.`);
|
|
149437
149654
|
}
|
|
149438
149655
|
if (cliConfig.verbose) {
|
|
149439
|
-
errors.forEach((e) => console.error(e));
|
|
149656
|
+
errors.forEach((e) => console.error(formatErrorForLog(e)));
|
|
149440
149657
|
}
|
|
149441
149658
|
};
|
|
149442
149659
|
var pushCollection = async () => {
|
|
@@ -149500,7 +149717,7 @@ var pushCollection = async () => {
|
|
|
149500
149717
|
success2(`Successfully pushed ${successfullyPushed} collections.`);
|
|
149501
149718
|
}
|
|
149502
149719
|
if (cliConfig.verbose) {
|
|
149503
|
-
errors.forEach((e) => console.error(e));
|
|
149720
|
+
errors.forEach((e) => console.error(formatErrorForLog(e)));
|
|
149504
149721
|
}
|
|
149505
149722
|
};
|
|
149506
149723
|
var pushBucket = async () => {
|
|
@@ -149550,7 +149767,7 @@ var pushBucket = async () => {
|
|
|
149550
149767
|
success2(`Successfully pushed ${successfullyPushed} buckets.`);
|
|
149551
149768
|
}
|
|
149552
149769
|
if (cliConfig.verbose) {
|
|
149553
|
-
errors.forEach((e) => console.error(e));
|
|
149770
|
+
errors.forEach((e) => console.error(formatErrorForLog(e)));
|
|
149554
149771
|
}
|
|
149555
149772
|
};
|
|
149556
149773
|
var pushTeam = async () => {
|
|
@@ -149600,7 +149817,7 @@ var pushTeam = async () => {
|
|
|
149600
149817
|
success2(`Successfully pushed ${successfullyPushed} teams.`);
|
|
149601
149818
|
}
|
|
149602
149819
|
if (cliConfig.verbose) {
|
|
149603
|
-
errors.forEach((e) => console.error(e));
|
|
149820
|
+
errors.forEach((e) => console.error(formatErrorForLog(e)));
|
|
149604
149821
|
}
|
|
149605
149822
|
};
|
|
149606
149823
|
var pushWebhook = async () => {
|
|
@@ -149650,7 +149867,7 @@ var pushWebhook = async () => {
|
|
|
149650
149867
|
success2(`Successfully pushed ${successfullyPushed} webhooks.`);
|
|
149651
149868
|
}
|
|
149652
149869
|
if (cliConfig.verbose) {
|
|
149653
|
-
errors.forEach((e) => console.error(e));
|
|
149870
|
+
errors.forEach((e) => console.error(formatErrorForLog(e)));
|
|
149654
149871
|
}
|
|
149655
149872
|
};
|
|
149656
149873
|
var pushMessagingTopic = async () => {
|
|
@@ -149700,7 +149917,7 @@ var pushMessagingTopic = async () => {
|
|
|
149700
149917
|
success2(`Successfully pushed ${successfullyPushed} topics.`);
|
|
149701
149918
|
}
|
|
149702
149919
|
if (cliConfig.verbose) {
|
|
149703
|
-
errors.forEach((e) => console.error(e));
|
|
149920
|
+
errors.forEach((e) => console.error(formatErrorForLog(e)));
|
|
149704
149921
|
}
|
|
149705
149922
|
};
|
|
149706
149923
|
var push = new Command("push").description(commandDescriptions["push"]).action(actionRunner(() => pushResources({ skipDeprecated: true })));
|