@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
@@ -341,6 +341,39 @@ idProvider: idp.provider("my-provider", "my-client"),
341
341
 
342
342
  See [IdP](./idp.md) for configuring identity providers.
343
343
 
344
+ ## Before Login Hook
345
+
346
+ Run custom logic before a user logs in. This is useful for JIT (Just-In-Time) user provisioning — automatically creating or updating user records when a user authenticates for the first time.
347
+
348
+ ```typescript
349
+ import { defineAuth } from "@tailor-platform/sdk";
350
+ import { user } from "./tailordb/user";
351
+
352
+ export const auth = defineAuth("my-auth", {
353
+ userProfile: {
354
+ type: user,
355
+ usernameField: "email",
356
+ },
357
+ machineUsers: {
358
+ "hook-invoker": {
359
+ attributes: { role: "ADMIN" },
360
+ },
361
+ },
362
+ hooks: {
363
+ beforeLogin: {
364
+ handler: async ({ claims, idpConfigName }) => {
365
+ // Provision or update user based on IdP claims
366
+ },
367
+ invoker: "hook-invoker",
368
+ },
369
+ },
370
+ });
371
+ ```
372
+
373
+ **handler**: An async function that receives `{ claims, idpConfigName }` and is called before each login. `claims` contains the token claims from the identity provider, and `idpConfigName` is the name of the IdP configuration used for authentication.
374
+
375
+ **invoker**: The machine user whose permissions are used to execute the hook. Must reference a machine user defined in the same auth configuration.
376
+
344
377
  ## CLI Commands
345
378
 
346
379
  Manage Auth resources using the CLI:
@@ -275,3 +275,35 @@ createResolver({
275
275
  // ...
276
276
  });
277
277
  ```
278
+
279
+ ## Authentication
280
+
281
+ Specify an `authInvoker` to execute the resolver with machine user credentials:
282
+
283
+ ```typescript
284
+ import { defineAuth, createResolver, t } from "@tailor-platform/sdk";
285
+
286
+ const auth = defineAuth("my-auth", {
287
+ // ... auth configuration
288
+ machineUsers: {
289
+ "batch-processor": {
290
+ attributes: { role: "ADMIN" },
291
+ },
292
+ },
293
+ });
294
+
295
+ export default createResolver({
296
+ name: "adminQuery",
297
+ operation: "query",
298
+ output: t.object({ result: t.string() }),
299
+ body: async () => {
300
+ // Executes as "batch-processor" machine user
301
+ return { result: "ok" };
302
+ },
303
+ authInvoker: auth.invoker("batch-processor"),
304
+ });
305
+ ```
306
+
307
+ The `authInvoker` option accepts the return value of `auth.invoker()`, which specifies the auth namespace and machine user name.
308
+
309
+ **Note:** `authInvoker` controls the permissions for database operations and other platform actions, but the `user` object passed to the `body` function still reflects the original caller who invoked the resolver.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.25.4",
3
+ "version": "1.27.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -132,9 +132,9 @@
132
132
  "@types/mime-types": "3.0.1",
133
133
  "@types/node": "24.12.0",
134
134
  "@typescript/native-preview": "7.0.0-dev.20260308.1",
135
- "@vitest/coverage-v8": "4.0.18",
135
+ "@vitest/coverage-v8": "4.1.0",
136
136
  "eslint": "9.39.4",
137
- "eslint-plugin-jsdoc": "62.7.1",
137
+ "eslint-plugin-jsdoc": "62.8.0",
138
138
  "eslint-plugin-oxlint": "1.39.0",
139
139
  "oxlint": "1.39.0",
140
140
  "oxlint-tsgolint": "0.16.0",
@@ -142,7 +142,7 @@
142
142
  "tsdown": "0.21.2",
143
143
  "typescript": "5.9.3",
144
144
  "typescript-eslint": "8.57.0",
145
- "vitest": "4.0.18",
145
+ "vitest": "4.1.0",
146
146
  "zinfer": "0.1.7"
147
147
  },
148
148
  "scripts": {