@tailor-platform/sdk 1.25.4 → 1.27.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 (65) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/application-CBJFUKrU.mjs +4701 -0
  3. package/dist/application-CBJFUKrU.mjs.map +1 -0
  4. package/dist/application-WyZetOky.mjs +11 -0
  5. package/dist/cli/index.mjs +290 -32
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +350 -8
  8. package/dist/cli/lib.mjs +10 -8
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/client-C2_wgujH.mjs +6 -0
  11. package/dist/{application-91Th6tm6.mjs → client-bTbnbQbB.mjs} +24 -4795
  12. package/dist/client-bTbnbQbB.mjs.map +1 -0
  13. package/dist/configure/index.d.mts +5 -5
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/crash-report-Cot_9Esm.mjs +6 -0
  16. package/dist/crash-report-Ju8cQF-l.mjs +414 -0
  17. package/dist/crash-report-Ju8cQF-l.mjs.map +1 -0
  18. package/dist/{enum-constants-6uK0VI_s.mjs → enum-constants-D1nfn0qD.mjs} +1 -1
  19. package/dist/{enum-constants-6uK0VI_s.mjs.map → enum-constants-D1nfn0qD.mjs.map} +1 -1
  20. package/dist/{env-uBeVwE9B.d.mts → env-BuMbIknz.d.mts} +2 -2
  21. package/dist/{file-utils-2T9w20FP.mjs → file-utils-Bctuzn3x.mjs} +1 -1
  22. package/dist/{file-utils-2T9w20FP.mjs.map → file-utils-Bctuzn3x.mjs.map} +1 -1
  23. package/dist/{index-BD-K97-C.d.mts → index-B0Lrzywd.d.mts} +2 -2
  24. package/dist/{index-cZilKprY.d.mts → index-CbnLNm14.d.mts} +2 -2
  25. package/dist/{index-D1J5SfyK.d.mts → index-CyapgSFI.d.mts} +2 -2
  26. package/dist/{index-CT53egux.d.mts → index-D1AM_02Y.d.mts} +2 -2
  27. package/dist/{index-Bu12qy3m.d.mts → index-cD9sQLTh.d.mts} +15 -15
  28. package/dist/{interceptor-BPiIBTk_.mjs → interceptor-B0d_GrI5.mjs} +1 -1
  29. package/dist/{interceptor-BPiIBTk_.mjs.map → interceptor-B0d_GrI5.mjs.map} +1 -1
  30. package/dist/{kysely-type-cMNbsQ6k.mjs → kysely-type-B_IecdK9.mjs} +1 -1
  31. package/dist/{kysely-type-cMNbsQ6k.mjs.map → kysely-type-B_IecdK9.mjs.map} +1 -1
  32. package/dist/logger-CqezTedh.mjs +181 -0
  33. package/dist/logger-CqezTedh.mjs.map +1 -0
  34. package/dist/{package-json-CVUv8Y9T.mjs → package-json-D3x2nBPB.mjs} +1 -1
  35. package/dist/{package-json-CVUv8Y9T.mjs.map → package-json-D3x2nBPB.mjs.map} +1 -1
  36. package/dist/package-json-DHfTiUCS.mjs +4 -0
  37. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  38. package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
  39. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  40. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  41. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  42. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  43. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  44. package/dist/plugin/builtin/seed/index.mjs +1 -1
  45. package/dist/plugin/index.d.mts +2 -2
  46. package/dist/{plugin-zY5wvV82.d.mts → plugin-D3a0-qe0.d.mts} +20 -4
  47. package/dist/{query-kb_4EQp4.mjs → query-CgGbAmUg.mjs} +460 -361
  48. package/dist/query-CgGbAmUg.mjs.map +1 -0
  49. package/dist/{seed-CCVRLibh.mjs → seed-CWkIDWMb.mjs} +1 -1
  50. package/dist/{seed-CCVRLibh.mjs.map → seed-CWkIDWMb.mjs.map} +1 -1
  51. package/dist/{telemetry-DDQZRqHK.mjs → telemetry-BevrwWwF.mjs} +1 -1
  52. package/dist/{telemetry-0w8OupuQ.mjs → telemetry-VvNfsyEE.mjs} +2 -2
  53. package/dist/{telemetry-0w8OupuQ.mjs.map → telemetry-VvNfsyEE.mjs.map} +1 -1
  54. package/dist/utils/test/index.d.mts +2 -2
  55. package/dist/{workflow.generated-v1LXRuB6.d.mts → workflow.generated-BsgIlrH-.d.mts} +2 -2
  56. package/docs/cli/crash-report.md +107 -0
  57. package/docs/cli/setup.md +82 -0
  58. package/docs/cli-reference.md +19 -0
  59. package/docs/services/auth.md +33 -0
  60. package/docs/services/resolver.md +32 -0
  61. package/package.json +4 -4
  62. package/dist/application-91Th6tm6.mjs.map +0 -1
  63. package/dist/application-DegTCDd8.mjs +0 -9
  64. package/dist/package-json-Bj76LPsV.mjs +0 -4
  65. package/dist/query-kb_4EQp4.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { $ as TailorFieldType, B as TailorDBInstance, Ct as RecordTrigger$1, Dt as WorkflowOperation$1, Et as WebhookOperation$1, J as ArrayFieldOutput, N as UserAttributeListKey, O as AuthServiceInput, Ot as AuthInvoker$1, P as UserAttributeMap, Q as FieldOutput, St as IncomingWebhookTrigger$1, Tt as ScheduleTriggerInput, V as TailorDBType, X as FieldMetadata, Y as DefinedFieldMetadata, Z as FieldOptions, bt as GqlOperation$1, dt as AllowedValues, et as TailorAnyField, ft as AllowedValuesOutput, gt as AuthAccessTokenTrigger$1, ht as GeneratorConfig, it as output$1, k as DefinedAuth, lt as TailorUser, mt as ResolverInput, n as Plugin, nt as InferFieldsOutput, pt as Resolver, rt as JsonCompatible, tt as TailorField, vt as ExecutorInput, wt as ResolverExecutedTrigger$1, xt as IdpUserTrigger$1, yt as FunctionOperation$1 } from "./plugin-zY5wvV82.mjs";
