@tailor-platform/sdk 1.21.0 → 1.22.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 (76) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/application-CTQe2HSB.mjs +5723 -0
  3. package/dist/application-CTQe2HSB.mjs.map +1 -0
  4. package/dist/application-DdSu3baZ.mjs +8 -0
  5. package/dist/{brand-BZJCv6UY.mjs → brand-DyPrAzpM.mjs} +1 -1
  6. package/dist/{brand-BZJCv6UY.mjs.map → brand-DyPrAzpM.mjs.map} +1 -1
  7. package/dist/cli/index.mjs +544 -57
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +49 -8
  10. package/dist/cli/lib.mjs +15 -16
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/configure/index.d.mts +4 -4
  13. package/dist/configure/index.mjs +15 -4
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/{enum-constants-CGVvu3dd.mjs → enum-constants-B5Nl-yzx.mjs} +1 -1
  16. package/dist/{enum-constants-CGVvu3dd.mjs.map → enum-constants-B5Nl-yzx.mjs.map} +1 -1
  17. package/dist/{file-utils-GX_tGWl4.mjs → file-utils-sEOwAdJ4.mjs} +1 -1
  18. package/dist/{file-utils-GX_tGWl4.mjs.map → file-utils-sEOwAdJ4.mjs.map} +1 -1
  19. package/dist/{index-Dn61THJK.d.mts → index-BGPX26_D.d.mts} +2 -2
  20. package/dist/{index-CnHd6BNg.d.mts → index-BiutQT7m.d.mts} +4 -10
  21. package/dist/{index-DxlmLUag.d.mts → index-ClS0NClx.d.mts} +2 -2
  22. package/dist/{index-BWVAwea4.d.mts → index-Cwi86SUR.d.mts} +2 -2
  23. package/dist/{index-oZXVKyfX.d.mts → index-DPN_P0w3.d.mts} +2 -2
  24. package/dist/{interceptor-D8MeZOxX.mjs → interceptor-DiARwPfw.mjs} +1 -1
  25. package/dist/{interceptor-D8MeZOxX.mjs.map → interceptor-DiARwPfw.mjs.map} +1 -1
  26. package/dist/{job-2Q82qQ6N.mjs → job-CRavYLLk.mjs} +4 -24
  27. package/dist/job-CRavYLLk.mjs.map +1 -0
  28. package/dist/kysely/index.d.mts +2 -2
  29. package/dist/kysely/index.mjs +2 -2
  30. package/dist/kysely/index.mjs.map +1 -1
  31. package/dist/{kysely-type-Cpq5TNGY.mjs → kysely-type-CSlcwNFH.mjs} +1 -1
  32. package/dist/{kysely-type-Cpq5TNGY.mjs.map → kysely-type-CSlcwNFH.mjs.map} +1 -1
  33. package/dist/package-json-BI0ng3_5.mjs +3 -0
  34. package/dist/{package-json-3H5gfhA4.mjs → package-json-iVBhE5Ef.mjs} +1 -1
  35. package/dist/{package-json-3H5gfhA4.mjs.map → package-json-iVBhE5Ef.mjs.map} +1 -1
  36. package/dist/plugin/builtin/enum-constants/index.d.mts +2 -2
  37. package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
  38. package/dist/plugin/builtin/file-utils/index.d.mts +2 -2
  39. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  40. package/dist/plugin/builtin/kysely-type/index.d.mts +2 -2
  41. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  42. package/dist/plugin/builtin/seed/index.d.mts +2 -2
  43. package/dist/plugin/builtin/seed/index.mjs +1 -1
  44. package/dist/plugin/index.d.mts +1 -1
  45. package/dist/plugin/index.mjs +3 -3
  46. package/dist/plugin/index.mjs.map +1 -1
  47. package/dist/{update-9MTRN1UA.mjs → query-Bz2oDGhw.mjs} +915 -174
  48. package/dist/query-Bz2oDGhw.mjs.map +1 -0
  49. package/dist/{schema-D5Cpd8fQ.mjs → schema-Cjm-OvPF.mjs} +2 -2
  50. package/dist/{schema-D5Cpd8fQ.mjs.map → schema-Cjm-OvPF.mjs.map} +1 -1
  51. package/dist/{seed-D-rYCN5F.mjs → seed-CXvCW3Xc.mjs} +2 -2
  52. package/dist/{seed-D-rYCN5F.mjs.map → seed-CXvCW3Xc.mjs.map} +1 -1
  53. package/dist/telemetry-BAxP8-PR.mjs +3 -0
  54. package/dist/{telemetry-DuBhnd0X.mjs → telemetry-C46fds1l.mjs} +2 -2
  55. package/dist/{telemetry-DuBhnd0X.mjs.map → telemetry-C46fds1l.mjs.map} +1 -1
  56. package/dist/{types-ClK_HJ0G.mjs → types-CBTSg-LK.mjs} +1 -1
  57. package/dist/{types-ClK_HJ0G.mjs.map → types-CBTSg-LK.mjs.map} +1 -1
  58. package/dist/{types-C0o90Cmb.d.mts → types-DVMQNdTs.d.mts} +6 -2
  59. package/dist/{types-QKq1usl7.d.mts → types-bcuNRo1Y.d.mts} +8 -8
  60. package/dist/utils/test/index.d.mts +42 -4
  61. package/dist/utils/test/index.mjs +78 -3
  62. package/dist/utils/test/index.mjs.map +1 -1
  63. package/docs/cli/function.md +83 -3
  64. package/package.json +7 -5
  65. package/dist/application-CEv5c7TU.mjs +0 -102207
  66. package/dist/application-CEv5c7TU.mjs.map +0 -1
  67. package/dist/application-DiCzM9b0.mjs +0 -9
  68. package/dist/chunk-CqAI0b6X.mjs +0 -47
  69. package/dist/jiti-DfS9jItj.mjs +0 -4482
  70. package/dist/jiti-DfS9jItj.mjs.map +0 -1
  71. package/dist/job-2Q82qQ6N.mjs.map +0 -1
  72. package/dist/package-json-DTDAqRRJ.mjs +0 -3
  73. package/dist/src-Bb1UVstT.mjs +0 -1038
  74. package/dist/src-Bb1UVstT.mjs.map +0 -1
  75. package/dist/telemetry-Dhzj9Ncm.mjs +0 -3
  76. package/dist/update-9MTRN1UA.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"job-2Q82qQ6N.mjs","names":[],"sources":["../src/configure/types/user.ts","../src/configure/services/workflow/job.ts"],"sourcesContent":["// Interfaces for module augmentation\n// Users can extend these via: declare module \"@tailor-platform/sdk\" { interface AttributeMap { ... } }\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface AttributeMap {}\nexport interface AttributeList {\n __tuple?: []; // Marker for tuple type\n}\n\nexport type InferredAttributeMap = keyof AttributeMap extends never\n ? Record<string, string | string[] | boolean | boolean[] | undefined>\n : AttributeMap;\n\nexport type InferredAttributeList = AttributeList[\"__tuple\"] extends []\n ? string[]\n : AttributeList[\"__tuple\"];\n\n/** Represents a user in the Tailor platform. */\nexport type TailorUser = {\n /**\n * The ID of the user.\n * For unauthenticated users, this will be a nil UUID.\n */\n id: string;\n /**\n * The type of the user.\n * For unauthenticated users, this will be an empty string.\n */\n type: \"user\" | \"machine_user\" | \"\";\n /** The ID of the workspace the user belongs to. */\n workspaceId: string;\n /**\n * A map of the user's attributes.\n * For unauthenticated users, this will be null.\n */\n attributes: InferredAttributeMap | null;\n /**\n * A list of the user's attributes.\n * For unauthenticated users, this will be an empty array.\n */\n attributeList: InferredAttributeList;\n};\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser: TailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n};\n","import { unauthenticatedTailorUser } from \"@/configure/types/user\";\nimport { brandValue } from \"@/utils/brand\";\nimport type { TailorEnv } from \"@/configure/types/env\";\nimport type { JsonCompatible } from \"@/configure/types/helpers\";\nimport type { TailorUser } from \"@/configure/types/user\";\nimport type { Jsonifiable, Jsonify, JsonPrimitive } from \"type-fest\";\n\n/**\n * Context object passed as the second argument to workflow job body functions.\n */\nexport type WorkflowJobContext = {\n env: TailorEnv;\n user: TailorUser;\n};\n\n/**\n * Allowed output types for workflow job body functions.\n * Includes Jsonifiable (JSON-serializable values including objects with toJSON like Date),\n * undefined, and void.\n */\nexport type WorkflowJobOutput = Jsonifiable | undefined | void;\n\n/**\n * Convert output type to what trigger returns after JSON serialization.\n * - Jsonifiable values are converted via Jsonify (Date -> string, etc.)\n * - undefined remains undefined\n * - void becomes void\n */\ntype JsonifyOutput<T> = T extends Jsonifiable ? Jsonify<T> : T;\n\n/**\n * Input type constraint for workflow jobs.\n * Accepts any type that is JSON-compatible (primitives, arrays, objects with JSON-compatible values).\n * Excludes objects with toJSON method (like Date) since they won't be serialized in input.\n */\nexport type WorkflowJobInput = undefined | JsonCompatible<unknown>;\n\n/**\n * WorkflowJob represents a job that can be triggered in a workflow.\n *\n * Type constraints:\n * - Input: Must be JSON-compatible (no Date/toJSON objects) or undefined. Interfaces are allowed.\n * - Output: Must be Jsonifiable, undefined, or void\n * - Trigger returns Jsonify<Output> (Date becomes string after JSON.stringify)\n */\nexport interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {\n name: Name;\n /**\n * Trigger this job with the given input.\n * At runtime, this is a placeholder that calls the body function.\n * During bundling, calls to .trigger() are transformed to\n * tailor.workflow.triggerJobFunction(\"<job-name>\", args).\n *\n * Returns Jsonify<Output> because the value passes through JSON.stringify.\n *\n * Inside a workflow job body, .trigger() calls are transformed by the bundler\n * into synchronous `triggerJobFunction` calls. You may use `await` for\n * readability — the bundler strips it automatically at build time.\n * @example\n * // Both styles work — await is stripped by the bundler:\n * body: async (input) => {\n * const a = await jobA.trigger({ id: input.id });\n * const b = await jobB.trigger({ id: input.id });\n * return { a, b };\n * }\n */\n trigger: [Input] extends [undefined]\n ? () => Promise<JsonifyOutput<Awaited<Output>>>\n : (input: Input) => Promise<JsonifyOutput<Awaited<Output>>>;\n body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;\n}\n\n/**\n * Helper type to check if all property types are valid.\n * Uses -? to remove optional modifiers so all properties are treated uniformly.\n */\ntype AllPropertiesValid<T> = {\n [K in keyof T]-?: IsValidInput<T[K]> extends true ? true : false;\n}[keyof T] extends true\n ? true\n : false;\n\n/**\n * Check if a type contains any non-JSON-compatible values.\n * Returns `true` if the type is valid for input, `false` otherwise.\n *\n * Accepts:\n * - JSON primitives (string, number, boolean, null)\n * - undefined\n * - Optional primitives (e.g., string | undefined)\n * - Arrays of valid types\n * - Objects with valid field types\n *\n * Rejects:\n * - Objects with toJSON methods (like Date)\n * - Other non-JSON-serializable types\n */\ntype IsValidInput<T> = T extends undefined\n ? true\n : T extends JsonPrimitive\n ? true\n : T extends readonly (infer U)[]\n ? IsValidInput<U>\n : T extends object\n ? T extends { toJSON: () => unknown }\n ? false\n : AllPropertiesValid<T>\n : false;\n\n/**\n * Helper type to check if all property types are valid for output.\n * Uses -? to remove optional modifiers so all properties are treated uniformly.\n */\ntype AllPropertiesValidOutput<T> = {\n [K in keyof T]-?: IsValidOutput<T[K]> extends true ? true : false;\n}[keyof T] extends true\n ? true\n : false;\n\n/**\n * Check if a type is valid for output.\n * Returns `true` if the type is valid, `false` otherwise.\n *\n * Accepts:\n * - JSON primitives (string, number, boolean, null)\n * - undefined and void\n * - Optional primitives (e.g., string | undefined)\n * - Jsonifiable types (Date, objects with toJSON)\n * - Arrays of valid types\n * - Objects with valid field types\n */\ntype IsValidOutput<T> = T extends undefined | void\n ? true\n : T extends JsonPrimitive\n ? true\n : T extends readonly (infer U)[]\n ? IsValidOutput<U>\n : T extends object\n ? AllPropertiesValidOutput<T>\n : false;\n\n/**\n * Body function type with conditional constraint.\n * If input contains invalid types (like Date), the body type becomes `never` to cause an error.\n */\ntype WorkflowJobBody<I, O> =\n IsValidInput<I> extends true\n ? IsValidOutput<O> extends true\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : never\n : never;\n\n/**\n * Environment variable key for workflow testing.\n * Contains JSON-serialized TailorEnv object.\n */\nexport const WORKFLOW_TEST_ENV_KEY = \"TAILOR_TEST_WORKFLOW_ENV\";\n\n/**\n * Environment variable key for workflow user testing.\n * Contains JSON-serialized TailorUser object.\n */\nexport const WORKFLOW_TEST_USER_KEY = \"TAILOR_TEST_WORKFLOW_USER\";\n\n/**\n * Create a workflow job definition.\n *\n * All jobs must be named exports from the workflow file.\n * Job names must be unique across the entire project.\n * @param config - Job configuration with name and body function\n * @param config.name - Unique job name across the project\n * @param config.body - Async function that processes the job input\n * @returns A WorkflowJob that can be triggered from other jobs\n * @example\n * // Simple job with async body:\n * export const fetchData = createWorkflowJob({\n * name: \"fetch-data\",\n * body: async (input: { id: string }) => {\n * const db = getDB(\"tailordb\");\n * return await db.selectFrom(\"Table\").selectAll().where(\"id\", \"=\", input.id).executeTakeFirst();\n * },\n * });\n * @example\n * // Orchestrator job that fans out to other jobs.\n * // await is optional — the bundler strips it at build time.\n * export const orchestrate = createWorkflowJob({\n * name: \"orchestrate\",\n * body: async (input: { orderId: string }) => {\n * const inventory = await checkInventory.trigger({ orderId: input.orderId });\n * const payment = await processPayment.trigger({ orderId: input.orderId });\n * return { inventory, payment };\n * },\n * });\n */\nexport const createWorkflowJob = <const Name extends string, I = undefined, O = undefined>(config: {\n readonly name: Name;\n readonly body: WorkflowJobBody<I, O>;\n}): WorkflowJob<Name, I, Awaited<O>> => {\n return brandValue({\n name: config.name,\n // JSON.parse(JSON.stringify(...)) ensures the return value matches Jsonify<Output> type.\n // This converts Date objects to strings, matching actual runtime behavior.\n // In production, bundler transforms .trigger() calls to tailor.workflow.triggerJobFunction().\n trigger: async (args?: unknown) => {\n const env: TailorEnv = JSON.parse(process.env[WORKFLOW_TEST_ENV_KEY] || \"{}\");\n const user: TailorUser = process.env[WORKFLOW_TEST_USER_KEY]\n ? JSON.parse(process.env[WORKFLOW_TEST_USER_KEY])\n : unauthenticatedTailorUser;\n const result = await config.body(args as I, { env, user });\n return result ? JSON.parse(JSON.stringify(result)) : result;\n },\n body: config.body,\n } as WorkflowJob<Name, I, Awaited<O>>);\n};\n"],"mappings":";;;;AA2CA,MAAa,4BAAwC;CACnD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,YAAY;CACZ,eAAe,EAAE;CAClB;;;;;;;;AC2GD,MAAa,wBAAwB;;;;;AAMrC,MAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCtC,MAAa,qBAA8E,WAGnD;AACtC,QAAO,WAAW;EAChB,MAAM,OAAO;EAIb,SAAS,OAAO,SAAmB;GACjC,MAAM,MAAiB,KAAK,MAAM,QAAQ,IAAI,0BAA0B,KAAK;GAC7E,MAAM,OAAmB,QAAQ,IAAI,0BACjC,KAAK,MAAM,QAAQ,IAAI,wBAAwB,GAC/C;GACJ,MAAM,SAAS,MAAM,OAAO,KAAK,MAAW;IAAE;IAAK;IAAM,CAAC;AAC1D,UAAO,SAAS,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC,GAAG;;EAEvD,MAAM,OAAO;EACd,CAAqC"}
@@ -1,3 +0,0 @@
1
- import { t as readPackageJson } from "./package-json-3H5gfhA4.mjs";
2
-
3
- export { readPackageJson };