@tailor-platform/sdk 1.21.0 → 1.23.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 (82) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/application-CTQe2HSB.mjs +5723 -0
  3. package/dist/application-CTQe2HSB.mjs.map +1 -0
  4. package/dist/application-DdSu3baZ.mjs +8 -0
  5. package/dist/{brand-BZJCv6UY.mjs → brand-DyPrAzpM.mjs} +1 -1
  6. package/dist/{brand-BZJCv6UY.mjs.map → brand-DyPrAzpM.mjs.map} +1 -1
  7. package/dist/cli/index.d.mts +0 -1
  8. package/dist/cli/index.mjs +544 -57
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.d.mts +49 -9
  11. package/dist/cli/lib.mjs +15 -16
  12. package/dist/cli/lib.mjs.map +1 -1
  13. package/dist/cli/skills.d.mts +0 -1
  14. package/dist/configure/index.d.mts +4 -5
  15. package/dist/configure/index.mjs +15 -4
  16. package/dist/configure/index.mjs.map +1 -1
  17. package/dist/{enum-constants-CGVvu3dd.mjs → enum-constants-B5Nl-yzx.mjs} +1 -1
  18. package/dist/{enum-constants-CGVvu3dd.mjs.map → enum-constants-B5Nl-yzx.mjs.map} +1 -1
  19. package/dist/{file-utils-GX_tGWl4.mjs → file-utils-sEOwAdJ4.mjs} +1 -1
  20. package/dist/{file-utils-GX_tGWl4.mjs.map → file-utils-sEOwAdJ4.mjs.map} +1 -1
  21. package/dist/{index-oZXVKyfX.d.mts → index-BSXclved.d.mts} +2 -3
  22. package/dist/{index-BWVAwea4.d.mts → index-CO-jsOMb.d.mts} +2 -3
  23. package/dist/{index-CnHd6BNg.d.mts → index-CU2kZzKa.d.mts} +4 -11
  24. package/dist/{index-DxlmLUag.d.mts → index-DQlsfhpg.d.mts} +2 -3
  25. package/dist/{index-Dn61THJK.d.mts → index-lIALNMi_.d.mts} +2 -3
  26. package/dist/{interceptor-D8MeZOxX.mjs → interceptor-DiARwPfw.mjs} +1 -1
  27. package/dist/{interceptor-D8MeZOxX.mjs.map → interceptor-DiARwPfw.mjs.map} +1 -1
  28. package/dist/{job-2Q82qQ6N.mjs → job-CRavYLLk.mjs} +4 -24
  29. package/dist/job-CRavYLLk.mjs.map +1 -0
  30. package/dist/kysely/index.d.mts +2 -3
  31. package/dist/kysely/index.mjs +2 -2
  32. package/dist/kysely/index.mjs.map +1 -1
  33. package/dist/{kysely-type-Cpq5TNGY.mjs → kysely-type-CSlcwNFH.mjs} +1 -1
  34. package/dist/{kysely-type-Cpq5TNGY.mjs.map → kysely-type-CSlcwNFH.mjs.map} +1 -1
  35. package/dist/package-json-BI0ng3_5.mjs +3 -0
  36. package/dist/{package-json-3H5gfhA4.mjs → package-json-iVBhE5Ef.mjs} +1 -1
  37. package/dist/{package-json-3H5gfhA4.mjs.map → package-json-iVBhE5Ef.mjs.map} +1 -1
  38. package/dist/plugin/builtin/enum-constants/index.d.mts +2 -3
  39. package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
  40. package/dist/plugin/builtin/file-utils/index.d.mts +2 -3
  41. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  42. package/dist/plugin/builtin/kysely-type/index.d.mts +2 -3
  43. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  44. package/dist/plugin/builtin/seed/index.d.mts +2 -3
  45. package/dist/plugin/builtin/seed/index.mjs +1 -1
  46. package/dist/plugin/index.d.mts +1 -2
  47. package/dist/plugin/index.mjs +3 -3
  48. package/dist/plugin/index.mjs.map +1 -1
  49. package/dist/{update-9MTRN1UA.mjs → query-BLQBOaAM.mjs} +1199 -198
  50. package/dist/query-BLQBOaAM.mjs.map +1 -0
  51. package/dist/{schema-D5Cpd8fQ.mjs → schema-Cjm-OvPF.mjs} +2 -2
  52. package/dist/schema-Cjm-OvPF.mjs.map +1 -0
  53. package/dist/{seed-D-rYCN5F.mjs → seed-CXvCW3Xc.mjs} +2 -2
  54. package/dist/{seed-D-rYCN5F.mjs.map → seed-CXvCW3Xc.mjs.map} +1 -1
  55. package/dist/telemetry-BAxP8-PR.mjs +3 -0
  56. package/dist/{telemetry-DuBhnd0X.mjs → telemetry-C46fds1l.mjs} +2 -2
  57. package/dist/{telemetry-DuBhnd0X.mjs.map → telemetry-C46fds1l.mjs.map} +1 -1
  58. package/dist/{types-QKq1usl7.d.mts → types--G4ilVmx.d.mts} +8 -9
  59. package/dist/{types-ClK_HJ0G.mjs → types-CBTSg-LK.mjs} +1 -1
  60. package/dist/{types-ClK_HJ0G.mjs.map → types-CBTSg-LK.mjs.map} +1 -1
  61. package/dist/{types-C0o90Cmb.d.mts → types-IR-hw0-y.d.mts} +6 -3
  62. package/dist/utils/test/index.d.mts +42 -5
  63. package/dist/utils/test/index.mjs +78 -3
  64. package/dist/utils/test/index.mjs.map +1 -1
  65. package/docs/cli/function.md +83 -3
  66. package/docs/services/auth.md +2 -2
  67. package/package.json +9 -7
  68. package/postinstall.mjs +4 -14
  69. package/dist/application-CEv5c7TU.mjs +0 -102207
  70. package/dist/application-CEv5c7TU.mjs.map +0 -1
  71. package/dist/application-DiCzM9b0.mjs +0 -9
  72. package/dist/chunk-CqAI0b6X.mjs +0 -47
  73. package/dist/jiti-DfS9jItj.mjs +0 -4482
  74. package/dist/jiti-DfS9jItj.mjs.map +0 -1
  75. package/dist/job-2Q82qQ6N.mjs.map +0 -1
  76. package/dist/package-json-DTDAqRRJ.mjs +0 -3
  77. package/dist/schema-D5Cpd8fQ.mjs.map +0 -1
  78. package/dist/src-Bb1UVstT.mjs +0 -1038
  79. package/dist/src-Bb1UVstT.mjs.map +0 -1
  80. package/dist/telemetry-Dhzj9Ncm.mjs +0 -3
  81. package/dist/update-9MTRN1UA.mjs.map +0 -1
  82. package/dist/user-defined.d.ts +0 -13