2
- import { n as TailorEnv, r as TailorActor } from "./env-uBeVwE9B.mjs";
3
- import { g as IdpDefinitionBrand, n as AppConfig, t as RetryPolicy, y as IdPInput } from "./workflow.generated-v1LXRuB6.mjs";
1
+ import { $ as FieldOutput, A as DefinedAuth, Ct as IncomingWebhookTrigger$1, Dt as WebhookOperation$1, Et as ScheduleTriggerInput, F as UserAttributeMap, H as TailorDBType, O as AuthServiceInput, Ot as WorkflowOperation$1, P as UserAttributeListKey, Q as FieldOptions, St as IdpUserTrigger$1, Tt as ResolverExecutedTrigger$1, V as TailorDBInstance, X as DefinedFieldMetadata, Y as ArrayFieldOutput, Z as FieldMetadata, _t as AuthAccessTokenTrigger$1, at as output$1, bt as FunctionOperation$1, et as TailorFieldType, ft as AllowedValues, gt as GeneratorConfig, ht as ResolverInput, it as JsonCompatible, kt as AuthInvoker$1, mt as Resolver, n as Plugin, nt as TailorField, pt as AllowedValuesOutput, rt as InferFieldsOutput, tt as TailorAnyField, ut as TailorUser, wt as RecordTrigger$1, xt as GqlOperation$1, yt as ExecutorInput } from "./plugin-D3a0-qe0.mjs";
2
+ import { n as TailorEnv, r as TailorActor } from "./env-BuMbIknz.mjs";
3
+ import { g as IdpDefinitionBrand, n as AppConfig, t as RetryPolicy, y as IdPInput } from "./workflow.generated-BsgIlrH-.mjs";
4
4
  import * as zod from "zod";
5
5
  import { JsonPrimitive, Jsonifiable, Jsonify } from "type-fest";
6
6
  import { Client } from "@urql/core";
@@ -650,7 +650,16 @@ declare function defineConfig<const Config extends AppConfig & Record<Exclude<ke
650
650
  * @param configs - Generator configurations
651
651
  * @returns Generator configurations as given
652
652
  */
