@tailor-platform/sdk 1.17.1 → 1.18.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 (77) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/application-Csj7Ow5Q.mjs +8 -0
  3. package/dist/{application-BMDE8KqK.mjs → application-gWUyKuzv.mjs} +120 -1618
  4. package/dist/application-gWUyKuzv.mjs.map +1 -0
  5. package/dist/brand-BZJCv6UY.mjs +28 -0
  6. package/dist/brand-BZJCv6UY.mjs.map +1 -0
  7. package/dist/cli/index.mjs +38 -20
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +10 -33
  10. package/dist/cli/lib.mjs +10 -5
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/configure/index.d.mts +4 -4
  13. package/dist/configure/index.mjs +10 -19
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/enum-constants-Cwd4qdpa.mjs +115 -0
  16. package/dist/enum-constants-Cwd4qdpa.mjs.map +1 -0
  17. package/dist/file-utils-cqcpFk87.mjs +139 -0
  18. package/dist/file-utils-cqcpFk87.mjs.map +1 -0
  19. package/dist/index-BKXch-td.d.mts +18 -0
  20. package/dist/index-C3Ib7pFc.d.mts +18 -0
  21. package/dist/{index-CVcYqZSf.d.mts → index-DP8EB9FK.d.mts} +12 -5
  22. package/dist/index-SqWgrTnF.d.mts +20 -0
  23. package/dist/index-sSDpuVQY.d.mts +18 -0
  24. package/dist/{jiti-BrELlEYT.mjs → jiti-DHlauMCo.mjs} +2 -2
  25. package/dist/{jiti-BrELlEYT.mjs.map → jiti-DHlauMCo.mjs.map} +1 -1
  26. package/dist/{job-CULA2Pvf.mjs → job-2Q82qQ6N.mjs} +27 -5
  27. package/dist/job-2Q82qQ6N.mjs.map +1 -0
  28. package/dist/kysely-type-DtUUoAi3.mjs +259 -0
  29. package/dist/kysely-type-DtUUoAi3.mjs.map +1 -0
  30. package/dist/plugin/builtin/enum-constants/index.d.mts +4 -0
  31. package/dist/plugin/builtin/enum-constants/index.mjs +3 -0
  32. package/dist/plugin/builtin/file-utils/index.d.mts +4 -0
  33. package/dist/plugin/builtin/file-utils/index.mjs +3 -0
  34. package/dist/plugin/builtin/kysely-type/index.d.mts +4 -0
  35. package/dist/plugin/builtin/kysely-type/index.mjs +3 -0
  36. package/dist/plugin/builtin/seed/index.d.mts +4 -0
  37. package/dist/plugin/builtin/seed/index.mjs +3 -0
  38. package/dist/plugin/index.d.mts +3 -3
  39. package/dist/plugin/index.mjs +11 -11
  40. package/dist/plugin/index.mjs.map +1 -1
  41. package/dist/{schema-R5TxC5Pn.mjs → schema-WDvc7Zel.mjs} +4 -3
  42. package/dist/schema-WDvc7Zel.mjs.map +1 -0
  43. package/dist/seed-Dm7lrGZ3.mjs +1050 -0
  44. package/dist/seed-Dm7lrGZ3.mjs.map +1 -0
  45. package/dist/{src-DMROgdcL.mjs → src-i4uqS1G4.mjs} +2 -2
  46. package/dist/{src-DMROgdcL.mjs.map → src-i4uqS1G4.mjs.map} +1 -1
  47. package/dist/types-Bhl_wAM2.d.mts +151 -0
  48. package/dist/{types-b-ig8nW_.mjs → types-ClK_HJ0G.mjs} +1 -1
  49. package/dist/{types-b-ig8nW_.mjs.map → types-ClK_HJ0G.mjs.map} +1 -1
  50. package/dist/{types-CZZBCaxB.d.mts → types-DdvTxFiD.d.mts} +1324 -988
  51. package/dist/{update-CUBVjZbL.mjs → update-BoNKMti-.mjs} +268 -97
  52. package/dist/update-BoNKMti-.mjs.map +1 -0
  53. package/dist/utils/test/index.d.mts +4 -4
  54. package/dist/utils/test/index.mjs +3 -2
  55. package/dist/utils/test/index.mjs.map +1 -1
  56. package/docs/cli/application.md +106 -14
  57. package/docs/cli/auth.md +92 -12
  58. package/docs/cli/completion.md +18 -2
  59. package/docs/cli/executor.md +122 -14
  60. package/docs/cli/function.md +32 -4
  61. package/docs/cli/secret.md +134 -18
  62. package/docs/cli/staticwebsite.md +60 -8
  63. package/docs/cli/tailordb.md +148 -20
  64. package/docs/cli/user.md +154 -22
  65. package/docs/cli/workflow.md +100 -12
  66. package/docs/cli/workspace.md +274 -38
  67. package/docs/generator/custom.md +2 -2
  68. package/docs/plugin/custom.md +270 -163
  69. package/docs/plugin/index.md +48 -2
  70. package/package.json +22 -2
  71. package/dist/application-BMDE8KqK.mjs.map +0 -1
  72. package/dist/application-Dni_W16P.mjs +0 -4
  73. package/dist/job-CULA2Pvf.mjs.map +0 -1
  74. package/dist/schema-R5TxC5Pn.mjs.map +0 -1
  75. package/dist/types-DthzUFfx.d.mts +0 -372
  76. package/dist/update-CUBVjZbL.mjs.map +0 -1
  77. /package/dist/{chunk-GMkBE123.mjs → chunk-CqAI0b6X.mjs} +0 -0
@@ -1145,821 +1145,34 @@ interface TypeFeatures {
1145
1145
  gqlOperations?: GqlOperationsConfig;
1146
1146
  }
1147
1147
  //#endregion
