@tailor-platform/sdk 1.45.0 → 1.45.2
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 +24 -0
- package/dist/{actor-CzX_hVOP.d.mts → actor-BmxQeMFP.d.mts} +2 -2
- package/dist/{application-BsSJZRCq.mjs → application-B4zVVNRS.mjs} +26 -26
- package/dist/application-B4zVVNRS.mjs.map +1 -0
- package/dist/application-BIzicxMA.mjs +4 -0
- package/dist/cli/index.mjs +29 -29
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +6 -6
- package/dist/cli/lib.mjs +8 -8
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/{client-DcuQRqSd.mjs → client-BwXkoiMq.mjs} +3 -3
- package/dist/{client-DcuQRqSd.mjs.map → client-BwXkoiMq.mjs.map} +1 -1
- package/dist/{client-IsYnTV5A.mjs → client-DTaArWQr.mjs} +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/{crash-report-DQen2i_W.mjs → crash-report-BUHzuzDn.mjs} +1 -1
- package/dist/{crash-report-DVZsX1bs.mjs → crash-report-CtYCva4d.mjs} +3 -3
- package/dist/{crash-report-DVZsX1bs.mjs.map → crash-report-CtYCva4d.mjs.map} +1 -1
- package/dist/{errors-_M2TVoWh.mjs → errors-wNQxQQBH.mjs} +1 -1
- package/dist/{errors-_M2TVoWh.mjs.map → errors-wNQxQQBH.mjs.map} +1 -1
- package/dist/{file-utils-775qWKoo.mjs → file-utils-DjNi_3U_.mjs} +9 -9
- package/dist/file-utils-DjNi_3U_.mjs.map +1 -0
- package/dist/{index-Bd-0JRjy.d.mts → index-B5_4Tzm2.d.mts} +2 -2
- package/dist/{index-DIz-15Cx.d.mts → index-BBvPd9Uv.d.mts} +2 -2
- package/dist/{index-CemBzf4z.d.mts → index-DUKJPEwq.d.mts} +4 -4
- package/dist/{index-SnYVi8ww.d.mts → index-DV-5OIEv.d.mts} +2 -2
- package/dist/{index-C_f357K2.d.mts → index-Dxe6alSZ.d.mts} +2 -2
- package/dist/{interceptor-4UC-KTno.mjs → interceptor-CrcDfLPq.mjs} +1 -1
- package/dist/{interceptor-4UC-KTno.mjs.map → interceptor-CrcDfLPq.mjs.map} +1 -1
- package/dist/{kysely-type-BQsYEZoY.mjs → kysely-type-B8aRz_oC.mjs} +6 -6
- package/dist/kysely-type-B8aRz_oC.mjs.map +1 -0
- package/dist/multiline-e3IpANmS.mjs +39 -0
- package/dist/multiline-e3IpANmS.mjs.map +1 -0
- package/dist/{package-json-CRzw5eUf.mjs → package-json-6Px8bDpG.mjs} +1 -1
- package/dist/{package-json-CRzw5eUf.mjs.map → package-json-6Px8bDpG.mjs.map} +1 -1
- package/dist/package-json-7sRXVndJ.mjs +4 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -2
- package/dist/{repl-editor-DjycioU-.mjs → repl-editor-BlT2dFtm.mjs} +1 -1
- package/dist/{repl-editor-DjycioU-.mjs.map → repl-editor-BlT2dFtm.mjs.map} +1 -1
- package/dist/{runtime-Bmq4L9pj.mjs → runtime-D97Ydu2S.mjs} +211 -51
- package/dist/runtime-D97Ydu2S.mjs.map +1 -0
- package/dist/{seed-BkVKgsxf.mjs → seed-DrKY5yIF.mjs} +15 -15
- package/dist/seed-DrKY5yIF.mjs.map +1 -0
- package/dist/{service-CCnx_IFw.mjs → service-CCgw66c6.mjs} +2 -2
- package/dist/{service-CCnx_IFw.mjs.map → service-CCgw66c6.mjs.map} +1 -1
- package/dist/{tailor-db-field-CY1D1PtT.d.mts → tailor-db-field-Hx9OqPWY.d.mts} +1 -1
- package/dist/telemetry-BvI1EgMG.mjs +4 -0
- package/dist/{telemetry-B6Le9XT-.mjs → telemetry-DXitz4RH.mjs} +2 -2
- package/dist/{telemetry-B6Le9XT-.mjs.map → telemetry-DXitz4RH.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +3 -3
- package/dist/{workflow.generated--YammZcl.d.mts → workflow.generated-DFljpJh7.d.mts} +2 -2
- package/docs/generator/builtin.md +36 -0
- package/package.json +9 -11
- package/dist/application-BsSJZRCq.mjs.map +0 -1
- package/dist/application-C0O80PUX.mjs +0 -4
- package/dist/file-utils-775qWKoo.mjs.map +0 -1
- package/dist/kysely-type-BQsYEZoY.mjs.map +0 -1
- package/dist/package-json-DR_mqrCW.mjs +0 -4
- package/dist/runtime-Bmq4L9pj.mjs.map +0 -1
- package/dist/seed-BkVKgsxf.mjs.map +0 -1
- package/dist/telemetry-C_WXxIo0.mjs +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as fetchMachineUserToken, c as fetchUserInfo, d as initOperatorClient, f as parseMethodName, h as userAgent, i as fetchAll, l as formatRequestParams, m as resolveStaticWebsiteUrls, n as closeConnectionPool, o as fetchPaged, p as platformBaseUrl, r as createTransport, s as fetchPlatformMachineUserToken, t as MAX_PAGE_SIZE, u as initOAuth2Client } from "./client-
|
|
2
|
+
import { a as fetchMachineUserToken, c as fetchUserInfo, d as initOperatorClient, f as parseMethodName, h as userAgent, i as fetchAll, l as formatRequestParams, m as resolveStaticWebsiteUrls, n as closeConnectionPool, o as fetchPaged, p as platformBaseUrl, r as createTransport, s as fetchPlatformMachineUserToken, t as MAX_PAGE_SIZE, u as initOAuth2Client } from "./client-BwXkoiMq.mjs";
|
|
3
3
|
|
|
4
4
|
export { userAgent };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { B as BeforeLoginHookArgs, C as ResolverReadyContext, Ct as SCIMAuthorization, Et as TenantProvider, F as AuthConfig, G as UserAttributeListKey, H as OAuth2ClientGrantType, Ht as TailorUser, I as AuthConnectionTokenResult, J as ValueOperand, K as UserAttributeMap, L as AuthExternalConfig, Lt as AttributeList, Q as Resolver, R as AuthOwnConfig, Rt as AttributeMap, S as ResolverNamespaceData, St as SCIMAttributeMapping, T as TailorDBReadyContext, Tt as SCIMResource, U as SCIMAttributeType, Ut as unauthenticatedTailorUser, V as DefinedAuth, Vt as TailorInvoker, W as UserAttributeKey, X as AuthConnectionConfig, Z as AuthConnectionOAuth2Config, _ as PluginProcessContext, _t as IdProvider, a as NamespacePluginOutput, b as ExecutorReadyContext, bt as SAML, c as PluginConfigs, d as PluginGeneratedExecutor, f as PluginGeneratedExecutorWithFile, g as PluginOutput, gt as IDToken, h as PluginNamespaceProcessContext, ht as BuiltinIdP, l as PluginExecutorContext, m as PluginGeneratedType, o as Plugin, p as PluginGeneratedResolver, q as UsernameFieldKey, s as PluginAttachment, u as PluginExecutorContextBase, v as TailorDBTypeForPlugin, vt as OAuth2ClientInput, w as TailorDBNamespaceData, wt as SCIMConfig, x as GeneratorResult, xt as SCIMAttribute, y as TypePluginOutput, yt as OIDC, z as AuthServiceInput } from "../tailor-db-field-
|
|
3
|
-
import { A as PermissionCondition, D as TailorDBInstance, E as TailorDBField, M as TailorTypePermission, N as unsafeAllowAllGqlPermission, O as TailorDBType, P as unsafeAllowAllTypePermission, S as IdPGqlOperationsInput, T as TailorAnyDBType, _ as IdPExternalConfig, a as ExecutorServiceInput, b as IdPEmailConfig, c as ResolverServiceInput, d as StaticWebsiteConfig, g as IdPConfig, i as ExecutorServiceConfig, j as TailorTypeGqlPermission, k as db, l as WorkflowServiceConfig, m as SecretsConfig, n as RetryPolicy, o as ResolverExternalConfig, s as ResolverServiceConfig, t as ConcurrencyPolicy, u as WorkflowServiceInput, w as TailorAnyDBField, x as IdPGqlOperations } from "../workflow.generated
|
|
4
|
-
import { $ as recordDeletedTrigger, A as AuthAccessTokenRefreshedArgs, B as RecordUpdatedArgs, C as IncomingWebhookTriggerOptions, Ct as MachineUserNameRegistry, D as scheduleTrigger, E as ScheduleTrigger, F as IdpUserDeletedArgs, G as authAccessTokenRefreshedTrigger, H as ResolverExecutedTrigger, I as IdpUserTrigger, J as idpUserCreatedTrigger, K as authAccessTokenRevokedTrigger, L as IdpUserUpdatedArgs, M as AuthAccessTokenTrigger, N as IdpUserArgs, O as AuthAccessTokenArgs, P as IdpUserCreatedArgs, Q as recordCreatedTrigger, R as RecordCreatedArgs, S as IncomingWebhookTrigger, St as MachineUserName, T as ScheduleArgs, U as TailorDBTrigger, V as ResolverExecutedArgs, W as authAccessTokenIssuedTrigger, X as idpUserTrigger, Y as idpUserDeletedTrigger, Z as idpUserUpdatedTrigger, _ as Trigger, _t as AuthInvoker, a as defineGenerators, at as Operation, b as IncomingWebhookResponse, bt as IdpNameRegistry, c as defineIdp, ct as Workflow, d as unsafeAllowAllIdPPermission, dt as WORKFLOW_TEST_ENV_KEY, et as recordTrigger, f as defineStaticWebSite, ft as WorkflowJob, g as createExecutor, gt as createResolver, h as defineWaitPoints, ht as QueryType, i as defineConfig, it as GqlOperation, j as AuthAccessTokenRevokedArgs, k as AuthAccessTokenIssuedArgs, l as IdPPermission, lt as WorkflowConfig, m as defineWaitPoint, mt as createWorkflowJob, n as output, nt as resolverExecutedTrigger, o as definePlugins, ot as WebhookOperation, p as WaitPointInstance, pt as WorkflowJobContext, q as authAccessTokenTrigger, r as t, rt as FunctionOperation, s as defineSecretManager, st as WorkflowOperation, t as __Infer, tt as recordUpdatedTrigger, u as IdPPermissionCondition, ut as createWorkflow, v as IncomingWebhookArgs, vt as defineAuth, w as incomingWebhookTrigger, x as IncomingWebhookResponseConfig, xt as TailorField, y as IncomingWebhookRequest, yt as IdpName, z as RecordDeletedArgs } from "../index-
|
|
5
|
-
import { n as Env } from "../actor-
|
|
2
|
+
import { B as BeforeLoginHookArgs, C as ResolverReadyContext, Ct as SCIMAuthorization, Et as TenantProvider, F as AuthConfig, G as UserAttributeListKey, H as OAuth2ClientGrantType, Ht as TailorUser, I as AuthConnectionTokenResult, J as ValueOperand, K as UserAttributeMap, L as AuthExternalConfig, Lt as AttributeList, Q as Resolver, R as AuthOwnConfig, Rt as AttributeMap, S as ResolverNamespaceData, St as SCIMAttributeMapping, T as TailorDBReadyContext, Tt as SCIMResource, U as SCIMAttributeType, Ut as unauthenticatedTailorUser, V as DefinedAuth, Vt as TailorInvoker, W as UserAttributeKey, X as AuthConnectionConfig, Z as AuthConnectionOAuth2Config, _ as PluginProcessContext, _t as IdProvider, a as NamespacePluginOutput, b as ExecutorReadyContext, bt as SAML, c as PluginConfigs, d as PluginGeneratedExecutor, f as PluginGeneratedExecutorWithFile, g as PluginOutput, gt as IDToken, h as PluginNamespaceProcessContext, ht as BuiltinIdP, l as PluginExecutorContext, m as PluginGeneratedType, o as Plugin, p as PluginGeneratedResolver, q as UsernameFieldKey, s as PluginAttachment, u as PluginExecutorContextBase, v as TailorDBTypeForPlugin, vt as OAuth2ClientInput, w as TailorDBNamespaceData, wt as SCIMConfig, x as GeneratorResult, xt as SCIMAttribute, y as TypePluginOutput, yt as OIDC, z as AuthServiceInput } from "../tailor-db-field-Hx9OqPWY.mjs";
|
|
3
|
+
import { A as PermissionCondition, D as TailorDBInstance, E as TailorDBField, M as TailorTypePermission, N as unsafeAllowAllGqlPermission, O as TailorDBType, P as unsafeAllowAllTypePermission, S as IdPGqlOperationsInput, T as TailorAnyDBType, _ as IdPExternalConfig, a as ExecutorServiceInput, b as IdPEmailConfig, c as ResolverServiceInput, d as StaticWebsiteConfig, g as IdPConfig, i as ExecutorServiceConfig, j as TailorTypeGqlPermission, k as db, l as WorkflowServiceConfig, m as SecretsConfig, n as RetryPolicy, o as ResolverExternalConfig, s as ResolverServiceConfig, t as ConcurrencyPolicy, u as WorkflowServiceInput, w as TailorAnyDBField, x as IdPGqlOperations } from "../workflow.generated-DFljpJh7.mjs";
|
|
4
|
+
import { $ as recordDeletedTrigger, A as AuthAccessTokenRefreshedArgs, B as RecordUpdatedArgs, C as IncomingWebhookTriggerOptions, Ct as MachineUserNameRegistry, D as scheduleTrigger, E as ScheduleTrigger, F as IdpUserDeletedArgs, G as authAccessTokenRefreshedTrigger, H as ResolverExecutedTrigger, I as IdpUserTrigger, J as idpUserCreatedTrigger, K as authAccessTokenRevokedTrigger, L as IdpUserUpdatedArgs, M as AuthAccessTokenTrigger, N as IdpUserArgs, O as AuthAccessTokenArgs, P as IdpUserCreatedArgs, Q as recordCreatedTrigger, R as RecordCreatedArgs, S as IncomingWebhookTrigger, St as MachineUserName, T as ScheduleArgs, U as TailorDBTrigger, V as ResolverExecutedArgs, W as authAccessTokenIssuedTrigger, X as idpUserTrigger, Y as idpUserDeletedTrigger, Z as idpUserUpdatedTrigger, _ as Trigger, _t as AuthInvoker, a as defineGenerators, at as Operation, b as IncomingWebhookResponse, bt as IdpNameRegistry, c as defineIdp, ct as Workflow, d as unsafeAllowAllIdPPermission, dt as WORKFLOW_TEST_ENV_KEY, et as recordTrigger, f as defineStaticWebSite, ft as WorkflowJob, g as createExecutor, gt as createResolver, h as defineWaitPoints, ht as QueryType, i as defineConfig, it as GqlOperation, j as AuthAccessTokenRevokedArgs, k as AuthAccessTokenIssuedArgs, l as IdPPermission, lt as WorkflowConfig, m as defineWaitPoint, mt as createWorkflowJob, n as output, nt as resolverExecutedTrigger, o as definePlugins, ot as WebhookOperation, p as WaitPointInstance, pt as WorkflowJobContext, q as authAccessTokenTrigger, r as t, rt as FunctionOperation, s as defineSecretManager, st as WorkflowOperation, t as __Infer, tt as recordUpdatedTrigger, u as IdPPermissionCondition, ut as createWorkflow, v as IncomingWebhookArgs, vt as defineAuth, w as incomingWebhookTrigger, x as IncomingWebhookResponseConfig, xt as TailorField, y as IncomingWebhookRequest, yt as IdpName, z as RecordDeletedArgs } from "../index-DUKJPEwq.mjs";
|
|
5
|
+
import { n as Env } from "../actor-BmxQeMFP.mjs";
|
|
6
6
|
export { AttributeList, AttributeMap, AuthAccessTokenArgs, AuthAccessTokenIssuedArgs, AuthAccessTokenRefreshedArgs, AuthAccessTokenRevokedArgs, AuthAccessTokenTrigger, AuthConfig, AuthConnectionConfig, AuthConnectionOAuth2Config, AuthConnectionTokenResult, AuthExternalConfig, AuthInvoker, AuthOwnConfig, AuthServiceInput, BeforeLoginHookArgs, BuiltinIdP, ConcurrencyPolicy, DefinedAuth, Env, ExecutorReadyContext, ExecutorServiceConfig, ExecutorServiceInput, FunctionOperation, GeneratorResult, GqlOperation, IDToken, IdPConfig, IdPEmailConfig, IdPExternalConfig, IdPGqlOperations, IdPGqlOperationsInput as IdPGqlOperationsConfig, IdPPermission, IdPPermissionCondition, IdProvider as IdProviderConfig, IdpName, IdpNameRegistry, IdpUserArgs, IdpUserCreatedArgs, IdpUserDeletedArgs, IdpUserTrigger, IdpUserUpdatedArgs, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, IncomingWebhookResponseConfig, IncomingWebhookTrigger, IncomingWebhookTriggerOptions, MachineUserName, MachineUserNameRegistry, NamespacePluginOutput, OAuth2ClientInput as OAuth2Client, OAuth2ClientGrantType, OIDC, Operation, PermissionCondition, Plugin, PluginAttachment, PluginConfigs, PluginExecutorContext, PluginExecutorContextBase, PluginGeneratedExecutor, PluginGeneratedExecutorWithFile, PluginGeneratedResolver, PluginGeneratedType, PluginNamespaceProcessContext, PluginOutput, PluginProcessContext, QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordUpdatedArgs, Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, ResolverExternalConfig, ResolverNamespaceData, ResolverReadyContext, ResolverServiceConfig, ResolverServiceInput, RetryPolicy, SAML, SCIMAttribute, SCIMAttributeMapping, SCIMAttributeType, SCIMAuthorization, SCIMConfig, SCIMResource, ScheduleArgs, ScheduleTrigger, SecretsConfig, StaticWebsiteConfig, TailorAnyDBField, TailorAnyDBType, TailorDBField, TailorDBInstance, TailorDBNamespaceData, TailorDBReadyContext, TailorDBTrigger, TailorDBType, TailorDBTypeForPlugin, TailorField, TailorInvoker, TailorTypeGqlPermission, TailorTypePermission, TailorUser, TenantProvider as TenantProviderConfig, Trigger, TypePluginOutput, UserAttributeKey, UserAttributeListKey, UserAttributeMap, UsernameFieldKey, ValueOperand, WORKFLOW_TEST_ENV_KEY, WaitPointInstance, WebhookOperation, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, WorkflowOperation, WorkflowServiceConfig, WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createResolver, createWorkflow, createWorkflowJob, db, defineAuth, defineConfig, defineGenerators, defineIdp, definePlugins, defineSecretManager, defineStaticWebSite, defineWaitPoint, defineWaitPoints, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { n as logger } from "./logger-DTNAMYGy.mjs";
|
|
3
|
-
import { t as readPackageJson } from "./package-json-
|
|
3
|
+
import { t as readPackageJson } from "./package-json-6Px8bDpG.mjs";
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import * as path from "pathe";
|
|
6
6
|
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-DTaArWQr.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=crash-report-
|
|
415
|
+
//# sourceMappingURL=crash-report-CtYCva4d.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crash-report-DVZsX1bs.mjs","names":[],"sources":["../src/cli/crash-report/config.ts","../src/cli/crash-report/writer.ts","../src/cli/crash-report/sender.ts","../src/cli/crash-report/sanitize.ts","../src/cli/crash-report/report.ts","../src/cli/crash-report/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 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 fs.mkdirSync(dir, { recursive: true });\n\n const filename = generateFilename(report);\n const filePath = path.join(dir, filename);\n const content = formatCrashReport(report);\n\n fs.writeFileSync(filePath, content, \"utf-8\");\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 crash-report 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;AAC1D,KAAI,KACF,QAAO;EACL,cAAc;EACd,eAAe;EACf,UAAU;EACX;CAGH,MAAM,gBAAgB,QAAQ,IAAI,8BAA8B,MAAM,aAAa,KAAK;CACxF,MAAM,iBAAiB,QAAQ,IAAI,+BAA+B,OAAO,aAAa,KAAK;CAC3F,MAAM,WAAW,YAAY,KAAK,KAAK,WAAW,mBAAmB,gBAAgB,GAAG;AAExF,QAAO;EACL,cAAc,gBAAgB,aAAa;EAC3C;EACA;EACD;;;;;AC9BH,MAAM,kBAAkB;;AAGxB,MAAa,qBAAqB;;AAGlC,MAAa,sBAAsB;;;;;;AAOnC,SAAgB,kBAAkB,QAA6B;AA2B7D,QAAO;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,KAAK;EACzC;EACA;EACA,SAAS,OAAO;EAChB,YAAY,OAAO;EACnB;EACA;EACA,OAAO,cAAc;EACrB;EACA;EACA,KAAK,UAAU,OAAO;EACtB;EAEU,CAAC,KAAK,KAAK;;;;;;;;AASzB,SAAS,iBAAiB,QAA6B;AAGrD,QAAO,GAFe,OAAO,UAAU,QAAQ,SAAS,IAEjC,CAAC,GADR,OAAO,GAAG,MAAM,GAAG,EACD,GAAG;;;;;;AAOvC,SAAS,gBAAgB,KAAmB;AAC1C,KAAI;EACF,MAAM,QAAQ,GAC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B,cAAyB;EAC5D,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,MAAM,QAAQ;AACrB,EAAK,YAAY,OAAO,UAAU,CAAC,cAAc;AAC/C,WAAQ,KAAK,EAAE;IACf;;AAGJ,SAAQ,GAAG,sBAAsB,UAAU,YAAY,OAAO,oBAAoB,CAAC;AACnF,SAAQ,GAAG,uBAAuB,WAAW,YAAY,QAAQ,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"crash-report-CtYCva4d.mjs","names":[],"sources":["../src/cli/crash-report/config.ts","../src/cli/crash-report/writer.ts","../src/cli/crash-report/sender.ts","../src/cli/crash-report/sanitize.ts","../src/cli/crash-report/report.ts","../src/cli/crash-report/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 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 fs.mkdirSync(dir, { recursive: true });\n\n const filename = generateFilename(report);\n const filePath = path.join(dir, filename);\n const content = formatCrashReport(report);\n\n fs.writeFileSync(filePath, content, \"utf-8\");\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 crash-report 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;AAC1D,KAAI,KACF,QAAO;EACL,cAAc;EACd,eAAe;EACf,UAAU;EACX;CAGH,MAAM,gBAAgB,QAAQ,IAAI,8BAA8B,MAAM,aAAa,KAAK;CACxF,MAAM,iBAAiB,QAAQ,IAAI,+BAA+B,OAAO,aAAa,KAAK;CAC3F,MAAM,WAAW,YAAY,KAAK,KAAK,WAAW,mBAAmB,gBAAgB,GAAG;AAExF,QAAO;EACL,cAAc,gBAAgB,aAAa;EAC3C;EACA;EACD;;;;;AC9BH,MAAM,kBAAkB;;AAGxB,MAAa,qBAAqB;;AAGlC,MAAa,sBAAsB;;;;;;AAOnC,SAAgB,kBAAkB,QAA6B;AA2B7D,QAAO;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,KAAK;EACzC;EACA;EACA,SAAS,OAAO;EAChB,YAAY,OAAO;EACnB;EACA;EACA,OAAO,cAAc;EACrB;EACA;EACA,KAAK,UAAU,OAAO;EACtB;EAEU,CAAC,KAAK,KAAK;;;;;;;;AASzB,SAAS,iBAAiB,QAA6B;AAGrD,QAAO,GAFe,OAAO,UAAU,QAAQ,SAAS,IAEjC,CAAC,GADR,OAAO,GAAG,MAAM,GAAG,EACD,GAAG;;;;;;AAOvC,SAAS,gBAAgB,KAAmB;A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O,cAAe;CAEnD,MAAM,eAAe,OAAgB,cAAyB;EAC5D,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,MAAM,QAAQ;AACrB,EAAK,YAAY,OAAO,UAAU,CAAC,cAAc;AAC/C,WAAQ,KAAK,EAAE;IACf;;AAGJ,SAAQ,GAAG,sBAAsB,UAAU,YAAY,OAAO,oBAAoB,CAAC;AACnF,SAAQ,GAAG,uBAAuB,WAAW,YAAY,QAAQ,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-wNQxQQBH.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,UAAU,CAC5E;AAED,KAAI,MAAM,QACR,OAAM,KAAK,OAAO,MAAM,KAAK,WAAW,CAAC,GAAG,MAAM,UAAU;AAG9D,KAAI,MAAM,WACR,OAAM,KAAK,OAAO,MAAM,KAAK,cAAc,CAAC,GAAG,MAAM,aAAa;AAGpE,KAAI,MAAM,QACR,OAAM,KACJ,OAAO,MAAM,KAAK,QAAQ,CAAC,oBAAoB,MAAM,QAAQ,kCAC9D;AAGH,QAAO,MAAM,KAAK,GAAG;;;;;;;AAQvB,SAAS,eAAe,SAAoC;CAC1D,MAAM,QAAQ,IAAI,MAAM,QAAQ,QAAQ;AACxC,OAAM,OAAO;AACb,OAAM,OAAO,QAAQ;AACrB,OAAM,UAAU,QAAQ;AACxB,OAAM,aAAa,QAAQ;AAC3B,OAAM,UAAU,QAAQ;AACxB,OAAM,eAAe,YAAY,MAAM;AACvC,QAAO;;;;;;;AAQT,SAAgB,WAAW,OAAmC;AAC5D,QAAO,iBAAiB,SAAS,MAAM,SAAS"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
2
|
+
import { t as multiline } from "./multiline-e3IpANmS.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/file-utils/generate-file-utils.ts
|
|
5
5
|
/**
|
|
@@ -17,19 +17,19 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
17
17
|
}
|
|
18
18
|
if (typeNamespaceMap.size === 0) return "";
|
|
19
19
|
return [
|
|
20
|
-
|
|
20
|
+
multiline`
|
|
21
21
|
export interface TypeWithFiles {
|
|
22
22
|
${Array.from(typeFieldsMap.entries()).map(([typeName, fields]) => {
|
|
23
23
|
return ` ${typeName}: {\n fields: ${fields.map((field) => `"${field}"`).join(" | ")};\n };`;
|
|
24
24
|
}).join("\n")}
|
|
25
25
|
}
|
|
26
26
|
` + "\n",
|
|
27
|
-
|
|
27
|
+
multiline`
|
|
28
28
|
const namespaces: Record<keyof TypeWithFiles, string> = {
|
|
29
29
|
${Array.from(typeNamespaceMap.entries()).map(([typeName, namespace]) => ` ${typeName}: "${namespace}"`).join(",\n")},
|
|
30
30
|
};
|
|
31
31
|
` + "\n",
|
|
32
|
-
|
|
32
|
+
multiline`
|
|
33
33
|
export async function downloadFile<T extends keyof TypeWithFiles>(
|
|
34
34
|
type: T,
|
|
35
35
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -38,7 +38,7 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
38
38
|
return await tailordb.file.download(namespaces[type], type, field, recordId);
|
|
39
39
|
}
|
|
40
40
|
` + "\n",
|
|
41
|
-
|
|
41
|
+
multiline`
|
|
42
42
|
export async function uploadFile<T extends keyof TypeWithFiles>(
|
|
43
43
|
type: T,
|
|
44
44
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -49,7 +49,7 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
49
49
|
return await tailordb.file.upload(namespaces[type], type, field, recordId, data, options);
|
|
50
50
|
}
|
|
51
51
|
` + "\n",
|
|
52
|
-
|
|
52
|
+
multiline`
|
|
53
53
|
export async function deleteFile<T extends keyof TypeWithFiles>(
|
|
54
54
|
type: T,
|
|
55
55
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -58,7 +58,7 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
58
58
|
return await tailordb.file.delete(namespaces[type], type, field, recordId);
|
|
59
59
|
}
|
|
60
60
|
` + "\n",
|
|
61
|
-
|
|
61
|
+
multiline`
|
|
62
62
|
export async function getFileMetadata<T extends keyof TypeWithFiles>(
|
|
63
63
|
type: T,
|
|
64
64
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -67,7 +67,7 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
67
67
|
return await tailordb.file.getMetadata(namespaces[type], type, field, recordId);
|
|
68
68
|
}
|
|
69
69
|
` + "\n",
|
|
70
|
-
|
|
70
|
+
multiline`
|
|
71
71
|
export async function openFileDownloadStream<T extends keyof TypeWithFiles>(
|
|
72
72
|
type: T,
|
|
73
73
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -138,4 +138,4 @@ function fileUtilsPlugin(options) {
|
|
|
138
138
|
|
|
139
139
|
//#endregion
|
|
140
140
|
export { fileUtilsPlugin as n, FileUtilsGeneratorID as t };
|
|
141
|
-
//# sourceMappingURL=file-utils-
|
|
141
|
+
//# sourceMappingURL=file-utils-DjNi_3U_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils-DjNi_3U_.mjs","names":[],"sources":["../src/plugin/builtin/file-utils/generate-file-utils.ts","../src/plugin/builtin/file-utils/process-file-type.ts","../src/plugin/builtin/file-utils/index.ts"],"sourcesContent":["import multiline from \"@/utils/multiline\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Generate unified file utility functions from collected metadata.\n * @param namespaceData - Namespace data with file utility metadata\n * @returns Generated file utility code\n */\nexport function generateUnifiedFileUtils(\n namespaceData: { namespace: string; types: FileUtilMetadata[] }[],\n): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Collect all types with their namespace\n const typeNamespaceMap = new Map<string, string>();\n const typeFieldsMap = new Map<string, string[]>();\n\n for (const { namespace, types } of namespaceData) {\n for (const type of types) {\n typeNamespaceMap.set(type.name, namespace);\n typeFieldsMap.set(type.name, type.fileFields);\n }\n }\n\n if (typeNamespaceMap.size === 0) {\n return \"\";\n }\n\n // Generate interface fields\n const interfaceFields = Array.from(typeFieldsMap.entries())\n .map(([typeName, fields]) => {\n const fieldNamesUnion = fields.map((field) => `\"${field}\"`).join(\" | \");\n return ` ${typeName}: {\\n fields: ${fieldNamesUnion};\\n };`;\n })\n .join(\"\\n\");\n\n const interfaceDefinition =\n multiline /* ts */ `\n export interface TypeWithFiles {\n ${interfaceFields}\n }\n ` + \"\\n\";\n\n // Generate namespaces object\n const namespaceEntries = Array.from(typeNamespaceMap.entries())\n .map(([typeName, namespace]) => ` ${typeName}: \"${namespace}\"`)\n .join(\",\\n\");\n\n const namespacesDefinition =\n multiline /* ts */ `\n const namespaces: Record<keyof TypeWithFiles, string> = {\n ${namespaceEntries},\n };\n ` + \"\\n\";\n\n // Generate downloadFile helper function\n const downloadFunction =\n multiline /* ts */ `\n export async function downloadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ) {\n return await tailordb.file.download(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate uploadFile helper function\n const uploadFunction =\n multiline /* ts */ `\n export async function uploadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n data: string | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse> {\n return await tailordb.file.upload(namespaces[type], type, field, recordId, data, options);\n }\n ` + \"\\n\";\n\n // Generate deleteFile helper function\n const deleteFunction =\n multiline /* ts */ `\n export async function deleteFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<void> {\n return await tailordb.file.delete(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate getFileMetadata helper function\n const getMetadataFunction =\n multiline /* ts */ `\n export async function getFileMetadata<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileMetadata> {\n return await tailordb.file.getMetadata(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate openFileDownloadStream helper function\n const openDownloadStreamFunction =\n multiline /* ts */ `\n export async function openFileDownloadStream<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileStreamIterator> {\n return await tailordb.file.openDownloadStream(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n return [\n interfaceDefinition,\n namespacesDefinition,\n downloadFunction,\n uploadFunction,\n deleteFunction,\n getMetadataFunction,\n openDownloadStreamFunction,\n ].join(\"\\n\");\n}\n","import type { FileUtilMetadata } from \"./types\";\nimport type { TailorDBType } from \"@/types/tailordb\";\n\n/**\n * Process a TailorDB type and extract file field metadata.\n * @param type - The parsed TailorDB type to process\n * @returns File utility metadata for the type\n */\nexport async function processFileType(type: TailorDBType): Promise<FileUtilMetadata> {\n const fileFields: string[] = [];\n\n if (type.files) {\n for (const fileFieldName of Object.keys(type.files)) {\n fileFields.push(fileFieldName);\n }\n }\n\n return {\n name: type.name,\n fileFields,\n };\n}\n","import { generateUnifiedFileUtils } from \"./generate-file-utils\";\nimport { processFileType } from \"./process-file-type\";\nimport type { FileUtilMetadata } from \"./types\";\nimport type { Plugin } from \"@/types/plugin\";\nimport type { GeneratorResult, TailorDBReadyContext } from \"@/types/plugin-generation\";\n\n/** Unique identifier for the file utilities generator plugin. */\nexport const FileUtilsGeneratorID = \"@tailor-platform/file-utils\";\n\ntype FileUtilsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates TypeWithFiles interface from TailorDB type definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated file utilities\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function fileUtilsPlugin(\n options: FileUtilsPluginOptions,\n): Plugin<unknown, FileUtilsPluginOptions> {\n return {\n id: FileUtilsGeneratorID,\n description: \"Generates TypeWithFiles interface from TailorDB type definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<FileUtilsPluginOptions>,\n ): Promise<GeneratorResult> {\n const namespaceData: { namespace: string; types: FileUtilMetadata[] }[] = [];\n\n for (const ns of ctx.tailordb) {\n const typesWithFiles: FileUtilMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processFileType(type);\n if (metadata.fileFields.length > 0) {\n typesWithFiles.push(metadata);\n }\n }\n\n if (typesWithFiles.length > 0) {\n namespaceData.push({\n namespace: ns.namespace,\n types: typesWithFiles,\n });\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (namespaceData.length > 0) {\n const content = generateUnifiedFileUtils(namespaceData);\n if (content) {\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,yBACd,eACQ;AACR,KAAI,cAAc,WAAW,EAC3B,QAAO;CAIT,MAAM,mCAAmB,IAAI,KAAqB;CAClD,MAAM,gCAAgB,IAAI,KAAuB;AAEjD,MAAK,MAAM,EAAE,WAAW,WAAW,cACjC,MAAK,MAAM,QAAQ,OAAO;AACxB,mBAAiB,IAAI,KAAK,MAAM,UAAU;AAC1C,gBAAc,IAAI,KAAK,MAAM,KAAK,WAAW;;AAIjD,KAAI,iBAAiB,SAAS,EAC5B,QAAO;AA4FT,QAAO;EAhFL,SAAmB;;QARG,MAAM,KAAK,cAAc,SAAS,CAAC,CACxD,KAAK,CAAC,UAAU,YAAY;AAE3B,UAAO,KAAK,SAAS,mBADG,OAAO,KAAK,UAAU,IAAI,MAAM,GAAG,CAAC,KAAK,MACV,CAAC;IACxD,CACD,KAAK,KAKa,CAAC;;QAEhB;EAQJ,SAAmB;;QALI,MAAM,KAAK,iBAAiB,SAAS,CAAC,CAC5D,KA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as Plugin } from "./tailor-db-field-Hx9OqPWY.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/file-utils/index.d.ts
|
|
5
5
|
/** Unique identifier for the file utilities generator plugin. */
|
|
@@ -16,4 +16,4 @@ type FileUtilsPluginOptions = {
|
|
|
16
16
|
declare function fileUtilsPlugin(options: FileUtilsPluginOptions): Plugin<unknown, FileUtilsPluginOptions>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { fileUtilsPlugin as n, FileUtilsGeneratorID as t };
|
|
19
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-B5_4Tzm2.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
2
|
+
import { o as Plugin } from "./tailor-db-field-Hx9OqPWY.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/seed/index.d.ts
|
|
5
5
|
/** Unique identifier for the seed generator plugin. */
|
|
@@ -18,4 +18,4 @@ type SeedPluginOptions = {
|
|
|
18
18
|
declare function seedPlugin(options: SeedPluginOptions): Plugin<unknown, SeedPluginOptions>;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { seedPlugin as n, SeedGeneratorID as t };
|
|
21
|
-
//# sourceMappingURL=index-
|
|
21
|
+
//# sourceMappingURL=index-BBvPd9Uv.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { $ as ResolverInput, At as FieldMetadata, Bt as InferredAttributeMap, Dt as ArrayFieldOutput, Ft as FieldValidateInput, G as UserAttributeListKey, Gt as JsonCompatible, Ht as TailorUser, Jt as output$1, K as UserAttributeMap, Kt as JsonValue, Mt as FieldOutput, Nt as TailorFieldType, Ot as DefinedFieldMetadata, Q as Resolver, V as DefinedAuth, Vt as TailorInvoker, Wt as InferFieldsOutput, Y as TailorField$1, at as FunctionOperation$1, ct as IncomingWebhookTrigger$1, dt as TailorDBTrigger$1, et as GeneratorConfig, ft as WebhookOperation$1, it as ExecutorInput, jt as FieldOptions, lt as ResolverExecutedTrigger$1, mt as AuthInvoker$1, nt as AuthAccessTokenTrigger$1, o as Plugin, ot as GqlOperation$1, pt as WorkflowOperation$1, qt as Prettify, st as IdpUserTrigger$1, tt as BaseGeneratorConfig, ut as ScheduleTriggerInput, z as AuthServiceInput } from "./tailor-db-field-
|
|
3
|
-
import { C as IdPInput, D as TailorDBInstance, F as AllowedValues, I as AllowedValuesOutput, O as TailorDBType, f as StaticWebsiteDefinitionBrand, h as SecretsDefinitionBrand, n as RetryPolicy, p as StaticWebsiteInput, r as AppConfig, t as ConcurrencyPolicy, v as IdPUserField, y as IdpDefinitionBrand } from "./workflow.generated
|
|
4
|
-
import { r as TailorEnv, t as TailorActor } from "./actor-
|
|
2
|
+
import { $ as ResolverInput, At as FieldMetadata, Bt as InferredAttributeMap, Dt as ArrayFieldOutput, Ft as FieldValidateInput, G as UserAttributeListKey, Gt as JsonCompatible, Ht as TailorUser, Jt as output$1, K as UserAttributeMap, Kt as JsonValue, Mt as FieldOutput, Nt as TailorFieldType, Ot as DefinedFieldMetadata, Q as Resolver, V as DefinedAuth, Vt as TailorInvoker, Wt as InferFieldsOutput, Y as TailorField$1, at as FunctionOperation$1, ct as IncomingWebhookTrigger$1, dt as TailorDBTrigger$1, et as GeneratorConfig, ft as WebhookOperation$1, it as ExecutorInput, jt as FieldOptions, lt as ResolverExecutedTrigger$1, mt as AuthInvoker$1, nt as AuthAccessTokenTrigger$1, o as Plugin, ot as GqlOperation$1, pt as WorkflowOperation$1, qt as Prettify, st as IdpUserTrigger$1, tt as BaseGeneratorConfig, ut as ScheduleTriggerInput, z as AuthServiceInput } from "./tailor-db-field-Hx9OqPWY.mjs";
|
|
3
|
+
import { C as IdPInput, D as TailorDBInstance, F as AllowedValues, I as AllowedValuesOutput, O as TailorDBType, f as StaticWebsiteDefinitionBrand, h as SecretsDefinitionBrand, n as RetryPolicy, p as StaticWebsiteInput, r as AppConfig, t as ConcurrencyPolicy, v as IdPUserField, y as IdpDefinitionBrand } from "./workflow.generated-DFljpJh7.mjs";
|
|
4
|
+
import { r as TailorEnv, t as TailorActor } from "./actor-BmxQeMFP.mjs";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
import { Client } from "@urql/core";
|
|
7
7
|
import { StandardCRON } from "ts-cron-validator";
|
|
@@ -1129,4 +1129,4 @@ declare namespace t {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
//#endregion
|
|
1131
1131
|
export { recordDeletedTrigger as $, AuthAccessTokenRefreshedArgs as A, RecordUpdatedArgs as B, IncomingWebhookTriggerOptions as C, MachineUserNameRegistry as Ct, scheduleTrigger as D, ScheduleTrigger as E, IdpUserDeletedArgs as F, authAccessTokenRefreshedTrigger as G, ResolverExecutedTrigger as H, IdpUserTrigger as I, idpUserCreatedTrigger as J, authAccessTokenRevokedTrigger as K, IdpUserUpdatedArgs as L, AuthAccessTokenTrigger as M, IdpUserArgs as N, AuthAccessTokenArgs as O, IdpUserCreatedArgs as P, recordCreatedTrigger as Q, RecordCreatedArgs as R, IncomingWebhookTrigger as S, MachineUserName as St, ScheduleArgs as T, TailorDBTrigger as U, ResolverExecutedArgs as V, authAccessTokenIssuedTrigger as W, idpUserTrigger as X, idpUserDeletedTrigger as Y, idpUserUpdatedTrigger as Z, Trigger as _, AuthInvoker as _t, defineGenerators as a, Operation as at, IncomingWebhookResponse as b, IdpNameRegistry as bt, defineIdp as c, Workflow as ct, unsafeAllowAllIdPPermission as d, WORKFLOW_TEST_ENV_KEY as dt, recordTrigger as et, defineStaticWebSite as f, WorkflowJob as ft, createExecutor as g, createResolver as gt, defineWaitPoints as h, QueryType as ht, defineConfig as i, GqlOperation as it, AuthAccessTokenRevokedArgs as j, AuthAccessTokenIssuedArgs as k, IdPPermission as l, WorkflowConfig as lt, defineWaitPoint as m, createWorkflowJob as mt, output as n, resolverExecutedTrigger as nt, definePlugins as o, WebhookOperation as ot, WaitPointInstance as p, WorkflowJobContext as pt, authAccessTokenTrigger as q, t as r, FunctionOperation as rt, defineSecretManager as s, WorkflowOperation as st, infer as t, recordUpdatedTrigger as tt, IdPPermissionCondition as u, createWorkflow as ut, IncomingWebhookArgs as v, defineAuth as vt, incomingWebhookTrigger as w, IncomingWebhookResponseConfig as x, TailorField as xt, IncomingWebhookRequest as y, IdpName as yt, RecordDeletedArgs as z };
|
|
1132
|
-
//# sourceMappingURL=index-
|
|
1132
|
+
//# sourceMappingURL=index-DUKJPEwq.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
2
|
+
import { o as Plugin } from "./tailor-db-field-Hx9OqPWY.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/kysely-type/index.d.ts
|
|
5
5
|
/** Unique identifier for the Kysely type generator plugin. */
|
|
@@ -16,4 +16,4 @@ type KyselyTypePluginOptions = {
|
|
|
16
16
|
declare function kyselyTypePlugin(options: KyselyTypePluginOptions): Plugin<unknown, KyselyTypePluginOptions>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { kyselyTypePlugin as n, KyselyGeneratorID as t };
|
|
19
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-DV-5OIEv.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
2
|
+
import { o as Plugin } from "./tailor-db-field-Hx9OqPWY.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/enum-constants/index.d.ts
|
|
5
5
|
/** Unique identifier for the enum constants generator plugin. */
|
|
@@ -16,4 +16,4 @@ type EnumConstantsPluginOptions = {
|
|
|
16
16
|
declare function enumConstantsPlugin(options: EnumConstantsPluginOptions): Plugin<unknown, EnumConstantsPluginOptions>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { enumConstantsPlugin as n, EnumConstantsGeneratorID as t };
|
|
19
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-Dxe6alSZ.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor-
|
|
1
|
+
{"version":3,"file":"interceptor-CrcDfLPq.mjs","names":[],"sources":["../src/cli/telemetry/interceptor.ts"],"sourcesContent":["import { trace, SpanStatusCode } from \"@opentelemetry/api\";\nimport type { Interceptor } from \"@connectrpc/connect\";\n\n/**\n * Create a Connect-RPC interceptor that records OTLP spans for each RPC call.\n * When no TracerProvider is registered, the OTel API automatically provides\n * noop spans with zero overhead.\n * @returns Tracing interceptor\n */\nexport function createTracingInterceptor(): Interceptor {\n return (next) => async (req) => {\n const tracer = trace.getTracer(\"tailor-sdk\");\n\n return tracer.startActiveSpan(`rpc.${req.method.name}`, async (span) => {\n span.setAttribute(\"rpc.method\", req.method.name);\n span.setAttribute(\"rpc.service\", \"OperatorService\");\n span.setAttribute(\"rpc.system\", \"connect-rpc\");\n\n try {\n const response = await next(req);\n span.setStatus({ code: SpanStatusCode.OK });\n return response;\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR });\n if (error instanceof Error) {\n span.recordException(error);\n }\n throw error;\n } finally {\n span.end();\n }\n });\n };\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,2BAAwC;AACtD,SAAQ,SAAS,OAAO,QAAQ;AAG9B,SAFe,MAAM,UAAU,aAElB,CAAC,gBAAgB,OAAO,IAAI,OAAO,QAAQ,OAAO,SAAS;AACtE,QAAK,aAAa,cAAc,IAAI,OAAO,KAAK;AAChD,QAAK,aAAa,eAAe,kBAAkB;AACnD,QAAK,aAAa,cAAc,cAAc;AAE9C,OAAI;IACF,MAAM,WAAW,MAAM,KAAK,IAAI;AAChC,SAAK,UAAU,EAAE,MAAM,eAAe,IAAI,CAAC;AAC3C,WAAO;YACA,OAAO;AACd,SAAK,UAAU,EAAE,MAAM,eAAe,OAAO,CAAC;AAC9C,QAAI,iBAAiB,MACnB,MAAK,gBAAgB,MAAM;AAE7B,UAAM;aACE;AACR,SAAK,KAAK;;IAEZ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
2
|
+
import { t as multiline } from "./multiline-e3IpANmS.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/kysely-type/type-processor.ts
|
|
5
5
|
/**
|
|
@@ -142,7 +142,7 @@ function generateTableInterface(type) {
|
|
|
142
142
|
Serial: false
|
|
143
143
|
});
|
|
144
144
|
return {
|
|
145
|
-
typeDef:
|
|
145
|
+
typeDef: multiline`
|
|
146
146
|
${type.name}: {
|
|
147
147
|
${fields.join("\n")}
|
|
148
148
|
}
|
|
@@ -183,7 +183,7 @@ function generateUnifiedKyselyTypes(namespaceData) {
|
|
|
183
183
|
if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ArrayColumnType<")))) utilityTypeImports.push("type ArrayColumnType");
|
|
184
184
|
if (globalUsedUtilityTypes.Serial) utilityTypeImports.push("type Serial");
|
|
185
185
|
return [
|
|
186
|
-
|
|
186
|
+
multiline`
|
|
187
187
|
import {
|
|
188
188
|
createGetDB,
|
|
189
189
|
${utilityTypeImports.join(",\n")},
|
|
@@ -201,12 +201,12 @@ function generateUnifiedKyselyTypes(namespaceData) {
|
|
|
201
201
|
return type.typeDef.split("\n").map((line) => line.trim() ? ` ${line}` : "").join("\n");
|
|
202
202
|
}).join("\n\n")}\n }`;
|
|
203
203
|
}).join(",\n")}\n}`,
|
|
204
|
-
|
|
204
|
+
multiline`
|
|
205
205
|
export const getDB = createGetDB<Namespace>();
|
|
206
206
|
|
|
207
207
|
export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
|
|
208
208
|
`,
|
|
209
|
-
|
|
209
|
+
multiline`
|
|
210
210
|
export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
|
|
211
211
|
NamespaceTransaction<Namespace, K>;
|
|
212
212
|
|
|
@@ -272,4 +272,4 @@ function kyselyTypePlugin(options) {
|
|
|
272
272
|
|
|
273
273
|
//#endregion
|
|
274
274
|
export { kyselyTypePlugin as n, KyselyGeneratorID as t };
|
|
275
|
-
//# sourceMappingURL=kysely-type-
|
|
275
|
+
//# sourceMappingURL=kysely-type-B8aRz_oC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely-type-B8aRz_oC.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"@/utils/multiline\";\nimport { type KyselyNamespaceMetadata, type KyselyTypeMetadata } from \"./types\";\nimport type { OperatorFieldConfig, TailorDBType } from \"@/types/tailordb\";\n\ntype UsedUtilityTypes = { Timestamp: boolean; Serial: boolean };\n\ntype FieldTypeResult = {\n type: string;\n usedUtilityTypes: UsedUtilityTypes;\n};\n\n/**\n * Get the enum type definition.\n * @param fieldConfig - The field configuration\n * @returns The enum type as a string union\n */\nfunction getEnumType(fieldConfig: OperatorFieldConfig): string {\n const allowedValues = fieldConfig.allowedValues;\n\n if (allowedValues && Array.isArray(allowedValues)) {\n return allowedValues\n .map((v: string | { value: string }) => {\n const value = typeof v === \"string\" ? v : v.value;\n return `\"${value}\"`;\n })\n .join(\" | \");\n }\n return \"string\";\n}\n\n/**\n * Get the nested object type definition.\n * @param fieldConfig - The field configuration\n * @returns The nested type with used utility types\n */\nfunction getNestedType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fields = fieldConfig.fields;\n if (!fields || typeof fields !== \"object\") {\n return {\n type: \"string\",\n usedUtilityTypes: { Timestamp: false, Serial: false },\n };\n }\n\n const fieldResults = Object.entries(fields).map(([fieldName, config]) => {\n const result = generateFieldType(config);\n const optional = config.required !== true ? \"?\" : \"\";\n return {\n fieldType: `${fieldName}${optional}: ${result.type}`,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n });\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const fieldTypes = fieldResults.map((r) => r.fieldType);\n const obj = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n\n const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields) {\n return { type: `ObjectColumnType<${obj}>`, usedUtilityTypes: aggregatedUtilityTypes };\n }\n return { type: obj, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Get the base Kysely type for a field (without array/null modifiers).\n * @param fieldConfig - The field configuration\n * @returns The base type with used utility types\n */\nfunction getBaseType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n let type: string;\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n type = \"string\";\n break;\n case \"integer\":\n case \"float\":\n type = \"number\";\n break;\n case \"date\":\n case \"datetime\":\n usedUtilityTypes.Timestamp = true;\n type = \"Timestamp\";\n break;\n case \"bool\":\n case \"boolean\":\n type = \"boolean\";\n break;\n case \"enum\":\n type = getEnumType(fieldConfig);\n break;\n case \"nested\": {\n const nestedResult = getNestedType(fieldConfig);\n return nestedResult;\n }\n default:\n type = \"string\";\n break;\n }\n\n return { type, usedUtilityTypes };\n}\n\n/**\n * Generate the complete field type including array and null modifiers.\n * @param fieldConfig - The field configuration\n * @returns The complete field type with used utility types\n */\nfunction generateFieldType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const baseTypeResult = getBaseType(fieldConfig);\n const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };\n\n const isArray = fieldConfig.array === true;\n const isNullable = fieldConfig.required !== true;\n\n // Types that use ColumnType internally (Timestamp, ObjectColumnType) cannot be\n // directly wrapped with [] for arrays, because Kysely only resolves ColumnType at\n // the top-level table property. Use ArrayColumnType/ObjectArrayColumnType to keep\n // the ColumnType at the top level with arrays inside.\n const columnTypeBaseTypes = new Set([\"Timestamp\"]);\n const isColumnTypeBase = columnTypeBaseTypes.has(baseTypeResult.type);\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n if (isColumnTypeBase || finalType.startsWith(\"ObjectColumnType<\")) {\n finalType = `ArrayColumnType<${baseTypeResult.type}>`;\n } else {\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\n }\n if (isNullable) {\n finalType = `${finalType} | null`;\n }\n\n if (fieldConfig.serial) {\n usedUtilityTypes.Serial = true;\n finalType = `Serial<${finalType}>`;\n }\n if (fieldConfig.hooks?.create) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param type - The parsed TailorDB type\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(type: TailorDBType): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(type.fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, parsedField]) => ({\n fieldName,\n ...generateFieldType(parsedField.config),\n }));\n\n const fields = [\n \"id: Generated<string>;\",\n ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`),\n ];\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const typeDef = multiline /* ts */ `\n ${type.name}: {\n ${fields.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB type\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n const result = generateTableInterface(type);\n\n return {\n name: type.name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Generate unified types file from multiple namespaces.\n * @param namespaceData - Namespace metadata\n * @returns Generated types file contents\n */\nexport function generateUnifiedKyselyTypes(namespaceData: KyselyNamespaceMetadata[]): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Aggregate used utility types from all namespaces\n const globalUsedUtilityTypes = namespaceData.reduce(\n (acc, ns) => ({\n Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || ns.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const utilityTypeImports: string[] = [\"type Generated\"];\n if (globalUsedUtilityTypes.Timestamp) {\n utilityTypeImports.push(\"type Timestamp\");\n }\n const hasObjectColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ObjectColumnType<\")),\n );\n if (hasObjectColumnType) {\n utilityTypeImports.push(\"type ObjectColumnType\");\n }\n const hasArrayColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ArrayColumnType<\")),\n );\n if (hasArrayColumnType) {\n utilityTypeImports.push(\"type ArrayColumnType\");\n }\n if (globalUsedUtilityTypes.Serial) {\n utilityTypeImports.push(\"type Serial\");\n }\n\n const importsSection = multiline /* ts */ `\n import {\n createGetDB,\n ${utilityTypeImports.join(\",\\n\")},\n type NamespaceDB,\n type NamespaceInsertable,\n type NamespaceSelectable,\n type NamespaceTable,\n type NamespaceTableName,\n type NamespaceTransaction,\n type NamespaceUpdateable,\n } from \"@tailor-platform/sdk/kysely\";\n `;\n\n // Generate Namespace interface with multiple namespaces\n const namespaceInterfaces = namespaceData\n .map(({ namespace, types }) => {\n const typeDefsWithIndent = types\n .map((type) => {\n return type.typeDef\n .split(\"\\n\")\n .map((line) => (line.trim() ? ` ${line}` : \"\"))\n .join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return ` \"${namespace}\": {\\n${typeDefsWithIndent}\\n }`;\n })\n .join(\",\\n\");\n\n const namespaceInterface = `export interface Namespace {\\n${namespaceInterfaces}\\n}`;\n\n const getDBFunction = multiline /* ts */ `\n export const getDB = createGetDB<Namespace>();\n\n export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;\n `;\n\n const utilityTypeExports = multiline /* ts */ `\n export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =\n NamespaceTransaction<Namespace, K>;\n\n type TableName = NamespaceTableName<Namespace>;\n export type Table<T extends TableName> = NamespaceTable<Namespace, T>;\n\n export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;\n export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;\n export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;\n `;\n\n return (\n [importsSection, namespaceInterface, getDBFunction, utilityTypeExports].join(\"\\n\\n\") + \"\\n\"\n );\n}\n","import { processKyselyType, generateUnifiedKyselyTypes } from \"./type-processor\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\nimport type { Plugin } from \"@/types/plugin\";\nimport type { GeneratorResult, TailorDBReadyContext } from \"@/types/plugin-generation\";\n\n/** Unique identifier for the Kysely type generator plugin. */\nexport const KyselyGeneratorID = \"@tailor-platform/kysely-type\";\n\ntype KyselyTypePluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB types.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated types\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function kyselyTypePlugin(\n options: KyselyTypePluginOptions,\n): Plugin<unknown, KyselyTypePluginOptions> {\n return {\n id: KyselyGeneratorID,\n description: \"Generates Kysely type definitions for TailorDB types\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<KyselyTypePluginOptions>,\n ): Promise<GeneratorResult> {\n const allNamespaceData: KyselyNamespaceMetadata[] = [];\n\n for (const ns of ctx.tailordb) {\n const typeMetadataList: KyselyTypeMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processKyselyType(type);\n typeMetadataList.push(metadata);\n }\n\n if (typeMetadataList.length === 0) continue;\n\n const usedUtilityTypes = typeMetadataList.reduce(\n (acc, type) => ({\n Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || type.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n allNamespaceData.push({\n namespace: ns.namespace,\n types: typeMetadataList,\n usedUtilityTypes,\n });\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allNamespaceData.length > 0) {\n const content = generateUnifiedKyselyTypes(allNamespaceData);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAS,YAAY,aAA0C;CAC7D,MAAM,gBAAgB,YAAY;AAElC,KAAI,iBAAiB,MAAM,QAAQ,cAAc,CAC/C,QAAO,cACJ,KAAK,MAAkC;AAEtC,SAAO,IADO,OAAO,MAAM,WAAW,IAAI,EAAE,MAC3B;GACjB,CACD,KAAK,MAAM;AAEhB,QAAO;;;;;;;AAQT,SAAS,cAAc,aAAmD;CACxE,MAAM,SAAS,YAAY;AAC3B,KAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,QAAO;EACL,MAAM;EACN,kBAAkB;GAAE,WAAW;GAAO,QAAQ;GAAO;EACtD;CAGH,MAAM,eAAe,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,WAAW,YAAY;EACvE,MAAM,SAAS,kBAAkB,OAAO;AAExC,SAAO;GACL,WAAW,GAAG,YAFC,OAAO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AAK,MAAM,QAAQ,OAAO,OAAO,GAAG,MAAM,EAAE;KAC1C,MAAM,WAAW,MAAM,kBAAkB,KAAK;AAC9C,sBAAiB,KAAK,SAAS;;AAGjC,QAAI,iBAAiB,WAAW,EAAG;IAEnC,MAAM,mBAAmB,iBAAiB,QACvC,KAAK,UAAU;KACd,WAAW,IAAI,aAAa,KAAK,iBAAiB;KAClD,QAAQ,IAAI,UAAU,KAAK,iBAAiB;KAC7C,GACD;KAAE,WAAW;KAAO,QAAQ;KAAO,CACpC;AAED,qBAAiB,KAAK;KACpB,WAAW,GAAG;KACd,OAAO;KACP;KACD,CAAC;;GAGJ,MAAM,QAAkC,EAAE;AAC1C,OAAI,iBAAiB,SAAS,GAAG;IAC/B,MAAM,UAAU,2BAA2B,iBAAiB;AAC5D,UAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;KACD,CAAC;;AAGJ,UAAO,EAAE,OAAO;;EAEnB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/multiline.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tag function which strips the common leading indent from a multi-line
|
|
5
|
+
* template literal and trims surrounding blank lines, while indenting each
|
|
6
|
+
* line of interpolated values to match the placeholder's indent.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the behaviour of the `multiline-ts` package, which we used to
|
|
9
|
+
* depend on. We replaced it with this in-tree implementation because the
|
|
10
|
+
* upstream package ships a `preinstall: npx only-allow pnpm` hook that
|
|
11
|
+
* makes `npx create-tailor-sdk@latest` (and any other npm-based install
|
|
12
|
+
* path that resolves a fresh copy) abort with `ECOMPROMISED`.
|
|
13
|
+
* @param value - Template strings array, or a plain string for non-tagged usage
|
|
14
|
+
* @param inputs - Interpolated values
|
|
15
|
+
* @returns The dedented and trimmed string
|
|
16
|
+
*/
|
|
17
|
+
function multiline(value, ...inputs) {
|
|
18
|
+
const strings = typeof value === "string" ? value.split(/(?=\r\n|\r|\n)/) : Array.from(value);
|
|
19
|
+
let currentIndent = "";
|
|
20
|
+
const lines = strings.map((segment, i) => {
|
|
21
|
+
if (/\r\n|\r|\n/.test(segment)) currentIndent = getFinalIndent(segment) || currentIndent;
|
|
22
|
+
return segment + (inputs[i] ?? "").replace(/\r\n|\r|\n/g, `\n${currentIndent}`);
|
|
23
|
+
}).join("").split(/\r\n|\r|\n/);
|
|
24
|
+
const indents = lines.filter((line) => /[^ \t]/.test(line)).map((line) => getIndent(line).length);
|
|
25
|
+
const minIndent = indents.length === 0 ? 0 : Math.min(...indents);
|
|
26
|
+
return lines.map((line) => line.slice(minIndent)).join("\n").replace(/^\n|\n[ \t]*$/g, "");
|
|
27
|
+
}
|
|
28
|
+
function getIndent(line) {
|
|
29
|
+
const match = line.match(/^[ \t]+/);
|
|
30
|
+
return match ? match[0] : "";
|
|
31
|
+
}
|
|
32
|
+
function getFinalIndent(value) {
|
|
33
|
+
const match = value.match(/(?<=(\r\n|\r|\n))[ \t]+$/);
|
|
34
|
+
return match ? match[0] : "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { multiline as t };
|
|
39
|
+
//# sourceMappingURL=multiline-e3IpANmS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiline-e3IpANmS.mjs","names":[],"sources":["../src/utils/multiline.ts"],"sourcesContent":["/**\n * Tag function which strips the common leading indent from a multi-line\n * template literal and trims surrounding blank lines, while indenting each\n * line of interpolated values to match the placeholder's indent.\n *\n * Mirrors the behaviour of the `multiline-ts` package, which we used to\n * depend on. We replaced it with this in-tree implementation because the\n * upstream package ships a `preinstall: npx only-allow pnpm` hook that\n * makes `npx create-tailor-sdk@latest` (and any other npm-based install\n * path that resolves a fresh copy) abort with `ECOMPROMISED`.\n * @param value - Template strings array, or a plain string for non-tagged usage\n * @param inputs - Interpolated values\n * @returns The dedented and trimmed string\n */\nexport default function multiline(\n value: TemplateStringsArray | string,\n ...inputs: string[]\n): string {\n const strings = typeof value === \"string\" ? value.split(/(?=\\r\\n|\\r|\\n)/) : Array.from(value);\n\n let currentIndent = \"\";\n const joined = strings\n .map((segment, i) => {\n if (/\\r\\n|\\r|\\n/.test(segment)) {\n currentIndent = getFinalIndent(segment) || currentIndent;\n }\n const input = inputs[i] ?? \"\";\n return segment + input.replace(/\\r\\n|\\r|\\n/g, `\\n${currentIndent}`);\n })\n .join(\"\");\n\n const lines = joined.split(/\\r\\n|\\r|\\n/);\n const indents = lines.filter((line) => /[^ \\t]/.test(line)).map((line) => getIndent(line).length);\n const minIndent = indents.length === 0 ? 0 : Math.min(...indents);\n return lines\n .map((line) => line.slice(minIndent))\n .join(\"\\n\")\n .replace(/^\\n|\\n[ \\t]*$/g, \"\");\n}\n\nfunction getIndent(line: string): string {\n const match = line.match(/^[ \\t]+/);\n return match ? match[0] : \"\";\n}\n\nfunction getFinalIndent(value: string): string {\n const match = value.match(/(?<=(\\r\\n|\\r|\\n))[ \\t]+$/);\n return match ? match[0] : \"\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,SAAwB,UACtB,OACA,GAAG,QACK;CACR,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,MAAM,iBAAiB,GAAG,MAAM,KAAK,MAAM;CAE7F,IAAI,gBAAgB;CAWpB,MAAM,QAVS,QACZ,KAAK,SAAS,MAAM;AACnB,MAAI,aAAa,KAAK,QAAQ,CAC5B,iBAAgB,eAAe,QAAQ,IAAI;AAG7C,SAAO,WADO,OAAO,MAAM,IACJ,QAAQ,eAAe,KAAK,gBAAgB;GACnE,CACD,KAAK,GAEY,CAAC,MAAM,aAAa;CACxC,MAAM,UAAU,MAAM,QAAQ,SAAS,SAAS,KAAK,KAAK,CAAC,CAAC,KAAK,SAAS,UAAU,KAAK,CAAC,OAAO;CACjG,MAAM,YAAY,QAAQ,WAAW,IAAI,IAAI,KAAK,IAAI,GAAG,QAAQ;AACjE,QAAO,MACJ,KAAK,SAAS,KAAK,MAAM,UAAU,CAAC,CACpC,KAAK,KAAK,CACV,QAAQ,kBAAkB,GAAG;;AAGlC,SAAS,UAAU,MAAsB;CACvC,MAAM,QAAQ,KAAK,MAAM,UAAU;AACnC,QAAO,QAAQ,MAAM,KAAK;;AAG5B,SAAS,eAAe,OAAuB;CAC7C,MAAM,QAAQ,MAAM,MAAM,2BAA2B;AACrD,QAAO,QAAQ,MAAM,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json-
|
|
1
|
+
{"version":3,"file":"package-json-6Px8bDpG.mjs","names":[],"sources":["../src/cli/shared/package-json.ts"],"sourcesContent":["import { readPackageJSON, type PackageJson } from \"pkg-types\";\n\nlet packageJson: PackageJson | null = null;\n\n/**\n * Read and cache the package.json of the SDK package.\n * @returns Parsed package.json contents\n */\nexport async function readPackageJson() {\n if (packageJson) {\n return packageJson;\n }\n packageJson = await readPackageJSON(import.meta.url);\n return packageJson;\n}\n"],"mappings":";;;;AAEA,IAAI,cAAkC;;;;;AAMtC,eAAsB,kBAAkB;AACtC,KAAI,YACF,QAAO;AAET,eAAc,MAAM,gBAAgB,OAAO,KAAK,IAAI;AACpD,QAAO"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-
|
|
2
|
+
import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-Dxe6alSZ.mjs";
|
|
3
3
|
export { EnumConstantsGeneratorID, enumConstantsPlugin };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-
|
|
2
|
+
import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-B5_4Tzm2.mjs";
|
|
3
3
|
export { FileUtilsGeneratorID, fileUtilsPlugin };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="@tailor-platform/function-types" />
|
|
2
|
-
import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-
|
|
2
|
+
import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-DV-5OIEv.mjs";
|
|
3
3
|
export { KyselyGeneratorID, kyselyTypePlugin };
|