@tailor-platform/sdk 1.50.1 → 1.51.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 +60 -0
- package/README.md +1 -0
- package/agent-skills/tailor-sdk/SKILL.md +2 -0
- package/dist/{actor-BeIEiPYM.d.mts → actor-Nag62ZDM.d.mts} +2 -3
- package/dist/application-Bcx-FbDE.mjs +4 -0
- package/dist/{application-CZMzt9jL.mjs → application-Z-fNwyZB.mjs} +50 -14
- package/dist/application-Z-fNwyZB.mjs.map +1 -0
- package/dist/authconnection-BDFTabLQ.d.mts +39 -0
- package/dist/authconnection-BUko4V6H.mjs +16 -0
- package/dist/authconnection-BUko4V6H.mjs.map +1 -0
- package/dist/{brand-D-d15jx3.mjs → brand-Ll48SMXe.mjs} +1 -1
- package/dist/{brand-D-d15jx3.mjs.map → brand-Ll48SMXe.mjs.map} +1 -1
- package/dist/chunk-DLeslSnM.mjs +21 -0
- package/dist/cli/index.d.mts +0 -1
- package/dist/cli/index.mjs +16 -16
- package/dist/cli/lib.d.mts +6 -7
- package/dist/cli/lib.mjs +8 -8
- package/dist/cli/skills.d.mts +0 -1
- package/dist/cli/skills.mjs +1 -1
- package/dist/{client-_kHh0Pip.mjs → client-BwV17byk.mjs} +4 -4
- package/dist/{client-_kHh0Pip.mjs.map → client-BwV17byk.mjs.map} +1 -1
- package/dist/{client-CPW1N1Rs.mjs → client-D_a50aIg.mjs} +1 -1
- package/dist/configure/index.d.mts +5 -5
- package/dist/configure/index.mjs +4 -4
- package/dist/configure/index.mjs.map +1 -1
- package/dist/context-BP5BUdcq.mjs +25 -0
- package/dist/context-BP5BUdcq.mjs.map +1 -0
- package/dist/context-BXDgEQK9.d.mts +68 -0
- package/dist/{crashreport-DHJuSmUc.mjs → crashreport-C4EbRoku.mjs} +1 -1
- package/dist/{crashreport-CvmdFs4i.mjs → crashreport-DauPOrKn.mjs} +5 -5
- package/dist/{crashreport-CvmdFs4i.mjs.map → crashreport-DauPOrKn.mjs.map} +1 -1
- package/dist/{enum-constants-C3KSpsYj.mjs → enum-constants-DI85-fPE.mjs} +1 -1
- package/dist/{enum-constants-C3KSpsYj.mjs.map → enum-constants-DI85-fPE.mjs.map} +1 -1
- package/dist/{errors-pMPXghkO.mjs → errors-C4cJ0M2K.mjs} +1 -1
- package/dist/{errors-pMPXghkO.mjs.map → errors-C4cJ0M2K.mjs.map} +1 -1
- package/dist/{field-DLSIuMTu.mjs → field-BY2vbJ8f.mjs} +1 -1
- package/dist/{field-DLSIuMTu.mjs.map → field-BY2vbJ8f.mjs.map} +1 -1
- package/dist/file-BE5Sy7lP.mjs +54 -0
- package/dist/file-BE5Sy7lP.mjs.map +1 -0
- package/dist/file-Dc4_QrlQ.d.mts +206 -0
- package/dist/{file-utils-DjNi_3U_.mjs → file-utils-BM8t5jCy.mjs} +20 -10
- package/dist/file-utils-BM8t5jCy.mjs.map +1 -0
- package/dist/iconv-BFNfdlIS.d.mts +122 -0
- package/dist/iconv-D0yL88Il.mjs +64 -0
- package/dist/iconv-D0yL88Il.mjs.map +1 -0
- package/dist/idp-B1b4O7ia.d.mts +161 -0
- package/dist/idp-CM7N7iID.mjs +76 -0
- package/dist/idp-CM7N7iID.mjs.map +1 -0
- package/dist/{index-C--7W0UO.d.mts → index-BD99GoHO.d.mts} +4 -5
- package/dist/{index-nV4ZC_Ve.d.mts → index-BXwAT_oE.d.mts} +2 -3
- package/dist/{index-BQ4oi0AI.d.mts → index-CYAZkd4b.d.mts} +2 -3
- package/dist/{index-BjXN1SdY.d.mts → index-CfSjuxzK.d.mts} +2 -3
- package/dist/index-Dy3ZH5Wm.d.mts +46 -0
- package/dist/{index-VJW98BSy.d.mts → index-aiIbrFGw.d.mts} +2 -3
- package/dist/{interceptor-DTNS0EtF.mjs → interceptor-Cr3kZWMc.mjs} +1 -1
- package/dist/{interceptor-DTNS0EtF.mjs.map → interceptor-Cr3kZWMc.mjs.map} +1 -1
- package/dist/{job-M3Avv_SV.mjs → job-4GOnasfT.mjs} +2 -2
- package/dist/{job-M3Avv_SV.mjs.map → job-4GOnasfT.mjs.map} +1 -1
- package/dist/kysely/index.d.mts +0 -1
- package/dist/{kysely-type-B8aRz_oC.mjs → kysely-type-BUoVDC5r.mjs} +2 -2
- package/dist/{kysely-type-B8aRz_oC.mjs.map → kysely-type-BUoVDC5r.mjs.map} +1 -1
- package/dist/{logger-DTNAMYGy.mjs → logger-B1g4I9wT.mjs} +1 -1
- package/dist/{logger-DTNAMYGy.mjs.map → logger-B1g4I9wT.mjs.map} +1 -1
- package/dist/{mock-BfL09ULZ.mjs → mock-B2t5gDMl.mjs} +11 -5
- package/dist/mock-B2t5gDMl.mjs.map +1 -0
- package/dist/{multiline-e3IpANmS.mjs → multiline-G1yF18OH.mjs} +1 -1
- package/dist/{multiline-e3IpANmS.mjs.map → multiline-G1yF18OH.mjs.map} +1 -1
- package/dist/package-json-CAGKAJff.mjs +4 -0
- package/dist/{package-json-6Px8bDpG.mjs → package-json-ZL0MkZOO.mjs} +1 -1
- package/dist/{package-json-6Px8bDpG.mjs.map → package-json-ZL0MkZOO.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -2
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -2
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -2
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -3
- package/dist/{repl-editor-jZ493eQI.mjs → repl-editor-yAjwS5_M.mjs} +1 -1
- package/dist/{repl-editor-jZ493eQI.mjs.map → repl-editor-yAjwS5_M.mjs.map} +1 -1
- package/dist/runtime/authconnection.d.mts +2 -0
- package/dist/runtime/authconnection.mjs +4 -0
- package/dist/runtime/context.d.mts +2 -0
- package/dist/runtime/context.mjs +4 -0
- package/dist/runtime/file.d.mts +2 -0
- package/dist/runtime/file.mjs +4 -0
- package/dist/runtime/globals.d.mts +103 -0
- package/dist/runtime/globals.mjs +2 -0
- package/dist/runtime/iconv.d.mts +2 -0
- package/dist/runtime/iconv.mjs +4 -0
- package/dist/runtime/idp.d.mts +2 -0
- package/dist/runtime/idp.mjs +4 -0
- package/dist/runtime/index.d.mts +9 -0
- package/dist/runtime/index.mjs +10 -0
- package/dist/runtime/secretmanager.d.mts +2 -0
- package/dist/runtime/secretmanager.mjs +4 -0
- package/dist/runtime/workflow.d.mts +2 -0
- package/dist/runtime/workflow.mjs +4 -0
- package/dist/{runtime-DgsMnMrO.mjs → runtime-CyX4zeod.mjs} +55 -32
- package/dist/runtime-CyX4zeod.mjs.map +1 -0
- package/dist/{schema-C5QjYEc-.mjs → schema-DBq6hr6h.mjs} +3 -3
- package/dist/{schema-C5QjYEc-.mjs.map → schema-DBq6hr6h.mjs.map} +1 -1
- package/dist/{secret-file-BHpxGyNf.mjs → secret-file-DnbmTWec.mjs} +1 -1
- package/dist/{secret-file-BHpxGyNf.mjs.map → secret-file-DnbmTWec.mjs.map} +1 -1
- package/dist/secretmanager-CQTTuCmn.mjs +25 -0
- package/dist/secretmanager-CQTTuCmn.mjs.map +1 -0
- package/dist/secretmanager-Cjq3s2aU.d.mts +55 -0
- package/dist/seed/index.d.mts +0 -1
- package/dist/{seed-DjfAn0BC.mjs → seed-kNk-xLoB.mjs} +7 -2
- package/dist/{seed-DjfAn0BC.mjs.map → seed-kNk-xLoB.mjs.map} +1 -1
- package/dist/{service-DCgJxdg1.mjs → service-DHgJ4YEF.mjs} +3 -3
- package/dist/{service-DCgJxdg1.mjs.map → service-DHgJ4YEF.mjs.map} +1 -1
- package/dist/{tailor-db-field-4bMLe25-.d.mts → tailor-db-field-BhWvOyky.d.mts} +1 -2
- package/dist/{telemetry-C1Y56L5E.mjs → telemetry-C8xKz3GM.mjs} +2 -2
- package/dist/{telemetry-C1Y56L5E.mjs.map → telemetry-C8xKz3GM.mjs.map} +1 -1
- package/dist/telemetry-DQl47E1s.mjs +4 -0
- package/dist/types-BnphjkIJ.mjs +5 -0
- package/dist/{types-sir9UPht.mjs → types-Duhhsx3R.mjs} +2 -2
- package/dist/{types-sir9UPht.mjs.map → types-Duhhsx3R.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +3 -4
- package/dist/utils/test/index.mjs +1 -1
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.d.mts +0 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +2 -3
- package/dist/vitest/index.mjs +3 -3
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/setup.d.mts +0 -1
- package/dist/vitest/setup.mjs +1 -1
- package/dist/workflow-DJRr-0nl.mjs +39 -0
- package/dist/workflow-DJRr-0nl.mjs.map +1 -0
- package/dist/workflow-DV_88JEf.d.mts +96 -0
- package/dist/{workflow.generated-OYAu_6zX.d.mts → workflow.generated-DV87DJfO.d.mts} +2 -3
- package/docs/cli/application.md +1 -1
- package/docs/cli/tailordb.md +9 -8
- package/docs/cli-reference.md +17 -16
- package/docs/configuration.md +1 -0
- package/docs/generator/builtin.md +2 -0
- package/docs/runtime.md +113 -0
- package/docs/testing.md +21 -0
- package/package.json +53 -9
- package/dist/application-CZMzt9jL.mjs.map +0 -1
- package/dist/application-v_E2W-Fz.mjs +0 -4
- package/dist/file-utils-DjNi_3U_.mjs.map +0 -1
- package/dist/mock-BfL09ULZ.mjs.map +0 -1
- package/dist/package-json-7sRXVndJ.mjs +0 -4
- package/dist/runtime-DgsMnMrO.mjs.map +0 -1
- package/dist/telemetry-C13VIFpT.mjs +0 -4
- package/dist/types-DoIG6Nij.mjs +0 -5
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
declare namespace context_d_exports {
|
|
2
|
+
export { ContextInvoker, Invoker, TailorContextAPI, getInvoker };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Execution context utilities.
|
|
6
|
+
*
|
|
7
|
+
* Thin typed wrapper around the platform-provided `tailor.context` runtime API.
|
|
8
|
+
* At runtime this delegates to `globalThis.tailor.context`.
|
|
9
|
+
* @example
|
|
10
|
+
* import { context } from "@tailor-platform/sdk/runtime";
|
|
11
|
+
*
|
|
12
|
+
* const invoker = context.getInvoker();
|
|
13
|
+
* if (invoker) {
|
|
14
|
+
* console.log(invoker.id, invoker.type, invoker.attributes, invoker.attributeList);
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Information about the invoker of the current function execution.
|
|
19
|
+
*
|
|
20
|
+
* Matches the shape of `TailorUser` and `TailorActor` — `attributes` is the
|
|
21
|
+
* attribute map and `attributeList` is the array of attribute IDs.
|
|
22
|
+
*/
|
|
23
|
+
interface Invoker {
|
|
24
|
+
/** The invoker's ID */
|
|
25
|
+
id: string;
|
|
26
|
+
/** The invoker's type */
|
|
27
|
+
type: "user" | "machine_user";
|
|
28
|
+
/** The workspace ID */
|
|
29
|
+
workspaceId: string;
|
|
30
|
+
/** A map of the invoker's attributes */
|
|
31
|
+
attributes: Record<string, unknown>;
|
|
32
|
+
/** The list of attribute IDs */
|
|
33
|
+
attributeList: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Raw platform-side invoker payload returned by `tailor.context.getInvoker()`.
|
|
37
|
+
* The wrapper normalizes this into {@link Invoker}.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
interface ContextInvoker {
|
|
41
|
+
/** The invoker's ID */
|
|
42
|
+
id: string;
|
|
43
|
+
/** The invoker's type */
|
|
44
|
+
type: "user" | "machine_user";
|
|
45
|
+
/** The workspace ID */
|
|
46
|
+
workspaceId: string;
|
|
47
|
+
/** The invoker's attribute IDs */
|
|
48
|
+
attributes: string[];
|
|
49
|
+
/** The invoker's attribute map */
|
|
50
|
+
attributeMap: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Platform API surface for `tailor.context`. Describes the shape the platform
|
|
54
|
+
* runtime injects on `globalThis.tailor.context`.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
interface TailorContextAPI {
|
|
58
|
+
getInvoker(): ContextInvoker | null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns information about the invoker of the current function execution,
|
|
62
|
+
* or `null` for anonymous invocations.
|
|
63
|
+
* @returns Invoker details, or `null` when the call is anonymous
|
|
64
|
+
*/
|
|
65
|
+
declare function getInvoker(): Invoker | null;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { getInvoker as a, context_d_exports as i, Invoker as n, TailorContextAPI as r, ContextInvoker as t };
|
|
68
|
+
//# sourceMappingURL=context-BXDgEQK9.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import { n as logger } from "./logger-
|
|
3
|
-
import { t as readPackageJson } from "./package-json-
|
|
4
|
-
import { r as writeSecretFile, t as ensureSecretDir } from "./secret-file-
|
|
2
|
+
import { n as logger } from "./logger-B1g4I9wT.mjs";
|
|
3
|
+
import { t as readPackageJson } from "./package-json-ZL0MkZOO.mjs";
|
|
4
|
+
import { r as writeSecretFile, t as ensureSecretDir } from "./secret-file-DnbmTWec.mjs";
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as path from "pathe";
|
|
7
7
|
import * as os from "node:os";
|
|
@@ -386,7 +386,7 @@ async function reportCrash(error, errorType) {
|
|
|
386
386
|
].join("\n"));
|
|
387
387
|
}
|
|
388
388
|
if (config.remoteEnabled) {
|
|
389
|
-
const { userAgent } = await import("./client-
|
|
389
|
+
const { userAgent } = await import("./client-D_a50aIg.mjs");
|
|
390
390
|
await sendCrashReport(report, await userAgent());
|
|
391
391
|
}
|
|
392
392
|
} catch {}
|
|
@@ -412,4 +412,4 @@ function initCrashReporting() {
|
|
|
412
412
|
|
|
413
413
|
//#endregion
|
|
414
414
|
export { JSON_FOOTER_MARKER as a, CRASH_LOG_EXTENSION as i, reportCrash as n, parseCrashReportConfig as o, sendCrashReport as r, initCrashReporting as t };
|
|
415
|
-
//# sourceMappingURL=crashreport-
|
|
415
|
+
//# sourceMappingURL=crashreport-DauPOrKn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crashreport-CvmdFs4i.mjs","names":[],"sources":["../src/cli/crashreport/config.ts","../src/cli/crashreport/writer.ts","../src/cli/crashreport/sender.ts","../src/cli/crashreport/sanitize.ts","../src/cli/crashreport/report.ts","../src/cli/crashreport/index.ts"],"sourcesContent":["import * as path from \"pathe\";\nimport { isCI } from \"std-env\";\nimport { xdgConfig } from \"xdg-basedir\";\n\nexport interface CrashReportConfig {\n readonly localEnabled: boolean;\n readonly remoteEnabled: boolean;\n readonly localDir: string;\n}\n\n/**\n * Parse crash report configuration from environment variables.\n * Local crash log writing is enabled by default (opt-out via TAILOR_CRASH_REPORTS_LOCAL=off).\n * Remote sending is disabled by default (opt-in via TAILOR_CRASH_REPORTS_REMOTE=on).\n * Both are auto-disabled in CI environments.\n * @returns Crash report configuration\n */\nexport function parseCrashReportConfig(): CrashReportConfig {\n if (isCI) {\n return {\n localEnabled: false,\n remoteEnabled: false,\n localDir: \"\",\n };\n }\n\n const localEnabled = (process.env.TAILOR_CRASH_REPORTS_LOCAL ?? \"on\").toLowerCase() !== \"off\";\n const remoteEnabled = (process.env.TAILOR_CRASH_REPORTS_REMOTE ?? \"off\").toLowerCase() === \"on\";\n const localDir = xdgConfig ? path.join(xdgConfig, \"tailor-platform\", \"crash-reports\") : \"\";\n\n return {\n localEnabled: localEnabled && localDir !== \"\",\n remoteEnabled,\n localDir,\n };\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { ensureSecretDir, writeSecretFile } from \"@/cli/shared/secret-file\";\nimport type { CrashReport } from \"./report\";\n\nconst MAX_CRASH_FILES = 10;\n\n/** Marker line that separates human-readable content from the JSON footer. */\nexport const JSON_FOOTER_MARKER = \"--- JSON ---\";\n\n/** File extension for crash log files. */\nexport const CRASH_LOG_EXTENSION = \".crash.log\";\n\n/**\n * Format a CrashReport as human-readable text for local crash log files.\n * @param report - Crash report to format\n * @returns Formatted text content\n */\nexport function formatCrashReport(report: CrashReport): string {\n const lines = [\n `Crash Report: ${report.id}`,\n `Timestamp: ${report.timestamp}`,\n `Error Type: ${report.errorType}`,\n \"\",\n \"--- Environment ---\",\n `SDK Version: ${report.sdkVersion}`,\n `Node Version: ${report.nodeVersion}`,\n `OS: ${report.osPlatform} ${report.osRelease}`,\n `Arch: ${report.arch}`,\n \"\",\n \"--- Command ---\",\n `Command: ${report.command}`,\n `Arguments: ${JSON.stringify(report.argv)}`,\n \"\",\n \"--- Error ---\",\n `Name: ${report.errorName}`,\n `Message: ${report.errorMessage}`,\n \"\",\n \"--- Stack Trace ---\",\n report.stackTrace || \"(no stack trace available)\",\n \"\",\n JSON_FOOTER_MARKER,\n JSON.stringify(report),\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n\n/**\n * Generate a filename for a crash log file.\n * Format: {timestamp}-{shortId}.crash.log\n * @param report - Crash report to generate filename for\n * @returns Filename string\n */\nfunction generateFilename(report: CrashReport): string {\n const safeTimestamp = report.timestamp.replace(/[:.]/g, \"-\");\n const shortId = report.id.slice(0, 8);\n return `${safeTimestamp}-${shortId}${CRASH_LOG_EXTENSION}`;\n}\n\n/**\n * Remove old crash log files, keeping only the most recent ones.\n * @param dir - Crash log directory\n */\nfunction cleanupOldFiles(dir: string): void {\n try {\n const files = fs\n .readdirSync(dir)\n .filter((f) => f.endsWith(CRASH_LOG_EXTENSION))\n .sort()\n .reverse();\n\n for (const file of files.slice(MAX_CRASH_FILES)) {\n fs.unlinkSync(path.join(dir, file));\n }\n } catch {\n // Best-effort cleanup, ignore errors\n }\n}\n\n/**\n * Write a crash report to a local file.\n * Creates the directory if it doesn't exist. Keeps only the last 10 crash files.\n * Never throws - returns the file path on success or undefined on failure.\n * @param report - Crash report to write\n * @param dir - Directory to write the crash log file to\n * @returns File path on success, undefined on failure\n */\nexport function writeCrashReport(report: CrashReport, dir: string): string | undefined {\n try {\n ensureSecretDir(dir);\n\n const filename = generateFilename(report);\n const filePath = path.join(dir, filename);\n const content = formatCrashReport(report);\n\n writeSecretFile(filePath, content);\n cleanupOldFiles(dir);\n\n return filePath;\n } catch {\n return undefined;\n }\n}\n","import type { CrashReport } from \"./report\";\n\nconst SEND_TIMEOUT_MS = 5000;\nconst PRODUCTION_ENDPOINT = \"https://sdk-error-tracking-926vh9t4cl.erp.dev/query\";\n\nconst SUBMIT_MUTATION = `\nmutation SubmitCrashReport(\n $id: String!\n $timestamp: String!\n $sdkVersion: String!\n $nodeVersion: String!\n $osPlatform: String!\n $osRelease: String!\n $arch: String!\n $command: String!\n $argv: [String]\n $errorName: String!\n $errorMessage: String!\n $stackTrace: String\n $errorType: String!\n $userId: String\n $userEmail: String\n) {\n submitCrashReport(\n id: $id\n timestamp: $timestamp\n sdkVersion: $sdkVersion\n nodeVersion: $nodeVersion\n osPlatform: $osPlatform\n osRelease: $osRelease\n arch: $arch\n command: $command\n argv: $argv\n errorName: $errorName\n errorMessage: $errorMessage\n stackTrace: $stackTrace\n errorType: $errorType\n userId: $userId\n userEmail: $userEmail\n ) {\n success\n }\n}`;\n\n/**\n * Send a crash report to the remote endpoint via GraphQL mutation.\n * Best-effort: never throws, returns boolean success.\n * @param report - Crash report to send\n * @param ua - User-Agent header value\n * @returns true if the request succeeded, false otherwise\n */\nexport async function sendCrashReport(report: CrashReport, ua: string): Promise<boolean> {\n try {\n const endpoint = process.env.TAILOR_CRASH_REPORT_ENDPOINT || PRODUCTION_ENDPOINT;\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"User-Agent\": ua,\n },\n body: JSON.stringify({\n query: SUBMIT_MUTATION,\n variables: report,\n }),\n signal: AbortSignal.timeout(SEND_TIMEOUT_MS),\n });\n\n if (!response.ok) return false;\n\n const data = (await response.json()) as {\n errors?: unknown[];\n data?: { submitCrashReport: { success: boolean } };\n };\n if (data.errors?.length) return false;\n return data.data?.submitCrashReport.success === true;\n } catch {\n return false;\n }\n}\n","import * as os from \"node:os\";\n\nconst HOME_DIR = os.homedir();\n\n// Patterns for sanitization (global variants for use with .replace())\nconst UUID_PATTERN = /\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b/gi;\nconst LONG_HEX_PATTERN = /\\b[0-9a-fA-F]{32,}\\b/g;\nconst EMAIL_PATTERN = /\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\\b/g;\nconst ABSOLUTE_PATH_PATTERN = /(?:\\/(?:[\\w.@\\- ]+\\/)+[\\w.@\\- ]+)/g;\nconst WINDOWS_PATH_PATTERN = /(?:[A-Za-z]:\\\\(?:[\\w.@\\- ]+\\\\)+[\\w.@\\- ]+)/g;\nconst URL_QUERY_PATTERN = /[?&][^?\\s]*/g;\n\n// Non-global variants for single-match .test() calls (avoids lastIndex state issues)\nconst EMAIL_TEST_PATTERN = /\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\\b/;\nconst WINDOWS_DRIVE_TEST_PATTERN = /^[A-Za-z]:\\\\/;\n\n// SDK package path marker for relative paths\nconst SDK_PACKAGE_MARKER = \"packages/sdk/\";\n\nfunction lastSegment(filePath: string, separator: string): string {\n return filePath.split(separator).pop() ?? filePath;\n}\n\n/**\n * Sanitize a stack trace by replacing absolute paths with relative SDK paths.\n * External paths are replaced with `<external>/filename.ext`.\n * Home directories are replaced with `~/<redacted>/`.\n * @param stack - Raw stack trace string\n * @returns Sanitized stack trace\n */\nexport function sanitizeStackTrace(stack: string): string {\n // V8 stack traces start with \"ErrorType: message\\n at ...\".\n // The error message may span multiple lines before the first \" at \" frame.\n // Apply message sanitization to all message lines so secrets embedded in\n // multiline error messages are redacted consistently with errorMessage.\n const firstFrameIndex = stack.search(/\\n\\s+at /);\n let result: string;\n if (firstFrameIndex !== -1) {\n result = sanitizeMessage(stack.slice(0, firstFrameIndex)) + stack.slice(firstFrameIndex);\n } else {\n result = sanitizeMessage(stack);\n }\n\n result = result.replace(ABSOLUTE_PATH_PATTERN, (match) => {\n const sdkIndex = match.indexOf(SDK_PACKAGE_MARKER);\n if (sdkIndex !== -1) {\n return match.slice(sdkIndex);\n }\n\n if (match.startsWith(HOME_DIR)) {\n return `~/<redacted>/${lastSegment(match, \"/\")}`;\n }\n\n return `<external>/${lastSegment(match, \"/\")}`;\n });\n result = result.replace(WINDOWS_PATH_PATTERN, (match) => {\n const normalized = match.replace(/\\\\/g, \"/\");\n const sdkIndex = normalized.indexOf(SDK_PACKAGE_MARKER);\n if (sdkIndex !== -1) {\n return normalized.slice(sdkIndex);\n }\n return `<external>/${lastSegment(match, \"\\\\\")}`;\n });\n return result;\n}\n\n/**\n * Sanitize an error message by redacting sensitive information.\n * Redacts: UUIDs, long hex tokens, email addresses, absolute paths, URL query strings.\n * @param message - Raw error message\n * @returns Sanitized error message\n */\nexport function sanitizeMessage(message: string): string {\n let result = message;\n // Strip serialized request/response bodies that may contain secrets\n result = result.replace(/\\nRequest:\\s*[\\s\\S]*$/, \"\\nRequest: <redacted>\");\n result = result.replace(UUID_PATTERN, \"<uuid>\");\n result = result.replace(LONG_HEX_PATTERN, \"<redacted>\");\n result = result.replace(EMAIL_PATTERN, \"<email>\");\n result = result.replace(URL_QUERY_PATTERN, \"?<redacted>\");\n result = result.replace(ABSOLUTE_PATH_PATTERN, (match) => `<path>/${lastSegment(match, \"/\")}`);\n result = result.replace(WINDOWS_PATH_PATTERN, (match) => `<path>/${lastSegment(match, \"\\\\\")}`);\n\n return result;\n}\n\n/**\n * Sanitize process.argv by keeping command/subcommand names and redacting\n * values of sensitive flags.\n * @param argv - Raw process.argv array\n * @returns Sanitized argv array\n */\nexport function sanitizeArgv(argv: string[]): string[] {\n const result: string[] = [];\n let redactNext = false;\n\n for (const arg of argv) {\n if (redactNext) {\n // If the next token is itself a flag, treat it as a new flag rather\n // than consuming it as the previous flag's value. This avoids leaking\n // the *next* flag's value (e.g., `--verbose --workspace-id secret`\n // would otherwise expose `secret`).\n if (!arg.startsWith(\"-\")) {\n result.push(\"<redacted>\");\n redactNext = false;\n continue;\n }\n redactNext = false;\n }\n\n if (arg.startsWith(\"-\")) {\n // --flag=value: keep flag name, redact value\n const eqIndex = arg.indexOf(\"=\");\n if (eqIndex !== -1) {\n result.push(`${arg.slice(0, eqIndex)}=<redacted>`);\n continue;\n }\n\n // --flag / -f: keep flag name, redact next arg as its value\n result.push(arg);\n redactNext = true;\n continue;\n }\n\n // Redact absolute paths\n if (arg.startsWith(\"/\") && arg.includes(\"/\", 1)) {\n result.push(\"<path>\");\n continue;\n }\n\n // Redact Windows-style absolute paths\n if (WINDOWS_DRIVE_TEST_PATTERN.test(arg)) {\n result.push(\"<path>\");\n continue;\n }\n\n // Redact email addresses\n if (EMAIL_TEST_PATTERN.test(arg)) {\n result.push(\"<email>\");\n continue;\n }\n\n result.push(arg);\n }\n\n return result;\n}\n","import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { parseYAML } from \"confbox\";\nimport * as path from \"pathe\";\nimport { xdgConfig } from \"xdg-basedir\";\nimport { sanitizeArgv, sanitizeMessage, sanitizeStackTrace } from \"./sanitize\";\n\nexport type ErrorType = \"uncaughtException\" | \"unhandledRejection\" | \"handledError\";\n\nexport interface CrashReport {\n id: string;\n timestamp: string;\n sdkVersion: string;\n nodeVersion: string;\n osPlatform: string;\n osRelease: string;\n arch: string;\n command: string;\n argv: string[];\n errorName: string;\n errorMessage: string;\n stackTrace: string;\n errorType: ErrorType;\n userId: string | null;\n userEmail: string | null;\n}\n\ninterface BuildCrashReportOptions {\n error: unknown;\n sdkVersion: string;\n errorType: ErrorType;\n}\n\n// Maximum subcommand depth to keep (e.g., \"tailordb migrate generate\" = 3 tokens).\n// Positional arguments beyond this are potentially sensitive user input.\n// Accepted trade-off: plain-text positional args that don't match known patterns\n// (UUIDs, hex tokens, emails, paths) pass through to `command` and `argv`.\n// Full redaction would require embedding the CLI command tree here, which is fragile.\nconst MAX_COMMAND_TOKENS = 3;\n\n/**\n * Parse the command name from process.argv.\n * Extracts up to MAX_COMMAND_TOKENS non-flag arguments after the script name.\n * @returns Parsed command string\n */\nfunction parseCommand(): string {\n const args = process.argv.slice(2);\n const commandParts: string[] = [];\n for (const arg of args) {\n if (arg.startsWith(\"-\") || commandParts.length >= MAX_COMMAND_TOKENS) break;\n commandParts.push(arg);\n }\n return commandParts.join(\" \") || \"<unknown>\";\n}\n\n/**\n * Build a CrashReport data structure from an error and context.\n * All sensitive data is sanitized before inclusion.\n * @param options - Error, SDK version, and crash type\n * @returns Sanitized crash report\n */\nexport function buildCrashReport(options: BuildCrashReportOptions): CrashReport {\n const { error, sdkVersion, errorType } = options;\n\n const isError = error instanceof Error;\n const rawMessage = isError ? error.message : String(error);\n const rawStack = isError && error.stack ? error.stack : \"\";\n const errorName = isError ? error.name : \"UnknownError\";\n\n const currentUser = readCurrentUser();\n\n return {\n id: crypto.randomUUID(),\n timestamp: new Date().toISOString(),\n sdkVersion,\n nodeVersion: process.version,\n osPlatform: process.platform,\n osRelease: os.release(),\n arch: process.arch,\n command: sanitizeMessage(parseCommand()),\n argv: sanitizeArgv(process.argv),\n errorName,\n errorMessage: sanitizeMessage(rawMessage),\n stackTrace: sanitizeStackTrace(rawStack),\n errorType,\n userId: currentUser,\n userEmail: currentUser,\n };\n}\n\n/**\n * Read current_user from Tailor Platform config without side effects.\n * Unlike readPlatformConfig(), this never triggers migration or logs warnings.\n * @returns The current user email, or null if unavailable\n */\nfunction readCurrentUser(): string | null {\n try {\n if (!xdgConfig) return null;\n const configPath = path.join(xdgConfig, \"tailor-platform\", \"config.yaml\");\n if (!fs.existsSync(configPath)) return null;\n const raw = parseYAML(fs.readFileSync(configPath, \"utf-8\")) as { current_user?: string | null };\n return raw?.current_user ?? null;\n } catch {\n return null;\n }\n}\n","import { logger } from \"@/cli/shared/logger\";\nimport { readPackageJson } from \"@/cli/shared/package-json\";\nimport { parseCrashReportConfig } from \"./config\";\nimport { buildCrashReport, type ErrorType } from \"./report\";\nimport { sendCrashReport } from \"./sender\";\nimport { writeCrashReport } from \"./writer\";\n\n/**\n * Report an unexpected crash. Writes a local crash log file and optionally\n * sends the report to a remote endpoint. Displays a user-facing message\n * with the crash log path and a command to submit the report.\n *\n * Never throws - all errors are silently caught.\n * @param error - The error that caused the crash\n * @param errorType - How the error was caught\n */\nexport async function reportCrash(error: unknown, errorType: ErrorType): Promise<void> {\n try {\n const config = parseCrashReportConfig();\n if (!config.localEnabled && !config.remoteEnabled) return;\n\n const packageJson = await readPackageJson();\n const sdkVersion = packageJson.version ?? \"unknown\";\n\n const report = buildCrashReport({ error, sdkVersion, errorType });\n\n if (config.localEnabled) {\n const filePath = writeCrashReport(report, config.localDir);\n if (filePath) {\n logger.log(\n [\n \"\",\n \"An unexpected error occurred. A crash report has been saved to:\",\n ` ${filePath}`,\n \"\",\n \"To submit this report:\",\n ` tailor-sdk crashreport send --file \"${filePath}\"`,\n ].join(\"\\n\"),\n );\n }\n }\n\n if (config.remoteEnabled) {\n // Lazy import: client.ts pulls in heavy dependencies (OAuth2, Connect, Protobuf)\n // that should not be loaded on the startup critical path via initCrashReporting().\n const { userAgent } = await import(\"@/cli/shared/client\");\n const ua = await userAgent();\n await sendCrashReport(report, ua);\n }\n } catch {\n // Never throw from crash reporting\n }\n}\n\n/**\n * Register global uncaughtException and unhandledRejection handlers.\n * These catch errors outside the normal cleanup flow (e.g., during\n * argument parsing). Should be called once at CLI startup before runMain.\n */\nexport function initCrashReporting(): void {\n const config = parseCrashReportConfig();\n if (!config.localEnabled && !config.remoteEnabled) return;\n\n const handleFatal = (error: unknown, errorType: ErrorType) => {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(message);\n void reportCrash(error, errorType).finally(() => {\n process.exit(1);\n });\n };\n\n process.on(\"uncaughtException\", (error) => handleFatal(error, \"uncaughtException\"));\n process.on(\"unhandledRejection\", (reason) => handleFatal(reason, \"unhandledRejection\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,yBAA4C;CAC1D,IAAI,MACF,OAAO;EACL,cAAc;EACd,eAAe;EACf,UAAU;CACZ;CAGF,MAAM,gBAAgB,QAAQ,IAAI,8BAA8B,MAAM,YAAY,MAAM;CACxF,MAAM,iBAAiB,QAAQ,IAAI,+BAA+B,OAAO,YAAY,MAAM;CAC3F,MAAM,WAAW,YAAY,KAAK,KAAK,WAAW,mBAAmB,eAAe,IAAI;CAExF,OAAO;EACL,cAAc,gBAAgB,aAAa;EAC3C;EACA;CACF;AACF;;;;AC9BA,MAAM,kBAAkB;;AAGxB,MAAa,qBAAqB;;AAGlC,MAAa,sBAAsB;;;;;;AAOnC,SAAgB,kBAAkB,QAA6B;CA2B7D,OAAO;EAzBL,iBAAiB,OAAO;EACxB,cAAc,OAAO;EACrB,eAAe,OAAO;EACtB;EACA;EACA,gBAAgB,OAAO;EACvB,iBAAiB,OAAO;EACxB,OAAO,OAAO,WAAW,GAAG,OAAO;EACnC,SAAS,OAAO;EAChB;EACA;EACA,YAAY,OAAO;EACnB,cAAc,KAAK,UAAU,OAAO,IAAI;EACxC;EACA;EACA,SAAS,OAAO;EAChB,YAAY,OAAO;EACnB;EACA;EACA,OAAO,cAAc;EACrB;EACA;EACA,KAAK,UAAU,MAAM;EACrB;CAES,EAAE,KAAK,IAAI;AACxB;;;;;;;AAQA,SAAS,iBAAiB,QAA6B;CAGrD,OAAO,GAFe,OAAO,UAAU,QAAQ,SAAS,GAElC,EAAE,GADR,OAAO,GAAG,MAAM,GAAG,CACF,IAAI;AACvC;;;;;AAMA,SAAS,gBAAgB,KAAmB;CAC1C,IAAI;EACF,MAAM,QAAQ,GACX,YAAY,GAA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B;CACtC,IAAI,CAAC,OAAO,gBAAgB,CAAC,OAAO,eAAe;CAEnD,MAAM,eAAe,OAAgB,cAAyB;EAC5D,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,OAAO,MAAM,OAAO;EACpB,AAAK,YAAY,OAAO,SAAS,EAAE,cAAc;GAC/C,QAAQ,KAAK,CAAC;EAChB,CAAC;CACH;CAEA,QAAQ,GAAG,sBAAsB,UAAU,YAAY,OAAO,mBAAmB,CAAC;CAClF,QAAQ,GAAG,uBAAuB,WAAW,YAAY,QAAQ,oBAAoB,CAAC;AACxF"}
|
|
1
|
+
{"version":3,"file":"crashreport-DauPOrKn.mjs","names":[],"sources":["../src/cli/crashreport/config.ts","../src/cli/crashreport/writer.ts","../src/cli/crashreport/sender.ts","../src/cli/crashreport/sanitize.ts","../src/cli/crashreport/report.ts","../src/cli/crashreport/index.ts"],"sourcesContent":["import * as path from \"pathe\";\nimport { isCI } from \"std-env\";\nimport { xdgConfig } from \"xdg-basedir\";\n\nexport interface CrashReportConfig {\n readonly localEnabled: boolean;\n readonly remoteEnabled: boolean;\n readonly localDir: string;\n}\n\n/**\n * Parse crash report configuration from environment variables.\n * Local crash log writing is enabled by default (opt-out via TAILOR_CRASH_REPORTS_LOCAL=off).\n * Remote sending is disabled by default (opt-in via TAILOR_CRASH_REPORTS_REMOTE=on).\n * Both are auto-disabled in CI environments.\n * @returns Crash report configuration\n */\nexport function parseCrashReportConfig(): CrashReportConfig {\n if (isCI) {\n return {\n localEnabled: false,\n remoteEnabled: false,\n localDir: \"\",\n };\n }\n\n const localEnabled = (process.env.TAILOR_CRASH_REPORTS_LOCAL ?? \"on\").toLowerCase() !== \"off\";\n const remoteEnabled = (process.env.TAILOR_CRASH_REPORTS_REMOTE ?? \"off\").toLowerCase() === \"on\";\n const localDir = xdgConfig ? path.join(xdgConfig, \"tailor-platform\", \"crash-reports\") : \"\";\n\n return {\n localEnabled: localEnabled && localDir !== \"\",\n remoteEnabled,\n localDir,\n };\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { ensureSecretDir, writeSecretFile } from \"@/cli/shared/secret-file\";\nimport type { CrashReport } from \"./report\";\n\nconst MAX_CRASH_FILES = 10;\n\n/** Marker line that separates human-readable content from the JSON footer. */\nexport const JSON_FOOTER_MARKER = \"--- JSON ---\";\n\n/** File extension for crash log files. */\nexport const CRASH_LOG_EXTENSION = \".crash.log\";\n\n/**\n * Format a CrashReport as human-readable text for local crash log files.\n * @param report - Crash report to format\n * @returns Formatted text content\n */\nexport function formatCrashReport(report: CrashReport): string {\n const lines = [\n `Crash Report: ${report.id}`,\n `Timestamp: ${report.timestamp}`,\n `Error Type: ${report.errorType}`,\n \"\",\n \"--- Environment ---\",\n `SDK Version: ${report.sdkVersion}`,\n `Node Version: ${report.nodeVersion}`,\n `OS: ${report.osPlatform} ${report.osRelease}`,\n `Arch: ${report.arch}`,\n \"\",\n \"--- Command ---\",\n `Command: ${report.command}`,\n `Arguments: ${JSON.stringify(report.argv)}`,\n \"\",\n \"--- Error ---\",\n `Name: ${report.errorName}`,\n `Message: ${report.errorMessage}`,\n \"\",\n \"--- Stack Trace ---\",\n report.stackTrace || \"(no stack trace available)\",\n \"\",\n JSON_FOOTER_MARKER,\n JSON.stringify(report),\n \"\",\n ];\n return lines.join(\"\\n\");\n}\n\n/**\n * Generate a filename for a crash log file.\n * Format: {timestamp}-{shortId}.crash.log\n * @param report - Crash report to generate filename for\n * @returns Filename string\n */\nfunction generateFilename(report: CrashReport): string {\n const safeTimestamp = report.timestamp.replace(/[:.]/g, \"-\");\n const shortId = report.id.slice(0, 8);\n return `${safeTimestamp}-${shortId}${CRASH_LOG_EXTENSION}`;\n}\n\n/**\n * Remove old crash log files, keeping only the most recent ones.\n * @param dir - Crash log directory\n */\nfunction cleanupOldFiles(dir: string): void {\n try {\n const files = fs\n .readdirSync(dir)\n .filter((f) => f.endsWith(CRASH_LOG_EXTENSION))\n .sort()\n .reverse();\n\n for (const file of files.slice(MAX_CRASH_FILES)) {\n fs.unlinkSync(path.join(dir, file));\n }\n } catch {\n // Best-effort cleanup, ignore errors\n }\n}\n\n/**\n * Write a crash report to a local file.\n * Creates the directory if it doesn't exist. Keeps only the last 10 crash files.\n * Never throws - returns the file path on success or undefined on failure.\n * @param report - Crash report to write\n * @param dir - Directory to write the crash log file to\n * @returns File path on success, undefined on failure\n */\nexport function writeCrashReport(report: CrashReport, dir: string): string | undefined {\n try {\n ensureSecretDir(dir);\n\n const filename = generateFilename(report);\n const filePath = path.join(dir, filename);\n const content = formatCrashReport(report);\n\n writeSecretFile(filePath, content);\n cleanupOldFiles(dir);\n\n return filePath;\n } catch {\n return undefined;\n }\n}\n","import type { CrashReport } from \"./report\";\n\nconst SEND_TIMEOUT_MS = 5000;\nconst PRODUCTION_ENDPOINT = \"https://sdk-error-tracking-926vh9t4cl.erp.dev/query\";\n\nconst SUBMIT_MUTATION = `\nmutation SubmitCrashReport(\n $id: String!\n $timestamp: String!\n $sdkVersion: String!\n $nodeVersion: String!\n $osPlatform: String!\n $osRelease: String!\n $arch: String!\n $command: String!\n $argv: [String]\n $errorName: String!\n $errorMessage: String!\n $stackTrace: String\n $errorType: String!\n $userId: String\n $userEmail: String\n) {\n submitCrashReport(\n id: $id\n timestamp: $timestamp\n sdkVersion: $sdkVersion\n nodeVersion: $nodeVersion\n osPlatform: $osPlatform\n osRelease: $osRelease\n arch: $arch\n command: $command\n argv: $argv\n errorName: $errorName\n errorMessage: $errorMessage\n stackTrace: $stackTrace\n errorType: $errorType\n userId: $userId\n userEmail: $userEmail\n ) {\n success\n }\n}`;\n\n/**\n * Send a crash report to the remote endpoint via GraphQL mutation.\n * Best-effort: never throws, returns boolean success.\n * @param report - Crash report to send\n * @param ua - User-Agent header value\n * @returns true if the request succeeded, false otherwise\n */\nexport async function sendCrashReport(report: CrashReport, ua: string): Promise<boolean> {\n try {\n const endpoint = process.env.TAILOR_CRASH_REPORT_ENDPOINT || PRODUCTION_ENDPOINT;\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"User-Agent\": ua,\n },\n body: JSON.stringify({\n query: SUBMIT_MUTATION,\n variables: report,\n }),\n signal: AbortSignal.timeout(SEND_TIMEOUT_MS),\n });\n\n if (!response.ok) return false;\n\n const data = (await response.json()) as {\n errors?: unknown[];\n data?: { submitCrashReport: { success: boolean } };\n };\n if (data.errors?.length) return false;\n return data.data?.submitCrashReport.success === true;\n } catch {\n return false;\n }\n}\n","import * as os from \"node:os\";\n\nconst HOME_DIR = os.homedir();\n\n// Patterns for sanitization (global variants for use with .replace())\nconst UUID_PATTERN = /\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b/gi;\nconst LONG_HEX_PATTERN = /\\b[0-9a-fA-F]{32,}\\b/g;\nconst EMAIL_PATTERN = /\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\\b/g;\nconst ABSOLUTE_PATH_PATTERN = /(?:\\/(?:[\\w.@\\- ]+\\/)+[\\w.@\\- ]+)/g;\nconst WINDOWS_PATH_PATTERN = /(?:[A-Za-z]:\\\\(?:[\\w.@\\- ]+\\\\)+[\\w.@\\- ]+)/g;\nconst URL_QUERY_PATTERN = /[?&][^?\\s]*/g;\n\n// Non-global variants for single-match .test() calls (avoids lastIndex state issues)\nconst EMAIL_TEST_PATTERN = /\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\\b/;\nconst WINDOWS_DRIVE_TEST_PATTERN = /^[A-Za-z]:\\\\/;\n\n// SDK package path marker for relative paths\nconst SDK_PACKAGE_MARKER = \"packages/sdk/\";\n\nfunction lastSegment(filePath: string, separator: string): string {\n return filePath.split(separator).pop() ?? filePath;\n}\n\n/**\n * Sanitize a stack trace by replacing absolute paths with relative SDK paths.\n * External paths are replaced with `<external>/filename.ext`.\n * Home directories are replaced with `~/<redacted>/`.\n * @param stack - Raw stack trace string\n * @returns Sanitized stack trace\n */\nexport function sanitizeStackTrace(stack: string): string {\n // V8 stack traces start with \"ErrorType: message\\n at ...\".\n // The error message may span multiple lines before the first \" at \" frame.\n // Apply message sanitization to all message lines so secrets embedded in\n // multiline error messages are redacted consistently with errorMessage.\n const firstFrameIndex = stack.search(/\\n\\s+at /);\n let result: string;\n if (firstFrameIndex !== -1) {\n result = sanitizeMessage(stack.slice(0, firstFrameIndex)) + stack.slice(firstFrameIndex);\n } else {\n result = sanitizeMessage(stack);\n }\n\n result = result.replace(ABSOLUTE_PATH_PATTERN, (match) => {\n const sdkIndex = match.indexOf(SDK_PACKAGE_MARKER);\n if (sdkIndex !== -1) {\n return match.slice(sdkIndex);\n }\n\n if (match.startsWith(HOME_DIR)) {\n return `~/<redacted>/${lastSegment(match, \"/\")}`;\n }\n\n return `<external>/${lastSegment(match, \"/\")}`;\n });\n result = result.replace(WINDOWS_PATH_PATTERN, (match) => {\n const normalized = match.replace(/\\\\/g, \"/\");\n const sdkIndex = normalized.indexOf(SDK_PACKAGE_MARKER);\n if (sdkIndex !== -1) {\n return normalized.slice(sdkIndex);\n }\n return `<external>/${lastSegment(match, \"\\\\\")}`;\n });\n return result;\n}\n\n/**\n * Sanitize an error message by redacting sensitive information.\n * Redacts: UUIDs, long hex tokens, email addresses, absolute paths, URL query strings.\n * @param message - Raw error message\n * @returns Sanitized error message\n */\nexport function sanitizeMessage(message: string): string {\n let result = message;\n // Strip serialized request/response bodies that may contain secrets\n result = result.replace(/\\nRequest:\\s*[\\s\\S]*$/, \"\\nRequest: <redacted>\");\n result = result.replace(UUID_PATTERN, \"<uuid>\");\n result = result.replace(LONG_HEX_PATTERN, \"<redacted>\");\n result = result.replace(EMAIL_PATTERN, \"<email>\");\n result = result.replace(URL_QUERY_PATTERN, \"?<redacted>\");\n result = result.replace(ABSOLUTE_PATH_PATTERN, (match) => `<path>/${lastSegment(match, \"/\")}`);\n result = result.replace(WINDOWS_PATH_PATTERN, (match) => `<path>/${lastSegment(match, \"\\\\\")}`);\n\n return result;\n}\n\n/**\n * Sanitize process.argv by keeping command/subcommand names and redacting\n * values of sensitive flags.\n * @param argv - Raw process.argv array\n * @returns Sanitized argv array\n */\nexport function sanitizeArgv(argv: string[]): string[] {\n const result: string[] = [];\n let redactNext = false;\n\n for (const arg of argv) {\n if (redactNext) {\n // If the next token is itself a flag, treat it as a new flag rather\n // than consuming it as the previous flag's value. This avoids leaking\n // the *next* flag's value (e.g., `--verbose --workspace-id secret`\n // would otherwise expose `secret`).\n if (!arg.startsWith(\"-\")) {\n result.push(\"<redacted>\");\n redactNext = false;\n continue;\n }\n redactNext = false;\n }\n\n if (arg.startsWith(\"-\")) {\n // --flag=value: keep flag name, redact value\n const eqIndex = arg.indexOf(\"=\");\n if (eqIndex !== -1) {\n result.push(`${arg.slice(0, eqIndex)}=<redacted>`);\n continue;\n }\n\n // --flag / -f: keep flag name, redact next arg as its value\n result.push(arg);\n redactNext = true;\n continue;\n }\n\n // Redact absolute paths\n if (arg.startsWith(\"/\") && arg.includes(\"/\", 1)) {\n result.push(\"<path>\");\n continue;\n }\n\n // Redact Windows-style absolute paths\n if (WINDOWS_DRIVE_TEST_PATTERN.test(arg)) {\n result.push(\"<path>\");\n continue;\n }\n\n // Redact email addresses\n if (EMAIL_TEST_PATTERN.test(arg)) {\n result.push(\"<email>\");\n continue;\n }\n\n result.push(arg);\n }\n\n return result;\n}\n","import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { parseYAML } from \"confbox\";\nimport * as path from \"pathe\";\nimport { xdgConfig } from \"xdg-basedir\";\nimport { sanitizeArgv, sanitizeMessage, sanitizeStackTrace } from \"./sanitize\";\n\nexport type ErrorType = \"uncaughtException\" | \"unhandledRejection\" | \"handledError\";\n\nexport interface CrashReport {\n id: string;\n timestamp: string;\n sdkVersion: string;\n nodeVersion: string;\n osPlatform: string;\n osRelease: string;\n arch: string;\n command: string;\n argv: string[];\n errorName: string;\n errorMessage: string;\n stackTrace: string;\n errorType: ErrorType;\n userId: string | null;\n userEmail: string | null;\n}\n\ninterface BuildCrashReportOptions {\n error: unknown;\n sdkVersion: string;\n errorType: ErrorType;\n}\n\n// Maximum subcommand depth to keep (e.g., \"tailordb migrate generate\" = 3 tokens).\n// Positional arguments beyond this are potentially sensitive user input.\n// Accepted trade-off: plain-text positional args that don't match known patterns\n// (UUIDs, hex tokens, emails, paths) pass through to `command` and `argv`.\n// Full redaction would require embedding the CLI command tree here, which is fragile.\nconst MAX_COMMAND_TOKENS = 3;\n\n/**\n * Parse the command name from process.argv.\n * Extracts up to MAX_COMMAND_TOKENS non-flag arguments after the script name.\n * @returns Parsed command string\n */\nfunction parseCommand(): string {\n const args = process.argv.slice(2);\n const commandParts: string[] = [];\n for (const arg of args) {\n if (arg.startsWith(\"-\") || commandParts.length >= MAX_COMMAND_TOKENS) break;\n commandParts.push(arg);\n }\n return commandParts.join(\" \") || \"<unknown>\";\n}\n\n/**\n * Build a CrashReport data structure from an error and context.\n * All sensitive data is sanitized before inclusion.\n * @param options - Error, SDK version, and crash type\n * @returns Sanitized crash report\n */\nexport function buildCrashReport(options: BuildCrashReportOptions): CrashReport {\n const { error, sdkVersion, errorType } = options;\n\n const isError = error instanceof Error;\n const rawMessage = isError ? error.message : String(error);\n const rawStack = isError && error.stack ? error.stack : \"\";\n const errorName = isError ? error.name : \"UnknownError\";\n\n const currentUser = readCurrentUser();\n\n return {\n id: crypto.randomUUID(),\n timestamp: new Date().toISOString(),\n sdkVersion,\n nodeVersion: process.version,\n osPlatform: process.platform,\n osRelease: os.release(),\n arch: process.arch,\n command: sanitizeMessage(parseCommand()),\n argv: sanitizeArgv(process.argv),\n errorName,\n errorMessage: sanitizeMessage(rawMessage),\n stackTrace: sanitizeStackTrace(rawStack),\n errorType,\n userId: currentUser,\n userEmail: currentUser,\n };\n}\n\n/**\n * Read current_user from Tailor Platform config without side effects.\n * Unlike readPlatformConfig(), this never triggers migration or logs warnings.\n * @returns The current user email, or null if unavailable\n */\nfunction readCurrentUser(): string | null {\n try {\n if (!xdgConfig) return null;\n const configPath = path.join(xdgConfig, \"tailor-platform\", \"config.yaml\");\n if (!fs.existsSync(configPath)) return null;\n const raw = parseYAML(fs.readFileSync(configPath, \"utf-8\")) as { current_user?: string | null };\n return raw?.current_user ?? null;\n } catch {\n return null;\n }\n}\n","import { logger } from \"@/cli/shared/logger\";\nimport { readPackageJson } from \"@/cli/shared/package-json\";\nimport { parseCrashReportConfig } from \"./config\";\nimport { buildCrashReport, type ErrorType } from \"./report\";\nimport { sendCrashReport } from \"./sender\";\nimport { writeCrashReport } from \"./writer\";\n\n/**\n * Report an unexpected crash. Writes a local crash log file and optionally\n * sends the report to a remote endpoint. Displays a user-facing message\n * with the crash log path and a command to submit the report.\n *\n * Never throws - all errors are silently caught.\n * @param error - The error that caused the crash\n * @param errorType - How the error was caught\n */\nexport async function reportCrash(error: unknown, errorType: ErrorType): Promise<void> {\n try {\n const config = parseCrashReportConfig();\n if (!config.localEnabled && !config.remoteEnabled) return;\n\n const packageJson = await readPackageJson();\n const sdkVersion = packageJson.version ?? \"unknown\";\n\n const report = buildCrashReport({ error, sdkVersion, errorType });\n\n if (config.localEnabled) {\n const filePath = writeCrashReport(report, config.localDir);\n if (filePath) {\n logger.log(\n [\n \"\",\n \"An unexpected error occurred. A crash report has been saved to:\",\n ` ${filePath}`,\n \"\",\n \"To submit this report:\",\n ` tailor-sdk crashreport send --file \"${filePath}\"`,\n ].join(\"\\n\"),\n );\n }\n }\n\n if (config.remoteEnabled) {\n // Lazy import: client.ts pulls in heavy dependencies (OAuth2, Connect, Protobuf)\n // that should not be loaded on the startup critical path via initCrashReporting().\n const { userAgent } = await import(\"@/cli/shared/client\");\n const ua = await userAgent();\n await sendCrashReport(report, ua);\n }\n } catch {\n // Never throw from crash reporting\n }\n}\n\n/**\n * Register global uncaughtException and unhandledRejection handlers.\n * These catch errors outside the normal cleanup flow (e.g., during\n * argument parsing). Should be called once at CLI startup before runMain.\n */\nexport function initCrashReporting(): void {\n const config = parseCrashReportConfig();\n if (!config.localEnabled && !config.remoteEnabled) return;\n\n const handleFatal = (error: unknown, errorType: ErrorType) => {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(message);\n void reportCrash(error, errorType).finally(() => {\n process.exit(1);\n });\n };\n\n process.on(\"uncaughtException\", (error) => handleFatal(error, \"uncaughtException\"));\n process.on(\"unhandledRejection\", (reason) => handleFatal(reason, \"unhandledRejection\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,yBAA4C;CAC1D,IAAI,MACF,OAAO;EACL,cAAc;EACd,eAAe;EACf,UAAU;CACZ;CAGF,MAAM,gBAAgB,QAAQ,IAAI,8BAA8B,MAAM,YAAY,MAAM;CACxF,MAAM,iBAAiB,QAAQ,IAAI,+BAA+B,OAAO,YAAY,MAAM;CAC3F,MAAM,WAAW,YAAY,KAAK,KAAK,WAAW,mBAAmB,eAAe,IAAI;CAExF,OAAO;EACL,cAAc,gBAAgB,aAAa;EAC3C;EACA;CACF;AACF;;;;AC9BA,MAAM,kBAAkB;;AAGxB,MAAa,qBAAqB;;AAGlC,MAAa,sBAAsB;;;;;;AAOnC,SAAgB,kBAAkB,QAA6B;CA2B7D,OAAO;EAzBL,iBAAiB,OAAO;EACxB,cAAc,OAAO;EACrB,eAAe,OAAO;EACtB;EACA;EACA,gBAAgB,OAAO;EACvB,iBAAiB,OAAO;EACxB,OAAO,OAAO,WAAW,GAAG,OAAO;EACnC,SAAS,OAAO;EAChB;EACA;EACA,YAAY,OAAO;EACnB,cAAc,KAAK,UAAU,OAAO,IAAI;EACxC;EACA;EACA,SAAS,OAAO;EAChB,YAAY,OAAO;EACnB;EACA;EACA,OAAO,cAAc;EACrB;EACA;EACA,KAAK,UAAU,MAAM;EACrB;CAES,EAAE,KAAK,IAAI;AACxB;;;;;;;AAQA,SAAS,iBAAiB,QAA6B;CAGrD,OA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AO,eAAe;GAGxB,MAAM,EAAE,cAAc,MAAM,OAAO;GAEnC,MAAM,gBAAgB,QAAQ,MADb,UAAU,CACK;EAClC;CACF,QAAQ,CAER;AACF;;;;;;AAOA,SAAgB,qBAA2B;CACzC,MAAM,SAAS,uBAAuB;CACtC,IAAI,CAAC,OAAO,gBAAgB,CAAC,OAAO,eAAe;CAEnD,MAAM,eAAe,OAAgB,cAAyB;EAC5D,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,OAAO,MAAM,OAAO;EACpB,AAAK,YAAY,OAAO,SAAS,EAAE,cAAc;GAC/C,QAAQ,KAAK,CAAC;EAChB,CAAC;CACH;CAEA,QAAQ,GAAG,sBAAsB,UAAU,YAAY,OAAO,mBAAmB,CAAC;CAClF,QAAQ,GAAG,uBAAuB,WAAW,YAAY,QAAQ,oBAAoB,CAAC;AACxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-constants-
|
|
1
|
+
{"version":3,"file":"enum-constants-DI85-fPE.mjs","names":[],"sources":["../src/plugin/builtin/enum-constants/generate-enum-constants.ts","../src/plugin/builtin/enum-constants/process-enum-type.ts","../src/plugin/builtin/enum-constants/index.ts"],"sourcesContent":["import type { EnumDefinition } from \"./types\";\n\n/**\n * Generate enum constant definitions from collected metadata.\n * @param allEnums - All collected enum definitions\n * @returns Generated enum constant definitions\n */\nexport function generateUnifiedEnumConstants(allEnums: EnumDefinition[]): string {\n if (allEnums.length === 0) {\n return \"\";\n }\n\n const enumMap = new Map<string, EnumDefinition>();\n for (const enumDef of allEnums) {\n enumMap.set(enumDef.name, enumDef);\n }\n\n const enumDefs = Array.from(enumMap.values())\n .map((e) => {\n const members = e.values\n .map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` \"${key}\": \"${v.value}\"`;\n })\n .join(\",\\n\");\n\n const hasDescriptions = e.values.some((v) => v.description);\n let jsDoc = \"\";\n if (e.fieldDescription || hasDescriptions) {\n const lines: string[] = [];\n\n if (e.fieldDescription) {\n lines.push(` * ${e.fieldDescription}`);\n if (hasDescriptions) {\n lines.push(\" *\");\n }\n }\n\n if (hasDescriptions) {\n const propertyDocs = e.values.map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` * @property ${[key, v.description].filter(Boolean).join(\" - \")}`;\n });\n lines.push(...propertyDocs);\n }\n\n if (lines.length > 0) {\n jsDoc = `/**\\n${lines.join(\"\\n\")}\\n */\\n`;\n }\n }\n\n const constDef = `${jsDoc}export const ${e.name} = {\\n${members}\\n} as const;`;\n const typeDef = `export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`;\n return `${constDef}\\n${typeDef}`;\n })\n .join(\"\\n\\n\");\n\n if (!enumDefs) {\n return \"\";\n }\n\n return enumDefs + \"\\n\";\n}\n","import type { EnumConstantMetadata } from \"./types\";\nimport type { TailorDBType } from \"@/types/tailordb\";\n\nfunction capitalizeFirst(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction collectEnums(type: TailorDBType): EnumConstantMetadata[\"enums\"] {\n const enums: EnumConstantMetadata[\"enums\"] = [];\n\n for (const [fieldName, parsedField] of Object.entries(type.fields)) {\n if (parsedField.config.type === \"enum\" && parsedField.config.allowedValues) {\n const enumTypeName = `${type.name}${capitalizeFirst(fieldName)}`;\n enums.push({\n name: enumTypeName,\n values: parsedField.config.allowedValues,\n fieldDescription: parsedField.config.description,\n });\n }\n\n // Process nested fields\n if (parsedField.config.type === \"nested\" && parsedField.config.fields) {\n for (const [nestedFieldName, nestedFieldConfig] of Object.entries(\n parsedField.config.fields,\n )) {\n if (nestedFieldConfig.type === \"enum\" && nestedFieldConfig.allowedValues) {\n const fullFieldName = `${fieldName}${capitalizeFirst(nestedFieldName)}`;\n const enumTypeName = `${type.name}${capitalizeFirst(fullFieldName)}`;\n enums.push({\n name: enumTypeName,\n values: nestedFieldConfig.allowedValues,\n fieldDescription: nestedFieldConfig.description,\n });\n }\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Process a TailorDB type and extract enum metadata.\n * @param type - The parsed TailorDB type to process\n * @returns Enum constant metadata for the type\n */\nexport async function processEnumType(type: TailorDBType): Promise<EnumConstantMetadata> {\n const enums = collectEnums(type);\n\n return {\n name: type.name,\n enums,\n };\n}\n","import { generateUnifiedEnumConstants } from \"./generate-enum-constants\";\nimport { processEnumType } from \"./process-enum-type\";\nimport type { EnumDefinition } from \"./types\";\nimport type { Plugin } from \"@/types/plugin\";\nimport type { GeneratorResult, TailorDBReadyContext } from \"@/types/plugin-generation\";\n\n/** Unique identifier for the enum constants generator plugin. */\nexport const EnumConstantsGeneratorID = \"@tailor-platform/enum-constants\";\n\ntype EnumConstantsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates enum constants from TailorDB type definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated constants\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function enumConstantsPlugin(\n options: EnumConstantsPluginOptions,\n): Plugin<unknown, EnumConstantsPluginOptions> {\n return {\n id: EnumConstantsGeneratorID,\n description: \"Generates enum constants from TailorDB type definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<EnumConstantsPluginOptions>,\n ): Promise<GeneratorResult> {\n const allEnums: EnumDefinition[] = [];\n\n for (const ns of ctx.tailordb) {\n for (const type of Object.values(ns.types)) {\n const metadata = await processEnumType(type);\n allEnums.push(...metadata.enums);\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allEnums.length > 0) {\n const content = generateUnifiedEnumConstants(allEnums);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,6BAA6B,UAAoC;CAC/E,IAAI,SAAS,WAAW,GACtB,OAAO;CAGT,MAAM,0BAAU,IAAI,IAA4B;CAChD,KAAK,MAAM,WAAW,UACpB,QAAQ,IAAI,QAAQ,MAAM,O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"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-C4cJ0M2K.mjs","names":[],"sources":["../src/cli/shared/errors.ts"],"sourcesContent":["import chalk from \"chalk\";\n\n/**\n * Options for creating a CLI error\n */\nexport interface CLIErrorOptions {\n message: string;\n details?: string;\n suggestion?: string;\n command?: string;\n code?: string;\n}\n\n/**\n * CLI error interface with formatted output\n */\nexport interface CLIError extends Error {\n readonly code?: string;\n readonly details?: string;\n readonly suggestion?: string;\n readonly command?: string;\n format(): string;\n}\n\ntype CLIErrorInternal = Error & {\n code?: string;\n details?: string;\n suggestion?: string;\n command?: string;\n format(): string;\n};\n\n/**\n * Format CLI error for output\n * @param error - CLIError instance to format\n * @returns Formatted error message\n */\nfunction formatError(error: CLIError): string {\n const parts: string[] = [\n chalk.red(`Error${error.code ? ` [${error.code}]` : \"\"}: ${error.message}`),\n ];\n\n if (error.details) {\n parts.push(`\\n ${chalk.gray(\"Details:\")} ${error.details}`);\n }\n\n if (error.suggestion) {\n parts.push(`\\n ${chalk.cyan(\"Suggestion:\")} ${error.suggestion}`);\n }\n\n if (error.command) {\n parts.push(\n `\\n ${chalk.gray(\"Help:\")} Run \\`tailor-sdk ${error.command} --help\\` for usage information.`,\n );\n }\n\n return parts.join(\"\");\n}\n\n/**\n * Create a CLI error with formatted output\n * @param options - Options to construct a CLIError\n * @returns Constructed CLIError instance\n */\nfunction createCLIError(options: CLIErrorOptions): CLIError {\n const error = new Error(options.message) as CLIErrorInternal;\n error.name = \"CLIError\";\n error.code = options.code;\n error.details = options.details;\n error.suggestion = options.suggestion;\n error.command = options.command;\n error.format = () => formatError(error);\n return error;\n}\n\n/**\n * Type guard to check if an error is a CLIError\n * @param error - Error to check\n * @returns True if the error is a CLIError\n */\nexport function isCLIError(error: unknown): error is CLIError {\n return error instanceof Error && error.name === \"CLIError\";\n}\n\n// Re-export createCLIError as CLIError for backward compatibility\nexport { createCLIError as CLIError };\n"],"mappings":";;;;;;;;;AAqCA,SAAS,YAAY,OAAyB;CAC5C,MAAM,QAAkB,CACtB,MAAM,IAAI,QAAQ,MAAM,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAI,MAAM,SAAS,CAC5E;CAEA,IAAI,MAAM,SACR,MAAM,KAAK,OAAO,MAAM,KAAK,UAAU,EAAE,GAAG,MAAM,SAAS;CAG7D,IAAI,MAAM,YACR,MAAM,KAAK,OAAO,MAAM,KAAK,aAAa,EAAE,GAAG,MAAM,YAAY;CAGnE,IAAI,MAAM,SACR,MAAM,KACJ,OAAO,MAAM,KAAK,OAAO,EAAE,oBAAoB,MAAM,QAAQ,iCAC/D;CAGF,OAAO,MAAM,KAAK,EAAE;AACtB;;;;;;AAOA,SAAS,eAAe,SAAoC;CAC1D,MAAM,QAAQ,IAAI,MAAM,QAAQ,OAAO;CACvC,MAAM,OAAO;CACb,MAAM,OAAO,QAAQ;CACrB,MAAM,UAAU,QAAQ;CACxB,MAAM,aAAa,QAAQ;CAC3B,MAAM,UAAU,QAAQ;CACxB,MAAM,eAAe,YAAY,KAAK;CACtC,OAAO;AACT;;;;;;AAOA,SAAgB,WAAW,OAAmC;CAC5D,OAAO,iBAAiB,SAAS,MAAM,SAAS;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-
|
|
1
|
+
{"version":3,"file":"field-BY2vbJ8f.mjs","names":[],"sources":["../src/configure/types/field.ts"],"sourcesContent":["import type { EnumValue } from \"@/types/field-types\";\n\nexport type AllowedValues = readonly [string | EnumValue, ...(string | EnumValue)[]];\n\n/**\n * Normalize allowed values into EnumValue objects with descriptions.\n * @param values - Allowed values as strings or EnumValue objects\n * @returns Normalized allowed values\n */\nexport function mapAllowedValues(values: AllowedValues): EnumValue[] {\n return values.map((value) => {\n if (typeof value === \"string\") {\n return { value, description: \"\" };\n }\n return { ...value, description: value.description ?? \"\" };\n });\n}\n\nexport type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T\n ? T extends string\n ? T\n : T extends { value: infer K }\n ? K\n : never\n : never;\n"],"mappings":";;;;;;;AASA,SAAgB,iBAAiB,QAAoC;CACnE,OAAO,OAAO,KAAK,UAAU;EAC3B,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,aAAa;EAAG;EAElC,OAAO;GAAE,GAAG;GAAO,aAAa,MAAM,eAAe;EAAG;CAC1D,CAAC;AACH"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
import { t as __exportAll } from "./chunk-DLeslSnM.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/file.ts
|
|
5
|
+
var file_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
delete: () => deleteFile,
|
|
7
|
+
deleteFile: () => deleteFile,
|
|
8
|
+
download: () => download,
|
|
9
|
+
downloadAsBase64: () => downloadAsBase64,
|
|
10
|
+
getMetadata: () => getMetadata,
|
|
11
|
+
openDownloadStream: () => openDownloadStream,
|
|
12
|
+
upload: () => upload
|
|
13
|
+
});
|
|
14
|
+
const api = () => globalThis.tailordb.file;
|
|
15
|
+
/**
|
|
16
|
+
* See {@link TailorDBFileAPI.upload}.
|
|
17
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.upload}
|
|
18
|
+
* @returns Upload response containing the file metadata
|
|
19
|
+
*/
|
|
20
|
+
const upload = (...args) => api().upload(...args);
|
|
21
|
+
/**
|
|
22
|
+
* See {@link TailorDBFileAPI.download}.
|
|
23
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.download}
|
|
24
|
+
* @returns Bytes and metadata for the file
|
|
25
|
+
*/
|
|
26
|
+
const download = (...args) => api().download(...args);
|
|
27
|
+
/**
|
|
28
|
+
* See {@link TailorDBFileAPI.downloadAsBase64}.
|
|
29
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.downloadAsBase64}
|
|
30
|
+
* @returns Base64-encoded contents and metadata for the file
|
|
31
|
+
*/
|
|
32
|
+
const downloadAsBase64 = (...args) => api().downloadAsBase64(...args);
|
|
33
|
+
/**
|
|
34
|
+
* See {@link TailorDBFileAPI.delete}.
|
|
35
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.delete}
|
|
36
|
+
* @returns Resolves once the file has been deleted
|
|
37
|
+
*/
|
|
38
|
+
const deleteFile = (...args) => api().delete(...args);
|
|
39
|
+
/**
|
|
40
|
+
* See {@link TailorDBFileAPI.getMetadata}.
|
|
41
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.getMetadata}
|
|
42
|
+
* @returns Metadata for the stored file
|
|
43
|
+
*/
|
|
44
|
+
const getMetadata = (...args) => api().getMetadata(...args);
|
|
45
|
+
/**
|
|
46
|
+
* See {@link TailorDBFileAPI.openDownloadStream}.
|
|
47
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.openDownloadStream}
|
|
48
|
+
* @returns Async iterator yielding file chunks; call `close()` to release resources
|
|
49
|
+
*/
|
|
50
|
+
const openDownloadStream = (...args) => api().openDownloadStream(...args);
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { getMetadata as a, file_exports as i, download as n, openDownloadStream as o, downloadAsBase64 as r, upload as s, deleteFile as t };
|
|
54
|
+
//# sourceMappingURL=file-BE5Sy7lP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-BE5Sy7lP.mjs","names":[],"sources":["../src/runtime/file.ts"],"sourcesContent":["/**\n * TailorDB file (BLOB) utilities.\n *\n * Thin typed wrapper around the platform-provided `tailordb.file` runtime API.\n * At runtime this delegates to `globalThis.tailordb.file`. Use `fileMock` from\n * `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { file } from \"@tailor-platform/sdk/runtime\";\n *\n * const { metadata } = await file.upload(\n * \"my-namespace\",\n * \"Document\",\n * \"attachment\",\n * recordId,\n * bytes,\n * );\n */\n\n/** Upload response metadata. */\nexport interface UploadMetadata {\n fileSize: number;\n sha256sum: string;\n}\n\n/** Download response metadata. */\nexport interface DownloadMetadata {\n contentType: string;\n fileSize: number;\n sha256sum: string;\n lastUploadedAt: string;\n}\n\n/** File metadata (for {@link getMetadata}). */\nexport interface FileMetadata {\n contentType: string;\n fileSize: number;\n sha256sum: string;\n urlPath: string;\n lastUploadedAt?: string;\n}\n\n/** Stream metadata (first chunk emitted by {@link openDownloadStream}). */\nexport interface StreamMetadata {\n contentType: string;\n fileSize: number;\n sha256sum: string;\n}\n\n/** Upload options. */\nexport interface FileUploadOptions {\n contentType?: string;\n}\n\n/** Upload response. */\nexport interface FileUploadResponse {\n metadata: UploadMetadata;\n}\n\n/** Download response. */\nexport interface FileDownloadResponse {\n data: Uint8Array;\n metadata: DownloadMetadata;\n}\n\n/** Download-as-Base64 response. */\nexport interface FileDownloadAsBase64Response {\n data: string;\n metadata: DownloadMetadata;\n}\n\n/** Stream chunk types emitted by {@link FileStreamIterator}. */\nexport type StreamValue =\n | { type: \"metadata\"; metadata: StreamMetadata }\n | { type: \"chunk\"; data: Uint8Array; position: number }\n | { type: \"complete\" };\n\n/** Stream iterator returned by {@link openDownloadStream}. */\nexport interface FileStreamIterator extends AsyncIterableIterator<StreamValue> {\n next(): Promise<IteratorResult<StreamValue>>;\n close(): Promise<void>;\n}\n\n/** Error code emitted by {@link TailorDBFileError}. */\nexport type TailorDBFileErrorCode =\n | \"INVALID_PARAMS\"\n | \"INVALID_DATA_TYPE\"\n | \"OPERATION_FAILED\"\n | \"DELETE_FAILED\"\n | \"STREAM_OPEN_FAILED\"\n | \"STREAM_READ_ERROR\"\n | \"STREAM_ERROR\"\n | \"FILE_TOO_LARGE\";\n\n/**\n * Type-only shape of the `TailorDBFileError` runtime class. The class itself\n * is provided by the platform runtime (and by `injectMocks` in tests); this\n * interface mirrors it so callers can `import type { TailorDBFileError }` from\n * the wrapper module without depending on any ambient declaration.\n */\nexport interface TailorDBFileError extends Error {\n name: \"TailorDBFileError\";\n code?: TailorDBFileErrorCode;\n cause?: unknown;\n}\n\n/**\n * Platform API surface for `tailordb.file`. Describes the shape the platform\n * runtime injects on `globalThis.tailordb.file`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module (e.g. `upload`, `download`, `deleteFile`) so callers can either\n * `import * as file from \"@tailor-platform/sdk/runtime/file\"` or pick\n * individual methods.\n */\nexport interface TailorDBFileAPI {\n /**\n * Upload a file to TailorDB.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @param data - File contents\n * @param options - Upload options (e.g. `contentType`)\n * @returns Upload response containing the file metadata\n */\n upload(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n data: string | ArrayBuffer | Uint8Array | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse>;\n\n /**\n * Download a file from TailorDB.\n *\n * Throws `TailorDBFileError` with code `FILE_TOO_LARGE` when the file\n * exceeds 10MB — use {@link openDownloadStream} for large files.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Bytes and metadata for the file\n */\n download(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileDownloadResponse>;\n\n /**\n * Download a file from TailorDB as a Base64-encoded string.\n *\n * Throws `TailorDBFileError` with code `FILE_TOO_LARGE` when the file\n * exceeds 10MB — use {@link openDownloadStream} for large files.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Base64-encoded contents and metadata for the file\n */\n downloadAsBase64(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileDownloadAsBase64Response>;\n\n /**\n * Delete a file from TailorDB. Exported as `deleteFile` (and aliased as\n * `delete`) so it can be used both with named and namespace imports.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Resolves once the file has been deleted\n */\n delete(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<void>;\n\n /**\n * Get file metadata from TailorDB.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Metadata for the stored file\n */\n getMetadata(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileMetadata>;\n\n /**\n * Open a download stream for large files.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Async iterator yielding file chunks; call `close()` to release resources\n */\n openDownloadStream(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileStreamIterator>;\n}\n\nconst api = (): TailorDBFileAPI =>\n (globalThis as { tailordb: { file: TailorDBFileAPI } }).tailordb.file;\n\n/**\n * See {@link TailorDBFileAPI.upload}.\n * @param args - Forwarded to {@link TailorDBFileAPI.upload}\n * @returns Upload response containing the file metadata\n */\nexport const upload: TailorDBFileAPI[\"upload\"] = (...args) => api().upload(...args);\n\n/**\n * See {@link TailorDBFileAPI.download}.\n * @param args - Forwarded to {@link TailorDBFileAPI.download}\n * @returns Bytes and metadata for the file\n */\nexport const download: TailorDBFileAPI[\"download\"] = (...args) => api().download(...args);\n\n/**\n * See {@link TailorDBFileAPI.downloadAsBase64}.\n * @param args - Forwarded to {@link TailorDBFileAPI.downloadAsBase64}\n * @returns Base64-encoded contents and metadata for the file\n */\nexport const downloadAsBase64: TailorDBFileAPI[\"downloadAsBase64\"] = (...args) =>\n api().downloadAsBase64(...args);\n\n/**\n * See {@link TailorDBFileAPI.delete}.\n * @param args - Forwarded to {@link TailorDBFileAPI.delete}\n * @returns Resolves once the file has been deleted\n */\nexport const deleteFile: TailorDBFileAPI[\"delete\"] = (...args) => api().delete(...args);\n\n/**\n * See {@link TailorDBFileAPI.getMetadata}.\n * @param args - Forwarded to {@link TailorDBFileAPI.getMetadata}\n * @returns Metadata for the stored file\n */\nexport const getMetadata: TailorDBFileAPI[\"getMetadata\"] = (...args) => api().getMetadata(...args);\n\n/**\n * See {@link TailorDBFileAPI.openDownloadStream}.\n * @param args - Forwarded to {@link TailorDBFileAPI.openDownloadStream}\n * @returns Async iterator yielding file chunks; call `close()` to release resources\n */\nexport const openDownloadStream: TailorDBFileAPI[\"openDownloadStream\"] = (...args) =>\n api().openDownloadStream(...args);\n\nexport { deleteFile as delete };\n"],"mappings":";;;;;;;;;;;;;AAoNA,MAAM,YACH,WAAuD,SAAS;;;;;;AAOnE,MAAa,UAAqC,GAAG,SAAS,IAAI,EAAE,OAAO,GAAG,IAAI;;;;;;AAOlF,MAAa,YAAyC,GAAG,SAAS,IAAI,EAAE,SAAS,GAAG,IAAI;;;;;;AAOxF,MAAa,oBAAyD,GAAG,SACvE,IAAI,EAAE,iBAAiB,GAAG,IAAI;;;;;;AAOhC,MAAa,cAAyC,GAAG,SAAS,IAAI,EAAE,OAAO,GAAG,IAAI;;;;;;AAOtF,MAAa,eAA+C,GAAG,SAAS,IAAI,EAAE,YAAY,GAAG,IAAI;;;;;;AAOjG,MAAa,sBAA6D,GAAG,SAC3E,IAAI,EAAE,mBAAmB,GAAG,IAAI"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
declare namespace file_d_exports {
|
|
2
|
+
export { DownloadMetadata, FileDownloadAsBase64Response, FileDownloadResponse, FileMetadata, FileStreamIterator, FileUploadOptions, FileUploadResponse, StreamMetadata, StreamValue, TailorDBFileAPI, TailorDBFileError, TailorDBFileErrorCode, UploadMetadata, deleteFile as delete, deleteFile, download, downloadAsBase64, getMetadata, openDownloadStream, upload };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* TailorDB file (BLOB) utilities.
|
|
6
|
+
*
|
|
7
|
+
* Thin typed wrapper around the platform-provided `tailordb.file` runtime API.
|
|
8
|
+
* At runtime this delegates to `globalThis.tailordb.file`. Use `fileMock` from
|
|
9
|
+
* `@tailor-platform/sdk/vitest` to mock these calls in unit tests.
|
|
10
|
+
* @example
|
|
11
|
+
* import { file } from "@tailor-platform/sdk/runtime";
|
|
12
|
+
*
|
|
13
|
+
* const { metadata } = await file.upload(
|
|
14
|
+
* "my-namespace",
|
|
15
|
+
* "Document",
|
|
16
|
+
* "attachment",
|
|
17
|
+
* recordId,
|
|
18
|
+
* bytes,
|
|
19
|
+
* );
|
|
20
|
+
*/
|
|
21
|
+
/** Upload response metadata. */
|
|
22
|
+
interface UploadMetadata {
|
|
23
|
+
fileSize: number;
|
|
24
|
+
sha256sum: string;
|
|
25
|
+
}
|
|
26
|
+
/** Download response metadata. */
|
|
27
|
+
interface DownloadMetadata {
|
|
28
|
+
contentType: string;
|
|
29
|
+
fileSize: number;
|
|
30
|
+
sha256sum: string;
|
|
31
|
+
lastUploadedAt: string;
|
|
32
|
+
}
|
|
33
|
+
/** File metadata (for {@link getMetadata}). */
|
|
34
|
+
interface FileMetadata {
|
|
35
|
+
contentType: string;
|
|
36
|
+
fileSize: number;
|
|
37
|
+
sha256sum: string;
|
|
38
|
+
urlPath: string;
|
|
39
|
+
lastUploadedAt?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Stream metadata (first chunk emitted by {@link openDownloadStream}). */
|
|
42
|
+
interface StreamMetadata {
|
|
43
|
+
contentType: string;
|
|
44
|
+
fileSize: number;
|
|
45
|
+
sha256sum: string;
|
|
46
|
+
}
|
|
47
|
+
/** Upload options. */
|
|
48
|
+
interface FileUploadOptions {
|
|
49
|
+
contentType?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Upload response. */
|
|
52
|
+
interface FileUploadResponse {
|
|
53
|
+
metadata: UploadMetadata;
|
|
54
|
+
}
|
|
55
|
+
/** Download response. */
|
|
56
|
+
interface FileDownloadResponse {
|
|
57
|
+
data: Uint8Array;
|
|
58
|
+
metadata: DownloadMetadata;
|
|
59
|
+
}
|
|
60
|
+
/** Download-as-Base64 response. */
|
|
61
|
+
interface FileDownloadAsBase64Response {
|
|
62
|
+
data: string;
|
|
63
|
+
metadata: DownloadMetadata;
|
|
64
|
+
}
|
|
65
|
+
/** Stream chunk types emitted by {@link FileStreamIterator}. */
|
|
66
|
+
type StreamValue = {
|
|
67
|
+
type: "metadata";
|
|
68
|
+
metadata: StreamMetadata;
|
|
69
|
+
} | {
|
|
70
|
+
type: "chunk";
|
|
71
|
+
data: Uint8Array;
|
|
72
|
+
position: number;
|
|
73
|
+
} | {
|
|
74
|
+
type: "complete";
|
|
75
|
+
};
|
|
76
|
+
/** Stream iterator returned by {@link openDownloadStream}. */
|
|
77
|
+
interface FileStreamIterator extends AsyncIterableIterator<StreamValue> {
|
|
78
|
+
next(): Promise<IteratorResult<StreamValue>>;
|
|
79
|
+
close(): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/** Error code emitted by {@link TailorDBFileError}. */
|
|
82
|
+
type TailorDBFileErrorCode = "INVALID_PARAMS" | "INVALID_DATA_TYPE" | "OPERATION_FAILED" | "DELETE_FAILED" | "STREAM_OPEN_FAILED" | "STREAM_READ_ERROR" | "STREAM_ERROR" | "FILE_TOO_LARGE";
|
|
83
|
+
/**
|
|
84
|
+
* Type-only shape of the `TailorDBFileError` runtime class. The class itself
|
|
85
|
+
* is provided by the platform runtime (and by `injectMocks` in tests); this
|
|
86
|
+
* interface mirrors it so callers can `import type { TailorDBFileError }` from
|
|
87
|
+
* the wrapper module without depending on any ambient declaration.
|
|
88
|
+
*/
|
|
89
|
+
interface TailorDBFileError extends Error {
|
|
90
|
+
name: "TailorDBFileError";
|
|
91
|
+
code?: TailorDBFileErrorCode;
|
|
92
|
+
cause?: unknown;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Platform API surface for `tailordb.file`. Describes the shape the platform
|
|
96
|
+
* runtime injects on `globalThis.tailordb.file`.
|
|
97
|
+
*
|
|
98
|
+
* Each method below is also re-exported as a top-level named export from this
|
|
99
|
+
* module (e.g. `upload`, `download`, `deleteFile`) so callers can either
|
|
100
|
+
* `import * as file from "@tailor-platform/sdk/runtime/file"` or pick
|
|
101
|
+
* individual methods.
|
|
102
|
+
*/
|
|
103
|
+
interface TailorDBFileAPI {
|
|
104
|
+
/**
|
|
105
|
+
* Upload a file to TailorDB.
|
|
106
|
+
* @param namespace - TailorDB namespace
|
|
107
|
+
* @param typeName - TailorDB type name
|
|
108
|
+
* @param fieldName - File field name on the type
|
|
109
|
+
* @param recordId - Record ID owning the field
|
|
110
|
+
* @param data - File contents
|
|
111
|
+
* @param options - Upload options (e.g. `contentType`)
|
|
112
|
+
* @returns Upload response containing the file metadata
|
|
113
|
+
*/
|
|
114
|
+
upload(namespace: string, typeName: string, fieldName: string, recordId: string, data: string | ArrayBuffer | Uint8Array | number[], options?: FileUploadOptions): Promise<FileUploadResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Download a file from TailorDB.
|
|
117
|
+
*
|
|
118
|
+
* Throws `TailorDBFileError` with code `FILE_TOO_LARGE` when the file
|
|
119
|
+
* exceeds 10MB — use {@link openDownloadStream} for large files.
|
|
120
|
+
* @param namespace - TailorDB namespace
|
|
121
|
+
* @param typeName - TailorDB type name
|
|
122
|
+
* @param fieldName - File field name on the type
|
|
123
|
+
* @param recordId - Record ID owning the field
|
|
124
|
+
* @returns Bytes and metadata for the file
|
|
125
|
+
*/
|
|
126
|
+
download(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<FileDownloadResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Download a file from TailorDB as a Base64-encoded string.
|
|
129
|
+
*
|
|
130
|
+
* Throws `TailorDBFileError` with code `FILE_TOO_LARGE` when the file
|
|
131
|
+
* exceeds 10MB — use {@link openDownloadStream} for large files.
|
|
132
|
+
* @param namespace - TailorDB namespace
|
|
133
|
+
* @param typeName - TailorDB type name
|
|
134
|
+
* @param fieldName - File field name on the type
|
|
135
|
+
* @param recordId - Record ID owning the field
|
|
136
|
+
* @returns Base64-encoded contents and metadata for the file
|
|
137
|
+
*/
|
|
138
|
+
downloadAsBase64(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<FileDownloadAsBase64Response>;
|
|
139
|
+
/**
|
|
140
|
+
* Delete a file from TailorDB. Exported as `deleteFile` (and aliased as
|
|
141
|
+
* `delete`) so it can be used both with named and namespace imports.
|
|
142
|
+
* @param namespace - TailorDB namespace
|
|
143
|
+
* @param typeName - TailorDB type name
|
|
144
|
+
* @param fieldName - File field name on the type
|
|
145
|
+
* @param recordId - Record ID owning the field
|
|
146
|
+
* @returns Resolves once the file has been deleted
|
|
147
|
+
*/
|
|
148
|
+
delete(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Get file metadata from TailorDB.
|
|
151
|
+
* @param namespace - TailorDB namespace
|
|
152
|
+
* @param typeName - TailorDB type name
|
|
153
|
+
* @param fieldName - File field name on the type
|
|
154
|
+
* @param recordId - Record ID owning the field
|
|
155
|
+
* @returns Metadata for the stored file
|
|
156
|
+
*/
|
|
157
|
+
getMetadata(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<FileMetadata>;
|
|
158
|
+
/**
|
|
159
|
+
* Open a download stream for large files.
|
|
160
|
+
* @param namespace - TailorDB namespace
|
|
161
|
+
* @param typeName - TailorDB type name
|
|
162
|
+
* @param fieldName - File field name on the type
|
|
163
|
+
* @param recordId - Record ID owning the field
|
|
164
|
+
* @returns Async iterator yielding file chunks; call `close()` to release resources
|
|
165
|
+
*/
|
|
166
|
+
openDownloadStream(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<FileStreamIterator>;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* See {@link TailorDBFileAPI.upload}.
|
|
170
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.upload}
|
|
171
|
+
* @returns Upload response containing the file metadata
|
|
172
|
+
*/
|
|
173
|
+
declare const upload: TailorDBFileAPI["upload"];
|
|
174
|
+
/**
|
|
175
|
+
* See {@link TailorDBFileAPI.download}.
|
|
176
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.download}
|
|
177
|
+
* @returns Bytes and metadata for the file
|
|
178
|
+
*/
|
|
179
|
+
declare const download: TailorDBFileAPI["download"];
|
|
180
|
+
/**
|
|
181
|
+
* See {@link TailorDBFileAPI.downloadAsBase64}.
|
|
182
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.downloadAsBase64}
|
|
183
|
+
* @returns Base64-encoded contents and metadata for the file
|
|
184
|
+
*/
|
|
185
|
+
declare const downloadAsBase64: TailorDBFileAPI["downloadAsBase64"];
|
|
186
|
+
/**
|
|
187
|
+
* See {@link TailorDBFileAPI.delete}.
|
|
188
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.delete}
|
|
189
|
+
* @returns Resolves once the file has been deleted
|
|
190
|
+
*/
|
|
191
|
+
declare const deleteFile: TailorDBFileAPI["delete"];
|
|
192
|
+
/**
|
|
193
|
+
* See {@link TailorDBFileAPI.getMetadata}.
|
|
194
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.getMetadata}
|
|
195
|
+
* @returns Metadata for the stored file
|
|
196
|
+
*/
|
|
197
|
+
declare const getMetadata: TailorDBFileAPI["getMetadata"];
|
|
198
|
+
/**
|
|
199
|
+
* See {@link TailorDBFileAPI.openDownloadStream}.
|
|
200
|
+
* @param args - Forwarded to {@link TailorDBFileAPI.openDownloadStream}
|
|
201
|
+
* @returns Async iterator yielding file chunks; call `close()` to release resources
|
|
202
|
+
*/
|
|
203
|
+
declare const openDownloadStream: TailorDBFileAPI["openDownloadStream"];
|
|
204
|
+
//#endregion
|
|
205
|
+
export { file_d_exports as _, FileStreamIterator as a, upload as b, StreamMetadata as c, TailorDBFileError as d, TailorDBFileErrorCode as f, downloadAsBase64 as g, download as h, FileMetadata as i, StreamValue as l, deleteFile as m, FileDownloadAsBase64Response as n, FileUploadOptions as o, UploadMetadata as p, FileDownloadResponse as r, FileUploadResponse as s, DownloadMetadata as t, TailorDBFileAPI as u, getMetadata as v, openDownloadStream as y };
|
|
206
|
+
//# sourceMappingURL=file-Dc4_QrlQ.d.mts.map
|