1148
- //#region src/parser/plugin-config/types.d.ts
1149
- type TypeConfigRequired<PluginConfig = unknown> = boolean | ((pluginConfig: PluginConfig | undefined) => boolean);
1150
- /**
1151
- * Interface for plugin configuration mapping.
1152
- * Extend this interface via declaration merging to add typed plugin configs.
1153
- *
1154
- * The `Fields` type parameter provides field names from the type being configured,
1155
- * enabling type-safe field references in plugin configs.
1156
- * @example
1157
- * ```typescript
1158
- * // In your plugin package or types file:
1159
- * declare module "@tailor-platform/sdk" {
1160
- * interface PluginConfigs<Fields extends string> {
1161
- * "@my-company/i18n": {
1162
- * labels: Partial<Record<Fields, { ja: string; en: string }>>;
1163
- * };
1164
- * }
1165
- * }
1166
- * ```
1167
- */
1168
- interface PluginConfigs<Fields extends string = string> {}
1169
- /**
1170
- * Plugin attachment stored on TailorAnyDBType instances.
1171
- * This is the configuration passed via `.plugin()` method.
1172
- */
1173
- interface PluginAttachment {
1174
- pluginId: string;
1175
- config: unknown;
1176
- }
1177
- /**
1178
- * Context passed to plugin's process method
1179
- */
1180
- interface PluginProcessContext<TypeConfig = unknown, PluginConfig = unknown> {
1181
- /** The raw TailorDB type being processed */
1182
- type: TailorAnyDBType;
1183
- /** Per-type configuration passed via .plugin() method */
1184
- typeConfig: TypeConfig;
1185
- /** Plugin-level configuration passed via definePlugins() */
1186
- pluginConfig: PluginConfig;
1187
- /** Namespace of the TailorDB type */
1188
- namespace: string;
1189
- }
1190
- /**
1191
- * Context passed to plugin's processNamespace method.
1192
- * Used for plugins that operate on a namespace without requiring a source type.
1193
- */
1194
- interface PluginNamespaceProcessContext<PluginConfig = unknown> {
1195
- /** Plugin-level configuration passed via definePlugins() */
1196
- pluginConfig: PluginConfig;
1197
- /** Target namespace for generated types */
1198
- namespace: string;
1199
- }
1200
- /**
1201
- * Interface representing a TailorDB type for plugin output.
1202
- * This interface is satisfied by db.type() instances.
1203
- */
1204
- interface TailorDBTypeForPlugin {
1205
- /** The name of the type */
1206
- readonly name: string;
1207
- /** The field definitions */
1208
- readonly fields: Record<string, unknown>;
1209
- }
1210
- /**
1211
- * Type generated by a plugin - use db.type() to create these.
1212
- */
1213
- type PluginGeneratedType = TailorDBTypeForPlugin;
1214
- /**
1215
- * Map of generated types keyed by kind identifier.
1216
- * The kind is used to generate distinct TypeScript type files for each generated type.
1217
- * @example
1218
- * ```typescript
1219
- * {
1220
- * request: changeRequest,
1221
- * step: changeStep,
1222
- * approval: changeApproval,
1223
- * }
1224
- * ```
1225
- */
1226
- type PluginGeneratedTypes = Record<string, PluginGeneratedType>;
1227
- /**
1228
- * Resolver definition generated by a plugin.
1229
- * Fields can be TailorDB field instances or raw field definitions.
1230
- */
1231
- interface PluginGeneratedResolver {
1232
- name: string;
1233
- operation: "query" | "mutation";
1234
- inputFields?: Record<string, unknown>;
1235
- outputFields: Record<string, unknown>;
1236
- /** Function body code as string */
1237
- body: string;
1238
- }
1239
- /**
1240
- * Record trigger configuration for plugin-generated executors
1241
- */
1242
- interface PluginRecordTriggerConfig {
1243
- kind: "recordCreated" | "recordUpdated" | "recordDeleted";
1244
- /** TailorDB type name for record triggers */
1245
- typeName: string;
1246
- }
1247
- /**
1248
- * Schedule trigger configuration for plugin-generated executors
1249
- */
1250
- interface PluginScheduleTriggerConfig {
1251
- kind: "schedule";
1252
- /** Cron expression */
1253
- cron: string;
1254
- /** Timezone (defaults to UTC) */
1255
- timezone?: string;
1256
- }
1257
- /**
1258
- * Incoming webhook trigger configuration for plugin-generated executors
1259
- */
1260
- interface PluginIncomingWebhookTriggerConfig {
1261
- kind: "incomingWebhook";
1262
- }
1263
- /**
1264
- * Trigger configuration for plugin-generated executors
1265
- */
1266
- type PluginTriggerConfig = PluginRecordTriggerConfig | PluginScheduleTriggerConfig | PluginIncomingWebhookTriggerConfig;
1267
- /**
1268
- * Inject value types supported for plugin executor injection.
1269
- * These values are serialized as const declarations in the generated file.
1270
- */
1271
- type PluginInjectValue = string | number | boolean | null;
1272
- /**
1273
- * Inject map for plugin executor.
1274
- * Keys become const variable names in the generated file.
1275
- */
1276
- type PluginInjectMap = Record<string, PluginInjectValue>;
1277
- /**
1278
- * Function operation configuration for plugin-generated executors
1279
- */
1280
- interface PluginFunctionOperationConfig {
1281
- kind: "function";
1282
- /** Function body code as string */
1283
- body: string;
1284
- /**
1285
- * Variables to inject into the generated file scope.
1286
- * These become const declarations at the top of the generated file,
1287
- * allowing the function body to reference them.
1288
- * @example { namespace: "tailordb", historyTypeName: "CustomerHistory" }
1289
- */
1290
- inject?: PluginInjectMap;
1291
- }
1292
- /**
1293
- * GraphQL operation configuration for plugin-generated executors
1294
- */
1295
- interface PluginGraphQLOperationConfig {
1296
- kind: "graphql";
1297
- /** GraphQL query string */
1298
- query: string;
1299
- /** App name for the GraphQL endpoint */
1300
- appName?: string;
1301
- /**
1302
- * Variables expression as a string function.
1303
- * Receives the executor args object and returns the variables object.
1304
- * @example "(args) => ({ input: { recordId: args.newRecord.id } })"
1305
- */
1306
- variables?: string;
1307
- }
1308
- /**
1309
- * Webhook operation configuration for plugin-generated executors
1310
- */
1311
- interface PluginWebhookOperationConfig {
1312
- kind: "webhook";
1313
- /** Webhook URL */
1314
- url: string;
1315
- }
1316
- /**
1317
- * Workflow operation configuration for plugin-generated executors
1318
- */
1319
- interface PluginWorkflowOperationConfig {
1320
- kind: "workflow";
1321
- /** Workflow name */
1322
- workflowName: string;
1323
- }
1324
- /**
1325
- * Operation configuration for plugin-generated executors
1326
- */
1327
- type PluginOperationConfig = PluginFunctionOperationConfig | PluginGraphQLOperationConfig | PluginWebhookOperationConfig | PluginWorkflowOperationConfig;
1328
- /**
1329
- * Context value types for plugin executor context.
1330
- * Supports primitive values and type references.
1331
- */
1332
- type PluginExecutorContextValue = TailorAnyDBType | string | number | boolean | null | undefined;
1333
- /**
1334
- * Base executor context that can include type references and other values.
1335
- * Type objects (TailorAnyDBType) will be handled specially by the generator
1336
- * to create appropriate import statements.
1337
- *
1338
- * Plugin authors should extend this interface for their specific context needs.
1339
- */
1340
- interface PluginExecutorContextBase {
1341
- /** Source type that the plugin is attached to. Null for namespace executors. */
1342
- sourceType: TailorAnyDBType | null;
1343
- /** TailorDB namespace for data operations */
1344
- namespace: string;
1345
- }
1346
- /**
1347
- * Flexible executor context type that allows additional properties.
1348
- * Used as the context type in PluginGeneratedExecutorWithFile.
1349
- */
1350
- type PluginExecutorContext = PluginExecutorContextBase & {
1351
- [key: string]: PluginExecutorContextValue;
1352
- };
1353
- /**
1354
- * Module shape returned by plugin executor resolve().
1355
- * The concrete context type is intentionally erased at this boundary.
1356
- */
1357
- interface PluginExecutorModule {
1358
- default: unknown;
1359
- }
1360
- /**
1361
- * Executor definition with dynamic import reference (new format).
1362
- * Used with withPluginContext for type-safe executor definitions in separate files.
1363
- */
1364
- interface PluginGeneratedExecutorWithFile<Ctx = PluginExecutorContext> {
1365
- /** Executor name (used for generated file name) */
1366
- name: string;
1367
- /**
1368
- * Resolver function for the executor module.
1369
- * Should return a dynamic import to the executor file.
1370
- * Relative import specifiers are resolved from the plugin's importPath base.
1371
- * @example `async () => await import("./executors/on-create")`
1372
- */
1373
- resolve: () => Promise<PluginExecutorModule>;
1374
- /**
1375
- * Context to pass to the executor factory.
1376
- * Can include TailorAnyDBType objects - these will be handled specially
1377
- * by the generator to create appropriate import statements.
1378
- */
1379
- context: Ctx;
1380
- }
1381
- /**
1382
- * Executor definition generated by a plugin (legacy format).
1383
- * @deprecated Use PluginGeneratedExecutorWithFile with withPluginContext instead.
1384
- */
1385
- interface PluginGeneratedExecutorLegacy {
1386
- name: string;
1387
- description?: string;
1388
- trigger: PluginTriggerConfig;
1389
- operation: PluginOperationConfig;
1390
- }
1391
- /**
1392
- * Executor definition generated by a plugin.
1393
- * Supports both legacy format (inline trigger/operation) and new format (executorFile/context).
1394
- */
1395
- type PluginGeneratedExecutor = PluginGeneratedExecutorWithFile | PluginGeneratedExecutorLegacy;
1396
- /**
1397
- * Extension options for modifying the source type
1398
- */
1399
- interface PluginExtends {
1400
- /**
1401
- * Fields to add to the source type.
1402
- * These fields will be merged into the original type's fields.
1403
- * Existing fields (from original definition or earlier plugins) take precedence.
1404
- */
1405
- fields?: Record<string, TailorAnyDBField>;
1406
- }
1407
- /**
1408
- * Base output returned by a plugin's process method.
1409
- * Used by both processType and processNamespace.
1410
- */
1411
- interface PluginOutput {
1412
- /**
1413
- * Additional TailorDB types to generate, keyed by kind identifier.
1414
- * The kind is used to generate distinct TypeScript type files.
1415
- * @example { request: changeRequest, step: changeStep }
1416
- */
1417
- types?: PluginGeneratedTypes;
1418
- /** Additional resolvers to generate */
1419
- resolvers?: PluginGeneratedResolver[];
1420
- /** Additional executors to generate */
1421
- executors?: PluginGeneratedExecutor[];
1422
- }
1423
- /**
1424
- * Output returned by a plugin's processType method.
1425
- * Extends PluginOutput with the ability to add fields to the source type.
1426
- */
1427
- interface TypePluginOutput extends PluginOutput {
1428
- /** Extensions to apply to the source type */
1429
- extends?: PluginExtends;
1430
- }
1431
- /**
1432
- * Output returned by a plugin's processNamespace method.
1433
- * Alias for PluginOutput (namespace plugins cannot extend a source type).
1434
- */
1435
- type NamespacePluginOutput = PluginOutput;
1436
- /**
1437
- * Plugin interface that all plugins must implement.
1438
- * @template TypeConfig - Type for per-type configuration passed via .plugin() method
1439
- * @template PluginConfig - Type for plugin-level configuration passed via definePlugins()
1440
- */
1441
- interface Plugin<TypeConfig = unknown, PluginConfig = unknown> {
1442
- /** Unique identifier for the plugin */
1443
- readonly id: string;
1444
- /** Human-readable description of the plugin */
1445
- readonly description: string;
1446
- /**
1447
- * Import path for this plugin's public API.
1448
- * Used by code generators to create correct import statements
1449
- * (e.g., plugin executors and seed schema generation).
1450
- */
1451
- readonly importPath: string;
1452
- /**
1453
- * Controls whether per-type plugin config is required when attaching via .plugin().
1454
- * If a function is provided, it receives pluginConfig from definePlugins().
1455
- * Default is optional when not provided.
1456
- */
1457
- readonly typeConfigRequired?: TypeConfigRequired<PluginConfig>;
1458
- /**
1459
- * Plugin-level configuration passed via definePlugins().
1460
- * This config is stored when the plugin is registered and made available
1461
- * to both processType() and processNamespace() methods.
1462
- */
1463
- readonly pluginConfig?: PluginConfig;
1464
- /**
1465
- * Process a single TailorDB type and generate outputs.
1466
- * This method is called for each type that has this plugin attached via .plugin().
1467
- * @param context - Context containing the type, config, pluginConfig, and namespace
1468
- * @returns Plugin output with generated types, resolvers, and executors
1469
- */
1470
- processType?(context: PluginProcessContext<TypeConfig, PluginConfig>): TypePluginOutput | Promise<TypePluginOutput>;
1471
- /**
1472
- * Process plugin for a namespace without requiring a source type.
1473
- * This method is called once per namespace for plugins configured via definePlugins().
1474
- * Use this for plugins that generate types independently of user-defined types.
1475
- * @param context - Context containing the plugin config, namespace, and types
1476
- * @returns Plugin output with generated types, resolvers, and executors
1477
- */
1478
- processNamespace?(context: PluginNamespaceProcessContext<PluginConfig>): NamespacePluginOutput | Promise<NamespacePluginOutput>;
1479
- }
1480
- //#endregion
1481
- //#region src/configure/services/tailordb/schema.d.ts
1482
- interface RelationConfig<S extends RelationType, T extends TailorDBType$1> {
1483
- type: S;
1484
- toward: {
1485
- type: T;
1486
- as?: string;
1487
- key?: keyof T["fields"] & string;
1488
- };
1489
- backward?: string;
1490
- }
1491
- type RelationSelfConfig = {
1492
- type: RelationType;
1493
- toward: {
1494
- type: "self";
1495
- as?: string;
1496
- key?: string;
1497
- };
1498
- backward?: string;
1499
- };
1500
- type TailorAnyDBField = TailorDBField<any, any>;
1501
- type TailorAnyDBType = TailorDBType$1<any, any>;
1502
- /**
1503
- * TailorDBField interface representing a database field with extended metadata.
1504
- * Extends TailorField with database-specific features like relations, indexes, and hooks.
1505
- */
1506
- interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends Omit<TailorField<Defined, Output, DBFieldMetadata, Defined["type"]>, "description" | "validate"> {
1507
- /** Returns a shallow copy of the raw relation config if set */
1508
- readonly rawRelation: Readonly<RawRelationConfig> | undefined;
1509
- /**
1510
- * Set a description for the field
1511
- * @param description - The description text
1512
- * @returns The field with updated metadata
1513
- */
1514
- description<CurrentDefined extends Defined>(this: CurrentDefined extends {
1515
- description: unknown;
1516
- } ? never : TailorField<CurrentDefined, Output>, description: string): TailorDBField<Prettify<CurrentDefined & {
1517
- description: true;
1518
- }>, Output>;
1519
- /**
1520
- * Define a relation to another type.
1521
- * Relation types: "n-1" (many-to-one), "1-1" (one-to-one), "keyOnly" (key only).
1522
- * Aliases "manyToOne", "oneToOne", and "N-1" are also accepted.
1523
- * @example db.uuid().relation({ type: "n-1", toward: { type: otherModel } })
1524
- * @example db.uuid().relation({ type: "1-1", toward: { type: profile } })
1525
- */
1526
- relation<S extends RelationType, T extends TailorAnyDBType, CurrentDefined extends Defined>(this: CurrentDefined extends {
1527
- relation: unknown;
1528
- } ? never : TailorDBField<CurrentDefined, Output>, config: RelationConfig<S, T>): TailorDBField<S extends "oneToOne" | "1-1" ? Prettify<CurrentDefined & {
1529
- unique: true;
1530
- index: true;
1531
- relation: true;
1532
- }> : Prettify<CurrentDefined & {
1533
- index: true;
1534
- relation: true;
1535
- }>, Output>;
1536
- /**
1537
- * Define a self-referencing relation
1538
- */
1539
- relation<S extends RelationSelfConfig, CurrentDefined extends Defined>(this: CurrentDefined extends {
1540
- relation: unknown;
1541
- } ? never : TailorDBField<CurrentDefined, Output>, config: S): TailorDBField<S["type"] extends "oneToOne" | "1-1" ? Prettify<CurrentDefined & {
1542
- unique: true;
1543
- index: true;
1544
- relation: true;
1545
- }> : Prettify<CurrentDefined & {
1546
- index: true;
1547
- relation: true;
1548
- }>, Output>;
1549
- /**
1550
- * Add an index to the field
1551
- */
1552
- index<CurrentDefined extends Defined>(this: CurrentDefined extends {
1553
- index: unknown;
1554
- } ? never : CurrentDefined extends {
1555
- array: true;
1556
- } ? never : TailorDBField<CurrentDefined, Output>): TailorDBField<Prettify<CurrentDefined & {
1557
- index: true;
1558
- }>, Output>;
1559
- /**
1560
- * Make the field unique (also adds an index)
1561
- */
1562
- unique<CurrentDefined extends Defined>(this: CurrentDefined extends {
1563
- unique: unknown;
1564
- } ? never : CurrentDefined extends {
1565
- array: true;
1566
- } ? never : TailorDBField<CurrentDefined, Output>): TailorDBField<Prettify<CurrentDefined & {
1567
- unique: true;
1568
- index: true;
1569
- }>, Output>;
1570
- /**
1571
- * Enable vector search on the field (string type only)
1572
- */
1573
- vector<CurrentDefined extends Defined>(this: CurrentDefined extends {
1574
- vector: unknown;
1575
- } ? never : CurrentDefined extends {
1576
- type: "string";
1577
- array: false;
1578
- } ? TailorDBField<CurrentDefined, Output> : never): TailorDBField<Prettify<CurrentDefined & {
1579
- vector: true;
1580
- }>, Output>;
1581
- /**
1582
- * Add hooks for create/update operations on this field.
1583
- * The hook function receives `{ value, data, user }` and returns the computed value.
1584
- * @example db.string().hooks({ create: ({ data }) => data.firstName + " " + data.lastName })
1585
- * @example db.datetime().hooks({ create: () => new Date(), update: () => new Date() })
1586
- */
1587
- hooks<CurrentDefined extends Defined, const H extends Hook<unknown, Output>>(this: CurrentDefined extends {
1588
- hooks: unknown;
1589
- } ? never : CurrentDefined extends {
1590
- type: "nested";
1591
- } ? never : TailorDBField<CurrentDefined, Output>, hooks: H): TailorDBField<Prettify<CurrentDefined & {
1592
- hooks?: {
1593
- create: H extends {
1594
- create: unknown;
1595
- } ? true : false;
1596
- update: H extends {
1597
- update: unknown;
1598
- } ? true : false;
1599
- };
1600
- serial: false;
1601
- }>, Output>;
1602
- /**
1603
- * Add validation functions to the field.
1604
- * Accepts a function or a tuple of [function, errorMessage].
1605
- * Prefer the tuple form for diagnosable errors.
1606
- * @example
1607
- * // Function form (default error message):
1608
- * db.int().validate(({ value }) => value >= 0)
1609
- * @example
1610
- * // Tuple form with custom error message (recommended):
1611
- * db.string().validate([({ value }) => value.length >= 8, "Must be at least 8 characters"])
1612
- */
1613
- validate<CurrentDefined extends Defined>(this: CurrentDefined extends {
1614
- validate: unknown;
1615
- } ? never : TailorDBField<CurrentDefined, Output>, ...validate: FieldValidateInput<Output>[]): TailorDBField<Prettify<CurrentDefined & {
1616
- validate: true;
1617
- }>, Output>;
1618
- /**
1619
- * Configure serial/auto-increment behavior
1620
- */
1621
- serial<CurrentDefined extends Defined>(this: CurrentDefined extends {
1622
- serial: unknown;
1623
- } ? never : Output extends null ? never : CurrentDefined extends {
1624
- type: "integer" | "string";
1625
- array: false;
1626
- } ? TailorDBField<CurrentDefined, Output> : never, config: SerialConfig<CurrentDefined["type"] & ("integer" | "string")>): TailorDBField<Prettify<CurrentDefined & {
1627
- serial: true;
1628
- hooks: {
1629
- create: false;
1630
- update: false;
1631
- };
1632
- }>, Output>;
1633
- /**
1634
- * Clone the field with optional overrides for field options
1635
- * @param options - Optional field options to override
1636
- * @returns A new TailorDBField instance with the same configuration
1637
- */
1638
- clone<const NewOpt extends FieldOptions>(options?: NewOpt): TailorDBField<Prettify<Omit<Defined, "array"> & {
1639
- array: NewOpt extends {
1640
- array: true;
1641
- } ? true : Defined["array"];
1642
- }>, FieldOutput$1<TailorToTs[Defined["type"]], NewOpt>>;
1643
- }
1644
- /**
1645
- * Create a UUID field.
1646
- * @param options - Field configuration options
1647
- * @returns A UUID field
1648
- * @example db.uuid()
1649
- * @example db.uuid({ optional: true })
1650
- */
1651
- declare function uuid<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1652
- type: "uuid";
1653
- array: Opt extends {
1654
- array: true;
1655
- } ? true : false;
1656
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1657
- /**
1658
- * Create a string field.
1659
- * @param options - Field configuration options
1660
- * @returns A string field
1661
- * @example db.string()
1662
- * @example db.string({ optional: true })
1663
- */
1664
- declare function string<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1665
- type: "string";
1666
- array: Opt extends {
1667
- array: true;
1668
- } ? true : false;
1669
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1670
- /**
1671
- * Create a boolean field.
1672
- * Note: The method name is `bool` but creates a `boolean` type field.
1673
- * @param options - Field configuration options
1674
- * @returns A boolean field
1675
- * @example db.bool()
1676
- * @example db.bool({ optional: true })
1677
- */
1678
- declare function bool<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1679
- type: "boolean";
1680
- array: Opt extends {
1681
- array: true;
1682
- } ? true : false;
1683
- }, Opt["optional"] extends true ? ArrayFieldOutput<boolean, Opt> | null : ArrayFieldOutput<boolean, Opt>>;
1684
- /**
1685
- * Create an integer field.
1686
- * @param options - Field configuration options
1687
- * @returns An integer field
1688
- * @example db.int()
1689
- * @example db.int({ optional: true })
1690
- */
1691
- declare function int<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1692
- type: "integer";
1693
- array: Opt extends {
1694
- array: true;
1695
- } ? true : false;
1696
- }, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
1697
- /**
1698
- * Create a float (decimal number) field.
1699
- * @param options - Field configuration options
1700
- * @returns A float field
1701
- * @example db.float()
1702
- * @example db.float({ optional: true })
1703
- */
1704
- declare function float<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1705
- type: "float";
1706
- array: Opt extends {
1707
- array: true;
1708
- } ? true : false;
1709
- }, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
1710
- /**
1711
- * Create a date field (date only, no time component).
1712
- * Format: "yyyy-MM-dd"
1713
- * @param options - Field configuration options
1714
- * @returns A date field
1715
- * @example db.date()
1716
- */
1717
- declare function date<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1718
- type: "date";
1719
- array: Opt extends {
1720
- array: true;
1721
- } ? true : false;
1722
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1723
- /**
1724
- * Create a datetime field (date and time).
1725
- * Format: ISO 8601 "yyyy-MM-ddTHH:mm:ssZ"
1726
- * @param options - Field configuration options
1727
- * @returns A datetime field
1728
- * @example db.datetime()
1729
- */
1730
- declare function datetime<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1731
- type: "datetime";
1732
- array: Opt extends {
1733
- array: true;
1734
- } ? true : false;
1735
- }, Opt["optional"] extends true ? ArrayFieldOutput<string | Date, Opt> | null : ArrayFieldOutput<string | Date, Opt>>;
1736
- /**
1737
- * Create a time field (time only, no date component).
1738
- * Format: "HH:mm"
1739
- * @param options - Field configuration options
1740
- * @returns A time field
1741
- * @example db.time()
1742
- */
1743
- declare function time<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
1744
- type: "time";
1745
- array: Opt extends {
1746
- array: true;
1747
- } ? true : false;
1748
- }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
1749
- /**
1750
- * Create an enum field with a fixed set of allowed string values.
1751
- * @param values - Array of allowed string values, or array of `{ value, description }` objects
1752
- * @param options - Field configuration options
1753
- * @returns An enum field
1754
- * @example db.enum(["active", "inactive", "suspended"])
1755
- * @example db.enum(["small", "medium", "large"], { optional: true })
1756
- */
1757
- declare function _enum<const V extends AllowedValues, const Opt extends FieldOptions>(values: V, options?: Opt): TailorDBField<{
1758
- type: "enum";
1759
- array: Opt extends {
1760
- array: true;
1761
- } ? true : false;
1762
- }, FieldOutput$1<AllowedValuesOutput<V>, Opt>>;
1763
- /**
1764
- * Create a nested object field with sub-fields.
1765
- * @param fields - Record of nested field definitions
1766
- * @param options - Field configuration options
1767
- * @returns A nested object field
1768
- * @example db.object({ street: db.string(), city: db.string(), zip: db.string() })
1769
- * @example db.object({ name: db.string() }, { optional: true })
1770
- */
1771
- declare function object<const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>, const Opt extends FieldOptions>(fields: F, options?: Opt): TailorDBField<{
1772
- type: "nested";
1773
- array: Opt extends {
1774
- array: true;
1775
- } ? true : false;
1776
- }, FieldOutput$1<InferFieldsOutput<F>, Opt>>;
1777
- /**
1778
- * TailorDBType interface representing a database type definition with fields, permissions, and settings.
1779
- */
1780
- interface TailorDBType$1<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> {
1781
- readonly name: string;
1782
- readonly fields: Fields;
1783
- readonly _output: InferFieldsOutput<Fields>;
1784
- _description?: string;
1785
- /** Returns metadata for the type */
1786
- readonly metadata: TailorDBTypeMetadata;
1787
- /**
1788
- * Add hooks for fields at the type level.
1789
- * Each key is a field name, and the value defines create/update hooks.
1790
- * @example
1791
- * db.type("Order", {
1792
- * total: db.float(),
1793
- * tax: db.float(),
1794
- * ...db.fields.timestamps(),
1795
- * }).hooks({
1796
- * tax: { create: ({ data }) => data.total * 0.1, update: ({ data }) => data.total * 0.1 },
1797
- * })
1798
- */
1799
- hooks(hooks: Hooks<Fields>): TailorDBType$1<Fields, User>;
1800
- /**
1801
- * Add validators for fields at the type level.
1802
- * Each key is a field name, and the value is a validator or array of validators.
1803
- * Prefer the tuple form [function, message] for diagnosable errors.
1804
- * @example
1805
- * db.type("User", { email: db.string() }).validate({
1806
- * email: [({ value }) => value.includes("@"), "Email must contain @"],
1807
- * })
1808
- */
1809
- validate(validators: Validators<Fields>): TailorDBType$1<Fields, User>;
1810
- /**
1811
- * Configure type features
1812
- */
1813
- features(features: Omit<TypeFeatures, "pluralForm">): TailorDBType$1<Fields, User>;
1814
- /**
1815
- * Define composite indexes
1816
- */
1817
- indexes(...indexes: IndexDef<TailorDBType$1<Fields, User>>[]): TailorDBType$1<Fields, User>;
1818
- /**
1819
- * Define file fields
1820
- */
1821
- files<const F extends string>(files: Record<F, string> & Partial<Record<keyof output<TailorDBType$1<Fields, User>>, never>>): TailorDBType$1<Fields, User>;
1822
- /**
1823
- * Set record-level permissions for create, read, update, and delete operations.
1824
- * Prefer object format with explicit `conditions` and `permit` for readability.
1825
- * For update operations, use `newRecord` and `oldRecord` operands.
1826
- * @example
1827
- * .permission({
1828
- * create: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
1829
- * read: [{ conditions: [[{ record: "isPublic" }, "=", true]], permit: true }],
1830
- * update: [{ conditions: [[{ newRecord: "ownerId" }, "=", { user: "id" }]], permit: true }],
1831
- * delete: [{ conditions: [[{ record: "ownerId" }, "=", { user: "id" }]], permit: true }],
1832
- * })
1833
- */
1834
- permission<U$1 extends object = User, P$1 extends TailorTypePermission<U$1, output<TailorDBType$1<Fields, User>>> = TailorTypePermission<U$1, output<TailorDBType$1<Fields, User>>>>(permission: P$1): TailorDBType$1<Fields, U$1>;
1835
- /**
1836
- * Set GraphQL-level permissions controlling access to GraphQL operations.
1837
- * @example
1838
- * .gqlPermission([
1839
- * {
1840
- * conditions: [[{ user: "_loggedIn" }, "=", true]],
1841
- * actions: "all",
1842
- * permit: true,
1843
- * },
1844
- * ])
1845
- */
1846
- gqlPermission<U$1 extends object = User, P$1 extends TailorTypeGqlPermission<U$1> = TailorTypeGqlPermission<U$1>>(permission: P$1): TailorDBType$1<Fields, U$1>;
1847
- /**
1848
- * Set type description
1849
- */
1850
- description(description: string): TailorDBType$1<Fields, User>;
1851
- /**
1852
- * Pick specific fields from the type
1853
- */
1854
- pickFields<K$1 extends keyof Fields, const Opt extends FieldOptions>(keys: K$1[], options: Opt): { [P in K$1]: Fields[P$1] extends TailorDBField<infer D, infer _O> ? TailorDBField<Omit<D, "array"> & {
1855
- array: Opt extends {
1856
- array: true;
1857
- } ? true : D["array"];
1858
- }, FieldOutput$1<TailorToTs[D["type"]], Opt>> : never };
1859
- /**
1860
- * Omit specific fields from the type
1861
- */
1862
- omitFields<K$1 extends keyof Fields>(keys: K$1[]): Omit<Fields, K$1>;
1863
- /**
1864
- * Plugin attachments for this type
1865
- */
1866
- readonly plugins: PluginAttachment[];
1867
- /**
1868
- * Attach a plugin to this type
1869
- * @param config - Plugin configuration in the format { pluginId: config }
1870
- * @returns The type with the plugin attached
1871
- */
1872
- plugin<P$1 extends keyof PluginConfigs<keyof Fields & string>>(config: { [K in P$1]: PluginConfigs<keyof Fields & string>[K$1] }): TailorDBType$1<Fields, User>;
1873
- }
1874
- type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> = TailorDBType$1<Fields, User>;
1875
- declare const idField: TailorDBField<{
1876
- type: "uuid";
1877
- array: false;
1878
- }, string>;
1879
- type idField = typeof idField;
1880
- type DBType<F extends {
1881
- id?: never;
1882
- } & Record<string, TailorAnyDBField>> = TailorDBInstance<{
1883
- id: idField;
1884
- } & F>;
1885
- /**
1886
- * Creates a new database type with the specified fields.
1887
- * An `id` field (UUID) is automatically added to every type.
1888
- * @param name - The name of the type, or a tuple of [name, pluralForm]
1889
- * @param fields - The field definitions for the type
1890
- * @returns A new TailorDBType instance
1891
- * @example
1892
- * export const user = db.type("User", {
1893
- * name: db.string(),
1894
- * email: db.string(),
1895
- * age: db.int({ optional: true }),
1896
- * role: db.enum(["admin", "member"]),
1897
- * ...db.fields.timestamps(),
1898
- * });
1899
- * // Always export both the value and type:
1900
- * export type user = typeof user;
1901
- */
1902
- declare function dbType<const F extends {
1903
- id?: never;
1904
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
1905
- /**
1906
- * Creates a new database type with the specified fields and description.
1907
- * An `id` field (UUID) is automatically added to every type.
1908
- * @param name - The name of the type, or a tuple of [name, pluralForm]
1909
- * @param description - A description of the type
1910
- * @param fields - The field definitions for the type
1911
- * @returns A new TailorDBType instance
1912
- */
1913
- declare function dbType<const F extends {
1914
- id?: never;
1915
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBType<F>;
1916
- declare const db: {
1917
- type: typeof dbType;
1918
- uuid: typeof uuid;
1919
- string: typeof string;
1920
- bool: typeof bool;
1921
- int: typeof int;
1922
- float: typeof float;
1923
- date: typeof date;
1924
- datetime: typeof datetime;
1925
- time: typeof time;
1926
- enum: typeof _enum;
1927
- object: typeof object;
1928
- fields: {
1929
- /**
1930
- * Creates standard timestamp fields (createdAt, updatedAt) with auto-hooks.
1931
- * createdAt is set on create, updatedAt is set on update.
1932
- * @returns An object with createdAt and updatedAt fields
1933
- * @example
1934
- * const model = db.type("Model", {
1935
- * name: db.string(),
1936
- * ...db.fields.timestamps(),
1937
- * });
1938
- */
1939
- timestamps: () => {
1940
- createdAt: TailorDBField<{
1941
- type: "datetime";
1942
- array: false;
1943
- hooks?: {
1944
- create: true;
1945
- update: false;
1946
- } | undefined;
1947
- serial: false;
1948
- description: true;
1949
- }, string | Date>;
1950
- updatedAt: TailorDBField<{
1951
- type: "datetime";
1952
- array: false;
1953
- hooks?: {
1954
- create: false;
1955
- update: true;
1956
- } | undefined;
1957
- serial: false;
1958
- description: true;
1959
- }, string | Date | null>;
1960
- };
1961
- };
1962
- };
1148
+ //#region src/parser/generator-config/types.d.ts
1149
+ type GeneratorConfig = z.input<typeof BaseGeneratorConfigSchema>;
1150
+ //#endregion
1151
+ //#region src/parser/generator-config/index.d.ts
1152
+ declare const BaseGeneratorConfigSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"@tailor-platform/kysely-type">, z.ZodObject<{
1153
+ distPath: z.ZodString;
1154
+ }, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/seed">, z.ZodObject<{
1155
+ distPath: z.ZodString;
1156
+ machineUserName: z.ZodOptional<z.ZodString>;
1157
+ }, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/enum-constants">, z.ZodObject<{
1158
+ distPath: z.ZodString;
1159
+ }, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/file-utils">, z.ZodObject<{
1160
+ distPath: z.ZodString;
1161
+ }, z.core.$strip>], null>, z.ZodObject<{
1162
+ id: z.ZodString;
1163
+ description: z.ZodString;
1164
+ dependencies: z.ZodArray<z.ZodEnum<{
1165
+ executor: "executor";
1166
+ tailordb: "tailordb";
1167
+ resolver: "resolver";
1168
+ }>>;
1169
+ processType: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
1170
+ processResolver: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
1171
+ processExecutor: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
1172
+ processTailorDBNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
1173
+ processResolverNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
1174
+ aggregate: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodAny>;
1175
+ }, z.core.$strip>]>;
1963
1176
  //#endregion
