@tailor-platform/sdk 1.62.0 → 2.0.0-next.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.
@@ -125,6 +125,89 @@ defineIdp("my-idp", {
125
125
  });
126
126
  ```
127
127
 
128
+ ### userAuthPolicy
129
+
130
+ User authentication policy. Controls password requirements, the identifier used for login, allowed email domains, and social login providers. Every field is optional. The boolean options default to disabled, and the password length fields default to a minimum of 6 and a maximum of 4096.
131
+
132
+ ```typescript
133
+ defineIdp("my-idp", {
134
+ clients: ["my-client"],
135
+ userAuthPolicy: {
136
+ useNonEmailIdentifier: false,
137
+ allowSelfPasswordReset: true,
138
+ passwordRequireUppercase: true,
139
+ passwordRequireLowercase: true,
140
+ passwordRequireNonAlphanumeric: true,
141
+ passwordRequireNumeric: true,
142
+ passwordMinLength: 8,
143
+ passwordMaxLength: 128,
144
+ },
145
+ });
146
+ ```
147
+
148
+ **Login behavior:**
149
+
150
+ - `useNonEmailIdentifier` - Allow a non-email identifier (username) instead of requiring an email address. Default `false`.
151
+ - `allowSelfPasswordReset` - Show the "Forgot password?" flow so users can reset their own password. Default `false`.
152
+ - `disablePasswordAuth` - Remove password authentication entirely. Default `false`. Requires at least one social login provider to be enabled.
153
+
154
+ **Password requirements:**
155
+
156
+ - `passwordRequireUppercase` - Require at least one uppercase letter. Default `false`.
157
+ - `passwordRequireLowercase` - Require at least one lowercase letter. Default `false`.
158
+ - `passwordRequireNumeric` - Require at least one numeric character. Default `false`.
159
+ - `passwordRequireNonAlphanumeric` - Require at least one non-alphanumeric character. Default `false`.
160
+ - `passwordMinLength` - Minimum password length. Must be between 6 and 30. Default `6`.
161
+ - `passwordMaxLength` - Maximum password length. Must be between 6 and 4096. Default `4096`.
162
+
163
+ **Email domains and social login:**
164
+
165
+ - `allowedEmailDomains` - Restrict registration to these email domains. An empty list (the default) allows all domains, but a non-empty list is required when `allowGoogleOauth` or `allowMicrosoftOauth` is enabled.
166
+ - `allowGoogleOauth` - Enable the "Sign in with Google" button. Default `false`.
167
+ - `allowMicrosoftOauth` - Enable the "Sign in with Microsoft" button. Default `false`.
168
+
169
+ **Constraints:** the following combinations are rejected at parse time.
170
+
171
+ - `passwordMinLength` must be less than or equal to `passwordMaxLength`.
172
+ - A non-empty `allowedEmailDomains` cannot be combined with `useNonEmailIdentifier: true` (an empty list is allowed). Enabling `allowGoogleOauth` or `allowMicrosoftOauth` is likewise rejected with `useNonEmailIdentifier: true` (leaving them `false` or unset is fine).
173
+ - `allowGoogleOauth` requires a non-empty `allowedEmailDomains`.
174
+ - `allowMicrosoftOauth` requires both a non-empty `allowedEmailDomains` and `disablePasswordAuth: true`.
175
+ - `disablePasswordAuth` requires `allowGoogleOauth` or `allowMicrosoftOauth`, and cannot be combined with `allowSelfPasswordReset`.
176
+
177
+ ### gqlOperations
178
+
179
+ Controls which GraphQL user-management operations the IdP exposes. All operations are enabled by default. Use this to turn operations off entirely, independent of the `permission` policies that decide who may call them.
180
+
181
+ ```typescript
182
+ defineIdp("my-idp", {
183
+ clients: ["my-client"],
184
+ gqlOperations: {
185
+ create: true,
186
+ read: true,
187
+ update: true,
188
+ delete: false,
189
+ sendPasswordResetEmail: false,
190
+ },
191
+ });
192
+ ```
193
+
194
+ **Fields:** each field defaults to `true` (enabled). Set a field to `false` to disable that operation.
195
+
196
+ - `create` - The `_createUser` mutation.
197
+ - `read` - The `_users` and `_user` query operations.
198
+ - `update` - The `_updateUser` mutation.
199
+ - `delete` - The `_deleteUser` mutation.
200
+ - `sendPasswordResetEmail` - The `_sendPasswordResetEmail` mutation.
201
+
202
+ **Shortcut:** pass the string `"query"` to expose a read-only IdP. It enables `read` and disables every mutation.
203
+
204
+ ```typescript
205
+ defineIdp("my-idp", {
206
+ clients: ["my-client"],
207
+ gqlOperations: "query",
208
+ });
209
+ ```
210
+
128
211
  ### authorization (optional, legacy)
129
212
 
130
213
  Legacy access control field. Use `permission` instead for fine-grained per-operation control. This field is kept for backward compatibility.
@@ -170,6 +253,19 @@ defineIdp("my-idp", {
170
253
 
171
254
  **Validation:** Each field must be 200 characters or less and must not contain newline characters.
172
255
 
256
+ ### lang
257
+
258
+ UI language for the IdP-hosted pages such as the login and password reset screens.
259
+
260
+ ```typescript
261
+ defineIdp("my-idp", {
262
+ clients: ["my-client"],
263
+ lang: "ja",
264
+ });
265
+ ```
266
+
267
+ **Values:** `"en"` or `"ja"`.
268
+
173
269
  ### publishUserEvents
174
270
 
175
271
  Publish IdP user lifecycle events (`idp.user.created`, `idp.user.updated`, `idp.user.deleted`). These events are consumed by executors that use `idpUserCreatedTrigger`, `idpUserUpdatedTrigger`, `idpUserDeletedTrigger`, or `idpUserTrigger`.
@@ -355,20 +355,21 @@ Coordinate this with your team because everyone else's local migrations will be
355
355
 
356
356
  ## Failure Recovery
357
357
 
358
- If a `migrate.ts` throws:
358
+ If the pre-migration phase or `migrate.ts` fails:
359
359
 
360
360
  - **The transaction rolls back** for that migration's script. Database changes the script made are undone.
361
- - **The pre-migration phase already ran** before the script. Type-level relaxations (e.g., a field changed to optional) **are not undone**. The post-migration phase, including the label bump, does not run.
362
- - The whole `apply` aborts. Subsequent migrations in the same run do not execute.
361
+ - **The pre-migration schema changes are rolled back** to the prior checkpoint: types that already existed are restored to their previous shape, and types the migration newly introduced are dropped. The workspace is left at its prior checkpoint and prior schema — not half-applied.
362
+ - The whole `apply` aborts and the checkpoint label is not bumped. Subsequent migrations in the same run do not execute.
363
+
364
+ The rollback is best-effort per type; if reverting a type fails, a warning is logged and the original migration error is still reported.
363
365
 
364
366
  After a failure:
365
367
 
366
368
  1. Read the `Logs:` block in the apply output to find the cause.
367
369
  2. Fix `migrate.ts` (or the data it depends on).
368
- 3. Re-run `tailor-sdk deploy`. The same migration runs again because its label was never bumped.
369
- 4. If the pre-migration relaxation is causing problems for application code in the meantime, accept the temporary optionality or roll forward with a fix; do not try to manually re-tighten the schema, or you'll create remote drift.
370
+ 3. Re-run `tailor-sdk deploy`. The same migration runs again because its label was never bumped, and the prior-checkpoint schema is a clean baseline to retry against.
370
371
 
371
- If a migration **succeeds in script** but the post-migration phase fails (rare; usually due to constraint violation that the script should have prevented), the situation is the same as above plus the data changes from the script are persisted. Investigate, fix, and re-run.
372
+ If a migration **succeeds in script** but the **post-migration phase** fails (rare; usually a constraint violation the script should have prevented), the pre-migration changes are **not** rolled back: the script's data changes are already committed and the post-migration phase may have dropped removed columns or types, which cannot be reverted without data loss. Investigate, fix, and re-run.
372
373
 
373
374
  ## Rollback Strategy
374
375
 
@@ -444,6 +445,16 @@ For genuinely different schemas across environments, prefer separate workspaces
444
445
  4. To force the remote schema back to a known snapshot, use `migration sync <N>` (see [`migration sync` Semantics](#migration-sync-semantics)).
445
446
  5. As a last resort in non-production environments, `--no-schema-check` skips both checks. Do not use this as a routine workaround.
446
447
 
448
+ ### "Invalid schema snapshot" or "Invalid migration diff" error
449
+
450
+ **Cause:** A `schema.json` or `diff.json` file in the `migrations/` directory is corrupted or does not match the expected structure. Merge conflicts left in these files are a common cause.
451
+
452
+ **Resolution:**
453
+
454
+ 1. Read the error message — it includes the file path and the offending field.
455
+ 2. Restore the file from version control (`git checkout -- <path>`), or regenerate migration files with `migration generate` / `migration script`.
456
+ 3. Do not hand-edit `schema.json` or `diff.json`; they are managed by the CLI.
457
+
447
458
  ### "No machine user available for migration execution"
448
459
 
449
460
  **Cause:** Neither `migration.machineUser` is set nor are there any machine users in `auth.machineUsers`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.62.0",
3
+ "version": "2.0.0-next.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -146,11 +146,11 @@
146
146
  "@jridgewell/trace-mapping": "0.3.31",
147
147
  "@napi-rs/keyring": "1.3.0",
148
148
  "@opentelemetry/api": "1.9.1",
149
- "@opentelemetry/exporter-trace-otlp-proto": "0.218.0",
150
- "@opentelemetry/resources": "2.7.1",
151
- "@opentelemetry/sdk-trace-node": "2.7.1",
149
+ "@opentelemetry/exporter-trace-otlp-proto": "0.219.0",
150
+ "@opentelemetry/resources": "2.8.0",
151
+ "@opentelemetry/sdk-trace-node": "2.8.0",
152
152
  "@opentelemetry/semantic-conventions": "1.41.1",
153
- "@oxc-project/types": "0.134.0",
153
+ "@oxc-project/types": "0.135.0",
154
154
  "@standard-schema/spec": "1.1.0",
155
155
  "@tailor-platform/function-kysely-tailordb": "0.1.3",
156
156
  "@toiroakr/lines-db": "0.9.2",
@@ -169,34 +169,34 @@
169
169
  "madge": "8.0.0",
170
170
  "mime-types": "3.0.2",
171
171
  "open": "11.0.0",
172
- "oxc-parser": "0.134.0",
172
+ "oxc-parser": "0.135.0",
173
173
  "p-limit": "7.3.0",
174
174
  "pathe": "2.0.3",
175
175
  "pgsql-ast-parser": "12.0.2",
176
176
  "pkg-types": "2.3.1",
177
177
  "politty": "0.5.1",
178
178
  "rolldown": "1.1.0",
179
- "semver": "7.8.2",
179
+ "semver": "7.8.3",
180
180
  "sql-highlight": "6.1.0",
181
181
  "std-env": "4.1.0",
182
182
  "table": "6.9.0",
183
183
  "ts-cron-validator": "1.1.5",
184
184
  "tsx": "4.22.4",
185
185
  "type-fest": "5.7.0",
186
- "undici": "8.4.0",
186
+ "undici": "8.4.1",
187
187
  "xdg-basedir": "5.1.0",
188
188
  "zod": "4.4.3"
189
189
  },
190
190
  "devDependencies": {
191
- "@opentelemetry/sdk-trace-base": "2.7.1",
191
+ "@opentelemetry/sdk-trace-base": "2.8.0",
192
192
  "@types/madge": "5.0.3",
193
193
  "@types/mime-types": "3.0.1",
194
194
  "@types/node": "24.13.1",
195
195
  "@types/semver": "7.7.1",
196
- "@typescript/native-preview": "7.0.0-dev.20260605.1",
196
+ "@typescript/native-preview": "7.0.0-dev.20260612.1",
197
197
  "@vitest/coverage-v8": "4.1.8",
198
- "oxfmt": "0.53.0",
199
- "oxlint": "1.68.0",
198
+ "oxfmt": "0.54.0",
199
+ "oxlint": "1.69.0",
200
200
  "oxlint-tsgolint": "0.23.0",
201
201
  "sonda": "0.11.1",
202
202
  "tsdown": "0.22.2",