@tailor-platform/sdk 2.6.0 → 2.8.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/{application-CmXOqTaK.mjs → application-D2E3FDfF.mjs} +27 -25
  3. package/dist/application-D2E3FDfF.mjs.map +1 -0
  4. package/dist/application-rySTKrFa.mjs +1 -0
  5. package/dist/cli/commands/deploy/config-id-injector.d.mts +16 -0
  6. package/dist/cli/commands/workspace/create.d.mts +1 -1
  7. package/dist/cli/lib.d.mts +7 -2
  8. package/dist/cli/lib.mjs +1 -1
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/cli/main.mjs +50 -1145
  11. package/dist/cli/main.mjs.map +1 -1
  12. package/dist/cli/shared/args.d.mts +7 -1
  13. package/dist/cli/shared/beta.d.mts +8 -0
  14. package/dist/cli/shared/client.d.mts +11 -1
  15. package/dist/cli/shared/config.d.mts +13 -0
  16. package/dist/cli/shared/prompt.d.mts +53 -0
  17. package/dist/cli/shared/script-executor.d.mts +1 -1
  18. package/dist/cli/shared/workspace-name.d.mts +10 -1
  19. package/dist/completion/zsh-worker.zsh +10 -206
  20. package/dist/errors-BlX4gUw5.mjs +4 -0
  21. package/dist/errors-BlX4gUw5.mjs.map +1 -0
  22. package/dist/es-builtins-BHCXINQp.mjs +2 -0
  23. package/dist/es-builtins-BHCXINQp.mjs.map +1 -0
  24. package/dist/field-column-type-QMtF6lUp.mjs +2 -0
  25. package/dist/field-column-type-QMtF6lUp.mjs.map +1 -0
  26. package/dist/{kysely-type-BTi3BMtL.mjs → kysely-type-CmvAz1Xj.mjs} +4 -4
  27. package/dist/kysely-type-CmvAz1Xj.mjs.map +1 -0
  28. package/dist/node-builtins-TQHhwNzG.mjs +2 -0
  29. package/dist/node-builtins-TQHhwNzG.mjs.map +1 -0
  30. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  31. package/dist/register-ts-hook-CQuJ7h5G.mjs +642 -0
  32. package/dist/register-ts-hook-CQuJ7h5G.mjs.map +1 -0
  33. package/dist/service-COC9whur.mjs +1 -0
  34. package/dist/{service-CLPMoj9n.mjs → service-CqbQXFDp.mjs} +2 -2
  35. package/dist/{service-CLPMoj9n.mjs.map → service-CqbQXFDp.mjs.map} +1 -1
  36. package/dist/{service-YqDsHmlK.mjs → service-DDon86tM.mjs} +2 -2
  37. package/dist/service-DDon86tM.mjs.map +1 -0
  38. package/dist/service_pb-BNxUPfP3.mjs +2 -0
  39. package/dist/service_pb-BNxUPfP3.mjs.map +1 -0
  40. package/dist/service_pb-D-xFu9Ub.mjs +1 -0
  41. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +12 -0
  42. package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +18 -1
  43. package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +130 -1
  44. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +43 -4
  45. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +9 -0
  46. package/dist/vitest/environment.mjs +1 -1
  47. package/dist/vitest/index.mjs +1 -1
  48. package/dist/vitest/mocks/file.d.mts +1 -1
  49. package/dist/workspace_resource_pb-B7S-zx4Z.mjs +2 -0
  50. package/dist/workspace_resource_pb-B7S-zx4Z.mjs.map +1 -0
  51. package/docs/cli-reference.md +0 -16
  52. package/docs/github-actions.md +12 -0
  53. package/docs/services/executor.md +17 -0
  54. package/docs/services/idp.md +1 -1
  55. package/docs/services/resolver.md +1 -1
  56. package/docs/services/tailordb-migration.md +12 -0
  57. package/docs/services/tailordb.md +6 -2
  58. package/docs/services/workflow.md +1 -1
  59. package/package.json +15 -17
  60. package/dist/application-CNeOcaLc.mjs +0 -1
  61. package/dist/application-CmXOqTaK.mjs.map +0 -1
  62. package/dist/errors-DLsQ_-ol.mjs +0 -2
  63. package/dist/errors-DLsQ_-ol.mjs.map +0 -1
  64. package/dist/es-builtins-n3wBv4Sv.mjs +0 -2
  65. package/dist/es-builtins-n3wBv4Sv.mjs.map +0 -1
  66. package/dist/kysely-type-BTi3BMtL.mjs.map +0 -1
  67. package/dist/node-builtins-oBl7EbyV.mjs +0 -2
  68. package/dist/node-builtins-oBl7EbyV.mjs.map +0 -1
  69. package/dist/register-ts-hook-oDA2JLp2.mjs +0 -640
  70. package/dist/register-ts-hook-oDA2JLp2.mjs.map +0 -1
  71. package/dist/service-D7iXk0BT.mjs +0 -1
  72. package/dist/service-YqDsHmlK.mjs.map +0 -1
  73. package/dist/service_pb-DGKCLuAs.mjs +0 -2
  74. package/dist/service_pb-DGKCLuAs.mjs.map +0 -1
  75. package/dist/service_pb-_aeFE-Nv.mjs +0 -1
  76. package/dist/workspace_resource_pb--GeYQPXu.mjs +0 -2
  77. package/dist/workspace_resource_pb--GeYQPXu.mjs.map +0 -1
  78. package/docs/cli/setup.md +0 -210
@@ -1,2 +0,0 @@
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}`),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};
2
- //# sourceMappingURL=errors-DLsQ_-ol.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-DLsQ_-ol.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}`);\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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AAY,CAAK,EAC/B,CACT,CAOA,SAAgB,WAAW,EAAmC,CAC5D,OAAO,aAAiB,OAAS,EAAM,OAAS,UAClD,CAOA,SAAgB,QAAQ,EAAuB,CAC7C,OAAO,aAAiB,MAAQ,EAAY,MAAM,OAAO,CAAK,CAAC,CACjE,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"}
@@ -1,2 +0,0 @@
1
- import*as e from"globals";const t=e.default??e,n=new Set([...Object.keys(t.builtin??{}),...Object.keys(t[`shared-node-browser`]??{})]);export{n as t};
2
- //# sourceMappingURL=es-builtins-n3wBv4Sv.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"es-builtins-n3wBv4Sv.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};\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"],"mappings":"0BAOA,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely-type-BTi3BMtL.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 {\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 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: 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 // 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 (\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":"6CAoBA,SAAS,YAAY,EAAwC,CAC3D,IAAM,EAAgB,EAAY,cAUlC,OARI,GAAiB,MAAM,QAAQ,CAAa,EACv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:`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(t){return e(t)}function getNodeBuiltinMessage(e){let n=normalizeNodeBuiltinSpecifier(e),r=t[n],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}export{isNodeBuiltinImport as n,getNodeBuiltinMessage as t};
2
- //# sourceMappingURL=node-builtins-oBl7EbyV.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-builtins-oBl7EbyV.mjs","names":[],"sources":["../src/utils/node-builtins.ts"],"sourcesContent":["import { isBuiltin } from \"node:module\";\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"],"mappings":"wCAEA,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"}