1964
1177
  //#region src/parser/service/auth/schema.d.ts
1965
1178
  declare const AuthInvokerSchema: z.ZodObject<{
@@ -2064,188 +1277,1311 @@ declare const SCIMAttributeSchema: z.ZodObject<{
2064
1277
  canonicalValues: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
2065
1278
  subAttributes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject< /*elided*/any, z.core.$strip>>>>;
2066
1279
  }, z.core.$strip>;
2067
- declare const SCIMAttributeMappingSchema: z.ZodObject<{
2068
- tailorDBField: z.ZodString;
2069
- scimPath: z.ZodString;
1280
+ declare const SCIMAttributeMappingSchema: z.ZodObject<{
1281
+ tailorDBField: z.ZodString;
1282
+ scimPath: z.ZodString;
1283
+ }, z.core.$strip>;
1284
+ declare const SCIMResourceSchema: z.ZodObject<{
1285
+ name: z.ZodString;
1286
+ tailorDBNamespace: z.ZodString;
1287
+ tailorDBType: z.ZodString;
1288
+ coreSchema: z.ZodObject<{
1289
+ name: z.ZodString;
1290
+ attributes: z.ZodArray<z.ZodObject<{
1291
+ type: z.ZodUnion<readonly [z.ZodLiteral<"string">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"datetime">, z.ZodLiteral<"complex">]>;
1292
+ name: z.ZodString;
1293
+ description: z.ZodOptional<z.ZodString>;
1294
+ mutability: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"readOnly">, z.ZodLiteral<"readWrite">, z.ZodLiteral<"writeOnly">]>>;
1295
+ required: z.ZodOptional<z.ZodBoolean>;
1296
+ multiValued: z.ZodOptional<z.ZodBoolean>;
1297
+ uniqueness: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodLiteral<"server">, z.ZodLiteral<"global">]>>;
1298
+ canonicalValues: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
1299
+ subAttributes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject< /*elided*/any, z.core.$strip>>>>;
1300
+ }, z.core.$strip>>;
1301
+ }, z.core.$strip>;
1302
+ attributeMapping: z.ZodArray<z.ZodObject<{
1303
+ tailorDBField: z.ZodString;
1304
+ scimPath: z.ZodString;
1305
+ }, z.core.$strip>>;
1306
+ }, z.core.$strip>;
1307
+ declare const SCIMSchema: z.ZodObject<{
1308
+ machineUserName: z.ZodString;
1309
+ authorization: z.ZodObject<{
1310
+ type: z.ZodUnion<readonly [z.ZodLiteral<"oauth2">, z.ZodLiteral<"bearer">]>;
1311
+ bearerSecret: z.ZodOptional<z.ZodObject<{
1312
+ vaultName: z.ZodString;
1313
+ secretKey: z.ZodString;
1314
+ }, z.core.$strip>>;
1315
+ }, z.core.$strip>;
1316
+ resources: z.ZodArray<z.ZodObject<{
1317
+ name: z.ZodString;
1318
+ tailorDBNamespace: z.ZodString;
1319
+ tailorDBType: z.ZodString;
1320
+ coreSchema: z.ZodObject<{
1321
+ name: z.ZodString;
1322
+ attributes: z.ZodArray<z.ZodObject<{
1323
+ type: z.ZodUnion<readonly [z.ZodLiteral<"string">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"datetime">, z.ZodLiteral<"complex">]>;
1324
+ name: z.ZodString;
1325
+ description: z.ZodOptional<z.ZodString>;
1326
+ mutability: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"readOnly">, z.ZodLiteral<"readWrite">, z.ZodLiteral<"writeOnly">]>>;
1327
+ required: z.ZodOptional<z.ZodBoolean>;
1328
+ multiValued: z.ZodOptional<z.ZodBoolean>;
1329
+ uniqueness: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodLiteral<"server">, z.ZodLiteral<"global">]>>;
1330
+ canonicalValues: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
1331
+ subAttributes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject< /*elided*/any, z.core.$strip>>>>;
1332
+ }, z.core.$strip>>;
1333
+ }, z.core.$strip>;
1334
+ attributeMapping: z.ZodArray<z.ZodObject<{
1335
+ tailorDBField: z.ZodString;
1336
+ scimPath: z.ZodString;
1337
+ }, z.core.$strip>>;
1338
+ }, z.core.$strip>>;
1339
+ }, z.core.$strip>;
1340
+ declare const TenantProviderSchema: z.ZodObject<{
1341
+ namespace: z.ZodString;
1342
+ type: z.ZodString;
1343
+ signatureField: z.ZodString;
1344
+ }, z.core.$strip>;
1345
+ //#endregion
1346
+ //#region src/parser/service/auth/types.d.ts
1347
+ type AuthInvoker = z.output<typeof AuthInvokerSchema>;
1348
+ type AuthInvokerWithName<M extends string> = Omit<AuthInvoker, "machineUserName"> & {
1349
+ machineUserName: M;
1350
+ };
1351
+ type OIDC = z.output<typeof OIDCSchema>;
1352
+ type SAML = z.output<typeof SAMLSchema>;
1353
+ type IDToken = z.output<typeof IDTokenSchema>;
1354
+ type BuiltinIdP = z.output<typeof BuiltinIdPSchema>;
1355
+ type IdProviderConfig = z.output<typeof IdProviderSchema>;
1356
+ type OAuth2ClientGrantType = z.output<typeof OAuth2ClientGrantTypeSchema>;
1357
+ type OAuth2ClientInput = z.input<typeof OAuth2ClientSchema>;
1358
+ type SCIMAuthorization = z.output<typeof SCIMAuthorizationSchema>;
1359
+ type SCIMAttributeType = z.output<typeof SCIMAttributeTypeSchema>;
1360
+ type SCIMAttribute = z.output<typeof SCIMAttributeSchema>;
1361
+ type SCIMAttributeMapping = z.output<typeof SCIMAttributeMappingSchema>;
1362
+ type SCIMResource = z.output<typeof SCIMResourceSchema>;
1363
+ type SCIMConfig = z.output<typeof SCIMSchema>;
1364
+ type TenantProviderConfig = z.output<typeof TenantProviderSchema>;
1365
+ type ValueOperand = string | boolean | string[] | boolean[];
1366
+ type AuthAttributeValue = ValueOperand | null | undefined;
1367
+ type UserFieldKeys<User extends TailorDBInstance> = keyof output<User> & string;
1368
+ type FieldDefined<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = User["fields"][Key] extends {
1369
+ _defined: infer Defined;
1370
+ } ? Defined : never;
1371
+ type FieldOutput<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = output<User>[Key];
1372
+ type FieldIsRequired<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = undefined extends FieldOutput<User, Key> ? false : true;
1373
+ type FieldIsOfType<User extends TailorDBInstance, Key extends UserFieldKeys<User>, Type extends string> = FieldDefined<User, Key> extends {
1374
+ type: Type;
1375
+ } ? true : false;
1376
+ type FieldIsArray<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
1377
+ array: true;
1378
+ } ? true : false;
1379
+ type FieldIsUnique<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
1380
+ unique: true;
1381
+ } ? true : false;
1382
+ type FieldSupportsValueOperand<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldOutput<User, Key> extends ValueOperand | null | undefined ? true : false;
1383
+ type UsernameFieldKey<User extends TailorDBInstance> = IsAny<User> extends true ? string : { [K in UserFieldKeys<User>]: FieldIsRequired<User, K> extends true ? FieldIsOfType<User, K, "string"> extends true ? FieldIsArray<User, K> extends true ? never : FieldIsUnique<User, K> extends true ? K : never : never : never }[UserFieldKeys<User>];
1384
+ type UserAttributeKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldSupportsValueOperand<User, K> extends true ? FieldIsOfType<User, K, "datetime" | "date" | "time"> extends true ? never : K : never }[UserFieldKeys<User>];
1385
+ type UserAttributeListKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldIsOfType<User, K, "uuid"> extends true ? FieldIsArray<User, K> extends true ? never : K : never }[UserFieldKeys<User>];
1386
+ type UserAttributeMap<User extends TailorDBInstance> = { [K in UserAttributeKey<User>]?: true };
1387
+ type DisallowExtraKeys<T, Allowed extends PropertyKey> = T & { [K in Exclude<keyof T, Allowed>]: never };
1388
+ type AttributeListValue<User extends TailorDBInstance, Key extends UserAttributeListKey<User>> = Key extends keyof output<User> ? output<User>[Key] : never;
1389
+ type AttributeListToTuple<User extends TailorDBInstance, AttributeList$1 extends readonly UserAttributeListKey<User>[]> = { [Index in keyof AttributeList$1]: AttributeList$1[Index] extends UserAttributeListKey<User> ? AttributeListValue<User, AttributeList$1[Index]> : never };
1390
+ type AttributeMapSelectedKeys<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User>> = Extract<{ [K in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K] ? never : K }[keyof AttributeMap$1], UserAttributeKey<User>>;
1391
+ type UserProfile<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User>, AttributeList$1 extends UserAttributeListKey<User>[]> = {
1392
+ /**
1393
+ * TailorDB namespace where the user type is defined.
1394
+ *
1395
+ * Usually auto-resolved, so you don't need to specify this.
1396
+ * Required only when multiple TailorDBs exist and the type is in an external TailorDB.
1397
+ */
1398
+ namespace?: string;
1399
+ type: User;
1400
+ usernameField: UsernameFieldKey<User>;
1401
+ attributes?: DisallowExtraKeys<AttributeMap$1, UserAttributeKey<User>>;
1402
+ attributeList?: AttributeList$1;
1403
+ };
1404
+ type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
1405
+ type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
1406
+ type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never };
1407
+ type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
1408
+ attributes?: never;
1409
+ } : {
1410
+ attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
1411
+ }) & {
1412
+ attributeList?: string[];
1413
+ };
1414
+ type MachineUser<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User> = UserAttributeMap<User>, AttributeList$1 extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
1415
+ attributes: Record<string, AuthAttributeValue>;
1416
+ attributeList?: string[];
1417
+ } : (AttributeMapSelectedKeys<User, AttributeMap$1> extends never ? {
1418
+ attributes?: never;
1419
+ } : {
1420
+ attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap$1>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap$1>>]?: never };
1421
+ }) & ([] extends AttributeList$1 ? {
1422
+ attributeList?: never;
1423
+ } : {
1424
+ attributeList: AttributeListToTuple<User, AttributeList$1>;
1425
+ }) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
1426
+ attributes: Record<string, AuthAttributeValue>;
1427
+ attributeList?: string[];
1428
+ } : (AttributeMapSelectedKeys<User, AttributeMap$1> extends never ? {
1429
+ attributes?: never;
1430
+ } : {
1431
+ attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap$1>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap$1>>]?: never };
1432
+ }) & ([] extends AttributeList$1 ? {
1433
+ attributeList?: never;
1434
+ } : {
1435
+ attributeList: AttributeListToTuple<User, AttributeList$1>;
1436
+ });
1437
+ type AuthServiceInput<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User>, AttributeList$1 extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined> = {
1438
+ userProfile?: UserProfile<User, AttributeMap$1, AttributeList$1>;
1439
+ machineUserAttributes?: MachineUserAttributes;
1440
+ machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap$1, AttributeList$1, MachineUserAttributes>>;
1441
+ oauth2Clients?: Record<string, OAuth2ClientInput>;
1442
+ idProvider?: IdProviderConfig;
1443
+ scim?: SCIMConfig;
1444
+ tenantProvider?: TenantProviderConfig;
1445
+ publishSessionEvents?: boolean;
1446
+ };
1447
+ declare const authDefinitionBrand: unique symbol;
1448
+ type AuthDefinitionBrand = {
1449
+ readonly [authDefinitionBrand]: true;
1450
+ };
1451
+ type DefinedAuth<Name extends string, Config, MachineUserNames extends string> = Config & {
1452
+ name: Name;
1453
+ invoker<M extends MachineUserNames>(machineUser: M): AuthInvokerWithName<M>;
1454
+ } & AuthDefinitionBrand;
1455
+ type AuthExternalConfig = {
1456
+ name: string;
1457
+ external: true;
1458
+ };
1459
+ type AuthServiceInputLoose = AuthServiceInput<any, any, any, string, any>;
1460
+ type AuthOwnConfig = DefinedAuth<string, AuthServiceInputLoose, string>;
1461
+ type AuthConfig = AuthOwnConfig | AuthExternalConfig;
1462
+ //#endregion
1463
+ //#region src/parser/service/executor/schema.d.ts
1464
+ declare const RecordTriggerSchema: z.ZodObject<{
1465
+ kind: z.ZodEnum<{
1466
+ recordCreated: "recordCreated";
1467
+ recordUpdated: "recordUpdated";
1468
+ recordDeleted: "recordDeleted";
1469
+ }>;
1470
+ typeName: z.ZodString;
1471
+ condition: z.ZodOptional<z.ZodCustom<Function, Function>>;
1472
+ }, z.core.$strip>;
1473
+ declare const ResolverExecutedTriggerSchema: z.ZodObject<{
1474
+ kind: z.ZodLiteral<"resolverExecuted">;
1475
+ resolverName: z.ZodString;
1476
+ condition: z.ZodOptional<z.ZodCustom<Function, Function>>;
1477
+ }, z.core.$strip>;
1478
+ declare const ScheduleTriggerSchema: z.ZodObject<{
1479
+ kind: z.ZodLiteral<"schedule">;
1480
+ cron: z.ZodString;
1481
+ timezone: z.ZodDefault<z.ZodOptional<z.ZodString>>;
1482
+ }, z.core.$strip>;
1483
+ declare const IncomingWebhookTriggerSchema: z.ZodObject<{
1484
+ kind: z.ZodLiteral<"incomingWebhook">;
1485
+ }, z.core.$strip>;
1486
+ declare const IdpUserTriggerSchema: z.ZodObject<{
1487
+ kind: z.ZodEnum<{
1488
+ idpUserCreated: "idpUserCreated";
1489
+ idpUserUpdated: "idpUserUpdated";
1490
+ idpUserDeleted: "idpUserDeleted";
1491
+ }>;
1492
+ }, z.core.$strip>;
1493
+ declare const AuthAccessTokenTriggerSchema: z.ZodObject<{
1494
+ kind: z.ZodEnum<{
1495
+ authAccessTokenIssued: "authAccessTokenIssued";
1496
+ authAccessTokenRefreshed: "authAccessTokenRefreshed";
1497
+ authAccessTokenRevoked: "authAccessTokenRevoked";
1498
+ }>;
1499
+ }, z.core.$strip>;
1500
+ declare const FunctionOperationSchema: z.ZodObject<{
1501
+ kind: z.ZodEnum<{
1502
+ function: "function";
1503
+ jobFunction: "jobFunction";
1504
+ }>;
1505
+ body: z.ZodCustom<Function, Function>;
1506
+ authInvoker: z.ZodOptional<z.ZodObject<{
1507
+ namespace: z.ZodString;
1508
+ machineUserName: z.ZodString;
1509
+ }, z.core.$strip>>;
1510
+ }, z.core.$strip>;
1511
+ declare const GqlOperationSchema: z.ZodObject<{
1512
+ kind: z.ZodLiteral<"graphql">;
1513
+ appName: z.ZodOptional<z.ZodString>;
1514
+ query: z.ZodPipe<z.ZodTransform<string, unknown>, z.ZodString>;
1515
+ variables: z.ZodOptional<z.ZodCustom<Function, Function>>;
1516
+ authInvoker: z.ZodOptional<z.ZodObject<{
1517
+ namespace: z.ZodString;
1518
+ machineUserName: z.ZodString;
1519
+ }, z.core.$strip>>;
2070
1520
  }, z.core.$strip>;