@@ -1,4 +1,3 @@
1
- /// <reference path="./user-defined.d.ts" />
2
1
  import { z } from "zod";
3
2
  import { IsAny, NonEmptyObject } from "type-fest";
4
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -678,12 +677,12 @@ declare const TailorFieldSchema: z.ZodObject<{
678
677
  type: z.ZodEnum<{
679
678
  string: "string";
680
679
  boolean: "boolean";
681
- date: "date";
682
- enum: "enum";
683
680
  uuid: "uuid";
684
681
  integer: "integer";
685
682
  float: "float";
686
683
  decimal: "decimal";
684
+ enum: "enum";
685
+ date: "date";
687
686
  datetime: "datetime";
688
687
  time: "time";
689
688
  nested: "nested";
@@ -712,12 +711,12 @@ declare const ResolverSchema: z.ZodObject<{
712
711
  type: z.ZodEnum<{
713
712
  string: "string";
714
713
  boolean: "boolean";
715
- date: "date";
716
- enum: "enum";
717
714
  uuid: "uuid";
718
715
  integer: "integer";
719
716
  float: "float";
720
717
  decimal: "decimal";
718
+ enum: "enum";
719
+ date: "date";
721
720
  datetime: "datetime";
722
721
  time: "time";
723
722
  nested: "nested";
@@ -743,12 +742,12 @@ declare const ResolverSchema: z.ZodObject<{
743
742
  type: z.ZodEnum<{
744
743
  string: "string";
745
744
  boolean: "boolean";
746
- date: "date";
747
- enum: "enum";
748
745
  uuid: "uuid";
749
746
  integer: "integer";
750
747
  float: "float";
751
748
  decimal: "decimal";
749
+ enum: "enum";
750
+ date: "date";
752
751
  datetime: "datetime";
753
752
  time: "time";
754
753
  nested: "nested";
@@ -1028,7 +1027,7 @@ type HasAnyCondition<Level extends "record" | "gql", User extends object, Update
1028
1027
  /**
1029
1028
  * Type representing a permission condition that combines user attributes, record fields, and literal values using comparison operators.
1030
1029
  *
1031
- * The User type is extended by `user-defined.d.ts`, which is automatically generated when running `tailor-sdk generate`.
1030
+ * The User type is extended by `tailor.d.ts`, which is automatically generated when running `tailor-sdk generate`.
1032
1031
  * Attributes enabled in the config file's `auth.userProfile.attributes` (or
1033
1032
  * `auth.machineUserAttributes` when userProfile is omitted) become available as types.
1034
1033
  * @example
@@ -2810,4 +2809,4 @@ interface TailorDBType {
2810
2809
  }
2811
2810
  //#endregion
2812
2811
  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 };
2813
- //# sourceMappingURL=types-QKq1usl7.d.mts.map
2812
+ //# sourceMappingURL=types--G4ilVmx.d.mts.map
@@ -10,4 +10,4 @@ function isPluginGeneratedType(source) {
10
10
 
11
11
  //#endregion
12
12
  export { isPluginGeneratedType as t };
13
- //# sourceMappingURL=types-ClK_HJ0G.mjs.map
13
+ //# sourceMappingURL=types-CBTSg-LK.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-ClK_HJ0G.mjs","names":[],"sources":["../src/parser/service/tailordb/types.ts"],"sourcesContent":["import type { RelationType } from \"./relation\";\nimport type {\n DBFieldMetadataSchema,\n RawRelationConfigSchema,\n RawPermissionsSchema,\n TailorDBTypeSchema,\n TailorDBServiceConfig as TailorDBServiceConfigType,\n TailorDBTypeSettingsSchema,\n} from \"./schema\";\nimport type { GqlOperationsConfig } from \"@/configure/services/tailordb\";\nimport type { ValueOperand } from \"@/parser/service/auth/types\";\nimport type { z } from \"zod\";\n\nexport type { RelationType } from \"./relation\";\nexport type { TypeSourceInfo } from \"./type-parser\";\n\n// ========================================\n// Source info type for TailorDB types\n// ========================================\n\n/**\n * Source information for a user-defined TailorDB type.\n */\nexport interface UserDefinedTypeSource {\n /** File path to import from */\n filePath: string;\n /** Export name in the source file */\n exportName: string;\n /** Not present for user-defined types */\n pluginId?: never;\n}\n\n/**\n * Source information for a plugin-generated TailorDB type.\n */\nexport interface PluginGeneratedTypeSource {\n /** Not present for plugin-generated types */\n filePath?: never;\n /** Export name of the generated type */\n exportName: string;\n /** Plugin ID that generated this type */\n pluginId: string;\n /** Plugin import path for code generators */\n pluginImportPath: string;\n /** Original type's file path */\n originalFilePath: string;\n /** Original type's export name */\n originalExportName: string;\n /** Generated type kind for getGeneratedType() API (e.g., \"request\", \"step\") */\n generatedTypeKind?: string;\n /** Plugin config used to generate this type */\n pluginConfig?: unknown;\n /** Namespace where this type was generated */\n namespace?: string;\n}\n\n/**\n * Source information for a TailorDB type.\n * Discriminated union: use `pluginId` to distinguish between user-defined and plugin-generated types.\n */\nexport type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;\n\n/**\n * Type guard to check if source is plugin-generated\n * @param source - Type source info to check\n * @returns True if source is plugin-generated\n */\nexport function isPluginGeneratedType(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTypeSource {\n return source.pluginId !== undefined;\n}\n\nexport type {\n TailorAnyDBField,\n TailorAnyDBType,\n TailorDBField,\n DBFieldMetadata,\n Hook,\n TailorTypePermission,\n TailorTypeGqlPermission,\n GqlOperationsConfig,\n GqlOperations,\n} from \"@/configure/services/tailordb\";\nexport type {\n TailorDBServiceConfigInput,\n TailorDBServiceConfig,\n TailorDBExternalConfig,\n TailorDBServiceInput,\n} from \"./schema\";\n\n/**\n * Parsed and normalized settings for TailorDB type.\n * gqlOperations is normalized from alias to object format.\n * @public\n */\nexport type TailorDBTypeParsedSettings = z.output<typeof TailorDBTypeSettingsSchema>;\n\n/**\n * Migration configuration for TailorDB\n * @public\n */\nexport type TailorDBMigrationConfig = NonNullable<TailorDBServiceConfigType[\"migration\"]>;\n\nexport type TailorDBTypeSchemaOutput = z.output<typeof TailorDBTypeSchema>;\n\nexport type DBFieldMetadataOutput = z.output<typeof DBFieldMetadataSchema>;\nexport type RawRelationConfigOutput = z.output<typeof RawRelationConfigSchema>;\n\nexport type RawPermissions = z.output<typeof RawPermissionsSchema>;\n\nexport type TailorDBFieldOutput = {\n type: string;\n fields?: Record<string, TailorDBFieldOutput>;\n metadata: DBFieldMetadataOutput;\n rawRelation?: RawRelationConfigOutput;\n};\n\nexport interface Script {\n expr: string;\n}\n\nexport interface EnumValue {\n value: string;\n description?: string;\n}\n\ninterface OperatorValidateConfig {\n script: Script;\n errorMessage: string;\n}\n\ninterface OperatorFieldHook {\n create?: Script;\n update?: Script;\n}\n\n/**\n * Raw relation config stored in configure layer, processed in parser layer.\n * This is the serialized form of RelationConfig from schema.ts where\n * the TailorDBType reference is replaced with the type name string.\n */\nexport interface RawRelationConfig {\n type: RelationType;\n toward: {\n type: string;\n as?: string;\n key?: string;\n };\n backward?: string;\n}\n\nexport interface OperatorFieldConfig {\n type: string;\n required?: boolean;\n description?: string;\n allowedValues?: EnumValue[];\n array?: boolean;\n index?: boolean;\n unique?: boolean;\n vector?: boolean;\n foreignKey?: boolean;\n foreignKeyType?: string;\n foreignKeyField?: string;\n rawRelation?: RawRelationConfig;\n validate?: OperatorValidateConfig[];\n hooks?: OperatorFieldHook;\n serial?: {\n start: number;\n maxValue?: number;\n format?: string;\n };\n scale?: number;\n fields?: Record<string, OperatorFieldConfig>;\n}\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype StandardPermissionOperator = \"eq\" | \"ne\" | \"in\" | \"nin\" | \"hasAny\" | \"nhasAny\";\n\ntype UserOperand = {\n user: string;\n};\n\ntype RecordOperand<Update extends boolean = false> = Update extends true\n ? { oldRecord: string } | { newRecord: string }\n : { record: string };\n\nexport type PermissionOperand<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = UserOperand | ValueOperand | (Level extends \"record\" ? RecordOperand<Update> : never);\n\nexport type StandardPermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = readonly [\n PermissionOperand<Level, Update>,\n StandardPermissionOperator,\n PermissionOperand<Level, Update>,\n];\n\nexport type StandardActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = {\n conditions: readonly StandardPermissionCondition<Level, Update>[];\n description?: string;\n permit: \"allow\" | \"deny\";\n};\n\nexport type StandardTailorTypePermission = {\n create: readonly StandardActionPermission<\"record\", false>[];\n read: readonly StandardActionPermission<\"record\", false>[];\n update: readonly StandardActionPermission<\"record\", true>[];\n delete: readonly StandardActionPermission<\"record\", false>[];\n};\n\nexport type StandardGqlPermissionPolicy = {\n conditions: readonly StandardPermissionCondition<\"gql\">[];\n actions: readonly [\"all\"] | readonly GqlPermissionAction[];\n permit: \"allow\" | \"deny\";\n description?: string;\n};\n\nexport type StandardTailorTypeGqlPermission = readonly StandardGqlPermissionPolicy[];\n\nexport interface Permissions {\n record?: StandardTailorTypePermission;\n gql?: StandardTailorTypeGqlPermission;\n}\n\nexport interface TailorDBTypeMetadata {\n name: string;\n description?: string;\n settings?: {\n pluralForm?: string;\n aggregation?: boolean;\n bulkUpsert?: boolean;\n gqlOperations?: GqlOperationsConfig;\n publishEvents?: boolean;\n };\n permissions: RawPermissions;\n files: Record<string, string>;\n indexes?: Record<\n string,\n {\n fields: string[];\n unique?: boolean;\n }\n >;\n}\n\n/**\n * Parsed and normalized TailorDB field information\n */\nexport interface ParsedField {\n name: string;\n config: OperatorFieldConfig;\n relation?: {\n targetType: string;\n forwardName: string;\n backwardName: string;\n key: string;\n unique: boolean;\n };\n}\n\n/**\n * Parsed and normalized TailorDB relationship information\n */\nexport interface ParsedRelationship {\n name: string;\n targetType: string;\n targetField: string;\n sourceField: string;\n isArray: boolean;\n description: string;\n}\n\n/**\n * Parsed and normalized TailorDB type information\n */\nexport interface TailorDBType {\n name: string;\n pluralForm: string;\n description?: string;\n fields: Record<string, ParsedField>;\n forwardRelationships: Record<string, ParsedRelationship>;\n backwardRelationships: Record<string, ParsedRelationship>;\n settings: TailorDBTypeParsedSettings;\n permissions: Permissions;\n indexes?: TailorDBTypeMetadata[\"indexes\"];\n files?: TailorDBTypeMetadata[\"files\"];\n}\n"],"mappings":";;;;;;AAmEA,SAAgB,sBACd,QACqC;AACrC,QAAO,OAAO,aAAa"}
1
+ {"version":3,"file":"types-CBTSg-LK.mjs","names":[],"sources":["../src/parser/service/tailordb/types.ts"],"sourcesContent":["import type { RelationType } from \"./relation\";\nimport type {\n DBFieldMetadataSchema,\n RawRelationConfigSchema,\n RawPermissionsSchema,\n TailorDBTypeSchema,\n TailorDBServiceConfig as TailorDBServiceConfigType,\n TailorDBTypeSettingsSchema,\n} from \"./schema\";\nimport type { GqlOperationsConfig } from \"@/configure/services/tailordb\";\nimport type { ValueOperand } from \"@/parser/service/auth/types\";\nimport type { z } from \"zod\";\n\nexport type { RelationType } from \"./relation\";\nexport type { TypeSourceInfo } from \"./type-parser\";\n\n// ========================================\n// Source info type for TailorDB types\n// ========================================\n\n/**\n * Source information for a user-defined TailorDB type.\n */\nexport interface UserDefinedTypeSource {\n /** File path to import from */\n filePath: string;\n /** Export name in the source file */\n exportName: string;\n /** Not present for user-defined types */\n pluginId?: never;\n}\n\n/**\n * Source information for a plugin-generated TailorDB type.\n */\nexport interface PluginGeneratedTypeSource {\n /** Not present for plugin-generated types */\n filePath?: never;\n /** Export name of the generated type */\n exportName: string;\n /** Plugin ID that generated this type */\n pluginId: string;\n /** Plugin import path for code generators */\n pluginImportPath: string;\n /** Original type's file path */\n originalFilePath: string;\n /** Original type's export name */\n originalExportName: string;\n /** Generated type kind for getGeneratedType() API (e.g., \"request\", \"step\") */\n generatedTypeKind?: string;\n /** Plugin config used to generate this type */\n pluginConfig?: unknown;\n /** Namespace where this type was generated */\n namespace?: string;\n}\n\n/**\n * Source information for a TailorDB type.\n * Discriminated union: use `pluginId` to distinguish between user-defined and plugin-generated types.\n */\nexport type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;\n\n/**\n * Type guard to check if source is plugin-generated\n * @param source - Type source info to check\n * @returns True if source is plugin-generated\n */\nexport function isPluginGeneratedType(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTypeSource {\n return source.pluginId !== undefined;\n}\n\nexport type {\n TailorAnyDBField,\n TailorAnyDBType,\n TailorDBField,\n DBFieldMetadata,\n Hook,\n TailorTypePermission,\n TailorTypeGqlPermission,\n GqlOperationsConfig,\n GqlOperations,\n} from \"@/configure/services/tailordb\";\nexport type {\n TailorDBServiceConfigInput,\n TailorDBServiceConfig,\n TailorDBExternalConfig,\n TailorDBServiceInput,\n} from \"./schema\";\n\n/**\n * Parsed and normalized settings for TailorDB type.\n * gqlOperations is normalized from alias to object format.\n * @public\n */\nexport type TailorDBTypeParsedSettings = z.output<typeof TailorDBTypeSettingsSchema>;\n\n/**\n * Migration configuration for TailorDB\n * @public\n */\nexport type TailorDBMigrationConfig = NonNullable<TailorDBServiceConfigType[\"migration\"]>;\n\nexport type TailorDBTypeSchemaOutput = z.output<typeof TailorDBTypeSchema>;\n\nexport type DBFieldMetadataOutput = z.output<typeof DBFieldMetadataSchema>;\nexport type RawRelationConfigOutput = z.output<typeof RawRelationConfigSchema>;\n\nexport type RawPermissions = z.output<typeof RawPermissionsSchema>;\n\nexport type TailorDBFieldOutput = {\n type: string;\n fields?: Record<string, TailorDBFieldOutput>;\n metadata: DBFieldMetadataOutput;\n rawRelation?: RawRelationConfigOutput;\n};\n\nexport interface Script {\n expr: string;\n}\n\nexport interface EnumValue {\n value: string;\n description?: string;\n}\n\ninterface OperatorValidateConfig {\n script: Script;\n errorMessage: string;\n}\n\ninterface OperatorFieldHook {\n create?: Script;\n update?: Script;\n}\n\n/**\n * Raw relation config stored in configure layer, processed in parser layer.\n * This is the serialized form of RelationConfig from schema.ts where\n * the TailorDBType reference is replaced with the type name string.\n */\nexport interface RawRelationConfig {\n type: RelationType;\n toward: {\n type: string;\n as?: string;\n key?: string;\n };\n backward?: string;\n}\n\nexport interface OperatorFieldConfig {\n type: string;\n required?: boolean;\n description?: string;\n allowedValues?: EnumValue[];\n array?: boolean;\n index?: boolean;\n unique?: boolean;\n vector?: boolean;\n foreignKey?: boolean;\n foreignKeyType?: string;\n foreignKeyField?: string;\n rawRelation?: RawRelationConfig;\n validate?: OperatorValidateConfig[];\n hooks?: OperatorFieldHook;\n serial?: {\n start: number;\n maxValue?: number;\n format?: string;\n };\n scale?: number;\n fields?: Record<string, OperatorFieldConfig>;\n}\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype StandardPermissionOperator = \"eq\" | \"ne\" | \"in\" | \"nin\" | \"hasAny\" | \"nhasAny\";\n\ntype UserOperand = {\n user: string;\n};\n\ntype RecordOperand<Update extends boolean = false> = Update extends true\n ? { oldRecord: string } | { newRecord: string }\n : { record: string };\n\nexport type PermissionOperand<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = UserOperand | ValueOperand | (Level extends \"record\" ? RecordOperand<Update> : never);\n\nexport type StandardPermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = readonly [\n PermissionOperand<Level, Update>,\n StandardPermissionOperator,\n PermissionOperand<Level, Update>,\n];\n\nexport type StandardActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = {\n conditions: readonly StandardPermissionCondition<Level, Update>[];\n description?: string;\n permit: \"allow\" | \"deny\";\n};\n\nexport type StandardTailorTypePermission = {\n create: readonly StandardActionPermission<\"record\", false>[];\n read: readonly StandardActionPermission<\"record\", false>[];\n update: readonly StandardActionPermission<\"record\", true>[];\n delete: readonly StandardActionPermission<\"record\", false>[];\n};\n\nexport type StandardGqlPermissionPolicy = {\n conditions: readonly StandardPermissionCondition<\"gql\">[];\n actions: readonly [\"all\"] | readonly GqlPermissionAction[];\n permit: \"allow\" | \"deny\";\n description?: string;\n};\n\nexport type StandardTailorTypeGqlPermission = readonly StandardGqlPermissionPolicy[];\n\nexport interface Permissions {\n record?: StandardTailorTypePermission;\n gql?: StandardTailorTypeGqlPermission;\n}\n\nexport interface TailorDBTypeMetadata {\n name: string;\n description?: string;\n settings?: {\n pluralForm?: string;\n aggregation?: boolean;\n bulkUpsert?: boolean;\n gqlOperations?: GqlOperationsConfig;\n publishEvents?: boolean;\n };\n permissions: RawPermissions;\n files: Record<string, string>;\n indexes?: Record<\n string,\n {\n fields: string[];\n unique?: boolean;\n }\n >;\n}\n\n/**\n * Parsed and normalized TailorDB field information\n */\nexport interface ParsedField {\n name: string;\n config: OperatorFieldConfig;\n relation?: {\n targetType: string;\n forwardName: string;\n backwardName: string;\n key: string;\n unique: boolean;\n };\n}\n\n/**\n * Parsed and normalized TailorDB relationship information\n */\nexport interface ParsedRelationship {\n name: string;\n targetType: string;\n targetField: string;\n sourceField: string;\n isArray: boolean;\n description: string;\n}\n\n/**\n * Parsed and normalized TailorDB type information\n */\nexport interface TailorDBType {\n name: string;\n pluralForm: string;\n description?: string;\n fields: Record<string, ParsedField>;\n forwardRelationships: Record<string, ParsedRelationship>;\n backwardRelationships: Record<string, ParsedRelationship>;\n settings: TailorDBTypeParsedSettings;\n permissions: Permissions;\n indexes?: TailorDBTypeMetadata[\"indexes\"];\n files?: TailorDBTypeMetadata[\"files\"];\n}\n"],"mappings":";;;;;;AAmEA,SAAgB,sBACd,QACqC;AACrC,QAAO,OAAO,aAAa"}
@@ -1,5 +1,4 @@
1
- /// <reference path="./user-defined.d.ts" />
2
- import { P as ExecutorServiceInput, Pt as ResolverServiceInput, W as AuthConfig, Y as BuiltinIdP, qt as TailorDBServiceInput } from "./types-QKq1usl7.mjs";
1
+ import { P as ExecutorServiceInput, Pt as ResolverServiceInput, W as AuthConfig, Y as BuiltinIdP, qt as TailorDBServiceInput } from "./types--G4ilVmx.mjs";
3
2
  import { z } from "zod";
4
3
 
5
4
  //#region src/parser/service/workflow/types.d.ts
@@ -62,6 +61,7 @@ declare const IdPSchema: z.core.$ZodBranded<z.ZodObject<{
62
61
  passwordMaxLength: z.ZodOptional<z.ZodNumber>;
63
62
  allowedEmailDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
63
  allowGoogleOauth: z.ZodOptional<z.ZodBoolean>;
64
+ allowMicrosoftOauth: z.ZodOptional<z.ZodBoolean>;
65
65
  disablePasswordAuth: z.ZodOptional<z.ZodBoolean>;
66
66
  }, z.core.$strip>, z.ZodTransform<{
67
67
  useNonEmailIdentifier?: boolean | undefined;
@@ -74,6 +74,7 @@ declare const IdPSchema: z.core.$ZodBranded<z.ZodObject<{
74
74
  passwordMaxLength?: number | undefined;
75
75
  allowedEmailDomains?: string[] | undefined;
76
76
  allowGoogleOauth?: boolean | undefined;
77
+ allowMicrosoftOauth?: boolean | undefined;
77
78
  disablePasswordAuth?: boolean | undefined;
78
79
  }, {
79
80
  useNonEmailIdentifier?: boolean | undefined;
@@ -86,6 +87,7 @@ declare const IdPSchema: z.core.$ZodBranded<z.ZodObject<{
86
87
  passwordMaxLength?: number | undefined;
87
88
  allowedEmailDomains?: string[] | undefined;
88
89
  allowGoogleOauth?: boolean | undefined;
90
+ allowMicrosoftOauth?: boolean | undefined;
89
91
  disablePasswordAuth?: boolean | undefined;
90
92
  }>>>;
91
93
  publishUserEvents: z.ZodOptional<z.ZodBoolean>;
@@ -162,6 +164,7 @@ declare function defineIdp<const TClients extends string[]>(name: string, config
162
164
  passwordMaxLength?: number | undefined;
163
165
  allowedEmailDomains?: string[] | undefined;
164
166
  allowGoogleOauth?: boolean | undefined;
167
+ allowMicrosoftOauth?: boolean | undefined;
165
168
  disablePasswordAuth?: boolean | undefined;
166
169
  } | undefined;
167
170
  readonly publishUserEvents?: boolean | undefined;
@@ -239,4 +242,4 @@ interface AppConfig<Auth extends AuthConfig = AuthConfig, Idp extends IdPConfig[
239
242
  }
240
243
  //#endregion
241
244
  export { IdPGqlOperationsAliasQuery as a, StaticWebsiteConfig as c, WorkflowServiceInput as d, IdPGqlOperations as i, defineStaticWebSite as l, IdPConfig as n, IdPGqlOperationsConfig as o, IdPExternalConfig as r, defineIdp as s, AppConfig as t, WorkflowServiceConfig as u };
242
- //# sourceMappingURL=types-C0o90Cmb.d.mts.map
245
+ //# sourceMappingURL=types-IR-hw0-y.d.mts.map
@@ -1,9 +1,46 @@
1
- /// <reference path="./../../user-defined.d.ts" />
2
- import { Ot as TailorField, s as TailorDBType } from "../../types-QKq1usl7.mjs";
3
- import "../../types-C0o90Cmb.mjs";
4
- import { G as WORKFLOW_TEST_USER_KEY, W as WORKFLOW_TEST_ENV_KEY, n as output } from "../../index-CnHd6BNg.mjs";
1
+ import { Ot as TailorField, s as TailorDBType } from "../../types--G4ilVmx.mjs";
2
+ import "../../types-IR-hw0-y.mjs";
3
+ import { W as WORKFLOW_TEST_ENV_KEY, n as output } from "../../index-CU2kZzKa.mjs";
5
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
5
 
6
+ //#region src/utils/test/mock.d.ts
7
+ type MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;
8
+ type QueryResolver = (query: string, params: unknown[]) => unknown[];
9
+ type JobHandler = (jobName: string, args: unknown) => unknown;
10
+ /**
11
+ * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.
12
+ * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.
13
+ * @returns Object containing arrays of executed queries and created clients for assertions.
14
+ */
15
+ declare function setupTailordbMock(resolver?: QueryResolver): {
16
+ executedQueries: {
17
+ query: string;
18
+ params: unknown[];
19
+ }[];
20
+ createdClients: {
21
+ namespace?: string;
22
+ ended: boolean;
23
+ }[];
24
+ };
25
+ /**
26
+ * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.
27
+ * @param handler - Function that handles triggered job calls and returns results.
28
+ * @returns Object containing an array of triggered jobs for assertions.
29
+ */
30
+ declare function setupWorkflowMock(handler: JobHandler): {
31
+ triggeredJobs: {
32
+ jobName: string;
33
+ args: unknown;
34
+ }[];
35
+ };
36
+ /**
37
+ * Creates a function that imports a bundled JS file and returns its `main` export.
38
+ * Used to test bundled output from `apply --buildOnly`.
39
+ * @param baseDir - Base directory where bundled files are located.
40
+ * @returns An async function that takes a relative path and returns the `main` function.
41
+ */
42
+ declare function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction>;
43
+ //#endregion
7
44
  //#region src/utils/test/index.d.ts
8
45
  /** Represents an unauthenticated user in the Tailor platform. */
9
46
  declare const unauthenticatedTailorUser: {
@@ -41,5 +78,5 @@ declare function createStandardSchema<T = Record<string, unknown>>(schemaType: T
41
78
  };
42
79
  };
43
80
  //#endregion
44
- export { WORKFLOW_TEST_ENV_KEY, WORKFLOW_TEST_USER_KEY, createStandardSchema, createTailorDBHook, unauthenticatedTailorUser };
81
+ export { WORKFLOW_TEST_ENV_KEY, createImportMain, createStandardSchema, createTailorDBHook, setupTailordbMock, setupWorkflowMock, unauthenticatedTailorUser };
45
82
  //# sourceMappingURL=index.d.mts.map
@@ -1,6 +1,81 @@
1
- import { n as WORKFLOW_TEST_USER_KEY, t as WORKFLOW_TEST_ENV_KEY } from "../../job-2Q82qQ6N.mjs";
2
- import "../../brand-BZJCv6UY.mjs";
1
+ import "../../brand-DyPrAzpM.mjs";
2
+ import { t as WORKFLOW_TEST_ENV_KEY } from "../../job-CRavYLLk.mjs";
3
+ import { pathToFileURL } from "node:url";
4
+ import * as path from "node:path";
3
5
 
6
+ //#region src/utils/test/mock.ts
7
+ const GlobalThis = globalThis;
8
+ /**
9
+ * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.
10
+ * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.
11
+ * @returns Object containing arrays of executed queries and created clients for assertions.
12
+ */
13
+ function setupTailordbMock(resolver = () => []) {
14
+ const executedQueries = [];
15
+ const createdClients = [];
16
+ class MockTailordbClient {
17
+ record;
18
+ constructor({ namespace }) {
19
+ this.record = {
20
+ namespace,
21
+ ended: false
22
+ };
23
+ createdClients.push(this.record);
24
+ }
25
+ async connect() {}
26
+ async end() {
27
+ this.record.ended = true;
28
+ }
29
+ async queryObject(query, params = []) {
30
+ executedQueries.push({
31
+ query,
32
+ params
33
+ });
34
+ return { rows: resolver(query, params) ?? [] };
35
+ }
36
+ }
37
+ GlobalThis.tailordb = { Client: MockTailordbClient };
38
+ return {
39
+ executedQueries,
40
+ createdClients
41
+ };
42
+ }
43
+ /**
44
+ * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.
45
+ * @param handler - Function that handles triggered job calls and returns results.
46
+ * @returns Object containing an array of triggered jobs for assertions.
47
+ */
48
+ function setupWorkflowMock(handler) {
49
+ const triggeredJobs = [];
50
+ GlobalThis.tailor = {
51
+ ...GlobalThis.tailor,
52
+ workflow: { triggerJobFunction: (jobName, args) => {
53
+ triggeredJobs.push({
54
+ jobName,
55
+ args
56
+ });
57
+ return handler(jobName, args);
58
+ } }
59
+ };
60
+ return { triggeredJobs };
61
+ }
62
+ /**
63
+ * Creates a function that imports a bundled JS file and returns its `main` export.
64
+ * Used to test bundled output from `apply --buildOnly`.
65
+ * @param baseDir - Base directory where bundled files are located.
66
+ * @returns An async function that takes a relative path and returns the `main` function.
67
+ */
68
+ function createImportMain(baseDir) {
69
+ return async (relativePath) => {
70
+ const fileUrl = pathToFileURL(path.join(baseDir, relativePath));
71
+ fileUrl.searchParams.set("v", `${Date.now()}-${Math.random()}`);
72
+ const main = (await import(fileUrl.href)).main;
73
+ if (typeof main !== "function") throw new Error(`Expected "main" to be a function in ${relativePath}, got ${typeof main}`);
74
+ return main;
75
+ };
76
+ }
77
+
78
+ //#endregion
4
79
  //#region src/utils/test/index.ts
5
80
  /** Represents an unauthenticated user in the Tailor platform. */
6
81
  const unauthenticatedTailorUser = {
@@ -63,5 +138,5 @@ function createStandardSchema(schemaType, hook) {
63
138
  }
64
139
 
65
140
  //#endregion
66
- export { WORKFLOW_TEST_ENV_KEY, WORKFLOW_TEST_USER_KEY, createStandardSchema, createTailorDBHook, unauthenticatedTailorUser };
141
+ export { WORKFLOW_TEST_ENV_KEY, createImportMain, createStandardSchema, createTailorDBHook, setupTailordbMock, setupWorkflowMock, unauthenticatedTailorUser };
67
142
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY, WORKFLOW_TEST_USER_KEY } from \"@/configure/services/workflow/job\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n hooked[key] = createTailorDBHook({ fields: field.fields } as any)(\n (data as Record<string, unknown>)[key],\n );\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;;;;AAQA,MAAa,4BAA4B;CACvC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,YAAY;CACZ,eAAe,EAAE;CAClB;;;;;;;;;;AAYD,SAAgB,mBAAqD,MAAS;AAC5E,SAAQ,SAAkB;AACxB,SAAO,OAAO,QAAQ,KAAK,OAAO,CAAC,QAChC,QAAQ,CAAC,KAAK,WAAW;GAExB,MAAM,QAAQ;AACd,OAAI,QAAQ,KAIV,QAAO,QADL,QAAQ,OAAO,SAAS,WAAY,KAAiC,OAAO,WAClD,OAAO,YAAY;YACtC,MAAM,SAAS,SAExB,QAAO,OAAO,mBAAmB,EAAE,QAAQ,MAAM,QAAQ,CAAQ,CAC9D,KAAiC,KACnC;YACQ,MAAM,SAAS,OAAO,QAAQ;AACvC,WAAO,OAAO,MAAM,SAAS,MAAM,OAAO;KACxC,OAAQ,KAAiC;KACnC;KACN,MAAM;KACP,CAAC;AACF,QAAI,OAAO,gBAAgB,KACzB,QAAO,OAAO,OAAO,KAAK,aAAa;cAEhC,QAAQ,OAAO,SAAS,SACjC,QAAO,OAAQ,KAAiC;AAElD,UAAO;KAET,EAAE,CACH;;;;;;;;;;;AAYL,SAAgB,qBAEd,YACA,MACA;AACA,QAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,MAAM;GAC1B,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;IACP,CAAC;AACF,OAAI,OAAO,OACT,QAAO;AAET,UAAO,EAAE,OAAO,QAAa;;EAEhC,EACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n triggerJobFunction: (jobName: string, args: unknown) => unknown;\n };\n };\n}\n\nconst GlobalThis = globalThis as TailordbGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) ?? [] };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n triggerJobFunction: (jobName: string, args: unknown) => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY } from \"@/configure/services/workflow/job\";\nexport { setupTailordbMock, setupWorkflowMock, createImportMain } from \"./mock\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n hooked[key] = createTailorDBHook({ fields: field.fields } as any)(\n (data as Record<string, unknown>)[key],\n );\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;;;;;AAyBA,MAAM,aAAa;;;;;;AAOnB,SAAgB,kBAAkB,iBAAgC,EAAE,EAGlE;CACA,MAAM,kBAA0D,EAAE;CAClE,MAAM,iBAA2D,EAAE;CAEnE,MAAM,mBAAmB;EACvB,AAAQ;EAER,YAAY,EAAE,aAAqC;AACjD,QAAK,SAAS;IAAE;IAAW,OAAO;IAAO;AACzC,kBAAe,KAAK,KAAK,OAAO;;EAGlC,MAAM,UAAyB;EAI/B,MAAM,MAAqB;AACzB,QAAK,OAAO,QAAQ;;EAGtB,MAAM,YAAY,OAAe,SAAoB,EAAE,EAAgC;AACrF,mBAAgB,KAAK;IAAE;IAAO;IAAQ,CAAC;AACvC,UAAO,EAAE,MAAM,SAAS,OAAO,OAAO,IAAI,EAAE,EAAE;;;AAIlD,YAAW,WAAW,EACpB,QAAQ,oBACT;AAED,QAAO;EAAE;EAAiB;EAAgB;;;;;;;AAQ5C,SAAgB,kBAAkB,SAEhC;CACA,MAAM,gBAAsD,EAAE;AAE9D,YAAW,SAAS;EAClB,GAAG,WAAW;EACd,UAAU,EACR,qBAAqB,SAAiB,SAAkB;AACtD,iBAAc,KAAK;IAAE;IAAS;IAAM,CAAC;AACrC,UAAO,QAAQ,SAAS,KAAK;KAEhC;EACF;AAED,QAAO,EAAE,eAAe;;;;;;;;AAS1B,SAAgB,iBAAiB,SAAkE;AACjG,QAAO,OAAO,iBAAgD;EAC5D,MAAM,UAAU,cAAc,KAAK,KAAK,SAAS,aAAa,CAAC;AAC/D,UAAQ,aAAa,IAAI,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,GAAG;EAE/D,MAAM,QADS,MAAM,OAAO,QAAQ,OAChB;AACpB,MAAI,OAAO,SAAS,WAClB,OAAM,IAAI,MAAM,uCAAuC,aAAa,QAAQ,OAAO,OAAO;AAE5F,SAAO;;;;;;;ACjGX,MAAa,4BAA4B;CACvC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,YAAY;CACZ,eAAe,EAAE;CAClB;;;;;;;;;;AAYD,SAAgB,mBAAqD,MAAS;AAC5E,SAAQ,SAAkB;AACxB,SAAO,OAAO,QAAQ,KAAK,OAAO,CAAC,QAChC,QAAQ,CAAC,KAAK,WAAW;GAExB,MAAM,QAAQ;AACd,OAAI,QAAQ,KAIV,QAAO,QADL,QAAQ,OAAO,SAAS,WAAY,KAAiC,OAAO,WAClD,OAAO,YAAY;YACtC,MAAM,SAAS,SAExB,QAAO,OAAO,mBAAmB,EAAE,QAAQ,MAAM,QAAQ,CAAQ,CAC9D,KAAiC,KACnC;YACQ,MAAM,SAAS,OAAO,QAAQ;AACvC,WAAO,OAAO,MAAM,SAAS,MAAM,OAAO;KACxC,OAAQ,KAAiC;KACnC;KACN,MAAM;KACP,CAAC;AACF,QAAI,OAAO,gBAAgB,KACzB,QAAO,OAAO,OAAO,KAAK,aAAa;cAEhC,QAAQ,OAAO,SAAS,SACjC,QAAO,OAAQ,KAAiC;AAElD,UAAO;KAET,EAAE,CACH;;;;;;;;;;;AAYL,SAAgB,qBAEd,YACA,MACA;AACA,QAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,MAAM;GAC1B,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;IACP,CAAC;AACF,OAAI,OAAO,OACT,QAAO;AAET,UAAO,EAAE,OAAO,QAAa;;EAEhC,EACF"}
@@ -28,9 +28,10 @@ tailor-sdk function [command]
28
28
 
29
29
  **Commands**
30
30
 
31
- | Command | Description |
32
- | --------------------------------- | ------------------------------------ |
33
- | [`function logs`](#function-logs) | List or get function execution logs. |
31
+ | Command | Description |
32
+ | ----------------------------------------- | --------------------------------------------------------------- |
33
+ | [`function logs`](#function-logs) | List or get function execution logs. |
34
+ | [`function test-run`](#function-test-run) | Run a function on the Tailor Platform server without deploying. |
34
35
 
35
36
  <!-- politty:command:function:subcommands:end -->
36
37
  <!-- politty:command:function logs:heading:start -->
@@ -90,3 +91,82 @@ tailor-sdk function logs <execution-id>
90
91
  tailor-sdk function logs --json
91
92
  tailor-sdk function logs <execution-id> --json
92
93
  ```
94
+
95
+ <!-- politty:command:function test-run:heading:start -->
96
+
97
+ ### function test-run
98
+
99
+ <!-- politty:command:function test-run:heading:end -->
100
+ <!-- politty:command:function test-run:description:start -->
101
+
102
+ Run a function on the Tailor Platform server without deploying.
103
+
104
+ <!-- politty:command:function test-run:description:end -->
105
+ <!-- politty:command:function test-run:usage:start -->
106
+
107
+ **Usage**
108
+
109
+ ```
110
+ tailor-sdk function test-run [options] <file>
111
+ ```
112
+
113
+ <!-- politty:command:function test-run:usage:end -->
114
+ <!-- politty:command:function test-run:arguments:start -->
115
+
116
+ **Arguments**
117
+
118
+ | Argument | Description | Required |
119
+ | -------- | ------------------------- | -------- |
120
+ | `file` | Path to the function file | Yes |
121
+
122
+ <!-- politty:command:function test-run:arguments:end -->
123
+ <!-- politty:command:function test-run:options:start -->
124
+
125
+ **Options**
126
+
127
+ | Option | Alias | Description | Required | Default |
128
+ | ------------------------------- | ----- | ------------------------------------------------------------------------ | -------- | -------------------- |
129
+ | `--json` | `-j` | Output as JSON | No | `false` |
130
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - |
131
+ | `--profile <PROFILE>` | `-p` | Workspace profile | No | - |
132
+ | `--name <NAME>` | `-n` | Workflow job name to run (matches the `name` field of createWorkflowJob) | No | - |
133
+ | `--arg <ARG>` | `-a` | JSON argument to pass to the function | No | - |
134
+ | `--machine-user <MACHINE_USER>` | `-m` | Machine user name for authentication | No | - |
135
+ | `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` |
136
+
137
+ <!-- politty:command:function test-run:options:end -->
138
+ <!-- politty:command:function test-run:examples:start -->
139
+
140
+ **Examples**
141
+
142
+ **Run a resolver with input arguments**
143
+
144
+ ```bash
145
+ $ tailor-sdk function test-run resolvers/add.ts --arg '{"input":{"a":1,"b":2}}'
146
+ ```
147
+
148
+ **Run a specific workflow job by name**
149
+
150
+ ```bash
151
+ $ tailor-sdk function test-run workflows/sample.ts --name validate-order
152
+ ```
153
+
154
+ **Run a pre-bundled .js file directly**
155
+
156
+ ```bash
157
+ $ tailor-sdk function test-run .tailor-sdk/resolvers/add.js --arg '{"input":{"a":1,"b":2}}'
158
+ ```
159
+
160
+ <!-- politty:command:function test-run:examples:end -->
161
+ <!-- politty:command:function test-run:notes:start -->
162
+
163
+ **Notes**
164
+
165
+ You can pass either a source file (`.ts`) or a pre-bundled file (`.js`).
166
+ When a `.js` file is provided, detection and bundling are skipped and the file is executed as-is.
167
+
168
+ > [!WARNING]
169
+ > Workflow job `.trigger()` calls do not work in test-run mode.
170
+ > Triggered jobs are not executed; only the target job's `body` function runs in isolation.
171
+
172
+ <!-- politty:command:function test-run:notes:end -->
@@ -139,7 +139,7 @@ body: (context) => {
139
139
  When you want to use machine users without defining a `userProfile`, define `machineUserAttributes` instead. These attributes are used for:
140
140
 
141
141
  - type-safe `machineUsers[*].attributes`
142
- - `context.user.attributes` typing (via `user-defined.d.ts`)
142
+ - `context.user.attributes` typing (via `tailor.d.ts`)
143
143
 
144
144
  ```typescript
145
145
  import { defineAuth, t } from "@tailor-platform/sdk";
@@ -158,7 +158,7 @@ export const auth = defineAuth("my-auth", {
158
158
  });
159
159
  ```
160
160
 
161
- To update types in `user-defined.d.ts`, run:
161
+ To update types in `tailor.d.ts`, run:
162
162
 
163
163
  ```bash
164
164
  tailor-sdk generate
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/tailor-platform/sdk.git",
8
+ "url": "git+https://github.com/tailor-platform/sdk.git",
9
9
  "directory": "packages/sdk"
10
10
  },
11
11
  "bin": {
@@ -71,6 +71,7 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
+ "@0no-co/graphql.web": "1.2.0",
74
75
  "@badgateway/oauth2-client": "3.3.1",
75
76
  "@bufbuild/protobuf": "2.10.2",
76
77
  "@connectrpc/connect": "2.1.1",
@@ -92,6 +93,7 @@
92
93
  "date-fns": "4.1.0",
93
94
  "es-toolkit": "^1.44.0",
94
95
  "find-up-simple": "1.0.1",
96
+ "globals": "17.0.0",
95
97
  "inflection": "3.0.2",
96
98
  "kysely": "0.28.10",
97
99
  "madge": "8.0.0",
@@ -102,8 +104,9 @@
102
104
  "oxc-parser": "0.108.0",
103
105
  "p-limit": "7.2.0",
104
106
  "pathe": "2.0.3",
107
+ "pgsql-ast-parser": "^12.0.2",
105
108
  "pkg-types": "2.3.0",
106
- "politty": "^0.4.0",
109
+ "politty": "^0.4.4",
107
110
  "rolldown": "1.0.0-beta.60",
108
111
  "serve": "14.2.5",
109
112
  "std-env": "3.10.0",
@@ -124,11 +127,9 @@
124
127
  "@types/node": "24.10.9",
125
128
  "@typescript/native-preview": "7.0.0-dev.20260118.1",
126
129
  "@vitest/coverage-v8": "4.0.17",
127
- "cross-env": "10.1.0",
128
130
  "eslint": "9.39.2",
129
131
  "eslint-plugin-jsdoc": "62.1.0",
130
132
  "eslint-plugin-oxlint": "1.39.0",
131
- "globals": "17.0.0",
132
133
  "oxlint": "1.39.0",
133
134
  "oxlint-tsgolint": "0.11.1",
134
135
  "sonda": "0.10.1",
@@ -144,7 +145,7 @@
144
145
  "test:coverage": "vitest --coverage",
145
146
  "docs:check": "vitest run --project=unit src/cli/docs.test.ts",
146
147
  "docs:update": "POLITTY_DOCS_UPDATE=true vitest run --project=unit src/cli/docs.test.ts",
147
- "build": "tsdown && cross-env FORCE_CREATE=1 node postinstall.mjs",
148
+ "build": "tsdown",
148
149
  "lint": "oxlint --type-aware . && eslint --cache .",
149
150
  "lint:fix": "oxlint --type-aware . --fix && eslint --cache . --fix",
150
151
  "typecheck": "tsc --noEmit",
@@ -154,6 +155,7 @@
154
155
  "prepublish": "pnpm run build",
155
156
  "postinstall": "node postinstall.mjs",
156
157
  "measure:bundle": "node ../../scripts/measure-bundle-size-sonda.js",
157
- "knip": "knip"
158
+ "knip": "knip",
159
+ "publint": "publint --strict"
158
160
  }
159
161
  }
package/postinstall.mjs CHANGED
@@ -11,26 +11,15 @@ const DEFAULT_CONFIG_FILENAME = "tailor.config.ts";
11
11
 
12
12
  async function install() {
13
13
  const cwd = process.env.INIT_CWD || process.cwd();
14
- const forceCreate = process.env.FORCE_CREATE === "1";
15
14
 
16
- // Skip if running in the tailor-sdk package itself (unless forced)
17
- if (!forceCreate && (cwd === __dirname || cwd === resolve(__dirname, "..", ".."))) {
15
+ // Skip if running in the tailor-sdk package itself
16
+ if (cwd === __dirname || cwd === resolve(__dirname, "..", "..")) {
18
17
  console.log("⚠️ Skipping postinstall in tailor-sdk package itself");
19
18
  return;
20
19
  }
21
20
 
22
21
  console.log("🔧 Initializing Tailor Platform SDK type definitions...");
23
22
 
24
- // Create user-defined.d.ts in the dist directory
25
- const distDir = resolve(__dirname, "dist");
26
- const pluginTypesPath = resolve(distDir, "user-defined.d.ts");
27
-
28
- // Check if dist directory exists
29
- if (!existsSync(distDir)) {
30
- console.log("⚠️ Dist directory not found, skipping type initialization");
31
- return;
32
- }
33
-
34
23
  // Try to find and load the user's tailor.config.ts
35
24
  // Priority: env/config > search parent directories
36
25
  const configPath = process.env.TAILOR_PLATFORM_SDK_CONFIG_PATH
@@ -55,7 +44,8 @@ async function install() {
55
44
  }
56
45
  }
57
46
 
58
- // Create empty type definition file as fallback
47
+ // Create empty type definition file as fallback (in cwd, next to where config would be)
48
+ const pluginTypesPath = resolve(cwd, "tailor.d.ts");
59
49
  const initialContent = `// This file is auto-generated by @tailor-platform/sdk
60
50
  // Do not edit this file manually
61
51
  // Regenerated automatically when running 'tailor-sdk apply' or 'tailor-sdk generate'