{"version":3,"file":"kysely-type-B_oA8D1k.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/pglite-schema.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  type UsedUtilityTypes,\n} from \"./types\";\nimport type { TailorDBType } from \"#/parser/service/tailordb/types\";\n\ntype FieldTypeResult = {\n  type: string;\n  usedUtilityTypes: UsedUtilityTypes;\n};\n\nfunction emptyUsedUtilityTypes(): UsedUtilityTypes {\n  return { Timestamp: false, Serial: false, ObjectColumnType: false, ArrayColumnType: false };\n}\n\nfunction mergeUsedUtilityTypes(a: UsedUtilityTypes, b: UsedUtilityTypes): UsedUtilityTypes {\n  return {\n    Timestamp: a.Timestamp || b.Timestamp,\n    Serial: a.Serial || b.Serial,\n    ObjectColumnType: a.ObjectColumnType || b.ObjectColumnType,\n    ArrayColumnType: a.ArrayColumnType || b.ArrayColumnType,\n  };\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: emptyUsedUtilityTypes(),\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) => mergeUsedUtilityTypes(acc, result.usedUtilityTypes),\n    emptyUsedUtilityTypes(),\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 {\n      type: `ObjectColumnType<${obj}>`,\n      usedUtilityTypes: { ...aggregatedUtilityTypes, ObjectColumnType: true },\n    };\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 = emptyUsedUtilityTypes();\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      usedUtilityTypes.ArrayColumnType = true;\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) => mergeUsedUtilityTypes(acc, result.usedUtilityTypes),\n    emptyUsedUtilityTypes(),\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\n    .flatMap((ns) => ns.types)\n    .reduce(\n      (acc, type) => mergeUsedUtilityTypes(acc, type.usedUtilityTypes),\n      emptyUsedUtilityTypes(),\n    );\n\n  const utilityTypeImports: string[] = [\"type Generated\"];\n  if (globalUsedUtilityTypes.Timestamp) {\n    utilityTypeImports.push(\"type Timestamp\");\n  }\n  if (globalUsedUtilityTypes.ObjectColumnType) {\n    utilityTypeImports.push(\"type ObjectColumnType\");\n  }\n  if (globalUsedUtilityTypes.ArrayColumnType) {\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 { generatePgliteSchemaModule, type DDLTableConfig } from \"#/utils/tailordb-ddl\";\nimport type { TailorDBType } from \"#/parser/service/tailordb/types\";\n\n/** Tables of one namespace, as the schema module groups them. */\nexport interface PGliteSchemaNamespace {\n  namespace: string;\n  tables: Record<string, TailorDBType>;\n}\n\n/**\n * Reduce parsed tables to what the DDL generator reads.\n * @param tables - Parsed TailorDB tables keyed by name\n * @returns DDL table configs in the same order\n */\nexport function toDDLTables(tables: Record<string, TailorDBType>): DDLTableConfig[] {\n  return Object.values(tables).map((type) => ({\n    name: type.name,\n    fields: Object.fromEntries(\n      Object.entries(type.fields).map(([fieldName, field]) => [fieldName, field.config]),\n    ),\n    indexes: type.indexes,\n  }));\n}\n\n/**\n * Render the module that exports each namespace's `CREATE TABLE` script for\n * `pglite.exec()`.\n * @param namespaces - Namespaces with their parsed tables\n * @returns TypeScript source of the schema module\n */\nexport function generatePGliteSchemaModule(namespaces: readonly PGliteSchemaNamespace[]): string {\n  return generatePgliteSchemaModule(\n    namespaces.map(({ namespace, tables }) => ({ namespace, tables: toDDLTables(tables) })),\n    { generatedBy: \"the kysely-type plugin\" },\n  );\n}\n","import { resolve } from \"pathe\";\nimport { generatePGliteSchemaModule } from \"./pglite-schema\";\nimport { 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  pgliteSchemaPath?: 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 * @param options.pgliteSchemaPath - Output file path for the PGlite `CREATE TABLE` script module; omit to skip it\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 { distPath, pgliteSchemaPath } = ctx.pluginConfig;\n      if (pgliteSchemaPath && resolve(distPath) === resolve(pgliteSchemaPath)) {\n        throw new Error(\"distPath and pgliteSchemaPath must resolve to different files.\");\n      }\n\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        allNamespaceData.push({\n          namespace: ns.namespace,\n          types: typeMetadataList,\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        if (ctx.pluginConfig.pgliteSchemaPath) {\n          files.push({\n            path: ctx.pluginConfig.pgliteSchemaPath,\n            content: generatePGliteSchemaModule(\n              ctx.tailordb.filter((ns) => Object.keys(ns.tables).length > 0),\n            ),\n          });\n        }\n      }\n\n      return { files };\n    },\n  };\n}\n"],"mappings":"2IAeA,SAAS,uBAA0C,CACjD,MAAO,CAAE,UAAW,GAAO,OAAQ,GAAO,iBAAkB,GAAO,gBAAiB,EAAM,CAC5F,CAEA,SAAS,sBAAsB,EA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