2071
- declare const SCIMResourceSchema: z.ZodObject<{
1521
+ declare const WebhookOperationSchema: z.ZodObject<{
1522
+ kind: z.ZodLiteral<"webhook">;
1523
+ url: z.ZodCustom<Function, Function>;
1524
+ requestBody: z.ZodOptional<z.ZodCustom<Function, Function>>;
1525
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1526
+ vault: z.ZodString;
1527
+ key: z.ZodString;
1528
+ }, z.core.$strip>]>>>;
1529
+ }, z.core.$strip>;
1530
+ declare const WorkflowOperationSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
1531
+ kind: z.ZodLiteral<"workflow">;
1532
+ workflowName: z.ZodString;
1533
+ args: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodCustom<Function, Function>]>>;
1534
+ authInvoker: z.ZodOptional<z.ZodObject<{
1535
+ namespace: z.ZodString;
1536
+ machineUserName: z.ZodString;
1537
+ }, z.core.$strip>>;
1538
+ }, z.core.$strip>>;
1539
+ declare const ExecutorSchema: z.ZodObject<{
2072
1540
  name: z.ZodString;
2073
- tailorDBNamespace: z.ZodString;
2074
- tailorDBType: z.ZodString;
2075
- coreSchema: z.ZodObject<{
2076
- name: z.ZodString;
2077
- attributes: z.ZodArray<z.ZodObject<{
2078
- type: z.ZodUnion<readonly [z.ZodLiteral<"string">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"datetime">, z.ZodLiteral<"complex">]>;
2079
- name: z.ZodString;
2080
- description: z.ZodOptional<z.ZodString>;
2081
- mutability: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"readOnly">, z.ZodLiteral<"readWrite">, z.ZodLiteral<"writeOnly">]>>;
2082
- required: z.ZodOptional<z.ZodBoolean>;
2083
- multiValued: z.ZodOptional<z.ZodBoolean>;
2084
- uniqueness: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodLiteral<"server">, z.ZodLiteral<"global">]>>;
2085
- canonicalValues: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
2086
- subAttributes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject< /*elided*/any, z.core.$strip>>>>;
1541
+ description: z.ZodOptional<z.ZodString>;
1542
+ disabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1543
+ trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
1544
+ kind: z.ZodEnum<{
1545
+ recordCreated: "recordCreated";
1546
+ recordUpdated: "recordUpdated";
1547
+ recordDeleted: "recordDeleted";
1548
+ }>;
1549
+ typeName: z.ZodString;
1550
+ condition: z.ZodOptional<z.ZodCustom<Function, Function>>;
1551
+ }, z.core.$strip>, z.ZodObject<{
1552
+ kind: z.ZodLiteral<"resolverExecuted">;
1553
+ resolverName: z.ZodString;
1554
+ condition: z.ZodOptional<z.ZodCustom<Function, Function>>;
1555
+ }, z.core.$strip>, z.ZodObject<{
1556
+ kind: z.ZodLiteral<"schedule">;
1557
+ cron: z.ZodString;
1558
+ timezone: z.ZodDefault<z.ZodOptional<z.ZodString>>;
1559
+ }, z.core.$strip>, z.ZodObject<{
1560
+ kind: z.ZodLiteral<"incomingWebhook">;
1561
+ }, z.core.$strip>, z.ZodObject<{
1562
+ kind: z.ZodEnum<{
1563
+ idpUserCreated: "idpUserCreated";
1564
+ idpUserUpdated: "idpUserUpdated";
1565
+ idpUserDeleted: "idpUserDeleted";
1566
+ }>;
1567
+ }, z.core.$strip>, z.ZodObject<{
1568
+ kind: z.ZodEnum<{
1569
+ authAccessTokenIssued: "authAccessTokenIssued";
1570
+ authAccessTokenRefreshed: "authAccessTokenRefreshed";
1571
+ authAccessTokenRevoked: "authAccessTokenRevoked";
1572
+ }>;
1573
+ }, z.core.$strip>], "kind">;
1574
+ operation: z.ZodUnion<readonly [z.ZodObject<{
1575
+ kind: z.ZodEnum<{
1576
+ function: "function";
1577
+ jobFunction: "jobFunction";
1578
+ }>;
1579
+ body: z.ZodCustom<Function, Function>;
1580
+ authInvoker: z.ZodOptional<z.ZodObject<{
1581
+ namespace: z.ZodString;
1582
+ machineUserName: z.ZodString;
2087
1583
  }, z.core.$strip>>;
2088
- }, z.core.$strip>;
2089
- attributeMapping: z.ZodArray<z.ZodObject<{
2090
- tailorDBField: z.ZodString;
2091
- scimPath: z.ZodString;
2092
- }, z.core.$strip>>;
2093
- }, z.core.$strip>;
2094
- declare const SCIMSchema: z.ZodObject<{
2095
- machineUserName: z.ZodString;
2096
- authorization: z.ZodObject<{
2097
- type: z.ZodUnion<readonly [z.ZodLiteral<"oauth2">, z.ZodLiteral<"bearer">]>;
2098
- bearerSecret: z.ZodOptional<z.ZodObject<{
2099
- vaultName: z.ZodString;
2100
- secretKey: z.ZodString;
1584
+ }, z.core.$strip>, z.ZodObject<{
1585
+ kind: z.ZodLiteral<"graphql">;
1586
+ appName: z.ZodOptional<z.ZodString>;
1587
+ query: z.ZodPipe<z.ZodTransform<string, unknown>, z.ZodString>;
1588
+ variables: z.ZodOptional<z.ZodCustom<Function, Function>>;
1589
+ authInvoker: z.ZodOptional<z.ZodObject<{
1590
+ namespace: z.ZodString;
1591
+ machineUserName: z.ZodString;
2101
1592
  }, z.core.$strip>>;
2102
- }, z.core.$strip>;
2103
- resources: z.ZodArray<z.ZodObject<{
2104
- name: z.ZodString;
2105
- tailorDBNamespace: z.ZodString;
2106
- tailorDBType: z.ZodString;
2107
- coreSchema: z.ZodObject<{
2108
- name: z.ZodString;
2109
- attributes: z.ZodArray<z.ZodObject<{
2110
- type: z.ZodUnion<readonly [z.ZodLiteral<"string">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"datetime">, z.ZodLiteral<"complex">]>;
2111
- name: z.ZodString;
2112
- description: z.ZodOptional<z.ZodString>;
2113
- mutability: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"readOnly">, z.ZodLiteral<"readWrite">, z.ZodLiteral<"writeOnly">]>>;
2114
- required: z.ZodOptional<z.ZodBoolean>;
2115
- multiValued: z.ZodOptional<z.ZodBoolean>;
2116
- uniqueness: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodLiteral<"server">, z.ZodLiteral<"global">]>>;
2117
- canonicalValues: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
2118
- subAttributes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject< /*elided*/any, z.core.$strip>>>>;
2119
- }, z.core.$strip>>;
2120
- }, z.core.$strip>;
2121
- attributeMapping: z.ZodArray<z.ZodObject<{
2122
- tailorDBField: z.ZodString;
2123
- scimPath: z.ZodString;
1593
+ }, z.core.$strip>, z.ZodObject<{
1594
+ kind: z.ZodLiteral<"webhook">;
1595
+ url: z.ZodCustom<Function, Function>;
1596
+ requestBody: z.ZodOptional<z.ZodCustom<Function, Function>>;
1597
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1598
+ vault: z.ZodString;
1599
+ key: z.ZodString;
1600
+ }, z.core.$strip>]>>>;
1601
+ }, z.core.$strip>, z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
1602
+ kind: z.ZodLiteral<"workflow">;
1603
+ workflowName: z.ZodString;
1604
+ args: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodCustom<Function, Function>]>>;
1605
+ authInvoker: z.ZodOptional<z.ZodObject<{
1606
+ namespace: z.ZodString;
1607
+ machineUserName: z.ZodString;
2124
1608
  }, z.core.$strip>>;
