appwrite-cli 18.0.1 → 18.2.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/bundle-win-arm64.mjs +1808 -985
- package/dist/cli.cjs +1808 -985
- package/dist/index.cjs +331 -33
- package/dist/index.js +331 -33
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/run.d.ts.map +1 -1
- package/dist/lib/commands/update.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +2 -2
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/emulation/docker.d.ts +1 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -1
- package/dist/lib/emulation/utils.d.ts +1 -1
- package/dist/lib/questions.d.ts.map +1 -1
- package/dist/lib/sdks.d.ts +1 -1
- package/dist/lib/sdks.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/package.json +9 -5
package/dist/index.cjs
CHANGED
|
@@ -35485,7 +35485,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
35485
35485
|
}
|
|
35486
35486
|
return positiveOption || option2;
|
|
35487
35487
|
};
|
|
35488
|
-
const
|
|
35488
|
+
const getErrorMessage2 = (option2) => {
|
|
35489
35489
|
const bestOption = findBestOptionFromValue(option2);
|
|
35490
35490
|
const optionKey = bestOption.attributeName();
|
|
35491
35491
|
const source = this.getOptionValueSource(optionKey);
|
|
@@ -35494,7 +35494,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
35494
35494
|
}
|
|
35495
35495
|
return `option '${bestOption.flags}'`;
|
|
35496
35496
|
};
|
|
35497
|
-
const message = `error: ${
|
|
35497
|
+
const message = `error: ${getErrorMessage2(option)} cannot be used with ${getErrorMessage2(conflictingOption)}`;
|
|
35498
35498
|
this.error(message, { code: "commander.conflictingOption" });
|
|
35499
35499
|
}
|
|
35500
35500
|
/**
|
|
@@ -64957,6 +64957,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
64957
64957
|
var import_fs7 = __toESM(require("fs"), 1);
|
|
64958
64958
|
var import_path6 = __toESM(require("path"), 1);
|
|
64959
64959
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
64960
|
+
var import_node_util = require("node:util");
|
|
64960
64961
|
var import_dotenv = __toESM(require_main(), 1);
|
|
64961
64962
|
var import_chalk9 = __toESM(require_source(), 1);
|
|
64962
64963
|
var import_inquirer3 = __toESM(require_inquirer(), 1);
|
|
@@ -65007,7 +65008,7 @@ var id_default = ID;
|
|
|
65007
65008
|
// lib/constants.ts
|
|
65008
65009
|
var SDK_TITLE = "Appwrite";
|
|
65009
65010
|
var SDK_TITLE_LOWER = "appwrite";
|
|
65010
|
-
var SDK_VERSION = "18.
|
|
65011
|
+
var SDK_VERSION = "18.2.0";
|
|
65011
65012
|
var SDK_LOGO = "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n";
|
|
65012
65013
|
var EXECUTABLE_NAME = "appwrite";
|
|
65013
65014
|
var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -65026,6 +65027,7 @@ var CONFIG_RESOURCE_KEYS = [
|
|
|
65026
65027
|
"tablesDB",
|
|
65027
65028
|
"tables",
|
|
65028
65029
|
"teams",
|
|
65030
|
+
"webhooks",
|
|
65029
65031
|
"collections"
|
|
65030
65032
|
];
|
|
65031
65033
|
var TOP_LEVEL_RESOURCE_ARRAY_KEYS = new Set(
|
|
@@ -79283,6 +79285,8 @@ var getSafeDirectoryName = (value, fallback) => {
|
|
|
79283
79285
|
var siteRequiresBuildCommand = (site) => {
|
|
79284
79286
|
return !(site.framework === "other" && site.adapter === "static");
|
|
79285
79287
|
};
|
|
79288
|
+
var WINDOWS_EXECUTABLE_NAME = `${EXECUTABLE_NAME.toLowerCase()}.exe`;
|
|
79289
|
+
var HOMEBREW_FORMULA_NAME = EXECUTABLE_NAME.toLowerCase();
|
|
79286
79290
|
var isCloudHostname = (hostname3) => hostname3 === "cloud.appwrite.io" || hostname3.endsWith(".cloud.appwrite.io");
|
|
79287
79291
|
var getConsoleBaseUrl = (endpoint) => {
|
|
79288
79292
|
try {
|
|
@@ -103666,7 +103670,7 @@ var package_default = {
|
|
|
103666
103670
|
type: "module",
|
|
103667
103671
|
homepage: "https://appwrite.io/support",
|
|
103668
103672
|
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",
|
|
103669
|
-
version: "18.0
|
|
103673
|
+
version: "18.2.0",
|
|
103670
103674
|
license: "BSD-3-Clause",
|
|
103671
103675
|
main: "dist/index.cjs",
|
|
103672
103676
|
module: "dist/index.js",
|
|
@@ -103698,9 +103702,9 @@ var package_default = {
|
|
|
103698
103702
|
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
|
|
103699
103703
|
"build:runtime": "npm run build:lib:runtime && npm run build:cli",
|
|
103700
103704
|
"build:lib:runtime": "npm run build:lib:esm && npm run build:lib:cjs",
|
|
103701
|
-
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
|
|
103702
|
-
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
|
|
103703
|
-
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
|
|
103705
|
+
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --external:terminal-image --outfile=dist/index.js",
|
|
103706
|
+
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:terminal-image --outfile=dist/index.cjs",
|
|
103707
|
+
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --external:terminal-image --outfile=dist/cli.cjs",
|
|
103704
103708
|
lint: "eslint .",
|
|
103705
103709
|
format: 'prettier --write "**/*.{js,ts,json,md}"',
|
|
103706
103710
|
generate: "tsx scripts/generate-commands.ts",
|
|
@@ -103711,7 +103715,7 @@ var package_default = {
|
|
|
103711
103715
|
"mac-x64": "bun build cli.ts --compile --sourcemap=inline --target=bun-darwin-x64 --outfile build/appwrite-cli-darwin-x64",
|
|
103712
103716
|
"mac-arm64": "bun build cli.ts --compile --sourcemap=inline --target=bun-darwin-arm64 --outfile build/appwrite-cli-darwin-arm64",
|
|
103713
103717
|
"windows-x64": "bun build cli.ts --compile --sourcemap=inline --target=bun-windows-x64 --outfile build/appwrite-cli-win-x64.exe",
|
|
103714
|
-
"windows-arm64": "esbuild cli.ts --bundle --loader:.hbs=text --platform=node --target=node18 --format=esm --external:fsevents --outfile=dist/bundle-win-arm64.mjs && pkg dist/bundle-win-arm64.mjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
|
|
103718
|
+
"windows-arm64": "esbuild cli.ts --bundle --loader:.hbs=text --platform=node --target=node18 --format=esm --external:fsevents --external:terminal-image --outfile=dist/bundle-win-arm64.mjs && pkg dist/bundle-win-arm64.mjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
|
|
103715
103719
|
},
|
|
103716
103720
|
dependencies: {
|
|
103717
103721
|
"@appwrite.io/console": "~9.1.0",
|
|
@@ -103730,9 +103734,13 @@ var package_default = {
|
|
|
103730
103734
|
"string-width": "^7.2.0",
|
|
103731
103735
|
tail: "^2.2.6",
|
|
103732
103736
|
tar: "^7.4.3",
|
|
103737
|
+
"terminal-image": "^3.1.1",
|
|
103733
103738
|
undici: "^6.24.0",
|
|
103734
103739
|
zod: "^4.3.5"
|
|
103735
103740
|
},
|
|
103741
|
+
overrides: {
|
|
103742
|
+
phin: "3.7.1"
|
|
103743
|
+
},
|
|
103736
103744
|
devDependencies: {
|
|
103737
103745
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
103738
103746
|
"@typescript-eslint/parser": "^8.0.0",
|
|
@@ -105042,9 +105050,9 @@ var import_chalk5 = __toESM(require_source(), 1);
|
|
|
105042
105050
|
|
|
105043
105051
|
// lib/sdks.ts
|
|
105044
105052
|
var import_os4 = __toESM(require("os"), 1);
|
|
105045
|
-
var sdkForConsole = async (requiresAuth = true) => {
|
|
105053
|
+
var sdkForConsole = async (requiresAuth = true, endpointOverride) => {
|
|
105046
105054
|
const client = new Client();
|
|
105047
|
-
const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
|
|
105055
|
+
const endpoint = endpointOverride || globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
|
|
105048
105056
|
const cookie = globalConfig2.getCookie();
|
|
105049
105057
|
const selfSigned = globalConfig2.getSelfSigned();
|
|
105050
105058
|
if (requiresAuth && cookie === "") {
|
|
@@ -105165,11 +105173,23 @@ var getWebhooksService = async (sdk) => {
|
|
|
105165
105173
|
|
|
105166
105174
|
// lib/questions.ts
|
|
105167
105175
|
var whenOverride = (answers) => answers.override === void 0 ? true : answers.override;
|
|
105176
|
+
var buildSelectionLabel = (name, id) => `${name} (${id})`;
|
|
105177
|
+
var extractSelectionId = (value) => {
|
|
105178
|
+
const match = value.match(/\(([^()]+)\)$/);
|
|
105179
|
+
return match ? match[1] : value;
|
|
105180
|
+
};
|
|
105181
|
+
var getInitProjectOverrideMessage = () => {
|
|
105182
|
+
const projectName = localConfig.getProject().projectName;
|
|
105183
|
+
if (projectName) {
|
|
105184
|
+
return `A project is already linked to this directory (${projectName}). Override?`;
|
|
105185
|
+
}
|
|
105186
|
+
return "A project is already linked to this directory. Override?";
|
|
105187
|
+
};
|
|
105168
105188
|
var questionsInitProject = [
|
|
105169
105189
|
{
|
|
105170
105190
|
type: "confirm",
|
|
105171
105191
|
name: "override",
|
|
105172
|
-
message:
|
|
105192
|
+
message: getInitProjectOverrideMessage(),
|
|
105173
105193
|
when() {
|
|
105174
105194
|
return Object.keys(localConfig.getProject()).length !== 0;
|
|
105175
105195
|
}
|
|
@@ -105178,14 +105198,14 @@ var questionsInitProject = [
|
|
|
105178
105198
|
type: "list",
|
|
105179
105199
|
name: "start",
|
|
105180
105200
|
when: whenOverride,
|
|
105181
|
-
message: "
|
|
105201
|
+
message: "Select a setup method:",
|
|
105182
105202
|
choices: [
|
|
105183
105203
|
{
|
|
105184
|
-
name: "Create new project",
|
|
105204
|
+
name: "Create a new project",
|
|
105185
105205
|
value: "new"
|
|
105186
105206
|
},
|
|
105187
105207
|
{
|
|
105188
|
-
name: "Link directory to an existing project",
|
|
105208
|
+
name: "Link this directory to an existing project",
|
|
105189
105209
|
value: "existing"
|
|
105190
105210
|
}
|
|
105191
105211
|
]
|
|
@@ -105193,7 +105213,7 @@ var questionsInitProject = [
|
|
|
105193
105213
|
{
|
|
105194
105214
|
type: "search-list",
|
|
105195
105215
|
name: "organization",
|
|
105196
|
-
message: "Choose your organization",
|
|
105216
|
+
message: "Choose your organization:",
|
|
105197
105217
|
choices: async () => {
|
|
105198
105218
|
const client = await sdkForConsole(true);
|
|
105199
105219
|
const { teams } = isCloud() ? await paginate(
|
|
@@ -105212,9 +105232,10 @@ var questionsInitProject = [
|
|
|
105212
105232
|
"teams"
|
|
105213
105233
|
);
|
|
105214
105234
|
const choices = teams.map((team, _idx) => {
|
|
105235
|
+
const label = buildSelectionLabel(team.name, team["$id"]);
|
|
105215
105236
|
return {
|
|
105216
|
-
name:
|
|
105217
|
-
value:
|
|
105237
|
+
name: label,
|
|
105238
|
+
value: label
|
|
105218
105239
|
};
|
|
105219
105240
|
});
|
|
105220
105241
|
if (choices.length == 0) {
|
|
@@ -105243,13 +105264,13 @@ var questionsInitProject = [
|
|
|
105243
105264
|
{
|
|
105244
105265
|
type: "search-list",
|
|
105245
105266
|
name: "project",
|
|
105246
|
-
message:
|
|
105267
|
+
message: "Choose your project:",
|
|
105247
105268
|
choices: async (answers) => {
|
|
105248
105269
|
const queries = [
|
|
105249
105270
|
JSON.stringify({
|
|
105250
105271
|
method: "equal",
|
|
105251
105272
|
attribute: "teamId",
|
|
105252
|
-
values: [answers.organization]
|
|
105273
|
+
values: [extractSelectionId(answers.organization)]
|
|
105253
105274
|
}),
|
|
105254
105275
|
JSON.stringify({ method: "orderDesc", attribute: "$id" })
|
|
105255
105276
|
];
|
|
@@ -105261,14 +105282,10 @@ var questionsInitProject = [
|
|
|
105261
105282
|
queries
|
|
105262
105283
|
);
|
|
105263
105284
|
const choices = projects.map((project) => {
|
|
105264
|
-
const label =
|
|
105285
|
+
const label = buildSelectionLabel(project.name, project["$id"]);
|
|
105265
105286
|
return {
|
|
105266
105287
|
name: label,
|
|
105267
|
-
|
|
105268
|
-
value: {
|
|
105269
|
-
$id: project["$id"],
|
|
105270
|
-
region: project.region || ""
|
|
105271
|
-
}
|
|
105288
|
+
value: label
|
|
105272
105289
|
};
|
|
105273
105290
|
});
|
|
105274
105291
|
if (choices.length === 0) {
|
|
@@ -106837,8 +106854,18 @@ var DEPLOYMENT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
|
106837
106854
|
var DEPLOYMENT_TIMEOUT_MINUTES = Math.round(
|
|
106838
106855
|
DEPLOYMENT_TIMEOUT_MS / (60 * 1e3)
|
|
106839
106856
|
);
|
|
106857
|
+
var SITE_SCREENSHOT_FINALIZATION_TIMEOUT_MS = 30 * 1e3;
|
|
106858
|
+
var SITE_SCREENSHOT_BUCKET_ID = "screenshots";
|
|
106859
|
+
var SITE_SCREENSHOT_PREVIEW_WIDTH = 480;
|
|
106860
|
+
var SITE_SCREENSHOT_PREVIEW_HEIGHT = 270;
|
|
106861
|
+
var SITE_TERMINAL_PREVIEW_TARGET_WIDTH = 72;
|
|
106862
|
+
var SITE_TERMINAL_PREVIEW_MAX_WIDTH = 80;
|
|
106863
|
+
var SITE_TERMINAL_PREVIEW_MAX_HEIGHT = 22;
|
|
106864
|
+
var SITE_TERMINAL_PREVIEW_MIN_HEIGHT = 8;
|
|
106840
106865
|
var WAITING_JOKE_THRESHOLD_MS = 30 * 1e3;
|
|
106841
106866
|
var WAITING_JOKE_URL = "https://xkcd.com/303/";
|
|
106867
|
+
var ANSI_RESET = "\x1B[0m";
|
|
106868
|
+
var terminalImageModulePromise;
|
|
106842
106869
|
function getDeploymentProgressText(status, waitingSince) {
|
|
106843
106870
|
if (status === "waiting" && waitingSince !== null && Date.now() - waitingSince >= WAITING_JOKE_THRESHOLD_MS) {
|
|
106844
106871
|
return `Still waiting... ${WAITING_JOKE_URL}`;
|
|
@@ -106848,6 +106875,184 @@ function getDeploymentProgressText(status, waitingSince) {
|
|
|
106848
106875
|
function getDeploymentTimeoutErrorMessage() {
|
|
106849
106876
|
return `Deployment got stuck for more than ${DEPLOYMENT_TIMEOUT_MINUTES} minutes`;
|
|
106850
106877
|
}
|
|
106878
|
+
async function getTerminalImage() {
|
|
106879
|
+
terminalImageModulePromise ??= import("terminal-image").then(
|
|
106880
|
+
(module2) => module2.default
|
|
106881
|
+
);
|
|
106882
|
+
return terminalImageModulePromise;
|
|
106883
|
+
}
|
|
106884
|
+
function getErrorMessage(error49) {
|
|
106885
|
+
if (error49 instanceof Error && error49.message.trim().length > 0) {
|
|
106886
|
+
return error49.message.trim();
|
|
106887
|
+
}
|
|
106888
|
+
if (Array.isArray(error49)) {
|
|
106889
|
+
const messages = error49.map((entry) => getErrorMessage(entry)).filter((entry) => entry !== "Unknown error");
|
|
106890
|
+
if (messages.length > 0) {
|
|
106891
|
+
return messages.join("; ");
|
|
106892
|
+
}
|
|
106893
|
+
}
|
|
106894
|
+
if (typeof error49 === "string" && error49.trim().length > 0) {
|
|
106895
|
+
return error49.trim();
|
|
106896
|
+
}
|
|
106897
|
+
if (error49 && typeof error49 === "object") {
|
|
106898
|
+
const objectMessage = Reflect.get(error49, "message");
|
|
106899
|
+
if (typeof objectMessage === "string" && objectMessage.trim().length > 0) {
|
|
106900
|
+
return objectMessage.trim();
|
|
106901
|
+
}
|
|
106902
|
+
try {
|
|
106903
|
+
return JSON.stringify(error49);
|
|
106904
|
+
} catch (_serializationError) {
|
|
106905
|
+
}
|
|
106906
|
+
}
|
|
106907
|
+
return "Unknown error";
|
|
106908
|
+
}
|
|
106909
|
+
function getSiteDeploymentScreenshots(deployment) {
|
|
106910
|
+
const screenshotLight = typeof deployment["screenshotLight"] === "string" && deployment["screenshotLight"].trim().length > 0 ? deployment["screenshotLight"] : void 0;
|
|
106911
|
+
const screenshotDark = typeof deployment["screenshotDark"] === "string" && deployment["screenshotDark"].trim().length > 0 ? deployment["screenshotDark"] : void 0;
|
|
106912
|
+
return {
|
|
106913
|
+
screenshotLight,
|
|
106914
|
+
screenshotDark
|
|
106915
|
+
};
|
|
106916
|
+
}
|
|
106917
|
+
function hasSiteDeploymentScreenshots(deployment) {
|
|
106918
|
+
const { screenshotLight, screenshotDark } = getSiteDeploymentScreenshots(deployment);
|
|
106919
|
+
return Boolean(screenshotLight || screenshotDark);
|
|
106920
|
+
}
|
|
106921
|
+
function shouldRenderSiteTerminalPreview() {
|
|
106922
|
+
return Boolean(process.stdout.isTTY) && !cliConfig.json && !cliConfig.raw;
|
|
106923
|
+
}
|
|
106924
|
+
function getSiteTerminalPreviewWidth() {
|
|
106925
|
+
const columns = process.stdout.columns ?? 80;
|
|
106926
|
+
return Math.max(
|
|
106927
|
+
16,
|
|
106928
|
+
Math.min(
|
|
106929
|
+
columns - 4,
|
|
106930
|
+
SITE_TERMINAL_PREVIEW_TARGET_WIDTH,
|
|
106931
|
+
SITE_TERMINAL_PREVIEW_MAX_WIDTH
|
|
106932
|
+
)
|
|
106933
|
+
);
|
|
106934
|
+
}
|
|
106935
|
+
function getSiteTerminalPreviewHeight() {
|
|
106936
|
+
const rows = process.stdout.rows ?? 24;
|
|
106937
|
+
return Math.max(
|
|
106938
|
+
SITE_TERMINAL_PREVIEW_MIN_HEIGHT,
|
|
106939
|
+
Math.min(rows - 10, SITE_TERMINAL_PREVIEW_MAX_HEIGHT)
|
|
106940
|
+
);
|
|
106941
|
+
}
|
|
106942
|
+
async function renderImageBufferToTerminalPreview(buffer) {
|
|
106943
|
+
const terminalImage = await getTerminalImage();
|
|
106944
|
+
const originalTermProgram = process.env.TERM_PROGRAM;
|
|
106945
|
+
const originalTermProgramVersion = process.env.TERM_PROGRAM_VERSION;
|
|
106946
|
+
const originalKonsoleVersion = process.env.KONSOLE_VERSION;
|
|
106947
|
+
const originalKittyWindowId = process.env.KITTY_WINDOW_ID;
|
|
106948
|
+
delete process.env.TERM_PROGRAM;
|
|
106949
|
+
delete process.env.TERM_PROGRAM_VERSION;
|
|
106950
|
+
delete process.env.KONSOLE_VERSION;
|
|
106951
|
+
delete process.env.KITTY_WINDOW_ID;
|
|
106952
|
+
try {
|
|
106953
|
+
return await terminalImage.buffer(buffer, {
|
|
106954
|
+
width: getSiteTerminalPreviewWidth(),
|
|
106955
|
+
height: getSiteTerminalPreviewHeight(),
|
|
106956
|
+
preserveAspectRatio: true
|
|
106957
|
+
});
|
|
106958
|
+
} finally {
|
|
106959
|
+
if (originalTermProgram === void 0) {
|
|
106960
|
+
delete process.env.TERM_PROGRAM;
|
|
106961
|
+
} else {
|
|
106962
|
+
process.env.TERM_PROGRAM = originalTermProgram;
|
|
106963
|
+
}
|
|
106964
|
+
if (originalTermProgramVersion === void 0) {
|
|
106965
|
+
delete process.env.TERM_PROGRAM_VERSION;
|
|
106966
|
+
} else {
|
|
106967
|
+
process.env.TERM_PROGRAM_VERSION = originalTermProgramVersion;
|
|
106968
|
+
}
|
|
106969
|
+
if (originalKonsoleVersion === void 0) {
|
|
106970
|
+
delete process.env.KONSOLE_VERSION;
|
|
106971
|
+
} else {
|
|
106972
|
+
process.env.KONSOLE_VERSION = originalKonsoleVersion;
|
|
106973
|
+
}
|
|
106974
|
+
if (originalKittyWindowId === void 0) {
|
|
106975
|
+
delete process.env.KITTY_WINDOW_ID;
|
|
106976
|
+
} else {
|
|
106977
|
+
process.env.KITTY_WINDOW_ID = originalKittyWindowId;
|
|
106978
|
+
}
|
|
106979
|
+
}
|
|
106980
|
+
}
|
|
106981
|
+
async function fetchSiteScreenshotPreview(params) {
|
|
106982
|
+
const previewUrl = params.renderer.storageService.getFilePreview({
|
|
106983
|
+
bucketId: SITE_SCREENSHOT_BUCKET_ID,
|
|
106984
|
+
fileId: params.fileId,
|
|
106985
|
+
width: SITE_SCREENSHOT_PREVIEW_WIDTH,
|
|
106986
|
+
height: SITE_SCREENSHOT_PREVIEW_HEIGHT,
|
|
106987
|
+
output: ImageFormat.Png
|
|
106988
|
+
});
|
|
106989
|
+
const imageData = await params.renderer.consoleClient.call(
|
|
106990
|
+
"get",
|
|
106991
|
+
new URL(previewUrl),
|
|
106992
|
+
{},
|
|
106993
|
+
{},
|
|
106994
|
+
"arrayBuffer"
|
|
106995
|
+
);
|
|
106996
|
+
if (!(imageData instanceof ArrayBuffer)) {
|
|
106997
|
+
throw new Error("Failed to download the site screenshot preview.");
|
|
106998
|
+
}
|
|
106999
|
+
return renderImageBufferToTerminalPreview(Buffer.from(imageData));
|
|
107000
|
+
}
|
|
107001
|
+
function frameTerminalPreview(preview) {
|
|
107002
|
+
const lines = preview.split("\n").map((line) => line.replace(/\s+$/, ""));
|
|
107003
|
+
while (lines.length > 0 && (0, import_node_util.stripVTControlCharacters)(lines[0]).trim().length === 0) {
|
|
107004
|
+
lines.shift();
|
|
107005
|
+
}
|
|
107006
|
+
while (lines.length > 0 && (0, import_node_util.stripVTControlCharacters)(lines[lines.length - 1]).trim().length === 0) {
|
|
107007
|
+
lines.pop();
|
|
107008
|
+
}
|
|
107009
|
+
if (lines.length === 0) {
|
|
107010
|
+
return "";
|
|
107011
|
+
}
|
|
107012
|
+
const contentWidth = Math.max(
|
|
107013
|
+
...lines.map((line) => (0, import_node_util.stripVTControlCharacters)(line).length)
|
|
107014
|
+
);
|
|
107015
|
+
const border = `+-${"-".repeat(contentWidth)}-+`;
|
|
107016
|
+
return [
|
|
107017
|
+
border,
|
|
107018
|
+
...lines.map((line) => {
|
|
107019
|
+
const visibleWidth = (0, import_node_util.stripVTControlCharacters)(line).length;
|
|
107020
|
+
return `| ${line}${ANSI_RESET}${" ".repeat(contentWidth - visibleWidth)} |`;
|
|
107021
|
+
}),
|
|
107022
|
+
border
|
|
107023
|
+
].join("\n");
|
|
107024
|
+
}
|
|
107025
|
+
async function renderSiteTerminalPreview(params) {
|
|
107026
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
107027
|
+
const candidates = [
|
|
107028
|
+
{ fileId: params.screenshotDark, label: "dark" },
|
|
107029
|
+
{ fileId: params.screenshotLight, label: "light" }
|
|
107030
|
+
];
|
|
107031
|
+
for (const candidate of candidates) {
|
|
107032
|
+
const { fileId, label } = candidate;
|
|
107033
|
+
if (!fileId) {
|
|
107034
|
+
continue;
|
|
107035
|
+
}
|
|
107036
|
+
try {
|
|
107037
|
+
const preview = await fetchSiteScreenshotPreview({
|
|
107038
|
+
renderer: params.renderer,
|
|
107039
|
+
fileId
|
|
107040
|
+
});
|
|
107041
|
+
return {
|
|
107042
|
+
preview: frameTerminalPreview(preview),
|
|
107043
|
+
warnings: []
|
|
107044
|
+
};
|
|
107045
|
+
} catch (previewError) {
|
|
107046
|
+
warnings.add(
|
|
107047
|
+
`${label === "dark" ? "Dark mode" : "Light mode"} screenshot: ${getErrorMessage(previewError)}`
|
|
107048
|
+
);
|
|
107049
|
+
}
|
|
107050
|
+
}
|
|
107051
|
+
return {
|
|
107052
|
+
preview: void 0,
|
|
107053
|
+
warnings: [...warnings]
|
|
107054
|
+
};
|
|
107055
|
+
}
|
|
106851
107056
|
function withDeploymentLogsHint(message, deploymentLogsController) {
|
|
106852
107057
|
const hint2 = deploymentLogsController.getToggleHint();
|
|
106853
107058
|
return hint2.length > 0 ? `${message} \u2022 ${hint2}` : message;
|
|
@@ -107724,7 +107929,7 @@ var Push = class {
|
|
|
107724
107929
|
deploymentLogsController
|
|
107725
107930
|
)
|
|
107726
107931
|
});
|
|
107727
|
-
|
|
107932
|
+
let timeoutDeadline = Date.now() + DEPLOYMENT_TIMEOUT_MS;
|
|
107728
107933
|
while (true) {
|
|
107729
107934
|
if (Date.now() > timeoutDeadline) {
|
|
107730
107935
|
deploymentLogPrinter.complete();
|
|
@@ -108111,6 +108316,8 @@ var Push = class {
|
|
|
108111
108316
|
deploymentId
|
|
108112
108317
|
);
|
|
108113
108318
|
let waitingSince = null;
|
|
108319
|
+
let readyWithoutScreenshotsSince = null;
|
|
108320
|
+
let activationApplied = false;
|
|
108114
108321
|
const deploymentLogPrinter = createDeploymentLogPrinter({
|
|
108115
108322
|
label: `site:${site.name}`,
|
|
108116
108323
|
showPrefix: sites.length > 1,
|
|
@@ -108150,7 +108357,7 @@ var Push = class {
|
|
|
108150
108357
|
deploymentLogsController
|
|
108151
108358
|
)
|
|
108152
108359
|
});
|
|
108153
|
-
|
|
108360
|
+
let timeoutDeadline = Date.now() + DEPLOYMENT_TIMEOUT_MS;
|
|
108154
108361
|
while (true) {
|
|
108155
108362
|
if (Date.now() > timeoutDeadline) {
|
|
108156
108363
|
deploymentLogPrinter.complete();
|
|
@@ -108184,7 +108391,9 @@ var Push = class {
|
|
|
108184
108391
|
waitingSince = null;
|
|
108185
108392
|
}
|
|
108186
108393
|
if (status === "ready") {
|
|
108187
|
-
|
|
108394
|
+
const { screenshotLight, screenshotDark } = getSiteDeploymentScreenshots(response);
|
|
108395
|
+
const screenshotsReady = hasSiteDeploymentScreenshots(response);
|
|
108396
|
+
if (activate && !activationApplied) {
|
|
108188
108397
|
currentDeploymentEnd = "Setting active deployment...";
|
|
108189
108398
|
updaterRow.update({
|
|
108190
108399
|
status: "Activating",
|
|
@@ -108200,6 +108409,28 @@ var Push = class {
|
|
|
108200
108409
|
siteId: site["$id"],
|
|
108201
108410
|
deploymentId
|
|
108202
108411
|
});
|
|
108412
|
+
activationApplied = true;
|
|
108413
|
+
}
|
|
108414
|
+
if (!screenshotsReady) {
|
|
108415
|
+
readyWithoutScreenshotsSince ??= Date.now();
|
|
108416
|
+
timeoutDeadline = Math.max(
|
|
108417
|
+
timeoutDeadline,
|
|
108418
|
+
readyWithoutScreenshotsSince + SITE_SCREENSHOT_FINALIZATION_TIMEOUT_MS
|
|
108419
|
+
);
|
|
108420
|
+
if (Date.now() - readyWithoutScreenshotsSince < SITE_SCREENSHOT_FINALIZATION_TIMEOUT_MS) {
|
|
108421
|
+
currentDeploymentEnd = "Finalizing deployment preview...";
|
|
108422
|
+
updaterRow.update({
|
|
108423
|
+
status: "Finalizing",
|
|
108424
|
+
end: withDeploymentLogsHint(
|
|
108425
|
+
currentDeploymentEnd,
|
|
108426
|
+
deploymentLogsController
|
|
108427
|
+
)
|
|
108428
|
+
});
|
|
108429
|
+
await new Promise(
|
|
108430
|
+
(resolve3) => setTimeout(resolve3, POLL_DEBOUNCE2)
|
|
108431
|
+
);
|
|
108432
|
+
continue;
|
|
108433
|
+
}
|
|
108203
108434
|
}
|
|
108204
108435
|
successfullyDeployed++;
|
|
108205
108436
|
let url2 = "";
|
|
@@ -108226,7 +108457,14 @@ var Push = class {
|
|
|
108226
108457
|
status: activate ? "Deployed" : "Built",
|
|
108227
108458
|
end: ""
|
|
108228
108459
|
});
|
|
108229
|
-
deploymentLogs.push({
|
|
108460
|
+
deploymentLogs.push({
|
|
108461
|
+
name: site.name,
|
|
108462
|
+
url: url2,
|
|
108463
|
+
consoleUrl,
|
|
108464
|
+
screenshotLight,
|
|
108465
|
+
screenshotDark,
|
|
108466
|
+
screenshotsPending: !screenshotsReady
|
|
108467
|
+
});
|
|
108230
108468
|
break;
|
|
108231
108469
|
} else if (status === "failed") {
|
|
108232
108470
|
deploymentLogPrinter.complete();
|
|
@@ -108281,16 +108519,76 @@ var Push = class {
|
|
|
108281
108519
|
Spinner.stop();
|
|
108282
108520
|
}
|
|
108283
108521
|
if (deploymentLogs.length > 0) {
|
|
108522
|
+
let sitePreviewRenderer = null;
|
|
108523
|
+
let sitePreviewSetupWarning = null;
|
|
108524
|
+
const emittedPreviewWarnings = /* @__PURE__ */ new Set();
|
|
108525
|
+
if (shouldRenderSiteTerminalPreview() && deploymentLogs.some(
|
|
108526
|
+
(deploymentLog) => deploymentLog.screenshotLight || deploymentLog.screenshotDark
|
|
108527
|
+
)) {
|
|
108528
|
+
try {
|
|
108529
|
+
const consoleClient = await sdkForConsole(
|
|
108530
|
+
true,
|
|
108531
|
+
localConfig.getEndpoint() || globalConfig2.getEndpoint()
|
|
108532
|
+
);
|
|
108533
|
+
sitePreviewRenderer = {
|
|
108534
|
+
consoleClient,
|
|
108535
|
+
storageService: await getStorageService(consoleClient)
|
|
108536
|
+
};
|
|
108537
|
+
} catch (previewSetupError) {
|
|
108538
|
+
sitePreviewSetupWarning = getErrorMessage(previewSetupError);
|
|
108539
|
+
}
|
|
108540
|
+
}
|
|
108284
108541
|
process.stdout.write("\n");
|
|
108285
|
-
deploymentLogs.
|
|
108542
|
+
for (const [index, dl] of deploymentLogs.entries()) {
|
|
108286
108543
|
if (index > 0) {
|
|
108287
108544
|
process.stdout.write("\n");
|
|
108288
108545
|
}
|
|
108546
|
+
if (deploymentLogs.length > 1) {
|
|
108547
|
+
process.stdout.write(`${import_chalk9.default.cyan.bold(`Site: ${dl.name}`)}
|
|
108548
|
+
`);
|
|
108549
|
+
}
|
|
108550
|
+
if (dl.screenshotsPending) {
|
|
108551
|
+
hint(
|
|
108552
|
+
"Deployment is ready, but screenshot generation is still finalizing. Open the deployment page to view it once it is available."
|
|
108553
|
+
);
|
|
108554
|
+
}
|
|
108555
|
+
if (sitePreviewRenderer && (dl.screenshotLight || dl.screenshotDark)) {
|
|
108556
|
+
const preview = await renderSiteTerminalPreview({
|
|
108557
|
+
renderer: sitePreviewRenderer,
|
|
108558
|
+
screenshotLight: dl.screenshotLight,
|
|
108559
|
+
screenshotDark: dl.screenshotDark
|
|
108560
|
+
});
|
|
108561
|
+
if (preview.preview) {
|
|
108562
|
+
process.stdout.write(
|
|
108563
|
+
`
|
|
108564
|
+
${import_chalk9.default.cyan.bold("Screenshot preview")}
|
|
108565
|
+
|
|
108566
|
+
`
|
|
108567
|
+
);
|
|
108568
|
+
process.stdout.write(`${preview.preview}
|
|
108569
|
+
|
|
108570
|
+
`);
|
|
108571
|
+
}
|
|
108572
|
+
for (const previewWarning of preview.warnings) {
|
|
108573
|
+
const warningMessage = `Screenshot preview unavailable: ${previewWarning}`;
|
|
108574
|
+
if (emittedPreviewWarnings.has(warningMessage)) {
|
|
108575
|
+
continue;
|
|
108576
|
+
}
|
|
108577
|
+
emittedPreviewWarnings.add(warningMessage);
|
|
108578
|
+
hint(warningMessage);
|
|
108579
|
+
}
|
|
108580
|
+
} else if (sitePreviewSetupWarning && (dl.screenshotLight || dl.screenshotDark)) {
|
|
108581
|
+
const warningMessage = `Screenshot preview unavailable: ${sitePreviewSetupWarning}`;
|
|
108582
|
+
if (!emittedPreviewWarnings.has(warningMessage)) {
|
|
108583
|
+
emittedPreviewWarnings.add(warningMessage);
|
|
108584
|
+
hint(warningMessage);
|
|
108585
|
+
}
|
|
108586
|
+
}
|
|
108289
108587
|
if (dl.url) {
|
|
108290
108588
|
this.log(`Preview link: ${import_chalk9.default.cyan(dl.url)}`);
|
|
108291
108589
|
}
|
|
108292
108590
|
this.log(`Deployment page: ${import_chalk9.default.cyan(dl.consoleUrl)}`);
|
|
108293
|
-
}
|
|
108591
|
+
}
|
|
108294
108592
|
process.stdout.write("\n");
|
|
108295
108593
|
}
|
|
108296
108594
|
return {
|
|
@@ -110541,7 +110839,7 @@ var BaseDatabasesGenerator = class {
|
|
|
110541
110839
|
};
|
|
110542
110840
|
|
|
110543
110841
|
// lib/commands/generators/typescript/templates/types.ts.hbs
|
|
110544
|
-
var types_ts_default = "import { type Models } from '{{appwriteDep}}';\n\n{{{ENUMS}}}{{{TYPES}}}\ndeclare const __roleStringBrand: unique symbol;\nexport type RoleString = string & { readonly [__roleStringBrand]: never };\n\nexport type RoleBuilder = {\n any: () => RoleString;\n user: (userId: string, status?: string) => RoleString;\n users: (status?: string) => RoleString;\n guests: () => RoleString;\n team: (teamId: string, role?: string) => RoleString;\n member: (memberId: string) => RoleString;\n label: (label: string) => RoleString;\n}\n\nexport type PermissionBuilder = {\n read: (role: RoleString) => string;\n write: (role: RoleString) => string;\n create: (role: RoleString) => string;\n update: (role: RoleString) => string;\n delete: (role: RoleString) => string;\n}\n\nexport type PermissionCallback = (permission: PermissionBuilder, role: RoleBuilder) => string[];\n\nexport type QueryValue = string | number | boolean;\n\nexport type ExtractQueryValue<T> = T extends (infer U)[]\n ? U extends QueryValue ? U : never\n : T extends QueryValue | null ? NonNullable<T> : never;\n\nexport type QueryableKeys<T> = {\n [K in keyof T]: ExtractQueryValue<T[K]> extends never ? never : K;\n}[keyof T];\n\nexport type QueryBuilder<T> = {\n equal: <K extends QueryableKeys<T>>(field: K, value:
|
|
110842
|
+
var types_ts_default = "import { type Models } from '{{appwriteDep}}';\n\n{{{ENUMS}}}{{{TYPES}}}\ndeclare const __roleStringBrand: unique symbol;\nexport type RoleString = string & { readonly [__roleStringBrand]: never };\n\nexport type RoleBuilder = {\n any: () => RoleString;\n user: (userId: string, status?: string) => RoleString;\n users: (status?: string) => RoleString;\n guests: () => RoleString;\n team: (teamId: string, role?: string) => RoleString;\n member: (memberId: string) => RoleString;\n label: (label: string) => RoleString;\n}\n\nexport type PermissionBuilder = {\n read: (role: RoleString) => string;\n write: (role: RoleString) => string;\n create: (role: RoleString) => string;\n update: (role: RoleString) => string;\n delete: (role: RoleString) => string;\n}\n\nexport type PermissionCallback = (permission: PermissionBuilder, role: RoleBuilder) => string[];\n\nexport type QueryValue = string | number | boolean;\n\nexport type ExtractQueryValue<T> = T extends (infer U)[]\n ? U extends QueryValue ? U : never\n : T extends QueryValue | null ? NonNullable<T> : never;\n\nexport type QueryableKeys<T> = {\n [K in keyof T]: ExtractQueryValue<T[K]> extends never ? never : K;\n}[keyof T];\n\nexport type QueryableFieldValue<T, K> = K extends keyof T\n ? ExtractQueryValue<T[K]>\n : never;\n\nexport type QueryBuilder<T> = {\n equal: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n notEqual: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n lessThan: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n lessThanEqual: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n greaterThan: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n greaterThanEqual: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n contains: <K extends QueryableKeys<T>>(field: K, value: QueryableFieldValue<T, K>) => string;\n search: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n isNull: <K extends QueryableKeys<T>>(field: K) => string;\n isNotNull: <K extends QueryableKeys<T>>(field: K) => string;\n startsWith: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n endsWith: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n between: <K extends QueryableKeys<T>>(field: K, start: QueryableFieldValue<T, K>, end: QueryableFieldValue<T, K>) => string;\n select: <K extends keyof T>(fields: K[]) => string;\n orderAsc: <K extends keyof T>(field: K) => string;\n orderDesc: <K extends keyof T>(field: K) => string;\n limit: (value: number) => string;\n offset: (value: number) => string;\n cursorAfter: (documentId: string) => string;\n cursorBefore: (documentId: string) => string;\n or: (...queries: string[]) => string;\n and: (...queries: string[]) => string;\n}\n\nexport type DatabaseId = {{{databaseIdType}}};\n\n{{{DATABASE_TABLES_TYPE}}}\n";
|
|
110545
110843
|
|
|
110546
110844
|
// lib/commands/generators/typescript/templates/databases.ts.hbs
|
|
110547
110845
|
var databases_ts_default = 'import { Client, TablesDB, ID, Query, type Models, Permission, Role } from \'{{appwriteDep}}\';\nimport type { DatabaseHandle, DatabaseId, DatabaseTableMap, DatabaseTables, QueryBuilder, QueryValue, PermissionBuilder, RoleBuilder, RoleString } from \'./types{{importExt}}\';\n{{#if supportsServerSide}}\nimport { PROJECT_ID, ENDPOINT, API_KEY } from \'./constants{{importExt}}\';\n{{else}}\nimport { PROJECT_ID, ENDPOINT } from \'./constants{{importExt}}\';\n{{/if}}\n\nconst createQueryBuilder = <T>(): QueryBuilder<T> => ({\n equal: (field, value) => Query.equal(String(field), value as QueryValue),\n notEqual: (field, value) => Query.notEqual(String(field), value as QueryValue),\n lessThan: (field, value) => Query.lessThan(String(field), value as QueryValue),\n lessThanEqual: (field, value) => Query.lessThanEqual(String(field), value as QueryValue),\n greaterThan: (field, value) => Query.greaterThan(String(field), value as QueryValue),\n greaterThanEqual: (field, value) => Query.greaterThanEqual(String(field), value as QueryValue),\n contains: (field, value) => Query.contains(String(field), value as string | QueryValue[]),\n search: (field, value) => Query.search(String(field), value),\n isNull: (field) => Query.isNull(String(field)),\n isNotNull: (field) => Query.isNotNull(String(field)),\n startsWith: (field, value) => Query.startsWith(String(field), value),\n endsWith: (field, value) => Query.endsWith(String(field), value),\n between: (field, start, end) => Query.between(String(field), start as string | number, end as string | number),\n select: (fields) => Query.select(fields.map(String)),\n orderAsc: (field) => Query.orderAsc(String(field)),\n orderDesc: (field) => Query.orderDesc(String(field)),\n limit: (value) => Query.limit(value),\n offset: (value) => Query.offset(value),\n cursorAfter: (documentId) => Query.cursorAfter(documentId),\n cursorBefore: (documentId) => Query.cursorBefore(documentId),\n or: (...queries) => Query.or(queries),\n and: (...queries) => Query.and(queries),\n});\n\n{{{TABLE_ID_MAP}}}\n\n{{{TABLES_WITH_RELATIONSHIPS}}}\n\nconst roleBuilder: RoleBuilder = {\n any: () => Role.any() as RoleString,\n user: (userId, status?) => Role.user(userId, status) as RoleString,\n users: (status?) => Role.users(status) as RoleString,\n guests: () => Role.guests() as RoleString,\n team: (teamId, role?) => Role.team(teamId, role) as RoleString,\n member: (memberId) => Role.member(memberId) as RoleString,\n label: (label) => Role.label(label) as RoleString,\n};\n\nconst permissionBuilder: PermissionBuilder = {\n read: (role) => Permission.read(role),\n write: (role) => Permission.write(role),\n create: (role) => Permission.create(role),\n update: (role) => Permission.update(role),\n delete: (role) => Permission.delete(role),\n};\n\nconst resolvePermissions = (callback?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]): string[] | undefined =>\n callback?.(permissionBuilder, roleBuilder);\n\nfunction createTableApi<T extends Models.Row>(\n tablesDB: TablesDB,\n databaseId: string,\n tableId: string,\n) {\n return {\n create: (data: Omit<T, keyof Models.Row>, options?: { rowId?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.createRow<T>({\n databaseId,\n tableId,\n rowId: options?.rowId ?? ID.unique(),\n data: data as T extends Models.DefaultRow ? Partial<Models.Row> & Record<string, unknown> : Partial<Models.Row> & Omit<T, keyof Models.Row>,\n permissions: resolvePermissions(options?.permissions),\n transactionId: options?.transactionId,\n }),\n get: (id: string) =>\n tablesDB.getRow<T>({\n databaseId,\n tableId,\n rowId: id,\n }),\n update: (id: string, data: Partial<Omit<T, keyof Models.Row>>, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.updateRow<T>({\n databaseId,\n tableId,\n rowId: id,\n data: data as T extends Models.DefaultRow ? Partial<Models.Row> & Record<string, unknown> : Partial<Models.Row> & Partial<Omit<T, keyof Models.Row>>,\n ...(options?.permissions ? { permissions: resolvePermissions(options.permissions) } : {}),\n transactionId: options?.transactionId,\n }),\n delete: async (id: string, options?: { transactionId?: string }) => {\n await tablesDB.deleteRow({\n databaseId,\n tableId,\n rowId: id,\n transactionId: options?.transactionId,\n });\n },\n list: (options?: { queries?: (q: QueryBuilder<T>) => string[] }) =>\n tablesDB.listRows<T>({\n databaseId,\n tableId,\n queries: options?.queries?.(createQueryBuilder<T>()),\n }),{{{BULK_METHODS}}}\n };\n}\n\n{{{BULK_CHECK}}}\nconst hasOwn = (obj: unknown, key: string): boolean =>\n obj != null && Object.prototype.hasOwnProperty.call(obj, key);\n\nfunction createDatabaseHandle<D extends DatabaseId>(\n tablesDB: TablesDB,\n databaseId: D,\n): DatabaseHandle<D> {\n const tableApiCache = new Map<string, unknown>();\n const dbMap = tableIdMap[databaseId];\n\n return {\n use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T): DatabaseTableMap[D][T] => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n\n if (!tableApiCache.has(tableId)) {\n const resolvedTableId = dbMap[tableId];\n const api = createTableApi(tablesDB, databaseId, resolvedTableId);\n {{{BULK_REMOVAL}}}\n tableApiCache.set(tableId, api);\n }\n return tableApiCache.get(tableId) as DatabaseTableMap[D][T];\n },\n{{#if supportsServerSide}}\n create: (tableId: string, name: string, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) =>\n tablesDB.createTable({\n databaseId,\n tableId,\n name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n columns: options?.columns,\n indexes: options?.indexes,\n }),\n update: (tableId: string, options?: { name?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean }) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n return tablesDB.updateTable({\n databaseId,\n tableId: resolvedTableId,\n name: options?.name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n });\n },\n delete: async (tableId: string) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n await tablesDB.deleteTable({\n databaseId,\n tableId: resolvedTableId,\n });\n },\n{{/if}}\n };\n}\n\nfunction createDatabasesApi(tablesDB: TablesDB): DatabaseTables {\n const dbCache = new Map<DatabaseId, ReturnType<typeof createDatabaseHandle>>();\n\n return {\n use: (databaseId: DatabaseId) => {\n if (!hasOwn(tableIdMap, databaseId)) {\n throw new Error(`Unknown database "${databaseId}"`);\n }\n\n if (!dbCache.has(databaseId)) {\n dbCache.set(databaseId, createDatabaseHandle(tablesDB, databaseId));\n }\n return dbCache.get(databaseId);\n },\n{{#if supportsServerSide}}\n create: (databaseId: string, name: string, options?: { enabled?: boolean }) =>\n tablesDB.create({\n databaseId,\n name,\n enabled: options?.enabled,\n }),\n update: (databaseId: DatabaseId, options?: { name?: string; enabled?: boolean }) => {\n return tablesDB.update({\n databaseId,\n name: options?.name ?? databaseId,\n enabled: options?.enabled,\n });\n },\n delete: async (databaseId: DatabaseId) => {\n await tablesDB.delete({\n databaseId,\n });\n },\n{{/if}}\n } as DatabaseTables;\n}\n\n// Initialize client\nconst client = new Client()\n .setEndpoint(ENDPOINT)\n .setProject(PROJECT_ID){{#if supportsServerSide}}\n .setKey(API_KEY){{/if}};\n\nconst tablesDB = new TablesDB(client);\n\nexport const databases: DatabaseTables = createDatabasesApi(tablesDB);\n';
|
|
@@ -110558,7 +110856,7 @@ var databasesTemplate = import_handlebars.default.compile(String(databases_ts_de
|
|
|
110558
110856
|
var indexTemplate = import_handlebars.default.compile(String(index_ts_default));
|
|
110559
110857
|
var constantsTemplate = import_handlebars.default.compile(String(constants_ts_default));
|
|
110560
110858
|
var PERMISSION_CALLBACK_INLINE = `(permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]`;
|
|
110561
|
-
var getQueryCallbackInline = (typeName) => `(q: { equal: <K extends QueryableKeys<${typeName}>>(field: K, value:
|
|
110859
|
+
var getQueryCallbackInline = (typeName) => `(q: { equal: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; notEqual: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; lessThan: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; lessThanEqual: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; greaterThan: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; greaterThanEqual: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; contains: <K extends QueryableKeys<${typeName}>>(field: K, value: QueryableFieldValue<${typeName}, K>) => string; search: <K extends QueryableKeys<${typeName}>>(field: K, value: string) => string; isNull: <K extends QueryableKeys<${typeName}>>(field: K) => string; isNotNull: <K extends QueryableKeys<${typeName}>>(field: K) => string; startsWith: <K extends QueryableKeys<${typeName}>>(field: K, value: string) => string; endsWith: <K extends QueryableKeys<${typeName}>>(field: K, value: string) => string; between: <K extends QueryableKeys<${typeName}>>(field: K, start: QueryableFieldValue<${typeName}, K>, end: QueryableFieldValue<${typeName}, K>) => string; select: <K extends keyof ${typeName}>(fields: K[]) => string; orderAsc: <K extends keyof ${typeName}>(field: K) => string; orderDesc: <K extends keyof ${typeName}>(field: K) => string; limit: (value: number) => string; offset: (value: number) => string; cursorAfter: (documentId: string) => string; cursorBefore: (documentId: string) => string; or: (...queries: string[]) => string; and: (...queries: string[]) => string }) => string[]`;
|
|
110562
110860
|
var TypeScriptDatabasesGenerator = class extends BaseDatabasesGenerator {
|
|
110563
110861
|
language = "typescript";
|
|
110564
110862
|
fileExtension = "ts";
|