653
- declare function defineGenerators(...configs: GeneratorConfig[]): ({
653
+ declare function defineGenerators(...configs: GeneratorConfig[]): (["@tailor-platform/kysely-type", {
654
+ distPath: string;
655
+ }] | ["@tailor-platform/seed", {
656
+ distPath: string;
657
+ machineUserName?: string | undefined;
658
+ }] | ["@tailor-platform/enum-constants", {
659
+ distPath: string;
660
+ }] | ["@tailor-platform/file-utils", {
661
+ distPath: string;
662
+ }] | {
654
663
  id: string;
655
664
  description: string;
656
665
  dependencies: ("executor" | "tailordb" | "resolver")[];
@@ -660,16 +669,7 @@ declare function defineGenerators(...configs: GeneratorConfig[]): ({
660
669
  processExecutor?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
661
670
  processTailorDBNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
662
671
  processResolverNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
663
- } | ["@tailor-platform/kysely-type", {
664
- distPath: string;
665
- }] | ["@tailor-platform/seed", {
666
- distPath: string;
667
- machineUserName?: string | undefined;
668
- }] | ["@tailor-platform/enum-constants", {
669
- distPath: string;
670
- }] | ["@tailor-platform/file-utils", {
671
- distPath: string;
672
- }])[];
672
+ })[];
673
673
  /**
674
674
  * Define plugins to be used with the Tailor SDK.
675
675
  * Plugins can generate additional types, resolvers, and executors
@@ -757,4 +757,4 @@ declare namespace t {
757
757
  }
758
758
  //#endregion
759
759
  export { AuthInvoker as $, idpUserCreatedTrigger as A, WebhookOperation as B, RecordTrigger as C, authAccessTokenIssuedTrigger as D, ResolverExecutedTrigger as E, recordUpdatedTrigger as F, WORKFLOW_TEST_ENV_KEY as G, Workflow as H, resolverExecutedTrigger as I, WorkflowJobInput as J, WorkflowJob as K, FunctionOperation as L, idpUserUpdatedTrigger as M, recordCreatedTrigger as N, authAccessTokenRefreshedTrigger as O, recordDeletedTrigger as P, createResolver as Q, GqlOperation as R, RecordDeletedArgs as S, ResolverExecutedArgs as T, WorkflowConfig as U, WorkflowOperation as V, createWorkflow as W, createWorkflowJob as X, WorkflowJobOutput as Y, QueryType as Z, AuthAccessTokenArgs as _, defineGenerators as a, IdpUserTrigger as b, createExecutor as c, IncomingWebhookRequest as d, defineAuth as et, IncomingWebhookTrigger as f, scheduleTrigger as g, ScheduleTrigger as h, defineConfig as i, idpUserDeletedTrigger as j, authAccessTokenRevokedTrigger as k, Trigger as l, ScheduleArgs as m, output as n, definePlugins as o, incomingWebhookTrigger as p, WorkflowJobContext as q, t as r, defineIdp as s, infer as t, IncomingWebhookArgs as u, AuthAccessTokenTrigger as v, RecordUpdatedArgs as w, RecordCreatedArgs as x, IdpUserArgs as y, Operation as z };
760
- //# sourceMappingURL=index-Bu12qy3m.d.mts.map
760
+ //# sourceMappingURL=index-cD9sQLTh.d.mts.map
@@ -31,4 +31,4 @@ function createTracingInterceptor() {
31
31
 
32
32
  //#endregion
33
33
  export { createTracingInterceptor };
34
- //# sourceMappingURL=interceptor-BPiIBTk_.mjs.map
34
+ //# sourceMappingURL=interceptor-B0d_GrI5.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"interceptor-BPiIBTk_.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,aAAa,CAE9B,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
+ {"version":3,"file":"interceptor-B0d_GrI5.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,aAAa,CAE9B,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"}
@@ -257,4 +257,4 @@ function kyselyTypePlugin(options) {
257
257
 
258
258
  //#endregion
259
259
  export { kyselyTypePlugin as n, KyselyGeneratorID as t };
260
- //# sourceMappingURL=kysely-type-cMNbsQ6k.mjs.map
260
+ //# sourceMappingURL=kysely-type-B_IecdK9.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"kysely-type-cMNbsQ6k.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"multiline-ts\";\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, nestedOperatorFieldConfig]) => ({\n fieldName,\n ...generateFieldType(nestedOperatorFieldConfig),\n }));\n\n const fieldTypes = fieldResults.map((result) => `${result.fieldName}: ${result.type}`);\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 type = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n return { type, 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 let finalType = baseTypeResult.type;\n if (isArray) {\n // Wrap enum types in parentheses before adding array suffix\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\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 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 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\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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GjC,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"}
1
+ {"version":3,"file":"kysely-type-B_IecdK9.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"multiline-ts\";\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, nestedOperatorFieldConfig]) => ({\n fieldName,\n ...generateFieldType(nestedOperatorFieldConfig),\n }));\n\n const fieldTypes = fieldResults.map((result) => `${result.fieldName}: ${result.type}`);\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 type = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n return { type, 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 let finalType = baseTypeResult.type;\n if (isArray) {\n // Wrap enum types in parentheses before adding array suffix\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\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 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 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\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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B,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,181 @@
1
+ import { formatWithOptions } from "node:util";
2
+ import chalk from "chalk";
3
+ import { formatDistanceToNowStrict } from "date-fns";
4
+ import { getBorderCharacters, table } from "table";
5
+
6
+ //#region src/cli/shared/logger.ts
7
+ /**
8
+ * Error thrown when a prompt is attempted in a CI environment
9
+ */
10
+ var CIPromptError = class extends Error {
11
+ constructor(message) {
12
+ super(message ?? "Interactive prompts are not available in CI environments. Use --yes flag to skip confirmation prompts.");
13
+ this.name = "CIPromptError";
14
+ }
15
+ };
16
+ /**
17
+ * Semantic style functions for inline text styling
18
+ */
19
+ const styles = {
20
+ success: chalk.green,
21
+ error: chalk.red,
22
+ warning: chalk.yellow,
23
+ info: chalk.cyan,
24
+ create: chalk.green,
25
+ update: chalk.yellow,
26
+ delete: chalk.red,
27
+ unchanged: chalk.gray,
28
+ bold: chalk.bold,
29
+ dim: chalk.gray,
30
+ highlight: chalk.cyanBright,
31
+ successBright: chalk.greenBright,
32
+ errorBright: chalk.redBright,
33
+ resourceType: chalk.bold,
34
+ resourceName: chalk.cyan,
35
+ path: chalk.cyan,
36
+ value: chalk.white,
37
+ placeholder: chalk.gray.italic
38
+ };
39
+ /**
40
+ * Standardized symbols for CLI output
41
+ */
42
+ const symbols = {
43
+ success: chalk.green("✓"),
44
+ error: chalk.red("✖"),
45
+ warning: chalk.yellow("⚠"),
46
+ info: chalk.cyan("i"),
47
+ create: chalk.green("+"),
48
+ update: chalk.yellow("~"),
49
+ delete: chalk.red("-"),
50
+ replace: chalk.magenta("±"),
51
+ bullet: chalk.gray("•"),
52
+ arrow: chalk.gray("→")
53
+ };
54
+ let _jsonMode = false;
55
+ const TYPE_ICONS = {
56
+ info: "ℹ",
57
+ success: "✔",
58
+ warn: "⚠",
59
+ error: "✖",
60
+ debug: "⚙",
61
+ trace: "→",
62
+ log: ""
63
+ };
64
+ const TYPE_COLORS = {
65
+ info: chalk.cyan,
66
+ success: chalk.green,
67
+ warn: chalk.yellow,
68
+ error: chalk.red,
69
+ debug: chalk.gray,
70
+ trace: chalk.gray,
71
+ log: (text) => text
72
+ };
73
+ /**
74
+ * Formats a log line with the appropriate prefix and indentation
75
+ * @param opts - Formatting options
76
+ * @returns Formatted log line
77
+ */
78
+ function formatLogLine(opts) {
79
+ const { mode, indent, type, message, timestamp } = opts;
80
+ const indentPrefix = indent > 0 ? " ".repeat(indent) : "";
81
+ const colorFn = TYPE_COLORS[type] || ((text) => text);
82
+ if (mode === "plain") return `${indentPrefix}${colorFn(message)}\n`;
83
+ const icon = TYPE_ICONS[type] || "";
84
+ const coloredOutput = colorFn(`${icon ? `${icon} ` : ""}${message}`);
85
+ return `${indentPrefix}${timestamp ?? ""}${coloredOutput}\n`;
86
+ }
87
+ /**
88
+ * Writes a formatted log line to stderr.
89
+ * @param type - Log type (info, success, warn, error, log)
90
+ * @param message - Log message
91
+ * @param opts - Log options (mode and indent)
92
+ */
93
+ function writeLog(type, message, opts) {
94
+ const mode = opts?.mode ?? "default";
95
+ const output = formatLogLine({
96
+ mode,
97
+ indent: opts?.indent ?? 0,
98
+ type,
99
+ message: formatWithOptions({ breakLength: process.stdout.columns || 80 }, message),
100
+ timestamp: mode === "stream" ? `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ` : ""
101
+ });
102
+ process.stderr.write(output);
103
+ }
104
+ const logger = {
105
+ get jsonMode() {
106
+ return _jsonMode;
107
+ },
108
+ set jsonMode(value) {
109
+ _jsonMode = value;
110
+ },
111
+ info(message, opts) {
112
+ writeLog("info", message, opts);
113
+ },
114
+ success(message, opts) {
115
+ writeLog("success", message, opts);
116
+ },
117
+ warn(message, opts) {
118
+ writeLog("warn", message, opts);
119
+ },
120
+ error(message, opts) {
121
+ writeLog("error", message, opts);
122
+ },
123
+ log(message) {
124
+ writeLog("log", message, { mode: "plain" });
125
+ },
126
+ newline() {
127
+ process.stderr.write("\n");
128
+ },
129
+ debug(message) {
130
+ if (process.env.DEBUG === "true") writeLog("log", styles.dim(message), { mode: "plain" });
131
+ },
132
+ out(data, options) {
133
+ if (typeof data === "string") {
134
+ process.stdout.write(data.endsWith("\n") ? data : data + "\n");
135
+ return;
136
+ }
137
+ if (this.jsonMode) {
138
+ console.log(JSON.stringify(data));
139
+ return;
140
+ }
141
+ const display = options?.display;
142
+ const formatValue = (value, pretty = false) => {
143
+ if (options?.showNull && value === null) return "NULL";
144
+ if (value === null || value === void 0) return "N/A";
145
+ if (value instanceof Date) return formatDistanceToNowStrict(value, { addSuffix: true });
146
+ if (typeof value === "object") return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
147
+ return String(value);
148
+ };
149
+ const isExcluded = (key) => {
150
+ return display !== void 0 && key in display && display[key] === null;
151
+ };
152
+ const transformValue = (key, value, item, pretty = false) => {
153
+ if (display && key in display) {
154
+ const transformer = display[key];
155
+ if (transformer) return transformer(value, item);
156
+ }
157
+ return formatValue(value, pretty);
158
+ };
159
+ if (!Array.isArray(data)) {
160
+ const t = table(Object.entries(data).filter(([key]) => !isExcluded(key)).map(([key, value]) => [key, transformValue(key, value, data, true)]), {
161
+ singleLine: false,
162
+ border: getBorderCharacters("norc")
163
+ });
164
+ process.stdout.write(t);
165
+ return;
166
+ }
167
+ if (data.length === 0) return;
168
+ const headers = Array.from(new Set(data.flatMap((item) => Object.keys(item)))).filter((h) => !isExcluded(h));
169
+ const t = table([headers, ...data.map((item) => headers.map((header) => transformValue(header, item[header], item)))], {
170
+ border: getBorderCharacters("norc"),
171
+ drawHorizontalLine: (lineIndex, rowCount) => {
172
+ return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
173
+ }
174
+ });
175
+ process.stdout.write(t);
176
+ }
177
+ };
178
+
179
+ //#endregion
180
+ export { symbols as i, logger as n, styles as r, CIPromptError as t };
181
+ //# sourceMappingURL=logger-CqezTedh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-CqezTedh.mjs","names":[],"sources":["../src/cli/shared/logger.ts"],"sourcesContent":["import { formatWithOptions, type InspectOptions } from \"node:util\";\nimport chalk from \"chalk\";\nimport { formatDistanceToNowStrict } from \"date-fns\";\nimport { getBorderCharacters, table } from \"table\";\n\n/**\n * Error thrown when a prompt is attempted in a CI environment\n */\nexport class CIPromptError extends Error {\n constructor(message?: string) {\n super(\n message ??\n \"Interactive prompts are not available in CI environments. Use --yes flag to skip confirmation prompts.\",\n );\n this.name = \"CIPromptError\";\n }\n}\n\n/**\n * Semantic style functions for inline text styling\n */\nexport const styles = {\n // Status colors\n success: chalk.green,\n error: chalk.red,\n warning: chalk.yellow,\n info: chalk.cyan,\n\n // Action colors (for change sets)\n create: chalk.green,\n update: chalk.yellow,\n delete: chalk.red,\n unchanged: chalk.gray,\n\n // Emphasis\n bold: chalk.bold,\n dim: chalk.gray,\n highlight: chalk.cyanBright,\n successBright: chalk.greenBright,\n errorBright: chalk.redBright,\n\n // Resource types\n resourceType: chalk.bold,\n resourceName: chalk.cyan,\n\n // File paths\n path: chalk.cyan,\n\n // Values\n value: chalk.white,\n placeholder: chalk.gray.italic,\n};\n\n/**\n * Standardized symbols for CLI output\n */\nexport const symbols = {\n success: chalk.green(\"\\u2713\"),\n error: chalk.red(\"\\u2716\"),\n warning: chalk.yellow(\"\\u26a0\"),\n info: chalk.cyan(\"i\"),\n create: chalk.green(\"+\"),\n update: chalk.yellow(\"~\"),\n delete: chalk.red(\"-\"),\n replace: chalk.magenta(\"\\u00b1\"),\n bullet: chalk.gray(\"\\u2022\"),\n arrow: chalk.gray(\"\\u2192\"),\n};\n\n/**\n * Log output modes\n */\nexport type LogMode = \"default\" | \"stream\" | \"plain\";\n\nexport interface LogOptions {\n /** Output mode (default: \"default\") */\n mode?: LogMode;\n /** Number of spaces to indent the entire line (default: 0) */\n indent?: number;\n}\n\n/** Field transformer function. null excludes the field from table output. */\nexport type FieldTransformer = ((value: unknown, item: object) => string) | null;\n\nexport interface OutOptions {\n /** Table display field transform/exclude settings. Only applied in table mode (not JSON). */\n display?: Record<string, FieldTransformer>;\n\n /** Show null values in table output (default: false) */\n showNull?: boolean;\n}\n\n// In JSON mode, all logs go to stderr to keep stdout clean for JSON data\nlet _jsonMode = false;\n\n// Type icons for log output\nconst TYPE_ICONS: Record<string, string> = {\n info: \"ℹ\",\n success: \"✔\",\n warn: \"⚠\",\n error: \"✖\",\n debug: \"⚙\",\n trace: \"→\",\n log: \"\",\n};\n\n// Color functions for icon and message text\nconst TYPE_COLORS: Record<string, (text: string) => string> = {\n info: chalk.cyan,\n success: chalk.green,\n warn: chalk.yellow,\n error: chalk.red,\n debug: chalk.gray,\n trace: chalk.gray,\n log: (text) => text,\n};\n\ninterface FormatLogLineOptions {\n mode: string;\n indent: number;\n type: string;\n message: string;\n timestamp?: string;\n}\n\n/**\n * Formats a log line with the appropriate prefix and indentation\n * @param opts - Formatting options\n * @returns Formatted log line\n */\nexport function formatLogLine(opts: FormatLogLineOptions): string {\n const { mode, indent, type, message, timestamp } = opts;\n const indentPrefix = indent > 0 ? \" \".repeat(indent) : \"\";\n const colorFn = TYPE_COLORS[type] || ((text: string) => text);\n\n // Plain mode: color only, no icon, no timestamp\n if (mode === \"plain\") {\n return `${indentPrefix}${colorFn(message)}\\n`;\n }\n\n // Default/Stream mode: with icon and color\n const icon = TYPE_ICONS[type] || \"\";\n const prefix = icon ? `${icon} ` : \"\";\n const coloredOutput = colorFn(`${prefix}${message}`);\n const timestampPrefix = timestamp ?? \"\";\n\n return `${indentPrefix}${timestampPrefix}${coloredOutput}\\n`;\n}\n\n/**\n * Writes a formatted log line to stderr.\n * @param type - Log type (info, success, warn, error, log)\n * @param message - Log message\n * @param opts - Log options (mode and indent)\n */\nfunction writeLog(type: string, message: string, opts?: LogOptions): void {\n const mode = opts?.mode ?? \"default\";\n const indent = opts?.indent ?? 0;\n const inspectOpts: InspectOptions = {\n breakLength: process.stdout.columns || 80,\n };\n const formattedMessage = formatWithOptions(inspectOpts, message);\n const timestamp = mode === \"stream\" ? `${new Date().toLocaleTimeString()} ` : \"\";\n const output = formatLogLine({ mode, indent, type, message: formattedMessage, timestamp });\n process.stderr.write(output);\n}\n\nexport const logger = {\n get jsonMode(): boolean {\n return _jsonMode;\n },\n set jsonMode(value: boolean) {\n _jsonMode = value;\n },\n\n info(message: string, opts?: LogOptions): void {\n writeLog(\"info\", message, opts);\n },\n\n success(message: string, opts?: LogOptions): void {\n writeLog(\"success\", message, opts);\n },\n\n warn(message: string, opts?: LogOptions): void {\n writeLog(\"warn\", message, opts);\n },\n\n error(message: string, opts?: LogOptions): void {\n writeLog(\"error\", message, opts);\n },\n\n log(message: string): void {\n writeLog(\"log\", message, { mode: \"plain\" });\n },\n\n newline(): void {\n process.stderr.write(\"\\n\");\n },\n\n debug(message: string): void {\n if (process.env.DEBUG === \"true\") {\n writeLog(\"log\", styles.dim(message), { mode: \"plain\" });\n }\n },\n\n out(data: string | object | object[], options?: OutOptions): void {\n if (typeof data === \"string\") {\n process.stdout.write(data.endsWith(\"\\n\") ? data : data + \"\\n\");\n return;\n }\n\n if (this.jsonMode) {\n // eslint-disable-next-line no-restricted-syntax\n console.log(JSON.stringify(data));\n return;\n }\n\n const display = options?.display;\n\n // Helper to format a value for table display\n const formatValue = (value: unknown, pretty = false): string => {\n if (options?.showNull && value === null) return \"NULL\";\n if (value === null || value === undefined) return \"N/A\";\n if (value instanceof Date) {\n return formatDistanceToNowStrict(value, { addSuffix: true });\n }\n if (typeof value === \"object\") {\n return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);\n }\n return String(value);\n };\n\n // Helper to check if field should be excluded\n const isExcluded = (key: string): boolean => {\n return display !== undefined && key in display && display[key] === null;\n };\n\n // Helper to apply transformer or default formatting\n const transformValue = (key: string, value: unknown, item: object, pretty = false): string => {\n if (display && key in display) {\n const transformer = display[key];\n if (transformer) {\n return transformer(value, item);\n }\n }\n return formatValue(value, pretty);\n };\n\n if (!Array.isArray(data)) {\n const entries = Object.entries(data).filter(([key]) => !isExcluded(key));\n const formattedEntries = entries.map(([key, value]) => [\n key,\n transformValue(key, value, data, true),\n ]);\n const t = table(formattedEntries, {\n singleLine: false,\n border: getBorderCharacters(\"norc\"),\n });\n process.stdout.write(t);\n return;\n }\n\n if (data.length === 0) {\n return;\n }\n\n const allHeaders = Array.from(new Set(data.flatMap((item) => Object.keys(item))));\n const headers = allHeaders.filter((h) => !isExcluded(h));\n const rows = data.map((item) =>\n headers.map((header) =>\n transformValue(header, (item as Record<string, unknown>)[header], item),\n ),\n );\n\n const t = table([headers, ...rows], {\n border: getBorderCharacters(\"norc\"),\n drawHorizontalLine: (lineIndex, rowCount) => {\n return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;\n },\n });\n process.stdout.write(t);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,IAAa,gBAAb,cAAmC,MAAM;CACvC,YAAY,SAAkB;AAC5B,QACE,WACE,yGACH;AACD,OAAK,OAAO;;;;;;AAOhB,MAAa,SAAS;CAEpB,SAAS,MAAM;CACf,OAAO,MAAM;CACb,SAAS,MAAM;CACf,MAAM,MAAM;CAGZ,QAAQ,MAAM;CACd,QAAQ,MAAM;CACd,QAAQ,MAAM;CACd,WAAW,MAAM;CAGjB,MAAM,MAAM;CACZ,KAAK,MAAM;CACX,WAAW,MAAM;CACjB,eAAe,MAAM;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v8Y9T.mjs.map
17
+ //# sourceMappingURL=package-json-D3x2nBPB.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-json-CVUv8Y9T.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
+ {"version":3,"file":"package-json-D3x2nBPB.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"}
@@ -0,0 +1,4 @@
1
+ import "./chunk-Cz-A8uMR.mjs";
2
+ import { t as readPackageJson } from "./package-json-D3x2nBPB.mjs";
3
+
4
+ export { readPackageJson };
@@ -1,2 +1,2 @@
1
- import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-cZilKprY.mjs";
1
+ import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-CbnLNm14.mjs";
2
2
  export { EnumConstantsGeneratorID, enumConstantsPlugin };
@@ -1,4 +1,4 @@
1
1
  import "../../../chunk-Cz-A8uMR.mjs";
2
- import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../enum-constants-6uK0VI_s.mjs";
2
+ import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../enum-constants-D1nfn0qD.mjs";
3
3
 
4
4
  export { EnumConstantsGeneratorID, enumConstantsPlugin };
@@ -1,2 +1,2 @@
1
- import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-BD-K97-C.mjs";
1
+ import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-B0Lrzywd.mjs";
2
2
  export { FileUtilsGeneratorID, fileUtilsPlugin };
@@ -1,4 +1,4 @@
1
1
  import "../../../chunk-Cz-A8uMR.mjs";
2
- import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../file-utils-2T9w20FP.mjs";
2
+ import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../file-utils-Bctuzn3x.mjs";
3
3
 
4
4
  export { FileUtilsGeneratorID, fileUtilsPlugin };
@@ -1,2 +1,2 @@
1
- import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-D1J5SfyK.mjs";
1
+ import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-CyapgSFI.mjs";
2
2
  export { KyselyGeneratorID, kyselyTypePlugin };
@@ -1,4 +1,4 @@
1
1
  import "../../../chunk-Cz-A8uMR.mjs";
2
- import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../kysely-type-cMNbsQ6k.mjs";
2
+ import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../kysely-type-B_IecdK9.mjs";
3
3
 
4
4
  export { KyselyGeneratorID, kyselyTypePlugin };
@@ -1,2 +1,2 @@
1
- import { n as seedPlugin, t as SeedGeneratorID } from "../../../index-CT53egux.mjs";
1
+ import { n as seedPlugin, t as SeedGeneratorID } from "../../../index-D1AM_02Y.mjs";
2
2
  export { SeedGeneratorID, seedPlugin };
@@ -1,4 +1,4 @@
1
1
  import "../../../chunk-Cz-A8uMR.mjs";
2
- import { n as seedPlugin, t as SeedGeneratorID } from "../../../seed-CCVRLibh.mjs";
2
+ import { n as seedPlugin, t as SeedGeneratorID } from "../../../seed-CWkIDWMb.mjs";
3
3
 
4
4
  export { SeedGeneratorID, seedPlugin };
@@ -1,5 +1,5 @@
1
- import { R as TailorAnyDBType } from "../plugin-zY5wvV82.mjs";
2
- import { n as TailorEnv, r as TailorActor } from "../env-uBeVwE9B.mjs";
1
+ import { z as TailorAnyDBType } from "../plugin-D3a0-qe0.mjs";
2
+ import { n as TailorEnv, r as TailorActor } from "../env-BuMbIknz.mjs";
3
3
 
4
4
  //#region src/plugin/with-context.d.ts
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { StandardSchemaV1 } from "@standard-schema/spec";
3
- import { IsAny, NonEmptyObject } from "type-fest";
3
+ import { IsAny, JsonObject, NonEmptyObject } from "type-fest";
4
4
 
5
5
  //#region src/parser/generator-config/index.d.ts
6
6
  declare const BaseGeneratorConfigSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"@tailor-platform/kysely-type">, z.ZodObject<{
@@ -379,7 +379,11 @@ type Resolver = {
379
379
  input?: {
380
380
  [x: string]: any;
381
381
  } | undefined; /** Enable publishing events from this resolver */
382
- publishEvents?: boolean | undefined;
382
+ publishEvents?: boolean | undefined; /** Machine user to execute this resolver as */
383
+ authInvoker?: {
384
+ namespace: string;
385
+ machineUserName: string;
386
+ } | undefined;
383
387
  };
384
388
  type ResolverInput = Resolver;
385
389
  //#endregion
@@ -1580,7 +1584,19 @@ type MachineUser<User extends TailorDBInstance, AttributeMap extends UserAttribu
1580
1584
  } : {
1581
1585
  attributeList: AttributeListToTuple<User, AttributeList>;
1582
1586
  });
1587
+ type BeforeLoginHookArgs = {
1588
+ claims: JsonObject;
1589
+ idpConfigName: string;
1590
+ };
1591
+ type BeforeLoginHook<MachineUserNames extends string> = {
1592
+ handler(args: BeforeLoginHookArgs): Promise<void>;
1593
+ invoker: NoInfer<MachineUserNames>;
1594
+ };
1595
+ type AuthHooks<MachineUserNames extends string> = {
1596
+ beforeLogin?: BeforeLoginHook<MachineUserNames>;
1597
+ };
1583
1598
  type AuthServiceInput<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined> = {
1599
+ hooks?: AuthHooks<MachineUserNames>;
1584
1600
  userProfile?: UserProfile<User, AttributeMap, AttributeList>;
1585
1601
  machineUserAttributes?: MachineUserAttributes;
1586
1602
  machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap, AttributeList, MachineUserAttributes>>;
@@ -2007,5 +2023,5 @@ interface Plugin<TypeConfig = unknown, PluginConfig = unknown> {
2007
2023
  onExecutorReady?(context: ExecutorReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
2008
2024
  }
2009
2025
  //#endregion
2010
- export { TailorFieldType as $, OAuth2ClientGrantType as A, IDToken as At, TailorDBInstance as B, TenantProvider as Bt, TailorDBType as C, RecordTrigger as Ct, AuthOwnConfig as D, WorkflowOperation as Dt, AuthExternalConfig as E, WebhookOperation as Et, UsernameFieldKey as F, SCIMAttribute as Ft, TailorTypePermission as G, db as H, ValueOperand as I, SCIMAttributeMapping as It, ArrayFieldOutput as J, unsafeAllowAllGqlPermission as K, TailorAnyDBField as L, SCIMAuthorization as Lt, UserAttributeKey as M, OAuth2ClientInput as Mt, UserAttributeListKey as N, OIDC as Nt, AuthServiceInput as O, AuthInvoker as Ot, UserAttributeMap as P, SAML as Pt, FieldOutput$1 as Q, TailorAnyDBType as R, SCIMConfig as Rt, TailorDBServiceInput as S, IncomingWebhookTrigger as St, AuthConfig as T, ScheduleTriggerInput as Tt, PermissionCondition as U, TailorDBType$1 as V, TailorTypeGqlPermission as W, FieldMetadata as X, DefinedFieldMetadata as Y, FieldOptions as Z, GeneratorResult as _, Executor as _t, PluginExecutorContext as a, AttributeList as at, TailorDBNamespaceData as b, GqlOperation as bt, PluginGeneratedExecutorWithFile as c, InferredAttributeMap as ct, PluginNamespaceProcessContext as d, AllowedValues as dt, TailorAnyField as et, PluginOutput as f, AllowedValuesOutput as ft, ExecutorReadyContext as g, AuthAccessTokenTrigger as gt, TypePluginOutput as h, GeneratorConfig as ht, PluginConfigs as i, output as it, SCIMAttributeType as j, IdProvider as jt, DefinedAuth as k, BuiltinIdP as kt, PluginGeneratedResolver as l, TailorUser as lt, TailorDBTypeForPlugin as m, ResolverInput as mt, Plugin as n, InferFieldsOutput as nt, PluginExecutorContextBase as o, AttributeMap as ot, PluginProcessContext as p, Resolver as pt, unsafeAllowAllTypePermission as q, PluginAttachment as r, JsonCompatible as rt, PluginGeneratedExecutor as s, InferredAttributeList as st, NamespacePluginOutput as t, TailorField as tt, PluginGeneratedType as u, unauthenticatedTailorUser as ut, ResolverNamespaceData as v, ExecutorInput as vt, TypeSourceInfoEntry as w, ResolverExecutedTrigger as wt, TailorDBReadyContext as x, IdpUserTrigger as xt, ResolverReadyContext as y, FunctionOperation as yt, TailorDBField as z, SCIMResource as zt };
2011
- //# sourceMappingURL=plugin-zY5wvV82.d.mts.map
2026
+ export { FieldOutput$1 as $, DefinedAuth as A, BuiltinIdP as At, TailorDBField as B, SCIMResource as Bt, TailorDBType as C, IncomingWebhookTrigger as Ct, AuthOwnConfig as D, WebhookOperation as Dt, AuthExternalConfig as E, ScheduleTriggerInput as Et, UserAttributeMap as F, SAML as Ft, TailorTypeGqlPermission as G, TailorDBType$1 as H, UsernameFieldKey as I, SCIMAttribute as It, unsafeAllowAllTypePermission as J, TailorTypePermission as K, ValueOperand as L, SCIMAttributeMapping as Lt, SCIMAttributeType as M, IdProvider as Mt, UserAttributeKey as N, OAuth2ClientInput as Nt, AuthServiceInput as O, WorkflowOperation as Ot, UserAttributeListKey as P, OIDC as Pt, FieldOptions as Q, TailorAnyDBField as R, SCIMAuthorization as Rt, TailorDBServiceInput as S, IdpUserTrigger as St, AuthConfig as T, ResolverExecutedTrigger as Tt, db as U, TailorDBInstance as V, TenantProvider as Vt, PermissionCondition as W, DefinedFieldMetadata as X, ArrayFieldOutput as Y, FieldMetadata as Z, GeneratorResult as _, AuthAccessTokenTrigger as _t, PluginExecutorContext as a, output as at, TailorDBNamespaceData as b, FunctionOperation as bt, PluginGeneratedExecutorWithFile as c, InferredAttributeList as ct, PluginNamespaceProcessContext as d, unauthenticatedTailorUser as dt, TailorFieldType as et, PluginOutput as f, AllowedValues as ft, ExecutorReadyContext as g, GeneratorConfig as gt, TypePluginOutput as h, ResolverInput as ht, PluginConfigs as i, JsonCompatible as it, OAuth2ClientGrantType as j, IDToken as jt, BeforeLoginHookArgs as k, AuthInvoker as kt, PluginGeneratedResolver as l, InferredAttributeMap as lt, TailorDBTypeForPlugin as m, Resolver as mt, Plugin as n, TailorField as nt, PluginExecutorContextBase as o, AttributeList as ot, PluginProcessContext as p, AllowedValuesOutput as pt, unsafeAllowAllGqlPermission as q, PluginAttachment as r, InferFieldsOutput as rt, PluginGeneratedExecutor as s, AttributeMap as st, NamespacePluginOutput as t, TailorAnyField as tt, PluginGeneratedType as u, TailorUser as ut, ResolverNamespaceData as v, Executor as vt, TypeSourceInfoEntry as w, RecordTrigger as wt, TailorDBReadyContext as x, GqlOperation as xt, ResolverReadyContext as y, ExecutorInput as yt, TailorAnyDBType as z, SCIMConfig as zt };
2027
+ //# sourceMappingURL=plugin-D3a0-qe0.d.mts.map