2125
- }, z.core.$strip>>;
2126
- }, z.core.$strip>;
2127
- declare const TenantProviderSchema: z.ZodObject<{
2128
- namespace: z.ZodString;
2129
- type: z.ZodString;
2130
- signatureField: z.ZodString;
1609
+ }, z.core.$strip>>]>;
2131
1610
  }, z.core.$strip>;
2132
1611
  //#endregion
2133
- //#region src/parser/service/auth/types.d.ts
2134
- type AuthInvoker = z.output<typeof AuthInvokerSchema>;
2135
- type AuthInvokerWithName<M extends string> = Omit<AuthInvoker, "machineUserName"> & {
2136
- machineUserName: M;
1612
+ //#region src/parser/service/executor/types.d.ts
1613
+ type RecordTrigger = z.infer<typeof RecordTriggerSchema>;
1614
+ type ResolverExecutedTrigger = z.infer<typeof ResolverExecutedTriggerSchema>;
1615
+ type ScheduleTriggerInput = z.input<typeof ScheduleTriggerSchema>;
1616
+ type IncomingWebhookTrigger = z.infer<typeof IncomingWebhookTriggerSchema>;
1617
+ type IdpUserTrigger = z.infer<typeof IdpUserTriggerSchema>;
1618
+ type AuthAccessTokenTrigger = z.infer<typeof AuthAccessTokenTriggerSchema>;
1619
+ type FunctionOperation = z.infer<typeof FunctionOperationSchema>;
1620
+ type GqlOperation = z.infer<typeof GqlOperationSchema>;
1621
+ type WebhookOperation = z.infer<typeof WebhookOperationSchema>;
1622
+ type WorkflowOperation = z.infer<typeof WorkflowOperationSchema>;
1623
+ type Executor = z.infer<typeof ExecutorSchema>;
1624
+ type ExecutorInput = z.input<typeof ExecutorSchema>;
1625
+ type ExecutorServiceConfig = {
1626
+ files: string[];
1627
+ ignores?: string[];
1628
+ };
1629
+ type ExecutorServiceInput = ExecutorServiceConfig;
1630
+ //#endregion
1631
+ //#region src/parser/plugin-config/generation-types.d.ts
1632
+ /**
1633
+ * A single generated file to write to disk.
1634
+ */
1635
+ interface GeneratedFile {
1636
+ path: string;
1637
+ content: string;
1638
+ skipIfExists?: boolean;
1639
+ executable?: boolean;
1640
+ }
1641
+ /**
1642
+ * Result returned by generation-time hooks.
1643
+ */
1644
+ interface GeneratorResult {
1645
+ files: GeneratedFile[];
1646
+ errors?: string[];
1647
+ }
1648
+ /**
1649
+ * Auth configuration available to generation-time hooks.
1650
+ */
1651
+ interface GeneratorAuthInput {
1652
+ name: string;
1653
+ userProfile?: {
1654
+ typeName: string;
1655
+ namespace: string;
1656
+ usernameField: string;
1657
+ };
1658
+ machineUsers?: Record<string, {
1659
+ attributes: Record<string, unknown>;
1660
+ }>;
1661
+ oauth2Clients?: Record<string, OAuth2ClientInput>;
1662
+ idProvider?: IdProviderConfig;
1663
+ }
1664
+ /**
1665
+ * Namespace-level TailorDB data available to generation-time hooks.
1666
+ */
1667
+ interface TailorDBNamespaceData {
1668
+ /** Namespace name */
1669
+ namespace: string;
1670
+ /** All TailorDB types in this namespace, keyed by type name */
1671
+ types: Record<string, TailorDBType>;
1672
+ /** Source info for each type (file path, export name, plugin info) */
1673
+ sourceInfo: ReadonlyMap<string, TypeSourceInfoEntry>;
1674
+ /** Plugin attachments configured on each type via .plugin() method */
1675
+ pluginAttachments: ReadonlyMap<string, readonly PluginAttachment[]>;
1676
+ }
1677
+ /**
1678
+ * Namespace-level resolver data available to generation-time hooks.
1679
+ */
1680
+ interface ResolverNamespaceData {
1681
+ /** Namespace name */
1682
+ namespace: string;
1683
+ /** All resolvers in this namespace, keyed by resolver name */
1684
+ resolvers: Record<string, Resolver>;
1685
+ }
1686
+ /**
1687
+ * Context passed to plugin's onTailorDBReady hook.
1688
+ * Called after all TailorDB types are loaded and finalized.
1689
+ * @template PluginConfig - Plugin-level configuration type
1690
+ */
1691
+ interface TailorDBReadyContext<PluginConfig = unknown> {
1692
+ /** All TailorDB namespaces with their types and metadata */
1693
+ tailordb: TailorDBNamespaceData[];
1694
+ /** Auth configuration */
1695
+ auth?: GeneratorAuthInput;
1696
+ /** Base directory for generated files */
1697
+ baseDir: string;
1698
+ /** Path to tailor.config.ts */
1699
+ configPath: string;
1700
+ /** Plugin-level configuration passed via definePlugins() */
1701
+ pluginConfig: PluginConfig;
1702
+ }
1703
+ /**
1704
+ * Context passed to plugin's onResolverReady hook.
1705
+ * Called after all resolvers are loaded and finalized.
1706
+ * @template PluginConfig - Plugin-level configuration type
1707
+ */
1708
+ interface ResolverReadyContext<PluginConfig = unknown> {
1709
+ /** All TailorDB namespaces with their types and metadata */
1710
+ tailordb: TailorDBNamespaceData[];
1711
+ /** All resolver namespaces with their resolvers */
1712
+ resolvers: ResolverNamespaceData[];
1713
+ /** Auth configuration */
1714
+ auth?: GeneratorAuthInput;
1715
+ /** Base directory for generated files */
1716
+ baseDir: string;
1717
+ /** Path to tailor.config.ts */
1718
+ configPath: string;
1719
+ /** Plugin-level configuration passed via definePlugins() */
1720
+ pluginConfig: PluginConfig;
1721
+ }
1722
+ /**
1723
+ * Context passed to plugin's onExecutorReady hook.
1724
+ * Called after all executors are loaded and finalized.
1725
+ * @template PluginConfig - Plugin-level configuration type
1726
+ */
1727
+ interface ExecutorReadyContext<PluginConfig = unknown> {
1728
+ /** All TailorDB namespaces with their types and metadata */
1729
+ tailordb: TailorDBNamespaceData[];
1730
+ /** All resolver namespaces with their resolvers */
1731
+ resolvers: ResolverNamespaceData[];
1732
+ /** All executors, keyed by executor name */
1733
+ executors: Record<string, Executor>;
1734
+ /** Auth configuration */
1735
+ auth?: GeneratorAuthInput;
1736
+ /** Base directory for generated files */
1737
+ baseDir: string;
1738
+ /** Path to tailor.config.ts */
1739
+ configPath: string;
1740
+ /** Plugin-level configuration passed via definePlugins() */
1741
+ pluginConfig: PluginConfig;
1742
+ }
1743
+ //#endregion
1744
+ //#region src/parser/plugin-config/types.d.ts
1745
+ type TypeConfigRequired<PluginConfig = unknown> = boolean | ((pluginConfig: PluginConfig | undefined) => boolean);
1746
+ /**
1747
+ * Interface for plugin configuration mapping.
1748
+ * Extend this interface via declaration merging to add typed plugin configs.
1749
+ *
1750
+ * The `Fields` type parameter provides field names from the type being configured,
1751
+ * enabling type-safe field references in plugin configs.
1752
+ * @example
1753
+ * ```typescript
1754
+ * // In your plugin package or types file:
1755
+ * declare module "@tailor-platform/sdk" {
1756
+ * interface PluginConfigs<Fields extends string> {
1757
+ * "@my-company/i18n": {
1758
+ * labels: Partial<Record<Fields, { ja: string; en: string }>>;
1759
+ * };
1760
+ * }
1761
+ * }
1762
+ * ```
1763
+ */
1764
+ interface PluginConfigs<Fields extends string = string> {}
1765
+ /**
1766
+ * Plugin attachment stored on TailorAnyDBType instances.
1767
+ * This is the configuration passed via `.plugin()` method.
1768
+ */
1769
+ interface PluginAttachment {
1770
+ pluginId: string;
1771
+ config: unknown;
1772
+ }
1773
+ /**
1774
+ * Context passed to plugin's process method
1775
+ */
1776
+ interface PluginProcessContext<TypeConfig = unknown, PluginConfig = unknown> {
1777
+ /** The raw TailorDB type being processed */
1778
+ type: TailorAnyDBType;
1779
+ /** Per-type configuration passed via .plugin() method */
1780
+ typeConfig: TypeConfig;
1781
+ /** Plugin-level configuration passed via definePlugins() */
1782
+ pluginConfig: PluginConfig;
1783
+ /** Namespace of the TailorDB type */
1784
+ namespace: string;
1785
+ }
1786
+ /**
1787
+ * Context passed to plugin's onNamespaceLoaded hook.
1788
+ * Used for plugins that operate on a namespace without requiring a source type.
1789
+ */
1790
+ interface PluginNamespaceProcessContext<PluginConfig = unknown> {
1791
+ /** Plugin-level configuration passed via definePlugins() */
1792
+ pluginConfig: PluginConfig;
1793
+ /** Target namespace for generated types */
1794
+ namespace: string;
1795
+ }
1796
+ /**
1797
+ * Interface representing a TailorDB type for plugin output.
1798
+ * This interface is satisfied by db.type() instances.
1799
+ */
1800
+ interface TailorDBTypeForPlugin {
1801
+ /** The name of the type */
1802
+ readonly name: string;
1803
+ /** The field definitions */
1804
+ readonly fields: Record<string, unknown>;
1805
+ }
1806
+ /**
1807
+ * Type generated by a plugin - use db.type() to create these.
1808
+ */
1809
+ type PluginGeneratedType = TailorDBTypeForPlugin;
1810
+ /**
1811
+ * Map of generated types keyed by kind identifier.
1812
+ * The kind is used to generate distinct TypeScript type files for each generated type.
1813
+ * @example
1814
+ * ```typescript
1815
+ * {
1816
+ * request: changeRequest,
1817
+ * step: changeStep,
1818
+ * approval: changeApproval,
1819
+ * }
1820
+ * ```
1821
+ */
1822
+ type PluginGeneratedTypes = Record<string, PluginGeneratedType>;
1823
+ /**
1824
+ * Resolver definition generated by a plugin.
1825
+ * Fields can be TailorDB field instances or raw field definitions.
1826
+ */
1827
+ interface PluginGeneratedResolver {
1828
+ name: string;
1829
+ operation: "query" | "mutation";
1830
+ inputFields?: Record<string, unknown>;
1831
+ outputFields: Record<string, unknown>;
1832
+ /** Function body code as string */
1833
+ body: string;
1834
+ }
1835
+ /**
1836
+ * Record trigger configuration for plugin-generated executors
1837
+ */
1838
+ interface PluginRecordTriggerConfig {
1839
+ kind: "recordCreated" | "recordUpdated" | "recordDeleted";
1840
+ /** TailorDB type name for record triggers */
1841
+ typeName: string;
1842
+ }
1843
+ /**
1844
+ * Schedule trigger configuration for plugin-generated executors
1845
+ */
1846
+ interface PluginScheduleTriggerConfig {
1847
+ kind: "schedule";
1848
+ /** Cron expression */
1849
+ cron: string;
1850
+ /** Timezone (defaults to UTC) */
1851
+ timezone?: string;
1852
+ }
1853
+ /**
1854
+ * Incoming webhook trigger configuration for plugin-generated executors
1855
+ */
1856
+ interface PluginIncomingWebhookTriggerConfig {
1857
+ kind: "incomingWebhook";
1858
+ }
1859
+ /**
1860
+ * Trigger configuration for plugin-generated executors
1861
+ */
1862
+ type PluginTriggerConfig = PluginRecordTriggerConfig | PluginScheduleTriggerConfig | PluginIncomingWebhookTriggerConfig;
1863
+ /**
1864
+ * Inject value types supported for plugin executor injection.
1865
+ * These values are serialized as const declarations in the generated file.
1866
+ */
1867
+ type PluginInjectValue = string | number | boolean | null;
1868
+ /**
1869
+ * Inject map for plugin executor.
1870
+ * Keys become const variable names in the generated file.
1871
+ */
1872
+ type PluginInjectMap = Record<string, PluginInjectValue>;
1873
+ /**
1874
+ * Function operation configuration for plugin-generated executors
1875
+ */
1876
+ interface PluginFunctionOperationConfig {
1877
+ kind: "function";
1878
+ /** Function body code as string */
1879
+ body: string;
1880
+ /**
1881
+ * Variables to inject into the generated file scope.
1882
+ * These become const declarations at the top of the generated file,
1883
+ * allowing the function body to reference them.
1884
+ * @example { namespace: "tailordb", historyTypeName: "CustomerHistory" }
1885
+ */
1886
+ inject?: PluginInjectMap;
1887
+ }
1888
+ /**
1889
+ * GraphQL operation configuration for plugin-generated executors
1890
+ */
1891
+ interface PluginGraphQLOperationConfig {
1892
+ kind: "graphql";
1893
+ /** GraphQL query string */
1894
+ query: string;
1895
+ /** App name for the GraphQL endpoint */
1896
+ appName?: string;
1897
+ /**
1898
+ * Variables expression as a string function.
1899
+ * Receives the executor args object and returns the variables object.
1900
+ * @example "(args) => ({ input: { recordId: args.newRecord.id } })"
1901
+ */
1902
+ variables?: string;
1903
+ }
1904
+ /**
1905
+ * Webhook operation configuration for plugin-generated executors
1906
+ */
1907
+ interface PluginWebhookOperationConfig {
1908
+ kind: "webhook";
1909
+ /** Webhook URL */
1910
+ url: string;
1911
+ }
1912
+ /**
1913
+ * Workflow operation configuration for plugin-generated executors
1914
+ */
1915
+ interface PluginWorkflowOperationConfig {
1916
+ kind: "workflow";
1917
+ /** Workflow name */
1918
+ workflowName: string;
1919
+ }
1920
+ /**
1921
+ * Operation configuration for plugin-generated executors
1922
+ */
1923
+ type PluginOperationConfig = PluginFunctionOperationConfig | PluginGraphQLOperationConfig | PluginWebhookOperationConfig | PluginWorkflowOperationConfig;
1924
+ /**
1925
+ * Context value types for plugin executor context.
1926
+ * Supports primitive values and type references.
1927
+ */
1928
+ type PluginExecutorContextValue = TailorAnyDBType | string | number | boolean | null | undefined;
1929
+ /**
1930
+ * Base executor context that can include type references and other values.
1931
+ * Type objects (TailorAnyDBType) will be handled specially by the generator
1932
+ * to create appropriate import statements.
1933
+ *
1934
+ * Plugin authors should extend this interface for their specific context needs.
1935
+ */
1936
+ interface PluginExecutorContextBase {
1937
+ /** Source type that the plugin is attached to. Null for namespace executors. */
1938
+ sourceType: TailorAnyDBType | null;
1939
+ /** TailorDB namespace for data operations */
1940
+ namespace: string;
1941
+ }
1942
+ /**
1943
+ * Flexible executor context type that allows additional properties.
1944
+ * Used as the context type in PluginGeneratedExecutorWithFile.
1945
+ */
1946
+ type PluginExecutorContext = PluginExecutorContextBase & {
1947
+ [key: string]: PluginExecutorContextValue;
1948
+ };
1949
+ /**
1950
+ * Module shape returned by plugin executor resolve().
1951
+ * The concrete context type is intentionally erased at this boundary.
1952
+ */
1953
+ interface PluginExecutorModule {
1954
+ default: unknown;
1955
+ }
1956
+ /**
1957
+ * Executor definition with dynamic import reference (new format).
1958
+ * Used with withPluginContext for type-safe executor definitions in separate files.
1959
+ */
1960
+ interface PluginGeneratedExecutorWithFile<Ctx = PluginExecutorContext> {
1961
+ /** Executor name (used for generated file name) */
1962
+ name: string;
1963
+ /**
1964
+ * Resolver function for the executor module.
1965
+ * Should return a dynamic import to the executor file.
1966
+ * Relative import specifiers are resolved from the plugin's importPath base.
1967
+ * @example `async () => await import("./executors/on-create")`
1968
+ */
1969
+ resolve: () => Promise<PluginExecutorModule>;
1970
+ /**
1971
+ * Context to pass to the executor factory.
1972
+ * Can include TailorAnyDBType objects - these will be handled specially
1973
+ * by the generator to create appropriate import statements.
1974
+ */
1975
+ context: Ctx;
1976
+ }
1977
+ /**
1978
+ * Executor definition generated by a plugin (legacy format).
1979
+ * @deprecated Use PluginGeneratedExecutorWithFile with withPluginContext instead.
1980
+ */
1981
+ interface PluginGeneratedExecutorLegacy {
1982
+ name: string;
1983
+ description?: string;
1984
+ trigger: PluginTriggerConfig;
1985
+ operation: PluginOperationConfig;
1986
+ }
1987
+ /**
1988
+ * Executor definition generated by a plugin.
1989
+ * Supports both legacy format (inline trigger/operation) and new format (executorFile/context).
1990
+ */
1991
+ type PluginGeneratedExecutor = PluginGeneratedExecutorWithFile | PluginGeneratedExecutorLegacy;
1992
+ /**
1993
+ * Extension options for modifying the source type
1994
+ */
1995
+ interface PluginExtends {
1996
+ /**
1997
+ * Fields to add to the source type.
1998
+ * These fields will be merged into the original type's fields.
1999
+ * Existing fields (from original definition or earlier plugins) take precedence.
2000
+ */
2001
+ fields?: Record<string, TailorAnyDBField>;
2002
+ }
2003
+ /**
2004
+ * Base output returned by a plugin's definition-time hooks.
2005
+ * Used by both onTypeLoaded and onNamespaceLoaded.
2006
+ */
2007
+ interface PluginOutput {
2008
+ /**
2009
+ * Additional TailorDB types to generate, keyed by kind identifier.
2010
+ * The kind is used to generate distinct TypeScript type files.
2011
+ * @example { request: changeRequest, step: changeStep }
2012
+ */
2013
+ types?: PluginGeneratedTypes;
2014
+ /** Additional resolvers to generate */
2015
+ resolvers?: PluginGeneratedResolver[];
2016
+ /** Additional executors to generate */
2017
+ executors?: PluginGeneratedExecutor[];
2018
+ }
2019
+ /**
2020
+ * Output returned by a plugin's onTypeLoaded hook.
2021
+ * Extends PluginOutput with the ability to add fields to the source type.
2022
+ */
2023
+ interface TypePluginOutput extends PluginOutput {
2024
+ /** Extensions to apply to the source type */
2025
+ extends?: PluginExtends;
2026
+ }
2027
+ /**
2028
+ * Output returned by a plugin's onNamespaceLoaded hook.
2029
+ * Alias for PluginOutput (namespace plugins cannot extend a source type).
2030
+ */
2031
+ type NamespacePluginOutput = PluginOutput;
2032
+ /**
2033
+ * Plugin interface that all plugins must implement.
2034
+ * Plugins can hook into two lifecycle phases:
2035
+ * - **Definition-time hooks** (`onTypeLoaded`, `onNamespaceLoaded`): Generate TailorDB types, resolvers, and executors
2036
+ * - **Generation-time hooks** (`onTailorDBReady`, `onResolverReady`, `onExecutorReady`): Process finalized artifacts and produce output files
2037
+ * @template TypeConfig - Type for per-type configuration passed via .plugin() method
2038
+ * @template PluginConfig - Type for plugin-level configuration passed via definePlugins()
2039
+ */
2040
+ interface Plugin<TypeConfig = unknown, PluginConfig = unknown> {
2041
+ /** Unique identifier for the plugin */
2042
+ readonly id: string;
2043
+ /** Human-readable description of the plugin */
2044
+ readonly description: string;
2045
+ /**
2046
+ * Import path for this plugin's public API.
2047
+ * Used by code generators to create correct import statements
2048
+ * (e.g., plugin executors and seed schema generation).
2049
+ * Required when plugin has definition-time hooks (onTypeLoaded/onNamespaceLoaded).
2050
+ * Optional for generation-only plugins.
2051
+ */
2052
+ readonly importPath?: string;
2053
+ /**
2054
+ * Controls whether per-type plugin config is required when attaching via .plugin().
2055
+ * If a function is provided, it receives pluginConfig from definePlugins().
2056
+ * Default is optional when not provided.
2057
+ */
2058
+ readonly typeConfigRequired?: TypeConfigRequired<PluginConfig>;
2059
+ /**
2060
+ * Plugin-level configuration passed via definePlugins().
2061
+ * This config is stored when the plugin is registered and made available
2062
+ * to all hook methods.
2063
+ */
2064
+ readonly pluginConfig?: PluginConfig;
2065
+ /**
2066
+ * Process a single TailorDB type and generate outputs.
2067
+ * Called for each type that has this plugin attached via .plugin().
2068
+ * @param context - Context containing the type, config, pluginConfig, and namespace
2069
+ * @returns Plugin output with generated types, resolvers, and executors
2070
+ */
2071
+ onTypeLoaded?(context: PluginProcessContext<TypeConfig, PluginConfig>): TypePluginOutput | Promise<TypePluginOutput>;
2072
+ /**
2073
+ * Process plugin for a namespace without requiring a source type.
2074
+ * Called once per namespace for plugins configured via definePlugins().
2075
+ * Use this for plugins that generate types independently of user-defined types.
2076
+ * @param context - Context containing the plugin config and namespace
2077
+ * @returns Plugin output with generated types, resolvers, and executors
2078
+ */
2079
+ onNamespaceLoaded?(context: PluginNamespaceProcessContext<PluginConfig>): NamespacePluginOutput | Promise<NamespacePluginOutput>;
2080
+ /**
2081
+ * Called after all TailorDB types are loaded and finalized.
2082
+ * Receives all TailorDB namespaces and their types.
2083
+ * @param context - Context containing all TailorDB data, auth, and output paths
2084
+ * @returns Generated files and optional errors
2085
+ */
2086
+ onTailorDBReady?(context: TailorDBReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
2087
+ /**
2088
+ * Called after all resolvers are loaded and finalized.
2089
+ * Receives all TailorDB data plus resolver data.
2090
+ * @param context - Context containing TailorDB data, resolvers, auth, and output paths
2091
+ * @returns Generated files and optional errors
2092
+ */
2093
+ onResolverReady?(context: ResolverReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
2094
+ /**
2095
+ * Called after all executors are loaded and finalized.
2096
+ * Receives all TailorDB data, resolver data, plus executor data.
2097
+ * @param context - Context containing all service data, auth, and output paths
2098
+ * @returns Generated files and optional errors
2099
+ */
2100
+ onExecutorReady?(context: ExecutorReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
2101
+ }
2102
+ //#endregion
2103
+ //#region src/configure/services/tailordb/schema.d.ts
2104
+ interface RelationConfig<S extends RelationType, T extends TailorDBType$1> {
2105
+ type: S;
2106
+ toward: {
2107
+ type: T;
2108
+ as?: string;
2109
+ key?: keyof T["fields"] & string;
2110
+ };
2111
+ backward?: string;
2112
+ }
2113
+ type RelationSelfConfig = {
2114
+ type: RelationType;
2115
+ toward: {
2116
+ type: "self";
2117
+ as?: string;
2118
+ key?: string;
2119
+ };
2120
+ backward?: string;
2137
2121
  };
2138
- type OIDC = z.output<typeof OIDCSchema>;
2139
- type SAML = z.output<typeof SAMLSchema>;
2140
- type IDToken = z.output<typeof IDTokenSchema>;
2141
- type BuiltinIdP = z.output<typeof BuiltinIdPSchema>;
2142
- type IdProviderConfig = z.output<typeof IdProviderSchema>;
2143
- type OAuth2ClientGrantType = z.output<typeof OAuth2ClientGrantTypeSchema>;
2144
- type OAuth2ClientInput = z.input<typeof OAuth2ClientSchema>;
2145
- type SCIMAuthorization = z.output<typeof SCIMAuthorizationSchema>;
2146
- type SCIMAttributeType = z.output<typeof SCIMAttributeTypeSchema>;
2147
- type SCIMAttribute = z.output<typeof SCIMAttributeSchema>;
2148
- type SCIMAttributeMapping = z.output<typeof SCIMAttributeMappingSchema>;
2149
- type SCIMResource = z.output<typeof SCIMResourceSchema>;
2150
- type SCIMConfig = z.output<typeof SCIMSchema>;
2151
- type TenantProviderConfig = z.output<typeof TenantProviderSchema>;
2152
- type ValueOperand = string | boolean | string[] | boolean[];
2153
- type AuthAttributeValue = ValueOperand | null | undefined;
2154
- type UserFieldKeys<User extends TailorDBInstance> = keyof output<User> & string;
2155
- type FieldDefined<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = User["fields"][Key] extends {
2156
- _defined: infer Defined;
2157
- } ? Defined : never;
2158
- type FieldOutput<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = output<User>[Key];
2159
- type FieldIsRequired<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = undefined extends FieldOutput<User, Key> ? false : true;
2160
- type FieldIsOfType<User extends TailorDBInstance, Key extends UserFieldKeys<User>, Type extends string> = FieldDefined<User, Key> extends {
2161
- type: Type;
2162
- } ? true : false;
2163
- type FieldIsArray<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
2164
- array: true;
2165
- } ? true : false;
2166
- type FieldIsUnique<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
2167
- unique: true;
2168
- } ? true : false;
2169
- type FieldSupportsValueOperand<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldOutput<User, Key> extends ValueOperand | null | undefined ? true : false;
2170
- type UsernameFieldKey<User extends TailorDBInstance> = IsAny<User> extends true ? string : { [K in UserFieldKeys<User>]: FieldIsRequired<User, K> extends true ? FieldIsOfType<User, K, "string"> extends true ? FieldIsArray<User, K> extends true ? never : FieldIsUnique<User, K> extends true ? K : never : never : never }[UserFieldKeys<User>];
2171
- type UserAttributeKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldSupportsValueOperand<User, K> extends true ? FieldIsOfType<User, K, "datetime" | "date" | "time"> extends true ? never : K : never }[UserFieldKeys<User>];
2172
- type UserAttributeListKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldIsOfType<User, K, "uuid"> extends true ? FieldIsArray<User, K> extends true ? never : K : never }[UserFieldKeys<User>];
2173
- type UserAttributeMap<User extends TailorDBInstance> = { [K in UserAttributeKey<User>]?: true };
2174
- type DisallowExtraKeys<T, Allowed extends PropertyKey> = T & { [K in Exclude<keyof T, Allowed>]: never };
2175
- type AttributeListValue<User extends TailorDBInstance, Key extends UserAttributeListKey<User>> = Key extends keyof output<User> ? output<User>[Key] : never;
2176
- type AttributeListToTuple<User extends TailorDBInstance, AttributeList$1 extends readonly UserAttributeListKey<User>[]> = { [Index in keyof AttributeList$1]: AttributeList$1[Index] extends UserAttributeListKey<User> ? AttributeListValue<User, AttributeList$1[Index]> : never };
2177
- type AttributeMapSelectedKeys<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User>> = Extract<{ [K in keyof AttributeMap$1]-?: undefined extends AttributeMap$1[K] ? never : K }[keyof AttributeMap$1], UserAttributeKey<User>>;
2178
- type UserProfile<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User>, AttributeList$1 extends UserAttributeListKey<User>[]> = {
2122
+ type TailorAnyDBField = TailorDBField<any, any>;
2123
+ type TailorAnyDBType = TailorDBType$1<any, any>;
2124
+ /**
2125
+ * TailorDBField interface representing a database field with extended metadata.
2126
+ * Extends TailorField with database-specific features like relations, indexes, and hooks.
2127
+ */
2128
+ interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends Omit<TailorField<Defined, Output, DBFieldMetadata, Defined["type"]>, "description" | "validate"> {
2129
+ /** Returns a shallow copy of the raw relation config if set */
2130
+ readonly rawRelation: Readonly<RawRelationConfig> | undefined;
2131
+ /**
2132
+ * Set a description for the field
2133
+ * @param description - The description text
2134
+ * @returns The field with updated metadata
2135
+ */
2136
+ description<CurrentDefined extends Defined>(this: CurrentDefined extends {
2137
+ description: unknown;
2138
+ } ? never : TailorField<CurrentDefined, Output>, description: string): TailorDBField<Prettify<CurrentDefined & {
2139
+ description: true;
2140
+ }>, Output>;
2141
+ /**
2142
+ * Define a relation to another type.
2143
+ * Relation types: "n-1" (many-to-one), "1-1" (one-to-one), "keyOnly" (key only).
2144
+ * Aliases "manyToOne", "oneToOne", and "N-1" are also accepted.
2145
+ * @example db.uuid().relation({ type: "n-1", toward: { type: otherModel } })
2146
+ * @example db.uuid().relation({ type: "1-1", toward: { type: profile } })
2147
+ */
2148
+ relation<S extends RelationType, T extends TailorAnyDBType, CurrentDefined extends Defined>(this: CurrentDefined extends {
2149
+ relation: unknown;
2150
+ } ? never : TailorDBField<CurrentDefined, Output>, config: RelationConfig<S, T>): TailorDBField<S extends "oneToOne" | "1-1" ? Prettify<CurrentDefined & {
2151
+ unique: true;
2152
+ index: true;
2153
+ relation: true;
2154
+ }> : Prettify<CurrentDefined & {
2155
+ index: true;
2156
+ relation: true;
2157
+ }>, Output>;
2158
+ /**
2159
+ * Define a self-referencing relation
2160
+ */
2161
+ relation<S extends RelationSelfConfig, CurrentDefined extends Defined>(this: CurrentDefined extends {
2162
+ relation: unknown;
2163
+ } ? never : TailorDBField<CurrentDefined, Output>, config: S): TailorDBField<S["type"] extends "oneToOne" | "1-1" ? Prettify<CurrentDefined & {
2164
+ unique: true;
2165
+ index: true;
2166
+ relation: true;
2167
+ }> : Prettify<CurrentDefined & {
2168
+ index: true;
2169
+ relation: true;
2170
+ }>, Output>;
2171
+ /**
2172
+ * Add an index to the field
2173
+ */
2174
+ index<CurrentDefined extends Defined>(this: CurrentDefined extends {
2175
+ index: unknown;
2176
+ } ? never : CurrentDefined extends {
2177
+ array: true;
2178
+ } ? never : TailorDBField<CurrentDefined, Output>): TailorDBField<Prettify<CurrentDefined & {
2179
+ index: true;
2180
+ }>, Output>;
2181
+ /**
2182
+ * Make the field unique (also adds an index)
2183
+ */
2184
+ unique<CurrentDefined extends Defined>(this: CurrentDefined extends {
2185
+ unique: unknown;
2186
+ } ? never : CurrentDefined extends {
2187
+ array: true;
2188
+ } ? never : TailorDBField<CurrentDefined, Output>): TailorDBField<Prettify<CurrentDefined & {
2189
+ unique: true;
2190
+ index: true;
2191
+ }>, Output>;
2192
+ /**
2193
+ * Enable vector search on the field (string type only)
2194
+ */
2195
+ vector<CurrentDefined extends Defined>(this: CurrentDefined extends {
2196
+ vector: unknown;
2197
+ } ? never : CurrentDefined extends {
2198
+ type: "string";
2199
+ array: false;
2200
+ } ? TailorDBField<CurrentDefined, Output> : never): TailorDBField<Prettify<CurrentDefined & {
2201
+ vector: true;
2202
+ }>, Output>;
2203
+ /**
2204
+ * Add hooks for create/update operations on this field.
2205
+ * The hook function receives `{ value, data, user }` and returns the computed value.
2206
+ * @example db.string().hooks({ create: ({ data }) => data.firstName + " " + data.lastName })
2207
+ * @example db.datetime().hooks({ create: () => new Date(), update: () => new Date() })
2208
+ */
2209
+ hooks<CurrentDefined extends Defined, const H extends Hook<unknown, Output>>(this: CurrentDefined extends {
2210
+ hooks: unknown;
2211
+ } ? never : CurrentDefined extends {
2212
+ type: "nested";
2213
+ } ? never : TailorDBField<CurrentDefined, Output>, hooks: H): TailorDBField<Prettify<CurrentDefined & {
2214
+ hooks?: {
2215
+ create: H extends {
2216
+ create: unknown;
2217
+ } ? true : false;
2218
+ update: H extends {
2219
+ update: unknown;
2220
+ } ? true : false;
2221
+ };
2222
+ serial: false;
2223
+ }>, Output>;
2224
+ /**
2225
+ * Add validation functions to the field.
2226
+ * Accepts a function or a tuple of [function, errorMessage].
2227
+ * Prefer the tuple form for diagnosable errors.
2228
+ * @example
2229
+ * // Function form (default error message):
2230
+ * db.int().validate(({ value }) => value >= 0)
2231
+ * @example
2232
+ * // Tuple form with custom error message (recommended):
2233
+ * db.string().validate([({ value }) => value.length >= 8, "Must be at least 8 characters"])
2234
+ */
2235
+ validate<CurrentDefined extends Defined>(this: CurrentDefined extends {
2236
+ validate: unknown;
2237
+ } ? never : TailorDBField<CurrentDefined, Output>, ...validate: FieldValidateInput<Output>[]): TailorDBField<Prettify<CurrentDefined & {
2238
+ validate: true;
2239
+ }>, Output>;
2240
+ /**
2241
+ * Configure serial/auto-increment behavior
2242
+ */
2243
+ serial<CurrentDefined extends Defined>(this: CurrentDefined extends {
2244
+ serial: unknown;
2245
+ } ? never : Output extends null ? never : CurrentDefined extends {
2246
+ type: "integer" | "string";
2247
+ array: false;
2248
+ } ? TailorDBField<CurrentDefined, Output> : never, config: SerialConfig<CurrentDefined["type"] & ("integer" | "string")>): TailorDBField<Prettify<CurrentDefined & {
2249
+ serial: true;
2250
+ hooks: {
2251
+ create: false;
2252
+ update: false;
2253
+ };
2254
+ }>, Output>;
2255
+ /**
2256
+ * Clone the field with optional overrides for field options
2257
+ * @param options - Optional field options to override
2258
+ * @returns A new TailorDBField instance with the same configuration
2259
+ */
2260
+ clone<const NewOpt extends FieldOptions>(options?: NewOpt): TailorDBField<Prettify<Omit<Defined, "array"> & {
2261
+ array: NewOpt extends {
2262
+ array: true;
2263
+ } ? true : Defined["array"];
2264
+ }>, FieldOutput$1<TailorToTs[Defined["type"]], NewOpt>>;
2265
+ }
2266
+ /**
2267
+ * Create a UUID field.
2268
+ * @param options - Field configuration options
2269
+ * @returns A UUID field
2270
+ * @example db.uuid()
2271
+ * @example db.uuid({ optional: true })
2272
+ */
2273
+ declare function uuid<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2274
+ type: "uuid";
2275
+ array: Opt extends {
2276
+ array: true;
2277
+ } ? true : false;
2278
+ }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
2279
+ /**
2280
+ * Create a string field.
2281
+ * @param options - Field configuration options
2282
+ * @returns A string field
2283
+ * @example db.string()
2284
+ * @example db.string({ optional: true })
2285
+ */
2286
+ declare function string<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2287
+ type: "string";
2288
+ array: Opt extends {
2289
+ array: true;
2290
+ } ? true : false;
2291
+ }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
2292
+ /**
2293
+ * Create a boolean field.
2294
+ * Note: The method name is `bool` but creates a `boolean` type field.
2295
+ * @param options - Field configuration options
2296
+ * @returns A boolean field
2297
+ * @example db.bool()
2298
+ * @example db.bool({ optional: true })
2299
+ */
2300
+ declare function bool<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2301
+ type: "boolean";
2302
+ array: Opt extends {
2303
+ array: true;
2304
+ } ? true : false;
2305
+ }, Opt["optional"] extends true ? ArrayFieldOutput<boolean, Opt> | null : ArrayFieldOutput<boolean, Opt>>;
2306
+ /**
2307
+ * Create an integer field.
2308
+ * @param options - Field configuration options
2309
+ * @returns An integer field
2310
+ * @example db.int()
2311
+ * @example db.int({ optional: true })
2312
+ */
2313
+ declare function int<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2314
+ type: "integer";
2315
+ array: Opt extends {
2316
+ array: true;
2317
+ } ? true : false;
2318
+ }, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
2319
+ /**
2320
+ * Create a float (decimal number) field.
2321
+ * @param options - Field configuration options
2322
+ * @returns A float field
2323
+ * @example db.float()
2324
+ * @example db.float({ optional: true })
2325
+ */
2326
+ declare function float<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2327
+ type: "float";
2328
+ array: Opt extends {
2329
+ array: true;
2330
+ } ? true : false;
2331
+ }, Opt["optional"] extends true ? ArrayFieldOutput<number, Opt> | null : ArrayFieldOutput<number, Opt>>;
2332
+ /**
2333
+ * Create a date field (date only, no time component).
2334
+ * Format: "yyyy-MM-dd"
2335
+ * @param options - Field configuration options
2336
+ * @returns A date field
2337
+ * @example db.date()
2338
+ */
2339
+ declare function date<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2340
+ type: "date";
2341
+ array: Opt extends {
2342
+ array: true;
2343
+ } ? true : false;
2344
+ }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
2345
+ /**
2346
+ * Create a datetime field (date and time).
2347
+ * Format: ISO 8601 "yyyy-MM-ddTHH:mm:ssZ"
2348
+ * @param options - Field configuration options
2349
+ * @returns A datetime field
2350
+ * @example db.datetime()
2351
+ */
2352
+ declare function datetime<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2353
+ type: "datetime";
2354
+ array: Opt extends {
2355
+ array: true;
2356
+ } ? true : false;
2357
+ }, Opt["optional"] extends true ? ArrayFieldOutput<string | Date, Opt> | null : ArrayFieldOutput<string | Date, Opt>>;
2358
+ /**
2359
+ * Create a time field (time only, no date component).
2360
+ * Format: "HH:mm"
2361
+ * @param options - Field configuration options
2362
+ * @returns A time field
2363
+ * @example db.time()
2364
+ */
2365
+ declare function time<const Opt extends FieldOptions>(options?: Opt): TailorDBField<{
2366
+ type: "time";
2367
+ array: Opt extends {
2368
+ array: true;
2369
+ } ? true : false;
2370
+ }, Opt["optional"] extends true ? ArrayFieldOutput<string, Opt> | null : ArrayFieldOutput<string, Opt>>;
2371
+ /**
2372
+ * Create an enum field with a fixed set of allowed string values.
2373
+ * @param values - Array of allowed string values, or array of `{ value, description }` objects
2374
+ * @param options - Field configuration options
2375
+ * @returns An enum field
2376
+ * @example db.enum(["active", "inactive", "suspended"])
2377
+ * @example db.enum(["small", "medium", "large"], { optional: true })
2378
+ */
2379
+ declare function _enum<const V extends AllowedValues, const Opt extends FieldOptions>(values: V, options?: Opt): TailorDBField<{
2380
+ type: "enum";
2381
+ array: Opt extends {
2382
+ array: true;
2383
+ } ? true : false;
2384
+ }, FieldOutput$1<AllowedValuesOutput<V>, Opt>>;
2385
+ /**
2386
+ * Create a nested object field with sub-fields.
2387
+ * @param fields - Record of nested field definitions
2388
+ * @param options - Field configuration options
2389
+ * @returns A nested object field
2390
+ * @example db.object({ street: db.string(), city: db.string(), zip: db.string() })
2391
+ * @example db.object({ name: db.string() }, { optional: true })
2392
+ */
2393
+ declare function object<const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>, const Opt extends FieldOptions>(fields: F, options?: Opt): TailorDBField<{
2394
+ type: "nested";
2395
+ array: Opt extends {
2396
+ array: true;
2397
+ } ? true : false;
2398
+ }, FieldOutput$1<InferFieldsOutput<F>, Opt>>;
2399
+ /**
2400
+ * TailorDBType interface representing a database type definition with fields, permissions, and settings.
2401
+ */
2402
+ interface TailorDBType$1<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> {
2403
+ readonly name: string;
2404
+ readonly fields: Fields;
2405
+ readonly _output: InferFieldsOutput<Fields>;
2406
+ _description?: string;
2407
+ /** Returns metadata for the type */
2408
+ readonly metadata: TailorDBTypeMetadata;
2179
2409
  /**
2180
- * TailorDB namespace where the user type is defined.
2181
- *
2182
- * Usually auto-resolved, so you don't need to specify this.
2183
- * Required only when multiple TailorDBs exist and the type is in an external TailorDB.
2410
+ * Add hooks for fields at the type level.
2411
+ * Each key is a field name, and the value defines create/update hooks.
2412
+ * @example
2413
+ * db.type("Order", {
2414
+ * total: db.float(),
2415
+ * tax: db.float(),
2416
+ * ...db.fields.timestamps(),
2417
+ * }).hooks({
2418
+ * tax: { create: ({ data }) => data.total * 0.1, update: ({ data }) => data.total * 0.1 },
2419
+ * })
2184
2420
  */
2185
- namespace?: string;
2186
- type: User;
2187
- usernameField: UsernameFieldKey<User>;
2188
- attributes?: DisallowExtraKeys<AttributeMap$1, UserAttributeKey<User>>;
2189
- attributeList?: AttributeList$1;
2190
- };
2191
- type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
2192
- type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
2193
- type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never };
2194
- type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
2195
- attributes?: never;
2196
- } : {
2197
- attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
2198
- }) & {
2199
- attributeList?: string[];
2200
- };
2201
- type MachineUser<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User> = UserAttributeMap<User>, AttributeList$1 extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
2202
- attributes: Record<string, AuthAttributeValue>;
2203
- attributeList?: string[];
2204
- } : (AttributeMapSelectedKeys<User, AttributeMap$1> extends never ? {
2205
- attributes?: never;
2206
- } : {
2207
- attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap$1>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap$1>>]?: never };
2208
- }) & ([] extends AttributeList$1 ? {
2209
- attributeList?: never;
2210
- } : {
2211
- attributeList: AttributeListToTuple<User, AttributeList$1>;
2212
- }) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
2213
- attributes: Record<string, AuthAttributeValue>;
2214
- attributeList?: string[];
2215
- } : (AttributeMapSelectedKeys<User, AttributeMap$1> extends never ? {
2216
- attributes?: never;
2217
- } : {
2218
- attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap$1>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap$1>>]?: never };
2219
- }) & ([] extends AttributeList$1 ? {
2220
- attributeList?: never;
2221
- } : {
2222
- attributeList: AttributeListToTuple<User, AttributeList$1>;
2223
- });
2224
- type AuthServiceInput<User extends TailorDBInstance, AttributeMap$1 extends UserAttributeMap<User>, AttributeList$1 extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined> = {
2225
- userProfile?: UserProfile<User, AttributeMap$1, AttributeList$1>;
2226
- machineUserAttributes?: MachineUserAttributes;
2227
- machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap$1, AttributeList$1, MachineUserAttributes>>;
2228
- oauth2Clients?: Record<string, OAuth2ClientInput>;
2229
- idProvider?: IdProviderConfig;
2230
- scim?: SCIMConfig;
2231
- tenantProvider?: TenantProviderConfig;
2232
- publishSessionEvents?: boolean;
2233
- };
2234
- declare const authDefinitionBrand: unique symbol;
2235
- type AuthDefinitionBrand = {
2236
- readonly [authDefinitionBrand]: true;
2237
- };
2238
- type DefinedAuth<Name extends string, Config, MachineUserNames extends string> = Config & {
2239
- name: Name;
2240
- invoker<M extends MachineUserNames>(machineUser: M): AuthInvokerWithName<M>;
2241
- } & AuthDefinitionBrand;
2242
- type AuthExternalConfig = {
2243
- name: string;
2244
- external: true;
2421
+ hooks(hooks: Hooks<Fields>): TailorDBType$1<Fields, User>;
2422
+ /**
2423
+ * Add validators for fields at the type level.
2424
+ * Each key is a field name, and the value is a validator or array of validators.
2425
+ * Prefer the tuple form [function, message] for diagnosable errors.
2426
+ * @example
2427
+ * db.type("User", { email: db.string() }).validate({
2428
+ * email: [({ value }) => value.includes("@"), "Email must contain @"],
2429
+ * })
2430
+ */
2431
+ validate(validators: Validators<Fields>): TailorDBType$1<Fields, User>;
2432
+ /**
2433
+ * Configure type features
2434
+ */
2435
+ features(features: Omit<TypeFeatures, "pluralForm">): TailorDBType$1<Fields, User>;
2436
+ /**
2437
+ * Define composite indexes
2438
+ */
2439
+ indexes(...indexes: IndexDef<TailorDBType$1<Fields, User>>[]): TailorDBType$1<Fields, User>;
2440
+ /**
2441
+ * Define file fields
2442
+ */
2443
+ files<const F extends string>(files: Record<F, string> & Partial<Record<keyof output<TailorDBType$1<Fields, User>>, never>>): TailorDBType$1<Fields, User>;
2444
+ /**
2445
+ * Set record-level permissions for create, read, update, and delete operations.
2446
+ * Prefer object format with explicit `conditions` and `permit` for readability.
2447
+ * For update operations, use `newRecord` and `oldRecord` operands.
2448
+ * @example
2449
+ * .permission({
2450
+ * create: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
2451
+ * read: [{ conditions: [[{ record: "isPublic" }, "=", true]], permit: true }],
2452
+ * update: [{ conditions: [[{ newRecord: "ownerId" }, "=", { user: "id" }]], permit: true }],
2453
+ * delete: [{ conditions: [[{ record: "ownerId" }, "=", { user: "id" }]], permit: true }],
2454
+ * })
2455
+ */
2456
+ permission<U$1 extends object = User, P$1 extends TailorTypePermission<U$1, output<TailorDBType$1<Fields, User>>> = TailorTypePermission<U$1, output<TailorDBType$1<Fields, User>>>>(permission: P$1): TailorDBType$1<Fields, U$1>;
2457
+ /**
2458
+ * Set GraphQL-level permissions controlling access to GraphQL operations.
2459
+ * @example
2460
+ * .gqlPermission([
2461
+ * {
2462
+ * conditions: [[{ user: "_loggedIn" }, "=", true]],
2463
+ * actions: "all",
2464
+ * permit: true,
2465
+ * },
2466
+ * ])
2467
+ */
2468
+ gqlPermission<U$1 extends object = User, P$1 extends TailorTypeGqlPermission<U$1> = TailorTypeGqlPermission<U$1>>(permission: P$1): TailorDBType$1<Fields, U$1>;
2469
+ /**
2470
+ * Set type description
2471
+ */
2472
+ description(description: string): TailorDBType$1<Fields, User>;
2473
+ /**
2474
+ * Pick specific fields from the type
2475
+ */
2476
+ pickFields<K$1 extends keyof Fields, const Opt extends FieldOptions>(keys: K$1[], options: Opt): { [P in K$1]: Fields[P$1] extends TailorDBField<infer D, infer _O> ? TailorDBField<Omit<D, "array"> & {
2477
+ array: Opt extends {
2478
+ array: true;
2479
+ } ? true : D["array"];
2480
+ }, FieldOutput$1<TailorToTs[D["type"]], Opt>> : never };
2481
+ /**
2482
+ * Omit specific fields from the type
2483
+ */
2484
+ omitFields<K$1 extends keyof Fields>(keys: K$1[]): Omit<Fields, K$1>;
2485
+ /**
2486
+ * Plugin attachments for this type
2487
+ */
2488
+ readonly plugins: PluginAttachment[];
2489
+ /**
2490
+ * Attach a plugin to this type
2491
+ * @param config - Plugin configuration in the format { pluginId: config }
2492
+ * @returns The type with the plugin attached
2493
+ */
2494
+ plugin<P$1 extends keyof PluginConfigs<keyof Fields & string>>(config: { [K in P$1]: PluginConfigs<keyof Fields & string>[K$1] }): TailorDBType$1<Fields, User>;
2495
+ }
2496
+ type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributeMap> = TailorDBType$1<Fields, User>;
2497
+ declare const idField: TailorDBField<{
2498
+ type: "uuid";
2499
+ array: false;
2500
+ }, string>;
2501
+ type idField = typeof idField;
2502
+ type DBType<F extends {
2503
+ id?: never;
2504
+ } & Record<string, TailorAnyDBField>> = TailorDBInstance<{
2505
+ id: idField;
2506
+ } & F>;
2507
+ /**
2508
+ * Creates a new database type with the specified fields.
2509
+ * An `id` field (UUID) is automatically added to every type.
2510
+ * @param name - The name of the type, or a tuple of [name, pluralForm]
2511
+ * @param fields - The field definitions for the type
2512
+ * @returns A new TailorDBType instance
2513
+ * @example
2514
+ * export const user = db.type("User", {
2515
+ * name: db.string(),
2516
+ * email: db.string(),
2517
+ * age: db.int({ optional: true }),
2518
+ * role: db.enum(["admin", "member"]),
2519
+ * ...db.fields.timestamps(),
2520
+ * });
2521
+ * // Always export both the value and type:
2522
+ * export type user = typeof user;
2523
+ */
2524
+ declare function dbType<const F extends {
2525
+ id?: never;
2526
+ } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
2527
+ /**
2528
+ * Creates a new database type with the specified fields and description.
2529
+ * An `id` field (UUID) is automatically added to every type.
2530
+ * @param name - The name of the type, or a tuple of [name, pluralForm]
2531
+ * @param description - A description of the type
2532
+ * @param fields - The field definitions for the type
2533
+ * @returns A new TailorDBType instance
2534
+ */
2535
+ declare function dbType<const F extends {
2536
+ id?: never;
2537
+ } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBType<F>;
2538
+ declare const db: {
2539
+ type: typeof dbType;
2540
+ uuid: typeof uuid;
2541
+ string: typeof string;
2542
+ bool: typeof bool;
2543
+ int: typeof int;
2544
+ float: typeof float;
2545
+ date: typeof date;
2546
+ datetime: typeof datetime;
2547
+ time: typeof time;
2548
+ enum: typeof _enum;
2549
+ object: typeof object;
2550
+ fields: {
2551
+ /**
2552
+ * Creates standard timestamp fields (createdAt, updatedAt) with auto-hooks.
2553
+ * createdAt is set on create, updatedAt is set on update.
2554
+ * @returns An object with createdAt and updatedAt fields
2555
+ * @example
2556
+ * const model = db.type("Model", {
2557
+ * name: db.string(),
2558
+ * ...db.fields.timestamps(),
2559
+ * });
2560
+ */
2561
+ timestamps: () => {
2562
+ createdAt: TailorDBField<{
2563
+ type: "datetime";
2564
+ array: false;
2565
+ hooks?: {
2566
+ create: true;
2567
+ update: false;
2568
+ } | undefined;
2569
+ serial: false;
2570
+ description: true;
2571
+ }, string | Date>;
2572
+ updatedAt: TailorDBField<{
2573
+ type: "datetime";
2574
+ array: false;
2575
+ hooks?: {
2576
+ create: false;
2577
+ update: true;
2578
+ } | undefined;
2579
+ serial: false;
2580
+ description: true;
2581
+ }, string | Date | null>;
2582
+ };
2583
+ };
2245
2584
  };
