@tailor-platform/sdk 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/dist/{application-CmXOqTaK.mjs → application-D5lh2-_W.mjs} +27 -25
- package/dist/application-D5lh2-_W.mjs.map +1 -0
- package/dist/application-o09L68wE.mjs +1 -0
- package/dist/cli/commands/deploy/config-id-injector.d.mts +16 -0
- package/dist/cli/commands/workspace/create.d.mts +1 -1
- package/dist/cli/lib.d.mts +7 -2
- package/dist/cli/lib.mjs +1 -1
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +41 -1136
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/args.d.mts +7 -1
- package/dist/cli/shared/beta.d.mts +8 -0
- package/dist/cli/shared/client.d.mts +11 -1
- package/dist/cli/shared/config.d.mts +13 -0
- package/dist/cli/shared/prompt.d.mts +53 -0
- package/dist/cli/shared/script-executor.d.mts +1 -1
- package/dist/cli/shared/workspace-name.d.mts +10 -1
- package/dist/completion/zsh-worker.zsh +10 -206
- package/dist/errors-BlX4gUw5.mjs +4 -0
- package/dist/errors-BlX4gUw5.mjs.map +1 -0
- package/dist/es-builtins-BHCXINQp.mjs +2 -0
- package/dist/es-builtins-BHCXINQp.mjs.map +1 -0
- package/dist/field-column-type-QMtF6lUp.mjs +2 -0
- package/dist/field-column-type-QMtF6lUp.mjs.map +1 -0
- package/dist/{kysely-type-BTi3BMtL.mjs → kysely-type-CmvAz1Xj.mjs} +4 -4
- package/dist/kysely-type-CmvAz1Xj.mjs.map +1 -0
- package/dist/node-builtins-TQHhwNzG.mjs +2 -0
- package/dist/node-builtins-TQHhwNzG.mjs.map +1 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/register-ts-hook-CL3Z3VP0.mjs +642 -0
- package/dist/register-ts-hook-CL3Z3VP0.mjs.map +1 -0
- package/dist/service-COC9whur.mjs +1 -0
- package/dist/{service-CLPMoj9n.mjs → service-CqbQXFDp.mjs} +2 -2
- package/dist/{service-CLPMoj9n.mjs.map → service-CqbQXFDp.mjs.map} +1 -1
- package/dist/{service-YqDsHmlK.mjs → service-DDon86tM.mjs} +2 -2
- package/dist/service-DDon86tM.mjs.map +1 -0
- package/dist/service_pb-BNxUPfP3.mjs +2 -0
- package/dist/service_pb-BNxUPfP3.mjs.map +1 -0
- package/dist/service_pb-D-xFu9Ub.mjs +1 -0
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +12 -0
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +18 -1
- package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +130 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +43 -4
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +9 -0
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.mjs +1 -1
- package/dist/workspace_resource_pb-B7S-zx4Z.mjs +2 -0
- package/dist/workspace_resource_pb-B7S-zx4Z.mjs.map +1 -0
- package/docs/cli-reference.md +0 -16
- package/docs/github-actions.md +12 -0
- package/docs/services/tailordb-migration.md +12 -0
- package/docs/services/tailordb.md +2 -2
- package/package.json +11 -13
- package/dist/application-CNeOcaLc.mjs +0 -1
- package/dist/application-CmXOqTaK.mjs.map +0 -1
- package/dist/errors-DLsQ_-ol.mjs +0 -2
- package/dist/errors-DLsQ_-ol.mjs.map +0 -1
- package/dist/es-builtins-n3wBv4Sv.mjs +0 -2
- package/dist/es-builtins-n3wBv4Sv.mjs.map +0 -1
- package/dist/kysely-type-BTi3BMtL.mjs.map +0 -1
- package/dist/node-builtins-oBl7EbyV.mjs +0 -2
- package/dist/node-builtins-oBl7EbyV.mjs.map +0 -1
- package/dist/register-ts-hook-oDA2JLp2.mjs +0 -640
- package/dist/register-ts-hook-oDA2JLp2.mjs.map +0 -1
- package/dist/service-D7iXk0BT.mjs +0 -1
- package/dist/service-YqDsHmlK.mjs.map +0 -1
- package/dist/service_pb-DGKCLuAs.mjs +0 -2
- package/dist/service_pb-DGKCLuAs.mjs.map +0 -1
- package/dist/service_pb-_aeFE-Nv.mjs +0 -1
- package/dist/workspace_resource_pb--GeYQPXu.mjs +0 -2
- package/dist/workspace_resource_pb--GeYQPXu.mjs.map +0 -1
- package/docs/cli/setup.md +0 -210
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./logger-CCjs1DuH.mjs";function shellQuote(e){return process.platform===`win32`?/^[A-Za-z0-9_./:=@+\\-]+$/.test(e)?e:`"${e.replaceAll(`"`,`\\"`)}"`:/^[A-Za-z0-9_./:=@+-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function needsArgvRendering(e){return process.platform===`win32`&&e.some(e=>/[%$!]/.test(e))}function formatCopyableCommand(e){return needsArgvRendering(e)?`argv ${JSON.stringify(e)}`:e.map(shellQuote).join(` `)}function formatNextAction(e){let t=[e.command,...e.args],n=formatCopyableCommand(t);return needsArgvRendering(t)?`with ${n}`:`\`${n}\``}function formatError(t){let n=[e.error(`Error${t.code?` [${t.code}]`:``}: ${t.message}`)];return t.details&&n.push(`\n ${e.dim(`Details:`)} ${t.details.split(`
|
|
2
|
+
`).join(`
|
|
3
|
+
`)}`),t.suggestion&&n.push(`\n ${e.info(`Suggestion:`)} ${t.suggestion}`),t.command&&n.push(`\n ${e.dim(`Help:`)} Run \`tailor ${t.command} --help\` for usage information.`),t.next&&n.push(`\n ${e.info(`Next:`)} Run ${formatNextAction(t.next)}.`),n.join(``)}function createCLIError(e){let t=Error(e.message);return t.name=`CLIError`,t.code=e.code,t.details=e.details,t.suggestion=e.suggestion,t.command=e.command,t.next=e.next,t.context=e.context,t.format=()=>formatError(t),t}function isCLIError(e){return e instanceof Error&&e.name===`CLIError`}function toError(e){return e instanceof Error?e:Error(String(e))}const t=/does not provide an export named '(?!default')([^']+)'/;function typeOnlyImportHint(e){if(!(e instanceof SyntaxError))return;let n=t.exec(e.message)?.[1];if(n)return`If '${n}' is a type, import it with \`import type\` (or the inline \`type\` modifier). The CLI runs TypeScript by stripping types from each file in isolation, so type-only exports do not exist at runtime. Set "verbatimModuleSyntax": true in tsconfig.json to catch this at typecheck.`}export{toError as a,isCLIError as i,formatCopyableCommand as n,typeOnlyImportHint as o,formatNextAction as r,createCLIError as t};
|
|
4
|
+
//# sourceMappingURL=errors-BlX4gUw5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BlX4gUw5.mjs","names":[],"sources":["../src/cli/shared/errors.ts"],"sourcesContent":["import { styles } from \"./logger\";\n\n/**\n * Options for creating a CLI error\n */\ninterface CLIErrorOptions {\n message: string;\n details?: string;\n suggestion?: string;\n command?: string;\n code?: string;\n next?: CLIErrorNextAction;\n context?: Readonly<Record<string, unknown>>;\n}\n\nexport interface CLIErrorNextAction {\n /** Executable name, such as `tailor`. */\n command: string;\n /** Arguments passed directly to the executable. */\n args: readonly 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 readonly next?: CLIErrorNextAction;\n readonly context?: Readonly<Record<string, unknown>>;\n format(): string;\n}\n\ntype CLIErrorInternal = Error & {\n code?: string;\n details?: string;\n suggestion?: string;\n command?: string;\n next?: CLIErrorNextAction;\n context?: Readonly<Record<string, unknown>>;\n format(): string;\n};\n\nfunction shellQuote(value: string): string {\n if (process.platform === \"win32\") {\n if (/^[A-Za-z0-9_./:=@+\\\\-]+$/.test(value)) return value;\n return `\"${value.replaceAll('\"', '\\\\\"')}\"`;\n }\n if (/^[A-Za-z0-9_./:=@+-]+$/.test(value)) return value;\n return `'${value.replaceAll(\"'\", `'\"'\"'`)}'`;\n}\n\nfunction needsArgvRendering(argv: readonly string[]): boolean {\n // cmd.exe/PowerShell expand %, $, and ! even inside double quotes, so no\n // quoting can keep such values literal on Windows.\n return process.platform === \"win32\" && argv.some((value) => /[%$!]/.test(value));\n}\n\n/**\n * Render an argv array as a copyable command line for the current platform's shell\n * @param {readonly string[]} argv - Executable name followed by its arguments\n * @returns {string} A shell-quoted command line, or an `argv [...]` JSON rendering when the platform shell cannot keep a value literal\n */\nexport function formatCopyableCommand(argv: readonly string[]): string {\n if (needsArgvRendering(argv)) {\n return `argv ${JSON.stringify(argv)}`;\n }\n return argv.map(shellQuote).join(\" \");\n}\n\n/**\n * Format an executable and argv as a shell-safe user-facing command.\n * @param next - Executable and arguments to format\n * @returns Shell command, or an argv representation when shell quoting is unsafe\n */\nexport function formatNextAction(next: CLIErrorNextAction): string {\n const argv = [next.command, ...next.args];\n const rendered = formatCopyableCommand(argv);\n return needsArgvRendering(argv) ? `with ${rendered}` : `\\`${rendered}\\``;\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 styles.error(`Error${error.code ? ` [${error.code}]` : \"\"}: ${error.message}`),\n ];\n\n if (error.details) {\n parts.push(`\\n ${styles.dim(\"Details:\")} ${error.details.split(\"\\n\").join(\"\\n \")}`);\n }\n\n if (error.suggestion) {\n parts.push(`\\n ${styles.info(\"Suggestion:\")} ${error.suggestion}`);\n }\n\n if (error.command) {\n parts.push(\n `\\n ${styles.dim(\"Help:\")} Run \\`tailor ${error.command} --help\\` for usage information.`,\n );\n }\n\n if (error.next) {\n parts.push(`\\n ${styles.info(\"Next:\")} Run ${formatNextAction(error.next)}.`);\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.next = options.next;\n error.context = options.context;\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/**\n * Convert a caught value into an Error, keeping Error instances as-is\n * @param value - Caught value\n * @returns The value itself when it is an Error, otherwise an Error of its string form\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value));\n}\n\nconst MISSING_NAMED_EXPORT_PATTERN = /does not provide an export named '(?!default')([^']+)'/;\n\n/**\n * Suggest `import type` when importing user code fails on a missing named\n * export. The CLI strips types from each file in isolation, so a type-only\n * export does not exist at runtime and a plain import of it fails to link.\n * @param error - Error thrown while importing user modules\n * @returns Suggestion text, or undefined when the error is not that failure\n */\nexport function typeOnlyImportHint(error: unknown): string | undefined {\n if (!(error instanceof SyntaxError)) return undefined;\n const name = MISSING_NAMED_EXPORT_PATTERN.exec(error.message)?.[1];\n if (!name) return undefined;\n return (\n `If '${name}' is a type, import it with \\`import type\\` (or the inline \\`type\\` modifier). ` +\n \"The CLI runs TypeScript by stripping types from each file in isolation, so type-only exports do not exist at runtime. \" +\n 'Set \"verbatimModuleSyntax\": true in tsconfig.json to catch this at typecheck.'\n );\n}\n\n// Re-export createCLIError as CLIError for backward compatibility\nexport { createCLIError as CLIError };\n"],"mappings":"0CA6CA,SAAS,WAAW,EAAuB,CAMzC,OALI,QAAQ,WAAa,QACnB,2BAA2B,KAAK,CAAK,EAAU,EAC5C,IAAI,EAAM,WAAW,IAAK,KAAK,EAAE,GAEtC,yBAAyB,KAAK,CAAK,EAAU,EAC1C,IAAI,EAAM,WAAW,IAAK,OAAO,EAAE,EAC5C,CAEA,SAAS,mBAAmB,EAAkC,CAG5D,OAAO,QAAQ,WAAa,SAAW,EAAK,KAAM,GAAU,QAAQ,KAAK,CAAK,CAAC,CACjF,CAOA,SAAgB,sBAAsB,EAAiC,CAIrE,OAHI,mBAAmB,CAAI,EAClB,QAAQ,KAAK,UAAU,CAAI,I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jE,CAEA,MAAM,EAA+B,yDASrC,SAAgB,mBAAmB,EAAoC,CACrE,GAAI,EAAE,aAAiB,aAAc,OACrC,IAAM,EAAO,EAA6B,KAAK,EAAM,OAAO,CAAC,GAAG,GAC3D,KACL,MACE,OAAO,EAAK,mRAIhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es-builtins-BHCXINQp.mjs","names":[],"sources":["../src/utils/es-builtins.ts"],"sourcesContent":["import * as globals from \"globals\";\n\ntype GlobalsShape = {\n builtin?: Record<string, boolean>;\n \"shared-node-browser\"?: Record<string, boolean>;\n node?: Record<string, boolean>;\n};\n\nconst globalsMap: GlobalsShape =\n (globals as unknown as { default?: GlobalsShape }).default ?? globals;\n\n/**\n * Runtime globals available in the PF execution environment.\n * Identifiers in this set are excluded from free variable detection\n * since they are always available in the runtime environment.\n *\n * Combines globals.builtin (ECMAScript language builtins) and\n * globals['shared-node-browser'] (shared runtime globals like\n * console, fetch, setTimeout, etc.) from the `globals` npm package.\n */\nexport const ES_BUILTINS = new Set([\n ...Object.keys(globalsMap.builtin ?? {}),\n ...Object.keys(globalsMap[\"shared-node-browser\"] ?? {}),\n]);\n\n/**\n * Node-only ambient globals (`process`, `Buffer`, `require`, `setImmediate`,\n * etc.) that `@types/node` puts in the global scope but that are absent from\n * `ES_BUILTINS`, so the Tailor Platform runtime never defines them. Sourced\n * from the same `globals` package as `ES_BUILTINS` instead of a hand-curated\n * list, so a newly recognized Node-only global can't be silently omitted.\n */\nexport const NODE_ONLY_GLOBALS = new Set(\n Object.keys(globalsMap.node ?? {}).filter((name) => !ES_BUILTINS.has(name)),\n);\n"],"mappings":"0BAQA,MAAM,EACH,EAAkD,SAAW,EAWnD,EAAc,IAAI,IAAI,CACjC,GAAG,OAAO,KAAK,EAAW,SAAW,CAAC,CAAC,EACvC,GAAG,OAAO,KAAK,EAAW,wBAA0B,CAAC,CAAC,CACxD,CAAC,EASY,EAAoB,IAAI,IACnC,OAAO,KAAK,EAAW,MAAQ,CAAC,CAAC,CAAC,CAAC,OAAQ,GAAS,CAAC,EAAY,IAAI,CAAI,CAAC,CAC5E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function mapFieldTypeToColumnType(e){switch(e){case`uuid`:case`string`:case`decimal`:return`string`;case`integer`:case`float`:return`number`;case`date`:case`datetime`:return`Timestamp`;case`bool`:case`boolean`:return`boolean`;case`enum`:case`nested`:throw Error(`Field type "${e}" has no scalar column type; resolve it before mapping.`);default:return`string`}}const e=new Map([[`Timestamp`,{select:`Date`,write:`Date | string`}]]);export{mapFieldTypeToColumnType as n,e as t};
|
|
2
|
+
//# sourceMappingURL=field-column-type-QMtF6lUp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-column-type-QMtF6lUp.mjs","names":[],"sources":["../src/utils/field-column-type.ts"],"sourcesContent":["/** The Kysely column type a TailorDB field maps to, before array/null modifiers. */\nexport type FieldColumnType = \"string\" | \"number\" | \"boolean\" | \"Timestamp\";\n\n/**\n * Map a scalar TailorDB field type to the column type generated code uses for it.\n *\n * `date` resolves to `Timestamp` because the function runtime hands back a\n * `Date` for a date column, same as for datetime.\n *\n * `enum` and `nested` carry their own shape, so each generator resolves them\n * before reaching here; passing either is a caller bug rather than a `string`\n * column.\n * @param fieldType - TailorDB scalar field type name\n * @returns The column type for the field, defaulting to `string`\n * @throws If given `enum` or `nested`\n */\nexport function mapFieldTypeToColumnType(fieldType: string): FieldColumnType {\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n return \"string\";\n case \"integer\":\n case \"float\":\n return \"number\";\n case \"date\":\n case \"datetime\":\n return \"Timestamp\";\n case \"bool\":\n case \"boolean\":\n return \"boolean\";\n case \"enum\":\n case \"nested\":\n throw new Error(\n `Field type \"${fieldType}\" has no scalar column type; resolve it before mapping.`,\n );\n default:\n return \"string\";\n }\n}\n\n/** The select and write types a `ColumnType`-shaped alias expands to. */\nexport type ColumnTypeAliasExpansion = {\n /** Type the alias reads back as. */\n readonly select: string;\n /** Type the alias accepts on insert and update. */\n readonly write: string;\n};\n\n/**\n * Column types whose alias expands to a `ColumnType`, mapped to that expansion.\n *\n * Kysely only unwraps a `ColumnType` at the top level of a table property, so an\n * array of one of these stays wrapped in `ArrayColumnType<...>` rather than taking\n * a `[]` suffix, which would nest the `ColumnType` out of Kysely's reach. Where a\n * generator has to spell out the slots itself, it reads the expansion from here\n * rather than inlining the alias, which would nest just the same.\n *\n * Both type generators track alias usage per alias to decide which declarations to\n * emit, so adding an entry here also means teaching them to report the new alias.\n */\nexport const COLUMN_TYPE_ALIASES: ReadonlyMap<string, ColumnTypeAliasExpansion> = new Map<\n FieldColumnType,\n ColumnTypeAliasExpansion\n>([[\"Timestamp\", { select: \"Date\", write: \"Date | string\" }]]);\n"],"mappings":"AAgBA,SAAgB,yBAAyB,EAAoC,CAC3E,OAAQ,EAAR,CACE,IAAK,OACL,IAAK,SACL,IAAK,UACH,MAAO,SACT,IAAK,UACL,IAAK,QACH,MAAO,SACT,IAAK,OACL,IAAK,WACH,MAAO,YACT,IAAK,OACL,IAAK,UACH,MAAO,UACT,IAAK,OACL,IAAK,SACH,MAAU,MACR,eAAe,EAAU,wDAC3B,EACF,QACE,MAAO,QACX,CACF,CAsBA,MAAa,EAAqE,IAAI,IAGpF,CAAC,CAAC,YAAa,CAAE,OAAQ,OAAQ,MAAO,eAAgB,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{t as e}from"./multiline-EyzjEwn9.mjs";function getEnumType(e){let t=e.allowedValues;return t&&Array.isArray(t)?t.map(e=>`"${typeof e==`string`?e:e.value}"`).join(` | `):`string`}function getNestedType(e){let t=e.fields;if(!t||typeof t!=`object`)return{type:`string`,usedUtilityTypes:{Timestamp:!1,Serial:!1}};let n=Object.entries(t).map(([e,t])=>{let n=generateFieldType(t);return{fieldType:`${e}${t.required===!0?``:`?`}: ${n.type}`,usedUtilityTypes:n.usedUtilityTypes}}),r=n.reduce((e,t)=>({Timestamp:e.Timestamp||t.usedUtilityTypes.Timestamp,Serial:e.Serial||t.usedUtilityTypes.Serial}),{Timestamp:!1,Serial:!1}),i=n.map(e=>e.fieldType),a=`{\n ${i.join(`;
|
|
2
|
-
`)}${i.length>0?`;`:``}\n}`,o=Object.values(t).some(e=>e.required!==!0),s=Object.values(t).some(e=>e.hooks?.create||e.default!==void 0||e.optionalOnCreate===!0);return r.Timestamp||o||s?{type:`ObjectColumnType<${a}>`,usedUtilityTypes:r}:{type:a,usedUtilityTypes:r}}function getBaseType(e){let
|
|
1
|
+
import{t as e}from"./multiline-EyzjEwn9.mjs";import{n as t,t as n}from"./field-column-type-QMtF6lUp.mjs";function getEnumType(e){let t=e.allowedValues;return t&&Array.isArray(t)?t.map(e=>`"${typeof e==`string`?e:e.value}"`).join(` | `):`string`}function getNestedType(e){let t=e.fields;if(!t||typeof t!=`object`)return{type:`string`,usedUtilityTypes:{Timestamp:!1,Serial:!1}};let n=Object.entries(t).map(([e,t])=>{let n=generateFieldType(t);return{fieldType:`${e}${t.required===!0?``:`?`}: ${n.type}`,usedUtilityTypes:n.usedUtilityTypes}}),r=n.reduce((e,t)=>({Timestamp:e.Timestamp||t.usedUtilityTypes.Timestamp,Serial:e.Serial||t.usedUtilityTypes.Serial}),{Timestamp:!1,Serial:!1}),i=n.map(e=>e.fieldType),a=`{\n ${i.join(`;
|
|
2
|
+
`)}${i.length>0?`;`:``}\n}`,o=Object.values(t).some(e=>e.required!==!0),s=Object.values(t).some(e=>e.hooks?.create||e.default!==void 0||e.optionalOnCreate===!0);return r.Timestamp||o||s?{type:`ObjectColumnType<${a}>`,usedUtilityTypes:r}:{type:a,usedUtilityTypes:r}}function getBaseType(e){let n=e.type,r={Timestamp:!1,Serial:!1};if(n===`enum`)return{type:getEnumType(e),usedUtilityTypes:r};if(n===`nested`)return getNestedType(e);let i=t(n);return r.Timestamp=i===`Timestamp`,{type:i,usedUtilityTypes:r}}function generateFieldType(e){let t=getBaseType(e),r={...t.usedUtilityTypes},i=e.array===!0,a=e.required!==!0,o=n.has(t.type),s=t.type;return i&&(s=o||s.startsWith(`ObjectColumnType<`)?`ArrayColumnType<${t.type}>`:e.type===`enum`?`(${t.type})[]`:`${t.type}[]`),a&&(s=`${s} | null`),e.serial&&(r.Serial=!0,s=`Serial<${s}>`),(e.hooks?.create||e.default!==void 0||e.optionalOnCreate===!0)&&(s=`Generated<${s}>`),{type:s,usedUtilityTypes:r}}function generateTableInterface(t,n){let r=Object.entries(n).filter(([e])=>e!==`id`).map(([e,t])=>({fieldName:e,...generateFieldType(t)})),i=[`id: Generated<string>;`,...r.map(e=>`${e.fieldName}: ${e.type};`)],a=r.reduce((e,t)=>({Timestamp:e.Timestamp||t.usedUtilityTypes.Timestamp,Serial:e.Serial||t.usedUtilityTypes.Serial}),{Timestamp:!1,Serial:!1});return{typeDef:e`
|
|
3
3
|
${t}: {
|
|
4
4
|
${i.join(`
|
|
5
5
|
`)}
|
|
@@ -39,5 +39,5 @@ import{t as e}from"./multiline-EyzjEwn9.mjs";function getEnumType(e){let t=e.all
|
|
|
39
39
|
`].join(`
|
|
40
40
|
|
|
41
41
|
`)+`
|
|
42
|
-
`}const
|
|
43
|
-
//# sourceMappingURL=kysely-type-
|
|
42
|
+
`}const r=`@tailor-platform/kysely-type`,i=`./generated/tailordb.ts`;function kyselyTypePlugin(e){return{id:r,description:`Generates Kysely type definitions for TailorDB tables`,pluginConfig:e,async onTailorDBReady(e){let t=[];for(let n of e.tailordb){let e=[];for(let t of Object.values(n.tables)){let n=await processKyselyType(t);e.push(n)}if(e.length===0)continue;let r=e.reduce((e,t)=>({Timestamp:e.Timestamp||t.usedUtilityTypes.Timestamp,Serial:e.Serial||t.usedUtilityTypes.Serial}),{Timestamp:!1,Serial:!1});t.push({namespace:n.namespace,types:e,usedUtilityTypes:r})}let n=[];if(t.length>0){let r=generateUnifiedKyselyTypes(t);n.push({path:e.pluginConfig.distPath,content:r})}return{files:n}}}}export{processKyselyFields as a,generateUnifiedKyselyTypes as i,r as n,kyselyTypePlugin as r,i as t};
|
|
43
|
+
//# sourceMappingURL=kysely-type-CmvAz1Xj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely-type-CmvAz1Xj.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import { COLUMN_TYPE_ALIASES, mapFieldTypeToColumnType } from \"#/utils/field-column-type\";\nimport multiline from \"#/utils/multiline\";\nimport {\n type KyselyFieldConfig,\n type KyselyNamespaceMetadata,\n type KyselyTypeMetadata,\n} from \"./types\";\nimport type { TailorDBType } from \"#/parser/service/tailordb/types\";\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: KyselyFieldConfig): 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: KyselyFieldConfig): 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 const hasGeneratedFields = Object.values(fields).some(\n (config) =>\n config.hooks?.create || config.default !== undefined || config.optionalOnCreate === true,\n );\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields || hasGeneratedFields) {\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: KyselyFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n if (fieldType === \"enum\") {\n return { type: getEnumType(fieldConfig), usedUtilityTypes };\n }\n if (fieldType === \"nested\") {\n return getNestedType(fieldConfig);\n }\n\n const type = mapFieldTypeToColumnType(fieldType);\n usedUtilityTypes.Timestamp = type === \"Timestamp\";\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: KyselyFieldConfig): 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 // A ColumnType-shaped alias and ObjectColumnType cannot be wrapped with [] for\n // arrays, because Kysely only resolves ColumnType at the top-level table\n // property. Use ArrayColumnType to keep the ColumnType at the top level.\n const isColumnTypeBase = COLUMN_TYPE_ALIASES.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 (\n fieldConfig.hooks?.create ||\n fieldConfig.default !== undefined ||\n fieldConfig.optionalOnCreate === true\n ) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param name - Table name\n * @param fields - Field configurations keyed by field name\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(\n name: string,\n fields: Record<string, KyselyFieldConfig>,\n): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, fieldConfig]) => ({\n fieldName,\n ...generateFieldType(fieldConfig),\n }));\n\n const fieldLines = [\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 ${name}: {\n ${fieldLines.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Generate KyselyTypeMetadata from field configurations.\n * @param name - Table name\n * @param fields - Field configurations keyed by field name\n * @returns Generated Kysely type metadata\n */\nexport function processKyselyFields(\n name: string,\n fields: Record<string, KyselyFieldConfig>,\n): KyselyTypeMetadata {\n const result = generateTableInterface(name, fields);\n\n return {\n name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB table\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n return processKyselyFields(\n type.name,\n Object.fromEntries(\n Object.entries(type.fields).map(([fieldName, parsedField]) => [\n fieldName,\n parsedField.config,\n ]),\n ),\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 { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\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// Register this plugin's config type under its own id, via the package's\n// real public specifier, so callers can resolve it type-safely from a\n// `Plugin[]` array (see plugin/get-plugin-config.ts's resolvePluginConfig)\n// without importing KyselyTypePluginOptions, which stays unexported.\ndeclare module \"@tailor-platform/sdk/plugin\" {\n interface PluginConfigRegistry {\n \"@tailor-platform/kysely-type\": KyselyTypePluginOptions;\n }\n}\n\n/** Conventional output path used when `kyselyTypePlugin` has no `distPath` configured. */\nexport const DEFAULT_KYSELY_TYPES_DIST_PATH = \"./generated/tailordb.ts\";\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB tables.\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 tables\",\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.tables)) {\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":"yGAqBA,SAAS,YAAY,EAAwC,CAC3D,IAAM,EAAgB,EAAY,cAUlC,OARI,GAAiB,MAAM,QAAQ,CAAa,EACvC,EACJ,I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;CAEwC,EAAE,MACnD,CAAC,CACD,KAAK;CAEsE,EAAE,KAqBzC,CAnBE;;;;IAmBa,CAbR;;;;;;;;;;GAa0B,CAAC,CAAC,KAAK;;CAAM,EAAI;CAE3F,CCzTA,MAAa,EAAoB,+BAiBpB,EAAiC,0BAQ9C,SAAgB,iBACd,EAC0C,CAC1C,MAAO,CACL,GAAI,EACJ,YAAa,wDACb,aAAc,EAEd,MAAM,gBACJ,EAC0B,CAC1B,IAAM,EAA8C,CAAC,EAErD,IAAK,IAAM,KAAM,EAAI,SAAU,CAC7B,IAAM,EAAyC,CAAC,EAEhD,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAG,MAAM,EAAG,CAC3C,IAAM,EAAW,MAAM,kBAAkB,CAAI,EAC7C,EAAiB,KAAK,CAAQ,CAChC,CAEA,GAAI,EAAiB,SAAW,EAAG,SAEnC,IAAM,EAAmB,EAAiB,QACvC,EAAK,KAAU,CACd,UAAW,EAAI,WAAa,EAAK,iBAAiB,UAClD,OAAQ,EAAI,QAAU,EAAK,iBAAiB,MAC9C,GACA,CAAE,UAAW,GAAO,OAAQ,EAAM,CACpC,EAEA,EAAiB,KAAK,CACpB,UAAW,EAAG,UACd,MAAO,EACP,kBACF,CAAC,CACH,CAEA,IAAM,EAAkC,CAAC,EACzC,GAAI,EAAiB,OAAS,EAAG,CAC/B,IAAM,EAAU,2BAA2B,CAAgB,EAC3D,EAAM,KAAK,CACT,KAAM,EAAI,aAAa,SACvB,SACF,CAAC,CACH,CAEA,MAAO,CAAE,OAAM,CACjB,CACF,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./es-builtins-BHCXINQp.mjs";import{isBuiltin as t}from"node:module";const n={crypto:`Use the Web Crypto API (globalThis.crypto) instead.`,buffer:`Use Uint8Array or ArrayBuffer instead.`,fs:`File system access is not available in the Tailor Platform runtime.`,"fs/promises":`File system access is not available in the Tailor Platform runtime.`,path:`Use URL or URLPattern for path manipulation.`,http:`Use the Fetch API (globalThis.fetch) for HTTP requests instead.`,https:`Use the Fetch API (globalThis.fetch) for HTTPS requests instead.`,url:`Use the URL and URLSearchParams Web APIs instead.`,util:`Use Web Standard APIs instead.`,stream:`Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.`,"stream/web":`Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.`,events:`Use EventTarget instead.`,zlib:`Use CompressionStream and DecompressionStream Web APIs instead.`,querystring:`Use URLSearchParams instead.`,string_decoder:`Use TextDecoder instead.`};function isNodeBuiltinImport(e){return t(e)}function getNodeBuiltinMessage(e){let t=normalizeNodeBuiltinSpecifier(e),r=n[t],i=`"${e}" is not available in the Tailor Platform runtime.`;return r?`${i} ${r}`:i}function normalizeNodeBuiltinSpecifier(e){return e.startsWith(`node:`)?e.slice(5):e}const r={process:"Use `defineConfig({ env })` and the `env` argument passed into the body function instead.",Buffer:`Use Uint8Array or ArrayBuffer instead.`,global:`Use globalThis instead.`,__dirname:`File system paths are not available in the Tailor Platform runtime.`,__filename:`File system paths are not available in the Tailor Platform runtime.`,require:"Use a static `import` instead.",module:`CommonJS module semantics are not available in the Tailor Platform runtime.`,exports:`CommonJS module semantics are not available in the Tailor Platform runtime.`,setImmediate:`Use setTimeout instead.`,clearImmediate:`Use clearTimeout instead.`};function isForbiddenGlobal(t){return e.has(t)}function getForbiddenGlobalMessage(e){let t=Object.hasOwn(r,e)?r[e]:void 0,n=`"${e}" is not available in the Tailor Platform runtime.`;return t?`${n} ${t}`:n}export{isNodeBuiltinImport as i,getNodeBuiltinMessage as n,isForbiddenGlobal as r,getForbiddenGlobalMessage as t};
|
|
2
|
+
//# sourceMappingURL=node-builtins-TQHhwNzG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-builtins-TQHhwNzG.mjs","names":[],"sources":["../src/utils/node-builtins.ts"],"sourcesContent":["import { isBuiltin } from \"node:module\";\nimport { NODE_ONLY_GLOBALS } from \"#/utils/es-builtins\";\n\nconst SUGGESTIONS: Record<string, string> = {\n crypto: \"Use the Web Crypto API (globalThis.crypto) instead.\",\n buffer: \"Use Uint8Array or ArrayBuffer instead.\",\n fs: \"File system access is not available in the Tailor Platform runtime.\",\n \"fs/promises\": \"File system access is not available in the Tailor Platform runtime.\",\n path: \"Use URL or URLPattern for path manipulation.\",\n http: \"Use the Fetch API (globalThis.fetch) for HTTP requests instead.\",\n https: \"Use the Fetch API (globalThis.fetch) for HTTPS requests instead.\",\n url: \"Use the URL and URLSearchParams Web APIs instead.\",\n util: \"Use Web Standard APIs instead.\",\n stream: \"Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.\",\n \"stream/web\": \"Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.\",\n events: \"Use EventTarget instead.\",\n zlib: \"Use CompressionStream and DecompressionStream Web APIs instead.\",\n querystring: \"Use URLSearchParams instead.\",\n string_decoder: \"Use TextDecoder instead.\",\n};\n\nexport function isNodeBuiltinImport(specifier: string): boolean {\n return isBuiltin(specifier);\n}\n\nexport function getNodeBuiltinMessage(specifier: string): string {\n const bare = normalizeNodeBuiltinSpecifier(specifier);\n const suggestion = SUGGESTIONS[bare];\n const base = `\"${specifier}\" is not available in the Tailor Platform runtime.`;\n return suggestion ? `${base} ${suggestion}` : base;\n}\n\nfunction normalizeNodeBuiltinSpecifier(specifier: string): string {\n return specifier.startsWith(\"node:\") ? specifier.slice(5) : specifier;\n}\n\n// Friendly suggestions for the most common members of NODE_ONLY_GLOBALS. A\n// name in NODE_ONLY_GLOBALS without an entry here still gets flagged, just\n// with the generic message below instead of a targeted one.\nconst GLOBAL_SUGGESTIONS: Record<string, string> = {\n process:\n \"Use `defineConfig({ env })` and the `env` argument passed into the body function instead.\",\n Buffer: \"Use Uint8Array or ArrayBuffer instead.\",\n global: \"Use globalThis instead.\",\n __dirname: \"File system paths are not available in the Tailor Platform runtime.\",\n __filename: \"File system paths are not available in the Tailor Platform runtime.\",\n require: \"Use a static `import` instead.\",\n module: \"CommonJS module semantics are not available in the Tailor Platform runtime.\",\n exports: \"CommonJS module semantics are not available in the Tailor Platform runtime.\",\n setImmediate: \"Use setTimeout instead.\",\n clearImmediate: \"Use clearTimeout instead.\",\n};\n\nexport function isForbiddenGlobal(name: string): boolean {\n return NODE_ONLY_GLOBALS.has(name);\n}\n\nexport function getForbiddenGlobalMessage(name: string): string {\n const suggestion = Object.hasOwn(GLOBAL_SUGGESTIONS, name) ? GLOBAL_SUGGESTIONS[name] : undefined;\n const base = `\"${name}\" is not available in the Tailor Platform runtime.`;\n return suggestion ? `${base} ${suggestion}` : base;\n}\n"],"mappings":"uFAGA,MAAM,EAAsC,CAC1C,OAAQ,sDACR,OAAQ,yCACR,GAAI,sEACJ,cAAe,sEACf,KAAM,+CACN,KAAM,kEACN,MAAO,mEACP,IAAK,oDACL,KAAM,iCACN,OAAQ,iFACR,aAAc,iFACd,OAAQ,2BACR,KAAM,kEACN,YAAa,+BACb,eAAgB,0BAClB,EAEA,SAAgB,oBAAoB,EAA4B,CAC9D,OAAO,EAAU,CAAS,CAC5B,CAEA,SAAgB,sBAAsB,EAA2B,CAC/D,IAAM,EAAO,8BAA8B,CAAS,EAC9C,EAAa,EAAY,GACzB,EAAO,IAAI,EAAU,oDAC3B,OAAO,EAAa,GAAG,EAAK,GAAG,IAAe,CAChD,CAEA,SAAS,8BAA8B,EAA2B,CAChE,OAAO,EAAU,WAAW,OAAO,EAAI,EAAU,MAAM,CAAC,EAAI,CAC9D,CAKA,MAAM,EAA6C,CACjD,QACE,4FACF,OAAQ,yCACR,OAAQ,0BACR,UAAW,sEACX,WAAY,sEACZ,QAAS,iCACT,OAAQ,8EACR,QAAS,8EACT,aAAc,0BACd,eAAgB,2BAClB,EAEA,SAAgB,kBAAkB,EAAuB,CACvD,OAAO,EAAkB,IAAI,CAAI,CACnC,CAEA,SAAgB,0BAA0B,EAAsB,CAC9D,IAAM,EAAa,OAAO,OAAO,EAAoB,CAAI,EAAI,EAAmB,GAAQ,IAAA,GAClF,EAAO,IAAI,EAAK,oDACtB,OAAO,EAAa,GAAG,EAAK,GAAG,IAAe,CAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"../../../kysely-type-
|
|
1
|
+
import{n as e,r as t,t as n}from"../../../kysely-type-CmvAz1Xj.mjs";export{n as DEFAULT_KYSELY_TYPES_DIST_PATH,e as KyselyGeneratorID,t as kyselyTypePlugin};
|