2246
- type AuthServiceInputLoose = AuthServiceInput<any, any, any, string, any>;
2247
- type AuthOwnConfig = DefinedAuth<string, AuthServiceInputLoose, string>;
2248
- type AuthConfig = AuthOwnConfig | AuthExternalConfig;
2249
2585
  //#endregion
2250
2586
  //#region src/parser/service/tailordb/types.d.ts
2251
2587
  /**
@@ -2438,5 +2774,5 @@ interface TailorDBType {
2438
2774
  files?: TailorDBTypeMetadata["files"];
2439
2775
  }
2440
2776
  //#endregion
2441
- export { unsafeAllowAllTypePermission as $, TailorDBField as A, PluginGeneratedExecutor as B, UserAttributeKey as C, unauthenticatedTailorUser as Ct, ValueOperand as D, UsernameFieldKey as E, TailorDBServiceInput as Et, Plugin as F, PluginOutput as G, PluginGeneratedResolver as H, PluginAttachment as I, TypePluginOutput as J, PluginProcessContext as K, PluginConfigs as L, TailorDBType$1 as M, db as N, TailorAnyDBField as O, NamespacePluginOutput as P, unsafeAllowAllGqlPermission as Q, PluginExecutorContext as R, TenantProviderConfig as S, TailorUser as St, UserAttributeMap as T, AllowedValuesOutput as Tt, PluginGeneratedType as U, PluginGeneratedExecutorWithFile as V, PluginNamespaceProcessContext as W, TailorTypeGqlPermission as X, PermissionCondition as Y, TailorTypePermission as Z, SCIMAttributeMapping as _, Env as _t, AuthInvoker as a, TailorFieldType as at, SCIMConfig as b, AttributeList as bt, BuiltinIdP as c, QueryType as ct, IdProviderConfig as d, ResolverInput as dt, ArrayFieldOutput as et, OAuth2ClientGrantType as f, ResolverServiceConfig as ft, SCIMAttribute as g, output as gt, SAML as h, JsonCompatible as ht, AuthExternalConfig as i, FieldOutput$1 as it, TailorDBInstance as j, TailorAnyDBType as k, DefinedAuth as l, Resolver as lt, OIDC as m, InferFieldsOutput as mt, TypeSourceInfoEntry as n, FieldMetadata as nt, AuthOwnConfig as o, TailorAnyField as ot, OAuth2ClientInput as p, ResolverServiceInput as pt, TailorDBTypeForPlugin as q, AuthConfig as r, FieldOptions as rt, AuthServiceInput as s, TailorField as st, TailorDBType as t, DefinedFieldMetadata as tt, IDToken as u, ResolverExternalConfig as ut, SCIMAttributeType as v, TailorEnv as vt, UserAttributeListKey as w, AllowedValues as wt, SCIMResource as x, AttributeMap as xt, SCIMAuthorization as y, TailorActor as yt, PluginExecutorContextBase as z };
2442
- //# sourceMappingURL=types-CZZBCaxB.d.mts.map
2777
+ export { OAuth2ClientGrantType as $, AuthAccessTokenTrigger as A, Resolver as At, ResolverExecutedTrigger as B, TailorActor as Bt, TypePluginOutput as C, FieldMetadata as Ct, ResolverReadyContext as D, TailorAnyField as Dt, ResolverNamespaceData as E, TailorFieldType as Et, FunctionOperation as F, InferFieldsOutput as Ft, AuthExternalConfig as G, AllowedValues as Gt, WebhookOperation as H, AttributeMap as Ht, GqlOperation as I, JsonCompatible as It, AuthServiceInput as J, AuthInvoker as K, AllowedValuesOutput as Kt, IdpUserTrigger as L, output as Lt, ExecutorInput as M, ResolverInput as Mt, ExecutorServiceConfig as N, ResolverServiceConfig as Nt, TailorDBNamespaceData as O, TailorField as Ot, ExecutorServiceInput as P, ResolverServiceInput as Pt, IdProviderConfig as Q, IncomingWebhookTrigger as R, Env as Rt, TailorDBTypeForPlugin as S, DefinedFieldMetadata as St, GeneratorResult as T, FieldOutput$1 as Tt, WorkflowOperation as U, TailorUser as Ut, ScheduleTriggerInput as V, AttributeList as Vt, AuthConfig as W, unauthenticatedTailorUser as Wt, DefinedAuth as X, BuiltinIdP as Y, IDToken as Z, PluginGeneratedResolver as _, TailorTypeGqlPermission as _t, TailorDBField as a, SCIMAttributeType as at, PluginOutput as b, unsafeAllowAllTypePermission as bt, db as c, SCIMResource as ct, PluginAttachment as d, UserAttributeListKey as dt, OAuth2ClientInput as et, PluginConfigs as f, UserAttributeMap as ft, PluginGeneratedExecutorWithFile as g, PermissionCondition as gt, PluginGeneratedExecutor as h, GeneratorConfig as ht, TailorAnyDBType as i, SCIMAttributeMapping as it, Executor as j, ResolverExternalConfig as jt, TailorDBReadyContext as k, QueryType as kt, NamespacePluginOutput as l, TenantProviderConfig as lt, PluginExecutorContextBase as m, ValueOperand as mt, TypeSourceInfoEntry as n, SAML as nt, TailorDBInstance as o, SCIMAuthorization as ot, PluginExecutorContext as p, UsernameFieldKey as pt, AuthOwnConfig as q, TailorDBServiceInput as qt, TailorAnyDBField as r, SCIMAttribute as rt, TailorDBType$1 as s, SCIMConfig as st, TailorDBType as t, OIDC as tt, Plugin as u, UserAttributeKey as ut, PluginGeneratedType as v, TailorTypePermission as vt, ExecutorReadyContext as w, FieldOptions as wt, PluginProcessContext as x, ArrayFieldOutput as xt, PluginNamespaceProcessContext as y, unsafeAllowAllGqlPermission as yt, RecordTrigger as z, TailorEnv as zt };
2778
+ //# sourceMappingURL=types-DdvTxFiD.d.mts.map